@sideboard-ai/core 0.1.309 → 0.1.311

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.
@@ -732,31 +732,55 @@ function applySystemCaEnv(env) {
732
732
  const inherited = process.env.NODE_EXTRA_CA_CERTS?.trim();
733
733
  if (inherited) env[NODE_EXTRA_CA_CERTS] = inherited;
734
734
  }
735
- function extraCertsFromBundle() {
735
+ function extraCertsFromBundle(io = {}) {
736
736
  const path = process.env.NODE_EXTRA_CA_CERTS?.trim();
737
737
  if (path) return splitPemCertificates(readExistingFile(path));
738
- const dest = systemCaBundlePath();
739
- return splitPemCertificates(readExistingFile(dest));
738
+ return splitPemCertificates(readExistingFile(systemCaBundlePath(io)));
739
+ }
740
+ function extraSystemCaPems(io = {}) {
741
+ const fromBundle = extraCertsFromBundle(io);
742
+ if (fromBundle.length > 0) return fromBundle;
743
+ return splitPemCertificates(collectSystemCaPem(io));
744
+ }
745
+ function mergeSystemCaIntoTlsOptions(options, extra, roots = import_node_tls.default.rootCertificates) {
746
+ const existing = options?.ca;
747
+ const base = existing == null ? [...roots] : Array.isArray(existing) ? [...existing] : [existing];
748
+ return { ...options, ca: [...base, ...extra] };
749
+ }
750
+ function installCreateSecureContextCaPatch(api, extra) {
751
+ if (api.__sideboardSystemCaPatched) return true;
752
+ if (typeof api.createSecureContext !== "function") return false;
753
+ const orig = api.createSecureContext;
754
+ const roots = api.rootCertificates ?? import_node_tls.default.rootCertificates;
755
+ api.createSecureContext = ((options) => orig(mergeSystemCaIntoTlsOptions(options, extra, roots)));
756
+ api.__sideboardSystemCaPatched = true;
757
+ return true;
740
758
  }
741
759
  function trustSystemCertificates(io = {}) {
742
760
  try {
743
- const api = import_node_tls.default;
744
- if (typeof api.getCACertificates !== "function" || typeof api.setDefaultCACertificates !== "function") {
745
- return false;
746
- }
747
- const current = api.getCACertificates("default");
748
- const system = api.getCACertificates("system");
749
- let extra = extraCertsFromBundle();
750
- if (system.length === 0 && extra.length === 0) {
751
- extra = splitPemCertificates(collectSystemCaPem(io));
761
+ const extra = extraSystemCaPems(io);
762
+ const api = io.tls ?? import_node_tls.default;
763
+ if (typeof api.getCACertificates === "function" && typeof api.setDefaultCACertificates === "function") {
764
+ const current = api.getCACertificates("default");
765
+ const system = api.getCACertificates("system");
766
+ if (system.length === 0 && extra.length === 0) return false;
767
+ api.setDefaultCACertificates([...current, ...system, ...extra]);
768
+ return true;
752
769
  }
753
- if (system.length === 0 && extra.length === 0) return false;
754
- api.setDefaultCACertificates([...current, ...system, ...extra]);
755
- return true;
770
+ if (extra.length === 0) return false;
771
+ return installCreateSecureContextCaPatch(api, extra);
756
772
  } catch {
757
773
  return false;
758
774
  }
759
775
  }
776
+ function bootstrapSystemCa(io = {}) {
777
+ const systemCaBundle = materializeSystemCaBundle(io);
778
+ if (systemCaBundle && !process.env.NODE_EXTRA_CA_CERTS?.trim()) {
779
+ process.env.NODE_EXTRA_CA_CERTS = systemCaBundle;
780
+ }
781
+ applySystemCaEnv(process.env);
782
+ trustSystemCertificates(io);
783
+ }
760
784
  var import_node_child_process, import_node_fs6, import_node_path7, import_node_tls, NODE_USE_SYSTEM_CA, NODE_EXTRA_CA_CERTS, BUNDLE_NAME, BUNDLE_MAX_AGE_MS, LINUX_CA_FILES, PEM_CERT_RE;
761
785
  var init_system_ca = __esm({
762
786
  "src/http/system-ca.ts"() {
@@ -2129,6 +2153,16 @@ function isAskUserToolName(name) {
2129
2153
  const base = name.replace(/^mcp__sideboard__/i, "");
2130
2154
  return ASK_USER_TOOL_RE.test(name) || /^ask_user$/i.test(base);
2131
2155
  }
2156
+ function lastTopLevelToolIsAskUser(parts) {
2157
+ if (!parts?.length) return false;
2158
+ for (let i = parts.length - 1; i >= 0; i--) {
2159
+ const part = parts[i];
2160
+ if (part.type === "tool" && !part.parentId) {
2161
+ return isAskUserToolName(part.name);
2162
+ }
2163
+ }
2164
+ return false;
2165
+ }
2132
2166
  function questionsFromToolPart(part) {
2133
2167
  const fromInput = parsePlanQuestionsInput(part.input);
2134
2168
  if (fromInput.length) return fromInput;
@@ -2156,6 +2190,18 @@ function extractPendingPlanQuestions(parts) {
2156
2190
  }
2157
2191
  return null;
2158
2192
  }
2193
+ function askBlockStillWaiting(block, messages) {
2194
+ if (!messages?.length) return Boolean(block?.at);
2195
+ const askedAt = block?.at;
2196
+ if (!askedAt) return false;
2197
+ for (let i = messages.length - 1; i >= 0; i--) {
2198
+ const message = messages[i];
2199
+ if (message.role !== "user" || message.origin === "continue") continue;
2200
+ if (!message.ts) return true;
2201
+ return askedAt > message.ts;
2202
+ }
2203
+ return true;
2204
+ }
2159
2205
  var ASK_USER_TOOL_RE;
2160
2206
  var init_ask_user = __esm({
2161
2207
  "src/plan/ask-user.ts"() {
@@ -2172,14 +2218,7 @@ function needsCoordinatorAction(state) {
2172
2218
  return isIncompleteTaskState(state) || state === "input-required";
2173
2219
  }
2174
2220
  function endedOnAskUser(parts) {
2175
- if (!parts?.length) return false;
2176
- for (let i = parts.length - 1; i >= 0; i--) {
2177
- const p = parts[i];
2178
- if (p.type === "tool" && !p.parentId) {
2179
- return isAskUserToolName(p.name);
2180
- }
2181
- }
2182
- return false;
2221
+ return lastTopLevelToolIsAskUser(parts);
2183
2222
  }
2184
2223
  function deriveTaskState(input) {
2185
2224
  if (input.stillRunning) {
@@ -18672,6 +18711,11 @@ function visibleAgentBlock(thread) {
18672
18711
  const block = thread.agentBlock;
18673
18712
  if (!block?.reason?.trim()) return null;
18674
18713
  if (isDismissedAskUserBlock(block, thread.dismissedQuestionSignature)) return null;
18714
+ if (block.source === "ask_user") {
18715
+ const inFlight = thread.status === "running" || thread.status === "queued";
18716
+ if (inFlight && !block.onScreen) return null;
18717
+ if (!askBlockStillWaiting(block, thread.messages)) return null;
18718
+ }
18675
18719
  return block;
18676
18720
  }
18677
18721
  function worktreeAgentBlock(group) {
@@ -18690,6 +18734,7 @@ function threadCardBlockFields(group) {
18690
18734
  var init_agent_block_view = __esm({
18691
18735
  "src/board/agent-block-view.ts"() {
18692
18736
  "use strict";
18737
+ init_ask_user();
18693
18738
  }
18694
18739
  });
18695
18740
 
@@ -18915,6 +18960,7 @@ function decisionBlockFromParts(parts, planMode, at = (/* @__PURE__ */ new Date(
18915
18960
  const reason = pending ? formatAskUserNotifyMessage(pending.questions) : "Waiting for an answer in that chat.";
18916
18961
  return {
18917
18962
  ...makeAgentBlock("ask_user", reason, at),
18963
+ onScreen: true,
18918
18964
  ...pending ? { questionSignature: pending.signature, questions: pending.questions } : {}
18919
18965
  };
18920
18966
  }
@@ -18972,6 +19018,38 @@ function dismissAskUserQuestion(threadId, signature) {
18972
19018
  ...clearBlock ? { agentBlock: null } : {}
18973
19019
  });
18974
19020
  }
19021
+ function askBlocksEqual(a, b) {
19022
+ if (a === b) return true;
19023
+ if (!a || !b) return false;
19024
+ return a.source === b.source && a.reason === b.reason && a.at === b.at && a.onScreen === b.onScreen && a.questionSignature === b.questionSignature;
19025
+ }
19026
+ function askBlockAfterLiveParts(existing, parts) {
19027
+ const last = lastTopLevelTool(parts);
19028
+ if (last?.type === "tool" && isAskUserToolName(last.name)) {
19029
+ if (existing?.source === "ask_user" && existing.onScreen) return existing;
19030
+ const pending = extractPendingPlanQuestions(parts);
19031
+ const questions = pending?.questions ?? existing?.questions;
19032
+ if (!questions?.length) {
19033
+ return existing?.source === "ask_user" ? { ...existing, onScreen: true } : existing ?? null;
19034
+ }
19035
+ const at = existing?.source === "ask_user" ? existing.at : void 0;
19036
+ return {
19037
+ ...makeAgentBlock("ask_user", formatAskUserNotifyMessage(questions), at),
19038
+ onScreen: true,
19039
+ questionSignature: pending?.signature ?? existing?.questionSignature,
19040
+ questions
19041
+ };
19042
+ }
19043
+ if (last && existing?.source === "ask_user") return null;
19044
+ return existing ?? null;
19045
+ }
19046
+ function syncAskUserBlockFromLive(threadId, parts) {
19047
+ const thread = readThread(threadId);
19048
+ if (!thread || thread.status === "archived") return;
19049
+ const next = askBlockAfterLiveParts(thread.agentBlock, parts);
19050
+ if (askBlocksEqual(thread.agentBlock, next)) return;
19051
+ updateThread(threadId, { agentBlock: next });
19052
+ }
18975
19053
  function writeAgentBlock(threadId, block) {
18976
19054
  const thread = readThread(threadId);
18977
19055
  if (!thread || thread.status === "archived") return;
@@ -22342,6 +22420,7 @@ function noteTurnLiveEvent(threadId, event) {
22342
22420
  const prev = buffers.get(threadId) ?? { parts: [], timer: null };
22343
22421
  prev.parts = trimParts(applyAgentEvent(prev.parts, event));
22344
22422
  buffers.set(threadId, prev);
22423
+ syncAskUserBlockFromLive(threadId, prev.parts);
22345
22424
  if (event.type === "exit") {
22346
22425
  flush(threadId);
22347
22426
  const cur = buffers.get(threadId);
@@ -22395,6 +22474,7 @@ var init_turn_live = __esm({
22395
22474
  import_node_fs55 = require("fs");
22396
22475
  init_message_parts();
22397
22476
  init_paths();
22477
+ init_agent_block();
22398
22478
  buffers = /* @__PURE__ */ new Map();
22399
22479
  FLUSH_MS = 800;
22400
22480
  MAX_PARTS = 80;
@@ -34515,12 +34595,7 @@ async function startMcpServer() {
34515
34595
 
34516
34596
  // src/mcp/run-stdio.ts
34517
34597
  dropNestedElectronEnvFromProcess();
34518
- var systemCaBundle = materializeSystemCaBundle();
34519
- if (systemCaBundle && !process.env.NODE_EXTRA_CA_CERTS?.trim()) {
34520
- process.env.NODE_EXTRA_CA_CERTS = systemCaBundle;
34521
- }
34522
- applySystemCaEnv(process.env);
34523
- trustSystemCertificates();
34598
+ bootstrapSystemCa();
34524
34599
  startMcpServer().catch((err) => {
34525
34600
  console.error(err);
34526
34601
  process.exitCode = 1;
@@ -56,7 +56,7 @@ import {
56
56
  updateSchedule,
57
57
  workspaceTagTargetRef,
58
58
  writeAgentBlock
59
- } from "../chunk-OU5V56OI.js";
59
+ } from "../chunk-7ORMOP3D.js";
60
60
  import "../chunk-LX5R5JOR.js";
61
61
  import {
62
62
  commentAbleTimeTask,
@@ -91,15 +91,13 @@ import {
91
91
  import "../chunk-DC3VZXMA.js";
92
92
  import {
93
93
  SIDEBOARD_THREAD_ID_ENV,
94
- applySystemCaEnv,
94
+ bootstrapSystemCa,
95
95
  isCursorApiKeyConfigured,
96
96
  listModelsForAgent,
97
- materializeSystemCaBundle,
98
97
  shouldRegisterMcpWaitForTurn,
99
98
  sideboardMcpProfile,
100
- trustSystemCertificates,
101
99
  worktreeMcpToolNames
102
- } from "../chunk-VXI7FFGO.js";
100
+ } from "../chunk-GQJOLTZU.js";
103
101
  import "../chunk-EGTCXNQM.js";
104
102
  import "../chunk-42JGPPVS.js";
105
103
  import "../chunk-PXMLMBMI.js";
@@ -116,7 +114,7 @@ import {
116
114
  waitForDetachedJob,
117
115
  waitForTurnToolResult,
118
116
  workspaceAgentChatSummaries
119
- } from "../chunk-AILQRQ26.js";
117
+ } from "../chunk-ZW7RSQHY.js";
120
118
  import {
121
119
  HUGE_TOOL_RESULT_SUMMARY,
122
120
  clipToolResultForStore,
@@ -5246,12 +5244,7 @@ async function startMcpServer() {
5246
5244
 
5247
5245
  // src/mcp/run-stdio.ts
5248
5246
  dropNestedElectronEnvFromProcess();
5249
- var systemCaBundle = materializeSystemCaBundle();
5250
- if (systemCaBundle && !process.env.NODE_EXTRA_CA_CERTS?.trim()) {
5251
- process.env.NODE_EXTRA_CA_CERTS = systemCaBundle;
5252
- }
5253
- applySystemCaEnv(process.env);
5254
- trustSystemCertificates();
5247
+ bootstrapSystemCa();
5255
5248
  startMcpServer().catch((err) => {
5256
5249
  console.error(err);
5257
5250
  process.exitCode = 1;
@@ -9,11 +9,11 @@ import {
9
9
  resolveSendFollowUp,
10
10
  startOrchestration,
11
11
  waitForPidExit
12
- } from "./chunk-M6PAT6HG.js";
12
+ } from "./chunk-2ER7DQJP.js";
13
13
  import "./chunk-PGPSIEMW.js";
14
- import "./chunk-FMSLOWKR.js";
14
+ import "./chunk-4YBQBVYL.js";
15
15
  import "./chunk-VEVFHO6K.js";
16
- import "./chunk-VBVSJUM2.js";
16
+ import "./chunk-QC2TQMPJ.js";
17
17
  import "./chunk-7Q327QF2.js";
18
18
  import "./chunk-7H655NEW.js";
19
19
  import "./chunk-WRZRX4Q7.js";
@@ -26,7 +26,7 @@ import "./chunk-33KDPEK4.js";
26
26
  import "./chunk-JAT3JFOS.js";
27
27
  import "./chunk-F2PVRF3B.js";
28
28
  import "./chunk-AXQ4ZWHK.js";
29
- import "./chunk-UA3YKQ3D.js";
29
+ import "./chunk-Y3Y7SZBZ.js";
30
30
  import "./chunk-5XNT6BCG.js";
31
31
  import "./chunk-6K64FJDD.js";
32
32
  import "./chunk-LG6RJBIY.js";
@@ -11,17 +11,17 @@ import {
11
11
  resolveSendFollowUp,
12
12
  startOrchestration,
13
13
  waitForPidExit
14
- } from "./chunk-OU5V56OI.js";
14
+ } from "./chunk-7ORMOP3D.js";
15
15
  import "./chunk-LX5R5JOR.js";
16
16
  import "./chunk-62ESCTJ4.js";
17
17
  import "./chunk-4GK32AYX.js";
18
18
  import "./chunk-DC3VZXMA.js";
19
- import "./chunk-VXI7FFGO.js";
19
+ import "./chunk-GQJOLTZU.js";
20
20
  import "./chunk-EGTCXNQM.js";
21
21
  import "./chunk-42JGPPVS.js";
22
22
  import "./chunk-PXMLMBMI.js";
23
23
  import "./chunk-2GPQZZLY.js";
24
- import "./chunk-AILQRQ26.js";
24
+ import "./chunk-ZW7RSQHY.js";
25
25
  import "./chunk-I5TESHDN.js";
26
26
  import "./chunk-X3FSWWW2.js";
27
27
  import "./chunk-DLGGLV2M.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sideboard-ai/core",
3
- "version": "0.1.309",
3
+ "version": "0.1.311",
4
4
  "description": "Sideboard core — orchestration, agents, git worktrees, MCP server",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",