@super-one/cli 0.61.0 → 0.62.0-alpha
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/MANIFEST.json +2 -2
- package/lib/cli.mjs +445 -385
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -2078,7 +2078,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2078
2078
|
},
|
|
2079
2079
|
{
|
|
2080
2080
|
"name": "computer_apps",
|
|
2081
|
-
"description": "Discover and open desktop apps. action=list (default) returns a compact TOON app catalog: one row per app with app, bundleId, running, frontmost, granted, grantScope, pid, windows. Use query to keyword-filter by display name / bundle id / localized aliases (e.g. query=Notes or com.apple.TextEdit). Paginate with offset + limit (default limit 25, max 100); hasMore means call again with offset+=limit. Rows are sorted running/frontmost/granted first.
|
|
2081
|
+
"description": "Discover and open desktop apps. action=list (default) returns a compact TOON app catalog: one row per app with app, bundleId, running, frontmost, granted, grantScope, pid, windows. Use query to keyword-filter by display name / bundle id / localized aliases (e.g. query=Notes or com.apple.TextEdit). Paginate with offset + limit (default limit 25, max 100); hasMore means call again with offset+=limit. Rows are sorted running/frontmost/granted first. action=focus|launch accepts display name (any locale) or reverse-DNS bundleId; host resolves to a stable bundleId before the permission grant so one allow covers later snapshot/act. Launch/focus returns a slim {target} confirmation. If the user only asks to open an app, launch once and stop when target is returned. Driving an app is computer_snapshot + computer_act; focus only puts a window in front.",
|
|
2082
2082
|
"inputSchema": {
|
|
2083
2083
|
"type": "object",
|
|
2084
2084
|
"properties": {
|
|
@@ -2130,7 +2130,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2130
2130
|
},
|
|
2131
2131
|
{
|
|
2132
2132
|
"name": "computer_snapshot",
|
|
2133
|
-
"description": "Capture an immutable UI snapshot and return stateId (analogous to browser_snapshot for desktop apps). All subsequent query/act/wait_for calls must reference this stateId. mode=visual (and fused) saves the image to a temporary file and returns image.path (not base64). The image is NOT loaded into your context automatically; call Read on image.path if you need to look at pixels, or leave the path as a record for the user. mode=semantic returns accessibility outline with @eN refs (no image). mode=fused = screenshot + AX. Use computer_query on the cached outline for search/expand/inspect without recapturing. capture=window (default) captures only the selected window; coordinates are local to that image and remain valid if the window moves. Use capture=display explicitly when the whole display is required. If the window is resized or moves to a different display scale, input fails closed and a successor observation is created.",
|
|
2133
|
+
"description": "Capture an immutable UI snapshot and return stateId (analogous to browser_snapshot for desktop apps). All subsequent query/act/wait_for calls must reference this stateId. mode=visual (and fused) saves the image to a temporary file and returns image.path (not base64). The image is NOT loaded into your context automatically; call Read on image.path if you need to look at pixels, or leave the path as a record for the user. mode=semantic returns accessibility outline with @eN refs (no image). mode=fused = screenshot + AX. The outline is a TOON table, not JSON: a header row outline[N]{ref,depth,role,name,value,x,y,w,h,can,state}: followed by one CSV-style row per node, in depth-first reading order. depth is the nesting level (a row is a child of the nearest row above it with a smaller depth). can lists only the supported actions, pipe-joined (press|setText|typeText|scroll|focus); empty means the node is inert. state lists only non-default flags (disabled|focused). x,y,w,h are the frame in capture space, empty when the node reports none. truncation.nodesOmitted > 0 means the returned outline was folded \u2014 reach the rest with computer_query, do not recapture. truncation.sourceTruncated means the native accessibility walk itself hit a limit, so those nodes are missing from the full tree too and computer_query cannot reach them either \u2014 narrow the target with capture=window or a specific rootId instead. Use computer_query on the cached outline for search/expand/inspect without recapturing. capture=window (default) captures only the selected window; coordinates are local to that image and remain valid if the window moves. Use capture=display explicitly when the whole display is required. If the window is resized or moves to a different display scale, input fails closed and a successor observation is created.",
|
|
2134
2134
|
"inputSchema": {
|
|
2135
2135
|
"type": "object",
|
|
2136
2136
|
"properties": {
|
|
@@ -2213,7 +2213,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2213
2213
|
},
|
|
2214
2214
|
{
|
|
2215
2215
|
"name": "computer_query",
|
|
2216
|
-
"description": "Search / expand / inspect the cached outline for a stateId without recapturing the desktop. Use this for progressive disclosure of deep accessibility trees.",
|
|
2216
|
+
"description": "Search / expand / inspect the cached outline for a stateId without recapturing the desktop. Use this for progressive disclosure of deep accessibility trees. expand/inspect return the subtree/element as the same TOON table computer_snapshot uses.",
|
|
2217
2217
|
"inputSchema": {
|
|
2218
2218
|
"type": "object",
|
|
2219
2219
|
"properties": {
|
|
@@ -2259,7 +2259,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2259
2259
|
},
|
|
2260
2260
|
{
|
|
2261
2261
|
"name": "computer_act",
|
|
2262
|
-
"description": "Submit 1\u201320 related UI actions as a checked transaction against a stateId.
|
|
2262
|
+
"description": "Submit 1\u201320 related UI actions as a checked transaction against a stateId. Set delivery explicitly when you can; that field describes how the three modes differ. Actions: click, typeText, keypress, scroll(dx,dy[,x,y|ref]), drag(path\u22652 points), moveMouse, press/setText (AX). scroll: positive dy scrolls content down; aim with x,y (capture space) or ref center; else window/outline center. drag: path is capture-space points; virtual cursor animates along the path. Returns outcome worked|didnt|unknown based on re-observation (not API success codes): worked when AX readback, expect, typed text, or a meaningful successor outline diff confirms effect; unknown only when applied but unprovable; didnt on hard failure or failed expect. When the successor has pixels, successorImage.path contains the fresh screenshot. Set recording=true to save a short video containing only this action transaction. Stale stateId (UI changed since snapshot) is rejected before side effects. delivery=semantic never silently upgrades to app-directed/physical input.",
|
|
2263
2263
|
"inputSchema": {
|
|
2264
2264
|
"type": "object",
|
|
2265
2265
|
"properties": {
|
|
@@ -2389,7 +2389,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2389
2389
|
"maximum": 6e4
|
|
2390
2390
|
},
|
|
2391
2391
|
"delivery": {
|
|
2392
|
-
"description": "
|
|
2392
|
+
"description": "semantic \u2014 pure AX; prefer it whenever actions use @eN refs and the action is press/setText/click(ref)/typeText(ref), the most reliable path for labeled controls. app-directed \u2014 the default when omitted; for coordinate click/type/scroll/drag/keypress or when no usable AX ref exists. Posts CGEvent to the target app PID in the background without stealing frontmost. physical \u2014 global HID; only when app-directed fails. Requires frontmost and is disruptive.",
|
|
2393
2393
|
"type": "string",
|
|
2394
2394
|
"enum": [
|
|
2395
2395
|
"semantic",
|
|
@@ -2785,9 +2785,33 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2785
2785
|
"additionalProperties": false
|
|
2786
2786
|
}
|
|
2787
2787
|
},
|
|
2788
|
+
{
|
|
2789
|
+
"name": "device_boot",
|
|
2790
|
+
"description": 'Start a device and grant nothing. Needs no approval, so call it as soon as you know which device you want \u2014 a cold boot costs ~20s and this pays it while you keep working. Returns once it is running; a device already up returns immediately. It does NOT let you drive it: device_snapshot and device_act still fail with NO_DEVICE until device_request_control succeeds. Real phones cannot be started this way. See read_manual({ domain: "product", topic: "devices" }).',
|
|
2791
|
+
"inputSchema": {
|
|
2792
|
+
"type": "object",
|
|
2793
|
+
"properties": {
|
|
2794
|
+
"description": {
|
|
2795
|
+
"type": "string",
|
|
2796
|
+
"minLength": 1,
|
|
2797
|
+
"maxLength": 160,
|
|
2798
|
+
"description": "Short explanation of this step for the user watching, in the conversation's language (e.g. 'Open the profile tab'). Shown in place of refs and coordinates."
|
|
2799
|
+
},
|
|
2800
|
+
"device": {
|
|
2801
|
+
"type": "string",
|
|
2802
|
+
"description": "The id from device_list. A name is matched loosely as a fallback."
|
|
2803
|
+
}
|
|
2804
|
+
},
|
|
2805
|
+
"required": [
|
|
2806
|
+
"description",
|
|
2807
|
+
"device"
|
|
2808
|
+
],
|
|
2809
|
+
"additionalProperties": false
|
|
2810
|
+
}
|
|
2811
|
+
},
|
|
2788
2812
|
{
|
|
2789
2813
|
"name": "device_request_control",
|
|
2790
|
-
"description": 'Ask the user to let this session control one device, and wait for their answer. Every other device_* tool fails with NO_DEVICE until this succeeds \u2014 call it first, not after a failure. Pick the device from device_list yourself; a decline carries feedback that often names a different one. Returns it bound and booted. See read_manual({ domain: "product", topic: "devices" }).',
|
|
2814
|
+
"description": 'Ask the user to let this session control one device, and wait for their answer. Every other device_* tool fails with NO_DEVICE until this succeeds \u2014 call it first, not after a failure. Boot it with device_boot first so the wait is not spent on a cold start. Pick the device from device_list yourself; a decline carries feedback that often names a different one. The user may approve it standing for this project, in which case later calls return with no prompt. Returns it bound and booted. See read_manual({ domain: "product", topic: "devices" }).',
|
|
2791
2815
|
"inputSchema": {
|
|
2792
2816
|
"type": "object",
|
|
2793
2817
|
"properties": {
|
|
@@ -19940,7 +19964,11 @@ var init_spawn_env = __esm({
|
|
|
19940
19964
|
"DYLD_FALLBACK_LIBRARY_PATH",
|
|
19941
19965
|
// Proxy bypass must survive E2BIG trimming — loopback MCP depends on it.
|
|
19942
19966
|
"NO_PROXY",
|
|
19943
|
-
"no_proxy"
|
|
19967
|
+
"no_proxy",
|
|
19968
|
+
// Selects which Claude account a session runs on. Trimming it does not fail loudly: the CLI
|
|
19969
|
+
// silently falls back to the default login and the turn bills the wrong subscription.
|
|
19970
|
+
"CLAUDE_SECURESTORAGE_CONFIG_DIR",
|
|
19971
|
+
"CLAUDE_CONFIG_DIR"
|
|
19944
19972
|
]);
|
|
19945
19973
|
ESSENTIAL_PREFIXES = [
|
|
19946
19974
|
"LC_",
|
|
@@ -20135,13 +20163,37 @@ var init_protocol_v149 = __esm({
|
|
|
20135
20163
|
}
|
|
20136
20164
|
});
|
|
20137
20165
|
|
|
20138
|
-
// ../../packages/codex/src/
|
|
20166
|
+
// ../../packages/codex/src/protocol-v153.ts
|
|
20139
20167
|
function asRecord2(value) {
|
|
20140
20168
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
20141
20169
|
}
|
|
20142
20170
|
function readString2(value) {
|
|
20143
20171
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20144
20172
|
}
|
|
20173
|
+
function readCodexAsyncUserInputQuestions(value) {
|
|
20174
|
+
if (!Array.isArray(value)) return void 0;
|
|
20175
|
+
const questions = value.flatMap((entry) => {
|
|
20176
|
+
const question = asRecord2(entry);
|
|
20177
|
+
const title = readString2(question?.title);
|
|
20178
|
+
if (!title) return [];
|
|
20179
|
+
const options = Array.isArray(question?.options) ? question.options.map(readString2).filter((option) => option !== null) : null;
|
|
20180
|
+
return [{ title, options }];
|
|
20181
|
+
});
|
|
20182
|
+
return questions.length > 0 ? questions : void 0;
|
|
20183
|
+
}
|
|
20184
|
+
var init_protocol_v153 = __esm({
|
|
20185
|
+
"../../packages/codex/src/protocol-v153.ts"() {
|
|
20186
|
+
"use strict";
|
|
20187
|
+
}
|
|
20188
|
+
});
|
|
20189
|
+
|
|
20190
|
+
// ../../packages/codex/src/agent-event-mapper.ts
|
|
20191
|
+
function asRecord3(value) {
|
|
20192
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
20193
|
+
}
|
|
20194
|
+
function readString3(value) {
|
|
20195
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20196
|
+
}
|
|
20145
20197
|
function readNumber2(value) {
|
|
20146
20198
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
20147
20199
|
if (typeof value === "string") {
|
|
@@ -20155,7 +20207,7 @@ function readBoolean(value) {
|
|
|
20155
20207
|
}
|
|
20156
20208
|
function readStringArray(value) {
|
|
20157
20209
|
if (!Array.isArray(value)) return [];
|
|
20158
|
-
return value.map(
|
|
20210
|
+
return value.map(readString3).filter((entry) => entry !== null);
|
|
20159
20211
|
}
|
|
20160
20212
|
function uniqueStrings(values) {
|
|
20161
20213
|
const result = [];
|
|
@@ -20166,30 +20218,30 @@ function uniqueStrings(values) {
|
|
|
20166
20218
|
return result;
|
|
20167
20219
|
}
|
|
20168
20220
|
function readTextPart(value) {
|
|
20169
|
-
const direct =
|
|
20221
|
+
const direct = readString3(value);
|
|
20170
20222
|
if (direct !== null) return direct;
|
|
20171
|
-
const rec =
|
|
20223
|
+
const rec = asRecord3(value);
|
|
20172
20224
|
if (!rec) return null;
|
|
20173
|
-
return
|
|
20225
|
+
return readString3(rec.text) ?? readString3(rec.summaryText) ?? readString3(rec.summary_text) ?? readString3(rec.content);
|
|
20174
20226
|
}
|
|
20175
20227
|
function readTextParts(value) {
|
|
20176
20228
|
if (!Array.isArray(value)) return [];
|
|
20177
20229
|
return value.map(readTextPart).filter((entry) => entry !== null && entry.length > 0);
|
|
20178
20230
|
}
|
|
20179
20231
|
function readCodexItemId(rec) {
|
|
20180
|
-
return
|
|
20232
|
+
return readString3(rec.itemId) ?? readString3(rec.item_id) ?? readString3(rec.id) ?? readString3(asRecord3(rec.item)?.id);
|
|
20181
20233
|
}
|
|
20182
20234
|
function readCodexDeltaText(rec) {
|
|
20183
|
-
return
|
|
20235
|
+
return readString3(rec.delta) ?? readString3(rec.textDelta) ?? readString3(rec.text_delta) ?? readString3(rec.summaryTextDelta) ?? readString3(rec.summary_text_delta) ?? readString3(rec.summaryDelta) ?? readString3(rec.summary_delta) ?? readString3(rec.text) ?? readString3(rec.summaryText) ?? readString3(rec.summary_text) ?? "";
|
|
20184
20236
|
}
|
|
20185
20237
|
function mapPatchChangeKind(raw) {
|
|
20186
|
-
const direct =
|
|
20238
|
+
const direct = readString3(raw);
|
|
20187
20239
|
if (direct === "add" || direct === "delete" || direct === "update") return direct;
|
|
20188
|
-
const kind =
|
|
20240
|
+
const kind = readString3(asRecord3(raw)?.type);
|
|
20189
20241
|
return kind === "add" || kind === "delete" || kind === "update" ? kind : "update";
|
|
20190
20242
|
}
|
|
20191
20243
|
function mapCommandExecutionStatus(raw) {
|
|
20192
|
-
switch (
|
|
20244
|
+
switch (readString3(raw)) {
|
|
20193
20245
|
case "in_progress":
|
|
20194
20246
|
case "inProgress":
|
|
20195
20247
|
return "in_progress";
|
|
@@ -20201,11 +20253,11 @@ function mapCommandExecutionStatus(raw) {
|
|
|
20201
20253
|
}
|
|
20202
20254
|
}
|
|
20203
20255
|
function mapPatchApplyStatus(raw) {
|
|
20204
|
-
const status =
|
|
20256
|
+
const status = readString3(raw);
|
|
20205
20257
|
return status === "failed" || status === "declined" ? "failed" : "completed";
|
|
20206
20258
|
}
|
|
20207
20259
|
function mapMcpToolCallStatus(raw) {
|
|
20208
|
-
switch (
|
|
20260
|
+
switch (readString3(raw)) {
|
|
20209
20261
|
case "in_progress":
|
|
20210
20262
|
case "inProgress":
|
|
20211
20263
|
return "in_progress";
|
|
@@ -20216,7 +20268,7 @@ function mapMcpToolCallStatus(raw) {
|
|
|
20216
20268
|
}
|
|
20217
20269
|
}
|
|
20218
20270
|
function normalizeCollabTool(value) {
|
|
20219
|
-
switch (
|
|
20271
|
+
switch (readString3(value)) {
|
|
20220
20272
|
case "spawnAgent":
|
|
20221
20273
|
case "spawn_agent":
|
|
20222
20274
|
return "spawnAgent";
|
|
@@ -20237,7 +20289,7 @@ function normalizeCollabTool(value) {
|
|
|
20237
20289
|
}
|
|
20238
20290
|
}
|
|
20239
20291
|
function normalizeCollabAgentStatus(value) {
|
|
20240
|
-
switch (
|
|
20292
|
+
switch (readString3(value)) {
|
|
20241
20293
|
case "pendingInit":
|
|
20242
20294
|
case "pending_init":
|
|
20243
20295
|
return "pendingInit";
|
|
@@ -20263,45 +20315,49 @@ function buildCodexReasoningItem(id, text, previous, now = Date.now) {
|
|
|
20263
20315
|
return { id, type: "reasoning", text, startedAt, endedAt: timestamp };
|
|
20264
20316
|
}
|
|
20265
20317
|
function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
20266
|
-
const rec =
|
|
20318
|
+
const rec = asRecord3(raw);
|
|
20267
20319
|
if (!rec) return null;
|
|
20268
|
-
const type =
|
|
20269
|
-
const id =
|
|
20320
|
+
const type = readString3(rec.type);
|
|
20321
|
+
const id = readString3(rec.id) ?? previous?.id;
|
|
20270
20322
|
if (!type || !id) return null;
|
|
20271
20323
|
switch (type) {
|
|
20272
20324
|
case "agent_message":
|
|
20273
|
-
case "agentMessage":
|
|
20325
|
+
case "agentMessage": {
|
|
20326
|
+
const previousMessage = previous?.type === "agent_message" ? previous : void 0;
|
|
20327
|
+
const questions = readCodexAsyncUserInputQuestions(rec.questions) ?? previousMessage?.questions;
|
|
20274
20328
|
return {
|
|
20275
20329
|
id,
|
|
20276
20330
|
type: "agent_message",
|
|
20277
|
-
text:
|
|
20278
|
-
...readCodexAgentMessageDelivery(rec.delivery) ??
|
|
20331
|
+
text: readString3(rec.text) ?? previousMessage?.text ?? "",
|
|
20332
|
+
...readCodexAgentMessageDelivery(rec.delivery) ?? previousMessage?.delivery ? { delivery: "async" } : {},
|
|
20333
|
+
...questions ? { questions } : {}
|
|
20279
20334
|
};
|
|
20335
|
+
}
|
|
20280
20336
|
case "reasoning": {
|
|
20281
|
-
const text =
|
|
20337
|
+
const text = readString3(rec.text) || readTextParts(rec.summary).join("\n\n") || readTextParts(rec.content).join("\n\n") || (previous?.type === "reasoning" ? previous.text : "");
|
|
20282
20338
|
return buildCodexReasoningItem(id, text, previous, now);
|
|
20283
20339
|
}
|
|
20284
20340
|
case "command_execution":
|
|
20285
20341
|
case "commandExecution": {
|
|
20286
20342
|
const prev = previous?.type === "command_execution" ? previous : null;
|
|
20287
20343
|
const actions = Array.isArray(rec.commandActions) ? rec.commandActions.map((entry) => {
|
|
20288
|
-
const action =
|
|
20344
|
+
const action = asRecord3(entry);
|
|
20289
20345
|
if (!action) return null;
|
|
20290
20346
|
return {
|
|
20291
|
-
type:
|
|
20292
|
-
...action.command != null ? { command:
|
|
20293
|
-
...action.name != null ? { name:
|
|
20294
|
-
...action.path != null ? { path:
|
|
20295
|
-
...action.query != null ? { query:
|
|
20347
|
+
type: readString3(action.type) ?? "unknown",
|
|
20348
|
+
...action.command != null ? { command: readString3(action.command) ?? void 0 } : {},
|
|
20349
|
+
...action.name != null ? { name: readString3(action.name) ?? void 0 } : {},
|
|
20350
|
+
...action.path != null ? { path: readString3(action.path) ?? void 0 } : {},
|
|
20351
|
+
...action.query != null ? { query: readString3(action.query) ?? void 0 } : {}
|
|
20296
20352
|
};
|
|
20297
20353
|
}).filter((entry) => entry !== null) : void 0;
|
|
20298
20354
|
const exitCode = readNumber2(rec.exitCode) ?? readNumber2(rec.exit_code);
|
|
20299
20355
|
return {
|
|
20300
20356
|
id,
|
|
20301
20357
|
type: "command_execution",
|
|
20302
|
-
command:
|
|
20358
|
+
command: readString3(rec.command) ?? prev?.command ?? "",
|
|
20303
20359
|
aggregatedOutput: capAggregatedOutput(
|
|
20304
|
-
|
|
20360
|
+
readString3(rec.aggregatedOutput) ?? readString3(rec.aggregated_output) ?? prev?.aggregatedOutput ?? ""
|
|
20305
20361
|
),
|
|
20306
20362
|
...exitCode !== null ? { exitCode } : {},
|
|
20307
20363
|
status: mapCommandExecutionStatus(rec.status ?? prev?.status),
|
|
@@ -20311,10 +20367,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20311
20367
|
case "file_change":
|
|
20312
20368
|
case "fileChange": {
|
|
20313
20369
|
const changes = Array.isArray(rec.changes) ? rec.changes.map((entry) => {
|
|
20314
|
-
const change =
|
|
20315
|
-
const path =
|
|
20370
|
+
const change = asRecord3(entry);
|
|
20371
|
+
const path = readString3(change?.path);
|
|
20316
20372
|
if (!path) return null;
|
|
20317
|
-
const diff =
|
|
20373
|
+
const diff = readString3(change?.diff);
|
|
20318
20374
|
return { path, kind: mapPatchChangeKind(change?.kind), ...diff !== null ? { diff } : {} };
|
|
20319
20375
|
}).filter((entry) => entry !== null) : previous?.type === "file_change" ? previous.changes : [];
|
|
20320
20376
|
return {
|
|
@@ -20327,19 +20383,19 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20327
20383
|
case "mcp_tool_call":
|
|
20328
20384
|
case "mcpToolCall": {
|
|
20329
20385
|
const prev = previous?.type === "mcp_tool_call" ? previous : null;
|
|
20330
|
-
const result =
|
|
20331
|
-
const error51 =
|
|
20386
|
+
const result = asRecord3(rec.result);
|
|
20387
|
+
const error51 = asRecord3(rec.error);
|
|
20332
20388
|
return {
|
|
20333
20389
|
id,
|
|
20334
20390
|
type: "mcp_tool_call",
|
|
20335
|
-
server:
|
|
20336
|
-
tool:
|
|
20391
|
+
server: readString3(rec.server) ?? prev?.server ?? "",
|
|
20392
|
+
tool: readString3(rec.tool) ?? prev?.tool ?? "",
|
|
20337
20393
|
arguments: rec.arguments ?? prev?.arguments ?? {},
|
|
20338
20394
|
...result ? { result: {
|
|
20339
20395
|
content: Array.isArray(result.content) ? result.content : [],
|
|
20340
20396
|
structuredContent: result.structuredContent ?? result.structured_content ?? null
|
|
20341
20397
|
} } : prev?.result ? { result: prev.result } : {},
|
|
20342
|
-
...error51 ? { error: { message:
|
|
20398
|
+
...error51 ? { error: { message: readString3(error51.message) ?? "Unknown MCP tool error" } } : prev?.error ? { error: prev.error } : {},
|
|
20343
20399
|
status: mapMcpToolCallStatus(rec.status ?? prev?.status)
|
|
20344
20400
|
};
|
|
20345
20401
|
}
|
|
@@ -20349,20 +20405,20 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20349
20405
|
return {
|
|
20350
20406
|
id,
|
|
20351
20407
|
type: "web_search",
|
|
20352
|
-
query:
|
|
20408
|
+
query: readString3(rec.query) ?? prev?.query ?? "",
|
|
20353
20409
|
status: mapMcpToolCallStatus(rec.status ?? prev?.status)
|
|
20354
20410
|
};
|
|
20355
20411
|
}
|
|
20356
20412
|
case "image_generation":
|
|
20357
20413
|
case "imageGeneration": {
|
|
20358
20414
|
const prev = previous?.type === "image_generation" ? previous : null;
|
|
20359
|
-
const revisedPrompt =
|
|
20360
|
-
const savedPath =
|
|
20415
|
+
const revisedPrompt = readString3(rec.revisedPrompt ?? rec.revised_prompt) ?? prev?.revisedPrompt;
|
|
20416
|
+
const savedPath = readString3(rec.savedPath ?? rec.saved_path) ?? prev?.savedPath;
|
|
20361
20417
|
const failure = readCodexImageGenerationFailure(rec.failure) ?? prev?.failure;
|
|
20362
20418
|
return {
|
|
20363
20419
|
id,
|
|
20364
20420
|
type: "image_generation",
|
|
20365
|
-
status:
|
|
20421
|
+
status: readString3(rec.status) ?? prev?.status ?? "in_progress",
|
|
20366
20422
|
...revisedPrompt ? { revisedPrompt } : {},
|
|
20367
20423
|
...savedPath ? { savedPath } : {},
|
|
20368
20424
|
...failure ? { failure } : {},
|
|
@@ -20372,8 +20428,8 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20372
20428
|
case "todo_list":
|
|
20373
20429
|
case "todoList": {
|
|
20374
20430
|
const items = Array.isArray(rec.items) ? rec.items.map((entry) => {
|
|
20375
|
-
const todo =
|
|
20376
|
-
const text =
|
|
20431
|
+
const todo = asRecord3(entry);
|
|
20432
|
+
const text = readString3(todo?.text);
|
|
20377
20433
|
return text ? { text, completed: readBoolean(todo?.completed) ?? false } : null;
|
|
20378
20434
|
}).filter((entry) => entry !== null) : previous?.type === "todo_list" ? previous.items : [];
|
|
20379
20435
|
return { id, type: "todo_list", items };
|
|
@@ -20382,16 +20438,16 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20382
20438
|
return {
|
|
20383
20439
|
id,
|
|
20384
20440
|
type: "error",
|
|
20385
|
-
message:
|
|
20441
|
+
message: readString3(rec.message) ?? (previous?.type === "error" ? previous.message : "Unknown error")
|
|
20386
20442
|
};
|
|
20387
20443
|
case "plan": {
|
|
20388
|
-
const text =
|
|
20444
|
+
const text = readString3(rec.text);
|
|
20389
20445
|
return text ? buildCodexReasoningItem(id, text, previous, now) : null;
|
|
20390
20446
|
}
|
|
20391
20447
|
case "enteredReviewMode":
|
|
20392
|
-
return { id, type: "review", phase: "entered", text:
|
|
20448
|
+
return { id, type: "review", phase: "entered", text: readString3(rec.text) ?? readString3(rec.review) ?? "" };
|
|
20393
20449
|
case "exitedReviewMode":
|
|
20394
|
-
return { id: `${id}_exit`, type: "review", phase: "exited", text:
|
|
20450
|
+
return { id: `${id}_exit`, type: "review", phase: "exited", text: readString3(rec.text) ?? readString3(rec.review) ?? "" };
|
|
20395
20451
|
case "contextCompaction":
|
|
20396
20452
|
return { id, type: "compaction" };
|
|
20397
20453
|
case "collabAgentToolCall":
|
|
@@ -20399,44 +20455,44 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20399
20455
|
const prev = previous?.type === "collab_tool_call" ? previous : null;
|
|
20400
20456
|
const receiverThreadIds = uniqueStrings([
|
|
20401
20457
|
...readStringArray(rec.receiverThreadIds ?? rec.receiver_thread_ids),
|
|
20402
|
-
|
|
20403
|
-
|
|
20458
|
+
readString3(rec.receiverThreadId ?? rec.receiver_thread_id),
|
|
20459
|
+
readString3(rec.newThreadId ?? rec.new_thread_id)
|
|
20404
20460
|
]);
|
|
20405
20461
|
const agentsStates = { ...prev?.agentsStates ?? {} };
|
|
20406
|
-
const rawStates =
|
|
20462
|
+
const rawStates = asRecord3(rec.agentsStates ?? rec.agents_states);
|
|
20407
20463
|
if (rawStates) {
|
|
20408
20464
|
for (const [agentId, value] of Object.entries(rawStates)) {
|
|
20409
|
-
const state =
|
|
20465
|
+
const state = asRecord3(value);
|
|
20410
20466
|
if (!state) continue;
|
|
20411
20467
|
const prior = prev?.agentsStates?.[agentId];
|
|
20412
20468
|
agentsStates[agentId] = {
|
|
20413
20469
|
...prior,
|
|
20414
20470
|
status: normalizeCollabAgentStatus(state.status) ?? prior?.status ?? "running",
|
|
20415
|
-
...state.message != null ? { message:
|
|
20471
|
+
...state.message != null ? { message: readString3(state.message) ?? void 0 } : {}
|
|
20416
20472
|
};
|
|
20417
20473
|
}
|
|
20418
20474
|
}
|
|
20419
20475
|
const rawAgentStatus = rec.agentStatus ?? rec.agent_status;
|
|
20420
|
-
const agentStatus =
|
|
20476
|
+
const agentStatus = asRecord3(rawAgentStatus);
|
|
20421
20477
|
if (!rawStates && rawAgentStatus != null) {
|
|
20422
20478
|
for (const agentId of receiverThreadIds) {
|
|
20423
20479
|
const prior = prev?.agentsStates?.[agentId];
|
|
20424
20480
|
agentsStates[agentId] = {
|
|
20425
20481
|
...prior,
|
|
20426
20482
|
status: normalizeCollabAgentStatus(agentStatus?.status ?? rawAgentStatus) ?? prior?.status ?? "running",
|
|
20427
|
-
...agentStatus?.message != null ? { message:
|
|
20483
|
+
...agentStatus?.message != null ? { message: readString3(agentStatus.message) ?? void 0 } : {}
|
|
20428
20484
|
};
|
|
20429
20485
|
}
|
|
20430
20486
|
}
|
|
20431
|
-
const rawStatus =
|
|
20487
|
+
const rawStatus = readString3(rec.status);
|
|
20432
20488
|
return {
|
|
20433
20489
|
id,
|
|
20434
20490
|
type: "collab_tool_call",
|
|
20435
20491
|
tool: normalizeCollabTool(rec.tool) ?? prev?.tool ?? "spawnAgent",
|
|
20436
20492
|
status: rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "in_progress",
|
|
20437
|
-
...
|
|
20493
|
+
...readString3(rec.senderThreadId) ?? readString3(rec.sender_thread_id) ?? prev?.senderThreadId ? { senderThreadId: readString3(rec.senderThreadId) ?? readString3(rec.sender_thread_id) ?? prev?.senderThreadId } : {},
|
|
20438
20494
|
receiverThreadIds: receiverThreadIds.length > 0 ? receiverThreadIds : prev?.receiverThreadIds ?? [],
|
|
20439
|
-
...
|
|
20495
|
+
...readString3(rec.prompt) ?? prev?.prompt ? { prompt: readString3(rec.prompt) ?? prev?.prompt } : {},
|
|
20440
20496
|
agentsStates,
|
|
20441
20497
|
...prev?.childItems ? { childItems: prev.childItems } : {}
|
|
20442
20498
|
};
|
|
@@ -20446,10 +20502,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
20446
20502
|
}
|
|
20447
20503
|
}
|
|
20448
20504
|
function mapCodexUsage(raw) {
|
|
20449
|
-
const rec =
|
|
20505
|
+
const rec = asRecord3(raw);
|
|
20450
20506
|
if (!rec) return null;
|
|
20451
20507
|
const parse4 = (value) => {
|
|
20452
|
-
const data =
|
|
20508
|
+
const data = asRecord3(value);
|
|
20453
20509
|
if (!data) return null;
|
|
20454
20510
|
return {
|
|
20455
20511
|
inputTokens: readNumber2(data.inputTokens ?? data.input_tokens) ?? 0,
|
|
@@ -20478,9 +20534,9 @@ function mapCodexUsage(raw) {
|
|
|
20478
20534
|
};
|
|
20479
20535
|
}
|
|
20480
20536
|
function extractError(raw) {
|
|
20481
|
-
const rec =
|
|
20537
|
+
const rec = asRecord3(raw);
|
|
20482
20538
|
if (!rec) return "Codex turn failed";
|
|
20483
|
-
return
|
|
20539
|
+
return readString3(rec.message) ?? readString3(asRecord3(rec.error)?.message) ?? "Codex turn failed";
|
|
20484
20540
|
}
|
|
20485
20541
|
function deriveCodexFinalResponse(items) {
|
|
20486
20542
|
for (let index = items.length - 1; index >= 0; index--) {
|
|
@@ -20519,7 +20575,7 @@ function createCodexAgentEventMapper(options) {
|
|
|
20519
20575
|
};
|
|
20520
20576
|
const finishStatus = () => options.emit({ type: "status_change", status: "idle" });
|
|
20521
20577
|
const startCompaction = (params) => {
|
|
20522
|
-
const turnId =
|
|
20578
|
+
const turnId = readString3(params.turnId) ?? readString3(params.turn_id) ?? currentTurnId;
|
|
20523
20579
|
if (turnId && completedCompactionTurns.has(turnId)) return;
|
|
20524
20580
|
if (activeCompaction && (!activeCompaction.turnId || !turnId || activeCompaction.turnId === turnId)) {
|
|
20525
20581
|
if (!activeCompaction.turnId && turnId) {
|
|
@@ -20539,7 +20595,7 @@ function createCodexAgentEventMapper(options) {
|
|
|
20539
20595
|
options.emit({ type: "status_indicator", indicator: "compacting" });
|
|
20540
20596
|
};
|
|
20541
20597
|
const completeCompaction = (params) => {
|
|
20542
|
-
const turnId =
|
|
20598
|
+
const turnId = readString3(params.turnId) ?? readString3(params.turn_id) ?? currentTurnId;
|
|
20543
20599
|
if (turnId && completedCompactionTurns.has(turnId)) return;
|
|
20544
20600
|
if (!activeCompaction) startCompaction(params);
|
|
20545
20601
|
const current = activeCompaction;
|
|
@@ -20603,7 +20659,7 @@ function createCodexAgentEventMapper(options) {
|
|
|
20603
20659
|
const params = note.params;
|
|
20604
20660
|
switch (note.method) {
|
|
20605
20661
|
case "thread/started": {
|
|
20606
|
-
const threadId =
|
|
20662
|
+
const threadId = readString3(asRecord3(params.thread)?.id);
|
|
20607
20663
|
if (threadId && threadId !== currentThreadId) {
|
|
20608
20664
|
currentThreadId = threadId;
|
|
20609
20665
|
options.emit({ type: "codex_thread_started", messageId: options.messageId, threadId });
|
|
@@ -20612,14 +20668,14 @@ function createCodexAgentEventMapper(options) {
|
|
|
20612
20668
|
}
|
|
20613
20669
|
case "item/started":
|
|
20614
20670
|
case "item/completed": {
|
|
20615
|
-
const raw =
|
|
20671
|
+
const raw = asRecord3(params.item);
|
|
20616
20672
|
if (!raw) break;
|
|
20617
|
-
if (
|
|
20673
|
+
if (readString3(raw.type) === "contextCompaction") {
|
|
20618
20674
|
if (note.method === "item/started") startCompaction(params);
|
|
20619
20675
|
else completeCompaction(params);
|
|
20620
20676
|
break;
|
|
20621
20677
|
}
|
|
20622
|
-
const previous =
|
|
20678
|
+
const previous = readString3(raw.id) ? itemMap.get(readString3(raw.id)) : void 0;
|
|
20623
20679
|
if (previous?.type === "plan" && note.method === "item/completed") {
|
|
20624
20680
|
emitItem("completed", previous);
|
|
20625
20681
|
break;
|
|
@@ -20647,12 +20703,13 @@ function createCodexAgentEventMapper(options) {
|
|
|
20647
20703
|
id: itemId,
|
|
20648
20704
|
type: "agent_message",
|
|
20649
20705
|
text: `${previous?.type === "agent_message" ? previous.text : ""}${delta}`,
|
|
20650
|
-
...previous?.type === "agent_message" && previous.delivery === "async" ? { delivery: "async" } : {}
|
|
20706
|
+
...previous?.type === "agent_message" && previous.delivery === "async" ? { delivery: "async" } : {},
|
|
20707
|
+
...previous?.type === "agent_message" && previous.questions ? { questions: previous.questions } : {}
|
|
20651
20708
|
});
|
|
20652
20709
|
break;
|
|
20653
20710
|
}
|
|
20654
20711
|
case "autoApprovalReview/strictReviewRequired": {
|
|
20655
|
-
const turnId =
|
|
20712
|
+
const turnId = readString3(params.turnId) ?? currentTurnId ?? "current";
|
|
20656
20713
|
emitItem("completed", {
|
|
20657
20714
|
id: `strict_review_${turnId}`,
|
|
20658
20715
|
type: "error",
|
|
@@ -20710,12 +20767,12 @@ function createCodexAgentEventMapper(options) {
|
|
|
20710
20767
|
case "turn/plan/updated": {
|
|
20711
20768
|
const rawPlan = Array.isArray(params.plan) ? params.plan : [];
|
|
20712
20769
|
const todoItems = rawPlan.map((entry) => {
|
|
20713
|
-
const step =
|
|
20714
|
-
const text =
|
|
20715
|
-
return text ? { text, completed:
|
|
20770
|
+
const step = asRecord3(entry);
|
|
20771
|
+
const text = readString3(step?.step);
|
|
20772
|
+
return text ? { text, completed: readString3(step?.status) === "completed" } : null;
|
|
20716
20773
|
}).filter((entry) => entry !== null);
|
|
20717
20774
|
if (todoItems.length > 0) {
|
|
20718
|
-
const turnId =
|
|
20775
|
+
const turnId = readString3(params.turnId) ?? readString3(params.turn_id) ?? currentTurnId ?? "current";
|
|
20719
20776
|
emitItem("updated", { id: `todo_${turnId}`, type: "todo_list", items: todoItems });
|
|
20720
20777
|
}
|
|
20721
20778
|
break;
|
|
@@ -20739,11 +20796,11 @@ function createCodexAgentEventMapper(options) {
|
|
|
20739
20796
|
break;
|
|
20740
20797
|
}
|
|
20741
20798
|
case "mcpServer/startupStatus/updated": {
|
|
20742
|
-
const name =
|
|
20799
|
+
const name = readString3(params.name);
|
|
20743
20800
|
if (!name) break;
|
|
20744
|
-
const rawStatus =
|
|
20801
|
+
const rawStatus = readString3(params.status);
|
|
20745
20802
|
const status = rawStatus === "ready" || rawStatus === "failed" || rawStatus === "cancelled" ? rawStatus : "starting";
|
|
20746
|
-
const failureReason =
|
|
20803
|
+
const failureReason = readString3(params.failureReason) === "reauthenticationRequired" ? "reauthenticationRequired" : void 0;
|
|
20747
20804
|
mcpServers.set(name, { status, ...failureReason ? { failureReason } : {} });
|
|
20748
20805
|
options.emit({
|
|
20749
20806
|
type: "codex_mcp_startup",
|
|
@@ -20763,9 +20820,9 @@ function createCodexAgentEventMapper(options) {
|
|
|
20763
20820
|
}
|
|
20764
20821
|
case "turn/completed":
|
|
20765
20822
|
case "turn/completed/v2": {
|
|
20766
|
-
const turn =
|
|
20767
|
-
currentTurnId =
|
|
20768
|
-
const status =
|
|
20823
|
+
const turn = asRecord3(params.turn);
|
|
20824
|
+
currentTurnId = readString3(turn?.id) ?? currentTurnId;
|
|
20825
|
+
const status = readString3(turn?.status) ?? readString3(params.status) ?? "completed";
|
|
20769
20826
|
if (status === "failed" || status === "error") {
|
|
20770
20827
|
result.error = extractError(turn?.error ?? params);
|
|
20771
20828
|
fail2(result.error, false, readCodexErrorOverrides(turn?.error ?? params));
|
|
@@ -20823,6 +20880,7 @@ var init_agent_event_mapper = __esm({
|
|
|
20823
20880
|
init_agent_error();
|
|
20824
20881
|
init_codex_command_output();
|
|
20825
20882
|
init_protocol_v149();
|
|
20883
|
+
init_protocol_v153();
|
|
20826
20884
|
}
|
|
20827
20885
|
});
|
|
20828
20886
|
|
|
@@ -21117,8 +21175,8 @@ async function ensureCodexThread(opts) {
|
|
|
21117
21175
|
sandbox: "workspace-write",
|
|
21118
21176
|
...configPayload
|
|
21119
21177
|
});
|
|
21120
|
-
const thread =
|
|
21121
|
-
threadId =
|
|
21178
|
+
const thread = asRecord4(resumed.thread);
|
|
21179
|
+
threadId = readString4(thread?.id) ?? readString4(resumed.id) ?? threadId;
|
|
21122
21180
|
} else {
|
|
21123
21181
|
const started = await opts.client.request("thread/start", {
|
|
21124
21182
|
cwd: opts.cwd,
|
|
@@ -21126,8 +21184,8 @@ async function ensureCodexThread(opts) {
|
|
|
21126
21184
|
sandbox: "workspace-write",
|
|
21127
21185
|
...configPayload
|
|
21128
21186
|
});
|
|
21129
|
-
const thread =
|
|
21130
|
-
threadId =
|
|
21187
|
+
const thread = asRecord4(started.thread);
|
|
21188
|
+
threadId = readString4(thread?.id) ?? readString4(started.id);
|
|
21131
21189
|
}
|
|
21132
21190
|
if (!threadId) {
|
|
21133
21191
|
throw new Error("thread/start did not return a thread id");
|
|
@@ -21207,8 +21265,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
21207
21265
|
sandboxPolicy: buildCodexWorkspaceWriteSandboxPolicy(opts.cwd, opts.additionalDirectories),
|
|
21208
21266
|
...collaborationMode ? { collaborationMode } : {}
|
|
21209
21267
|
}));
|
|
21210
|
-
const turn =
|
|
21211
|
-
turnId =
|
|
21268
|
+
const turn = asRecord4(turnStartResult.turn);
|
|
21269
|
+
turnId = readString4(turn?.id);
|
|
21212
21270
|
}
|
|
21213
21271
|
let finalText = "";
|
|
21214
21272
|
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS;
|
|
@@ -21234,8 +21292,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
21234
21292
|
continue;
|
|
21235
21293
|
}
|
|
21236
21294
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
21237
|
-
const completedTurn =
|
|
21238
|
-
const completedId =
|
|
21295
|
+
const completedTurn = asRecord4(note.params.turn);
|
|
21296
|
+
const completedId = readString4(completedTurn?.id);
|
|
21239
21297
|
if (turnId && completedId && completedId !== turnId) {
|
|
21240
21298
|
continue;
|
|
21241
21299
|
}
|
|
@@ -21250,8 +21308,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
21250
21308
|
});
|
|
21251
21309
|
}
|
|
21252
21310
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
21253
|
-
const completedTurn =
|
|
21254
|
-
const status =
|
|
21311
|
+
const completedTurn = asRecord4(note.params.turn);
|
|
21312
|
+
const status = readString4(completedTurn?.status) ?? readString4(note.params.status);
|
|
21255
21313
|
if (status === "failed" || status === "error") {
|
|
21256
21314
|
throw new Error("Codex turn failed");
|
|
21257
21315
|
}
|
|
@@ -21304,10 +21362,10 @@ function extractAgentTextFromTurn(turn) {
|
|
|
21304
21362
|
let text = "";
|
|
21305
21363
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
21306
21364
|
for (const item of items) {
|
|
21307
|
-
const rec =
|
|
21365
|
+
const rec = asRecord4(item);
|
|
21308
21366
|
if (!rec) continue;
|
|
21309
|
-
if (
|
|
21310
|
-
const t =
|
|
21367
|
+
if (readString4(rec.type) === "agentMessage" || readString4(rec.itemType) === "agentMessage") {
|
|
21368
|
+
const t = readString4(rec.text);
|
|
21311
21369
|
if (t) text += t;
|
|
21312
21370
|
}
|
|
21313
21371
|
}
|
|
@@ -21315,7 +21373,7 @@ function extractAgentTextFromTurn(turn) {
|
|
|
21315
21373
|
}
|
|
21316
21374
|
function applyAgentDelta(note, onDelta) {
|
|
21317
21375
|
if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
|
|
21318
|
-
const delta =
|
|
21376
|
+
const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord4(note.params.item)?.delta);
|
|
21319
21377
|
if (delta) onDelta(delta);
|
|
21320
21378
|
}
|
|
21321
21379
|
}
|
|
@@ -21331,10 +21389,10 @@ function defaultSpawn(command, args, options) {
|
|
|
21331
21389
|
windowsHide: options.windowsHide
|
|
21332
21390
|
});
|
|
21333
21391
|
}
|
|
21334
|
-
function
|
|
21392
|
+
function asRecord4(value) {
|
|
21335
21393
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
21336
21394
|
}
|
|
21337
|
-
function
|
|
21395
|
+
function readString4(value) {
|
|
21338
21396
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
21339
21397
|
}
|
|
21340
21398
|
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS, TURN_WAIT_TIMEOUT_MS, MAX_STDERR_CHARS;
|
|
@@ -21382,10 +21440,10 @@ function applySetAuth(current, request) {
|
|
|
21382
21440
|
}
|
|
21383
21441
|
return { mode, apiKey: normalizeApiKey(apiKey) };
|
|
21384
21442
|
}
|
|
21385
|
-
function
|
|
21443
|
+
function asRecord5(value) {
|
|
21386
21444
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
21387
21445
|
}
|
|
21388
|
-
function
|
|
21446
|
+
function readString5(value) {
|
|
21389
21447
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
21390
21448
|
}
|
|
21391
21449
|
function readBoolean2(value) {
|
|
@@ -21406,25 +21464,25 @@ function parseAccountAuthMode(value) {
|
|
|
21406
21464
|
}
|
|
21407
21465
|
}
|
|
21408
21466
|
function parseAccountStatus(raw) {
|
|
21409
|
-
const account =
|
|
21467
|
+
const account = asRecord5(raw.account);
|
|
21410
21468
|
return {
|
|
21411
21469
|
signedIn: account !== null,
|
|
21412
21470
|
authMode: parseAccountAuthMode(account?.type),
|
|
21413
|
-
email:
|
|
21414
|
-
planType:
|
|
21471
|
+
email: readString5(account?.email),
|
|
21472
|
+
planType: readString5(account?.planType),
|
|
21415
21473
|
requiresOpenaiAuth: readBoolean2(raw.requiresOpenaiAuth) ?? false
|
|
21416
21474
|
};
|
|
21417
21475
|
}
|
|
21418
21476
|
function parseAccountLoginStart(raw) {
|
|
21419
|
-
const loginId =
|
|
21420
|
-
const type =
|
|
21477
|
+
const loginId = readString5(raw.loginId);
|
|
21478
|
+
const type = readString5(raw.type);
|
|
21421
21479
|
if (!loginId || type !== "chatgpt" && type !== "chatgptDeviceCode") {
|
|
21422
21480
|
throw new Error("Codex returned an invalid account login response");
|
|
21423
21481
|
}
|
|
21424
21482
|
const result = { type, loginId };
|
|
21425
|
-
const authUrl =
|
|
21426
|
-
const verificationUrl =
|
|
21427
|
-
const userCode =
|
|
21483
|
+
const authUrl = readString5(raw.authUrl);
|
|
21484
|
+
const verificationUrl = readString5(raw.verificationUrl);
|
|
21485
|
+
const userCode = readString5(raw.userCode);
|
|
21428
21486
|
if (authUrl) result.authUrl = authUrl;
|
|
21429
21487
|
if (verificationUrl) result.verificationUrl = verificationUrl;
|
|
21430
21488
|
if (userCode) result.userCode = userCode;
|
|
@@ -21456,15 +21514,15 @@ function parseRateLimitWindow(raw) {
|
|
|
21456
21514
|
function parseResetCredit(raw) {
|
|
21457
21515
|
if (!raw || typeof raw !== "object") return null;
|
|
21458
21516
|
const rec = raw;
|
|
21459
|
-
const id =
|
|
21517
|
+
const id = readString5(rec.id);
|
|
21460
21518
|
if (!id) return null;
|
|
21461
|
-
const rawStatus =
|
|
21519
|
+
const rawStatus = readString5(rec.status);
|
|
21462
21520
|
const status = rawStatus === "available" || rawStatus === "redeeming" || rawStatus === "redeemed" ? rawStatus : "unknown";
|
|
21463
21521
|
return {
|
|
21464
21522
|
id,
|
|
21465
21523
|
status,
|
|
21466
|
-
title:
|
|
21467
|
-
description:
|
|
21524
|
+
title: readString5(rec.title) ?? null,
|
|
21525
|
+
description: readString5(rec.description) ?? null,
|
|
21468
21526
|
expiresAt: readNumericLike(rec.expiresAt)
|
|
21469
21527
|
};
|
|
21470
21528
|
}
|
|
@@ -21481,7 +21539,7 @@ function parseRateLimits(raw) {
|
|
|
21481
21539
|
return {
|
|
21482
21540
|
primary,
|
|
21483
21541
|
secondary,
|
|
21484
|
-
planType:
|
|
21542
|
+
planType: readString5(snapshot.planType),
|
|
21485
21543
|
resetCredits,
|
|
21486
21544
|
...resetCreditList && resetCreditList.length > 0 ? { resetCreditList } : {}
|
|
21487
21545
|
};
|
|
@@ -21501,18 +21559,18 @@ function parseAccountUsage(raw) {
|
|
|
21501
21559
|
return hasAny ? usage2 : null;
|
|
21502
21560
|
}
|
|
21503
21561
|
function parseThreadUsage(raw) {
|
|
21504
|
-
const rec =
|
|
21505
|
-
const threadId =
|
|
21562
|
+
const rec = asRecord5(raw);
|
|
21563
|
+
const threadId = readString5(rec?.threadId);
|
|
21506
21564
|
const credits = readNumericLike(rec?.estimatedUsageCreditsMicros);
|
|
21507
21565
|
if (!threadId || credits === null) return null;
|
|
21508
21566
|
const groups = Array.isArray(rec?.groups) ? rec.groups.flatMap((value) => {
|
|
21509
|
-
const group =
|
|
21567
|
+
const group = asRecord5(value);
|
|
21510
21568
|
const groupCredits = readNumericLike(group?.estimatedUsageCreditsMicros);
|
|
21511
21569
|
if (!group || groupCredits === null) return [];
|
|
21512
21570
|
return [{
|
|
21513
|
-
model:
|
|
21514
|
-
reasoningEffort:
|
|
21515
|
-
speed:
|
|
21571
|
+
model: readString5(group.model),
|
|
21572
|
+
reasoningEffort: readString5(group.reasoningEffort),
|
|
21573
|
+
speed: readString5(group.speed),
|
|
21516
21574
|
estimatedUsageCreditsMicros: groupCredits,
|
|
21517
21575
|
netNewInputTokens: readNumericLike(group.netNewInputTokens),
|
|
21518
21576
|
cachedInputTokens: readNumericLike(group.cachedInputTokens),
|
|
@@ -21531,12 +21589,12 @@ function parseThreadUsage(raw) {
|
|
|
21531
21589
|
function parseExternalAgentItem(raw) {
|
|
21532
21590
|
if (!raw || typeof raw !== "object") return null;
|
|
21533
21591
|
const rec = raw;
|
|
21534
|
-
const itemType =
|
|
21592
|
+
const itemType = readString5(rec.itemType);
|
|
21535
21593
|
if (!itemType) return null;
|
|
21536
21594
|
return {
|
|
21537
21595
|
itemType,
|
|
21538
|
-
description:
|
|
21539
|
-
cwd:
|
|
21596
|
+
description: readString5(rec.description) ?? "",
|
|
21597
|
+
cwd: readString5(rec.cwd) ?? null,
|
|
21540
21598
|
...rec.details !== void 0 ? { details: rec.details } : {}
|
|
21541
21599
|
};
|
|
21542
21600
|
}
|
|
@@ -21600,7 +21658,7 @@ async function readAccountUsage(client3, threadId) {
|
|
|
21600
21658
|
}
|
|
21601
21659
|
}
|
|
21602
21660
|
function parseResetOutcome(raw) {
|
|
21603
|
-
switch (
|
|
21661
|
+
switch (readString5(raw.outcome)) {
|
|
21604
21662
|
case "reset":
|
|
21605
21663
|
return "reset";
|
|
21606
21664
|
case "nothingToReset":
|
|
@@ -21633,7 +21691,7 @@ async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e
|
|
|
21633
21691
|
scopes: options?.scopes,
|
|
21634
21692
|
timeoutSecs: options?.timeoutSecs
|
|
21635
21693
|
}));
|
|
21636
|
-
const authorizationUrl =
|
|
21694
|
+
const authorizationUrl = readString5(res.authorizationUrl);
|
|
21637
21695
|
if (!authorizationUrl) return { success: false, error: "Codex returned no authorization URL" };
|
|
21638
21696
|
openUrl?.(authorizationUrl);
|
|
21639
21697
|
const effectiveTimeoutMs = typeof options?.timeoutSecs === "number" && options.timeoutSecs > 0 ? options.timeoutSecs * 1e3 : timeoutMs;
|
|
@@ -21641,10 +21699,10 @@ async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e
|
|
|
21641
21699
|
while (Date.now() < deadline) {
|
|
21642
21700
|
const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
|
|
21643
21701
|
if (!notif) continue;
|
|
21644
|
-
if (notif.method === "mcpServer/oauthLogin/completed" &&
|
|
21702
|
+
if (notif.method === "mcpServer/oauthLogin/completed" && readString5(notif.params.name) === serverName && (!options?.threadId || readString5(notif.params.threadId) === options.threadId)) {
|
|
21645
21703
|
return {
|
|
21646
21704
|
success: readBoolean2(notif.params.success) ?? false,
|
|
21647
|
-
error:
|
|
21705
|
+
error: readString5(notif.params.error) ?? void 0,
|
|
21648
21706
|
authorizationUrl
|
|
21649
21707
|
};
|
|
21650
21708
|
}
|
|
@@ -21680,12 +21738,12 @@ async function importExternalAgentConfig(client3, items, timeoutMs = 12e4) {
|
|
|
21680
21738
|
migrationItems: items,
|
|
21681
21739
|
source: "superone"
|
|
21682
21740
|
});
|
|
21683
|
-
const importId =
|
|
21741
|
+
const importId = readString5(res.importId);
|
|
21684
21742
|
const deadline = Date.now() + timeoutMs;
|
|
21685
21743
|
while (Date.now() < deadline) {
|
|
21686
21744
|
const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
|
|
21687
21745
|
if (!notif) continue;
|
|
21688
|
-
if (notif.method === "externalAgentConfig/import/completed" && (!importId ||
|
|
21746
|
+
if (notif.method === "externalAgentConfig/import/completed" && (!importId || readString5(notif.params.importId) === importId)) {
|
|
21689
21747
|
return summarizeImportResults(notif.params.itemTypeResults);
|
|
21690
21748
|
}
|
|
21691
21749
|
}
|
|
@@ -21702,19 +21760,19 @@ async function listPluginInventory(client3, projectPath) {
|
|
|
21702
21760
|
const marketplaces = Array.isArray(result.marketplaces) ? result.marketplaces : [];
|
|
21703
21761
|
const records = [];
|
|
21704
21762
|
for (const rawMarketplace of marketplaces) {
|
|
21705
|
-
const marketplace =
|
|
21763
|
+
const marketplace = asRecord5(rawMarketplace);
|
|
21706
21764
|
if (!marketplace) continue;
|
|
21707
|
-
const marketplaceName =
|
|
21708
|
-
const marketplacePath =
|
|
21765
|
+
const marketplaceName = readString5(marketplace.name);
|
|
21766
|
+
const marketplacePath = readString5(marketplace.path);
|
|
21709
21767
|
if (!marketplaceName || !marketplacePath) continue;
|
|
21710
21768
|
const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
21711
21769
|
for (const rawPlugin of plugins) {
|
|
21712
|
-
const plugin =
|
|
21770
|
+
const plugin = asRecord5(rawPlugin);
|
|
21713
21771
|
if (!plugin) continue;
|
|
21714
|
-
const key =
|
|
21715
|
-
const name =
|
|
21716
|
-
const source =
|
|
21717
|
-
const sourcePath =
|
|
21772
|
+
const key = readString5(plugin.id);
|
|
21773
|
+
const name = readString5(plugin.name);
|
|
21774
|
+
const source = asRecord5(plugin.source);
|
|
21775
|
+
const sourcePath = readString5(source?.path) ?? void 0;
|
|
21718
21776
|
if (!key || !name) continue;
|
|
21719
21777
|
records.push({
|
|
21720
21778
|
key,
|
|
@@ -21744,8 +21802,8 @@ async function marketplaceAdd(client3, request) {
|
|
|
21744
21802
|
sparsePaths: request.sparsePaths && request.sparsePaths.length > 0 ? request.sparsePaths : void 0
|
|
21745
21803
|
}));
|
|
21746
21804
|
return {
|
|
21747
|
-
marketplaceName:
|
|
21748
|
-
installedRoot:
|
|
21805
|
+
marketplaceName: readString5(result.marketplaceName) ?? "",
|
|
21806
|
+
installedRoot: readString5(result.installedRoot) ?? "",
|
|
21749
21807
|
alreadyAdded: readBoolean2(result.alreadyAdded) ?? false
|
|
21750
21808
|
};
|
|
21751
21809
|
}
|
|
@@ -21761,10 +21819,10 @@ async function marketplaceUpgrade(client3, marketplaceName) {
|
|
|
21761
21819
|
name ? { marketplaceName: name } : {}
|
|
21762
21820
|
);
|
|
21763
21821
|
const errors = Array.isArray(result.errors) ? result.errors.map((raw) => {
|
|
21764
|
-
const rec =
|
|
21822
|
+
const rec = asRecord5(raw);
|
|
21765
21823
|
if (!rec) return null;
|
|
21766
|
-
const marketplaceName2 =
|
|
21767
|
-
const message =
|
|
21824
|
+
const marketplaceName2 = readString5(rec.marketplaceName) ?? readString5(rec.name);
|
|
21825
|
+
const message = readString5(rec.message) ?? readString5(rec.error);
|
|
21768
21826
|
if (!marketplaceName2 || !message) return null;
|
|
21769
21827
|
return { marketplaceName: marketplaceName2, message };
|
|
21770
21828
|
}).filter((e) => e !== null) : [];
|
|
@@ -21825,6 +21883,7 @@ var init_src = __esm({
|
|
|
21825
21883
|
init_fork_thread();
|
|
21826
21884
|
init_agent_event_mapper();
|
|
21827
21885
|
init_protocol_v149();
|
|
21886
|
+
init_protocol_v153();
|
|
21828
21887
|
}
|
|
21829
21888
|
});
|
|
21830
21889
|
|
|
@@ -21921,6 +21980,7 @@ var init_superone_host_owned_tools = __esm({
|
|
|
21921
21980
|
];
|
|
21922
21981
|
DEVICE_AGENT_TOOL_NAMES = [
|
|
21923
21982
|
"device_list",
|
|
21983
|
+
"device_boot",
|
|
21924
21984
|
"device_request_control",
|
|
21925
21985
|
"device_snapshot",
|
|
21926
21986
|
"device_query",
|
|
@@ -22752,7 +22812,7 @@ var init_agent_event_mapper2 = __esm({
|
|
|
22752
22812
|
});
|
|
22753
22813
|
|
|
22754
22814
|
// ../../packages/claude/src/map-sdk-message.ts
|
|
22755
|
-
function
|
|
22815
|
+
function asRecord6(value) {
|
|
22756
22816
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
22757
22817
|
return value;
|
|
22758
22818
|
}
|
|
@@ -22795,11 +22855,11 @@ function applySdkMessage(message, state, emit) {
|
|
|
22795
22855
|
const sessionId = sessionIdOf2(record2);
|
|
22796
22856
|
const parentToolUseId = typeof record2.parent_tool_use_id === "string" ? record2.parent_tool_use_id : null;
|
|
22797
22857
|
if (record2.type === "stream_event") {
|
|
22798
|
-
const event =
|
|
22858
|
+
const event = asRecord6(record2.event);
|
|
22799
22859
|
if (!event) return emptyApply(sessionId);
|
|
22800
22860
|
const index = typeof event.index === "number" ? event.index : null;
|
|
22801
22861
|
if (event.type === "content_block_start") {
|
|
22802
|
-
const block =
|
|
22862
|
+
const block = asRecord6(event.content_block);
|
|
22803
22863
|
if (!block) return emptyApply(sessionId);
|
|
22804
22864
|
if (block.type === "text" && index != null) {
|
|
22805
22865
|
state.indexToKind.set(index, "text");
|
|
@@ -22831,7 +22891,7 @@ function applySdkMessage(message, state, emit) {
|
|
|
22831
22891
|
return emptyApply(sessionId);
|
|
22832
22892
|
}
|
|
22833
22893
|
if (event.type === "content_block_delta") {
|
|
22834
|
-
const delta =
|
|
22894
|
+
const delta = asRecord6(event.delta);
|
|
22835
22895
|
if (!delta) return emptyApply(sessionId);
|
|
22836
22896
|
if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
|
|
22837
22897
|
return {
|
|
@@ -22865,10 +22925,10 @@ function applySdkMessage(message, state, emit) {
|
|
|
22865
22925
|
return emptyApply(sessionId);
|
|
22866
22926
|
}
|
|
22867
22927
|
if (record2.type === "assistant") {
|
|
22868
|
-
const messageBody =
|
|
22928
|
+
const messageBody = asRecord6(record2.message);
|
|
22869
22929
|
const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
|
|
22870
22930
|
for (const raw of content) {
|
|
22871
|
-
const block =
|
|
22931
|
+
const block = asRecord6(raw);
|
|
22872
22932
|
if (!block || block.type !== "tool_use") continue;
|
|
22873
22933
|
const toolUseId = typeof block.id === "string" && block.id.length > 0 ? block.id : null;
|
|
22874
22934
|
const toolName = typeof block.name === "string" && block.name.length > 0 ? block.name : "unknown";
|
|
@@ -22895,10 +22955,10 @@ function applySdkMessage(message, state, emit) {
|
|
|
22895
22955
|
return emptyApply(sessionId);
|
|
22896
22956
|
}
|
|
22897
22957
|
if (record2.type === "user") {
|
|
22898
|
-
const messageBody =
|
|
22958
|
+
const messageBody = asRecord6(record2.message);
|
|
22899
22959
|
const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
|
|
22900
22960
|
for (const raw of content) {
|
|
22901
|
-
const block =
|
|
22961
|
+
const block = asRecord6(raw);
|
|
22902
22962
|
if (!block || block.type !== "tool_result") continue;
|
|
22903
22963
|
const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : typeof block.toolUseId === "string" ? block.toolUseId : null;
|
|
22904
22964
|
if (!toolUseId) continue;
|
|
@@ -23077,7 +23137,7 @@ var init_ask_user_question = __esm({
|
|
|
23077
23137
|
});
|
|
23078
23138
|
|
|
23079
23139
|
// ../../packages/claude/src/ask-user-question-bridge.ts
|
|
23080
|
-
function
|
|
23140
|
+
function asRecord7(value) {
|
|
23081
23141
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
23082
23142
|
}
|
|
23083
23143
|
async function resolveAskUserQuestion(params) {
|
|
@@ -23086,7 +23146,7 @@ async function resolveAskUserQuestion(params) {
|
|
|
23086
23146
|
return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
|
|
23087
23147
|
}
|
|
23088
23148
|
const previewFormat = asQuestionPreviewFormat(params.previewFormat);
|
|
23089
|
-
const rawInput =
|
|
23149
|
+
const rawInput = asRecord7(input);
|
|
23090
23150
|
const baseInput = rawInput ? { ...rawInput, ...previewFormat ? { previewFormat } : {} } : null;
|
|
23091
23151
|
const answer = await onQuestion({
|
|
23092
23152
|
interactionId,
|
|
@@ -23095,9 +23155,9 @@ async function resolveAskUserQuestion(params) {
|
|
|
23095
23155
|
toolUseId,
|
|
23096
23156
|
input: baseInput ?? void 0
|
|
23097
23157
|
});
|
|
23098
|
-
const record2 =
|
|
23158
|
+
const record2 = asRecord7(answer);
|
|
23099
23159
|
const answers = record2 && "answers" in record2 ? record2.answers : answer;
|
|
23100
|
-
const answerMap =
|
|
23160
|
+
const answerMap = asRecord7(answers);
|
|
23101
23161
|
const updatedInput = {
|
|
23102
23162
|
...baseInput,
|
|
23103
23163
|
...buildAnsweredQuestionInput({
|
|
@@ -23888,7 +23948,7 @@ var init_content_delta = __esm({
|
|
|
23888
23948
|
});
|
|
23889
23949
|
|
|
23890
23950
|
// ../../packages/shared/src/node-session-event-map.ts
|
|
23891
|
-
function
|
|
23951
|
+
function asRecord8(value) {
|
|
23892
23952
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
23893
23953
|
return value;
|
|
23894
23954
|
}
|
|
@@ -23920,7 +23980,7 @@ function stamp(event, ctx, sequence) {
|
|
|
23920
23980
|
}
|
|
23921
23981
|
function mapQuestionRequest(payload, fallbackId) {
|
|
23922
23982
|
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
23923
|
-
const input =
|
|
23983
|
+
const input = asRecord8(payload.input);
|
|
23924
23984
|
const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
|
|
23925
23985
|
const questions = [];
|
|
23926
23986
|
for (const q2 of rawQuestions) {
|
|
@@ -23959,7 +24019,7 @@ function mapQuestionRequest(payload, fallbackId) {
|
|
|
23959
24019
|
}
|
|
23960
24020
|
function mapPlanRequest(payload, fallbackId) {
|
|
23961
24021
|
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
23962
|
-
const input =
|
|
24022
|
+
const input = asRecord8(payload.input);
|
|
23963
24023
|
let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
|
|
23964
24024
|
if (!planContent && input.plan && typeof input.plan === "object") {
|
|
23965
24025
|
try {
|
|
@@ -24025,7 +24085,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
24025
24085
|
if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
|
|
24026
24086
|
if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
|
|
24027
24087
|
const eventType = envelope.eventType;
|
|
24028
|
-
const payload =
|
|
24088
|
+
const payload = asRecord8(envelope.payload);
|
|
24029
24089
|
const out = [];
|
|
24030
24090
|
const push = (event) => {
|
|
24031
24091
|
out.push(stamp(event, ctx, envelope.sequence));
|
|
@@ -24051,7 +24111,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
24051
24111
|
break;
|
|
24052
24112
|
}
|
|
24053
24113
|
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
24054
|
-
const rawEvent =
|
|
24114
|
+
const rawEvent = asRecord8(payload.event);
|
|
24055
24115
|
const type = asString2(rawEvent.type);
|
|
24056
24116
|
if (!type) break;
|
|
24057
24117
|
const eventRecord = { ...rawEvent };
|
|
@@ -24061,7 +24121,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
24061
24121
|
delete eventRecord.seq;
|
|
24062
24122
|
delete eventRecord.epoch;
|
|
24063
24123
|
const event = eventRecord;
|
|
24064
|
-
const rawMessageId = type === "message_start" ? asString2(
|
|
24124
|
+
const rawMessageId = type === "message_start" ? asString2(asRecord8(eventRecord.message).id) : asString2(eventRecord.messageId);
|
|
24065
24125
|
if (type === "message_start" && rawMessageId) {
|
|
24066
24126
|
startedAssistantIds.add(rawMessageId);
|
|
24067
24127
|
lastAssistantId = rawMessageId;
|
|
@@ -24240,7 +24300,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
24240
24300
|
requestId: interactionId,
|
|
24241
24301
|
toolName,
|
|
24242
24302
|
toolUseId: asString2(payload.toolUseId),
|
|
24243
|
-
input:
|
|
24303
|
+
input: asRecord8(payload.input),
|
|
24244
24304
|
allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
|
|
24245
24305
|
...requestKind ? {
|
|
24246
24306
|
requestKind
|
|
@@ -24346,7 +24406,7 @@ var init_node_session_event_map = __esm({
|
|
|
24346
24406
|
});
|
|
24347
24407
|
|
|
24348
24408
|
// ../../packages/runtime/src/session/message-catalog.ts
|
|
24349
|
-
function
|
|
24409
|
+
function asRecord9(value) {
|
|
24350
24410
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
24351
24411
|
return value;
|
|
24352
24412
|
}
|
|
@@ -24429,7 +24489,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
24429
24489
|
for (const ev of events) {
|
|
24430
24490
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
24431
24491
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
24432
|
-
const payload =
|
|
24492
|
+
const payload = asRecord9(ev.payload);
|
|
24433
24493
|
switch (ev.eventType) {
|
|
24434
24494
|
case SESSION_DURABLE_EVENT.turnStarted: {
|
|
24435
24495
|
turnKey += 1;
|
|
@@ -24455,10 +24515,10 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
24455
24515
|
break;
|
|
24456
24516
|
}
|
|
24457
24517
|
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
24458
|
-
const raw =
|
|
24518
|
+
const raw = asRecord9(payload.event);
|
|
24459
24519
|
const type = asString3(raw.type);
|
|
24460
24520
|
if (type === "message_start") {
|
|
24461
|
-
const id = asString3(
|
|
24521
|
+
const id = asString3(asRecord9(raw.message).id);
|
|
24462
24522
|
if (id) bindAssistant(id);
|
|
24463
24523
|
} else if (type === "message_complete") {
|
|
24464
24524
|
const id = asString3(raw.messageId);
|
|
@@ -24466,7 +24526,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
24466
24526
|
} else if (type === "content_delta") {
|
|
24467
24527
|
const messageId = asString3(raw.messageId);
|
|
24468
24528
|
if (messageId) bindAssistant(messageId);
|
|
24469
|
-
const delta =
|
|
24529
|
+
const delta = asRecord9(raw.delta);
|
|
24470
24530
|
const dType = asString3(delta.type);
|
|
24471
24531
|
if (dType === "tool_use") {
|
|
24472
24532
|
const toolUseId = asString3(delta.toolUseId);
|
|
@@ -24609,7 +24669,7 @@ function collectContentByAssistantId(events, sessionId) {
|
|
|
24609
24669
|
if (changed) contentById.set(ev.messageId, next);
|
|
24610
24670
|
}
|
|
24611
24671
|
}
|
|
24612
|
-
const payload =
|
|
24672
|
+
const payload = asRecord9(envelope.payload);
|
|
24613
24673
|
if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
24614
24674
|
const blockId = asString3(payload.blockId);
|
|
24615
24675
|
const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
|
|
@@ -24633,7 +24693,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
24633
24693
|
const ev = events[i];
|
|
24634
24694
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
24635
24695
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
24636
|
-
const payload =
|
|
24696
|
+
const payload = asRecord9(ev.payload);
|
|
24637
24697
|
if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
24638
24698
|
if (asString3(payload.blockId) !== blockId) continue;
|
|
24639
24699
|
const checkpointId = asString3(payload.checkpointId);
|
|
@@ -24648,7 +24708,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
24648
24708
|
}
|
|
24649
24709
|
}
|
|
24650
24710
|
if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
|
|
24651
|
-
const raw =
|
|
24711
|
+
const raw = asRecord9(payload.event);
|
|
24652
24712
|
if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
|
|
24653
24713
|
continue;
|
|
24654
24714
|
}
|
|
@@ -50815,7 +50875,7 @@ function toolInputJson(raw) {
|
|
|
50815
50875
|
return "{}";
|
|
50816
50876
|
}
|
|
50817
50877
|
}
|
|
50818
|
-
function
|
|
50878
|
+
function asRecord10(raw) {
|
|
50819
50879
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
|
|
50820
50880
|
return {};
|
|
50821
50881
|
}
|
|
@@ -50959,7 +51019,7 @@ function grokMetaInput(tool) {
|
|
|
50959
51019
|
const xai = meta3["x.ai/tool"];
|
|
50960
51020
|
if (!xai || typeof xai !== "object") return {};
|
|
50961
51021
|
const input = xai.input;
|
|
50962
|
-
return
|
|
51022
|
+
return asRecord10(input);
|
|
50963
51023
|
}
|
|
50964
51024
|
function queryFromWebSearchTitle(title) {
|
|
50965
51025
|
if (!title) return void 0;
|
|
@@ -51222,11 +51282,11 @@ function unwrapMcpEnvelope(tool, raw) {
|
|
|
51222
51282
|
if (!isUseToolEnvelope(tool, raw)) return null;
|
|
51223
51283
|
const id = raw.tool_name;
|
|
51224
51284
|
if (typeof id !== "string" || !id.includes("__")) return null;
|
|
51225
|
-
return { toolName: `mcp__${id}`, input:
|
|
51285
|
+
return { toolName: `mcp__${id}`, input: asRecord10(raw.tool_input) };
|
|
51226
51286
|
}
|
|
51227
51287
|
function normalizeAcpTool(tool, opts) {
|
|
51228
|
-
const raw = { ...grokMetaInput(tool), ...
|
|
51229
|
-
const rawInput =
|
|
51288
|
+
const raw = { ...grokMetaInput(tool), ...asRecord10(tool.rawInput) };
|
|
51289
|
+
const rawInput = asRecord10(tool.rawInput);
|
|
51230
51290
|
const mcp = unwrapMcpEnvelope(tool, rawInput);
|
|
51231
51291
|
if (mcp) return mcp;
|
|
51232
51292
|
if (isUseToolEnvelope(tool, rawInput) && typeof rawInput.tool_name !== "string") return null;
|
|
@@ -51550,7 +51610,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
|
|
|
51550
51610
|
});
|
|
51551
51611
|
}
|
|
51552
51612
|
}
|
|
51553
|
-
function
|
|
51613
|
+
function asRecord11(v3) {
|
|
51554
51614
|
if (!v3 || typeof v3 !== "object" || Array.isArray(v3)) return null;
|
|
51555
51615
|
return v3;
|
|
51556
51616
|
}
|
|
@@ -51583,18 +51643,18 @@ function arrField(o, ...keys) {
|
|
|
51583
51643
|
return void 0;
|
|
51584
51644
|
}
|
|
51585
51645
|
function parseXaiSessionNotificationEnvelope(raw) {
|
|
51586
|
-
const o =
|
|
51646
|
+
const o = asRecord11(raw);
|
|
51587
51647
|
if (!o) return null;
|
|
51588
|
-
const update =
|
|
51648
|
+
const update = asRecord11(o.update);
|
|
51589
51649
|
if (!update) return null;
|
|
51590
51650
|
const sessionId = strField(o, "sessionId", "session_id");
|
|
51591
|
-
const meta3 =
|
|
51651
|
+
const meta3 = asRecord11(o._meta) ?? asRecord11(o.meta);
|
|
51592
51652
|
const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
|
|
51593
51653
|
const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
|
|
51594
51654
|
return { sessionId, update, meta: meta3, eventSeq, eventId };
|
|
51595
51655
|
}
|
|
51596
51656
|
function parseXaiExtParams(raw) {
|
|
51597
|
-
return
|
|
51657
|
+
return asRecord11(raw) ?? {};
|
|
51598
51658
|
}
|
|
51599
51659
|
function parsePlainTextTaskAck(text) {
|
|
51600
51660
|
const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
|
|
@@ -51699,13 +51759,13 @@ function tryParseJsonObject(text) {
|
|
|
51699
51759
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
|
|
51700
51760
|
try {
|
|
51701
51761
|
const v3 = JSON.parse(trimmed);
|
|
51702
|
-
return
|
|
51762
|
+
return asRecord11(v3);
|
|
51703
51763
|
} catch {
|
|
51704
51764
|
const start = trimmed.indexOf("{");
|
|
51705
51765
|
const end = trimmed.lastIndexOf("}");
|
|
51706
51766
|
if (start < 0 || end <= start) return null;
|
|
51707
51767
|
try {
|
|
51708
|
-
return
|
|
51768
|
+
return asRecord11(JSON.parse(trimmed.slice(start, end + 1)));
|
|
51709
51769
|
} catch {
|
|
51710
51770
|
return null;
|
|
51711
51771
|
}
|
|
@@ -51946,7 +52006,7 @@ function mapWorkflowPhases(raw) {
|
|
|
51946
52006
|
if (!raw?.length) return [];
|
|
51947
52007
|
const out = [];
|
|
51948
52008
|
for (const item of raw) {
|
|
51949
|
-
const p3 =
|
|
52009
|
+
const p3 = asRecord11(item);
|
|
51950
52010
|
if (!p3) continue;
|
|
51951
52011
|
const title = strField(p3, "title");
|
|
51952
52012
|
if (!title) continue;
|
|
@@ -51964,7 +52024,7 @@ function mapWorkflowAgents(raw) {
|
|
|
51964
52024
|
if (!raw?.length) return [];
|
|
51965
52025
|
const out = [];
|
|
51966
52026
|
for (const item of raw) {
|
|
51967
|
-
const a =
|
|
52027
|
+
const a = asRecord11(item);
|
|
51968
52028
|
if (!a) continue;
|
|
51969
52029
|
const agentId = strField(a, "agent_id", "agentId");
|
|
51970
52030
|
const label = strField(a, "label") ?? agentId ?? "agent";
|
|
@@ -51990,7 +52050,7 @@ function buildWorkflowPhaseSummary(u2, currentPhase, pauseMessage, lastEvent, la
|
|
|
51990
52050
|
const phaseBits = [];
|
|
51991
52051
|
if (phases?.length) {
|
|
51992
52052
|
for (const p3 of phases) {
|
|
51993
|
-
const ph =
|
|
52053
|
+
const ph = asRecord11(p3);
|
|
51994
52054
|
if (!ph) continue;
|
|
51995
52055
|
const title = strField(ph, "title") ?? "?";
|
|
51996
52056
|
const state = strField(ph, "state") ?? "";
|
|
@@ -52138,7 +52198,7 @@ function mapTaskBackgrounded(u2, state) {
|
|
|
52138
52198
|
}];
|
|
52139
52199
|
}
|
|
52140
52200
|
function mapTaskCompleted(u2, state) {
|
|
52141
|
-
const snapshot =
|
|
52201
|
+
const snapshot = asRecord11(u2.task_snapshot) ?? asRecord11(u2.taskSnapshot) ?? u2;
|
|
52142
52202
|
const taskId = strField(snapshot, "task_id", "taskId");
|
|
52143
52203
|
if (!taskId) return [];
|
|
52144
52204
|
const known = state.bgTaskById.get(taskId);
|
|
@@ -52434,7 +52494,7 @@ function mapResponseStarted(u2, state, ctx) {
|
|
|
52434
52494
|
return event ? [event] : [];
|
|
52435
52495
|
}
|
|
52436
52496
|
function mapResponseCompleted(u2, state, ctx) {
|
|
52437
|
-
const usageRaw =
|
|
52497
|
+
const usageRaw = asRecord11(u2.usage) ?? u2;
|
|
52438
52498
|
const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
|
|
52439
52499
|
const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
|
|
52440
52500
|
const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
|
|
@@ -52449,7 +52509,7 @@ function mapResponseCompleted(u2, state, ctx) {
|
|
|
52449
52509
|
}
|
|
52450
52510
|
function mapTurnCompleted(u2, state, ctx) {
|
|
52451
52511
|
const events = mapTurnStopReason(u2, state);
|
|
52452
|
-
const usageRaw =
|
|
52512
|
+
const usageRaw = asRecord11(u2.usage);
|
|
52453
52513
|
if (!usageRaw) {
|
|
52454
52514
|
resetTurnTokens(state);
|
|
52455
52515
|
return events;
|
|
@@ -52616,7 +52676,7 @@ function mapModelAutoSwitched(u2) {
|
|
|
52616
52676
|
];
|
|
52617
52677
|
}
|
|
52618
52678
|
function mapRetryState(u2) {
|
|
52619
|
-
const nested =
|
|
52679
|
+
const nested = asRecord11(u2.retry_state) ?? asRecord11(u2.retryState) ?? u2;
|
|
52620
52680
|
const type = (strField(nested, "type") ?? "").toLowerCase();
|
|
52621
52681
|
if (type === "retrying") {
|
|
52622
52682
|
const attempt = numField(nested, "attempt") ?? 1;
|
|
@@ -52683,7 +52743,7 @@ function mapAutoRecoveryExhausted(u2) {
|
|
|
52683
52743
|
}];
|
|
52684
52744
|
}
|
|
52685
52745
|
function mapFollowUps(u2) {
|
|
52686
|
-
const meta3 =
|
|
52746
|
+
const meta3 = asRecord11(u2._meta) ?? asRecord11(u2.meta);
|
|
52687
52747
|
if (meta3 && meta3["x.ai/replayed"] === true) return [];
|
|
52688
52748
|
const responseId = strField(u2, "response_id", "responseId");
|
|
52689
52749
|
if (!responseId || responseId.length > 128) return [];
|
|
@@ -52692,7 +52752,7 @@ function mapFollowUps(u2) {
|
|
|
52692
52752
|
let count = 0;
|
|
52693
52753
|
for (const s4 of suggestions) {
|
|
52694
52754
|
if (count >= 6) break;
|
|
52695
|
-
const rec =
|
|
52755
|
+
const rec = asRecord11(s4);
|
|
52696
52756
|
const label = (rec ? strField(rec, "label") : typeof s4 === "string" ? s4 : void 0)?.trim();
|
|
52697
52757
|
if (!label) continue;
|
|
52698
52758
|
const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
|
|
@@ -60541,7 +60601,7 @@ function toolDisplayName(name) {
|
|
|
60541
60601
|
}
|
|
60542
60602
|
function unwrapCursorMcpTool(toolType, args) {
|
|
60543
60603
|
if (toolType.toLowerCase() !== "mcp") return { toolType, args };
|
|
60544
|
-
const rec =
|
|
60604
|
+
const rec = asRecord12(args);
|
|
60545
60605
|
if (!rec) return { toolType, args };
|
|
60546
60606
|
const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
|
|
60547
60607
|
const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
|
|
@@ -60567,12 +60627,12 @@ function idField(obj, ...keys) {
|
|
|
60567
60627
|
return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
|
|
60568
60628
|
}
|
|
60569
60629
|
function extractCursorCallId(update) {
|
|
60570
|
-
const rec =
|
|
60630
|
+
const rec = asRecord12(update);
|
|
60571
60631
|
if (!rec) return null;
|
|
60572
|
-
const nested =
|
|
60632
|
+
const nested = asRecord12(rec.toolCall) ?? asRecord12(rec.message);
|
|
60573
60633
|
return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
|
|
60574
60634
|
}
|
|
60575
|
-
function
|
|
60635
|
+
function asRecord12(value) {
|
|
60576
60636
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
60577
60637
|
return value;
|
|
60578
60638
|
}
|
|
@@ -60586,13 +60646,13 @@ function stringifyPayload(value) {
|
|
|
60586
60646
|
}
|
|
60587
60647
|
}
|
|
60588
60648
|
function extractToolCallParts(update) {
|
|
60589
|
-
const rec =
|
|
60649
|
+
const rec = asRecord12(update) ?? {};
|
|
60590
60650
|
const callId = extractCursorCallId(update);
|
|
60591
|
-
const nested =
|
|
60651
|
+
const nested = asRecord12(rec.toolCall);
|
|
60592
60652
|
if (nested) {
|
|
60593
60653
|
const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
|
|
60594
60654
|
const result = nested.result;
|
|
60595
|
-
const resultRec =
|
|
60655
|
+
const resultRec = asRecord12(result);
|
|
60596
60656
|
const isError = resultRec?.status === "error" || Boolean(rec.isError);
|
|
60597
60657
|
return {
|
|
60598
60658
|
callId,
|
|
@@ -60616,7 +60676,7 @@ function mapTodosPayload(todos) {
|
|
|
60616
60676
|
return {
|
|
60617
60677
|
type: "todos_updated",
|
|
60618
60678
|
todos: todos.map((todo, index) => {
|
|
60619
|
-
const row =
|
|
60679
|
+
const row = asRecord12(todo) ?? {};
|
|
60620
60680
|
const statusRaw = String(row.status ?? "pending");
|
|
60621
60681
|
return {
|
|
60622
60682
|
id: String(row.id ?? index + 1),
|
|
@@ -60645,15 +60705,15 @@ function toolUseEvent(messageId, callId, toolType, args, status) {
|
|
|
60645
60705
|
}
|
|
60646
60706
|
function normalizeCursorToolInput(toolName, args) {
|
|
60647
60707
|
if (toolName.startsWith("mcp__")) return args;
|
|
60648
|
-
const rec =
|
|
60708
|
+
const rec = asRecord12(args);
|
|
60649
60709
|
if (!rec) return args ?? {};
|
|
60650
60710
|
return normalizeTranscriptTool(toolName, rec).input;
|
|
60651
60711
|
}
|
|
60652
60712
|
function mergeCursorToolResultArgs(toolType, args, result) {
|
|
60653
60713
|
if (toolType.toLowerCase() === "mcp") return args;
|
|
60654
|
-
const res =
|
|
60714
|
+
const res = asRecord12(result);
|
|
60655
60715
|
if (!res) return args;
|
|
60656
|
-
const rec =
|
|
60716
|
+
const rec = asRecord12(args);
|
|
60657
60717
|
if (!rec) return args;
|
|
60658
60718
|
const diff = typeof res.diffString === "string" ? res.diffString : void 0;
|
|
60659
60719
|
const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
|
|
@@ -60714,7 +60774,7 @@ function stampParentToolUseId(events, parentToolUseId) {
|
|
|
60714
60774
|
function mapInteractionUpdate(messageId, update, options) {
|
|
60715
60775
|
const events = [];
|
|
60716
60776
|
const type = String(update.type ?? "");
|
|
60717
|
-
const rec =
|
|
60777
|
+
const rec = asRecord12(update) ?? {};
|
|
60718
60778
|
switch (type) {
|
|
60719
60779
|
case "text-delta": {
|
|
60720
60780
|
const text = strField2(update, "text");
|
|
@@ -60754,7 +60814,7 @@ function mapInteractionUpdate(messageId, update, options) {
|
|
|
60754
60814
|
if (!parts.callId) break;
|
|
60755
60815
|
events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
|
|
60756
60816
|
if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
|
|
60757
|
-
const todos =
|
|
60817
|
+
const todos = asRecord12(parts.args)?.todos;
|
|
60758
60818
|
const todoEvent = mapTodosPayload(todos);
|
|
60759
60819
|
if (todoEvent) events.push(todoEvent);
|
|
60760
60820
|
}
|
|
@@ -60791,7 +60851,7 @@ function mapInteractionUpdate(messageId, update, options) {
|
|
|
60791
60851
|
events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
|
|
60792
60852
|
events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
|
|
60793
60853
|
if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
|
|
60794
|
-
const todos =
|
|
60854
|
+
const todos = asRecord12(parts.args)?.todos ?? asRecord12(parts.result)?.todos;
|
|
60795
60855
|
const todoEvent = mapTodosPayload(todos);
|
|
60796
60856
|
if (todoEvent) events.push(todoEvent);
|
|
60797
60857
|
}
|
|
@@ -60896,7 +60956,7 @@ ${text}
|
|
|
60896
60956
|
}
|
|
60897
60957
|
function mapConversationStep(messageId, step, options) {
|
|
60898
60958
|
const events = [];
|
|
60899
|
-
const rec =
|
|
60959
|
+
const rec = asRecord12(step);
|
|
60900
60960
|
if (!rec) return events;
|
|
60901
60961
|
const stepType = strField2(rec, "type");
|
|
60902
60962
|
if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
|
|
@@ -60904,14 +60964,14 @@ function mapConversationStep(messageId, step, options) {
|
|
|
60904
60964
|
}
|
|
60905
60965
|
if (stepType === "toolCall") {
|
|
60906
60966
|
const message = rec.message ?? rec.toolCall ?? rec;
|
|
60907
|
-
const nested =
|
|
60967
|
+
const nested = asRecord12(message);
|
|
60908
60968
|
const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
|
|
60909
60969
|
if (!callId) {
|
|
60910
60970
|
return events;
|
|
60911
60971
|
}
|
|
60912
60972
|
const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
|
|
60913
60973
|
const args = nested?.args ?? nested?.input ?? {};
|
|
60914
|
-
const resultRec =
|
|
60974
|
+
const resultRec = asRecord12(nested?.result);
|
|
60915
60975
|
const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
|
|
60916
60976
|
events.push(toolUseEvent(
|
|
60917
60977
|
messageId,
|
|
@@ -60921,7 +60981,7 @@ function mapConversationStep(messageId, step, options) {
|
|
|
60921
60981
|
"complete"
|
|
60922
60982
|
));
|
|
60923
60983
|
if (toolType === "updateTodos" || toolType === "update_todos") {
|
|
60924
|
-
const todos =
|
|
60984
|
+
const todos = asRecord12(args)?.todos;
|
|
60925
60985
|
const todoEvent = mapTodosPayload(todos);
|
|
60926
60986
|
if (todoEvent) events.push(todoEvent);
|
|
60927
60987
|
}
|
|
@@ -61058,7 +61118,7 @@ var init_cursor_event_map = __esm({
|
|
|
61058
61118
|
observeDelta(update) {
|
|
61059
61119
|
const type = String(update.type ?? "");
|
|
61060
61120
|
if (type === "tool-call-delta") {
|
|
61061
|
-
const taskUpdate =
|
|
61121
|
+
const taskUpdate = asRecord12(update)?.taskUpdate;
|
|
61062
61122
|
if (taskUpdate && typeof taskUpdate === "object") {
|
|
61063
61123
|
this.observeDelta(taskUpdate);
|
|
61064
61124
|
}
|
|
@@ -62439,10 +62499,10 @@ var init_harness_runners = __esm({
|
|
|
62439
62499
|
});
|
|
62440
62500
|
|
|
62441
62501
|
// src/session/codex-live-turn.ts
|
|
62442
|
-
function
|
|
62502
|
+
function asRecord13(value) {
|
|
62443
62503
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
62444
62504
|
}
|
|
62445
|
-
function
|
|
62505
|
+
function readString6(value) {
|
|
62446
62506
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
62447
62507
|
}
|
|
62448
62508
|
function compactRecord3(input) {
|
|
@@ -62470,10 +62530,10 @@ function extractAgentTextFromTurn2(turn) {
|
|
|
62470
62530
|
let text = "";
|
|
62471
62531
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
62472
62532
|
for (const item of items) {
|
|
62473
|
-
const rec =
|
|
62533
|
+
const rec = asRecord13(item);
|
|
62474
62534
|
if (!rec) continue;
|
|
62475
|
-
if (
|
|
62476
|
-
const t =
|
|
62535
|
+
if (readString6(rec.type) === "agentMessage" || readString6(rec.itemType) === "agentMessage") {
|
|
62536
|
+
const t = readString6(rec.text);
|
|
62477
62537
|
if (t) text += t;
|
|
62478
62538
|
}
|
|
62479
62539
|
}
|
|
@@ -62502,8 +62562,8 @@ async function openTurnAndStream(opts) {
|
|
|
62502
62562
|
...collaborationMode ? { collaborationMode } : {}
|
|
62503
62563
|
})
|
|
62504
62564
|
);
|
|
62505
|
-
const turn =
|
|
62506
|
-
const turnId =
|
|
62565
|
+
const turn = asRecord13(turnStartResult.turn);
|
|
62566
|
+
const turnId = readString6(turn?.id);
|
|
62507
62567
|
opts.onTurnStarted?.(turnId);
|
|
62508
62568
|
let finalText = "";
|
|
62509
62569
|
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS2;
|
|
@@ -62530,23 +62590,23 @@ async function openTurnAndStream(opts) {
|
|
|
62530
62590
|
continue;
|
|
62531
62591
|
}
|
|
62532
62592
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
62533
|
-
const completedTurn =
|
|
62534
|
-
const completedId =
|
|
62593
|
+
const completedTurn = asRecord13(note.params.turn);
|
|
62594
|
+
const completedId = readString6(completedTurn?.id);
|
|
62535
62595
|
if (turnId && completedId && completedId !== turnId) continue;
|
|
62536
62596
|
}
|
|
62537
62597
|
if (agentEventMapper) {
|
|
62538
62598
|
const applied = agentEventMapper.apply(note);
|
|
62539
62599
|
if (applied.textDelta) finalText += applied.textDelta;
|
|
62540
62600
|
} else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
|
|
62541
|
-
const delta =
|
|
62601
|
+
const delta = readString6(note.params.delta) ?? readString6(note.params.text) ?? readString6(asRecord13(note.params.item)?.delta);
|
|
62542
62602
|
if (delta) {
|
|
62543
62603
|
finalText += delta;
|
|
62544
62604
|
opts.onDelta?.(delta);
|
|
62545
62605
|
}
|
|
62546
62606
|
}
|
|
62547
62607
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
62548
|
-
const completedTurn =
|
|
62549
|
-
const status =
|
|
62608
|
+
const completedTurn = asRecord13(note.params.turn);
|
|
62609
|
+
const status = readString6(completedTurn?.status) ?? readString6(note.params.status);
|
|
62550
62610
|
if (status === "failed" || status === "error") {
|
|
62551
62611
|
throw new Error("Codex turn failed");
|
|
62552
62612
|
}
|
|
@@ -70307,8 +70367,8 @@ import { fileURLToPath } from "node:url";
|
|
|
70307
70367
|
function resolveCliReleaseVersion() {
|
|
70308
70368
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
70309
70369
|
if (fromEnv) return fromEnv;
|
|
70310
|
-
if ("0.
|
|
70311
|
-
return "0.
|
|
70370
|
+
if ("0.62.0-alpha".trim()) {
|
|
70371
|
+
return "0.62.0-alpha".trim();
|
|
70312
70372
|
}
|
|
70313
70373
|
const fromDist = readDistManifestVersion();
|
|
70314
70374
|
if (fromDist) return fromDist;
|
|
@@ -72421,7 +72481,7 @@ function requireResourceWrite(client3, scope) {
|
|
|
72421
72481
|
if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
|
|
72422
72482
|
return null;
|
|
72423
72483
|
}
|
|
72424
|
-
function
|
|
72484
|
+
function asRecord14(payload) {
|
|
72425
72485
|
return payload && typeof payload === "object" ? payload : {};
|
|
72426
72486
|
}
|
|
72427
72487
|
function mapThrown(err) {
|
|
@@ -72450,7 +72510,7 @@ function manageOpts(ctx) {
|
|
|
72450
72510
|
function handleSkillsList(payload, ctx) {
|
|
72451
72511
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72452
72512
|
if (denied) return denied;
|
|
72453
|
-
const p3 =
|
|
72513
|
+
const p3 = asRecord14(payload);
|
|
72454
72514
|
try {
|
|
72455
72515
|
const projectId = String(p3.projectId ?? "");
|
|
72456
72516
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72470,7 +72530,7 @@ function handleSkillsList(payload, ctx) {
|
|
|
72470
72530
|
function handleSkillsGet(payload, ctx) {
|
|
72471
72531
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72472
72532
|
if (denied) return denied;
|
|
72473
|
-
const p3 =
|
|
72533
|
+
const p3 = asRecord14(payload);
|
|
72474
72534
|
try {
|
|
72475
72535
|
const projectId = String(p3.projectId ?? "");
|
|
72476
72536
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72495,7 +72555,7 @@ function handleSkillsGet(payload, ctx) {
|
|
|
72495
72555
|
function handleSkillsReadFile(payload, ctx) {
|
|
72496
72556
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72497
72557
|
if (denied) return denied;
|
|
72498
|
-
const p3 =
|
|
72558
|
+
const p3 = asRecord14(payload);
|
|
72499
72559
|
try {
|
|
72500
72560
|
const projectId = String(p3.projectId ?? "");
|
|
72501
72561
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72529,7 +72589,7 @@ function handleSkillsReadFile(payload, ctx) {
|
|
|
72529
72589
|
function handleSkillsDelete(payload, ctx) {
|
|
72530
72590
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72531
72591
|
if (denied) return denied;
|
|
72532
|
-
const p3 =
|
|
72592
|
+
const p3 = asRecord14(payload);
|
|
72533
72593
|
try {
|
|
72534
72594
|
const projectId = String(p3.projectId ?? "");
|
|
72535
72595
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72554,7 +72614,7 @@ function handleSkillsDelete(payload, ctx) {
|
|
|
72554
72614
|
function handleSkillsInstall(payload, ctx) {
|
|
72555
72615
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72556
72616
|
if (baseDenied) return baseDenied;
|
|
72557
|
-
const p3 =
|
|
72617
|
+
const p3 = asRecord14(payload);
|
|
72558
72618
|
try {
|
|
72559
72619
|
const projectId = String(p3.projectId ?? "");
|
|
72560
72620
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72588,7 +72648,7 @@ function handleSkillsInstall(payload, ctx) {
|
|
|
72588
72648
|
function handleMcpList(payload, ctx) {
|
|
72589
72649
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72590
72650
|
if (denied) return denied;
|
|
72591
|
-
const p3 =
|
|
72651
|
+
const p3 = asRecord14(payload);
|
|
72592
72652
|
try {
|
|
72593
72653
|
const projectId = String(p3.projectId ?? "");
|
|
72594
72654
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72645,7 +72705,7 @@ function parseMcpWriteConfig(raw) {
|
|
|
72645
72705
|
function handleMcpSave(payload, ctx) {
|
|
72646
72706
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72647
72707
|
if (baseDenied) return baseDenied;
|
|
72648
|
-
const p3 =
|
|
72708
|
+
const p3 = asRecord14(payload);
|
|
72649
72709
|
try {
|
|
72650
72710
|
const projectId = String(p3.projectId ?? "");
|
|
72651
72711
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72675,7 +72735,7 @@ function handleMcpSave(payload, ctx) {
|
|
|
72675
72735
|
function handleMcpToggle(payload, ctx) {
|
|
72676
72736
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72677
72737
|
if (baseDenied) return baseDenied;
|
|
72678
|
-
const p3 =
|
|
72738
|
+
const p3 = asRecord14(payload);
|
|
72679
72739
|
try {
|
|
72680
72740
|
const projectId = String(p3.projectId ?? "");
|
|
72681
72741
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72706,7 +72766,7 @@ function handleMcpToggle(payload, ctx) {
|
|
|
72706
72766
|
function handleMcpDelete(payload, ctx) {
|
|
72707
72767
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72708
72768
|
if (baseDenied) return baseDenied;
|
|
72709
|
-
const p3 =
|
|
72769
|
+
const p3 = asRecord14(payload);
|
|
72710
72770
|
try {
|
|
72711
72771
|
const projectId = String(p3.projectId ?? "");
|
|
72712
72772
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72746,7 +72806,7 @@ function parseMarketplaceScope(raw) {
|
|
|
72746
72806
|
async function handlePluginsList(payload, ctx) {
|
|
72747
72807
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72748
72808
|
if (denied) return denied;
|
|
72749
|
-
const p3 =
|
|
72809
|
+
const p3 = asRecord14(payload);
|
|
72750
72810
|
try {
|
|
72751
72811
|
const projectId = String(p3.projectId ?? "");
|
|
72752
72812
|
projectRoot(ctx.projects, projectId);
|
|
@@ -72793,7 +72853,7 @@ async function handlePluginsList(payload, ctx) {
|
|
|
72793
72853
|
function handlePluginsGet(payload, ctx) {
|
|
72794
72854
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72795
72855
|
if (denied) return denied;
|
|
72796
|
-
const p3 =
|
|
72856
|
+
const p3 = asRecord14(payload);
|
|
72797
72857
|
try {
|
|
72798
72858
|
const projectId = String(p3.projectId ?? "");
|
|
72799
72859
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72817,7 +72877,7 @@ function handlePluginsGet(payload, ctx) {
|
|
|
72817
72877
|
function handlePluginsReadFile(payload, ctx) {
|
|
72818
72878
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72819
72879
|
if (denied) return denied;
|
|
72820
|
-
const p3 =
|
|
72880
|
+
const p3 = asRecord14(payload);
|
|
72821
72881
|
try {
|
|
72822
72882
|
const projectId = String(p3.projectId ?? "");
|
|
72823
72883
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72845,7 +72905,7 @@ function handlePluginsReadFile(payload, ctx) {
|
|
|
72845
72905
|
function handlePluginsDelete(payload, ctx) {
|
|
72846
72906
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72847
72907
|
if (baseDenied) return baseDenied;
|
|
72848
|
-
const p3 =
|
|
72908
|
+
const p3 = asRecord14(payload);
|
|
72849
72909
|
try {
|
|
72850
72910
|
const projectId = String(p3.projectId ?? "");
|
|
72851
72911
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72871,7 +72931,7 @@ function handlePluginsDelete(payload, ctx) {
|
|
|
72871
72931
|
async function handlePluginsInstall(payload, ctx) {
|
|
72872
72932
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72873
72933
|
if (baseDenied) return baseDenied;
|
|
72874
|
-
const p3 =
|
|
72934
|
+
const p3 = asRecord14(payload);
|
|
72875
72935
|
try {
|
|
72876
72936
|
const projectId = String(p3.projectId ?? "");
|
|
72877
72937
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72897,7 +72957,7 @@ async function handlePluginsInstall(payload, ctx) {
|
|
|
72897
72957
|
function handlePluginsUpdate(payload, ctx) {
|
|
72898
72958
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72899
72959
|
if (baseDenied) return baseDenied;
|
|
72900
|
-
const p3 =
|
|
72960
|
+
const p3 = asRecord14(payload);
|
|
72901
72961
|
try {
|
|
72902
72962
|
const projectId = String(p3.projectId ?? "");
|
|
72903
72963
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72923,7 +72983,7 @@ function handlePluginsUpdate(payload, ctx) {
|
|
|
72923
72983
|
function handlePluginsListMarketplace(payload, ctx) {
|
|
72924
72984
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72925
72985
|
if (denied) return denied;
|
|
72926
|
-
const p3 =
|
|
72986
|
+
const p3 = asRecord14(payload);
|
|
72927
72987
|
try {
|
|
72928
72988
|
const projectId = String(p3.projectId ?? "");
|
|
72929
72989
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72945,7 +73005,7 @@ function handlePluginsListMarketplace(payload, ctx) {
|
|
|
72945
73005
|
async function handlePluginsAddMarketplace(payload, ctx) {
|
|
72946
73006
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72947
73007
|
if (baseDenied) return baseDenied;
|
|
72948
|
-
const p3 =
|
|
73008
|
+
const p3 = asRecord14(payload);
|
|
72949
73009
|
try {
|
|
72950
73010
|
const projectId = String(p3.projectId ?? "");
|
|
72951
73011
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72971,7 +73031,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
|
|
|
72971
73031
|
async function handlePluginsRemoveMarketplace(payload, ctx) {
|
|
72972
73032
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72973
73033
|
if (baseDenied) return baseDenied;
|
|
72974
|
-
const p3 =
|
|
73034
|
+
const p3 = asRecord14(payload);
|
|
72975
73035
|
try {
|
|
72976
73036
|
const projectId = String(p3.projectId ?? "");
|
|
72977
73037
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73006,7 +73066,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
73006
73066
|
if (denied) return denied;
|
|
73007
73067
|
const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73008
73068
|
if (adminDenied) return adminDenied;
|
|
73009
|
-
const p3 =
|
|
73069
|
+
const p3 = asRecord14(payload);
|
|
73010
73070
|
try {
|
|
73011
73071
|
const projectId = String(p3.projectId ?? "");
|
|
73012
73072
|
if (projectId) {
|
|
@@ -73028,7 +73088,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
73028
73088
|
function handlePluginsReadMarketplace(payload, ctx) {
|
|
73029
73089
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73030
73090
|
if (denied) return denied;
|
|
73031
|
-
const p3 =
|
|
73091
|
+
const p3 = asRecord14(payload);
|
|
73032
73092
|
try {
|
|
73033
73093
|
const projectId = String(p3.projectId ?? "");
|
|
73034
73094
|
if (projectId) {
|
|
@@ -73059,7 +73119,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
|
|
|
73059
73119
|
function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
73060
73120
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73061
73121
|
if (denied) return denied;
|
|
73062
|
-
const p3 =
|
|
73122
|
+
const p3 = asRecord14(payload);
|
|
73063
73123
|
try {
|
|
73064
73124
|
const projectId = String(p3.projectId ?? "");
|
|
73065
73125
|
if (projectId) {
|
|
@@ -73093,7 +73153,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
|
73093
73153
|
function handleAgentsList(payload, ctx) {
|
|
73094
73154
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73095
73155
|
if (denied) return denied;
|
|
73096
|
-
const p3 =
|
|
73156
|
+
const p3 = asRecord14(payload);
|
|
73097
73157
|
try {
|
|
73098
73158
|
const projectId = String(p3.projectId ?? "");
|
|
73099
73159
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73110,7 +73170,7 @@ function handleAgentsList(payload, ctx) {
|
|
|
73110
73170
|
function handleAgentsReadFile(payload, ctx) {
|
|
73111
73171
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73112
73172
|
if (denied) return denied;
|
|
73113
|
-
const p3 =
|
|
73173
|
+
const p3 = asRecord14(payload);
|
|
73114
73174
|
try {
|
|
73115
73175
|
const projectId = String(p3.projectId ?? "");
|
|
73116
73176
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73142,7 +73202,7 @@ function parseHookSavePayload(raw) {
|
|
|
73142
73202
|
function handleHooksList(payload, ctx) {
|
|
73143
73203
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73144
73204
|
if (denied) return denied;
|
|
73145
|
-
const p3 =
|
|
73205
|
+
const p3 = asRecord14(payload);
|
|
73146
73206
|
try {
|
|
73147
73207
|
const projectId = String(p3.projectId ?? "");
|
|
73148
73208
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73155,7 +73215,7 @@ function handleHooksList(payload, ctx) {
|
|
|
73155
73215
|
function handleHooksSave(payload, ctx) {
|
|
73156
73216
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
73157
73217
|
if (baseDenied) return baseDenied;
|
|
73158
|
-
const p3 =
|
|
73218
|
+
const p3 = asRecord14(payload);
|
|
73159
73219
|
try {
|
|
73160
73220
|
const projectId = String(p3.projectId ?? "");
|
|
73161
73221
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73183,7 +73243,7 @@ function handleHooksSave(payload, ctx) {
|
|
|
73183
73243
|
function handleHooksDelete(payload, ctx) {
|
|
73184
73244
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
73185
73245
|
if (baseDenied) return baseDenied;
|
|
73186
|
-
const p3 =
|
|
73246
|
+
const p3 = asRecord14(payload);
|
|
73187
73247
|
try {
|
|
73188
73248
|
const projectId = String(p3.projectId ?? "");
|
|
73189
73249
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -73282,7 +73342,7 @@ function requireScopes2(client3, scopes) {
|
|
|
73282
73342
|
}
|
|
73283
73343
|
return null;
|
|
73284
73344
|
}
|
|
73285
|
-
function
|
|
73345
|
+
function asRecord15(payload) {
|
|
73286
73346
|
return payload && typeof payload === "object" ? payload : {};
|
|
73287
73347
|
}
|
|
73288
73348
|
function mapThrown2(err) {
|
|
@@ -73373,7 +73433,7 @@ function parseSchedule(raw) {
|
|
|
73373
73433
|
function handleAutomationList(payload, ctx) {
|
|
73374
73434
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
|
|
73375
73435
|
if (denied) return denied;
|
|
73376
|
-
const p3 =
|
|
73436
|
+
const p3 = asRecord15(payload);
|
|
73377
73437
|
const projectId = String(p3.projectId ?? "").trim();
|
|
73378
73438
|
if (!projectId) {
|
|
73379
73439
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -73392,7 +73452,7 @@ function handleAutomationList(payload, ctx) {
|
|
|
73392
73452
|
function handleAutomationCreate(payload, ctx) {
|
|
73393
73453
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73394
73454
|
if (denied) return denied;
|
|
73395
|
-
const p3 =
|
|
73455
|
+
const p3 = asRecord15(payload);
|
|
73396
73456
|
const projectId = String(p3.projectId ?? "").trim();
|
|
73397
73457
|
if (!projectId) {
|
|
73398
73458
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -73429,7 +73489,7 @@ function handleAutomationCreate(payload, ctx) {
|
|
|
73429
73489
|
function handleAutomationUpdate(payload, ctx) {
|
|
73430
73490
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73431
73491
|
if (denied) return denied;
|
|
73432
|
-
const p3 =
|
|
73492
|
+
const p3 = asRecord15(payload);
|
|
73433
73493
|
const automationId = String(p3.automationId ?? p3.id ?? "").trim();
|
|
73434
73494
|
if (!automationId) {
|
|
73435
73495
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -73473,7 +73533,7 @@ function handleAutomationUpdate(payload, ctx) {
|
|
|
73473
73533
|
function handleAutomationDelete(payload, ctx) {
|
|
73474
73534
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73475
73535
|
if (denied) return denied;
|
|
73476
|
-
const p3 =
|
|
73536
|
+
const p3 = asRecord15(payload);
|
|
73477
73537
|
const automationId = String(p3.automationId ?? p3.id ?? "").trim();
|
|
73478
73538
|
if (!automationId) {
|
|
73479
73539
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -73499,7 +73559,7 @@ function handleAutomationDelete(payload, ctx) {
|
|
|
73499
73559
|
async function handleAutomationRunNow(payload, ctx) {
|
|
73500
73560
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73501
73561
|
if (denied) return denied;
|
|
73502
|
-
const p3 =
|
|
73562
|
+
const p3 = asRecord15(payload);
|
|
73503
73563
|
const automationId = String(p3.automationId ?? p3.id ?? "").trim();
|
|
73504
73564
|
if (!automationId) {
|
|
73505
73565
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -73556,7 +73616,7 @@ function requireScopes3(client3, scopes) {
|
|
|
73556
73616
|
}
|
|
73557
73617
|
return null;
|
|
73558
73618
|
}
|
|
73559
|
-
function
|
|
73619
|
+
function asRecord16(payload) {
|
|
73560
73620
|
return payload && typeof payload === "object" ? payload : {};
|
|
73561
73621
|
}
|
|
73562
73622
|
function optionalString(value) {
|
|
@@ -73565,7 +73625,7 @@ function optionalString(value) {
|
|
|
73565
73625
|
function parseAttachments(value) {
|
|
73566
73626
|
if (!Array.isArray(value)) return [];
|
|
73567
73627
|
return value.flatMap((raw) => {
|
|
73568
|
-
const a =
|
|
73628
|
+
const a = asRecord16(raw);
|
|
73569
73629
|
const name = typeof a.name === "string" ? a.name : "";
|
|
73570
73630
|
const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
|
|
73571
73631
|
const data = typeof a.data === "string" ? a.data : "";
|
|
@@ -73578,7 +73638,7 @@ function mapThrown3(err) {
|
|
|
73578
73638
|
function handleDraftList(payload, ctx) {
|
|
73579
73639
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
|
|
73580
73640
|
if (denied) return denied;
|
|
73581
|
-
const p3 =
|
|
73641
|
+
const p3 = asRecord16(payload);
|
|
73582
73642
|
const projectPath = optionalString(p3.projectPath);
|
|
73583
73643
|
try {
|
|
73584
73644
|
return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
|
|
@@ -73589,7 +73649,7 @@ function handleDraftList(payload, ctx) {
|
|
|
73589
73649
|
function handleDraftUpsert(payload, ctx) {
|
|
73590
73650
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73591
73651
|
if (denied) return denied;
|
|
73592
|
-
const p3 =
|
|
73652
|
+
const p3 = asRecord16(payload);
|
|
73593
73653
|
const id = String(p3.id ?? "").trim();
|
|
73594
73654
|
if (!id) {
|
|
73595
73655
|
return { error: { code: "invalid_argument", message: "id is required" } };
|
|
@@ -73620,7 +73680,7 @@ function handleDraftUpsert(payload, ctx) {
|
|
|
73620
73680
|
function handleDraftDelete(payload, ctx) {
|
|
73621
73681
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73622
73682
|
if (denied) return denied;
|
|
73623
|
-
const p3 =
|
|
73683
|
+
const p3 = asRecord16(payload);
|
|
73624
73684
|
const draftId = String(p3.draftId ?? "").trim();
|
|
73625
73685
|
if (!draftId) {
|
|
73626
73686
|
return { error: { code: "invalid_argument", message: "draftId is required" } };
|
|
@@ -73654,7 +73714,7 @@ function requireScopes4(client3, scopes) {
|
|
|
73654
73714
|
}
|
|
73655
73715
|
return null;
|
|
73656
73716
|
}
|
|
73657
|
-
function
|
|
73717
|
+
function asRecord17(payload) {
|
|
73658
73718
|
return payload && typeof payload === "object" ? payload : {};
|
|
73659
73719
|
}
|
|
73660
73720
|
function mapThrown4(err) {
|
|
@@ -73740,7 +73800,7 @@ var CODEX_MUTATING_METHODS = [
|
|
|
73740
73800
|
function handleGetAuthStatus(payload, ctx) {
|
|
73741
73801
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73742
73802
|
if (denied) return denied;
|
|
73743
|
-
const p3 =
|
|
73803
|
+
const p3 = asRecord17(payload);
|
|
73744
73804
|
const projectId = projectIdOf(p3);
|
|
73745
73805
|
if (!projectId) {
|
|
73746
73806
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73753,7 +73813,7 @@ function handleGetAuthStatus(payload, ctx) {
|
|
|
73753
73813
|
function handleSetAuth(payload, ctx) {
|
|
73754
73814
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73755
73815
|
if (denied) return denied;
|
|
73756
|
-
const p3 =
|
|
73816
|
+
const p3 = asRecord17(payload);
|
|
73757
73817
|
const projectId = projectIdOf(p3);
|
|
73758
73818
|
if (!projectId) {
|
|
73759
73819
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73778,7 +73838,7 @@ function handleSetAuth(payload, ctx) {
|
|
|
73778
73838
|
async function handleGetAccountStatus(payload, ctx) {
|
|
73779
73839
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73780
73840
|
if (denied) return denied;
|
|
73781
|
-
const p3 =
|
|
73841
|
+
const p3 = asRecord17(payload);
|
|
73782
73842
|
const projectId = projectIdOf(p3);
|
|
73783
73843
|
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
73784
73844
|
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
@@ -73791,7 +73851,7 @@ async function handleGetAccountStatus(payload, ctx) {
|
|
|
73791
73851
|
async function handleAccountLoginStart(payload, ctx) {
|
|
73792
73852
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73793
73853
|
if (denied) return denied;
|
|
73794
|
-
const p3 =
|
|
73854
|
+
const p3 = asRecord17(payload);
|
|
73795
73855
|
const projectId = projectIdOf(p3);
|
|
73796
73856
|
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
73797
73857
|
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
@@ -73804,7 +73864,7 @@ async function handleAccountLoginStart(payload, ctx) {
|
|
|
73804
73864
|
async function handleAccountLoginCancel(payload, ctx) {
|
|
73805
73865
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73806
73866
|
if (denied) return denied;
|
|
73807
|
-
const p3 =
|
|
73867
|
+
const p3 = asRecord17(payload);
|
|
73808
73868
|
const loginId = typeof p3.loginId === "string" ? p3.loginId.trim() : "";
|
|
73809
73869
|
if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
|
|
73810
73870
|
try {
|
|
@@ -73817,7 +73877,7 @@ async function handleAccountLoginCancel(payload, ctx) {
|
|
|
73817
73877
|
async function handleAccountLogout(payload, ctx) {
|
|
73818
73878
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73819
73879
|
if (denied) return denied;
|
|
73820
|
-
const p3 =
|
|
73880
|
+
const p3 = asRecord17(payload);
|
|
73821
73881
|
const projectId = projectIdOf(p3);
|
|
73822
73882
|
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
73823
73883
|
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
@@ -73830,7 +73890,7 @@ async function handleAccountLogout(payload, ctx) {
|
|
|
73830
73890
|
async function handleGetRateLimits(payload, ctx) {
|
|
73831
73891
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73832
73892
|
if (denied) return denied;
|
|
73833
|
-
const p3 =
|
|
73893
|
+
const p3 = asRecord17(payload);
|
|
73834
73894
|
const projectId = projectIdOf(p3);
|
|
73835
73895
|
if (!projectId) {
|
|
73836
73896
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73857,7 +73917,7 @@ async function handleGetRateLimits(payload, ctx) {
|
|
|
73857
73917
|
async function handleGetAccountUsage(payload, ctx) {
|
|
73858
73918
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73859
73919
|
if (denied) return denied;
|
|
73860
|
-
const p3 =
|
|
73920
|
+
const p3 = asRecord17(payload);
|
|
73861
73921
|
const projectId = projectIdOf(p3);
|
|
73862
73922
|
if (!projectId) {
|
|
73863
73923
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73885,7 +73945,7 @@ async function handleGetAccountUsage(payload, ctx) {
|
|
|
73885
73945
|
async function handleGetServerDiagnostics(payload, ctx) {
|
|
73886
73946
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73887
73947
|
if (denied) return denied;
|
|
73888
|
-
const p3 =
|
|
73948
|
+
const p3 = asRecord17(payload);
|
|
73889
73949
|
const projectId = projectIdOf(p3);
|
|
73890
73950
|
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
73891
73951
|
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
@@ -73903,7 +73963,7 @@ async function handleGetServerDiagnostics(payload, ctx) {
|
|
|
73903
73963
|
async function handleGetConfigRequirements(payload, ctx) {
|
|
73904
73964
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73905
73965
|
if (denied) return denied;
|
|
73906
|
-
const p3 =
|
|
73966
|
+
const p3 = asRecord17(payload);
|
|
73907
73967
|
const projectId = projectIdOf(p3);
|
|
73908
73968
|
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
73909
73969
|
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
@@ -73921,7 +73981,7 @@ async function handleGetConfigRequirements(payload, ctx) {
|
|
|
73921
73981
|
async function handleConsumeRateLimitReset(payload, ctx) {
|
|
73922
73982
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73923
73983
|
if (denied) return denied;
|
|
73924
|
-
const p3 =
|
|
73984
|
+
const p3 = asRecord17(payload);
|
|
73925
73985
|
const projectId = projectIdOf(p3);
|
|
73926
73986
|
if (!projectId) {
|
|
73927
73987
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73951,7 +74011,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
|
|
|
73951
74011
|
async function handleLoginMcpOauth(payload, ctx) {
|
|
73952
74012
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73953
74013
|
if (denied) return denied;
|
|
73954
|
-
const p3 =
|
|
74014
|
+
const p3 = asRecord17(payload);
|
|
73955
74015
|
const projectId = projectIdOf(p3);
|
|
73956
74016
|
const serverName = String(p3.serverName ?? p3.name ?? "").trim();
|
|
73957
74017
|
if (!projectId || !serverName) {
|
|
@@ -73961,7 +74021,7 @@ async function handleLoginMcpOauth(payload, ctx) {
|
|
|
73961
74021
|
}
|
|
73962
74022
|
try {
|
|
73963
74023
|
const apiProviderId = typeof p3.apiProviderId === "string" ? p3.apiProviderId : null;
|
|
73964
|
-
const rawOptions =
|
|
74024
|
+
const rawOptions = asRecord17(p3.options);
|
|
73965
74025
|
const options = {
|
|
73966
74026
|
...rawOptions.clientRegistration === "auto" || rawOptions.clientRegistration === "cimd" || rawOptions.clientRegistration === "dcr" ? { clientRegistration: rawOptions.clientRegistration } : {},
|
|
73967
74027
|
...typeof rawOptions.threadId === "string" || rawOptions.threadId === null ? { threadId: rawOptions.threadId } : {},
|
|
@@ -73978,7 +74038,7 @@ async function handleLoginMcpOauth(payload, ctx) {
|
|
|
73978
74038
|
async function handleDetectExternalAgent(payload, ctx) {
|
|
73979
74039
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73980
74040
|
if (denied) return denied;
|
|
73981
|
-
const p3 =
|
|
74041
|
+
const p3 = asRecord17(payload);
|
|
73982
74042
|
const projectId = projectIdOf(p3);
|
|
73983
74043
|
if (!projectId) {
|
|
73984
74044
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73997,7 +74057,7 @@ async function handleDetectExternalAgent(payload, ctx) {
|
|
|
73997
74057
|
async function handleImportExternalAgent(payload, ctx) {
|
|
73998
74058
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73999
74059
|
if (denied) return denied;
|
|
74000
|
-
const p3 =
|
|
74060
|
+
const p3 = asRecord17(payload);
|
|
74001
74061
|
const projectId = projectIdOf(p3);
|
|
74002
74062
|
if (!projectId) {
|
|
74003
74063
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -74015,7 +74075,7 @@ async function handleImportExternalAgent(payload, ctx) {
|
|
|
74015
74075
|
async function handlePluginsList2(payload, ctx) {
|
|
74016
74076
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74017
74077
|
if (denied) return denied;
|
|
74018
|
-
const p3 =
|
|
74078
|
+
const p3 = asRecord17(payload);
|
|
74019
74079
|
const projectId = projectIdOf(p3);
|
|
74020
74080
|
if (!projectId) {
|
|
74021
74081
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -74038,7 +74098,7 @@ async function handlePluginsList2(payload, ctx) {
|
|
|
74038
74098
|
async function handlePluginsInstall2(payload, ctx) {
|
|
74039
74099
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74040
74100
|
if (denied) return denied;
|
|
74041
|
-
const p3 =
|
|
74101
|
+
const p3 = asRecord17(payload);
|
|
74042
74102
|
const projectId = projectIdOf(p3);
|
|
74043
74103
|
const key = String(p3.key ?? p3.pluginId ?? "").trim();
|
|
74044
74104
|
if (!projectId || !key) {
|
|
@@ -74054,7 +74114,7 @@ async function handlePluginsInstall2(payload, ctx) {
|
|
|
74054
74114
|
async function handlePluginsUninstall(payload, ctx) {
|
|
74055
74115
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74056
74116
|
if (denied) return denied;
|
|
74057
|
-
const p3 =
|
|
74117
|
+
const p3 = asRecord17(payload);
|
|
74058
74118
|
const projectId = projectIdOf(p3);
|
|
74059
74119
|
const key = String(p3.key ?? p3.pluginId ?? "").trim();
|
|
74060
74120
|
if (!projectId || !key) {
|
|
@@ -74070,7 +74130,7 @@ async function handlePluginsUninstall(payload, ctx) {
|
|
|
74070
74130
|
async function handleMarketplaceAdd(payload, ctx) {
|
|
74071
74131
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74072
74132
|
if (denied) return denied;
|
|
74073
|
-
const p3 =
|
|
74133
|
+
const p3 = asRecord17(payload);
|
|
74074
74134
|
const projectId = projectIdOf(p3);
|
|
74075
74135
|
const source = String(p3.source ?? "").trim();
|
|
74076
74136
|
if (!projectId || !source) {
|
|
@@ -74099,7 +74159,7 @@ async function handleMarketplaceAdd(payload, ctx) {
|
|
|
74099
74159
|
async function handleMarketplaceRemove(payload, ctx) {
|
|
74100
74160
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74101
74161
|
if (denied) return denied;
|
|
74102
|
-
const p3 =
|
|
74162
|
+
const p3 = asRecord17(payload);
|
|
74103
74163
|
const projectId = projectIdOf(p3);
|
|
74104
74164
|
const marketplaceName = String(p3.marketplaceName ?? p3.name ?? "").trim();
|
|
74105
74165
|
if (!projectId || !marketplaceName) {
|
|
@@ -74122,7 +74182,7 @@ async function handleMarketplaceRemove(payload, ctx) {
|
|
|
74122
74182
|
async function handleMarketplaceUpgrade(payload, ctx) {
|
|
74123
74183
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74124
74184
|
if (denied) return denied;
|
|
74125
|
-
const p3 =
|
|
74185
|
+
const p3 = asRecord17(payload);
|
|
74126
74186
|
const projectId = projectIdOf(p3);
|
|
74127
74187
|
if (!projectId) {
|
|
74128
74188
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -74155,7 +74215,7 @@ function requireScopes5(client3, scopes) {
|
|
|
74155
74215
|
}
|
|
74156
74216
|
return null;
|
|
74157
74217
|
}
|
|
74158
|
-
function
|
|
74218
|
+
function asRecord18(payload) {
|
|
74159
74219
|
return payload && typeof payload === "object" ? payload : {};
|
|
74160
74220
|
}
|
|
74161
74221
|
function mapThrown5(err) {
|
|
@@ -74184,7 +74244,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
|
|
|
74184
74244
|
function handleList(payload, ctx) {
|
|
74185
74245
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74186
74246
|
if (denied) return denied;
|
|
74187
|
-
const p3 =
|
|
74247
|
+
const p3 = asRecord18(payload);
|
|
74188
74248
|
try {
|
|
74189
74249
|
const harnessId = typeof p3.harnessId === "string" && p3.harnessId.trim() ? p3.harnessId.trim() : null;
|
|
74190
74250
|
const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
|
|
@@ -74196,7 +74256,7 @@ function handleList(payload, ctx) {
|
|
|
74196
74256
|
function handleGet(payload, ctx) {
|
|
74197
74257
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74198
74258
|
if (denied) return denied;
|
|
74199
|
-
const p3 =
|
|
74259
|
+
const p3 = asRecord18(payload);
|
|
74200
74260
|
const id = String(p3.id ?? "");
|
|
74201
74261
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
74202
74262
|
try {
|
|
@@ -74208,7 +74268,7 @@ function handleGet(payload, ctx) {
|
|
|
74208
74268
|
function handleGetBase(payload, ctx) {
|
|
74209
74269
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74210
74270
|
if (denied) return denied;
|
|
74211
|
-
const p3 =
|
|
74271
|
+
const p3 = asRecord18(payload);
|
|
74212
74272
|
const harnessId = String(p3.harnessId ?? "");
|
|
74213
74273
|
if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
|
|
74214
74274
|
try {
|
|
@@ -74220,7 +74280,7 @@ function handleGetBase(payload, ctx) {
|
|
|
74220
74280
|
function handleCreate(payload, ctx) {
|
|
74221
74281
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74222
74282
|
if (denied) return denied;
|
|
74223
|
-
const p3 =
|
|
74283
|
+
const p3 = asRecord18(payload);
|
|
74224
74284
|
try {
|
|
74225
74285
|
const provider = ctx.sessionProviders.create({
|
|
74226
74286
|
harnessId: String(p3.harnessId ?? ""),
|
|
@@ -74236,7 +74296,7 @@ function handleCreate(payload, ctx) {
|
|
|
74236
74296
|
function handleUpdate(payload, ctx) {
|
|
74237
74297
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74238
74298
|
if (denied) return denied;
|
|
74239
|
-
const p3 =
|
|
74299
|
+
const p3 = asRecord18(payload);
|
|
74240
74300
|
const id = String(p3.id ?? "");
|
|
74241
74301
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
74242
74302
|
try {
|
|
@@ -74252,7 +74312,7 @@ function handleUpdate(payload, ctx) {
|
|
|
74252
74312
|
function handleDelete(payload, ctx) {
|
|
74253
74313
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74254
74314
|
if (denied) return denied;
|
|
74255
|
-
const p3 =
|
|
74315
|
+
const p3 = asRecord18(payload);
|
|
74256
74316
|
const id = String(p3.id ?? "");
|
|
74257
74317
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
74258
74318
|
try {
|
|
@@ -74293,7 +74353,7 @@ function requireScopes6(client3, scopes) {
|
|
|
74293
74353
|
}
|
|
74294
74354
|
return null;
|
|
74295
74355
|
}
|
|
74296
|
-
function
|
|
74356
|
+
function asRecord19(payload) {
|
|
74297
74357
|
return payload && typeof payload === "object" ? payload : {};
|
|
74298
74358
|
}
|
|
74299
74359
|
function defaultProbeModels(ctx) {
|
|
@@ -74321,7 +74381,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
|
|
|
74321
74381
|
async function handleHarnessResources(payload, ctx) {
|
|
74322
74382
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74323
74383
|
if (denied) return denied;
|
|
74324
|
-
const p3 =
|
|
74384
|
+
const p3 = asRecord19(payload);
|
|
74325
74385
|
const projectId = String(p3.projectId ?? "");
|
|
74326
74386
|
if (!projectId) {
|
|
74327
74387
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -74767,7 +74827,7 @@ function handleProviderListCredentials(ctx) {
|
|
|
74767
74827
|
function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
74768
74828
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74769
74829
|
if (denied) return denied;
|
|
74770
|
-
const p3 =
|
|
74830
|
+
const p3 = asRecord20(payload);
|
|
74771
74831
|
const cred = ctx.providers.getCredentialDecrypted(String(p3.id ?? ""));
|
|
74772
74832
|
if (!cred) return { error: { code: "not_found", message: "credential not found" } };
|
|
74773
74833
|
return { result: cred };
|
|
@@ -74775,7 +74835,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
|
74775
74835
|
function handleProviderCreateCredential(payload, ctx) {
|
|
74776
74836
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74777
74837
|
if (denied) return denied;
|
|
74778
|
-
const p3 =
|
|
74838
|
+
const p3 = asRecord20(payload);
|
|
74779
74839
|
try {
|
|
74780
74840
|
return {
|
|
74781
74841
|
result: ctx.providers.createCredential({
|
|
@@ -74798,7 +74858,7 @@ function handleProviderCreateCredential(payload, ctx) {
|
|
|
74798
74858
|
function handleProviderUpdateCredential(payload, ctx) {
|
|
74799
74859
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74800
74860
|
if (denied) return denied;
|
|
74801
|
-
const p3 =
|
|
74861
|
+
const p3 = asRecord20(payload);
|
|
74802
74862
|
const id = String(p3.id ?? "");
|
|
74803
74863
|
const updated = ctx.providers.updateCredential(id, {
|
|
74804
74864
|
name: typeof p3.name === "string" ? p3.name : void 0,
|
|
@@ -74816,7 +74876,7 @@ function handleProviderUpdateCredential(payload, ctx) {
|
|
|
74816
74876
|
function handleProviderDeleteCredential(payload, ctx) {
|
|
74817
74877
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74818
74878
|
if (denied) return denied;
|
|
74819
|
-
const p3 =
|
|
74879
|
+
const p3 = asRecord20(payload);
|
|
74820
74880
|
const ok = ctx.providers.deleteCredential(String(p3.id ?? ""));
|
|
74821
74881
|
if (!ok) return { error: { code: "not_found", message: "credential not found" } };
|
|
74822
74882
|
return { result: { ok: true } };
|
|
@@ -74829,7 +74889,7 @@ function handleProviderListBindings(ctx) {
|
|
|
74829
74889
|
function handleProviderSetBinding(payload, ctx) {
|
|
74830
74890
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74831
74891
|
if (denied) return denied;
|
|
74832
|
-
const p3 =
|
|
74892
|
+
const p3 = asRecord20(payload);
|
|
74833
74893
|
const binding = p3;
|
|
74834
74894
|
if (!binding.consumer || !binding.credentialId) {
|
|
74835
74895
|
return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
|
|
@@ -74840,7 +74900,7 @@ function handleProviderSetBinding(payload, ctx) {
|
|
|
74840
74900
|
function handleProviderClearBinding(payload, ctx) {
|
|
74841
74901
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74842
74902
|
if (denied) return denied;
|
|
74843
|
-
const p3 =
|
|
74903
|
+
const p3 = asRecord20(payload);
|
|
74844
74904
|
ctx.providers.clearBinding(String(p3.consumer ?? ""));
|
|
74845
74905
|
return { result: { ok: true } };
|
|
74846
74906
|
}
|
|
@@ -74852,14 +74912,14 @@ function handleProviderListCustomPlatforms(ctx) {
|
|
|
74852
74912
|
function handleProviderUpsertCustomPlatform(payload, ctx) {
|
|
74853
74913
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74854
74914
|
if (denied) return denied;
|
|
74855
|
-
const def =
|
|
74915
|
+
const def = asRecord20(payload);
|
|
74856
74916
|
if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
|
|
74857
74917
|
return { result: ctx.providers.upsertCustomPlatform(def) };
|
|
74858
74918
|
}
|
|
74859
74919
|
function handleProviderDeleteCustomPlatform(payload, ctx) {
|
|
74860
74920
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74861
74921
|
if (denied) return denied;
|
|
74862
|
-
const p3 =
|
|
74922
|
+
const p3 = asRecord20(payload);
|
|
74863
74923
|
const ok = ctx.providers.deleteCustomPlatform(String(p3.id ?? ""));
|
|
74864
74924
|
if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
|
|
74865
74925
|
return { result: { ok: true } };
|
|
@@ -74872,7 +74932,7 @@ function handleProviderExportBundle(ctx) {
|
|
|
74872
74932
|
function handleProviderListModels(payload, ctx) {
|
|
74873
74933
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74874
74934
|
if (denied) return denied;
|
|
74875
|
-
const p3 =
|
|
74935
|
+
const p3 = asRecord20(payload);
|
|
74876
74936
|
const harness = String(p3.harness ?? p3.harnessId ?? "claude");
|
|
74877
74937
|
const apiProviderId = typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
|
|
74878
74938
|
return {
|
|
@@ -74884,7 +74944,7 @@ function handleProviderListModels(payload, ctx) {
|
|
|
74884
74944
|
function handleProviderImportBundle(payload, ctx) {
|
|
74885
74945
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74886
74946
|
if (denied) return denied;
|
|
74887
|
-
const p3 =
|
|
74947
|
+
const p3 = asRecord20(payload);
|
|
74888
74948
|
const bundle = p3.bundle && typeof p3.bundle === "object" ? p3.bundle : p3;
|
|
74889
74949
|
const replaceAll = p3.replaceAll === true;
|
|
74890
74950
|
try {
|
|
@@ -74949,7 +75009,7 @@ function handleHarnessList(ctx) {
|
|
|
74949
75009
|
function handleHarnessShow(payload, ctx) {
|
|
74950
75010
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74951
75011
|
if (denied) return denied;
|
|
74952
|
-
const p3 =
|
|
75012
|
+
const p3 = asRecord20(payload);
|
|
74953
75013
|
const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
|
|
74954
75014
|
if (!isNodeHarnessId(id)) {
|
|
74955
75015
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74959,7 +75019,7 @@ function handleHarnessShow(payload, ctx) {
|
|
|
74959
75019
|
function handleHarnessProbe(payload, ctx) {
|
|
74960
75020
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74961
75021
|
if (denied) return denied;
|
|
74962
|
-
const p3 =
|
|
75022
|
+
const p3 = asRecord20(payload);
|
|
74963
75023
|
const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
|
|
74964
75024
|
if (!isNodeHarnessId(id)) {
|
|
74965
75025
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74974,7 +75034,7 @@ function handleHarnessProbe(payload, ctx) {
|
|
|
74974
75034
|
async function handleHarnessEnable(payload, ctx) {
|
|
74975
75035
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74976
75036
|
if (denied) return denied;
|
|
74977
|
-
const p3 =
|
|
75037
|
+
const p3 = asRecord20(payload);
|
|
74978
75038
|
const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
|
|
74979
75039
|
if (!isNodeHarnessId(id)) {
|
|
74980
75040
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -75000,7 +75060,7 @@ async function handleHarnessEnable(payload, ctx) {
|
|
|
75000
75060
|
function handleHarnessDisable(payload, ctx) {
|
|
75001
75061
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
75002
75062
|
if (denied) return denied;
|
|
75003
|
-
const p3 =
|
|
75063
|
+
const p3 = asRecord20(payload);
|
|
75004
75064
|
const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
|
|
75005
75065
|
if (!isNodeHarnessId(id)) {
|
|
75006
75066
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -75065,7 +75125,7 @@ function handleSettingsGet(ctx) {
|
|
|
75065
75125
|
function handleSettingsPatch(payload, ctx) {
|
|
75066
75126
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
75067
75127
|
if (denied) return denied;
|
|
75068
|
-
const p3 =
|
|
75128
|
+
const p3 = asRecord20(payload);
|
|
75069
75129
|
const rawPatch = p3.patch && typeof p3.patch === "object" ? p3.patch : p3;
|
|
75070
75130
|
try {
|
|
75071
75131
|
const settings = patchNodeAgentSettings(
|
|
@@ -75086,13 +75146,13 @@ async function handleSandboxProbe(ctx) {
|
|
|
75086
75146
|
return mapThrown7(err);
|
|
75087
75147
|
}
|
|
75088
75148
|
}
|
|
75089
|
-
function
|
|
75149
|
+
function asRecord20(payload) {
|
|
75090
75150
|
return payload && typeof payload === "object" ? payload : {};
|
|
75091
75151
|
}
|
|
75092
75152
|
function handleTerminalCreate(payload, ctx) {
|
|
75093
75153
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75094
75154
|
if (denied) return denied;
|
|
75095
|
-
const p3 =
|
|
75155
|
+
const p3 = asRecord20(payload);
|
|
75096
75156
|
const cwd = typeof p3.cwd === "string" ? p3.cwd : process.cwd();
|
|
75097
75157
|
try {
|
|
75098
75158
|
const info = ctx.terminals.create({
|
|
@@ -75117,7 +75177,7 @@ function handleTerminalCreate(payload, ctx) {
|
|
|
75117
75177
|
function handleTerminalAttach(payload, ctx) {
|
|
75118
75178
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75119
75179
|
if (denied) return denied;
|
|
75120
|
-
const p3 =
|
|
75180
|
+
const p3 = asRecord20(payload);
|
|
75121
75181
|
const terminalId = String(p3.terminalId ?? "");
|
|
75122
75182
|
try {
|
|
75123
75183
|
const attached = ctx.terminals.attach(terminalId);
|
|
@@ -75129,7 +75189,7 @@ function handleTerminalAttach(payload, ctx) {
|
|
|
75129
75189
|
function handleTerminalRead(payload, ctx) {
|
|
75130
75190
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75131
75191
|
if (denied) return denied;
|
|
75132
|
-
const p3 =
|
|
75192
|
+
const p3 = asRecord20(payload);
|
|
75133
75193
|
try {
|
|
75134
75194
|
return {
|
|
75135
75195
|
result: ctx.terminals.readAfter(
|
|
@@ -75157,7 +75217,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
|
|
|
75157
75217
|
function handleTerminalWrite(payload, ctx) {
|
|
75158
75218
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75159
75219
|
if (denied) return denied;
|
|
75160
|
-
const p3 =
|
|
75220
|
+
const p3 = asRecord20(payload);
|
|
75161
75221
|
const terminalId = String(p3.terminalId ?? "");
|
|
75162
75222
|
const leaseErr = requireTerminalLease(p3, ctx, terminalId);
|
|
75163
75223
|
if (leaseErr) return leaseErr;
|
|
@@ -75175,7 +75235,7 @@ function handleTerminalWrite(payload, ctx) {
|
|
|
75175
75235
|
function handleTerminalResize(payload, ctx) {
|
|
75176
75236
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75177
75237
|
if (denied) return denied;
|
|
75178
|
-
const p3 =
|
|
75238
|
+
const p3 = asRecord20(payload);
|
|
75179
75239
|
const terminalId = String(p3.terminalId ?? "");
|
|
75180
75240
|
const leaseErr = requireTerminalLease(p3, ctx, terminalId);
|
|
75181
75241
|
if (leaseErr) return leaseErr;
|
|
@@ -75191,7 +75251,7 @@ function handleTerminalResize(payload, ctx) {
|
|
|
75191
75251
|
function handleTerminalKill(payload, ctx) {
|
|
75192
75252
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75193
75253
|
if (denied) return denied;
|
|
75194
|
-
const p3 =
|
|
75254
|
+
const p3 = asRecord20(payload);
|
|
75195
75255
|
const terminalId = String(p3.terminalId ?? "");
|
|
75196
75256
|
const leaseErr = requireTerminalLease(p3, ctx, terminalId);
|
|
75197
75257
|
if (leaseErr) return leaseErr;
|
|
@@ -75205,7 +75265,7 @@ function handleTerminalKill(payload, ctx) {
|
|
|
75205
75265
|
function handleTerminalAcquireControl(payload, ctx) {
|
|
75206
75266
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75207
75267
|
if (denied) return denied;
|
|
75208
|
-
const p3 =
|
|
75268
|
+
const p3 = asRecord20(payload);
|
|
75209
75269
|
const terminalId = String(p3.terminalId ?? "");
|
|
75210
75270
|
try {
|
|
75211
75271
|
return {
|
|
@@ -75222,7 +75282,7 @@ function handleTerminalAcquireControl(payload, ctx) {
|
|
|
75222
75282
|
function handleTerminalRenewControl(payload, ctx) {
|
|
75223
75283
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75224
75284
|
if (denied) return denied;
|
|
75225
|
-
const p3 =
|
|
75285
|
+
const p3 = asRecord20(payload);
|
|
75226
75286
|
try {
|
|
75227
75287
|
return {
|
|
75228
75288
|
result: ctx.leases.renew({
|
|
@@ -75239,7 +75299,7 @@ function handleTerminalRenewControl(payload, ctx) {
|
|
|
75239
75299
|
function handleTerminalReleaseControl(payload, ctx) {
|
|
75240
75300
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
75241
75301
|
if (denied) return denied;
|
|
75242
|
-
const p3 =
|
|
75302
|
+
const p3 = asRecord20(payload);
|
|
75243
75303
|
try {
|
|
75244
75304
|
ctx.leases.release(
|
|
75245
75305
|
String(p3.leaseId ?? ""),
|
|
@@ -75264,7 +75324,7 @@ function handleProjectList(ctx) {
|
|
|
75264
75324
|
function handleProjectGet(payload, ctx) {
|
|
75265
75325
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
|
|
75266
75326
|
if (denied) return denied;
|
|
75267
|
-
const p3 =
|
|
75327
|
+
const p3 = asRecord20(payload);
|
|
75268
75328
|
const projectId = String(p3.projectId ?? "");
|
|
75269
75329
|
return { result: ctx.projects.get(projectId) };
|
|
75270
75330
|
}
|
|
@@ -75280,7 +75340,7 @@ function expandHostPath(path) {
|
|
|
75280
75340
|
function handleProjectOpen(payload, ctx) {
|
|
75281
75341
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75282
75342
|
if (denied) return denied;
|
|
75283
|
-
const p3 =
|
|
75343
|
+
const p3 = asRecord20(payload);
|
|
75284
75344
|
const path = expandHostPath(String(p3.path ?? ""));
|
|
75285
75345
|
if (!path) {
|
|
75286
75346
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -75298,7 +75358,7 @@ function handleProjectOpen(payload, ctx) {
|
|
|
75298
75358
|
function handleProjectUpdate(payload, ctx) {
|
|
75299
75359
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75300
75360
|
if (denied) return denied;
|
|
75301
|
-
const p3 =
|
|
75361
|
+
const p3 = asRecord20(payload);
|
|
75302
75362
|
const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
|
|
75303
75363
|
const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
|
|
75304
75364
|
if (!projectId && !pathRaw) {
|
|
@@ -75326,7 +75386,7 @@ function handleProjectUpdate(payload, ctx) {
|
|
|
75326
75386
|
function handleProjectRemove(payload, ctx) {
|
|
75327
75387
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75328
75388
|
if (denied) return denied;
|
|
75329
|
-
const p3 =
|
|
75389
|
+
const p3 = asRecord20(payload);
|
|
75330
75390
|
const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
|
|
75331
75391
|
const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
|
|
75332
75392
|
if (!projectId && !pathRaw) {
|
|
@@ -75345,7 +75405,7 @@ function handleProjectRemove(payload, ctx) {
|
|
|
75345
75405
|
function handleFsListDir(payload, ctx) {
|
|
75346
75406
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75347
75407
|
if (denied) return denied;
|
|
75348
|
-
const p3 =
|
|
75408
|
+
const p3 = asRecord20(payload);
|
|
75349
75409
|
const raw = String(p3.path ?? "");
|
|
75350
75410
|
if (!raw || raw.includes("\0")) {
|
|
75351
75411
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -75371,7 +75431,7 @@ function handleFsListDir(payload, ctx) {
|
|
|
75371
75431
|
function handleWorkspaceListDir(payload, ctx) {
|
|
75372
75432
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75373
75433
|
if (denied) return denied;
|
|
75374
|
-
const p3 =
|
|
75434
|
+
const p3 = asRecord20(payload);
|
|
75375
75435
|
try {
|
|
75376
75436
|
return {
|
|
75377
75437
|
result: ctx.workspaceFs.listDir(String(p3.projectId ?? ""), String(p3.relativePath ?? "."))
|
|
@@ -75383,7 +75443,7 @@ function handleWorkspaceListDir(payload, ctx) {
|
|
|
75383
75443
|
function handleWorkspaceListFiles(payload, ctx) {
|
|
75384
75444
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75385
75445
|
if (denied) return denied;
|
|
75386
|
-
const p3 =
|
|
75446
|
+
const p3 = asRecord20(payload);
|
|
75387
75447
|
try {
|
|
75388
75448
|
return {
|
|
75389
75449
|
result: {
|
|
@@ -75401,7 +75461,7 @@ function handleWorkspaceListFiles(payload, ctx) {
|
|
|
75401
75461
|
function handleWorkspaceListSkills(payload, ctx) {
|
|
75402
75462
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75403
75463
|
if (denied) return denied;
|
|
75404
|
-
const p3 =
|
|
75464
|
+
const p3 = asRecord20(payload);
|
|
75405
75465
|
try {
|
|
75406
75466
|
return {
|
|
75407
75467
|
result: ctx.workspaceFs.listSkillsAndCommands(String(p3.projectId ?? ""))
|
|
@@ -75413,7 +75473,7 @@ function handleWorkspaceListSkills(payload, ctx) {
|
|
|
75413
75473
|
function handleWorkspaceReadFile(payload, ctx) {
|
|
75414
75474
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75415
75475
|
if (denied) return denied;
|
|
75416
|
-
const p3 =
|
|
75476
|
+
const p3 = asRecord20(payload);
|
|
75417
75477
|
try {
|
|
75418
75478
|
return {
|
|
75419
75479
|
result: ctx.workspaceFs.readFile(String(p3.projectId ?? ""), String(p3.relativePath ?? ""), {
|
|
@@ -75428,7 +75488,7 @@ function handleWorkspaceReadFile(payload, ctx) {
|
|
|
75428
75488
|
function handleWorkspaceWriteFile(payload, ctx) {
|
|
75429
75489
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75430
75490
|
if (denied) return denied;
|
|
75431
|
-
const p3 =
|
|
75491
|
+
const p3 = asRecord20(payload);
|
|
75432
75492
|
const raw = typeof p3.content === "string" ? p3.content : String(p3.content ?? "");
|
|
75433
75493
|
const encoding = p3.encoding === "base64" ? "base64" : "utf8";
|
|
75434
75494
|
let content = raw;
|
|
@@ -75458,7 +75518,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
|
|
|
75458
75518
|
function handleWorkspaceSearch(payload, ctx) {
|
|
75459
75519
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75460
75520
|
if (denied) return denied;
|
|
75461
|
-
const p3 =
|
|
75521
|
+
const p3 = asRecord20(payload);
|
|
75462
75522
|
try {
|
|
75463
75523
|
return {
|
|
75464
75524
|
result: ctx.workspaceFs.search(
|
|
@@ -75474,7 +75534,7 @@ function handleWorkspaceSearch(payload, ctx) {
|
|
|
75474
75534
|
function handleWorkspaceRename(payload, ctx) {
|
|
75475
75535
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75476
75536
|
if (denied) return denied;
|
|
75477
|
-
const p3 =
|
|
75537
|
+
const p3 = asRecord20(payload);
|
|
75478
75538
|
try {
|
|
75479
75539
|
return {
|
|
75480
75540
|
result: ctx.workspaceFs.rename(
|
|
@@ -75490,7 +75550,7 @@ function handleWorkspaceRename(payload, ctx) {
|
|
|
75490
75550
|
function handleWorkspaceMove(payload, ctx) {
|
|
75491
75551
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75492
75552
|
if (denied) return denied;
|
|
75493
|
-
const p3 =
|
|
75553
|
+
const p3 = asRecord20(payload);
|
|
75494
75554
|
try {
|
|
75495
75555
|
return {
|
|
75496
75556
|
result: ctx.workspaceFs.move(
|
|
@@ -75506,7 +75566,7 @@ function handleWorkspaceMove(payload, ctx) {
|
|
|
75506
75566
|
function handleWorkspaceDelete(payload, ctx) {
|
|
75507
75567
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75508
75568
|
if (denied) return denied;
|
|
75509
|
-
const p3 =
|
|
75569
|
+
const p3 = asRecord20(payload);
|
|
75510
75570
|
try {
|
|
75511
75571
|
return {
|
|
75512
75572
|
result: ctx.workspaceFs.delete(
|
|
@@ -75521,7 +75581,7 @@ function handleWorkspaceDelete(payload, ctx) {
|
|
|
75521
75581
|
function handleWorkspaceMkdir(payload, ctx) {
|
|
75522
75582
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75523
75583
|
if (denied) return denied;
|
|
75524
|
-
const p3 =
|
|
75584
|
+
const p3 = asRecord20(payload);
|
|
75525
75585
|
try {
|
|
75526
75586
|
return {
|
|
75527
75587
|
result: ctx.workspaceFs.mkdir(
|
|
@@ -75536,7 +75596,7 @@ function handleWorkspaceMkdir(payload, ctx) {
|
|
|
75536
75596
|
function handleWorkspaceWatchStart(payload, ctx) {
|
|
75537
75597
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75538
75598
|
if (denied) return denied;
|
|
75539
|
-
const p3 =
|
|
75599
|
+
const p3 = asRecord20(payload);
|
|
75540
75600
|
try {
|
|
75541
75601
|
const events = [];
|
|
75542
75602
|
const { watchId, cancel } = ctx.workspaceWatch.subscribe(
|
|
@@ -75557,7 +75617,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
|
|
|
75557
75617
|
function handleWorkspaceWatchPoll(payload, ctx) {
|
|
75558
75618
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75559
75619
|
if (denied) return denied;
|
|
75560
|
-
const p3 =
|
|
75620
|
+
const p3 = asRecord20(payload);
|
|
75561
75621
|
const watchId = String(p3.watchId ?? "");
|
|
75562
75622
|
const buf = watchBuffers.get(watchId);
|
|
75563
75623
|
if (!buf || buf.owner !== ctx.client.clientSessionId) {
|
|
@@ -75569,7 +75629,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
|
|
|
75569
75629
|
function handleWorkspaceWatchStop(payload, ctx) {
|
|
75570
75630
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75571
75631
|
if (denied) return denied;
|
|
75572
|
-
const p3 =
|
|
75632
|
+
const p3 = asRecord20(payload);
|
|
75573
75633
|
const watchId = String(p3.watchId ?? "");
|
|
75574
75634
|
const buf = watchBuffers.get(watchId);
|
|
75575
75635
|
if (buf && buf.owner === ctx.client.clientSessionId) {
|
|
@@ -75581,7 +75641,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
|
|
|
75581
75641
|
function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
75582
75642
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75583
75643
|
if (denied) return denied;
|
|
75584
|
-
const p3 =
|
|
75644
|
+
const p3 = asRecord20(payload);
|
|
75585
75645
|
try {
|
|
75586
75646
|
const offset = typeof p3.offset === "number" ? p3.offset : void 0;
|
|
75587
75647
|
const absolutePath = typeof p3.absolutePath === "string" ? p3.absolutePath : void 0;
|
|
@@ -75599,7 +75659,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
|
75599
75659
|
function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
75600
75660
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75601
75661
|
if (denied) return denied;
|
|
75602
|
-
const p3 =
|
|
75662
|
+
const p3 = asRecord20(payload);
|
|
75603
75663
|
try {
|
|
75604
75664
|
return {
|
|
75605
75665
|
result: ctx.workspaceTailWatch.poll(String(p3.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -75611,7 +75671,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
|
75611
75671
|
function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
75612
75672
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75613
75673
|
if (denied) return denied;
|
|
75614
|
-
const p3 =
|
|
75674
|
+
const p3 = asRecord20(payload);
|
|
75615
75675
|
try {
|
|
75616
75676
|
return {
|
|
75617
75677
|
result: ctx.workspaceTailWatch.stop(String(p3.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -75623,7 +75683,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
|
75623
75683
|
function handleGitStatus(payload, ctx) {
|
|
75624
75684
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75625
75685
|
if (denied) return denied;
|
|
75626
|
-
const p3 =
|
|
75686
|
+
const p3 = asRecord20(payload);
|
|
75627
75687
|
try {
|
|
75628
75688
|
const projectId = String(p3.projectId ?? "");
|
|
75629
75689
|
const cwd = typeof p3.cwd === "string" ? p3.cwd : null;
|
|
@@ -75637,7 +75697,7 @@ function handleGitStatus(payload, ctx) {
|
|
|
75637
75697
|
function handleGitDiff(payload, ctx) {
|
|
75638
75698
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75639
75699
|
if (denied) return denied;
|
|
75640
|
-
const p3 =
|
|
75700
|
+
const p3 = asRecord20(payload);
|
|
75641
75701
|
try {
|
|
75642
75702
|
return {
|
|
75643
75703
|
result: ctx.workspaceGit.diff(String(p3.projectId ?? ""), {
|
|
@@ -75652,7 +75712,7 @@ function handleGitDiff(payload, ctx) {
|
|
|
75652
75712
|
function handleGitBranches(payload, ctx) {
|
|
75653
75713
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75654
75714
|
if (denied) return denied;
|
|
75655
|
-
const p3 =
|
|
75715
|
+
const p3 = asRecord20(payload);
|
|
75656
75716
|
try {
|
|
75657
75717
|
return {
|
|
75658
75718
|
result: ctx.workspaceGit.branches(
|
|
@@ -75667,7 +75727,7 @@ function handleGitBranches(payload, ctx) {
|
|
|
75667
75727
|
function handleGitSwitchBranch(payload, ctx) {
|
|
75668
75728
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75669
75729
|
if (denied) return denied;
|
|
75670
|
-
const p3 =
|
|
75730
|
+
const p3 = asRecord20(payload);
|
|
75671
75731
|
try {
|
|
75672
75732
|
return {
|
|
75673
75733
|
result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
|
|
@@ -75682,7 +75742,7 @@ function handleGitSwitchBranch(payload, ctx) {
|
|
|
75682
75742
|
function handleGitCreateBranch(payload, ctx) {
|
|
75683
75743
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75684
75744
|
if (denied) return denied;
|
|
75685
|
-
const p3 =
|
|
75745
|
+
const p3 = asRecord20(payload);
|
|
75686
75746
|
try {
|
|
75687
75747
|
return {
|
|
75688
75748
|
result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
|
|
@@ -75697,7 +75757,7 @@ function handleGitCreateBranch(payload, ctx) {
|
|
|
75697
75757
|
function handleGitWorktrees(payload, ctx) {
|
|
75698
75758
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75699
75759
|
if (denied) return denied;
|
|
75700
|
-
const p3 =
|
|
75760
|
+
const p3 = asRecord20(payload);
|
|
75701
75761
|
try {
|
|
75702
75762
|
return { result: ctx.workspaceGit.worktrees(String(p3.projectId ?? "")) };
|
|
75703
75763
|
} catch (err) {
|
|
@@ -75707,7 +75767,7 @@ function handleGitWorktrees(payload, ctx) {
|
|
|
75707
75767
|
function handleGitWorktreeActivate(payload, ctx) {
|
|
75708
75768
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75709
75769
|
if (denied) return denied;
|
|
75710
|
-
const p3 =
|
|
75770
|
+
const p3 = asRecord20(payload);
|
|
75711
75771
|
const mode = p3.mode === "attach" || p3.mode === "detach" || p3.mode === "branch" ? p3.mode : null;
|
|
75712
75772
|
if (!mode) {
|
|
75713
75773
|
return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
|
|
@@ -75728,7 +75788,7 @@ function handleGitWorktreeActivate(payload, ctx) {
|
|
|
75728
75788
|
function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
75729
75789
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75730
75790
|
if (denied) return denied;
|
|
75731
|
-
const p3 =
|
|
75791
|
+
const p3 = asRecord20(payload);
|
|
75732
75792
|
try {
|
|
75733
75793
|
return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p3.projectId ?? "")) } };
|
|
75734
75794
|
} catch (err) {
|
|
@@ -75738,7 +75798,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
|
75738
75798
|
function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
75739
75799
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75740
75800
|
if (denied) return denied;
|
|
75741
|
-
const p3 =
|
|
75801
|
+
const p3 = asRecord20(payload);
|
|
75742
75802
|
try {
|
|
75743
75803
|
return {
|
|
75744
75804
|
result: ctx.workspaceGit.assignBranch(
|
|
@@ -75754,7 +75814,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
|
75754
75814
|
function handleGitWorktreeHandoff(payload, ctx) {
|
|
75755
75815
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75756
75816
|
if (denied) return denied;
|
|
75757
|
-
const p3 =
|
|
75817
|
+
const p3 = asRecord20(payload);
|
|
75758
75818
|
try {
|
|
75759
75819
|
return {
|
|
75760
75820
|
result: ctx.workspaceGit.handoffToMain(
|
|
@@ -75769,7 +75829,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
|
|
|
75769
75829
|
function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
75770
75830
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75771
75831
|
if (denied) return denied;
|
|
75772
|
-
const p3 =
|
|
75832
|
+
const p3 = asRecord20(payload);
|
|
75773
75833
|
try {
|
|
75774
75834
|
return {
|
|
75775
75835
|
result: ctx.workspaceGit.handoffPreview(
|
|
@@ -75784,7 +75844,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
|
75784
75844
|
function handleSessionSetCwd(payload, ctx) {
|
|
75785
75845
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75786
75846
|
if (denied) return denied;
|
|
75787
|
-
const p3 =
|
|
75847
|
+
const p3 = asRecord20(payload);
|
|
75788
75848
|
const sessionId = String(p3.sessionId ?? "");
|
|
75789
75849
|
const cwdRaw = p3.cwd;
|
|
75790
75850
|
const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
|
|
@@ -75813,7 +75873,7 @@ function handleSessionSetCwd(payload, ctx) {
|
|
|
75813
75873
|
function handleSessionPatchSettings(payload, ctx) {
|
|
75814
75874
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75815
75875
|
if (denied) return denied;
|
|
75816
|
-
const p3 =
|
|
75876
|
+
const p3 = asRecord20(payload);
|
|
75817
75877
|
const sessionId = String(p3.sessionId ?? "").trim();
|
|
75818
75878
|
if (!sessionId) {
|
|
75819
75879
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75829,7 +75889,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
75829
75889
|
generation: String(p3.generation ?? ""),
|
|
75830
75890
|
holderClientId: ctx.client.clientSessionId
|
|
75831
75891
|
});
|
|
75832
|
-
const settingsSrc =
|
|
75892
|
+
const settingsSrc = asRecord20(p3.settings ?? p3);
|
|
75833
75893
|
const patch = {};
|
|
75834
75894
|
const take = (key) => {
|
|
75835
75895
|
if (!(key in settingsSrc)) return;
|
|
@@ -75855,7 +75915,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
75855
75915
|
async function handleSessionFork(payload, ctx) {
|
|
75856
75916
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75857
75917
|
if (denied) return denied;
|
|
75858
|
-
const p3 =
|
|
75918
|
+
const p3 = asRecord20(payload);
|
|
75859
75919
|
const sessionId = String(p3.sessionId ?? "").trim();
|
|
75860
75920
|
if (!sessionId) {
|
|
75861
75921
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75942,7 +76002,7 @@ async function handleSessionFork(payload, ctx) {
|
|
|
75942
76002
|
async function handleGitClone(payload, ctx) {
|
|
75943
76003
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75944
76004
|
if (denied) return denied;
|
|
75945
|
-
const p3 =
|
|
76005
|
+
const p3 = asRecord20(payload);
|
|
75946
76006
|
try {
|
|
75947
76007
|
const cloned = await cloneRepository({
|
|
75948
76008
|
remoteUrl: String(p3.remoteUrl ?? ""),
|
|
@@ -75958,7 +76018,7 @@ async function handleGitClone(payload, ctx) {
|
|
|
75958
76018
|
function handleSessionCreate(payload, ctx) {
|
|
75959
76019
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75960
76020
|
if (denied) return denied;
|
|
75961
|
-
const p3 =
|
|
76021
|
+
const p3 = asRecord20(payload);
|
|
75962
76022
|
const rawHarnessId = typeof p3.harnessId === "string" ? p3.harnessId : "claude";
|
|
75963
76023
|
const harnessId = normalizeSessionHarnessId(rawHarnessId);
|
|
75964
76024
|
if (!harnessId) {
|
|
@@ -76011,7 +76071,7 @@ function handleSessionCreate(payload, ctx) {
|
|
|
76011
76071
|
try {
|
|
76012
76072
|
const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
|
|
76013
76073
|
const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
|
|
76014
|
-
const options =
|
|
76074
|
+
const options = asRecord20(p3.options);
|
|
76015
76075
|
const providerId = typeof p3.providerId === "string" && p3.providerId.trim() ? p3.providerId.trim() : void 0;
|
|
76016
76076
|
const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
|
|
76017
76077
|
const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
|
|
@@ -76072,13 +76132,13 @@ function handleSessionCreate(payload, ctx) {
|
|
|
76072
76132
|
function handleSessionGet(payload, ctx) {
|
|
76073
76133
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
76074
76134
|
if (denied) return denied;
|
|
76075
|
-
const p3 =
|
|
76135
|
+
const p3 = asRecord20(payload);
|
|
76076
76136
|
return { result: ctx.sessions.get(String(p3.sessionId ?? "")) };
|
|
76077
76137
|
}
|
|
76078
76138
|
function handleSessionList(payload, ctx) {
|
|
76079
76139
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
76080
76140
|
if (denied) return denied;
|
|
76081
|
-
const p3 =
|
|
76141
|
+
const p3 = asRecord20(payload);
|
|
76082
76142
|
const projectId = typeof p3.projectId === "string" ? p3.projectId : void 0;
|
|
76083
76143
|
if (typeof p3.limit !== "number" || !Number.isFinite(p3.limit)) {
|
|
76084
76144
|
return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
|
|
@@ -76118,7 +76178,7 @@ function handleSessionList(payload, ctx) {
|
|
|
76118
76178
|
function handleSessionAcquireControl(payload, ctx) {
|
|
76119
76179
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76120
76180
|
if (denied) return denied;
|
|
76121
|
-
const p3 =
|
|
76181
|
+
const p3 = asRecord20(payload);
|
|
76122
76182
|
const sessionId = String(p3.sessionId ?? "");
|
|
76123
76183
|
if (!sessionId) {
|
|
76124
76184
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -76142,7 +76202,7 @@ function handleSessionAcquireControl(payload, ctx) {
|
|
|
76142
76202
|
function handleSessionRenewControl(payload, ctx) {
|
|
76143
76203
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76144
76204
|
if (denied) return denied;
|
|
76145
|
-
const p3 =
|
|
76205
|
+
const p3 = asRecord20(payload);
|
|
76146
76206
|
try {
|
|
76147
76207
|
return {
|
|
76148
76208
|
result: ctx.leases.renew({
|
|
@@ -76159,7 +76219,7 @@ function handleSessionRenewControl(payload, ctx) {
|
|
|
76159
76219
|
function handleSessionReleaseControl(payload, ctx) {
|
|
76160
76220
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76161
76221
|
if (denied) return denied;
|
|
76162
|
-
const p3 =
|
|
76222
|
+
const p3 = asRecord20(payload);
|
|
76163
76223
|
try {
|
|
76164
76224
|
ctx.leases.release(
|
|
76165
76225
|
String(p3.leaseId ?? ""),
|
|
@@ -76174,7 +76234,7 @@ function handleSessionReleaseControl(payload, ctx) {
|
|
|
76174
76234
|
function handleSessionClose(payload, ctx) {
|
|
76175
76235
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76176
76236
|
if (denied) return denied;
|
|
76177
|
-
const p3 =
|
|
76237
|
+
const p3 = asRecord20(payload);
|
|
76178
76238
|
const sessionId = String(p3.sessionId ?? "");
|
|
76179
76239
|
try {
|
|
76180
76240
|
ctx.leases.assertValid({
|
|
@@ -76200,7 +76260,7 @@ function handleSessionClose(payload, ctx) {
|
|
|
76200
76260
|
function handleSessionRemove(payload, ctx) {
|
|
76201
76261
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76202
76262
|
if (denied) return denied;
|
|
76203
|
-
const p3 =
|
|
76263
|
+
const p3 = asRecord20(payload);
|
|
76204
76264
|
const sessionId = String(p3.sessionId ?? "");
|
|
76205
76265
|
if (!sessionId) {
|
|
76206
76266
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -76227,7 +76287,7 @@ function handleSessionRemove(payload, ctx) {
|
|
|
76227
76287
|
function handleSessionRename(payload, ctx) {
|
|
76228
76288
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76229
76289
|
if (denied) return denied;
|
|
76230
|
-
const p3 =
|
|
76290
|
+
const p3 = asRecord20(payload);
|
|
76231
76291
|
const sessionId = String(p3.sessionId ?? "");
|
|
76232
76292
|
const title = String(p3.title ?? "");
|
|
76233
76293
|
const source = p3.source === "agent" ? "agent" : "user";
|
|
@@ -76243,7 +76303,7 @@ function handleSessionRename(payload, ctx) {
|
|
|
76243
76303
|
function handleSessionSetTags(payload, ctx) {
|
|
76244
76304
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76245
76305
|
if (denied) return denied;
|
|
76246
|
-
const p3 =
|
|
76306
|
+
const p3 = asRecord20(payload);
|
|
76247
76307
|
const sessionId = String(p3.sessionId ?? "");
|
|
76248
76308
|
if (!sessionId) {
|
|
76249
76309
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -76269,7 +76329,7 @@ function handleSessionSetTags(payload, ctx) {
|
|
|
76269
76329
|
function handleSessionSetUiFlags(payload, ctx) {
|
|
76270
76330
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76271
76331
|
if (denied) return denied;
|
|
76272
|
-
const p3 =
|
|
76332
|
+
const p3 = asRecord20(payload);
|
|
76273
76333
|
const sessionId = String(p3.sessionId ?? "");
|
|
76274
76334
|
if (!sessionId) {
|
|
76275
76335
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -76288,9 +76348,9 @@ function handleSessionSetUiFlags(payload, ctx) {
|
|
|
76288
76348
|
async function handleSessionSend(payload, ctx) {
|
|
76289
76349
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76290
76350
|
if (denied) return denied;
|
|
76291
|
-
const p3 =
|
|
76351
|
+
const p3 = asRecord20(payload);
|
|
76292
76352
|
try {
|
|
76293
|
-
const options =
|
|
76353
|
+
const options = asRecord20(p3.options);
|
|
76294
76354
|
const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
|
|
76295
76355
|
const modelTopLevel = typeof p3.model === "string" && p3.model.trim() ? p3.model.trim() : null;
|
|
76296
76356
|
const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
|
|
@@ -76387,7 +76447,7 @@ async function handleSessionSend(payload, ctx) {
|
|
|
76387
76447
|
function handleSessionInterrupt(payload, ctx) {
|
|
76388
76448
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76389
76449
|
if (denied) return denied;
|
|
76390
|
-
const p3 =
|
|
76450
|
+
const p3 = asRecord20(payload);
|
|
76391
76451
|
try {
|
|
76392
76452
|
ctx.sessions.interrupt(
|
|
76393
76453
|
String(p3.sessionId ?? ""),
|
|
@@ -76403,7 +76463,7 @@ function handleSessionInterrupt(payload, ctx) {
|
|
|
76403
76463
|
function handleSessionRespondPermission(payload, ctx) {
|
|
76404
76464
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76405
76465
|
if (denied) return denied;
|
|
76406
|
-
const p3 =
|
|
76466
|
+
const p3 = asRecord20(payload);
|
|
76407
76467
|
try {
|
|
76408
76468
|
const formAnswers = p3.formAnswers && typeof p3.formAnswers === "object" && !Array.isArray(p3.formAnswers) ? p3.formAnswers : p3.options && typeof p3.options === "object" && !Array.isArray(p3.options) ? p3.options.formAnswers ?? p3.options : void 0;
|
|
76409
76469
|
ctx.sessions.respondPermission({
|
|
@@ -76424,7 +76484,7 @@ function handleSessionRespondPermission(payload, ctx) {
|
|
|
76424
76484
|
function handleSessionRespondQuestion(payload, ctx) {
|
|
76425
76485
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76426
76486
|
if (denied) return denied;
|
|
76427
|
-
const p3 =
|
|
76487
|
+
const p3 = asRecord20(payload);
|
|
76428
76488
|
try {
|
|
76429
76489
|
ctx.sessions.respondQuestion({
|
|
76430
76490
|
sessionId: String(p3.sessionId ?? ""),
|
|
@@ -76442,7 +76502,7 @@ function handleSessionRespondQuestion(payload, ctx) {
|
|
|
76442
76502
|
function handleSessionRespondPlan(payload, ctx) {
|
|
76443
76503
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76444
76504
|
if (denied) return denied;
|
|
76445
|
-
const p3 =
|
|
76505
|
+
const p3 = asRecord20(payload);
|
|
76446
76506
|
const decision = p3.decision === "approve" || p3.decision === "reject" ? p3.decision : null;
|
|
76447
76507
|
if (!decision) {
|
|
76448
76508
|
return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
|
|
@@ -76465,7 +76525,7 @@ function handleSessionRespondPlan(payload, ctx) {
|
|
|
76465
76525
|
async function handleSessionHostActionsPoll(payload, ctx) {
|
|
76466
76526
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76467
76527
|
if (denied) return denied;
|
|
76468
|
-
const p3 =
|
|
76528
|
+
const p3 = asRecord20(payload);
|
|
76469
76529
|
try {
|
|
76470
76530
|
const result = await ctx.sessions.pollHostActions({
|
|
76471
76531
|
controllerClientSessionId: ctx.client.clientSessionId,
|
|
@@ -76481,7 +76541,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
|
|
|
76481
76541
|
function handleSessionClaimHostAction(payload, ctx) {
|
|
76482
76542
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76483
76543
|
if (denied) return denied;
|
|
76484
|
-
const p3 =
|
|
76544
|
+
const p3 = asRecord20(payload);
|
|
76485
76545
|
try {
|
|
76486
76546
|
const result = ctx.sessions.claimHostAction({
|
|
76487
76547
|
actionId: String(p3.actionId ?? ""),
|
|
@@ -76497,7 +76557,7 @@ function handleSessionClaimHostAction(payload, ctx) {
|
|
|
76497
76557
|
function handleSessionRespondHostAction(payload, ctx) {
|
|
76498
76558
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76499
76559
|
if (denied) return denied;
|
|
76500
|
-
const p3 =
|
|
76560
|
+
const p3 = asRecord20(payload);
|
|
76501
76561
|
const outcome = p3.outcome === "failed" ? "failed" : p3.outcome === "succeeded" ? "succeeded" : null;
|
|
76502
76562
|
if (!outcome) {
|
|
76503
76563
|
return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
|
|
@@ -76519,14 +76579,14 @@ function handleSessionRespondHostAction(payload, ctx) {
|
|
|
76519
76579
|
function handleSessionEvents(payload, ctx) {
|
|
76520
76580
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
76521
76581
|
if (denied) return denied;
|
|
76522
|
-
const p3 =
|
|
76582
|
+
const p3 = asRecord20(payload);
|
|
76523
76583
|
const after = String(p3.afterSequence ?? "0");
|
|
76524
76584
|
return { result: { events: ctx.sessions.listEventsAfter(after) } };
|
|
76525
76585
|
}
|
|
76526
76586
|
function handleSessionMessagesList(payload, ctx) {
|
|
76527
76587
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
76528
76588
|
if (denied) return denied;
|
|
76529
|
-
const p3 =
|
|
76589
|
+
const p3 = asRecord20(payload);
|
|
76530
76590
|
const sessionId = String(p3.sessionId ?? "").trim();
|
|
76531
76591
|
if (!sessionId) {
|
|
76532
76592
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -76565,7 +76625,7 @@ function handleCollaborationListProfiles(ctx) {
|
|
|
76565
76625
|
async function handleCollaborationRequest(payload, ctx) {
|
|
76566
76626
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76567
76627
|
if (denied) return denied;
|
|
76568
|
-
const p3 =
|
|
76628
|
+
const p3 = asRecord20(payload);
|
|
76569
76629
|
const parentSessionId = String(p3.parentSessionId ?? "");
|
|
76570
76630
|
if (!parentSessionId) {
|
|
76571
76631
|
return { error: { code: "invalid_argument", message: "parentSessionId required" } };
|
|
@@ -76599,7 +76659,7 @@ async function handleCollaborationRequest(payload, ctx) {
|
|
|
76599
76659
|
async function handleCollaborationStart(payload, ctx) {
|
|
76600
76660
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76601
76661
|
if (denied) return denied;
|
|
76602
|
-
const p3 =
|
|
76662
|
+
const p3 = asRecord20(payload);
|
|
76603
76663
|
const credential = typeof p3.credential === "string" ? p3.credential : void 0;
|
|
76604
76664
|
const grantId = typeof p3.grantId === "string" ? p3.grantId : void 0;
|
|
76605
76665
|
if (!credential && !grantId) {
|
|
@@ -76645,7 +76705,7 @@ async function handleCollaborationStart(payload, ctx) {
|
|
|
76645
76705
|
function handleCollaborationSend(payload, ctx) {
|
|
76646
76706
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
76647
76707
|
if (denied) return denied;
|
|
76648
|
-
const p3 =
|
|
76708
|
+
const p3 = asRecord20(payload);
|
|
76649
76709
|
const credential = String(p3.credential ?? "");
|
|
76650
76710
|
const sessionId = String(p3.sessionId ?? p3.fromSessionId ?? "");
|
|
76651
76711
|
const content = typeof p3.content === "string" ? p3.content : p3.body !== void 0 ? typeof p3.body === "string" ? p3.body : JSON.stringify(p3.body) : "";
|
|
@@ -76681,7 +76741,7 @@ function handleCollaborationSend(payload, ctx) {
|
|
|
76681
76741
|
function handleCollaborationRetrieve(payload, ctx) {
|
|
76682
76742
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
76683
76743
|
if (denied) return denied;
|
|
76684
|
-
const p3 =
|
|
76744
|
+
const p3 = asRecord20(payload);
|
|
76685
76745
|
const credential = String(p3.credential ?? "");
|
|
76686
76746
|
const sessionId = String(p3.sessionId ?? "");
|
|
76687
76747
|
if (!credential) {
|
|
@@ -77528,7 +77588,7 @@ import { existsSync as existsSync28, mkdirSync as mkdirSync17, readFileSync as r
|
|
|
77528
77588
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
77529
77589
|
import { join as join26, resolve as resolve7 } from "node:path";
|
|
77530
77590
|
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.257";
|
|
77531
|
-
var OFFICIAL_CODEX_NPM_VERSION = "0.
|
|
77591
|
+
var OFFICIAL_CODEX_NPM_VERSION = "0.153.2";
|
|
77532
77592
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
77533
77593
|
function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
77534
77594
|
const platform2 = process.platform;
|