@mgamadeus/ddd-agents 0.7.0 → 0.7.2
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 +9 -0
- package/dist/chat.js +1 -1
- package/dist/chunks/conversation-CbWEHPbL.js.map +1 -1
- package/dist/chunks/{withPollingChangeSubscription-mWdchMOH.js → withPollingChangeSubscription-ClyOABgu.js} +4 -1
- package/dist/chunks/{withPollingChangeSubscription-mWdchMOH.js.map → withPollingChangeSubscription-ClyOABgu.js.map} +1 -1
- package/dist/client.js +61 -6
- package/dist/client.js.map +1 -1
- package/dist/files/i18n-keys.json +49 -0
- package/dist/types/client/AgentsConversationClient.d.ts +21 -2
- package/dist/types/client/http/agents-http-mappers.d.ts +4 -2
- package/dist/types/client/http/agents-http-wire.d.ts +21 -0
- package/dist/types/contract/conversation.d.ts +29 -3
- package/dist/types/entries/voice-admin.d.ts +2 -0
- package/dist/types/ui/client-tools.d.ts +50 -1
- package/dist/types/ui/useAgentUIClient.d.ts +7 -0
- package/dist/types/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.d.ts +33 -0
- package/dist/types/voice/samples/agent-voice-sample-player.d.ts +33 -0
- package/dist/ui.js +146 -31
- package/dist/ui.js.map +1 -1
- package/dist/voice-admin.js +161 -3
- package/dist/voice-admin.js.map +1 -1
- package/package.json +1 -1
- package/public-api.json +36 -2
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../src/client/http/agents-http-mappers.ts","../src/client/http/createAgentsHttpConversationClient.ts"],"sourcesContent":["import {\n AGENTS_CLIENT_CONTEXT_LIMITS,\n AgentsClientError,\n type AgentsClientContext,\n type AgentsClientErrorKind,\n type AgentsConversation,\n type AgentsConversationMessage,\n type ConversationActivity,\n type ConversationActivityElement,\n type ConversationMessageAuthorType,\n type ConversationMessageRole,\n type ConversationMessageSearchHit,\n type ConversationMessageStatus,\n type ConversationMessageType,\n type ConversationProgressStep,\n type ConversationRunState,\n type ConversationRunStateRead,\n type ConversationSearchGroup,\n type ConversationSubAgent,\n type SelectableModel,\n} from \"../../contract/conversation\";\nimport type {\n WireActivityLine,\n WireClientContext,\n WireClientContextRouteParameter,\n WireConversation,\n WireConversationActivityResponse,\n WireConversationMessage,\n WireConversationRunStateResponse,\n WireConversationSearchGroup,\n WireCustomerProgressStep,\n WireDelegationSubAgentRecord,\n WireErrorBody,\n WireSelectableModel,\n WireSemanticSearchHit,\n WireSet,\n} from \"./agents-http-wire\";\n\n// The vocabularies of the contract: a wire value outside one maps to null.\nconst RUN_STATES: readonly ConversationRunState[] = [\n \"IDLE\",\n \"QUEUED\",\n \"RUNNING\",\n \"AWAITING_DELEGATES\",\n \"FAILED\",\n \"COMPLETED\",\n \"CANCELLED\",\n];\nconst MESSAGE_ROLES: readonly ConversationMessageRole[] = [\"SYSTEM\", \"USER\", \"ASSISTANT\"];\nconst MESSAGE_TYPES: readonly ConversationMessageType[] = [\n \"TEXT\",\n \"TOOL_CALL\",\n \"CHECKPOINT\",\n \"ERROR\",\n \"SIGNAL\",\n \"TOOL_MESSAGE\",\n];\nconst MESSAGE_STATUSES: readonly ConversationMessageStatus[] = [\n \"PENDING\",\n \"RUNNING\",\n \"CANCEL_REQUESTED\",\n \"CANCELLED\",\n \"COMPLETED\",\n \"FAILED\",\n];\nconst AUTHOR_TYPES: readonly ConversationMessageAuthorType[] = [\"USER\", \"ASSISTANT\", \"AGENT\", \"TOOL\"];\nconst PROGRESS_STEP_STATUSES: readonly ConversationProgressStep[\"status\"][] = [\"done\", \"active\", \"upcoming\"];\nconst ACTIVITY_STATES: readonly NonNullable<ConversationActivityElement[\"state\"]>[] = [\n \"queued\",\n \"running\",\n \"finished\",\n \"failed\",\n \"skipped\",\n];\nconst ACTIVITY_KINDS: readonly NonNullable<ConversationActivityElement[\"kind\"]>[] = [\n \"tool\",\n \"delegation\",\n \"background\",\n \"long\",\n \"turnStart\",\n];\n\nconst readVocabularyValue = <Value extends string>(vocabulary: readonly Value[], value: unknown): Value | null =>\n typeof value === \"string\" && (vocabulary as readonly string[]).includes(value) ? (value as Value) : null;\n\nconst readNumberOrNull = (value: unknown): number | null =>\n typeof value === \"number\" && Number.isFinite(value) ? value : null;\n\nconst readStringOrNull = (value: unknown): string | null => (typeof value === \"string\" ? value : null);\n\n/** The elements of a serialized set (`{ elements: [...] }`), a plain array, or the values of a keyed object. */\nexport const readWireSetElements = <Element>(\n wireSet: WireSet<Element> | Record<string, Element> | null | undefined,\n): Element[] => {\n if (!wireSet) return [];\n if (Array.isArray(wireSet)) return wireSet;\n if (typeof wireSet === \"object\" && \"elements\" in wireSet) {\n const elements = (wireSet as { elements?: Element[] | null }).elements;\n return Array.isArray(elements) ? elements : [];\n }\n return Object.values(wireSet as Record<string, Element>);\n};\n\nconst mapWireProgressStep = (wireStep: WireCustomerProgressStep): ConversationProgressStep => ({\n key: wireStep.key ?? \"\",\n label: wireStep.customerLabel ?? \"\",\n status: readVocabularyValue(PROGRESS_STEP_STATUSES, wireStep.status) ?? \"upcoming\",\n});\n\n/** An `AIConversation` as the contract's conversation. */\nexport const mapWireConversation = (wireConversation: WireConversation): AgentsConversation => {\n const conversation: AgentsConversation = {\n id: wireConversation.id ?? 0,\n agentSpaceKey: readNumberOrNull(wireConversation.agentSpaceId),\n runState: readVocabularyValue(RUN_STATES, wireConversation.runState),\n agentTurnOwedAt: readStringOrNull(wireConversation.agentTurnOwedAt),\n title: readStringOrNull(wireConversation.summary?.title),\n titleManuallyEdited: wireConversation.summary?.manuallyEdited === true,\n summary: readStringOrNull(wireConversation.summary?.text),\n created: readStringOrNull(wireConversation.created ?? wireConversation.changeHistory?.createdTime),\n updated: readStringOrNull(wireConversation.updated ?? wireConversation.changeHistory?.modifiedTime),\n purposeName: readStringOrNull(wireConversation.purposeName),\n initiatorType: readStringOrNull(wireConversation.initiatorType),\n scheduleId: readNumberOrNull(wireConversation.scheduleId),\n entryPointKey: readStringOrNull(wireConversation.entryPointKey),\n progressSteps: readWireSetElements(wireConversation.customerProgressSteps).map(mapWireProgressStep),\n };\n if (wireConversation.lastMessageId !== undefined) conversation.lastMessageId = readNumberOrNull(wireConversation.lastMessageId);\n if (wireConversation.aiPromptExtensionId !== undefined) {\n conversation.promptExtensionId = readNumberOrNull(wireConversation.aiPromptExtensionId);\n }\n return conversation;\n};\n\nconst mapWireSubAgent = (wireSubAgent: WireDelegationSubAgentRecord | null | undefined): ConversationSubAgent | null =>\n wireSubAgent\n ? {\n currentRunNumber: readNumberOrNull(wireSubAgent.currentRunNumber),\n runs: readWireSetElements(wireSubAgent.runs).map((wireRun) => ({\n runNumber: readNumberOrNull(wireRun.runNumber),\n status: readStringOrNull(wireRun.status),\n })),\n }\n : null;\n\n/** An `AIConversationMessage` as the contract's message. */\nexport const mapWireConversationMessage = (wireMessage: WireConversationMessage): AgentsConversationMessage => {\n const message: AgentsConversationMessage = {\n id: wireMessage.id ?? 0,\n conversationId: readNumberOrNull(wireMessage.aiConversationId),\n indexInConversation: readNumberOrNull(wireMessage.indexInConversation),\n role: readVocabularyValue(MESSAGE_ROLES, wireMessage.role),\n messageType: readVocabularyValue(MESSAGE_TYPES, wireMessage.messageType),\n status: readVocabularyValue(MESSAGE_STATUSES, wireMessage.status),\n authorType: readVocabularyValue(AUTHOR_TYPES, wireMessage.authorType),\n signalSource: readStringOrNull(wireMessage.signalSource),\n message: wireMessage.message ?? \"\",\n createdDate: readStringOrNull(wireMessage.createdDate),\n toolCall: wireMessage.toolCall\n ? {\n toolCallId: readStringOrNull(wireMessage.toolCall.toolCallId),\n name: readStringOrNull(wireMessage.toolCall.name),\n arguments: wireMessage.toolCall.arguments ?? null,\n status: readStringOrNull(wireMessage.toolCall.status),\n }\n : null,\n delegatedConversations: readWireSetElements(wireMessage.delegatedConversations).map((delegated) => ({\n id: delegated.id ?? 0,\n runState: readVocabularyValue(RUN_STATES, delegated.runState),\n })),\n subAgent: mapWireSubAgent(wireMessage.delegationResults?.subAgent),\n };\n const hasForensics =\n wireMessage.inputTokens != null || wireMessage.outputTokens != null || wireMessage.requestSnapshot != null;\n if (hasForensics) {\n message.forensics = {\n inputTokens: readNumberOrNull(wireMessage.inputTokens),\n outputTokens: readNumberOrNull(wireMessage.outputTokens),\n costInUSD: readNumberOrNull(wireMessage.costInUSD),\n requestSnapshot: wireMessage.requestSnapshot ?? null,\n };\n }\n return message;\n};\n\n/** The run-state read (`AIConversationRunStateGetResponseDto`). */\nexport const mapWireConversationRunState = (wireRunState: WireConversationRunStateResponse): ConversationRunStateRead => ({\n id: wireRunState.id ?? 0,\n runState: readVocabularyValue(RUN_STATES, wireRunState.runState),\n agentTurnOwedAt: readStringOrNull(wireRunState.agentTurnOwedAt),\n lastMessageId: readNumberOrNull(wireRunState.lastMessageId),\n title: readStringOrNull(wireRunState.title),\n titleManuallyEdited: wireRunState.titleManuallyEdited === true,\n summary: readStringOrNull(wireRunState.summary),\n updated: readStringOrNull(wireRunState.updated),\n});\n\nconst mapWireActivityLine = (wireLine: WireActivityLine): ConversationActivityElement => ({\n toolCallMessageId: wireLine.toolCallMessageId ?? 0,\n batchId: readStringOrNull(wireLine.batchId),\n state: readVocabularyValue(ACTIVITY_STATES, wireLine.state),\n kind: readVocabularyValue(ACTIVITY_KINDS, wireLine.kind),\n childCount: readNumberOrNull(wireLine.childCount),\n helperIndex: readNumberOrNull(wireLine.helperIndex),\n line: readStringOrNull(wireLine.line),\n});\n\n/** The activity of a turn (`AIConversationActivityGetResponseDto`). */\nexport const mapWireConversationActivity = (wireActivity: WireConversationActivityResponse): ConversationActivity => ({\n turnMessageId: readNumberOrNull(wireActivity.turnMessageId),\n turnRunning: wireActivity.turnRunning === true,\n elements: readWireSetElements(wireActivity.elements).map(mapWireActivityLine),\n});\n\n/** A `SemanticSearchHit`. */\nexport const mapWireSearchHit = (wireHit: WireSemanticSearchHit): ConversationMessageSearchHit => ({\n messageId: readNumberOrNull(wireHit.messageId),\n conversationId: readNumberOrNull(wireHit.conversationId),\n indexInConversation: readNumberOrNull(wireHit.indexInConversation),\n role: readStringOrNull(wireHit.role),\n excerpt: wireHit.excerpt ?? \"\",\n relevance: readNumberOrNull(wireHit.relevance) ?? 0,\n created: readStringOrNull(wireHit.created),\n updated: readStringOrNull(wireHit.updated),\n title: readStringOrNull(wireHit.title),\n});\n\n/** An `AIConversationSearchGroup`. */\nexport const mapWireSearchGroup = (wireGroup: WireConversationSearchGroup): ConversationSearchGroup => ({\n conversationId: readNumberOrNull(wireGroup.conversationId),\n title: readStringOrNull(wireGroup.title),\n summary: readStringOrNull(wireGroup.summary),\n created: readStringOrNull(wireGroup.created),\n updated: readStringOrNull(wireGroup.updated),\n relevance: readNumberOrNull(wireGroup.relevance) ?? 0,\n hits: readWireSetElements(wireGroup.hits).map(mapWireSearchHit),\n});\n\n/** An `AgentCustomerSelectableModel`. */\nexport const mapWireSelectableModel = (wireModel: WireSelectableModel): SelectableModel => ({\n name: wireModel.name ?? \"\",\n displayName: wireModel.displayName ?? wireModel.name ?? \"\",\n description: wireModel.description ?? \"\",\n strengthLevel: readNumberOrNull(wireModel.strengthLevel),\n speedLevel: readNumberOrNull(wireModel.speedLevel),\n creditsMultiplier: readNumberOrNull(wireModel.creditsMultiplier),\n});\n\n/** The stable codes of the server's refusals the chat tells apart. */\nconst ERROR_KIND_BY_CODE: Readonly<Record<string, AgentsClientErrorKind>> = {\n AI_BUDGET_REACHED: \"budget\",\n RATE_LIMIT_EXCEEDED: \"rateLimit\",\n CONVERSATION_CLOSED: \"closed\",\n};\n\n/**\n * A refused request as the port's error: the stable code first (`errorCode` of the JSON body), then the status — 429\n * `rateLimit` (with `Retry-After`), 404 `notFound`, 403 and 401 `forbidden`, 5xx `network`, everything else `other`.\n */\nexport const mapHttpFailureToAgentsClientError = (\n httpStatus: number,\n wireErrorBody: WireErrorBody | null,\n retryAfterHeader: string | null,\n): AgentsClientError => {\n const code = wireErrorBody?.errorCode ?? wireErrorBody?.code ?? null;\n const message = wireErrorBody?.error ?? wireErrorBody?.message ?? undefined;\n const retryAfterOfHeader = retryAfterHeader !== null && /^\\d+$/.test(retryAfterHeader.trim()) ? Number(retryAfterHeader) : null;\n const retryAfterSeconds = readNumberOrNull(wireErrorBody?.retryAfterSeconds) ?? retryAfterOfHeader;\n const kindOfCode = code !== null ? ERROR_KIND_BY_CODE[code] : undefined;\n const kind: AgentsClientErrorKind =\n kindOfCode ??\n (httpStatus === 429\n ? \"rateLimit\"\n : httpStatus === 404\n ? \"notFound\"\n : httpStatus === 403 || httpStatus === 401\n ? \"forbidden\"\n : httpStatus >= 500\n ? \"network\"\n : \"other\");\n return new AgentsClientError(kind, { message: message ?? undefined, code, retryAfterSeconds, httpStatus });\n};\n\n// eslint-disable-next-line no-control-regex\nconst CONTROL_CHARACTERS = /[\\u0000-\\u001f\\u007f]/;\n\n/** A text field of the client context as it goes out: trimmed, or left out when empty, over its cap or not one line. */\nconst readClientContextText = (value: string | number | null | undefined, maxChars: number): string | undefined => {\n if (value === null || value === undefined) return undefined;\n const text = String(value).trim();\n if (text === \"\" || text.length > maxChars || CONTROL_CHARACTERS.test(text)) return undefined;\n return text;\n};\n\n/**\n * The client context as the body field `clientContext` carries it (`AgentClientContext`): the route parameters as a\n * list of `{name, value}`. A field over its cap ({@link AGENTS_CLIENT_CONTEXT_LIMITS}) or with a control character is\n * left out — never cut — so a send never fails on the context; the route parameters go together or not at all.\n * Undefined when nothing is left.\n */\nexport const mapClientContextToWire = (clientContext: AgentsClientContext | null | undefined): WireClientContext | undefined => {\n if (!clientContext) return undefined;\n const wireClientContext: WireClientContext = {};\n const routePath = readClientContextText(clientContext.routePath, AGENTS_CLIENT_CONTEXT_LIMITS.routePathChars);\n if (routePath !== undefined) wireClientContext.routePath = routePath;\n const routeParameters: WireClientContextRouteParameter[] = Object.entries(clientContext.routeParameters ?? {})\n .filter(([name, value]) => name.trim() !== \"\" && value !== null && value !== undefined)\n .map(([name, value]) => ({ name, value: String(value) }));\n const routeParametersText = routeParameters.map((routeParameter) => `${routeParameter.name}=${routeParameter.value}`).join(\"&\");\n if (\n routeParameters.length > 0 &&\n routeParameters.length <= AGENTS_CLIENT_CONTEXT_LIMITS.routeParameterCount &&\n routeParametersText.length <= AGENTS_CLIENT_CONTEXT_LIMITS.routeParametersChars &&\n !CONTROL_CHARACTERS.test(routeParametersText)\n ) {\n wireClientContext.routeParameters = routeParameters;\n }\n const recordKind = readClientContextText(clientContext.recordKind, AGENTS_CLIENT_CONTEXT_LIMITS.recordKindChars);\n if (recordKind !== undefined) wireClientContext.recordKind = recordKind;\n const recordId = readClientContextText(clientContext.recordId, AGENTS_CLIENT_CONTEXT_LIMITS.recordIdChars);\n if (recordId !== undefined) wireClientContext.recordId = recordId;\n const tab = readClientContextText(clientContext.tab, AGENTS_CLIENT_CONTEXT_LIMITS.tabChars);\n if (tab !== undefined) wireClientContext.tab = tab;\n return Object.keys(wireClientContext).length > 0 ? wireClientContext : undefined;\n};\n","import type {\n AgentsConversationClient,\n AgentsConversationClientBindingOptions,\n AgentsConversationOperation,\n} from \"../AgentsConversationClient\";\nimport {\n AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED,\n AgentsClientError,\n type AgentsClientContext,\n type AgentsConversation,\n type ChangedConversationMessages,\n type ChangedMessagesRequest,\n type ConversationActivity,\n type ConversationAttachmentReference,\n type ConversationListQueryOptions,\n type ConversationMessageSearchHit,\n type ConversationMessagesPage,\n type ConversationRunStateRead,\n type ConversationSearchGroup,\n type ConversationSearchOptions,\n type ConversationSignal,\n type PostedMessage,\n type PurposeStartRequest,\n type SelectableModel,\n type StartedConversation,\n type StartedPurposeConversation,\n} from \"../../contract/conversation\";\nimport { type AgentUIState, createAgentUIClientId } from \"../../ui/agent-ui-state\";\nimport type { AgentUIClientBinding } from \"../../ui/AgentUIClient\";\nimport type { ClientToolAnswer } from \"../../ui/client-tools\";\nimport {\n acceptArrivedRealtimeMessage,\n type AgentRealtimeListenerCredential,\n type AgentRealtimeMessageDelivery,\n} from \"../../ui/realtime-arrival\";\nimport { composeAttachmentMessageText } from \"../compose-attachment-message-text\";\nimport type { PollingConversationChangeSubscriptionOptions } from \"../polling/createPollingConversationChangeSubscription\";\nimport { withPollingChangeSubscription } from \"../polling/withPollingChangeSubscription\";\nimport {\n mapClientContextToWire,\n mapHttpFailureToAgentsClientError,\n mapWireConversation,\n mapWireConversationActivity,\n mapWireConversationMessage,\n mapWireConversationRunState,\n mapWireSearchGroup,\n mapWireSearchHit,\n mapWireSelectableModel,\n readWireSetElements,\n} from \"./agents-http-mappers\";\nimport type { AccountRealtimeRead } from \"../../ui/account-realtime\";\nimport type {\n WireAccountRealtimeMessagesResponse,\n WireConversationActivityResponse,\n WireConversationMessageSearchResponse,\n WireConversationMessagesResponse,\n WireConversationResponse,\n WireConversationRunStateResponse,\n WireConversationSearchResponse,\n WireConversationsResponse,\n WireConversationStartResponse,\n WireErrorBody,\n WirePurposeStartResponse,\n WireSelectableModelsResponse,\n} from \"./agents-http-wire\";\n\n/** What every request of the binding carries from the host: headers, credentials, mode, cache. */\nexport type AgentsHttpFetchOptions = Omit<RequestInit, \"method\" | \"body\">;\n\nexport interface AgentsHttpConversationClientOptions extends AgentsConversationClientBindingOptions {\n /**\n * Where the application's conversations controller is mounted (its `#[Route]`): a path such as\n * `/api/agents/conversations` or an absolute URL. The module's routes are relative to it.\n */\n baseUrl: string;\n /**\n * Request options every request carries (credentials, an authorization header). A function is called per request,\n * so it may hand out a fresh token. Default: none (the browser's defaults: same-origin credentials).\n */\n fetchOptions?: AgentsHttpFetchOptions | (() => AgentsHttpFetchOptions | Promise<AgentsHttpFetchOptions>);\n /** The fetch function. Default: the global `fetch`. */\n fetch?: typeof fetch;\n /**\n * The application's start route below `baseUrl` (`AgentConversationStartTrait` declares none). Default: `/start` for\n * a start without an agent space (key 0), `/start/{agentSpaceKey}` otherwise — the start DTO reads `agentSpaceId`\n * from the path.\n */\n buildStartPath?: (agentSpaceKey: number) => string;\n /**\n * The controller uses `AgentSelectableModelsTrait` (`GET …/selectable-models`): the client offers\n * `getSelectableModels` and the chat shows the model picker. Default false.\n */\n hasSelectableModelsRoute?: boolean;\n /**\n * The live updates: the polling default over the run-state read (`withPollingChangeSubscription`), which also reads\n * at once after a post, a signal or a retry the server accepted. The intervals of\n * `PollingConversationChangeSubscriptionOptions`; `false` = no subscription (the host adds its own push transport).\n * Default: polling with the default intervals.\n */\n polling?: PollingConversationChangeSubscriptionOptions | false;\n /**\n * What the owner's client shows, read on every start, posted message and injected signal and sent as the body field\n * `clientContext` (the route, its parameters, the record on screen, the tab). The agent reads the newest one as one\n * line beside the owner's newest message. A field over its cap is left out, never cut. Default: none.\n */\n clientContext?: (operation: AgentsClientContextOperation) => AgentsClientContext | null | undefined;\n /**\n * The UI side of `Agent.UI` (`AgentUIClient` of `@mgamadeus/ddd-agents/ui`): its client id and UI state ride on every\n * write and every run-state read; a client tool request the run-state read delivers goes to it, and the binding\n * posts its answer (`POST /{conversationId}/clientToolRequests/{requestId}/answer`). Default: none; the account\n * read alone then states a client id the binding creates once (`getAccountRealtimeMessages`).\n */\n uiClient?: AgentUIClientBinding;\n /**\n * The open messages of the realtime port of other types than a client tool request (types other packages\n * registered), as the run-state read delivers them; a client acts on one type and key once. Default: none.\n */\n onRealtimeMessage?: (conversationId: number, message: AgentRealtimeMessageDelivery) => void;\n /** What the client needs to listen on the host's transport, with every run-state read (null without one). Default: none. */\n onRealtimeListenerCredential?: (conversationId: number, credential: AgentRealtimeListenerCredential | null) => void;\n}\n\n/** The writes that carry the client context. */\nexport type AgentsClientContextOperation = \"startConversation\" | \"postMessage\" | \"injectSignal\";\n\n/** The page size of a changed-messages read when the request names none (as the chat sends it). */\nexport const AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE = 50;\n\n/** The expand of every message page: the delegated children with the two fields the chat reads. */\nconst MESSAGES_EXPAND = \"delegatedConversations(select=id,runState)\";\n\nconst defaultBuildStartPath = (agentSpaceKey: number): string => (agentSpaceKey > 0 ? `/start/${agentSpaceKey}` : \"/start\");\n\ntype QueryParameters = Record<string, string | number | boolean | undefined | null>;\n\ninterface HttpRequest {\n operation: AgentsConversationOperation;\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\n path: string;\n query?: QueryParameters;\n body?: unknown;\n}\n\n/** A filter value as the query-options grammar writes it: quoted. */\nconst quoteFilterValue = (value: number | string): string => `'${String(value).replace(/'/g, \"\\\\'\")}'`;\n\n/** The module's conversation routes over fetch: one request per port function, the wire mapped onto the contract. */\nclass AgentsHttpConversationClient implements AgentsConversationClient {\n readonly getSelectableModels?: () => Promise<SelectableModel[]>;\n\n /** The client id this client created for its account read (no `uiClient` bound): once, kept while it lives. */\n protected ownAccountReadClientId: string | undefined;\n\n constructor(protected readonly options: AgentsHttpConversationClientOptions) {\n if (options.hasSelectableModelsRoute) this.getSelectableModels = this.readSelectableModels;\n }\n\n // ── Reads ─────────────────────────────────────────────────────────────────────────────────────────────────────\n\n getConversationMetadata = async (conversationId: number): Promise<AgentsConversation> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"getConversationMetadata\",\n method: \"GET\",\n path: `/${conversationId}`,\n });\n return mapWireConversation(response.aiConversation ?? {});\n };\n\n getConversationRunState = async (conversationId: number): Promise<ConversationRunStateRead> => {\n const uiClient = this.options.uiClient;\n const uiState = uiClient?.readUIState() ?? null;\n const response = await this.request<WireConversationRunStateResponse>({\n operation: \"getConversationRunState\",\n method: \"GET\",\n path: `/${conversationId}/runState`,\n query: uiClient ? { clientId: uiClient.clientId, uiStateJson: uiState ? JSON.stringify(uiState) : undefined } : undefined,\n });\n const sendAnswer = (requestId: number, answer: ClientToolAnswer): Promise<void> =>\n this.answerClientToolRequest(conversationId, requestId, answer);\n if (uiClient && response.clientToolRequest) {\n uiClient.acceptClientToolRequest(conversationId, response.clientToolRequest, sendAnswer);\n }\n for (const message of readWireSetElements(response.realtimeMessages)) {\n if (uiClient) acceptArrivedRealtimeMessage(conversationId, message, uiClient, sendAnswer, this.options.onRealtimeMessage);\n else this.options.onRealtimeMessage?.(conversationId, message);\n }\n this.options.onRealtimeListenerCredential?.(conversationId, response.realtimeListenerCredential ?? null);\n return mapWireConversationRunState(response);\n };\n\n /**\n * The account-level realtime read (`GET /realtimeMessages?clientId=…`): the messages addressed to the signed-in\n * account for this client and the listener credential without a conversation. It always states a client id\n * (`resolveAccountReadClientId`), so the server knows a client that only polls. Arrival is the caller's\n * (`createAccountRealtimePoll` of `/ui`).\n *\n * @param clientId the client id the caller wants stated (the `clientId` option of the poll)\n */\n getAccountRealtimeMessages = async (clientId?: string): Promise<AccountRealtimeRead> => {\n const response = await this.request<WireAccountRealtimeMessagesResponse>({\n operation: \"getAccountRealtimeMessages\",\n method: \"GET\",\n path: \"/realtimeMessages\",\n query: { clientId: this.resolveAccountReadClientId(clientId) },\n });\n return {\n messages: readWireSetElements(response.realtimeMessages),\n listenerCredential: response.realtimeListenerCredential ?? null,\n };\n };\n\n /**\n * The client id the account read states, decided here and nowhere else: the caller's, else the bound `uiClient`'s,\n * else one this client creates once and keeps while it lives. Only the account read asks: every other request\n * states a client id only with a `uiClient`.\n */\n protected resolveAccountReadClientId(clientId: string | undefined): string {\n if (clientId) return clientId;\n if (this.options.uiClient) return this.options.uiClient.clientId;\n this.ownAccountReadClientId ??= createAgentUIClientId();\n return this.ownAccountReadClientId;\n }\n\n /** Posts the answer of the UI client to a client tool request (`Agent.UI`); a refused answer is the server's word. */\n answerClientToolRequest = async (conversationId: number, requestId: number, answer: ClientToolAnswer): Promise<void> => {\n await this.request<unknown>({\n operation: \"answerClientToolRequest\",\n method: \"POST\",\n path: `/${conversationId}/clientToolRequests/${requestId}/answer`,\n body: {\n clientId: this.options.uiClient?.clientId ?? \"\",\n outcome: answer.outcome,\n text: answer.text,\n detailsJson: JSON.stringify(answer.details ?? {}),\n pictureBase64: answer.pictureBase64,\n uiStateJson: this.readUIStateJsonAfterAnswer(),\n },\n });\n };\n\n /** What the UI shows after the request was carried out, so the server's `[SIGNAL:ui]` note is current at once. */\n protected readUIStateJsonAfterAnswer(): string | undefined {\n const uiState: AgentUIState | null = this.options.uiClient?.readUIState() ?? null;\n return uiState ? JSON.stringify(uiState) : undefined;\n }\n\n getNewestMessagesPage = (conversationId: number, pageSize: number): Promise<ConversationMessagesPage> =>\n this.readMessagesPage(\"getNewestMessagesPage\", conversationId, pageSize, undefined);\n\n getOlderMessagesPage = (conversationId: number, beforeIndex: number, pageSize: number): Promise<ConversationMessagesPage> =>\n this.readMessagesPage(\n \"getOlderMessagesPage\",\n conversationId,\n pageSize,\n `indexInConversation lt ${quoteFilterValue(beforeIndex)}`,\n );\n\n getChangedMessages = async (\n conversationId: number,\n request: ChangedMessagesRequest,\n ): Promise<ChangedConversationMessages> => {\n const page = await this.readMessagesPage(\n \"getChangedMessages\",\n conversationId,\n request.pageSize ?? AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE,\n `(id gt ${quoteFilterValue(request.highestKnownId)} or indexInConversation ge ${quoteFilterValue(request.fromIndex)})`,\n );\n return { messages: page.messages };\n };\n\n listConversations = async (agentSpaceKey: number, options: ConversationListQueryOptions = {}): Promise<AgentsConversation[]> => {\n const filters = [\"rootConversationId eq null\"];\n if (agentSpaceKey > 0) filters.push(`agentSpaceId eq ${quoteFilterValue(agentSpaceKey)}`);\n const response = await this.request<WireConversationsResponse>({\n operation: \"listConversations\",\n method: \"GET\",\n path: \"/listAllConversations\",\n query: {\n filters: filters.join(\" and \"),\n orderBy: \"id desc\",\n top: options.paging?.top,\n skip: options.paging?.skip,\n },\n });\n const conversations = readWireSetElements(response.aiConversations).map(mapWireConversation);\n // Without a summary there is no title yet; the list leaves such a conversation out unless asked for it.\n return options.includeUnsummarized ? conversations : conversations.filter((conversation) => conversation.title !== null);\n };\n\n searchConversations = async (text: string, options: ConversationSearchOptions = {}): Promise<ConversationSearchGroup[]> => {\n const response = await this.request<WireConversationSearchResponse>({\n operation: \"searchConversations\",\n method: \"GET\",\n path: \"/search\",\n query: { query: text, limit: options.limit, excerptChars: options.excerptLength },\n });\n return readWireSetElements(response.conversations).map(mapWireSearchGroup);\n };\n\n searchConversationMessages = async (\n conversationId: number,\n text: string,\n options: ConversationSearchOptions = {},\n ): Promise<ConversationMessageSearchHit[]> => {\n const response = await this.request<WireConversationMessageSearchResponse>({\n operation: \"searchConversationMessages\",\n method: \"GET\",\n path: `/${conversationId}/messages/search`,\n query: { query: text, limit: options.limit, excerptChars: options.excerptLength },\n });\n return readWireSetElements(response.hits).map(mapWireSearchHit);\n };\n\n getConversationActivity = async (conversationId: number, turnMessageId?: number | null): Promise<ConversationActivity> => {\n const response = await this.request<WireConversationActivityResponse>({\n operation: \"getConversationActivity\",\n method: \"GET\",\n path: `/${conversationId}/activity`,\n query: { turnMessageId: turnMessageId ?? undefined },\n });\n return mapWireConversationActivity(response);\n };\n\n composeSentMessageText = (text: string, attachments: ConversationAttachmentReference[] | undefined): string =>\n composeAttachmentMessageText(text, attachments);\n\n // ── Writes ────────────────────────────────────────────────────────────────────────────────────────────────────\n\n startConversation = async (request: Parameters<AgentsConversationClient[\"startConversation\"]>[0]): Promise<StartedConversation> => {\n const buildStartPath = this.options.buildStartPath ?? defaultBuildStartPath;\n const response = await this.request<WireConversationStartResponse>({\n operation: \"startConversation\",\n method: \"POST\",\n path: buildStartPath(request.agentSpaceKey),\n query: { aiModelName: request.model },\n body: {\n aiConversationMessage: { message: composeAttachmentMessageText(request.text, request.attachments) },\n ...(request.startSignalText ? { signalText: request.startSignalText } : {}),\n ...(request.entryPointKey ? { entryPointKey: request.entryPointKey } : {}),\n ...this.readClientContextBody(\"startConversation\"),\n },\n });\n const wireConversation = response.aiConversation ?? {};\n const reopenedExisting = response.reopenedExistingConversation === true;\n return {\n conversation: mapWireConversation(wireConversation),\n messages: reopenedExisting ? [] : readWireSetElements(wireConversation.messages).map(mapWireConversationMessage),\n reopenedExisting,\n };\n };\n\n startPurpose = async (request: PurposeStartRequest): Promise<StartedPurposeConversation> => {\n const response = await this.request<WirePurposeStartResponse>({\n operation: \"startPurpose\",\n method: \"POST\",\n path: \"/startPurpose\",\n body: {\n purposeId: request.purposeId,\n ...(request.agentSpaceKey ? { agentSpaceId: request.agentSpaceKey } : {}),\n ...(request.subject\n ? { subject: { subjectEntityClass: request.subject.entityClass, subjectEntityId: request.subject.entityId } }\n : {}),\n ...(request.prefill ? { prefill: request.prefill } : {}),\n },\n });\n const conversationId = Number(response.aiConversationId ?? 0);\n if (!Number.isInteger(conversationId) || conversationId < 1) {\n throw new AgentsClientError(\"other\", { message: \"The purposed start answered no conversation id.\" });\n }\n return {\n conversationId,\n resumedExisting: response.resumedExistingConversation === true,\n prefillDelivered: response.prefillDelivered === true,\n };\n };\n\n postMessage = async (\n conversationId: number,\n message: { text: string; model?: string; attachments?: ConversationAttachmentReference[] },\n ): Promise<PostedMessage> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"postMessage\",\n method: \"POST\",\n path: `/${conversationId}/postMessage`,\n query: { aiModelName: message.model },\n body: {\n aiConversationMessage: { message: composeAttachmentMessageText(message.text, message.attachments) },\n ...this.readClientContextBody(\"postMessage\"),\n },\n });\n return { messages: readWireSetElements(response.aiConversation?.messages).map(mapWireConversationMessage) };\n };\n\n injectSignal = async (conversationId: number, signal: ConversationSignal): Promise<void> => {\n await this.request<WireConversationResponse>({\n operation: \"injectSignal\",\n method: \"POST\",\n path: `/${conversationId}/injectSignal`,\n body: {\n signalText: signal.text,\n ...(signal.source ? { signalSource: signal.source } : {}),\n ...this.readClientContextBody(\"injectSignal\"),\n },\n });\n };\n\n retryConversation = async (conversationId: number): Promise<void> => {\n await this.request<WireConversationResponse>({\n operation: \"retryConversation\",\n method: \"POST\",\n path: `/${conversationId}/retry`,\n });\n };\n\n renameConversation = async (conversationId: number, title: string): Promise<AgentsConversation> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"renameConversation\",\n method: \"PATCH\",\n path: `/${conversationId}/title`,\n body: { title },\n });\n return mapWireConversation(response.aiConversation ?? {});\n };\n\n deleteConversation = async (conversationId: number): Promise<void> => {\n await this.request<unknown>({ operation: \"deleteConversation\", method: \"DELETE\", path: `/${conversationId}` });\n };\n\n // ── Transport ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n protected readSelectableModels = async (): Promise<SelectableModel[]> => {\n const response = await this.request<WireSelectableModelsResponse>({\n operation: \"getSelectableModels\",\n method: \"GET\",\n path: \"/selectable-models\",\n });\n return readWireSetElements(response.models).map(mapWireSelectableModel);\n };\n\n protected async readMessagesPage(\n operation: AgentsConversationOperation,\n conversationId: number,\n pageSize: number,\n filters: string | undefined,\n ): Promise<ConversationMessagesPage> {\n const response = await this.request<WireConversationMessagesResponse>({\n operation,\n method: \"GET\",\n path: `/${conversationId}/messages`,\n query: { filters, orderBy: \"indexInConversation desc\", top: pageSize, expand: MESSAGES_EXPAND },\n });\n return {\n messages: readWireSetElements(response.messages).map(mapWireConversationMessage),\n hasMoreOlder: response.hasMoreOlder === true,\n };\n }\n\n /** The body field `clientContext` of a write, from the host's option; nothing when it gives none. */\n protected readClientContextBody(operation: AgentsClientContextOperation): {\n clientContext?: ReturnType<typeof mapClientContextToWire>;\n clientId?: string;\n uiState?: AgentUIState;\n } {\n const wireClientContext = mapClientContextToWire(this.options.clientContext?.(operation));\n const uiClient = this.options.uiClient;\n const uiState = uiClient?.readUIState() ?? null;\n return {\n ...(wireClientContext ? { clientContext: wireClientContext } : {}),\n ...(uiClient ? { clientId: uiClient.clientId } : {}),\n ...(uiState ? { uiState } : {}),\n };\n }\n\n /** The URL of a route: the base, the path, the binding's query parameters with the host's extra ones over them. */\n protected buildUrl(request: HttpRequest): string {\n const searchParameters = new URLSearchParams();\n const extraParameters = this.options.extraRequestParameters?.(request.operation) ?? {};\n for (const [name, value] of Object.entries({ ...request.query, ...extraParameters })) {\n if (value !== undefined && value !== null) searchParameters.set(name, String(value));\n }\n const query = searchParameters.toString();\n const baseUrl = this.options.baseUrl.replace(/\\/+$/, \"\");\n return `${baseUrl}${request.path}${query ? `?${query}` : \"\"}`;\n }\n\n protected async readFetchOptions(): Promise<AgentsHttpFetchOptions> {\n const { fetchOptions } = this.options;\n return typeof fetchOptions === \"function\" ? await fetchOptions() : (fetchOptions ?? {});\n }\n\n /** One request; every failure becomes an `AgentsClientError` (the port's one error shape). */\n protected async request<ResponseBody>(request: HttpRequest): Promise<ResponseBody> {\n const fetchFunction = this.options.fetch ?? globalThis.fetch.bind(globalThis);\n let response: Response;\n try {\n const fetchOptions = await this.readFetchOptions();\n const headers = new Headers(fetchOptions.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n if (request.body !== undefined && !headers.has(\"Content-Type\")) headers.set(\"Content-Type\", \"application/json\");\n response = await fetchFunction(this.buildUrl(request), {\n ...fetchOptions,\n headers,\n method: request.method,\n body: request.body === undefined ? undefined : JSON.stringify(request.body),\n });\n } catch (failure) {\n if (failure instanceof AgentsClientError) throw failure;\n const isAbort = failure instanceof Error && failure.name === \"AbortError\";\n throw isAbort\n ? new AgentsClientError(\"other\", { code: AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED, message: \"The request was cancelled.\" })\n : new AgentsClientError(\"network\", { message: failure instanceof Error ? failure.message : \"The request failed.\" });\n }\n const responseText = await response.text().catch(() => \"\");\n const responseBody = readJsonBody(responseText);\n if (!response.ok) {\n throw mapHttpFailureToAgentsClientError(\n response.status,\n isPlainObject(responseBody) ? (responseBody as WireErrorBody) : null,\n response.headers.get(\"Retry-After\"),\n );\n }\n return (responseBody ?? {}) as ResponseBody;\n }\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst readJsonBody = (text: string): unknown => {\n if (text.trim() === \"\") return null;\n try {\n return JSON.parse(text);\n } catch {\n return null;\n }\n};\n\n/**\n * The conversation client over the module's own conversation routes (`AgentConversationReadsTrait`,\n * `AgentConversationWritesTrait`, the application's start route of `AgentConversationStartTrait`, optionally\n * `AgentSelectableModelsTrait`): `baseUrl` is where the application mounted its conversations controller, `fetchOptions`\n * what every request carries. Every function rejects with `AgentsClientError`. The client comes with live updates —\n * the polling default over the run-state read, which also reads at once after an accepted send — unless `polling` is\n * `false`.\n *\n * ```ts\n * const client = createAgentsHttpConversationClient({\n * baseUrl: \"/api/agents/conversations\",\n * fetchOptions: () => ({ headers: { Authorization: `Bearer ${readToken()}` } }),\n * });\n * <AgentsProvider client={client}><AgentChat /></AgentsProvider>\n * ```\n */\nexport const createAgentsHttpConversationClient = (options: AgentsHttpConversationClientOptions): AgentsConversationClient => {\n const client = new AgentsHttpConversationClient(options);\n return options.polling === false ? client : withPollingChangeSubscription(client, options.polling);\n};\n"],"names":["options"],"mappings":";;;;;;;AAuCA,MAAM,aAA8C;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,gBAAoD,CAAC,UAAU,QAAQ,WAAW;AACxF,MAAM,gBAAoD;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,mBAAyD;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,eAAyD,CAAC,QAAQ,aAAa,SAAS,MAAM;AACpG,MAAM,yBAAwE,CAAC,QAAQ,UAAU,UAAU;AAC3G,MAAM,kBAAgF;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,iBAA8E;AAAA,EAClF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,sBAAsB,CAAuB,YAA8B,UAC/E,OAAO,UAAU,YAAa,WAAiC,SAAS,KAAK,IAAK,QAAkB;AAEtG,MAAM,mBAAmB,CAAC,UACxB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AAEhE,MAAM,mBAAmB,CAAC,UAAmC,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,EAAE,MAAM,0CAA0C,SAAS,6BAAA,CAA8B,IACxH,IAAI,kBAAkB,WAAW,EAAE,SAAS,mBAAmB,QAAQ,QAAQ,UAAU,uBAAuB;AAAA,IACtH;AACA,UAAM,eAAe,MAAM,SAAS,OAAO,MAAM,MAAM,EAAE;AACzD,UAAM,eAAe,aAAa,YAAY;AAC9C,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM;AAAA,QACJ,SAAS;AAAA,QACT,cAAc,YAAY,IAAK,eAAiC;AAAA,QAChE,SAAS,QAAQ,IAAI,aAAa;AAAA,MAAA;AAAA,IAEtC;AACA,WAAQ,gBAAgB,CAAA;AAAA,EAC1B;AACF;AAEA,MAAM,gBAAgB,CAAC,UACrB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAErE,MAAM,eAAe,CAAC,SAA0B;AAC9C,MAAI,KAAK,WAAW,GAAI,QAAO;AAC/B,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAkBO,MAAM,qCAAqC,CAAC,YAA2E;AAC5H,QAAM,SAAS,IAAI,6BAA6B,OAAO;AACvD,SAAO,QAAQ,YAAY,QAAQ,SAAS,8BAA8B,QAAQ,QAAQ,OAAO;AACnG;"}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../src/client/http/agents-http-mappers.ts","../src/client/http/createAgentsHttpConversationClient.ts"],"sourcesContent":["import {\n AGENTS_CLIENT_CONTEXT_LIMITS,\n AgentsClientError,\n type AgentsClientContext,\n type AgentsClientErrorKind,\n type AgentsConversation,\n type AgentsConversationMessage,\n type BoundConversationSubject,\n type ConversationActivity,\n type ConversationActivityElement,\n type ConversationMessageAuthorType,\n type ConversationMessageRole,\n type ConversationMessageSearchHit,\n type ConversationMessageStatus,\n type ConversationMessageType,\n type ConversationProgressStep,\n type ConversationRunState,\n type ConversationRunStateRead,\n type ConversationSearchGroup,\n type ConversationSubAgent,\n type SelectableModel,\n} from \"../../contract/conversation\";\nimport type {\n WireActivityLine,\n WireBoundConversationSubject,\n WireClientContext,\n WireClientContextRouteParameter,\n WireConversation,\n WireConversationActivityResponse,\n WireConversationMessage,\n WireConversationRunStateResponse,\n WireConversationSearchGroup,\n WireCustomerProgressStep,\n WireDelegationSubAgentRecord,\n WireErrorBody,\n WireSelectableModel,\n WireSemanticSearchHit,\n WireSet,\n} from \"./agents-http-wire\";\n\n// The vocabularies of the contract: a wire value outside one maps to null.\nconst RUN_STATES: readonly ConversationRunState[] = [\n \"IDLE\",\n \"QUEUED\",\n \"RUNNING\",\n \"AWAITING_DELEGATES\",\n \"FAILED\",\n \"COMPLETED\",\n \"CANCELLED\",\n];\nconst MESSAGE_ROLES: readonly ConversationMessageRole[] = [\"SYSTEM\", \"USER\", \"ASSISTANT\"];\nconst MESSAGE_TYPES: readonly ConversationMessageType[] = [\n \"TEXT\",\n \"TOOL_CALL\",\n \"CHECKPOINT\",\n \"ERROR\",\n \"SIGNAL\",\n \"TOOL_MESSAGE\",\n];\nconst MESSAGE_STATUSES: readonly ConversationMessageStatus[] = [\n \"PENDING\",\n \"RUNNING\",\n \"CANCEL_REQUESTED\",\n \"CANCELLED\",\n \"COMPLETED\",\n \"FAILED\",\n];\nconst AUTHOR_TYPES: readonly ConversationMessageAuthorType[] = [\"USER\", \"ASSISTANT\", \"AGENT\", \"TOOL\"];\nconst PROGRESS_STEP_STATUSES: readonly ConversationProgressStep[\"status\"][] = [\"done\", \"active\", \"upcoming\"];\nconst ACTIVITY_STATES: readonly NonNullable<ConversationActivityElement[\"state\"]>[] = [\n \"queued\",\n \"running\",\n \"finished\",\n \"failed\",\n \"skipped\",\n];\nconst ACTIVITY_KINDS: readonly NonNullable<ConversationActivityElement[\"kind\"]>[] = [\n \"tool\",\n \"delegation\",\n \"background\",\n \"long\",\n \"turnStart\",\n];\n\nconst readVocabularyValue = <Value extends string>(vocabulary: readonly Value[], value: unknown): Value | null =>\n typeof value === \"string\" && (vocabulary as readonly string[]).includes(value) ? (value as Value) : null;\n\nconst readNumberOrNull = (value: unknown): number | null =>\n typeof value === \"number\" && Number.isFinite(value) ? value : null;\n\nconst readStringOrNull = (value: unknown): string | null => (typeof value === \"string\" ? value : null);\n\n/** The elements of a serialized set (`{ elements: [...] }`), a plain array, or the values of a keyed object. */\nexport const readWireSetElements = <Element>(\n wireSet: WireSet<Element> | Record<string, Element> | null | undefined,\n): Element[] => {\n if (!wireSet) return [];\n if (Array.isArray(wireSet)) return wireSet;\n if (typeof wireSet === \"object\" && \"elements\" in wireSet) {\n const elements = (wireSet as { elements?: Element[] | null }).elements;\n return Array.isArray(elements) ? elements : [];\n }\n return Object.values(wireSet as Record<string, Element>);\n};\n\nconst mapWireProgressStep = (wireStep: WireCustomerProgressStep): ConversationProgressStep => ({\n key: wireStep.key ?? \"\",\n label: wireStep.customerLabel ?? \"\",\n status: readVocabularyValue(PROGRESS_STEP_STATUSES, wireStep.status) ?? \"upcoming\",\n});\n\n/** An `AIConversation` as the contract's conversation. */\nexport const mapWireConversation = (wireConversation: WireConversation): AgentsConversation => {\n const conversation: AgentsConversation = {\n id: wireConversation.id ?? 0,\n agentSpaceKey: readNumberOrNull(wireConversation.agentSpaceId),\n runState: readVocabularyValue(RUN_STATES, wireConversation.runState),\n agentTurnOwedAt: readStringOrNull(wireConversation.agentTurnOwedAt),\n title: readStringOrNull(wireConversation.summary?.title),\n titleManuallyEdited: wireConversation.summary?.manuallyEdited === true,\n summary: readStringOrNull(wireConversation.summary?.text),\n created: readStringOrNull(wireConversation.created ?? wireConversation.changeHistory?.createdTime),\n updated: readStringOrNull(wireConversation.updated ?? wireConversation.changeHistory?.modifiedTime),\n purposeName: readStringOrNull(wireConversation.purposeName),\n initiatorType: readStringOrNull(wireConversation.initiatorType),\n scheduleId: readNumberOrNull(wireConversation.scheduleId),\n entryPointKey: readStringOrNull(wireConversation.entryPointKey),\n progressSteps: readWireSetElements(wireConversation.customerProgressSteps).map(mapWireProgressStep),\n };\n if (wireConversation.lastMessageId !== undefined) conversation.lastMessageId = readNumberOrNull(wireConversation.lastMessageId);\n if (wireConversation.aiPromptExtensionId !== undefined) {\n conversation.promptExtensionId = readNumberOrNull(wireConversation.aiPromptExtensionId);\n }\n return conversation;\n};\n\nconst mapWireSubAgent = (wireSubAgent: WireDelegationSubAgentRecord | null | undefined): ConversationSubAgent | null =>\n wireSubAgent\n ? {\n currentRunNumber: readNumberOrNull(wireSubAgent.currentRunNumber),\n runs: readWireSetElements(wireSubAgent.runs).map((wireRun) => ({\n runNumber: readNumberOrNull(wireRun.runNumber),\n status: readStringOrNull(wireRun.status),\n })),\n }\n : null;\n\n/** An `AIConversationMessage` as the contract's message. */\nexport const mapWireConversationMessage = (wireMessage: WireConversationMessage): AgentsConversationMessage => {\n const message: AgentsConversationMessage = {\n id: wireMessage.id ?? 0,\n conversationId: readNumberOrNull(wireMessage.aiConversationId),\n indexInConversation: readNumberOrNull(wireMessage.indexInConversation),\n role: readVocabularyValue(MESSAGE_ROLES, wireMessage.role),\n messageType: readVocabularyValue(MESSAGE_TYPES, wireMessage.messageType),\n status: readVocabularyValue(MESSAGE_STATUSES, wireMessage.status),\n authorType: readVocabularyValue(AUTHOR_TYPES, wireMessage.authorType),\n signalSource: readStringOrNull(wireMessage.signalSource),\n message: wireMessage.message ?? \"\",\n createdDate: readStringOrNull(wireMessage.createdDate),\n toolCall: wireMessage.toolCall\n ? {\n toolCallId: readStringOrNull(wireMessage.toolCall.toolCallId),\n name: readStringOrNull(wireMessage.toolCall.name),\n arguments: wireMessage.toolCall.arguments ?? null,\n status: readStringOrNull(wireMessage.toolCall.status),\n }\n : null,\n delegatedConversations: readWireSetElements(wireMessage.delegatedConversations).map((delegated) => ({\n id: delegated.id ?? 0,\n runState: readVocabularyValue(RUN_STATES, delegated.runState),\n })),\n subAgent: mapWireSubAgent(wireMessage.delegationResults?.subAgent),\n };\n const hasForensics =\n wireMessage.inputTokens != null || wireMessage.outputTokens != null || wireMessage.requestSnapshot != null;\n if (hasForensics) {\n message.forensics = {\n inputTokens: readNumberOrNull(wireMessage.inputTokens),\n outputTokens: readNumberOrNull(wireMessage.outputTokens),\n costInUSD: readNumberOrNull(wireMessage.costInUSD),\n requestSnapshot: wireMessage.requestSnapshot ?? null,\n };\n }\n return message;\n};\n\n/** The run-state read (`AIConversationRunStateGetResponseDto`). */\nexport const mapWireConversationRunState = (wireRunState: WireConversationRunStateResponse): ConversationRunStateRead => ({\n id: wireRunState.id ?? 0,\n runState: readVocabularyValue(RUN_STATES, wireRunState.runState),\n agentTurnOwedAt: readStringOrNull(wireRunState.agentTurnOwedAt),\n lastMessageId: readNumberOrNull(wireRunState.lastMessageId),\n title: readStringOrNull(wireRunState.title),\n titleManuallyEdited: wireRunState.titleManuallyEdited === true,\n summary: readStringOrNull(wireRunState.summary),\n updated: readStringOrNull(wireRunState.updated),\n});\n\nconst mapWireActivityLine = (wireLine: WireActivityLine): ConversationActivityElement => ({\n toolCallMessageId: wireLine.toolCallMessageId ?? 0,\n batchId: readStringOrNull(wireLine.batchId),\n state: readVocabularyValue(ACTIVITY_STATES, wireLine.state),\n kind: readVocabularyValue(ACTIVITY_KINDS, wireLine.kind),\n childCount: readNumberOrNull(wireLine.childCount),\n helperIndex: readNumberOrNull(wireLine.helperIndex),\n line: readStringOrNull(wireLine.line),\n});\n\n/** The activity of a turn (`AIConversationActivityGetResponseDto`). */\nexport const mapWireConversationActivity = (wireActivity: WireConversationActivityResponse): ConversationActivity => ({\n turnMessageId: readNumberOrNull(wireActivity.turnMessageId),\n turnRunning: wireActivity.turnRunning === true,\n elements: readWireSetElements(wireActivity.elements).map(mapWireActivityLine),\n});\n\n/** A `SemanticSearchHit`. */\nexport const mapWireSearchHit = (wireHit: WireSemanticSearchHit): ConversationMessageSearchHit => ({\n messageId: readNumberOrNull(wireHit.messageId),\n conversationId: readNumberOrNull(wireHit.conversationId),\n indexInConversation: readNumberOrNull(wireHit.indexInConversation),\n role: readStringOrNull(wireHit.role),\n excerpt: wireHit.excerpt ?? \"\",\n relevance: readNumberOrNull(wireHit.relevance) ?? 0,\n created: readStringOrNull(wireHit.created),\n updated: readStringOrNull(wireHit.updated),\n title: readStringOrNull(wireHit.title),\n});\n\n/** An `AIConversationSearchGroup`. */\nexport const mapWireSearchGroup = (wireGroup: WireConversationSearchGroup): ConversationSearchGroup => ({\n conversationId: readNumberOrNull(wireGroup.conversationId),\n title: readStringOrNull(wireGroup.title),\n summary: readStringOrNull(wireGroup.summary),\n created: readStringOrNull(wireGroup.created),\n updated: readStringOrNull(wireGroup.updated),\n relevance: readNumberOrNull(wireGroup.relevance) ?? 0,\n hits: readWireSetElements(wireGroup.hits).map(mapWireSearchHit),\n});\n\n/** An `AgentCustomerSelectableModel`. */\nexport const mapWireSelectableModel = (wireModel: WireSelectableModel): SelectableModel => ({\n name: wireModel.name ?? \"\",\n displayName: wireModel.displayName ?? wireModel.name ?? \"\",\n description: wireModel.description ?? \"\",\n strengthLevel: readNumberOrNull(wireModel.strengthLevel),\n speedLevel: readNumberOrNull(wireModel.speedLevel),\n creditsMultiplier: readNumberOrNull(wireModel.creditsMultiplier),\n});\n\n/** The stable codes of the server's refusals the chat tells apart. */\nconst ERROR_KIND_BY_CODE: Readonly<Record<string, AgentsClientErrorKind>> = {\n AI_BUDGET_REACHED: \"budget\",\n RATE_LIMIT_EXCEEDED: \"rateLimit\",\n CONVERSATION_CLOSED: \"closed\",\n};\n\n/**\n * A refused request as the port's error: the stable code first (`errorCode` of the JSON body), then the status — 429\n * `rateLimit` (with `Retry-After`), 404 `notFound`, 403 and 401 `forbidden`, 5xx `network`, everything else `other`.\n */\nexport const mapHttpFailureToAgentsClientError = (\n httpStatus: number,\n wireErrorBody: WireErrorBody | null,\n retryAfterHeader: string | null,\n): AgentsClientError => {\n const code = wireErrorBody?.errorCode ?? wireErrorBody?.code ?? null;\n const message = wireErrorBody?.error ?? wireErrorBody?.message ?? undefined;\n const retryAfterOfHeader = retryAfterHeader !== null && /^\\d+$/.test(retryAfterHeader.trim()) ? Number(retryAfterHeader) : null;\n const retryAfterSeconds = readNumberOrNull(wireErrorBody?.retryAfterSeconds) ?? retryAfterOfHeader;\n const kindOfCode = code !== null ? ERROR_KIND_BY_CODE[code] : undefined;\n const kind: AgentsClientErrorKind =\n kindOfCode ??\n (httpStatus === 429\n ? \"rateLimit\"\n : httpStatus === 404\n ? \"notFound\"\n : httpStatus === 403 || httpStatus === 401\n ? \"forbidden\"\n : httpStatus >= 500\n ? \"network\"\n : \"other\");\n return new AgentsClientError(kind, { message: message ?? undefined, code, retryAfterSeconds, httpStatus });\n};\n\n// eslint-disable-next-line no-control-regex\nconst CONTROL_CHARACTERS = /[\\u0000-\\u001f\\u007f]/;\n\n/** A text field of the client context as it goes out: trimmed, or left out when empty, over its cap or not one line. */\nconst readClientContextText = (value: string | number | null | undefined, maxChars: number): string | undefined => {\n if (value === null || value === undefined) return undefined;\n const text = String(value).trim();\n if (text === \"\" || text.length > maxChars || CONTROL_CHARACTERS.test(text)) return undefined;\n return text;\n};\n\n/**\n * The client context as the body field `clientContext` carries it (`AgentClientContext`): the route parameters as a\n * list of `{name, value}`. A field over its cap ({@link AGENTS_CLIENT_CONTEXT_LIMITS}) or with a control character is\n * left out — never cut — so a send never fails on the context; the route parameters go together or not at all.\n * Undefined when nothing is left.\n */\nexport const mapClientContextToWire = (clientContext: AgentsClientContext | null | undefined): WireClientContext | undefined => {\n if (!clientContext) return undefined;\n const wireClientContext: WireClientContext = {};\n const routePath = readClientContextText(clientContext.routePath, AGENTS_CLIENT_CONTEXT_LIMITS.routePathChars);\n if (routePath !== undefined) wireClientContext.routePath = routePath;\n const routeParameters: WireClientContextRouteParameter[] = Object.entries(clientContext.routeParameters ?? {})\n .filter(([name, value]) => name.trim() !== \"\" && value !== null && value !== undefined)\n .map(([name, value]) => ({ name, value: String(value) }));\n const routeParametersText = routeParameters.map((routeParameter) => `${routeParameter.name}=${routeParameter.value}`).join(\"&\");\n if (\n routeParameters.length > 0 &&\n routeParameters.length <= AGENTS_CLIENT_CONTEXT_LIMITS.routeParameterCount &&\n routeParametersText.length <= AGENTS_CLIENT_CONTEXT_LIMITS.routeParametersChars &&\n !CONTROL_CHARACTERS.test(routeParametersText)\n ) {\n wireClientContext.routeParameters = routeParameters;\n }\n const recordKind = readClientContextText(clientContext.recordKind, AGENTS_CLIENT_CONTEXT_LIMITS.recordKindChars);\n if (recordKind !== undefined) wireClientContext.recordKind = recordKind;\n const recordId = readClientContextText(clientContext.recordId, AGENTS_CLIENT_CONTEXT_LIMITS.recordIdChars);\n if (recordId !== undefined) wireClientContext.recordId = recordId;\n const tab = readClientContextText(clientContext.tab, AGENTS_CLIENT_CONTEXT_LIMITS.tabChars);\n if (tab !== undefined) wireClientContext.tab = tab;\n return Object.keys(wireClientContext).length > 0 ? wireClientContext : undefined;\n};\n\n/** The record of an answer (`AIConversationBoundSubject`), or null when it names none. */\nexport const mapWireBoundConversationSubject = (wireSubject: WireBoundConversationSubject | null | undefined): BoundConversationSubject | null => {\n const entityId = Number(wireSubject?.subjectEntityId ?? 0);\n if (!wireSubject || !wireSubject.subjectEntityClass || !Number.isInteger(entityId) || entityId < 1) return null;\n return {\n conversationId: wireSubject.aiConversationId ?? null,\n entityClass: wireSubject.subjectEntityClass,\n entityId,\n name: wireSubject.name ?? null,\n link: wireSubject.link ?? null,\n purposeId: wireSubject.purposeName ?? null,\n };\n};\n","import type {\n AgentsConversationClient,\n AgentsConversationClientBindingOptions,\n AgentsConversationOperation,\n} from \"../AgentsConversationClient\";\nimport {\n AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED,\n AgentsClientError,\n type AgentsClientContext,\n type AgentsConversation,\n type ChangedConversationMessages,\n type ChangedMessagesRequest,\n type ConversationActivity,\n type ConversationAttachmentReference,\n type ConversationListQueryOptions,\n type ConversationMessageSearchHit,\n type ConversationMessagesPage,\n type ConversationRunStateRead,\n type ConversationSearchGroup,\n type ConversationSearchOptions,\n type ConversationSignal,\n type PostedMessage,\n type BoundConversationSubject,\n type ConversationsOfSubject,\n type ConversationSubject,\n type PurposeStartRequest,\n type SelectableModel,\n type StartedConversation,\n type StartedPurposeConversation,\n} from \"../../contract/conversation\";\nimport { type AgentUIState, createAgentUIClientId } from \"../../ui/agent-ui-state\";\nimport type { AgentUIClientBinding } from \"../../ui/AgentUIClient\";\nimport type { ClientToolAnswer } from \"../../ui/client-tools\";\nimport {\n acceptArrivedRealtimeMessage,\n type AgentRealtimeListenerCredential,\n type AgentRealtimeMessageDelivery,\n} from \"../../ui/realtime-arrival\";\nimport { composeAttachmentMessageText } from \"../compose-attachment-message-text\";\nimport type { PollingConversationChangeSubscriptionOptions } from \"../polling/createPollingConversationChangeSubscription\";\nimport { withPollingChangeSubscription } from \"../polling/withPollingChangeSubscription\";\nimport {\n mapClientContextToWire,\n mapHttpFailureToAgentsClientError,\n mapWireBoundConversationSubject,\n mapWireConversation,\n mapWireConversationActivity,\n mapWireConversationMessage,\n mapWireConversationRunState,\n mapWireSearchGroup,\n mapWireSearchHit,\n mapWireSelectableModel,\n readWireSetElements,\n} from \"./agents-http-mappers\";\nimport type { AccountRealtimeRead } from \"../../ui/account-realtime\";\nimport type {\n WireAccountRealtimeMessagesResponse,\n WireConversationActivityResponse,\n WireConversationMessageSearchResponse,\n WireConversationMessagesResponse,\n WireConversationResponse,\n WireConversationRunStateResponse,\n WireConversationSearchResponse,\n WireBoundConversationSubjectsResponse,\n WireConversationsOfSubjectResponse,\n WireConversationsResponse,\n WireConversationSubjectResponse,\n WireConversationStartResponse,\n WireErrorBody,\n WirePurposeStartResponse,\n WireSelectableModelsResponse,\n} from \"./agents-http-wire\";\n\n/** What every request of the binding carries from the host: headers, credentials, mode, cache. */\nexport type AgentsHttpFetchOptions = Omit<RequestInit, \"method\" | \"body\">;\n\nexport interface AgentsHttpConversationClientOptions extends AgentsConversationClientBindingOptions {\n /**\n * Where the application's conversations controller is mounted (its `#[Route]`): a path such as\n * `/api/agents/conversations` or an absolute URL. The module's routes are relative to it.\n */\n baseUrl: string;\n /**\n * Request options every request carries (credentials, an authorization header). A function is called per request,\n * so it may hand out a fresh token. Default: none (the browser's defaults: same-origin credentials).\n */\n fetchOptions?: AgentsHttpFetchOptions | (() => AgentsHttpFetchOptions | Promise<AgentsHttpFetchOptions>);\n /** The fetch function. Default: the global `fetch`. */\n fetch?: typeof fetch;\n /**\n * The application's start route below `baseUrl` (`AgentConversationStartTrait` declares none). Default: `/start` for\n * a start without an agent space (key 0), `/start/{agentSpaceKey}` otherwise — the start DTO reads `agentSpaceId`\n * from the path.\n */\n buildStartPath?: (agentSpaceKey: number) => string;\n /**\n * The controller uses `AgentSelectableModelsTrait` (`GET …/selectable-models`): the client offers\n * `getSelectableModels` and the chat shows the model picker. Default false.\n */\n hasSelectableModelsRoute?: boolean;\n /**\n * The live updates: the polling default over the run-state read (`withPollingChangeSubscription`), which also reads\n * at once after a post, a signal or a retry the server accepted. The intervals of\n * `PollingConversationChangeSubscriptionOptions`; `false` = no subscription (the host adds its own push transport).\n * Default: polling with the default intervals.\n */\n polling?: PollingConversationChangeSubscriptionOptions | false;\n /**\n * What the owner's client shows, read on every start, posted message and injected signal and sent as the body field\n * `clientContext` (the route, its parameters, the record on screen, the tab). The agent reads the newest one as one\n * line beside the owner's newest message. A field over its cap is left out, never cut. Default: none.\n */\n clientContext?: (operation: AgentsClientContextOperation) => AgentsClientContext | null | undefined;\n /**\n * The UI side of `Agent.UI` (`AgentUIClient` of `@mgamadeus/ddd-agents/ui`): its client id and UI state ride on every\n * write and every run-state read; a client tool request the run-state read delivers goes to it, and the binding\n * posts its answer (`POST /{conversationId}/clientToolRequests/{requestId}/answer`). Default: none; the account\n * read alone then states a client id the binding creates once (`getAccountRealtimeMessages`).\n */\n uiClient?: AgentUIClientBinding;\n /**\n * The open messages of the realtime port of other types than a client tool request (types other packages\n * registered), as the run-state read delivers them; a client acts on one type and key once. Default: none.\n */\n onRealtimeMessage?: (conversationId: number, message: AgentRealtimeMessageDelivery) => void;\n /** What the client needs to listen on the host's transport, with every run-state read (null without one). Default: none. */\n onRealtimeListenerCredential?: (conversationId: number, credential: AgentRealtimeListenerCredential | null) => void;\n}\n\n/** The writes that carry the client context. */\nexport type AgentsClientContextOperation = \"startConversation\" | \"postMessage\" | \"injectSignal\";\n\n/** The page size of a changed-messages read when the request names none (as the chat sends it). */\nexport const AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE = 50;\n\n/** The expand of every message page: the delegated children with the two fields the chat reads. */\nconst MESSAGES_EXPAND = \"delegatedConversations(select=id,runState)\";\n\nconst defaultBuildStartPath = (agentSpaceKey: number): string => (agentSpaceKey > 0 ? `/start/${agentSpaceKey}` : \"/start\");\n\ntype QueryParameters = Record<string, string | number | boolean | undefined | null>;\n\ninterface HttpRequest {\n operation: AgentsConversationOperation;\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\n path: string;\n query?: QueryParameters;\n body?: unknown;\n}\n\n/** A filter value as the query-options grammar writes it: quoted. */\nconst quoteFilterValue = (value: number | string): string => `'${String(value).replace(/'/g, \"\\\\'\")}'`;\n\n/** The module's conversation routes over fetch: one request per port function, the wire mapped onto the contract. */\nclass AgentsHttpConversationClient implements AgentsConversationClient {\n readonly getSelectableModels?: () => Promise<SelectableModel[]>;\n\n /** The client id this client created for its account read (no `uiClient` bound): once, kept while it lives. */\n protected ownAccountReadClientId: string | undefined;\n\n constructor(protected readonly options: AgentsHttpConversationClientOptions) {\n if (options.hasSelectableModelsRoute) this.getSelectableModels = this.readSelectableModels;\n }\n\n // ── Reads ─────────────────────────────────────────────────────────────────────────────────────────────────────\n\n getConversationMetadata = async (conversationId: number): Promise<AgentsConversation> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"getConversationMetadata\",\n method: \"GET\",\n path: `/${conversationId}`,\n });\n return mapWireConversation(response.aiConversation ?? {});\n };\n\n getConversationRunState = async (conversationId: number): Promise<ConversationRunStateRead> => {\n const uiClient = this.options.uiClient;\n const uiState = uiClient?.readUIState() ?? null;\n const response = await this.request<WireConversationRunStateResponse>({\n operation: \"getConversationRunState\",\n method: \"GET\",\n path: `/${conversationId}/runState`,\n query: uiClient ? { clientId: uiClient.clientId, uiStateJson: uiState ? JSON.stringify(uiState) : undefined } : undefined,\n });\n const sendAnswer = (requestId: number, answer: ClientToolAnswer): Promise<void> =>\n this.answerClientToolRequest(conversationId, requestId, answer);\n if (uiClient && response.clientToolRequest) {\n uiClient.acceptClientToolRequest(conversationId, response.clientToolRequest, sendAnswer);\n }\n for (const message of readWireSetElements(response.realtimeMessages)) {\n if (uiClient) acceptArrivedRealtimeMessage(conversationId, message, uiClient, sendAnswer, this.options.onRealtimeMessage);\n else this.options.onRealtimeMessage?.(conversationId, message);\n }\n this.options.onRealtimeListenerCredential?.(conversationId, response.realtimeListenerCredential ?? null);\n return mapWireConversationRunState(response);\n };\n\n /**\n * The account-level realtime read (`GET /realtimeMessages?clientId=…`): the messages addressed to the signed-in\n * account for this client and the listener credential without a conversation. It always states a client id\n * (`resolveAccountReadClientId`), so the server knows a client that only polls. Arrival is the caller's\n * (`createAccountRealtimePoll` of `/ui`).\n *\n * @param clientId the client id the caller wants stated (the `clientId` option of the poll)\n */\n getAccountRealtimeMessages = async (clientId?: string): Promise<AccountRealtimeRead> => {\n const response = await this.request<WireAccountRealtimeMessagesResponse>({\n operation: \"getAccountRealtimeMessages\",\n method: \"GET\",\n path: \"/realtimeMessages\",\n query: { clientId: this.resolveAccountReadClientId(clientId) },\n });\n return {\n messages: readWireSetElements(response.realtimeMessages),\n listenerCredential: response.realtimeListenerCredential ?? null,\n };\n };\n\n /**\n * The client id the account read states, decided here and nowhere else: the caller's, else the bound `uiClient`'s,\n * else one this client creates once and keeps while it lives. Only the account read asks: every other request\n * states a client id only with a `uiClient`.\n */\n protected resolveAccountReadClientId(clientId: string | undefined): string {\n if (clientId) return clientId;\n if (this.options.uiClient) return this.options.uiClient.clientId;\n this.ownAccountReadClientId ??= createAgentUIClientId();\n return this.ownAccountReadClientId;\n }\n\n /** Posts the answer of the UI client to a client tool request (`Agent.UI`); a refused answer is the server's word. */\n answerClientToolRequest = async (conversationId: number, requestId: number, answer: ClientToolAnswer): Promise<void> => {\n await this.request<unknown>({\n operation: \"answerClientToolRequest\",\n method: \"POST\",\n path: `/${conversationId}/clientToolRequests/${requestId}/answer`,\n body: {\n clientId: this.options.uiClient?.clientId ?? \"\",\n outcome: answer.outcome,\n text: answer.text,\n detailsJson: JSON.stringify(answer.details ?? {}),\n pictureBase64: answer.pictureBase64,\n uiStateJson: this.readUIStateJsonAfterAnswer(),\n },\n });\n };\n\n /** What the UI shows after the request was carried out, so the server's `[SIGNAL:ui]` note is current at once. */\n protected readUIStateJsonAfterAnswer(): string | undefined {\n const uiState: AgentUIState | null = this.options.uiClient?.readUIState() ?? null;\n return uiState ? JSON.stringify(uiState) : undefined;\n }\n\n getNewestMessagesPage = (conversationId: number, pageSize: number): Promise<ConversationMessagesPage> =>\n this.readMessagesPage(\"getNewestMessagesPage\", conversationId, pageSize, undefined);\n\n getOlderMessagesPage = (conversationId: number, beforeIndex: number, pageSize: number): Promise<ConversationMessagesPage> =>\n this.readMessagesPage(\n \"getOlderMessagesPage\",\n conversationId,\n pageSize,\n `indexInConversation lt ${quoteFilterValue(beforeIndex)}`,\n );\n\n getChangedMessages = async (\n conversationId: number,\n request: ChangedMessagesRequest,\n ): Promise<ChangedConversationMessages> => {\n const page = await this.readMessagesPage(\n \"getChangedMessages\",\n conversationId,\n request.pageSize ?? AGENTS_HTTP_DEFAULT_CHANGED_MESSAGES_PAGE_SIZE,\n `(id gt ${quoteFilterValue(request.highestKnownId)} or indexInConversation ge ${quoteFilterValue(request.fromIndex)})`,\n );\n return { messages: page.messages };\n };\n\n /** The query of the root conversations list (of one space, or of all), newest first: shared by the list and the read of its records. */\n protected buildConversationsListQuery(agentSpaceKey: number, options: ConversationListQueryOptions) {\n const filters = [\"rootConversationId eq null\"];\n if (agentSpaceKey > 0) filters.push(`agentSpaceId eq ${quoteFilterValue(agentSpaceKey)}`);\n return {\n filters: filters.join(\" and \"),\n orderBy: \"id desc\",\n top: options.paging?.top,\n skip: options.paging?.skip,\n };\n }\n\n listConversations = async (agentSpaceKey: number, options: ConversationListQueryOptions = {}): Promise<AgentsConversation[]> => {\n const response = await this.request<WireConversationsResponse>({\n operation: \"listConversations\",\n method: \"GET\",\n path: \"/listAllConversations\",\n query: this.buildConversationsListQuery(agentSpaceKey, options),\n });\n const conversations = readWireSetElements(response.aiConversations).map(mapWireConversation);\n // Without a summary there is no title yet; the list leaves such a conversation out unless asked for it.\n return options.includeUnsummarized ? conversations : conversations.filter((conversation) => conversation.title !== null);\n };\n\n listConversationsOfSubject = async (subject: ConversationSubject, options: ConversationListQueryOptions = {}): Promise<ConversationsOfSubject> => {\n const response = await this.request<WireConversationsOfSubjectResponse>({\n operation: \"listConversationsOfSubject\",\n method: \"GET\",\n path: \"/listConversationsOfSubject\",\n query: {\n subjectEntityClass: subject.entityClass,\n subjectEntityId: subject.entityId,\n filters: \"rootConversationId eq null\",\n orderBy: \"id desc\",\n top: options.paging?.top,\n skip: options.paging?.skip,\n },\n });\n const conversations = readWireSetElements(response.aiConversations).map(mapWireConversation);\n return {\n subject: mapWireBoundConversationSubject(response.subject),\n conversations: options.includeUnsummarized ? conversations : conversations.filter((conversation) => conversation.title !== null),\n };\n };\n\n listSubjectsOfConversations = async (agentSpaceKey: number, options: ConversationListQueryOptions = {}): Promise<BoundConversationSubject[]> => {\n const response = await this.request<WireBoundConversationSubjectsResponse>({\n operation: \"listSubjectsOfConversations\",\n method: \"GET\",\n path: \"/listSubjectsOfConversations\",\n query: this.buildConversationsListQuery(agentSpaceKey, options),\n });\n return readWireSetElements(response.subjects)\n .map(mapWireBoundConversationSubject)\n .filter((subject): subject is BoundConversationSubject => subject !== null);\n };\n\n getConversationSubject = async (conversationId: number): Promise<BoundConversationSubject | null> => {\n const response = await this.request<WireConversationSubjectResponse>({\n operation: \"getConversationSubject\",\n method: \"GET\",\n path: `/${conversationId}/subject`,\n });\n return mapWireBoundConversationSubject(response.subject);\n };\n\n searchConversations = async (text: string, options: ConversationSearchOptions = {}): Promise<ConversationSearchGroup[]> => {\n const response = await this.request<WireConversationSearchResponse>({\n operation: \"searchConversations\",\n method: \"GET\",\n path: \"/search\",\n query: { query: text, limit: options.limit, excerptChars: options.excerptLength },\n });\n return readWireSetElements(response.conversations).map(mapWireSearchGroup);\n };\n\n searchConversationMessages = async (\n conversationId: number,\n text: string,\n options: ConversationSearchOptions = {},\n ): Promise<ConversationMessageSearchHit[]> => {\n const response = await this.request<WireConversationMessageSearchResponse>({\n operation: \"searchConversationMessages\",\n method: \"GET\",\n path: `/${conversationId}/messages/search`,\n query: { query: text, limit: options.limit, excerptChars: options.excerptLength },\n });\n return readWireSetElements(response.hits).map(mapWireSearchHit);\n };\n\n getConversationActivity = async (conversationId: number, turnMessageId?: number | null): Promise<ConversationActivity> => {\n const response = await this.request<WireConversationActivityResponse>({\n operation: \"getConversationActivity\",\n method: \"GET\",\n path: `/${conversationId}/activity`,\n query: { turnMessageId: turnMessageId ?? undefined },\n });\n return mapWireConversationActivity(response);\n };\n\n composeSentMessageText = (text: string, attachments: ConversationAttachmentReference[] | undefined): string =>\n composeAttachmentMessageText(text, attachments);\n\n // ── Writes ────────────────────────────────────────────────────────────────────────────────────────────────────\n\n startConversation = async (request: Parameters<AgentsConversationClient[\"startConversation\"]>[0]): Promise<StartedConversation> => {\n const buildStartPath = this.options.buildStartPath ?? defaultBuildStartPath;\n const response = await this.request<WireConversationStartResponse>({\n operation: \"startConversation\",\n method: \"POST\",\n path: buildStartPath(request.agentSpaceKey),\n query: { aiModelName: request.model },\n body: {\n aiConversationMessage: { message: composeAttachmentMessageText(request.text, request.attachments) },\n ...(request.startSignalText ? { signalText: request.startSignalText } : {}),\n ...(request.entryPointKey ? { entryPointKey: request.entryPointKey } : {}),\n ...(request.subject\n ? { subject: { subjectEntityClass: request.subject.entityClass, subjectEntityId: request.subject.entityId } }\n : {}),\n ...this.readClientContextBody(\"startConversation\"),\n },\n });\n const wireConversation = response.aiConversation ?? {};\n const reopenedExisting = response.reopenedExistingConversation === true;\n return {\n conversation: mapWireConversation(wireConversation),\n messages: reopenedExisting ? [] : readWireSetElements(wireConversation.messages).map(mapWireConversationMessage),\n reopenedExisting,\n };\n };\n\n startPurpose = async (request: PurposeStartRequest): Promise<StartedPurposeConversation> => {\n const response = await this.request<WirePurposeStartResponse>({\n operation: \"startPurpose\",\n method: \"POST\",\n path: \"/startPurpose\",\n body: {\n purposeId: request.purposeId,\n ...(request.agentSpaceKey ? { agentSpaceId: request.agentSpaceKey } : {}),\n ...(request.subject\n ? { subject: { subjectEntityClass: request.subject.entityClass, subjectEntityId: request.subject.entityId } }\n : {}),\n ...(request.prefill ? { prefill: request.prefill } : {}),\n },\n });\n const conversationId = Number(response.aiConversationId ?? 0);\n if (!Number.isInteger(conversationId) || conversationId < 1) {\n throw new AgentsClientError(\"other\", { message: \"The purposed start answered no conversation id.\" });\n }\n return {\n conversationId,\n resumedExisting: response.resumedExistingConversation === true,\n prefillDelivered: response.prefillDelivered === true,\n };\n };\n\n postMessage = async (\n conversationId: number,\n message: { text: string; model?: string; attachments?: ConversationAttachmentReference[] },\n ): Promise<PostedMessage> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"postMessage\",\n method: \"POST\",\n path: `/${conversationId}/postMessage`,\n query: { aiModelName: message.model },\n body: {\n aiConversationMessage: { message: composeAttachmentMessageText(message.text, message.attachments) },\n ...this.readClientContextBody(\"postMessage\"),\n },\n });\n return { messages: readWireSetElements(response.aiConversation?.messages).map(mapWireConversationMessage) };\n };\n\n injectSignal = async (conversationId: number, signal: ConversationSignal): Promise<void> => {\n await this.request<WireConversationResponse>({\n operation: \"injectSignal\",\n method: \"POST\",\n path: `/${conversationId}/injectSignal`,\n body: {\n signalText: signal.text,\n ...(signal.source ? { signalSource: signal.source } : {}),\n ...this.readClientContextBody(\"injectSignal\"),\n },\n });\n };\n\n retryConversation = async (conversationId: number): Promise<void> => {\n await this.request<WireConversationResponse>({\n operation: \"retryConversation\",\n method: \"POST\",\n path: `/${conversationId}/retry`,\n });\n };\n\n renameConversation = async (conversationId: number, title: string): Promise<AgentsConversation> => {\n const response = await this.request<WireConversationResponse>({\n operation: \"renameConversation\",\n method: \"PATCH\",\n path: `/${conversationId}/title`,\n body: { title },\n });\n return mapWireConversation(response.aiConversation ?? {});\n };\n\n deleteConversation = async (conversationId: number): Promise<void> => {\n await this.request<unknown>({ operation: \"deleteConversation\", method: \"DELETE\", path: `/${conversationId}` });\n };\n\n // ── Transport ─────────────────────────────────────────────────────────────────────────────────────────────────\n\n protected readSelectableModels = async (): Promise<SelectableModel[]> => {\n const response = await this.request<WireSelectableModelsResponse>({\n operation: \"getSelectableModels\",\n method: \"GET\",\n path: \"/selectable-models\",\n });\n return readWireSetElements(response.models).map(mapWireSelectableModel);\n };\n\n protected async readMessagesPage(\n operation: AgentsConversationOperation,\n conversationId: number,\n pageSize: number,\n filters: string | undefined,\n ): Promise<ConversationMessagesPage> {\n const response = await this.request<WireConversationMessagesResponse>({\n operation,\n method: \"GET\",\n path: `/${conversationId}/messages`,\n query: { filters, orderBy: \"indexInConversation desc\", top: pageSize, expand: MESSAGES_EXPAND },\n });\n return {\n messages: readWireSetElements(response.messages).map(mapWireConversationMessage),\n hasMoreOlder: response.hasMoreOlder === true,\n };\n }\n\n /** The body field `clientContext` of a write, from the host's option; nothing when it gives none. */\n protected readClientContextBody(operation: AgentsClientContextOperation): {\n clientContext?: ReturnType<typeof mapClientContextToWire>;\n clientId?: string;\n uiState?: AgentUIState;\n } {\n const wireClientContext = mapClientContextToWire(this.options.clientContext?.(operation));\n const uiClient = this.options.uiClient;\n const uiState = uiClient?.readUIState() ?? null;\n return {\n ...(wireClientContext ? { clientContext: wireClientContext } : {}),\n ...(uiClient ? { clientId: uiClient.clientId } : {}),\n ...(uiState ? { uiState } : {}),\n };\n }\n\n /** The URL of a route: the base, the path, the binding's query parameters with the host's extra ones over them. */\n protected buildUrl(request: HttpRequest): string {\n const searchParameters = new URLSearchParams();\n const extraParameters = this.options.extraRequestParameters?.(request.operation) ?? {};\n for (const [name, value] of Object.entries({ ...request.query, ...extraParameters })) {\n if (value !== undefined && value !== null) searchParameters.set(name, String(value));\n }\n const query = searchParameters.toString();\n const baseUrl = this.options.baseUrl.replace(/\\/+$/, \"\");\n return `${baseUrl}${request.path}${query ? `?${query}` : \"\"}`;\n }\n\n protected async readFetchOptions(): Promise<AgentsHttpFetchOptions> {\n const { fetchOptions } = this.options;\n return typeof fetchOptions === \"function\" ? await fetchOptions() : (fetchOptions ?? {});\n }\n\n /** One request; every failure becomes an `AgentsClientError` (the port's one error shape). */\n protected async request<ResponseBody>(request: HttpRequest): Promise<ResponseBody> {\n const fetchFunction = this.options.fetch ?? globalThis.fetch.bind(globalThis);\n let response: Response;\n try {\n const fetchOptions = await this.readFetchOptions();\n const headers = new Headers(fetchOptions.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n if (request.body !== undefined && !headers.has(\"Content-Type\")) headers.set(\"Content-Type\", \"application/json\");\n response = await fetchFunction(this.buildUrl(request), {\n ...fetchOptions,\n headers,\n method: request.method,\n body: request.body === undefined ? undefined : JSON.stringify(request.body),\n });\n } catch (failure) {\n if (failure instanceof AgentsClientError) throw failure;\n const isAbort = failure instanceof Error && failure.name === \"AbortError\";\n throw isAbort\n ? new AgentsClientError(\"other\", { code: AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED, message: \"The request was cancelled.\" })\n : new AgentsClientError(\"network\", { message: failure instanceof Error ? failure.message : \"The request failed.\" });\n }\n const responseText = await response.text().catch(() => \"\");\n const responseBody = readJsonBody(responseText);\n if (!response.ok) {\n throw mapHttpFailureToAgentsClientError(\n response.status,\n isPlainObject(responseBody) ? (responseBody as WireErrorBody) : null,\n response.headers.get(\"Retry-After\"),\n );\n }\n return (responseBody ?? {}) as ResponseBody;\n }\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst readJsonBody = (text: string): unknown => {\n if (text.trim() === \"\") return null;\n try {\n return JSON.parse(text);\n } catch {\n return null;\n }\n};\n\n/**\n * The conversation client over the module's own conversation routes (`AgentConversationReadsTrait`,\n * `AgentConversationWritesTrait`, the application's start route of `AgentConversationStartTrait`, optionally\n * `AgentSelectableModelsTrait`): `baseUrl` is where the application mounted its conversations controller, `fetchOptions`\n * what every request carries. Every function rejects with `AgentsClientError`. The client comes with live updates —\n * the polling default over the run-state read, which also reads at once after an accepted send — unless `polling` is\n * `false`.\n *\n * ```ts\n * const client = createAgentsHttpConversationClient({\n * baseUrl: \"/api/agents/conversations\",\n * fetchOptions: () => ({ headers: { Authorization: `Bearer ${readToken()}` } }),\n * });\n * <AgentsProvider client={client}><AgentChat /></AgentsProvider>\n * ```\n */\nexport const createAgentsHttpConversationClient = (options: AgentsHttpConversationClientOptions): AgentsConversationClient => {\n const client = new AgentsHttpConversationClient(options);\n return options.polling === false ? client : withPollingChangeSubscription(client, options.polling);\n};\n"],"names":["options"],"mappings":";;;;;;;AAyCA,MAAM,aAA8C;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,gBAAoD,CAAC,UAAU,QAAQ,WAAW;AACxF,MAAM,gBAAoD;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,mBAAyD;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,eAAyD,CAAC,QAAQ,aAAa,SAAS,MAAM;AACpG,MAAM,yBAAwE,CAAC,QAAQ,UAAU,UAAU;AAC3G,MAAM,kBAAgF;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,iBAA8E;AAAA,E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AAC,SAA0B;AAC9C,MAAI,KAAK,WAAW,GAAI,QAAO;AAC/B,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAkBO,MAAM,qCAAqC,CAAC,YAA2E;AAC5H,QAAM,SAAS,IAAI,6BAA6B,OAAO;AACvD,SAAO,QAAQ,YAAY,QAAQ,SAAS,8BAA8B,QAAQ,QAAQ,OAAO;AACnG;"}
|
|
@@ -1330,6 +1330,17 @@
|
|
|
1330
1330
|
"src/chat/ConversationMessage/ConversationMessageWidgets/ConversationMessageThinking/ConversationMessageThinking.tsx"
|
|
1331
1331
|
]
|
|
1332
1332
|
},
|
|
1333
|
+
{
|
|
1334
|
+
"key": "Play the sample of %voiceName%",
|
|
1335
|
+
"defaultText": "Play the sample of %voiceName%",
|
|
1336
|
+
"placeholders": [
|
|
1337
|
+
"voiceName"
|
|
1338
|
+
],
|
|
1339
|
+
"contexts": [],
|
|
1340
|
+
"usedIn": [
|
|
1341
|
+
"src/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.tsx"
|
|
1342
|
+
]
|
|
1343
|
+
},
|
|
1333
1344
|
{
|
|
1334
1345
|
"key": "Play the video %title%",
|
|
1335
1346
|
"defaultText": "Play the video %title%",
|
|
@@ -1797,6 +1808,17 @@
|
|
|
1797
1808
|
"src/voice/admin/AgentVoiceCallsScreen/AgentVoiceCallsScreen.tsx"
|
|
1798
1809
|
]
|
|
1799
1810
|
},
|
|
1811
|
+
{
|
|
1812
|
+
"key": "Stop the sample of %voiceName%",
|
|
1813
|
+
"defaultText": "Stop the sample of %voiceName%",
|
|
1814
|
+
"placeholders": [
|
|
1815
|
+
"voiceName"
|
|
1816
|
+
],
|
|
1817
|
+
"contexts": [],
|
|
1818
|
+
"usedIn": [
|
|
1819
|
+
"src/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.tsx"
|
|
1820
|
+
]
|
|
1821
|
+
},
|
|
1800
1822
|
{
|
|
1801
1823
|
"key": "Subject",
|
|
1802
1824
|
"defaultText": "Subject",
|
|
@@ -2002,6 +2024,24 @@
|
|
|
2002
2024
|
"src/voice/admin/agent-voice-admin-format.ts"
|
|
2003
2025
|
]
|
|
2004
2026
|
},
|
|
2027
|
+
{
|
|
2028
|
+
"key": "The sample could not be loaded.",
|
|
2029
|
+
"defaultText": "The sample could not be loaded.",
|
|
2030
|
+
"placeholders": [],
|
|
2031
|
+
"contexts": [],
|
|
2032
|
+
"usedIn": [
|
|
2033
|
+
"src/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.tsx"
|
|
2034
|
+
]
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
"key": "The sample could not be played.",
|
|
2038
|
+
"defaultText": "The sample could not be played.",
|
|
2039
|
+
"placeholders": [],
|
|
2040
|
+
"contexts": [],
|
|
2041
|
+
"usedIn": [
|
|
2042
|
+
"src/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.tsx"
|
|
2043
|
+
]
|
|
2044
|
+
},
|
|
2005
2045
|
{
|
|
2006
2046
|
"key": "The session ended on an error of the provider, the model or the worker",
|
|
2007
2047
|
"defaultText": "The session ended on an error of the provider, the model or the worker",
|
|
@@ -2145,6 +2185,15 @@
|
|
|
2145
2185
|
"src/voice/call/agent-voice-call-store.ts"
|
|
2146
2186
|
]
|
|
2147
2187
|
},
|
|
2188
|
+
{
|
|
2189
|
+
"key": "There is no sample of this voice yet.",
|
|
2190
|
+
"defaultText": "There is no sample of this voice yet.",
|
|
2191
|
+
"placeholders": [],
|
|
2192
|
+
"contexts": [],
|
|
2193
|
+
"usedIn": [
|
|
2194
|
+
"src/voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton.tsx"
|
|
2195
|
+
]
|
|
2196
|
+
},
|
|
2148
2197
|
{
|
|
2149
2198
|
"key": "These files show here once the drive is part of this app.",
|
|
2150
2199
|
"defaultText": "These files show here once the drive is part of this app.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccountRealtimeRead } from "../ui/account-realtime";
|
|
2
2
|
import type { ClientToolAnswer } from "../ui/client-tools";
|
|
3
|
-
import type { AgentsConversation, ChangedConversationMessages, ChangedMessagesRequest, ConversationActivity, ConversationAttachmentReference, ConversationChangeSignal, ConversationListQueryOptions, ConversationMessageSearchHit, ConversationMessageSentPayload, ConversationMessagesPage, ConversationRunStateRead, ConversationSearchGroup, ConversationSearchOptions, ConversationSignal, ConversationSubscriptionEndReason, PostedMessage, PurposeStartRequest, SelectableModel, StartedConversation, StartedPurposeConversation } from "../contract/conversation";
|
|
3
|
+
import type { AgentsConversation, ChangedConversationMessages, ChangedMessagesRequest, ConversationActivity, ConversationAttachmentReference, ConversationChangeSignal, ConversationListQueryOptions, ConversationMessageSearchHit, ConversationMessageSentPayload, ConversationMessagesPage, ConversationRunStateRead, ConversationSearchGroup, ConversationSearchOptions, ConversationSignal, ConversationSubscriptionEndReason, PostedMessage, BoundConversationSubject, ConversationsOfSubject, ConversationSubject, PurposeStartRequest, SelectableModel, StartedConversation, StartedPurposeConversation } from "../contract/conversation";
|
|
4
4
|
/**
|
|
5
5
|
* The conversation client port (one function per row of the table, derived from the chat
|
|
6
6
|
* controller's requests). The package calls only this; an app binds it over its own request layer; the package
|
|
@@ -45,7 +45,8 @@ export interface AgentsConversationClient {
|
|
|
45
45
|
/**
|
|
46
46
|
* Start a conversation with its first message. `text` may be empty only together with `startSignalText` (the agent
|
|
47
47
|
* speaks first); `entryPointKey` reopens the recent conversation of that entry point instead of starting an
|
|
48
|
-
* identical one; `model` is a name from `getSelectableModels
|
|
48
|
+
* identical one; `model` is a name from `getSelectableModels`; `subject` binds the NEW conversation to a record
|
|
49
|
+
* (the agent then reads what the record is in every call; a reopened conversation keeps its own subject).
|
|
49
50
|
*/
|
|
50
51
|
startConversation: (request: {
|
|
51
52
|
agentSpaceKey: number;
|
|
@@ -54,7 +55,25 @@ export interface AgentsConversationClient {
|
|
|
54
55
|
entryPointKey?: string;
|
|
55
56
|
model?: string;
|
|
56
57
|
attachments?: ConversationAttachmentReference[];
|
|
58
|
+
subject?: ConversationSubject;
|
|
57
59
|
}) => Promise<StartedConversation>;
|
|
60
|
+
/**
|
|
61
|
+
* The user's root conversations about one record, newest first (`GET …/listConversationsOfSubject`): the free ones
|
|
62
|
+
* started about it and the purposed ones started for it, of every agent space. Optional: a binding without it
|
|
63
|
+
* offers no list per record.
|
|
64
|
+
*/
|
|
65
|
+
listConversationsOfSubject?: (subject: ConversationSubject, options?: ConversationListQueryOptions) => Promise<ConversationsOfSubject>;
|
|
66
|
+
/**
|
|
67
|
+
* The record one conversation is bound to (`GET …/{conversationId}/subject`), or null for a conversation without
|
|
68
|
+
* one. Optional like {@link listConversationsOfSubject}.
|
|
69
|
+
*/
|
|
70
|
+
getConversationSubject?: (conversationId: number) => Promise<BoundConversationSubject | null>;
|
|
71
|
+
/**
|
|
72
|
+
* The records the conversations of a page of {@link listConversations} are bound to
|
|
73
|
+
* (`GET …/listSubjectsOfConversations`, the same space and paging): one entry per bound conversation
|
|
74
|
+
* (`conversationId`). Optional like {@link listConversationsOfSubject}.
|
|
75
|
+
*/
|
|
76
|
+
listSubjectsOfConversations?: (agentSpaceKey: number, options?: ConversationListQueryOptions) => Promise<BoundConversationSubject[]>;
|
|
58
77
|
/**
|
|
59
78
|
* Start a purposed conversation (`POST …/startPurpose`), or reopen its open one; the chat then opens the answered
|
|
60
79
|
* conversation by its id. Optional: a binding without it offers no purposed start.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentsClientError, type AgentsClientContext, type AgentsConversation, type AgentsConversationMessage, type ConversationActivity, type ConversationMessageSearchHit, type ConversationRunStateRead, type ConversationSearchGroup, type SelectableModel } from "../../contract/conversation";
|
|
2
|
-
import type { WireClientContext, WireConversation, WireConversationActivityResponse, WireConversationMessage, WireConversationRunStateResponse, WireConversationSearchGroup, WireErrorBody, WireSelectableModel, WireSemanticSearchHit, WireSet } from "./agents-http-wire";
|
|
1
|
+
import { AgentsClientError, type AgentsClientContext, type AgentsConversation, type AgentsConversationMessage, type BoundConversationSubject, type ConversationActivity, type ConversationMessageSearchHit, type ConversationRunStateRead, type ConversationSearchGroup, type SelectableModel } from "../../contract/conversation";
|
|
2
|
+
import type { WireBoundConversationSubject, WireClientContext, WireConversation, WireConversationActivityResponse, WireConversationMessage, WireConversationRunStateResponse, WireConversationSearchGroup, WireErrorBody, WireSelectableModel, WireSemanticSearchHit, WireSet } from "./agents-http-wire";
|
|
3
3
|
/** The elements of a serialized set (`{ elements: [...] }`), a plain array, or the values of a keyed object. */
|
|
4
4
|
export declare const readWireSetElements: <Element>(wireSet: WireSet<Element> | Record<string, Element> | null | undefined) => Element[];
|
|
5
5
|
/** An `AIConversation` as the contract's conversation. */
|
|
@@ -28,3 +28,5 @@ export declare const mapHttpFailureToAgentsClientError: (httpStatus: number, wir
|
|
|
28
28
|
* Undefined when nothing is left.
|
|
29
29
|
*/
|
|
30
30
|
export declare const mapClientContextToWire: (clientContext: AgentsClientContext | null | undefined) => WireClientContext | undefined;
|
|
31
|
+
/** The record of an answer (`AIConversationBoundSubject`), or null when it names none. */
|
|
32
|
+
export declare const mapWireBoundConversationSubject: (wireSubject: WireBoundConversationSubject | null | undefined) => BoundConversationSubject | null;
|
|
@@ -146,6 +146,27 @@ export interface WirePurposeStartResponse {
|
|
|
146
146
|
resumedExistingConversation?: boolean | null;
|
|
147
147
|
prefillDelivered?: boolean | null;
|
|
148
148
|
}
|
|
149
|
+
/** `AIConversationBoundSubject`. */
|
|
150
|
+
export interface WireBoundConversationSubject {
|
|
151
|
+
aiConversationId?: number | null;
|
|
152
|
+
subjectEntityClass?: string | null;
|
|
153
|
+
subjectEntityId?: number | null;
|
|
154
|
+
purposeName?: string | null;
|
|
155
|
+
name?: string | null;
|
|
156
|
+
link?: string | null;
|
|
157
|
+
}
|
|
158
|
+
/** `AIConversationSubjectGetResponseDto`. */
|
|
159
|
+
export interface WireConversationSubjectResponse {
|
|
160
|
+
subject?: WireBoundConversationSubject | null;
|
|
161
|
+
}
|
|
162
|
+
/** `AIConversationBoundSubjectsGetResponseDto`: `subjects` is the set `AIConversationBoundSubjects`. */
|
|
163
|
+
export interface WireBoundConversationSubjectsResponse {
|
|
164
|
+
subjects?: WireSet<WireBoundConversationSubject> | null;
|
|
165
|
+
}
|
|
166
|
+
/** `AIConversationsOfSubjectGetResponseDto`. */
|
|
167
|
+
export interface WireConversationsOfSubjectResponse extends WireConversationsResponse {
|
|
168
|
+
subject?: WireBoundConversationSubject | null;
|
|
169
|
+
}
|
|
149
170
|
/** `AIConversationsGetResponseDto`. */
|
|
150
171
|
export interface WireConversationsResponse {
|
|
151
172
|
aiConversations?: WireSet<WireConversation> | null;
|
|
@@ -210,15 +210,41 @@ export interface StartedConversation {
|
|
|
210
210
|
reopenedExisting: boolean;
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
-
* The record a
|
|
214
|
-
*
|
|
213
|
+
* The record a conversation is about: the entity class as the record's `objectType` and its id. The server checks
|
|
214
|
+
* both (a class the application does not allow and a record the user cannot read answer 404).
|
|
215
215
|
*/
|
|
216
|
-
export interface
|
|
216
|
+
export interface ConversationSubject {
|
|
217
217
|
/** generic — the record's entity class, e.g. `App\\Domain\\Support\\Entities\\Tickets\\SupportTicket` */
|
|
218
218
|
entityClass: string;
|
|
219
219
|
/** generic */
|
|
220
220
|
entityId: number;
|
|
221
221
|
}
|
|
222
|
+
/** The record a purposed conversation works on ({@link ConversationSubject}); the name of before free conversations had subjects. */
|
|
223
|
+
export type PurposeSubject = ConversationSubject;
|
|
224
|
+
/**
|
|
225
|
+
* The record one conversation is bound to, with what the application said about it when the conversation started:
|
|
226
|
+
* its display name and where the owner opens it. `purposeId` is null for a free conversation about the record.
|
|
227
|
+
*/
|
|
228
|
+
export interface BoundConversationSubject extends ConversationSubject {
|
|
229
|
+
/** generic — the conversation that is bound to the record; null for a record named without a conversation */
|
|
230
|
+
conversationId: number | null;
|
|
231
|
+
/** generic — the record's display name when the conversation started; data, never markup */
|
|
232
|
+
name: string | null;
|
|
233
|
+
/** generic — an absolute URL or a path of the application */
|
|
234
|
+
link: string | null;
|
|
235
|
+
/** generic — the purpose of a purposed conversation for the record */
|
|
236
|
+
purposeId: string | null;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The user's conversations about one record (`listConversationsOfSubject`) and the record itself as the application
|
|
240
|
+
* names it now: `subject` carries its name and link (no purpose), also when no conversation about it exists yet;
|
|
241
|
+
* null when the answer named no record.
|
|
242
|
+
*/
|
|
243
|
+
export interface ConversationsOfSubject {
|
|
244
|
+
subject: BoundConversationSubject | null;
|
|
245
|
+
/** generic — root conversations, newest first */
|
|
246
|
+
conversations: AgentsConversation[];
|
|
247
|
+
}
|
|
222
248
|
/** The start of a purposed conversation (`startPurpose`). */
|
|
223
249
|
export interface PurposeStartRequest {
|
|
224
250
|
/** generic — the purpose's name, e.g. `Support.AnswerTicket` */
|
|
@@ -5,3 +5,5 @@ export { AgentVoiceCallConversationLink, type AgentVoiceCallConversationLinkProp
|
|
|
5
5
|
export { AgentVoiceCallStateBadges, type AgentVoiceCallStateBadgesProps, } from "../voice/admin/AgentVoiceCallStateBadges/AgentVoiceCallStateBadges";
|
|
6
6
|
export { AGENT_VOICE_CALLS_MAX_PAGE_SIZE, AgentVoiceCallsScreen, type AgentVoiceCallsScreenProps, } from "../voice/admin/AgentVoiceCallsScreen/AgentVoiceCallsScreen";
|
|
7
7
|
export { AgentVoiceCallDetailScreen, type AgentVoiceCallDetailScreenProps, } from "../voice/admin/AgentVoiceCallDetailScreen/AgentVoiceCallDetailScreen";
|
|
8
|
+
export { AGENT_VOICE_SAMPLE_ERROR_TEXTS, type AgentVoiceSampleButtonProps, AgentVoiceSampleButton, type AgentVoiceSamplePlayer, useAgentVoiceSamplePlayer, type UseAgentVoiceSamplePlayerOptions, } from "../voice/samples/AgentVoiceSampleButton/AgentVoiceSampleButton";
|
|
9
|
+
export { type AgentVoiceSampleErrorKind, agentVoiceSampleKeyOf, type AgentVoiceSamplePlayerState, type FetchAgentVoiceSample, isAgentVoiceSampleNotFound, readAgentVoiceSamplePlayerState, resetAgentVoiceSamplePlayer, stopAgentVoiceSample, subscribeAgentVoiceSamplePlayer, toggleAgentVoiceSample, } from "../voice/samples/agent-voice-sample-player";
|
|
@@ -50,10 +50,19 @@ export declare const CLIENT_TOOL_OUTCOMES: {
|
|
|
50
50
|
readonly writeAction: 'WRITE_ACTION';
|
|
51
51
|
readonly disabled: 'DISABLED';
|
|
52
52
|
readonly noEffect: 'NO_EFFECT';
|
|
53
|
+
readonly unknownFilterValue: 'UNKNOWN_FILTER_VALUE';
|
|
53
54
|
};
|
|
54
55
|
export interface ScreenTargetFilter {
|
|
55
56
|
/** The query parameter, e.g. `customerId` */
|
|
56
57
|
key: string;
|
|
58
|
+
/** The stored values the filter takes (an enumeration, a sort); without them any value is passed on */
|
|
59
|
+
values?: readonly string[];
|
|
60
|
+
/** Whether the filter takes several of its values as a comma list */
|
|
61
|
+
multiple?: boolean;
|
|
62
|
+
/** What a free value is, e.g. `date YYYY-MM-DD`, `id` */
|
|
63
|
+
hint?: string;
|
|
64
|
+
/** The tabs of the target the filter belongs to (a record screen with a list per tab); without them every page of the target */
|
|
65
|
+
tabs?: readonly string[];
|
|
57
66
|
}
|
|
58
67
|
/** A screen the user can open: a menu entry, a record screen or a page below one. */
|
|
59
68
|
export interface ScreenTarget {
|
|
@@ -237,9 +246,49 @@ export declare const parseClientToolArguments: (argumentsJson: string) => Record
|
|
|
237
246
|
export declare const capAnswerText: (text: string) => string;
|
|
238
247
|
/** One line of a target in the `listScreens` answer. */
|
|
239
248
|
export declare const formatScreenTargetLine: (target: ScreenTarget) => string;
|
|
249
|
+
/** The most values of one filter a description names. */
|
|
250
|
+
export declare const MAX_DESCRIBED_FILTER_VALUES = 24;
|
|
251
|
+
/** Whether a filter says more than its key: values or a hint. */
|
|
252
|
+
export declare const isDescribedScreenTargetFilter: (filter: ScreenTargetFilter) => boolean;
|
|
253
|
+
/**
|
|
254
|
+
* The values of a filter as one phrase. A sort (every value `<key>:asc` or `<key>:desc`, both of each key) names its
|
|
255
|
+
* keys once: `one of id|created, each with :asc or :desc`.
|
|
256
|
+
*/
|
|
257
|
+
export declare const describeScreenFilterValues: (values: readonly string[], multiple: boolean) => string;
|
|
258
|
+
/** A filter with what its value is: `status one or more of OPEN|SOLVED, comma-separated`, `from date YYYY-MM-DD`. */
|
|
259
|
+
export declare const describeScreenTargetFilter: (filter: ScreenTargetFilter) => string;
|
|
260
|
+
/**
|
|
261
|
+
* The filters of a target on one of its tabs (`null`: its own page): those of every page and those of that tab; a
|
|
262
|
+
* filter declared for the tab replaces the one of every page with the same key.
|
|
263
|
+
*/
|
|
264
|
+
export declare const screenTargetFiltersOfTab: (target: ScreenTarget, tab: string | null) => ScreenTargetFilter[];
|
|
265
|
+
/**
|
|
266
|
+
* The lines below a target that name the values of its filters, one per tab that has filters of its own (a filter of
|
|
267
|
+
* a tab is passed with that tab); `null` when no filter says more than its key.
|
|
268
|
+
*/
|
|
269
|
+
export declare const formatScreenTargetFilterValues: (target: ScreenTarget) => string | null;
|
|
270
|
+
/**
|
|
271
|
+
* The part of a filter value its filter does not take (`null` when the value is fine): a filter without values takes
|
|
272
|
+
* anything, an empty value clears a filter, a filter for several takes a comma list of its values.
|
|
273
|
+
*/
|
|
274
|
+
export declare const findUnknownScreenFilterValue: (filter: ScreenTargetFilter, value: string) => string | null;
|
|
275
|
+
/** `status=DONE (status one of OPEN|SOLVED)`: a filter value that was not taken, with what the filter takes. */
|
|
276
|
+
export declare const describeUnknownScreenFilterValue: (filter: ScreenTargetFilter, value: string) => string;
|
|
277
|
+
/** The most matching targets a `listScreens` answer names the filter values of. */
|
|
278
|
+
export declare const MAX_TARGETS_WITH_FILTER_VALUES = 4;
|
|
240
279
|
/** The most characters of a `listScreens` answer. */
|
|
241
280
|
export declare const MAX_TARGET_LIST_CHARS = 4500;
|
|
242
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* The short line of a target, for a catalogue too long for full lines: its key and label (without the group, which
|
|
283
|
+
* the full line names), how many tabs it has and whether it has filters or views.
|
|
284
|
+
*/
|
|
285
|
+
export declare const formatScreenTargetShortLine: (target: ScreenTarget) => string;
|
|
286
|
+
/**
|
|
287
|
+
* The `listScreens` answer: the targets whose line contains every word of the search text, capped. A screen names the
|
|
288
|
+
* values of its filters when the search is narrowed to at most {@link MAX_TARGETS_WITH_FILTER_VALUES} screens, and
|
|
289
|
+
* always when the search text is its key (it then comes first). A catalogue too long for full lines lists every
|
|
290
|
+
* screen in a short line instead of leaving screens out.
|
|
291
|
+
*/
|
|
243
292
|
export declare const formatScreenTargetList: (targets: ScreenTarget[], searchText: string) => string;
|
|
244
293
|
export declare const isClientToolToken: (value: unknown) => value is string;
|
|
245
294
|
/** The route of a target for the given record ids and tab; `null` when a record id is missing. */
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { AgentUIStateSource } from "./agent-ui-state";
|
|
2
2
|
import { AgentUIClient } from "./AgentUIClient";
|
|
3
3
|
import type { ScreenAdapters } from "./client-tools";
|
|
4
|
+
/**
|
|
5
|
+
* Adapters that always answer from the newest set an application passed (`readAdapters`): the runner keeps one object
|
|
6
|
+
* while the application may build a new one on every render. The optional adapters, and the navigator's optional
|
|
7
|
+
* methods of the screen actions (`currentTarget`, `applyFilters`), are present exactly when the newest set has them,
|
|
8
|
+
* so the runner's "this client cannot do that" answers stay true.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createLatestScreenAdapters: (readAdapters: () => ScreenAdapters) => ScreenAdapters;
|
|
4
11
|
/**
|
|
5
12
|
* One `AgentUIClient` per mount of the agent window: a stable client id and the runner of the delivered requests. The
|
|
6
13
|
* adapters are read through the latest render (a ref), so an application may pass a new object on every render. Hand
|