@mgamadeus/ddd-agents 0.16.1 → 0.17.1
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 +113 -10
- package/boundary.json +15 -1
- package/dist/admin-chat-widgets.js +158 -0
- package/dist/admin-chat-widgets.js.map +1 -0
- package/dist/admin.js +92 -65
- package/dist/admin.js.map +1 -1
- package/dist/chat.js +19 -19
- package/dist/chat.js.map +1 -1
- package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js +304 -0
- package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js.map +1 -0
- package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js → ConversationMarkdown-dj0EF6bu.js} +5 -5
- package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js.map → ConversationMarkdown-dj0EF6bu.js.map} +1 -1
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js → ConversationMessageInputComposerWidgets-ClgCwnVW.js} +6 -6
- package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js.map → ConversationMessageInputComposerWidgets-ClgCwnVW.js.map} +1 -1
- package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js → VoiceBarsIcon-B6VTVtdB.js} +4 -4
- package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js.map → VoiceBarsIcon-B6VTVtdB.js.map} +1 -1
- package/dist/chunks/{WebSearchResultsConversationWidget-l9Aek_lG.js → WebSearchResultsConversationWidget-BVMwJfhL.js} +73 -64
- package/dist/chunks/WebSearchResultsConversationWidget-BVMwJfhL.js.map +1 -0
- package/dist/chunks/{agents-http-trace-mappers-rsbGAf2_.js → agents-http-trace-mappers-CuGZOFu-.js} +53 -14
- package/dist/chunks/agents-http-trace-mappers-CuGZOFu-.js.map +1 -0
- package/dist/chunks/{browser-request-interception-D678IemW.js → browser-request-interception-BnOQWLaJ.js} +2 -2
- package/dist/chunks/{browser-request-interception-D678IemW.js.map → browser-request-interception-BnOQWLaJ.js.map} +1 -1
- package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js → canvas-label-context-5yvbmK-V.js} +3 -3
- package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js.map → canvas-label-context-5yvbmK-V.js.map} +1 -1
- package/dist/chunks/{canvas-reducers-BYArW_Ji.js → canvas-reducers-133Kl1QH.js} +2 -2
- package/dist/chunks/{canvas-reducers-BYArW_Ji.js.map → canvas-reducers-133Kl1QH.js.map} +1 -1
- package/dist/chunks/{canvasBodies-BpLPp-S8.js → canvasBodies-B2M6aWao.js} +4 -4
- package/dist/chunks/{canvasBodies-BpLPp-S8.js.map → canvasBodies-B2M6aWao.js.map} +1 -1
- package/dist/chunks/{canvasStorage-DSspwRMg.js → canvasStorage-B69JHOLd.js} +2 -2
- package/dist/chunks/{canvasStorage-DSspwRMg.js.map → canvasStorage-B69JHOLd.js.map} +1 -1
- package/dist/chunks/{content-from-unified-diff-DWyBHRSy.js → content-from-unified-diff-BKdgop63.js} +39 -5
- package/dist/chunks/content-from-unified-diff-BKdgop63.js.map +1 -0
- package/dist/chunks/{contract-DtFmOk91.js → contract-CQ6PO_e8.js} +2 -2
- package/dist/chunks/{contract-DtFmOk91.js.map → contract-CQ6PO_e8.js.map} +1 -1
- package/dist/chunks/{conversation-Cbrqtx-_.js → conversation-VosmRbsr.js} +4 -2
- package/dist/chunks/{conversation-Cbrqtx-_.js.map → conversation-VosmRbsr.js.map} +1 -1
- package/dist/chunks/conversation-trace-fVeh6Lg6.js.map +1 -1
- package/dist/chunks/{widget-name-resolver-DXIE9JUr.js → conversationWidgetRegistry-webrYtkI.js} +810 -530
- package/dist/chunks/conversationWidgetRegistry-webrYtkI.js.map +1 -0
- package/dist/chunks/{index-DZovGMpG.js → index-DAEGct6X.js} +61 -61
- package/dist/chunks/index-DAEGct6X.js.map +1 -0
- package/dist/chunks/{link-navigation-a_sRfmsj.js → link-navigation-DQWyeNkx.js} +2 -2
- package/dist/chunks/{link-navigation-a_sRfmsj.js.map → link-navigation-DQWyeNkx.js.map} +1 -1
- package/dist/chunks/{withPollingChangeSubscription-Cz3Diolr.js → withPollingChangeSubscription-Ct8kjmlL.js} +19 -2
- package/dist/chunks/withPollingChangeSubscription-Ct8kjmlL.js.map +1 -0
- package/dist/client-testing.js +39 -5
- package/dist/client-testing.js.map +1 -1
- package/dist/client.js +43 -14
- package/dist/client.js.map +1 -1
- package/dist/contract.js +4 -3
- package/dist/files/i18n-keys.json +619 -15
- package/dist/files/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.md +4 -2
- package/dist/files/widgets/OwnerStepConfirmationConversationWidget/OwnerStepConfirmationConversationWidget.md +54 -0
- package/dist/files/widgets/OwnerStepConfirmationConversationWidget/owner-step-confirmation.preview-fixtures.json +16 -0
- package/dist/image-render.js +8 -8
- package/dist/index.js +16 -16
- package/dist/kit.js +2 -2
- package/dist/preview.js +124 -117
- package/dist/preview.js.map +1 -1
- package/dist/provider.js +2 -2
- package/dist/renderer.js +53 -52
- package/dist/styles.css +46 -0
- package/dist/types/admin/connections/connection-parts.d.ts +2 -1
- package/dist/types/admin/schedules/AgentScheduleOrderDraftPanel.d.ts +45 -0
- package/dist/types/admin/schedules/AgentSchedulesPanel.d.ts +11 -3
- package/dist/types/admin/schedules/agent-schedules-api.d.ts +38 -2
- package/dist/types/admin/schedules/agent-schedules-format.d.ts +22 -1
- package/dist/types/admin/schedules/agent-schedules-types.d.ts +91 -1
- package/dist/types/admin-chat-widgets/ScheduleOrderApprovalConversationWidget.d.ts +37 -0
- package/dist/types/admin-chat-widgets/registerScheduleOrderApprovalWidget.d.ts +11 -0
- package/dist/types/chat/trace/TurnMetaLine.d.ts +5 -3
- package/dist/types/chat/trace/trace-counts.d.ts +2 -0
- package/dist/types/chat/trace/trace-types.d.ts +4 -0
- package/dist/types/client/AgentsConversationClient.d.ts +17 -1
- package/dist/types/client/http/agents-http-mappers.d.ts +4 -2
- package/dist/types/client/http/agents-http-trace-wire.d.ts +2 -0
- package/dist/types/client/http/agents-http-wire.d.ts +24 -0
- package/dist/types/client/testing/createInMemoryAgentsConversationClient.d.ts +13 -1
- package/dist/types/contract/conversation-trace.d.ts +4 -0
- package/dist/types/contract/conversation.d.ts +43 -0
- package/dist/types/entries/admin-chat-widgets.d.ts +2 -0
- package/dist/types/entries/admin.d.ts +4 -2
- package/dist/types/entries/renderer.d.ts +1 -1
- package/dist/types/renderer/widget-tree/composed-node-schema.d.ts +20 -3
- package/dist/types/widgets/DriveFilesConversationWidget/shared/drive-files.d.ts +3 -1
- package/dist/voice.js +2 -2
- package/dist/widgets.js +4 -4
- package/package.json +7 -1
- package/public-api.json +39 -0
- package/dist/chunks/WebSearchResultsConversationWidget-l9Aek_lG.js.map +0 -1
- package/dist/chunks/agents-http-trace-mappers-rsbGAf2_.js.map +0 -1
- package/dist/chunks/content-from-unified-diff-DWyBHRSy.js.map +0 -1
- package/dist/chunks/index-DZovGMpG.js.map +0 -1
- package/dist/chunks/widget-name-resolver-DXIE9JUr.js.map +0 -1
- package/dist/chunks/withPollingChangeSubscription-Cz3Diolr.js.map +0 -1
package/dist/client-testing.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { A as AgentsClientError,
|
|
2
|
+
import { A as AgentsClientError, e as CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION, r as readConversationRunStatusOfRunState } from "./chunks/conversation-VosmRbsr.js";
|
|
3
3
|
import { c as composeAttachmentMessageText } from "./chunks/compose-attachment-message-text-FvVJbrge.js";
|
|
4
|
-
import { l as listWidgetHydratorTypes,
|
|
5
|
-
import { j as conversationWidgetRegistry, k as replaceConversationWidgetRegistryEntries } from "./chunks/
|
|
6
|
-
import { l, s } from "./chunks/
|
|
7
|
-
import { c, r, s as s2 } from "./chunks/canvasStorage-
|
|
4
|
+
import { l as listWidgetHydratorTypes, m as getWidgetHydrator, j as registerWidgetHydrator, n as abandonWidgetHydrationReads, o as unregisterWidgetHydrator } from "./chunks/WebSearchResultsConversationWidget-BVMwJfhL.js";
|
|
5
|
+
import { j as conversationWidgetRegistry, k as replaceConversationWidgetRegistryEntries } from "./chunks/conversationWidgetRegistry-webrYtkI.js";
|
|
6
|
+
import { l, s } from "./chunks/conversationWidgetRegistry-webrYtkI.js";
|
|
7
|
+
import { c, r, s as s2 } from "./chunks/canvasStorage-B69JHOLd.js";
|
|
8
8
|
const DEFAULT_SCRIPTED_ASSISTANT_ANSWER = "Done.";
|
|
9
9
|
const DEFAULT_PAGE_SIZE = 50;
|
|
10
10
|
const copyOf = (value) => JSON.parse(JSON.stringify(value));
|
|
@@ -96,6 +96,32 @@ class InMemoryAgentsConversationClient {
|
|
|
96
96
|
};
|
|
97
97
|
return { isStopped: true, state: "CANCELLED" };
|
|
98
98
|
};
|
|
99
|
+
this.getStepConfirmation = async (conversationId, stepConfirmationId) => {
|
|
100
|
+
this.countRequest("getStepConfirmation");
|
|
101
|
+
return copyOf(this.readStepConfirmation(conversationId, stepConfirmationId));
|
|
102
|
+
};
|
|
103
|
+
this.executeStepConfirmation = async (conversationId, stepConfirmationId, contentHash) => {
|
|
104
|
+
this.countRequest("executeStepConfirmation");
|
|
105
|
+
const stepConfirmation = this.readStepConfirmation(conversationId, stepConfirmationId);
|
|
106
|
+
if (stepConfirmation.contentHash !== contentHash) {
|
|
107
|
+
throw new AgentsClientError("other", { httpStatus: 400, message: "This step changed meanwhile; only the step shown in the chat can run." });
|
|
108
|
+
}
|
|
109
|
+
if (stepConfirmation.status !== "OPEN") {
|
|
110
|
+
throw new AgentsClientError("forbidden", { httpStatus: 403, message: `This step is no longer open (${stepConfirmation.status ?? "unknown"}).` });
|
|
111
|
+
}
|
|
112
|
+
stepConfirmation.status = "EXECUTED";
|
|
113
|
+
stepConfirmation.resultExcerpt = "Done.";
|
|
114
|
+
return copyOf(stepConfirmation);
|
|
115
|
+
};
|
|
116
|
+
this.discardStepConfirmation = async (conversationId, stepConfirmationId) => {
|
|
117
|
+
this.countRequest("discardStepConfirmation");
|
|
118
|
+
const stepConfirmation = this.readStepConfirmation(conversationId, stepConfirmationId);
|
|
119
|
+
if (stepConfirmation.status !== "OPEN") {
|
|
120
|
+
throw new AgentsClientError("forbidden", { httpStatus: 403, message: "This step was answered meanwhile." });
|
|
121
|
+
}
|
|
122
|
+
stepConfirmation.status = "DISCARDED";
|
|
123
|
+
return copyOf(stepConfirmation);
|
|
124
|
+
};
|
|
99
125
|
this.startConversation = async (request) => {
|
|
100
126
|
this.countRequest("startConversation");
|
|
101
127
|
if (request.text === "" && !request.startSignalText) {
|
|
@@ -277,6 +303,14 @@ class InMemoryAgentsConversationClient {
|
|
|
277
303
|
this.nextMessageId = Math.max(0, ...allMessageIds) + 1;
|
|
278
304
|
this.nextConversationId = Math.max(0, ...allConversationIds) + 1;
|
|
279
305
|
}
|
|
306
|
+
/** A recorded step of the conversation, or `notFound` like the server. */
|
|
307
|
+
readStepConfirmation(conversationId, stepConfirmationId) {
|
|
308
|
+
const stepConfirmation = (this.readRecord(conversationId).stepConfirmations ?? []).find((recordedStep) => recordedStep.id === stepConfirmationId);
|
|
309
|
+
if (!stepConfirmation) {
|
|
310
|
+
throw new AgentsClientError("notFound", { httpStatus: 404, message: `No step ${stepConfirmationId} in conversation ${conversationId}.` });
|
|
311
|
+
}
|
|
312
|
+
return stepConfirmation;
|
|
313
|
+
}
|
|
280
314
|
// ── Internals ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
281
315
|
countRequest(operation) {
|
|
282
316
|
this.requestCountsByOperation.set(operation, (this.requestCountsByOperation.get(operation) ?? 0) + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-testing.js","sources":["../src/client/testing/createInMemoryAgentsConversationClient.ts","../src/client/testing/widget-hydration-stand-ins.ts","../src/client/testing/test-conversation-widgets.ts"],"sourcesContent":["import type { AgentsConversationClient, AgentsConversationOperation } from \"../AgentsConversationClient\";\nimport {\n AgentsClientError,\n type AgentsConversation,\n type AgentsConversationMessage,\n type ChangedConversationMessages,\n type ChangedMessagesRequest,\n type ConversationActivity,\n type ConversationAttachmentReference,\n type ConversationBackgroundJobStop,\n type ConversationChangeSignal,\n type ConversationListQueryOptions,\n type ConversationMessageSearchHit,\n type ConversationMessageSentPayload,\n type ConversationMessagesPage,\n type ConversationRunStatus,\n CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION,\n type ConversationSearchGroup,\n type ConversationSearchOptions,\n type ConversationSignal,\n type ConversationSubscriptionEndReason,\n type PostedMessage,\n readConversationRunStatusOfRunState,\n type SelectableModel,\n type StartedConversation,\n} from \"../../contract/conversation\";\nimport { composeAttachmentMessageText } from \"../compose-attachment-message-text\";\n\n/** One recorded conversation handed to the in-memory client: plain data, as a fixture file holds it. */\nexport interface RecordedConversation {\n conversation: AgentsConversation;\n messages: AgentsConversationMessage[];\n /** What `getConversationActivity` answers for this conversation; an empty, finished turn when omitted. */\n activity?: ConversationActivity;\n}\n\nexport interface InMemoryAgentsConversationClientData {\n conversations: RecordedConversation[];\n /**\n * The assistant's answers to a post, an injected signal, a start or a retry, used in order; the last one repeats.\n * Default: one answer, \"Done.\".\n */\n scriptedAssistantAnswers?: string[];\n /** What `getSelectableModels` answers; the client has no `getSelectableModels` when omitted. */\n selectableModels?: SelectableModel[];\n /** The page size of `getChangedMessages` when the request names none. Default 50. */\n defaultPageSize?: number;\n /** What `getMessageSentPayload` answers, by message id; the client has no `getMessageSentPayload` when omitted. */\n sentPayloadsByMessageId?: Record<number, ConversationMessageSentPayload>;\n /**\n * The assistant answers this many milliseconds after the send, like a server's turn: the run state is RUNNING\n * meanwhile, then the answer is stored and the run state goes back to IDLE — no `emit()` involved, so a poller sees it.\n * Default 0: the answer is stored together with the send.\n */\n assistantAnswerDelayMs?: number;\n /**\n * The client has no `subscribeToConversationChanges` — a backend without push. The chat then follows the\n * conversation through the polling default (`withPollingChangeSubscription`). Default false.\n */\n withoutChangeSubscription?: boolean;\n}\n\n/** A subscriber of one conversation's live updates. */\ninterface ConversationChangeSubscriber {\n onChange: (signal: ConversationChangeSignal) => void;\n onEnded: (reason: ConversationSubscriptionEndReason) => void;\n}\n\n/** The live-update state of one conversation. */\ninterface ConversationSignalState {\n changeCounter: number;\n summaryUpdatedAt: number | null;\n}\n\nconst DEFAULT_SCRIPTED_ASSISTANT_ANSWER = \"Done.\";\nconst DEFAULT_PAGE_SIZE = 50;\n\n/** A deep copy, so a caller can never change the client's records through a returned object. */\nconst copyOf = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst sortByIndexAscending = (messages: AgentsConversationMessage[]): AgentsConversationMessage[] =>\n [...messages].sort((first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0));\n\nconst textContains = (text: string | null | undefined, searchText: string): boolean =>\n (text ?? \"\").toLowerCase().includes(searchText.trim().toLowerCase());\n\n/** The message text a send stores: the typed text plus one reference line per attachment (as the host application's chat sends it). */\nconst buildStoredMessageText = composeAttachmentMessageText;\n\n/**\n * The conversation client over recorded conversations, for specs, stories and the reference app\n * (`./testing`). Behaves like the server where the chat can see it: a post stores the owner's message and, at once,\n * the next scripted assistant answer — but live updates are driven by hand: `emit()` sends the conversation's next\n * signal to its subscribers (counter advanced, newest message id, the run status), `end()` ends the subscriptions.\n * With `assistantAnswerDelayMs` the answer is stored later, as a server turn would (RUNNING meanwhile); with\n * `withoutChangeSubscription` the client has no subscription at all and the chat polls it.\n */\nexport class InMemoryAgentsConversationClient implements AgentsConversationClient {\n protected readonly recordsByConversationId = new Map<number, RecordedConversation>();\n protected readonly subscribersByConversationId = new Map<number, Set<ConversationChangeSubscriber>>();\n protected readonly signalStateByConversationId = new Map<number, ConversationSignalState>();\n protected readonly scriptedAssistantAnswers: string[];\n protected readonly defaultPageSize: number;\n protected readonly selectableModels: SelectableModel[] | undefined;\n protected readonly sentPayloadsByMessageId: Record<number, ConversationMessageSentPayload> | undefined;\n protected readonly assistantAnswerDelayMs: number;\n protected readonly requestCountsByOperation = new Map<AgentsConversationOperation, number>();\n protected scriptedAssistantAnswersUsed = 0;\n protected nextMessageId: number;\n protected nextConversationId: number;\n\n /** Present only when the data names selectable models (the port function is optional). */\n readonly getSelectableModels?: () => Promise<SelectableModel[]>;\n /** Present only when the data names sent payloads (the port function is optional). */\n readonly getMessageSentPayload?: (conversationId: number, messageId: number) => Promise<ConversationMessageSentPayload>;\n /** Present unless the data asks for a client without push (`withoutChangeSubscription`). */\n readonly subscribeToConversationChanges?: (\n conversationId: number,\n onChange: (signal: ConversationChangeSignal) => void,\n onEnded: (reason: ConversationSubscriptionEndReason) => void,\n ) => () => void;\n\n constructor(data: InMemoryAgentsConversationClientData) {\n for (const recordedConversation of copyOf(data.conversations)) {\n this.recordsByConversationId.set(recordedConversation.conversation.id, recordedConversation);\n }\n const scriptedAssistantAnswers = data.scriptedAssistantAnswers ?? [];\n this.scriptedAssistantAnswers =\n scriptedAssistantAnswers.length > 0 ? [...scriptedAssistantAnswers] : [DEFAULT_SCRIPTED_ASSISTANT_ANSWER];\n this.defaultPageSize = data.defaultPageSize ?? DEFAULT_PAGE_SIZE;\n this.selectableModels = data.selectableModels ? copyOf(data.selectableModels) : undefined;\n if (this.selectableModels) {\n this.getSelectableModels = this.readSelectableModels;\n }\n this.sentPayloadsByMessageId = data.sentPayloadsByMessageId ? copyOf(data.sentPayloadsByMessageId) : undefined;\n if (this.sentPayloadsByMessageId) {\n this.getMessageSentPayload = this.readMessageSentPayload;\n }\n this.assistantAnswerDelayMs = data.assistantAnswerDelayMs ?? 0;\n if (!data.withoutChangeSubscription) {\n this.subscribeToConversationChanges = this.subscribeToRecordedConversationChanges;\n }\n const allMessageIds = data.conversations.flatMap((recorded) => recorded.messages.map((message) => message.id));\n const allConversationIds = data.conversations.map((recorded) => recorded.conversation.id);\n this.nextMessageId = Math.max(0, ...allMessageIds) + 1;\n this.nextConversationId = Math.max(0, ...allConversationIds) + 1;\n }\n\n // ── Port ──────────────────────────────────────────────────────────────────────────────────────────────────────\n\n listConversations = async (\n agentSpaceKey: number,\n options: ConversationListQueryOptions = {},\n ): Promise<AgentsConversation[]> => {\n this.countRequest(\"listConversations\");\n const { includeUnsummarized = false, paging = {} } = options;\n const { top, skip = 0 } = paging;\n const conversationsOfAgentSpace = [...this.recordsByConversationId.values()]\n .map((recorded) => recorded.conversation)\n .filter((conversation) => conversation.agentSpaceKey === agentSpaceKey)\n .filter((conversation) => includeUnsummarized || conversation.title !== null)\n .sort((first, second) => second.id - first.id);\n const end = top === undefined ? undefined : skip + top;\n return copyOf(conversationsOfAgentSpace.slice(skip, end));\n };\n\n /** Account-wide, like the server: every recorded conversation is searched. */\n searchConversations = async (text: string, options: ConversationSearchOptions = {}): Promise<ConversationSearchGroup[]> => {\n this.countRequest(\"searchConversations\");\n const searchGroups: ConversationSearchGroup[] = [];\n for (const recorded of this.recordsByConversationId.values()) {\n const hits = this.findMessageSearchHits(recorded, text);\n if (hits.length === 0) continue;\n searchGroups.push({\n conversationId: recorded.conversation.id,\n title: recorded.conversation.title,\n summary: null,\n created: recorded.messages[0]?.createdDate ?? null,\n updated: recorded.messages[recorded.messages.length - 1]?.createdDate ?? null,\n relevance: 1,\n hits,\n });\n }\n return copyOf(searchGroups.slice(0, options.limit));\n };\n\n /** The stored conversation with `lastMessageId` (the newest stored message), as a backend without push answers it. */\n getConversationMetadata = async (conversationId: number): Promise<AgentsConversation> => {\n this.countRequest(\"getConversationMetadata\");\n const recorded = this.readRecord(conversationId);\n return copyOf({ ...recorded.conversation, lastMessageId: sortByIndexAscending(recorded.messages).pop()?.id ?? null });\n };\n\n getNewestMessagesPage = async (conversationId: number, pageSize: number): Promise<ConversationMessagesPage> => {\n this.countRequest(\"getNewestMessagesPage\");\n const newestFirst = this.readMessagesNewestFirst(conversationId);\n return copyOf({ messages: newestFirst.slice(0, pageSize), hasMoreOlder: newestFirst.length > pageSize });\n };\n\n getOlderMessagesPage = async (\n conversationId: number,\n beforeIndex: number,\n pageSize: number,\n ): Promise<ConversationMessagesPage> => {\n this.countRequest(\"getOlderMessagesPage\");\n const olderMessages = this.readMessagesNewestFirst(conversationId).filter(\n (message) => (message.indexInConversation ?? Number.MAX_SAFE_INTEGER) < beforeIndex,\n );\n return copyOf({ messages: olderMessages.slice(0, pageSize), hasMoreOlder: olderMessages.length > pageSize });\n };\n\n getChangedMessages = async (\n conversationId: number,\n request: ChangedMessagesRequest,\n ): Promise<ChangedConversationMessages> => {\n this.countRequest(\"getChangedMessages\");\n const changedMessages = this.readMessagesNewestFirst(conversationId).filter(\n (message) => message.id > request.highestKnownId || (message.indexInConversation ?? -1) >= request.fromIndex,\n );\n return copyOf({ messages: changedMessages.slice(0, request.pageSize ?? this.defaultPageSize) });\n };\n\n searchConversationMessages = async (\n conversationId: number,\n text: string,\n options: ConversationSearchOptions = {},\n ): Promise<ConversationMessageSearchHit[]> => {\n this.countRequest(\"searchConversationMessages\");\n return copyOf(this.findMessageSearchHits(this.readRecord(conversationId), text).slice(0, options.limit));\n };\n\n getConversationActivity = async (conversationId: number): Promise<ConversationActivity> => {\n this.countRequest(\"getConversationActivity\");\n const activity = this.readRecord(conversationId).activity;\n // a recorded fixture written before the field names no background job: it has none\n return copyOf(\n activity ? { ...activity, runningBackgroundJobs: activity.runningBackgroundJobs ?? [] } : { turnMessageId: null, turnRunning: false, elements: [], runningBackgroundJobs: [] },\n );\n };\n\n /**\n * Stops a running job of the recorded activity like the server: it ends CANCELLED and leaves the running jobs (its\n * end is reported). A job that is not RUNNING answers `isStopped` false with its state; an unknown one is `notFound`.\n */\n stopBackgroundJob = async (conversationId: number, backgroundJobId: number): Promise<ConversationBackgroundJobStop> => {\n this.countRequest(\"stopBackgroundJob\");\n const recorded = this.readRecord(conversationId);\n const runningBackgroundJobs = recorded.activity?.runningBackgroundJobs ?? [];\n const backgroundJob = runningBackgroundJobs.find((runningBackgroundJob) => runningBackgroundJob.id === backgroundJobId);\n if (!backgroundJob || !recorded.activity) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `No background job ${backgroundJobId} in conversation ${conversationId}.` });\n }\n if (backgroundJob.state !== \"RUNNING\") {\n return { isStopped: false, state: backgroundJob.state };\n }\n recorded.activity = {\n ...recorded.activity,\n runningBackgroundJobs: runningBackgroundJobs.filter((runningBackgroundJob) => runningBackgroundJob.id !== backgroundJobId),\n };\n return { isStopped: true, state: \"CANCELLED\" };\n };\n\n startConversation = async (request: {\n agentSpaceKey: number;\n text: string;\n startSignalText?: string;\n entryPointKey?: string;\n model?: string;\n attachments?: ConversationAttachmentReference[];\n }): Promise<StartedConversation> => {\n this.countRequest(\"startConversation\");\n if (request.text === \"\" && !request.startSignalText) {\n throw new AgentsClientError(\"other\", { httpStatus: 400, message: \"A start needs a message or a signal.\" });\n }\n const reopenedConversation = request.entryPointKey\n ? [...this.recordsByConversationId.values()].find(\n (recorded) =>\n recorded.conversation.agentSpaceKey === request.agentSpaceKey &&\n recorded.conversation.entryPointKey === request.entryPointKey,\n )\n : undefined;\n if (reopenedConversation) {\n return { conversation: copyOf(reopenedConversation.conversation), messages: [], reopenedExisting: true };\n }\n const recorded: RecordedConversation = {\n conversation: {\n id: this.nextConversationId,\n agentSpaceKey: request.agentSpaceKey,\n runState: \"IDLE\",\n agentTurnOwedAt: null,\n title: null,\n titleManuallyEdited: false,\n summary: null,\n created: null,\n updated: null,\n purposeName: null,\n initiatorType: null,\n scheduleId: null,\n entryPointKey: request.entryPointKey ?? null,\n progressSteps: [],\n },\n messages: [],\n };\n this.nextConversationId += 1;\n this.recordsByConversationId.set(recorded.conversation.id, recorded);\n if (request.startSignalText) {\n this.appendMessage(recorded, { role: \"USER\", messageType: \"SIGNAL\", authorType: \"USER\", message: request.startSignalText });\n }\n if (request.text !== \"\") {\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"TEXT\",\n authorType: \"USER\",\n message: buildStoredMessageText(request.text, request.attachments),\n });\n }\n const messagesBeforeTheAnswer = copyOf(recorded.messages);\n this.appendScriptedAssistantAnswer(recorded);\n return { conversation: copyOf(recorded.conversation), messages: messagesBeforeTheAnswer, reopenedExisting: false };\n };\n\n postMessage = async (\n conversationId: number,\n message: { text: string; model?: string; attachments?: ConversationAttachmentReference[] },\n ): Promise<PostedMessage> => {\n this.countRequest(\"postMessage\");\n const recorded = this.readOpenRecord(conversationId);\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"TEXT\",\n authorType: \"USER\",\n message: buildStoredMessageText(message.text, message.attachments),\n });\n const messagesBeforeTheAnswer = copyOf(recorded.messages);\n this.appendScriptedAssistantAnswer(recorded);\n return { messages: messagesBeforeTheAnswer };\n };\n\n injectSignal = async (conversationId: number, signal: ConversationSignal): Promise<void> => {\n this.countRequest(\"injectSignal\");\n const recorded = this.readOpenRecord(conversationId);\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"SIGNAL\",\n authorType: \"USER\",\n message: signal.text,\n signalSource: signal.source ?? \"FRONTEND_WIDGET_CLICK\",\n });\n this.appendScriptedAssistantAnswer(recorded);\n };\n\n retryConversation = async (conversationId: number): Promise<void> => {\n this.countRequest(\"retryConversation\");\n const recorded = this.readRecord(conversationId);\n const newestMessage = sortByIndexAscending(recorded.messages).pop();\n if (newestMessage === undefined || newestMessage.role === \"ASSISTANT\") {\n throw new AgentsClientError(\"other\", { httpStatus: 400, message: \"Nothing to retry.\" });\n }\n this.appendScriptedAssistantAnswer(recorded);\n };\n\n renameConversation = async (conversationId: number, title: string): Promise<AgentsConversation> => {\n this.countRequest(\"renameConversation\");\n const recorded = this.readRecord(conversationId);\n recorded.conversation.title = title;\n recorded.conversation.titleManuallyEdited = true;\n return copyOf(recorded.conversation);\n };\n\n deleteConversation = async (conversationId: number): Promise<void> => {\n this.countRequest(\"deleteConversation\");\n this.readRecord(conversationId);\n this.recordsByConversationId.delete(conversationId);\n };\n\n /** The port's `subscribeToConversationChanges` unless `withoutChangeSubscription`; signals come from `emit()`. */\n protected subscribeToRecordedConversationChanges = (\n conversationId: number,\n onChange: (signal: ConversationChangeSignal) => void,\n onEnded: (reason: ConversationSubscriptionEndReason) => void,\n ): (() => void) => {\n const subscriber: ConversationChangeSubscriber = { onChange, onEnded };\n const subscribers = this.subscribersByConversationId.get(conversationId) ?? new Set<ConversationChangeSubscriber>();\n subscribers.add(subscriber);\n this.subscribersByConversationId.set(conversationId, subscribers);\n // Like the realtime database: the current value arrives at once, before any change.\n const record = this.recordsByConversationId.get(conversationId);\n if (record) {\n onChange(this.buildSignal(record, this.readSignalState(conversationId), null));\n }\n return () => {\n subscribers.delete(subscriber);\n };\n };\n\n // ── Driving live updates by hand ──────────────────────────────────────────────────────────────────────────────\n\n /**\n * Sends the conversation's next signal to its subscribers: the counter advances, `lastMessageId` is the newest\n * stored message, the run status follows the stored run state unless `runStatus` is given. `summaryChanged` also\n * advances `summaryUpdatedAt`. Returns the sent signal.\n */\n emit = (\n conversationId: number,\n change: { runStatus?: ConversationRunStatus; summaryChanged?: boolean } = {},\n ): ConversationChangeSignal => {\n const record = this.readRecord(conversationId);\n const signalState = this.readSignalState(conversationId);\n signalState.changeCounter += 1;\n if (change.summaryChanged) {\n signalState.summaryUpdatedAt = (signalState.summaryUpdatedAt ?? 0) + 1;\n }\n const signal = this.buildSignal(record, signalState, change.runStatus ?? null);\n for (const subscriber of [...(this.subscribersByConversationId.get(conversationId) ?? [])]) {\n subscriber.onChange(copyOf(signal));\n }\n return signal;\n };\n\n /** Ends every subscription of the conversation with `reason`, as the server's deletion or a lost access would. */\n end = (conversationId: number, reason: ConversationSubscriptionEndReason): void => {\n const subscribers = [...(this.subscribersByConversationId.get(conversationId) ?? [])];\n this.subscribersByConversationId.delete(conversationId);\n for (const subscriber of subscribers) {\n subscriber.onEnded(reason);\n }\n };\n\n /** Sets a conversation's stored run state (a turn that runs, fails, or a conversation that closes). */\n setRunState = (conversationId: number, runState: AgentsConversation[\"runState\"]): void => {\n this.readRecord(conversationId).conversation.runState = runState;\n };\n\n /**\n * How many requests the client answered — of one port function, or of all when `operation` is omitted (the\n * subscription is no request). For assertions such as \"no read after the chat unmounted\".\n */\n readRequestCount = (operation?: AgentsConversationOperation): number => {\n if (operation !== undefined) return this.requestCountsByOperation.get(operation) ?? 0;\n let requestCount = 0;\n for (const operationRequestCount of this.requestCountsByOperation.values()) requestCount += operationRequestCount;\n return requestCount;\n };\n\n /** Every stored message of a conversation in index order — for assertions. */\n readStoredMessages = (conversationId: number): AgentsConversationMessage[] =>\n copyOf(sortByIndexAscending(this.readRecord(conversationId).messages));\n\n // ── Internals ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n protected countRequest(operation: AgentsConversationOperation): void {\n this.requestCountsByOperation.set(operation, (this.requestCountsByOperation.get(operation) ?? 0) + 1);\n }\n\n protected readSelectableModels = async (): Promise<SelectableModel[]> => {\n this.countRequest(\"getSelectableModels\");\n return copyOf(this.selectableModels ?? []);\n };\n\n protected readMessageSentPayload = async (\n conversationId: number,\n messageId: number,\n ): Promise<ConversationMessageSentPayload> => {\n this.countRequest(\"getMessageSentPayload\");\n this.readRecord(conversationId);\n const sentPayload = this.sentPayloadsByMessageId?.[messageId];\n if (sentPayload === undefined) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `No sent payload for message ${messageId}.` });\n }\n return copyOf(sentPayload);\n };\n\n protected readMessagesNewestFirst(conversationId: number): AgentsConversationMessage[] {\n return sortByIndexAscending(this.readRecord(conversationId).messages).reverse();\n }\n\n protected readRecord(conversationId: number): RecordedConversation {\n const recorded = this.recordsByConversationId.get(conversationId);\n if (!recorded) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `Conversation ${conversationId} not found.` });\n }\n return recorded;\n }\n\n /** The record of a conversation that still takes input; a completed or cancelled one refuses like the server. */\n protected readOpenRecord(conversationId: number): RecordedConversation {\n const recorded = this.readRecord(conversationId);\n const runState = recorded.conversation.runState;\n if (runState !== null && CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION.includes(runState)) {\n throw new AgentsClientError(\"closed\", { httpStatus: 400, code: \"CONVERSATION_CLOSED\" });\n }\n return recorded;\n }\n\n protected readSignalState(conversationId: number): ConversationSignalState {\n const existingSignalState = this.signalStateByConversationId.get(conversationId);\n if (existingSignalState) return existingSignalState;\n const signalState: ConversationSignalState = { changeCounter: 0, summaryUpdatedAt: null };\n this.signalStateByConversationId.set(conversationId, signalState);\n return signalState;\n }\n\n protected buildSignal(\n recorded: RecordedConversation,\n signalState: ConversationSignalState,\n runStatus: ConversationRunStatus | null,\n ): ConversationChangeSignal {\n const newestMessage = sortByIndexAscending(recorded.messages).pop();\n return {\n changeCounter: signalState.changeCounter,\n lastMessageId: newestMessage?.id ?? null,\n runStatus: runStatus ?? readConversationRunStatusOfRunState(recorded.conversation.runState),\n summaryUpdatedAt: signalState.summaryUpdatedAt,\n };\n }\n\n protected appendMessage(\n recorded: RecordedConversation,\n fields: Pick<AgentsConversationMessage, \"role\" | \"messageType\" | \"authorType\" | \"message\"> &\n Partial<Pick<AgentsConversationMessage, \"signalSource\">>,\n ): AgentsConversationMessage {\n const highestIndex = Math.max(-1, ...recorded.messages.map((message) => message.indexInConversation ?? -1));\n const storedMessage: AgentsConversationMessage = {\n id: this.nextMessageId,\n conversationId: recorded.conversation.id,\n indexInConversation: highestIndex + 1,\n status: \"COMPLETED\",\n signalSource: null,\n createdDate: null,\n toolCall: null,\n delegatedConversations: [],\n subAgent: null,\n ...fields,\n };\n this.nextMessageId += 1;\n recorded.messages.push(storedMessage);\n return storedMessage;\n }\n\n /** The next scripted answer: stored at once, or after `assistantAnswerDelayMs` with the run state RUNNING meanwhile. */\n protected appendScriptedAssistantAnswer(recorded: RecordedConversation): void {\n const answerIndex = Math.min(this.scriptedAssistantAnswersUsed, this.scriptedAssistantAnswers.length - 1);\n this.scriptedAssistantAnswersUsed += 1;\n const answerText = this.scriptedAssistantAnswers[answerIndex];\n if (this.assistantAnswerDelayMs <= 0) {\n this.storeAssistantAnswer(recorded, answerText);\n return;\n }\n recorded.conversation.runState = \"RUNNING\";\n setTimeout(this.storeAssistantAnswer, this.assistantAnswerDelayMs, recorded, answerText);\n }\n\n protected storeAssistantAnswer = (recorded: RecordedConversation, answerText: string): void => {\n this.appendMessage(recorded, {\n role: \"ASSISTANT\",\n messageType: \"TEXT\",\n authorType: \"ASSISTANT\",\n message: answerText,\n });\n recorded.conversation.runState = \"IDLE\";\n };\n\n protected findMessageSearchHits(recorded: RecordedConversation, text: string): ConversationMessageSearchHit[] {\n if (text.trim() === \"\") return [];\n return sortByIndexAscending(recorded.messages)\n .filter((message) => message.messageType === \"TEXT\" && textContains(message.message, text))\n .map((message) => ({\n messageId: message.id,\n conversationId: recorded.conversation.id,\n indexInConversation: message.indexInConversation,\n role: message.role,\n excerpt: message.message,\n relevance: 1,\n created: message.createdDate,\n updated: null,\n title: recorded.conversation.title,\n }));\n }\n}\n\n/** The in-memory conversation client over recorded conversations (plain data). */\nexport const createInMemoryAgentsConversationClient = (\n data: InMemoryAgentsConversationClientData,\n): InMemoryAgentsConversationClient => new InMemoryAgentsConversationClient(data);\n","import {\n getWidgetHydrator,\n listWidgetHydratorTypes,\n registerWidgetHydrator,\n unregisterWidgetHydrator,\n} from \"../../renderer/widget-hydration/widget-hydration.registry\";\nimport type { RegisteredWidget, WidgetHydratorContext } from \"../../renderer/widget-hydration/widget-hydration.types\";\nimport { abandonWidgetHydrationReads } from \"../../renderer/widget-hydration/use-widget-hydration\";\n\n/**\n * What a stand-in answers for one hydration: the data itself (a copy is handed out), `{ __status: <code> }` for a\n * failed read (the widget observes `error`), or `{ __pending: true }` for a read that never ends (`loading`). The same\n * shape as a preview fixture's `hydration` entry.\n */\nexport type WidgetHydrationStandInAnswer = unknown | { __status: number; __body?: unknown } | { __pending: true };\n\nconst isPendingAnswer = (answer: unknown): boolean =>\n typeof answer === \"object\" && answer !== null && (answer as { __pending?: unknown }).__pending === true;\n\nconst isStatusAnswer = (answer: unknown): answer is { __status: number } =>\n typeof answer === \"object\" && answer !== null && typeof (answer as { __status?: unknown }).__status === \"number\";\n\n/**\n * Hydration answered by a spec instead of mocking `useWidgetHydration`: every registered hydrator is replaced by one\n * that answers from `answers` — by the hydration's derived key first, then by its type — and otherwise runs the real\n * hydrator. A key that names no registered hydrator gets a stand-in hydrator of that type, so a widget hydrates even\n * when the spec did not import the app's hydrator module. The widget runs its live code path (`useWidgetHydration`\n * with the provider's state store); the answer arrives asynchronously, as a real read does. `restore()` puts the\n * real hydrators back, removes the added ones and abandons every read started through the stand-ins that has not\n * settled yet: the hydration hook keeps one in-flight read per key beyond a store and a mount, so a read left pending\n * would otherwise hold every later mount of the same key in loading.\n */\nexport class WidgetHydrationStandIns {\n protected readonly replacedHydrators = new Map<string, RegisteredWidget<unknown, unknown>>();\n\n protected readonly addedTypes: string[] = [];\n\n /** The hydration key of every read started through the stand-ins that has not settled yet, by its rejection. */\n protected readonly unsettledReadKeys = new Map<(reason: Error) => void, string>();\n\n constructor(protected readonly answers: Readonly<Record<string, WidgetHydrationStandInAnswer>>) {\n for (const type of listWidgetHydratorTypes()) {\n const registered = getWidgetHydrator<unknown, unknown>(type);\n if (registered) this.replaceHydrator(type, registered);\n }\n for (const key of Object.keys(answers)) {\n if (this.replacedHydrators.has(key)) continue;\n this.addedTypes.push(key);\n registerWidgetHydrator<unknown, unknown>(key, {\n hydrator: (payload, context) => this.answer(key, key, payload, context, undefined),\n });\n }\n }\n\n /**\n * Puts the real hydrators back, removes the stand-ins added for types nothing had registered, and aborts and\n * forgets the reads still pending, so the next mount of their keys reads anew.\n */\n restore(): void {\n abandonWidgetHydrationReads(new Set(this.unsettledReadKeys.values()));\n for (const rejectRead of this.unsettledReadKeys.keys()) rejectRead(new Error(\"hydration stand-ins restored\"));\n this.unsettledReadKeys.clear();\n for (const type of this.addedTypes) unregisterWidgetHydrator(type);\n for (const [type, registered] of this.replacedHydrators) {\n unregisterWidgetHydrator(type);\n registerWidgetHydrator(type, registered);\n }\n }\n\n protected replaceHydrator(type: string, registered: RegisteredWidget<unknown, unknown>): void {\n this.replacedHydrators.set(type, registered);\n unregisterWidgetHydrator(type);\n registerWidgetHydrator<unknown, unknown>(type, {\n ...registered,\n hydrator: (payload, context) => this.answer(type, registered.deriveKey(type, payload), payload, context, registered),\n });\n }\n\n /** One read, abandoned by `restore()` while it has not settled. */\n protected answer(\n type: string,\n derivedKey: string,\n payload: unknown,\n context: WidgetHydratorContext,\n registered: RegisteredWidget<unknown, unknown> | undefined,\n ): Promise<unknown> {\n const read = this.readAnswer(type, derivedKey, payload, context, registered);\n return new Promise<unknown>((resolve, reject) => {\n this.unsettledReadKeys.set(reject, derivedKey);\n read.then(resolve, reject).finally(() => this.unsettledReadKeys.delete(reject));\n });\n }\n\n /** The answer for one read: the derived key's entry, else the type's, else the real hydrator (none: a failed read). */\n protected readAnswer(\n type: string,\n derivedKey: string,\n payload: unknown,\n context: WidgetHydratorContext,\n registered: RegisteredWidget<unknown, unknown> | undefined,\n ): Promise<unknown> {\n const answerKey = Object.prototype.hasOwnProperty.call(this.answers, derivedKey)\n ? derivedKey\n : Object.prototype.hasOwnProperty.call(this.answers, type)\n ? type\n : undefined;\n if (answerKey === undefined) {\n return registered\n ? registered.hydrator(payload, context)\n : Promise.reject(new Error(`no hydration stand-in for ${derivedKey}`));\n }\n const answer = this.answers[answerKey];\n if (isPendingAnswer(answer)) return new Promise<never>(() => {});\n if (isStatusAnswer(answer)) return Promise.reject(new Error(`hydration stand-in ${answer.__status}`));\n return Promise.resolve(structuredClone(answer));\n }\n}\n\n/** Installs hydration stand-ins (`WidgetHydrationStandIns`); call `restore()` on the result after the spec. */\nexport const installWidgetHydrationStandIns = (\n answers: Readonly<Record<string, WidgetHydrationStandInAnswer>>,\n): WidgetHydrationStandIns => new WidgetHydrationStandIns(answers);\n","import {\n conversationWidgetRegistry,\n replaceConversationWidgetRegistryEntries,\n type ConversationWidgetEntry,\n} from \"../../renderer/conversationWidgetRegistry\";\n\nexport interface TestConversationWidgetsOptions {\n /**\n * Keeps the registered widgets beside the test widgets (a test widget replaces the registered one of its wire name).\n * Default false: the registry holds the test widgets only, so an app's registrations made with its environment land\n * nowhere while the installation lasts.\n */\n keepRegisteredWidgets?: boolean;\n}\n\n/**\n * The registry entries a spec renders against, and the way back: `restore()` puts the entries the registry held before\n * the installation. Everything that reads the registry — the widget host, the name resolver, the markdown renderer, an\n * embedded widget — sees the test widgets while it lasts.\n */\nexport class TestConversationWidgetsInstallation {\n protected readonly previousWidgets: ConversationWidgetEntry[];\n\n constructor(widgets: readonly ConversationWidgetEntry[], options: TestConversationWidgetsOptions = {}) {\n const testWidgetNames = new Set(widgets.map((widget) => widget.name));\n const keptWidgets = options.keepRegisteredWidgets\n ? conversationWidgetRegistry.widgets.filter((widget) => !testWidgetNames.has(widget.name))\n : [];\n this.previousWidgets = replaceConversationWidgetRegistryEntries([...keptWidgets, ...widgets]);\n }\n\n /** Puts the entries back that the registry held before the installation. */\n restore(): void {\n replaceConversationWidgetRegistryEntries(this.previousWidgets);\n }\n}\n\n/**\n * Renders a spec against widgets of its own instead of mocking the registry module: the test widgets take the\n * registry's place (or join it, `keepRegisteredWidgets`) until `restore()`.\n */\nexport const installTestConversationWidgets = (\n widgets: readonly ConversationWidgetEntry[],\n options: TestConversationWidgetsOptions = {},\n): TestConversationWidgetsInstallation => new TestConversationWidgetsInstallation(widgets, options);\n"],"names":["recorded"],"mappings":";;;;;;;AA0EA,MAAM,oCAAoC;AAC1C,MAAM,oBAAoB;AAG1B,MAAM,SAAS,CAAI,UAAgB,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AAEnE,MAAM,uBAAuB,CAAC,aAC5B,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,OAAO,YAAY,MAAM,uBAAuB,MAAM,OAAO,uBAAuB,EAAE;AAE5G,MAAM,eAAe,CAAC,MAAiC,gBACpD,QAAQ,IAAI,YAAA,EAAc,SAAS,WAAW,KAAA,EAAO,aAAa;AAGrE,MAAM,yBAAyB;AAUxB,MAAM,iCAAqE;AAAA,EAyBhF,YAAY,MAA4C;AAxBxD,SAAmB,8CAA8B,IAAA;AACjD,SAAmB,kDAAkC,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I,eAAe,MAAM,EAAG,QAAO,QAAQ,OAAO,IAAI,MAAM,sBAAsB,OAAO,QAAQ,EAAE,CAAC;AACpG,WAAO,QAAQ,QAAQ,gBAAgB,MAAM,CAAC;AAAA,EAChD;AACF;AAGO,MAAM,iCAAiC,CAC5C,YAC4B,IAAI,wBAAwB,OAAO;ACrG1D,MAAM,oCAAoC;AAAA,EAG/C,YAAY,SAA6C,UAA0C,IAAI;AACrG,UAAM,kBAAkB,IAAI,IAAI,QAAQ,IAAI,CAAC,WAAW,OAAO,IAAI,CAAC;AACpE,UAAM,cAAc,QAAQ,wBACxB,2BAA2B,QAAQ,OAAO,CAAC,WAAW,CAAC,gBAAgB,IAAI,OAAO,IAAI,CAAC,IACvF,CAAA;AACJ,SAAK,kBAAkB,yCAAyC,CAAC,GAAG,aAAa,GAAG,OAAO,CAAC;AAAA,EAC9F;AAAA;AAAA,EAGA,UAAgB;AACd,6CAAyC,KAAK,eAAe;AAAA,EAC/D;AACF;AAMO,MAAM,iCAAiC,CAC5C,SACA,UAA0C,CAAA,MACF,IAAI,oCAAoC,SAAS,OAAO;"}
|
|
1
|
+
{"version":3,"file":"client-testing.js","sources":["../src/client/testing/createInMemoryAgentsConversationClient.ts","../src/client/testing/widget-hydration-stand-ins.ts","../src/client/testing/test-conversation-widgets.ts"],"sourcesContent":["import type { AgentsConversationClient, AgentsConversationOperation } from \"../AgentsConversationClient\";\nimport {\n AgentsClientError,\n type AgentsConversation,\n type AgentsConversationMessage,\n type ChangedConversationMessages,\n type ChangedMessagesRequest,\n type ConversationActivity,\n type ConversationAttachmentReference,\n type ConversationBackgroundJobStop,\n type ConversationStepConfirmation,\n type ConversationChangeSignal,\n type ConversationListQueryOptions,\n type ConversationMessageSearchHit,\n type ConversationMessageSentPayload,\n type ConversationMessagesPage,\n type ConversationRunStatus,\n CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION,\n type ConversationSearchGroup,\n type ConversationSearchOptions,\n type ConversationSignal,\n type ConversationSubscriptionEndReason,\n type PostedMessage,\n readConversationRunStatusOfRunState,\n type SelectableModel,\n type StartedConversation,\n} from \"../../contract/conversation\";\nimport { composeAttachmentMessageText } from \"../compose-attachment-message-text\";\n\n/** One recorded conversation handed to the in-memory client: plain data, as a fixture file holds it. */\nexport interface RecordedConversation {\n conversation: AgentsConversation;\n messages: AgentsConversationMessage[];\n /** What `getConversationActivity` answers for this conversation; an empty, finished turn when omitted. */\n activity?: ConversationActivity;\n /** The stored steps that wait for the owner's click (`getStepConfirmation`, `executeStepConfirmation`, `discardStepConfirmation`). */\n stepConfirmations?: ConversationStepConfirmation[];\n}\n\nexport interface InMemoryAgentsConversationClientData {\n conversations: RecordedConversation[];\n /**\n * The assistant's answers to a post, an injected signal, a start or a retry, used in order; the last one repeats.\n * Default: one answer, \"Done.\".\n */\n scriptedAssistantAnswers?: string[];\n /** What `getSelectableModels` answers; the client has no `getSelectableModels` when omitted. */\n selectableModels?: SelectableModel[];\n /** The page size of `getChangedMessages` when the request names none. Default 50. */\n defaultPageSize?: number;\n /** What `getMessageSentPayload` answers, by message id; the client has no `getMessageSentPayload` when omitted. */\n sentPayloadsByMessageId?: Record<number, ConversationMessageSentPayload>;\n /**\n * The assistant answers this many milliseconds after the send, like a server's turn: the run state is RUNNING\n * meanwhile, then the answer is stored and the run state goes back to IDLE — no `emit()` involved, so a poller sees it.\n * Default 0: the answer is stored together with the send.\n */\n assistantAnswerDelayMs?: number;\n /**\n * The client has no `subscribeToConversationChanges` — a backend without push. The chat then follows the\n * conversation through the polling default (`withPollingChangeSubscription`). Default false.\n */\n withoutChangeSubscription?: boolean;\n}\n\n/** A subscriber of one conversation's live updates. */\ninterface ConversationChangeSubscriber {\n onChange: (signal: ConversationChangeSignal) => void;\n onEnded: (reason: ConversationSubscriptionEndReason) => void;\n}\n\n/** The live-update state of one conversation. */\ninterface ConversationSignalState {\n changeCounter: number;\n summaryUpdatedAt: number | null;\n}\n\nconst DEFAULT_SCRIPTED_ASSISTANT_ANSWER = \"Done.\";\nconst DEFAULT_PAGE_SIZE = 50;\n\n/** A deep copy, so a caller can never change the client's records through a returned object. */\nconst copyOf = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;\n\nconst sortByIndexAscending = (messages: AgentsConversationMessage[]): AgentsConversationMessage[] =>\n [...messages].sort((first, second) => (first.indexInConversation ?? 0) - (second.indexInConversation ?? 0));\n\nconst textContains = (text: string | null | undefined, searchText: string): boolean =>\n (text ?? \"\").toLowerCase().includes(searchText.trim().toLowerCase());\n\n/** The message text a send stores: the typed text plus one reference line per attachment (as the host application's chat sends it). */\nconst buildStoredMessageText = composeAttachmentMessageText;\n\n/**\n * The conversation client over recorded conversations, for specs, stories and the reference app\n * (`./testing`). Behaves like the server where the chat can see it: a post stores the owner's message and, at once,\n * the next scripted assistant answer — but live updates are driven by hand: `emit()` sends the conversation's next\n * signal to its subscribers (counter advanced, newest message id, the run status), `end()` ends the subscriptions.\n * With `assistantAnswerDelayMs` the answer is stored later, as a server turn would (RUNNING meanwhile); with\n * `withoutChangeSubscription` the client has no subscription at all and the chat polls it.\n */\nexport class InMemoryAgentsConversationClient implements AgentsConversationClient {\n protected readonly recordsByConversationId = new Map<number, RecordedConversation>();\n protected readonly subscribersByConversationId = new Map<number, Set<ConversationChangeSubscriber>>();\n protected readonly signalStateByConversationId = new Map<number, ConversationSignalState>();\n protected readonly scriptedAssistantAnswers: string[];\n protected readonly defaultPageSize: number;\n protected readonly selectableModels: SelectableModel[] | undefined;\n protected readonly sentPayloadsByMessageId: Record<number, ConversationMessageSentPayload> | undefined;\n protected readonly assistantAnswerDelayMs: number;\n protected readonly requestCountsByOperation = new Map<AgentsConversationOperation, number>();\n protected scriptedAssistantAnswersUsed = 0;\n protected nextMessageId: number;\n protected nextConversationId: number;\n\n /** Present only when the data names selectable models (the port function is optional). */\n readonly getSelectableModels?: () => Promise<SelectableModel[]>;\n /** Present only when the data names sent payloads (the port function is optional). */\n readonly getMessageSentPayload?: (conversationId: number, messageId: number) => Promise<ConversationMessageSentPayload>;\n /** Present unless the data asks for a client without push (`withoutChangeSubscription`). */\n readonly subscribeToConversationChanges?: (\n conversationId: number,\n onChange: (signal: ConversationChangeSignal) => void,\n onEnded: (reason: ConversationSubscriptionEndReason) => void,\n ) => () => void;\n\n constructor(data: InMemoryAgentsConversationClientData) {\n for (const recordedConversation of copyOf(data.conversations)) {\n this.recordsByConversationId.set(recordedConversation.conversation.id, recordedConversation);\n }\n const scriptedAssistantAnswers = data.scriptedAssistantAnswers ?? [];\n this.scriptedAssistantAnswers =\n scriptedAssistantAnswers.length > 0 ? [...scriptedAssistantAnswers] : [DEFAULT_SCRIPTED_ASSISTANT_ANSWER];\n this.defaultPageSize = data.defaultPageSize ?? DEFAULT_PAGE_SIZE;\n this.selectableModels = data.selectableModels ? copyOf(data.selectableModels) : undefined;\n if (this.selectableModels) {\n this.getSelectableModels = this.readSelectableModels;\n }\n this.sentPayloadsByMessageId = data.sentPayloadsByMessageId ? copyOf(data.sentPayloadsByMessageId) : undefined;\n if (this.sentPayloadsByMessageId) {\n this.getMessageSentPayload = this.readMessageSentPayload;\n }\n this.assistantAnswerDelayMs = data.assistantAnswerDelayMs ?? 0;\n if (!data.withoutChangeSubscription) {\n this.subscribeToConversationChanges = this.subscribeToRecordedConversationChanges;\n }\n const allMessageIds = data.conversations.flatMap((recorded) => recorded.messages.map((message) => message.id));\n const allConversationIds = data.conversations.map((recorded) => recorded.conversation.id);\n this.nextMessageId = Math.max(0, ...allMessageIds) + 1;\n this.nextConversationId = Math.max(0, ...allConversationIds) + 1;\n }\n\n // ── Port ──────────────────────────────────────────────────────────────────────────────────────────────────────\n\n listConversations = async (\n agentSpaceKey: number,\n options: ConversationListQueryOptions = {},\n ): Promise<AgentsConversation[]> => {\n this.countRequest(\"listConversations\");\n const { includeUnsummarized = false, paging = {} } = options;\n const { top, skip = 0 } = paging;\n const conversationsOfAgentSpace = [...this.recordsByConversationId.values()]\n .map((recorded) => recorded.conversation)\n .filter((conversation) => conversation.agentSpaceKey === agentSpaceKey)\n .filter((conversation) => includeUnsummarized || conversation.title !== null)\n .sort((first, second) => second.id - first.id);\n const end = top === undefined ? undefined : skip + top;\n return copyOf(conversationsOfAgentSpace.slice(skip, end));\n };\n\n /** Account-wide, like the server: every recorded conversation is searched. */\n searchConversations = async (text: string, options: ConversationSearchOptions = {}): Promise<ConversationSearchGroup[]> => {\n this.countRequest(\"searchConversations\");\n const searchGroups: ConversationSearchGroup[] = [];\n for (const recorded of this.recordsByConversationId.values()) {\n const hits = this.findMessageSearchHits(recorded, text);\n if (hits.length === 0) continue;\n searchGroups.push({\n conversationId: recorded.conversation.id,\n title: recorded.conversation.title,\n summary: null,\n created: recorded.messages[0]?.createdDate ?? null,\n updated: recorded.messages[recorded.messages.length - 1]?.createdDate ?? null,\n relevance: 1,\n hits,\n });\n }\n return copyOf(searchGroups.slice(0, options.limit));\n };\n\n /** The stored conversation with `lastMessageId` (the newest stored message), as a backend without push answers it. */\n getConversationMetadata = async (conversationId: number): Promise<AgentsConversation> => {\n this.countRequest(\"getConversationMetadata\");\n const recorded = this.readRecord(conversationId);\n return copyOf({ ...recorded.conversation, lastMessageId: sortByIndexAscending(recorded.messages).pop()?.id ?? null });\n };\n\n getNewestMessagesPage = async (conversationId: number, pageSize: number): Promise<ConversationMessagesPage> => {\n this.countRequest(\"getNewestMessagesPage\");\n const newestFirst = this.readMessagesNewestFirst(conversationId);\n return copyOf({ messages: newestFirst.slice(0, pageSize), hasMoreOlder: newestFirst.length > pageSize });\n };\n\n getOlderMessagesPage = async (\n conversationId: number,\n beforeIndex: number,\n pageSize: number,\n ): Promise<ConversationMessagesPage> => {\n this.countRequest(\"getOlderMessagesPage\");\n const olderMessages = this.readMessagesNewestFirst(conversationId).filter(\n (message) => (message.indexInConversation ?? Number.MAX_SAFE_INTEGER) < beforeIndex,\n );\n return copyOf({ messages: olderMessages.slice(0, pageSize), hasMoreOlder: olderMessages.length > pageSize });\n };\n\n getChangedMessages = async (\n conversationId: number,\n request: ChangedMessagesRequest,\n ): Promise<ChangedConversationMessages> => {\n this.countRequest(\"getChangedMessages\");\n const changedMessages = this.readMessagesNewestFirst(conversationId).filter(\n (message) => message.id > request.highestKnownId || (message.indexInConversation ?? -1) >= request.fromIndex,\n );\n return copyOf({ messages: changedMessages.slice(0, request.pageSize ?? this.defaultPageSize) });\n };\n\n searchConversationMessages = async (\n conversationId: number,\n text: string,\n options: ConversationSearchOptions = {},\n ): Promise<ConversationMessageSearchHit[]> => {\n this.countRequest(\"searchConversationMessages\");\n return copyOf(this.findMessageSearchHits(this.readRecord(conversationId), text).slice(0, options.limit));\n };\n\n getConversationActivity = async (conversationId: number): Promise<ConversationActivity> => {\n this.countRequest(\"getConversationActivity\");\n const activity = this.readRecord(conversationId).activity;\n // a recorded fixture written before the field names no background job: it has none\n return copyOf(\n activity ? { ...activity, runningBackgroundJobs: activity.runningBackgroundJobs ?? [] } : { turnMessageId: null, turnRunning: false, elements: [], runningBackgroundJobs: [] },\n );\n };\n\n /**\n * Stops a running job of the recorded activity like the server: it ends CANCELLED and leaves the running jobs (its\n * end is reported). A job that is not RUNNING answers `isStopped` false with its state; an unknown one is `notFound`.\n */\n stopBackgroundJob = async (conversationId: number, backgroundJobId: number): Promise<ConversationBackgroundJobStop> => {\n this.countRequest(\"stopBackgroundJob\");\n const recorded = this.readRecord(conversationId);\n const runningBackgroundJobs = recorded.activity?.runningBackgroundJobs ?? [];\n const backgroundJob = runningBackgroundJobs.find((runningBackgroundJob) => runningBackgroundJob.id === backgroundJobId);\n if (!backgroundJob || !recorded.activity) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `No background job ${backgroundJobId} in conversation ${conversationId}.` });\n }\n if (backgroundJob.state !== \"RUNNING\") {\n return { isStopped: false, state: backgroundJob.state };\n }\n recorded.activity = {\n ...recorded.activity,\n runningBackgroundJobs: runningBackgroundJobs.filter((runningBackgroundJob) => runningBackgroundJob.id !== backgroundJobId),\n };\n return { isStopped: true, state: \"CANCELLED\" };\n };\n\n /** A recorded step of the conversation, or `notFound` like the server. */\n protected readStepConfirmation(conversationId: number, stepConfirmationId: number): ConversationStepConfirmation {\n const stepConfirmation = (this.readRecord(conversationId).stepConfirmations ?? []).find((recordedStep) => recordedStep.id === stepConfirmationId);\n if (!stepConfirmation) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `No step ${stepConfirmationId} in conversation ${conversationId}.` });\n }\n return stepConfirmation;\n }\n\n getStepConfirmation = async (conversationId: number, stepConfirmationId: number): Promise<ConversationStepConfirmation> => {\n this.countRequest(\"getStepConfirmation\");\n return copyOf(this.readStepConfirmation(conversationId, stepConfirmationId));\n };\n\n /**\n * Runs a recorded step like the server: refused with HTTP 400 when the hash differs, with 403 when the step is no\n * longer open; else it ends EXECUTED with the excerpt \"Done.\".\n */\n executeStepConfirmation = async (conversationId: number, stepConfirmationId: number, contentHash: string): Promise<ConversationStepConfirmation> => {\n this.countRequest(\"executeStepConfirmation\");\n const stepConfirmation = this.readStepConfirmation(conversationId, stepConfirmationId);\n if (stepConfirmation.contentHash !== contentHash) {\n throw new AgentsClientError(\"other\", { httpStatus: 400, message: \"This step changed meanwhile; only the step shown in the chat can run.\" });\n }\n if (stepConfirmation.status !== \"OPEN\") {\n throw new AgentsClientError(\"forbidden\", { httpStatus: 403, message: `This step is no longer open (${stepConfirmation.status ?? \"unknown\"}).` });\n }\n stepConfirmation.status = \"EXECUTED\";\n stepConfirmation.resultExcerpt = \"Done.\";\n return copyOf(stepConfirmation);\n };\n\n /** Discards a recorded open step like the server (403 when it is no longer open). */\n discardStepConfirmation = async (conversationId: number, stepConfirmationId: number): Promise<ConversationStepConfirmation> => {\n this.countRequest(\"discardStepConfirmation\");\n const stepConfirmation = this.readStepConfirmation(conversationId, stepConfirmationId);\n if (stepConfirmation.status !== \"OPEN\") {\n throw new AgentsClientError(\"forbidden\", { httpStatus: 403, message: \"This step was answered meanwhile.\" });\n }\n stepConfirmation.status = \"DISCARDED\";\n return copyOf(stepConfirmation);\n };\n\n startConversation = async (request: {\n agentSpaceKey: number;\n text: string;\n startSignalText?: string;\n entryPointKey?: string;\n model?: string;\n attachments?: ConversationAttachmentReference[];\n }): Promise<StartedConversation> => {\n this.countRequest(\"startConversation\");\n if (request.text === \"\" && !request.startSignalText) {\n throw new AgentsClientError(\"other\", { httpStatus: 400, message: \"A start needs a message or a signal.\" });\n }\n const reopenedConversation = request.entryPointKey\n ? [...this.recordsByConversationId.values()].find(\n (recorded) =>\n recorded.conversation.agentSpaceKey === request.agentSpaceKey &&\n recorded.conversation.entryPointKey === request.entryPointKey,\n )\n : undefined;\n if (reopenedConversation) {\n return { conversation: copyOf(reopenedConversation.conversation), messages: [], reopenedExisting: true };\n }\n const recorded: RecordedConversation = {\n conversation: {\n id: this.nextConversationId,\n agentSpaceKey: request.agentSpaceKey,\n runState: \"IDLE\",\n agentTurnOwedAt: null,\n title: null,\n titleManuallyEdited: false,\n summary: null,\n created: null,\n updated: null,\n purposeName: null,\n initiatorType: null,\n scheduleId: null,\n entryPointKey: request.entryPointKey ?? null,\n progressSteps: [],\n },\n messages: [],\n };\n this.nextConversationId += 1;\n this.recordsByConversationId.set(recorded.conversation.id, recorded);\n if (request.startSignalText) {\n this.appendMessage(recorded, { role: \"USER\", messageType: \"SIGNAL\", authorType: \"USER\", message: request.startSignalText });\n }\n if (request.text !== \"\") {\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"TEXT\",\n authorType: \"USER\",\n message: buildStoredMessageText(request.text, request.attachments),\n });\n }\n const messagesBeforeTheAnswer = copyOf(recorded.messages);\n this.appendScriptedAssistantAnswer(recorded);\n return { conversation: copyOf(recorded.conversation), messages: messagesBeforeTheAnswer, reopenedExisting: false };\n };\n\n postMessage = async (\n conversationId: number,\n message: { text: string; model?: string; attachments?: ConversationAttachmentReference[] },\n ): Promise<PostedMessage> => {\n this.countRequest(\"postMessage\");\n const recorded = this.readOpenRecord(conversationId);\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"TEXT\",\n authorType: \"USER\",\n message: buildStoredMessageText(message.text, message.attachments),\n });\n const messagesBeforeTheAnswer = copyOf(recorded.messages);\n this.appendScriptedAssistantAnswer(recorded);\n return { messages: messagesBeforeTheAnswer };\n };\n\n injectSignal = async (conversationId: number, signal: ConversationSignal): Promise<void> => {\n this.countRequest(\"injectSignal\");\n const recorded = this.readOpenRecord(conversationId);\n this.appendMessage(recorded, {\n role: \"USER\",\n messageType: \"SIGNAL\",\n authorType: \"USER\",\n message: signal.text,\n signalSource: signal.source ?? \"FRONTEND_WIDGET_CLICK\",\n });\n this.appendScriptedAssistantAnswer(recorded);\n };\n\n retryConversation = async (conversationId: number): Promise<void> => {\n this.countRequest(\"retryConversation\");\n const recorded = this.readRecord(conversationId);\n const newestMessage = sortByIndexAscending(recorded.messages).pop();\n if (newestMessage === undefined || newestMessage.role === \"ASSISTANT\") {\n throw new AgentsClientError(\"other\", { httpStatus: 400, message: \"Nothing to retry.\" });\n }\n this.appendScriptedAssistantAnswer(recorded);\n };\n\n renameConversation = async (conversationId: number, title: string): Promise<AgentsConversation> => {\n this.countRequest(\"renameConversation\");\n const recorded = this.readRecord(conversationId);\n recorded.conversation.title = title;\n recorded.conversation.titleManuallyEdited = true;\n return copyOf(recorded.conversation);\n };\n\n deleteConversation = async (conversationId: number): Promise<void> => {\n this.countRequest(\"deleteConversation\");\n this.readRecord(conversationId);\n this.recordsByConversationId.delete(conversationId);\n };\n\n /** The port's `subscribeToConversationChanges` unless `withoutChangeSubscription`; signals come from `emit()`. */\n protected subscribeToRecordedConversationChanges = (\n conversationId: number,\n onChange: (signal: ConversationChangeSignal) => void,\n onEnded: (reason: ConversationSubscriptionEndReason) => void,\n ): (() => void) => {\n const subscriber: ConversationChangeSubscriber = { onChange, onEnded };\n const subscribers = this.subscribersByConversationId.get(conversationId) ?? new Set<ConversationChangeSubscriber>();\n subscribers.add(subscriber);\n this.subscribersByConversationId.set(conversationId, subscribers);\n // Like the realtime database: the current value arrives at once, before any change.\n const record = this.recordsByConversationId.get(conversationId);\n if (record) {\n onChange(this.buildSignal(record, this.readSignalState(conversationId), null));\n }\n return () => {\n subscribers.delete(subscriber);\n };\n };\n\n // ── Driving live updates by hand ──────────────────────────────────────────────────────────────────────────────\n\n /**\n * Sends the conversation's next signal to its subscribers: the counter advances, `lastMessageId` is the newest\n * stored message, the run status follows the stored run state unless `runStatus` is given. `summaryChanged` also\n * advances `summaryUpdatedAt`. Returns the sent signal.\n */\n emit = (\n conversationId: number,\n change: { runStatus?: ConversationRunStatus; summaryChanged?: boolean } = {},\n ): ConversationChangeSignal => {\n const record = this.readRecord(conversationId);\n const signalState = this.readSignalState(conversationId);\n signalState.changeCounter += 1;\n if (change.summaryChanged) {\n signalState.summaryUpdatedAt = (signalState.summaryUpdatedAt ?? 0) + 1;\n }\n const signal = this.buildSignal(record, signalState, change.runStatus ?? null);\n for (const subscriber of [...(this.subscribersByConversationId.get(conversationId) ?? [])]) {\n subscriber.onChange(copyOf(signal));\n }\n return signal;\n };\n\n /** Ends every subscription of the conversation with `reason`, as the server's deletion or a lost access would. */\n end = (conversationId: number, reason: ConversationSubscriptionEndReason): void => {\n const subscribers = [...(this.subscribersByConversationId.get(conversationId) ?? [])];\n this.subscribersByConversationId.delete(conversationId);\n for (const subscriber of subscribers) {\n subscriber.onEnded(reason);\n }\n };\n\n /** Sets a conversation's stored run state (a turn that runs, fails, or a conversation that closes). */\n setRunState = (conversationId: number, runState: AgentsConversation[\"runState\"]): void => {\n this.readRecord(conversationId).conversation.runState = runState;\n };\n\n /**\n * How many requests the client answered — of one port function, or of all when `operation` is omitted (the\n * subscription is no request). For assertions such as \"no read after the chat unmounted\".\n */\n readRequestCount = (operation?: AgentsConversationOperation): number => {\n if (operation !== undefined) return this.requestCountsByOperation.get(operation) ?? 0;\n let requestCount = 0;\n for (const operationRequestCount of this.requestCountsByOperation.values()) requestCount += operationRequestCount;\n return requestCount;\n };\n\n /** Every stored message of a conversation in index order — for assertions. */\n readStoredMessages = (conversationId: number): AgentsConversationMessage[] =>\n copyOf(sortByIndexAscending(this.readRecord(conversationId).messages));\n\n // ── Internals ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n protected countRequest(operation: AgentsConversationOperation): void {\n this.requestCountsByOperation.set(operation, (this.requestCountsByOperation.get(operation) ?? 0) + 1);\n }\n\n protected readSelectableModels = async (): Promise<SelectableModel[]> => {\n this.countRequest(\"getSelectableModels\");\n return copyOf(this.selectableModels ?? []);\n };\n\n protected readMessageSentPayload = async (\n conversationId: number,\n messageId: number,\n ): Promise<ConversationMessageSentPayload> => {\n this.countRequest(\"getMessageSentPayload\");\n this.readRecord(conversationId);\n const sentPayload = this.sentPayloadsByMessageId?.[messageId];\n if (sentPayload === undefined) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `No sent payload for message ${messageId}.` });\n }\n return copyOf(sentPayload);\n };\n\n protected readMessagesNewestFirst(conversationId: number): AgentsConversationMessage[] {\n return sortByIndexAscending(this.readRecord(conversationId).messages).reverse();\n }\n\n protected readRecord(conversationId: number): RecordedConversation {\n const recorded = this.recordsByConversationId.get(conversationId);\n if (!recorded) {\n throw new AgentsClientError(\"notFound\", { httpStatus: 404, message: `Conversation ${conversationId} not found.` });\n }\n return recorded;\n }\n\n /** The record of a conversation that still takes input; a completed or cancelled one refuses like the server. */\n protected readOpenRecord(conversationId: number): RecordedConversation {\n const recorded = this.readRecord(conversationId);\n const runState = recorded.conversation.runState;\n if (runState !== null && CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION.includes(runState)) {\n throw new AgentsClientError(\"closed\", { httpStatus: 400, code: \"CONVERSATION_CLOSED\" });\n }\n return recorded;\n }\n\n protected readSignalState(conversationId: number): ConversationSignalState {\n const existingSignalState = this.signalStateByConversationId.get(conversationId);\n if (existingSignalState) return existingSignalState;\n const signalState: ConversationSignalState = { changeCounter: 0, summaryUpdatedAt: null };\n this.signalStateByConversationId.set(conversationId, signalState);\n return signalState;\n }\n\n protected buildSignal(\n recorded: RecordedConversation,\n signalState: ConversationSignalState,\n runStatus: ConversationRunStatus | null,\n ): ConversationChangeSignal {\n const newestMessage = sortByIndexAscending(recorded.messages).pop();\n return {\n changeCounter: signalState.changeCounter,\n lastMessageId: newestMessage?.id ?? null,\n runStatus: runStatus ?? readConversationRunStatusOfRunState(recorded.conversation.runState),\n summaryUpdatedAt: signalState.summaryUpdatedAt,\n };\n }\n\n protected appendMessage(\n recorded: RecordedConversation,\n fields: Pick<AgentsConversationMessage, \"role\" | \"messageType\" | \"authorType\" | \"message\"> &\n Partial<Pick<AgentsConversationMessage, \"signalSource\">>,\n ): AgentsConversationMessage {\n const highestIndex = Math.max(-1, ...recorded.messages.map((message) => message.indexInConversation ?? -1));\n const storedMessage: AgentsConversationMessage = {\n id: this.nextMessageId,\n conversationId: recorded.conversation.id,\n indexInConversation: highestIndex + 1,\n status: \"COMPLETED\",\n signalSource: null,\n createdDate: null,\n toolCall: null,\n delegatedConversations: [],\n subAgent: null,\n ...fields,\n };\n this.nextMessageId += 1;\n recorded.messages.push(storedMessage);\n return storedMessage;\n }\n\n /** The next scripted answer: stored at once, or after `assistantAnswerDelayMs` with the run state RUNNING meanwhile. */\n protected appendScriptedAssistantAnswer(recorded: RecordedConversation): void {\n const answerIndex = Math.min(this.scriptedAssistantAnswersUsed, this.scriptedAssistantAnswers.length - 1);\n this.scriptedAssistantAnswersUsed += 1;\n const answerText = this.scriptedAssistantAnswers[answerIndex];\n if (this.assistantAnswerDelayMs <= 0) {\n this.storeAssistantAnswer(recorded, answerText);\n return;\n }\n recorded.conversation.runState = \"RUNNING\";\n setTimeout(this.storeAssistantAnswer, this.assistantAnswerDelayMs, recorded, answerText);\n }\n\n protected storeAssistantAnswer = (recorded: RecordedConversation, answerText: string): void => {\n this.appendMessage(recorded, {\n role: \"ASSISTANT\",\n messageType: \"TEXT\",\n authorType: \"ASSISTANT\",\n message: answerText,\n });\n recorded.conversation.runState = \"IDLE\";\n };\n\n protected findMessageSearchHits(recorded: RecordedConversation, text: string): ConversationMessageSearchHit[] {\n if (text.trim() === \"\") return [];\n return sortByIndexAscending(recorded.messages)\n .filter((message) => message.messageType === \"TEXT\" && textContains(message.message, text))\n .map((message) => ({\n messageId: message.id,\n conversationId: recorded.conversation.id,\n indexInConversation: message.indexInConversation,\n role: message.role,\n excerpt: message.message,\n relevance: 1,\n created: message.createdDate,\n updated: null,\n title: recorded.conversation.title,\n }));\n }\n}\n\n/** The in-memory conversation client over recorded conversations (plain data). */\nexport const createInMemoryAgentsConversationClient = (\n data: InMemoryAgentsConversationClientData,\n): InMemoryAgentsConversationClient => new InMemoryAgentsConversationClient(data);\n","import {\n getWidgetHydrator,\n listWidgetHydratorTypes,\n registerWidgetHydrator,\n unregisterWidgetHydrator,\n} from \"../../renderer/widget-hydration/widget-hydration.registry\";\nimport type { RegisteredWidget, WidgetHydratorContext } from \"../../renderer/widget-hydration/widget-hydration.types\";\nimport { abandonWidgetHydrationReads } from \"../../renderer/widget-hydration/use-widget-hydration\";\n\n/**\n * What a stand-in answers for one hydration: the data itself (a copy is handed out), `{ __status: <code> }` for a\n * failed read (the widget observes `error`), or `{ __pending: true }` for a read that never ends (`loading`). The same\n * shape as a preview fixture's `hydration` entry.\n */\nexport type WidgetHydrationStandInAnswer = unknown | { __status: number; __body?: unknown } | { __pending: true };\n\nconst isPendingAnswer = (answer: unknown): boolean =>\n typeof answer === \"object\" && answer !== null && (answer as { __pending?: unknown }).__pending === true;\n\nconst isStatusAnswer = (answer: unknown): answer is { __status: number } =>\n typeof answer === \"object\" && answer !== null && typeof (answer as { __status?: unknown }).__status === \"number\";\n\n/**\n * Hydration answered by a spec instead of mocking `useWidgetHydration`: every registered hydrator is replaced by one\n * that answers from `answers` — by the hydration's derived key first, then by its type — and otherwise runs the real\n * hydrator. A key that names no registered hydrator gets a stand-in hydrator of that type, so a widget hydrates even\n * when the spec did not import the app's hydrator module. The widget runs its live code path (`useWidgetHydration`\n * with the provider's state store); the answer arrives asynchronously, as a real read does. `restore()` puts the\n * real hydrators back, removes the added ones and abandons every read started through the stand-ins that has not\n * settled yet: the hydration hook keeps one in-flight read per key beyond a store and a mount, so a read left pending\n * would otherwise hold every later mount of the same key in loading.\n */\nexport class WidgetHydrationStandIns {\n protected readonly replacedHydrators = new Map<string, RegisteredWidget<unknown, unknown>>();\n\n protected readonly addedTypes: string[] = [];\n\n /** The hydration key of every read started through the stand-ins that has not settled yet, by its rejection. */\n protected readonly unsettledReadKeys = new Map<(reason: Error) => void, string>();\n\n constructor(protected readonly answers: Readonly<Record<string, WidgetHydrationStandInAnswer>>) {\n for (const type of listWidgetHydratorTypes()) {\n const registered = getWidgetHydrator<unknown, unknown>(type);\n if (registered) this.replaceHydrator(type, registered);\n }\n for (const key of Object.keys(answers)) {\n if (this.replacedHydrators.has(key)) continue;\n this.addedTypes.push(key);\n registerWidgetHydrator<unknown, unknown>(key, {\n hydrator: (payload, context) => this.answer(key, key, payload, context, undefined),\n });\n }\n }\n\n /**\n * Puts the real hydrators back, removes the stand-ins added for types nothing had registered, and aborts and\n * forgets the reads still pending, so the next mount of their keys reads anew.\n */\n restore(): void {\n abandonWidgetHydrationReads(new Set(this.unsettledReadKeys.values()));\n for (const rejectRead of this.unsettledReadKeys.keys()) rejectRead(new Error(\"hydration stand-ins restored\"));\n this.unsettledReadKeys.clear();\n for (const type of this.addedTypes) unregisterWidgetHydrator(type);\n for (const [type, registered] of this.replacedHydrators) {\n unregisterWidgetHydrator(type);\n registerWidgetHydrator(type, registered);\n }\n }\n\n protected replaceHydrator(type: string, registered: RegisteredWidget<unknown, unknown>): void {\n this.replacedHydrators.set(type, registered);\n unregisterWidgetHydrator(type);\n registerWidgetHydrator<unknown, unknown>(type, {\n ...registered,\n hydrator: (payload, context) => this.answer(type, registered.deriveKey(type, payload), payload, context, registered),\n });\n }\n\n /** One read, abandoned by `restore()` while it has not settled. */\n protected answer(\n type: string,\n derivedKey: string,\n payload: unknown,\n context: WidgetHydratorContext,\n registered: RegisteredWidget<unknown, unknown> | undefined,\n ): Promise<unknown> {\n const read = this.readAnswer(type, derivedKey, payload, context, registered);\n return new Promise<unknown>((resolve, reject) => {\n this.unsettledReadKeys.set(reject, derivedKey);\n read.then(resolve, reject).finally(() => this.unsettledReadKeys.delete(reject));\n });\n }\n\n /** The answer for one read: the derived key's entry, else the type's, else the real hydrator (none: a failed read). */\n protected readAnswer(\n type: string,\n derivedKey: string,\n payload: unknown,\n context: WidgetHydratorContext,\n registered: RegisteredWidget<unknown, unknown> | undefined,\n ): Promise<unknown> {\n const answerKey = Object.prototype.hasOwnProperty.call(this.answers, derivedKey)\n ? derivedKey\n : Object.prototype.hasOwnProperty.call(this.answers, type)\n ? type\n : undefined;\n if (answerKey === undefined) {\n return registered\n ? registered.hydrator(payload, context)\n : Promise.reject(new Error(`no hydration stand-in for ${derivedKey}`));\n }\n const answer = this.answers[answerKey];\n if (isPendingAnswer(answer)) return new Promise<never>(() => {});\n if (isStatusAnswer(answer)) return Promise.reject(new Error(`hydration stand-in ${answer.__status}`));\n return Promise.resolve(structuredClone(answer));\n }\n}\n\n/** Installs hydration stand-ins (`WidgetHydrationStandIns`); call `restore()` on the result after the spec. */\nexport const installWidgetHydrationStandIns = (\n answers: Readonly<Record<string, WidgetHydrationStandInAnswer>>,\n): WidgetHydrationStandIns => new WidgetHydrationStandIns(answers);\n","import {\n conversationWidgetRegistry,\n replaceConversationWidgetRegistryEntries,\n type ConversationWidgetEntry,\n} from \"../../renderer/conversationWidgetRegistry\";\n\nexport interface TestConversationWidgetsOptions {\n /**\n * Keeps the registered widgets beside the test widgets (a test widget replaces the registered one of its wire name).\n * Default false: the registry holds the test widgets only, so an app's registrations made with its environment land\n * nowhere while the installation lasts.\n */\n keepRegisteredWidgets?: boolean;\n}\n\n/**\n * The registry entries a spec renders against, and the way back: `restore()` puts the entries the registry held before\n * the installation. Everything that reads the registry — the widget host, the name resolver, the markdown renderer, an\n * embedded widget — sees the test widgets while it lasts.\n */\nexport class TestConversationWidgetsInstallation {\n protected readonly previousWidgets: ConversationWidgetEntry[];\n\n constructor(widgets: readonly ConversationWidgetEntry[], options: TestConversationWidgetsOptions = {}) {\n const testWidgetNames = new Set(widgets.map((widget) => widget.name));\n const keptWidgets = options.keepRegisteredWidgets\n ? conversationWidgetRegistry.widgets.filter((widget) => !testWidgetNames.has(widget.name))\n : [];\n this.previousWidgets = replaceConversationWidgetRegistryEntries([...keptWidgets, ...widgets]);\n }\n\n /** Puts the entries back that the registry held before the installation. */\n restore(): void {\n replaceConversationWidgetRegistryEntries(this.previousWidgets);\n }\n}\n\n/**\n * Renders a spec against widgets of its own instead of mocking the registry module: the test widgets take the\n * registry's place (or join it, `keepRegisteredWidgets`) until `restore()`.\n */\nexport const installTestConversationWidgets = (\n widgets: readonly ConversationWidgetEntry[],\n options: TestConversationWidgetsOptions = {},\n): TestConversationWidgetsInstallation => new TestConversationWidgetsInstallation(widgets, options);\n"],"names":["recorded"],"mappings":";;;;;;;AA6EA,MAAM,oCAAoC;AAC1C,MAAM,oBAAoB;AAG1B,MAAM,SAAS,CAAI,UAAgB,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AAEnE,MAAM,uBAAuB,CAAC,aAC5B,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,OAAO,YAAY,MAAM,uBAAuB,MAAM,OAAO,uBAAuB,EAAE;AAE5G,MAAM,eAAe,CAAC,MAAiC,gBACpD,QAAQ,IAAI,YAAA,EAAc,SAAS,WAAW,KAAA,EAAO,aAAa;AAGrE,MAAM,yBAAyB;AAUxB,MAAM,iCAAqE;AAAA,EAyBhF,YAAY,MAA4C;AAxBxD,SAAmB,8CAA8B,IAAA;AACjD,SAAmB,kDAAkC,IAAA;AACrD,SAAmB,kDAAkC,IAAA;AAMrD,SAAmB,+CAA+B,IAAA;AAClD,SAAU,+BAA+B;AA2CzC,SAAA,oBAAoB,OAClB,eACA,UAAwC,CAAA,MACN;AAClC,WAAK,aAAa,mBAAmB;AACrC,YAAM,EAAE,sBAAsB,OAAO,SAAS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AM,oCAAoC;AAAA,EAG/C,YAAY,SAA6C,UAA0C,IAAI;AACrG,UAAM,kBAAkB,IAAI,IAAI,QAAQ,IAAI,CAAC,WAAW,OAAO,IAAI,CAAC;AACpE,UAAM,cAAc,QAAQ,wBACxB,2BAA2B,QAAQ,OAAO,CAAC,WAAW,CAAC,gBAAgB,IAAI,OAAO,IAAI,CAAC,IACvF,CAAA;AACJ,SAAK,kBAAkB,yCAAyC,CAAC,GAAG,aAAa,GAAG,OAAO,CAAC;AAAA,EAC9F;AAAA;AAAA,EAGA,UAAgB;AACd,6CAAyC,KAAK,eAAe;AAAA,EAC/D;AACF;AAMO,MAAM,iCAAiC,CAC5C,SACA,UAA0C,CAAA,MACF,IAAI,oCAAoC,SAAS,OAAO;"}
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { A, u, a } from "./chunks/AgentsConversationClientContext-B_UJSLXU.js";
|
|
3
|
-
import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-
|
|
4
|
-
import { P, a as a2, b, c, d, r } from "./chunks/withPollingChangeSubscription-
|
|
5
|
-
import { A as AgentsClientError, a as AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED } from "./chunks/conversation-
|
|
3
|
+
import { w as withPollingChangeSubscription } from "./chunks/withPollingChangeSubscription-Ct8kjmlL.js";
|
|
4
|
+
import { P, a as a2, b, c, d, r } from "./chunks/withPollingChangeSubscription-Ct8kjmlL.js";
|
|
5
|
+
import { A as AgentsClientError, a as AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED } from "./chunks/conversation-VosmRbsr.js";
|
|
6
6
|
import { a as acceptArrivedRealtimeMessage, c as createAgentUIClientId } from "./chunks/realtime-arrival-BfsAPwqQ.js";
|
|
7
7
|
import { c as composeAttachmentMessageText } from "./chunks/compose-attachment-message-text-FvVJbrge.js";
|
|
8
|
-
import { m as mapWireConversation, a as mapWireTraceViewPolicy, r as readWireSetElements, b as mapWireConversationRunState, c as mapWireBoundConversationSubject, d as mapWireSearchGroup, e as mapWireSearchHit, f as mapWireConversationActivity, g as mapWireTurnTraces, h as mapWireContextComposition, i as mapWireFileChangeDiff, j as mapWireConversationMessage, k as mapWireBackgroundJobStop, l as mapWireTurnStop, n as mapWireSelectableModel, o as
|
|
9
|
-
import {
|
|
8
|
+
import { m as mapWireConversation, a as mapWireTraceViewPolicy, r as readWireSetElements, b as mapWireConversationRunState, c as mapWireBoundConversationSubject, d as mapWireSearchGroup, e as mapWireSearchHit, f as mapWireConversationActivity, g as mapWireTurnTraces, h as mapWireContextComposition, i as mapWireFileChangeDiff, j as mapWireConversationMessage, k as mapWireBackgroundJobStop, l as mapWireTurnStop, n as mapWireSelectableModel, o as mapWireStepConfirmation, p as mapClientContextToWire, q as mapHttpFailureToAgentsClientError } from "./chunks/agents-http-trace-mappers-CuGZOFu-.js";
|
|
9
|
+
import { s, t, u as u2, v, w, x, y, z, A as A2 } from "./chunks/agents-http-trace-mappers-CuGZOFu-.js";
|
|
10
10
|
const AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE = 50;
|
|
11
11
|
const MESSAGES_EXPAND = "delegatedConversations(select=id,runState)";
|
|
12
12
|
const defaultBuildStartPath = (agentSpaceKey) => agentSpaceKey > 0 ? `/start/${agentSpaceKey}` : "/start";
|
|
@@ -279,6 +279,28 @@ class AgentsHttpConversationClient {
|
|
|
279
279
|
});
|
|
280
280
|
return mapWireBackgroundJobStop(response);
|
|
281
281
|
};
|
|
282
|
+
this.getStepConfirmation = async (conversationId, stepConfirmationId) => this.readStepConfirmationAnswer(
|
|
283
|
+
await this.request({
|
|
284
|
+
operation: "getStepConfirmation",
|
|
285
|
+
method: "GET",
|
|
286
|
+
path: `/${conversationId}/stepConfirmations/${stepConfirmationId}`
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
this.executeStepConfirmation = async (conversationId, stepConfirmationId, contentHash) => this.readStepConfirmationAnswer(
|
|
290
|
+
await this.request({
|
|
291
|
+
operation: "executeStepConfirmation",
|
|
292
|
+
method: "POST",
|
|
293
|
+
path: `/${conversationId}/stepConfirmations/${stepConfirmationId}/execute`,
|
|
294
|
+
body: { contentHash }
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
this.discardStepConfirmation = async (conversationId, stepConfirmationId) => this.readStepConfirmationAnswer(
|
|
298
|
+
await this.request({
|
|
299
|
+
operation: "discardStepConfirmation",
|
|
300
|
+
method: "POST",
|
|
301
|
+
path: `/${conversationId}/stepConfirmations/${stepConfirmationId}/discard`
|
|
302
|
+
})
|
|
303
|
+
);
|
|
282
304
|
this.stopTurn = async (conversationId) => {
|
|
283
305
|
const response = await this.request({ operation: "stopTurn", method: "POST", path: `/${conversationId}/stop` });
|
|
284
306
|
return mapWireTurnStop(response);
|
|
@@ -332,6 +354,12 @@ class AgentsHttpConversationClient {
|
|
|
332
354
|
skip: options.paging?.skip
|
|
333
355
|
};
|
|
334
356
|
}
|
|
357
|
+
/** The step of an answer; an answer without one is a failure of the route. */
|
|
358
|
+
readStepConfirmationAnswer(response) {
|
|
359
|
+
const stepConfirmation = mapWireStepConfirmation(response);
|
|
360
|
+
if (stepConfirmation === null) throw new AgentsClientError("other", { message: "The step confirmation answer names no step." });
|
|
361
|
+
return stepConfirmation;
|
|
362
|
+
}
|
|
335
363
|
async readMessagesPage(operation, conversationId, pageSize, filters) {
|
|
336
364
|
const response = await this.request({
|
|
337
365
|
operation,
|
|
@@ -427,7 +455,7 @@ export {
|
|
|
427
455
|
d as createPollingConversationChangeSubscription,
|
|
428
456
|
mapClientContextToWire,
|
|
429
457
|
mapHttpFailureToAgentsClientError,
|
|
430
|
-
|
|
458
|
+
s as mapWireBackgroundJob,
|
|
431
459
|
mapWireBackgroundJobStop,
|
|
432
460
|
mapWireBoundConversationSubject,
|
|
433
461
|
mapWireContextComposition,
|
|
@@ -436,19 +464,20 @@ export {
|
|
|
436
464
|
mapWireConversationMessage,
|
|
437
465
|
mapWireConversationRunState,
|
|
438
466
|
mapWireFileChangeDiff,
|
|
439
|
-
|
|
467
|
+
t as mapWireRunningBackgroundJobs,
|
|
440
468
|
mapWireSearchGroup,
|
|
441
469
|
mapWireSearchHit,
|
|
442
470
|
mapWireSelectableModel,
|
|
443
|
-
|
|
444
|
-
u2 as
|
|
445
|
-
v as
|
|
446
|
-
w as
|
|
447
|
-
x as
|
|
448
|
-
y as
|
|
471
|
+
mapWireStepConfirmation,
|
|
472
|
+
u2 as mapWireTraceBackgroundJob,
|
|
473
|
+
v as mapWireTraceFileChange,
|
|
474
|
+
w as mapWireTraceMessage,
|
|
475
|
+
x as mapWireTraceStep,
|
|
476
|
+
y as mapWireTraceTaskPlanItems,
|
|
477
|
+
z as mapWireTraceTaskPlanRejections,
|
|
449
478
|
mapWireTraceViewPolicy,
|
|
450
479
|
mapWireTurnStop,
|
|
451
|
-
|
|
480
|
+
A2 as mapWireTurnTrace,
|
|
452
481
|
mapWireTurnTraces,
|
|
453
482
|
r as readPolledRunStatus,
|
|
454
483
|
readWireSetElements,
|