@sema-agent/cli 1.0.81 → 1.0.83

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.
package/sema-main.js CHANGED
@@ -39600,8 +39600,8 @@ var require_get_proto = __commonJS({
39600
39600
  var require_hasown = __commonJS({
39601
39601
  "node_modules/hasown/index.js"(exports2, module2) {
39602
39602
  "use strict";
39603
- var call77 = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty, bind2 = require_function_bind();
39604
- module2.exports = bind2.call(call77, $hasOwn);
39603
+ var call78 = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty, bind2 = require_function_bind();
39604
+ module2.exports = bind2.call(call78, $hasOwn);
39605
39605
  }
39606
39606
  });
39607
39607
 
@@ -40775,9 +40775,9 @@ var require_ms = __commonJS({
40775
40775
  }
40776
40776
  function fmtLong(ms) {
40777
40777
  var msAbs = Math.abs(ms);
40778
- return msAbs >= d4 ? plural5(ms, msAbs, d4, "day") : msAbs >= h ? plural5(ms, msAbs, h, "hour") : msAbs >= m2 ? plural5(ms, msAbs, m2, "minute") : msAbs >= s ? plural5(ms, msAbs, s, "second") : ms + " ms";
40778
+ return msAbs >= d4 ? plural6(ms, msAbs, d4, "day") : msAbs >= h ? plural6(ms, msAbs, h, "hour") : msAbs >= m2 ? plural6(ms, msAbs, m2, "minute") : msAbs >= s ? plural6(ms, msAbs, s, "second") : ms + " ms";
40779
40779
  }
40780
- function plural5(ms, msAbs, n2, name) {
40780
+ function plural6(ms, msAbs, n2, name) {
40781
40781
  var isPlural = msAbs >= n2 * 1.5;
40782
40782
  return Math.round(ms / n2) + " " + name + (isPlural ? "s" : "");
40783
40783
  }
@@ -46920,6 +46920,13 @@ var EnvironmentVariablesSchema, PermissionsSchema, KILL_SWITCH_KEYS, ExtraKnownM
46920
46920
  semaAutoModeModels: external_exports.array(external_exports.string()).optional().catch(void 0).describe(
46921
46921
  "sema: model allowlist force-enabling auto mode for the listed models (tengu_auto_mode_config.allowModels; exact model IDs or canonical family names). Default (absent/empty) keeps the built-in allowlist. Applies on next shell start."
46922
46922
  ),
46923
+ // agent-teams(具名持久队友族)的 settings 面 opt-in。门本体 = utils/agentSwarmsEnabled.ts
46924
+ // (grep semaAgentTeamsEnabled),三源析取:本键 / env SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS /
46925
+ // --agent-teams flag,任一为真即开,默认关。读的是**用户级** settings.json(不吃
46926
+ // projectSettings —— 起子进程队友的能力不该由 clone 来的仓库替用户打开),boot-only 快照。
46927
+ semaAgentTeamsEnabled: external_exports.boolean().optional().catch(void 0).describe(
46928
+ "sema: opt in to the experimental agent teams feature (named persistent teammates with a shared task list). Default (absent/false) keeps it off. Equivalent to the SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS env var or the --agent-teams flag; any one of the three turns it on. Applies on next shell start."
46929
+ ),
46923
46930
  sshConfigs: external_exports.array(
46924
46931
  external_exports.object({
46925
46932
  id: external_exports.string().describe(
@@ -55605,6 +55612,9 @@ var CONTEXT_LINES, DIFF_TIMEOUT_MS, AMPERSAND_TOKEN, DOLLAR_TOKEN, init_patch =
55605
55612
  });
55606
55613
 
55607
55614
  // node_modules/@sema-agent/client-core/dist/engineErrorCodes.js
55615
+ function isLimitsExceededCode(code2) {
55616
+ return typeof code2 == "string" && code2.startsWith(LIMITS_ERROR_CODE_PREFIX);
55617
+ }
55608
55618
  function isConfigRefusalCode(code2) {
55609
55619
  return typeof code2 == "string" && code2.startsWith("config.");
55610
55620
  }
@@ -55617,9 +55627,10 @@ function isRewindFamilyCode(code2) {
55617
55627
  function asModelFallbackReason(v2) {
55618
55628
  return v2 === MODEL_FALLBACK_INHERIT_NO_TIER_BINDING ? MODEL_FALLBACK_INHERIT_NO_TIER_BINDING : void 0;
55619
55629
  }
55620
- var LIMITS_MAX_TOKENS_EXCEEDED, LIMITS_MAX_COST_EXCEEDED, LIMITS_MAX_TURNS_EXCEEDED, LIMITS_MAX_WALLTIME_EXCEEDED, USAGE_WINDOW_EXHAUSTED, ENV_LIFETIME_EXPIRED, CONFIG_LIMIT_INVALID, CONFIG_STRATEGY_FIND_LIMIT_INVALID, CONFIG_STRATEGY_MAX_SIZE_INVALID, CONFIG_LIMIT_UNKNOWN_KEY, CONFIG_REFUSAL_CODES, TOOL_END_INTERRUPTED_NEVER_STARTED, TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN, TOOL_END_INTERRUPTED_CODES, ACTIVE_RUN_BUSY_ERROR_CODE, STOP_PARK_ARBITER_UNREACHABLE, STOP_PARK_RESUME_WON, STOP_NOT_LANDED, STOP_NOT_LOCAL, STOP_PARKED, STOP_CONFLICT_CODES, OUTPUT_INVALID, RESUME_AT_ERROR_CODE_PREFIX, REWIND_ERROR_CODE_PREFIXES, DRAINING_ERROR_CODE, SCENARIO_NOT_ALLOWED_ERROR_CODE, STREAM_MAX_DURATION, MODEL_FALLBACK_INHERIT_NO_TIER_BINDING, init_engineErrorCodes = __esm({
55630
+ var LIMITS_MAX_TOKENS_EXCEEDED, LIMITS_MAX_COST_EXCEEDED, LIMITS_MAX_TURNS_EXCEEDED, LIMITS_MAX_WALLTIME_EXCEEDED, LIMITS_ERROR_CODE_PREFIX, USAGE_WINDOW_EXHAUSTED, ENV_LIFETIME_EXPIRED, CONFIG_LIMIT_INVALID, CONFIG_STRATEGY_FIND_LIMIT_INVALID, CONFIG_STRATEGY_MAX_SIZE_INVALID, CONFIG_LIMIT_UNKNOWN_KEY, CONFIG_REFUSAL_CODES, TOOL_END_INTERRUPTED_NEVER_STARTED, TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN, TOOL_END_INTERRUPTED_CODES, ACTIVE_RUN_BUSY_ERROR_CODE, STOP_PARK_ARBITER_UNREACHABLE, STOP_PARK_RESUME_WON, STOP_NOT_LANDED, STOP_NOT_LOCAL, STOP_PARKED, STOP_CONFLICT_CODES, OUTPUT_INVALID, RESUME_AT_ERROR_CODE_PREFIX, REWIND_ERROR_CODE_PREFIXES, DRAINING_ERROR_CODE, SCENARIO_NOT_ALLOWED_ERROR_CODE, STREAM_MAX_DURATION, MODEL_FALLBACK_INHERIT_NO_TIER_BINDING, init_engineErrorCodes = __esm({
55621
55631
  "node_modules/@sema-agent/client-core/dist/engineErrorCodes.js"() {
55622
- LIMITS_MAX_TOKENS_EXCEEDED = "limits.max_tokens_exceeded", LIMITS_MAX_COST_EXCEEDED = "limits.max_cost_exceeded", LIMITS_MAX_TURNS_EXCEEDED = "limits.max_turns_exceeded", LIMITS_MAX_WALLTIME_EXCEEDED = "limits.max_walltime_exceeded", USAGE_WINDOW_EXHAUSTED = "usage.window_exhausted", ENV_LIFETIME_EXPIRED = "env.lifetime_expired", CONFIG_LIMIT_INVALID = "config.limit_invalid", CONFIG_STRATEGY_FIND_LIMIT_INVALID = "config.strategy_find_limit_invalid", CONFIG_STRATEGY_MAX_SIZE_INVALID = "config.strategy_max_size_invalid", CONFIG_LIMIT_UNKNOWN_KEY = "config.limit_unknown_key", CONFIG_REFUSAL_CODES = /* @__PURE__ */ new Set([
55632
+ LIMITS_MAX_TOKENS_EXCEEDED = "limits.max_tokens_exceeded", LIMITS_MAX_COST_EXCEEDED = "limits.max_cost_exceeded", LIMITS_MAX_TURNS_EXCEEDED = "limits.max_turns_exceeded", LIMITS_MAX_WALLTIME_EXCEEDED = "limits.max_walltime_exceeded", LIMITS_ERROR_CODE_PREFIX = "limits.";
55633
+ USAGE_WINDOW_EXHAUSTED = "usage.window_exhausted", ENV_LIFETIME_EXPIRED = "env.lifetime_expired", CONFIG_LIMIT_INVALID = "config.limit_invalid", CONFIG_STRATEGY_FIND_LIMIT_INVALID = "config.strategy_find_limit_invalid", CONFIG_STRATEGY_MAX_SIZE_INVALID = "config.strategy_max_size_invalid", CONFIG_LIMIT_UNKNOWN_KEY = "config.limit_unknown_key", CONFIG_REFUSAL_CODES = /* @__PURE__ */ new Set([
55623
55634
  CONFIG_LIMIT_INVALID,
55624
55635
  CONFIG_STRATEGY_FIND_LIMIT_INVALID,
55625
55636
  CONFIG_STRATEGY_MAX_SIZE_INVALID,
@@ -59849,6 +59860,13 @@ function classifyActiveRunBusy(input) {
59849
59860
  let handle2 = typeof input.activeTaskId == "string" && input.activeTaskId.length > 0 ? input.activeTaskId : null;
59850
59861
  return input.errorCode === ACTIVE_RUN_BUSY_ERROR_CODE ? { busy: !0, handle: handle2 } : typeof input.activeTaskId == "string" ? { busy: !0, handle: handle2 } : { busy: !1, handle: handle2 };
59851
59862
  }
59863
+ function isGovernanceStopRowText(text2) {
59864
+ let t2 = text2.trimStart();
59865
+ return t2.startsWith(`${RUN_STOPPED_MESSAGE_PREFIX}:`) || t2.startsWith(`${RUN_BLOCKED_MESSAGE_PREFIX}`);
59866
+ }
59867
+ function isGovernanceTerminal(input) {
59868
+ return input.status === "blocked" || isLimitsExceededCode(input.errorCode) ? !0 : input.errorCode === OUTPUT_INVALID;
59869
+ }
59852
59870
  function sanitizeFrameType(type) {
59853
59871
  let flattened = type.replace(/[\u0000-\u001f\u007f-\u009f]/g, "\uFFFD");
59854
59872
  return flattened.length > DROPPED_TYPE_DISPLAY_CAP ? `${flattened.slice(0, DROPPED_TYPE_DISPLAY_CAP)}\u2026` : flattened;
@@ -59942,7 +59960,14 @@ async function* runStreamInner(events3, ctx, handle2 = {}) {
59942
59960
  errorCode: ev.type === "failed" ? ev.errorCode : failedResult?.errorCode,
59943
59961
  activeTaskId
59944
59962
  }), maxTokHint = /max_tokens/i.test(errText3) ? `
59945
- your provider caps max_tokens lower \u2014 lower it in /model (press m, or M to type a value)` : "", busyHandle = busy.handle, rowText = busy.busy ? `This session is locked by an earlier run${busyHandle ? ` (run ${busyHandle})` : ""} that has not been released, so this message was NOT sent. Nothing releases it on its own \u2014 cancel that run (POST /v1/runs/${busyHandle ?? "<id>"}/cancel), or start a new session.` : `API Error: ${errText3}${maxTokHint}`;
59963
+ your provider caps max_tokens lower \u2014 lower it in /model (press m, or M to type a value)` : "", governance = isGovernanceTerminal({
59964
+ status: ev.type === "failed" ? void 0 : failedResult?.status,
59965
+ errorCode: ev.type === "failed" ? ev.errorCode : failedResult?.errorCode
59966
+ }), busyHandle = busy.handle, rowText = busy.busy ? `This session is locked by an earlier run${busyHandle ? ` (run ${busyHandle})` : ""} that has not been released, so this message was NOT sent. Nothing releases it on its own \u2014 cancel that run (POST /v1/runs/${busyHandle ?? "<id>"}/cancel), or start a new session.` : governance ? (
59967
+ // blocked 的 errText 自己就以 `Run blocked` 开头(见上方 errText 构造),再套一层
59968
+ // `Run stopped:` 会变成两个前缀叠字;其余治理码用中性前缀 + 引擎原话。
59969
+ `${isGovernanceStopRowText(errText3) ? errText3 : `${RUN_STOPPED_MESSAGE_PREFIX}: ${errText3}`}${maxTokHint}`
59970
+ ) : `API Error: ${errText3}${maxTokHint}`;
59946
59971
  yield {
59947
59972
  session_id: ctx.sessionId ?? "",
59948
59973
  uuid: `err-${Date.now().toString(36)}`,
@@ -59972,7 +59997,7 @@ your provider caps max_tokens lower \u2014 lower it in /model (press m, or M to
59972
59997
  projection.kind === "dropped" && reportDroppedFrame(projection.why, projection.type, ctx);
59973
59998
  }
59974
59999
  }
59975
- var MAIN2, reportedDroppedTypes, DROPPED_TYPE_MEMO_CAP, DROPPED_TYPE_DISPLAY_CAP, inFlightTurns, init_runStream = __esm({
60000
+ var MAIN2, RUN_STOPPED_MESSAGE_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, reportedDroppedTypes, DROPPED_TYPE_MEMO_CAP, DROPPED_TYPE_DISPLAY_CAP, inFlightTurns, init_runStream = __esm({
59976
60001
  "node_modules/@sema-agent/client-core/dist/adapter/runStream.js"() {
59977
60002
  init_types4();
59978
60003
  init_eventToSdkMessage();
@@ -59980,6 +60005,7 @@ var MAIN2, reportedDroppedTypes, DROPPED_TYPE_MEMO_CAP, DROPPED_TYPE_DISPLAY_CAP
59980
60005
  init_subagentContentStore();
59981
60006
  init_engineErrorCodes();
59982
60007
  MAIN2 = { lane: "main" };
60008
+ RUN_STOPPED_MESSAGE_PREFIX = "Run stopped", RUN_BLOCKED_MESSAGE_PREFIX = "Run blocked";
59983
60009
  reportedDroppedTypes = /* @__PURE__ */ new Set(), DROPPED_TYPE_MEMO_CAP = 64, DROPPED_TYPE_DISPLAY_CAP = 60;
59984
60010
  inFlightTurns = 0;
59985
60011
  }
@@ -60006,6 +60032,21 @@ function askParkForeignGateKind(row2) {
60006
60032
  let kind = typeof row2.gateKind == "string" && row2.gateKind.length > 0 ? row2.gateKind : null;
60007
60033
  return kind !== null && !ASK_PARK_GATE_KINDS.includes(kind) ? kind : null;
60008
60034
  }
60035
+ function selfHealSubmissionDisposition(outcome) {
60036
+ switch (outcome.kind) {
60037
+ case "decision-pending":
60038
+ return "held-for-decision";
60039
+ case "ask-reopened":
60040
+ case "plan-review-reopened":
60041
+ return "held-for-decision";
60042
+ case "running-cancelled":
60043
+ return "resending";
60044
+ case "running-steered":
60045
+ return "handed-off";
60046
+ default:
60047
+ return "not-delivered";
60048
+ }
60049
+ }
60009
60050
  function sessionOpts(deps2) {
60010
60051
  let sessionId = deps2?.sessionId;
60011
60052
  return typeof sessionId == "string" && sessionId.length > 0 ? { session: sessionId } : {};
@@ -60229,10 +60270,12 @@ function decidePathClause(signal) {
60229
60270
  function governanceOriginClause(signal) {
60230
60271
  return signal?.pendingGate?.governanceForced === !0 ? " That gate is enforced by this deployment's governance policy, not by a permission rule you set." : "";
60231
60272
  }
60232
- function activeRunSelfHealRow(outcome, signal, copy2) {
60273
+ function activeRunSelfHealRow(outcome, signal, copy2, origin2) {
60233
60274
  let override = copy2?.rowFor?.(outcome, signal);
60234
60275
  if (typeof override == "string")
60235
60276
  return override;
60277
+ if (origin2 === "injected")
60278
+ return injectedSubmissionRow(outcome);
60236
60279
  let base = activeRunSelfHealBaseRow(outcome, signal, copy2?.wayOut ?? DEFAULT_WAY_OUT);
60237
60280
  switch (outcome.kind) {
60238
60281
  // 这两条是「用户此刻卡住了、而且没有别的把手」的结局 —— wire 给的 decide 入口在这里才有用。
@@ -60245,6 +60288,19 @@ function activeRunSelfHealRow(outcome, signal, copy2) {
60245
60288
  return base + governanceOriginClause(signal);
60246
60289
  }
60247
60290
  }
60291
+ function injectedSubmissionRow(outcome) {
60292
+ let handle2 = "taskId" in outcome && outcome.taskId ? ` (run ${outcome.taskId})` : "";
60293
+ switch (selfHealSubmissionDisposition(outcome)) {
60294
+ case "held-for-decision":
60295
+ return `A system notification could not be delivered while an earlier turn${handle2} is waiting on a decision \u2014 sema kept it queued and will deliver it after you answer the open card.`;
60296
+ case "resending":
60297
+ return `A system notification was held while the earlier run${handle2} was cancelled; sema is delivering it now.`;
60298
+ case "handed-off":
60299
+ return `A system notification was handed to the run that is already working${handle2} instead of starting a new turn \u2014 watch that run for what it does with it.`;
60300
+ case "not-delivered":
60301
+ return `A system notification was NOT delivered: this session is still held by an earlier run${handle2} and sema could not put a decision for it on screen, so it did not retry. The model was not told about it.`;
60302
+ }
60303
+ }
60248
60304
  function activeRunSelfHealBaseRow(outcome, signal, wayOut) {
60249
60305
  switch (outcome.kind) {
60250
60306
  case "decision-pending":
@@ -62391,8 +62447,8 @@ function projectActivity(beats) {
62391
62447
  continue;
62392
62448
  let key = typeof b3.toolCallId == "string" && b3.toolCallId ? b3.toolCallId : `#${anon++}`;
62393
62449
  byCall.has(key) || order2.push(key);
62394
- let prev = byCall.get(key), arg = typeof b3.arg == "string" && b3.arg.trim() ? oneLineSummary(b3.arg.trim()) : prev?.summary, call77 = { name };
62395
- arg && (call77.summary = arg), byCall.set(key, { ...prev, ...call77 });
62450
+ let prev = byCall.get(key), arg = typeof b3.arg == "string" && b3.arg.trim() ? oneLineSummary(b3.arg.trim()) : prev?.summary, call78 = { name };
62451
+ arg && (call78.summary = arg), byCall.set(key, { ...prev, ...call78 });
62396
62452
  }
62397
62453
  return order2.map((k2) => byCall.get(k2)).filter((c2) => !!c2);
62398
62454
  }
@@ -68193,6 +68249,7 @@ __export(dist_exports, {
68193
68249
  IDLE_FLUSH_MS: () => IDLE_FLUSH_MS,
68194
68250
  INTERACTIVE_WAY_OUT: () => INTERACTIVE_WAY_OUT,
68195
68251
  INTERNAL_SDK_ARM_TYPES: () => INTERNAL_SDK_ARM_TYPES,
68252
+ LIMITS_ERROR_CODE_PREFIX: () => LIMITS_ERROR_CODE_PREFIX,
68196
68253
  LIMITS_MAX_COST_EXCEEDED: () => LIMITS_MAX_COST_EXCEEDED,
68197
68254
  LIMITS_MAX_TOKENS_EXCEEDED: () => LIMITS_MAX_TOKENS_EXCEEDED,
68198
68255
  LIMITS_MAX_TURNS_EXCEEDED: () => LIMITS_MAX_TURNS_EXCEEDED,
@@ -68250,6 +68307,8 @@ __export(dist_exports, {
68250
68307
  RETAIN_BACKGROUND_ENV: () => RETAIN_BACKGROUND_ENV,
68251
68308
  REWIND_ERROR_CODE_PREFIXES: () => REWIND_ERROR_CODE_PREFIXES,
68252
68309
  RUNNING_STATES: () => RUNNING_STATES,
68310
+ RUN_BLOCKED_MESSAGE_PREFIX: () => RUN_BLOCKED_MESSAGE_PREFIX,
68311
+ RUN_STOPPED_MESSAGE_PREFIX: () => RUN_STOPPED_MESSAGE_PREFIX,
68253
68312
  SANDBOX_CASCADE_CONFLICT_400_ANCHOR: () => SANDBOX_CASCADE_CONFLICT_400_ANCHOR,
68254
68313
  SANDBOX_K8S_ONLY_400_ANCHOR: () => SANDBOX_K8S_ONLY_400_ANCHOR,
68255
68314
  SANDBOX_NO_IMAGE_INDEX_400_ANCHOR: () => SANDBOX_NO_IMAGE_INDEX_400_ANCHOR,
@@ -68566,10 +68625,13 @@ __export(dist_exports, {
68566
68625
  isFromSubagent: () => isFromSubagent,
68567
68626
  isFsApprovalGate: () => isFsApprovalGate,
68568
68627
  isGoalStopHookWireArmed: () => isGoalStopHookWireArmed,
68628
+ isGovernanceStopRowText: () => isGovernanceStopRowText,
68629
+ isGovernanceTerminal: () => isGovernanceTerminal,
68569
68630
  isHitlSafetyErrorLike: () => isHitlSafetyErrorLike,
68570
68631
  isHookNoticeFrame: () => isHookNoticeFrame,
68571
68632
  isInterruptedToolEndCode: () => isInterruptedToolEndCode,
68572
68633
  isKnownWorkflowAgentTaskId: () => isKnownWorkflowAgentTaskId,
68634
+ isLimitsExceededCode: () => isLimitsExceededCode,
68573
68635
  isLocalSessionEvent: () => isLocalSessionEvent,
68574
68636
  isLocalSessionRecord: () => isLocalSessionRecord,
68575
68637
  isLoopbackWireUrl: () => isLoopbackWireUrl,
@@ -68773,6 +68835,7 @@ __export(dist_exports, {
68773
68835
  scenarioForPrint: () => scenarioForPrint,
68774
68836
  scratchpadDirField: () => scratchpadDirField,
68775
68837
  searchPresetTableViolations: () => searchPresetTableViolations,
68838
+ selfHealSubmissionDisposition: () => selfHealSubmissionDisposition,
68776
68839
  selfOrchestrationFromEnv: () => selfOrchestrationFromEnv,
68777
68840
  setLiveModelCatalog: () => setLiveModelCatalog,
68778
68841
  setLiveModelCatalogRefresher: () => setLiveModelCatalogRefresher,
@@ -109772,7 +109835,7 @@ var import_stack_utils, import_jsx_runtime6, cleanupPath, stackUtils, init_Error
109772
109835
  // build-src/src/ink/components/TerminalSizeContext.tsx
109773
109836
  var import_react9, TerminalSizeContext, init_TerminalSizeContext = __esm({
109774
109837
  "build-src/src/ink/components/TerminalSizeContext.tsx"() {
109775
- import_react9 = __toESM(require_react()), TerminalSizeContext = (0, import_react9.createContext)(null);
109838
+ import_react9 = __toESM(require_react(), 1), TerminalSizeContext = (0, import_react9.createContext)(null);
109776
109839
  }
109777
109840
  });
109778
109841
 
@@ -117242,6 +117305,18 @@ ${ctx}` : line;
117242
117305
  }
117243
117306
  return "Execution error";
117244
117307
  }
117308
+ function formatTextModeGovernanceStop(errors2, fallbackTemplate) {
117309
+ if (Array.isArray(errors2)) {
117310
+ let first = errors2.find(
117311
+ (e) => typeof e == "string" && e.trim().length > 0
117312
+ );
117313
+ if (first) {
117314
+ let msg = extractProviderErrorMessage(first.trim());
117315
+ return /^(API Error|Error)\b/i.test(msg) ? msg : `Error: ${msg}`;
117316
+ }
117317
+ }
117318
+ return fallbackTemplate;
117319
+ }
117245
117320
  var init_textModeError = __esm({
117246
117321
  "build-src/src/cli/textModeError.ts"() {
117247
117322
  }
@@ -117296,6 +117371,18 @@ var init_probePlan = __esm({
117296
117371
  }
117297
117372
  });
117298
117373
 
117374
+ // build-src/src/utils/dispatcherTimeouts.ts
117375
+ var LONG_POLL_DISPATCHER_TIMEOUTS, init_dispatcherTimeouts = __esm({
117376
+ "build-src/src/utils/dispatcherTimeouts.ts"() {
117377
+ LONG_POLL_DISPATCHER_TIMEOUTS = {
117378
+ /** 等响应头的上限(HITL 审批挂在这一段:请求发出去了,人还没点)。 */
117379
+ headersTimeout: 216e5,
117380
+ /** 两个 body 分片之间的上限(SSE / 流式响应的静默段)。 */
117381
+ bodyTimeout: 216e5
117382
+ };
117383
+ }
117384
+ });
117385
+
117299
117386
  // build-src/src/utils/caCerts.ts
117300
117387
  var caCerts_exports = {};
117301
117388
  __export(caCerts_exports, {
@@ -121100,7 +121187,7 @@ var require_webidl = __commonJS({
121100
121187
  return new TypeError(`${message.header}: ${message.message}`);
121101
121188
  };
121102
121189
  webidl.errors.conversionFailed = function(opts) {
121103
- let plural5 = opts.types.length === 1 ? "" : " one of", message = `${opts.argument} could not be converted to${plural5}: ${opts.types.join(", ")}.`;
121190
+ let plural6 = opts.types.length === 1 ? "" : " one of", message = `${opts.argument} could not be converted to${plural6}: ${opts.types.join(", ")}.`;
121104
121191
  return webidl.errors.exception({
121105
121192
  header: opts.prefix,
121106
121193
  message
@@ -136156,7 +136243,10 @@ function getTLSFetchOptions() {
136156
136243
  passphrase: tlsConfig.passphrase,
136157
136244
  ...tlsConfig.ca && { ca: tlsConfig.ca }
136158
136245
  },
136159
- pipelining: 1
136246
+ pipelining: 1,
136247
+ // #270:长挂豁免。缺省 300s 会把 plan_review 这类「挂着等人做决定」的请求单方面掐断
136248
+ // (引擎侧记 499),用户观感 = 审批完没反应。取值理由见 dispatcherTimeouts.ts 头注。
136249
+ ...LONG_POLL_DISPATCHER_TIMEOUTS
136160
136250
  }) };
136161
136251
  }
136162
136252
  function clearMTLSCache() {
@@ -136172,6 +136262,7 @@ var getMTLSConfig, getMTLSAgent, init_mtls = __esm({
136172
136262
  init_memoize();
136173
136263
  init_caCerts();
136174
136264
  init_debug();
136265
+ init_dispatcherTimeouts();
136175
136266
  init_fsOperations();
136176
136267
  getMTLSConfig = memoize_default(() => {
136177
136268
  let config4 = {};
@@ -136392,11 +136483,15 @@ var import_https_proxy_agent2, keepAliveDisabled, getProxyAgent, proxyIntercepto
136392
136483
  init_memoize();
136393
136484
  init_caCerts();
136394
136485
  init_debug();
136486
+ init_dispatcherTimeouts();
136395
136487
  init_envUtils();
136396
136488
  init_mtls();
136397
136489
  keepAliveDisabled = !1;
136398
136490
  getProxyAgent = memoize_default((uri) => {
136399
136491
  let undiciMod = require_undici(), mtlsConfig = getMTLSConfig(), caCerts = getCACertificates(), proxyOptions = {
136492
+ // #270:长挂豁免。EnvHttpProxyAgent 把这两个键透传给它内部的 no-proxy/http/https 三个
136493
+ // 子 agent(缺一条真实路径就等于没修)。取值理由见 dispatcherTimeouts.ts 头注。
136494
+ ...LONG_POLL_DISPATCHER_TIMEOUTS,
136400
136495
  // Override both HTTP and HTTPS proxy with the provided URI
136401
136496
  httpProxy: uri,
136402
136497
  httpsProxy: uri,
@@ -136479,10 +136574,16 @@ async function injectDispatcher(extra) {
136479
136574
  noProxy: process.env.NO_PROXY || process.env.no_proxy,
136480
136575
  connect: { ca }
136481
136576
  };
136482
- opts.requestTls = { ca }, undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent(opts));
136577
+ opts.requestTls = { ca }, Object.assign(opts, LONG_POLL_DISPATCHER_TIMEOUTS), undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent(opts));
136483
136578
  return;
136484
136579
  }
136485
- undici.setGlobalDispatcher(new undici.Agent({ connect: { ca: [...tls.rootCertificates, ...extra] } }));
136580
+ undici.setGlobalDispatcher(
136581
+ new undici.Agent({
136582
+ connect: { ca: [...tls.rootCertificates, ...extra] },
136583
+ // #270 同上:无代理臂也是一个真的全局出口,同样不许留在 300s 缺省。
136584
+ ...LONG_POLL_DISPATCHER_TIMEOUTS
136585
+ })
136586
+ );
136486
136587
  }
136487
136588
  async function applyPersistedTlsTrust() {
136488
136589
  try {
@@ -136523,6 +136624,7 @@ async function applySystemTlsTrust() {
136523
136624
  var caPath, builtinRootBodies, init_tlsTrust = __esm({
136524
136625
  "build-src/src/sema/tlsTrust.ts"() {
136525
136626
  init_failOpen();
136627
+ init_dispatcherTimeouts();
136526
136628
  init_envUtils();
136527
136629
  caPath = () => join32(getClaudeConfigHomeDir(), "extra-ca.pem");
136528
136630
  }
@@ -171585,16 +171687,37 @@ var officialUrls, init_officialRegistry = __esm({
171585
171687
  });
171586
171688
 
171587
171689
  // build-src/src/utils/agentSwarmsEnabled.ts
171588
- function isAgentTeamsFlagSet() {
171589
- return process.argv.includes("--agent-teams");
171690
+ function readAgentTeamsSetting() {
171691
+ if (!isSettingSourceEnabled("userSettings")) return !1;
171692
+ try {
171693
+ return getSettingsForSource("userSettings")?.semaAgentTeamsEnabled === !0;
171694
+ } catch {
171695
+ return !1;
171696
+ }
171697
+ }
171698
+ function argvHasFlagBeforeTerminator(argv, flag) {
171699
+ let terminator = argv.indexOf("--");
171700
+ return (terminator === -1 ? argv : argv.slice(0, terminator)).includes(flag);
171701
+ }
171702
+ function agentTeamsEnabledFrom(settingEnabled, env5, argv) {
171703
+ return settingEnabled || isEnvTruthy(env5[AGENT_TEAMS_ENV_VAR]) ? !0 : argvHasFlagBeforeTerminator(argv, AGENT_TEAMS_FLAG);
171704
+ }
171705
+ function agentTeamsSettingCached() {
171706
+ return settingCache === void 0 && (settingCache = readAgentTeamsSetting()), settingCache;
171590
171707
  }
171591
171708
  function isAgentSwarmsEnabled() {
171592
- return process.env.USER_TYPE === "ant" ? !0 : !(!isEnvTruthy(process.env.SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS) && !isAgentTeamsFlagSet() || !getFeatureValue_CACHED_MAY_BE_STALE2("tengu_amber_flint", !0));
171709
+ return agentTeamsEnabledFrom(
171710
+ agentTeamsSettingCached(),
171711
+ process.env,
171712
+ process.argv
171713
+ );
171593
171714
  }
171594
- var init_agentSwarmsEnabled = __esm({
171715
+ var AGENT_TEAMS_ENV_VAR, AGENT_TEAMS_SETTING_KEY, AGENT_TEAMS_FLAG, settingCache, init_agentSwarmsEnabled = __esm({
171595
171716
  "build-src/src/utils/agentSwarmsEnabled.ts"() {
171596
- init_growthbook_advisor_flag();
171597
171717
  init_envUtils();
171718
+ init_constants2();
171719
+ init_settings2();
171720
+ AGENT_TEAMS_ENV_VAR = "SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS", AGENT_TEAMS_SETTING_KEY = "semaAgentTeamsEnabled", AGENT_TEAMS_FLAG = "--agent-teams";
171598
171721
  }
171599
171722
  });
171600
171723
 
@@ -177483,6 +177606,7 @@ __export(leaderPermissionBridge_exports, {
177483
177606
  registerLeaderSetToolPermissionContext: () => registerLeaderSetToolPermissionContext,
177484
177607
  registerLeaderToolUseConfirmQueue: () => registerLeaderToolUseConfirmQueue,
177485
177608
  setLeaderPendingDecisionCardCount: () => setLeaderPendingDecisionCardCount,
177609
+ subscribeToLeaderPendingDecisionCards: () => subscribeToLeaderPendingDecisionCards,
177486
177610
  unregisterLeaderSetToolPermissionContext: () => unregisterLeaderSetToolPermissionContext,
177487
177611
  unregisterLeaderToolUseConfirmQueue: () => unregisterLeaderToolUseConfirmQueue
177488
177612
  });
@@ -177496,7 +177620,8 @@ function unregisterLeaderToolUseConfirmQueue() {
177496
177620
  registeredSetter = null;
177497
177621
  }
177498
177622
  function setLeaderPendingDecisionCardCount(count3) {
177499
- pendingDecisionCardCount = Number.isFinite(count3) && count3 > 0 ? count3 : 0;
177623
+ let next = Number.isFinite(count3) && count3 > 0 ? count3 : 0;
177624
+ next !== pendingDecisionCardCount && (pendingDecisionCardCount = next, pendingDecisionCardsChanged.emit());
177500
177625
  }
177501
177626
  function leaderHasPendingDecisionCard() {
177502
177627
  return pendingDecisionCardCount > 0;
@@ -177513,10 +177638,11 @@ function getLeaderSetToolPermissionContext() {
177513
177638
  function unregisterLeaderSetToolPermissionContext() {
177514
177639
  registeredPermissionContextSetter = null;
177515
177640
  }
177516
- var registeredSetter, registeredPermissionContextSetter, pendingDecisionCardCount, init_leaderPermissionBridge = __esm({
177641
+ var registeredSetter, registeredPermissionContextSetter, pendingDecisionCardCount, pendingDecisionCardsChanged, subscribeToLeaderPendingDecisionCards, init_leaderPermissionBridge = __esm({
177517
177642
  "build-src/src/utils/swarm/leaderPermissionBridge.ts"() {
177643
+ init_signal();
177518
177644
  registeredSetter = null, registeredPermissionContextSetter = null;
177519
- pendingDecisionCardCount = 0;
177645
+ pendingDecisionCardCount = 0, pendingDecisionCardsChanged = createSignal(), subscribeToLeaderPendingDecisionCards = pendingDecisionCardsChanged.subscribe;
177520
177646
  }
177521
177647
  });
177522
177648
 
@@ -178059,11 +178185,29 @@ function enqueue(command8) {
178059
178185
  );
178060
178186
  }
178061
178187
  function enqueuePendingNotification(command8) {
178062
- commandQueue.push({ ...command8, priority: command8.priority ?? "later" }), notifySubscribers(), logOperation(
178188
+ commandQueue.push({ ...command8, priority: command8.priority ?? "later", isMeta: command8.isMeta ?? !0 }), notifySubscribers(), logOperation(
178063
178189
  "enqueue",
178064
178190
  typeof command8.value == "string" ? command8.value : void 0
178065
178191
  );
178066
178192
  }
178193
+ function requeueFailedInjection(command8) {
178194
+ if (command8.isMeta !== !0) return !1;
178195
+ let attempts = (command8.requeueCount ?? 0) + 1;
178196
+ return attempts > MAX_INJECTION_REQUEUES ? !1 : (commandQueue.push({
178197
+ ...command8,
178198
+ priority: command8.priority ?? "later",
178199
+ requeueCount: attempts,
178200
+ // 归零推迟预算(1.0.83 扫码异源复审 F3):不归零则到顶件回灌后下一拍闸恒放行,撞同一张
178201
+ // 未答卡即再回灌,自激三圈秒级烧光 requeue 预算丢通知;归零后回灌件重新静止等卡信号。
178202
+ deferCount: 0
178203
+ }), notifySubscribers(), logOperation(
178204
+ "enqueue",
178205
+ typeof command8.value == "string" ? command8.value : void 0
178206
+ ), !0);
178207
+ }
178208
+ function noteInjectionDeferred(command8) {
178209
+ command8.deferCount = (command8.deferCount ?? 0) + 1;
178210
+ }
178067
178211
  function dequeue(filter2) {
178068
178212
  if (commandQueue.length === 0)
178069
178213
  return;
@@ -178175,7 +178319,7 @@ function getCommandsByMaxPriority(maxPriority) {
178175
178319
  (cmd) => PRIORITY_ORDER[cmd.priority ?? "next"] <= threshold2
178176
178320
  );
178177
178321
  }
178178
- var commandQueue, snapshot2, queueChanged, subscribeToCommandQueue, PRIORITY_ORDER, NON_EDITABLE_MODES, init_messageQueueManager = __esm({
178322
+ var commandQueue, snapshot2, queueChanged, subscribeToCommandQueue, MAX_INJECTION_REQUEUES, MAX_INJECTION_DEFERRALS, PRIORITY_ORDER, NON_EDITABLE_MODES, init_messageQueueManager = __esm({
178179
178323
  "build-src/src/utils/messageQueueManager.ts"() {
178180
178324
  init_state();
178181
178325
  init_messages4();
@@ -178184,6 +178328,8 @@ var commandQueue, snapshot2, queueChanged, subscribeToCommandQueue, PRIORITY_ORD
178184
178328
  init_signal();
178185
178329
  commandQueue = [], snapshot2 = Object.freeze([]), queueChanged = createSignal();
178186
178330
  subscribeToCommandQueue = queueChanged.subscribe;
178331
+ MAX_INJECTION_REQUEUES = 3;
178332
+ MAX_INJECTION_DEFERRALS = 2;
178187
178333
  PRIORITY_ORDER = {
178188
178334
  now: 0,
178189
178335
  next: 1,
@@ -181919,6 +182065,29 @@ var status, listeners7, fadeTimer, init_engineRuntimeStatus = __esm({
181919
182065
  }
181920
182066
  });
181921
182067
 
182068
+ // build-src/src/utils/injectionRequeueLatch.ts
182069
+ function beginSubmissionTurn() {
182070
+ let id = nextTurnId++;
182071
+ return activeTurnId = id, id;
182072
+ }
182073
+ function noteSubmissionHeldForDecision() {
182074
+ if (activeTurnId !== null)
182075
+ for (heldTurnIds.add(activeTurnId); heldTurnIds.size > MAX_HELD_TURNS; ) {
182076
+ let oldest = heldTurnIds.values().next();
182077
+ if (oldest.done) break;
182078
+ heldTurnIds.delete(oldest.value);
182079
+ }
182080
+ }
182081
+ function consumeSubmissionHeldForDecision(turnId) {
182082
+ let held = heldTurnIds.delete(turnId);
182083
+ return activeTurnId === turnId && (activeTurnId = null), held;
182084
+ }
182085
+ var nextTurnId, activeTurnId, heldTurnIds, MAX_HELD_TURNS, init_injectionRequeueLatch = __esm({
182086
+ "build-src/src/utils/injectionRequeueLatch.ts"() {
182087
+ nextTurnId = 1, activeTurnId = null, heldTurnIds = /* @__PURE__ */ new Set(), MAX_HELD_TURNS = 32;
182088
+ }
182089
+ });
182090
+
181922
182091
  // build-src/src/sema/engineAttachCapabilityGate.ts
181923
182092
  var engineAttachCapabilityGate_exports = {};
181924
182093
  __export(engineAttachCapabilityGate_exports, {
@@ -182306,10 +182475,10 @@ function lockedTokenProvider(profileName) {
182306
182475
  }), lastIssuedRefreshToken = tokens.refreshToken, foreignRotationObserved = !1;
182307
182476
  },
182308
182477
  async clear() {
182309
- let attempted = lastIssuedRefreshToken, foreign = foreignRotationObserved;
182478
+ let attempted2 = lastIssuedRefreshToken, foreign = foreignRotationObserved;
182310
182479
  await mutateCredentials((creds) => {
182311
182480
  let current5 = creds[profileName];
182312
- if (!current5 || attempted === void 0 || current5.refreshToken !== attempted || foreign) return !1;
182481
+ if (!current5 || attempted2 === void 0 || current5.refreshToken !== attempted2 || foreign) return !1;
182313
182482
  delete creds[profileName];
182314
182483
  });
182315
182484
  }
@@ -185319,8 +185488,8 @@ Fix: run \`sema doctor\` to diagnose, or restart sema to retry.`
185319
185488
  // —— 一条中止口的在场与否不该取决于「这一轮有没有铸卡」。顶层形是它的严格超集,
185320
185489
  // 车B 的消费面(deps.signal)逐字不变。
185321
185490
  ...signal ? { signal } : {}
185322
- });
185323
- if (yield apiErrorRow(activeRunSelfHealRow(outcome, detectedBusy)), outcome.kind === "running-cancelled" && !signal?.aborted) {
185491
+ }), submissionOrigin = trailingStandaloneMetaUserMessages(params.messages).length > 0 ? "injected" : "user";
185492
+ if (submissionOrigin === "injected" && isMainLaneQuerySource(params.querySource) && selfHealSubmissionDisposition(outcome) === "held-for-decision" && noteSubmissionHeldForDecision(), yield apiErrorRow(activeRunSelfHealRow(outcome, detectedBusy, void 0, submissionOrigin)), outcome.kind === "running-cancelled" && !signal?.aborted) {
185324
185493
  retryStream = !0;
185325
185494
  continue;
185326
185495
  }
@@ -185598,6 +185767,7 @@ var BG_TEAR_MAX_RESENDS, BG_RECOVERY_WAIT_MS, DRAINING_MAX_RETRIES, drainingBack
185598
185767
  init_log2();
185599
185768
  init_engineRuntimeStatus();
185600
185769
  init_activeRunSelfHeal2();
185770
+ init_injectionRequeueLatch();
185601
185771
  BG_TEAR_MAX_RESENDS = 2, BG_RECOVERY_WAIT_MS = 12e4, DRAINING_MAX_RETRIES = 3;
185602
185772
  client = makeMockClient(), clientExplicitlySet = !1;
185603
185773
  seamRewindCapture = !0;
@@ -189726,14 +189896,22 @@ var PROMPT_PREFIX, init_bashClassifier = __esm({
189726
189896
  // build-src/src/utils/permissions/permissionsLoader.ts
189727
189897
  var permissionsLoader_exports = {};
189728
189898
  __export(permissionsLoader_exports, {
189899
+ _resetPermissionsLoaderNoticesForTest: () => _resetPermissionsLoaderNoticesForTest,
189729
189900
  addPermissionRulesToSettings: () => addPermissionRulesToSettings,
189730
189901
  deletePermissionRuleFromSettings: () => deletePermissionRuleFromSettings,
189731
189902
  getPermissionRulesForSource: () => getPermissionRulesForSource,
189732
189903
  loadAllPermissionRulesFromDisk: () => loadAllPermissionRulesFromDisk,
189904
+ permissionsLoaderLoudNoticesActive: () => permissionsLoaderLoudNoticesActive,
189733
189905
  resolveManagedPermissionRuleScope: () => resolveManagedPermissionRuleScope,
189734
189906
  shouldAllowManagedPermissionRulesOnly: () => shouldAllowManagedPermissionRulesOnly,
189735
189907
  shouldShowAlwaysAllowOptions: () => shouldShowAlwaysAllowOptions
189736
189908
  });
189909
+ function permissionsLoaderLoudNoticesActive() {
189910
+ return [...loudPermissionsLoaderNotices];
189911
+ }
189912
+ function _resetPermissionsLoaderNoticesForTest() {
189913
+ loudManagedPolicyDegradationEmitted = !1, loudPermissionsLoaderNotices.length = 0;
189914
+ }
189737
189915
  function shouldAllowManagedPermissionRulesOnly() {
189738
189916
  return resolveManagedPermissionRuleScope() !== "all-sources";
189739
189917
  }
@@ -189741,10 +189919,16 @@ function resolveManagedPermissionRuleScope() {
189741
189919
  let health = resolveManagedPolicyLayerHealth(
189742
189920
  () => filterManagedPolicyErrors(getSettingsWithErrors().errors)
189743
189921
  );
189744
- return health.healthy ? getSettingsForSource("policySettings")?.allowManagedPermissionRulesOnly === !0 ? "managed-only" : "all-sources" : (loudManagedPolicyDegradationEmitted || (loudManagedPolicyDegradationEmitted = !0, process.stderr.write(
189745
- `[sema] permission rules degraded to policy deny/ask only (fail-closed): ${health.loudReason} \u2014 allow rules from every source (including the user-writable HKCU policy slot) are NOT applied until the managed policy layer reads cleanly
189746
- `
189747
- )), "degraded");
189922
+ if (!health.healthy) {
189923
+ if (!loudManagedPolicyDegradationEmitted) {
189924
+ loudManagedPolicyDegradationEmitted = !0;
189925
+ let msg = `permission rules degraded to policy deny/ask only (fail-closed): ${health.loudReason} \u2014 allow rules from every source (including the user-writable HKCU policy slot) are NOT applied until the managed policy layer reads cleanly`;
189926
+ process.stderr.write(`[sema] ${msg}
189927
+ `), loudPermissionsLoaderNotices.push(msg);
189928
+ }
189929
+ return "degraded";
189930
+ }
189931
+ return getSettingsForSource("policySettings")?.allowManagedPermissionRulesOnly === !0 ? "managed-only" : "all-sources";
189748
189932
  }
189749
189933
  function shouldShowAlwaysAllowOptions() {
189750
189934
  return !shouldAllowManagedPermissionRulesOnly();
@@ -189855,7 +190039,7 @@ function addPermissionRulesToSettings({
189855
190039
  return logError(error51), !1;
189856
190040
  }
189857
190041
  }
189858
- var loudManagedPolicyDegradationEmitted, SUPPORTED_RULE_BEHAVIORS, EDITABLE_SOURCES, init_permissionsLoader = __esm({
190042
+ var loudManagedPolicyDegradationEmitted, loudPermissionsLoaderNotices, SUPPORTED_RULE_BEHAVIORS, EDITABLE_SOURCES, init_permissionsLoader = __esm({
189859
190043
  "build-src/src/utils/permissions/permissionsLoader.ts"() {
189860
190044
  init_fileRead();
189861
190045
  init_fsOperations();
@@ -189865,7 +190049,7 @@ var loudManagedPolicyDegradationEmitted, SUPPORTED_RULE_BEHAVIORS, EDITABLE_SOUR
189865
190049
  init_settings2();
189866
190050
  init_settings();
189867
190051
  init_permissionRuleParser();
189868
- loudManagedPolicyDegradationEmitted = !1;
190052
+ loudManagedPolicyDegradationEmitted = !1, loudPermissionsLoaderNotices = [];
189869
190053
  SUPPORTED_RULE_BEHAVIORS = [
189870
190054
  "allow",
189871
190055
  "deny",
@@ -269485,17 +269669,18 @@ var FINGERPRINT_SALT, init_fingerprint = __esm({
269485
269669
 
269486
269670
  // build-src/src/sema/livePrincipal.ts
269487
269671
  function resolveLivePrincipal() {
269488
- return normalizeWirePrincipal(process.env.SEMA_LIVE_PRINCIPAL);
269672
+ return normalizeWirePrincipal(process.env.SEMA_LIVE_PRINCIPAL) ?? SINGLE_TENANT_DEFAULT;
269489
269673
  }
269490
269674
  function resolveFleetPrincipal() {
269491
269675
  return normalizeWirePrincipal(process.env.SEMA_FLEET_PRINCIPAL) ?? resolveLivePrincipal();
269492
269676
  }
269493
269677
  function describeLivePrincipal() {
269494
- return resolveLivePrincipal() ?? "absent(owner-null)";
269678
+ return resolveLivePrincipal();
269495
269679
  }
269496
- var init_livePrincipal = __esm({
269680
+ var SINGLE_TENANT_DEFAULT, init_livePrincipal = __esm({
269497
269681
  "build-src/src/sema/livePrincipal.ts"() {
269498
269682
  init_dist();
269683
+ SINGLE_TENANT_DEFAULT = "default";
269499
269684
  }
269500
269685
  });
269501
269686
 
@@ -295468,6 +295653,10 @@ var init_systemPromptType = __esm({
295468
295653
  });
295469
295654
 
295470
295655
  // build-src/src/stubs/bun-bundle.js
295656
+ var bun_bundle_exports = {};
295657
+ __export(bun_bundle_exports, {
295658
+ feature: () => feature
295659
+ });
295471
295660
  function feature(flag) {
295472
295661
  return ON.has(flag);
295473
295662
  }
@@ -300243,7 +300432,7 @@ async function compactConversation(messages, context3, cacheSafeParams, suppress
300243
300432
  };
300244
300433
  }
300245
300434
  if (summary) {
300246
- if (startsWithApiErrorPrefix(summary))
300435
+ if (startsWithApiErrorPrefix(summary) || isGovernanceStopRowText(summary))
300247
300436
  throw new Error(summary);
300248
300437
  } else throw logForDebugging(
300249
300438
  `Compact failed: no summary text in response. Response: ${jsonStringify(summaryResponse)}`,
@@ -300427,7 +300616,7 @@ User context: ${userFeedback}` : hookResult.newCustomInstructions ? customInstru
300427
300616
  };
300428
300617
  }
300429
300618
  if (summary) {
300430
- if (startsWithApiErrorPrefix(summary))
300619
+ if (startsWithApiErrorPrefix(summary) || isGovernanceStopRowText(summary))
300431
300620
  throw {
300432
300621
  ...failureMetadata
300433
300622
  }, new Error(summary);
@@ -300853,6 +301042,7 @@ var POST_COMPACT_MAX_FILES_TO_RESTORE, POST_COMPACT_TOKEN_BUDGET, POST_COMPACT_M
300853
301042
  init_analytics_index();
300854
301043
  init_claude();
300855
301044
  init_errors7();
301045
+ init_dist();
300856
301046
  init_promptCacheBreakDetection();
300857
301047
  init_withRetry();
300858
301048
  init_internalLogging();
@@ -304301,7 +304491,17 @@ var PROVIDER_MANAGED_ENV_VARS, PROVIDER_MANAGED_ENV_PREFIXES, DANGEROUS_SHELL_SE
304301
304491
  "SEMA_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
304302
304492
  "SEMA_CODE_DISABLE_TERMINAL_TITLE",
304303
304493
  "SEMA_CODE_ENABLE_TELEMETRY",
304304
- "SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS",
304494
+ // 🔴 sema 分歧(安全收紧类,cc-divergences 已登记;#287 / C-R13,对抗复审 finding):CC 把
304495
+ // agent-teams 的 opt-in env 放在这张**项目可写**的允许表里,于是 clone 来的仓库只要在
304496
+ // `.sema/settings.json` 的 `env` 块写一行,就能替用户挂上具名队友族(TeamCreate/TeamDelete/
304497
+ // SendMessage + 起子进程/worktree 的队友任务)—— 把 agentSwarmsEnabled 那道「只认用户级 settings
304498
+ // 且服从 --setting-sources」的隔离整条绕过去。这类「能起进程、能改状态」的能力位不属于
304499
+ // 「项目可安全设置」的语义,故移出本表。
304500
+ // 影响面两条,都朝更紧的方向:①applySafeConfigEnvironmentVariables 的合并层不再从
304501
+ // project/local 注入它(受信源 user/flag/policy 走 TRUSTED 循环灌全部键,不受影响 ⇒ 用户级
304502
+ // `env` 块照常生效);②bashPermissions 的前缀跳过表同源 —— 带该前缀的命令不再被当成
304503
+ // 「可忽略的安全赋值」去匹配 allow 规则,退回询问。
304504
+ // 'SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS' —— 见上,刻意不在册。
304305
304505
  "SEMA_CODE_IDE_SKIP_AUTO_INSTALL",
304306
304506
  "SEMA_CODE_MAX_OUTPUT_TOKENS",
304307
304507
  "SEMA_CODE_SKIP_BEDROCK_AUTH",
@@ -305873,14 +306073,12 @@ var EN_MESSAGES, init_messages_en = __esm({
305873
306073
  "onboard.station.mcp": "MCP servers",
305874
306074
  "onboard.station.skills": "Skills",
305875
306075
  "onboard.station.plugins": "Plugins",
305876
- "onboard.station.rules": "Permission rules",
305877
306076
  // ── onboard: per-station "you can change this anytime" blurbs ─────────────────────────────
305878
306077
  "onboard.blurb.model": "Add the model(s) sema should use \u2014 you can change this anytime with `sema config model`.",
305879
306078
  "onboard.blurb.tiers": "Bind your models to tiers (pro drives everyday work, flash the cheap volume) and pick the default tier \u2014 you can change this anytime with `sema config tiers`.",
305880
306079
  "onboard.blurb.mcp": "Import MCP servers \u2014 you can change this anytime with `sema config mcp`.",
305881
306080
  "onboard.blurb.skills": "Import skills \u2014 you can change this anytime with `sema config skills`.",
305882
306081
  "onboard.blurb.plugins": "Install plugins \u2014 you can change this anytime with `sema config plugins`.",
305883
- "onboard.blurb.rules": "Import the commands you already allow in Claude Code, so sema stops asking about them \u2014 you can review them anytime with `/permissions`.",
305884
306082
  // ── onboard: the theme station's own copy (the first thing a first-run user reads) ─────────
305885
306083
  "onboard.welcome.title": "\u273B Welcome to Sema",
305886
306084
  "onboard.welcome.tagline": "One shell, your whole fleet \u2014 local engine autostart, multi-agent orchestration, cloud when you want it.",
@@ -305989,14 +306187,12 @@ var ZH_MESSAGES, init_messages_zh = __esm({
305989
306187
  "onboard.station.mcp": "MCP \u670D\u52A1\u5668",
305990
306188
  "onboard.station.skills": "\u6280\u80FD",
305991
306189
  "onboard.station.plugins": "\u63D2\u4EF6",
305992
- "onboard.station.rules": "\u6743\u9650\u89C4\u5219",
305993
306190
  // ── onboard:各站「随时可改」说明行 ──────────────────────────────────────────────────────
305994
306191
  "onboard.blurb.model": "\u6DFB\u52A0 sema \u8981\u7528\u7684\u6A21\u578B \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config model` \u4FEE\u6539\u3002",
305995
306192
  "onboard.blurb.tiers": "\u628A\u6A21\u578B\u7ED1\u5230\u5404\u4E2A\u6863\u4F4D(pro \u8DD1\u65E5\u5E38\u3001flash \u8DD1\u4FBF\u5B9C\u7684\u91CF),\u5E76\u9009\u4E00\u4E2A\u9ED8\u8BA4\u6863 \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config tiers` \u4FEE\u6539\u3002",
305996
306193
  "onboard.blurb.mcp": "\u5BFC\u5165 MCP \u670D\u52A1\u5668 \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config mcp` \u4FEE\u6539\u3002",
305997
306194
  "onboard.blurb.skills": "\u5BFC\u5165\u6280\u80FD \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config skills` \u4FEE\u6539\u3002",
305998
306195
  "onboard.blurb.plugins": "\u5B89\u88C5\u63D2\u4EF6 \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config plugins` \u4FEE\u6539\u3002",
305999
- "onboard.blurb.rules": "\u628A\u4F60\u5728 Claude Code \u91CC\u5DF2\u7ECF\u5141\u8BB8\u7684\u547D\u4EE4\u5BFC\u8FDB\u6765,sema \u5C31\u4E0D\u518D\u4E3A\u5B83\u4EEC\u5F39\u7A97\u8BE2\u95EE \u2014\u2014 \u968F\u65F6\u53EF\u7528 `/permissions` \u67E5\u770B\u3002",
306000
306196
  // ── onboard:主题站文案 ─────────────────────────────────────────────────────────────────
306001
306197
  "onboard.welcome.title": "\u273B \u6B22\u8FCE\u4F7F\u7528 Sema",
306002
306198
  "onboard.welcome.tagline": "\u4E00\u4E2A\u58F3,\u7BA1\u4F4F\u4F60\u7684\u6574\u652F\u8230\u961F \u2014\u2014 \u672C\u5730\u5F15\u64CE\u81EA\u542F\u3001\u591A\u667A\u80FD\u4F53\u7F16\u6392,\u60F3\u4E0A\u4E91\u7684\u65F6\u5019\u518D\u4E0A\u4E91\u3002",
@@ -317775,7 +317971,7 @@ function useClaudeAiLimits() {
317775
317971
  }
317776
317972
  var import_react69, init_claudeAiLimitsHook = __esm({
317777
317973
  "build-src/src/services/claudeAiLimitsHook.ts"() {
317778
- import_react69 = __toESM(require_react());
317974
+ import_react69 = __toESM(require_react(), 1);
317779
317975
  init_claudeAiLimits();
317780
317976
  }
317781
317977
  });
@@ -317936,7 +318132,7 @@ function AssistantTextMessage(t0) {
317936
318132
  return $3[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(MessageResponse, { height: 1, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(InterruptedByUser, {}) }), $3[14] = t2) : t2 = $3[14], t2;
317937
318133
  }
317938
318134
  default: {
317939
- if (startsWithApiErrorPrefix(text2)) {
318135
+ if (startsWithApiErrorPrefix(text2) || isGovernanceStopRowText(text2)) {
317940
318136
  let truncated = !verbose && text2.trim().length > MAX_API_ERROR_CHARS, t22 = text2 === API_ERROR_MESSAGE_PREFIX ? `${API_ERROR_MESSAGE_PREFIX}: Please wait a moment and try again.` : truncated ? text2.trim().slice(0, MAX_API_ERROR_CHARS) + "\u2026" : text2.trim(), t32;
317941
318137
  if ($3[15] !== t22) {
317942
318138
  let apiErrSplit = splitApiErrorSupplement(t22);
@@ -348161,26 +348357,26 @@ function formatIncomingCallsResult(result, cwd5) {
348161
348357
  let lines = [
348162
348358
  `Found ${result.length} incoming ${plural(result.length, "call")}:`
348163
348359
  ], byFile = /* @__PURE__ */ new Map();
348164
- for (let call77 of result) {
348165
- if (!call77.from) {
348360
+ for (let call78 of result) {
348361
+ if (!call78.from) {
348166
348362
  logForDebugging(
348167
348363
  "formatIncomingCallsResult: CallHierarchyIncomingCall has undefined from field",
348168
348364
  { level: "warn" }
348169
348365
  );
348170
348366
  continue;
348171
348367
  }
348172
- let filePath = formatUri2(call77.from.uri, cwd5), existing = byFile.get(filePath);
348173
- existing ? existing.push(call77) : byFile.set(filePath, [call77]);
348368
+ let filePath = formatUri2(call78.from.uri, cwd5), existing = byFile.get(filePath);
348369
+ existing ? existing.push(call78) : byFile.set(filePath, [call78]);
348174
348370
  }
348175
348371
  for (let [filePath, calls] of byFile) {
348176
348372
  lines.push(`
348177
348373
  ${filePath}:`);
348178
- for (let call77 of calls) {
348179
- if (!call77.from)
348374
+ for (let call78 of calls) {
348375
+ if (!call78.from)
348180
348376
  continue;
348181
- let kind = symbolKindToString(call77.from.kind), line = call77.from.range.start.line + 1, callLine = ` ${call77.from.name} (${kind}) - Line ${line}`;
348182
- if (call77.fromRanges && call77.fromRanges.length > 0) {
348183
- let callSites = call77.fromRanges.map((r) => `${r.start.line + 1}:${r.start.character + 1}`).join(", ");
348377
+ let kind = symbolKindToString(call78.from.kind), line = call78.from.range.start.line + 1, callLine = ` ${call78.from.name} (${kind}) - Line ${line}`;
348378
+ if (call78.fromRanges && call78.fromRanges.length > 0) {
348379
+ let callSites = call78.fromRanges.map((r) => `${r.start.line + 1}:${r.start.character + 1}`).join(", ");
348184
348380
  callLine += ` [calls at: ${callSites}]`;
348185
348381
  }
348186
348382
  lines.push(callLine);
@@ -348195,26 +348391,26 @@ function formatOutgoingCallsResult(result, cwd5) {
348195
348391
  let lines = [
348196
348392
  `Found ${result.length} outgoing ${plural(result.length, "call")}:`
348197
348393
  ], byFile = /* @__PURE__ */ new Map();
348198
- for (let call77 of result) {
348199
- if (!call77.to) {
348394
+ for (let call78 of result) {
348395
+ if (!call78.to) {
348200
348396
  logForDebugging(
348201
348397
  "formatOutgoingCallsResult: CallHierarchyOutgoingCall has undefined to field",
348202
348398
  { level: "warn" }
348203
348399
  );
348204
348400
  continue;
348205
348401
  }
348206
- let filePath = formatUri2(call77.to.uri, cwd5), existing = byFile.get(filePath);
348207
- existing ? existing.push(call77) : byFile.set(filePath, [call77]);
348402
+ let filePath = formatUri2(call78.to.uri, cwd5), existing = byFile.get(filePath);
348403
+ existing ? existing.push(call78) : byFile.set(filePath, [call78]);
348208
348404
  }
348209
348405
  for (let [filePath, calls] of byFile) {
348210
348406
  lines.push(`
348211
348407
  ${filePath}:`);
348212
- for (let call77 of calls) {
348213
- if (!call77.to)
348408
+ for (let call78 of calls) {
348409
+ if (!call78.to)
348214
348410
  continue;
348215
- let kind = symbolKindToString(call77.to.kind), line = call77.to.range.start.line + 1, callLine = ` ${call77.to.name} (${kind}) - Line ${line}`;
348216
- if (call77.fromRanges && call77.fromRanges.length > 0) {
348217
- let callSites = call77.fromRanges.map((r) => `${r.start.line + 1}:${r.start.character + 1}`).join(", ");
348411
+ let kind = symbolKindToString(call78.to.kind), line = call78.to.range.start.line + 1, callLine = ` ${call78.to.name} (${kind}) - Line ${line}`;
348412
+ if (call78.fromRanges && call78.fromRanges.length > 0) {
348413
+ let callSites = call78.fromRanges.map((r) => `${r.start.line + 1}:${r.start.character + 1}`).join(", ");
348218
348414
  callLine += ` [called from: ${callSites}]`;
348219
348415
  }
348220
348416
  lines.push(callLine);
@@ -348777,11 +348973,11 @@ function countUniqueFilesFromCallItems(items) {
348777
348973
  return new Set(validUris).size;
348778
348974
  }
348779
348975
  function countUniqueFilesFromIncomingCalls(calls) {
348780
- let validUris = calls.map((call77) => call77.from?.uri).filter((uri) => uri);
348976
+ let validUris = calls.map((call78) => call78.from?.uri).filter((uri) => uri);
348781
348977
  return new Set(validUris).size;
348782
348978
  }
348783
348979
  function countUniqueFilesFromOutgoingCalls(calls) {
348784
- let validUris = calls.map((call77) => call77.to?.uri).filter((uri) => uri);
348980
+ let validUris = calls.map((call78) => call78.to?.uri).filter((uri) => uri);
348785
348981
  return new Set(validUris).size;
348786
348982
  }
348787
348983
  var MAX_LSP_FILE_SIZE_BYTES, inputSchema25, outputSchema21, LSPTool, init_LSPTool = __esm({
@@ -372629,6 +372825,7 @@ var classifierDecisionModule, autoModeStateModule4, CLASSIFIER_FAIL_CLOSED_REFRE
372629
372825
  // build-src/src/utils/permissions/permissionSetup.ts
372630
372826
  var permissionSetup_exports = {};
372631
372827
  __export(permissionSetup_exports, {
372828
+ __resetFactoryDefaultAutoForTests: () => __resetFactoryDefaultAutoForTests,
372632
372829
  checkAndDisableBypassPermissions: () => checkAndDisableBypassPermissions,
372633
372830
  createDisabledBypassPermissionsContext: () => createDisabledBypassPermissionsContext,
372634
372831
  findDangerousClassifierPermissions: () => findDangerousClassifierPermissions,
@@ -372647,8 +372844,10 @@ __export(permissionSetup_exports, {
372647
372844
  isDangerousPowerShellPermission: () => isDangerousPowerShellPermission,
372648
372845
  isDangerousTaskPermission: () => isDangerousTaskPermission,
372649
372846
  isDefaultPermissionModeAuto: () => isDefaultPermissionModeAuto,
372847
+ isFactoryDefaultAutoActive: () => isFactoryDefaultAutoActive,
372650
372848
  isOverlyBroadBashAllowRule: () => isOverlyBroadBashAllowRule,
372651
372849
  isOverlyBroadPowerShellAllowRule: () => isOverlyBroadPowerShellAllowRule,
372850
+ markFactoryDefaultAutoActive: () => markFactoryDefaultAutoActive,
372652
372851
  parseBaseToolsFromCLI: () => parseBaseToolsFromCLI,
372653
372852
  parseToolListFromCLI: () => parseToolListFromCLI,
372654
372853
  prepareContextForPlanMode: () => prepareContextForPlanMode,
@@ -372907,7 +373106,7 @@ function transitionPermissionMode(fromMode, toMode, context3) {
372907
373106
  if (!isAutoModeGateEnabled())
372908
373107
  throw new Error("Cannot transition to auto mode: gate is not enabled");
372909
373108
  autoModeStateModule5?.setAutoModeActive(!0), context3 = stripDangerousPermissionsForAutoMode(context3);
372910
- } else fromUsesClassifier && !toUsesClassifier && (autoModeStateModule5?.setAutoModeActive(!1), setNeedsAutoModeExitAttachment(!0), context3 = restoreDangerousPermissions(context3));
373109
+ } else fromUsesClassifier && !toUsesClassifier && (autoModeStateModule5?.setAutoModeActive(!1), setNeedsAutoModeExitAttachment(!0), factoryDefaultAutoActive = !1, context3 = restoreDangerousPermissions(context3));
372911
373110
  }
372912
373111
  return fromMode === "plan" && toMode !== "plan" && context3.prePlanMode ? { ...context3, prePlanMode: void 0 } : context3;
372913
373112
  }
@@ -372928,9 +373127,19 @@ function settingsDisableBypassFailClosed() {
372928
373127
  () => filterManagedPolicyErrors(getSettingsWithErrors().errors)
372929
373128
  ).disable;
372930
373129
  }
373130
+ function isFactoryDefaultAutoActive() {
373131
+ return factoryDefaultAutoActive;
373132
+ }
373133
+ function __resetFactoryDefaultAutoForTests() {
373134
+ factoryDefaultAutoActive = !1;
373135
+ }
373136
+ function markFactoryDefaultAutoActive() {
373137
+ factoryDefaultAutoActive = !0;
373138
+ }
372931
373139
  function initialPermissionModeFromCLI({
372932
373140
  permissionModeCli,
372933
- dangerouslySkipPermissions
373141
+ dangerouslySkipPermissions,
373142
+ factoryDefaultAutoEligible
372934
373143
  }) {
372935
373144
  let settings2 = getSettings_DEPRECATED() || {}, growthBookDisableBypassPermissionsMode = checkStatsigFeatureGate_CACHED_MAY_BE_STALE(
372936
373145
  "tengu_disable_bypass_permissions_mode"
@@ -372952,6 +373161,7 @@ function initialPermissionModeFromCLI({
372952
373161
  { level: "warn" }
372953
373162
  ) : orderedModes.push("auto") : orderedModes.push(settingsMode);
372954
373163
  }
373164
+ factoryDefaultAutoEligible && orderedModes.length === 0 && !autoModeCircuitBrokenSync && !isAutoModeDisabledBySettings() && (orderedModes.push("auto"), factoryDefaultAutoActive = !0);
372955
373165
  let result;
372956
373166
  for (let mode of orderedModes) {
372957
373167
  if (mode === "bypassPermissions" && disableBypassPermissionsMode) {
@@ -373182,7 +373392,7 @@ function isDefaultPermissionModeAuto() {
373182
373392
  return (getSettings_DEPRECATED() || {}).permissions?.defaultMode === "auto";
373183
373393
  }
373184
373394
  function shouldPlanUseAutoMode() {
373185
- return hasAutoModeOptIn() && isAutoModeGateEnabled() && getUseAutoModeDuringPlan();
373395
+ return (hasAutoModeOptIn() || isFactoryDefaultAutoActive()) && isAutoModeGateEnabled() && getUseAutoModeDuringPlan();
373186
373396
  }
373187
373397
  function prepareContextForPlanMode(context3) {
373188
373398
  let currentMode = context3.mode;
@@ -373211,7 +373421,7 @@ function transitionPlanAutoMode(context3) {
373211
373421
  let want = shouldPlanUseAutoMode(), have = autoModeStateModule5?.isAutoModeActive() ?? !1;
373212
373422
  return want && have ? stripDangerousPermissionsForAutoMode(context3) : !want && !have ? context3 : want ? (autoModeStateModule5?.setAutoModeActive(!0), setNeedsAutoModeExitAttachment(!1), stripDangerousPermissionsForAutoMode(context3)) : (autoModeStateModule5?.setAutoModeActive(!1), setNeedsAutoModeExitAttachment(!0), restoreDangerousPermissions(context3));
373213
373423
  }
373214
- var autoModeStateModule5, AUTO_MODE_ENABLED_DEFAULT, NO_CACHED_AUTO_MODE_CONFIG, init_permissionSetup = __esm({
373424
+ var autoModeStateModule5, factoryDefaultAutoActive, AUTO_MODE_ENABLED_DEFAULT, NO_CACHED_AUTO_MODE_CONFIG, init_permissionSetup = __esm({
373215
373425
  "build-src/src/utils/permissions/permissionSetup.ts"() {
373216
373426
  init_state();
373217
373427
  init_cwd();
@@ -373238,6 +373448,7 @@ var autoModeStateModule5, AUTO_MODE_ENABLED_DEFAULT, NO_CACHED_AUTO_MODE_CONFIG,
373238
373448
  init_PermissionUpdate();
373239
373449
  init_permissionRuleParser();
373240
373450
  autoModeStateModule5 = (init_autoModeState(), __toCommonJS(autoModeState_exports));
373451
+ factoryDefaultAutoActive = !1;
373241
373452
  AUTO_MODE_ENABLED_DEFAULT = "disabled";
373242
373453
  NO_CACHED_AUTO_MODE_CONFIG = /* @__PURE__ */ Symbol("no-cached-auto-mode-config");
373243
373454
  }
@@ -401313,15 +401524,14 @@ var sema_brand_default, init_sema_brand = __esm({
401313
401524
  _doc: "displayName/email \u7559 null = \u8FD0\u884C\u65F6\u56DE\u9000(\u540D\u5B57\u53D6\u672C\u673A OS \u7528\u6237\u540D,\u90AE\u7BB1\u4E0D\u663E\u793A)\u3002\u522B\u70E7\u4E2A\u4EBA\u4FE1\u606F\u8FDB\u54C1\u724C\u6587\u4EF6(F-S1-1:\u65B0\u7528\u6237\u66FE\u770B\u5230 Welcome back Clay!)\u3002"
401314
401525
  },
401315
401526
  whatsNew: {
401316
- version: "1.0.79",
401527
+ version: "1.0.82",
401317
401528
  notes: [
401318
- "Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools stay in force \u2014 degraded mode only tightens, never widens",
401319
- "Approval cards carry org-rule evidence notes end-to-end and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing",
401320
- "Engine 7.24.0 (from 7.22.0)"
401529
+ "Claude Code permission rules are imported automatically on first launch when detected \u2014 no confirmation step, and a one-line notice tells you what was imported; review or roll back anytime in /permissions",
401530
+ "Engine 7.28.0 (from 7.26.0)"
401321
401531
  ]
401322
401532
  },
401323
- productVersion: "1.0.81",
401324
- announcement: "sema 1.0.81 \u2014 Steering a specific background agent row now resolves through that row's own recorded run (no more silently steering whichever run happens to be active; a stale row fails honestly with a no-run notice instead). Background-notification trust is now graded per acceptance path and kept with the row, so panel rows never flip state on unproven evidence. Under the hood: the self-test fleet gained a port registry with hard guards, so test tooling can never touch a production engine port."
401533
+ productVersion: "1.0.83",
401534
+ announcement: "sema 1.0.83 \u2014 Auto mode is now the factory default: a fresh start with no permission configuration boots straight into auto (footer shows \u201Cauto mode on\u201D), while any explicit --permission-mode flag or settings defaultMode still wins, and the managed disableAutoMode kill-switch vetoes it at the source. Also fixed: compaction no longer replaces your history with a governance stop line, leaving auto via Shift+Tab fully retires the factory default for the session, and queued system notifications survive an open decision card instead of being dropped."
401325
401535
  };
401326
401536
  }
401327
401537
  });
@@ -405524,15 +405734,14 @@ var require_sema_brand = __commonJS({
405524
405734
  _doc: "displayName/email \u7559 null = \u8FD0\u884C\u65F6\u56DE\u9000(\u540D\u5B57\u53D6\u672C\u673A OS \u7528\u6237\u540D,\u90AE\u7BB1\u4E0D\u663E\u793A)\u3002\u522B\u70E7\u4E2A\u4EBA\u4FE1\u606F\u8FDB\u54C1\u724C\u6587\u4EF6(F-S1-1:\u65B0\u7528\u6237\u66FE\u770B\u5230 Welcome back Clay!)\u3002"
405525
405735
  },
405526
405736
  whatsNew: {
405527
- version: "1.0.79",
405737
+ version: "1.0.82",
405528
405738
  notes: [
405529
- "Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools stay in force \u2014 degraded mode only tightens, never widens",
405530
- "Approval cards carry org-rule evidence notes end-to-end and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing",
405531
- "Engine 7.24.0 (from 7.22.0)"
405739
+ "Claude Code permission rules are imported automatically on first launch when detected \u2014 no confirmation step, and a one-line notice tells you what was imported; review or roll back anytime in /permissions",
405740
+ "Engine 7.28.0 (from 7.26.0)"
405532
405741
  ]
405533
405742
  },
405534
- productVersion: "1.0.81",
405535
- announcement: "sema 1.0.81 \u2014 Steering a specific background agent row now resolves through that row's own recorded run (no more silently steering whichever run happens to be active; a stale row fails honestly with a no-run notice instead). Background-notification trust is now graded per acceptance path and kept with the row, so panel rows never flip state on unproven evidence. Under the hood: the self-test fleet gained a port registry with hard guards, so test tooling can never touch a production engine port."
405743
+ productVersion: "1.0.83",
405744
+ announcement: "sema 1.0.83 \u2014 Auto mode is now the factory default: a fresh start with no permission configuration boots straight into auto (footer shows \u201Cauto mode on\u201D), while any explicit --permission-mode flag or settings defaultMode still wins, and the managed disableAutoMode kill-switch vetoes it at the source. Also fixed: compaction no longer replaces your history with a governance stop line, leaving auto via Shift+Tab fully retires the factory default for the session, and queued system notifications survive an open decision card instead of being dropped."
405536
405745
  };
405537
405746
  }
405538
405747
  });
@@ -412900,27 +413109,27 @@ var collab, collab_default, init_collab2 = __esm({
412900
413109
  }
412901
413110
  });
412902
413111
 
412903
- // build-src/src/commands/team.ts
412904
- var USAGE, WORKFLOW_NAME, TRAMPOLINE, team, team_default, init_team = __esm({
412905
- "build-src/src/commands/team.ts"() {
413112
+ // build-src/src/commands/discuss.ts
413113
+ var USAGE, WORKFLOW_NAME, TRAMPOLINE, discuss, discuss_default, init_discuss = __esm({
413114
+ "build-src/src/commands/discuss.ts"() {
412906
413115
  init_dist();
412907
413116
  USAGE = [
412908
- "Usage: /team <topic> \u2014 start a multi-agent team discussion on the topic.",
412909
- "Example: /team should we introduce write-through caching for the session store",
413117
+ "Usage: /discuss <topic> \u2014 start a multi-agent discussion on the topic.",
413118
+ "Example: /discuss should we introduce write-through caching for the session store",
412910
413119
  "To browse collaboration-mode templates instead, use /collab."
412911
413120
  ].join(`
412912
- `), WORKFLOW_NAME = "team-discussion", TRAMPOLINE = (topic) => `The user ran /team to start a team discussion. Do this now:
413121
+ `), WORKFLOW_NAME = "team-discussion", TRAMPOLINE = (topic) => `The user ran /discuss to start a team discussion. Do this now:
412913
413122
 
412914
413123
  1. Call the Workflow tool with exactly: {"name": "${WORKFLOW_NAME}", "args": {"topic": ${JSON.stringify(topic)}}}. The user explicitly requested this discussion, which authorizes the workflow invocation.
412915
413124
  2. When the workflow finishes, present its final synthesis to the user as your answer.
412916
413125
 
412917
- If the Workflow tool is not available, or the name "${WORKFLOW_NAME}" does not resolve, do NOT pretend a discussion happened: tell the user plainly that team discussions are unavailable in this deployment, then answer the topic yourself as a single agent.`, team = {
413126
+ If the Workflow tool is not available, or the name "${WORKFLOW_NAME}" does not resolve, do NOT pretend a discussion happened: tell the user plainly that team discussions are unavailable in this deployment, then answer the topic yourself as a single agent.`, discuss = {
412918
413127
  type: "prompt",
412919
- name: "team",
413128
+ name: "discuss",
412920
413129
  // 裁项 #5 默认:壳 author 一句入口标签(成本提示,与 whenToUse 语义对齐但不逐字复制)。
412921
- description: "Start a team discussion (multi-agent, multi-round; cost \u2248 members \xD7 rounds \u2014 not for single factual questions)",
413130
+ description: "Start a multi-agent discussion (multi-round; cost \u2248 members \xD7 rounds \u2014 not for single factual questions)",
412922
413131
  argNames: ["topic"],
412923
- progressMessage: "starting team discussion",
413132
+ progressMessage: "starting discussion",
412924
413133
  contentLength: 0,
412925
413134
  // dynamic (built per-invocation from the topic)
412926
413135
  source: "builtin",
@@ -412930,10 +413139,201 @@ If the Workflow tool is not available, or the name "${WORKFLOW_NAME}" does not r
412930
413139
  throw new Error(USAGE);
412931
413140
  if (selfOrchestrationFromEnv() === void 0)
412932
413141
  throw new Error(
412933
- `Team discussions need the workflow engine, but it is disabled (${SELF_ORCHESTRATION_ENV}=${process.env[SELF_ORCHESTRATION_ENV]}). Unset ${SELF_ORCHESTRATION_ENV} (or set it to 1) and restart to enable /team.`
413142
+ `Multi-agent discussions need the workflow engine, but it is disabled (${SELF_ORCHESTRATION_ENV}=${process.env[SELF_ORCHESTRATION_ENV]}). Unset ${SELF_ORCHESTRATION_ENV} (or set it to 1) and restart to enable /discuss.`
412934
413143
  );
412935
413144
  return [{ type: "text", text: TRAMPOLINE(topic) }];
412936
413145
  }
413146
+ }, discuss_default = discuss;
413147
+ }
413148
+ });
413149
+
413150
+ // build-src/src/utils/teamDiscovery.ts
413151
+ import { readdirSync as readdirSync11 } from "fs";
413152
+ function discoverTeams(sessionId = getSessionId()) {
413153
+ let entries;
413154
+ try {
413155
+ entries = readdirSync11(getTeamsDir(), { withFileTypes: !0 }).filter((d4) => d4.isDirectory()).map((d4) => d4.name);
413156
+ } catch (e) {
413157
+ let code2 = getErrnoCode(e);
413158
+ return { teams: [], skipped: 0, dirError: code2 === "ENOENT" ? void 0 : code2 ?? "EUNKNOWN" };
413159
+ }
413160
+ let teams = [], skipped = 0;
413161
+ for (let dirName of entries)
413162
+ try {
413163
+ let teamFile = readTeamFile(dirName);
413164
+ if (!teamFile) {
413165
+ skipped++;
413166
+ continue;
413167
+ }
413168
+ let rawMembers = teamFile.members;
413169
+ if (!Array.isArray(rawMembers)) {
413170
+ skipped++;
413171
+ continue;
413172
+ }
413173
+ if (!rawMembers.every(
413174
+ (m2) => m2 !== null && typeof m2 == "object" && typeof m2.name == "string" && (m2.isActive === void 0 || typeof m2.isActive == "boolean")
413175
+ )) {
413176
+ skipped++;
413177
+ continue;
413178
+ }
413179
+ let members = rawMembers.filter((m2) => m2.name !== TEAM_LEAD_NAME), runningCount = members.filter((m2) => m2.isActive !== !1).length, name = typeof teamFile.name == "string" && teamFile.name.length > 0 ? teamFile.name : dirName;
413180
+ teams.push({
413181
+ name,
413182
+ memberCount: members.length,
413183
+ runningCount,
413184
+ idleCount: members.length - runningCount,
413185
+ ledByThisSession: typeof teamFile.leadSessionId == "string" && teamFile.leadSessionId === sessionId
413186
+ });
413187
+ } catch {
413188
+ skipped++;
413189
+ continue;
413190
+ }
413191
+ return teams.sort((a, b3) => a.name.localeCompare(b3.name)), { teams, skipped };
413192
+ }
413193
+ function getTeammateStatuses(teamName) {
413194
+ let teamFile = readTeamFile(teamName);
413195
+ if (!teamFile)
413196
+ return [];
413197
+ let hiddenPaneIds = new Set(teamFile.hiddenPaneIds ?? []), statuses = [];
413198
+ for (let member of teamFile.members) {
413199
+ if (member.name === "team-lead")
413200
+ continue;
413201
+ let status3 = member.isActive !== !1 ? "running" : "idle";
413202
+ statuses.push({
413203
+ name: member.name,
413204
+ agentId: member.agentId,
413205
+ agentType: member.agentType,
413206
+ model: member.model,
413207
+ prompt: member.prompt,
413208
+ status: status3,
413209
+ color: member.color,
413210
+ tmuxPaneId: member.tmuxPaneId,
413211
+ cwd: member.cwd,
413212
+ worktreePath: member.worktreePath,
413213
+ isHidden: hiddenPaneIds.has(member.tmuxPaneId),
413214
+ backendType: member.backendType && isPaneBackend(member.backendType) ? member.backendType : void 0,
413215
+ mode: member.mode
413216
+ });
413217
+ }
413218
+ return statuses;
413219
+ }
413220
+ var init_teamDiscovery = __esm({
413221
+ "build-src/src/utils/teamDiscovery.ts"() {
413222
+ init_errors2();
413223
+ init_state();
413224
+ init_types18();
413225
+ init_constants10();
413226
+ init_envUtils();
413227
+ init_teamHelpers();
413228
+ }
413229
+ });
413230
+
413231
+ // build-src/src/commands/team.ts
413232
+ var team_exports = {};
413233
+ __export(team_exports, {
413234
+ default: () => team_default,
413235
+ renderTeamPanel: () => renderTeamPanel,
413236
+ runTeamCommand: () => runTeamCommand,
413237
+ userSettingsPathForGuidance: () => userSettingsPathForGuidance
413238
+ });
413239
+ function sanitizeDiskText(raw2) {
413240
+ let cleaned = raw2.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").replace(/[<>]/g, "").trim();
413241
+ return cleaned.length === 0 ? "(unnamed)" : cleaned.length > 64 ? `${cleaned.slice(0, 64)}\u2026` : cleaned;
413242
+ }
413243
+ function plural4(n2, word) {
413244
+ return `${n2} ${word}${n2 === 1 ? "" : "s"}`;
413245
+ }
413246
+ function renderTeamPanel(input) {
413247
+ let { gateOpen, discovery, settingsPath, teamsDir } = input, { teams, skipped, dirError } = discovery;
413248
+ if (!gateOpen)
413249
+ return [
413250
+ "Agent teams: off (experimental, off by default).",
413251
+ "",
413252
+ "Named persistent teammates that share a task list. Turn it on with any one of",
413253
+ "these, then restart sema:",
413254
+ ` \xB7 settings \u2014 add "${AGENT_TEAMS_SETTING_KEY}": true to ${settingsPath}`,
413255
+ ` \xB7 env \u2014 ${AGENT_TEAMS_ENV_VAR}=1`,
413256
+ ` \xB7 flag \u2014 sema ${AGENT_TEAMS_FLAG}`,
413257
+ "",
413258
+ "Once it is on, /team lists your teams."
413259
+ ].join(`
413260
+ `);
413261
+ let skippedNotice = skipped > 0 ? `${plural4(skipped, "team file")} could not be read and ${skipped === 1 ? "is" : "are"} not listed above \u2014 that is not the same as not having them.` : null;
413262
+ if (dirError !== void 0)
413263
+ return [
413264
+ `Agent teams: on (experimental). Could not read the team directory (${dirError}).`,
413265
+ "",
413266
+ `${teamsDir} is unreadable, so this list may be incomplete \u2014 it does NOT mean you`,
413267
+ "have no teams. Fix the path/permissions and run /team again."
413268
+ ].join(`
413269
+ `);
413270
+ if (teams.length === 0)
413271
+ return skippedNotice ? [
413272
+ "Agent teams: on (experimental). No teams could be listed.",
413273
+ "",
413274
+ skippedNotice,
413275
+ `Team files live in ${teamsDir}.`
413276
+ ].join(`
413277
+ `) : [
413278
+ "Agent teams: on (experimental). No teams yet.",
413279
+ "",
413280
+ 'Ask Claude to create one \u2014 for example: "create a team of two reviewers to go',
413281
+ 'over this diff". Claude builds it with the TeamCreate tool.',
413282
+ `Team files live in ${teamsDir}.`
413283
+ ].join(`
413284
+ `);
413285
+ let rows2 = teams.map((t2) => {
413286
+ let counts2 = `${plural4(t2.memberCount, "teammate")} (${t2.runningCount} running, ${t2.idleCount} idle)`;
413287
+ return ` \xB7 ${sanitizeDiskText(t2.name)} \u2014 ${counts2}${t2.ledByThisSession ? " \u2014 led by this session" : ""}`;
413288
+ });
413289
+ return [
413290
+ `Agent teams: on (experimental). ${plural4(teams.length, "team")}:`,
413291
+ "",
413292
+ ...rows2,
413293
+ "",
413294
+ ...skippedNotice ? [skippedNotice] : [],
413295
+ // 诚实边界:running/idle 读的是团队台账里的 isActive 心跳位,不是进程存活探测。
413296
+ "Counts come from each team file, not from a live process probe.",
413297
+ `Team files live in ${teamsDir}.`
413298
+ ].join(`
413299
+ `);
413300
+ }
413301
+ function userSettingsPathForGuidance() {
413302
+ return getSettingsFilePathForSource("userSettings") ?? "your user settings.json";
413303
+ }
413304
+ async function runTeamCommand(args) {
413305
+ if ((args ?? "").trim().length > 0)
413306
+ return { type: "text", value: USAGE2, level: "error" };
413307
+ let gateOpen = isAgentSwarmsEnabled();
413308
+ return {
413309
+ type: "text",
413310
+ value: renderTeamPanel({
413311
+ gateOpen,
413312
+ // 门关时不去扫磁盘:功能没开,列表既无意义也只会让指路文案被噪音淹掉。
413313
+ discovery: gateOpen ? discoverTeams() : { teams: [], skipped: 0 },
413314
+ settingsPath: userSettingsPathForGuidance(),
413315
+ teamsDir: getTeamsDir()
413316
+ })
413317
+ };
413318
+ }
413319
+ var USAGE2, call44, team, team_default, init_team = __esm({
413320
+ "build-src/src/commands/team.ts"() {
413321
+ init_agentSwarmsEnabled();
413322
+ init_envUtils();
413323
+ init_settings2();
413324
+ init_teamDiscovery();
413325
+ USAGE2 = [
413326
+ "Usage: /team \u2014 show agent-teams status (named persistent teammates).",
413327
+ "It takes no arguments.",
413328
+ "To start a one-off multi-agent discussion instead, use /discuss <topic>."
413329
+ ].join(`
413330
+ `);
413331
+ call44 = (args) => runTeamCommand(args), team = {
413332
+ type: "local",
413333
+ name: "team",
413334
+ description: "Show agent-teams status: named persistent teammates and how to enable them (experimental)",
413335
+ supportsNonInteractive: !0,
413336
+ load: () => Promise.resolve({ call: call44 })
412937
413337
  }, team_default = team;
412938
413338
  }
412939
413339
  });
@@ -412941,7 +413341,7 @@ If the Workflow tool is not available, or the name "${WORKFLOW_NAME}" does not r
412941
413341
  // build-src/src/commands/think-back/thinkback.tsx
412942
413342
  var thinkback_exports = {};
412943
413343
  __export(thinkback_exports, {
412944
- call: () => call44,
413344
+ call: () => call45,
412945
413345
  playAnimation: () => playAnimation
412946
413346
  });
412947
413347
  import { readFile as readFile46 } from "fs/promises";
@@ -413214,7 +413614,7 @@ function ThinkbackFlow(t0) {
413214
413614
  let t8;
413215
413615
  return $3[22] !== handleAction || $3[23] !== hasGenerated || $3[24] !== onDone || $3[25] !== skillDir ? (t8 = /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(ThinkbackMenu, { onDone, onAction: handleAction, skillDir, hasGenerated }), $3[22] = handleAction, $3[23] = hasGenerated, $3[24] = onDone, $3[25] = skillDir, $3[26] = t8) : t8 = $3[26], t8;
413216
413616
  }
413217
- async function call44(onDone) {
413617
+ async function call45(onDone) {
413218
413618
  return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(ThinkbackFlow, { onDone });
413219
413619
  }
413220
413620
  var import_compiler_runtime210, import_react176, import_jsx_runtime302, OFFICIAL_MARKETPLACE_REPO, SKILL_NAME, EDIT_PROMPT, FIX_PROMPT, REGENERATE_PROMPT, init_thinkback = __esm({
@@ -413263,13 +413663,13 @@ var thinkback, think_back_default, init_think_back = __esm({
413263
413663
  // build-src/src/commands/thinkback-play/thinkback-play.ts
413264
413664
  var thinkback_play_exports = {};
413265
413665
  __export(thinkback_play_exports, {
413266
- call: () => call45
413666
+ call: () => call46
413267
413667
  });
413268
413668
  import { join as join155 } from "path";
413269
413669
  function getPluginId2() {
413270
413670
  return `thinkback@${process.env.USER_TYPE === "ant" ? INTERNAL_MARKETPLACE_NAME : OFFICIAL_MARKETPLACE_NAME}`;
413271
413671
  }
413272
- async function call45() {
413672
+ async function call46() {
413273
413673
  let v2Data = loadInstalledPluginsV2(), pluginId = getPluginId2(), installations = v2Data.plugins[pluginId];
413274
413674
  if (!installations || installations.length === 0)
413275
413675
  return {
@@ -413803,6 +414203,16 @@ function collectCcSettingsLayers(cwd5 = process.cwd()) {
413803
414203
  }
413804
414204
  return out6;
413805
414205
  }
414206
+ function collectCcUserLayerAt(settingsPath) {
414207
+ let root2;
414208
+ try {
414209
+ root2 = realpathSync9(homedir41());
414210
+ } catch {
414211
+ root2 = homedir41();
414212
+ }
414213
+ let out6 = { layers: [], missing: [] }, res = readOneLayer("userSettings", settingsPath, root2, { refuseSymlinks: !1 });
414214
+ return "layer" in res ? out6.layers.push(res.layer) : out6.missing.push(res.missing), out6;
414215
+ }
413806
414216
  function buildToolApprovalRespondBody(input) {
413807
414217
  let wantsPersist = typeof input.persistRule == "string" && input.persistRule !== "" && input.decision !== "deny";
413808
414218
  return {
@@ -413908,6 +414318,10 @@ var init_ccRulesImport = __esm({
413908
414318
  // build-src/src/sema/rules/ccImportMarker.ts
413909
414319
  import { existsSync as existsSync25, readFileSync as readFileSync35, writeFileSync as writeFileSync19, mkdirSync as mkdirSync20 } from "node:fs";
413910
414320
  import { join as join157, dirname as dirname73 } from "node:path";
414321
+ import { homedir as homedir42 } from "node:os";
414322
+ function ruleStoreWireAvailable(baseUrl) {
414323
+ return persistedRulesLaneAvailable2(baseUrl);
414324
+ }
413911
414325
  function markerPath() {
413912
414326
  return join157(getClaudeConfigHomeDir(), "cc-import.json");
413913
414327
  }
@@ -413921,7 +414335,8 @@ function readCcImportMarker() {
413921
414335
  return typeof raw2.importedAt != "string" || typeof raw2.importedCount != "number" ? null : {
413922
414336
  importedAt: raw2.importedAt,
413923
414337
  sourcePath: typeof raw2.sourcePath == "string" ? raw2.sourcePath : "",
413924
- importedCount: raw2.importedCount
414338
+ importedCount: raw2.importedCount,
414339
+ declined: raw2.declined === !0
413925
414340
  };
413926
414341
  } catch {
413927
414342
  return null;
@@ -413932,6 +414347,28 @@ function writeCcImportMarker(marker) {
413932
414347
  mkdirSync20(dirname73(p), { recursive: !0 }), writeFileSync19(p, JSON.stringify(marker, null, 2) + `
413933
414348
  `, "utf8");
413934
414349
  }
414350
+ function detectCcAllowRulesSource() {
414351
+ let ccEnvKey = "CLAUDE_CONFIG_DIR", ccLegacyDir = join157(homedir42(), ".claude"), roots = [process.env[ccEnvKey], ccLegacyDir].filter(
414352
+ (r) => typeof r == "string" && r.length > 0
414353
+ );
414354
+ for (let root2 of roots) {
414355
+ let p = join157(root2, "settings.json");
414356
+ if (existsSync25(p))
414357
+ try {
414358
+ let parsed = JSON.parse(readFileSync35(p, "utf8"));
414359
+ if (typeof parsed != "object" || parsed === null) continue;
414360
+ let perms = parsed.permissions;
414361
+ if (typeof perms != "object" || perms === null) continue;
414362
+ let allow = perms.allow;
414363
+ if (Array.isArray(allow) && allow.length > 0) return p;
414364
+ } catch {
414365
+ }
414366
+ }
414367
+ return null;
414368
+ }
414369
+ function ccImportBootGate(baseUrl) {
414370
+ return !ruleStoreWireAvailable(baseUrl) || readCcImportMarker() !== null ? null : detectCcAllowRulesSource();
414371
+ }
413935
414372
  var init_ccImportMarker = __esm({
413936
414373
  "build-src/src/sema/rules/ccImportMarker.ts"() {
413937
414374
  init_envUtils();
@@ -415242,13 +415679,13 @@ var import_compiler_runtime217, React107, import_react180, import_jsx_runtime312
415242
415679
  // build-src/src/commands/permissions/permissions.tsx
415243
415680
  var permissions_exports3 = {};
415244
415681
  __export(permissions_exports3, {
415245
- call: () => call46
415682
+ call: () => call47
415246
415683
  });
415247
- var import_jsx_runtime313, call46, init_permissions3 = __esm({
415684
+ var import_jsx_runtime313, call47, init_permissions3 = __esm({
415248
415685
  "build-src/src/commands/permissions/permissions.tsx"() {
415249
415686
  init_PermissionRuleList();
415250
415687
  init_messages4();
415251
- import_jsx_runtime313 = __toESM(require_jsx_runtime(), 1), call46 = async (onDone, context3) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PermissionRuleList, { onExit: onDone, onRetryDenials: (commands) => {
415688
+ import_jsx_runtime313 = __toESM(require_jsx_runtime(), 1), call47 = async (onDone, context3) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(PermissionRuleList, { onExit: onDone, onRetryDenials: (commands) => {
415252
415689
  context3.setMessages((prev) => [...prev, createPermissionRetryMessage(commands)]);
415253
415690
  } });
415254
415691
  }
@@ -415271,7 +415708,7 @@ var permissions, permissions_default, init_permissions4 = __esm({
415271
415708
  // build-src/src/commands/plan/plan.tsx
415272
415709
  var plan_exports = {};
415273
415710
  __export(plan_exports, {
415274
- call: () => call47
415711
+ call: () => call48
415275
415712
  });
415276
415713
  function PlanDisplay(t0) {
415277
415714
  let $3 = (0, import_compiler_runtime218.c)(11), {
@@ -415298,7 +415735,7 @@ function PlanDisplay(t0) {
415298
415735
  t4
415299
415736
  ] }), $3[7] = t2, $3[8] = t3, $3[9] = t4, $3[10] = t5) : t5 = $3[10], t5;
415300
415737
  }
415301
- async function call47(onDone, context3, args) {
415738
+ async function call48(onDone, context3, args) {
415302
415739
  let {
415303
415740
  getAppState,
415304
415741
  setAppState
@@ -415401,7 +415838,7 @@ var import_compiler_runtime219, import_jsx_runtime315, init_FastIcon = __esm({
415401
415838
  var fast_exports = {};
415402
415839
  __export(fast_exports, {
415403
415840
  FastModePicker: () => FastModePicker,
415404
- call: () => call48
415841
+ call: () => call49
415405
415842
  });
415406
415843
  function applyFastMode(enable, setAppState) {
415407
415844
  clearFastModeCooldown(), updateSettingsForSource("userSettings", {
@@ -415534,7 +415971,7 @@ async function handleFastModeShortcut(enable, getAppState, setAppState) {
415534
415971
  } else
415535
415972
  return "Fast mode OFF";
415536
415973
  }
415537
- async function call48(onDone, context3, args) {
415974
+ async function call49(onDone, context3, args) {
415538
415975
  if (!isFastModeEnabled())
415539
415976
  return null;
415540
415977
  await prefetchFastModeStatus();
@@ -415705,9 +416142,9 @@ var import_react182, import_jsx_runtime317, init_Passes = __esm({
415705
416142
  // build-src/src/commands/passes/passes.tsx
415706
416143
  var passes_exports = {};
415707
416144
  __export(passes_exports, {
415708
- call: () => call49
416145
+ call: () => call50
415709
416146
  });
415710
- async function call49(onDone) {
416147
+ async function call50(onDone) {
415711
416148
  let isFirstVisit = !getGlobalConfig().hasVisitedPasses;
415712
416149
  if (isFirstVisit) {
415713
416150
  let remaining = getCachedRemainingPasses();
@@ -416025,9 +416462,9 @@ var import_compiler_runtime221, import_react183, import_jsx_runtime319, NEW_TERM
416025
416462
  // build-src/src/commands/privacy-settings/privacy-settings.tsx
416026
416463
  var privacy_settings_exports = {};
416027
416464
  __export(privacy_settings_exports, {
416028
- call: () => call50
416465
+ call: () => call51
416029
416466
  });
416030
- async function call50(onDone) {
416467
+ async function call51(onDone) {
416031
416468
  if (!await isQualifiedForGrove())
416032
416469
  return onDone(FALLBACK_MESSAGE), null;
416033
416470
  let [settingsResult, configResult] = await Promise.all([getGroveSettings(), getGroveNoticeConfig()]);
@@ -417062,14 +417499,14 @@ var import_compiler_runtime225, import_react184, import_jsx_runtime325, init_Hoo
417062
417499
  // build-src/src/commands/hooks/hooks.tsx
417063
417500
  var hooks_exports = {};
417064
417501
  __export(hooks_exports, {
417065
- call: () => call51
417502
+ call: () => call52
417066
417503
  });
417067
- var import_jsx_runtime326, call51, init_hooks3 = __esm({
417504
+ var import_jsx_runtime326, call52, init_hooks3 = __esm({
417068
417505
  "build-src/src/commands/hooks/hooks.tsx"() {
417069
417506
  init_HooksConfigMenu();
417070
417507
  init_analytics_index();
417071
417508
  init_tools2();
417072
- import_jsx_runtime326 = __toESM(require_jsx_runtime(), 1), call51 = async (onDone, context3) => {
417509
+ import_jsx_runtime326 = __toESM(require_jsx_runtime(), 1), call52 = async (onDone, context3) => {
417073
417510
  let permissionContext = context3.getAppState().toolPermissionContext, toolNames = getTools(permissionContext).map((tool) => tool.name);
417074
417511
  return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(HooksConfigMenu, { toolNames, onExit: onDone });
417075
417512
  };
@@ -417092,10 +417529,10 @@ var hooks, hooks_default, init_hooks4 = __esm({
417092
417529
  // build-src/src/commands/files/files.ts
417093
417530
  var files_exports2 = {};
417094
417531
  __export(files_exports2, {
417095
- call: () => call52
417532
+ call: () => call53
417096
417533
  });
417097
417534
  import { relative as relative26 } from "path";
417098
- async function call52(_args, context3) {
417535
+ async function call53(_args, context3) {
417099
417536
  let files2 = context3.readFileState ? cacheKeys(context3.readFileState) : [];
417100
417537
  return files2.length === 0 ? { type: "text", value: "No files in context" } : { type: "text", value: `Files in context:
417101
417538
  ${files2.map((file2) => relative26(getCwd(), file2)).join(`
@@ -417233,7 +417670,7 @@ async function getUniqueForkName(baseName) {
417233
417670
  nextNumber++;
417234
417671
  return `${baseName} (Branch ${nextNumber})`;
417235
417672
  }
417236
- async function call53(onDone, context3, args) {
417673
+ async function call54(onDone, context3, args) {
417237
417674
  let customTitle = args?.trim() || void 0, originalSessionId = getSessionId();
417238
417675
  try {
417239
417676
  let {
@@ -417303,7 +417740,7 @@ function resolveDurable() {
417303
417740
  function makeLiveBranchDeps() {
417304
417741
  return {
417305
417742
  resolveDurable,
417306
- localBranch: call53
417743
+ localBranch: call54
417307
417744
  };
417308
417745
  }
417309
417746
  var init_branchDurableLive = __esm({
@@ -417342,14 +417779,14 @@ var agents_exports2 = {};
417342
417779
  __export(agents_exports2, {
417343
417780
  default: () => agents_default
417344
417781
  });
417345
- var WIZARD_REMOVED_TEXT, call54, agents, agents_default, init_agents2 = __esm({
417782
+ var WIZARD_REMOVED_TEXT, call55, agents, agents_default, init_agents2 = __esm({
417346
417783
  "build-src/src/commands/agents/index.ts"() {
417347
417784
  WIZARD_REMOVED_TEXT = `The /agents wizard has been removed.
417348
417785
 
417349
417786
  Ask sema to create or update subagents for you (e.g. "create a code-reviewer subagent that ..."),
417350
417787
  or edit the files directly:
417351
417788
  \u2022 .sema/agents/ (this project)
417352
- \u2022 ~/.sema/agents/ (all projects)`, call54 = async () => ({
417789
+ \u2022 ~/.sema/agents/ (all projects)`, call55 = async () => ({
417353
417790
  type: "text",
417354
417791
  value: WIZARD_REMOVED_TEXT
417355
417792
  }), agents = {
@@ -417357,7 +417794,7 @@ or edit the files directly:
417357
417794
  name: "agents",
417358
417795
  description: "(removed) Ask sema to create/manage subagents, or edit .sema/agents/",
417359
417796
  supportsNonInteractive: !0,
417360
- load: () => Promise.resolve({ call: call54 })
417797
+ load: () => Promise.resolve({ call: call55 })
417361
417798
  }, agents_default = agents;
417362
417799
  }
417363
417800
  });
@@ -418451,9 +418888,9 @@ For -m/--message and --remote, use the CLI: sema plugin tag --help`;
418451
418888
  // build-src/src/commands/plugin/plugin.tsx
418452
418889
  var plugin_exports = {};
418453
418890
  __export(plugin_exports, {
418454
- call: () => call55
418891
+ call: () => call56
418455
418892
  });
418456
- async function call55(onDone, context3, args) {
418893
+ async function call56(onDone, context3, args) {
418457
418894
  let getSessionContext = () => ({
418458
418895
  readFileState: context3.readFileState,
418459
418896
  bashTools: extractBashToolsFromMessages(context3.messages ?? []),
@@ -418634,12 +419071,12 @@ var init_refresh = __esm({
418634
419071
  // build-src/src/commands/reload-plugins/reload-plugins.ts
418635
419072
  var reload_plugins_exports = {};
418636
419073
  __export(reload_plugins_exports, {
418637
- call: () => call56
419074
+ call: () => call57
418638
419075
  });
418639
419076
  function n(count3, noun) {
418640
419077
  return `${count3} ${plural(count3, noun)}`;
418641
419078
  }
418642
- var call56, init_reload_plugins = __esm({
419079
+ var call57, init_reload_plugins = __esm({
418643
419080
  "build-src/src/commands/reload-plugins/reload-plugins.ts"() {
418644
419081
  init_state();
418645
419082
  init_settingsSync();
@@ -418647,7 +419084,7 @@ var call56, init_reload_plugins = __esm({
418647
419084
  init_refresh();
418648
419085
  init_changeDetector();
418649
419086
  init_stringUtils();
418650
- call56 = async (_args, context3) => {
419087
+ call57 = async (_args, context3) => {
418651
419088
  let r = await refreshActivePlugins(context3.setAppState), msg = `Reloaded: ${[
418652
419089
  n(r.enabled_count, "plugin"),
418653
419090
  n(r.command_count, "skill"),
@@ -418684,9 +419121,9 @@ var reloadPlugins, reload_plugins_default, init_reload_plugins2 = __esm({
418684
419121
  // build-src/src/commands/rewind/rewind.ts
418685
419122
  var rewind_exports = {};
418686
419123
  __export(rewind_exports, {
418687
- call: () => call57
419124
+ call: () => call58
418688
419125
  });
418689
- async function call57(_args, context3) {
419126
+ async function call58(_args, context3) {
418690
419127
  return context3.openMessageSelector && context3.openMessageSelector(), { type: "skip" };
418691
419128
  }
418692
419129
  var init_rewind = __esm({
@@ -418840,9 +419277,9 @@ var init_heapDumpService = __esm({
418840
419277
  // build-src/src/commands/heapdump/heapdump.ts
418841
419278
  var heapdump_exports = {};
418842
419279
  __export(heapdump_exports, {
418843
- call: () => call58
419280
+ call: () => call59
418844
419281
  });
418845
- async function call58() {
419282
+ async function call59() {
418846
419283
  let result = await performHeapDump();
418847
419284
  return result.success ? {
418848
419285
  type: "text",
@@ -419238,10 +419675,10 @@ var debugHandle, faultQueue, init_bridgeDebug = __esm({
419238
419675
  });
419239
419676
 
419240
419677
  // build-src/src/commands/bridge-kick.ts
419241
- var USAGE2, call59, bridgeKick, bridge_kick_default, init_bridge_kick = __esm({
419678
+ var USAGE3, call60, bridgeKick, bridge_kick_default, init_bridge_kick = __esm({
419242
419679
  "build-src/src/commands/bridge-kick.ts"() {
419243
419680
  init_bridgeDebug();
419244
- USAGE2 = `/bridge-kick <subcommand>
419681
+ USAGE3 = `/bridge-kick <subcommand>
419245
419682
  close <code> fire ws_closed with the given code (e.g. 1002)
419246
419683
  poll <status> [type] next poll throws BridgeFatalError(status, type)
419247
419684
  poll transient next poll throws axios-style rejection (5xx/net)
@@ -419250,7 +419687,7 @@ var USAGE2, call59, bridgeKick, bridge_kick_default, init_bridge_kick = __esm({
419250
419687
  reconnect-session fail next POST /bridge/reconnect fails
419251
419688
  heartbeat <status> next heartbeat throws BridgeFatalError(status)
419252
419689
  reconnect call reconnectEnvironmentWithSession directly
419253
- status print bridge state`, call59 = async (args) => {
419690
+ status print bridge state`, call60 = async (args) => {
419254
419691
  let h = getBridgeDebugHandle();
419255
419692
  if (!h)
419256
419693
  return {
@@ -419265,7 +419702,7 @@ var USAGE2, call59, bridgeKick, bridge_kick_default, init_bridge_kick = __esm({
419265
419702
  type: "text",
419266
419703
  value: `Fired transport close(${code2}). Watch debug.log for [bridge:repl] recovery.`
419267
419704
  }) : { type: "text", value: `close: need a numeric code
419268
- ${USAGE2}` };
419705
+ ${USAGE3}` };
419269
419706
  }
419270
419707
  case "poll": {
419271
419708
  if (a === "transient")
@@ -419283,7 +419720,7 @@ ${USAGE2}` };
419283
419720
  return {
419284
419721
  type: "text",
419285
419722
  value: `poll: need 'transient' or a status code
419286
- ${USAGE2}`
419723
+ ${USAGE3}`
419287
419724
  };
419288
419725
  let errorType = b3 ?? (status3 === 404 ? "not_found_error" : "authentication_error");
419289
419726
  return h.injectFault({
@@ -419352,7 +419789,7 @@ ${USAGE2}`
419352
419789
  case "status":
419353
419790
  return { type: "text", value: h.describe() };
419354
419791
  default:
419355
- return { type: "text", value: USAGE2 };
419792
+ return { type: "text", value: USAGE3 };
419356
419793
  }
419357
419794
  }, bridgeKick = {
419358
419795
  type: "local",
@@ -419360,16 +419797,16 @@ ${USAGE2}`
419360
419797
  description: "Inject bridge failure states for manual recovery testing",
419361
419798
  isEnabled: () => process.env.USER_TYPE === "ant",
419362
419799
  supportsNonInteractive: !1,
419363
- load: () => Promise.resolve({ call: call59 })
419800
+ load: () => Promise.resolve({ call: call60 })
419364
419801
  }, bridge_kick_default = bridgeKick;
419365
419802
  }
419366
419803
  });
419367
419804
 
419368
419805
  // build-src/src/commands/version.ts
419369
- var SEMA_PRODUCT_VERSION, call60, version3, version_default, init_version2 = __esm({
419806
+ var SEMA_PRODUCT_VERSION, call61, version3, version_default, init_version2 = __esm({
419370
419807
  "build-src/src/commands/version.ts"() {
419371
419808
  init_sema_brand();
419372
- SEMA_PRODUCT_VERSION = sema_brand_default.productVersion ?? "0.0.0", call60 = async () => ({
419809
+ SEMA_PRODUCT_VERSION = sema_brand_default.productVersion ?? "0.0.0", call61 = async () => ({
419373
419810
  type: "text",
419374
419811
  value: `sema ${SEMA_PRODUCT_VERSION} (CC-compatible base 2.1.187)`
419375
419812
  }), version3 = {
@@ -419378,7 +419815,7 @@ var SEMA_PRODUCT_VERSION, call60, version3, version_default, init_version2 = __e
419378
419815
  description: "Print the version this session is running (not what autoupdate downloaded)",
419379
419816
  isEnabled: () => process.env.USER_TYPE === "ant",
419380
419817
  supportsNonInteractive: !0,
419381
- load: () => Promise.resolve({ call: call60 })
419818
+ load: () => Promise.resolve({ call: call61 })
419382
419819
  }, version_default = version3;
419383
419820
  }
419384
419821
  });
@@ -419855,10 +420292,10 @@ var import_compiler_runtime228, import_jsx_runtime331, init_SandboxSettings = __
419855
420292
  // build-src/src/commands/sandbox/sandbox-toggle.tsx
419856
420293
  var sandbox_toggle_exports = {};
419857
420294
  __export(sandbox_toggle_exports, {
419858
- call: () => call61
420295
+ call: () => call62
419859
420296
  });
419860
420297
  import { relative as relative28 } from "path";
419861
- async function call61(onDone, _context, args) {
420298
+ async function call62(onDone, _context, args) {
419862
420299
  let themeName = getSettings_DEPRECATED().theme || "light", platform4 = getPlatform();
419863
420300
  if (!SandboxManager2.isSupportedPlatform()) {
419864
420301
  let errorMessage4 = platform4 === "wsl" ? "Error: Sandboxing requires WSL2. WSL1 is not supported." : "Error: Sandboxing is currently only supported on macOS, Linux, and WSL2.", message = color("error", themeName)(errorMessage4);
@@ -419987,7 +420424,7 @@ var PROD_EXTENSION_ID, DEV_EXTENSION_ID, ANT_EXTENSION_ID, init_setupPortable =
419987
420424
 
419988
420425
  // build-src/src/utils/claudeInChrome/setup.ts
419989
420426
  import { chmod as chmod12, mkdir as mkdir40, readFile as readFile50, writeFile as writeFile43 } from "fs/promises";
419990
- import { homedir as homedir42 } from "os";
420427
+ import { homedir as homedir43 } from "os";
419991
420428
  import { join as join161 } from "path";
419992
420429
  import { fileURLToPath as fileURLToPath8 } from "url";
419993
420430
  function shouldEnableClaudeInChrome(chromeFlag) {
@@ -420063,7 +420500,7 @@ function setupClaudeInChrome() {
420063
420500
  }
420064
420501
  function getNativeMessagingHostsDirs() {
420065
420502
  if (getPlatform() === "windows") {
420066
- let home = homedir42(), appData = process.env.APPDATA || join161(home, "AppData", "Local");
420503
+ let home = homedir43(), appData = process.env.APPDATA || join161(home, "AppData", "Local");
420067
420504
  return [join161(appData, "Sema", "ChromeNativeHost")];
420068
420505
  }
420069
420506
  return getAllNativeMessagingHostsDirs().map(({ path: path28 }) => path28);
@@ -420191,7 +420628,7 @@ var CHROME_EXTENSION_RECONNECT_URL, NATIVE_HOST_IDENTIFIER, NATIVE_HOST_MANIFEST
420191
420628
  // build-src/src/commands/chrome/chrome.tsx
420192
420629
  var chrome_exports = {};
420193
420630
  __export(chrome_exports, {
420194
- call: () => call62
420631
+ call: () => call63
420195
420632
  });
420196
420633
  async function callChromeTool(chromeClient, tool, args) {
420197
420634
  let result = await chromeClient.client.callTool({ name: tool, arguments: args }), content = Array.isArray(result.content) ? result.content[0] : void 0;
@@ -420408,7 +420845,7 @@ function ClaudeInChromeMenu(t0) {
420408
420845
  }
420409
420846
  );
420410
420847
  }
420411
- var import_react186, import_jsx_runtime333, CHROME_EXTENSION_URL, CHROME_PERMISSIONS_URL, CHROME_RECONNECT_URL, ConnectedBrowserSchema, call62, init_chrome = __esm({
420848
+ var import_react186, import_jsx_runtime333, CHROME_EXTENSION_URL, CHROME_PERMISSIONS_URL, CHROME_RECONNECT_URL, ConnectedBrowserSchema, call63, init_chrome = __esm({
420412
420849
  "build-src/src/commands/chrome/chrome.tsx"() {
420413
420850
  import_react186 = __toESM(require_react(), 1);
420414
420851
  init_v4();
@@ -420432,7 +420869,7 @@ var import_react186, import_jsx_runtime333, CHROME_EXTENSION_URL, CHROME_PERMISS
420432
420869
  name: external_exports.string().default("Browser"),
420433
420870
  osPlatform: external_exports.string().optional()
420434
420871
  });
420435
- call62 = async function(onDone) {
420872
+ call63 = async function(onDone) {
420436
420873
  let isExtensionInstalled = await isChromeExtensionInstalled().catch((error51) => (logError(
420437
420874
  new Error(
420438
420875
  `[Claude in Chrome] Extension detection failed: ${error51 instanceof Error ? error51.message : String(error51)}`
@@ -420470,9 +420907,9 @@ var command7, chrome_default, init_chrome2 = __esm({
420470
420907
  // build-src/src/commands/stickers/stickers.ts
420471
420908
  var stickers_exports = {};
420472
420909
  __export(stickers_exports, {
420473
- call: () => call63
420910
+ call: () => call64
420474
420911
  });
420475
- async function call63() {
420912
+ async function call64() {
420476
420913
  let url3 = "https://www.stickermule.com/claudecode";
420477
420914
  return await openBrowser(url3) ? { type: "text", value: "Opening sticker page in browser\u2026" } : {
420478
420915
  type: "text",
@@ -420647,7 +421084,7 @@ function AdvisorDialog({
420647
421084
  ] })
420648
421085
  ] }) });
420649
421086
  }
420650
- var import_react187, import_jsx_runtime334, ADVISOR_BLOG_URL, ADVISOR_REMOTE_REFUSAL, ADVISOR_MODEL_ALIASES, MODEL_CAPABILITY_RANK, call64, advisor, advisor_default, init_advisor2 = __esm({
421087
+ var import_react187, import_jsx_runtime334, ADVISOR_BLOG_URL, ADVISOR_REMOTE_REFUSAL, ADVISOR_MODEL_ALIASES, MODEL_CAPABILITY_RANK, call65, advisor, advisor_default, init_advisor2 = __esm({
420651
421088
  "build-src/src/commands/advisor.tsx"() {
420652
421089
  import_react187 = __toESM(require_react(), 1);
420653
421090
  init_select();
@@ -420669,7 +421106,7 @@ var import_react187, import_jsx_runtime334, ADVISOR_BLOG_URL, ADVISOR_REMOTE_REF
420669
421106
  "claude-mythos-5": 5,
420670
421107
  "claude-fable-5": 5
420671
421108
  };
420672
- call64 = async (onDone, _context, args) => {
421109
+ call65 = async (onDone, _context, args) => {
420673
421110
  let arg = (args ?? "").trim().toLowerCase();
420674
421111
  if (!arg)
420675
421112
  return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)(AdvisorDialog, { onDone });
@@ -420694,7 +421131,7 @@ var import_react187, import_jsx_runtime334, ADVISOR_BLOG_URL, ADVISOR_REMOTE_REF
420694
421131
  get isHidden() {
420695
421132
  return !canUserConfigureAdvisor();
420696
421133
  },
420697
- load: () => Promise.resolve({ call: call64 })
421134
+ load: () => Promise.resolve({ call: call65 })
420698
421135
  }, advisor_default = advisor;
420699
421136
  }
420700
421137
  });
@@ -420967,13 +421404,13 @@ var import_compiler_runtime229, import_jsx_runtime336, GOODBYE_MESSAGES, init_Ex
420967
421404
  // build-src/src/commands/exit/exit.tsx
420968
421405
  var exit_exports = {};
420969
421406
  __export(exit_exports, {
420970
- call: () => call65
421407
+ call: () => call66
420971
421408
  });
420972
421409
  import { spawnSync as spawnSync10 } from "child_process";
420973
421410
  function getRandomGoodbyeMessage2() {
420974
421411
  return sample_default(GOODBYE_MESSAGES2) ?? "Goodbye!";
420975
421412
  }
420976
- async function call65(onDone) {
421413
+ async function call66(onDone) {
420977
421414
  if (isBgSession())
420978
421415
  return onDone(), spawnSync10("tmux", ["detach-client"], {
420979
421416
  stdio: "ignore"
@@ -421150,7 +421587,7 @@ var import_react190, import_jsx_runtime339, init_exportRenderer = __esm({
421150
421587
  // build-src/src/commands/export/export.tsx
421151
421588
  var export_exports = {};
421152
421589
  __export(export_exports, {
421153
- call: () => call66,
421590
+ call: () => call67,
421154
421591
  extractFirstPrompt: () => extractFirstPrompt,
421155
421592
  sanitizeFilename: () => sanitizeFilename
421156
421593
  });
@@ -421180,7 +421617,7 @@ async function exportWithReactRenderer(context3) {
421180
421617
  let tools = context3.options.tools || [];
421181
421618
  return renderMessagesToPlainText(context3.messages, tools);
421182
421619
  }
421183
- async function call66(onDone, context3, args) {
421620
+ async function call67(onDone, context3, args) {
421184
421621
  let content = await exportWithReactRenderer(context3), filename = args.trim();
421185
421622
  if (filename) {
421186
421623
  let finalFilename = filename.endsWith(".txt") ? filename : filename.replace(/\.[^.]+$/, "") + ".txt", filepath = join164(getCwd(), finalFilename);
@@ -421580,7 +422017,7 @@ var import_react191, import_jsx_runtime341, NO_PREFERENCE2, HEADER_TEXT, MAX_EFF
421580
422017
  // build-src/src/commands/model/model.tsx
421581
422018
  var model_exports2 = {};
421582
422019
  __export(model_exports2, {
421583
- call: () => call67,
422020
+ call: () => call68,
421584
422021
  renderModelLabel: () => renderModelLabel
421585
422022
  });
421586
422023
  function ModelPickerWrapper(t0) {
@@ -421730,7 +422167,7 @@ function renderModelLabel(model) {
421730
422167
  let rendered = renderDefaultModelSetting(model ?? getDefaultMainLoopModelSetting());
421731
422168
  return model === null ? `${rendered} (default)` : rendered;
421732
422169
  }
421733
- var import_compiler_runtime230, React113, import_jsx_runtime342, call67, init_model2 = __esm({
422170
+ var import_compiler_runtime230, React113, import_jsx_runtime342, call68, init_model2 = __esm({
421734
422171
  "build-src/src/commands/model/model.tsx"() {
421735
422172
  import_compiler_runtime230 = __toESM(require_compiler_runtime(), 1);
421736
422173
  init_source2();
@@ -421751,7 +422188,7 @@ var import_compiler_runtime230, React113, import_jsx_runtime342, call67, init_mo
421751
422188
  init_modelAllowlist();
421752
422189
  init_validateModel();
421753
422190
  import_jsx_runtime342 = __toESM(require_jsx_runtime(), 1);
421754
- call67 = async (onDone, _context, args) => {
422191
+ call68 = async (onDone, _context, args) => {
421755
422192
  if (args = args?.trim() || "", COMMON_INFO_ARGS.includes(args))
421756
422193
  return /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(ShowModelAndClose, { onDone });
421757
422194
  if (COMMON_HELP_ARGS.includes(args)) {
@@ -421790,7 +422227,7 @@ var model_default, init_model3 = __esm({
421790
422227
  // build-src/src/commands/tag/tag.tsx
421791
422228
  var tag_exports = {};
421792
422229
  __export(tag_exports, {
421793
- call: () => call68
422230
+ call: () => call69
421794
422231
  });
421795
422232
  function ConfirmRemoveTag(t0) {
421796
422233
  let $3 = (0, import_compiler_runtime231.c)(11), {
@@ -421885,7 +422322,7 @@ Examples:
421885
422322
  });
421886
422323
  }, t2 = [onDone], $3[0] = onDone, $3[1] = t1, $3[2] = t2) : (t1 = $3[1], t2 = $3[2]), React114.useEffect(t1, t2), null;
421887
422324
  }
421888
- async function call68(onDone, _context, args) {
422325
+ async function call69(onDone, _context, args) {
421889
422326
  return args = args?.trim() || "", COMMON_INFO_ARGS.includes(args) || COMMON_HELP_ARGS.includes(args) ? /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(ShowHelp, { onDone }) : args ? /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(ToggleTagAndClose, { tagName: args, onDone }) : /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(ShowHelp, { onDone });
421890
422327
  }
421891
422328
  var import_compiler_runtime231, React114, import_jsx_runtime343, init_tag = __esm({
@@ -421922,9 +422359,9 @@ var tag, tag_default, init_tag2 = __esm({
421922
422359
  // build-src/src/commands/output-style/output-style.tsx
421923
422360
  var output_style_exports = {};
421924
422361
  __export(output_style_exports, {
421925
- call: () => call69
422362
+ call: () => call70
421926
422363
  });
421927
- async function call69(onDone) {
422364
+ async function call70(onDone) {
421928
422365
  onDone("/output-style has been deprecated. Use /config to change your output style, or set it in your settings file. Changes take effect on the next session.", {
421929
422366
  display: "system"
421930
422367
  });
@@ -422168,9 +422605,9 @@ var import_compiler_runtime232, import_react192, import_jsx_runtime344, DIALOG_T
422168
422605
  // build-src/src/commands/remote-env/remote-env.tsx
422169
422606
  var remote_env_exports = {};
422170
422607
  __export(remote_env_exports, {
422171
- call: () => call70
422608
+ call: () => call71
422172
422609
  });
422173
- async function call70(onDone) {
422610
+ async function call71(onDone) {
422174
422611
  return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(RemoteEnvironmentDialog, { onDone });
422175
422612
  }
422176
422613
  var import_jsx_runtime345, init_remote_env = __esm({
@@ -422201,9 +422638,9 @@ var remote_env_default, init_remote_env2 = __esm({
422201
422638
  // build-src/src/commands/upgrade/upgrade.tsx
422202
422639
  var upgrade_exports = {};
422203
422640
  __export(upgrade_exports, {
422204
- call: () => call71
422641
+ call: () => call72
422205
422642
  });
422206
- async function call71(onDone, context3) {
422643
+ async function call72(onDone, context3) {
422207
422644
  try {
422208
422645
  if (isClaudeAISubscriber()) {
422209
422646
  let tokens = getClaudeAIOAuthTokens(), isMax20x = !1;
@@ -422254,7 +422691,7 @@ var upgrade, upgrade_default, init_upgrade2 = __esm({
422254
422691
  // build-src/src/commands/rate-limit-options/rate-limit-options.tsx
422255
422692
  var rate_limit_options_exports = {};
422256
422693
  __export(rate_limit_options_exports, {
422257
- call: () => call72
422694
+ call: () => call73
422258
422695
  });
422259
422696
  function RateLimitOptionsMenu(t0) {
422260
422697
  let $3 = (0, import_compiler_runtime233.c)(25), {
@@ -422312,7 +422749,7 @@ function RateLimitOptionsMenu(t0) {
422312
422749
  }, $3[13] = onDone, $3[14] = t4) : t4 = $3[14];
422313
422750
  let handleCancel = t4, t5;
422314
422751
  $3[15] !== context3 || $3[16] !== handleCancel || $3[17] !== onDone ? (t5 = function(value) {
422315
- value === "upgrade" ? call71(onDone, context3).then((jsx526) => {
422752
+ value === "upgrade" ? call72(onDone, context3).then((jsx526) => {
422316
422753
  jsx526 && setSubCommandJSX(jsx526);
422317
422754
  }) : value === "extra-usage" ? call2(onDone, context3).then((jsx_0) => {
422318
422755
  jsx_0 && setSubCommandJSX(jsx_0);
@@ -422326,7 +422763,7 @@ function RateLimitOptionsMenu(t0) {
422326
422763
  let t7;
422327
422764
  return $3[22] !== handleCancel || $3[23] !== t6 ? (t7 = /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(Dialog, { title: "What do you want to do?", onCancel: handleCancel, color: "suggestion", children: t6 }), $3[22] = handleCancel, $3[23] = t6, $3[24] = t7) : t7 = $3[24], t7;
422328
422765
  }
422329
- async function call72(onDone, context3) {
422766
+ async function call73(onDone, context3) {
422330
422767
  return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)(RateLimitOptionsMenu, { onDone, context: context3 });
422331
422768
  }
422332
422769
  var import_compiler_runtime233, import_react193, import_jsx_runtime347, init_rate_limit_options = __esm({
@@ -422503,7 +422940,7 @@ var import_compiler_runtime234, React116, import_jsx_runtime348, init_effort2 =
422503
422940
  // build-src/src/sema/overrides/effort.tsx
422504
422941
  var effort_exports = {};
422505
422942
  __export(effort_exports, {
422506
- call: () => call73,
422943
+ call: () => call74,
422507
422944
  executeEffort: () => executeEffort,
422508
422945
  showCurrentEffort: () => showCurrentEffort
422509
422946
  });
@@ -422654,7 +423091,7 @@ function EffortSlider({ onDone }) {
422654
423091
  footer
422655
423092
  ] });
422656
423093
  }
422657
- async function call73(onDone, _context, args) {
423094
+ async function call74(onDone, _context, args) {
422658
423095
  if (args = args?.trim() || "", COMMON_HELP_ARGS2.includes(args)) {
422659
423096
  onDone(HELP_TEXT);
422660
423097
  return;
@@ -422735,12 +423172,12 @@ var effort_default, init_effort4 = __esm({
422735
423172
  // build-src/src/commands/stats/stats.tsx
422736
423173
  var stats_exports = {};
422737
423174
  __export(stats_exports, {
422738
- call: () => call74
423175
+ call: () => call75
422739
423176
  });
422740
- var import_jsx_runtime350, call74, init_stats2 = __esm({
423177
+ var import_jsx_runtime350, call75, init_stats2 = __esm({
422741
423178
  "build-src/src/commands/stats/stats.tsx"() {
422742
423179
  init_Stats();
422743
- import_jsx_runtime350 = __toESM(require_jsx_runtime(), 1), call74 = async (onDone) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(Stats2, { onClose: onDone });
423180
+ import_jsx_runtime350 = __toESM(require_jsx_runtime(), 1), call75 = async (onDone) => /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(Stats2, { onClose: onDone });
422744
423181
  }
422745
423182
  });
422746
423183
 
@@ -422977,7 +423414,7 @@ var import_react195, import_jsx_runtime351, init_RemoteCallout = __esm({
422977
423414
  // build-src/src/commands/remote-control/bridge.tsx
422978
423415
  var bridge_exports = {};
422979
423416
  __export(bridge_exports, {
422980
- call: () => call75
423417
+ call: () => call76
422981
423418
  });
422982
423419
  function BridgeToggle(t0) {
422983
423420
  let $3 = (0, import_compiler_runtime235.c)(10), {
@@ -423174,7 +423611,7 @@ async function checkBridgePrerequisites() {
423174
423611
  let versionError = isEnvLessBridgeEnabled() ? await checkEnvLessBridgeMinVersion() : checkBridgeMinVersion();
423175
423612
  return versionError || (getBridgeAccessToken() ? (logForDebugging("[bridge] Prerequisites passed, enabling bridge"), null) : BRIDGE_LOGIN_INSTRUCTION);
423176
423613
  }
423177
- async function call75(onDone, _context, args) {
423614
+ async function call76(onDone, _context, args) {
423178
423615
  let name = args.trim() || void 0;
423179
423616
  return /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(BridgeToggle, { onDone, name });
423180
423617
  }
@@ -423373,7 +423810,7 @@ var CCR_BYOC_BETA_HEADER, RedactedGithubToken, init_api4 = __esm({
423373
423810
  // build-src/src/commands/web-setup/remote-setup.tsx
423374
423811
  var remote_setup_exports = {};
423375
423812
  __export(remote_setup_exports, {
423376
- call: () => call76
423813
+ call: () => call77
423377
423814
  });
423378
423815
  async function checkLoginState() {
423379
423816
  if (!await isSignedIn())
@@ -423478,7 +423915,7 @@ function Web({
423478
423915
  }, onCancel: handleCancel })
423479
423916
  ] });
423480
423917
  }
423481
- async function call76(onDone) {
423918
+ async function call77(onDone) {
423482
423919
  return /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(Web, { onDone });
423483
423920
  }
423484
423921
  var import_react197, import_jsx_runtime353, init_remote_setup = __esm({
@@ -425617,6 +426054,7 @@ var agentsPlatform, proactive, briefCommand, assistantCommand, bridge2, remoteCo
425617
426054
  init_vim2();
425618
426055
  init_websearch2();
425619
426056
  init_collab2();
426057
+ init_discuss();
425620
426058
  init_team();
425621
426059
  init_think_back();
425622
426060
  init_thinkback_play2();
@@ -425777,6 +426215,7 @@ var agentsPlatform, proactive, briefCommand, assistantCommand, bridge2, remoteCo
425777
426215
  stickers_default,
425778
426216
  tag_default,
425779
426217
  collab_default,
426218
+ discuss_default,
425780
426219
  team_default,
425781
426220
  theme_default,
425782
426221
  websearch_default,
@@ -428852,7 +429291,7 @@ __export(filesystem_exports, {
428852
429291
  toPosixPath: () => toPosixPath
428853
429292
  });
428854
429293
  import { randomBytes as randomBytes21 } from "crypto";
428855
- import { homedir as homedir43, tmpdir as tmpdir14 } from "os";
429294
+ import { homedir as homedir44, tmpdir as tmpdir14 } from "os";
428856
429295
  import { join as join168, normalize as normalize17, posix as posix8, sep as sep37 } from "path";
428857
429296
  function normalizeCaseForComparison2(path28) {
428858
429297
  return path28.toLowerCase();
@@ -428864,7 +429303,7 @@ function getClaudeSkillScope(filePath) {
428864
429303
  prefix: "/.sema/skills/"
428865
429304
  },
428866
429305
  {
428867
- dir: expandPath(join168(homedir43(), ".sema", "skills")),
429306
+ dir: expandPath(join168(homedir44(), ".sema", "skills")),
428868
429307
  prefix: "~/.sema/skills/"
428869
429308
  }
428870
429309
  ];
@@ -429103,7 +429542,7 @@ function patternWithRoot(pattern, source) {
429103
429542
  if (pattern.startsWith(`~${DIR_SEP}`))
429104
429543
  return {
429105
429544
  relativePattern: pattern.slice(1),
429106
- root: homedir43().normalize("NFC")
429545
+ root: homedir44().normalize("NFC")
429107
429546
  };
429108
429547
  if (pattern.startsWith(DIR_SEP))
429109
429548
  return {
@@ -433646,6 +434085,7 @@ function noteModelEvidenceFrom(msg) {
433646
434085
  b3.text.includes(model) && noteModelRejected(model, "rejected by the provider");
433647
434086
  continue;
433648
434087
  }
434088
+ if (isGovernanceStopRowText(b3.text)) continue;
433649
434089
  b3.text.length > 0 && noteModelServed(model);
433650
434090
  continue;
433651
434091
  }
@@ -450301,7 +450741,7 @@ var WORKTREE_PARENT, init_git_worktree_env = __esm({
450301
450741
  });
450302
450742
 
450303
450743
  // node_modules/@sema-agent/core/dist/core/memory-engine/layout.js
450304
- import { closeSync as closeSync13, constants as fsConstants8, copyFileSync as copyFileSync6, existsSync as existsSync27, fstatSync as fstatSync3, fsyncSync as fsyncSync10, lstatSync as lstatSync4, mkdirSync as mkdirSync22, openSync as openSync14, readFileSync as readFileSync37, readdirSync as readdirSync11, realpathSync as realpathSync10, renameSync as renameSync13, rmSync as rmSync7, rmdirSync as rmdirSync3, statSync as statSync14, unlinkSync as unlinkSync11, writeFileSync as writeFileSync21, writeSync as writeSync7 } from "node:fs";
450744
+ import { closeSync as closeSync13, constants as fsConstants8, copyFileSync as copyFileSync6, existsSync as existsSync27, fstatSync as fstatSync3, fsyncSync as fsyncSync10, lstatSync as lstatSync4, mkdirSync as mkdirSync22, openSync as openSync14, readFileSync as readFileSync37, readdirSync as readdirSync12, realpathSync as realpathSync10, renameSync as renameSync13, rmSync as rmSync7, rmdirSync as rmdirSync3, statSync as statSync14, unlinkSync as unlinkSync11, writeFileSync as writeFileSync21, writeSync as writeSync7 } from "node:fs";
450305
450745
  var O_WRONLY, O_CREAT, O_TRUNC, O_NOFOLLOW3, O_EXCL, init_layout = __esm({
450306
450746
  "node_modules/@sema-agent/core/dist/core/memory-engine/layout.js"() {
450307
450747
  ({ O_WRONLY, O_CREAT, O_TRUNC, O_NOFOLLOW: O_NOFOLLOW3, O_EXCL } = fsConstants8);
@@ -455180,8 +455620,8 @@ function policyFromPermissions(perms) {
455180
455620
  return policy2;
455181
455621
  }
455182
455622
  function deriveMode(eff, opts) {
455183
- let launch = opts?.launchMode, fileMode = eff.permissionMode, mode = launch ?? fileMode ?? "default";
455184
- return mode === "bypassPermissions" && eff.disableBypassPermissionsMode === !0 && (mode = "default"), mode === "acceptEdits" && eff.disableAutoMode === !0 && (mode = "default"), mode;
455623
+ let launch = opts?.launchMode, fileMode = eff.permissionMode, factory2 = launch === void 0 && fileMode === void 0 && opts?.factoryDefaultAuto === !0, mode = launch ?? fileMode ?? (factory2 ? "auto" : "default");
455624
+ return mode === "bypassPermissions" && eff.disableBypassPermissionsMode === !0 && (mode = "default"), (mode === "acceptEdits" || mode === "auto") && eff.disableAutoMode === !0 && (mode = "default"), { mode, isFactoryDefault: factory2 && mode === "auto" };
455185
455625
  }
455186
455626
  function modeToolPolicy(mode, basePolicy) {
455187
455627
  switch (mode) {
@@ -455208,7 +455648,7 @@ function modeToolPolicy(mode, basePolicy) {
455208
455648
  }
455209
455649
  }
455210
455650
  function toEffectiveConfig(eff, opts) {
455211
- let basePolicy = policyFromPermissions(eff.permissions), derivedMode = deriveMode(eff, opts), { toolPolicy, handsReadOnly, onAsk } = modeToolPolicy(
455651
+ let basePolicy = policyFromPermissions(eff.permissions), { mode: derivedMode, isFactoryDefault } = deriveMode(eff, opts), { toolPolicy, handsReadOnly, onAsk } = modeToolPolicy(
455212
455652
  derivedMode,
455213
455653
  basePolicy
455214
455654
  ), taskSpecOverrides = { toolPolicy };
@@ -455220,6 +455660,7 @@ function toEffectiveConfig(eff, opts) {
455220
455660
  model: eff.model,
455221
455661
  outputStyle: eff.outputStyle,
455222
455662
  derivedMode,
455663
+ ...isFactoryDefault ? { derivedModeIsFactoryDefault: !0 } : {},
455223
455664
  provenance: eff.provenance
455224
455665
  };
455225
455666
  }
@@ -458819,8 +459260,11 @@ var init_caCertsConfig = __esm({
458819
459260
  // build-src/src/utils/managedEnv.ts
458820
459261
  var managedEnv_exports = {};
458821
459262
  __export(managedEnv_exports, {
459263
+ PROJECT_FORBIDDEN_ENV_VARS: () => PROJECT_FORBIDDEN_ENV_VARS,
458822
459264
  applyConfigEnvironmentVariables: () => applyConfigEnvironmentVariables,
458823
- applySafeConfigEnvironmentVariables: () => applySafeConfigEnvironmentVariables
459265
+ applySafeConfigEnvironmentVariables: () => applySafeConfigEnvironmentVariables,
459266
+ stripUntrustedCapabilityEnv: () => stripUntrustedCapabilityEnv,
459267
+ trustedCapabilityEnv: () => trustedCapabilityEnv
458824
459268
  });
458825
459269
  function withoutSSHTunnelVars(env5) {
458826
459270
  if (!env5 || !process.env.ANTHROPIC_UNIX_SOCKET) return env5 || {};
@@ -458866,14 +459310,48 @@ function applySafeConfigEnvironmentVariables() {
458866
459310
  process.env,
458867
459311
  filterSettingsEnv(getSettingsForSource("policySettings")?.env)
458868
459312
  );
458869
- let settingsEnv4 = filterSettingsEnv(getSettings_DEPRECATED()?.env);
459313
+ let settingsEnv4 = stripUntrustedCapabilityEnv(
459314
+ filterSettingsEnv(getSettings_DEPRECATED()?.env),
459315
+ (source) => isSettingSourceEnabled(source) ? filterSettingsEnv(getSettingsForSource(source)?.env) : void 0
459316
+ );
458870
459317
  for (let [key, value] of Object.entries(settingsEnv4))
458871
459318
  SAFE_ENV_VARS3.has(key.toUpperCase()) && (process.env[key] = value);
459319
+ Object.assign(
459320
+ process.env,
459321
+ trustedCapabilityEnv(
459322
+ (source) => isSettingSourceEnabled(source) ? filterSettingsEnv(getSettingsForSource(source)?.env) : void 0
459323
+ )
459324
+ );
459325
+ }
459326
+ function stripUntrustedCapabilityEnv(merged, readSourceEnv) {
459327
+ let out6 = { ...merged };
459328
+ for (let key of Object.keys(out6))
459329
+ PROJECT_FORBIDDEN_ENV_VARS.has(key.toUpperCase()) && delete out6[key];
459330
+ return Object.assign(out6, trustedCapabilityEnv(readSourceEnv));
459331
+ }
459332
+ function trustedCapabilityEnv(readSourceEnv) {
459333
+ let out6 = {};
459334
+ for (let canonical2 of PROJECT_FORBIDDEN_ENV_VARS)
459335
+ for (let source of TRUSTED_SETTING_SOURCES) {
459336
+ let sourceEnv = readSourceEnv(source);
459337
+ if (sourceEnv)
459338
+ for (let [key, value] of Object.entries(sourceEnv))
459339
+ key.toUpperCase() === canonical2 && (out6[canonical2] = value);
459340
+ }
459341
+ return out6;
458872
459342
  }
458873
459343
  function applyConfigEnvironmentVariables() {
458874
- Object.assign(process.env, filterSettingsEnv(getGlobalConfig().env)), Object.assign(process.env, filterSettingsEnv(getSettings_DEPRECATED()?.env)), clearCACertsCache(), clearMTLSCache(), clearProxyCache(), configureGlobalAgents();
459344
+ Object.assign(process.env, filterSettingsEnv(getGlobalConfig().env)), Object.assign(
459345
+ process.env,
459346
+ stripUntrustedCapabilityEnv(
459347
+ filterSettingsEnv(getSettings_DEPRECATED()?.env),
459348
+ // 🔴 取回也要服从 `--setting-sources`:该 flag 排除 userSettings 时,那份文件里的
459349
+ // 能力位不该还能透过(getSettingsForSource 自身不查源开关)。
459350
+ (source) => isSettingSourceEnabled(source) ? filterSettingsEnv(getSettingsForSource(source)?.env) : void 0
459351
+ )
459352
+ ), clearCACertsCache(), clearMTLSCache(), clearProxyCache(), configureGlobalAgents();
458875
459353
  }
458876
- var ccdSpawnEnvKeys, TRUSTED_SETTING_SOURCES, init_managedEnv = __esm({
459354
+ var ccdSpawnEnvKeys, TRUSTED_SETTING_SOURCES, PROJECT_FORBIDDEN_ENV_VARS, init_managedEnv = __esm({
458877
459355
  "build-src/src/utils/managedEnv.ts"() {
458878
459356
  init_syncCache();
458879
459357
  init_caCerts();
@@ -458889,6 +459367,24 @@ var ccdSpawnEnvKeys, TRUSTED_SETTING_SOURCES, init_managedEnv = __esm({
458889
459367
  "flagSettings",
458890
459368
  "policySettings"
458891
459369
  ];
459370
+ PROJECT_FORBIDDEN_ENV_VARS = /* @__PURE__ */ new Set([
459371
+ // agent-teams 的 opt-in:开门 = 挂上 TeamCreate/TeamDelete/SendMessage + 起队友进程的能力面。
459372
+ // 🔴 品牌名 + CC 名两形都要登记(1.0.82 扫码修,真病 S3):裸字面量 'SEMA_CODE_...' 会被
459373
+ // branding codemod 逐字改写成 'SEMA_CODE_...'(dist 直证:产物里恒 0 处 CLAUDE_ 形、6 处
459374
+ // SEMA_ 形),于是构建后的禁表**只剩品牌名一形**。而 `ccEnvCompatBoot.ts` 的 `applyCcEnvCompat()`
459375
+ // 只在进程边界跑一次、只读**真实 shell env**——它不会回头翻译「后来才从 settings.json 合并
459376
+ // 进 process.env」的值。项目 `.sema/settings.json` 写 `{"env":{"SEMA_CODE_EXPERIMENTAL_
459377
+ // AGENT_TEAMS":"1"}}` 时,合并层按品牌名做的剥离扫不到这个 CC 原名键,它原样滲进
459378
+ // `process.env`——本进程的门读不到(读的是品牌名),但**继承该 env 的子 sema 进程**
459379
+ // (main.tsx spawnSync/worktree.ts/Bash 工具再跑 sema)在自己 boot 期重新跑 compat,会把这个
459380
+ // 继承来的 CC 原名值回翻成品牌名,子进程的门就开了。
459381
+ // 拼接规避同一条 codemod(仓内 envUtils.ts/ccImportMarker.ts 同款纪律):裸写会被连带改掉,
459382
+ // 拼接后的字符串在源码文本层面不含 `\bCLAUDE_\b`,codemod 认不出,构建后仍保持 CC 原形——
459383
+ // 于是禁表在**构建产物**里真同时含两个不同字符串(品牌名+CC 原名);raw src 下两条字面量相同,
459384
+ // Set 天然去重成一条,对 raw src 测试无害(此时两形本就同形)。
459385
+ "SEMA_CODE_EXPERIMENTAL_AGENT_TEAMS",
459386
+ "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS".toUpperCase()
459387
+ ]);
458892
459388
  }
458893
459389
  });
458894
459390
 
@@ -459113,7 +459609,7 @@ __export(upstreamproxy_exports, {
459113
459609
  resetUpstreamProxyForTests: () => resetUpstreamProxyForTests
459114
459610
  });
459115
459611
  import { mkdir as mkdir45, readFile as readFile53, unlink as unlink26, writeFile as writeFile46 } from "fs/promises";
459116
- import { homedir as homedir44 } from "os";
459612
+ import { homedir as homedir45 } from "os";
459117
459613
  import { join as join177 } from "path";
459118
459614
  async function initUpstreamProxy(opts) {
459119
459615
  if (!isEnvTruthy(process.env.SEMA_CODE_REMOTE) || !isEnvTruthy(process.env.CCR_UPSTREAM_PROXY_ENABLED))
@@ -459128,7 +459624,7 @@ async function initUpstreamProxy(opts) {
459128
459624
  if (!token)
459129
459625
  return logForDebugging("[upstreamproxy] no session token file; proxy disabled"), state3;
459130
459626
  setNonDumpable();
459131
- let baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com", caBundlePath = opts?.caBundlePath ?? join177(homedir44(), ".ccr", "ca-bundle.crt");
459627
+ let baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com", caBundlePath = opts?.caBundlePath ?? join177(homedir45(), ".ccr", "ca-bundle.crt");
459132
459628
  if (!await downloadCaBundle(
459133
459629
  baseUrl,
459134
459630
  opts?.systemCaPath ?? SYSTEM_CA_BUNDLE,
@@ -462607,6 +463103,88 @@ var import_compiler_runtime243, import_jsx_runtime365, init_WorkerPendingPermiss
462607
463103
  }
462608
463104
  });
462609
463105
 
463106
+ // build-src/src/sema/rules/ccImportBootRun.ts
463107
+ var ccImportBootRun_exports = {};
463108
+ __export(ccImportBootRun_exports, {
463109
+ __resetCcImportBootLatchForTests: () => __resetCcImportBootLatchForTests,
463110
+ __resetCcImportBootPendingNoticeForTests: () => __resetCcImportBootPendingNoticeForTests,
463111
+ __setCcImportCapsWaitCapForTests: () => __setCcImportCapsWaitCapForTests,
463112
+ drainPendingCcImportBootNotice: () => drainPendingCcImportBootNotice,
463113
+ runCcImportBootAuto: () => runCcImportBootAuto,
463114
+ runCcImportBootAutoWith: () => runCcImportBootAutoWith
463115
+ });
463116
+ async function runCcImportBootAutoWith(deps2) {
463117
+ try {
463118
+ let sourcePath = deps2.gate();
463119
+ if (sourcePath === null) return "gate-closed";
463120
+ let { layers: layers2 } = deps2.collect(sourcePath);
463121
+ if (layers2.length === 0) return "no-layers";
463122
+ let facade = await deps2.facade(), prep = await prepareCcRuleImport(facade, layers2);
463123
+ if (!prep.ok) return "prepare-failed";
463124
+ if ((Array.isArray(prep.prepared?.preview?.candidates) ? prep.prepared.preview.candidates : []).length === 0)
463125
+ return deps2.writeMarker({ importedAt: (/* @__PURE__ */ new Date()).toISOString(), sourcePath, importedCount: 0 }), "nothing-to-import";
463126
+ let red = await redeemCcRuleImport(facade, prep.prepared.ticket);
463127
+ if (!red.ok) return "redeem-failed";
463128
+ let persisted = Array.isArray(red.redeemed?.result?.persisted) ? red.redeemed.result.persisted.length : 0, deduped = Array.isArray(red.redeemed?.result?.deduped) ? red.redeemed.result.deduped.length : 0;
463129
+ if (deps2.writeMarker({ importedAt: (/* @__PURE__ */ new Date()).toISOString(), sourcePath, importedCount: persisted }), persisted > 0) {
463130
+ let noun = persisted === 1 ? "rule" : "rules", dedupTail = deduped > 0 ? ` (${deduped} already present)` : "", text2 = `Imported ${persisted} permission ${noun} from Sema settings${dedupTail} \u2014 review in /permissions`;
463131
+ deps2.notice(text2) || (pendingNotice = text2);
463132
+ }
463133
+ return "imported";
463134
+ } catch {
463135
+ return "prepare-failed";
463136
+ }
463137
+ }
463138
+ function __resetCcImportBootLatchForTests() {
463139
+ attempted = !1;
463140
+ }
463141
+ function drainPendingCcImportBootNotice() {
463142
+ let n2 = pendingNotice;
463143
+ return pendingNotice = null, n2;
463144
+ }
463145
+ function __resetCcImportBootPendingNoticeForTests() {
463146
+ pendingNotice = null;
463147
+ }
463148
+ function __setCcImportCapsWaitCapForTests(ms) {
463149
+ capsWaitCapMs = ms ?? CAPS_SETTLE_CAP_MS;
463150
+ }
463151
+ async function awaitEngineCapsSettled(base) {
463152
+ let timer2;
463153
+ try {
463154
+ return await Promise.race([
463155
+ engineCapsSettled(base).then(() => "settled"),
463156
+ new Promise((r) => {
463157
+ timer2 = setTimeout(() => r("timeout"), capsWaitCapMs);
463158
+ })
463159
+ ]);
463160
+ } finally {
463161
+ timer2 !== void 0 && clearTimeout(timer2);
463162
+ }
463163
+ }
463164
+ async function runCcImportBootAuto() {
463165
+ if (attempted) return "already-attempted";
463166
+ attempted = !0;
463167
+ let base = process.env.SEMA_LIVE_BASEURL;
463168
+ return typeof base == "string" && base.trim() !== "" && await awaitEngineCapsSettled(base) === "timeout" || process.env.SEMA_LIVE_BASEURL !== base ? (attempted = !1, "caps-unsettled") : runCcImportBootAutoWith({
463169
+ gate: () => ccImportBootGate(typeof base == "string" && base.trim() !== "" ? base : void 0),
463170
+ collect: collectCcUserLayerAt,
463171
+ facade: resolveRulesFacade,
463172
+ writeMarker: writeCcImportMarker,
463173
+ notice: surfaceTranscriptSystemNotice
463174
+ });
463175
+ }
463176
+ var attempted, pendingNotice, CAPS_SETTLE_CAP_MS, capsWaitCapMs, init_ccImportBootRun = __esm({
463177
+ "build-src/src/sema/rules/ccImportBootRun.ts"() {
463178
+ init_dist();
463179
+ init_persistedRulesWire2();
463180
+ init_transcriptSystemNotice();
463181
+ init_ccImportMarker();
463182
+ attempted = !1;
463183
+ pendingNotice = null;
463184
+ CAPS_SETTLE_CAP_MS = 15e3, capsWaitCapMs = CAPS_SETTLE_CAP_MS;
463185
+ }
463186
+ });
463187
+
462610
463188
  // build-src/src/hooks/useLogMessages.ts
462611
463189
  function useLogMessages(messages, ignore6 = !1) {
462612
463190
  let teamContext = useAppState((s) => s.teamContext), lastRecordedLengthRef = (0, import_react205.useRef)(0), lastParentUuidRef = (0, import_react205.useRef)(void 0), firstMessageUuidRef = (0, import_react205.useRef)(void 0), callSeqRef = (0, import_react205.useRef)(0);
@@ -472593,7 +473171,7 @@ var import_compiler_runtime255, import_jsx_runtime383, init_ShowInIDEPrompt = __
472593
473171
  });
472594
473172
 
472595
473173
  // build-src/src/components/permissions/FilePermissionDialog/permissionOptions.tsx
472596
- import { homedir as homedir45 } from "os";
473174
+ import { homedir as homedir46 } from "os";
472597
473175
  import { basename as basename56, join as join181, sep as sep39 } from "path";
472598
473176
  function isInClaudeFolder(filePath) {
472599
473177
  let absolutePath = expandPath(filePath), claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`), normalizedAbsolutePath = normalizeCaseForComparison2(absolutePath), normalizedClaudeFolderPath = normalizeCaseForComparison2(claudeFolderPath);
@@ -472601,7 +473179,7 @@ function isInClaudeFolder(filePath) {
472601
473179
  normalizedAbsolutePath.startsWith(normalizedClaudeFolderPath + "/");
472602
473180
  }
472603
473181
  function isInGlobalClaudeFolder(filePath) {
472604
- let absolutePath = expandPath(filePath), globalClaudeFolderPath = join181(homedir45(), ".sema"), normalizedAbsolutePath = normalizeCaseForComparison2(absolutePath), normalizedGlobalClaudeFolderPath = normalizeCaseForComparison2(globalClaudeFolderPath);
473182
+ let absolutePath = expandPath(filePath), globalClaudeFolderPath = join181(homedir46(), ".sema"), normalizedAbsolutePath = normalizeCaseForComparison2(absolutePath), normalizedGlobalClaudeFolderPath = normalizeCaseForComparison2(globalClaudeFolderPath);
472605
473183
  return normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + sep39.toLowerCase()) || normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + "/");
472606
473184
  }
472607
473185
  function getFilePermissionOptions({
@@ -481801,41 +482379,6 @@ var import_compiler_runtime284, import_react256, import_jsx_runtime427, init_Thi
481801
482379
  }
481802
482380
  });
481803
482381
 
481804
- // build-src/src/utils/teamDiscovery.ts
481805
- function getTeammateStatuses(teamName) {
481806
- let teamFile = readTeamFile(teamName);
481807
- if (!teamFile)
481808
- return [];
481809
- let hiddenPaneIds = new Set(teamFile.hiddenPaneIds ?? []), statuses = [];
481810
- for (let member of teamFile.members) {
481811
- if (member.name === "team-lead")
481812
- continue;
481813
- let status3 = member.isActive !== !1 ? "running" : "idle";
481814
- statuses.push({
481815
- name: member.name,
481816
- agentId: member.agentId,
481817
- agentType: member.agentType,
481818
- model: member.model,
481819
- prompt: member.prompt,
481820
- status: status3,
481821
- color: member.color,
481822
- tmuxPaneId: member.tmuxPaneId,
481823
- cwd: member.cwd,
481824
- worktreePath: member.worktreePath,
481825
- isHidden: hiddenPaneIds.has(member.tmuxPaneId),
481826
- backendType: member.backendType && isPaneBackend(member.backendType) ? member.backendType : void 0,
481827
- mode: member.mode
481828
- });
481829
- }
481830
- return statuses;
481831
- }
481832
- var init_teamDiscovery = __esm({
481833
- "build-src/src/utils/teamDiscovery.ts"() {
481834
- init_types18();
481835
- init_teamHelpers();
481836
- }
481837
- });
481838
-
481839
482382
  // build-src/src/components/teams/TeamsDialog.tsx
481840
482383
  import { randomUUID as randomUUID43 } from "crypto";
481841
482384
  function TeamsDialog({
@@ -488558,7 +489101,7 @@ var SESSION_SCAN_INTERVAL_MS, DEFAULTS, runner, init_autoDream = __esm({
488558
489101
 
488559
489102
  // build-src/src/utils/cleanup.ts
488560
489103
  import * as fs14 from "fs/promises";
488561
- import { homedir as homedir46 } from "os";
489104
+ import { homedir as homedir47 } from "os";
488562
489105
  import { join as join183 } from "path";
488563
489106
  function getCleanupPeriodDays() {
488564
489107
  return (getSettings_DEPRECATED() || {}).cleanupPeriodDays ?? DEFAULT_CLEANUP_PERIOD_DAYS;
@@ -488873,7 +489416,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
488873
489416
  return;
488874
489417
  }
488875
489418
  logForDebugging("npm cache cleanup: starting");
488876
- let npmCachePath = join183(homedir46(), ".npm", "_cacache"), NPM_CACHE_RETENTION_COUNT = 5, startTime = Date.now();
489419
+ let npmCachePath = join183(homedir47(), ".npm", "_cacache"), NPM_CACHE_RETENTION_COUNT = 5, startTime = Date.now();
488877
489420
  try {
488878
489421
  let cacache = await import("cacache"), cutoff = startTime - ONE_DAY_MS2, stream5 = cacache.ls.stream(npmCachePath), anthropicEntries = [];
488879
489422
  for await (let entry of stream5)
@@ -491114,6 +491657,7 @@ async function executeUserInput(params) {
491114
491657
  queuedCommands
491115
491658
  } = params, abortController = createAbortController();
491116
491659
  setAbortController(abortController);
491660
+ let submissionTurnId = beginSubmissionTurn();
491117
491661
  function makeContext() {
491118
491662
  return getToolUseContext(messages, [], abortController, mainLoopModel);
491119
491663
  }
@@ -491194,6 +491738,14 @@ async function executeUserInput(params) {
491194
491738
  nextInput && (submitNextInput ? enqueue({ value: nextInput, mode: "prompt" }) : params.onInputChange(nextInput));
491195
491739
  });
491196
491740
  } finally {
491741
+ if (consumeSubmissionHeldForDecision(submissionTurnId)) {
491742
+ let injected = (params.queuedCommands ?? []).filter((c2) => c2.isMeta === !0);
491743
+ for (let cmd of injected) {
491744
+ if (requeueFailedInjection(cmd)) continue;
491745
+ let text2 = `A system notification was dropped after ${MAX_INJECTION_REQUEUES} attempts \u2014 this session kept an unanswered decision open, so it never reached the model.`;
491746
+ surfaceTranscriptSystemNotice(text2) || logError(new Error(`[sema] ${text2}`));
491747
+ }
491748
+ }
491197
491749
  queryGuard.cancelReservation(), setUserInputOnProcessing(void 0);
491198
491750
  }
491199
491751
  }
@@ -491209,7 +491761,9 @@ var init_handlePromptSubmit = __esm({
491209
491761
  init_log2();
491210
491762
  init_fileHistory();
491211
491763
  init_gracefulShutdown();
491764
+ init_injectionRequeueLatch();
491212
491765
  init_messageQueueManager();
491766
+ init_transcriptSystemNotice();
491213
491767
  init_model();
491214
491768
  init_processUserInput();
491215
491769
  init_queryProfiler();
@@ -491227,17 +491781,24 @@ function isSlashCommand(cmd) {
491227
491781
  return !1;
491228
491782
  }
491229
491783
  function processQueueIfReady({
491230
- executeInput
491784
+ executeInput,
491785
+ pendingDecisionCard = !1
491231
491786
  }) {
491232
- let isMainThread = (cmd) => cmd.agentId === void 0, next = peek(isMainThread);
491787
+ let isMainThread = (cmd) => cmd.agentId === void 0, deferred = /* @__PURE__ */ new Set();
491788
+ if (pendingDecisionCard) {
491789
+ for (let cmd of getCommandQueue())
491790
+ isMainThread(cmd) && cmd.isMeta === !0 && (cmd.deferCount ?? 0) < MAX_INJECTION_DEFERRALS && deferred.add(cmd);
491791
+ for (let cmd of deferred) noteInjectionDeferred(cmd);
491792
+ }
491793
+ let drainable = deferred.size > 0 ? (cmd) => isMainThread(cmd) && !deferred.has(cmd) : isMainThread, next = peek(drainable);
491233
491794
  if (!next)
491234
491795
  return { processed: !1 };
491235
491796
  if (isSlashCommand(next) || next.mode === "bash") {
491236
- let cmd = dequeue(isMainThread);
491797
+ let cmd = dequeue(drainable);
491237
491798
  return executeInput([cmd]), { processed: !0 };
491238
491799
  }
491239
- let targetMode = next.mode, commands = dequeueAllMatching(
491240
- (cmd) => isMainThread(cmd) && !isSlashCommand(cmd) && cmd.mode === targetMode
491800
+ let targetMode = next.mode, targetInjected = next.isMeta === !0, commands = dequeueAllMatching(
491801
+ (cmd) => drainable(cmd) && !isSlashCommand(cmd) && cmd.mode === targetMode && cmd.isMeta === !0 === targetInjected
491241
491802
  );
491242
491803
  return commands.length === 0 ? { processed: !1 } : (executeInput(commands), { processed: !0 });
491243
491804
  }
@@ -491259,23 +491820,37 @@ function useQueueProcessor({
491259
491820
  ), queueSnapshot = (0, import_react287.useSyncExternalStore)(
491260
491821
  subscribeToCommandQueue,
491261
491822
  getCommandQueueSnapshot
491823
+ ), pendingDecisionCards = (0, import_react287.useSyncExternalStore)(
491824
+ subscribeToLeaderPendingDecisionCards,
491825
+ leaderPendingDecisionCardCount
491262
491826
  );
491263
491827
  (0, import_react287.useEffect)(() => {
491264
491828
  process.env.SEMA_DEBUG && queueSnapshot.length > 0 && logForDebugging(
491265
- `[queue-drain] len=${queueSnapshot.length} queryActive=${isQueryActive} jsxUI=${hasActiveLocalJsxUI} modes=${queueSnapshot.map((c2) => c2.mode).join(",")}`
491266
- ), !isQueryActive && (hasActiveLocalJsxUI || queueSnapshot.length !== 0 && processQueueIfReady({ executeInput: executeQueuedInput }));
491829
+ `[queue-drain] len=${queueSnapshot.length} queryActive=${isQueryActive} jsxUI=${hasActiveLocalJsxUI} cards=${pendingDecisionCards} modes=${queueSnapshot.map((c2) => c2.mode).join(",")}`
491830
+ ), !isQueryActive && (hasActiveLocalJsxUI || queueSnapshot.length !== 0 && processQueueIfReady({
491831
+ executeInput: executeQueuedInput,
491832
+ // #289 批面①:有**引擎的**卡挂着 ⇒ 注入件这一拍先不出队(人类提交照走)。
491833
+ // 🔴 减掉壳自己合成的 running 三选卡 —— 与自愈腿 `hasPendingDecision` 同一个判据
491834
+ // (seamQuery 装配处逐字同形)。它们进同一条 REPL 卡队列,但答那张卡**不释放会话**,
491835
+ // 拿总长度当判据 = 用一个答不出问题的量去闸主队列(复审轮 R1 半场)。
491836
+ // 推迟有预算(MAX_INJECTION_DEFERRALS),陈旧镜像下不会永久饿死 —— 见 processQueueIfReady。
491837
+ pendingDecisionCard: pendingDecisionCards > openRunningChoiceCardCount()
491838
+ }));
491267
491839
  }, [
491268
491840
  queueSnapshot,
491269
491841
  isQueryActive,
491270
491842
  executeQueuedInput,
491271
491843
  hasActiveLocalJsxUI,
491272
- queryGuard
491844
+ queryGuard,
491845
+ pendingDecisionCards
491273
491846
  ]);
491274
491847
  }
491275
491848
  var import_react287, init_useQueueProcessor = __esm({
491276
491849
  "build-src/src/hooks/useQueueProcessor.ts"() {
491277
491850
  import_react287 = __toESM(require_react(), 1);
491278
491851
  init_messageQueueManager();
491852
+ init_leaderPermissionBridge();
491853
+ init_activeRunRunningChoice();
491279
491854
  init_debug();
491280
491855
  init_queueProcessor();
491281
491856
  }
@@ -493135,6 +493710,52 @@ var import_react295, INBOX_POLL_INTERVAL_MS, init_useInboxPoller = __esm({
493135
493710
  }
493136
493711
  });
493137
493712
 
493713
+ // build-src/src/sema/planReviewModeExit.ts
493714
+ function isPlanReviewQuestionId(questionId) {
493715
+ return typeof questionId == "string" && questionId.startsWith(PLAN_REVIEW_QUESTION_ID_PREFIX);
493716
+ }
493717
+ function shouldExitPlanModeForAnswer(questionId, answer) {
493718
+ return isPlanReviewQuestionId(questionId) ? planReviewDecisionFromAnswer(answer) === "approve" : !1;
493719
+ }
493720
+ function reevaluateRestoreMode(ctx) {
493721
+ let wanted = ctx.prePlanMode ?? "default";
493722
+ if (wanted !== "auto" && wanted !== "bypassPermissions") return wanted;
493723
+ try {
493724
+ return wanted === "auto" ? isAutoModeGateEnabled() ? "auto" : "default" : ctx.isBypassPermissionsModeAvailable === !1 || isBypassPermissionsModeDisabled() ? "default" : "bypassPermissions";
493725
+ } catch (e) {
493726
+ return process.env.SEMA_DEBUG && console.error(
493727
+ `[sema][planReviewModeExit] ${wanted} availability probe threw \u2014 falling back to default (fail-closed): ${String(e)}`
493728
+ ), "default";
493729
+ }
493730
+ }
493731
+ function applyPlanModeExit(prev) {
493732
+ let ctx = prev.toolPermissionContext;
493733
+ if (ctx.mode !== "plan") return prev;
493734
+ let restoreMode = reevaluateRestoreMode(ctx), nextCtx;
493735
+ try {
493736
+ nextCtx = transitionPermissionMode("plan", restoreMode, ctx);
493737
+ } catch (e) {
493738
+ return process.env.SEMA_DEBUG && console.error(`[sema][planReviewModeExit] transition to ${restoreMode} threw: ${String(e)}`), { ...prev, toolPermissionContext: { ...ctx, mode: "default", prePlanMode: void 0 } };
493739
+ }
493740
+ return {
493741
+ ...prev,
493742
+ toolPermissionContext: { ...nextCtx, mode: restoreMode }
493743
+ };
493744
+ }
493745
+ function exitPlanModeIfApproved(questionId, answer, setAppState) {
493746
+ try {
493747
+ return shouldExitPlanModeForAnswer(questionId, answer) ? (setAppState(applyPlanModeExit), !0) : !1;
493748
+ } catch (e) {
493749
+ return process.env.SEMA_DEBUG && console.error(`[sema][planReviewModeExit] exit failed for ${String(questionId)}: ${String(e)}`), !1;
493750
+ }
493751
+ }
493752
+ var init_planReviewModeExit = __esm({
493753
+ "build-src/src/sema/planReviewModeExit.ts"() {
493754
+ init_dist();
493755
+ init_permissionSetup();
493756
+ }
493757
+ });
493758
+
493138
493759
  // build-src/src/sema/resumePendingReconcile.ts
493139
493760
  var resumePendingReconcile_exports = {};
493140
493761
  __export(resumePendingReconcile_exports, {
@@ -493434,10 +494055,10 @@ async function runQuestionPermissionRequestHooks(frame, getHookToolUseContext) {
493434
494055
  }
493435
494056
  return null;
493436
494057
  }
493437
- function buildQuestionToolUseConfirm(frame, getHookToolUseContext) {
494058
+ function buildQuestionToolUseConfirm(frame, getHookToolUseContext, setAppState) {
493438
494059
  let questionId = frame.questionId, questions = frame.questions ?? [], answerAndRelease = (answer) => {
493439
494060
  respondToQuestion(questionId, answer).then(() => {
493440
- notePlanReviewAnsweredIfDecisive(questionId, answer);
494061
+ notePlanReviewAnsweredIfDecisive(questionId, answer), setAppState && exitPlanModeIfApproved(questionId, answer, setAppState);
493441
494062
  }).catch(() => {
493442
494063
  });
493443
494064
  };
@@ -493472,21 +494093,22 @@ function buildQuestionToolUseConfirm(frame, getHookToolUseContext) {
493472
494093
  }
493473
494094
  function useLiveQuestionOverlay({
493474
494095
  setToolUseConfirmQueue,
493475
- getHookToolUseContext
494096
+ getHookToolUseContext,
494097
+ setAppState
493476
494098
  }) {
493477
494099
  (0, import_react296.useEffect)(() => {
493478
494100
  let completedBeforeDialog = /* @__PURE__ */ new Set(), seenQuestionIds = /* @__PURE__ */ new Set(), alive = !0, unsubscribe = onQuestionFrame((frame) => {
493479
494101
  if (frame.type === "question") {
493480
494102
  if (!frame.questions || frame.questions.length === 0 || seenQuestionIds.has(frame.questionId)) return;
493481
494103
  seenQuestionIds.add(frame.questionId);
493482
- let entry = buildQuestionToolUseConfirm(frame, getHookToolUseContext);
494104
+ let entry = buildQuestionToolUseConfirm(frame, getHookToolUseContext, setAppState);
493483
494105
  (async () => {
493484
494106
  let decision = await runQuestionPermissionRequestHooks(frame, getHookToolUseContext);
493485
494107
  if (!completedBeforeDialog.has(frame.questionId)) {
493486
494108
  if (decision?.behavior === "allow") {
493487
494109
  let updated = decision.updatedInput, wireAnswer = questionAnswersToWire(frame.questions ?? [], updated?.answers, updated?.annotations);
493488
494110
  respondToQuestion(frame.questionId, wireAnswer).then(() => {
493489
- notePlanReviewAnsweredIfDecisive(frame.questionId, wireAnswer);
494111
+ notePlanReviewAnsweredIfDecisive(frame.questionId, wireAnswer), setAppState && exitPlanModeIfApproved(frame.questionId, wireAnswer, setAppState);
493490
494112
  }).catch(() => {
493491
494113
  });
493492
494114
  return;
@@ -493520,6 +494142,7 @@ var import_react296, init_useLiveQuestionOverlay = __esm({
493520
494142
  init_messages4();
493521
494143
  init_dist();
493522
494144
  init_armedGateRegistry2();
494145
+ init_planReviewModeExit();
493523
494146
  init_resumePendingReconcile();
493524
494147
  }
493525
494148
  });
@@ -499598,9 +500221,12 @@ function REPL({
499598
500221
  }
499599
500222
  rawSetMessages(next);
499600
500223
  }, []);
499601
- (0, import_react332.useEffect)(() => registerTranscriptSystemNoticeSink((text2) => {
499602
- setMessages((prev) => [...prev, createSystemMessage(text2, "warning")]);
499603
- }), [setMessages]);
500224
+ (0, import_react332.useEffect)(() => {
500225
+ let unregister = registerTranscriptSystemNoticeSink((text2) => {
500226
+ setMessages((prev) => [...prev, createSystemMessage(text2, "warning")]);
500227
+ }), pending2 = drainPendingCcImportBootNotice();
500228
+ return pending2 !== null && setMessages((prev) => [...prev, createSystemMessage(pending2, "info")]), unregister;
500229
+ }, [setMessages]);
499604
500230
  let setUserInputOnProcessing = (0, import_react332.useCallback)((input) => {
499605
500231
  input !== void 0 ? (userInputBaselineRef.current = messagesRef.current.length, userMessagePendingRef.current = !0) : userMessagePendingRef.current = !1, setUserInputOnProcessingRaw(input);
499606
500232
  }, []), {
@@ -500998,7 +501624,9 @@ ${fileList}`);
500998
501624
  let getHookToolUseContext = (0, import_react332.useCallback)(() => getToolUseContext(messagesRef.current, [], new AbortController(), mainLoopModel), [getToolUseContext, mainLoopModel]);
500999
501625
  useLiveQuestionOverlay({
501000
501626
  setToolUseConfirmQueue,
501001
- getHookToolUseContext
501627
+ getHookToolUseContext,
501628
+ // #266:plan 卡 approve 后退出壳本地 plan 模式(rc.47 挂账的 app-state seam 只有这一层有)。
501629
+ setAppState
501002
501630
  }), useMailboxBridge({
501003
501631
  isLoading,
501004
501632
  onSubmitMessage: handleIncomingPrompt
@@ -501531,6 +502159,7 @@ var import_compiler_runtime325, React175, import_react332, import_jsx_runtime478
501531
502159
  init_LocalAgentTask();
501532
502160
  init_leaderPermissionBridge();
501533
502161
  init_transcriptSystemNotice();
502162
+ init_ccImportBootRun();
501534
502163
  init_sessionTracing();
501535
502164
  init_useLogMessages();
501536
502165
  init_useReplBridge();
@@ -509658,7 +510287,7 @@ var lastMemoryMessageUuid, initSessionMemoryConfigIfNeeded, hasLoggedGateFailure
509658
510287
 
509659
510288
  // build-src/src/utils/iTermBackup.ts
509660
510289
  import { copyFile as copyFile11, stat as stat50 } from "fs/promises";
509661
- import { homedir as homedir47 } from "os";
510290
+ import { homedir as homedir48 } from "os";
509662
510291
  import { join as join193 } from "path";
509663
510292
  function markITerm2SetupComplete() {
509664
510293
  saveGlobalConfig((current5) => ({
@@ -509675,7 +510304,7 @@ function getIterm2RecoveryInfo() {
509675
510304
  }
509676
510305
  function getITerm2PlistPath() {
509677
510306
  return join193(
509678
- homedir47(),
510307
+ homedir48(),
509679
510308
  "Library",
509680
510309
  "Preferences",
509681
510310
  "com.googlecode.iterm2.plist"
@@ -510114,7 +510743,7 @@ var STDOUT_GUARD_MARKER, installed2, buffer4, originalWrite, init_streamJsonStdo
510114
510743
 
510115
510744
  // build-src/src/sema/config/mcpChannels.ts
510116
510745
  import { readFileSync as readFileSync49 } from "node:fs";
510117
- import { homedir as homedir48 } from "node:os";
510746
+ import { homedir as homedir49 } from "node:os";
510118
510747
  import { join as join194 } from "node:path";
510119
510748
  function mcpTransportOf(config4) {
510120
510749
  let c2 = config4;
@@ -510160,9 +510789,9 @@ function externalEntryToConfig(e) {
510160
510789
  };
510161
510790
  }
510162
510791
  function detectMcpChannels() {
510163
- let out6 = [], ccRoot2 = process.env.SEMA_CC_ROOT || join194(homedir48(), CC_DIR5), merged = {}, settingsServers = readJsoncSafe(join194(ccRoot2, "settings.json"))?.mcpServers;
510792
+ let out6 = [], ccRoot2 = process.env.SEMA_CC_ROOT || join194(homedir49(), CC_DIR5), merged = {}, settingsServers = readJsoncSafe(join194(ccRoot2, "settings.json"))?.mcpServers;
510164
510793
  settingsServers && typeof settingsServers == "object" && Object.assign(merged, settingsServers);
510165
- let globalServers = readJsoncSafe(join194(homedir48(), CC_GLOBAL_FILE2))?.mcpServers;
510794
+ let globalServers = readJsoncSafe(join194(homedir49(), CC_GLOBAL_FILE2))?.mcpServers;
510166
510795
  globalServers && typeof globalServers == "object" && Object.assign(merged, globalServers), Object.keys(merged).length > 0 && out6.push({ channel: "claude-code", label: CC_BRAND, servers: merged });
510167
510796
  for (let [channel, detected] of [
510168
510797
  ["openclaw", detectOpenclawMcp()],
@@ -510248,23 +510877,23 @@ var CC_DIR5, CC_GLOBAL_FILE2, MCP_SCOPE_LABELS, init_mcpChannels = __esm({
510248
510877
  });
510249
510878
 
510250
510879
  // build-src/src/sema/importSources.ts
510251
- import { existsSync as existsSync33, mkdirSync as mkdirSync26, readdirSync as readdirSync12, readFileSync as readFileSync50, writeFileSync as writeFileSync26 } from "node:fs";
510880
+ import { existsSync as existsSync33, mkdirSync as mkdirSync26, readdirSync as readdirSync13, readFileSync as readFileSync50, writeFileSync as writeFileSync26 } from "node:fs";
510252
510881
  import { createHash as createHash29 } from "node:crypto";
510253
- import { homedir as homedir49 } from "node:os";
510882
+ import { homedir as homedir50 } from "node:os";
510254
510883
  import { dirname as dirname89, join as join195, resolve as resolve49, sep as sep42 } from "node:path";
510255
510884
  function toSafeName(raw2) {
510256
510885
  return raw2.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "item";
510257
510886
  }
510258
510887
  function safeReaddirFiles(dir, ext) {
510259
510888
  try {
510260
- return readdirSync12(dir, { withFileTypes: !0 }).filter((e) => e.isFile() && e.name.endsWith(ext)).map((e) => e.name);
510889
+ return readdirSync13(dir, { withFileTypes: !0 }).filter((e) => e.isFile() && e.name.endsWith(ext)).map((e) => e.name);
510261
510890
  } catch {
510262
510891
  return [];
510263
510892
  }
510264
510893
  }
510265
510894
  function hasNamespacedSubdirs(dir) {
510266
510895
  try {
510267
- return readdirSync12(dir, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => e.name);
510896
+ return readdirSync13(dir, { withFileTypes: !0 }).filter((e) => e.isDirectory()).map((e) => e.name);
510268
510897
  } catch {
510269
510898
  return [];
510270
510899
  }
@@ -510444,7 +511073,7 @@ function hasShellExecMarker(body) {
510444
511073
  return /!\{[^}]+\}/.test(body) || /!`[^`]*`/.test(body);
510445
511074
  }
510446
511075
  function codexRoot() {
510447
- return process.env.SEMA_CODEX_ROOT || join195(homedir49(), ".codex");
511076
+ return process.env.SEMA_CODEX_ROOT || join195(homedir50(), ".codex");
510448
511077
  }
510449
511078
  function codexDetect() {
510450
511079
  let root2 = codexRoot();
@@ -510519,7 +511148,7 @@ async function codexScan() {
510519
511148
  return { items, unmappable };
510520
511149
  }
510521
511150
  function geminiRoot() {
510522
- return process.env.SEMA_GEMINI_ROOT || join195(homedir49(), ".gemini");
511151
+ return process.env.SEMA_GEMINI_ROOT || join195(homedir50(), ".gemini");
510523
511152
  }
510524
511153
  function geminiDetect() {
510525
511154
  let root2 = geminiRoot();
@@ -510632,7 +511261,7 @@ async function geminiScan() {
510632
511261
  return { items, unmappable };
510633
511262
  }
510634
511263
  function claudeRoot() {
510635
- return process.env.SEMA_CC_ROOT || join195(homedir49(), SEMA_SOURCE_DIR);
511264
+ return process.env.SEMA_CC_ROOT || join195(homedir50(), SEMA_SOURCE_DIR);
510636
511265
  }
510637
511266
  function claudeDetect() {
510638
511267
  let root2 = claudeRoot();
@@ -510755,7 +511384,7 @@ __export(cmd_import_exports, {
510755
511384
  default: () => cmd_import_default,
510756
511385
  runImportNonInteractive: () => runImportNonInteractive
510757
511386
  });
510758
- function plural4(n2, word) {
511387
+ function plural5(n2, word) {
510759
511388
  return n2 === 1 ? word : `${word}s`;
510760
511389
  }
510761
511390
  function allItems(scans) {
@@ -510766,13 +511395,13 @@ function allUnmappable(scans) {
510766
511395
  }
510767
511396
  function formatPreview(scans, from, digest, warnings) {
510768
511397
  let items = allItems(scans), unmappable = allUnmappable(scans), sourceNames = scans.map((s) => s.displayName).join(" and "), lines = [
510769
- `Found ${items.length} importable ${plural4(items.length, "item")} from ${sourceNames} (scan digest: ${digest}).`,
511398
+ `Found ${items.length} importable ${plural5(items.length, "item")} from ${sourceNames} (scan digest: ${digest}).`,
510770
511399
  ...warnings
510771
511400
  ];
510772
511401
  for (let item of items)
510773
511402
  lines.push(` [${item.source}] ${item.label} (${item.kind})`);
510774
511403
  if (unmappable.length > 0) {
510775
- lines.push("", `${unmappable.length} ${plural4(unmappable.length, "item")} could not be mapped automatically:`);
511404
+ lines.push("", `${unmappable.length} ${plural5(unmappable.length, "item")} could not be mapped automatically:`);
510776
511405
  for (let u of unmappable)
510777
511406
  lines.push(` \u26A0 [${u.source}] ${u.label}: ${u.reason}`);
510778
511407
  }
@@ -510792,8 +511421,8 @@ async function applyScans(scans, dryRun, warnings) {
510792
511421
  } catch (e) {
510793
511422
  resultLines.push(` \u2717 ${item.label}: ${e instanceof Error ? e.message : String(e)}`);
510794
511423
  }
510795
- let header = dryRun ? `Dry run \u2014 would import ${imported} ${plural4(imported, "item")}:` : `Imported ${imported} ${plural4(imported, "item")}:`, footer = [...warnings];
510796
- return unmappable.length > 0 && footer.push("", `${unmappable.length} ${plural4(unmappable.length, "item")} could not be mapped automatically \u2014 re-run \`/import\` to review.`), [header, ...resultLines, ...footer].join(`
511424
+ let header = dryRun ? `Dry run \u2014 would import ${imported} ${plural5(imported, "item")}:` : `Imported ${imported} ${plural5(imported, "item")}:`, footer = [...warnings];
511425
+ return unmappable.length > 0 && footer.push("", `${unmappable.length} ${plural5(unmappable.length, "item")} could not be mapped automatically \u2014 re-run \`/import\` to review.`), [header, ...resultLines, ...footer].join(`
510797
511426
  `);
510798
511427
  }
510799
511428
  async function handleImport(argsRaw) {
@@ -510889,6 +511518,10 @@ async function tryPrintLocalCommand(objective, deps2 = {}) {
510889
511518
  let result = await (await (await Promise.resolve().then(() => (init_agents2(), agents_exports2))).default.load()).call();
510890
511519
  return result.type === "text" ? result.value : null;
510891
511520
  }
511521
+ if (name === "team") {
511522
+ let { runTeamCommand: runTeamCommand2 } = await Promise.resolve().then(() => (init_team(), team_exports)), result = await runTeamCommand2(args);
511523
+ return result.type === "text" ? result.value : null;
511524
+ }
510892
511525
  return null;
510893
511526
  }
510894
511527
  var MCP_USAGE, MCP_NONE, MCP_CONTROLS_UNAVAILABLE, MODEL_HELP_TOKENS, init_printLocalCommands = __esm({
@@ -511948,8 +512581,8 @@ function resolveAgentModel(opts = {}) {
511948
512581
  let deps2 = { ...defaultDeps, ...opts.deps }, env5 = opts.env ?? process.env, envRaw = normalize19(env5.SEMA_SUBAGENT_MODEL) ?? normalize19(env5.SEMA_CODE_SUBAGENT_MODEL);
511949
512582
  if (envRaw && envRaw.toLowerCase() !== "inherit")
511950
512583
  return resolveWord(envRaw, "env", deps2);
511951
- let call77 = normalize19(opts.callParam);
511952
- if (call77) return resolveWord(call77, "call", deps2);
512584
+ let call78 = normalize19(opts.callParam);
512585
+ if (call78) return resolveWord(call78, "call", deps2);
511953
512586
  let fm = normalize19(opts.frontmatterModel);
511954
512587
  return fm ? resolveWord(fm, "frontmatter", deps2) : { model: "inherit", source: "main", kind: "inherit" };
511955
512588
  }
@@ -514161,17 +514794,19 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
514161
514794
  // 文本形态源之一),(b) 只会渲本地 loop 语义的模板句 —— 引擎终帧(timeout→error_max_turns、
514162
514795
  // budget、output.invalid)带 errors[] 引擎原话时优先如实渲它(--deadline 的 timeout 若渲
514163
514796
  // "Reached max turns (undefined)" 是撒谎)。errors[] 缺席时维持 CC 模板句(补 \n)。
514797
+ // #289 批面③(dogfood 复扫 api C1)—— **错档前缀**。这三个 subtype 全是引擎侧治理限额
514798
+ // 到限(轮数 / USD 预算 / 结构化输出重试),不是 provider 或 HTTP 层故障;此前 errors[]
514799
+ // 臂经 formatTextModeExecutionError 无条件补 `API Error: `,于是 `sema -p --max-turns N`
514800
+ // 的 STDERR 逐字是 `API Error: max turns exceeded`,把用户支去查网络/密钥/额度。而同一臂
514801
+ // 自己的 CC 对齐模板刻意不带 `API` 字样 —— 两条路径对同一类终态说了两种身份,且由于上游
514802
+ // terminalToSdkResult 恒填非空 errors[],真跑到的永远是补前缀那条(模板等同死码)。
514803
+ // 修 = 两条路径合流到一个中性格式化器:有引擎原话就用原话(前缀 `Error: `),没有才落模板。
514164
514804
  case "error_max_turns":
514165
514805
  case "error_max_budget_usd":
514166
514806
  case "error_max_structured_output_retries": {
514167
- let engineErrors = lastMessage.errors;
514168
- if (Array.isArray(engineErrors) && engineErrors.length > 0) {
514169
- process.stderr.write(formatTextModeExecutionError(engineErrors, mergedModelEnv()) + `
514170
- `);
514171
- break;
514172
- }
514173
- let template = lastMessage.subtype === "error_max_turns" ? `Error: Reached max turns (${options.maxTurns})` : lastMessage.subtype === "error_max_budget_usd" ? `Error: Exceeded USD budget (${options.maxBudgetUsd})` : "Error: Failed to provide valid structured output after maximum retries";
514174
- writeToStdout(template + `
514807
+ let engineErrors = lastMessage.errors, template = lastMessage.subtype === "error_max_turns" ? `Error: Reached max turns (${options.maxTurns})` : lastMessage.subtype === "error_max_budget_usd" ? `Error: Exceeded USD budget (${options.maxBudgetUsd})` : "Error: Failed to provide valid structured output after maximum retries", line = formatTextModeGovernanceStop(engineErrors, template);
514808
+ line === template ? writeToStdout(template + `
514809
+ `) : process.stderr.write(line + `
514175
514810
  `);
514176
514811
  break;
514177
514812
  }
@@ -517299,7 +517934,7 @@ __export(claudeDesktop_exports, {
517299
517934
  readClaudeDesktopMcpServers: () => readClaudeDesktopMcpServers
517300
517935
  });
517301
517936
  import { readdir as readdir33, readFile as readFile58, stat as stat52 } from "fs/promises";
517302
- import { homedir as homedir50 } from "os";
517937
+ import { homedir as homedir51 } from "os";
517303
517938
  import { join as join198 } from "path";
517304
517939
  async function getClaudeDesktopConfigPath() {
517305
517940
  let platform4 = getPlatform();
@@ -517309,7 +517944,7 @@ async function getClaudeDesktopConfigPath() {
517309
517944
  );
517310
517945
  if (platform4 === "macos")
517311
517946
  return join198(
517312
- homedir50(),
517947
+ homedir51(),
517313
517948
  "Library",
517314
517949
  "Application Support",
517315
517950
  "Claude",
@@ -517794,18 +518429,18 @@ __export(adoptionGuard_exports, {
517794
518429
  countLocalSessionArtifacts: () => countLocalSessionArtifacts,
517795
518430
  remoteSwitchSessionNotice: () => remoteSwitchSessionNotice
517796
518431
  });
517797
- import { readdirSync as readdirSync13, existsSync as existsSync34 } from "node:fs";
518432
+ import { readdirSync as readdirSync14, existsSync as existsSync34 } from "node:fs";
517798
518433
  import { join as join199 } from "node:path";
517799
518434
  function countLocalSessionArtifacts() {
517800
518435
  let census = { projects: 0, sessions: 0 };
517801
518436
  try {
517802
518437
  let root2 = getProjectsDir();
517803
518438
  if (!existsSync34(root2)) return census;
517804
- for (let entry of readdirSync13(root2, { withFileTypes: !0 })) {
518439
+ for (let entry of readdirSync14(root2, { withFileTypes: !0 })) {
517805
518440
  if (!entry.isDirectory()) continue;
517806
518441
  let n2 = 0;
517807
518442
  try {
517808
- n2 = readdirSync13(join199(root2, entry.name)).filter((f) => f.endsWith(".jsonl")).length;
518443
+ n2 = readdirSync14(join199(root2, entry.name)).filter((f) => f.endsWith(".jsonl")).length;
517809
518444
  } catch {
517810
518445
  continue;
517811
518446
  }
@@ -519704,7 +520339,7 @@ __export(cloudResources_exports, {
519704
520339
  cloudResourceSync: () => cloudResourceSync
519705
520340
  });
519706
520341
  import { createHash as createHash30 } from "node:crypto";
519707
- import { existsSync as existsSync36, readdirSync as readdirSync14, readFileSync as readFileSync54, statSync as statSync16 } from "node:fs";
520342
+ import { existsSync as existsSync36, readdirSync as readdirSync15, readFileSync as readFileSync54, statSync as statSync16 } from "node:fs";
519708
520343
  import { basename as basename69, dirname as dirname91, isAbsolute as isAbsolute34, join as join202, resolve as resolve50 } from "node:path";
519709
520344
  import { getEffective as getEffective2, getMeConfig, getScopeConfigDraft as getScopeConfigDraft2, OAuthFlowError as OAuthFlowError3, RegistryApiError as RegistryApiError3 } from "@sema-agent/sdk/registry";
519710
520345
  function fail4(e) {
@@ -520203,7 +520838,7 @@ async function loadLocalSkillEntries() {
520203
520838
  for (let root2 of roots) {
520204
520839
  let dirs = [];
520205
520840
  try {
520206
- dirs = readdirSync14(root2).filter((d4) => {
520841
+ dirs = readdirSync15(root2).filter((d4) => {
520207
520842
  try {
520208
520843
  return statSync16(join202(root2, d4)).isDirectory() && existsSync36(join202(root2, d4, "SKILL.md"));
520209
520844
  } catch {
@@ -524609,9 +525244,9 @@ var install_exports = {};
524609
525244
  __export(install_exports, {
524610
525245
  install: () => install
524611
525246
  });
524612
- import { homedir as homedir51 } from "node:os";
525247
+ import { homedir as homedir52 } from "node:os";
524613
525248
  function getInstallationPath2(realPath) {
524614
- let isWindows2 = env2.platform === "win32", homeDir = homedir51();
525249
+ let isWindows2 = env2.platform === "win32", homeDir = homedir52();
524615
525250
  return isWindows2 ? realPath.replace(/\//g, "\\") : realPath.startsWith(homeDir) ? `~${realPath.slice(homeDir.length)}` : realPath;
524616
525251
  }
524617
525252
  function SetupNotes(t0) {
@@ -525337,18 +525972,18 @@ var configSync_exports = {};
525337
525972
  __export(configSync_exports, {
525338
525973
  configSyncHandler: () => configSyncHandler
525339
525974
  });
525340
- import { homedir as homedir52 } from "node:os";
525975
+ import { homedir as homedir53 } from "node:os";
525341
525976
  import {
525342
525977
  copyFileSync as copyFileSync8,
525343
525978
  existsSync as existsSync38,
525344
525979
  mkdirSync as mkdirSync28,
525345
- readdirSync as readdirSync15,
525980
+ readdirSync as readdirSync16,
525346
525981
  readFileSync as readFileSync55,
525347
525982
  statSync as statSync18
525348
525983
  } from "node:fs";
525349
525984
  import { dirname as dirname95, join as join207, relative as relative37 } from "node:path";
525350
525985
  function display(p) {
525351
- let home = homedir52();
525986
+ let home = homedir53();
525352
525987
  return p.startsWith(home) ? "~" + p.slice(home.length) : p;
525353
525988
  }
525354
525989
  function filesEqual(a, b3) {
@@ -525463,7 +526098,7 @@ function syncTree(srcDir, destDir, labelBase, opts, report) {
525463
526098
  syncPlainFile(srcDir, destDir, labelBase, opts, report);
525464
526099
  return;
525465
526100
  }
525466
- for (let name of readdirSync15(srcDir)) {
526101
+ for (let name of readdirSync16(srcDir)) {
525467
526102
  let srcChild = join207(srcDir, name), destChild = join207(destDir, name), childStat;
525468
526103
  try {
525469
526104
  childStat = statSync18(srcChild);
@@ -525543,7 +526178,7 @@ async function configSyncHandler(opts) {
525543
526178
  }, dryTag = opts.dryRun ? source_default.yellow(" [dry-run]") : "";
525544
526179
  process.stdout.write(source_default.bold(`sema config sync${dryTag}
525545
526180
  `));
525546
- let userSrc = join207(homedir52(), LEGACY_DIR3), userDest = getClaudeConfigHomeDir();
526181
+ let userSrc = join207(homedir53(), LEGACY_DIR3), userDest = getClaudeConfigHomeDir();
525547
526182
  process.stdout.write(
525548
526183
  source_default.bold(`
525549
526184
  user: ${display(userSrc)} \u2192 ${display(userDest)}
@@ -525562,7 +526197,7 @@ user: ${display(userSrc)} \u2192 ${display(userDest)}
525562
526197
  opts,
525563
526198
  report
525564
526199
  );
525565
- let globalSrc = join207(homedir52(), LEGACY_GLOBAL_FILE), globalDest = getGlobalClaudeFile();
526200
+ let globalSrc = join207(homedir53(), LEGACY_GLOBAL_FILE), globalDest = getGlobalClaudeFile();
525566
526201
  if (existsSync38(globalSrc) && globalSrc !== globalDest && syncJsonFile(globalSrc, globalDest, display(globalDest), opts, report), flushEntries(report, userStart, opts), opts.project) {
525567
526202
  let projSrc = join207(process.cwd(), LEGACY_DIR3), projDest = join207(process.cwd(), ".sema");
525568
526203
  process.stdout.write(
@@ -525658,7 +526293,7 @@ __export(importCredentials_exports, {
525658
526293
  });
525659
526294
  import { execFileSync as execFileSync7 } from "node:child_process";
525660
526295
  import { readFileSync as readFileSync56 } from "node:fs";
525661
- import { homedir as homedir53, userInfo as userInfo4 } from "node:os";
526296
+ import { homedir as homedir54, userInfo as userInfo4 } from "node:os";
525662
526297
  import { join as join208 } from "node:path";
525663
526298
  function readCcKeychain() {
525664
526299
  if (process.platform !== "darwin") return null;
@@ -525681,7 +526316,7 @@ function readCcFile(ccRoot2) {
525681
526316
  }
525682
526317
  }
525683
526318
  async function importCredentialsHandler(opts) {
525684
- let ccRoot2 = opts.from ?? join208(homedir53(), LEGACY_DIR4), fromKeychain = readCcKeychain(), fromFile = readCcFile(ccRoot2);
526319
+ let ccRoot2 = opts.from ?? join208(homedir54(), LEGACY_DIR4), fromKeychain = readCcKeychain(), fromFile = readCcFile(ccRoot2);
525685
526320
  if (!fromKeychain && !fromFile) {
525686
526321
  console.log(`No ${SOURCE_BRAND2} credentials found (checked keychain and ${ccRoot2}/.credentials.json).`), process.exitCode = 1;
525687
526322
  return;
@@ -527676,7 +528311,7 @@ var React192, import_jsx_runtime504, init_navStack = __esm({
527676
528311
 
527677
528312
  // build-src/src/sema/config/PluginsHub.tsx
527678
528313
  import { readFileSync as readFileSync57 } from "node:fs";
527679
- import { homedir as homedir54 } from "node:os";
528314
+ import { homedir as homedir55 } from "node:os";
527680
528315
  import { join as join209 } from "node:path";
527681
528316
  function listInstalledPluginRows() {
527682
528317
  let plugins = {};
@@ -527710,7 +528345,7 @@ function readJsonSafe(path28) {
527710
528345
  }
527711
528346
  }
527712
528347
  function detectCcPlugins() {
527713
- let ccRoot2 = process.env.SEMA_CC_ROOT || join209(homedir54(), CC_DIR6), byId = /* @__PURE__ */ new Map(), pluginsField = readJsonSafe(join209(ccRoot2, "plugins", "installed_plugins.json"))?.plugins;
528348
+ let ccRoot2 = process.env.SEMA_CC_ROOT || join209(homedir55(), CC_DIR6), byId = /* @__PURE__ */ new Map(), pluginsField = readJsonSafe(join209(ccRoot2, "plugins", "installed_plugins.json"))?.plugins;
527714
528349
  if (pluginsField && typeof pluginsField == "object")
527715
528350
  for (let [id, v2] of Object.entries(pluginsField)) {
527716
528351
  let entry = Array.isArray(v2) ? v2[0] : v2;
@@ -528345,7 +528980,7 @@ var React194, import_jsx_runtime506, lastTierEditError, init_TiersHub = __esm({
528345
528980
  });
528346
528981
 
528347
528982
  // build-src/src/sema/config/skillsChannels.ts
528348
- import { existsSync as existsSync39, mkdirSync as mkdirSync29, readdirSync as readdirSync16, readFileSync as readFileSync58, realpathSync as realpathSync15, renameSync as renameSync17, statSync as statSync19 } from "node:fs";
528983
+ import { existsSync as existsSync39, mkdirSync as mkdirSync29, readdirSync as readdirSync17, readFileSync as readFileSync58, realpathSync as realpathSync15, renameSync as renameSync17, statSync as statSync19 } from "node:fs";
528349
528984
  import { basename as basename72, dirname as dirname96, join as join210 } from "node:path";
528350
528985
  function skillsDirFor(source) {
528351
528986
  return source === "user" ? join210(getClaudeConfigHomeDir(), "skills") : join210(getCwd(), ".sema", "skills");
@@ -528392,7 +529027,7 @@ function listInstalledSkills() {
528392
529027
  for (let source of sources) {
528393
529028
  let dir = skillsDirFor(source), entries;
528394
529029
  try {
528395
- entries = readdirSync16(dir).filter((n2) => !n2.startsWith("."));
529030
+ entries = readdirSync17(dir).filter((n2) => !n2.startsWith("."));
528396
529031
  } catch {
528397
529032
  continue;
528398
529033
  }
@@ -528961,20 +529596,11 @@ function stationSkipped(id) {
528961
529596
  if (id === "mcp") return detectMcpChannels().length === 0;
528962
529597
  if (id === "skills") return detectSkillChannels().length === 0;
528963
529598
  if (id === "plugins") return detectCcPlugins().plugins.length === 0;
528964
- if (id === "rules")
528965
- return readCcImportMarker() !== null ? !0 : !detectCcRulesImport().offer;
528966
529599
  } catch {
528967
529600
  return !1;
528968
529601
  }
528969
529602
  return !1;
528970
529603
  }
528971
- function rulesSkipSummary() {
528972
- try {
528973
- return readCcImportMarker() !== null ? "already imported once \u2014 re-import anytime from `/permissions`" : detectCcRulesImport().why === "lane-unavailable" ? "skipped \u2014 this engine has no rule store (manage saved rules from `/permissions`)" : "no permission rules found to import (manage saved rules from `/permissions`)";
528974
- } catch {
528975
- return "skipped (manage saved rules from `/permissions`)";
528976
- }
528977
- }
528978
529604
  function finalize2(flow) {
528979
529605
  if (!flow.finalized) {
528980
529606
  flow.finalized = !0;
@@ -528994,15 +529620,10 @@ function finalize2(flow) {
528994
529620
  } catch (e) {
528995
529621
  flow.summary.push(`model apply failed: ${e instanceof Error ? e.message : String(e)}`);
528996
529622
  }
528997
- for (let id of flow.skippedIds) {
528998
- if (id === "rules") {
528999
- flow.summary.push(`rules ${rulesSkipSummary()}`);
529000
- continue;
529001
- }
529623
+ for (let id of flow.skippedIds)
529002
529624
  flow.summary.push(
529003
529625
  `${id.padEnd(10)} nothing to import \u2014 skipped (run \`sema config ${id}\` anytime)`
529004
529626
  );
529005
- }
529006
529627
  }
529007
529628
  }
529008
529629
  function StationFrame({ flow, children }) {
@@ -529159,7 +529780,7 @@ function OnboardWizardBody({
529159
529780
  () => ({ summary: [], skippedIds: /* @__PURE__ */ new Set(), finalized: !1, zeroModels: !1, escArmedAt: 0, ctrlCArmedAt: 0, station: null }),
529160
529781
  []
529161
529782
  ), chain = React198.useMemo(
529162
- () => modelOnly ? ["model"] : ["language", "theme", "model", "tiers", "mcp", "skills", "plugins", "rules"],
529783
+ () => modelOnly ? ["model"] : ["language", "theme", "model", "tiers", "mcp", "skills", "plugins"],
529163
529784
  [modelOnly]
529164
529785
  ), setUiLanguage = useSetUiLanguage(), t2 = useT(), tRef = React198.useRef(t2);
529165
529786
  tRef.current = t2;
@@ -529239,28 +529860,6 @@ function OnboardWizardBody({
529239
529860
  }
529240
529861
  )
529241
529862
  };
529242
- if (id === "rules") {
529243
- let rulesNavRef = { current: null }, detected = detectCcRulesImport();
529244
- return {
529245
- key: "onboard-rules",
529246
- wantsEsc: () => {
529247
- let nav = rulesNavRef.current;
529248
- return !nav || goBack(i, nav) ? !0 : firstStationEsc();
529249
- },
529250
- render: (nav) => (rulesNavRef.current = nav, /* @__PURE__ */ (0, import_jsx_runtime511.jsxs)(ThemedBox_default, { flexDirection: "column", children: [
529251
- /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(ThemedText, { dimColor: !0, children: tt2("onboard.blurb.rules") }),
529252
- /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(
529253
- CcRulesImportFlow,
529254
- {
529255
- layers: detected.layers,
529256
- onDone: (summary) => {
529257
- summary !== null && flow.summary.push(summary), advance(i, nav);
529258
- }
529259
- }
529260
- )
529261
- ] }))
529262
- };
529263
- }
529264
529863
  let navRef = { current: null }, onboardOpts = {
529265
529864
  blurb: tt2(STATION_BLURB_KEYS[id]),
529266
529865
  continueLabel: "Continue \u2192",
@@ -529301,10 +529900,7 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529301
529900
  init_TiersHub();
529302
529901
  init_skillsChannels();
529303
529902
  init_SkillsHub();
529304
- init_ccImportMarker();
529305
529903
  init_BigStepTitle();
529306
- init_CcRulesImportFlow();
529307
- init_ccRulesImport();
529308
529904
  init_LanguageStation();
529309
529905
  init_onboardVerification();
529310
529906
  init_onboardZeroModel();
@@ -529319,8 +529915,7 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529319
529915
  tiers: "onboard.station.tiers",
529320
529916
  mcp: "onboard.station.mcp",
529321
529917
  skills: "onboard.station.skills",
529322
- plugins: "onboard.station.plugins",
529323
- rules: "onboard.station.rules"
529918
+ plugins: "onboard.station.plugins"
529324
529919
  }, STATION_WORDS = {
529325
529920
  language: "LANGUAGE",
529326
529921
  theme: "THEME",
@@ -529328,15 +529923,13 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529328
529923
  tiers: "TIERS",
529329
529924
  mcp: "MCP",
529330
529925
  skills: "SKILLS",
529331
- plugins: "PLUGINS",
529332
- rules: "RULES"
529926
+ plugins: "PLUGINS"
529333
529927
  }, STATION_BLURB_KEYS = {
529334
529928
  model: "onboard.blurb.model",
529335
529929
  tiers: "onboard.blurb.tiers",
529336
529930
  mcp: "onboard.blurb.mcp",
529337
529931
  skills: "onboard.blurb.skills",
529338
- plugins: "onboard.blurb.plugins",
529339
- rules: "onboard.blurb.rules"
529932
+ plugins: "onboard.blurb.plugins"
529340
529933
  };
529341
529934
  WELCOME_WORDMARK = [
529342
529935
  ["#00E5FF", "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 "],
@@ -529790,7 +530383,12 @@ ${addendum}` : addendum;
529790
530383
  notification: permissionModeNotification
529791
530384
  } = initialPermissionModeFromCLI({
529792
530385
  permissionModeCli,
529793
- dangerouslySkipPermissions
530386
+ dangerouslySkipPermissions,
530387
+ // sema 出厂默认 auto([4197]⑤)仅真交互车道。判据必须是 isNonInteractive 全开集
530388
+ // (print/--init-only/SDK URL/stdout 非 TTY 四臂,839 行铸位)而非 `!print` 单臂——
530389
+ // 1.0.83 扫码异源复审 F2:stdout 重定向且无 -p 时 print=false 却走 headless,单臂判据
530390
+ // 会让无人值守车道漏进出厂 auto。#164/#165 headless 门链以 default 为前提。
530391
+ factoryDefaultAutoEligible: !getIsNonInteractiveSession()
529794
530392
  });
529795
530393
  setSessionBypassPermissionsMode(permissionMode === "bypassPermissions"), (options.enableAutoMode || permissionModeCli === "auto" || permissionMode === "auto" || !permissionModeCli && isDefaultPermissionModeAuto()) && autoModeStateModule7?.setAutoModeFlagCli(!0);
529796
530394
  let dynamicMcpConfig = {};
@@ -530692,7 +531290,7 @@ Usage: sema --remote "your task description"`, () => gracefulShutdown(1));
530692
531290
  pendingHookMessages
530693
531291
  }, renderAndRun);
530694
531292
  }
530695
- }).version("sema 1.0.81", "-v, --version", "Output the version number"), program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)"), program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux."), canUserConfigureAdvisor() && program2.addOption(new Option("--advisor <model>", "Enable the server-side advisor tool with the specified model (alias or full ID).").hideHelp()), program2.addOption(new Option("--bg, --background", "Start the session as a background agent and return immediately (manage with `sema agents`)")), program2.command("ps").description("List background sessions").action(async () => {
531293
+ }).version("sema 1.0.83", "-v, --version", "Output the version number"), program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)"), program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux."), canUserConfigureAdvisor() && program2.addOption(new Option("--advisor <model>", "Enable the server-side advisor tool with the specified model (alias or full ID).").hideHelp()), program2.addOption(new Option("--bg, --background", "Start the session as a background agent and return immediately (manage with `sema agents`)")), program2.command("ps").description("List background sessions").action(async () => {
530696
531294
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).psHandler([]), process.exit(process.exitCode ?? 0);
530697
531295
  }), program2.command("logs [id]").description("Print a background session's recent terminal output").action(async (id) => {
530698
531296
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).logsHandler(id, []), process.exit(process.exitCode ?? 0);
@@ -530700,7 +531298,7 @@ Usage: sema --remote "your task description"`, () => gracefulShutdown(1));
530700
531298
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).attachHandler(id, []), process.exit(process.exitCode ?? 0);
530701
531299
  }), program2.command("kill [id]").description("Terminate a background session").action(async (id) => {
530702
531300
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).killHandler(id, []), process.exit(process.exitCode ?? 0);
530703
- }), program2.addOption(new Option("--brief", "Enable SendUserMessage tool for agent-to-user communication")), program2.addOption(new Option("--ax-screen-reader", "Render screen-reader friendly output (flat text, no decorative borders or animations).")), program2.addOption(new Option("--enable-auto-mode", "Opt in to auto mode").hideHelp()), program2.addOption(new Option("--agent-id <id>", "Teammate agent ID").hideHelp()), program2.addOption(new Option("--agent-name <name>", "Teammate display name").hideHelp()), program2.addOption(new Option("--team-name <name>", "Team name for swarm coordination").hideHelp()), program2.addOption(new Option("--agent-color <color>", "Teammate UI color").hideHelp()), program2.addOption(new Option("--plan-mode-required", "Require plan mode before implementation").hideHelp()), program2.addOption(new Option("--parent-session-id <id>", "Parent session ID for analytics correlation").hideHelp()), program2.addOption(new Option("--teammate-mode <mode>", 'How to spawn teammates: "tmux", "iterm2", "in-process", or "auto"').choices(["auto", "tmux", "iterm2", "in-process"]).hideHelp()), program2.addOption(new Option("--agent-type <type>", "Custom agent type for this teammate").hideHelp()), program2.addOption(new Option("--sdk-url <url>", "Use remote WebSocket endpoint for SDK I/O streaming (only with -p and stream-json format)").hideHelp()), program2.addOption(new Option("--teleport [session]", "Resume a teleport session, optionally specify session ID").hideHelp()), program2.addOption(new Option("--cloud [description|session_id|url]", "Create a cloud session with the given description, or attach to an existing one by session ID or claude.ai/code URL").hideHelp()), program2.addOption(new Option("--remote [description|session_id|url]", "Deprecated alias for --cloud").hideHelp()), program2.addOption(new Option("--remote-control [name]", "Start an interactive session with Remote Control enabled (optionally named)").argParser((value) => value || !0)), program2.addOption(new Option("--rc [name]", "Alias for --remote-control").argParser((value) => value || !0).hideHelp()), program2.option("--remote-control-session-name-prefix <prefix>", "Prefix for auto-generated Remote Control session names (default: hostname)"), profileCheckpoint("run_main_options_built");
531301
+ }), program2.addOption(new Option("--brief", "Enable SendUserMessage tool for agent-to-user communication")), program2.addOption(new Option("--ax-screen-reader", "Render screen-reader friendly output (flat text, no decorative borders or animations).")), program2.option("--agent-teams", "Enable agent teams: named persistent teammates with a shared task list (experimental, off by default)", () => !0), program2.addOption(new Option("--enable-auto-mode", "Opt in to auto mode").hideHelp()), program2.addOption(new Option("--agent-id <id>", "Teammate agent ID").hideHelp()), program2.addOption(new Option("--agent-name <name>", "Teammate display name").hideHelp()), program2.addOption(new Option("--team-name <name>", "Team name for swarm coordination").hideHelp()), program2.addOption(new Option("--agent-color <color>", "Teammate UI color").hideHelp()), program2.addOption(new Option("--plan-mode-required", "Require plan mode before implementation").hideHelp()), program2.addOption(new Option("--parent-session-id <id>", "Parent session ID for analytics correlation").hideHelp()), program2.addOption(new Option("--teammate-mode <mode>", 'How to spawn teammates: "tmux", "iterm2", "in-process", or "auto"').choices(["auto", "tmux", "iterm2", "in-process"]).hideHelp()), program2.addOption(new Option("--agent-type <type>", "Custom agent type for this teammate").hideHelp()), program2.addOption(new Option("--sdk-url <url>", "Use remote WebSocket endpoint for SDK I/O streaming (only with -p and stream-json format)").hideHelp()), program2.addOption(new Option("--teleport [session]", "Resume a teleport session, optionally specify session ID").hideHelp()), program2.addOption(new Option("--cloud [description|session_id|url]", "Create a cloud session with the given description, or attach to an existing one by session ID or claude.ai/code URL").hideHelp()), program2.addOption(new Option("--remote [description|session_id|url]", "Deprecated alias for --cloud").hideHelp()), program2.addOption(new Option("--remote-control [name]", "Start an interactive session with Remote Control enabled (optionally named)").argParser((value) => value || !0)), program2.addOption(new Option("--rc [name]", "Alias for --remote-control").argParser((value) => value || !0).hideHelp()), program2.option("--remote-control-session-name-prefix <prefix>", "Prefix for auto-generated Remote Control session names (default: hostname)"), profileCheckpoint("run_main_options_built");
530704
531302
  let isPrintMode = process.argv.includes("-p") || process.argv.includes("--print"), isCcUrl = process.argv.some((a) => a.startsWith("cc://") || a.startsWith("cc+unix://"));
530705
531303
  if (isPrintMode && !isCcUrl)
530706
531304
  return profileCheckpoint("run_before_parse"), await program2.parseAsync(process.argv), profileCheckpoint("run_after_parse"), program2;
@@ -531211,7 +531809,7 @@ Usage: sema --remote "your task description"`, () => gracefulShutdown(1));
531211
531809
  let after = installedVersion2();
531212
531810
  console.log(`sema ${cur ?? "unknown"} \u2192 ${after ?? "unknown"}${cur === after ? " (forced reinstall, same version)" : ""}`);
531213
531811
  let { finalizeEngineSwapAfterUpdate: finalizeEngineSwapAfterUpdate2 } = await Promise.resolve().then(() => (init_semaUpdater(), semaUpdater_exports));
531214
- await finalizeEngineSwapAfterUpdate2(after ?? latest), process.exit(0);
531812
+ await finalizeEngineSwapAfterUpdate2(after ?? latest), console.log("Run 'sema doctor' to verify your configuration on the new version."), process.exit(0);
531215
531813
  }
531216
531814
  }
531217
531815
  let {
@@ -532305,7 +532903,7 @@ var TrustDialog_exports = {};
532305
532903
  __export(TrustDialog_exports, {
532306
532904
  TrustDialog: () => TrustDialog
532307
532905
  });
532308
- import { homedir as homedir55 } from "os";
532906
+ import { homedir as homedir56 } from "os";
532309
532907
  function TrustDialog(t0) {
532310
532908
  let $3 = (0, import_compiler_runtime350.c)(33), {
532311
532909
  onDone,
@@ -532336,7 +532934,7 @@ function TrustDialog(t0) {
532336
532934
  $3[11] !== commands ? (t11 = commands?.some(_temp437) ?? !1, $3[11] = commands, $3[12] = t11) : t11 = $3[12];
532337
532935
  let hasSkillsBash = t11, hasAnyBashExecution = bashSettingSources.length > 0 || hasSlashCommandBash || hasSkillsBash, hasTrustDialogAccepted = checkHasTrustDialogAccepted(), t12, t13;
532338
532936
  $3[13] !== hasAnyBashExecution ? (t12 = () => {
532339
- let isHomeDir = homedir55() === getCwd();
532937
+ let isHomeDir = homedir56() === getCwd();
532340
532938
  }, t13 = [hasMcpServers, hasHooks2, hasAnyBashExecution, hasApiKeyHelper2, hasAwsCommands2, hasGcpCommands2, hasOtelHeadersHelper2, hasDangerousEnvVars2], $3[13] = hasAnyBashExecution, $3[14] = t12, $3[15] = t13) : (t12 = $3[14], t13 = $3[15]), import_react350.default.useEffect(t12, t13);
532341
532939
  let t14;
532342
532940
  $3[16] !== hasAnyBashExecution || $3[17] !== onDone ? (t14 = function(value) {
@@ -532344,7 +532942,7 @@ function TrustDialog(t0) {
532344
532942
  gracefulShutdownSync(1);
532345
532943
  return;
532346
532944
  }
532347
- let isHomeDir_0 = homedir55() === getCwd();
532945
+ let isHomeDir_0 = homedir56() === getCwd();
532348
532946
  isHomeDir_0 ? setSessionTrustAccepted(!0) : saveCurrentProjectConfig(_temp523), onDone();
532349
532947
  }, $3[16] = hasAnyBashExecution, $3[17] = onDone, $3[18] = t14) : t14 = $3[18];
532350
532948
  let onChange = t14, exitState = useExitOnCtrlCDWithKeybindings(_temp619), t15;
@@ -532683,7 +533281,7 @@ async function showSetupScreens(root2, permissionMode, allowDangerouslySkipPermi
532683
533281
  } = await Promise.resolve().then(() => (init_BypassPermissionsModeDialog(), BypassPermissionsModeDialog_exports));
532684
533282
  await showSetupDialog(root2, (done) => /* @__PURE__ */ (0, import_jsx_runtime526.jsx)(BypassPermissionsModeDialog2, { onAccept: done }));
532685
533283
  }
532686
- if (permissionMode === "auto" && !hasAutoModeOptIn()) {
533284
+ if (permissionMode === "auto" && !hasAutoModeOptIn() && !isFactoryDefaultAutoActive()) {
532687
533285
  let {
532688
533286
  AutoModeOptInDialog: AutoModeOptInDialog2
532689
533287
  } = await Promise.resolve().then(() => (init_AutoModeOptInDialog(), AutoModeOptInDialog_exports));
@@ -532750,6 +533348,7 @@ var import_jsx_runtime526, init_interactiveHelpers = __esm({
532750
533348
  init_AppState();
532751
533349
  init_onChangeAppState();
532752
533350
  init_authPortable();
533351
+ init_permissionSetup();
532753
533352
  init_claudemd();
532754
533353
  init_config();
532755
533354
  init_terminalPreference();
@@ -533289,13 +533888,13 @@ __export(claudeImportHint_exports, {
533289
533888
  maybeEmitClaudeImportHint: () => maybeEmitClaudeImportHint
533290
533889
  });
533291
533890
  import { existsSync as existsSync40 } from "node:fs";
533292
- import { homedir as homedir56 } from "node:os";
533891
+ import { homedir as homedir57 } from "node:os";
533293
533892
  import { join as join212 } from "node:path";
533294
533893
  function shouldShowClaudeImportHint() {
533295
533894
  try {
533296
533895
  if (process.env.SEMA_CONFIG_DIR || process.env["CLAUDE_CONFIG_DIR"]) return !1;
533297
- let legacyDir = join212(homedir56(), ".claude");
533298
- return !(!existsSync40(legacyDir) || existsSync40(join212(homedir56(), ".sema")) || getGlobalConfig().hasSeenClaudeImportHint);
533896
+ let legacyDir = join212(homedir57(), ".claude");
533897
+ return !(!existsSync40(legacyDir) || existsSync40(join212(homedir57(), ".sema")) || getGlobalConfig().hasSeenClaudeImportHint);
533299
533898
  } catch {
533300
533899
  return !1;
533301
533900
  }
@@ -533689,7 +534288,7 @@ var init_schedulerDaemonWire = __esm({
533689
534288
  });
533690
534289
 
533691
534290
  // build-src/src/sema/scheduler/sessionReap.ts
533692
- import { mkdirSync as mkdirSync32, readdirSync as readdirSync17, readFileSync as readFileSync63, unlinkSync as unlinkSync15, writeFileSync as writeFileSync30 } from "node:fs";
534291
+ import { mkdirSync as mkdirSync32, readdirSync as readdirSync18, readFileSync as readFileSync63, unlinkSync as unlinkSync15, writeFileSync as writeFileSync30 } from "node:fs";
533693
534292
  import { dirname as dirname99, join as join215 } from "node:path";
533694
534293
  function isSessionLifetimeRecord(r) {
533695
534294
  return r.lifetime === "session";
@@ -533743,7 +534342,7 @@ function removeSchedulerClaim(storePath, pid = process.pid) {
533743
534342
  function readAliveClaimedSessionIds(storePath, opts = {}) {
533744
534343
  let alive = opts.isPidAlive ?? pidAlive3, dir = schedulerClaimsDir(storePath), out6 = /* @__PURE__ */ new Set(), files2;
533745
534344
  try {
533746
- files2 = readdirSync17(dir);
534345
+ files2 = readdirSync18(dir);
533747
534346
  } catch {
533748
534347
  return out6;
533749
534348
  }
@@ -534227,11 +534826,11 @@ var init_skillsFill = __esm({
534227
534826
  });
534228
534827
 
534229
534828
  // build-src/src/sema/teamOnboarding.ts
534230
- import { existsSync as existsSync42, readdirSync as readdirSync18 } from "fs";
534829
+ import { existsSync as existsSync42, readdirSync as readdirSync19 } from "fs";
534231
534830
  function hasWorkspaceData() {
534232
534831
  try {
534233
534832
  let dir = getProjectsDir2();
534234
- return existsSync42(dir) ? readdirSync18(dir).length > 0 : !1;
534833
+ return existsSync42(dir) ? readdirSync19(dir).length > 0 : !1;
534235
534834
  } catch {
534236
534835
  return !1;
534237
534836
  }
@@ -535316,7 +535915,7 @@ __export(mcpFill_exports, {
535316
535915
  default: () => mcpFill_default,
535317
535916
  loadCanonicalMcpClients: () => loadCanonicalMcpClients
535318
535917
  });
535319
- import { homedir as homedir57 } from "os";
535918
+ import { homedir as homedir58 } from "os";
535320
535919
  import { readFileSync as readFileSync64 } from "fs";
535321
535920
  function builtinDynamicConfig(command8) {
535322
535921
  return { type: "stdio", command: command8, args: [], scope: "dynamic" };
@@ -535329,7 +535928,7 @@ function builtinDynamicClients() {
535329
535928
  }));
535330
535929
  }
535331
535930
  function canonicalGlobalConfigFile() {
535332
- return `${process.env.HOME ?? process.env.USERPROFILE ?? homedir57()}/.claude.json`;
535931
+ return `${process.env.HOME ?? process.env.USERPROFILE ?? homedir58()}/.claude.json`;
535333
535932
  }
535334
535933
  async function loadCanonicalMcpClients() {
535335
535934
  try {
@@ -535376,8 +535975,8 @@ var BUILTIN_DYNAMIC, mcpFill_default, init_mcpFill = __esm({
535376
535975
  });
535377
535976
 
535378
535977
  // build-src/stubs/bun-bundle.js
535379
- var bun_bundle_exports = {};
535380
- __export(bun_bundle_exports, {
535978
+ var bun_bundle_exports2 = {};
535979
+ __export(bun_bundle_exports2, {
535381
535980
  feature: () => feature2
535382
535981
  });
535383
535982
  function feature2(flag) {
@@ -537189,7 +537788,9 @@ async function main2() {
537189
537788
  liveWorkflowBaseUrl ? (liveWorkflowSource = createLiveWorkflowSource({
537190
537789
  baseUrl: liveWorkflowBaseUrl,
537191
537790
  authToken: process.env.SEMA_WORKFLOW_TOKEN || process.env.SEMA_FLEET_TOKEN || "anon",
537192
- principal: process.env.SEMA_WORKFLOW_PRINCIPAL ?? process.env.SEMA_FLEET_PRINCIPAL ?? "anon:sema",
537791
+ // principal 恒经闸口(F-011/[4189];workflow 专属 env 显式恒赢,回落 fleet→live 解析
537792
+ // 链缺省 'default'——同文件 workflow monitor 臂同形;anon 前缀哨兵残留已清)
537793
+ principal: process.env.SEMA_WORKFLOW_PRINCIPAL ?? resolveFleetPrincipal(),
537193
537794
  ...process.env.SEMA_WORKFLOW_ID ? { workflowId: process.env.SEMA_WORKFLOW_ID } : {}
537194
537795
  }), process.env.SEMA_DEBUG && console.error(
537195
537796
  `[sema] workflow source: LIVE WIRE (${liveWorkflowBaseUrl}) \u2014 createLiveWorkflowSource`
@@ -537237,7 +537838,9 @@ async function main2() {
537237
537838
  let { createLiveFleetSource: createLiveFleetSource2 } = await Promise.resolve().then(() => (init_fleetClient(), fleetClient_exports)), source2 = createLiveFleetSource2({
537238
537839
  baseUrl: liveBaseUrl,
537239
537840
  authToken: process.env.SEMA_FLEET_TOKEN || "anon",
537240
- principal: process.env.SEMA_FLEET_PRINCIPAL ?? "anon:sema"
537841
+ // principal 恒经闸口(F-011/[4189]:resolveFleetPrincipal 内部先认 SEMA_FLEET_PRINCIPAL
537842
+ // 显式值,缺省 'default' 租户键;anon 前缀哨兵残留已清)
537843
+ principal: resolveFleetPrincipal()
537241
537844
  });
537242
537845
  return process.env.SEMA_DEBUG && console.error(`[sema] fleet source: LIVE WIRE (${liveBaseUrl}) \u2014 createLiveFleetSource`), source2;
537243
537846
  }
@@ -537973,7 +538576,7 @@ async function launchReplProduction() {
537973
538576
  let offlineFallback = process.env.SEMA_LIVE_BASEURL ? "unknown" : "opus[1m]";
537974
538577
  initialState.mainLoopModel = resolved ?? offlineFallback;
537975
538578
  }
537976
- let bypassModeLaunch = !1, settingsRejectionNotices = [];
538579
+ let bypassModeLaunch = !1, settingsRejectionNotices = [], bootFailClosedNotices = [];
537977
538580
  try {
537978
538581
  let argv = process.argv.slice(2), allowDangerouslySkipPermissions = argv.includes("--dangerously-skip-permissions"), pmIdx = argv.indexOf("--permission-mode"), cliPermissionMode = pmIdx >= 0 ? argv[pmIdx + 1] : void 0, { PERMISSION_MODES: PERMISSION_MODES3 } = await Promise.resolve().then(() => (init_PermissionMode(), PermissionMode_exports)), launchMode = ((m2) => !!m2 && PERMISSION_MODES3.includes(m2))(cliPermissionMode) ? cliPermissionMode : allowDangerouslySkipPermissions ? "bypassPermissions" : void 0, settingsDisableBypass = !0;
537979
538582
  try {
@@ -537985,23 +538588,35 @@ async function launchReplProduction() {
537985
538588
  () => getInitialSettings2()?.permissions?.disableBypassPermissionsMode,
537986
538589
  () => mdmMod.filterManagedPolicyErrors(getSettingsWithErrors2().errors)
537987
538590
  );
537988
- settingsDisableBypass = verdict.disable, verdict.loudReason && process.stderr.write(
537989
- `[sema] bypassPermissions kept unavailable (fail-closed): ${verdict.loudReason}
537990
- `
537991
- );
538591
+ if (settingsDisableBypass = verdict.disable, verdict.loudReason) {
538592
+ let msg = `bypassPermissions kept unavailable (fail-closed): ${verdict.loudReason}`;
538593
+ process.stderr.write(`[sema] ${msg}
538594
+ `), bootFailClosedNotices.push(msg);
538595
+ }
537992
538596
  } catch (e) {
537993
- settingsDisableBypass = !0, process.stderr.write(
537994
- `[sema] settings read failed \u2014 bypassPermissions kept unavailable (fail-closed): ${e instanceof Error ? e.message : String(e)}
537995
- `
537996
- );
538597
+ settingsDisableBypass = !0;
538598
+ let msg = `settings read failed \u2014 bypassPermissions kept unavailable (fail-closed): ${e instanceof Error ? e.message : String(e)}`;
538599
+ process.stderr.write(`[sema] ${msg}
538600
+ `), bootFailClosedNotices.push(msg);
537997
538601
  }
537998
538602
  let isBypassPermissionsModeAvailable = (launchMode === "bypassPermissions" || allowDangerouslySkipPermissions) && !settingsDisableBypass, tpc = initialState.toolPermissionContext;
537999
538603
  launchMode && (tpc.mode = launchMode), tpc.isBypassPermissionsModeAvailable = isBypassPermissionsModeAvailable, bypassModeLaunch = isBypassPermissionsModeAvailable;
538000
538604
  let effectiveConfig;
538001
538605
  try {
538002
- effectiveConfig = resolveSemaConfig({ launchMode });
538606
+ let { feature: feature3 } = await Promise.resolve().then(() => (init_bun_bundle(), bun_bundle_exports)), { getAutoModeEnabledStateIfCached: getAutoModeEnabledStateIfCached2 } = await Promise.resolve().then(() => (init_permissionSetup(), permissionSetup_exports)), factoryDefaultAutoEligible = getAutoModeEnabledStateIfCached2() !== "disabled";
538607
+ effectiveConfig = resolveSemaConfig({
538608
+ launchMode,
538609
+ factoryDefaultAuto: factoryDefaultAutoEligible
538610
+ });
538003
538611
  let dm = effectiveConfig.derivedMode;
538004
- tpc.mode = dm === "bypassPermissions" && !isBypassPermissionsModeAvailable ? "default" : dm, bypassModeLaunch = tpc.mode === "bypassPermissions", settingsRejectionNotices = effectiveConfig.rejections.map(describeRejection), process.env.SEMA_DEBUG && console.error(
538612
+ if (tpc.mode = dm === "bypassPermissions" && !isBypassPermissionsModeAvailable ? "default" : dm, bypassModeLaunch = tpc.mode === "bypassPermissions", tpc.mode === "auto") {
538613
+ let { setAutoModeActive: setAutoModeActive2 } = await Promise.resolve().then(() => (init_autoModeState(), autoModeState_exports));
538614
+ if (setAutoModeActive2(!0), effectiveConfig.derivedModeIsFactoryDefault === !0) {
538615
+ let { markFactoryDefaultAutoActive: markFactoryDefaultAutoActive2 } = await Promise.resolve().then(() => (init_permissionSetup(), permissionSetup_exports));
538616
+ markFactoryDefaultAutoActive2();
538617
+ }
538618
+ }
538619
+ settingsRejectionNotices = effectiveConfig.rejections.map(describeRejection), process.env.SEMA_DEBUG && console.error(
538005
538620
  `[sema] resolver: derivedMode=${dm} \u2192 tpc.mode=${tpc.mode} \xB7 model=${effectiveConfig.model ?? "\u2205"} hooks=${effectiveConfig.hooks ? "set" : "\u2205"} envKeys=${Object.keys(effectiveConfig.env ?? {}).length}`
538006
538621
  );
538007
538622
  try {
@@ -538009,11 +538624,9 @@ async function launchReplProduction() {
538009
538624
  try {
538010
538625
  let deadRules = unenforceableSettingsRules(fullWire);
538011
538626
  if (deadRules.length > 0) {
538012
- let shown = deadRules.slice(0, 5).map((r) => JSON.stringify(r)).join(", "), more = deadRules.length > 5 ? ` (+${deadRules.length - 5} more)` : "";
538013
- process.stderr.write(
538014
- `[sema] permissions: ${deadRules.length} rule(s) use tool names this engine does not recognize and will not be enforced: ${shown}${more} \u2014 update these entries in your settings permissions lists
538015
- `
538016
- );
538627
+ let shown = deadRules.slice(0, 5).map((r) => JSON.stringify(r)).join(", "), more = deadRules.length > 5 ? ` (+${deadRules.length - 5} more)` : "", msg = `permissions: ${deadRules.length} rule(s) use tool names this engine does not recognize and will not be enforced: ${shown}${more} \u2014 update these entries in your settings permissions lists`;
538628
+ process.stderr.write(`[sema] ${msg}
538629
+ `), bootFailClosedNotices.push(msg);
538017
538630
  }
538018
538631
  } catch {
538019
538632
  }
@@ -538109,7 +538722,7 @@ async function launchReplProduction() {
538109
538722
  try {
538110
538723
  let modeApi = null;
538111
538724
  try {
538112
- let { feature: feature3 } = await Promise.resolve().then(() => (init_bun_bundle2(), bun_bundle_exports));
538725
+ let { feature: feature3 } = await Promise.resolve().then(() => (init_bun_bundle2(), bun_bundle_exports2));
538113
538726
  } catch {
538114
538727
  }
538115
538728
  let resumeContext = {
@@ -538307,15 +538920,25 @@ async function launchReplProduction() {
538307
538920
  }
538308
538921
  let { launchRepl: launchRepl2 } = await Promise.resolve().then(() => (init_replLauncher(), replLauncher_exports)), { createSystemMessage: createSystemMessage3 } = await Promise.resolve().then(() => (init_messages4(), messages_exports2));
538309
538922
  try {
538310
- let { settingsLoudNoticesActive: settingsLoudNoticesActive2 } = await Promise.resolve().then(() => (init_settings2(), settings_exports2)), { resolverLoudNoticesActive: resolverLoudNoticesActive2 } = await Promise.resolve().then(() => (init_resolver2(), resolver_exports));
538923
+ let { settingsLoudNoticesActive: settingsLoudNoticesActive2 } = await Promise.resolve().then(() => (init_settings2(), settings_exports2)), { resolverLoudNoticesActive: resolverLoudNoticesActive2 } = await Promise.resolve().then(() => (init_resolver2(), resolver_exports)), { permissionsLoaderLoudNoticesActive: permissionsLoaderLoudNoticesActive2 } = await Promise.resolve().then(() => (init_permissionsLoader(), permissionsLoader_exports));
538311
538924
  settingsRejectionNotices = [
538312
538925
  ...settingsRejectionNotices,
538313
538926
  ...settingsLoudNoticesActive2(),
538314
- ...resolverLoudNoticesActive2()
538927
+ ...resolverLoudNoticesActive2(),
538928
+ ...bootFailClosedNotices,
538929
+ ...permissionsLoaderLoudNoticesActive2()
538315
538930
  ];
538316
538931
  } catch (eN) {
538317
538932
  process.env.SEMA_DEBUG && console.error("[sema] settings notices merge soft-failed:", eN);
538318
538933
  }
538934
+ try {
538935
+ let { runCcImportBootAuto: runCcImportBootAuto2 } = await Promise.resolve().then(() => (init_ccImportBootRun(), ccImportBootRun_exports));
538936
+ runCcImportBootAuto2().then((outcome) => {
538937
+ process.env.SEMA_DEBUG && console.error(`[sema] cc-import boot arm: ${outcome}`);
538938
+ });
538939
+ } catch (eI) {
538940
+ process.env.SEMA_DEBUG && console.error("[sema] cc-import boot arm load soft-failed:", eI);
538941
+ }
538319
538942
  await launchRepl2(
538320
538943
  root2,
538321
538944
  {
@@ -538490,7 +539113,7 @@ var React215, import_jsx_runtime537, isMain, COMMANDER_SUBCOMMANDS, replEntry_de
538490
539113
  if (isMain) {
538491
539114
  let argv = process.argv.slice(2);
538492
539115
  (async () => {
538493
- let { feature: feature3 } = await Promise.resolve().then(() => (init_bun_bundle2(), bun_bundle_exports));
539116
+ let { feature: feature3 } = await Promise.resolve().then(() => (init_bun_bundle2(), bun_bundle_exports2));
538494
539117
  if (argv[0] === "--daemon-worker") {
538495
539118
  let { runDaemonWorker: runDaemonWorker2 } = await Promise.resolve().then(() => (init_workerRegistry(), workerRegistry_exports));
538496
539119
  return await runDaemonWorker2(argv[1]), !0;