@super-one/cli 0.63.0-alpha → 0.63.0

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 +650 -280
  3. package/package.json +1 -1
package/lib/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- process.env.SUPERONE_VARIANT = "alpha";
1
+ process.env.SUPERONE_VARIANT = "stable";
2
2
  import { createRequire as __superoneCreateRequire } from 'node:module';
3
3
  import { fileURLToPath as __superoneFileURLToPath } from 'node:url';
4
4
  import { dirname as __superoneDirname } from 'node:path';
@@ -2862,27 +2862,6 @@ var init_host_action_superone_descriptors = __esm({
2862
2862
  "additionalProperties": false
2863
2863
  }
2864
2864
  },
2865
- {
2866
- "name": "mobile_share_file",
2867
- "description": "Share a file from the desktop to the mobile device that is currently viewing this session, so the user can open or save it on their phone. This tool is ONLY available while a mobile device is subscribed to the session \u2014 if it is not in your tool list, no phone is connected. The file is delivered end-to-end encrypted and appears as a file card in the mobile chat. The path MUST point to a file inside the current project directory. Use it when the user asks to send, share, or get a file onto their phone.",
2868
- "inputSchema": {
2869
- "type": "object",
2870
- "properties": {
2871
- "path": {
2872
- "type": "string",
2873
- "description": "Path to the file to send. Absolute, or relative to the project directory. Must resolve inside the project."
2874
- },
2875
- "caption": {
2876
- "type": "string",
2877
- "description": "Optional short note shown next to the file on the phone."
2878
- }
2879
- },
2880
- "required": [
2881
- "path"
2882
- ],
2883
- "additionalProperties": false
2884
- }
2885
- },
2886
2865
  {
2887
2866
  "name": "device_list",
2888
2867
  "description": "Browse the devices this machine can offer, one tier at a time. No arguments: what is running, what this project used before, and which kinds exist. kind: its models. model: its devices, one per runtime, with ids. Prefer a running or recent one \u2014 attaching is instant, a cold boot costs ~20s. Free: it grants nothing and boots nothing.",
@@ -8142,12 +8121,14 @@ function resolveMappedClaudeModelId(model, env) {
8142
8121
  if (!model || !hasOneM(model)) return model;
8143
8122
  return hasProviderModelMappingEnv(env) ? stripOneM(model) : model;
8144
8123
  }
8145
- var SESSION_AGENT_LAUNCHES_FIELD, SESSION_AGENT_TASK_MAX, CODEX_PERMISSION_PRESETS, DEFAULT_CODEX_PERMISSION_PRESET, DEFAULT_CODEX_PERMISSION_PROFILE, MODEL_BUCKETS, BUCKET_ENV_KEYS, ONE_M_SUFFIX, MODEL_MAPPING_ENV_IDS;
8124
+ var SESSION_AGENT_LAUNCHES_FIELD, SESSION_AGENT_TASK_MAX, DEFAULT_CONTEXT_WINDOW, CODEX_GPT_5_6_CONTEXT_WINDOW, CODEX_PERMISSION_PRESETS, DEFAULT_CODEX_PERMISSION_PRESET, DEFAULT_CODEX_PERMISSION_PROFILE, MODEL_BUCKETS, BUCKET_ENV_KEYS, ONE_M_SUFFIX, MODEL_MAPPING_ENV_IDS;
8146
8125
  var init_agent_types = __esm({
8147
8126
  "../../packages/shared/src/agent-types.ts"() {
8148
8127
  "use strict";
8149
8128
  SESSION_AGENT_LAUNCHES_FIELD = "sessionAgentLaunchesJson";
8150
8129
  SESSION_AGENT_TASK_MAX = 1e5;
8130
+ DEFAULT_CONTEXT_WINDOW = 2e5;
8131
+ CODEX_GPT_5_6_CONTEXT_WINDOW = 272e3;
8151
8132
  CODEX_PERMISSION_PRESETS = {
8152
8133
  "read-only": {
8153
8134
  approvalPolicy: "on-request",
@@ -19971,7 +19952,7 @@ Prefer SuperOne's built-in tools unless the user explicitly requests another too
19971
19952
  Response rendering:
19972
19953
  - Prefer widget_show over plain Markdown for visual, data-heavy, or interactive content. For Mermaid diagrams, use fenced \`\`\`mermaid blocks; SuperOne renders them natively.
19973
19954
  - Math: use LaTeX with $$...$$ for inline formulas, or place the opening and closing $$ on separate lines for display equations. SuperOne renders math with KaTeX. Do not use single-dollar delimiters or wrap formulas in code blocks.
19974
- - Reference project files with Markdown links using absolute paths. Add :N or #LN for a line, e.g. [file.ts](/abs/path/file.ts:42).
19955
+ - Reference project files with Markdown links using absolute paths. Add :N or #LN for a line, e.g. [file.ts](/abs/path/file.ts:42). Such links render as tappable file chips on the desktop and on the user's phone, where opening one previews the file and lets the user save or share it \u2014 there is no separate tool for sending a file to a phone; link it.
19975
19956
  - Images: use ![description](/abs/path/image.png) to display an inline image.
19976
19957
  - Videos: use ![description](/abs/path/video.mp4) to display an inline video player.
19977
19958
  - Audio: use ![description](/abs/path/audio.mp3) to display an inline audio player.
@@ -22059,7 +22040,6 @@ var init_src = __esm({
22059
22040
  // ../../packages/shared/src/superone-host-owned-tools.ts
22060
22041
  function isStaticHostOwnedSuperoneBareName(bare) {
22061
22042
  if (BUILT_IN_SUPERONE_TOOL_NAMES.includes(bare)) return true;
22062
- if (bare === MOBILE_SHARE_FILE_TOOL_NAME) return true;
22063
22043
  if (bare === MINIAPP_LIST_BARE_NAME) return true;
22064
22044
  if (bare === MINIAPP_CALL_BARE_NAME) return true;
22065
22045
  return false;
@@ -22072,7 +22052,7 @@ function isStaticHostOwnedSuperoneToolQualified(qualifiedName) {
22072
22052
  function isNeverAutoAllowSuperoneBareName(bare) {
22073
22053
  return NEVER_AUTO_ALLOW_SUPERONE_BARE_NAMES.includes(bare);
22074
22054
  }
22075
- 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, NEVER_AUTO_ALLOW_SUPERONE_BARE_NAMES, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
22055
+ 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, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME, NEVER_AUTO_ALLOW_SUPERONE_BARE_NAMES, STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES;
22076
22056
  var init_superone_host_owned_tools = __esm({
22077
22057
  "../../packages/shared/src/superone-host-owned-tools.ts"() {
22078
22058
  "use strict";
@@ -22187,13 +22167,11 @@ var init_superone_host_owned_tools = __esm({
22187
22167
  ...BROWSER_TOOL_NAMES,
22188
22168
  ...DEVICE_AGENT_TOOL_NAMES
22189
22169
  ];
22190
- MOBILE_SHARE_FILE_TOOL_NAME = "mobile_share_file";
22191
22170
  MINIAPP_LIST_BARE_NAME = "miniapp_list";
22192
22171
  MINIAPP_CALL_BARE_NAME = "miniapp_call";
22193
22172
  NEVER_AUTO_ALLOW_SUPERONE_BARE_NAMES = ["browser_tools_call"];
22194
22173
  STATIC_HOST_OWNED_SUPERONE_QUALIFIED_TOOL_NAMES = [
22195
22174
  ...BUILT_IN_SUPERONE_TOOL_NAMES,
22196
- MOBILE_SHARE_FILE_TOOL_NAME,
22197
22175
  MINIAPP_LIST_BARE_NAME,
22198
22176
  MINIAPP_CALL_BARE_NAME
22199
22177
  ].filter((bare) => !isNeverAutoAllowSuperoneBareName(bare)).map((bare) => `${MCP_SUPERONE_TOOL_PREFIX}${bare}`);
@@ -24006,6 +23984,12 @@ var init_src2 = __esm({
24006
23984
  });
24007
23985
 
24008
23986
  // ../../packages/shared/src/content-delta.ts
23987
+ function isToolResultBlock(block) {
23988
+ return block.type === "tool_result" || block.type === "bash_result" || block.type === "todo_result";
23989
+ }
23990
+ function isToolUseBlock(block) {
23991
+ return "toolName" in block;
23992
+ }
24009
23993
  function parseInputObject(input) {
24010
23994
  if (input == null || input === "") return {};
24011
23995
  if (typeof input === "object" && !Array.isArray(input)) {
@@ -24067,7 +24051,7 @@ function lastMergeTargetIndex(content, delta) {
24067
24051
  for (let i = content.length - 1; i >= 0; i--) {
24068
24052
  const b3 = content[i];
24069
24053
  if (!sameParent(b3, delta)) continue;
24070
- if (b3.type === "tool_result") continue;
24054
+ if (isToolResultBlock(b3) && content.some((c) => isToolUseBlock(c) && c.toolUseId === b3.toolUseId)) continue;
24071
24055
  return i;
24072
24056
  }
24073
24057
  return -1;
@@ -24087,11 +24071,11 @@ function applyContentDelta(content, delta, now = Date.now) {
24087
24071
  return content.map((b3, i) => i === idx ? { ...target, thinking: target.thinking + delta.thinking, endedAt: delta.endedAt ?? target.endedAt } : b3);
24088
24072
  }
24089
24073
  }
24090
- if (delta.type === "tool_use") {
24091
- const idx = content.findIndex((b3) => b3.type === "tool_use" && b3.toolUseId === delta.toolUseId);
24074
+ if (isToolUseBlock(delta)) {
24075
+ const idx = content.findIndex((b3) => isToolUseBlock(b3) && b3.toolUseId === delta.toolUseId);
24092
24076
  if (idx !== -1) {
24093
24077
  const existing = content[idx];
24094
- if (existing.type !== "tool_use") {
24078
+ if (!isToolUseBlock(existing)) {
24095
24079
  return content.map((b3, i) => i === idx ? { ...delta, startedAt: now() } : b3);
24096
24080
  }
24097
24081
  const mergedInput = mergeToolUseInputJson(existing.input, delta.input);
@@ -24114,9 +24098,9 @@ function applyContentDelta(content, delta, now = Date.now) {
24114
24098
  }
24115
24099
  return [...content, { ...delta, startedAt: now() }];
24116
24100
  }
24117
- if (delta.type === "tool_result") {
24101
+ if (isToolResultBlock(delta)) {
24118
24102
  const updated = content.map(
24119
- (b3) => b3.type === "tool_use" && b3.toolUseId === delta.toolUseId ? { ...b3, status: "complete" } : b3
24103
+ (b3) => isToolUseBlock(b3) && b3.toolUseId === delta.toolUseId ? { ...b3, status: "complete" } : b3
24120
24104
  );
24121
24105
  return [...updated, delta];
24122
24106
  }
@@ -60984,9 +60968,175 @@ var init_cursor_mcp_map = __esm({
60984
60968
  }
60985
60969
  });
60986
60970
 
60971
+ // ../../packages/cursor/src/cursor-interactions.ts
60972
+ function buildCursorAskUserQuestionRequest(requestId, args) {
60973
+ const { maxQuestions, minOptions, maxOptions } = CURSOR_QUESTION_LIMITS;
60974
+ const rec = args && typeof args === "object" && !Array.isArray(args) ? args : null;
60975
+ if (!rec || !Array.isArray(rec.questions)) return { ok: false, error: "`questions` must be an array." };
60976
+ if (rec.questions.length === 0) return { ok: false, error: "Provide at least one question." };
60977
+ if (rec.questions.length > maxQuestions) {
60978
+ return { ok: false, error: `Ask at most ${maxQuestions} questions per call (got ${rec.questions.length}).` };
60979
+ }
60980
+ const questions = [];
60981
+ for (const [index, raw] of rec.questions.entries()) {
60982
+ const at2 = `questions[${index}]`;
60983
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ok: false, error: `${at2} must be an object.` };
60984
+ const row = raw;
60985
+ const question = typeof row.question === "string" ? row.question.trim() : "";
60986
+ if (!question) return { ok: false, error: `${at2}.question must be a non-empty string.` };
60987
+ if (!Array.isArray(row.options)) return { ok: false, error: `${at2}.options must be an array.` };
60988
+ if (row.options.length < minOptions || row.options.length > maxOptions) {
60989
+ return { ok: false, error: `${at2}.options must contain ${minOptions}\u2013${maxOptions} options (got ${row.options.length}).` };
60990
+ }
60991
+ const options = [];
60992
+ for (const [optIndex, opt] of row.options.entries()) {
60993
+ const optAt = `${at2}.options[${optIndex}]`;
60994
+ if (!opt || typeof opt !== "object" || Array.isArray(opt)) return { ok: false, error: `${optAt} must be an object.` };
60995
+ const o = opt;
60996
+ const label = typeof o.label === "string" ? o.label.trim() : "";
60997
+ if (!label) return { ok: false, error: `${optAt}.label must be a non-empty string.` };
60998
+ options.push({ label, description: typeof o.description === "string" ? o.description : "" });
60999
+ }
61000
+ questions.push({
61001
+ question,
61002
+ header: typeof row.header === "string" && row.header.trim() ? row.header.trim() : question.slice(0, 12),
61003
+ options,
61004
+ multiSelect: row.multiSelect === true
61005
+ });
61006
+ }
61007
+ return { ok: true, request: { requestId, questions } };
61008
+ }
61009
+ function questionNotes(annotations) {
61010
+ const notes = {};
61011
+ for (const [question, annotation] of Object.entries(annotations ?? {})) {
61012
+ const text = annotation?.notes?.trim();
61013
+ if (text) notes[question] = text;
61014
+ }
61015
+ return notes;
61016
+ }
61017
+ function formatCursorQuestionResult(answer) {
61018
+ if (answer.kind === "answered") {
61019
+ const answers = {};
61020
+ for (const [key, value] of Object.entries(answer.answers)) {
61021
+ if (value) answers[key] = value;
61022
+ }
61023
+ const notes = questionNotes(answer.annotations);
61024
+ return { outcome: "answered", answers, ...Object.keys(notes).length > 0 ? { notes } : {} };
61025
+ }
61026
+ if (answer.kind === "dismissed") {
61027
+ return {
61028
+ outcome: "dismissed",
61029
+ note: "The user dismissed the question without answering. This is not approval. If the answer is required for the requested action, stop and say what you still need; otherwise continue only with work that does not depend on it."
61030
+ };
61031
+ }
61032
+ return { outcome: "cancelled", reason: answer.reason };
61033
+ }
61034
+ function isCursorQuestionTool(toolName) {
61035
+ return toolName === CURSOR_ASK_USER_QUESTION_TOOL || toolName === `mcp__${CURSOR_CUSTOM_TOOLS_SERVER}__${CURSOR_ASK_USER_QUESTION_TOOL}`;
61036
+ }
61037
+ function asRecord13(value) {
61038
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
61039
+ }
61040
+ function unwrapCursorHostToolResult(result) {
61041
+ const rec = asRecord13(result);
61042
+ if (!rec || !Array.isArray(rec.content)) return { payload: result, isError: false };
61043
+ const isError = rec.isError === true;
61044
+ const structured = asRecord13(rec.structuredContent);
61045
+ if (structured) return { payload: structured, isError };
61046
+ const first = asRecord13(rec.content[0]);
61047
+ const nestedText = asRecord13(first?.text);
61048
+ const text = typeof nestedText?.text === "string" ? nestedText.text : typeof first?.text === "string" ? first.text : "";
61049
+ if (!text) return { payload: void 0, isError };
61050
+ try {
61051
+ return { payload: JSON.parse(text), isError };
61052
+ } catch {
61053
+ return { payload: text, isError };
61054
+ }
61055
+ }
61056
+ function cursorQuestionToolPresentation(args, result) {
61057
+ const rec = asRecord13(args) ?? {};
61058
+ const questions = Array.isArray(rec.questions) ? rec.questions : [];
61059
+ const { payload, isError } = unwrapCursorHostToolResult(result);
61060
+ if (isError) {
61061
+ return { input: { questions }, summary: typeof payload === "string" ? payload : null, isError };
61062
+ }
61063
+ const res = asRecord13(payload);
61064
+ const outcome = typeof res?.outcome === "string" ? res.outcome : null;
61065
+ if (outcome === "answered" && asRecord13(res?.answers)) {
61066
+ const answers = res.answers;
61067
+ const notes = asRecord13(res.notes);
61068
+ const annotations = {};
61069
+ for (const [question, text] of Object.entries(notes ?? {})) {
61070
+ if (typeof text === "string") annotations[question] = { notes: text };
61071
+ }
61072
+ return {
61073
+ input: buildAnsweredQuestionInput({ questions, answers, annotations }),
61074
+ summary: Object.entries(answers).map(([q2, a]) => `"${q2}"="${a}"`).join(", ") || null,
61075
+ isError: false
61076
+ };
61077
+ }
61078
+ if (outcome === "dismissed") return { input: { questions }, summary: "User dismissed the question without answering.", isError: false };
61079
+ if (outcome === "cancelled") {
61080
+ return { input: { questions }, summary: `Question cancelled: ${typeof res?.reason === "string" ? res.reason : "turn ended"}.`, isError: false };
61081
+ }
61082
+ return { input: { questions }, summary: null, isError: false };
61083
+ }
61084
+ function buildCursorPlanApprovalRequest(requestId, args) {
61085
+ const rec = args && typeof args === "object" ? args : {};
61086
+ const plan = typeof rec.plan === "string" ? rec.plan.trim() : "";
61087
+ if (!plan) return null;
61088
+ return { requestId, planContent: plan, planFilePath: "", allowedPrompts: [] };
61089
+ }
61090
+ var CURSOR_ASK_USER_QUESTION_TOOL, CURSOR_QUESTION_LIMITS, CURSOR_ASK_USER_QUESTION_SCHEMA, CURSOR_CUSTOM_TOOLS_SERVER;
61091
+ var init_cursor_interactions = __esm({
61092
+ "../../packages/cursor/src/cursor-interactions.ts"() {
61093
+ "use strict";
61094
+ init_ask_user_question();
61095
+ CURSOR_ASK_USER_QUESTION_TOOL = "superone_ask_user_question";
61096
+ CURSOR_QUESTION_LIMITS = { maxQuestions: 4, minOptions: 2, maxOptions: 4 };
61097
+ CURSOR_ASK_USER_QUESTION_SCHEMA = {
61098
+ type: "object",
61099
+ properties: {
61100
+ questions: {
61101
+ type: "array",
61102
+ minItems: 1,
61103
+ maxItems: CURSOR_QUESTION_LIMITS.maxQuestions,
61104
+ items: {
61105
+ type: "object",
61106
+ properties: {
61107
+ question: { type: "string", description: "The question to ask the user." },
61108
+ header: { type: "string", description: "Short label (\u2264 12 chars) shown as the question chip." },
61109
+ options: {
61110
+ type: "array",
61111
+ minItems: CURSOR_QUESTION_LIMITS.minOptions,
61112
+ maxItems: CURSOR_QUESTION_LIMITS.maxOptions,
61113
+ items: {
61114
+ type: "object",
61115
+ properties: {
61116
+ label: { type: "string" },
61117
+ description: { type: "string" }
61118
+ },
61119
+ required: ["label"],
61120
+ additionalProperties: false
61121
+ }
61122
+ },
61123
+ multiSelect: { type: "boolean", description: "Allow more than one option to be selected." }
61124
+ },
61125
+ required: ["question", "options"],
61126
+ additionalProperties: false
61127
+ }
61128
+ }
61129
+ },
61130
+ required: ["questions"],
61131
+ additionalProperties: false
61132
+ };
61133
+ CURSOR_CUSTOM_TOOLS_SERVER = "custom-user-tools";
61134
+ }
61135
+ });
61136
+
60987
61137
  // ../../packages/cursor/src/cursor-custom-tools.ts
60988
61138
  function buildCursorCustomTools(ctx) {
60989
- return {
61139
+ const tools = {
60990
61140
  superone_session_info: {
60991
61141
  description: "Return SuperOne host session metadata (session id, project cwd). Prefer SuperOne MCP tools for project actions.",
60992
61142
  inputSchema: {
@@ -61001,10 +61151,31 @@ function buildCursorCustomTools(ctx) {
61001
61151
  })
61002
61152
  }
61003
61153
  };
61154
+ const askUser = ctx.askUser;
61155
+ if (askUser) {
61156
+ tools[CURSOR_ASK_USER_QUESTION_TOOL] = {
61157
+ description: "Ask the user one to four multiple-choice questions and wait for the answer. Use it whenever you need a decision, clarification or preference from the user before continuing. The built-in askQuestion tool is not available in this host; use this tool instead.",
61158
+ inputSchema: CURSOR_ASK_USER_QUESTION_SCHEMA,
61159
+ execute: async (args, context) => {
61160
+ const requestId = context.toolCallId || `cursor_ask_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
61161
+ const parsed = buildCursorAskUserQuestionRequest(requestId, args);
61162
+ if (!parsed.ok) {
61163
+ return {
61164
+ content: [{ type: "text", text: `Invalid input: ${parsed.error}` }],
61165
+ isError: true
61166
+ };
61167
+ }
61168
+ const answer = await askUser(parsed.request);
61169
+ return formatCursorQuestionResult(answer);
61170
+ }
61171
+ };
61172
+ }
61173
+ return tools;
61004
61174
  }
61005
61175
  var init_cursor_custom_tools = __esm({
61006
61176
  "../../packages/cursor/src/cursor-custom-tools.ts"() {
61007
61177
  "use strict";
61178
+ init_cursor_interactions();
61008
61179
  }
61009
61180
  });
61010
61181
 
@@ -61033,7 +61204,7 @@ function toolDisplayName(name) {
61033
61204
  }
61034
61205
  function unwrapCursorMcpTool(toolType, args) {
61035
61206
  if (toolType.toLowerCase() !== "mcp") return { toolType, args };
61036
- const rec = asRecord13(args);
61207
+ const rec = asRecord14(args);
61037
61208
  if (!rec) return { toolType, args };
61038
61209
  const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
61039
61210
  const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
@@ -61059,12 +61230,12 @@ function idField(obj, ...keys) {
61059
61230
  return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
61060
61231
  }
61061
61232
  function extractCursorCallId(update) {
61062
- const rec = asRecord13(update);
61233
+ const rec = asRecord14(update);
61063
61234
  if (!rec) return null;
61064
- const nested = asRecord13(rec.toolCall) ?? asRecord13(rec.message);
61235
+ const nested = asRecord14(rec.toolCall) ?? asRecord14(rec.message);
61065
61236
  return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
61066
61237
  }
61067
- function asRecord13(value) {
61238
+ function asRecord14(value) {
61068
61239
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
61069
61240
  return value;
61070
61241
  }
@@ -61078,13 +61249,13 @@ function stringifyPayload(value) {
61078
61249
  }
61079
61250
  }
61080
61251
  function extractToolCallParts(update) {
61081
- const rec = asRecord13(update) ?? {};
61252
+ const rec = asRecord14(update) ?? {};
61082
61253
  const callId = extractCursorCallId(update);
61083
- const nested = asRecord13(rec.toolCall);
61254
+ const nested = asRecord14(rec.toolCall);
61084
61255
  if (nested) {
61085
61256
  const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
61086
61257
  const result = nested.result;
61087
- const resultRec = asRecord13(result);
61258
+ const resultRec = asRecord14(result);
61088
61259
  const isError = resultRec?.status === "error" || Boolean(rec.isError);
61089
61260
  return {
61090
61261
  callId,
@@ -61108,7 +61279,7 @@ function mapTodosPayload(todos) {
61108
61279
  return {
61109
61280
  type: "todos_updated",
61110
61281
  todos: todos.map((todo, index) => {
61111
- const row = asRecord13(todo) ?? {};
61282
+ const row = asRecord14(todo) ?? {};
61112
61283
  const statusRaw = String(row.status ?? "pending");
61113
61284
  return {
61114
61285
  id: String(row.id ?? index + 1),
@@ -61119,8 +61290,21 @@ function mapTodosPayload(todos) {
61119
61290
  })
61120
61291
  };
61121
61292
  }
61122
- function toolUseEvent(messageId, callId, toolType, args, status) {
61123
- const unwrapped = unwrapCursorMcpTool(toolType, args);
61293
+ function canonicalizeCursorHostTool(toolType, args, result) {
61294
+ if (!isCursorQuestionTool(toolType)) return { toolType, args };
61295
+ const shaped = cursorQuestionToolPresentation(args, result);
61296
+ return {
61297
+ toolType: "AskUserQuestion",
61298
+ args: shaped.input,
61299
+ ...shaped.summary ? { resultSummary: shaped.summary } : {},
61300
+ // The SDK keeps the outer status `success` for a rejected custom-tool call;
61301
+ // the real flag lives inside the MCP envelope.
61302
+ ...shaped.isError ? { resultIsError: true } : {}
61303
+ };
61304
+ }
61305
+ function toolUseEvent(messageId, callId, toolType, args, status, result) {
61306
+ const mcp = unwrapCursorMcpTool(toolType, args);
61307
+ const unwrapped = canonicalizeCursorHostTool(mcp.toolType, mcp.args, result);
61124
61308
  const toolName = toolDisplayName(unwrapped.toolType);
61125
61309
  return {
61126
61310
  type: "content_delta",
@@ -61137,15 +61321,15 @@ function toolUseEvent(messageId, callId, toolType, args, status) {
61137
61321
  }
61138
61322
  function normalizeCursorToolInput(toolName, args) {
61139
61323
  if (toolName.startsWith("mcp__")) return args;
61140
- const rec = asRecord13(args);
61324
+ const rec = asRecord14(args);
61141
61325
  if (!rec) return args ?? {};
61142
61326
  return normalizeTranscriptTool(toolName, rec).input;
61143
61327
  }
61144
61328
  function mergeCursorToolResultArgs(toolType, args, result) {
61145
61329
  if (toolType.toLowerCase() === "mcp") return args;
61146
- const res = asRecord13(result);
61330
+ const res = asRecord14(result);
61147
61331
  if (!res) return args;
61148
- const rec = asRecord13(args);
61332
+ const rec = asRecord14(args);
61149
61333
  if (!rec) return args;
61150
61334
  const diff = typeof res.diffString === "string" ? res.diffString : void 0;
61151
61335
  const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
@@ -61167,32 +61351,30 @@ function mergeCursorToolResultArgs(toolType, args, result) {
61167
61351
  }
61168
61352
  return changed ? next : rec;
61169
61353
  }
61170
- function toolResultEvent(messageId, callId, result, isError) {
61354
+ function toolResultEvent(messageId, callId, result, isError, toolType, args) {
61355
+ const host = toolType != null ? canonicalizeCursorHostTool(unwrapCursorMcpTool(toolType, args).toolType, args, result) : null;
61171
61356
  return {
61172
61357
  type: "content_delta",
61173
61358
  messageId,
61174
61359
  delta: {
61175
61360
  type: "tool_result",
61176
61361
  toolUseId: callId,
61177
- summary: formatTranscriptToolResult(result) || stringifyPayload(result),
61178
- isError
61362
+ summary: host?.resultSummary ?? (formatTranscriptToolResult(result) || stringifyPayload(result)),
61363
+ isError: isError || host?.resultIsError === true
61179
61364
  }
61180
61365
  };
61181
61366
  }
61182
- function contextTokensFromUsage(usage2) {
61183
- return usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens;
61367
+ function estimateTokens(text) {
61368
+ if (!text) return 0;
61369
+ const nonAscii = text.match(NON_ASCII_RE)?.length ?? 0;
61370
+ return (text.length - nonAscii) / ASCII_CHARS_PER_TOKEN + nonAscii / NON_ASCII_CHARS_PER_TOKEN;
61184
61371
  }
61185
- function mapCursorTokenUsage(messageId, usage2, extras) {
61186
- const contextTokens = extras?.contextTokens && extras.contextTokens > 0 ? extras.contextTokens : contextTokensFromUsage(usage2);
61187
- return {
61188
- type: "message_usage",
61189
- messageId,
61190
- inputTokens: usage2.inputTokens,
61191
- outputTokens: usage2.outputTokens,
61192
- cacheReadTokens: usage2.cacheReadTokens,
61193
- contextTokens,
61194
- ...extras?.contextWindow && extras.contextWindow > 0 ? { contextWindow: extras.contextWindow } : {}
61195
- };
61372
+ function modelCallIndexFromId(modelCallId) {
61373
+ if (typeof modelCallId !== "string") return null;
61374
+ const match = MODEL_CALL_INDEX_RE.exec(modelCallId);
61375
+ if (!match) return null;
61376
+ const index = Number(match[1]);
61377
+ return Number.isInteger(index) && index >= 0 ? index : null;
61196
61378
  }
61197
61379
  function stampParentToolUseId(events, parentToolUseId) {
61198
61380
  if (!parentToolUseId) return events;
@@ -61206,11 +61388,13 @@ function stampParentToolUseId(events, parentToolUseId) {
61206
61388
  function mapInteractionUpdate(messageId, update, options) {
61207
61389
  const events = [];
61208
61390
  const type = String(update.type ?? "");
61209
- const rec = asRecord13(update) ?? {};
61391
+ const rec = asRecord14(update) ?? {};
61392
+ const turnUsage = options?.parentToolUseId ? void 0 : options?.turnUsage;
61210
61393
  switch (type) {
61211
61394
  case "text-delta": {
61212
61395
  const text = strField2(update, "text");
61213
61396
  if (text) {
61397
+ turnUsage?.addText(text);
61214
61398
  events.push({ type: "content_delta", messageId, delta: { type: "text", text } });
61215
61399
  }
61216
61400
  break;
@@ -61244,9 +61428,10 @@ function mapInteractionUpdate(messageId, update, options) {
61244
61428
  case "partial-tool-call": {
61245
61429
  const parts = extractToolCallParts(update);
61246
61430
  if (!parts.callId) break;
61431
+ if (type === "tool-call-started") turnUsage?.observeToolCallStarted(rec.modelCallId);
61247
61432
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
61248
61433
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
61249
- const todos = asRecord13(parts.args)?.todos;
61434
+ const todos = asRecord14(parts.args)?.todos;
61250
61435
  const todoEvent = mapTodosPayload(todos);
61251
61436
  if (todoEvent) events.push(todoEvent);
61252
61437
  }
@@ -61279,11 +61464,16 @@ function mapInteractionUpdate(messageId, update, options) {
61279
61464
  case "tool-call-completed": {
61280
61465
  const parts = extractToolCallParts(update);
61281
61466
  if (!parts.callId) break;
61467
+ turnUsage?.observeToolCallCompleted(
61468
+ rec.modelCallId,
61469
+ stringifyPayload(parts.args),
61470
+ stringifyPayload(parts.result)
61471
+ );
61282
61472
  const args = mergeCursorToolResultArgs(parts.toolType, parts.args, parts.result);
61283
- events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
61284
- events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
61473
+ events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete", parts.result));
61474
+ events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError, parts.toolType, parts.args));
61285
61475
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
61286
- const todos = asRecord13(parts.args)?.todos ?? asRecord13(parts.result)?.todos;
61476
+ const todos = asRecord14(parts.args)?.todos ?? asRecord14(parts.result)?.todos;
61287
61477
  const todoEvent = mapTodosPayload(todos);
61288
61478
  if (todoEvent) events.push(todoEvent);
61289
61479
  }
@@ -61303,7 +61493,6 @@ function mapInteractionUpdate(messageId, update, options) {
61303
61493
  case "token-delta": {
61304
61494
  const tokens = Number(update.tokens);
61305
61495
  if (Number.isFinite(tokens) && tokens > 0) {
61306
- const turnUsage = options?.turnUsage;
61307
61496
  if (turnUsage) turnUsage.addTokenDelta(tokens);
61308
61497
  events.push({
61309
61498
  type: "message_usage",
@@ -61316,22 +61505,17 @@ function mapInteractionUpdate(messageId, update, options) {
61316
61505
  }
61317
61506
  case "turn-ended": {
61318
61507
  const usage2 = update.usage;
61319
- if (usage2) {
61320
- const turnUsage = options?.turnUsage;
61321
- if (turnUsage) {
61322
- turnUsage.applyInternalTurn(usage2);
61323
- events.push({
61324
- type: "message_usage",
61325
- messageId,
61326
- inputTokens: turnUsage.input,
61327
- outputTokens: turnUsage.output,
61328
- cacheReadTokens: usage2.cacheReadTokens,
61329
- contextTokens: turnUsage.context,
61330
- ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
61331
- });
61332
- } else {
61333
- events.push(mapCursorTokenUsage(messageId, usage2, { contextWindow: options?.contextWindow }));
61334
- }
61508
+ if (usage2 && turnUsage) {
61509
+ turnUsage.applyInternalTurn(usage2);
61510
+ events.push({
61511
+ type: "message_usage",
61512
+ messageId,
61513
+ inputTokens: turnUsage.input,
61514
+ outputTokens: turnUsage.output,
61515
+ cacheReadTokens: usage2.cacheReadTokens,
61516
+ contextTokens: turnUsage.context,
61517
+ ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
61518
+ });
61335
61519
  }
61336
61520
  events.push({ type: "status_change", status: "idle" });
61337
61521
  break;
@@ -61388,7 +61572,7 @@ ${text}
61388
61572
  }
61389
61573
  function mapConversationStep(messageId, step, options) {
61390
61574
  const events = [];
61391
- const rec = asRecord13(step);
61575
+ const rec = asRecord14(step);
61392
61576
  if (!rec) return events;
61393
61577
  const stepType = strField2(rec, "type");
61394
61578
  if (stepType === "assistantMessage" || stepType === "thinkingMessage") {
@@ -61396,14 +61580,14 @@ function mapConversationStep(messageId, step, options) {
61396
61580
  }
61397
61581
  if (stepType === "toolCall") {
61398
61582
  const message = rec.message ?? rec.toolCall ?? rec;
61399
- const nested = asRecord13(message);
61583
+ const nested = asRecord14(message);
61400
61584
  const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
61401
61585
  if (!callId) {
61402
61586
  return events;
61403
61587
  }
61404
61588
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
61405
61589
  const args = nested?.args ?? nested?.input ?? {};
61406
- const resultRec = asRecord13(nested?.result);
61590
+ const resultRec = asRecord14(nested?.result);
61407
61591
  const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
61408
61592
  events.push(toolUseEvent(
61409
61593
  messageId,
@@ -61413,7 +61597,7 @@ function mapConversationStep(messageId, step, options) {
61413
61597
  "complete"
61414
61598
  ));
61415
61599
  if (toolType === "updateTodos" || toolType === "update_todos") {
61416
- const todos = asRecord13(args)?.todos;
61600
+ const todos = asRecord14(args)?.todos;
61417
61601
  const todoEvent = mapTodosPayload(todos);
61418
61602
  if (todoEvent) events.push(todoEvent);
61419
61603
  }
@@ -61443,14 +61627,6 @@ function mapSdkMessageLifecycle(messageId, message, options) {
61443
61627
  break;
61444
61628
  }
61445
61629
  case "usage": {
61446
- const u2 = message.usage;
61447
- events.push(mapCursorTokenUsage(messageId, {
61448
- inputTokens: u2.inputTokens,
61449
- outputTokens: u2.outputTokens,
61450
- cacheReadTokens: u2.cacheReadTokens,
61451
- cacheWriteTokens: u2.cacheWriteTokens,
61452
- reasoningTokens: u2.reasoningTokens
61453
- }, { contextWindow: options?.contextWindow }));
61454
61630
  break;
61455
61631
  }
61456
61632
  case "thinking": {
@@ -61512,36 +61688,167 @@ function mapToolCallMessage(messageId, message) {
61512
61688
  const status = message.status === "completed" || message.status === "error" ? "complete" : "streaming";
61513
61689
  const args = status === "complete" ? mergeCursorToolResultArgs(message.name, message.args, message.result) : message.args;
61514
61690
  const events = [
61515
- toolUseEvent(messageId, message.call_id, message.name, args, status)
61691
+ toolUseEvent(messageId, message.call_id, message.name, args, status, status === "complete" ? message.result : void 0)
61516
61692
  ];
61517
61693
  if (message.status === "completed" || message.status === "error") {
61518
- events.push(toolResultEvent(messageId, message.call_id, message.result, message.status === "error"));
61694
+ events.push(toolResultEvent(messageId, message.call_id, message.result, message.status === "error", message.name, message.args));
61519
61695
  }
61520
61696
  return events;
61521
61697
  }
61522
- var TOOL_CALL_ID_KEYS, CursorTurnUsage, CursorTurnCallIdBridge;
61698
+ var TOOL_CALL_ID_KEYS, ASCII_CHARS_PER_TOKEN, NON_ASCII_CHARS_PER_TOKEN, NON_ASCII_RE, CHAIN_ALPHA_MIN, CHAIN_ALPHA_MAX, CHAIN_ZERO_TOLERANCE, MODEL_CALL_INDEX_RE, CursorTurnUsage, CursorTurnCallIdBridge;
61523
61699
  var init_cursor_event_map = __esm({
61524
61700
  "../../packages/cursor/src/cursor-event-map.ts"() {
61525
61701
  "use strict";
61526
61702
  init_agent_error();
61527
61703
  init_tool_ui();
61704
+ init_cursor_interactions();
61528
61705
  TOOL_CALL_ID_KEYS = ["callId", "toolCallId", "call_id"];
61706
+ ASCII_CHARS_PER_TOKEN = 3.5;
61707
+ NON_ASCII_CHARS_PER_TOKEN = 1.5;
61708
+ NON_ASCII_RE = /[^\x00-\x7f]/g;
61709
+ CHAIN_ALPHA_MIN = 0.4;
61710
+ CHAIN_ALPHA_MAX = 2.5;
61711
+ CHAIN_ZERO_TOLERANCE = 0.02;
61712
+ MODEL_CALL_INDEX_RE = /-(\d+)-[^-]+$/;
61529
61713
  CursorTurnUsage = class {
61530
- input = 0;
61714
+ input;
61531
61715
  output = 0;
61716
+ /** Estimated context occupancy after this turn (0 until `turn-ended`). */
61532
61717
  context = 0;
61718
+ /** How the last `applyInternalTurn` arrived at `context`; for logs and tests. */
61719
+ lastEstimate = null;
61720
+ promptTokens;
61721
+ previousOccupancy;
61722
+ /** Tokens appended by each model call, indexed by model-call index. */
61723
+ calls = [];
61724
+ /** Text streamed since the last tool call; belongs to the next call seen. */
61725
+ pendingTextTokens = 0;
61726
+ currentCallIndex = 0;
61727
+ sawToolCallComplete = false;
61728
+ /**
61729
+ * @param prompt Full prompt text sent this turn (host context included).
61730
+ * @param previousOccupancy Occupancy after the previous turn, 0 when unknown.
61731
+ */
61732
+ constructor(prompt = "", previousOccupancy = 0) {
61733
+ this.promptTokens = Math.round(estimateTokens(prompt));
61734
+ this.previousOccupancy = Number.isFinite(previousOccupancy) && previousOccupancy > 0 ? previousOccupancy : 0;
61735
+ this.input = this.promptTokens;
61736
+ }
61533
61737
  addTokenDelta(tokens) {
61534
61738
  if (Number.isFinite(tokens) && tokens > 0) this.output += tokens;
61535
61739
  }
61740
+ /** Streamed assistant text (thinking is not re-sent to the model, skip it). */
61741
+ addText(text) {
61742
+ this.pendingTextTokens += estimateTokens(text);
61743
+ }
61744
+ /** A tool call was issued: the text streamed before it belongs to the same model call. */
61745
+ observeToolCallStarted(modelCallId) {
61746
+ const index = this.resolveCallIndex(modelCallId, true);
61747
+ this.callAt(index).out += this.pendingTextTokens;
61748
+ this.pendingTextTokens = 0;
61749
+ }
61750
+ /**
61751
+ * A tool call finished: its final args (model output) and result (input-side
61752
+ * growth for the next call) both land in the context.
61753
+ */
61754
+ observeToolCallCompleted(modelCallId, args, result) {
61755
+ const index = this.resolveCallIndex(modelCallId, false);
61756
+ const call = this.callAt(index);
61757
+ const resultTokens = estimateTokens(result);
61758
+ call.out += estimateTokens(args);
61759
+ call.result += resultTokens;
61760
+ this.sawToolCallComplete = true;
61761
+ this.input += Math.round(resultTokens);
61762
+ }
61536
61763
  applyInternalTurn(usage2) {
61537
- this.input += usage2.inputTokens;
61538
61764
  if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
61539
- this.context = contextTokensFromUsage(usage2);
61765
+ const outputText = Math.max(0, usage2.outputTokens - (usage2.reasoningTokens ?? 0));
61766
+ const estimate = this.estimateOccupancy(usage2.inputTokens, outputText);
61767
+ this.lastEstimate = estimate;
61768
+ this.context = estimate.occupancy;
61769
+ this.input = estimate.inputGrowth;
61540
61770
  }
61771
+ /** Run totals only refine output; billed input never reaches the footer. */
61541
61772
  applyRunTotals(usage2) {
61542
- if (usage2.inputTokens > this.input) this.input = usage2.inputTokens;
61543
61773
  if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
61544
61774
  }
61775
+ /**
61776
+ * Solve the occupancy the *next* prompt will carry.
61777
+ *
61778
+ * @param inputTokens Cursor's summed prompt tokens for this run (exact).
61779
+ * @param outputText Exact output tokens that stay in context (0 when unknown).
61780
+ */
61781
+ estimateOccupancy(inputTokens, outputText = 0) {
61782
+ const calls = this.calls.map((call) => ({ out: call.out, result: call.result }));
61783
+ if (this.pendingTextTokens > 0 || calls.length === 0) {
61784
+ calls.push({ out: this.pendingTextTokens, result: 0 });
61785
+ }
61786
+ const n = calls.length;
61787
+ let estimatedOut = 0;
61788
+ let totalResult = 0;
61789
+ for (const call of calls) {
61790
+ estimatedOut += call.out;
61791
+ totalResult += call.result;
61792
+ }
61793
+ const beta = outputText > 0 && estimatedOut > 0 ? outputText / estimatedOut : 1;
61794
+ const retainedOutput = outputText > 0 ? outputText : estimatedOut;
61795
+ let weightedOut = 0;
61796
+ let weightedResult = 0;
61797
+ let prefixOut = 0;
61798
+ let prefixResult = 0;
61799
+ for (const call of calls) {
61800
+ weightedOut += prefixOut;
61801
+ weightedResult += prefixResult;
61802
+ prefixOut += call.out * beta;
61803
+ prefixResult += call.result;
61804
+ }
61805
+ const previous = this.previousOccupancy;
61806
+ if (previous > 0) {
61807
+ if (n === 1) {
61808
+ return {
61809
+ occupancy: Math.round(inputTokens + retainedOutput),
61810
+ inputGrowth: this.promptTokens,
61811
+ chained: true,
61812
+ alpha: 1
61813
+ };
61814
+ }
61815
+ const firstPrompt2 = previous + this.promptTokens;
61816
+ const weightedResultTrue = inputTokens - n * firstPrompt2 - weightedOut;
61817
+ const alpha = weightedResult > 0 ? weightedResultTrue / weightedResult : Math.abs(weightedResultTrue) <= CHAIN_ZERO_TOLERANCE * inputTokens ? 1 : Number.NaN;
61818
+ if (Number.isFinite(alpha) && alpha >= CHAIN_ALPHA_MIN && alpha <= CHAIN_ALPHA_MAX) {
61819
+ return {
61820
+ occupancy: Math.round(firstPrompt2 + alpha * totalResult + retainedOutput),
61821
+ inputGrowth: Math.round(this.promptTokens + alpha * totalResult),
61822
+ chained: true,
61823
+ alpha
61824
+ };
61825
+ }
61826
+ }
61827
+ const firstPrompt = Math.max(0, (inputTokens - weightedOut - weightedResult) / n);
61828
+ return {
61829
+ occupancy: Math.round(firstPrompt + totalResult + retainedOutput),
61830
+ inputGrowth: this.input,
61831
+ chained: false,
61832
+ alpha: 1
61833
+ };
61834
+ }
61835
+ resolveCallIndex(modelCallId, isStart) {
61836
+ const parsed = modelCallIndexFromId(modelCallId);
61837
+ if (parsed != null) {
61838
+ this.currentCallIndex = Math.max(this.currentCallIndex, parsed);
61839
+ this.sawToolCallComplete = false;
61840
+ return parsed;
61841
+ }
61842
+ if (isStart && this.sawToolCallComplete) {
61843
+ this.currentCallIndex += 1;
61844
+ this.sawToolCallComplete = false;
61845
+ }
61846
+ return this.currentCallIndex;
61847
+ }
61848
+ callAt(index) {
61849
+ while (this.calls.length <= index) this.calls.push({ out: 0, result: 0 });
61850
+ return this.calls[index];
61851
+ }
61545
61852
  };
61546
61853
  CursorTurnCallIdBridge = class {
61547
61854
  queue = [];
@@ -61550,7 +61857,7 @@ var init_cursor_event_map = __esm({
61550
61857
  observeDelta(update) {
61551
61858
  const type = String(update.type ?? "");
61552
61859
  if (type === "tool-call-delta") {
61553
- const taskUpdate = asRecord13(update)?.taskUpdate;
61860
+ const taskUpdate = asRecord14(update)?.taskUpdate;
61554
61861
  if (taskUpdate && typeof taskUpdate === "object") {
61555
61862
  this.observeDelta(taskUpdate);
61556
61863
  }
@@ -62071,13 +62378,38 @@ function parseCatalogContextWindow(raw) {
62071
62378
  const unit = match[2]?.toLowerCase();
62072
62379
  return Math.round(amount * (unit === "m" ? 1e6 : unit === "k" ? 1e3 : 1));
62073
62380
  }
62381
+ function firstParseableContextValue(values) {
62382
+ for (const item of values ?? []) {
62383
+ if (parseCatalogContextWindow(item.value) != null) return item.value;
62384
+ }
62385
+ return null;
62386
+ }
62387
+ function defaultCatalogContextWindow(modelId) {
62388
+ return modelId && GPT_5_6_MODEL_RE.test(modelId) ? CODEX_GPT_5_6_CONTEXT_WINDOW : DEFAULT_CONTEXT_WINDOW;
62389
+ }
62390
+ function selectedCatalogContextWindow(selected, model) {
62391
+ const parsed = parseCatalogContextWindow(selected);
62392
+ if (parsed != null) return parsed;
62393
+ return parseCatalogContextWindow(
62394
+ firstParseableContextValue(model?.parameters?.find((param) => param.id === "context")?.values)
62395
+ );
62396
+ }
62397
+ function resolveCatalogContextWindow(selected, model, modelId) {
62398
+ return selectedCatalogContextWindow(selected, model) ?? defaultCatalogContextWindow(modelId);
62399
+ }
62400
+ var GPT_5_6_MODEL_RE;
62074
62401
  var init_model_option_params = __esm({
62075
62402
  "../../packages/shared/src/model-option-params.ts"() {
62076
62403
  "use strict";
62404
+ init_agent_types();
62405
+ GPT_5_6_MODEL_RE = /(^|[/-])gpt-5\.6(?:$|-)/i;
62077
62406
  }
62078
62407
  });
62079
62408
 
62080
62409
  // ../../packages/cursor/src/cursor-model-selection.ts
62410
+ function resolveCursorContextWindow(selected, model, modelId) {
62411
+ return resolveCatalogContextWindow(selected, model, modelId);
62412
+ }
62081
62413
  var init_cursor_model_selection = __esm({
62082
62414
  "../../packages/cursor/src/cursor-model-selection.ts"() {
62083
62415
  "use strict";
@@ -62255,7 +62587,7 @@ function formatCursorError(error51) {
62255
62587
  }
62256
62588
  function resolveContextWindow(modelSelection) {
62257
62589
  const contextParam = modelSelection?.params?.find((p3) => p3.id === "context");
62258
- return parseCatalogContextWindow(contextParam?.value);
62590
+ return resolveCursorContextWindow(contextParam?.value, null, modelSelection?.id);
62259
62591
  }
62260
62592
  async function createCursorRuntime(opts) {
62261
62593
  const log2 = {
@@ -62296,7 +62628,13 @@ async function createCursorRuntime(opts) {
62296
62628
  const mcpServers = plan.mcpServers;
62297
62629
  const config2 = plan.config;
62298
62630
  const buildMcpServers = opts.buildMcpServers ?? (() => ({}));
62299
- const customTools = isCloud ? void 0 : buildCursorCustomTools({ sessionId: opts.sessionId, cwd: opts.cwd });
62631
+ const interactions = opts.interactions;
62632
+ const customTools = isCloud ? void 0 : buildCursorCustomTools({
62633
+ sessionId: opts.sessionId,
62634
+ cwd: opts.cwd,
62635
+ ...interactions ? { askUser: (request) => interactions.askQuestion(request) } : {}
62636
+ });
62637
+ const hostContextExtra = !isCloud && interactions ? [opts.systemPromptAppend?.trim(), CURSOR_QUESTION_TOOL_HINT].filter(Boolean).join("\n\n") : opts.systemPromptAppend;
62300
62638
  const agentName = opts.agentName?.trim() || void 0;
62301
62639
  const toolRestrictions = isCloud ? {} : resolveCursorToolRestrictions(config2);
62302
62640
  const toolsOpt = toolRestrictions.tools ? { tools: toolRestrictions.tools } : {};
@@ -62425,6 +62763,7 @@ async function createCursorRuntime(opts) {
62425
62763
  opts.onProviderSessionId?.(agent.agentId);
62426
62764
  opts.onEvent({ type: "provider_session_id", providerSessionId: agent.agentId });
62427
62765
  let currentRun = null;
62766
+ let activeCancelToken = null;
62428
62767
  let lastRunId = null;
62429
62768
  let modelSelection = model;
62430
62769
  let permissionMode = opts.permissionMode;
@@ -62470,7 +62809,7 @@ async function createCursorRuntime(opts) {
62470
62809
  if (disposed) throw new Error("Cursor runtime disposed");
62471
62810
  const permLocal = mapPermissionToCursorLocal(permissionMode);
62472
62811
  const includeHostContext = !hostContextSent && !text.trimStart().startsWith("/");
62473
- const prompt = includeHostContext ? `${superoneHostContext(opts.systemPromptAppend)}
62812
+ const prompt = includeHostContext ? `${superoneHostContext(hostContextExtra)}
62474
62813
 
62475
62814
  ${text}` : text;
62476
62815
  const userMessage2 = sendOpts?.images?.length ? {
@@ -62484,7 +62823,10 @@ ${text}` : text;
62484
62823
  lastMcpServers = servers;
62485
62824
  const contextWindow = resolveContextWindow(modelSelection);
62486
62825
  const callIdBridge = new CursorTurnCallIdBridge();
62487
- const turnUsage = new CursorTurnUsage();
62826
+ const turnUsage = new CursorTurnUsage(prompt, sendOpts?.previousContextTokens ?? 0);
62827
+ const completedPlan = { current: null };
62828
+ const cancelToken = { cancelled: false };
62829
+ activeCancelToken = cancelToken;
62488
62830
  const sendStarted = Date.now();
62489
62831
  log2.info("[CursorRuntime] send start", { messageId });
62490
62832
  tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
@@ -62504,6 +62846,12 @@ ${text}` : text;
62504
62846
  for (const event of mapInteractionUpdate(messageId, update, { contextWindow, turnUsage })) {
62505
62847
  opts.onEvent(event);
62506
62848
  }
62849
+ if (interactions && permLocal.mode === "plan" && update.type === "tool-call-completed") {
62850
+ const parts = extractToolCallParts(update);
62851
+ if (parts.toolType === "createPlan" && parts.callId && !parts.isError) {
62852
+ completedPlan.current = { callId: parts.callId, args: parts.args };
62853
+ }
62854
+ }
62507
62855
  },
62508
62856
  onStep: ({ step }) => {
62509
62857
  tracer.sdk(cursorSdkType(step, "step"), step, messageId);
@@ -62577,8 +62925,7 @@ ${text}` : text;
62577
62925
  for await (const message of run.stream()) {
62578
62926
  tracer.sdk(cursorSdkType(message, "stream"), message, messageId);
62579
62927
  for (const event of mapSdkMessageLifecycle(messageId, message, {
62580
- includeContent: false,
62581
- contextWindow
62928
+ includeContent: false
62582
62929
  })) {
62583
62930
  opts.onEvent(event);
62584
62931
  }
@@ -62600,12 +62947,30 @@ ${text}` : text;
62600
62947
  name: error51 instanceof Error ? error51.name : "Error"
62601
62948
  }, messageId);
62602
62949
  throw formatCursorError(error51);
62950
+ } finally {
62951
+ interactions?.cancelQuestions("turn ended");
62603
62952
  }
62604
62953
  tracer.sdk("result", result, messageId);
62605
62954
  currentRun = null;
62606
62955
  lastRunId = result.id || lastRunId;
62956
+ const plan2 = completedPlan.current;
62957
+ if (plan2 && interactions && result.status === "finished" && !cancelToken.cancelled && !disposed) {
62958
+ const request = buildCursorPlanApprovalRequest(plan2.callId, plan2.args);
62959
+ if (request) {
62960
+ tracer.runtime("plan_approval_raised", { requestId: request.requestId }, messageId);
62961
+ void interactions.requestPlanApproval(request);
62962
+ }
62963
+ }
62607
62964
  if (result.usage) {
62608
62965
  turnUsage.applyRunTotals(result.usage);
62966
+ if (turnUsage.lastEstimate) {
62967
+ log2.debug("[CursorRuntime] context estimate", {
62968
+ messageId,
62969
+ inputTokens: result.usage.inputTokens,
62970
+ previous: sendOpts?.previousContextTokens ?? 0,
62971
+ ...turnUsage.lastEstimate
62972
+ });
62973
+ }
62609
62974
  opts.onEvent({
62610
62975
  type: "message_usage",
62611
62976
  messageId,
@@ -62646,6 +63011,7 @@ ${text}` : text;
62646
63011
  };
62647
63012
  },
62648
63013
  async cancel() {
63014
+ if (activeCancelToken) activeCancelToken.cancelled = true;
62649
63015
  try {
62650
63016
  await currentRun?.cancel();
62651
63017
  } catch (error51) {
@@ -62654,6 +63020,7 @@ ${text}` : text;
62654
63020
  },
62655
63021
  async close() {
62656
63022
  disposed = true;
63023
+ if (activeCancelToken) activeCancelToken.cancelled = true;
62657
63024
  try {
62658
63025
  await currentRun?.cancel();
62659
63026
  } catch {
@@ -62672,7 +63039,7 @@ ${text}` : text;
62672
63039
  }
62673
63040
  };
62674
63041
  }
62675
- var noopLog, CursorIntegrationError;
63042
+ var noopLog, CursorIntegrationError, CURSOR_QUESTION_TOOL_HINT;
62676
63043
  var init_cursor_runtime = __esm({
62677
63044
  "../../packages/cursor/src/cursor-runtime.ts"() {
62678
63045
  "use strict";
@@ -62682,6 +63049,7 @@ var init_cursor_runtime = __esm({
62682
63049
  init_cursor_network_retry();
62683
63050
  init_cursor_custom_tools();
62684
63051
  init_cursor_event_map();
63052
+ init_cursor_interactions();
62685
63053
  init_cursor_mcp_map();
62686
63054
  init_cursor_model_selection();
62687
63055
  init_cursor_platform_binaries();
@@ -62703,6 +63071,7 @@ var init_cursor_runtime = __esm({
62703
63071
  this.helpUrl = opts?.helpUrl;
62704
63072
  }
62705
63073
  };
63074
+ CURSOR_QUESTION_TOOL_HINT = `To ask the user a question, call the \`${CURSOR_ASK_USER_QUESTION_TOOL}\` tool from the custom-user-tools server and wait for its result. The built-in askQuestion tool is not available in this host.`;
62706
63075
  }
62707
63076
  });
62708
63077
 
@@ -62854,6 +63223,7 @@ var init_src5 = __esm({
62854
63223
  init_cursor_platform_binaries();
62855
63224
  init_cursor_mcp_map();
62856
63225
  init_cursor_custom_tools();
63226
+ init_cursor_interactions();
62857
63227
  init_cursor_event_map();
62858
63228
  init_cursor_store();
62859
63229
  init_cursor_client();
@@ -62945,7 +63315,7 @@ var init_harness_runners = __esm({
62945
63315
  });
62946
63316
 
62947
63317
  // src/session/codex-live-turn.ts
62948
- function asRecord14(value) {
63318
+ function asRecord15(value) {
62949
63319
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
62950
63320
  }
62951
63321
  function readString6(value) {
@@ -62976,7 +63346,7 @@ function extractAgentTextFromTurn2(turn) {
62976
63346
  let text = "";
62977
63347
  const items = Array.isArray(turn.items) ? turn.items : [];
62978
63348
  for (const item of items) {
62979
- const rec = asRecord14(item);
63349
+ const rec = asRecord15(item);
62980
63350
  if (!rec) continue;
62981
63351
  if (readString6(rec.type) === "agentMessage" || readString6(rec.itemType) === "agentMessage") {
62982
63352
  const t = readString6(rec.text);
@@ -63008,7 +63378,7 @@ async function openTurnAndStream(opts) {
63008
63378
  ...collaborationMode ? { collaborationMode } : {}
63009
63379
  })
63010
63380
  );
63011
- const turn = asRecord14(turnStartResult.turn);
63381
+ const turn = asRecord15(turnStartResult.turn);
63012
63382
  const turnId = readString6(turn?.id);
63013
63383
  opts.onTurnStarted?.(turnId);
63014
63384
  let finalText = "";
@@ -63036,7 +63406,7 @@ async function openTurnAndStream(opts) {
63036
63406
  continue;
63037
63407
  }
63038
63408
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
63039
- const completedTurn = asRecord14(note.params.turn);
63409
+ const completedTurn = asRecord15(note.params.turn);
63040
63410
  const completedId = readString6(completedTurn?.id);
63041
63411
  if (turnId && completedId && completedId !== turnId) continue;
63042
63412
  }
@@ -63044,14 +63414,14 @@ async function openTurnAndStream(opts) {
63044
63414
  const applied = agentEventMapper.apply(note);
63045
63415
  if (applied.textDelta) finalText += applied.textDelta;
63046
63416
  } else if (note.method === "item/agentMessage/delta" || note.method === "item/agentMessageDelta") {
63047
- const delta = readString6(note.params.delta) ?? readString6(note.params.text) ?? readString6(asRecord14(note.params.item)?.delta);
63417
+ const delta = readString6(note.params.delta) ?? readString6(note.params.text) ?? readString6(asRecord15(note.params.item)?.delta);
63048
63418
  if (delta) {
63049
63419
  finalText += delta;
63050
63420
  opts.onDelta?.(delta);
63051
63421
  }
63052
63422
  }
63053
63423
  if (note.method === "turn/completed" || note.method === "turn/completed/v2") {
63054
- const completedTurn = asRecord14(note.params.turn);
63424
+ const completedTurn = asRecord15(note.params.turn);
63055
63425
  const status = readString6(completedTurn?.status) ?? readString6(note.params.status);
63056
63426
  if (status === "failed" || status === "error") {
63057
63427
  throw new Error("Codex turn failed");
@@ -70834,8 +71204,8 @@ import { fileURLToPath } from "node:url";
70834
71204
  function resolveCliReleaseVersion() {
70835
71205
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
70836
71206
  if (fromEnv) return fromEnv;
70837
- if ("0.63.0-alpha".trim()) {
70838
- return "0.63.0-alpha".trim();
71207
+ if ("0.63.0".trim()) {
71208
+ return "0.63.0".trim();
70839
71209
  }
70840
71210
  const fromDist = readDistManifestVersion();
70841
71211
  if (fromDist) return fromDist;
@@ -72950,7 +73320,7 @@ function requireResourceWrite(client3, scope) {
72950
73320
  if (scope === "user") return requireScopes(client3, OPERATION_SCOPES.adminNode);
72951
73321
  return null;
72952
73322
  }
72953
- function asRecord15(payload) {
73323
+ function asRecord16(payload) {
72954
73324
  return payload && typeof payload === "object" ? payload : {};
72955
73325
  }
72956
73326
  function mapThrown(err) {
@@ -72979,7 +73349,7 @@ function manageOpts(ctx) {
72979
73349
  function handleSkillsList(payload, ctx) {
72980
73350
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
72981
73351
  if (denied) return denied;
72982
- const p3 = asRecord15(payload);
73352
+ const p3 = asRecord16(payload);
72983
73353
  try {
72984
73354
  const projectId = String(p3.projectId ?? "");
72985
73355
  const cwd = projectRoot(ctx.projects, projectId);
@@ -72999,7 +73369,7 @@ function handleSkillsList(payload, ctx) {
72999
73369
  function handleSkillsGet(payload, ctx) {
73000
73370
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73001
73371
  if (denied) return denied;
73002
- const p3 = asRecord15(payload);
73372
+ const p3 = asRecord16(payload);
73003
73373
  try {
73004
73374
  const projectId = String(p3.projectId ?? "");
73005
73375
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73024,7 +73394,7 @@ function handleSkillsGet(payload, ctx) {
73024
73394
  function handleSkillsReadFile(payload, ctx) {
73025
73395
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73026
73396
  if (denied) return denied;
73027
- const p3 = asRecord15(payload);
73397
+ const p3 = asRecord16(payload);
73028
73398
  try {
73029
73399
  const projectId = String(p3.projectId ?? "");
73030
73400
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73058,7 +73428,7 @@ function handleSkillsReadFile(payload, ctx) {
73058
73428
  function handleSkillsDelete(payload, ctx) {
73059
73429
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73060
73430
  if (denied) return denied;
73061
- const p3 = asRecord15(payload);
73431
+ const p3 = asRecord16(payload);
73062
73432
  try {
73063
73433
  const projectId = String(p3.projectId ?? "");
73064
73434
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73083,7 +73453,7 @@ function handleSkillsDelete(payload, ctx) {
73083
73453
  function handleSkillsInstall(payload, ctx) {
73084
73454
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73085
73455
  if (baseDenied) return baseDenied;
73086
- const p3 = asRecord15(payload);
73456
+ const p3 = asRecord16(payload);
73087
73457
  try {
73088
73458
  const projectId = String(p3.projectId ?? "");
73089
73459
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73117,7 +73487,7 @@ function handleSkillsInstall(payload, ctx) {
73117
73487
  function handleMcpList(payload, ctx) {
73118
73488
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73119
73489
  if (denied) return denied;
73120
- const p3 = asRecord15(payload);
73490
+ const p3 = asRecord16(payload);
73121
73491
  try {
73122
73492
  const projectId = String(p3.projectId ?? "");
73123
73493
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73174,7 +73544,7 @@ function parseMcpWriteConfig(raw) {
73174
73544
  function handleMcpSave(payload, ctx) {
73175
73545
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73176
73546
  if (baseDenied) return baseDenied;
73177
- const p3 = asRecord15(payload);
73547
+ const p3 = asRecord16(payload);
73178
73548
  try {
73179
73549
  const projectId = String(p3.projectId ?? "");
73180
73550
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73204,7 +73574,7 @@ function handleMcpSave(payload, ctx) {
73204
73574
  function handleMcpToggle(payload, ctx) {
73205
73575
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73206
73576
  if (baseDenied) return baseDenied;
73207
- const p3 = asRecord15(payload);
73577
+ const p3 = asRecord16(payload);
73208
73578
  try {
73209
73579
  const projectId = String(p3.projectId ?? "");
73210
73580
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73235,7 +73605,7 @@ function handleMcpToggle(payload, ctx) {
73235
73605
  function handleMcpDelete(payload, ctx) {
73236
73606
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73237
73607
  if (baseDenied) return baseDenied;
73238
- const p3 = asRecord15(payload);
73608
+ const p3 = asRecord16(payload);
73239
73609
  try {
73240
73610
  const projectId = String(p3.projectId ?? "");
73241
73611
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73275,7 +73645,7 @@ function parseMarketplaceScope(raw) {
73275
73645
  async function handlePluginsList(payload, ctx) {
73276
73646
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73277
73647
  if (denied) return denied;
73278
- const p3 = asRecord15(payload);
73648
+ const p3 = asRecord16(payload);
73279
73649
  try {
73280
73650
  const projectId = String(p3.projectId ?? "");
73281
73651
  projectRoot(ctx.projects, projectId);
@@ -73322,7 +73692,7 @@ async function handlePluginsList(payload, ctx) {
73322
73692
  function handlePluginsGet(payload, ctx) {
73323
73693
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73324
73694
  if (denied) return denied;
73325
- const p3 = asRecord15(payload);
73695
+ const p3 = asRecord16(payload);
73326
73696
  try {
73327
73697
  const projectId = String(p3.projectId ?? "");
73328
73698
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73346,7 +73716,7 @@ function handlePluginsGet(payload, ctx) {
73346
73716
  function handlePluginsReadFile(payload, ctx) {
73347
73717
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73348
73718
  if (denied) return denied;
73349
- const p3 = asRecord15(payload);
73719
+ const p3 = asRecord16(payload);
73350
73720
  try {
73351
73721
  const projectId = String(p3.projectId ?? "");
73352
73722
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73374,7 +73744,7 @@ function handlePluginsReadFile(payload, ctx) {
73374
73744
  function handlePluginsDelete(payload, ctx) {
73375
73745
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73376
73746
  if (baseDenied) return baseDenied;
73377
- const p3 = asRecord15(payload);
73747
+ const p3 = asRecord16(payload);
73378
73748
  try {
73379
73749
  const projectId = String(p3.projectId ?? "");
73380
73750
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73400,7 +73770,7 @@ function handlePluginsDelete(payload, ctx) {
73400
73770
  async function handlePluginsInstall(payload, ctx) {
73401
73771
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73402
73772
  if (baseDenied) return baseDenied;
73403
- const p3 = asRecord15(payload);
73773
+ const p3 = asRecord16(payload);
73404
73774
  try {
73405
73775
  const projectId = String(p3.projectId ?? "");
73406
73776
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73426,7 +73796,7 @@ async function handlePluginsInstall(payload, ctx) {
73426
73796
  function handlePluginsUpdate(payload, ctx) {
73427
73797
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73428
73798
  if (baseDenied) return baseDenied;
73429
- const p3 = asRecord15(payload);
73799
+ const p3 = asRecord16(payload);
73430
73800
  try {
73431
73801
  const projectId = String(p3.projectId ?? "");
73432
73802
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73452,7 +73822,7 @@ function handlePluginsUpdate(payload, ctx) {
73452
73822
  function handlePluginsListMarketplace(payload, ctx) {
73453
73823
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73454
73824
  if (denied) return denied;
73455
- const p3 = asRecord15(payload);
73825
+ const p3 = asRecord16(payload);
73456
73826
  try {
73457
73827
  const projectId = String(p3.projectId ?? "");
73458
73828
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73474,7 +73844,7 @@ function handlePluginsListMarketplace(payload, ctx) {
73474
73844
  async function handlePluginsAddMarketplace(payload, ctx) {
73475
73845
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73476
73846
  if (baseDenied) return baseDenied;
73477
- const p3 = asRecord15(payload);
73847
+ const p3 = asRecord16(payload);
73478
73848
  try {
73479
73849
  const projectId = String(p3.projectId ?? "");
73480
73850
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73500,7 +73870,7 @@ async function handlePluginsAddMarketplace(payload, ctx) {
73500
73870
  async function handlePluginsRemoveMarketplace(payload, ctx) {
73501
73871
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73502
73872
  if (baseDenied) return baseDenied;
73503
- const p3 = asRecord15(payload);
73873
+ const p3 = asRecord16(payload);
73504
73874
  try {
73505
73875
  const projectId = String(p3.projectId ?? "");
73506
73876
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73535,7 +73905,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
73535
73905
  if (denied) return denied;
73536
73906
  const adminDenied = requireScopes(ctx.client, OPERATION_SCOPES.adminNode);
73537
73907
  if (adminDenied) return adminDenied;
73538
- const p3 = asRecord15(payload);
73908
+ const p3 = asRecord16(payload);
73539
73909
  try {
73540
73910
  const projectId = String(p3.projectId ?? "");
73541
73911
  if (projectId) {
@@ -73557,7 +73927,7 @@ async function handlePluginsUpdateMarketplace(payload, ctx) {
73557
73927
  function handlePluginsReadMarketplace(payload, ctx) {
73558
73928
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73559
73929
  if (denied) return denied;
73560
- const p3 = asRecord15(payload);
73930
+ const p3 = asRecord16(payload);
73561
73931
  try {
73562
73932
  const projectId = String(p3.projectId ?? "");
73563
73933
  if (projectId) {
@@ -73588,7 +73958,7 @@ function handlePluginsReadMarketplace(payload, ctx) {
73588
73958
  function handlePluginsReadMarketplaceFile(payload, ctx) {
73589
73959
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73590
73960
  if (denied) return denied;
73591
- const p3 = asRecord15(payload);
73961
+ const p3 = asRecord16(payload);
73592
73962
  try {
73593
73963
  const projectId = String(p3.projectId ?? "");
73594
73964
  if (projectId) {
@@ -73622,7 +73992,7 @@ function handlePluginsReadMarketplaceFile(payload, ctx) {
73622
73992
  function handleAgentsList(payload, ctx) {
73623
73993
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73624
73994
  if (denied) return denied;
73625
- const p3 = asRecord15(payload);
73995
+ const p3 = asRecord16(payload);
73626
73996
  try {
73627
73997
  const projectId = String(p3.projectId ?? "");
73628
73998
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73639,7 +74009,7 @@ function handleAgentsList(payload, ctx) {
73639
74009
  function handleAgentsReadFile(payload, ctx) {
73640
74010
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73641
74011
  if (denied) return denied;
73642
- const p3 = asRecord15(payload);
74012
+ const p3 = asRecord16(payload);
73643
74013
  try {
73644
74014
  const projectId = String(p3.projectId ?? "");
73645
74015
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73671,7 +74041,7 @@ function parseHookSavePayload(raw) {
73671
74041
  function handleHooksList(payload, ctx) {
73672
74042
  const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
73673
74043
  if (denied) return denied;
73674
- const p3 = asRecord15(payload);
74044
+ const p3 = asRecord16(payload);
73675
74045
  try {
73676
74046
  const projectId = String(p3.projectId ?? "");
73677
74047
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73684,7 +74054,7 @@ function handleHooksList(payload, ctx) {
73684
74054
  function handleHooksSave(payload, ctx) {
73685
74055
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73686
74056
  if (baseDenied) return baseDenied;
73687
- const p3 = asRecord15(payload);
74057
+ const p3 = asRecord16(payload);
73688
74058
  try {
73689
74059
  const projectId = String(p3.projectId ?? "");
73690
74060
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73712,7 +74082,7 @@ function handleHooksSave(payload, ctx) {
73712
74082
  function handleHooksDelete(payload, ctx) {
73713
74083
  const baseDenied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
73714
74084
  if (baseDenied) return baseDenied;
73715
- const p3 = asRecord15(payload);
74085
+ const p3 = asRecord16(payload);
73716
74086
  try {
73717
74087
  const projectId = String(p3.projectId ?? "");
73718
74088
  const cwd = projectRoot(ctx.projects, projectId);
@@ -73811,7 +74181,7 @@ function requireScopes2(client3, scopes) {
73811
74181
  }
73812
74182
  return null;
73813
74183
  }
73814
- function asRecord16(payload) {
74184
+ function asRecord17(payload) {
73815
74185
  return payload && typeof payload === "object" ? payload : {};
73816
74186
  }
73817
74187
  function mapThrown2(err) {
@@ -73902,7 +74272,7 @@ function parseSchedule(raw) {
73902
74272
  function handleAutomationList(payload, ctx) {
73903
74273
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.readSession);
73904
74274
  if (denied) return denied;
73905
- const p3 = asRecord16(payload);
74275
+ const p3 = asRecord17(payload);
73906
74276
  const projectId = String(p3.projectId ?? "").trim();
73907
74277
  if (!projectId) {
73908
74278
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -73921,7 +74291,7 @@ function handleAutomationList(payload, ctx) {
73921
74291
  function handleAutomationCreate(payload, ctx) {
73922
74292
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73923
74293
  if (denied) return denied;
73924
- const p3 = asRecord16(payload);
74294
+ const p3 = asRecord17(payload);
73925
74295
  const projectId = String(p3.projectId ?? "").trim();
73926
74296
  if (!projectId) {
73927
74297
  return { error: { code: "invalid_argument", message: "projectId is required" } };
@@ -73958,7 +74328,7 @@ function handleAutomationCreate(payload, ctx) {
73958
74328
  function handleAutomationUpdate(payload, ctx) {
73959
74329
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
73960
74330
  if (denied) return denied;
73961
- const p3 = asRecord16(payload);
74331
+ const p3 = asRecord17(payload);
73962
74332
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
73963
74333
  if (!automationId) {
73964
74334
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74002,7 +74372,7 @@ function handleAutomationUpdate(payload, ctx) {
74002
74372
  function handleAutomationDelete(payload, ctx) {
74003
74373
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74004
74374
  if (denied) return denied;
74005
- const p3 = asRecord16(payload);
74375
+ const p3 = asRecord17(payload);
74006
74376
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
74007
74377
  if (!automationId) {
74008
74378
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74028,7 +74398,7 @@ function handleAutomationDelete(payload, ctx) {
74028
74398
  async function handleAutomationRunNow(payload, ctx) {
74029
74399
  const denied = requireScopes2(ctx.client, OPERATION_SCOPES.operateSession);
74030
74400
  if (denied) return denied;
74031
- const p3 = asRecord16(payload);
74401
+ const p3 = asRecord17(payload);
74032
74402
  const automationId = String(p3.automationId ?? p3.id ?? "").trim();
74033
74403
  if (!automationId) {
74034
74404
  return { error: { code: "invalid_argument", message: "automationId is required" } };
@@ -74085,7 +74455,7 @@ function requireScopes3(client3, scopes) {
74085
74455
  }
74086
74456
  return null;
74087
74457
  }
74088
- function asRecord17(payload) {
74458
+ function asRecord18(payload) {
74089
74459
  return payload && typeof payload === "object" ? payload : {};
74090
74460
  }
74091
74461
  function optionalString(value) {
@@ -74094,7 +74464,7 @@ function optionalString(value) {
74094
74464
  function parseAttachments(value) {
74095
74465
  if (!Array.isArray(value)) return [];
74096
74466
  return value.flatMap((raw) => {
74097
- const a = asRecord17(raw);
74467
+ const a = asRecord18(raw);
74098
74468
  const name = typeof a.name === "string" ? a.name : "";
74099
74469
  const mimeType = typeof a.mimeType === "string" ? a.mimeType : "";
74100
74470
  const data = typeof a.data === "string" ? a.data : "";
@@ -74107,7 +74477,7 @@ function mapThrown3(err) {
74107
74477
  function handleDraftList(payload, ctx) {
74108
74478
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.readSession);
74109
74479
  if (denied) return denied;
74110
- const p3 = asRecord17(payload);
74480
+ const p3 = asRecord18(payload);
74111
74481
  const projectPath = optionalString(p3.projectPath);
74112
74482
  try {
74113
74483
  return { result: { drafts: ctx.drafts.list(projectPath ?? void 0) } };
@@ -74118,7 +74488,7 @@ function handleDraftList(payload, ctx) {
74118
74488
  function handleDraftUpsert(payload, ctx) {
74119
74489
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
74120
74490
  if (denied) return denied;
74121
- const p3 = asRecord17(payload);
74491
+ const p3 = asRecord18(payload);
74122
74492
  const id = String(p3.id ?? "").trim();
74123
74493
  if (!id) {
74124
74494
  return { error: { code: "invalid_argument", message: "id is required" } };
@@ -74149,7 +74519,7 @@ function handleDraftUpsert(payload, ctx) {
74149
74519
  function handleDraftDelete(payload, ctx) {
74150
74520
  const denied = requireScopes3(ctx.client, OPERATION_SCOPES.operateSession);
74151
74521
  if (denied) return denied;
74152
- const p3 = asRecord17(payload);
74522
+ const p3 = asRecord18(payload);
74153
74523
  const draftId = String(p3.draftId ?? "").trim();
74154
74524
  if (!draftId) {
74155
74525
  return { error: { code: "invalid_argument", message: "draftId is required" } };
@@ -74183,7 +74553,7 @@ function requireScopes4(client3, scopes) {
74183
74553
  }
74184
74554
  return null;
74185
74555
  }
74186
- function asRecord18(payload) {
74556
+ function asRecord19(payload) {
74187
74557
  return payload && typeof payload === "object" ? payload : {};
74188
74558
  }
74189
74559
  function mapThrown4(err) {
@@ -74269,7 +74639,7 @@ var CODEX_MUTATING_METHODS = [
74269
74639
  function handleGetAuthStatus(payload, ctx) {
74270
74640
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74271
74641
  if (denied) return denied;
74272
- const p3 = asRecord18(payload);
74642
+ const p3 = asRecord19(payload);
74273
74643
  const projectId = projectIdOf(p3);
74274
74644
  if (!projectId) {
74275
74645
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74282,7 +74652,7 @@ function handleGetAuthStatus(payload, ctx) {
74282
74652
  function handleSetAuth(payload, ctx) {
74283
74653
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74284
74654
  if (denied) return denied;
74285
- const p3 = asRecord18(payload);
74655
+ const p3 = asRecord19(payload);
74286
74656
  const projectId = projectIdOf(p3);
74287
74657
  if (!projectId) {
74288
74658
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74307,7 +74677,7 @@ function handleSetAuth(payload, ctx) {
74307
74677
  async function handleGetAccountStatus(payload, ctx) {
74308
74678
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74309
74679
  if (denied) return denied;
74310
- const p3 = asRecord18(payload);
74680
+ const p3 = asRecord19(payload);
74311
74681
  const projectId = projectIdOf(p3);
74312
74682
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74313
74683
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74320,7 +74690,7 @@ async function handleGetAccountStatus(payload, ctx) {
74320
74690
  async function handleAccountLoginStart(payload, ctx) {
74321
74691
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74322
74692
  if (denied) return denied;
74323
- const p3 = asRecord18(payload);
74693
+ const p3 = asRecord19(payload);
74324
74694
  const projectId = projectIdOf(p3);
74325
74695
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74326
74696
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74333,7 +74703,7 @@ async function handleAccountLoginStart(payload, ctx) {
74333
74703
  async function handleAccountLoginCancel(payload, ctx) {
74334
74704
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74335
74705
  if (denied) return denied;
74336
- const p3 = asRecord18(payload);
74706
+ const p3 = asRecord19(payload);
74337
74707
  const loginId = typeof p3.loginId === "string" ? p3.loginId.trim() : "";
74338
74708
  if (!loginId) return { error: { code: "invalid_argument", message: "loginId required" } };
74339
74709
  try {
@@ -74346,7 +74716,7 @@ async function handleAccountLoginCancel(payload, ctx) {
74346
74716
  async function handleAccountLogout(payload, ctx) {
74347
74717
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74348
74718
  if (denied) return denied;
74349
- const p3 = asRecord18(payload);
74719
+ const p3 = asRecord19(payload);
74350
74720
  const projectId = projectIdOf(p3);
74351
74721
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74352
74722
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74359,7 +74729,7 @@ async function handleAccountLogout(payload, ctx) {
74359
74729
  async function handleGetRateLimits(payload, ctx) {
74360
74730
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74361
74731
  if (denied) return denied;
74362
- const p3 = asRecord18(payload);
74732
+ const p3 = asRecord19(payload);
74363
74733
  const projectId = projectIdOf(p3);
74364
74734
  if (!projectId) {
74365
74735
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74386,7 +74756,7 @@ async function handleGetRateLimits(payload, ctx) {
74386
74756
  async function handleGetAccountUsage(payload, ctx) {
74387
74757
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74388
74758
  if (denied) return denied;
74389
- const p3 = asRecord18(payload);
74759
+ const p3 = asRecord19(payload);
74390
74760
  const projectId = projectIdOf(p3);
74391
74761
  if (!projectId) {
74392
74762
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74414,7 +74784,7 @@ async function handleGetAccountUsage(payload, ctx) {
74414
74784
  async function handleGetServerDiagnostics(payload, ctx) {
74415
74785
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74416
74786
  if (denied) return denied;
74417
- const p3 = asRecord18(payload);
74787
+ const p3 = asRecord19(payload);
74418
74788
  const projectId = projectIdOf(p3);
74419
74789
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74420
74790
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74432,7 +74802,7 @@ async function handleGetServerDiagnostics(payload, ctx) {
74432
74802
  async function handleGetConfigRequirements(payload, ctx) {
74433
74803
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74434
74804
  if (denied) return denied;
74435
- const p3 = asRecord18(payload);
74805
+ const p3 = asRecord19(payload);
74436
74806
  const projectId = projectIdOf(p3);
74437
74807
  if (!projectId) return { error: { code: "invalid_argument", message: "projectId required" } };
74438
74808
  if (!ctx.projects.get(projectId)) return { error: { code: "not_found", message: "project not found" } };
@@ -74450,7 +74820,7 @@ async function handleGetConfigRequirements(payload, ctx) {
74450
74820
  async function handleConsumeRateLimitReset(payload, ctx) {
74451
74821
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74452
74822
  if (denied) return denied;
74453
- const p3 = asRecord18(payload);
74823
+ const p3 = asRecord19(payload);
74454
74824
  const projectId = projectIdOf(p3);
74455
74825
  if (!projectId) {
74456
74826
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74480,7 +74850,7 @@ async function handleConsumeRateLimitReset(payload, ctx) {
74480
74850
  async function handleLoginMcpOauth(payload, ctx) {
74481
74851
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74482
74852
  if (denied) return denied;
74483
- const p3 = asRecord18(payload);
74853
+ const p3 = asRecord19(payload);
74484
74854
  const projectId = projectIdOf(p3);
74485
74855
  const serverName = String(p3.serverName ?? p3.name ?? "").trim();
74486
74856
  if (!projectId || !serverName) {
@@ -74490,7 +74860,7 @@ async function handleLoginMcpOauth(payload, ctx) {
74490
74860
  }
74491
74861
  try {
74492
74862
  const apiProviderId = typeof p3.apiProviderId === "string" ? p3.apiProviderId : null;
74493
- const rawOptions = asRecord18(p3.options);
74863
+ const rawOptions = asRecord19(p3.options);
74494
74864
  const options = {
74495
74865
  ...rawOptions.clientRegistration === "auto" || rawOptions.clientRegistration === "cimd" || rawOptions.clientRegistration === "dcr" ? { clientRegistration: rawOptions.clientRegistration } : {},
74496
74866
  ...typeof rawOptions.threadId === "string" || rawOptions.threadId === null ? { threadId: rawOptions.threadId } : {},
@@ -74507,7 +74877,7 @@ async function handleLoginMcpOauth(payload, ctx) {
74507
74877
  async function handleDetectExternalAgent(payload, ctx) {
74508
74878
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readEnvironment);
74509
74879
  if (denied) return denied;
74510
- const p3 = asRecord18(payload);
74880
+ const p3 = asRecord19(payload);
74511
74881
  const projectId = projectIdOf(p3);
74512
74882
  if (!projectId) {
74513
74883
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74526,7 +74896,7 @@ async function handleDetectExternalAgent(payload, ctx) {
74526
74896
  async function handleImportExternalAgent(payload, ctx) {
74527
74897
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74528
74898
  if (denied) return denied;
74529
- const p3 = asRecord18(payload);
74899
+ const p3 = asRecord19(payload);
74530
74900
  const projectId = projectIdOf(p3);
74531
74901
  if (!projectId) {
74532
74902
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74544,7 +74914,7 @@ async function handleImportExternalAgent(payload, ctx) {
74544
74914
  async function handlePluginsList2(payload, ctx) {
74545
74915
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.readWorkspace);
74546
74916
  if (denied) return denied;
74547
- const p3 = asRecord18(payload);
74917
+ const p3 = asRecord19(payload);
74548
74918
  const projectId = projectIdOf(p3);
74549
74919
  if (!projectId) {
74550
74920
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74567,7 +74937,7 @@ async function handlePluginsList2(payload, ctx) {
74567
74937
  async function handlePluginsInstall2(payload, ctx) {
74568
74938
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74569
74939
  if (denied) return denied;
74570
- const p3 = asRecord18(payload);
74940
+ const p3 = asRecord19(payload);
74571
74941
  const projectId = projectIdOf(p3);
74572
74942
  const key = String(p3.key ?? p3.pluginId ?? "").trim();
74573
74943
  if (!projectId || !key) {
@@ -74583,7 +74953,7 @@ async function handlePluginsInstall2(payload, ctx) {
74583
74953
  async function handlePluginsUninstall(payload, ctx) {
74584
74954
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74585
74955
  if (denied) return denied;
74586
- const p3 = asRecord18(payload);
74956
+ const p3 = asRecord19(payload);
74587
74957
  const projectId = projectIdOf(p3);
74588
74958
  const key = String(p3.key ?? p3.pluginId ?? "").trim();
74589
74959
  if (!projectId || !key) {
@@ -74599,7 +74969,7 @@ async function handlePluginsUninstall(payload, ctx) {
74599
74969
  async function handleMarketplaceAdd(payload, ctx) {
74600
74970
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74601
74971
  if (denied) return denied;
74602
- const p3 = asRecord18(payload);
74972
+ const p3 = asRecord19(payload);
74603
74973
  const projectId = projectIdOf(p3);
74604
74974
  const source = String(p3.source ?? "").trim();
74605
74975
  if (!projectId || !source) {
@@ -74628,7 +74998,7 @@ async function handleMarketplaceAdd(payload, ctx) {
74628
74998
  async function handleMarketplaceRemove(payload, ctx) {
74629
74999
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74630
75000
  if (denied) return denied;
74631
- const p3 = asRecord18(payload);
75001
+ const p3 = asRecord19(payload);
74632
75002
  const projectId = projectIdOf(p3);
74633
75003
  const marketplaceName = String(p3.marketplaceName ?? p3.name ?? "").trim();
74634
75004
  if (!projectId || !marketplaceName) {
@@ -74651,7 +75021,7 @@ async function handleMarketplaceRemove(payload, ctx) {
74651
75021
  async function handleMarketplaceUpgrade(payload, ctx) {
74652
75022
  const denied = requireScopes4(ctx.client, OPERATION_SCOPES.adminNode);
74653
75023
  if (denied) return denied;
74654
- const p3 = asRecord18(payload);
75024
+ const p3 = asRecord19(payload);
74655
75025
  const projectId = projectIdOf(p3);
74656
75026
  if (!projectId) {
74657
75027
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -74684,7 +75054,7 @@ function requireScopes5(client3, scopes) {
74684
75054
  }
74685
75055
  return null;
74686
75056
  }
74687
- function asRecord19(payload) {
75057
+ function asRecord20(payload) {
74688
75058
  return payload && typeof payload === "object" ? payload : {};
74689
75059
  }
74690
75060
  function mapThrown5(err) {
@@ -74713,7 +75083,7 @@ function dispatchSessionProviderRpc(method, payload, ctx) {
74713
75083
  function handleList(payload, ctx) {
74714
75084
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74715
75085
  if (denied) return denied;
74716
- const p3 = asRecord19(payload);
75086
+ const p3 = asRecord20(payload);
74717
75087
  try {
74718
75088
  const harnessId = typeof p3.harnessId === "string" && p3.harnessId.trim() ? p3.harnessId.trim() : null;
74719
75089
  const providers = harnessId ? ctx.sessionProviders.listByHarness(harnessId) : ctx.sessionProviders.list();
@@ -74725,7 +75095,7 @@ function handleList(payload, ctx) {
74725
75095
  function handleGet(payload, ctx) {
74726
75096
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74727
75097
  if (denied) return denied;
74728
- const p3 = asRecord19(payload);
75098
+ const p3 = asRecord20(payload);
74729
75099
  const id = String(p3.id ?? "");
74730
75100
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74731
75101
  try {
@@ -74737,7 +75107,7 @@ function handleGet(payload, ctx) {
74737
75107
  function handleGetBase(payload, ctx) {
74738
75108
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.readEnvironment);
74739
75109
  if (denied) return denied;
74740
- const p3 = asRecord19(payload);
75110
+ const p3 = asRecord20(payload);
74741
75111
  const harnessId = String(p3.harnessId ?? "");
74742
75112
  if (!harnessId) return { error: { code: "invalid_argument", message: "harnessId required" } };
74743
75113
  try {
@@ -74749,7 +75119,7 @@ function handleGetBase(payload, ctx) {
74749
75119
  function handleCreate(payload, ctx) {
74750
75120
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74751
75121
  if (denied) return denied;
74752
- const p3 = asRecord19(payload);
75122
+ const p3 = asRecord20(payload);
74753
75123
  try {
74754
75124
  const provider = ctx.sessionProviders.create({
74755
75125
  harnessId: String(p3.harnessId ?? ""),
@@ -74765,7 +75135,7 @@ function handleCreate(payload, ctx) {
74765
75135
  function handleUpdate(payload, ctx) {
74766
75136
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74767
75137
  if (denied) return denied;
74768
- const p3 = asRecord19(payload);
75138
+ const p3 = asRecord20(payload);
74769
75139
  const id = String(p3.id ?? "");
74770
75140
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74771
75141
  try {
@@ -74781,7 +75151,7 @@ function handleUpdate(payload, ctx) {
74781
75151
  function handleDelete(payload, ctx) {
74782
75152
  const denied = requireScopes5(ctx.client, OPERATION_SCOPES.adminNode);
74783
75153
  if (denied) return denied;
74784
- const p3 = asRecord19(payload);
75154
+ const p3 = asRecord20(payload);
74785
75155
  const id = String(p3.id ?? "");
74786
75156
  if (!id) return { error: { code: "invalid_argument", message: "id required" } };
74787
75157
  try {
@@ -74822,7 +75192,7 @@ function requireScopes6(client3, scopes) {
74822
75192
  }
74823
75193
  return null;
74824
75194
  }
74825
- function asRecord20(payload) {
75195
+ function asRecord21(payload) {
74826
75196
  return payload && typeof payload === "object" ? payload : {};
74827
75197
  }
74828
75198
  function defaultProbeModels(ctx) {
@@ -74850,7 +75220,7 @@ async function dispatchHarnessResourcesRpc(method, payload, ctx) {
74850
75220
  async function handleHarnessResources(payload, ctx) {
74851
75221
  const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readEnvironment);
74852
75222
  if (denied) return denied;
74853
- const p3 = asRecord20(payload);
75223
+ const p3 = asRecord21(payload);
74854
75224
  const projectId = String(p3.projectId ?? "");
74855
75225
  if (!projectId) {
74856
75226
  return { error: { code: "invalid_argument", message: "projectId required" } };
@@ -75298,7 +75668,7 @@ function handleProviderListCredentials(ctx) {
75298
75668
  function handleProviderGetCredentialDecrypted(payload, ctx) {
75299
75669
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75300
75670
  if (denied) return denied;
75301
- const p3 = asRecord21(payload);
75671
+ const p3 = asRecord22(payload);
75302
75672
  const cred = ctx.providers.getCredentialDecrypted(String(p3.id ?? ""));
75303
75673
  if (!cred) return { error: { code: "not_found", message: "credential not found" } };
75304
75674
  return { result: cred };
@@ -75306,7 +75676,7 @@ function handleProviderGetCredentialDecrypted(payload, ctx) {
75306
75676
  function handleProviderCreateCredential(payload, ctx) {
75307
75677
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75308
75678
  if (denied) return denied;
75309
- const p3 = asRecord21(payload);
75679
+ const p3 = asRecord22(payload);
75310
75680
  try {
75311
75681
  return {
75312
75682
  result: ctx.providers.createCredential({
@@ -75329,7 +75699,7 @@ function handleProviderCreateCredential(payload, ctx) {
75329
75699
  function handleProviderUpdateCredential(payload, ctx) {
75330
75700
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75331
75701
  if (denied) return denied;
75332
- const p3 = asRecord21(payload);
75702
+ const p3 = asRecord22(payload);
75333
75703
  const id = String(p3.id ?? "");
75334
75704
  const updated = ctx.providers.updateCredential(id, {
75335
75705
  name: typeof p3.name === "string" ? p3.name : void 0,
@@ -75347,7 +75717,7 @@ function handleProviderUpdateCredential(payload, ctx) {
75347
75717
  function handleProviderDeleteCredential(payload, ctx) {
75348
75718
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75349
75719
  if (denied) return denied;
75350
- const p3 = asRecord21(payload);
75720
+ const p3 = asRecord22(payload);
75351
75721
  const ok = ctx.providers.deleteCredential(String(p3.id ?? ""));
75352
75722
  if (!ok) return { error: { code: "not_found", message: "credential not found" } };
75353
75723
  return { result: { ok: true } };
@@ -75360,7 +75730,7 @@ function handleProviderListBindings(ctx) {
75360
75730
  function handleProviderSetBinding(payload, ctx) {
75361
75731
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75362
75732
  if (denied) return denied;
75363
- const p3 = asRecord21(payload);
75733
+ const p3 = asRecord22(payload);
75364
75734
  const binding = p3;
75365
75735
  if (!binding.consumer || !binding.credentialId) {
75366
75736
  return { error: { code: "invalid_argument", message: "consumer and credentialId required" } };
@@ -75371,7 +75741,7 @@ function handleProviderSetBinding(payload, ctx) {
75371
75741
  function handleProviderClearBinding(payload, ctx) {
75372
75742
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75373
75743
  if (denied) return denied;
75374
- const p3 = asRecord21(payload);
75744
+ const p3 = asRecord22(payload);
75375
75745
  ctx.providers.clearBinding(String(p3.consumer ?? ""));
75376
75746
  return { result: { ok: true } };
75377
75747
  }
@@ -75383,14 +75753,14 @@ function handleProviderListCustomPlatforms(ctx) {
75383
75753
  function handleProviderUpsertCustomPlatform(payload, ctx) {
75384
75754
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75385
75755
  if (denied) return denied;
75386
- const def = asRecord21(payload);
75756
+ const def = asRecord22(payload);
75387
75757
  if (!def?.id) return { error: { code: "invalid_argument", message: "platform id required" } };
75388
75758
  return { result: ctx.providers.upsertCustomPlatform(def) };
75389
75759
  }
75390
75760
  function handleProviderDeleteCustomPlatform(payload, ctx) {
75391
75761
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75392
75762
  if (denied) return denied;
75393
- const p3 = asRecord21(payload);
75763
+ const p3 = asRecord22(payload);
75394
75764
  const ok = ctx.providers.deleteCustomPlatform(String(p3.id ?? ""));
75395
75765
  if (!ok) return { error: { code: "not_found", message: "custom platform not found" } };
75396
75766
  return { result: { ok: true } };
@@ -75403,7 +75773,7 @@ function handleProviderExportBundle(ctx) {
75403
75773
  function handleProviderListModels(payload, ctx) {
75404
75774
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readEnvironment);
75405
75775
  if (denied) return denied;
75406
- const p3 = asRecord21(payload);
75776
+ const p3 = asRecord22(payload);
75407
75777
  const harness = String(p3.harness ?? p3.harnessId ?? "claude");
75408
75778
  const apiProviderId = typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
75409
75779
  return {
@@ -75415,7 +75785,7 @@ function handleProviderListModels(payload, ctx) {
75415
75785
  function handleProviderImportBundle(payload, ctx) {
75416
75786
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75417
75787
  if (denied) return denied;
75418
- const p3 = asRecord21(payload);
75788
+ const p3 = asRecord22(payload);
75419
75789
  const bundle = p3.bundle && typeof p3.bundle === "object" ? p3.bundle : p3;
75420
75790
  const replaceAll = p3.replaceAll === true;
75421
75791
  try {
@@ -75480,7 +75850,7 @@ function handleHarnessList(ctx) {
75480
75850
  function handleHarnessShow(payload, ctx) {
75481
75851
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75482
75852
  if (denied) return denied;
75483
- const p3 = asRecord21(payload);
75853
+ const p3 = asRecord22(payload);
75484
75854
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75485
75855
  if (!isNodeHarnessId(id)) {
75486
75856
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75490,7 +75860,7 @@ function handleHarnessShow(payload, ctx) {
75490
75860
  function handleHarnessProbe(payload, ctx) {
75491
75861
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75492
75862
  if (denied) return denied;
75493
- const p3 = asRecord21(payload);
75863
+ const p3 = asRecord22(payload);
75494
75864
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75495
75865
  if (!isNodeHarnessId(id)) {
75496
75866
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75505,7 +75875,7 @@ function handleHarnessProbe(payload, ctx) {
75505
75875
  async function handleHarnessEnable(payload, ctx) {
75506
75876
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75507
75877
  if (denied) return denied;
75508
- const p3 = asRecord21(payload);
75878
+ const p3 = asRecord22(payload);
75509
75879
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75510
75880
  if (!isNodeHarnessId(id)) {
75511
75881
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75531,7 +75901,7 @@ async function handleHarnessEnable(payload, ctx) {
75531
75901
  function handleHarnessDisable(payload, ctx) {
75532
75902
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75533
75903
  if (denied) return denied;
75534
- const p3 = asRecord21(payload);
75904
+ const p3 = asRecord22(payload);
75535
75905
  const id = typeof p3.harnessId === "string" ? p3.harnessId : typeof p3.id === "string" ? p3.id : "";
75536
75906
  if (!isNodeHarnessId(id)) {
75537
75907
  return { error: { code: "invalid_argument", message: `unknown harnessId: ${id}` } };
@@ -75596,7 +75966,7 @@ function handleSettingsGet(ctx) {
75596
75966
  function handleSettingsPatch(payload, ctx) {
75597
75967
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.adminNode);
75598
75968
  if (denied) return denied;
75599
- const p3 = asRecord21(payload);
75969
+ const p3 = asRecord22(payload);
75600
75970
  const rawPatch = p3.patch && typeof p3.patch === "object" ? p3.patch : p3;
75601
75971
  try {
75602
75972
  const settings = patchNodeAgentSettings(
@@ -75617,13 +75987,13 @@ async function handleSandboxProbe(ctx) {
75617
75987
  return mapThrown7(err);
75618
75988
  }
75619
75989
  }
75620
- function asRecord21(payload) {
75990
+ function asRecord22(payload) {
75621
75991
  return payload && typeof payload === "object" ? payload : {};
75622
75992
  }
75623
75993
  function handleTerminalCreate(payload, ctx) {
75624
75994
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75625
75995
  if (denied) return denied;
75626
- const p3 = asRecord21(payload);
75996
+ const p3 = asRecord22(payload);
75627
75997
  const cwd = typeof p3.cwd === "string" ? p3.cwd : process.cwd();
75628
75998
  try {
75629
75999
  const info = ctx.terminals.create({
@@ -75648,7 +76018,7 @@ function handleTerminalCreate(payload, ctx) {
75648
76018
  function handleTerminalAttach(payload, ctx) {
75649
76019
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75650
76020
  if (denied) return denied;
75651
- const p3 = asRecord21(payload);
76021
+ const p3 = asRecord22(payload);
75652
76022
  const terminalId = String(p3.terminalId ?? "");
75653
76023
  try {
75654
76024
  const attached = ctx.terminals.attach(terminalId);
@@ -75660,7 +76030,7 @@ function handleTerminalAttach(payload, ctx) {
75660
76030
  function handleTerminalRead(payload, ctx) {
75661
76031
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75662
76032
  if (denied) return denied;
75663
- const p3 = asRecord21(payload);
76033
+ const p3 = asRecord22(payload);
75664
76034
  try {
75665
76035
  return {
75666
76036
  result: ctx.terminals.readAfter(
@@ -75688,7 +76058,7 @@ function requireTerminalLease(payload, ctx, terminalId) {
75688
76058
  function handleTerminalWrite(payload, ctx) {
75689
76059
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75690
76060
  if (denied) return denied;
75691
- const p3 = asRecord21(payload);
76061
+ const p3 = asRecord22(payload);
75692
76062
  const terminalId = String(p3.terminalId ?? "");
75693
76063
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
75694
76064
  if (leaseErr) return leaseErr;
@@ -75706,7 +76076,7 @@ function handleTerminalWrite(payload, ctx) {
75706
76076
  function handleTerminalResize(payload, ctx) {
75707
76077
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75708
76078
  if (denied) return denied;
75709
- const p3 = asRecord21(payload);
76079
+ const p3 = asRecord22(payload);
75710
76080
  const terminalId = String(p3.terminalId ?? "");
75711
76081
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
75712
76082
  if (leaseErr) return leaseErr;
@@ -75722,7 +76092,7 @@ function handleTerminalResize(payload, ctx) {
75722
76092
  function handleTerminalKill(payload, ctx) {
75723
76093
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75724
76094
  if (denied) return denied;
75725
- const p3 = asRecord21(payload);
76095
+ const p3 = asRecord22(payload);
75726
76096
  const terminalId = String(p3.terminalId ?? "");
75727
76097
  const leaseErr = requireTerminalLease(p3, ctx, terminalId);
75728
76098
  if (leaseErr) return leaseErr;
@@ -75736,7 +76106,7 @@ function handleTerminalKill(payload, ctx) {
75736
76106
  function handleTerminalAcquireControl(payload, ctx) {
75737
76107
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75738
76108
  if (denied) return denied;
75739
- const p3 = asRecord21(payload);
76109
+ const p3 = asRecord22(payload);
75740
76110
  const terminalId = String(p3.terminalId ?? "");
75741
76111
  try {
75742
76112
  return {
@@ -75753,7 +76123,7 @@ function handleTerminalAcquireControl(payload, ctx) {
75753
76123
  function handleTerminalRenewControl(payload, ctx) {
75754
76124
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75755
76125
  if (denied) return denied;
75756
- const p3 = asRecord21(payload);
76126
+ const p3 = asRecord22(payload);
75757
76127
  try {
75758
76128
  return {
75759
76129
  result: ctx.leases.renew({
@@ -75770,7 +76140,7 @@ function handleTerminalRenewControl(payload, ctx) {
75770
76140
  function handleTerminalReleaseControl(payload, ctx) {
75771
76141
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateTerminal);
75772
76142
  if (denied) return denied;
75773
- const p3 = asRecord21(payload);
76143
+ const p3 = asRecord22(payload);
75774
76144
  try {
75775
76145
  ctx.leases.release(
75776
76146
  String(p3.leaseId ?? ""),
@@ -75795,7 +76165,7 @@ function handleProjectList(ctx) {
75795
76165
  function handleProjectGet(payload, ctx) {
75796
76166
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readProject);
75797
76167
  if (denied) return denied;
75798
- const p3 = asRecord21(payload);
76168
+ const p3 = asRecord22(payload);
75799
76169
  const projectId = String(p3.projectId ?? "");
75800
76170
  return { result: ctx.projects.get(projectId) };
75801
76171
  }
@@ -75811,7 +76181,7 @@ function expandHostPath(path) {
75811
76181
  function handleProjectOpen(payload, ctx) {
75812
76182
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75813
76183
  if (denied) return denied;
75814
- const p3 = asRecord21(payload);
76184
+ const p3 = asRecord22(payload);
75815
76185
  const path = expandHostPath(String(p3.path ?? ""));
75816
76186
  if (!path) {
75817
76187
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -75829,7 +76199,7 @@ function handleProjectOpen(payload, ctx) {
75829
76199
  function handleProjectUpdate(payload, ctx) {
75830
76200
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75831
76201
  if (denied) return denied;
75832
- const p3 = asRecord21(payload);
76202
+ const p3 = asRecord22(payload);
75833
76203
  const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
75834
76204
  const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
75835
76205
  if (!projectId && !pathRaw) {
@@ -75857,7 +76227,7 @@ function handleProjectUpdate(payload, ctx) {
75857
76227
  function handleProjectRemove(payload, ctx) {
75858
76228
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
75859
76229
  if (denied) return denied;
75860
- const p3 = asRecord21(payload);
76230
+ const p3 = asRecord22(payload);
75861
76231
  const projectId = typeof p3.projectId === "string" && p3.projectId ? p3.projectId : void 0;
75862
76232
  const pathRaw = typeof p3.path === "string" && p3.path ? expandHostPath(p3.path) : void 0;
75863
76233
  if (!projectId && !pathRaw) {
@@ -75876,7 +76246,7 @@ function handleProjectRemove(payload, ctx) {
75876
76246
  function handleFsListDir(payload, ctx) {
75877
76247
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75878
76248
  if (denied) return denied;
75879
- const p3 = asRecord21(payload);
76249
+ const p3 = asRecord22(payload);
75880
76250
  const raw = String(p3.path ?? "");
75881
76251
  if (!raw || raw.includes("\0")) {
75882
76252
  return { error: { code: "invalid_argument", message: "path is required" } };
@@ -75902,7 +76272,7 @@ function handleFsListDir(payload, ctx) {
75902
76272
  function handleWorkspaceListDir(payload, ctx) {
75903
76273
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75904
76274
  if (denied) return denied;
75905
- const p3 = asRecord21(payload);
76275
+ const p3 = asRecord22(payload);
75906
76276
  try {
75907
76277
  return {
75908
76278
  result: ctx.workspaceFs.listDir(String(p3.projectId ?? ""), String(p3.relativePath ?? "."))
@@ -75914,7 +76284,7 @@ function handleWorkspaceListDir(payload, ctx) {
75914
76284
  function handleWorkspaceListFiles(payload, ctx) {
75915
76285
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75916
76286
  if (denied) return denied;
75917
- const p3 = asRecord21(payload);
76287
+ const p3 = asRecord22(payload);
75918
76288
  try {
75919
76289
  return {
75920
76290
  result: {
@@ -75932,7 +76302,7 @@ function handleWorkspaceListFiles(payload, ctx) {
75932
76302
  function handleWorkspaceListSkills(payload, ctx) {
75933
76303
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75934
76304
  if (denied) return denied;
75935
- const p3 = asRecord21(payload);
76305
+ const p3 = asRecord22(payload);
75936
76306
  try {
75937
76307
  return {
75938
76308
  result: ctx.workspaceFs.listSkillsAndCommands(String(p3.projectId ?? ""))
@@ -75944,7 +76314,7 @@ function handleWorkspaceListSkills(payload, ctx) {
75944
76314
  function handleWorkspaceReadFile(payload, ctx) {
75945
76315
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75946
76316
  if (denied) return denied;
75947
- const p3 = asRecord21(payload);
76317
+ const p3 = asRecord22(payload);
75948
76318
  try {
75949
76319
  return {
75950
76320
  result: ctx.workspaceFs.readFile(String(p3.projectId ?? ""), String(p3.relativePath ?? ""), {
@@ -75959,7 +76329,7 @@ function handleWorkspaceReadFile(payload, ctx) {
75959
76329
  function handleWorkspaceWriteFile(payload, ctx) {
75960
76330
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
75961
76331
  if (denied) return denied;
75962
- const p3 = asRecord21(payload);
76332
+ const p3 = asRecord22(payload);
75963
76333
  const raw = typeof p3.content === "string" ? p3.content : String(p3.content ?? "");
75964
76334
  const encoding = p3.encoding === "base64" ? "base64" : "utf8";
75965
76335
  let content = raw;
@@ -75989,7 +76359,7 @@ function handleWorkspaceWriteFile(payload, ctx) {
75989
76359
  function handleWorkspaceSearch(payload, ctx) {
75990
76360
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
75991
76361
  if (denied) return denied;
75992
- const p3 = asRecord21(payload);
76362
+ const p3 = asRecord22(payload);
75993
76363
  try {
75994
76364
  return {
75995
76365
  result: ctx.workspaceFs.search(
@@ -76005,7 +76375,7 @@ function handleWorkspaceSearch(payload, ctx) {
76005
76375
  function handleWorkspaceRename(payload, ctx) {
76006
76376
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76007
76377
  if (denied) return denied;
76008
- const p3 = asRecord21(payload);
76378
+ const p3 = asRecord22(payload);
76009
76379
  try {
76010
76380
  return {
76011
76381
  result: ctx.workspaceFs.rename(
@@ -76021,7 +76391,7 @@ function handleWorkspaceRename(payload, ctx) {
76021
76391
  function handleWorkspaceMove(payload, ctx) {
76022
76392
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76023
76393
  if (denied) return denied;
76024
- const p3 = asRecord21(payload);
76394
+ const p3 = asRecord22(payload);
76025
76395
  try {
76026
76396
  return {
76027
76397
  result: ctx.workspaceFs.move(
@@ -76037,7 +76407,7 @@ function handleWorkspaceMove(payload, ctx) {
76037
76407
  function handleWorkspaceDelete(payload, ctx) {
76038
76408
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76039
76409
  if (denied) return denied;
76040
- const p3 = asRecord21(payload);
76410
+ const p3 = asRecord22(payload);
76041
76411
  try {
76042
76412
  return {
76043
76413
  result: ctx.workspaceFs.delete(
@@ -76052,7 +76422,7 @@ function handleWorkspaceDelete(payload, ctx) {
76052
76422
  function handleWorkspaceMkdir(payload, ctx) {
76053
76423
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76054
76424
  if (denied) return denied;
76055
- const p3 = asRecord21(payload);
76425
+ const p3 = asRecord22(payload);
76056
76426
  try {
76057
76427
  return {
76058
76428
  result: ctx.workspaceFs.mkdir(
@@ -76067,7 +76437,7 @@ function handleWorkspaceMkdir(payload, ctx) {
76067
76437
  function handleWorkspaceWatchStart(payload, ctx) {
76068
76438
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76069
76439
  if (denied) return denied;
76070
- const p3 = asRecord21(payload);
76440
+ const p3 = asRecord22(payload);
76071
76441
  try {
76072
76442
  const events = [];
76073
76443
  const { watchId, cancel } = ctx.workspaceWatch.subscribe(
@@ -76088,7 +76458,7 @@ function handleWorkspaceWatchStart(payload, ctx) {
76088
76458
  function handleWorkspaceWatchPoll(payload, ctx) {
76089
76459
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76090
76460
  if (denied) return denied;
76091
- const p3 = asRecord21(payload);
76461
+ const p3 = asRecord22(payload);
76092
76462
  const watchId = String(p3.watchId ?? "");
76093
76463
  const buf = watchBuffers.get(watchId);
76094
76464
  if (!buf || buf.owner !== ctx.client.clientSessionId) {
@@ -76100,7 +76470,7 @@ function handleWorkspaceWatchPoll(payload, ctx) {
76100
76470
  function handleWorkspaceWatchStop(payload, ctx) {
76101
76471
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76102
76472
  if (denied) return denied;
76103
- const p3 = asRecord21(payload);
76473
+ const p3 = asRecord22(payload);
76104
76474
  const watchId = String(p3.watchId ?? "");
76105
76475
  const buf = watchBuffers.get(watchId);
76106
76476
  if (buf && buf.owner === ctx.client.clientSessionId) {
@@ -76112,7 +76482,7 @@ function handleWorkspaceWatchStop(payload, ctx) {
76112
76482
  function handleWorkspaceTailWatchStart(payload, ctx) {
76113
76483
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76114
76484
  if (denied) return denied;
76115
- const p3 = asRecord21(payload);
76485
+ const p3 = asRecord22(payload);
76116
76486
  try {
76117
76487
  const offset = typeof p3.offset === "number" ? p3.offset : void 0;
76118
76488
  const absolutePath = typeof p3.absolutePath === "string" ? p3.absolutePath : void 0;
@@ -76130,7 +76500,7 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
76130
76500
  function handleWorkspaceTailWatchPoll(payload, ctx) {
76131
76501
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76132
76502
  if (denied) return denied;
76133
- const p3 = asRecord21(payload);
76503
+ const p3 = asRecord22(payload);
76134
76504
  try {
76135
76505
  return {
76136
76506
  result: ctx.workspaceTailWatch.poll(String(p3.watchId ?? ""), ctx.client.clientSessionId)
@@ -76142,7 +76512,7 @@ function handleWorkspaceTailWatchPoll(payload, ctx) {
76142
76512
  function handleWorkspaceTailWatchStop(payload, ctx) {
76143
76513
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76144
76514
  if (denied) return denied;
76145
- const p3 = asRecord21(payload);
76515
+ const p3 = asRecord22(payload);
76146
76516
  try {
76147
76517
  return {
76148
76518
  result: ctx.workspaceTailWatch.stop(String(p3.watchId ?? ""), ctx.client.clientSessionId)
@@ -76154,7 +76524,7 @@ function handleWorkspaceTailWatchStop(payload, ctx) {
76154
76524
  function handleGitStatus(payload, ctx) {
76155
76525
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76156
76526
  if (denied) return denied;
76157
- const p3 = asRecord21(payload);
76527
+ const p3 = asRecord22(payload);
76158
76528
  try {
76159
76529
  const projectId = String(p3.projectId ?? "");
76160
76530
  const cwd = typeof p3.cwd === "string" ? p3.cwd : null;
@@ -76168,7 +76538,7 @@ function handleGitStatus(payload, ctx) {
76168
76538
  function handleGitDiff(payload, ctx) {
76169
76539
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76170
76540
  if (denied) return denied;
76171
- const p3 = asRecord21(payload);
76541
+ const p3 = asRecord22(payload);
76172
76542
  try {
76173
76543
  return {
76174
76544
  result: ctx.workspaceGit.diff(String(p3.projectId ?? ""), {
@@ -76183,7 +76553,7 @@ function handleGitDiff(payload, ctx) {
76183
76553
  function handleGitBranches(payload, ctx) {
76184
76554
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76185
76555
  if (denied) return denied;
76186
- const p3 = asRecord21(payload);
76556
+ const p3 = asRecord22(payload);
76187
76557
  try {
76188
76558
  return {
76189
76559
  result: ctx.workspaceGit.branches(
@@ -76198,7 +76568,7 @@ function handleGitBranches(payload, ctx) {
76198
76568
  function handleGitSwitchBranch(payload, ctx) {
76199
76569
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76200
76570
  if (denied) return denied;
76201
- const p3 = asRecord21(payload);
76571
+ const p3 = asRecord22(payload);
76202
76572
  try {
76203
76573
  return {
76204
76574
  result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
@@ -76213,7 +76583,7 @@ function handleGitSwitchBranch(payload, ctx) {
76213
76583
  function handleGitCreateBranch(payload, ctx) {
76214
76584
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76215
76585
  if (denied) return denied;
76216
- const p3 = asRecord21(payload);
76586
+ const p3 = asRecord22(payload);
76217
76587
  try {
76218
76588
  return {
76219
76589
  result: ctx.workspaceGit.switchBranch(String(p3.projectId ?? ""), String(p3.branch ?? ""), {
@@ -76228,7 +76598,7 @@ function handleGitCreateBranch(payload, ctx) {
76228
76598
  function handleGitWorktrees(payload, ctx) {
76229
76599
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76230
76600
  if (denied) return denied;
76231
- const p3 = asRecord21(payload);
76601
+ const p3 = asRecord22(payload);
76232
76602
  try {
76233
76603
  return { result: ctx.workspaceGit.worktrees(String(p3.projectId ?? "")) };
76234
76604
  } catch (err) {
@@ -76238,7 +76608,7 @@ function handleGitWorktrees(payload, ctx) {
76238
76608
  function handleGitWorktreeActivate(payload, ctx) {
76239
76609
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76240
76610
  if (denied) return denied;
76241
- const p3 = asRecord21(payload);
76611
+ const p3 = asRecord22(payload);
76242
76612
  const mode = p3.mode === "attach" || p3.mode === "detach" || p3.mode === "branch" ? p3.mode : null;
76243
76613
  if (!mode) {
76244
76614
  return { error: { code: "invalid_argument", message: "mode must be branch|attach|detach" } };
@@ -76259,7 +76629,7 @@ function handleGitWorktreeActivate(payload, ctx) {
76259
76629
  function handleGitWorktreeCheckedOutBranches(payload, ctx) {
76260
76630
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76261
76631
  if (denied) return denied;
76262
- const p3 = asRecord21(payload);
76632
+ const p3 = asRecord22(payload);
76263
76633
  try {
76264
76634
  return { result: { branches: ctx.workspaceGit.checkedOutBranches(String(p3.projectId ?? "")) } };
76265
76635
  } catch (err) {
@@ -76269,7 +76639,7 @@ function handleGitWorktreeCheckedOutBranches(payload, ctx) {
76269
76639
  function handleGitWorktreeAssignBranch(payload, ctx) {
76270
76640
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76271
76641
  if (denied) return denied;
76272
- const p3 = asRecord21(payload);
76642
+ const p3 = asRecord22(payload);
76273
76643
  try {
76274
76644
  return {
76275
76645
  result: ctx.workspaceGit.assignBranch(
@@ -76285,7 +76655,7 @@ function handleGitWorktreeAssignBranch(payload, ctx) {
76285
76655
  function handleGitWorktreeHandoff(payload, ctx) {
76286
76656
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.writeWorkspace);
76287
76657
  if (denied) return denied;
76288
- const p3 = asRecord21(payload);
76658
+ const p3 = asRecord22(payload);
76289
76659
  try {
76290
76660
  return {
76291
76661
  result: ctx.workspaceGit.handoffToMain(
@@ -76300,7 +76670,7 @@ function handleGitWorktreeHandoff(payload, ctx) {
76300
76670
  function handleGitWorktreeHandoffPreview(payload, ctx) {
76301
76671
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readWorkspace);
76302
76672
  if (denied) return denied;
76303
- const p3 = asRecord21(payload);
76673
+ const p3 = asRecord22(payload);
76304
76674
  try {
76305
76675
  return {
76306
76676
  result: ctx.workspaceGit.handoffPreview(
@@ -76315,7 +76685,7 @@ function handleGitWorktreeHandoffPreview(payload, ctx) {
76315
76685
  function handleSessionSetCwd(payload, ctx) {
76316
76686
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76317
76687
  if (denied) return denied;
76318
- const p3 = asRecord21(payload);
76688
+ const p3 = asRecord22(payload);
76319
76689
  const sessionId = String(p3.sessionId ?? "");
76320
76690
  const cwdRaw = p3.cwd;
76321
76691
  const cwd = cwdRaw === null || cwdRaw === void 0 || cwdRaw === "" ? null : String(cwdRaw);
@@ -76344,7 +76714,7 @@ function handleSessionSetCwd(payload, ctx) {
76344
76714
  function handleSessionPatchSettings(payload, ctx) {
76345
76715
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76346
76716
  if (denied) return denied;
76347
- const p3 = asRecord21(payload);
76717
+ const p3 = asRecord22(payload);
76348
76718
  const sessionId = String(p3.sessionId ?? "").trim();
76349
76719
  if (!sessionId) {
76350
76720
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76360,7 +76730,7 @@ function handleSessionPatchSettings(payload, ctx) {
76360
76730
  generation: String(p3.generation ?? ""),
76361
76731
  holderClientId: ctx.client.clientSessionId
76362
76732
  });
76363
- const settingsSrc = asRecord21(p3.settings ?? p3);
76733
+ const settingsSrc = asRecord22(p3.settings ?? p3);
76364
76734
  const patch = {};
76365
76735
  const take = (key) => {
76366
76736
  if (!(key in settingsSrc)) return;
@@ -76386,7 +76756,7 @@ function handleSessionPatchSettings(payload, ctx) {
76386
76756
  async function handleSessionFork(payload, ctx) {
76387
76757
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76388
76758
  if (denied) return denied;
76389
- const p3 = asRecord21(payload);
76759
+ const p3 = asRecord22(payload);
76390
76760
  const sessionId = String(p3.sessionId ?? "").trim();
76391
76761
  if (!sessionId) {
76392
76762
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76473,7 +76843,7 @@ async function handleSessionFork(payload, ctx) {
76473
76843
  async function handleGitClone(payload, ctx) {
76474
76844
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
76475
76845
  if (denied) return denied;
76476
- const p3 = asRecord21(payload);
76846
+ const p3 = asRecord22(payload);
76477
76847
  try {
76478
76848
  const cloned = await cloneRepository({
76479
76849
  remoteUrl: String(p3.remoteUrl ?? ""),
@@ -76489,7 +76859,7 @@ async function handleGitClone(payload, ctx) {
76489
76859
  function handleSessionCreate(payload, ctx) {
76490
76860
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76491
76861
  if (denied) return denied;
76492
- const p3 = asRecord21(payload);
76862
+ const p3 = asRecord22(payload);
76493
76863
  const rawHarnessId = typeof p3.harnessId === "string" ? p3.harnessId : "claude";
76494
76864
  const harnessId = normalizeSessionHarnessId(rawHarnessId);
76495
76865
  if (!harnessId) {
@@ -76542,7 +76912,7 @@ function handleSessionCreate(payload, ctx) {
76542
76912
  try {
76543
76913
  const agentSettings = loadNodeAgentSettings(ctx.settingsConfigPath);
76544
76914
  const defaults = resolveAgentTurnDefaults(agentSettings, harnessId);
76545
- const options = asRecord21(p3.options);
76915
+ const options = asRecord22(p3.options);
76546
76916
  const providerId = typeof p3.providerId === "string" && p3.providerId.trim() ? p3.providerId.trim() : void 0;
76547
76917
  const profile = providerId ? ctx.sessionProviders.get(providerId) : null;
76548
76918
  const profileSettings = profile ? settingsFromSessionProviderConfig(profile.config) : {};
@@ -76603,7 +76973,7 @@ function handleSessionCreate(payload, ctx) {
76603
76973
  function handleSessionGet(payload, ctx) {
76604
76974
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76605
76975
  if (denied) return denied;
76606
- const p3 = asRecord21(payload);
76976
+ const p3 = asRecord22(payload);
76607
76977
  return { result: ctx.sessions.get(String(p3.sessionId ?? "")) };
76608
76978
  }
76609
76979
  function mapSessionRow(s4) {
@@ -76632,7 +77002,7 @@ function mapSessionRow(s4) {
76632
77002
  function handleSessionList(payload, ctx) {
76633
77003
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76634
77004
  if (denied) return denied;
76635
- const p3 = asRecord21(payload);
77005
+ const p3 = asRecord22(payload);
76636
77006
  const projectId = typeof p3.projectId === "string" ? p3.projectId : void 0;
76637
77007
  if (typeof p3.limit !== "number" || !Number.isFinite(p3.limit)) {
76638
77008
  return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
@@ -76648,7 +77018,7 @@ function handleSessionList(payload, ctx) {
76648
77018
  function handleSessionListPinned(payload, ctx) {
76649
77019
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
76650
77020
  if (denied) return denied;
76651
- const p3 = asRecord21(payload);
77021
+ const p3 = asRecord22(payload);
76652
77022
  const limit = typeof p3.limit === "number" && Number.isFinite(p3.limit) ? Math.min(Math.max(Math.floor(p3.limit), 0), 500) : 200;
76653
77023
  const rows = ctx.sessions.list(void 0).filter((s4) => s4.isPinned === true && s4.isHidden !== true).slice(0, limit);
76654
77024
  return {
@@ -76665,7 +77035,7 @@ function handleSessionListPinned(payload, ctx) {
76665
77035
  function handleSessionAcquireControl(payload, ctx) {
76666
77036
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76667
77037
  if (denied) return denied;
76668
- const p3 = asRecord21(payload);
77038
+ const p3 = asRecord22(payload);
76669
77039
  const sessionId = String(p3.sessionId ?? "");
76670
77040
  if (!sessionId) {
76671
77041
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76689,7 +77059,7 @@ function handleSessionAcquireControl(payload, ctx) {
76689
77059
  function handleSessionRenewControl(payload, ctx) {
76690
77060
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76691
77061
  if (denied) return denied;
76692
- const p3 = asRecord21(payload);
77062
+ const p3 = asRecord22(payload);
76693
77063
  try {
76694
77064
  return {
76695
77065
  result: ctx.leases.renew({
@@ -76706,7 +77076,7 @@ function handleSessionRenewControl(payload, ctx) {
76706
77076
  function handleSessionReleaseControl(payload, ctx) {
76707
77077
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76708
77078
  if (denied) return denied;
76709
- const p3 = asRecord21(payload);
77079
+ const p3 = asRecord22(payload);
76710
77080
  try {
76711
77081
  ctx.leases.release(
76712
77082
  String(p3.leaseId ?? ""),
@@ -76721,7 +77091,7 @@ function handleSessionReleaseControl(payload, ctx) {
76721
77091
  function handleSessionClose(payload, ctx) {
76722
77092
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76723
77093
  if (denied) return denied;
76724
- const p3 = asRecord21(payload);
77094
+ const p3 = asRecord22(payload);
76725
77095
  const sessionId = String(p3.sessionId ?? "");
76726
77096
  try {
76727
77097
  ctx.leases.assertValid({
@@ -76747,7 +77117,7 @@ function handleSessionClose(payload, ctx) {
76747
77117
  function handleSessionRemove(payload, ctx) {
76748
77118
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76749
77119
  if (denied) return denied;
76750
- const p3 = asRecord21(payload);
77120
+ const p3 = asRecord22(payload);
76751
77121
  const sessionId = String(p3.sessionId ?? "");
76752
77122
  if (!sessionId) {
76753
77123
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76774,7 +77144,7 @@ function handleSessionRemove(payload, ctx) {
76774
77144
  function handleSessionRename(payload, ctx) {
76775
77145
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76776
77146
  if (denied) return denied;
76777
- const p3 = asRecord21(payload);
77147
+ const p3 = asRecord22(payload);
76778
77148
  const sessionId = String(p3.sessionId ?? "");
76779
77149
  const title = String(p3.title ?? "");
76780
77150
  const source = p3.source === "agent" ? "agent" : "user";
@@ -76790,7 +77160,7 @@ function handleSessionRename(payload, ctx) {
76790
77160
  function handleSessionSetTags(payload, ctx) {
76791
77161
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76792
77162
  if (denied) return denied;
76793
- const p3 = asRecord21(payload);
77163
+ const p3 = asRecord22(payload);
76794
77164
  const sessionId = String(p3.sessionId ?? "");
76795
77165
  if (!sessionId) {
76796
77166
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76816,7 +77186,7 @@ function handleSessionSetTags(payload, ctx) {
76816
77186
  function handleSessionSetUiFlags(payload, ctx) {
76817
77187
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76818
77188
  if (denied) return denied;
76819
- const p3 = asRecord21(payload);
77189
+ const p3 = asRecord22(payload);
76820
77190
  const sessionId = String(p3.sessionId ?? "");
76821
77191
  if (!sessionId) {
76822
77192
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -76835,9 +77205,9 @@ function handleSessionSetUiFlags(payload, ctx) {
76835
77205
  async function handleSessionSend(payload, ctx) {
76836
77206
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76837
77207
  if (denied) return denied;
76838
- const p3 = asRecord21(payload);
77208
+ const p3 = asRecord22(payload);
76839
77209
  try {
76840
- const options = asRecord21(p3.options);
77210
+ const options = asRecord22(p3.options);
76841
77211
  const modelFromOptions = typeof options.model === "string" && options.model.trim() ? options.model.trim() : null;
76842
77212
  const modelTopLevel = typeof p3.model === "string" && p3.model.trim() ? p3.model.trim() : null;
76843
77213
  const apiProviderId = typeof options.apiProviderId === "string" && options.apiProviderId.trim() ? options.apiProviderId.trim() : typeof p3.apiProviderId === "string" && p3.apiProviderId.trim() ? p3.apiProviderId.trim() : null;
@@ -76934,7 +77304,7 @@ async function handleSessionSend(payload, ctx) {
76934
77304
  function handleSessionInterrupt(payload, ctx) {
76935
77305
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76936
77306
  if (denied) return denied;
76937
- const p3 = asRecord21(payload);
77307
+ const p3 = asRecord22(payload);
76938
77308
  try {
76939
77309
  ctx.sessions.interrupt(
76940
77310
  String(p3.sessionId ?? ""),
@@ -76950,7 +77320,7 @@ function handleSessionInterrupt(payload, ctx) {
76950
77320
  function handleSessionRespondPermission(payload, ctx) {
76951
77321
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76952
77322
  if (denied) return denied;
76953
- const p3 = asRecord21(payload);
77323
+ const p3 = asRecord22(payload);
76954
77324
  try {
76955
77325
  const formAnswers = p3.formAnswers && typeof p3.formAnswers === "object" && !Array.isArray(p3.formAnswers) ? p3.formAnswers : p3.options && typeof p3.options === "object" && !Array.isArray(p3.options) ? p3.options.formAnswers ?? p3.options : void 0;
76956
77326
  ctx.sessions.respondPermission({
@@ -76971,7 +77341,7 @@ function handleSessionRespondPermission(payload, ctx) {
76971
77341
  function handleSessionRespondQuestion(payload, ctx) {
76972
77342
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76973
77343
  if (denied) return denied;
76974
- const p3 = asRecord21(payload);
77344
+ const p3 = asRecord22(payload);
76975
77345
  try {
76976
77346
  ctx.sessions.respondQuestion({
76977
77347
  sessionId: String(p3.sessionId ?? ""),
@@ -76989,7 +77359,7 @@ function handleSessionRespondQuestion(payload, ctx) {
76989
77359
  function handleSessionRespondPlan(payload, ctx) {
76990
77360
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
76991
77361
  if (denied) return denied;
76992
- const p3 = asRecord21(payload);
77362
+ const p3 = asRecord22(payload);
76993
77363
  const decision = p3.decision === "approve" || p3.decision === "reject" ? p3.decision : null;
76994
77364
  if (!decision) {
76995
77365
  return { error: { code: "invalid_argument", message: "decision must be approve|reject" } };
@@ -77012,7 +77382,7 @@ function handleSessionRespondPlan(payload, ctx) {
77012
77382
  async function handleSessionHostActionsPoll(payload, ctx) {
77013
77383
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77014
77384
  if (denied) return denied;
77015
- const p3 = asRecord21(payload);
77385
+ const p3 = asRecord22(payload);
77016
77386
  try {
77017
77387
  const result = await ctx.sessions.pollHostActions({
77018
77388
  controllerClientSessionId: ctx.client.clientSessionId,
@@ -77028,7 +77398,7 @@ async function handleSessionHostActionsPoll(payload, ctx) {
77028
77398
  function handleSessionClaimHostAction(payload, ctx) {
77029
77399
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77030
77400
  if (denied) return denied;
77031
- const p3 = asRecord21(payload);
77401
+ const p3 = asRecord22(payload);
77032
77402
  try {
77033
77403
  const result = ctx.sessions.claimHostAction({
77034
77404
  actionId: String(p3.actionId ?? ""),
@@ -77044,7 +77414,7 @@ function handleSessionClaimHostAction(payload, ctx) {
77044
77414
  function handleSessionRespondHostAction(payload, ctx) {
77045
77415
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77046
77416
  if (denied) return denied;
77047
- const p3 = asRecord21(payload);
77417
+ const p3 = asRecord22(payload);
77048
77418
  const outcome = p3.outcome === "failed" ? "failed" : p3.outcome === "succeeded" ? "succeeded" : null;
77049
77419
  if (!outcome) {
77050
77420
  return { error: { code: "invalid_argument", message: "outcome must be succeeded|failed" } };
@@ -77066,14 +77436,14 @@ function handleSessionRespondHostAction(payload, ctx) {
77066
77436
  function handleSessionEvents(payload, ctx) {
77067
77437
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77068
77438
  if (denied) return denied;
77069
- const p3 = asRecord21(payload);
77439
+ const p3 = asRecord22(payload);
77070
77440
  const after = String(p3.afterSequence ?? "0");
77071
77441
  return { result: { events: ctx.sessions.listEventsAfter(after) } };
77072
77442
  }
77073
77443
  function handleSessionMessagesList(payload, ctx) {
77074
77444
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77075
77445
  if (denied) return denied;
77076
- const p3 = asRecord21(payload);
77446
+ const p3 = asRecord22(payload);
77077
77447
  const sessionId = String(p3.sessionId ?? "").trim();
77078
77448
  if (!sessionId) {
77079
77449
  return { error: { code: "invalid_argument", message: "sessionId required" } };
@@ -77112,7 +77482,7 @@ function handleCollaborationListProfiles(ctx) {
77112
77482
  async function handleCollaborationRequest(payload, ctx) {
77113
77483
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77114
77484
  if (denied) return denied;
77115
- const p3 = asRecord21(payload);
77485
+ const p3 = asRecord22(payload);
77116
77486
  const parentSessionId = String(p3.parentSessionId ?? "");
77117
77487
  if (!parentSessionId) {
77118
77488
  return { error: { code: "invalid_argument", message: "parentSessionId required" } };
@@ -77146,7 +77516,7 @@ async function handleCollaborationRequest(payload, ctx) {
77146
77516
  async function handleCollaborationStart(payload, ctx) {
77147
77517
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77148
77518
  if (denied) return denied;
77149
- const p3 = asRecord21(payload);
77519
+ const p3 = asRecord22(payload);
77150
77520
  const credential = typeof p3.credential === "string" ? p3.credential : void 0;
77151
77521
  const grantId = typeof p3.grantId === "string" ? p3.grantId : void 0;
77152
77522
  if (!credential && !grantId) {
@@ -77192,7 +77562,7 @@ async function handleCollaborationStart(payload, ctx) {
77192
77562
  function handleCollaborationSend(payload, ctx) {
77193
77563
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.operateSession);
77194
77564
  if (denied) return denied;
77195
- const p3 = asRecord21(payload);
77565
+ const p3 = asRecord22(payload);
77196
77566
  const credential = String(p3.credential ?? "");
77197
77567
  const sessionId = String(p3.sessionId ?? p3.fromSessionId ?? "");
77198
77568
  const content = typeof p3.content === "string" ? p3.content : p3.body !== void 0 ? typeof p3.body === "string" ? p3.body : JSON.stringify(p3.body) : "";
@@ -77228,7 +77598,7 @@ function handleCollaborationSend(payload, ctx) {
77228
77598
  function handleCollaborationRetrieve(payload, ctx) {
77229
77599
  const denied = requireScopes7(ctx.client, OPERATION_SCOPES.readSession);
77230
77600
  if (denied) return denied;
77231
- const p3 = asRecord21(payload);
77601
+ const p3 = asRecord22(payload);
77232
77602
  const credential = String(p3.credential ?? "");
77233
77603
  const sessionId = String(p3.sessionId ?? "");
77234
77604
  if (!credential) {