@sideboard-ai/core 0.1.53 → 0.1.56

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 (30) hide show
  1. package/dist/agents/cursor-runner.cjs +83 -7
  2. package/dist/agents/cursor-runner.js +1 -1
  3. package/dist/{agents-KYACODJ3.js → agents-2YYWW723.js} +3 -3
  4. package/dist/{agents-KP7UJEHJ.js → agents-AQFEFKBL.js} +2 -2
  5. package/dist/{app-settings-LZP632KI.js → app-settings-2LQNRTBE.js} +3 -1
  6. package/dist/{app-settings-7XVDQJ7F.js → app-settings-73DI4B6T.js} +3 -1
  7. package/dist/{chunk-VG22SETP.js → chunk-3WJAUKIL.js} +83 -7
  8. package/dist/{chunk-GNML24AW.js → chunk-5DMYULLC.js} +1 -1
  9. package/dist/{chunk-A6HVEMIB.js → chunk-7F454EE2.js} +86 -11
  10. package/dist/{chunk-BZST4HMJ.js → chunk-C3J4GDW4.js} +172 -21
  11. package/dist/{chunk-HBJSHRY2.js → chunk-C4BCC5X5.js} +17 -1
  12. package/dist/{chunk-T5QQVXK3.js → chunk-DIOF73S2.js} +17 -1
  13. package/dist/{chunk-UEAHMGHW.js → chunk-DQJ5D42H.js} +16 -2
  14. package/dist/{chunk-YOWIYAVA.js → chunk-EBWEKG52.js} +36 -11
  15. package/dist/{chunk-XX5BB7NV.js → chunk-S42XDFKF.js} +36 -11
  16. package/dist/{chunk-LRLKJM3O.js → chunk-UA5NDAHL.js} +16 -2
  17. package/dist/{chunk-YDXQ72MD.js → chunk-V2DUTUNC.js} +1 -1
  18. package/dist/{coordinator-prompt-S6JZD5EF.js → coordinator-prompt-ICF36NUQ.js} +2 -1
  19. package/dist/{coordinator-prompt-6FXVTSFN.js → coordinator-prompt-RBKUNRPR.js} +2 -1
  20. package/dist/{global-workspace-EV4G2WMQ.js → global-workspace-667XLBW6.js} +3 -2
  21. package/dist/{global-workspace-MSX2K27Y.js → global-workspace-S7VLWPWG.js} +3 -2
  22. package/dist/index.cjs +298 -50
  23. package/dist/index.d.cts +24 -2
  24. package/dist/index.d.ts +24 -2
  25. package/dist/index.js +81 -35
  26. package/dist/mcp/run-stdio.cjs +292 -46
  27. package/dist/mcp/run-stdio.js +81 -36
  28. package/dist/{workspaces-AYTBR6KQ.js → workspaces-FPJJXXAE.js} +4 -3
  29. package/dist/{workspaces-3RQQZQRO.js → workspaces-LYIDE2VR.js} +4 -3
  30. package/package.json +1 -1
@@ -2974,6 +2974,7 @@ __export(app_settings_exports, {
2974
2974
  orchestrationQuotaOnLimit: () => orchestrationQuotaOnLimit,
2975
2975
  resolveClaudeExecutable: () => resolveClaudeExecutable,
2976
2976
  resolveEffectiveIssueSource: () => resolveEffectiveIssueSource,
2977
+ resolveNewThreadOptions: () => resolveNewThreadOptions,
2977
2978
  resolveThreadDefaults: () => resolveThreadDefaults,
2978
2979
  saveAppSettings: () => saveAppSettings,
2979
2980
  updateAdvancedSettings: () => updateAdvancedSettings,
@@ -3266,6 +3267,16 @@ function resolveThreadDefaults(settings = loadAppSettings()) {
3266
3267
  fast: getDefaultFast(settings)
3267
3268
  };
3268
3269
  }
3270
+ function resolveNewThreadOptions(overrides = {}, settings = loadAppSettings()) {
3271
+ const defaults = resolveThreadDefaults(settings);
3272
+ const effort = overrides.effort === void 0 || overrides.effort === null ? defaults.effort : normalizeThinkingEffort(overrides.effort) ?? defaults.effort;
3273
+ return {
3274
+ agent: overrides.agent ?? defaults.agent,
3275
+ model: overrides.model === void 0 ? defaults.model : overrides.model?.trim() || null,
3276
+ effort,
3277
+ fast: overrides.fast === void 0 || overrides.fast === null ? defaults.fast : Boolean(overrides.fast)
3278
+ };
3279
+ }
3269
3280
  function isLinearConnected(settings = loadAppSettings()) {
3270
3281
  return Boolean(settings.integrations.linearApiKey?.trim());
3271
3282
  }
@@ -3285,7 +3296,12 @@ function brightsyCloudConnectEnabled(settings = loadAppSettings()) {
3285
3296
  return Boolean(settings.brightsy.cloudConnectEnabled);
3286
3297
  }
3287
3298
  function brightsyCloudConnectAgent(settings = loadAppSettings()) {
3288
- return settings.brightsy.cloudConnectAgent ?? "claude";
3299
+ const fallback = settings.brightsy.cloudConnectAgent && CLOUD_CONNECT_AGENTS.has(settings.brightsy.cloudConnectAgent) ? settings.brightsy.cloudConnectAgent : "claude";
3300
+ const preferred = getDefaultAgent(settings);
3301
+ if (CLOUD_CONNECT_AGENTS.has(preferred)) {
3302
+ return preferred;
3303
+ }
3304
+ return fallback;
3289
3305
  }
3290
3306
  function updateAdvancedSettings(patch) {
3291
3307
  const current = loadAppSettings();
@@ -3533,6 +3549,11 @@ function coordinatorGreenfieldPlaybook(reposDir) {
3533
3549
  "- Do coding work in the child worktree thread, not by editing files in this home cwd."
3534
3550
  ].join("\n");
3535
3551
  }
3552
+ function accountDefaultsPlaybookLine() {
3553
+ const d = resolveThreadDefaults();
3554
+ const model = d.model?.trim() || "Auto";
3555
+ return `- Account defaults for create_thread (omit agent/model to use these): agent=${d.agent}, model=${model}, effort=${d.effort}`;
3556
+ }
3536
3557
  function coordinatorTurnReminder(opts) {
3537
3558
  const goal = opts.goal?.trim();
3538
3559
  return [
@@ -3542,6 +3563,7 @@ function coordinatorTurnReminder(opts) {
3542
3563
  "- Registered workspaces / child threads are the fleet you manage via Sideboard MCP.",
3543
3564
  `- Parent thread id (pass as parentThreadId when creating children): ${opts.parentId}`,
3544
3565
  goal ? `- Goal / title: ${goal}` : null,
3566
+ accountDefaultsPlaybookLine(),
3545
3567
  `- For "what's going on": call list_threads (and list_workspaces if needed). Summarize fleet status \u2014 do not ls/git-status this synthetic home.`,
3546
3568
  "- Existing repo: create_thread on a repoPath \u2192 send_to_thread \u2192 wait_for_turn.",
3547
3569
  "- New repo: Bash (clone or gh repo create under ~/sideboard/repos/<name>) \u2192 add_workspace \u2192 create_thread \u2192 send_to_thread \u2192 wait_for_turn \u2192 draft PR.",
@@ -3564,9 +3586,12 @@ function ensureGlobalCoordinatorCwd() {
3564
3586
  "",
3565
3587
  COORDINATOR_TOOL_PLAYBOOK,
3566
3588
  "",
3589
+ accountDefaultsPlaybookLine(),
3590
+ "",
3567
3591
  coordinatorGreenfieldPlaybook(reposDir),
3568
3592
  "",
3569
3593
  "When creating threads, pass `repoPath` from `list_workspaces` (or the path you just registered) and `parentThreadId` for children.",
3594
+ "Omit `agent` / `model` on `create_thread` unless you have a reason to override Account defaults.",
3570
3595
  "Typical flow (existing): list_workspaces \u2192 list_branches|list_prs|list_issues \u2192 create_thread \u2192 send_to_thread \u2192 wait_for_turn.",
3571
3596
  "Typical flow (new app): Bash create/clone under repos dir \u2192 add_workspace \u2192 create_thread \u2192 send_to_thread (implement) \u2192 wait_for_turn \u2192 draft PR via worktree agent.",
3572
3597
  "Always ask worktree agents to open draft PRs (`send_to_thread` + `gh pr create --draft -R <origin>`); never open PRs from the orchestrator."
@@ -3592,8 +3617,10 @@ function coordinatorSystemPrompt(opts) {
3592
3617
  "You operate across ALL registered workspaces below.",
3593
3618
  "You have no project git home \u2014 this process cwd is synthetic and empty on purpose.",
3594
3619
  COORDINATOR_TOOL_PLAYBOOK,
3620
+ accountDefaultsPlaybookLine(),
3595
3621
  coordinatorGreenfieldPlaybook(reposDir),
3596
3622
  "When creating threads, pass the correct repoPath for the target workspace and parentThreadId for children.",
3623
+ "Omit agent/model on create_thread unless you need to override Account defaults.",
3597
3624
  "Typical flow (existing): list_workspaces \u2192 list_branches|list_prs|list_issues \u2192 create_thread \u2192 send_to_thread (implement) \u2192 wait_for_turn \u2192 send_to_thread (ask for `gh pr create --draft -R <origin-owner/name>` using the workspace github slug) \u2192 wait_for_turn. Never target upstream. Never open PRs from the orchestrator.",
3598
3625
  "Typical flow (new app): Bash under repos dir (clone or gh repo create) \u2192 add_workspace \u2192 create_thread \u2192 send_to_thread \u2192 wait_for_turn \u2192 draft PR via worktree agent.",
3599
3626
  `Goal: ${opts.goal}`,
@@ -3609,6 +3636,7 @@ var init_coordinator_prompt = __esm({
3609
3636
  import_node_fs6 = require("fs");
3610
3637
  import_node_path7 = require("path");
3611
3638
  init_worktree();
3639
+ init_app_settings();
3612
3640
  init_paths();
3613
3641
  COORDINATOR_TOOL_PLAYBOOK = [
3614
3642
  "Role: you oversee Sideboard worktree agents across registered repos. You do not live inside one of those worktrees.",
@@ -3617,12 +3645,12 @@ var init_coordinator_prompt = __esm({
3617
3645
  "- list_workspaces \u2014 registered repos (path + github slug when known)",
3618
3646
  "- list_branches / list_prs / list_issues \u2014 pass repoPath from list_workspaces (issues: Linear API or GitHub Issues)",
3619
3647
  "- get_pr_stack / open_pr_stack_layers / add_stack_layer / create_pr_stack \u2014 GitHub stacked PRs (`gh stack`); one worktree per layer",
3620
- "- list_models \u2014 only when you need a specific model (rare); otherwise leave model unset = Auto",
3648
+ "- list_models \u2014 only when you need a specific model (rare); otherwise omit model so Account defaults apply",
3621
3649
  "- list_threads / get_thread \u2014 fleet status (what is going on)",
3622
3650
  "Workspaces:",
3623
3651
  "- add_workspace / remove_workspace \u2014 register or unregister a git repo",
3624
3652
  "Worktree threads (chats):",
3625
- "- create_thread \u2014 create a worktree + chat from branch | pr | ticket; pass repoPath + parentThreadId",
3653
+ "- create_thread \u2014 create a worktree + chat from branch | pr | ticket; pass repoPath + parentThreadId; omit agent and model to use Sideboard Account defaults (Settings \u2192 Default agent, model & effort)",
3626
3654
  "- fork_worktree \u2014 fork a worktree chat into a NEW git worktree + chat (transcript attached); optional agent; leave model unset (Auto) unless you have a reason. Not for orchestration chats.",
3627
3655
  "- fork_chat \u2014 fork a worktree chat (same worktree tab) OR a Global orchestration chat (new orchestration tab); optional agent; leave model unset (Auto) unless you have a reason. Remote coordinators: use this to continue another orchestration chat on a different agent after session limits.",
3628
3656
  "- send_to_thread \u2014 queue a prompt (start/continue a chat turn); pass force_stop: true to interrupt mid-turn / clear stale queued prompts before replacing with a new request",
@@ -3722,7 +3750,13 @@ function createGlobalChat(opts) {
3722
3750
  const explicit = opts.title?.trim();
3723
3751
  const title = explicit && explicit !== CLOUD_ORCHESTRATOR_GOAL ? explicit : allocateTeamName(takenTeamSlugsForOrchestration()).name;
3724
3752
  const sourceRef = opts.sourceRef?.trim() || (isCloud ? CLOUD_ORCHESTRATOR_GOAL : title);
3725
- const agent = assertOrchestratorCapableAgent(opts.agent);
3753
+ const resolved = resolveNewThreadOptions({
3754
+ agent: opts.agent,
3755
+ model: opts.model,
3756
+ effort: opts.effort,
3757
+ fast: opts.fast
3758
+ });
3759
+ const agent = assertOrchestratorCapableAgent(resolved.agent);
3726
3760
  const thread = createEmptyThread({
3727
3761
  title,
3728
3762
  // Stick nicknames the same way chat tabs do (avoid later sync overwrites).
@@ -3734,9 +3768,9 @@ function createGlobalChat(opts) {
3734
3768
  repoPath: GLOBAL_WORKSPACE_ID,
3735
3769
  agent,
3736
3770
  autonomy: opts.autonomy ?? "default",
3737
- model: opts.model ?? null,
3738
- effort: opts.effort ?? "high",
3739
- fast: Boolean(opts.fast),
3771
+ model: resolved.model,
3772
+ effort: resolved.effort,
3773
+ fast: resolved.fast,
3740
3774
  planMode: Boolean(opts.planMode),
3741
3775
  attachments: opts.attachments ?? [],
3742
3776
  parentThreadId: opts.parentThreadId ?? null,
@@ -3769,20 +3803,35 @@ function findCloudCoordinator() {
3769
3803
  );
3770
3804
  }
3771
3805
  function ensureCloudCoordinator(agent) {
3806
+ const defaults = resolveThreadDefaults();
3807
+ const desired = assertOrchestratorCapableAgent(agent);
3772
3808
  const existing = findCloudCoordinator();
3773
3809
  if (existing) {
3810
+ const patch = {};
3774
3811
  if (existing.repoPath !== GLOBAL_WORKSPACE_ID) {
3775
- return updateThread(existing.id, {
3776
- repoPath: GLOBAL_WORKSPACE_ID,
3777
- worktreePath: globalAgentCwd(),
3778
- branchName: "global"
3779
- });
3812
+ patch.repoPath = GLOBAL_WORKSPACE_ID;
3813
+ patch.worktreePath = globalAgentCwd();
3814
+ patch.branchName = "global";
3815
+ }
3816
+ const hasAgentTurns = existing.messages.some((m) => m.role === "agent");
3817
+ const canRetarget = !existing.sessionId && !hasAgentTurns && existing.status !== "running" && existing.status !== "queued";
3818
+ if (canRetarget) {
3819
+ if (existing.agent !== desired) patch.agent = desired;
3820
+ if (existing.model !== defaults.model) patch.model = defaults.model;
3821
+ if (existing.effort !== defaults.effort) patch.effort = defaults.effort;
3822
+ if (existing.fast !== defaults.fast) patch.fast = defaults.fast;
3823
+ }
3824
+ if (Object.keys(patch).length > 0) {
3825
+ return updateThread(existing.id, patch);
3780
3826
  }
3781
3827
  return existing;
3782
3828
  }
3783
3829
  const created = createGlobalChat({
3784
3830
  sourceRef: CLOUD_ORCHESTRATOR_GOAL,
3785
- agent
3831
+ agent: desired,
3832
+ model: defaults.model,
3833
+ effort: defaults.effort,
3834
+ fast: defaults.fast
3786
3835
  });
3787
3836
  const all = listThreads({ includeArchived: true }).filter(
3788
3837
  (t) => t.status !== "archived" && isCloudCoordinatorThread(t)
@@ -3797,6 +3846,7 @@ var init_global_workspace = __esm({
3797
3846
  init_orchestrator_capable();
3798
3847
  init_teams();
3799
3848
  init_coordinator_prompt();
3849
+ init_app_settings();
3800
3850
  init_paths();
3801
3851
  init_thread_store();
3802
3852
  GLOBAL_WORKSPACE_ID = "__global__";
@@ -4551,6 +4601,7 @@ function toCodexMcpConfigArgs(servers) {
4551
4601
  args.push("-c", `${prefix}.env.${key}=${JSON.stringify(value)}`);
4552
4602
  }
4553
4603
  }
4604
+ args.push("-c", `${prefix}.default_tools_approval_mode=${JSON.stringify("approve")}`);
4554
4605
  }
4555
4606
  return args;
4556
4607
  }
@@ -5059,6 +5110,32 @@ function codexConfigHasNetworkAccess() {
5059
5110
  }
5060
5111
  return false;
5061
5112
  }
5113
+ function unwrapCodexMcpResult(result) {
5114
+ if (result == null) return void 0;
5115
+ if (typeof result === "string") return result;
5116
+ if (typeof result !== "object") return String(result);
5117
+ const rec = result;
5118
+ if (Array.isArray(rec.content)) {
5119
+ const texts = [];
5120
+ for (const item of rec.content) {
5121
+ if (!item || typeof item !== "object") continue;
5122
+ const text = item.text;
5123
+ if (typeof text === "string") texts.push(text);
5124
+ }
5125
+ if (texts.length) return texts.join("\n");
5126
+ }
5127
+ try {
5128
+ return JSON.stringify(result);
5129
+ } catch {
5130
+ return String(result);
5131
+ }
5132
+ }
5133
+ function asRecord(value) {
5134
+ if (value && typeof value === "object" && !Array.isArray(value)) {
5135
+ return value;
5136
+ }
5137
+ return void 0;
5138
+ }
5062
5139
  var import_node_fs11, import_node_os7, import_node_path11, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
5063
5140
  var init_codex = __esm({
5064
5141
  "src/agents/codex.ts"() {
@@ -5171,15 +5248,49 @@ var init_codex = __esm({
5171
5248
  }
5172
5249
  if (typeof obj.item === "object" && obj.item !== null) {
5173
5250
  const item = obj.item;
5174
- if (item.type === "error") {
5251
+ const itemType = item.type ?? item.item_type;
5252
+ if (itemType === "error") {
5175
5253
  const detail = item.message?.trim() || extractJsonErrorMessage(obj) || "Codex item error";
5176
5254
  return { type: "stderr", data: detail };
5177
5255
  }
5178
- if (item.type === "agent_message" && item.text) {
5256
+ if (itemType === "agent_message" && item.text) {
5179
5257
  return { type: "stdout", data: item.text };
5180
5258
  }
5259
+ if (itemType === "mcp_tool_call" && item.id && item.server && item.tool) {
5260
+ const name = `mcp__${item.server}__${item.tool}`;
5261
+ const input = asRecord(item.arguments);
5262
+ const events = [
5263
+ { type: "tool_use", id: item.id, name, input }
5264
+ ];
5265
+ const finished = type === "item.completed" || item.status === "completed" || item.status === "failed";
5266
+ if (finished) {
5267
+ const errMsg = item.error && typeof item.error.message === "string" ? item.error.message : void 0;
5268
+ events.push({
5269
+ type: "tool_result",
5270
+ id: item.id,
5271
+ content: unwrapCodexMcpResult(item.result) ?? errMsg,
5272
+ isError: item.status === "failed" || Boolean(errMsg)
5273
+ });
5274
+ }
5275
+ return events.length === 1 ? events[0] : events;
5276
+ }
5277
+ if (itemType === "command_execution" && item.id) {
5278
+ const input = item.command ? { command: item.command } : void 0;
5279
+ const events = [
5280
+ { type: "tool_use", id: item.id, name: "Bash", input }
5281
+ ];
5282
+ if (type === "item.completed" || item.status === "completed" || item.status === "failed") {
5283
+ events.push({
5284
+ type: "tool_result",
5285
+ id: item.id,
5286
+ content: item.aggregated_output,
5287
+ isError: item.status === "failed"
5288
+ });
5289
+ }
5290
+ return events.length === 1 ? events[0] : events;
5291
+ }
5181
5292
  if (item.status === "failed") {
5182
- const detail = item.message?.trim() || extractJsonErrorMessage(item) || `Codex ${item.type ?? "item"} failed`;
5293
+ const detail = item.message?.trim() || extractJsonErrorMessage(item) || `Codex ${itemType ?? "item"} failed`;
5183
5294
  return { type: "stderr", data: detail };
5184
5295
  }
5185
5296
  }
@@ -5265,6 +5376,75 @@ function usageFromCursor(usage) {
5265
5376
  cacheWriteTokens: usage.cacheWriteTokens ? Number(usage.cacheWriteTokens) : void 0
5266
5377
  };
5267
5378
  }
5379
+ function asRecord2(value) {
5380
+ if (value && typeof value === "object" && !Array.isArray(value)) {
5381
+ return value;
5382
+ }
5383
+ return void 0;
5384
+ }
5385
+ function normalizeCursorToolCall(name, args) {
5386
+ const raw = asRecord2(args);
5387
+ const toolName = typeof raw?.toolName === "string" && raw.toolName.trim() ? raw.toolName.trim() : null;
5388
+ const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" || asRecord2(raw?.args) != null);
5389
+ if (looksLikeMcp && toolName) {
5390
+ const providerRaw = typeof raw.providerIdentifier === "string" && raw.providerIdentifier.trim() ? raw.providerIdentifier.trim() : "sideboard";
5391
+ const provider = providerRaw.replace(/[^a-zA-Z0-9_-]/g, "_");
5392
+ const nested = asRecord2(raw.args);
5393
+ return {
5394
+ name: `mcp__${provider}__${toolName}`,
5395
+ input: nested ?? { toolName }
5396
+ };
5397
+ }
5398
+ return { name, input: raw };
5399
+ }
5400
+ function unwrapCursorToolResult(result) {
5401
+ if (result == null) return void 0;
5402
+ if (typeof result === "string") return result;
5403
+ const rec = asRecord2(result);
5404
+ if (!rec) {
5405
+ try {
5406
+ return JSON.stringify(result);
5407
+ } catch {
5408
+ return String(result);
5409
+ }
5410
+ }
5411
+ const collectTexts = (items) => {
5412
+ const texts = [];
5413
+ for (const item of items) {
5414
+ const row = asRecord2(item);
5415
+ if (!row) continue;
5416
+ if (typeof row.text === "string") {
5417
+ texts.push(row.text);
5418
+ continue;
5419
+ }
5420
+ const nested = asRecord2(row.text);
5421
+ if (typeof nested?.text === "string") texts.push(nested.text);
5422
+ }
5423
+ return texts;
5424
+ };
5425
+ const value = asRecord2(rec.value);
5426
+ if (value && Array.isArray(value.content)) {
5427
+ const texts = collectTexts(value.content);
5428
+ if (texts.length) return texts.join("\n");
5429
+ }
5430
+ if (Array.isArray(rec.content)) {
5431
+ const texts = collectTexts(rec.content);
5432
+ if (texts.length) return texts.join("\n");
5433
+ }
5434
+ try {
5435
+ return JSON.stringify(result);
5436
+ } catch {
5437
+ return String(result);
5438
+ }
5439
+ }
5440
+ function cursorToolResultIsError(status, result) {
5441
+ if (status === "error") return true;
5442
+ const rec = asRecord2(result);
5443
+ if (!rec) return false;
5444
+ if (rec.status === "error") return true;
5445
+ const value = asRecord2(rec.value);
5446
+ return value?.isError === true;
5447
+ }
5268
5448
  function cursorSdkMessageToEvents(msg) {
5269
5449
  if (!msg?.type) return [];
5270
5450
  if (msg.type === "system" && msg.agent_id) {
@@ -5279,35 +5459,42 @@ function cursorSdkMessageToEvents(msg) {
5279
5459
  if (block?.type === "text" && block.text) {
5280
5460
  out.push({ type: "stdout", data: block.text });
5281
5461
  } else if (block?.type === "tool_use" && block.id && block.name) {
5462
+ const normalized = normalizeCursorToolCall(block.name, block.input);
5282
5463
  out.push({
5283
5464
  type: "tool_use",
5284
5465
  id: block.id,
5285
- name: block.name,
5286
- input: block.input && typeof block.input === "object" ? block.input : void 0
5466
+ name: normalized.name,
5467
+ input: normalized.input
5287
5468
  });
5288
5469
  }
5289
5470
  }
5290
5471
  return out;
5291
5472
  }
5292
5473
  if (msg.type === "tool_call" && msg.call_id && msg.name) {
5474
+ const normalized = normalizeCursorToolCall(msg.name, msg.args);
5293
5475
  if (msg.status === "running") {
5294
5476
  return [
5295
5477
  {
5296
5478
  type: "tool_use",
5297
5479
  id: msg.call_id,
5298
- name: msg.name,
5299
- input: msg.args && typeof msg.args === "object" ? msg.args : void 0
5480
+ name: normalized.name,
5481
+ input: normalized.input
5300
5482
  }
5301
5483
  ];
5302
5484
  }
5303
5485
  if (msg.status === "completed" || msg.status === "error") {
5304
- const content = typeof msg.result === "string" ? msg.result : msg.result != null ? JSON.stringify(msg.result) : void 0;
5305
5486
  return [
5487
+ {
5488
+ type: "tool_use",
5489
+ id: msg.call_id,
5490
+ name: normalized.name,
5491
+ input: normalized.input
5492
+ },
5306
5493
  {
5307
5494
  type: "tool_result",
5308
5495
  id: msg.call_id,
5309
- content,
5310
- isError: msg.status === "error"
5496
+ content: unwrapCursorToolResult(msg.result),
5497
+ isError: cursorToolResultIsError(msg.status, msg.result)
5311
5498
  }
5312
5499
  ];
5313
5500
  }
@@ -5677,17 +5864,31 @@ var init_opencode = __esm({
5677
5864
  return { type: "stderr", data: detail };
5678
5865
  }
5679
5866
  const sid = typeof obj.sessionID === "string" && obj.sessionID || typeof obj.sessionId === "string" && obj.sessionId || typeof obj.session_id === "string" && obj.session_id;
5680
- if (sid) return { type: "session_id", data: sid };
5867
+ if (sid && (!obj.type || obj.type === "step_start" || obj.type === "session")) {
5868
+ return { type: "session_id", data: sid };
5869
+ }
5681
5870
  if (obj.type === "text") {
5682
5871
  const text = obj.part?.text ?? obj.text;
5683
5872
  if (text) return { type: "stdout", data: text };
5684
5873
  }
5685
5874
  if (obj.type === "tool_use") {
5686
5875
  const part = obj.part;
5687
- const id = part?.id ?? obj.id ?? `tool-${Date.now()}`;
5688
- const name = part?.name ?? part?.tool ?? obj.name ?? obj.tool ?? "tool";
5689
- const input = part?.input ?? obj.input;
5690
- return { type: "tool_use", id, name, input };
5876
+ const id = part?.callID ?? part?.id ?? obj.id ?? `tool-${Date.now()}`;
5877
+ const name = part?.tool ?? part?.name ?? obj.tool ?? obj.name ?? "tool";
5878
+ const state = part?.state;
5879
+ const input = (state?.input && typeof state.input === "object" ? state.input : void 0) ?? part?.input ?? obj.input;
5880
+ const events = [{ type: "tool_use", id, name, input }];
5881
+ const output = state?.output;
5882
+ if (output != null || state?.status === "completed" || state?.status === "error") {
5883
+ const content = typeof output === "string" ? output : output != null ? JSON.stringify(output) : formatUnknownDetail(state?.error) || void 0;
5884
+ events.push({
5885
+ type: "tool_result",
5886
+ id,
5887
+ content,
5888
+ isError: state?.status === "error" || state?.status === "failed"
5889
+ });
5890
+ }
5891
+ return events.length === 1 ? events[0] : events;
5691
5892
  }
5692
5893
  if (obj.type === "tool_result") {
5693
5894
  const part = obj.part;
@@ -6359,7 +6560,7 @@ var init_workspaces = __esm({
6359
6560
  });
6360
6561
 
6361
6562
  // src/plan/plan-present.ts
6362
- function asRecord2(v) {
6563
+ function asRecord4(v) {
6363
6564
  return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
6364
6565
  }
6365
6566
  function isPresentPlanToolName(name) {
@@ -6371,7 +6572,7 @@ function extractPresentedPlan(parts) {
6371
6572
  for (let i = parts.length - 1; i >= 0; i--) {
6372
6573
  const p = parts[i];
6373
6574
  if (p.type !== "tool" || !isPresentPlanToolName(p.name)) continue;
6374
- const input = asRecord2(p.input) ?? {};
6575
+ const input = asRecord4(p.input) ?? {};
6375
6576
  const content = typeof input.content === "string" ? input.content : typeof input.plan === "string" ? input.plan : typeof input.markdown === "string" ? input.markdown : "";
6376
6577
  if (!content.trim()) continue;
6377
6578
  const title = typeof input.title === "string" && input.title.trim() ? input.title.trim() : "Plan";
@@ -6537,7 +6738,7 @@ init_agents();
6537
6738
  init_orchestrator_capable();
6538
6739
 
6539
6740
  // src/agents/message-parts.ts
6540
- function asRecord(input) {
6741
+ function asRecord3(input) {
6541
6742
  if (input && typeof input === "object" && !Array.isArray(input)) {
6542
6743
  return input;
6543
6744
  }
@@ -6672,7 +6873,7 @@ function applyAgentEvent(parts, event) {
6672
6873
  return next;
6673
6874
  }
6674
6875
  if (event.type === "tool_use") {
6675
- const input = asRecord(event.input);
6876
+ const input = asRecord3(event.input);
6676
6877
  const diff = diffFromInput(input);
6677
6878
  const existing = parts.findIndex((p) => p.type === "tool" && p.id === event.id);
6678
6879
  if (existing >= 0) {
@@ -6706,9 +6907,25 @@ function applyAgentEvent(parts, event) {
6706
6907
  ];
6707
6908
  }
6708
6909
  if (event.type === "tool_result") {
6709
- const next = parts.map((p) => {
6710
- if (p.type !== "tool" || p.id !== event.id) return p;
6711
- const fromResult = parseDiffStat(event.content);
6910
+ const existing = parts.findIndex((p) => p.type === "tool" && p.id === event.id);
6911
+ const fromResult = parseDiffStat(event.content);
6912
+ if (existing < 0) {
6913
+ return [
6914
+ ...parts,
6915
+ {
6916
+ type: "tool",
6917
+ id: event.id,
6918
+ name: "tool",
6919
+ description: "tool",
6920
+ status: event.isError ? "error" : "done",
6921
+ result: event.content,
6922
+ ...fromResult.additions != null ? { additions: fromResult.additions } : {},
6923
+ ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
6924
+ }
6925
+ ];
6926
+ }
6927
+ return parts.map((p, i) => {
6928
+ if (i !== existing || p.type !== "tool") return p;
6712
6929
  return {
6713
6930
  ...p,
6714
6931
  status: event.isError ? "error" : "done",
@@ -6717,7 +6934,6 @@ function applyAgentEvent(parts, event) {
6717
6934
  ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
6718
6935
  };
6719
6936
  });
6720
- return next;
6721
6937
  }
6722
6938
  return parts;
6723
6939
  }
@@ -7513,10 +7729,17 @@ async function requireAgent(agent, opts) {
7513
7729
 
7514
7730
  // src/threads/create.ts
7515
7731
  init_worktree();
7732
+ init_app_settings();
7516
7733
  init_thread_store();
7517
7734
  init_workspaces();
7518
7735
  async function createThread(input, _onSetupLine) {
7519
- await requireAgent(input.agent);
7736
+ const resolved = resolveNewThreadOptions({
7737
+ agent: input.agent,
7738
+ model: input.model,
7739
+ effort: input.effort,
7740
+ fast: input.fast
7741
+ });
7742
+ await requireAgent(resolved.agent);
7520
7743
  const repoPath = await resolveRepoRoot(input.repoPath);
7521
7744
  if (!(0, import_node_fs18.existsSync)(repoPath)) {
7522
7745
  throw new Error(`Repo not found: ${repoPath}`);
@@ -7559,11 +7782,11 @@ async function createThread(input, _onSetupLine) {
7559
7782
  branchName,
7560
7783
  worktreePath,
7561
7784
  repoPath,
7562
- agent: input.agent,
7785
+ agent: resolved.agent,
7563
7786
  autonomy: input.autonomy ?? "default",
7564
- model: input.model ?? null,
7565
- effort: input.effort ?? "high",
7566
- fast: Boolean(input.fast),
7787
+ model: resolved.model,
7788
+ effort: resolved.effort,
7789
+ fast: resolved.fast,
7567
7790
  planMode: Boolean(input.planMode),
7568
7791
  attachments: input.attachments ?? [],
7569
7792
  sourceIsFork,
@@ -10530,7 +10753,7 @@ var Orchestrator = class {
10530
10753
  }
10531
10754
  }
10532
10755
  listWorkspaces() {
10533
- const fromThreads = listThreads({ includeArchived: false }).map((t) => t.repoPath);
10756
+ const fromThreads = listThreads({ includeArchived: true }).map((t) => t.repoPath);
10534
10757
  return syncWorkspacesFromThreads(fromThreads);
10535
10758
  }
10536
10759
  async addWorkspace(repoPath) {
@@ -11630,7 +11853,15 @@ var Orchestrator = class {
11630
11853
  }
11631
11854
  await removeWorktree(thread.repoPath, thread.worktreePath);
11632
11855
  }
11633
- return setStatus(thread.id, "archived");
11856
+ const archived = setStatus(thread.id, "archived");
11857
+ if (thread.repoPath && !isGlobalRepoPath(thread.repoPath)) {
11858
+ try {
11859
+ const { ensureWorkspace: ensureWorkspace2 } = await Promise.resolve().then(() => (init_workspaces(), workspaces_exports));
11860
+ await ensureWorkspace2(thread.repoPath);
11861
+ } catch {
11862
+ }
11863
+ }
11864
+ return archived;
11634
11865
  }
11635
11866
  async purge(threadRef, opts) {
11636
11867
  const thread = this.requireThread(threadRef);
@@ -12052,13 +12283,19 @@ async function startMcpServer() {
12052
12283
  return { content: [{ type: "text", text: JSON.stringify(payload) }] };
12053
12284
  }
12054
12285
  );
12286
+ const { resolveNewThreadOptions: resolveNewThreadOptions2, resolveThreadDefaults: resolveThreadDefaults2 } = await Promise.resolve().then(() => (init_app_settings(), app_settings_exports));
12287
+ const accountDefaults = resolveThreadDefaults2();
12288
+ const accountDefaultsHint = `Account defaults: agent=${accountDefaults.agent}, model=${accountDefaults.model?.trim() || "Auto"}, effort=${accountDefaults.effort}`;
12055
12289
  server.tool(
12056
12290
  "create_thread",
12057
- "Create a new worktree thread (chat) from branch, pr, or ticket. Pass repoPath from list_workspaces and parentThreadId when spawning from an orchestrator. Then use send_to_thread to chat.",
12291
+ `Create a new worktree thread (chat) from branch, pr, or ticket. Pass repoPath from list_workspaces and parentThreadId when spawning from an orchestrator. Prefer omitting agent/model so Sideboard applies ${accountDefaultsHint}. Then use send_to_thread to chat.`,
12058
12292
  {
12059
12293
  sourceType: import_zod.z.enum(["branch", "pr", "ticket"]),
12060
12294
  sourceRef: import_zod.z.string(),
12061
- agent: import_zod.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
12295
+ agent: import_zod.z.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(`Omit to use Account default agent (${accountDefaults.agent})`),
12296
+ model: import_zod.z.string().nullable().optional().describe(
12297
+ `Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
12298
+ ),
12062
12299
  repoPath: import_zod.z.string(),
12063
12300
  title: import_zod.z.string().optional(),
12064
12301
  parentThreadId: import_zod.z.string().optional()
@@ -12078,10 +12315,17 @@ async function startMcpServer() {
12078
12315
  };
12079
12316
  }
12080
12317
  }
12318
+ const opts = resolveNewThreadOptions2({
12319
+ agent: args.agent,
12320
+ model: args.model
12321
+ });
12081
12322
  const thread = await orch.createThread({
12082
12323
  sourceType: args.sourceType,
12083
12324
  sourceRef: args.sourceRef,
12084
- agent: args.agent,
12325
+ agent: opts.agent,
12326
+ model: opts.model,
12327
+ effort: opts.effort,
12328
+ fast: opts.fast,
12085
12329
  repoPath: args.repoPath,
12086
12330
  title: args.title,
12087
12331
  parentThreadId: args.parentThreadId ?? null
@@ -12095,6 +12339,8 @@ async function startMcpServer() {
12095
12339
  title: thread.title,
12096
12340
  branchName: thread.branchName,
12097
12341
  worktreePath: thread.worktreePath,
12342
+ agent: thread.agent,
12343
+ model: thread.model,
12098
12344
  status: thread.status,
12099
12345
  link: `sideboard://thread/${thread.id}`
12100
12346
  })