mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-29 00:38:33 +00:00
* 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
120 lines
3.8 KiB
TypeScript
120 lines
3.8 KiB
TypeScript
import { BehaviorController } from "../src/main/behavior.ts";
|
|
import { snapshot, clientInfo } from "../../client/tests/fixtures.ts";
|
|
import assert from "node:assert/strict";
|
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
import { ClientController } from "../../client/src/controller.ts";
|
|
import { ReMeClient } from "../../client/src/reme-client.ts";
|
|
import { Storage } from "../src/main/storage.ts";
|
|
import { UiError } from "../../client/src/i18n.ts";
|
|
import type {
|
|
Presentation,
|
|
AgentMessage,
|
|
StreamChunk,
|
|
} from "../../client/src/protocol.ts";
|
|
|
|
const reminder: AgentMessage = {
|
|
id: "reme-proactive-reminder-combined",
|
|
role: "assistant",
|
|
source: "proactive",
|
|
content: "A relevant change",
|
|
completed: true,
|
|
delivery: "idle",
|
|
notification_eligible: true,
|
|
origin_session_id: null,
|
|
session_id: "session",
|
|
items: [],
|
|
turn_id: null,
|
|
created_at: null,
|
|
outcome: "completed",
|
|
error: null,
|
|
};
|
|
|
|
test("explicit chat reading persists locally while historical presentation leaves messages unread", async (t) => {
|
|
const directory = await mkdtemp(
|
|
path.join(tmpdir(), "reme-read-receipt-test-"),
|
|
);
|
|
const manifest = JSON.parse(
|
|
await readFile(
|
|
new URL("../assets/remy/manifest.json", import.meta.url),
|
|
"utf8",
|
|
),
|
|
);
|
|
const storage = new Storage(directory);
|
|
const calls: string[] = [];
|
|
t.mock.method(ReMeClient.prototype, "call", async (job: string) => {
|
|
calls.push(job);
|
|
assert.equal(job, "get_client_info");
|
|
return clientInfo;
|
|
});
|
|
t.mock.method(
|
|
ReMeClient.prototype,
|
|
"stream",
|
|
async (
|
|
_job: string,
|
|
_body: unknown,
|
|
signal: AbortSignal,
|
|
listener: (chunk: StreamChunk) => void,
|
|
) => {
|
|
listener({
|
|
chunk_type: "data",
|
|
chunk: snapshot([reminder]),
|
|
});
|
|
await new Promise<void>((resolve) => {
|
|
if (signal.aborted) resolve();
|
|
else signal.addEventListener("abort", () => resolve(), { once: true });
|
|
});
|
|
},
|
|
);
|
|
const controller = new ClientController(
|
|
storage,
|
|
() => {},
|
|
new BehaviorController(manifest),
|
|
);
|
|
t.after(async () => {
|
|
await controller.close();
|
|
await rm(directory, { recursive: true, force: true });
|
|
});
|
|
controller.start();
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(controller.state.connection, "connected");
|
|
assert.equal(controller.state.unread, 1);
|
|
assert.deepEqual(controller.state.readMessageIds, []);
|
|
// A historical snapshot is suppressed locally without claiming the user read it.
|
|
controller.markAllRead();
|
|
assert.equal(controller.state.unread, 0);
|
|
assert.deepEqual(controller.state.readMessageIds, [reminder.id]);
|
|
assert.deepEqual(calls, ["get_client_info"]);
|
|
await storage.flush();
|
|
const presentations = JSON.parse(
|
|
await readFile(path.join(directory, "presentation.json"), "utf8"),
|
|
) as Record<string, Presentation>;
|
|
const receipt = Object.values(presentations).flatMap((value) =>
|
|
Object.values(value.receipts),
|
|
)[0];
|
|
assert.deepEqual(receipt, { presented: true, userRead: true });
|
|
const restored = new Storage(directory);
|
|
await restored.load();
|
|
assert.deepEqual(restored.presentations, storage.presentations);
|
|
});
|
|
|
|
test("storage requires a user-read flag in presentation receipts", async (t) => {
|
|
const directory = await mkdtemp(path.join(tmpdir(), "reme-invalid-receipt-"));
|
|
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
await writeFile(
|
|
path.join(directory, "presentation.json"),
|
|
JSON.stringify({
|
|
scope: {
|
|
initialized: true,
|
|
receipts: { old: { read: true, presented: true } },
|
|
},
|
|
}),
|
|
);
|
|
await assert.rejects(
|
|
new Storage(directory).load(),
|
|
(error: unknown) =>
|
|
error instanceof UiError && error.key === "invalidReceipts",
|
|
);
|
|
});
|