源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
This commit is contained in:
+122
@@ -0,0 +1,122 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
mergeAgentActivityMessages,
|
||||
type AgentActivityMessage
|
||||
} from "@tutti-os/agent-activity-core";
|
||||
import {
|
||||
createOptimisticGoalControlMessage,
|
||||
createOptimisticPromptMessage,
|
||||
normalizePromptContentBlocks
|
||||
} from "./agentGuiController.promptHelpers";
|
||||
|
||||
// Step 9 (ADR 0004 desktop-half): optimistic echoes must not carry
|
||||
// daemon-domain version numbers. Durable rows use the store's small monotonic
|
||||
// counter; an echo minted from a ms wall-clock timestamp (~10^12) would win
|
||||
// every version comparison against its durable twin and poison version-based
|
||||
// cursors.
|
||||
describe("createOptimisticPromptMessage", () => {
|
||||
const echoInput = {
|
||||
workspaceId: "room-1",
|
||||
agentSessionId: "session-1",
|
||||
turnId: "pending:submit-1",
|
||||
clientSubmitId: "submit-1",
|
||||
userId: "user-1",
|
||||
content: [{ type: "text" as const, text: "Ask" }],
|
||||
occurredAtUnixMs: 1_750_000_000_000
|
||||
};
|
||||
|
||||
it("mints the echo outside the durable version domain", () => {
|
||||
const echo = createOptimisticPromptMessage(echoInput);
|
||||
expect(echo.version).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps presentation text separate from runtime content", () => {
|
||||
const echo = createOptimisticPromptMessage({
|
||||
...echoInput,
|
||||
displayPrompt: "/browser",
|
||||
content: [{ type: "text", text: "runtime instructions" }]
|
||||
});
|
||||
expect(echo.payload).toMatchObject({
|
||||
content: [{ type: "text", text: "runtime instructions" }],
|
||||
displayPrompt: "/browser",
|
||||
text: "/browser"
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps image-only content without synthesizing presentation text", () => {
|
||||
const echo = createOptimisticPromptMessage({
|
||||
...echoInput,
|
||||
content: [
|
||||
{
|
||||
type: "image",
|
||||
mimeType: "image/png",
|
||||
path: "/prompt-assets/screen.png",
|
||||
name: "screen.png"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
expect(echo.payload).toMatchObject({
|
||||
content: [
|
||||
{
|
||||
type: "image",
|
||||
mimeType: "image/png",
|
||||
path: "/prompt-assets/screen.png",
|
||||
name: "screen.png"
|
||||
}
|
||||
],
|
||||
text: ""
|
||||
});
|
||||
});
|
||||
|
||||
it("lets the durable twin replace the echo in an id-keyed merge", () => {
|
||||
const echo = createOptimisticPromptMessage(echoInput);
|
||||
const durableTwin: AgentActivityMessage = {
|
||||
...echo,
|
||||
version: 3,
|
||||
turnId: "turn-2",
|
||||
payload: {
|
||||
actorId: "user-1",
|
||||
clientSubmitId: "submit-1",
|
||||
text: "Ask"
|
||||
}
|
||||
};
|
||||
const merged = mergeAgentActivityMessages([echo], [durableTwin]);
|
||||
expect(merged).toHaveLength(1);
|
||||
expect(merged[0]).toMatchObject({ version: 3, turnId: "turn-2" });
|
||||
});
|
||||
|
||||
it("marks an initial goal as a control event instead of a prompt turn", () => {
|
||||
const echo = createOptimisticGoalControlMessage({
|
||||
...echoInput,
|
||||
displayPrompt: "/goal ship it",
|
||||
goalControl: { action: "set", objective: "ship it" }
|
||||
});
|
||||
|
||||
expect(echo).toMatchObject({
|
||||
kind: "session_audit",
|
||||
payload: {
|
||||
__agentGuiOptimisticPrompt: true,
|
||||
action: "set",
|
||||
goalControl: true,
|
||||
messageId: "client-submit:user:submit-1",
|
||||
objective: "ship it",
|
||||
text: "/goal ship it"
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizePromptContentBlocks", () => {
|
||||
it("preserves a valid structured local connector selection", () => {
|
||||
expect(
|
||||
normalizePromptContentBlocks([
|
||||
{ type: "text", text: "list my calendar events" },
|
||||
{ type: "connector", connectorKey: " lark-cli " }
|
||||
])
|
||||
).toEqual([
|
||||
{ type: "text", text: "list my calendar events" },
|
||||
{ type: "connector", connectorKey: "lark-cli" }
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user