axexec 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +196 -0
- package/bin/axexec +17 -0
- package/dist/agents/claude-code/adapter.d.ts +6 -0
- package/dist/agents/claude-code/adapter.js +71 -0
- package/dist/agents/claude-code/parse-event.d.ts +16 -0
- package/dist/agents/claude-code/parse-event.js +185 -0
- package/dist/agents/claude-code/types.d.ts +180 -0
- package/dist/agents/claude-code/types.js +112 -0
- package/dist/agents/codex/adapter.d.ts +6 -0
- package/dist/agents/codex/adapter.js +62 -0
- package/dist/agents/codex/item-parsers.d.ts +17 -0
- package/dist/agents/codex/item-parsers.js +126 -0
- package/dist/agents/codex/parse-event.d.ts +38 -0
- package/dist/agents/codex/parse-event.js +141 -0
- package/dist/agents/codex/types.d.ts +407 -0
- package/dist/agents/codex/types.js +188 -0
- package/dist/agents/copilot/adapter.d.ts +11 -0
- package/dist/agents/copilot/adapter.js +81 -0
- package/dist/agents/copilot/parse-event.d.ts +20 -0
- package/dist/agents/copilot/parse-event.js +137 -0
- package/dist/agents/copilot/stream-session.d.ts +10 -0
- package/dist/agents/copilot/stream-session.js +120 -0
- package/dist/agents/copilot/tail-file.d.ts +11 -0
- package/dist/agents/copilot/tail-file.js +52 -0
- package/dist/agents/copilot/transform-event.d.ts +19 -0
- package/dist/agents/copilot/transform-event.js +100 -0
- package/dist/agents/copilot/types.d.ts +320 -0
- package/dist/agents/copilot/types.js +220 -0
- package/dist/agents/copilot/watch-session.d.ts +26 -0
- package/dist/agents/copilot/watch-session.js +186 -0
- package/dist/agents/gemini/adapter.d.ts +6 -0
- package/dist/agents/gemini/adapter.js +78 -0
- package/dist/agents/gemini/parse-event.d.ts +18 -0
- package/dist/agents/gemini/parse-event.js +144 -0
- package/dist/agents/gemini/types.d.ts +162 -0
- package/dist/agents/gemini/types.js +103 -0
- package/dist/agents/opencode/adapter.d.ts +16 -0
- package/dist/agents/opencode/adapter.js +142 -0
- package/dist/agents/opencode/cleanup-session.d.ts +17 -0
- package/dist/agents/opencode/cleanup-session.js +41 -0
- package/dist/agents/opencode/create-session-start-event.d.ts +18 -0
- package/dist/agents/opencode/create-session-start-event.js +24 -0
- package/dist/agents/opencode/detect-empty-session.d.ts +25 -0
- package/dist/agents/opencode/detect-empty-session.js +42 -0
- package/dist/agents/opencode/map-error-to-event.d.ts +10 -0
- package/dist/agents/opencode/map-error-to-event.js +55 -0
- package/dist/agents/opencode/parse-message-part.d.ts +24 -0
- package/dist/agents/opencode/parse-message-part.js +112 -0
- package/dist/agents/opencode/parse-sse-event.d.ts +23 -0
- package/dist/agents/opencode/parse-sse-event.js +125 -0
- package/dist/agents/opencode/process-sse-events.d.ts +24 -0
- package/dist/agents/opencode/process-sse-events.js +66 -0
- package/dist/agents/opencode/server-types.d.ts +509 -0
- package/dist/agents/opencode/server-types.js +293 -0
- package/dist/agents/opencode/session-api.d.ts +56 -0
- package/dist/agents/opencode/session-api.js +151 -0
- package/dist/agents/opencode/spawn-server.d.ts +29 -0
- package/dist/agents/opencode/spawn-server.js +95 -0
- package/dist/agents/opencode/sse-client.d.ts +33 -0
- package/dist/agents/opencode/sse-client.js +145 -0
- package/dist/agents/registry.d.ts +15 -0
- package/dist/agents/registry.js +24 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +119 -0
- package/dist/credentials/get-credential-environment.d.ts +13 -0
- package/dist/credentials/get-credential-environment.js +46 -0
- package/dist/credentials/install-credentials.d.ts +27 -0
- package/dist/credentials/install-credentials.js +102 -0
- package/dist/credentials/save-json-file.d.ts +11 -0
- package/dist/credentials/save-json-file.js +21 -0
- package/dist/credentials/types.d.ts +24 -0
- package/dist/credentials/types.js +4 -0
- package/dist/credentials/write-agent-credentials.d.ts +36 -0
- package/dist/credentials/write-agent-credentials.js +91 -0
- package/dist/determine-session-success.d.ts +15 -0
- package/dist/determine-session-success.js +25 -0
- package/dist/format-event-tsv.d.ts +23 -0
- package/dist/format-event-tsv.js +136 -0
- package/dist/parse-credentials.d.ts +13 -0
- package/dist/parse-credentials.js +63 -0
- package/dist/parse-iso-timestamp.d.ts +21 -0
- package/dist/parse-iso-timestamp.js +37 -0
- package/dist/resolve-binary.d.ts +29 -0
- package/dist/resolve-binary.js +46 -0
- package/dist/resolve-output-mode.d.ts +39 -0
- package/dist/resolve-output-mode.js +39 -0
- package/dist/run-agent.d.ts +32 -0
- package/dist/run-agent.js +146 -0
- package/dist/stream-agent.d.ts +20 -0
- package/dist/stream-agent.js +207 -0
- package/dist/types/adapter.d.ts +101 -0
- package/dist/types/adapter.js +14 -0
- package/dist/types/events.d.ts +82 -0
- package/dist/types/events.js +13 -0
- package/dist/types/options.d.ts +41 -0
- package/dist/types/options.js +4 -0
- package/dist/validate-agent.d.ts +20 -0
- package/dist/validate-agent.js +50 -0
- package/dist/write-event.d.ts +23 -0
- package/dist/write-event.js +43 -0
- package/package.json +79 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE event processing for OpenCode adapter.
|
|
3
|
+
*/
|
|
4
|
+
import type { AxexecEvent } from "../../types/events.js";
|
|
5
|
+
import { OpenCodeSSEEvent } from "./server-types.js";
|
|
6
|
+
interface ProcessEventsContext {
|
|
7
|
+
serverUrl: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
sessionStartTime: number;
|
|
10
|
+
requestedModel?: string;
|
|
11
|
+
cwd: string;
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
onComplete: () => void;
|
|
14
|
+
onAbort: () => void;
|
|
15
|
+
}
|
|
16
|
+
interface ProcessEventsResult {
|
|
17
|
+
sessionStartEmitted: boolean;
|
|
18
|
+
sessionComplete: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Processes SSE events and yields normalized AxexecEvents.
|
|
22
|
+
*/
|
|
23
|
+
declare function processSSEEvents(sseGenerator: AsyncGenerator<OpenCodeSSEEvent>, context: ProcessEventsContext): AsyncGenerator<AxexecEvent, ProcessEventsResult>;
|
|
24
|
+
export { processSSEEvents };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE event processing for OpenCode adapter.
|
|
3
|
+
*/
|
|
4
|
+
import { createSessionStartEvent } from "./create-session-start-event.js";
|
|
5
|
+
import { checkEmptySession, createContentTracker, trackContentEvent, } from "./detect-empty-session.js";
|
|
6
|
+
import { createSSEEventParser } from "./parse-sse-event.js";
|
|
7
|
+
import { isMessagePartUpdatedEvent, isSessionErrorEvent, isSessionIdleEvent, OpenCodeSSEEvent, } from "./server-types.js";
|
|
8
|
+
import { getSessionModelInfo } from "./session-api.js";
|
|
9
|
+
/**
|
|
10
|
+
* Processes SSE events and yields normalized AxexecEvents.
|
|
11
|
+
*/
|
|
12
|
+
async function* processSSEEvents(sseGenerator, context) {
|
|
13
|
+
const parseEvent = createSSEEventParser(context.sessionStartTime);
|
|
14
|
+
const contentTracker = createContentTracker();
|
|
15
|
+
let modelInfo;
|
|
16
|
+
let sessionStartEmitted = false;
|
|
17
|
+
let sessionComplete = false;
|
|
18
|
+
while (!context.signal.aborted) {
|
|
19
|
+
const result = await sseGenerator.next();
|
|
20
|
+
if (result.done)
|
|
21
|
+
break;
|
|
22
|
+
const sseEvent = result.value;
|
|
23
|
+
// On first message.part.updated, query for model info and emit session.start
|
|
24
|
+
if (!sessionStartEmitted && isMessagePartUpdatedEvent(sseEvent)) {
|
|
25
|
+
modelInfo = await getSessionModelInfo(context.serverUrl, context.sessionId, context.cwd);
|
|
26
|
+
yield createSessionStartEvent({
|
|
27
|
+
sessionId: context.sessionId,
|
|
28
|
+
timestamp: context.sessionStartTime,
|
|
29
|
+
modelInfo,
|
|
30
|
+
requestedModel: context.requestedModel,
|
|
31
|
+
});
|
|
32
|
+
sessionStartEmitted = true;
|
|
33
|
+
}
|
|
34
|
+
// Emit session.start before terminal events (fallback path)
|
|
35
|
+
const isTerminal = isSessionErrorEvent(sseEvent) || isSessionIdleEvent(sseEvent);
|
|
36
|
+
if (!sessionStartEmitted && isTerminal) {
|
|
37
|
+
yield createSessionStartEvent({
|
|
38
|
+
sessionId: context.sessionId,
|
|
39
|
+
timestamp: context.sessionStartTime,
|
|
40
|
+
modelInfo: undefined,
|
|
41
|
+
requestedModel: context.requestedModel,
|
|
42
|
+
});
|
|
43
|
+
sessionStartEmitted = true;
|
|
44
|
+
}
|
|
45
|
+
if (isSessionIdleEvent(sseEvent))
|
|
46
|
+
sessionComplete = true;
|
|
47
|
+
const axexecEvents = parseEvent(sseEvent);
|
|
48
|
+
for (const event of axexecEvents) {
|
|
49
|
+
trackContentEvent(contentTracker, event);
|
|
50
|
+
// Detect empty sessions (silent failures) and convert to error
|
|
51
|
+
const emptyError = checkEmptySession(event, contentTracker);
|
|
52
|
+
if (emptyError) {
|
|
53
|
+
yield emptyError;
|
|
54
|
+
context.onAbort();
|
|
55
|
+
return { sessionStartEmitted, sessionComplete };
|
|
56
|
+
}
|
|
57
|
+
yield event;
|
|
58
|
+
if (event.type === "session.complete" || event.type === "session.error") {
|
|
59
|
+
context.onAbort();
|
|
60
|
+
return { sessionStartEmitted, sessionComplete };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { sessionStartEmitted, sessionComplete };
|
|
65
|
+
}
|
|
66
|
+
export { processSSEEvents };
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE event types from OpenCode server mode.
|
|
3
|
+
*
|
|
4
|
+
* These types represent the events streamed via SSE from:
|
|
5
|
+
* `GET /event` endpoint on `opencode serve`
|
|
6
|
+
*
|
|
7
|
+
* The parser transforms these into normalized {@link AxexecEvent} types.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
/** session.created event */
|
|
11
|
+
declare const SessionCreatedEvent: z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"session.created">;
|
|
13
|
+
properties: z.ZodObject<{
|
|
14
|
+
info: z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
parentID: z.ZodOptional<z.ZodString>;
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
projectID: z.ZodOptional<z.ZodString>;
|
|
19
|
+
share: z.ZodOptional<z.ZodString>;
|
|
20
|
+
updated: z.ZodNumber;
|
|
21
|
+
created: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
type SessionCreatedEvent = z.infer<typeof SessionCreatedEvent>;
|
|
26
|
+
/** session.idle event - signals session has finished processing */
|
|
27
|
+
declare const SessionIdleEvent: z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"session.idle">;
|
|
29
|
+
properties: z.ZodObject<{
|
|
30
|
+
sessionID: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
type SessionIdleEvent = z.infer<typeof SessionIdleEvent>;
|
|
34
|
+
/** session.error event */
|
|
35
|
+
declare const SessionErrorEvent: z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"session.error">;
|
|
37
|
+
properties: z.ZodObject<{
|
|
38
|
+
sessionID: z.ZodOptional<z.ZodString>;
|
|
39
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
message: z.ZodOptional<z.ZodString>;
|
|
43
|
+
providerID: z.ZodOptional<z.ZodString>;
|
|
44
|
+
statusCode: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
isRetryable: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
}, z.core.$loose>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type SessionErrorEvent = z.infer<typeof SessionErrorEvent>;
|
|
51
|
+
/** Tool part */
|
|
52
|
+
declare const ToolPart: z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
sessionID: z.ZodString;
|
|
55
|
+
messageID: z.ZodString;
|
|
56
|
+
type: z.ZodLiteral<"tool">;
|
|
57
|
+
callID: z.ZodString;
|
|
58
|
+
tool: z.ZodString;
|
|
59
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
60
|
+
status: z.ZodLiteral<"pending">;
|
|
61
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
62
|
+
raw: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
64
|
+
status: z.ZodLiteral<"running">;
|
|
65
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
|
+
title: z.ZodOptional<z.ZodString>;
|
|
67
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
68
|
+
time: z.ZodObject<{
|
|
69
|
+
start: z.ZodNumber;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
status: z.ZodLiteral<"completed">;
|
|
73
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
74
|
+
output: z.ZodString;
|
|
75
|
+
title: z.ZodString;
|
|
76
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
77
|
+
time: z.ZodObject<{
|
|
78
|
+
start: z.ZodNumber;
|
|
79
|
+
end: z.ZodNumber;
|
|
80
|
+
compacted: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
status: z.ZodLiteral<"error">;
|
|
85
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
86
|
+
error: z.ZodString;
|
|
87
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
88
|
+
time: z.ZodObject<{
|
|
89
|
+
start: z.ZodNumber;
|
|
90
|
+
end: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
}, z.core.$strip>], "status">;
|
|
93
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
type ToolPart = z.infer<typeof ToolPart>;
|
|
96
|
+
/** Step-finish part with cost and token data */
|
|
97
|
+
declare const StepFinishPart: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
sessionID: z.ZodString;
|
|
100
|
+
messageID: z.ZodString;
|
|
101
|
+
type: z.ZodLiteral<"step-finish">;
|
|
102
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
103
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
104
|
+
cost: z.ZodNumber;
|
|
105
|
+
tokens: z.ZodObject<{
|
|
106
|
+
input: z.ZodNumber;
|
|
107
|
+
output: z.ZodNumber;
|
|
108
|
+
reasoning: z.ZodNumber;
|
|
109
|
+
cache: z.ZodObject<{
|
|
110
|
+
read: z.ZodNumber;
|
|
111
|
+
write: z.ZodNumber;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
type StepFinishPart = z.infer<typeof StepFinishPart>;
|
|
116
|
+
/** All part types */
|
|
117
|
+
declare const Part: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
sessionID: z.ZodString;
|
|
120
|
+
messageID: z.ZodString;
|
|
121
|
+
type: z.ZodLiteral<"text">;
|
|
122
|
+
text: z.ZodString;
|
|
123
|
+
synthetic: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
ignored: z.ZodOptional<z.ZodBoolean>;
|
|
125
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
start: z.ZodNumber;
|
|
127
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
130
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
131
|
+
id: z.ZodString;
|
|
132
|
+
sessionID: z.ZodString;
|
|
133
|
+
messageID: z.ZodString;
|
|
134
|
+
type: z.ZodLiteral<"reasoning">;
|
|
135
|
+
text: z.ZodString;
|
|
136
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
137
|
+
start: z.ZodNumber;
|
|
138
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
141
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
+
id: z.ZodString;
|
|
143
|
+
sessionID: z.ZodString;
|
|
144
|
+
messageID: z.ZodString;
|
|
145
|
+
type: z.ZodLiteral<"tool">;
|
|
146
|
+
callID: z.ZodString;
|
|
147
|
+
tool: z.ZodString;
|
|
148
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
|
+
status: z.ZodLiteral<"pending">;
|
|
150
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
151
|
+
raw: z.ZodOptional<z.ZodString>;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
status: z.ZodLiteral<"running">;
|
|
154
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
155
|
+
title: z.ZodOptional<z.ZodString>;
|
|
156
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
157
|
+
time: z.ZodObject<{
|
|
158
|
+
start: z.ZodNumber;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
161
|
+
status: z.ZodLiteral<"completed">;
|
|
162
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
163
|
+
output: z.ZodString;
|
|
164
|
+
title: z.ZodString;
|
|
165
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
166
|
+
time: z.ZodObject<{
|
|
167
|
+
start: z.ZodNumber;
|
|
168
|
+
end: z.ZodNumber;
|
|
169
|
+
compacted: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
172
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
173
|
+
status: z.ZodLiteral<"error">;
|
|
174
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
175
|
+
error: z.ZodString;
|
|
176
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
177
|
+
time: z.ZodObject<{
|
|
178
|
+
start: z.ZodNumber;
|
|
179
|
+
end: z.ZodNumber;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
}, z.core.$strip>], "status">;
|
|
182
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
183
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
184
|
+
id: z.ZodString;
|
|
185
|
+
sessionID: z.ZodString;
|
|
186
|
+
messageID: z.ZodString;
|
|
187
|
+
type: z.ZodLiteral<"step-start">;
|
|
188
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
sessionID: z.ZodString;
|
|
192
|
+
messageID: z.ZodString;
|
|
193
|
+
type: z.ZodLiteral<"step-finish">;
|
|
194
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
195
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
196
|
+
cost: z.ZodNumber;
|
|
197
|
+
tokens: z.ZodObject<{
|
|
198
|
+
input: z.ZodNumber;
|
|
199
|
+
output: z.ZodNumber;
|
|
200
|
+
reasoning: z.ZodNumber;
|
|
201
|
+
cache: z.ZodObject<{
|
|
202
|
+
read: z.ZodNumber;
|
|
203
|
+
write: z.ZodNumber;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
}, z.core.$strip>], "type">;
|
|
207
|
+
type Part = z.infer<typeof Part>;
|
|
208
|
+
/** message.part.updated event */
|
|
209
|
+
declare const MessagePartUpdatedEvent: z.ZodObject<{
|
|
210
|
+
type: z.ZodLiteral<"message.part.updated">;
|
|
211
|
+
properties: z.ZodObject<{
|
|
212
|
+
part: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
sessionID: z.ZodString;
|
|
215
|
+
messageID: z.ZodString;
|
|
216
|
+
type: z.ZodLiteral<"text">;
|
|
217
|
+
text: z.ZodString;
|
|
218
|
+
synthetic: z.ZodOptional<z.ZodBoolean>;
|
|
219
|
+
ignored: z.ZodOptional<z.ZodBoolean>;
|
|
220
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
221
|
+
start: z.ZodNumber;
|
|
222
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
225
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
226
|
+
id: z.ZodString;
|
|
227
|
+
sessionID: z.ZodString;
|
|
228
|
+
messageID: z.ZodString;
|
|
229
|
+
type: z.ZodLiteral<"reasoning">;
|
|
230
|
+
text: z.ZodString;
|
|
231
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
232
|
+
start: z.ZodNumber;
|
|
233
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
}, z.core.$strip>>;
|
|
235
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
236
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
237
|
+
id: z.ZodString;
|
|
238
|
+
sessionID: z.ZodString;
|
|
239
|
+
messageID: z.ZodString;
|
|
240
|
+
type: z.ZodLiteral<"tool">;
|
|
241
|
+
callID: z.ZodString;
|
|
242
|
+
tool: z.ZodString;
|
|
243
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
244
|
+
status: z.ZodLiteral<"pending">;
|
|
245
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
246
|
+
raw: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
248
|
+
status: z.ZodLiteral<"running">;
|
|
249
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
250
|
+
title: z.ZodOptional<z.ZodString>;
|
|
251
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
252
|
+
time: z.ZodObject<{
|
|
253
|
+
start: z.ZodNumber;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
256
|
+
status: z.ZodLiteral<"completed">;
|
|
257
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
258
|
+
output: z.ZodString;
|
|
259
|
+
title: z.ZodString;
|
|
260
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
261
|
+
time: z.ZodObject<{
|
|
262
|
+
start: z.ZodNumber;
|
|
263
|
+
end: z.ZodNumber;
|
|
264
|
+
compacted: z.ZodOptional<z.ZodNumber>;
|
|
265
|
+
}, z.core.$strip>;
|
|
266
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
267
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
268
|
+
status: z.ZodLiteral<"error">;
|
|
269
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
270
|
+
error: z.ZodString;
|
|
271
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
272
|
+
time: z.ZodObject<{
|
|
273
|
+
start: z.ZodNumber;
|
|
274
|
+
end: z.ZodNumber;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
}, z.core.$strip>], "status">;
|
|
277
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
278
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
279
|
+
id: z.ZodString;
|
|
280
|
+
sessionID: z.ZodString;
|
|
281
|
+
messageID: z.ZodString;
|
|
282
|
+
type: z.ZodLiteral<"step-start">;
|
|
283
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
284
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
285
|
+
id: z.ZodString;
|
|
286
|
+
sessionID: z.ZodString;
|
|
287
|
+
messageID: z.ZodString;
|
|
288
|
+
type: z.ZodLiteral<"step-finish">;
|
|
289
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
290
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
291
|
+
cost: z.ZodNumber;
|
|
292
|
+
tokens: z.ZodObject<{
|
|
293
|
+
input: z.ZodNumber;
|
|
294
|
+
output: z.ZodNumber;
|
|
295
|
+
reasoning: z.ZodNumber;
|
|
296
|
+
cache: z.ZodObject<{
|
|
297
|
+
read: z.ZodNumber;
|
|
298
|
+
write: z.ZodNumber;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
}, z.core.$strip>], "type">;
|
|
302
|
+
delta: z.ZodOptional<z.ZodString>;
|
|
303
|
+
}, z.core.$strip>;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
type MessagePartUpdatedEvent = z.infer<typeof MessagePartUpdatedEvent>;
|
|
306
|
+
/** permission.updated event - requires user approval */
|
|
307
|
+
declare const PermissionUpdatedEvent: z.ZodObject<{
|
|
308
|
+
type: z.ZodLiteral<"permission.updated">;
|
|
309
|
+
properties: z.ZodObject<{
|
|
310
|
+
id: z.ZodString;
|
|
311
|
+
sessionID: z.ZodString;
|
|
312
|
+
messageID: z.ZodOptional<z.ZodString>;
|
|
313
|
+
title: z.ZodString;
|
|
314
|
+
description: z.ZodOptional<z.ZodString>;
|
|
315
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
316
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
317
|
+
time: z.ZodObject<{
|
|
318
|
+
created: z.ZodNumber;
|
|
319
|
+
responded: z.ZodOptional<z.ZodNumber>;
|
|
320
|
+
}, z.core.$strip>;
|
|
321
|
+
}, z.core.$strip>;
|
|
322
|
+
}, z.core.$strip>;
|
|
323
|
+
type PermissionUpdatedEvent = z.infer<typeof PermissionUpdatedEvent>;
|
|
324
|
+
/** All SSE event types we handle */
|
|
325
|
+
declare const OpenCodeSSEEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
326
|
+
type: z.ZodLiteral<"server.connected">;
|
|
327
|
+
properties: z.ZodObject<{}, z.core.$strip>;
|
|
328
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
329
|
+
type: z.ZodLiteral<"server.heartbeat">;
|
|
330
|
+
properties: z.ZodObject<{}, z.core.$strip>;
|
|
331
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
332
|
+
type: z.ZodLiteral<"session.created">;
|
|
333
|
+
properties: z.ZodObject<{
|
|
334
|
+
info: z.ZodObject<{
|
|
335
|
+
id: z.ZodString;
|
|
336
|
+
parentID: z.ZodOptional<z.ZodString>;
|
|
337
|
+
title: z.ZodOptional<z.ZodString>;
|
|
338
|
+
projectID: z.ZodOptional<z.ZodString>;
|
|
339
|
+
share: z.ZodOptional<z.ZodString>;
|
|
340
|
+
updated: z.ZodNumber;
|
|
341
|
+
created: z.ZodNumber;
|
|
342
|
+
}, z.core.$strip>;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
345
|
+
type: z.ZodLiteral<"session.updated">;
|
|
346
|
+
properties: z.ZodObject<{
|
|
347
|
+
info: z.ZodObject<{
|
|
348
|
+
id: z.ZodString;
|
|
349
|
+
parentID: z.ZodOptional<z.ZodString>;
|
|
350
|
+
title: z.ZodOptional<z.ZodString>;
|
|
351
|
+
projectID: z.ZodOptional<z.ZodString>;
|
|
352
|
+
share: z.ZodOptional<z.ZodString>;
|
|
353
|
+
updated: z.ZodNumber;
|
|
354
|
+
created: z.ZodNumber;
|
|
355
|
+
}, z.core.$strip>;
|
|
356
|
+
}, z.core.$strip>;
|
|
357
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
358
|
+
type: z.ZodLiteral<"session.idle">;
|
|
359
|
+
properties: z.ZodObject<{
|
|
360
|
+
sessionID: z.ZodString;
|
|
361
|
+
}, z.core.$strip>;
|
|
362
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
363
|
+
type: z.ZodLiteral<"session.status">;
|
|
364
|
+
properties: z.ZodObject<{
|
|
365
|
+
sessionID: z.ZodString;
|
|
366
|
+
status: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
367
|
+
type: z.ZodLiteral<"idle">;
|
|
368
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
369
|
+
type: z.ZodLiteral<"retry">;
|
|
370
|
+
attempt: z.ZodNumber;
|
|
371
|
+
message: z.ZodString;
|
|
372
|
+
next: z.ZodNumber;
|
|
373
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
374
|
+
type: z.ZodLiteral<"busy">;
|
|
375
|
+
}, z.core.$strip>], "type">;
|
|
376
|
+
}, z.core.$strip>;
|
|
377
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
378
|
+
type: z.ZodLiteral<"session.error">;
|
|
379
|
+
properties: z.ZodObject<{
|
|
380
|
+
sessionID: z.ZodOptional<z.ZodString>;
|
|
381
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
382
|
+
name: z.ZodString;
|
|
383
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
384
|
+
message: z.ZodOptional<z.ZodString>;
|
|
385
|
+
providerID: z.ZodOptional<z.ZodString>;
|
|
386
|
+
statusCode: z.ZodOptional<z.ZodNumber>;
|
|
387
|
+
isRetryable: z.ZodOptional<z.ZodBoolean>;
|
|
388
|
+
}, z.core.$loose>>;
|
|
389
|
+
}, z.core.$strip>>;
|
|
390
|
+
}, z.core.$strip>;
|
|
391
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
392
|
+
type: z.ZodLiteral<"message.part.updated">;
|
|
393
|
+
properties: z.ZodObject<{
|
|
394
|
+
part: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
395
|
+
id: z.ZodString;
|
|
396
|
+
sessionID: z.ZodString;
|
|
397
|
+
messageID: z.ZodString;
|
|
398
|
+
type: z.ZodLiteral<"text">;
|
|
399
|
+
text: z.ZodString;
|
|
400
|
+
synthetic: z.ZodOptional<z.ZodBoolean>;
|
|
401
|
+
ignored: z.ZodOptional<z.ZodBoolean>;
|
|
402
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
403
|
+
start: z.ZodNumber;
|
|
404
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
405
|
+
}, z.core.$strip>>;
|
|
406
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
407
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
408
|
+
id: z.ZodString;
|
|
409
|
+
sessionID: z.ZodString;
|
|
410
|
+
messageID: z.ZodString;
|
|
411
|
+
type: z.ZodLiteral<"reasoning">;
|
|
412
|
+
text: z.ZodString;
|
|
413
|
+
time: z.ZodOptional<z.ZodObject<{
|
|
414
|
+
start: z.ZodNumber;
|
|
415
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
416
|
+
}, z.core.$strip>>;
|
|
417
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
418
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
419
|
+
id: z.ZodString;
|
|
420
|
+
sessionID: z.ZodString;
|
|
421
|
+
messageID: z.ZodString;
|
|
422
|
+
type: z.ZodLiteral<"tool">;
|
|
423
|
+
callID: z.ZodString;
|
|
424
|
+
tool: z.ZodString;
|
|
425
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
426
|
+
status: z.ZodLiteral<"pending">;
|
|
427
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
428
|
+
raw: z.ZodOptional<z.ZodString>;
|
|
429
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
430
|
+
status: z.ZodLiteral<"running">;
|
|
431
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
432
|
+
title: z.ZodOptional<z.ZodString>;
|
|
433
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
434
|
+
time: z.ZodObject<{
|
|
435
|
+
start: z.ZodNumber;
|
|
436
|
+
}, z.core.$strip>;
|
|
437
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
438
|
+
status: z.ZodLiteral<"completed">;
|
|
439
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
440
|
+
output: z.ZodString;
|
|
441
|
+
title: z.ZodString;
|
|
442
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
443
|
+
time: z.ZodObject<{
|
|
444
|
+
start: z.ZodNumber;
|
|
445
|
+
end: z.ZodNumber;
|
|
446
|
+
compacted: z.ZodOptional<z.ZodNumber>;
|
|
447
|
+
}, z.core.$strip>;
|
|
448
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
449
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
450
|
+
status: z.ZodLiteral<"error">;
|
|
451
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
452
|
+
error: z.ZodString;
|
|
453
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
454
|
+
time: z.ZodObject<{
|
|
455
|
+
start: z.ZodNumber;
|
|
456
|
+
end: z.ZodNumber;
|
|
457
|
+
}, z.core.$strip>;
|
|
458
|
+
}, z.core.$strip>], "status">;
|
|
459
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
460
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
461
|
+
id: z.ZodString;
|
|
462
|
+
sessionID: z.ZodString;
|
|
463
|
+
messageID: z.ZodString;
|
|
464
|
+
type: z.ZodLiteral<"step-start">;
|
|
465
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
466
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
467
|
+
id: z.ZodString;
|
|
468
|
+
sessionID: z.ZodString;
|
|
469
|
+
messageID: z.ZodString;
|
|
470
|
+
type: z.ZodLiteral<"step-finish">;
|
|
471
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
472
|
+
snapshot: z.ZodOptional<z.ZodString>;
|
|
473
|
+
cost: z.ZodNumber;
|
|
474
|
+
tokens: z.ZodObject<{
|
|
475
|
+
input: z.ZodNumber;
|
|
476
|
+
output: z.ZodNumber;
|
|
477
|
+
reasoning: z.ZodNumber;
|
|
478
|
+
cache: z.ZodObject<{
|
|
479
|
+
read: z.ZodNumber;
|
|
480
|
+
write: z.ZodNumber;
|
|
481
|
+
}, z.core.$strip>;
|
|
482
|
+
}, z.core.$strip>;
|
|
483
|
+
}, z.core.$strip>], "type">;
|
|
484
|
+
delta: z.ZodOptional<z.ZodString>;
|
|
485
|
+
}, z.core.$strip>;
|
|
486
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
487
|
+
type: z.ZodLiteral<"permission.updated">;
|
|
488
|
+
properties: z.ZodObject<{
|
|
489
|
+
id: z.ZodString;
|
|
490
|
+
sessionID: z.ZodString;
|
|
491
|
+
messageID: z.ZodOptional<z.ZodString>;
|
|
492
|
+
title: z.ZodString;
|
|
493
|
+
description: z.ZodOptional<z.ZodString>;
|
|
494
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
495
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
496
|
+
time: z.ZodObject<{
|
|
497
|
+
created: z.ZodNumber;
|
|
498
|
+
responded: z.ZodOptional<z.ZodNumber>;
|
|
499
|
+
}, z.core.$strip>;
|
|
500
|
+
}, z.core.$strip>;
|
|
501
|
+
}, z.core.$strip>], "type">;
|
|
502
|
+
type OpenCodeSSEEvent = z.infer<typeof OpenCodeSSEEvent>;
|
|
503
|
+
declare function isSessionCreatedEvent(event: OpenCodeSSEEvent): event is SessionCreatedEvent;
|
|
504
|
+
declare function isSessionIdleEvent(event: OpenCodeSSEEvent): event is SessionIdleEvent;
|
|
505
|
+
declare function isSessionErrorEvent(event: OpenCodeSSEEvent): event is SessionErrorEvent;
|
|
506
|
+
declare function isMessagePartUpdatedEvent(event: OpenCodeSSEEvent): event is MessagePartUpdatedEvent;
|
|
507
|
+
declare function isPermissionUpdatedEvent(event: OpenCodeSSEEvent): event is PermissionUpdatedEvent;
|
|
508
|
+
export { OpenCodeSSEEvent, isMessagePartUpdatedEvent, isPermissionUpdatedEvent, isSessionCreatedEvent, isSessionErrorEvent, isSessionIdleEvent, };
|
|
509
|
+
export type { MessagePartUpdatedEvent, Part, StepFinishPart, ToolPart };
|