@super-one/cli 0.55.1-alpha → 0.56.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/MANIFEST.json +2 -2
  2. package/lib/cli.mjs +839 -271
  3. package/package.json +10 -10
package/lib/cli.mjs CHANGED
@@ -164,14 +164,109 @@ var init_host_actions = __esm({
164
164
  });
165
165
 
166
166
  // ../../packages/shared/src/environment/host-action-superone-descriptors.ts
167
- var HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS;
167
+ var deviceDescriptionProperty, deviceConditionSchema, deviceActionSchema, HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS;
168
168
  var init_host_action_superone_descriptors = __esm({
169
169
  "../../packages/shared/src/environment/host-action-superone-descriptors.ts"() {
170
170
  "use strict";
171
+ deviceDescriptionProperty = {
172
+ type: "string",
173
+ minLength: 1,
174
+ maxLength: 160,
175
+ description: "A short human-friendly explanation of what this step accomplishes, phrased for the user watching (e.g. 'Open the profile tab', 'Check the order total'). Shown in the UI in place of refs and coordinates. Write it in the conversation's language."
176
+ };
177
+ deviceConditionSchema = {
178
+ type: "object",
179
+ properties: {
180
+ kind: { type: "string", enum: ["exists", "notExists", "textEquals", "textContains"] },
181
+ ref: {
182
+ description: "Only valid within the snapshot it came from; prefer label or identifier when waiting.",
183
+ type: "string"
184
+ },
185
+ label: { description: "Visible name of the element.", type: "string" },
186
+ identifier: {
187
+ description: "Developer-assigned id. Survives copy changes and translation \u2014 the most durable target.",
188
+ type: "string"
189
+ },
190
+ text: {
191
+ description: "The string textEquals/textContains compares against. Required by those two kinds, and NOT a way to name an element \u2014 use label for that.",
192
+ type: "string",
193
+ minLength: 1
194
+ }
195
+ },
196
+ required: ["kind"],
197
+ additionalProperties: false
198
+ };
199
+ deviceActionSchema = {
200
+ type: "object",
201
+ properties: {
202
+ type: {
203
+ type: "string",
204
+ enum: ["tap", "doubleTap", "longPress", "swipe", "pinch", "press", "type", "key", "rotate", "keyboard"]
205
+ },
206
+ ref: { description: 'Element ref from the snapshot, e.g. "@e12". Preferred over coordinates.', type: "string" },
207
+ x: {
208
+ description: "Horizontal position as a fraction of the screen (0-1). Only when no ref fits.",
209
+ type: "number",
210
+ minimum: 0,
211
+ maximum: 1
212
+ },
213
+ y: {
214
+ description: "Vertical position as a fraction of the screen (0-1).",
215
+ type: "number",
216
+ minimum: 0,
217
+ maximum: 1
218
+ },
219
+ direction: {
220
+ description: 'swipe: which way the finger travels. Content moves the opposite way, so "up" scrolls down a list.',
221
+ type: "string",
222
+ enum: ["up", "down", "left", "right"]
223
+ },
224
+ distance: {
225
+ description: "swipe: travel as a fraction of the screen. Default 0.6.",
226
+ type: "number",
227
+ minimum: 0.05,
228
+ maximum: 1
229
+ },
230
+ toX: {
231
+ description: "swipe: explicit destination instead of direction.",
232
+ type: "number",
233
+ minimum: 0,
234
+ maximum: 1
235
+ },
236
+ toY: { type: "number", minimum: 0, maximum: 1 },
237
+ scale: {
238
+ description: "pinch: final separation factor. Below 1 pinches in (zoom out), above 1 spreads.",
239
+ type: "number",
240
+ minimum: 0.1,
241
+ maximum: 5
242
+ },
243
+ durationMs: {
244
+ description: "How long the gesture takes. Short swipes flick and coast; long ones drag and stop.",
245
+ type: "integer",
246
+ minimum: 16,
247
+ maximum: 1e4
248
+ },
249
+ text: {
250
+ description: "type: text to enter. Anything the simulated keyboard cannot spell (Chinese, emoji) is pasted automatically.",
251
+ type: "string"
252
+ },
253
+ button: { type: "string", enum: ["home", "lock", "side", "volume-up", "volume-down"] },
254
+ orientation: {
255
+ type: "string",
256
+ enum: ["portrait", "landscape-left", "portrait-upside-down", "landscape-right"]
257
+ },
258
+ connected: {
259
+ description: "keyboard: attach or detach the hardware keyboard. Detach it to make the on-screen keyboard appear.",
260
+ type: "boolean"
261
+ }
262
+ },
263
+ required: ["type"],
264
+ additionalProperties: false
265
+ };
171
266
  HOST_ACTION_SUPERONE_TOOL_DESCRIPTORS = [
172
267
  {
173
268
  "name": "session_collab_list_agents",
174
- "description": "List the agent profiles available for user-approved child sessions. Inspect each profile's harness and defaultConfig before session_collab_request. You may reuse one agentId for multiple launches.",
269
+ "description": "List the agent profiles available for user-approved child sessions. Only launchable agents are returned. Inspect each profile's harness and defaultConfig before session_collab_request. You may reuse one agentId for multiple launches. Skip this call when the user already named an agent with @ \u2014 that mention carries its agentId.",
175
270
  "inputSchema": {
176
271
  "type": "object",
177
272
  "properties": {},
@@ -3620,6 +3715,75 @@ If the tool returns an error containing "user_locked", the user has manually nam
3620
3715
  ],
3621
3716
  "additionalProperties": false
3622
3717
  }
3718
+ },
3719
+ {
3720
+ "name": "device_snapshot",
3721
+ "description": "Capture the screen and return a stateId later calls must quote. mode=semantic (default) returns the accessibility tree with @eN refs, labels, identifiers and bounds \u2014 prefer it: refs survive animation and rotation, coordinates do not. mode=visual saves a PNG and returns image.path (not pixels); Read it only if you need to look. mode=fused returns both. Waits for animation to stop first; settled=false means it was still moving, so treat geometry as approximate. A screen with no accessibility tree falls back to text read from pixels; the reply says source=ocr. Re-snapshot after anything that changes the screen \u2014 refs are positional and a stale stateId is rejected by device_act.",
3722
+ "inputSchema": {
3723
+ "type": "object",
3724
+ "properties": {
3725
+ "description": deviceDescriptionProperty,
3726
+ "mode": { "description": "Default semantic", "type": "string", "enum": ["semantic", "visual", "fused"] },
3727
+ "maxNodes": {
3728
+ "description": "Ceiling on tree size. Default 500; truncated=true means the screen has more.",
3729
+ "type": "integer",
3730
+ "minimum": 1,
3731
+ "maximum": 2e3
3732
+ }
3733
+ },
3734
+ "required": ["description"],
3735
+ "additionalProperties": false
3736
+ }
3737
+ },
3738
+ {
3739
+ "name": "device_query",
3740
+ "description": "Search or inspect an existing snapshot without re-capturing the device. Use this instead of taking another snapshot when you only need to find an element or read its details \u2014 it costs no device round trip and cannot race an animation. op=search matches text against labels, values and identifiers. op=inspect returns one element and its children.",
3741
+ "inputSchema": {
3742
+ "type": "object",
3743
+ "properties": {
3744
+ "description": deviceDescriptionProperty,
3745
+ "stateId": { "type": "string", "description": "From a prior device_snapshot." },
3746
+ "op": { "type": "string", "enum": ["search", "inspect"] },
3747
+ "text": { "description": "For search.", "type": "string" },
3748
+ "ref": { "description": 'For inspect, e.g. "@e12".', "type": "string" }
3749
+ },
3750
+ "required": ["description", "stateId", "op"],
3751
+ "additionalProperties": false
3752
+ }
3753
+ },
3754
+ {
3755
+ "name": "device_act",
3756
+ "description": "Run 1-10 touch actions against a snapshot, then re-observe to judge if they worked. Actions: tap, doubleTap, longPress, swipe(direction|toX/toY), pinch(scale), press(ref), type, key, rotate, keyboard. Prefer press for a ref-backed control; it goes through accessibility, immune to animation, rotation and scale (not on a source=ocr snapshot \u2014 tap there). Aim touch actions at refs too; raw x/y is a last resort. The whole batch, stale stateId included, is validated up front. rotate ends the snapshot it is in: put it last, then re-snapshot \u2014 a later ref or coordinate is refused. Returns worked|didnt|unknown; unknown means input landed but nothing visibly changed. Pass expect to define success.",
3757
+ "inputSchema": {
3758
+ "type": "object",
3759
+ "properties": {
3760
+ "description": deviceDescriptionProperty,
3761
+ "stateId": { "type": "string" },
3762
+ "actions": { "minItems": 1, "maxItems": 10, "type": "array", "items": deviceActionSchema },
3763
+ "expect": { "description": "Postcondition checked after the actions run.", ...deviceConditionSchema }
3764
+ },
3765
+ "required": ["description", "stateId", "actions"],
3766
+ "additionalProperties": false
3767
+ }
3768
+ },
3769
+ {
3770
+ "name": "device_wait_for",
3771
+ "description": "Wait until the screen satisfies a condition. Use this instead of snapshotting in a loop. Distinguishes preexisting (already true when asked) from verified (became true while waiting), so you can tell a real transition from a check that was never going to fail. Returns a fresh settled stateId and matching tree when successful. Target the element by label or identifier, not by ref: refs belong to one snapshot, and what you are waiting for usually does not exist yet. Every condition must name an element that way \u2014 text only says what to compare, it never selects.",
3772
+ "inputSchema": {
3773
+ "type": "object",
3774
+ "properties": {
3775
+ "description": deviceDescriptionProperty,
3776
+ "condition": deviceConditionSchema,
3777
+ "timeoutMs": {
3778
+ "description": "Default 5000",
3779
+ "type": "integer",
3780
+ "minimum": 100,
3781
+ "maximum": 6e4
3782
+ }
3783
+ },
3784
+ "required": ["description", "condition"],
3785
+ "additionalProperties": false
3786
+ }
3623
3787
  }
3624
3788
  ];
3625
3789
  }
@@ -3693,6 +3857,9 @@ var init_host_action_browser_catalog = __esm({
3693
3857
  "widget_list_templates",
3694
3858
  "miniapp_list",
3695
3859
  "automation_list",
3860
+ "device_snapshot",
3861
+ "device_query",
3862
+ "device_wait_for",
3696
3863
  // session_collab_* are node-local (not HA); list_agents stays "safe" if ever reclassified
3697
3864
  "computer_apps",
3698
3865
  "computer_snapshot",
@@ -20267,6 +20434,45 @@ function readString3(value) {
20267
20434
  function readBoolean2(value) {
20268
20435
  return typeof value === "boolean" ? value : null;
20269
20436
  }
20437
+ function parseAccountAuthMode(value) {
20438
+ switch (value) {
20439
+ case "apiKey":
20440
+ case "chatgpt":
20441
+ case "chatgptAuthTokens":
20442
+ case "agentIdentity":
20443
+ case "personalAccessToken":
20444
+ case "amazonBedrock":
20445
+ case "bedrockApiKey":
20446
+ return value;
20447
+ default:
20448
+ return null;
20449
+ }
20450
+ }
20451
+ function parseAccountStatus(raw) {
20452
+ const account = asRecord3(raw.account);
20453
+ return {
20454
+ signedIn: account !== null,
20455
+ authMode: parseAccountAuthMode(account?.type),
20456
+ email: readString3(account?.email),
20457
+ planType: readString3(account?.planType),
20458
+ requiresOpenaiAuth: readBoolean2(raw.requiresOpenaiAuth) ?? false
20459
+ };
20460
+ }
20461
+ function parseAccountLoginStart(raw) {
20462
+ const loginId = readString3(raw.loginId);
20463
+ const type = readString3(raw.type);
20464
+ if (!loginId || type !== "chatgpt" && type !== "chatgptDeviceCode") {
20465
+ throw new Error("Codex returned an invalid account login response");
20466
+ }
20467
+ const result = { type, loginId };
20468
+ const authUrl = readString3(raw.authUrl);
20469
+ const verificationUrl = readString3(raw.verificationUrl);
20470
+ const userCode = readString3(raw.userCode);
20471
+ if (authUrl) result.authUrl = authUrl;
20472
+ if (verificationUrl) result.verificationUrl = verificationUrl;
20473
+ if (userCode) result.userCode = userCode;
20474
+ return result;
20475
+ }
20270
20476
  function readFiniteNumber(value) {
20271
20477
  return typeof value === "number" && Number.isFinite(value) ? value : null;
20272
20478
  }
@@ -20367,6 +20573,37 @@ async function readRateLimits(client3) {
20367
20573
  throw safePublicError("account/rateLimits/read failed", err);
20368
20574
  }
20369
20575
  }
20576
+ async function readAccountStatus(client3, refreshToken = false) {
20577
+ try {
20578
+ return parseAccountStatus(await client3.request("account/read", { refreshToken }));
20579
+ } catch (err) {
20580
+ throw safePublicError("account/read failed", err);
20581
+ }
20582
+ }
20583
+ async function startAccountLogin(client3, type) {
20584
+ try {
20585
+ return parseAccountLoginStart(await client3.request(
20586
+ "account/login/start",
20587
+ type === "chatgpt" ? { type, useHostedLoginSuccessPage: true, appBrand: "chatgpt" } : { type }
20588
+ ));
20589
+ } catch (err) {
20590
+ throw safePublicError("account/login/start failed", err);
20591
+ }
20592
+ }
20593
+ async function cancelAccountLogin(client3, loginId) {
20594
+ try {
20595
+ await client3.request("account/login/cancel", { loginId });
20596
+ } catch (err) {
20597
+ throw safePublicError("account/login/cancel failed", err);
20598
+ }
20599
+ }
20600
+ async function logoutAccount(client3) {
20601
+ try {
20602
+ await client3.request("account/logout");
20603
+ } catch (err) {
20604
+ throw safePublicError("account/logout failed", err);
20605
+ }
20606
+ }
20370
20607
  async function readAccountUsage(client3) {
20371
20608
  try {
20372
20609
  const result = await client3.request("account/usage/read");
@@ -20618,7 +20855,7 @@ function isStaticHostOwnedSuperoneToolQualified(qualifiedName) {
20618
20855
  const bare = qualifiedName.slice(MCP_SUPERONE_TOOL_PREFIX.length);
20619
20856
  return isStaticHostOwnedSuperoneBareName(bare);
20620
20857
  }
20621
- var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_LEGACY_TOOL_NAMES, BROWSER_COMPACT_TOOL_NAMES, BROWSER_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
20858
+ var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_LEGACY_TOOL_NAMES, BROWSER_COMPACT_TOOL_NAMES, BROWSER_TOOL_NAMES, DEVICE_AGENT_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
20622
20859
  var init_superone_host_owned_tools = __esm({
20623
20860
  "../../packages/shared/src/superone-host-owned-tools.ts"() {
20624
20861
  "use strict";
@@ -20679,6 +20916,12 @@ var init_superone_host_owned_tools = __esm({
20679
20916
  (name) => !BROWSER_LEGACY_TOOL_NAMES.includes(name)
20680
20917
  )
20681
20918
  ];
20919
+ DEVICE_AGENT_TOOL_NAMES = [
20920
+ "device_snapshot",
20921
+ "device_query",
20922
+ "device_act",
20923
+ "device_wait_for"
20924
+ ];
20682
20925
  BUILT_IN_SUPERONE_TOOL_NAMES = [
20683
20926
  "read_manual",
20684
20927
  "miniapp_dev_setup",
@@ -20709,7 +20952,8 @@ var init_superone_host_owned_tools = __esm({
20709
20952
  "automation_list",
20710
20953
  "automation_apply",
20711
20954
  "automation_delete",
20712
- ...BROWSER_TOOL_NAMES
20955
+ ...BROWSER_TOOL_NAMES,
20956
+ ...DEVICE_AGENT_TOOL_NAMES
20713
20957
  ];
20714
20958
  MOBILE_SHARE_FILE_TOOL_NAME = "mobile_share_file";
20715
20959
  MINIAPP_LIST_BARE_NAME = "miniapp_list";
@@ -21182,6 +21426,7 @@ function createClaudeAgentEventMapper(options) {
21182
21426
  outputStyle: system.output_style,
21183
21427
  availableOutputStyles: system.available_output_styles,
21184
21428
  plugins: system.plugins,
21429
+ ...system.effort !== void 0 ? { appliedEffort: system.effort } : {},
21185
21430
  fastModeState: system.fast_mode_state,
21186
21431
  fastModeDisabledReason: system.fast_mode_disabled_reason
21187
21432
  }
@@ -21716,6 +21961,94 @@ var init_root_permission_guard = __esm({
21716
21961
  }
21717
21962
  });
21718
21963
 
21964
+ // ../../packages/shared/src/ask-user-question.ts
21965
+ function asQuestionPreviewFormat(value) {
21966
+ const v2 = value?.trim();
21967
+ return v2 === "markdown" || v2 === "html" ? v2 : void 0;
21968
+ }
21969
+ function buildAnsweredQuestionInput(params) {
21970
+ const { questions, answers, previewFormat } = params;
21971
+ const annotations = { ...params.annotations };
21972
+ for (const q of questions) {
21973
+ const answer = answers[q.question];
21974
+ if (!answer) continue;
21975
+ const lastLabel = q.multiSelect ? answer.split(", ").pop() : answer;
21976
+ const selected = q.options?.find((o) => o.label === lastLabel);
21977
+ if (selected?.preview) {
21978
+ annotations[q.question] = { ...annotations[q.question], preview: selected.preview };
21979
+ }
21980
+ }
21981
+ return {
21982
+ questions,
21983
+ answers,
21984
+ ...Object.keys(annotations).length > 0 && { annotations },
21985
+ ...previewFormat ? { previewFormat } : {}
21986
+ };
21987
+ }
21988
+ function answeredQuestionDelta(messageId, toolUseId, input) {
21989
+ return {
21990
+ type: "content_delta",
21991
+ messageId,
21992
+ delta: {
21993
+ type: "tool_use",
21994
+ toolName: "AskUserQuestion",
21995
+ toolUseId,
21996
+ input: JSON.stringify(input)
21997
+ }
21998
+ };
21999
+ }
22000
+ var init_ask_user_question = __esm({
22001
+ "../../packages/shared/src/ask-user-question.ts"() {
22002
+ "use strict";
22003
+ }
22004
+ });
22005
+
22006
+ // ../../packages/claude/src/ask-user-question-bridge.ts
22007
+ function asRecord5(value) {
22008
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
22009
+ }
22010
+ async function resolveAskUserQuestion(params) {
22011
+ const { onQuestion, interactionId, toolName, toolUseId, input } = params;
22012
+ if (!onQuestion) {
22013
+ return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
22014
+ }
22015
+ const previewFormat = asQuestionPreviewFormat(params.previewFormat);
22016
+ const rawInput = asRecord5(input);
22017
+ const baseInput = rawInput ? { ...rawInput, ...previewFormat ? { previewFormat } : {} } : null;
22018
+ const answer = await onQuestion({
22019
+ interactionId,
22020
+ kind: "question",
22021
+ toolName,
22022
+ toolUseId,
22023
+ input: baseInput ?? void 0
22024
+ });
22025
+ const record2 = asRecord5(answer);
22026
+ const answers = record2 && "answers" in record2 ? record2.answers : answer;
22027
+ const answerMap = asRecord5(answers);
22028
+ const updatedInput = {
22029
+ ...baseInput,
22030
+ ...buildAnsweredQuestionInput({
22031
+ questions: Array.isArray(baseInput?.questions) ? baseInput.questions : [],
22032
+ answers: answerMap ?? {},
22033
+ annotations: record2?.annotations,
22034
+ previewFormat
22035
+ }),
22036
+ // Preserve the host's answer shape verbatim — it is not always a record.
22037
+ answers
22038
+ };
22039
+ const messageId = params.getMessageId?.();
22040
+ if (messageId && toolUseId && params.emitAgentEvent) {
22041
+ params.emitAgentEvent(answeredQuestionDelta(messageId, toolUseId, updatedInput));
22042
+ }
22043
+ return { behavior: "allow", updatedInput };
22044
+ }
22045
+ var init_ask_user_question_bridge = __esm({
22046
+ "../../packages/claude/src/ask-user-question-bridge.ts"() {
22047
+ "use strict";
22048
+ init_ask_user_question();
22049
+ }
22050
+ });
22051
+
21719
22052
  // ../../packages/claude/src/run-sdk-turn.ts
21720
22053
  import { query as sdkQuery } from "@anthropic-ai/claude-agent-sdk";
21721
22054
  var init_run_sdk_turn = __esm({
@@ -21727,6 +22060,8 @@ var init_run_sdk_turn = __esm({
21727
22060
  init_agent_event_mapper2();
21728
22061
  init_resolve_sdk_binary();
21729
22062
  init_root_permission_guard();
22063
+ init_ask_user_question_bridge();
22064
+ init_ask_user_question();
21730
22065
  }
21731
22066
  });
21732
22067
 
@@ -21800,7 +22135,7 @@ var init_message_bridge = __esm({
21800
22135
  import { existsSync as existsSync18 } from "node:fs";
21801
22136
  import { randomUUID as randomUUID2 } from "node:crypto";
21802
22137
  import { query as sdkQuery2 } from "@anthropic-ai/claude-agent-sdk";
21803
- function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing) {
22138
+ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing, turn) {
21804
22139
  const abortController = new AbortController();
21805
22140
  if (signal.aborted) abortController.abort();
21806
22141
  else signal.addEventListener("abort", () => abortController.abort(), { once: true });
@@ -21813,26 +22148,16 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
21813
22148
  }
21814
22149
  const interactionId = typeof toolOpts.requestId === "string" && toolOpts.requestId || typeof toolOpts.toolUseID === "string" && toolOpts.toolUseID || `interaction_${Date.now()}`;
21815
22150
  if (toolName === "AskUserQuestion") {
21816
- if (!onQuestion) {
21817
- return { behavior: "deny", message: "Question denied by SuperOne node (no question handler)" };
21818
- }
21819
- const answer = await onQuestion({
22151
+ return resolveAskUserQuestion({
22152
+ onQuestion,
21820
22153
  interactionId,
21821
- kind: "question",
21822
22154
  toolName,
21823
22155
  toolUseId: typeof toolOpts.toolUseID === "string" ? toolOpts.toolUseID : void 0,
21824
- input: input && typeof input === "object" ? input : void 0
22156
+ input,
22157
+ previewFormat: opts.askUserQuestionPreviewFormat,
22158
+ emitAgentEvent: turn.emitAgentEvent,
22159
+ getMessageId: turn.getMessageId
21825
22160
  });
21826
- const record2 = answer && typeof answer === "object" ? answer : null;
21827
- const answers = record2 && "answers" in record2 ? record2.answers : answer;
21828
- return {
21829
- behavior: "allow",
21830
- updatedInput: {
21831
- ...input && typeof input === "object" ? input : {},
21832
- answers,
21833
- ...record2 && record2.annotations !== void 0 ? { annotations: record2.annotations } : {}
21834
- }
21835
- };
21836
22161
  }
21837
22162
  if (toolName === "ExitPlanMode") {
21838
22163
  if (!onPlan) {
@@ -21900,6 +22225,7 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
21900
22225
  ...sandbox ? { sandbox } : {},
21901
22226
  ...opts.additionalDirectories && opts.additionalDirectories.length > 0 ? { additionalDirectories: opts.additionalDirectories } : {},
21902
22227
  ...opts.enabledSkills && opts.enabledSkills.length > 0 ? { skills: opts.enabledSkills } : {},
22228
+ ...asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) ? { toolConfig: { askUserQuestion: { previewFormat: asQuestionPreviewFormat(opts.askUserQuestionPreviewFormat) } } } : {},
21903
22229
  systemPrompt: {
21904
22230
  type: "preset",
21905
22231
  preset: "claude_code",
@@ -21936,6 +22262,8 @@ var init_claude_live_session = __esm({
21936
22262
  init_map_sdk_message();
21937
22263
  init_resolve_sdk_binary();
21938
22264
  init_root_permission_guard();
22265
+ init_ask_user_question_bridge();
22266
+ init_ask_user_question();
21939
22267
  init_superone_system_prompt();
21940
22268
  init_superone_host_owned_tools();
21941
22269
  ClaudeLiveSession = class _ClaudeLiveSession {
@@ -21959,7 +22287,11 @@ var init_claude_live_session = __esm({
21959
22287
  return this.planHandler(req);
21960
22288
  },
21961
22289
  this.processAbort.signal,
21962
- this.timing
22290
+ this.timing,
22291
+ {
22292
+ emitAgentEvent: (e) => this.active?.input.onAgentEvent?.(e),
22293
+ getMessageId: () => this.active?.messageId
22294
+ }
21963
22295
  );
21964
22296
  const q = queryFn({ prompt: this.bridge, options });
21965
22297
  this.iterationDone = this.iterate(q);
@@ -22481,7 +22813,7 @@ var init_content_delta = __esm({
22481
22813
  });
22482
22814
 
22483
22815
  // ../../packages/shared/src/node-session-event-map.ts
22484
- function asRecord5(value) {
22816
+ function asRecord6(value) {
22485
22817
  if (value && typeof value === "object" && !Array.isArray(value)) {
22486
22818
  return value;
22487
22819
  }
@@ -22513,7 +22845,7 @@ function stamp(event, ctx, sequence) {
22513
22845
  }
22514
22846
  function mapQuestionRequest(payload, fallbackId) {
22515
22847
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
22516
- const input = asRecord5(payload.input);
22848
+ const input = asRecord6(payload.input);
22517
22849
  const rawQuestions = Array.isArray(payload.questions) ? payload.questions : Array.isArray(input.questions) ? input.questions : [];
22518
22850
  const questions = [];
22519
22851
  for (const q of rawQuestions) {
@@ -22552,7 +22884,7 @@ function mapQuestionRequest(payload, fallbackId) {
22552
22884
  }
22553
22885
  function mapPlanRequest(payload, fallbackId) {
22554
22886
  const interactionId = asString2(payload.interactionId) ?? asString2(payload.requestId) ?? fallbackId;
22555
- const input = asRecord5(payload.input);
22887
+ const input = asRecord6(payload.input);
22556
22888
  let planContent = asString2(payload.plan) ?? asString2(payload.planContent) ?? asString2(input.plan) ?? asString2(input.planContent) ?? "";
22557
22889
  if (!planContent && input.plan && typeof input.plan === "object") {
22558
22890
  try {
@@ -22618,7 +22950,7 @@ function createNodeSessionEventMapper(ctx) {
22618
22950
  if (envelope.aggregateType && envelope.aggregateType !== "session") return [];
22619
22951
  if (envelope.aggregateId && envelope.aggregateId !== ctx.sessionId) return [];
22620
22952
  const eventType = envelope.eventType;
22621
- const payload = asRecord5(envelope.payload);
22953
+ const payload = asRecord6(envelope.payload);
22622
22954
  const out = [];
22623
22955
  const push = (event) => {
22624
22956
  out.push(stamp(event, ctx, envelope.sequence));
@@ -22644,7 +22976,7 @@ function createNodeSessionEventMapper(ctx) {
22644
22976
  break;
22645
22977
  }
22646
22978
  case SESSION_DURABLE_EVENT.agentEvent: {
22647
- const rawEvent = asRecord5(payload.event);
22979
+ const rawEvent = asRecord6(payload.event);
22648
22980
  const type = asString2(rawEvent.type);
22649
22981
  if (!type) break;
22650
22982
  const eventRecord = { ...rawEvent };
@@ -22654,7 +22986,7 @@ function createNodeSessionEventMapper(ctx) {
22654
22986
  delete eventRecord.seq;
22655
22987
  delete eventRecord.epoch;
22656
22988
  const event = eventRecord;
22657
- const rawMessageId = type === "message_start" ? asString2(asRecord5(eventRecord.message).id) : asString2(eventRecord.messageId);
22989
+ const rawMessageId = type === "message_start" ? asString2(asRecord6(eventRecord.message).id) : asString2(eventRecord.messageId);
22658
22990
  if (type === "message_start" && rawMessageId) {
22659
22991
  startedAssistantIds.add(rawMessageId);
22660
22992
  lastAssistantId = rawMessageId;
@@ -22832,7 +23164,7 @@ function createNodeSessionEventMapper(ctx) {
22832
23164
  requestId: interactionId,
22833
23165
  toolName,
22834
23166
  toolUseId: asString2(payload.toolUseId),
22835
- input: asRecord5(payload.input),
23167
+ input: asRecord6(payload.input),
22836
23168
  allowAlwaysAllow: requestKind === "session_agents_confirm" ? false : payload.allowAlwaysAllow !== false,
22837
23169
  ...requestKind ? {
22838
23170
  requestKind
@@ -22937,7 +23269,7 @@ var init_node_session_event_map = __esm({
22937
23269
  });
22938
23270
 
22939
23271
  // ../../packages/runtime/src/session/message-catalog.ts
22940
- function asRecord6(value) {
23272
+ function asRecord7(value) {
22941
23273
  if (value && typeof value === "object" && !Array.isArray(value)) {
22942
23274
  return value;
22943
23275
  }
@@ -23020,7 +23352,7 @@ function collectToolsByAssistantId(events, sessionId) {
23020
23352
  for (const ev of events) {
23021
23353
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
23022
23354
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
23023
- const payload = asRecord6(ev.payload);
23355
+ const payload = asRecord7(ev.payload);
23024
23356
  switch (ev.eventType) {
23025
23357
  case SESSION_DURABLE_EVENT.turnStarted: {
23026
23358
  turnKey += 1;
@@ -23046,10 +23378,10 @@ function collectToolsByAssistantId(events, sessionId) {
23046
23378
  break;
23047
23379
  }
23048
23380
  case SESSION_DURABLE_EVENT.agentEvent: {
23049
- const raw = asRecord6(payload.event);
23381
+ const raw = asRecord7(payload.event);
23050
23382
  const type = asString3(raw.type);
23051
23383
  if (type === "message_start") {
23052
- const id = asString3(asRecord6(raw.message).id);
23384
+ const id = asString3(asRecord7(raw.message).id);
23053
23385
  if (id) bindAssistant(id);
23054
23386
  } else if (type === "message_complete") {
23055
23387
  const id = asString3(raw.messageId);
@@ -23057,7 +23389,7 @@ function collectToolsByAssistantId(events, sessionId) {
23057
23389
  } else if (type === "content_delta") {
23058
23390
  const messageId = asString3(raw.messageId);
23059
23391
  if (messageId) bindAssistant(messageId);
23060
- const delta = asRecord6(raw.delta);
23392
+ const delta = asRecord7(raw.delta);
23061
23393
  const dType = asString3(delta.type);
23062
23394
  if (dType === "tool_use") {
23063
23395
  const toolUseId = asString3(delta.toolUseId);
@@ -23200,7 +23532,7 @@ function collectContentByAssistantId(events, sessionId) {
23200
23532
  if (changed) contentById.set(ev.messageId, next);
23201
23533
  }
23202
23534
  }
23203
- const payload = asRecord6(envelope.payload);
23535
+ const payload = asRecord7(envelope.payload);
23204
23536
  if (envelope.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
23205
23537
  const blockId = asString3(payload.blockId);
23206
23538
  const sticky = stickyBefore ?? mapper.currentAssistantMessageId();
@@ -23224,7 +23556,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
23224
23556
  const ev = events[i];
23225
23557
  if (ev.aggregateType && ev.aggregateType !== "session") continue;
23226
23558
  if (ev.aggregateId && ev.aggregateId !== sessionId) continue;
23227
- const payload = asRecord6(ev.payload);
23559
+ const payload = asRecord7(ev.payload);
23228
23560
  if (ev.eventType === SESSION_DURABLE_EVENT.assistantMessage) {
23229
23561
  if (asString3(payload.blockId) !== blockId) continue;
23230
23562
  const checkpointId = asString3(payload.checkpointId);
@@ -23239,7 +23571,7 @@ function extractCheckpointMeta(events, sessionId, blockId) {
23239
23571
  }
23240
23572
  }
23241
23573
  if (ev.eventType === SESSION_DURABLE_EVENT.agentEvent) {
23242
- const raw = asRecord6(payload.event);
23574
+ const raw = asRecord7(payload.event);
23243
23575
  if (asString3(raw.type) !== "message_complete" && asString3(raw.type) !== "checkpoint_captured") {
23244
23576
  continue;
23245
23577
  }
@@ -23331,17 +23663,12 @@ function getBuiltinCapability(id) {
23331
23663
  function stripCapabilityMarkup(text) {
23332
23664
  return text.replace(CAPABILITY_REMINDER_REGEX, "").replace(CAPABILITY_TAG_REGEX, (_2, name) => `@${String(name).trim()}`).replace(/\s+/g, " ").trim();
23333
23665
  }
23334
- var BUILTIN_CAPABILITIES, BUILTIN_CAPABILITY_IDS, byId, CAPABILITY_TAG_REGEX, CAPABILITY_REMINDER_REGEX;
23666
+ var LEGACY_CAPABILITY_IDS, BUILTIN_CAPABILITIES, BUILTIN_CAPABILITY_IDS, byId, legacyIds, CAPABILITY_TAG_REGEX, CAPABILITY_REMINDER_REGEX;
23335
23667
  var init_capability_prompt_tags = __esm({
23336
23668
  "../../packages/shared/src/capability-prompt-tags.ts"() {
23337
23669
  "use strict";
23670
+ LEGACY_CAPABILITY_IDS = ["collab"];
23338
23671
  BUILTIN_CAPABILITIES = [
23339
- {
23340
- id: "collab",
23341
- displayName: "Agents Collaboration",
23342
- intent: "spawn and coordinate child agent sessions via collaboration tools",
23343
- toolPrefix: "session_collab_"
23344
- },
23345
23672
  {
23346
23673
  id: "computer",
23347
23674
  displayName: "Computer Use",
@@ -23369,6 +23696,7 @@ var init_capability_prompt_tags = __esm({
23369
23696
  ];
23370
23697
  BUILTIN_CAPABILITY_IDS = BUILTIN_CAPABILITIES.map((c) => c.id);
23371
23698
  byId = new Map(BUILTIN_CAPABILITIES.map((c) => [c.id, c]));
23699
+ legacyIds = new Set(LEGACY_CAPABILITY_IDS);
23372
23700
  CAPABILITY_TAG_REGEX = /<superone-capability>\s*<name>([\s\S]*?)<\/name>\s*<id>([\s\S]*?)<\/id>\s*<\/superone-capability>/g;
23373
23701
  CAPABILITY_REMINDER_REGEX = /\n*<superone-capability-reminder>[\s\S]*?<\/superone-capability-reminder>\n*/g;
23374
23702
  }
@@ -31050,6 +31378,7 @@ function createNodeClaudeTurnRunner(opts) {
31050
31378
  permissionMode: permissions.permissionMode,
31051
31379
  uid,
31052
31380
  sandboxMode: input.sandboxMode && input.sandboxMode.trim() ? input.sandboxMode.trim() : void 0,
31381
+ askUserQuestionPreviewFormat: opts.askUserQuestionPreviewFormat?.(),
31053
31382
  additionalDirectories: input.additionalDirectories?.filter(Boolean),
31054
31383
  enabledSkills: resolveEnabledSkills(cwd, input.enabledSkills, input.disabledSkills),
31055
31384
  env: authEnv,
@@ -50499,7 +50828,7 @@ function toolInputJson(raw) {
50499
50828
  return "{}";
50500
50829
  }
50501
50830
  }
50502
- function asRecord7(raw) {
50831
+ function asRecord8(raw) {
50503
50832
  if (raw && typeof raw === "object" && !Array.isArray(raw)) return raw;
50504
50833
  return {};
50505
50834
  }
@@ -50638,7 +50967,7 @@ function grokMetaInput(tool) {
50638
50967
  const xai = meta3["x.ai/tool"];
50639
50968
  if (!xai || typeof xai !== "object") return {};
50640
50969
  const input = xai.input;
50641
- return asRecord7(input);
50970
+ return asRecord8(input);
50642
50971
  }
50643
50972
  function queryFromWebSearchTitle(title) {
50644
50973
  if (!title) return void 0;
@@ -50899,11 +51228,11 @@ function unwrapMcpEnvelope(tool, raw) {
50899
51228
  if (!isEnvelope) return null;
50900
51229
  const id = raw.tool_name;
50901
51230
  if (typeof id !== "string" || !id.includes("__")) return null;
50902
- return { toolName: `mcp__${id}`, input: asRecord7(raw.tool_input) };
51231
+ return { toolName: `mcp__${id}`, input: asRecord8(raw.tool_input) };
50903
51232
  }
50904
51233
  function normalizeAcpTool(tool, opts) {
50905
- const raw = { ...grokMetaInput(tool), ...asRecord7(tool.rawInput) };
50906
- const mcp = unwrapMcpEnvelope(tool, asRecord7(tool.rawInput));
51234
+ const raw = { ...grokMetaInput(tool), ...asRecord8(tool.rawInput) };
51235
+ const mcp = unwrapMcpEnvelope(tool, asRecord8(tool.rawInput));
50907
51236
  if (mcp) return mcp;
50908
51237
  const diffs = extractDiffs(tool.content);
50909
51238
  const terminalId = extractEmbeddedTerminalId(tool.content);
@@ -51097,6 +51426,39 @@ var init_tool_result_map = __esm({
51097
51426
  }
51098
51427
  });
51099
51428
 
51429
+ // ../../packages/shared/src/acp-goal.ts
51430
+ function normalizeAcpGoalStatus(raw) {
51431
+ const status = raw.trim().toLowerCase().replace(/-/g, "_");
51432
+ switch (status) {
51433
+ case "active":
51434
+ return "active";
51435
+ case "blocked":
51436
+ return "blocked";
51437
+ case "budget_limited":
51438
+ case "budgetlimited":
51439
+ return "budgetLimited";
51440
+ case "complete":
51441
+ case "completed":
51442
+ return "complete";
51443
+ case "cleared":
51444
+ return "cleared";
51445
+ case "user_paused":
51446
+ case "backoff_paused":
51447
+ case "back_off_paused":
51448
+ case "no_progress_paused":
51449
+ case "infra_paused":
51450
+ case "paused":
51451
+ return "paused";
51452
+ default:
51453
+ return "paused";
51454
+ }
51455
+ }
51456
+ var init_acp_goal = __esm({
51457
+ "../../packages/shared/src/acp-goal.ts"() {
51458
+ "use strict";
51459
+ }
51460
+ });
51461
+
51100
51462
  // ../../packages/acp/src/xai-state.ts
51101
51463
  import { homedir as homedir4 } from "node:os";
51102
51464
  import { join as join20 } from "node:path";
@@ -51161,7 +51523,7 @@ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOu
51161
51523
  });
51162
51524
  }
51163
51525
  }
51164
- function asRecord8(v2) {
51526
+ function asRecord9(v2) {
51165
51527
  if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return null;
51166
51528
  return v2;
51167
51529
  }
@@ -51194,18 +51556,18 @@ function arrField(o, ...keys) {
51194
51556
  return void 0;
51195
51557
  }
51196
51558
  function parseXaiSessionNotificationEnvelope(raw) {
51197
- const o = asRecord8(raw);
51559
+ const o = asRecord9(raw);
51198
51560
  if (!o) return null;
51199
- const update = asRecord8(o.update);
51561
+ const update = asRecord9(o.update);
51200
51562
  if (!update) return null;
51201
51563
  const sessionId = strField(o, "sessionId", "session_id");
51202
- const meta3 = asRecord8(o._meta) ?? asRecord8(o.meta);
51564
+ const meta3 = asRecord9(o._meta) ?? asRecord9(o.meta);
51203
51565
  const eventSeq = meta3 ? numField(meta3, "eventSeq", "event_seq") ?? null : null;
51204
51566
  const eventId = meta3 ? strField(meta3, "eventId", "event_id") ?? null : null;
51205
51567
  return { sessionId, update, meta: meta3, eventSeq, eventId };
51206
51568
  }
51207
51569
  function parseXaiExtParams(raw) {
51208
- return asRecord8(raw) ?? {};
51570
+ return asRecord9(raw) ?? {};
51209
51571
  }
51210
51572
  function parsePlainTextTaskAck(text) {
51211
51573
  const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
@@ -51310,13 +51672,13 @@ function tryParseJsonObject(text) {
51310
51672
  if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return null;
51311
51673
  try {
51312
51674
  const v2 = JSON.parse(trimmed);
51313
- return asRecord8(v2);
51675
+ return asRecord9(v2);
51314
51676
  } catch {
51315
51677
  const start = trimmed.indexOf("{");
51316
51678
  const end = trimmed.lastIndexOf("}");
51317
51679
  if (start < 0 || end <= start) return null;
51318
51680
  try {
51319
- return asRecord8(JSON.parse(trimmed.slice(start, end + 1)));
51681
+ return asRecord9(JSON.parse(trimmed.slice(start, end + 1)));
51320
51682
  } catch {
51321
51683
  return null;
51322
51684
  }
@@ -51554,7 +51916,7 @@ function mapWorkflowPhases(raw) {
51554
51916
  if (!raw?.length) return [];
51555
51917
  const out = [];
51556
51918
  for (const item of raw) {
51557
- const p2 = asRecord8(item);
51919
+ const p2 = asRecord9(item);
51558
51920
  if (!p2) continue;
51559
51921
  const title = strField(p2, "title");
51560
51922
  if (!title) continue;
@@ -51572,7 +51934,7 @@ function mapWorkflowAgents(raw) {
51572
51934
  if (!raw?.length) return [];
51573
51935
  const out = [];
51574
51936
  for (const item of raw) {
51575
- const a = asRecord8(item);
51937
+ const a = asRecord9(item);
51576
51938
  if (!a) continue;
51577
51939
  const agentId = strField(a, "agent_id", "agentId");
51578
51940
  const label = strField(a, "label") ?? agentId ?? "agent";
@@ -51598,7 +51960,7 @@ function buildWorkflowPhaseSummary(u, currentPhase, pauseMessage, lastEvent, las
51598
51960
  const phaseBits = [];
51599
51961
  if (phases?.length) {
51600
51962
  for (const p2 of phases) {
51601
- const ph = asRecord8(p2);
51963
+ const ph = asRecord9(p2);
51602
51964
  if (!ph) continue;
51603
51965
  const title = strField(ph, "title") ?? "?";
51604
51966
  const state = strField(ph, "state") ?? "";
@@ -51746,7 +52108,7 @@ function mapTaskBackgrounded(u, state) {
51746
52108
  }];
51747
52109
  }
51748
52110
  function mapTaskCompleted(u, state) {
51749
- const snapshot = asRecord8(u.task_snapshot) ?? asRecord8(u.taskSnapshot) ?? u;
52111
+ const snapshot = asRecord9(u.task_snapshot) ?? asRecord9(u.taskSnapshot) ?? u;
51750
52112
  const taskId = strField(snapshot, "task_id", "taskId");
51751
52113
  if (!taskId) return [];
51752
52114
  const known = state.bgTaskById.get(taskId);
@@ -51828,6 +52190,16 @@ function mapGoalUpdated(u, state) {
51828
52190
  pauseMessage || lastEvent
51829
52191
  ].filter(Boolean).join(" \xB7 ");
51830
52192
  const events = [];
52193
+ const goal = {
52194
+ goalId,
52195
+ objective,
52196
+ status: normalizeAcpGoalStatus(status),
52197
+ tokensUsed,
52198
+ elapsedMs,
52199
+ ...pauseMessage ? { pauseMessage } : {},
52200
+ ...phase ? { phase } : {}
52201
+ };
52202
+ events.push({ type: "acp_goal", goal: goal.status === "cleared" ? null : goal });
51831
52203
  if (!state.goalStarted.has(goalId)) {
51832
52204
  state.goalStarted.add(goalId);
51833
52205
  events.push({
@@ -52012,7 +52384,7 @@ function mapResponseStarted(u, state, ctx) {
52012
52384
  return event ? [event] : [];
52013
52385
  }
52014
52386
  function mapResponseCompleted(u, state, ctx) {
52015
- const usageRaw = asRecord8(u.usage) ?? u;
52387
+ const usageRaw = asRecord9(u.usage) ?? u;
52016
52388
  const input = numField(usageRaw, "inputTokens", "input_tokens") ?? 0;
52017
52389
  const output = numField(usageRaw, "outputTokens", "output_tokens") ?? 0;
52018
52390
  const cacheRead = numField(usageRaw, "cacheReadInputTokens", "cache_read_input_tokens") ?? 0;
@@ -52027,7 +52399,7 @@ function mapResponseCompleted(u, state, ctx) {
52027
52399
  }
52028
52400
  function mapTurnCompleted(u, state, ctx) {
52029
52401
  const events = mapTurnStopReason(u, state);
52030
- const usageRaw = asRecord8(u.usage);
52402
+ const usageRaw = asRecord9(u.usage);
52031
52403
  if (!usageRaw) {
52032
52404
  resetTurnTokens(state);
52033
52405
  return events;
@@ -52194,7 +52566,7 @@ function mapModelAutoSwitched(u) {
52194
52566
  ];
52195
52567
  }
52196
52568
  function mapRetryState(u) {
52197
- const nested = asRecord8(u.retry_state) ?? asRecord8(u.retryState) ?? u;
52569
+ const nested = asRecord9(u.retry_state) ?? asRecord9(u.retryState) ?? u;
52198
52570
  const type = (strField(nested, "type") ?? "").toLowerCase();
52199
52571
  if (type === "retrying") {
52200
52572
  const attempt = numField(nested, "attempt") ?? 1;
@@ -52261,7 +52633,7 @@ function mapAutoRecoveryExhausted(u) {
52261
52633
  }];
52262
52634
  }
52263
52635
  function mapFollowUps(u) {
52264
- const meta3 = asRecord8(u._meta) ?? asRecord8(u.meta);
52636
+ const meta3 = asRecord9(u._meta) ?? asRecord9(u.meta);
52265
52637
  if (meta3 && meta3["x.ai/replayed"] === true) return [];
52266
52638
  const responseId = strField(u, "response_id", "responseId");
52267
52639
  if (!responseId || responseId.length > 128) return [];
@@ -52270,7 +52642,7 @@ function mapFollowUps(u) {
52270
52642
  let count = 0;
52271
52643
  for (const s2 of suggestions) {
52272
52644
  if (count >= 6) break;
52273
- const rec = asRecord8(s2);
52645
+ const rec = asRecord9(s2);
52274
52646
  const label = (rec ? strField(rec, "label") : typeof s2 === "string" ? s2 : void 0)?.trim();
52275
52647
  if (!label) continue;
52276
52648
  const cleaned = label.replace(/[\u0000-\u001f\u007f]/g, "").slice(0, 256).trim();
@@ -52292,6 +52664,7 @@ var log, WORKFLOW_TERMINAL;
52292
52664
  var init_xai_event_map = __esm({
52293
52665
  "../../packages/acp/src/xai-event-map.ts"() {
52294
52666
  "use strict";
52667
+ init_acp_goal();
52295
52668
  init_xai_state();
52296
52669
  log = { debug: (..._args) => void 0 };
52297
52670
  WORKFLOW_TERMINAL = /* @__PURE__ */ new Set([
@@ -60116,7 +60489,7 @@ function toolDisplayName(name) {
60116
60489
  }
60117
60490
  function unwrapCursorMcpTool(toolType, args) {
60118
60491
  if (toolType.toLowerCase() !== "mcp") return { toolType, args };
60119
- const rec = asRecord9(args);
60492
+ const rec = asRecord10(args);
60120
60493
  if (!rec) return { toolType, args };
60121
60494
  const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
60122
60495
  const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
@@ -60142,12 +60515,12 @@ function idField(obj, ...keys) {
60142
60515
  return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
60143
60516
  }
60144
60517
  function extractCursorCallId(update) {
60145
- const rec = asRecord9(update);
60518
+ const rec = asRecord10(update);
60146
60519
  if (!rec) return null;
60147
- const nested = asRecord9(rec.toolCall) ?? asRecord9(rec.message);
60520
+ const nested = asRecord10(rec.toolCall) ?? asRecord10(rec.message);
60148
60521
  return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
60149
60522
  }
60150
- function asRecord9(value) {
60523
+ function asRecord10(value) {
60151
60524
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
60152
60525
  return value;
60153
60526
  }
@@ -60161,13 +60534,13 @@ function stringifyPayload(value) {
60161
60534
  }
60162
60535
  }
60163
60536
  function extractToolCallParts(update) {
60164
- const rec = asRecord9(update) ?? {};
60537
+ const rec = asRecord10(update) ?? {};
60165
60538
  const callId = extractCursorCallId(update);
60166
- const nested = asRecord9(rec.toolCall);
60539
+ const nested = asRecord10(rec.toolCall);
60167
60540
  if (nested) {
60168
60541
  const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
60169
60542
  const result = nested.result;
60170
- const resultRec = asRecord9(result);
60543
+ const resultRec = asRecord10(result);
60171
60544
  const isError = resultRec?.status === "error" || Boolean(rec.isError);
60172
60545
  return {
60173
60546
  callId,
@@ -60191,7 +60564,7 @@ function mapTodosPayload(todos) {
60191
60564
  return {
60192
60565
  type: "todos_updated",
60193
60566
  todos: todos.map((todo, index) => {
60194
- const row = asRecord9(todo) ?? {};
60567
+ const row = asRecord10(todo) ?? {};
60195
60568
  const statusRaw = String(row.status ?? "pending");
60196
60569
  return {
60197
60570
  id: String(row.id ?? index + 1),
@@ -60220,15 +60593,15 @@ function toolUseEvent(messageId, callId, toolType, args, status) {
60220
60593
  }
60221
60594
  function normalizeCursorToolInput(toolName, args) {
60222
60595
  if (toolName.startsWith("mcp__")) return args;
60223
- const rec = asRecord9(args);
60596
+ const rec = asRecord10(args);
60224
60597
  if (!rec) return args ?? {};
60225
60598
  return normalizeTranscriptTool(toolName, rec).input;
60226
60599
  }
60227
60600
  function mergeCursorToolResultArgs(toolType, args, result) {
60228
60601
  if (toolType.toLowerCase() === "mcp") return args;
60229
- const res = asRecord9(result);
60602
+ const res = asRecord10(result);
60230
60603
  if (!res) return args;
60231
- const rec = asRecord9(args);
60604
+ const rec = asRecord10(args);
60232
60605
  if (!rec) return args;
60233
60606
  const diff = typeof res.diffString === "string" ? res.diffString : void 0;
60234
60607
  const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
@@ -60289,7 +60662,7 @@ function stampParentToolUseId(events, parentToolUseId) {
60289
60662
  function mapInteractionUpdate(messageId, update, options) {
60290
60663
  const events = [];
60291
60664
  const type = String(update.type ?? "");
60292
- const rec = asRecord9(update) ?? {};
60665
+ const rec = asRecord10(update) ?? {};
60293
60666
  switch (type) {
60294
60667
  case "text-delta": {
60295
60668
  const text = strField2(update, "text");
@@ -60329,7 +60702,7 @@ function mapInteractionUpdate(messageId, update, options) {
60329
60702
  if (!parts.callId) break;
60330
60703
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
60331
60704
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
60332
- const todos = asRecord9(parts.args)?.todos;
60705
+ const todos = asRecord10(parts.args)?.todos;
60333
60706
  const todoEvent = mapTodosPayload(todos);
60334
60707
  if (todoEvent) events.push(todoEvent);
60335
60708
  }
@@ -60366,7 +60739,7 @@ function mapInteractionUpdate(messageId, update, options) {
60366
60739
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
60367
60740
  events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
60368
60741
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
60369
- const todos = asRecord9(parts.args)?.todos ?? asRecord9(parts.result)?.todos;
60742
+ const todos = asRecord10(parts.args)?.todos ?? asRecord10(parts.result)?.todos;
60370
60743
  const todoEvent = mapTodosPayload(todos);
60371
60744
  if (todoEvent) events.push(todoEvent);
60372
60745
  }
@@ -60471,7 +60844,7 @@ ${text}
60471
60844
  }
60472
60845
  function mapConversationStep(messageId, step, options) {
60473
60846
  const events = [];
60474
- const rec = asRecord9(step);
60847
+ const rec = asRecord10(step);
60475
60848
  if (!rec) return events;
60476
60849
  const stepType = strField2(rec, "type");
60477
60850
  if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
@@ -60479,14 +60852,14 @@ function mapConversationStep(messageId, step, options) {
60479
60852
  }
60480
60853
  if (stepType === "toolCall") {
60481
60854
  const message = rec.message ?? rec.toolCall ?? rec;
60482
- const nested = asRecord9(message);
60855
+ const nested = asRecord10(message);
60483
60856
  const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
60484
60857
  if (!callId) {
60485
60858
  return events;
60486
60859
  }
60487
60860
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
60488
60861
  const args = nested?.args ?? nested?.input ?? {};
60489
- const resultRec = asRecord9(nested?.result);
60862
+ const resultRec = asRecord10(nested?.result);
60490
60863
  const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
60491
60864
  events.push(toolUseEvent(
60492
60865
  messageId,
@@ -60496,7 +60869,7 @@ function mapConversationStep(messageId, step, options) {
60496
60869
  "complete"
60497
60870
  ));
60498
60871
  if (toolType === "updateTodos" || toolType === "update_todos") {
60499
- const todos = asRecord9(args)?.todos;
60872
+ const todos = asRecord10(args)?.todos;
60500
60873
  const todoEvent = mapTodosPayload(todos);
60501
60874
  if (todoEvent) events.push(todoEvent);
60502
60875
  }
@@ -60633,7 +61006,7 @@ var init_cursor_event_map = __esm({
60633
61006
  observeDelta(update) {
60634
61007
  const type = String(update.type ?? "");
60635
61008
  if (type === "tool-call-delta") {
60636
- const taskUpdate = asRecord9(update)?.taskUpdate;
61009
+ const taskUpdate = asRecord10(update)?.taskUpdate;
60637
61010
  if (taskUpdate && typeof taskUpdate === "object") {
60638
61011
  this.observeDelta(taskUpdate);
60639
61012
  }
@@ -62014,7 +62387,7 @@ var init_harness_runners = __esm({
62014
62387
  });
62015
62388
 
62016
62389
  // src/session/codex-live-turn.ts
62017
- function asRecord10(value) {
62390
+ function asRecord11(value) {
62018
62391
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
62019
62392
  }
62020
62393
  function readString4(value) {
@@ -62045,7 +62418,7 @@ function extractAgentTextFromTurn2(turn) {
62045
62418
  let text = "";
62046
62419
  const items = Array.isArray(turn.items) ? turn.items : [];
62047
62420
  for (const item of items) {
62048
- const rec = asRecord10(item);
62421
+ const rec = asRecord11(item);
62049
62422
  if (!rec) continue;
62050
62423
  if (readString4(rec.type) === "agentMessage" || readString4(rec.itemType) === "agentMessage") {
62051
62424
  const t = readString4(rec.text);
@@ -62077,7 +62450,7 @@ async function openTurnAndStream(opts) {
62077
62450
  ...collaborationMode ? { collaborationMode } : {}
62078
62451
  })
62079
62452
  );
62080
- const turn = asRecord10(turnStartResult.turn);
62453
+ const turn = asRecord11(turnStartResult.turn);
62081
62454
  const turnId = readString4(turn?.id);
62082
62455
  opts.onTurnStarted?.(turnId);
62083
62456
  let finalText = "";
@@ -62105,7 +62478,7 @@ async function openTurnAndStream(opts) {
62105
62478
  continue;
62106
62479
  }
62107
62480
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
62108
- const completedTurn = asRecord10(note.params.turn);
62481
+ const completedTurn = asRecord11(note.params.turn);
62109
62482
  const completedId = readString4(completedTurn?.id);
62110
62483
  if (turnId && completedId && completedId !== turnId) continue;
62111
62484
  }
@@ -62113,14 +62486,14 @@ async function openTurnAndStream(opts) {
62113
62486
  const applied = agentEventMapper.apply(note);
62114
62487
  if (applied.textDelta) finalText += applied.textDelta;
62115
62488
  } else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
62116
- const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord10(note.params.item)?.delta);
62489
+ const delta = readString4(note.params.delta) ?? readString4(note.params.text) ?? readString4(asRecord11(note.params.item)?.delta);
62117
62490
  if (delta) {
62118
62491
  finalText += delta;
62119
62492
  opts.onDelta?.(delta);
62120
62493
  }
62121
62494
  }
62122
62495
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
62123
- const completedTurn = asRecord10(note.params.turn);
62496
+ const completedTurn = asRecord11(note.params.turn);
62124
62497
  const status = readString4(completedTurn?.status) ?? readString4(note.params.status);
62125
62498
  if (status === "failed" || status === "error") {
62126
62499
  throw new Error("Codex turn failed");
@@ -62391,6 +62764,7 @@ function createProductionTurnRunner(opts) {
62391
62764
  allowSimulatedFallback: opts.allowSimulatedFallback,
62392
62765
  providers: opts.providers,
62393
62766
  experimentalClaudeOpenAiChatEnabled: opts.experimentalClaudeOpenAiChatEnabled,
62767
+ askUserQuestionPreviewFormat: opts.askUserQuestionPreviewFormat,
62394
62768
  createHostActionClaudeMcp: opts.createHostActionClaudeMcp,
62395
62769
  mcpMergeMode: opts.mcpMergeMode,
62396
62770
  homeDir: opts.homeDir
@@ -62456,8 +62830,13 @@ function createCodexAdminService(opts) {
62456
62830
  }
62457
62831
  function clearCodexAdminAuthForTest() {
62458
62832
  projectAuthById.clear();
62833
+ for (const pending of pendingAccountLogins.values()) {
62834
+ void pending.client.close().catch(() => {
62835
+ });
62836
+ }
62837
+ pendingAccountLogins.clear();
62459
62838
  }
62460
- var projectAuthById, CodexAdminService;
62839
+ var projectAuthById, pendingAccountLogins, CodexAdminService;
62461
62840
  var init_codex_admin_service = __esm({
62462
62841
  "src/session/codex-admin-service.ts"() {
62463
62842
  "use strict";
@@ -62466,6 +62845,7 @@ var init_codex_admin_service = __esm({
62466
62845
  init_codex_turn_runner();
62467
62846
  init_resolve_service();
62468
62847
  projectAuthById = /* @__PURE__ */ new Map();
62848
+ pendingAccountLogins = /* @__PURE__ */ new Map();
62469
62849
  CodexAdminService = class {
62470
62850
  constructor(opts) {
62471
62851
  this.opts = opts;
@@ -62539,6 +62919,91 @@ var init_codex_admin_service = __esm({
62539
62919
  });
62540
62920
  }
62541
62921
  }
62922
+ async openAccountClient() {
62923
+ const binary = resolveCodexBinaryPath({
62924
+ binaryPath: this.opts.binaryPath,
62925
+ harnesses: this.opts.harnesses
62926
+ });
62927
+ if (!binary) {
62928
+ throw Object.assign(new Error("Codex binary not available"), {
62929
+ code: "failed_precondition"
62930
+ });
62931
+ }
62932
+ const env = { ...process.env, ...this.opts.env };
62933
+ delete env.CODEX_API_KEY;
62934
+ return openCodexAppServer({
62935
+ binaryPath: binary,
62936
+ env,
62937
+ spawnFn: this.opts.spawnFn
62938
+ });
62939
+ }
62940
+ async getAccountStatus() {
62941
+ const client3 = await this.openAccountClient();
62942
+ try {
62943
+ return await readAccountStatus(client3);
62944
+ } finally {
62945
+ await client3.close().catch(() => {
62946
+ });
62947
+ }
62948
+ }
62949
+ async startAccountLogin(projectId) {
62950
+ const client3 = await this.openAccountClient();
62951
+ try {
62952
+ const result = await startAccountLogin(client3, "chatgptDeviceCode");
62953
+ pendingAccountLogins.set(result.loginId, { projectId, client: client3 });
62954
+ void this.waitForAccountLogin(result.loginId, client3);
62955
+ return result;
62956
+ } catch (error51) {
62957
+ await client3.close().catch(() => {
62958
+ });
62959
+ throw error51;
62960
+ }
62961
+ }
62962
+ async waitForAccountLogin(loginId, client3) {
62963
+ const deadline = Date.now() + 15 * 6e4;
62964
+ try {
62965
+ while (Date.now() < deadline && pendingAccountLogins.get(loginId)?.client === client3) {
62966
+ const notification = await client3.nextNotification(Math.min(1e3, deadline - Date.now()));
62967
+ if (!notification) continue;
62968
+ if (notification.method === "account/login/completed" && notification.params.loginId === loginId) return;
62969
+ }
62970
+ } catch {
62971
+ } finally {
62972
+ if (pendingAccountLogins.get(loginId)?.client === client3) {
62973
+ pendingAccountLogins.delete(loginId);
62974
+ }
62975
+ await client3.close().catch(() => {
62976
+ });
62977
+ }
62978
+ }
62979
+ async cancelAccountLogin(loginId) {
62980
+ const pending = pendingAccountLogins.get(loginId);
62981
+ if (!pending) return;
62982
+ pendingAccountLogins.delete(loginId);
62983
+ try {
62984
+ await cancelAccountLogin(pending.client, loginId);
62985
+ } finally {
62986
+ await pending.client.close().catch(() => {
62987
+ });
62988
+ }
62989
+ }
62990
+ async logoutAccount() {
62991
+ for (const [loginId, pending] of [...pendingAccountLogins]) {
62992
+ pendingAccountLogins.delete(loginId);
62993
+ await cancelAccountLogin(pending.client, loginId).catch(() => {
62994
+ });
62995
+ await pending.client.close().catch(() => {
62996
+ });
62997
+ }
62998
+ const client3 = await this.openAccountClient();
62999
+ try {
63000
+ await logoutAccount(client3);
63001
+ return await readAccountStatus(client3);
63002
+ } finally {
63003
+ await client3.close().catch(() => {
63004
+ });
63005
+ }
63006
+ }
62542
63007
  async getRateLimits(projectId, apiProviderId) {
62543
63008
  const auth = this.getProjectAuth(projectId);
62544
63009
  if (resolveMode(auth.mode, auth.apiKey) !== "chatgpt") return null;
@@ -69753,8 +70218,8 @@ import { fileURLToPath } from "node:url";
69753
70218
  function resolveCliReleaseVersion() {
69754
70219
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
69755
70220
  if (fromEnv) return fromEnv;
69756
- if ("0.55.1-alpha".trim()) {
69757
- return "0.55.1-alpha".trim();
70221
+ if ("0.56.0-alpha".trim()) {
70222
+ return "0.56.0-alpha".trim();
69758
70223
  }
69759
70224
  const fromDist = readDistManifestVersion();
69760
70225
  if (fromDist) return fromDist;
@@ -71389,13 +71854,15 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as rea
71389
71854
  import { dirname as dirname4 } from "node:path";
71390
71855
  var CODEX_PRESETS = /* @__PURE__ */ new Set(["", "read-only", "default", "full-access"]);
71391
71856
  var SANDBOX_MODES = /* @__PURE__ */ new Set(["", "off", "on", "auto"]);
71857
+ var QUESTION_PREVIEW_FORMATS = /* @__PURE__ */ new Set(["", "markdown", "html"]);
71392
71858
  var DEFAULT_NODE_AGENT_SETTINGS = {
71393
71859
  claude: {
71394
71860
  defaultModel: "",
71395
71861
  defaultEffort: "",
71396
71862
  permissionMode: "",
71397
71863
  sandboxMode: "",
71398
- disabledSkills: []
71864
+ disabledSkills: [],
71865
+ askUserQuestionPreviewFormat: ""
71399
71866
  },
71400
71867
  codex: {
71401
71868
  defaultModel: "",
@@ -71418,12 +71885,14 @@ function normalizeClaude(raw) {
71418
71885
  const r = raw && typeof raw === "object" ? raw : {};
71419
71886
  const sandboxMode = asString(r.sandboxMode ?? r.defaultSandboxMode, "");
71420
71887
  const permissionMode = asString(r.permissionMode ?? r.defaultPermissionMode, "");
71888
+ const previewFormat = asString(r.askUserQuestionPreviewFormat, "");
71421
71889
  return {
71422
71890
  defaultModel: asString(r.defaultModel, ""),
71423
71891
  defaultEffort: asString(r.defaultEffort, ""),
71424
71892
  permissionMode,
71425
71893
  sandboxMode: SANDBOX_MODES.has(sandboxMode) ? sandboxMode : "",
71426
- disabledSkills: asStringArray(r.disabledSkills, [])
71894
+ disabledSkills: asStringArray(r.disabledSkills, []),
71895
+ askUserQuestionPreviewFormat: QUESTION_PREVIEW_FORMATS.has(previewFormat) ? previewFormat : ""
71427
71896
  };
71428
71897
  }
71429
71898
  function normalizeCodex(raw) {
@@ -71470,6 +71939,10 @@ function mergeNodeAgentSettings(current, patch) {
71470
71939
  const m2 = patch.claude.sandboxMode;
71471
71940
  next.claude.sandboxMode = SANDBOX_MODES.has(m2) ? m2 : next.claude.sandboxMode;
71472
71941
  }
71942
+ if (typeof patch.claude.askUserQuestionPreviewFormat === "string") {
71943
+ const f2 = patch.claude.askUserQuestionPreviewFormat;
71944
+ if (QUESTION_PREVIEW_FORMATS.has(f2)) next.claude.askUserQuestionPreviewFormat = f2;
71945
+ }
71473
71946
  if (Array.isArray(patch.claude.disabledSkills)) {
71474
71947
  next.claude.disabledSkills = patch.claude.disabledSkills.filter((s2) => typeof s2 === "string").map((s2) => s2.trim()).filter(Boolean);
71475
71948
  }
@@ -71792,7 +72265,7 @@ function requireResourceWrite(client3, scope) {
71792
72265
  if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
71793
72266
  return null;
71794
72267
  }
71795
- function asRecord11(payload) {
72268
+ function asRecord12(payload) {
71796
72269
  return payload && typeof payload === "object" ? payload : {};
71797
72270
  }
71798
72271
  function mapThrown(err) {
@@ -71821,7 +72294,7 @@ function manageOpts(ctx) {
71821
72294
  function handleSkillsList(payload, ctx) {
71822
72295
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
71823
72296
  if (denied) return denied;
71824
- const p2 = asRecord11(payload);
72297
+ const p2 = asRecord12(payload);
71825
72298
  try {
71826
72299
  const projectId = String(p2.projectId ?? "");
71827
72300
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71841,7 +72314,7 @@ function handleSkillsList(payload, ctx) {
71841
72314
  function handleSkillsGet(payload, ctx) {
71842
72315
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
71843
72316
  if (denied) return denied;
71844
- const p2 = asRecord11(payload);
72317
+ const p2 = asRecord12(payload);
71845
72318
  try {
71846
72319
  const projectId = String(p2.projectId ?? "");
71847
72320
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71866,7 +72339,7 @@ function handleSkillsGet(payload, ctx) {
71866
72339
  function handleSkillsReadFile(payload, ctx) {
71867
72340
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
71868
72341
  if (denied) return denied;
71869
- const p2 = asRecord11(payload);
72342
+ const p2 = asRecord12(payload);
71870
72343
  try {
71871
72344
  const projectId = String(p2.projectId ?? "");
71872
72345
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71900,7 +72373,7 @@ function handleSkillsReadFile(payload, ctx) {
71900
72373
  function handleSkillsDelete(payload, ctx) {
71901
72374
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
71902
72375
  if (denied) return denied;
71903
- const p2 = asRecord11(payload);
72376
+ const p2 = asRecord12(payload);
71904
72377
  try {
71905
72378
  const projectId = String(p2.projectId ?? "");
71906
72379
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71925,7 +72398,7 @@ function handleSkillsDelete(payload, ctx) {
71925
72398
  function handleSkillsInstall(payload, ctx) {
71926
72399
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
71927
72400
  if (baseDenied) return baseDenied;
71928
- const p2 = asRecord11(payload);
72401
+ const p2 = asRecord12(payload);
71929
72402
  try {
71930
72403
  const projectId = String(p2.projectId ?? "");
71931
72404
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71959,7 +72432,7 @@ function handleSkillsInstall(payload, ctx) {
71959
72432
  function handleMcpList(payload, ctx) {
71960
72433
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
71961
72434
  if (denied) return denied;
71962
- const p2 = asRecord11(payload);
72435
+ const p2 = asRecord12(payload);
71963
72436
  try {
71964
72437
  const projectId = String(p2.projectId ?? "");
71965
72438
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71983,7 +72456,7 @@ function handleMcpList(payload, ctx) {
71983
72456
  function handleAdditionalDirsList(payload, ctx) {
71984
72457
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
71985
72458
  if (denied) return denied;
71986
- const p2 = asRecord11(payload);
72459
+ const p2 = asRecord12(payload);
71987
72460
  try {
71988
72461
  const projectId = String(p2.projectId ?? "");
71989
72462
  const cwd = projectRoot(ctx.projects, projectId);
@@ -71998,7 +72471,7 @@ function handleAdditionalDirsList(payload, ctx) {
71998
72471
  function handleAdditionalDirsAdd(payload, ctx) {
71999
72472
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72000
72473
  if (denied) return denied;
72001
- const p2 = asRecord11(payload);
72474
+ const p2 = asRecord12(payload);
72002
72475
  try {
72003
72476
  const projectId = String(p2.projectId ?? "");
72004
72477
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72016,7 +72489,7 @@ function handleAdditionalDirsAdd(payload, ctx) {
72016
72489
  function handleAdditionalDirsRemove(payload, ctx) {
72017
72490
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72018
72491
  if (denied) return denied;
72019
- const p2 = asRecord11(payload);
72492
+ const p2 = asRecord12(payload);
72020
72493
  try {
72021
72494
  const projectId = String(p2.projectId ?? "");
72022
72495
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72067,7 +72540,7 @@ function parseMcpWriteConfig(raw) {
72067
72540
  function handleMcpSave(payload, ctx) {
72068
72541
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72069
72542
  if (baseDenied) return baseDenied;
72070
- const p2 = asRecord11(payload);
72543
+ const p2 = asRecord12(payload);
72071
72544
  try {
72072
72545
  const projectId = String(p2.projectId ?? "");
72073
72546
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72097,7 +72570,7 @@ function handleMcpSave(payload, ctx) {
72097
72570
  function handleMcpToggle(payload, ctx) {
72098
72571
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72099
72572
  if (baseDenied) return baseDenied;
72100
- const p2 = asRecord11(payload);
72573
+ const p2 = asRecord12(payload);
72101
72574
  try {
72102
72575
  const projectId = String(p2.projectId ?? "");
72103
72576
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72128,7 +72601,7 @@ function handleMcpToggle(payload, ctx) {
72128
72601
  function handleMcpDelete(payload, ctx) {
72129
72602
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72130
72603
  if (baseDenied) return baseDenied;
72131
- const p2 = asRecord11(payload);
72604
+ const p2 = asRecord12(payload);
72132
72605
  try {
72133
72606
  const projectId = String(p2.projectId ?? "");
72134
72607
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72168,7 +72641,7 @@ function parseMarketplaceScope(raw) {
72168
72641
  async function handlePluginsList(payload, ctx) {
72169
72642
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72170
72643
  if (denied) return denied;
72171
- const p2 = asRecord11(payload);
72644
+ const p2 = asRecord12(payload);
72172
72645
  try {
72173
72646
  const projectId = String(p2.projectId ?? "");
72174
72647
  projectRoot(ctx.projects, projectId);
@@ -72215,7 +72688,7 @@ async function handlePluginsList(payload, ctx) {
72215
72688
  function handlePluginsGet(payload, ctx) {
72216
72689
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72217
72690
  if (denied) return denied;
72218
- const p2 = asRecord11(payload);
72691
+ const p2 = asRecord12(payload);
72219
72692
  try {
72220
72693
  const projectId = String(p2.projectId ?? "");
72221
72694
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72239,7 +72712,7 @@ function handlePluginsGet(payload, ctx) {
72239
72712
  function handlePluginsReadFile(payload, ctx) {
72240
72713
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72241
72714
  if (denied) return denied;
72242
- const p2 = asRecord11(payload);
72715
+ const p2 = asRecord12(payload);
72243
72716
  try {
72244
72717
  const projectId = String(p2.projectId ?? "");
72245
72718
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72267,7 +72740,7 @@ function handlePluginsReadFile(payload, ctx) {
72267
72740
  function handlePluginsDelete(payload, ctx) {
72268
72741
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72269
72742
  if (baseDenied) return baseDenied;
72270
- const p2 = asRecord11(payload);
72743
+ const p2 = asRecord12(payload);
72271
72744
  try {
72272
72745
  const projectId = String(p2.projectId ?? "");
72273
72746
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72293,7 +72766,7 @@ function handlePluginsDelete(payload, ctx) {
72293
72766
  async function handlePluginsInstall(payload, ctx) {
72294
72767
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72295
72768
  if (baseDenied) return baseDenied;
72296
- const p2 = asRecord11(payload);
72769
+ const p2 = asRecord12(payload);
72297
72770
  try {
72298
72771
  const projectId = String(p2.projectId ?? "");
72299
72772
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72319,7 +72792,7 @@ async function handlePluginsInstall(payload, ctx) {
72319
72792
  function handlePluginsUpdate(payload, ctx) {
72320
72793
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72321
72794
  if (baseDenied) return baseDenied;
72322
- const p2 = asRecord11(payload);
72795
+ const p2 = asRecord12(payload);
72323
72796
  try {
72324
72797
  const projectId = String(p2.projectId ?? "");
72325
72798
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72345,7 +72818,7 @@ function handlePluginsUpdate(payload, ctx) {
72345
72818
  function handlePluginsListMarketplace(payload, ctx) {
72346
72819
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72347
72820
  if (denied) return denied;
72348
- const p2 = asRecord11(payload);
72821
+ const p2 = asRecord12(payload);
72349
72822
  try {
72350
72823
  const projectId = String(p2.projectId ?? "");
72351
72824
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72367,7 +72840,7 @@ function handlePluginsListMarketplace(payload, ctx) {
72367
72840
  async function handlePluginsAddMarketplace(payload, ctx) {
72368
72841
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72369
72842
  if (baseDenied) return baseDenied;
72370
- const p2 = asRecord11(payload);
72843
+ const p2 = asRecord12(payload);
72371
72844
  try {
72372
72845
  const projectId = String(p2.projectId ?? "");
72373
72846
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72393,7 +72866,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
72393
72866
  async function handlePluginsRemoveMarketplace(payload, ctx) {
72394
72867
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72395
72868
  if (baseDenied) return baseDenied;
72396
- const p2 = asRecord11(payload);
72869
+ const p2 = asRecord12(payload);
72397
72870
  try {
72398
72871
  const projectId = String(p2.projectId ?? "");
72399
72872
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72428,7 +72901,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
72428
72901
  if (denied) return denied;
72429
72902
  const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
72430
72903
  if (adminDenied) return adminDenied;
72431
- const p2 = asRecord11(payload);
72904
+ const p2 = asRecord12(payload);
72432
72905
  try {
72433
72906
  const projectId = String(p2.projectId ?? "");
72434
72907
  if (projectId) {
@@ -72450,7 +72923,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
72450
72923
  function handlePluginsReadMarketplace(payload, ctx) {
72451
72924
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72452
72925
  if (denied) return denied;
72453
- const p2 = asRecord11(payload);
72926
+ const p2 = asRecord12(payload);
72454
72927
  try {
72455
72928
  const projectId = String(p2.projectId ?? "");
72456
72929
  if (projectId) {
@@ -72481,7 +72954,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
72481
72954
  function handlePluginsReadMarketplaceFile(payload, ctx) {
72482
72955
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72483
72956
  if (denied) return denied;
72484
- const p2 = asRecord11(payload);
72957
+ const p2 = asRecord12(payload);
72485
72958
  try {
72486
72959
  const projectId = String(p2.projectId ?? "");
72487
72960
  if (projectId) {
@@ -72515,7 +72988,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
72515
72988
  function handleAgentsList(payload, ctx) {
72516
72989
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72517
72990
  if (denied) return denied;
72518
- const p2 = asRecord11(payload);
72991
+ const p2 = asRecord12(payload);
72519
72992
  try {
72520
72993
  const projectId = String(p2.projectId ?? "");
72521
72994
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72532,7 +73005,7 @@ function handleAgentsList(payload, ctx) {
72532
73005
  function handleAgentsReadFile(payload, ctx) {
72533
73006
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72534
73007
  if (denied) return denied;
72535
- const p2 = asRecord11(payload);
73008
+ const p2 = asRecord12(payload);
72536
73009
  try {
72537
73010
  const projectId = String(p2.projectId ?? "");
72538
73011
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72564,7 +73037,7 @@ function parseHookSavePayload(raw) {
72564
73037
  function handleHooksList(payload, ctx) {
72565
73038
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72566
73039
  if (denied) return denied;
72567
- const p2 = asRecord11(payload);
73040
+ const p2 = asRecord12(payload);
72568
73041
  try {
72569
73042
  const projectId = String(p2.projectId ?? "");
72570
73043
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72577,7 +73050,7 @@ function handleHooksList(payload, ctx) {
72577
73050
  function handleHooksSave(payload, ctx) {
72578
73051
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72579
73052
  if (baseDenied) return baseDenied;
72580
- const p2 = asRecord11(payload);
73053
+ const p2 = asRecord12(payload);
72581
73054
  try {
72582
73055
  const projectId = String(p2.projectId ?? "");
72583
73056
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72605,7 +73078,7 @@ function handleHooksSave(payload, ctx) {
72605
73078
  function handleHooksDelete(payload, ctx) {
72606
73079
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
72607
73080
  if (baseDenied) return baseDenied;
72608
- const p2 = asRecord11(payload);
73081
+ const p2 = asRecord12(payload);
72609
73082
  try {
72610
73083
  const projectId = String(p2.projectId ?? "");
72611
73084
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72710,7 +73183,7 @@ function requireScopes2(client3, scopes) {
72710
73183
  }
72711
73184
  return null;
72712
73185
  }
72713
- function asRecord12(payload) {
73186
+ function asRecord13(payload) {
72714
73187
  return payload && typeof payload === "object" ? payload : {};
72715
73188
  }
72716
73189
  function mapThrown2(err) {
@@ -72801,7 +73274,7 @@ function parseSchedule(raw) {
72801
73274
  function handleAutomationList(payload, ctx) {
72802
73275
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
72803
73276
  if (denied) return denied;
72804
- const p2 = asRecord12(payload);
73277
+ const p2 = asRecord13(payload);
72805
73278
  const projectId = String(p2.projectId ?? "").trim();
72806
73279
  if (!projectId) {
72807
73280
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -72820,7 +73293,7 @@ function handleAutomationList(payload, ctx) {
72820
73293
  function handleAutomationCreate(payload, ctx) {
72821
73294
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
72822
73295
  if (denied) return denied;
72823
- const p2 = asRecord12(payload);
73296
+ const p2 = asRecord13(payload);
72824
73297
  const projectId = String(p2.projectId ?? "").trim();
72825
73298
  if (!projectId) {
72826
73299
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -72857,7 +73330,7 @@ function handleAutomationCreate(payload, ctx) {
72857
73330
  function handleAutomationUpdate(payload, ctx) {
72858
73331
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
72859
73332
  if (denied) return denied;
72860
- const p2 = asRecord12(payload);
73333
+ const p2 = asRecord13(payload);
72861
73334
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
72862
73335
  if (!automationId) {
72863
73336
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -72901,7 +73374,7 @@ function handleAutomationUpdate(payload, ctx) {
72901
73374
  function handleAutomationDelete(payload, ctx) {
72902
73375
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
72903
73376
  if (denied) return denied;
72904
- const p2 = asRecord12(payload);
73377
+ const p2 = asRecord13(payload);
72905
73378
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
72906
73379
  if (!automationId) {
72907
73380
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -72927,7 +73400,7 @@ function handleAutomationDelete(payload, ctx) {
72927
73400
  async function handleAutomationRunNow(payload, ctx) {
72928
73401
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
72929
73402
  if (denied) return denied;
72930
- const p2 = asRecord12(payload);
73403
+ const p2 = asRecord13(payload);
72931
73404
  const automationId = String(p2.automationId ?? p2.id ?? "").trim();
72932
73405
  if (!automationId) {
72933
73406
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -72984,7 +73457,7 @@ function requireScopes3(client3, scopes) {
72984
73457
  }
72985
73458
  return null;
72986
73459
  }
72987
- function asRecord13(payload) {
73460
+ function asRecord14(payload) {
72988
73461
  return payload && typeof payload === "object" ? payload : {};
72989
73462
  }
72990
73463
  function optionalString(value) {
@@ -72993,7 +73466,7 @@ function optionalString(value) {
72993
73466
  function parseAttachments(value) {
72994
73467
  if (!Array.isArray(value)) return [];
72995
73468
  return value.flatMap((raw) => {
72996
- const a = asRecord13(raw);
73469
+ const a = asRecord14(raw);
72997
73470
  const name = typeof a.name === "string" ? a.name : "";
72998
73471
  const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
72999
73472
  const data = typeof a.data === "string" ? a.data : "";
@@ -73006,7 +73479,7 @@ function mapThrown3(err) {
73006
73479
  function handleDraftList(payload, ctx) {
73007
73480
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
73008
73481
  if (denied) return denied;
73009
- const p2 = asRecord13(payload);
73482
+ const p2 = asRecord14(payload);
73010
73483
  const projectPath = optionalString(p2.projectPath);
73011
73484
  try {
73012
73485
  return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
@@ -73017,7 +73490,7 @@ function handleDraftList(payload, ctx) {
73017
73490
  function handleDraftUpsert(payload, ctx) {
73018
73491
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
73019
73492
  if (denied) return denied;
73020
- const p2 = asRecord13(payload);
73493
+ const p2 = asRecord14(payload);
73021
73494
  const id = String(p2.id ?? "").trim();
73022
73495
  if (!id) {
73023
73496
  return { error: { code: "invalid_argument", message: "id is required" } };
@@ -73048,7 +73521,7 @@ function handleDraftUpsert(payload, ctx) {
73048
73521
  function handleDraftDelete(payload, ctx) {
73049
73522
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
73050
73523
  if (denied) return denied;
73051
- const p2 = asRecord13(payload);
73524
+ const p2 = asRecord14(payload);
73052
73525
  const draftId = String(p2.draftId ?? "").trim();
73053
73526
  if (!draftId) {
73054
73527
  return { error: { code: "invalid_argument", message: "draftId is required" } };
@@ -73082,7 +73555,7 @@ function requireScopes4(client3, scopes) {
73082
73555
  }
73083
73556
  return null;
73084
73557
  }
73085
- function asRecord14(payload) {
73558
+ function asRecord15(payload) {
73086
73559
  return payload && typeof payload === "object" ? payload : {};
73087
73560
  }
73088
73561
  function mapThrown4(err) {
@@ -73109,6 +73582,14 @@ async function dispatchCodexRpc(method, payload, ctx) {
73109
73582
  return handleGetAuthStatus(payload, ctx);
73110
73583
  case "codex.setAuth":
73111
73584
  return handleSetAuth(payload, ctx);
73585
+ case "codex.getAccountStatus":
73586
+ return handleGetAccountStatus(payload, ctx);
73587
+ case "codex.accountLoginStart":
73588
+ return handleAccountLoginStart(payload, ctx);
73589
+ case "codex.accountLoginCancel":
73590
+ return handleAccountLoginCancel(payload, ctx);
73591
+ case "codex.accountLogout":
73592
+ return handleAccountLogout(payload, ctx);
73112
73593
  case "codex.getRateLimits":
73113
73594
  return handleGetRateLimits(payload, ctx);
73114
73595
  case "codex.getAccountUsage":
@@ -73141,6 +73622,9 @@ async function dispatchCodexRpc(method, payload, ctx) {
73141
73622
  }
73142
73623
  var CODEX_MUTATING_METHODS = [
73143
73624
  "codex.setAuth",
73625
+ "codex.accountLoginStart",
73626
+ "codex.accountLoginCancel",
73627
+ "codex.accountLogout",
73144
73628
  "codex.consumeRateLimitReset",
73145
73629
  "codex.loginMcpOauth",
73146
73630
  "codex.importExternalAgent",
@@ -73153,7 +73637,7 @@ var CODEX_MUTATING_METHODS = [
73153
73637
  function handleGetAuthStatus(payload, ctx) {
73154
73638
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73155
73639
  if (denied) return denied;
73156
- const p2 = asRecord14(payload);
73640
+ const p2 = asRecord15(payload);
73157
73641
  const projectId = projectIdOf(p2);
73158
73642
  if (!projectId) {
73159
73643
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73166,7 +73650,7 @@ function handleGetAuthStatus(payload, ctx) {
73166
73650
  function handleSetAuth(payload, ctx) {
73167
73651
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73168
73652
  if (denied) return denied;
73169
- const p2 = asRecord14(payload);
73653
+ const p2 = asRecord15(payload);
73170
73654
  const projectId = projectIdOf(p2);
73171
73655
  if (!projectId) {
73172
73656
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73188,10 +73672,62 @@ function handleSetAuth(payload, ctx) {
73188
73672
  return mapThrown4(err);
73189
73673
  }
73190
73674
  }
73675
+ async function handleGetAccountStatus(payload, ctx) {
73676
+ const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73677
+ if (denied) return denied;
73678
+ const p2 = asRecord15(payload);
73679
+ const projectId = projectIdOf(p2);
73680
+ if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73681
+ if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
73682
+ try {
73683
+ return { result: await admin(ctx).getAccountStatus() };
73684
+ } catch (err) {
73685
+ return mapThrown4(err);
73686
+ }
73687
+ }
73688
+ async function handleAccountLoginStart(payload, ctx) {
73689
+ const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73690
+ if (denied) return denied;
73691
+ const p2 = asRecord15(payload);
73692
+ const projectId = projectIdOf(p2);
73693
+ if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73694
+ if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
73695
+ try {
73696
+ return { result: await admin(ctx).startAccountLogin(projectId) };
73697
+ } catch (err) {
73698
+ return mapThrown4(err);
73699
+ }
73700
+ }
73701
+ async function handleAccountLoginCancel(payload, ctx) {
73702
+ const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73703
+ if (denied) return denied;
73704
+ const p2 = asRecord15(payload);
73705
+ const loginId = typeof p2.loginId === "string" ? p2.loginId.trim() : "";
73706
+ if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
73707
+ try {
73708
+ await admin(ctx).cancelAccountLogin(loginId);
73709
+ return { result: { ok: true } };
73710
+ } catch (err) {
73711
+ return mapThrown4(err);
73712
+ }
73713
+ }
73714
+ async function handleAccountLogout(payload, ctx) {
73715
+ const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73716
+ if (denied) return denied;
73717
+ const p2 = asRecord15(payload);
73718
+ const projectId = projectIdOf(p2);
73719
+ if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
73720
+ if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
73721
+ try {
73722
+ return { result: await admin(ctx).logoutAccount() };
73723
+ } catch (err) {
73724
+ return mapThrown4(err);
73725
+ }
73726
+ }
73191
73727
  async function handleGetRateLimits(payload, ctx) {
73192
73728
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73193
73729
  if (denied) return denied;
73194
- const p2 = asRecord14(payload);
73730
+ const p2 = asRecord15(payload);
73195
73731
  const projectId = projectIdOf(p2);
73196
73732
  if (!projectId) {
73197
73733
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73218,7 +73754,7 @@ async function handleGetRateLimits(payload, ctx) {
73218
73754
  async function handleGetAccountUsage(payload, ctx) {
73219
73755
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73220
73756
  if (denied) return denied;
73221
- const p2 = asRecord14(payload);
73757
+ const p2 = asRecord15(payload);
73222
73758
  const projectId = projectIdOf(p2);
73223
73759
  if (!projectId) {
73224
73760
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73245,7 +73781,7 @@ async function handleGetAccountUsage(payload, ctx) {
73245
73781
  async function handleConsumeRateLimitReset(payload, ctx) {
73246
73782
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73247
73783
  if (denied) return denied;
73248
- const p2 = asRecord14(payload);
73784
+ const p2 = asRecord15(payload);
73249
73785
  const projectId = projectIdOf(p2);
73250
73786
  if (!projectId) {
73251
73787
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73275,7 +73811,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
73275
73811
  async function handleLoginMcpOauth(payload, ctx) {
73276
73812
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73277
73813
  if (denied) return denied;
73278
- const p2 = asRecord14(payload);
73814
+ const p2 = asRecord15(payload);
73279
73815
  const projectId = projectIdOf(p2);
73280
73816
  const serverName = String(p2.serverName ?? p2.name ?? "").trim();
73281
73817
  if (!projectId || !serverName) {
@@ -73295,7 +73831,7 @@ async function handleLoginMcpOauth(payload, ctx) {
73295
73831
  async function handleDetectExternalAgent(payload, ctx) {
73296
73832
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
73297
73833
  if (denied) return denied;
73298
- const p2 = asRecord14(payload);
73834
+ const p2 = asRecord15(payload);
73299
73835
  const projectId = projectIdOf(p2);
73300
73836
  if (!projectId) {
73301
73837
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73314,7 +73850,7 @@ async function handleDetectExternalAgent(payload, ctx) {
73314
73850
  async function handleImportExternalAgent(payload, ctx) {
73315
73851
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73316
73852
  if (denied) return denied;
73317
- const p2 = asRecord14(payload);
73853
+ const p2 = asRecord15(payload);
73318
73854
  const projectId = projectIdOf(p2);
73319
73855
  if (!projectId) {
73320
73856
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73332,7 +73868,7 @@ async function handleImportExternalAgent(payload, ctx) {
73332
73868
  async function handlePluginsList2(payload, ctx) {
73333
73869
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
73334
73870
  if (denied) return denied;
73335
- const p2 = asRecord14(payload);
73871
+ const p2 = asRecord15(payload);
73336
73872
  const projectId = projectIdOf(p2);
73337
73873
  if (!projectId) {
73338
73874
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73355,7 +73891,7 @@ async function handlePluginsList2(payload, ctx) {
73355
73891
  async function handlePluginsInstall2(payload, ctx) {
73356
73892
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73357
73893
  if (denied) return denied;
73358
- const p2 = asRecord14(payload);
73894
+ const p2 = asRecord15(payload);
73359
73895
  const projectId = projectIdOf(p2);
73360
73896
  const key = String(p2.key ?? p2.pluginId ?? "").trim();
73361
73897
  if (!projectId || !key) {
@@ -73371,7 +73907,7 @@ async function handlePluginsInstall2(payload, ctx) {
73371
73907
  async function handlePluginsUninstall(payload, ctx) {
73372
73908
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73373
73909
  if (denied) return denied;
73374
- const p2 = asRecord14(payload);
73910
+ const p2 = asRecord15(payload);
73375
73911
  const projectId = projectIdOf(p2);
73376
73912
  const key = String(p2.key ?? p2.pluginId ?? "").trim();
73377
73913
  if (!projectId || !key) {
@@ -73387,7 +73923,7 @@ async function handlePluginsUninstall(payload, ctx) {
73387
73923
  async function handleMarketplaceAdd(payload, ctx) {
73388
73924
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73389
73925
  if (denied) return denied;
73390
- const p2 = asRecord14(payload);
73926
+ const p2 = asRecord15(payload);
73391
73927
  const projectId = projectIdOf(p2);
73392
73928
  const source = String(p2.source ?? "").trim();
73393
73929
  if (!projectId || !source) {
@@ -73416,7 +73952,7 @@ async function handleMarketplaceAdd(payload, ctx) {
73416
73952
  async function handleMarketplaceRemove(payload, ctx) {
73417
73953
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73418
73954
  if (denied) return denied;
73419
- const p2 = asRecord14(payload);
73955
+ const p2 = asRecord15(payload);
73420
73956
  const projectId = projectIdOf(p2);
73421
73957
  const marketplaceName = String(p2.marketplaceName ?? p2.name ?? "").trim();
73422
73958
  if (!projectId || !marketplaceName) {
@@ -73439,7 +73975,7 @@ async function handleMarketplaceRemove(payload, ctx) {
73439
73975
  async function handleMarketplaceUpgrade(payload, ctx) {
73440
73976
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
73441
73977
  if (denied) return denied;
73442
- const p2 = asRecord14(payload);
73978
+ const p2 = asRecord15(payload);
73443
73979
  const projectId = projectIdOf(p2);
73444
73980
  if (!projectId) {
73445
73981
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -73472,7 +74008,7 @@ function requireScopes5(client3, scopes) {
73472
74008
  }
73473
74009
  return null;
73474
74010
  }
73475
- function asRecord15(payload) {
74011
+ function asRecord16(payload) {
73476
74012
  return payload && typeof payload === "object" ? payload : {};
73477
74013
  }
73478
74014
  function mapThrown5(err) {
@@ -73501,7 +74037,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
73501
74037
  function handleList(payload, ctx) {
73502
74038
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
73503
74039
  if (denied) return denied;
73504
- const p2 = asRecord15(payload);
74040
+ const p2 = asRecord16(payload);
73505
74041
  try {
73506
74042
  const harnessId = typeof p2.harnessId === "string" && p2.harnessId.trim() ? p2.harnessId.trim() : null;
73507
74043
  const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
@@ -73513,7 +74049,7 @@ function handleList(payload, ctx) {
73513
74049
  function handleGet(payload, ctx) {
73514
74050
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
73515
74051
  if (denied) return denied;
73516
- const p2 = asRecord15(payload);
74052
+ const p2 = asRecord16(payload);
73517
74053
  const id = String(p2.id ?? "");
73518
74054
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
73519
74055
  try {
@@ -73525,7 +74061,7 @@ function handleGet(payload, ctx) {
73525
74061
  function handleGetBase(payload, ctx) {
73526
74062
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
73527
74063
  if (denied) return denied;
73528
- const p2 = asRecord15(payload);
74064
+ const p2 = asRecord16(payload);
73529
74065
  const harnessId = String(p2.harnessId ?? "");
73530
74066
  if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
73531
74067
  try {
@@ -73537,7 +74073,7 @@ function handleGetBase(payload, ctx) {
73537
74073
  function handleCreate(payload, ctx) {
73538
74074
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
73539
74075
  if (denied) return denied;
73540
- const p2 = asRecord15(payload);
74076
+ const p2 = asRecord16(payload);
73541
74077
  try {
73542
74078
  const provider = ctx.sessionProviders.create({
73543
74079
  harnessId: String(p2.harnessId ?? ""),
@@ -73553,7 +74089,7 @@ function handleCreate(payload, ctx) {
73553
74089
  function handleUpdate(payload, ctx) {
73554
74090
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
73555
74091
  if (denied) return denied;
73556
- const p2 = asRecord15(payload);
74092
+ const p2 = asRecord16(payload);
73557
74093
  const id = String(p2.id ?? "");
73558
74094
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
73559
74095
  try {
@@ -73569,7 +74105,7 @@ function handleUpdate(payload, ctx) {
73569
74105
  function handleDelete(payload, ctx) {
73570
74106
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
73571
74107
  if (denied) return denied;
73572
- const p2 = asRecord15(payload);
74108
+ const p2 = asRecord16(payload);
73573
74109
  const id = String(p2.id ?? "");
73574
74110
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
73575
74111
  try {
@@ -73610,7 +74146,7 @@ function requireScopes6(client3, scopes) {
73610
74146
  }
73611
74147
  return null;
73612
74148
  }
73613
- function asRecord16(payload) {
74149
+ function asRecord17(payload) {
73614
74150
  return payload && typeof payload === "object" ? payload : {};
73615
74151
  }
73616
74152
  function defaultProbeModels(ctx) {
@@ -73638,7 +74174,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
73638
74174
  async function handleHarnessResources(payload, ctx) {
73639
74175
  const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
73640
74176
  if (denied) return denied;
73641
- const p2 = asRecord16(payload);
74177
+ const p2 = asRecord17(payload);
73642
74178
  const projectId = String(p2.projectId ?? "");
73643
74179
  if (!projectId) {
73644
74180
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74080,7 +74616,7 @@ function handleProviderListCredentials(ctx) {
74080
74616
  function handleProviderGetCredentialDecrypted(payload, ctx) {
74081
74617
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74082
74618
  if (denied) return denied;
74083
- const p2 = asRecord17(payload);
74619
+ const p2 = asRecord18(payload);
74084
74620
  const cred = ctx.providers.getCredentialDecrypted(String(p2.id ?? ""));
74085
74621
  if (!cred) return { error: { code: "not_found", message: "credential not found" } };
74086
74622
  return { result: cred };
@@ -74088,7 +74624,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
74088
74624
  function handleProviderCreateCredential(payload, ctx) {
74089
74625
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74090
74626
  if (denied) return denied;
74091
- const p2 = asRecord17(payload);
74627
+ const p2 = asRecord18(payload);
74092
74628
  try {
74093
74629
  return {
74094
74630
  result: ctx.providers.createCredential({
@@ -74110,7 +74646,7 @@ function handleProviderCreateCredential(payload, ctx) {
74110
74646
  function handleProviderUpdateCredential(payload, ctx) {
74111
74647
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74112
74648
  if (denied) return denied;
74113
- const p2 = asRecord17(payload);
74649
+ const p2 = asRecord18(payload);
74114
74650
  const id = String(p2.id ?? "");
74115
74651
  const updated = ctx.providers.updateCredential(id, {
74116
74652
  name: typeof p2.name === "string" ? p2.name : void 0,
@@ -74127,7 +74663,7 @@ function handleProviderUpdateCredential(payload, ctx) {
74127
74663
  function handleProviderDeleteCredential(payload, ctx) {
74128
74664
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74129
74665
  if (denied) return denied;
74130
- const p2 = asRecord17(payload);
74666
+ const p2 = asRecord18(payload);
74131
74667
  const ok = ctx.providers.deleteCredential(String(p2.id ?? ""));
74132
74668
  if (!ok) return { error: { code: "not_found", message: "credential not found" } };
74133
74669
  return { result: { ok: true } };
@@ -74140,7 +74676,7 @@ function handleProviderListBindings(ctx) {
74140
74676
  function handleProviderSetBinding(payload, ctx) {
74141
74677
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74142
74678
  if (denied) return denied;
74143
- const p2 = asRecord17(payload);
74679
+ const p2 = asRecord18(payload);
74144
74680
  const binding = p2;
74145
74681
  if (!binding.consumer || !binding.credentialId) {
74146
74682
  return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
@@ -74151,7 +74687,7 @@ function handleProviderSetBinding(payload, ctx) {
74151
74687
  function handleProviderClearBinding(payload, ctx) {
74152
74688
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74153
74689
  if (denied) return denied;
74154
- const p2 = asRecord17(payload);
74690
+ const p2 = asRecord18(payload);
74155
74691
  ctx.providers.clearBinding(String(p2.consumer ?? ""));
74156
74692
  return { result: { ok: true } };
74157
74693
  }
@@ -74163,14 +74699,14 @@ function handleProviderListCustomPlatforms(ctx) {
74163
74699
  function handleProviderUpsertCustomPlatform(payload, ctx) {
74164
74700
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74165
74701
  if (denied) return denied;
74166
- const def = asRecord17(payload);
74702
+ const def = asRecord18(payload);
74167
74703
  if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
74168
74704
  return { result: ctx.providers.upsertCustomPlatform(def) };
74169
74705
  }
74170
74706
  function handleProviderDeleteCustomPlatform(payload, ctx) {
74171
74707
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74172
74708
  if (denied) return denied;
74173
- const p2 = asRecord17(payload);
74709
+ const p2 = asRecord18(payload);
74174
74710
  const ok = ctx.providers.deleteCustomPlatform(String(p2.id ?? ""));
74175
74711
  if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
74176
74712
  return { result: { ok: true } };
@@ -74183,7 +74719,7 @@ function handleProviderExportBundle(ctx) {
74183
74719
  function handleProviderListModels(payload, ctx) {
74184
74720
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
74185
74721
  if (denied) return denied;
74186
- const p2 = asRecord17(payload);
74722
+ const p2 = asRecord18(payload);
74187
74723
  const harness = String(p2.harness ?? p2.harnessId ?? "claude");
74188
74724
  const apiProviderId = typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
74189
74725
  return {
@@ -74195,7 +74731,7 @@ function handleProviderListModels(payload, ctx) {
74195
74731
  function handleProviderImportBundle(payload, ctx) {
74196
74732
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74197
74733
  if (denied) return denied;
74198
- const p2 = asRecord17(payload);
74734
+ const p2 = asRecord18(payload);
74199
74735
  const bundle = p2.bundle && typeof p2.bundle === "object" ? p2.bundle : p2;
74200
74736
  const replaceAll = p2.replaceAll === true;
74201
74737
  try {
@@ -74260,7 +74796,7 @@ function handleHarnessList(ctx) {
74260
74796
  function handleHarnessShow(payload, ctx) {
74261
74797
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74262
74798
  if (denied) return denied;
74263
- const p2 = asRecord17(payload);
74799
+ const p2 = asRecord18(payload);
74264
74800
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74265
74801
  if (!isNodeHarnessId(id)) {
74266
74802
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74270,7 +74806,7 @@ function handleHarnessShow(payload, ctx) {
74270
74806
  function handleHarnessProbe(payload, ctx) {
74271
74807
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74272
74808
  if (denied) return denied;
74273
- const p2 = asRecord17(payload);
74809
+ const p2 = asRecord18(payload);
74274
74810
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74275
74811
  if (!isNodeHarnessId(id)) {
74276
74812
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74285,7 +74821,7 @@ function handleHarnessProbe(payload, ctx) {
74285
74821
  async function handleHarnessEnable(payload, ctx) {
74286
74822
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74287
74823
  if (denied) return denied;
74288
- const p2 = asRecord17(payload);
74824
+ const p2 = asRecord18(payload);
74289
74825
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74290
74826
  if (!isNodeHarnessId(id)) {
74291
74827
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74311,7 +74847,7 @@ async function handleHarnessEnable(payload, ctx) {
74311
74847
  function handleHarnessDisable(payload, ctx) {
74312
74848
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74313
74849
  if (denied) return denied;
74314
- const p2 = asRecord17(payload);
74850
+ const p2 = asRecord18(payload);
74315
74851
  const id = typeof p2.harnessId === "string" ? p2.harnessId : typeof p2.id === "string" ? p2.id : "";
74316
74852
  if (!isNodeHarnessId(id)) {
74317
74853
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -74376,7 +74912,7 @@ function handleSettingsGet(ctx) {
74376
74912
  function handleSettingsPatch(payload, ctx) {
74377
74913
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
74378
74914
  if (denied) return denied;
74379
- const p2 = asRecord17(payload);
74915
+ const p2 = asRecord18(payload);
74380
74916
  const rawPatch = p2.patch && typeof p2.patch === "object" ? p2.patch : p2;
74381
74917
  try {
74382
74918
  const settings = patchNodeAgentSettings(
@@ -74397,13 +74933,13 @@ async function handleSandboxProbe(ctx) {
74397
74933
  return mapThrown7(err);
74398
74934
  }
74399
74935
  }
74400
- function asRecord17(payload) {
74936
+ function asRecord18(payload) {
74401
74937
  return payload && typeof payload === "object" ? payload : {};
74402
74938
  }
74403
74939
  function handleTerminalCreate(payload, ctx) {
74404
74940
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74405
74941
  if (denied) return denied;
74406
- const p2 = asRecord17(payload);
74942
+ const p2 = asRecord18(payload);
74407
74943
  const cwd = typeof p2.cwd === "string" ? p2.cwd : process.cwd();
74408
74944
  try {
74409
74945
  const info = ctx.terminals.create({
@@ -74428,7 +74964,7 @@ function handleTerminalCreate(payload, ctx) {
74428
74964
  function handleTerminalAttach(payload, ctx) {
74429
74965
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74430
74966
  if (denied) return denied;
74431
- const p2 = asRecord17(payload);
74967
+ const p2 = asRecord18(payload);
74432
74968
  const terminalId = String(p2.terminalId ?? "");
74433
74969
  try {
74434
74970
  const attached = ctx.terminals.attach(terminalId);
@@ -74440,7 +74976,7 @@ function handleTerminalAttach(payload, ctx) {
74440
74976
  function handleTerminalRead(payload, ctx) {
74441
74977
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74442
74978
  if (denied) return denied;
74443
- const p2 = asRecord17(payload);
74979
+ const p2 = asRecord18(payload);
74444
74980
  try {
74445
74981
  return {
74446
74982
  result: ctx.terminals.readAfter(
@@ -74468,7 +75004,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
74468
75004
  function handleTerminalWrite(payload, ctx) {
74469
75005
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74470
75006
  if (denied) return denied;
74471
- const p2 = asRecord17(payload);
75007
+ const p2 = asRecord18(payload);
74472
75008
  const terminalId = String(p2.terminalId ?? "");
74473
75009
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
74474
75010
  if (leaseErr) return leaseErr;
@@ -74486,7 +75022,7 @@ function handleTerminalWrite(payload, ctx) {
74486
75022
  function handleTerminalResize(payload, ctx) {
74487
75023
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74488
75024
  if (denied) return denied;
74489
- const p2 = asRecord17(payload);
75025
+ const p2 = asRecord18(payload);
74490
75026
  const terminalId = String(p2.terminalId ?? "");
74491
75027
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
74492
75028
  if (leaseErr) return leaseErr;
@@ -74502,7 +75038,7 @@ function handleTerminalResize(payload, ctx) {
74502
75038
  function handleTerminalKill(payload, ctx) {
74503
75039
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74504
75040
  if (denied) return denied;
74505
- const p2 = asRecord17(payload);
75041
+ const p2 = asRecord18(payload);
74506
75042
  const terminalId = String(p2.terminalId ?? "");
74507
75043
  const leaseErr = requireTerminalLease(p2, ctx, terminalId);
74508
75044
  if (leaseErr) return leaseErr;
@@ -74516,7 +75052,7 @@ function handleTerminalKill(payload, ctx) {
74516
75052
  function handleTerminalAcquireControl(payload, ctx) {
74517
75053
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74518
75054
  if (denied) return denied;
74519
- const p2 = asRecord17(payload);
75055
+ const p2 = asRecord18(payload);
74520
75056
  const terminalId = String(p2.terminalId ?? "");
74521
75057
  try {
74522
75058
  return {
@@ -74533,7 +75069,7 @@ function handleTerminalAcquireControl(payload, ctx) {
74533
75069
  function handleTerminalRenewControl(payload, ctx) {
74534
75070
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74535
75071
  if (denied) return denied;
74536
- const p2 = asRecord17(payload);
75072
+ const p2 = asRecord18(payload);
74537
75073
  try {
74538
75074
  return {
74539
75075
  result: ctx.leases.renew({
@@ -74550,7 +75086,7 @@ function handleTerminalRenewControl(payload, ctx) {
74550
75086
  function handleTerminalReleaseControl(payload, ctx) {
74551
75087
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
74552
75088
  if (denied) return denied;
74553
- const p2 = asRecord17(payload);
75089
+ const p2 = asRecord18(payload);
74554
75090
  try {
74555
75091
  ctx.leases.release(
74556
75092
  String(p2.leaseId ?? ""),
@@ -74575,7 +75111,7 @@ function handleProjectList(ctx) {
74575
75111
  function handleProjectGet(payload, ctx) {
74576
75112
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
74577
75113
  if (denied) return denied;
74578
- const p2 = asRecord17(payload);
75114
+ const p2 = asRecord18(payload);
74579
75115
  const projectId = String(p2.projectId ?? "");
74580
75116
  return { result: ctx.projects.get(projectId) };
74581
75117
  }
@@ -74591,7 +75127,7 @@ function expandHostPath(path) {
74591
75127
  function handleProjectOpen(payload, ctx) {
74592
75128
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
74593
75129
  if (denied) return denied;
74594
- const p2 = asRecord17(payload);
75130
+ const p2 = asRecord18(payload);
74595
75131
  const path = expandHostPath(String(p2.path ?? ""));
74596
75132
  if (!path) {
74597
75133
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -74609,7 +75145,7 @@ function handleProjectOpen(payload, ctx) {
74609
75145
  function handleProjectRemove(payload, ctx) {
74610
75146
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
74611
75147
  if (denied) return denied;
74612
- const p2 = asRecord17(payload);
75148
+ const p2 = asRecord18(payload);
74613
75149
  const projectId = typeof p2.projectId === "string" && p2.projectId ? p2.projectId : void 0;
74614
75150
  const pathRaw = typeof p2.path === "string" && p2.path ? expandHostPath(p2.path) : void 0;
74615
75151
  if (!projectId && !pathRaw) {
@@ -74628,7 +75164,7 @@ function handleProjectRemove(payload, ctx) {
74628
75164
  function handleFsListDir(payload, ctx) {
74629
75165
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74630
75166
  if (denied) return denied;
74631
- const p2 = asRecord17(payload);
75167
+ const p2 = asRecord18(payload);
74632
75168
  const raw = String(p2.path ?? "");
74633
75169
  if (!raw || raw.includes("\0")) {
74634
75170
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -74654,7 +75190,7 @@ function handleFsListDir(payload, ctx) {
74654
75190
  function handleWorkspaceListDir(payload, ctx) {
74655
75191
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74656
75192
  if (denied) return denied;
74657
- const p2 = asRecord17(payload);
75193
+ const p2 = asRecord18(payload);
74658
75194
  try {
74659
75195
  return {
74660
75196
  result: ctx.workspaceFs.listDir(String(p2.projectId ?? ""), String(p2.relativePath ?? "."))
@@ -74666,7 +75202,7 @@ function handleWorkspaceListDir(payload, ctx) {
74666
75202
  function handleWorkspaceListFiles(payload, ctx) {
74667
75203
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74668
75204
  if (denied) return denied;
74669
- const p2 = asRecord17(payload);
75205
+ const p2 = asRecord18(payload);
74670
75206
  try {
74671
75207
  return {
74672
75208
  result: {
@@ -74684,7 +75220,7 @@ function handleWorkspaceListFiles(payload, ctx) {
74684
75220
  function handleWorkspaceListSkills(payload, ctx) {
74685
75221
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74686
75222
  if (denied) return denied;
74687
- const p2 = asRecord17(payload);
75223
+ const p2 = asRecord18(payload);
74688
75224
  try {
74689
75225
  return {
74690
75226
  result: ctx.workspaceFs.listSkillsAndCommands(String(p2.projectId ?? ""))
@@ -74696,7 +75232,7 @@ function handleWorkspaceListSkills(payload, ctx) {
74696
75232
  function handleWorkspaceReadFile(payload, ctx) {
74697
75233
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74698
75234
  if (denied) return denied;
74699
- const p2 = asRecord17(payload);
75235
+ const p2 = asRecord18(payload);
74700
75236
  try {
74701
75237
  return {
74702
75238
  result: ctx.workspaceFs.readFile(String(p2.projectId ?? ""), String(p2.relativePath ?? ""), {
@@ -74711,7 +75247,7 @@ function handleWorkspaceReadFile(payload, ctx) {
74711
75247
  function handleWorkspaceWriteFile(payload, ctx) {
74712
75248
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74713
75249
  if (denied) return denied;
74714
- const p2 = asRecord17(payload);
75250
+ const p2 = asRecord18(payload);
74715
75251
  const raw = typeof p2.content === "string" ? p2.content : String(p2.content ?? "");
74716
75252
  const encoding = p2.encoding === "base64" ? "base64" : "utf8";
74717
75253
  let content = raw;
@@ -74741,7 +75277,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
74741
75277
  function handleWorkspaceSearch(payload, ctx) {
74742
75278
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74743
75279
  if (denied) return denied;
74744
- const p2 = asRecord17(payload);
75280
+ const p2 = asRecord18(payload);
74745
75281
  try {
74746
75282
  return {
74747
75283
  result: ctx.workspaceFs.search(
@@ -74757,7 +75293,7 @@ function handleWorkspaceSearch(payload, ctx) {
74757
75293
  function handleWorkspaceRename(payload, ctx) {
74758
75294
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74759
75295
  if (denied) return denied;
74760
- const p2 = asRecord17(payload);
75296
+ const p2 = asRecord18(payload);
74761
75297
  try {
74762
75298
  return {
74763
75299
  result: ctx.workspaceFs.rename(
@@ -74773,7 +75309,7 @@ function handleWorkspaceRename(payload, ctx) {
74773
75309
  function handleWorkspaceMove(payload, ctx) {
74774
75310
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74775
75311
  if (denied) return denied;
74776
- const p2 = asRecord17(payload);
75312
+ const p2 = asRecord18(payload);
74777
75313
  try {
74778
75314
  return {
74779
75315
  result: ctx.workspaceFs.move(
@@ -74789,7 +75325,7 @@ function handleWorkspaceMove(payload, ctx) {
74789
75325
  function handleWorkspaceDelete(payload, ctx) {
74790
75326
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74791
75327
  if (denied) return denied;
74792
- const p2 = asRecord17(payload);
75328
+ const p2 = asRecord18(payload);
74793
75329
  try {
74794
75330
  return {
74795
75331
  result: ctx.workspaceFs.delete(
@@ -74804,7 +75340,7 @@ function handleWorkspaceDelete(payload, ctx) {
74804
75340
  function handleWorkspaceMkdir(payload, ctx) {
74805
75341
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74806
75342
  if (denied) return denied;
74807
- const p2 = asRecord17(payload);
75343
+ const p2 = asRecord18(payload);
74808
75344
  try {
74809
75345
  return {
74810
75346
  result: ctx.workspaceFs.mkdir(
@@ -74819,7 +75355,7 @@ function handleWorkspaceMkdir(payload, ctx) {
74819
75355
  function handleWorkspaceWatchStart(payload, ctx) {
74820
75356
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74821
75357
  if (denied) return denied;
74822
- const p2 = asRecord17(payload);
75358
+ const p2 = asRecord18(payload);
74823
75359
  try {
74824
75360
  const events = [];
74825
75361
  const { watchId, cancel } = ctx.workspaceWatch.subscribe(
@@ -74840,7 +75376,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
74840
75376
  function handleWorkspaceWatchPoll(payload, ctx) {
74841
75377
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74842
75378
  if (denied) return denied;
74843
- const p2 = asRecord17(payload);
75379
+ const p2 = asRecord18(payload);
74844
75380
  const watchId = String(p2.watchId ?? "");
74845
75381
  const buf = watchBuffers.get(watchId);
74846
75382
  if (!buf || buf.owner !== ctx.client.clientSessionId) {
@@ -74852,7 +75388,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
74852
75388
  function handleWorkspaceWatchStop(payload, ctx) {
74853
75389
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74854
75390
  if (denied) return denied;
74855
- const p2 = asRecord17(payload);
75391
+ const p2 = asRecord18(payload);
74856
75392
  const watchId = String(p2.watchId ?? "");
74857
75393
  const buf = watchBuffers.get(watchId);
74858
75394
  if (buf && buf.owner === ctx.client.clientSessionId) {
@@ -74864,7 +75400,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
74864
75400
  function handleWorkspaceTailWatchStart(payload, ctx) {
74865
75401
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74866
75402
  if (denied) return denied;
74867
- const p2 = asRecord17(payload);
75403
+ const p2 = asRecord18(payload);
74868
75404
  try {
74869
75405
  const offset = typeof p2.offset === "number" ? p2.offset : void 0;
74870
75406
  const absolutePath = typeof p2.absolutePath === "string" ? p2.absolutePath : void 0;
@@ -74882,7 +75418,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
74882
75418
  function handleWorkspaceTailWatchPoll(payload, ctx) {
74883
75419
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74884
75420
  if (denied) return denied;
74885
- const p2 = asRecord17(payload);
75421
+ const p2 = asRecord18(payload);
74886
75422
  try {
74887
75423
  return {
74888
75424
  result: ctx.workspaceTailWatch.poll(String(p2.watchId ?? ""), ctx.client.clientSessionId)
@@ -74894,7 +75430,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
74894
75430
  function handleWorkspaceTailWatchStop(payload, ctx) {
74895
75431
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74896
75432
  if (denied) return denied;
74897
- const p2 = asRecord17(payload);
75433
+ const p2 = asRecord18(payload);
74898
75434
  try {
74899
75435
  return {
74900
75436
  result: ctx.workspaceTailWatch.stop(String(p2.watchId ?? ""), ctx.client.clientSessionId)
@@ -74906,7 +75442,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
74906
75442
  function handleGitStatus(payload, ctx) {
74907
75443
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74908
75444
  if (denied) return denied;
74909
- const p2 = asRecord17(payload);
75445
+ const p2 = asRecord18(payload);
74910
75446
  try {
74911
75447
  const projectId = String(p2.projectId ?? "");
74912
75448
  const cwd = typeof p2.cwd === "string" ? p2.cwd : null;
@@ -74920,7 +75456,7 @@ function handleGitStatus(payload, ctx) {
74920
75456
  function handleGitDiff(payload, ctx) {
74921
75457
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74922
75458
  if (denied) return denied;
74923
- const p2 = asRecord17(payload);
75459
+ const p2 = asRecord18(payload);
74924
75460
  try {
74925
75461
  return {
74926
75462
  result: ctx.workspaceGit.diff(String(p2.projectId ?? ""), {
@@ -74935,7 +75471,7 @@ function handleGitDiff(payload, ctx) {
74935
75471
  function handleGitBranches(payload, ctx) {
74936
75472
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74937
75473
  if (denied) return denied;
74938
- const p2 = asRecord17(payload);
75474
+ const p2 = asRecord18(payload);
74939
75475
  try {
74940
75476
  return {
74941
75477
  result: ctx.workspaceGit.branches(
@@ -74950,7 +75486,7 @@ function handleGitBranches(payload, ctx) {
74950
75486
  function handleGitSwitchBranch(payload, ctx) {
74951
75487
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74952
75488
  if (denied) return denied;
74953
- const p2 = asRecord17(payload);
75489
+ const p2 = asRecord18(payload);
74954
75490
  try {
74955
75491
  return {
74956
75492
  result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
@@ -74965,7 +75501,7 @@ function handleGitSwitchBranch(payload, ctx) {
74965
75501
  function handleGitCreateBranch(payload, ctx) {
74966
75502
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74967
75503
  if (denied) return denied;
74968
- const p2 = asRecord17(payload);
75504
+ const p2 = asRecord18(payload);
74969
75505
  try {
74970
75506
  return {
74971
75507
  result: ctx.workspaceGit.switchBranch(String(p2.projectId ?? ""), String(p2.branch ?? ""), {
@@ -74980,7 +75516,7 @@ function handleGitCreateBranch(payload, ctx) {
74980
75516
  function handleGitWorktrees(payload, ctx) {
74981
75517
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
74982
75518
  if (denied) return denied;
74983
- const p2 = asRecord17(payload);
75519
+ const p2 = asRecord18(payload);
74984
75520
  try {
74985
75521
  return { result: ctx.workspaceGit.worktrees(String(p2.projectId ?? "")) };
74986
75522
  } catch (err) {
@@ -74990,7 +75526,7 @@ function handleGitWorktrees(payload, ctx) {
74990
75526
  function handleGitWorktreeActivate(payload, ctx) {
74991
75527
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
74992
75528
  if (denied) return denied;
74993
- const p2 = asRecord17(payload);
75529
+ const p2 = asRecord18(payload);
74994
75530
  const mode = p2.mode === "attach" || p2.mode === "detach" || p2.mode === "branch" ? p2.mode : null;
74995
75531
  if (!mode) {
74996
75532
  return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
@@ -75011,7 +75547,7 @@ function handleGitWorktreeActivate(payload, ctx) {
75011
75547
  function handleGitWorktreeCheckedOutBranches(payload, ctx) {
75012
75548
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75013
75549
  if (denied) return denied;
75014
- const p2 = asRecord17(payload);
75550
+ const p2 = asRecord18(payload);
75015
75551
  try {
75016
75552
  return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p2.projectId ?? "")) } };
75017
75553
  } catch (err) {
@@ -75021,7 +75557,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
75021
75557
  function handleGitWorktreeAssignBranch(payload, ctx) {
75022
75558
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75023
75559
  if (denied) return denied;
75024
- const p2 = asRecord17(payload);
75560
+ const p2 = asRecord18(payload);
75025
75561
  try {
75026
75562
  return {
75027
75563
  result: ctx.workspaceGit.assignBranch(
@@ -75037,7 +75573,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
75037
75573
  function handleGitWorktreeHandoff(payload, ctx) {
75038
75574
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75039
75575
  if (denied) return denied;
75040
- const p2 = asRecord17(payload);
75576
+ const p2 = asRecord18(payload);
75041
75577
  try {
75042
75578
  return {
75043
75579
  result: ctx.workspaceGit.handoffToMain(
@@ -75052,7 +75588,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
75052
75588
  function handleGitWorktreeHandoffPreview(payload, ctx) {
75053
75589
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75054
75590
  if (denied) return denied;
75055
- const p2 = asRecord17(payload);
75591
+ const p2 = asRecord18(payload);
75056
75592
  try {
75057
75593
  return {
75058
75594
  result: ctx.workspaceGit.handoffPreview(
@@ -75067,7 +75603,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
75067
75603
  function handleSessionSetCwd(payload, ctx) {
75068
75604
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75069
75605
  if (denied) return denied;
75070
- const p2 = asRecord17(payload);
75606
+ const p2 = asRecord18(payload);
75071
75607
  const sessionId = String(p2.sessionId ?? "");
75072
75608
  const cwdRaw = p2.cwd;
75073
75609
  const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
@@ -75096,7 +75632,7 @@ function handleSessionSetCwd(payload, ctx) {
75096
75632
  function handleSessionPatchSettings(payload, ctx) {
75097
75633
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75098
75634
  if (denied) return denied;
75099
- const p2 = asRecord17(payload);
75635
+ const p2 = asRecord18(payload);
75100
75636
  const sessionId = String(p2.sessionId ?? "").trim();
75101
75637
  if (!sessionId) {
75102
75638
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75112,7 +75648,7 @@ function handleSessionPatchSettings(payload, ctx) {
75112
75648
  generation: String(p2.generation ?? ""),
75113
75649
  holderClientId: ctx.client.clientSessionId
75114
75650
  });
75115
- const settingsSrc = asRecord17(p2.settings ?? p2);
75651
+ const settingsSrc = asRecord18(p2.settings ?? p2);
75116
75652
  const patch = {};
75117
75653
  const take = (key) => {
75118
75654
  if (!(key in settingsSrc)) return;
@@ -75138,7 +75674,7 @@ function handleSessionPatchSettings(payload, ctx) {
75138
75674
  async function handleSessionFork(payload, ctx) {
75139
75675
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75140
75676
  if (denied) return denied;
75141
- const p2 = asRecord17(payload);
75677
+ const p2 = asRecord18(payload);
75142
75678
  const sessionId = String(p2.sessionId ?? "").trim();
75143
75679
  if (!sessionId) {
75144
75680
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75225,7 +75761,7 @@ async function handleSessionFork(payload, ctx) {
75225
75761
  async function handleGitClone(payload, ctx) {
75226
75762
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75227
75763
  if (denied) return denied;
75228
- const p2 = asRecord17(payload);
75764
+ const p2 = asRecord18(payload);
75229
75765
  try {
75230
75766
  const cloned = await cloneRepository({
75231
75767
  remoteUrl: String(p2.remoteUrl ?? ""),
@@ -75241,7 +75777,7 @@ async function handleGitClone(payload, ctx) {
75241
75777
  function handleSessionCreate(payload, ctx) {
75242
75778
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75243
75779
  if (denied) return denied;
75244
- const p2 = asRecord17(payload);
75780
+ const p2 = asRecord18(payload);
75245
75781
  const rawHarnessId = typeof p2.harnessId === "string" ? p2.harnessId : "claude";
75246
75782
  const harnessId = normalizeSessionHarnessId(rawHarnessId);
75247
75783
  if (!harnessId) {
@@ -75294,7 +75830,7 @@ function handleSessionCreate(payload, ctx) {
75294
75830
  try {
75295
75831
  const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
75296
75832
  const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
75297
- const options = asRecord17(p2.options);
75833
+ const options = asRecord18(p2.options);
75298
75834
  const providerId = typeof p2.providerId === "string" && p2.providerId.trim() ? p2.providerId.trim() : void 0;
75299
75835
  const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
75300
75836
  const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
@@ -75355,13 +75891,13 @@ function handleSessionCreate(payload, ctx) {
75355
75891
  function handleSessionGet(payload, ctx) {
75356
75892
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75357
75893
  if (denied) return denied;
75358
- const p2 = asRecord17(payload);
75894
+ const p2 = asRecord18(payload);
75359
75895
  return { result: ctx.sessions.get(String(p2.sessionId ?? "")) };
75360
75896
  }
75361
75897
  function handleSessionList(payload, ctx) {
75362
75898
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75363
75899
  if (denied) return denied;
75364
- const p2 = asRecord17(payload);
75900
+ const p2 = asRecord18(payload);
75365
75901
  const projectId = typeof p2.projectId === "string" ? p2.projectId : void 0;
75366
75902
  if (typeof p2.limit !== "number" || !Number.isFinite(p2.limit)) {
75367
75903
  return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
@@ -75401,7 +75937,7 @@ function handleSessionList(payload, ctx) {
75401
75937
  function handleSessionAcquireControl(payload, ctx) {
75402
75938
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75403
75939
  if (denied) return denied;
75404
- const p2 = asRecord17(payload);
75940
+ const p2 = asRecord18(payload);
75405
75941
  const sessionId = String(p2.sessionId ?? "");
75406
75942
  if (!sessionId) {
75407
75943
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75425,7 +75961,7 @@ function handleSessionAcquireControl(payload, ctx) {
75425
75961
  function handleSessionRenewControl(payload, ctx) {
75426
75962
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75427
75963
  if (denied) return denied;
75428
- const p2 = asRecord17(payload);
75964
+ const p2 = asRecord18(payload);
75429
75965
  try {
75430
75966
  return {
75431
75967
  result: ctx.leases.renew({
@@ -75442,7 +75978,7 @@ function handleSessionRenewControl(payload, ctx) {
75442
75978
  function handleSessionReleaseControl(payload, ctx) {
75443
75979
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75444
75980
  if (denied) return denied;
75445
- const p2 = asRecord17(payload);
75981
+ const p2 = asRecord18(payload);
75446
75982
  try {
75447
75983
  ctx.leases.release(
75448
75984
  String(p2.leaseId ?? ""),
@@ -75457,7 +75993,7 @@ function handleSessionReleaseControl(payload, ctx) {
75457
75993
  function handleSessionClose(payload, ctx) {
75458
75994
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75459
75995
  if (denied) return denied;
75460
- const p2 = asRecord17(payload);
75996
+ const p2 = asRecord18(payload);
75461
75997
  const sessionId = String(p2.sessionId ?? "");
75462
75998
  try {
75463
75999
  ctx.leases.assertValid({
@@ -75483,7 +76019,7 @@ function handleSessionClose(payload, ctx) {
75483
76019
  function handleSessionRemove(payload, ctx) {
75484
76020
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75485
76021
  if (denied) return denied;
75486
- const p2 = asRecord17(payload);
76022
+ const p2 = asRecord18(payload);
75487
76023
  const sessionId = String(p2.sessionId ?? "");
75488
76024
  if (!sessionId) {
75489
76025
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75510,7 +76046,7 @@ function handleSessionRemove(payload, ctx) {
75510
76046
  function handleSessionRename(payload, ctx) {
75511
76047
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75512
76048
  if (denied) return denied;
75513
- const p2 = asRecord17(payload);
76049
+ const p2 = asRecord18(payload);
75514
76050
  const sessionId = String(p2.sessionId ?? "");
75515
76051
  const title = String(p2.title ?? "");
75516
76052
  const source = p2.source === "agent" ? "agent" : "user";
@@ -75526,7 +76062,7 @@ function handleSessionRename(payload, ctx) {
75526
76062
  function handleSessionSetTags(payload, ctx) {
75527
76063
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75528
76064
  if (denied) return denied;
75529
- const p2 = asRecord17(payload);
76065
+ const p2 = asRecord18(payload);
75530
76066
  const sessionId = String(p2.sessionId ?? "");
75531
76067
  if (!sessionId) {
75532
76068
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75552,7 +76088,7 @@ function handleSessionSetTags(payload, ctx) {
75552
76088
  function handleSessionSetUiFlags(payload, ctx) {
75553
76089
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75554
76090
  if (denied) return denied;
75555
- const p2 = asRecord17(payload);
76091
+ const p2 = asRecord18(payload);
75556
76092
  const sessionId = String(p2.sessionId ?? "");
75557
76093
  if (!sessionId) {
75558
76094
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75571,9 +76107,9 @@ function handleSessionSetUiFlags(payload, ctx) {
75571
76107
  async function handleSessionSend(payload, ctx) {
75572
76108
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75573
76109
  if (denied) return denied;
75574
- const p2 = asRecord17(payload);
76110
+ const p2 = asRecord18(payload);
75575
76111
  try {
75576
- const options = asRecord17(p2.options);
76112
+ const options = asRecord18(p2.options);
75577
76113
  const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
75578
76114
  const modelTopLevel = typeof p2.model === "string" && p2.model.trim() ? p2.model.trim() : null;
75579
76115
  const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p2.apiProviderId === "string" && p2.apiProviderId.trim() ? p2.apiProviderId.trim() : null;
@@ -75666,7 +76202,7 @@ async function handleSessionSend(payload, ctx) {
75666
76202
  function handleSessionInterrupt(payload, ctx) {
75667
76203
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75668
76204
  if (denied) return denied;
75669
- const p2 = asRecord17(payload);
76205
+ const p2 = asRecord18(payload);
75670
76206
  try {
75671
76207
  ctx.sessions.interrupt(
75672
76208
  String(p2.sessionId ?? ""),
@@ -75682,7 +76218,7 @@ function handleSessionInterrupt(payload, ctx) {
75682
76218
  function handleSessionRespondPermission(payload, ctx) {
75683
76219
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75684
76220
  if (denied) return denied;
75685
- const p2 = asRecord17(payload);
76221
+ const p2 = asRecord18(payload);
75686
76222
  try {
75687
76223
  const formAnswers = p2.formAnswers && typeof p2.formAnswers === "object" && !Array.isArray(p2.formAnswers) ? p2.formAnswers : p2.options && typeof p2.options === "object" && !Array.isArray(p2.options) ? p2.options.formAnswers ?? p2.options : void 0;
75688
76224
  ctx.sessions.respondPermission({
@@ -75703,7 +76239,7 @@ function handleSessionRespondPermission(payload, ctx) {
75703
76239
  function handleSessionRespondQuestion(payload, ctx) {
75704
76240
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75705
76241
  if (denied) return denied;
75706
- const p2 = asRecord17(payload);
76242
+ const p2 = asRecord18(payload);
75707
76243
  try {
75708
76244
  ctx.sessions.respondQuestion({
75709
76245
  sessionId: String(p2.sessionId ?? ""),
@@ -75721,7 +76257,7 @@ function handleSessionRespondQuestion(payload, ctx) {
75721
76257
  function handleSessionRespondPlan(payload, ctx) {
75722
76258
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75723
76259
  if (denied) return denied;
75724
- const p2 = asRecord17(payload);
76260
+ const p2 = asRecord18(payload);
75725
76261
  const decision = p2.decision === "approve" || p2.decision === "reject" ? p2.decision : null;
75726
76262
  if (!decision) {
75727
76263
  return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
@@ -75744,7 +76280,7 @@ function handleSessionRespondPlan(payload, ctx) {
75744
76280
  async function handleSessionHostActionsPoll(payload, ctx) {
75745
76281
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75746
76282
  if (denied) return denied;
75747
- const p2 = asRecord17(payload);
76283
+ const p2 = asRecord18(payload);
75748
76284
  try {
75749
76285
  const result = await ctx.sessions.pollHostActions({
75750
76286
  controllerClientSessionId: ctx.client.clientSessionId,
@@ -75760,7 +76296,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
75760
76296
  function handleSessionClaimHostAction(payload, ctx) {
75761
76297
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75762
76298
  if (denied) return denied;
75763
- const p2 = asRecord17(payload);
76299
+ const p2 = asRecord18(payload);
75764
76300
  try {
75765
76301
  const result = ctx.sessions.claimHostAction({
75766
76302
  actionId: String(p2.actionId ?? ""),
@@ -75776,7 +76312,7 @@ function handleSessionClaimHostAction(payload, ctx) {
75776
76312
  function handleSessionRespondHostAction(payload, ctx) {
75777
76313
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75778
76314
  if (denied) return denied;
75779
- const p2 = asRecord17(payload);
76315
+ const p2 = asRecord18(payload);
75780
76316
  const outcome = p2.outcome === "failed" ? "failed" : p2.outcome === "succeeded" ? "succeeded" : null;
75781
76317
  if (!outcome) {
75782
76318
  return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
@@ -75798,14 +76334,14 @@ function handleSessionRespondHostAction(payload, ctx) {
75798
76334
  function handleSessionEvents(payload, ctx) {
75799
76335
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75800
76336
  if (denied) return denied;
75801
- const p2 = asRecord17(payload);
76337
+ const p2 = asRecord18(payload);
75802
76338
  const after = String(p2.afterSequence ?? "0");
75803
76339
  return { result: { events: ctx.sessions.listEventsAfter(after) } };
75804
76340
  }
75805
76341
  function handleSessionMessagesList(payload, ctx) {
75806
76342
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75807
76343
  if (denied) return denied;
75808
- const p2 = asRecord17(payload);
76344
+ const p2 = asRecord18(payload);
75809
76345
  const sessionId = String(p2.sessionId ?? "").trim();
75810
76346
  if (!sessionId) {
75811
76347
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -75844,7 +76380,7 @@ function handleCollaborationListProfiles(ctx) {
75844
76380
  async function handleCollaborationRequest(payload, ctx) {
75845
76381
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75846
76382
  if (denied) return denied;
75847
- const p2 = asRecord17(payload);
76383
+ const p2 = asRecord18(payload);
75848
76384
  const parentSessionId = String(p2.parentSessionId ?? "");
75849
76385
  if (!parentSessionId) {
75850
76386
  return { error: { code: "invalid_argument", message: "parentSessionId required" } };
@@ -75878,7 +76414,7 @@ async function handleCollaborationRequest(payload, ctx) {
75878
76414
  async function handleCollaborationStart(payload, ctx) {
75879
76415
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75880
76416
  if (denied) return denied;
75881
- const p2 = asRecord17(payload);
76417
+ const p2 = asRecord18(payload);
75882
76418
  const credential = typeof p2.credential === "string" ? p2.credential : void 0;
75883
76419
  const grantId = typeof p2.grantId === "string" ? p2.grantId : void 0;
75884
76420
  if (!credential && !grantId) {
@@ -75924,7 +76460,7 @@ async function handleCollaborationStart(payload, ctx) {
75924
76460
  function handleCollaborationSend(payload, ctx) {
75925
76461
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
75926
76462
  if (denied) return denied;
75927
- const p2 = asRecord17(payload);
76463
+ const p2 = asRecord18(payload);
75928
76464
  const credential = String(p2.credential ?? "");
75929
76465
  const sessionId = String(p2.sessionId ?? p2.fromSessionId ?? "");
75930
76466
  const content = typeof p2.content === "string" ? p2.content : p2.body !== void 0 ? typeof p2.body === "string" ? p2.body : JSON.stringify(p2.body) : "";
@@ -75960,7 +76496,7 @@ function handleCollaborationSend(payload, ctx) {
75960
76496
  function handleCollaborationRetrieve(payload, ctx) {
75961
76497
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
75962
76498
  if (denied) return denied;
75963
- const p2 = asRecord17(payload);
76499
+ const p2 = asRecord18(payload);
75964
76500
  const credential = String(p2.credential ?? "");
75965
76501
  const sessionId = String(p2.sessionId ?? "");
75966
76502
  if (!credential) {
@@ -76806,7 +77342,7 @@ function requiredRuntimeVersion(harnessId, manifest) {
76806
77342
  import { existsSync as existsSync29, mkdirSync as mkdirSync18, readFileSync as readFileSync17, readdirSync as readdirSync10, statSync as statSync9, writeFileSync as writeFileSync13 } from "node:fs";
76807
77343
  import { arch as osArch2, platform as osPlatform2 } from "node:os";
76808
77344
  import { join as join27, resolve as resolve7 } from "node:path";
76809
- var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.232";
77345
+ var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.238";
76810
77346
  var OFFICIAL_CODEX_NPM_VERSION = "0.147.0";
76811
77347
  var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
76812
77348
  function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
@@ -79626,10 +80162,45 @@ init_codex_turn_runner();
79626
80162
  // src/session/collaboration.ts
79627
80163
  init_agent_types();
79628
80164
  init_environment();
79629
- init_resolve_service();
79630
80165
  import { createHash as createHash9, randomBytes as randomBytes5, randomUUID as randomUUID10 } from "node:crypto";
79631
80166
  import { existsSync as existsSync39, statSync as statSync15 } from "node:fs";
79632
80167
  import { resolve as pathResolve2 } from "node:path";
80168
+
80169
+ // ../../packages/shared/src/harness/acp-brand.ts
80170
+ function isGrokAcpAgent(agentId) {
80171
+ if (!agentId) return false;
80172
+ const id = agentId.toLowerCase();
80173
+ return id.includes("grok");
80174
+ }
80175
+ function isOpenCodeAcpAgent(agentId) {
80176
+ if (!agentId) return false;
80177
+ return agentId.toLowerCase().includes("opencode");
80178
+ }
80179
+ function resolveHarnessBrandKey(harnessId, acpAgentId) {
80180
+ if (!harnessId) return "claude";
80181
+ if (harnessId !== "acp") return harnessId;
80182
+ if (isGrokAcpAgent(acpAgentId)) return "acp-grok";
80183
+ if (isOpenCodeAcpAgent(acpAgentId)) return "acp-opencode";
80184
+ if (acpAgentId?.trim()) {
80185
+ const short = acpAgentId.trim().toLowerCase().replace(/-build$/, "").replace(/[^a-z0-9]+/g, "-");
80186
+ return short ? `acp-${short}` : "acp";
80187
+ }
80188
+ return "acp";
80189
+ }
80190
+ function acpAgentDisplayName(agentId, catalogName) {
80191
+ if (catalogName?.trim()) {
80192
+ return catalogName.trim().replace(/\s+Build$/i, "");
80193
+ }
80194
+ if (isGrokAcpAgent(agentId)) return "Grok";
80195
+ if (isOpenCodeAcpAgent(agentId)) return "OpenCode";
80196
+ if (agentId?.trim()) {
80197
+ return agentId.trim().replace(/-build$/i, "").split(/[-_]/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
80198
+ }
80199
+ return "ACP";
80200
+ }
80201
+
80202
+ // src/session/collaboration.ts
80203
+ init_resolve_service();
79633
80204
  var MAX_MESSAGES_PER_RETRIEVE = 100;
79634
80205
  var EMPTY_MAILBOX_HINT = "No peer has replied yet. Do not retrieve again, do not sleep, do not wait in place \u2014 end your turn or do unrelated work. A task notification will start a new turn for you as soon as a message arrives.";
79635
80206
  function hashCredential(credential) {
@@ -79642,6 +80213,12 @@ function parseConfig(raw) {
79642
80213
  return {};
79643
80214
  }
79644
80215
  }
80216
+ function resolveProfile(profiles, agentId) {
80217
+ const direct = profiles.get(agentId);
80218
+ if (direct) return direct;
80219
+ const wire = normalizeSessionHarnessId(agentId);
80220
+ return wire ? profiles.get(`${wire}-base`) : void 0;
80221
+ }
79645
80222
  function resolveLaunchMode(raw) {
79646
80223
  if (raw === "link") return "link";
79647
80224
  if (raw === "handoff") return "handoff";
@@ -79696,9 +80273,7 @@ var CollaborationService = class {
79696
80273
  };
79697
80274
  const pushProfile = (profileId, harnessId, name, description, profileConfig) => {
79698
80275
  if (seen.has(profileId)) return;
79699
- if (harnessId !== "claude" && harnessId !== "codex" && harnessId !== "acp" && harnessId !== "opencode") {
79700
- return;
79701
- }
80276
+ if (!harnesses.isSessionHarnessRunnable(harnessId)) return;
79702
80277
  seen.add(profileId);
79703
80278
  const models = listHarnessModels(providers, harnessId, null, providerOptions).map((m2) => ({
79704
80279
  id: m2.id,
@@ -79713,13 +80288,15 @@ var CollaborationService = class {
79713
80288
  const cfg = profileConfig && typeof profileConfig === "object" && !Array.isArray(profileConfig) ? profileConfig : {};
79714
80289
  const cfgModel = typeof cfg.model === "string" && cfg.model.trim() ? cfg.model.trim() : void 0;
79715
80290
  const cfgEffort = typeof cfg.effort === "string" && cfg.effort.trim() ? cfg.effort.trim() : typeof cfg.reasoningEffort === "string" && cfg.reasoningEffort.trim() ? cfg.reasoningEffort.trim() : void 0;
80291
+ const acpAgentId = harnessId === "acp" && typeof cfg.agentId === "string" && cfg.agentId.trim() ? cfg.agentId.trim() : null;
79716
80292
  const modelDefault = cfgModel ?? defaultModel?.id;
79717
80293
  const effortDefault = cfgEffort ?? (efforts.has("high") ? "high" : efforts.has("medium") ? "medium" : efforts.size > 0 ? [...efforts][0] : void 0);
79718
80294
  profiles.push({
79719
80295
  id: profileId,
79720
- name,
80296
+ name: harnessId === "acp" ? acpAgentDisplayName(acpAgentId) : name,
79721
80297
  harnessId,
79722
- brandKey: harnessId === "acp" ? "acp" : harnessId,
80298
+ ...acpAgentId ? { acpAgentId } : {},
80299
+ brandKey: resolveHarnessBrandKey(harnessId, acpAgentId),
79723
80300
  description,
79724
80301
  defaultConfig: {
79725
80302
  ...modelDefault ? { model: modelDefault } : {},
@@ -79739,25 +80316,12 @@ var CollaborationService = class {
79739
80316
  p2.isBase ? `${p2.harnessId} harness with the built-in configuration` : `Custom ${p2.harnessId} profile`,
79740
80317
  p2.config
79741
80318
  );
79742
- if (p2.isBase && p2.id === `${p2.harnessId}-base`) {
79743
- pushProfile(
79744
- p2.harnessId,
79745
- p2.harnessId,
79746
- p2.harnessId,
79747
- `${p2.harnessId} harness`,
79748
- p2.config
79749
- );
79750
- }
79751
80319
  }
79752
80320
  }
79753
80321
  if (profiles.length === 0) {
79754
- const ready = new Set(harnesses.readySessionHarnessIds());
79755
- const seedIds = new Set(
79756
- ready.size > 0 ? [...ready] : NODE_HARNESS_DEFINITIONS.map((d) => d.sessionHarnessId)
79757
- );
80322
+ const seedIds = new Set(harnesses.readySessionHarnessIds());
79758
80323
  for (const s2 of sessions.list()) {
79759
80324
  if (s2.harnessId) seedIds.add(s2.harnessId);
79760
- if (s2.providerId) seedIds.add(s2.providerId);
79761
80325
  }
79762
80326
  for (const id of seedIds) {
79763
80327
  const harnessId = normalizeSessionHarnessId(id) ?? id;
@@ -79862,7 +80426,7 @@ var CollaborationService = class {
79862
80426
  { code: "invalid_argument" }
79863
80427
  );
79864
80428
  }
79865
- const profile = profiles.get(agentId);
80429
+ const profile = resolveProfile(profiles, agentId);
79866
80430
  if (!profile) {
79867
80431
  throw Object.assign(new Error(`Unknown agent profile: ${agentId}`), {
79868
80432
  code: "invalid_argument"
@@ -80238,7 +80802,10 @@ var CollaborationService = class {
80238
80802
  });
80239
80803
  cwd = wt.path;
80240
80804
  }
80241
- const profile = this.listProfiles().find((p2) => p2.id === grant.agent_id);
80805
+ const profile = resolveProfile(
80806
+ new Map(this.listProfiles().map((p2) => [p2.id, p2])),
80807
+ grant.agent_id
80808
+ );
80242
80809
  const harnessId = profile?.harnessId ?? normalizeSessionHarnessId(grant.agent_id) ?? "claude";
80243
80810
  const displayName = deriveCollaborationName({ name: config2.name });
80244
80811
  const role = deriveCollaborationRole({ role: config2.role, task: grant.task });
@@ -94724,6 +95291,7 @@ async function startNodeRuntime(partial2 = {}) {
94724
95291
  allowSimulatedFallback: allowSimulatedTurnFallback,
94725
95292
  providers,
94726
95293
  experimentalClaudeOpenAiChatEnabled: () => loadNodeAgentSettings(paths.configJson).experimentalClaudeOpenAiChatEnabled,
95294
+ askUserQuestionPreviewFormat: () => loadNodeAgentSettings(paths.configJson).claude.askUserQuestionPreviewFormat,
94727
95295
  // Claude: in-process SDK MCP (same core tools as HTTP).
94728
95296
  createHostActionClaudeMcp: (sessionId) => hostActionMcp.createClaudeSdkMcp(sessionId),
94729
95297
  // Codex / ACP / OpenCode: loopback HTTP with per-session HMAC.