@aimount/core 0.1.0 → 0.2.0-beta.0

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"),r=e.z.record(e.z.string(),e.z.unknown()),o=e.z.number().int().nonnegative(),d=e.z.object({code:e.z.string(),message:e.z.string(),details:r.optional()}),R=e.z.object({agentId:e.z.string(),userId:e.z.string()}),x=R.extend({profileId:e.z.string()}),v=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()}),k=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()}),c=e.z.object({roleId:e.z.string(),modelId:e.z.string()}),C=e.z.string().min(1),I=e.z.object({sessionId:e.z.string(),executionToken:e.z.string(),status:C,inputBoundary:e.z.object({lastUserMessageId:e.z.string()}).nullable().optional(),agentMessageId:e.z.string().nullable().optional(),selection:c.optional(),createdAt:e.z.string(),updatedAt:e.z.string()}),h=e.z.object({type:e.z.literal("text"),id:e.z.string(),text:e.z.string()}),P=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:r,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:r,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:r,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:r,cancellation:d})]),T=e.z.object({type:e.z.literal("unknown"),id:e.z.string(),originalType:e.z.string(),payload:e.z.unknown()}),O=e.z.object({type:e.z.string(),id:e.z.string().optional()}).passthrough(),U=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}),b=e.z.object({id:e.z.string(),name:e.z.string()}),M=e.z.object({scope:x,selection:e.z.object({roles:e.z.array(b),models:e.z.array(b),defaults:c.nullable()}),limits:e.z.object({maxInputTextLength:o,maxMessages:o.nullable(),maxTokens:o.nullable(),messagesPerMinute:o.nullable(),messagesPerHour:o.nullable(),messagesPerDay:o.nullable()})}),W=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:r.optional()}),B=e.z.enum(["in_progress","completed","failed","cancelled"]),q=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:c.optional()}),j=e.z.object({id:e.z.string(),commandId:e.z.string(),text:e.z.string(),selection:c,createdAt:e.z.string()}),L=u.extend({type:e.z.literal("agent_message"),status:B,inputBoundary:W.optional(),selection:c.optional(),content:e.z.array(e.z.unknown())}),N=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()}),V=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:r}),D=e.z.object({itemId:e.z.string(),partId:e.z.string(),partType:e.z.literal("text"),delta:e.z.string()}),H=e.z.object({itemId:e.z.string(),part:h.extend({id:e.z.string()})}),$=e.z.object({pendingInput:e.z.object({id:e.z.string(),sessionId:e.z.string(),commandId:e.z.string(),text:e.z.string(),requestedSelection:U.optional(),selection:c.optional(),createdAt:e.z.string()})}),F=e.z.object({pendingInputId:e.z.string(),commandId:e.z.string(),itemId:e.z.string()}),G=e.z.unknown().transform((n,t)=>{try{return A(n)}catch{return t.addIssue({code:"custom",message:"invalid_runtime_event"}),e.z.NEVER}}),J=e.z.object({events:e.z.array(G),nextEventId:e.z.string().nullable()}),y=e.z.object({commandId:e.z.string(),status:e.z.literal("accepted")}),K=y,Q=y,X=e.z.object({session:v,execution:I,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(j)}).optional().default({entries:[]}),ack:e.z.object({sessionId:e.z.string(),commandId:e.z.string(),status:e.z.literal("accepted")})}),Y=e.z.enum(["session_unavailable","maintenance"]),Z=e.z.enum(["execution_not_active","session_unavailable","maintenance"]),S=n=>e.z.discriminatedUnion("available",[e.z.object({available:e.z.literal(!0)}),e.z.object({available:e.z.literal(!1),reason:n})]),ee=e.z.object({session:v,execution:I,lastEventId:e.z.string().nullable(),capabilities:e.z.object({sendText:S(Y),stop:S(Z)}),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(j)}).optional().default({entries:[]})}).transform(n=>({...n,items:{...n.items,entries:n.items.entries.map(m)}})),te=e.z.object({items:e.z.array(k),nextCursor:e.z.string().nullable()});function ne(n){return i(n,d,"invalid_runtime_error")}function se(n){return i(n,M,"invalid_runtime_profile_response")}function w(n){return i(n,v,"invalid_runtime_session")}function g(n){return i(n,I,"invalid_runtime_session_execution")}function E(n,t=0){const a=h.safeParse(n);if(a.success)return a.data;const s=P.safeParse(n);if(s.success&&ie(s.data))return s.data;const _=T.safeParse(n);if(_.success)return _.data;const p=O.safeParse(n);if(p.success)return{type:"unknown",id:p.data.id??`unknown_${t}`,originalType:p.data.type,payload:n};throw new Error("invalid_runtime_content")}function ie(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 a=()=>({...z(t.data),type:"unknown",originalType:t.data.type,payload:n});if(t.data.type==="user_message"){const s=q.safeParse(n);if(!s.success)throw new Error("invalid_runtime_session_item");return{...z(s.data),type:"user_message",...s.data.commandId===void 0?{}:{commandId:s.data.commandId},content:f(s.data.content),..."environment"in s.data?{environment:s.data.environment}:{},...s.data.selection===void 0?{}:{selection:s.data.selection}}}if(t.data.type==="agent_message"){const s=L.safeParse(n);if(!s.success)throw new Error("invalid_runtime_session_item");return{...z(s.data),type:"agent_message",status:s.data.status,inputBoundary:s.data.inputBoundary,...s.data.selection===void 0?{}:{selection:s.data.selection},content:f(s.data.content)}}if(t.data.type==="compaction"){const s=N.safeParse(n);if(!s.success)throw new Error("invalid_runtime_session_item");return s.data}return a()}function A(n){const t=i(n,V,"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:w(l(t.payload,"session")),execution:g(l(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:g(l(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:i(t.payload,$,"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:i(t.payload,F,"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(l(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:i(t.payload,D,"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:i(t.payload,H,"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 ae(n){return i(n,J,"invalid_runtime_session_events_page")}function l(n,t){if(Object.hasOwn(n,t))return n[t];throw new Error("invalid_runtime_event")}function re(n){return i(n,y,"invalid_runtime_command_ack")}function oe(n){return i(n,K,"invalid_runtime_input_ack")}function de(n){return i(n,Q,"invalid_runtime_stop_ack")}function ce(n){return i(n,X,"invalid_runtime_create_session_response")}function le(n){return i(n,ee,"invalid_runtime_session_view_response")}function ue(n){return i(n,te,"invalid_runtime_list_sessions_response")}function i(n,t,a){const s=t.safeParse(n);if(!s.success)throw new Error(a);return s.data}function f(n){try{return n.map((t,a)=>E(t,a))}catch{throw new Error("invalid_runtime_session_item")}}function z(n){return{type:n.type,id:n.id,sessionId:n.sessionId,createdAt:n.createdAt,...n.metadata===void 0?{}:{metadata:n.metadata}}}exports.parseRuntimeCommandAck=re;exports.parseRuntimeContent=E;exports.parseRuntimeCreateSessionResult=ce;exports.parseRuntimeError=ne;exports.parseRuntimeEventWire=A;exports.parseRuntimeInputCommandAck=oe;exports.parseRuntimeListSessionsResult=ue;exports.parseRuntimeProfile=se;exports.parseRuntimeSession=w;exports.parseRuntimeSessionEventsPage=ae;exports.parseRuntimeSessionExecution=g;exports.parseRuntimeSessionItem=m;exports.parseRuntimeSessionView=le;exports.parseRuntimeStopCommandAck=de;
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,527 @@
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 r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(), d = e.object({
3
+ code: e.string(),
4
+ message: e.string(),
5
+ details: r.optional()
6
+ }), E = e.object({
7
+ agentId: e.string(),
8
+ userId: e.string()
9
+ }), A = E.extend({
10
+ profileId: e.string()
11
+ }), g = 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
+ }), x = 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
+ }), c = 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: c.optional(),
36
+ createdAt: e.string(),
37
+ updatedAt: e.string()
38
+ }), j = e.object({
39
+ type: e.literal("text"),
40
+ id: e.string(),
41
+ text: e.string()
42
+ }), C = e.discriminatedUnion(
43
+ "status",
44
+ [
45
+ e.object({
46
+ type: e.literal("tool_call"),
47
+ id: e.string(),
48
+ name: e.string(),
49
+ status: e.literal("succeeded"),
50
+ input: r,
51
+ result: e.unknown()
52
+ }),
53
+ e.object({
54
+ type: e.literal("tool_call"),
55
+ id: e.string(),
56
+ name: e.string(),
57
+ status: e.literal("failed"),
58
+ input: r,
59
+ error: d
60
+ }),
61
+ e.object({
62
+ type: e.literal("tool_call"),
63
+ id: e.string(),
64
+ name: e.string(),
65
+ status: e.literal("denied"),
66
+ input: r,
67
+ denial: d
68
+ }),
69
+ e.object({
70
+ type: e.literal("tool_call"),
71
+ id: e.string(),
72
+ name: e.string(),
73
+ status: e.literal("cancelled"),
74
+ input: r,
75
+ cancellation: d
76
+ })
77
+ ]
78
+ ), P = e.object({
79
+ type: e.literal("unknown"),
80
+ id: e.string(),
81
+ originalType: e.string(),
82
+ payload: e.unknown()
83
+ }), R = e.object({
84
+ type: e.string(),
85
+ id: e.string().optional()
86
+ }).passthrough(), T = e.object({
87
+ roleId: e.string().optional(),
88
+ modelId: e.string().optional()
89
+ }).transform((n) => {
90
+ const t = {};
91
+ return n.roleId !== void 0 && (t.roleId = n.roleId), n.modelId !== void 0 && (t.modelId = n.modelId), t;
92
+ }), b = e.object({
93
+ id: e.string(),
94
+ name: e.string()
95
+ }), O = e.object({
96
+ scope: A,
97
+ selection: e.object({
98
+ roles: e.array(b),
99
+ models: e.array(b),
100
+ defaults: c.nullable()
101
+ }),
102
+ limits: e.object({
103
+ maxInputTextLength: o,
104
+ maxMessages: o.nullable(),
105
+ maxTokens: o.nullable(),
106
+ messagesPerMinute: o.nullable(),
107
+ messagesPerHour: o.nullable(),
108
+ messagesPerDay: o.nullable()
109
+ })
110
+ }), U = e.object({
111
+ lastUserMessageId: e.string()
112
+ }), u = e.object({
113
+ type: e.string(),
114
+ id: e.string(),
115
+ sessionId: e.string(),
116
+ createdAt: e.string(),
117
+ metadata: r.optional()
118
+ }), M = e.enum([
119
+ "in_progress",
120
+ "completed",
121
+ "failed",
122
+ "cancelled"
123
+ ]), B = u.extend({
124
+ type: e.literal("user_message"),
125
+ commandId: e.string().optional(),
126
+ content: e.array(e.unknown()),
127
+ environment: e.unknown().optional(),
128
+ selection: c.optional()
129
+ }), w = e.object({
130
+ id: e.string(),
131
+ commandId: e.string(),
132
+ text: e.string(),
133
+ selection: c,
134
+ createdAt: e.string()
135
+ }), W = u.extend({
136
+ type: e.literal("agent_message"),
137
+ status: M,
138
+ inputBoundary: U.optional(),
139
+ selection: c.optional(),
140
+ content: e.array(e.unknown())
141
+ }), q = u.extend({
142
+ type: e.literal("compaction"),
143
+ status: e.enum(["in_progress", "completed", "failed", "cancelled"]),
144
+ reason: e.string().optional(),
145
+ beforeItemId: e.string().optional(),
146
+ summary: e.string().optional(),
147
+ retainedContext: e.string().optional(),
148
+ error: d.optional(),
149
+ cancellation: d.optional()
150
+ }), L = e.object({
151
+ eventId: e.string(),
152
+ previousEventId: e.string().nullable(),
153
+ sessionId: e.string(),
154
+ commandId: e.string().optional(),
155
+ type: e.string().min(1),
156
+ createdAt: e.string(),
157
+ payload: r
158
+ }), N = e.object({
159
+ itemId: e.string(),
160
+ partId: e.string(),
161
+ partType: e.literal("text"),
162
+ delta: e.string()
163
+ }), V = e.object({
164
+ itemId: e.string(),
165
+ part: j.extend({ id: e.string() })
166
+ }), z = e.object({
167
+ pendingInput: e.object({
168
+ id: e.string(),
169
+ sessionId: e.string(),
170
+ commandId: e.string(),
171
+ text: e.string(),
172
+ requestedSelection: T.optional(),
173
+ selection: c.optional(),
174
+ createdAt: e.string()
175
+ })
176
+ }), D = e.object({
177
+ pendingInputId: e.string(),
178
+ commandId: e.string(),
179
+ itemId: e.string()
180
+ }), H = e.unknown().transform((n, t) => {
181
+ try {
182
+ return ne(n);
183
+ } catch {
184
+ return t.addIssue({ code: "custom", message: "invalid_runtime_event" }), e.NEVER;
185
+ }
186
+ }), $ = e.object({
187
+ events: e.array(H),
188
+ nextEventId: e.string().nullable()
189
+ }), I = e.object({
190
+ commandId: e.string(),
191
+ status: e.literal("accepted")
192
+ }), F = I, G = I, J = e.object({
193
+ session: g,
194
+ execution: v,
195
+ lastEventId: e.string(),
196
+ capabilities: e.object({
197
+ sendText: e.discriminatedUnion("available", [
198
+ e.object({ available: e.literal(!0) }),
199
+ e.object({
200
+ available: e.literal(!1),
201
+ reason: e.enum(["session_unavailable", "maintenance"])
202
+ })
203
+ ]),
204
+ stop: e.discriminatedUnion("available", [
205
+ e.object({ available: e.literal(!0) }),
206
+ e.object({
207
+ available: e.literal(!1),
208
+ reason: e.enum(["execution_not_active", "session_unavailable", "maintenance"])
209
+ })
210
+ ])
211
+ }),
212
+ items: e.object({
213
+ entries: e.array(e.unknown()),
214
+ continuityToken: e.string(),
215
+ olderCursor: e.string().nullable(),
216
+ newerCursor: e.string().nullable(),
217
+ hasOlder: e.boolean(),
218
+ hasNewer: e.boolean()
219
+ }).transform((n) => ({
220
+ ...n,
221
+ entries: n.entries.map(y)
222
+ })),
223
+ pendingInput: e.object({ entries: e.array(w) }).optional().default({ entries: [] }),
224
+ ack: e.object({
225
+ sessionId: e.string(),
226
+ commandId: e.string(),
227
+ status: e.literal("accepted")
228
+ })
229
+ }), K = e.enum(["session_unavailable", "maintenance"]), Q = e.enum([
230
+ "execution_not_active",
231
+ "session_unavailable",
232
+ "maintenance"
233
+ ]), S = (n) => e.discriminatedUnion("available", [
234
+ e.object({ available: e.literal(!0) }),
235
+ e.object({ available: e.literal(!1), reason: n })
236
+ ]), X = e.object({
237
+ session: g,
238
+ execution: v,
239
+ lastEventId: e.string().nullable(),
240
+ capabilities: e.object({
241
+ sendText: S(K),
242
+ stop: S(Q)
243
+ }),
244
+ items: e.object({
245
+ entries: e.array(e.unknown()),
246
+ continuityToken: e.string(),
247
+ olderCursor: e.string().nullable(),
248
+ newerCursor: e.string().nullable(),
249
+ hasOlder: e.boolean(),
250
+ hasNewer: e.boolean()
251
+ }),
252
+ pendingInput: e.object({ entries: e.array(w) }).optional().default({ entries: [] })
253
+ }).transform((n) => ({
254
+ ...n,
255
+ items: {
256
+ ...n.items,
257
+ entries: n.items.entries.map(y)
258
+ }
259
+ })), Y = e.object({
260
+ items: e.array(x),
261
+ nextCursor: e.string().nullable()
262
+ });
263
+ function ie(n) {
264
+ return i(n, d, "invalid_runtime_error");
265
+ }
266
+ function ae(n) {
267
+ return i(n, O, "invalid_runtime_profile_response");
268
+ }
269
+ function Z(n) {
270
+ return i(n, g, "invalid_runtime_session");
271
+ }
272
+ function f(n) {
273
+ return i(n, v, "invalid_runtime_session_execution");
274
+ }
275
+ function ee(n, t = 0) {
276
+ const a = j.safeParse(n);
277
+ if (a.success)
278
+ return a.data;
279
+ const s = C.safeParse(n);
280
+ if (s.success && te(s.data))
281
+ return s.data;
282
+ const _ = P.safeParse(n);
283
+ if (_.success)
284
+ return _.data;
285
+ const m = R.safeParse(n);
286
+ if (m.success)
287
+ return {
288
+ type: "unknown",
289
+ id: m.data.id ?? `unknown_${t}`,
290
+ originalType: m.data.type,
291
+ payload: n
292
+ };
293
+ throw new Error("invalid_runtime_content");
294
+ }
295
+ function te(n) {
296
+ switch (n.status) {
297
+ case "succeeded":
298
+ return Object.hasOwn(n, "result");
299
+ case "failed":
300
+ return Object.hasOwn(n, "error");
301
+ case "denied":
302
+ return Object.hasOwn(n, "denial");
303
+ case "cancelled":
304
+ return Object.hasOwn(n, "cancellation");
305
+ }
306
+ }
307
+ function y(n) {
308
+ const t = u.safeParse(n);
309
+ if (!t.success)
310
+ throw new Error("invalid_runtime_session_item");
311
+ const a = () => ({
312
+ ...p(t.data),
313
+ type: "unknown",
314
+ originalType: t.data.type,
315
+ payload: n
316
+ });
317
+ if (t.data.type === "user_message") {
318
+ const s = B.safeParse(n);
319
+ if (!s.success)
320
+ throw new Error("invalid_runtime_session_item");
321
+ return {
322
+ ...p(s.data),
323
+ type: "user_message",
324
+ ...s.data.commandId === void 0 ? {} : { commandId: s.data.commandId },
325
+ content: h(s.data.content),
326
+ ..."environment" in s.data ? { environment: s.data.environment } : {},
327
+ ...s.data.selection === void 0 ? {} : { selection: s.data.selection }
328
+ };
329
+ }
330
+ if (t.data.type === "agent_message") {
331
+ const s = W.safeParse(n);
332
+ if (!s.success)
333
+ throw new Error("invalid_runtime_session_item");
334
+ return {
335
+ ...p(s.data),
336
+ type: "agent_message",
337
+ status: s.data.status,
338
+ inputBoundary: s.data.inputBoundary,
339
+ ...s.data.selection === void 0 ? {} : { selection: s.data.selection },
340
+ content: h(s.data.content)
341
+ };
342
+ }
343
+ if (t.data.type === "compaction") {
344
+ const s = q.safeParse(n);
345
+ if (!s.success)
346
+ throw new Error("invalid_runtime_session_item");
347
+ return s.data;
348
+ }
349
+ return a();
350
+ }
351
+ function ne(n) {
352
+ const t = i(
353
+ n,
354
+ L,
355
+ "invalid_runtime_event"
356
+ );
357
+ try {
358
+ if (t.type === "session.created")
359
+ return {
360
+ eventId: t.eventId,
361
+ previousEventId: null,
362
+ sessionId: t.sessionId,
363
+ type: t.type,
364
+ createdAt: t.createdAt,
365
+ payload: {
366
+ session: Z(l(t.payload, "session")),
367
+ execution: f(l(t.payload, "execution"))
368
+ }
369
+ };
370
+ if (t.type === "session_execution.updated")
371
+ return {
372
+ eventId: t.eventId,
373
+ previousEventId: t.previousEventId,
374
+ sessionId: t.sessionId,
375
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
376
+ type: t.type,
377
+ createdAt: t.createdAt,
378
+ payload: { execution: f(l(t.payload, "execution")) }
379
+ };
380
+ if (t.type === "pending_input.created")
381
+ return {
382
+ eventId: t.eventId,
383
+ previousEventId: t.previousEventId,
384
+ sessionId: t.sessionId,
385
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
386
+ type: t.type,
387
+ createdAt: t.createdAt,
388
+ payload: i(
389
+ t.payload,
390
+ z,
391
+ "invalid_runtime_event"
392
+ )
393
+ };
394
+ if (t.type === "pending_input.committed")
395
+ return {
396
+ eventId: t.eventId,
397
+ previousEventId: t.previousEventId,
398
+ sessionId: t.sessionId,
399
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
400
+ type: t.type,
401
+ createdAt: t.createdAt,
402
+ payload: i(
403
+ t.payload,
404
+ D,
405
+ "invalid_runtime_event"
406
+ )
407
+ };
408
+ if (t.type === "session_item.created" || t.type === "session_item.updated")
409
+ return {
410
+ eventId: t.eventId,
411
+ previousEventId: t.previousEventId,
412
+ sessionId: t.sessionId,
413
+ ...t.commandId === void 0 ? {} : { commandId: t.commandId },
414
+ type: t.type,
415
+ createdAt: t.createdAt,
416
+ payload: { item: y(l(t.payload, "item")) }
417
+ };
418
+ if (t.type === "session_item.content_delta")
419
+ return {
420
+ eventId: t.eventId,
421
+ previousEventId: t.previousEventId,
422
+ sessionId: t.sessionId,
423
+ type: t.type,
424
+ createdAt: t.createdAt,
425
+ payload: i(
426
+ t.payload,
427
+ N,
428
+ "invalid_runtime_event"
429
+ )
430
+ };
431
+ if (t.type === "session_item.part.created")
432
+ return {
433
+ eventId: t.eventId,
434
+ previousEventId: t.previousEventId,
435
+ sessionId: t.sessionId,
436
+ type: t.type,
437
+ createdAt: t.createdAt,
438
+ payload: i(
439
+ t.payload,
440
+ V,
441
+ "invalid_runtime_event"
442
+ )
443
+ };
444
+ } catch {
445
+ throw new Error("invalid_runtime_event");
446
+ }
447
+ return {
448
+ eventId: t.eventId,
449
+ previousEventId: t.previousEventId,
450
+ sessionId: t.sessionId,
451
+ type: "unknown",
452
+ originalType: t.type,
453
+ createdAt: t.createdAt,
454
+ payload: t.payload
16
455
  };
17
456
  }
18
- function a(t) {
19
- return r(t), t;
457
+ function re(n) {
458
+ return i(n, $, "invalid_runtime_session_events_page");
459
+ }
460
+ function l(n, t) {
461
+ if (Object.hasOwn(n, t)) return n[t];
462
+ throw new Error("invalid_runtime_event");
463
+ }
464
+ function oe(n) {
465
+ return i(n, I, "invalid_runtime_command_ack");
20
466
  }
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.`);
467
+ function de(n) {
468
+ return i(n, F, "invalid_runtime_input_ack");
469
+ }
470
+ function ce(n) {
471
+ return i(n, G, "invalid_runtime_stop_ack");
472
+ }
473
+ function le(n) {
474
+ return i(
475
+ n,
476
+ J,
477
+ "invalid_runtime_create_session_response"
478
+ );
479
+ }
480
+ function ue(n) {
481
+ return i(n, X, "invalid_runtime_session_view_response");
482
+ }
483
+ function me(n) {
484
+ return i(
485
+ n,
486
+ Y,
487
+ "invalid_runtime_list_sessions_response"
488
+ );
489
+ }
490
+ function i(n, t, a) {
491
+ const s = t.safeParse(n);
492
+ if (!s.success)
493
+ throw new Error(a);
494
+ return s.data;
495
+ }
496
+ function h(n) {
497
+ try {
498
+ return n.map((t, a) => ee(t, a));
499
+ } catch {
500
+ throw new Error("invalid_runtime_session_item");
501
+ }
502
+ }
503
+ function p(n) {
504
+ return {
505
+ type: n.type,
506
+ id: n.id,
507
+ sessionId: n.sessionId,
508
+ createdAt: n.createdAt,
509
+ ...n.metadata === void 0 ? {} : { metadata: n.metadata }
510
+ };
26
511
  }
27
512
  export {
28
- n as collectPendingToolCallIdsFromAssistantParts,
29
- a as createTool,
30
- s as toDefaultStatusFromAssistantParts
513
+ oe as parseRuntimeCommandAck,
514
+ ee as parseRuntimeContent,
515
+ le as parseRuntimeCreateSessionResult,
516
+ ie as parseRuntimeError,
517
+ ne as parseRuntimeEventWire,
518
+ de as parseRuntimeInputCommandAck,
519
+ me as parseRuntimeListSessionsResult,
520
+ ae as parseRuntimeProfile,
521
+ Z as parseRuntimeSession,
522
+ re as parseRuntimeSessionEventsPage,
523
+ f as parseRuntimeSessionExecution,
524
+ y as parseRuntimeSessionItem,
525
+ ue as parseRuntimeSessionView,
526
+ ce as parseRuntimeStopCommandAck
31
527
  };