@robota-sdk/agent-transport 3.0.0-beta.82 → 3.0.0-beta.84
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/CHANGELOG.md +795 -0
- package/README.md +80 -118
- package/dist/browser/client.d.ts +2 -2
- package/dist/browser/client.js +1 -1
- package/dist/browser/index.d.ts +87 -13
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/observer-messages-CEeisRaF.js +2 -0
- package/dist/browser/observer-messages-CEeisRaF.js.map +1 -0
- package/dist/browser/observer-messages-Dnff2Tdb.d.ts +471 -0
- package/dist/browser/observer-messages-Dnff2Tdb.d.ts.map +1 -0
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +308 -16
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.ts +308 -16
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.cjs +1 -1
- package/dist/node/node.d.cts +69 -1
- package/dist/node/node.d.cts.map +1 -1
- package/dist/node/node.d.ts +70 -2
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +1 -1
- package/dist/node/node.js.map +1 -1
- package/package.json +17 -14
- package/src/__tests__/bearer-resource-gate.test.ts +120 -0
- package/src/__tests__/history-attached-budget.test.ts +216 -0
- package/src/__tests__/message-decoders.test.ts +496 -6
- package/src/__tests__/project-read-messages.test.ts +118 -0
- package/src/__tests__/session-detail-loop-status.test.ts +169 -0
- package/src/__tests__/session-directory-messages.test.ts +322 -0
- package/src/__tests__/session-error-classification.test.ts +113 -0
- package/src/__tests__/session-history-wire.test.ts +342 -0
- package/src/__tests__/session-message-handler-observe.test.ts +217 -0
- package/src/__tests__/session-message-handler.test.ts +139 -4
- package/src/__tests__/settings-messages.test.ts +193 -0
- package/src/__tests__/ws-broadcast-events.test.ts +10 -0
- package/src/client.ts +9 -1
- package/src/index.ts +18 -2
- package/src/loop-control-messages.ts +34 -0
- package/src/message-decoders.ts +238 -6
- package/src/node/bearer-resource-gate.ts +291 -0
- package/src/node/index.ts +13 -0
- package/src/observer-messages.ts +47 -0
- package/src/open-prompts.ts +76 -0
- package/src/outbound-delivery.ts +11 -2
- package/src/project-read-messages.ts +74 -0
- package/src/protocol-session.ts +23 -1
- package/src/session-directory-messages.ts +162 -0
- package/src/session-error-classification.ts +91 -0
- package/src/session-events.ts +100 -19
- package/src/session-message-handler.ts +110 -15
- package/src/session-query-messages.ts +123 -5
- package/src/session-resume-bridge.ts +8 -0
- package/src/settings-messages.ts +103 -0
- package/src/wire-messages.ts +238 -11
- package/dist/browser/message-decoders-BB8n-H2X.d.ts +0 -252
- package/dist/browser/message-decoders-BB8n-H2X.d.ts.map +0 -1
- package/dist/browser/message-decoders-CDmDoZPR.js +0 -2
- package/dist/browser/message-decoders-CDmDoZPR.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{SESSION_CHANGE_REFUSAL_CODES as e,SESSION_DELETE_REFUSAL_CODES as t}from"@robota-sdk/agent-interface-session";const n=4*1024*1024;function r(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const i=e=>typeof e==`string`,a=e=>typeof e==`string`&&e.length>0,o=e=>typeof e==`boolean`,s=e=>typeof e==`number`&&Number.isFinite(e),c=e=>Number.isSafeInteger(e)&&e>=0,l=e=>t=>t===void 0||e(t),u=e=>Array.isArray(e)&&e.every(r),d=e=>e===null||r(e),f=e=>t=>typeof t==`string`&&e.includes(t),p={user:!0,"agent-wakeup":!0,peer:!0,external:!0},m=e=>r(e)&&i(e.id)&&i(e.timestamp)&&i(e.category)&&i(e.type),h=e=>Array.isArray(e)&&e.every(m),g=e=>r(e)&&i(e.name)&&i(e.description)&&i(e.definedIn),_=e=>Array.isArray(e)&&e.every(g),v=[`agent`,`process`,`scheduled`],y=[`foreground`,`background`],b=[`queued`,`running`,`waiting_permission`,`sleeping`,`paused`,`completed`,`failed`,`cancelled`],x=[`cancel`,`close`,`send`],S=e=>r(e)&&l(f(v))(e.kind)&&l(f(b))(e.status)&&l(f(y))(e.mode)&&l(o)(e.includeClosed),C=e=>r(e)&&l(i)(e.prompt)&&l(i)(e.stdin),w=e=>r(e)&&s(e.offset),T=e=>r(e)&&c(e.offset),E=e=>o(e)||e===`allow-session`||e===`allow-project`,D=e=>r(e)&&(e.type===`answer`&&Array.isArray(e.values)&&e.values.every(i)&&l(i)(e.text)||e.type===`cancelled`&&e.values===void 0&&e.text===void 0),O={language:{language:a},outputStyle:{styleId:a},preset:{presetId:a},permissionMode:{mode:a},sandbox:{enabled:o},removePermissionRule:{scope:a,kind:f([`allow`,`deny`,`ask`]),pattern:a},mcpServerEnabled:{serverId:a,enabled:o},reloadMcpServers:{},pluginEnabled:{pluginId:a,enabled:o},reloadPlugins:{},installPlugin:{pluginId:a},uninstallPlugin:{pluginId:a},providerProfile:{profileName:a},providerModel:{profileName:a,modelId:a},deleteProviderProfile:{profileName:a}},k=e=>{if(!r(e)||!i(e.field))return!1;let t=e.field;if(!Object.prototype.hasOwnProperty.call(O,t))return!1;let n=O[t];return Object.entries(n).every(([t,n])=>n(e[t]))},A={none:{},several:{message:i},stopped:{loopId:a,message:l(i)},failed:{loopId:l(a),message:i}},j=e=>{if(!r(e)||!i(e.kind))return!1;let t=e.kind;if(!Object.prototype.hasOwnProperty.call(A,t))return!1;let n=A[t];return Object.entries(n).every(([t,n])=>n(e[t]))};function M(e){return t=>{if(!r(t)||!i(t.kind))return!1;let n=Object.prototype.hasOwnProperty.call(e,t.kind)?e[t.kind]:void 0;return n!==void 0&&Object.entries(n).every(([e,n])=>n(t[e]))}}const N=[`Added`,`Modified`,`Deleted`,`Renamed`,`Copied`,`Untracked`,`Conflicted`],P=e=>r(e)&&a(e.path)&&f(N)(e.status)&&l(a)(e.renamedFrom)&&l(s)(e.added)&&l(s)(e.removed),F=M({status:{branch:l(i),unborn:o,files:e=>Array.isArray(e)&&e.every(P),truncated:o},"not-a-repository":{},failed:{message:i}}),I=[`add`,`remove`,`context`,`hunk`],L=e=>r(e)&&f(I)(e.type)&&i(e.text)&&s(e.lineNumber),R=M({diff:{diffLines:e=>Array.isArray(e)&&e.every(L),truncated:o},"not-a-repository":{},"outside-workspace":{},failed:{message:i}}),z=M({memory:{content:i,path:a,truncated:o},unavailable:{message:i}}),B={submit:{prompt:a},command:{name:a,args:l(i),requestId:l(a)},abort:{},"cancel-queue":{},"get-messages":{},"get-history":{fromIndex:l(c)},"get-prompts":{},"get-context":{},"get-commands":{},"get-status":{},"list-models":{requestId:a},"get-agent-definitions":{requestId:a},"list-sessions":{requestId:a},"new-session":{requestId:l(a)},"switch-session":{sessionId:a,requestId:l(a)},"rename-session":{sessionId:a,name:a,requestId:a},"delete-session":{sessionId:a,requestId:a},"get-usage-report":{},"get-personal-usage-report":{requestId:a,period:f([`7d`,`30d`]),timezone:a},"get-stored-session-usage-report":{requestId:a,sessionId:a},"get-executing":{},"get-pending":{},"get-execution-workspace":{},"read-execution-detail":{requestId:a,entryId:a,cursor:l(T)},"stop-waiting-loop":{requestId:a},"project-status":{requestId:a},"project-diff":{requestId:a,path:a},"project-memory":{requestId:a},"get-background-tasks":{filter:l(S)},"get-background-task":{taskId:a},"get-background-job-groups":{},"get-background-job-group":{groupId:a},"wait-background-job-group":{groupId:a},"cancel-background-task":{taskId:a,reason:l(i)},"close-background-task":{taskId:a},"send-background-task":{taskId:a,input:C},"read-background-task-log":{taskId:a,cursor:l(w)},"permission-response":{id:a,result:E},"ask-response":{id:a,response:D},resume:{lastSeq:s},ack:{seq:s},"get-settings":{requestId:a},"update-settings":{requestId:a,patch:k}},V={driverId:l(i)},H={text_delta:{delta:i,...V},user_message:{content:i,...V},tool_start:{state:r,...V},tool_end:{state:r,...V},thinking:{isThinking:o,...V},complete:{result:r,...V},interrupted:{result:r,...V},error:{message:i,code:l(f([`auth`,`rate_limit`,`model_unavailable`,`network`,`provider`])),provider:l(i),retryAfterSeconds:l(s),model:l(i),...V},command_result:{name:i,message:i,success:o,requestId:l(i)},messages:{messages:u,display:l(u),...V},history:{startIndex:c,total:c,entries:h},context:{state:r},history_changed:{},turn_source:{source:f(Object.keys(p))},commands:{commands:u,skills:u},session_status:{status:r},model_list:{requestId:a,groups:u,currentProfile:l(i),currentModel:i},agent_definitions:{requestId:a,agents:_,current:a},sessions:{requestId:a,listing:r},sessions_error:{requestId:a,code:f([`not_available`,`list_failed`]),message:i},session_switched:{event:r},session_change_failed:{code:f(e),message:i,requestId:l(i)},session_renamed_in_list:{requestId:a,sessionId:i,name:i},session_rename_failed:{requestId:a,message:i},session_deleted:{requestId:a,sessionId:i},session_delete_failed:{requestId:a,code:f(t),message:i},usage_report:{report:r},personal_usage_report:{requestId:a,report:r},personal_usage_report_error:{requestId:a,code:f([`not_available`,`report_failed`]),message:i},stored_session_usage_report:{requestId:a,sessionId:a,report:r},stored_session_usage_report_error:{requestId:a,sessionId:a,code:f([`not_available`,`report_failed`]),message:i},executing:{executing:o},pending:{pending:e=>e===null||i(e),pendingCount:l(c)},execution_workspace_event:{snapshot:r},execution_detail:{requestId:a,page:r},execution_detail_error:{requestId:a,message:i},waiting_loop_stop:{requestId:a,outcome:j},project_status:{requestId:a,result:F},project_diff:{requestId:a,result:R},project_memory:{requestId:a,result:z},background_task_event:{event:r},background_job_group_event:{event:r},plan_event:{event:r},context_file_refreshed:{event:r},branch_event:{event:r},background_tasks:{tasks:u},background_task:{taskId:i,task:d},background_job_groups:{groups:u},background_job_group:{groupId:i,group:d},background_task_log:{taskId:i,page:r},permission_request:{event:r},ask_request:{event:r},prompt_resolved:{event:r},ui_intent:{event:r},session_renamed:{event:r},history_cleared:{},background_task_control_result:{action:f(x),taskId:i,success:o,message:l(i)},protocol_error:{message:i,requestId:l(i)},resume_gap:{},settings:{requestId:a,settings:r},settings_error:{requestId:a,code:f([`not_available`,`invalid`,`refused`,`update_failed`]),message:i}};function U(e,t,n){if(!r(e))return{ok:!1,reason:`message must be a JSON object`};let a=e.type;if(!i(a))return{ok:!1,reason:`message type must be a string`};let o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o===void 0)return{ok:!1,reason:`Unknown message type: ${a}`};for(let[t,r]of Object.entries(o))if(!r(e[t]))return{ok:!1,reason:n(t)};return{ok:!0,message:e}}function W(e){return U(e,B,e=>e===`prompt`?`prompt must be a non-empty string`:`${e} has an invalid shape`)}function G(e){return U(e,H,e=>`${e} has an invalid shape`)}function K(e,t){if(e.length>4194304)return{ok:!1,reason:`Frame too large`};let n;try{n=JSON.parse(e)}catch{return{ok:!1,reason:`Invalid JSON`}}return t(n)}const q=new Set([`get-messages`,`get-history`,`get-context`,`get-status`,`get-commands`,`list-models`,`get-executing`,`get-pending`,`get-execution-workspace`,`read-execution-detail`,`get-agent-definitions`,`get-usage-report`,`list-sessions`,`get-background-tasks`,`get-background-task`,`get-background-job-groups`,`get-background-job-group`,`wait-background-job-group`,`read-background-task-log`,`get-settings`,`project-status`,`project-diff`,`project-memory`]);function J(e){return q.has(e)}export{G as a,K as i,n,W as r,J as t};
|
|
2
|
+
//# sourceMappingURL=observer-messages-CEeisRaF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer-messages-CEeisRaF.js","names":[],"sources":["../../src/message-decoders.ts","../../src/observer-messages.ts"],"sourcesContent":["/**\n * Owner-side runtime decoders for the wire message unions (issue #2045 / TRANS-005 adjacent).\n *\n * `wire-messages.ts` owns the TypeScript unions; this file owns turning `JSON.parse` output into one\n * of them. Before it, the server did `JSON.parse(data) as TClientMessage` and each client did the\n * same for `TServerMessage`, so valid JSON with an invalid shape crossed the boundary wearing a\n * protocol type. Carriers now implement `raw string → owner decoder → typed message` and answer a\n * refusal with the protocol's own `protocol_error` (server side) or client error (client side).\n *\n * `decodeClientMessage` is TOTAL: every variant and every nested field it carries is validated.\n * `decodeServerMessage` validates every variant's discriminator and declared top-level fields; a\n * payload OWNED BY ANOTHER PACKAGE (`IToolState`, `IExecutionResult`, background events, …) is\n * checked as a non-array record (or array of records) here — its own total decoding belongs to its\n * owner and is tracked there, not duplicated in a transport package.\n */\n\nimport {\n SESSION_CHANGE_REFUSAL_CODES,\n SESSION_DELETE_REFUSAL_CODES,\n} from '@robota-sdk/agent-interface-session';\n\nimport type { TBackgroundControlAction, TClientMessage, TServerMessage } from './wire-messages.js';\n\nexport type TMessageDecodeResult<TMessage> =\n | { readonly ok: true; readonly message: TMessage }\n | { readonly ok: false; readonly reason: string };\n\n/** Serialized frames larger than this are refused before any parse (a bounded inbound budget). */\nexport const MAX_INBOUND_FRAME_BYTES = 4 * 1024 * 1024;\n\ntype TRecord = Record<string, unknown>;\n\nfunction isRecord(value: unknown): value is TRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nconst isString = (v: unknown): v is string => typeof v === 'string';\nconst isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0;\nconst isBoolean = (v: unknown): v is boolean => typeof v === 'boolean';\nconst isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);\nconst isCount = (v: unknown): v is number => Number.isSafeInteger(v) && (v as number) >= 0;\nconst isOptional =\n (check: (v: unknown) => boolean) =>\n (v: unknown): boolean =>\n v === undefined || check(v);\nconst isRecordArray = (v: unknown): boolean => Array.isArray(v) && v.every(isRecord);\nconst isNullableRecord = (v: unknown): boolean => v === null || isRecord(v);\nconst oneOf =\n (members: readonly string[]) =>\n (v: unknown): boolean =>\n typeof v === 'string' && members.includes(v);\n/** A record, not an array, so a turn source added to the union without one here fails to compile. */\nconst TURN_SOURCES: Readonly<\n Record<Extract<TServerMessage, { type: 'turn_source' }>['source'], true>\n> = { user: true, 'agent-wakeup': true, peer: true, external: true };\n/** A history entry's envelope is this package's (`IWireHistoryEntry`); its `data` is the recorder's. */\nconst isWireHistoryEntry = (v: unknown): boolean =>\n isRecord(v) &&\n isString(v['id']) &&\n isString(v['timestamp']) &&\n isString(v['category']) &&\n isString(v['type']);\nconst isWireHistoryEntries = (v: unknown): boolean =>\n Array.isArray(v) && v.every(isWireHistoryEntry);\n/** #3282 §4: one row of `agent_definitions` — name, one-line description, plain-words location. */\nconst isWireAgentDefinition = (v: unknown): boolean =>\n isRecord(v) && isString(v['name']) && isString(v['description']) && isString(v['definedIn']);\nconst isWireAgentDefinitions = (v: unknown): boolean =>\n Array.isArray(v) && v.every(isWireAgentDefinition);\n\ntype TFieldCheck = (value: unknown) => boolean;\ntype TVariantShape = Readonly<Record<string, TFieldCheck>>;\n\nconst BACKGROUND_TASK_KINDS = ['agent', 'process', 'scheduled'] as const;\nconst BACKGROUND_TASK_MODES = ['foreground', 'background'] as const;\nconst BACKGROUND_TASK_STATUSES = [\n 'queued',\n 'running',\n 'waiting_permission',\n 'sleeping',\n 'paused',\n 'completed',\n 'failed',\n 'cancelled',\n] as const;\nconst BACKGROUND_CONTROL_ACTIONS: readonly TBackgroundControlAction[] = ['cancel', 'close', 'send'];\n\nconst isBackgroundTaskListFilter: TFieldCheck = (v) =>\n isRecord(v) &&\n isOptional(oneOf(BACKGROUND_TASK_KINDS))(v['kind']) &&\n isOptional(oneOf(BACKGROUND_TASK_STATUSES))(v['status']) &&\n isOptional(oneOf(BACKGROUND_TASK_MODES))(v['mode']) &&\n isOptional(isBoolean)(v['includeClosed']);\nconst isBackgroundTaskInput: TFieldCheck = (v) =>\n isRecord(v) && isOptional(isString)(v['prompt']) && isOptional(isString)(v['stdin']);\nconst isBackgroundTaskLogCursor: TFieldCheck = (v) => isRecord(v) && isFiniteNumber(v['offset']);\nconst isExecutionDetailCursor: TFieldCheck = (v) => isRecord(v) && isCount(v['offset']);\nconst isPermissionResultValue: TFieldCheck = (v) =>\n isBoolean(v) || v === 'allow-session' || v === 'allow-project';\nconst isActionResponse: TFieldCheck = (v) =>\n isRecord(v) &&\n ((v['type'] === 'answer' &&\n Array.isArray(v['values']) &&\n v['values'].every(isString) &&\n isOptional(isString)(v['text'])) ||\n (v['type'] === 'cancelled' && v['values'] === undefined && v['text'] === undefined));\n\ntype TSettingsPatch = Extract<TClientMessage, { type: 'update-settings' }>['patch'];\n/** Keyed by `field`, so a patch variant added to the union without a shape here fails to compile. */\nconst SETTINGS_PATCH_SHAPES: Readonly<Record<TSettingsPatch['field'], TVariantShape>> = {\n language: { language: isNonEmptyString },\n outputStyle: { styleId: isNonEmptyString },\n preset: { presetId: isNonEmptyString },\n permissionMode: { mode: isNonEmptyString },\n sandbox: { enabled: isBoolean },\n removePermissionRule: {\n scope: isNonEmptyString,\n kind: oneOf(['allow', 'deny', 'ask']),\n pattern: isNonEmptyString,\n },\n mcpServerEnabled: { serverId: isNonEmptyString, enabled: isBoolean },\n reloadMcpServers: {},\n pluginEnabled: { pluginId: isNonEmptyString, enabled: isBoolean },\n reloadPlugins: {},\n installPlugin: { pluginId: isNonEmptyString },\n uninstallPlugin: { pluginId: isNonEmptyString },\n // #3282 §4b: \"Providers & Models\" — Use, Model, Delete.\n providerProfile: { profileName: isNonEmptyString },\n providerModel: { profileName: isNonEmptyString, modelId: isNonEmptyString },\n deleteProviderProfile: { profileName: isNonEmptyString },\n};\nconst isSettingsPatch: TFieldCheck = (v) => {\n if (!isRecord(v) || !isString(v['field'])) return false;\n const field = v['field'];\n if (!Object.prototype.hasOwnProperty.call(SETTINGS_PATCH_SHAPES, field)) return false;\n const shape = SETTINGS_PATCH_SHAPES[field as TSettingsPatch['field']];\n return Object.entries(shape).every(([key, check]) => check(v[key]));\n};\n\ntype TWaitingLoopStopOutcome = Extract<TServerMessage, { type: 'waiting_loop_stop' }>['outcome'];\n/** Keyed by `kind`, so an outcome added to the union without a shape here fails to compile. */\nconst WAITING_LOOP_STOP_OUTCOME_SHAPES: Readonly<\n Record<TWaitingLoopStopOutcome['kind'], TVariantShape>\n> = {\n none: {},\n several: { message: isString },\n stopped: { loopId: isNonEmptyString, message: isOptional(isString) },\n failed: { loopId: isOptional(isNonEmptyString), message: isString },\n};\nconst isWaitingLoopStopOutcome: TFieldCheck = (v) => {\n if (!isRecord(v) || !isString(v['kind'])) return false;\n const kind = v['kind'];\n if (!Object.prototype.hasOwnProperty.call(WAITING_LOOP_STOP_OUTCOME_SHAPES, kind)) return false;\n const shape = WAITING_LOOP_STOP_OUTCOME_SHAPES[kind as TWaitingLoopStopOutcome['kind']];\n return Object.entries(shape).every(([field, check]) => check(v[field]));\n};\n\n/** Decode a `kind`-discriminated result union (the `TWaitingLoopStopOutcome` convention) from a shape\n * map keyed by `kind`. */\nfunction isKindDiscriminated(shapes: Readonly<Record<string, TVariantShape>>): TFieldCheck {\n return (v) => {\n if (!isRecord(v) || !isString(v['kind'])) return false;\n const shape = Object.prototype.hasOwnProperty.call(shapes, v['kind']) ? shapes[v['kind']] : undefined;\n if (shape === undefined) return false;\n return Object.entries(shape).every(([field, check]) => check(v[field]));\n };\n}\n\n// #3282 §4c: the Project panel's reads. Each result is the session method's own return value, crossing\n// the wire unchanged (the `TWaitingLoopStopOutcome` convention above) — decoded from a `kind`-keyed\n// shape map the same way.\nconst PROJECT_FILE_STATUSES = [\n 'Added',\n 'Modified',\n 'Deleted',\n 'Renamed',\n 'Copied',\n 'Untracked',\n 'Conflicted',\n] as const;\nconst isProjectStatusFile: TFieldCheck = (v) =>\n isRecord(v) &&\n isNonEmptyString(v['path']) &&\n oneOf(PROJECT_FILE_STATUSES)(v['status']) &&\n isOptional(isNonEmptyString)(v['renamedFrom']) &&\n isOptional(isFiniteNumber)(v['added']) &&\n isOptional(isFiniteNumber)(v['removed']);\nconst isProjectStatusFiles: TFieldCheck = (v) => Array.isArray(v) && v.every(isProjectStatusFile);\n\ntype TProjectStatusReadResult = Extract<TServerMessage, { type: 'project_status' }>['result'];\nconst PROJECT_STATUS_READ_SHAPES: Readonly<Record<TProjectStatusReadResult['kind'], TVariantShape>> = {\n status: {\n branch: isOptional(isString),\n unborn: isBoolean,\n files: isProjectStatusFiles,\n truncated: isBoolean,\n },\n 'not-a-repository': {},\n failed: { message: isString },\n};\nconst isProjectStatusRead = isKindDiscriminated(PROJECT_STATUS_READ_SHAPES);\n\nconst DIFF_LINE_TYPES = ['add', 'remove', 'context', 'hunk'] as const;\nconst isDiffLine: TFieldCheck = (v) =>\n isRecord(v) && oneOf(DIFF_LINE_TYPES)(v['type']) && isString(v['text']) && isFiniteNumber(v['lineNumber']);\nconst isDiffLines: TFieldCheck = (v) => Array.isArray(v) && v.every(isDiffLine);\n\ntype TProjectDiffReadResult = Extract<TServerMessage, { type: 'project_diff' }>['result'];\nconst PROJECT_DIFF_READ_SHAPES: Readonly<Record<TProjectDiffReadResult['kind'], TVariantShape>> = {\n diff: { diffLines: isDiffLines, truncated: isBoolean },\n 'not-a-repository': {},\n 'outside-workspace': {},\n failed: { message: isString },\n};\nconst isProjectDiffRead = isKindDiscriminated(PROJECT_DIFF_READ_SHAPES);\n\ntype TProjectMemoryReadResult = Extract<TServerMessage, { type: 'project_memory' }>['result'];\nconst PROJECT_MEMORY_READ_SHAPES: Readonly<Record<TProjectMemoryReadResult['kind'], TVariantShape>> = {\n memory: { content: isString, path: isNonEmptyString, truncated: isBoolean },\n unavailable: { message: isString },\n};\nconst isProjectMemoryRead = isKindDiscriminated(PROJECT_MEMORY_READ_SHAPES);\n\n/** One entry per `TClientMessage` variant — a variant added to the union without one fails the test. */\nexport const CLIENT_MESSAGE_SHAPES: Readonly<Record<TClientMessage['type'], TVariantShape>> = {\n submit: { prompt: isNonEmptyString },\n command: {\n name: isNonEmptyString,\n args: isOptional(isString),\n requestId: isOptional(isNonEmptyString),\n },\n abort: {},\n 'cancel-queue': {},\n 'get-messages': {},\n 'get-history': { fromIndex: isOptional(isCount) },\n 'get-prompts': {},\n 'get-context': {},\n 'get-commands': {},\n 'get-status': {},\n 'list-models': { requestId: isNonEmptyString },\n 'get-agent-definitions': { requestId: isNonEmptyString },\n 'list-sessions': { requestId: isNonEmptyString },\n 'new-session': { requestId: isOptional(isNonEmptyString) },\n 'switch-session': { sessionId: isNonEmptyString, requestId: isOptional(isNonEmptyString) },\n 'rename-session': {\n sessionId: isNonEmptyString,\n name: isNonEmptyString,\n requestId: isNonEmptyString,\n },\n 'delete-session': { sessionId: isNonEmptyString, requestId: isNonEmptyString },\n 'get-usage-report': {},\n 'get-personal-usage-report': {\n requestId: isNonEmptyString,\n period: oneOf(['7d', '30d']),\n timezone: isNonEmptyString,\n },\n 'get-stored-session-usage-report': {\n requestId: isNonEmptyString,\n sessionId: isNonEmptyString,\n },\n 'get-executing': {},\n 'get-pending': {},\n 'get-execution-workspace': {},\n 'read-execution-detail': {\n requestId: isNonEmptyString,\n entryId: isNonEmptyString,\n cursor: isOptional(isExecutionDetailCursor),\n },\n 'stop-waiting-loop': { requestId: isNonEmptyString },\n 'project-status': { requestId: isNonEmptyString },\n 'project-diff': { requestId: isNonEmptyString, path: isNonEmptyString },\n 'project-memory': { requestId: isNonEmptyString },\n 'get-background-tasks': { filter: isOptional(isBackgroundTaskListFilter) },\n 'get-background-task': { taskId: isNonEmptyString },\n 'get-background-job-groups': {},\n 'get-background-job-group': { groupId: isNonEmptyString },\n 'wait-background-job-group': { groupId: isNonEmptyString },\n 'cancel-background-task': { taskId: isNonEmptyString, reason: isOptional(isString) },\n 'close-background-task': { taskId: isNonEmptyString },\n 'send-background-task': { taskId: isNonEmptyString, input: isBackgroundTaskInput },\n 'read-background-task-log': {\n taskId: isNonEmptyString,\n cursor: isOptional(isBackgroundTaskLogCursor),\n },\n 'permission-response': { id: isNonEmptyString, result: isPermissionResultValue },\n 'ask-response': { id: isNonEmptyString, response: isActionResponse },\n resume: { lastSeq: isFiniteNumber },\n ack: { seq: isFiniteNumber },\n 'get-settings': { requestId: isNonEmptyString },\n 'update-settings': { requestId: isNonEmptyString, patch: isSettingsPatch },\n};\n\nconst authored: TVariantShape = { driverId: isOptional(isString) };\n\n/** One entry per `TServerMessage` variant. Foreign-owned payloads are checked as records (see header). */\nexport const SERVER_MESSAGE_SHAPES: Readonly<Record<TServerMessage['type'], TVariantShape>> = {\n text_delta: { delta: isString, ...authored },\n user_message: { content: isString, ...authored },\n tool_start: { state: isRecord, ...authored },\n tool_end: { state: isRecord, ...authored },\n thinking: { isThinking: isBoolean, ...authored },\n complete: { result: isRecord, ...authored },\n interrupted: { result: isRecord, ...authored },\n error: {\n message: isString,\n code: isOptional(oneOf(['auth', 'rate_limit', 'model_unavailable', 'network', 'provider'])),\n provider: isOptional(isString),\n retryAfterSeconds: isOptional(isFiniteNumber),\n model: isOptional(isString),\n ...authored,\n },\n command_result: {\n name: isString,\n message: isString,\n success: isBoolean,\n requestId: isOptional(isString),\n },\n messages: { messages: isRecordArray, display: isOptional(isRecordArray), ...authored },\n history: { startIndex: isCount, total: isCount, entries: isWireHistoryEntries },\n context: { state: isRecord },\n history_changed: {},\n turn_source: { source: oneOf(Object.keys(TURN_SOURCES)) },\n commands: { commands: isRecordArray, skills: isRecordArray },\n session_status: { status: isRecord },\n model_list: {\n requestId: isNonEmptyString,\n groups: isRecordArray,\n currentProfile: isOptional(isString),\n currentModel: isString,\n },\n agent_definitions: {\n requestId: isNonEmptyString,\n agents: isWireAgentDefinitions,\n current: isNonEmptyString,\n },\n sessions: { requestId: isNonEmptyString, listing: isRecord },\n sessions_error: {\n requestId: isNonEmptyString,\n code: oneOf(['not_available', 'list_failed']),\n message: isString,\n },\n session_switched: { event: isRecord },\n session_change_failed: {\n code: oneOf(SESSION_CHANGE_REFUSAL_CODES),\n message: isString,\n requestId: isOptional(isString),\n },\n session_renamed_in_list: { requestId: isNonEmptyString, sessionId: isString, name: isString },\n session_rename_failed: { requestId: isNonEmptyString, message: isString },\n session_deleted: { requestId: isNonEmptyString, sessionId: isString },\n session_delete_failed: {\n requestId: isNonEmptyString,\n code: oneOf(SESSION_DELETE_REFUSAL_CODES),\n message: isString,\n },\n usage_report: { report: isRecord },\n personal_usage_report: { requestId: isNonEmptyString, report: isRecord },\n personal_usage_report_error: {\n requestId: isNonEmptyString,\n code: oneOf(['not_available', 'report_failed']),\n message: isString,\n },\n stored_session_usage_report: {\n requestId: isNonEmptyString,\n sessionId: isNonEmptyString,\n report: isRecord,\n },\n stored_session_usage_report_error: {\n requestId: isNonEmptyString,\n sessionId: isNonEmptyString,\n code: oneOf(['not_available', 'report_failed']),\n message: isString,\n },\n executing: { executing: isBoolean },\n // An older host sends no count; a client then counts the one prompt it can see.\n pending: { pending: (v) => v === null || isString(v), pendingCount: isOptional(isCount) },\n execution_workspace_event: { snapshot: isRecord },\n execution_detail: { requestId: isNonEmptyString, page: isRecord },\n execution_detail_error: { requestId: isNonEmptyString, message: isString },\n waiting_loop_stop: { requestId: isNonEmptyString, outcome: isWaitingLoopStopOutcome },\n project_status: { requestId: isNonEmptyString, result: isProjectStatusRead },\n project_diff: { requestId: isNonEmptyString, result: isProjectDiffRead },\n project_memory: { requestId: isNonEmptyString, result: isProjectMemoryRead },\n background_task_event: { event: isRecord },\n background_job_group_event: { event: isRecord },\n plan_event: { event: isRecord },\n context_file_refreshed: { event: isRecord },\n branch_event: { event: isRecord },\n background_tasks: { tasks: isRecordArray },\n background_task: { taskId: isString, task: isNullableRecord },\n background_job_groups: { groups: isRecordArray },\n background_job_group: { groupId: isString, group: isNullableRecord },\n background_task_log: { taskId: isString, page: isRecord },\n permission_request: { event: isRecord },\n ask_request: { event: isRecord },\n prompt_resolved: { event: isRecord },\n ui_intent: { event: isRecord },\n session_renamed: { event: isRecord },\n history_cleared: {},\n background_task_control_result: {\n action: oneOf(BACKGROUND_CONTROL_ACTIONS),\n taskId: isString,\n success: isBoolean,\n message: isOptional(isString),\n },\n protocol_error: { message: isString, requestId: isOptional(isString) },\n resume_gap: {},\n settings: { requestId: isNonEmptyString, settings: isRecord },\n settings_error: {\n requestId: isNonEmptyString,\n code: oneOf(['not_available', 'invalid', 'refused', 'update_failed']),\n message: isString,\n },\n};\n\nfunction decodeVariant<TMessage extends { type: string }>(\n value: unknown,\n shapes: Readonly<Record<string, TVariantShape>>,\n reasonFor: (field: string) => string,\n): TMessageDecodeResult<TMessage> {\n if (!isRecord(value)) return { ok: false, reason: 'message must be a JSON object' };\n const type = value['type'];\n if (!isString(type)) return { ok: false, reason: 'message type must be a string' };\n const shape = Object.prototype.hasOwnProperty.call(shapes, type) ? shapes[type] : undefined;\n if (shape === undefined) return { ok: false, reason: `Unknown message type: ${type}` };\n for (const [field, check] of Object.entries(shape)) {\n if (!check(value[field])) return { ok: false, reason: reasonFor(field) };\n }\n return { ok: true, message: value as unknown as TMessage };\n}\n\n/** Total decode of a parsed client frame. */\nexport function decodeClientMessage(value: unknown): TMessageDecodeResult<TClientMessage> {\n return decodeVariant<TClientMessage>(value, CLIENT_MESSAGE_SHAPES, (field) =>\n field === 'prompt' ? 'prompt must be a non-empty string' : `${field} has an invalid shape`,\n );\n}\n\n/** Variant-level decode of a parsed server frame (foreign-owned payloads as records, see header). */\nexport function decodeServerMessage(value: unknown): TMessageDecodeResult<TServerMessage> {\n return decodeVariant<TServerMessage>(\n value,\n SERVER_MESSAGE_SHAPES,\n (field) => `${field} has an invalid shape`,\n );\n}\n\n/** `raw string → JSON → owner decoder`, the one path a carrier implements. */\nexport function decodeFrame<TMessage>(\n data: string,\n decode: (value: unknown) => TMessageDecodeResult<TMessage>,\n): TMessageDecodeResult<TMessage> {\n if (data.length > MAX_INBOUND_FRAME_BYTES) return { ok: false, reason: 'Frame too large' };\n let parsed: unknown;\n try {\n parsed = JSON.parse(data);\n // allow-fallback: the parse failure is returned as a typed refusal the carrier answers on the wire\n } catch {\n return { ok: false, reason: 'Invalid JSON' };\n }\n return decode(parsed);\n}\n","import type { TClientMessage } from './wire-messages.js';\n\n/**\n * The only inbound messages an observer may send: reads of this session. An allowlist, so a message\n * type added later is refused to observers until someone decides it is a read. `get-prompts` is left\n * out: an observer never receives prompts, open ones included.\n *\n * The host refuses anything else from an observer, and a client in observe mode sends only these, so\n * both sides read this one list.\n */\nexport const OBSERVER_MESSAGES: ReadonlySet<TClientMessage['type']> = new Set<\n TClientMessage['type']\n>([\n 'get-messages',\n 'get-history',\n 'get-context',\n 'get-status',\n 'get-commands',\n 'list-models',\n 'get-executing',\n 'get-pending',\n 'get-execution-workspace',\n 'read-execution-detail',\n 'get-agent-definitions',\n 'get-usage-report',\n 'list-sessions',\n 'get-background-tasks',\n 'get-background-task',\n 'get-background-job-groups',\n 'get-background-job-group',\n 'wait-background-job-group',\n 'read-background-task-log',\n // #3282 §4a: reading the Settings snapshot is a pure read of this session's own configuration.\n // `update-settings` stays out — an observer never writes.\n 'get-settings',\n // #3282 §4c: the Project panel's reads — git status, one file's diff, project memory. All three are\n // read-only (there is no \"restore\"/write counterpart in this feature — see the SPEC.md design\n // decision on why checkpoints/rewind are excluded entirely), so all three are observer-safe.\n 'project-status',\n 'project-diff',\n 'project-memory',\n]);\n\n/** Whether an observer may send a message of this type. */\nexport function isObserverMessageType(type: string): boolean {\n return (OBSERVER_MESSAGES as ReadonlySet<string>).has(type);\n}\n"],"mappings":"qHA4BA,MAAa,EAA0B,EAAI,KAAO,KAIlD,SAAS,EAAS,EAAkC,CAClD,OAAO,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,CAAK,CAC5E,CACA,MAAM,EAAY,GAA4B,OAAO,GAAM,SACrD,EAAoB,GAA4B,OAAO,GAAM,UAAY,EAAE,OAAS,EACpF,EAAa,GAA6B,OAAO,GAAM,UACvD,EAAkB,GAA4B,OAAO,GAAM,UAAY,OAAO,SAAS,CAAC,EACxF,EAAW,GAA4B,OAAO,cAAc,CAAC,GAAM,GAAgB,EACnF,EACH,GACA,GACC,IAAM,IAAA,IAAa,EAAM,CAAC,EACxB,EAAiB,GAAwB,MAAM,QAAQ,CAAC,GAAK,EAAE,MAAM,CAAQ,EAC7E,EAAoB,GAAwB,IAAM,MAAQ,EAAS,CAAC,EACpE,EACH,GACA,GACC,OAAO,GAAM,UAAY,EAAQ,SAAS,CAAC,EAEzC,EAEF,CAAE,KAAM,GAAM,eAAgB,GAAM,KAAM,GAAM,SAAU,EAAK,EAE7D,EAAsB,GAC1B,EAAS,CAAC,GAC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ACA,uBACA,sBACA,4BACA,2BACA,4BACA,2BAGA,eAIA,iBACA,eACA,gBACF,CAAC,EAGD,SAAgB,EAAsB,EAAuB,CAC3D,OAAQ,EAA0C,IAAI,CAAI,CAC5D"}
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { IAskRequestEvent, IBranchEvent, IContextFileRefreshedEvent, IExecutionResult, IModelListGroup, IPermissionRequestEvent, IPlanApprovalEvent, IPromptResolvedEvent, ISessionConversationRead, ISessionListing, ISessionRenamedEvent, ISessionStatusSnapshot, ISessionSwitchedEvent, ISettingsSnapshot, IToolState, IUiIntentEvent, TDriverId, TPermissionResultValue, TProjectDiffRead, TProjectMemoryRead, TProjectStatusRead, TSessionChangeRefusalCode, TSessionDeleteRefusalCode, TSettingsPatch, TTurnSource, TWaitingLoopStopOutcome } from "@robota-sdk/agent-interface-session";
|
|
2
|
+
import { IPersonalUsageReport, IPersonalUsageRequest, IUsageBySourceReport } from "@robota-sdk/agent-interface-analytics";
|
|
3
|
+
import { ICommandListEntry, ICommandResult, ICommandSkillListEntry } from "@robota-sdk/agent-interface-command";
|
|
4
|
+
import { IBackgroundJobGroupState, IBackgroundTaskInput, IBackgroundTaskListFilter, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, IBackgroundTaskState, IExecutionDetailCursor, IExecutionDetailPage, IExecutionWorkspaceSnapshot, TBackgroundJobGroupEvent, TBackgroundTaskEvent } from "@robota-sdk/agent-interface-execution";
|
|
5
|
+
import { TActionResponse } from "@robota-sdk/agent-interface-transport";
|
|
6
|
+
//#region src/wire-messages.d.ts
|
|
7
|
+
type TBackgroundControlAction = 'cancel' | 'close' | 'send';
|
|
8
|
+
type THistoryEntry = ReturnType<ISessionConversationRead['getFullHistory']>[number];
|
|
9
|
+
/**
|
|
10
|
+
* #3282 §4: one agent the switcher can offer. `definedIn` is a plain-words location — a discovered
|
|
11
|
+
* file's path, or "Built-in" — never a raw internal id.
|
|
12
|
+
*/
|
|
13
|
+
interface IWireAgentDefinitionSummary {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
definedIn: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* #3189: one entry of the session's full history as it crosses the wire. The same record the session
|
|
20
|
+
* keeps, except that `timestamp` is an ISO 8601 string: a `Date` does not survive JSON, and a
|
|
21
|
+
* declared `Date` that arrives as a string would let a client call `Date` methods on a string.
|
|
22
|
+
*/
|
|
23
|
+
interface IWireHistoryEntry extends Omit<THistoryEntry, 'timestamp'> {
|
|
24
|
+
/** ISO 8601. */
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* #3189: a turn's result as it crosses the wire. The session's whole history stays behind: it only
|
|
29
|
+
* grows, so a client reads it in bounded pages with `get-history` instead.
|
|
30
|
+
*/
|
|
31
|
+
type TWireExecutionResult = Omit<IExecutionResult, 'history'>;
|
|
32
|
+
/** Inbound message from client to server. */
|
|
33
|
+
type TClientMessage = {
|
|
34
|
+
type: 'submit';
|
|
35
|
+
prompt: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'command';
|
|
38
|
+
name: string;
|
|
39
|
+
args?: string;
|
|
40
|
+
requestId?: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'abort';
|
|
43
|
+
} | {
|
|
44
|
+
type: 'cancel-queue';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'get-messages';
|
|
47
|
+
} | {
|
|
48
|
+
type: 'get-history';
|
|
49
|
+
fromIndex?: number;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'get-prompts';
|
|
52
|
+
} | {
|
|
53
|
+
type: 'get-context';
|
|
54
|
+
} | {
|
|
55
|
+
type: 'get-commands';
|
|
56
|
+
} | {
|
|
57
|
+
type: 'get-status';
|
|
58
|
+
} | {
|
|
59
|
+
type: 'list-models';
|
|
60
|
+
requestId: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'get-agent-definitions';
|
|
63
|
+
requestId: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'list-sessions';
|
|
66
|
+
requestId: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'new-session';
|
|
69
|
+
requestId?: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'switch-session';
|
|
72
|
+
sessionId: string;
|
|
73
|
+
requestId?: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'rename-session';
|
|
76
|
+
sessionId: string;
|
|
77
|
+
name: string;
|
|
78
|
+
requestId: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'delete-session';
|
|
81
|
+
sessionId: string;
|
|
82
|
+
requestId: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: 'get-usage-report';
|
|
85
|
+
} | {
|
|
86
|
+
type: 'get-personal-usage-report';
|
|
87
|
+
requestId: string;
|
|
88
|
+
period: IPersonalUsageRequest['period'];
|
|
89
|
+
timezone: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: 'get-stored-session-usage-report';
|
|
92
|
+
requestId: string;
|
|
93
|
+
sessionId: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'get-executing';
|
|
96
|
+
} | {
|
|
97
|
+
type: 'get-pending';
|
|
98
|
+
} | {
|
|
99
|
+
type: 'get-execution-workspace';
|
|
100
|
+
} | {
|
|
101
|
+
type: 'read-execution-detail';
|
|
102
|
+
requestId: string;
|
|
103
|
+
entryId: string;
|
|
104
|
+
cursor?: IExecutionDetailCursor;
|
|
105
|
+
} | {
|
|
106
|
+
type: 'stop-waiting-loop';
|
|
107
|
+
requestId: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: 'project-status';
|
|
110
|
+
requestId: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: 'project-diff';
|
|
113
|
+
requestId: string;
|
|
114
|
+
path: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'project-memory';
|
|
117
|
+
requestId: string;
|
|
118
|
+
} | {
|
|
119
|
+
type: 'get-background-tasks';
|
|
120
|
+
filter?: IBackgroundTaskListFilter;
|
|
121
|
+
} | {
|
|
122
|
+
type: 'get-background-task';
|
|
123
|
+
taskId: string;
|
|
124
|
+
} | {
|
|
125
|
+
type: 'get-background-job-groups';
|
|
126
|
+
} | {
|
|
127
|
+
type: 'get-background-job-group';
|
|
128
|
+
groupId: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'wait-background-job-group';
|
|
131
|
+
groupId: string;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'cancel-background-task';
|
|
134
|
+
taskId: string;
|
|
135
|
+
reason?: string;
|
|
136
|
+
} | {
|
|
137
|
+
type: 'close-background-task';
|
|
138
|
+
taskId: string;
|
|
139
|
+
} | {
|
|
140
|
+
type: 'send-background-task';
|
|
141
|
+
taskId: string;
|
|
142
|
+
input: IBackgroundTaskInput;
|
|
143
|
+
} | {
|
|
144
|
+
type: 'read-background-task-log';
|
|
145
|
+
taskId: string;
|
|
146
|
+
cursor?: IBackgroundTaskLogCursor;
|
|
147
|
+
} | {
|
|
148
|
+
type: 'permission-response';
|
|
149
|
+
id: string;
|
|
150
|
+
result: TPermissionResultValue;
|
|
151
|
+
} | {
|
|
152
|
+
type: 'ask-response';
|
|
153
|
+
id: string;
|
|
154
|
+
response: TActionResponse;
|
|
155
|
+
} | {
|
|
156
|
+
type: 'resume';
|
|
157
|
+
lastSeq: number;
|
|
158
|
+
} | {
|
|
159
|
+
type: 'ack';
|
|
160
|
+
seq: number;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'get-settings';
|
|
163
|
+
requestId: string;
|
|
164
|
+
} | {
|
|
165
|
+
type: 'update-settings';
|
|
166
|
+
requestId: string;
|
|
167
|
+
patch: TSettingsPatch;
|
|
168
|
+
};
|
|
169
|
+
/** Outbound message from server to client. */
|
|
170
|
+
type TServerMessage = {
|
|
171
|
+
type: 'text_delta';
|
|
172
|
+
delta: string;
|
|
173
|
+
driverId?: TDriverId;
|
|
174
|
+
} | {
|
|
175
|
+
type: 'user_message';
|
|
176
|
+
content: string;
|
|
177
|
+
driverId?: TDriverId;
|
|
178
|
+
} | {
|
|
179
|
+
type: 'tool_start';
|
|
180
|
+
state: IToolState;
|
|
181
|
+
driverId?: TDriverId;
|
|
182
|
+
} | {
|
|
183
|
+
type: 'tool_end';
|
|
184
|
+
state: IToolState;
|
|
185
|
+
driverId?: TDriverId;
|
|
186
|
+
} | {
|
|
187
|
+
type: 'thinking';
|
|
188
|
+
isThinking: boolean;
|
|
189
|
+
driverId?: TDriverId;
|
|
190
|
+
} | {
|
|
191
|
+
type: 'complete';
|
|
192
|
+
result: TWireExecutionResult;
|
|
193
|
+
driverId?: TDriverId;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'interrupted';
|
|
196
|
+
result: TWireExecutionResult;
|
|
197
|
+
driverId?: TDriverId;
|
|
198
|
+
} | {
|
|
199
|
+
type: 'error';
|
|
200
|
+
/** The raw failure text — kept for a "Details" disclosure; never the whole story on its own. */
|
|
201
|
+
message: string;
|
|
202
|
+
/**
|
|
203
|
+
* What kind of failure this was, when it's known — so a renderer can say what happened and
|
|
204
|
+
* what to do next in plain words instead of showing `message` verbatim (#3289 §3). Additive:
|
|
205
|
+
* absent for a session error this classification does not recognize (unchanged behavior).
|
|
206
|
+
*/
|
|
207
|
+
code?: 'auth' | 'rate_limit' | 'model_unavailable' | 'network' | 'provider';
|
|
208
|
+
/** The provider/profile name the failure came from, when `code` names one. */
|
|
209
|
+
provider?: string;
|
|
210
|
+
/** For `code: 'rate_limit'`, how long until a retry may succeed, when the provider said so. */
|
|
211
|
+
retryAfterSeconds?: number;
|
|
212
|
+
/**
|
|
213
|
+
* For `code: 'model_unavailable'`, the model the failed request tried — captured at the moment
|
|
214
|
+
* of failure so a renderer never has to fall back to whatever model is live by the time it
|
|
215
|
+
* draws this notice (which may already be a different one the person switched to).
|
|
216
|
+
*/
|
|
217
|
+
model?: string;
|
|
218
|
+
driverId?: TDriverId;
|
|
219
|
+
} | {
|
|
220
|
+
type: 'command_result';
|
|
221
|
+
name: string;
|
|
222
|
+
message: string;
|
|
223
|
+
success: boolean;
|
|
224
|
+
data?: ICommandResult['data'];
|
|
225
|
+
/** The `requestId` of the `command` this answers, when it carried one. */
|
|
226
|
+
requestId?: string;
|
|
227
|
+
} | {
|
|
228
|
+
type: 'messages';
|
|
229
|
+
messages: ReturnType<ISessionConversationRead['getMessages']>;
|
|
230
|
+
/**
|
|
231
|
+
* #3288 §2: the SAME history, projected into display segments (text runs and finished tool
|
|
232
|
+
* calls, diffs included) — so a reload/reconnect/resume replay shows tool rows instead of bare
|
|
233
|
+
* text. Optional so an older host that has not grown `getMessagesDisplay()` yet still sends a
|
|
234
|
+
* valid frame; a client without this field falls back to `messages`-only (text bubbles), the
|
|
235
|
+
* same as before this existed.
|
|
236
|
+
*/
|
|
237
|
+
display?: ReturnType<ISessionConversationRead['getMessagesDisplay']>;
|
|
238
|
+
/**
|
|
239
|
+
* #3289 §3: this connection's own server-assigned driver id, carried on the first frame every
|
|
240
|
+
* connection already gets — so a client can tell its OWN turns from a co-driver's instead of
|
|
241
|
+
* treating everything but the literal `'owner'` id as someone else (REMOTE-014 E5 display-only).
|
|
242
|
+
*/
|
|
243
|
+
driverId?: TDriverId;
|
|
244
|
+
} | {
|
|
245
|
+
type: 'history';
|
|
246
|
+
startIndex: number;
|
|
247
|
+
total: number;
|
|
248
|
+
entries: IWireHistoryEntry[];
|
|
249
|
+
} | {
|
|
250
|
+
type: 'context';
|
|
251
|
+
state: ReturnType<ISessionConversationRead['getContextState']>;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'history_changed';
|
|
254
|
+
} | {
|
|
255
|
+
type: 'turn_source';
|
|
256
|
+
source: TTurnSource;
|
|
257
|
+
} | {
|
|
258
|
+
type: 'commands';
|
|
259
|
+
commands: ICommandListEntry[];
|
|
260
|
+
skills: ICommandSkillListEntry[];
|
|
261
|
+
} | {
|
|
262
|
+
type: 'session_status';
|
|
263
|
+
status: ISessionStatusSnapshot;
|
|
264
|
+
} | {
|
|
265
|
+
type: 'model_list';
|
|
266
|
+
requestId: string;
|
|
267
|
+
groups: readonly IModelListGroup[];
|
|
268
|
+
currentProfile?: string;
|
|
269
|
+
currentModel: string;
|
|
270
|
+
} | {
|
|
271
|
+
type: 'agent_definitions';
|
|
272
|
+
requestId: string;
|
|
273
|
+
agents: readonly IWireAgentDefinitionSummary[];
|
|
274
|
+
current: string;
|
|
275
|
+
} | {
|
|
276
|
+
type: 'sessions';
|
|
277
|
+
requestId: string;
|
|
278
|
+
listing: ISessionListing;
|
|
279
|
+
} | {
|
|
280
|
+
type: 'sessions_error';
|
|
281
|
+
requestId: string;
|
|
282
|
+
code: 'not_available' | 'list_failed';
|
|
283
|
+
message: string;
|
|
284
|
+
} | {
|
|
285
|
+
type: 'session_switched';
|
|
286
|
+
event: ISessionSwitchedEvent;
|
|
287
|
+
} | {
|
|
288
|
+
type: 'session_change_failed';
|
|
289
|
+
code: TSessionChangeRefusalCode;
|
|
290
|
+
message: string;
|
|
291
|
+
requestId?: string;
|
|
292
|
+
} | {
|
|
293
|
+
type: 'session_renamed_in_list';
|
|
294
|
+
requestId: string;
|
|
295
|
+
sessionId: string;
|
|
296
|
+
name: string;
|
|
297
|
+
} | {
|
|
298
|
+
type: 'session_rename_failed';
|
|
299
|
+
requestId: string;
|
|
300
|
+
message: string;
|
|
301
|
+
} | {
|
|
302
|
+
type: 'session_deleted';
|
|
303
|
+
requestId: string;
|
|
304
|
+
sessionId: string;
|
|
305
|
+
} | {
|
|
306
|
+
type: 'session_delete_failed';
|
|
307
|
+
requestId: string;
|
|
308
|
+
code: TSessionDeleteRefusalCode;
|
|
309
|
+
message: string;
|
|
310
|
+
} | {
|
|
311
|
+
type: 'usage_report';
|
|
312
|
+
report: IUsageBySourceReport;
|
|
313
|
+
} | {
|
|
314
|
+
type: 'personal_usage_report';
|
|
315
|
+
requestId: string;
|
|
316
|
+
report: IPersonalUsageReport;
|
|
317
|
+
} | {
|
|
318
|
+
type: 'personal_usage_report_error';
|
|
319
|
+
requestId: string;
|
|
320
|
+
code: 'not_available' | 'report_failed';
|
|
321
|
+
message: string;
|
|
322
|
+
} | {
|
|
323
|
+
type: 'stored_session_usage_report';
|
|
324
|
+
requestId: string;
|
|
325
|
+
sessionId: string;
|
|
326
|
+
report: IUsageBySourceReport;
|
|
327
|
+
} | {
|
|
328
|
+
type: 'stored_session_usage_report_error';
|
|
329
|
+
requestId: string;
|
|
330
|
+
sessionId: string;
|
|
331
|
+
code: 'not_available' | 'report_failed';
|
|
332
|
+
message: string;
|
|
333
|
+
} | {
|
|
334
|
+
type: 'executing';
|
|
335
|
+
executing: boolean;
|
|
336
|
+
} | {
|
|
337
|
+
type: 'pending';
|
|
338
|
+
pending: string | null;
|
|
339
|
+
pendingCount?: number;
|
|
340
|
+
} | {
|
|
341
|
+
type: 'execution_workspace_event';
|
|
342
|
+
snapshot: IExecutionWorkspaceSnapshot;
|
|
343
|
+
} | {
|
|
344
|
+
type: 'execution_detail';
|
|
345
|
+
requestId: string;
|
|
346
|
+
page: IExecutionDetailPage;
|
|
347
|
+
} | {
|
|
348
|
+
type: 'execution_detail_error';
|
|
349
|
+
requestId: string;
|
|
350
|
+
message: string;
|
|
351
|
+
} | {
|
|
352
|
+
type: 'waiting_loop_stop';
|
|
353
|
+
requestId: string;
|
|
354
|
+
outcome: TWaitingLoopStopOutcome;
|
|
355
|
+
} | {
|
|
356
|
+
type: 'project_status';
|
|
357
|
+
requestId: string;
|
|
358
|
+
result: TProjectStatusRead;
|
|
359
|
+
} | {
|
|
360
|
+
type: 'project_diff';
|
|
361
|
+
requestId: string;
|
|
362
|
+
result: TProjectDiffRead;
|
|
363
|
+
} | {
|
|
364
|
+
type: 'project_memory';
|
|
365
|
+
requestId: string;
|
|
366
|
+
result: TProjectMemoryRead;
|
|
367
|
+
} | {
|
|
368
|
+
type: 'background_task_event';
|
|
369
|
+
event: TBackgroundTaskEvent;
|
|
370
|
+
} | {
|
|
371
|
+
type: 'background_job_group_event';
|
|
372
|
+
event: TBackgroundJobGroupEvent;
|
|
373
|
+
} | {
|
|
374
|
+
type: 'plan_event';
|
|
375
|
+
event: IPlanApprovalEvent;
|
|
376
|
+
} | {
|
|
377
|
+
type: 'context_file_refreshed';
|
|
378
|
+
event: IContextFileRefreshedEvent;
|
|
379
|
+
} | {
|
|
380
|
+
type: 'branch_event';
|
|
381
|
+
event: IBranchEvent;
|
|
382
|
+
} | {
|
|
383
|
+
type: 'background_tasks';
|
|
384
|
+
tasks: IBackgroundTaskState[];
|
|
385
|
+
} | {
|
|
386
|
+
type: 'background_task';
|
|
387
|
+
taskId: string;
|
|
388
|
+
task: IBackgroundTaskState | null;
|
|
389
|
+
} | {
|
|
390
|
+
type: 'background_job_groups';
|
|
391
|
+
groups: IBackgroundJobGroupState[];
|
|
392
|
+
} | {
|
|
393
|
+
type: 'background_job_group';
|
|
394
|
+
groupId: string;
|
|
395
|
+
group: IBackgroundJobGroupState | null;
|
|
396
|
+
} | {
|
|
397
|
+
type: 'background_task_log';
|
|
398
|
+
taskId: string;
|
|
399
|
+
page: IBackgroundTaskLogPage;
|
|
400
|
+
} | {
|
|
401
|
+
type: 'permission_request';
|
|
402
|
+
event: IPermissionRequestEvent;
|
|
403
|
+
} | {
|
|
404
|
+
type: 'ask_request';
|
|
405
|
+
event: IAskRequestEvent;
|
|
406
|
+
} | {
|
|
407
|
+
type: 'prompt_resolved';
|
|
408
|
+
event: IPromptResolvedEvent;
|
|
409
|
+
} | {
|
|
410
|
+
type: 'ui_intent';
|
|
411
|
+
event: IUiIntentEvent;
|
|
412
|
+
} | {
|
|
413
|
+
type: 'session_renamed';
|
|
414
|
+
event: ISessionRenamedEvent;
|
|
415
|
+
} | {
|
|
416
|
+
type: 'history_cleared';
|
|
417
|
+
} | {
|
|
418
|
+
type: 'background_task_control_result';
|
|
419
|
+
action: TBackgroundControlAction;
|
|
420
|
+
taskId: string;
|
|
421
|
+
success: boolean;
|
|
422
|
+
message?: string;
|
|
423
|
+
} | {
|
|
424
|
+
type: 'protocol_error';
|
|
425
|
+
message: string;
|
|
426
|
+
requestId?: string;
|
|
427
|
+
} | {
|
|
428
|
+
type: 'resume_gap';
|
|
429
|
+
} | {
|
|
430
|
+
type: 'settings';
|
|
431
|
+
requestId: string;
|
|
432
|
+
settings: ISettingsSnapshot;
|
|
433
|
+
} | {
|
|
434
|
+
type: 'settings_error';
|
|
435
|
+
requestId: string;
|
|
436
|
+
code: 'not_available' | 'invalid' | 'refused' | 'update_failed';
|
|
437
|
+
message: string;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* REMOTE-013 E4: a server message stamped with its monotonic session sequence number (added by the
|
|
441
|
+
* {@link SessionResumeBridge} on the reconnectable WebRTC path). Intersecting over the union distributes the
|
|
442
|
+
* `seq` field onto every variant. The WS localhost path never stamps it (a `type`-dispatching client ignores
|
|
443
|
+
* an absent/extra `seq`).
|
|
444
|
+
*/
|
|
445
|
+
type TSeqServerMessage = TServerMessage & {
|
|
446
|
+
seq: number;
|
|
447
|
+
};
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/message-decoders.d.ts
|
|
450
|
+
type TMessageDecodeResult<TMessage> = {
|
|
451
|
+
readonly ok: true;
|
|
452
|
+
readonly message: TMessage;
|
|
453
|
+
} | {
|
|
454
|
+
readonly ok: false;
|
|
455
|
+
readonly reason: string;
|
|
456
|
+
};
|
|
457
|
+
/** Serialized frames larger than this are refused before any parse (a bounded inbound budget). */
|
|
458
|
+
declare const MAX_INBOUND_FRAME_BYTES: number;
|
|
459
|
+
/** Total decode of a parsed client frame. */
|
|
460
|
+
declare function decodeClientMessage(value: unknown): TMessageDecodeResult<TClientMessage>;
|
|
461
|
+
/** Variant-level decode of a parsed server frame (foreign-owned payloads as records, see header). */
|
|
462
|
+
declare function decodeServerMessage(value: unknown): TMessageDecodeResult<TServerMessage>;
|
|
463
|
+
/** `raw string → JSON → owner decoder`, the one path a carrier implements. */
|
|
464
|
+
declare function decodeFrame<TMessage>(data: string, decode: (value: unknown) => TMessageDecodeResult<TMessage>): TMessageDecodeResult<TMessage>;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/observer-messages.d.ts
|
|
467
|
+
/** Whether an observer may send a message of this type. */
|
|
468
|
+
declare function isObserverMessageType(type: string): boolean;
|
|
469
|
+
//#endregion
|
|
470
|
+
export { decodeFrame as a, IWireHistoryEntry as c, TServerMessage as d, TWireExecutionResult as f, decodeClientMessage as i, TClientMessage as l, MAX_INBOUND_FRAME_BYTES as n, decodeServerMessage as o, TMessageDecodeResult as r, IWireAgentDefinitionSummary as s, isObserverMessageType as t, TSeqServerMessage as u };
|
|
471
|
+
//# sourceMappingURL=observer-messages-Dnff2Tdb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observer-messages-Dnff2Tdb.d.ts","names":[],"sources":["../../src/wire-messages.ts","../../src/message-decoders.ts","../../src/observer-messages.ts"],"mappings":";;;;;;KAyDY;KAEP,gBAAgB,WAAW;;;;;UAMf;EACf;EACA;EACA;;;;;;;UAQe,0BAA0B,KAAK;;EAE9C;;;;;;KAOU,uBAAuB,KAAK;;KAG5B;EACN;EAAgB;;EAGhB;EAAiB;EAAc;EAAe;;EAC9C;;EACA;;EACA;;EAIA;EAAqB;;EAGrB;;EACA;;EAGA;;EACA;;EAIA;EAAqB;;EAIrB;EAA+B;;EAG/B;EAAuB;;EACvB;EAAqB;;EACrB;EAAwB;EAAmB;;EAG3C;EAAwB;EAAmB;EAAc;;EAGzD;EAAwB;EAAmB;;EAE3C;;EAEA;EACA;EACA,QAAQ;EACR;;EAEA;EAAyC;EAAmB;;EAC5D;;EACA;;EACA;;EAIA;EACA;EACA;EACA,SAAS;;EAGT;EAA2B;;EAG3B;EAAwB;;EAIxB;EAAsB;EAAmB;;EAGzC;EAAwB;;EACxB;EAA8B,SAAS;;EACvC;EAA6B;;EAC7B;;EACA;EAAkC;;EAClC;EAAmC;;EACnC;EAAgC;EAAgB;;EAChD;EAA+B;;EAC/B;EAA8B;EAAgB,OAAO;;EACrD;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