@athenaintel/react 0.53.1 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/dist/agent-runtime/src/call-recap.cjs +2 -3
- package/dist/agent-runtime/src/call-recap.cjs.map +1 -1
- package/dist/agent-runtime/src/call-recap.d.ts +1 -2
- package/dist/agent-runtime/src/call-recap.js +1 -2
- package/dist/agent-runtime/src/call-recap.js.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +7 -3
- package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
- package/dist/agent-runtime/src/deep-agent-transport-recipe.d.ts +10 -2
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js +8 -4
- package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
- package/dist/agent-runtime/src/dictation-session.d.ts +158 -0
- package/dist/agent-runtime/src/edit-command.cjs +15 -3
- package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/agent-runtime/src/edit-command.d.ts +8 -0
- package/dist/agent-runtime/src/edit-command.js +15 -3
- package/dist/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs +10 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +25 -1
- package/dist/agent-runtime/src/generated/runconfig-contract.js +10 -0
- package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/agent-runtime/src/history-pages.cjs +279 -0
- package/dist/agent-runtime/src/history-pages.cjs.map +1 -0
- package/dist/agent-runtime/src/history-pages.d.ts +252 -0
- package/dist/agent-runtime/src/history-pages.js +279 -0
- package/dist/agent-runtime/src/history-pages.js.map +1 -0
- package/dist/agent-runtime/src/index.d.ts +8 -7
- package/dist/agent-runtime/src/message-window.cjs +111 -7
- package/dist/agent-runtime/src/message-window.cjs.map +1 -1
- package/dist/agent-runtime/src/message-window.d.ts +66 -6
- package/dist/agent-runtime/src/message-window.js +112 -8
- package/dist/agent-runtime/src/message-window.js.map +1 -1
- package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
- package/dist/agent-runtime/src/offline-status.d.ts +64 -2
- package/dist/agent-runtime/src/offline-status.js.map +1 -1
- package/dist/agent-runtime/src/runtime.d.ts +4 -3
- package/dist/agent-runtime/src/subagent-transcripts.cjs +23 -1
- package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
- package/dist/agent-runtime/src/subagent-transcripts.js +25 -3
- package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
- package/dist/agent-runtime/src/subagents.cjs +112 -0
- package/dist/agent-runtime/src/subagents.cjs.map +1 -1
- package/dist/agent-runtime/src/subagents.d.ts +103 -0
- package/dist/agent-runtime/src/subagents.js +113 -1
- package/dist/agent-runtime/src/subagents.js.map +1 -1
- package/dist/agent-runtime/src/thread-handoff-protocol.d.ts +37 -9
- package/dist/agent-runtime/src/thread-handoff.d.ts +1 -1
- package/dist/agent-runtime/src/tool-metadata.cjs +8 -0
- package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/agent-runtime/src/tool-metadata.js +8 -0
- package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs +22 -2
- package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +9 -1
- package/dist/agent-runtime/src/use-deep-agent-thread.js +23 -3
- package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +106 -25
- package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
- package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +41 -6
- package/dist/agent-runtime/src/use-deep-agent-window-sync.js +109 -28
- package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -1
- package/dist/agent-runtime/src/use-thread-handoff-flow.d.ts +5 -9
- package/dist/agent-runtime/src/voice-presentation.cjs +34 -0
- package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
- package/dist/agent-runtime/src/voice-presentation.d.ts +35 -0
- package/dist/agent-runtime/src/voice-presentation.js +34 -0
- package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
- package/dist/assets/AthenaAssetEmbed.cjs +4 -2
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.d.ts +17 -8
- package/dist/assets/AthenaAssetEmbed.js +4 -2
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/assets/use-asset-embed.cjs.map +1 -1
- package/dist/assets/use-asset-embed.d.ts +7 -5
- package/dist/assets/use-asset-embed.js.map +1 -1
- package/dist/auth/account-identity.cjs +69 -0
- package/dist/auth/account-identity.cjs.map +1 -0
- package/dist/auth/account-identity.d.ts +57 -0
- package/dist/auth/account-identity.js +69 -0
- package/dist/auth/account-identity.js.map +1 -0
- package/dist/chat/AthenaChat.cjs +1 -1
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.js +1 -1
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.cjs +51 -43
- package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingCard.js +51 -43
- package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs +9 -4
- package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
- package/dist/chat/super-grouping/SuperGroupingTranscript.js +9 -4
- package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +7 -4
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.d.ts +10 -1
- package/dist/chat/super-grouping/activity-timeline.js +7 -4
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/super-grouping/earlier-steps-button.cjs +50 -0
- package/dist/chat/super-grouping/earlier-steps-button.cjs.map +1 -0
- package/dist/chat/super-grouping/earlier-steps-button.d.ts +11 -0
- package/dist/chat/super-grouping/earlier-steps-button.js +50 -0
- package/dist/chat/super-grouping/earlier-steps-button.js.map +1 -0
- package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
- package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
- package/dist/chat/super-grouping/toolkit-map.js +1 -0
- package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
- package/dist/chat/super-grouping/use-turn-steps.cjs +28 -0
- package/dist/chat/super-grouping/use-turn-steps.cjs.map +1 -0
- package/dist/chat/super-grouping/use-turn-steps.d.ts +23 -0
- package/dist/chat/super-grouping/use-turn-steps.js +28 -0
- package/dist/chat/super-grouping/use-turn-steps.js.map +1 -0
- package/dist/chat/use-statewire-approval-request.cjs +5 -5
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +7 -0
- package/dist/chat/use-statewire-approval-request.js +5 -5
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs +18 -58
- package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
- package/dist/chat-ui/mentions/use-account-workspace-id.js +18 -58
- package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
- package/dist/chat-ui/messages/voice-delegation-card.cjs +93 -25
- package/dist/chat-ui/messages/voice-delegation-card.cjs.map +1 -1
- package/dist/chat-ui/messages/voice-delegation-card.d.ts +16 -7
- package/dist/chat-ui/messages/voice-delegation-card.js +95 -27
- package/dist/chat-ui/messages/voice-delegation-card.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +6 -0
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.d.ts +3 -1
- package/dist/chat-ui/statewire.js +7 -1
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/handoff-cursor.cjs +2 -2
- package/dist/chat-ui/thread/handoff-cursor.cjs.map +1 -1
- package/dist/chat-ui/thread/handoff-cursor.js +3 -3
- package/dist/chat-ui/thread/handoff-cursor.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +4 -0
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.d.ts +11 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +5 -1
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/collab/client.cjs +134 -7
- package/dist/collab/client.cjs.map +1 -1
- package/dist/collab/client.d.ts +44 -0
- package/dist/collab/client.js +134 -7
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.d.ts +1 -1
- package/dist/composer/QuoteContext.cjs +3 -3
- package/dist/composer/QuoteContext.cjs.map +1 -1
- package/dist/composer/QuoteContext.js +3 -3
- package/dist/composer/QuoteContext.js.map +1 -1
- package/dist/keryx-http/src/initial-sync.cjs +121 -0
- package/dist/keryx-http/src/initial-sync.cjs.map +1 -0
- package/dist/keryx-http/src/initial-sync.d.ts +77 -0
- package/dist/keryx-http/src/initial-sync.js +104 -0
- package/dist/keryx-http/src/initial-sync.js.map +1 -0
- package/dist/keryx-http/src/unconfirmed-update-attributions.cjs +8 -0
- package/dist/keryx-http/src/unconfirmed-update-attributions.cjs.map +1 -1
- package/dist/keryx-http/src/unconfirmed-update-attributions.d.ts +6 -0
- package/dist/keryx-http/src/unconfirmed-update-attributions.js +8 -0
- package/dist/keryx-http/src/unconfirmed-update-attributions.js.map +1 -1
- package/dist/provider/AthenaProvider.cjs +11 -3
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.js +12 -4
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/provider/statewire-window-context.cjs +6 -0
- package/dist/provider/statewire-window-context.cjs.map +1 -1
- package/dist/provider/statewire-window-context.d.ts +10 -1
- package/dist/provider/statewire-window-context.js +6 -0
- package/dist/provider/statewire-window-context.js.map +1 -1
- package/dist/react/package.json.cjs +1 -1
- package/dist/react/package.json.js +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +2 -0
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.d.ts +7 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +2 -0
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/api.cjs +1 -2
- package/dist/threads/api.cjs.map +1 -1
- package/dist/threads/api.d.ts +3 -2
- package/dist/threads/api.js +1 -2
- package/dist/threads/api.js.map +1 -1
- package/dist/threads/sessions-query.cjs +2 -0
- package/dist/threads/sessions-query.cjs.map +1 -1
- package/dist/threads/sessions-query.js +2 -0
- package/dist/threads/sessions-query.js.map +1 -1
- package/dist/threads/statewire-thread-list.cjs +5 -7
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +7 -9
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/tools/subagent-task-tool-ui.cjs +15 -5
- package/dist/tools/subagent-task-tool-ui.cjs.map +1 -1
- package/dist/tools/subagent-task-tool-ui.d.ts +5 -4
- package/dist/tools/subagent-task-tool-ui.js +16 -6
- package/dist/tools/subagent-task-tool-ui.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-pages.js","sources":["../../../../agent-runtime/src/history-pages.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport { DEEP_AGENT_HISTORY_PAGE_COMMAND } from './generated/runconfig-contract';\nimport { QUIET_TOOL_NAMES } from './tool-names';\n\n/**\n * Older history by command, a turn at a time — the client half of agora's\n * `history_page.py` (protocol 3, `docs/plans/2026-11-03-history-by-command-plan.md`).\n *\n * A host advertising `DEEP_AGENT_HISTORY_PAGE_PROTOCOL_VERSION` answers\n * `history/page` with whole turns older than a message the client holds, as a\n * command result: nothing is mounted in the attach's view, so no interest\n * document grows with how far back a reader goes, and a re-attach restates\n * nothing it paged. The client keeps the answers in a\n * {@link DeepAgentHistoryStore} and joins them in front of the live window\n * ({@link joinDeepAgentHistory}).\n *\n * A turn longer than the host's whole-turn limit rides as its prompt and its\n * answer, with `steps` counting what it left out; `history/page` with a\n * `turn` pages those steps newest first. The join marks each summarized turn\n * on a source message ({@link DEEP_AGENT_TURN_STEPS_KEY}) so a renderer reads\n * the turn's exact counts, and inserts the steps fetched so far between the\n * prompt and the answer.\n */\n\n/** Turns one `history/page` asks for. */\nexport const DEEP_AGENT_HISTORY_PAGE_TURNS = 10;\n/** Steps of one turn one `history/page` asks for. */\nexport const DEEP_AGENT_TURN_STEPS_PAGE = 100;\n/** `additional_kwargs` key the join marks a summarized turn's first reply message with. */\nexport const DEEP_AGENT_TURN_STEPS_KEY = 'athena_turn_steps';\n/**\n * Key on the composed thread state (`useDeepAgentThread`'s converter) set when\n * the paged turns joined in front of the window reach the transcript's start:\n * the live window's own `hasOlder` still says older messages exist, so an\n * edit's anchor search reads this to know the first message has no parent.\n */\nexport const DEEP_AGENT_HISTORY_START_KEY = 'athenaHistoryStart';\n\n/** Whether a composed thread state says its messages start at the transcript's start. */\nexport function isDeepAgentHistoryAtStart(state: unknown): boolean {\n return isRecord(state) && state[DEEP_AGENT_HISTORY_START_KEY] === true;\n}\n\n/** What a summarized turn's page left out (the host's `steps`). */\nexport interface DeepAgentHistoryTurnSteps {\n /** Messages left out. */\n count: number;\n /** Tool calls among the messages left out (a renderer adds the ones it holds). */\n tools: number;\n /** Of which `task` delegations. */\n delegations: number;\n first: string | null;\n last: string | null;\n}\n\n/** One turn of a `history/page` answer. */\nexport interface DeepAgentHistoryTurn {\n /** The turn's first message (its prompt), the id its steps are paged by. */\n id: string;\n /** What the page shows of it, oldest first: the prompt and the answer, or the whole turn. */\n messages: LangChainMessage[];\n /** What it left out, or `null` when the turn rides whole. */\n steps: DeepAgentHistoryTurnSteps | null;\n}\n\nexport interface DeepAgentHistoryPageAnswer {\n turns: DeepAgentHistoryTurn[];\n more: { before: boolean };\n}\n\nexport interface DeepAgentTurnStepsAnswer {\n turn: string;\n /** Steps, oldest first. */\n messages: LangChainMessage[];\n more: { before: boolean };\n}\n\n/** The `history/page` command asking for turns older than `before`. */\nexport interface HistoryPageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_PAGE_COMMAND;\n readonly before: string;\n readonly turns: number;\n}\n\n/** The `history/page` command asking for one turn's steps older than `before`. */\nexport interface TurnStepsCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_PAGE_COMMAND;\n readonly turn: string;\n readonly before?: string;\n readonly steps: number;\n}\n\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** Older turns, outside the attach's view. */\n historyPage: HistoryPageCommand;\n /** One summarized turn's steps. */\n historyTurnSteps: TurnStepsCommand;\n }\n }\n}\n\nexport function buildHistoryPageCommand({\n before,\n turns = DEEP_AGENT_HISTORY_PAGE_TURNS,\n}: {\n before: string;\n turns?: number;\n}): HistoryPageCommand {\n return { type: DEEP_AGENT_HISTORY_PAGE_COMMAND, before, turns };\n}\n\nexport function buildTurnStepsCommand({\n turn,\n before,\n steps = DEEP_AGENT_TURN_STEPS_PAGE,\n}: {\n turn: string;\n before?: string | undefined;\n steps?: number;\n}): TurnStepsCommand {\n return {\n type: DEEP_AGENT_HISTORY_PAGE_COMMAND,\n turn,\n ...(before !== undefined && { before }),\n steps,\n };\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\nconst isCount = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\nconst isId = (value: unknown): value is string => typeof value === 'string' && value.length > 0;\n\nfunction readMessages(value: unknown): LangChainMessage[] | null {\n if (!Array.isArray(value)) return null;\n for (const message of value) {\n if (!isRecord(message) || !isId(message.id) || typeof message.type !== 'string') return null;\n }\n return value as LangChainMessage[];\n}\n\nfunction readMore(value: unknown): { before: boolean } | null {\n return isRecord(value) && typeof value.before === 'boolean' ? { before: value.before } : null;\n}\n\nfunction readSteps(value: unknown): DeepAgentHistoryTurnSteps | null | undefined {\n if (value === null) return null;\n if (!isRecord(value)) return undefined;\n const { count, tools, delegations, first, last } = value;\n if (!isCount(count) || !isCount(tools) || !isCount(delegations)) return undefined;\n if ((first !== null && !isId(first)) || (last !== null && !isId(last))) return undefined;\n return { count, tools, delegations, first, last };\n}\n\n/** A `history/page` answer to `{before, turns}`, or `null` when it is malformed. */\nexport function readHistoryPageAnswer(payload: unknown): DeepAgentHistoryPageAnswer | null {\n if (!isRecord(payload) || !Array.isArray(payload.turns)) return null;\n const more = readMore(payload.more);\n if (more === null) return null;\n const turns: DeepAgentHistoryTurn[] = [];\n for (const turn of payload.turns) {\n if (!isRecord(turn) || !isId(turn.id)) return null;\n const messages = readMessages(turn.messages);\n const steps = readSteps(turn.steps);\n if (messages === null || steps === undefined) return null;\n turns.push({ id: turn.id, messages, steps });\n }\n return { turns, more };\n}\n\n/** A `history/page` answer to `{turn, before?, steps}`, or `null` when it is malformed. */\nexport function readTurnStepsAnswer(payload: unknown): DeepAgentTurnStepsAnswer | null {\n if (!isRecord(payload) || !isId(payload.turn)) return null;\n const messages = readMessages(payload.messages);\n const more = readMore(payload.more);\n if (messages === null || more === null) return null;\n return { turn: payload.turn, messages, more };\n}\n\n/** The steps of one summarized turn fetched so far, oldest first. */\nexport interface DeepAgentHistoryTurnStepsLoaded {\n messages: LangChainMessage[];\n /** Older steps of the turn remain. */\n more: boolean;\n}\n\n/** The turns one conversation has paged in, in front of its live window. */\nexport interface DeepAgentHistorySnapshot {\n /** The conversation they belong to. */\n threadId: string;\n /** The message the first page was asked `before`: the live window's first message then. */\n anchor: string;\n /** Whether the anchor is a reply rather than a prompt: the newest turn's rest is in the live window. */\n anchorInsideTurn: boolean;\n /** Turns, oldest first. */\n turns: DeepAgentHistoryTurn[];\n /** Older turns remain beyond the first. */\n more: boolean;\n /** Steps fetched per summarized turn id. */\n steps: ReadonlyMap<string, DeepAgentHistoryTurnStepsLoaded>;\n}\n\n/** How a store asks the host: the thread's `sendCommand` (its answer, the command's payload). */\nexport type DeepAgentHistorySend = (command: HistoryPageCommand | TurnStepsCommand) => unknown;\n\n/**\n * The history paged in for the open conversation: a subscribable store the\n * thread's converter joins in front of its live window and the window sync\n * fills. One per provider, like the tool-output store; it holds one\n * conversation at a time and resets when another one pages.\n *\n * Everything history pages do runs through the store's methods, so a surface\n * that creates no store (it never pages by command) bundles none of it: the\n * shared thread and window sync only call `historyPages?.…`.\n */\nexport interface DeepAgentHistoryStore {\n /** The current snapshot (a new object on every change), or `null` when empty. */\n getSnapshot(): DeepAgentHistorySnapshot | null;\n subscribe(listener: () => void): () => void;\n /**\n * Adds a page asked `before` a message. A page for another conversation, or\n * asked before a message other than the oldest turn held, starts over.\n */\n addPage(page: {\n threadId: string;\n before: string;\n beforeIsPrompt: boolean;\n answer: DeepAgentHistoryPageAnswer;\n }): void;\n /** Adds one summarized turn's older steps. */\n addSteps(steps: { threadId: string; answer: DeepAgentTurnStepsAnswer }): void;\n /** Whether a steps request for the turn is in flight — the loader's dedupe. */\n isLoadingSteps(turn: string): boolean;\n setLoadingSteps(turn: string, loading: boolean): void;\n clear(): void;\n /**\n * The transcript to render: the held turns joined in front of the live\n * window ({@link joinDeepAgentHistory}), and whether they reach the\n * transcript's start (`more.before` false). `live` alone, `atStart` false,\n * while nothing held meets the window.\n */\n join(options: {\n threadId: string | undefined;\n live: LangChainMessage[];\n liveIds: ReadonlySet<string>;\n }): { messages: LangChainMessage[]; atStart: boolean };\n /** Whether the held turns no longer meet the live window ({@link isDeepAgentHistoryDetached}). */\n isDetached(options: { threadId: string | undefined; liveIds: ReadonlySet<string> }): boolean;\n /**\n * Asks the host for the turns before `before` and adds them; resolves how\n * many it answered. Rejects with the host's refusal, or when the answer is\n * not a page this client reads.\n */\n requestOlder(options: {\n send: DeepAgentHistorySend;\n threadId: string;\n before: string;\n beforeIsPrompt: boolean;\n turns?: number;\n }): Promise<number>;\n /**\n * Fetches a summarized turn's next older steps (`history/page` with its\n * `turn`) into the store, newest first. A turn already loading, or with no\n * steps left, is a no-op. Rejects with the host's refusal.\n */\n loadSteps(options: { send: DeepAgentHistorySend; marker: DeepAgentTurnStepsMarker }): Promise<void>;\n}\n\nexport function createDeepAgentHistoryStore(): DeepAgentHistoryStore {\n let snapshot: DeepAgentHistorySnapshot | null = null;\n const loadingSteps = new Set<string>();\n const listeners = new Set<() => void>();\n const publish = (next: DeepAgentHistorySnapshot | null) => {\n snapshot = next;\n for (const listener of listeners) listener();\n };\n const store: DeepAgentHistoryStore = {\n getSnapshot: () => snapshot,\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n addPage({ threadId, before, beforeIsPrompt, answer }) {\n const current = snapshot;\n const continues =\n current !== null && current.threadId === threadId && current.turns[0]?.id === before;\n if (!continues) {\n loadingSteps.clear();\n publish({\n threadId,\n anchor: before,\n anchorInsideTurn: !beforeIsPrompt,\n turns: answer.turns,\n more: answer.more.before,\n steps: new Map(),\n });\n return;\n }\n const held = new Set(current.turns.map((turn) => turn.id));\n publish({\n ...current,\n turns: [...answer.turns.filter((turn) => !held.has(turn.id)), ...current.turns],\n more: answer.more.before,\n });\n },\n addSteps({ threadId, answer }) {\n const current = snapshot;\n if (current === null || current.threadId !== threadId) return;\n if (!current.turns.some((turn) => turn.id === answer.turn)) return;\n const loaded = current.steps.get(answer.turn);\n const held = new Set(loaded?.messages.map((message) => message.id));\n const steps = new Map(current.steps);\n steps.set(answer.turn, {\n messages: [\n ...answer.messages.filter((message) => !held.has(message.id)),\n ...(loaded?.messages ?? []),\n ],\n more: answer.more.before,\n });\n publish({ ...current, steps });\n },\n isLoadingSteps: (turn) => loadingSteps.has(turn),\n setLoadingSteps(turn, loading) {\n if (loading) loadingSteps.add(turn);\n else loadingSteps.delete(turn);\n },\n clear() {\n loadingSteps.clear();\n if (snapshot !== null) publish(null);\n },\n join({ threadId, live, liveIds }) {\n const history = snapshot;\n if (history === null || history.turns.length === 0 || isDeepAgentHistoryDetached({ history, threadId, liveIds })) {\n return { messages: live, atStart: false };\n }\n return { messages: joinDeepAgentHistory({ history, threadId, live, liveIds }), atStart: !history.more };\n },\n isDetached: ({ threadId, liveIds }) =>\n snapshot !== null && isDeepAgentHistoryDetached({ history: snapshot, threadId, liveIds }),\n async requestOlder({ send, threadId, before, beforeIsPrompt, turns }) {\n const answer = readHistoryPageAnswer(await send(buildHistoryPageCommand({ before, turns })));\n if (answer === null) throw new Error('history/page answered in a shape this client cannot read');\n store.addPage({ threadId, before, beforeIsPrompt, answer });\n return answer.turns.length;\n },\n async loadSteps({ send, marker }) {\n const current = snapshot;\n if (current === null || marker.hiddenSteps === 0 || loadingSteps.has(marker.turn)) return;\n // The newest turn of a page asked inside a turn: its later steps are in\n // the live window, so the steps it left out end at the page's anchor.\n const newestInsideTurn = current.anchorInsideTurn && current.turns.at(-1)?.id === marker.turn;\n const before = marker.before ?? (newestInsideTurn ? current.anchor : undefined);\n loadingSteps.add(marker.turn);\n try {\n const answer = readTurnStepsAnswer(await send(buildTurnStepsCommand({ turn: marker.turn, before })));\n if (answer === null) {\n throw new Error('history/page answered steps in a shape this client cannot read');\n }\n store.addSteps({ threadId: current.threadId, answer });\n } finally {\n loadingSteps.delete(marker.turn);\n }\n },\n };\n return store;\n}\n\n/**\n * The marker the join puts on a summarized turn's first reply message: the\n * turn's steps it has not shown yet, so a renderer reads exact counts (\"Used\n * 313 tools\") and knows whether opening it has steps to fetch.\n */\nexport interface DeepAgentTurnStepsMarker {\n /** The turn's first message: the id its steps are paged by. */\n turn: string;\n /** Steps not loaded yet. */\n hiddenSteps: number;\n /** Tool calls among them. */\n hiddenTools: number;\n /** Of which `task` delegations. */\n hiddenDelegations: number;\n /** The oldest step loaded, the next steps request's `before`. */\n before: string | undefined;\n}\n\n/**\n * The tool calls among `messages` the converter shows. The host counts every\n * call of a turn; a quiet call (`QUIET_TOOL_NAMES`) never renders, so it stays\n * in the hidden count once loaded and the turn's total holds still as its\n * steps load.\n */\nfunction toolCalls(messages: readonly LangChainMessage[]): { tools: number; delegations: number } {\n let tools = 0;\n let delegations = 0;\n for (const message of messages) {\n if (message.type !== 'ai') continue;\n for (const call of message.tool_calls ?? []) {\n if (QUIET_TOOL_NAMES.has(call.name)) continue;\n tools += 1;\n if (call.name === 'task') delegations += 1;\n }\n }\n return { tools, delegations };\n}\n\n/** The marker a join put on a source message, or `undefined`. */\nexport function readTurnStepsMarker(message: unknown): DeepAgentTurnStepsMarker | undefined {\n if (!isRecord(message) || !isRecord(message.additional_kwargs)) return undefined;\n const marker = message.additional_kwargs[DEEP_AGENT_TURN_STEPS_KEY];\n if (!isRecord(marker) || !isId(marker.turn)) return undefined;\n const { hiddenSteps, hiddenTools, hiddenDelegations, before } = marker;\n if (!isCount(hiddenSteps) || !isCount(hiddenTools) || !isCount(hiddenDelegations)) return undefined;\n return {\n turn: marker.turn,\n hiddenSteps,\n hiddenTools,\n hiddenDelegations,\n before: isId(before) ? before : undefined,\n };\n}\n\n/** The marked copy of a message, reused while the message and its marker are the same. */\nconst markedCopies = new WeakMap<object, { key: string; message: LangChainMessage }>();\n\nfunction withMarker(message: LangChainMessage, marker: DeepAgentTurnStepsMarker): LangChainMessage {\n const key = JSON.stringify(marker);\n const cached = markedCopies.get(message);\n if (cached?.key === key) return cached.message;\n // Every wire message carries `additional_kwargs` in practice; the upstream\n // type leaves it off tool messages.\n const kwargs = (message as { additional_kwargs?: Record<string, unknown> }).additional_kwargs;\n const marked = {\n ...message,\n additional_kwargs: { ...(kwargs ?? {}), [DEEP_AGENT_TURN_STEPS_KEY]: marker },\n } as LangChainMessage;\n markedCopies.set(message, { key, message: marked });\n return marked;\n}\n\n/**\n * The transcript a converter renders: the paged turns in front of the live\n * window, when they still meet it.\n *\n * The paged turns end just before the snapshot's anchor. While the anchor is\n * in `live`, they are joined in front of it, minus any message `live` already\n * holds (a reveal or an edit paged an interest page over the same range). When\n * the anchor has left the live window (an edit rewound past it, a branch\n * switch), the pages describe another transcript: `live` is returned alone,\n * and {@link isDeepAgentHistoryDetached} tells the window sync to clear them.\n *\n * Each summarized turn gets its fetched steps between its prompt and its\n * answer, and its first reply message the {@link DeepAgentTurnStepsMarker}.\n * The newest turn of a page asked inside a turn has its rest in `live`, so its\n * marker lands on the first live message after its prompt.\n */\nexport function joinDeepAgentHistory({\n history,\n threadId,\n live,\n liveIds,\n}: {\n history: DeepAgentHistorySnapshot | null;\n threadId: string | undefined;\n live: LangChainMessage[];\n /** The live window's chain ids; the anchor must be among them. */\n liveIds: ReadonlySet<string>;\n}): LangChainMessage[] {\n if (history === null || history.turns.length === 0 || isDeepAgentHistoryDetached({ history, threadId, liveIds })) {\n return live;\n }\n const joined: LangChainMessage[] = [];\n let pendingMarker: DeepAgentTurnStepsMarker | null = null;\n // The marker rides an assistant message: a tool result whose call is older\n // than what is loaded (a head that starts on one) converts to no row.\n const markNext = (message: LangChainMessage): LangChainMessage => {\n if (pendingMarker === null || message.type !== 'ai') return message;\n const marked = withMarker(message, pendingMarker);\n pendingMarker = null;\n return marked;\n };\n for (const turn of history.turns) {\n if (turn.steps === null) {\n for (const message of turn.messages) {\n if (!liveIds.has(message.id ?? '')) joined.push(message);\n }\n continue;\n }\n const loaded = history.steps.get(turn.id)?.messages ?? [];\n const [first, ...rest] = turn.messages;\n const prompt = first?.type === 'human' ? first : undefined;\n const answer = prompt === undefined ? turn.messages : rest;\n // The host counts only the messages the page left out; of those, the\n // steps paged in since render on their own, so they leave the hidden count.\n const paged = toolCalls(loaded);\n pendingMarker = {\n turn: turn.id,\n hiddenSteps: Math.max(0, turn.steps.count - loaded.length),\n hiddenTools: Math.max(0, turn.steps.tools - paged.tools),\n hiddenDelegations: Math.max(0, turn.steps.delegations - paged.delegations),\n before: loaded[0]?.id,\n };\n for (const message of [...(prompt ? [prompt] : []), ...loaded, ...answer]) {\n if (liveIds.has(message.id ?? '')) continue;\n joined.push(markNext(message));\n }\n // A summarized turn with no reply shown carries its marker no further,\n // except the newest one of a page asked inside a turn: its rest is live.\n if (pendingMarker !== null && (turn !== history.turns.at(-1) || !history.anchorInsideTurn)) {\n pendingMarker = null;\n }\n }\n for (const message of live) joined.push(markNext(message));\n return joined;\n}\n\n/** Whether the paged turns no longer meet the live window: another conversation, or the anchor left it. */\nexport function isDeepAgentHistoryDetached({\n history,\n threadId,\n liveIds,\n}: {\n history: DeepAgentHistorySnapshot;\n threadId: string | undefined;\n liveIds: ReadonlySet<string>;\n}): boolean {\n if (threadId !== undefined && history.threadId !== threadId) return true;\n return liveIds.size > 0 && !liveIds.has(history.anchor);\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,gCAAgC;AAEtC,MAAM,6BAA6B;AAEnC,MAAM,4BAA4B;AAOlC,MAAM,+BAA+B;AAGrC,SAAS,0BAA0B,OAAyB;AACjE,SAAO,SAAS,KAAK,KAAK,MAAM,4BAA4B,MAAM;AACpE;AA8DO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA,QAAQ;AACV,GAGuB;AACrB,SAAO,EAAE,MAAM,iCAAiC,QAAQ,MAAA;AAC1D;AAEO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAIqB;AACnB,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,GAAI,WAAW,UAAa,EAAE,OAAA;AAAA,IAC9B;AAAA,EAAA;AAEJ;AAEA,MAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AACrE,MAAM,UAAU,CAAC,UACf,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS;AACnE,MAAM,OAAO,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SAAS,QAAQ,MAAM,GAAG,EAAE,KAAK,CAAC,QAAQ,mBAAmB;AAC1F,sBAAgB;AAAA,IAClB;AAAA,EACF;AACA,aAAW,WAAW,KAAM,QAAO,KAAK,SAAS,OAAO,CAAC;AACzD,SAAO;AACT;AAGO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACF,GAIY;AACV,MAAI,aAAa,UAAa,QAAQ,aAAa,SAAU,QAAO;AACpE,SAAO,QAAQ,OAAO,KAAK,CAAC,QAAQ,IAAI,QAAQ,MAAM;AACxD;"}
|
|
@@ -17,12 +17,13 @@ export { buildQueueEditCommand, buildStatewireQueueRows, describeQueueSendFailur
|
|
|
17
17
|
export { createDeepAgentSendRecovery, type DeepAgentSendRecovery, type DeepAgentSendRecoveryOptions, shouldAutoRetryFailedSend, } from "./send-recovery";
|
|
18
18
|
export { hasStatewireThreadExtras, readStatewireFailedSendLane, requireStatewireFailedActions, type StatewireFailedActions, type StatewireFailedSendEntry, type StatewireFailedSendLane, } from "./thread-extras";
|
|
19
19
|
export { applyRunErrorStatus, ATHENA_ERRORS_KEY, ATHENA_HANDOFF_KEY, ATHENA_QUEUED_LANE_KEY, ATHENA_RUN_MARKER_CANCELLED, ATHENA_RUN_MARKER_FAILED, ATHENA_RUN_MARKER_KEY, ATHENA_RUN_MARKER_SOURCE_KEY, ATHENA_STOP_SOURCE_INSTANCE_CLOSED, ATHENA_STOP_SOURCE_POD_DRAIN, ATHENA_STOP_SOURCE_SEND_NOW, ATHENA_STOP_SOURCE_VOICE_STEER, ATHENA_TERMINATION_REASON_KEY, convertDeepAgentLangChainMessage, convertDeepAgentState, type ConvertDeepAgentStateOptions, type DeepAgentMessageConversionOptions, createDeepAgentMaterialize, createDeepAgentMessageConversionCache, type DeepAgentConversionMemory, deepAgentMaterialize, type DeepAgentMaterializeOptions, DeepAgentMessageConversionCache, deepAgentRowKey, isConvertibleChatMessage, isDrainRunMarker, isLangGraphState, isMessageHiddenFromFrontend, isQueuedLaneMessage, isServerUpdateStopSource, isSilentRunMarker, laneTailMessages, liftBranchIntoMetadata, liftCompactionBoundaryIntoMetadata, liftConversationStatsIntoMetadata, liftErrorsIntoMetadata, liftHandoffSummaryIntoMetadata, liftModelIntoMetadata, liftPlaceInstructionsIntoMetadata, liftRunMarkerIntoMetadata, liftTerminationIntoMetadata, liftToolMessageMetadataIntoArtifact, liftTruncatedToolOutputIntoArtifact, convertDeepAgentMessage, markPreliminaryToolResults, messageConverter, nativeStepUsage, PENDING_ASSISTANT_MESSAGE_ID, PLACE_INSTRUCTIONS_STAMP_KEY, readMessageErrorsFromSourceMessages, readRunMarkerFromSourceMessages, readSoleRunMarker, type RunMarkerInfo, sanitizeLangChainMessages, substituteToolOutput, withPendingAssistantMessage, } from "./messages";
|
|
20
|
-
export { ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY, buildHistoryMessageCommand, buildToolOutputCommand, clampMessageWindowSize, type DeepAgentInterestChainEntry, type DeepAgentInterestRequest, type DeepAgentInterestResolution, type DeepAgentMessageWindow, type DeepAgentMessageWindowDeclaration, headInterestRequest, type HistoryMessageCommand, type HistoryMessageResult,
|
|
20
|
+
export { ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY, buildHistoryMessageCommand, buildToolOutputCommand, clampMessageWindowSize, type DeepAgentInterestChainEntry, type DeepAgentInterestDeclaration, type DeepAgentInterestRequest, type DeepAgentInterestResolution, type DeepAgentMessageWindow, type DeepAgentMessageWindowDeclaration, headInterestRequest, type HistoryMessageCommand, type HistoryMessageResult, messageWindowCarries, pageInterestRequest, pageInterestRequests, readDeepAgentInterestDeclaration, readDeepAgentInterestDocument, readDeepAgentInterestResolution, readDeepAgentMessageWindow, readHistoryMessageResult, readToolOutputResult, readTruncatedToolContent, readTruncatedToolOutputArtifact, restatedInterestRequests, type ToolOutputCommand, type ToolOutputResult, type TruncatedToolContent, type TruncatedToolOutputArtifact, withDeclaredInterests, withDeclaredMessageWindow, } from "./message-window";
|
|
21
21
|
export { buildHistoryLaneCommand, type DeepAgentLaneHistoryState, type DeepAgentLaneTarget, deepAgentLaneHistoryQueryKey, type HistoryLaneCommand, type HistoryLanePage, isWholeCardRefusal, mergeLaneHistory, readHistoryLanePage, useDeepAgentLaneHistory, } from "./lane-history";
|
|
22
22
|
export { buildHistoryLaneImageCommand, type DeepAgentLaneImagesState, deepAgentLaneImageQueryKey, type HistoryLaneImageChunk, type HistoryLaneImageCommand, type InlineImage, type InlineImageChunk, type LaneImageRef, laneImageKey, omittedLaneImages, readChunkedInlineImage, readHistoryLaneImageChunk, readInlineImageChunk, readLaneImage, readLaneImageTile, showLaneImages, useDeepAgentLaneImages, } from "./lane-images";
|
|
23
23
|
export { createDeepAgentLaneFollowRegistry, type DeepAgentLaneFollowRegistry, type DeepAgentLaneFollowRequest, type DeepAgentLaneFollows, isLaneFollowRequest, laneFollowRequest, mergeFollowedLane, readDeepAgentFollowedWindow, readDeepAgentLaneFollows, useDeepAgentLaneFollow, useDeepAgentLaneFollowSync, type UseDeepAgentLaneFollowSyncOptions, } from "./lane-follow";
|
|
24
|
-
export { buildDeepAgentEditCommand, deepAgentHistoryHasOlder, type DeepAgentPreparedMessageMetadata, type DeepAgentStatewireExtras, isSourceBelowLoadedWindow, loadOlderDeepAgentHistoryPage, MAX_EDIT_ANCHOR_HISTORY_LOADS, readDeepAgentStatewireExtras, resolveDeepAgentEditCommand, resolveWireAnchorMessageId, } from "./edit-command";
|
|
25
|
-
export {
|
|
24
|
+
export { buildDeepAgentEditCommand, deepAgentHistoryHasOlder, type DeepAgentPreparedMessageMetadata, type DeepAgentStatewireExtras, isHistoryPageLostToReconnect, isSourceBelowLoadedWindow, loadOlderDeepAgentHistoryPage, MAX_EDIT_ANCHOR_HISTORY_LOADS, readDeepAgentStatewireExtras, resolveDeepAgentEditCommand, resolveWireAnchorMessageId, } from "./edit-command";
|
|
25
|
+
export { buildHistoryPageCommand, buildTurnStepsCommand, createDeepAgentHistoryStore, DEEP_AGENT_HISTORY_PAGE_TURNS, DEEP_AGENT_HISTORY_START_KEY, DEEP_AGENT_TURN_STEPS_KEY, DEEP_AGENT_TURN_STEPS_PAGE, type DeepAgentHistoryPageAnswer, type DeepAgentHistorySend, type DeepAgentHistorySnapshot, type DeepAgentHistoryStore, type DeepAgentHistoryTurn, type DeepAgentHistoryTurnSteps, type DeepAgentHistoryTurnStepsLoaded, type DeepAgentTurnStepsAnswer, type DeepAgentTurnStepsMarker, type HistoryPageCommand, isDeepAgentHistoryAtStart, isDeepAgentHistoryDetached, joinDeepAgentHistory, readHistoryPageAnswer, readTurnStepsAnswer, readTurnStepsMarker, type TurnStepsCommand, } from "./history-pages";
|
|
26
|
+
export { DEEP_AGENT_MAX_CHAINED_HISTORY_LOADS, type DeepAgentHistoryLoadEvent, type DeepAgentHistoryPageEvent, type DeepAgentWindowSyncMessage, type DeepAgentWindowSyncState, useDeepAgentMessageWindow, useDeepAgentWindowSync, type UseDeepAgentWindowSyncOptions, } from "./use-deep-agent-window-sync";
|
|
26
27
|
export { useDeepAgentMessageEditSubmit } from "./use-deep-agent-edit-submit";
|
|
27
28
|
export { createDeepAgentToolOutputStore, type DeepAgentToolOutputEntry, type DeepAgentToolOutputStore, type DeepAgentToolOutputStoreOptions, } from "./tool-outputs";
|
|
28
29
|
export { claimDeepAgentFailedSendText, type DeepAgentFailedSend, type DeepAgentWithdrawableTurn, type DeepAgentWithdrawnFromRun, type DeepAgentWithdrawnTurns, type DeepAgentWithdrawnTurnVerdict, readDeepAgentFailedSends, readDeepAgentWithdrawableTurn, readDeepAgentWithdrawnTurnVerdict, } from "./withdrawn-turns";
|
|
@@ -37,7 +38,7 @@ export { type DeepAgentModelContextHost, registerDeepAgentRunConfig, } from "./m
|
|
|
37
38
|
export { type CompletedPtcParent, extractCompletedPtcParents, type PtcSubcall, ptcSubcallsFromArtifact, } from "./ptc-subcalls";
|
|
38
39
|
export { isRunningToolPlaceholder, isRunningToolPlaceholderArtifact, } from "./running-tool-placeholder";
|
|
39
40
|
export { convertSubagentTranscript, createSubagentLaneConversion, createSubagentTranscriptConversionCache, type SubagentLaneConversion, withLaneReport, withRepeatedResult, } from "./subagent-transcripts";
|
|
40
|
-
export { countInEvalDispatches, countSubagentStatuses, deriveEvalSubagents, finalizeOrphanedSubagents, isTerminalSubagentStatus, nestedMessagesFromArtifact, nestedTodosFromArtifact, ORPHANED_SUBAGENT_OUTPUT, ptcSubagentsFromArtifact, readLaneUsage, readTruncatedLane, type SubagentDiscoverySnapshot, type SubagentLaneSource, type SubagentStatus, type SubagentStatusCounts, type SubagentTokenUsage, subagentAwaitingApproval, subagentToolCallAwaitingApproval, type TaskSiblingGroup, type TokenCounts, type TruncatedLane, taskSiblingGroup, taskSubagentsOfThread, taskSubagentsOfTurn, transcriptStepUsage, turnToolCallsAwaitingApproval, useTurnToolCallsAwaitingApproval, } from "./subagents";
|
|
41
|
+
export { countInEvalDispatches, countSubagentStatuses, deriveEvalSubagents, finalizeOrphanedSubagents, isTerminalSubagentStatus, nestedMessagesFromArtifact, nestedTodosFromArtifact, ORPHANED_SUBAGENT_OUTPUT, ptcSubagentsFromArtifact, readLaneUsage, readTruncatedLane, type SubagentDiscoverySnapshot, type SubagentLaneSource, type SubagentStatus, type SubagentStatusCounts, type SubagentTokenUsage, openTurnToolCallIds, SUBAGENT_AWAITING_APPROVAL_LABEL, subagentApprovalNoteLabel, subagentAwaitingApproval, type SubagentLaneApprovalWait, subagentLaneApprovalWait, subagentLanesHoldingUnseenApproval, subagentToolCallAwaitingApproval, type TaskSiblingGroup, type TokenCounts, type TruncatedLane, taskSiblingGroup, taskSubagentsOfThread, taskSubagentsOfTurn, transcriptStepUsage, turnLaneApprovalWait, turnToolCallsAwaitingApproval, type UnseenApprovalLanes, useTurnToolCallsAwaitingApproval, } from "./subagents";
|
|
41
42
|
export { ASK_AGENT_TOOL_NAME, ASYNC_TASK_TOOL_NAMES, CANCEL_ASYNC_TASK_TOOL_NAME, CHECK_ASYNC_TASK_TOOL_NAME, EDIT_FILE_TOOL_NAME, EVAL_TOOL_NAME, EXECUTE_PRESENTATION_CODE_TOOL_NAME, EXECUTE_SPREADSHEET_CODE_TOOL_NAME, EXECUTE_TOOL_NAME, EXECUTE_WORD_DOCUMENT_CODE_TOOL_NAME, type FileToolArgs, LIST_ASYNC_TASKS_TOOL_NAME, PTC_PARENT_TOOL_NAMES, QUIET_TOOL_NAMES, RUN_PYTHON_CODE_TOOL_NAME, salientToolCallDetail, START_ASYNC_TASK_TOOL_NAME, SUBMIT_FEEDBACK_TOOL_NAME, TASK_TOOL_NAME, UPDATE_ASYNC_TASK_TOOL_NAME, WRITE_FILE_TOOL_NAME, } from "./tool-names";
|
|
42
43
|
export { buildOptimisticHumanContent, type OptimisticContentPart, } from "./optimistic-content";
|
|
43
44
|
export { DEEP_AGENT_DEFAULT_CLIENT_PROTOCOL_VERSION, type DeepAgentProtocolDeclaration, type DeepAgentProtocolStatus, type DeepAgentWireProtocol, declaredDeepAgentProtocolVersion, isDeepAgentHostState, projectDeepAgentProtocol, readDeepAgentProtocol, withDeclaredProtocolVersion, } from "./protocol";
|
|
@@ -67,7 +68,7 @@ export { applyConfigPatch, applyToolsDisable, applyToolsEnable, diffThreadConfig
|
|
|
67
68
|
export { DEEP_AGENT_CONNECTION_STATUSES, type DeepAgentConnectionState, type DeepAgentConnectionStatus, type DeepAgentLaneProjection, type DeepAgentStreamValues, type LangGraphState, type PtcSubagentEntry, type Todo, } from "./types";
|
|
68
69
|
export { classifyVoiceStartError, type DeepAgentVoiceDiagnostic, type DeepAgentVoiceDiagnosticEvent, type DeepAgentVoiceFailure, type DeepAgentVoiceFailureKind, type DeepAgentVoiceFailureStage, type DeepAgentVoiceLiveKitAdapter, type DeepAgentVoiceCallMove, type DeepAgentVoiceLiveKitAnswer, type DeepAgentVoiceLiveKitSession, type DeepAgentVoiceModelOption, type DeepAgentVoiceOpening, type DeepAgentVoiceOwnerWireState, type DeepAgentVoicePhase, type DeepAgentVoiceRemoteStream, type DeepAgentVoiceStartOptions, type DeepAgentVoiceSurface, type DeepAgentVoiceToolCall, type DeepAgentVoiceTransferWireState, type DeepAgentVoiceTransport, type DeepAgentVoiceWireState, describeVoiceFailure, describeVoiceLiveElsewhere, describeVoiceMovedTo, describeVoiceWireError, float32FromPcm16, formatVoiceElapsed, parseVoiceLiveKitAnswer, parseVoiceModelOptions, parseVoiceOwner, pcm16FromFloat32, playVoiceMoveEarcon, useDeepAgentVoice, useVoiceElapsed, useVoiceMovedNotice, type UseDeepAgentVoiceOptions, type UseDeepAgentVoiceReturn, VOICE_LIVEKIT_ANSWER_PREFIX, VOICE_CONTINUE_BY_VOICE_LABEL, VOICE_LIVEKIT_OFFER, VOICE_MOVE_CALL_HERE_LABEL, VOICE_MOVE_EARCON_MS, VOICE_MOVE_EARCON_PEAK, VOICE_MOVE_EARCON_SAMPLE_RATE, VOICE_MOVE_HERE_ACTION, VOICE_MOVED_NOTICE_MS, VOICE_RELAY_ANSWER_PREFIX, VOICE_RELAY_SAMPLE_RATE, VOICE_WEBSOCKET_OFFER, voiceMoveEarconDataUri, voiceMoveEarconSamples, voiceMoveEarconWav, voiceRelayUrl, voiceSurfaceLabel, } from "./use-deep-agent-voice";
|
|
69
70
|
export { type DeepAgentVoiceWireError } from "./types";
|
|
70
|
-
export { describeVoiceUpdateToolCall, isSpokenTurnTextPart, isVoiceDelegationMessage, VOICE_DELEGATION_ID_PREFIX, VOICE_LIVE_KEY, VOICE_LIVE_TYPED_HINT, VOICE_SOURCE_DELEGATION, VOICE_SOURCE_SPOKEN, VOICE_SOURCE_TYPED, VOICE_TURN_IDS_KEY, VOICE_UPDATE_TOOL_NAME, type VoiceMessageMarker, type VoiceProvenance, type VoiceUpdateToolCall, voiceProvenanceLabel, voiceUpdateStatusLabel, } from "./voice-presentation";
|
|
71
|
+
export { describeVoiceUpdateToolCall, isSpokenTurnTextPart, isVoiceDelegationMessage, VOICE_DELEGATION_ID_PREFIX, VOICE_LIVE_KEY, VOICE_LIVE_TYPED_HINT, VOICE_SOURCE_DELEGATION, VOICE_SOURCE_SPOKEN, VOICE_SOURCE_TYPED, VOICE_TURN_IDS_KEY, VOICE_UPDATE_TOOL_NAME, type VoiceMessageMarker, type VoiceProvenance, type VoiceTranscriptMessage, type VoiceUpdateToolCall, voiceDelegationEchoesRequest, voiceProvenanceLabel, voiceUpdateStatusLabel, } from "./voice-presentation";
|
|
71
72
|
export { groupSpokenUserTurns, isSpokenUserTurn } from "./voice-turn-grouping";
|
|
72
73
|
export { CALL_RECAP_APPROVAL_LABEL, CALL_RECAP_TITLE, type CallRecap, type CallRecapApproval, type CallRecapAsset, type CallRecapItem, type CallRecapLink, type CallRecapMessage, type CallRecapOpenToolCall, type CallRecapPart, callRecapAfter, callRecapHasItems, callRecapItems, isCallUserMessage, mayHaveLiveCall, VOICE_TYPED_ID_PREFIX, } from "./call-recap";
|
|
73
74
|
export { canPersistDeepAgentSession, type DeepAgentPendingSession, type DeepAgentRunConfigRegistration, type DeepAgentSessionPersistence, type DeepAgentThreadElement, type DeepAgentThreadStateClientHost, logUnhandledStatewireError, useDeepAgentRuntime, type UseDeepAgentRuntimeOptions, } from "./use-deep-agent-runtime";
|
|
@@ -75,8 +76,8 @@ export { type DeepAgentAttachSource, type DeepAgentHeadersResolver, readSessionP
|
|
|
75
76
|
export { GITHUB_EVENT_SOURCE_KEY, type GithubWakeEvent, githubWakeEventLabel, githubWakeEventUrl, githubWakeMarkerText, githubWakeReference, isGithubWakeMessage, readGithubWakeEvent, } from "./github-wake-event";
|
|
76
77
|
export { githubSubscriptionHeadline, isSubscriptionWakeMessage, readSubscriptionWakeEvent, SUBSCRIPTION_EVENT_KEY, type SubscriptionWakeChange, type SubscriptionWakeEvent, type SubscriptionWakeGithub, subscriptionPlaceWords, subscriptionWakeDetail, subscriptionWakeGithub, subscriptionWakeHeadline, } from "./subscription-wake-event";
|
|
77
78
|
export { describeTerminationReason, readRuntimeMessageFromSourceMessages, readSoleRuntimeMessageKind, readTerminationReason, runtimeMessageMarkerText, TERMINATION_REASONS, type AthenaRuntimeMessage, type AthenaRuntimeMessageKind, type AthenaRuntimeMessageSeverity, type AthenaTerminationReason, type TerminationDescription, } from "./runtime-messages";
|
|
78
|
-
export { buildHandoffQrSvg, buildMobileHandoffSchemeUrl, classifyHandoffTransportError, type CreateThreadHandoffInput, type CreateThreadHandoffResponse, createThreadHandoffResponseSchema, describeHandoffTransportError, type DestinationReadiness, HANDOFF_DESTINATION_LABELS, HANDOFF_DESTINATIONS, HANDOFF_URL_PARAM, type HandoffDestination, type HandoffDestinationPresentation, type HandoffEnvironment, HandoffGoneError, type HandoffLaunch, type HandoffOutcome, HandoffPermanentError, type HandoffReadinessResponse, type HandoffReadinessState, type HandoffSource, type HandoffState, type HandoffTransportErrorKind, handoffHttpError, handoffReadinessResponseSchema, handoffStateSchema, isHandoffGoneError, isHandoffPermanentError, isRetryableHandoffHttpStatus, isOfficeHandoffDestination, isServerHandoffDestination, isTerminalHandoffState, type MobileHandoffLaunch, type MobileLaunchMode, mobileHandoffLaunchSchema, OFFICE_HANDOFF_DESTINATIONS, type OfficeHandoffDestination, type OfficeHandoffLaunch, officeHandoffLaunchSchema, type OfficeInvitationLaunch, officeInvitationLaunchSchema, type OfficeLaunchMode, officeLaunchModeSchema, threadHandoffCreateBody, parseHandoffIdParam, presentHandoffDestination, readinessByDestination, SERVER_HANDOFF_DESTINATIONS, type ServerHandoffDestination, selectMobileLaunchMode, supportsDesktopHandoffSource, type ThreadHandoffTransport, type ThreadHandoffView, threadHandoffViewSchema, waitForHandoffOutcome, type WaitForHandoffOutcomeOptions, type ClaimThreadHandoffResponse, claimThreadHandoffResponseSchema, clampHandoffDraft, handoffDraftToCarry, continuedFromLabel, pickUpFromLabel, pickUpOfferLabel, type DesktopThreadHandoffLaunch, desktopThreadHandoffLaunchSchema, driverSurfaceForChannel, drivingOnLabel, type HandoffLanding, handoffLandingFromView, isPickupSurface, MAX_HANDOFF_DRAFT_LENGTH, nextHandoffLaunchSchema, parseThreadHandoffCreateResponse, pendingThreadHandoffResponseSchema, pickedUpOnLabel, PICKUP_SURFACES, type PickupSurface, shouldOfferPendingHandoff, IMPLICIT_PICKUP_ACTIVATION_WINDOW_MS, IMPLICIT_PICKUP_DECLINE_HOLD_MS, type ImplicitPickupAnswer, type ImplicitPickupContext, implicitPickupAllowed, isImplicitHandoff, nextImplicitPickupAnswer, SPACES_HANDOFF_URL_PARAM, type SpacesHandoffLaunch, spacesHandoffLaunchSchema, SURFACE_HANDOFF_DESTINATIONS, type SurfaceHandoffDestination, supportsSurfaceHandoffDestinations, THREAD_HANDOFF_DESTINATION_LABELS, THREAD_HANDOFF_DESTINATIONS, threadHandoffClaimBody, threadHandoffCreateRequest, type ThreadHandoffDestination, type ThreadHandoffReceiverTransport, MAX_PENDING_EXCLUDE, handoffDeclineKey, pendingExcludeIds, pickupExcludeIds, pendingHandoffPath, type HandoffMode, handoffModeSchema, isVoiceHandoffDestination, MAX_HANDOFF_CURSOR_LENGTH, parseHandoffCursor, supportsHandoffCursor, livenessAgo, presentSurfaceLiveness, type SurfaceLiveness, type SurfaceLivenessBasis, surfaceLivenessBasisSchema, surfaceLivenessBySurface, type SurfaceLivenessPresentation, surfaceLivenessSchema, type SurfaceLivenessState, surfaceLivenessStateSchema, type SurfaceLivenessTone, supportsSurfaceLiveness, } from "./thread-handoff";
|
|
79
|
-
export {
|
|
79
|
+
export { buildHandoffQrSvg, buildMobileHandoffSchemeUrl, classifyHandoffTransportError, type CreateThreadHandoffInput, type CreateThreadHandoffResponse, createThreadHandoffResponseSchema, describeHandoffTransportError, type DestinationReadiness, HANDOFF_DESTINATION_LABELS, HANDOFF_DESTINATIONS, HANDOFF_EXPIRY_GRACE_MS, HANDOFF_TICKET_LIFETIME_MS, HANDOFF_URL_PARAM, type HandoffDestination, type HandoffDestinationPresentation, type HandoffEnvironment, HandoffGoneError, type HandoffLaunch, type HandoffOutcome, HandoffPermanentError, type HandoffReadinessResponse, type HandoffReadinessState, type HandoffSource, type HandoffState, type HandoffTransportErrorKind, handoffHttpError, handoffReadinessResponseSchema, handoffStateSchema, handoffTicketLifetimeMs, isHandoffGoneError, isHandoffPermanentError, isRetryableHandoffHttpStatus, isOfficeHandoffDestination, isServerHandoffDestination, isTerminalHandoffState, type MobileHandoffLaunch, type MobileLaunchMode, mobileHandoffLaunchSchema, OFFICE_HANDOFF_DESTINATIONS, type OfficeHandoffDestination, type OfficeHandoffLaunch, officeHandoffLaunchSchema, type OfficeInvitationLaunch, officeInvitationLaunchSchema, type OfficeLaunchMode, officeLaunchModeSchema, threadHandoffCreateBody, parseHandoffIdParam, presentHandoffDestination, readinessByDestination, SERVER_HANDOFF_DESTINATIONS, type ServerHandoffDestination, selectMobileLaunchMode, supportsDesktopHandoffSource, type ThreadHandoffTransport, type ThreadHandoffView, threadHandoffViewSchema, waitForHandoffOutcome, type WaitForHandoffOutcomeOptions, type ClaimThreadHandoffResponse, claimThreadHandoffResponseSchema, clampHandoffDraft, handoffDraftToCarry, continuedFromLabel, pickUpFromLabel, pickUpOfferLabel, type DesktopThreadHandoffLaunch, desktopThreadHandoffLaunchSchema, driverSurfaceForChannel, drivingOnLabel, type HandoffLanding, handoffLandingFromView, isPickupSurface, MAX_HANDOFF_DRAFT_LENGTH, nextHandoffLaunchSchema, parseThreadHandoffCreateResponse, pendingThreadHandoffResponseSchema, pickedUpOnLabel, PICKUP_SURFACES, type PickupSurface, shouldOfferPendingHandoff, IMPLICIT_PICKUP_ACTIVATION_WINDOW_MS, IMPLICIT_PICKUP_DECLINE_HOLD_MS, type ImplicitPickupAnswer, type ImplicitPickupContext, implicitPickupAllowed, isImplicitHandoff, nextImplicitPickupAnswer, SPACES_HANDOFF_URL_PARAM, type SpacesHandoffLaunch, spacesHandoffLaunchSchema, SURFACE_HANDOFF_DESTINATIONS, type SurfaceHandoffDestination, supportsSurfaceHandoffDestinations, THREAD_HANDOFF_DESTINATION_LABELS, THREAD_HANDOFF_DESTINATIONS, threadHandoffClaimBody, threadHandoffCreateRequest, type ThreadHandoffDestination, type ThreadHandoffReceiverTransport, MAX_PENDING_EXCLUDE, handoffDeclineKey, pendingExcludeIds, pickupExcludeIds, pendingHandoffPath, type HandoffMode, handoffModeSchema, isVoiceHandoffDestination, MAX_HANDOFF_CURSOR_LENGTH, parseHandoffCursor, supportsHandoffCursor, livenessAgo, presentSurfaceLiveness, type SurfaceLiveness, type SurfaceLivenessBasis, surfaceLivenessBasisSchema, surfaceLivenessBySurface, type SurfaceLivenessPresentation, surfaceLivenessSchema, type SurfaceLivenessState, surfaceLivenessStateSchema, type SurfaceLivenessTone, supportsSurfaceLiveness, } from "./thread-handoff";
|
|
80
|
+
export { type StartThreadHandoffInput, type ThreadHandoffFlowCallbacks, type ThreadHandoffFlowController, type ThreadHandoffFlowPhase, useThreadHandoffFlow, type UseThreadHandoffFlowOptions, } from "./use-thread-handoff-flow";
|
|
80
81
|
export { anchorHandoffArrival, clearHandoffArrival, type HandoffArrival, HandoffArrivalContext, MAX_HANDOFF_ARRIVALS, readHandoffArrival, recordHandoffArrival, resetHandoffArrivalsForTests, settleHandoffArrivalCursor, subscribeHandoffArrivals, useHandoffArrival, useHandoffArrivalAfter, useHandoffArrivalCursor, } from "./handoff-arrival";
|
|
81
82
|
export { HANDOFF_CURSOR_HIGHLIGHT_MS, HANDOFF_CURSOR_MAX_HISTORY_PAGES, HANDOFF_CURSOR_SETTLE_MS, HANDOFF_CURSOR_WAIT_MS, handoffCursorMessageId, handoffCursorRevealStep, type HandoffCursorRevealStep, MESSAGE_ROW_ID_ATTRIBUTE, READING_CURSOR_BOTTOM_TOLERANCE_PX, READING_LINE_FRACTION, type ReadingRow, type ReadingViewportLike, readingCursorFromRows, readingCursorFromVisibleIds, readingCursorOf, } from "./handoff-cursor";
|
|
82
83
|
export { connectVoiceMedia, VOICE_MICROPHONE_CAPTURE } from './voice-media';
|
|
@@ -104,15 +104,11 @@ function pageInterestRequests(window, size) {
|
|
|
104
104
|
if (appended.length <= runconfigContract.DEEP_AGENT_MAX_INTERESTS) return appended;
|
|
105
105
|
return coalescedInterestRequests(window.chain, page.before - 1);
|
|
106
106
|
}
|
|
107
|
-
function interestsCovered(carried, stated) {
|
|
108
|
-
return stated.every(
|
|
109
|
-
(request) => carried.some((have) => have.at === request.at && have.before >= request.before)
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
107
|
function readDeepAgentMessageWindow(mounted) {
|
|
113
108
|
var _a, _b, _c;
|
|
114
109
|
if (mounted === void 0) return null;
|
|
115
110
|
let windows;
|
|
111
|
+
let threadId;
|
|
116
112
|
const documents = /* @__PURE__ */ new Map();
|
|
117
113
|
for (const document of mounted.values()) {
|
|
118
114
|
const key = document.key;
|
|
@@ -120,6 +116,7 @@ function readDeepAgentMessageWindow(mounted) {
|
|
|
120
116
|
windows = (_a = readDeepAgentInterestDocument(document.value)) == null ? void 0 : _a.windows;
|
|
121
117
|
} else if (document.protocol === statewireTransport.DEEP_AGENT_STATEWIRE_PROTOCOL && key !== null && key[1] === runconfigContract.DEEP_AGENT_MAIN_NS && (key.length === 3 || key.length === 4 && key[3] === runconfigContract.DEEP_AGENT_CUT_LANE_DOCUMENT)) {
|
|
122
118
|
documents.set(key[2], document.value);
|
|
119
|
+
if (threadId === void 0 && typeof key[0] === "string") threadId = key[0];
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
const head = windows == null ? void 0 : windows[0];
|
|
@@ -149,7 +146,110 @@ function readDeepAgentMessageWindow(mounted) {
|
|
|
149
146
|
const message = documents.get(entry.id);
|
|
150
147
|
if (message !== void 0) messages.push(message);
|
|
151
148
|
}
|
|
152
|
-
return { requests, chain, messages, hasOlder, pages };
|
|
149
|
+
return { requests, chain, messages, hasOlder, pages, ...threadId !== void 0 && { threadId } };
|
|
150
|
+
}
|
|
151
|
+
const echoedRequest = (window) => {
|
|
152
|
+
const { ns, before, at, after, follow } = window;
|
|
153
|
+
if (ns !== runconfigContract.DEEP_AGENT_MAIN_NS || !isIndex(before)) return null;
|
|
154
|
+
if (at !== void 0 && typeof at !== "string") return null;
|
|
155
|
+
if (after !== void 0 && !isIndex(after)) return null;
|
|
156
|
+
const followBefore = typeof follow === "object" && follow !== null ? follow.before : void 0;
|
|
157
|
+
if (follow !== void 0 && !isIndex(followBefore)) return null;
|
|
158
|
+
return {
|
|
159
|
+
ns: runconfigContract.DEEP_AGENT_MAIN_NS,
|
|
160
|
+
before,
|
|
161
|
+
...at !== void 0 && { at },
|
|
162
|
+
...after !== void 0 && { after },
|
|
163
|
+
...isIndex(followBefore) && { follow: { before: followBefore } }
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const firstChainId = (chain) => {
|
|
167
|
+
var _a;
|
|
168
|
+
if (!Array.isArray(chain)) return void 0;
|
|
169
|
+
const id = (_a = chain[0]) == null ? void 0 : _a.id;
|
|
170
|
+
return typeof id === "string" && id ? id : void 0;
|
|
171
|
+
};
|
|
172
|
+
function readDeepAgentInterestDeclaration(mounted) {
|
|
173
|
+
var _a;
|
|
174
|
+
if (mounted === void 0) return null;
|
|
175
|
+
let windows;
|
|
176
|
+
for (const document of mounted.values()) {
|
|
177
|
+
if (document.protocol !== runconfigContract.DEEP_AGENT_INTEREST_PROTOCOL || document.main !== true) continue;
|
|
178
|
+
const value = document.value;
|
|
179
|
+
if (value !== null && typeof value === "object" && Array.isArray(value.windows)) {
|
|
180
|
+
windows = value.windows;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (windows === void 0 || windows.length === 0) return null;
|
|
184
|
+
const requests = [];
|
|
185
|
+
const deepest = /* @__PURE__ */ new Map();
|
|
186
|
+
for (const [index, window] of windows.entries()) {
|
|
187
|
+
if (typeof window !== "object" || window === null) return null;
|
|
188
|
+
const record = window;
|
|
189
|
+
const request = echoedRequest(record);
|
|
190
|
+
if (request === null) return null;
|
|
191
|
+
if (index === 0 && request.at !== void 0) return null;
|
|
192
|
+
if (index === 0 || firstChainId(record.chain) !== void 0) requests.push(request);
|
|
193
|
+
const follows2 = record.follows;
|
|
194
|
+
if (typeof follows2 !== "object" || follows2 === null) continue;
|
|
195
|
+
for (const [ns, follow] of Object.entries(follows2)) {
|
|
196
|
+
const chain = follow == null ? void 0 : follow.chain;
|
|
197
|
+
if (!Array.isArray(chain) || chain.length <= (((_a = deepest.get(ns)) == null ? void 0 : _a.length) ?? 0)) continue;
|
|
198
|
+
deepest.set(ns, chain);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const floor = firstChainId(windows[0].chain);
|
|
202
|
+
const follows = {};
|
|
203
|
+
for (const [ns, chain] of deepest) {
|
|
204
|
+
const step = firstChainId(chain);
|
|
205
|
+
if (step !== void 0) follows[ns] = step;
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
requests,
|
|
209
|
+
...floor !== void 0 && { floor },
|
|
210
|
+
...Object.keys(follows).length > 0 && { follows }
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function encodeDeepAgentInterestDeclaration(declaration) {
|
|
214
|
+
const encoded = JSON.stringify(declaration).replace(
|
|
215
|
+
/[^ -~]/g,
|
|
216
|
+
(char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
217
|
+
);
|
|
218
|
+
return encoded.length > runconfigContract.DEEP_AGENT_MAX_MESSAGE_INTERESTS_HEADER_BYTES ? null : encoded;
|
|
219
|
+
}
|
|
220
|
+
function withDeclaredInterests(headers, declaration) {
|
|
221
|
+
if (declaration === null || runconfigContract.DEEP_AGENT_MESSAGE_INTERESTS_HEADER in headers) return headers;
|
|
222
|
+
const encoded = encodeDeepAgentInterestDeclaration(declaration);
|
|
223
|
+
return encoded === null ? headers : { ...headers, [runconfigContract.DEEP_AGENT_MESSAGE_INTERESTS_HEADER]: encoded };
|
|
224
|
+
}
|
|
225
|
+
function messageWindowCarries({
|
|
226
|
+
hello,
|
|
227
|
+
held
|
|
228
|
+
}) {
|
|
229
|
+
var _a;
|
|
230
|
+
const oldest = (_a = held.chain[0]) == null ? void 0 : _a.id;
|
|
231
|
+
if (oldest === void 0 || !hello.hasOlder) return true;
|
|
232
|
+
return hello.chain.some((entry) => entry.id === oldest);
|
|
233
|
+
}
|
|
234
|
+
function restatedInterestRequests({
|
|
235
|
+
held,
|
|
236
|
+
hello = null
|
|
237
|
+
}) {
|
|
238
|
+
var _a, _b;
|
|
239
|
+
const [head, ...pages] = held.requests;
|
|
240
|
+
if (head === void 0) return [];
|
|
241
|
+
const newest = (_a = held.chain.at(-1)) == null ? void 0 : _a.id;
|
|
242
|
+
const since = hello === null || newest === void 0 ? -1 : hello.chain.findIndex((entry) => entry.id === newest);
|
|
243
|
+
const chain = since === -1 || hello === null ? held.chain : [...held.chain, ...hello.chain.slice(since + 1)];
|
|
244
|
+
const anchor = (_b = pages[0]) == null ? void 0 : _b.at;
|
|
245
|
+
const start = anchor === void 0 ? 0 : chain.findIndex((entry) => entry.id === anchor);
|
|
246
|
+
const covered = hello !== null && since === -1 ? runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW : chain.length - Math.max(0, start);
|
|
247
|
+
if (covered > runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW) {
|
|
248
|
+
const coalesced = coalescedInterestRequests(chain, 0);
|
|
249
|
+
if (coalesced !== null) return coalesced;
|
|
250
|
+
}
|
|
251
|
+
const before = Math.min(runconfigContract.DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.max(head.before, covered));
|
|
252
|
+
return [{ ...head, before }, ...pages];
|
|
153
253
|
}
|
|
154
254
|
function buildToolOutputCommand({ messageId }) {
|
|
155
255
|
return { type: runconfigContract.DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };
|
|
@@ -192,10 +292,12 @@ exports.ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = ATHENA_TRUNCATED_TOOL_OUTPUT
|
|
|
192
292
|
exports.buildHistoryMessageCommand = buildHistoryMessageCommand;
|
|
193
293
|
exports.buildToolOutputCommand = buildToolOutputCommand;
|
|
194
294
|
exports.clampMessageWindowSize = clampMessageWindowSize;
|
|
295
|
+
exports.encodeDeepAgentInterestDeclaration = encodeDeepAgentInterestDeclaration;
|
|
195
296
|
exports.headInterestRequest = headInterestRequest;
|
|
196
|
-
exports.
|
|
297
|
+
exports.messageWindowCarries = messageWindowCarries;
|
|
197
298
|
exports.pageInterestRequest = pageInterestRequest;
|
|
198
299
|
exports.pageInterestRequests = pageInterestRequests;
|
|
300
|
+
exports.readDeepAgentInterestDeclaration = readDeepAgentInterestDeclaration;
|
|
199
301
|
exports.readDeepAgentInterestDocument = readDeepAgentInterestDocument;
|
|
200
302
|
exports.readDeepAgentInterestResolution = readDeepAgentInterestResolution;
|
|
201
303
|
exports.readDeepAgentMessageWindow = readDeepAgentMessageWindow;
|
|
@@ -203,5 +305,7 @@ exports.readHistoryMessageResult = readHistoryMessageResult;
|
|
|
203
305
|
exports.readToolOutputResult = readToolOutputResult;
|
|
204
306
|
exports.readTruncatedToolContent = readTruncatedToolContent;
|
|
205
307
|
exports.readTruncatedToolOutputArtifact = readTruncatedToolOutputArtifact;
|
|
308
|
+
exports.restatedInterestRequests = restatedInterestRequests;
|
|
309
|
+
exports.withDeclaredInterests = withDeclaredInterests;
|
|
206
310
|
exports.withDeclaredMessageWindow = withDeclaredMessageWindow;
|
|
207
311
|
//# sourceMappingURL=message-window.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-window.cjs","sources":["../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireDocuments } from 'statewire';\nimport {\n DEEP_AGENT_CUT_LANE_DOCUMENT,\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_INTEREST_PROTOCOL,\n DEEP_AGENT_MAIN_NS,\n DEEP_AGENT_MAX_INTERESTS,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from './statewire-transport';\n\n/**\n * The interest window — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * The wire main document carries no `messages`. A client states its interests\n * on the `athena/interest` lane as one array (`set(requests)`): the first is\n * the head (the newest `before` messages of the `main` namespace), the rest\n * are pages anchored `at` the first message of the window they extend. The\n * host holds one ephemeral main document per attach, `{ windows }`, one\n * resolution per request in order (the request echoed plus the covered\n * `chain` and `more` flags; an anchor that vanished leaves an empty window in\n * place), and one shared `athena` document per covered message, keyed\n * `[threadId, \"main\", messageId]` — or `[threadId, \"main\", messageId, \"cut\"]`\n * for a finished card a version-2 view carries cut to its newest steps (its\n * whole lane pages in through `history/lane`, see `lane-history.ts`).\n * {@link readDeepAgentMessageWindow} joins them into the transcript the\n * converter renders.\n *\n * Two host rules shape the client half. The head window never drops below\n * the oldest message it has carried on an attach (a run's appends grow the\n * view, nothing loaded slides out), so a page stays anchored at the head's\n * first message while the transcript grows; and the host remembers a client\n * id's interests across its attaches, so a reconnect's hello carries the\n * view the client held. A fresh client's hello carries the head it declared\n * on the attach headers ({@link withDeclaredMessageWindow}) — a statement\n * cannot ride the first attach, the hello negotiates the lanes.\n *\n * Pages are appended one per load until the host's interest cap, then the\n * loaded range is restated in as few maximal requests as it takes\n * ({@link pageInterestRequests}); the whole transcript stays reachable up to\n * `MAX_INTERESTS × MAX_MESSAGE_WINDOW` messages. A truncated tool output\n * comes back whole through `history/tool_output` ({@link buildToolOutputCommand});\n * a message's stored form — provenance blobs and all — through\n * `history/message` ({@link buildHistoryMessageCommand}).\n */\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/** What a surface declares for its window: the interest size (the host clamps to its bounds). */\nexport interface DeepAgentMessageWindowDeclaration {\n size?: number;\n}\n\nexport function clampMessageWindowSize(size?: number): number {\n if (size === undefined || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n return Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n}\n\n/** An `athena/interest` request over the linear transcript. */\nexport interface DeepAgentInterestRequest {\n readonly ns: typeof DEEP_AGENT_MAIN_NS;\n /** Messages ending at the anchor (the tail without `at`). */\n readonly before: number;\n /** Anchor message id; a page's is the first message of the window it extends. */\n readonly at?: string;\n /** Messages past the anchor (requires `at`). */\n readonly after?: number;\n /** The newest steps of every subagent lane a covered card names (see `lane-follow.ts`). */\n readonly follow?: { readonly before: number };\n}\n\nexport function headInterestRequest(size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };\n}\n\nexport function pageInterestRequest(at: string, size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };\n}\n\n/**\n * Attach headers with the head window declared (`x-athena-deep-agent-window`):\n * the hello of a client the host does not remember carries the newest `size`\n * messages. Part of the one attach recipe, so a pooled dial asks for the shape\n * the thread's own attach would. An explicit entry (tests, overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;\n return {\n ...headers,\n [DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size)),\n };\n}\n\nexport interface DeepAgentInterestChainEntry {\n id: string;\n siblings: string[];\n}\n\n/** The host's resolution document of one interest: the request echoed plus its coverage. */\nexport interface DeepAgentInterestResolution extends DeepAgentInterestRequest {\n /** Covered message ids, oldest first (a page ends at its anchor). */\n chain: DeepAgentInterestChainEntry[];\n more: { before: boolean; after: boolean };\n}\n\nexport function readDeepAgentInterestResolution(value: unknown): DeepAgentInterestResolution | null {\n if (typeof value !== 'object' || value === null) return null;\n const { ns, before, at, after, chain, more } = value as Record<string, unknown>;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n if (typeof more !== 'object' || more === null) return null;\n const { before: moreBefore, after: moreAfter } = more as Record<string, unknown>;\n if (typeof moreBefore !== 'boolean' || typeof moreAfter !== 'boolean') return null;\n const entries: DeepAgentInterestChainEntry[] = [];\n for (const entry of chain) {\n const { id, siblings } = (entry ?? {}) as Record<string, unknown>;\n if (typeof id !== 'string') return null;\n entries.push({\n id,\n siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === 'string') : [id],\n });\n }\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n chain: entries,\n more: { before: moreBefore, after: moreAfter },\n };\n}\n\n/** The attach's interest document: one resolution per stated request, in order. */\nexport interface DeepAgentInterestDocument {\n windows: DeepAgentInterestResolution[];\n}\n\nexport function readDeepAgentInterestDocument(value: unknown): DeepAgentInterestDocument | null {\n if (typeof value !== 'object' || value === null) return null;\n const { windows } = value as Record<string, unknown>;\n if (!Array.isArray(windows)) return null;\n const resolutions: DeepAgentInterestResolution[] = [];\n for (const window of windows) {\n const resolution = readDeepAgentInterestResolution(window);\n if (resolution === null) return null;\n resolutions.push(resolution);\n }\n return { windows: resolutions };\n}\n\nconst interestRequest = ({ ns, before, at, after }: DeepAgentInterestRequest): DeepAgentInterestRequest => ({\n ns,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n});\n\n/** The loaded transcript window, joined from the head interest and its anchored pages. */\nexport interface DeepAgentMessageWindow {\n /** The requests the joined view stands on, in order (the head first): what a `set` restates. A stale page (its anchor gone) or one the head already covers is left out. */\n requests: DeepAgentInterestRequest[];\n /** Covered chain, oldest first. */\n chain: DeepAgentInterestChainEntry[];\n /** The chain's message documents, in chain order (an unmounted one is skipped). */\n messages: LangChainMessage[];\n /** Whether the host holds messages older than the window. */\n hasOlder: boolean;\n /** Pages joined onto the head. */\n pages: number;\n}\n\n/**\n * The loaded chain plus `grow` older messages, restated in as few requests as\n * it takes: a maximal head, then maximal pages each anchored at the first\n * message of the window above it. `null` once even that exceeds the host's\n * interest cap — the reachable depth is `MAX_INTERESTS × MAX_MESSAGE_WINDOW`.\n */\nfunction coalescedInterestRequests(\n chain: readonly DeepAgentInterestChainEntry[],\n grow: number\n): DeepAgentInterestRequest[] | null {\n const loaded = chain.length;\n const requests: DeepAgentInterestRequest[] = [\n { ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) },\n ];\n // `low` is the chain index of the lowest message the plan covers so far.\n let low = loaded - (requests[0] as DeepAgentInterestRequest).before;\n while (low > 0) {\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before,\n at: (chain[low] as DeepAgentInterestChainEntry).id,\n });\n low = low + 1 - before;\n }\n // The plan covers the chain; the new messages extend its lowest request\n // when that stays within one window, else they are a page of their own.\n const last = requests[requests.length - 1] as DeepAgentInterestRequest;\n if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n requests[requests.length - 1] = { ...last, before: last.before + grow };\n } else {\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before: grow + 1,\n at: (chain[0] as DeepAgentInterestChainEntry).id,\n });\n }\n return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;\n}\n\n/**\n * The requests to state for one more page of older history, or `null` when\n * there is nothing to load (no anchor, the beginning reached) or the host's\n * interest cap is spent. One page is appended, anchored at the window's first\n * message, while the cap allows; at the cap the loaded range is coalesced\n * into maximal requests first (see {@link coalescedInterestRequests}).\n */\nexport function pageInterestRequests(\n window: DeepAgentMessageWindow,\n size?: number\n): DeepAgentInterestRequest[] | null {\n const anchor = window.chain[0]?.id;\n if (anchor === undefined || !window.hasOlder) return null;\n const page = pageInterestRequest(anchor, size);\n const appended = [...window.requests, page];\n if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;\n // A page's `before` counts its anchor: it adds `before - 1` older messages.\n return coalescedInterestRequests(window.chain, page.before - 1);\n}\n\n/**\n * Whether every `stated` request is carried by `carried` (the same anchor, at\n * least as wide): a reconnect's hello that carries what the client last\n * stated — the host remembers a client id's interests — needs no restatement.\n */\nexport function interestsCovered(\n carried: readonly DeepAgentInterestRequest[],\n stated: readonly DeepAgentInterestRequest[]\n): boolean {\n return stated.every((request) =>\n carried.some((have) => have.at === request.at && have.before >= request.before)\n );\n}\n\n/**\n * The window off the mounted documents, or `null` while the head interest has\n * not resolved (pre-attach, before the first `set` answer, a wire without\n * documents). A page joins wherever its anchor sits in the chain so far — at\n * the first message it extends the view, inside the head (the head widened\n * past it) it adds nothing and is left out of `requests`; a page whose anchor\n * left the transcript (a rewind emptied it in place) is left out too. A\n * malformed document reads as absent.\n */\nexport function readDeepAgentMessageWindow(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentMessageWindow | null {\n if (mounted === undefined) return null;\n let windows: DeepAgentInterestResolution[] | undefined;\n const documents = new Map<string, LangChainMessage>();\n for (const document of mounted.values()) {\n const key = document.key;\n if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {\n windows = readDeepAgentInterestDocument(document.value)?.windows;\n } else if (\n document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL &&\n key !== null &&\n key[1] === DEEP_AGENT_MAIN_NS &&\n (key.length === 3 || (key.length === 4 && key[3] === DEEP_AGENT_CUT_LANE_DOCUMENT))\n ) {\n documents.set(key[2] as string, document.value as LangChainMessage);\n }\n }\n const head = windows?.[0];\n if (windows === undefined || head === undefined) return null;\n let chain = head.chain;\n let hasOlder = head.more.before;\n const requests = [interestRequest(head)];\n const loaded = new Set(chain.map((entry) => entry.id));\n let pages = 0;\n for (const page of windows.slice(1)) {\n if (page.at === undefined || !loaded.has(page.at)) continue;\n const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);\n if (anchorAt < 0) continue;\n // Both windows are ranges of one linear transcript sharing the anchor:\n // what the page holds below it and the chain does not is a prefix.\n const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));\n if (fresh.length === 0) {\n // Nothing new, but a page that starts where the loaded chain starts\n // has looked below it: its `more.before` is the answer for the edge.\n if (page.chain[0]?.id === chain[0]?.id) hasOlder = page.more.before;\n continue;\n }\n chain = [...fresh, ...chain];\n for (const entry of fresh) loaded.add(entry.id);\n hasOlder = page.more.before;\n requests.push(interestRequest(page));\n pages += 1;\n }\n const messages: LangChainMessage[] = [];\n for (const entry of chain) {\n const message = documents.get(entry.id);\n if (message !== undefined) messages.push(message);\n }\n return { requests, chain, messages, hasOlder, pages };\n}\n\n/**\n * The windowed wire's read command on the statewire command union, so\n * `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the\n * deep-agent host is driven (`DeepAgentThread.history_tool_output`, an\n * attach-ACL read).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n /** One stored message whole — the per-client shape, by command. */\n historyMessage: HistoryMessageCommand;\n }\n }\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/**\n * The `history/message` command: a message as the host stores it — the\n * model-provenance blobs the wire strips and an untruncated tool output\n * included. Every client receives one projected wire form; this is the one\n * per-client shape, fetched on demand like `history/tool_output`.\n */\nexport interface HistoryMessageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_MESSAGE_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildHistoryMessageCommand({\n messageId,\n}: {\n messageId: string;\n}): HistoryMessageCommand {\n return { type: DEEP_AGENT_HISTORY_MESSAGE_COMMAND, messageId };\n}\n\nexport interface HistoryMessageResult {\n messageId: string;\n message: LangChainMessage;\n}\n\nexport function readHistoryMessageResult(payload: unknown): HistoryMessageResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, message } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n if (typeof message !== 'object' || message === null) return null;\n return { messageId, message: message as LangChainMessage };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","DEEP_AGENT_MIN_MESSAGE_WINDOW","DEEP_AGENT_MAX_MESSAGE_WINDOW","DEEP_AGENT_MAIN_NS","DEEP_AGENT_MESSAGE_WINDOW_HEADER","DEEP_AGENT_MAX_INTERESTS","DEEP_AGENT_INTEREST_PROTOCOL","DEEP_AGENT_STATEWIRE_PROTOCOL","DEEP_AGENT_CUT_LANE_DOCUMENT","DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND","DEEP_AGENT_HISTORY_MESSAGE_COMMAND","DEEP_AGENT_TRUNCATED_CONTENT_KEY"],"mappings":";;;;AAqDA,MAAM,UAAU,CAAC,UACf,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,SAAS;AAO5D,SAAS,uBAAuB,MAAuB;AAC5D,MAAI,SAAS,UAAa,CAAC,OAAO,SAAS,IAAI,EAAG,QAAOA,kBAAAA;AACzD,SAAO,KAAK;AAAA,IACVC,kBAAAA;AAAAA,IACA,KAAK,IAAIC,kBAAAA,+BAA+B,KAAK,MAAM,IAAI,CAAC;AAAA,EAAA;AAE5D;AAeO,SAAS,oBAAoB,MAAyC;AAC3E,SAAO,EAAE,IAAIC,kBAAAA,oBAAoB,QAAQ,uBAAuB,IAAI,EAA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AAA,IAAY;AAC/B,MAAI,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AACxD,SAAO,EAAE,WAAW,QAAA;AACtB;AAaO,SAAS,2BAA2B;AAAA,EACzC;AACF,GAE0B;AACxB,SAAO,EAAE,MAAMC,kBAAAA,oCAAoC,UAAA;AACrD;AAOO,SAAS,yBAAyB,SAA+C;AACtF,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,EAAE,WAAW,QAAA,IAAY;AAC/B,MAAI,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AACxD,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,SAAO,EAAE,WAAW,QAAA;AACtB;AAYO,SAAS,yBAAyB,SAA+C;AACtF,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,SAAU,QAAoCC,kDAAgC;AACpF,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,QAAS,OAAmC;AAClD,SAAO,QAAQ,KAAK,IAAI,EAAE,UAAU;AACtC;AAQO,MAAM,4CAA4C;AAUlD,SAAS,gCACd,UACoC;AACpC,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,SAAU,SAAqC,yCAAyC;AAC9F,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,OAAO,UAAA,IAAc;AAC7B,MAAI,CAAC,QAAQ,KAAK,KAAK,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AAC3E,SAAO,EAAE,OAAO,UAAA;AAClB;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"message-window.cjs","sources":["../../../../agent-runtime/src/message-window.ts"],"sourcesContent":["import type { LangChainMessage } from '@assistant-ui/react-langgraph';\nimport type { StatewireDocuments } from 'statewire';\nimport {\n DEEP_AGENT_CUT_LANE_DOCUMENT,\n DEEP_AGENT_DEFAULT_MESSAGE_WINDOW,\n DEEP_AGENT_HISTORY_MESSAGE_COMMAND,\n DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND,\n DEEP_AGENT_INTEREST_PROTOCOL,\n DEEP_AGENT_MAIN_NS,\n DEEP_AGENT_MAX_INTERESTS,\n DEEP_AGENT_MAX_MESSAGE_INTERESTS_HEADER_BYTES,\n DEEP_AGENT_MAX_MESSAGE_WINDOW,\n DEEP_AGENT_MESSAGE_INTERESTS_HEADER,\n DEEP_AGENT_MESSAGE_WINDOW_HEADER,\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n DEEP_AGENT_TRUNCATED_CONTENT_KEY,\n} from './generated/runconfig-contract';\nimport { DEEP_AGENT_STATEWIRE_PROTOCOL } from './statewire-transport';\n\n/**\n * The interest window — the client half of agora's\n * `agora/graphs/athena_deep_agent/message_window.py`.\n *\n * The wire main document carries no `messages`. A client states its interests\n * on the `athena/interest` lane as one array (`set(requests)`): the first is\n * the head (the newest `before` messages of the `main` namespace), the rest\n * are pages anchored `at` the first message of the window they extend. The\n * host holds one ephemeral main document per attach, `{ windows }`, one\n * resolution per request in order (the request echoed plus the covered\n * `chain` and `more` flags; an anchor that vanished leaves an empty window in\n * place), and one shared `athena` document per covered message, keyed\n * `[threadId, \"main\", messageId]` — or `[threadId, \"main\", messageId, \"cut\"]`\n * for a finished card a version-2 view carries cut to its newest steps (its\n * whole lane pages in through `history/lane`, see `lane-history.ts`).\n * {@link readDeepAgentMessageWindow} joins them into the transcript the\n * converter renders.\n *\n * Two host rules shape the client half. The head window never drops below\n * the oldest message it has carried on an attach (a run's appends grow the\n * view, nothing loaded slides out), so a page stays anchored at the head's\n * first message while the transcript grows; and a re-attach's hello carries\n * the view the client held. A fresh client's hello carries the head it\n * declared on the attach headers ({@link withDeclaredMessageWindow}) — a\n * statement cannot ride the first attach, the hello negotiates the lanes. A\n * re-attach declares the view it holds there too\n * ({@link readDeepAgentInterestDeclaration}, {@link withDeclaredInterests}),\n * so its hello carries every page it had loaded on whichever host instance it\n * lands on: the host's own memo of a client id lives on one instance, and a\n * deploy moves the thread to another.\n *\n * Pages are appended one per load until the host's interest cap, then the\n * loaded range is restated in as few maximal requests as it takes\n * ({@link pageInterestRequests}), up to `MAX_INTERESTS × MAX_MESSAGE_WINDOW`\n * messages. The interest document lists every loaded message and the host\n * keeps it within a byte budget, which binds first: about a thousand\n * messages, after which the host refuses a page as `oversized-interest`\n * (`useDeepAgentWindowSync` then reports `canLoadOlder` false). A truncated tool output\n * comes back whole through `history/tool_output` ({@link buildToolOutputCommand});\n * a message's stored form — provenance blobs and all — through\n * `history/message` ({@link buildHistoryMessageCommand}).\n */\n\nconst isIndex = (value: unknown): value is number =>\n typeof value === 'number' && Number.isInteger(value) && value >= 0;\n\n/** What a surface declares for its window: the interest size (the host clamps to its bounds). */\nexport interface DeepAgentMessageWindowDeclaration {\n size?: number;\n}\n\nexport function clampMessageWindowSize(size?: number): number {\n if (size === undefined || !Number.isFinite(size)) return DEEP_AGENT_DEFAULT_MESSAGE_WINDOW;\n return Math.max(\n DEEP_AGENT_MIN_MESSAGE_WINDOW,\n Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.trunc(size))\n );\n}\n\n/** An `athena/interest` request over the linear transcript. */\nexport interface DeepAgentInterestRequest {\n readonly ns: typeof DEEP_AGENT_MAIN_NS;\n /** Messages ending at the anchor (the tail without `at`). */\n readonly before: number;\n /** Anchor message id; a page's is the first message of the window it extends. */\n readonly at?: string;\n /** Messages past the anchor (requires `at`). */\n readonly after?: number;\n /** The newest steps of every subagent lane a covered card names (see `lane-follow.ts`). */\n readonly follow?: { readonly before: number };\n}\n\nexport function headInterestRequest(size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size) };\n}\n\nexport function pageInterestRequest(at: string, size?: number): DeepAgentInterestRequest {\n return { ns: DEEP_AGENT_MAIN_NS, before: clampMessageWindowSize(size), at };\n}\n\n/**\n * Attach headers with the head window declared (`x-athena-deep-agent-window`):\n * the hello of a client the host does not remember carries the newest `size`\n * messages. Part of the one attach recipe, so a pooled dial asks for the shape\n * the thread's own attach would. An explicit entry (tests, overrides) wins.\n */\nexport function withDeclaredMessageWindow(\n headers: Record<string, string>,\n declaration: DeepAgentMessageWindowDeclaration = {}\n): Record<string, string> {\n if (DEEP_AGENT_MESSAGE_WINDOW_HEADER in headers) return headers;\n return {\n ...headers,\n [DEEP_AGENT_MESSAGE_WINDOW_HEADER]: String(clampMessageWindowSize(declaration.size)),\n };\n}\n\nexport interface DeepAgentInterestChainEntry {\n id: string;\n siblings: string[];\n}\n\n/** The host's resolution document of one interest: the request echoed plus its coverage. */\nexport interface DeepAgentInterestResolution extends DeepAgentInterestRequest {\n /** Covered message ids, oldest first (a page ends at its anchor). */\n chain: DeepAgentInterestChainEntry[];\n more: { before: boolean; after: boolean };\n}\n\nexport function readDeepAgentInterestResolution(value: unknown): DeepAgentInterestResolution | null {\n if (typeof value !== 'object' || value === null) return null;\n const { ns, before, at, after, chain, more } = value as Record<string, unknown>;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before) || !Array.isArray(chain)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n if (typeof more !== 'object' || more === null) return null;\n const { before: moreBefore, after: moreAfter } = more as Record<string, unknown>;\n if (typeof moreBefore !== 'boolean' || typeof moreAfter !== 'boolean') return null;\n const entries: DeepAgentInterestChainEntry[] = [];\n for (const entry of chain) {\n const { id, siblings } = (entry ?? {}) as Record<string, unknown>;\n if (typeof id !== 'string') return null;\n entries.push({\n id,\n siblings: Array.isArray(siblings) ? siblings.filter((s) => typeof s === 'string') : [id],\n });\n }\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n chain: entries,\n more: { before: moreBefore, after: moreAfter },\n };\n}\n\n/** The attach's interest document: one resolution per stated request, in order. */\nexport interface DeepAgentInterestDocument {\n windows: DeepAgentInterestResolution[];\n}\n\nexport function readDeepAgentInterestDocument(value: unknown): DeepAgentInterestDocument | null {\n if (typeof value !== 'object' || value === null) return null;\n const { windows } = value as Record<string, unknown>;\n if (!Array.isArray(windows)) return null;\n const resolutions: DeepAgentInterestResolution[] = [];\n for (const window of windows) {\n const resolution = readDeepAgentInterestResolution(window);\n if (resolution === null) return null;\n resolutions.push(resolution);\n }\n return { windows: resolutions };\n}\n\nconst interestRequest = ({ ns, before, at, after }: DeepAgentInterestRequest): DeepAgentInterestRequest => ({\n ns,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n});\n\n/** The loaded transcript window, joined from the head interest and its anchored pages. */\nexport interface DeepAgentMessageWindow {\n /** The requests the joined view stands on, in order (the head first): what a `set` restates. A stale page (its anchor gone) or one the head already covers is left out. */\n requests: DeepAgentInterestRequest[];\n /** Covered chain, oldest first. */\n chain: DeepAgentInterestChainEntry[];\n /** The chain's message documents, in chain order (an unmounted one is skipped). */\n messages: LangChainMessage[];\n /** Whether the host holds messages older than the window. */\n hasOlder: boolean;\n /** Pages joined onto the head. */\n pages: number;\n /** The conversation the window's message documents belong to (their key's thread); absent before one is mounted. */\n threadId?: string;\n}\n\n/**\n * The loaded chain plus `grow` older messages, restated in as few requests as\n * it takes: a maximal head, then maximal pages each anchored at the first\n * message of the window above it. `null` once even that exceeds the host's\n * interest cap — the reachable depth is `MAX_INTERESTS × MAX_MESSAGE_WINDOW`.\n */\nfunction coalescedInterestRequests(\n chain: readonly DeepAgentInterestChainEntry[],\n grow: number\n): DeepAgentInterestRequest[] | null {\n const loaded = chain.length;\n const requests: DeepAgentInterestRequest[] = [\n { ns: DEEP_AGENT_MAIN_NS, before: Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, loaded) },\n ];\n // `low` is the chain index of the lowest message the plan covers so far.\n let low = loaded - (requests[0] as DeepAgentInterestRequest).before;\n while (low > 0) {\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, low + 1);\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before,\n at: (chain[low] as DeepAgentInterestChainEntry).id,\n });\n low = low + 1 - before;\n }\n // The plan covers the chain; the new messages extend its lowest request\n // when that stays within one window, else they are a page of their own.\n const last = requests[requests.length - 1] as DeepAgentInterestRequest;\n if (last.before + grow <= DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n requests[requests.length - 1] = { ...last, before: last.before + grow };\n } else {\n requests.push({\n ns: DEEP_AGENT_MAIN_NS,\n before: grow + 1,\n at: (chain[0] as DeepAgentInterestChainEntry).id,\n });\n }\n return requests.length > DEEP_AGENT_MAX_INTERESTS ? null : requests;\n}\n\n/**\n * The requests to state for one more page of older history, or `null` when\n * there is nothing to load (no anchor, the beginning reached) or the host's\n * interest cap is spent. One page is appended, anchored at the window's first\n * message, while the cap allows; at the cap the loaded range is coalesced\n * into maximal requests first (see {@link coalescedInterestRequests}).\n */\nexport function pageInterestRequests(\n window: DeepAgentMessageWindow,\n size?: number\n): DeepAgentInterestRequest[] | null {\n const anchor = window.chain[0]?.id;\n if (anchor === undefined || !window.hasOlder) return null;\n const page = pageInterestRequest(anchor, size);\n const appended = [...window.requests, page];\n if (appended.length <= DEEP_AGENT_MAX_INTERESTS) return appended;\n // A page's `before` counts its anchor: it adds `before - 1` older messages.\n return coalescedInterestRequests(window.chain, page.before - 1);\n}\n\n/**\n * The window off the mounted documents, or `null` while the head interest has\n * not resolved (pre-attach, before the first `set` answer, a wire without\n * documents). A page joins wherever its anchor sits in the chain so far — at\n * the first message it extends the view, inside the head (the head widened\n * past it) it adds nothing and is left out of `requests`; a page whose anchor\n * left the transcript (a rewind emptied it in place) is left out too. A\n * malformed document reads as absent.\n */\nexport function readDeepAgentMessageWindow(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentMessageWindow | null {\n if (mounted === undefined) return null;\n let windows: DeepAgentInterestResolution[] | undefined;\n let threadId: string | undefined;\n const documents = new Map<string, LangChainMessage>();\n for (const document of mounted.values()) {\n const key = document.key;\n if (document.protocol === DEEP_AGENT_INTEREST_PROTOCOL && document.main === true) {\n windows = readDeepAgentInterestDocument(document.value)?.windows;\n } else if (\n document.protocol === DEEP_AGENT_STATEWIRE_PROTOCOL &&\n key !== null &&\n key[1] === DEEP_AGENT_MAIN_NS &&\n (key.length === 3 || (key.length === 4 && key[3] === DEEP_AGENT_CUT_LANE_DOCUMENT))\n ) {\n documents.set(key[2] as string, document.value as LangChainMessage);\n if (threadId === undefined && typeof key[0] === 'string') threadId = key[0];\n }\n }\n const head = windows?.[0];\n if (windows === undefined || head === undefined) return null;\n let chain = head.chain;\n let hasOlder = head.more.before;\n const requests = [interestRequest(head)];\n const loaded = new Set(chain.map((entry) => entry.id));\n let pages = 0;\n for (const page of windows.slice(1)) {\n if (page.at === undefined || !loaded.has(page.at)) continue;\n const anchorAt = page.chain.findIndex((entry) => entry.id === page.at);\n if (anchorAt < 0) continue;\n // Both windows are ranges of one linear transcript sharing the anchor:\n // what the page holds below it and the chain does not is a prefix.\n const fresh = page.chain.slice(0, anchorAt).filter((entry) => !loaded.has(entry.id));\n if (fresh.length === 0) {\n // Nothing new, but a page that starts where the loaded chain starts\n // has looked below it: its `more.before` is the answer for the edge.\n if (page.chain[0]?.id === chain[0]?.id) hasOlder = page.more.before;\n continue;\n }\n chain = [...fresh, ...chain];\n for (const entry of fresh) loaded.add(entry.id);\n hasOlder = page.more.before;\n requests.push(interestRequest(page));\n pages += 1;\n }\n const messages: LangChainMessage[] = [];\n for (const entry of chain) {\n const message = documents.get(entry.id);\n if (message !== undefined) messages.push(message);\n }\n return { requests, chain, messages, hasOlder, pages, ...(threadId !== undefined && { threadId }) };\n}\n\n/**\n * The view a client holds, as it declares it on a re-attach\n * (`x-athena-deep-agent-interests`): what the host would have remembered for\n * its client id, read off the attach's own interest document.\n */\nexport interface DeepAgentInterestDeclaration {\n /** Every request the interest document echoes that still covers something, the head first. */\n readonly requests: readonly DeepAgentInterestRequest[];\n /** The oldest message the head covers: the host holds the head down to it as the transcript grows. */\n readonly floor?: string;\n /** Per followed subagent lane, the oldest step a follow window covers. */\n readonly follows?: Readonly<Record<string, string>>;\n}\n\nconst echoedRequest = (window: Record<string, unknown>): DeepAgentInterestRequest | null => {\n const { ns, before, at, after, follow } = window;\n if (ns !== DEEP_AGENT_MAIN_NS || !isIndex(before)) return null;\n if (at !== undefined && typeof at !== 'string') return null;\n if (after !== undefined && !isIndex(after)) return null;\n const followBefore =\n typeof follow === 'object' && follow !== null ? (follow as Record<string, unknown>).before : undefined;\n if (follow !== undefined && !isIndex(followBefore)) return null;\n return {\n ns: DEEP_AGENT_MAIN_NS,\n before,\n ...(at !== undefined && { at }),\n ...(after !== undefined && { after }),\n ...(isIndex(followBefore) && { follow: { before: followBefore } }),\n };\n};\n\nconst firstChainId = (chain: unknown): string | undefined => {\n if (!Array.isArray(chain)) return undefined;\n const id = (chain[0] as { id?: unknown } | undefined)?.id;\n return typeof id === 'string' && id ? id : undefined;\n};\n\n/**\n * The view to declare on a re-attach, read off the mounted interest document,\n * or `null` before one resolved. Requests are taken as the host echoed them\n * (lane `follow`s included); a page whose anchor left the transcript covers\n * nothing and is left out, the head never. The floors are what the host\n * commits from the same document (the head's first message, each lane's\n * deepest follow window's first step).\n */\nexport function readDeepAgentInterestDeclaration(\n mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined\n): DeepAgentInterestDeclaration | null {\n if (mounted === undefined) return null;\n let windows: unknown[] | undefined;\n for (const document of mounted.values()) {\n if (document.protocol !== DEEP_AGENT_INTEREST_PROTOCOL || document.main !== true) continue;\n const value = document.value as { windows?: unknown } | null;\n if (value !== null && typeof value === 'object' && Array.isArray(value.windows)) {\n windows = value.windows;\n }\n }\n if (windows === undefined || windows.length === 0) return null;\n const requests: DeepAgentInterestRequest[] = [];\n const deepest = new Map<string, unknown[]>();\n for (const [index, window] of windows.entries()) {\n if (typeof window !== 'object' || window === null) return null;\n const record = window as Record<string, unknown>;\n const request = echoedRequest(record);\n if (request === null) return null;\n if (index === 0 && request.at !== undefined) return null;\n if (index === 0 || firstChainId(record.chain) !== undefined) requests.push(request);\n const follows = record.follows;\n if (typeof follows !== 'object' || follows === null) continue;\n for (const [ns, follow] of Object.entries(follows)) {\n const chain = (follow as { chain?: unknown } | null)?.chain;\n if (!Array.isArray(chain) || chain.length <= (deepest.get(ns)?.length ?? 0)) continue;\n deepest.set(ns, chain);\n }\n }\n const floor = firstChainId((windows[0] as Record<string, unknown>).chain);\n const follows: Record<string, string> = {};\n for (const [ns, chain] of deepest) {\n const step = firstChainId(chain);\n if (step !== undefined) follows[ns] = step;\n }\n return {\n requests,\n ...(floor !== undefined && { floor }),\n ...(Object.keys(follows).length > 0 && { follows }),\n };\n}\n\n/**\n * `declaration` as the header value: JSON with every non-ASCII character\n * escaped (a header value is Latin-1 on the wire), or `null` when it is\n * larger than the host reads — the attach then falls back to the host's memo\n * or the declared head, as before.\n */\nexport function encodeDeepAgentInterestDeclaration(\n declaration: DeepAgentInterestDeclaration\n): string | null {\n // Everything outside printable ASCII as a JSON escape (a surrogate pair as two).\n const encoded = JSON.stringify(declaration).replace(\n /[^ -~]/g,\n (char) => `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`\n );\n return encoded.length > DEEP_AGENT_MAX_MESSAGE_INTERESTS_HEADER_BYTES ? null : encoded;\n}\n\n/**\n * Attach headers with the view a re-attach holds declared\n * (`x-athena-deep-agent-interests`), so its hello carries that view on any\n * host instance. A first attach declares nothing (`null`); an explicit entry\n * wins.\n */\nexport function withDeclaredInterests(\n headers: Record<string, string>,\n declaration: DeepAgentInterestDeclaration | null\n): Record<string, string> {\n if (declaration === null || DEEP_AGENT_MESSAGE_INTERESTS_HEADER in headers) return headers;\n const encoded = encodeDeepAgentInterestDeclaration(declaration);\n return encoded === null ? headers : { ...headers, [DEEP_AGENT_MESSAGE_INTERESTS_HEADER]: encoded };\n}\n\n/**\n * Whether `hello` (a re-attach's window) carries what `held` covered: it\n * reaches `held`'s oldest message, or there is nothing older to reach.\n */\nexport function messageWindowCarries({\n hello,\n held,\n}: {\n hello: DeepAgentMessageWindow;\n held: DeepAgentMessageWindow;\n}): boolean {\n const oldest = held.chain[0]?.id;\n if (oldest === undefined || !hello.hasOlder) return true;\n return hello.chain.some((entry) => entry.id === oldest);\n}\n\n/**\n * The statement that loads `held` again after a hello that did not carry it\n * (a host that neither read the declared view nor remembers the client).\n *\n * The requests it stood on, the head widened to reach the first page's anchor:\n * a head holding its floor covers more than it asked for once a run appended\n * past it, and `hello` (the re-attach's own window) shows what was appended\n * while the view was away, which the head must span too. Without pages, the\n * head is widened to everything it covered. Where that is more than one\n * request can state, the whole chain is restated in maximal windows, each\n * anchored inside the one above it (`coalescedInterestRequests`), so no page\n * is left without its anchor. A hello that does not reach the held view at\n * all (more was appended than it shows) gets the widest head one request can\n * state: the best an older host allows.\n */\nexport function restatedInterestRequests({\n held,\n hello = null,\n}: {\n held: DeepAgentMessageWindow;\n /** The re-attach's own window; omitted, nothing is known to have been appended. */\n hello?: DeepAgentMessageWindow | null;\n}): DeepAgentInterestRequest[] {\n const [head, ...pages] = held.requests;\n if (head === undefined) return [];\n const newest = held.chain.at(-1)?.id;\n const since =\n hello === null || newest === undefined\n ? -1\n : hello.chain.findIndex((entry) => entry.id === newest);\n const chain = since === -1 || hello === null ? held.chain : [...held.chain, ...hello.chain.slice(since + 1)];\n const anchor = pages[0]?.at;\n const start = anchor === undefined ? 0 : chain.findIndex((entry) => entry.id === anchor);\n const covered =\n hello !== null && since === -1\n ? DEEP_AGENT_MAX_MESSAGE_WINDOW\n : chain.length - Math.max(0, start);\n if (covered > DEEP_AGENT_MAX_MESSAGE_WINDOW) {\n const coalesced = coalescedInterestRequests(chain, 0);\n if (coalesced !== null) return coalesced;\n }\n const before = Math.min(DEEP_AGENT_MAX_MESSAGE_WINDOW, Math.max(head.before, covered));\n return [{ ...head, before }, ...pages];\n}\n\n/**\n * The windowed wire's read command on the statewire command union, so\n * `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the\n * deep-agent host is driven (`DeepAgentThread.history_tool_output`, an\n * attach-ACL read).\n */\ndeclare module '@assistant-ui/core' {\n namespace Assistant {\n interface Commands {\n /** A tool output the windowed wire carried cut, whole. */\n historyToolOutput: ToolOutputCommand;\n /** One stored message whole — the per-client shape, by command. */\n historyMessage: HistoryMessageCommand;\n }\n }\n}\n\n/** The `history/tool_output` command: a truncated tool output, whole. */\nexport interface ToolOutputCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildToolOutputCommand({ messageId }: { messageId: string }): ToolOutputCommand {\n return { type: DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND, messageId };\n}\n\nexport interface ToolOutputResult {\n messageId: string;\n content: unknown;\n}\n\nexport function readToolOutputResult(payload: unknown): ToolOutputResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, content } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n return { messageId, content };\n}\n\n/**\n * The `history/message` command: a message as the host stores it — the\n * model-provenance blobs the wire strips and an untruncated tool output\n * included. Every client receives one projected wire form; this is the one\n * per-client shape, fetched on demand like `history/tool_output`.\n */\nexport interface HistoryMessageCommand {\n readonly type: typeof DEEP_AGENT_HISTORY_MESSAGE_COMMAND;\n readonly messageId: string;\n}\n\nexport function buildHistoryMessageCommand({\n messageId,\n}: {\n messageId: string;\n}): HistoryMessageCommand {\n return { type: DEEP_AGENT_HISTORY_MESSAGE_COMMAND, messageId };\n}\n\nexport interface HistoryMessageResult {\n messageId: string;\n message: LangChainMessage;\n}\n\nexport function readHistoryMessageResult(payload: unknown): HistoryMessageResult | null {\n if (typeof payload !== 'object' || payload === null) return null;\n const { messageId, message } = payload as Record<string, unknown>;\n if (typeof messageId !== 'string' || !messageId) return null;\n if (typeof message !== 'object' || message === null) return null;\n return { messageId, message: message as LangChainMessage };\n}\n\n/** The wire marker on a tool message whose content the host cut. */\nexport interface TruncatedToolContent {\n /** Length of the full output, in characters. */\n chars: number;\n}\n\n/**\n * The truncation marker off a raw wire message, or `null` when the message's\n * content is whole. Pure and selector-safe on the marker object.\n */\nexport function readTruncatedToolContent(message: unknown): TruncatedToolContent | null {\n if (typeof message !== 'object' || message === null) return null;\n const marker = (message as Record<string, unknown>)[DEEP_AGENT_TRUNCATED_CONTENT_KEY];\n if (typeof marker !== 'object' || marker === null) return null;\n const chars = (marker as Record<string, unknown>).chars;\n return isIndex(chars) ? { chars } : null;\n}\n\n/**\n * `artifact` key the shared converter lifts a truncated tool output's marker\n * into (with the tool message id), so a tool card can ask for the full output\n * — the converter joins the ToolMessage into its tool-call part and would\n * otherwise drop the wire marker.\n */\nexport const ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY = '_athena_content_truncated';\n\nexport interface TruncatedToolOutputArtifact extends TruncatedToolContent {\n /** The tool message to name in `history/tool_output`. */\n messageId: string;\n}\n\n/**\n * The lifted truncation marker off a tool-call part's `artifact`, or `null`.\n */\nexport function readTruncatedToolOutputArtifact(\n artifact: unknown\n): TruncatedToolOutputArtifact | null {\n if (typeof artifact !== 'object' || artifact === null) return null;\n const lifted = (artifact as Record<string, unknown>)[ATHENA_TRUNCATED_TOOL_OUTPUT_ARTIFACT_KEY];\n if (typeof lifted !== 'object' || lifted === null) return null;\n const { chars, messageId } = lifted as Record<string, unknown>;\n if (!isIndex(chars) || typeof messageId !== 'string' || !messageId) return null;\n return { chars, messageId };\n}\n"],"names":["DEEP_AGENT_DEFAULT_MESSAGE_WINDOW","DEEP_AGENT_MIN_MESSAGE_WINDOW","DEEP_AGENT_MAX_MESSAGE_WINDOW","DEEP_AGENT_MAIN_NS","DEEP_AGENT_MESSAGE_WINDOW_HEADER","DEEP_AGENT_MAX_INTERESTS","DEEP_AGENT_INTEREST_PROTOCOL","DEEP_AGENT_STATEWIRE_PROTOCOL","DEEP_AGENT_CUT_LANE_DOCUMENT","follows","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AAO,QAAQ,KAAK,IAAI,EAAE,UAAU;AACtC;AAQO,MAAM,4CAA4C;AAUlD,SAAS,gCACd,UACoC;AACpC,MAAI,OAAO,aAAa,YAAY,aAAa,KAAM,QAAO;AAC9D,QAAM,SAAU,SAAqC,yCAAyC;AAC9F,MAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,QAAM,EAAE,OAAO,UAAA,IAAc;AAC7B,MAAI,CAAC,QAAQ,KAAK,KAAK,OAAO,cAAc,YAAY,CAAC,UAAW,QAAO;AAC3E,SAAO,EAAE,OAAO,UAAA;AAClB;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -60,6 +60,8 @@ export interface DeepAgentMessageWindow {
|
|
|
60
60
|
hasOlder: boolean;
|
|
61
61
|
/** Pages joined onto the head. */
|
|
62
62
|
pages: number;
|
|
63
|
+
/** The conversation the window's message documents belong to (their key's thread); absent before one is mounted. */
|
|
64
|
+
threadId?: string;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* The requests to state for one more page of older history, or `null` when
|
|
@@ -69,12 +71,6 @@ export interface DeepAgentMessageWindow {
|
|
|
69
71
|
* into maximal requests first (see {@link coalescedInterestRequests}).
|
|
70
72
|
*/
|
|
71
73
|
export declare function pageInterestRequests(window: DeepAgentMessageWindow, size?: number): DeepAgentInterestRequest[] | null;
|
|
72
|
-
/**
|
|
73
|
-
* Whether every `stated` request is carried by `carried` (the same anchor, at
|
|
74
|
-
* least as wide): a reconnect's hello that carries what the client last
|
|
75
|
-
* stated — the host remembers a client id's interests — needs no restatement.
|
|
76
|
-
*/
|
|
77
|
-
export declare function interestsCovered(carried: readonly DeepAgentInterestRequest[], stated: readonly DeepAgentInterestRequest[]): boolean;
|
|
78
74
|
/**
|
|
79
75
|
* The window off the mounted documents, or `null` while the head interest has
|
|
80
76
|
* not resolved (pre-attach, before the first `set` answer, a wire without
|
|
@@ -85,6 +81,70 @@ export declare function interestsCovered(carried: readonly DeepAgentInterestRequ
|
|
|
85
81
|
* malformed document reads as absent.
|
|
86
82
|
*/
|
|
87
83
|
export declare function readDeepAgentMessageWindow(mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined): DeepAgentMessageWindow | null;
|
|
84
|
+
/**
|
|
85
|
+
* The view a client holds, as it declares it on a re-attach
|
|
86
|
+
* (`x-athena-deep-agent-interests`): what the host would have remembered for
|
|
87
|
+
* its client id, read off the attach's own interest document.
|
|
88
|
+
*/
|
|
89
|
+
export interface DeepAgentInterestDeclaration {
|
|
90
|
+
/** Every request the interest document echoes that still covers something, the head first. */
|
|
91
|
+
readonly requests: readonly DeepAgentInterestRequest[];
|
|
92
|
+
/** The oldest message the head covers: the host holds the head down to it as the transcript grows. */
|
|
93
|
+
readonly floor?: string;
|
|
94
|
+
/** Per followed subagent lane, the oldest step a follow window covers. */
|
|
95
|
+
readonly follows?: Readonly<Record<string, string>>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The view to declare on a re-attach, read off the mounted interest document,
|
|
99
|
+
* or `null` before one resolved. Requests are taken as the host echoed them
|
|
100
|
+
* (lane `follow`s included); a page whose anchor left the transcript covers
|
|
101
|
+
* nothing and is left out, the head never. The floors are what the host
|
|
102
|
+
* commits from the same document (the head's first message, each lane's
|
|
103
|
+
* deepest follow window's first step).
|
|
104
|
+
*/
|
|
105
|
+
export declare function readDeepAgentInterestDeclaration(mounted: ReadonlyMap<number, StatewireDocuments.Document> | undefined): DeepAgentInterestDeclaration | null;
|
|
106
|
+
/**
|
|
107
|
+
* `declaration` as the header value: JSON with every non-ASCII character
|
|
108
|
+
* escaped (a header value is Latin-1 on the wire), or `null` when it is
|
|
109
|
+
* larger than the host reads — the attach then falls back to the host's memo
|
|
110
|
+
* or the declared head, as before.
|
|
111
|
+
*/
|
|
112
|
+
export declare function encodeDeepAgentInterestDeclaration(declaration: DeepAgentInterestDeclaration): string | null;
|
|
113
|
+
/**
|
|
114
|
+
* Attach headers with the view a re-attach holds declared
|
|
115
|
+
* (`x-athena-deep-agent-interests`), so its hello carries that view on any
|
|
116
|
+
* host instance. A first attach declares nothing (`null`); an explicit entry
|
|
117
|
+
* wins.
|
|
118
|
+
*/
|
|
119
|
+
export declare function withDeclaredInterests(headers: Record<string, string>, declaration: DeepAgentInterestDeclaration | null): Record<string, string>;
|
|
120
|
+
/**
|
|
121
|
+
* Whether `hello` (a re-attach's window) carries what `held` covered: it
|
|
122
|
+
* reaches `held`'s oldest message, or there is nothing older to reach.
|
|
123
|
+
*/
|
|
124
|
+
export declare function messageWindowCarries({ hello, held, }: {
|
|
125
|
+
hello: DeepAgentMessageWindow;
|
|
126
|
+
held: DeepAgentMessageWindow;
|
|
127
|
+
}): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* The statement that loads `held` again after a hello that did not carry it
|
|
130
|
+
* (a host that neither read the declared view nor remembers the client).
|
|
131
|
+
*
|
|
132
|
+
* The requests it stood on, the head widened to reach the first page's anchor:
|
|
133
|
+
* a head holding its floor covers more than it asked for once a run appended
|
|
134
|
+
* past it, and `hello` (the re-attach's own window) shows what was appended
|
|
135
|
+
* while the view was away, which the head must span too. Without pages, the
|
|
136
|
+
* head is widened to everything it covered. Where that is more than one
|
|
137
|
+
* request can state, the whole chain is restated in maximal windows, each
|
|
138
|
+
* anchored inside the one above it (`coalescedInterestRequests`), so no page
|
|
139
|
+
* is left without its anchor. A hello that does not reach the held view at
|
|
140
|
+
* all (more was appended than it shows) gets the widest head one request can
|
|
141
|
+
* state: the best an older host allows.
|
|
142
|
+
*/
|
|
143
|
+
export declare function restatedInterestRequests({ held, hello, }: {
|
|
144
|
+
held: DeepAgentMessageWindow;
|
|
145
|
+
/** The re-attach's own window; omitted, nothing is known to have been appended. */
|
|
146
|
+
hello?: DeepAgentMessageWindow | null;
|
|
147
|
+
}): DeepAgentInterestRequest[];
|
|
88
148
|
/**
|
|
89
149
|
* The windowed wire's read command on the statewire command union, so
|
|
90
150
|
* `sendCommand({ type: 'history/tool_output', … })` typechecks wherever the
|