@sema-agent/cli 1.0.82 → 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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sema-agent/cli",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sema-agent/cli",
9
- "version": "1.0.82",
9
+ "version": "1.0.83",
10
10
  "license": "BUSL-1.1",
11
11
  "dependencies": {
12
12
  "@sema-agent/sdk": "7.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/cli",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "description": "Sema — your own Claude Code-grade coding agent, in the terminal.",
5
5
  "license": "BUSL-1.1",
6
6
  "bin": {
package/sema-main.js CHANGED
@@ -55612,6 +55612,9 @@ var CONTEXT_LINES, DIFF_TIMEOUT_MS, AMPERSAND_TOKEN, DOLLAR_TOKEN, init_patch =
55612
55612
  });
55613
55613
 
55614
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
+ }
55615
55618
  function isConfigRefusalCode(code2) {
55616
55619
  return typeof code2 == "string" && code2.startsWith("config.");
55617
55620
  }
@@ -55624,9 +55627,10 @@ function isRewindFamilyCode(code2) {
55624
55627
  function asModelFallbackReason(v2) {
55625
55628
  return v2 === MODEL_FALLBACK_INHERIT_NO_TIER_BINDING ? MODEL_FALLBACK_INHERIT_NO_TIER_BINDING : void 0;
55626
55629
  }
55627
- 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({
55628
55631
  "node_modules/@sema-agent/client-core/dist/engineErrorCodes.js"() {
55629
- 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([
55630
55634
  CONFIG_LIMIT_INVALID,
55631
55635
  CONFIG_STRATEGY_FIND_LIMIT_INVALID,
55632
55636
  CONFIG_STRATEGY_MAX_SIZE_INVALID,
@@ -59856,6 +59860,13 @@ function classifyActiveRunBusy(input) {
59856
59860
  let handle2 = typeof input.activeTaskId == "string" && input.activeTaskId.length > 0 ? input.activeTaskId : null;
59857
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 };
59858
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
+ }
59859
59870
  function sanitizeFrameType(type) {
59860
59871
  let flattened = type.replace(/[\u0000-\u001f\u007f-\u009f]/g, "\uFFFD");
59861
59872
  return flattened.length > DROPPED_TYPE_DISPLAY_CAP ? `${flattened.slice(0, DROPPED_TYPE_DISPLAY_CAP)}\u2026` : flattened;
@@ -59949,7 +59960,14 @@ async function* runStreamInner(events3, ctx, handle2 = {}) {
59949
59960
  errorCode: ev.type === "failed" ? ev.errorCode : failedResult?.errorCode,
59950
59961
  activeTaskId
59951
59962
  }), maxTokHint = /max_tokens/i.test(errText3) ? `
59952
- 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}`;
59953
59971
  yield {
59954
59972
  session_id: ctx.sessionId ?? "",
59955
59973
  uuid: `err-${Date.now().toString(36)}`,
@@ -59979,7 +59997,7 @@ your provider caps max_tokens lower \u2014 lower it in /model (press m, or M to
59979
59997
  projection.kind === "dropped" && reportDroppedFrame(projection.why, projection.type, ctx);
59980
59998
  }
59981
59999
  }
59982
- 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({
59983
60001
  "node_modules/@sema-agent/client-core/dist/adapter/runStream.js"() {
59984
60002
  init_types4();
59985
60003
  init_eventToSdkMessage();
@@ -59987,6 +60005,7 @@ var MAIN2, reportedDroppedTypes, DROPPED_TYPE_MEMO_CAP, DROPPED_TYPE_DISPLAY_CAP
59987
60005
  init_subagentContentStore();
59988
60006
  init_engineErrorCodes();
59989
60007
  MAIN2 = { lane: "main" };
60008
+ RUN_STOPPED_MESSAGE_PREFIX = "Run stopped", RUN_BLOCKED_MESSAGE_PREFIX = "Run blocked";
59990
60009
  reportedDroppedTypes = /* @__PURE__ */ new Set(), DROPPED_TYPE_MEMO_CAP = 64, DROPPED_TYPE_DISPLAY_CAP = 60;
59991
60010
  inFlightTurns = 0;
59992
60011
  }
@@ -60013,6 +60032,21 @@ function askParkForeignGateKind(row2) {
60013
60032
  let kind = typeof row2.gateKind == "string" && row2.gateKind.length > 0 ? row2.gateKind : null;
60014
60033
  return kind !== null && !ASK_PARK_GATE_KINDS.includes(kind) ? kind : null;
60015
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
+ }
60016
60050
  function sessionOpts(deps2) {
60017
60051
  let sessionId = deps2?.sessionId;
60018
60052
  return typeof sessionId == "string" && sessionId.length > 0 ? { session: sessionId } : {};
@@ -60236,10 +60270,12 @@ function decidePathClause(signal) {
60236
60270
  function governanceOriginClause(signal) {
60237
60271
  return signal?.pendingGate?.governanceForced === !0 ? " That gate is enforced by this deployment's governance policy, not by a permission rule you set." : "";
60238
60272
  }
60239
- function activeRunSelfHealRow(outcome, signal, copy2) {
60273
+ function activeRunSelfHealRow(outcome, signal, copy2, origin2) {
60240
60274
  let override = copy2?.rowFor?.(outcome, signal);
60241
60275
  if (typeof override == "string")
60242
60276
  return override;
60277
+ if (origin2 === "injected")
60278
+ return injectedSubmissionRow(outcome);
60243
60279
  let base = activeRunSelfHealBaseRow(outcome, signal, copy2?.wayOut ?? DEFAULT_WAY_OUT);
60244
60280
  switch (outcome.kind) {
60245
60281
  // 这两条是「用户此刻卡住了、而且没有别的把手」的结局 —— wire 给的 decide 入口在这里才有用。
@@ -60252,6 +60288,19 @@ function activeRunSelfHealRow(outcome, signal, copy2) {
60252
60288
  return base + governanceOriginClause(signal);
60253
60289
  }
60254
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
+ }
60255
60304
  function activeRunSelfHealBaseRow(outcome, signal, wayOut) {
60256
60305
  switch (outcome.kind) {
60257
60306
  case "decision-pending":
@@ -68200,6 +68249,7 @@ __export(dist_exports, {
68200
68249
  IDLE_FLUSH_MS: () => IDLE_FLUSH_MS,
68201
68250
  INTERACTIVE_WAY_OUT: () => INTERACTIVE_WAY_OUT,
68202
68251
  INTERNAL_SDK_ARM_TYPES: () => INTERNAL_SDK_ARM_TYPES,
68252
+ LIMITS_ERROR_CODE_PREFIX: () => LIMITS_ERROR_CODE_PREFIX,
68203
68253
  LIMITS_MAX_COST_EXCEEDED: () => LIMITS_MAX_COST_EXCEEDED,
68204
68254
  LIMITS_MAX_TOKENS_EXCEEDED: () => LIMITS_MAX_TOKENS_EXCEEDED,
68205
68255
  LIMITS_MAX_TURNS_EXCEEDED: () => LIMITS_MAX_TURNS_EXCEEDED,
@@ -68257,6 +68307,8 @@ __export(dist_exports, {
68257
68307
  RETAIN_BACKGROUND_ENV: () => RETAIN_BACKGROUND_ENV,
68258
68308
  REWIND_ERROR_CODE_PREFIXES: () => REWIND_ERROR_CODE_PREFIXES,
68259
68309
  RUNNING_STATES: () => RUNNING_STATES,
68310
+ RUN_BLOCKED_MESSAGE_PREFIX: () => RUN_BLOCKED_MESSAGE_PREFIX,
68311
+ RUN_STOPPED_MESSAGE_PREFIX: () => RUN_STOPPED_MESSAGE_PREFIX,
68260
68312
  SANDBOX_CASCADE_CONFLICT_400_ANCHOR: () => SANDBOX_CASCADE_CONFLICT_400_ANCHOR,
68261
68313
  SANDBOX_K8S_ONLY_400_ANCHOR: () => SANDBOX_K8S_ONLY_400_ANCHOR,
68262
68314
  SANDBOX_NO_IMAGE_INDEX_400_ANCHOR: () => SANDBOX_NO_IMAGE_INDEX_400_ANCHOR,
@@ -68573,10 +68625,13 @@ __export(dist_exports, {
68573
68625
  isFromSubagent: () => isFromSubagent,
68574
68626
  isFsApprovalGate: () => isFsApprovalGate,
68575
68627
  isGoalStopHookWireArmed: () => isGoalStopHookWireArmed,
68628
+ isGovernanceStopRowText: () => isGovernanceStopRowText,
68629
+ isGovernanceTerminal: () => isGovernanceTerminal,
68576
68630
  isHitlSafetyErrorLike: () => isHitlSafetyErrorLike,
68577
68631
  isHookNoticeFrame: () => isHookNoticeFrame,
68578
68632
  isInterruptedToolEndCode: () => isInterruptedToolEndCode,
68579
68633
  isKnownWorkflowAgentTaskId: () => isKnownWorkflowAgentTaskId,
68634
+ isLimitsExceededCode: () => isLimitsExceededCode,
68580
68635
  isLocalSessionEvent: () => isLocalSessionEvent,
68581
68636
  isLocalSessionRecord: () => isLocalSessionRecord,
68582
68637
  isLoopbackWireUrl: () => isLoopbackWireUrl,
@@ -68780,6 +68835,7 @@ __export(dist_exports, {
68780
68835
  scenarioForPrint: () => scenarioForPrint,
68781
68836
  scratchpadDirField: () => scratchpadDirField,
68782
68837
  searchPresetTableViolations: () => searchPresetTableViolations,
68838
+ selfHealSubmissionDisposition: () => selfHealSubmissionDisposition,
68783
68839
  selfOrchestrationFromEnv: () => selfOrchestrationFromEnv,
68784
68840
  setLiveModelCatalog: () => setLiveModelCatalog,
68785
68841
  setLiveModelCatalogRefresher: () => setLiveModelCatalogRefresher,
@@ -109779,7 +109835,7 @@ var import_stack_utils, import_jsx_runtime6, cleanupPath, stackUtils, init_Error
109779
109835
  // build-src/src/ink/components/TerminalSizeContext.tsx
109780
109836
  var import_react9, TerminalSizeContext, init_TerminalSizeContext = __esm({
109781
109837
  "build-src/src/ink/components/TerminalSizeContext.tsx"() {
109782
- import_react9 = __toESM(require_react()), TerminalSizeContext = (0, import_react9.createContext)(null);
109838
+ import_react9 = __toESM(require_react(), 1), TerminalSizeContext = (0, import_react9.createContext)(null);
109783
109839
  }
109784
109840
  });
109785
109841
 
@@ -117249,6 +117305,18 @@ ${ctx}` : line;
117249
117305
  }
117250
117306
  return "Execution error";
117251
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
+ }
117252
117320
  var init_textModeError = __esm({
117253
117321
  "build-src/src/cli/textModeError.ts"() {
117254
117322
  }
@@ -177538,6 +177606,7 @@ __export(leaderPermissionBridge_exports, {
177538
177606
  registerLeaderSetToolPermissionContext: () => registerLeaderSetToolPermissionContext,
177539
177607
  registerLeaderToolUseConfirmQueue: () => registerLeaderToolUseConfirmQueue,
177540
177608
  setLeaderPendingDecisionCardCount: () => setLeaderPendingDecisionCardCount,
177609
+ subscribeToLeaderPendingDecisionCards: () => subscribeToLeaderPendingDecisionCards,
177541
177610
  unregisterLeaderSetToolPermissionContext: () => unregisterLeaderSetToolPermissionContext,
177542
177611
  unregisterLeaderToolUseConfirmQueue: () => unregisterLeaderToolUseConfirmQueue
177543
177612
  });
@@ -177551,7 +177620,8 @@ function unregisterLeaderToolUseConfirmQueue() {
177551
177620
  registeredSetter = null;
177552
177621
  }
177553
177622
  function setLeaderPendingDecisionCardCount(count3) {
177554
- 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());
177555
177625
  }
177556
177626
  function leaderHasPendingDecisionCard() {
177557
177627
  return pendingDecisionCardCount > 0;
@@ -177568,10 +177638,11 @@ function getLeaderSetToolPermissionContext() {
177568
177638
  function unregisterLeaderSetToolPermissionContext() {
177569
177639
  registeredPermissionContextSetter = null;
177570
177640
  }
177571
- var registeredSetter, registeredPermissionContextSetter, pendingDecisionCardCount, init_leaderPermissionBridge = __esm({
177641
+ var registeredSetter, registeredPermissionContextSetter, pendingDecisionCardCount, pendingDecisionCardsChanged, subscribeToLeaderPendingDecisionCards, init_leaderPermissionBridge = __esm({
177572
177642
  "build-src/src/utils/swarm/leaderPermissionBridge.ts"() {
177643
+ init_signal();
177573
177644
  registeredSetter = null, registeredPermissionContextSetter = null;
177574
- pendingDecisionCardCount = 0;
177645
+ pendingDecisionCardCount = 0, pendingDecisionCardsChanged = createSignal(), subscribeToLeaderPendingDecisionCards = pendingDecisionCardsChanged.subscribe;
177575
177646
  }
177576
177647
  });
177577
177648
 
@@ -178114,11 +178185,29 @@ function enqueue(command8) {
178114
178185
  );
178115
178186
  }
178116
178187
  function enqueuePendingNotification(command8) {
178117
- commandQueue.push({ ...command8, priority: command8.priority ?? "later" }), notifySubscribers(), logOperation(
178188
+ commandQueue.push({ ...command8, priority: command8.priority ?? "later", isMeta: command8.isMeta ?? !0 }), notifySubscribers(), logOperation(
178118
178189
  "enqueue",
178119
178190
  typeof command8.value == "string" ? command8.value : void 0
178120
178191
  );
178121
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
+ }
178122
178211
  function dequeue(filter2) {
178123
178212
  if (commandQueue.length === 0)
178124
178213
  return;
@@ -178230,7 +178319,7 @@ function getCommandsByMaxPriority(maxPriority) {
178230
178319
  (cmd) => PRIORITY_ORDER[cmd.priority ?? "next"] <= threshold2
178231
178320
  );
178232
178321
  }
178233
- 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({
178234
178323
  "build-src/src/utils/messageQueueManager.ts"() {
178235
178324
  init_state();
178236
178325
  init_messages4();
@@ -178239,6 +178328,8 @@ var commandQueue, snapshot2, queueChanged, subscribeToCommandQueue, PRIORITY_ORD
178239
178328
  init_signal();
178240
178329
  commandQueue = [], snapshot2 = Object.freeze([]), queueChanged = createSignal();
178241
178330
  subscribeToCommandQueue = queueChanged.subscribe;
178331
+ MAX_INJECTION_REQUEUES = 3;
178332
+ MAX_INJECTION_DEFERRALS = 2;
178242
178333
  PRIORITY_ORDER = {
178243
178334
  now: 0,
178244
178335
  next: 1,
@@ -181974,6 +182065,29 @@ var status, listeners7, fadeTimer, init_engineRuntimeStatus = __esm({
181974
182065
  }
181975
182066
  });
181976
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
+
181977
182091
  // build-src/src/sema/engineAttachCapabilityGate.ts
181978
182092
  var engineAttachCapabilityGate_exports = {};
181979
182093
  __export(engineAttachCapabilityGate_exports, {
@@ -185374,8 +185488,8 @@ Fix: run \`sema doctor\` to diagnose, or restart sema to retry.`
185374
185488
  // —— 一条中止口的在场与否不该取决于「这一轮有没有铸卡」。顶层形是它的严格超集,
185375
185489
  // 车B 的消费面(deps.signal)逐字不变。
185376
185490
  ...signal ? { signal } : {}
185377
- });
185378
- 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) {
185379
185493
  retryStream = !0;
185380
185494
  continue;
185381
185495
  }
@@ -185653,6 +185767,7 @@ var BG_TEAR_MAX_RESENDS, BG_RECOVERY_WAIT_MS, DRAINING_MAX_RETRIES, drainingBack
185653
185767
  init_log2();
185654
185768
  init_engineRuntimeStatus();
185655
185769
  init_activeRunSelfHeal2();
185770
+ init_injectionRequeueLatch();
185656
185771
  BG_TEAR_MAX_RESENDS = 2, BG_RECOVERY_WAIT_MS = 12e4, DRAINING_MAX_RETRIES = 3;
185657
185772
  client = makeMockClient(), clientExplicitlySet = !1;
185658
185773
  seamRewindCapture = !0;
@@ -269554,17 +269669,18 @@ var FINGERPRINT_SALT, init_fingerprint = __esm({
269554
269669
 
269555
269670
  // build-src/src/sema/livePrincipal.ts
269556
269671
  function resolveLivePrincipal() {
269557
- return normalizeWirePrincipal(process.env.SEMA_LIVE_PRINCIPAL);
269672
+ return normalizeWirePrincipal(process.env.SEMA_LIVE_PRINCIPAL) ?? SINGLE_TENANT_DEFAULT;
269558
269673
  }
269559
269674
  function resolveFleetPrincipal() {
269560
269675
  return normalizeWirePrincipal(process.env.SEMA_FLEET_PRINCIPAL) ?? resolveLivePrincipal();
269561
269676
  }
269562
269677
  function describeLivePrincipal() {
269563
- return resolveLivePrincipal() ?? "absent(owner-null)";
269678
+ return resolveLivePrincipal();
269564
269679
  }
269565
- var init_livePrincipal = __esm({
269680
+ var SINGLE_TENANT_DEFAULT, init_livePrincipal = __esm({
269566
269681
  "build-src/src/sema/livePrincipal.ts"() {
269567
269682
  init_dist();
269683
+ SINGLE_TENANT_DEFAULT = "default";
269568
269684
  }
269569
269685
  });
269570
269686
 
@@ -287008,7 +287124,7 @@ function FileEditToolUseRejectedMessage(t0) {
287008
287124
  }
287009
287125
  var import_compiler_runtime43, import_jsx_runtime52, MAX_LINES_TO_RENDER, init_FileEditToolUseRejectedMessage = __esm({
287010
287126
  "build-src/src/components/FileEditToolUseRejectedMessage.tsx"() {
287011
- import_compiler_runtime43 = __toESM(require_compiler_runtime(), 1);
287127
+ import_compiler_runtime43 = __toESM(require_compiler_runtime());
287012
287128
  init_useTerminalSize();
287013
287129
  init_cwd();
287014
287130
  init_ink2();
@@ -287016,7 +287132,7 @@ var import_compiler_runtime43, import_jsx_runtime52, MAX_LINES_TO_RENDER, init_F
287016
287132
  init_MessageResponse();
287017
287133
  init_StructuredDiffList();
287018
287134
  init_stringUtils();
287019
- import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1), MAX_LINES_TO_RENDER = 10;
287135
+ import_jsx_runtime52 = __toESM(require_jsx_runtime()), MAX_LINES_TO_RENDER = 10;
287020
287136
  }
287021
287137
  });
287022
287138
 
@@ -295537,6 +295653,10 @@ var init_systemPromptType = __esm({
295537
295653
  });
295538
295654
 
295539
295655
  // build-src/src/stubs/bun-bundle.js
295656
+ var bun_bundle_exports = {};
295657
+ __export(bun_bundle_exports, {
295658
+ feature: () => feature
295659
+ });
295540
295660
  function feature(flag) {
295541
295661
  return ON.has(flag);
295542
295662
  }
@@ -300312,7 +300432,7 @@ async function compactConversation(messages, context3, cacheSafeParams, suppress
300312
300432
  };
300313
300433
  }
300314
300434
  if (summary) {
300315
- if (startsWithApiErrorPrefix(summary))
300435
+ if (startsWithApiErrorPrefix(summary) || isGovernanceStopRowText(summary))
300316
300436
  throw new Error(summary);
300317
300437
  } else throw logForDebugging(
300318
300438
  `Compact failed: no summary text in response. Response: ${jsonStringify(summaryResponse)}`,
@@ -300496,7 +300616,7 @@ User context: ${userFeedback}` : hookResult.newCustomInstructions ? customInstru
300496
300616
  };
300497
300617
  }
300498
300618
  if (summary) {
300499
- if (startsWithApiErrorPrefix(summary))
300619
+ if (startsWithApiErrorPrefix(summary) || isGovernanceStopRowText(summary))
300500
300620
  throw {
300501
300621
  ...failureMetadata
300502
300622
  }, new Error(summary);
@@ -300922,6 +301042,7 @@ var POST_COMPACT_MAX_FILES_TO_RESTORE, POST_COMPACT_TOKEN_BUDGET, POST_COMPACT_M
300922
301042
  init_analytics_index();
300923
301043
  init_claude();
300924
301044
  init_errors7();
301045
+ init_dist();
300925
301046
  init_promptCacheBreakDetection();
300926
301047
  init_withRetry();
300927
301048
  init_internalLogging();
@@ -301414,9 +301535,9 @@ function streamingTailWrap(unstableSuffix) {
301414
301535
  }
301415
301536
  var import_compiler_runtime53, import_react48, import_jsx_runtime65, TOKEN_CACHE_MAX, tokenCache, MD_SYNTAX_RE, init_Markdown = __esm({
301416
301537
  "build-src/src/components/Markdown.tsx"() {
301417
- import_compiler_runtime53 = __toESM(require_compiler_runtime(), 1);
301538
+ import_compiler_runtime53 = __toESM(require_compiler_runtime());
301418
301539
  init_marked_esm();
301419
- import_react48 = __toESM(require_react(), 1);
301540
+ import_react48 = __toESM(require_react());
301420
301541
  init_useSettings();
301421
301542
  init_ink2();
301422
301543
  init_cliHighlight();
@@ -301424,7 +301545,7 @@ var import_compiler_runtime53, import_react48, import_jsx_runtime65, TOKEN_CACHE
301424
301545
  init_markdown();
301425
301546
  init_messages4();
301426
301547
  init_MarkdownTable();
301427
- import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1), TOKEN_CACHE_MAX = 500, tokenCache = /* @__PURE__ */ new Map(), MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
301548
+ import_jsx_runtime65 = __toESM(require_jsx_runtime()), TOKEN_CACHE_MAX = 500, tokenCache = /* @__PURE__ */ new Map(), MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
301428
301549
  }
301429
301550
  });
301430
301551
 
@@ -305952,14 +306073,12 @@ var EN_MESSAGES, init_messages_en = __esm({
305952
306073
  "onboard.station.mcp": "MCP servers",
305953
306074
  "onboard.station.skills": "Skills",
305954
306075
  "onboard.station.plugins": "Plugins",
305955
- "onboard.station.rules": "Permission rules",
305956
306076
  // ── onboard: per-station "you can change this anytime" blurbs ─────────────────────────────
305957
306077
  "onboard.blurb.model": "Add the model(s) sema should use \u2014 you can change this anytime with `sema config model`.",
305958
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`.",
305959
306079
  "onboard.blurb.mcp": "Import MCP servers \u2014 you can change this anytime with `sema config mcp`.",
305960
306080
  "onboard.blurb.skills": "Import skills \u2014 you can change this anytime with `sema config skills`.",
305961
306081
  "onboard.blurb.plugins": "Install plugins \u2014 you can change this anytime with `sema config plugins`.",
305962
- "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`.",
305963
306082
  // ── onboard: the theme station's own copy (the first thing a first-run user reads) ─────────
305964
306083
  "onboard.welcome.title": "\u273B Welcome to Sema",
305965
306084
  "onboard.welcome.tagline": "One shell, your whole fleet \u2014 local engine autostart, multi-agent orchestration, cloud when you want it.",
@@ -306068,14 +306187,12 @@ var ZH_MESSAGES, init_messages_zh = __esm({
306068
306187
  "onboard.station.mcp": "MCP \u670D\u52A1\u5668",
306069
306188
  "onboard.station.skills": "\u6280\u80FD",
306070
306189
  "onboard.station.plugins": "\u63D2\u4EF6",
306071
- "onboard.station.rules": "\u6743\u9650\u89C4\u5219",
306072
306190
  // ── onboard:各站「随时可改」说明行 ──────────────────────────────────────────────────────
306073
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",
306074
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",
306075
306193
  "onboard.blurb.mcp": "\u5BFC\u5165 MCP \u670D\u52A1\u5668 \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config mcp` \u4FEE\u6539\u3002",
306076
306194
  "onboard.blurb.skills": "\u5BFC\u5165\u6280\u80FD \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config skills` \u4FEE\u6539\u3002",
306077
306195
  "onboard.blurb.plugins": "\u5B89\u88C5\u63D2\u4EF6 \u2014\u2014 \u4E4B\u540E\u968F\u65F6\u53EF\u7528 `sema config plugins` \u4FEE\u6539\u3002",
306078
- "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",
306079
306196
  // ── onboard:主题站文案 ─────────────────────────────────────────────────────────────────
306080
306197
  "onboard.welcome.title": "\u273B \u6B22\u8FCE\u4F7F\u7528 Sema",
306081
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",
@@ -318015,7 +318132,7 @@ function AssistantTextMessage(t0) {
318015
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;
318016
318133
  }
318017
318134
  default: {
318018
- if (startsWithApiErrorPrefix(text2)) {
318135
+ if (startsWithApiErrorPrefix(text2) || isGovernanceStopRowText(text2)) {
318019
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;
318020
318137
  if ($3[15] !== t22) {
318021
318138
  let apiErrSplit = splitApiErrorSupplement(t22);
@@ -372708,6 +372825,7 @@ var classifierDecisionModule, autoModeStateModule4, CLASSIFIER_FAIL_CLOSED_REFRE
372708
372825
  // build-src/src/utils/permissions/permissionSetup.ts
372709
372826
  var permissionSetup_exports = {};
372710
372827
  __export(permissionSetup_exports, {
372828
+ __resetFactoryDefaultAutoForTests: () => __resetFactoryDefaultAutoForTests,
372711
372829
  checkAndDisableBypassPermissions: () => checkAndDisableBypassPermissions,
372712
372830
  createDisabledBypassPermissionsContext: () => createDisabledBypassPermissionsContext,
372713
372831
  findDangerousClassifierPermissions: () => findDangerousClassifierPermissions,
@@ -372726,8 +372844,10 @@ __export(permissionSetup_exports, {
372726
372844
  isDangerousPowerShellPermission: () => isDangerousPowerShellPermission,
372727
372845
  isDangerousTaskPermission: () => isDangerousTaskPermission,
372728
372846
  isDefaultPermissionModeAuto: () => isDefaultPermissionModeAuto,
372847
+ isFactoryDefaultAutoActive: () => isFactoryDefaultAutoActive,
372729
372848
  isOverlyBroadBashAllowRule: () => isOverlyBroadBashAllowRule,
372730
372849
  isOverlyBroadPowerShellAllowRule: () => isOverlyBroadPowerShellAllowRule,
372850
+ markFactoryDefaultAutoActive: () => markFactoryDefaultAutoActive,
372731
372851
  parseBaseToolsFromCLI: () => parseBaseToolsFromCLI,
372732
372852
  parseToolListFromCLI: () => parseToolListFromCLI,
372733
372853
  prepareContextForPlanMode: () => prepareContextForPlanMode,
@@ -372986,7 +373106,7 @@ function transitionPermissionMode(fromMode, toMode, context3) {
372986
373106
  if (!isAutoModeGateEnabled())
372987
373107
  throw new Error("Cannot transition to auto mode: gate is not enabled");
372988
373108
  autoModeStateModule5?.setAutoModeActive(!0), context3 = stripDangerousPermissionsForAutoMode(context3);
372989
- } 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));
372990
373110
  }
372991
373111
  return fromMode === "plan" && toMode !== "plan" && context3.prePlanMode ? { ...context3, prePlanMode: void 0 } : context3;
372992
373112
  }
@@ -373007,9 +373127,19 @@ function settingsDisableBypassFailClosed() {
373007
373127
  () => filterManagedPolicyErrors(getSettingsWithErrors().errors)
373008
373128
  ).disable;
373009
373129
  }
373130
+ function isFactoryDefaultAutoActive() {
373131
+ return factoryDefaultAutoActive;
373132
+ }
373133
+ function __resetFactoryDefaultAutoForTests() {
373134
+ factoryDefaultAutoActive = !1;
373135
+ }
373136
+ function markFactoryDefaultAutoActive() {
373137
+ factoryDefaultAutoActive = !0;
373138
+ }
373010
373139
  function initialPermissionModeFromCLI({
373011
373140
  permissionModeCli,
373012
- dangerouslySkipPermissions
373141
+ dangerouslySkipPermissions,
373142
+ factoryDefaultAutoEligible
373013
373143
  }) {
373014
373144
  let settings2 = getSettings_DEPRECATED() || {}, growthBookDisableBypassPermissionsMode = checkStatsigFeatureGate_CACHED_MAY_BE_STALE(
373015
373145
  "tengu_disable_bypass_permissions_mode"
@@ -373031,6 +373161,7 @@ function initialPermissionModeFromCLI({
373031
373161
  { level: "warn" }
373032
373162
  ) : orderedModes.push("auto") : orderedModes.push(settingsMode);
373033
373163
  }
373164
+ factoryDefaultAutoEligible && orderedModes.length === 0 && !autoModeCircuitBrokenSync && !isAutoModeDisabledBySettings() && (orderedModes.push("auto"), factoryDefaultAutoActive = !0);
373034
373165
  let result;
373035
373166
  for (let mode of orderedModes) {
373036
373167
  if (mode === "bypassPermissions" && disableBypassPermissionsMode) {
@@ -373261,7 +373392,7 @@ function isDefaultPermissionModeAuto() {
373261
373392
  return (getSettings_DEPRECATED() || {}).permissions?.defaultMode === "auto";
373262
373393
  }
373263
373394
  function shouldPlanUseAutoMode() {
373264
- return hasAutoModeOptIn() && isAutoModeGateEnabled() && getUseAutoModeDuringPlan();
373395
+ return (hasAutoModeOptIn() || isFactoryDefaultAutoActive()) && isAutoModeGateEnabled() && getUseAutoModeDuringPlan();
373265
373396
  }
373266
373397
  function prepareContextForPlanMode(context3) {
373267
373398
  let currentMode = context3.mode;
@@ -373290,7 +373421,7 @@ function transitionPlanAutoMode(context3) {
373290
373421
  let want = shouldPlanUseAutoMode(), have = autoModeStateModule5?.isAutoModeActive() ?? !1;
373291
373422
  return want && have ? stripDangerousPermissionsForAutoMode(context3) : !want && !have ? context3 : want ? (autoModeStateModule5?.setAutoModeActive(!0), setNeedsAutoModeExitAttachment(!1), stripDangerousPermissionsForAutoMode(context3)) : (autoModeStateModule5?.setAutoModeActive(!1), setNeedsAutoModeExitAttachment(!0), restoreDangerousPermissions(context3));
373292
373423
  }
373293
- 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({
373294
373425
  "build-src/src/utils/permissions/permissionSetup.ts"() {
373295
373426
  init_state();
373296
373427
  init_cwd();
@@ -373317,6 +373448,7 @@ var autoModeStateModule5, AUTO_MODE_ENABLED_DEFAULT, NO_CACHED_AUTO_MODE_CONFIG,
373317
373448
  init_PermissionUpdate();
373318
373449
  init_permissionRuleParser();
373319
373450
  autoModeStateModule5 = (init_autoModeState(), __toCommonJS(autoModeState_exports));
373451
+ factoryDefaultAutoActive = !1;
373320
373452
  AUTO_MODE_ENABLED_DEFAULT = "disabled";
373321
373453
  NO_CACHED_AUTO_MODE_CONFIG = /* @__PURE__ */ Symbol("no-cached-auto-mode-config");
373322
373454
  }
@@ -401398,8 +401530,8 @@ var sema_brand_default, init_sema_brand = __esm({
401398
401530
  "Engine 7.28.0 (from 7.26.0)"
401399
401531
  ]
401400
401532
  },
401401
- productVersion: "1.0.82",
401402
- announcement: "sema 1.0.82 \u2014 Claude Code permission rules are now imported automatically on first launch when detected, with a one-line notice and full visibility in /permissions afterward (no confirmation step, no silent surprises). Under the hood: the agent-teams gate was hardened against config-source bypass, and a queue-processing edge case around injected background prompts was tightened."
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."
401403
401535
  };
401404
401536
  }
401405
401537
  });
@@ -405608,8 +405740,8 @@ var require_sema_brand = __commonJS({
405608
405740
  "Engine 7.28.0 (from 7.26.0)"
405609
405741
  ]
405610
405742
  },
405611
- productVersion: "1.0.82",
405612
- announcement: "sema 1.0.82 \u2014 Claude Code permission rules are now imported automatically on first launch when detected, with a one-line notice and full visibility in /permissions afterward (no confirmation step, no silent surprises). Under the hood: the agent-teams gate was hardened against config-source bypass, and a queue-processing edge case around injected background prompts was tightened."
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."
405613
405745
  };
405614
405746
  }
405615
405747
  });
@@ -414187,8 +414319,8 @@ var init_ccRulesImport = __esm({
414187
414319
  import { existsSync as existsSync25, readFileSync as readFileSync35, writeFileSync as writeFileSync19, mkdirSync as mkdirSync20 } from "node:fs";
414188
414320
  import { join as join157, dirname as dirname73 } from "node:path";
414189
414321
  import { homedir as homedir42 } from "node:os";
414190
- function ruleStoreWireAvailable() {
414191
- return persistedRulesLaneAvailable2();
414322
+ function ruleStoreWireAvailable(baseUrl) {
414323
+ return persistedRulesLaneAvailable2(baseUrl);
414192
414324
  }
414193
414325
  function markerPath() {
414194
414326
  return join157(getClaudeConfigHomeDir(), "cc-import.json");
@@ -414215,9 +414347,6 @@ function writeCcImportMarker(marker) {
414215
414347
  mkdirSync20(dirname73(p), { recursive: !0 }), writeFileSync19(p, JSON.stringify(marker, null, 2) + `
414216
414348
  `, "utf8");
414217
414349
  }
414218
- function writeCcImportDeclinedMarker() {
414219
- writeCcImportMarker({ importedAt: (/* @__PURE__ */ new Date()).toISOString(), sourcePath: "", importedCount: 0, declined: !0 });
414220
- }
414221
414350
  function detectCcAllowRulesSource() {
414222
414351
  let ccEnvKey = "CLAUDE_CONFIG_DIR", ccLegacyDir = join157(homedir42(), ".claude"), roots = [process.env[ccEnvKey], ccLegacyDir].filter(
414223
414352
  (r) => typeof r == "string" && r.length > 0
@@ -414237,8 +414366,8 @@ function detectCcAllowRulesSource() {
414237
414366
  }
414238
414367
  return null;
414239
414368
  }
414240
- function ccImportBootGate() {
414241
- return !ruleStoreWireAvailable() || readCcImportMarker() !== null ? null : detectCcAllowRulesSource();
414369
+ function ccImportBootGate(baseUrl) {
414370
+ return !ruleStoreWireAvailable(baseUrl) || readCcImportMarker() !== null ? null : detectCcAllowRulesSource();
414242
414371
  }
414243
414372
  var init_ccImportMarker = __esm({
414244
414373
  "build-src/src/sema/rules/ccImportMarker.ts"() {
@@ -433956,6 +434085,7 @@ function noteModelEvidenceFrom(msg) {
433956
434085
  b3.text.includes(model) && noteModelRejected(model, "rejected by the provider");
433957
434086
  continue;
433958
434087
  }
434088
+ if (isGovernanceStopRowText(b3.text)) continue;
433959
434089
  b3.text.length > 0 && noteModelServed(model);
433960
434090
  continue;
433961
434091
  }
@@ -455490,8 +455620,8 @@ function policyFromPermissions(perms) {
455490
455620
  return policy2;
455491
455621
  }
455492
455622
  function deriveMode(eff, opts) {
455493
- let launch = opts?.launchMode, fileMode = eff.permissionMode, mode = launch ?? fileMode ?? "default";
455494
- 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" };
455495
455625
  }
455496
455626
  function modeToolPolicy(mode, basePolicy) {
455497
455627
  switch (mode) {
@@ -455518,7 +455648,7 @@ function modeToolPolicy(mode, basePolicy) {
455518
455648
  }
455519
455649
  }
455520
455650
  function toEffectiveConfig(eff, opts) {
455521
- 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(
455522
455652
  derivedMode,
455523
455653
  basePolicy
455524
455654
  ), taskSpecOverrides = { toolPolicy };
@@ -455530,6 +455660,7 @@ function toEffectiveConfig(eff, opts) {
455530
455660
  model: eff.model,
455531
455661
  outputStyle: eff.outputStyle,
455532
455662
  derivedMode,
455663
+ ...isFactoryDefault ? { derivedModeIsFactoryDefault: !0 } : {},
455533
455664
  provenance: eff.provenance
455534
455665
  };
455535
455666
  }
@@ -462977,6 +463108,7 @@ var ccImportBootRun_exports = {};
462977
463108
  __export(ccImportBootRun_exports, {
462978
463109
  __resetCcImportBootLatchForTests: () => __resetCcImportBootLatchForTests,
462979
463110
  __resetCcImportBootPendingNoticeForTests: () => __resetCcImportBootPendingNoticeForTests,
463111
+ __setCcImportCapsWaitCapForTests: () => __setCcImportCapsWaitCapForTests,
462980
463112
  drainPendingCcImportBootNotice: () => drainPendingCcImportBootNotice,
462981
463113
  runCcImportBootAuto: () => runCcImportBootAuto,
462982
463114
  runCcImportBootAutoWith: () => runCcImportBootAutoWith
@@ -462993,7 +463125,7 @@ async function runCcImportBootAutoWith(deps2) {
462993
463125
  return deps2.writeMarker({ importedAt: (/* @__PURE__ */ new Date()).toISOString(), sourcePath, importedCount: 0 }), "nothing-to-import";
462994
463126
  let red = await redeemCcRuleImport(facade, prep.prepared.ticket);
462995
463127
  if (!red.ok) return "redeem-failed";
462996
- let persisted = Array.isArray(red.redeemed?.persisted) ? red.redeemed.persisted.length : 0, deduped = Array.isArray(red.redeemed?.deduped) ? red.redeemed.deduped.length : 0;
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;
462997
463129
  if (deps2.writeMarker({ importedAt: (/* @__PURE__ */ new Date()).toISOString(), sourcePath, importedCount: persisted }), persisted > 0) {
462998
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`;
462999
463131
  deps2.notice(text2) || (pendingNotice = text2);
@@ -463013,22 +463145,43 @@ function drainPendingCcImportBootNotice() {
463013
463145
  function __resetCcImportBootPendingNoticeForTests() {
463014
463146
  pendingNotice = null;
463015
463147
  }
463016
- function runCcImportBootAuto() {
463017
- return attempted ? Promise.resolve("already-attempted") : (attempted = !0, runCcImportBootAutoWith({
463018
- gate: ccImportBootGate,
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),
463019
463170
  collect: collectCcUserLayerAt,
463020
463171
  facade: resolveRulesFacade,
463021
463172
  writeMarker: writeCcImportMarker,
463022
463173
  notice: surfaceTranscriptSystemNotice
463023
- }));
463174
+ });
463024
463175
  }
463025
- var attempted, pendingNotice, init_ccImportBootRun = __esm({
463176
+ var attempted, pendingNotice, CAPS_SETTLE_CAP_MS, capsWaitCapMs, init_ccImportBootRun = __esm({
463026
463177
  "build-src/src/sema/rules/ccImportBootRun.ts"() {
463178
+ init_dist();
463027
463179
  init_persistedRulesWire2();
463028
463180
  init_transcriptSystemNotice();
463029
463181
  init_ccImportMarker();
463030
463182
  attempted = !1;
463031
463183
  pendingNotice = null;
463184
+ CAPS_SETTLE_CAP_MS = 15e3, capsWaitCapMs = CAPS_SETTLE_CAP_MS;
463032
463185
  }
463033
463186
  });
463034
463187
 
@@ -491504,6 +491657,7 @@ async function executeUserInput(params) {
491504
491657
  queuedCommands
491505
491658
  } = params, abortController = createAbortController();
491506
491659
  setAbortController(abortController);
491660
+ let submissionTurnId = beginSubmissionTurn();
491507
491661
  function makeContext() {
491508
491662
  return getToolUseContext(messages, [], abortController, mainLoopModel);
491509
491663
  }
@@ -491584,6 +491738,14 @@ async function executeUserInput(params) {
491584
491738
  nextInput && (submitNextInput ? enqueue({ value: nextInput, mode: "prompt" }) : params.onInputChange(nextInput));
491585
491739
  });
491586
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
+ }
491587
491749
  queryGuard.cancelReservation(), setUserInputOnProcessing(void 0);
491588
491750
  }
491589
491751
  }
@@ -491599,7 +491761,9 @@ var init_handlePromptSubmit = __esm({
491599
491761
  init_log2();
491600
491762
  init_fileHistory();
491601
491763
  init_gracefulShutdown();
491764
+ init_injectionRequeueLatch();
491602
491765
  init_messageQueueManager();
491766
+ init_transcriptSystemNotice();
491603
491767
  init_model();
491604
491768
  init_processUserInput();
491605
491769
  init_queryProfiler();
@@ -491617,17 +491781,24 @@ function isSlashCommand(cmd) {
491617
491781
  return !1;
491618
491782
  }
491619
491783
  function processQueueIfReady({
491620
- executeInput
491784
+ executeInput,
491785
+ pendingDecisionCard = !1
491621
491786
  }) {
491622
- 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);
491623
491794
  if (!next)
491624
491795
  return { processed: !1 };
491625
491796
  if (isSlashCommand(next) || next.mode === "bash") {
491626
- let cmd = dequeue(isMainThread);
491797
+ let cmd = dequeue(drainable);
491627
491798
  return executeInput([cmd]), { processed: !0 };
491628
491799
  }
491629
491800
  let targetMode = next.mode, targetInjected = next.isMeta === !0, commands = dequeueAllMatching(
491630
- (cmd) => isMainThread(cmd) && !isSlashCommand(cmd) && cmd.mode === targetMode && cmd.isMeta === !0 === targetInjected
491801
+ (cmd) => drainable(cmd) && !isSlashCommand(cmd) && cmd.mode === targetMode && cmd.isMeta === !0 === targetInjected
491631
491802
  );
491632
491803
  return commands.length === 0 ? { processed: !1 } : (executeInput(commands), { processed: !0 });
491633
491804
  }
@@ -491649,23 +491820,37 @@ function useQueueProcessor({
491649
491820
  ), queueSnapshot = (0, import_react287.useSyncExternalStore)(
491650
491821
  subscribeToCommandQueue,
491651
491822
  getCommandQueueSnapshot
491823
+ ), pendingDecisionCards = (0, import_react287.useSyncExternalStore)(
491824
+ subscribeToLeaderPendingDecisionCards,
491825
+ leaderPendingDecisionCardCount
491652
491826
  );
491653
491827
  (0, import_react287.useEffect)(() => {
491654
491828
  process.env.SEMA_DEBUG && queueSnapshot.length > 0 && logForDebugging(
491655
- `[queue-drain] len=${queueSnapshot.length} queryActive=${isQueryActive} jsxUI=${hasActiveLocalJsxUI} modes=${queueSnapshot.map((c2) => c2.mode).join(",")}`
491656
- ), !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
+ }));
491657
491839
  }, [
491658
491840
  queueSnapshot,
491659
491841
  isQueryActive,
491660
491842
  executeQueuedInput,
491661
491843
  hasActiveLocalJsxUI,
491662
- queryGuard
491844
+ queryGuard,
491845
+ pendingDecisionCards
491663
491846
  ]);
491664
491847
  }
491665
491848
  var import_react287, init_useQueueProcessor = __esm({
491666
491849
  "build-src/src/hooks/useQueueProcessor.ts"() {
491667
491850
  import_react287 = __toESM(require_react(), 1);
491668
491851
  init_messageQueueManager();
491852
+ init_leaderPermissionBridge();
491853
+ init_activeRunRunningChoice();
491669
491854
  init_debug();
491670
491855
  init_queueProcessor();
491671
491856
  }
@@ -497196,7 +497381,7 @@ function _temp158() {
497196
497381
  }
497197
497382
  var import_compiler_runtime308, import_react313, SETTINGS_ERRORS_NOTIFICATION_KEY, init_useSettingsErrors = __esm({
497198
497383
  "build-src/src/hooks/notifs/useSettingsErrors.tsx"() {
497199
- import_compiler_runtime308 = __toESM(require_compiler_runtime()), import_react313 = __toESM(require_react());
497384
+ import_compiler_runtime308 = __toESM(require_compiler_runtime(), 1), import_react313 = __toESM(require_react(), 1);
497200
497385
  init_notifications2();
497201
497386
  init_state();
497202
497387
  init_allErrors();
@@ -514609,17 +514794,19 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
514609
514794
  // 文本形态源之一),(b) 只会渲本地 loop 语义的模板句 —— 引擎终帧(timeout→error_max_turns、
514610
514795
  // budget、output.invalid)带 errors[] 引擎原话时优先如实渲它(--deadline 的 timeout 若渲
514611
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: `),没有才落模板。
514612
514804
  case "error_max_turns":
514613
514805
  case "error_max_budget_usd":
514614
514806
  case "error_max_structured_output_retries": {
514615
- let engineErrors = lastMessage.errors;
514616
- if (Array.isArray(engineErrors) && engineErrors.length > 0) {
514617
- process.stderr.write(formatTextModeExecutionError(engineErrors, mergedModelEnv()) + `
514618
- `);
514619
- break;
514620
- }
514621
- 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";
514622
- 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 + `
514623
514810
  `);
514624
514811
  break;
514625
514812
  }
@@ -529409,20 +529596,11 @@ function stationSkipped(id) {
529409
529596
  if (id === "mcp") return detectMcpChannels().length === 0;
529410
529597
  if (id === "skills") return detectSkillChannels().length === 0;
529411
529598
  if (id === "plugins") return detectCcPlugins().plugins.length === 0;
529412
- if (id === "rules")
529413
- return readCcImportMarker() !== null ? !0 : !detectCcRulesImport().offer;
529414
529599
  } catch {
529415
529600
  return !1;
529416
529601
  }
529417
529602
  return !1;
529418
529603
  }
529419
- function rulesSkipSummary() {
529420
- try {
529421
- 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`)";
529422
- } catch {
529423
- return "skipped (manage saved rules from `/permissions`)";
529424
- }
529425
- }
529426
529604
  function finalize2(flow) {
529427
529605
  if (!flow.finalized) {
529428
529606
  flow.finalized = !0;
@@ -529442,15 +529620,10 @@ function finalize2(flow) {
529442
529620
  } catch (e) {
529443
529621
  flow.summary.push(`model apply failed: ${e instanceof Error ? e.message : String(e)}`);
529444
529622
  }
529445
- for (let id of flow.skippedIds) {
529446
- if (id === "rules") {
529447
- flow.summary.push(`rules ${rulesSkipSummary()}`);
529448
- continue;
529449
- }
529623
+ for (let id of flow.skippedIds)
529450
529624
  flow.summary.push(
529451
529625
  `${id.padEnd(10)} nothing to import \u2014 skipped (run \`sema config ${id}\` anytime)`
529452
529626
  );
529453
- }
529454
529627
  }
529455
529628
  }
529456
529629
  function StationFrame({ flow, children }) {
@@ -529607,7 +529780,7 @@ function OnboardWizardBody({
529607
529780
  () => ({ summary: [], skippedIds: /* @__PURE__ */ new Set(), finalized: !1, zeroModels: !1, escArmedAt: 0, ctrlCArmedAt: 0, station: null }),
529608
529781
  []
529609
529782
  ), chain = React198.useMemo(
529610
- () => modelOnly ? ["model"] : ["language", "theme", "model", "tiers", "mcp", "skills", "plugins", "rules"],
529783
+ () => modelOnly ? ["model"] : ["language", "theme", "model", "tiers", "mcp", "skills", "plugins"],
529611
529784
  [modelOnly]
529612
529785
  ), setUiLanguage = useSetUiLanguage(), t2 = useT(), tRef = React198.useRef(t2);
529613
529786
  tRef.current = t2;
@@ -529687,28 +529860,6 @@ function OnboardWizardBody({
529687
529860
  }
529688
529861
  )
529689
529862
  };
529690
- if (id === "rules") {
529691
- let rulesNavRef = { current: null }, detected = detectCcRulesImport();
529692
- return {
529693
- key: "onboard-rules",
529694
- wantsEsc: () => {
529695
- let nav = rulesNavRef.current;
529696
- return !nav || goBack(i, nav) ? !0 : firstStationEsc();
529697
- },
529698
- render: (nav) => (rulesNavRef.current = nav, /* @__PURE__ */ (0, import_jsx_runtime511.jsxs)(ThemedBox_default, { flexDirection: "column", children: [
529699
- /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(ThemedText, { dimColor: !0, children: tt2("onboard.blurb.rules") }),
529700
- /* @__PURE__ */ (0, import_jsx_runtime511.jsx)(
529701
- CcRulesImportFlow,
529702
- {
529703
- layers: detected.layers,
529704
- onDone: (summary) => {
529705
- summary !== null ? flow.summary.push(summary) : writeCcImportDeclinedMarker(), advance(i, nav);
529706
- }
529707
- }
529708
- )
529709
- ] }))
529710
- };
529711
- }
529712
529863
  let navRef = { current: null }, onboardOpts = {
529713
529864
  blurb: tt2(STATION_BLURB_KEYS[id]),
529714
529865
  continueLabel: "Continue \u2192",
@@ -529749,10 +529900,7 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529749
529900
  init_TiersHub();
529750
529901
  init_skillsChannels();
529751
529902
  init_SkillsHub();
529752
- init_ccImportMarker();
529753
529903
  init_BigStepTitle();
529754
- init_CcRulesImportFlow();
529755
- init_ccRulesImport();
529756
529904
  init_LanguageStation();
529757
529905
  init_onboardVerification();
529758
529906
  init_onboardZeroModel();
@@ -529767,8 +529915,7 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529767
529915
  tiers: "onboard.station.tiers",
529768
529916
  mcp: "onboard.station.mcp",
529769
529917
  skills: "onboard.station.skills",
529770
- plugins: "onboard.station.plugins",
529771
- rules: "onboard.station.rules"
529918
+ plugins: "onboard.station.plugins"
529772
529919
  }, STATION_WORDS = {
529773
529920
  language: "LANGUAGE",
529774
529921
  theme: "THEME",
@@ -529776,15 +529923,13 @@ var React198, import_jsx_runtime511, STATION_LABEL_KEYS, STATION_WORDS, STATION_
529776
529923
  tiers: "TIERS",
529777
529924
  mcp: "MCP",
529778
529925
  skills: "SKILLS",
529779
- plugins: "PLUGINS",
529780
- rules: "RULES"
529926
+ plugins: "PLUGINS"
529781
529927
  }, STATION_BLURB_KEYS = {
529782
529928
  model: "onboard.blurb.model",
529783
529929
  tiers: "onboard.blurb.tiers",
529784
529930
  mcp: "onboard.blurb.mcp",
529785
529931
  skills: "onboard.blurb.skills",
529786
- plugins: "onboard.blurb.plugins",
529787
- rules: "onboard.blurb.rules"
529932
+ plugins: "onboard.blurb.plugins"
529788
529933
  };
529789
529934
  WELCOME_WORDMARK = [
529790
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 "],
@@ -530238,7 +530383,12 @@ ${addendum}` : addendum;
530238
530383
  notification: permissionModeNotification
530239
530384
  } = initialPermissionModeFromCLI({
530240
530385
  permissionModeCli,
530241
- 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()
530242
530392
  });
530243
530393
  setSessionBypassPermissionsMode(permissionMode === "bypassPermissions"), (options.enableAutoMode || permissionModeCli === "auto" || permissionMode === "auto" || !permissionModeCli && isDefaultPermissionModeAuto()) && autoModeStateModule7?.setAutoModeFlagCli(!0);
530244
530394
  let dynamicMcpConfig = {};
@@ -531140,7 +531290,7 @@ Usage: sema --remote "your task description"`, () => gracefulShutdown(1));
531140
531290
  pendingHookMessages
531141
531291
  }, renderAndRun);
531142
531292
  }
531143
- }).version("sema 1.0.82", "-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 () => {
531144
531294
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).psHandler([]), process.exit(process.exitCode ?? 0);
531145
531295
  }), program2.command("logs [id]").description("Print a background session's recent terminal output").action(async (id) => {
531146
531296
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).logsHandler(id, []), process.exit(process.exitCode ?? 0);
@@ -533131,7 +533281,7 @@ async function showSetupScreens(root2, permissionMode, allowDangerouslySkipPermi
533131
533281
  } = await Promise.resolve().then(() => (init_BypassPermissionsModeDialog(), BypassPermissionsModeDialog_exports));
533132
533282
  await showSetupDialog(root2, (done) => /* @__PURE__ */ (0, import_jsx_runtime526.jsx)(BypassPermissionsModeDialog2, { onAccept: done }));
533133
533283
  }
533134
- if (permissionMode === "auto" && !hasAutoModeOptIn()) {
533284
+ if (permissionMode === "auto" && !hasAutoModeOptIn() && !isFactoryDefaultAutoActive()) {
533135
533285
  let {
533136
533286
  AutoModeOptInDialog: AutoModeOptInDialog2
533137
533287
  } = await Promise.resolve().then(() => (init_AutoModeOptInDialog(), AutoModeOptInDialog_exports));
@@ -533198,6 +533348,7 @@ var import_jsx_runtime526, init_interactiveHelpers = __esm({
533198
533348
  init_AppState();
533199
533349
  init_onChangeAppState();
533200
533350
  init_authPortable();
533351
+ init_permissionSetup();
533201
533352
  init_claudemd();
533202
533353
  init_config();
533203
533354
  init_terminalPreference();
@@ -535824,8 +535975,8 @@ var BUILTIN_DYNAMIC, mcpFill_default, init_mcpFill = __esm({
535824
535975
  });
535825
535976
 
535826
535977
  // build-src/stubs/bun-bundle.js
535827
- var bun_bundle_exports = {};
535828
- __export(bun_bundle_exports, {
535978
+ var bun_bundle_exports2 = {};
535979
+ __export(bun_bundle_exports2, {
535829
535980
  feature: () => feature2
535830
535981
  });
535831
535982
  function feature2(flag) {
@@ -537637,7 +537788,9 @@ async function main2() {
537637
537788
  liveWorkflowBaseUrl ? (liveWorkflowSource = createLiveWorkflowSource({
537638
537789
  baseUrl: liveWorkflowBaseUrl,
537639
537790
  authToken: process.env.SEMA_WORKFLOW_TOKEN || process.env.SEMA_FLEET_TOKEN || "anon",
537640
- 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(),
537641
537794
  ...process.env.SEMA_WORKFLOW_ID ? { workflowId: process.env.SEMA_WORKFLOW_ID } : {}
537642
537795
  }), process.env.SEMA_DEBUG && console.error(
537643
537796
  `[sema] workflow source: LIVE WIRE (${liveWorkflowBaseUrl}) \u2014 createLiveWorkflowSource`
@@ -537685,7 +537838,9 @@ async function main2() {
537685
537838
  let { createLiveFleetSource: createLiveFleetSource2 } = await Promise.resolve().then(() => (init_fleetClient(), fleetClient_exports)), source2 = createLiveFleetSource2({
537686
537839
  baseUrl: liveBaseUrl,
537687
537840
  authToken: process.env.SEMA_FLEET_TOKEN || "anon",
537688
- principal: process.env.SEMA_FLEET_PRINCIPAL ?? "anon:sema"
537841
+ // principal 恒经闸口(F-011/[4189]:resolveFleetPrincipal 内部先认 SEMA_FLEET_PRINCIPAL
537842
+ // 显式值,缺省 'default' 租户键;anon 前缀哨兵残留已清)
537843
+ principal: resolveFleetPrincipal()
537689
537844
  });
537690
537845
  return process.env.SEMA_DEBUG && console.error(`[sema] fleet source: LIVE WIRE (${liveBaseUrl}) \u2014 createLiveFleetSource`), source2;
537691
537846
  }
@@ -538448,9 +538603,20 @@ async function launchReplProduction() {
538448
538603
  launchMode && (tpc.mode = launchMode), tpc.isBypassPermissionsModeAvailable = isBypassPermissionsModeAvailable, bypassModeLaunch = isBypassPermissionsModeAvailable;
538449
538604
  let effectiveConfig;
538450
538605
  try {
538451
- 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
+ });
538452
538611
  let dm = effectiveConfig.derivedMode;
538453
- 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(
538454
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}`
538455
538621
  );
538456
538622
  try {
@@ -538556,7 +538722,7 @@ async function launchReplProduction() {
538556
538722
  try {
538557
538723
  let modeApi = null;
538558
538724
  try {
538559
- 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));
538560
538726
  } catch {
538561
538727
  }
538562
538728
  let resumeContext = {
@@ -538947,7 +539113,7 @@ var React215, import_jsx_runtime537, isMain, COMMANDER_SUBCOMMANDS, replEntry_de
538947
539113
  if (isMain) {
538948
539114
  let argv = process.argv.slice(2);
538949
539115
  (async () => {
538950
- 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));
538951
539117
  if (argv[0] === "--daemon-worker") {
538952
539118
  let { runDaemonWorker: runDaemonWorker2 } = await Promise.resolve().then(() => (init_workerRegistry(), workerRegistry_exports));
538953
539119
  return await runDaemonWorker2(argv[1]), !0;
package/sema.js CHANGED
@@ -71,7 +71,7 @@ function installBootSignalTailFrame(argv2 = process.argv.slice(2)) {
71
71
  installBootSignalTailFrame();
72
72
 
73
73
  // build-src/src/sema/preludeEntry.ts
74
- var versionLine = "sema 1.0.82" ? "sema 1.0.82" : "";
74
+ var versionLine = "sema 1.0.83" ? "sema 1.0.83" : "";
75
75
  var argv = process.argv.slice(2);
76
76
  var wantsVersionFastPath = argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v");
77
77
  if (wantsVersionFastPath && versionLine) {