@aimount/core 0.2.0-beta.0 → 0.2.0-beta.2
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/dist/index.cjs +1 -0
- package/dist/index.es.js +238 -169
- package/dist/runtime-api.d.ts +83 -5
- package/package.json +3 -3
- package/dist/index.cjs.js +0 -1
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()}),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.es.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
const
|
|
2
|
+
const o = e.record(e.string(), e.unknown()), a = e.number().int().nonnegative(), d = e.object({
|
|
3
3
|
code: e.string(),
|
|
4
4
|
message: e.string(),
|
|
5
|
-
details:
|
|
6
|
-
}),
|
|
5
|
+
details: o.optional()
|
|
6
|
+
}), x = e.object({
|
|
7
7
|
agentId: e.string(),
|
|
8
8
|
userId: e.string()
|
|
9
|
-
}),
|
|
9
|
+
}), R = x.extend({
|
|
10
10
|
profileId: e.string()
|
|
11
|
-
}),
|
|
11
|
+
}), I = 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
|
-
}),
|
|
18
|
+
}), C = e.object({
|
|
19
19
|
id: e.string(),
|
|
20
20
|
agentId: e.string(),
|
|
21
21
|
userId: e.string(),
|
|
@@ -23,7 +23,7 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
23
23
|
createdAt: e.string(),
|
|
24
24
|
updatedAt: e.string(),
|
|
25
25
|
lastActivityAt: e.string()
|
|
26
|
-
}),
|
|
26
|
+
}), l = e.object({
|
|
27
27
|
roleId: e.string(),
|
|
28
28
|
modelId: e.string()
|
|
29
29
|
}), k = e.string().min(1), v = e.object({
|
|
@@ -32,14 +32,27 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
32
32
|
status: k,
|
|
33
33
|
inputBoundary: e.object({ lastUserMessageId: e.string() }).nullable().optional(),
|
|
34
34
|
agentMessageId: e.string().nullable().optional(),
|
|
35
|
-
selection:
|
|
35
|
+
selection: l.optional(),
|
|
36
36
|
createdAt: e.string(),
|
|
37
37
|
updatedAt: e.string()
|
|
38
|
-
}),
|
|
38
|
+
}), w = e.object({
|
|
39
39
|
type: e.literal("text"),
|
|
40
40
|
id: e.string(),
|
|
41
41
|
text: e.string()
|
|
42
|
-
}),
|
|
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(
|
|
43
56
|
"status",
|
|
44
57
|
[
|
|
45
58
|
e.object({
|
|
@@ -47,7 +60,7 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
47
60
|
id: e.string(),
|
|
48
61
|
name: e.string(),
|
|
49
62
|
status: e.literal("succeeded"),
|
|
50
|
-
input:
|
|
63
|
+
input: o,
|
|
51
64
|
result: e.unknown()
|
|
52
65
|
}),
|
|
53
66
|
e.object({
|
|
@@ -55,7 +68,7 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
55
68
|
id: e.string(),
|
|
56
69
|
name: e.string(),
|
|
57
70
|
status: e.literal("failed"),
|
|
58
|
-
input:
|
|
71
|
+
input: o,
|
|
59
72
|
error: d
|
|
60
73
|
}),
|
|
61
74
|
e.object({
|
|
@@ -63,7 +76,7 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
63
76
|
id: e.string(),
|
|
64
77
|
name: e.string(),
|
|
65
78
|
status: e.literal("denied"),
|
|
66
|
-
input:
|
|
79
|
+
input: o,
|
|
67
80
|
denial: d
|
|
68
81
|
}),
|
|
69
82
|
e.object({
|
|
@@ -71,74 +84,78 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
71
84
|
id: e.string(),
|
|
72
85
|
name: e.string(),
|
|
73
86
|
status: e.literal("cancelled"),
|
|
74
|
-
input:
|
|
87
|
+
input: o,
|
|
75
88
|
cancellation: d
|
|
76
89
|
})
|
|
77
90
|
]
|
|
78
|
-
),
|
|
91
|
+
), T = e.object({
|
|
79
92
|
type: e.literal("unknown"),
|
|
80
93
|
id: e.string(),
|
|
81
94
|
originalType: e.string(),
|
|
82
95
|
payload: e.unknown()
|
|
83
|
-
}),
|
|
96
|
+
}), O = e.object({
|
|
84
97
|
type: e.string(),
|
|
85
98
|
id: e.string().optional()
|
|
86
|
-
}).passthrough(),
|
|
99
|
+
}).passthrough(), B = e.object({
|
|
87
100
|
roleId: e.string().optional(),
|
|
88
101
|
modelId: e.string().optional()
|
|
89
102
|
}).transform((n) => {
|
|
90
103
|
const t = {};
|
|
91
104
|
return n.roleId !== void 0 && (t.roleId = n.roleId), n.modelId !== void 0 && (t.modelId = n.modelId), t;
|
|
92
|
-
}),
|
|
105
|
+
}), M = e.object({
|
|
106
|
+
input: e.array(e.string().min(1)),
|
|
107
|
+
output: e.array(e.string().min(1))
|
|
108
|
+
}), f = e.object({
|
|
93
109
|
id: e.string(),
|
|
94
|
-
name: e.string()
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
name: e.string(),
|
|
111
|
+
modalities: M.optional()
|
|
112
|
+
}), F = e.object({
|
|
113
|
+
scope: R,
|
|
97
114
|
selection: e.object({
|
|
98
|
-
roles: e.array(
|
|
99
|
-
models: e.array(
|
|
100
|
-
defaults:
|
|
115
|
+
roles: e.array(f),
|
|
116
|
+
models: e.array(f),
|
|
117
|
+
defaults: l.nullable()
|
|
101
118
|
}),
|
|
102
119
|
limits: e.object({
|
|
103
|
-
maxInputTextLength:
|
|
104
|
-
maxMessages:
|
|
105
|
-
maxTokens:
|
|
106
|
-
messagesPerMinute:
|
|
107
|
-
messagesPerHour:
|
|
108
|
-
messagesPerDay:
|
|
120
|
+
maxInputTextLength: a,
|
|
121
|
+
maxMessages: a.nullable(),
|
|
122
|
+
maxTokens: a.nullable(),
|
|
123
|
+
messagesPerMinute: a.nullable(),
|
|
124
|
+
messagesPerHour: a.nullable(),
|
|
125
|
+
messagesPerDay: a.nullable()
|
|
109
126
|
})
|
|
110
|
-
}),
|
|
127
|
+
}), W = e.object({
|
|
111
128
|
lastUserMessageId: e.string()
|
|
112
129
|
}), u = e.object({
|
|
113
130
|
type: e.string(),
|
|
114
131
|
id: e.string(),
|
|
115
132
|
sessionId: e.string(),
|
|
116
133
|
createdAt: e.string(),
|
|
117
|
-
metadata:
|
|
118
|
-
}),
|
|
134
|
+
metadata: o.optional()
|
|
135
|
+
}), q = e.enum([
|
|
119
136
|
"in_progress",
|
|
120
137
|
"completed",
|
|
121
138
|
"failed",
|
|
122
139
|
"cancelled"
|
|
123
|
-
]),
|
|
140
|
+
]), z = u.extend({
|
|
124
141
|
type: e.literal("user_message"),
|
|
125
142
|
commandId: e.string().optional(),
|
|
126
143
|
content: e.array(e.unknown()),
|
|
127
144
|
environment: e.unknown().optional(),
|
|
128
|
-
selection:
|
|
129
|
-
}),
|
|
145
|
+
selection: l.optional()
|
|
146
|
+
}), E = e.object({
|
|
130
147
|
id: e.string(),
|
|
131
148
|
commandId: e.string(),
|
|
132
|
-
|
|
133
|
-
selection:
|
|
149
|
+
content: e.array(A),
|
|
150
|
+
selection: l.optional(),
|
|
134
151
|
createdAt: e.string()
|
|
135
|
-
}),
|
|
152
|
+
}), L = u.extend({
|
|
136
153
|
type: e.literal("agent_message"),
|
|
137
|
-
status:
|
|
138
|
-
inputBoundary:
|
|
139
|
-
selection:
|
|
154
|
+
status: q,
|
|
155
|
+
inputBoundary: W.optional(),
|
|
156
|
+
selection: l.optional(),
|
|
140
157
|
content: e.array(e.unknown())
|
|
141
|
-
}),
|
|
158
|
+
}), N = u.extend({
|
|
142
159
|
type: e.literal("compaction"),
|
|
143
160
|
status: e.enum(["in_progress", "completed", "failed", "cancelled"]),
|
|
144
161
|
reason: e.string().optional(),
|
|
@@ -147,50 +164,71 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
147
164
|
retainedContext: e.string().optional(),
|
|
148
165
|
error: d.optional(),
|
|
149
166
|
cancellation: d.optional()
|
|
150
|
-
}),
|
|
167
|
+
}), V = e.object({
|
|
151
168
|
eventId: e.string(),
|
|
152
169
|
previousEventId: e.string().nullable(),
|
|
153
170
|
sessionId: e.string(),
|
|
154
171
|
commandId: e.string().optional(),
|
|
155
172
|
type: e.string().min(1),
|
|
156
173
|
createdAt: e.string(),
|
|
157
|
-
payload:
|
|
158
|
-
}),
|
|
174
|
+
payload: o
|
|
175
|
+
}), D = e.object({
|
|
159
176
|
itemId: e.string(),
|
|
160
177
|
partId: e.string(),
|
|
161
178
|
partType: e.literal("text"),
|
|
162
179
|
delta: e.string()
|
|
163
|
-
}),
|
|
180
|
+
}), H = e.object({
|
|
164
181
|
itemId: e.string(),
|
|
165
|
-
part:
|
|
166
|
-
}),
|
|
182
|
+
part: w.extend({ id: e.string() })
|
|
183
|
+
}), $ = e.object({
|
|
167
184
|
pendingInput: e.object({
|
|
168
185
|
id: e.string(),
|
|
169
186
|
sessionId: e.string(),
|
|
170
187
|
commandId: e.string(),
|
|
171
|
-
|
|
172
|
-
requestedSelection:
|
|
173
|
-
selection:
|
|
188
|
+
content: e.array(A),
|
|
189
|
+
requestedSelection: B.optional(),
|
|
190
|
+
selection: l.optional(),
|
|
174
191
|
createdAt: e.string()
|
|
175
192
|
})
|
|
176
|
-
}),
|
|
193
|
+
}), G = e.object({
|
|
177
194
|
pendingInputId: e.string(),
|
|
178
195
|
commandId: e.string(),
|
|
179
196
|
itemId: e.string()
|
|
180
|
-
}),
|
|
197
|
+
}), J = e.unknown().transform((n, t) => {
|
|
181
198
|
try {
|
|
182
|
-
return
|
|
199
|
+
return ce(n);
|
|
183
200
|
} catch {
|
|
184
201
|
return t.addIssue({ code: "custom", message: "invalid_runtime_event" }), e.NEVER;
|
|
185
202
|
}
|
|
186
|
-
}),
|
|
187
|
-
events: e.array(
|
|
203
|
+
}), K = e.object({
|
|
204
|
+
events: e.array(J),
|
|
188
205
|
nextEventId: e.string().nullable()
|
|
189
|
-
}),
|
|
206
|
+
}), y = e.object({
|
|
190
207
|
commandId: e.string(),
|
|
191
208
|
status: e.literal("accepted")
|
|
192
|
-
}),
|
|
193
|
-
|
|
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,
|
|
194
232
|
execution: v,
|
|
195
233
|
lastEventId: e.string(),
|
|
196
234
|
capabilities: e.object({
|
|
@@ -218,28 +256,28 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
218
256
|
hasNewer: e.boolean()
|
|
219
257
|
}).transform((n) => ({
|
|
220
258
|
...n,
|
|
221
|
-
entries: n.entries.map(
|
|
259
|
+
entries: n.entries.map(_)
|
|
222
260
|
})),
|
|
223
|
-
pendingInput: e.object({ entries: e.array(
|
|
261
|
+
pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] }),
|
|
224
262
|
ack: e.object({
|
|
225
263
|
sessionId: e.string(),
|
|
226
264
|
commandId: e.string(),
|
|
227
265
|
status: e.literal("accepted")
|
|
228
266
|
})
|
|
229
|
-
}),
|
|
267
|
+
}), ie = e.enum(["session_unavailable", "maintenance"]), se = e.enum([
|
|
230
268
|
"execution_not_active",
|
|
231
269
|
"session_unavailable",
|
|
232
270
|
"maintenance"
|
|
233
271
|
]), S = (n) => e.discriminatedUnion("available", [
|
|
234
272
|
e.object({ available: e.literal(!0) }),
|
|
235
273
|
e.object({ available: e.literal(!1), reason: n })
|
|
236
|
-
]),
|
|
237
|
-
session:
|
|
274
|
+
]), ae = e.object({
|
|
275
|
+
session: I,
|
|
238
276
|
execution: v,
|
|
239
277
|
lastEventId: e.string().nullable(),
|
|
240
278
|
capabilities: e.object({
|
|
241
|
-
sendText: S(
|
|
242
|
-
stop: S(
|
|
279
|
+
sendText: S(ie),
|
|
280
|
+
stop: S(se)
|
|
243
281
|
}),
|
|
244
282
|
items: e.object({
|
|
245
283
|
entries: e.array(e.unknown()),
|
|
@@ -249,50 +287,53 @@ const r = e.record(e.string(), e.unknown()), o = e.number().int().nonnegative(),
|
|
|
249
287
|
hasOlder: e.boolean(),
|
|
250
288
|
hasNewer: e.boolean()
|
|
251
289
|
}),
|
|
252
|
-
pendingInput: e.object({ entries: e.array(
|
|
290
|
+
pendingInput: e.object({ entries: e.array(E) }).optional().default({ entries: [] })
|
|
253
291
|
}).transform((n) => ({
|
|
254
292
|
...n,
|
|
255
293
|
items: {
|
|
256
294
|
...n.items,
|
|
257
|
-
entries: n.items.entries.map(
|
|
295
|
+
entries: n.items.entries.map(_)
|
|
258
296
|
}
|
|
259
|
-
})),
|
|
260
|
-
items: e.array(
|
|
297
|
+
})), re = e.object({
|
|
298
|
+
items: e.array(C),
|
|
261
299
|
nextCursor: e.string().nullable()
|
|
262
300
|
});
|
|
263
|
-
function
|
|
264
|
-
return
|
|
301
|
+
function me(n) {
|
|
302
|
+
return s(n, d, "invalid_runtime_error");
|
|
265
303
|
}
|
|
266
|
-
function
|
|
267
|
-
return
|
|
304
|
+
function pe(n) {
|
|
305
|
+
return s(n, F, "invalid_runtime_profile_response");
|
|
268
306
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
307
|
+
function oe(n) {
|
|
308
|
+
return s(n, I, "invalid_runtime_session");
|
|
271
309
|
}
|
|
272
|
-
function
|
|
273
|
-
return
|
|
310
|
+
function h(n) {
|
|
311
|
+
return s(n, v, "invalid_runtime_session_execution");
|
|
274
312
|
}
|
|
275
|
-
function
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
278
|
-
return
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
return
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
284
|
-
return
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
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)
|
|
287
328
|
return {
|
|
288
329
|
type: "unknown",
|
|
289
|
-
id:
|
|
290
|
-
originalType:
|
|
330
|
+
id: p.data.id ?? `unknown_${t}`,
|
|
331
|
+
originalType: p.data.type,
|
|
291
332
|
payload: n
|
|
292
333
|
};
|
|
293
334
|
throw new Error("invalid_runtime_content");
|
|
294
335
|
}
|
|
295
|
-
function
|
|
336
|
+
function le(n) {
|
|
296
337
|
switch (n.status) {
|
|
297
338
|
case "succeeded":
|
|
298
339
|
return Object.hasOwn(n, "result");
|
|
@@ -304,54 +345,54 @@ function te(n) {
|
|
|
304
345
|
return Object.hasOwn(n, "cancellation");
|
|
305
346
|
}
|
|
306
347
|
}
|
|
307
|
-
function
|
|
348
|
+
function _(n) {
|
|
308
349
|
const t = u.safeParse(n);
|
|
309
350
|
if (!t.success)
|
|
310
351
|
throw new Error("invalid_runtime_session_item");
|
|
311
|
-
const
|
|
312
|
-
...
|
|
352
|
+
const r = () => ({
|
|
353
|
+
...g(t.data),
|
|
313
354
|
type: "unknown",
|
|
314
355
|
originalType: t.data.type,
|
|
315
356
|
payload: n
|
|
316
357
|
});
|
|
317
358
|
if (t.data.type === "user_message") {
|
|
318
|
-
const
|
|
319
|
-
if (!
|
|
359
|
+
const i = z.safeParse(n);
|
|
360
|
+
if (!i.success)
|
|
320
361
|
throw new Error("invalid_runtime_session_item");
|
|
321
362
|
return {
|
|
322
|
-
...
|
|
363
|
+
...g(i.data),
|
|
323
364
|
type: "user_message",
|
|
324
|
-
...
|
|
325
|
-
content:
|
|
326
|
-
..."environment" in
|
|
327
|
-
...
|
|
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 }
|
|
328
369
|
};
|
|
329
370
|
}
|
|
330
371
|
if (t.data.type === "agent_message") {
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
372
|
+
const i = L.safeParse(n);
|
|
373
|
+
if (!i.success)
|
|
333
374
|
throw new Error("invalid_runtime_session_item");
|
|
334
375
|
return {
|
|
335
|
-
...
|
|
376
|
+
...g(i.data),
|
|
336
377
|
type: "agent_message",
|
|
337
|
-
status:
|
|
338
|
-
inputBoundary:
|
|
339
|
-
...
|
|
340
|
-
content:
|
|
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)
|
|
341
382
|
};
|
|
342
383
|
}
|
|
343
384
|
if (t.data.type === "compaction") {
|
|
344
|
-
const
|
|
345
|
-
if (!
|
|
385
|
+
const i = N.safeParse(n);
|
|
386
|
+
if (!i.success)
|
|
346
387
|
throw new Error("invalid_runtime_session_item");
|
|
347
|
-
return
|
|
388
|
+
return i.data;
|
|
348
389
|
}
|
|
349
|
-
return
|
|
390
|
+
return r();
|
|
350
391
|
}
|
|
351
|
-
function
|
|
352
|
-
const t =
|
|
392
|
+
function ce(n) {
|
|
393
|
+
const t = s(
|
|
353
394
|
n,
|
|
354
|
-
|
|
395
|
+
V,
|
|
355
396
|
"invalid_runtime_event"
|
|
356
397
|
);
|
|
357
398
|
try {
|
|
@@ -363,8 +404,10 @@ function ne(n) {
|
|
|
363
404
|
type: t.type,
|
|
364
405
|
createdAt: t.createdAt,
|
|
365
406
|
payload: {
|
|
366
|
-
session:
|
|
367
|
-
execution:
|
|
407
|
+
session: oe(c(t.payload, "session")),
|
|
408
|
+
execution: h(
|
|
409
|
+
c(t.payload, "execution")
|
|
410
|
+
)
|
|
368
411
|
}
|
|
369
412
|
};
|
|
370
413
|
if (t.type === "session_execution.updated")
|
|
@@ -375,7 +418,11 @@ function ne(n) {
|
|
|
375
418
|
...t.commandId === void 0 ? {} : { commandId: t.commandId },
|
|
376
419
|
type: t.type,
|
|
377
420
|
createdAt: t.createdAt,
|
|
378
|
-
payload: {
|
|
421
|
+
payload: {
|
|
422
|
+
execution: h(
|
|
423
|
+
c(t.payload, "execution")
|
|
424
|
+
)
|
|
425
|
+
}
|
|
379
426
|
};
|
|
380
427
|
if (t.type === "pending_input.created")
|
|
381
428
|
return {
|
|
@@ -385,9 +432,9 @@ function ne(n) {
|
|
|
385
432
|
...t.commandId === void 0 ? {} : { commandId: t.commandId },
|
|
386
433
|
type: t.type,
|
|
387
434
|
createdAt: t.createdAt,
|
|
388
|
-
payload:
|
|
435
|
+
payload: s(
|
|
389
436
|
t.payload,
|
|
390
|
-
|
|
437
|
+
$,
|
|
391
438
|
"invalid_runtime_event"
|
|
392
439
|
)
|
|
393
440
|
};
|
|
@@ -399,9 +446,9 @@ function ne(n) {
|
|
|
399
446
|
...t.commandId === void 0 ? {} : { commandId: t.commandId },
|
|
400
447
|
type: t.type,
|
|
401
448
|
createdAt: t.createdAt,
|
|
402
|
-
payload:
|
|
449
|
+
payload: s(
|
|
403
450
|
t.payload,
|
|
404
|
-
|
|
451
|
+
G,
|
|
405
452
|
"invalid_runtime_event"
|
|
406
453
|
)
|
|
407
454
|
};
|
|
@@ -413,7 +460,9 @@ function ne(n) {
|
|
|
413
460
|
...t.commandId === void 0 ? {} : { commandId: t.commandId },
|
|
414
461
|
type: t.type,
|
|
415
462
|
createdAt: t.createdAt,
|
|
416
|
-
payload: {
|
|
463
|
+
payload: {
|
|
464
|
+
item: _(c(t.payload, "item"))
|
|
465
|
+
}
|
|
417
466
|
};
|
|
418
467
|
if (t.type === "session_item.content_delta")
|
|
419
468
|
return {
|
|
@@ -422,9 +471,9 @@ function ne(n) {
|
|
|
422
471
|
sessionId: t.sessionId,
|
|
423
472
|
type: t.type,
|
|
424
473
|
createdAt: t.createdAt,
|
|
425
|
-
payload:
|
|
474
|
+
payload: s(
|
|
426
475
|
t.payload,
|
|
427
|
-
|
|
476
|
+
D,
|
|
428
477
|
"invalid_runtime_event"
|
|
429
478
|
)
|
|
430
479
|
};
|
|
@@ -435,9 +484,9 @@ function ne(n) {
|
|
|
435
484
|
sessionId: t.sessionId,
|
|
436
485
|
type: t.type,
|
|
437
486
|
createdAt: t.createdAt,
|
|
438
|
-
payload:
|
|
487
|
+
payload: s(
|
|
439
488
|
t.payload,
|
|
440
|
-
|
|
489
|
+
H,
|
|
441
490
|
"invalid_runtime_event"
|
|
442
491
|
)
|
|
443
492
|
};
|
|
@@ -454,53 +503,69 @@ function ne(n) {
|
|
|
454
503
|
payload: t.payload
|
|
455
504
|
};
|
|
456
505
|
}
|
|
457
|
-
function
|
|
458
|
-
return
|
|
506
|
+
function ge(n) {
|
|
507
|
+
return s(
|
|
508
|
+
n,
|
|
509
|
+
K,
|
|
510
|
+
"invalid_runtime_session_events_page"
|
|
511
|
+
);
|
|
459
512
|
}
|
|
460
|
-
function
|
|
513
|
+
function c(n, t) {
|
|
461
514
|
if (Object.hasOwn(n, t)) return n[t];
|
|
462
515
|
throw new Error("invalid_runtime_event");
|
|
463
516
|
}
|
|
464
|
-
function
|
|
465
|
-
return
|
|
517
|
+
function Ie(n) {
|
|
518
|
+
return s(n, y, "invalid_runtime_command_ack");
|
|
466
519
|
}
|
|
467
|
-
function
|
|
468
|
-
return
|
|
520
|
+
function ve(n) {
|
|
521
|
+
return s(n, Q, "invalid_runtime_input_ack");
|
|
469
522
|
}
|
|
470
|
-
function
|
|
471
|
-
return
|
|
523
|
+
function ye(n) {
|
|
524
|
+
return s(n, X, "invalid_runtime_stop_ack");
|
|
472
525
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
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(
|
|
475
540
|
n,
|
|
476
|
-
|
|
541
|
+
ne,
|
|
477
542
|
"invalid_runtime_create_session_response"
|
|
478
543
|
);
|
|
479
544
|
}
|
|
480
|
-
function
|
|
481
|
-
return
|
|
545
|
+
function je(n) {
|
|
546
|
+
return s(n, ae, "invalid_runtime_session_view_response");
|
|
482
547
|
}
|
|
483
|
-
function
|
|
484
|
-
return
|
|
548
|
+
function we(n) {
|
|
549
|
+
return s(
|
|
485
550
|
n,
|
|
486
|
-
|
|
551
|
+
re,
|
|
487
552
|
"invalid_runtime_list_sessions_response"
|
|
488
553
|
);
|
|
489
554
|
}
|
|
490
|
-
function
|
|
491
|
-
const
|
|
492
|
-
if (!
|
|
493
|
-
throw new Error(
|
|
494
|
-
return
|
|
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;
|
|
495
560
|
}
|
|
496
|
-
function
|
|
561
|
+
function j(n) {
|
|
497
562
|
try {
|
|
498
|
-
return n.map((t,
|
|
563
|
+
return n.map((t, r) => de(t, r));
|
|
499
564
|
} catch {
|
|
500
565
|
throw new Error("invalid_runtime_session_item");
|
|
501
566
|
}
|
|
502
567
|
}
|
|
503
|
-
function
|
|
568
|
+
function g(n) {
|
|
504
569
|
return {
|
|
505
570
|
type: n.type,
|
|
506
571
|
id: n.id,
|
|
@@ -510,18 +575,22 @@ function p(n) {
|
|
|
510
575
|
};
|
|
511
576
|
}
|
|
512
577
|
export {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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
|
|
527
596
|
};
|
package/dist/runtime-api.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export type RuntimeError = {
|
|
|
7
7
|
export type RuntimeSelectionOption = {
|
|
8
8
|
id: string;
|
|
9
9
|
name: string;
|
|
10
|
+
modalities?: RuntimeModelModalities | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type RuntimeModelInputModality = 'text' | 'image' | 'pdf' | (string & {});
|
|
13
|
+
export type RuntimeModelOutputModality = 'text' | (string & {});
|
|
14
|
+
export type RuntimeModelModalities = {
|
|
15
|
+
input: RuntimeModelInputModality[];
|
|
16
|
+
output: RuntimeModelOutputModality[];
|
|
10
17
|
};
|
|
11
18
|
export type RuntimeLimits = {
|
|
12
19
|
maxInputTextLength: number;
|
|
@@ -65,6 +72,14 @@ export type RuntimeTextContent = {
|
|
|
65
72
|
id: string;
|
|
66
73
|
text: string;
|
|
67
74
|
};
|
|
75
|
+
export type RuntimeFileContent = {
|
|
76
|
+
type: 'file';
|
|
77
|
+
id: string;
|
|
78
|
+
fileId: string;
|
|
79
|
+
name?: string | undefined;
|
|
80
|
+
mediaType?: string | undefined;
|
|
81
|
+
sizeBytes?: number | undefined;
|
|
82
|
+
};
|
|
68
83
|
export type RuntimeToolCallContent = {
|
|
69
84
|
type: 'tool_call';
|
|
70
85
|
id: string;
|
|
@@ -100,7 +115,7 @@ export type RuntimeUnknownContent = {
|
|
|
100
115
|
originalType: string;
|
|
101
116
|
payload: unknown;
|
|
102
117
|
};
|
|
103
|
-
export type RuntimeContent = RuntimeTextContent | RuntimeToolCallContent | RuntimeUnknownContent;
|
|
118
|
+
export type RuntimeContent = RuntimeTextContent | RuntimeFileContent | RuntimeToolCallContent | RuntimeUnknownContent;
|
|
104
119
|
export type RuntimeUserMessageContent = RuntimeContent;
|
|
105
120
|
export type RuntimeAgentMessageContent = RuntimeContent;
|
|
106
121
|
export type RuntimeSelection = {
|
|
@@ -110,6 +125,13 @@ export type RuntimeSelection = {
|
|
|
110
125
|
export type RuntimeInputBoundary = {
|
|
111
126
|
lastUserMessageId: string;
|
|
112
127
|
};
|
|
128
|
+
export type RuntimeSubmitInputContent = {
|
|
129
|
+
type: 'text';
|
|
130
|
+
text: string;
|
|
131
|
+
} | {
|
|
132
|
+
type: 'file';
|
|
133
|
+
fileId: string;
|
|
134
|
+
};
|
|
113
135
|
export type RuntimeSessionItemBase<TType extends string> = {
|
|
114
136
|
type: TType;
|
|
115
137
|
id: string;
|
|
@@ -126,8 +148,8 @@ export type RuntimeUserMessage = RuntimeSessionItemBase<'user_message'> & {
|
|
|
126
148
|
export type RuntimePendingUserMessage = {
|
|
127
149
|
id: string;
|
|
128
150
|
commandId: string;
|
|
129
|
-
|
|
130
|
-
selection
|
|
151
|
+
content: RuntimeSubmitInputContent[];
|
|
152
|
+
selection?: RuntimeSelection;
|
|
131
153
|
createdAt: string;
|
|
132
154
|
};
|
|
133
155
|
export type RuntimeAgentMessageStatus = 'in_progress' | 'completed' | 'failed' | 'cancelled';
|
|
@@ -176,7 +198,7 @@ export type RuntimePendingInputCreatedEventWire = {
|
|
|
176
198
|
id: string;
|
|
177
199
|
sessionId: string;
|
|
178
200
|
commandId: string;
|
|
179
|
-
|
|
201
|
+
content: RuntimeSubmitInputContent[];
|
|
180
202
|
requestedSelection?: Partial<RuntimeSelection> | undefined;
|
|
181
203
|
selection?: RuntimeSelection | undefined;
|
|
182
204
|
createdAt: string;
|
|
@@ -259,6 +281,49 @@ export type RuntimeCommandAck = {
|
|
|
259
281
|
};
|
|
260
282
|
export type RuntimeInputCommandAck = RuntimeCommandAck;
|
|
261
283
|
export type RuntimeStopCommandAck = RuntimeCommandAck;
|
|
284
|
+
export type RuntimeCreateFileUploadParams = {
|
|
285
|
+
name: string;
|
|
286
|
+
mediaType: string;
|
|
287
|
+
sizeBytes: number;
|
|
288
|
+
signal?: AbortSignal;
|
|
289
|
+
};
|
|
290
|
+
export type RuntimeCreateFileUploadResult = {
|
|
291
|
+
fileId: string;
|
|
292
|
+
status: 'draft';
|
|
293
|
+
uploadUrl: string;
|
|
294
|
+
uploadUrlExpiresAt: string;
|
|
295
|
+
name: string;
|
|
296
|
+
mediaType: string;
|
|
297
|
+
sizeBytes: number;
|
|
298
|
+
};
|
|
299
|
+
export type RuntimeRefreshFileUploadUrlParams = {
|
|
300
|
+
fileId: string;
|
|
301
|
+
signal?: AbortSignal;
|
|
302
|
+
};
|
|
303
|
+
export type RuntimeRefreshFileUploadUrlResult = {
|
|
304
|
+
fileId: string;
|
|
305
|
+
uploadUrl: string;
|
|
306
|
+
uploadUrlExpiresAt: string;
|
|
307
|
+
};
|
|
308
|
+
export type RuntimeCompleteFileUploadParams = {
|
|
309
|
+
fileId: string;
|
|
310
|
+
signal?: AbortSignal;
|
|
311
|
+
};
|
|
312
|
+
export type RuntimeCompleteFileUploadResult = {
|
|
313
|
+
fileId: string;
|
|
314
|
+
status: 'ready';
|
|
315
|
+
name: string;
|
|
316
|
+
mediaType: string;
|
|
317
|
+
sizeBytes: number;
|
|
318
|
+
};
|
|
319
|
+
export type RuntimeCreateFileAccessUrlParams = {
|
|
320
|
+
fileId: string;
|
|
321
|
+
signal?: AbortSignal;
|
|
322
|
+
};
|
|
323
|
+
export type RuntimeCreateFileAccessUrlResult = {
|
|
324
|
+
url: string;
|
|
325
|
+
expiresAt: string;
|
|
326
|
+
};
|
|
262
327
|
export type RuntimeCreateSessionParams = {
|
|
263
328
|
idempotencyKey: string;
|
|
264
329
|
title?: string;
|
|
@@ -275,6 +340,10 @@ export type RuntimeListSessionsParams = {
|
|
|
275
340
|
cursor?: string;
|
|
276
341
|
signal?: AbortSignal;
|
|
277
342
|
};
|
|
343
|
+
export type RuntimeDeleteSessionParams = {
|
|
344
|
+
sessionId: string;
|
|
345
|
+
signal?: AbortSignal;
|
|
346
|
+
};
|
|
278
347
|
export type RuntimeReadSessionEventsParams = {
|
|
279
348
|
sessionId: string;
|
|
280
349
|
afterEventId?: string;
|
|
@@ -285,7 +354,7 @@ export type RuntimeReadSessionEventsParams = {
|
|
|
285
354
|
export type RuntimeSubmitSessionInputParams = {
|
|
286
355
|
sessionId: string;
|
|
287
356
|
idempotencyKey: string;
|
|
288
|
-
|
|
357
|
+
content: RuntimeSubmitInputContent[];
|
|
289
358
|
selection?: RuntimeSelection;
|
|
290
359
|
signal?: AbortSignal;
|
|
291
360
|
};
|
|
@@ -346,8 +415,13 @@ export type RuntimeApi = {
|
|
|
346
415
|
getProfile: (_?: {
|
|
347
416
|
signal?: AbortSignal;
|
|
348
417
|
}) => Promise<RuntimeResult<RuntimeProfile>>;
|
|
418
|
+
createFileUpload: (_: RuntimeCreateFileUploadParams) => Promise<RuntimeResult<RuntimeCreateFileUploadResult>>;
|
|
419
|
+
refreshFileUploadUrl: (_: RuntimeRefreshFileUploadUrlParams) => Promise<RuntimeResult<RuntimeRefreshFileUploadUrlResult>>;
|
|
420
|
+
completeFileUpload: (_: RuntimeCompleteFileUploadParams) => Promise<RuntimeResult<RuntimeCompleteFileUploadResult>>;
|
|
421
|
+
createFileAccessUrl: (_: RuntimeCreateFileAccessUrlParams) => Promise<RuntimeResult<RuntimeCreateFileAccessUrlResult>>;
|
|
349
422
|
createSession: (_: RuntimeCreateSessionParams) => Promise<RuntimeResult<RuntimeCreateSessionResult>>;
|
|
350
423
|
listSessions: (_?: RuntimeListSessionsParams) => Promise<RuntimeResult<RuntimeListSessionsResult>>;
|
|
424
|
+
deleteSession: (_: RuntimeDeleteSessionParams) => Promise<RuntimeResult<void>>;
|
|
351
425
|
getSessionView: (_: RuntimeGetSessionViewParams) => Promise<RuntimeResult<RuntimeSessionView>>;
|
|
352
426
|
readSessionEvents: (_: RuntimeReadSessionEventsParams) => Promise<RuntimeResult<RuntimeSessionEventsPage>>;
|
|
353
427
|
submitSessionInput: (_: RuntimeSubmitSessionInputParams) => Promise<RuntimeResult<RuntimeInputCommandAck>>;
|
|
@@ -364,6 +438,10 @@ export declare function parseRuntimeSessionEventsPage(input: unknown): RuntimeSe
|
|
|
364
438
|
export declare function parseRuntimeCommandAck(input: unknown): RuntimeCommandAck;
|
|
365
439
|
export declare function parseRuntimeInputCommandAck(input: unknown): RuntimeInputCommandAck;
|
|
366
440
|
export declare function parseRuntimeStopCommandAck(input: unknown): RuntimeStopCommandAck;
|
|
441
|
+
export declare function parseRuntimeFileUploadResult(input: unknown): RuntimeCreateFileUploadResult;
|
|
442
|
+
export declare function parseRuntimeFileUploadUrlResult(input: unknown): RuntimeRefreshFileUploadUrlResult;
|
|
443
|
+
export declare function parseRuntimeFileCompleteResult(input: unknown): RuntimeCompleteFileUploadResult;
|
|
444
|
+
export declare function parseRuntimeFileAccessUrlResult(input: unknown): RuntimeCreateFileAccessUrlResult;
|
|
367
445
|
export declare function parseRuntimeCreateSessionResult(input: unknown): RuntimeCreateSessionResult;
|
|
368
446
|
export declare function parseRuntimeSessionView(input: unknown): RuntimeSessionView;
|
|
369
447
|
export declare function parseRuntimeListSessionsResult(input: unknown): RuntimeListSessionsResult;
|
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.
|
|
4
|
+
"version": "0.2.0-beta.2",
|
|
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
|
|
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
|
|
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"),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;
|