@aimount/core 0.2.0-beta.1 → 0.2.0-beta.3

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
@@ -30,6 +30,18 @@ stays free of transport, UI, and orchestration concerns.
30
30
  `@aimount/core` owns the current Runtime API SDK contract, including public types,
31
31
  schemas, and parsers used by transport packages.
32
32
 
33
+ Create-session callers can opt into automatic title replacement while supplying an immediate fallback:
34
+
35
+ ```ts
36
+ await runtimeApi.createSession({
37
+ idempotencyKey: crypto.randomUUID(),
38
+ title: 'Explain invoice.pdf',
39
+ generateTitle: true,
40
+ });
41
+ ```
42
+
43
+ The event parser exposes `session.updated` as a typed replacement snapshot. Runtime profile parsing also exposes current server tool entries. Response parsers remain tolerant of unknown future fields and event types.
44
+
33
45
  ## Tool execution relation
34
46
 
35
47
  `@assistant-wi/interaction` can keep normalization and parser behavior while reusing
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
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()}),y=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),_=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()}),w=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()}),tools:e.z.array(e.z.object({namespace:e.z.string(),name:e.z.string(),version:e.z.string(),description:e.z.string()})).optional()}),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()}),A=e.z.object({id:e.z.string(),commandId:e.z.string(),content:e.z.array(w),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(w),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()}),b=e.z.object({commandId:e.z.string(),status:e.z.literal("accepted")}),Z=b,ee=b,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:y,execution:_,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(A)}).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"]),h=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:y,execution:_,lastEventId:e.z.string().nullable(),capabilities:e.z.object({sendText:h(re),stop:h(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(A)}).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 v(n){return s(n,y,"invalid_runtime_session")}function I(n){return s(n,_,"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 f=F.safeParse(n);if(f.success)return f.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:j(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:j(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:v(c(t.payload,"session")),execution:I(c(t.payload,"execution"))}};if(t.type==="session.updated")return{eventId:t.eventId,previousEventId:t.previousEventId,sessionId:t.sessionId,type:t.type,createdAt:t.createdAt,payload:{session:v(c(t.payload,"session"))}};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:I(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,b,"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 fe(n){return s(n,ae,"invalid_runtime_create_session_response")}function Se(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 j(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=fe;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=v;exports.parseRuntimeSessionEventsPage=pe;exports.parseRuntimeSessionExecution=I;exports.parseRuntimeSessionItem=m;exports.parseRuntimeSessionView=Se;exports.parseRuntimeStopCommandAck=ve;
package/dist/index.es.js CHANGED
@@ -3,19 +3,19 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
3
3
  code: e.string(),
4
4
  message: e.string(),
5
5
  details: o.optional()
6
- }), x = e.object({
6
+ }), R = e.object({
7
7
  agentId: e.string(),
8
8
  userId: e.string()
9
- }), R = x.extend({
9
+ }), C = R.extend({
10
10
  profileId: e.string()
11
- }), I = e.object({
11
+ }), v = e.object({
12
12
  id: e.string(),
13
13
  agentId: e.string(),
14
14
  userId: e.string(),
15
15
  title: e.string().nullable(),
16
16
  createdAt: e.string(),
17
17
  updatedAt: e.string()
18
- }), C = e.object({
18
+ }), k = e.object({
19
19
  id: e.string(),
20
20
  agentId: e.string(),
21
21
  userId: e.string(),
@@ -26,33 +26,33 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
26
26
  }), l = e.object({
27
27
  roleId: e.string(),
28
28
  modelId: e.string()
29
- }), k = e.string().min(1), v = e.object({
29
+ }), P = e.string().min(1), I = e.object({
30
30
  sessionId: e.string(),
31
31
  executionToken: e.string(),
32
- status: k,
32
+ status: P,
33
33
  inputBoundary: e.object({ lastUserMessageId: e.string() }).nullable().optional(),
34
34
  agentMessageId: e.string().nullable().optional(),
35
35
  selection: l.optional(),
36
36
  createdAt: e.string(),
37
37
  updatedAt: e.string()
38
- }), w = e.object({
38
+ }), A = e.object({
39
39
  type: e.literal("text"),
40
40
  id: e.string(),
41
41
  text: e.string()
42
- }), P = e.object({
42
+ }), U = e.object({
43
43
  type: e.literal("file"),
44
44
  id: e.string(),
45
45
  fileId: e.string(),
46
46
  name: e.string().optional(),
47
47
  mediaType: e.string().optional(),
48
48
  sizeBytes: a.optional()
49
- }), A = e.discriminatedUnion(
49
+ }), E = e.discriminatedUnion(
50
50
  "type",
51
51
  [
52
52
  e.object({ type: e.literal("text"), text: e.string() }),
53
53
  e.object({ type: e.literal("file"), fileId: e.string() })
54
54
  ]
55
- ), U = e.discriminatedUnion(
55
+ ), T = e.discriminatedUnion(
56
56
  "status",
57
57
  [
58
58
  e.object({
@@ -88,29 +88,29 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
88
88
  cancellation: d
89
89
  })
90
90
  ]
91
- ), T = e.object({
91
+ ), O = e.object({
92
92
  type: e.literal("unknown"),
93
93
  id: e.string(),
94
94
  originalType: e.string(),
95
95
  payload: e.unknown()
96
- }), O = e.object({
96
+ }), B = e.object({
97
97
  type: e.string(),
98
98
  id: e.string().optional()
99
- }).passthrough(), B = e.object({
99
+ }).passthrough(), M = e.object({
100
100
  roleId: e.string().optional(),
101
101
  modelId: e.string().optional()
102
102
  }).transform((n) => {
103
103
  const t = {};
104
104
  return n.roleId !== void 0 && (t.roleId = n.roleId), n.modelId !== void 0 && (t.modelId = n.modelId), t;
105
- }), M = e.object({
105
+ }), F = e.object({
106
106
  input: e.array(e.string().min(1)),
107
107
  output: e.array(e.string().min(1))
108
108
  }), f = e.object({
109
109
  id: e.string(),
110
110
  name: e.string(),
111
- modalities: M.optional()
112
- }), F = e.object({
113
- scope: R,
111
+ modalities: F.optional()
112
+ }), W = e.object({
113
+ scope: C,
114
114
  selection: e.object({
115
115
  roles: e.array(f),
116
116
  models: e.array(f),
@@ -123,8 +123,16 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
123
123
  messagesPerMinute: a.nullable(),
124
124
  messagesPerHour: a.nullable(),
125
125
  messagesPerDay: a.nullable()
126
- })
127
- }), W = e.object({
126
+ }),
127
+ tools: e.array(
128
+ e.object({
129
+ namespace: e.string(),
130
+ name: e.string(),
131
+ version: e.string(),
132
+ description: e.string()
133
+ })
134
+ ).optional()
135
+ }), q = e.object({
128
136
  lastUserMessageId: e.string()
129
137
  }), u = e.object({
130
138
  type: e.string(),
@@ -132,30 +140,30 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
132
140
  sessionId: e.string(),
133
141
  createdAt: e.string(),
134
142
  metadata: o.optional()
135
- }), q = e.enum([
143
+ }), z = e.enum([
136
144
  "in_progress",
137
145
  "completed",
138
146
  "failed",
139
147
  "cancelled"
140
- ]), z = u.extend({
148
+ ]), L = u.extend({
141
149
  type: e.literal("user_message"),
142
150
  commandId: e.string().optional(),
143
151
  content: e.array(e.unknown()),
144
152
  environment: e.unknown().optional(),
145
153
  selection: l.optional()
146
- }), E = e.object({
154
+ }), x = e.object({
147
155
  id: e.string(),
148
156
  commandId: e.string(),
149
- content: e.array(A),
157
+ content: e.array(E),
150
158
  selection: l.optional(),
151
159
  createdAt: e.string()
152
- }), L = u.extend({
160
+ }), N = u.extend({
153
161
  type: e.literal("agent_message"),
154
- status: q,
155
- inputBoundary: W.optional(),
162
+ status: z,
163
+ inputBoundary: q.optional(),
156
164
  selection: l.optional(),
157
165
  content: e.array(e.unknown())
158
- }), N = u.extend({
166
+ }), V = u.extend({
159
167
  type: e.literal("compaction"),
160
168
  status: e.enum(["in_progress", "completed", "failed", "cancelled"]),
161
169
  reason: e.string().optional(),
@@ -164,7 +172,7 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
164
172
  retainedContext: e.string().optional(),
165
173
  error: d.optional(),
166
174
  cancellation: d.optional()
167
- }), V = e.object({
175
+ }), D = e.object({
168
176
  eventId: e.string(),
169
177
  previousEventId: e.string().nullable(),
170
178
  sessionId: e.string(),
@@ -172,41 +180,41 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
172
180
  type: e.string().min(1),
173
181
  createdAt: e.string(),
174
182
  payload: o
175
- }), D = e.object({
183
+ }), H = e.object({
176
184
  itemId: e.string(),
177
185
  partId: e.string(),
178
186
  partType: e.literal("text"),
179
187
  delta: e.string()
180
- }), H = e.object({
181
- itemId: e.string(),
182
- part: w.extend({ id: e.string() })
183
188
  }), $ = e.object({
189
+ itemId: e.string(),
190
+ part: A.extend({ id: e.string() })
191
+ }), G = e.object({
184
192
  pendingInput: e.object({
185
193
  id: e.string(),
186
194
  sessionId: e.string(),
187
195
  commandId: e.string(),
188
- content: e.array(A),
189
- requestedSelection: B.optional(),
196
+ content: e.array(E),
197
+ requestedSelection: M.optional(),
190
198
  selection: l.optional(),
191
199
  createdAt: e.string()
192
200
  })
193
- }), G = e.object({
201
+ }), J = e.object({
194
202
  pendingInputId: e.string(),
195
203
  commandId: e.string(),
196
204
  itemId: e.string()
197
- }), J = e.unknown().transform((n, t) => {
205
+ }), K = e.unknown().transform((n, t) => {
198
206
  try {
199
207
  return ce(n);
200
208
  } catch {
201
209
  return t.addIssue({ code: "custom", message: "invalid_runtime_event" }), e.NEVER;
202
210
  }
203
- }), K = e.object({
204
- events: e.array(J),
211
+ }), Q = e.object({
212
+ events: e.array(K),
205
213
  nextEventId: e.string().nullable()
206
214
  }), y = e.object({
207
215
  commandId: e.string(),
208
216
  status: e.literal("accepted")
209
- }), Q = y, X = y, Y = e.object({
217
+ }), X = y, Y = y, Z = e.object({
210
218
  fileId: e.string(),
211
219
  status: e.literal("draft"),
212
220
  uploadUrl: e.string(),
@@ -214,22 +222,22 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
214
222
  name: e.string(),
215
223
  mediaType: e.string(),
216
224
  sizeBytes: a
217
- }), Z = e.object({
225
+ }), ee = e.object({
218
226
  fileId: e.string(),
219
227
  uploadUrl: e.string(),
220
228
  uploadUrlExpiresAt: e.string()
221
- }), ee = e.object({
229
+ }), te = e.object({
222
230
  fileId: e.string(),
223
231
  status: e.literal("ready"),
224
232
  name: e.string(),
225
233
  mediaType: e.string(),
226
234
  sizeBytes: a
227
- }), te = e.object({
235
+ }), ne = e.object({
228
236
  url: e.string(),
229
237
  expiresAt: e.string()
230
- }), ne = e.object({
231
- session: I,
232
- execution: v,
238
+ }), ie = e.object({
239
+ session: v,
240
+ execution: I,
233
241
  lastEventId: e.string(),
234
242
  capabilities: e.object({
235
243
  sendText: e.discriminatedUnion("available", [
@@ -258,26 +266,26 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
258
266
  ...n,
259
267
  entries: n.entries.map(_)
260
268
  })),
261
- pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] }),
269
+ pendingInput: e.object({ entries: e.array(x) }).optional().default({ entries: [] }),
262
270
  ack: e.object({
263
271
  sessionId: e.string(),
264
272
  commandId: e.string(),
265
273
  status: e.literal("accepted")
266
274
  })
267
- }), ie = e.enum(["session_unavailable", "maintenance"]), se = e.enum([
275
+ }), se = e.enum(["session_unavailable", "maintenance"]), ae = e.enum([
268
276
  "execution_not_active",
269
277
  "session_unavailable",
270
278
  "maintenance"
271
279
  ]), S = (n) => e.discriminatedUnion("available", [
272
280
  e.object({ available: e.literal(!0) }),
273
281
  e.object({ available: e.literal(!1), reason: n })
274
- ]), ae = e.object({
275
- session: I,
276
- execution: v,
282
+ ]), re = e.object({
283
+ session: v,
284
+ execution: I,
277
285
  lastEventId: e.string().nullable(),
278
286
  capabilities: e.object({
279
- sendText: S(ie),
280
- stop: S(se)
287
+ sendText: S(se),
288
+ stop: S(ae)
281
289
  }),
282
290
  items: e.object({
283
291
  entries: e.array(e.unknown()),
@@ -287,43 +295,43 @@ const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(),
287
295
  hasOlder: e.boolean(),
288
296
  hasNewer: e.boolean()
289
297
  }),
290
- pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] })
298
+ pendingInput: e.object({ entries: e.array(x) }).optional().default({ entries: [] })
291
299
  }).transform((n) => ({
292
300
  ...n,
293
301
  items: {
294
302
  ...n.items,
295
303
  entries: n.items.entries.map(_)
296
304
  }
297
- })), re = e.object({
298
- items: e.array(C),
305
+ })), oe = e.object({
306
+ items: e.array(k),
299
307
  nextCursor: e.string().nullable()
300
308
  });
301
309
  function me(n) {
302
310
  return s(n, d, "invalid_runtime_error");
303
311
  }
304
312
  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");
313
+ return s(n, W, "invalid_runtime_profile_response");
309
314
  }
310
315
  function h(n) {
311
- return s(n, v, "invalid_runtime_session_execution");
316
+ return s(n, v, "invalid_runtime_session");
317
+ }
318
+ function j(n) {
319
+ return s(n, I, "invalid_runtime_session_execution");
312
320
  }
313
321
  function de(n, t = 0) {
314
- const r = w.safeParse(n);
322
+ const r = A.safeParse(n);
315
323
  if (r.success)
316
324
  return r.data;
317
- const i = P.safeParse(n);
325
+ const i = U.safeParse(n);
318
326
  if (i.success)
319
327
  return i.data;
320
- const m = U.safeParse(n);
328
+ const m = T.safeParse(n);
321
329
  if (m.success && le(m.data))
322
330
  return m.data;
323
- const b = T.safeParse(n);
331
+ const b = O.safeParse(n);
324
332
  if (b.success)
325
333
  return b.data;
326
- const p = O.safeParse(n);
334
+ const p = B.safeParse(n);
327
335
  if (p.success)
328
336
  return {
329
337
  type: "unknown",
@@ -356,20 +364,20 @@ function _(n) {
356
364
  payload: n
357
365
  });
358
366
  if (t.data.type === "user_message") {
359
- const i = z.safeParse(n);
367
+ const i = L.safeParse(n);
360
368
  if (!i.success)
361
369
  throw new Error("invalid_runtime_session_item");
362
370
  return {
363
371
  ...g(i.data),
364
372
  type: "user_message",
365
373
  ...i.data.commandId === void 0 ? {} : { commandId: i.data.commandId },
366
- content: j(i.data.content),
374
+ content: w(i.data.content),
367
375
  ..."environment" in i.data ? { environment: i.data.environment } : {},
368
376
  ...i.data.selection === void 0 ? {} : { selection: i.data.selection }
369
377
  };
370
378
  }
371
379
  if (t.data.type === "agent_message") {
372
- const i = L.safeParse(n);
380
+ const i = N.safeParse(n);
373
381
  if (!i.success)
374
382
  throw new Error("invalid_runtime_session_item");
375
383
  return {
@@ -378,11 +386,11 @@ function _(n) {
378
386
  status: i.data.status,
379
387
  inputBoundary: i.data.inputBoundary,
380
388
  ...i.data.selection === void 0 ? {} : { selection: i.data.selection },
381
- content: j(i.data.content)
389
+ content: w(i.data.content)
382
390
  };
383
391
  }
384
392
  if (t.data.type === "compaction") {
385
- const i = N.safeParse(n);
393
+ const i = V.safeParse(n);
386
394
  if (!i.success)
387
395
  throw new Error("invalid_runtime_session_item");
388
396
  return i.data;
@@ -392,7 +400,7 @@ function _(n) {
392
400
  function ce(n) {
393
401
  const t = s(
394
402
  n,
395
- V,
403
+ D,
396
404
  "invalid_runtime_event"
397
405
  );
398
406
  try {
@@ -404,12 +412,23 @@ function ce(n) {
404
412
  type: t.type,
405
413
  createdAt: t.createdAt,
406
414
  payload: {
407
- session: oe(c(t.payload, "session")),
408
- execution: h(
415
+ session: h(c(t.payload, "session")),
416
+ execution: j(
409
417
  c(t.payload, "execution")
410
418
  )
411
419
  }
412
420
  };
421
+ if (t.type === "session.updated")
422
+ return {
423
+ eventId: t.eventId,
424
+ previousEventId: t.previousEventId,
425
+ sessionId: t.sessionId,
426
+ type: t.type,
427
+ createdAt: t.createdAt,
428
+ payload: {
429
+ session: h(c(t.payload, "session"))
430
+ }
431
+ };
413
432
  if (t.type === "session_execution.updated")
414
433
  return {
415
434
  eventId: t.eventId,
@@ -419,7 +438,7 @@ function ce(n) {
419
438
  type: t.type,
420
439
  createdAt: t.createdAt,
421
440
  payload: {
422
- execution: h(
441
+ execution: j(
423
442
  c(t.payload, "execution")
424
443
  )
425
444
  }
@@ -434,7 +453,7 @@ function ce(n) {
434
453
  createdAt: t.createdAt,
435
454
  payload: s(
436
455
  t.payload,
437
- $,
456
+ G,
438
457
  "invalid_runtime_event"
439
458
  )
440
459
  };
@@ -448,7 +467,7 @@ function ce(n) {
448
467
  createdAt: t.createdAt,
449
468
  payload: s(
450
469
  t.payload,
451
- G,
470
+ J,
452
471
  "invalid_runtime_event"
453
472
  )
454
473
  };
@@ -473,7 +492,7 @@ function ce(n) {
473
492
  createdAt: t.createdAt,
474
493
  payload: s(
475
494
  t.payload,
476
- D,
495
+ H,
477
496
  "invalid_runtime_event"
478
497
  )
479
498
  };
@@ -486,7 +505,7 @@ function ce(n) {
486
505
  createdAt: t.createdAt,
487
506
  payload: s(
488
507
  t.payload,
489
- H,
508
+ $,
490
509
  "invalid_runtime_event"
491
510
  )
492
511
  };
@@ -506,7 +525,7 @@ function ce(n) {
506
525
  function ge(n) {
507
526
  return s(
508
527
  n,
509
- K,
528
+ Q,
510
529
  "invalid_runtime_session_events_page"
511
530
  );
512
531
  }
@@ -514,41 +533,41 @@ function c(n, t) {
514
533
  if (Object.hasOwn(n, t)) return n[t];
515
534
  throw new Error("invalid_runtime_event");
516
535
  }
517
- function Ie(n) {
536
+ function ve(n) {
518
537
  return s(n, y, "invalid_runtime_command_ack");
519
538
  }
520
- function ve(n) {
521
- return s(n, Q, "invalid_runtime_input_ack");
539
+ function Ie(n) {
540
+ return s(n, X, "invalid_runtime_input_ack");
522
541
  }
523
542
  function ye(n) {
524
- return s(n, X, "invalid_runtime_stop_ack");
543
+ return s(n, Y, "invalid_runtime_stop_ack");
525
544
  }
526
545
  function _e(n) {
527
- return s(n, Y, "invalid_runtime_file_upload_response");
546
+ return s(n, Z, "invalid_runtime_file_upload_response");
528
547
  }
529
548
  function be(n) {
530
- return s(n, Z, "invalid_runtime_file_upload_url_response");
549
+ return s(n, ee, "invalid_runtime_file_upload_url_response");
531
550
  }
532
551
  function fe(n) {
533
- return s(n, ee, "invalid_runtime_file_complete_response");
552
+ return s(n, te, "invalid_runtime_file_complete_response");
534
553
  }
535
554
  function Se(n) {
536
- return s(n, te, "invalid_runtime_file_access_response");
555
+ return s(n, ne, "invalid_runtime_file_access_response");
537
556
  }
538
557
  function he(n) {
539
558
  return s(
540
559
  n,
541
- ne,
560
+ ie,
542
561
  "invalid_runtime_create_session_response"
543
562
  );
544
563
  }
545
564
  function je(n) {
546
- return s(n, ae, "invalid_runtime_session_view_response");
565
+ return s(n, re, "invalid_runtime_session_view_response");
547
566
  }
548
567
  function we(n) {
549
568
  return s(
550
569
  n,
551
- re,
570
+ oe,
552
571
  "invalid_runtime_list_sessions_response"
553
572
  );
554
573
  }
@@ -558,7 +577,7 @@ function s(n, t, r) {
558
577
  throw new Error(r);
559
578
  return i.data;
560
579
  }
561
- function j(n) {
580
+ function w(n) {
562
581
  try {
563
582
  return n.map((t, r) => de(t, r));
564
583
  } catch {
@@ -575,7 +594,7 @@ function g(n) {
575
594
  };
576
595
  }
577
596
  export {
578
- Ie as parseRuntimeCommandAck,
597
+ ve as parseRuntimeCommandAck,
579
598
  de as parseRuntimeContent,
580
599
  he as parseRuntimeCreateSessionResult,
581
600
  me as parseRuntimeError,
@@ -584,12 +603,12 @@ export {
584
603
  fe as parseRuntimeFileCompleteResult,
585
604
  _e as parseRuntimeFileUploadResult,
586
605
  be as parseRuntimeFileUploadUrlResult,
587
- ve as parseRuntimeInputCommandAck,
606
+ Ie as parseRuntimeInputCommandAck,
588
607
  we as parseRuntimeListSessionsResult,
589
608
  pe as parseRuntimeProfile,
590
- oe as parseRuntimeSession,
609
+ h as parseRuntimeSession,
591
610
  ge as parseRuntimeSessionEventsPage,
592
- h as parseRuntimeSessionExecution,
611
+ j as parseRuntimeSessionExecution,
593
612
  _ as parseRuntimeSessionItem,
594
613
  je as parseRuntimeSessionView,
595
614
  ye as parseRuntimeStopCommandAck
@@ -31,6 +31,13 @@ export type RuntimeProfile = {
31
31
  defaults: RuntimeSelection | null;
32
32
  };
33
33
  limits: RuntimeLimits;
34
+ tools?: RuntimeProfileTool[] | undefined;
35
+ };
36
+ export type RuntimeProfileTool = {
37
+ namespace: string;
38
+ name: string;
39
+ version: string;
40
+ description: string;
34
41
  };
35
42
  type RuntimeSessionOwnership = {
36
43
  agentId: string;
@@ -174,7 +181,7 @@ export type RuntimeUnknownSessionItem = RuntimeSessionItemBase<'unknown'> & {
174
181
  payload: unknown;
175
182
  };
176
183
  export type RuntimeSessionItem = RuntimeUserMessage | RuntimeAgentMessage | RuntimeCompaction | RuntimeUnknownSessionItem;
177
- export type RuntimeEventType = 'session.created' | 'pending_input.created' | 'pending_input.committed' | 'session_item.created' | 'session_item.part.created' | 'session_item.content_delta' | 'session_item.updated' | 'session_execution.updated';
184
+ export type RuntimeEventType = 'session.created' | 'session.updated' | 'pending_input.created' | 'pending_input.committed' | 'session_item.created' | 'session_item.part.created' | 'session_item.content_delta' | 'session_item.updated' | 'session_execution.updated';
178
185
  export type RuntimeSessionItemEventWire = {
179
186
  eventId: string;
180
187
  previousEventId: string | null;
@@ -265,6 +272,16 @@ export type RuntimeSessionCreatedEventWire = {
265
272
  execution: RuntimeSessionExecution;
266
273
  };
267
274
  };
275
+ export type RuntimeSessionUpdatedEventWire = {
276
+ eventId: string;
277
+ previousEventId: string | null;
278
+ sessionId: string;
279
+ type: 'session.updated';
280
+ createdAt: string;
281
+ payload: {
282
+ session: RuntimeSession;
283
+ };
284
+ };
268
285
  export type RuntimeUnknownEventWire = {
269
286
  eventId: string;
270
287
  previousEventId: string | null;
@@ -274,7 +291,7 @@ export type RuntimeUnknownEventWire = {
274
291
  createdAt: string;
275
292
  payload: Record<string, unknown>;
276
293
  };
277
- export type RuntimeEventWire = RuntimeSessionCreatedEventWire | RuntimePendingInputCreatedEventWire | RuntimePendingInputCommittedEventWire | RuntimeSessionItemEventWire | RuntimeSessionItemPartCreatedEventWire | RuntimeSessionItemContentDeltaEventWire | RuntimeSessionExecutionEventWire | RuntimeUnknownEventWire;
294
+ export type RuntimeEventWire = RuntimeSessionCreatedEventWire | RuntimeSessionUpdatedEventWire | RuntimePendingInputCreatedEventWire | RuntimePendingInputCommittedEventWire | RuntimeSessionItemEventWire | RuntimeSessionItemPartCreatedEventWire | RuntimeSessionItemContentDeltaEventWire | RuntimeSessionExecutionEventWire | RuntimeUnknownEventWire;
278
295
  export type RuntimeCommandAck = {
279
296
  commandId: string;
280
297
  status: 'accepted';
@@ -327,6 +344,7 @@ export type RuntimeCreateFileAccessUrlResult = {
327
344
  export type RuntimeCreateSessionParams = {
328
345
  idempotencyKey: string;
329
346
  title?: string;
347
+ generateTitle?: boolean;
330
348
  signal?: AbortSignal;
331
349
  };
332
350
  export type RuntimeGetSessionViewParams = {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@aimount/core",
3
3
  "private": false,
4
- "version": "0.2.0-beta.1",
4
+ "version": "0.2.0-beta.3",
5
5
  "type": "module",
6
6
  "description": "Core Runtime API contracts and DTOs for aimount",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
- "main": "./dist/index.cjs.js",
10
+ "main": "./dist/index.cjs",
11
11
  "module": "./dist/index.es.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
@@ -17,7 +17,7 @@
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.es.js",
20
- "require": "./dist/index.cjs.js",
20
+ "require": "./dist/index.cjs",
21
21
  "default": "./dist/index.es.js"
22
22
  },
23
23
  "./package.json": "./package.json"
package/dist/index.cjs.js DELETED
@@ -1 +0,0 @@
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;