@aimount/core 0.1.0 → 0.2.0-beta.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 CHANGED
@@ -27,8 +27,8 @@ stays free of transport, UI, and orchestration concerns.
27
27
 
28
28
  ## Runtime API relation
29
29
 
30
- `@aimount/runtime` remains the transport-facing compatibility package for wire,
31
- codec, and protocol surfaces while re-exporting the core-owned runtime model layer.
30
+ `@aimount/core` owns the current Runtime API SDK contract, including public types,
31
+ schemas, and parsers used by transport packages.
32
32
 
33
33
  ## Tool execution relation
34
34
 
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){const o=new Set;for(const e of t)e.type==="tool"&&(e.state==="done"||e.state==="error"||e.state==="canceled"||e.toolCallId.length>0&&o.add(e.toolCallId));return Array.from(o)}function r(t){return n(t).length>0?{version:1,code:"waiting_tool_outputs",reason:"system.awaiting_tool_outputs"}:{version:1,code:"completed",reason:"provider.stop"}}function s(t){return a(t),t}function a(t,o){if(typeof t.execute=="function")return;const e="createTool";throw new Error(`${e} now requires execute(); legacy workflow is no longer supported.`)}exports.collectPendingToolCallIdsFromAssistantParts=n;exports.createTool=s;exports.toDefaultStatusFromAssistantParts=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),o=e.z.record(e.z.string(),e.z.unknown()),a=e.z.number().int().nonnegative(),d=e.z.object({code:e.z.string(),message:e.z.string(),details:o.optional()}),C=e.z.object({agentId:e.z.string(),userId:e.z.string()}),k=C.extend({profileId:e.z.string()}),I=e.z.object({id:e.z.string(),agentId:e.z.string(),userId:e.z.string(),title:e.z.string().nullable(),createdAt:e.z.string(),updatedAt:e.z.string()}),P=e.z.object({id:e.z.string(),agentId:e.z.string(),userId:e.z.string(),title:e.z.string().nullable(),createdAt:e.z.string(),updatedAt:e.z.string(),lastActivityAt:e.z.string()}),l=e.z.object({roleId:e.z.string(),modelId:e.z.string()}),U=e.z.string().min(1),y=e.z.object({sessionId:e.z.string(),executionToken:e.z.string(),status:U,inputBoundary:e.z.object({lastUserMessageId:e.z.string()}).nullable().optional(),agentMessageId:e.z.string().nullable().optional(),selection:l.optional(),createdAt:e.z.string(),updatedAt:e.z.string()}),R=e.z.object({type:e.z.literal("text"),id:e.z.string(),text:e.z.string()}),T=e.z.object({type:e.z.literal("file"),id:e.z.string(),fileId:e.z.string(),name:e.z.string().optional(),mediaType:e.z.string().optional(),sizeBytes:a.optional()}),j=e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("text"),text:e.z.string()}),e.z.object({type:e.z.literal("file"),fileId:e.z.string()})]),O=e.z.discriminatedUnion("status",[e.z.object({type:e.z.literal("tool_call"),id:e.z.string(),name:e.z.string(),status:e.z.literal("succeeded"),input:o,result:e.z.unknown()}),e.z.object({type:e.z.literal("tool_call"),id:e.z.string(),name:e.z.string(),status:e.z.literal("failed"),input:o,error:d}),e.z.object({type:e.z.literal("tool_call"),id:e.z.string(),name:e.z.string(),status:e.z.literal("denied"),input:o,denial:d}),e.z.object({type:e.z.literal("tool_call"),id:e.z.string(),name:e.z.string(),status:e.z.literal("cancelled"),input:o,cancellation:d})]),F=e.z.object({type:e.z.literal("unknown"),id:e.z.string(),originalType:e.z.string(),payload:e.z.unknown()}),M=e.z.object({type:e.z.string(),id:e.z.string().optional()}).passthrough(),B=e.z.object({roleId:e.z.string().optional(),modelId:e.z.string().optional()}).transform(n=>{const t={};return n.roleId!==void 0&&(t.roleId=n.roleId),n.modelId!==void 0&&(t.modelId=n.modelId),t}),W=e.z.object({input:e.z.array(e.z.string().min(1)),output:e.z.array(e.z.string().min(1))}),S=e.z.object({id:e.z.string(),name:e.z.string(),modalities:W.optional()}),q=e.z.object({scope:k,selection:e.z.object({roles:e.z.array(S),models:e.z.array(S),defaults:l.nullable()}),limits:e.z.object({maxInputTextLength:a,maxMessages:a.nullable(),maxTokens:a.nullable(),messagesPerMinute:a.nullable(),messagesPerHour:a.nullable(),messagesPerDay:a.nullable()})}),L=e.z.object({lastUserMessageId:e.z.string()}),u=e.z.object({type:e.z.string(),id:e.z.string(),sessionId:e.z.string(),createdAt:e.z.string(),metadata:o.optional()}),N=e.z.enum(["in_progress","completed","failed","cancelled"]),V=u.extend({type:e.z.literal("user_message"),commandId:e.z.string().optional(),content:e.z.array(e.z.unknown()),environment:e.z.unknown().optional(),selection:l.optional()}),w=e.z.object({id:e.z.string(),commandId:e.z.string(),content:e.z.array(j),selection:l.optional(),createdAt:e.z.string()}),D=u.extend({type:e.z.literal("agent_message"),status:N,inputBoundary:L.optional(),selection:l.optional(),content:e.z.array(e.z.unknown())}),H=u.extend({type:e.z.literal("compaction"),status:e.z.enum(["in_progress","completed","failed","cancelled"]),reason:e.z.string().optional(),beforeItemId:e.z.string().optional(),summary:e.z.string().optional(),retainedContext:e.z.string().optional(),error:d.optional(),cancellation:d.optional()}),$=e.z.object({eventId:e.z.string(),previousEventId:e.z.string().nullable(),sessionId:e.z.string(),commandId:e.z.string().optional(),type:e.z.string().min(1),createdAt:e.z.string(),payload:o}),G=e.z.object({itemId:e.z.string(),partId:e.z.string(),partType:e.z.literal("text"),delta:e.z.string()}),J=e.z.object({itemId:e.z.string(),part:R.extend({id:e.z.string()})}),K=e.z.object({pendingInput:e.z.object({id:e.z.string(),sessionId:e.z.string(),commandId:e.z.string(),content:e.z.array(j),requestedSelection:B.optional(),selection:l.optional(),createdAt:e.z.string()})}),Q=e.z.object({pendingInputId:e.z.string(),commandId:e.z.string(),itemId:e.z.string()}),X=e.z.unknown().transform((n,t)=>{try{return x(n)}catch{return t.addIssue({code:"custom",message:"invalid_runtime_event"}),e.z.NEVER}}),Y=e.z.object({events:e.z.array(X),nextEventId:e.z.string().nullable()}),_=e.z.object({commandId:e.z.string(),status:e.z.literal("accepted")}),Z=_,ee=_,te=e.z.object({fileId:e.z.string(),status:e.z.literal("draft"),uploadUrl:e.z.string(),uploadUrlExpiresAt:e.z.string(),name:e.z.string(),mediaType:e.z.string(),sizeBytes:a}),ne=e.z.object({fileId:e.z.string(),uploadUrl:e.z.string(),uploadUrlExpiresAt:e.z.string()}),ie=e.z.object({fileId:e.z.string(),status:e.z.literal("ready"),name:e.z.string(),mediaType:e.z.string(),sizeBytes:a}),se=e.z.object({url:e.z.string(),expiresAt:e.z.string()}),ae=e.z.object({session:I,execution:y,lastEventId:e.z.string(),capabilities:e.z.object({sendText:e.z.discriminatedUnion("available",[e.z.object({available:e.z.literal(!0)}),e.z.object({available:e.z.literal(!1),reason:e.z.enum(["session_unavailable","maintenance"])})]),stop:e.z.discriminatedUnion("available",[e.z.object({available:e.z.literal(!0)}),e.z.object({available:e.z.literal(!1),reason:e.z.enum(["execution_not_active","session_unavailable","maintenance"])})])}),items:e.z.object({entries:e.z.array(e.z.unknown()),continuityToken:e.z.string(),olderCursor:e.z.string().nullable(),newerCursor:e.z.string().nullable(),hasOlder:e.z.boolean(),hasNewer:e.z.boolean()}).transform(n=>({...n,entries:n.entries.map(m)})),pendingInput:e.z.object({entries:e.z.array(w)}).optional().default({entries:[]}),ack:e.z.object({sessionId:e.z.string(),commandId:e.z.string(),status:e.z.literal("accepted")})}),re=e.z.enum(["session_unavailable","maintenance"]),oe=e.z.enum(["execution_not_active","session_unavailable","maintenance"]),f=n=>e.z.discriminatedUnion("available",[e.z.object({available:e.z.literal(!0)}),e.z.object({available:e.z.literal(!1),reason:n})]),de=e.z.object({session:I,execution:y,lastEventId:e.z.string().nullable(),capabilities:e.z.object({sendText:f(re),stop:f(oe)}),items:e.z.object({entries:e.z.array(e.z.unknown()),continuityToken:e.z.string(),olderCursor:e.z.string().nullable(),newerCursor:e.z.string().nullable(),hasOlder:e.z.boolean(),hasNewer:e.z.boolean()}),pendingInput:e.z.object({entries:e.z.array(w)}).optional().default({entries:[]})}).transform(n=>({...n,items:{...n.items,entries:n.items.entries.map(m)}})),le=e.z.object({items:e.z.array(P),nextCursor:e.z.string().nullable()});function ce(n){return s(n,d,"invalid_runtime_error")}function ue(n){return s(n,q,"invalid_runtime_profile_response")}function A(n){return s(n,I,"invalid_runtime_session")}function v(n){return s(n,y,"invalid_runtime_session_execution")}function E(n,t=0){const r=R.safeParse(n);if(r.success)return r.data;const i=T.safeParse(n);if(i.success)return i.data;const p=O.safeParse(n);if(p.success&&me(p.data))return p.data;const b=F.safeParse(n);if(b.success)return b.data;const z=M.safeParse(n);if(z.success)return{type:"unknown",id:z.data.id??`unknown_${t}`,originalType:z.data.type,payload:n};throw new Error("invalid_runtime_content")}function me(n){switch(n.status){case"succeeded":return Object.hasOwn(n,"result");case"failed":return Object.hasOwn(n,"error");case"denied":return Object.hasOwn(n,"denial");case"cancelled":return Object.hasOwn(n,"cancellation")}}function m(n){const t=u.safeParse(n);if(!t.success)throw new Error("invalid_runtime_session_item");const r=()=>({...g(t.data),type:"unknown",originalType:t.data.type,payload:n});if(t.data.type==="user_message"){const i=V.safeParse(n);if(!i.success)throw new Error("invalid_runtime_session_item");return{...g(i.data),type:"user_message",...i.data.commandId===void 0?{}:{commandId:i.data.commandId},content:h(i.data.content),..."environment"in i.data?{environment:i.data.environment}:{},...i.data.selection===void 0?{}:{selection:i.data.selection}}}if(t.data.type==="agent_message"){const i=D.safeParse(n);if(!i.success)throw new Error("invalid_runtime_session_item");return{...g(i.data),type:"agent_message",status:i.data.status,inputBoundary:i.data.inputBoundary,...i.data.selection===void 0?{}:{selection:i.data.selection},content:h(i.data.content)}}if(t.data.type==="compaction"){const i=H.safeParse(n);if(!i.success)throw new Error("invalid_runtime_session_item");return i.data}return r()}function x(n){const t=s(n,$,"invalid_runtime_event");try{if(t.type==="session.created")return{eventId:t.eventId,previousEventId:null,sessionId:t.sessionId,type:t.type,createdAt:t.createdAt,payload:{session:A(c(t.payload,"session")),execution:v(c(t.payload,"execution"))}};if(t.type==="session_execution.updated")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,...t.commandId===void 0?{}:{commandId:t.commandId},type:t.type,createdAt:t.createdAt,payload:{execution:v(c(t.payload,"execution"))}};if(t.type==="pending_input.created")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,...t.commandId===void 0?{}:{commandId:t.commandId},type:t.type,createdAt:t.createdAt,payload:s(t.payload,K,"invalid_runtime_event")};if(t.type==="pending_input.committed")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,...t.commandId===void 0?{}:{commandId:t.commandId},type:t.type,createdAt:t.createdAt,payload:s(t.payload,Q,"invalid_runtime_event")};if(t.type==="session_item.created"||t.type==="session_item.updated")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,...t.commandId===void 0?{}:{commandId:t.commandId},type:t.type,createdAt:t.createdAt,payload:{item:m(c(t.payload,"item"))}};if(t.type==="session_item.content_delta")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,type:t.type,createdAt:t.createdAt,payload:s(t.payload,G,"invalid_runtime_event")};if(t.type==="session_item.part.created")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,type:t.type,createdAt:t.createdAt,payload:s(t.payload,J,"invalid_runtime_event")}}catch{throw new Error("invalid_runtime_event")}return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,type:"unknown",originalType:t.type,createdAt:t.createdAt,payload:t.payload}}function pe(n){return s(n,Y,"invalid_runtime_session_events_page")}function c(n,t){if(Object.hasOwn(n,t))return n[t];throw new Error("invalid_runtime_event")}function ze(n){return s(n,_,"invalid_runtime_command_ack")}function ge(n){return s(n,Z,"invalid_runtime_input_ack")}function ve(n){return s(n,ee,"invalid_runtime_stop_ack")}function Ie(n){return s(n,te,"invalid_runtime_file_upload_response")}function ye(n){return s(n,ne,"invalid_runtime_file_upload_url_response")}function _e(n){return s(n,ie,"invalid_runtime_file_complete_response")}function be(n){return s(n,se,"invalid_runtime_file_access_response")}function Se(n){return s(n,ae,"invalid_runtime_create_session_response")}function fe(n){return s(n,de,"invalid_runtime_session_view_response")}function he(n){return s(n,le,"invalid_runtime_list_sessions_response")}function s(n,t,r){const i=t.safeParse(n);if(!i.success)throw new Error(r);return i.data}function h(n){try{return n.map((t,r)=>E(t,r))}catch{throw new Error("invalid_runtime_session_item")}}function g(n){return{type:n.type,id:n.id,sessionId:n.sessionId,createdAt:n.createdAt,...n.metadata===void 0?{}:{metadata:n.metadata}}}exports.parseRuntimeCommandAck=ze;exports.parseRuntimeContent=E;exports.parseRuntimeCreateSessionResult=Se;exports.parseRuntimeError=ce;exports.parseRuntimeEventWire=x;exports.parseRuntimeFileAccessUrlResult=be;exports.parseRuntimeFileCompleteResult=_e;exports.parseRuntimeFileUploadResult=Ie;exports.parseRuntimeFileUploadUrlResult=ye;exports.parseRuntimeInputCommandAck=ge;exports.parseRuntimeListSessionsResult=he;exports.parseRuntimeProfile=ue;exports.parseRuntimeSession=A;exports.parseRuntimeSessionEventsPage=pe;exports.parseRuntimeSessionExecution=v;exports.parseRuntimeSessionItem=m;exports.parseRuntimeSessionView=fe;exports.parseRuntimeStopCommandAck=ve;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,2 @@
1
- export * from './shared';
2
- export * from './profile';
3
- export * from './sessions';
4
- export * from './tools';
5
- export * from './assistant-parts';
6
- export * from './messages';
7
- export * from './events';
8
- export * from './runtime-api';
9
- export * from './tool';
10
- export * from './part';
11
- export * from './status';
12
- export * from './feedback';
13
- export * from './message';
14
- export * from './message-data';
15
- export * from './session';
1
+ export * from './shared.js';
2
+ export * from './runtime-api.js';
package/dist/index.es.js CHANGED
@@ -1,31 +1,596 @@
1
- function n(t) {
2
- const o = /* @__PURE__ */ new Set();
3
- for (const e of t)
4
- e.type === "tool" && (e.state === "done" || e.state === "error" || e.state === "canceled" || e.toolCallId.length > 0 && o.add(e.toolCallId));
5
- return Array.from(o);
6
- }
7
- function s(t) {
8
- return n(t).length > 0 ? {
9
- version: 1,
10
- code: "waiting_tool_outputs",
11
- reason: "system.awaiting_tool_outputs"
12
- } : {
13
- version: 1,
14
- code: "completed",
15
- reason: "provider.stop"
1
+ import { z as e } from "zod";
2
+ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(), d = e.object({
3
+ code: e.string(),
4
+ message: e.string(),
5
+ details: o.optional()
6
+ }), x = e.object({
7
+ agentId: e.string(),
8
+ userId: e.string()
9
+ }), R = x.extend({
10
+ profileId: e.string()
11
+ }), I = e.object({
12
+ id: e.string(),
13
+ agentId: e.string(),
14
+ userId: e.string(),
15
+ title: e.string().nullable(),
16
+ createdAt: e.string(),
17
+ updatedAt: e.string()
18
+ }), C = e.object({
19
+ id: e.string(),
20
+ agentId: e.string(),
21
+ userId: e.string(),
22
+ title: e.string().nullable(),
23
+ createdAt: e.string(),
24
+ updatedAt: e.string(),
25
+ lastActivityAt: e.string()
26
+ }), l = e.object({
27
+ roleId: e.string(),
28
+ modelId: e.string()
29
+ }), k = e.string().min(1), v = e.object({
30
+ sessionId: e.string(),
31
+ executionToken: e.string(),
32
+ status: k,
33
+ inputBoundary: e.object({ lastUserMessageId: e.string() }).nullable().optional(),
34
+ agentMessageId: e.string().nullable().optional(),
35
+ selection: l.optional(),
36
+ createdAt: e.string(),
37
+ updatedAt: e.string()
38
+ }), w = e.object({
39
+ type: e.literal("text"),
40
+ id: e.string(),
41
+ text: e.string()
42
+ }), P = e.object({
43
+ type: e.literal("file"),
44
+ id: e.string(),
45
+ fileId: e.string(),
46
+ name: e.string().optional(),
47
+ mediaType: e.string().optional(),
48
+ sizeBytes: a.optional()
49
+ }), A = e.discriminatedUnion(
50
+ "type",
51
+ [
52
+ e.object({ type: e.literal("text"), text: e.string() }),
53
+ e.object({ type: e.literal("file"), fileId: e.string() })
54
+ ]
55
+ ), U = e.discriminatedUnion(
56
+ "status",
57
+ [
58
+ e.object({
59
+ type: e.literal("tool_call"),
60
+ id: e.string(),
61
+ name: e.string(),
62
+ status: e.literal("succeeded"),
63
+ input: o,
64
+ result: e.unknown()
65
+ }),
66
+ e.object({
67
+ type: e.literal("tool_call"),
68
+ id: e.string(),
69
+ name: e.string(),
70
+ status: e.literal("failed"),
71
+ input: o,
72
+ error: d
73
+ }),
74
+ e.object({
75
+ type: e.literal("tool_call"),
76
+ id: e.string(),
77
+ name: e.string(),
78
+ status: e.literal("denied"),
79
+ input: o,
80
+ denial: d
81
+ }),
82
+ e.object({
83
+ type: e.literal("tool_call"),
84
+ id: e.string(),
85
+ name: e.string(),
86
+ status: e.literal("cancelled"),
87
+ input: o,
88
+ cancellation: d
89
+ })
90
+ ]
91
+ ), T = e.object({
92
+ type: e.literal("unknown"),
93
+ id: e.string(),
94
+ originalType: e.string(),
95
+ payload: e.unknown()
96
+ }), O = e.object({
97
+ type: e.string(),
98
+ id: e.string().optional()
99
+ }).passthrough(), B = e.object({
100
+ roleId: e.string().optional(),
101
+ modelId: e.string().optional()
102
+ }).transform((n) => {
103
+ const t = {};
104
+ return n.roleId !== void 0 && (t.roleId = n.roleId), n.modelId !== void 0 && (t.modelId = n.modelId), t;
105
+ }), M = e.object({
106
+ input: e.array(e.string().min(1)),
107
+ output: e.array(e.string().min(1))
108
+ }), f = e.object({
109
+ id: e.string(),
110
+ name: e.string(),
111
+ modalities: M.optional()
112
+ }), F = e.object({
113
+ scope: R,
114
+ selection: e.object({
115
+ roles: e.array(f),
116
+ models: e.array(f),
117
+ defaults: l.nullable()
118
+ }),
119
+ limits: e.object({
120
+ maxInputTextLength: a,
121
+ maxMessages: a.nullable(),
122
+ maxTokens: a.nullable(),
123
+ messagesPerMinute: a.nullable(),
124
+ messagesPerHour: a.nullable(),
125
+ messagesPerDay: a.nullable()
126
+ })
127
+ }), W = e.object({
128
+ lastUserMessageId: e.string()
129
+ }), u = e.object({
130
+ type: e.string(),
131
+ id: e.string(),
132
+ sessionId: e.string(),
133
+ createdAt: e.string(),
134
+ metadata: o.optional()
135
+ }), q = e.enum([
136
+ "in_progress",
137
+ "completed",
138
+ "failed",
139
+ "cancelled"
140
+ ]), z = u.extend({
141
+ type: e.literal("user_message"),
142
+ commandId: e.string().optional(),
143
+ content: e.array(e.unknown()),
144
+ environment: e.unknown().optional(),
145
+ selection: l.optional()
146
+ }), E = e.object({
147
+ id: e.string(),
148
+ commandId: e.string(),
149
+ content: e.array(A),
150
+ selection: l.optional(),
151
+ createdAt: e.string()
152
+ }), L = u.extend({
153
+ type: e.literal("agent_message"),
154
+ status: q,
155
+ inputBoundary: W.optional(),
156
+ selection: l.optional(),
157
+ content: e.array(e.unknown())
158
+ }), N = u.extend({
159
+ type: e.literal("compaction"),
160
+ status: e.enum(["in_progress", "completed", "failed", "cancelled"]),
161
+ reason: e.string().optional(),
162
+ beforeItemId: e.string().optional(),
163
+ summary: e.string().optional(),
164
+ retainedContext: e.string().optional(),
165
+ error: d.optional(),
166
+ cancellation: d.optional()
167
+ }), V = e.object({
168
+ eventId: e.string(),
169
+ previousEventId: e.string().nullable(),
170
+ sessionId: e.string(),
171
+ commandId: e.string().optional(),
172
+ type: e.string().min(1),
173
+ createdAt: e.string(),
174
+ payload: o
175
+ }), D = e.object({
176
+ itemId: e.string(),
177
+ partId: e.string(),
178
+ partType: e.literal("text"),
179
+ delta: e.string()
180
+ }), H = e.object({
181
+ itemId: e.string(),
182
+ part: w.extend({ id: e.string() })
183
+ }), $ = e.object({
184
+ pendingInput: e.object({
185
+ id: e.string(),
186
+ sessionId: e.string(),
187
+ commandId: e.string(),
188
+ content: e.array(A),
189
+ requestedSelection: B.optional(),
190
+ selection: l.optional(),
191
+ createdAt: e.string()
192
+ })
193
+ }), G = e.object({
194
+ pendingInputId: e.string(),
195
+ commandId: e.string(),
196
+ itemId: e.string()
197
+ }), J = e.unknown().transform((n, t) => {
198
+ try {
199
+ return ce(n);
200
+ } catch {
201
+ return t.addIssue({ code: "custom", message: "invalid_runtime_event" }), e.NEVER;
202
+ }
203
+ }), K = e.object({
204
+ events: e.array(J),
205
+ nextEventId: e.string().nullable()
206
+ }), y = e.object({
207
+ commandId: e.string(),
208
+ status: e.literal("accepted")
209
+ }), Q = y, X = y, Y = e.object({
210
+ fileId: e.string(),
211
+ status: e.literal("draft"),
212
+ uploadUrl: e.string(),
213
+ uploadUrlExpiresAt: e.string(),
214
+ name: e.string(),
215
+ mediaType: e.string(),
216
+ sizeBytes: a
217
+ }), Z = e.object({
218
+ fileId: e.string(),
219
+ uploadUrl: e.string(),
220
+ uploadUrlExpiresAt: e.string()
221
+ }), ee = e.object({
222
+ fileId: e.string(),
223
+ status: e.literal("ready"),
224
+ name: e.string(),
225
+ mediaType: e.string(),
226
+ sizeBytes: a
227
+ }), te = e.object({
228
+ url: e.string(),
229
+ expiresAt: e.string()
230
+ }), ne = e.object({
231
+ session: I,
232
+ execution: v,
233
+ lastEventId: e.string(),
234
+ capabilities: e.object({
235
+ sendText: e.discriminatedUnion("available", [
236
+ e.object({ available: e.literal(!0) }),
237
+ e.object({
238
+ available: e.literal(!1),
239
+ reason: e.enum(["session_unavailable", "maintenance"])
240
+ })
241
+ ]),
242
+ stop: e.discriminatedUnion("available", [
243
+ e.object({ available: e.literal(!0) }),
244
+ e.object({
245
+ available: e.literal(!1),
246
+ reason: e.enum(["execution_not_active", "session_unavailable", "maintenance"])
247
+ })
248
+ ])
249
+ }),
250
+ items: e.object({
251
+ entries: e.array(e.unknown()),
252
+ continuityToken: e.string(),
253
+ olderCursor: e.string().nullable(),
254
+ newerCursor: e.string().nullable(),
255
+ hasOlder: e.boolean(),
256
+ hasNewer: e.boolean()
257
+ }).transform((n) => ({
258
+ ...n,
259
+ entries: n.entries.map(_)
260
+ })),
261
+ pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] }),
262
+ ack: e.object({
263
+ sessionId: e.string(),
264
+ commandId: e.string(),
265
+ status: e.literal("accepted")
266
+ })
267
+ }), ie = e.enum(["session_unavailable", "maintenance"]), se = e.enum([
268
+ "execution_not_active",
269
+ "session_unavailable",
270
+ "maintenance"
271
+ ]), S = (n) => e.discriminatedUnion("available", [
272
+ e.object({ available: e.literal(!0) }),
273
+ e.object({ available: e.literal(!1), reason: n })
274
+ ]), ae = e.object({
275
+ session: I,
276
+ execution: v,
277
+ lastEventId: e.string().nullable(),
278
+ capabilities: e.object({
279
+ sendText: S(ie),
280
+ stop: S(se)
281
+ }),
282
+ items: e.object({
283
+ entries: e.array(e.unknown()),
284
+ continuityToken: e.string(),
285
+ olderCursor: e.string().nullable(),
286
+ newerCursor: e.string().nullable(),
287
+ hasOlder: e.boolean(),
288
+ hasNewer: e.boolean()
289
+ }),
290
+ pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] })
291
+ }).transform((n) => ({
292
+ ...n,
293
+ items: {
294
+ ...n.items,
295
+ entries: n.items.entries.map(_)
296
+ }
297
+ })), re = e.object({
298
+ items: e.array(C),
299
+ nextCursor: e.string().nullable()
300
+ });
301
+ function me(n) {
302
+ return s(n, d, "invalid_runtime_error");
303
+ }
304
+ function pe(n) {
305
+ return s(n, F, "invalid_runtime_profile_response");
306
+ }
307
+ function oe(n) {
308
+ return s(n, I, "invalid_runtime_session");
309
+ }
310
+ function h(n) {
311
+ return s(n, v, "invalid_runtime_session_execution");
312
+ }
313
+ function de(n, t = 0) {
314
+ const r = w.safeParse(n);
315
+ if (r.success)
316
+ return r.data;
317
+ const i = P.safeParse(n);
318
+ if (i.success)
319
+ return i.data;
320
+ const m = U.safeParse(n);
321
+ if (m.success && le(m.data))
322
+ return m.data;
323
+ const b = T.safeParse(n);
324
+ if (b.success)
325
+ return b.data;
326
+ const p = O.safeParse(n);
327
+ if (p.success)
328
+ return {
329
+ type: "unknown",
330
+ id: p.data.id ?? `unknown_${t}`,
331
+ originalType: p.data.type,
332
+ payload: n
333
+ };
334
+ throw new Error("invalid_runtime_content");
335
+ }
336
+ function le(n) {
337
+ switch (n.status) {
338
+ case "succeeded":
339
+ return Object.hasOwn(n, "result");
340
+ case "failed":
341
+ return Object.hasOwn(n, "error");
342
+ case "denied":
343
+ return Object.hasOwn(n, "denial");
344
+ case "cancelled":
345
+ return Object.hasOwn(n, "cancellation");
346
+ }
347
+ }
348
+ function _(n) {
349
+ const t = u.safeParse(n);
350
+ if (!t.success)
351
+ throw new Error("invalid_runtime_session_item");
352
+ const r = () => ({
353
+ ...g(t.data),
354
+ type: "unknown",
355
+ originalType: t.data.type,
356
+ payload: n
357
+ });
358
+ if (t.data.type === "user_message") {
359
+ const i = z.safeParse(n);
360
+ if (!i.success)
361
+ throw new Error("invalid_runtime_session_item");
362
+ return {
363
+ ...g(i.data),
364
+ type: "user_message",
365
+ ...i.data.commandId === void 0 ? {} : { commandId: i.data.commandId },
366
+ content: j(i.data.content),
367
+ ..."environment" in i.data ? { environment: i.data.environment } : {},
368
+ ...i.data.selection === void 0 ? {} : { selection: i.data.selection }
369
+ };
370
+ }
371
+ if (t.data.type === "agent_message") {
372
+ const i = L.safeParse(n);
373
+ if (!i.success)
374
+ throw new Error("invalid_runtime_session_item");
375
+ return {
376
+ ...g(i.data),
377
+ type: "agent_message",
378
+ status: i.data.status,
379
+ inputBoundary: i.data.inputBoundary,
380
+ ...i.data.selection === void 0 ? {} : { selection: i.data.selection },
381
+ content: j(i.data.content)
382
+ };
383
+ }
384
+ if (t.data.type === "compaction") {
385
+ const i = N.safeParse(n);
386
+ if (!i.success)
387
+ throw new Error("invalid_runtime_session_item");
388
+ return i.data;
389
+ }
390
+ return r();
391
+ }
392
+ function ce(n) {
393
+ const t = s(
394
+ n,
395
+ V,
396
+ "invalid_runtime_event"
397
+ );
398
+ try {
399
+ if (t.type === "session.created")
400
+ return {
401
+ eventId: t.eventId,
402
+ previousEventId: null,
403
+ sessionId: t.sessionId,
404
+ type: t.type,
405
+ createdAt: t.createdAt,
406
+ payload: {
407
+ session: oe(c(t.payload, "session")),
408
+ execution: h(
409
+ c(t.payload, "execution")
410
+ )
411
+ }
412
+ };
413
+ if (t.type === "session_execution.updated")
414
+ return {
415
+ eventId: t.eventId,
416
+ previousEventId: t.previousEventId,
417
+ sessionId: t.sessionId,
418
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
419
+ type: t.type,
420
+ createdAt: t.createdAt,
421
+ payload: {
422
+ execution: h(
423
+ c(t.payload, "execution")
424
+ )
425
+ }
426
+ };
427
+ if (t.type === "pending_input.created")
428
+ return {
429
+ eventId: t.eventId,
430
+ previousEventId: t.previousEventId,
431
+ sessionId: t.sessionId,
432
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
433
+ type: t.type,
434
+ createdAt: t.createdAt,
435
+ payload: s(
436
+ t.payload,
437
+ $,
438
+ "invalid_runtime_event"
439
+ )
440
+ };
441
+ if (t.type === "pending_input.committed")
442
+ return {
443
+ eventId: t.eventId,
444
+ previousEventId: t.previousEventId,
445
+ sessionId: t.sessionId,
446
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
447
+ type: t.type,
448
+ createdAt: t.createdAt,
449
+ payload: s(
450
+ t.payload,
451
+ G,
452
+ "invalid_runtime_event"
453
+ )
454
+ };
455
+ if (t.type === "session_item.created" || t.type === "session_item.updated")
456
+ return {
457
+ eventId: t.eventId,
458
+ previousEventId: t.previousEventId,
459
+ sessionId: t.sessionId,
460
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
461
+ type: t.type,
462
+ createdAt: t.createdAt,
463
+ payload: {
464
+ item: _(c(t.payload, "item"))
465
+ }
466
+ };
467
+ if (t.type === "session_item.content_delta")
468
+ return {
469
+ eventId: t.eventId,
470
+ previousEventId: t.previousEventId,
471
+ sessionId: t.sessionId,
472
+ type: t.type,
473
+ createdAt: t.createdAt,
474
+ payload: s(
475
+ t.payload,
476
+ D,
477
+ "invalid_runtime_event"
478
+ )
479
+ };
480
+ if (t.type === "session_item.part.created")
481
+ return {
482
+ eventId: t.eventId,
483
+ previousEventId: t.previousEventId,
484
+ sessionId: t.sessionId,
485
+ type: t.type,
486
+ createdAt: t.createdAt,
487
+ payload: s(
488
+ t.payload,
489
+ H,
490
+ "invalid_runtime_event"
491
+ )
492
+ };
493
+ } catch {
494
+ throw new Error("invalid_runtime_event");
495
+ }
496
+ return {
497
+ eventId: t.eventId,
498
+ previousEventId: t.previousEventId,
499
+ sessionId: t.sessionId,
500
+ type: "unknown",
501
+ originalType: t.type,
502
+ createdAt: t.createdAt,
503
+ payload: t.payload
16
504
  };
17
505
  }
18
- function a(t) {
19
- return r(t), t;
506
+ function ge(n) {
507
+ return s(
508
+ n,
509
+ K,
510
+ "invalid_runtime_session_events_page"
511
+ );
512
+ }
513
+ function c(n, t) {
514
+ if (Object.hasOwn(n, t)) return n[t];
515
+ throw new Error("invalid_runtime_event");
516
+ }
517
+ function Ie(n) {
518
+ return s(n, y, "invalid_runtime_command_ack");
519
+ }
520
+ function ve(n) {
521
+ return s(n, Q, "invalid_runtime_input_ack");
522
+ }
523
+ function ye(n) {
524
+ return s(n, X, "invalid_runtime_stop_ack");
20
525
  }
21
- function r(t, o) {
22
- if (typeof t.execute == "function")
23
- return;
24
- const e = "createTool";
25
- throw new Error(`${e} now requires execute(); legacy workflow is no longer supported.`);
526
+ function _e(n) {
527
+ return s(n, Y, "invalid_runtime_file_upload_response");
528
+ }
529
+ function be(n) {
530
+ return s(n, Z, "invalid_runtime_file_upload_url_response");
531
+ }
532
+ function fe(n) {
533
+ return s(n, ee, "invalid_runtime_file_complete_response");
534
+ }
535
+ function Se(n) {
536
+ return s(n, te, "invalid_runtime_file_access_response");
537
+ }
538
+ function he(n) {
539
+ return s(
540
+ n,
541
+ ne,
542
+ "invalid_runtime_create_session_response"
543
+ );
544
+ }
545
+ function je(n) {
546
+ return s(n, ae, "invalid_runtime_session_view_response");
547
+ }
548
+ function we(n) {
549
+ return s(
550
+ n,
551
+ re,
552
+ "invalid_runtime_list_sessions_response"
553
+ );
554
+ }
555
+ function s(n, t, r) {
556
+ const i = t.safeParse(n);
557
+ if (!i.success)
558
+ throw new Error(r);
559
+ return i.data;
560
+ }
561
+ function j(n) {
562
+ try {
563
+ return n.map((t, r) => de(t, r));
564
+ } catch {
565
+ throw new Error("invalid_runtime_session_item");
566
+ }
567
+ }
568
+ function g(n) {
569
+ return {
570
+ type: n.type,
571
+ id: n.id,
572
+ sessionId: n.sessionId,
573
+ createdAt: n.createdAt,
574
+ ...n.metadata === void 0 ? {} : { metadata: n.metadata }
575
+ };
26
576
  }
27
577
  export {
28
- n as collectPendingToolCallIdsFromAssistantParts,
29
- a as createTool,
30
- s as toDefaultStatusFromAssistantParts
578
+ Ie as parseRuntimeCommandAck,
579
+ de as parseRuntimeContent,
580
+ he as parseRuntimeCreateSessionResult,
581
+ me as parseRuntimeError,
582
+ ce as parseRuntimeEventWire,
583
+ Se as parseRuntimeFileAccessUrlResult,
584
+ fe as parseRuntimeFileCompleteResult,
585
+ _e as parseRuntimeFileUploadResult,
586
+ be as parseRuntimeFileUploadUrlResult,
587
+ ve as parseRuntimeInputCommandAck,
588
+ we as parseRuntimeListSessionsResult,
589
+ pe as parseRuntimeProfile,
590
+ oe as parseRuntimeSession,
591
+ ge as parseRuntimeSessionEventsPage,
592
+ h as parseRuntimeSessionExecution,
593
+ _ as parseRuntimeSessionItem,
594
+ je as parseRuntimeSessionView,
595
+ ye as parseRuntimeStopCommandAck
31
596
  };