@super-one/cli 0.63.0 → 0.64.0-alpha.1

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 +445 -309
  3. package/package.json +16 -16
package/lib/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- process.env.SUPERONE_VARIANT = "stable";
1
+ process.env.SUPERONE_VARIANT = "alpha";
2
2
  import { createRequire as __superoneCreateRequire } from 'node:module';
3
3
  import { fileURLToPath as __superoneFileURLToPath } from 'node:url';
4
4
  import { dirname as __superoneDirname } from 'node:path';
@@ -19968,6 +19968,42 @@ Rename again when the user approves a plan, when the topic changes substantially
19968
19968
  }
19969
19969
  });
19970
19970
 
19971
+ // ../../packages/codex/src/server-request.ts
19972
+ function isKnownCodexServerRequest(method) {
19973
+ return KNOWN_APPROVAL_METHODS.has(method);
19974
+ }
19975
+ function isCodexUserVerificationElicitation(params) {
19976
+ return params?.mode === "openai/userVerification";
19977
+ }
19978
+ function jsonRpcMethodNotFound(id) {
19979
+ return {
19980
+ jsonrpc: "2.0",
19981
+ id,
19982
+ error: { code: JSON_RPC_METHOD_NOT_FOUND, message: "Method not found" }
19983
+ };
19984
+ }
19985
+ function elicitationCancelResult() {
19986
+ return { action: "cancel", content: null, _meta: null };
19987
+ }
19988
+ function approvalDenyResult() {
19989
+ return { decision: "deny", outcome: { decision: "deny" } };
19990
+ }
19991
+ var JSON_RPC_METHOD_NOT_FOUND, KNOWN_APPROVAL_METHODS;
19992
+ var init_server_request = __esm({
19993
+ "../../packages/codex/src/server-request.ts"() {
19994
+ "use strict";
19995
+ JSON_RPC_METHOD_NOT_FOUND = -32601;
19996
+ KNOWN_APPROVAL_METHODS = /* @__PURE__ */ new Set([
19997
+ "item/commandExecution/requestApproval",
19998
+ "item/fileChange/requestApproval",
19999
+ "item/requestApproval",
20000
+ "mcpServer/elicitation/request",
20001
+ "item/tool/requestUserInput",
20002
+ "tool/requestUserInput"
20003
+ ]);
20004
+ }
20005
+ });
20006
+
19971
20007
  // ../../packages/runtime/src/spawn-env.ts
19972
20008
  function mergeLoopbackNoProxy(env) {
19973
20009
  const existingParts = [];
@@ -20331,10 +20367,26 @@ var init_protocol_v153 = __esm({
20331
20367
  }
20332
20368
  });
20333
20369
 
20334
- // ../../packages/codex/src/agent-event-mapper.ts
20370
+ // ../../packages/codex/src/protocol-v154.ts
20335
20371
  function asRecord3(value) {
20336
20372
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
20337
20373
  }
20374
+ function readCodexMcpWwwAuthenticate(meta3) {
20375
+ const rec = asRecord3(meta3);
20376
+ if (!rec) return void 0;
20377
+ if (rec["mcp/www_authenticate"] !== void 0) return rec["mcp/www_authenticate"];
20378
+ return rec.mcpWwwAuthenticate;
20379
+ }
20380
+ var init_protocol_v154 = __esm({
20381
+ "../../packages/codex/src/protocol-v154.ts"() {
20382
+ "use strict";
20383
+ }
20384
+ });
20385
+
20386
+ // ../../packages/codex/src/agent-event-mapper.ts
20387
+ function asRecord4(value) {
20388
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
20389
+ }
20338
20390
  function readString3(value) {
20339
20391
  return typeof value === "string" && value.length > 0 ? value : null;
20340
20392
  }
@@ -20364,7 +20416,7 @@ function uniqueStrings(values) {
20364
20416
  function readTextPart(value) {
20365
20417
  const direct = readString3(value);
20366
20418
  if (direct !== null) return direct;
20367
- const rec = asRecord3(value);
20419
+ const rec = asRecord4(value);
20368
20420
  if (!rec) return null;
20369
20421
  return readString3(rec.text) ?? readString3(rec.summaryText) ?? readString3(rec.summary_text) ?? readString3(rec.content);
20370
20422
  }
@@ -20373,7 +20425,7 @@ function readTextParts(value) {
20373
20425
  return value.map(readTextPart).filter((entry) => entry !== null && entry.length > 0);
20374
20426
  }
20375
20427
  function readCodexItemId(rec) {
20376
- return readString3(rec.itemId) ?? readString3(rec.item_id) ?? readString3(rec.id) ?? readString3(asRecord3(rec.item)?.id);
20428
+ return readString3(rec.itemId) ?? readString3(rec.item_id) ?? readString3(rec.id) ?? readString3(asRecord4(rec.item)?.id);
20377
20429
  }
20378
20430
  function readCodexDeltaText(rec) {
20379
20431
  return readString3(rec.delta) ?? readString3(rec.textDelta) ?? readString3(rec.text_delta) ?? readString3(rec.summaryTextDelta) ?? readString3(rec.summary_text_delta) ?? readString3(rec.summaryDelta) ?? readString3(rec.summary_delta) ?? readString3(rec.text) ?? readString3(rec.summaryText) ?? readString3(rec.summary_text) ?? "";
@@ -20381,7 +20433,7 @@ function readCodexDeltaText(rec) {
20381
20433
  function mapPatchChangeKind(raw) {
20382
20434
  const direct = readString3(raw);
20383
20435
  if (direct === "add" || direct === "delete" || direct === "update") return direct;
20384
- const kind = readString3(asRecord3(raw)?.type);
20436
+ const kind = readString3(asRecord4(raw)?.type);
20385
20437
  return kind === "add" || kind === "delete" || kind === "update" ? kind : "update";
20386
20438
  }
20387
20439
  function mapCommandExecutionStatus(raw) {
@@ -20459,7 +20511,7 @@ function buildCodexReasoningItem(id, text, previous, now = Date.now) {
20459
20511
  return { id, type: "reasoning", text, startedAt, endedAt: timestamp };
20460
20512
  }
20461
20513
  function mapCodexThreadItem(raw, previous, now = Date.now) {
20462
- const rec = asRecord3(raw);
20514
+ const rec = asRecord4(raw);
20463
20515
  if (!rec) return null;
20464
20516
  const type = readString3(rec.type);
20465
20517
  const id = readString3(rec.id) ?? previous?.id;
@@ -20485,7 +20537,7 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20485
20537
  case "commandExecution": {
20486
20538
  const prev = previous?.type === "command_execution" ? previous : null;
20487
20539
  const actions = Array.isArray(rec.commandActions) ? rec.commandActions.map((entry) => {
20488
- const action = asRecord3(entry);
20540
+ const action = asRecord4(entry);
20489
20541
  if (!action) return null;
20490
20542
  return {
20491
20543
  type: readString3(action.type) ?? "unknown",
@@ -20511,7 +20563,7 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20511
20563
  case "file_change":
20512
20564
  case "fileChange": {
20513
20565
  const changes = Array.isArray(rec.changes) ? rec.changes.map((entry) => {
20514
- const change = asRecord3(entry);
20566
+ const change = asRecord4(entry);
20515
20567
  const path = readString3(change?.path);
20516
20568
  if (!path) return null;
20517
20569
  const diff = readString3(change?.diff);
@@ -20527,19 +20579,25 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20527
20579
  case "mcp_tool_call":
20528
20580
  case "mcpToolCall": {
20529
20581
  const prev = previous?.type === "mcp_tool_call" ? previous : null;
20530
- const result = asRecord3(rec.result);
20531
- const error51 = asRecord3(rec.error);
20582
+ const result = asRecord4(rec.result);
20583
+ const error51 = asRecord4(rec.error);
20584
+ const resultMeta = asRecord4(result?._meta) ?? asRecord4(result?.meta) ?? prev?.result?.meta;
20585
+ const authChallenge = readCodexMcpWwwAuthenticate(resultMeta);
20586
+ const mappedResult = result ? {
20587
+ content: Array.isArray(result.content) ? result.content : [],
20588
+ structuredContent: result.structuredContent ?? result.structured_content ?? null,
20589
+ ...resultMeta ? { meta: resultMeta } : {}
20590
+ } : prev?.result;
20591
+ const mappedError = error51 ? { message: readString3(error51.message) ?? "Unknown MCP tool error" } : authChallenge !== void 0 ? { message: "MCP authentication required" } : prev?.error;
20532
20592
  return {
20533
20593
  id,
20534
20594
  type: "mcp_tool_call",
20535
20595
  server: readString3(rec.server) ?? prev?.server ?? "",
20536
20596
  tool: readString3(rec.tool) ?? prev?.tool ?? "",
20537
20597
  arguments: rec.arguments ?? prev?.arguments ?? {},
20538
- ...result ? { result: {
20539
- content: Array.isArray(result.content) ? result.content : [],
20540
- structuredContent: result.structuredContent ?? result.structured_content ?? null
20541
- } } : prev?.result ? { result: prev.result } : {},
20542
- ...error51 ? { error: { message: readString3(error51.message) ?? "Unknown MCP tool error" } } : prev?.error ? { error: prev.error } : {},
20598
+ ...mappedResult ? { result: mappedResult } : {},
20599
+ ...mappedError ? { error: mappedError } : {},
20600
+ ...authChallenge !== void 0 ? { authRequired: true } : prev?.authRequired ? { authRequired: true } : {},
20543
20601
  status: mapMcpToolCallStatus(rec.status ?? prev?.status)
20544
20602
  };
20545
20603
  }
@@ -20572,7 +20630,7 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20572
20630
  case "todo_list":
20573
20631
  case "todoList": {
20574
20632
  const items = Array.isArray(rec.items) ? rec.items.map((entry) => {
20575
- const todo = asRecord3(entry);
20633
+ const todo = asRecord4(entry);
20576
20634
  const text = readString3(todo?.text);
20577
20635
  return text ? { text, completed: readBoolean(todo?.completed) ?? false } : null;
20578
20636
  }).filter((entry) => entry !== null) : previous?.type === "todo_list" ? previous.items : [];
@@ -20603,10 +20661,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20603
20661
  readString3(rec.newThreadId ?? rec.new_thread_id)
20604
20662
  ]);
20605
20663
  const agentsStates = { ...prev?.agentsStates ?? {} };
20606
- const rawStates = asRecord3(rec.agentsStates ?? rec.agents_states);
20664
+ const rawStates = asRecord4(rec.agentsStates ?? rec.agents_states);
20607
20665
  if (rawStates) {
20608
20666
  for (const [agentId, value] of Object.entries(rawStates)) {
20609
- const state = asRecord3(value);
20667
+ const state = asRecord4(value);
20610
20668
  if (!state) continue;
20611
20669
  const prior = prev?.agentsStates?.[agentId];
20612
20670
  agentsStates[agentId] = {
@@ -20617,7 +20675,7 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20617
20675
  }
20618
20676
  }
20619
20677
  const rawAgentStatus = rec.agentStatus ?? rec.agent_status;
20620
- const agentStatus = asRecord3(rawAgentStatus);
20678
+ const agentStatus = asRecord4(rawAgentStatus);
20621
20679
  if (!rawStates && rawAgentStatus != null) {
20622
20680
  for (const agentId of receiverThreadIds) {
20623
20681
  const prior = prev?.agentsStates?.[agentId];
@@ -20646,10 +20704,10 @@ function mapCodexThreadItem(raw, previous, now = Date.now) {
20646
20704
  }
20647
20705
  }
20648
20706
  function mapCodexUsage(raw) {
20649
- const rec = asRecord3(raw);
20707
+ const rec = asRecord4(raw);
20650
20708
  if (!rec) return null;
20651
20709
  const parse5 = (value) => {
20652
- const data = asRecord3(value);
20710
+ const data = asRecord4(value);
20653
20711
  if (!data) return null;
20654
20712
  return {
20655
20713
  inputTokens: readNumber2(data.inputTokens ?? data.input_tokens) ?? 0,
@@ -20678,9 +20736,9 @@ function mapCodexUsage(raw) {
20678
20736
  };
20679
20737
  }
20680
20738
  function extractError(raw) {
20681
- const rec = asRecord3(raw);
20739
+ const rec = asRecord4(raw);
20682
20740
  if (!rec) return "Codex turn failed";
20683
- return readString3(rec.message) ?? readString3(asRecord3(rec.error)?.message) ?? "Codex turn failed";
20741
+ return readString3(rec.message) ?? readString3(asRecord4(rec.error)?.message) ?? "Codex turn failed";
20684
20742
  }
20685
20743
  function deriveCodexFinalResponse(items) {
20686
20744
  for (let index = items.length - 1; index >= 0; index--) {
@@ -20803,7 +20861,7 @@ function createCodexAgentEventMapper(options) {
20803
20861
  const params = note.params;
20804
20862
  switch (note.method) {
20805
20863
  case "thread/started": {
20806
- const threadId = readString3(asRecord3(params.thread)?.id);
20864
+ const threadId = readString3(asRecord4(params.thread)?.id);
20807
20865
  if (threadId && threadId !== currentThreadId) {
20808
20866
  currentThreadId = threadId;
20809
20867
  options.emit({ type: "codex_thread_started", messageId: options.messageId, threadId });
@@ -20812,7 +20870,7 @@ function createCodexAgentEventMapper(options) {
20812
20870
  }
20813
20871
  case "item/started":
20814
20872
  case "item/completed": {
20815
- const raw = asRecord3(params.item);
20873
+ const raw = asRecord4(params.item);
20816
20874
  if (!raw) break;
20817
20875
  if (readString3(raw.type) === "contextCompaction") {
20818
20876
  if (note.method === "item/started") startCompaction(params);
@@ -20911,7 +20969,7 @@ function createCodexAgentEventMapper(options) {
20911
20969
  case "turn/plan/updated": {
20912
20970
  const rawPlan = Array.isArray(params.plan) ? params.plan : [];
20913
20971
  const todoItems = rawPlan.map((entry) => {
20914
- const step = asRecord3(entry);
20972
+ const step = asRecord4(entry);
20915
20973
  const text = readString3(step?.step);
20916
20974
  return text ? { text, completed: readString3(step?.status) === "completed" } : null;
20917
20975
  }).filter((entry) => entry !== null);
@@ -20964,7 +21022,7 @@ function createCodexAgentEventMapper(options) {
20964
21022
  }
20965
21023
  case "turn/completed":
20966
21024
  case "turn/completed/v2": {
20967
- const turn = asRecord3(params.turn);
21025
+ const turn = asRecord4(params.turn);
20968
21026
  currentTurnId = readString3(turn?.id) ?? currentTurnId;
20969
21027
  const status = readString3(turn?.status) ?? readString3(params.status) ?? "completed";
20970
21028
  if (status === "failed" || status === "error") {
@@ -21025,6 +21083,7 @@ var init_agent_event_mapper = __esm({
21025
21083
  init_codex_command_output();
21026
21084
  init_protocol_v149();
21027
21085
  init_protocol_v153();
21086
+ init_protocol_v154();
21028
21087
  }
21029
21088
  });
21030
21089
 
@@ -21166,15 +21225,15 @@ async function openCodexAppServer(opts) {
21166
21225
  const rec = parsed;
21167
21226
  if (typeof rec.method === "string" && rec.id != null) {
21168
21227
  const id = rec.id;
21228
+ const params = rec.params && typeof rec.params === "object" && !Array.isArray(rec.params) ? rec.params : void 0;
21169
21229
  try {
21170
- writeLine({
21171
- jsonrpc: "2.0",
21172
- id,
21173
- result: {
21174
- decision: "deny",
21175
- outcome: { decision: "deny" }
21176
- }
21177
- });
21230
+ if (rec.method === "mcpServer/elicitation/request" && isCodexUserVerificationElicitation(params)) {
21231
+ writeLine({ jsonrpc: "2.0", id, result: elicitationCancelResult() });
21232
+ } else if (isKnownCodexServerRequest(rec.method)) {
21233
+ writeLine({ jsonrpc: "2.0", id, result: approvalDenyResult() });
21234
+ } else {
21235
+ writeLine(jsonRpcMethodNotFound(id));
21236
+ }
21178
21237
  } catch {
21179
21238
  }
21180
21239
  continue;
@@ -21285,6 +21344,9 @@ async function openCodexAppServer(opts) {
21285
21344
  },
21286
21345
  capabilities: {
21287
21346
  experimentalApi: true
21347
+ // requestAttestation stays omitted (default false). Do not implement
21348
+ // inbound attestation/generate this round; unknown inbound methods
21349
+ // receive JSON-RPC -32601.
21288
21350
  }
21289
21351
  });
21290
21352
  await notify("initialized");
@@ -21324,7 +21386,7 @@ async function ensureCodexThread(opts) {
21324
21386
  sandbox: "workspace-write",
21325
21387
  ...configPayload
21326
21388
  });
21327
- const thread = asRecord4(resumed.thread);
21389
+ const thread = asRecord5(resumed.thread);
21328
21390
  threadId = readString4(thread?.id) ?? readString4(resumed.id) ?? threadId;
21329
21391
  } else {
21330
21392
  const started = await opts.client.request("thread/start", {
@@ -21333,7 +21395,7 @@ async function ensureCodexThread(opts) {
21333
21395
  sandbox: "workspace-write",
21334
21396
  ...configPayload
21335
21397
  });
21336
- const thread = asRecord4(started.thread);
21398
+ const thread = asRecord5(started.thread);
21337
21399
  threadId = readString4(thread?.id) ?? readString4(started.id);
21338
21400
  }
21339
21401
  if (!threadId) {
@@ -21414,7 +21476,7 @@ async function runCodexAppServerTurn(opts) {
21414
21476
  sandboxPolicy: buildCodexWorkspaceWriteSandboxPolicy(opts.cwd, opts.additionalDirectories),
21415
21477
  ...collaborationMode ? { collaborationMode } : {}
21416
21478
  }));
21417
- const turn = asRecord4(turnStartResult.turn);
21479
+ const turn = asRecord5(turnStartResult.turn);
21418
21480
  turnId = readString4(turn?.id);
21419
21481
  }
21420
21482
  let finalText = "";
@@ -21441,7 +21503,7 @@ async function runCodexAppServerTurn(opts) {
21441
21503
  continue;
21442
21504
  }
21443
21505
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
21444
- const completedTurn = asRecord4(note.params.turn);
21506
+ const completedTurn = asRecord5(note.params.turn);
21445
21507
  const completedId = readString4(completedTurn?.id);
21446
21508
  if (turnId && completedId && completedId !== turnId) {
21447
21509
  continue;
@@ -21457,7 +21519,7 @@ async function runCodexAppServerTurn(opts) {
21457
21519
  });
21458
21520
  }
21459
21521
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
21460
- const completedTurn = asRecord4(note.params.turn);
21522
+ const completedTurn = asRecord5(note.params.turn);
21461
21523
  const status = readString4(completedTurn?.status) ?? readString4(note.params.status);
21462
21524
  if (status === "failed" || status === "error") {
21463
21525
  throw new Error("Codex turn failed");
@@ -21511,7 +21573,7 @@ function extractAgentTextFromTurn(turn) {
21511
21573
  let text = "";
21512
21574
  const items = Array.isArray(turn.items) ? turn.items : [];
21513
21575
  for (const item of items) {
21514
- const rec = asRecord4(item);
21576
+ const rec = asRecord5(item);
21515
21577
  if (!rec) continue;
21516
21578
  if (readString4(rec.type) === "agentMessage" || readString4(rec.itemType) === "agentMessage") {
21517
21579
  const t = readString4(rec.text);
@@ -21522,7 +21584,7 @@ function extractAgentTextFromTurn(turn) {
21522
21584
  }
21523
21585
  function applyAgentDelta(note, onDelta) {
21524
21586
  if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
21525
- const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord4(note.params.item)?.delta);
21587
+ const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord5(note.params.item)?.delta);
21526
21588
  if (delta) onDelta(delta);
21527
21589
  }
21528
21590
  }
@@ -21538,7 +21600,7 @@ function defaultSpawn(command, args, options) {
21538
21600
  windowsHide: options.windowsHide
21539
21601
  });
21540
21602
  }
21541
- function asRecord4(value) {
21603
+ function asRecord5(value) {
21542
21604
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
21543
21605
  }
21544
21606
  function readString4(value) {
@@ -21549,6 +21611,7 @@ var init_app_server_client = __esm({
21549
21611
  "../../packages/codex/src/app-server-client.ts"() {
21550
21612
  "use strict";
21551
21613
  init_superone_system_prompt();
21614
+ init_server_request();
21552
21615
  init_spawn_env();
21553
21616
  init_environment();
21554
21617
  init_sandbox_policy();
@@ -21590,7 +21653,7 @@ function applySetAuth(current, request) {
21590
21653
  }
21591
21654
  return { mode, apiKey: normalizeApiKey(apiKey) };
21592
21655
  }
21593
- function asRecord5(value) {
21656
+ function asRecord6(value) {
21594
21657
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
21595
21658
  }
21596
21659
  function readString5(value) {
@@ -21614,7 +21677,7 @@ function parseAccountAuthMode(value) {
21614
21677
  }
21615
21678
  }
21616
21679
  function parseAccountStatus(raw) {
21617
- const account = asRecord5(raw.account);
21680
+ const account = asRecord6(raw.account);
21618
21681
  return {
21619
21682
  signedIn: account !== null,
21620
21683
  authMode: parseAccountAuthMode(account?.type),
@@ -21709,12 +21772,12 @@ function parseAccountUsage(raw) {
21709
21772
  return hasAny ? usage2 : null;
21710
21773
  }
21711
21774
  function parseThreadUsage(raw) {
21712
- const rec = asRecord5(raw);
21775
+ const rec = asRecord6(raw);
21713
21776
  const threadId = readString5(rec?.threadId);
21714
21777
  const credits = readNumericLike(rec?.estimatedUsageCreditsMicros);
21715
21778
  if (!threadId || credits === null) return null;
21716
21779
  const groups = Array.isArray(rec?.groups) ? rec.groups.flatMap((value) => {
21717
- const group = asRecord5(value);
21780
+ const group = asRecord6(value);
21718
21781
  const groupCredits = readNumericLike(group?.estimatedUsageCreditsMicros);
21719
21782
  if (!group || groupCredits === null) return [];
21720
21783
  return [{
@@ -21910,18 +21973,18 @@ async function listPluginInventory(client3, projectPath) {
21910
21973
  const marketplaces = Array.isArray(result.marketplaces) ? result.marketplaces : [];
21911
21974
  const records = [];
21912
21975
  for (const rawMarketplace of marketplaces) {
21913
- const marketplace = asRecord5(rawMarketplace);
21976
+ const marketplace = asRecord6(rawMarketplace);
21914
21977
  if (!marketplace) continue;
21915
21978
  const marketplaceName = readString5(marketplace.name);
21916
21979
  const marketplacePath = readString5(marketplace.path);
21917
21980
  if (!marketplaceName || !marketplacePath) continue;
21918
21981
  const plugins = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
21919
21982
  for (const rawPlugin of plugins) {
21920
- const plugin = asRecord5(rawPlugin);
21983
+ const plugin = asRecord6(rawPlugin);
21921
21984
  if (!plugin) continue;
21922
21985
  const key = readString5(plugin.id);
21923
21986
  const name = readString5(plugin.name);
21924
- const source = asRecord5(plugin.source);
21987
+ const source = asRecord6(plugin.source);
21925
21988
  const sourcePath = readString5(source?.path) ?? void 0;
21926
21989
  if (!key || !name) continue;
21927
21990
  records.push({
@@ -21969,7 +22032,7 @@ async function marketplaceUpgrade(client3, marketplaceName) {
21969
22032
  name ? { marketplaceName: name } : {}
21970
22033
  );
21971
22034
  const errors = Array.isArray(result.errors) ? result.errors.map((raw) => {
21972
- const rec = asRecord5(raw);
22035
+ const rec = asRecord6(raw);
21973
22036
  if (!rec) return null;
21974
22037
  const marketplaceName2 = readString5(rec.marketplaceName) ?? readString5(rec.name);
21975
22038
  const message = readString5(rec.message) ?? readString5(rec.error);
@@ -22034,6 +22097,8 @@ var init_src = __esm({
22034
22097
  init_agent_event_mapper();
22035
22098
  init_protocol_v149();
22036
22099
  init_protocol_v153();
22100
+ init_protocol_v154();
22101
+ init_server_request();
22037
22102
  }
22038
22103
  });
22039
22104
 
@@ -22985,7 +23050,7 @@ var init_agent_event_mapper2 = __esm({
22985
23050
  });
22986
23051
 
22987
23052
  // ../../packages/claude/src/map-sdk-message.ts
22988
- function asRecord6(value) {
23053
+ function asRecord7(value) {
22989
23054
  if (value && typeof value === "object" && !Array.isArray(value)) {
22990
23055
  return value;
22991
23056
  }
@@ -23028,11 +23093,11 @@ function applySdkMessage(message, state, emit) {
23028
23093
  const sessionId = sessionIdOf2(record2);
23029
23094
  const parentToolUseId = typeof record2.parent_tool_use_id === "string" ? record2.parent_tool_use_id : null;
23030
23095
  if (record2.type === "stream_event") {
23031
- const event = asRecord6(record2.event);
23096
+ const event = asRecord7(record2.event);
23032
23097
  if (!event) return emptyApply(sessionId);
23033
23098
  const index = typeof event.index === "number" ? event.index : null;
23034
23099
  if (event.type === "content_block_start") {
23035
- const block = asRecord6(event.content_block);
23100
+ const block = asRecord7(event.content_block);
23036
23101
  if (!block) return emptyApply(sessionId);
23037
23102
  if (block.type === "text" && index != null) {
23038
23103
  state.indexToKind.set(index, "text");
@@ -23064,7 +23129,7 @@ function applySdkMessage(message, state, emit) {
23064
23129
  return emptyApply(sessionId);
23065
23130
  }
23066
23131
  if (event.type === "content_block_delta") {
23067
- const delta = asRecord6(event.delta);
23132
+ const delta = asRecord7(event.delta);
23068
23133
  if (!delta) return emptyApply(sessionId);
23069
23134
  if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text.length > 0) {
23070
23135
  return {
@@ -23098,10 +23163,10 @@ function applySdkMessage(message, state, emit) {
23098
23163
  return emptyApply(sessionId);
23099
23164
  }
23100
23165
  if (record2.type === "assistant") {
23101
- const messageBody = asRecord6(record2.message);
23166
+ const messageBody = asRecord7(record2.message);
23102
23167
  const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
23103
23168
  for (const raw of content) {
23104
- const block = asRecord6(raw);
23169
+ const block = asRecord7(raw);
23105
23170
  if (!block || block.type !== "tool_use") continue;
23106
23171
  const toolUseId = typeof block.id === "string" && block.id.length > 0 ? block.id : null;
23107
23172
  const toolName = typeof block.name === "string" && block.name.length > 0 ? block.name : "unknown";
@@ -23128,10 +23193,10 @@ function applySdkMessage(message, state, emit) {
23128
23193
  return emptyApply(sessionId);
23129
23194
  }
23130
23195
  if (record2.type === "user") {
23131
- const messageBody = asRecord6(record2.message);
23196
+ const messageBody = asRecord7(record2.message);
23132
23197
  const content = messageBody && Array.isArray(messageBody.content) ? messageBody.content : [];
23133
23198
  for (const raw of content) {
23134
- const block = asRecord6(raw);
23199
+ const block = asRecord7(raw);
23135
23200
  if (!block || block.type !== "tool_result") continue;
23136
23201
  const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : typeof block.toolUseId === "string" ? block.toolUseId : null;
23137
23202
  if (!toolUseId) continue;
@@ -23310,7 +23375,7 @@ var init_ask_user_question = __esm({
23310
23375
  });
23311
23376
 
23312
23377
  // ../../packages/claude/src/ask-user-question-bridge.ts
23313
- function asRecord7(value) {
23378
+ function asRecord8(value) {
23314
23379
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
23315
23380
  }
23316
23381
  async function resolveAskUserQuestion(params) {
@@ -23319,7 +23384,7 @@ async function resolveAskUserQuestion(params) {
23319
23384
  return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
23320
23385
  }
23321
23386
  const previewFormat = asQuestionPreviewFormat(params.previewFormat);
23322
- const rawInput = asRecord7(input);
23387
+ const rawInput = asRecord8(input);
23323
23388
  const baseInput = rawInput ? { ...rawInput, ...previewFormat ? { previewFormat } : {} } : null;
23324
23389
  const answer = await onQuestion({
23325
23390
  interactionId,
@@ -23328,9 +23393,9 @@ async function resolveAskUserQuestion(params) {
23328
23393
  toolUseId,
23329
23394
  input: baseInput ?? void 0
23330
23395
  });
23331
- const record2 = asRecord7(answer);
23396
+ const record2 = asRecord8(answer);
23332
23397
  const answers = record2 && "answers" in record2 ? record2.answers : answer;
23333
- const answerMap = asRecord7(answers);
23398
+ const answerMap = asRecord8(answers);
23334
23399
  const updatedInput = {
23335
23400
  ...baseInput,
23336
23401
  ...buildAnsweredQuestionInput({
@@ -23532,10 +23597,16 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
23532
23597
  ...opts.additionalDirectories && opts.additionalDirectories.length > 0 ? { additionalDirectories: opts.additionalDirectories } : {},
23533
23598
  ...opts.enabledSkills && opts.enabledSkills.length > 0 ? { skills: opts.enabledSkills } : {},
23534
23599
  ...asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) ? { toolConfig: { askUserQuestion: { previewFormat: asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) } } } : {},
23600
+ // SDK 0.3.267+ records the rendered system prompt on the first request and
23601
+ // replays it verbatim on every later launch of the same session until
23602
+ // compaction. SuperOne's append changes across app versions and the
23603
+ // collaboration block carries a per-grant credential, so keep per-request
23604
+ // rendering: a resumed session must see the current append, not a stale one.
23535
23605
  systemPrompt: {
23536
23606
  type: "preset",
23537
23607
  preset: "claude_code",
23538
- append: [SUPERONE_SYSTEM_PROMPT_APPEND, opts.systemPromptAppend].filter(Boolean).join("\n\n")
23608
+ append: [SUPERONE_SYSTEM_PROMPT_APPEND, opts.systemPromptAppend].filter(Boolean).join("\n\n"),
23609
+ snapshot: false
23539
23610
  },
23540
23611
  ...opts.sessionId ? { resume: opts.sessionId } : {},
23541
23612
  ...opts.resumeSessionAt ? { resumeSessionAt: opts.resumeSessionAt } : {},
@@ -24128,7 +24199,7 @@ var init_content_delta = __esm({
24128
24199
  });
24129
24200
 
24130
24201
  // ../../packages/shared/src/node-session-event-map.ts
24131
- function asRecord8(value) {
24202
+ function asRecord9(value) {
24132
24203
  if (value && typeof value === "object" && !Array.isArray(value)) {
24133
24204
  return value;
24134
24205
  }
@@ -24160,7 +24231,7 @@ function stamp(event, ctx, sequence) {
24160
24231
  }
24161
24232
  function mapQuestionRequest(payload, fallbackId) {
24162
24233
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
24163
- const input = asRecord8(payload.input);
24234
+ const input = asRecord9(payload.input);
24164
24235
  const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
24165
24236
  const questions = [];
24166
24237
  for (const q2 of rawQuestions) {
@@ -24199,7 +24270,7 @@ function mapQuestionRequest(payload, fallbackId) {
24199
24270
  }
24200
24271
  function mapPlanRequest(payload, fallbackId) {
24201
24272
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
24202
- const input = asRecord8(payload.input);
24273
+ const input = asRecord9(payload.input);
24203
24274
  let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
24204
24275
  if (!planContent && input.plan && typeof input.plan === "object") {
24205
24276
  try {
@@ -24265,7 +24336,7 @@ function createNodeSessionEventMapper(ctx) {
24265
24336
  if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
24266
24337
  if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
24267
24338
  const eventType = envelope.eventType;
24268
- const payload = asRecord8(envelope.payload);
24339
+ const payload = asRecord9(envelope.payload);
24269
24340
  const out = [];
24270
24341
  const push = (event) => {
24271
24342
  out.push(stamp(event, ctx, envelope.sequence));
@@ -24291,7 +24362,7 @@ function createNodeSessionEventMapper(ctx) {
24291
24362
  break;
24292
24363
  }
24293
24364
  case SESSION_DURABLE_EVENT.agentEvent: {
24294
- const rawEvent = asRecord8(payload.event);
24365
+ const rawEvent = asRecord9(payload.event);
24295
24366
  const type = asString2(rawEvent.type);
24296
24367
  if (!type) break;
24297
24368
  const eventRecord = { ...rawEvent };
@@ -24301,7 +24372,7 @@ function createNodeSessionEventMapper(ctx) {
24301
24372
  delete eventRecord.seq;
24302
24373
  delete eventRecord.epoch;
24303
24374
  const event = eventRecord;
24304
- const rawMessageId = type === "message_start" ? asString2(asRecord8(eventRecord.message).id) : asString2(eventRecord.messageId);
24375
+ const rawMessageId = type === "message_start" ? asString2(asRecord9(eventRecord.message).id) : asString2(eventRecord.messageId);
24305
24376
  if (type === "message_start" && rawMessageId) {
24306
24377
  startedAssistantIds.add(rawMessageId);
24307
24378
  lastAssistantId = rawMessageId;
@@ -24480,7 +24551,7 @@ function createNodeSessionEventMapper(ctx) {
24480
24551
  requestId: interactionId,
24481
24552
  toolName,
24482
24553
  toolUseId: asString2(payload.toolUseId),
24483
- input: asRecord8(payload.input),
24554
+ input: asRecord9(payload.input),
24484
24555
  allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
24485
24556
  ...requestKind ? {
24486
24557
  requestKind
@@ -24586,7 +24657,7 @@ var init_node_session_event_map = __esm({
24586
24657
  });
24587
24658
 
24588
24659
  // ../../packages/runtime/src/session/message-catalog.ts
24589
- function asRecord9(value) {
24660
+ function asRecord10(value) {
24590
24661
  if (value && typeof value === "object" && !Array.isArray(value)) {
24591
24662
  return value;
24592
24663
  }
@@ -24669,7 +24740,7 @@ function collectToolsByAssistantId(events, sessionId) {
24669
24740
  for (const ev of events) {
24670
24741
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
24671
24742
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
24672
- const payload = asRecord9(ev.payload);
24743
+ const payload = asRecord10(ev.payload);
24673
24744
  switch (ev.eventType) {
24674
24745
  case SESSION_DURABLE_EVENT.turnStarted: {
24675
24746
  turnKey += 1;
@@ -24695,10 +24766,10 @@ function collectToolsByAssistantId(events, sessionId) {
24695
24766
  break;
24696
24767
  }
24697
24768
  case SESSION_DURABLE_EVENT.agentEvent: {
24698
- const raw = asRecord9(payload.event);
24769
+ const raw = asRecord10(payload.event);
24699
24770
  const type = asString3(raw.type);
24700
24771
  if (type === "message_start") {
24701
- const id = asString3(asRecord9(raw.message).id);
24772
+ const id = asString3(asRecord10(raw.message).id);
24702
24773
  if (id) bindAssistant(id);
24703
24774
  } else if (type === "message_complete") {
24704
24775
  const id = asString3(raw.messageId);
@@ -24706,7 +24777,7 @@ function collectToolsByAssistantId(events, sessionId) {
24706
24777
  } else if (type === "content_delta") {
24707
24778
  const messageId = asString3(raw.messageId);
24708
24779
  if (messageId) bindAssistant(messageId);
24709
- const delta = asRecord9(raw.delta);
24780
+ const delta = asRecord10(raw.delta);
24710
24781
  const dType = asString3(delta.type);
24711
24782
  if (dType === "tool_use") {
24712
24783
  const toolUseId = asString3(delta.toolUseId);
@@ -24849,7 +24920,7 @@ function collectContentByAssistantId(events, sessionId) {
24849
24920
  if (changed) contentById.set(ev.messageId, next);
24850
24921
  }
24851
24922
  }
24852
- const payload = asRecord9(envelope.payload);
24923
+ const payload = asRecord10(envelope.payload);
24853
24924
  if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
24854
24925
  const blockId = asString3(payload.blockId);
24855
24926
  const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
@@ -24873,7 +24944,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
24873
24944
  const ev = events[i];
24874
24945
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
24875
24946
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
24876
- const payload = asRecord9(ev.payload);
24947
+ const payload = asRecord10(ev.payload);
24877
24948
  if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
24878
24949
  if (asString3(payload.blockId) !== blockId) continue;
24879
24950
  const checkpointId = asString3(payload.checkpointId);
@@ -24888,7 +24959,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
24888
24959
  }
24889
24960
  }
24890
24961
  if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
24891
- const raw = asRecord9(payload.event);
24962
+ const raw = asRecord10(payload.event);
24892
24963
  if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
24893
24964
  continue;
24894
24965
  }
@@ -50627,13 +50698,25 @@ function uiToolNameFromId(id) {
50627
50698
  const key = normalizeToolIdKey(id);
50628
50699
  return TOOL_ID_TO_UI_NAME[key] ?? null;
50629
50700
  }
50701
+ function parseMcpToolName(toolName) {
50702
+ if (!toolName) return null;
50703
+ const prefixed = /^mcp__(.+?)__(.+)$/.exec(toolName);
50704
+ if (prefixed) return { serverName: prefixed[1], mcpToolName: prefixed[2] };
50705
+ const delimiter2 = toolName.indexOf("__");
50706
+ if (delimiter2 <= 0) return null;
50707
+ if (toolName.indexOf("__", delimiter2 + 2) !== -1) return null;
50708
+ const serverName = toolName.slice(0, delimiter2);
50709
+ const mcpToolName = toolName.slice(delimiter2 + 2);
50710
+ if (!serverName || !mcpToolName) return null;
50711
+ return { serverName, mcpToolName };
50712
+ }
50630
50713
  function isAlwaysHiddenToolName(toolName) {
50631
50714
  const ui2 = uiToolNameFromId(toolName) ?? toolName;
50632
50715
  if (HIDDEN_UI_TOOL_NAMES.has(ui2)) return true;
50633
50716
  const harnessKey = ui2.trim().toLowerCase().replace(/[^a-z0-9]/g, "");
50634
50717
  if (HIDDEN_HARNESS_TOOL_KEYS.has(harnessKey)) return true;
50635
- const mcp = ui2.match(/^mcp__(.+?)__(.+)$/) ?? toolName.match(/^mcp__(.+?)__(.+)$/);
50636
- return mcp?.[1] === "superone" && HIDDEN_SUPERONE_MCP_TOOLS.has(mcp[2]);
50718
+ const mcp = parseMcpToolName(ui2) ?? parseMcpToolName(toolName);
50719
+ return mcp?.serverName === "superone" && HIDDEN_SUPERONE_MCP_TOOLS.has(mcp.mcpToolName);
50637
50720
  }
50638
50721
  function resolveGrokStreamingToolName(wireName, argumentsJson) {
50639
50722
  if (!wireName) return null;
@@ -51086,7 +51169,7 @@ function toolInputJson(raw) {
51086
51169
  return "{}";
51087
51170
  }
51088
51171
  }
51089
- function asRecord10(raw) {
51172
+ function asRecord11(raw) {
51090
51173
  if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
51091
51174
  return {};
51092
51175
  }
@@ -51230,7 +51313,7 @@ function grokMetaInput(tool) {
51230
51313
  const xai = meta3["x.ai/tool"];
51231
51314
  if (!xai || typeof xai !== "object") return {};
51232
51315
  const input = xai.input;
51233
- return asRecord10(input);
51316
+ return asRecord11(input);
51234
51317
  }
51235
51318
  function queryFromWebSearchTitle(title) {
51236
51319
  if (!title) return void 0;
@@ -51493,11 +51576,11 @@ function unwrapMcpEnvelope(tool, raw) {
51493
51576
  if (!isUseToolEnvelope(tool, raw)) return null;
51494
51577
  const id = raw.tool_name;
51495
51578
  if (typeof id !== "string" || !id.includes("__")) return null;
51496
- return { toolName: `mcp__${id}`, input: asRecord10(raw.tool_input) };
51579
+ return { toolName: `mcp__${id}`, input: asRecord11(raw.tool_input) };
51497
51580
  }
51498
51581
  function normalizeAcpTool(tool, opts) {
51499
- const raw = { ...grokMetaInput(tool), ...asRecord10(tool.rawInput) };
51500
- const rawInput = asRecord10(tool.rawInput);
51582
+ const raw = { ...grokMetaInput(tool), ...asRecord11(tool.rawInput) };
51583
+ const rawInput = asRecord11(tool.rawInput);
51501
51584
  const mcp = unwrapMcpEnvelope(tool, rawInput);
51502
51585
  if (mcp) return mcp;
51503
51586
  if (isUseToolEnvelope(tool, rawInput) && typeof rawInput.tool_name !== "string") return null;
@@ -51832,7 +51915,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
51832
51915
  });
51833
51916
  }
51834
51917
  }
51835
- function asRecord11(v3) {
51918
+ function asRecord12(v3) {
51836
51919
  if (!v3 || typeof v3 !== "object" || Array.isArray(v3)) return null;
51837
51920
  return v3;
51838
51921
  }
@@ -51865,18 +51948,18 @@ function arrField(o, ...keys) {
51865
51948
  return void 0;
51866
51949
  }
51867
51950
  function parseXaiSessionNotificationEnvelope(raw) {
51868
- const o = asRecord11(raw);
51951
+ const o = asRecord12(raw);
51869
51952
  if (!o) return null;
51870
- const update = asRecord11(o.update);
51953
+ const update = asRecord12(o.update);
51871
51954
  if (!update) return null;
51872
51955
  const sessionId = strField(o, "sessionId", "session_id");
51873
- const meta3 = asRecord11(o._meta) ?? asRecord11(o.meta);
51956
+ const meta3 = asRecord12(o._meta) ?? asRecord12(o.meta);
51874
51957
  const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
51875
51958
  const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
51876
51959
  return { sessionId, update, meta: meta3, eventSeq, eventId };
51877
51960
  }
51878
51961
  function parseXaiExtParams(raw) {
51879
- return asRecord11(raw) ?? {};
51962
+ return asRecord12(raw) ?? {};
51880
51963
  }
51881
51964
  function parsePlainTextTaskAck(text) {
51882
51965
  const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
@@ -51981,13 +52064,13 @@ function tryParseJsonObject(text) {
51981
52064
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
51982
52065
  try {
51983
52066
  const v3 = JSON.parse(trimmed);
51984
- return asRecord11(v3);
52067
+ return asRecord12(v3);
51985
52068
  } catch {
51986
52069
  const start = trimmed.indexOf("{");
51987
52070
  const end = trimmed.lastIndexOf("}");
51988
52071
  if (start < 0 || end <= start) return null;
51989
52072
  try {
51990
- return asRecord11(JSON.parse(trimmed.slice(start, end + 1)));
52073
+ return asRecord12(JSON.parse(trimmed.slice(start, end + 1)));
51991
52074
  } catch {
51992
52075
  return null;
51993
52076
  }
@@ -52269,7 +52352,7 @@ function mapWorkflowPhases(raw) {
52269
52352
  if (!raw?.length) return [];
52270
52353
  const out = [];
52271
52354
  for (const item of raw) {
52272
- const p3 = asRecord11(item);
52355
+ const p3 = asRecord12(item);
52273
52356
  if (!p3) continue;
52274
52357
  const title = strField(p3, "title");
52275
52358
  if (!title) continue;
@@ -52287,7 +52370,7 @@ function mapWorkflowAgents(raw) {
52287
52370
  if (!raw?.length) return [];
52288
52371
  const out = [];
52289
52372
  for (const item of raw) {
52290
- const a = asRecord11(item);
52373
+ const a = asRecord12(item);
52291
52374
  if (!a) continue;
52292
52375
  const agentId = strField(a, "agent_id", "agentId");
52293
52376
  const label = strField(a, "label") ?? agentId ?? "agent";
@@ -52313,7 +52396,7 @@ function buildWorkflowPhaseSummary(u2, currentPhase, pauseMessage, lastEvent, la
52313
52396
  const phaseBits = [];
52314
52397
  if (phases?.length) {
52315
52398
  for (const p3 of phases) {
52316
- const ph = asRecord11(p3);
52399
+ const ph = asRecord12(p3);
52317
52400
  if (!ph) continue;
52318
52401
  const title = strField(ph, "title") ?? "?";
52319
52402
  const state = strField(ph, "state") ?? "";
@@ -52461,7 +52544,7 @@ function mapTaskBackgrounded(u2, state) {
52461
52544
  }];
52462
52545
  }
52463
52546
  function mapTaskCompleted(u2, state) {
52464
- const snapshot = asRecord11(u2.task_snapshot) ?? asRecord11(u2.taskSnapshot) ?? u2;
52547
+ const snapshot = asRecord12(u2.task_snapshot) ?? asRecord12(u2.taskSnapshot) ?? u2;
52465
52548
  const taskId = strField(snapshot, "task_id", "taskId");
52466
52549
  if (!taskId) return [];
52467
52550
  const known = state.bgTaskById.get(taskId);
@@ -52757,7 +52840,7 @@ function mapResponseStarted(u2, state, ctx) {
52757
52840
  return event ? [event] : [];
52758
52841
  }
52759
52842
  function mapResponseCompleted(u2, state, ctx) {
52760
- const usageRaw = asRecord11(u2.usage) ?? u2;
52843
+ const usageRaw = asRecord12(u2.usage) ?? u2;
52761
52844
  const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
52762
52845
  const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
52763
52846
  const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
@@ -52772,7 +52855,7 @@ function mapResponseCompleted(u2, state, ctx) {
52772
52855
  }
52773
52856
  function mapTurnCompleted(u2, state, ctx) {
52774
52857
  const events = mapTurnStopReason(u2, state);
52775
- const usageRaw = asRecord11(u2.usage);
52858
+ const usageRaw = asRecord12(u2.usage);
52776
52859
  if (!usageRaw) {
52777
52860
  resetTurnTokens(state);
52778
52861
  return events;
@@ -52939,7 +53022,7 @@ function mapModelAutoSwitched(u2) {
52939
53022
  ];
52940
53023
  }
52941
53024
  function mapRetryState(u2) {
52942
- const nested = asRecord11(u2.retry_state) ?? asRecord11(u2.retryState) ?? u2;
53025
+ const nested = asRecord12(u2.retry_state) ?? asRecord12(u2.retryState) ?? u2;
52943
53026
  const type = (strField(nested, "type") ?? "").toLowerCase();
52944
53027
  if (type === "retrying") {
52945
53028
  const attempt = numField(nested, "attempt") ?? 1;
@@ -53010,7 +53093,7 @@ function mapAutoRecoveryExhausted(u2) {
53010
53093
  }];
53011
53094
  }
53012
53095
  function mapFollowUps(u2) {
53013
- const meta3 = asRecord11(u2._meta) ?? asRecord11(u2.meta);
53096
+ const meta3 = asRecord12(u2._meta) ?? asRecord12(u2.meta);
53014
53097
  if (meta3 && meta3["x.ai/replayed"] === true) return [];
53015
53098
  const responseId = strField(u2, "response_id", "responseId");
53016
53099
  if (!responseId || responseId.length > 128) return [];
@@ -53018,7 +53101,7 @@ function mapFollowUps(u2) {
53018
53101
  const labels = [];
53019
53102
  for (const s4 of suggestions) {
53020
53103
  if (labels.length >= 6) break;
53021
- const rec = asRecord11(s4);
53104
+ const rec = asRecord12(s4);
53022
53105
  const label = (rec ? strField(rec, "label") : typeof s4 === "string" ? s4 : void 0)?.trim();
53023
53106
  if (!label) continue;
53024
53107
  const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
@@ -53573,7 +53656,7 @@ var init_process = __esm({
53573
53656
  });
53574
53657
 
53575
53658
  // ../../packages/acp/src/xai-elicit.ts
53576
- function asRecord12(v3) {
53659
+ function asRecord13(v3) {
53577
53660
  if (!v3 || typeof v3 !== "object" || Array.isArray(v3)) return null;
53578
53661
  return v3;
53579
53662
  }
@@ -53594,7 +53677,7 @@ Previous results from earlier executions of this task may appear in the conversa
53594
53677
  ` + prompt;
53595
53678
  }
53596
53679
  function parseGrokScheduledInject(raw) {
53597
- const o = asRecord12(raw);
53680
+ const o = asRecord13(raw);
53598
53681
  if (!o) return null;
53599
53682
  const prompt = str3(o, "prompt");
53600
53683
  if (!prompt) return null;
@@ -53605,14 +53688,14 @@ function parseGrokScheduledInject(raw) {
53605
53688
  };
53606
53689
  }
53607
53690
  function parseGrokElicitComplete(raw) {
53608
- const o = asRecord12(raw);
53691
+ const o = asRecord13(raw);
53609
53692
  if (!o) return null;
53610
53693
  const elicitationId = str3(o, "elicitationId", "elicitation_id");
53611
53694
  if (!elicitationId) return null;
53612
53695
  return { elicitationId };
53613
53696
  }
53614
53697
  function grokElicitToPendingInteraction(raw) {
53615
- const o = asRecord12(raw);
53698
+ const o = asRecord13(raw);
53616
53699
  if (!o) return null;
53617
53700
  const serverName = str3(o, "serverName", "server_name") ?? "mcp";
53618
53701
  const message = str3(o, "message") ?? `Allow ${serverName}?`;
@@ -53621,13 +53704,13 @@ function grokElicitToPendingInteraction(raw) {
53621
53704
  const elicitationId = str3(o, "elicitationId", "elicitation_id");
53622
53705
  const toolCallId = str3(o, "toolCallId", "tool_call_id");
53623
53706
  const requestId = toolCallId || `acp_elicit_${Date.now().toString(36)}`;
53624
- const schema = asRecord12(o.requestedSchema ?? o.requested_schema);
53707
+ const schema = asRecord13(o.requestedSchema ?? o.requested_schema);
53625
53708
  const form = [];
53626
- const properties = schema ? asRecord12(schema.properties) : null;
53709
+ const properties = schema ? asRecord13(schema.properties) : null;
53627
53710
  if (properties) {
53628
53711
  const required2 = Array.isArray(schema?.required) ? schema.required : [];
53629
53712
  for (const [name, spec] of Object.entries(properties)) {
53630
- const field = asRecord12(spec);
53713
+ const field = asRecord13(spec);
53631
53714
  if (!field) continue;
53632
53715
  form.push({
53633
53716
  name,
@@ -61034,17 +61117,17 @@ function formatCursorQuestionResult(answer) {
61034
61117
  function isCursorQuestionTool(toolName) {
61035
61118
  return toolName === CURSOR_ASK_USER_QUESTION_TOOL || toolName === `mcp__${CURSOR_CUSTOM_TOOLS_SERVER}__${CURSOR_ASK_USER_QUESTION_TOOL}`;
61036
61119
  }
61037
- function asRecord13(value) {
61120
+ function asRecord14(value) {
61038
61121
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
61039
61122
  }
61040
61123
  function unwrapCursorHostToolResult(result) {
61041
- const rec = asRecord13(result);
61124
+ const rec = asRecord14(result);
61042
61125
  if (!rec || !Array.isArray(rec.content)) return { payload: result, isError: false };
61043
61126
  const isError = rec.isError === true;
61044
- const structured = asRecord13(rec.structuredContent);
61127
+ const structured = asRecord14(rec.structuredContent);
61045
61128
  if (structured) return { payload: structured, isError };
61046
- const first = asRecord13(rec.content[0]);
61047
- const nestedText = asRecord13(first?.text);
61129
+ const first = asRecord14(rec.content[0]);
61130
+ const nestedText = asRecord14(first?.text);
61048
61131
  const text = typeof nestedText?.text === "string" ? nestedText.text : typeof first?.text === "string" ? first.text : "";
61049
61132
  if (!text) return { payload: void 0, isError };
61050
61133
  try {
@@ -61054,17 +61137,17 @@ function unwrapCursorHostToolResult(result) {
61054
61137
  }
61055
61138
  }
61056
61139
  function cursorQuestionToolPresentation(args, result) {
61057
- const rec = asRecord13(args) ?? {};
61140
+ const rec = asRecord14(args) ?? {};
61058
61141
  const questions = Array.isArray(rec.questions) ? rec.questions : [];
61059
61142
  const { payload, isError } = unwrapCursorHostToolResult(result);
61060
61143
  if (isError) {
61061
61144
  return { input: { questions }, summary: typeof payload === "string" ? payload : null, isError };
61062
61145
  }
61063
- const res = asRecord13(payload);
61146
+ const res = asRecord14(payload);
61064
61147
  const outcome = typeof res?.outcome === "string" ? res.outcome : null;
61065
- if (outcome === "answered" && asRecord13(res?.answers)) {
61148
+ if (outcome === "answered" && asRecord14(res?.answers)) {
61066
61149
  const answers = res.answers;
61067
- const notes = asRecord13(res.notes);
61150
+ const notes = asRecord14(res.notes);
61068
61151
  const annotations = {};
61069
61152
  for (const [question, text] of Object.entries(notes ?? {})) {
61070
61153
  if (typeof text === "string") annotations[question] = { notes: text };
@@ -61204,7 +61287,7 @@ function toolDisplayName(name) {
61204
61287
  }
61205
61288
  function unwrapCursorMcpTool(toolType, args) {
61206
61289
  if (toolType.toLowerCase() !== "mcp") return { toolType, args };
61207
- const rec = asRecord14(args);
61290
+ const rec = asRecord15(args);
61208
61291
  if (!rec) return { toolType, args };
61209
61292
  const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
61210
61293
  const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
@@ -61230,12 +61313,12 @@ function idField(obj, ...keys) {
61230
61313
  return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
61231
61314
  }
61232
61315
  function extractCursorCallId(update) {
61233
- const rec = asRecord14(update);
61316
+ const rec = asRecord15(update);
61234
61317
  if (!rec) return null;
61235
- const nested = asRecord14(rec.toolCall) ?? asRecord14(rec.message);
61318
+ const nested = asRecord15(rec.toolCall) ?? asRecord15(rec.message);
61236
61319
  return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
61237
61320
  }
61238
- function asRecord14(value) {
61321
+ function asRecord15(value) {
61239
61322
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
61240
61323
  return value;
61241
61324
  }
@@ -61249,13 +61332,13 @@ function stringifyPayload(value) {
61249
61332
  }
61250
61333
  }
61251
61334
  function extractToolCallParts(update) {
61252
- const rec = asRecord14(update) ?? {};
61335
+ const rec = asRecord15(update) ?? {};
61253
61336
  const callId = extractCursorCallId(update);
61254
- const nested = asRecord14(rec.toolCall);
61337
+ const nested = asRecord15(rec.toolCall);
61255
61338
  if (nested) {
61256
61339
  const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
61257
61340
  const result = nested.result;
61258
- const resultRec = asRecord14(result);
61341
+ const resultRec = asRecord15(result);
61259
61342
  const isError = resultRec?.status === "error" || Boolean(rec.isError);
61260
61343
  return {
61261
61344
  callId,
@@ -61279,7 +61362,7 @@ function mapTodosPayload(todos) {
61279
61362
  return {
61280
61363
  type: "todos_updated",
61281
61364
  todos: todos.map((todo, index) => {
61282
- const row = asRecord14(todo) ?? {};
61365
+ const row = asRecord15(todo) ?? {};
61283
61366
  const statusRaw = String(row.status ?? "pending");
61284
61367
  return {
61285
61368
  id: String(row.id ?? index + 1),
@@ -61321,15 +61404,15 @@ function toolUseEvent(messageId, callId, toolType, args, status, result) {
61321
61404
  }
61322
61405
  function normalizeCursorToolInput(toolName, args) {
61323
61406
  if (toolName.startsWith("mcp__")) return args;
61324
- const rec = asRecord14(args);
61407
+ const rec = asRecord15(args);
61325
61408
  if (!rec) return args ?? {};
61326
61409
  return normalizeTranscriptTool(toolName, rec).input;
61327
61410
  }
61328
61411
  function mergeCursorToolResultArgs(toolType, args, result) {
61329
61412
  if (toolType.toLowerCase() === "mcp") return args;
61330
- const res = asRecord14(result);
61413
+ const res = asRecord15(result);
61331
61414
  if (!res) return args;
61332
- const rec = asRecord14(args);
61415
+ const rec = asRecord15(args);
61333
61416
  if (!rec) return args;
61334
61417
  const diff = typeof res.diffString === "string" ? res.diffString : void 0;
61335
61418
  const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
@@ -61388,7 +61471,7 @@ function stampParentToolUseId(events, parentToolUseId) {
61388
61471
  function mapInteractionUpdate(messageId, update, options) {
61389
61472
  const events = [];
61390
61473
  const type = String(update.type ?? "");
61391
- const rec = asRecord14(update) ?? {};
61474
+ const rec = asRecord15(update) ?? {};
61392
61475
  const turnUsage = options?.parentToolUseId ? void 0 : options?.turnUsage;
61393
61476
  switch (type) {
61394
61477
  case "text-delta": {
@@ -61431,7 +61514,7 @@ function mapInteractionUpdate(messageId, update, options) {
61431
61514
  if (type === "tool-call-started") turnUsage?.observeToolCallStarted(rec.modelCallId);
61432
61515
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
61433
61516
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
61434
- const todos = asRecord14(parts.args)?.todos;
61517
+ const todos = asRecord15(parts.args)?.todos;
61435
61518
  const todoEvent = mapTodosPayload(todos);
61436
61519
  if (todoEvent) events.push(todoEvent);
61437
61520
  }
@@ -61473,7 +61556,7 @@ function mapInteractionUpdate(messageId, update, options) {
61473
61556
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete", parts.result));
61474
61557
  events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError, parts.toolType, parts.args));
61475
61558
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
61476
- const todos = asRecord14(parts.args)?.todos ?? asRecord14(parts.result)?.todos;
61559
+ const todos = asRecord15(parts.args)?.todos ?? asRecord15(parts.result)?.todos;
61477
61560
  const todoEvent = mapTodosPayload(todos);
61478
61561
  if (todoEvent) events.push(todoEvent);
61479
61562
  }
@@ -61572,7 +61655,7 @@ ${text}
61572
61655
  }
61573
61656
  function mapConversationStep(messageId, step, options) {
61574
61657
  const events = [];
61575
- const rec = asRecord14(step);
61658
+ const rec = asRecord15(step);
61576
61659
  if (!rec) return events;
61577
61660
  const stepType = strField2(rec, "type");
61578
61661
  if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
@@ -61580,14 +61663,14 @@ function mapConversationStep(messageId, step, options) {
61580
61663
  }
61581
61664
  if (stepType === "toolCall") {
61582
61665
  const message = rec.message ?? rec.toolCall ?? rec;
61583
- const nested = asRecord14(message);
61666
+ const nested = asRecord15(message);
61584
61667
  const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
61585
61668
  if (!callId) {
61586
61669
  return events;
61587
61670
  }
61588
61671
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
61589
61672
  const args = nested?.args ?? nested?.input ?? {};
61590
- const resultRec = asRecord14(nested?.result);
61673
+ const resultRec = asRecord15(nested?.result);
61591
61674
  const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
61592
61675
  events.push(toolUseEvent(
61593
61676
  messageId,
@@ -61597,7 +61680,7 @@ function mapConversationStep(messageId, step, options) {
61597
61680
  "complete"
61598
61681
  ));
61599
61682
  if (toolType === "updateTodos" || toolType === "update_todos") {
61600
- const todos = asRecord14(args)?.todos;
61683
+ const todos = asRecord15(args)?.todos;
61601
61684
  const todoEvent = mapTodosPayload(todos);
61602
61685
  if (todoEvent) events.push(todoEvent);
61603
61686
  }
@@ -61857,7 +61940,7 @@ var init_cursor_event_map = __esm({
61857
61940
  observeDelta(update) {
61858
61941
  const type = String(update.type ?? "");
61859
61942
  if (type === "tool-call-delta") {
61860
- const taskUpdate = asRecord14(update)?.taskUpdate;
61943
+ const taskUpdate = asRecord15(update)?.taskUpdate;
61861
61944
  if (taskUpdate && typeof taskUpdate === "object") {
61862
61945
  this.observeDelta(taskUpdate);
61863
61946
  }
@@ -63315,7 +63398,7 @@ var init_harness_runners = __esm({
63315
63398
  });
63316
63399
 
63317
63400
  // src/session/codex-live-turn.ts
63318
- function asRecord15(value) {
63401
+ function asRecord16(value) {
63319
63402
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
63320
63403
  }
63321
63404
  function readString6(value) {
@@ -63346,7 +63429,7 @@ function extractAgentTextFromTurn2(turn) {
63346
63429
  let text = "";
63347
63430
  const items = Array.isArray(turn.items) ? turn.items : [];
63348
63431
  for (const item of items) {
63349
- const rec = asRecord15(item);
63432
+ const rec = asRecord16(item);
63350
63433
  if (!rec) continue;
63351
63434
  if (readString6(rec.type) === "agentMessage" || readString6(rec.itemType) === "agentMessage") {
63352
63435
  const t = readString6(rec.text);
@@ -63378,7 +63461,7 @@ async function openTurnAndStream(opts) {
63378
63461
  ...collaborationMode ? { collaborationMode } : {}
63379
63462
  })
63380
63463
  );
63381
- const turn = asRecord15(turnStartResult.turn);
63464
+ const turn = asRecord16(turnStartResult.turn);
63382
63465
  const turnId = readString6(turn?.id);
63383
63466
  opts.onTurnStarted?.(turnId);
63384
63467
  let finalText = "";
@@ -63406,7 +63489,7 @@ async function openTurnAndStream(opts) {
63406
63489
  continue;
63407
63490
  }
63408
63491
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
63409
- const completedTurn = asRecord15(note.params.turn);
63492
+ const completedTurn = asRecord16(note.params.turn);
63410
63493
  const completedId = readString6(completedTurn?.id);
63411
63494
  if (turnId && completedId && completedId !== turnId) continue;
63412
63495
  }
@@ -63414,14 +63497,14 @@ async function openTurnAndStream(opts) {
63414
63497
  const applied = agentEventMapper.apply(note);
63415
63498
  if (applied.textDelta) finalText += applied.textDelta;
63416
63499
  } else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
63417
- const delta = readString6(note.params.delta) ?? readString6(note.params.text) ?? readString6(asRecord15(note.params.item)?.delta);
63500
+ const delta = readString6(note.params.delta) ?? readString6(note.params.text) ?? readString6(asRecord16(note.params.item)?.delta);
63418
63501
  if (delta) {
63419
63502
  finalText += delta;
63420
63503
  opts.onDelta?.(delta);
63421
63504
  }
63422
63505
  }
63423
63506
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
63424
- const completedTurn = asRecord15(note.params.turn);
63507
+ const completedTurn = asRecord16(note.params.turn);
63425
63508
  const status = readString6(completedTurn?.status) ?? readString6(note.params.status);
63426
63509
  if (status === "failed" || status === "error") {
63427
63510
  throw new Error("Codex turn failed");
@@ -71204,8 +71287,8 @@ import { fileURLToPath } from "node:url";
71204
71287
  function resolveCliReleaseVersion() {
71205
71288
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
71206
71289
  if (fromEnv) return fromEnv;
71207
- if ("0.63.0".trim()) {
71208
- return "0.63.0".trim();
71290
+ if ("0.64.0-alpha.1".trim()) {
71291
+ return "0.64.0-alpha.1".trim();
71209
71292
  }
71210
71293
  const fromDist = readDistManifestVersion();
71211
71294
  if (fromDist) return fromDist;
@@ -73320,7 +73403,7 @@ function requireResourceWrite(client3, scope) {
73320
73403
  if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
73321
73404
  return null;
73322
73405
  }
73323
- function asRecord16(payload) {
73406
+ function asRecord17(payload) {
73324
73407
  return payload && typeof payload === "object" ? payload : {};
73325
73408
  }
73326
73409
  function mapThrown(err) {
@@ -73349,7 +73432,7 @@ function manageOpts(ctx) {
73349
73432
  function handleSkillsList(payload, ctx) {
73350
73433
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73351
73434
  if (denied) return denied;
73352
- const p3 = asRecord16(payload);
73435
+ const p3 = asRecord17(payload);
73353
73436
  try {
73354
73437
  const projectId = String(p3.projectId ?? "");
73355
73438
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73369,7 +73452,7 @@ function handleSkillsList(payload, ctx) {
73369
73452
  function handleSkillsGet(payload, ctx) {
73370
73453
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73371
73454
  if (denied) return denied;
73372
- const p3 = asRecord16(payload);
73455
+ const p3 = asRecord17(payload);
73373
73456
  try {
73374
73457
  const projectId = String(p3.projectId ?? "");
73375
73458
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73394,7 +73477,7 @@ function handleSkillsGet(payload, ctx) {
73394
73477
  function handleSkillsReadFile(payload, ctx) {
73395
73478
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73396
73479
  if (denied) return denied;
73397
- const p3 = asRecord16(payload);
73480
+ const p3 = asRecord17(payload);
73398
73481
  try {
73399
73482
  const projectId = String(p3.projectId ?? "");
73400
73483
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73428,7 +73511,7 @@ function handleSkillsReadFile(payload, ctx) {
73428
73511
  function handleSkillsDelete(payload, ctx) {
73429
73512
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73430
73513
  if (denied) return denied;
73431
- const p3 = asRecord16(payload);
73514
+ const p3 = asRecord17(payload);
73432
73515
  try {
73433
73516
  const projectId = String(p3.projectId ?? "");
73434
73517
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73453,7 +73536,7 @@ function handleSkillsDelete(payload, ctx) {
73453
73536
  function handleSkillsInstall(payload, ctx) {
73454
73537
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73455
73538
  if (baseDenied) return baseDenied;
73456
- const p3 = asRecord16(payload);
73539
+ const p3 = asRecord17(payload);
73457
73540
  try {
73458
73541
  const projectId = String(p3.projectId ?? "");
73459
73542
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73487,7 +73570,7 @@ function handleSkillsInstall(payload, ctx) {
73487
73570
  function handleMcpList(payload, ctx) {
73488
73571
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73489
73572
  if (denied) return denied;
73490
- const p3 = asRecord16(payload);
73573
+ const p3 = asRecord17(payload);
73491
73574
  try {
73492
73575
  const projectId = String(p3.projectId ?? "");
73493
73576
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73544,7 +73627,7 @@ function parseMcpWriteConfig(raw) {
73544
73627
  function handleMcpSave(payload, ctx) {
73545
73628
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73546
73629
  if (baseDenied) return baseDenied;
73547
- const p3 = asRecord16(payload);
73630
+ const p3 = asRecord17(payload);
73548
73631
  try {
73549
73632
  const projectId = String(p3.projectId ?? "");
73550
73633
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73574,7 +73657,7 @@ function handleMcpSave(payload, ctx) {
73574
73657
  function handleMcpToggle(payload, ctx) {
73575
73658
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73576
73659
  if (baseDenied) return baseDenied;
73577
- const p3 = asRecord16(payload);
73660
+ const p3 = asRecord17(payload);
73578
73661
  try {
73579
73662
  const projectId = String(p3.projectId ?? "");
73580
73663
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73605,7 +73688,7 @@ function handleMcpToggle(payload, ctx) {
73605
73688
  function handleMcpDelete(payload, ctx) {
73606
73689
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73607
73690
  if (baseDenied) return baseDenied;
73608
- const p3 = asRecord16(payload);
73691
+ const p3 = asRecord17(payload);
73609
73692
  try {
73610
73693
  const projectId = String(p3.projectId ?? "");
73611
73694
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73645,7 +73728,7 @@ function parseMarketplaceScope(raw) {
73645
73728
  async function handlePluginsList(payload, ctx) {
73646
73729
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73647
73730
  if (denied) return denied;
73648
- const p3 = asRecord16(payload);
73731
+ const p3 = asRecord17(payload);
73649
73732
  try {
73650
73733
  const projectId = String(p3.projectId ?? "");
73651
73734
  projectRoot(ctx.projects, projectId);
@@ -73692,7 +73775,7 @@ async function handlePluginsList(payload, ctx) {
73692
73775
  function handlePluginsGet(payload, ctx) {
73693
73776
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73694
73777
  if (denied) return denied;
73695
- const p3 = asRecord16(payload);
73778
+ const p3 = asRecord17(payload);
73696
73779
  try {
73697
73780
  const projectId = String(p3.projectId ?? "");
73698
73781
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73716,7 +73799,7 @@ function handlePluginsGet(payload, ctx) {
73716
73799
  function handlePluginsReadFile(payload, ctx) {
73717
73800
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73718
73801
  if (denied) return denied;
73719
- const p3 = asRecord16(payload);
73802
+ const p3 = asRecord17(payload);
73720
73803
  try {
73721
73804
  const projectId = String(p3.projectId ?? "");
73722
73805
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73744,7 +73827,7 @@ function handlePluginsReadFile(payload, ctx) {
73744
73827
  function handlePluginsDelete(payload, ctx) {
73745
73828
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73746
73829
  if (baseDenied) return baseDenied;
73747
- const p3 = asRecord16(payload);
73830
+ const p3 = asRecord17(payload);
73748
73831
  try {
73749
73832
  const projectId = String(p3.projectId ?? "");
73750
73833
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73770,7 +73853,7 @@ function handlePluginsDelete(payload, ctx) {
73770
73853
  async function handlePluginsInstall(payload, ctx) {
73771
73854
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73772
73855
  if (baseDenied) return baseDenied;
73773
- const p3 = asRecord16(payload);
73856
+ const p3 = asRecord17(payload);
73774
73857
  try {
73775
73858
  const projectId = String(p3.projectId ?? "");
73776
73859
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73796,7 +73879,7 @@ async function handlePluginsInstall(payload, ctx) {
73796
73879
  function handlePluginsUpdate(payload, ctx) {
73797
73880
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73798
73881
  if (baseDenied) return baseDenied;
73799
- const p3 = asRecord16(payload);
73882
+ const p3 = asRecord17(payload);
73800
73883
  try {
73801
73884
  const projectId = String(p3.projectId ?? "");
73802
73885
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73822,7 +73905,7 @@ function handlePluginsUpdate(payload, ctx) {
73822
73905
  function handlePluginsListMarketplace(payload, ctx) {
73823
73906
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73824
73907
  if (denied) return denied;
73825
- const p3 = asRecord16(payload);
73908
+ const p3 = asRecord17(payload);
73826
73909
  try {
73827
73910
  const projectId = String(p3.projectId ?? "");
73828
73911
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73844,7 +73927,7 @@ function handlePluginsListMarketplace(payload, ctx) {
73844
73927
  async function handlePluginsAddMarketplace(payload, ctx) {
73845
73928
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73846
73929
  if (baseDenied) return baseDenied;
73847
- const p3 = asRecord16(payload);
73930
+ const p3 = asRecord17(payload);
73848
73931
  try {
73849
73932
  const projectId = String(p3.projectId ?? "");
73850
73933
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73870,7 +73953,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
73870
73953
  async function handlePluginsRemoveMarketplace(payload, ctx) {
73871
73954
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73872
73955
  if (baseDenied) return baseDenied;
73873
- const p3 = asRecord16(payload);
73956
+ const p3 = asRecord17(payload);
73874
73957
  try {
73875
73958
  const projectId = String(p3.projectId ?? "");
73876
73959
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73905,7 +73988,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
73905
73988
  if (denied) return denied;
73906
73989
  const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
73907
73990
  if (adminDenied) return adminDenied;
73908
- const p3 = asRecord16(payload);
73991
+ const p3 = asRecord17(payload);
73909
73992
  try {
73910
73993
  const projectId = String(p3.projectId ?? "");
73911
73994
  if (projectId) {
@@ -73927,7 +74010,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
73927
74010
  function handlePluginsReadMarketplace(payload, ctx) {
73928
74011
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73929
74012
  if (denied) return denied;
73930
- const p3 = asRecord16(payload);
74013
+ const p3 = asRecord17(payload);
73931
74014
  try {
73932
74015
  const projectId = String(p3.projectId ?? "");
73933
74016
  if (projectId) {
@@ -73958,7 +74041,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
73958
74041
  function handlePluginsReadMarketplaceFile(payload, ctx) {
73959
74042
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73960
74043
  if (denied) return denied;
73961
- const p3 = asRecord16(payload);
74044
+ const p3 = asRecord17(payload);
73962
74045
  try {
73963
74046
  const projectId = String(p3.projectId ?? "");
73964
74047
  if (projectId) {
@@ -73992,7 +74075,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
73992
74075
  function handleAgentsList(payload, ctx) {
73993
74076
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73994
74077
  if (denied) return denied;
73995
- const p3 = asRecord16(payload);
74078
+ const p3 = asRecord17(payload);
73996
74079
  try {
73997
74080
  const projectId = String(p3.projectId ?? "");
73998
74081
  const cwd = projectRoot(ctx.projects, projectId);
@@ -74009,7 +74092,7 @@ function handleAgentsList(payload, ctx) {
74009
74092
  function handleAgentsReadFile(payload, ctx) {
74010
74093
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
74011
74094
  if (denied) return denied;
74012
- const p3 = asRecord16(payload);
74095
+ const p3 = asRecord17(payload);
74013
74096
  try {
74014
74097
  const projectId = String(p3.projectId ?? "");
74015
74098
  const cwd = projectRoot(ctx.projects, projectId);
@@ -74041,7 +74124,7 @@ function parseHookSavePayload(raw) {
74041
74124
  function handleHooksList(payload, ctx) {
74042
74125
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
74043
74126
  if (denied) return denied;
74044
- const p3 = asRecord16(payload);
74127
+ const p3 = asRecord17(payload);
74045
74128
  try {
74046
74129
  const projectId = String(p3.projectId ?? "");
74047
74130
  const cwd = projectRoot(ctx.projects, projectId);
@@ -74054,7 +74137,7 @@ function handleHooksList(payload, ctx) {
74054
74137
  function handleHooksSave(payload, ctx) {
74055
74138
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
74056
74139
  if (baseDenied) return baseDenied;
74057
- const p3 = asRecord16(payload);
74140
+ const p3 = asRecord17(payload);
74058
74141
  try {
74059
74142
  const projectId = String(p3.projectId ?? "");
74060
74143
  const cwd = projectRoot(ctx.projects, projectId);
@@ -74082,7 +74165,7 @@ function handleHooksSave(payload, ctx) {
74082
74165
  function handleHooksDelete(payload, ctx) {
74083
74166
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
74084
74167
  if (baseDenied) return baseDenied;
74085
- const p3 = asRecord16(payload);
74168
+ const p3 = asRecord17(payload);
74086
74169
  try {
74087
74170
  const projectId = String(p3.projectId ?? "");
74088
74171
  const cwd = projectRoot(ctx.projects, projectId);
@@ -74181,7 +74264,7 @@ function requireScopes2(client3, scopes) {
74181
74264
  }
74182
74265
  return null;
74183
74266
  }
74184
- function asRecord17(payload) {
74267
+ function asRecord18(payload) {
74185
74268
  return payload && typeof payload === "object" ? payload : {};
74186
74269
  }
74187
74270
  function mapThrown2(err) {
@@ -74272,7 +74355,7 @@ function parseSchedule(raw) {
74272
74355
  function handleAutomationList(payload, ctx) {
74273
74356
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
74274
74357
  if (denied) return denied;
74275
- const p3 = asRecord17(payload);
74358
+ const p3 = asRecord18(payload);
74276
74359
  const projectId = String(p3.projectId ?? "").trim();
74277
74360
  if (!projectId) {
74278
74361
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -74291,7 +74374,7 @@ function handleAutomationList(payload, ctx) {
74291
74374
  function handleAutomationCreate(payload, ctx) {
74292
74375
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74293
74376
  if (denied) return denied;
74294
- const p3 = asRecord17(payload);
74377
+ const p3 = asRecord18(payload);
74295
74378
  const projectId = String(p3.projectId ?? "").trim();
74296
74379
  if (!projectId) {
74297
74380
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -74328,7 +74411,7 @@ function handleAutomationCreate(payload, ctx) {
74328
74411
  function handleAutomationUpdate(payload, ctx) {
74329
74412
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74330
74413
  if (denied) return denied;
74331
- const p3 = asRecord17(payload);
74414
+ const p3 = asRecord18(payload);
74332
74415
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
74333
74416
  if (!automationId) {
74334
74417
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74372,7 +74455,7 @@ function handleAutomationUpdate(payload, ctx) {
74372
74455
  function handleAutomationDelete(payload, ctx) {
74373
74456
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74374
74457
  if (denied) return denied;
74375
- const p3 = asRecord17(payload);
74458
+ const p3 = asRecord18(payload);
74376
74459
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
74377
74460
  if (!automationId) {
74378
74461
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74398,7 +74481,7 @@ function handleAutomationDelete(payload, ctx) {
74398
74481
  async function handleAutomationRunNow(payload, ctx) {
74399
74482
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74400
74483
  if (denied) return denied;
74401
- const p3 = asRecord17(payload);
74484
+ const p3 = asRecord18(payload);
74402
74485
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
74403
74486
  if (!automationId) {
74404
74487
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74455,7 +74538,7 @@ function requireScopes3(client3, scopes) {
74455
74538
  }
74456
74539
  return null;
74457
74540
  }
74458
- function asRecord18(payload) {
74541
+ function asRecord19(payload) {
74459
74542
  return payload && typeof payload === "object" ? payload : {};
74460
74543
  }
74461
74544
  function optionalString(value) {
@@ -74464,7 +74547,7 @@ function optionalString(value) {
74464
74547
  function parseAttachments(value) {
74465
74548
  if (!Array.isArray(value)) return [];
74466
74549
  return value.flatMap((raw) => {
74467
- const a = asRecord18(raw);
74550
+ const a = asRecord19(raw);
74468
74551
  const name = typeof a.name === "string" ? a.name : "";
74469
74552
  const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
74470
74553
  const data = typeof a.data === "string" ? a.data : "";
@@ -74477,7 +74560,7 @@ function mapThrown3(err) {
74477
74560
  function handleDraftList(payload, ctx) {
74478
74561
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
74479
74562
  if (denied) return denied;
74480
- const p3 = asRecord18(payload);
74563
+ const p3 = asRecord19(payload);
74481
74564
  const projectPath = optionalString(p3.projectPath);
74482
74565
  try {
74483
74566
  return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
@@ -74488,7 +74571,7 @@ function handleDraftList(payload, ctx) {
74488
74571
  function handleDraftUpsert(payload, ctx) {
74489
74572
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
74490
74573
  if (denied) return denied;
74491
- const p3 = asRecord18(payload);
74574
+ const p3 = asRecord19(payload);
74492
74575
  const id = String(p3.id ?? "").trim();
74493
74576
  if (!id) {
74494
74577
  return { error: { code: "invalid_argument", message: "id is required" } };
@@ -74519,7 +74602,7 @@ function handleDraftUpsert(payload, ctx) {
74519
74602
  function handleDraftDelete(payload, ctx) {
74520
74603
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
74521
74604
  if (denied) return denied;
74522
- const p3 = asRecord18(payload);
74605
+ const p3 = asRecord19(payload);
74523
74606
  const draftId = String(p3.draftId ?? "").trim();
74524
74607
  if (!draftId) {
74525
74608
  return { error: { code: "invalid_argument", message: "draftId is required" } };
@@ -74553,7 +74636,7 @@ function requireScopes4(client3, scopes) {
74553
74636
  }
74554
74637
  return null;
74555
74638
  }
74556
- function asRecord19(payload) {
74639
+ function asRecord20(payload) {
74557
74640
  return payload && typeof payload === "object" ? payload : {};
74558
74641
  }
74559
74642
  function mapThrown4(err) {
@@ -74639,7 +74722,7 @@ var CODEX_MUTATING_METHODS = [
74639
74722
  function handleGetAuthStatus(payload, ctx) {
74640
74723
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74641
74724
  if (denied) return denied;
74642
- const p3 = asRecord19(payload);
74725
+ const p3 = asRecord20(payload);
74643
74726
  const projectId = projectIdOf(p3);
74644
74727
  if (!projectId) {
74645
74728
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74652,7 +74735,7 @@ function handleGetAuthStatus(payload, ctx) {
74652
74735
  function handleSetAuth(payload, ctx) {
74653
74736
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74654
74737
  if (denied) return denied;
74655
- const p3 = asRecord19(payload);
74738
+ const p3 = asRecord20(payload);
74656
74739
  const projectId = projectIdOf(p3);
74657
74740
  if (!projectId) {
74658
74741
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74677,7 +74760,7 @@ function handleSetAuth(payload, ctx) {
74677
74760
  async function handleGetAccountStatus(payload, ctx) {
74678
74761
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74679
74762
  if (denied) return denied;
74680
- const p3 = asRecord19(payload);
74763
+ const p3 = asRecord20(payload);
74681
74764
  const projectId = projectIdOf(p3);
74682
74765
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74683
74766
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74690,7 +74773,7 @@ async function handleGetAccountStatus(payload, ctx) {
74690
74773
  async function handleAccountLoginStart(payload, ctx) {
74691
74774
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74692
74775
  if (denied) return denied;
74693
- const p3 = asRecord19(payload);
74776
+ const p3 = asRecord20(payload);
74694
74777
  const projectId = projectIdOf(p3);
74695
74778
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74696
74779
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74703,7 +74786,7 @@ async function handleAccountLoginStart(payload, ctx) {
74703
74786
  async function handleAccountLoginCancel(payload, ctx) {
74704
74787
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74705
74788
  if (denied) return denied;
74706
- const p3 = asRecord19(payload);
74789
+ const p3 = asRecord20(payload);
74707
74790
  const loginId = typeof p3.loginId === "string" ? p3.loginId.trim() : "";
74708
74791
  if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
74709
74792
  try {
@@ -74716,7 +74799,7 @@ async function handleAccountLoginCancel(payload, ctx) {
74716
74799
  async function handleAccountLogout(payload, ctx) {
74717
74800
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74718
74801
  if (denied) return denied;
74719
- const p3 = asRecord19(payload);
74802
+ const p3 = asRecord20(payload);
74720
74803
  const projectId = projectIdOf(p3);
74721
74804
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74722
74805
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74729,7 +74812,7 @@ async function handleAccountLogout(payload, ctx) {
74729
74812
  async function handleGetRateLimits(payload, ctx) {
74730
74813
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74731
74814
  if (denied) return denied;
74732
- const p3 = asRecord19(payload);
74815
+ const p3 = asRecord20(payload);
74733
74816
  const projectId = projectIdOf(p3);
74734
74817
  if (!projectId) {
74735
74818
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74756,7 +74839,7 @@ async function handleGetRateLimits(payload, ctx) {
74756
74839
  async function handleGetAccountUsage(payload, ctx) {
74757
74840
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74758
74841
  if (denied) return denied;
74759
- const p3 = asRecord19(payload);
74842
+ const p3 = asRecord20(payload);
74760
74843
  const projectId = projectIdOf(p3);
74761
74844
  if (!projectId) {
74762
74845
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74784,7 +74867,7 @@ async function handleGetAccountUsage(payload, ctx) {
74784
74867
  async function handleGetServerDiagnostics(payload, ctx) {
74785
74868
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74786
74869
  if (denied) return denied;
74787
- const p3 = asRecord19(payload);
74870
+ const p3 = asRecord20(payload);
74788
74871
  const projectId = projectIdOf(p3);
74789
74872
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74790
74873
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74802,7 +74885,7 @@ async function handleGetServerDiagnostics(payload, ctx) {
74802
74885
  async function handleGetConfigRequirements(payload, ctx) {
74803
74886
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74804
74887
  if (denied) return denied;
74805
- const p3 = asRecord19(payload);
74888
+ const p3 = asRecord20(payload);
74806
74889
  const projectId = projectIdOf(p3);
74807
74890
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74808
74891
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74820,7 +74903,7 @@ async function handleGetConfigRequirements(payload, ctx) {
74820
74903
  async function handleConsumeRateLimitReset(payload, ctx) {
74821
74904
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74822
74905
  if (denied) return denied;
74823
- const p3 = asRecord19(payload);
74906
+ const p3 = asRecord20(payload);
74824
74907
  const projectId = projectIdOf(p3);
74825
74908
  if (!projectId) {
74826
74909
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74850,7 +74933,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
74850
74933
  async function handleLoginMcpOauth(payload, ctx) {
74851
74934
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74852
74935
  if (denied) return denied;
74853
- const p3 = asRecord19(payload);
74936
+ const p3 = asRecord20(payload);
74854
74937
  const projectId = projectIdOf(p3);
74855
74938
  const serverName = String(p3.serverName ?? p3.name ?? "").trim();
74856
74939
  if (!projectId || !serverName) {
@@ -74860,7 +74943,7 @@ async function handleLoginMcpOauth(payload, ctx) {
74860
74943
  }
74861
74944
  try {
74862
74945
  const apiProviderId = typeof p3.apiProviderId === "string" ? p3.apiProviderId : null;
74863
- const rawOptions = asRecord19(p3.options);
74946
+ const rawOptions = asRecord20(p3.options);
74864
74947
  const options = {
74865
74948
  ...rawOptions.clientRegistration === "auto" || rawOptions.clientRegistration === "cimd" || rawOptions.clientRegistration === "dcr" ? { clientRegistration: rawOptions.clientRegistration } : {},
74866
74949
  ...typeof rawOptions.threadId === "string" || rawOptions.threadId === null ? { threadId: rawOptions.threadId } : {},
@@ -74877,7 +74960,7 @@ async function handleLoginMcpOauth(payload, ctx) {
74877
74960
  async function handleDetectExternalAgent(payload, ctx) {
74878
74961
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74879
74962
  if (denied) return denied;
74880
- const p3 = asRecord19(payload);
74963
+ const p3 = asRecord20(payload);
74881
74964
  const projectId = projectIdOf(p3);
74882
74965
  if (!projectId) {
74883
74966
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74896,7 +74979,7 @@ async function handleDetectExternalAgent(payload, ctx) {
74896
74979
  async function handleImportExternalAgent(payload, ctx) {
74897
74980
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74898
74981
  if (denied) return denied;
74899
- const p3 = asRecord19(payload);
74982
+ const p3 = asRecord20(payload);
74900
74983
  const projectId = projectIdOf(p3);
74901
74984
  if (!projectId) {
74902
74985
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74914,7 +74997,7 @@ async function handleImportExternalAgent(payload, ctx) {
74914
74997
  async function handlePluginsList2(payload, ctx) {
74915
74998
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
74916
74999
  if (denied) return denied;
74917
- const p3 = asRecord19(payload);
75000
+ const p3 = asRecord20(payload);
74918
75001
  const projectId = projectIdOf(p3);
74919
75002
  if (!projectId) {
74920
75003
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74937,7 +75020,7 @@ async function handlePluginsList2(payload, ctx) {
74937
75020
  async function handlePluginsInstall2(payload, ctx) {
74938
75021
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74939
75022
  if (denied) return denied;
74940
- const p3 = asRecord19(payload);
75023
+ const p3 = asRecord20(payload);
74941
75024
  const projectId = projectIdOf(p3);
74942
75025
  const key = String(p3.key ?? p3.pluginId ?? "").trim();
74943
75026
  if (!projectId || !key) {
@@ -74953,7 +75036,7 @@ async function handlePluginsInstall2(payload, ctx) {
74953
75036
  async function handlePluginsUninstall(payload, ctx) {
74954
75037
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74955
75038
  if (denied) return denied;
74956
- const p3 = asRecord19(payload);
75039
+ const p3 = asRecord20(payload);
74957
75040
  const projectId = projectIdOf(p3);
74958
75041
  const key = String(p3.key ?? p3.pluginId ?? "").trim();
74959
75042
  if (!projectId || !key) {
@@ -74969,7 +75052,7 @@ async function handlePluginsUninstall(payload, ctx) {
74969
75052
  async function handleMarketplaceAdd(payload, ctx) {
74970
75053
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74971
75054
  if (denied) return denied;
74972
- const p3 = asRecord19(payload);
75055
+ const p3 = asRecord20(payload);
74973
75056
  const projectId = projectIdOf(p3);
74974
75057
  const source = String(p3.source ?? "").trim();
74975
75058
  if (!projectId || !source) {
@@ -74998,7 +75081,7 @@ async function handleMarketplaceAdd(payload, ctx) {
74998
75081
  async function handleMarketplaceRemove(payload, ctx) {
74999
75082
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
75000
75083
  if (denied) return denied;
75001
- const p3 = asRecord19(payload);
75084
+ const p3 = asRecord20(payload);
75002
75085
  const projectId = projectIdOf(p3);
75003
75086
  const marketplaceName = String(p3.marketplaceName ?? p3.name ?? "").trim();
75004
75087
  if (!projectId || !marketplaceName) {
@@ -75021,7 +75104,7 @@ async function handleMarketplaceRemove(payload, ctx) {
75021
75104
  async function handleMarketplaceUpgrade(payload, ctx) {
75022
75105
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
75023
75106
  if (denied) return denied;
75024
- const p3 = asRecord19(payload);
75107
+ const p3 = asRecord20(payload);
75025
75108
  const projectId = projectIdOf(p3);
75026
75109
  if (!projectId) {
75027
75110
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -75054,7 +75137,7 @@ function requireScopes5(client3, scopes) {
75054
75137
  }
75055
75138
  return null;
75056
75139
  }
75057
- function asRecord20(payload) {
75140
+ function asRecord21(payload) {
75058
75141
  return payload && typeof payload === "object" ? payload : {};
75059
75142
  }
75060
75143
  function mapThrown5(err) {
@@ -75083,7 +75166,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
75083
75166
  function handleList(payload, ctx) {
75084
75167
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
75085
75168
  if (denied) return denied;
75086
- const p3 = asRecord20(payload);
75169
+ const p3 = asRecord21(payload);
75087
75170
  try {
75088
75171
  const harnessId = typeof p3.harnessId === "string" && p3.harnessId.trim() ? p3.harnessId.trim() : null;
75089
75172
  const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
@@ -75095,7 +75178,7 @@ function handleList(payload, ctx) {
75095
75178
  function handleGet(payload, ctx) {
75096
75179
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
75097
75180
  if (denied) return denied;
75098
- const p3 = asRecord20(payload);
75181
+ const p3 = asRecord21(payload);
75099
75182
  const id = String(p3.id ?? "");
75100
75183
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
75101
75184
  try {
@@ -75107,7 +75190,7 @@ function handleGet(payload, ctx) {
75107
75190
  function handleGetBase(payload, ctx) {
75108
75191
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
75109
75192
  if (denied) return denied;
75110
- const p3 = asRecord20(payload);
75193
+ const p3 = asRecord21(payload);
75111
75194
  const harnessId = String(p3.harnessId ?? "");
75112
75195
  if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
75113
75196
  try {
@@ -75119,7 +75202,7 @@ function handleGetBase(payload, ctx) {
75119
75202
  function handleCreate(payload, ctx) {
75120
75203
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
75121
75204
  if (denied) return denied;
75122
- const p3 = asRecord20(payload);
75205
+ const p3 = asRecord21(payload);
75123
75206
  try {
75124
75207
  const provider = ctx.sessionProviders.create({
75125
75208
  harnessId: String(p3.harnessId ?? ""),
@@ -75135,7 +75218,7 @@ function handleCreate(payload, ctx) {
75135
75218
  function handleUpdate(payload, ctx) {
75136
75219
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
75137
75220
  if (denied) return denied;
75138
- const p3 = asRecord20(payload);
75221
+ const p3 = asRecord21(payload);
75139
75222
  const id = String(p3.id ?? "");
75140
75223
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
75141
75224
  try {
@@ -75151,7 +75234,7 @@ function handleUpdate(payload, ctx) {
75151
75234
  function handleDelete(payload, ctx) {
75152
75235
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
75153
75236
  if (denied) return denied;
75154
- const p3 = asRecord20(payload);
75237
+ const p3 = asRecord21(payload);
75155
75238
  const id = String(p3.id ?? "");
75156
75239
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
75157
75240
  try {
@@ -75192,7 +75275,7 @@ function requireScopes6(client3, scopes) {
75192
75275
  }
75193
75276
  return null;
75194
75277
  }
75195
- function asRecord21(payload) {
75278
+ function asRecord22(payload) {
75196
75279
  return payload && typeof payload === "object" ? payload : {};
75197
75280
  }
75198
75281
  function defaultProbeModels(ctx) {
@@ -75220,7 +75303,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
75220
75303
  async function handleHarnessResources(payload, ctx) {
75221
75304
  const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
75222
75305
  if (denied) return denied;
75223
- const p3 = asRecord21(payload);
75306
+ const p3 = asRecord22(payload);
75224
75307
  const projectId = String(p3.projectId ?? "");
75225
75308
  if (!projectId) {
75226
75309
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -75668,7 +75751,7 @@ function handleProviderListCredentials(ctx) {
75668
75751
  function handleProviderGetCredentialDecrypted(payload, ctx) {
75669
75752
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75670
75753
  if (denied) return denied;
75671
- const p3 = asRecord22(payload);
75754
+ const p3 = asRecord23(payload);
75672
75755
  const cred = ctx.providers.getCredentialDecrypted(String(p3.id ?? ""));
75673
75756
  if (!cred) return { error: { code: "not_found", message: "credential not found" } };
75674
75757
  return { result: cred };
@@ -75676,7 +75759,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
75676
75759
  function handleProviderCreateCredential(payload, ctx) {
75677
75760
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75678
75761
  if (denied) return denied;
75679
- const p3 = asRecord22(payload);
75762
+ const p3 = asRecord23(payload);
75680
75763
  try {
75681
75764
  return {
75682
75765
  result: ctx.providers.createCredential({
@@ -75699,7 +75782,7 @@ function handleProviderCreateCredential(payload, ctx) {
75699
75782
  function handleProviderUpdateCredential(payload, ctx) {
75700
75783
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75701
75784
  if (denied) return denied;
75702
- const p3 = asRecord22(payload);
75785
+ const p3 = asRecord23(payload);
75703
75786
  const id = String(p3.id ?? "");
75704
75787
  const updated = ctx.providers.updateCredential(id, {
75705
75788
  name: typeof p3.name === "string" ? p3.name : void 0,
@@ -75717,7 +75800,7 @@ function handleProviderUpdateCredential(payload, ctx) {
75717
75800
  function handleProviderDeleteCredential(payload, ctx) {
75718
75801
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75719
75802
  if (denied) return denied;
75720
- const p3 = asRecord22(payload);
75803
+ const p3 = asRecord23(payload);
75721
75804
  const ok = ctx.providers.deleteCredential(String(p3.id ?? ""));
75722
75805
  if (!ok) return { error: { code: "not_found", message: "credential not found" } };
75723
75806
  return { result: { ok: true } };
@@ -75730,7 +75813,7 @@ function handleProviderListBindings(ctx) {
75730
75813
  function handleProviderSetBinding(payload, ctx) {
75731
75814
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75732
75815
  if (denied) return denied;
75733
- const p3 = asRecord22(payload);
75816
+ const p3 = asRecord23(payload);
75734
75817
  const binding = p3;
75735
75818
  if (!binding.consumer || !binding.credentialId) {
75736
75819
  return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
@@ -75741,7 +75824,7 @@ function handleProviderSetBinding(payload, ctx) {
75741
75824
  function handleProviderClearBinding(payload, ctx) {
75742
75825
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75743
75826
  if (denied) return denied;
75744
- const p3 = asRecord22(payload);
75827
+ const p3 = asRecord23(payload);
75745
75828
  ctx.providers.clearBinding(String(p3.consumer ?? ""));
75746
75829
  return { result: { ok: true } };
75747
75830
  }
@@ -75753,14 +75836,14 @@ function handleProviderListCustomPlatforms(ctx) {
75753
75836
  function handleProviderUpsertCustomPlatform(payload, ctx) {
75754
75837
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75755
75838
  if (denied) return denied;
75756
- const def = asRecord22(payload);
75839
+ const def = asRecord23(payload);
75757
75840
  if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
75758
75841
  return { result: ctx.providers.upsertCustomPlatform(def) };
75759
75842
  }
75760
75843
  function handleProviderDeleteCustomPlatform(payload, ctx) {
75761
75844
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75762
75845
  if (denied) return denied;
75763
- const p3 = asRecord22(payload);
75846
+ const p3 = asRecord23(payload);
75764
75847
  const ok = ctx.providers.deleteCustomPlatform(String(p3.id ?? ""));
75765
75848
  if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
75766
75849
  return { result: { ok: true } };
@@ -75773,7 +75856,7 @@ function handleProviderExportBundle(ctx) {
75773
75856
  function handleProviderListModels(payload, ctx) {
75774
75857
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
75775
75858
  if (denied) return denied;
75776
- const p3 = asRecord22(payload);
75859
+ const p3 = asRecord23(payload);
75777
75860
  const harness = String(p3.harness ?? p3.harnessId ?? "claude");
75778
75861
  const apiProviderId = typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
75779
75862
  return {
@@ -75785,7 +75868,7 @@ function handleProviderListModels(payload, ctx) {
75785
75868
  function handleProviderImportBundle(payload, ctx) {
75786
75869
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75787
75870
  if (denied) return denied;
75788
- const p3 = asRecord22(payload);
75871
+ const p3 = asRecord23(payload);
75789
75872
  const bundle = p3.bundle && typeof p3.bundle === "object" ? p3.bundle : p3;
75790
75873
  const replaceAll = p3.replaceAll === true;
75791
75874
  try {
@@ -75850,7 +75933,7 @@ function handleHarnessList(ctx) {
75850
75933
  function handleHarnessShow(payload, ctx) {
75851
75934
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75852
75935
  if (denied) return denied;
75853
- const p3 = asRecord22(payload);
75936
+ const p3 = asRecord23(payload);
75854
75937
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75855
75938
  if (!isNodeHarnessId(id)) {
75856
75939
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75860,7 +75943,7 @@ function handleHarnessShow(payload, ctx) {
75860
75943
  function handleHarnessProbe(payload, ctx) {
75861
75944
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75862
75945
  if (denied) return denied;
75863
- const p3 = asRecord22(payload);
75946
+ const p3 = asRecord23(payload);
75864
75947
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75865
75948
  if (!isNodeHarnessId(id)) {
75866
75949
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75875,7 +75958,7 @@ function handleHarnessProbe(payload, ctx) {
75875
75958
  async function handleHarnessEnable(payload, ctx) {
75876
75959
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75877
75960
  if (denied) return denied;
75878
- const p3 = asRecord22(payload);
75961
+ const p3 = asRecord23(payload);
75879
75962
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75880
75963
  if (!isNodeHarnessId(id)) {
75881
75964
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75901,7 +75984,7 @@ async function handleHarnessEnable(payload, ctx) {
75901
75984
  function handleHarnessDisable(payload, ctx) {
75902
75985
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75903
75986
  if (denied) return denied;
75904
- const p3 = asRecord22(payload);
75987
+ const p3 = asRecord23(payload);
75905
75988
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75906
75989
  if (!isNodeHarnessId(id)) {
75907
75990
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75966,7 +76049,7 @@ function handleSettingsGet(ctx) {
75966
76049
  function handleSettingsPatch(payload, ctx) {
75967
76050
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75968
76051
  if (denied) return denied;
75969
- const p3 = asRecord22(payload);
76052
+ const p3 = asRecord23(payload);
75970
76053
  const rawPatch = p3.patch && typeof p3.patch === "object" ? p3.patch : p3;
75971
76054
  try {
75972
76055
  const settings = patchNodeAgentSettings(
@@ -75987,13 +76070,13 @@ async function handleSandboxProbe(ctx) {
75987
76070
  return mapThrown7(err);
75988
76071
  }
75989
76072
  }
75990
- function asRecord22(payload) {
76073
+ function asRecord23(payload) {
75991
76074
  return payload && typeof payload === "object" ? payload : {};
75992
76075
  }
75993
76076
  function handleTerminalCreate(payload, ctx) {
75994
76077
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75995
76078
  if (denied) return denied;
75996
- const p3 = asRecord22(payload);
76079
+ const p3 = asRecord23(payload);
75997
76080
  const cwd = typeof p3.cwd === "string" ? p3.cwd : process.cwd();
75998
76081
  try {
75999
76082
  const info = ctx.terminals.create({
@@ -76018,7 +76101,7 @@ function handleTerminalCreate(payload, ctx) {
76018
76101
  function handleTerminalAttach(payload, ctx) {
76019
76102
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76020
76103
  if (denied) return denied;
76021
- const p3 = asRecord22(payload);
76104
+ const p3 = asRecord23(payload);
76022
76105
  const terminalId = String(p3.terminalId ?? "");
76023
76106
  try {
76024
76107
  const attached = ctx.terminals.attach(terminalId);
@@ -76030,7 +76113,7 @@ function handleTerminalAttach(payload, ctx) {
76030
76113
  function handleTerminalRead(payload, ctx) {
76031
76114
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76032
76115
  if (denied) return denied;
76033
- const p3 = asRecord22(payload);
76116
+ const p3 = asRecord23(payload);
76034
76117
  try {
76035
76118
  return {
76036
76119
  result: ctx.terminals.readAfter(
@@ -76058,7 +76141,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
76058
76141
  function handleTerminalWrite(payload, ctx) {
76059
76142
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76060
76143
  if (denied) return denied;
76061
- const p3 = asRecord22(payload);
76144
+ const p3 = asRecord23(payload);
76062
76145
  const terminalId = String(p3.terminalId ?? "");
76063
76146
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
76064
76147
  if (leaseErr) return leaseErr;
@@ -76076,7 +76159,7 @@ function handleTerminalWrite(payload, ctx) {
76076
76159
  function handleTerminalResize(payload, ctx) {
76077
76160
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76078
76161
  if (denied) return denied;
76079
- const p3 = asRecord22(payload);
76162
+ const p3 = asRecord23(payload);
76080
76163
  const terminalId = String(p3.terminalId ?? "");
76081
76164
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
76082
76165
  if (leaseErr) return leaseErr;
@@ -76092,7 +76175,7 @@ function handleTerminalResize(payload, ctx) {
76092
76175
  function handleTerminalKill(payload, ctx) {
76093
76176
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76094
76177
  if (denied) return denied;
76095
- const p3 = asRecord22(payload);
76178
+ const p3 = asRecord23(payload);
76096
76179
  const terminalId = String(p3.terminalId ?? "");
76097
76180
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
76098
76181
  if (leaseErr) return leaseErr;
@@ -76106,7 +76189,7 @@ function handleTerminalKill(payload, ctx) {
76106
76189
  function handleTerminalAcquireControl(payload, ctx) {
76107
76190
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76108
76191
  if (denied) return denied;
76109
- const p3 = asRecord22(payload);
76192
+ const p3 = asRecord23(payload);
76110
76193
  const terminalId = String(p3.terminalId ?? "");
76111
76194
  try {
76112
76195
  return {
@@ -76123,7 +76206,7 @@ function handleTerminalAcquireControl(payload, ctx) {
76123
76206
  function handleTerminalRenewControl(payload, ctx) {
76124
76207
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76125
76208
  if (denied) return denied;
76126
- const p3 = asRecord22(payload);
76209
+ const p3 = asRecord23(payload);
76127
76210
  try {
76128
76211
  return {
76129
76212
  result: ctx.leases.renew({
@@ -76140,7 +76223,7 @@ function handleTerminalRenewControl(payload, ctx) {
76140
76223
  function handleTerminalReleaseControl(payload, ctx) {
76141
76224
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
76142
76225
  if (denied) return denied;
76143
- const p3 = asRecord22(payload);
76226
+ const p3 = asRecord23(payload);
76144
76227
  try {
76145
76228
  ctx.leases.release(
76146
76229
  String(p3.leaseId ?? ""),
@@ -76165,7 +76248,7 @@ function handleProjectList(ctx) {
76165
76248
  function handleProjectGet(payload, ctx) {
76166
76249
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
76167
76250
  if (denied) return denied;
76168
- const p3 = asRecord22(payload);
76251
+ const p3 = asRecord23(payload);
76169
76252
  const projectId = String(p3.projectId ?? "");
76170
76253
  return { result: ctx.projects.get(projectId) };
76171
76254
  }
@@ -76181,7 +76264,7 @@ function expandHostPath(path) {
76181
76264
  function handleProjectOpen(payload, ctx) {
76182
76265
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
76183
76266
  if (denied) return denied;
76184
- const p3 = asRecord22(payload);
76267
+ const p3 = asRecord23(payload);
76185
76268
  const path = expandHostPath(String(p3.path ?? ""));
76186
76269
  if (!path) {
76187
76270
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -76199,7 +76282,7 @@ function handleProjectOpen(payload, ctx) {
76199
76282
  function handleProjectUpdate(payload, ctx) {
76200
76283
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
76201
76284
  if (denied) return denied;
76202
- const p3 = asRecord22(payload);
76285
+ const p3 = asRecord23(payload);
76203
76286
  const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
76204
76287
  const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
76205
76288
  if (!projectId && !pathRaw) {
@@ -76227,7 +76310,7 @@ function handleProjectUpdate(payload, ctx) {
76227
76310
  function handleProjectRemove(payload, ctx) {
76228
76311
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
76229
76312
  if (denied) return denied;
76230
- const p3 = asRecord22(payload);
76313
+ const p3 = asRecord23(payload);
76231
76314
  const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
76232
76315
  const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
76233
76316
  if (!projectId && !pathRaw) {
@@ -76246,7 +76329,7 @@ function handleProjectRemove(payload, ctx) {
76246
76329
  function handleFsListDir(payload, ctx) {
76247
76330
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76248
76331
  if (denied) return denied;
76249
- const p3 = asRecord22(payload);
76332
+ const p3 = asRecord23(payload);
76250
76333
  const raw = String(p3.path ?? "");
76251
76334
  if (!raw || raw.includes("\0")) {
76252
76335
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -76272,7 +76355,7 @@ function handleFsListDir(payload, ctx) {
76272
76355
  function handleWorkspaceListDir(payload, ctx) {
76273
76356
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76274
76357
  if (denied) return denied;
76275
- const p3 = asRecord22(payload);
76358
+ const p3 = asRecord23(payload);
76276
76359
  try {
76277
76360
  return {
76278
76361
  result: ctx.workspaceFs.listDir(String(p3.projectId ?? ""), String(p3.relativePath ?? "."))
@@ -76284,7 +76367,7 @@ function handleWorkspaceListDir(payload, ctx) {
76284
76367
  function handleWorkspaceListFiles(payload, ctx) {
76285
76368
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76286
76369
  if (denied) return denied;
76287
- const p3 = asRecord22(payload);
76370
+ const p3 = asRecord23(payload);
76288
76371
  try {
76289
76372
  return {
76290
76373
  result: {
@@ -76302,7 +76385,7 @@ function handleWorkspaceListFiles(payload, ctx) {
76302
76385
  function handleWorkspaceListSkills(payload, ctx) {
76303
76386
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76304
76387
  if (denied) return denied;
76305
- const p3 = asRecord22(payload);
76388
+ const p3 = asRecord23(payload);
76306
76389
  try {
76307
76390
  return {
76308
76391
  result: ctx.workspaceFs.listSkillsAndCommands(String(p3.projectId ?? ""))
@@ -76314,7 +76397,7 @@ function handleWorkspaceListSkills(payload, ctx) {
76314
76397
  function handleWorkspaceReadFile(payload, ctx) {
76315
76398
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76316
76399
  if (denied) return denied;
76317
- const p3 = asRecord22(payload);
76400
+ const p3 = asRecord23(payload);
76318
76401
  try {
76319
76402
  return {
76320
76403
  result: ctx.workspaceFs.readFile(String(p3.projectId ?? ""), String(p3.relativePath ?? ""), {
@@ -76329,7 +76412,7 @@ function handleWorkspaceReadFile(payload, ctx) {
76329
76412
  function handleWorkspaceWriteFile(payload, ctx) {
76330
76413
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76331
76414
  if (denied) return denied;
76332
- const p3 = asRecord22(payload);
76415
+ const p3 = asRecord23(payload);
76333
76416
  const raw = typeof p3.content === "string" ? p3.content : String(p3.content ?? "");
76334
76417
  const encoding = p3.encoding === "base64" ? "base64" : "utf8";
76335
76418
  let content = raw;
@@ -76359,7 +76442,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
76359
76442
  function handleWorkspaceSearch(payload, ctx) {
76360
76443
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76361
76444
  if (denied) return denied;
76362
- const p3 = asRecord22(payload);
76445
+ const p3 = asRecord23(payload);
76363
76446
  try {
76364
76447
  return {
76365
76448
  result: ctx.workspaceFs.search(
@@ -76375,7 +76458,7 @@ function handleWorkspaceSearch(payload, ctx) {
76375
76458
  function handleWorkspaceRename(payload, ctx) {
76376
76459
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76377
76460
  if (denied) return denied;
76378
- const p3 = asRecord22(payload);
76461
+ const p3 = asRecord23(payload);
76379
76462
  try {
76380
76463
  return {
76381
76464
  result: ctx.workspaceFs.rename(
@@ -76391,7 +76474,7 @@ function handleWorkspaceRename(payload, ctx) {
76391
76474
  function handleWorkspaceMove(payload, ctx) {
76392
76475
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76393
76476
  if (denied) return denied;
76394
- const p3 = asRecord22(payload);
76477
+ const p3 = asRecord23(payload);
76395
76478
  try {
76396
76479
  return {
76397
76480
  result: ctx.workspaceFs.move(
@@ -76407,7 +76490,7 @@ function handleWorkspaceMove(payload, ctx) {
76407
76490
  function handleWorkspaceDelete(payload, ctx) {
76408
76491
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76409
76492
  if (denied) return denied;
76410
- const p3 = asRecord22(payload);
76493
+ const p3 = asRecord23(payload);
76411
76494
  try {
76412
76495
  return {
76413
76496
  result: ctx.workspaceFs.delete(
@@ -76422,7 +76505,7 @@ function handleWorkspaceDelete(payload, ctx) {
76422
76505
  function handleWorkspaceMkdir(payload, ctx) {
76423
76506
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76424
76507
  if (denied) return denied;
76425
- const p3 = asRecord22(payload);
76508
+ const p3 = asRecord23(payload);
76426
76509
  try {
76427
76510
  return {
76428
76511
  result: ctx.workspaceFs.mkdir(
@@ -76437,7 +76520,7 @@ function handleWorkspaceMkdir(payload, ctx) {
76437
76520
  function handleWorkspaceWatchStart(payload, ctx) {
76438
76521
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76439
76522
  if (denied) return denied;
76440
- const p3 = asRecord22(payload);
76523
+ const p3 = asRecord23(payload);
76441
76524
  try {
76442
76525
  const events = [];
76443
76526
  const { watchId, cancel } = ctx.workspaceWatch.subscribe(
@@ -76458,7 +76541,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
76458
76541
  function handleWorkspaceWatchPoll(payload, ctx) {
76459
76542
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76460
76543
  if (denied) return denied;
76461
- const p3 = asRecord22(payload);
76544
+ const p3 = asRecord23(payload);
76462
76545
  const watchId = String(p3.watchId ?? "");
76463
76546
  const buf = watchBuffers.get(watchId);
76464
76547
  if (!buf || buf.owner !== ctx.client.clientSessionId) {
@@ -76470,7 +76553,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
76470
76553
  function handleWorkspaceWatchStop(payload, ctx) {
76471
76554
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76472
76555
  if (denied) return denied;
76473
- const p3 = asRecord22(payload);
76556
+ const p3 = asRecord23(payload);
76474
76557
  const watchId = String(p3.watchId ?? "");
76475
76558
  const buf = watchBuffers.get(watchId);
76476
76559
  if (buf && buf.owner === ctx.client.clientSessionId) {
@@ -76482,7 +76565,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
76482
76565
  function handleWorkspaceTailWatchStart(payload, ctx) {
76483
76566
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76484
76567
  if (denied) return denied;
76485
- const p3 = asRecord22(payload);
76568
+ const p3 = asRecord23(payload);
76486
76569
  try {
76487
76570
  const offset = typeof p3.offset === "number" ? p3.offset : void 0;
76488
76571
  const absolutePath = typeof p3.absolutePath === "string" ? p3.absolutePath : void 0;
@@ -76500,7 +76583,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
76500
76583
  function handleWorkspaceTailWatchPoll(payload, ctx) {
76501
76584
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76502
76585
  if (denied) return denied;
76503
- const p3 = asRecord22(payload);
76586
+ const p3 = asRecord23(payload);
76504
76587
  try {
76505
76588
  return {
76506
76589
  result: ctx.workspaceTailWatch.poll(String(p3.watchId ?? ""), ctx.client.clientSessionId)
@@ -76512,7 +76595,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
76512
76595
  function handleWorkspaceTailWatchStop(payload, ctx) {
76513
76596
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76514
76597
  if (denied) return denied;
76515
- const p3 = asRecord22(payload);
76598
+ const p3 = asRecord23(payload);
76516
76599
  try {
76517
76600
  return {
76518
76601
  result: ctx.workspaceTailWatch.stop(String(p3.watchId ?? ""), ctx.client.clientSessionId)
@@ -76524,7 +76607,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
76524
76607
  function handleGitStatus(payload, ctx) {
76525
76608
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76526
76609
  if (denied) return denied;
76527
- const p3 = asRecord22(payload);
76610
+ const p3 = asRecord23(payload);
76528
76611
  try {
76529
76612
  const projectId = String(p3.projectId ?? "");
76530
76613
  const cwd = typeof p3.cwd === "string" ? p3.cwd : null;
@@ -76538,7 +76621,7 @@ function handleGitStatus(payload, ctx) {
76538
76621
  function handleGitDiff(payload, ctx) {
76539
76622
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76540
76623
  if (denied) return denied;
76541
- const p3 = asRecord22(payload);
76624
+ const p3 = asRecord23(payload);
76542
76625
  try {
76543
76626
  return {
76544
76627
  result: ctx.workspaceGit.diff(String(p3.projectId ?? ""), {
@@ -76553,7 +76636,7 @@ function handleGitDiff(payload, ctx) {
76553
76636
  function handleGitBranches(payload, ctx) {
76554
76637
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76555
76638
  if (denied) return denied;
76556
- const p3 = asRecord22(payload);
76639
+ const p3 = asRecord23(payload);
76557
76640
  try {
76558
76641
  return {
76559
76642
  result: ctx.workspaceGit.branches(
@@ -76568,7 +76651,7 @@ function handleGitBranches(payload, ctx) {
76568
76651
  function handleGitSwitchBranch(payload, ctx) {
76569
76652
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76570
76653
  if (denied) return denied;
76571
- const p3 = asRecord22(payload);
76654
+ const p3 = asRecord23(payload);
76572
76655
  try {
76573
76656
  return {
76574
76657
  result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
@@ -76583,7 +76666,7 @@ function handleGitSwitchBranch(payload, ctx) {
76583
76666
  function handleGitCreateBranch(payload, ctx) {
76584
76667
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76585
76668
  if (denied) return denied;
76586
- const p3 = asRecord22(payload);
76669
+ const p3 = asRecord23(payload);
76587
76670
  try {
76588
76671
  return {
76589
76672
  result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
@@ -76598,7 +76681,7 @@ function handleGitCreateBranch(payload, ctx) {
76598
76681
  function handleGitWorktrees(payload, ctx) {
76599
76682
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76600
76683
  if (denied) return denied;
76601
- const p3 = asRecord22(payload);
76684
+ const p3 = asRecord23(payload);
76602
76685
  try {
76603
76686
  return { result: ctx.workspaceGit.worktrees(String(p3.projectId ?? "")) };
76604
76687
  } catch (err) {
@@ -76608,7 +76691,7 @@ function handleGitWorktrees(payload, ctx) {
76608
76691
  function handleGitWorktreeActivate(payload, ctx) {
76609
76692
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76610
76693
  if (denied) return denied;
76611
- const p3 = asRecord22(payload);
76694
+ const p3 = asRecord23(payload);
76612
76695
  const mode = p3.mode === "attach" || p3.mode === "detach" || p3.mode === "branch" ? p3.mode : null;
76613
76696
  if (!mode) {
76614
76697
  return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
@@ -76629,7 +76712,7 @@ function handleGitWorktreeActivate(payload, ctx) {
76629
76712
  function handleGitWorktreeCheckedOutBranches(payload, ctx) {
76630
76713
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76631
76714
  if (denied) return denied;
76632
- const p3 = asRecord22(payload);
76715
+ const p3 = asRecord23(payload);
76633
76716
  try {
76634
76717
  return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p3.projectId ?? "")) } };
76635
76718
  } catch (err) {
@@ -76639,7 +76722,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
76639
76722
  function handleGitWorktreeAssignBranch(payload, ctx) {
76640
76723
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76641
76724
  if (denied) return denied;
76642
- const p3 = asRecord22(payload);
76725
+ const p3 = asRecord23(payload);
76643
76726
  try {
76644
76727
  return {
76645
76728
  result: ctx.workspaceGit.assignBranch(
@@ -76655,7 +76738,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
76655
76738
  function handleGitWorktreeHandoff(payload, ctx) {
76656
76739
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76657
76740
  if (denied) return denied;
76658
- const p3 = asRecord22(payload);
76741
+ const p3 = asRecord23(payload);
76659
76742
  try {
76660
76743
  return {
76661
76744
  result: ctx.workspaceGit.handoffToMain(
@@ -76670,7 +76753,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
76670
76753
  function handleGitWorktreeHandoffPreview(payload, ctx) {
76671
76754
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76672
76755
  if (denied) return denied;
76673
- const p3 = asRecord22(payload);
76756
+ const p3 = asRecord23(payload);
76674
76757
  try {
76675
76758
  return {
76676
76759
  result: ctx.workspaceGit.handoffPreview(
@@ -76685,7 +76768,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
76685
76768
  function handleSessionSetCwd(payload, ctx) {
76686
76769
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76687
76770
  if (denied) return denied;
76688
- const p3 = asRecord22(payload);
76771
+ const p3 = asRecord23(payload);
76689
76772
  const sessionId = String(p3.sessionId ?? "");
76690
76773
  const cwdRaw = p3.cwd;
76691
76774
  const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
@@ -76714,7 +76797,7 @@ function handleSessionSetCwd(payload, ctx) {
76714
76797
  function handleSessionPatchSettings(payload, ctx) {
76715
76798
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76716
76799
  if (denied) return denied;
76717
- const p3 = asRecord22(payload);
76800
+ const p3 = asRecord23(payload);
76718
76801
  const sessionId = String(p3.sessionId ?? "").trim();
76719
76802
  if (!sessionId) {
76720
76803
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76730,7 +76813,7 @@ function handleSessionPatchSettings(payload, ctx) {
76730
76813
  generation: String(p3.generation ?? ""),
76731
76814
  holderClientId: ctx.client.clientSessionId
76732
76815
  });
76733
- const settingsSrc = asRecord22(p3.settings ?? p3);
76816
+ const settingsSrc = asRecord23(p3.settings ?? p3);
76734
76817
  const patch = {};
76735
76818
  const take = (key) => {
76736
76819
  if (!(key in settingsSrc)) return;
@@ -76756,7 +76839,7 @@ function handleSessionPatchSettings(payload, ctx) {
76756
76839
  async function handleSessionFork(payload, ctx) {
76757
76840
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76758
76841
  if (denied) return denied;
76759
- const p3 = asRecord22(payload);
76842
+ const p3 = asRecord23(payload);
76760
76843
  const sessionId = String(p3.sessionId ?? "").trim();
76761
76844
  if (!sessionId) {
76762
76845
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76843,7 +76926,7 @@ async function handleSessionFork(payload, ctx) {
76843
76926
  async function handleGitClone(payload, ctx) {
76844
76927
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
76845
76928
  if (denied) return denied;
76846
- const p3 = asRecord22(payload);
76929
+ const p3 = asRecord23(payload);
76847
76930
  try {
76848
76931
  const cloned = await cloneRepository({
76849
76932
  remoteUrl: String(p3.remoteUrl ?? ""),
@@ -76859,7 +76942,7 @@ async function handleGitClone(payload, ctx) {
76859
76942
  function handleSessionCreate(payload, ctx) {
76860
76943
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76861
76944
  if (denied) return denied;
76862
- const p3 = asRecord22(payload);
76945
+ const p3 = asRecord23(payload);
76863
76946
  const rawHarnessId = typeof p3.harnessId === "string" ? p3.harnessId : "claude";
76864
76947
  const harnessId = normalizeSessionHarnessId(rawHarnessId);
76865
76948
  if (!harnessId) {
@@ -76912,7 +76995,7 @@ function handleSessionCreate(payload, ctx) {
76912
76995
  try {
76913
76996
  const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
76914
76997
  const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
76915
- const options = asRecord22(p3.options);
76998
+ const options = asRecord23(p3.options);
76916
76999
  const providerId = typeof p3.providerId === "string" && p3.providerId.trim() ? p3.providerId.trim() : void 0;
76917
77000
  const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
76918
77001
  const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
@@ -76973,7 +77056,7 @@ function handleSessionCreate(payload, ctx) {
76973
77056
  function handleSessionGet(payload, ctx) {
76974
77057
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76975
77058
  if (denied) return denied;
76976
- const p3 = asRecord22(payload);
77059
+ const p3 = asRecord23(payload);
76977
77060
  return { result: ctx.sessions.get(String(p3.sessionId ?? "")) };
76978
77061
  }
76979
77062
  function mapSessionRow(s4) {
@@ -77002,7 +77085,7 @@ function mapSessionRow(s4) {
77002
77085
  function handleSessionList(payload, ctx) {
77003
77086
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77004
77087
  if (denied) return denied;
77005
- const p3 = asRecord22(payload);
77088
+ const p3 = asRecord23(payload);
77006
77089
  const projectId = typeof p3.projectId === "string" ? p3.projectId : void 0;
77007
77090
  if (typeof p3.limit !== "number" || !Number.isFinite(p3.limit)) {
77008
77091
  return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
@@ -77018,7 +77101,7 @@ function handleSessionList(payload, ctx) {
77018
77101
  function handleSessionListPinned(payload, ctx) {
77019
77102
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77020
77103
  if (denied) return denied;
77021
- const p3 = asRecord22(payload);
77104
+ const p3 = asRecord23(payload);
77022
77105
  const limit = typeof p3.limit === "number" && Number.isFinite(p3.limit) ? Math.min(Math.max(Math.floor(p3.limit), 0), 500) : 200;
77023
77106
  const rows = ctx.sessions.list(void 0).filter((s4) => s4.isPinned === true && s4.isHidden !== true).slice(0, limit);
77024
77107
  return {
@@ -77035,7 +77118,7 @@ function handleSessionListPinned(payload, ctx) {
77035
77118
  function handleSessionAcquireControl(payload, ctx) {
77036
77119
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77037
77120
  if (denied) return denied;
77038
- const p3 = asRecord22(payload);
77121
+ const p3 = asRecord23(payload);
77039
77122
  const sessionId = String(p3.sessionId ?? "");
77040
77123
  if (!sessionId) {
77041
77124
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77059,7 +77142,7 @@ function handleSessionAcquireControl(payload, ctx) {
77059
77142
  function handleSessionRenewControl(payload, ctx) {
77060
77143
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77061
77144
  if (denied) return denied;
77062
- const p3 = asRecord22(payload);
77145
+ const p3 = asRecord23(payload);
77063
77146
  try {
77064
77147
  return {
77065
77148
  result: ctx.leases.renew({
@@ -77076,7 +77159,7 @@ function handleSessionRenewControl(payload, ctx) {
77076
77159
  function handleSessionReleaseControl(payload, ctx) {
77077
77160
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77078
77161
  if (denied) return denied;
77079
- const p3 = asRecord22(payload);
77162
+ const p3 = asRecord23(payload);
77080
77163
  try {
77081
77164
  ctx.leases.release(
77082
77165
  String(p3.leaseId ?? ""),
@@ -77091,7 +77174,7 @@ function handleSessionReleaseControl(payload, ctx) {
77091
77174
  function handleSessionClose(payload, ctx) {
77092
77175
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77093
77176
  if (denied) return denied;
77094
- const p3 = asRecord22(payload);
77177
+ const p3 = asRecord23(payload);
77095
77178
  const sessionId = String(p3.sessionId ?? "");
77096
77179
  try {
77097
77180
  ctx.leases.assertValid({
@@ -77117,7 +77200,7 @@ function handleSessionClose(payload, ctx) {
77117
77200
  function handleSessionRemove(payload, ctx) {
77118
77201
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77119
77202
  if (denied) return denied;
77120
- const p3 = asRecord22(payload);
77203
+ const p3 = asRecord23(payload);
77121
77204
  const sessionId = String(p3.sessionId ?? "");
77122
77205
  if (!sessionId) {
77123
77206
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77144,7 +77227,7 @@ function handleSessionRemove(payload, ctx) {
77144
77227
  function handleSessionRename(payload, ctx) {
77145
77228
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77146
77229
  if (denied) return denied;
77147
- const p3 = asRecord22(payload);
77230
+ const p3 = asRecord23(payload);
77148
77231
  const sessionId = String(p3.sessionId ?? "");
77149
77232
  const title = String(p3.title ?? "");
77150
77233
  const source = p3.source === "agent" ? "agent" : "user";
@@ -77160,7 +77243,7 @@ function handleSessionRename(payload, ctx) {
77160
77243
  function handleSessionSetTags(payload, ctx) {
77161
77244
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77162
77245
  if (denied) return denied;
77163
- const p3 = asRecord22(payload);
77246
+ const p3 = asRecord23(payload);
77164
77247
  const sessionId = String(p3.sessionId ?? "");
77165
77248
  if (!sessionId) {
77166
77249
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77186,7 +77269,7 @@ function handleSessionSetTags(payload, ctx) {
77186
77269
  function handleSessionSetUiFlags(payload, ctx) {
77187
77270
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77188
77271
  if (denied) return denied;
77189
- const p3 = asRecord22(payload);
77272
+ const p3 = asRecord23(payload);
77190
77273
  const sessionId = String(p3.sessionId ?? "");
77191
77274
  if (!sessionId) {
77192
77275
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77205,9 +77288,9 @@ function handleSessionSetUiFlags(payload, ctx) {
77205
77288
  async function handleSessionSend(payload, ctx) {
77206
77289
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77207
77290
  if (denied) return denied;
77208
- const p3 = asRecord22(payload);
77291
+ const p3 = asRecord23(payload);
77209
77292
  try {
77210
- const options = asRecord22(p3.options);
77293
+ const options = asRecord23(p3.options);
77211
77294
  const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
77212
77295
  const modelTopLevel = typeof p3.model === "string" && p3.model.trim() ? p3.model.trim() : null;
77213
77296
  const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
@@ -77304,7 +77387,7 @@ async function handleSessionSend(payload, ctx) {
77304
77387
  function handleSessionInterrupt(payload, ctx) {
77305
77388
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77306
77389
  if (denied) return denied;
77307
- const p3 = asRecord22(payload);
77390
+ const p3 = asRecord23(payload);
77308
77391
  try {
77309
77392
  ctx.sessions.interrupt(
77310
77393
  String(p3.sessionId ?? ""),
@@ -77320,7 +77403,7 @@ function handleSessionInterrupt(payload, ctx) {
77320
77403
  function handleSessionRespondPermission(payload, ctx) {
77321
77404
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77322
77405
  if (denied) return denied;
77323
- const p3 = asRecord22(payload);
77406
+ const p3 = asRecord23(payload);
77324
77407
  try {
77325
77408
  const formAnswers = p3.formAnswers && typeof p3.formAnswers === "object" && !Array.isArray(p3.formAnswers) ? p3.formAnswers : p3.options && typeof p3.options === "object" && !Array.isArray(p3.options) ? p3.options.formAnswers ?? p3.options : void 0;
77326
77409
  ctx.sessions.respondPermission({
@@ -77341,7 +77424,7 @@ function handleSessionRespondPermission(payload, ctx) {
77341
77424
  function handleSessionRespondQuestion(payload, ctx) {
77342
77425
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77343
77426
  if (denied) return denied;
77344
- const p3 = asRecord22(payload);
77427
+ const p3 = asRecord23(payload);
77345
77428
  try {
77346
77429
  ctx.sessions.respondQuestion({
77347
77430
  sessionId: String(p3.sessionId ?? ""),
@@ -77359,7 +77442,7 @@ function handleSessionRespondQuestion(payload, ctx) {
77359
77442
  function handleSessionRespondPlan(payload, ctx) {
77360
77443
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77361
77444
  if (denied) return denied;
77362
- const p3 = asRecord22(payload);
77445
+ const p3 = asRecord23(payload);
77363
77446
  const decision = p3.decision === "approve" || p3.decision === "reject" ? p3.decision : null;
77364
77447
  if (!decision) {
77365
77448
  return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
@@ -77382,7 +77465,7 @@ function handleSessionRespondPlan(payload, ctx) {
77382
77465
  async function handleSessionHostActionsPoll(payload, ctx) {
77383
77466
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77384
77467
  if (denied) return denied;
77385
- const p3 = asRecord22(payload);
77468
+ const p3 = asRecord23(payload);
77386
77469
  try {
77387
77470
  const result = await ctx.sessions.pollHostActions({
77388
77471
  controllerClientSessionId: ctx.client.clientSessionId,
@@ -77398,7 +77481,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
77398
77481
  function handleSessionClaimHostAction(payload, ctx) {
77399
77482
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77400
77483
  if (denied) return denied;
77401
- const p3 = asRecord22(payload);
77484
+ const p3 = asRecord23(payload);
77402
77485
  try {
77403
77486
  const result = ctx.sessions.claimHostAction({
77404
77487
  actionId: String(p3.actionId ?? ""),
@@ -77414,7 +77497,7 @@ function handleSessionClaimHostAction(payload, ctx) {
77414
77497
  function handleSessionRespondHostAction(payload, ctx) {
77415
77498
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77416
77499
  if (denied) return denied;
77417
- const p3 = asRecord22(payload);
77500
+ const p3 = asRecord23(payload);
77418
77501
  const outcome = p3.outcome === "failed" ? "failed" : p3.outcome === "succeeded" ? "succeeded" : null;
77419
77502
  if (!outcome) {
77420
77503
  return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
@@ -77436,14 +77519,14 @@ function handleSessionRespondHostAction(payload, ctx) {
77436
77519
  function handleSessionEvents(payload, ctx) {
77437
77520
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77438
77521
  if (denied) return denied;
77439
- const p3 = asRecord22(payload);
77522
+ const p3 = asRecord23(payload);
77440
77523
  const after = String(p3.afterSequence ?? "0");
77441
77524
  return { result: { events: ctx.sessions.listEventsAfter(after) } };
77442
77525
  }
77443
77526
  function handleSessionMessagesList(payload, ctx) {
77444
77527
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77445
77528
  if (denied) return denied;
77446
- const p3 = asRecord22(payload);
77529
+ const p3 = asRecord23(payload);
77447
77530
  const sessionId = String(p3.sessionId ?? "").trim();
77448
77531
  if (!sessionId) {
77449
77532
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77482,7 +77565,7 @@ function handleCollaborationListProfiles(ctx) {
77482
77565
  async function handleCollaborationRequest(payload, ctx) {
77483
77566
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77484
77567
  if (denied) return denied;
77485
- const p3 = asRecord22(payload);
77568
+ const p3 = asRecord23(payload);
77486
77569
  const parentSessionId = String(p3.parentSessionId ?? "");
77487
77570
  if (!parentSessionId) {
77488
77571
  return { error: { code: "invalid_argument", message: "parentSessionId required" } };
@@ -77516,7 +77599,7 @@ async function handleCollaborationRequest(payload, ctx) {
77516
77599
  async function handleCollaborationStart(payload, ctx) {
77517
77600
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77518
77601
  if (denied) return denied;
77519
- const p3 = asRecord22(payload);
77602
+ const p3 = asRecord23(payload);
77520
77603
  const credential = typeof p3.credential === "string" ? p3.credential : void 0;
77521
77604
  const grantId = typeof p3.grantId === "string" ? p3.grantId : void 0;
77522
77605
  if (!credential && !grantId) {
@@ -77562,7 +77645,7 @@ async function handleCollaborationStart(payload, ctx) {
77562
77645
  function handleCollaborationSend(payload, ctx) {
77563
77646
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77564
77647
  if (denied) return denied;
77565
- const p3 = asRecord22(payload);
77648
+ const p3 = asRecord23(payload);
77566
77649
  const credential = String(p3.credential ?? "");
77567
77650
  const sessionId = String(p3.sessionId ?? p3.fromSessionId ?? "");
77568
77651
  const content = typeof p3.content === "string" ? p3.content : p3.body !== void 0 ? typeof p3.body === "string" ? p3.body : JSON.stringify(p3.body) : "";
@@ -77598,7 +77681,7 @@ function handleCollaborationSend(payload, ctx) {
77598
77681
  function handleCollaborationRetrieve(payload, ctx) {
77599
77682
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77600
77683
  if (denied) return denied;
77601
- const p3 = asRecord22(payload);
77684
+ const p3 = asRecord23(payload);
77602
77685
  const credential = String(p3.credential ?? "");
77603
77686
  const sessionId = String(p3.sessionId ?? "");
77604
77687
  if (!credential) {
@@ -78440,8 +78523,8 @@ function requiredRuntimeVersion(harnessId, manifest) {
78440
78523
  import { existsSync as existsSync28, mkdirSync as mkdirSync17, readFileSync as readFileSync16, readdirSync as readdirSync10, statSync as statSync9, writeFileSync as writeFileSync12 } from "node:fs";
78441
78524
  import { arch as osArch2, platform as osPlatform2 } from "node:os";
78442
78525
  import { join as join27, resolve as resolve7 } from "node:path";
78443
- var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.257";
78444
- var OFFICIAL_CODEX_NPM_VERSION = "0.153.2";
78526
+ var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.269";
78527
+ var OFFICIAL_CODEX_NPM_VERSION = "0.154.0";
78445
78528
  var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
78446
78529
  function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
78447
78530
  const platform2 = process.platform;
@@ -99447,6 +99530,27 @@ var AutomationService = class {
99447
99530
 
99448
99531
  // ../../packages/runtime/src/drafts/store.ts
99449
99532
  init_environment();
99533
+
99534
+ // ../../packages/shared/src/environment/draft-content.ts
99535
+ function hasPersistableDraftContent(draft) {
99536
+ if (draft.text.trim() || draft.attachments?.length) return true;
99537
+ const pending = [draft.docJson];
99538
+ const seen = /* @__PURE__ */ new Set();
99539
+ while (pending.length) {
99540
+ const node = pending.pop();
99541
+ if (!node || typeof node !== "object") continue;
99542
+ if (seen.has(node)) continue;
99543
+ seen.add(node);
99544
+ const { type, text, attrs, content } = node;
99545
+ if (type === "text" && typeof text === "string" && text.trim()) return true;
99546
+ const value = type === "pasteChip" ? attrs?.text : type === "mention" ? attrs?.value : null;
99547
+ if (typeof value === "string" && value.trim()) return true;
99548
+ if (Array.isArray(content)) pending.push(...content);
99549
+ }
99550
+ return false;
99551
+ }
99552
+
99553
+ // ../../packages/runtime/src/drafts/store.ts
99450
99554
  var DRAFTS_TABLE_DDL = `
99451
99555
  CREATE TABLE IF NOT EXISTS drafts (
99452
99556
  id TEXT PRIMARY KEY NOT NULL,
@@ -99545,6 +99649,7 @@ function denormalize(input) {
99545
99649
  }
99546
99650
  function createDraftStore(db) {
99547
99651
  ensureDraftsTable(db);
99652
+ const emptyEditors = /* @__PURE__ */ new Map();
99548
99653
  const selectOne = db.prepare("SELECT * FROM drafts WHERE id = ?");
99549
99654
  const selectAll = db.prepare("SELECT * FROM drafts ORDER BY updated_at DESC, id DESC");
99550
99655
  const selectByProject = db.prepare(
@@ -99573,9 +99678,13 @@ ON CONFLICT(id) DO UPDATE SET
99573
99678
  updated_at = excluded.updated_at
99574
99679
  `);
99575
99680
  const get3 = (id) => {
99681
+ if (emptyEditors.has(id)) return emptyEditors.get(id);
99576
99682
  const row = selectOne.get(id);
99577
99683
  return row ? toRecord2(row) : void 0;
99578
99684
  };
99685
+ for (const row of selectAll.all()) {
99686
+ if (!hasPersistableDraftContent(toRecord2(row))) deleteOne.run(row.id);
99687
+ }
99579
99688
  return {
99580
99689
  list(projectPath) {
99581
99690
  const rows = projectPath === void 0 ? selectAll.all() : selectByProject.all(projectPath);
@@ -99583,12 +99692,37 @@ ON CONFLICT(id) DO UPDATE SET
99583
99692
  },
99584
99693
  get: get3,
99585
99694
  upsert(input) {
99586
- const now = (/* @__PURE__ */ new Date()).toISOString();
99587
99695
  const existing = get3(input.id);
99696
+ const now = new Date(Math.max(Date.now(), existing ? Date.parse(existing.updatedAt) + 1 : 0)).toISOString();
99588
99697
  const attachments = clampAttachments(input.attachments);
99589
99698
  const originSessionId = input.originSessionId ?? null;
99590
99699
  const { harness, model, permissionMode, settings } = denormalize(input);
99591
- if (originSessionId) deleteOtherOwners.run(originSessionId, input.id);
99700
+ if (originSessionId) {
99701
+ deleteOtherOwners.run(originSessionId, input.id);
99702
+ for (const [id, editor] of emptyEditors) {
99703
+ if (id !== input.id && editor.originSessionId === originSessionId) emptyEditors.delete(id);
99704
+ }
99705
+ }
99706
+ if (!hasPersistableDraftContent({ ...input, attachments })) {
99707
+ const cleared = {
99708
+ id: input.id,
99709
+ title: "",
99710
+ text: input.text,
99711
+ docJson: input.docJson ?? null,
99712
+ attachments,
99713
+ projectPath: input.projectPath ?? null,
99714
+ harness,
99715
+ model,
99716
+ permissionMode,
99717
+ settings: { harness, model, permissionMode, ...settings },
99718
+ originSessionId,
99719
+ createdAt: existing?.createdAt ?? input.createdAt ?? now,
99720
+ updatedAt: now
99721
+ };
99722
+ deleteOne.run(input.id);
99723
+ emptyEditors.set(input.id, cleared);
99724
+ return cleared;
99725
+ }
99592
99726
  upsertOne.run(
99593
99727
  input.id,
99594
99728
  deriveDraftTitle(input.text),
@@ -99604,10 +99738,12 @@ ON CONFLICT(id) DO UPDATE SET
99604
99738
  existing?.createdAt ?? input.createdAt ?? now,
99605
99739
  now
99606
99740
  );
99741
+ emptyEditors.delete(input.id);
99607
99742
  return get3(input.id);
99608
99743
  },
99609
99744
  delete(id) {
99610
- return deleteOne.run(id).changes > 0;
99745
+ const empty = emptyEditors.delete(id);
99746
+ return deleteOne.run(id).changes > 0 || empty;
99611
99747
  }
99612
99748
  };
99613
99749
  }