@super-one/cli 0.56.0-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.
Files changed (3) hide show
  1. package/MANIFEST.json +2 -2
  2. package/lib/cli.mjs +813 -421
  3. package/package.json +1 -1
package/lib/cli.mjs CHANGED
@@ -164,7 +164,7 @@ var init_host_actions = __esm({
164
164
  });
165
165
 
166
166
  // ../../packages/shared/src/environment/host-action-superone-descriptors.ts
167
- var deviceDescriptionProperty, deviceConditionSchema, deviceActionSchema, 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";
@@ -174,6 +174,10 @@ var init_host_action_superone_descriptors = __esm({
174
174
  maxLength: 160,
175
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
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
+ };
177
181
  deviceConditionSchema = {
178
182
  type: "object",
179
183
  properties: {
@@ -250,7 +254,11 @@ var init_host_action_superone_descriptors = __esm({
250
254
  description: "type: text to enter. Anything the simulated keyboard cannot spell (Chinese, emoji) is pasted automatically.",
251
255
  type: "string"
252
256
  },
253
- button: { type: "string", enum: ["home", "lock", "side", "volume-up", "volume-down"] },
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
+ },
254
262
  orientation: {
255
263
  type: "string",
256
264
  enum: ["portrait", "landscape-left", "portrait-upside-down", "landscape-right"]
@@ -3658,7 +3666,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
3658
3666
  },
3659
3667
  "reasoningEffort": {
3660
3668
  "type": "string",
3661
- "enum": ["minimal", "low", "medium", "high", "xhigh"],
3669
+ "enum": ["minimal", "low", "medium", "high", "xhigh", "max", "ultra"],
3662
3670
  "description": "Codex legacy alias for effort."
3663
3671
  },
3664
3672
  "permissionPreset": {
@@ -3716,13 +3724,51 @@ If the tool returns an error containing "user_locked", the user has manually nam
3716
3724
  "additionalProperties": false
3717
3725
  }
3718
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
+ },
3719
3764
  {
3720
3765
  "name": "device_snapshot",
3721
- "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 only if you need to look. mode=fused returns both. Waits for animation to stop first; settled=false means it was still moving, so treat geometry as approximate. A screen with no accessibility tree falls back to text read from pixels; the reply says source=ocr. Re-snapshot after anything that changes the screen \u2014 refs are positional and a stale stateId is rejected by device_act.",
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.",
3722
3767
  "inputSchema": {
3723
3768
  "type": "object",
3724
3769
  "properties": {
3725
3770
  "description": deviceDescriptionProperty,
3771
+ "device": deviceTargetProperty,
3726
3772
  "mode": { "description": "Default semantic", "type": "string", "enum": ["semantic", "visual", "fused"] },
3727
3773
  "maxNodes": {
3728
3774
  "description": "Ceiling on tree size. Default 500; truncated=true means the screen has more.",
@@ -3742,6 +3788,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
3742
3788
  "type": "object",
3743
3789
  "properties": {
3744
3790
  "description": deviceDescriptionProperty,
3791
+ "device": deviceTargetProperty,
3745
3792
  "stateId": { "type": "string", "description": "From a prior device_snapshot." },
3746
3793
  "op": { "type": "string", "enum": ["search", "inspect"] },
3747
3794
  "text": { "description": "For search.", "type": "string" },
@@ -3758,6 +3805,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
3758
3805
  "type": "object",
3759
3806
  "properties": {
3760
3807
  "description": deviceDescriptionProperty,
3808
+ "device": deviceTargetProperty,
3761
3809
  "stateId": { "type": "string" },
3762
3810
  "actions": { "minItems": 1, "maxItems": 10, "type": "array", "items": deviceActionSchema },
3763
3811
  "expect": { "description": "Postcondition checked after the actions run.", ...deviceConditionSchema }
@@ -3773,6 +3821,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
3773
3821
  "type": "object",
3774
3822
  "properties": {
3775
3823
  "description": deviceDescriptionProperty,
3824
+ "device": deviceTargetProperty,
3776
3825
  "condition": deviceConditionSchema,
3777
3826
  "timeoutMs": {
3778
3827
  "description": "Default 5000",
@@ -3857,6 +3906,7 @@ var init_host_action_browser_catalog = __esm({
3857
3906
  "widget_list_templates",
3858
3907
  "miniapp_list",
3859
3908
  "automation_list",
3909
+ "device_list",
3860
3910
  "device_snapshot",
3861
3911
  "device_query",
3862
3912
  "device_wait_for",
@@ -19200,7 +19250,7 @@ var init_agent_error = __esm({
19200
19250
  }
19201
19251
  });
19202
19252
 
19203
- // ../../packages/codex/src/agent-event-mapper.ts
19253
+ // ../../packages/codex/src/protocol-v149.ts
19204
19254
  function asRecord(value) {
19205
19255
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
19206
19256
  }
@@ -19208,6 +19258,75 @@ function readString(value) {
19208
19258
  return typeof value === "string" && value.length > 0 ? value : null;
19209
19259
  }
19210
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) {
19211
19330
  if (typeof value === "number" && Number.isFinite(value)) return value;
19212
19331
  if (typeof value === "string") {
19213
19332
  const parsed = Number(value);
@@ -19220,7 +19339,7 @@ function readBoolean(value) {
19220
19339
  }
19221
19340
  function readStringArray(value) {
19222
19341
  if (!Array.isArray(value)) return [];
19223
- return value.map(readString).filter((entry) => entry !== null);
19342
+ return value.map(readString2).filter((entry) => entry !== null);
19224
19343
  }
19225
19344
  function uniqueStrings(values) {
19226
19345
  const result = [];
@@ -19231,30 +19350,30 @@ function uniqueStrings(values) {
19231
19350
  return result;
19232
19351
  }
19233
19352
  function readTextPart(value) {
19234
- const direct = readString(value);
19353
+ const direct = readString2(value);
19235
19354
  if (direct !== null) return direct;
19236
- const rec = asRecord(value);
19355
+ const rec = asRecord2(value);
19237
19356
  if (!rec) return null;
19238
- return readString(rec.text) ?? readString(rec.summaryText) ?? readString(rec.summary_text) ?? readString(rec.content);
19357
+ return readString2(rec.text) ?? readString2(rec.summaryText) ?? readString2(rec.summary_text) ?? readString2(rec.content);
19239
19358
  }
19240
19359
  function readTextParts(value) {
19241
19360
  if (!Array.isArray(value)) return [];
19242
19361
  return value.map(readTextPart).filter((entry) => entry !== null && entry.length > 0);
19243
19362
  }
19244
19363
  function readCodexItemId(rec) {
19245
- return readString(rec.itemId) ?? readString(rec.item_id) ?? readString(rec.id) ?? readString(asRecord(rec.item)?.id);
19364
+ return readString2(rec.itemId) ?? readString2(rec.item_id) ?? readString2(rec.id) ?? readString2(asRecord2(rec.item)?.id);
19246
19365
  }
19247
19366
  function readCodexDeltaText(rec) {
19248
- return readString(rec.delta) ?? readString(rec.textDelta) ?? readString(rec.text_delta) ?? readString(rec.summaryTextDelta) ?? readString(rec.summary_text_delta) ?? readString(rec.summaryDelta) ?? readString(rec.summary_delta) ?? readString(rec.text) ?? readString(rec.summaryText) ?? readString(rec.summary_text) ?? "";
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) ?? "";
19249
19368
  }
19250
19369
  function mapPatchChangeKind(raw) {
19251
- const direct = readString(raw);
19370
+ const direct = readString2(raw);
19252
19371
  if (direct === "add" || direct === "delete" || direct === "update") return direct;
19253
- const kind = readString(asRecord(raw)?.type);
19372
+ const kind = readString2(asRecord2(raw)?.type);
19254
19373
  return kind === "add" || kind === "delete" || kind === "update" ? kind : "update";
19255
19374
  }
19256
19375
  function mapCommandExecutionStatus(raw) {
19257
- switch (readString(raw)) {
19376
+ switch (readString2(raw)) {
19258
19377
  case "in_progress":
19259
19378
  case "inProgress":
19260
19379
  return "in_progress";
@@ -19266,11 +19385,11 @@ function mapCommandExecutionStatus(raw) {
19266
19385
  }
19267
19386
  }
19268
19387
  function mapPatchApplyStatus(raw) {
19269
- const status = readString(raw);
19388
+ const status = readString2(raw);
19270
19389
  return status === "failed" || status === "declined" ? "failed" : "completed";
19271
19390
  }
19272
19391
  function mapMcpToolCallStatus(raw) {
19273
- switch (readString(raw)) {
19392
+ switch (readString2(raw)) {
19274
19393
  case "in_progress":
19275
19394
  case "inProgress":
19276
19395
  return "in_progress";
@@ -19281,7 +19400,7 @@ function mapMcpToolCallStatus(raw) {
19281
19400
  }
19282
19401
  }
19283
19402
  function normalizeCollabTool(value) {
19284
- switch (readString(value)) {
19403
+ switch (readString2(value)) {
19285
19404
  case "spawnAgent":
19286
19405
  case "spawn_agent":
19287
19406
  return "spawnAgent";
@@ -19302,7 +19421,7 @@ function normalizeCollabTool(value) {
19302
19421
  }
19303
19422
  }
19304
19423
  function normalizeCollabAgentStatus(value) {
19305
- switch (readString(value)) {
19424
+ switch (readString2(value)) {
19306
19425
  case "pendingInit":
19307
19426
  case "pending_init":
19308
19427
  return "pendingInit";
@@ -19328,10 +19447,10 @@ function buildCodexReasoningItem(id, text, previous, now = Date.now) {
19328
19447
  return { id, type: "reasoning", text, startedAt, endedAt: timestamp };
19329
19448
  }
19330
19449
  function mapCodexThreadItem(raw, previous, now = Date.now) {
19331
- const rec = asRecord(raw);
19450
+ const rec = asRecord2(raw);
19332
19451
  if (!rec) return null;
19333
- const type = readString(rec.type);
19334
- const id = readString(rec.id) ?? previous?.id;
19452
+ const type = readString2(rec.type);
19453
+ const id = readString2(rec.id) ?? previous?.id;
19335
19454
  if (!type || !id) return null;
19336
19455
  switch (type) {
19337
19456
  case "agent_message":
@@ -19339,32 +19458,33 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19339
19458
  return {
19340
19459
  id,
19341
19460
  type: "agent_message",
19342
- text: readString(rec.text) ?? (previous?.type === "agent_message" ? previous.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" } : {}
19343
19463
  };
19344
19464
  case "reasoning": {
19345
- const text = readString(rec.text) || readTextParts(rec.summary).join("\n\n") || readTextParts(rec.content).join("\n\n") || (previous?.type === "reasoning" ? previous.text : "");
19465
+ const text = readString2(rec.text) || readTextParts(rec.summary).join("\n\n") || readTextParts(rec.content).join("\n\n") || (previous?.type === "reasoning" ? previous.text : "");
19346
19466
  return buildCodexReasoningItem(id, text, previous, now);
19347
19467
  }
19348
19468
  case "command_execution":
19349
19469
  case "commandExecution": {
19350
19470
  const prev = previous?.type === "command_execution" ? previous : null;
19351
19471
  const actions = Array.isArray(rec.commandActions) ? rec.commandActions.map((entry) => {
19352
- const action = asRecord(entry);
19472
+ const action = asRecord2(entry);
19353
19473
  if (!action) return null;
19354
19474
  return {
19355
- type: readString(action.type) ?? "unknown",
19356
- ...action.command != null ? { command: readString(action.command) ?? void 0 } : {},
19357
- ...action.name != null ? { name: readString(action.name) ?? void 0 } : {},
19358
- ...action.path != null ? { path: readString(action.path) ?? void 0 } : {},
19359
- ...action.query != null ? { query: readString(action.query) ?? void 0 } : {}
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 } : {}
19360
19480
  };
19361
19481
  }).filter((entry) => entry !== null) : void 0;
19362
- const exitCode = readNumber(rec.exitCode) ?? readNumber(rec.exit_code);
19482
+ const exitCode = readNumber2(rec.exitCode) ?? readNumber2(rec.exit_code);
19363
19483
  return {
19364
19484
  id,
19365
19485
  type: "command_execution",
19366
- command: readString(rec.command) ?? prev?.command ?? "",
19367
- aggregatedOutput: readString(rec.aggregatedOutput) ?? readString(rec.aggregated_output) ?? prev?.aggregatedOutput ?? "",
19486
+ command: readString2(rec.command) ?? prev?.command ?? "",
19487
+ aggregatedOutput: readString2(rec.aggregatedOutput) ?? readString2(rec.aggregated_output) ?? prev?.aggregatedOutput ?? "",
19368
19488
  ...exitCode !== null ? { exitCode } : {},
19369
19489
  status: mapCommandExecutionStatus(rec.status ?? prev?.status),
19370
19490
  ...actions ? { commandActions: actions } : prev?.commandActions ? { commandActions: prev.commandActions } : {}
@@ -19373,10 +19493,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19373
19493
  case "file_change":
19374
19494
  case "fileChange": {
19375
19495
  const changes = Array.isArray(rec.changes) ? rec.changes.map((entry) => {
19376
- const change = asRecord(entry);
19377
- const path = readString(change?.path);
19496
+ const change = asRecord2(entry);
19497
+ const path = readString2(change?.path);
19378
19498
  if (!path) return null;
19379
- const diff = readString(change?.diff);
19499
+ const diff = readString2(change?.diff);
19380
19500
  return { path, kind: mapPatchChangeKind(change?.kind), ...diff !== null ? { diff } : {} };
19381
19501
  }).filter((entry) => entry !== null) : previous?.type === "file_change" ? previous.changes : [];
19382
19502
  return {
@@ -19389,19 +19509,19 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19389
19509
  case "mcp_tool_call":
19390
19510
  case "mcpToolCall": {
19391
19511
  const prev = previous?.type === "mcp_tool_call" ? previous : null;
19392
- const result = asRecord(rec.result);
19393
- const error51 = asRecord(rec.error);
19512
+ const result = asRecord2(rec.result);
19513
+ const error51 = asRecord2(rec.error);
19394
19514
  return {
19395
19515
  id,
19396
19516
  type: "mcp_tool_call",
19397
- server: readString(rec.server) ?? prev?.server ?? "",
19398
- tool: readString(rec.tool) ?? prev?.tool ?? "",
19517
+ server: readString2(rec.server) ?? prev?.server ?? "",
19518
+ tool: readString2(rec.tool) ?? prev?.tool ?? "",
19399
19519
  arguments: rec.arguments ?? prev?.arguments ?? {},
19400
19520
  ...result ? { result: {
19401
19521
  content: Array.isArray(result.content) ? result.content : [],
19402
19522
  structuredContent: result.structuredContent ?? result.structured_content ?? null
19403
19523
  } } : prev?.result ? { result: prev.result } : {},
19404
- ...error51 ? { error: { message: readString(error51.message) ?? "Unknown MCP tool error" } } : prev?.error ? { error: prev.error } : {},
19524
+ ...error51 ? { error: { message: readString2(error51.message) ?? "Unknown MCP tool error" } } : prev?.error ? { error: prev.error } : {},
19405
19525
  status: mapMcpToolCallStatus(rec.status ?? prev?.status)
19406
19526
  };
19407
19527
  }
@@ -19411,29 +19531,31 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19411
19531
  return {
19412
19532
  id,
19413
19533
  type: "web_search",
19414
- query: readString(rec.query) ?? prev?.query ?? "",
19534
+ query: readString2(rec.query) ?? prev?.query ?? "",
19415
19535
  status: mapMcpToolCallStatus(rec.status ?? prev?.status)
19416
19536
  };
19417
19537
  }
19418
19538
  case "image_generation":
19419
19539
  case "imageGeneration": {
19420
19540
  const prev = previous?.type === "image_generation" ? previous : null;
19421
- const revisedPrompt = readString(rec.revisedPrompt ?? rec.revised_prompt) ?? prev?.revisedPrompt;
19422
- const savedPath = readString(rec.savedPath ?? rec.saved_path) ?? prev?.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;
19423
19544
  return {
19424
19545
  id,
19425
19546
  type: "image_generation",
19426
- status: readString(rec.status) ?? prev?.status ?? "in_progress",
19547
+ status: readString2(rec.status) ?? prev?.status ?? "in_progress",
19427
19548
  ...revisedPrompt ? { revisedPrompt } : {},
19428
19549
  ...savedPath ? { savedPath } : {},
19550
+ ...failure ? { failure } : {},
19429
19551
  ...prev?.generationMs !== void 0 ? { generationMs: prev.generationMs } : {}
19430
19552
  };
19431
19553
  }
19432
19554
  case "todo_list":
19433
19555
  case "todoList": {
19434
19556
  const items = Array.isArray(rec.items) ? rec.items.map((entry) => {
19435
- const todo = asRecord(entry);
19436
- const text = readString(todo?.text);
19557
+ const todo = asRecord2(entry);
19558
+ const text = readString2(todo?.text);
19437
19559
  return text ? { text, completed: readBoolean(todo?.completed) ?? false } : null;
19438
19560
  }).filter((entry) => entry !== null) : previous?.type === "todo_list" ? previous.items : [];
19439
19561
  return { id, type: "todo_list", items };
@@ -19442,16 +19564,16 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19442
19564
  return {
19443
19565
  id,
19444
19566
  type: "error",
19445
- message: readString(rec.message) ?? (previous?.type === "error" ? previous.message : "Unknown error")
19567
+ message: readString2(rec.message) ?? (previous?.type === "error" ? previous.message : "Unknown error")
19446
19568
  };
19447
19569
  case "plan": {
19448
- const text = readString(rec.text);
19570
+ const text = readString2(rec.text);
19449
19571
  return text ? buildCodexReasoningItem(id, text, previous, now) : null;
19450
19572
  }
19451
19573
  case "enteredReviewMode":
19452
- return { id, type: "review", phase: "entered", text: readString(rec.text) ?? readString(rec.review) ?? "" };
19574
+ return { id, type: "review", phase: "entered", text: readString2(rec.text) ?? readString2(rec.review) ?? "" };
19453
19575
  case "exitedReviewMode":
19454
- return { id: `${id}_exit`, type: "review", phase: "exited", text: readString(rec.text) ?? readString(rec.review) ?? "" };
19576
+ return { id: `${id}_exit`, type: "review", phase: "exited", text: readString2(rec.text) ?? readString2(rec.review) ?? "" };
19455
19577
  case "contextCompaction":
19456
19578
  return { id, type: "compaction" };
19457
19579
  case "collabAgentToolCall":
@@ -19459,44 +19581,44 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19459
19581
  const prev = previous?.type === "collab_tool_call" ? previous : null;
19460
19582
  const receiverThreadIds = uniqueStrings([
19461
19583
  ...readStringArray(rec.receiverThreadIds ?? rec.receiver_thread_ids),
19462
- readString(rec.receiverThreadId ?? rec.receiver_thread_id),
19463
- readString(rec.newThreadId ?? rec.new_thread_id)
19584
+ readString2(rec.receiverThreadId ?? rec.receiver_thread_id),
19585
+ readString2(rec.newThreadId ?? rec.new_thread_id)
19464
19586
  ]);
19465
19587
  const agentsStates = { ...prev?.agentsStates ?? {} };
19466
- const rawStates = asRecord(rec.agentsStates ?? rec.agents_states);
19588
+ const rawStates = asRecord2(rec.agentsStates ?? rec.agents_states);
19467
19589
  if (rawStates) {
19468
19590
  for (const [agentId, value] of Object.entries(rawStates)) {
19469
- const state = asRecord(value);
19591
+ const state = asRecord2(value);
19470
19592
  if (!state) continue;
19471
19593
  const prior = prev?.agentsStates?.[agentId];
19472
19594
  agentsStates[agentId] = {
19473
19595
  ...prior,
19474
19596
  status: normalizeCollabAgentStatus(state.status) ?? prior?.status ?? "running",
19475
- ...state.message != null ? { message: readString(state.message) ?? void 0 } : {}
19597
+ ...state.message != null ? { message: readString2(state.message) ?? void 0 } : {}
19476
19598
  };
19477
19599
  }
19478
19600
  }
19479
19601
  const rawAgentStatus = rec.agentStatus ?? rec.agent_status;
19480
- const agentStatus = asRecord(rawAgentStatus);
19602
+ const agentStatus = asRecord2(rawAgentStatus);
19481
19603
  if (!rawStates && rawAgentStatus != null) {
19482
19604
  for (const agentId of receiverThreadIds) {
19483
19605
  const prior = prev?.agentsStates?.[agentId];
19484
19606
  agentsStates[agentId] = {
19485
19607
  ...prior,
19486
19608
  status: normalizeCollabAgentStatus(agentStatus?.status ?? rawAgentStatus) ?? prior?.status ?? "running",
19487
- ...agentStatus?.message != null ? { message: readString(agentStatus.message) ?? void 0 } : {}
19609
+ ...agentStatus?.message != null ? { message: readString2(agentStatus.message) ?? void 0 } : {}
19488
19610
  };
19489
19611
  }
19490
19612
  }
19491
- const rawStatus = readString(rec.status);
19613
+ const rawStatus = readString2(rec.status);
19492
19614
  return {
19493
19615
  id,
19494
19616
  type: "collab_tool_call",
19495
19617
  tool: normalizeCollabTool(rec.tool) ?? prev?.tool ?? "spawnAgent",
19496
19618
  status: rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "in_progress",
19497
- ...readString(rec.senderThreadId) ?? readString(rec.sender_thread_id) ?? prev?.senderThreadId ? { senderThreadId: readString(rec.senderThreadId) ?? readString(rec.sender_thread_id) ?? prev?.senderThreadId } : {},
19619
+ ...readString2(rec.senderThreadId) ?? readString2(rec.sender_thread_id) ?? prev?.senderThreadId ? { senderThreadId: readString2(rec.senderThreadId) ?? readString2(rec.sender_thread_id) ?? prev?.senderThreadId } : {},
19498
19620
  receiverThreadIds: receiverThreadIds.length > 0 ? receiverThreadIds : prev?.receiverThreadIds ?? [],
19499
- ...readString(rec.prompt) ?? prev?.prompt ? { prompt: readString(rec.prompt) ?? prev?.prompt } : {},
19621
+ ...readString2(rec.prompt) ?? prev?.prompt ? { prompt: readString2(rec.prompt) ?? prev?.prompt } : {},
19500
19622
  agentsStates,
19501
19623
  ...prev?.childItems ? { childItems: prev.childItems } : {}
19502
19624
  };
@@ -19506,17 +19628,17 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
19506
19628
  }
19507
19629
  }
19508
19630
  function mapCodexUsage(raw) {
19509
- const rec = asRecord(raw);
19631
+ const rec = asRecord2(raw);
19510
19632
  if (!rec) return null;
19511
19633
  const parse4 = (value) => {
19512
- const data = asRecord(value);
19634
+ const data = asRecord2(value);
19513
19635
  if (!data) return null;
19514
19636
  return {
19515
- inputTokens: readNumber(data.inputTokens ?? data.input_tokens) ?? 0,
19516
- cachedInputTokens: readNumber(data.cachedInputTokens ?? data.cached_input_tokens) ?? 0,
19517
- cacheWriteInputTokens: readNumber(data.cacheWriteInputTokens ?? data.cache_write_input_tokens) ?? 0,
19518
- outputTokens: readNumber(data.outputTokens ?? data.output_tokens) ?? 0,
19519
- reasoningOutputTokens: readNumber(data.reasoningOutputTokens ?? data.reasoning_output_tokens) ?? 0
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
19520
19642
  };
19521
19643
  };
19522
19644
  const last = parse4(rec.last);
@@ -19533,19 +19655,19 @@ function mapCodexUsage(raw) {
19533
19655
  lastCachedInputTokens: resolvedLast.cachedInputTokens,
19534
19656
  lastCacheWriteInputTokens: resolvedLast.cacheWriteInputTokens,
19535
19657
  lastOutputTokens: resolvedLast.outputTokens,
19536
- reasoningOutputTokens: resolvedTotal.reasoningOutputTokens || (readNumber(rec.reasoningOutputTokens ?? rec.reasoning_output_tokens) ?? 0),
19537
- contextWindow: readNumber(rec.modelContextWindow ?? rec.model_context_window ?? rec.contextWindow ?? rec.context_window) ?? 0
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
19538
19660
  };
19539
19661
  }
19540
19662
  function extractError(raw) {
19541
- const rec = asRecord(raw);
19663
+ const rec = asRecord2(raw);
19542
19664
  if (!rec) return "Codex turn failed";
19543
- return readString(rec.message) ?? readString(asRecord(rec.error)?.message) ?? "Codex turn failed";
19665
+ return readString2(rec.message) ?? readString2(asRecord2(rec.error)?.message) ?? "Codex turn failed";
19544
19666
  }
19545
19667
  function deriveCodexFinalResponse(items) {
19546
19668
  for (let index = items.length - 1; index >= 0; index--) {
19547
19669
  const item = items[index];
19548
- if (item?.type === "agent_message") return item.text;
19670
+ if (item?.type === "agent_message" && item.delivery !== "async") return item.text;
19549
19671
  }
19550
19672
  return "";
19551
19673
  }
@@ -19579,13 +19701,13 @@ function createCodexAgentEventMapper(options) {
19579
19701
  };
19580
19702
  const finishStatus = () => options.emit({ type: "status_change", status: "idle" });
19581
19703
  const startCompaction = (params) => {
19582
- const turnId = readString(params.turnId) ?? readString(params.turn_id) ?? currentTurnId;
19704
+ const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId;
19583
19705
  if (turnId && completedCompactionTurns.has(turnId)) return;
19584
19706
  if (activeCompaction && (!activeCompaction.turnId || !turnId || activeCompaction.turnId === turnId)) {
19585
19707
  if (!activeCompaction.turnId && turnId) {
19586
19708
  activeCompaction = {
19587
19709
  turnId,
19588
- startedAt: readNumber(params.startedAtMs ?? params.started_at_ms) ?? activeCompaction.startedAt,
19710
+ startedAt: readNumber2(params.startedAtMs ?? params.started_at_ms) ?? activeCompaction.startedAt,
19589
19711
  preTokens: currentUsage?.lastInputTokens ?? activeCompaction.preTokens
19590
19712
  };
19591
19713
  }
@@ -19593,18 +19715,18 @@ function createCodexAgentEventMapper(options) {
19593
19715
  }
19594
19716
  activeCompaction = {
19595
19717
  turnId,
19596
- startedAt: readNumber(params.startedAtMs ?? params.started_at_ms) ?? now(),
19718
+ startedAt: readNumber2(params.startedAtMs ?? params.started_at_ms) ?? now(),
19597
19719
  preTokens: currentUsage?.lastInputTokens ?? 0
19598
19720
  };
19599
19721
  options.emit({ type: "status_indicator", indicator: "compacting" });
19600
19722
  };
19601
19723
  const completeCompaction = (params) => {
19602
- const turnId = readString(params.turnId) ?? readString(params.turn_id) ?? currentTurnId;
19724
+ const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId;
19603
19725
  if (turnId && completedCompactionTurns.has(turnId)) return;
19604
19726
  if (!activeCompaction) startCompaction(params);
19605
19727
  const current = activeCompaction;
19606
19728
  if (!current) return;
19607
- const completedAt = readNumber(params.completedAtMs ?? params.completed_at_ms) ?? now();
19729
+ const completedAt = readNumber2(params.completedAtMs ?? params.completed_at_ms) ?? now();
19608
19730
  const postTokens = currentUsage?.lastInputTokens;
19609
19731
  options.emit({
19610
19732
  type: "compact_boundary",
@@ -19619,7 +19741,7 @@ function createCodexAgentEventMapper(options) {
19619
19741
  if (completedTurnId) completedCompactionTurns.add(completedTurnId);
19620
19742
  activeCompaction = null;
19621
19743
  };
19622
- const fail2 = (error51, interrupted = false) => {
19744
+ const fail2 = (error51, interrupted = false, errorOverrides = {}) => {
19623
19745
  if (terminal) return;
19624
19746
  terminal = true;
19625
19747
  if (activeCompaction) {
@@ -19630,7 +19752,10 @@ function createCodexAgentEventMapper(options) {
19630
19752
  type: "message_error",
19631
19753
  messageId: options.messageId,
19632
19754
  error: error51,
19633
- errorInfo: buildAgentErrorInfo(error51, retriedErrors.length > 0 ? { retries: { attempts: retriedErrors.length } } : {})
19755
+ errorInfo: buildAgentErrorInfo(error51, {
19756
+ ...retriedErrors.length > 0 ? { retries: { attempts: retriedErrors.length } } : {},
19757
+ ...errorOverrides
19758
+ })
19634
19759
  });
19635
19760
  finishStatus();
19636
19761
  };
@@ -19660,7 +19785,7 @@ function createCodexAgentEventMapper(options) {
19660
19785
  const params = note.params;
19661
19786
  switch (note.method) {
19662
19787
  case "thread/started": {
19663
- const threadId = readString(asRecord(params.thread)?.id);
19788
+ const threadId = readString2(asRecord2(params.thread)?.id);
19664
19789
  if (threadId && threadId !== currentThreadId) {
19665
19790
  currentThreadId = threadId;
19666
19791
  options.emit({ type: "codex_thread_started", messageId: options.messageId, threadId });
@@ -19669,14 +19794,14 @@ function createCodexAgentEventMapper(options) {
19669
19794
  }
19670
19795
  case "item/started":
19671
19796
  case "item/completed": {
19672
- const raw = asRecord(params.item);
19797
+ const raw = asRecord2(params.item);
19673
19798
  if (!raw) break;
19674
- if (readString(raw.type) === "contextCompaction") {
19799
+ if (readString2(raw.type) === "contextCompaction") {
19675
19800
  if (note.method === "item/started") startCompaction(params);
19676
19801
  else completeCompaction(params);
19677
19802
  break;
19678
19803
  }
19679
- const previous = readString(raw.id) ? itemMap.get(readString(raw.id)) : void 0;
19804
+ const previous = readString2(raw.id) ? itemMap.get(readString2(raw.id)) : void 0;
19680
19805
  if (previous?.type === "plan" && note.method === "item/completed") {
19681
19806
  emitItem("completed", previous);
19682
19807
  break;
@@ -19694,14 +19819,26 @@ function createCodexAgentEventMapper(options) {
19694
19819
  case "item/agentMessage/delta":
19695
19820
  case "item/agentMessageDelta": {
19696
19821
  const delta = readCodexDeltaText(params);
19697
- result.textDelta = delta || null;
19698
19822
  const itemId = readCodexItemId(params);
19699
19823
  if (!itemId) break;
19700
19824
  const previous = itemMap.get(itemId);
19825
+ if (previous?.type !== "agent_message" || previous.delivery !== "async") {
19826
+ result.textDelta = delta || null;
19827
+ }
19701
19828
  emitItem("updated", {
19702
19829
  id: itemId,
19703
19830
  type: "agent_message",
19704
- 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."
19705
19842
  });
19706
19843
  break;
19707
19844
  }
@@ -19755,12 +19892,12 @@ function createCodexAgentEventMapper(options) {
19755
19892
  case "turn/plan/updated": {
19756
19893
  const rawPlan = Array.isArray(params.plan) ? params.plan : [];
19757
19894
  const todoItems = rawPlan.map((entry) => {
19758
- const step = asRecord(entry);
19759
- const text = readString(step?.step);
19760
- return text ? { text, completed: readString(step?.status) === "completed" } : null;
19895
+ const step = asRecord2(entry);
19896
+ const text = readString2(step?.step);
19897
+ return text ? { text, completed: readString2(step?.status) === "completed" } : null;
19761
19898
  }).filter((entry) => entry !== null);
19762
19899
  if (todoItems.length > 0) {
19763
- const turnId = readString(params.turnId) ?? readString(params.turn_id) ?? currentTurnId ?? "current";
19900
+ const turnId = readString2(params.turnId) ?? readString2(params.turn_id) ?? currentTurnId ?? "current";
19764
19901
  emitItem("updated", { id: `todo_${turnId}`, type: "todo_list", items: todoItems });
19765
19902
  }
19766
19903
  break;
@@ -19784,11 +19921,11 @@ function createCodexAgentEventMapper(options) {
19784
19921
  break;
19785
19922
  }
19786
19923
  case "mcpServer/startupStatus/updated": {
19787
- const name = readString(params.name);
19924
+ const name = readString2(params.name);
19788
19925
  if (!name) break;
19789
- const rawStatus = readString(params.status);
19926
+ const rawStatus = readString2(params.status);
19790
19927
  const status = rawStatus === "ready" || rawStatus === "failed" || rawStatus === "cancelled" ? rawStatus : "starting";
19791
- const failureReason = readString(params.failureReason) === "reauthenticationRequired" ? "reauthenticationRequired" : void 0;
19928
+ const failureReason = readString2(params.failureReason) === "reauthenticationRequired" ? "reauthenticationRequired" : void 0;
19792
19929
  mcpServers.set(name, { status, ...failureReason ? { failureReason } : {} });
19793
19930
  options.emit({
19794
19931
  type: "codex_mcp_startup",
@@ -19803,17 +19940,17 @@ function createCodexAgentEventMapper(options) {
19803
19940
  break;
19804
19941
  }
19805
19942
  result.error = extractError(params);
19806
- fail2(result.error);
19943
+ fail2(result.error, false, readCodexErrorOverrides(params));
19807
19944
  break;
19808
19945
  }
19809
19946
  case "turn/completed":
19810
19947
  case "turn/completed/v2": {
19811
- const turn = asRecord(params.turn);
19812
- currentTurnId = readString(turn?.id) ?? currentTurnId;
19813
- const status = readString(turn?.status) ?? readString(params.status) ?? "completed";
19948
+ const turn = asRecord2(params.turn);
19949
+ currentTurnId = readString2(turn?.id) ?? currentTurnId;
19950
+ const status = readString2(turn?.status) ?? readString2(params.status) ?? "completed";
19814
19951
  if (status === "failed" || status === "error") {
19815
19952
  result.error = extractError(turn?.error ?? params);
19816
- fail2(result.error);
19953
+ fail2(result.error, false, readCodexErrorOverrides(turn?.error ?? params));
19817
19954
  break;
19818
19955
  }
19819
19956
  if (status === "interrupted" || status === "cancelled") {
@@ -19866,6 +20003,7 @@ var init_agent_event_mapper = __esm({
19866
20003
  "../../packages/codex/src/agent-event-mapper.ts"() {
19867
20004
  "use strict";
19868
20005
  init_agent_error();
20006
+ init_protocol_v149();
19869
20007
  }
19870
20008
  });
19871
20009
 
@@ -20160,8 +20298,8 @@ async function ensureCodexThread(opts) {
20160
20298
  sandbox: "workspace-write",
20161
20299
  ...configPayload
20162
20300
  });
20163
- const thread = asRecord2(resumed.thread);
20164
- threadId = readString2(thread?.id) ?? readString2(resumed.id) ?? threadId;
20301
+ const thread = asRecord3(resumed.thread);
20302
+ threadId = readString3(thread?.id) ?? readString3(resumed.id) ?? threadId;
20165
20303
  } else {
20166
20304
  const started = await opts.client.request("thread/start", {
20167
20305
  cwd: opts.cwd,
@@ -20169,8 +20307,8 @@ async function ensureCodexThread(opts) {
20169
20307
  sandbox: "workspace-write",
20170
20308
  ...configPayload
20171
20309
  });
20172
- const thread = asRecord2(started.thread);
20173
- threadId = readString2(thread?.id) ?? readString2(started.id);
20310
+ const thread = asRecord3(started.thread);
20311
+ threadId = readString3(thread?.id) ?? readString3(started.id);
20174
20312
  }
20175
20313
  if (!threadId) {
20176
20314
  throw new Error("thread/start did not return a thread id");
@@ -20250,8 +20388,8 @@ async function runCodexAppServerTurn(opts) {
20250
20388
  sandboxPolicy: buildCodexWorkspaceWriteSandboxPolicy(opts.cwd, opts.additionalDirectories),
20251
20389
  ...collaborationMode ? { collaborationMode } : {}
20252
20390
  }));
20253
- const turn = asRecord2(turnStartResult.turn);
20254
- turnId = readString2(turn?.id);
20391
+ const turn = asRecord3(turnStartResult.turn);
20392
+ turnId = readString3(turn?.id);
20255
20393
  }
20256
20394
  let finalText = "";
20257
20395
  const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS;
@@ -20277,8 +20415,8 @@ async function runCodexAppServerTurn(opts) {
20277
20415
  continue;
20278
20416
  }
20279
20417
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
20280
- const completedTurn = asRecord2(note.params.turn);
20281
- const completedId = readString2(completedTurn?.id);
20418
+ const completedTurn = asRecord3(note.params.turn);
20419
+ const completedId = readString3(completedTurn?.id);
20282
20420
  if (turnId && completedId && completedId !== turnId) {
20283
20421
  continue;
20284
20422
  }
@@ -20293,8 +20431,8 @@ async function runCodexAppServerTurn(opts) {
20293
20431
  });
20294
20432
  }
20295
20433
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
20296
- const completedTurn = asRecord2(note.params.turn);
20297
- const status = readString2(completedTurn?.status) ?? readString2(note.params.status);
20434
+ const completedTurn = asRecord3(note.params.turn);
20435
+ const status = readString3(completedTurn?.status) ?? readString3(note.params.status);
20298
20436
  if (status === "failed" || status === "error") {
20299
20437
  throw new Error("Codex turn failed");
20300
20438
  }
@@ -20347,10 +20485,10 @@ function extractAgentTextFromTurn(turn) {
20347
20485
  let text = "";
20348
20486
  const items = Array.isArray(turn.items) ? turn.items : [];
20349
20487
  for (const item of items) {
20350
- const rec = asRecord2(item);
20488
+ const rec = asRecord3(item);
20351
20489
  if (!rec) continue;
20352
- if (readString2(rec.type) === "agentMessage" || readString2(rec.itemType) === "agentMessage") {
20353
- const t = readString2(rec.text);
20490
+ if (readString3(rec.type) === "agentMessage" || readString3(rec.itemType) === "agentMessage") {
20491
+ const t = readString3(rec.text);
20354
20492
  if (t) text += t;
20355
20493
  }
20356
20494
  }
@@ -20358,7 +20496,7 @@ function extractAgentTextFromTurn(turn) {
20358
20496
  }
20359
20497
  function applyAgentDelta(note, onDelta) {
20360
20498
  if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
20361
- const delta = readString2(note.params.delta) ?? readString2(note.params.text) ?? readString2(asRecord2(note.params.item)?.delta);
20499
+ const delta = readString3(note.params.delta) ?? readString3(note.params.text) ?? readString3(asRecord3(note.params.item)?.delta);
20362
20500
  if (delta) onDelta(delta);
20363
20501
  }
20364
20502
  }
@@ -20374,10 +20512,10 @@ function defaultSpawn(command, args, options) {
20374
20512
  windowsHide: options.windowsHide
20375
20513
  });
20376
20514
  }
20377
- function asRecord2(value) {
20515
+ function asRecord3(value) {
20378
20516
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
20379
20517
  }
20380
- function readString2(value) {
20518
+ function readString3(value) {
20381
20519
  return typeof value === "string" && value.length > 0 ? value : null;
20382
20520
  }
20383
20521
  var DEFAULT_REQUEST_TIMEOUT_MS, THREAD_TIMEOUT_MS, TURN_WAIT_TIMEOUT_MS, MAX_STDERR_CHARS;
@@ -20425,10 +20563,10 @@ function applySetAuth(current, request) {
20425
20563
  }
20426
20564
  return { mode, apiKey: normalizeApiKey(apiKey) };
20427
20565
  }
20428
- function asRecord3(value) {
20566
+ function asRecord4(value) {
20429
20567
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
20430
20568
  }
20431
- function readString3(value) {
20569
+ function readString4(value) {
20432
20570
  return typeof value === "string" && value.length > 0 ? value : null;
20433
20571
  }
20434
20572
  function readBoolean2(value) {
@@ -20449,25 +20587,25 @@ function parseAccountAuthMode(value) {
20449
20587
  }
20450
20588
  }
20451
20589
  function parseAccountStatus(raw) {
20452
- const account = asRecord3(raw.account);
20590
+ const account = asRecord4(raw.account);
20453
20591
  return {
20454
20592
  signedIn: account !== null,
20455
20593
  authMode: parseAccountAuthMode(account?.type),
20456
- email: readString3(account?.email),
20457
- planType: readString3(account?.planType),
20594
+ email: readString4(account?.email),
20595
+ planType: readString4(account?.planType),
20458
20596
  requiresOpenaiAuth: readBoolean2(raw.requiresOpenaiAuth) ?? false
20459
20597
  };
20460
20598
  }
20461
20599
  function parseAccountLoginStart(raw) {
20462
- const loginId = readString3(raw.loginId);
20463
- const type = readString3(raw.type);
20600
+ const loginId = readString4(raw.loginId);
20601
+ const type = readString4(raw.type);
20464
20602
  if (!loginId || type !== "chatgpt" && type !== "chatgptDeviceCode") {
20465
20603
  throw new Error("Codex returned an invalid account login response");
20466
20604
  }
20467
20605
  const result = { type, loginId };
20468
- const authUrl = readString3(raw.authUrl);
20469
- const verificationUrl = readString3(raw.verificationUrl);
20470
- const userCode = readString3(raw.userCode);
20606
+ const authUrl = readString4(raw.authUrl);
20607
+ const verificationUrl = readString4(raw.verificationUrl);
20608
+ const userCode = readString4(raw.userCode);
20471
20609
  if (authUrl) result.authUrl = authUrl;
20472
20610
  if (verificationUrl) result.verificationUrl = verificationUrl;
20473
20611
  if (userCode) result.userCode = userCode;
@@ -20499,15 +20637,15 @@ function parseRateLimitWindow(raw) {
20499
20637
  function parseResetCredit(raw) {
20500
20638
  if (!raw || typeof raw !== "object") return null;
20501
20639
  const rec = raw;
20502
- const id = readString3(rec.id);
20640
+ const id = readString4(rec.id);
20503
20641
  if (!id) return null;
20504
- const rawStatus = readString3(rec.status);
20642
+ const rawStatus = readString4(rec.status);
20505
20643
  const status = rawStatus === "available" || rawStatus === "redeeming" || rawStatus === "redeemed" ? rawStatus : "unknown";
20506
20644
  return {
20507
20645
  id,
20508
20646
  status,
20509
- title: readString3(rec.title) ?? null,
20510
- description: readString3(rec.description) ?? null,
20647
+ title: readString4(rec.title) ?? null,
20648
+ description: readString4(rec.description) ?? null,
20511
20649
  expiresAt: readNumericLike(rec.expiresAt)
20512
20650
  };
20513
20651
  }
@@ -20524,32 +20662,62 @@ function parseRateLimits(raw) {
20524
20662
  return {
20525
20663
  primary,
20526
20664
  secondary,
20527
- planType: readString3(snapshot.planType),
20665
+ planType: readString4(snapshot.planType),
20528
20666
  resetCredits,
20529
20667
  ...resetCreditList && resetCreditList.length > 0 ? { resetCreditList } : {}
20530
20668
  };
20531
20669
  }
20532
20670
  function parseAccountUsage(raw) {
20533
20671
  const summary = raw.summary && typeof raw.summary === "object" ? raw.summary : raw;
20672
+ const threadUsage = parseThreadUsage(raw.threadUsage);
20534
20673
  const usage2 = {
20535
20674
  lifetimeTokens: readNumericLike(summary.lifetimeTokens),
20536
20675
  peakDailyTokens: readNumericLike(summary.peakDailyTokens),
20537
20676
  longestRunningTurnSec: readNumericLike(summary.longestRunningTurnSec),
20538
20677
  currentStreakDays: readNumericLike(summary.currentStreakDays),
20539
- longestStreakDays: readNumericLike(summary.longestStreakDays)
20678
+ longestStreakDays: readNumericLike(summary.longestStreakDays),
20679
+ ...threadUsage ? { threadUsage } : {}
20540
20680
  };
20541
- const hasAny = Object.values(usage2).some((v2) => v2 !== null);
20681
+ const hasAny = Object.values(usage2).some((v2) => v2 !== null && v2 !== void 0);
20542
20682
  return hasAny ? usage2 : null;
20543
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
+ }
20544
20712
  function parseExternalAgentItem(raw) {
20545
20713
  if (!raw || typeof raw !== "object") return null;
20546
20714
  const rec = raw;
20547
- const itemType = readString3(rec.itemType);
20715
+ const itemType = readString4(rec.itemType);
20548
20716
  if (!itemType) return null;
20549
20717
  return {
20550
20718
  itemType,
20551
- description: readString3(rec.description) ?? "",
20552
- cwd: readString3(rec.cwd) ?? null,
20719
+ description: readString4(rec.description) ?? "",
20720
+ cwd: readString4(rec.cwd) ?? null,
20553
20721
  ...rec.details !== void 0 ? { details: rec.details } : {}
20554
20722
  };
20555
20723
  }
@@ -20604,16 +20772,16 @@ async function logoutAccount(client3) {
20604
20772
  throw safePublicError("account/logout failed", err);
20605
20773
  }
20606
20774
  }
20607
- async function readAccountUsage(client3) {
20775
+ async function readAccountUsage(client3, threadId) {
20608
20776
  try {
20609
- const result = await client3.request("account/usage/read");
20777
+ const result = await client3.request("account/usage/read", threadId ? { threadId } : {});
20610
20778
  return parseAccountUsage(result);
20611
20779
  } catch (err) {
20612
20780
  throw safePublicError("account/usage/read failed", err);
20613
20781
  }
20614
20782
  }
20615
20783
  function parseResetOutcome(raw) {
20616
- switch (readString3(raw.outcome)) {
20784
+ switch (readString4(raw.outcome)) {
20617
20785
  case "reset":
20618
20786
  return "reset";
20619
20787
  case "nothingToReset":
@@ -20637,20 +20805,27 @@ async function consumeRateLimitReset(client3, creditId) {
20637
20805
  throw safePublicError("account/rateLimitResetCredit/consume failed", err);
20638
20806
  }
20639
20807
  }
20640
- async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e4) {
20808
+ async function loginMcpServerOauth(client3, serverName, openUrl, timeoutMs = 18e4, options) {
20641
20809
  try {
20642
- const res = await client3.request("mcpServer/oauth/login", { name: serverName });
20643
- const authorizationUrl = readString3(res.authorizationUrl);
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);
20644
20818
  if (!authorizationUrl) return { success: false, error: "Codex returned no authorization URL" };
20645
20819
  openUrl?.(authorizationUrl);
20646
- const deadline = Date.now() + timeoutMs;
20820
+ const effectiveTimeoutMs = typeof options?.timeoutSecs === "number" && options.timeoutSecs > 0 ? options.timeoutSecs * 1e3 : timeoutMs;
20821
+ const deadline = Date.now() + effectiveTimeoutMs;
20647
20822
  while (Date.now() < deadline) {
20648
20823
  const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
20649
20824
  if (!notif) continue;
20650
- if (notif.method === "mcpServer/oauthLogin/completed" && readString3(notif.params.name) === serverName) {
20825
+ if (notif.method === "mcpServer/oauthLogin/completed" && readString4(notif.params.name) === serverName && (!options?.threadId || readString4(notif.params.threadId) === options.threadId)) {
20651
20826
  return {
20652
20827
  success: readBoolean2(notif.params.success) ?? false,
20653
- error: readString3(notif.params.error) ?? void 0,
20828
+ error: readString4(notif.params.error) ?? void 0,
20654
20829
  authorizationUrl
20655
20830
  };
20656
20831
  }
@@ -20686,12 +20861,12 @@ async function importExternalAgentConfig(client3, items, timeoutMs = 12e4) {
20686
20861
  migrationItems: items,
20687
20862
  source: "superone"
20688
20863
  });
20689
- const importId = readString3(res.importId);
20864
+ const importId = readString4(res.importId);
20690
20865
  const deadline = Date.now() + timeoutMs;
20691
20866
  while (Date.now() < deadline) {
20692
20867
  const notif = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
20693
20868
  if (!notif) continue;
20694
- if (notif.method === "externalAgentConfig/import/completed" && (!importId || readString3(notif.params.importId) === importId)) {
20869
+ if (notif.method === "externalAgentConfig/import/completed" && (!importId || readString4(notif.params.importId) === importId)) {
20695
20870
  return summarizeImportResults(notif.params.itemTypeResults);
20696
20871
  }
20697
20872
  }
@@ -20708,19 +20883,19 @@ async function listPluginInventory(client3, projectPath) {
20708
20883
  const marketplaces = Array.isArray(result.marketplaces) ? result.marketplaces : [];
20709
20884
  const records = [];
20710
20885
  for (const rawMarketplace of marketplaces) {
20711
- const marketplace = asRecord3(rawMarketplace);
20886
+ const marketplace = asRecord4(rawMarketplace);
20712
20887
  if (!marketplace) continue;
20713
- const marketplaceName = readString3(marketplace.name);
20714
- const marketplacePath = readString3(marketplace.path);
20888
+ const marketplaceName = readString4(marketplace.name);
20889
+ const marketplacePath = readString4(marketplace.path);
20715
20890
  if (!marketplaceName || !marketplacePath) continue;
20716
20891
  const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
20717
20892
  for (const rawPlugin of plugins) {
20718
- const plugin = asRecord3(rawPlugin);
20893
+ const plugin = asRecord4(rawPlugin);
20719
20894
  if (!plugin) continue;
20720
- const key = readString3(plugin.id);
20721
- const name = readString3(plugin.name);
20722
- const source = asRecord3(plugin.source);
20723
- const sourcePath = readString3(source?.path) ?? void 0;
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;
20724
20899
  if (!key || !name) continue;
20725
20900
  records.push({
20726
20901
  key,
@@ -20750,8 +20925,8 @@ async function marketplaceAdd(client3, request) {
20750
20925
  sparsePaths: request.sparsePaths && request.sparsePaths.length > 0 ? request.sparsePaths : void 0
20751
20926
  }));
20752
20927
  return {
20753
- marketplaceName: readString3(result.marketplaceName) ?? "",
20754
- installedRoot: readString3(result.installedRoot) ?? "",
20928
+ marketplaceName: readString4(result.marketplaceName) ?? "",
20929
+ installedRoot: readString4(result.installedRoot) ?? "",
20755
20930
  alreadyAdded: readBoolean2(result.alreadyAdded) ?? false
20756
20931
  };
20757
20932
  }
@@ -20767,10 +20942,10 @@ async function marketplaceUpgrade(client3, marketplaceName) {
20767
20942
  name ? { marketplaceName: name } : {}
20768
20943
  );
20769
20944
  const errors = Array.isArray(result.errors) ? result.errors.map((raw) => {
20770
- const rec = asRecord3(raw);
20945
+ const rec = asRecord4(raw);
20771
20946
  if (!rec) return null;
20772
- const marketplaceName2 = readString3(rec.marketplaceName) ?? readString3(rec.name);
20773
- const message = readString3(rec.message) ?? readString3(rec.error);
20947
+ const marketplaceName2 = readString4(rec.marketplaceName) ?? readString4(rec.name);
20948
+ const message = readString4(rec.message) ?? readString4(rec.error);
20774
20949
  if (!marketplaceName2 || !message) return null;
20775
20950
  return { marketplaceName: marketplaceName2, message };
20776
20951
  }).filter((e) => e !== null) : [];
@@ -20830,6 +21005,7 @@ var init_src = __esm({
20830
21005
  init_codex_admin();
20831
21006
  init_fork_thread();
20832
21007
  init_agent_event_mapper();
21008
+ init_protocol_v149();
20833
21009
  }
20834
21010
  });
20835
21011
 
@@ -20917,6 +21093,8 @@ var init_superone_host_owned_tools = __esm({
20917
21093
  )
20918
21094
  ];
20919
21095
  DEVICE_AGENT_TOOL_NAMES = [
21096
+ "device_list",
21097
+ "device_request_control",
20920
21098
  "device_snapshot",
20921
21099
  "device_query",
20922
21100
  "device_act",
@@ -20968,7 +21146,7 @@ var init_superone_host_owned_tools = __esm({
20968
21146
  });
20969
21147
 
20970
21148
  // ../../packages/claude/src/map-sdk-message.ts
20971
- function asRecord4(value) {
21149
+ function asRecord5(value) {
20972
21150
  if (value && typeof value === "object" && !Array.isArray(value)) {
20973
21151
  return value;
20974
21152
  }
@@ -21010,11 +21188,11 @@ function applySdkMessage(message, state, emit) {
21010
21188
  const sessionId = sessionIdOf(record2);
21011
21189
  const parentToolUseId = typeof record2.parent_tool_use_id === "string" ? record2.parent_tool_use_id : null;
21012
21190
  if (record2.type === "stream_event") {
21013
- const event = asRecord4(record2.event);
21191
+ const event = asRecord5(record2.event);
21014
21192
  if (!event) return emptyApply(sessionId);
21015
21193
  const index = typeof event.index === "number" ? event.index : null;
21016
21194
  if (event.type === "content_block_start") {
21017
- const block = asRecord4(event.content_block);
21195
+ const block = asRecord5(event.content_block);
21018
21196
  if (!block) return emptyApply(sessionId);
21019
21197
  if (block.type === "text" && index != null) {
21020
21198
  state.indexToKind.set(index, "text");
@@ -21046,7 +21224,7 @@ function applySdkMessage(message, state, emit) {
21046
21224
  return emptyApply(sessionId);
21047
21225
  }
21048
21226
  if (event.type === "content_block_delta") {
21049
- const delta = asRecord4(event.delta);
21227
+ const delta = asRecord5(event.delta);
21050
21228
  if (!delta) return emptyApply(sessionId);
21051
21229
  if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
21052
21230
  return {
@@ -21080,10 +21258,10 @@ function applySdkMessage(message, state, emit) {
21080
21258
  return emptyApply(sessionId);
21081
21259
  }
21082
21260
  if (record2.type === "assistant") {
21083
- const messageBody = asRecord4(record2.message);
21261
+ const messageBody = asRecord5(record2.message);
21084
21262
  const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
21085
21263
  for (const raw of content) {
21086
- const block = asRecord4(raw);
21264
+ const block = asRecord5(raw);
21087
21265
  if (!block || block.type !== "tool_use") continue;
21088
21266
  const toolUseId = typeof block.id === "string" && block.id.length > 0 ? block.id : null;
21089
21267
  const toolName = typeof block.name === "string" && block.name.length > 0 ? block.name : "unknown";
@@ -21110,10 +21288,10 @@ function applySdkMessage(message, state, emit) {
21110
21288
  return emptyApply(sessionId);
21111
21289
  }
21112
21290
  if (record2.type === "user") {
21113
- const messageBody = asRecord4(record2.message);
21291
+ const messageBody = asRecord5(record2.message);
21114
21292
  const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
21115
21293
  for (const raw of content) {
21116
- const block = asRecord4(raw);
21294
+ const block = asRecord5(raw);
21117
21295
  if (!block || block.type !== "tool_result") continue;
21118
21296
  const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : typeof block.toolUseId === "string" ? block.toolUseId : null;
21119
21297
  if (!toolUseId) continue;
@@ -22004,7 +22182,7 @@ var init_ask_user_question = __esm({
22004
22182
  });
22005
22183
 
22006
22184
  // ../../packages/claude/src/ask-user-question-bridge.ts
22007
- function asRecord5(value) {
22185
+ function asRecord6(value) {
22008
22186
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
22009
22187
  }
22010
22188
  async function resolveAskUserQuestion(params) {
@@ -22013,7 +22191,7 @@ async function resolveAskUserQuestion(params) {
22013
22191
  return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
22014
22192
  }
22015
22193
  const previewFormat = asQuestionPreviewFormat(params.previewFormat);
22016
- const rawInput = asRecord5(input);
22194
+ const rawInput = asRecord6(input);
22017
22195
  const baseInput = rawInput ? { ...rawInput, ...previewFormat ? { previewFormat } : {} } : null;
22018
22196
  const answer = await onQuestion({
22019
22197
  interactionId,
@@ -22022,9 +22200,9 @@ async function resolveAskUserQuestion(params) {
22022
22200
  toolUseId,
22023
22201
  input: baseInput ?? void 0
22024
22202
  });
22025
- const record2 = asRecord5(answer);
22203
+ const record2 = asRecord6(answer);
22026
22204
  const answers = record2 && "answers" in record2 ? record2.answers : answer;
22027
- const answerMap = asRecord5(answers);
22205
+ const answerMap = asRecord6(answers);
22028
22206
  const updatedInput = {
22029
22207
  ...baseInput,
22030
22208
  ...buildAnsweredQuestionInput({
@@ -22813,7 +22991,7 @@ var init_content_delta = __esm({
22813
22991
  });
22814
22992
 
22815
22993
  // ../../packages/shared/src/node-session-event-map.ts
22816
- function asRecord6(value) {
22994
+ function asRecord7(value) {
22817
22995
  if (value && typeof value === "object" && !Array.isArray(value)) {
22818
22996
  return value;
22819
22997
  }
@@ -22845,7 +23023,7 @@ function stamp(event, ctx, sequence) {
22845
23023
  }
22846
23024
  function mapQuestionRequest(payload, fallbackId) {
22847
23025
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
22848
- const input = asRecord6(payload.input);
23026
+ const input = asRecord7(payload.input);
22849
23027
  const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
22850
23028
  const questions = [];
22851
23029
  for (const q of rawQuestions) {
@@ -22884,7 +23062,7 @@ function mapQuestionRequest(payload, fallbackId) {
22884
23062
  }
22885
23063
  function mapPlanRequest(payload, fallbackId) {
22886
23064
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
22887
- const input = asRecord6(payload.input);
23065
+ const input = asRecord7(payload.input);
22888
23066
  let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
22889
23067
  if (!planContent && input.plan && typeof input.plan === "object") {
22890
23068
  try {
@@ -22950,7 +23128,7 @@ function createNodeSessionEventMapper(ctx) {
22950
23128
  if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
22951
23129
  if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
22952
23130
  const eventType = envelope.eventType;
22953
- const payload = asRecord6(envelope.payload);
23131
+ const payload = asRecord7(envelope.payload);
22954
23132
  const out = [];
22955
23133
  const push = (event) => {
22956
23134
  out.push(stamp(event, ctx, envelope.sequence));
@@ -22976,7 +23154,7 @@ function createNodeSessionEventMapper(ctx) {
22976
23154
  break;
22977
23155
  }
22978
23156
  case SESSION_DURABLE_EVENT.agentEvent: {
22979
- const rawEvent = asRecord6(payload.event);
23157
+ const rawEvent = asRecord7(payload.event);
22980
23158
  const type = asString2(rawEvent.type);
22981
23159
  if (!type) break;
22982
23160
  const eventRecord = { ...rawEvent };
@@ -22986,7 +23164,7 @@ function createNodeSessionEventMapper(ctx) {
22986
23164
  delete eventRecord.seq;
22987
23165
  delete eventRecord.epoch;
22988
23166
  const event = eventRecord;
22989
- const rawMessageId = type === "message_start" ? asString2(asRecord6(eventRecord.message).id) : asString2(eventRecord.messageId);
23167
+ const rawMessageId = type === "message_start" ? asString2(asRecord7(eventRecord.message).id) : asString2(eventRecord.messageId);
22990
23168
  if (type === "message_start" && rawMessageId) {
22991
23169
  startedAssistantIds.add(rawMessageId);
22992
23170
  lastAssistantId = rawMessageId;
@@ -23164,7 +23342,7 @@ function createNodeSessionEventMapper(ctx) {
23164
23342
  requestId: interactionId,
23165
23343
  toolName,
23166
23344
  toolUseId: asString2(payload.toolUseId),
23167
- input: asRecord6(payload.input),
23345
+ input: asRecord7(payload.input),
23168
23346
  allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
23169
23347
  ...requestKind ? {
23170
23348
  requestKind
@@ -23269,7 +23447,7 @@ var init_node_session_event_map = __esm({
23269
23447
  });
23270
23448
 
23271
23449
  // ../../packages/runtime/src/session/message-catalog.ts
23272
- function asRecord7(value) {
23450
+ function asRecord8(value) {
23273
23451
  if (value && typeof value === "object" && !Array.isArray(value)) {
23274
23452
  return value;
23275
23453
  }
@@ -23352,7 +23530,7 @@ function collectToolsByAssistantId(events, sessionId) {
23352
23530
  for (const ev of events) {
23353
23531
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
23354
23532
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
23355
- const payload = asRecord7(ev.payload);
23533
+ const payload = asRecord8(ev.payload);
23356
23534
  switch (ev.eventType) {
23357
23535
  case SESSION_DURABLE_EVENT.turnStarted: {
23358
23536
  turnKey += 1;
@@ -23378,10 +23556,10 @@ function collectToolsByAssistantId(events, sessionId) {
23378
23556
  break;
23379
23557
  }
23380
23558
  case SESSION_DURABLE_EVENT.agentEvent: {
23381
- const raw = asRecord7(payload.event);
23559
+ const raw = asRecord8(payload.event);
23382
23560
  const type = asString3(raw.type);
23383
23561
  if (type === "message_start") {
23384
- const id = asString3(asRecord7(raw.message).id);
23562
+ const id = asString3(asRecord8(raw.message).id);
23385
23563
  if (id) bindAssistant(id);
23386
23564
  } else if (type === "message_complete") {
23387
23565
  const id = asString3(raw.messageId);
@@ -23389,7 +23567,7 @@ function collectToolsByAssistantId(events, sessionId) {
23389
23567
  } else if (type === "content_delta") {
23390
23568
  const messageId = asString3(raw.messageId);
23391
23569
  if (messageId) bindAssistant(messageId);
23392
- const delta = asRecord7(raw.delta);
23570
+ const delta = asRecord8(raw.delta);
23393
23571
  const dType = asString3(delta.type);
23394
23572
  if (dType === "tool_use") {
23395
23573
  const toolUseId = asString3(delta.toolUseId);
@@ -23532,7 +23710,7 @@ function collectContentByAssistantId(events, sessionId) {
23532
23710
  if (changed) contentById.set(ev.messageId, next);
23533
23711
  }
23534
23712
  }
23535
- const payload = asRecord7(envelope.payload);
23713
+ const payload = asRecord8(envelope.payload);
23536
23714
  if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
23537
23715
  const blockId = asString3(payload.blockId);
23538
23716
  const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
@@ -23556,7 +23734,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
23556
23734
  const ev = events[i];
23557
23735
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
23558
23736
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
23559
- const payload = asRecord7(ev.payload);
23737
+ const payload = asRecord8(ev.payload);
23560
23738
  if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
23561
23739
  if (asString3(payload.blockId) !== blockId) continue;
23562
23740
  const checkpointId = asString3(payload.checkpointId);
@@ -23571,7 +23749,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
23571
23749
  }
23572
23750
  }
23573
23751
  if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
23574
- const raw = asRecord7(payload.event);
23752
+ const raw = asRecord8(payload.event);
23575
23753
  if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
23576
23754
  continue;
23577
23755
  }
@@ -24955,10 +25133,7 @@ var init_session_runtime = __esm({
24955
25133
  if (typeof stored === "string" && stored.trim()) return stored.trim();
24956
25134
  return stored ?? void 0;
24957
25135
  };
24958
- let turnKind = input.turnKind ?? null;
24959
- if (!turnKind && session.status === "streaming" && (session.harnessId || "claude") === "codex") {
24960
- turnKind = "steer";
24961
- }
25136
+ const turnKind = input.turnKind ?? null;
24962
25137
  const turnOpts = {
24963
25138
  text: input.text,
24964
25139
  requestId: input.requestId,
@@ -24978,11 +25153,8 @@ var init_session_runtime = __esm({
24978
25153
  this.appendUserMessage(session, turnOpts);
24979
25154
  if (session.status === "streaming") {
24980
25155
  const harnessId = session.harnessId || "claude";
24981
- const liveInject = harnessId === "claude" || harnessId === "codex" && (turnOpts.turnKind === "steer" || turnOpts.turnKind === "run");
25156
+ const liveInject = harnessId === "claude" || harnessId === "codex" && turnOpts.turnKind === "steer";
24982
25157
  if (liveInject) {
24983
- if (harnessId === "codex" && turnOpts.turnKind === "run") {
24984
- turnOpts.turnKind = "steer";
24985
- }
24986
25158
  this.beginTurn(session, turnOpts);
24987
25159
  return this.clone(session);
24988
25160
  }
@@ -50395,6 +50567,79 @@ var init_slash_filter = __esm({
50395
50567
  }
50396
50568
  });
50397
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
+
50398
50643
  // ../../packages/shared/src/tool-ui.ts
50399
50644
  function normalizeToolIdKey(id) {
50400
50645
  return id.trim().toLowerCase().replace(/[\s-]+/g, "_");
@@ -50417,6 +50662,23 @@ function uiToolNameFromId(id) {
50417
50662
  const key = normalizeToolIdKey(id);
50418
50663
  return TOOL_ID_TO_UI_NAME[key] ?? null;
50419
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
+ }
50420
50682
  function normalizeTranscriptTool(rawName, rawInput) {
50421
50683
  const envelopeId = typeof rawInput.tool_name === "string" ? rawInput.tool_name : "";
50422
50684
  const isUseTool = normalizeToolIdKey(rawName) === "use_tool" || rawInput.variant === "UseTool";
@@ -50726,10 +50988,11 @@ function formatTranscriptToolResult(content, opts) {
50726
50988
  const max = opts?.maxChars ?? MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
50727
50989
  return truncateTranscriptToolResult(formatted, max);
50728
50990
  }
50729
- 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;
50730
50992
  var init_tool_ui = __esm({
50731
50993
  "../../packages/shared/src/tool-ui.ts"() {
50732
50994
  "use strict";
50995
+ init_partial_json();
50733
50996
  TOOL_ID_TO_UI_NAME = {
50734
50997
  read: "Read",
50735
50998
  read_file: "Read",
@@ -50738,6 +51001,8 @@ var init_tool_ui = __esm({
50738
51001
  search_replace: "Edit",
50739
51002
  str_replace: "Edit",
50740
51003
  apply_patch: "Edit",
51004
+ hashline_edit: "Edit",
51005
+ hashlineedit: "Edit",
50741
51006
  write: "Write",
50742
51007
  write_file: "Write",
50743
51008
  writefile: "Write",
@@ -50764,6 +51029,8 @@ var init_tool_ui = __esm({
50764
51029
  open_page_with_find: "WebFetch",
50765
51030
  web_search: "WebSearch",
50766
51031
  websearch: "WebSearch",
51032
+ x_search: "XSearch",
51033
+ xsearch: "XSearch",
50767
51034
  todo_write: "TodoWrite",
50768
51035
  todowrite: "TodoWrite",
50769
51036
  todo: "TodoWrite",
@@ -50783,16 +51050,21 @@ var init_tool_ui = __esm({
50783
51050
  memory_search: "MemorySearch",
50784
51051
  memorysearch: "MemorySearch",
50785
51052
  search_memory: "MemorySearch",
51053
+ memory_get: "MemoryGet",
51054
+ memoryget: "MemoryGet",
50786
51055
  ask_user_question: "AskUserQuestion",
50787
51056
  askuserquestion: "AskUserQuestion",
50788
51057
  get_task_output: "TaskOutput",
50789
51058
  get_command_or_subagent_output: "TaskOutput",
50790
51059
  get_terminal_command_output: "TaskOutput",
51060
+ get_task_or_subagent_output: "TaskOutput",
50791
51061
  wait_tasks: "TaskOutput",
50792
51062
  wait_commands_or_subagents: "TaskOutput",
51063
+ wait_tasks_or_subagents: "TaskOutput",
50793
51064
  kill_task: "KillTask",
50794
51065
  kill_command_or_subagent: "KillTask",
50795
51066
  kill_terminal_command: "KillTask",
51067
+ kill_task_or_subagent: "KillTask",
50796
51068
  enter_plan_mode: "EnterPlanMode",
50797
51069
  exit_plan_mode: "ExitPlanMode",
50798
51070
  skill: "Skill",
@@ -50805,10 +51077,31 @@ var init_tool_ui = __esm({
50805
51077
  update_goal: "UpdateGoal",
50806
51078
  scheduler_create: "SchedulerCreate",
50807
51079
  scheduler_delete: "SchedulerDelete",
50808
- scheduler_list: "SchedulerList"
51080
+ scheduler_list: "SchedulerList",
51081
+ deploy_app: "DeployApp",
51082
+ deployapp: "DeployApp",
51083
+ lsp: "Lsp",
51084
+ report_findings: "ReportFindings",
51085
+ reportfindings: "ReportFindings"
50809
51086
  };
50810
51087
  GENERIC_SUBAGENT_TYPES = /* @__PURE__ */ new Set(["general-purpose", "general"]);
50811
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
+ ]);
50812
51105
  MAX_TRANSCRIPT_TOOL_RESULT_CHARS = 48e3;
50813
51106
  }
50814
51107
  });
@@ -50828,7 +51121,7 @@ function toolInputJson(raw) {
50828
51121
  return "{}";
50829
51122
  }
50830
51123
  }
50831
- function asRecord8(raw) {
51124
+ function asRecord9(raw) {
50832
51125
  if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
50833
51126
  return {};
50834
51127
  }
@@ -50903,6 +51196,11 @@ function nameFromVariant(raw) {
50903
51196
  if (variant === "ExitPlanMode") return "ExitPlanMode";
50904
51197
  if (variant === "KillTask") return "KillTask";
50905
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";
50906
51204
  }
50907
51205
  if (Array.isArray(raw.questions) && raw.questions.length > 0) return "AskUserQuestion";
50908
51206
  if (Array.isArray(raw.task_ids) || raw.task_id != null || raw.taskId != null) {
@@ -50967,7 +51265,7 @@ function grokMetaInput(tool) {
50967
51265
  const xai = meta3["x.ai/tool"];
50968
51266
  if (!xai || typeof xai !== "object") return {};
50969
51267
  const input = xai.input;
50970
- return asRecord8(input);
51268
+ return asRecord9(input);
50971
51269
  }
50972
51270
  function queryFromWebSearchTitle(title) {
50973
51271
  if (!title) return void 0;
@@ -51223,17 +51521,21 @@ function normalizeInput(toolName, kind, raw, filePath, diffs, terminalCommand) {
51223
51521
  return { ...raw };
51224
51522
  }
51225
51523
  }
51524
+ function isUseToolEnvelope(tool, raw) {
51525
+ return nameFromGrokMeta(tool) === "UseTool" || raw.variant === "UseTool" || uiToolNameFromId(typeof tool.title === "string" ? tool.title : null) === "UseTool";
51526
+ }
51226
51527
  function unwrapMcpEnvelope(tool, raw) {
51227
- const isEnvelope = nameFromGrokMeta(tool) === "UseTool" || raw.variant === "UseTool";
51228
- if (!isEnvelope) return null;
51528
+ if (!isUseToolEnvelope(tool, raw)) return null;
51229
51529
  const id = raw.tool_name;
51230
51530
  if (typeof id !== "string" || !id.includes("__")) return null;
51231
- return { toolName: `mcp__${id}`, input: asRecord8(raw.tool_input) };
51531
+ return { toolName: `mcp__${id}`, input: asRecord9(raw.tool_input) };
51232
51532
  }
51233
51533
  function normalizeAcpTool(tool, opts) {
51234
- const raw = { ...grokMetaInput(tool), ...asRecord8(tool.rawInput) };
51235
- const mcp = unwrapMcpEnvelope(tool, asRecord8(tool.rawInput));
51534
+ const raw = { ...grokMetaInput(tool), ...asRecord9(tool.rawInput) };
51535
+ const rawInput = asRecord9(tool.rawInput);
51536
+ const mcp = unwrapMcpEnvelope(tool, rawInput);
51236
51537
  if (mcp) return mcp;
51538
+ if (isUseToolEnvelope(tool, rawInput) && typeof rawInput.tool_name !== "string") return null;
51237
51539
  const diffs = extractDiffs(tool.content);
51238
51540
  const terminalId = extractEmbeddedTerminalId(tool.content);
51239
51541
  const toolName = resolveToolName(tool, raw, diffs, !!terminalId);
@@ -51468,6 +51770,7 @@ function skipEventSeqDedup(kind) {
51468
51770
  function createXaiCorrelationState(opts) {
51469
51771
  return {
51470
51772
  ...opts?.cwd ? { cwd: opts.cwd } : {},
51773
+ ...opts?.parentSessionId ? { parentSessionId: opts.parentSessionId } : {},
51471
51774
  workflowToolByRunId: /* @__PURE__ */ new Map(),
51472
51775
  workflowRevision: /* @__PURE__ */ new Map(),
51473
51776
  workflowStarted: /* @__PURE__ */ new Set(),
@@ -51479,6 +51782,9 @@ function createXaiCorrelationState(opts) {
51479
51782
  subagentStarted: /* @__PURE__ */ new Set(),
51480
51783
  deferredSubagentFinishes: /* @__PURE__ */ new Map(),
51481
51784
  deltaToolStarted: /* @__PURE__ */ new Set(),
51785
+ deltaToolWireName: /* @__PURE__ */ new Map(),
51786
+ deltaToolArgs: /* @__PURE__ */ new Map(),
51787
+ deltaToolIdByIndex: /* @__PURE__ */ new Map(),
51482
51788
  bgTaskById: /* @__PURE__ */ new Map(),
51483
51789
  goalStarted: /* @__PURE__ */ new Set(),
51484
51790
  lastEventSeq: null,
@@ -51523,7 +51829,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
51523
51829
  });
51524
51830
  }
51525
51831
  }
51526
- function asRecord9(v2) {
51832
+ function asRecord10(v2) {
51527
51833
  if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return null;
51528
51834
  return v2;
51529
51835
  }
@@ -51556,18 +51862,18 @@ function arrField(o, ...keys) {
51556
51862
  return void 0;
51557
51863
  }
51558
51864
  function parseXaiSessionNotificationEnvelope(raw) {
51559
- const o = asRecord9(raw);
51865
+ const o = asRecord10(raw);
51560
51866
  if (!o) return null;
51561
- const update = asRecord9(o.update);
51867
+ const update = asRecord10(o.update);
51562
51868
  if (!update) return null;
51563
51869
  const sessionId = strField(o, "sessionId", "session_id");
51564
- const meta3 = asRecord9(o._meta) ?? asRecord9(o.meta);
51870
+ const meta3 = asRecord10(o._meta) ?? asRecord10(o.meta);
51565
51871
  const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
51566
51872
  const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
51567
51873
  return { sessionId, update, meta: meta3, eventSeq, eventId };
51568
51874
  }
51569
51875
  function parseXaiExtParams(raw) {
51570
- return asRecord9(raw) ?? {};
51876
+ return asRecord10(raw) ?? {};
51571
51877
  }
51572
51878
  function parsePlainTextTaskAck(text) {
51573
51879
  const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
@@ -51672,13 +51978,13 @@ function tryParseJsonObject(text) {
51672
51978
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
51673
51979
  try {
51674
51980
  const v2 = JSON.parse(trimmed);
51675
- return asRecord9(v2);
51981
+ return asRecord10(v2);
51676
51982
  } catch {
51677
51983
  const start = trimmed.indexOf("{");
51678
51984
  const end = trimmed.lastIndexOf("}");
51679
51985
  if (start < 0 || end <= start) return null;
51680
51986
  try {
51681
- return asRecord9(JSON.parse(trimmed.slice(start, end + 1)));
51987
+ return asRecord10(JSON.parse(trimmed.slice(start, end + 1)));
51682
51988
  } catch {
51683
51989
  return null;
51684
51990
  }
@@ -51801,6 +52107,9 @@ function mapXaiStandaloneNotification(method, params, state, ctx = {}) {
51801
52107
  log.debug("[acp-xai] bad session_notification envelope");
51802
52108
  return [];
51803
52109
  }
52110
+ if (env.sessionId && state.parentSessionId && env.sessionId !== state.parentSessionId) {
52111
+ return [];
52112
+ }
51804
52113
  const kind = strField(env.update, "sessionUpdate", "session_update");
51805
52114
  if (!skipEventSeqDedup(kind) && env.eventSeq != null) {
51806
52115
  if (state.lastEventSeq != null && env.eventSeq <= state.lastEventSeq) {
@@ -51916,7 +52225,7 @@ function mapWorkflowPhases(raw) {
51916
52225
  if (!raw?.length) return [];
51917
52226
  const out = [];
51918
52227
  for (const item of raw) {
51919
- const p2 = asRecord9(item);
52228
+ const p2 = asRecord10(item);
51920
52229
  if (!p2) continue;
51921
52230
  const title = strField(p2, "title");
51922
52231
  if (!title) continue;
@@ -51934,7 +52243,7 @@ function mapWorkflowAgents(raw) {
51934
52243
  if (!raw?.length) return [];
51935
52244
  const out = [];
51936
52245
  for (const item of raw) {
51937
- const a = asRecord9(item);
52246
+ const a = asRecord10(item);
51938
52247
  if (!a) continue;
51939
52248
  const agentId = strField(a, "agent_id", "agentId");
51940
52249
  const label = strField(a, "label") ?? agentId ?? "agent";
@@ -51960,7 +52269,7 @@ function buildWorkflowPhaseSummary(u, currentPhase, pauseMessage, lastEvent, las
51960
52269
  const phaseBits = [];
51961
52270
  if (phases?.length) {
51962
52271
  for (const p2 of phases) {
51963
- const ph = asRecord9(p2);
52272
+ const ph = asRecord10(p2);
51964
52273
  if (!ph) continue;
51965
52274
  const title = strField(ph, "title") ?? "?";
51966
52275
  const state = strField(ph, "state") ?? "";
@@ -52108,7 +52417,7 @@ function mapTaskBackgrounded(u, state) {
52108
52417
  }];
52109
52418
  }
52110
52419
  function mapTaskCompleted(u, state) {
52111
- const snapshot = asRecord9(u.task_snapshot) ?? asRecord9(u.taskSnapshot) ?? u;
52420
+ const snapshot = asRecord10(u.task_snapshot) ?? asRecord10(u.taskSnapshot) ?? u;
52112
52421
  const taskId = strField(snapshot, "task_id", "taskId");
52113
52422
  if (!taskId) return [];
52114
52423
  const known = state.bgTaskById.get(taskId);
@@ -52296,13 +52605,21 @@ function mapScheduledTaskDeleted(u, _state) {
52296
52605
  function mapToolCallDeltaChunk(u, state, ctx) {
52297
52606
  const toolCallId = strField(u, "tool_call_id", "toolCallId");
52298
52607
  const index = numField(u, "tool_index", "toolIndex");
52299
- const id = toolCallId ?? (index != null ? `acp_delta_${index}` : null);
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);
52300
52610
  const messageId = ctx.messageId ?? state.lastMessageId;
52301
52611
  if (!id || !messageId) return [];
52302
52612
  const name = strField(u, "name");
52303
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
+ );
52304
52620
  const events = [];
52305
- if (name && !state.deltaToolStarted.has(id)) {
52621
+ const hidden = resolved ? isAlwaysHiddenToolName(resolved) : false;
52622
+ if (resolved && !hidden && !state.deltaToolStarted.has(id)) {
52306
52623
  state.deltaToolStarted.add(id);
52307
52624
  events.push({
52308
52625
  type: "content_delta",
@@ -52310,13 +52627,22 @@ function mapToolCallDeltaChunk(u, state, ctx) {
52310
52627
  delta: {
52311
52628
  type: "tool_use",
52312
52629
  toolUseId: id,
52313
- toolName: name,
52630
+ toolName: resolved,
52314
52631
  input: "",
52315
52632
  status: "streaming"
52316
52633
  }
52317
52634
  });
52318
- }
52319
- if (delta) {
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)) {
52320
52646
  events.push({
52321
52647
  type: "tool_input_delta",
52322
52648
  messageId,
@@ -52324,6 +52650,9 @@ function mapToolCallDeltaChunk(u, state, ctx) {
52324
52650
  partialJson: delta
52325
52651
  });
52326
52652
  }
52653
+ if (resolved && hidden && resolved !== "UseTool") {
52654
+ state.deltaToolArgs.delete(id);
52655
+ }
52327
52656
  return events;
52328
52657
  }
52329
52658
  function noteContextTokensFromMeta(state, meta3) {
@@ -52384,7 +52713,7 @@ function mapResponseStarted(u, state, ctx) {
52384
52713
  return event ? [event] : [];
52385
52714
  }
52386
52715
  function mapResponseCompleted(u, state, ctx) {
52387
- const usageRaw = asRecord9(u.usage) ?? u;
52716
+ const usageRaw = asRecord10(u.usage) ?? u;
52388
52717
  const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
52389
52718
  const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
52390
52719
  const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
@@ -52399,7 +52728,7 @@ function mapResponseCompleted(u, state, ctx) {
52399
52728
  }
52400
52729
  function mapTurnCompleted(u, state, ctx) {
52401
52730
  const events = mapTurnStopReason(u, state);
52402
- const usageRaw = asRecord9(u.usage);
52731
+ const usageRaw = asRecord10(u.usage);
52403
52732
  if (!usageRaw) {
52404
52733
  resetTurnTokens(state);
52405
52734
  return events;
@@ -52566,7 +52895,7 @@ function mapModelAutoSwitched(u) {
52566
52895
  ];
52567
52896
  }
52568
52897
  function mapRetryState(u) {
52569
- const nested = asRecord9(u.retry_state) ?? asRecord9(u.retryState) ?? u;
52898
+ const nested = asRecord10(u.retry_state) ?? asRecord10(u.retryState) ?? u;
52570
52899
  const type = (strField(nested, "type") ?? "").toLowerCase();
52571
52900
  if (type === "retrying") {
52572
52901
  const attempt = numField(nested, "attempt") ?? 1;
@@ -52633,7 +52962,7 @@ function mapAutoRecoveryExhausted(u) {
52633
52962
  }];
52634
52963
  }
52635
52964
  function mapFollowUps(u) {
52636
- const meta3 = asRecord9(u._meta) ?? asRecord9(u.meta);
52965
+ const meta3 = asRecord10(u._meta) ?? asRecord10(u.meta);
52637
52966
  if (meta3 && meta3["x.ai/replayed"] === true) return [];
52638
52967
  const responseId = strField(u, "response_id", "responseId");
52639
52968
  if (!responseId || responseId.length > 128) return [];
@@ -52642,7 +52971,7 @@ function mapFollowUps(u) {
52642
52971
  let count = 0;
52643
52972
  for (const s2 of suggestions) {
52644
52973
  if (count >= 6) break;
52645
- const rec = asRecord9(s2);
52974
+ const rec = asRecord10(s2);
52646
52975
  const label = (rec ? strField(rec, "label") : typeof s2 === "string" ? s2 : void 0)?.trim();
52647
52976
  if (!label) continue;
52648
52977
  const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
@@ -52665,6 +52994,7 @@ var init_xai_event_map = __esm({
52665
52994
  "../../packages/acp/src/xai-event-map.ts"() {
52666
52995
  "use strict";
52667
52996
  init_acp_goal();
52997
+ init_tool_ui();
52668
52998
  init_xai_state();
52669
52999
  log = { debug: (..._args) => void 0 };
52670
53000
  WORKFLOW_TERMINAL = /* @__PURE__ */ new Set([
@@ -52972,6 +53302,7 @@ function createAcpAgentEventMapper(options) {
52972
53302
  start(providerSessionId) {
52973
53303
  if (started) return;
52974
53304
  started = true;
53305
+ if (providerSessionId) xaiCorrelation.parentSessionId = providerSessionId;
52975
53306
  emitMessageStart(options.messageId);
52976
53307
  options.emit({ type: "status_change", status: "streaming" });
52977
53308
  if (providerSessionId) {
@@ -60489,7 +60820,7 @@ function toolDisplayName(name) {
60489
60820
  }
60490
60821
  function unwrapCursorMcpTool(toolType, args) {
60491
60822
  if (toolType.toLowerCase() !== "mcp") return { toolType, args };
60492
- const rec = asRecord10(args);
60823
+ const rec = asRecord11(args);
60493
60824
  if (!rec) return { toolType, args };
60494
60825
  const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
60495
60826
  const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
@@ -60515,12 +60846,12 @@ function idField(obj, ...keys) {
60515
60846
  return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
60516
60847
  }
60517
60848
  function extractCursorCallId(update) {
60518
- const rec = asRecord10(update);
60849
+ const rec = asRecord11(update);
60519
60850
  if (!rec) return null;
60520
- const nested = asRecord10(rec.toolCall) ?? asRecord10(rec.message);
60851
+ const nested = asRecord11(rec.toolCall) ?? asRecord11(rec.message);
60521
60852
  return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
60522
60853
  }
60523
- function asRecord10(value) {
60854
+ function asRecord11(value) {
60524
60855
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
60525
60856
  return value;
60526
60857
  }
@@ -60534,13 +60865,13 @@ function stringifyPayload(value) {
60534
60865
  }
60535
60866
  }
60536
60867
  function extractToolCallParts(update) {
60537
- const rec = asRecord10(update) ?? {};
60868
+ const rec = asRecord11(update) ?? {};
60538
60869
  const callId = extractCursorCallId(update);
60539
- const nested = asRecord10(rec.toolCall);
60870
+ const nested = asRecord11(rec.toolCall);
60540
60871
  if (nested) {
60541
60872
  const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
60542
60873
  const result = nested.result;
60543
- const resultRec = asRecord10(result);
60874
+ const resultRec = asRecord11(result);
60544
60875
  const isError = resultRec?.status === "error" || Boolean(rec.isError);
60545
60876
  return {
60546
60877
  callId,
@@ -60564,7 +60895,7 @@ function mapTodosPayload(todos) {
60564
60895
  return {
60565
60896
  type: "todos_updated",
60566
60897
  todos: todos.map((todo, index) => {
60567
- const row = asRecord10(todo) ?? {};
60898
+ const row = asRecord11(todo) ?? {};
60568
60899
  const statusRaw = String(row.status ?? "pending");
60569
60900
  return {
60570
60901
  id: String(row.id ?? index + 1),
@@ -60593,15 +60924,15 @@ function toolUseEvent(messageId, callId, toolType, args, status) {
60593
60924
  }
60594
60925
  function normalizeCursorToolInput(toolName, args) {
60595
60926
  if (toolName.startsWith("mcp__")) return args;
60596
- const rec = asRecord10(args);
60927
+ const rec = asRecord11(args);
60597
60928
  if (!rec) return args ?? {};
60598
60929
  return normalizeTranscriptTool(toolName, rec).input;
60599
60930
  }
60600
60931
  function mergeCursorToolResultArgs(toolType, args, result) {
60601
60932
  if (toolType.toLowerCase() === "mcp") return args;
60602
- const res = asRecord10(result);
60933
+ const res = asRecord11(result);
60603
60934
  if (!res) return args;
60604
- const rec = asRecord10(args);
60935
+ const rec = asRecord11(args);
60605
60936
  if (!rec) return args;
60606
60937
  const diff = typeof res.diffString === "string" ? res.diffString : void 0;
60607
60938
  const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
@@ -60662,7 +60993,7 @@ function stampParentToolUseId(events, parentToolUseId) {
60662
60993
  function mapInteractionUpdate(messageId, update, options) {
60663
60994
  const events = [];
60664
60995
  const type = String(update.type ?? "");
60665
- const rec = asRecord10(update) ?? {};
60996
+ const rec = asRecord11(update) ?? {};
60666
60997
  switch (type) {
60667
60998
  case "text-delta": {
60668
60999
  const text = strField2(update, "text");
@@ -60702,7 +61033,7 @@ function mapInteractionUpdate(messageId, update, options) {
60702
61033
  if (!parts.callId) break;
60703
61034
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
60704
61035
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
60705
- const todos = asRecord10(parts.args)?.todos;
61036
+ const todos = asRecord11(parts.args)?.todos;
60706
61037
  const todoEvent = mapTodosPayload(todos);
60707
61038
  if (todoEvent) events.push(todoEvent);
60708
61039
  }
@@ -60739,7 +61070,7 @@ function mapInteractionUpdate(messageId, update, options) {
60739
61070
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
60740
61071
  events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
60741
61072
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
60742
- const todos = asRecord10(parts.args)?.todos ?? asRecord10(parts.result)?.todos;
61073
+ const todos = asRecord11(parts.args)?.todos ?? asRecord11(parts.result)?.todos;
60743
61074
  const todoEvent = mapTodosPayload(todos);
60744
61075
  if (todoEvent) events.push(todoEvent);
60745
61076
  }
@@ -60844,7 +61175,7 @@ ${text}
60844
61175
  }
60845
61176
  function mapConversationStep(messageId, step, options) {
60846
61177
  const events = [];
60847
- const rec = asRecord10(step);
61178
+ const rec = asRecord11(step);
60848
61179
  if (!rec) return events;
60849
61180
  const stepType = strField2(rec, "type");
60850
61181
  if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
@@ -60852,14 +61183,14 @@ function mapConversationStep(messageId, step, options) {
60852
61183
  }
60853
61184
  if (stepType === "toolCall") {
60854
61185
  const message = rec.message ?? rec.toolCall ?? rec;
60855
- const nested = asRecord10(message);
61186
+ const nested = asRecord11(message);
60856
61187
  const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
60857
61188
  if (!callId) {
60858
61189
  return events;
60859
61190
  }
60860
61191
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
60861
61192
  const args = nested?.args ?? nested?.input ?? {};
60862
- const resultRec = asRecord10(nested?.result);
61193
+ const resultRec = asRecord11(nested?.result);
60863
61194
  const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
60864
61195
  events.push(toolUseEvent(
60865
61196
  messageId,
@@ -60869,7 +61200,7 @@ function mapConversationStep(messageId, step, options) {
60869
61200
  "complete"
60870
61201
  ));
60871
61202
  if (toolType === "updateTodos" || toolType === "update_todos") {
60872
- const todos = asRecord10(args)?.todos;
61203
+ const todos = asRecord11(args)?.todos;
60873
61204
  const todoEvent = mapTodosPayload(todos);
60874
61205
  if (todoEvent) events.push(todoEvent);
60875
61206
  }
@@ -61006,7 +61337,7 @@ var init_cursor_event_map = __esm({
61006
61337
  observeDelta(update) {
61007
61338
  const type = String(update.type ?? "");
61008
61339
  if (type === "tool-call-delta") {
61009
- const taskUpdate = asRecord10(update)?.taskUpdate;
61340
+ const taskUpdate = asRecord11(update)?.taskUpdate;
61010
61341
  if (taskUpdate && typeof taskUpdate === "object") {
61011
61342
  this.observeDelta(taskUpdate);
61012
61343
  }
@@ -62387,10 +62718,10 @@ var init_harness_runners = __esm({
62387
62718
  });
62388
62719
 
62389
62720
  // src/session/codex-live-turn.ts
62390
- function asRecord11(value) {
62721
+ function asRecord12(value) {
62391
62722
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
62392
62723
  }
62393
- function readString4(value) {
62724
+ function readString5(value) {
62394
62725
  return typeof value === "string" && value.length > 0 ? value : null;
62395
62726
  }
62396
62727
  function compactRecord3(input) {
@@ -62418,10 +62749,10 @@ function extractAgentTextFromTurn2(turn) {
62418
62749
  let text = "";
62419
62750
  const items = Array.isArray(turn.items) ? turn.items : [];
62420
62751
  for (const item of items) {
62421
- const rec = asRecord11(item);
62752
+ const rec = asRecord12(item);
62422
62753
  if (!rec) continue;
62423
- if (readString4(rec.type) === "agentMessage" || readString4(rec.itemType) === "agentMessage") {
62424
- const t = readString4(rec.text);
62754
+ if (readString5(rec.type) === "agentMessage" || readString5(rec.itemType) === "agentMessage") {
62755
+ const t = readString5(rec.text);
62425
62756
  if (t) text += t;
62426
62757
  }
62427
62758
  }
@@ -62450,8 +62781,8 @@ async function openTurnAndStream(opts) {
62450
62781
  ...collaborationMode ? { collaborationMode } : {}
62451
62782
  })
62452
62783
  );
62453
- const turn = asRecord11(turnStartResult.turn);
62454
- const turnId = readString4(turn?.id);
62784
+ const turn = asRecord12(turnStartResult.turn);
62785
+ const turnId = readString5(turn?.id);
62455
62786
  opts.onTurnStarted?.(turnId);
62456
62787
  let finalText = "";
62457
62788
  const deadline = Date.now() + TURN_WAIT_TIMEOUT_MS2;
@@ -62478,23 +62809,23 @@ async function openTurnAndStream(opts) {
62478
62809
  continue;
62479
62810
  }
62480
62811
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
62481
- const completedTurn = asRecord11(note.params.turn);
62482
- const completedId = readString4(completedTurn?.id);
62812
+ const completedTurn = asRecord12(note.params.turn);
62813
+ const completedId = readString5(completedTurn?.id);
62483
62814
  if (turnId && completedId && completedId !== turnId) continue;
62484
62815
  }
62485
62816
  if (agentEventMapper) {
62486
62817
  const applied = agentEventMapper.apply(note);
62487
62818
  if (applied.textDelta) finalText += applied.textDelta;
62488
62819
  } else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
62489
- const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord11(note.params.item)?.delta);
62820
+ const delta = readString5(note.params.delta) ?? readString5(note.params.text) ?? readString5(asRecord12(note.params.item)?.delta);
62490
62821
  if (delta) {
62491
62822
  finalText += delta;
62492
62823
  opts.onDelta?.(delta);
62493
62824
  }
62494
62825
  }
62495
62826
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
62496
- const completedTurn = asRecord11(note.params.turn);
62497
- const status = readString4(completedTurn?.status) ?? readString4(note.params.status);
62827
+ const completedTurn = asRecord12(note.params.turn);
62828
+ const status = readString5(completedTurn?.status) ?? readString5(note.params.status);
62498
62829
  if (status === "failed" || status === "error") {
62499
62830
  throw new Error("Codex turn failed");
62500
62831
  }
@@ -62531,8 +62862,7 @@ import { existsSync as existsSync25 } from "node:fs";
62531
62862
  function mapCodexReasoningEffort(effort) {
62532
62863
  if (!effort) return void 0;
62533
62864
  const e = effort.trim().toLowerCase();
62534
- if (e === "max") return "xhigh";
62535
- 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") {
62536
62866
  return e;
62537
62867
  }
62538
62868
  return void 0;
@@ -63013,11 +63343,25 @@ var init_codex_admin_service = __esm({
63013
63343
  return null;
63014
63344
  }
63015
63345
  }
63016
- async getAccountUsage(projectId, apiProviderId) {
63346
+ async getAccountUsage(projectId, apiProviderId, threadId) {
63017
63347
  const auth = this.getProjectAuth(projectId);
63018
63348
  if (resolveMode(auth.mode, auth.apiKey) !== "chatgpt") return null;
63019
63349
  try {
63020
- 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));
63021
63365
  } catch {
63022
63366
  return null;
63023
63367
  }
@@ -63035,11 +63379,11 @@ var init_codex_admin_service = __esm({
63035
63379
  return null;
63036
63380
  }
63037
63381
  }
63038
- async loginMcpOauth(projectId, serverName, apiProviderId) {
63382
+ async loginMcpOauth(projectId, serverName, apiProviderId, options) {
63039
63383
  return this.withClient(
63040
63384
  projectId,
63041
63385
  apiProviderId,
63042
- (client3) => loginMcpServerOauth(client3, serverName)
63386
+ (client3) => loginMcpServerOauth(client3, serverName, void 0, 18e4, options)
63043
63387
  );
63044
63388
  }
63045
63389
  async detectExternalAgent(projectId, apiProviderId) {
@@ -70218,8 +70562,8 @@ import { fileURLToPath } from "node:url";
70218
70562
  function resolveCliReleaseVersion() {
70219
70563
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
70220
70564
  if (fromEnv) return fromEnv;
70221
- if ("0.56.0-alpha".trim()) {
70222
- return "0.56.0-alpha".trim();
70565
+ if ("0.57.0-alpha".trim()) {
70566
+ return "0.57.0-alpha".trim();
70223
70567
  }
70224
70568
  const fromDist = readDistManifestVersion();
70225
70569
  if (fromDist) return fromDist;
@@ -72265,7 +72609,7 @@ function requireResourceWrite(client3, scope) {
72265
72609
  if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
72266
72610
  return null;
72267
72611
  }
72268
- function asRecord12(payload) {
72612
+ function asRecord13(payload) {
72269
72613
  return payload && typeof payload === "object" ? payload : {};
72270
72614
  }
72271
72615
  function mapThrown(err) {
@@ -72294,7 +72638,7 @@ function manageOpts(ctx) {
72294
72638
  function handleSkillsList(payload, ctx) {
72295
72639
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72296
72640
  if (denied) return denied;
72297
- const p2 = asRecord12(payload);
72641
+ const p2 = asRecord13(payload);
72298
72642
  try {
72299
72643
  const projectId = String(p2.projectId ?? "");
72300
72644
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72314,7 +72658,7 @@ function handleSkillsList(payload, ctx) {
72314
72658
  function handleSkillsGet(payload, ctx) {
72315
72659
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72316
72660
  if (denied) return denied;
72317
- const p2 = asRecord12(payload);
72661
+ const p2 = asRecord13(payload);
72318
72662
  try {
72319
72663
  const projectId = String(p2.projectId ?? "");
72320
72664
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72339,7 +72683,7 @@ function handleSkillsGet(payload, ctx) {
72339
72683
  function handleSkillsReadFile(payload, ctx) {
72340
72684
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72341
72685
  if (denied) return denied;
72342
- const p2 = asRecord12(payload);
72686
+ const p2 = asRecord13(payload);
72343
72687
  try {
72344
72688
  const projectId = String(p2.projectId ?? "");
72345
72689
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72373,7 +72717,7 @@ function handleSkillsReadFile(payload, ctx) {
72373
72717
  function handleSkillsDelete(payload, ctx) {
72374
72718
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72375
72719
  if (denied) return denied;
72376
- const p2 = asRecord12(payload);
72720
+ const p2 = asRecord13(payload);
72377
72721
  try {
72378
72722
  const projectId = String(p2.projectId ?? "");
72379
72723
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72398,7 +72742,7 @@ function handleSkillsDelete(payload, ctx) {
72398
72742
  function handleSkillsInstall(payload, ctx) {
72399
72743
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72400
72744
  if (baseDenied) return baseDenied;
72401
- const p2 = asRecord12(payload);
72745
+ const p2 = asRecord13(payload);
72402
72746
  try {
72403
72747
  const projectId = String(p2.projectId ?? "");
72404
72748
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72432,7 +72776,7 @@ function handleSkillsInstall(payload, ctx) {
72432
72776
  function handleMcpList(payload, ctx) {
72433
72777
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72434
72778
  if (denied) return denied;
72435
- const p2 = asRecord12(payload);
72779
+ const p2 = asRecord13(payload);
72436
72780
  try {
72437
72781
  const projectId = String(p2.projectId ?? "");
72438
72782
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72456,7 +72800,7 @@ function handleMcpList(payload, ctx) {
72456
72800
  function handleAdditionalDirsList(payload, ctx) {
72457
72801
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72458
72802
  if (denied) return denied;
72459
- const p2 = asRecord12(payload);
72803
+ const p2 = asRecord13(payload);
72460
72804
  try {
72461
72805
  const projectId = String(p2.projectId ?? "");
72462
72806
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72471,7 +72815,7 @@ function handleAdditionalDirsList(payload, ctx) {
72471
72815
  function handleAdditionalDirsAdd(payload, ctx) {
72472
72816
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72473
72817
  if (denied) return denied;
72474
- const p2 = asRecord12(payload);
72818
+ const p2 = asRecord13(payload);
72475
72819
  try {
72476
72820
  const projectId = String(p2.projectId ?? "");
72477
72821
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72489,7 +72833,7 @@ function handleAdditionalDirsAdd(payload, ctx) {
72489
72833
  function handleAdditionalDirsRemove(payload, ctx) {
72490
72834
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72491
72835
  if (denied) return denied;
72492
- const p2 = asRecord12(payload);
72836
+ const p2 = asRecord13(payload);
72493
72837
  try {
72494
72838
  const projectId = String(p2.projectId ?? "");
72495
72839
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72540,7 +72884,7 @@ function parseMcpWriteConfig(raw) {
72540
72884
  function handleMcpSave(payload, ctx) {
72541
72885
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72542
72886
  if (baseDenied) return baseDenied;
72543
- const p2 = asRecord12(payload);
72887
+ const p2 = asRecord13(payload);
72544
72888
  try {
72545
72889
  const projectId = String(p2.projectId ?? "");
72546
72890
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72570,7 +72914,7 @@ function handleMcpSave(payload, ctx) {
72570
72914
  function handleMcpToggle(payload, ctx) {
72571
72915
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72572
72916
  if (baseDenied) return baseDenied;
72573
- const p2 = asRecord12(payload);
72917
+ const p2 = asRecord13(payload);
72574
72918
  try {
72575
72919
  const projectId = String(p2.projectId ?? "");
72576
72920
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72601,7 +72945,7 @@ function handleMcpToggle(payload, ctx) {
72601
72945
  function handleMcpDelete(payload, ctx) {
72602
72946
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72603
72947
  if (baseDenied) return baseDenied;
72604
- const p2 = asRecord12(payload);
72948
+ const p2 = asRecord13(payload);
72605
72949
  try {
72606
72950
  const projectId = String(p2.projectId ?? "");
72607
72951
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72641,7 +72985,7 @@ function parseMarketplaceScope(raw) {
72641
72985
  async function handlePluginsList(payload, ctx) {
72642
72986
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72643
72987
  if (denied) return denied;
72644
- const p2 = asRecord12(payload);
72988
+ const p2 = asRecord13(payload);
72645
72989
  try {
72646
72990
  const projectId = String(p2.projectId ?? "");
72647
72991
  projectRoot(ctx.projects, projectId);
@@ -72688,7 +73032,7 @@ async function handlePluginsList(payload, ctx) {
72688
73032
  function handlePluginsGet(payload, ctx) {
72689
73033
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72690
73034
  if (denied) return denied;
72691
- const p2 = asRecord12(payload);
73035
+ const p2 = asRecord13(payload);
72692
73036
  try {
72693
73037
  const projectId = String(p2.projectId ?? "");
72694
73038
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72712,7 +73056,7 @@ function handlePluginsGet(payload, ctx) {
72712
73056
  function handlePluginsReadFile(payload, ctx) {
72713
73057
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72714
73058
  if (denied) return denied;
72715
- const p2 = asRecord12(payload);
73059
+ const p2 = asRecord13(payload);
72716
73060
  try {
72717
73061
  const projectId = String(p2.projectId ?? "");
72718
73062
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72740,7 +73084,7 @@ function handlePluginsReadFile(payload, ctx) {
72740
73084
  function handlePluginsDelete(payload, ctx) {
72741
73085
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72742
73086
  if (baseDenied) return baseDenied;
72743
- const p2 = asRecord12(payload);
73087
+ const p2 = asRecord13(payload);
72744
73088
  try {
72745
73089
  const projectId = String(p2.projectId ?? "");
72746
73090
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72766,7 +73110,7 @@ function handlePluginsDelete(payload, ctx) {
72766
73110
  async function handlePluginsInstall(payload, ctx) {
72767
73111
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72768
73112
  if (baseDenied) return baseDenied;
72769
- const p2 = asRecord12(payload);
73113
+ const p2 = asRecord13(payload);
72770
73114
  try {
72771
73115
  const projectId = String(p2.projectId ?? "");
72772
73116
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72792,7 +73136,7 @@ async function handlePluginsInstall(payload, ctx) {
72792
73136
  function handlePluginsUpdate(payload, ctx) {
72793
73137
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72794
73138
  if (baseDenied) return baseDenied;
72795
- const p2 = asRecord12(payload);
73139
+ const p2 = asRecord13(payload);
72796
73140
  try {
72797
73141
  const projectId = String(p2.projectId ?? "");
72798
73142
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72818,7 +73162,7 @@ function handlePluginsUpdate(payload, ctx) {
72818
73162
  function handlePluginsListMarketplace(payload, ctx) {
72819
73163
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72820
73164
  if (denied) return denied;
72821
- const p2 = asRecord12(payload);
73165
+ const p2 = asRecord13(payload);
72822
73166
  try {
72823
73167
  const projectId = String(p2.projectId ?? "");
72824
73168
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72840,7 +73184,7 @@ function handlePluginsListMarketplace(payload, ctx) {
72840
73184
  async function handlePluginsAddMarketplace(payload, ctx) {
72841
73185
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72842
73186
  if (baseDenied) return baseDenied;
72843
- const p2 = asRecord12(payload);
73187
+ const p2 = asRecord13(payload);
72844
73188
  try {
72845
73189
  const projectId = String(p2.projectId ?? "");
72846
73190
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72866,7 +73210,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
72866
73210
  async function handlePluginsRemoveMarketplace(payload, ctx) {
72867
73211
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72868
73212
  if (baseDenied) return baseDenied;
72869
- const p2 = asRecord12(payload);
73213
+ const p2 = asRecord13(payload);
72870
73214
  try {
72871
73215
  const projectId = String(p2.projectId ?? "");
72872
73216
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72901,7 +73245,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
72901
73245
  if (denied) return denied;
72902
73246
  const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
72903
73247
  if (adminDenied) return adminDenied;
72904
- const p2 = asRecord12(payload);
73248
+ const p2 = asRecord13(payload);
72905
73249
  try {
72906
73250
  const projectId = String(p2.projectId ?? "");
72907
73251
  if (projectId) {
@@ -72923,7 +73267,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
72923
73267
  function handlePluginsReadMarketplace(payload, ctx) {
72924
73268
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72925
73269
  if (denied) return denied;
72926
- const p2 = asRecord12(payload);
73270
+ const p2 = asRecord13(payload);
72927
73271
  try {
72928
73272
  const projectId = String(p2.projectId ?? "");
72929
73273
  if (projectId) {
@@ -72954,7 +73298,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
72954
73298
  function handlePluginsReadMarketplaceFile(payload, ctx) {
72955
73299
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72956
73300
  if (denied) return denied;
72957
- const p2 = asRecord12(payload);
73301
+ const p2 = asRecord13(payload);
72958
73302
  try {
72959
73303
  const projectId = String(p2.projectId ?? "");
72960
73304
  if (projectId) {
@@ -72988,7 +73332,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
72988
73332
  function handleAgentsList(payload, ctx) {
72989
73333
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72990
73334
  if (denied) return denied;
72991
- const p2 = asRecord12(payload);
73335
+ const p2 = asRecord13(payload);
72992
73336
  try {
72993
73337
  const projectId = String(p2.projectId ?? "");
72994
73338
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73005,7 +73349,7 @@ function handleAgentsList(payload, ctx) {
73005
73349
  function handleAgentsReadFile(payload, ctx) {
73006
73350
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73007
73351
  if (denied) return denied;
73008
- const p2 = asRecord12(payload);
73352
+ const p2 = asRecord13(payload);
73009
73353
  try {
73010
73354
  const projectId = String(p2.projectId ?? "");
73011
73355
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73037,7 +73381,7 @@ function parseHookSavePayload(raw) {
73037
73381
  function handleHooksList(payload, ctx) {
73038
73382
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73039
73383
  if (denied) return denied;
73040
- const p2 = asRecord12(payload);
73384
+ const p2 = asRecord13(payload);
73041
73385
  try {
73042
73386
  const projectId = String(p2.projectId ?? "");
73043
73387
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73050,7 +73394,7 @@ function handleHooksList(payload, ctx) {
73050
73394
  function handleHooksSave(payload, ctx) {
73051
73395
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73052
73396
  if (baseDenied) return baseDenied;
73053
- const p2 = asRecord12(payload);
73397
+ const p2 = asRecord13(payload);
73054
73398
  try {
73055
73399
  const projectId = String(p2.projectId ?? "");
73056
73400
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73078,7 +73422,7 @@ function handleHooksSave(payload, ctx) {
73078
73422
  function handleHooksDelete(payload, ctx) {
73079
73423
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73080
73424
  if (baseDenied) return baseDenied;
73081
- const p2 = asRecord12(payload);
73425
+ const p2 = asRecord13(payload);
73082
73426
  try {
73083
73427
  const projectId = String(p2.projectId ?? "");
73084
73428
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73183,7 +73527,7 @@ function requireScopes2(client3, scopes) {
73183
73527
  }
73184
73528
  return null;
73185
73529
  }
73186
- function asRecord13(payload) {
73530
+ function asRecord14(payload) {
73187
73531
  return payload && typeof payload === "object" ? payload : {};
73188
73532
  }
73189
73533
  function mapThrown2(err) {
@@ -73274,7 +73618,7 @@ function parseSchedule(raw) {
73274
73618
  function handleAutomationList(payload, ctx) {
73275
73619
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
73276
73620
  if (denied) return denied;
73277
- const p2 = asRecord13(payload);
73621
+ const p2 = asRecord14(payload);
73278
73622
  const projectId = String(p2.projectId ?? "").trim();
73279
73623
  if (!projectId) {
73280
73624
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -73293,7 +73637,7 @@ function handleAutomationList(payload, ctx) {
73293
73637
  function handleAutomationCreate(payload, ctx) {
73294
73638
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73295
73639
  if (denied) return denied;
73296
- const p2 = asRecord13(payload);
73640
+ const p2 = asRecord14(payload);
73297
73641
  const projectId = String(p2.projectId ?? "").trim();
73298
73642
  if (!projectId) {
73299
73643
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -73330,7 +73674,7 @@ function handleAutomationCreate(payload, ctx) {
73330
73674
  function handleAutomationUpdate(payload, ctx) {
73331
73675
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73332
73676
  if (denied) return denied;
73333
- const p2 = asRecord13(payload);
73677
+ const p2 = asRecord14(payload);
73334
73678
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
73335
73679
  if (!automationId) {
73336
73680
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -73374,7 +73718,7 @@ function handleAutomationUpdate(payload, ctx) {
73374
73718
  function handleAutomationDelete(payload, ctx) {
73375
73719
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73376
73720
  if (denied) return denied;
73377
- const p2 = asRecord13(payload);
73721
+ const p2 = asRecord14(payload);
73378
73722
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
73379
73723
  if (!automationId) {
73380
73724
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -73400,7 +73744,7 @@ function handleAutomationDelete(payload, ctx) {
73400
73744
  async function handleAutomationRunNow(payload, ctx) {
73401
73745
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73402
73746
  if (denied) return denied;
73403
- const p2 = asRecord13(payload);
73747
+ const p2 = asRecord14(payload);
73404
73748
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
73405
73749
  if (!automationId) {
73406
73750
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -73457,7 +73801,7 @@ function requireScopes3(client3, scopes) {
73457
73801
  }
73458
73802
  return null;
73459
73803
  }
73460
- function asRecord14(payload) {
73804
+ function asRecord15(payload) {
73461
73805
  return payload && typeof payload === "object" ? payload : {};
73462
73806
  }
73463
73807
  function optionalString(value) {
@@ -73466,7 +73810,7 @@ function optionalString(value) {
73466
73810
  function parseAttachments(value) {
73467
73811
  if (!Array.isArray(value)) return [];
73468
73812
  return value.flatMap((raw) => {
73469
- const a = asRecord14(raw);
73813
+ const a = asRecord15(raw);
73470
73814
  const name = typeof a.name === "string" ? a.name : "";
73471
73815
  const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
73472
73816
  const data = typeof a.data === "string" ? a.data : "";
@@ -73479,7 +73823,7 @@ function mapThrown3(err) {
73479
73823
  function handleDraftList(payload, ctx) {
73480
73824
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
73481
73825
  if (denied) return denied;
73482
- const p2 = asRecord14(payload);
73826
+ const p2 = asRecord15(payload);
73483
73827
  const projectPath = optionalString(p2.projectPath);
73484
73828
  try {
73485
73829
  return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
@@ -73490,7 +73834,7 @@ function handleDraftList(payload, ctx) {
73490
73834
  function handleDraftUpsert(payload, ctx) {
73491
73835
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
73492
73836
  if (denied) return denied;
73493
- const p2 = asRecord14(payload);
73837
+ const p2 = asRecord15(payload);
73494
73838
  const id = String(p2.id ?? "").trim();
73495
73839
  if (!id) {
73496
73840
  return { error: { code: "invalid_argument", message: "id is required" } };
@@ -73521,7 +73865,7 @@ function handleDraftUpsert(payload, ctx) {
73521
73865
  function handleDraftDelete(payload, ctx) {
73522
73866
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
73523
73867
  if (denied) return denied;
73524
- const p2 = asRecord14(payload);
73868
+ const p2 = asRecord15(payload);
73525
73869
  const draftId = String(p2.draftId ?? "").trim();
73526
73870
  if (!draftId) {
73527
73871
  return { error: { code: "invalid_argument", message: "draftId is required" } };
@@ -73555,7 +73899,7 @@ function requireScopes4(client3, scopes) {
73555
73899
  }
73556
73900
  return null;
73557
73901
  }
73558
- function asRecord15(payload) {
73902
+ function asRecord16(payload) {
73559
73903
  return payload && typeof payload === "object" ? payload : {};
73560
73904
  }
73561
73905
  function mapThrown4(err) {
@@ -73594,6 +73938,10 @@ async function dispatchCodexRpc(method, payload, ctx) {
73594
73938
  return handleGetRateLimits(payload, ctx);
73595
73939
  case "codex.getAccountUsage":
73596
73940
  return handleGetAccountUsage(payload, ctx);
73941
+ case "codex.getServerDiagnostics":
73942
+ return handleGetServerDiagnostics(payload, ctx);
73943
+ case "codex.getConfigRequirements":
73944
+ return handleGetConfigRequirements(payload, ctx);
73597
73945
  case "codex.consumeRateLimitReset":
73598
73946
  return handleConsumeRateLimitReset(payload, ctx);
73599
73947
  case "codex.loginMcpOauth":
@@ -73637,7 +73985,7 @@ var CODEX_MUTATING_METHODS = [
73637
73985
  function handleGetAuthStatus(payload, ctx) {
73638
73986
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73639
73987
  if (denied) return denied;
73640
- const p2 = asRecord15(payload);
73988
+ const p2 = asRecord16(payload);
73641
73989
  const projectId = projectIdOf(p2);
73642
73990
  if (!projectId) {
73643
73991
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73650,7 +73998,7 @@ function handleGetAuthStatus(payload, ctx) {
73650
73998
  function handleSetAuth(payload, ctx) {
73651
73999
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73652
74000
  if (denied) return denied;
73653
- const p2 = asRecord15(payload);
74001
+ const p2 = asRecord16(payload);
73654
74002
  const projectId = projectIdOf(p2);
73655
74003
  if (!projectId) {
73656
74004
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73675,7 +74023,7 @@ function handleSetAuth(payload, ctx) {
73675
74023
  async function handleGetAccountStatus(payload, ctx) {
73676
74024
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73677
74025
  if (denied) return denied;
73678
- const p2 = asRecord15(payload);
74026
+ const p2 = asRecord16(payload);
73679
74027
  const projectId = projectIdOf(p2);
73680
74028
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73681
74029
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -73688,7 +74036,7 @@ async function handleGetAccountStatus(payload, ctx) {
73688
74036
  async function handleAccountLoginStart(payload, ctx) {
73689
74037
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73690
74038
  if (denied) return denied;
73691
- const p2 = asRecord15(payload);
74039
+ const p2 = asRecord16(payload);
73692
74040
  const projectId = projectIdOf(p2);
73693
74041
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73694
74042
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -73701,7 +74049,7 @@ async function handleAccountLoginStart(payload, ctx) {
73701
74049
  async function handleAccountLoginCancel(payload, ctx) {
73702
74050
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73703
74051
  if (denied) return denied;
73704
- const p2 = asRecord15(payload);
74052
+ const p2 = asRecord16(payload);
73705
74053
  const loginId = typeof p2.loginId === "string" ? p2.loginId.trim() : "";
73706
74054
  if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
73707
74055
  try {
@@ -73714,7 +74062,7 @@ async function handleAccountLoginCancel(payload, ctx) {
73714
74062
  async function handleAccountLogout(payload, ctx) {
73715
74063
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73716
74064
  if (denied) return denied;
73717
- const p2 = asRecord15(payload);
74065
+ const p2 = asRecord16(payload);
73718
74066
  const projectId = projectIdOf(p2);
73719
74067
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73720
74068
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -73727,7 +74075,7 @@ async function handleAccountLogout(payload, ctx) {
73727
74075
  async function handleGetRateLimits(payload, ctx) {
73728
74076
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73729
74077
  if (denied) return denied;
73730
- const p2 = asRecord15(payload);
74078
+ const p2 = asRecord16(payload);
73731
74079
  const projectId = projectIdOf(p2);
73732
74080
  if (!projectId) {
73733
74081
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73754,7 +74102,7 @@ async function handleGetRateLimits(payload, ctx) {
73754
74102
  async function handleGetAccountUsage(payload, ctx) {
73755
74103
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73756
74104
  if (denied) return denied;
73757
- const p2 = asRecord15(payload);
74105
+ const p2 = asRecord16(payload);
73758
74106
  const projectId = projectIdOf(p2);
73759
74107
  if (!projectId) {
73760
74108
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73773,7 +74121,44 @@ async function handleGetAccountUsage(payload, ctx) {
73773
74121
  };
73774
74122
  }
73775
74123
  const apiProviderId = typeof p2.apiProviderId === "string" ? p2.apiProviderId : null;
73776
- return { result: await svc.getAccountUsage(projectId, apiProviderId) };
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) };
73777
74162
  } catch (err) {
73778
74163
  return mapThrown4(err);
73779
74164
  }
@@ -73781,7 +74166,7 @@ async function handleGetAccountUsage(payload, ctx) {
73781
74166
  async function handleConsumeRateLimitReset(payload, ctx) {
73782
74167
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73783
74168
  if (denied) return denied;
73784
- const p2 = asRecord15(payload);
74169
+ const p2 = asRecord16(payload);
73785
74170
  const projectId = projectIdOf(p2);
73786
74171
  if (!projectId) {
73787
74172
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73811,7 +74196,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
73811
74196
  async function handleLoginMcpOauth(payload, ctx) {
73812
74197
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73813
74198
  if (denied) return denied;
73814
- const p2 = asRecord15(payload);
74199
+ const p2 = asRecord16(payload);
73815
74200
  const projectId = projectIdOf(p2);
73816
74201
  const serverName = String(p2.serverName ?? p2.name ?? "").trim();
73817
74202
  if (!projectId || !serverName) {
@@ -73821,8 +74206,15 @@ async function handleLoginMcpOauth(payload, ctx) {
73821
74206
  }
73822
74207
  try {
73823
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
+ };
73824
74216
  return {
73825
- result: await admin(ctx).loginMcpOauth(projectId, serverName, apiProviderId)
74217
+ result: await admin(ctx).loginMcpOauth(projectId, serverName, apiProviderId, options)
73826
74218
  };
73827
74219
  } catch (err) {
73828
74220
  return mapThrown4(err);
@@ -73831,7 +74223,7 @@ async function handleLoginMcpOauth(payload, ctx) {
73831
74223
  async function handleDetectExternalAgent(payload, ctx) {
73832
74224
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73833
74225
  if (denied) return denied;
73834
- const p2 = asRecord15(payload);
74226
+ const p2 = asRecord16(payload);
73835
74227
  const projectId = projectIdOf(p2);
73836
74228
  if (!projectId) {
73837
74229
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73850,7 +74242,7 @@ async function handleDetectExternalAgent(payload, ctx) {
73850
74242
  async function handleImportExternalAgent(payload, ctx) {
73851
74243
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73852
74244
  if (denied) return denied;
73853
- const p2 = asRecord15(payload);
74245
+ const p2 = asRecord16(payload);
73854
74246
  const projectId = projectIdOf(p2);
73855
74247
  if (!projectId) {
73856
74248
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73868,7 +74260,7 @@ async function handleImportExternalAgent(payload, ctx) {
73868
74260
  async function handlePluginsList2(payload, ctx) {
73869
74261
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
73870
74262
  if (denied) return denied;
73871
- const p2 = asRecord15(payload);
74263
+ const p2 = asRecord16(payload);
73872
74264
  const projectId = projectIdOf(p2);
73873
74265
  if (!projectId) {
73874
74266
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73891,7 +74283,7 @@ async function handlePluginsList2(payload, ctx) {
73891
74283
  async function handlePluginsInstall2(payload, ctx) {
73892
74284
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73893
74285
  if (denied) return denied;
73894
- const p2 = asRecord15(payload);
74286
+ const p2 = asRecord16(payload);
73895
74287
  const projectId = projectIdOf(p2);
73896
74288
  const key = String(p2.key ?? p2.pluginId ?? "").trim();
73897
74289
  if (!projectId || !key) {
@@ -73907,7 +74299,7 @@ async function handlePluginsInstall2(payload, ctx) {
73907
74299
  async function handlePluginsUninstall(payload, ctx) {
73908
74300
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73909
74301
  if (denied) return denied;
73910
- const p2 = asRecord15(payload);
74302
+ const p2 = asRecord16(payload);
73911
74303
  const projectId = projectIdOf(p2);
73912
74304
  const key = String(p2.key ?? p2.pluginId ?? "").trim();
73913
74305
  if (!projectId || !key) {
@@ -73923,7 +74315,7 @@ async function handlePluginsUninstall(payload, ctx) {
73923
74315
  async function handleMarketplaceAdd(payload, ctx) {
73924
74316
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73925
74317
  if (denied) return denied;
73926
- const p2 = asRecord15(payload);
74318
+ const p2 = asRecord16(payload);
73927
74319
  const projectId = projectIdOf(p2);
73928
74320
  const source = String(p2.source ?? "").trim();
73929
74321
  if (!projectId || !source) {
@@ -73952,7 +74344,7 @@ async function handleMarketplaceAdd(payload, ctx) {
73952
74344
  async function handleMarketplaceRemove(payload, ctx) {
73953
74345
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73954
74346
  if (denied) return denied;
73955
- const p2 = asRecord15(payload);
74347
+ const p2 = asRecord16(payload);
73956
74348
  const projectId = projectIdOf(p2);
73957
74349
  const marketplaceName = String(p2.marketplaceName ?? p2.name ?? "").trim();
73958
74350
  if (!projectId || !marketplaceName) {
@@ -73975,7 +74367,7 @@ async function handleMarketplaceRemove(payload, ctx) {
73975
74367
  async function handleMarketplaceUpgrade(payload, ctx) {
73976
74368
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73977
74369
  if (denied) return denied;
73978
- const p2 = asRecord15(payload);
74370
+ const p2 = asRecord16(payload);
73979
74371
  const projectId = projectIdOf(p2);
73980
74372
  if (!projectId) {
73981
74373
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74008,7 +74400,7 @@ function requireScopes5(client3, scopes) {
74008
74400
  }
74009
74401
  return null;
74010
74402
  }
74011
- function asRecord16(payload) {
74403
+ function asRecord17(payload) {
74012
74404
  return payload && typeof payload === "object" ? payload : {};
74013
74405
  }
74014
74406
  function mapThrown5(err) {
@@ -74037,7 +74429,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
74037
74429
  function handleList(payload, ctx) {
74038
74430
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74039
74431
  if (denied) return denied;
74040
- const p2 = asRecord16(payload);
74432
+ const p2 = asRecord17(payload);
74041
74433
  try {
74042
74434
  const harnessId = typeof p2.harnessId === "string" && p2.harnessId.trim() ? p2.harnessId.trim() : null;
74043
74435
  const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
@@ -74049,7 +74441,7 @@ function handleList(payload, ctx) {
74049
74441
  function handleGet(payload, ctx) {
74050
74442
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74051
74443
  if (denied) return denied;
74052
- const p2 = asRecord16(payload);
74444
+ const p2 = asRecord17(payload);
74053
74445
  const id = String(p2.id ?? "");
74054
74446
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74055
74447
  try {
@@ -74061,7 +74453,7 @@ function handleGet(payload, ctx) {
74061
74453
  function handleGetBase(payload, ctx) {
74062
74454
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74063
74455
  if (denied) return denied;
74064
- const p2 = asRecord16(payload);
74456
+ const p2 = asRecord17(payload);
74065
74457
  const harnessId = String(p2.harnessId ?? "");
74066
74458
  if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
74067
74459
  try {
@@ -74073,7 +74465,7 @@ function handleGetBase(payload, ctx) {
74073
74465
  function handleCreate(payload, ctx) {
74074
74466
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74075
74467
  if (denied) return denied;
74076
- const p2 = asRecord16(payload);
74468
+ const p2 = asRecord17(payload);
74077
74469
  try {
74078
74470
  const provider = ctx.sessionProviders.create({
74079
74471
  harnessId: String(p2.harnessId ?? ""),
@@ -74089,7 +74481,7 @@ function handleCreate(payload, ctx) {
74089
74481
  function handleUpdate(payload, ctx) {
74090
74482
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74091
74483
  if (denied) return denied;
74092
- const p2 = asRecord16(payload);
74484
+ const p2 = asRecord17(payload);
74093
74485
  const id = String(p2.id ?? "");
74094
74486
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74095
74487
  try {
@@ -74105,7 +74497,7 @@ function handleUpdate(payload, ctx) {
74105
74497
  function handleDelete(payload, ctx) {
74106
74498
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74107
74499
  if (denied) return denied;
74108
- const p2 = asRecord16(payload);
74500
+ const p2 = asRecord17(payload);
74109
74501
  const id = String(p2.id ?? "");
74110
74502
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74111
74503
  try {
@@ -74146,7 +74538,7 @@ function requireScopes6(client3, scopes) {
74146
74538
  }
74147
74539
  return null;
74148
74540
  }
74149
- function asRecord17(payload) {
74541
+ function asRecord18(payload) {
74150
74542
  return payload && typeof payload === "object" ? payload : {};
74151
74543
  }
74152
74544
  function defaultProbeModels(ctx) {
@@ -74174,7 +74566,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
74174
74566
  async function handleHarnessResources(payload, ctx) {
74175
74567
  const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
74176
74568
  if (denied) return denied;
74177
- const p2 = asRecord17(payload);
74569
+ const p2 = asRecord18(payload);
74178
74570
  const projectId = String(p2.projectId ?? "");
74179
74571
  if (!projectId) {
74180
74572
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74616,7 +75008,7 @@ function handleProviderListCredentials(ctx) {
74616
75008
  function handleProviderGetCredentialDecrypted(payload, ctx) {
74617
75009
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74618
75010
  if (denied) return denied;
74619
- const p2 = asRecord18(payload);
75011
+ const p2 = asRecord19(payload);
74620
75012
  const cred = ctx.providers.getCredentialDecrypted(String(p2.id ?? ""));
74621
75013
  if (!cred) return { error: { code: "not_found", message: "credential not found" } };
74622
75014
  return { result: cred };
@@ -74624,7 +75016,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
74624
75016
  function handleProviderCreateCredential(payload, ctx) {
74625
75017
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74626
75018
  if (denied) return denied;
74627
- const p2 = asRecord18(payload);
75019
+ const p2 = asRecord19(payload);
74628
75020
  try {
74629
75021
  return {
74630
75022
  result: ctx.providers.createCredential({
@@ -74646,7 +75038,7 @@ function handleProviderCreateCredential(payload, ctx) {
74646
75038
  function handleProviderUpdateCredential(payload, ctx) {
74647
75039
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74648
75040
  if (denied) return denied;
74649
- const p2 = asRecord18(payload);
75041
+ const p2 = asRecord19(payload);
74650
75042
  const id = String(p2.id ?? "");
74651
75043
  const updated = ctx.providers.updateCredential(id, {
74652
75044
  name: typeof p2.name === "string" ? p2.name : void 0,
@@ -74663,7 +75055,7 @@ function handleProviderUpdateCredential(payload, ctx) {
74663
75055
  function handleProviderDeleteCredential(payload, ctx) {
74664
75056
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74665
75057
  if (denied) return denied;
74666
- const p2 = asRecord18(payload);
75058
+ const p2 = asRecord19(payload);
74667
75059
  const ok = ctx.providers.deleteCredential(String(p2.id ?? ""));
74668
75060
  if (!ok) return { error: { code: "not_found", message: "credential not found" } };
74669
75061
  return { result: { ok: true } };
@@ -74676,7 +75068,7 @@ function handleProviderListBindings(ctx) {
74676
75068
  function handleProviderSetBinding(payload, ctx) {
74677
75069
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74678
75070
  if (denied) return denied;
74679
- const p2 = asRecord18(payload);
75071
+ const p2 = asRecord19(payload);
74680
75072
  const binding = p2;
74681
75073
  if (!binding.consumer || !binding.credentialId) {
74682
75074
  return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
@@ -74687,7 +75079,7 @@ function handleProviderSetBinding(payload, ctx) {
74687
75079
  function handleProviderClearBinding(payload, ctx) {
74688
75080
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74689
75081
  if (denied) return denied;
74690
- const p2 = asRecord18(payload);
75082
+ const p2 = asRecord19(payload);
74691
75083
  ctx.providers.clearBinding(String(p2.consumer ?? ""));
74692
75084
  return { result: { ok: true } };
74693
75085
  }
@@ -74699,14 +75091,14 @@ function handleProviderListCustomPlatforms(ctx) {
74699
75091
  function handleProviderUpsertCustomPlatform(payload, ctx) {
74700
75092
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74701
75093
  if (denied) return denied;
74702
- const def = asRecord18(payload);
75094
+ const def = asRecord19(payload);
74703
75095
  if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
74704
75096
  return { result: ctx.providers.upsertCustomPlatform(def) };
74705
75097
  }
74706
75098
  function handleProviderDeleteCustomPlatform(payload, ctx) {
74707
75099
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74708
75100
  if (denied) return denied;
74709
- const p2 = asRecord18(payload);
75101
+ const p2 = asRecord19(payload);
74710
75102
  const ok = ctx.providers.deleteCustomPlatform(String(p2.id ?? ""));
74711
75103
  if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
74712
75104
  return { result: { ok: true } };
@@ -74719,7 +75111,7 @@ function handleProviderExportBundle(ctx) {
74719
75111
  function handleProviderListModels(payload, ctx) {
74720
75112
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
74721
75113
  if (denied) return denied;
74722
- const p2 = asRecord18(payload);
75114
+ const p2 = asRecord19(payload);
74723
75115
  const harness = String(p2.harness ?? p2.harnessId ?? "claude");
74724
75116
  const apiProviderId = typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
74725
75117
  return {
@@ -74731,7 +75123,7 @@ function handleProviderListModels(payload, ctx) {
74731
75123
  function handleProviderImportBundle(payload, ctx) {
74732
75124
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74733
75125
  if (denied) return denied;
74734
- const p2 = asRecord18(payload);
75126
+ const p2 = asRecord19(payload);
74735
75127
  const bundle = p2.bundle && typeof p2.bundle === "object" ? p2.bundle : p2;
74736
75128
  const replaceAll = p2.replaceAll === true;
74737
75129
  try {
@@ -74796,7 +75188,7 @@ function handleHarnessList(ctx) {
74796
75188
  function handleHarnessShow(payload, ctx) {
74797
75189
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74798
75190
  if (denied) return denied;
74799
- const p2 = asRecord18(payload);
75191
+ const p2 = asRecord19(payload);
74800
75192
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74801
75193
  if (!isNodeHarnessId(id)) {
74802
75194
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74806,7 +75198,7 @@ function handleHarnessShow(payload, ctx) {
74806
75198
  function handleHarnessProbe(payload, ctx) {
74807
75199
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74808
75200
  if (denied) return denied;
74809
- const p2 = asRecord18(payload);
75201
+ const p2 = asRecord19(payload);
74810
75202
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74811
75203
  if (!isNodeHarnessId(id)) {
74812
75204
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74821,7 +75213,7 @@ function handleHarnessProbe(payload, ctx) {
74821
75213
  async function handleHarnessEnable(payload, ctx) {
74822
75214
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74823
75215
  if (denied) return denied;
74824
- const p2 = asRecord18(payload);
75216
+ const p2 = asRecord19(payload);
74825
75217
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74826
75218
  if (!isNodeHarnessId(id)) {
74827
75219
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74847,7 +75239,7 @@ async function handleHarnessEnable(payload, ctx) {
74847
75239
  function handleHarnessDisable(payload, ctx) {
74848
75240
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74849
75241
  if (denied) return denied;
74850
- const p2 = asRecord18(payload);
75242
+ const p2 = asRecord19(payload);
74851
75243
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74852
75244
  if (!isNodeHarnessId(id)) {
74853
75245
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74912,7 +75304,7 @@ function handleSettingsGet(ctx) {
74912
75304
  function handleSettingsPatch(payload, ctx) {
74913
75305
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74914
75306
  if (denied) return denied;
74915
- const p2 = asRecord18(payload);
75307
+ const p2 = asRecord19(payload);
74916
75308
  const rawPatch = p2.patch && typeof p2.patch === "object" ? p2.patch : p2;
74917
75309
  try {
74918
75310
  const settings = patchNodeAgentSettings(
@@ -74933,13 +75325,13 @@ async function handleSandboxProbe(ctx) {
74933
75325
  return mapThrown7(err);
74934
75326
  }
74935
75327
  }
74936
- function asRecord18(payload) {
75328
+ function asRecord19(payload) {
74937
75329
  return payload && typeof payload === "object" ? payload : {};
74938
75330
  }
74939
75331
  function handleTerminalCreate(payload, ctx) {
74940
75332
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74941
75333
  if (denied) return denied;
74942
- const p2 = asRecord18(payload);
75334
+ const p2 = asRecord19(payload);
74943
75335
  const cwd = typeof p2.cwd === "string" ? p2.cwd : process.cwd();
74944
75336
  try {
74945
75337
  const info = ctx.terminals.create({
@@ -74964,7 +75356,7 @@ function handleTerminalCreate(payload, ctx) {
74964
75356
  function handleTerminalAttach(payload, ctx) {
74965
75357
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74966
75358
  if (denied) return denied;
74967
- const p2 = asRecord18(payload);
75359
+ const p2 = asRecord19(payload);
74968
75360
  const terminalId = String(p2.terminalId ?? "");
74969
75361
  try {
74970
75362
  const attached = ctx.terminals.attach(terminalId);
@@ -74976,7 +75368,7 @@ function handleTerminalAttach(payload, ctx) {
74976
75368
  function handleTerminalRead(payload, ctx) {
74977
75369
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74978
75370
  if (denied) return denied;
74979
- const p2 = asRecord18(payload);
75371
+ const p2 = asRecord19(payload);
74980
75372
  try {
74981
75373
  return {
74982
75374
  result: ctx.terminals.readAfter(
@@ -75004,7 +75396,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
75004
75396
  function handleTerminalWrite(payload, ctx) {
75005
75397
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75006
75398
  if (denied) return denied;
75007
- const p2 = asRecord18(payload);
75399
+ const p2 = asRecord19(payload);
75008
75400
  const terminalId = String(p2.terminalId ?? "");
75009
75401
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
75010
75402
  if (leaseErr) return leaseErr;
@@ -75022,7 +75414,7 @@ function handleTerminalWrite(payload, ctx) {
75022
75414
  function handleTerminalResize(payload, ctx) {
75023
75415
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75024
75416
  if (denied) return denied;
75025
- const p2 = asRecord18(payload);
75417
+ const p2 = asRecord19(payload);
75026
75418
  const terminalId = String(p2.terminalId ?? "");
75027
75419
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
75028
75420
  if (leaseErr) return leaseErr;
@@ -75038,7 +75430,7 @@ function handleTerminalResize(payload, ctx) {
75038
75430
  function handleTerminalKill(payload, ctx) {
75039
75431
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75040
75432
  if (denied) return denied;
75041
- const p2 = asRecord18(payload);
75433
+ const p2 = asRecord19(payload);
75042
75434
  const terminalId = String(p2.terminalId ?? "");
75043
75435
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
75044
75436
  if (leaseErr) return leaseErr;
@@ -75052,7 +75444,7 @@ function handleTerminalKill(payload, ctx) {
75052
75444
  function handleTerminalAcquireControl(payload, ctx) {
75053
75445
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75054
75446
  if (denied) return denied;
75055
- const p2 = asRecord18(payload);
75447
+ const p2 = asRecord19(payload);
75056
75448
  const terminalId = String(p2.terminalId ?? "");
75057
75449
  try {
75058
75450
  return {
@@ -75069,7 +75461,7 @@ function handleTerminalAcquireControl(payload, ctx) {
75069
75461
  function handleTerminalRenewControl(payload, ctx) {
75070
75462
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75071
75463
  if (denied) return denied;
75072
- const p2 = asRecord18(payload);
75464
+ const p2 = asRecord19(payload);
75073
75465
  try {
75074
75466
  return {
75075
75467
  result: ctx.leases.renew({
@@ -75086,7 +75478,7 @@ function handleTerminalRenewControl(payload, ctx) {
75086
75478
  function handleTerminalReleaseControl(payload, ctx) {
75087
75479
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75088
75480
  if (denied) return denied;
75089
- const p2 = asRecord18(payload);
75481
+ const p2 = asRecord19(payload);
75090
75482
  try {
75091
75483
  ctx.leases.release(
75092
75484
  String(p2.leaseId ?? ""),
@@ -75111,7 +75503,7 @@ function handleProjectList(ctx) {
75111
75503
  function handleProjectGet(payload, ctx) {
75112
75504
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
75113
75505
  if (denied) return denied;
75114
- const p2 = asRecord18(payload);
75506
+ const p2 = asRecord19(payload);
75115
75507
  const projectId = String(p2.projectId ?? "");
75116
75508
  return { result: ctx.projects.get(projectId) };
75117
75509
  }
@@ -75127,7 +75519,7 @@ function expandHostPath(path) {
75127
75519
  function handleProjectOpen(payload, ctx) {
75128
75520
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75129
75521
  if (denied) return denied;
75130
- const p2 = asRecord18(payload);
75522
+ const p2 = asRecord19(payload);
75131
75523
  const path = expandHostPath(String(p2.path ?? ""));
75132
75524
  if (!path) {
75133
75525
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -75145,7 +75537,7 @@ function handleProjectOpen(payload, ctx) {
75145
75537
  function handleProjectRemove(payload, ctx) {
75146
75538
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75147
75539
  if (denied) return denied;
75148
- const p2 = asRecord18(payload);
75540
+ const p2 = asRecord19(payload);
75149
75541
  const projectId = typeof p2.projectId === "string" && p2.projectId ? p2.projectId : void 0;
75150
75542
  const pathRaw = typeof p2.path === "string" && p2.path ? expandHostPath(p2.path) : void 0;
75151
75543
  if (!projectId && !pathRaw) {
@@ -75164,7 +75556,7 @@ function handleProjectRemove(payload, ctx) {
75164
75556
  function handleFsListDir(payload, ctx) {
75165
75557
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75166
75558
  if (denied) return denied;
75167
- const p2 = asRecord18(payload);
75559
+ const p2 = asRecord19(payload);
75168
75560
  const raw = String(p2.path ?? "");
75169
75561
  if (!raw || raw.includes("\0")) {
75170
75562
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -75190,7 +75582,7 @@ function handleFsListDir(payload, ctx) {
75190
75582
  function handleWorkspaceListDir(payload, ctx) {
75191
75583
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75192
75584
  if (denied) return denied;
75193
- const p2 = asRecord18(payload);
75585
+ const p2 = asRecord19(payload);
75194
75586
  try {
75195
75587
  return {
75196
75588
  result: ctx.workspaceFs.listDir(String(p2.projectId ?? ""), String(p2.relativePath ?? "."))
@@ -75202,7 +75594,7 @@ function handleWorkspaceListDir(payload, ctx) {
75202
75594
  function handleWorkspaceListFiles(payload, ctx) {
75203
75595
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75204
75596
  if (denied) return denied;
75205
- const p2 = asRecord18(payload);
75597
+ const p2 = asRecord19(payload);
75206
75598
  try {
75207
75599
  return {
75208
75600
  result: {
@@ -75220,7 +75612,7 @@ function handleWorkspaceListFiles(payload, ctx) {
75220
75612
  function handleWorkspaceListSkills(payload, ctx) {
75221
75613
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75222
75614
  if (denied) return denied;
75223
- const p2 = asRecord18(payload);
75615
+ const p2 = asRecord19(payload);
75224
75616
  try {
75225
75617
  return {
75226
75618
  result: ctx.workspaceFs.listSkillsAndCommands(String(p2.projectId ?? ""))
@@ -75232,7 +75624,7 @@ function handleWorkspaceListSkills(payload, ctx) {
75232
75624
  function handleWorkspaceReadFile(payload, ctx) {
75233
75625
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75234
75626
  if (denied) return denied;
75235
- const p2 = asRecord18(payload);
75627
+ const p2 = asRecord19(payload);
75236
75628
  try {
75237
75629
  return {
75238
75630
  result: ctx.workspaceFs.readFile(String(p2.projectId ?? ""), String(p2.relativePath ?? ""), {
@@ -75247,7 +75639,7 @@ function handleWorkspaceReadFile(payload, ctx) {
75247
75639
  function handleWorkspaceWriteFile(payload, ctx) {
75248
75640
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75249
75641
  if (denied) return denied;
75250
- const p2 = asRecord18(payload);
75642
+ const p2 = asRecord19(payload);
75251
75643
  const raw = typeof p2.content === "string" ? p2.content : String(p2.content ?? "");
75252
75644
  const encoding = p2.encoding === "base64" ? "base64" : "utf8";
75253
75645
  let content = raw;
@@ -75277,7 +75669,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
75277
75669
  function handleWorkspaceSearch(payload, ctx) {
75278
75670
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75279
75671
  if (denied) return denied;
75280
- const p2 = asRecord18(payload);
75672
+ const p2 = asRecord19(payload);
75281
75673
  try {
75282
75674
  return {
75283
75675
  result: ctx.workspaceFs.search(
@@ -75293,7 +75685,7 @@ function handleWorkspaceSearch(payload, ctx) {
75293
75685
  function handleWorkspaceRename(payload, ctx) {
75294
75686
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75295
75687
  if (denied) return denied;
75296
- const p2 = asRecord18(payload);
75688
+ const p2 = asRecord19(payload);
75297
75689
  try {
75298
75690
  return {
75299
75691
  result: ctx.workspaceFs.rename(
@@ -75309,7 +75701,7 @@ function handleWorkspaceRename(payload, ctx) {
75309
75701
  function handleWorkspaceMove(payload, ctx) {
75310
75702
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75311
75703
  if (denied) return denied;
75312
- const p2 = asRecord18(payload);
75704
+ const p2 = asRecord19(payload);
75313
75705
  try {
75314
75706
  return {
75315
75707
  result: ctx.workspaceFs.move(
@@ -75325,7 +75717,7 @@ function handleWorkspaceMove(payload, ctx) {
75325
75717
  function handleWorkspaceDelete(payload, ctx) {
75326
75718
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75327
75719
  if (denied) return denied;
75328
- const p2 = asRecord18(payload);
75720
+ const p2 = asRecord19(payload);
75329
75721
  try {
75330
75722
  return {
75331
75723
  result: ctx.workspaceFs.delete(
@@ -75340,7 +75732,7 @@ function handleWorkspaceDelete(payload, ctx) {
75340
75732
  function handleWorkspaceMkdir(payload, ctx) {
75341
75733
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75342
75734
  if (denied) return denied;
75343
- const p2 = asRecord18(payload);
75735
+ const p2 = asRecord19(payload);
75344
75736
  try {
75345
75737
  return {
75346
75738
  result: ctx.workspaceFs.mkdir(
@@ -75355,7 +75747,7 @@ function handleWorkspaceMkdir(payload, ctx) {
75355
75747
  function handleWorkspaceWatchStart(payload, ctx) {
75356
75748
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75357
75749
  if (denied) return denied;
75358
- const p2 = asRecord18(payload);
75750
+ const p2 = asRecord19(payload);
75359
75751
  try {
75360
75752
  const events = [];
75361
75753
  const { watchId, cancel } = ctx.workspaceWatch.subscribe(
@@ -75376,7 +75768,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
75376
75768
  function handleWorkspaceWatchPoll(payload, ctx) {
75377
75769
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75378
75770
  if (denied) return denied;
75379
- const p2 = asRecord18(payload);
75771
+ const p2 = asRecord19(payload);
75380
75772
  const watchId = String(p2.watchId ?? "");
75381
75773
  const buf = watchBuffers.get(watchId);
75382
75774
  if (!buf || buf.owner !== ctx.client.clientSessionId) {
@@ -75388,7 +75780,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
75388
75780
  function handleWorkspaceWatchStop(payload, ctx) {
75389
75781
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75390
75782
  if (denied) return denied;
75391
- const p2 = asRecord18(payload);
75783
+ const p2 = asRecord19(payload);
75392
75784
  const watchId = String(p2.watchId ?? "");
75393
75785
  const buf = watchBuffers.get(watchId);
75394
75786
  if (buf && buf.owner === ctx.client.clientSessionId) {
@@ -75400,7 +75792,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
75400
75792
  function handleWorkspaceTailWatchStart(payload, ctx) {
75401
75793
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75402
75794
  if (denied) return denied;
75403
- const p2 = asRecord18(payload);
75795
+ const p2 = asRecord19(payload);
75404
75796
  try {
75405
75797
  const offset = typeof p2.offset === "number" ? p2.offset : void 0;
75406
75798
  const absolutePath = typeof p2.absolutePath === "string" ? p2.absolutePath : void 0;
@@ -75418,7 +75810,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
75418
75810
  function handleWorkspaceTailWatchPoll(payload, ctx) {
75419
75811
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75420
75812
  if (denied) return denied;
75421
- const p2 = asRecord18(payload);
75813
+ const p2 = asRecord19(payload);
75422
75814
  try {
75423
75815
  return {
75424
75816
  result: ctx.workspaceTailWatch.poll(String(p2.watchId ?? ""), ctx.client.clientSessionId)
@@ -75430,7 +75822,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
75430
75822
  function handleWorkspaceTailWatchStop(payload, ctx) {
75431
75823
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75432
75824
  if (denied) return denied;
75433
- const p2 = asRecord18(payload);
75825
+ const p2 = asRecord19(payload);
75434
75826
  try {
75435
75827
  return {
75436
75828
  result: ctx.workspaceTailWatch.stop(String(p2.watchId ?? ""), ctx.client.clientSessionId)
@@ -75442,7 +75834,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
75442
75834
  function handleGitStatus(payload, ctx) {
75443
75835
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75444
75836
  if (denied) return denied;
75445
- const p2 = asRecord18(payload);
75837
+ const p2 = asRecord19(payload);
75446
75838
  try {
75447
75839
  const projectId = String(p2.projectId ?? "");
75448
75840
  const cwd = typeof p2.cwd === "string" ? p2.cwd : null;
@@ -75456,7 +75848,7 @@ function handleGitStatus(payload, ctx) {
75456
75848
  function handleGitDiff(payload, ctx) {
75457
75849
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75458
75850
  if (denied) return denied;
75459
- const p2 = asRecord18(payload);
75851
+ const p2 = asRecord19(payload);
75460
75852
  try {
75461
75853
  return {
75462
75854
  result: ctx.workspaceGit.diff(String(p2.projectId ?? ""), {
@@ -75471,7 +75863,7 @@ function handleGitDiff(payload, ctx) {
75471
75863
  function handleGitBranches(payload, ctx) {
75472
75864
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75473
75865
  if (denied) return denied;
75474
- const p2 = asRecord18(payload);
75866
+ const p2 = asRecord19(payload);
75475
75867
  try {
75476
75868
  return {
75477
75869
  result: ctx.workspaceGit.branches(
@@ -75486,7 +75878,7 @@ function handleGitBranches(payload, ctx) {
75486
75878
  function handleGitSwitchBranch(payload, ctx) {
75487
75879
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75488
75880
  if (denied) return denied;
75489
- const p2 = asRecord18(payload);
75881
+ const p2 = asRecord19(payload);
75490
75882
  try {
75491
75883
  return {
75492
75884
  result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
@@ -75501,7 +75893,7 @@ function handleGitSwitchBranch(payload, ctx) {
75501
75893
  function handleGitCreateBranch(payload, ctx) {
75502
75894
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75503
75895
  if (denied) return denied;
75504
- const p2 = asRecord18(payload);
75896
+ const p2 = asRecord19(payload);
75505
75897
  try {
75506
75898
  return {
75507
75899
  result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
@@ -75516,7 +75908,7 @@ function handleGitCreateBranch(payload, ctx) {
75516
75908
  function handleGitWorktrees(payload, ctx) {
75517
75909
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75518
75910
  if (denied) return denied;
75519
- const p2 = asRecord18(payload);
75911
+ const p2 = asRecord19(payload);
75520
75912
  try {
75521
75913
  return { result: ctx.workspaceGit.worktrees(String(p2.projectId ?? "")) };
75522
75914
  } catch (err) {
@@ -75526,7 +75918,7 @@ function handleGitWorktrees(payload, ctx) {
75526
75918
  function handleGitWorktreeActivate(payload, ctx) {
75527
75919
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75528
75920
  if (denied) return denied;
75529
- const p2 = asRecord18(payload);
75921
+ const p2 = asRecord19(payload);
75530
75922
  const mode = p2.mode === "attach" || p2.mode === "detach" || p2.mode === "branch" ? p2.mode : null;
75531
75923
  if (!mode) {
75532
75924
  return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
@@ -75547,7 +75939,7 @@ function handleGitWorktreeActivate(payload, ctx) {
75547
75939
  function handleGitWorktreeCheckedOutBranches(payload, ctx) {
75548
75940
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75549
75941
  if (denied) return denied;
75550
- const p2 = asRecord18(payload);
75942
+ const p2 = asRecord19(payload);
75551
75943
  try {
75552
75944
  return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p2.projectId ?? "")) } };
75553
75945
  } catch (err) {
@@ -75557,7 +75949,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
75557
75949
  function handleGitWorktreeAssignBranch(payload, ctx) {
75558
75950
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75559
75951
  if (denied) return denied;
75560
- const p2 = asRecord18(payload);
75952
+ const p2 = asRecord19(payload);
75561
75953
  try {
75562
75954
  return {
75563
75955
  result: ctx.workspaceGit.assignBranch(
@@ -75573,7 +75965,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
75573
75965
  function handleGitWorktreeHandoff(payload, ctx) {
75574
75966
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75575
75967
  if (denied) return denied;
75576
- const p2 = asRecord18(payload);
75968
+ const p2 = asRecord19(payload);
75577
75969
  try {
75578
75970
  return {
75579
75971
  result: ctx.workspaceGit.handoffToMain(
@@ -75588,7 +75980,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
75588
75980
  function handleGitWorktreeHandoffPreview(payload, ctx) {
75589
75981
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75590
75982
  if (denied) return denied;
75591
- const p2 = asRecord18(payload);
75983
+ const p2 = asRecord19(payload);
75592
75984
  try {
75593
75985
  return {
75594
75986
  result: ctx.workspaceGit.handoffPreview(
@@ -75603,7 +75995,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
75603
75995
  function handleSessionSetCwd(payload, ctx) {
75604
75996
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75605
75997
  if (denied) return denied;
75606
- const p2 = asRecord18(payload);
75998
+ const p2 = asRecord19(payload);
75607
75999
  const sessionId = String(p2.sessionId ?? "");
75608
76000
  const cwdRaw = p2.cwd;
75609
76001
  const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
@@ -75632,7 +76024,7 @@ function handleSessionSetCwd(payload, ctx) {
75632
76024
  function handleSessionPatchSettings(payload, ctx) {
75633
76025
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75634
76026
  if (denied) return denied;
75635
- const p2 = asRecord18(payload);
76027
+ const p2 = asRecord19(payload);
75636
76028
  const sessionId = String(p2.sessionId ?? "").trim();
75637
76029
  if (!sessionId) {
75638
76030
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75648,7 +76040,7 @@ function handleSessionPatchSettings(payload, ctx) {
75648
76040
  generation: String(p2.generation ?? ""),
75649
76041
  holderClientId: ctx.client.clientSessionId
75650
76042
  });
75651
- const settingsSrc = asRecord18(p2.settings ?? p2);
76043
+ const settingsSrc = asRecord19(p2.settings ?? p2);
75652
76044
  const patch = {};
75653
76045
  const take = (key) => {
75654
76046
  if (!(key in settingsSrc)) return;
@@ -75674,7 +76066,7 @@ function handleSessionPatchSettings(payload, ctx) {
75674
76066
  async function handleSessionFork(payload, ctx) {
75675
76067
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75676
76068
  if (denied) return denied;
75677
- const p2 = asRecord18(payload);
76069
+ const p2 = asRecord19(payload);
75678
76070
  const sessionId = String(p2.sessionId ?? "").trim();
75679
76071
  if (!sessionId) {
75680
76072
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75761,7 +76153,7 @@ async function handleSessionFork(payload, ctx) {
75761
76153
  async function handleGitClone(payload, ctx) {
75762
76154
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75763
76155
  if (denied) return denied;
75764
- const p2 = asRecord18(payload);
76156
+ const p2 = asRecord19(payload);
75765
76157
  try {
75766
76158
  const cloned = await cloneRepository({
75767
76159
  remoteUrl: String(p2.remoteUrl ?? ""),
@@ -75777,7 +76169,7 @@ async function handleGitClone(payload, ctx) {
75777
76169
  function handleSessionCreate(payload, ctx) {
75778
76170
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75779
76171
  if (denied) return denied;
75780
- const p2 = asRecord18(payload);
76172
+ const p2 = asRecord19(payload);
75781
76173
  const rawHarnessId = typeof p2.harnessId === "string" ? p2.harnessId : "claude";
75782
76174
  const harnessId = normalizeSessionHarnessId(rawHarnessId);
75783
76175
  if (!harnessId) {
@@ -75830,7 +76222,7 @@ function handleSessionCreate(payload, ctx) {
75830
76222
  try {
75831
76223
  const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
75832
76224
  const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
75833
- const options = asRecord18(p2.options);
76225
+ const options = asRecord19(p2.options);
75834
76226
  const providerId = typeof p2.providerId === "string" && p2.providerId.trim() ? p2.providerId.trim() : void 0;
75835
76227
  const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
75836
76228
  const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
@@ -75891,13 +76283,13 @@ function handleSessionCreate(payload, ctx) {
75891
76283
  function handleSessionGet(payload, ctx) {
75892
76284
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75893
76285
  if (denied) return denied;
75894
- const p2 = asRecord18(payload);
76286
+ const p2 = asRecord19(payload);
75895
76287
  return { result: ctx.sessions.get(String(p2.sessionId ?? "")) };
75896
76288
  }
75897
76289
  function handleSessionList(payload, ctx) {
75898
76290
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75899
76291
  if (denied) return denied;
75900
- const p2 = asRecord18(payload);
76292
+ const p2 = asRecord19(payload);
75901
76293
  const projectId = typeof p2.projectId === "string" ? p2.projectId : void 0;
75902
76294
  if (typeof p2.limit !== "number" || !Number.isFinite(p2.limit)) {
75903
76295
  return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
@@ -75937,7 +76329,7 @@ function handleSessionList(payload, ctx) {
75937
76329
  function handleSessionAcquireControl(payload, ctx) {
75938
76330
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75939
76331
  if (denied) return denied;
75940
- const p2 = asRecord18(payload);
76332
+ const p2 = asRecord19(payload);
75941
76333
  const sessionId = String(p2.sessionId ?? "");
75942
76334
  if (!sessionId) {
75943
76335
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75961,7 +76353,7 @@ function handleSessionAcquireControl(payload, ctx) {
75961
76353
  function handleSessionRenewControl(payload, ctx) {
75962
76354
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75963
76355
  if (denied) return denied;
75964
- const p2 = asRecord18(payload);
76356
+ const p2 = asRecord19(payload);
75965
76357
  try {
75966
76358
  return {
75967
76359
  result: ctx.leases.renew({
@@ -75978,7 +76370,7 @@ function handleSessionRenewControl(payload, ctx) {
75978
76370
  function handleSessionReleaseControl(payload, ctx) {
75979
76371
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75980
76372
  if (denied) return denied;
75981
- const p2 = asRecord18(payload);
76373
+ const p2 = asRecord19(payload);
75982
76374
  try {
75983
76375
  ctx.leases.release(
75984
76376
  String(p2.leaseId ?? ""),
@@ -75993,7 +76385,7 @@ function handleSessionReleaseControl(payload, ctx) {
75993
76385
  function handleSessionClose(payload, ctx) {
75994
76386
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75995
76387
  if (denied) return denied;
75996
- const p2 = asRecord18(payload);
76388
+ const p2 = asRecord19(payload);
75997
76389
  const sessionId = String(p2.sessionId ?? "");
75998
76390
  try {
75999
76391
  ctx.leases.assertValid({
@@ -76019,7 +76411,7 @@ function handleSessionClose(payload, ctx) {
76019
76411
  function handleSessionRemove(payload, ctx) {
76020
76412
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76021
76413
  if (denied) return denied;
76022
- const p2 = asRecord18(payload);
76414
+ const p2 = asRecord19(payload);
76023
76415
  const sessionId = String(p2.sessionId ?? "");
76024
76416
  if (!sessionId) {
76025
76417
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76046,7 +76438,7 @@ function handleSessionRemove(payload, ctx) {
76046
76438
  function handleSessionRename(payload, ctx) {
76047
76439
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76048
76440
  if (denied) return denied;
76049
- const p2 = asRecord18(payload);
76441
+ const p2 = asRecord19(payload);
76050
76442
  const sessionId = String(p2.sessionId ?? "");
76051
76443
  const title = String(p2.title ?? "");
76052
76444
  const source = p2.source === "agent" ? "agent" : "user";
@@ -76062,7 +76454,7 @@ function handleSessionRename(payload, ctx) {
76062
76454
  function handleSessionSetTags(payload, ctx) {
76063
76455
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76064
76456
  if (denied) return denied;
76065
- const p2 = asRecord18(payload);
76457
+ const p2 = asRecord19(payload);
76066
76458
  const sessionId = String(p2.sessionId ?? "");
76067
76459
  if (!sessionId) {
76068
76460
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76088,7 +76480,7 @@ function handleSessionSetTags(payload, ctx) {
76088
76480
  function handleSessionSetUiFlags(payload, ctx) {
76089
76481
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76090
76482
  if (denied) return denied;
76091
- const p2 = asRecord18(payload);
76483
+ const p2 = asRecord19(payload);
76092
76484
  const sessionId = String(p2.sessionId ?? "");
76093
76485
  if (!sessionId) {
76094
76486
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76107,9 +76499,9 @@ function handleSessionSetUiFlags(payload, ctx) {
76107
76499
  async function handleSessionSend(payload, ctx) {
76108
76500
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76109
76501
  if (denied) return denied;
76110
- const p2 = asRecord18(payload);
76502
+ const p2 = asRecord19(payload);
76111
76503
  try {
76112
- const options = asRecord18(p2.options);
76504
+ const options = asRecord19(p2.options);
76113
76505
  const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
76114
76506
  const modelTopLevel = typeof p2.model === "string" && p2.model.trim() ? p2.model.trim() : null;
76115
76507
  const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
@@ -76202,7 +76594,7 @@ async function handleSessionSend(payload, ctx) {
76202
76594
  function handleSessionInterrupt(payload, ctx) {
76203
76595
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76204
76596
  if (denied) return denied;
76205
- const p2 = asRecord18(payload);
76597
+ const p2 = asRecord19(payload);
76206
76598
  try {
76207
76599
  ctx.sessions.interrupt(
76208
76600
  String(p2.sessionId ?? ""),
@@ -76218,7 +76610,7 @@ function handleSessionInterrupt(payload, ctx) {
76218
76610
  function handleSessionRespondPermission(payload, ctx) {
76219
76611
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76220
76612
  if (denied) return denied;
76221
- const p2 = asRecord18(payload);
76613
+ const p2 = asRecord19(payload);
76222
76614
  try {
76223
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;
76224
76616
  ctx.sessions.respondPermission({
@@ -76239,7 +76631,7 @@ function handleSessionRespondPermission(payload, ctx) {
76239
76631
  function handleSessionRespondQuestion(payload, ctx) {
76240
76632
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76241
76633
  if (denied) return denied;
76242
- const p2 = asRecord18(payload);
76634
+ const p2 = asRecord19(payload);
76243
76635
  try {
76244
76636
  ctx.sessions.respondQuestion({
76245
76637
  sessionId: String(p2.sessionId ?? ""),
@@ -76257,7 +76649,7 @@ function handleSessionRespondQuestion(payload, ctx) {
76257
76649
  function handleSessionRespondPlan(payload, ctx) {
76258
76650
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76259
76651
  if (denied) return denied;
76260
- const p2 = asRecord18(payload);
76652
+ const p2 = asRecord19(payload);
76261
76653
  const decision = p2.decision === "approve" || p2.decision === "reject" ? p2.decision : null;
76262
76654
  if (!decision) {
76263
76655
  return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
@@ -76280,7 +76672,7 @@ function handleSessionRespondPlan(payload, ctx) {
76280
76672
  async function handleSessionHostActionsPoll(payload, ctx) {
76281
76673
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76282
76674
  if (denied) return denied;
76283
- const p2 = asRecord18(payload);
76675
+ const p2 = asRecord19(payload);
76284
76676
  try {
76285
76677
  const result = await ctx.sessions.pollHostActions({
76286
76678
  controllerClientSessionId: ctx.client.clientSessionId,
@@ -76296,7 +76688,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
76296
76688
  function handleSessionClaimHostAction(payload, ctx) {
76297
76689
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76298
76690
  if (denied) return denied;
76299
- const p2 = asRecord18(payload);
76691
+ const p2 = asRecord19(payload);
76300
76692
  try {
76301
76693
  const result = ctx.sessions.claimHostAction({
76302
76694
  actionId: String(p2.actionId ?? ""),
@@ -76312,7 +76704,7 @@ function handleSessionClaimHostAction(payload, ctx) {
76312
76704
  function handleSessionRespondHostAction(payload, ctx) {
76313
76705
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76314
76706
  if (denied) return denied;
76315
- const p2 = asRecord18(payload);
76707
+ const p2 = asRecord19(payload);
76316
76708
  const outcome = p2.outcome === "failed" ? "failed" : p2.outcome === "succeeded" ? "succeeded" : null;
76317
76709
  if (!outcome) {
76318
76710
  return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
@@ -76334,14 +76726,14 @@ function handleSessionRespondHostAction(payload, ctx) {
76334
76726
  function handleSessionEvents(payload, ctx) {
76335
76727
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76336
76728
  if (denied) return denied;
76337
- const p2 = asRecord18(payload);
76729
+ const p2 = asRecord19(payload);
76338
76730
  const after = String(p2.afterSequence ?? "0");
76339
76731
  return { result: { events: ctx.sessions.listEventsAfter(after) } };
76340
76732
  }
76341
76733
  function handleSessionMessagesList(payload, ctx) {
76342
76734
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76343
76735
  if (denied) return denied;
76344
- const p2 = asRecord18(payload);
76736
+ const p2 = asRecord19(payload);
76345
76737
  const sessionId = String(p2.sessionId ?? "").trim();
76346
76738
  if (!sessionId) {
76347
76739
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76380,7 +76772,7 @@ function handleCollaborationListProfiles(ctx) {
76380
76772
  async function handleCollaborationRequest(payload, ctx) {
76381
76773
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76382
76774
  if (denied) return denied;
76383
- const p2 = asRecord18(payload);
76775
+ const p2 = asRecord19(payload);
76384
76776
  const parentSessionId = String(p2.parentSessionId ?? "");
76385
76777
  if (!parentSessionId) {
76386
76778
  return { error: { code: "invalid_argument", message: "parentSessionId required" } };
@@ -76414,7 +76806,7 @@ async function handleCollaborationRequest(payload, ctx) {
76414
76806
  async function handleCollaborationStart(payload, ctx) {
76415
76807
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76416
76808
  if (denied) return denied;
76417
- const p2 = asRecord18(payload);
76809
+ const p2 = asRecord19(payload);
76418
76810
  const credential = typeof p2.credential === "string" ? p2.credential : void 0;
76419
76811
  const grantId = typeof p2.grantId === "string" ? p2.grantId : void 0;
76420
76812
  if (!credential && !grantId) {
@@ -76460,7 +76852,7 @@ async function handleCollaborationStart(payload, ctx) {
76460
76852
  function handleCollaborationSend(payload, ctx) {
76461
76853
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76462
76854
  if (denied) return denied;
76463
- const p2 = asRecord18(payload);
76855
+ const p2 = asRecord19(payload);
76464
76856
  const credential = String(p2.credential ?? "");
76465
76857
  const sessionId = String(p2.sessionId ?? p2.fromSessionId ?? "");
76466
76858
  const content = typeof p2.content === "string" ? p2.content : p2.body !== void 0 ? typeof p2.body === "string" ? p2.body : JSON.stringify(p2.body) : "";
@@ -76496,7 +76888,7 @@ function handleCollaborationSend(payload, ctx) {
76496
76888
  function handleCollaborationRetrieve(payload, ctx) {
76497
76889
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76498
76890
  if (denied) return denied;
76499
- const p2 = asRecord18(payload);
76891
+ const p2 = asRecord19(payload);
76500
76892
  const credential = String(p2.credential ?? "");
76501
76893
  const sessionId = String(p2.sessionId ?? "");
76502
76894
  if (!credential) {
@@ -77343,7 +77735,7 @@ import { existsSync as existsSync29, mkdirSync as mkdirSync18, readFileSync as r
77343
77735
  import { arch as osArch2, platform as osPlatform2 } from "node:os";
77344
77736
  import { join as join27, resolve as resolve7 } from "node:path";
77345
77737
  var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.238";
77346
- var OFFICIAL_CODEX_NPM_VERSION = "0.147.0";
77738
+ var OFFICIAL_CODEX_NPM_VERSION = "0.149.0";
77347
77739
  var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
77348
77740
  function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
77349
77741
  const platform2 = process.platform;