@super-one/cli 0.55.2-alpha → 0.57.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 +1360 -427
- package/package.json +10 -10
package/lib/cli.mjs
CHANGED
|
@@ -164,10 +164,113 @@ var init_host_actions = __esm({
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
// ../../packages/shared/src/environment/host-action-superone-descriptors.ts
|
|
167
|
-
var HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS;
|
|
167
|
+
var deviceDescriptionProperty, deviceTargetProperty, deviceConditionSchema, deviceActionSchema, HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS;
|
|
168
168
|
var init_host_action_superone_descriptors = __esm({
|
|
169
169
|
"../../packages/shared/src/environment/host-action-superone-descriptors.ts"() {
|
|
170
170
|
"use strict";
|
|
171
|
+
deviceDescriptionProperty = {
|
|
172
|
+
type: "string",
|
|
173
|
+
minLength: 1,
|
|
174
|
+
maxLength: 160,
|
|
175
|
+
description: "A short human-friendly explanation of what this step accomplishes, phrased for the user watching (e.g. 'Open the profile tab', 'Check the order total'). Shown in the UI in place of refs and coordinates. Write it in the conversation's language."
|
|
176
|
+
};
|
|
177
|
+
deviceTargetProperty = {
|
|
178
|
+
type: "string",
|
|
179
|
+
description: "Which controlled device to act on \u2014 the id from device_list, or its name. Optional while this session controls exactly one device; required once it controls more than one (driving the wrong app there looks like a bug in the right one). Use device_request_control to be granted another."
|
|
180
|
+
};
|
|
181
|
+
deviceConditionSchema = {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {
|
|
184
|
+
kind: { type: "string", enum: ["exists", "notExists", "textEquals", "textContains"] },
|
|
185
|
+
ref: {
|
|
186
|
+
description: "Only valid within the snapshot it came from; prefer label or identifier when waiting.",
|
|
187
|
+
type: "string"
|
|
188
|
+
},
|
|
189
|
+
label: { description: "Visible name of the element.", type: "string" },
|
|
190
|
+
identifier: {
|
|
191
|
+
description: "Developer-assigned id. Survives copy changes and translation \u2014 the most durable target.",
|
|
192
|
+
type: "string"
|
|
193
|
+
},
|
|
194
|
+
text: {
|
|
195
|
+
description: "The string textEquals/textContains compares against. Required by those two kinds, and NOT a way to name an element \u2014 use label for that.",
|
|
196
|
+
type: "string",
|
|
197
|
+
minLength: 1
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
required: ["kind"],
|
|
201
|
+
additionalProperties: false
|
|
202
|
+
};
|
|
203
|
+
deviceActionSchema = {
|
|
204
|
+
type: "object",
|
|
205
|
+
properties: {
|
|
206
|
+
type: {
|
|
207
|
+
type: "string",
|
|
208
|
+
enum: ["tap", "doubleTap", "longPress", "swipe", "pinch", "press", "type", "key", "rotate", "keyboard"]
|
|
209
|
+
},
|
|
210
|
+
ref: { description: 'Element ref from the snapshot, e.g. "@e12". Preferred over coordinates.', type: "string" },
|
|
211
|
+
x: {
|
|
212
|
+
description: "Horizontal position as a fraction of the screen (0-1). Only when no ref fits.",
|
|
213
|
+
type: "number",
|
|
214
|
+
minimum: 0,
|
|
215
|
+
maximum: 1
|
|
216
|
+
},
|
|
217
|
+
y: {
|
|
218
|
+
description: "Vertical position as a fraction of the screen (0-1).",
|
|
219
|
+
type: "number",
|
|
220
|
+
minimum: 0,
|
|
221
|
+
maximum: 1
|
|
222
|
+
},
|
|
223
|
+
direction: {
|
|
224
|
+
description: 'swipe: which way the finger travels. Content moves the opposite way, so "up" scrolls down a list.',
|
|
225
|
+
type: "string",
|
|
226
|
+
enum: ["up", "down", "left", "right"]
|
|
227
|
+
},
|
|
228
|
+
distance: {
|
|
229
|
+
description: "swipe: travel as a fraction of the screen. Default 0.6.",
|
|
230
|
+
type: "number",
|
|
231
|
+
minimum: 0.05,
|
|
232
|
+
maximum: 1
|
|
233
|
+
},
|
|
234
|
+
toX: {
|
|
235
|
+
description: "swipe: explicit destination instead of direction.",
|
|
236
|
+
type: "number",
|
|
237
|
+
minimum: 0,
|
|
238
|
+
maximum: 1
|
|
239
|
+
},
|
|
240
|
+
toY: { type: "number", minimum: 0, maximum: 1 },
|
|
241
|
+
scale: {
|
|
242
|
+
description: "pinch: final separation factor. Below 1 pinches in (zoom out), above 1 spreads.",
|
|
243
|
+
type: "number",
|
|
244
|
+
minimum: 0.1,
|
|
245
|
+
maximum: 5
|
|
246
|
+
},
|
|
247
|
+
durationMs: {
|
|
248
|
+
description: "How long the gesture takes. Short swipes flick and coast; long ones drag and stop.",
|
|
249
|
+
type: "integer",
|
|
250
|
+
minimum: 16,
|
|
251
|
+
maximum: 1e4
|
|
252
|
+
},
|
|
253
|
+
text: {
|
|
254
|
+
description: "type: text to enter. Anything the simulated keyboard cannot spell (Chinese, emoji) is pasted automatically.",
|
|
255
|
+
type: "string"
|
|
256
|
+
},
|
|
257
|
+
button: {
|
|
258
|
+
type: "string",
|
|
259
|
+
enum: ["home", "lock", "side", "volume-up", "volume-down", "back", "app-switch"],
|
|
260
|
+
description: "key: a hardware button. `back` and `app-switch` are Android-only and are refused elsewhere."
|
|
261
|
+
},
|
|
262
|
+
orientation: {
|
|
263
|
+
type: "string",
|
|
264
|
+
enum: ["portrait", "landscape-left", "portrait-upside-down", "landscape-right"]
|
|
265
|
+
},
|
|
266
|
+
connected: {
|
|
267
|
+
description: "keyboard: attach or detach the hardware keyboard. Detach it to make the on-screen keyboard appear.",
|
|
268
|
+
type: "boolean"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
required: ["type"],
|
|
272
|
+
additionalProperties: false
|
|
273
|
+
};
|
|
171
274
|
HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS = [
|
|
172
275
|
{
|
|
173
276
|
"name": "session_collab_list_agents",
|
|
@@ -3563,7 +3666,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3563
3666
|
},
|
|
3564
3667
|
"reasoningEffort": {
|
|
3565
3668
|
"type": "string",
|
|
3566
|
-
"enum": ["minimal", "low", "medium", "high", "xhigh"],
|
|
3669
|
+
"enum": ["minimal", "low", "medium", "high", "xhigh", "max", "ultra"],
|
|
3567
3670
|
"description": "Codex legacy alias for effort."
|
|
3568
3671
|
},
|
|
3569
3672
|
"permissionPreset": {
|
|
@@ -3620,6 +3723,116 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3620
3723
|
],
|
|
3621
3724
|
"additionalProperties": false
|
|
3622
3725
|
}
|
|
3726
|
+
},
|
|
3727
|
+
{
|
|
3728
|
+
"name": "device_list",
|
|
3729
|
+
"description": "Browse the devices this machine can offer, one tier at a time \u2014 a dev machine holds over a hundred simulators, so this never dumps them all. No arguments: what is running (attaching is instant; a cold boot costs ~20s), what this project used before, and which kinds exist. kind: that kind's models. model: that model's devices, one per runtime, with the ids. Prefer a running or recent device; ids only matter when you need a specific runtime, since device_request_control also takes a model name and picks its newest. Free and side-effect-free \u2014 it grants nothing and boots nothing.",
|
|
3730
|
+
"inputSchema": {
|
|
3731
|
+
"type": "object",
|
|
3732
|
+
"properties": {
|
|
3733
|
+
"kind": {
|
|
3734
|
+
"type": "string",
|
|
3735
|
+
"description": 'Narrow to one family: "iphone", "ipad", "watch", "tv", "vision". Returns its models.'
|
|
3736
|
+
},
|
|
3737
|
+
"model": {
|
|
3738
|
+
"type": "string",
|
|
3739
|
+
"description": 'A model name from the kind tier ("iPhone 17 Pro Max"). Returns one entry per runtime, with ids.'
|
|
3740
|
+
}
|
|
3741
|
+
},
|
|
3742
|
+
"additionalProperties": false
|
|
3743
|
+
}
|
|
3744
|
+
},
|
|
3745
|
+
{
|
|
3746
|
+
"name": "device_request_control",
|
|
3747
|
+
"description": "Ask the user to let this session control one specific device, and wait for their answer. Every other device_* tool needs that grant and fails with NO_DEVICE until this succeeds \u2014 call it first, not after a failure. Pick the device from device_list yourself; the user only approves or declines, and a decline carries their feedback (often naming a different device \u2014 read it before retrying). Returns it once bound and ready, booting it if it was not running; asking again for one this session already holds returns it without prompting. A session may hold several, and then every device_* call must name one with `device`. Install a build afterwards with `xcrun simctl install/launch`.",
|
|
3748
|
+
"inputSchema": {
|
|
3749
|
+
"type": "object",
|
|
3750
|
+
"properties": {
|
|
3751
|
+
"description": deviceDescriptionProperty,
|
|
3752
|
+
"device": {
|
|
3753
|
+
"type": "string",
|
|
3754
|
+
"description": 'The id from device_list. A device name ("iPhone 17 Pro Max") is matched loosely against the catalog as a fallback, but the id is what makes the approved device the one you meant.'
|
|
3755
|
+
}
|
|
3756
|
+
},
|
|
3757
|
+
"required": [
|
|
3758
|
+
"description",
|
|
3759
|
+
"device"
|
|
3760
|
+
],
|
|
3761
|
+
"additionalProperties": false
|
|
3762
|
+
}
|
|
3763
|
+
},
|
|
3764
|
+
{
|
|
3765
|
+
"name": "device_snapshot",
|
|
3766
|
+
"description": "Capture the screen and return a stateId later calls must quote. mode=semantic (default) returns the accessibility tree with @eN refs, labels, identifiers and bounds \u2014 prefer it: refs survive animation and rotation, coordinates do not. mode=visual saves a PNG and returns image.path (not pixels); Read it to look. fused returns both. Waits for animation to stop; settled=false means geometry is approximate. A region with no accessibility tree \u2014 a WebView, a canvas \u2014 has its text read from pixels and merged in, marked (ocr): tap those, never press. The reply says source=ocr or hybrid. Re-snapshot after anything that changes the screen \u2014 refs are positional and device_act rejects a stale stateId.",
|
|
3767
|
+
"inputSchema": {
|
|
3768
|
+
"type": "object",
|
|
3769
|
+
"properties": {
|
|
3770
|
+
"description": deviceDescriptionProperty,
|
|
3771
|
+
"device": deviceTargetProperty,
|
|
3772
|
+
"mode": { "description": "Default semantic", "type": "string", "enum": ["semantic", "visual", "fused"] },
|
|
3773
|
+
"maxNodes": {
|
|
3774
|
+
"description": "Ceiling on tree size. Default 500; truncated=true means the screen has more.",
|
|
3775
|
+
"type": "integer",
|
|
3776
|
+
"minimum": 1,
|
|
3777
|
+
"maximum": 2e3
|
|
3778
|
+
}
|
|
3779
|
+
},
|
|
3780
|
+
"required": ["description"],
|
|
3781
|
+
"additionalProperties": false
|
|
3782
|
+
}
|
|
3783
|
+
},
|
|
3784
|
+
{
|
|
3785
|
+
"name": "device_query",
|
|
3786
|
+
"description": "Search or inspect an existing snapshot without re-capturing the device. Use this instead of taking another snapshot when you only need to find an element or read its details \u2014 it costs no device round trip and cannot race an animation. op=search matches text against labels, values and identifiers. op=inspect returns one element and its children.",
|
|
3787
|
+
"inputSchema": {
|
|
3788
|
+
"type": "object",
|
|
3789
|
+
"properties": {
|
|
3790
|
+
"description": deviceDescriptionProperty,
|
|
3791
|
+
"device": deviceTargetProperty,
|
|
3792
|
+
"stateId": { "type": "string", "description": "From a prior device_snapshot." },
|
|
3793
|
+
"op": { "type": "string", "enum": ["search", "inspect"] },
|
|
3794
|
+
"text": { "description": "For search.", "type": "string" },
|
|
3795
|
+
"ref": { "description": 'For inspect, e.g. "@e12".', "type": "string" }
|
|
3796
|
+
},
|
|
3797
|
+
"required": ["description", "stateId", "op"],
|
|
3798
|
+
"additionalProperties": false
|
|
3799
|
+
}
|
|
3800
|
+
},
|
|
3801
|
+
{
|
|
3802
|
+
"name": "device_act",
|
|
3803
|
+
"description": "Run 1-10 touch actions against a snapshot, then re-observe to judge if they worked. Actions: tap, doubleTap, longPress, swipe(direction|toX/toY), pinch(scale), press(ref), type, key, rotate, keyboard. Prefer press for a ref-backed control; it goes through accessibility, immune to animation, rotation and scale (not on a source=ocr snapshot \u2014 tap there). Aim touch actions at refs too; raw x/y is a last resort. The whole batch, stale stateId included, is validated up front. rotate ends the snapshot it is in: put it last, then re-snapshot \u2014 a later ref or coordinate is refused. Returns worked|didnt|unknown; unknown means input landed but nothing visibly changed. Pass expect to define success.",
|
|
3804
|
+
"inputSchema": {
|
|
3805
|
+
"type": "object",
|
|
3806
|
+
"properties": {
|
|
3807
|
+
"description": deviceDescriptionProperty,
|
|
3808
|
+
"device": deviceTargetProperty,
|
|
3809
|
+
"stateId": { "type": "string" },
|
|
3810
|
+
"actions": { "minItems": 1, "maxItems": 10, "type": "array", "items": deviceActionSchema },
|
|
3811
|
+
"expect": { "description": "Postcondition checked after the actions run.", ...deviceConditionSchema }
|
|
3812
|
+
},
|
|
3813
|
+
"required": ["description", "stateId", "actions"],
|
|
3814
|
+
"additionalProperties": false
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
{
|
|
3818
|
+
"name": "device_wait_for",
|
|
3819
|
+
"description": "Wait until the screen satisfies a condition. Use this instead of snapshotting in a loop. Distinguishes preexisting (already true when asked) from verified (became true while waiting), so you can tell a real transition from a check that was never going to fail. Returns a fresh settled stateId and matching tree when successful. Target the element by label or identifier, not by ref: refs belong to one snapshot, and what you are waiting for usually does not exist yet. Every condition must name an element that way \u2014 text only says what to compare, it never selects.",
|
|
3820
|
+
"inputSchema": {
|
|
3821
|
+
"type": "object",
|
|
3822
|
+
"properties": {
|
|
3823
|
+
"description": deviceDescriptionProperty,
|
|
3824
|
+
"device": deviceTargetProperty,
|
|
3825
|
+
"condition": deviceConditionSchema,
|
|
3826
|
+
"timeoutMs": {
|
|
3827
|
+
"description": "Default 5000",
|
|
3828
|
+
"type": "integer",
|
|
3829
|
+
"minimum": 100,
|
|
3830
|
+
"maximum": 6e4
|
|
3831
|
+
}
|
|
3832
|
+
},
|
|
3833
|
+
"required": ["description", "condition"],
|
|
3834
|
+
"additionalProperties": false
|
|
3835
|
+
}
|
|
3623
3836
|
}
|
|
3624
3837
|
];
|
|
3625
3838
|
}
|
|
@@ -3693,6 +3906,10 @@ var init_host_action_browser_catalog = __esm({
|
|
|
3693
3906
|
"widget_list_templates",
|
|
3694
3907
|
"miniapp_list",
|
|
3695
3908
|
"automation_list",
|
|
3909
|
+
"device_list",
|
|
3910
|
+
"device_snapshot",
|
|
3911
|
+
"device_query",
|
|
3912
|
+
"device_wait_for",
|
|
3696
3913
|
// session_collab_* are node-local (not HA); list_agents stays "safe" if ever reclassified
|
|
3697
3914
|
"computer_apps",
|
|
3698
3915
|
"computer_snapshot",
|
|
@@ -19033,7 +19250,7 @@ var init_agent_error = __esm({
|
|
|
19033
19250
|
}
|
|
19034
19251
|
});
|
|
19035
19252
|
|
|
19036
|
-
// ../../packages/codex/src/
|
|
19253
|
+
// ../../packages/codex/src/protocol-v149.ts
|
|
19037
19254
|
function asRecord(value) {
|
|
19038
19255
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
19039
19256
|
}
|
|
@@ -19041,6 +19258,75 @@ function readString(value) {
|
|
|
19041
19258
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
19042
19259
|
}
|
|
19043
19260
|
function readNumber(value) {
|
|
19261
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
19262
|
+
}
|
|
19263
|
+
function readCodexAgentMessageDelivery(value) {
|
|
19264
|
+
return value === "async" ? "async" : void 0;
|
|
19265
|
+
}
|
|
19266
|
+
function readCodexImageGenerationFailure(value) {
|
|
19267
|
+
const failure = asRecord(value);
|
|
19268
|
+
if (!failure || failure.type !== "usageLimitExceeded") return void 0;
|
|
19269
|
+
const limitId = readString(failure.limitId);
|
|
19270
|
+
if (!limitId) return void 0;
|
|
19271
|
+
return {
|
|
19272
|
+
type: "usageLimitExceeded",
|
|
19273
|
+
limitId,
|
|
19274
|
+
resetsAt: readNumber(failure.resetsAt)
|
|
19275
|
+
};
|
|
19276
|
+
}
|
|
19277
|
+
function readCodexErrorOverrides(value) {
|
|
19278
|
+
const rec = asRecord(value);
|
|
19279
|
+
const error51 = asRecord(rec?.error) ?? rec;
|
|
19280
|
+
const info = error51?.codexErrorInfo ?? error51?.codex_error_info;
|
|
19281
|
+
if (typeof info === "string") return { code: info };
|
|
19282
|
+
const variant = asRecord(info);
|
|
19283
|
+
if (!variant) return {};
|
|
19284
|
+
const normalizedCode = readString(variant.code);
|
|
19285
|
+
if (normalizedCode) {
|
|
19286
|
+
const httpStatus2 = readNumber(variant.httpStatus);
|
|
19287
|
+
return { code: normalizedCode, ...httpStatus2 === null ? {} : { httpStatus: httpStatus2 } };
|
|
19288
|
+
}
|
|
19289
|
+
const [code, payload] = Object.entries(variant)[0] ?? [];
|
|
19290
|
+
if (!code) return {};
|
|
19291
|
+
const httpStatus = readNumber(asRecord(payload)?.httpStatusCode);
|
|
19292
|
+
return { code, ...httpStatus === null ? {} : { httpStatus } };
|
|
19293
|
+
}
|
|
19294
|
+
async function readCodexServerDiagnostics(client3) {
|
|
19295
|
+
const result = await client3.request("server/diagnostics");
|
|
19296
|
+
const process3 = asRecord(result.process);
|
|
19297
|
+
const gauges = Array.isArray(result.gauges) ? result.gauges.flatMap((value) => {
|
|
19298
|
+
const gauge = asRecord(value);
|
|
19299
|
+
const name = readString(gauge?.name);
|
|
19300
|
+
const numeric = readNumber(gauge?.value);
|
|
19301
|
+
return name && numeric !== null ? [{ name, value: numeric }] : [];
|
|
19302
|
+
}) : [];
|
|
19303
|
+
return {
|
|
19304
|
+
process: {
|
|
19305
|
+
id: readNumber(process3?.id) ?? 0,
|
|
19306
|
+
residentMemoryBytes: readNumber(process3?.residentMemoryBytes),
|
|
19307
|
+
physicalFootprintBytes: readNumber(process3?.physicalFootprintBytes)
|
|
19308
|
+
},
|
|
19309
|
+
gauges
|
|
19310
|
+
};
|
|
19311
|
+
}
|
|
19312
|
+
async function readCodexConfigRequirements(client3) {
|
|
19313
|
+
const result = await client3.request("configRequirements/read", {});
|
|
19314
|
+
return asRecord(result.requirements);
|
|
19315
|
+
}
|
|
19316
|
+
var init_protocol_v149 = __esm({
|
|
19317
|
+
"../../packages/codex/src/protocol-v149.ts"() {
|
|
19318
|
+
"use strict";
|
|
19319
|
+
}
|
|
19320
|
+
});
|
|
19321
|
+
|
|
19322
|
+
// ../../packages/codex/src/agent-event-mapper.ts
|
|
19323
|
+
function asRecord2(value) {
|
|
19324
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
19325
|
+
}
|
|
19326
|
+
function readString2(value) {
|
|
19327
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
19328
|
+
}
|
|
19329
|
+
function readNumber2(value) {
|
|
19044
19330
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
19045
19331
|
if (typeof value === "string") {
|
|
19046
19332
|
const parsed = Number(value);
|
|
@@ -19053,7 +19339,7 @@ function readBoolean(value) {
|
|
|
19053
19339
|
}
|
|
19054
19340
|
function readStringArray(value) {
|
|
19055
19341
|
if (!Array.isArray(value)) return [];
|
|
19056
|
-
return value.map(
|
|
19342
|
+
return value.map(readString2).filter((entry) => entry !== null);
|
|
19057
19343
|
}
|
|
19058
19344
|
function uniqueStrings(values) {
|
|
19059
19345
|
const result = [];
|
|
@@ -19064,30 +19350,30 @@ function uniqueStrings(values) {
|
|
|
19064
19350
|
return result;
|
|
19065
19351
|
}
|
|
19066
19352
|
function readTextPart(value) {
|
|
19067
|
-
const direct =
|
|
19353
|
+
const direct = readString2(value);
|
|
19068
19354
|
if (direct !== null) return direct;
|
|
19069
|
-
const rec =
|
|
19355
|
+
const rec = asRecord2(value);
|
|
19070
19356
|
if (!rec) return null;
|
|
19071
|
-
return
|
|
19357
|
+
return readString2(rec.text) ?? readString2(rec.summaryText) ?? readString2(rec.summary_text) ?? readString2(rec.content);
|
|
19072
19358
|
}
|
|
19073
19359
|
function readTextParts(value) {
|
|
19074
19360
|
if (!Array.isArray(value)) return [];
|
|
19075
19361
|
return value.map(readTextPart).filter((entry) => entry !== null && entry.length > 0);
|
|
19076
19362
|
}
|
|
19077
19363
|
function readCodexItemId(rec) {
|
|
19078
|
-
return
|
|
19364
|
+
return readString2(rec.itemId) ?? readString2(rec.item_id) ?? readString2(rec.id) ?? readString2(asRecord2(rec.item)?.id);
|
|
19079
19365
|
}
|
|
19080
19366
|
function readCodexDeltaText(rec) {
|
|
19081
|
-
return
|
|
19367
|
+
return readString2(rec.delta) ?? readString2(rec.textDelta) ?? readString2(rec.text_delta) ?? readString2(rec.summaryTextDelta) ?? readString2(rec.summary_text_delta) ?? readString2(rec.summaryDelta) ?? readString2(rec.summary_delta) ?? readString2(rec.text) ?? readString2(rec.summaryText) ?? readString2(rec.summary_text) ?? "";
|
|
19082
19368
|
}
|
|
19083
19369
|
function mapPatchChangeKind(raw) {
|
|
19084
|
-
const direct =
|
|
19370
|
+
const direct = readString2(raw);
|
|
19085
19371
|
if (direct === "add" || direct === "delete" || direct === "update") return direct;
|
|
19086
|
-
const kind =
|
|
19372
|
+
const kind = readString2(asRecord2(raw)?.type);
|
|
19087
19373
|
return kind === "add" || kind === "delete" || kind === "update" ? kind : "update";
|
|
19088
19374
|
}
|
|
19089
19375
|
function mapCommandExecutionStatus(raw) {
|
|
19090
|
-
switch (
|
|
19376
|
+
switch (readString2(raw)) {
|
|
19091
19377
|
case "in_progress":
|
|
19092
19378
|
case "inProgress":
|
|
19093
19379
|
return "in_progress";
|
|
@@ -19099,11 +19385,11 @@ function mapCommandExecutionStatus(raw) {
|
|
|
19099
19385
|
}
|
|
19100
19386
|
}
|
|
19101
19387
|
function mapPatchApplyStatus(raw) {
|
|
19102
|
-
const status =
|
|
19388
|
+
const status = readString2(raw);
|
|
19103
19389
|
return status === "failed" || status === "declined" ? "failed" : "completed";
|
|
19104
19390
|
}
|
|
19105
19391
|
function mapMcpToolCallStatus(raw) {
|
|
19106
|
-
switch (
|
|
19392
|
+
switch (readString2(raw)) {
|
|
19107
19393
|
case "in_progress":
|
|
19108
19394
|
case "inProgress":
|
|
19109
19395
|
return "in_progress";
|
|
@@ -19114,7 +19400,7 @@ function mapMcpToolCallStatus(raw) {
|
|
|
19114
19400
|
}
|
|
19115
19401
|
}
|
|
19116
19402
|
function normalizeCollabTool(value) {
|
|
19117
|
-
switch (
|
|
19403
|
+
switch (readString2(value)) {
|
|
19118
19404
|
case "spawnAgent":
|
|
19119
19405
|
case "spawn_agent":
|
|
19120
19406
|
return "spawnAgent";
|
|
@@ -19135,7 +19421,7 @@ function normalizeCollabTool(value) {
|
|
|
19135
19421
|
}
|
|
19136
19422
|
}
|
|
19137
19423
|
function normalizeCollabAgentStatus(value) {
|
|
19138
|
-
switch (
|
|
19424
|
+
switch (readString2(value)) {
|
|
19139
19425
|
case "pendingInit":
|
|
19140
19426
|
case "pending_init":
|
|
19141
19427
|
return "pendingInit";
|
|
@@ -19161,10 +19447,10 @@ function buildCodexReasoningItem(id, text, previous, now = Date.now) {
|
|
|
19161
19447
|
return { id, type: "reasoning", text, startedAt, endedAt: timestamp };
|
|
19162
19448
|
}
|
|
19163
19449
|
function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
19164
|
-
const rec =
|
|
19450
|
+
const rec = asRecord2(raw);
|
|
19165
19451
|
if (!rec) return null;
|
|
19166
|
-
const type =
|
|
19167
|
-
const id =
|
|
19452
|
+
const type = readString2(rec.type);
|
|
19453
|
+
const id = readString2(rec.id) ?? previous?.id;
|
|
19168
19454
|
if (!type || !id) return null;
|
|
19169
19455
|
switch (type) {
|
|
19170
19456
|
case "agent_message":
|
|
@@ -19172,32 +19458,33 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19172
19458
|
return {
|
|
19173
19459
|
id,
|
|
19174
19460
|
type: "agent_message",
|
|
19175
|
-
text:
|
|
19461
|
+
text: readString2(rec.text) ?? (previous?.type === "agent_message" ? previous.text : ""),
|
|
19462
|
+
...readCodexAgentMessageDelivery(rec.delivery) ?? (previous?.type === "agent_message" ? previous.delivery : void 0) ? { delivery: "async" } : {}
|
|
19176
19463
|
};
|
|
19177
19464
|
case "reasoning": {
|
|
19178
|
-
const text =
|
|
19465
|
+
const text = readString2(rec.text) || readTextParts(rec.summary).join("\n\n") || readTextParts(rec.content).join("\n\n") || (previous?.type === "reasoning" ? previous.text : "");
|
|
19179
19466
|
return buildCodexReasoningItem(id, text, previous, now);
|
|
19180
19467
|
}
|
|
19181
19468
|
case "command_execution":
|
|
19182
19469
|
case "commandExecution": {
|
|
19183
19470
|
const prev = previous?.type === "command_execution" ? previous : null;
|
|
19184
19471
|
const actions = Array.isArray(rec.commandActions) ? rec.commandActions.map((entry) => {
|
|
19185
|
-
const action =
|
|
19472
|
+
const action = asRecord2(entry);
|
|
19186
19473
|
if (!action) return null;
|
|
19187
19474
|
return {
|
|
19188
|
-
type:
|
|
19189
|
-
...action.command != null ? { command:
|
|
19190
|
-
...action.name != null ? { name:
|
|
19191
|
-
...action.path != null ? { path:
|
|
19192
|
-
...action.query != null ? { query:
|
|
19475
|
+
type: readString2(action.type) ?? "unknown",
|
|
19476
|
+
...action.command != null ? { command: readString2(action.command) ?? void 0 } : {},
|
|
19477
|
+
...action.name != null ? { name: readString2(action.name) ?? void 0 } : {},
|
|
19478
|
+
...action.path != null ? { path: readString2(action.path) ?? void 0 } : {},
|
|
19479
|
+
...action.query != null ? { query: readString2(action.query) ?? void 0 } : {}
|
|
19193
19480
|
};
|
|
19194
19481
|
}).filter((entry) => entry !== null) : void 0;
|
|
19195
|
-
const exitCode =
|
|
19482
|
+
const exitCode = readNumber2(rec.exitCode) ?? readNumber2(rec.exit_code);
|
|
19196
19483
|
return {
|
|
19197
19484
|
id,
|
|
19198
19485
|
type: "command_execution",
|
|
19199
|
-
command:
|
|
19200
|
-
aggregatedOutput:
|
|
19486
|
+
command: readString2(rec.command) ?? prev?.command ?? "",
|
|
19487
|
+
aggregatedOutput: readString2(rec.aggregatedOutput) ?? readString2(rec.aggregated_output) ?? prev?.aggregatedOutput ?? "",
|
|
19201
19488
|
...exitCode !== null ? { exitCode } : {},
|
|
19202
19489
|
status: mapCommandExecutionStatus(rec.status ?? prev?.status),
|
|
19203
19490
|
...actions ? { commandActions: actions } : prev?.commandActions ? { commandActions: prev.commandActions } : {}
|
|
@@ -19206,10 +19493,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19206
19493
|
case "file_change":
|
|
19207
19494
|
case "fileChange": {
|
|
19208
19495
|
const changes = Array.isArray(rec.changes) ? rec.changes.map((entry) => {
|
|
19209
|
-
const change =
|
|
19210
|
-
const path =
|
|
19496
|
+
const change = asRecord2(entry);
|
|
19497
|
+
const path = readString2(change?.path);
|
|
19211
19498
|
if (!path) return null;
|
|
19212
|
-
const diff =
|
|
19499
|
+
const diff = readString2(change?.diff);
|
|
19213
19500
|
return { path, kind: mapPatchChangeKind(change?.kind), ...diff !== null ? { diff } : {} };
|
|
19214
19501
|
}).filter((entry) => entry !== null) : previous?.type === "file_change" ? previous.changes : [];
|
|
19215
19502
|
return {
|
|
@@ -19222,19 +19509,19 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19222
19509
|
case "mcp_tool_call":
|
|
19223
19510
|
case "mcpToolCall": {
|
|
19224
19511
|
const prev = previous?.type === "mcp_tool_call" ? previous : null;
|
|
19225
|
-
const result =
|
|
19226
|
-
const error51 =
|
|
19512
|
+
const result = asRecord2(rec.result);
|
|
19513
|
+
const error51 = asRecord2(rec.error);
|
|
19227
19514
|
return {
|
|
19228
19515
|
id,
|
|
19229
19516
|
type: "mcp_tool_call",
|
|
19230
|
-
server:
|
|
19231
|
-
tool:
|
|
19517
|
+
server: readString2(rec.server) ?? prev?.server ?? "",
|
|
19518
|
+
tool: readString2(rec.tool) ?? prev?.tool ?? "",
|
|
19232
19519
|
arguments: rec.arguments ?? prev?.arguments ?? {},
|
|
19233
19520
|
...result ? { result: {
|
|
19234
19521
|
content: Array.isArray(result.content) ? result.content : [],
|
|
19235
19522
|
structuredContent: result.structuredContent ?? result.structured_content ?? null
|
|
19236
19523
|
} } : prev?.result ? { result: prev.result } : {},
|
|
19237
|
-
...error51 ? { error: { message:
|
|
19524
|
+
...error51 ? { error: { message: readString2(error51.message) ?? "Unknown MCP tool error" } } : prev?.error ? { error: prev.error } : {},
|
|
19238
19525
|
status: mapMcpToolCallStatus(rec.status ?? prev?.status)
|
|
19239
19526
|
};
|
|
19240
19527
|
}
|
|
@@ -19244,29 +19531,31 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19244
19531
|
return {
|
|
19245
19532
|
id,
|
|
19246
19533
|
type: "web_search",
|
|
19247
|
-
query:
|
|
19534
|
+
query: readString2(rec.query) ?? prev?.query ?? "",
|
|
19248
19535
|
status: mapMcpToolCallStatus(rec.status ?? prev?.status)
|
|
19249
19536
|
};
|
|
19250
19537
|
}
|
|
19251
19538
|
case "image_generation":
|
|
19252
19539
|
case "imageGeneration": {
|
|
19253
19540
|
const prev = previous?.type === "image_generation" ? previous : null;
|
|
19254
|
-
const revisedPrompt =
|
|
19255
|
-
const savedPath =
|
|
19541
|
+
const revisedPrompt = readString2(rec.revisedPrompt ?? rec.revised_prompt) ?? prev?.revisedPrompt;
|
|
19542
|
+
const savedPath = readString2(rec.savedPath ?? rec.saved_path) ?? prev?.savedPath;
|
|
19543
|
+
const failure = readCodexImageGenerationFailure(rec.failure) ?? prev?.failure;
|
|
19256
19544
|
return {
|
|
19257
19545
|
id,
|
|
19258
19546
|
type: "image_generation",
|
|
19259
|
-
status:
|
|
19547
|
+
status: readString2(rec.status) ?? prev?.status ?? "in_progress",
|
|
19260
19548
|
...revisedPrompt ? { revisedPrompt } : {},
|
|
19261
19549
|
...savedPath ? { savedPath } : {},
|
|
19550
|
+
...failure ? { failure } : {},
|
|
19262
19551
|
...prev?.generationMs !== void 0 ? { generationMs: prev.generationMs } : {}
|
|
19263
19552
|
};
|
|
19264
19553
|
}
|
|
19265
19554
|
case "todo_list":
|
|
19266
19555
|
case "todoList": {
|
|
19267
19556
|
const items = Array.isArray(rec.items) ? rec.items.map((entry) => {
|
|
19268
|
-
const todo =
|
|
19269
|
-
const text =
|
|
19557
|
+
const todo = asRecord2(entry);
|
|
19558
|
+
const text = readString2(todo?.text);
|
|
19270
19559
|
return text ? { text, completed: readBoolean(todo?.completed) ?? false } : null;
|
|
19271
19560
|
}).filter((entry) => entry !== null) : previous?.type === "todo_list" ? previous.items : [];
|
|
19272
19561
|
return { id, type: "todo_list", items };
|
|
@@ -19275,16 +19564,16 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19275
19564
|
return {
|
|
19276
19565
|
id,
|
|
19277
19566
|
type: "error",
|
|
19278
|
-
message:
|
|
19567
|
+
message: readString2(rec.message) ?? (previous?.type === "error" ? previous.message : "Unknown error")
|
|
19279
19568
|
};
|
|
19280
19569
|
case "plan": {
|
|
19281
|
-
const text =
|
|
19570
|
+
const text = readString2(rec.text);
|
|
19282
19571
|
return text ? buildCodexReasoningItem(id, text, previous, now) : null;
|
|
19283
19572
|
}
|
|
19284
19573
|
case "enteredReviewMode":
|
|
19285
|
-
return { id, type: "review", phase: "entered", text:
|
|
19574
|
+
return { id, type: "review", phase: "entered", text: readString2(rec.text) ?? readString2(rec.review) ?? "" };
|
|
19286
19575
|
case "exitedReviewMode":
|
|
19287
|
-
return { id: `${id}_exit`, type: "review", phase: "exited", text:
|
|
19576
|
+
return { id: `${id}_exit`, type: "review", phase: "exited", text: readString2(rec.text) ?? readString2(rec.review) ?? "" };
|
|
19288
19577
|
case "contextCompaction":
|
|
19289
19578
|
return { id, type: "compaction" };
|
|
19290
19579
|
case "collabAgentToolCall":
|
|
@@ -19292,44 +19581,44 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19292
19581
|
const prev = previous?.type === "collab_tool_call" ? previous : null;
|
|
19293
19582
|
const receiverThreadIds = uniqueStrings([
|
|
19294
19583
|
...readStringArray(rec.receiverThreadIds ?? rec.receiver_thread_ids),
|
|
19295
|
-
|
|
19296
|
-
|
|
19584
|
+
readString2(rec.receiverThreadId ?? rec.receiver_thread_id),
|
|
19585
|
+
readString2(rec.newThreadId ?? rec.new_thread_id)
|
|
19297
19586
|
]);
|
|
19298
19587
|
const agentsStates = { ...prev?.agentsStates ?? {} };
|
|
19299
|
-
const rawStates =
|
|
19588
|
+
const rawStates = asRecord2(rec.agentsStates ?? rec.agents_states);
|
|
19300
19589
|
if (rawStates) {
|
|
19301
19590
|
for (const [agentId, value] of Object.entries(rawStates)) {
|
|
19302
|
-
const state =
|
|
19591
|
+
const state = asRecord2(value);
|
|
19303
19592
|
if (!state) continue;
|
|
19304
19593
|
const prior = prev?.agentsStates?.[agentId];
|
|
19305
19594
|
agentsStates[agentId] = {
|
|
19306
19595
|
...prior,
|
|
19307
19596
|
status: normalizeCollabAgentStatus(state.status) ?? prior?.status ?? "running",
|
|
19308
|
-
...state.message != null ? { message:
|
|
19597
|
+
...state.message != null ? { message: readString2(state.message) ?? void 0 } : {}
|
|
19309
19598
|
};
|
|
19310
19599
|
}
|
|
19311
19600
|
}
|
|
19312
19601
|
const rawAgentStatus = rec.agentStatus ?? rec.agent_status;
|
|
19313
|
-
const agentStatus =
|
|
19602
|
+
const agentStatus = asRecord2(rawAgentStatus);
|
|
19314
19603
|
if (!rawStates && rawAgentStatus != null) {
|
|
19315
19604
|
for (const agentId of receiverThreadIds) {
|
|
19316
19605
|
const prior = prev?.agentsStates?.[agentId];
|
|
19317
19606
|
agentsStates[agentId] = {
|
|
19318
19607
|
...prior,
|
|
19319
19608
|
status: normalizeCollabAgentStatus(agentStatus?.status ?? rawAgentStatus) ?? prior?.status ?? "running",
|
|
19320
|
-
...agentStatus?.message != null ? { message:
|
|
19609
|
+
...agentStatus?.message != null ? { message: readString2(agentStatus.message) ?? void 0 } : {}
|
|
19321
19610
|
};
|
|
19322
19611
|
}
|
|
19323
19612
|
}
|
|
19324
|
-
const rawStatus =
|
|
19613
|
+
const rawStatus = readString2(rec.status);
|
|
19325
19614
|
return {
|
|
19326
19615
|
id,
|
|
19327
19616
|
type: "collab_tool_call",
|
|
19328
19617
|
tool: normalizeCollabTool(rec.tool) ?? prev?.tool ?? "spawnAgent",
|
|
19329
19618
|
status: rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "in_progress",
|
|
19330
|
-
...
|
|
19619
|
+
...readString2(rec.senderThreadId) ?? readString2(rec.sender_thread_id) ?? prev?.senderThreadId ? { senderThreadId: readString2(rec.senderThreadId) ?? readString2(rec.sender_thread_id) ?? prev?.senderThreadId } : {},
|
|
19331
19620
|
receiverThreadIds: receiverThreadIds.length > 0 ? receiverThreadIds : prev?.receiverThreadIds ?? [],
|
|
19332
|
-
...
|
|
19621
|
+
...readString2(rec.prompt) ?? prev?.prompt ? { prompt: readString2(rec.prompt) ?? prev?.prompt } : {},
|
|
19333
19622
|
agentsStates,
|
|
19334
19623
|
...prev?.childItems ? { childItems: prev.childItems } : {}
|
|
19335
19624
|
};
|
|
@@ -19339,17 +19628,17 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
|
|
|
19339
19628
|
}
|
|
19340
19629
|
}
|
|
19341
19630
|
function mapCodexUsage(raw) {
|
|
19342
|
-
const rec =
|
|
19631
|
+
const rec = asRecord2(raw);
|
|
19343
19632
|
if (!rec) return null;
|
|
19344
19633
|
const parse4 = (value) => {
|
|
19345
|
-
const data =
|
|
19634
|
+
const data = asRecord2(value);
|
|
19346
19635
|
if (!data) return null;
|
|
19347
19636
|
return {
|
|
19348
|
-
inputTokens:
|
|
19349
|
-
cachedInputTokens:
|
|
19350
|
-
cacheWriteInputTokens:
|
|
19351
|
-
outputTokens:
|
|
19352
|
-
reasoningOutputTokens:
|
|
19637
|
+
inputTokens: readNumber2(data.inputTokens ?? data.input_tokens) ?? 0,
|
|
19638
|
+
cachedInputTokens: readNumber2(data.cachedInputTokens ?? data.cached_input_tokens) ?? 0,
|
|
19639
|
+
cacheWriteInputTokens: readNumber2(data.cacheWriteInputTokens ?? data.cache_write_input_tokens) ?? 0,
|
|
19640
|
+
outputTokens: readNumber2(data.outputTokens ?? data.output_tokens) ?? 0,
|
|
19641
|
+
reasoningOutputTokens: readNumber2(data.reasoningOutputTokens ?? data.reasoning_output_tokens) ?? 0
|
|
19353
19642
|
};
|
|
19354
19643
|
};
|
|
19355
19644
|
const last = parse4(rec.last);
|
|
@@ -19366,19 +19655,19 @@ function mapCodexUsage(raw) {
|
|
|
19366
19655
|
lastCachedInputTokens: resolvedLast.cachedInputTokens,
|
|
19367
19656
|
lastCacheWriteInputTokens: resolvedLast.cacheWriteInputTokens,
|
|
19368
19657
|
lastOutputTokens: resolvedLast.outputTokens,
|
|
19369
|
-
reasoningOutputTokens: resolvedTotal.reasoningOutputTokens || (
|
|
19370
|
-
contextWindow:
|
|
19658
|
+
reasoningOutputTokens: resolvedTotal.reasoningOutputTokens || (readNumber2(rec.reasoningOutputTokens ?? rec.reasoning_output_tokens) ?? 0),
|
|
19659
|
+
contextWindow: readNumber2(rec.modelContextWindow ?? rec.model_context_window ?? rec.contextWindow ?? rec.context_window) ?? 0
|
|
19371
19660
|
};
|
|
19372
19661
|
}
|
|
19373
19662
|
function extractError(raw) {
|
|
19374
|
-
const rec =
|
|
19663
|
+
const rec = asRecord2(raw);
|
|
19375
19664
|
if (!rec) return "Codex turn failed";
|
|
19376
|
-
return
|
|
19665
|
+
return readString2(rec.message) ?? readString2(asRecord2(rec.error)?.message) ?? "Codex turn failed";
|
|
19377
19666
|
}
|
|
19378
19667
|
function deriveCodexFinalResponse(items) {
|
|
19379
19668
|
for (let index = items.length - 1; index >= 0; index--) {
|
|
19380
19669
|
const item = items[index];
|
|
19381
|
-
if (item?.type === "agent_message") return item.text;
|
|
19670
|
+
if (item?.type === "agent_message" && item.delivery !== "async") return item.text;
|
|
19382
19671
|
}
|
|
19383
19672
|
return "";
|
|
19384
19673
|
}
|
|
@@ -19412,13 +19701,13 @@ function createCodexAgentEventMapper(options) {
|
|
|
19412
19701
|
};
|
|
19413
19702
|
const finishStatus = () => options.emit({ type: "status_change", status: "idle" });
|
|
19414
19703
|
const startCompaction = (params) => {
|
|
19415
|
-
const turnId =
|
|
19704
|
+
const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId;
|
|
19416
19705
|
if (turnId && completedCompactionTurns.has(turnId)) return;
|
|
19417
19706
|
if (activeCompaction && (!activeCompaction.turnId || !turnId || activeCompaction.turnId === turnId)) {
|
|
19418
19707
|
if (!activeCompaction.turnId && turnId) {
|
|
19419
19708
|
activeCompaction = {
|
|
19420
19709
|
turnId,
|
|
19421
|
-
startedAt:
|
|
19710
|
+
startedAt: readNumber2(params.startedAtMs ?? params.started_at_ms) ?? activeCompaction.startedAt,
|
|
19422
19711
|
preTokens: currentUsage?.lastInputTokens ?? activeCompaction.preTokens
|
|
19423
19712
|
};
|
|
19424
19713
|
}
|
|
@@ -19426,18 +19715,18 @@ function createCodexAgentEventMapper(options) {
|
|
|
19426
19715
|
}
|
|
19427
19716
|
activeCompaction = {
|
|
19428
19717
|
turnId,
|
|
19429
|
-
startedAt:
|
|
19718
|
+
startedAt: readNumber2(params.startedAtMs ?? params.started_at_ms) ?? now(),
|
|
19430
19719
|
preTokens: currentUsage?.lastInputTokens ?? 0
|
|
19431
19720
|
};
|
|
19432
19721
|
options.emit({ type: "status_indicator", indicator: "compacting" });
|
|
19433
19722
|
};
|
|
19434
19723
|
const completeCompaction = (params) => {
|
|
19435
|
-
const turnId =
|
|
19724
|
+
const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId;
|
|
19436
19725
|
if (turnId && completedCompactionTurns.has(turnId)) return;
|
|
19437
19726
|
if (!activeCompaction) startCompaction(params);
|
|
19438
19727
|
const current = activeCompaction;
|
|
19439
19728
|
if (!current) return;
|
|
19440
|
-
const completedAt =
|
|
19729
|
+
const completedAt = readNumber2(params.completedAtMs ?? params.completed_at_ms) ?? now();
|
|
19441
19730
|
const postTokens = currentUsage?.lastInputTokens;
|
|
19442
19731
|
options.emit({
|
|
19443
19732
|
type: "compact_boundary",
|
|
@@ -19452,7 +19741,7 @@ function createCodexAgentEventMapper(options) {
|
|
|
19452
19741
|
if (completedTurnId) completedCompactionTurns.add(completedTurnId);
|
|
19453
19742
|
activeCompaction = null;
|
|
19454
19743
|
};
|
|
19455
|
-
const fail2 = (error51, interrupted = false) => {
|
|
19744
|
+
const fail2 = (error51, interrupted = false, errorOverrides = {}) => {
|
|
19456
19745
|
if (terminal) return;
|
|
19457
19746
|
terminal = true;
|
|
19458
19747
|
if (activeCompaction) {
|
|
@@ -19463,7 +19752,10 @@ function createCodexAgentEventMapper(options) {
|
|
|
19463
19752
|
type: "message_error",
|
|
19464
19753
|
messageId: options.messageId,
|
|
19465
19754
|
error: error51,
|
|
19466
|
-
errorInfo: buildAgentErrorInfo(error51,
|
|
19755
|
+
errorInfo: buildAgentErrorInfo(error51, {
|
|
19756
|
+
...retriedErrors.length > 0 ? { retries: { attempts: retriedErrors.length } } : {},
|
|
19757
|
+
...errorOverrides
|
|
19758
|
+
})
|
|
19467
19759
|
});
|
|
19468
19760
|
finishStatus();
|
|
19469
19761
|
};
|
|
@@ -19493,7 +19785,7 @@ function createCodexAgentEventMapper(options) {
|
|
|
19493
19785
|
const params = note.params;
|
|
19494
19786
|
switch (note.method) {
|
|
19495
19787
|
case "thread/started": {
|
|
19496
|
-
const threadId =
|
|
19788
|
+
const threadId = readString2(asRecord2(params.thread)?.id);
|
|
19497
19789
|
if (threadId && threadId !== currentThreadId) {
|
|
19498
19790
|
currentThreadId = threadId;
|
|
19499
19791
|
options.emit({ type: "codex_thread_started", messageId: options.messageId, threadId });
|
|
@@ -19502,14 +19794,14 @@ function createCodexAgentEventMapper(options) {
|
|
|
19502
19794
|
}
|
|
19503
19795
|
case "item/started":
|
|
19504
19796
|
case "item/completed": {
|
|
19505
|
-
const raw =
|
|
19797
|
+
const raw = asRecord2(params.item);
|
|
19506
19798
|
if (!raw) break;
|
|
19507
|
-
if (
|
|
19799
|
+
if (readString2(raw.type) === "contextCompaction") {
|
|
19508
19800
|
if (note.method === "item/started") startCompaction(params);
|
|
19509
19801
|
else completeCompaction(params);
|
|
19510
19802
|
break;
|
|
19511
19803
|
}
|
|
19512
|
-
const previous =
|
|
19804
|
+
const previous = readString2(raw.id) ? itemMap.get(readString2(raw.id)) : void 0;
|
|
19513
19805
|
if (previous?.type === "plan" && note.method === "item/completed") {
|
|
19514
19806
|
emitItem("completed", previous);
|
|
19515
19807
|
break;
|
|
@@ -19527,14 +19819,26 @@ function createCodexAgentEventMapper(options) {
|
|
|
19527
19819
|
case "item/agentMessage/delta":
|
|
19528
19820
|
case "item/agentMessageDelta": {
|
|
19529
19821
|
const delta = readCodexDeltaText(params);
|
|
19530
|
-
result.textDelta = delta || null;
|
|
19531
19822
|
const itemId = readCodexItemId(params);
|
|
19532
19823
|
if (!itemId) break;
|
|
19533
19824
|
const previous = itemMap.get(itemId);
|
|
19825
|
+
if (previous?.type !== "agent_message" || previous.delivery !== "async") {
|
|
19826
|
+
result.textDelta = delta || null;
|
|
19827
|
+
}
|
|
19534
19828
|
emitItem("updated", {
|
|
19535
19829
|
id: itemId,
|
|
19536
19830
|
type: "agent_message",
|
|
19537
|
-
text: `${previous?.type === "agent_message" ? previous.text : ""}${delta}
|
|
19831
|
+
text: `${previous?.type === "agent_message" ? previous.text : ""}${delta}`,
|
|
19832
|
+
...previous?.type === "agent_message" && previous.delivery === "async" ? { delivery: "async" } : {}
|
|
19833
|
+
});
|
|
19834
|
+
break;
|
|
19835
|
+
}
|
|
19836
|
+
case "autoApprovalReview/strictReviewRequired": {
|
|
19837
|
+
const turnId = readString2(params.turnId) ?? currentTurnId ?? "current";
|
|
19838
|
+
emitItem("completed", {
|
|
19839
|
+
id: `strict_review_${turnId}`,
|
|
19840
|
+
type: "error",
|
|
19841
|
+
message: "Codex requires strict safety review for this turn."
|
|
19538
19842
|
});
|
|
19539
19843
|
break;
|
|
19540
19844
|
}
|
|
@@ -19588,12 +19892,12 @@ function createCodexAgentEventMapper(options) {
|
|
|
19588
19892
|
case "turn/plan/updated": {
|
|
19589
19893
|
const rawPlan = Array.isArray(params.plan) ? params.plan : [];
|
|
19590
19894
|
const todoItems = rawPlan.map((entry) => {
|
|
19591
|
-
const step =
|
|
19592
|
-
const text =
|
|
19593
|
-
return text ? { text, completed:
|
|
19895
|
+
const step = asRecord2(entry);
|
|
19896
|
+
const text = readString2(step?.step);
|
|
19897
|
+
return text ? { text, completed: readString2(step?.status) === "completed" } : null;
|
|
19594
19898
|
}).filter((entry) => entry !== null);
|
|
19595
19899
|
if (todoItems.length > 0) {
|
|
19596
|
-
const turnId =
|
|
19900
|
+
const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId ?? "current";
|
|
19597
19901
|
emitItem("updated", { id: `todo_${turnId}`, type: "todo_list", items: todoItems });
|
|
19598
19902
|
}
|
|
19599
19903
|
break;
|
|
@@ -19617,11 +19921,11 @@ function createCodexAgentEventMapper(options) {
|
|
|
19617
19921
|
break;
|
|
19618
19922
|
}
|
|
19619
19923
|
case "mcpServer/startupStatus/updated": {
|
|
19620
|
-
const name =
|
|
19924
|
+
const name = readString2(params.name);
|
|
19621
19925
|
if (!name) break;
|
|
19622
|
-
const rawStatus =
|
|
19926
|
+
const rawStatus = readString2(params.status);
|
|
19623
19927
|
const status = rawStatus === "ready" || rawStatus === "failed" || rawStatus === "cancelled" ? rawStatus : "starting";
|
|
19624
|
-
const failureReason =
|
|
19928
|
+
const failureReason = readString2(params.failureReason) === "reauthenticationRequired" ? "reauthenticationRequired" : void 0;
|
|
19625
19929
|
mcpServers.set(name, { status, ...failureReason ? { failureReason } : {} });
|
|
19626
19930
|
options.emit({
|
|
19627
19931
|
type: "codex_mcp_startup",
|
|
@@ -19636,17 +19940,17 @@ function createCodexAgentEventMapper(options) {
|
|
|
19636
19940
|
break;
|
|
19637
19941
|
}
|
|
19638
19942
|
result.error = extractError(params);
|
|
19639
|
-
fail2(result.error);
|
|
19943
|
+
fail2(result.error, false, readCodexErrorOverrides(params));
|
|
19640
19944
|
break;
|
|
19641
19945
|
}
|
|
19642
19946
|
case "turn/completed":
|
|
19643
19947
|
case "turn/completed/v2": {
|
|
19644
|
-
const turn =
|
|
19645
|
-
currentTurnId =
|
|
19646
|
-
const status =
|
|
19948
|
+
const turn = asRecord2(params.turn);
|
|
19949
|
+
currentTurnId = readString2(turn?.id) ?? currentTurnId;
|
|
19950
|
+
const status = readString2(turn?.status) ?? readString2(params.status) ?? "completed";
|
|
19647
19951
|
if (status === "failed" || status === "error") {
|
|
19648
19952
|
result.error = extractError(turn?.error ?? params);
|
|
19649
|
-
fail2(result.error);
|
|
19953
|
+
fail2(result.error, false, readCodexErrorOverrides(turn?.error ?? params));
|
|
19650
19954
|
break;
|
|
19651
19955
|
}
|
|
19652
19956
|
if (status === "interrupted" || status === "cancelled") {
|
|
@@ -19699,6 +20003,7 @@ var init_agent_event_mapper = __esm({
|
|
|
19699
20003
|
"../../packages/codex/src/agent-event-mapper.ts"() {
|
|
19700
20004
|
"use strict";
|
|
19701
20005
|
init_agent_error();
|
|
20006
|
+
init_protocol_v149();
|
|
19702
20007
|
}
|
|
19703
20008
|
});
|
|
19704
20009
|
|
|
@@ -19993,8 +20298,8 @@ async function ensureCodexThread(opts) {
|
|
|
19993
20298
|
sandbox: "workspace-write",
|
|
19994
20299
|
...configPayload
|
|
19995
20300
|
});
|
|
19996
|
-
const thread =
|
|
19997
|
-
threadId =
|
|
20301
|
+
const thread = asRecord3(resumed.thread);
|
|
20302
|
+
threadId = readString3(thread?.id) ?? readString3(resumed.id) ?? threadId;
|
|
19998
20303
|
} else {
|
|
19999
20304
|
const started = await opts.client.request("thread/start", {
|
|
20000
20305
|
cwd: opts.cwd,
|
|
@@ -20002,8 +20307,8 @@ async function ensureCodexThread(opts) {
|
|
|
20002
20307
|
sandbox: "workspace-write",
|
|
20003
20308
|
...configPayload
|
|
20004
20309
|
});
|
|
20005
|
-
const thread =
|
|
20006
|
-
threadId =
|
|
20310
|
+
const thread = asRecord3(started.thread);
|
|
20311
|
+
threadId = readString3(thread?.id) ?? readString3(started.id);
|
|
20007
20312
|
}
|
|
20008
20313
|
if (!threadId) {
|
|
20009
20314
|
throw new Error("thread/start did not return a thread id");
|
|
@@ -20083,8 +20388,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
20083
20388
|
sandboxPolicy: buildCodexWorkspaceWriteSandboxPolicy(opts.cwd, opts.additionalDirectories),
|
|
20084
20389
|
...collaborationMode ? { collaborationMode } : {}
|
|
20085
20390
|
}));
|
|
20086
|
-
const turn =
|
|
20087
|
-
turnId =
|
|
20391
|
+
const turn = asRecord3(turnStartResult.turn);
|
|
20392
|
+
turnId = readString3(turn?.id);
|
|
20088
20393
|
}
|
|
20089
20394
|
let finalText = "";
|
|
20090
20395
|
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS;
|
|
@@ -20110,8 +20415,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
20110
20415
|
continue;
|
|
20111
20416
|
}
|
|
20112
20417
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
20113
|
-
const completedTurn =
|
|
20114
|
-
const completedId =
|
|
20418
|
+
const completedTurn = asRecord3(note.params.turn);
|
|
20419
|
+
const completedId = readString3(completedTurn?.id);
|
|
20115
20420
|
if (turnId && completedId && completedId !== turnId) {
|
|
20116
20421
|
continue;
|
|
20117
20422
|
}
|
|
@@ -20126,8 +20431,8 @@ async function runCodexAppServerTurn(opts) {
|
|
|
20126
20431
|
});
|
|
20127
20432
|
}
|
|
20128
20433
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
20129
|
-
const completedTurn =
|
|
20130
|
-
const status =
|
|
20434
|
+
const completedTurn = asRecord3(note.params.turn);
|
|
20435
|
+
const status = readString3(completedTurn?.status) ?? readString3(note.params.status);
|
|
20131
20436
|
if (status === "failed" || status === "error") {
|
|
20132
20437
|
throw new Error("Codex turn failed");
|
|
20133
20438
|
}
|
|
@@ -20180,10 +20485,10 @@ function extractAgentTextFromTurn(turn) {
|
|
|
20180
20485
|
let text = "";
|
|
20181
20486
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
20182
20487
|
for (const item of items) {
|
|
20183
|
-
const rec =
|
|
20488
|
+
const rec = asRecord3(item);
|
|
20184
20489
|
if (!rec) continue;
|
|
20185
|
-
if (
|
|
20186
|
-
const t =
|
|
20490
|
+
if (readString3(rec.type) === "agentMessage" || readString3(rec.itemType) === "agentMessage") {
|
|
20491
|
+
const t = readString3(rec.text);
|
|
20187
20492
|
if (t) text += t;
|
|
20188
20493
|
}
|
|
20189
20494
|
}
|
|
@@ -20191,7 +20496,7 @@ function extractAgentTextFromTurn(turn) {
|
|
|
20191
20496
|
}
|
|
20192
20497
|
function applyAgentDelta(note, onDelta) {
|
|
20193
20498
|
if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
|
|
20194
|
-
const delta =
|
|
20499
|
+
const delta = readString3(note.params.delta) ?? readString3(note.params.text) ?? readString3(asRecord3(note.params.item)?.delta);
|
|
20195
20500
|
if (delta) onDelta(delta);
|
|
20196
20501
|
}
|
|
20197
20502
|
}
|
|
@@ -20207,10 +20512,10 @@ function defaultSpawn(command, args, options) {
|
|
|
20207
20512
|
windowsHide: options.windowsHide
|
|
20208
20513
|
});
|
|
20209
20514
|
}
|
|
20210
|
-
function
|
|
20515
|
+
function asRecord3(value) {
|
|
20211
20516
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
20212
20517
|
}
|
|
20213
|
-
function
|
|
20518
|
+
function readString3(value) {
|
|
20214
20519
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20215
20520
|
}
|
|
20216
20521
|
var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS, TURN_WAIT_TIMEOUT_MS, MAX_STDERR_CHARS;
|
|
@@ -20258,15 +20563,54 @@ function applySetAuth(current, request) {
|
|
|
20258
20563
|
}
|
|
20259
20564
|
return { mode, apiKey: normalizeApiKey(apiKey) };
|
|
20260
20565
|
}
|
|
20261
|
-
function
|
|
20566
|
+
function asRecord4(value) {
|
|
20262
20567
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
20263
20568
|
}
|
|
20264
|
-
function
|
|
20569
|
+
function readString4(value) {
|
|
20265
20570
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20266
20571
|
}
|
|
20267
20572
|
function readBoolean2(value) {
|
|
20268
20573
|
return typeof value === "boolean" ? value : null;
|
|
20269
20574
|
}
|
|
20575
|
+
function parseAccountAuthMode(value) {
|
|
20576
|
+
switch (value) {
|
|
20577
|
+
case "apiKey":
|
|
20578
|
+
case "chatgpt":
|
|
20579
|
+
case "chatgptAuthTokens":
|
|
20580
|
+
case "agentIdentity":
|
|
20581
|
+
case "personalAccessToken":
|
|
20582
|
+
case "amazonBedrock":
|
|
20583
|
+
case "bedrockApiKey":
|
|
20584
|
+
return value;
|
|
20585
|
+
default:
|
|
20586
|
+
return null;
|
|
20587
|
+
}
|
|
20588
|
+
}
|
|
20589
|
+
function parseAccountStatus(raw) {
|
|
20590
|
+
const account = asRecord4(raw.account);
|
|
20591
|
+
return {
|
|
20592
|
+
signedIn: account !== null,
|
|
20593
|
+
authMode: parseAccountAuthMode(account?.type),
|
|
20594
|
+
email: readString4(account?.email),
|
|
20595
|
+
planType: readString4(account?.planType),
|
|
20596
|
+
requiresOpenaiAuth: readBoolean2(raw.requiresOpenaiAuth) ?? false
|
|
20597
|
+
};
|
|
20598
|
+
}
|
|
20599
|
+
function parseAccountLoginStart(raw) {
|
|
20600
|
+
const loginId = readString4(raw.loginId);
|
|
20601
|
+
const type = readString4(raw.type);
|
|
20602
|
+
if (!loginId || type !== "chatgpt" && type !== "chatgptDeviceCode") {
|
|
20603
|
+
throw new Error("Codex returned an invalid account login response");
|
|
20604
|
+
}
|
|
20605
|
+
const result = { type, loginId };
|
|
20606
|
+
const authUrl = readString4(raw.authUrl);
|
|
20607
|
+
const verificationUrl = readString4(raw.verificationUrl);
|
|
20608
|
+
const userCode = readString4(raw.userCode);
|
|
20609
|
+
if (authUrl) result.authUrl = authUrl;
|
|
20610
|
+
if (verificationUrl) result.verificationUrl = verificationUrl;
|
|
20611
|
+
if (userCode) result.userCode = userCode;
|
|
20612
|
+
return result;
|
|
20613
|
+
}
|
|
20270
20614
|
function readFiniteNumber(value) {
|
|
20271
20615
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
20272
20616
|
}
|
|
@@ -20293,15 +20637,15 @@ function parseRateLimitWindow(raw) {
|
|
|
20293
20637
|
function parseResetCredit(raw) {
|
|
20294
20638
|
if (!raw || typeof raw !== "object") return null;
|
|
20295
20639
|
const rec = raw;
|
|
20296
|
-
const id =
|
|
20640
|
+
const id = readString4(rec.id);
|
|
20297
20641
|
if (!id) return null;
|
|
20298
|
-
const rawStatus =
|
|
20642
|
+
const rawStatus = readString4(rec.status);
|
|
20299
20643
|
const status = rawStatus === "available" || rawStatus === "redeeming" || rawStatus === "redeemed" ? rawStatus : "unknown";
|
|
20300
20644
|
return {
|
|
20301
20645
|
id,
|
|
20302
20646
|
status,
|
|
20303
|
-
title:
|
|
20304
|
-
description:
|
|
20647
|
+
title: readString4(rec.title) ?? null,
|
|
20648
|
+
description: readString4(rec.description) ?? null,
|
|
20305
20649
|
expiresAt: readNumericLike(rec.expiresAt)
|
|
20306
20650
|
};
|
|
20307
20651
|
}
|
|
@@ -20318,32 +20662,62 @@ function parseRateLimits(raw) {
|
|
|
20318
20662
|
return {
|
|
20319
20663
|
primary,
|
|
20320
20664
|
secondary,
|
|
20321
|
-
planType:
|
|
20665
|
+
planType: readString4(snapshot.planType),
|
|
20322
20666
|
resetCredits,
|
|
20323
20667
|
...resetCreditList && resetCreditList.length > 0 ? { resetCreditList } : {}
|
|
20324
20668
|
};
|
|
20325
20669
|
}
|
|
20326
20670
|
function parseAccountUsage(raw) {
|
|
20327
20671
|
const summary = raw.summary && typeof raw.summary === "object" ? raw.summary : raw;
|
|
20672
|
+
const threadUsage = parseThreadUsage(raw.threadUsage);
|
|
20328
20673
|
const usage2 = {
|
|
20329
20674
|
lifetimeTokens: readNumericLike(summary.lifetimeTokens),
|
|
20330
20675
|
peakDailyTokens: readNumericLike(summary.peakDailyTokens),
|
|
20331
20676
|
longestRunningTurnSec: readNumericLike(summary.longestRunningTurnSec),
|
|
20332
20677
|
currentStreakDays: readNumericLike(summary.currentStreakDays),
|
|
20333
|
-
longestStreakDays: readNumericLike(summary.longestStreakDays)
|
|
20678
|
+
longestStreakDays: readNumericLike(summary.longestStreakDays),
|
|
20679
|
+
...threadUsage ? { threadUsage } : {}
|
|
20334
20680
|
};
|
|
20335
|
-
const hasAny = Object.values(usage2).some((v2) => v2 !== null);
|
|
20681
|
+
const hasAny = Object.values(usage2).some((v2) => v2 !== null && v2 !== void 0);
|
|
20336
20682
|
return hasAny ? usage2 : null;
|
|
20337
20683
|
}
|
|
20684
|
+
function parseThreadUsage(raw) {
|
|
20685
|
+
const rec = asRecord4(raw);
|
|
20686
|
+
const threadId = readString4(rec?.threadId);
|
|
20687
|
+
const credits = readNumericLike(rec?.estimatedUsageCreditsMicros);
|
|
20688
|
+
if (!threadId || credits === null) return null;
|
|
20689
|
+
const groups = Array.isArray(rec?.groups) ? rec.groups.flatMap((value) => {
|
|
20690
|
+
const group = asRecord4(value);
|
|
20691
|
+
const groupCredits = readNumericLike(group?.estimatedUsageCreditsMicros);
|
|
20692
|
+
if (!group || groupCredits === null) return [];
|
|
20693
|
+
return [{
|
|
20694
|
+
model: readString4(group.model),
|
|
20695
|
+
reasoningEffort: readString4(group.reasoningEffort),
|
|
20696
|
+
speed: readString4(group.speed),
|
|
20697
|
+
estimatedUsageCreditsMicros: groupCredits,
|
|
20698
|
+
netNewInputTokens: readNumericLike(group.netNewInputTokens),
|
|
20699
|
+
cachedInputTokens: readNumericLike(group.cachedInputTokens),
|
|
20700
|
+
inputTokens: readNumericLike(group.inputTokens),
|
|
20701
|
+
outputTokens: readNumericLike(group.outputTokens),
|
|
20702
|
+
totalTokens: readNumericLike(group.totalTokens)
|
|
20703
|
+
}];
|
|
20704
|
+
}) : [];
|
|
20705
|
+
return {
|
|
20706
|
+
threadId,
|
|
20707
|
+
estimatedUsageCreditsMicros: credits,
|
|
20708
|
+
estimatedUsageUsdMicros: readNumericLike(rec?.estimatedUsageUsdMicros),
|
|
20709
|
+
groups
|
|
20710
|
+
};
|
|
20711
|
+
}
|
|
20338
20712
|
function parseExternalAgentItem(raw) {
|
|
20339
20713
|
if (!raw || typeof raw !== "object") return null;
|
|
20340
20714
|
const rec = raw;
|
|
20341
|
-
const itemType =
|
|
20715
|
+
const itemType = readString4(rec.itemType);
|
|
20342
20716
|
if (!itemType) return null;
|
|
20343
20717
|
return {
|
|
20344
20718
|
itemType,
|
|
20345
|
-
description:
|
|
20346
|
-
cwd:
|
|
20719
|
+
description: readString4(rec.description) ?? "",
|
|
20720
|
+
cwd: readString4(rec.cwd) ?? null,
|
|
20347
20721
|
...rec.details !== void 0 ? { details: rec.details } : {}
|
|
20348
20722
|
};
|
|
20349
20723
|
}
|
|
@@ -20367,16 +20741,47 @@ async function readRateLimits(client3) {
|
|
|
20367
20741
|
throw safePublicError("account/rateLimits/read failed", err);
|
|
20368
20742
|
}
|
|
20369
20743
|
}
|
|
20370
|
-
async function
|
|
20744
|
+
async function readAccountStatus(client3, refreshToken = false) {
|
|
20745
|
+
try {
|
|
20746
|
+
return parseAccountStatus(await client3.request("account/read", { refreshToken }));
|
|
20747
|
+
} catch (err) {
|
|
20748
|
+
throw safePublicError("account/read failed", err);
|
|
20749
|
+
}
|
|
20750
|
+
}
|
|
20751
|
+
async function startAccountLogin(client3, type) {
|
|
20752
|
+
try {
|
|
20753
|
+
return parseAccountLoginStart(await client3.request(
|
|
20754
|
+
"account/login/start",
|
|
20755
|
+
type === "chatgpt" ? { type, useHostedLoginSuccessPage: true, appBrand: "chatgpt" } : { type }
|
|
20756
|
+
));
|
|
20757
|
+
} catch (err) {
|
|
20758
|
+
throw safePublicError("account/login/start failed", err);
|
|
20759
|
+
}
|
|
20760
|
+
}
|
|
20761
|
+
async function cancelAccountLogin(client3, loginId) {
|
|
20762
|
+
try {
|
|
20763
|
+
await client3.request("account/login/cancel", { loginId });
|
|
20764
|
+
} catch (err) {
|
|
20765
|
+
throw safePublicError("account/login/cancel failed", err);
|
|
20766
|
+
}
|
|
20767
|
+
}
|
|
20768
|
+
async function logoutAccount(client3) {
|
|
20371
20769
|
try {
|
|
20372
|
-
|
|
20770
|
+
await client3.request("account/logout");
|
|
20771
|
+
} catch (err) {
|
|
20772
|
+
throw safePublicError("account/logout failed", err);
|
|
20773
|
+
}
|
|
20774
|
+
}
|
|
20775
|
+
async function readAccountUsage(client3, threadId) {
|
|
20776
|
+
try {
|
|
20777
|
+
const result = await client3.request("account/usage/read", threadId ? { threadId } : {});
|
|
20373
20778
|
return parseAccountUsage(result);
|
|
20374
20779
|
} catch (err) {
|
|
20375
20780
|
throw safePublicError("account/usage/read failed", err);
|
|
20376
20781
|
}
|
|
20377
20782
|
}
|
|
20378
20783
|
function parseResetOutcome(raw) {
|
|
20379
|
-
switch (
|
|
20784
|
+
switch (readString4(raw.outcome)) {
|
|
20380
20785
|
case "reset":
|
|
20381
20786
|
return "reset";
|
|
20382
20787
|
case "nothingToReset":
|
|
@@ -20400,20 +20805,27 @@ async function consumeRateLimitReset(client3, creditId) {
|
|
|
20400
20805
|
throw safePublicError("account/rateLimitResetCredit/consume failed", err);
|
|
20401
20806
|
}
|
|
20402
20807
|
}
|
|
20403
|
-
async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e4) {
|
|
20808
|
+
async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e4, options) {
|
|
20404
20809
|
try {
|
|
20405
|
-
const res = await client3.request("mcpServer/oauth/login", {
|
|
20406
|
-
|
|
20810
|
+
const res = await client3.request("mcpServer/oauth/login", compactRecord2({
|
|
20811
|
+
name: serverName,
|
|
20812
|
+
clientRegistration: options?.clientRegistration,
|
|
20813
|
+
threadId: options?.threadId,
|
|
20814
|
+
scopes: options?.scopes,
|
|
20815
|
+
timeoutSecs: options?.timeoutSecs
|
|
20816
|
+
}));
|
|
20817
|
+
const authorizationUrl = readString4(res.authorizationUrl);
|
|
20407
20818
|
if (!authorizationUrl) return { success: false, error: "Codex returned no authorization URL" };
|
|
20408
20819
|
openUrl?.(authorizationUrl);
|
|
20409
|
-
const
|
|
20820
|
+
const effectiveTimeoutMs = typeof options?.timeoutSecs === "number" && options.timeoutSecs > 0 ? options.timeoutSecs * 1e3 : timeoutMs;
|
|
20821
|
+
const deadline = Date.now() + effectiveTimeoutMs;
|
|
20410
20822
|
while (Date.now() < deadline) {
|
|
20411
20823
|
const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
|
|
20412
20824
|
if (!notif) continue;
|
|
20413
|
-
if (notif.method === "mcpServer/oauthLogin/completed" &&
|
|
20825
|
+
if (notif.method === "mcpServer/oauthLogin/completed" && readString4(notif.params.name) === serverName && (!options?.threadId || readString4(notif.params.threadId) === options.threadId)) {
|
|
20414
20826
|
return {
|
|
20415
20827
|
success: readBoolean2(notif.params.success) ?? false,
|
|
20416
|
-
error:
|
|
20828
|
+
error: readString4(notif.params.error) ?? void 0,
|
|
20417
20829
|
authorizationUrl
|
|
20418
20830
|
};
|
|
20419
20831
|
}
|
|
@@ -20449,12 +20861,12 @@ async function importExternalAgentConfig(client3, items, timeoutMs = 12e4) {
|
|
|
20449
20861
|
migrationItems: items,
|
|
20450
20862
|
source: "superone"
|
|
20451
20863
|
});
|
|
20452
|
-
const importId =
|
|
20864
|
+
const importId = readString4(res.importId);
|
|
20453
20865
|
const deadline = Date.now() + timeoutMs;
|
|
20454
20866
|
while (Date.now() < deadline) {
|
|
20455
20867
|
const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
|
|
20456
20868
|
if (!notif) continue;
|
|
20457
|
-
if (notif.method === "externalAgentConfig/import/completed" && (!importId ||
|
|
20869
|
+
if (notif.method === "externalAgentConfig/import/completed" && (!importId || readString4(notif.params.importId) === importId)) {
|
|
20458
20870
|
return summarizeImportResults(notif.params.itemTypeResults);
|
|
20459
20871
|
}
|
|
20460
20872
|
}
|
|
@@ -20471,19 +20883,19 @@ async function listPluginInventory(client3, projectPath) {
|
|
|
20471
20883
|
const marketplaces = Array.isArray(result.marketplaces) ? result.marketplaces : [];
|
|
20472
20884
|
const records = [];
|
|
20473
20885
|
for (const rawMarketplace of marketplaces) {
|
|
20474
|
-
const marketplace =
|
|
20886
|
+
const marketplace = asRecord4(rawMarketplace);
|
|
20475
20887
|
if (!marketplace) continue;
|
|
20476
|
-
const marketplaceName =
|
|
20477
|
-
const marketplacePath =
|
|
20888
|
+
const marketplaceName = readString4(marketplace.name);
|
|
20889
|
+
const marketplacePath = readString4(marketplace.path);
|
|
20478
20890
|
if (!marketplaceName || !marketplacePath) continue;
|
|
20479
20891
|
const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
20480
20892
|
for (const rawPlugin of plugins) {
|
|
20481
|
-
const plugin =
|
|
20893
|
+
const plugin = asRecord4(rawPlugin);
|
|
20482
20894
|
if (!plugin) continue;
|
|
20483
|
-
const key =
|
|
20484
|
-
const name =
|
|
20485
|
-
const source =
|
|
20486
|
-
const sourcePath =
|
|
20895
|
+
const key = readString4(plugin.id);
|
|
20896
|
+
const name = readString4(plugin.name);
|
|
20897
|
+
const source = asRecord4(plugin.source);
|
|
20898
|
+
const sourcePath = readString4(source?.path) ?? void 0;
|
|
20487
20899
|
if (!key || !name) continue;
|
|
20488
20900
|
records.push({
|
|
20489
20901
|
key,
|
|
@@ -20513,8 +20925,8 @@ async function marketplaceAdd(client3, request) {
|
|
|
20513
20925
|
sparsePaths: request.sparsePaths && request.sparsePaths.length > 0 ? request.sparsePaths : void 0
|
|
20514
20926
|
}));
|
|
20515
20927
|
return {
|
|
20516
|
-
marketplaceName:
|
|
20517
|
-
installedRoot:
|
|
20928
|
+
marketplaceName: readString4(result.marketplaceName) ?? "",
|
|
20929
|
+
installedRoot: readString4(result.installedRoot) ?? "",
|
|
20518
20930
|
alreadyAdded: readBoolean2(result.alreadyAdded) ?? false
|
|
20519
20931
|
};
|
|
20520
20932
|
}
|
|
@@ -20530,10 +20942,10 @@ async function marketplaceUpgrade(client3, marketplaceName) {
|
|
|
20530
20942
|
name ? { marketplaceName: name } : {}
|
|
20531
20943
|
);
|
|
20532
20944
|
const errors = Array.isArray(result.errors) ? result.errors.map((raw) => {
|
|
20533
|
-
const rec =
|
|
20945
|
+
const rec = asRecord4(raw);
|
|
20534
20946
|
if (!rec) return null;
|
|
20535
|
-
const marketplaceName2 =
|
|
20536
|
-
const message =
|
|
20947
|
+
const marketplaceName2 = readString4(rec.marketplaceName) ?? readString4(rec.name);
|
|
20948
|
+
const message = readString4(rec.message) ?? readString4(rec.error);
|
|
20537
20949
|
if (!marketplaceName2 || !message) return null;
|
|
20538
20950
|
return { marketplaceName: marketplaceName2, message };
|
|
20539
20951
|
}).filter((e) => e !== null) : [];
|
|
@@ -20593,6 +21005,7 @@ var init_src = __esm({
|
|
|
20593
21005
|
init_codex_admin();
|
|
20594
21006
|
init_fork_thread();
|
|
20595
21007
|
init_agent_event_mapper();
|
|
21008
|
+
init_protocol_v149();
|
|
20596
21009
|
}
|
|
20597
21010
|
});
|
|
20598
21011
|
|
|
@@ -20618,7 +21031,7 @@ function isStaticHostOwnedSuperoneToolQualified(qualifiedName) {
|
|
|
20618
21031
|
const bare = qualifiedName.slice(MCP_SUPERONE_TOOL_PREFIX.length);
|
|
20619
21032
|
return isStaticHostOwnedSuperoneBareName(bare);
|
|
20620
21033
|
}
|
|
20621
|
-
var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_LEGACY_TOOL_NAMES, BROWSER_COMPACT_TOOL_NAMES, BROWSER_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
|
|
21034
|
+
var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_LEGACY_TOOL_NAMES, BROWSER_COMPACT_TOOL_NAMES, BROWSER_TOOL_NAMES, DEVICE_AGENT_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
|
|
20622
21035
|
var init_superone_host_owned_tools = __esm({
|
|
20623
21036
|
"../../packages/shared/src/superone-host-owned-tools.ts"() {
|
|
20624
21037
|
"use strict";
|
|
@@ -20679,6 +21092,14 @@ var init_superone_host_owned_tools = __esm({
|
|
|
20679
21092
|
(name) => !BROWSER_LEGACY_TOOL_NAMES.includes(name)
|
|
20680
21093
|
)
|
|
20681
21094
|
];
|
|
21095
|
+
DEVICE_AGENT_TOOL_NAMES = [
|
|
21096
|
+
"device_list",
|
|
21097
|
+
"device_request_control",
|
|
21098
|
+
"device_snapshot",
|
|
21099
|
+
"device_query",
|
|
21100
|
+
"device_act",
|
|
21101
|
+
"device_wait_for"
|
|
21102
|
+
];
|
|
20682
21103
|
BUILT_IN_SUPERONE_TOOL_NAMES = [
|
|
20683
21104
|
"read_manual",
|
|
20684
21105
|
"miniapp_dev_setup",
|
|
@@ -20709,7 +21130,8 @@ var init_superone_host_owned_tools = __esm({
|
|
|
20709
21130
|
"automation_list",
|
|
20710
21131
|
"automation_apply",
|
|
20711
21132
|
"automation_delete",
|
|
20712
|
-
...BROWSER_TOOL_NAMES
|
|
21133
|
+
...BROWSER_TOOL_NAMES,
|
|
21134
|
+
...DEVICE_AGENT_TOOL_NAMES
|
|
20713
21135
|
];
|
|
20714
21136
|
MOBILE_SHARE_FILE_TOOL_NAME = "mobile_share_file";
|
|
20715
21137
|
MINIAPP_LIST_BARE_NAME = "miniapp_list";
|
|
@@ -20724,7 +21146,7 @@ var init_superone_host_owned_tools = __esm({
|
|
|
20724
21146
|
});
|
|
20725
21147
|
|
|
20726
21148
|
// ../../packages/claude/src/map-sdk-message.ts
|
|
20727
|
-
function
|
|
21149
|
+
function asRecord5(value) {
|
|
20728
21150
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
20729
21151
|
return value;
|
|
20730
21152
|
}
|
|
@@ -20766,11 +21188,11 @@ function applySdkMessage(message, state, emit) {
|
|
|
20766
21188
|
const sessionId = sessionIdOf(record2);
|
|
20767
21189
|
const parentToolUseId = typeof record2.parent_tool_use_id === "string" ? record2.parent_tool_use_id : null;
|
|
20768
21190
|
if (record2.type === "stream_event") {
|
|
20769
|
-
const event =
|
|
21191
|
+
const event = asRecord5(record2.event);
|
|
20770
21192
|
if (!event) return emptyApply(sessionId);
|
|
20771
21193
|
const index = typeof event.index === "number" ? event.index : null;
|
|
20772
21194
|
if (event.type === "content_block_start") {
|
|
20773
|
-
const block =
|
|
21195
|
+
const block = asRecord5(event.content_block);
|
|
20774
21196
|
if (!block) return emptyApply(sessionId);
|
|
20775
21197
|
if (block.type === "text" && index != null) {
|
|
20776
21198
|
state.indexToKind.set(index, "text");
|
|
@@ -20802,7 +21224,7 @@ function applySdkMessage(message, state, emit) {
|
|
|
20802
21224
|
return emptyApply(sessionId);
|
|
20803
21225
|
}
|
|
20804
21226
|
if (event.type === "content_block_delta") {
|
|
20805
|
-
const delta =
|
|
21227
|
+
const delta = asRecord5(event.delta);
|
|
20806
21228
|
if (!delta) return emptyApply(sessionId);
|
|
20807
21229
|
if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
|
|
20808
21230
|
return {
|
|
@@ -20836,10 +21258,10 @@ function applySdkMessage(message, state, emit) {
|
|
|
20836
21258
|
return emptyApply(sessionId);
|
|
20837
21259
|
}
|
|
20838
21260
|
if (record2.type === "assistant") {
|
|
20839
|
-
const messageBody =
|
|
21261
|
+
const messageBody = asRecord5(record2.message);
|
|
20840
21262
|
const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
|
|
20841
21263
|
for (const raw of content) {
|
|
20842
|
-
const block =
|
|
21264
|
+
const block = asRecord5(raw);
|
|
20843
21265
|
if (!block || block.type !== "tool_use") continue;
|
|
20844
21266
|
const toolUseId = typeof block.id === "string" && block.id.length > 0 ? block.id : null;
|
|
20845
21267
|
const toolName = typeof block.name === "string" && block.name.length > 0 ? block.name : "unknown";
|
|
@@ -20866,10 +21288,10 @@ function applySdkMessage(message, state, emit) {
|
|
|
20866
21288
|
return emptyApply(sessionId);
|
|
20867
21289
|
}
|
|
20868
21290
|
if (record2.type === "user") {
|
|
20869
|
-
const messageBody =
|
|
21291
|
+
const messageBody = asRecord5(record2.message);
|
|
20870
21292
|
const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
|
|
20871
21293
|
for (const raw of content) {
|
|
20872
|
-
const block =
|
|
21294
|
+
const block = asRecord5(raw);
|
|
20873
21295
|
if (!block || block.type !== "tool_result") continue;
|
|
20874
21296
|
const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : typeof block.toolUseId === "string" ? block.toolUseId : null;
|
|
20875
21297
|
if (!toolUseId) continue;
|
|
@@ -21182,6 +21604,7 @@ function createClaudeAgentEventMapper(options) {
|
|
|
21182
21604
|
outputStyle: system.output_style,
|
|
21183
21605
|
availableOutputStyles: system.available_output_styles,
|
|
21184
21606
|
plugins: system.plugins,
|
|
21607
|
+
...system.effort !== void 0 ? { appliedEffort: system.effort } : {},
|
|
21185
21608
|
fastModeState: system.fast_mode_state,
|
|
21186
21609
|
fastModeDisabledReason: system.fast_mode_disabled_reason
|
|
21187
21610
|
}
|
|
@@ -21716,6 +22139,94 @@ var init_root_permission_guard = __esm({
|
|
|
21716
22139
|
}
|
|
21717
22140
|
});
|
|
21718
22141
|
|
|
22142
|
+
// ../../packages/shared/src/ask-user-question.ts
|
|
22143
|
+
function asQuestionPreviewFormat(value) {
|
|
22144
|
+
const v2 = value?.trim();
|
|
22145
|
+
return v2 === "markdown" || v2 === "html" ? v2 : void 0;
|
|
22146
|
+
}
|
|
22147
|
+
function buildAnsweredQuestionInput(params) {
|
|
22148
|
+
const { questions, answers, previewFormat } = params;
|
|
22149
|
+
const annotations = { ...params.annotations };
|
|
22150
|
+
for (const q of questions) {
|
|
22151
|
+
const answer = answers[q.question];
|
|
22152
|
+
if (!answer) continue;
|
|
22153
|
+
const lastLabel = q.multiSelect ? answer.split(", ").pop() : answer;
|
|
22154
|
+
const selected = q.options?.find((o) => o.label === lastLabel);
|
|
22155
|
+
if (selected?.preview) {
|
|
22156
|
+
annotations[q.question] = { ...annotations[q.question], preview: selected.preview };
|
|
22157
|
+
}
|
|
22158
|
+
}
|
|
22159
|
+
return {
|
|
22160
|
+
questions,
|
|
22161
|
+
answers,
|
|
22162
|
+
...Object.keys(annotations).length > 0 && { annotations },
|
|
22163
|
+
...previewFormat ? { previewFormat } : {}
|
|
22164
|
+
};
|
|
22165
|
+
}
|
|
22166
|
+
function answeredQuestionDelta(messageId, toolUseId, input) {
|
|
22167
|
+
return {
|
|
22168
|
+
type: "content_delta",
|
|
22169
|
+
messageId,
|
|
22170
|
+
delta: {
|
|
22171
|
+
type: "tool_use",
|
|
22172
|
+
toolName: "AskUserQuestion",
|
|
22173
|
+
toolUseId,
|
|
22174
|
+
input: JSON.stringify(input)
|
|
22175
|
+
}
|
|
22176
|
+
};
|
|
22177
|
+
}
|
|
22178
|
+
var init_ask_user_question = __esm({
|
|
22179
|
+
"../../packages/shared/src/ask-user-question.ts"() {
|
|
22180
|
+
"use strict";
|
|
22181
|
+
}
|
|
22182
|
+
});
|
|
22183
|
+
|
|
22184
|
+
// ../../packages/claude/src/ask-user-question-bridge.ts
|
|
22185
|
+
function asRecord6(value) {
|
|
22186
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
22187
|
+
}
|
|
22188
|
+
async function resolveAskUserQuestion(params) {
|
|
22189
|
+
const { onQuestion, interactionId, toolName, toolUseId, input } = params;
|
|
22190
|
+
if (!onQuestion) {
|
|
22191
|
+
return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
|
|
22192
|
+
}
|
|
22193
|
+
const previewFormat = asQuestionPreviewFormat(params.previewFormat);
|
|
22194
|
+
const rawInput = asRecord6(input);
|
|
22195
|
+
const baseInput = rawInput ? { ...rawInput, ...previewFormat ? { previewFormat } : {} } : null;
|
|
22196
|
+
const answer = await onQuestion({
|
|
22197
|
+
interactionId,
|
|
22198
|
+
kind: "question",
|
|
22199
|
+
toolName,
|
|
22200
|
+
toolUseId,
|
|
22201
|
+
input: baseInput ?? void 0
|
|
22202
|
+
});
|
|
22203
|
+
const record2 = asRecord6(answer);
|
|
22204
|
+
const answers = record2 && "answers" in record2 ? record2.answers : answer;
|
|
22205
|
+
const answerMap = asRecord6(answers);
|
|
22206
|
+
const updatedInput = {
|
|
22207
|
+
...baseInput,
|
|
22208
|
+
...buildAnsweredQuestionInput({
|
|
22209
|
+
questions: Array.isArray(baseInput?.questions) ? baseInput.questions : [],
|
|
22210
|
+
answers: answerMap ?? {},
|
|
22211
|
+
annotations: record2?.annotations,
|
|
22212
|
+
previewFormat
|
|
22213
|
+
}),
|
|
22214
|
+
// Preserve the host's answer shape verbatim — it is not always a record.
|
|
22215
|
+
answers
|
|
22216
|
+
};
|
|
22217
|
+
const messageId = params.getMessageId?.();
|
|
22218
|
+
if (messageId && toolUseId && params.emitAgentEvent) {
|
|
22219
|
+
params.emitAgentEvent(answeredQuestionDelta(messageId, toolUseId, updatedInput));
|
|
22220
|
+
}
|
|
22221
|
+
return { behavior: "allow", updatedInput };
|
|
22222
|
+
}
|
|
22223
|
+
var init_ask_user_question_bridge = __esm({
|
|
22224
|
+
"../../packages/claude/src/ask-user-question-bridge.ts"() {
|
|
22225
|
+
"use strict";
|
|
22226
|
+
init_ask_user_question();
|
|
22227
|
+
}
|
|
22228
|
+
});
|
|
22229
|
+
|
|
21719
22230
|
// ../../packages/claude/src/run-sdk-turn.ts
|
|
21720
22231
|
import { query as sdkQuery } from "@anthropic-ai/claude-agent-sdk";
|
|
21721
22232
|
var init_run_sdk_turn = __esm({
|
|
@@ -21727,6 +22238,8 @@ var init_run_sdk_turn = __esm({
|
|
|
21727
22238
|
init_agent_event_mapper2();
|
|
21728
22239
|
init_resolve_sdk_binary();
|
|
21729
22240
|
init_root_permission_guard();
|
|
22241
|
+
init_ask_user_question_bridge();
|
|
22242
|
+
init_ask_user_question();
|
|
21730
22243
|
}
|
|
21731
22244
|
});
|
|
21732
22245
|
|
|
@@ -21800,7 +22313,7 @@ var init_message_bridge = __esm({
|
|
|
21800
22313
|
import { existsSync as existsSync18 } from "node:fs";
|
|
21801
22314
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
21802
22315
|
import { query as sdkQuery2 } from "@anthropic-ai/claude-agent-sdk";
|
|
21803
|
-
function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing) {
|
|
22316
|
+
function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing, turn) {
|
|
21804
22317
|
const abortController = new AbortController();
|
|
21805
22318
|
if (signal.aborted) abortController.abort();
|
|
21806
22319
|
else signal.addEventListener("abort", () => abortController.abort(), { once: true });
|
|
@@ -21813,26 +22326,16 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
|
|
|
21813
22326
|
}
|
|
21814
22327
|
const interactionId = typeof toolOpts.requestId === "string" && toolOpts.requestId || typeof toolOpts.toolUseID === "string" && toolOpts.toolUseID || `interaction_${Date.now()}`;
|
|
21815
22328
|
if (toolName === "AskUserQuestion") {
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
}
|
|
21819
|
-
const answer = await onQuestion({
|
|
22329
|
+
return resolveAskUserQuestion({
|
|
22330
|
+
onQuestion,
|
|
21820
22331
|
interactionId,
|
|
21821
|
-
kind: "question",
|
|
21822
22332
|
toolName,
|
|
21823
22333
|
toolUseId: typeof toolOpts.toolUseID === "string" ? toolOpts.toolUseID : void 0,
|
|
21824
|
-
input
|
|
22334
|
+
input,
|
|
22335
|
+
previewFormat: opts.askUserQuestionPreviewFormat,
|
|
22336
|
+
emitAgentEvent: turn.emitAgentEvent,
|
|
22337
|
+
getMessageId: turn.getMessageId
|
|
21825
22338
|
});
|
|
21826
|
-
const record2 = answer && typeof answer === "object" ? answer : null;
|
|
21827
|
-
const answers = record2 && "answers" in record2 ? record2.answers : answer;
|
|
21828
|
-
return {
|
|
21829
|
-
behavior: "allow",
|
|
21830
|
-
updatedInput: {
|
|
21831
|
-
...input && typeof input === "object" ? input : {},
|
|
21832
|
-
answers,
|
|
21833
|
-
...record2 && record2.annotations !== void 0 ? { annotations: record2.annotations } : {}
|
|
21834
|
-
}
|
|
21835
|
-
};
|
|
21836
22339
|
}
|
|
21837
22340
|
if (toolName === "ExitPlanMode") {
|
|
21838
22341
|
if (!onPlan) {
|
|
@@ -21900,6 +22403,7 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
|
|
|
21900
22403
|
...sandbox ? { sandbox } : {},
|
|
21901
22404
|
...opts.additionalDirectories && opts.additionalDirectories.length > 0 ? { additionalDirectories: opts.additionalDirectories } : {},
|
|
21902
22405
|
...opts.enabledSkills && opts.enabledSkills.length > 0 ? { skills: opts.enabledSkills } : {},
|
|
22406
|
+
...asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) ? { toolConfig: { askUserQuestion: { previewFormat: asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) } } } : {},
|
|
21903
22407
|
systemPrompt: {
|
|
21904
22408
|
type: "preset",
|
|
21905
22409
|
preset: "claude_code",
|
|
@@ -21936,6 +22440,8 @@ var init_claude_live_session = __esm({
|
|
|
21936
22440
|
init_map_sdk_message();
|
|
21937
22441
|
init_resolve_sdk_binary();
|
|
21938
22442
|
init_root_permission_guard();
|
|
22443
|
+
init_ask_user_question_bridge();
|
|
22444
|
+
init_ask_user_question();
|
|
21939
22445
|
init_superone_system_prompt();
|
|
21940
22446
|
init_superone_host_owned_tools();
|
|
21941
22447
|
ClaudeLiveSession = class _ClaudeLiveSession {
|
|
@@ -21959,7 +22465,11 @@ var init_claude_live_session = __esm({
|
|
|
21959
22465
|
return this.planHandler(req);
|
|
21960
22466
|
},
|
|
21961
22467
|
this.processAbort.signal,
|
|
21962
|
-
this.timing
|
|
22468
|
+
this.timing,
|
|
22469
|
+
{
|
|
22470
|
+
emitAgentEvent: (e) => this.active?.input.onAgentEvent?.(e),
|
|
22471
|
+
getMessageId: () => this.active?.messageId
|
|
22472
|
+
}
|
|
21963
22473
|
);
|
|
21964
22474
|
const q = queryFn({ prompt: this.bridge, options });
|
|
21965
22475
|
this.iterationDone = this.iterate(q);
|
|
@@ -22481,7 +22991,7 @@ var init_content_delta = __esm({
|
|
|
22481
22991
|
});
|
|
22482
22992
|
|
|
22483
22993
|
// ../../packages/shared/src/node-session-event-map.ts
|
|
22484
|
-
function
|
|
22994
|
+
function asRecord7(value) {
|
|
22485
22995
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
22486
22996
|
return value;
|
|
22487
22997
|
}
|
|
@@ -22513,7 +23023,7 @@ function stamp(event, ctx, sequence) {
|
|
|
22513
23023
|
}
|
|
22514
23024
|
function mapQuestionRequest(payload, fallbackId) {
|
|
22515
23025
|
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
22516
|
-
const input =
|
|
23026
|
+
const input = asRecord7(payload.input);
|
|
22517
23027
|
const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
|
|
22518
23028
|
const questions = [];
|
|
22519
23029
|
for (const q of rawQuestions) {
|
|
@@ -22552,7 +23062,7 @@ function mapQuestionRequest(payload, fallbackId) {
|
|
|
22552
23062
|
}
|
|
22553
23063
|
function mapPlanRequest(payload, fallbackId) {
|
|
22554
23064
|
const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
|
|
22555
|
-
const input =
|
|
23065
|
+
const input = asRecord7(payload.input);
|
|
22556
23066
|
let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
|
|
22557
23067
|
if (!planContent && input.plan && typeof input.plan === "object") {
|
|
22558
23068
|
try {
|
|
@@ -22618,7 +23128,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
22618
23128
|
if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
|
|
22619
23129
|
if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
|
|
22620
23130
|
const eventType = envelope.eventType;
|
|
22621
|
-
const payload =
|
|
23131
|
+
const payload = asRecord7(envelope.payload);
|
|
22622
23132
|
const out = [];
|
|
22623
23133
|
const push = (event) => {
|
|
22624
23134
|
out.push(stamp(event, ctx, envelope.sequence));
|
|
@@ -22644,7 +23154,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
22644
23154
|
break;
|
|
22645
23155
|
}
|
|
22646
23156
|
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
22647
|
-
const rawEvent =
|
|
23157
|
+
const rawEvent = asRecord7(payload.event);
|
|
22648
23158
|
const type = asString2(rawEvent.type);
|
|
22649
23159
|
if (!type) break;
|
|
22650
23160
|
const eventRecord = { ...rawEvent };
|
|
@@ -22654,7 +23164,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
22654
23164
|
delete eventRecord.seq;
|
|
22655
23165
|
delete eventRecord.epoch;
|
|
22656
23166
|
const event = eventRecord;
|
|
22657
|
-
const rawMessageId = type === "message_start" ? asString2(
|
|
23167
|
+
const rawMessageId = type === "message_start" ? asString2(asRecord7(eventRecord.message).id) : asString2(eventRecord.messageId);
|
|
22658
23168
|
if (type === "message_start" && rawMessageId) {
|
|
22659
23169
|
startedAssistantIds.add(rawMessageId);
|
|
22660
23170
|
lastAssistantId = rawMessageId;
|
|
@@ -22832,7 +23342,7 @@ function createNodeSessionEventMapper(ctx) {
|
|
|
22832
23342
|
requestId: interactionId,
|
|
22833
23343
|
toolName,
|
|
22834
23344
|
toolUseId: asString2(payload.toolUseId),
|
|
22835
|
-
input:
|
|
23345
|
+
input: asRecord7(payload.input),
|
|
22836
23346
|
allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
|
|
22837
23347
|
...requestKind ? {
|
|
22838
23348
|
requestKind
|
|
@@ -22937,7 +23447,7 @@ var init_node_session_event_map = __esm({
|
|
|
22937
23447
|
});
|
|
22938
23448
|
|
|
22939
23449
|
// ../../packages/runtime/src/session/message-catalog.ts
|
|
22940
|
-
function
|
|
23450
|
+
function asRecord8(value) {
|
|
22941
23451
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
22942
23452
|
return value;
|
|
22943
23453
|
}
|
|
@@ -23020,7 +23530,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
23020
23530
|
for (const ev of events) {
|
|
23021
23531
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
23022
23532
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
23023
|
-
const payload =
|
|
23533
|
+
const payload = asRecord8(ev.payload);
|
|
23024
23534
|
switch (ev.eventType) {
|
|
23025
23535
|
case SESSION_DURABLE_EVENT.turnStarted: {
|
|
23026
23536
|
turnKey += 1;
|
|
@@ -23046,10 +23556,10 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
23046
23556
|
break;
|
|
23047
23557
|
}
|
|
23048
23558
|
case SESSION_DURABLE_EVENT.agentEvent: {
|
|
23049
|
-
const raw =
|
|
23559
|
+
const raw = asRecord8(payload.event);
|
|
23050
23560
|
const type = asString3(raw.type);
|
|
23051
23561
|
if (type === "message_start") {
|
|
23052
|
-
const id = asString3(
|
|
23562
|
+
const id = asString3(asRecord8(raw.message).id);
|
|
23053
23563
|
if (id) bindAssistant(id);
|
|
23054
23564
|
} else if (type === "message_complete") {
|
|
23055
23565
|
const id = asString3(raw.messageId);
|
|
@@ -23057,7 +23567,7 @@ function collectToolsByAssistantId(events, sessionId) {
|
|
|
23057
23567
|
} else if (type === "content_delta") {
|
|
23058
23568
|
const messageId = asString3(raw.messageId);
|
|
23059
23569
|
if (messageId) bindAssistant(messageId);
|
|
23060
|
-
const delta =
|
|
23570
|
+
const delta = asRecord8(raw.delta);
|
|
23061
23571
|
const dType = asString3(delta.type);
|
|
23062
23572
|
if (dType === "tool_use") {
|
|
23063
23573
|
const toolUseId = asString3(delta.toolUseId);
|
|
@@ -23200,7 +23710,7 @@ function collectContentByAssistantId(events, sessionId) {
|
|
|
23200
23710
|
if (changed) contentById.set(ev.messageId, next);
|
|
23201
23711
|
}
|
|
23202
23712
|
}
|
|
23203
|
-
const payload =
|
|
23713
|
+
const payload = asRecord8(envelope.payload);
|
|
23204
23714
|
if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
23205
23715
|
const blockId = asString3(payload.blockId);
|
|
23206
23716
|
const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
|
|
@@ -23224,7 +23734,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
23224
23734
|
const ev = events[i];
|
|
23225
23735
|
if (ev.aggregateType && ev.aggregateType !== "session") continue;
|
|
23226
23736
|
if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
|
|
23227
|
-
const payload =
|
|
23737
|
+
const payload = asRecord8(ev.payload);
|
|
23228
23738
|
if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
|
|
23229
23739
|
if (asString3(payload.blockId) !== blockId) continue;
|
|
23230
23740
|
const checkpointId = asString3(payload.checkpointId);
|
|
@@ -23239,7 +23749,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
|
|
|
23239
23749
|
}
|
|
23240
23750
|
}
|
|
23241
23751
|
if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
|
|
23242
|
-
const raw =
|
|
23752
|
+
const raw = asRecord8(payload.event);
|
|
23243
23753
|
if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
|
|
23244
23754
|
continue;
|
|
23245
23755
|
}
|
|
@@ -24623,10 +25133,7 @@ var init_session_runtime = __esm({
|
|
|
24623
25133
|
if (typeof stored === "string" && stored.trim()) return stored.trim();
|
|
24624
25134
|
return stored ?? void 0;
|
|
24625
25135
|
};
|
|
24626
|
-
|
|
24627
|
-
if (!turnKind && session.status === "streaming" && (session.harnessId || "claude") === "codex") {
|
|
24628
|
-
turnKind = "steer";
|
|
24629
|
-
}
|
|
25136
|
+
const turnKind = input.turnKind ?? null;
|
|
24630
25137
|
const turnOpts = {
|
|
24631
25138
|
text: input.text,
|
|
24632
25139
|
requestId: input.requestId,
|
|
@@ -24646,11 +25153,8 @@ var init_session_runtime = __esm({
|
|
|
24646
25153
|
this.appendUserMessage(session, turnOpts);
|
|
24647
25154
|
if (session.status === "streaming") {
|
|
24648
25155
|
const harnessId = session.harnessId || "claude";
|
|
24649
|
-
const liveInject = harnessId === "claude" || harnessId === "codex" &&
|
|
25156
|
+
const liveInject = harnessId === "claude" || harnessId === "codex" && turnOpts.turnKind === "steer";
|
|
24650
25157
|
if (liveInject) {
|
|
24651
|
-
if (harnessId === "codex" && turnOpts.turnKind === "run") {
|
|
24652
|
-
turnOpts.turnKind = "steer";
|
|
24653
|
-
}
|
|
24654
25158
|
this.beginTurn(session, turnOpts);
|
|
24655
25159
|
return this.clone(session);
|
|
24656
25160
|
}
|
|
@@ -31046,6 +31550,7 @@ function createNodeClaudeTurnRunner(opts) {
|
|
|
31046
31550
|
permissionMode: permissions.permissionMode,
|
|
31047
31551
|
uid,
|
|
31048
31552
|
sandboxMode: input.sandboxMode && input.sandboxMode.trim() ? input.sandboxMode.trim() : void 0,
|
|
31553
|
+
askUserQuestionPreviewFormat: opts.askUserQuestionPreviewFormat?.(),
|
|
31049
31554
|
additionalDirectories: input.additionalDirectories?.filter(Boolean),
|
|
31050
31555
|
enabledSkills: resolveEnabledSkills(cwd, input.enabledSkills, input.disabledSkills),
|
|
31051
31556
|
env: authEnv,
|
|
@@ -50062,6 +50567,79 @@ var init_slash_filter = __esm({
|
|
|
50062
50567
|
}
|
|
50063
50568
|
});
|
|
50064
50569
|
|
|
50570
|
+
// ../../packages/shared/src/partial-json.ts
|
|
50571
|
+
function extractJsonStringValue(json4, key, opts) {
|
|
50572
|
+
const re = new RegExp(`"${key}":\\s*"`);
|
|
50573
|
+
const match = re.exec(json4);
|
|
50574
|
+
if (!match) return void 0;
|
|
50575
|
+
let i = match.index + match[0].length;
|
|
50576
|
+
const start = i;
|
|
50577
|
+
while (i < json4.length) {
|
|
50578
|
+
const c = json4.charCodeAt(i);
|
|
50579
|
+
if (c === 92 || c === 34) break;
|
|
50580
|
+
i++;
|
|
50581
|
+
}
|
|
50582
|
+
if (i >= json4.length) return opts?.requireClosed ? void 0 : json4.slice(start);
|
|
50583
|
+
if (json4.charCodeAt(i) === 34) return json4.slice(start, i);
|
|
50584
|
+
const parts = [json4.slice(start, i)];
|
|
50585
|
+
while (i < json4.length) {
|
|
50586
|
+
const ch = json4[i];
|
|
50587
|
+
if (ch === '"') {
|
|
50588
|
+
return parts.join("");
|
|
50589
|
+
}
|
|
50590
|
+
if (ch === "\\") {
|
|
50591
|
+
if (i + 1 >= json4.length) {
|
|
50592
|
+
parts.push(ch);
|
|
50593
|
+
i++;
|
|
50594
|
+
break;
|
|
50595
|
+
}
|
|
50596
|
+
const next = json4[i + 1];
|
|
50597
|
+
if (next === '"') {
|
|
50598
|
+
parts.push('"');
|
|
50599
|
+
i += 2;
|
|
50600
|
+
} else if (next === "\\") {
|
|
50601
|
+
parts.push("\\");
|
|
50602
|
+
i += 2;
|
|
50603
|
+
} else if (next === "n") {
|
|
50604
|
+
parts.push("\n");
|
|
50605
|
+
i += 2;
|
|
50606
|
+
} else if (next === "r") {
|
|
50607
|
+
parts.push("\r");
|
|
50608
|
+
i += 2;
|
|
50609
|
+
} else if (next === "t") {
|
|
50610
|
+
parts.push(" ");
|
|
50611
|
+
i += 2;
|
|
50612
|
+
} else if (next === "/") {
|
|
50613
|
+
parts.push("/");
|
|
50614
|
+
i += 2;
|
|
50615
|
+
} else if (next === "u" && i + 5 < json4.length) {
|
|
50616
|
+
const hex3 = json4.slice(i + 2, i + 6);
|
|
50617
|
+
if (/^[0-9a-fA-F]{4}$/.test(hex3)) {
|
|
50618
|
+
parts.push(String.fromCharCode(parseInt(hex3, 16)));
|
|
50619
|
+
i += 6;
|
|
50620
|
+
} else {
|
|
50621
|
+
parts.push(ch);
|
|
50622
|
+
i++;
|
|
50623
|
+
}
|
|
50624
|
+
} else {
|
|
50625
|
+
parts.push(ch);
|
|
50626
|
+
i++;
|
|
50627
|
+
}
|
|
50628
|
+
} else {
|
|
50629
|
+
const runStart = i;
|
|
50630
|
+
i++;
|
|
50631
|
+
while (i < json4.length && json4[i] !== "\\" && json4[i] !== '"') i++;
|
|
50632
|
+
parts.push(json4.slice(runStart, i));
|
|
50633
|
+
}
|
|
50634
|
+
}
|
|
50635
|
+
return opts?.requireClosed ? void 0 : parts.join("");
|
|
50636
|
+
}
|
|
50637
|
+
var init_partial_json = __esm({
|
|
50638
|
+
"../../packages/shared/src/partial-json.ts"() {
|
|
50639
|
+
"use strict";
|
|
50640
|
+
}
|
|
50641
|
+
});
|
|
50642
|
+
|
|
50065
50643
|
// ../../packages/shared/src/tool-ui.ts
|
|
50066
50644
|
function normalizeToolIdKey(id) {
|
|
50067
50645
|
return id.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
@@ -50084,6 +50662,23 @@ function uiToolNameFromId(id) {
|
|
|
50084
50662
|
const key = normalizeToolIdKey(id);
|
|
50085
50663
|
return TOOL_ID_TO_UI_NAME[key] ?? null;
|
|
50086
50664
|
}
|
|
50665
|
+
function isAlwaysHiddenToolName(toolName) {
|
|
50666
|
+
const ui = uiToolNameFromId(toolName) ?? toolName;
|
|
50667
|
+
if (HIDDEN_UI_TOOL_NAMES.has(ui)) return true;
|
|
50668
|
+
const harnessKey = ui.trim().toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
50669
|
+
if (HIDDEN_HARNESS_TOOL_KEYS.has(harnessKey)) return true;
|
|
50670
|
+
const mcp = ui.match(/^mcp__(.+?)__(.+)$/) ?? toolName.match(/^mcp__(.+?)__(.+)$/);
|
|
50671
|
+
return mcp?.[1] === "superone" && HIDDEN_SUPERONE_MCP_TOOLS.has(mcp[2]);
|
|
50672
|
+
}
|
|
50673
|
+
function resolveGrokStreamingToolName(wireName, argumentsJson) {
|
|
50674
|
+
if (!wireName) return null;
|
|
50675
|
+
const ui = uiToolNameFromId(wireName) ?? wireName;
|
|
50676
|
+
if (ui === "UseTool" && argumentsJson) {
|
|
50677
|
+
const id = extractJsonStringValue(argumentsJson, "tool_name", { requireClosed: true });
|
|
50678
|
+
if (id && id.includes("__")) return `mcp__${id}`;
|
|
50679
|
+
}
|
|
50680
|
+
return ui;
|
|
50681
|
+
}
|
|
50087
50682
|
function normalizeTranscriptTool(rawName, rawInput) {
|
|
50088
50683
|
const envelopeId = typeof rawInput.tool_name === "string" ? rawInput.tool_name : "";
|
|
50089
50684
|
const isUseTool = normalizeToolIdKey(rawName) === "use_tool" || rawInput.variant === "UseTool";
|
|
@@ -50393,10 +50988,11 @@ function formatTranscriptToolResult(content, opts) {
|
|
|
50393
50988
|
const max = opts?.maxChars ?? MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
|
|
50394
50989
|
return truncateTranscriptToolResult(formatted, max);
|
|
50395
50990
|
}
|
|
50396
|
-
var TOOL_ID_TO_UI_NAME, GENERIC_SUBAGENT_TYPES, DESCRIPTION_PERSONA_RE, MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
|
|
50991
|
+
var TOOL_ID_TO_UI_NAME, GENERIC_SUBAGENT_TYPES, DESCRIPTION_PERSONA_RE, HIDDEN_UI_TOOL_NAMES, HIDDEN_HARNESS_TOOL_KEYS, HIDDEN_SUPERONE_MCP_TOOLS, MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
|
|
50397
50992
|
var init_tool_ui = __esm({
|
|
50398
50993
|
"../../packages/shared/src/tool-ui.ts"() {
|
|
50399
50994
|
"use strict";
|
|
50995
|
+
init_partial_json();
|
|
50400
50996
|
TOOL_ID_TO_UI_NAME = {
|
|
50401
50997
|
read: "Read",
|
|
50402
50998
|
read_file: "Read",
|
|
@@ -50405,6 +51001,8 @@ var init_tool_ui = __esm({
|
|
|
50405
51001
|
search_replace: "Edit",
|
|
50406
51002
|
str_replace: "Edit",
|
|
50407
51003
|
apply_patch: "Edit",
|
|
51004
|
+
hashline_edit: "Edit",
|
|
51005
|
+
hashlineedit: "Edit",
|
|
50408
51006
|
write: "Write",
|
|
50409
51007
|
write_file: "Write",
|
|
50410
51008
|
writefile: "Write",
|
|
@@ -50431,6 +51029,8 @@ var init_tool_ui = __esm({
|
|
|
50431
51029
|
open_page_with_find: "WebFetch",
|
|
50432
51030
|
web_search: "WebSearch",
|
|
50433
51031
|
websearch: "WebSearch",
|
|
51032
|
+
x_search: "XSearch",
|
|
51033
|
+
xsearch: "XSearch",
|
|
50434
51034
|
todo_write: "TodoWrite",
|
|
50435
51035
|
todowrite: "TodoWrite",
|
|
50436
51036
|
todo: "TodoWrite",
|
|
@@ -50450,16 +51050,21 @@ var init_tool_ui = __esm({
|
|
|
50450
51050
|
memory_search: "MemorySearch",
|
|
50451
51051
|
memorysearch: "MemorySearch",
|
|
50452
51052
|
search_memory: "MemorySearch",
|
|
51053
|
+
memory_get: "MemoryGet",
|
|
51054
|
+
memoryget: "MemoryGet",
|
|
50453
51055
|
ask_user_question: "AskUserQuestion",
|
|
50454
51056
|
askuserquestion: "AskUserQuestion",
|
|
50455
51057
|
get_task_output: "TaskOutput",
|
|
50456
51058
|
get_command_or_subagent_output: "TaskOutput",
|
|
50457
51059
|
get_terminal_command_output: "TaskOutput",
|
|
51060
|
+
get_task_or_subagent_output: "TaskOutput",
|
|
50458
51061
|
wait_tasks: "TaskOutput",
|
|
50459
51062
|
wait_commands_or_subagents: "TaskOutput",
|
|
51063
|
+
wait_tasks_or_subagents: "TaskOutput",
|
|
50460
51064
|
kill_task: "KillTask",
|
|
50461
51065
|
kill_command_or_subagent: "KillTask",
|
|
50462
51066
|
kill_terminal_command: "KillTask",
|
|
51067
|
+
kill_task_or_subagent: "KillTask",
|
|
50463
51068
|
enter_plan_mode: "EnterPlanMode",
|
|
50464
51069
|
exit_plan_mode: "ExitPlanMode",
|
|
50465
51070
|
skill: "Skill",
|
|
@@ -50472,10 +51077,31 @@ var init_tool_ui = __esm({
|
|
|
50472
51077
|
update_goal: "UpdateGoal",
|
|
50473
51078
|
scheduler_create: "SchedulerCreate",
|
|
50474
51079
|
scheduler_delete: "SchedulerDelete",
|
|
50475
|
-
scheduler_list: "SchedulerList"
|
|
51080
|
+
scheduler_list: "SchedulerList",
|
|
51081
|
+
deploy_app: "DeployApp",
|
|
51082
|
+
deployapp: "DeployApp",
|
|
51083
|
+
lsp: "Lsp",
|
|
51084
|
+
report_findings: "ReportFindings",
|
|
51085
|
+
reportfindings: "ReportFindings"
|
|
50476
51086
|
};
|
|
50477
51087
|
GENERIC_SUBAGENT_TYPES = /* @__PURE__ */ new Set(["general-purpose", "general"]);
|
|
50478
51088
|
DESCRIPTION_PERSONA_RE = /^\[([a-zA-Z][a-zA-Z0-9_-]*)\]\s*/;
|
|
51089
|
+
HIDDEN_UI_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
51090
|
+
"TodoWrite",
|
|
51091
|
+
"TaskCreate",
|
|
51092
|
+
"TaskUpdate",
|
|
51093
|
+
"UseTool",
|
|
51094
|
+
"SearchTools",
|
|
51095
|
+
"ToolSearch"
|
|
51096
|
+
]);
|
|
51097
|
+
HIDDEN_HARNESS_TOOL_KEYS = /* @__PURE__ */ new Set(["toolsearch", "searchtool", "searchtools"]);
|
|
51098
|
+
HIDDEN_SUPERONE_MCP_TOOLS = /* @__PURE__ */ new Set([
|
|
51099
|
+
"session_rename",
|
|
51100
|
+
"session_tag_list",
|
|
51101
|
+
"session_collab_list_agents",
|
|
51102
|
+
"session_list_agents",
|
|
51103
|
+
"miniapp_list"
|
|
51104
|
+
]);
|
|
50479
51105
|
MAX_TRANSCRIPT_TOOL_RESULT_CHARS = 48e3;
|
|
50480
51106
|
}
|
|
50481
51107
|
});
|
|
@@ -50495,7 +51121,7 @@ function toolInputJson(raw) {
|
|
|
50495
51121
|
return "{}";
|
|
50496
51122
|
}
|
|
50497
51123
|
}
|
|
50498
|
-
function
|
|
51124
|
+
function asRecord9(raw) {
|
|
50499
51125
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
|
|
50500
51126
|
return {};
|
|
50501
51127
|
}
|
|
@@ -50570,6 +51196,11 @@ function nameFromVariant(raw) {
|
|
|
50570
51196
|
if (variant === "ExitPlanMode") return "ExitPlanMode";
|
|
50571
51197
|
if (variant === "KillTask") return "KillTask";
|
|
50572
51198
|
if (variant === "Skill") return "Skill";
|
|
51199
|
+
if (variant === "HashlineEdit") return "Edit";
|
|
51200
|
+
if (variant === "MemoryGet") return "MemoryGet";
|
|
51201
|
+
if (variant === "DeployApp") return "DeployApp";
|
|
51202
|
+
if (variant === "Lsp") return "Lsp";
|
|
51203
|
+
if (variant === "XSearch") return "XSearch";
|
|
50573
51204
|
}
|
|
50574
51205
|
if (Array.isArray(raw.questions) && raw.questions.length > 0) return "AskUserQuestion";
|
|
50575
51206
|
if (Array.isArray(raw.task_ids) || raw.task_id != null || raw.taskId != null) {
|
|
@@ -50634,7 +51265,7 @@ function grokMetaInput(tool) {
|
|
|
50634
51265
|
const xai = meta3["x.ai/tool"];
|
|
50635
51266
|
if (!xai || typeof xai !== "object") return {};
|
|
50636
51267
|
const input = xai.input;
|
|
50637
|
-
return
|
|
51268
|
+
return asRecord9(input);
|
|
50638
51269
|
}
|
|
50639
51270
|
function queryFromWebSearchTitle(title) {
|
|
50640
51271
|
if (!title) return void 0;
|
|
@@ -50890,17 +51521,21 @@ function normalizeInput(toolName, kind, raw, filePath, diffs, terminalCommand) {
|
|
|
50890
51521
|
return { ...raw };
|
|
50891
51522
|
}
|
|
50892
51523
|
}
|
|
51524
|
+
function isUseToolEnvelope(tool, raw) {
|
|
51525
|
+
return nameFromGrokMeta(tool) === "UseTool" || raw.variant === "UseTool" || uiToolNameFromId(typeof tool.title === "string" ? tool.title : null) === "UseTool";
|
|
51526
|
+
}
|
|
50893
51527
|
function unwrapMcpEnvelope(tool, raw) {
|
|
50894
|
-
|
|
50895
|
-
if (!isEnvelope) return null;
|
|
51528
|
+
if (!isUseToolEnvelope(tool, raw)) return null;
|
|
50896
51529
|
const id = raw.tool_name;
|
|
50897
51530
|
if (typeof id !== "string" || !id.includes("__")) return null;
|
|
50898
|
-
return { toolName: `mcp__${id}`, input:
|
|
51531
|
+
return { toolName: `mcp__${id}`, input: asRecord9(raw.tool_input) };
|
|
50899
51532
|
}
|
|
50900
51533
|
function normalizeAcpTool(tool, opts) {
|
|
50901
|
-
const raw = { ...grokMetaInput(tool), ...
|
|
50902
|
-
const
|
|
51534
|
+
const raw = { ...grokMetaInput(tool), ...asRecord9(tool.rawInput) };
|
|
51535
|
+
const rawInput = asRecord9(tool.rawInput);
|
|
51536
|
+
const mcp = unwrapMcpEnvelope(tool, rawInput);
|
|
50903
51537
|
if (mcp) return mcp;
|
|
51538
|
+
if (isUseToolEnvelope(tool, rawInput) && typeof rawInput.tool_name !== "string") return null;
|
|
50904
51539
|
const diffs = extractDiffs(tool.content);
|
|
50905
51540
|
const terminalId = extractEmbeddedTerminalId(tool.content);
|
|
50906
51541
|
const toolName = resolveToolName(tool, raw, diffs, !!terminalId);
|
|
@@ -51093,6 +51728,39 @@ var init_tool_result_map = __esm({
|
|
|
51093
51728
|
}
|
|
51094
51729
|
});
|
|
51095
51730
|
|
|
51731
|
+
// ../../packages/shared/src/acp-goal.ts
|
|
51732
|
+
function normalizeAcpGoalStatus(raw) {
|
|
51733
|
+
const status = raw.trim().toLowerCase().replace(/-/g, "_");
|
|
51734
|
+
switch (status) {
|
|
51735
|
+
case "active":
|
|
51736
|
+
return "active";
|
|
51737
|
+
case "blocked":
|
|
51738
|
+
return "blocked";
|
|
51739
|
+
case "budget_limited":
|
|
51740
|
+
case "budgetlimited":
|
|
51741
|
+
return "budgetLimited";
|
|
51742
|
+
case "complete":
|
|
51743
|
+
case "completed":
|
|
51744
|
+
return "complete";
|
|
51745
|
+
case "cleared":
|
|
51746
|
+
return "cleared";
|
|
51747
|
+
case "user_paused":
|
|
51748
|
+
case "backoff_paused":
|
|
51749
|
+
case "back_off_paused":
|
|
51750
|
+
case "no_progress_paused":
|
|
51751
|
+
case "infra_paused":
|
|
51752
|
+
case "paused":
|
|
51753
|
+
return "paused";
|
|
51754
|
+
default:
|
|
51755
|
+
return "paused";
|
|
51756
|
+
}
|
|
51757
|
+
}
|
|
51758
|
+
var init_acp_goal = __esm({
|
|
51759
|
+
"../../packages/shared/src/acp-goal.ts"() {
|
|
51760
|
+
"use strict";
|
|
51761
|
+
}
|
|
51762
|
+
});
|
|
51763
|
+
|
|
51096
51764
|
// ../../packages/acp/src/xai-state.ts
|
|
51097
51765
|
import { homedir as homedir4 } from "node:os";
|
|
51098
51766
|
import { join as join20 } from "node:path";
|
|
@@ -51102,6 +51770,7 @@ function skipEventSeqDedup(kind) {
|
|
|
51102
51770
|
function createXaiCorrelationState(opts) {
|
|
51103
51771
|
return {
|
|
51104
51772
|
...opts?.cwd ? { cwd: opts.cwd } : {},
|
|
51773
|
+
...opts?.parentSessionId ? { parentSessionId: opts.parentSessionId } : {},
|
|
51105
51774
|
workflowToolByRunId: /* @__PURE__ */ new Map(),
|
|
51106
51775
|
workflowRevision: /* @__PURE__ */ new Map(),
|
|
51107
51776
|
workflowStarted: /* @__PURE__ */ new Set(),
|
|
@@ -51113,6 +51782,9 @@ function createXaiCorrelationState(opts) {
|
|
|
51113
51782
|
subagentStarted: /* @__PURE__ */ new Set(),
|
|
51114
51783
|
deferredSubagentFinishes: /* @__PURE__ */ new Map(),
|
|
51115
51784
|
deltaToolStarted: /* @__PURE__ */ new Set(),
|
|
51785
|
+
deltaToolWireName: /* @__PURE__ */ new Map(),
|
|
51786
|
+
deltaToolArgs: /* @__PURE__ */ new Map(),
|
|
51787
|
+
deltaToolIdByIndex: /* @__PURE__ */ new Map(),
|
|
51116
51788
|
bgTaskById: /* @__PURE__ */ new Map(),
|
|
51117
51789
|
goalStarted: /* @__PURE__ */ new Set(),
|
|
51118
51790
|
lastEventSeq: null,
|
|
@@ -51157,7 +51829,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
|
|
|
51157
51829
|
});
|
|
51158
51830
|
}
|
|
51159
51831
|
}
|
|
51160
|
-
function
|
|
51832
|
+
function asRecord10(v2) {
|
|
51161
51833
|
if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return null;
|
|
51162
51834
|
return v2;
|
|
51163
51835
|
}
|
|
@@ -51190,18 +51862,18 @@ function arrField(o, ...keys) {
|
|
|
51190
51862
|
return void 0;
|
|
51191
51863
|
}
|
|
51192
51864
|
function parseXaiSessionNotificationEnvelope(raw) {
|
|
51193
|
-
const o =
|
|
51865
|
+
const o = asRecord10(raw);
|
|
51194
51866
|
if (!o) return null;
|
|
51195
|
-
const update =
|
|
51867
|
+
const update = asRecord10(o.update);
|
|
51196
51868
|
if (!update) return null;
|
|
51197
51869
|
const sessionId = strField(o, "sessionId", "session_id");
|
|
51198
|
-
const meta3 =
|
|
51870
|
+
const meta3 = asRecord10(o._meta) ?? asRecord10(o.meta);
|
|
51199
51871
|
const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
|
|
51200
51872
|
const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
|
|
51201
51873
|
return { sessionId, update, meta: meta3, eventSeq, eventId };
|
|
51202
51874
|
}
|
|
51203
51875
|
function parseXaiExtParams(raw) {
|
|
51204
|
-
return
|
|
51876
|
+
return asRecord10(raw) ?? {};
|
|
51205
51877
|
}
|
|
51206
51878
|
function parsePlainTextTaskAck(text) {
|
|
51207
51879
|
const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
|
|
@@ -51306,13 +51978,13 @@ function tryParseJsonObject(text) {
|
|
|
51306
51978
|
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
|
|
51307
51979
|
try {
|
|
51308
51980
|
const v2 = JSON.parse(trimmed);
|
|
51309
|
-
return
|
|
51981
|
+
return asRecord10(v2);
|
|
51310
51982
|
} catch {
|
|
51311
51983
|
const start = trimmed.indexOf("{");
|
|
51312
51984
|
const end = trimmed.lastIndexOf("}");
|
|
51313
51985
|
if (start < 0 || end <= start) return null;
|
|
51314
51986
|
try {
|
|
51315
|
-
return
|
|
51987
|
+
return asRecord10(JSON.parse(trimmed.slice(start, end + 1)));
|
|
51316
51988
|
} catch {
|
|
51317
51989
|
return null;
|
|
51318
51990
|
}
|
|
@@ -51435,6 +52107,9 @@ function mapXaiStandaloneNotification(method, params, state, ctx = {}) {
|
|
|
51435
52107
|
log.debug("[acp-xai] bad session_notification envelope");
|
|
51436
52108
|
return [];
|
|
51437
52109
|
}
|
|
52110
|
+
if (env.sessionId && state.parentSessionId && env.sessionId !== state.parentSessionId) {
|
|
52111
|
+
return [];
|
|
52112
|
+
}
|
|
51438
52113
|
const kind = strField(env.update, "sessionUpdate", "session_update");
|
|
51439
52114
|
if (!skipEventSeqDedup(kind) && env.eventSeq != null) {
|
|
51440
52115
|
if (state.lastEventSeq != null && env.eventSeq <= state.lastEventSeq) {
|
|
@@ -51550,7 +52225,7 @@ function mapWorkflowPhases(raw) {
|
|
|
51550
52225
|
if (!raw?.length) return [];
|
|
51551
52226
|
const out = [];
|
|
51552
52227
|
for (const item of raw) {
|
|
51553
|
-
const p2 =
|
|
52228
|
+
const p2 = asRecord10(item);
|
|
51554
52229
|
if (!p2) continue;
|
|
51555
52230
|
const title = strField(p2, "title");
|
|
51556
52231
|
if (!title) continue;
|
|
@@ -51568,7 +52243,7 @@ function mapWorkflowAgents(raw) {
|
|
|
51568
52243
|
if (!raw?.length) return [];
|
|
51569
52244
|
const out = [];
|
|
51570
52245
|
for (const item of raw) {
|
|
51571
|
-
const a =
|
|
52246
|
+
const a = asRecord10(item);
|
|
51572
52247
|
if (!a) continue;
|
|
51573
52248
|
const agentId = strField(a, "agent_id", "agentId");
|
|
51574
52249
|
const label = strField(a, "label") ?? agentId ?? "agent";
|
|
@@ -51594,7 +52269,7 @@ function buildWorkflowPhaseSummary(u, currentPhase, pauseMessage, lastEvent, las
|
|
|
51594
52269
|
const phaseBits = [];
|
|
51595
52270
|
if (phases?.length) {
|
|
51596
52271
|
for (const p2 of phases) {
|
|
51597
|
-
const ph =
|
|
52272
|
+
const ph = asRecord10(p2);
|
|
51598
52273
|
if (!ph) continue;
|
|
51599
52274
|
const title = strField(ph, "title") ?? "?";
|
|
51600
52275
|
const state = strField(ph, "state") ?? "";
|
|
@@ -51742,7 +52417,7 @@ function mapTaskBackgrounded(u, state) {
|
|
|
51742
52417
|
}];
|
|
51743
52418
|
}
|
|
51744
52419
|
function mapTaskCompleted(u, state) {
|
|
51745
|
-
const snapshot =
|
|
52420
|
+
const snapshot = asRecord10(u.task_snapshot) ?? asRecord10(u.taskSnapshot) ?? u;
|
|
51746
52421
|
const taskId = strField(snapshot, "task_id", "taskId");
|
|
51747
52422
|
if (!taskId) return [];
|
|
51748
52423
|
const known = state.bgTaskById.get(taskId);
|
|
@@ -51824,6 +52499,16 @@ function mapGoalUpdated(u, state) {
|
|
|
51824
52499
|
pauseMessage || lastEvent
|
|
51825
52500
|
].filter(Boolean).join(" \xB7 ");
|
|
51826
52501
|
const events = [];
|
|
52502
|
+
const goal = {
|
|
52503
|
+
goalId,
|
|
52504
|
+
objective,
|
|
52505
|
+
status: normalizeAcpGoalStatus(status),
|
|
52506
|
+
tokensUsed,
|
|
52507
|
+
elapsedMs,
|
|
52508
|
+
...pauseMessage ? { pauseMessage } : {},
|
|
52509
|
+
...phase ? { phase } : {}
|
|
52510
|
+
};
|
|
52511
|
+
events.push({ type: "acp_goal", goal: goal.status === "cleared" ? null : goal });
|
|
51827
52512
|
if (!state.goalStarted.has(goalId)) {
|
|
51828
52513
|
state.goalStarted.add(goalId);
|
|
51829
52514
|
events.push({
|
|
@@ -51920,13 +52605,21 @@ function mapScheduledTaskDeleted(u, _state) {
|
|
|
51920
52605
|
function mapToolCallDeltaChunk(u, state, ctx) {
|
|
51921
52606
|
const toolCallId = strField(u, "tool_call_id", "toolCallId");
|
|
51922
52607
|
const index = numField(u, "tool_index", "toolIndex");
|
|
51923
|
-
|
|
52608
|
+
if (index != null && toolCallId) state.deltaToolIdByIndex.set(index, toolCallId);
|
|
52609
|
+
const id = toolCallId ?? (index != null ? state.deltaToolIdByIndex.get(index) : void 0) ?? (index != null ? `acp_delta_${index}` : null);
|
|
51924
52610
|
const messageId = ctx.messageId ?? state.lastMessageId;
|
|
51925
52611
|
if (!id || !messageId) return [];
|
|
51926
52612
|
const name = strField(u, "name");
|
|
51927
52613
|
const delta = strField(u, "arguments_delta", "argumentsDelta") ?? "";
|
|
52614
|
+
if (name) state.deltaToolWireName.set(id, name);
|
|
52615
|
+
if (delta) state.deltaToolArgs.set(id, (state.deltaToolArgs.get(id) ?? "") + delta);
|
|
52616
|
+
const resolved = resolveGrokStreamingToolName(
|
|
52617
|
+
name ?? state.deltaToolWireName.get(id),
|
|
52618
|
+
state.deltaToolArgs.get(id)
|
|
52619
|
+
);
|
|
51928
52620
|
const events = [];
|
|
51929
|
-
|
|
52621
|
+
const hidden = resolved ? isAlwaysHiddenToolName(resolved) : false;
|
|
52622
|
+
if (resolved && !hidden && !state.deltaToolStarted.has(id)) {
|
|
51930
52623
|
state.deltaToolStarted.add(id);
|
|
51931
52624
|
events.push({
|
|
51932
52625
|
type: "content_delta",
|
|
@@ -51934,13 +52627,22 @@ function mapToolCallDeltaChunk(u, state, ctx) {
|
|
|
51934
52627
|
delta: {
|
|
51935
52628
|
type: "tool_use",
|
|
51936
52629
|
toolUseId: id,
|
|
51937
|
-
toolName:
|
|
52630
|
+
toolName: resolved,
|
|
51938
52631
|
input: "",
|
|
51939
52632
|
status: "streaming"
|
|
51940
52633
|
}
|
|
51941
52634
|
});
|
|
51942
|
-
|
|
51943
|
-
|
|
52635
|
+
const acc = state.deltaToolArgs.get(id);
|
|
52636
|
+
if (acc) {
|
|
52637
|
+
events.push({
|
|
52638
|
+
type: "tool_input_delta",
|
|
52639
|
+
messageId,
|
|
52640
|
+
toolUseId: id,
|
|
52641
|
+
partialJson: acc
|
|
52642
|
+
});
|
|
52643
|
+
}
|
|
52644
|
+
state.deltaToolArgs.delete(id);
|
|
52645
|
+
} else if (delta && state.deltaToolStarted.has(id)) {
|
|
51944
52646
|
events.push({
|
|
51945
52647
|
type: "tool_input_delta",
|
|
51946
52648
|
messageId,
|
|
@@ -51948,6 +52650,9 @@ function mapToolCallDeltaChunk(u, state, ctx) {
|
|
|
51948
52650
|
partialJson: delta
|
|
51949
52651
|
});
|
|
51950
52652
|
}
|
|
52653
|
+
if (resolved && hidden && resolved !== "UseTool") {
|
|
52654
|
+
state.deltaToolArgs.delete(id);
|
|
52655
|
+
}
|
|
51951
52656
|
return events;
|
|
51952
52657
|
}
|
|
51953
52658
|
function noteContextTokensFromMeta(state, meta3) {
|
|
@@ -52008,7 +52713,7 @@ function mapResponseStarted(u, state, ctx) {
|
|
|
52008
52713
|
return event ? [event] : [];
|
|
52009
52714
|
}
|
|
52010
52715
|
function mapResponseCompleted(u, state, ctx) {
|
|
52011
|
-
const usageRaw =
|
|
52716
|
+
const usageRaw = asRecord10(u.usage) ?? u;
|
|
52012
52717
|
const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
|
|
52013
52718
|
const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
|
|
52014
52719
|
const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
|
|
@@ -52023,7 +52728,7 @@ function mapResponseCompleted(u, state, ctx) {
|
|
|
52023
52728
|
}
|
|
52024
52729
|
function mapTurnCompleted(u, state, ctx) {
|
|
52025
52730
|
const events = mapTurnStopReason(u, state);
|
|
52026
|
-
const usageRaw =
|
|
52731
|
+
const usageRaw = asRecord10(u.usage);
|
|
52027
52732
|
if (!usageRaw) {
|
|
52028
52733
|
resetTurnTokens(state);
|
|
52029
52734
|
return events;
|
|
@@ -52190,7 +52895,7 @@ function mapModelAutoSwitched(u) {
|
|
|
52190
52895
|
];
|
|
52191
52896
|
}
|
|
52192
52897
|
function mapRetryState(u) {
|
|
52193
|
-
const nested =
|
|
52898
|
+
const nested = asRecord10(u.retry_state) ?? asRecord10(u.retryState) ?? u;
|
|
52194
52899
|
const type = (strField(nested, "type") ?? "").toLowerCase();
|
|
52195
52900
|
if (type === "retrying") {
|
|
52196
52901
|
const attempt = numField(nested, "attempt") ?? 1;
|
|
@@ -52257,7 +52962,7 @@ function mapAutoRecoveryExhausted(u) {
|
|
|
52257
52962
|
}];
|
|
52258
52963
|
}
|
|
52259
52964
|
function mapFollowUps(u) {
|
|
52260
|
-
const meta3 =
|
|
52965
|
+
const meta3 = asRecord10(u._meta) ?? asRecord10(u.meta);
|
|
52261
52966
|
if (meta3 && meta3["x.ai/replayed"] === true) return [];
|
|
52262
52967
|
const responseId = strField(u, "response_id", "responseId");
|
|
52263
52968
|
if (!responseId || responseId.length > 128) return [];
|
|
@@ -52266,7 +52971,7 @@ function mapFollowUps(u) {
|
|
|
52266
52971
|
let count = 0;
|
|
52267
52972
|
for (const s2 of suggestions) {
|
|
52268
52973
|
if (count >= 6) break;
|
|
52269
|
-
const rec =
|
|
52974
|
+
const rec = asRecord10(s2);
|
|
52270
52975
|
const label = (rec ? strField(rec, "label") : typeof s2 === "string" ? s2 : void 0)?.trim();
|
|
52271
52976
|
if (!label) continue;
|
|
52272
52977
|
const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
|
|
@@ -52288,6 +52993,8 @@ var log, WORKFLOW_TERMINAL;
|
|
|
52288
52993
|
var init_xai_event_map = __esm({
|
|
52289
52994
|
"../../packages/acp/src/xai-event-map.ts"() {
|
|
52290
52995
|
"use strict";
|
|
52996
|
+
init_acp_goal();
|
|
52997
|
+
init_tool_ui();
|
|
52291
52998
|
init_xai_state();
|
|
52292
52999
|
log = { debug: (..._args) => void 0 };
|
|
52293
53000
|
WORKFLOW_TERMINAL = /* @__PURE__ */ new Set([
|
|
@@ -52595,6 +53302,7 @@ function createAcpAgentEventMapper(options) {
|
|
|
52595
53302
|
start(providerSessionId) {
|
|
52596
53303
|
if (started) return;
|
|
52597
53304
|
started = true;
|
|
53305
|
+
if (providerSessionId) xaiCorrelation.parentSessionId = providerSessionId;
|
|
52598
53306
|
emitMessageStart(options.messageId);
|
|
52599
53307
|
options.emit({ type: "status_change", status: "streaming" });
|
|
52600
53308
|
if (providerSessionId) {
|
|
@@ -60112,7 +60820,7 @@ function toolDisplayName(name) {
|
|
|
60112
60820
|
}
|
|
60113
60821
|
function unwrapCursorMcpTool(toolType, args) {
|
|
60114
60822
|
if (toolType.toLowerCase() !== "mcp") return { toolType, args };
|
|
60115
|
-
const rec =
|
|
60823
|
+
const rec = asRecord11(args);
|
|
60116
60824
|
if (!rec) return { toolType, args };
|
|
60117
60825
|
const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
|
|
60118
60826
|
const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
|
|
@@ -60138,12 +60846,12 @@ function idField(obj, ...keys) {
|
|
|
60138
60846
|
return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
|
|
60139
60847
|
}
|
|
60140
60848
|
function extractCursorCallId(update) {
|
|
60141
|
-
const rec =
|
|
60849
|
+
const rec = asRecord11(update);
|
|
60142
60850
|
if (!rec) return null;
|
|
60143
|
-
const nested =
|
|
60851
|
+
const nested = asRecord11(rec.toolCall) ?? asRecord11(rec.message);
|
|
60144
60852
|
return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
|
|
60145
60853
|
}
|
|
60146
|
-
function
|
|
60854
|
+
function asRecord11(value) {
|
|
60147
60855
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
60148
60856
|
return value;
|
|
60149
60857
|
}
|
|
@@ -60157,13 +60865,13 @@ function stringifyPayload(value) {
|
|
|
60157
60865
|
}
|
|
60158
60866
|
}
|
|
60159
60867
|
function extractToolCallParts(update) {
|
|
60160
|
-
const rec =
|
|
60868
|
+
const rec = asRecord11(update) ?? {};
|
|
60161
60869
|
const callId = extractCursorCallId(update);
|
|
60162
|
-
const nested =
|
|
60870
|
+
const nested = asRecord11(rec.toolCall);
|
|
60163
60871
|
if (nested) {
|
|
60164
60872
|
const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
|
|
60165
60873
|
const result = nested.result;
|
|
60166
|
-
const resultRec =
|
|
60874
|
+
const resultRec = asRecord11(result);
|
|
60167
60875
|
const isError = resultRec?.status === "error" || Boolean(rec.isError);
|
|
60168
60876
|
return {
|
|
60169
60877
|
callId,
|
|
@@ -60187,7 +60895,7 @@ function mapTodosPayload(todos) {
|
|
|
60187
60895
|
return {
|
|
60188
60896
|
type: "todos_updated",
|
|
60189
60897
|
todos: todos.map((todo, index) => {
|
|
60190
|
-
const row =
|
|
60898
|
+
const row = asRecord11(todo) ?? {};
|
|
60191
60899
|
const statusRaw = String(row.status ?? "pending");
|
|
60192
60900
|
return {
|
|
60193
60901
|
id: String(row.id ?? index + 1),
|
|
@@ -60216,15 +60924,15 @@ function toolUseEvent(messageId, callId, toolType, args, status) {
|
|
|
60216
60924
|
}
|
|
60217
60925
|
function normalizeCursorToolInput(toolName, args) {
|
|
60218
60926
|
if (toolName.startsWith("mcp__")) return args;
|
|
60219
|
-
const rec =
|
|
60927
|
+
const rec = asRecord11(args);
|
|
60220
60928
|
if (!rec) return args ?? {};
|
|
60221
60929
|
return normalizeTranscriptTool(toolName, rec).input;
|
|
60222
60930
|
}
|
|
60223
60931
|
function mergeCursorToolResultArgs(toolType, args, result) {
|
|
60224
60932
|
if (toolType.toLowerCase() === "mcp") return args;
|
|
60225
|
-
const res =
|
|
60933
|
+
const res = asRecord11(result);
|
|
60226
60934
|
if (!res) return args;
|
|
60227
|
-
const rec =
|
|
60935
|
+
const rec = asRecord11(args);
|
|
60228
60936
|
if (!rec) return args;
|
|
60229
60937
|
const diff = typeof res.diffString === "string" ? res.diffString : void 0;
|
|
60230
60938
|
const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
|
|
@@ -60285,7 +60993,7 @@ function stampParentToolUseId(events, parentToolUseId) {
|
|
|
60285
60993
|
function mapInteractionUpdate(messageId, update, options) {
|
|
60286
60994
|
const events = [];
|
|
60287
60995
|
const type = String(update.type ?? "");
|
|
60288
|
-
const rec =
|
|
60996
|
+
const rec = asRecord11(update) ?? {};
|
|
60289
60997
|
switch (type) {
|
|
60290
60998
|
case "text-delta": {
|
|
60291
60999
|
const text = strField2(update, "text");
|
|
@@ -60325,7 +61033,7 @@ function mapInteractionUpdate(messageId, update, options) {
|
|
|
60325
61033
|
if (!parts.callId) break;
|
|
60326
61034
|
events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
|
|
60327
61035
|
if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
|
|
60328
|
-
const todos =
|
|
61036
|
+
const todos = asRecord11(parts.args)?.todos;
|
|
60329
61037
|
const todoEvent = mapTodosPayload(todos);
|
|
60330
61038
|
if (todoEvent) events.push(todoEvent);
|
|
60331
61039
|
}
|
|
@@ -60362,7 +61070,7 @@ function mapInteractionUpdate(messageId, update, options) {
|
|
|
60362
61070
|
events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
|
|
60363
61071
|
events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
|
|
60364
61072
|
if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
|
|
60365
|
-
const todos =
|
|
61073
|
+
const todos = asRecord11(parts.args)?.todos ?? asRecord11(parts.result)?.todos;
|
|
60366
61074
|
const todoEvent = mapTodosPayload(todos);
|
|
60367
61075
|
if (todoEvent) events.push(todoEvent);
|
|
60368
61076
|
}
|
|
@@ -60467,7 +61175,7 @@ ${text}
|
|
|
60467
61175
|
}
|
|
60468
61176
|
function mapConversationStep(messageId, step, options) {
|
|
60469
61177
|
const events = [];
|
|
60470
|
-
const rec =
|
|
61178
|
+
const rec = asRecord11(step);
|
|
60471
61179
|
if (!rec) return events;
|
|
60472
61180
|
const stepType = strField2(rec, "type");
|
|
60473
61181
|
if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
|
|
@@ -60475,14 +61183,14 @@ function mapConversationStep(messageId, step, options) {
|
|
|
60475
61183
|
}
|
|
60476
61184
|
if (stepType === "toolCall") {
|
|
60477
61185
|
const message = rec.message ?? rec.toolCall ?? rec;
|
|
60478
|
-
const nested =
|
|
61186
|
+
const nested = asRecord11(message);
|
|
60479
61187
|
const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
|
|
60480
61188
|
if (!callId) {
|
|
60481
61189
|
return events;
|
|
60482
61190
|
}
|
|
60483
61191
|
const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
|
|
60484
61192
|
const args = nested?.args ?? nested?.input ?? {};
|
|
60485
|
-
const resultRec =
|
|
61193
|
+
const resultRec = asRecord11(nested?.result);
|
|
60486
61194
|
const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
|
|
60487
61195
|
events.push(toolUseEvent(
|
|
60488
61196
|
messageId,
|
|
@@ -60492,7 +61200,7 @@ function mapConversationStep(messageId, step, options) {
|
|
|
60492
61200
|
"complete"
|
|
60493
61201
|
));
|
|
60494
61202
|
if (toolType === "updateTodos" || toolType === "update_todos") {
|
|
60495
|
-
const todos =
|
|
61203
|
+
const todos = asRecord11(args)?.todos;
|
|
60496
61204
|
const todoEvent = mapTodosPayload(todos);
|
|
60497
61205
|
if (todoEvent) events.push(todoEvent);
|
|
60498
61206
|
}
|
|
@@ -60629,7 +61337,7 @@ var init_cursor_event_map = __esm({
|
|
|
60629
61337
|
observeDelta(update) {
|
|
60630
61338
|
const type = String(update.type ?? "");
|
|
60631
61339
|
if (type === "tool-call-delta") {
|
|
60632
|
-
const taskUpdate =
|
|
61340
|
+
const taskUpdate = asRecord11(update)?.taskUpdate;
|
|
60633
61341
|
if (taskUpdate && typeof taskUpdate === "object") {
|
|
60634
61342
|
this.observeDelta(taskUpdate);
|
|
60635
61343
|
}
|
|
@@ -62010,10 +62718,10 @@ var init_harness_runners = __esm({
|
|
|
62010
62718
|
});
|
|
62011
62719
|
|
|
62012
62720
|
// src/session/codex-live-turn.ts
|
|
62013
|
-
function
|
|
62721
|
+
function asRecord12(value) {
|
|
62014
62722
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
62015
62723
|
}
|
|
62016
|
-
function
|
|
62724
|
+
function readString5(value) {
|
|
62017
62725
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
62018
62726
|
}
|
|
62019
62727
|
function compactRecord3(input) {
|
|
@@ -62041,10 +62749,10 @@ function extractAgentTextFromTurn2(turn) {
|
|
|
62041
62749
|
let text = "";
|
|
62042
62750
|
const items = Array.isArray(turn.items) ? turn.items : [];
|
|
62043
62751
|
for (const item of items) {
|
|
62044
|
-
const rec =
|
|
62752
|
+
const rec = asRecord12(item);
|
|
62045
62753
|
if (!rec) continue;
|
|
62046
|
-
if (
|
|
62047
|
-
const t =
|
|
62754
|
+
if (readString5(rec.type) === "agentMessage" || readString5(rec.itemType) === "agentMessage") {
|
|
62755
|
+
const t = readString5(rec.text);
|
|
62048
62756
|
if (t) text += t;
|
|
62049
62757
|
}
|
|
62050
62758
|
}
|
|
@@ -62073,8 +62781,8 @@ async function openTurnAndStream(opts) {
|
|
|
62073
62781
|
...collaborationMode ? { collaborationMode } : {}
|
|
62074
62782
|
})
|
|
62075
62783
|
);
|
|
62076
|
-
const turn =
|
|
62077
|
-
const turnId =
|
|
62784
|
+
const turn = asRecord12(turnStartResult.turn);
|
|
62785
|
+
const turnId = readString5(turn?.id);
|
|
62078
62786
|
opts.onTurnStarted?.(turnId);
|
|
62079
62787
|
let finalText = "";
|
|
62080
62788
|
const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS2;
|
|
@@ -62101,23 +62809,23 @@ async function openTurnAndStream(opts) {
|
|
|
62101
62809
|
continue;
|
|
62102
62810
|
}
|
|
62103
62811
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
62104
|
-
const completedTurn =
|
|
62105
|
-
const completedId =
|
|
62812
|
+
const completedTurn = asRecord12(note.params.turn);
|
|
62813
|
+
const completedId = readString5(completedTurn?.id);
|
|
62106
62814
|
if (turnId && completedId && completedId !== turnId) continue;
|
|
62107
62815
|
}
|
|
62108
62816
|
if (agentEventMapper) {
|
|
62109
62817
|
const applied = agentEventMapper.apply(note);
|
|
62110
62818
|
if (applied.textDelta) finalText += applied.textDelta;
|
|
62111
62819
|
} else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
|
|
62112
|
-
const delta =
|
|
62820
|
+
const delta = readString5(note.params.delta) ?? readString5(note.params.text) ?? readString5(asRecord12(note.params.item)?.delta);
|
|
62113
62821
|
if (delta) {
|
|
62114
62822
|
finalText += delta;
|
|
62115
62823
|
opts.onDelta?.(delta);
|
|
62116
62824
|
}
|
|
62117
62825
|
}
|
|
62118
62826
|
if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
|
|
62119
|
-
const completedTurn =
|
|
62120
|
-
const status =
|
|
62827
|
+
const completedTurn = asRecord12(note.params.turn);
|
|
62828
|
+
const status = readString5(completedTurn?.status) ?? readString5(note.params.status);
|
|
62121
62829
|
if (status === "failed" || status === "error") {
|
|
62122
62830
|
throw new Error("Codex turn failed");
|
|
62123
62831
|
}
|
|
@@ -62154,8 +62862,7 @@ import { existsSync as existsSync25 } from "node:fs";
|
|
|
62154
62862
|
function mapCodexReasoningEffort(effort) {
|
|
62155
62863
|
if (!effort) return void 0;
|
|
62156
62864
|
const e = effort.trim().toLowerCase();
|
|
62157
|
-
if (e === "
|
|
62158
|
-
if (e === "minimal" || e === "low" || e === "medium" || e === "high" || e === "xhigh") {
|
|
62865
|
+
if (e === "minimal" || e === "low" || e === "medium" || e === "high" || e === "xhigh" || e === "max" || e === "ultra") {
|
|
62159
62866
|
return e;
|
|
62160
62867
|
}
|
|
62161
62868
|
return void 0;
|
|
@@ -62387,6 +63094,7 @@ function createProductionTurnRunner(opts) {
|
|
|
62387
63094
|
allowSimulatedFallback: opts.allowSimulatedFallback,
|
|
62388
63095
|
providers: opts.providers,
|
|
62389
63096
|
experimentalClaudeOpenAiChatEnabled: opts.experimentalClaudeOpenAiChatEnabled,
|
|
63097
|
+
askUserQuestionPreviewFormat: opts.askUserQuestionPreviewFormat,
|
|
62390
63098
|
createHostActionClaudeMcp: opts.createHostActionClaudeMcp,
|
|
62391
63099
|
mcpMergeMode: opts.mcpMergeMode,
|
|
62392
63100
|
homeDir: opts.homeDir
|
|
@@ -62452,8 +63160,13 @@ function createCodexAdminService(opts) {
|
|
|
62452
63160
|
}
|
|
62453
63161
|
function clearCodexAdminAuthForTest() {
|
|
62454
63162
|
projectAuthById.clear();
|
|
63163
|
+
for (const pending of pendingAccountLogins.values()) {
|
|
63164
|
+
void pending.client.close().catch(() => {
|
|
63165
|
+
});
|
|
63166
|
+
}
|
|
63167
|
+
pendingAccountLogins.clear();
|
|
62455
63168
|
}
|
|
62456
|
-
var projectAuthById, CodexAdminService;
|
|
63169
|
+
var projectAuthById, pendingAccountLogins, CodexAdminService;
|
|
62457
63170
|
var init_codex_admin_service = __esm({
|
|
62458
63171
|
"src/session/codex-admin-service.ts"() {
|
|
62459
63172
|
"use strict";
|
|
@@ -62462,6 +63175,7 @@ var init_codex_admin_service = __esm({
|
|
|
62462
63175
|
init_codex_turn_runner();
|
|
62463
63176
|
init_resolve_service();
|
|
62464
63177
|
projectAuthById = /* @__PURE__ */ new Map();
|
|
63178
|
+
pendingAccountLogins = /* @__PURE__ */ new Map();
|
|
62465
63179
|
CodexAdminService = class {
|
|
62466
63180
|
constructor(opts) {
|
|
62467
63181
|
this.opts = opts;
|
|
@@ -62535,6 +63249,91 @@ var init_codex_admin_service = __esm({
|
|
|
62535
63249
|
});
|
|
62536
63250
|
}
|
|
62537
63251
|
}
|
|
63252
|
+
async openAccountClient() {
|
|
63253
|
+
const binary = resolveCodexBinaryPath({
|
|
63254
|
+
binaryPath: this.opts.binaryPath,
|
|
63255
|
+
harnesses: this.opts.harnesses
|
|
63256
|
+
});
|
|
63257
|
+
if (!binary) {
|
|
63258
|
+
throw Object.assign(new Error("Codex binary not available"), {
|
|
63259
|
+
code: "failed_precondition"
|
|
63260
|
+
});
|
|
63261
|
+
}
|
|
63262
|
+
const env = { ...process.env, ...this.opts.env };
|
|
63263
|
+
delete env.CODEX_API_KEY;
|
|
63264
|
+
return openCodexAppServer({
|
|
63265
|
+
binaryPath: binary,
|
|
63266
|
+
env,
|
|
63267
|
+
spawnFn: this.opts.spawnFn
|
|
63268
|
+
});
|
|
63269
|
+
}
|
|
63270
|
+
async getAccountStatus() {
|
|
63271
|
+
const client3 = await this.openAccountClient();
|
|
63272
|
+
try {
|
|
63273
|
+
return await readAccountStatus(client3);
|
|
63274
|
+
} finally {
|
|
63275
|
+
await client3.close().catch(() => {
|
|
63276
|
+
});
|
|
63277
|
+
}
|
|
63278
|
+
}
|
|
63279
|
+
async startAccountLogin(projectId) {
|
|
63280
|
+
const client3 = await this.openAccountClient();
|
|
63281
|
+
try {
|
|
63282
|
+
const result = await startAccountLogin(client3, "chatgptDeviceCode");
|
|
63283
|
+
pendingAccountLogins.set(result.loginId, { projectId, client: client3 });
|
|
63284
|
+
void this.waitForAccountLogin(result.loginId, client3);
|
|
63285
|
+
return result;
|
|
63286
|
+
} catch (error51) {
|
|
63287
|
+
await client3.close().catch(() => {
|
|
63288
|
+
});
|
|
63289
|
+
throw error51;
|
|
63290
|
+
}
|
|
63291
|
+
}
|
|
63292
|
+
async waitForAccountLogin(loginId, client3) {
|
|
63293
|
+
const deadline = Date.now() + 15 * 6e4;
|
|
63294
|
+
try {
|
|
63295
|
+
while (Date.now() < deadline && pendingAccountLogins.get(loginId)?.client === client3) {
|
|
63296
|
+
const notification = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
|
|
63297
|
+
if (!notification) continue;
|
|
63298
|
+
if (notification.method === "account/login/completed" && notification.params.loginId === loginId) return;
|
|
63299
|
+
}
|
|
63300
|
+
} catch {
|
|
63301
|
+
} finally {
|
|
63302
|
+
if (pendingAccountLogins.get(loginId)?.client === client3) {
|
|
63303
|
+
pendingAccountLogins.delete(loginId);
|
|
63304
|
+
}
|
|
63305
|
+
await client3.close().catch(() => {
|
|
63306
|
+
});
|
|
63307
|
+
}
|
|
63308
|
+
}
|
|
63309
|
+
async cancelAccountLogin(loginId) {
|
|
63310
|
+
const pending = pendingAccountLogins.get(loginId);
|
|
63311
|
+
if (!pending) return;
|
|
63312
|
+
pendingAccountLogins.delete(loginId);
|
|
63313
|
+
try {
|
|
63314
|
+
await cancelAccountLogin(pending.client, loginId);
|
|
63315
|
+
} finally {
|
|
63316
|
+
await pending.client.close().catch(() => {
|
|
63317
|
+
});
|
|
63318
|
+
}
|
|
63319
|
+
}
|
|
63320
|
+
async logoutAccount() {
|
|
63321
|
+
for (const [loginId, pending] of [...pendingAccountLogins]) {
|
|
63322
|
+
pendingAccountLogins.delete(loginId);
|
|
63323
|
+
await cancelAccountLogin(pending.client, loginId).catch(() => {
|
|
63324
|
+
});
|
|
63325
|
+
await pending.client.close().catch(() => {
|
|
63326
|
+
});
|
|
63327
|
+
}
|
|
63328
|
+
const client3 = await this.openAccountClient();
|
|
63329
|
+
try {
|
|
63330
|
+
await logoutAccount(client3);
|
|
63331
|
+
return await readAccountStatus(client3);
|
|
63332
|
+
} finally {
|
|
63333
|
+
await client3.close().catch(() => {
|
|
63334
|
+
});
|
|
63335
|
+
}
|
|
63336
|
+
}
|
|
62538
63337
|
async getRateLimits(projectId, apiProviderId) {
|
|
62539
63338
|
const auth = this.getProjectAuth(projectId);
|
|
62540
63339
|
if (resolveMode(auth.mode, auth.apiKey) !== "chatgpt") return null;
|
|
@@ -62544,11 +63343,25 @@ var init_codex_admin_service = __esm({
|
|
|
62544
63343
|
return null;
|
|
62545
63344
|
}
|
|
62546
63345
|
}
|
|
62547
|
-
async getAccountUsage(projectId, apiProviderId) {
|
|
63346
|
+
async getAccountUsage(projectId, apiProviderId, threadId) {
|
|
62548
63347
|
const auth = this.getProjectAuth(projectId);
|
|
62549
63348
|
if (resolveMode(auth.mode, auth.apiKey) !== "chatgpt") return null;
|
|
62550
63349
|
try {
|
|
62551
|
-
return await this.withClient(projectId, apiProviderId, (client3) => readAccountUsage(client3));
|
|
63350
|
+
return await this.withClient(projectId, apiProviderId, (client3) => readAccountUsage(client3, threadId));
|
|
63351
|
+
} catch {
|
|
63352
|
+
return null;
|
|
63353
|
+
}
|
|
63354
|
+
}
|
|
63355
|
+
async getServerDiagnostics(projectId, apiProviderId) {
|
|
63356
|
+
try {
|
|
63357
|
+
return await this.withClient(projectId, apiProviderId, (client3) => readCodexServerDiagnostics(client3));
|
|
63358
|
+
} catch {
|
|
63359
|
+
return null;
|
|
63360
|
+
}
|
|
63361
|
+
}
|
|
63362
|
+
async getConfigRequirements(projectId, apiProviderId) {
|
|
63363
|
+
try {
|
|
63364
|
+
return await this.withClient(projectId, apiProviderId, (client3) => readCodexConfigRequirements(client3));
|
|
62552
63365
|
} catch {
|
|
62553
63366
|
return null;
|
|
62554
63367
|
}
|
|
@@ -62566,11 +63379,11 @@ var init_codex_admin_service = __esm({
|
|
|
62566
63379
|
return null;
|
|
62567
63380
|
}
|
|
62568
63381
|
}
|
|
62569
|
-
async loginMcpOauth(projectId, serverName, apiProviderId) {
|
|
63382
|
+
async loginMcpOauth(projectId, serverName, apiProviderId, options) {
|
|
62570
63383
|
return this.withClient(
|
|
62571
63384
|
projectId,
|
|
62572
63385
|
apiProviderId,
|
|
62573
|
-
(client3) => loginMcpServerOauth(client3, serverName)
|
|
63386
|
+
(client3) => loginMcpServerOauth(client3, serverName, void 0, 18e4, options)
|
|
62574
63387
|
);
|
|
62575
63388
|
}
|
|
62576
63389
|
async detectExternalAgent(projectId, apiProviderId) {
|
|
@@ -69749,8 +70562,8 @@ import { fileURLToPath } from "node:url";
|
|
|
69749
70562
|
function resolveCliReleaseVersion() {
|
|
69750
70563
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
69751
70564
|
if (fromEnv) return fromEnv;
|
|
69752
|
-
if ("0.
|
|
69753
|
-
return "0.
|
|
70565
|
+
if ("0.57.0-alpha".trim()) {
|
|
70566
|
+
return "0.57.0-alpha".trim();
|
|
69754
70567
|
}
|
|
69755
70568
|
const fromDist = readDistManifestVersion();
|
|
69756
70569
|
if (fromDist) return fromDist;
|
|
@@ -71385,13 +72198,15 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as rea
|
|
|
71385
72198
|
import { dirname as dirname4 } from "node:path";
|
|
71386
72199
|
var CODEX_PRESETS = /* @__PURE__ */ new Set(["", "read-only", "default", "full-access"]);
|
|
71387
72200
|
var SANDBOX_MODES = /* @__PURE__ */ new Set(["", "off", "on", "auto"]);
|
|
72201
|
+
var QUESTION_PREVIEW_FORMATS = /* @__PURE__ */ new Set(["", "markdown", "html"]);
|
|
71388
72202
|
var DEFAULT_NODE_AGENT_SETTINGS = {
|
|
71389
72203
|
claude: {
|
|
71390
72204
|
defaultModel: "",
|
|
71391
72205
|
defaultEffort: "",
|
|
71392
72206
|
permissionMode: "",
|
|
71393
72207
|
sandboxMode: "",
|
|
71394
|
-
disabledSkills: []
|
|
72208
|
+
disabledSkills: [],
|
|
72209
|
+
askUserQuestionPreviewFormat: ""
|
|
71395
72210
|
},
|
|
71396
72211
|
codex: {
|
|
71397
72212
|
defaultModel: "",
|
|
@@ -71414,12 +72229,14 @@ function normalizeClaude(raw) {
|
|
|
71414
72229
|
const r = raw && typeof raw === "object" ? raw : {};
|
|
71415
72230
|
const sandboxMode = asString(r.sandboxMode ?? r.defaultSandboxMode, "");
|
|
71416
72231
|
const permissionMode = asString(r.permissionMode ?? r.defaultPermissionMode, "");
|
|
72232
|
+
const previewFormat = asString(r.askUserQuestionPreviewFormat, "");
|
|
71417
72233
|
return {
|
|
71418
72234
|
defaultModel: asString(r.defaultModel, ""),
|
|
71419
72235
|
defaultEffort: asString(r.defaultEffort, ""),
|
|
71420
72236
|
permissionMode,
|
|
71421
72237
|
sandboxMode: SANDBOX_MODES.has(sandboxMode) ? sandboxMode : "",
|
|
71422
|
-
disabledSkills: asStringArray(r.disabledSkills, [])
|
|
72238
|
+
disabledSkills: asStringArray(r.disabledSkills, []),
|
|
72239
|
+
askUserQuestionPreviewFormat: QUESTION_PREVIEW_FORMATS.has(previewFormat) ? previewFormat : ""
|
|
71423
72240
|
};
|
|
71424
72241
|
}
|
|
71425
72242
|
function normalizeCodex(raw) {
|
|
@@ -71466,6 +72283,10 @@ function mergeNodeAgentSettings(current, patch) {
|
|
|
71466
72283
|
const m2 = patch.claude.sandboxMode;
|
|
71467
72284
|
next.claude.sandboxMode = SANDBOX_MODES.has(m2) ? m2 : next.claude.sandboxMode;
|
|
71468
72285
|
}
|
|
72286
|
+
if (typeof patch.claude.askUserQuestionPreviewFormat === "string") {
|
|
72287
|
+
const f2 = patch.claude.askUserQuestionPreviewFormat;
|
|
72288
|
+
if (QUESTION_PREVIEW_FORMATS.has(f2)) next.claude.askUserQuestionPreviewFormat = f2;
|
|
72289
|
+
}
|
|
71469
72290
|
if (Array.isArray(patch.claude.disabledSkills)) {
|
|
71470
72291
|
next.claude.disabledSkills = patch.claude.disabledSkills.filter((s2) => typeof s2 === "string").map((s2) => s2.trim()).filter(Boolean);
|
|
71471
72292
|
}
|
|
@@ -71788,7 +72609,7 @@ function requireResourceWrite(client3, scope) {
|
|
|
71788
72609
|
if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
|
|
71789
72610
|
return null;
|
|
71790
72611
|
}
|
|
71791
|
-
function
|
|
72612
|
+
function asRecord13(payload) {
|
|
71792
72613
|
return payload && typeof payload === "object" ? payload : {};
|
|
71793
72614
|
}
|
|
71794
72615
|
function mapThrown(err) {
|
|
@@ -71817,7 +72638,7 @@ function manageOpts(ctx) {
|
|
|
71817
72638
|
function handleSkillsList(payload, ctx) {
|
|
71818
72639
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
71819
72640
|
if (denied) return denied;
|
|
71820
|
-
const p2 =
|
|
72641
|
+
const p2 = asRecord13(payload);
|
|
71821
72642
|
try {
|
|
71822
72643
|
const projectId = String(p2.projectId ?? "");
|
|
71823
72644
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71837,7 +72658,7 @@ function handleSkillsList(payload, ctx) {
|
|
|
71837
72658
|
function handleSkillsGet(payload, ctx) {
|
|
71838
72659
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
71839
72660
|
if (denied) return denied;
|
|
71840
|
-
const p2 =
|
|
72661
|
+
const p2 = asRecord13(payload);
|
|
71841
72662
|
try {
|
|
71842
72663
|
const projectId = String(p2.projectId ?? "");
|
|
71843
72664
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71862,7 +72683,7 @@ function handleSkillsGet(payload, ctx) {
|
|
|
71862
72683
|
function handleSkillsReadFile(payload, ctx) {
|
|
71863
72684
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
71864
72685
|
if (denied) return denied;
|
|
71865
|
-
const p2 =
|
|
72686
|
+
const p2 = asRecord13(payload);
|
|
71866
72687
|
try {
|
|
71867
72688
|
const projectId = String(p2.projectId ?? "");
|
|
71868
72689
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71896,7 +72717,7 @@ function handleSkillsReadFile(payload, ctx) {
|
|
|
71896
72717
|
function handleSkillsDelete(payload, ctx) {
|
|
71897
72718
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
71898
72719
|
if (denied) return denied;
|
|
71899
|
-
const p2 =
|
|
72720
|
+
const p2 = asRecord13(payload);
|
|
71900
72721
|
try {
|
|
71901
72722
|
const projectId = String(p2.projectId ?? "");
|
|
71902
72723
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71921,7 +72742,7 @@ function handleSkillsDelete(payload, ctx) {
|
|
|
71921
72742
|
function handleSkillsInstall(payload, ctx) {
|
|
71922
72743
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
71923
72744
|
if (baseDenied) return baseDenied;
|
|
71924
|
-
const p2 =
|
|
72745
|
+
const p2 = asRecord13(payload);
|
|
71925
72746
|
try {
|
|
71926
72747
|
const projectId = String(p2.projectId ?? "");
|
|
71927
72748
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71955,7 +72776,7 @@ function handleSkillsInstall(payload, ctx) {
|
|
|
71955
72776
|
function handleMcpList(payload, ctx) {
|
|
71956
72777
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
71957
72778
|
if (denied) return denied;
|
|
71958
|
-
const p2 =
|
|
72779
|
+
const p2 = asRecord13(payload);
|
|
71959
72780
|
try {
|
|
71960
72781
|
const projectId = String(p2.projectId ?? "");
|
|
71961
72782
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71979,7 +72800,7 @@ function handleMcpList(payload, ctx) {
|
|
|
71979
72800
|
function handleAdditionalDirsList(payload, ctx) {
|
|
71980
72801
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
71981
72802
|
if (denied) return denied;
|
|
71982
|
-
const p2 =
|
|
72803
|
+
const p2 = asRecord13(payload);
|
|
71983
72804
|
try {
|
|
71984
72805
|
const projectId = String(p2.projectId ?? "");
|
|
71985
72806
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -71994,7 +72815,7 @@ function handleAdditionalDirsList(payload, ctx) {
|
|
|
71994
72815
|
function handleAdditionalDirsAdd(payload, ctx) {
|
|
71995
72816
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
71996
72817
|
if (denied) return denied;
|
|
71997
|
-
const p2 =
|
|
72818
|
+
const p2 = asRecord13(payload);
|
|
71998
72819
|
try {
|
|
71999
72820
|
const projectId = String(p2.projectId ?? "");
|
|
72000
72821
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72012,7 +72833,7 @@ function handleAdditionalDirsAdd(payload, ctx) {
|
|
|
72012
72833
|
function handleAdditionalDirsRemove(payload, ctx) {
|
|
72013
72834
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72014
72835
|
if (denied) return denied;
|
|
72015
|
-
const p2 =
|
|
72836
|
+
const p2 = asRecord13(payload);
|
|
72016
72837
|
try {
|
|
72017
72838
|
const projectId = String(p2.projectId ?? "");
|
|
72018
72839
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72063,7 +72884,7 @@ function parseMcpWriteConfig(raw) {
|
|
|
72063
72884
|
function handleMcpSave(payload, ctx) {
|
|
72064
72885
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72065
72886
|
if (baseDenied) return baseDenied;
|
|
72066
|
-
const p2 =
|
|
72887
|
+
const p2 = asRecord13(payload);
|
|
72067
72888
|
try {
|
|
72068
72889
|
const projectId = String(p2.projectId ?? "");
|
|
72069
72890
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72093,7 +72914,7 @@ function handleMcpSave(payload, ctx) {
|
|
|
72093
72914
|
function handleMcpToggle(payload, ctx) {
|
|
72094
72915
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72095
72916
|
if (baseDenied) return baseDenied;
|
|
72096
|
-
const p2 =
|
|
72917
|
+
const p2 = asRecord13(payload);
|
|
72097
72918
|
try {
|
|
72098
72919
|
const projectId = String(p2.projectId ?? "");
|
|
72099
72920
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72124,7 +72945,7 @@ function handleMcpToggle(payload, ctx) {
|
|
|
72124
72945
|
function handleMcpDelete(payload, ctx) {
|
|
72125
72946
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72126
72947
|
if (baseDenied) return baseDenied;
|
|
72127
|
-
const p2 =
|
|
72948
|
+
const p2 = asRecord13(payload);
|
|
72128
72949
|
try {
|
|
72129
72950
|
const projectId = String(p2.projectId ?? "");
|
|
72130
72951
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72164,7 +72985,7 @@ function parseMarketplaceScope(raw) {
|
|
|
72164
72985
|
async function handlePluginsList(payload, ctx) {
|
|
72165
72986
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72166
72987
|
if (denied) return denied;
|
|
72167
|
-
const p2 =
|
|
72988
|
+
const p2 = asRecord13(payload);
|
|
72168
72989
|
try {
|
|
72169
72990
|
const projectId = String(p2.projectId ?? "");
|
|
72170
72991
|
projectRoot(ctx.projects, projectId);
|
|
@@ -72211,7 +73032,7 @@ async function handlePluginsList(payload, ctx) {
|
|
|
72211
73032
|
function handlePluginsGet(payload, ctx) {
|
|
72212
73033
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72213
73034
|
if (denied) return denied;
|
|
72214
|
-
const p2 =
|
|
73035
|
+
const p2 = asRecord13(payload);
|
|
72215
73036
|
try {
|
|
72216
73037
|
const projectId = String(p2.projectId ?? "");
|
|
72217
73038
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72235,7 +73056,7 @@ function handlePluginsGet(payload, ctx) {
|
|
|
72235
73056
|
function handlePluginsReadFile(payload, ctx) {
|
|
72236
73057
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72237
73058
|
if (denied) return denied;
|
|
72238
|
-
const p2 =
|
|
73059
|
+
const p2 = asRecord13(payload);
|
|
72239
73060
|
try {
|
|
72240
73061
|
const projectId = String(p2.projectId ?? "");
|
|
72241
73062
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72263,7 +73084,7 @@ function handlePluginsReadFile(payload, ctx) {
|
|
|
72263
73084
|
function handlePluginsDelete(payload, ctx) {
|
|
72264
73085
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72265
73086
|
if (baseDenied) return baseDenied;
|
|
72266
|
-
const p2 =
|
|
73087
|
+
const p2 = asRecord13(payload);
|
|
72267
73088
|
try {
|
|
72268
73089
|
const projectId = String(p2.projectId ?? "");
|
|
72269
73090
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72289,7 +73110,7 @@ function handlePluginsDelete(payload, ctx) {
|
|
|
72289
73110
|
async function handlePluginsInstall(payload, ctx) {
|
|
72290
73111
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72291
73112
|
if (baseDenied) return baseDenied;
|
|
72292
|
-
const p2 =
|
|
73113
|
+
const p2 = asRecord13(payload);
|
|
72293
73114
|
try {
|
|
72294
73115
|
const projectId = String(p2.projectId ?? "");
|
|
72295
73116
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72315,7 +73136,7 @@ async function handlePluginsInstall(payload, ctx) {
|
|
|
72315
73136
|
function handlePluginsUpdate(payload, ctx) {
|
|
72316
73137
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72317
73138
|
if (baseDenied) return baseDenied;
|
|
72318
|
-
const p2 =
|
|
73139
|
+
const p2 = asRecord13(payload);
|
|
72319
73140
|
try {
|
|
72320
73141
|
const projectId = String(p2.projectId ?? "");
|
|
72321
73142
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72341,7 +73162,7 @@ function handlePluginsUpdate(payload, ctx) {
|
|
|
72341
73162
|
function handlePluginsListMarketplace(payload, ctx) {
|
|
72342
73163
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72343
73164
|
if (denied) return denied;
|
|
72344
|
-
const p2 =
|
|
73165
|
+
const p2 = asRecord13(payload);
|
|
72345
73166
|
try {
|
|
72346
73167
|
const projectId = String(p2.projectId ?? "");
|
|
72347
73168
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72363,7 +73184,7 @@ function handlePluginsListMarketplace(payload, ctx) {
|
|
|
72363
73184
|
async function handlePluginsAddMarketplace(payload, ctx) {
|
|
72364
73185
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72365
73186
|
if (baseDenied) return baseDenied;
|
|
72366
|
-
const p2 =
|
|
73187
|
+
const p2 = asRecord13(payload);
|
|
72367
73188
|
try {
|
|
72368
73189
|
const projectId = String(p2.projectId ?? "");
|
|
72369
73190
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72389,7 +73210,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
|
|
|
72389
73210
|
async function handlePluginsRemoveMarketplace(payload, ctx) {
|
|
72390
73211
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72391
73212
|
if (baseDenied) return baseDenied;
|
|
72392
|
-
const p2 =
|
|
73213
|
+
const p2 = asRecord13(payload);
|
|
72393
73214
|
try {
|
|
72394
73215
|
const projectId = String(p2.projectId ?? "");
|
|
72395
73216
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72424,7 +73245,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
72424
73245
|
if (denied) return denied;
|
|
72425
73246
|
const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
|
|
72426
73247
|
if (adminDenied) return adminDenied;
|
|
72427
|
-
const p2 =
|
|
73248
|
+
const p2 = asRecord13(payload);
|
|
72428
73249
|
try {
|
|
72429
73250
|
const projectId = String(p2.projectId ?? "");
|
|
72430
73251
|
if (projectId) {
|
|
@@ -72446,7 +73267,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
|
|
|
72446
73267
|
function handlePluginsReadMarketplace(payload, ctx) {
|
|
72447
73268
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72448
73269
|
if (denied) return denied;
|
|
72449
|
-
const p2 =
|
|
73270
|
+
const p2 = asRecord13(payload);
|
|
72450
73271
|
try {
|
|
72451
73272
|
const projectId = String(p2.projectId ?? "");
|
|
72452
73273
|
if (projectId) {
|
|
@@ -72477,7 +73298,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
|
|
|
72477
73298
|
function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
72478
73299
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72479
73300
|
if (denied) return denied;
|
|
72480
|
-
const p2 =
|
|
73301
|
+
const p2 = asRecord13(payload);
|
|
72481
73302
|
try {
|
|
72482
73303
|
const projectId = String(p2.projectId ?? "");
|
|
72483
73304
|
if (projectId) {
|
|
@@ -72511,7 +73332,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
|
|
|
72511
73332
|
function handleAgentsList(payload, ctx) {
|
|
72512
73333
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72513
73334
|
if (denied) return denied;
|
|
72514
|
-
const p2 =
|
|
73335
|
+
const p2 = asRecord13(payload);
|
|
72515
73336
|
try {
|
|
72516
73337
|
const projectId = String(p2.projectId ?? "");
|
|
72517
73338
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72528,7 +73349,7 @@ function handleAgentsList(payload, ctx) {
|
|
|
72528
73349
|
function handleAgentsReadFile(payload, ctx) {
|
|
72529
73350
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72530
73351
|
if (denied) return denied;
|
|
72531
|
-
const p2 =
|
|
73352
|
+
const p2 = asRecord13(payload);
|
|
72532
73353
|
try {
|
|
72533
73354
|
const projectId = String(p2.projectId ?? "");
|
|
72534
73355
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72560,7 +73381,7 @@ function parseHookSavePayload(raw) {
|
|
|
72560
73381
|
function handleHooksList(payload, ctx) {
|
|
72561
73382
|
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72562
73383
|
if (denied) return denied;
|
|
72563
|
-
const p2 =
|
|
73384
|
+
const p2 = asRecord13(payload);
|
|
72564
73385
|
try {
|
|
72565
73386
|
const projectId = String(p2.projectId ?? "");
|
|
72566
73387
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72573,7 +73394,7 @@ function handleHooksList(payload, ctx) {
|
|
|
72573
73394
|
function handleHooksSave(payload, ctx) {
|
|
72574
73395
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72575
73396
|
if (baseDenied) return baseDenied;
|
|
72576
|
-
const p2 =
|
|
73397
|
+
const p2 = asRecord13(payload);
|
|
72577
73398
|
try {
|
|
72578
73399
|
const projectId = String(p2.projectId ?? "");
|
|
72579
73400
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72601,7 +73422,7 @@ function handleHooksSave(payload, ctx) {
|
|
|
72601
73422
|
function handleHooksDelete(payload, ctx) {
|
|
72602
73423
|
const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72603
73424
|
if (baseDenied) return baseDenied;
|
|
72604
|
-
const p2 =
|
|
73425
|
+
const p2 = asRecord13(payload);
|
|
72605
73426
|
try {
|
|
72606
73427
|
const projectId = String(p2.projectId ?? "");
|
|
72607
73428
|
const cwd = projectRoot(ctx.projects, projectId);
|
|
@@ -72706,7 +73527,7 @@ function requireScopes2(client3, scopes) {
|
|
|
72706
73527
|
}
|
|
72707
73528
|
return null;
|
|
72708
73529
|
}
|
|
72709
|
-
function
|
|
73530
|
+
function asRecord14(payload) {
|
|
72710
73531
|
return payload && typeof payload === "object" ? payload : {};
|
|
72711
73532
|
}
|
|
72712
73533
|
function mapThrown2(err) {
|
|
@@ -72797,7 +73618,7 @@ function parseSchedule(raw) {
|
|
|
72797
73618
|
function handleAutomationList(payload, ctx) {
|
|
72798
73619
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
|
|
72799
73620
|
if (denied) return denied;
|
|
72800
|
-
const p2 =
|
|
73621
|
+
const p2 = asRecord14(payload);
|
|
72801
73622
|
const projectId = String(p2.projectId ?? "").trim();
|
|
72802
73623
|
if (!projectId) {
|
|
72803
73624
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -72816,7 +73637,7 @@ function handleAutomationList(payload, ctx) {
|
|
|
72816
73637
|
function handleAutomationCreate(payload, ctx) {
|
|
72817
73638
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
72818
73639
|
if (denied) return denied;
|
|
72819
|
-
const p2 =
|
|
73640
|
+
const p2 = asRecord14(payload);
|
|
72820
73641
|
const projectId = String(p2.projectId ?? "").trim();
|
|
72821
73642
|
if (!projectId) {
|
|
72822
73643
|
return { error: { code: "invalid_argument", message: "projectId is required" } };
|
|
@@ -72853,7 +73674,7 @@ function handleAutomationCreate(payload, ctx) {
|
|
|
72853
73674
|
function handleAutomationUpdate(payload, ctx) {
|
|
72854
73675
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
72855
73676
|
if (denied) return denied;
|
|
72856
|
-
const p2 =
|
|
73677
|
+
const p2 = asRecord14(payload);
|
|
72857
73678
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
72858
73679
|
if (!automationId) {
|
|
72859
73680
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -72897,7 +73718,7 @@ function handleAutomationUpdate(payload, ctx) {
|
|
|
72897
73718
|
function handleAutomationDelete(payload, ctx) {
|
|
72898
73719
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
72899
73720
|
if (denied) return denied;
|
|
72900
|
-
const p2 =
|
|
73721
|
+
const p2 = asRecord14(payload);
|
|
72901
73722
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
72902
73723
|
if (!automationId) {
|
|
72903
73724
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -72923,7 +73744,7 @@ function handleAutomationDelete(payload, ctx) {
|
|
|
72923
73744
|
async function handleAutomationRunNow(payload, ctx) {
|
|
72924
73745
|
const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
|
|
72925
73746
|
if (denied) return denied;
|
|
72926
|
-
const p2 =
|
|
73747
|
+
const p2 = asRecord14(payload);
|
|
72927
73748
|
const automationId = String(p2.automationId ?? p2.id ?? "").trim();
|
|
72928
73749
|
if (!automationId) {
|
|
72929
73750
|
return { error: { code: "invalid_argument", message: "automationId is required" } };
|
|
@@ -72980,7 +73801,7 @@ function requireScopes3(client3, scopes) {
|
|
|
72980
73801
|
}
|
|
72981
73802
|
return null;
|
|
72982
73803
|
}
|
|
72983
|
-
function
|
|
73804
|
+
function asRecord15(payload) {
|
|
72984
73805
|
return payload && typeof payload === "object" ? payload : {};
|
|
72985
73806
|
}
|
|
72986
73807
|
function optionalString(value) {
|
|
@@ -72989,7 +73810,7 @@ function optionalString(value) {
|
|
|
72989
73810
|
function parseAttachments(value) {
|
|
72990
73811
|
if (!Array.isArray(value)) return [];
|
|
72991
73812
|
return value.flatMap((raw) => {
|
|
72992
|
-
const a =
|
|
73813
|
+
const a = asRecord15(raw);
|
|
72993
73814
|
const name = typeof a.name === "string" ? a.name : "";
|
|
72994
73815
|
const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
|
|
72995
73816
|
const data = typeof a.data === "string" ? a.data : "";
|
|
@@ -73002,7 +73823,7 @@ function mapThrown3(err) {
|
|
|
73002
73823
|
function handleDraftList(payload, ctx) {
|
|
73003
73824
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
|
|
73004
73825
|
if (denied) return denied;
|
|
73005
|
-
const p2 =
|
|
73826
|
+
const p2 = asRecord15(payload);
|
|
73006
73827
|
const projectPath = optionalString(p2.projectPath);
|
|
73007
73828
|
try {
|
|
73008
73829
|
return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
|
|
@@ -73013,7 +73834,7 @@ function handleDraftList(payload, ctx) {
|
|
|
73013
73834
|
function handleDraftUpsert(payload, ctx) {
|
|
73014
73835
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73015
73836
|
if (denied) return denied;
|
|
73016
|
-
const p2 =
|
|
73837
|
+
const p2 = asRecord15(payload);
|
|
73017
73838
|
const id = String(p2.id ?? "").trim();
|
|
73018
73839
|
if (!id) {
|
|
73019
73840
|
return { error: { code: "invalid_argument", message: "id is required" } };
|
|
@@ -73044,7 +73865,7 @@ function handleDraftUpsert(payload, ctx) {
|
|
|
73044
73865
|
function handleDraftDelete(payload, ctx) {
|
|
73045
73866
|
const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
|
|
73046
73867
|
if (denied) return denied;
|
|
73047
|
-
const p2 =
|
|
73868
|
+
const p2 = asRecord15(payload);
|
|
73048
73869
|
const draftId = String(p2.draftId ?? "").trim();
|
|
73049
73870
|
if (!draftId) {
|
|
73050
73871
|
return { error: { code: "invalid_argument", message: "draftId is required" } };
|
|
@@ -73078,7 +73899,7 @@ function requireScopes4(client3, scopes) {
|
|
|
73078
73899
|
}
|
|
73079
73900
|
return null;
|
|
73080
73901
|
}
|
|
73081
|
-
function
|
|
73902
|
+
function asRecord16(payload) {
|
|
73082
73903
|
return payload && typeof payload === "object" ? payload : {};
|
|
73083
73904
|
}
|
|
73084
73905
|
function mapThrown4(err) {
|
|
@@ -73105,10 +73926,22 @@ async function dispatchCodexRpc(method, payload, ctx) {
|
|
|
73105
73926
|
return handleGetAuthStatus(payload, ctx);
|
|
73106
73927
|
case "codex.setAuth":
|
|
73107
73928
|
return handleSetAuth(payload, ctx);
|
|
73929
|
+
case "codex.getAccountStatus":
|
|
73930
|
+
return handleGetAccountStatus(payload, ctx);
|
|
73931
|
+
case "codex.accountLoginStart":
|
|
73932
|
+
return handleAccountLoginStart(payload, ctx);
|
|
73933
|
+
case "codex.accountLoginCancel":
|
|
73934
|
+
return handleAccountLoginCancel(payload, ctx);
|
|
73935
|
+
case "codex.accountLogout":
|
|
73936
|
+
return handleAccountLogout(payload, ctx);
|
|
73108
73937
|
case "codex.getRateLimits":
|
|
73109
73938
|
return handleGetRateLimits(payload, ctx);
|
|
73110
73939
|
case "codex.getAccountUsage":
|
|
73111
73940
|
return handleGetAccountUsage(payload, ctx);
|
|
73941
|
+
case "codex.getServerDiagnostics":
|
|
73942
|
+
return handleGetServerDiagnostics(payload, ctx);
|
|
73943
|
+
case "codex.getConfigRequirements":
|
|
73944
|
+
return handleGetConfigRequirements(payload, ctx);
|
|
73112
73945
|
case "codex.consumeRateLimitReset":
|
|
73113
73946
|
return handleConsumeRateLimitReset(payload, ctx);
|
|
73114
73947
|
case "codex.loginMcpOauth":
|
|
@@ -73137,6 +73970,9 @@ async function dispatchCodexRpc(method, payload, ctx) {
|
|
|
73137
73970
|
}
|
|
73138
73971
|
var CODEX_MUTATING_METHODS = [
|
|
73139
73972
|
"codex.setAuth",
|
|
73973
|
+
"codex.accountLoginStart",
|
|
73974
|
+
"codex.accountLoginCancel",
|
|
73975
|
+
"codex.accountLogout",
|
|
73140
73976
|
"codex.consumeRateLimitReset",
|
|
73141
73977
|
"codex.loginMcpOauth",
|
|
73142
73978
|
"codex.importExternalAgent",
|
|
@@ -73149,7 +73985,7 @@ var CODEX_MUTATING_METHODS = [
|
|
|
73149
73985
|
function handleGetAuthStatus(payload, ctx) {
|
|
73150
73986
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73151
73987
|
if (denied) return denied;
|
|
73152
|
-
const p2 =
|
|
73988
|
+
const p2 = asRecord16(payload);
|
|
73153
73989
|
const projectId = projectIdOf(p2);
|
|
73154
73990
|
if (!projectId) {
|
|
73155
73991
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73162,7 +73998,7 @@ function handleGetAuthStatus(payload, ctx) {
|
|
|
73162
73998
|
function handleSetAuth(payload, ctx) {
|
|
73163
73999
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73164
74000
|
if (denied) return denied;
|
|
73165
|
-
const p2 =
|
|
74001
|
+
const p2 = asRecord16(payload);
|
|
73166
74002
|
const projectId = projectIdOf(p2);
|
|
73167
74003
|
if (!projectId) {
|
|
73168
74004
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73184,10 +74020,62 @@ function handleSetAuth(payload, ctx) {
|
|
|
73184
74020
|
return mapThrown4(err);
|
|
73185
74021
|
}
|
|
73186
74022
|
}
|
|
74023
|
+
async function handleGetAccountStatus(payload, ctx) {
|
|
74024
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74025
|
+
if (denied) return denied;
|
|
74026
|
+
const p2 = asRecord16(payload);
|
|
74027
|
+
const projectId = projectIdOf(p2);
|
|
74028
|
+
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
74029
|
+
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
74030
|
+
try {
|
|
74031
|
+
return { result: await admin(ctx).getAccountStatus() };
|
|
74032
|
+
} catch (err) {
|
|
74033
|
+
return mapThrown4(err);
|
|
74034
|
+
}
|
|
74035
|
+
}
|
|
74036
|
+
async function handleAccountLoginStart(payload, ctx) {
|
|
74037
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74038
|
+
if (denied) return denied;
|
|
74039
|
+
const p2 = asRecord16(payload);
|
|
74040
|
+
const projectId = projectIdOf(p2);
|
|
74041
|
+
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
74042
|
+
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
74043
|
+
try {
|
|
74044
|
+
return { result: await admin(ctx).startAccountLogin(projectId) };
|
|
74045
|
+
} catch (err) {
|
|
74046
|
+
return mapThrown4(err);
|
|
74047
|
+
}
|
|
74048
|
+
}
|
|
74049
|
+
async function handleAccountLoginCancel(payload, ctx) {
|
|
74050
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74051
|
+
if (denied) return denied;
|
|
74052
|
+
const p2 = asRecord16(payload);
|
|
74053
|
+
const loginId = typeof p2.loginId === "string" ? p2.loginId.trim() : "";
|
|
74054
|
+
if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
|
|
74055
|
+
try {
|
|
74056
|
+
await admin(ctx).cancelAccountLogin(loginId);
|
|
74057
|
+
return { result: { ok: true } };
|
|
74058
|
+
} catch (err) {
|
|
74059
|
+
return mapThrown4(err);
|
|
74060
|
+
}
|
|
74061
|
+
}
|
|
74062
|
+
async function handleAccountLogout(payload, ctx) {
|
|
74063
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74064
|
+
if (denied) return denied;
|
|
74065
|
+
const p2 = asRecord16(payload);
|
|
74066
|
+
const projectId = projectIdOf(p2);
|
|
74067
|
+
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
74068
|
+
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
74069
|
+
try {
|
|
74070
|
+
return { result: await admin(ctx).logoutAccount() };
|
|
74071
|
+
} catch (err) {
|
|
74072
|
+
return mapThrown4(err);
|
|
74073
|
+
}
|
|
74074
|
+
}
|
|
73187
74075
|
async function handleGetRateLimits(payload, ctx) {
|
|
73188
74076
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73189
74077
|
if (denied) return denied;
|
|
73190
|
-
const p2 =
|
|
74078
|
+
const p2 = asRecord16(payload);
|
|
73191
74079
|
const projectId = projectIdOf(p2);
|
|
73192
74080
|
if (!projectId) {
|
|
73193
74081
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73214,7 +74102,7 @@ async function handleGetRateLimits(payload, ctx) {
|
|
|
73214
74102
|
async function handleGetAccountUsage(payload, ctx) {
|
|
73215
74103
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73216
74104
|
if (denied) return denied;
|
|
73217
|
-
const p2 =
|
|
74105
|
+
const p2 = asRecord16(payload);
|
|
73218
74106
|
const projectId = projectIdOf(p2);
|
|
73219
74107
|
if (!projectId) {
|
|
73220
74108
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73233,7 +74121,44 @@ async function handleGetAccountUsage(payload, ctx) {
|
|
|
73233
74121
|
};
|
|
73234
74122
|
}
|
|
73235
74123
|
const apiProviderId = typeof p2.apiProviderId === "string" ? p2.apiProviderId : null;
|
|
73236
|
-
|
|
74124
|
+
const threadId = typeof p2.threadId === "string" ? p2.threadId : null;
|
|
74125
|
+
return { result: await svc.getAccountUsage(projectId, apiProviderId, threadId) };
|
|
74126
|
+
} catch (err) {
|
|
74127
|
+
return mapThrown4(err);
|
|
74128
|
+
}
|
|
74129
|
+
}
|
|
74130
|
+
async function handleGetServerDiagnostics(payload, ctx) {
|
|
74131
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74132
|
+
if (denied) return denied;
|
|
74133
|
+
const p2 = asRecord16(payload);
|
|
74134
|
+
const projectId = projectIdOf(p2);
|
|
74135
|
+
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
74136
|
+
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
74137
|
+
try {
|
|
74138
|
+
const svc = admin(ctx);
|
|
74139
|
+
if (!svc.isBinaryReady()) {
|
|
74140
|
+
return { error: { code: "failed_precondition", message: "Codex binary not ready" } };
|
|
74141
|
+
}
|
|
74142
|
+
const apiProviderId = typeof p2.apiProviderId === "string" ? p2.apiProviderId : null;
|
|
74143
|
+
return { result: await svc.getServerDiagnostics(projectId, apiProviderId) };
|
|
74144
|
+
} catch (err) {
|
|
74145
|
+
return mapThrown4(err);
|
|
74146
|
+
}
|
|
74147
|
+
}
|
|
74148
|
+
async function handleGetConfigRequirements(payload, ctx) {
|
|
74149
|
+
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74150
|
+
if (denied) return denied;
|
|
74151
|
+
const p2 = asRecord16(payload);
|
|
74152
|
+
const projectId = projectIdOf(p2);
|
|
74153
|
+
if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
74154
|
+
if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
|
|
74155
|
+
try {
|
|
74156
|
+
const svc = admin(ctx);
|
|
74157
|
+
if (!svc.isBinaryReady()) {
|
|
74158
|
+
return { error: { code: "failed_precondition", message: "Codex binary not ready" } };
|
|
74159
|
+
}
|
|
74160
|
+
const apiProviderId = typeof p2.apiProviderId === "string" ? p2.apiProviderId : null;
|
|
74161
|
+
return { result: await svc.getConfigRequirements(projectId, apiProviderId) };
|
|
73237
74162
|
} catch (err) {
|
|
73238
74163
|
return mapThrown4(err);
|
|
73239
74164
|
}
|
|
@@ -73241,7 +74166,7 @@ async function handleGetAccountUsage(payload, ctx) {
|
|
|
73241
74166
|
async function handleConsumeRateLimitReset(payload, ctx) {
|
|
73242
74167
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73243
74168
|
if (denied) return denied;
|
|
73244
|
-
const p2 =
|
|
74169
|
+
const p2 = asRecord16(payload);
|
|
73245
74170
|
const projectId = projectIdOf(p2);
|
|
73246
74171
|
if (!projectId) {
|
|
73247
74172
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73271,7 +74196,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
|
|
|
73271
74196
|
async function handleLoginMcpOauth(payload, ctx) {
|
|
73272
74197
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73273
74198
|
if (denied) return denied;
|
|
73274
|
-
const p2 =
|
|
74199
|
+
const p2 = asRecord16(payload);
|
|
73275
74200
|
const projectId = projectIdOf(p2);
|
|
73276
74201
|
const serverName = String(p2.serverName ?? p2.name ?? "").trim();
|
|
73277
74202
|
if (!projectId || !serverName) {
|
|
@@ -73281,8 +74206,15 @@ async function handleLoginMcpOauth(payload, ctx) {
|
|
|
73281
74206
|
}
|
|
73282
74207
|
try {
|
|
73283
74208
|
const apiProviderId = typeof p2.apiProviderId === "string" ? p2.apiProviderId : null;
|
|
74209
|
+
const rawOptions = asRecord16(p2.options);
|
|
74210
|
+
const options = {
|
|
74211
|
+
...rawOptions.clientRegistration === "auto" || rawOptions.clientRegistration === "cimd" || rawOptions.clientRegistration === "dcr" ? { clientRegistration: rawOptions.clientRegistration } : {},
|
|
74212
|
+
...typeof rawOptions.threadId === "string" || rawOptions.threadId === null ? { threadId: rawOptions.threadId } : {},
|
|
74213
|
+
...Array.isArray(rawOptions.scopes) && rawOptions.scopes.every((scope) => typeof scope === "string") ? { scopes: rawOptions.scopes } : {},
|
|
74214
|
+
...typeof rawOptions.timeoutSecs === "number" && Number.isFinite(rawOptions.timeoutSecs) && rawOptions.timeoutSecs > 0 ? { timeoutSecs: rawOptions.timeoutSecs } : {}
|
|
74215
|
+
};
|
|
73284
74216
|
return {
|
|
73285
|
-
result: await admin(ctx).loginMcpOauth(projectId, serverName, apiProviderId)
|
|
74217
|
+
result: await admin(ctx).loginMcpOauth(projectId, serverName, apiProviderId, options)
|
|
73286
74218
|
};
|
|
73287
74219
|
} catch (err) {
|
|
73288
74220
|
return mapThrown4(err);
|
|
@@ -73291,7 +74223,7 @@ async function handleLoginMcpOauth(payload, ctx) {
|
|
|
73291
74223
|
async function handleDetectExternalAgent(payload, ctx) {
|
|
73292
74224
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73293
74225
|
if (denied) return denied;
|
|
73294
|
-
const p2 =
|
|
74226
|
+
const p2 = asRecord16(payload);
|
|
73295
74227
|
const projectId = projectIdOf(p2);
|
|
73296
74228
|
if (!projectId) {
|
|
73297
74229
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73310,7 +74242,7 @@ async function handleDetectExternalAgent(payload, ctx) {
|
|
|
73310
74242
|
async function handleImportExternalAgent(payload, ctx) {
|
|
73311
74243
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73312
74244
|
if (denied) return denied;
|
|
73313
|
-
const p2 =
|
|
74245
|
+
const p2 = asRecord16(payload);
|
|
73314
74246
|
const projectId = projectIdOf(p2);
|
|
73315
74247
|
if (!projectId) {
|
|
73316
74248
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73328,7 +74260,7 @@ async function handleImportExternalAgent(payload, ctx) {
|
|
|
73328
74260
|
async function handlePluginsList2(payload, ctx) {
|
|
73329
74261
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
73330
74262
|
if (denied) return denied;
|
|
73331
|
-
const p2 =
|
|
74263
|
+
const p2 = asRecord16(payload);
|
|
73332
74264
|
const projectId = projectIdOf(p2);
|
|
73333
74265
|
if (!projectId) {
|
|
73334
74266
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73351,7 +74283,7 @@ async function handlePluginsList2(payload, ctx) {
|
|
|
73351
74283
|
async function handlePluginsInstall2(payload, ctx) {
|
|
73352
74284
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73353
74285
|
if (denied) return denied;
|
|
73354
|
-
const p2 =
|
|
74286
|
+
const p2 = asRecord16(payload);
|
|
73355
74287
|
const projectId = projectIdOf(p2);
|
|
73356
74288
|
const key = String(p2.key ?? p2.pluginId ?? "").trim();
|
|
73357
74289
|
if (!projectId || !key) {
|
|
@@ -73367,7 +74299,7 @@ async function handlePluginsInstall2(payload, ctx) {
|
|
|
73367
74299
|
async function handlePluginsUninstall(payload, ctx) {
|
|
73368
74300
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73369
74301
|
if (denied) return denied;
|
|
73370
|
-
const p2 =
|
|
74302
|
+
const p2 = asRecord16(payload);
|
|
73371
74303
|
const projectId = projectIdOf(p2);
|
|
73372
74304
|
const key = String(p2.key ?? p2.pluginId ?? "").trim();
|
|
73373
74305
|
if (!projectId || !key) {
|
|
@@ -73383,7 +74315,7 @@ async function handlePluginsUninstall(payload, ctx) {
|
|
|
73383
74315
|
async function handleMarketplaceAdd(payload, ctx) {
|
|
73384
74316
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73385
74317
|
if (denied) return denied;
|
|
73386
|
-
const p2 =
|
|
74318
|
+
const p2 = asRecord16(payload);
|
|
73387
74319
|
const projectId = projectIdOf(p2);
|
|
73388
74320
|
const source = String(p2.source ?? "").trim();
|
|
73389
74321
|
if (!projectId || !source) {
|
|
@@ -73412,7 +74344,7 @@ async function handleMarketplaceAdd(payload, ctx) {
|
|
|
73412
74344
|
async function handleMarketplaceRemove(payload, ctx) {
|
|
73413
74345
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73414
74346
|
if (denied) return denied;
|
|
73415
|
-
const p2 =
|
|
74347
|
+
const p2 = asRecord16(payload);
|
|
73416
74348
|
const projectId = projectIdOf(p2);
|
|
73417
74349
|
const marketplaceName = String(p2.marketplaceName ?? p2.name ?? "").trim();
|
|
73418
74350
|
if (!projectId || !marketplaceName) {
|
|
@@ -73435,7 +74367,7 @@ async function handleMarketplaceRemove(payload, ctx) {
|
|
|
73435
74367
|
async function handleMarketplaceUpgrade(payload, ctx) {
|
|
73436
74368
|
const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73437
74369
|
if (denied) return denied;
|
|
73438
|
-
const p2 =
|
|
74370
|
+
const p2 = asRecord16(payload);
|
|
73439
74371
|
const projectId = projectIdOf(p2);
|
|
73440
74372
|
if (!projectId) {
|
|
73441
74373
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -73468,7 +74400,7 @@ function requireScopes5(client3, scopes) {
|
|
|
73468
74400
|
}
|
|
73469
74401
|
return null;
|
|
73470
74402
|
}
|
|
73471
|
-
function
|
|
74403
|
+
function asRecord17(payload) {
|
|
73472
74404
|
return payload && typeof payload === "object" ? payload : {};
|
|
73473
74405
|
}
|
|
73474
74406
|
function mapThrown5(err) {
|
|
@@ -73497,7 +74429,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
|
|
|
73497
74429
|
function handleList(payload, ctx) {
|
|
73498
74430
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73499
74431
|
if (denied) return denied;
|
|
73500
|
-
const p2 =
|
|
74432
|
+
const p2 = asRecord17(payload);
|
|
73501
74433
|
try {
|
|
73502
74434
|
const harnessId = typeof p2.harnessId === "string" && p2.harnessId.trim() ? p2.harnessId.trim() : null;
|
|
73503
74435
|
const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
|
|
@@ -73509,7 +74441,7 @@ function handleList(payload, ctx) {
|
|
|
73509
74441
|
function handleGet(payload, ctx) {
|
|
73510
74442
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73511
74443
|
if (denied) return denied;
|
|
73512
|
-
const p2 =
|
|
74444
|
+
const p2 = asRecord17(payload);
|
|
73513
74445
|
const id = String(p2.id ?? "");
|
|
73514
74446
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
73515
74447
|
try {
|
|
@@ -73521,7 +74453,7 @@ function handleGet(payload, ctx) {
|
|
|
73521
74453
|
function handleGetBase(payload, ctx) {
|
|
73522
74454
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73523
74455
|
if (denied) return denied;
|
|
73524
|
-
const p2 =
|
|
74456
|
+
const p2 = asRecord17(payload);
|
|
73525
74457
|
const harnessId = String(p2.harnessId ?? "");
|
|
73526
74458
|
if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
|
|
73527
74459
|
try {
|
|
@@ -73533,7 +74465,7 @@ function handleGetBase(payload, ctx) {
|
|
|
73533
74465
|
function handleCreate(payload, ctx) {
|
|
73534
74466
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73535
74467
|
if (denied) return denied;
|
|
73536
|
-
const p2 =
|
|
74468
|
+
const p2 = asRecord17(payload);
|
|
73537
74469
|
try {
|
|
73538
74470
|
const provider = ctx.sessionProviders.create({
|
|
73539
74471
|
harnessId: String(p2.harnessId ?? ""),
|
|
@@ -73549,7 +74481,7 @@ function handleCreate(payload, ctx) {
|
|
|
73549
74481
|
function handleUpdate(payload, ctx) {
|
|
73550
74482
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73551
74483
|
if (denied) return denied;
|
|
73552
|
-
const p2 =
|
|
74484
|
+
const p2 = asRecord17(payload);
|
|
73553
74485
|
const id = String(p2.id ?? "");
|
|
73554
74486
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
73555
74487
|
try {
|
|
@@ -73565,7 +74497,7 @@ function handleUpdate(payload, ctx) {
|
|
|
73565
74497
|
function handleDelete(payload, ctx) {
|
|
73566
74498
|
const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
|
|
73567
74499
|
if (denied) return denied;
|
|
73568
|
-
const p2 =
|
|
74500
|
+
const p2 = asRecord17(payload);
|
|
73569
74501
|
const id = String(p2.id ?? "");
|
|
73570
74502
|
if (!id) return { error: { code: "invalid_argument", message: "id required" } };
|
|
73571
74503
|
try {
|
|
@@ -73606,7 +74538,7 @@ function requireScopes6(client3, scopes) {
|
|
|
73606
74538
|
}
|
|
73607
74539
|
return null;
|
|
73608
74540
|
}
|
|
73609
|
-
function
|
|
74541
|
+
function asRecord18(payload) {
|
|
73610
74542
|
return payload && typeof payload === "object" ? payload : {};
|
|
73611
74543
|
}
|
|
73612
74544
|
function defaultProbeModels(ctx) {
|
|
@@ -73634,7 +74566,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
|
|
|
73634
74566
|
async function handleHarnessResources(payload, ctx) {
|
|
73635
74567
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
73636
74568
|
if (denied) return denied;
|
|
73637
|
-
const p2 =
|
|
74569
|
+
const p2 = asRecord18(payload);
|
|
73638
74570
|
const projectId = String(p2.projectId ?? "");
|
|
73639
74571
|
if (!projectId) {
|
|
73640
74572
|
return { error: { code: "invalid_argument", message: "projectId required" } };
|
|
@@ -74076,7 +75008,7 @@ function handleProviderListCredentials(ctx) {
|
|
|
74076
75008
|
function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
74077
75009
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74078
75010
|
if (denied) return denied;
|
|
74079
|
-
const p2 =
|
|
75011
|
+
const p2 = asRecord19(payload);
|
|
74080
75012
|
const cred = ctx.providers.getCredentialDecrypted(String(p2.id ?? ""));
|
|
74081
75013
|
if (!cred) return { error: { code: "not_found", message: "credential not found" } };
|
|
74082
75014
|
return { result: cred };
|
|
@@ -74084,7 +75016,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
|
|
|
74084
75016
|
function handleProviderCreateCredential(payload, ctx) {
|
|
74085
75017
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74086
75018
|
if (denied) return denied;
|
|
74087
|
-
const p2 =
|
|
75019
|
+
const p2 = asRecord19(payload);
|
|
74088
75020
|
try {
|
|
74089
75021
|
return {
|
|
74090
75022
|
result: ctx.providers.createCredential({
|
|
@@ -74106,7 +75038,7 @@ function handleProviderCreateCredential(payload, ctx) {
|
|
|
74106
75038
|
function handleProviderUpdateCredential(payload, ctx) {
|
|
74107
75039
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74108
75040
|
if (denied) return denied;
|
|
74109
|
-
const p2 =
|
|
75041
|
+
const p2 = asRecord19(payload);
|
|
74110
75042
|
const id = String(p2.id ?? "");
|
|
74111
75043
|
const updated = ctx.providers.updateCredential(id, {
|
|
74112
75044
|
name: typeof p2.name === "string" ? p2.name : void 0,
|
|
@@ -74123,7 +75055,7 @@ function handleProviderUpdateCredential(payload, ctx) {
|
|
|
74123
75055
|
function handleProviderDeleteCredential(payload, ctx) {
|
|
74124
75056
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74125
75057
|
if (denied) return denied;
|
|
74126
|
-
const p2 =
|
|
75058
|
+
const p2 = asRecord19(payload);
|
|
74127
75059
|
const ok = ctx.providers.deleteCredential(String(p2.id ?? ""));
|
|
74128
75060
|
if (!ok) return { error: { code: "not_found", message: "credential not found" } };
|
|
74129
75061
|
return { result: { ok: true } };
|
|
@@ -74136,7 +75068,7 @@ function handleProviderListBindings(ctx) {
|
|
|
74136
75068
|
function handleProviderSetBinding(payload, ctx) {
|
|
74137
75069
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74138
75070
|
if (denied) return denied;
|
|
74139
|
-
const p2 =
|
|
75071
|
+
const p2 = asRecord19(payload);
|
|
74140
75072
|
const binding = p2;
|
|
74141
75073
|
if (!binding.consumer || !binding.credentialId) {
|
|
74142
75074
|
return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
|
|
@@ -74147,7 +75079,7 @@ function handleProviderSetBinding(payload, ctx) {
|
|
|
74147
75079
|
function handleProviderClearBinding(payload, ctx) {
|
|
74148
75080
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74149
75081
|
if (denied) return denied;
|
|
74150
|
-
const p2 =
|
|
75082
|
+
const p2 = asRecord19(payload);
|
|
74151
75083
|
ctx.providers.clearBinding(String(p2.consumer ?? ""));
|
|
74152
75084
|
return { result: { ok: true } };
|
|
74153
75085
|
}
|
|
@@ -74159,14 +75091,14 @@ function handleProviderListCustomPlatforms(ctx) {
|
|
|
74159
75091
|
function handleProviderUpsertCustomPlatform(payload, ctx) {
|
|
74160
75092
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74161
75093
|
if (denied) return denied;
|
|
74162
|
-
const def =
|
|
75094
|
+
const def = asRecord19(payload);
|
|
74163
75095
|
if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
|
|
74164
75096
|
return { result: ctx.providers.upsertCustomPlatform(def) };
|
|
74165
75097
|
}
|
|
74166
75098
|
function handleProviderDeleteCustomPlatform(payload, ctx) {
|
|
74167
75099
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74168
75100
|
if (denied) return denied;
|
|
74169
|
-
const p2 =
|
|
75101
|
+
const p2 = asRecord19(payload);
|
|
74170
75102
|
const ok = ctx.providers.deleteCustomPlatform(String(p2.id ?? ""));
|
|
74171
75103
|
if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
|
|
74172
75104
|
return { result: { ok: true } };
|
|
@@ -74179,7 +75111,7 @@ function handleProviderExportBundle(ctx) {
|
|
|
74179
75111
|
function handleProviderListModels(payload, ctx) {
|
|
74180
75112
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
|
|
74181
75113
|
if (denied) return denied;
|
|
74182
|
-
const p2 =
|
|
75114
|
+
const p2 = asRecord19(payload);
|
|
74183
75115
|
const harness = String(p2.harness ?? p2.harnessId ?? "claude");
|
|
74184
75116
|
const apiProviderId = typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
|
|
74185
75117
|
return {
|
|
@@ -74191,7 +75123,7 @@ function handleProviderListModels(payload, ctx) {
|
|
|
74191
75123
|
function handleProviderImportBundle(payload, ctx) {
|
|
74192
75124
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74193
75125
|
if (denied) return denied;
|
|
74194
|
-
const p2 =
|
|
75126
|
+
const p2 = asRecord19(payload);
|
|
74195
75127
|
const bundle = p2.bundle && typeof p2.bundle === "object" ? p2.bundle : p2;
|
|
74196
75128
|
const replaceAll = p2.replaceAll === true;
|
|
74197
75129
|
try {
|
|
@@ -74256,7 +75188,7 @@ function handleHarnessList(ctx) {
|
|
|
74256
75188
|
function handleHarnessShow(payload, ctx) {
|
|
74257
75189
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74258
75190
|
if (denied) return denied;
|
|
74259
|
-
const p2 =
|
|
75191
|
+
const p2 = asRecord19(payload);
|
|
74260
75192
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
74261
75193
|
if (!isNodeHarnessId(id)) {
|
|
74262
75194
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74266,7 +75198,7 @@ function handleHarnessShow(payload, ctx) {
|
|
|
74266
75198
|
function handleHarnessProbe(payload, ctx) {
|
|
74267
75199
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74268
75200
|
if (denied) return denied;
|
|
74269
|
-
const p2 =
|
|
75201
|
+
const p2 = asRecord19(payload);
|
|
74270
75202
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
74271
75203
|
if (!isNodeHarnessId(id)) {
|
|
74272
75204
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74281,7 +75213,7 @@ function handleHarnessProbe(payload, ctx) {
|
|
|
74281
75213
|
async function handleHarnessEnable(payload, ctx) {
|
|
74282
75214
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74283
75215
|
if (denied) return denied;
|
|
74284
|
-
const p2 =
|
|
75216
|
+
const p2 = asRecord19(payload);
|
|
74285
75217
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
74286
75218
|
if (!isNodeHarnessId(id)) {
|
|
74287
75219
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74307,7 +75239,7 @@ async function handleHarnessEnable(payload, ctx) {
|
|
|
74307
75239
|
function handleHarnessDisable(payload, ctx) {
|
|
74308
75240
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74309
75241
|
if (denied) return denied;
|
|
74310
|
-
const p2 =
|
|
75242
|
+
const p2 = asRecord19(payload);
|
|
74311
75243
|
const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
|
|
74312
75244
|
if (!isNodeHarnessId(id)) {
|
|
74313
75245
|
return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
|
|
@@ -74372,7 +75304,7 @@ function handleSettingsGet(ctx) {
|
|
|
74372
75304
|
function handleSettingsPatch(payload, ctx) {
|
|
74373
75305
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
|
|
74374
75306
|
if (denied) return denied;
|
|
74375
|
-
const p2 =
|
|
75307
|
+
const p2 = asRecord19(payload);
|
|
74376
75308
|
const rawPatch = p2.patch && typeof p2.patch === "object" ? p2.patch : p2;
|
|
74377
75309
|
try {
|
|
74378
75310
|
const settings = patchNodeAgentSettings(
|
|
@@ -74393,13 +75325,13 @@ async function handleSandboxProbe(ctx) {
|
|
|
74393
75325
|
return mapThrown7(err);
|
|
74394
75326
|
}
|
|
74395
75327
|
}
|
|
74396
|
-
function
|
|
75328
|
+
function asRecord19(payload) {
|
|
74397
75329
|
return payload && typeof payload === "object" ? payload : {};
|
|
74398
75330
|
}
|
|
74399
75331
|
function handleTerminalCreate(payload, ctx) {
|
|
74400
75332
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74401
75333
|
if (denied) return denied;
|
|
74402
|
-
const p2 =
|
|
75334
|
+
const p2 = asRecord19(payload);
|
|
74403
75335
|
const cwd = typeof p2.cwd === "string" ? p2.cwd : process.cwd();
|
|
74404
75336
|
try {
|
|
74405
75337
|
const info = ctx.terminals.create({
|
|
@@ -74424,7 +75356,7 @@ function handleTerminalCreate(payload, ctx) {
|
|
|
74424
75356
|
function handleTerminalAttach(payload, ctx) {
|
|
74425
75357
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74426
75358
|
if (denied) return denied;
|
|
74427
|
-
const p2 =
|
|
75359
|
+
const p2 = asRecord19(payload);
|
|
74428
75360
|
const terminalId = String(p2.terminalId ?? "");
|
|
74429
75361
|
try {
|
|
74430
75362
|
const attached = ctx.terminals.attach(terminalId);
|
|
@@ -74436,7 +75368,7 @@ function handleTerminalAttach(payload, ctx) {
|
|
|
74436
75368
|
function handleTerminalRead(payload, ctx) {
|
|
74437
75369
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74438
75370
|
if (denied) return denied;
|
|
74439
|
-
const p2 =
|
|
75371
|
+
const p2 = asRecord19(payload);
|
|
74440
75372
|
try {
|
|
74441
75373
|
return {
|
|
74442
75374
|
result: ctx.terminals.readAfter(
|
|
@@ -74464,7 +75396,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
|
|
|
74464
75396
|
function handleTerminalWrite(payload, ctx) {
|
|
74465
75397
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74466
75398
|
if (denied) return denied;
|
|
74467
|
-
const p2 =
|
|
75399
|
+
const p2 = asRecord19(payload);
|
|
74468
75400
|
const terminalId = String(p2.terminalId ?? "");
|
|
74469
75401
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
74470
75402
|
if (leaseErr) return leaseErr;
|
|
@@ -74482,7 +75414,7 @@ function handleTerminalWrite(payload, ctx) {
|
|
|
74482
75414
|
function handleTerminalResize(payload, ctx) {
|
|
74483
75415
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74484
75416
|
if (denied) return denied;
|
|
74485
|
-
const p2 =
|
|
75417
|
+
const p2 = asRecord19(payload);
|
|
74486
75418
|
const terminalId = String(p2.terminalId ?? "");
|
|
74487
75419
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
74488
75420
|
if (leaseErr) return leaseErr;
|
|
@@ -74498,7 +75430,7 @@ function handleTerminalResize(payload, ctx) {
|
|
|
74498
75430
|
function handleTerminalKill(payload, ctx) {
|
|
74499
75431
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74500
75432
|
if (denied) return denied;
|
|
74501
|
-
const p2 =
|
|
75433
|
+
const p2 = asRecord19(payload);
|
|
74502
75434
|
const terminalId = String(p2.terminalId ?? "");
|
|
74503
75435
|
const leaseErr = requireTerminalLease(p2, ctx, terminalId);
|
|
74504
75436
|
if (leaseErr) return leaseErr;
|
|
@@ -74512,7 +75444,7 @@ function handleTerminalKill(payload, ctx) {
|
|
|
74512
75444
|
function handleTerminalAcquireControl(payload, ctx) {
|
|
74513
75445
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74514
75446
|
if (denied) return denied;
|
|
74515
|
-
const p2 =
|
|
75447
|
+
const p2 = asRecord19(payload);
|
|
74516
75448
|
const terminalId = String(p2.terminalId ?? "");
|
|
74517
75449
|
try {
|
|
74518
75450
|
return {
|
|
@@ -74529,7 +75461,7 @@ function handleTerminalAcquireControl(payload, ctx) {
|
|
|
74529
75461
|
function handleTerminalRenewControl(payload, ctx) {
|
|
74530
75462
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74531
75463
|
if (denied) return denied;
|
|
74532
|
-
const p2 =
|
|
75464
|
+
const p2 = asRecord19(payload);
|
|
74533
75465
|
try {
|
|
74534
75466
|
return {
|
|
74535
75467
|
result: ctx.leases.renew({
|
|
@@ -74546,7 +75478,7 @@ function handleTerminalRenewControl(payload, ctx) {
|
|
|
74546
75478
|
function handleTerminalReleaseControl(payload, ctx) {
|
|
74547
75479
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
|
|
74548
75480
|
if (denied) return denied;
|
|
74549
|
-
const p2 =
|
|
75481
|
+
const p2 = asRecord19(payload);
|
|
74550
75482
|
try {
|
|
74551
75483
|
ctx.leases.release(
|
|
74552
75484
|
String(p2.leaseId ?? ""),
|
|
@@ -74571,7 +75503,7 @@ function handleProjectList(ctx) {
|
|
|
74571
75503
|
function handleProjectGet(payload, ctx) {
|
|
74572
75504
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
|
|
74573
75505
|
if (denied) return denied;
|
|
74574
|
-
const p2 =
|
|
75506
|
+
const p2 = asRecord19(payload);
|
|
74575
75507
|
const projectId = String(p2.projectId ?? "");
|
|
74576
75508
|
return { result: ctx.projects.get(projectId) };
|
|
74577
75509
|
}
|
|
@@ -74587,7 +75519,7 @@ function expandHostPath(path) {
|
|
|
74587
75519
|
function handleProjectOpen(payload, ctx) {
|
|
74588
75520
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
74589
75521
|
if (denied) return denied;
|
|
74590
|
-
const p2 =
|
|
75522
|
+
const p2 = asRecord19(payload);
|
|
74591
75523
|
const path = expandHostPath(String(p2.path ?? ""));
|
|
74592
75524
|
if (!path) {
|
|
74593
75525
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -74605,7 +75537,7 @@ function handleProjectOpen(payload, ctx) {
|
|
|
74605
75537
|
function handleProjectRemove(payload, ctx) {
|
|
74606
75538
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
74607
75539
|
if (denied) return denied;
|
|
74608
|
-
const p2 =
|
|
75540
|
+
const p2 = asRecord19(payload);
|
|
74609
75541
|
const projectId = typeof p2.projectId === "string" && p2.projectId ? p2.projectId : void 0;
|
|
74610
75542
|
const pathRaw = typeof p2.path === "string" && p2.path ? expandHostPath(p2.path) : void 0;
|
|
74611
75543
|
if (!projectId && !pathRaw) {
|
|
@@ -74624,7 +75556,7 @@ function handleProjectRemove(payload, ctx) {
|
|
|
74624
75556
|
function handleFsListDir(payload, ctx) {
|
|
74625
75557
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74626
75558
|
if (denied) return denied;
|
|
74627
|
-
const p2 =
|
|
75559
|
+
const p2 = asRecord19(payload);
|
|
74628
75560
|
const raw = String(p2.path ?? "");
|
|
74629
75561
|
if (!raw || raw.includes("\0")) {
|
|
74630
75562
|
return { error: { code: "invalid_argument", message: "path is required" } };
|
|
@@ -74650,7 +75582,7 @@ function handleFsListDir(payload, ctx) {
|
|
|
74650
75582
|
function handleWorkspaceListDir(payload, ctx) {
|
|
74651
75583
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74652
75584
|
if (denied) return denied;
|
|
74653
|
-
const p2 =
|
|
75585
|
+
const p2 = asRecord19(payload);
|
|
74654
75586
|
try {
|
|
74655
75587
|
return {
|
|
74656
75588
|
result: ctx.workspaceFs.listDir(String(p2.projectId ?? ""), String(p2.relativePath ?? "."))
|
|
@@ -74662,7 +75594,7 @@ function handleWorkspaceListDir(payload, ctx) {
|
|
|
74662
75594
|
function handleWorkspaceListFiles(payload, ctx) {
|
|
74663
75595
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74664
75596
|
if (denied) return denied;
|
|
74665
|
-
const p2 =
|
|
75597
|
+
const p2 = asRecord19(payload);
|
|
74666
75598
|
try {
|
|
74667
75599
|
return {
|
|
74668
75600
|
result: {
|
|
@@ -74680,7 +75612,7 @@ function handleWorkspaceListFiles(payload, ctx) {
|
|
|
74680
75612
|
function handleWorkspaceListSkills(payload, ctx) {
|
|
74681
75613
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74682
75614
|
if (denied) return denied;
|
|
74683
|
-
const p2 =
|
|
75615
|
+
const p2 = asRecord19(payload);
|
|
74684
75616
|
try {
|
|
74685
75617
|
return {
|
|
74686
75618
|
result: ctx.workspaceFs.listSkillsAndCommands(String(p2.projectId ?? ""))
|
|
@@ -74692,7 +75624,7 @@ function handleWorkspaceListSkills(payload, ctx) {
|
|
|
74692
75624
|
function handleWorkspaceReadFile(payload, ctx) {
|
|
74693
75625
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74694
75626
|
if (denied) return denied;
|
|
74695
|
-
const p2 =
|
|
75627
|
+
const p2 = asRecord19(payload);
|
|
74696
75628
|
try {
|
|
74697
75629
|
return {
|
|
74698
75630
|
result: ctx.workspaceFs.readFile(String(p2.projectId ?? ""), String(p2.relativePath ?? ""), {
|
|
@@ -74707,7 +75639,7 @@ function handleWorkspaceReadFile(payload, ctx) {
|
|
|
74707
75639
|
function handleWorkspaceWriteFile(payload, ctx) {
|
|
74708
75640
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74709
75641
|
if (denied) return denied;
|
|
74710
|
-
const p2 =
|
|
75642
|
+
const p2 = asRecord19(payload);
|
|
74711
75643
|
const raw = typeof p2.content === "string" ? p2.content : String(p2.content ?? "");
|
|
74712
75644
|
const encoding = p2.encoding === "base64" ? "base64" : "utf8";
|
|
74713
75645
|
let content = raw;
|
|
@@ -74737,7 +75669,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
|
|
|
74737
75669
|
function handleWorkspaceSearch(payload, ctx) {
|
|
74738
75670
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74739
75671
|
if (denied) return denied;
|
|
74740
|
-
const p2 =
|
|
75672
|
+
const p2 = asRecord19(payload);
|
|
74741
75673
|
try {
|
|
74742
75674
|
return {
|
|
74743
75675
|
result: ctx.workspaceFs.search(
|
|
@@ -74753,7 +75685,7 @@ function handleWorkspaceSearch(payload, ctx) {
|
|
|
74753
75685
|
function handleWorkspaceRename(payload, ctx) {
|
|
74754
75686
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74755
75687
|
if (denied) return denied;
|
|
74756
|
-
const p2 =
|
|
75688
|
+
const p2 = asRecord19(payload);
|
|
74757
75689
|
try {
|
|
74758
75690
|
return {
|
|
74759
75691
|
result: ctx.workspaceFs.rename(
|
|
@@ -74769,7 +75701,7 @@ function handleWorkspaceRename(payload, ctx) {
|
|
|
74769
75701
|
function handleWorkspaceMove(payload, ctx) {
|
|
74770
75702
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74771
75703
|
if (denied) return denied;
|
|
74772
|
-
const p2 =
|
|
75704
|
+
const p2 = asRecord19(payload);
|
|
74773
75705
|
try {
|
|
74774
75706
|
return {
|
|
74775
75707
|
result: ctx.workspaceFs.move(
|
|
@@ -74785,7 +75717,7 @@ function handleWorkspaceMove(payload, ctx) {
|
|
|
74785
75717
|
function handleWorkspaceDelete(payload, ctx) {
|
|
74786
75718
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74787
75719
|
if (denied) return denied;
|
|
74788
|
-
const p2 =
|
|
75720
|
+
const p2 = asRecord19(payload);
|
|
74789
75721
|
try {
|
|
74790
75722
|
return {
|
|
74791
75723
|
result: ctx.workspaceFs.delete(
|
|
@@ -74800,7 +75732,7 @@ function handleWorkspaceDelete(payload, ctx) {
|
|
|
74800
75732
|
function handleWorkspaceMkdir(payload, ctx) {
|
|
74801
75733
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74802
75734
|
if (denied) return denied;
|
|
74803
|
-
const p2 =
|
|
75735
|
+
const p2 = asRecord19(payload);
|
|
74804
75736
|
try {
|
|
74805
75737
|
return {
|
|
74806
75738
|
result: ctx.workspaceFs.mkdir(
|
|
@@ -74815,7 +75747,7 @@ function handleWorkspaceMkdir(payload, ctx) {
|
|
|
74815
75747
|
function handleWorkspaceWatchStart(payload, ctx) {
|
|
74816
75748
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74817
75749
|
if (denied) return denied;
|
|
74818
|
-
const p2 =
|
|
75750
|
+
const p2 = asRecord19(payload);
|
|
74819
75751
|
try {
|
|
74820
75752
|
const events = [];
|
|
74821
75753
|
const { watchId, cancel } = ctx.workspaceWatch.subscribe(
|
|
@@ -74836,7 +75768,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
|
|
|
74836
75768
|
function handleWorkspaceWatchPoll(payload, ctx) {
|
|
74837
75769
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74838
75770
|
if (denied) return denied;
|
|
74839
|
-
const p2 =
|
|
75771
|
+
const p2 = asRecord19(payload);
|
|
74840
75772
|
const watchId = String(p2.watchId ?? "");
|
|
74841
75773
|
const buf = watchBuffers.get(watchId);
|
|
74842
75774
|
if (!buf || buf.owner !== ctx.client.clientSessionId) {
|
|
@@ -74848,7 +75780,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
|
|
|
74848
75780
|
function handleWorkspaceWatchStop(payload, ctx) {
|
|
74849
75781
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74850
75782
|
if (denied) return denied;
|
|
74851
|
-
const p2 =
|
|
75783
|
+
const p2 = asRecord19(payload);
|
|
74852
75784
|
const watchId = String(p2.watchId ?? "");
|
|
74853
75785
|
const buf = watchBuffers.get(watchId);
|
|
74854
75786
|
if (buf && buf.owner === ctx.client.clientSessionId) {
|
|
@@ -74860,7 +75792,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
|
|
|
74860
75792
|
function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
74861
75793
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74862
75794
|
if (denied) return denied;
|
|
74863
|
-
const p2 =
|
|
75795
|
+
const p2 = asRecord19(payload);
|
|
74864
75796
|
try {
|
|
74865
75797
|
const offset = typeof p2.offset === "number" ? p2.offset : void 0;
|
|
74866
75798
|
const absolutePath = typeof p2.absolutePath === "string" ? p2.absolutePath : void 0;
|
|
@@ -74878,7 +75810,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
|
74878
75810
|
function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
74879
75811
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74880
75812
|
if (denied) return denied;
|
|
74881
|
-
const p2 =
|
|
75813
|
+
const p2 = asRecord19(payload);
|
|
74882
75814
|
try {
|
|
74883
75815
|
return {
|
|
74884
75816
|
result: ctx.workspaceTailWatch.poll(String(p2.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -74890,7 +75822,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
|
|
|
74890
75822
|
function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
74891
75823
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74892
75824
|
if (denied) return denied;
|
|
74893
|
-
const p2 =
|
|
75825
|
+
const p2 = asRecord19(payload);
|
|
74894
75826
|
try {
|
|
74895
75827
|
return {
|
|
74896
75828
|
result: ctx.workspaceTailWatch.stop(String(p2.watchId ?? ""), ctx.client.clientSessionId)
|
|
@@ -74902,7 +75834,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
|
|
|
74902
75834
|
function handleGitStatus(payload, ctx) {
|
|
74903
75835
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74904
75836
|
if (denied) return denied;
|
|
74905
|
-
const p2 =
|
|
75837
|
+
const p2 = asRecord19(payload);
|
|
74906
75838
|
try {
|
|
74907
75839
|
const projectId = String(p2.projectId ?? "");
|
|
74908
75840
|
const cwd = typeof p2.cwd === "string" ? p2.cwd : null;
|
|
@@ -74916,7 +75848,7 @@ function handleGitStatus(payload, ctx) {
|
|
|
74916
75848
|
function handleGitDiff(payload, ctx) {
|
|
74917
75849
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74918
75850
|
if (denied) return denied;
|
|
74919
|
-
const p2 =
|
|
75851
|
+
const p2 = asRecord19(payload);
|
|
74920
75852
|
try {
|
|
74921
75853
|
return {
|
|
74922
75854
|
result: ctx.workspaceGit.diff(String(p2.projectId ?? ""), {
|
|
@@ -74931,7 +75863,7 @@ function handleGitDiff(payload, ctx) {
|
|
|
74931
75863
|
function handleGitBranches(payload, ctx) {
|
|
74932
75864
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74933
75865
|
if (denied) return denied;
|
|
74934
|
-
const p2 =
|
|
75866
|
+
const p2 = asRecord19(payload);
|
|
74935
75867
|
try {
|
|
74936
75868
|
return {
|
|
74937
75869
|
result: ctx.workspaceGit.branches(
|
|
@@ -74946,7 +75878,7 @@ function handleGitBranches(payload, ctx) {
|
|
|
74946
75878
|
function handleGitSwitchBranch(payload, ctx) {
|
|
74947
75879
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74948
75880
|
if (denied) return denied;
|
|
74949
|
-
const p2 =
|
|
75881
|
+
const p2 = asRecord19(payload);
|
|
74950
75882
|
try {
|
|
74951
75883
|
return {
|
|
74952
75884
|
result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
|
|
@@ -74961,7 +75893,7 @@ function handleGitSwitchBranch(payload, ctx) {
|
|
|
74961
75893
|
function handleGitCreateBranch(payload, ctx) {
|
|
74962
75894
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74963
75895
|
if (denied) return denied;
|
|
74964
|
-
const p2 =
|
|
75896
|
+
const p2 = asRecord19(payload);
|
|
74965
75897
|
try {
|
|
74966
75898
|
return {
|
|
74967
75899
|
result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
|
|
@@ -74976,7 +75908,7 @@ function handleGitCreateBranch(payload, ctx) {
|
|
|
74976
75908
|
function handleGitWorktrees(payload, ctx) {
|
|
74977
75909
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
74978
75910
|
if (denied) return denied;
|
|
74979
|
-
const p2 =
|
|
75911
|
+
const p2 = asRecord19(payload);
|
|
74980
75912
|
try {
|
|
74981
75913
|
return { result: ctx.workspaceGit.worktrees(String(p2.projectId ?? "")) };
|
|
74982
75914
|
} catch (err) {
|
|
@@ -74986,7 +75918,7 @@ function handleGitWorktrees(payload, ctx) {
|
|
|
74986
75918
|
function handleGitWorktreeActivate(payload, ctx) {
|
|
74987
75919
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
74988
75920
|
if (denied) return denied;
|
|
74989
|
-
const p2 =
|
|
75921
|
+
const p2 = asRecord19(payload);
|
|
74990
75922
|
const mode = p2.mode === "attach" || p2.mode === "detach" || p2.mode === "branch" ? p2.mode : null;
|
|
74991
75923
|
if (!mode) {
|
|
74992
75924
|
return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
|
|
@@ -75007,7 +75939,7 @@ function handleGitWorktreeActivate(payload, ctx) {
|
|
|
75007
75939
|
function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
75008
75940
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75009
75941
|
if (denied) return denied;
|
|
75010
|
-
const p2 =
|
|
75942
|
+
const p2 = asRecord19(payload);
|
|
75011
75943
|
try {
|
|
75012
75944
|
return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p2.projectId ?? "")) } };
|
|
75013
75945
|
} catch (err) {
|
|
@@ -75017,7 +75949,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
|
|
|
75017
75949
|
function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
75018
75950
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75019
75951
|
if (denied) return denied;
|
|
75020
|
-
const p2 =
|
|
75952
|
+
const p2 = asRecord19(payload);
|
|
75021
75953
|
try {
|
|
75022
75954
|
return {
|
|
75023
75955
|
result: ctx.workspaceGit.assignBranch(
|
|
@@ -75033,7 +75965,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
|
|
|
75033
75965
|
function handleGitWorktreeHandoff(payload, ctx) {
|
|
75034
75966
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
75035
75967
|
if (denied) return denied;
|
|
75036
|
-
const p2 =
|
|
75968
|
+
const p2 = asRecord19(payload);
|
|
75037
75969
|
try {
|
|
75038
75970
|
return {
|
|
75039
75971
|
result: ctx.workspaceGit.handoffToMain(
|
|
@@ -75048,7 +75980,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
|
|
|
75048
75980
|
function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
75049
75981
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
75050
75982
|
if (denied) return denied;
|
|
75051
|
-
const p2 =
|
|
75983
|
+
const p2 = asRecord19(payload);
|
|
75052
75984
|
try {
|
|
75053
75985
|
return {
|
|
75054
75986
|
result: ctx.workspaceGit.handoffPreview(
|
|
@@ -75063,7 +75995,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
|
|
|
75063
75995
|
function handleSessionSetCwd(payload, ctx) {
|
|
75064
75996
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75065
75997
|
if (denied) return denied;
|
|
75066
|
-
const p2 =
|
|
75998
|
+
const p2 = asRecord19(payload);
|
|
75067
75999
|
const sessionId = String(p2.sessionId ?? "");
|
|
75068
76000
|
const cwdRaw = p2.cwd;
|
|
75069
76001
|
const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
|
|
@@ -75092,7 +76024,7 @@ function handleSessionSetCwd(payload, ctx) {
|
|
|
75092
76024
|
function handleSessionPatchSettings(payload, ctx) {
|
|
75093
76025
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75094
76026
|
if (denied) return denied;
|
|
75095
|
-
const p2 =
|
|
76027
|
+
const p2 = asRecord19(payload);
|
|
75096
76028
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
75097
76029
|
if (!sessionId) {
|
|
75098
76030
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75108,7 +76040,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
75108
76040
|
generation: String(p2.generation ?? ""),
|
|
75109
76041
|
holderClientId: ctx.client.clientSessionId
|
|
75110
76042
|
});
|
|
75111
|
-
const settingsSrc =
|
|
76043
|
+
const settingsSrc = asRecord19(p2.settings ?? p2);
|
|
75112
76044
|
const patch = {};
|
|
75113
76045
|
const take = (key) => {
|
|
75114
76046
|
if (!(key in settingsSrc)) return;
|
|
@@ -75134,7 +76066,7 @@ function handleSessionPatchSettings(payload, ctx) {
|
|
|
75134
76066
|
async function handleSessionFork(payload, ctx) {
|
|
75135
76067
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75136
76068
|
if (denied) return denied;
|
|
75137
|
-
const p2 =
|
|
76069
|
+
const p2 = asRecord19(payload);
|
|
75138
76070
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
75139
76071
|
if (!sessionId) {
|
|
75140
76072
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75221,7 +76153,7 @@ async function handleSessionFork(payload, ctx) {
|
|
|
75221
76153
|
async function handleGitClone(payload, ctx) {
|
|
75222
76154
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75223
76155
|
if (denied) return denied;
|
|
75224
|
-
const p2 =
|
|
76156
|
+
const p2 = asRecord19(payload);
|
|
75225
76157
|
try {
|
|
75226
76158
|
const cloned = await cloneRepository({
|
|
75227
76159
|
remoteUrl: String(p2.remoteUrl ?? ""),
|
|
@@ -75237,7 +76169,7 @@ async function handleGitClone(payload, ctx) {
|
|
|
75237
76169
|
function handleSessionCreate(payload, ctx) {
|
|
75238
76170
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75239
76171
|
if (denied) return denied;
|
|
75240
|
-
const p2 =
|
|
76172
|
+
const p2 = asRecord19(payload);
|
|
75241
76173
|
const rawHarnessId = typeof p2.harnessId === "string" ? p2.harnessId : "claude";
|
|
75242
76174
|
const harnessId = normalizeSessionHarnessId(rawHarnessId);
|
|
75243
76175
|
if (!harnessId) {
|
|
@@ -75290,7 +76222,7 @@ function handleSessionCreate(payload, ctx) {
|
|
|
75290
76222
|
try {
|
|
75291
76223
|
const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
|
|
75292
76224
|
const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
|
|
75293
|
-
const options =
|
|
76225
|
+
const options = asRecord19(p2.options);
|
|
75294
76226
|
const providerId = typeof p2.providerId === "string" && p2.providerId.trim() ? p2.providerId.trim() : void 0;
|
|
75295
76227
|
const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
|
|
75296
76228
|
const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
|
|
@@ -75351,13 +76283,13 @@ function handleSessionCreate(payload, ctx) {
|
|
|
75351
76283
|
function handleSessionGet(payload, ctx) {
|
|
75352
76284
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
75353
76285
|
if (denied) return denied;
|
|
75354
|
-
const p2 =
|
|
76286
|
+
const p2 = asRecord19(payload);
|
|
75355
76287
|
return { result: ctx.sessions.get(String(p2.sessionId ?? "")) };
|
|
75356
76288
|
}
|
|
75357
76289
|
function handleSessionList(payload, ctx) {
|
|
75358
76290
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
75359
76291
|
if (denied) return denied;
|
|
75360
|
-
const p2 =
|
|
76292
|
+
const p2 = asRecord19(payload);
|
|
75361
76293
|
const projectId = typeof p2.projectId === "string" ? p2.projectId : void 0;
|
|
75362
76294
|
if (typeof p2.limit !== "number" || !Number.isFinite(p2.limit)) {
|
|
75363
76295
|
return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
|
|
@@ -75397,7 +76329,7 @@ function handleSessionList(payload, ctx) {
|
|
|
75397
76329
|
function handleSessionAcquireControl(payload, ctx) {
|
|
75398
76330
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75399
76331
|
if (denied) return denied;
|
|
75400
|
-
const p2 =
|
|
76332
|
+
const p2 = asRecord19(payload);
|
|
75401
76333
|
const sessionId = String(p2.sessionId ?? "");
|
|
75402
76334
|
if (!sessionId) {
|
|
75403
76335
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75421,7 +76353,7 @@ function handleSessionAcquireControl(payload, ctx) {
|
|
|
75421
76353
|
function handleSessionRenewControl(payload, ctx) {
|
|
75422
76354
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75423
76355
|
if (denied) return denied;
|
|
75424
|
-
const p2 =
|
|
76356
|
+
const p2 = asRecord19(payload);
|
|
75425
76357
|
try {
|
|
75426
76358
|
return {
|
|
75427
76359
|
result: ctx.leases.renew({
|
|
@@ -75438,7 +76370,7 @@ function handleSessionRenewControl(payload, ctx) {
|
|
|
75438
76370
|
function handleSessionReleaseControl(payload, ctx) {
|
|
75439
76371
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75440
76372
|
if (denied) return denied;
|
|
75441
|
-
const p2 =
|
|
76373
|
+
const p2 = asRecord19(payload);
|
|
75442
76374
|
try {
|
|
75443
76375
|
ctx.leases.release(
|
|
75444
76376
|
String(p2.leaseId ?? ""),
|
|
@@ -75453,7 +76385,7 @@ function handleSessionReleaseControl(payload, ctx) {
|
|
|
75453
76385
|
function handleSessionClose(payload, ctx) {
|
|
75454
76386
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75455
76387
|
if (denied) return denied;
|
|
75456
|
-
const p2 =
|
|
76388
|
+
const p2 = asRecord19(payload);
|
|
75457
76389
|
const sessionId = String(p2.sessionId ?? "");
|
|
75458
76390
|
try {
|
|
75459
76391
|
ctx.leases.assertValid({
|
|
@@ -75479,7 +76411,7 @@ function handleSessionClose(payload, ctx) {
|
|
|
75479
76411
|
function handleSessionRemove(payload, ctx) {
|
|
75480
76412
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75481
76413
|
if (denied) return denied;
|
|
75482
|
-
const p2 =
|
|
76414
|
+
const p2 = asRecord19(payload);
|
|
75483
76415
|
const sessionId = String(p2.sessionId ?? "");
|
|
75484
76416
|
if (!sessionId) {
|
|
75485
76417
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75506,7 +76438,7 @@ function handleSessionRemove(payload, ctx) {
|
|
|
75506
76438
|
function handleSessionRename(payload, ctx) {
|
|
75507
76439
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75508
76440
|
if (denied) return denied;
|
|
75509
|
-
const p2 =
|
|
76441
|
+
const p2 = asRecord19(payload);
|
|
75510
76442
|
const sessionId = String(p2.sessionId ?? "");
|
|
75511
76443
|
const title = String(p2.title ?? "");
|
|
75512
76444
|
const source = p2.source === "agent" ? "agent" : "user";
|
|
@@ -75522,7 +76454,7 @@ function handleSessionRename(payload, ctx) {
|
|
|
75522
76454
|
function handleSessionSetTags(payload, ctx) {
|
|
75523
76455
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75524
76456
|
if (denied) return denied;
|
|
75525
|
-
const p2 =
|
|
76457
|
+
const p2 = asRecord19(payload);
|
|
75526
76458
|
const sessionId = String(p2.sessionId ?? "");
|
|
75527
76459
|
if (!sessionId) {
|
|
75528
76460
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75548,7 +76480,7 @@ function handleSessionSetTags(payload, ctx) {
|
|
|
75548
76480
|
function handleSessionSetUiFlags(payload, ctx) {
|
|
75549
76481
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75550
76482
|
if (denied) return denied;
|
|
75551
|
-
const p2 =
|
|
76483
|
+
const p2 = asRecord19(payload);
|
|
75552
76484
|
const sessionId = String(p2.sessionId ?? "");
|
|
75553
76485
|
if (!sessionId) {
|
|
75554
76486
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75567,9 +76499,9 @@ function handleSessionSetUiFlags(payload, ctx) {
|
|
|
75567
76499
|
async function handleSessionSend(payload, ctx) {
|
|
75568
76500
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75569
76501
|
if (denied) return denied;
|
|
75570
|
-
const p2 =
|
|
76502
|
+
const p2 = asRecord19(payload);
|
|
75571
76503
|
try {
|
|
75572
|
-
const options =
|
|
76504
|
+
const options = asRecord19(p2.options);
|
|
75573
76505
|
const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
|
|
75574
76506
|
const modelTopLevel = typeof p2.model === "string" && p2.model.trim() ? p2.model.trim() : null;
|
|
75575
76507
|
const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
|
|
@@ -75662,7 +76594,7 @@ async function handleSessionSend(payload, ctx) {
|
|
|
75662
76594
|
function handleSessionInterrupt(payload, ctx) {
|
|
75663
76595
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75664
76596
|
if (denied) return denied;
|
|
75665
|
-
const p2 =
|
|
76597
|
+
const p2 = asRecord19(payload);
|
|
75666
76598
|
try {
|
|
75667
76599
|
ctx.sessions.interrupt(
|
|
75668
76600
|
String(p2.sessionId ?? ""),
|
|
@@ -75678,7 +76610,7 @@ function handleSessionInterrupt(payload, ctx) {
|
|
|
75678
76610
|
function handleSessionRespondPermission(payload, ctx) {
|
|
75679
76611
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75680
76612
|
if (denied) return denied;
|
|
75681
|
-
const p2 =
|
|
76613
|
+
const p2 = asRecord19(payload);
|
|
75682
76614
|
try {
|
|
75683
76615
|
const formAnswers = p2.formAnswers && typeof p2.formAnswers === "object" && !Array.isArray(p2.formAnswers) ? p2.formAnswers : p2.options && typeof p2.options === "object" && !Array.isArray(p2.options) ? p2.options.formAnswers ?? p2.options : void 0;
|
|
75684
76616
|
ctx.sessions.respondPermission({
|
|
@@ -75699,7 +76631,7 @@ function handleSessionRespondPermission(payload, ctx) {
|
|
|
75699
76631
|
function handleSessionRespondQuestion(payload, ctx) {
|
|
75700
76632
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75701
76633
|
if (denied) return denied;
|
|
75702
|
-
const p2 =
|
|
76634
|
+
const p2 = asRecord19(payload);
|
|
75703
76635
|
try {
|
|
75704
76636
|
ctx.sessions.respondQuestion({
|
|
75705
76637
|
sessionId: String(p2.sessionId ?? ""),
|
|
@@ -75717,7 +76649,7 @@ function handleSessionRespondQuestion(payload, ctx) {
|
|
|
75717
76649
|
function handleSessionRespondPlan(payload, ctx) {
|
|
75718
76650
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75719
76651
|
if (denied) return denied;
|
|
75720
|
-
const p2 =
|
|
76652
|
+
const p2 = asRecord19(payload);
|
|
75721
76653
|
const decision = p2.decision === "approve" || p2.decision === "reject" ? p2.decision : null;
|
|
75722
76654
|
if (!decision) {
|
|
75723
76655
|
return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
|
|
@@ -75740,7 +76672,7 @@ function handleSessionRespondPlan(payload, ctx) {
|
|
|
75740
76672
|
async function handleSessionHostActionsPoll(payload, ctx) {
|
|
75741
76673
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75742
76674
|
if (denied) return denied;
|
|
75743
|
-
const p2 =
|
|
76675
|
+
const p2 = asRecord19(payload);
|
|
75744
76676
|
try {
|
|
75745
76677
|
const result = await ctx.sessions.pollHostActions({
|
|
75746
76678
|
controllerClientSessionId: ctx.client.clientSessionId,
|
|
@@ -75756,7 +76688,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
|
|
|
75756
76688
|
function handleSessionClaimHostAction(payload, ctx) {
|
|
75757
76689
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75758
76690
|
if (denied) return denied;
|
|
75759
|
-
const p2 =
|
|
76691
|
+
const p2 = asRecord19(payload);
|
|
75760
76692
|
try {
|
|
75761
76693
|
const result = ctx.sessions.claimHostAction({
|
|
75762
76694
|
actionId: String(p2.actionId ?? ""),
|
|
@@ -75772,7 +76704,7 @@ function handleSessionClaimHostAction(payload, ctx) {
|
|
|
75772
76704
|
function handleSessionRespondHostAction(payload, ctx) {
|
|
75773
76705
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75774
76706
|
if (denied) return denied;
|
|
75775
|
-
const p2 =
|
|
76707
|
+
const p2 = asRecord19(payload);
|
|
75776
76708
|
const outcome = p2.outcome === "failed" ? "failed" : p2.outcome === "succeeded" ? "succeeded" : null;
|
|
75777
76709
|
if (!outcome) {
|
|
75778
76710
|
return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
|
|
@@ -75794,14 +76726,14 @@ function handleSessionRespondHostAction(payload, ctx) {
|
|
|
75794
76726
|
function handleSessionEvents(payload, ctx) {
|
|
75795
76727
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
75796
76728
|
if (denied) return denied;
|
|
75797
|
-
const p2 =
|
|
76729
|
+
const p2 = asRecord19(payload);
|
|
75798
76730
|
const after = String(p2.afterSequence ?? "0");
|
|
75799
76731
|
return { result: { events: ctx.sessions.listEventsAfter(after) } };
|
|
75800
76732
|
}
|
|
75801
76733
|
function handleSessionMessagesList(payload, ctx) {
|
|
75802
76734
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
75803
76735
|
if (denied) return denied;
|
|
75804
|
-
const p2 =
|
|
76736
|
+
const p2 = asRecord19(payload);
|
|
75805
76737
|
const sessionId = String(p2.sessionId ?? "").trim();
|
|
75806
76738
|
if (!sessionId) {
|
|
75807
76739
|
return { error: { code: "invalid_argument", message: "sessionId required" } };
|
|
@@ -75840,7 +76772,7 @@ function handleCollaborationListProfiles(ctx) {
|
|
|
75840
76772
|
async function handleCollaborationRequest(payload, ctx) {
|
|
75841
76773
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75842
76774
|
if (denied) return denied;
|
|
75843
|
-
const p2 =
|
|
76775
|
+
const p2 = asRecord19(payload);
|
|
75844
76776
|
const parentSessionId = String(p2.parentSessionId ?? "");
|
|
75845
76777
|
if (!parentSessionId) {
|
|
75846
76778
|
return { error: { code: "invalid_argument", message: "parentSessionId required" } };
|
|
@@ -75874,7 +76806,7 @@ async function handleCollaborationRequest(payload, ctx) {
|
|
|
75874
76806
|
async function handleCollaborationStart(payload, ctx) {
|
|
75875
76807
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75876
76808
|
if (denied) return denied;
|
|
75877
|
-
const p2 =
|
|
76809
|
+
const p2 = asRecord19(payload);
|
|
75878
76810
|
const credential = typeof p2.credential === "string" ? p2.credential : void 0;
|
|
75879
76811
|
const grantId = typeof p2.grantId === "string" ? p2.grantId : void 0;
|
|
75880
76812
|
if (!credential && !grantId) {
|
|
@@ -75920,7 +76852,7 @@ async function handleCollaborationStart(payload, ctx) {
|
|
|
75920
76852
|
function handleCollaborationSend(payload, ctx) {
|
|
75921
76853
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
|
|
75922
76854
|
if (denied) return denied;
|
|
75923
|
-
const p2 =
|
|
76855
|
+
const p2 = asRecord19(payload);
|
|
75924
76856
|
const credential = String(p2.credential ?? "");
|
|
75925
76857
|
const sessionId = String(p2.sessionId ?? p2.fromSessionId ?? "");
|
|
75926
76858
|
const content = typeof p2.content === "string" ? p2.content : p2.body !== void 0 ? typeof p2.body === "string" ? p2.body : JSON.stringify(p2.body) : "";
|
|
@@ -75956,7 +76888,7 @@ function handleCollaborationSend(payload, ctx) {
|
|
|
75956
76888
|
function handleCollaborationRetrieve(payload, ctx) {
|
|
75957
76889
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
|
|
75958
76890
|
if (denied) return denied;
|
|
75959
|
-
const p2 =
|
|
76891
|
+
const p2 = asRecord19(payload);
|
|
75960
76892
|
const credential = String(p2.credential ?? "");
|
|
75961
76893
|
const sessionId = String(p2.sessionId ?? "");
|
|
75962
76894
|
if (!credential) {
|
|
@@ -76802,8 +77734,8 @@ function requiredRuntimeVersion(harnessId, manifest) {
|
|
|
76802
77734
|
import { existsSync as existsSync29, mkdirSync as mkdirSync18, readFileSync as readFileSync17, readdirSync as readdirSync10, statSync as statSync9, writeFileSync as writeFileSync13 } from "node:fs";
|
|
76803
77735
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
76804
77736
|
import { join as join27, resolve as resolve7 } from "node:path";
|
|
76805
|
-
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.
|
|
76806
|
-
var OFFICIAL_CODEX_NPM_VERSION = "0.
|
|
77737
|
+
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.238";
|
|
77738
|
+
var OFFICIAL_CODEX_NPM_VERSION = "0.149.0";
|
|
76807
77739
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
76808
77740
|
function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
76809
77741
|
const platform2 = process.platform;
|
|
@@ -94751,6 +95683,7 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
94751
95683
|
allowSimulatedFallback: allowSimulatedTurnFallback,
|
|
94752
95684
|
providers,
|
|
94753
95685
|
experimentalClaudeOpenAiChatEnabled: () => loadNodeAgentSettings(paths.configJson).experimentalClaudeOpenAiChatEnabled,
|
|
95686
|
+
askUserQuestionPreviewFormat: () => loadNodeAgentSettings(paths.configJson).claude.askUserQuestionPreviewFormat,
|
|
94754
95687
|
// Claude: in-process SDK MCP (same core tools as HTTP).
|
|
94755
95688
|
createHostActionClaudeMcp: (sessionId) => hostActionMcp.createClaudeSdkMcp(sessionId),
|
|
94756
95689
|
// Codex / ACP / OpenCode: loopback HTTP with per-session HMAC.
|