@mgamadeus/ddd-agents 0.15.4 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/dist/admin.js +258 -15
- package/dist/admin.js.map +1 -1
- package/dist/chat.js +221 -63
- package/dist/chat.js.map +1 -1
- package/dist/chunks/{agents-http-trace-mappers-BYEpNy0b.js → agents-http-trace-mappers-rsbGAf2_.js} +64 -14
- package/dist/chunks/agents-http-trace-mappers-rsbGAf2_.js.map +1 -0
- package/dist/chunks/{content-from-unified-diff-Dzsh8kR2.js → content-from-unified-diff-DWyBHRSy.js} +233 -63
- package/dist/chunks/content-from-unified-diff-DWyBHRSy.js.map +1 -0
- package/dist/chunks/{contract-IQHESBXq.js → contract-DtFmOk91.js} +5 -3
- package/dist/chunks/contract-DtFmOk91.js.map +1 -0
- package/dist/chunks/{conversation-B7-evdj_.js → conversation-Cbrqtx-_.js} +6 -2
- package/dist/chunks/{conversation-B7-evdj_.js.map → conversation-Cbrqtx-_.js.map} +1 -1
- package/dist/chunks/conversation-trace-fVeh6Lg6.js.map +1 -1
- package/dist/chunks/{withPollingChangeSubscription-XvCpjGmd.js → withPollingChangeSubscription-Cz3Diolr.js} +10 -2
- package/dist/chunks/withPollingChangeSubscription-Cz3Diolr.js.map +1 -0
- package/dist/client-testing.js +22 -2
- package/dist/client-testing.js.map +1 -1
- package/dist/client.js +23 -11
- package/dist/client.js.map +1 -1
- package/dist/contract.js +5 -3
- package/dist/files/i18n-keys.json +807 -13
- package/dist/styles.css +73 -1
- package/dist/types/admin/conversations/AgentConversationDetailScreen.d.ts +1 -1
- package/dist/types/admin/conversations/BackgroundJobsPanel.d.ts +28 -0
- package/dist/types/admin/conversations/agent-inspect-api.d.ts +13 -1
- package/dist/types/admin/conversations/agent-inspect-mappers.d.ts +3 -1
- package/dist/types/admin/conversations/agent-inspect-types.d.ts +45 -0
- package/dist/types/chat/controller/use-conversation-activity.d.ts +13 -1
- package/dist/types/chat/trace/ConversationTurnTrace.d.ts +4 -2
- package/dist/types/chat/trace/RunningBackgroundJobLines.d.ts +19 -0
- package/dist/types/chat/trace/StepKindDetails.d.ts +11 -1
- package/dist/types/chat/trace/ToolStepDetail.d.ts +2 -0
- package/dist/types/chat/trace/UntrustedContentText.d.ts +11 -0
- package/dist/types/chat/trace/index.d.ts +4 -2
- package/dist/types/chat/trace/running-background-jobs-context.d.ts +20 -0
- package/dist/types/chat/trace/trace-counts.d.ts +2 -0
- package/dist/types/chat/trace/trace-labels.d.ts +15 -2
- package/dist/types/chat/trace/trace-types.d.ts +22 -0
- package/dist/types/chat/trace/untrusted-content.d.ts +23 -0
- package/dist/types/client/AgentsConversationClient.d.ts +8 -1
- package/dist/types/client/http/agents-http-mappers.d.ts +8 -2
- package/dist/types/client/http/agents-http-trace-mappers.d.ts +4 -2
- package/dist/types/client/http/agents-http-trace-wire.d.ts +18 -0
- package/dist/types/client/http/agents-http-wire.d.ts +18 -0
- package/dist/types/client/testing/createInMemoryAgentsConversationClient.d.ts +6 -1
- package/dist/types/contract/conversation-trace.d.ts +30 -0
- package/dist/types/contract/conversation.d.ts +45 -0
- package/dist/types/entries/admin.d.ts +3 -2
- package/package.json +1 -1
- package/public-api.json +31 -0
- package/dist/chunks/agents-http-trace-mappers-BYEpNy0b.js.map +0 -1
- package/dist/chunks/content-from-unified-diff-Dzsh8kR2.js.map +0 -1
- package/dist/chunks/contract-IQHESBXq.js.map +0 -1
- package/dist/chunks/withPollingChangeSubscription-XvCpjGmd.js.map +0 -1
|
@@ -229,11 +229,29 @@ export interface WireAccountRealtimeMessagesResponse {
|
|
|
229
229
|
expiresAt?: string | null;
|
|
230
230
|
} | null;
|
|
231
231
|
}
|
|
232
|
+
/** `AgentBackgroundJob` as the activity answer carries it (without reference, workspace, outcome and call id). */
|
|
233
|
+
export interface WireBackgroundJob {
|
|
234
|
+
id?: number | null;
|
|
235
|
+
kind?: string | null;
|
|
236
|
+
label?: string | null;
|
|
237
|
+
state?: string | null;
|
|
238
|
+
liveStatus?: string | null;
|
|
239
|
+
liveNote?: string | null;
|
|
240
|
+
startedAt?: string | null;
|
|
241
|
+
deadlineAt?: string | null;
|
|
242
|
+
dueAt?: string | null;
|
|
243
|
+
}
|
|
232
244
|
/** `AIConversationActivityGetResponseDto`. */
|
|
233
245
|
export interface WireConversationActivityResponse {
|
|
234
246
|
turnMessageId?: number | null;
|
|
235
247
|
turnRunning?: boolean | null;
|
|
236
248
|
elements?: WireSet<WireActivityLine> | null;
|
|
249
|
+
runningBackgroundJobs?: WireSet<WireBackgroundJob> | null;
|
|
250
|
+
}
|
|
251
|
+
/** `AIConversationBackgroundJobStopPostResponseDto`. */
|
|
252
|
+
export interface WireBackgroundJobStopResponse {
|
|
253
|
+
isStopped?: boolean | null;
|
|
254
|
+
state?: string | null;
|
|
237
255
|
}
|
|
238
256
|
/** `AIConversationSearchGetResponseDto`. */
|
|
239
257
|
export interface WireConversationSearchResponse {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentsConversationClient, AgentsConversationOperation } from "../AgentsConversationClient";
|
|
2
|
-
import { type AgentsConversation, type AgentsConversationMessage, type ChangedConversationMessages, type ChangedMessagesRequest, type ConversationActivity, type ConversationAttachmentReference, type ConversationChangeSignal, type ConversationListQueryOptions, type ConversationMessageSearchHit, type ConversationMessageSentPayload, type ConversationMessagesPage, type ConversationRunStatus, type ConversationSearchGroup, type ConversationSearchOptions, type ConversationSignal, type ConversationSubscriptionEndReason, type PostedMessage, type SelectableModel, type StartedConversation } from "../../contract/conversation";
|
|
2
|
+
import { type AgentsConversation, type AgentsConversationMessage, type ChangedConversationMessages, type ChangedMessagesRequest, type ConversationActivity, type ConversationAttachmentReference, type ConversationBackgroundJobStop, type ConversationChangeSignal, type ConversationListQueryOptions, type ConversationMessageSearchHit, type ConversationMessageSentPayload, type ConversationMessagesPage, type ConversationRunStatus, type ConversationSearchGroup, type ConversationSearchOptions, type ConversationSignal, type ConversationSubscriptionEndReason, type PostedMessage, type SelectableModel, type StartedConversation } from "../../contract/conversation";
|
|
3
3
|
/** One recorded conversation handed to the in-memory client: plain data, as a fixture file holds it. */
|
|
4
4
|
export interface RecordedConversation {
|
|
5
5
|
conversation: AgentsConversation;
|
|
@@ -80,6 +80,11 @@ export declare class InMemoryAgentsConversationClient implements AgentsConversat
|
|
|
80
80
|
getChangedMessages: (conversationId: number, request: ChangedMessagesRequest) => Promise<ChangedConversationMessages>;
|
|
81
81
|
searchConversationMessages: (conversationId: number, text: string, options?: ConversationSearchOptions) => Promise<ConversationMessageSearchHit[]>;
|
|
82
82
|
getConversationActivity: (conversationId: number) => Promise<ConversationActivity>;
|
|
83
|
+
/**
|
|
84
|
+
* Stops a running job of the recorded activity like the server: it ends CANCELLED and leaves the running jobs (its
|
|
85
|
+
* end is reported). A job that is not RUNNING answers `isStopped` false with its state; an unknown one is `notFound`.
|
|
86
|
+
*/
|
|
87
|
+
stopBackgroundJob: (conversationId: number, backgroundJobId: number) => Promise<ConversationBackgroundJobStop>;
|
|
83
88
|
startConversation: (request: {
|
|
84
89
|
agentSpaceKey: number;
|
|
85
90
|
text: string;
|
|
@@ -433,6 +433,32 @@ export interface ConversationTraceMessage {
|
|
|
433
433
|
/** Such a message: the platform note that handed it to the model. */
|
|
434
434
|
foldSignalMessageId?: number | null;
|
|
435
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* The background job a tool call started (`AgentTraceBackgroundJob`), at the step of that call: its state, deadline
|
|
438
|
+
* and checks. Its end is the signal step of its notification.
|
|
439
|
+
*/
|
|
440
|
+
export interface ConversationTraceBackgroundJob {
|
|
441
|
+
/** The job's number (`#12`). */
|
|
442
|
+
id: number;
|
|
443
|
+
/** The provider's key (`sandbox.exec`, `timer`, …). */
|
|
444
|
+
kind: string | null;
|
|
445
|
+
label: string;
|
|
446
|
+
/** `RUNNING`, `SUCCEEDED`, `FAILED`, `TIMED_OUT`, `CANCELLED` or `LOST`, as the server stores it. */
|
|
447
|
+
state: string | null;
|
|
448
|
+
/** The last reading while it runs: `RUNNING` or `WAITING_FOR_HOST`. */
|
|
449
|
+
liveStatus: string | null;
|
|
450
|
+
startedAt: string | null;
|
|
451
|
+
endedAt: string | null;
|
|
452
|
+
deadlineAt: string | null;
|
|
453
|
+
/** The known end of a wake-up. */
|
|
454
|
+
dueAt: string | null;
|
|
455
|
+
/** The checks made so far. */
|
|
456
|
+
checkCount: number;
|
|
457
|
+
lastCheckedAt: string | null;
|
|
458
|
+
/** How its end was reported (`NOTIFICATION`, `OWNER_STOP`, `TURN_STOP`, …); null while unreported. */
|
|
459
|
+
reportKind: string | null;
|
|
460
|
+
reportedAt: string | null;
|
|
461
|
+
}
|
|
436
462
|
/** One step of a turn. */
|
|
437
463
|
export interface ConversationTraceStep {
|
|
438
464
|
/** A key that is stable within the turn: the server's step id, else the row's message id, its kind and its position. */
|
|
@@ -457,6 +483,10 @@ export interface ConversationTraceStep {
|
|
|
457
483
|
backgroundOperationName?: string | null;
|
|
458
484
|
/** That step: the stable id of the job, `<operation>:<tool name>` or the operation. */
|
|
459
485
|
backgroundJobKey?: string | null;
|
|
486
|
+
/** A tool call that started a background job (a command still running after the detach window, a wake-up): that job. */
|
|
487
|
+
backgroundJob?: ConversationTraceBackgroundJob | null;
|
|
488
|
+
/** The platform-written result row of a detached call: the job whose result it carries (no call of the model). */
|
|
489
|
+
resultOfBackgroundJobId?: number | null;
|
|
460
490
|
startedAt: string | null;
|
|
461
491
|
durationMs: number | null;
|
|
462
492
|
/** The narrated activity line, as the owner read it; null when none was narrated. */
|
|
@@ -389,6 +389,46 @@ export interface ConversationActivityElement {
|
|
|
389
389
|
/** generic — the sentence; null while the narrator has not answered */
|
|
390
390
|
line: string | null;
|
|
391
391
|
}
|
|
392
|
+
/** The states of a background job (`AgentBackgroundJob::STATES`). */
|
|
393
|
+
export declare const CONVERSATION_BACKGROUND_JOB_STATES: readonly ["RUNNING", "SUCCEEDED", "FAILED", "TIMED_OUT", "CANCELLED", "LOST"];
|
|
394
|
+
/** One state of a background job. */
|
|
395
|
+
export type ConversationBackgroundJobState = (typeof CONVERSATION_BACKGROUND_JOB_STATES)[number];
|
|
396
|
+
/** The last reading of a running background job (`AgentBackgroundJob::LIVE_STATUSES`). */
|
|
397
|
+
export declare const CONVERSATION_BACKGROUND_JOB_LIVE_STATUSES: readonly ["RUNNING", "WAITING_FOR_HOST"];
|
|
398
|
+
/** One live status of a background job. */
|
|
399
|
+
export type ConversationBackgroundJobLiveStatus = (typeof CONVERSATION_BACKGROUND_JOB_LIVE_STATUSES)[number];
|
|
400
|
+
/**
|
|
401
|
+
* A background job of the conversation whose end is not reported yet (`AgentBackgroundJob`, as the activity answer
|
|
402
|
+
* carries it): a command still running after the detach window, a wake-up the agent set. Its end arrives in the
|
|
403
|
+
* conversation as a notification by itself.
|
|
404
|
+
*/
|
|
405
|
+
export interface ConversationBackgroundJob {
|
|
406
|
+
/** generic — the job's number (`#12`), the key of its line and of its stop */
|
|
407
|
+
id: number;
|
|
408
|
+
/** generic — the provider's key (`sandbox.exec`, `timer`, …) */
|
|
409
|
+
kind: string | null;
|
|
410
|
+
/** generic — what runs, as the agent named it; data, never translated */
|
|
411
|
+
label: string;
|
|
412
|
+
/** generic — RUNNING while the work runs (or its outcome is still being collected) */
|
|
413
|
+
state: ConversationBackgroundJobState | null;
|
|
414
|
+
/** generic — the last reading; WAITING_FOR_HOST: the work waits for the host; null before the first reading */
|
|
415
|
+
liveStatus: ConversationBackgroundJobLiveStatus | null;
|
|
416
|
+
/** generic — the note of the last reading */
|
|
417
|
+
liveNote: string | null;
|
|
418
|
+
/** generic — a server date-time */
|
|
419
|
+
startedAt: string | null;
|
|
420
|
+
/** generic — after it the job ends TIMED_OUT */
|
|
421
|
+
deadlineAt: string | null;
|
|
422
|
+
/** generic — the known end of a wake-up; null for work without one */
|
|
423
|
+
dueAt: string | null;
|
|
424
|
+
}
|
|
425
|
+
/** The answer of the owner's stop of one background job (`POST …/{id}/backgroundJobs/{jobId}/stop`). */
|
|
426
|
+
export interface ConversationBackgroundJobStop {
|
|
427
|
+
/** generic — this call stopped the job; false when it had ended or was reported before */
|
|
428
|
+
isStopped: boolean;
|
|
429
|
+
/** generic — the state of the job after the call, as the server stores it; null when it names none */
|
|
430
|
+
state: ConversationBackgroundJobState | null;
|
|
431
|
+
}
|
|
392
432
|
/** The activity of one turn (`GET …/activity`). */
|
|
393
433
|
export interface ConversationActivity {
|
|
394
434
|
/** generic — the message that started the narrated turn */
|
|
@@ -397,6 +437,11 @@ export interface ConversationActivity {
|
|
|
397
437
|
turnRunning: boolean;
|
|
398
438
|
/** generic */
|
|
399
439
|
elements: ConversationActivityElement[];
|
|
440
|
+
/**
|
|
441
|
+
* generic — the background jobs of the conversation whose end is not reported yet, oldest first, whatever the turn
|
|
442
|
+
* (a job runs on after the turn that started it answered); empty without any
|
|
443
|
+
*/
|
|
444
|
+
runningBackgroundJobs: ConversationBackgroundJob[];
|
|
400
445
|
}
|
|
401
446
|
/** A model the owner (host application: an impersonating admin) may pick for the next turns (`AgentCustomerSelectableModel`). */
|
|
402
447
|
export interface SelectableModel {
|
|
@@ -57,8 +57,8 @@ export { AGENT_QUALITY_EVAL_RUN_URL_KEYS, AgentQualityEvalRunScreen, type AgentQ
|
|
|
57
57
|
export { AGENT_QUALITY_URL_KEYS, AgentQualityScreen, type AgentQualityScreenProps, EvalRunCounts } from "../admin/quality/AgentQualityScreen";
|
|
58
58
|
export { SaveAsEvalCaseDialog, type SaveAsEvalCaseDialogProps } from "../admin/quality/SaveAsEvalCaseDialog";
|
|
59
59
|
export { AGENT_INSPECT_TAG, type AgentInspectApi, agentInspectEndpointDefinitions, buildAgentInspectListQuery, buildAgentInspectRequests, createAgentInspectApi, type CreateAgentInspectApiOptions, createStaticAgentInspectApi, type StaticAgentInspectData, } from "../admin/conversations/agent-inspect-api";
|
|
60
|
-
export { mapAgentInspectCompactionNode, mapAgentInspectDelegationTree, mapAgentInspectFileChange, mapAgentInspectFileChanges, mapAgentInspectWorkedSubject, mapAgentInspectWorkedSubjects, shortAgentInspectSubjectClass, mapAgentInspectSandboxChronicle, mapAgentInspectStep, mapAgentInspectSubAgent, mapAgentInspectTrace, mapAgentInspectTurn, } from "../admin/conversations/agent-inspect-mappers";
|
|
61
|
-
export { AGENT_INSPECT_ORIGINS, AGENT_INSPECT_RUN_STATES, AGENT_INSPECT_SEGMENTS, type AgentInspectCompactionNode, type AgentInspectCompactionNodesResponse, type AgentInspectDecision, type AgentInspectConversationArg, type AgentInspectConversationHeader, type AgentInspectConversationResponse, type AgentInspectConversationsResponse, type AgentInspectDelegationBatch, type AgentInspectDelegationsResponse, type AgentInspectDelegationTree, type AgentInspectDriveArg, type AgentInspectDriveResponse, type AgentInspectedConversation, type AgentInspectFileChange, type AgentInspectFileChangeArg, type AgentInspectFileChangeDiffResponse, type AgentInspectFileChangesResponse, type AgentInspectWorkedSubject, type AgentInspectWorkedSubjectsArg, type AgentInspectWorkedSubjectsResponse, type AgentInspectLabel, type AgentInspectListArg, type AgentInspectMessageRouteArg, type AgentInspectMetric, type AgentInspectMetrics, type AgentInspectMetricsResponse, type AgentInspectModelCallFacts, type AgentInspectRunControlResponse, type AgentInspectRunSettingsArg, type AgentInspectRunSettingsOverride, type AgentInspectRunSettingsResponse, type AgentInspectRunState, type AgentInspectSandboxChronicle, type AgentInspectSandboxEntry, type AgentInspectSandboxResponse, type AgentInspectSegment, type AgentInspectStep, type AgentInspectSubAgent, type AgentInspectToolCallReplay, type AgentInspectToolCallReplayResponse, type AgentInspectToolCallResultResponse, type AgentInspectTouchedFile, type AgentInspectTouchedMount, type AgentInspectTrace, type AgentInspectTraceArg, type AgentInspectTraceResponse, type AgentInspectTruncateArg, type AgentInspectTruncateResponse, type AgentInspectTurn, type AgentInspectWaitingWindow, } from "../admin/conversations/agent-inspect-types";
|
|
60
|
+
export { mapAgentInspectBackgroundJobs, mapAgentInspectCompactionNode, mapAgentInspectDelegationTree, mapAgentInspectFileChange, mapAgentInspectFileChanges, mapAgentInspectWorkedSubject, mapAgentInspectWorkedSubjects, shortAgentInspectSubjectClass, mapAgentInspectSandboxChronicle, mapAgentInspectStep, mapAgentInspectSubAgent, mapAgentInspectTrace, mapAgentInspectTurn, } from "../admin/conversations/agent-inspect-mappers";
|
|
61
|
+
export { AGENT_INSPECT_ORIGINS, AGENT_INSPECT_RUN_STATES, AGENT_INSPECT_SEGMENTS, type AgentInspectBackgroundJob, type AgentInspectBackgroundJobOutcome, type AgentInspectBackgroundJobsResponse, type AgentInspectCompactionNode, type AgentInspectCompactionNodesResponse, type AgentInspectDecision, type AgentInspectConversationArg, type AgentInspectConversationHeader, type AgentInspectConversationResponse, type AgentInspectConversationsResponse, type AgentInspectDelegationBatch, type AgentInspectDelegationsResponse, type AgentInspectDelegationTree, type AgentInspectDriveArg, type AgentInspectDriveResponse, type AgentInspectedConversation, type AgentInspectFileChange, type AgentInspectFileChangeArg, type AgentInspectFileChangeDiffResponse, type AgentInspectFileChangesResponse, type AgentInspectWorkedSubject, type AgentInspectWorkedSubjectsArg, type AgentInspectWorkedSubjectsResponse, type AgentInspectLabel, type AgentInspectListArg, type AgentInspectMessageRouteArg, type AgentInspectMetric, type AgentInspectMetrics, type AgentInspectMetricsResponse, type AgentInspectModelCallFacts, type AgentInspectRunControlResponse, type AgentInspectRunSettingsArg, type AgentInspectRunSettingsOverride, type AgentInspectRunSettingsResponse, type AgentInspectRunState, type AgentInspectSandboxChronicle, type AgentInspectSandboxEntry, type AgentInspectSandboxResponse, type AgentInspectSegment, type AgentInspectStep, type AgentInspectSubAgent, type AgentInspectToolCallReplay, type AgentInspectToolCallReplayResponse, type AgentInspectToolCallResultResponse, type AgentInspectTouchedFile, type AgentInspectTouchedMount, type AgentInspectTrace, type AgentInspectTraceArg, type AgentInspectTraceResponse, type AgentInspectTruncateArg, type AgentInspectTruncateResponse, type AgentInspectTurn, type AgentInspectWaitingWindow, } from "../admin/conversations/agent-inspect-types";
|
|
62
62
|
export { AGENT_CONVERSATION_DETAIL_KEYS, buildAgentConversationSandboxQuery, AGENT_CONVERSATION_DETAIL_TABS, AgentConversationDetailScreen, type AgentConversationDetailScreenProps, type AgentConversationDetailTab, } from "../admin/conversations/AgentConversationDetailScreen";
|
|
63
63
|
export { AGENT_CONVERSATION_COLUMN_IDS, AGENT_CONVERSATIONS_MAX_PAGE_SIZE, AgentConversationsScreen, type AgentConversationsScreenProps, } from "../admin/conversations/AgentConversationsScreen";
|
|
64
64
|
export { AGENT_INSPECT_DEBUG_SWITCH_DEFAULTS, AGENT_INSPECT_DEBUG_SWITCH_NAMES, type AgentInspectDebugSwitchName, type AgentInspectDebugSwitches, applyAgentInspectDebugSwitches, readAgentInspectDebugSwitches, writeAgentInspectDebugSwitches, } from "../admin/conversations/debug-switches";
|
|
@@ -68,6 +68,7 @@ export { AGENT_LIVE_RUN_STATES, AGENT_ORIGIN_CONTEXT, AGENT_ORIGIN_LABELS, AGENT
|
|
|
68
68
|
export { AgentTraceFrame, type AgentTraceFrameAttributes, type AgentTraceFrameProps, LiveDot, } from "../admin/conversations/inspect-parts";
|
|
69
69
|
export { type AgentInspectActions, type AgentInspectFilePreviewOptions, type AgentInspectFileSelection, type AgentInspectRenderFilePreview, type AgentInspectSubjectFilter, } from "../admin/conversations/inspect-scope";
|
|
70
70
|
export { readSubjectFilter, subjectKindLabelOf, writeSubjectFilter } from "../admin/conversations/WorkedRecordsPanel";
|
|
71
|
+
export { AGENT_BACKGROUND_JOB_REPORT_CONTEXT, AGENT_BACKGROUND_JOB_REPORT_KIND_LABELS, AGENT_BACKGROUND_JOB_STATE, AGENT_BACKGROUND_JOB_STATE_CONTEXT, } from "../admin/conversations/BackgroundJobsPanel";
|
|
71
72
|
export { buildTouchedFilesNodes, buildTouchedFilesTree, findTouchedFile, flattenTouchedFilesNodes, touchedFileKeyOf, type TouchedFilesDirectoryNode, type TouchedFilesFileNode, type TouchedFilesMountGroup, type TouchedFilesNode, type TouchedFilesRow, touchedMountKeyOf, } from "../admin/conversations/touched-files-tree";
|
|
72
73
|
export { AGENT_INSPECT_TURN_PAGE_SIZE, type AgentInspectModelCallReference, type AgentInspectTurnWindow, collectAgentInspectModelCalls, mergeAgentInspectTraces, mergeAgentInspectTurns, newestAgentInspectModelCallMessageId, previousAgentInspectTurnWindow, } from "../admin/conversations/turn-paging";
|
|
73
74
|
export { buildTurnTimeline, type TurnTimeline, type TurnTimelineSegment, type TurnTimelineSegmentKind, } from "../admin/conversations/turn-timeline";
|
package/package.json
CHANGED
package/public-api.json
CHANGED
|
@@ -500,6 +500,8 @@
|
|
|
500
500
|
"AGENTS_CLIENT_CONTEXT_LIMITS",
|
|
501
501
|
"AGENTS_CLIENT_ERROR_CODE_REQUEST_ABORTED",
|
|
502
502
|
"AgentsClientError",
|
|
503
|
+
"CONVERSATION_BACKGROUND_JOB_LIVE_STATUSES",
|
|
504
|
+
"CONVERSATION_BACKGROUND_JOB_STATES",
|
|
503
505
|
"CONVERSATION_RUN_STATES_THAT_END_THE_CONVERSATION",
|
|
504
506
|
"CONVERSATION_TRACE_LEVELS",
|
|
505
507
|
"buildChangedMessagesRequest",
|
|
@@ -517,6 +519,10 @@
|
|
|
517
519
|
"ConversationActivity",
|
|
518
520
|
"ConversationActivityElement",
|
|
519
521
|
"ConversationAttachmentReference",
|
|
522
|
+
"ConversationBackgroundJob",
|
|
523
|
+
"ConversationBackgroundJobLiveStatus",
|
|
524
|
+
"ConversationBackgroundJobState",
|
|
525
|
+
"ConversationBackgroundJobStop",
|
|
520
526
|
"ConversationChangeSignal",
|
|
521
527
|
"ConversationContextComposition",
|
|
522
528
|
"ConversationContextSegment",
|
|
@@ -546,6 +552,7 @@
|
|
|
546
552
|
"ConversationSubject",
|
|
547
553
|
"ConversationSubscriptionEndReason",
|
|
548
554
|
"ConversationToolCall",
|
|
555
|
+
"ConversationTraceBackgroundJob",
|
|
549
556
|
"ConversationTraceCompaction",
|
|
550
557
|
"ConversationTraceDecision",
|
|
551
558
|
"ConversationTraceDecisionProbability",
|
|
@@ -603,6 +610,8 @@
|
|
|
603
610
|
"createPollingConversationChangeSubscription",
|
|
604
611
|
"mapClientContextToWire",
|
|
605
612
|
"mapHttpFailureToAgentsClientError",
|
|
613
|
+
"mapWireBackgroundJob",
|
|
614
|
+
"mapWireBackgroundJobStop",
|
|
606
615
|
"mapWireBoundConversationSubject",
|
|
607
616
|
"mapWireContextComposition",
|
|
608
617
|
"mapWireConversation",
|
|
@@ -610,9 +619,11 @@
|
|
|
610
619
|
"mapWireConversationMessage",
|
|
611
620
|
"mapWireConversationRunState",
|
|
612
621
|
"mapWireFileChangeDiff",
|
|
622
|
+
"mapWireRunningBackgroundJobs",
|
|
613
623
|
"mapWireSearchGroup",
|
|
614
624
|
"mapWireSearchHit",
|
|
615
625
|
"mapWireSelectableModel",
|
|
626
|
+
"mapWireTraceBackgroundJob",
|
|
616
627
|
"mapWireTraceFileChange",
|
|
617
628
|
"mapWireTraceMessage",
|
|
618
629
|
"mapWireTraceStep",
|
|
@@ -645,6 +656,8 @@
|
|
|
645
656
|
"PollingTimers",
|
|
646
657
|
"WireAccountRealtimeMessagesResponse",
|
|
647
658
|
"WireActivityLine",
|
|
659
|
+
"WireBackgroundJob",
|
|
660
|
+
"WireBackgroundJobStopResponse",
|
|
648
661
|
"WireBoundConversationSubject",
|
|
649
662
|
"WireBoundConversationSubjectsResponse",
|
|
650
663
|
"WireChangeHistory",
|
|
@@ -680,6 +693,7 @@
|
|
|
680
693
|
"WireSemanticSearchHit",
|
|
681
694
|
"WireSet",
|
|
682
695
|
"WireToolCall",
|
|
696
|
+
"WireTraceBackgroundJob",
|
|
683
697
|
"WireTraceCompaction",
|
|
684
698
|
"WireTraceDecision",
|
|
685
699
|
"WireTraceEntityReference",
|
|
@@ -741,6 +755,7 @@
|
|
|
741
755
|
"AgentChatController",
|
|
742
756
|
"AgentsChatStateContainer",
|
|
743
757
|
"AgentsChatStoreProvider",
|
|
758
|
+
"BackgroundJobFacts",
|
|
744
759
|
"BackgroundTasksList",
|
|
745
760
|
"CanvasPane",
|
|
746
761
|
"CanvasRestoreOnMount",
|
|
@@ -780,6 +795,8 @@
|
|
|
780
795
|
"PHONE_CALL_LIFECYCLE_SIGNAL_SOURCES",
|
|
781
796
|
"QueuedMessageChip",
|
|
782
797
|
"RunStatusLine",
|
|
798
|
+
"RunningBackgroundJobLines",
|
|
799
|
+
"RunningBackgroundJobsContext",
|
|
783
800
|
"SIGNAL_SOURCES_THAT_OWE_NO_WORK",
|
|
784
801
|
"SUCCESS_BEAT_MS",
|
|
785
802
|
"SignalDetail",
|
|
@@ -830,6 +847,7 @@
|
|
|
830
847
|
"createTraceFormat",
|
|
831
848
|
"defaultTraceViewModeOfPolicy",
|
|
832
849
|
"deriveAgentActivity",
|
|
850
|
+
"describeBackgroundJobState",
|
|
833
851
|
"describeChangedFieldName",
|
|
834
852
|
"describeChangedRecord",
|
|
835
853
|
"describeSubAgentCounts",
|
|
@@ -896,6 +914,7 @@
|
|
|
896
914
|
"useMessageTimeFormat",
|
|
897
915
|
"useOptionalAgentsChatStore",
|
|
898
916
|
"useOptionalAgentsConversationClient",
|
|
917
|
+
"useRunningBackgroundJobs",
|
|
899
918
|
"useTraceFormat"
|
|
900
919
|
],
|
|
901
920
|
"types": [
|
|
@@ -920,6 +939,7 @@
|
|
|
920
939
|
"AgentsChatState",
|
|
921
940
|
"AgentsChatStore",
|
|
922
941
|
"AssistantServerMessagePayload",
|
|
942
|
+
"BackgroundJobFactsProps",
|
|
923
943
|
"BackgroundTask",
|
|
924
944
|
"BackgroundTaskType",
|
|
925
945
|
"BackgroundTasksListProps",
|
|
@@ -973,6 +993,8 @@
|
|
|
973
993
|
"QueuedMessageChipProps",
|
|
974
994
|
"ResolvedAgentChatActivityTiming",
|
|
975
995
|
"RunStatusLineProps",
|
|
996
|
+
"RunningBackgroundJobLinesProps",
|
|
997
|
+
"RunningBackgroundJobsContextValue",
|
|
976
998
|
"SendMessageHandler",
|
|
977
999
|
"SendMessageOptions",
|
|
978
1000
|
"SideBySideDiffRow",
|
|
@@ -997,6 +1019,7 @@
|
|
|
997
1019
|
"ToolStepDetailProps",
|
|
998
1020
|
"ToolStepGroupProps",
|
|
999
1021
|
"ToolStepRowProps",
|
|
1022
|
+
"TraceBackgroundJob",
|
|
1000
1023
|
"TraceChangedRecord",
|
|
1001
1024
|
"TraceCodePanelProps",
|
|
1002
1025
|
"TraceCompaction",
|
|
@@ -1606,6 +1629,10 @@
|
|
|
1606
1629
|
"values": [
|
|
1607
1630
|
"ADMIN_PERIOD_MAX_DAYS",
|
|
1608
1631
|
"ADMIN_PERIOD_PRESETS",
|
|
1632
|
+
"AGENT_BACKGROUND_JOB_REPORT_CONTEXT",
|
|
1633
|
+
"AGENT_BACKGROUND_JOB_REPORT_KIND_LABELS",
|
|
1634
|
+
"AGENT_BACKGROUND_JOB_STATE",
|
|
1635
|
+
"AGENT_BACKGROUND_JOB_STATE_CONTEXT",
|
|
1609
1636
|
"AGENT_CONNECTIONS_PAGE_SURFACE",
|
|
1610
1637
|
"AGENT_CONNECTIONS_TAG",
|
|
1611
1638
|
"AGENT_CONNECTIONS_URL_KEYS",
|
|
@@ -1933,6 +1960,7 @@
|
|
|
1933
1960
|
"jsonChildCountOf",
|
|
1934
1961
|
"jsonChildEntriesOf",
|
|
1935
1962
|
"jsonValueKindOf",
|
|
1963
|
+
"mapAgentInspectBackgroundJobs",
|
|
1936
1964
|
"mapAgentInspectCompactionNode",
|
|
1937
1965
|
"mapAgentInspectDelegationTree",
|
|
1938
1966
|
"mapAgentInspectFileChange",
|
|
@@ -2152,6 +2180,9 @@
|
|
|
2152
2180
|
"AgentDecisionWords",
|
|
2153
2181
|
"AgentInspectActions",
|
|
2154
2182
|
"AgentInspectApi",
|
|
2183
|
+
"AgentInspectBackgroundJob",
|
|
2184
|
+
"AgentInspectBackgroundJobOutcome",
|
|
2185
|
+
"AgentInspectBackgroundJobsResponse",
|
|
2155
2186
|
"AgentInspectCompactionNode",
|
|
2156
2187
|
"AgentInspectCompactionNodesResponse",
|
|
2157
2188
|
"AgentInspectContextApi",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agents-http-trace-mappers-BYEpNy0b.js","sources":["../../src/client/http/agents-http-mappers.ts","../../src/client/http/agents-http-trace-mappers.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 createdAt: readStringOrNull(wireMessage.changeHistory?.createdTime),\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 ConversationContextComposition,\n ConversationContextSegment,\n ConversationFileChange,\n ConversationFileChangeDiff,\n ConversationFileChangeDiffState,\n ConversationFileChangeType,\n ConversationTraceCompaction,\n ConversationTraceDecision,\n ConversationTraceDecisionProbability,\n ConversationTraceEntityReference,\n ConversationTraceFieldChange,\n ConversationTraceLevel,\n ConversationTraceViewPolicy,\n ConversationTraceLoadedSkill,\n ConversationTraceLoadedSkillTool,\n ConversationTraceMessage,\n ConversationTraceModelCall,\n ConversationTraceRecordChange,\n ConversationTraceRecordChangeOperation,\n ConversationTraceRefusalReason,\n ConversationTraceSignal,\n ConversationTraceSkillLoad,\n ConversationTraceSkillLoadEntry,\n ConversationTraceStep,\n ConversationTraceStepKind,\n ConversationTraceStepStatus,\n ConversationTraceSubAgent,\n ConversationTraceSubAgentRun,\n ConversationTraceSubAgentTaskKind,\n ConversationTraceTaskPlanItem,\n ConversationTraceTaskPlanRejection,\n ConversationTraceTerminal,\n ConversationTraceToolEffect,\n ConversationTraceWidget,\n ConversationTraceWindowMode,\n ConversationTurnStop,\n ConversationTurnTrace,\n ConversationTurnTraces,\n ConversationTurnTraceTotals,\n} from \"../../contract/conversation-trace\";\nimport { CONVERSATION_TRACE_LEVELS } from \"../../contract/conversation-trace\";\nimport { readWireSetElements } from \"./agents-http-mappers\";\nimport type {\n WireContextComposition,\n WireContextCompositionResponse,\n WireContextSegment,\n WireFileChangeDiffResponse,\n WireTurnStopResponse,\n WireTraceCompaction,\n WireTraceDecision,\n WireTraceFieldChange,\n WireTraceFileChange,\n WireTraceLoadedSkill,\n WireTraceMessage,\n WireTraceModelCall,\n WireTraceRecordChange,\n WireTraceRecordChanges,\n WireTraceSkillLoad,\n WireTraceSkillLoadEntry,\n WireTraceStep,\n WireTraceSubAgent,\n WireTraceSubAgentRun,\n WireTraceTaskPlanItem,\n WireTraceTaskPlanItemDeclaration,\n WireTraceTaskPlanRejection,\n WireTraceTerminal,\n WireTraceWidget,\n WireTurnTrace,\n WireTurnTraces,\n WireTurnTracesResponse,\n WireTurnTraceTotals,\n} from \"./agents-http-trace-wire\";\n\n// The mappers of the trace routes. They are tolerant on purpose: a field the server does not send reads as null (or\n// false, or an empty list), a value outside a vocabulary reads as null, a field the binding does not know is ignored.\n\nconst TRACE_LEVELS: readonly ConversationTraceLevel[] = CONVERSATION_TRACE_LEVELS;\n\n/**\n * The server's `AgentTraceViewPolicy` (`traceViewPolicy` of a conversation or trace read) as the contract's policy;\n * null when absent or without a known maximum. The default never exceeds the maximum; a policy that allows one level\n * shows no switch, whatever the wire says.\n */\nexport const mapWireTraceViewPolicy = (wirePolicy: unknown): ConversationTraceViewPolicy | null => {\n if (wirePolicy === null || typeof wirePolicy !== \"object\") return null;\n const fields = wirePolicy as { maxDetailLevel?: unknown; defaultDetailLevel?: unknown; isSwitchShown?: unknown };\n const maxDetailLevel = readVocabularyValue(TRACE_LEVELS, typeof fields.maxDetailLevel === \"string\" ? fields.maxDetailLevel : null);\n if (maxDetailLevel === null) return null;\n const requestedDefault = readVocabularyValue(TRACE_LEVELS, typeof fields.defaultDetailLevel === \"string\" ? fields.defaultDetailLevel : null);\n const defaultDetailLevel =\n requestedDefault !== null && TRACE_LEVELS.indexOf(requestedDefault) <= TRACE_LEVELS.indexOf(maxDetailLevel) ? requestedDefault : maxDetailLevel;\n const isSwitchShown = maxDetailLevel !== \"RESULT\" && fields.isSwitchShown !== false;\n return { maxDetailLevel, defaultDetailLevel, isSwitchShown };\n};\nconst TRACE_WINDOW_MODES: readonly ConversationTraceWindowMode[] = [\"NEWEST\", \"FROM_TURN\", \"FOLLOW_UP\"];\nconst STEP_KINDS: readonly ConversationTraceStepKind[] = [\n \"THINKING\",\n \"MODEL_CALL\",\n \"TOOL_CALL\",\n \"SKILL_LOAD\",\n \"SUB_AGENT\",\n \"WIDGET\",\n \"COMPACTION\",\n \"SIGNAL\",\n \"DECISION\",\n \"TASK_PLAN\",\n \"ERROR\",\n];\nconst TOOL_EFFECTS: readonly ConversationTraceToolEffect[] = [\"READ\", \"WORKSPACE\", \"WRITE\", \"DELETE\"];\nconst STEP_STATUSES: readonly ConversationTraceStepStatus[] = [\n \"PENDING\",\n \"RUNNING\",\n \"COMPLETED\",\n \"FAILED\",\n \"CANCEL_REQUESTED\",\n \"CANCELLED\",\n \"ERROR\",\n \"REFUSED\",\n];\nconst REFUSAL_REASONS: readonly ConversationTraceRefusalReason[] = [\"turnAnswersOwner\", \"ownerWroteDuringTurn\", \"noSubAgentRunning\", \"other\"];\nconst SUB_AGENT_TASK_KINDS: readonly ConversationTraceSubAgentTaskKind[] = [\"agent\", \"toolRun\", \"awaitedRun\"];\nconst FILE_CHANGE_TYPES: readonly ConversationFileChangeType[] = [\"ADDED\", \"MODIFIED\", \"DELETED\", \"RENAMED\", \"DIRECTORY_CREATED\"];\nconst DIFF_STATES: readonly ConversationFileChangeDiffState[] = [\"NONE\", \"INLINE\", \"STORED\", \"BINARY\", \"TOO_LARGE\", \"UNAVAILABLE\"];\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\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** The same check for a value whose wire shape is known: the shape stays, null and a non-object are ruled out. */\nconst isWireObject = <Wire extends object>(value: Wire | null | undefined): value is Wire => isPlainObject(value);\n\n/** A list of strings from a set, an array or a comma-separated text. */\nconst readStringList = (value: unknown): string[] => {\n if (typeof value === \"string\") return value.split(\",\").map((part) => part.trim()).filter((part) => part !== \"\");\n if (!isPlainObject(value) && !Array.isArray(value)) return [];\n return readWireSetElements(value as string[]).filter((element): element is string => typeof element === \"string\");\n};\n\nconst mapWireTraceModelCall = (wireModelCall: WireTraceModelCall | null | undefined): ConversationTraceModelCall | null =>\n isPlainObject(wireModelCall)\n ? {\n modelName: readStringOrNull(wireModelCall.modelName),\n effort: readStringOrNull(wireModelCall.reasoningEffort),\n inputTokens: readNumberOrNull(wireModelCall.inputTokens),\n outputTokens: readNumberOrNull(wireModelCall.outputTokens),\n cachedInputTokens: readNumberOrNull(wireModelCall.cachedInputTokens),\n cachePercent: readNumberOrNull(wireModelCall.cachePercent),\n costInUsd: readNumberOrNull(wireModelCall.costInUSD ?? wireModelCall.costInUsd),\n reasoningTokens: readNumberOrNull(wireModelCall.reasoningTokens),\n cacheWriteTokens: readNumberOrNull(wireModelCall.cacheWriteTokens),\n wireApi: readStringOrNull(wireModelCall.wireApi),\n forcedToolChoice: readStringOrNull(wireModelCall.forcedToolChoice ?? wireModelCall.forceToolChoice),\n providerCallMs: readNumberOrNull(wireModelCall.providerCallMs),\n loopOverheadMs: readNumberOrNull(wireModelCall.loopOverheadMs),\n hasStoredPayload: wireModelCall.hasStoredPayload === true,\n contextMessageId: readNumberOrNull(wireModelCall.contextMessageId),\n callNumberInTurn: readNumberOrNull(wireModelCall.callNumberInTurn),\n toolNames: readStringList(wireModelCall.toolNames),\n stopReason: readStringOrNull(wireModelCall.stopReason),\n toolDelivery: readStringOrNull(wireModelCall.toolDelivery),\n retryCount: readNumberOrNull(wireModelCall.retryCount),\n }\n : null;\n\n/** A JSON text from a field that carries text, or an object the server did not encode. */\nconst readJsonTextOrNull = (value: unknown): string | null => {\n if (typeof value === \"string\") return value === \"\" ? null : value;\n if (isPlainObject(value) || Array.isArray(value)) return JSON.stringify(value);\n return null;\n};\n\n/** The probabilities of a decision (name → probability), highest first. */\nconst readDecisionProbabilities = (value: unknown): ConversationTraceDecisionProbability[] =>\n isPlainObject(value)\n ? Object.entries(value)\n .filter((entry): entry is [string, number] => typeof entry[1] === \"number\" && Number.isFinite(entry[1]))\n .map(([name, probability]) => ({ name, probability }))\n .sort((left, right) => right.probability - left.probability)\n : [];\n\n/**\n * The decision of a `DECISION` step. The server's `decision` object is read as it is. A server that sends only the\n * stored event (`eventSite`, `eventPayloadExcerpt`) still names the decision: its site, and from the payload's start\n * who decided and whether the loop acted on it; the payload is what the loop resolved (`outcomeJson`).\n */\nconst mapWireTraceDecision = (wireStep: WireTraceStep): ConversationTraceDecision | null => {\n const wireDecision: WireTraceDecision | null = isWireObject(wireStep.decision) ? wireStep.decision : null;\n const eventSite = readStringOrNull(wireStep.eventSite);\n const eventPayload = readStringOrNull(wireStep.eventPayloadExcerpt);\n if (wireDecision === null && eventSite === null && eventPayload === null) return null;\n // The excerpt may be cut in the middle of its JSON: the two facts are read by their names, not by parsing it.\n const decidedBy = readStringOrNull(wireDecision?.decidedBy) ?? (eventPayload === null ? null : (/\"decidedBy\"\\s*:\\s*\"([^\"]*)\"/.exec(eventPayload)?.[1] ?? null));\n const appliedFlag = eventPayload === null ? null : (/\"applied\"\\s*:\\s*(true|false)/.exec(eventPayload)?.[1] ?? null);\n const isApplied = wireDecision?.isApplied === true || (wireDecision?.isApplied == null && appliedFlag === \"true\");\n const isFallback = decidedBy !== null && decidedBy.startsWith(\"fallback\");\n const derivedStatus = isFallback ? \"FALLBACK\" : decidedBy === \"shadow\" ? \"SHADOW\" : isApplied ? \"APPLIED\" : decidedBy !== null || appliedFlag !== null ? \"DECIDED\" : null;\n const derivedFallbackReason = isFallback ? (decidedBy ?? \"\").replace(/^fallback:?\\s*/, \"\") || null : null;\n return {\n site: readStringOrNull(wireDecision?.site) ?? eventSite,\n siteLabel: readStringOrNull(wireDecision?.siteLabel),\n subject: readStringOrNull(wireDecision?.subject) ?? readStringOrNull(wireStep.eventSubject),\n engine: readStringOrNull(wireDecision?.engine),\n engineLabel: readStringOrNull(wireDecision?.engineLabel) ?? (isFallback ? null : decidedBy),\n mode: readStringOrNull(wireDecision?.mode),\n status: readStringOrNull(wireDecision?.status) ?? derivedStatus,\n resultSummary: readStringOrNull(wireDecision?.resultSummary),\n modelName: readStringOrNull(wireDecision?.modelName),\n modelVersion: readStringOrNull(wireDecision?.modelVersion),\n durationMs: readNumberOrNull(wireDecision?.durationMs) ?? readNumberOrNull(wireStep.durationMs),\n sharedRequestDecisionCount: readNumberOrNull(wireDecision?.sharedRequestDecisionCount),\n confidence: readNumberOrNull(wireDecision?.confidence),\n probabilities: readDecisionProbabilities(wireDecision?.probabilities),\n fallbackReason: readStringOrNull(wireDecision?.fallbackReason) ?? derivedFallbackReason,\n skipReason: readStringOrNull(wireDecision?.skipReason),\n inputJson: readJsonTextOrNull(wireDecision?.inputJson),\n isInputCut: wireDecision?.isInputCut === true,\n questionsJson: readJsonTextOrNull(wireDecision?.questionsJson),\n isQuestionsCut: wireDecision?.isQuestionsCut === true,\n outputJson: readJsonTextOrNull(wireDecision?.outputJson),\n isOutputCut: wireDecision?.isOutputCut === true,\n outcomeJson: readJsonTextOrNull(wireDecision?.outcomeJson) ?? eventPayload,\n isOutcomeCut: wireDecision?.isOutcomeCut === true,\n };\n};\n\nconst mapWireTraceCompaction = (wireCompaction: WireTraceCompaction | null | undefined): ConversationTraceCompaction | null => {\n if (!isWireObject(wireCompaction)) return null;\n const tokensBefore = readNumberOrNull(wireCompaction.coveredTokens);\n const tokensAfter = readNumberOrNull(wireCompaction.summaryTokens);\n const compressionPercentOfTokens =\n tokensBefore !== null && tokensAfter !== null && tokensBefore > 0 ? Math.round(((tokensBefore - tokensAfter) / tokensBefore) * 100) : null;\n return {\n level: readNumberOrNull(wireCompaction.level),\n foldedMessageCount: readNumberOrNull(wireCompaction.coveredMessageCount),\n foldedFromMessageIndex: readNumberOrNull(wireCompaction.coveredFromMessageIndex),\n foldedToMessageIndex: readNumberOrNull(wireCompaction.coveredToMessageIndex),\n tokensBefore,\n tokensAfter,\n compressionPercent: readNumberOrNull(wireCompaction.compressionPercent) ?? compressionPercentOfTokens,\n modelName: readStringOrNull(wireCompaction.modelName),\n summaryText: readStringOrNull(wireCompaction.summaryText),\n isSummaryCut: wireCompaction.isSummaryCut === true,\n preservedFactsJson: readJsonTextOrNull(wireCompaction.preservedFactsJson),\n };\n};\n\n/** The signal of a `SIGNAL` step (the server writes its fields on the step itself). */\nconst mapWireTraceSignal = (wireStep: WireTraceStep): ConversationTraceSignal | null => {\n const source = readStringOrNull(wireStep.signalSource);\n const text = readStringOrNull(wireStep.signalText);\n const kind = readStringOrNull(wireStep.signalKind) ?? (text === null ? null : (/^\\[SIGNAL:([^\\]]+)\\]/.exec(text)?.[1] ?? null));\n const tag = readStringOrNull(wireStep.signalTag) ?? (text === null ? null : (/^\\s*\\[SIGNAL:([^\\]\\s]+)\\]/.exec(text)?.[1] ?? null));\n return source === null && text === null && kind === null ? null : { source, kind, tag, text, isTextCut: wireStep.isSignalTextCut === true };\n};\n\nconst mapWireTraceWidget = (wireWidget: WireTraceWidget | null | undefined): ConversationTraceWidget | null =>\n isWireObject(wireWidget)\n ? {\n type: readStringOrNull(wireWidget.type),\n emittedBy: readStringOrNull(wireWidget.emittedBy),\n isValid: wireWidget.isValid !== false,\n title: readStringOrNull(wireWidget.title),\n summary: readStringOrNull(wireWidget.summary),\n payloadJson: readJsonTextOrNull(wireWidget.payloadJson),\n isPayloadCut: wireWidget.isPayloadCut === true,\n messageId: readNumberOrNull(wireWidget.messageId),\n stepId: readStringOrNull(wireWidget.stepId),\n }\n : null;\n\nconst mapWireTraceLoadedSkillTools = (wireTools: WireTraceSkillLoadEntry[\"tools\"]): ConversationTraceLoadedSkillTool[] =>\n readWireSetElements(wireTools)\n .filter(isPlainObject)\n .map((wireTool) => ({\n name: readStringOrNull(wireTool.name) ?? \"\",\n residentTokens: readNumberOrNull(wireTool.residentTokens),\n usageCount: readNumberOrNull(wireTool.usageCount),\n }));\n\nconst mapWireTraceSkillLoad = (wireSkillLoad: WireTraceSkillLoad | null | undefined): ConversationTraceSkillLoad | null =>\n isWireObject(wireSkillLoad)\n ? {\n cause: readStringOrNull(wireSkillLoad.cause),\n loadedCount: readNumberOrNull(wireSkillLoad.loadedCount),\n notLoadedCount: readNumberOrNull(wireSkillLoad.notLoadedCount),\n requestedNames: readStringList(wireSkillLoad.requestedNames),\n skills: readWireSetElements(wireSkillLoad.skills)\n .filter(isPlainObject)\n .map(\n (wireEntry: WireTraceSkillLoadEntry): ConversationTraceSkillLoadEntry => ({\n name: readStringOrNull(wireEntry.name) ?? \"\",\n type: readStringOrNull(wireEntry.type),\n outcome: readStringOrNull(wireEntry.outcome),\n cause: readStringOrNull(wireEntry.cause),\n residentTokens: readNumberOrNull(wireEntry.residentTokens),\n residentTokensWithTools: readNumberOrNull(wireEntry.residentTokensWithTools),\n tools: mapWireTraceLoadedSkillTools(wireEntry.tools),\n }),\n ),\n notLoadedText: readStringOrNull(wireSkillLoad.notLoadedText),\n }\n : null;\n\nexport const mapWireTraceTaskPlanItems = (wireItems: WireTraceStep[\"taskPlanItems\"]): ConversationTraceTaskPlanItem[] =>\n readWireSetElements(wireItems)\n .filter(isPlainObject)\n .map((wireItem: WireTraceTaskPlanItem, position) => ({\n key: readStringOrNull(wireItem.key) ?? readStringOrNull(wireItem.numberPath) ?? String(position),\n numberPath: readStringOrNull(wireItem.numberPath),\n depth: readNumberOrNull(wireItem.depth) ?? 0,\n title: readStringOrNull(wireItem.title) ?? \"\",\n status: readStringOrNull(wireItem.status),\n shownStatus: readStringOrNull(wireItem.shownStatus),\n statusNote: readStringOrNull(wireItem.statusNote),\n requiresUserAction: wireItem.requiresUserAction === true,\n retryable: wireItem.retryable === true,\n isSeeded: wireItem.isSeeded === true,\n isPreResolvedAtSeed: wireItem.isPreResolvedAtSeed === true,\n closesItself: wireItem.closesItself === true,\n wasClosedByPlatform: wireItem.wasClosedByPlatform === true,\n doneCriterion: readStringOrNull(wireItem.doneCriterion),\n customerProgressStepKey: readStringOrNull(wireItem.customerProgressStepKey),\n instruction: readStringOrNull(wireItem.instruction),\n skillNames: readWireSetElements(wireItem.skillNames).filter((name): name is string => typeof name === \"string\" && name !== \"\"),\n declarations: readWireSetElements(wireItem.declarations)\n .filter(isPlainObject)\n .map((wireDeclaration: WireTraceTaskPlanItemDeclaration) => ({\n name: readStringOrNull(wireDeclaration.name) ?? \"\",\n kind: readStringOrNull(wireDeclaration.kind) ?? \"\",\n value: readStringOrNull(wireDeclaration.value) ?? \"\",\n }))\n .filter((declaration) => declaration.name !== \"\"),\n evidenceMessageIndex: readNumberOrNull(wireItem.evidenceMessageIndex),\n platformResolvedAtMessageIndex: readNumberOrNull(wireItem.platformResolvedAtMessageIndex),\n }));\n\nexport const mapWireTraceTaskPlanRejections = (wireRejections: WireTraceStep[\"taskPlanRejections\"]): ConversationTraceTaskPlanRejection[] =>\n readWireSetElements(wireRejections)\n .filter(isPlainObject)\n .map((wireRejection: WireTraceTaskPlanRejection) => ({\n line: readStringOrNull(wireRejection.line) ?? \"\",\n itemKey: readStringOrNull(wireRejection.itemKey),\n }))\n .filter((rejection) => rejection.line !== \"\");\n\nconst mapWireTraceLoadedSkill = (wireSkill: WireTraceLoadedSkill): ConversationTraceLoadedSkill => ({\n name: readStringOrNull(wireSkill.name) ?? \"\",\n residentTokens: readNumberOrNull(wireSkill.residentTokens),\n isNew: wireSkill.isNew === true,\n isAlwaysLoaded: wireSkill.isAlwaysLoaded === true,\n cause: readStringOrNull(wireSkill.cause ?? wireSkill.source),\n tools: mapWireTraceLoadedSkillTools(wireSkill.tools),\n});\n\nconst mapWireTraceTerminal = (wireTerminal: WireTraceTerminal | null | undefined): ConversationTraceTerminal | null =>\n isPlainObject(wireTerminal)\n ? {\n command: readStringOrNull(wireTerminal.command),\n cwd: readStringOrNull(wireTerminal.cwd),\n exitCode: readNumberOrNull(wireTerminal.exitCode),\n durationMs: readNumberOrNull(wireTerminal.durationMs),\n output: readStringOrNull(wireTerminal.output),\n errorOutput: readStringOrNull(wireTerminal.errorOutput),\n isTruncated: wireTerminal.isTruncated === true,\n isBackground: wireTerminal.isBackground === true,\n timedOut: wireTerminal.timedOut === true,\n }\n : null;\n\n/** An `AgentTraceFileChange` as the contract's file change. */\nexport const mapWireTraceFileChange = (wireFileChange: WireTraceFileChange): ConversationFileChange => ({\n id: readNumberOrNull(wireFileChange.fileChangeId ?? wireFileChange.id),\n source: readStringOrNull(wireFileChange.source),\n mountKind: readStringOrNull(wireFileChange.mountKind),\n mountName: readStringOrNull(wireFileChange.mountName),\n driveSpaceId: readNumberOrNull(wireFileChange.driveSpaceId),\n path: readStringOrNull(wireFileChange.path) ?? \"\",\n previousPath: readStringOrNull(wireFileChange.previousPath),\n changeType: readVocabularyValue(FILE_CHANGE_TYPES, wireFileChange.changeType),\n sizeBefore: readNumberOrNull(wireFileChange.sizeBefore),\n sizeAfter: readNumberOrNull(wireFileChange.sizeAfter),\n sha256Before: readStringOrNull(wireFileChange.sha256Before),\n sha256After: readStringOrNull(wireFileChange.sha256After),\n contentType: readStringOrNull(wireFileChange.contentType),\n isBinary: wireFileChange.isBinary === true,\n linesAdded: readNumberOrNull(wireFileChange.linesAdded),\n linesRemoved: readNumberOrNull(wireFileChange.linesRemoved),\n diffState: readVocabularyValue(DIFF_STATES, wireFileChange.diffState),\n diffPreview: readStringOrNull(wireFileChange.diffPreview),\n driveNodeId: readNumberOrNull(wireFileChange.driveNodeId),\n driveFileVersionId: readNumberOrNull(wireFileChange.driveFileVersionId),\n externalRevisionId: readStringOrNull(wireFileChange.externalRevisionId),\n});\n\nconst mapWireTraceSubAgentRun = (wireRun: WireTraceSubAgentRun): ConversationTraceSubAgentRun => ({\n runNumber: readNumberOrNull(wireRun.runNumber),\n status: readStringOrNull(wireRun.status),\n startedAt: readStringOrNull(wireRun.startedAt),\n finishedAt: readStringOrNull(wireRun.finishedAt),\n verdict: readStringOrNull(wireRun.verdict),\n failureReason: readStringOrNull(wireRun.failureReason),\n costInUsd: readNumberOrNull(wireRun.costInUsd ?? wireRun.costInUSD),\n inputTokens: readNumberOrNull(wireRun.inputTokens),\n outputTokens: readNumberOrNull(wireRun.outputTokens),\n resultText: readStringOrNull(wireRun.resultText),\n isResultTextCut: wireRun.isResultTextCut === true,\n isToolResponse: wireRun.isToolResponse === true,\n isError: typeof wireRun.isError === \"boolean\" ? wireRun.isError : null,\n});\n\nconst mapWireTraceSubAgent = (wireSubAgent: WireTraceSubAgent | null | undefined): ConversationTraceSubAgent | null => {\n if (!isWireObject(wireSubAgent)) return null;\n const runs = readWireSetElements(wireSubAgent.runs).filter(isPlainObject).map(mapWireTraceSubAgentRun);\n return {\n number: readNumberOrNull(wireSubAgent.number),\n label: readStringOrNull(wireSubAgent.label) ?? \"\",\n taskText: readStringOrNull(wireSubAgent.taskText),\n skillNames: readStringList(wireSubAgent.skillNames),\n childConversationId: readNumberOrNull(wireSubAgent.childConversationId),\n status: readStringOrNull(wireSubAgent.status) ?? runs[runs.length - 1]?.status ?? null,\n runs,\n modelName: readStringOrNull(wireSubAgent.modelName ?? wireSubAgent.childModelNames),\n modelLabel: readStringOrNull(wireSubAgent.childModelLabels),\n costInUsd: readNumberOrNull(wireSubAgent.childCostInUSD ?? wireSubAgent.childCostInUsd),\n inputTokens: readNumberOrNull(wireSubAgent.childInputTokens),\n outputTokens: readNumberOrNull(wireSubAgent.childOutputTokens),\n cachedInputTokens: readNumberOrNull(wireSubAgent.childCachedInputTokens),\n messageCount: readNumberOrNull(wireSubAgent.childMessageCount),\n taskKind: readVocabularyValue(SUB_AGENT_TASK_KINDS, wireSubAgent.taskKind),\n toolName: readStringOrNull(wireSubAgent.toolName),\n operationName: readStringOrNull(wireSubAgent.operationName),\n backgroundJobKey: readStringOrNull(wireSubAgent.backgroundJobKey),\n verdictText: readStringOrNull(wireSubAgent.verdictText),\n resultText: readStringOrNull(wireSubAgent.resultText),\n isResultTextCut: wireSubAgent.isResultTextCut === true,\n };\n};\n\nconst mapWireTraceEntityReference = (wireReference: unknown): ConversationTraceEntityReference | null => {\n if (!isPlainObject(wireReference)) return null;\n const argumentName = readStringOrNull(wireReference.argumentName);\n const id = readNumberOrNull(wireReference.id);\n return argumentName !== null && argumentName !== \"\" && id !== null ? { argumentName, id } : null;\n};\n\nconst RECORD_CHANGE_OPERATIONS: readonly ConversationTraceRecordChangeOperation[] = [\"CREATED\", \"CHANGED\", \"DELETED\"];\n\nconst mapWireTraceFieldChange = (wireFieldChange: WireTraceFieldChange | null | undefined): ConversationTraceFieldChange | null => {\n if (!isWireObject(wireFieldChange)) return null;\n const fieldName = readStringOrNull(wireFieldChange.fieldName);\n if (fieldName === null || fieldName === \"\") return null;\n return {\n fieldName,\n before: readStringOrNull(wireFieldChange.before),\n after: readStringOrNull(wireFieldChange.after),\n isCut: wireFieldChange.isCut === true,\n };\n};\n\nconst mapWireTraceRecordChange = (wireRecordChange: WireTraceRecordChange | null | undefined): ConversationTraceRecordChange | null => {\n if (!isWireObject(wireRecordChange)) return null;\n const operation = readVocabularyValue(RECORD_CHANGE_OPERATIONS, wireRecordChange.operation);\n const tableName = readStringOrNull(wireRecordChange.tableName);\n if (operation === null || tableName === null || tableName === \"\") return null;\n return {\n operation,\n tableName,\n recordId: readNumberOrNull(wireRecordChange.recordId),\n fieldChanges: readWireSetElements(wireRecordChange.fieldChanges)\n .map(mapWireTraceFieldChange)\n .filter((fieldChange): fieldChange is ConversationTraceFieldChange => fieldChange !== null),\n omittedFieldCount: readNumberOrNull(wireRecordChange.omittedFieldCount) ?? 0,\n };\n};\n\n/** The readable thinking of a model call, with an ellipsis when the server cut it; null without one. */\nconst readThinkingSummary = (wireStep: WireTraceStep): string | null => {\n const thinkingSummary = readStringOrNull(wireStep.thinkingSummary);\n if (thinkingSummary === null || thinkingSummary.trim() === \"\") return null;\n return wireStep.isThinkingSummaryCut === true ? `${thinkingSummary}…` : thinkingSummary;\n};\n\n/** The record changes of a writing call (`ToolCallRecordChanges`); empty without them. */\nconst mapWireTraceRecordChanges = (\n wireRecordChanges: WireTraceRecordChanges | null | undefined,\n): { recordChanges: ConversationTraceRecordChange[]; omittedRecordChangeCount: number } => {\n if (!isWireObject(wireRecordChanges)) return { recordChanges: [], omittedRecordChangeCount: 0 };\n return {\n recordChanges: readWireSetElements(wireRecordChanges.elements)\n .map(mapWireTraceRecordChange)\n .filter((recordChange): recordChange is ConversationTraceRecordChange => recordChange !== null),\n omittedRecordChangeCount: readNumberOrNull(wireRecordChanges.omittedRecordCount) ?? 0,\n };\n};\n\n/**\n * An `AgentTraceStep` as the contract's step. A step of a kind the binding does not know is mapped to null and left\n * out of its turn. `position` is the step's place in its turn (part of its key when the server sends no step id).\n */\nexport const mapWireTraceStep = (wireStep: WireTraceStep, position: number): ConversationTraceStep | null => {\n if (!isWireObject(wireStep)) return null;\n const kind = readVocabularyValue(STEP_KINDS, wireStep.kind);\n if (kind === null) return null;\n const messageId = readNumberOrNull(wireStep.messageId);\n const loadedSkills =\n wireStep.loadedSkills == null ? null : readWireSetElements(wireStep.loadedSkills).filter(isPlainObject).map(mapWireTraceLoadedSkill);\n const stepId = typeof wireStep.stepId === \"number\" ? String(wireStep.stepId) : readStringOrNull(wireStep.stepId) || null;\n const widget = mapWireTraceWidget(wireStep.widget);\n return {\n key: stepId ?? `${messageId ?? \"event\"}:${kind}:${readStringOrNull(wireStep.toolCallId) ?? position}`,\n stepId,\n turnNumber: readNumberOrNull(wireStep.turnNumber),\n kind,\n messageId,\n toolName: readStringOrNull(wireStep.toolName),\n deliveredThroughCallTool: wireStep.deliveredThroughCallTool === true,\n effect: readVocabularyValue(TOOL_EFFECTS, wireStep.effect),\n status: readVocabularyValue(STEP_STATUSES, wireStep.status),\n storedStatus: readStringOrNull(wireStep.storedStatus),\n refusalReason:\n wireStep.refusalReason == null ? null : (readVocabularyValue(REFUSAL_REASONS, wireStep.refusalReason) ?? \"other\"),\n backgroundOperationName: readStringOrNull(wireStep.backgroundOperationName),\n backgroundJobKey: readStringOrNull(wireStep.backgroundJobKey),\n startedAt: readStringOrNull(wireStep.startedAt),\n durationMs: readNumberOrNull(wireStep.durationMs),\n line: readStringOrNull(wireStep.line),\n toolNameInWords: readStringOrNull(wireStep.toolNameInWords),\n toolSkillNames: readStringList(wireStep.toolSkillNames),\n modelLabel: readStringOrNull(wireStep.modelLabel),\n thinkingSummary: readThinkingSummary(wireStep),\n entityReferences: readWireSetElements(wireStep.entityReferences)\n .map(mapWireTraceEntityReference)\n .filter((reference): reference is ConversationTraceEntityReference => reference !== null),\n ...mapWireTraceRecordChanges(wireStep.recordChanges),\n isHeldForConsent: wireStep.wasHeldForOwnerConsent === true || wireStep.isHeldForConsent === true,\n isAwaitingOwnerClick: wireStep.isAwaitingOwnerClick === true,\n isRefused:\n wireStep.wasRefusedByGate === true || wireStep.wasRefusedAsDuplicate === true || wireStep.wasRefusedAsFinal === true,\n errorText: readStringOrNull(wireStep.errorText),\n errorCode: readStringOrNull(wireStep.errorCode),\n wasRetried: wireStep.wasRetried === true,\n widgetType: widget?.type ?? null,\n widget,\n decision: kind === \"DECISION\" ? mapWireTraceDecision(wireStep) : null,\n compaction: mapWireTraceCompaction(wireStep.compaction),\n signal: kind === \"SIGNAL\" ? mapWireTraceSignal(wireStep) : null,\n skillLoad: mapWireTraceSkillLoad(wireStep.skillLoad),\n taskPlanItems: mapWireTraceTaskPlanItems(wireStep.taskPlanItems),\n taskPlanRejections: mapWireTraceTaskPlanRejections(wireStep.taskPlanRejections),\n taskPlanTitle: readStringOrNull(wireStep.taskPlanTitle),\n taskPlanItemCount: readNumberOrNull(wireStep.taskPlanItemCount),\n taskPlanOpenItemCount: readNumberOrNull(wireStep.taskPlanOpenItemCount),\n taskPlanDoneItemCount: readNumberOrNull(wireStep.taskPlanDoneItemCount),\n taskPlanBlockedItemCount: readNumberOrNull(wireStep.taskPlanBlockedItemCount),\n terminal: mapWireTraceTerminal(wireStep.terminal),\n fileChanges: readWireSetElements(wireStep.fileChanges).filter(isPlainObject).map(mapWireTraceFileChange),\n subAgent: mapWireTraceSubAgent(wireStep.subAgent),\n argumentsJson: readStringOrNull(wireStep.argumentsJson),\n isArgumentsCut: wireStep.isArgumentsCut === true,\n result: readStringOrNull(wireStep.result),\n resultChars: readNumberOrNull(wireStep.resultChars),\n isResultCut: wireStep.isResultCut === true,\n modelCall: mapWireTraceModelCall(wireStep.modelCall),\n loadedSkills,\n loadedSkillNames: readStringList(wireStep.loadedSkillNames),\n assistantText: readStringOrNull(wireStep.assistantText) || null,\n assistantTextChars: readNumberOrNull(wireStep.assistantTextChars),\n isAssistantTextCut: wireStep.isAssistantTextCut === true,\n };\n};\n\n/** An `AgentTraceMessage`: a message of a turn with its text; null for anything that is no object. */\nexport const mapWireTraceMessage = (wireMessage: WireTraceMessage | null | undefined): ConversationTraceMessage | null => {\n if (!isWireObject(wireMessage)) return null;\n const text = readStringOrNull(wireMessage.text) ?? \"\";\n return {\n messageId: readNumberOrNull(wireMessage.messageId),\n messageIndex: readNumberOrNull(wireMessage.messageIndex),\n authorKind: readStringOrNull(wireMessage.authorKind),\n text,\n textChars: readNumberOrNull(wireMessage.textChars) ?? text.length,\n isTextCut: wireMessage.isTextCut === true,\n createdAt: readStringOrNull(wireMessage.createdAt),\n signalSource: readStringOrNull(wireMessage.signalSource),\n isInterim: wireMessage.isInterim === true,\n modelLabel: readStringOrNull(wireMessage.modelLabel),\n modelName: readStringOrNull(wireMessage.modelName),\n widgetTypes: readStringList(wireMessage.widgetTypes),\n widgets: readWireSetElements(wireMessage.widgets)\n .map((wireWidget) => mapWireTraceWidget(wireWidget))\n .filter((widget): widget is ConversationTraceWidget => widget !== null),\n isQueuedDuringRun: wireMessage.isQueuedDuringRun === true,\n arrivedDuringTurnNumber: readNumberOrNull(wireMessage.arrivedDuringTurnNumber),\n handledInTurnNumber: readNumberOrNull(wireMessage.handledInTurnNumber),\n foldSignalMessageId: readNumberOrNull(wireMessage.foldSignalMessageId),\n };\n};\n\n/** The share of the input tokens read from the cache, when the server sends the two counts but not the share. */\nconst readCachePercent = (wireTotals: WireTurnTraceTotals): number | null => {\n const cachePercent = readNumberOrNull(wireTotals.cachePercent);\n if (cachePercent !== null) return cachePercent;\n const inputTokens = readNumberOrNull(wireTotals.inputTokens);\n const cachedInputTokens = readNumberOrNull(wireTotals.cachedInputTokens);\n if (inputTokens === null || cachedInputTokens === null || inputTokens <= 0) return null;\n return Math.round((cachedInputTokens / inputTokens) * 100);\n};\n\nconst mapWireTurnTraceTotals = (wireTurn: WireTurnTrace, steps: ConversationTraceStep[]): ConversationTurnTraceTotals => {\n // The server writes the totals on the turn itself; an object of their own wins when one arrives.\n const wireTotals: WireTurnTraceTotals = isPlainObject(wireTurn.totals) ? { ...wireTurn, ...wireTurn.totals } : wireTurn;\n return {\n durationMs: readNumberOrNull(wireTotals.durationMs),\n inputTokens: readNumberOrNull(wireTotals.inputTokens),\n outputTokens: readNumberOrNull(wireTotals.outputTokens),\n cachedInputTokens: readNumberOrNull(wireTotals.cachedInputTokens),\n cachePercent: readCachePercent(wireTotals),\n costInUsd: readNumberOrNull(wireTotals.costInUSD ?? wireTotals.costInUsd),\n stepCount: readNumberOrNull(wireTotals.stepCount) ?? steps.length,\n commandCount: readNumberOrNull(wireTotals.commandCount) ?? steps.filter((step) => step.terminal !== null).length,\n fileCount: readNumberOrNull(wireTotals.fileCount) ?? steps.reduce((count, step) => count + step.fileChanges.length, 0),\n linesAdded: readNumberOrNull(wireTotals.linesAdded) ?? 0,\n linesRemoved: readNumberOrNull(wireTotals.linesRemoved) ?? 0,\n modelName: readStringOrNull(wireTotals.modelName),\n effort: readStringOrNull(wireTotals.reasoningEffort ?? wireTotals.effort),\n outcome: readStringOrNull(wireTotals.outcome),\n };\n};\n\n/** An `AgentTurnTrace` as the contract's turn trace. */\nexport const mapWireTurnTrace = (wireTurn: WireTurnTrace): ConversationTurnTrace => {\n const steps = readWireSetElements(wireTurn.steps)\n .map((wireStep, position) => mapWireTraceStep(wireStep, position))\n .filter((step): step is ConversationTraceStep => step !== null);\n return {\n turnNumber: readNumberOrNull(wireTurn.turnNumber) ?? 0,\n turnMessageId: readNumberOrNull(wireTurn.initiatorMessageId ?? wireTurn.turnMessageId),\n turnMessageIndex: readNumberOrNull(wireTurn.initiatorMessageIndex),\n startedAt: readStringOrNull(wireTurn.startedAt),\n isRunning: wireTurn.isRunning === true,\n isStoppedByOwner: wireTurn.isStoppedByOwner === true,\n initiatorMessage: mapWireTraceMessage(wireTurn.initiatorMessage),\n answerMessages: readWireSetElements(wireTurn.answerMessages)\n .map(mapWireTraceMessage)\n .filter((message): message is ConversationTraceMessage => message !== null),\n queuedMessages: readWireSetElements(wireTurn.queuedMessages)\n .map(mapWireTraceMessage)\n .filter((message): message is ConversationTraceMessage => message !== null),\n isStartedForQueuedOwnerMessage: wireTurn.isStartedForQueuedOwnerMessage === true,\n startedBySignalMessageId: readNumberOrNull(wireTurn.startedBySignalMessageId),\n steps,\n totals: mapWireTurnTraceTotals(wireTurn, steps),\n };\n};\n\n/** The object of an answer that carries `fieldName`: the answer itself, or the first of its fields that does. */\nconst findObjectWithField = <Found>(response: unknown, fieldName: string): Found | null => {\n if (!isPlainObject(response)) return null;\n if (fieldName in response) return response as Found;\n for (const value of Object.values(response)) {\n if (isPlainObject(value) && fieldName in value) return value as Found;\n }\n return null;\n};\n\n/** The traces of an answer: the object that carries the turns (`elements` of the set, or `turns`) or its paging facts. */\nconst findWireTurnTraces = (response: unknown): WireTurnTraces =>\n findObjectWithField<WireTurnTraces>(response, \"totalTurnCount\") ?? findObjectWithField<WireTurnTraces>(response, \"turns\") ?? {};\n\n/**\n * The trace read (`AgentTurnTraces`) as the contract's turn traces: the traces may be the answer itself or sit in one\n * of its fields (a response DTO). The turns are the elements of the set. An answer without turns reads as an empty\n * trace.\n */\nexport const mapWireTurnTraces = (response: WireTurnTracesResponse | null | undefined): ConversationTurnTraces => {\n const wireTraces = findWireTurnTraces(response);\n const turns = readWireSetElements(Array.isArray(wireTraces.elements) ? wireTraces.elements : wireTraces.turns).filter(isPlainObject).map(mapWireTurnTrace);\n return {\n conversationId: readNumberOrNull(wireTraces.aiConversationId),\n level: readVocabularyValue(TRACE_LEVELS, wireTraces.detailLevel) ?? \"STEPS\",\n turns,\n windowMode: readVocabularyValue(TRACE_WINDOW_MODES, wireTraces.windowMode),\n totalTurnCount: readNumberOrNull(wireTraces.totalTurnCount),\n firstTurnNumber: readNumberOrNull(wireTraces.firstTurnNumber) ?? turns[0]?.turnNumber ?? null,\n lastTurnNumber: readNumberOrNull(wireTraces.lastTurnNumber) ?? turns[turns.length - 1]?.turnNumber ?? null,\n hasOlderTurns: wireTraces.hasOlderTurns === true,\n hasNewerTurns: wireTraces.hasNewerTurns === true,\n newestMessageIndex: readNumberOrNull(wireTraces.newestMessageIndex),\n isRunLive: wireTraces.isRunLive === true,\n // the policy sits beside the traces in the response DTO (or on the traces themselves)\n traceViewPolicy: mapWireTraceViewPolicy(\n (response as Record<string, unknown> | null | undefined)?.traceViewPolicy ?? (wireTraces as Record<string, unknown>).traceViewPolicy,\n ),\n };\n};\n\nconst mapWireContextSegment = (wireSegment: WireContextSegment, position: number): ConversationContextSegment => {\n const key = readStringOrNull(wireSegment.key) ?? readStringOrNull(wireSegment.name) ?? readStringOrNull(wireSegment.type) ?? \"segment\";\n return {\n // The segments of a kind repeat (one per wire message): the position makes the key unique.\n key: `${key}:${position}`,\n label: readStringOrNull(wireSegment.label) ?? key,\n tokens: readNumberOrNull(wireSegment.tokenCount ?? wireSegment.tokens) ?? 0,\n percent: readNumberOrNull(wireSegment.percent),\n };\n};\n\n/**\n * The context composition of one model call. The server's answer carries the composition in `composition` (the\n * segments of the system message, of the tool schemas and of the wire messages, in the order the model read them) and\n * the compaction threshold beside it: the context's size is the provider's count of the newest call, the size it may\n * reach is the threshold in effect. A flat answer (`segments`, `totalTokens`, `contextWindowTokens`) is read as well.\n */\nexport const mapWireContextComposition = (\n response: WireContextCompositionResponse | null | undefined,\n): ConversationContextComposition => {\n const wireResponse: WireContextComposition = isPlainObject(response) ? response : {};\n const wireComposition = isWireObject(wireResponse.composition)\n ? wireResponse.composition\n : isWireObject(wireResponse.contextComposition)\n ? wireResponse.contextComposition\n : null;\n const wireSegments =\n wireComposition !== null\n ? [\n ...readWireSetElements(wireComposition.systemSegments),\n ...readWireSetElements(wireComposition.toolSchemaSegments),\n ...readWireSetElements(wireComposition.messageSegments),\n ]\n : readWireSetElements((findObjectWithField<WireContextComposition>(response, \"segments\") ?? {}).segments);\n const mappedSegments = wireSegments.filter(isPlainObject).map(mapWireContextSegment);\n const segmentTokens = mappedSegments.length > 0 ? mappedSegments.reduce((sum, segment) => sum + segment.tokens, 0) : null;\n const wireThreshold = isWireObject(wireResponse.compactionThreshold) ? wireResponse.compactionThreshold : null;\n const totalTokens = readNumberOrNull(wireResponse.totalTokens) ?? readNumberOrNull(wireThreshold?.latestContextInputTokens) ?? segmentTokens;\n const thresholdTokens = readNumberOrNull(wireThreshold?.thresholdTokens);\n const contextWindowTokens = readNumberOrNull(wireResponse.contextWindowTokens) ?? (thresholdTokens !== null && thresholdTokens > 0 ? thresholdTokens : null);\n const fillPercentOfTokens =\n totalTokens !== null && contextWindowTokens !== null && contextWindowTokens > 0\n ? Math.round((totalTokens / contextWindowTokens) * 100)\n : null;\n // The share of each segment in the composition, when the server sends none.\n const segments = mappedSegments.map((segment) =>\n segment.percent === null && segmentTokens !== null && segmentTokens > 0\n ? { ...segment, percent: Math.round((segment.tokens / segmentTokens) * 1000) / 10 }\n : segment,\n );\n return {\n messageId: readNumberOrNull(wireResponse.messageId ?? wireResponse.aiConversationMessageId),\n totalTokens,\n contextWindowTokens,\n fillPercent: readNumberOrNull(wireResponse.fillPercent) ?? fillPercentOfTokens,\n segments,\n };\n};\n\n/** The whole diff of a file change. */\nexport const mapWireFileChangeDiff = (\n response: WireFileChangeDiffResponse | null | undefined,\n fileChangeId: number,\n): ConversationFileChangeDiff => {\n const wireDiff = findObjectWithField<WireFileChangeDiffResponse>(response, \"diff\") ??\n findObjectWithField<WireFileChangeDiffResponse>(response, \"diffText\") ?? {};\n const wireFileChange = isWireObject(wireDiff.fileChange) ? wireDiff.fileChange : null;\n return {\n fileChangeId: readNumberOrNull(wireDiff.fileChangeId) ?? readNumberOrNull(wireFileChange?.fileChangeId ?? wireFileChange?.id) ?? fileChangeId,\n diff: readStringOrNull(wireDiff.diff) ?? readStringOrNull(wireDiff.diffText) ?? \"\",\n isCut: wireDiff.isCut === true || wireDiff.isDiffCut === true,\n };\n};\n\n/** The answer of the stop route: whether a running turn was stopped, and the run state after it. */\nexport const mapWireTurnStop = (response: WireTurnStopResponse | null | undefined): ConversationTurnStop => {\n const wireStop: WireTurnStopResponse = isPlainObject(response) ? response : {};\n return { isStopped: wireStop.isStopped === true, runState: readStringOrNull(wireStop.runState) };\n};\n"],"names":["readVocabularyValue","readNumberOrNull","readStringOrNull"],"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,EAClF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAMA,wBAAsB,CAAuB,YAA8B,UAC/E,OAAO,UAAU,YAAa,WAAiC,SAAS,KAAK,IAAK,QAAkB;AAEtG,MAAMC,qBAAmB,CAAC,UACxB,O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