@jrkropp/codex-js 0.1.2 → 0.1.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/CHANGELOG.md +4 -0
- package/dist/ClientNotification-B6-FhXQf.d.ts +5 -0
- package/dist/DynamicToolCallResponse-82DFjES2.d.ts +8 -0
- package/dist/DynamicToolSpec-CfnhqAYK.d.ts +29 -0
- package/dist/PermissionsRequestApprovalResponse-DxzPPDRb.d.ts +55 -0
- package/dist/ProviderStatusBanner-BlP6lzwE.d.ts +441 -0
- package/dist/ServerRequest-B5cKVJjr.d.ts +2181 -0
- package/dist/{session-DPhHN7RZ.d.ts → ThreadResumeResponse-DvmE1juU.d.ts} +3 -306
- package/dist/ToolRequestUserInputQuestion-CeZa5X1J.d.ts +23 -0
- package/dist/ToolRequestUserInputResponse-zcPLwbiK.d.ts +17 -0
- package/dist/TurnSteerResponse-0kBCfplh.d.ts +209 -0
- package/dist/WebSearchToolConfig-D3ep0625.d.ts +18 -0
- package/dist/chat-runtime-B6azJyKo.d.ts +381 -0
- package/dist/chunk-2DZRMCI2.js +1258 -0
- package/dist/chunk-2DZRMCI2.js.map +1 -0
- package/dist/chunk-4DPLJPB5.js +396 -0
- package/dist/chunk-4DPLJPB5.js.map +1 -0
- package/dist/chunk-5JMJ6OI5.js +3 -0
- package/dist/chunk-5JMJ6OI5.js.map +1 -0
- package/dist/chunk-6ZMJ34KE.js +1153 -0
- package/dist/chunk-6ZMJ34KE.js.map +1 -0
- package/dist/chunk-CGBS37IU.js +128 -0
- package/dist/chunk-CGBS37IU.js.map +1 -0
- package/dist/chunk-DCMKA2A6.js +18 -0
- package/dist/chunk-DCMKA2A6.js.map +1 -0
- package/dist/chunk-DYLHN3HG.js +937 -0
- package/dist/chunk-DYLHN3HG.js.map +1 -0
- package/dist/chunk-ILXA6HLX.js +1973 -0
- package/dist/chunk-ILXA6HLX.js.map +1 -0
- package/dist/{chunk-SVK6PLGO.js → chunk-LWQNX4LI.js} +12009 -18768
- package/dist/chunk-LWQNX4LI.js.map +1 -0
- package/dist/{chunk-JLDH4U5L.js → chunk-NCI4MAWZ.js} +317 -1967
- package/dist/chunk-NCI4MAWZ.js.map +1 -0
- package/dist/chunk-O44XP7LH.js +214 -0
- package/dist/chunk-O44XP7LH.js.map +1 -0
- package/dist/chunk-PST3ZWX2.js +555 -0
- package/dist/chunk-PST3ZWX2.js.map +1 -0
- package/dist/chunk-SYPHCDRD.js +1133 -0
- package/dist/chunk-SYPHCDRD.js.map +1 -0
- package/dist/chunk-V4BMZWBM.js +2401 -0
- package/dist/chunk-V4BMZWBM.js.map +1 -0
- package/dist/chunk-YHVCFD2D.js +117 -0
- package/dist/chunk-YHVCFD2D.js.map +1 -0
- package/dist/chunk-Z63UPBS3.js +152 -0
- package/dist/chunk-Z63UPBS3.js.map +1 -0
- package/dist/client/index.d.ts +16 -4
- package/dist/client/index.js +13 -1
- package/dist/codex-rs/app-server/index.d.ts +161 -0
- package/dist/codex-rs/app-server/index.js +13 -0
- package/dist/codex-rs/app-server/index.js.map +1 -0
- package/dist/codex-rs/app-server-protocol/index.d.ts +1722 -0
- package/dist/codex-rs/app-server-protocol/index.js +6 -0
- package/dist/codex-rs/app-server-protocol/index.js.map +1 -0
- package/dist/codex-rs/app-server-protocol/protocol.d.ts +19 -0
- package/dist/codex-rs/app-server-protocol/protocol.js +4 -0
- package/dist/codex-rs/app-server-protocol/protocol.js.map +1 -0
- package/dist/codex-rs/codex-api/index.d.ts +104 -0
- package/dist/codex-rs/codex-api/index.js +11 -0
- package/dist/codex-rs/codex-api/index.js.map +1 -0
- package/dist/codex-rs/config/index.d.ts +88 -0
- package/dist/codex-rs/config/index.js +4 -0
- package/dist/codex-rs/config/index.js.map +1 -0
- package/dist/codex-rs/core/config/index.d.ts +61 -0
- package/dist/codex-rs/core/config/index.js +5 -0
- package/dist/codex-rs/core/config/index.js.map +1 -0
- package/dist/codex-rs/core/index.d.ts +1393 -0
- package/dist/codex-rs/core/index.js +11 -0
- package/dist/codex-rs/core/index.js.map +1 -0
- package/dist/codex-rs/model-provider/index.d.ts +2 -0
- package/dist/codex-rs/model-provider/index.js +4 -0
- package/dist/codex-rs/model-provider/index.js.map +1 -0
- package/dist/codex-rs/models-manager/index.d.ts +2 -0
- package/dist/codex-rs/models-manager/index.js +4 -0
- package/dist/codex-rs/models-manager/index.js.map +1 -0
- package/dist/codex-rs/parity.d.ts +26 -0
- package/dist/codex-rs/parity.js +3 -0
- package/dist/codex-rs/parity.js.map +1 -0
- package/dist/codex-rs/thread-store/index.d.ts +5 -0
- package/dist/codex-rs/thread-store/index.js +4 -0
- package/dist/codex-rs/thread-store/index.js.map +1 -0
- package/dist/codex-rs/unsupported.d.ts +15 -0
- package/dist/codex-rs/unsupported.js +22 -0
- package/dist/codex-rs/unsupported.js.map +1 -0
- package/dist/codex-rs/utils/output-truncation.d.ts +21 -0
- package/dist/codex-rs/utils/output-truncation.js +4 -0
- package/dist/codex-rs/utils/output-truncation.js.map +1 -0
- package/dist/codex-rs/utils/string.d.ts +7 -0
- package/dist/codex-rs/utils/string.js +3 -0
- package/dist/codex-rs/utils/string.js.map +1 -0
- package/dist/common-CTyph5x8.d.ts +40 -0
- package/dist/event-mapping-CbISdQ1D.d.ts +43 -0
- package/dist/history-CfM-4V7b.d.ts +1654 -0
- package/dist/index-77U_Oc-a.d.ts +63 -0
- package/dist/index-CoDZosq0.d.ts +261 -0
- package/dist/index.d.ts +18 -7
- package/dist/index.js +16 -2
- package/dist/lib-nXlaKiS-.d.ts +48 -0
- package/dist/live-thread-BMvlflzM.d.ts +30 -0
- package/dist/merge-B_AWVmnI.d.ts +24 -0
- package/dist/mod-DYVLSWO4.d.ts +91 -0
- package/dist/plan-mode-Cv6KWb_S.d.ts +14 -0
- package/dist/proposed-plan-DpN1ma0Y.d.ts +53 -0
- package/dist/protocol-mpBcYHrm.d.ts +1655 -0
- package/dist/react/index.d.ts +20 -52
- package/dist/react/index.js +16 -2
- package/dist/{remote-_6TDvg-g.d.ts → remote-ClZbq9KN.d.ts} +3 -1
- package/dist/rendered-thread-AOxw3V5b.d.ts +29 -0
- package/dist/responses_websocket-BhxSgCzK.d.ts +183 -0
- package/dist/runtime-Cm6ml53h.d.ts +528 -0
- package/dist/server/index.d.ts +29 -2416
- package/dist/server/index.js +13 -1
- package/dist/session-BRYzi8OT.d.ts +46 -0
- package/dist/shadcn/index.d.ts +1 -1
- package/dist/{sidebar-DT2XoitN.d.ts → sidebar-DMMij22z.d.ts} +1 -1
- package/dist/spec_plan_types-CmsJ-Tfn.d.ts +260 -0
- package/dist/{store-GYldc9EJ.d.ts → store-AGRxhgQ3.d.ts} +2 -1
- package/dist/t3code/apps/web/components/chat.d.ts +508 -0
- package/dist/t3code/apps/web/components/chat.js +12 -0
- package/dist/t3code/apps/web/components/chat.js.map +1 -0
- package/dist/t3code/apps/web/index.d.ts +12 -0
- package/dist/t3code/apps/web/index.js +13 -0
- package/dist/t3code/apps/web/index.js.map +1 -0
- package/dist/testing/index.d.ts +9 -91
- package/dist/testing/index.js +13 -1
- package/dist/thread-history-builder-zW0zeqcS.d.ts +58 -0
- package/dist/thread_event_store-C0zYzukG.d.ts +77 -0
- package/dist/types-BTeabLYr.d.ts +126 -0
- package/package.json +65 -1
- package/dist/chat-runtime-D7wu_KbX.d.ts +0 -747
- package/dist/chunk-JLDH4U5L.js.map +0 -1
- package/dist/chunk-SVK6PLGO.js.map +0 -1
- package/dist/index-CB9la6xE.d.ts +0 -112
- package/dist/thread_event_store-B9CoQUIA.d.ts +0 -3868
|
@@ -0,0 +1,1258 @@
|
|
|
1
|
+
import { renderThreadFromHistory } from './chunk-DYLHN3HG.js';
|
|
2
|
+
|
|
3
|
+
// src/upstream/codex-rs/app-server-protocol/src/protocol/event-mapping.ts
|
|
4
|
+
function eventMsgToAppServerEvents(msg, context) {
|
|
5
|
+
if (msg.type === "token_count") {
|
|
6
|
+
const events = [];
|
|
7
|
+
const turnId = turnIdFromEventMsg(msg, context);
|
|
8
|
+
if (msg.info) {
|
|
9
|
+
events.push(
|
|
10
|
+
turnId ? notification({
|
|
11
|
+
method: "thread/tokenUsage/updated",
|
|
12
|
+
params: {
|
|
13
|
+
threadId: context.threadId,
|
|
14
|
+
turnId,
|
|
15
|
+
tokenUsage: threadTokenUsageFromTokenUsageInfo(msg.info)
|
|
16
|
+
}
|
|
17
|
+
}) : missingTurnIdWarning(context.threadId, msg.type)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
if (msg.rate_limits) {
|
|
21
|
+
events.push(notification({
|
|
22
|
+
method: "account/rateLimits/updated",
|
|
23
|
+
params: {
|
|
24
|
+
rateLimits: appServerRateLimitSnapshot(msg.rate_limits)
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
return events;
|
|
29
|
+
}
|
|
30
|
+
if (msg.type === "dynamic_tool_call_request") {
|
|
31
|
+
const threadId = context.threadId;
|
|
32
|
+
return [
|
|
33
|
+
notification({
|
|
34
|
+
method: "item/started",
|
|
35
|
+
params: {
|
|
36
|
+
threadId,
|
|
37
|
+
turnId: msg.turn_id,
|
|
38
|
+
startedAtMs: msg.started_at_ms ?? Date.now(),
|
|
39
|
+
item: {
|
|
40
|
+
type: "dynamicToolCall",
|
|
41
|
+
id: msg.call_id,
|
|
42
|
+
namespace: msg.namespace ?? null,
|
|
43
|
+
tool: msg.tool,
|
|
44
|
+
arguments: msg.arguments,
|
|
45
|
+
status: "inProgress",
|
|
46
|
+
contentItems: null,
|
|
47
|
+
success: null,
|
|
48
|
+
durationMs: null
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
request(
|
|
53
|
+
{
|
|
54
|
+
method: "item/tool/call",
|
|
55
|
+
params: {
|
|
56
|
+
threadId,
|
|
57
|
+
turnId: msg.turn_id,
|
|
58
|
+
callId: msg.call_id,
|
|
59
|
+
namespace: msg.namespace ?? null,
|
|
60
|
+
tool: msg.tool,
|
|
61
|
+
arguments: msg.arguments
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{ type: "dynamic_tool", callId: msg.call_id }
|
|
65
|
+
)
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
if (msg.type === "agent_message") {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
return [eventMsgToAppServerEvent(msg, context)];
|
|
72
|
+
}
|
|
73
|
+
function eventMsgToAppServerEvent(msg, context) {
|
|
74
|
+
const threadId = context.threadId;
|
|
75
|
+
const turnId = turnIdFromEventMsg(msg, context);
|
|
76
|
+
switch (msg.type) {
|
|
77
|
+
case "turn_started":
|
|
78
|
+
return notification({
|
|
79
|
+
method: "turn/started",
|
|
80
|
+
params: {
|
|
81
|
+
threadId,
|
|
82
|
+
turn: {
|
|
83
|
+
...context.activeTurn ?? {},
|
|
84
|
+
id: msg.turn_id,
|
|
85
|
+
items: [],
|
|
86
|
+
itemsView: "notLoaded",
|
|
87
|
+
status: "inProgress",
|
|
88
|
+
error: null,
|
|
89
|
+
startedAt: epochSeconds(msg.started_at),
|
|
90
|
+
completedAt: null,
|
|
91
|
+
durationMs: null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
case "turn_complete":
|
|
96
|
+
return notification({
|
|
97
|
+
method: "turn/completed",
|
|
98
|
+
params: {
|
|
99
|
+
threadId,
|
|
100
|
+
turn: completedTurnFromEvent({
|
|
101
|
+
completedAt: epochSeconds(msg.completed_at),
|
|
102
|
+
durationMs: msg.duration_ms ?? null,
|
|
103
|
+
fallbackTurnId: msg.turn_id,
|
|
104
|
+
status: "completed",
|
|
105
|
+
terminalTurn: context.terminalTurn
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
case "turn_aborted":
|
|
110
|
+
return notification({
|
|
111
|
+
method: "turn/completed",
|
|
112
|
+
params: {
|
|
113
|
+
threadId,
|
|
114
|
+
turn: completedTurnFromEvent({
|
|
115
|
+
completedAt: epochSeconds(msg.completed_at ?? msg.aborted_at),
|
|
116
|
+
durationMs: msg.duration_ms ?? null,
|
|
117
|
+
fallbackTurnId: msg.turn_id,
|
|
118
|
+
status: "interrupted",
|
|
119
|
+
terminalTurn: context.terminalTurn
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
case "agent_message_content_delta":
|
|
124
|
+
return notification({
|
|
125
|
+
method: "item/agentMessage/delta",
|
|
126
|
+
params: {
|
|
127
|
+
threadId: msg.thread_id,
|
|
128
|
+
turnId: msg.turn_id,
|
|
129
|
+
itemId: msg.item_id,
|
|
130
|
+
delta: msg.delta
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
case "plan_delta":
|
|
134
|
+
return notification({
|
|
135
|
+
method: "item/plan/delta",
|
|
136
|
+
params: {
|
|
137
|
+
threadId: msg.thread_id,
|
|
138
|
+
turnId: msg.turn_id,
|
|
139
|
+
itemId: msg.item_id,
|
|
140
|
+
delta: msg.delta
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
case "plan_update":
|
|
144
|
+
if (!turnId) {
|
|
145
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
146
|
+
}
|
|
147
|
+
return notification({
|
|
148
|
+
method: "turn/plan/updated",
|
|
149
|
+
params: {
|
|
150
|
+
threadId,
|
|
151
|
+
turnId,
|
|
152
|
+
explanation: msg.explanation ?? null,
|
|
153
|
+
plan: msg.plan.map((step) => ({
|
|
154
|
+
step: step.step,
|
|
155
|
+
status: step.status === "in_progress" ? "inProgress" : step.status
|
|
156
|
+
}))
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
case "item_started": {
|
|
160
|
+
if (!turnId) {
|
|
161
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
162
|
+
}
|
|
163
|
+
const item = coreTurnItemToThreadItem(msg.item);
|
|
164
|
+
return item ? notification({
|
|
165
|
+
method: "item/started",
|
|
166
|
+
params: {
|
|
167
|
+
threadId,
|
|
168
|
+
turnId: msg.turn_id ?? turnId,
|
|
169
|
+
item,
|
|
170
|
+
startedAtMs: Date.now()
|
|
171
|
+
}
|
|
172
|
+
}) : warning(threadId, `Unmapped Codex item_started: ${msg.item.type}`);
|
|
173
|
+
}
|
|
174
|
+
case "item_completed": {
|
|
175
|
+
if (!turnId) {
|
|
176
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
177
|
+
}
|
|
178
|
+
const item = coreTurnItemToThreadItem(msg.item);
|
|
179
|
+
return item ? notification({
|
|
180
|
+
method: "item/completed",
|
|
181
|
+
params: {
|
|
182
|
+
threadId,
|
|
183
|
+
turnId: msg.turn_id ?? turnId,
|
|
184
|
+
item,
|
|
185
|
+
completedAtMs: Date.now()
|
|
186
|
+
}
|
|
187
|
+
}) : warning(threadId, `Unmapped Codex item_completed: ${msg.item.type}`);
|
|
188
|
+
}
|
|
189
|
+
case "user_message":
|
|
190
|
+
if (!turnId) {
|
|
191
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
192
|
+
}
|
|
193
|
+
return notification({
|
|
194
|
+
method: "item/completed",
|
|
195
|
+
params: {
|
|
196
|
+
threadId,
|
|
197
|
+
turnId,
|
|
198
|
+
completedAtMs: Date.now(),
|
|
199
|
+
item: {
|
|
200
|
+
type: "userMessage",
|
|
201
|
+
id: `user-${turnId}`,
|
|
202
|
+
content: userInputsFromUserMessage(msg)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
case "raw_response_item":
|
|
207
|
+
if (!turnId) {
|
|
208
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
209
|
+
}
|
|
210
|
+
return notification({
|
|
211
|
+
method: "rawResponseItem/completed",
|
|
212
|
+
params: {
|
|
213
|
+
threadId,
|
|
214
|
+
turnId,
|
|
215
|
+
item: msg.item
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
case "request_user_input":
|
|
219
|
+
return request(
|
|
220
|
+
{
|
|
221
|
+
method: "item/tool/requestUserInput",
|
|
222
|
+
params: {
|
|
223
|
+
threadId,
|
|
224
|
+
turnId: msg.turn_id,
|
|
225
|
+
itemId: msg.call_id,
|
|
226
|
+
questions: msg.questions.map((question) => ({
|
|
227
|
+
id: question.id,
|
|
228
|
+
header: question.header,
|
|
229
|
+
question: question.question,
|
|
230
|
+
isOther: question.isOther,
|
|
231
|
+
isSecret: question.isSecret,
|
|
232
|
+
options: question.options.map((option) => ({ ...option }))
|
|
233
|
+
}))
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{ type: "user_input", responseId: msg.turn_id }
|
|
237
|
+
);
|
|
238
|
+
case "request_permissions":
|
|
239
|
+
return request(
|
|
240
|
+
{
|
|
241
|
+
method: "item/permissions/requestApproval",
|
|
242
|
+
params: {
|
|
243
|
+
threadId,
|
|
244
|
+
turnId: msg.turn_id,
|
|
245
|
+
itemId: msg.call_id,
|
|
246
|
+
cwd: msg.cwd ?? "",
|
|
247
|
+
reason: msg.reason ?? null,
|
|
248
|
+
permissions: msg.permissions
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{ type: "request_permissions", callId: msg.call_id }
|
|
252
|
+
);
|
|
253
|
+
case "command_approval_request":
|
|
254
|
+
if (!turnId) {
|
|
255
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
256
|
+
}
|
|
257
|
+
return request({
|
|
258
|
+
method: "item/commandExecution/requestApproval",
|
|
259
|
+
params: {
|
|
260
|
+
threadId,
|
|
261
|
+
turnId,
|
|
262
|
+
itemId: msg.call_id,
|
|
263
|
+
approvalId: null,
|
|
264
|
+
reason: msg.reason ?? null,
|
|
265
|
+
command: msg.command.join(" "),
|
|
266
|
+
cwd: msg.cwd,
|
|
267
|
+
commandActions: [],
|
|
268
|
+
networkApprovalContext: null,
|
|
269
|
+
proposedExecpolicyAmendment: null,
|
|
270
|
+
proposedNetworkPolicyAmendments: null
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
case "file_change_approval_request":
|
|
274
|
+
if (!turnId) {
|
|
275
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
276
|
+
}
|
|
277
|
+
return request({
|
|
278
|
+
method: "item/fileChange/requestApproval",
|
|
279
|
+
params: {
|
|
280
|
+
threadId,
|
|
281
|
+
turnId,
|
|
282
|
+
itemId: msg.call_id,
|
|
283
|
+
reason: msg.reason ?? null,
|
|
284
|
+
grantRoot: null
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
case "dynamic_tool_call_request":
|
|
288
|
+
return request(
|
|
289
|
+
{
|
|
290
|
+
method: "item/tool/call",
|
|
291
|
+
params: {
|
|
292
|
+
threadId,
|
|
293
|
+
turnId: msg.turn_id,
|
|
294
|
+
callId: msg.call_id,
|
|
295
|
+
namespace: msg.namespace ?? null,
|
|
296
|
+
tool: msg.tool,
|
|
297
|
+
arguments: msg.arguments
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
{ type: "dynamic_tool", callId: msg.call_id }
|
|
301
|
+
);
|
|
302
|
+
case "dynamic_tool_call_response":
|
|
303
|
+
return notification({
|
|
304
|
+
method: "item/completed",
|
|
305
|
+
params: {
|
|
306
|
+
threadId,
|
|
307
|
+
turnId: msg.turn_id,
|
|
308
|
+
completedAtMs: msg.completed_at_ms ?? Date.now(),
|
|
309
|
+
item: {
|
|
310
|
+
type: "dynamicToolCall",
|
|
311
|
+
id: msg.call_id,
|
|
312
|
+
namespace: msg.namespace ?? null,
|
|
313
|
+
tool: msg.tool,
|
|
314
|
+
arguments: msg.arguments,
|
|
315
|
+
status: msg.success ? "completed" : "failed",
|
|
316
|
+
contentItems: msg.content_items.map(
|
|
317
|
+
(item) => item.type === "inputText" ? { type: "inputText", text: item.text } : { type: "inputImage", imageUrl: item.imageUrl }
|
|
318
|
+
),
|
|
319
|
+
success: msg.success,
|
|
320
|
+
durationMs: durationMsFromString(msg.duration)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
case "mcp_server_elicitation_request":
|
|
325
|
+
return request(
|
|
326
|
+
{
|
|
327
|
+
method: "mcpServer/elicitation/request",
|
|
328
|
+
params: {
|
|
329
|
+
threadId,
|
|
330
|
+
turnId: msg.turn_id,
|
|
331
|
+
serverName: msg.server_name,
|
|
332
|
+
...msg.request.type === "url" ? {
|
|
333
|
+
mode: "url",
|
|
334
|
+
message: msg.request.message,
|
|
335
|
+
_meta: msg.request.meta ?? null,
|
|
336
|
+
url: msg.request.url,
|
|
337
|
+
elicitationId: msg.request.elicitation_id ?? ""
|
|
338
|
+
} : {
|
|
339
|
+
mode: "form",
|
|
340
|
+
message: msg.request.message,
|
|
341
|
+
_meta: msg.request.meta ?? null,
|
|
342
|
+
requestedSchema: msg.request.requested_schema
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
type: "mcp_elicitation",
|
|
348
|
+
serverName: msg.server_name,
|
|
349
|
+
requestId: msg.id
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
case "context_compacted":
|
|
353
|
+
if (!turnId) {
|
|
354
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
355
|
+
}
|
|
356
|
+
return notification({
|
|
357
|
+
method: "thread/compacted",
|
|
358
|
+
params: { threadId, turnId }
|
|
359
|
+
});
|
|
360
|
+
case "realtime_conversation_started":
|
|
361
|
+
return notification({
|
|
362
|
+
method: "thread/realtime/started",
|
|
363
|
+
params: {
|
|
364
|
+
threadId,
|
|
365
|
+
realtimeSessionId: msg.realtime_session_id ?? null,
|
|
366
|
+
version: msg.version
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
case "realtime_conversation_sdp":
|
|
370
|
+
return notification({
|
|
371
|
+
method: "thread/realtime/sdp",
|
|
372
|
+
params: { threadId, sdp: msg.sdp }
|
|
373
|
+
});
|
|
374
|
+
case "realtime_conversation_realtime":
|
|
375
|
+
if (typeof msg.payload === "object" && msg.payload !== null && msg.payload.type === "error") {
|
|
376
|
+
return notification({
|
|
377
|
+
method: "thread/realtime/error",
|
|
378
|
+
params: {
|
|
379
|
+
threadId,
|
|
380
|
+
message: String(
|
|
381
|
+
msg.payload.message ?? "Realtime conversation error."
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return notification({
|
|
387
|
+
method: "thread/realtime/itemAdded",
|
|
388
|
+
params: {
|
|
389
|
+
threadId,
|
|
390
|
+
item: msg.payload
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
case "realtime_conversation_closed":
|
|
394
|
+
return notification({
|
|
395
|
+
method: "thread/realtime/closed",
|
|
396
|
+
params: { threadId, reason: msg.reason ?? null }
|
|
397
|
+
});
|
|
398
|
+
case "warning":
|
|
399
|
+
return warning(threadId, msg.message);
|
|
400
|
+
case "error":
|
|
401
|
+
if (!turnId) {
|
|
402
|
+
return missingTurnIdWarning(threadId, msg.type);
|
|
403
|
+
}
|
|
404
|
+
return notification({
|
|
405
|
+
method: "error",
|
|
406
|
+
params: {
|
|
407
|
+
threadId,
|
|
408
|
+
turnId,
|
|
409
|
+
willRetry: false,
|
|
410
|
+
error: {
|
|
411
|
+
message: msg.message,
|
|
412
|
+
codexErrorInfo: null,
|
|
413
|
+
additionalDetails: null
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
default:
|
|
418
|
+
return warning(threadId, `Unmapped Codex event: ${msg.type}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
var eventMsgToServerProtocolEvent = eventMsgToAppServerEvent;
|
|
422
|
+
var eventMsgToServerProtocolEvents = eventMsgToAppServerEvents;
|
|
423
|
+
function serverRequestResolvedNotification(input) {
|
|
424
|
+
return notification({
|
|
425
|
+
method: "serverRequest/resolved",
|
|
426
|
+
params: {
|
|
427
|
+
threadId: input.threadId,
|
|
428
|
+
requestId: input.requestId
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
function notification(notification2) {
|
|
433
|
+
return { notification: notification2, type: "server_notification" };
|
|
434
|
+
}
|
|
435
|
+
function request(request2, coreTarget) {
|
|
436
|
+
return {
|
|
437
|
+
...coreTarget ? { coreTarget } : {},
|
|
438
|
+
request: request2,
|
|
439
|
+
type: "server_request"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function warning(threadId, message) {
|
|
443
|
+
return notification({
|
|
444
|
+
method: "warning",
|
|
445
|
+
params: { threadId, message }
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function missingTurnIdWarning(threadId, eventType) {
|
|
449
|
+
return warning(threadId, `Codex event ${eventType} was missing a turn id.`);
|
|
450
|
+
}
|
|
451
|
+
function turnIdFromEventMsg(msg, context) {
|
|
452
|
+
if ("turn_id" in msg && typeof msg.turn_id === "string") {
|
|
453
|
+
return msg.turn_id;
|
|
454
|
+
}
|
|
455
|
+
return context.turnId ?? null;
|
|
456
|
+
}
|
|
457
|
+
function epochSeconds(value) {
|
|
458
|
+
return typeof value === "number" ? value / 1e3 : null;
|
|
459
|
+
}
|
|
460
|
+
function durationMsFromString(value) {
|
|
461
|
+
if (!value) {
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
const parsed = Number.parseFloat(value);
|
|
465
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
466
|
+
}
|
|
467
|
+
function completedTurnFromEvent(input) {
|
|
468
|
+
const turn = input.terminalTurn?.id === input.fallbackTurnId ? input.terminalTurn : null;
|
|
469
|
+
return {
|
|
470
|
+
id: input.fallbackTurnId,
|
|
471
|
+
items: turn?.items ?? [],
|
|
472
|
+
itemsView: turn?.itemsView ?? "notLoaded",
|
|
473
|
+
status: turn?.status === "failed" && input.status === "completed" ? "failed" : input.status,
|
|
474
|
+
error: turn?.error ?? null,
|
|
475
|
+
startedAt: turn?.startedAt ?? null,
|
|
476
|
+
completedAt: input.completedAt,
|
|
477
|
+
durationMs: input.durationMs
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function threadTokenUsageFromTokenUsageInfo(info) {
|
|
481
|
+
return {
|
|
482
|
+
total: appServerTokenUsageBreakdown(info.total_token_usage),
|
|
483
|
+
last: appServerTokenUsageBreakdown(info.last_token_usage),
|
|
484
|
+
modelContextWindow: info.model_context_window ?? null
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function appServerTokenUsageBreakdown(usage) {
|
|
488
|
+
return {
|
|
489
|
+
totalTokens: usage.total_tokens,
|
|
490
|
+
inputTokens: usage.input_tokens,
|
|
491
|
+
cachedInputTokens: usage.cached_input_tokens,
|
|
492
|
+
outputTokens: usage.output_tokens,
|
|
493
|
+
reasoningOutputTokens: usage.reasoning_output_tokens
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function appServerRateLimitSnapshot(snapshot) {
|
|
497
|
+
return {
|
|
498
|
+
limitId: valueAsStringOrNull(snapshot.limit_id),
|
|
499
|
+
limitName: valueAsStringOrNull(snapshot.limit_name),
|
|
500
|
+
primary: appServerRateLimitWindow(snapshot.primary),
|
|
501
|
+
secondary: appServerRateLimitWindow(snapshot.secondary),
|
|
502
|
+
credits: snapshot.credits ?? null,
|
|
503
|
+
planType: snapshot.plan_type ?? null,
|
|
504
|
+
rateLimitReachedType: snapshot.rate_limit_reached_type ?? null
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function appServerRateLimitWindow(window) {
|
|
508
|
+
if (!window || typeof window !== "object") {
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
const record = window;
|
|
512
|
+
const resetSeconds = typeof record.reset_seconds === "number" ? record.reset_seconds : null;
|
|
513
|
+
const resetsAt = typeof record.resets_at === "number" ? record.resets_at : resetSeconds === null ? null : Math.floor(Date.now() / 1e3) + resetSeconds;
|
|
514
|
+
return {
|
|
515
|
+
usedPercent: numberOrZero(record.usedPercent ?? record.used_percent),
|
|
516
|
+
windowDurationMins: typeof record.windowDurationMins === "number" ? record.windowDurationMins : typeof record.window_duration_mins === "number" ? record.window_duration_mins : null,
|
|
517
|
+
resetsAt
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function numberOrZero(value) {
|
|
521
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
522
|
+
}
|
|
523
|
+
function valueAsStringOrNull(value) {
|
|
524
|
+
return typeof value === "string" ? value : null;
|
|
525
|
+
}
|
|
526
|
+
function userInputsFromUserMessage(msg) {
|
|
527
|
+
const inputs = [
|
|
528
|
+
{
|
|
529
|
+
type: "text",
|
|
530
|
+
text: msg.message,
|
|
531
|
+
text_elements: appServerTextElementsFromCore(msg.text_elements ?? [])
|
|
532
|
+
}
|
|
533
|
+
];
|
|
534
|
+
for (const url of msg.images ?? []) {
|
|
535
|
+
inputs.push({ type: "image", url });
|
|
536
|
+
}
|
|
537
|
+
for (const path of msg.local_images ?? []) {
|
|
538
|
+
inputs.push({ type: "localImage", path });
|
|
539
|
+
}
|
|
540
|
+
return inputs;
|
|
541
|
+
}
|
|
542
|
+
function appServerUserInputsFromCore(inputs) {
|
|
543
|
+
return inputs.map((input) => {
|
|
544
|
+
if (input.type === "text") {
|
|
545
|
+
return {
|
|
546
|
+
type: "text",
|
|
547
|
+
text: input.text,
|
|
548
|
+
text_elements: appServerTextElementsFromCore(input.text_elements ?? [])
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
if (input.type === "image") {
|
|
552
|
+
return { type: "image", url: input.image_url };
|
|
553
|
+
}
|
|
554
|
+
if (input.type === "local_image") {
|
|
555
|
+
return { type: "localImage", path: input.path };
|
|
556
|
+
}
|
|
557
|
+
return input;
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
function appServerTextElementsFromCore(elements) {
|
|
561
|
+
return elements.map((element) => ({
|
|
562
|
+
byteRange: element.byte_range,
|
|
563
|
+
placeholder: element.placeholder ?? null
|
|
564
|
+
}));
|
|
565
|
+
}
|
|
566
|
+
function appServerMessagePhase(value) {
|
|
567
|
+
return value === "commentary" || value === "final_answer" ? value : null;
|
|
568
|
+
}
|
|
569
|
+
function appServerMemoryCitationFromCore(citation) {
|
|
570
|
+
return citation ? {
|
|
571
|
+
entries: citation.entries,
|
|
572
|
+
threadIds: citation.rolloutIds ?? []
|
|
573
|
+
} : null;
|
|
574
|
+
}
|
|
575
|
+
function coreTurnItemToThreadItem(item) {
|
|
576
|
+
if (!item || typeof item !== "object" || !("type" in item)) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
const value = item;
|
|
580
|
+
switch (value.type) {
|
|
581
|
+
case "UserMessage":
|
|
582
|
+
return {
|
|
583
|
+
type: "userMessage",
|
|
584
|
+
id: String(value.id ?? ""),
|
|
585
|
+
content: appServerUserInputsFromCore(value.content ?? [])
|
|
586
|
+
};
|
|
587
|
+
case "AgentMessage":
|
|
588
|
+
return {
|
|
589
|
+
type: "agentMessage",
|
|
590
|
+
id: String(value.id ?? ""),
|
|
591
|
+
text: (value.content ?? []).map((part) => part.text ?? "").join(""),
|
|
592
|
+
phase: appServerMessagePhase(value.phase),
|
|
593
|
+
memoryCitation: appServerMemoryCitationFromCore(
|
|
594
|
+
value.memory_citation ?? null
|
|
595
|
+
)
|
|
596
|
+
};
|
|
597
|
+
case "Plan":
|
|
598
|
+
return {
|
|
599
|
+
type: "plan",
|
|
600
|
+
id: String(value.id ?? ""),
|
|
601
|
+
text: String(value.text ?? "")
|
|
602
|
+
};
|
|
603
|
+
case "Reasoning":
|
|
604
|
+
return {
|
|
605
|
+
type: "reasoning",
|
|
606
|
+
id: String(value.id ?? ""),
|
|
607
|
+
summary: value.summary_text ?? [],
|
|
608
|
+
content: value.raw_content ?? []
|
|
609
|
+
};
|
|
610
|
+
case "WebSearch": {
|
|
611
|
+
const action = appServerWebSearchAction(value.action);
|
|
612
|
+
return {
|
|
613
|
+
type: "webSearch",
|
|
614
|
+
id: String(value.id ?? ""),
|
|
615
|
+
query: typeof value.query === "string" ? value.query : webSearchActionDetail(action),
|
|
616
|
+
action
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
case "CommandExecution":
|
|
620
|
+
return {
|
|
621
|
+
type: "commandExecution",
|
|
622
|
+
id: String(value.id ?? ""),
|
|
623
|
+
command: (value.command ?? []).join(" "),
|
|
624
|
+
cwd: String(value.cwd ?? ""),
|
|
625
|
+
processId: null,
|
|
626
|
+
source: "agent",
|
|
627
|
+
status: commandStatusToAppServer(value.status),
|
|
628
|
+
commandActions: [],
|
|
629
|
+
aggregatedOutput: [value.stdout, value.stderr].filter(Boolean).join("") || null,
|
|
630
|
+
exitCode: typeof value.exit_code === "number" ? value.exit_code : null,
|
|
631
|
+
durationMs: typeof value.duration_ms === "number" ? value.duration_ms : null
|
|
632
|
+
};
|
|
633
|
+
case "FileChange":
|
|
634
|
+
return {
|
|
635
|
+
type: "fileChange",
|
|
636
|
+
id: String(value.id ?? ""),
|
|
637
|
+
changes: [],
|
|
638
|
+
status: value.status ?? "completed"
|
|
639
|
+
};
|
|
640
|
+
case "DynamicToolCall":
|
|
641
|
+
return {
|
|
642
|
+
type: "dynamicToolCall",
|
|
643
|
+
id: String(value.id ?? ""),
|
|
644
|
+
namespace: value.namespace ?? null,
|
|
645
|
+
tool: String(value.tool ?? ""),
|
|
646
|
+
arguments: value.arguments ?? null,
|
|
647
|
+
status: dynamicToolStatusToAppServer(value.status),
|
|
648
|
+
contentItems: value.content_items ?? null,
|
|
649
|
+
success: value.success ?? null,
|
|
650
|
+
durationMs: durationMsFromString(value.duration)
|
|
651
|
+
};
|
|
652
|
+
case "ContextCompaction":
|
|
653
|
+
return {
|
|
654
|
+
type: "contextCompaction",
|
|
655
|
+
id: String(value.id ?? "")
|
|
656
|
+
};
|
|
657
|
+
default:
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
function appServerWebSearchAction(action) {
|
|
662
|
+
if (!action || typeof action !== "object") {
|
|
663
|
+
return { type: "other" };
|
|
664
|
+
}
|
|
665
|
+
const record = action;
|
|
666
|
+
if (record.type === "search") {
|
|
667
|
+
return {
|
|
668
|
+
type: "search",
|
|
669
|
+
query: typeof record.query === "string" ? record.query : null,
|
|
670
|
+
queries: Array.isArray(record.queries) ? record.queries.filter((query) => typeof query === "string") : null
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
if (record.type === "open_page" || record.type === "openPage") {
|
|
674
|
+
return {
|
|
675
|
+
type: "openPage",
|
|
676
|
+
url: typeof record.url === "string" ? record.url : null
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
if (record.type === "find_in_page" || record.type === "findInPage") {
|
|
680
|
+
return {
|
|
681
|
+
type: "findInPage",
|
|
682
|
+
url: typeof record.url === "string" ? record.url : null,
|
|
683
|
+
pattern: typeof record.pattern === "string" ? record.pattern : null
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
return { type: "other" };
|
|
687
|
+
}
|
|
688
|
+
function webSearchActionDetail(action) {
|
|
689
|
+
switch (action.type) {
|
|
690
|
+
case "search":
|
|
691
|
+
return action.query ?? action.queries?.join(", ") ?? "";
|
|
692
|
+
case "openPage":
|
|
693
|
+
return action.url ?? "";
|
|
694
|
+
case "findInPage": {
|
|
695
|
+
const pattern = action.pattern ?? "";
|
|
696
|
+
const url = action.url ?? "";
|
|
697
|
+
return pattern && url ? `'${pattern}' in ${url}` : pattern || url;
|
|
698
|
+
}
|
|
699
|
+
case "other":
|
|
700
|
+
return "";
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function commandStatusToAppServer(value) {
|
|
704
|
+
if (value === "completed" || value === "failed") {
|
|
705
|
+
return value;
|
|
706
|
+
}
|
|
707
|
+
if (value === "cancelled") {
|
|
708
|
+
return "failed";
|
|
709
|
+
}
|
|
710
|
+
return "inProgress";
|
|
711
|
+
}
|
|
712
|
+
function dynamicToolStatusToAppServer(value) {
|
|
713
|
+
if (value === "completed" || value === "failed") {
|
|
714
|
+
return value;
|
|
715
|
+
}
|
|
716
|
+
return "inProgress";
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// src/upstream/codex-rs/app-server-protocol/src/protocol/thread-resume.ts
|
|
720
|
+
function buildThreadResumeResponseFromHistory(input) {
|
|
721
|
+
const thread = threadHistoryToAppServerThread(input);
|
|
722
|
+
return {
|
|
723
|
+
thread,
|
|
724
|
+
model: input.thread.model ?? "gpt-5.4",
|
|
725
|
+
modelProvider: input.thread.model_provider,
|
|
726
|
+
serviceTier: null,
|
|
727
|
+
cwd: input.thread.cwd,
|
|
728
|
+
instructionSources: [],
|
|
729
|
+
approvalPolicy: approvalPolicyFromStoredThread(input.thread),
|
|
730
|
+
approvalsReviewer: "user",
|
|
731
|
+
sandbox: sandboxPolicyFromStoredThread(input.thread),
|
|
732
|
+
reasoningEffort: reasoningEffortFromStoredThread(input.thread)
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function threadHistoryToAppServerThread(input) {
|
|
736
|
+
const rendered = renderThreadFromHistory(input.history);
|
|
737
|
+
return {
|
|
738
|
+
id: input.thread.thread_id,
|
|
739
|
+
sessionId: input.thread.rollout_path ?? input.thread.thread_id,
|
|
740
|
+
forkedFromId: input.thread.forked_from_id ?? null,
|
|
741
|
+
preview: input.thread.preview,
|
|
742
|
+
ephemeral: false,
|
|
743
|
+
modelProvider: input.thread.model_provider,
|
|
744
|
+
createdAt: epochSecondsFromIso(input.thread.created_at),
|
|
745
|
+
updatedAt: epochSecondsFromIso(input.thread.updated_at),
|
|
746
|
+
status: { type: "idle" },
|
|
747
|
+
path: input.thread.rollout_path ?? null,
|
|
748
|
+
cwd: input.thread.cwd,
|
|
749
|
+
cliVersion: input.thread.cli_version ?? "",
|
|
750
|
+
source: sessionSourceFromStoredThread(input.thread.source),
|
|
751
|
+
threadSource: threadSourceFromStoredThread(input.thread.thread_source),
|
|
752
|
+
agentNickname: input.thread.agent_nickname ?? null,
|
|
753
|
+
agentRole: input.thread.agent_role ?? null,
|
|
754
|
+
gitInfo: gitInfoFromStoredThread(input.thread.git_info),
|
|
755
|
+
name: input.thread.name ?? null,
|
|
756
|
+
turns: rendered.turns.map(appServerTurnFromCoreTurn)
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function renderableHistoryFromAppServerThread(thread) {
|
|
760
|
+
return {
|
|
761
|
+
thread_id: thread.id,
|
|
762
|
+
items: thread.turns.flatMap((turn) => {
|
|
763
|
+
const items = [
|
|
764
|
+
{
|
|
765
|
+
type: "event_msg",
|
|
766
|
+
payload: {
|
|
767
|
+
type: "turn_started",
|
|
768
|
+
turn_id: turn.id,
|
|
769
|
+
started_at: typeof turn.startedAt === "number" ? turn.startedAt * 1e3 : void 0
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
...turn.items.map((item) => rolloutItemFromThreadItem(item, turn.id)).filter((item) => item !== null)
|
|
773
|
+
];
|
|
774
|
+
if (turn.status === "inProgress") {
|
|
775
|
+
return items;
|
|
776
|
+
}
|
|
777
|
+
return [
|
|
778
|
+
...items,
|
|
779
|
+
{
|
|
780
|
+
type: "event_msg",
|
|
781
|
+
payload: turn.status === "interrupted" ? {
|
|
782
|
+
type: "turn_aborted",
|
|
783
|
+
turn_id: turn.id,
|
|
784
|
+
reason: "interrupted",
|
|
785
|
+
completed_at: typeof turn.completedAt === "number" ? turn.completedAt * 1e3 : void 0,
|
|
786
|
+
duration_ms: turn.durationMs
|
|
787
|
+
} : {
|
|
788
|
+
type: "turn_complete",
|
|
789
|
+
turn_id: turn.id,
|
|
790
|
+
completed_at: typeof turn.completedAt === "number" ? turn.completedAt * 1e3 : void 0,
|
|
791
|
+
duration_ms: turn.durationMs
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
];
|
|
795
|
+
})
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function appServerTurnFromCoreTurn(turn) {
|
|
799
|
+
return {
|
|
800
|
+
id: turn.id,
|
|
801
|
+
items: turn.items.map(coreTurnItemToThreadItem).filter((item) => item !== null),
|
|
802
|
+
itemsView: turn.items_view === "not_loaded" ? "notLoaded" : turn.items_view,
|
|
803
|
+
status: coreTurnStatusToAppServer(turn.status),
|
|
804
|
+
error: turn.error ? {
|
|
805
|
+
message: turn.error.message,
|
|
806
|
+
codexErrorInfo: turn.error.codex_error_info ?? null,
|
|
807
|
+
additionalDetails: turn.error.additional_details ?? null
|
|
808
|
+
} : null,
|
|
809
|
+
startedAt: epochSeconds2(turn.started_at),
|
|
810
|
+
completedAt: epochSeconds2(turn.completed_at),
|
|
811
|
+
durationMs: turn.duration_ms
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
function rolloutItemFromThreadItem(item, turnId) {
|
|
815
|
+
const coreItem = coreTurnItemFromThreadItem(item);
|
|
816
|
+
if (!coreItem) {
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
return {
|
|
820
|
+
type: "event_msg",
|
|
821
|
+
payload: {
|
|
822
|
+
type: "item_completed",
|
|
823
|
+
turn_id: turnId,
|
|
824
|
+
item: coreItem
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function coreTurnItemFromThreadItem(item) {
|
|
829
|
+
switch (item.type) {
|
|
830
|
+
case "userMessage":
|
|
831
|
+
return {
|
|
832
|
+
type: "UserMessage",
|
|
833
|
+
id: item.id,
|
|
834
|
+
content: item.content.map((input) => {
|
|
835
|
+
if (input.type === "image") {
|
|
836
|
+
return { type: "image", image_url: input.url };
|
|
837
|
+
}
|
|
838
|
+
if (input.type === "localImage") {
|
|
839
|
+
return { type: "local_image", path: input.path };
|
|
840
|
+
}
|
|
841
|
+
if (input.type !== "text") {
|
|
842
|
+
return {
|
|
843
|
+
type: "text",
|
|
844
|
+
text: input.name,
|
|
845
|
+
text_elements: []
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
type: "text",
|
|
850
|
+
text: input.text,
|
|
851
|
+
text_elements: input.text_elements.map((element) => ({
|
|
852
|
+
byte_range: element.byteRange,
|
|
853
|
+
placeholder: element.placeholder ?? void 0
|
|
854
|
+
}))
|
|
855
|
+
};
|
|
856
|
+
})
|
|
857
|
+
};
|
|
858
|
+
case "agentMessage":
|
|
859
|
+
return {
|
|
860
|
+
type: "AgentMessage",
|
|
861
|
+
id: item.id,
|
|
862
|
+
content: [{ type: "Text", text: item.text }],
|
|
863
|
+
phase: item.phase,
|
|
864
|
+
memory_citation: item.memoryCitation ? {
|
|
865
|
+
entries: item.memoryCitation.entries,
|
|
866
|
+
rolloutIds: item.memoryCitation.threadIds
|
|
867
|
+
} : null
|
|
868
|
+
};
|
|
869
|
+
case "plan":
|
|
870
|
+
return { type: "Plan", id: item.id, text: item.text };
|
|
871
|
+
case "reasoning":
|
|
872
|
+
return {
|
|
873
|
+
type: "Reasoning",
|
|
874
|
+
id: item.id,
|
|
875
|
+
summary_text: item.summary,
|
|
876
|
+
raw_content: item.content
|
|
877
|
+
};
|
|
878
|
+
case "webSearch":
|
|
879
|
+
return {
|
|
880
|
+
type: "WebSearch",
|
|
881
|
+
id: item.id,
|
|
882
|
+
query: item.query,
|
|
883
|
+
action: coreWebSearchActionFromAppServer(item.action)
|
|
884
|
+
};
|
|
885
|
+
case "commandExecution":
|
|
886
|
+
return {
|
|
887
|
+
type: "CommandExecution",
|
|
888
|
+
id: item.id,
|
|
889
|
+
command: [item.command],
|
|
890
|
+
cwd: item.cwd,
|
|
891
|
+
status: coreCommandStatusFromAppServer(item.status),
|
|
892
|
+
stdout: item.aggregatedOutput ?? "",
|
|
893
|
+
exit_code: item.exitCode,
|
|
894
|
+
duration_ms: item.durationMs
|
|
895
|
+
};
|
|
896
|
+
case "fileChange":
|
|
897
|
+
return {
|
|
898
|
+
type: "FileChange",
|
|
899
|
+
id: item.id,
|
|
900
|
+
changes: {},
|
|
901
|
+
status: item.status === "completed" || item.status === "failed" || item.status === "declined" ? item.status : null,
|
|
902
|
+
auto_approved: false,
|
|
903
|
+
stdout: "",
|
|
904
|
+
stderr: ""
|
|
905
|
+
};
|
|
906
|
+
case "dynamicToolCall":
|
|
907
|
+
return {
|
|
908
|
+
type: "DynamicToolCall",
|
|
909
|
+
id: item.id,
|
|
910
|
+
namespace: item.namespace,
|
|
911
|
+
tool: item.tool,
|
|
912
|
+
arguments: item.arguments,
|
|
913
|
+
status: item.status,
|
|
914
|
+
content_items: item.contentItems ?? [],
|
|
915
|
+
success: item.success,
|
|
916
|
+
duration: item.durationMs === null ? null : String(item.durationMs)
|
|
917
|
+
};
|
|
918
|
+
case "contextCompaction":
|
|
919
|
+
return { type: "ContextCompaction", id: item.id };
|
|
920
|
+
default:
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
function coreWebSearchActionFromAppServer(action) {
|
|
925
|
+
if (!action) {
|
|
926
|
+
return { type: "other" };
|
|
927
|
+
}
|
|
928
|
+
switch (action.type) {
|
|
929
|
+
case "search":
|
|
930
|
+
return {
|
|
931
|
+
type: "search",
|
|
932
|
+
...action.query ? { query: action.query } : {},
|
|
933
|
+
...action.queries ? { queries: action.queries } : {}
|
|
934
|
+
};
|
|
935
|
+
case "openPage":
|
|
936
|
+
return {
|
|
937
|
+
type: "open_page",
|
|
938
|
+
...action.url ? { url: action.url } : {}
|
|
939
|
+
};
|
|
940
|
+
case "findInPage":
|
|
941
|
+
return {
|
|
942
|
+
type: "find_in_page",
|
|
943
|
+
...action.url ? { url: action.url } : {},
|
|
944
|
+
...action.pattern ? { pattern: action.pattern } : {}
|
|
945
|
+
};
|
|
946
|
+
case "other":
|
|
947
|
+
return { type: "other" };
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function coreTurnStatusToAppServer(status) {
|
|
951
|
+
if (status === "in_progress") {
|
|
952
|
+
return "inProgress";
|
|
953
|
+
}
|
|
954
|
+
return status;
|
|
955
|
+
}
|
|
956
|
+
function coreCommandStatusFromAppServer(status) {
|
|
957
|
+
if (status === "declined") {
|
|
958
|
+
return "failed";
|
|
959
|
+
}
|
|
960
|
+
return status === "inProgress" ? "in_progress" : status;
|
|
961
|
+
}
|
|
962
|
+
function epochSeconds2(value) {
|
|
963
|
+
return typeof value === "number" ? value / 1e3 : null;
|
|
964
|
+
}
|
|
965
|
+
function epochSecondsFromIso(value) {
|
|
966
|
+
const parsed = Date.parse(value);
|
|
967
|
+
return Number.isFinite(parsed) ? Math.floor(parsed / 1e3) : 0;
|
|
968
|
+
}
|
|
969
|
+
function sessionSourceFromStoredThread(source) {
|
|
970
|
+
if (source === "cli" || source === "vscode" || source === "exec" || source === "unknown") {
|
|
971
|
+
return source;
|
|
972
|
+
}
|
|
973
|
+
if (source === "appServer" || source === "app-server") {
|
|
974
|
+
return "appServer";
|
|
975
|
+
}
|
|
976
|
+
return { custom: source };
|
|
977
|
+
}
|
|
978
|
+
function threadSourceFromStoredThread(source) {
|
|
979
|
+
if (source === "user" || source === "subagent" || source === "memory_consolidation") {
|
|
980
|
+
return source;
|
|
981
|
+
}
|
|
982
|
+
return null;
|
|
983
|
+
}
|
|
984
|
+
function gitInfoFromStoredThread(gitInfo) {
|
|
985
|
+
if (!gitInfo || typeof gitInfo !== "object") {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
const value = gitInfo;
|
|
989
|
+
return {
|
|
990
|
+
sha: typeof value.sha === "string" ? value.sha : typeof value.commit_hash === "string" ? value.commit_hash : null,
|
|
991
|
+
branch: typeof value.branch === "string" ? value.branch : null,
|
|
992
|
+
originUrl: typeof value.originUrl === "string" ? value.originUrl : typeof value.repository_url === "string" ? value.repository_url : null
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
function approvalPolicyFromStoredThread(thread) {
|
|
996
|
+
if (thread.approval_mode === "untrusted" || thread.approval_mode === "on-failure" || thread.approval_mode === "on-request" || thread.approval_mode === "never") {
|
|
997
|
+
return thread.approval_mode;
|
|
998
|
+
}
|
|
999
|
+
return "on-request";
|
|
1000
|
+
}
|
|
1001
|
+
function sandboxPolicyFromStoredThread(thread) {
|
|
1002
|
+
if (thread.sandbox_policy && typeof thread.sandbox_policy === "object") {
|
|
1003
|
+
return thread.sandbox_policy;
|
|
1004
|
+
}
|
|
1005
|
+
if (thread.sandbox_policy === "read-only") {
|
|
1006
|
+
return { type: "readOnly", networkAccess: false };
|
|
1007
|
+
}
|
|
1008
|
+
return { type: "dangerFullAccess" };
|
|
1009
|
+
}
|
|
1010
|
+
function reasoningEffortFromStoredThread(thread) {
|
|
1011
|
+
if (thread.reasoning_effort === "none" || thread.reasoning_effort === "minimal" || thread.reasoning_effort === "low" || thread.reasoning_effort === "medium" || thread.reasoning_effort === "high" || thread.reasoning_effort === "xhigh") {
|
|
1012
|
+
return thread.reasoning_effort;
|
|
1013
|
+
}
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// src/upstream/codex-rs/app-server-protocol/src/protocol/common.ts
|
|
1018
|
+
function clientRequestId(request2) {
|
|
1019
|
+
return request2.id;
|
|
1020
|
+
}
|
|
1021
|
+
function clientRequestMethod(request2) {
|
|
1022
|
+
return request2.method;
|
|
1023
|
+
}
|
|
1024
|
+
function clientRequestExperimentalReason(request2) {
|
|
1025
|
+
return EXPERIMENTAL_METHOD_REASONS[request2.method] ?? clientRequestParamExperimentalReason(request2.method, objectParams(request2.params));
|
|
1026
|
+
}
|
|
1027
|
+
function clientRequestSerializationScope(request2) {
|
|
1028
|
+
const params = objectParams(request2.params);
|
|
1029
|
+
switch (request2.method) {
|
|
1030
|
+
case "thread/resume":
|
|
1031
|
+
case "thread/fork":
|
|
1032
|
+
return threadOrPathScope(params, "threadId", "path");
|
|
1033
|
+
case "thread/archive":
|
|
1034
|
+
case "thread/unsubscribe":
|
|
1035
|
+
case "thread/increment_elicitation":
|
|
1036
|
+
case "thread/decrement_elicitation":
|
|
1037
|
+
case "thread/name/set":
|
|
1038
|
+
case "thread/goal/set":
|
|
1039
|
+
case "thread/goal/get":
|
|
1040
|
+
case "thread/goal/clear":
|
|
1041
|
+
case "thread/metadata/update":
|
|
1042
|
+
case "thread/memoryMode/set":
|
|
1043
|
+
case "thread/unarchive":
|
|
1044
|
+
case "thread/compact/start":
|
|
1045
|
+
case "thread/shellCommand":
|
|
1046
|
+
case "thread/approveGuardianDeniedAction":
|
|
1047
|
+
case "thread/backgroundTerminals/clean":
|
|
1048
|
+
case "thread/rollback":
|
|
1049
|
+
case "thread/read":
|
|
1050
|
+
case "thread/inject_items":
|
|
1051
|
+
case "turn/start":
|
|
1052
|
+
case "turn/steer":
|
|
1053
|
+
case "turn/interrupt":
|
|
1054
|
+
case "thread/realtime/start":
|
|
1055
|
+
case "thread/realtime/appendAudio":
|
|
1056
|
+
case "thread/realtime/appendText":
|
|
1057
|
+
case "thread/realtime/stop":
|
|
1058
|
+
case "review/start":
|
|
1059
|
+
case "mcpServer/tool/call":
|
|
1060
|
+
return threadScope(params, "threadId", "thread_id");
|
|
1061
|
+
case "memory/reset":
|
|
1062
|
+
return globalScope("memory");
|
|
1063
|
+
case "skills/list":
|
|
1064
|
+
case "hooks/list":
|
|
1065
|
+
case "marketplace/add":
|
|
1066
|
+
case "marketplace/remove":
|
|
1067
|
+
case "marketplace/upgrade":
|
|
1068
|
+
case "plugin/list":
|
|
1069
|
+
case "plugin/read":
|
|
1070
|
+
case "plugin/skill/read":
|
|
1071
|
+
case "plugin/share/save":
|
|
1072
|
+
case "plugin/share/updateTargets":
|
|
1073
|
+
case "plugin/share/list":
|
|
1074
|
+
case "plugin/share/delete":
|
|
1075
|
+
case "skills/config/write":
|
|
1076
|
+
case "plugin/install":
|
|
1077
|
+
case "plugin/uninstall":
|
|
1078
|
+
case "experimentalFeature/list":
|
|
1079
|
+
case "experimentalFeature/enablement/set":
|
|
1080
|
+
case "windowsSandbox/readiness":
|
|
1081
|
+
case "config/read":
|
|
1082
|
+
case "externalAgentConfig/detect":
|
|
1083
|
+
case "externalAgentConfig/import":
|
|
1084
|
+
case "config/value/write":
|
|
1085
|
+
case "config/batchWrite":
|
|
1086
|
+
case "configRequirements/read":
|
|
1087
|
+
return globalScope("config");
|
|
1088
|
+
case "device/key/create":
|
|
1089
|
+
case "device/key/public":
|
|
1090
|
+
case "device/key/sign":
|
|
1091
|
+
return globalScope("device-key");
|
|
1092
|
+
case "mcpServer/oauth/login":
|
|
1093
|
+
return mcpOauthScope(params, "name");
|
|
1094
|
+
case "config/mcpServer/reload":
|
|
1095
|
+
case "mcpServerStatus/list":
|
|
1096
|
+
return globalScope("mcp-registry");
|
|
1097
|
+
case "mcpServer/resource/read":
|
|
1098
|
+
return optionalThreadScope(params, "threadId", "thread_id");
|
|
1099
|
+
case "windowsSandbox/setupStart":
|
|
1100
|
+
return globalScope("windows-sandbox-setup");
|
|
1101
|
+
case "account/login/start":
|
|
1102
|
+
case "account/login/cancel":
|
|
1103
|
+
case "account/logout":
|
|
1104
|
+
case "account/sendAddCreditsNudgeEmail":
|
|
1105
|
+
case "account/read":
|
|
1106
|
+
case "getAuthStatus":
|
|
1107
|
+
return globalScope("account-auth");
|
|
1108
|
+
case "command/exec":
|
|
1109
|
+
return optionalCommandExecProcessScope(params, "processId", "process_id");
|
|
1110
|
+
case "command/exec/write":
|
|
1111
|
+
case "command/exec/terminate":
|
|
1112
|
+
case "command/exec/resize":
|
|
1113
|
+
return commandExecProcessScope(params, "processId", "process_id");
|
|
1114
|
+
case "process/spawn":
|
|
1115
|
+
case "process/writeStdin":
|
|
1116
|
+
case "process/kill":
|
|
1117
|
+
case "process/resizePty":
|
|
1118
|
+
return processHandleScope(params, "processHandle", "process_handle");
|
|
1119
|
+
case "fuzzyFileSearch/sessionStart":
|
|
1120
|
+
case "fuzzyFileSearch/sessionUpdate":
|
|
1121
|
+
case "fuzzyFileSearch/sessionStop":
|
|
1122
|
+
return fuzzySessionScope(params, "sessionId", "session_id");
|
|
1123
|
+
case "fs/watch":
|
|
1124
|
+
case "fs/unwatch":
|
|
1125
|
+
return fsWatchScope(params, "watchId", "watch_id");
|
|
1126
|
+
default:
|
|
1127
|
+
return null;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
var EXPERIMENTAL_METHOD_REASONS = {
|
|
1131
|
+
"collaborationMode/list": "collaborationMode/list",
|
|
1132
|
+
"fuzzyFileSearch/sessionStart": "fuzzyFileSearch/sessionStart",
|
|
1133
|
+
"fuzzyFileSearch/sessionStop": "fuzzyFileSearch/sessionStop",
|
|
1134
|
+
"fuzzyFileSearch/sessionUpdate": "fuzzyFileSearch/sessionUpdate",
|
|
1135
|
+
"memory/reset": "memory/reset",
|
|
1136
|
+
"mock/experimentalMethod": "mock/experimentalMethod",
|
|
1137
|
+
"process/kill": "process/kill",
|
|
1138
|
+
"process/resizePty": "process/resizePty",
|
|
1139
|
+
"process/spawn": "process/spawn",
|
|
1140
|
+
"process/writeStdin": "process/writeStdin",
|
|
1141
|
+
"thread/backgroundTerminals/clean": "thread/backgroundTerminals/clean",
|
|
1142
|
+
"thread/decrement_elicitation": "thread/decrement_elicitation",
|
|
1143
|
+
"thread/goal/clear": "thread/goal/clear",
|
|
1144
|
+
"thread/goal/get": "thread/goal/get",
|
|
1145
|
+
"thread/goal/set": "thread/goal/set",
|
|
1146
|
+
"thread/increment_elicitation": "thread/increment_elicitation",
|
|
1147
|
+
"thread/memoryMode/set": "thread/memoryMode/set",
|
|
1148
|
+
"thread/realtime/appendAudio": "thread/realtime/appendAudio",
|
|
1149
|
+
"thread/realtime/appendText": "thread/realtime/appendText",
|
|
1150
|
+
"thread/realtime/listVoices": "thread/realtime/listVoices",
|
|
1151
|
+
"thread/realtime/start": "thread/realtime/start",
|
|
1152
|
+
"thread/realtime/stop": "thread/realtime/stop",
|
|
1153
|
+
"thread/turns/list": "thread/turns/list"
|
|
1154
|
+
};
|
|
1155
|
+
function clientRequestParamExperimentalReason(method, params) {
|
|
1156
|
+
switch (method) {
|
|
1157
|
+
case "thread/start":
|
|
1158
|
+
return granularApprovalReason(params) ?? presentFieldReason(params, "thread/start.permissions", "permissions") ?? presentFieldReason(params, "thread/start.environments", "environments") ?? presentFieldReason(params, "thread/start.dynamicTools", "dynamicTools", "dynamic_tools") ?? presentFieldReason(params, "thread/start.mockExperimentalField", "mockExperimentalField", "mock_experimental_field") ?? truthyFieldReason(params, "thread/start.experimentalRawEvents", "experimentalRawEvents", "experimental_raw_events") ?? truthyFieldReason(params, "thread/start.persistFullHistory", "persistExtendedHistory", "persist_extended_history");
|
|
1159
|
+
case "thread/resume":
|
|
1160
|
+
return presentFieldReason(params, "thread/resume.history", "history") ?? presentFieldReason(params, "thread/resume.path", "path") ?? granularApprovalReason(params) ?? presentFieldReason(params, "thread/resume.permissions", "permissions") ?? truthyFieldReason(params, "thread/resume.excludeTurns", "excludeTurns", "exclude_turns") ?? truthyFieldReason(params, "thread/resume.persistFullHistory", "persistExtendedHistory", "persist_extended_history");
|
|
1161
|
+
case "thread/fork":
|
|
1162
|
+
return presentFieldReason(params, "thread/fork.path", "path") ?? granularApprovalReason(params) ?? presentFieldReason(params, "thread/fork.permissions", "permissions") ?? truthyFieldReason(params, "thread/fork.excludeTurns", "excludeTurns", "exclude_turns") ?? truthyFieldReason(params, "thread/fork.persistFullHistory", "persistExtendedHistory", "persist_extended_history");
|
|
1163
|
+
case "turn/start":
|
|
1164
|
+
return presentFieldReason(params, "turn/start.responsesapiClientMetadata", "responsesapiClientMetadata", "responsesapi_client_metadata") ?? presentFieldReason(params, "turn/start.environments", "environments") ?? granularApprovalReason(params) ?? presentFieldReason(params, "turn/start.permissions", "permissions") ?? presentFieldReason(params, "turn/start.collaborationMode", "collaborationMode", "collaboration_mode");
|
|
1165
|
+
case "turn/steer":
|
|
1166
|
+
return presentFieldReason(params, "turn/steer.responsesapiClientMetadata", "responsesapiClientMetadata", "responsesapi_client_metadata");
|
|
1167
|
+
case "command/exec":
|
|
1168
|
+
return presentFieldReason(params, "command/exec.permissionProfile", "permissionProfile", "permission_profile");
|
|
1169
|
+
case "account/login/start":
|
|
1170
|
+
return params.type === "chatgptAuthTokens" ? "account/login/start.chatgptAuthTokens" : null;
|
|
1171
|
+
default:
|
|
1172
|
+
return null;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function granularApprovalReason(params) {
|
|
1176
|
+
const approvalPolicy = params.approvalPolicy ?? params.approval_policy;
|
|
1177
|
+
return isRecord(approvalPolicy) && "granular" in approvalPolicy ? "askForApproval.granular" : null;
|
|
1178
|
+
}
|
|
1179
|
+
function presentFieldReason(params, reason, ...fields) {
|
|
1180
|
+
for (const field of fields) {
|
|
1181
|
+
if (params[field] !== void 0 && params[field] !== null) {
|
|
1182
|
+
return reason;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return null;
|
|
1186
|
+
}
|
|
1187
|
+
function truthyFieldReason(params, reason, ...fields) {
|
|
1188
|
+
for (const field of fields) {
|
|
1189
|
+
if (params[field] === true) {
|
|
1190
|
+
return reason;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
return null;
|
|
1194
|
+
}
|
|
1195
|
+
function objectParams(value) {
|
|
1196
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
1197
|
+
}
|
|
1198
|
+
function isRecord(value) {
|
|
1199
|
+
return typeof value === "object" && value !== null;
|
|
1200
|
+
}
|
|
1201
|
+
function globalScope(key) {
|
|
1202
|
+
return { key, type: "global" };
|
|
1203
|
+
}
|
|
1204
|
+
function threadScope(params, ...fields) {
|
|
1205
|
+
const threadId = stringField(params, ...fields);
|
|
1206
|
+
return threadId ? { threadId, type: "thread" } : null;
|
|
1207
|
+
}
|
|
1208
|
+
function optionalThreadScope(params, ...fields) {
|
|
1209
|
+
return threadScope(params, ...fields);
|
|
1210
|
+
}
|
|
1211
|
+
function threadOrPathScope(params, threadField, pathField) {
|
|
1212
|
+
const threadId = stringField(params, threadField);
|
|
1213
|
+
if (threadId) {
|
|
1214
|
+
return { threadId, type: "thread" };
|
|
1215
|
+
}
|
|
1216
|
+
const path = stringField(params, pathField);
|
|
1217
|
+
if (path) {
|
|
1218
|
+
return { path, type: "threadPath" };
|
|
1219
|
+
}
|
|
1220
|
+
return threadId === "" ? { threadId, type: "thread" } : null;
|
|
1221
|
+
}
|
|
1222
|
+
function optionalCommandExecProcessScope(params, ...fields) {
|
|
1223
|
+
const processId = stringField(params, ...fields);
|
|
1224
|
+
return processId ? { processId, type: "commandExecProcess" } : null;
|
|
1225
|
+
}
|
|
1226
|
+
function commandExecProcessScope(params, ...fields) {
|
|
1227
|
+
const processId = stringField(params, ...fields);
|
|
1228
|
+
return processId ? { processId, type: "commandExecProcess" } : null;
|
|
1229
|
+
}
|
|
1230
|
+
function processHandleScope(params, ...fields) {
|
|
1231
|
+
const processHandle = stringField(params, ...fields);
|
|
1232
|
+
return processHandle ? { processHandle, type: "process" } : null;
|
|
1233
|
+
}
|
|
1234
|
+
function fuzzySessionScope(params, ...fields) {
|
|
1235
|
+
const sessionId = stringField(params, ...fields);
|
|
1236
|
+
return sessionId ? { sessionId, type: "fuzzyFileSearchSession" } : null;
|
|
1237
|
+
}
|
|
1238
|
+
function fsWatchScope(params, ...fields) {
|
|
1239
|
+
const watchId = stringField(params, ...fields);
|
|
1240
|
+
return watchId ? { watchId, type: "fsWatch" } : null;
|
|
1241
|
+
}
|
|
1242
|
+
function mcpOauthScope(params, ...fields) {
|
|
1243
|
+
const serverName = stringField(params, ...fields);
|
|
1244
|
+
return serverName ? { serverName, type: "mcpOauth" } : null;
|
|
1245
|
+
}
|
|
1246
|
+
function stringField(params, ...fields) {
|
|
1247
|
+
for (const field of fields) {
|
|
1248
|
+
const value = params[field];
|
|
1249
|
+
if (typeof value === "string") {
|
|
1250
|
+
return value;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
export { appServerTurnFromCoreTurn, buildThreadResumeResponseFromHistory, clientRequestExperimentalReason, clientRequestId, clientRequestMethod, clientRequestSerializationScope, coreTurnItemToThreadItem, eventMsgToAppServerEvent, eventMsgToAppServerEvents, eventMsgToServerProtocolEvent, eventMsgToServerProtocolEvents, renderableHistoryFromAppServerThread, serverRequestResolvedNotification, threadHistoryToAppServerThread, threadTokenUsageFromTokenUsageInfo };
|
|
1257
|
+
//# sourceMappingURL=chunk-2DZRMCI2.js.map
|
|
1258
|
+
//# sourceMappingURL=chunk-2DZRMCI2.js.map
|