ReMe/reme_studio/client/tests/agent-resources.test.ts
jinliyl 524b1b6908
feat(studio): unify the workbench and proactive runtime (#764)
* fix(proactive): simplify round files and restore failed summaries

* fix(proactive): validate document-relative Markdown links

* feat(proactive_agent): implement v2 daily record workflow with single-file decision

- Add ProactiveAgentStepV2 class to support single daily note decision and reminder
- Introduce RoundOutputs for v2 round file tracking, and keep RoundArtifacts for v1 summary backup
- Refactor AgentOutbox to support both v1 standalone reminder files and v2 daily reminder records
- Add proactive_record utilities to parse and validate v2 daily record frontmatter and metadata
- Enhance proactive_agent to prepare, read, and manage artifacts for both v1 and v2 flows
- Add configuration profile proactive_v2 to enable new workflow with backward compatibility
- Update proactive.yaml and reactive proactive_agent_step configuration comment for easy switching
- Provide extensive schema validation for v2 reminders ensuring priority and message consistency
- Document v2 workflow and usage in English and Chinese runtime docs
- Add unit tests for v2 step verifying single file output and proper decision handling

* refactor(agent/runtime): replace ReminderRef with string keys and simplify reminder handling

- Remove ReminderRef model and switch to using workspace-relative string keys for reminders
- Simplify AgentOutbox to read, write, and manage reminders keyed by strings
- Change file locking and version checking to protect concurrent edits on daily record files
- Replace legacy and v2 reminder file handling with unified ReminderFiles storage
- Adjust ChatNotifications to operate with the new key scheme and update pending/read sets
- Refactor RoundOutputs to RoundRecord for safer round record tracking and rollback
- Remove unused ProactiveRunResult and related references from imports and exports
- Update InboxWakeRequest, AgentReminder, and related models for consistent ID and path validation
- Adjust proactive agent runtime and local runtime to check reminder versions before commit
- Correct language and docs to describe reminders as daily records instead of separate files
- Clean up roles of inbox and outbox for reminder ownership, delivery, and acknowledgments

* fix(proactive): serialize round commits and align desktop reminders

* refactor(proactive): unify task triggers in Proactive Runtime

* fix(proactive): bound reminder payloads and simplify receipts

* refactor(studio): share workbench and simplify proactive delivery

* fix(studio): update and centralize build dependencies

* fix(proactive): guard draft repair and verify Studio deployments

* chore(docs): update source-map-js

* feat(release): support publishing selected artifacts from a tag

* chore(studio): remove the public playground

* refactor: simplify reminders and release workflows

* fix: preserve proactive records and align release provenance

* test(proactive): remove brittle prompt and preset assertions

* fix(proactive): register reminders after input acknowledgement

* feat(notebook): list projects across todos and ideas

* feat(studio): connect mobile apps to configurable ReMe services

* fix(proactive): reserve registered reminder paths

* fix(studio): request Android local network access

* fix(proactive): reserve reminder paths referenced by receipts
2026-11-23 17:19:21 +08:00

128 lines
3.4 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { resolveWorkspaceLink } from "../src/links.ts";
import { requestWorkspace } from "../src/workspace.ts";
import type { ReMeClient } from "../src/reme-client.ts";
test("workspace links resolve documents, wikilinks and contained native paths", () => {
assert.equal(
resolveWorkspaceLink("../detail.md", "daily/2026-11-15/summary.md"),
"daily/detail.md",
);
assert.equal(
resolveWorkspaceLink(
"#reme-file=daily%2Freport.md",
"reme_agents/Remy/MEMORY.md",
),
"daily/report.md",
);
assert.equal(
resolveWorkspaceLink(
"file:///work/reme/resource/image.png",
"",
"/work/reme",
),
"resource/image.png",
);
assert.equal(
resolveWorkspaceLink("/work/reme/daily/report.md#result", "", "/work/reme"),
"daily/report.md",
);
assert.equal(resolveWorkspaceLink("#reme-file=note"), "note.md");
assert.equal(
resolveWorkspaceLink("C:\\work\\reme\\daily\\note.md", "", "C:/work/reme"),
"daily/note.md",
);
assert.equal(
resolveWorkspaceLink(
"file:///C:/Work/ReMe/daily/100%25%23.md",
"",
"c:/work/reme",
),
"daily/100%#.md",
);
assert.equal(
resolveWorkspaceLink(
"file:///work/reme/daily/report%2520.md",
"",
"/work/reme",
),
"daily/report%20.md",
);
assert.equal(
resolveWorkspaceLink("file:///daily/report.md", "", "/"),
"daily/report.md",
);
for (const url of [
"../outside.md",
"/work/other/note.md",
"/work/reme/../outside.md",
"file://remote/work/reme/note.md",
"javascript:alert(1)",
"~/.env",
"%00",
"#heading",
"%E0%A4%A",
]) {
assert.equal(resolveWorkspaceLink(url, "", "/work/reme"), undefined, url);
}
});
test("workspace resource requests use the new scoped contracts and reject retired requests", async () => {
const calls: [string, unknown][] = [];
const client = {
request: async (job: string, body: unknown) => {
calls.push([job, body]);
return { success: true, answer: {}, metadata: {} };
},
} as unknown as ReMeClient;
const signal = new AbortController().signal;
await requestWorkspace(
client,
{ type: "outbox", agentName: "finance", state: "pending" },
signal,
);
await requestWorkspace(
client,
{ type: "inbox", agentName: "任务", state: "processing", offset: 20 },
signal,
);
const record = `daily/${"archive/".repeat(16)}2026-11-22/finance_090000.md`;
await requestWorkspace(
client,
{ type: "reminder", agentName: "finance", id: record },
signal,
);
assert.deepEqual(calls, [
[
"list_task_reminders",
{ agent_name: "finance", state: "pending", offset: 0, limit: 20 },
],
[
"list_agent_inbox",
{ agent_name: "任务", state: "processing", offset: 20, limit: 20 },
],
[
"read_agent_reminder",
{
agent_name: "finance",
message_id: record,
},
],
]);
for (const request of [
{ type: "proactiveInbox" },
{ type: "outbox", agentName: "Remy", offset: -1 },
{ type: "inbox", agentName: "finance", limit: 101 },
{ type: "reminder", agentName: "Remy", id: "" },
]) {
await assert.rejects(
requestWorkspace(
client,
request as Parameters<typeof requestWorkspace>[1],
signal,
),
);
}
assert.equal(calls.length, 3);
});