@sema-agent/cli 1.0.66 → 1.0.68
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/npm-shrinkwrap.json +32 -32
- package/package.json +5 -5
- package/sema-main.js +1590 -857
- package/sema.js +1 -1
package/sema-main.js
CHANGED
|
@@ -40445,7 +40445,7 @@ var init_gitFilesystem = __esm({
|
|
|
40445
40445
|
}
|
|
40446
40446
|
watchPath(path28, callback) {
|
|
40447
40447
|
this.watchedPaths.push(path28);
|
|
40448
|
-
watchFile(path28, { interval: WATCH_INTERVAL_MS }, callback);
|
|
40448
|
+
watchFile(path28, { interval: WATCH_INTERVAL_MS, persistent: false }, callback);
|
|
40449
40449
|
}
|
|
40450
40450
|
/**
|
|
40451
40451
|
* Watch the loose ref file for the current branch.
|
|
@@ -65953,11 +65953,11 @@ var init_types3 = __esm({
|
|
|
65953
65953
|
"Show thinking summaries in the transcript view (ctrl+o). Default: false."
|
|
65954
65954
|
),
|
|
65955
65955
|
skipDangerousModePermissionPrompt: external_exports.boolean().optional().describe(
|
|
65956
|
-
"Whether the user has accepted the bypass permissions mode dialog"
|
|
65956
|
+
"Whether the user has accepted the bypass permissions mode dialog. Remembers the warning screen only \u2014 it is NOT an approval switch and never changes what gets approved."
|
|
65957
65957
|
),
|
|
65958
65958
|
...true ? {
|
|
65959
65959
|
skipAutoPermissionPrompt: external_exports.boolean().optional().describe(
|
|
65960
|
-
"Whether the user has accepted the auto mode opt-in dialog"
|
|
65960
|
+
"Whether the user has accepted the auto mode opt-in dialog. Remembers the opt-in screen only \u2014 it is NOT an approval switch and never changes what gets approved."
|
|
65961
65961
|
),
|
|
65962
65962
|
useAutoModeDuringPlan: external_exports.boolean().optional().describe(
|
|
65963
65963
|
"Whether plan mode uses auto mode semantics when auto mode is available (default: true)"
|
|
@@ -69214,6 +69214,64 @@ var init_patch = __esm({
|
|
|
69214
69214
|
}
|
|
69215
69215
|
});
|
|
69216
69216
|
|
|
69217
|
+
// node_modules/@sema-agent/client-core/dist/engineErrorCodes.js
|
|
69218
|
+
function isConfigRefusalCode(code2) {
|
|
69219
|
+
return typeof code2 === "string" && code2.startsWith("config.");
|
|
69220
|
+
}
|
|
69221
|
+
function isInterruptedToolEndCode(code2) {
|
|
69222
|
+
return typeof code2 === "string" && TOOL_END_INTERRUPTED_CODES.has(code2);
|
|
69223
|
+
}
|
|
69224
|
+
function isRewindFamilyCode(code2) {
|
|
69225
|
+
return typeof code2 === "string" && REWIND_ERROR_CODE_PREFIXES.some((p) => code2.startsWith(p));
|
|
69226
|
+
}
|
|
69227
|
+
function asModelFallbackReason(v2) {
|
|
69228
|
+
return v2 === MODEL_FALLBACK_INHERIT_NO_TIER_BINDING ? MODEL_FALLBACK_INHERIT_NO_TIER_BINDING : void 0;
|
|
69229
|
+
}
|
|
69230
|
+
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, REWIND_ERROR_CODE_PREFIXES, STREAM_MAX_DURATION, MODEL_FALLBACK_INHERIT_NO_TIER_BINDING;
|
|
69231
|
+
var init_engineErrorCodes = __esm({
|
|
69232
|
+
"node_modules/@sema-agent/client-core/dist/engineErrorCodes.js"() {
|
|
69233
|
+
LIMITS_MAX_TOKENS_EXCEEDED = "limits.max_tokens_exceeded";
|
|
69234
|
+
LIMITS_MAX_COST_EXCEEDED = "limits.max_cost_exceeded";
|
|
69235
|
+
LIMITS_MAX_TURNS_EXCEEDED = "limits.max_turns_exceeded";
|
|
69236
|
+
LIMITS_MAX_WALLTIME_EXCEEDED = "limits.max_walltime_exceeded";
|
|
69237
|
+
USAGE_WINDOW_EXHAUSTED = "usage.window_exhausted";
|
|
69238
|
+
ENV_LIFETIME_EXPIRED = "env.lifetime_expired";
|
|
69239
|
+
CONFIG_LIMIT_INVALID = "config.limit_invalid";
|
|
69240
|
+
CONFIG_STRATEGY_FIND_LIMIT_INVALID = "config.strategy_find_limit_invalid";
|
|
69241
|
+
CONFIG_STRATEGY_MAX_SIZE_INVALID = "config.strategy_max_size_invalid";
|
|
69242
|
+
CONFIG_LIMIT_UNKNOWN_KEY = "config.limit_unknown_key";
|
|
69243
|
+
CONFIG_REFUSAL_CODES = /* @__PURE__ */ new Set([
|
|
69244
|
+
CONFIG_LIMIT_INVALID,
|
|
69245
|
+
CONFIG_STRATEGY_FIND_LIMIT_INVALID,
|
|
69246
|
+
CONFIG_STRATEGY_MAX_SIZE_INVALID,
|
|
69247
|
+
CONFIG_LIMIT_UNKNOWN_KEY
|
|
69248
|
+
]);
|
|
69249
|
+
TOOL_END_INTERRUPTED_NEVER_STARTED = "interrupted_never_started";
|
|
69250
|
+
TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN = "interrupted_outcome_unknown";
|
|
69251
|
+
TOOL_END_INTERRUPTED_CODES = /* @__PURE__ */ new Set([
|
|
69252
|
+
TOOL_END_INTERRUPTED_NEVER_STARTED,
|
|
69253
|
+
TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN
|
|
69254
|
+
]);
|
|
69255
|
+
ACTIVE_RUN_BUSY_ERROR_CODE = "conflict.session_active_run";
|
|
69256
|
+
STOP_PARK_ARBITER_UNREACHABLE = "stop.park_arbiter_unreachable";
|
|
69257
|
+
STOP_PARK_RESUME_WON = "stop.park_resume_won";
|
|
69258
|
+
STOP_NOT_LANDED = "stop.not_landed";
|
|
69259
|
+
STOP_NOT_LOCAL = "stop.not_local";
|
|
69260
|
+
STOP_PARKED = "stop.parked";
|
|
69261
|
+
STOP_CONFLICT_CODES = [
|
|
69262
|
+
STOP_PARK_ARBITER_UNREACHABLE,
|
|
69263
|
+
STOP_PARK_RESUME_WON,
|
|
69264
|
+
STOP_NOT_LANDED,
|
|
69265
|
+
STOP_NOT_LOCAL,
|
|
69266
|
+
STOP_PARKED
|
|
69267
|
+
];
|
|
69268
|
+
OUTPUT_INVALID = "output.invalid";
|
|
69269
|
+
REWIND_ERROR_CODE_PREFIXES = ["resume_at.", "rewind_snapshot."];
|
|
69270
|
+
STREAM_MAX_DURATION = "STREAM_MAX_DURATION";
|
|
69271
|
+
MODEL_FALLBACK_INHERIT_NO_TIER_BINDING = "inherit_no_tier_binding";
|
|
69272
|
+
}
|
|
69273
|
+
});
|
|
69274
|
+
|
|
69217
69275
|
// node_modules/@sema-agent/client-core/dist/toolResult.js
|
|
69218
69276
|
function structuredDetailType(structured) {
|
|
69219
69277
|
if (typeof structured !== "object" || structured === null)
|
|
@@ -69752,15 +69810,54 @@ function reportFindingsToolUseResult(structured, rawInput) {
|
|
|
69752
69810
|
}
|
|
69753
69811
|
};
|
|
69754
69812
|
}
|
|
69813
|
+
function readCompletedAgentCard(structured) {
|
|
69814
|
+
if (structured === null || typeof structured !== "object")
|
|
69815
|
+
return null;
|
|
69816
|
+
const s = structured;
|
|
69817
|
+
if (s.type !== "agent")
|
|
69818
|
+
return null;
|
|
69819
|
+
const status3 = s.status;
|
|
69820
|
+
if (typeof status3 !== "string" || status3.length === 0 || status3 === "async_launched")
|
|
69821
|
+
return null;
|
|
69822
|
+
const taskId = s.taskId;
|
|
69823
|
+
if (typeof taskId !== "string" || taskId.length === 0)
|
|
69824
|
+
return null;
|
|
69825
|
+
const str3 = (v2) => typeof v2 === "string" && v2.length > 0 ? v2 : void 0;
|
|
69826
|
+
const num = (v2) => typeof v2 === "number" && Number.isFinite(v2) ? v2 : void 0;
|
|
69827
|
+
return {
|
|
69828
|
+
status: status3,
|
|
69829
|
+
taskId,
|
|
69830
|
+
...str3(s.sessionId) !== void 0 ? { sessionId: str3(s.sessionId) } : {},
|
|
69831
|
+
...str3(s.subagent_type) !== void 0 ? { subagentType: str3(s.subagent_type) } : {},
|
|
69832
|
+
// `result` 允许空串(子代没产出正文是一个诚实的事实),故这里不用 `str` 的非空过滤。
|
|
69833
|
+
...typeof s.result === "string" ? { result: s.result } : {},
|
|
69834
|
+
...typeof s.salvagedOutput === "string" ? { salvagedOutput: s.salvagedOutput } : {},
|
|
69835
|
+
...s.structuredOutput !== void 0 ? { structuredOutput: s.structuredOutput } : {},
|
|
69836
|
+
...str3(s.blockedReason) !== void 0 ? { blockedReason: str3(s.blockedReason) } : {},
|
|
69837
|
+
...str3(s.errorMessage) !== void 0 ? { errorMessage: str3(s.errorMessage) } : {},
|
|
69838
|
+
...str3(s.errorCode) !== void 0 ? { errorCode: str3(s.errorCode) } : {},
|
|
69839
|
+
...num(s.retryAfterMs) !== void 0 ? { retryAfterMs: num(s.retryAfterMs) } : {},
|
|
69840
|
+
// 对象守卫(与 terminalToSdkResult.degradedOf 同姿势):非对象/null 一律当缺席,不硬塞。
|
|
69841
|
+
...typeof s.degraded === "object" && s.degraded !== null ? { degraded: s.degraded } : {},
|
|
69842
|
+
...str3(s.error_kind) !== void 0 ? { errorKind: str3(s.error_kind) } : {},
|
|
69843
|
+
...typeof s.retryable === "boolean" ? { retryable: s.retryable } : {},
|
|
69844
|
+
...typeof s.stats === "object" && s.stats !== null ? { stats: s.stats } : {},
|
|
69845
|
+
...str3(s.model) !== void 0 ? { model: str3(s.model) } : {},
|
|
69846
|
+
...str3(s.resolvedModel) !== void 0 ? { resolvedModel: str3(s.resolvedModel) } : {},
|
|
69847
|
+
...asModelFallbackReason(s.modelFallback) !== void 0 ? { modelFallback: asModelFallbackReason(s.modelFallback) } : {},
|
|
69848
|
+
...str3(s.worktreePath) !== void 0 ? { worktreePath: str3(s.worktreePath) } : {},
|
|
69849
|
+
...s.toolStats !== void 0 ? { toolStats: s.toolStats } : {}
|
|
69850
|
+
};
|
|
69851
|
+
}
|
|
69755
69852
|
var STRUCTURED_DETAIL_TYPES, MAX_STRUCTURED_FIELD_CHARS, WF_TERMINAL_STATUSES, PROTOCOL_MARKERS, modelFacingParseCount, THREE_GEN_BG_RECEIPT_RE, backgroundReceiptParseCount, TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT;
|
|
69756
69853
|
var init_toolResult = __esm({
|
|
69757
69854
|
"node_modules/@sema-agent/client-core/dist/toolResult.js"() {
|
|
69758
69855
|
init_patch();
|
|
69759
69856
|
init_notifications();
|
|
69760
69857
|
init_workflow();
|
|
69858
|
+
init_engineErrorCodes();
|
|
69761
69859
|
STRUCTURED_DETAIL_TYPES = /* @__PURE__ */ new Set([
|
|
69762
69860
|
"edit",
|
|
69763
|
-
"multiedit",
|
|
69764
69861
|
"create",
|
|
69765
69862
|
"update",
|
|
69766
69863
|
"bash",
|
|
@@ -69778,7 +69875,6 @@ var init_toolResult = __esm({
|
|
|
69778
69875
|
"task",
|
|
69779
69876
|
"task-list",
|
|
69780
69877
|
"task-output",
|
|
69781
|
-
"memory-saved",
|
|
69782
69878
|
"workflow-run",
|
|
69783
69879
|
"web-fetch",
|
|
69784
69880
|
"web-search",
|
|
@@ -69789,7 +69885,6 @@ var init_toolResult = __esm({
|
|
|
69789
69885
|
"image",
|
|
69790
69886
|
"task-stop",
|
|
69791
69887
|
"tool-search",
|
|
69792
|
-
"memory-recall",
|
|
69793
69888
|
"repo-map",
|
|
69794
69889
|
"fork",
|
|
69795
69890
|
"enter-plan-mode",
|
|
@@ -69800,7 +69895,22 @@ var init_toolResult = __esm({
|
|
|
69800
69895
|
"file_unchanged",
|
|
69801
69896
|
"worktree",
|
|
69802
69897
|
"monitor-start",
|
|
69803
|
-
"path_not_in_root"
|
|
69898
|
+
"path_not_in_root",
|
|
69899
|
+
// ── core 5.10.0 词表换代(2026-08-04 提货批;engine-vocab 等值门对 5.10.0 实装物直证)──────
|
|
69900
|
+
// 5.10.0 的 structured-card 审计把这张表变成**双向契约**(每个铸点都登记 / 每个登记词都真被产出)。
|
|
69901
|
+
// 新登记 7 词 —— 它们的工具**一直**在铸卡,漏的只是登记,于是这 7 类卡从来没上过 wire:
|
|
69902
|
+
// · `report-findings` 最坏(ReportFindings 的模型面被**故意**压成「N findings reported.」,
|
|
69903
|
+
// 卡又丢了 ⇒ findings 模型看不到、宿主也看不到,两头落空);
|
|
69904
|
+
// · `readonly_out_of_root` 与既有 `path_not_in_root` 是同一份「按字段数拒绝次数」契约的两半
|
|
69905
|
+
// (一个在 shell 面、一个在 fs 面);
|
|
69906
|
+
// · `schedule-wakeup` / `send-message` / `agent-transcript` / `a2a` / `document` 同理。
|
|
69907
|
+
"readonly_out_of_root",
|
|
69908
|
+
"report-findings",
|
|
69909
|
+
"schedule-wakeup",
|
|
69910
|
+
"send-message",
|
|
69911
|
+
"agent-transcript",
|
|
69912
|
+
"a2a",
|
|
69913
|
+
"document"
|
|
69804
69914
|
]);
|
|
69805
69915
|
MAX_STRUCTURED_FIELD_CHARS = 1e6;
|
|
69806
69916
|
WF_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -73203,8 +73313,8 @@ function defaultMaxTokensFor(contextWindow, perModelCap) {
|
|
|
73203
73313
|
const ctx = normalizeCtx(contextWindow);
|
|
73204
73314
|
const base = ctx >= 5e5 ? 64e3 : 32e3;
|
|
73205
73315
|
const quarter = Math.floor(ctx / 4);
|
|
73206
|
-
const
|
|
73207
|
-
return Math.min(base, quarter,
|
|
73316
|
+
const cap2 = typeof perModelCap === "number" && Number.isFinite(perModelCap) && perModelCap > 0 ? perModelCap : Infinity;
|
|
73317
|
+
return Math.min(base, quarter, cap2);
|
|
73208
73318
|
}
|
|
73209
73319
|
function tierChoicesFor(contextWindow) {
|
|
73210
73320
|
const ctx = normalizeCtx(contextWindow);
|
|
@@ -73326,18 +73436,27 @@ function streamEventArm2(ctx, event) {
|
|
|
73326
73436
|
function assertNeverArm(_ev) {
|
|
73327
73437
|
}
|
|
73328
73438
|
function eventToSdkMessage(ev, ctx) {
|
|
73329
|
-
const raw2 = ev;
|
|
73330
|
-
if (raw2.type === "workflow_complete") {
|
|
73331
|
-
if (typeof raw2.runId !== "string")
|
|
73332
|
-
return dropped("malformed", "workflow_complete");
|
|
73333
|
-
return projected(stamp(ctx, armBody({
|
|
73334
|
-
type: "workflow_complete",
|
|
73335
|
-
runId: raw2.runId,
|
|
73336
|
-
status: raw2.status === "failed" ? "failed" : "completed",
|
|
73337
|
-
summary: typeof raw2.summary === "string" ? raw2.summary : ""
|
|
73338
|
-
})));
|
|
73339
|
-
}
|
|
73340
73439
|
switch (ev.type) {
|
|
73440
|
+
// service 1.75 — `workflow_complete`: an out-of-band background-workflow completion push, ridden onto
|
|
73441
|
+
// the session's next stream open (BEFORE the run's own events). Projects to a NEUTRAL internal arm;
|
|
73442
|
+
// the upstream bridge turns it into CC's `<task-notification>` injection.
|
|
73443
|
+
// 🔴 **到期复核已兑现(sdk 6.2.0 提货批,2026-08-04)**:本臂此前是 switch 之前的**唯一** raw
|
|
73444
|
+
// 预分派臂,理由写着「`workflow_complete` 至今不在 union 里……入 union 当天搬进 switch」。
|
|
73445
|
+
// sdk 6.2.0 的 TR-7 批把它连同 question/elicitation 族一并加进了 `AgentEvent` union
|
|
73446
|
+
// (判据 = `dist/events.d.ts` 出现 `type: "workflow_complete"`),故按原定计划搬进来 ——
|
|
73447
|
+
// raw 预分派臂与 `raw` 变量一并退役,本函数从此**每一条臂都受 B5 编译期穷举保护**。
|
|
73448
|
+
// 语义不变:至少一次投递(两条腿同开可能双发),消费方按 `runId` 去重(notifications 台账干这件事)。
|
|
73449
|
+
case "workflow_complete": {
|
|
73450
|
+
if (typeof ev.runId !== "string" || ev.runId.length === 0) {
|
|
73451
|
+
return dropped("malformed", "workflow_complete");
|
|
73452
|
+
}
|
|
73453
|
+
return projected(stamp(ctx, armBody({
|
|
73454
|
+
type: "workflow_complete",
|
|
73455
|
+
runId: ev.runId,
|
|
73456
|
+
status: ev.status === "failed" ? "failed" : "completed",
|
|
73457
|
+
summary: typeof ev.summary === "string" ? ev.summary : ""
|
|
73458
|
+
})));
|
|
73459
|
+
}
|
|
73341
73460
|
// CS-1 §2.2 — turn-aggregated answer text (durable). Drop raw block array.
|
|
73342
73461
|
case "text":
|
|
73343
73462
|
return projected(assistantArm2(ctx, [{ type: "text", text: ev.text }]));
|
|
@@ -73397,11 +73516,13 @@ function eventToSdkMessage(ev, ctx) {
|
|
|
73397
73516
|
// a side-channel arm `sdkMessagesToCcEvents` reads; CC's own renderer never sees it.
|
|
73398
73517
|
case "tool_end": {
|
|
73399
73518
|
const structured = ev.structured;
|
|
73519
|
+
const toolEndErrorCode = ev.errorCode;
|
|
73400
73520
|
return projected(stamp(ctx, armBody({
|
|
73401
73521
|
type: "tool_end_result",
|
|
73402
73522
|
toolCallId: ev.toolCallId,
|
|
73403
73523
|
toolName: ev.toolName,
|
|
73404
73524
|
isError: ev.isError,
|
|
73525
|
+
...typeof toolEndErrorCode === "string" && toolEndErrorCode.length > 0 ? { errorCode: toolEndErrorCode } : {},
|
|
73405
73526
|
// P0-2([1725] 清单A)— `tool_end.label` 同 tool_start 待遇(server trace/project.js:61 白名单
|
|
73406
73527
|
// 本体产出)。此臂是壳内部侧信道(不进 transcript),所以这里带着无 provider 风险;
|
|
73407
73528
|
// tool_start 先到时 bridge 已登记过,这条是补位(只有 tool_end 带 label 的场景)。
|
|
@@ -73550,7 +73671,35 @@ function eventToSdkMessage(ev, ctx) {
|
|
|
73550
73671
|
return nothing("usage_only");
|
|
73551
73672
|
// §2.9 — suspended 的 HITL 登记是 run driver 的活(hitlBridge.observe),本层不投影。
|
|
73552
73673
|
case "suspended":
|
|
73674
|
+
// ── sdk 6.2.0 TR-7 新入 union 的 HITL 带外族(2026-08-04 提货批)────────────────────────
|
|
73675
|
+
// `question` / `question_complete`(AskUserQuestion 的开问/收尾)与 `elicitation` /
|
|
73676
|
+
// `elicitation_complete`(入站 MCP server 向用户要输入)是**对话框覆盖层**的词汇,不是
|
|
73677
|
+
// transcript 的。它们此前只走 live 腿的 SSE `event:` 名分派(`liveQuestionStore.ts` 的 demux
|
|
73678
|
+
// 口),6.2.0 把 durable 腿的重放形也纳入了 union —— 于是它们第一次**流经本函数**。
|
|
73679
|
+
// 🔴 处置理由与 `suspended` 同族、也与本包既有分工一致:HITL 的挂起/应答由
|
|
73680
|
+
// `hitl/hitlBridge.ts` 的 `observe()` 与 `liveQuestionStore` 负责,本切片(CC transcript
|
|
73681
|
+
// 投影)对它们**没有对位渲染物** —— 硬投一个 transcript 形就是替覆盖层编一条假消息。
|
|
73682
|
+
// 所以走 `hitl_out_of_slice`(可分辨的三态之一),不是 `dropped`(那是「我看不懂」)。
|
|
73683
|
+
// 🔴 记档给下一棒(诚实缺席,不是无事发生):durable 重放腿上,一条被重放的 `question` 今天
|
|
73684
|
+
// **不会**再打开覆盖层 —— 覆盖层的入口是 liveQuestionStore 的 live demux 写口,而不是本函数。
|
|
73685
|
+
// 这在交互 REPL 上无损(live 腿原路不变),在「断线后按 Last-Event-ID 续读」的场景下是一个
|
|
73686
|
+
// 真缺口。补它属**行为面**改动(要先答「重放一条已经过期 5min TTL 的问题该不该弹窗」),
|
|
73687
|
+
// 按宪法三问单独走,不在本提货批里顺手加 —— 但缺口写在这里,不留白。
|
|
73688
|
+
case "question":
|
|
73689
|
+
case "question_complete":
|
|
73690
|
+
case "elicitation":
|
|
73691
|
+
case "elicitation_complete":
|
|
73553
73692
|
return nothing("hitl_out_of_slice");
|
|
73693
|
+
// ── sdk 6.2.0 CB-1/TR-6 `error` 臂(2026-08-04 提货批)──────────────────────────────────
|
|
73694
|
+
// 🔴 **名字骗人,别当终态**:这是流的 15 分钟帽帧(server `sse-log.ts`),帧自己就说
|
|
73695
|
+
// 「run 仍然活着」。终态臂只有 `done` / `failed`。把它渲成终态 = 把一条还在跑的任务判死。
|
|
73696
|
+
// 正确处置 = 按 `Last-Event-ID` 重连续读,而那件事 SDK 的 `runs.events` 车道内部就做了
|
|
73697
|
+
// (本包侧的坐标 = `headlessReconnectWire.ts` 的 STREAM_MAX_DURATION 段)。
|
|
73698
|
+
// ⇒ 本切片无对位渲染物,也**绝不终止**调用方的循环(返回 none,不是 terminal)。
|
|
73699
|
+
// 🔴 `errorCode` 开集(已知 `STREAM_MAX_DURATION`):未知码同样按「可重连的流控信号」降级,
|
|
73700
|
+
// 不要按成员判死 —— 词表见 `engineErrorCodes.ts`。
|
|
73701
|
+
case "error":
|
|
73702
|
+
return nothing("not_in_slice");
|
|
73554
73703
|
// CS-10 / CS-11 — terminals are projected by terminalToSdkResult.
|
|
73555
73704
|
case "done":
|
|
73556
73705
|
case "failed":
|
|
@@ -73668,7 +73817,7 @@ function subtypeForErrorCode(code2) {
|
|
|
73668
73817
|
return "error_max_budget_usd";
|
|
73669
73818
|
if (TURNS_EXCEEDED_CODES.has(code2))
|
|
73670
73819
|
return "error_max_turns";
|
|
73671
|
-
if (code2 ===
|
|
73820
|
+
if (code2 === OUTPUT_INVALID)
|
|
73672
73821
|
return "error_max_structured_output_retries";
|
|
73673
73822
|
return "error_during_execution";
|
|
73674
73823
|
}
|
|
@@ -73738,7 +73887,7 @@ function doneToSdkResult(ev, ctx) {
|
|
|
73738
73887
|
return errorResult(ctx, {
|
|
73739
73888
|
...errorBase,
|
|
73740
73889
|
subtype: failedSubtype,
|
|
73741
|
-
...cutoffParts(r, rr.errorMessage, rr.errorCode ===
|
|
73890
|
+
...cutoffParts(r, rr.errorMessage, rr.errorCode === LIMITS_MAX_TOKENS_EXCEEDED ? "run exhausted its token budget" : "run hit its wall-clock limit", rr.errorCode)
|
|
73742
73891
|
});
|
|
73743
73892
|
}
|
|
73744
73893
|
return errorResult(ctx, {
|
|
@@ -73748,7 +73897,7 @@ function doneToSdkResult(ev, ctx) {
|
|
|
73748
73897
|
// rewind_snapshot.unresolvable 骑在 done{status:"failed"} 帧的 errorCode 上,非 `failed` 帧)——
|
|
73749
73898
|
// 与 failedToSdkResult 的同款 append 对齐,message 后附 code 便于对账。
|
|
73750
73899
|
errors: [
|
|
73751
|
-
|
|
73900
|
+
isRewindFamilyCode(rr.errorCode) && rr.errorMessage ? `${rr.errorMessage} (${rr.errorCode})` : rr.errorMessage ?? "run failed"
|
|
73752
73901
|
]
|
|
73753
73902
|
});
|
|
73754
73903
|
}
|
|
@@ -73832,7 +73981,7 @@ function failedToSdkResult(ev, ctx) {
|
|
|
73832
73981
|
// resume_at.before_root_unsupported / rewind_snapshot.unresolvable)透传给用户 —— 这些是
|
|
73833
73982
|
// 用户可自解的操作性错误(选错目标/回退过根/快照缺失),code 附在 message 后便于对账。
|
|
73834
73983
|
errors: [
|
|
73835
|
-
|
|
73984
|
+
isRewindFamilyCode(ev.errorCode) && ev.errorMessage ? `${ev.errorMessage} (${ev.errorCode})` : ev.errorMessage ?? ev.errorCode ?? "run failed"
|
|
73836
73985
|
]
|
|
73837
73986
|
});
|
|
73838
73987
|
}
|
|
@@ -73844,15 +73993,12 @@ var init_terminalToSdkResult = __esm({
|
|
|
73844
73993
|
"node_modules/@sema-agent/client-core/dist/adapter/downstream/terminalToSdkResult.js"() {
|
|
73845
73994
|
init_types4();
|
|
73846
73995
|
init_turnUsageToModelUsage();
|
|
73847
|
-
|
|
73848
|
-
|
|
73849
|
-
]);
|
|
73850
|
-
TURNS_EXCEEDED_CODES = /* @__PURE__ */ new Set([
|
|
73851
|
-
"limits.max_turns_exceeded"
|
|
73852
|
-
]);
|
|
73996
|
+
init_engineErrorCodes();
|
|
73997
|
+
COST_EXCEEDED_CODES = /* @__PURE__ */ new Set([LIMITS_MAX_COST_EXCEEDED]);
|
|
73998
|
+
TURNS_EXCEEDED_CODES = /* @__PURE__ */ new Set([LIMITS_MAX_TURNS_EXCEEDED]);
|
|
73853
73999
|
CUTOFF_EXCEEDED_CODES = /* @__PURE__ */ new Set([
|
|
73854
|
-
|
|
73855
|
-
|
|
74000
|
+
LIMITS_MAX_TOKENS_EXCEEDED,
|
|
74001
|
+
LIMITS_MAX_WALLTIME_EXCEEDED
|
|
73856
74002
|
]);
|
|
73857
74003
|
}
|
|
73858
74004
|
});
|
|
@@ -74039,15 +74185,15 @@ async function* runStreamInner(events3, ctx, handle2 = {}) {
|
|
|
74039
74185
|
reportDroppedFrame(projection.why, projection.type, ctx);
|
|
74040
74186
|
}
|
|
74041
74187
|
}
|
|
74042
|
-
var MAIN2,
|
|
74188
|
+
var MAIN2, reportedDroppedTypes, DROPPED_TYPE_MEMO_CAP, DROPPED_TYPE_DISPLAY_CAP, inFlightTurns;
|
|
74043
74189
|
var init_runStream = __esm({
|
|
74044
74190
|
"node_modules/@sema-agent/client-core/dist/adapter/runStream.js"() {
|
|
74045
74191
|
init_types4();
|
|
74046
74192
|
init_eventToSdkMessage();
|
|
74047
74193
|
init_terminalToSdkResult();
|
|
74048
74194
|
init_subagentContentStore();
|
|
74195
|
+
init_engineErrorCodes();
|
|
74049
74196
|
MAIN2 = { lane: "main" };
|
|
74050
|
-
ACTIVE_RUN_BUSY_ERROR_CODE = "conflict.session_active_run";
|
|
74051
74197
|
reportedDroppedTypes = /* @__PURE__ */ new Set();
|
|
74052
74198
|
DROPPED_TYPE_MEMO_CAP = 64;
|
|
74053
74199
|
DROPPED_TYPE_DISPLAY_CAP = 60;
|
|
@@ -74568,6 +74714,15 @@ function parseNoFinalVerifyArgv(argv) {
|
|
|
74568
74714
|
}
|
|
74569
74715
|
return false;
|
|
74570
74716
|
}
|
|
74717
|
+
function parseFinalVerifyArgv(argv) {
|
|
74718
|
+
for (const a of argv) {
|
|
74719
|
+
if (a === "--")
|
|
74720
|
+
break;
|
|
74721
|
+
if (a === "--final-verify")
|
|
74722
|
+
return true;
|
|
74723
|
+
}
|
|
74724
|
+
return false;
|
|
74725
|
+
}
|
|
74571
74726
|
function headlessFinalVerifyDisabledByEnv(env5 = hostEnv()) {
|
|
74572
74727
|
return envFlagOff(env5[HEADLESS_FINAL_VERIFY_ENV]);
|
|
74573
74728
|
}
|
|
@@ -74583,9 +74738,13 @@ function resolveHeadlessFinalVerifyDetail(argv, env5 = hostEnv(), wireHooks) {
|
|
|
74583
74738
|
return { on: false, offReason: "flag" };
|
|
74584
74739
|
if (headlessFinalVerifyDisabledByEnv(env5))
|
|
74585
74740
|
return { on: false, offReason: "env" };
|
|
74586
|
-
|
|
74587
|
-
|
|
74588
|
-
|
|
74741
|
+
const explicitOn = parseFinalVerifyArgv(argv) || envFlagOn(env5[HEADLESS_FINAL_VERIFY_ENV]);
|
|
74742
|
+
if (explicitOn) {
|
|
74743
|
+
if (hasUserStopHook(wireHooks))
|
|
74744
|
+
return { on: false, offReason: "stop-hook" };
|
|
74745
|
+
return { on: true };
|
|
74746
|
+
}
|
|
74747
|
+
return { on: false };
|
|
74589
74748
|
}
|
|
74590
74749
|
var HEADLESS_FINAL_VERIFY_ENV, FINAL_VERIFY_YIELD_NOTICE;
|
|
74591
74750
|
var init_finalVerifyWire = __esm({
|
|
@@ -74608,7 +74767,7 @@ function parseIntInDomain(raw2, min, max2) {
|
|
|
74608
74767
|
return n2;
|
|
74609
74768
|
}
|
|
74610
74769
|
function hasAnyLimit(l3) {
|
|
74611
|
-
return l3.maxWalltimeMs !== void 0 || l3.maxTurns !== void 0 || l3.
|
|
74770
|
+
return l3.maxWalltimeMs !== void 0 || l3.maxTurns !== void 0 || l3.maxOutputTokens !== void 0;
|
|
74612
74771
|
}
|
|
74613
74772
|
function parseLimitsArgv(argv) {
|
|
74614
74773
|
const limits = {};
|
|
@@ -74634,7 +74793,7 @@ function parseLimitsArgv(argv) {
|
|
|
74634
74793
|
const n2 = mk.raw !== void 0 ? parseIntInDomain(mk.raw, MAX_TOKENS_MIN, MAX_TOKENS_MAX) : null;
|
|
74635
74794
|
if (n2 === null)
|
|
74636
74795
|
return { ok: false, error: MAX_TOKENS_USAGE };
|
|
74637
|
-
limits.
|
|
74796
|
+
limits.maxOutputTokens = n2;
|
|
74638
74797
|
flaggedFlags.push("--max-tokens");
|
|
74639
74798
|
}
|
|
74640
74799
|
return {
|
|
@@ -74670,7 +74829,7 @@ function headlessLimitsFromEnv(env5 = hostEnv()) {
|
|
|
74670
74829
|
if (n2 === null) {
|
|
74671
74830
|
return { ok: false, error: `Error: ${HEADLESS_MAX_TOKENS_ENV}="${mk}" is not a positive integer. Fix or unset it.` };
|
|
74672
74831
|
}
|
|
74673
|
-
out6.
|
|
74832
|
+
out6.maxOutputTokens = n2;
|
|
74674
74833
|
}
|
|
74675
74834
|
return { ok: true, limits: hasAnyLimit(out6) ? out6 : void 0 };
|
|
74676
74835
|
}
|
|
@@ -75700,15 +75859,15 @@ function classifyTaskStopConflict(e) {
|
|
|
75700
75859
|
const raw2 = e?.errorCode;
|
|
75701
75860
|
const code2 = typeof raw2 === "string" ? raw2 : STOP_CONFLICT_CODES.find((c2) => detail.includes(c2)) ?? "";
|
|
75702
75861
|
switch (code2) {
|
|
75703
|
-
case
|
|
75862
|
+
case STOP_NOT_LOCAL:
|
|
75704
75863
|
return { ok: false, reason: "not_local", detail };
|
|
75705
|
-
case
|
|
75864
|
+
case STOP_PARKED:
|
|
75706
75865
|
return { ok: false, reason: "parked", detail };
|
|
75707
|
-
case
|
|
75866
|
+
case STOP_PARK_RESUME_WON:
|
|
75708
75867
|
return { ok: false, reason: "park_resume_won", detail };
|
|
75709
|
-
case
|
|
75868
|
+
case STOP_PARK_ARBITER_UNREACHABLE:
|
|
75710
75869
|
return { ok: false, reason: "park_arbiter_unreachable", detail };
|
|
75711
|
-
case
|
|
75870
|
+
case STOP_NOT_LANDED:
|
|
75712
75871
|
return { ok: false, reason: "not_landed", detail };
|
|
75713
75872
|
default:
|
|
75714
75873
|
return { ok: false, reason: "unknown_conflict", detail };
|
|
@@ -75752,7 +75911,7 @@ async function stopEngineTask(handle2, opts) {
|
|
|
75752
75911
|
return { ok: false, reason: "error", detail };
|
|
75753
75912
|
}
|
|
75754
75913
|
}
|
|
75755
|
-
var accumulated
|
|
75914
|
+
var accumulated;
|
|
75756
75915
|
var init_engineTaskHandleWire = __esm({
|
|
75757
75916
|
"node_modules/@sema-agent/client-core/dist/subagent/engineTaskHandleWire.js"() {
|
|
75758
75917
|
init_host();
|
|
@@ -75762,14 +75921,8 @@ var init_engineTaskHandleWire = __esm({
|
|
|
75762
75921
|
init_subagentContentStore();
|
|
75763
75922
|
init_engineRowStopGate();
|
|
75764
75923
|
init_toolResult();
|
|
75924
|
+
init_engineErrorCodes();
|
|
75765
75925
|
accumulated = /* @__PURE__ */ new Map();
|
|
75766
|
-
STOP_CONFLICT_CODES = [
|
|
75767
|
-
"stop.park_arbiter_unreachable",
|
|
75768
|
-
"stop.park_resume_won",
|
|
75769
|
-
"stop.not_landed",
|
|
75770
|
-
"stop.not_local",
|
|
75771
|
-
"stop.parked"
|
|
75772
|
-
];
|
|
75773
75926
|
}
|
|
75774
75927
|
});
|
|
75775
75928
|
|
|
@@ -78855,124 +79008,6 @@ var init_toolApprovalWire = __esm({
|
|
|
78855
79008
|
}
|
|
78856
79009
|
});
|
|
78857
79010
|
|
|
78858
|
-
// node_modules/@sema-agent/client-core/dist/hitl/gateLedger.js
|
|
78859
|
-
function createGateLedger() {
|
|
78860
|
-
const startedCalls = /* @__PURE__ */ new Set();
|
|
78861
|
-
const endedCalls = /* @__PURE__ */ new Set();
|
|
78862
|
-
const heldAskEnds = /* @__PURE__ */ new Map();
|
|
78863
|
-
const gatedStartArgsByCall = /* @__PURE__ */ new Map();
|
|
78864
|
-
const deniedCalls = /* @__PURE__ */ new Set();
|
|
78865
|
-
const pendingFsCalls = [];
|
|
78866
|
-
const resolvedAnswers = /* @__PURE__ */ new Map();
|
|
78867
|
-
const decidedGates = /* @__PURE__ */ new Set();
|
|
78868
|
-
let lastFsOrShellGatedCall;
|
|
78869
|
-
let denyStampNextFsEnd = false;
|
|
78870
|
-
let seq;
|
|
78871
|
-
return {
|
|
78872
|
-
noteSeq(ev) {
|
|
78873
|
-
const rawSeq = ev.id ?? ev.seq;
|
|
78874
|
-
if (typeof rawSeq === "string" && rawSeq.length > 0)
|
|
78875
|
-
seq = rawSeq;
|
|
78876
|
-
else if (typeof rawSeq === "number" && Number.isFinite(rawSeq))
|
|
78877
|
-
seq = String(rawSeq);
|
|
78878
|
-
},
|
|
78879
|
-
lastSeq() {
|
|
78880
|
-
return seq;
|
|
78881
|
-
},
|
|
78882
|
-
markStarted(callId) {
|
|
78883
|
-
if (startedCalls.has(callId))
|
|
78884
|
-
return false;
|
|
78885
|
-
startedCalls.add(callId);
|
|
78886
|
-
return true;
|
|
78887
|
-
},
|
|
78888
|
-
noteGatedStart(callId, ev) {
|
|
78889
|
-
gatedStartArgsByCall.set(callId, ev.args);
|
|
78890
|
-
},
|
|
78891
|
-
gatedStartArgs() {
|
|
78892
|
-
return gatedStartArgsByCall;
|
|
78893
|
-
},
|
|
78894
|
-
isEnded(callId) {
|
|
78895
|
-
return endedCalls.has(callId);
|
|
78896
|
-
},
|
|
78897
|
-
markEnded(callId) {
|
|
78898
|
-
endedCalls.add(callId);
|
|
78899
|
-
},
|
|
78900
|
-
hold(callId, ev) {
|
|
78901
|
-
heldAskEnds.set(callId, ev);
|
|
78902
|
-
},
|
|
78903
|
-
dropHeld(callId) {
|
|
78904
|
-
heldAskEnds.delete(callId);
|
|
78905
|
-
},
|
|
78906
|
-
heldCount() {
|
|
78907
|
-
return heldAskEnds.size;
|
|
78908
|
-
},
|
|
78909
|
-
*flushHeld() {
|
|
78910
|
-
for (const [callId, held] of heldAskEnds) {
|
|
78911
|
-
endedCalls.add(callId);
|
|
78912
|
-
yield held;
|
|
78913
|
-
}
|
|
78914
|
-
heldAskEnds.clear();
|
|
78915
|
-
},
|
|
78916
|
-
markDenied(callId) {
|
|
78917
|
-
deniedCalls.add(callId);
|
|
78918
|
-
},
|
|
78919
|
-
isDenied(callId) {
|
|
78920
|
-
return deniedCalls.has(callId);
|
|
78921
|
-
},
|
|
78922
|
-
takeDenied(callId) {
|
|
78923
|
-
return deniedCalls.delete(callId);
|
|
78924
|
-
},
|
|
78925
|
-
armDenyStamp() {
|
|
78926
|
-
denyStampNextFsEnd = true;
|
|
78927
|
-
},
|
|
78928
|
-
takeDenyStamp() {
|
|
78929
|
-
if (!denyStampNextFsEnd)
|
|
78930
|
-
return false;
|
|
78931
|
-
denyStampNextFsEnd = false;
|
|
78932
|
-
return true;
|
|
78933
|
-
},
|
|
78934
|
-
pushFsCall(callId) {
|
|
78935
|
-
pendingFsCalls.push(callId);
|
|
78936
|
-
},
|
|
78937
|
-
dropFsCall(callId) {
|
|
78938
|
-
const at = pendingFsCalls.indexOf(callId);
|
|
78939
|
-
if (at !== -1)
|
|
78940
|
-
pendingFsCalls.splice(at, 1);
|
|
78941
|
-
},
|
|
78942
|
-
lastPendingFsCall() {
|
|
78943
|
-
return pendingFsCalls.length > 0 ? pendingFsCalls[pendingFsCalls.length - 1] : void 0;
|
|
78944
|
-
},
|
|
78945
|
-
noteFsOrShellGate(callId) {
|
|
78946
|
-
lastFsOrShellGatedCall = callId;
|
|
78947
|
-
},
|
|
78948
|
-
lastFsOrShellGatedCallId() {
|
|
78949
|
-
return lastFsOrShellGatedCall;
|
|
78950
|
-
},
|
|
78951
|
-
rememberAnswer(callId, answered) {
|
|
78952
|
-
resolvedAnswers.set(callId, answered);
|
|
78953
|
-
},
|
|
78954
|
-
answerFor(callId) {
|
|
78955
|
-
return resolvedAnswers.get(callId);
|
|
78956
|
-
},
|
|
78957
|
-
dropAnswer(callId) {
|
|
78958
|
-
resolvedAnswers.delete(callId);
|
|
78959
|
-
},
|
|
78960
|
-
markDecided(callId) {
|
|
78961
|
-
decidedGates.add(callId);
|
|
78962
|
-
},
|
|
78963
|
-
takeDecided(callId) {
|
|
78964
|
-
return decidedGates.delete(callId);
|
|
78965
|
-
},
|
|
78966
|
-
decidedCount() {
|
|
78967
|
-
return decidedGates.size;
|
|
78968
|
-
}
|
|
78969
|
-
};
|
|
78970
|
-
}
|
|
78971
|
-
var init_gateLedger = __esm({
|
|
78972
|
-
"node_modules/@sema-agent/client-core/dist/hitl/gateLedger.js"() {
|
|
78973
|
-
}
|
|
78974
|
-
});
|
|
78975
|
-
|
|
78976
79011
|
// node_modules/@sema-agent/client-core/dist/hitl/frameRouter.js
|
|
78977
79012
|
function rejectMessageForRender() {
|
|
78978
79013
|
return HITL_REJECT_MESSAGE;
|
|
@@ -79230,6 +79265,124 @@ var init_frameRouter = __esm({
|
|
|
79230
79265
|
}
|
|
79231
79266
|
});
|
|
79232
79267
|
|
|
79268
|
+
// node_modules/@sema-agent/client-core/dist/hitl/gateLedger.js
|
|
79269
|
+
function createGateLedger() {
|
|
79270
|
+
const startedCalls = /* @__PURE__ */ new Set();
|
|
79271
|
+
const endedCalls = /* @__PURE__ */ new Set();
|
|
79272
|
+
const heldAskEnds = /* @__PURE__ */ new Map();
|
|
79273
|
+
const gatedStartArgsByCall = /* @__PURE__ */ new Map();
|
|
79274
|
+
const deniedCalls = /* @__PURE__ */ new Set();
|
|
79275
|
+
const pendingFsCalls = [];
|
|
79276
|
+
const resolvedAnswers = /* @__PURE__ */ new Map();
|
|
79277
|
+
const decidedGates = /* @__PURE__ */ new Set();
|
|
79278
|
+
let lastFsOrShellGatedCall;
|
|
79279
|
+
let denyStampNextFsEnd = false;
|
|
79280
|
+
let seq;
|
|
79281
|
+
return {
|
|
79282
|
+
noteSeq(ev) {
|
|
79283
|
+
const rawSeq = ev.id ?? ev.seq;
|
|
79284
|
+
if (typeof rawSeq === "string" && rawSeq.length > 0)
|
|
79285
|
+
seq = rawSeq;
|
|
79286
|
+
else if (typeof rawSeq === "number" && Number.isFinite(rawSeq))
|
|
79287
|
+
seq = String(rawSeq);
|
|
79288
|
+
},
|
|
79289
|
+
lastSeq() {
|
|
79290
|
+
return seq;
|
|
79291
|
+
},
|
|
79292
|
+
markStarted(callId) {
|
|
79293
|
+
if (startedCalls.has(callId))
|
|
79294
|
+
return false;
|
|
79295
|
+
startedCalls.add(callId);
|
|
79296
|
+
return true;
|
|
79297
|
+
},
|
|
79298
|
+
noteGatedStart(callId, ev) {
|
|
79299
|
+
gatedStartArgsByCall.set(callId, ev.args);
|
|
79300
|
+
},
|
|
79301
|
+
gatedStartArgs() {
|
|
79302
|
+
return gatedStartArgsByCall;
|
|
79303
|
+
},
|
|
79304
|
+
isEnded(callId) {
|
|
79305
|
+
return endedCalls.has(callId);
|
|
79306
|
+
},
|
|
79307
|
+
markEnded(callId) {
|
|
79308
|
+
endedCalls.add(callId);
|
|
79309
|
+
},
|
|
79310
|
+
hold(callId, ev) {
|
|
79311
|
+
heldAskEnds.set(callId, ev);
|
|
79312
|
+
},
|
|
79313
|
+
dropHeld(callId) {
|
|
79314
|
+
heldAskEnds.delete(callId);
|
|
79315
|
+
},
|
|
79316
|
+
heldCount() {
|
|
79317
|
+
return heldAskEnds.size;
|
|
79318
|
+
},
|
|
79319
|
+
*flushHeld() {
|
|
79320
|
+
for (const [callId, held] of heldAskEnds) {
|
|
79321
|
+
endedCalls.add(callId);
|
|
79322
|
+
yield held;
|
|
79323
|
+
}
|
|
79324
|
+
heldAskEnds.clear();
|
|
79325
|
+
},
|
|
79326
|
+
markDenied(callId) {
|
|
79327
|
+
deniedCalls.add(callId);
|
|
79328
|
+
},
|
|
79329
|
+
isDenied(callId) {
|
|
79330
|
+
return deniedCalls.has(callId);
|
|
79331
|
+
},
|
|
79332
|
+
takeDenied(callId) {
|
|
79333
|
+
return deniedCalls.delete(callId);
|
|
79334
|
+
},
|
|
79335
|
+
armDenyStamp() {
|
|
79336
|
+
denyStampNextFsEnd = true;
|
|
79337
|
+
},
|
|
79338
|
+
takeDenyStamp() {
|
|
79339
|
+
if (!denyStampNextFsEnd)
|
|
79340
|
+
return false;
|
|
79341
|
+
denyStampNextFsEnd = false;
|
|
79342
|
+
return true;
|
|
79343
|
+
},
|
|
79344
|
+
pushFsCall(callId) {
|
|
79345
|
+
pendingFsCalls.push(callId);
|
|
79346
|
+
},
|
|
79347
|
+
dropFsCall(callId) {
|
|
79348
|
+
const at = pendingFsCalls.indexOf(callId);
|
|
79349
|
+
if (at !== -1)
|
|
79350
|
+
pendingFsCalls.splice(at, 1);
|
|
79351
|
+
},
|
|
79352
|
+
lastPendingFsCall() {
|
|
79353
|
+
return pendingFsCalls.length > 0 ? pendingFsCalls[pendingFsCalls.length - 1] : void 0;
|
|
79354
|
+
},
|
|
79355
|
+
noteFsOrShellGate(callId) {
|
|
79356
|
+
lastFsOrShellGatedCall = callId;
|
|
79357
|
+
},
|
|
79358
|
+
lastFsOrShellGatedCallId() {
|
|
79359
|
+
return lastFsOrShellGatedCall;
|
|
79360
|
+
},
|
|
79361
|
+
rememberAnswer(callId, answered) {
|
|
79362
|
+
resolvedAnswers.set(callId, answered);
|
|
79363
|
+
},
|
|
79364
|
+
answerFor(callId) {
|
|
79365
|
+
return resolvedAnswers.get(callId);
|
|
79366
|
+
},
|
|
79367
|
+
dropAnswer(callId) {
|
|
79368
|
+
resolvedAnswers.delete(callId);
|
|
79369
|
+
},
|
|
79370
|
+
markDecided(callId) {
|
|
79371
|
+
decidedGates.add(callId);
|
|
79372
|
+
},
|
|
79373
|
+
takeDecided(callId) {
|
|
79374
|
+
return decidedGates.delete(callId);
|
|
79375
|
+
},
|
|
79376
|
+
decidedCount() {
|
|
79377
|
+
return decidedGates.size;
|
|
79378
|
+
}
|
|
79379
|
+
};
|
|
79380
|
+
}
|
|
79381
|
+
var init_gateLedger = __esm({
|
|
79382
|
+
"node_modules/@sema-agent/client-core/dist/hitl/gateLedger.js"() {
|
|
79383
|
+
}
|
|
79384
|
+
});
|
|
79385
|
+
|
|
79233
79386
|
// node_modules/@sema-agent/client-core/dist/hitl/parkResolver.js
|
|
79234
79387
|
function isGateFailureCode(v2) {
|
|
79235
79388
|
return v2 === "no_pending" || v2 === "binding_mismatch" || v2 === "wrong_gate" || v2 === "bad_plan_edit";
|
|
@@ -81717,6 +81870,7 @@ var init_localeGeo = __esm({
|
|
|
81717
81870
|
var dist_exports = {};
|
|
81718
81871
|
__export(dist_exports, {
|
|
81719
81872
|
ABSENT_SETTLE_MS: () => ABSENT_SETTLE_MS,
|
|
81873
|
+
ACTIVE_RUN_BUSY_ERROR_CODE: () => ACTIVE_RUN_BUSY_ERROR_CODE,
|
|
81720
81874
|
ADAPTER_COVERAGE: () => ADAPTER_COVERAGE,
|
|
81721
81875
|
ADAPTER_DIVERGENCES: () => ADAPTER_DIVERGENCES,
|
|
81722
81876
|
ATTACHMENTS_ENV: () => ATTACHMENTS_ENV,
|
|
@@ -81737,6 +81891,11 @@ __export(dist_exports, {
|
|
|
81737
81891
|
CHROME_EVENT_KINDS: () => CHROME_EVENT_KINDS,
|
|
81738
81892
|
CLASSIFIER_DENY_SIGNATURE: () => CLASSIFIER_DENY_SIGNATURE,
|
|
81739
81893
|
CLIENT_VERBS: () => CLIENT_VERBS,
|
|
81894
|
+
CONFIG_LIMIT_INVALID: () => CONFIG_LIMIT_INVALID,
|
|
81895
|
+
CONFIG_LIMIT_UNKNOWN_KEY: () => CONFIG_LIMIT_UNKNOWN_KEY,
|
|
81896
|
+
CONFIG_REFUSAL_CODES: () => CONFIG_REFUSAL_CODES,
|
|
81897
|
+
CONFIG_STRATEGY_FIND_LIMIT_INVALID: () => CONFIG_STRATEGY_FIND_LIMIT_INVALID,
|
|
81898
|
+
CONFIG_STRATEGY_MAX_SIZE_INVALID: () => CONFIG_STRATEGY_MAX_SIZE_INVALID,
|
|
81740
81899
|
CONTEXT_LINES: () => CONTEXT_LINES,
|
|
81741
81900
|
CONTROL_TOOL_VERBS: () => CONTROL_TOOL_VERBS,
|
|
81742
81901
|
ControlRouter: () => ControlRouter,
|
|
@@ -81763,6 +81922,7 @@ __export(dist_exports, {
|
|
|
81763
81922
|
ENGINE_HANDS_BAND: () => ENGINE_HANDS_BAND,
|
|
81764
81923
|
ENGINE_RUNNER_FACE: () => ENGINE_RUNNER_FACE,
|
|
81765
81924
|
ENGINE_SCENARIO_EXTRAS_DEFAULT: () => ENGINE_SCENARIO_EXTRAS_DEFAULT,
|
|
81925
|
+
ENV_LIFETIME_EXPIRED: () => ENV_LIFETIME_EXPIRED,
|
|
81766
81926
|
FALLBACK_CONTEXT_WINDOW: () => FALLBACK_CONTEXT_WINDOW,
|
|
81767
81927
|
FINAL_VERIFY_YIELD_NOTICE: () => FINAL_VERIFY_YIELD_NOTICE,
|
|
81768
81928
|
FLEET_TASK_ROW_KEYS_NOT_PROJECTED: () => FLEET_TASK_ROW_KEYS_NOT_PROJECTED,
|
|
@@ -81790,6 +81950,10 @@ __export(dist_exports, {
|
|
|
81790
81950
|
HitlBridge: () => HitlBridge,
|
|
81791
81951
|
HitlSafetyError: () => HitlSafetyError,
|
|
81792
81952
|
IDLE_FLUSH_MS: () => IDLE_FLUSH_MS,
|
|
81953
|
+
LIMITS_MAX_COST_EXCEEDED: () => LIMITS_MAX_COST_EXCEEDED,
|
|
81954
|
+
LIMITS_MAX_TOKENS_EXCEEDED: () => LIMITS_MAX_TOKENS_EXCEEDED,
|
|
81955
|
+
LIMITS_MAX_TURNS_EXCEEDED: () => LIMITS_MAX_TURNS_EXCEEDED,
|
|
81956
|
+
LIMITS_MAX_WALLTIME_EXCEEDED: () => LIMITS_MAX_WALLTIME_EXCEEDED,
|
|
81793
81957
|
LIMITS_WIRE_MIN_ENGINE: () => LIMITS_WIRE_MIN_ENGINE,
|
|
81794
81958
|
LIVE_DEFAULT_FIELDS: () => LIVE_DEFAULT_FIELDS,
|
|
81795
81959
|
LOCAL_SESSIONS_SPEC: () => LOCAL_SESSIONS_SPEC,
|
|
@@ -81811,7 +81975,9 @@ __export(dist_exports, {
|
|
|
81811
81975
|
MAX_TURNS_MIN: () => MAX_TURNS_MIN,
|
|
81812
81976
|
MCP_CAPS: () => MCP_CAPS,
|
|
81813
81977
|
MIGRATED_COMPENSATIONS: () => MIGRATED_COMPENSATIONS,
|
|
81978
|
+
MODEL_FALLBACK_INHERIT_NO_TIER_BINDING: () => MODEL_FALLBACK_INHERIT_NO_TIER_BINDING,
|
|
81814
81979
|
MODEL_FAMILIES: () => MODEL_FAMILIES,
|
|
81980
|
+
OUTPUT_INVALID: () => OUTPUT_INVALID,
|
|
81815
81981
|
PANEL_TOOLUSES_LANE_POLICY: () => PANEL_TOOLUSES_LANE_POLICY,
|
|
81816
81982
|
PERMISSION_MODE_INTENTS: () => PERMISSION_MODE_INTENTS,
|
|
81817
81983
|
PLAN_REVIEW_APPROVE_LABEL: () => PLAN_REVIEW_APPROVE_LABEL,
|
|
@@ -81824,6 +81990,7 @@ __export(dist_exports, {
|
|
|
81824
81990
|
REJECT_MESSAGE: () => REJECT_MESSAGE,
|
|
81825
81991
|
REQUEST_FIELD_MATRIX: () => REQUEST_FIELD_MATRIX,
|
|
81826
81992
|
RETAIN_BACKGROUND_ENV: () => RETAIN_BACKGROUND_ENV,
|
|
81993
|
+
REWIND_ERROR_CODE_PREFIXES: () => REWIND_ERROR_CODE_PREFIXES,
|
|
81827
81994
|
SANDBOX_CASCADE_CONFLICT_400_ANCHOR: () => SANDBOX_CASCADE_CONFLICT_400_ANCHOR,
|
|
81828
81995
|
SANDBOX_K8S_ONLY_400_ANCHOR: () => SANDBOX_K8S_ONLY_400_ANCHOR,
|
|
81829
81996
|
SANDBOX_NO_IMAGE_INDEX_400_ANCHOR: () => SANDBOX_NO_IMAGE_INDEX_400_ANCHOR,
|
|
@@ -81848,6 +82015,13 @@ __export(dist_exports, {
|
|
|
81848
82015
|
SSE_GRACE_MIN_MS: () => SSE_GRACE_MIN_MS,
|
|
81849
82016
|
SSE_HEARTBEAT_GRACE_ENV: () => SSE_HEARTBEAT_GRACE_ENV,
|
|
81850
82017
|
START_SESSION_OPTION_KEYS: () => START_SESSION_OPTION_KEYS,
|
|
82018
|
+
STOP_CONFLICT_CODES: () => STOP_CONFLICT_CODES,
|
|
82019
|
+
STOP_NOT_LANDED: () => STOP_NOT_LANDED,
|
|
82020
|
+
STOP_NOT_LOCAL: () => STOP_NOT_LOCAL,
|
|
82021
|
+
STOP_PARKED: () => STOP_PARKED,
|
|
82022
|
+
STOP_PARK_ARBITER_UNREACHABLE: () => STOP_PARK_ARBITER_UNREACHABLE,
|
|
82023
|
+
STOP_PARK_RESUME_WON: () => STOP_PARK_RESUME_WON,
|
|
82024
|
+
STREAM_MAX_DURATION: () => STREAM_MAX_DURATION,
|
|
81851
82025
|
STRUCTURED_DETAIL_TYPES: () => STRUCTURED_DETAIL_TYPES,
|
|
81852
82026
|
SUBAGENT_TOOL_NAMES: () => SUBAGENT_TOOL_NAMES,
|
|
81853
82027
|
TASK_AGENT_WIRE_FIELDS: () => TASK_AGENT_WIRE_FIELDS,
|
|
@@ -81855,9 +82029,13 @@ __export(dist_exports, {
|
|
|
81855
82029
|
TERMINAL_RETAIN_MS: () => TERMINAL_RETAIN_MS,
|
|
81856
82030
|
TOCTOU_BINDING_KEYS: () => TOCTOU_BINDING_KEYS,
|
|
81857
82031
|
TOOL_APPROVAL_FRAME_KEYS_MIRROR: () => TOOL_APPROVAL_FRAME_KEYS_MIRROR,
|
|
82032
|
+
TOOL_END_INTERRUPTED_CODES: () => TOOL_END_INTERRUPTED_CODES,
|
|
82033
|
+
TOOL_END_INTERRUPTED_NEVER_STARTED: () => TOOL_END_INTERRUPTED_NEVER_STARTED,
|
|
82034
|
+
TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN: () => TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN,
|
|
81858
82035
|
TOOL_PERMISSION_DECISION_KEYS: () => TOOL_PERMISSION_DECISION_KEYS,
|
|
81859
82036
|
TOOL_PERMISSION_REQUEST_KEYS: () => TOOL_PERMISSION_REQUEST_KEYS,
|
|
81860
82037
|
TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT: () => TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT,
|
|
82038
|
+
USAGE_WINDOW_EXHAUSTED: () => USAGE_WINDOW_EXHAUSTED,
|
|
81861
82039
|
USER_EMAIL_ENV: () => USER_EMAIL_ENV,
|
|
81862
82040
|
WEBSEARCH_ENV: () => WEBSEARCH_ENV,
|
|
81863
82041
|
WEB_SEARCH_ENGINE_DEFAULTS: () => WEB_SEARCH_ENGINE_DEFAULTS,
|
|
@@ -81906,6 +82084,7 @@ __export(dist_exports, {
|
|
|
81906
82084
|
approvalCardPortMissesFor: () => approvalCardPortMissesFor,
|
|
81907
82085
|
armDetachCancel: () => armDetachCancel,
|
|
81908
82086
|
armPlanReviewApproval: () => armPlanReviewApproval,
|
|
82087
|
+
asModelFallbackReason: () => asModelFallbackReason,
|
|
81909
82088
|
assistantTaskToBackgroundRow: () => assistantTaskToBackgroundRow,
|
|
81910
82089
|
attachmentsForRequest: () => attachmentsForRequest,
|
|
81911
82090
|
awaitTaskAgentsWire: () => awaitTaskAgentsWire,
|
|
@@ -82067,6 +82246,7 @@ __export(dist_exports, {
|
|
|
82067
82246
|
isAllowedCatalogUrl: () => isAllowedCatalogUrl,
|
|
82068
82247
|
isAlreadyResolvedGateReason: () => isAlreadyResolvedGateReason,
|
|
82069
82248
|
isAttachmentUploadReceipt: () => isAttachmentUploadReceipt,
|
|
82249
|
+
isConfigRefusalCode: () => isConfigRefusalCode,
|
|
82070
82250
|
isDetachArmed: () => isDetachArmed,
|
|
82071
82251
|
isEngineCompactPending: () => isEngineCompactPending,
|
|
82072
82252
|
isEnginePanelTaskResident: () => isEnginePanelTaskResident,
|
|
@@ -82079,6 +82259,7 @@ __export(dist_exports, {
|
|
|
82079
82259
|
isFsApprovalGate: () => isFsApprovalGate,
|
|
82080
82260
|
isGoalStopHookWireArmed: () => isGoalStopHookWireArmed,
|
|
82081
82261
|
isHookNoticeFrame: () => isHookNoticeFrame,
|
|
82262
|
+
isInterruptedToolEndCode: () => isInterruptedToolEndCode,
|
|
82082
82263
|
isKnownWorkflowAgentTaskId: () => isKnownWorkflowAgentTaskId,
|
|
82083
82264
|
isLocalSessionEvent: () => isLocalSessionEvent,
|
|
82084
82265
|
isLocalSessionRecord: () => isLocalSessionRecord,
|
|
@@ -82086,6 +82267,7 @@ __export(dist_exports, {
|
|
|
82086
82267
|
isOwnEngineRun: () => isOwnEngineRun,
|
|
82087
82268
|
isOwnWorkflowRun: () => isOwnWorkflowRun,
|
|
82088
82269
|
isPlanReviewPark: () => isPlanReviewPark,
|
|
82270
|
+
isRewindFamilyCode: () => isRewindFamilyCode,
|
|
82089
82271
|
isRunStreamActive: () => isRunStreamActive,
|
|
82090
82272
|
isSeatModelCatalog: () => isSeatModelCatalog,
|
|
82091
82273
|
isSendMessageAck: () => isSendMessageAck,
|
|
@@ -82136,6 +82318,7 @@ __export(dist_exports, {
|
|
|
82136
82318
|
parentToolCallIdOf: () => parentToolCallIdOf,
|
|
82137
82319
|
parseBackgroundReceipt: () => parseBackgroundReceipt,
|
|
82138
82320
|
parseCatalogSources: () => parseCatalogSources,
|
|
82321
|
+
parseFinalVerifyArgv: () => parseFinalVerifyArgv,
|
|
82139
82322
|
parseLimitsArgv: () => parseLimitsArgv,
|
|
82140
82323
|
parseModelFacingBash: () => parseModelFacingBash,
|
|
82141
82324
|
parseModelFacingTaskOutput: () => parseModelFacingTaskOutput,
|
|
@@ -82174,6 +82357,7 @@ __export(dist_exports, {
|
|
|
82174
82357
|
publishQuestionFrameFor: () => publishQuestionFrameFor,
|
|
82175
82358
|
publishSubagentContentEvent: () => publishSubagentContentEvent,
|
|
82176
82359
|
pushSubagentLocalEcho: () => pushSubagentLocalEcho,
|
|
82360
|
+
readCompletedAgentCard: () => readCompletedAgentCard,
|
|
82177
82361
|
readEngineActiveBgTasks: () => readEngineActiveBgTasks,
|
|
82178
82362
|
readEngineActiveBgTasksFor: () => readEngineActiveBgTasksFor,
|
|
82179
82363
|
recordBgParentRun: () => recordBgParentRun,
|
|
@@ -82266,6 +82450,7 @@ __export(dist_exports, {
|
|
|
82266
82450
|
toCappedSpec: () => toCappedSpec,
|
|
82267
82451
|
toCcModelUsage: () => toCcModelUsage,
|
|
82268
82452
|
todoWriteToolUseResult: () => todoWriteToolUseResult,
|
|
82453
|
+
toolEndOutputText: () => toolEndOutputText,
|
|
82269
82454
|
toolEndResultToUserFrame: () => toolEndResultToUserFrame,
|
|
82270
82455
|
toolNameIsFsWrite: () => toolNameIsFsWrite,
|
|
82271
82456
|
toolNameIsShellExec: () => toolNameIsShellExec,
|
|
@@ -82324,6 +82509,7 @@ var init_dist = __esm({
|
|
|
82324
82509
|
init_sseIdleTriage();
|
|
82325
82510
|
init_engineWireSdk();
|
|
82326
82511
|
init_classifierVerdictWire();
|
|
82512
|
+
init_engineErrorCodes();
|
|
82327
82513
|
init_agentsWireCaps();
|
|
82328
82514
|
init_attachmentsWireCaps();
|
|
82329
82515
|
init_clientContextWireCaps();
|
|
@@ -82381,6 +82567,7 @@ var init_dist = __esm({
|
|
|
82381
82567
|
init_liveInitToolFace();
|
|
82382
82568
|
init_providerPresets2();
|
|
82383
82569
|
init_hitlBridge();
|
|
82570
|
+
init_frameRouter();
|
|
82384
82571
|
init_hitlHostSurface();
|
|
82385
82572
|
init_toolApprovalWire();
|
|
82386
82573
|
init_askGateWire();
|
|
@@ -130614,20 +130801,20 @@ function drainAdaptive(node, pending2, innerHeight) {
|
|
|
130614
130801
|
const step = abs <= SCROLL_INSTANT_THRESHOLD ? abs : abs < SCROLL_HIGH_PENDING ? SCROLL_STEP_MED : SCROLL_STEP_HIGH;
|
|
130615
130802
|
applied += sign * step;
|
|
130616
130803
|
const rem = abs - step;
|
|
130617
|
-
const
|
|
130804
|
+
const cap2 = Math.max(1, innerHeight - 1);
|
|
130618
130805
|
const totalAbs = Math.abs(applied);
|
|
130619
|
-
if (totalAbs >
|
|
130620
|
-
const excess = totalAbs -
|
|
130806
|
+
if (totalAbs > cap2) {
|
|
130807
|
+
const excess = totalAbs - cap2;
|
|
130621
130808
|
node.pendingScrollDelta = sign * (rem + excess);
|
|
130622
|
-
return sign *
|
|
130809
|
+
return sign * cap2;
|
|
130623
130810
|
}
|
|
130624
130811
|
node.pendingScrollDelta = rem > 0 ? sign * rem : void 0;
|
|
130625
130812
|
return applied;
|
|
130626
130813
|
}
|
|
130627
130814
|
function drainProportional(node, pending2, innerHeight) {
|
|
130628
130815
|
const abs = Math.abs(pending2);
|
|
130629
|
-
const
|
|
130630
|
-
const step = Math.min(
|
|
130816
|
+
const cap2 = Math.max(1, innerHeight - 1);
|
|
130817
|
+
const step = Math.min(cap2, Math.max(SCROLL_MIN_PER_FRAME, abs * 3 >> 2));
|
|
130631
130818
|
if (abs <= step) {
|
|
130632
130819
|
node.pendingScrollDelta = void 0;
|
|
130633
130820
|
return pending2;
|
|
@@ -136121,7 +136308,7 @@ function activeRunBusySignal2(ev) {
|
|
|
136121
136308
|
const activeTaskId = "activeTaskId" in carrier ? carrier.activeTaskId : void 0;
|
|
136122
136309
|
const activeTaskStatus = "activeTaskStatus" in carrier ? carrier.activeTaskStatus : void 0;
|
|
136123
136310
|
const rawGate = "pendingGate" in carrier ? carrier.pendingGate : void 0;
|
|
136124
|
-
const codeHit = errorCode ===
|
|
136311
|
+
const codeHit = errorCode === ACTIVE_RUN_BUSY_ERROR_CODE;
|
|
136125
136312
|
const handle2 = typeof activeTaskId === "string" && activeTaskId.length > 0 ? activeTaskId : null;
|
|
136126
136313
|
if (!codeHit && handle2 === null) return null;
|
|
136127
136314
|
let pendingGate = null;
|
|
@@ -136203,15 +136390,42 @@ async function attemptActiveRunSelfHeal(signal, runs, deps2) {
|
|
|
136203
136390
|
}
|
|
136204
136391
|
return { kind: "healed", taskId, status: status3 };
|
|
136205
136392
|
}
|
|
136206
|
-
function
|
|
136207
|
-
return
|
|
136393
|
+
function gateKindPhrase(kind) {
|
|
136394
|
+
return kind ? `a ${kind} decision` : "a decision";
|
|
136395
|
+
}
|
|
136396
|
+
function decidePathClause(signal) {
|
|
136397
|
+
const decidePath = signal?.pendingGate?.decidePath;
|
|
136398
|
+
if (!decidePath) return "";
|
|
136399
|
+
return ` The engine says that run is waiting on ${gateKindPhrase(signal?.pendingGate?.kind)} and that it is decided at POST ${decidePath} \u2014 deciding it releases the session.`;
|
|
136400
|
+
}
|
|
136401
|
+
function healedCostClause(signal) {
|
|
136402
|
+
const gate = signal?.pendingGate;
|
|
136403
|
+
if (gate) return `it was waiting on ${gateKindPhrase(gate.kind)}, so that decision was declined`;
|
|
136404
|
+
if (signal?.activeTaskStatus)
|
|
136405
|
+
return "the engine reported no decision pending on it (a stale park), so nothing was decided on your behalf";
|
|
136406
|
+
return "the engine did not report what it was waiting on, so anything still pending on it is now gone";
|
|
136407
|
+
}
|
|
136408
|
+
function activeRunSelfHealRow(outcome, signal) {
|
|
136409
|
+
const base = activeRunSelfHealBaseRow(outcome, signal);
|
|
136410
|
+
switch (outcome.kind) {
|
|
136411
|
+
// 这四条是「用户此刻卡住了、而且没有别的把手」的结局 —— wire 给的 decide 入口在这里才有用。
|
|
136412
|
+
case "not-parked":
|
|
136413
|
+
case "state-unknown":
|
|
136414
|
+
case "cancel-failed":
|
|
136415
|
+
case "budget-exhausted":
|
|
136416
|
+
return base + decidePathClause(signal);
|
|
136417
|
+
// healed = 已经解开了;两条 plan-review 臂与 decision-pending 手上都另有一张更好的把手
|
|
136418
|
+
// (重开的卡 / 已开的卡 / 基句自己渲的 decidePath)—— 再叠一条引擎路由只会稀释那一个动作。
|
|
136419
|
+
default:
|
|
136420
|
+
return base;
|
|
136421
|
+
}
|
|
136208
136422
|
}
|
|
136209
|
-
function activeRunSelfHealBaseRow(outcome) {
|
|
136423
|
+
function activeRunSelfHealBaseRow(outcome, signal) {
|
|
136210
136424
|
switch (outcome.kind) {
|
|
136211
136425
|
case "decision-pending":
|
|
136212
136426
|
return `This session is held by an earlier turn${outcome.taskId ? ` (run ${outcome.taskId})` : ""} that is waiting on a decision you have not made yet, and there is a decision card open for it. sema did NOT cancel it \u2014 answering that card is what releases the session, and cancelling would decide it for you. Your message was NOT sent; answer the open card and send it again.`;
|
|
136213
136427
|
case "healed": {
|
|
136214
|
-
const cost2 =
|
|
136428
|
+
const cost2 = healedCostClause(signal);
|
|
136215
136429
|
void outcome.status;
|
|
136216
136430
|
return `Your previous turn was parked (run ${outcome.taskId}) and was still holding this session, so nothing new could start \u2014 ${cost2}. sema cancelled that parked run and re-sent this message.`;
|
|
136217
136431
|
}
|
|
@@ -136222,6 +136436,9 @@ function activeRunSelfHealBaseRow(outcome) {
|
|
|
136222
136436
|
return `The previous turn is parked waiting for a plan review (run ${outcome.taskId}) and sema could not reopen that approval card. It did NOT cancel the run \u2014 that would have discarded the plan for you. Your message was NOT sent; ${INTERACTIVE_WAY_OUT} if you no longer want that plan.${viaEngine}`;
|
|
136223
136437
|
}
|
|
136224
136438
|
case "not-parked":
|
|
136439
|
+
if (signal?.pendingGate) {
|
|
136440
|
+
return `This session is held by an earlier run (run ${outcome.taskId}, status ${outcome.status}) that is waiting on ${gateKindPhrase(signal.pendingGate.kind)} \u2014 it will not finish on its own. sema did NOT cancel it, because cancelling would decide that item for you. Your message was NOT sent; ${INTERACTIVE_WAY_OUT} if you no longer want it.`;
|
|
136441
|
+
}
|
|
136225
136442
|
return `This session already has a run in flight (run ${outcome.taskId}, status ${outcome.status}) \u2014 most likely a turn you sent to the background. sema did NOT cancel it, because that would throw away work you asked for. Wait for it to finish, or ${INTERACTIVE_WAY_OUT}.`;
|
|
136226
136443
|
case "state-unknown":
|
|
136227
136444
|
return `This session is locked by an earlier run${outcome.taskId ? ` (run ${outcome.taskId})` : ""} and sema could not read that run's state, so it did not touch it (${outcome.detail}). Your message was NOT sent. This session cannot start a new turn until that run settles \u2014 ${INTERACTIVE_WAY_OUT}.`;
|
|
@@ -136231,14 +136448,25 @@ function activeRunSelfHealBaseRow(outcome) {
|
|
|
136231
136448
|
return `This session is still locked${outcome.taskId ? ` by run ${outcome.taskId}` : ""} after sema already cancelled one parked run for this message. Not retrying again (a second automatic cancel would only spin). Your message was NOT sent \u2014 ${INTERACTIVE_WAY_OUT}.`;
|
|
136232
136449
|
}
|
|
136233
136450
|
}
|
|
136234
|
-
function activeRunBusyHeadlessRow(
|
|
136451
|
+
function activeRunBusyHeadlessRow(signal) {
|
|
136452
|
+
const activeTaskId = signal.activeTaskId;
|
|
136235
136453
|
const handle2 = activeTaskId ? ` (run ${activeTaskId})` : "";
|
|
136236
|
-
|
|
136454
|
+
const cancelPath = `POST /v1/runs/${activeTaskId ?? "<id>"}/cancel`;
|
|
136455
|
+
const status3 = signal.activeTaskStatus;
|
|
136456
|
+
const decidePath = signal.pendingGate?.decidePath ?? null;
|
|
136457
|
+
const freshSession = "start a new session (drop --resume/--continue)";
|
|
136458
|
+
if (decidePath) {
|
|
136459
|
+
return `This session is held by an earlier run${handle2}${status3 ? ` (status ${status3})` : ""} that is parked waiting on ${gateKindPhrase(signal.pendingGate?.kind)}, so this message was NOT sent. Decide it and the session unlocks: POST ${decidePath}. Cancelling instead (${cancelPath}) also unlocks it, but it decides that item against you. Or ${freshSession}.`;
|
|
136460
|
+
}
|
|
136461
|
+
if (status3) {
|
|
136462
|
+
return `This session is held by an earlier run${handle2} with status ${status3}, so this message was NOT sent. The engine reported no decision pending on that run: if it is still working, wait for it to finish; if it will never settle, release it with ${cancelPath} (that discards whatever it was doing). Or ${freshSession}.`;
|
|
136463
|
+
}
|
|
136464
|
+
return `This session is locked by an earlier run${handle2} that was never released, so this message was NOT sent. Nothing here clears on its own. Start a new session (drop --resume/--continue), or release the run on the engine: ${cancelPath}`;
|
|
136237
136465
|
}
|
|
136238
|
-
var
|
|
136466
|
+
var PLAN_REVIEW_STATES, ASK_PARK_STATES, ACTIVE_RUN_SELF_HEAL_MAX_ATTEMPTS, INTERACTIVE_WAY_OUT;
|
|
136239
136467
|
var init_activeRunSelfHeal = __esm({
|
|
136240
136468
|
"build-src/src/sema/activeRunSelfHeal.ts"() {
|
|
136241
|
-
|
|
136469
|
+
init_dist();
|
|
136242
136470
|
PLAN_REVIEW_STATES = ["needs_review"];
|
|
136243
136471
|
ASK_PARK_STATES = ["suspended"];
|
|
136244
136472
|
ACTIVE_RUN_SELF_HEAL_MAX_ATTEMPTS = 1;
|
|
@@ -136277,6 +136505,8 @@ var init_lastTurnUsageStore = __esm({
|
|
|
136277
136505
|
// build-src/src/seam/adapter/runStream.ts
|
|
136278
136506
|
var runStream_exports = {};
|
|
136279
136507
|
__export(runStream_exports, {
|
|
136508
|
+
_resetHostDroppedFrameMemoForTest: () => _resetHostDroppedFrameMemoForTest,
|
|
136509
|
+
hostDroppedFrameSink: () => hostDroppedFrameSink,
|
|
136280
136510
|
isRunStreamActive: () => isRunStreamActive,
|
|
136281
136511
|
runStream: () => runStream2
|
|
136282
136512
|
});
|
|
@@ -136300,7 +136530,7 @@ function rewriteActiveRunBusyRow(msgs, seen2) {
|
|
|
136300
136530
|
...m2,
|
|
136301
136531
|
message: {
|
|
136302
136532
|
...envelope,
|
|
136303
|
-
content: [{ type: "text", text: activeRunBusyHeadlessRow(busy
|
|
136533
|
+
content: [{ type: "text", text: activeRunBusyHeadlessRow(busy) }]
|
|
136304
136534
|
}
|
|
136305
136535
|
};
|
|
136306
136536
|
continue;
|
|
@@ -136322,20 +136552,47 @@ function hostSink(e) {
|
|
|
136322
136552
|
});
|
|
136323
136553
|
}
|
|
136324
136554
|
}
|
|
136555
|
+
function consoleLegForDroppedFrame(type, line) {
|
|
136556
|
+
if (reportedDroppedTypes2.has(type)) return;
|
|
136557
|
+
if (reportedDroppedTypes2.size < DROPPED_TYPE_MEMO_CAP2) reportedDroppedTypes2.add(type);
|
|
136558
|
+
console.error(line);
|
|
136559
|
+
}
|
|
136560
|
+
function _resetHostDroppedFrameMemoForTest() {
|
|
136561
|
+
reportedDroppedTypes2.clear();
|
|
136562
|
+
}
|
|
136563
|
+
function hostDroppedFrameSink(info) {
|
|
136564
|
+
const clean = (v2) => (
|
|
136565
|
+
// eslint-disable-next-line no-control-regex
|
|
136566
|
+
String(v2).replace(/[\x00-\x1f\x7f]/g, ".").slice(0, 120)
|
|
136567
|
+
);
|
|
136568
|
+
const type = clean(info.type);
|
|
136569
|
+
const line = `[sema][wire] dropped engine frame: type=${type} why=${clean(info.why)} \u2014 this build's projector has no arm for it (engine newer than the client, or a malformed frame). It renders NOWHERE.`;
|
|
136570
|
+
void Promise.resolve().then(() => (init_debug(), debug_exports)).then((m2) => {
|
|
136571
|
+
m2.logForDebugging(line, { level: "warn" });
|
|
136572
|
+
if (!m2.isDebugMode() && process.env.USER_TYPE !== "ant") consoleLegForDroppedFrame(type, line);
|
|
136573
|
+
}).catch(() => consoleLegForDroppedFrame(type, line));
|
|
136574
|
+
}
|
|
136325
136575
|
function runStream2(events3, ctx, handle2 = {}) {
|
|
136326
136576
|
const seen2 = { busy: null };
|
|
136327
136577
|
const projected2 = runStream(
|
|
136328
136578
|
watchActiveRunBusy(events3, seen2),
|
|
136329
|
-
{
|
|
136579
|
+
{
|
|
136580
|
+
...ctx,
|
|
136581
|
+
emitChrome: ctx.emitChrome ?? hostSink,
|
|
136582
|
+
onDroppedFrame: ctx.onDroppedFrame ?? hostDroppedFrameSink
|
|
136583
|
+
},
|
|
136330
136584
|
handle2
|
|
136331
136585
|
);
|
|
136332
136586
|
return rewriteActiveRunBusyRow(projected2, seen2);
|
|
136333
136587
|
}
|
|
136588
|
+
var reportedDroppedTypes2, DROPPED_TYPE_MEMO_CAP2;
|
|
136334
136589
|
var init_runStream2 = __esm({
|
|
136335
136590
|
"build-src/src/seam/adapter/runStream.ts"() {
|
|
136336
136591
|
init_dist();
|
|
136337
136592
|
init_activeRunSelfHeal();
|
|
136338
136593
|
init_dist();
|
|
136594
|
+
reportedDroppedTypes2 = /* @__PURE__ */ new Set();
|
|
136595
|
+
DROPPED_TYPE_MEMO_CAP2 = 64;
|
|
136339
136596
|
}
|
|
136340
136597
|
});
|
|
136341
136598
|
|
|
@@ -137682,79 +137939,6 @@ var init_textModeError = __esm({
|
|
|
137682
137939
|
}
|
|
137683
137940
|
});
|
|
137684
137941
|
|
|
137685
|
-
// build-src/src/sema/subagentDurablePause.ts
|
|
137686
|
-
function detectDurablePauseReport(text2) {
|
|
137687
|
-
const m2 = DURABLE_PAUSE_RE.exec(text2);
|
|
137688
|
-
if (m2 === null) return null;
|
|
137689
|
-
return {
|
|
137690
|
-
status: m2[1],
|
|
137691
|
-
checkpointToken: m2[2] ?? "?",
|
|
137692
|
-
lane: m2[3] === "fork" ? "fork" : "delegation"
|
|
137693
|
-
};
|
|
137694
|
-
}
|
|
137695
|
-
function honestDurablePauseReport(text2, facts) {
|
|
137696
|
-
const what = facts.lane === "fork" ? "fork" : "delegation";
|
|
137697
|
-
return text2.replace(
|
|
137698
|
-
DURABLE_PAUSE_RE,
|
|
137699
|
-
`status: paused
|
|
137700
|
-
paused: the sub-agent stopped at an approval gate and durably paused (${facts.status}). It is waiting for a human decision \u2014 this is NOT a task failure and NOT a tool error.
|
|
137701
|
-
checkpoint: ${facts.checkpointToken}
|
|
137702
|
-
what to do: a nested (sub-agent) durable pause cannot be adjudicated from inside this ${what}, so re-issuing the same approval-gated action will park again. Tell the user the gate is waiting (quote the checkpoint above), and either have the action pre-approved / the permission mode widened before re-running the ${what}, or take a route that does not need that gate. Do NOT report this to the user as a plain failure.`
|
|
137703
|
-
);
|
|
137704
|
-
}
|
|
137705
|
-
function toolResultText(content) {
|
|
137706
|
-
if (typeof content === "string") return content;
|
|
137707
|
-
if (!Array.isArray(content)) return null;
|
|
137708
|
-
const parts = [];
|
|
137709
|
-
for (const b3 of content) {
|
|
137710
|
-
const bb = b3;
|
|
137711
|
-
if (bb?.type === "text" && typeof bb.text === "string") parts.push(bb.text);
|
|
137712
|
-
}
|
|
137713
|
-
return parts.length > 0 ? parts.join("") : null;
|
|
137714
|
-
}
|
|
137715
|
-
function rewriteToolResultContent(content, next) {
|
|
137716
|
-
if (typeof content === "string") return next;
|
|
137717
|
-
if (!Array.isArray(content)) return content;
|
|
137718
|
-
let done = false;
|
|
137719
|
-
return content.map((b3) => {
|
|
137720
|
-
const bb = b3;
|
|
137721
|
-
if (done || bb?.type !== "text" || typeof bb.text !== "string") return b3;
|
|
137722
|
-
done = true;
|
|
137723
|
-
return { ...bb, text: next };
|
|
137724
|
-
});
|
|
137725
|
-
}
|
|
137726
|
-
function reduceSubagentDurablePauseEnvelope(msg) {
|
|
137727
|
-
if (msg.type !== "user") return msg;
|
|
137728
|
-
const message = msg.message;
|
|
137729
|
-
const content = message?.content;
|
|
137730
|
-
if (!Array.isArray(content)) return msg;
|
|
137731
|
-
let changed = false;
|
|
137732
|
-
const next = content.map((block2) => {
|
|
137733
|
-
const b3 = block2;
|
|
137734
|
-
if (b3?.type !== "tool_result") return block2;
|
|
137735
|
-
const text2 = toolResultText(b3.content);
|
|
137736
|
-
if (text2 === null) return block2;
|
|
137737
|
-
const facts = detectDurablePauseReport(text2);
|
|
137738
|
-
if (facts === null) return block2;
|
|
137739
|
-
changed = true;
|
|
137740
|
-
return {
|
|
137741
|
-
...b3,
|
|
137742
|
-
content: rewriteToolResultContent(b3.content, honestDurablePauseReport(text2, facts)),
|
|
137743
|
-
// 🔴 承重位:这是把 park 接回「UserToolResultMessage 的 `if (param.is_error)` →
|
|
137744
|
-
// renderToolUseErrorMessage」那条真会上屏的臂的唯一开关。删了它 = 退回零渲染(病象复发)。
|
|
137745
|
-
is_error: true
|
|
137746
|
-
};
|
|
137747
|
-
});
|
|
137748
|
-
if (!changed) return msg;
|
|
137749
|
-
return { ...msg, message: { ...message, content: next } };
|
|
137750
|
-
}
|
|
137751
|
-
var DURABLE_PAUSE_RE;
|
|
137752
|
-
var init_subagentDurablePause = __esm({
|
|
137753
|
-
"build-src/src/sema/subagentDurablePause.ts"() {
|
|
137754
|
-
DURABLE_PAUSE_RE = /\bstatus: failed\n(?:error: )?unexpected durable pause \((suspended|needs_review), checkpoint ([^)]*)\) — treat this (delegation|fork) as failed; do not retry (?:with )?the same (?:approval-)?gated action\./;
|
|
137755
|
-
}
|
|
137756
|
-
});
|
|
137757
|
-
|
|
137758
137942
|
// build-src/src/sema/appStateRef.ts
|
|
137759
137943
|
var appStateRef_exports = {};
|
|
137760
137944
|
__export(appStateRef_exports, {
|
|
@@ -167543,12 +167727,12 @@ function getContextWindowForModel(model, betas) {
|
|
|
167543
167727
|
if (has1mContext(model)) {
|
|
167544
167728
|
return 1e6;
|
|
167545
167729
|
}
|
|
167546
|
-
const
|
|
167547
|
-
if (
|
|
167548
|
-
if (
|
|
167730
|
+
const cap2 = getModelCapability(model);
|
|
167731
|
+
if (cap2?.max_input_tokens && cap2.max_input_tokens >= 1e5) {
|
|
167732
|
+
if (cap2.max_input_tokens > MODEL_CONTEXT_WINDOW_DEFAULT && is1mContextDisabled()) {
|
|
167549
167733
|
return MODEL_CONTEXT_WINDOW_DEFAULT;
|
|
167550
167734
|
}
|
|
167551
|
-
return
|
|
167735
|
+
return cap2.max_input_tokens;
|
|
167552
167736
|
}
|
|
167553
167737
|
if (betas?.includes(CONTEXT_1M_BETA_HEADER) && modelSupports1M(model)) {
|
|
167554
167738
|
return 1e6;
|
|
@@ -167637,9 +167821,9 @@ function getModelMaxOutputTokens(model) {
|
|
|
167637
167821
|
defaultTokens = MAX_OUTPUT_TOKENS_DEFAULT;
|
|
167638
167822
|
upperLimit = MAX_OUTPUT_TOKENS_UPPER_LIMIT;
|
|
167639
167823
|
}
|
|
167640
|
-
const
|
|
167641
|
-
if (
|
|
167642
|
-
upperLimit =
|
|
167824
|
+
const cap2 = getModelCapability(model);
|
|
167825
|
+
if (cap2?.max_tokens && cap2.max_tokens >= 4096) {
|
|
167826
|
+
upperLimit = cap2.max_tokens;
|
|
167643
167827
|
defaultTokens = Math.min(defaultTokens, upperLimit);
|
|
167644
167828
|
}
|
|
167645
167829
|
return { default: defaultTokens, upperLimit };
|
|
@@ -223277,59 +223461,6 @@ var init_rewindAnchorSidecar = __esm({
|
|
|
223277
223461
|
list() {
|
|
223278
223462
|
return [...this.index.entries()].map(([uuid8, taskId]) => ({ uuid: uuid8, taskId }));
|
|
223279
223463
|
}
|
|
223280
|
-
/**
|
|
223281
|
-
* Drop all anchors whose record belongs to `shellSessionId` and rewrite the file (compaction — the only
|
|
223282
|
-
* non-append operation, rare: used on /clear or session delete). Reads existing records, filters, atomic
|
|
223283
|
-
* temp+rename. Best-effort.
|
|
223284
|
-
*/
|
|
223285
|
-
deleteBySession(shellSessionId) {
|
|
223286
|
-
if (!this.path) {
|
|
223287
|
-
return;
|
|
223288
|
-
}
|
|
223289
|
-
let raw2;
|
|
223290
|
-
try {
|
|
223291
|
-
raw2 = readFileSync18(this.path, "utf8");
|
|
223292
|
-
} catch {
|
|
223293
|
-
return;
|
|
223294
|
-
}
|
|
223295
|
-
const kept = [];
|
|
223296
|
-
const droppedUuids = /* @__PURE__ */ new Set();
|
|
223297
|
-
for (const line of raw2.split("\n")) {
|
|
223298
|
-
if (line.length === 0) continue;
|
|
223299
|
-
try {
|
|
223300
|
-
const rec = JSON.parse(line);
|
|
223301
|
-
if (!rec || typeof rec.uuid !== "string") continue;
|
|
223302
|
-
if (rec.shellSessionId === shellSessionId) {
|
|
223303
|
-
droppedUuids.add(rec.uuid);
|
|
223304
|
-
} else {
|
|
223305
|
-
kept.push(rec);
|
|
223306
|
-
}
|
|
223307
|
-
} catch {
|
|
223308
|
-
}
|
|
223309
|
-
}
|
|
223310
|
-
for (const uuid8 of droppedUuids) this.index.delete(uuid8);
|
|
223311
|
-
const body = kept.map((r) => JSON.stringify(r) + "\n").join("");
|
|
223312
|
-
const tmp = `${this.path}.tmp-${process.pid}`;
|
|
223313
|
-
let release2;
|
|
223314
|
-
try {
|
|
223315
|
-
release2 = lockSyncRetry(this.path, LOCK_OPTS);
|
|
223316
|
-
} catch {
|
|
223317
|
-
release2 = void 0;
|
|
223318
|
-
}
|
|
223319
|
-
try {
|
|
223320
|
-
writeFileSync10(tmp, body, { mode: 384 });
|
|
223321
|
-
renameSync9(tmp, this.path);
|
|
223322
|
-
} catch (err8) {
|
|
223323
|
-
logForDebugging3(`rewindAnchorSidecar: compaction failed: ${err8}`);
|
|
223324
|
-
} finally {
|
|
223325
|
-
if (release2) {
|
|
223326
|
-
try {
|
|
223327
|
-
release2();
|
|
223328
|
-
} catch {
|
|
223329
|
-
}
|
|
223330
|
-
}
|
|
223331
|
-
}
|
|
223332
|
-
}
|
|
223333
223464
|
/**
|
|
223334
223465
|
* Clear ALL anchors for the current sidecar file (it is per-session — filename = sessionId), truncating
|
|
223335
223466
|
* the file to empty. Used on /clear. Atomic temp+rename. Best-effort.
|
|
@@ -224758,6 +224889,38 @@ var init_apiErrorSupplement = __esm({
|
|
|
224758
224889
|
}
|
|
224759
224890
|
});
|
|
224760
224891
|
|
|
224892
|
+
// build-src/src/sema/atMentionAttachmentWire.ts
|
|
224893
|
+
function collectSubmissionAttachmentTexts(msgs, submitted, normalize20) {
|
|
224894
|
+
const anchorIdx = msgs.lastIndexOf(submitted);
|
|
224895
|
+
if (anchorIdx < 0) return { ok: true, texts: [] };
|
|
224896
|
+
const out6 = [];
|
|
224897
|
+
for (let i = anchorIdx + 1; i < msgs.length; i++) {
|
|
224898
|
+
const m2 = msgs[i];
|
|
224899
|
+
if (m2?.type === "assistant") break;
|
|
224900
|
+
if (m2?.type !== "attachment" || !m2.attachment) continue;
|
|
224901
|
+
let projected2;
|
|
224902
|
+
try {
|
|
224903
|
+
projected2 = normalize20(m2.attachment);
|
|
224904
|
+
} catch (e) {
|
|
224905
|
+
return { ok: false, reason: `malformed attachment payload: ${String(e)}` };
|
|
224906
|
+
}
|
|
224907
|
+
for (const am of projected2) {
|
|
224908
|
+
const c2 = am?.message?.content;
|
|
224909
|
+
if (typeof c2 === "string") out6.push(c2);
|
|
224910
|
+
else if (Array.isArray(c2)) {
|
|
224911
|
+
for (const b3 of c2) {
|
|
224912
|
+
if (b3?.type === "text" && typeof b3.text === "string" && b3.text.trim().length > 0) out6.push(b3.text);
|
|
224913
|
+
}
|
|
224914
|
+
}
|
|
224915
|
+
}
|
|
224916
|
+
}
|
|
224917
|
+
return { ok: true, texts: out6 };
|
|
224918
|
+
}
|
|
224919
|
+
var init_atMentionAttachmentWire = __esm({
|
|
224920
|
+
"build-src/src/sema/atMentionAttachmentWire.ts"() {
|
|
224921
|
+
}
|
|
224922
|
+
});
|
|
224923
|
+
|
|
224761
224924
|
// build-src/src/sema/engineRuntimeStatus.ts
|
|
224762
224925
|
var engineRuntimeStatus_exports = {};
|
|
224763
224926
|
__export(engineRuntimeStatus_exports, {
|
|
@@ -226808,6 +226971,8 @@ function resetDeadRespawnStateForTests() {
|
|
|
226808
226971
|
recentDeathTimestamps = [];
|
|
226809
226972
|
cooldownRetryPending = false;
|
|
226810
226973
|
cooldownRetryLevel = 0;
|
|
226974
|
+
cooldownRetriesUsed = 0;
|
|
226975
|
+
cooldownSpentMs = 0;
|
|
226811
226976
|
cooldownRetryFire = void 0;
|
|
226812
226977
|
cooldownRetryAt = 0;
|
|
226813
226978
|
lastRespawnOkAt = null;
|
|
@@ -226826,18 +226991,8 @@ function stampFailedNextRetryAt() {
|
|
|
226826
226991
|
} catch {
|
|
226827
226992
|
}
|
|
226828
226993
|
}
|
|
226829
|
-
function
|
|
226830
|
-
|
|
226831
|
-
stampFailedNextRetryAt();
|
|
226832
|
-
return;
|
|
226833
|
-
}
|
|
226834
|
-
cooldownRetryPending = true;
|
|
226835
|
-
const delay = nextCooldownDelayMs();
|
|
226836
|
-
cooldownRetryLevel++;
|
|
226837
|
-
logForDebugging(
|
|
226838
|
-
`[engine-lifecycle] engine auto-restart parked \u2014 cooldown retry scheduled in ${Math.round(delay / 1e3)}s`
|
|
226839
|
-
);
|
|
226840
|
-
const fire = () => {
|
|
226994
|
+
function makeCooldownFire(deps2) {
|
|
226995
|
+
return () => {
|
|
226841
226996
|
cooldownRetryPending = false;
|
|
226842
226997
|
cooldownRetryFire = void 0;
|
|
226843
226998
|
cooldownRetryAt = 0;
|
|
@@ -226850,6 +227005,33 @@ function scheduleCooldownRetry(deps2) {
|
|
|
226850
227005
|
void runEngineDeadRespawn(deps2).catch(() => {
|
|
226851
227006
|
});
|
|
226852
227007
|
};
|
|
227008
|
+
}
|
|
227009
|
+
function giveUpOnAutoRestart(deps2) {
|
|
227010
|
+
cooldownRetryAt = 0;
|
|
227011
|
+
cooldownRetryFire = makeCooldownFire(deps2);
|
|
227012
|
+
const spentMin = Math.max(1, Math.round(cooldownSpentMs / 6e4));
|
|
227013
|
+
const detail = `automatic engine restart gave up after ${cooldownRetriesUsed} cooldown attempts over ~${spentMin} minutes \u2014 sema is not retrying on its own any more. Send a message to retry now, run sema doctor, or restart sema.`;
|
|
227014
|
+
logForDebugging(`[engine-lifecycle] ${detail}`);
|
|
227015
|
+
setEngineRuntimeStatus({ phase: "failed", detail });
|
|
227016
|
+
}
|
|
227017
|
+
function scheduleCooldownRetry(deps2) {
|
|
227018
|
+
if (cooldownRetryPending) {
|
|
227019
|
+
stampFailedNextRetryAt();
|
|
227020
|
+
return;
|
|
227021
|
+
}
|
|
227022
|
+
if (cooldownRetriesUsed >= CRASH_LOOP_COOLDOWN_MAX_RETRIES) {
|
|
227023
|
+
giveUpOnAutoRestart(deps2);
|
|
227024
|
+
return;
|
|
227025
|
+
}
|
|
227026
|
+
cooldownRetryPending = true;
|
|
227027
|
+
const delay = nextCooldownDelayMs();
|
|
227028
|
+
cooldownRetryLevel++;
|
|
227029
|
+
cooldownRetriesUsed++;
|
|
227030
|
+
cooldownSpentMs += delay;
|
|
227031
|
+
logForDebugging(
|
|
227032
|
+
`[engine-lifecycle] engine auto-restart parked \u2014 cooldown retry ${cooldownRetriesUsed}/${CRASH_LOOP_COOLDOWN_MAX_RETRIES} scheduled in ${Math.round(delay / 1e3)}s`
|
|
227033
|
+
);
|
|
227034
|
+
const fire = makeCooldownFire(deps2);
|
|
226853
227035
|
cooldownRetryFire = fire;
|
|
226854
227036
|
cooldownRetryAt = Date.now() + delay;
|
|
226855
227037
|
stampFailedNextRetryAt();
|
|
@@ -226861,9 +227043,11 @@ function scheduleCooldownRetry(deps2) {
|
|
|
226861
227043
|
if (typeof cooldownRetryTimer.unref === "function") cooldownRetryTimer.unref();
|
|
226862
227044
|
}
|
|
226863
227045
|
function requestEngineRetryNow() {
|
|
226864
|
-
if (!
|
|
227046
|
+
if (!cooldownRetryFire) return false;
|
|
226865
227047
|
if (deadRespawnInFlight) return false;
|
|
226866
227048
|
logForDebugging("[engine-lifecycle] manual retry-now requested \u2014 firing the parked cooldown retry immediately");
|
|
227049
|
+
cooldownRetriesUsed = 0;
|
|
227050
|
+
cooldownSpentMs = 0;
|
|
226867
227051
|
cooldownRetryFire();
|
|
226868
227052
|
return true;
|
|
226869
227053
|
}
|
|
@@ -226884,6 +227068,8 @@ async function runEngineDeadRespawn(deps2) {
|
|
|
226884
227068
|
const t2 = now2();
|
|
226885
227069
|
if (lastRespawnOkAt !== null && t2 - lastRespawnOkAt >= CRASH_LOOP_WINDOW_MS) {
|
|
226886
227070
|
cooldownRetryLevel = 0;
|
|
227071
|
+
cooldownRetriesUsed = 0;
|
|
227072
|
+
cooldownSpentMs = 0;
|
|
226887
227073
|
}
|
|
226888
227074
|
recentDeathTimestamps = recentDeathTimestamps.filter((d4) => t2 - d4 < CRASH_LOOP_WINDOW_MS);
|
|
226889
227075
|
recentDeathTimestamps.push(t2);
|
|
@@ -227164,7 +227350,7 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
227164
227350
|
}
|
|
227165
227351
|
return !isProcessAlive(pid);
|
|
227166
227352
|
}
|
|
227167
|
-
var PORT_FILE_VERSION, HEALTH_POLL_INTERVAL_MS, HEALTH_POLL_MAX_ATTEMPTS, HEALTH_FETCH_TIMEOUT_MS, HEARTBEAT_INTERVAL_MS, HEARTBEAT_MAX_MISSES, SHUTDOWN_GRACE_MS, SHUTDOWN_SECOND_TERM_GRACE_MS, LOCK_OPTS2, ENGINE_LOCK_WAIT_MS_DEFAULT, ENGINE_LOCK_WAIT_POLL_MS, WORKFLOW_SIZE_GUIDELINE_VALUES, RETIRED_ENV_RENAMES, lastServiceAuthToken, lastInitFailureReason, lastInitFailureDetail, localEngineActive, DERIVED_PORT_PROBE_MAX, expectedExitPids, onOwnedEngineExitCb, deadRespawnInFlight, CRASH_LOOP_WINDOW_MS, CRASH_LOOP_MAX_DEATHS, recentDeathTimestamps, CRASH_LOOP_COOLDOWN_BASE_MS, CRASH_LOOP_COOLDOWN_CAP_MS, cooldownRetryPending, cooldownRetryLevel, cooldownRetryFire, cooldownRetryTimer, cooldownRetryAt, lastRespawnOkAt, teardownGetInstance, teardownInstalled, teardownDone;
|
|
227353
|
+
var PORT_FILE_VERSION, HEALTH_POLL_INTERVAL_MS, HEALTH_POLL_MAX_ATTEMPTS, HEALTH_FETCH_TIMEOUT_MS, HEARTBEAT_INTERVAL_MS, HEARTBEAT_MAX_MISSES, SHUTDOWN_GRACE_MS, SHUTDOWN_SECOND_TERM_GRACE_MS, LOCK_OPTS2, ENGINE_LOCK_WAIT_MS_DEFAULT, ENGINE_LOCK_WAIT_POLL_MS, WORKFLOW_SIZE_GUIDELINE_VALUES, RETIRED_ENV_RENAMES, lastServiceAuthToken, lastInitFailureReason, lastInitFailureDetail, localEngineActive, DERIVED_PORT_PROBE_MAX, expectedExitPids, onOwnedEngineExitCb, deadRespawnInFlight, CRASH_LOOP_WINDOW_MS, CRASH_LOOP_MAX_DEATHS, recentDeathTimestamps, CRASH_LOOP_COOLDOWN_BASE_MS, CRASH_LOOP_COOLDOWN_CAP_MS, CRASH_LOOP_COOLDOWN_MAX_RETRIES, cooldownRetryPending, cooldownRetryLevel, cooldownRetriesUsed, cooldownSpentMs, cooldownRetryFire, cooldownRetryTimer, cooldownRetryAt, lastRespawnOkAt, teardownGetInstance, teardownInstalled, teardownDone;
|
|
227168
227354
|
var init_engineLifecycleManager = __esm({
|
|
227169
227355
|
"build-src/src/sema/engineLifecycleManager.ts"() {
|
|
227170
227356
|
init_state2();
|
|
@@ -227205,8 +227391,11 @@ var init_engineLifecycleManager = __esm({
|
|
|
227205
227391
|
recentDeathTimestamps = [];
|
|
227206
227392
|
CRASH_LOOP_COOLDOWN_BASE_MS = 6e4;
|
|
227207
227393
|
CRASH_LOOP_COOLDOWN_CAP_MS = 10 * 6e4;
|
|
227394
|
+
CRASH_LOOP_COOLDOWN_MAX_RETRIES = 6;
|
|
227208
227395
|
cooldownRetryPending = false;
|
|
227209
227396
|
cooldownRetryLevel = 0;
|
|
227397
|
+
cooldownRetriesUsed = 0;
|
|
227398
|
+
cooldownSpentMs = 0;
|
|
227210
227399
|
cooldownRetryAt = 0;
|
|
227211
227400
|
lastRespawnOkAt = null;
|
|
227212
227401
|
teardownGetInstance = null;
|
|
@@ -228228,6 +228417,18 @@ function toTaskRequest(params) {
|
|
|
228228
228417
|
}
|
|
228229
228418
|
}
|
|
228230
228419
|
}
|
|
228420
|
+
if (submitted) {
|
|
228421
|
+
const collected = collectSubmissionAttachmentTexts(msgs, submitted, normalizeAttachmentForAPI);
|
|
228422
|
+
if (!collected.ok) {
|
|
228423
|
+
process.stderr.write(`[sema] @-mention attachment could not be included in the message \u2014 ${collected.reason}
|
|
228424
|
+
`);
|
|
228425
|
+
} else if (collected.texts.length > 0) {
|
|
228426
|
+
objective = [...collected.texts, objective].join("\n\n");
|
|
228427
|
+
if (process.env.SEMA_DEBUG) {
|
|
228428
|
+
console.error(`[sema][seamQuery] at-mention attachments wire: ${collected.texts.length} block(s) \u2192 objective prefix`);
|
|
228429
|
+
}
|
|
228430
|
+
}
|
|
228431
|
+
}
|
|
228231
228432
|
const standaloneMeta = trailingStandaloneMetaUserMessages(msgs);
|
|
228232
228433
|
let metaIsSubmission = false;
|
|
228233
228434
|
if (standaloneMeta.length > 0) {
|
|
@@ -228666,7 +228867,7 @@ Setup looks unfinished (no model was saved). Run \`sema onboard\` to finish setu
|
|
|
228666
228867
|
reopenPlanReview: reopenPlanReviewCard
|
|
228667
228868
|
})
|
|
228668
228869
|
) : { kind: "budget-exhausted", taskId: detectedBusy.activeTaskId };
|
|
228669
|
-
yield apiErrorRow(activeRunSelfHealRow(outcome));
|
|
228870
|
+
yield apiErrorRow(activeRunSelfHealRow(outcome, detectedBusy));
|
|
228670
228871
|
if (outcome.kind === "healed") {
|
|
228671
228872
|
selfHealAttempts++;
|
|
228672
228873
|
retryStream = true;
|
|
@@ -228852,6 +229053,7 @@ var init_seamQuery = __esm({
|
|
|
228852
229053
|
init_controlRouterStore();
|
|
228853
229054
|
init_apiErrorSupplement();
|
|
228854
229055
|
init_messages4();
|
|
229056
|
+
init_atMentionAttachmentWire();
|
|
228855
229057
|
init_dist();
|
|
228856
229058
|
init_log2();
|
|
228857
229059
|
init_engineRuntimeStatus();
|
|
@@ -234088,6 +234290,15 @@ var init_bashClassifier = __esm({
|
|
|
234088
234290
|
});
|
|
234089
234291
|
|
|
234090
234292
|
// build-src/src/utils/permissions/permissionsLoader.ts
|
|
234293
|
+
var permissionsLoader_exports = {};
|
|
234294
|
+
__export(permissionsLoader_exports, {
|
|
234295
|
+
addPermissionRulesToSettings: () => addPermissionRulesToSettings,
|
|
234296
|
+
deletePermissionRuleFromSettings: () => deletePermissionRuleFromSettings,
|
|
234297
|
+
getPermissionRulesForSource: () => getPermissionRulesForSource,
|
|
234298
|
+
loadAllPermissionRulesFromDisk: () => loadAllPermissionRulesFromDisk,
|
|
234299
|
+
shouldAllowManagedPermissionRulesOnly: () => shouldAllowManagedPermissionRulesOnly,
|
|
234300
|
+
shouldShowAlwaysAllowOptions: () => shouldShowAlwaysAllowOptions
|
|
234301
|
+
});
|
|
234091
234302
|
function shouldAllowManagedPermissionRulesOnly() {
|
|
234092
234303
|
return getSettingsForSource("policySettings")?.allowManagedPermissionRulesOnly === true;
|
|
234093
234304
|
}
|
|
@@ -238292,6 +238503,33 @@ var init_pathValidation2 = __esm({
|
|
|
238292
238503
|
});
|
|
238293
238504
|
|
|
238294
238505
|
// build-src/src/tools/BashTool/bashPermissions.ts
|
|
238506
|
+
var bashPermissions_exports = {};
|
|
238507
|
+
__export(bashPermissions_exports, {
|
|
238508
|
+
BINARY_HIJACK_VARS: () => BINARY_HIJACK_VARS,
|
|
238509
|
+
MAX_SUBCOMMANDS_FOR_SECURITY_CHECK: () => MAX_SUBCOMMANDS_FOR_SECURITY_CHECK,
|
|
238510
|
+
MAX_SUGGESTED_RULES_FOR_COMPOUND: () => MAX_SUGGESTED_RULES_FOR_COMPOUND,
|
|
238511
|
+
awaitClassifierAutoApproval: () => awaitClassifierAutoApproval,
|
|
238512
|
+
bashPermissionRule: () => bashPermissionRule,
|
|
238513
|
+
bashToolCheckExactMatchPermission: () => bashToolCheckExactMatchPermission,
|
|
238514
|
+
bashToolCheckPermission: () => bashToolCheckPermission,
|
|
238515
|
+
bashToolHasPermission: () => bashToolHasPermission,
|
|
238516
|
+
checkCommandAndSuggestRules: () => checkCommandAndSuggestRules,
|
|
238517
|
+
clearSpeculativeChecks: () => clearSpeculativeChecks,
|
|
238518
|
+
commandHasAnyCd: () => commandHasAnyCd,
|
|
238519
|
+
consumeSpeculativeClassifierCheck: () => consumeSpeculativeClassifierCheck,
|
|
238520
|
+
executeAsyncClassifierCheck: () => executeAsyncClassifierCheck,
|
|
238521
|
+
getFirstWordPrefix: () => getFirstWordPrefix,
|
|
238522
|
+
getSimpleCommandPrefix: () => getSimpleCommandPrefix,
|
|
238523
|
+
isNormalizedCdCommand: () => isNormalizedCdCommand,
|
|
238524
|
+
isNormalizedGitCommand: () => isNormalizedGitCommand,
|
|
238525
|
+
matchWildcardPattern: () => matchWildcardPattern2,
|
|
238526
|
+
peekSpeculativeClassifierCheck: () => peekSpeculativeClassifierCheck,
|
|
238527
|
+
permissionRuleExtractPrefix: () => permissionRuleExtractPrefix3,
|
|
238528
|
+
startSpeculativeClassifierCheck: () => startSpeculativeClassifierCheck,
|
|
238529
|
+
stripAllLeadingEnvVars: () => stripAllLeadingEnvVars,
|
|
238530
|
+
stripSafeWrappers: () => stripSafeWrappers,
|
|
238531
|
+
stripWrappersFromArgv: () => stripWrappersFromArgv2
|
|
238532
|
+
});
|
|
238295
238533
|
function logClassifierResultForAnts(command8, behavior, descriptions, result) {
|
|
238296
238534
|
if (process.env.USER_TYPE !== "ant") {
|
|
238297
238535
|
return;
|
|
@@ -238454,6 +238692,45 @@ function stripSafeWrappers(command8) {
|
|
|
238454
238692
|
}
|
|
238455
238693
|
return stripped.trim();
|
|
238456
238694
|
}
|
|
238695
|
+
function skipTimeoutFlags2(a) {
|
|
238696
|
+
let i = 1;
|
|
238697
|
+
while (i < a.length) {
|
|
238698
|
+
const arg = a[i];
|
|
238699
|
+
const next = a[i + 1];
|
|
238700
|
+
if (arg === "--foreground" || arg === "--preserve-status" || arg === "--verbose")
|
|
238701
|
+
i++;
|
|
238702
|
+
else if (/^--(?:kill-after|signal)=[A-Za-z0-9_.+-]+$/.test(arg)) i++;
|
|
238703
|
+
else if ((arg === "--kill-after" || arg === "--signal") && next && TIMEOUT_FLAG_VALUE_RE2.test(next))
|
|
238704
|
+
i += 2;
|
|
238705
|
+
else if (arg === "--") {
|
|
238706
|
+
i++;
|
|
238707
|
+
break;
|
|
238708
|
+
} else if (arg.startsWith("--")) return -1;
|
|
238709
|
+
else if (arg === "-v") i++;
|
|
238710
|
+
else if ((arg === "-k" || arg === "-s") && next && TIMEOUT_FLAG_VALUE_RE2.test(next))
|
|
238711
|
+
i += 2;
|
|
238712
|
+
else if (/^-[ks][A-Za-z0-9_.+-]+$/.test(arg)) i++;
|
|
238713
|
+
else if (arg.startsWith("-")) return -1;
|
|
238714
|
+
else break;
|
|
238715
|
+
}
|
|
238716
|
+
return i;
|
|
238717
|
+
}
|
|
238718
|
+
function stripWrappersFromArgv2(argv) {
|
|
238719
|
+
let a = argv;
|
|
238720
|
+
for (; ; ) {
|
|
238721
|
+
if (a[0] === "time" || a[0] === "nohup") {
|
|
238722
|
+
a = a.slice(a[1] === "--" ? 2 : 1);
|
|
238723
|
+
} else if (a[0] === "timeout") {
|
|
238724
|
+
const i = skipTimeoutFlags2(a);
|
|
238725
|
+
if (i < 0 || !a[i] || !/^\d+(?:\.\d+)?[smhd]?$/.test(a[i])) return a;
|
|
238726
|
+
a = a.slice(i + 1);
|
|
238727
|
+
} else if (a[0] === "nice" && a[1] === "-n" && a[2] && /^-?\d+$/.test(a[2])) {
|
|
238728
|
+
a = a.slice(a[3] === "--" ? 4 : 3);
|
|
238729
|
+
} else {
|
|
238730
|
+
return a;
|
|
238731
|
+
}
|
|
238732
|
+
}
|
|
238733
|
+
}
|
|
238457
238734
|
function stripAllLeadingEnvVars(command8, blocklist) {
|
|
238458
238735
|
const ENV_VAR_PATTERN = /^([A-Za-z_][A-Za-z0-9_]*(?:\[[^\]]*\])?)\+?=(?:'[^'\n\r]*'|"(?:\\.|[^"$`\\\n\r])*"|\\.|[^ \t\n\r$`;|&()<>\\\\'"])*[ \t]+/;
|
|
238459
238736
|
let stripped = command8;
|
|
@@ -238753,9 +239030,96 @@ function checkSemanticsDeny(input, toolPermissionContext, commands) {
|
|
|
238753
239030
|
}
|
|
238754
239031
|
return null;
|
|
238755
239032
|
}
|
|
239033
|
+
function peekSpeculativeClassifierCheck(command8) {
|
|
239034
|
+
return speculativeChecks.get(command8);
|
|
239035
|
+
}
|
|
239036
|
+
function startSpeculativeClassifierCheck(command8, toolPermissionContext, signal, isNonInteractiveSession) {
|
|
239037
|
+
if (!isClassifierPermissionsEnabled()) return false;
|
|
239038
|
+
if (toolPermissionContext.mode === "auto")
|
|
239039
|
+
return false;
|
|
239040
|
+
if (toolPermissionContext.mode === "bypassPermissions") return false;
|
|
239041
|
+
const allowDescriptions = getBashPromptAllowDescriptions(
|
|
239042
|
+
toolPermissionContext
|
|
239043
|
+
);
|
|
239044
|
+
if (allowDescriptions.length === 0) return false;
|
|
239045
|
+
const cwd5 = getCwd();
|
|
239046
|
+
const promise2 = classifyBashCommand(
|
|
239047
|
+
command8,
|
|
239048
|
+
cwd5,
|
|
239049
|
+
allowDescriptions,
|
|
239050
|
+
"allow",
|
|
239051
|
+
signal,
|
|
239052
|
+
isNonInteractiveSession
|
|
239053
|
+
);
|
|
239054
|
+
promise2.catch(() => {
|
|
239055
|
+
});
|
|
239056
|
+
speculativeChecks.set(command8, promise2);
|
|
239057
|
+
return true;
|
|
239058
|
+
}
|
|
239059
|
+
function consumeSpeculativeClassifierCheck(command8) {
|
|
239060
|
+
const promise2 = speculativeChecks.get(command8);
|
|
239061
|
+
if (promise2) {
|
|
239062
|
+
speculativeChecks.delete(command8);
|
|
239063
|
+
}
|
|
239064
|
+
return promise2;
|
|
239065
|
+
}
|
|
238756
239066
|
function clearSpeculativeChecks() {
|
|
238757
239067
|
speculativeChecks.clear();
|
|
238758
239068
|
}
|
|
239069
|
+
async function awaitClassifierAutoApproval(pendingCheck, signal, isNonInteractiveSession) {
|
|
239070
|
+
const { command: command8, cwd: cwd5, descriptions } = pendingCheck;
|
|
239071
|
+
const speculativeResult = consumeSpeculativeClassifierCheck(command8);
|
|
239072
|
+
const classifierResult = speculativeResult ? await speculativeResult : await classifyBashCommand(
|
|
239073
|
+
command8,
|
|
239074
|
+
cwd5,
|
|
239075
|
+
descriptions,
|
|
239076
|
+
"allow",
|
|
239077
|
+
signal,
|
|
239078
|
+
isNonInteractiveSession
|
|
239079
|
+
);
|
|
239080
|
+
logClassifierResultForAnts(command8, "allow", descriptions, classifierResult);
|
|
239081
|
+
if (false) {
|
|
239082
|
+
return {
|
|
239083
|
+
type: "classifier",
|
|
239084
|
+
classifier: "bash_allow",
|
|
239085
|
+
reason: `Allowed by prompt rule: "${classifierResult.matchedDescription}"`
|
|
239086
|
+
};
|
|
239087
|
+
}
|
|
239088
|
+
return void 0;
|
|
239089
|
+
}
|
|
239090
|
+
async function executeAsyncClassifierCheck(pendingCheck, signal, isNonInteractiveSession, callbacks) {
|
|
239091
|
+
const { command: command8, cwd: cwd5, descriptions } = pendingCheck;
|
|
239092
|
+
const speculativeResult = consumeSpeculativeClassifierCheck(command8);
|
|
239093
|
+
let classifierResult;
|
|
239094
|
+
try {
|
|
239095
|
+
classifierResult = speculativeResult ? await speculativeResult : await classifyBashCommand(
|
|
239096
|
+
command8,
|
|
239097
|
+
cwd5,
|
|
239098
|
+
descriptions,
|
|
239099
|
+
"allow",
|
|
239100
|
+
signal,
|
|
239101
|
+
isNonInteractiveSession
|
|
239102
|
+
);
|
|
239103
|
+
} catch (error51) {
|
|
239104
|
+
if (error51 instanceof APIUserAbortError || error51 instanceof AbortError) {
|
|
239105
|
+
callbacks.onComplete?.();
|
|
239106
|
+
return;
|
|
239107
|
+
}
|
|
239108
|
+
callbacks.onComplete?.();
|
|
239109
|
+
throw error51;
|
|
239110
|
+
}
|
|
239111
|
+
logClassifierResultForAnts(command8, "allow", descriptions, classifierResult);
|
|
239112
|
+
if (!callbacks.shouldContinue()) return;
|
|
239113
|
+
if (false) {
|
|
239114
|
+
callbacks.onAllow({
|
|
239115
|
+
type: "classifier",
|
|
239116
|
+
classifier: "bash_allow",
|
|
239117
|
+
reason: `Allowed by prompt rule: "${classifierResult.matchedDescription}"`
|
|
239118
|
+
});
|
|
239119
|
+
} else {
|
|
239120
|
+
callbacks.onComplete?.();
|
|
239121
|
+
}
|
|
239122
|
+
}
|
|
238759
239123
|
async function bashToolHasPermission(input, context3, getCommandSubcommandPrefixFn = getCommandSubcommandPrefix) {
|
|
238760
239124
|
let appState = context3.getAppState();
|
|
238761
239125
|
const injectionCheckDisabled = isEnvTruthy(
|
|
@@ -239351,7 +239715,7 @@ function commandHasAnyCd(command8) {
|
|
|
239351
239715
|
(subcmd) => isNormalizedCdCommand(subcmd.trim())
|
|
239352
239716
|
);
|
|
239353
239717
|
}
|
|
239354
|
-
var bashCommandIsSafeAsync, splitCommand, ENV_VAR_ASSIGN_RE, MAX_SUBCOMMANDS_FOR_SECURITY_CHECK, MAX_SUGGESTED_RULES_FOR_COMPOUND, BARE_SHELL_PREFIXES, permissionRuleExtractPrefix3, bashPermissionRule, SAFE_ENV_VARS2, ANT_ONLY_SAFE_ENV_VARS, BINARY_HIJACK_VARS, bashToolCheckExactMatchPermission, bashToolCheckPermission, speculativeChecks;
|
|
239718
|
+
var bashCommandIsSafeAsync, splitCommand, ENV_VAR_ASSIGN_RE, MAX_SUBCOMMANDS_FOR_SECURITY_CHECK, MAX_SUGGESTED_RULES_FOR_COMPOUND, BARE_SHELL_PREFIXES, permissionRuleExtractPrefix3, bashPermissionRule, SAFE_ENV_VARS2, ANT_ONLY_SAFE_ENV_VARS, TIMEOUT_FLAG_VALUE_RE2, BINARY_HIJACK_VARS, bashToolCheckExactMatchPermission, bashToolCheckPermission, speculativeChecks;
|
|
239355
239719
|
var init_bashPermissions = __esm({
|
|
239356
239720
|
"build-src/src/tools/BashTool/bashPermissions.ts"() {
|
|
239357
239721
|
init_sdk();
|
|
@@ -239567,6 +239931,7 @@ var init_bashPermissions = __esm({
|
|
|
239567
239931
|
"GROWTHBOOK_API_KEY"
|
|
239568
239932
|
// self-hosted growthbook
|
|
239569
239933
|
]);
|
|
239934
|
+
TIMEOUT_FLAG_VALUE_RE2 = /^[A-Za-z0-9_.+-]+$/;
|
|
239570
239935
|
BINARY_HIJACK_VARS = /^(LD_|DYLD_|PATH$)/;
|
|
239571
239936
|
bashToolCheckExactMatchPermission = (input, toolPermissionContext) => {
|
|
239572
239937
|
const command8 = input.command.trim();
|
|
@@ -309861,9 +310226,9 @@ function copyTextOf(msg) {
|
|
|
309861
310226
|
return tc ? PRIMARY_INPUT[tc.name]?.extract(tc.input) ?? "" : "";
|
|
309862
310227
|
}
|
|
309863
310228
|
case "grouped_tool_use":
|
|
309864
|
-
return msg.results.map(
|
|
310229
|
+
return msg.results.map(toolResultText).filter(Boolean).join("\n\n");
|
|
309865
310230
|
case "collapsed_read_search":
|
|
309866
|
-
return msg.messages.flatMap((m2) => m2.type === "user" ? [
|
|
310231
|
+
return msg.messages.flatMap((m2) => m2.type === "user" ? [toolResultText(m2)] : m2.type === "grouped_tool_use" ? m2.results.map(toolResultText) : []).filter(Boolean).join("\n\n");
|
|
309867
310232
|
case "system":
|
|
309868
310233
|
if ("content" in msg) return msg.content;
|
|
309869
310234
|
if ("error" in msg) return String(msg.error);
|
|
@@ -309879,7 +310244,7 @@ function copyTextOf(msg) {
|
|
|
309879
310244
|
}
|
|
309880
310245
|
return "";
|
|
309881
310246
|
}
|
|
309882
|
-
function
|
|
310247
|
+
function toolResultText(r) {
|
|
309883
310248
|
const b3 = r.message.content[0];
|
|
309884
310249
|
if (b3?.type !== "tool_result") return "";
|
|
309885
310250
|
const c2 = b3.content;
|
|
@@ -382740,7 +383105,7 @@ function createInProcessCanUseTool(identity3, abortController, onPermissionWaitM
|
|
|
382740
383105
|
return result;
|
|
382741
383106
|
}
|
|
382742
383107
|
if (false) {
|
|
382743
|
-
const classifierDecision = await
|
|
383108
|
+
const classifierDecision = await awaitClassifierAutoApproval2(
|
|
382744
383109
|
result.pendingClassifierCheck,
|
|
382745
383110
|
abortController.signal,
|
|
382746
383111
|
toolUseContext.options.isNonInteractiveSession
|
|
@@ -394951,16 +395316,29 @@ var init_RejectedToolUseMessage = __esm({
|
|
|
394951
395316
|
});
|
|
394952
395317
|
|
|
394953
395318
|
// build-src/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx
|
|
395319
|
+
function unwrapWholeSystemReminder(content) {
|
|
395320
|
+
const OPEN = "<system-reminder>";
|
|
395321
|
+
const CLOSE = "</system-reminder>";
|
|
395322
|
+
const trimmed2 = content.trim();
|
|
395323
|
+
if (!trimmed2.startsWith(OPEN) || !trimmed2.endsWith(CLOSE)) return content;
|
|
395324
|
+
return trimmed2.split(OPEN).join("").split(CLOSE).join("").trim();
|
|
395325
|
+
}
|
|
395326
|
+
function normalizeEngineReminderParam(p) {
|
|
395327
|
+
if (typeof p.content !== "string") return p;
|
|
395328
|
+
const unwrapped = unwrapWholeSystemReminder(p.content);
|
|
395329
|
+
return unwrapped === p.content ? p : { ...p, content: unwrapped };
|
|
395330
|
+
}
|
|
394954
395331
|
function UserToolErrorMessage(t0) {
|
|
394955
395332
|
const $3 = (0, import_compiler_runtime105.c)(14);
|
|
394956
395333
|
const {
|
|
394957
395334
|
progressMessagesForMessage,
|
|
394958
395335
|
tool,
|
|
394959
395336
|
tools,
|
|
394960
|
-
param,
|
|
395337
|
+
param: rawParam,
|
|
394961
395338
|
verbose,
|
|
394962
395339
|
isTranscriptMode
|
|
394963
395340
|
} = t0;
|
|
395341
|
+
const param = normalizeEngineReminderParam(rawParam);
|
|
394964
395342
|
if (typeof param.content === "string" && param.content.includes(INTERRUPT_MESSAGE_FOR_TOOL_USE)) {
|
|
394965
395343
|
let t12;
|
|
394966
395344
|
if ($3[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -399507,6 +399885,7 @@ var client_exports2 = {};
|
|
|
399507
399885
|
__export(client_exports2, {
|
|
399508
399886
|
MAX_RPC_BYTES: () => MAX_RPC_BYTES,
|
|
399509
399887
|
daemonRpc: () => daemonRpc,
|
|
399888
|
+
daemonStartupFailureMessage: () => daemonStartupFailureMessage,
|
|
399510
399889
|
dispatchJob: () => dispatchJob,
|
|
399511
399890
|
ensureDaemonRunning: () => ensureDaemonRunning
|
|
399512
399891
|
});
|
|
@@ -399603,13 +399982,16 @@ async function ensureDaemonRunning() {
|
|
|
399603
399982
|
);
|
|
399604
399983
|
child.unref();
|
|
399605
399984
|
}
|
|
399606
|
-
for (let i = 0; i <
|
|
399985
|
+
for (let i = 0; i < 100; i++) {
|
|
399607
399986
|
await sleep5(150);
|
|
399608
399987
|
info = await readDaemonInfo();
|
|
399609
399988
|
if (info && isDaemonAlive(info) && await pingOk(info)) return info;
|
|
399610
399989
|
}
|
|
399611
399990
|
return null;
|
|
399612
399991
|
}
|
|
399992
|
+
function daemonStartupFailureMessage(registeredLate) {
|
|
399993
|
+
return registeredLate ? "the daemon registered but did not answer pings within the startup window \u2014 it may still be starting (slow machine) or wedged; check daemon.log" : "the daemon did not register within the startup window \u2014 slow first boot or a crash on boot; check daemon.log";
|
|
399994
|
+
}
|
|
399613
399995
|
function mapResponse(r) {
|
|
399614
399996
|
if (r.ok) return { ok: true, pid: r.pid };
|
|
399615
399997
|
if (r.code === "short-alive" || r.code === "stale-short") {
|
|
@@ -399621,10 +400003,11 @@ function mapResponse(r) {
|
|
|
399621
400003
|
async function dispatchJob(job) {
|
|
399622
400004
|
let info = await ensureDaemonRunning();
|
|
399623
400005
|
if (!info) {
|
|
400006
|
+
const late3 = await readDaemonInfo();
|
|
399624
400007
|
return {
|
|
399625
400008
|
ok: false,
|
|
399626
400009
|
code: "daemon-unreachable",
|
|
399627
|
-
message:
|
|
400010
|
+
message: daemonStartupFailureMessage(late3 !== null)
|
|
399628
400011
|
};
|
|
399629
400012
|
}
|
|
399630
400013
|
const nonce = randomUUID18();
|
|
@@ -409599,7 +409982,7 @@ var require_select = __commonJS({
|
|
|
409599
409982
|
return url3.replace(/^(?:\w+:\/\/|\/+)/, "").replace(/(?:\/+|\/*#.*?)$/, "").split("/", num).join("/");
|
|
409600
409983
|
};
|
|
409601
409984
|
var parseNth = function(param_, test2) {
|
|
409602
|
-
var param = param_.replace(/\s+/g, ""),
|
|
409985
|
+
var param = param_.replace(/\s+/g, ""), cap2;
|
|
409603
409986
|
if (param === "even") {
|
|
409604
409987
|
param = "2n+0";
|
|
409605
409988
|
} else if (param === "odd") {
|
|
@@ -409607,10 +409990,10 @@ var require_select = __commonJS({
|
|
|
409607
409990
|
} else if (param.indexOf("n") === -1) {
|
|
409608
409991
|
param = "0n" + param;
|
|
409609
409992
|
}
|
|
409610
|
-
|
|
409993
|
+
cap2 = /^([+-])?(\d+)?n([+-])?(\d+)?$/.exec(param);
|
|
409611
409994
|
return {
|
|
409612
|
-
group:
|
|
409613
|
-
offset:
|
|
409995
|
+
group: cap2[1] === "-" ? -(cap2[2] || 1) : +(cap2[2] || 1),
|
|
409996
|
+
offset: cap2[4] ? cap2[3] === "-" ? -cap2[4] : +cap2[4] : 0
|
|
409614
409997
|
};
|
|
409615
409998
|
};
|
|
409616
409999
|
var nth = function(param_, test2, last3) {
|
|
@@ -410025,23 +410408,23 @@ var require_select = __commonJS({
|
|
|
410025
410408
|
rules.ident = replace(rules.ident, "cssid", rules.cssid);
|
|
410026
410409
|
rules.str_escape = replace(rules.str_escape, "escape", rules.escape);
|
|
410027
410410
|
var compile = function(sel_) {
|
|
410028
|
-
var sel = sel_.replace(/^\s+|\s+$/g, ""), test2, filter2 = [], buff = [], subject, qname,
|
|
410411
|
+
var sel = sel_.replace(/^\s+|\s+$/g, ""), test2, filter2 = [], buff = [], subject, qname, cap2, op, ref;
|
|
410029
410412
|
while (sel) {
|
|
410030
|
-
if (
|
|
410031
|
-
sel = sel.substring(
|
|
410032
|
-
qname = decodeid(
|
|
410413
|
+
if (cap2 = rules.qname.exec(sel)) {
|
|
410414
|
+
sel = sel.substring(cap2[0].length);
|
|
410415
|
+
qname = decodeid(cap2[1]);
|
|
410033
410416
|
buff.push(tok(qname, true));
|
|
410034
|
-
} else if (
|
|
410035
|
-
sel = sel.substring(
|
|
410417
|
+
} else if (cap2 = rules.simple.exec(sel)) {
|
|
410418
|
+
sel = sel.substring(cap2[0].length);
|
|
410036
410419
|
qname = "*";
|
|
410037
410420
|
buff.push(tok(qname, true));
|
|
410038
|
-
buff.push(tok(
|
|
410421
|
+
buff.push(tok(cap2));
|
|
410039
410422
|
} else {
|
|
410040
410423
|
throw new SyntaxError("Invalid selector.");
|
|
410041
410424
|
}
|
|
410042
|
-
while (
|
|
410043
|
-
sel = sel.substring(
|
|
410044
|
-
buff.push(tok(
|
|
410425
|
+
while (cap2 = rules.simple.exec(sel)) {
|
|
410426
|
+
sel = sel.substring(cap2[0].length);
|
|
410427
|
+
buff.push(tok(cap2));
|
|
410045
410428
|
}
|
|
410046
410429
|
if (sel[0] === "!") {
|
|
410047
410430
|
sel = sel.substring(1);
|
|
@@ -410049,16 +410432,16 @@ var require_select = __commonJS({
|
|
|
410049
410432
|
subject.qname = qname;
|
|
410050
410433
|
buff.push(subject.simple);
|
|
410051
410434
|
}
|
|
410052
|
-
if (
|
|
410053
|
-
sel = sel.substring(
|
|
410054
|
-
ref = combinators.ref(makeSimple(buff), decodeid(
|
|
410435
|
+
if (cap2 = rules.ref.exec(sel)) {
|
|
410436
|
+
sel = sel.substring(cap2[0].length);
|
|
410437
|
+
ref = combinators.ref(makeSimple(buff), decodeid(cap2[1]));
|
|
410055
410438
|
filter2.push(ref.combinator);
|
|
410056
410439
|
buff = [];
|
|
410057
410440
|
continue;
|
|
410058
410441
|
}
|
|
410059
|
-
if (
|
|
410060
|
-
sel = sel.substring(
|
|
410061
|
-
op =
|
|
410442
|
+
if (cap2 = rules.combinator.exec(sel)) {
|
|
410443
|
+
sel = sel.substring(cap2[0].length);
|
|
410444
|
+
op = cap2[1] || cap2[2] || cap2[3];
|
|
410062
410445
|
if (op === ",") {
|
|
410063
410446
|
filter2.push(combinators.noop(makeSimple(buff)));
|
|
410064
410447
|
break;
|
|
@@ -410090,23 +410473,23 @@ var require_select = __commonJS({
|
|
|
410090
410473
|
}
|
|
410091
410474
|
return test2;
|
|
410092
410475
|
};
|
|
410093
|
-
var tok = function(
|
|
410476
|
+
var tok = function(cap2, qname) {
|
|
410094
410477
|
if (qname) {
|
|
410095
|
-
return
|
|
410478
|
+
return cap2 === "*" ? selectors["*"] : selectors.type(cap2);
|
|
410096
410479
|
}
|
|
410097
|
-
if (
|
|
410098
|
-
return
|
|
410480
|
+
if (cap2[1]) {
|
|
410481
|
+
return cap2[1][0] === "." ? selectors.attr("class", "~=", decodeid(cap2[1].substring(1)), false) : selectors.attr("id", "=", decodeid(cap2[1].substring(1)), false);
|
|
410099
410482
|
}
|
|
410100
|
-
if (
|
|
410101
|
-
return
|
|
410483
|
+
if (cap2[2]) {
|
|
410484
|
+
return cap2[3] ? selectors[decodeid(cap2[2])](unquote(cap2[3])) : selectors[decodeid(cap2[2])];
|
|
410102
410485
|
}
|
|
410103
|
-
if (
|
|
410104
|
-
var value =
|
|
410486
|
+
if (cap2[4]) {
|
|
410487
|
+
var value = cap2[6];
|
|
410105
410488
|
var i = /["'\s]\s*I$/i.test(value);
|
|
410106
410489
|
if (i) {
|
|
410107
410490
|
value = value.replace(/\s*I$/i, "");
|
|
410108
410491
|
}
|
|
410109
|
-
return selectors.attr(decodeid(
|
|
410492
|
+
return selectors.attr(decodeid(cap2[4]), cap2[5] || "-", unquote(value), i);
|
|
410110
410493
|
}
|
|
410111
410494
|
throw new SyntaxError("Unknown Selector.");
|
|
410112
410495
|
};
|
|
@@ -458495,6 +458878,26 @@ var init_classifierDecision = __esm({
|
|
|
458495
458878
|
});
|
|
458496
458879
|
|
|
458497
458880
|
// build-src/src/utils/permissions/permissions.ts
|
|
458881
|
+
var permissions_exports2 = {};
|
|
458882
|
+
__export(permissions_exports2, {
|
|
458883
|
+
applyPermissionRulesToPermissionContext: () => applyPermissionRulesToPermissionContext,
|
|
458884
|
+
checkRuleBasedPermissions: () => checkRuleBasedPermissions,
|
|
458885
|
+
createPermissionRequestMessage: () => createPermissionRequestMessage,
|
|
458886
|
+
deletePermissionRule: () => deletePermissionRule,
|
|
458887
|
+
filterDeniedAgents: () => filterDeniedAgents,
|
|
458888
|
+
getAllowRules: () => getAllowRules,
|
|
458889
|
+
getAskRuleForTool: () => getAskRuleForTool,
|
|
458890
|
+
getAskRules: () => getAskRules,
|
|
458891
|
+
getDenyRuleForAgent: () => getDenyRuleForAgent,
|
|
458892
|
+
getDenyRuleForTool: () => getDenyRuleForTool,
|
|
458893
|
+
getDenyRules: () => getDenyRules,
|
|
458894
|
+
getRuleByContentsForTool: () => getRuleByContentsForTool,
|
|
458895
|
+
getRuleByContentsForToolName: () => getRuleByContentsForToolName,
|
|
458896
|
+
hasPermissionsToUseTool: () => hasPermissionsToUseTool,
|
|
458897
|
+
permissionRuleSourceDisplayString: () => permissionRuleSourceDisplayString,
|
|
458898
|
+
syncPermissionRulesFromDisk: () => syncPermissionRulesFromDisk,
|
|
458899
|
+
toolAlwaysAllowedRule: () => toolAlwaysAllowedRule
|
|
458900
|
+
});
|
|
458498
458901
|
function permissionRuleSourceDisplayString(source) {
|
|
458499
458902
|
return getSettingSourceDisplayNameLowercase(source);
|
|
458500
458903
|
}
|
|
@@ -458773,6 +459176,57 @@ Latest blocked action: ${classifierReason}`
|
|
|
458773
459176
|
}
|
|
458774
459177
|
};
|
|
458775
459178
|
}
|
|
459179
|
+
async function checkRuleBasedPermissions(tool, input, context3) {
|
|
459180
|
+
const appState = context3.getAppState();
|
|
459181
|
+
const denyRule = getDenyRuleForTool(appState.toolPermissionContext, tool);
|
|
459182
|
+
if (denyRule) {
|
|
459183
|
+
return {
|
|
459184
|
+
behavior: "deny",
|
|
459185
|
+
decisionReason: {
|
|
459186
|
+
type: "rule",
|
|
459187
|
+
rule: denyRule
|
|
459188
|
+
},
|
|
459189
|
+
message: `Permission to use ${tool.name} has been denied.`
|
|
459190
|
+
};
|
|
459191
|
+
}
|
|
459192
|
+
const askRule = getAskRuleForTool(appState.toolPermissionContext, tool);
|
|
459193
|
+
if (askRule) {
|
|
459194
|
+
const canSandboxAutoAllow = tool.name === BASH_TOOL_NAME && SandboxManager2.isSandboxingEnabled() && SandboxManager2.isAutoAllowBashIfSandboxedEnabled() && shouldUseSandbox(input);
|
|
459195
|
+
if (!canSandboxAutoAllow) {
|
|
459196
|
+
return {
|
|
459197
|
+
behavior: "ask",
|
|
459198
|
+
decisionReason: {
|
|
459199
|
+
type: "rule",
|
|
459200
|
+
rule: askRule
|
|
459201
|
+
},
|
|
459202
|
+
message: createPermissionRequestMessage(tool.name)
|
|
459203
|
+
};
|
|
459204
|
+
}
|
|
459205
|
+
}
|
|
459206
|
+
let toolPermissionResult = {
|
|
459207
|
+
behavior: "passthrough",
|
|
459208
|
+
message: createPermissionRequestMessage(tool.name)
|
|
459209
|
+
};
|
|
459210
|
+
try {
|
|
459211
|
+
const parsedInput = tool.inputSchema.parse(input);
|
|
459212
|
+
toolPermissionResult = await tool.checkPermissions(parsedInput, context3);
|
|
459213
|
+
} catch (e) {
|
|
459214
|
+
if (e instanceof AbortError || e instanceof APIUserAbortError) {
|
|
459215
|
+
throw e;
|
|
459216
|
+
}
|
|
459217
|
+
logError(e);
|
|
459218
|
+
}
|
|
459219
|
+
if (toolPermissionResult?.behavior === "deny") {
|
|
459220
|
+
return toolPermissionResult;
|
|
459221
|
+
}
|
|
459222
|
+
if (toolPermissionResult?.behavior === "ask" && toolPermissionResult.decisionReason?.type === "rule" && toolPermissionResult.decisionReason.rule.ruleBehavior === "ask") {
|
|
459223
|
+
return toolPermissionResult;
|
|
459224
|
+
}
|
|
459225
|
+
if (toolPermissionResult?.behavior === "ask" && toolPermissionResult.decisionReason?.type === "safetyCheck") {
|
|
459226
|
+
return toolPermissionResult;
|
|
459227
|
+
}
|
|
459228
|
+
return null;
|
|
459229
|
+
}
|
|
458776
459230
|
async function hasPermissionsToUseToolInner(tool, input, context3) {
|
|
458777
459231
|
if (context3.abortController.signal.aborted) {
|
|
458778
459232
|
throw new AbortError();
|
|
@@ -501752,8 +502206,8 @@ var init_sema_brand = __esm({
|
|
|
501752
502206
|
"Bulk stop now lists the rows it could not stop with a named reason, and quota/scenario refusals carry a plain-language line next to the machine-readable error"
|
|
501753
502207
|
]
|
|
501754
502208
|
},
|
|
501755
|
-
productVersion: "1.0.
|
|
501756
|
-
announcement:
|
|
502209
|
+
productVersion: "1.0.68",
|
|
502210
|
+
announcement: "sema 1.0.68 \u2014 Approvals got faster and quieter: permission rules you save in settings.json (permissions.allow/deny/ask) now actually apply in the interactive REPL, and a remembered allow rule answers the engine's approval gate instantly \u2014 no card, no pause, no suspend penalty. Reading your own config directory (~/.sema) no longer triggers a permission prompt on every read (engine 6.6.0 read-only whitelist); writes still ask. A background-task daemon that starts slowly on a cold machine is no longer misreported as crashed (startup window 6s \u2192 15s, and the error now distinguishes slow from dead). The setup wizard renders correctly in narrow 80-column terminals (help text word-wraps instead of losing the end of sentences) and no longer scrambles the option list if you paste an extremely long endpoint URL. Engine 6.6.0, core 5.11.0, SDK 6.5.0, client-core 0.17.1, registry-core 0.14.0."
|
|
501757
502211
|
};
|
|
501758
502212
|
}
|
|
501759
502213
|
});
|
|
@@ -508087,8 +508541,8 @@ var require_sema_brand = __commonJS({
|
|
|
508087
508541
|
"Bulk stop now lists the rows it could not stop with a named reason, and quota/scenario refusals carry a plain-language line next to the machine-readable error"
|
|
508088
508542
|
]
|
|
508089
508543
|
},
|
|
508090
|
-
productVersion: "1.0.
|
|
508091
|
-
announcement:
|
|
508544
|
+
productVersion: "1.0.68",
|
|
508545
|
+
announcement: "sema 1.0.68 \u2014 Approvals got faster and quieter: permission rules you save in settings.json (permissions.allow/deny/ask) now actually apply in the interactive REPL, and a remembered allow rule answers the engine's approval gate instantly \u2014 no card, no pause, no suspend penalty. Reading your own config directory (~/.sema) no longer triggers a permission prompt on every read (engine 6.6.0 read-only whitelist); writes still ask. A background-task daemon that starts slowly on a cold machine is no longer misreported as crashed (startup window 6s \u2192 15s, and the error now distinguishes slow from dead). The setup wizard renders correctly in narrow 80-column terminals (help text word-wraps instead of losing the end of sentences) and no longer scrambles the option list if you paste an extremely long endpoint URL. Engine 6.6.0, core 5.11.0, SDK 6.5.0, client-core 0.17.1, registry-core 0.14.0."
|
|
508092
508546
|
};
|
|
508093
508547
|
}
|
|
508094
508548
|
});
|
|
@@ -508150,12 +508604,12 @@ function dropTextInBriefTurns(messages, briefToolNames) {
|
|
|
508150
508604
|
return t2 === void 0 || !turnsWithBrief.has(t2);
|
|
508151
508605
|
});
|
|
508152
508606
|
}
|
|
508153
|
-
function computeSliceStart(collapsed, anchorRef,
|
|
508607
|
+
function computeSliceStart(collapsed, anchorRef, cap2 = MAX_MESSAGES_WITHOUT_VIRTUALIZATION, step = MESSAGE_CAP_STEP) {
|
|
508154
508608
|
const anchor = anchorRef.current;
|
|
508155
508609
|
const anchorIdx = anchor ? collapsed.findIndex((m2) => m2.uuid === anchor.uuid) : -1;
|
|
508156
|
-
let start = anchorIdx >= 0 ? anchorIdx : anchor ? Math.min(anchor.idx, Math.max(0, collapsed.length -
|
|
508157
|
-
if (collapsed.length - start >
|
|
508158
|
-
start = collapsed.length -
|
|
508610
|
+
let start = anchorIdx >= 0 ? anchorIdx : anchor ? Math.min(anchor.idx, Math.max(0, collapsed.length - cap2)) : 0;
|
|
508611
|
+
if (collapsed.length - start > cap2 + step) {
|
|
508612
|
+
start = collapsed.length - cap2;
|
|
508159
508613
|
}
|
|
508160
508614
|
const msgAtStart = collapsed[start];
|
|
508161
508615
|
if (msgAtStart && (anchor?.uuid !== msgAtStart.uuid || anchor.idx !== start)) {
|
|
@@ -529035,8 +529489,8 @@ var init_PermissionRuleList = __esm({
|
|
|
529035
529489
|
});
|
|
529036
529490
|
|
|
529037
529491
|
// build-src/src/commands/permissions/permissions.tsx
|
|
529038
|
-
var
|
|
529039
|
-
__export(
|
|
529492
|
+
var permissions_exports3 = {};
|
|
529493
|
+
__export(permissions_exports3, {
|
|
529040
529494
|
call: () => call46
|
|
529041
529495
|
});
|
|
529042
529496
|
var import_jsx_runtime307, call46;
|
|
@@ -529063,7 +529517,7 @@ var init_permissions4 = __esm({
|
|
|
529063
529517
|
aliases: ["allowed-tools"],
|
|
529064
529518
|
// 218 parity (aligned 2026-07-24, F8b): "and", not "&".
|
|
529065
529519
|
description: "Manage allow and deny tool permission rules",
|
|
529066
|
-
load: () => Promise.resolve().then(() => (init_permissions3(),
|
|
529520
|
+
load: () => Promise.resolve().then(() => (init_permissions3(), permissions_exports3))
|
|
529067
529521
|
};
|
|
529068
529522
|
permissions_default = permissions;
|
|
529069
529523
|
}
|
|
@@ -547421,6 +547875,38 @@ var init_agentMemory = __esm({
|
|
|
547421
547875
|
});
|
|
547422
547876
|
|
|
547423
547877
|
// build-src/src/utils/permissions/filesystem.ts
|
|
547878
|
+
var filesystem_exports = {};
|
|
547879
|
+
__export(filesystem_exports, {
|
|
547880
|
+
DANGEROUS_DIRECTORIES: () => DANGEROUS_DIRECTORIES2,
|
|
547881
|
+
DANGEROUS_FILES: () => DANGEROUS_FILES2,
|
|
547882
|
+
allWorkingDirectories: () => allWorkingDirectories,
|
|
547883
|
+
checkEditableInternalPath: () => checkEditableInternalPath,
|
|
547884
|
+
checkPathSafetyForAutoEdit: () => checkPathSafetyForAutoEdit,
|
|
547885
|
+
checkReadPermissionForTool: () => checkReadPermissionForTool,
|
|
547886
|
+
checkReadableInternalPath: () => checkReadableInternalPath,
|
|
547887
|
+
checkWritePermissionForTool: () => checkWritePermissionForTool,
|
|
547888
|
+
ensureScratchpadDir: () => ensureScratchpadDir,
|
|
547889
|
+
generateSuggestions: () => generateSuggestions,
|
|
547890
|
+
getBundledSkillsRoot: () => getBundledSkillsRoot,
|
|
547891
|
+
getClaudeSkillScope: () => getClaudeSkillScope,
|
|
547892
|
+
getClaudeTempDir: () => getClaudeTempDir,
|
|
547893
|
+
getClaudeTempDirName: () => getClaudeTempDirName,
|
|
547894
|
+
getFileReadIgnorePatterns: () => getFileReadIgnorePatterns,
|
|
547895
|
+
getProjectTempDir: () => getProjectTempDir,
|
|
547896
|
+
getResolvedWorkingDirPaths: () => getResolvedWorkingDirPaths,
|
|
547897
|
+
getScratchpadDir: () => getScratchpadDir,
|
|
547898
|
+
getSessionMemoryDir: () => getSessionMemoryDir,
|
|
547899
|
+
getSessionMemoryPath: () => getSessionMemoryPath,
|
|
547900
|
+
isClaudeSettingsPath: () => isClaudeSettingsPath,
|
|
547901
|
+
isScratchpadEnabled: () => isScratchpadEnabled,
|
|
547902
|
+
matchingRuleForInput: () => matchingRuleForInput,
|
|
547903
|
+
normalizeCaseForComparison: () => normalizeCaseForComparison2,
|
|
547904
|
+
normalizePatternsToPath: () => normalizePatternsToPath,
|
|
547905
|
+
pathInAllowedWorkingPath: () => pathInAllowedWorkingPath,
|
|
547906
|
+
pathInWorkingPath: () => pathInWorkingPath,
|
|
547907
|
+
relativePath: () => relativePath,
|
|
547908
|
+
toPosixPath: () => toPosixPath
|
|
547909
|
+
});
|
|
547424
547910
|
import { randomBytes as randomBytes21 } from "crypto";
|
|
547425
547911
|
import { homedir as homedir42, tmpdir as tmpdir14 } from "os";
|
|
547426
547912
|
import { join as join166, normalize as normalize17, posix as posix8, sep as sep36 } from "path";
|
|
@@ -553640,9 +554126,7 @@ async function* sdkMessagesToCcEvents(sdk, meta3) {
|
|
|
553640
554126
|
macrotaskPending = false;
|
|
553641
554127
|
}
|
|
553642
554128
|
if (out6.plane === "transcript") {
|
|
553643
|
-
const msg =
|
|
553644
|
-
reduceApiErrorEnvelope(out6.message)
|
|
553645
|
-
);
|
|
554129
|
+
const msg = reduceApiErrorEnvelope(out6.message);
|
|
553646
554130
|
noteModelEvidenceFrom(msg);
|
|
553647
554131
|
const w2 = notifWatch.get(seenFrameNo);
|
|
553648
554132
|
if (w2 !== void 0 && !w2.rowYielded && isTaskNotificationRow(msg)) w2.rowYielded = true;
|
|
@@ -553660,7 +554144,6 @@ var init_upstreamBridge = __esm({
|
|
|
553660
554144
|
init_dist();
|
|
553661
554145
|
init_bridgeAdapter();
|
|
553662
554146
|
init_textModeError();
|
|
553663
|
-
init_subagentDurablePause();
|
|
553664
554147
|
init_appStateRef();
|
|
553665
554148
|
init_modelVerificationStore();
|
|
553666
554149
|
init_retryStatusStore();
|
|
@@ -568577,144 +569060,6 @@ var init_a2a = __esm({
|
|
|
568577
569060
|
}
|
|
568578
569061
|
});
|
|
568579
569062
|
|
|
568580
|
-
// node_modules/@sema-agent/core/dist/agents/tool-filter.js
|
|
568581
|
-
var init_tool_filter = __esm({
|
|
568582
|
-
"node_modules/@sema-agent/core/dist/agents/tool-filter.js"() {
|
|
568583
|
-
}
|
|
568584
|
-
});
|
|
568585
|
-
|
|
568586
|
-
// node_modules/@sema-agent/core/dist/agents/builtin-agents.js
|
|
568587
|
-
var init_builtin_agents = __esm({
|
|
568588
|
-
"node_modules/@sema-agent/core/dist/agents/builtin-agents.js"() {
|
|
568589
|
-
}
|
|
568590
|
-
});
|
|
568591
|
-
|
|
568592
|
-
// node_modules/@sema-agent/core/dist/agents/suspend-guard.js
|
|
568593
|
-
var init_suspend_guard = __esm({
|
|
568594
|
-
"node_modules/@sema-agent/core/dist/agents/suspend-guard.js"() {
|
|
568595
|
-
}
|
|
568596
|
-
});
|
|
568597
|
-
|
|
568598
|
-
// node_modules/@sema-agent/core/dist/core/untrusted-egress.js
|
|
568599
|
-
function redactUserinfo2(scheme, userinfoWithAt) {
|
|
568600
|
-
const userinfo = userinfoWithAt.slice(0, -1);
|
|
568601
|
-
if (userinfo.includes("@"))
|
|
568602
|
-
return `${scheme}[redacted-credentials]@`;
|
|
568603
|
-
const colonIdx = userinfo.indexOf(":");
|
|
568604
|
-
if (colonIdx === -1) {
|
|
568605
|
-
return userinfo.length >= BARE_USERNAME_MAX_LEN ? `${scheme}[redacted-credentials]@` : `${scheme}${userinfo}@`;
|
|
568606
|
-
}
|
|
568607
|
-
return `${scheme}${userinfo.slice(0, colonIdx)}:[redacted-credentials]@`;
|
|
568608
|
-
}
|
|
568609
|
-
function redactSecrets3(s, report) {
|
|
568610
|
-
return runRedactionPasses(s, SECRET_TIER_PASSES, report);
|
|
568611
|
-
}
|
|
568612
|
-
function countRedactionMarkers(s) {
|
|
568613
|
-
return (s.match(REDACTION_MARKER_RE) ?? []).length;
|
|
568614
|
-
}
|
|
568615
|
-
function safeEllipsisTruncate(s, max2) {
|
|
568616
|
-
if (max2 < 1)
|
|
568617
|
-
return "";
|
|
568618
|
-
const budget = max2 - 1;
|
|
568619
|
-
let out6 = "";
|
|
568620
|
-
for (const codePoint of s) {
|
|
568621
|
-
if (out6.length + codePoint.length > budget)
|
|
568622
|
-
break;
|
|
568623
|
-
out6 += codePoint;
|
|
568624
|
-
}
|
|
568625
|
-
return out6 + "\u2026";
|
|
568626
|
-
}
|
|
568627
|
-
function boundedString(value, max2, redact) {
|
|
568628
|
-
let s;
|
|
568629
|
-
try {
|
|
568630
|
-
s = typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
568631
|
-
} catch {
|
|
568632
|
-
s = "[unserializable result]";
|
|
568633
|
-
}
|
|
568634
|
-
s = redact(s);
|
|
568635
|
-
if (s.length <= max2)
|
|
568636
|
-
return s;
|
|
568637
|
-
const totalMarkers = countRedactionMarkers(s);
|
|
568638
|
-
const plainSuffix = (kept) => `\u2026[+${s.length - kept.length} chars]`;
|
|
568639
|
-
const enrichedSuffix = (kept) => {
|
|
568640
|
-
const lost = totalMarkers - countRedactionMarkers(kept);
|
|
568641
|
-
return lost > 0 ? `\u2026[+${s.length - kept.length} chars, ${lost} redaction marker(s) among them]` : plainSuffix(kept);
|
|
568642
|
-
};
|
|
568643
|
-
const converge = (suffixFor) => {
|
|
568644
|
-
let keep = max2;
|
|
568645
|
-
let out7 = "";
|
|
568646
|
-
for (let i = 0; i < 4; i++) {
|
|
568647
|
-
const kept = sliceHeadSafe(s, keep);
|
|
568648
|
-
out7 = `${kept}${suffixFor(kept)}`;
|
|
568649
|
-
if (out7.length <= max2)
|
|
568650
|
-
return out7;
|
|
568651
|
-
if (keep === 0)
|
|
568652
|
-
return void 0;
|
|
568653
|
-
keep = Math.max(0, keep - (out7.length - max2));
|
|
568654
|
-
}
|
|
568655
|
-
return out7.length <= max2 ? out7 : void 0;
|
|
568656
|
-
};
|
|
568657
|
-
const out6 = (totalMarkers > 0 ? converge(enrichedSuffix) : void 0) ?? converge(plainSuffix);
|
|
568658
|
-
if (out6 === void 0) {
|
|
568659
|
-
return safeEllipsisTruncate(s, max2);
|
|
568660
|
-
}
|
|
568661
|
-
if (out6.length >= s.length)
|
|
568662
|
-
return s;
|
|
568663
|
-
return out6;
|
|
568664
|
-
}
|
|
568665
|
-
function boundedRedactedSummary(value, max2) {
|
|
568666
|
-
return boundedString(value, max2, redactSecrets3);
|
|
568667
|
-
}
|
|
568668
|
-
var URI_SCHEME, CREDENTIALS_IN_AUTHORITY, URL_OF_ANY_PROTOCOL, BARE_USERNAME_MAX_LEN, SECRET_TIER_PASSES, HOST_LEAK_PASSES, REDACTION_MARKER_RE;
|
|
568669
|
-
var init_untrusted_egress = __esm({
|
|
568670
|
-
"node_modules/@sema-agent/core/dist/core/untrusted-egress.js"() {
|
|
568671
|
-
init_untrusted_text();
|
|
568672
|
-
init_arg_summary();
|
|
568673
|
-
init_surrogate_safe_slice();
|
|
568674
|
-
init_arg_summary();
|
|
568675
|
-
URI_SCHEME = String.raw`[A-Za-z][A-Za-z0-9+.\-_]{0,63}`;
|
|
568676
|
-
CREDENTIALS_IN_AUTHORITY = new RegExp(String.raw`(${URI_SCHEME}:\/\/)((?:[^/\s"'@]*@)+)`, "gi");
|
|
568677
|
-
URL_OF_ANY_PROTOCOL = new RegExp(String.raw`${URI_SCHEME}:\/\/[^\s"'\`]+`, "gi");
|
|
568678
|
-
BARE_USERNAME_MAX_LEN = 20;
|
|
568679
|
-
SECRET_TIER_PASSES = [
|
|
568680
|
-
...SECRET_PASSES,
|
|
568681
|
-
{
|
|
568682
|
-
kind: "url-credentials",
|
|
568683
|
-
confidence: "medium",
|
|
568684
|
-
marker: "[redacted-credentials]",
|
|
568685
|
-
source: "untrusted-egress",
|
|
568686
|
-
re: CREDENTIALS_IN_AUTHORITY,
|
|
568687
|
-
replace: (_m, scheme, userinfo) => redactUserinfo2(scheme, userinfo)
|
|
568688
|
-
},
|
|
568689
|
-
{ kind: "signed-url-param", confidence: "high", marker: "[redacted]", source: "untrusted-egress", re: /([?&#](?:sig|signature|sas|code)=)[^&\s"'#]+/gi, replace: "$1[redacted]" }
|
|
568690
|
-
];
|
|
568691
|
-
HOST_LEAK_PASSES = [
|
|
568692
|
-
...SECRET_TIER_PASSES,
|
|
568693
|
-
{ kind: "url", confidence: "medium", marker: "[redacted-url]", source: "untrusted-egress", re: URL_OF_ANY_PROTOCOL, replace: "[redacted-url]" },
|
|
568694
|
-
{ kind: "fs-path", confidence: "low", marker: "[redacted-path]", source: "untrusted-egress", re: /(?:\/[A-Za-z0-9_.-]+){2,}/g, replace: "[redacted-path]" }
|
|
568695
|
-
];
|
|
568696
|
-
REDACTION_MARKER_RE = /\[redacted(?:-[a-z]+)?\]/g;
|
|
568697
|
-
}
|
|
568698
|
-
});
|
|
568699
|
-
|
|
568700
|
-
// node_modules/@sema-agent/core/dist/core/git-worktree-env.js
|
|
568701
|
-
var WORKTREE_PARENT;
|
|
568702
|
-
var init_git_worktree_env = __esm({
|
|
568703
|
-
"node_modules/@sema-agent/core/dist/core/git-worktree-env.js"() {
|
|
568704
|
-
WORKTREE_PARENT = ".sema-worktrees";
|
|
568705
|
-
}
|
|
568706
|
-
});
|
|
568707
|
-
|
|
568708
|
-
// node_modules/@sema-agent/core/dist/tools/fs/search.js
|
|
568709
|
-
var FILE_MAX_BYTES;
|
|
568710
|
-
var init_search = __esm({
|
|
568711
|
-
"node_modules/@sema-agent/core/dist/tools/fs/search.js"() {
|
|
568712
|
-
init_untrusted_text();
|
|
568713
|
-
init_safety();
|
|
568714
|
-
FILE_MAX_BYTES = 5 * 1024 * 1024;
|
|
568715
|
-
}
|
|
568716
|
-
});
|
|
568717
|
-
|
|
568718
569063
|
// node_modules/@sema-agent/core/dist/core/background-agent-store.js
|
|
568719
569064
|
var background_agent_store_exports = {};
|
|
568720
569065
|
__export(background_agent_store_exports, {
|
|
@@ -568901,6 +569246,7 @@ var init_background_agent_store = __esm({
|
|
|
568901
569246
|
"errorCode",
|
|
568902
569247
|
"errorRetryable",
|
|
568903
569248
|
"errorKind",
|
|
569249
|
+
"errorRetryAfterMs",
|
|
568904
569250
|
"resultIsPartial",
|
|
568905
569251
|
"summary",
|
|
568906
569252
|
"recentSteps",
|
|
@@ -569047,6 +569393,108 @@ var init_workflow_run_store = __esm({
|
|
|
569047
569393
|
}
|
|
569048
569394
|
});
|
|
569049
569395
|
|
|
569396
|
+
// node_modules/@sema-agent/core/dist/core/untrusted-egress.js
|
|
569397
|
+
function redactUserinfo2(scheme, userinfoWithAt) {
|
|
569398
|
+
const userinfo = userinfoWithAt.slice(0, -1);
|
|
569399
|
+
if (userinfo.includes("@"))
|
|
569400
|
+
return `${scheme}[redacted-credentials]@`;
|
|
569401
|
+
const colonIdx = userinfo.indexOf(":");
|
|
569402
|
+
if (colonIdx === -1) {
|
|
569403
|
+
return userinfo.length >= BARE_USERNAME_MAX_LEN ? `${scheme}[redacted-credentials]@` : `${scheme}${userinfo}@`;
|
|
569404
|
+
}
|
|
569405
|
+
return `${scheme}${userinfo.slice(0, colonIdx)}:[redacted-credentials]@`;
|
|
569406
|
+
}
|
|
569407
|
+
function redactSecrets3(s, report) {
|
|
569408
|
+
return runRedactionPasses(s, SECRET_TIER_PASSES, report);
|
|
569409
|
+
}
|
|
569410
|
+
function countRedactionMarkers(s) {
|
|
569411
|
+
return (s.match(REDACTION_MARKER_RE) ?? []).length;
|
|
569412
|
+
}
|
|
569413
|
+
function safeEllipsisTruncate(s, max2) {
|
|
569414
|
+
if (max2 < 1)
|
|
569415
|
+
return "";
|
|
569416
|
+
const budget = max2 - 1;
|
|
569417
|
+
let out6 = "";
|
|
569418
|
+
for (const codePoint of s) {
|
|
569419
|
+
if (out6.length + codePoint.length > budget)
|
|
569420
|
+
break;
|
|
569421
|
+
out6 += codePoint;
|
|
569422
|
+
}
|
|
569423
|
+
return out6 + "\u2026";
|
|
569424
|
+
}
|
|
569425
|
+
function boundedString(value, max2, redact) {
|
|
569426
|
+
let s;
|
|
569427
|
+
try {
|
|
569428
|
+
s = typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
|
|
569429
|
+
} catch {
|
|
569430
|
+
s = "[unserializable result]";
|
|
569431
|
+
}
|
|
569432
|
+
s = redact(s);
|
|
569433
|
+
if (s.length <= max2)
|
|
569434
|
+
return s;
|
|
569435
|
+
const totalMarkers = countRedactionMarkers(s);
|
|
569436
|
+
const plainSuffix = (kept) => `\u2026[+${s.length - kept.length} chars]`;
|
|
569437
|
+
const enrichedSuffix = (kept) => {
|
|
569438
|
+
const lost = totalMarkers - countRedactionMarkers(kept);
|
|
569439
|
+
return lost > 0 ? `\u2026[+${s.length - kept.length} chars, ${lost} redaction marker(s) among them]` : plainSuffix(kept);
|
|
569440
|
+
};
|
|
569441
|
+
const converge = (suffixFor) => {
|
|
569442
|
+
let keep = max2;
|
|
569443
|
+
let out7 = "";
|
|
569444
|
+
for (let i = 0; i < 4; i++) {
|
|
569445
|
+
const kept = sliceHeadSafe(s, keep);
|
|
569446
|
+
out7 = `${kept}${suffixFor(kept)}`;
|
|
569447
|
+
if (out7.length <= max2)
|
|
569448
|
+
return out7;
|
|
569449
|
+
if (keep === 0)
|
|
569450
|
+
return void 0;
|
|
569451
|
+
keep = Math.max(0, keep - (out7.length - max2));
|
|
569452
|
+
}
|
|
569453
|
+
return out7.length <= max2 ? out7 : void 0;
|
|
569454
|
+
};
|
|
569455
|
+
const out6 = (totalMarkers > 0 ? converge(enrichedSuffix) : void 0) ?? converge(plainSuffix);
|
|
569456
|
+
if (out6 === void 0) {
|
|
569457
|
+
return safeEllipsisTruncate(s, max2);
|
|
569458
|
+
}
|
|
569459
|
+
if (out6.length >= s.length)
|
|
569460
|
+
return s;
|
|
569461
|
+
return out6;
|
|
569462
|
+
}
|
|
569463
|
+
function boundedRedactedSummary(value, max2) {
|
|
569464
|
+
return boundedString(value, max2, redactSecrets3);
|
|
569465
|
+
}
|
|
569466
|
+
var URI_SCHEME, CREDENTIALS_IN_AUTHORITY, URL_OF_ANY_PROTOCOL, BARE_USERNAME_MAX_LEN, SECRET_TIER_PASSES, HOST_LEAK_PASSES, REDACTION_MARKER_RE;
|
|
569467
|
+
var init_untrusted_egress = __esm({
|
|
569468
|
+
"node_modules/@sema-agent/core/dist/core/untrusted-egress.js"() {
|
|
569469
|
+
init_untrusted_text();
|
|
569470
|
+
init_arg_summary();
|
|
569471
|
+
init_surrogate_safe_slice();
|
|
569472
|
+
init_arg_summary();
|
|
569473
|
+
URI_SCHEME = String.raw`[A-Za-z][A-Za-z0-9+.\-_]{0,63}`;
|
|
569474
|
+
CREDENTIALS_IN_AUTHORITY = new RegExp(String.raw`(${URI_SCHEME}:\/\/)((?:[^/\s"'@]*@)+)`, "gi");
|
|
569475
|
+
URL_OF_ANY_PROTOCOL = new RegExp(String.raw`${URI_SCHEME}:\/\/[^\s"'\`]+`, "gi");
|
|
569476
|
+
BARE_USERNAME_MAX_LEN = 20;
|
|
569477
|
+
SECRET_TIER_PASSES = [
|
|
569478
|
+
...SECRET_PASSES,
|
|
569479
|
+
{
|
|
569480
|
+
kind: "url-credentials",
|
|
569481
|
+
confidence: "medium",
|
|
569482
|
+
marker: "[redacted-credentials]",
|
|
569483
|
+
source: "untrusted-egress",
|
|
569484
|
+
re: CREDENTIALS_IN_AUTHORITY,
|
|
569485
|
+
replace: (_m, scheme, userinfo) => redactUserinfo2(scheme, userinfo)
|
|
569486
|
+
},
|
|
569487
|
+
{ kind: "signed-url-param", confidence: "high", marker: "[redacted]", source: "untrusted-egress", re: /([?&#](?:sig|signature|sas|code)=)[^&\s"'#]+/gi, replace: "$1[redacted]" }
|
|
569488
|
+
];
|
|
569489
|
+
HOST_LEAK_PASSES = [
|
|
569490
|
+
...SECRET_TIER_PASSES,
|
|
569491
|
+
{ kind: "url", confidence: "medium", marker: "[redacted-url]", source: "untrusted-egress", re: URL_OF_ANY_PROTOCOL, replace: "[redacted-url]" },
|
|
569492
|
+
{ kind: "fs-path", confidence: "low", marker: "[redacted-path]", source: "untrusted-egress", re: /(?:\/[A-Za-z0-9_.-]+){2,}/g, replace: "[redacted-path]" }
|
|
569493
|
+
];
|
|
569494
|
+
REDACTION_MARKER_RE = /\[redacted(?:-[a-z]+)?\]/g;
|
|
569495
|
+
}
|
|
569496
|
+
});
|
|
569497
|
+
|
|
569050
569498
|
// node_modules/@sema-agent/core/dist/core/task-registry-shared.js
|
|
569051
569499
|
function mintCompletionId(target) {
|
|
569052
569500
|
if (target.completionId === void 0)
|
|
@@ -569099,10 +569547,10 @@ function statusFromBackground(status3, exitCode) {
|
|
|
569099
569547
|
return exitCode === 0 ? "completed" : "failed";
|
|
569100
569548
|
return "failed";
|
|
569101
569549
|
}
|
|
569102
|
-
function rollSpoolText(spool, s,
|
|
569103
|
-
if (s.length <=
|
|
569550
|
+
function rollSpoolText(spool, s, cap2, onDrop) {
|
|
569551
|
+
if (s.length <= cap2)
|
|
569104
569552
|
return s;
|
|
569105
|
-
const half = Math.floor(
|
|
569553
|
+
const half = Math.floor(cap2 / 2);
|
|
569106
569554
|
const dropped2 = s.slice(half, s.length - half);
|
|
569107
569555
|
spool.rolledChars += dropped2.length;
|
|
569108
569556
|
onDrop?.(dropped2);
|
|
@@ -570626,6 +571074,8 @@ function settleBackgroundAgentLane(core, id, outcome) {
|
|
|
570626
571074
|
handle2.errorRetryable = outcome.retryable;
|
|
570627
571075
|
if (outcome.errorKind !== void 0)
|
|
570628
571076
|
handle2.errorKind = outcome.errorKind;
|
|
571077
|
+
if (outcome.retryAfterMs !== void 0)
|
|
571078
|
+
handle2.errorRetryAfterMs = outcome.retryAfterMs;
|
|
570629
571079
|
}
|
|
570630
571080
|
handle2.updatedAt = Date.now();
|
|
570631
571081
|
if (outcome.seq !== void 0)
|
|
@@ -570643,7 +571093,8 @@ function settleBackgroundAgentLane(core, id, outcome) {
|
|
|
570643
571093
|
...handle2.error !== void 0 ? { error: handle2.error } : {},
|
|
570644
571094
|
...handle2.errorCode !== void 0 ? { errorCode: handle2.errorCode } : {},
|
|
570645
571095
|
...handle2.errorRetryable !== void 0 ? { errorRetryable: handle2.errorRetryable } : {},
|
|
570646
|
-
...handle2.errorKind !== void 0 ? { errorKind: handle2.errorKind } : {}
|
|
571096
|
+
...handle2.errorKind !== void 0 ? { errorKind: handle2.errorKind } : {},
|
|
571097
|
+
...handle2.errorRetryAfterMs !== void 0 ? { errorRetryAfterMs: handle2.errorRetryAfterMs } : {}
|
|
570647
571098
|
}, ["parkedCheckpointToken", "parkClaimId", "parkedAt"]);
|
|
570648
571099
|
return outcome.status;
|
|
570649
571100
|
}
|
|
@@ -570770,6 +571221,7 @@ function reviveBackgroundAgentLane(core, id, access7, abort) {
|
|
|
570770
571221
|
handle2.errorCode = void 0;
|
|
570771
571222
|
handle2.errorRetryable = void 0;
|
|
570772
571223
|
handle2.errorKind = void 0;
|
|
571224
|
+
handle2.errorRetryAfterMs = void 0;
|
|
570773
571225
|
handle2.resultIsPartial = void 0;
|
|
570774
571226
|
handle2.stopSource = void 0;
|
|
570775
571227
|
handle2.completionId = void 0;
|
|
@@ -570954,6 +571406,7 @@ function buildAgentPollDetails(input) {
|
|
|
570954
571406
|
...failed && input.error !== void 0 ? { error: delimitUntrusted("agent error", boundedRedactedSummary(input.error, 300)) } : {},
|
|
570955
571407
|
...failed && input.errorCode !== void 0 ? { errorCode: input.errorCode } : {},
|
|
570956
571408
|
...failed && input.errorRetryable !== void 0 ? { retryable: input.errorRetryable } : {},
|
|
571409
|
+
...failed && input.errorRetryAfterMs !== void 0 ? { retryAfterMs: input.errorRetryAfterMs } : {},
|
|
570957
571410
|
...input.resultIsPartial === true ? { partial_result: true } : {},
|
|
570958
571411
|
...input.completionId !== void 0 ? { completionId: input.completionId } : {}
|
|
570959
571412
|
};
|
|
@@ -570971,7 +571424,7 @@ The agent is durably suspended, waiting for an approval decision. It resumes whe
|
|
|
570971
571424
|
})
|
|
570972
571425
|
};
|
|
570973
571426
|
}
|
|
570974
|
-
const kindClause = row2.status === "failed" && row2.errorKind !== void 0 && row2.errorRetryable !== void 0 ? ` (error_kind: ${row2.errorKind}, retryable: ${row2.errorRetryable})` : "";
|
|
571427
|
+
const kindClause = row2.status === "failed" && row2.errorKind !== void 0 && row2.errorRetryable !== void 0 ? ` (error_kind: ${row2.errorKind}, retryable: ${row2.errorRetryable}${row2.errorRetryAfterMs !== void 0 ? `, retry_after_ms: ${row2.errorRetryAfterMs}` : ""})` : "";
|
|
570975
571428
|
const body = `status: ${row2.status}
|
|
570976
571429
|
${row2.error ? `error: ${row2.error}${kindClause}
|
|
570977
571430
|
` : ""}${row2.finalOutput ? `--- result${row2.resultIsPartial ? " (partial \u2014 produced before the task was stopped)" : ""} ---
|
|
@@ -570987,6 +571440,7 @@ ${clipTaskOutput(row2.finalOutputFull ?? row2.finalOutput)}` : "(no result text)
|
|
|
570987
571440
|
...row2.error !== void 0 ? { error: row2.error } : {},
|
|
570988
571441
|
...row2.errorCode !== void 0 ? { errorCode: row2.errorCode } : {},
|
|
570989
571442
|
...row2.errorRetryable !== void 0 ? { errorRetryable: row2.errorRetryable } : {},
|
|
571443
|
+
...row2.errorRetryAfterMs !== void 0 ? { errorRetryAfterMs: row2.errorRetryAfterMs } : {},
|
|
570990
571444
|
...row2.resultIsPartial === true ? { resultIsPartial: true } : {},
|
|
570991
571445
|
...row2.completionId !== void 0 ? { completionId: row2.completionId } : {}
|
|
570992
571446
|
}),
|
|
@@ -571027,7 +571481,7 @@ The agent is durably suspended, waiting for an approval decision. It resumes whe
|
|
|
571027
571481
|
}
|
|
571028
571482
|
const fullResult = handle2.result ? handle2.resultFull ?? handle2.result : void 0;
|
|
571029
571483
|
const resultText = fullResult !== void 0 ? await spillClippedAgentResult(handle2, fullResult, clipTaskOutput(fullResult, handle2.outputFile), store, sessionId) : void 0;
|
|
571030
|
-
const kindClause = handle2.status === "failed" && handle2.errorKind !== void 0 && handle2.errorRetryable !== void 0 ? ` (error_kind: ${handle2.errorKind}, retryable: ${handle2.errorRetryable})` : "";
|
|
571484
|
+
const kindClause = handle2.status === "failed" && handle2.errorKind !== void 0 && handle2.errorRetryable !== void 0 ? ` (error_kind: ${handle2.errorKind}, retryable: ${handle2.errorRetryable}${handle2.errorRetryAfterMs !== void 0 ? `, retry_after_ms: ${handle2.errorRetryAfterMs}` : ""})` : "";
|
|
571031
571485
|
const body = running ? oneShot === true ? `status: running
|
|
571032
571486
|
This is a ONE-SHOT submission \u2014 there is no later turn for a background notification to land in, so do NOT end your turn expecting one. Actively wait instead: TaskOutput({ task_id: "${handle2.id}", block: true }). If it is still running after the wait, wait again (bounded) rather than ending the turn, or write out your best available answer now if you are near your own time budget.` : `status: running
|
|
571033
571487
|
The agent is still working \u2014 you will be notified when it completes.` : `status: ${handle2.status}
|
|
@@ -571045,6 +571499,7 @@ ${resultText}` : "(no result text)"}`;
|
|
|
571045
571499
|
...handle2.error !== void 0 ? { error: handle2.error } : {},
|
|
571046
571500
|
...handle2.errorCode !== void 0 ? { errorCode: handle2.errorCode } : {},
|
|
571047
571501
|
...handle2.errorRetryable !== void 0 ? { errorRetryable: handle2.errorRetryable } : {},
|
|
571502
|
+
...handle2.errorRetryAfterMs !== void 0 ? { errorRetryAfterMs: handle2.errorRetryAfterMs } : {},
|
|
571048
571503
|
...handle2.resultIsPartial === true ? { resultIsPartial: true } : {},
|
|
571049
571504
|
...handle2.completionId !== void 0 ? { completionId: handle2.completionId } : {}
|
|
571050
571505
|
}),
|
|
@@ -571218,9 +571673,9 @@ async function drainBashTailBestEffort(handle2) {
|
|
|
571218
571673
|
if (drained.ok && (drained.value.stdout.length > 0 || drained.value.stderr.length > 0)) {
|
|
571219
571674
|
if (handle2.spool !== void 0) {
|
|
571220
571675
|
const spool = handle2.spool;
|
|
571221
|
-
const
|
|
571222
|
-
spool.stdout = rollSpoolText(spool, spool.stdout + drained.value.stdout,
|
|
571223
|
-
spool.stderr = rollSpoolText(spool, spool.stderr + drained.value.stderr,
|
|
571676
|
+
const cap2 = 2 * TASK_OUTPUT_MAX_CHARS;
|
|
571677
|
+
spool.stdout = rollSpoolText(spool, spool.stdout + drained.value.stdout, cap2);
|
|
571678
|
+
spool.stderr = rollSpoolText(spool, spool.stderr + drained.value.stderr, cap2);
|
|
571224
571679
|
const ap = await handle2.env.appendFile(handle2.outputFile, drained.value.stdout + drained.value.stderr);
|
|
571225
571680
|
if (!ap.ok)
|
|
571226
571681
|
spool.mirrorFailed = true;
|
|
@@ -572382,6 +572837,283 @@ ${shape(stderr) || "(none)"}`;
|
|
|
572382
572837
|
}
|
|
572383
572838
|
});
|
|
572384
572839
|
|
|
572840
|
+
// node_modules/@sema-agent/core/dist/tools/fs/search.js
|
|
572841
|
+
var FILE_MAX_BYTES;
|
|
572842
|
+
var init_search = __esm({
|
|
572843
|
+
"node_modules/@sema-agent/core/dist/tools/fs/search.js"() {
|
|
572844
|
+
init_untrusted_text();
|
|
572845
|
+
init_safety();
|
|
572846
|
+
FILE_MAX_BYTES = 5 * 1024 * 1024;
|
|
572847
|
+
}
|
|
572848
|
+
});
|
|
572849
|
+
|
|
572850
|
+
// node_modules/@sema-agent/core/dist/tools/fs/repo-map.js
|
|
572851
|
+
var FILE_SCAN_MAX_BYTES;
|
|
572852
|
+
var init_repo_map = __esm({
|
|
572853
|
+
"node_modules/@sema-agent/core/dist/tools/fs/repo-map.js"() {
|
|
572854
|
+
init_build3();
|
|
572855
|
+
init_tools3();
|
|
572856
|
+
init_safety();
|
|
572857
|
+
init_search();
|
|
572858
|
+
FILE_SCAN_MAX_BYTES = 256 * 1024;
|
|
572859
|
+
}
|
|
572860
|
+
});
|
|
572861
|
+
|
|
572862
|
+
// node_modules/@sema-agent/core/dist/tools/fs/encoding.js
|
|
572863
|
+
var init_encoding = __esm({
|
|
572864
|
+
"node_modules/@sema-agent/core/dist/tools/fs/encoding.js"() {
|
|
572865
|
+
}
|
|
572866
|
+
});
|
|
572867
|
+
|
|
572868
|
+
// node_modules/@sema-agent/core/dist/tools/fs/notebook.js
|
|
572869
|
+
var init_notebook2 = __esm({
|
|
572870
|
+
"node_modules/@sema-agent/core/dist/tools/fs/notebook.js"() {
|
|
572871
|
+
init_safety();
|
|
572872
|
+
}
|
|
572873
|
+
});
|
|
572874
|
+
|
|
572875
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-shared.js
|
|
572876
|
+
var MAX_READ_BYTES2, SLICED_READ_MAX_BYTES, MAX_EDIT_BYTES, MAX_IMAGE_READ_BYTES, MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES, NO_DOWNSAMPLER_IMAGE_CAP_HINT, BASH_DEFAULT_TIMEOUT_SEC, BASH_MAX_TIMEOUT_SEC, BASH_DEFAULT_TIMEOUT_MS2, BASH_MAX_TIMEOUT_MS, FILE_PATH_PARAMS;
|
|
572877
|
+
var init_fs_shared = __esm({
|
|
572878
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-shared.js"() {
|
|
572879
|
+
init_build3();
|
|
572880
|
+
init_tool_errors();
|
|
572881
|
+
init_safety();
|
|
572882
|
+
init_encoding();
|
|
572883
|
+
init_search();
|
|
572884
|
+
init_notebook2();
|
|
572885
|
+
init_mcp4();
|
|
572886
|
+
MAX_READ_BYTES2 = 256 * 1024;
|
|
572887
|
+
SLICED_READ_MAX_BYTES = 64 * 1024 * 1024;
|
|
572888
|
+
MAX_EDIT_BYTES = 1024 * 1024 * 1024;
|
|
572889
|
+
MAX_IMAGE_READ_BYTES = 5 * 1024 * 1024;
|
|
572890
|
+
MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES = 64 * 1024 * 1024;
|
|
572891
|
+
NO_DOWNSAMPLER_IMAGE_CAP_HINT = `Install the optional "sharp" dependency (declared in this package's optionalDependencies) to read images up to ${MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES} bytes \u2014 it downsamples them to fit the API image limit.`;
|
|
572892
|
+
BASH_DEFAULT_TIMEOUT_SEC = 120;
|
|
572893
|
+
BASH_MAX_TIMEOUT_SEC = 600;
|
|
572894
|
+
BASH_DEFAULT_TIMEOUT_MS2 = BASH_DEFAULT_TIMEOUT_SEC * 1e3;
|
|
572895
|
+
BASH_MAX_TIMEOUT_MS = BASH_MAX_TIMEOUT_SEC * 1e3;
|
|
572896
|
+
FILE_PATH_PARAMS = {
|
|
572897
|
+
file_path: typebox_exports.String({ description: "File path (within the configured root)." })
|
|
572898
|
+
};
|
|
572899
|
+
}
|
|
572900
|
+
});
|
|
572901
|
+
|
|
572902
|
+
// node_modules/@sema-agent/core/dist/tools/fs/pdf.js
|
|
572903
|
+
var PDF_TARGET_RAW_SIZE2, PDF_MAX_EXTRACT_SIZE2;
|
|
572904
|
+
var init_pdf2 = __esm({
|
|
572905
|
+
"node_modules/@sema-agent/core/dist/tools/fs/pdf.js"() {
|
|
572906
|
+
PDF_TARGET_RAW_SIZE2 = 20 * 1024 * 1024;
|
|
572907
|
+
PDF_MAX_EXTRACT_SIZE2 = 100 * 1024 * 1024;
|
|
572908
|
+
}
|
|
572909
|
+
});
|
|
572910
|
+
|
|
572911
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-pdf.js
|
|
572912
|
+
var init_fs_pdf = __esm({
|
|
572913
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-pdf.js"() {
|
|
572914
|
+
init_tools3();
|
|
572915
|
+
init_untrusted_text();
|
|
572916
|
+
init_mcp4();
|
|
572917
|
+
init_pdf2();
|
|
572918
|
+
init_fs_shared();
|
|
572919
|
+
init_pdf2();
|
|
572920
|
+
}
|
|
572921
|
+
});
|
|
572922
|
+
|
|
572923
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-read.js
|
|
572924
|
+
var init_fs_read = __esm({
|
|
572925
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-read.js"() {
|
|
572926
|
+
init_build3();
|
|
572927
|
+
init_tools3();
|
|
572928
|
+
init_safety();
|
|
572929
|
+
init_encoding();
|
|
572930
|
+
init_notebook2();
|
|
572931
|
+
init_mcp4();
|
|
572932
|
+
init_pdf2();
|
|
572933
|
+
init_fs_shared();
|
|
572934
|
+
init_fs_pdf();
|
|
572935
|
+
}
|
|
572936
|
+
});
|
|
572937
|
+
|
|
572938
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-write.js
|
|
572939
|
+
var init_fs_write = __esm({
|
|
572940
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-write.js"() {
|
|
572941
|
+
init_build3();
|
|
572942
|
+
init_tools3();
|
|
572943
|
+
init_safety();
|
|
572944
|
+
init_encoding();
|
|
572945
|
+
init_fs_shared();
|
|
572946
|
+
}
|
|
572947
|
+
});
|
|
572948
|
+
|
|
572949
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-search-tools.js
|
|
572950
|
+
var init_fs_search_tools = __esm({
|
|
572951
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-search-tools.js"() {
|
|
572952
|
+
init_build3();
|
|
572953
|
+
init_tools3();
|
|
572954
|
+
init_safety();
|
|
572955
|
+
init_search();
|
|
572956
|
+
}
|
|
572957
|
+
});
|
|
572958
|
+
|
|
572959
|
+
// node_modules/@sema-agent/core/dist/tools/fs/bash-readonly-classifier.js
|
|
572960
|
+
var init_bash_readonly_classifier = __esm({
|
|
572961
|
+
"node_modules/@sema-agent/core/dist/tools/fs/bash-readonly-classifier.js"() {
|
|
572962
|
+
init_safety();
|
|
572963
|
+
}
|
|
572964
|
+
});
|
|
572965
|
+
|
|
572966
|
+
// node_modules/@sema-agent/core/dist/core/remote-env.js
|
|
572967
|
+
var init_remote_env3 = __esm({
|
|
572968
|
+
"node_modules/@sema-agent/core/dist/core/remote-env.js"() {
|
|
572969
|
+
}
|
|
572970
|
+
});
|
|
572971
|
+
|
|
572972
|
+
// node_modules/@sema-agent/core/dist/tools/fs/gh-rate-limit.js
|
|
572973
|
+
var init_gh_rate_limit = __esm({
|
|
572974
|
+
"node_modules/@sema-agent/core/dist/tools/fs/gh-rate-limit.js"() {
|
|
572975
|
+
}
|
|
572976
|
+
});
|
|
572977
|
+
|
|
572978
|
+
// node_modules/@sema-agent/core/dist/tools/fs/fs-bash.js
|
|
572979
|
+
var init_fs_bash = __esm({
|
|
572980
|
+
"node_modules/@sema-agent/core/dist/tools/fs/fs-bash.js"() {
|
|
572981
|
+
init_build3();
|
|
572982
|
+
init_tools3();
|
|
572983
|
+
init_task_registry();
|
|
572984
|
+
init_task_registry_shared();
|
|
572985
|
+
init_task_tool_shape();
|
|
572986
|
+
init_background_shell();
|
|
572987
|
+
init_untrusted_text();
|
|
572988
|
+
init_mcp4();
|
|
572989
|
+
init_safety();
|
|
572990
|
+
init_remote_env3();
|
|
572991
|
+
init_gh_rate_limit();
|
|
572992
|
+
init_fs_shared();
|
|
572993
|
+
init_bash_readonly_classifier();
|
|
572994
|
+
}
|
|
572995
|
+
});
|
|
572996
|
+
|
|
572997
|
+
// node_modules/@sema-agent/core/dist/tools/fs/index.js
|
|
572998
|
+
var init_fs = __esm({
|
|
572999
|
+
"node_modules/@sema-agent/core/dist/tools/fs/index.js"() {
|
|
573000
|
+
init_task_registry();
|
|
573001
|
+
init_background_shell();
|
|
573002
|
+
init_safety();
|
|
573003
|
+
init_repo_map();
|
|
573004
|
+
init_fs_shared();
|
|
573005
|
+
init_fs_pdf();
|
|
573006
|
+
init_fs_read();
|
|
573007
|
+
init_fs_write();
|
|
573008
|
+
init_fs_search_tools();
|
|
573009
|
+
init_bash_readonly_classifier();
|
|
573010
|
+
init_fs_bash();
|
|
573011
|
+
init_bash_readonly_classifier();
|
|
573012
|
+
init_fs_shared();
|
|
573013
|
+
init_fs_read();
|
|
573014
|
+
init_fs_write();
|
|
573015
|
+
init_fs_search_tools();
|
|
573016
|
+
init_fs_bash();
|
|
573017
|
+
}
|
|
573018
|
+
});
|
|
573019
|
+
|
|
573020
|
+
// node_modules/@sema-agent/core/dist/core/tool-policy.js
|
|
573021
|
+
function refuseOutOfContractDecision(d4) {
|
|
573022
|
+
if (typeof d4 !== "object" || d4 === null)
|
|
573023
|
+
return d4;
|
|
573024
|
+
if (!Object.prototype.hasOwnProperty.call(d4, RETIRED_TEXT_FIELD))
|
|
573025
|
+
return d4;
|
|
573026
|
+
return { action: "deny", message: RETIRED_TEXT_FIELD_DENY_MESSAGE, decisionReason: "rule" };
|
|
573027
|
+
}
|
|
573028
|
+
function toolPolicyNameSets(p) {
|
|
573029
|
+
const sets = p?.nameSets;
|
|
573030
|
+
return Array.isArray(sets) ? sets : [];
|
|
573031
|
+
}
|
|
573032
|
+
function createAllowDenyPolicy(opts) {
|
|
573033
|
+
const allow = opts.allow ? new Set(opts.allow) : void 0;
|
|
573034
|
+
const deny2 = new Set(opts.deny ?? []);
|
|
573035
|
+
return {
|
|
573036
|
+
nameSets: [{ ...opts.allow ? { allow: [...opts.allow] } : {}, ...opts.deny ? { deny: [...opts.deny] } : {} }],
|
|
573037
|
+
check(req) {
|
|
573038
|
+
const toolName2 = req.toolName;
|
|
573039
|
+
if (deny2.has(toolName2)) {
|
|
573040
|
+
return { action: "deny", message: `tool "${req.toolName}" is denied by policy` };
|
|
573041
|
+
}
|
|
573042
|
+
if (allow && !allow.has(toolName2)) {
|
|
573043
|
+
return { action: "deny", message: `tool "${req.toolName}" is not in the allowlist` };
|
|
573044
|
+
}
|
|
573045
|
+
return ALLOW;
|
|
573046
|
+
}
|
|
573047
|
+
};
|
|
573048
|
+
}
|
|
573049
|
+
function combinePolicies(...policies) {
|
|
573050
|
+
const nameSets = policies.flatMap(toolPolicyNameSets);
|
|
573051
|
+
return {
|
|
573052
|
+
...nameSets.length > 0 ? { nameSets } : {},
|
|
573053
|
+
async check(req, signal) {
|
|
573054
|
+
let asked;
|
|
573055
|
+
let current5 = req;
|
|
573056
|
+
let rewrite;
|
|
573057
|
+
for (const p of policies) {
|
|
573058
|
+
const d4 = refuseOutOfContractDecision(await p.check(current5, signal));
|
|
573059
|
+
if (d4.action === "deny") {
|
|
573060
|
+
return rewrite?.updatedInput !== void 0 ? { ...d4, updatedInput: rewrite.updatedInput } : d4;
|
|
573061
|
+
}
|
|
573062
|
+
if (d4.updatedInput !== void 0) {
|
|
573063
|
+
current5 = { ...current5, args: d4.updatedInput };
|
|
573064
|
+
rewrite = d4;
|
|
573065
|
+
}
|
|
573066
|
+
if (d4.action === "ask" && (asked === void 0 || d4.requiresRealApproval === true && asked.requiresRealApproval !== true)) {
|
|
573067
|
+
asked = d4;
|
|
573068
|
+
}
|
|
573069
|
+
}
|
|
573070
|
+
if (asked) {
|
|
573071
|
+
const merged = rewrite?.updatedInput;
|
|
573072
|
+
return merged !== void 0 ? { ...asked, updatedInput: merged } : asked;
|
|
573073
|
+
}
|
|
573074
|
+
return rewrite ?? ALLOW;
|
|
573075
|
+
}
|
|
573076
|
+
};
|
|
573077
|
+
}
|
|
573078
|
+
var ALLOW, RETIRED_TEXT_FIELD, RETIRED_TEXT_FIELD_DENY_MESSAGE, COARSE_SHELL_TOOLS, CASE_INSENSITIVE_FS;
|
|
573079
|
+
var init_tool_policy = __esm({
|
|
573080
|
+
"node_modules/@sema-agent/core/dist/core/tool-policy.js"() {
|
|
573081
|
+
init_fs();
|
|
573082
|
+
init_safety();
|
|
573083
|
+
ALLOW = { action: "allow" };
|
|
573084
|
+
RETIRED_TEXT_FIELD = "reason";
|
|
573085
|
+
RETIRED_TEXT_FIELD_DENY_MESSAGE = `a permission decision carries the retired "${RETIRED_TEXT_FIELD}" field \u2014 rename it to "message" (the one text field a decision carries); denied fail-closed rather than executing a decision whose text this layer cannot read`;
|
|
573086
|
+
COARSE_SHELL_TOOLS = ["Bash", "Monitor"];
|
|
573087
|
+
CASE_INSENSITIVE_FS = process.platform === "darwin" || process.platform === "win32";
|
|
573088
|
+
}
|
|
573089
|
+
});
|
|
573090
|
+
|
|
573091
|
+
// node_modules/@sema-agent/core/dist/agents/tool-filter.js
|
|
573092
|
+
var init_tool_filter = __esm({
|
|
573093
|
+
"node_modules/@sema-agent/core/dist/agents/tool-filter.js"() {
|
|
573094
|
+
}
|
|
573095
|
+
});
|
|
573096
|
+
|
|
573097
|
+
// node_modules/@sema-agent/core/dist/agents/builtin-agents.js
|
|
573098
|
+
var init_builtin_agents = __esm({
|
|
573099
|
+
"node_modules/@sema-agent/core/dist/agents/builtin-agents.js"() {
|
|
573100
|
+
}
|
|
573101
|
+
});
|
|
573102
|
+
|
|
573103
|
+
// node_modules/@sema-agent/core/dist/agents/suspend-guard.js
|
|
573104
|
+
var init_suspend_guard = __esm({
|
|
573105
|
+
"node_modules/@sema-agent/core/dist/agents/suspend-guard.js"() {
|
|
573106
|
+
}
|
|
573107
|
+
});
|
|
573108
|
+
|
|
573109
|
+
// node_modules/@sema-agent/core/dist/core/git-worktree-env.js
|
|
573110
|
+
var WORKTREE_PARENT;
|
|
573111
|
+
var init_git_worktree_env = __esm({
|
|
573112
|
+
"node_modules/@sema-agent/core/dist/core/git-worktree-env.js"() {
|
|
573113
|
+
WORKTREE_PARENT = ".sema-worktrees";
|
|
573114
|
+
}
|
|
573115
|
+
});
|
|
573116
|
+
|
|
572385
573117
|
// node_modules/@sema-agent/core/dist/agents/retain-ledger.js
|
|
572386
573118
|
var init_retain_ledger = __esm({
|
|
572387
573119
|
"node_modules/@sema-agent/core/dist/agents/retain-ledger.js"() {
|
|
@@ -572630,6 +573362,7 @@ var EXTRA_TOOLS_MAX_FACTORY_CALLS_PER_TREE, EXTRA_TOOLS_BUDGET_NOTE, FAILED_SESS
|
|
|
572630
573362
|
var init_subagent = __esm({
|
|
572631
573363
|
"node_modules/@sema-agent/core/dist/agents/subagent.js"() {
|
|
572632
573364
|
init_build3();
|
|
573365
|
+
init_tool_policy();
|
|
572633
573366
|
init_roles();
|
|
572634
573367
|
init_synthetic_tools();
|
|
572635
573368
|
init_tool_disclosure();
|
|
@@ -572687,253 +573420,15 @@ var init_send_message_tool = __esm({
|
|
|
572687
573420
|
}
|
|
572688
573421
|
});
|
|
572689
573422
|
|
|
572690
|
-
// node_modules/@sema-agent/core/dist/tools/fs/repo-map.js
|
|
572691
|
-
var FILE_SCAN_MAX_BYTES;
|
|
572692
|
-
var init_repo_map = __esm({
|
|
572693
|
-
"node_modules/@sema-agent/core/dist/tools/fs/repo-map.js"() {
|
|
572694
|
-
init_build3();
|
|
572695
|
-
init_tools3();
|
|
572696
|
-
init_safety();
|
|
572697
|
-
init_search();
|
|
572698
|
-
FILE_SCAN_MAX_BYTES = 256 * 1024;
|
|
572699
|
-
}
|
|
572700
|
-
});
|
|
572701
|
-
|
|
572702
|
-
// node_modules/@sema-agent/core/dist/tools/fs/encoding.js
|
|
572703
|
-
var init_encoding = __esm({
|
|
572704
|
-
"node_modules/@sema-agent/core/dist/tools/fs/encoding.js"() {
|
|
572705
|
-
}
|
|
572706
|
-
});
|
|
572707
|
-
|
|
572708
|
-
// node_modules/@sema-agent/core/dist/tools/fs/notebook.js
|
|
572709
|
-
var init_notebook2 = __esm({
|
|
572710
|
-
"node_modules/@sema-agent/core/dist/tools/fs/notebook.js"() {
|
|
572711
|
-
init_safety();
|
|
572712
|
-
}
|
|
572713
|
-
});
|
|
572714
|
-
|
|
572715
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-shared.js
|
|
572716
|
-
var MAX_READ_BYTES2, SLICED_READ_MAX_BYTES, MAX_EDIT_BYTES, MAX_IMAGE_READ_BYTES, MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES, NO_DOWNSAMPLER_IMAGE_CAP_HINT, BASH_DEFAULT_TIMEOUT_SEC, BASH_MAX_TIMEOUT_SEC, BASH_DEFAULT_TIMEOUT_MS2, BASH_MAX_TIMEOUT_MS, FILE_PATH_PARAMS;
|
|
572717
|
-
var init_fs_shared = __esm({
|
|
572718
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-shared.js"() {
|
|
572719
|
-
init_build3();
|
|
572720
|
-
init_tool_errors();
|
|
572721
|
-
init_safety();
|
|
572722
|
-
init_encoding();
|
|
572723
|
-
init_search();
|
|
572724
|
-
init_notebook2();
|
|
572725
|
-
init_mcp4();
|
|
572726
|
-
MAX_READ_BYTES2 = 256 * 1024;
|
|
572727
|
-
SLICED_READ_MAX_BYTES = 64 * 1024 * 1024;
|
|
572728
|
-
MAX_EDIT_BYTES = 1024 * 1024 * 1024;
|
|
572729
|
-
MAX_IMAGE_READ_BYTES = 5 * 1024 * 1024;
|
|
572730
|
-
MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES = 64 * 1024 * 1024;
|
|
572731
|
-
NO_DOWNSAMPLER_IMAGE_CAP_HINT = `Install the optional "sharp" dependency (declared in this package's optionalDependencies) to read images up to ${MAX_IMAGE_DOWNSAMPLE_INPUT_BYTES} bytes \u2014 it downsamples them to fit the API image limit.`;
|
|
572732
|
-
BASH_DEFAULT_TIMEOUT_SEC = 120;
|
|
572733
|
-
BASH_MAX_TIMEOUT_SEC = 600;
|
|
572734
|
-
BASH_DEFAULT_TIMEOUT_MS2 = BASH_DEFAULT_TIMEOUT_SEC * 1e3;
|
|
572735
|
-
BASH_MAX_TIMEOUT_MS = BASH_MAX_TIMEOUT_SEC * 1e3;
|
|
572736
|
-
FILE_PATH_PARAMS = {
|
|
572737
|
-
file_path: typebox_exports.String({ description: "File path (within the configured root)." })
|
|
572738
|
-
};
|
|
572739
|
-
}
|
|
572740
|
-
});
|
|
572741
|
-
|
|
572742
|
-
// node_modules/@sema-agent/core/dist/tools/fs/pdf.js
|
|
572743
|
-
var PDF_TARGET_RAW_SIZE2, PDF_MAX_EXTRACT_SIZE2;
|
|
572744
|
-
var init_pdf2 = __esm({
|
|
572745
|
-
"node_modules/@sema-agent/core/dist/tools/fs/pdf.js"() {
|
|
572746
|
-
PDF_TARGET_RAW_SIZE2 = 20 * 1024 * 1024;
|
|
572747
|
-
PDF_MAX_EXTRACT_SIZE2 = 100 * 1024 * 1024;
|
|
572748
|
-
}
|
|
572749
|
-
});
|
|
572750
|
-
|
|
572751
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-pdf.js
|
|
572752
|
-
var init_fs_pdf = __esm({
|
|
572753
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-pdf.js"() {
|
|
572754
|
-
init_tools3();
|
|
572755
|
-
init_untrusted_text();
|
|
572756
|
-
init_mcp4();
|
|
572757
|
-
init_pdf2();
|
|
572758
|
-
init_fs_shared();
|
|
572759
|
-
init_pdf2();
|
|
572760
|
-
}
|
|
572761
|
-
});
|
|
572762
|
-
|
|
572763
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-read.js
|
|
572764
|
-
var init_fs_read = __esm({
|
|
572765
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-read.js"() {
|
|
572766
|
-
init_build3();
|
|
572767
|
-
init_tools3();
|
|
572768
|
-
init_safety();
|
|
572769
|
-
init_encoding();
|
|
572770
|
-
init_notebook2();
|
|
572771
|
-
init_mcp4();
|
|
572772
|
-
init_pdf2();
|
|
572773
|
-
init_fs_shared();
|
|
572774
|
-
init_fs_pdf();
|
|
572775
|
-
}
|
|
572776
|
-
});
|
|
572777
|
-
|
|
572778
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-write.js
|
|
572779
|
-
var init_fs_write = __esm({
|
|
572780
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-write.js"() {
|
|
572781
|
-
init_build3();
|
|
572782
|
-
init_tools3();
|
|
572783
|
-
init_safety();
|
|
572784
|
-
init_encoding();
|
|
572785
|
-
init_fs_shared();
|
|
572786
|
-
}
|
|
572787
|
-
});
|
|
572788
|
-
|
|
572789
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-search-tools.js
|
|
572790
|
-
var init_fs_search_tools = __esm({
|
|
572791
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-search-tools.js"() {
|
|
572792
|
-
init_build3();
|
|
572793
|
-
init_tools3();
|
|
572794
|
-
init_safety();
|
|
572795
|
-
init_search();
|
|
572796
|
-
}
|
|
572797
|
-
});
|
|
572798
|
-
|
|
572799
|
-
// node_modules/@sema-agent/core/dist/tools/fs/bash-readonly-classifier.js
|
|
572800
|
-
var init_bash_readonly_classifier = __esm({
|
|
572801
|
-
"node_modules/@sema-agent/core/dist/tools/fs/bash-readonly-classifier.js"() {
|
|
572802
|
-
init_safety();
|
|
572803
|
-
}
|
|
572804
|
-
});
|
|
572805
|
-
|
|
572806
|
-
// node_modules/@sema-agent/core/dist/core/remote-env.js
|
|
572807
|
-
var init_remote_env3 = __esm({
|
|
572808
|
-
"node_modules/@sema-agent/core/dist/core/remote-env.js"() {
|
|
572809
|
-
}
|
|
572810
|
-
});
|
|
572811
|
-
|
|
572812
|
-
// node_modules/@sema-agent/core/dist/tools/fs/gh-rate-limit.js
|
|
572813
|
-
var init_gh_rate_limit = __esm({
|
|
572814
|
-
"node_modules/@sema-agent/core/dist/tools/fs/gh-rate-limit.js"() {
|
|
572815
|
-
}
|
|
572816
|
-
});
|
|
572817
|
-
|
|
572818
|
-
// node_modules/@sema-agent/core/dist/tools/fs/fs-bash.js
|
|
572819
|
-
var init_fs_bash = __esm({
|
|
572820
|
-
"node_modules/@sema-agent/core/dist/tools/fs/fs-bash.js"() {
|
|
572821
|
-
init_build3();
|
|
572822
|
-
init_tools3();
|
|
572823
|
-
init_task_registry();
|
|
572824
|
-
init_task_registry_shared();
|
|
572825
|
-
init_task_tool_shape();
|
|
572826
|
-
init_background_shell();
|
|
572827
|
-
init_untrusted_text();
|
|
572828
|
-
init_mcp4();
|
|
572829
|
-
init_safety();
|
|
572830
|
-
init_remote_env3();
|
|
572831
|
-
init_gh_rate_limit();
|
|
572832
|
-
init_fs_shared();
|
|
572833
|
-
init_bash_readonly_classifier();
|
|
572834
|
-
}
|
|
572835
|
-
});
|
|
572836
|
-
|
|
572837
|
-
// node_modules/@sema-agent/core/dist/tools/fs/index.js
|
|
572838
|
-
var init_fs = __esm({
|
|
572839
|
-
"node_modules/@sema-agent/core/dist/tools/fs/index.js"() {
|
|
572840
|
-
init_task_registry();
|
|
572841
|
-
init_background_shell();
|
|
572842
|
-
init_safety();
|
|
572843
|
-
init_repo_map();
|
|
572844
|
-
init_fs_shared();
|
|
572845
|
-
init_fs_pdf();
|
|
572846
|
-
init_fs_read();
|
|
572847
|
-
init_fs_write();
|
|
572848
|
-
init_fs_search_tools();
|
|
572849
|
-
init_bash_readonly_classifier();
|
|
572850
|
-
init_fs_bash();
|
|
572851
|
-
init_bash_readonly_classifier();
|
|
572852
|
-
init_fs_shared();
|
|
572853
|
-
init_fs_read();
|
|
572854
|
-
init_fs_write();
|
|
572855
|
-
init_fs_search_tools();
|
|
572856
|
-
init_fs_bash();
|
|
572857
|
-
}
|
|
572858
|
-
});
|
|
572859
|
-
|
|
572860
|
-
// node_modules/@sema-agent/core/dist/core/tool-policy.js
|
|
572861
|
-
function refuseOutOfContractDecision(d4) {
|
|
572862
|
-
if (typeof d4 !== "object" || d4 === null)
|
|
572863
|
-
return d4;
|
|
572864
|
-
if (!Object.prototype.hasOwnProperty.call(d4, RETIRED_TEXT_FIELD))
|
|
572865
|
-
return d4;
|
|
572866
|
-
return { action: "deny", message: RETIRED_TEXT_FIELD_DENY_MESSAGE, decisionReason: "rule" };
|
|
572867
|
-
}
|
|
572868
|
-
function toolPolicyNameSets(p) {
|
|
572869
|
-
const sets = p?.nameSets;
|
|
572870
|
-
return Array.isArray(sets) ? sets : [];
|
|
572871
|
-
}
|
|
572872
|
-
function createAllowDenyPolicy(opts) {
|
|
572873
|
-
const allow = opts.allow ? new Set(opts.allow) : void 0;
|
|
572874
|
-
const deny2 = new Set(opts.deny ?? []);
|
|
572875
|
-
return {
|
|
572876
|
-
nameSets: [{ ...opts.allow ? { allow: [...opts.allow] } : {}, ...opts.deny ? { deny: [...opts.deny] } : {} }],
|
|
572877
|
-
check(req) {
|
|
572878
|
-
const toolName2 = req.toolName;
|
|
572879
|
-
if (deny2.has(toolName2)) {
|
|
572880
|
-
return { action: "deny", message: `tool "${req.toolName}" is denied by policy` };
|
|
572881
|
-
}
|
|
572882
|
-
if (allow && !allow.has(toolName2)) {
|
|
572883
|
-
return { action: "deny", message: `tool "${req.toolName}" is not in the allowlist` };
|
|
572884
|
-
}
|
|
572885
|
-
return ALLOW;
|
|
572886
|
-
}
|
|
572887
|
-
};
|
|
572888
|
-
}
|
|
572889
|
-
function combinePolicies(...policies) {
|
|
572890
|
-
const nameSets = policies.flatMap(toolPolicyNameSets);
|
|
572891
|
-
return {
|
|
572892
|
-
...nameSets.length > 0 ? { nameSets } : {},
|
|
572893
|
-
async check(req, signal) {
|
|
572894
|
-
let asked;
|
|
572895
|
-
let current5 = req;
|
|
572896
|
-
let rewrite;
|
|
572897
|
-
for (const p of policies) {
|
|
572898
|
-
const d4 = refuseOutOfContractDecision(await p.check(current5, signal));
|
|
572899
|
-
if (d4.action === "deny") {
|
|
572900
|
-
return rewrite?.updatedInput !== void 0 ? { ...d4, updatedInput: rewrite.updatedInput } : d4;
|
|
572901
|
-
}
|
|
572902
|
-
if (d4.updatedInput !== void 0) {
|
|
572903
|
-
current5 = { ...current5, args: d4.updatedInput };
|
|
572904
|
-
rewrite = d4;
|
|
572905
|
-
}
|
|
572906
|
-
if (d4.action === "ask" && (asked === void 0 || d4.requiresRealApproval === true && asked.requiresRealApproval !== true)) {
|
|
572907
|
-
asked = d4;
|
|
572908
|
-
}
|
|
572909
|
-
}
|
|
572910
|
-
if (asked) {
|
|
572911
|
-
const merged = rewrite?.updatedInput;
|
|
572912
|
-
return merged !== void 0 ? { ...asked, updatedInput: merged } : asked;
|
|
572913
|
-
}
|
|
572914
|
-
return rewrite ?? ALLOW;
|
|
572915
|
-
}
|
|
572916
|
-
};
|
|
572917
|
-
}
|
|
572918
|
-
var ALLOW, RETIRED_TEXT_FIELD, RETIRED_TEXT_FIELD_DENY_MESSAGE, COARSE_SHELL_TOOLS, CASE_INSENSITIVE_FS;
|
|
572919
|
-
var init_tool_policy = __esm({
|
|
572920
|
-
"node_modules/@sema-agent/core/dist/core/tool-policy.js"() {
|
|
572921
|
-
init_fs();
|
|
572922
|
-
init_safety();
|
|
572923
|
-
ALLOW = { action: "allow" };
|
|
572924
|
-
RETIRED_TEXT_FIELD = "reason";
|
|
572925
|
-
RETIRED_TEXT_FIELD_DENY_MESSAGE = `a permission decision carries the retired "${RETIRED_TEXT_FIELD}" field \u2014 rename it to "message" (the one text field a decision carries); denied fail-closed rather than executing a decision whose text this layer cannot read`;
|
|
572926
|
-
COARSE_SHELL_TOOLS = ["Bash", "Monitor"];
|
|
572927
|
-
CASE_INSENSITIVE_FS = process.platform === "darwin" || process.platform === "win32";
|
|
572928
|
-
}
|
|
572929
|
-
});
|
|
572930
|
-
|
|
572931
573423
|
// node_modules/@sema-agent/core/dist/core/runner/session-rule-policy.js
|
|
573424
|
+
var PATH_WRITE_TOOLS, PATH_CONFINABLE_WRITE_TOOLS;
|
|
572932
573425
|
var init_session_rule_policy = __esm({
|
|
572933
573426
|
"node_modules/@sema-agent/core/dist/core/runner/session-rule-policy.js"() {
|
|
572934
573427
|
init_safety();
|
|
572935
573428
|
init_safety();
|
|
572936
573429
|
init_tool_policy();
|
|
573430
|
+
PATH_WRITE_TOOLS = /* @__PURE__ */ new Set(["Write", "Edit", "MultiEdit"]);
|
|
573431
|
+
PATH_CONFINABLE_WRITE_TOOLS = /* @__PURE__ */ new Set([...PATH_WRITE_TOOLS, "NotebookEdit"]);
|
|
572937
573432
|
}
|
|
572938
573433
|
});
|
|
572939
573434
|
|
|
@@ -573437,6 +573932,13 @@ var init_lsp = __esm({
|
|
|
573437
573932
|
}
|
|
573438
573933
|
});
|
|
573439
573934
|
|
|
573935
|
+
// node_modules/@sema-agent/core/dist/core/runner/session-file-state-replay.js
|
|
573936
|
+
var init_session_file_state_replay = __esm({
|
|
573937
|
+
"node_modules/@sema-agent/core/dist/core/runner/session-file-state-replay.js"() {
|
|
573938
|
+
init_safety();
|
|
573939
|
+
}
|
|
573940
|
+
});
|
|
573941
|
+
|
|
573440
573942
|
// node_modules/@sema-agent/core/dist/core/usage-window-store.js
|
|
573441
573943
|
var EMPTY_USAGE_WINDOW_RECORD;
|
|
573442
573944
|
var init_usage_window_store = __esm({
|
|
@@ -573518,6 +574020,7 @@ var init_prepare_task = __esm({
|
|
|
573518
574020
|
init_workflow_size_guideline();
|
|
573519
574021
|
init_lsp();
|
|
573520
574022
|
init_safety();
|
|
574023
|
+
init_session_file_state_replay();
|
|
573521
574024
|
init_checkpoint_store();
|
|
573522
574025
|
init_canonical_json();
|
|
573523
574026
|
init_usage_window_store();
|
|
@@ -573645,7 +574148,7 @@ var init_skills_directory = __esm({
|
|
|
573645
574148
|
});
|
|
573646
574149
|
|
|
573647
574150
|
// node_modules/@sema-agent/core/dist/tools/web.js
|
|
573648
|
-
var DEFAULT_MAX_BYTES, ERROR_BODY_CONVERT_MAX_CHARS, HTML_CONVERT_MAX_CHARS;
|
|
574151
|
+
var DEFAULT_MAX_BYTES, GROUNDING_RATIO_MAX_TEXT_CHARS, GROUNDING_ECHO_MAX_CHARS, ERROR_BODY_CONVERT_MAX_CHARS, HTML_CONVERT_MAX_CHARS;
|
|
573649
574152
|
var init_web = __esm({
|
|
573650
574153
|
"node_modules/@sema-agent/core/dist/tools/web.js"() {
|
|
573651
574154
|
init_build3();
|
|
@@ -573653,7 +574156,11 @@ var init_web = __esm({
|
|
|
573653
574156
|
init_untrusted_text();
|
|
573654
574157
|
init_untrusted_egress();
|
|
573655
574158
|
init_image();
|
|
574159
|
+
init_safety();
|
|
574160
|
+
init_pdf2();
|
|
573656
574161
|
DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
|
|
574162
|
+
GROUNDING_RATIO_MAX_TEXT_CHARS = 2e3;
|
|
574163
|
+
GROUNDING_ECHO_MAX_CHARS = GROUNDING_RATIO_MAX_TEXT_CHARS + 100;
|
|
573657
574164
|
ERROR_BODY_CONVERT_MAX_CHARS = 64 * 1024;
|
|
573658
574165
|
HTML_CONVERT_MAX_CHARS = 256 * 1024;
|
|
573659
574166
|
}
|
|
@@ -574942,6 +575449,22 @@ var init_anthropic = __esm({
|
|
|
574942
575449
|
}
|
|
574943
575450
|
});
|
|
574944
575451
|
|
|
575452
|
+
// node_modules/@sema-agent/core/dist/brain/open-responses.js
|
|
575453
|
+
var init_open_responses = __esm({
|
|
575454
|
+
"node_modules/@sema-agent/core/dist/brain/open-responses.js"() {
|
|
575455
|
+
init_llm2();
|
|
575456
|
+
init_errors12();
|
|
575457
|
+
init_repetition();
|
|
575458
|
+
init_stream_shared();
|
|
575459
|
+
init_tool_call_id();
|
|
575460
|
+
init_status_sink();
|
|
575461
|
+
init_media_degrade();
|
|
575462
|
+
init_request_params();
|
|
575463
|
+
init_reasoning();
|
|
575464
|
+
init_stream_engine();
|
|
575465
|
+
}
|
|
575466
|
+
});
|
|
575467
|
+
|
|
574945
575468
|
// node_modules/@sema-agent/core/dist/brain/model-presets.js
|
|
574946
575469
|
var init_model_presets = __esm({
|
|
574947
575470
|
"node_modules/@sema-agent/core/dist/brain/model-presets.js"() {
|
|
@@ -575157,6 +575680,7 @@ var init_dist10 = __esm({
|
|
|
575157
575680
|
init_context_edit();
|
|
575158
575681
|
init_openai();
|
|
575159
575682
|
init_anthropic();
|
|
575683
|
+
init_open_responses();
|
|
575160
575684
|
init_model_presets();
|
|
575161
575685
|
init_failover();
|
|
575162
575686
|
init_routing();
|
|
@@ -576280,6 +576804,7 @@ __export(workflow_detail_dialog_exports, {
|
|
|
576280
576804
|
WorkflowDetailDialog: () => WorkflowDetailDialog2,
|
|
576281
576805
|
activityLine: () => activityLine,
|
|
576282
576806
|
agentDisplayStatus: () => agentDisplayStatus,
|
|
576807
|
+
agentStats: () => agentStats,
|
|
576283
576808
|
buildAgentDetailLines: () => buildAgentDetailLines,
|
|
576284
576809
|
computeVisibleWindow: () => computeVisibleWindow,
|
|
576285
576810
|
default: () => workflow_detail_dialog_default
|
|
@@ -576547,7 +577072,9 @@ function buildAgentDetailLines({
|
|
|
576547
577072
|
const wrapWidth = Math.max(8, width - 2);
|
|
576548
577073
|
const { glyph, color: color4 } = statusGlyph(status3);
|
|
576549
577074
|
const meta3 = [];
|
|
576550
|
-
if (agent.model != null
|
|
577075
|
+
if (agent.model != null && agent.fallbackModel != null && agent.fallbackModel !== agent.model)
|
|
577076
|
+
meta3.push(`requested ${agent.model} \u2192 running on ${agent.fallbackModel}`);
|
|
577077
|
+
else if (agent.model != null) meta3.push(agent.model);
|
|
576551
577078
|
else if (agent.fallbackModel != null) meta3.push(agent.fallbackModel);
|
|
576552
577079
|
if (agent.agentType != null) meta3.push(agent.agentType);
|
|
576553
577080
|
if (agent.isolation != null)
|
|
@@ -589538,7 +590065,7 @@ async function startWorkPollLoop({
|
|
|
589538
590065
|
if (hbConfig.non_exclusive_heartbeat_interval_ms <= 0) break;
|
|
589539
590066
|
const info = getHeartbeatInfo();
|
|
589540
590067
|
if (!info) break;
|
|
589541
|
-
const
|
|
590068
|
+
const cap2 = capacitySignal();
|
|
589542
590069
|
try {
|
|
589543
590070
|
await api2.heartbeatWork(
|
|
589544
590071
|
info.environmentId,
|
|
@@ -589550,7 +590077,7 @@ async function startWorkPollLoop({
|
|
|
589550
590077
|
`[bridge:repl:heartbeat] Failed: ${errorMessage(err8)}`
|
|
589551
590078
|
);
|
|
589552
590079
|
if (err8 instanceof BridgeFatalError) {
|
|
589553
|
-
|
|
590080
|
+
cap2.cleanup();
|
|
589554
590081
|
logEvent("tengu_bridge_heartbeat_error", {
|
|
589555
590082
|
status: err8.status,
|
|
589556
590083
|
error_type: err8.status === 401 || err8.status === 403 ? "auth_failed" : "fatal"
|
|
@@ -589569,9 +590096,9 @@ async function startWorkPollLoop({
|
|
|
589569
590096
|
hbCycles++;
|
|
589570
590097
|
await sleep2(
|
|
589571
590098
|
hbConfig.non_exclusive_heartbeat_interval_ms,
|
|
589572
|
-
|
|
590099
|
+
cap2.signal
|
|
589573
590100
|
);
|
|
589574
|
-
|
|
590101
|
+
cap2.cleanup();
|
|
589575
590102
|
}
|
|
589576
590103
|
const exitReason = needsBackoff ? "error" : signal.aborted ? "shutdown" : !isAtCapacity() ? "capacity_changed" : pollDeadline !== null && Date.now() >= pollDeadline ? "poll_due" : "config_disabled";
|
|
589577
590104
|
logEvent("tengu_bridge_heartbeat_mode_exited", {
|
|
@@ -589589,10 +590116,10 @@ async function startWorkPollLoop({
|
|
|
589589
590116
|
}
|
|
589590
590117
|
const sleepMs2 = atCapMs > 0 ? atCapMs : pollConfig.non_exclusive_heartbeat_interval_ms;
|
|
589591
590118
|
if (sleepMs2 > 0) {
|
|
589592
|
-
const
|
|
590119
|
+
const cap2 = capacitySignal();
|
|
589593
590120
|
const sleepStart = Date.now();
|
|
589594
|
-
await sleep2(sleepMs2,
|
|
589595
|
-
|
|
590121
|
+
await sleep2(sleepMs2, cap2.signal);
|
|
590122
|
+
cap2.cleanup();
|
|
589596
590123
|
const overrun = Date.now() - sleepStart - sleepMs2;
|
|
589597
590124
|
if (overrun > 6e4) {
|
|
589598
590125
|
logForDebugging(
|
|
@@ -593000,7 +593527,7 @@ var init_resumeModelRestore = __esm({
|
|
|
593000
593527
|
init_dist();
|
|
593001
593528
|
init_dist();
|
|
593002
593529
|
RESUME_DECLINE_REASONS = {
|
|
593003
|
-
unknown_family: "not
|
|
593530
|
+
unknown_family: "not in this session's configured model pool \u2014 pick one with /model or add it in settings"
|
|
593004
593531
|
};
|
|
593005
593532
|
}
|
|
593006
593533
|
});
|
|
@@ -616665,7 +617192,7 @@ function pickDiverseCoreFiles(sortedPaths, want) {
|
|
|
616665
617192
|
const picked = [];
|
|
616666
617193
|
const seenBasenames = /* @__PURE__ */ new Set();
|
|
616667
617194
|
const dirTally = /* @__PURE__ */ new Map();
|
|
616668
|
-
for (let
|
|
617195
|
+
for (let cap2 = 1; picked.length < want && cap2 <= want; cap2++) {
|
|
616669
617196
|
for (const p of sortedPaths) {
|
|
616670
617197
|
if (picked.length >= want) break;
|
|
616671
617198
|
if (!isCoreFile(p)) continue;
|
|
@@ -616673,7 +617200,7 @@ function pickDiverseCoreFiles(sortedPaths, want) {
|
|
|
616673
617200
|
const base = lastSep >= 0 ? p.slice(lastSep + 1) : p;
|
|
616674
617201
|
if (!base || seenBasenames.has(base)) continue;
|
|
616675
617202
|
const dir = lastSep >= 0 ? p.slice(0, lastSep) : ".";
|
|
616676
|
-
if ((dirTally.get(dir) ?? 0) >=
|
|
617203
|
+
if ((dirTally.get(dir) ?? 0) >= cap2) continue;
|
|
616677
617204
|
picked.push(base);
|
|
616678
617205
|
seenBasenames.add(base);
|
|
616679
617206
|
dirTally.set(dir, (dirTally.get(dir) ?? 0) + 1);
|
|
@@ -623449,7 +623976,7 @@ function createPermissionContext(tool, input, toolUseContext, assistantMessage,
|
|
|
623449
623976
|
if (tool.name !== BASH_TOOL_NAME3 || !pendingClassifierCheck) {
|
|
623450
623977
|
return null;
|
|
623451
623978
|
}
|
|
623452
|
-
const classifierDecision = await
|
|
623979
|
+
const classifierDecision = await awaitClassifierAutoApproval3(
|
|
623453
623980
|
pendingClassifierCheck,
|
|
623454
623981
|
toolUseContext.abortController.signal,
|
|
623455
623982
|
toolUseContext.options.isNonInteractiveSession
|
|
@@ -623894,7 +624421,7 @@ function handleInteractivePermission(params, resolve57) {
|
|
|
623894
624421
|
}
|
|
623895
624422
|
if (false) {
|
|
623896
624423
|
setClassifierChecking2(ctx.toolUseID);
|
|
623897
|
-
void
|
|
624424
|
+
void executeAsyncClassifierCheck2(
|
|
623898
624425
|
result.pendingClassifierCheck,
|
|
623899
624426
|
ctx.toolUseContext.abortController.signal,
|
|
623900
624427
|
ctx.toolUseContext.options.isNonInteractiveSession,
|
|
@@ -624170,14 +624697,14 @@ function useCanUseTool(setToolUseConfirmQueue, setToolPermissionContext) {
|
|
|
624170
624697
|
return;
|
|
624171
624698
|
}
|
|
624172
624699
|
if (false) {
|
|
624173
|
-
const speculativePromise =
|
|
624700
|
+
const speculativePromise = peekSpeculativeClassifierCheck2(input.command);
|
|
624174
624701
|
if (speculativePromise) {
|
|
624175
624702
|
const raceResult = await Promise.race([speculativePromise.then(_temp), new Promise(_temp2)]);
|
|
624176
624703
|
if (ctx.resolveIfAborted(resolve57)) {
|
|
624177
624704
|
return;
|
|
624178
624705
|
}
|
|
624179
624706
|
if (raceResult.type === "result" && raceResult.result.matches && raceResult.result.confidence === "high" && false) {
|
|
624180
|
-
|
|
624707
|
+
consumeSpeculativeClassifierCheck2(input.command);
|
|
624181
624708
|
const matchedRule = raceResult.result.matchedDescription ?? void 0;
|
|
624182
624709
|
if (matchedRule) {
|
|
624183
624710
|
setClassifierApproval3(toolUseID, matchedRule);
|
|
@@ -632634,8 +633161,8 @@ function _temp159() {
|
|
|
632634
633161
|
var import_compiler_runtime309, import_react312, SETTINGS_ERRORS_NOTIFICATION_KEY;
|
|
632635
633162
|
var init_useSettingsErrors = __esm({
|
|
632636
633163
|
"build-src/src/hooks/notifs/useSettingsErrors.tsx"() {
|
|
632637
|
-
import_compiler_runtime309 = __toESM(require_compiler_runtime()
|
|
632638
|
-
import_react312 = __toESM(require_react()
|
|
633164
|
+
import_compiler_runtime309 = __toESM(require_compiler_runtime());
|
|
633165
|
+
import_react312 = __toESM(require_react());
|
|
632639
633166
|
init_notifications2();
|
|
632640
633167
|
init_state();
|
|
632641
633168
|
init_allErrors();
|
|
@@ -635814,16 +636341,16 @@ function computeWheelStep(state4, dir, now2) {
|
|
|
635814
636341
|
}
|
|
635815
636342
|
if (state4.wheelMode) {
|
|
635816
636343
|
const m2 = Math.pow(0.5, gap2 / WHEEL_DECAY_HALFLIFE_MS);
|
|
635817
|
-
const
|
|
636344
|
+
const cap2 = Math.max(WHEEL_MODE_CAP, state4.base * 2);
|
|
635818
636345
|
const next = 1 + (state4.mult - 1) * m2 + WHEEL_MODE_STEP * m2;
|
|
635819
|
-
state4.mult = Math.min(
|
|
636346
|
+
state4.mult = Math.min(cap2, next, state4.mult + WHEEL_MODE_RAMP);
|
|
635820
636347
|
return Math.floor(state4.mult);
|
|
635821
636348
|
}
|
|
635822
636349
|
if (gap2 > WHEEL_ACCEL_WINDOW_MS) {
|
|
635823
636350
|
state4.mult = state4.base;
|
|
635824
636351
|
} else {
|
|
635825
|
-
const
|
|
635826
|
-
state4.mult = Math.min(
|
|
636352
|
+
const cap2 = Math.max(WHEEL_ACCEL_MAX, state4.base * 2);
|
|
636353
|
+
state4.mult = Math.min(cap2, state4.mult + WHEEL_ACCEL_STEP);
|
|
635827
636354
|
}
|
|
635828
636355
|
return Math.floor(state4.mult);
|
|
635829
636356
|
}
|
|
@@ -635837,8 +636364,8 @@ function computeWheelStep(state4, dir, now2) {
|
|
|
635837
636364
|
state4.frac = 0;
|
|
635838
636365
|
} else {
|
|
635839
636366
|
const m2 = Math.pow(0.5, gap / WHEEL_DECAY_HALFLIFE_MS);
|
|
635840
|
-
const
|
|
635841
|
-
state4.mult = Math.min(
|
|
636367
|
+
const cap2 = gap >= WHEEL_DECAY_GAP_MS ? WHEEL_DECAY_CAP_SLOW : WHEEL_DECAY_CAP_FAST;
|
|
636368
|
+
state4.mult = Math.min(cap2, 1 + (state4.mult - 1) * m2 + WHEEL_DECAY_STEP * m2);
|
|
635842
636369
|
}
|
|
635843
636370
|
const total = state4.mult + state4.frac;
|
|
635844
636371
|
const rows2 = Math.floor(total);
|
|
@@ -638498,7 +639025,7 @@ Error: sandbox required but unavailable: ${reason}
|
|
|
638498
639025
|
helpers.setCursorOffset(stashedPrompt.cursorOffset);
|
|
638499
639026
|
setPastedContents(stashedPrompt.pastedContents);
|
|
638500
639027
|
setStashedPrompt(void 0);
|
|
638501
|
-
} else
|
|
639028
|
+
} else {
|
|
638502
639029
|
if (!options?.fromKeybinding) {
|
|
638503
639030
|
setInputValue("");
|
|
638504
639031
|
helpers.setCursorOffset(0);
|
|
@@ -644357,9 +644884,9 @@ be shared and iterated on outside the terminal:
|
|
|
644357
644884
|
Skip this step if the review was invoked only to feed another tool (e.g. a
|
|
644358
644885
|
workflow step whose caller handles its own output).
|
|
644359
644886
|
`;
|
|
644360
|
-
outputAsJson = (
|
|
644887
|
+
outputAsJson = (cap2) => `## Output
|
|
644361
644888
|
|
|
644362
|
-
Return findings as a JSON array of at most ${
|
|
644889
|
+
Return findings as a JSON array of at most ${cap2} objects:
|
|
644363
644890
|
|
|
644364
644891
|
\`\`\`json
|
|
644365
644892
|
[
|
|
@@ -644372,19 +644899,19 @@ Return findings as a JSON array of at most ${cap} objects:
|
|
|
644372
644899
|
]
|
|
644373
644900
|
\`\`\`
|
|
644374
644901
|
|
|
644375
|
-
Ranked most-severe first. If more than ${
|
|
644902
|
+
Ranked most-severe first. If more than ${cap2} survive, keep the ${cap2} most
|
|
644376
644903
|
severe. If nothing survives verification, return \`[]\`.
|
|
644377
644904
|
`;
|
|
644378
|
-
outputViaReportFindings = (
|
|
644905
|
+
outputViaReportFindings = (cap2) => `## Output
|
|
644379
644906
|
|
|
644380
644907
|
Call the ${REPORT_FINDINGS_TOOL_NAME} tool once to report this review's results
|
|
644381
|
-
with \`{level, findings}\`. \`findings\` is at most ${
|
|
644908
|
+
with \`{level, findings}\`. \`findings\` is at most ${cap2} entries ranked
|
|
644382
644909
|
most-severe first; each entry has \`file\`, \`line\`, \`summary\`,
|
|
644383
644910
|
\`failure_scenario\`, and \`category\` \u2014 a short kebab-case slug for the angle
|
|
644384
644911
|
that produced it (\`correctness\`, \`simplification\`, \`efficiency\`,
|
|
644385
644912
|
\`reuse\`, \`altitude\`, \`conventions\`, or a more specific slug like
|
|
644386
644913
|
\`test-coverage\` when one fits better) \u2014 plus \`verdict\` when a verify pass
|
|
644387
|
-
produced one. If more than ${
|
|
644914
|
+
produced one. If more than ${cap2} survive, keep the ${cap2} most severe. If
|
|
644388
644915
|
nothing survives verification, call it with an empty array. Do not also print
|
|
644389
644916
|
the findings as text.
|
|
644390
644917
|
`;
|
|
@@ -644552,14 +645079,14 @@ Output at most **8 findings**, most-severe first, one line each:
|
|
|
644552
645079
|
\`path/to/file.ext:123 \u2014 what's wrong and the concrete failure\`.
|
|
644553
645080
|
Target at least min(files_changed, 4) findings \u2014 if you see fewer, widen to other hunks in the same diff before stopping. If fewer than 4 genuine findings exist, emit what you have.
|
|
644554
645081
|
`;
|
|
644555
|
-
withRecallFloor = (output) => (
|
|
645082
|
+
withRecallFloor = (output) => (cap2) => output(cap2).replace(
|
|
644556
645083
|
"## Output\n",
|
|
644557
645084
|
`## Output
|
|
644558
645085
|
|
|
644559
|
-
Target **at least ${Math.floor(
|
|
645086
|
+
Target **at least ${Math.floor(cap2 / 2)} findings**. If fewer genuine findings exist, emit what you have \u2014 do not invent to hit the floor.
|
|
644560
645087
|
`
|
|
644561
645088
|
).replace(/nothing survives verification/g, "nothing survives");
|
|
644562
|
-
o48Cell = (header, stance,
|
|
645089
|
+
o48Cell = (header, stance, cap2) => (output) => `\`${header}\`
|
|
644563
645090
|
|
|
644564
645091
|
${stance}
|
|
644565
645092
|
|
|
@@ -644584,7 +645111,7 @@ silently drop half-believed candidates are the dominant cause of misses.
|
|
|
644584
645111
|
|
|
644585
645112
|
Pool all candidates. Dedup near-duplicates only (same defect, same location, same reason \u2192 keep one). Do NOT run verifiers; do NOT re-judge. Sort by severity.
|
|
644586
645113
|
|
|
644587
|
-
${withRecallFloor(output)(
|
|
645114
|
+
${withRecallFloor(output)(cap2)}`;
|
|
644588
645115
|
cellO48Medium = o48Cell(
|
|
644589
645116
|
"medium effort \u2192 8 inline angles \u2192 dedup (no verify) \u2192 \u22648 findings",
|
|
644590
645117
|
`You are reviewing for **correctness bugs**: surface every plausible bug. At this
|
|
@@ -650869,6 +651396,141 @@ var init_classifierVerdictWire2 = __esm({
|
|
|
650869
651396
|
}
|
|
650870
651397
|
});
|
|
650871
651398
|
|
|
651399
|
+
// build-src/src/sema/engineGateSyncAllow.ts
|
|
651400
|
+
function cap() {
|
|
651401
|
+
if (budgetCap !== null) return budgetCap;
|
|
651402
|
+
const raw2 = process.env.SEMA_GATE_SYNC_ALLOW_BUDGET;
|
|
651403
|
+
const parsed = raw2 !== void 0 && raw2 !== "" ? Number(raw2) : Number.NaN;
|
|
651404
|
+
budgetCap = Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : DEFAULT_BUDGET;
|
|
651405
|
+
return budgetCap;
|
|
651406
|
+
}
|
|
651407
|
+
function readPermissionContext() {
|
|
651408
|
+
try {
|
|
651409
|
+
const state4 = getAppStateStoreRef()?.getState?.();
|
|
651410
|
+
return state4?.toolPermissionContext ?? null;
|
|
651411
|
+
} catch {
|
|
651412
|
+
return null;
|
|
651413
|
+
}
|
|
651414
|
+
}
|
|
651415
|
+
function canonicalToolName(name) {
|
|
651416
|
+
const n2 = name.replace(/[\s_-]+/g, "").toLowerCase();
|
|
651417
|
+
if (n2 === "bash") return { canonical: "Bash", family: "bash" };
|
|
651418
|
+
if (n2 === "write" || n2 === "filewrite") return { canonical: "Write", family: "fsWrite", pathKey: "file_path" };
|
|
651419
|
+
if (n2 === "edit" || n2 === "fileedit") return { canonical: "Edit", family: "fsWrite", pathKey: "file_path" };
|
|
651420
|
+
if (n2 === "multiedit") return { canonical: "MultiEdit", family: "fsWrite", pathKey: "file_path" };
|
|
651421
|
+
if (n2 === "notebookedit")
|
|
651422
|
+
return { canonical: "NotebookEdit", family: "fsWrite", pathKey: "notebook_path" };
|
|
651423
|
+
return { canonical: name, family: "other" };
|
|
651424
|
+
}
|
|
651425
|
+
function permissionsModule() {
|
|
651426
|
+
return init_permissions2(), __toCommonJS(permissions_exports2);
|
|
651427
|
+
}
|
|
651428
|
+
function filesystemModule() {
|
|
651429
|
+
return init_filesystem(), __toCommonJS(filesystem_exports);
|
|
651430
|
+
}
|
|
651431
|
+
function bashPermissionsModule() {
|
|
651432
|
+
return init_bashPermissions(), __toCommonJS(bashPermissions_exports);
|
|
651433
|
+
}
|
|
651434
|
+
function bashVerdict(ctx, args) {
|
|
651435
|
+
const command8 = args.command;
|
|
651436
|
+
if (typeof command8 !== "string" || command8.trim() === "") {
|
|
651437
|
+
return { allow: false, reason: "bash gate carries no command string" };
|
|
651438
|
+
}
|
|
651439
|
+
const result = bashPermissionsModule().bashToolCheckPermission(
|
|
651440
|
+
{ command: command8 },
|
|
651441
|
+
ctx
|
|
651442
|
+
);
|
|
651443
|
+
if (result.behavior !== "allow") return { allow: false, reason: `bash rules say ${String(result.behavior)}` };
|
|
651444
|
+
if (result.decisionReason?.type !== "rule") {
|
|
651445
|
+
return { allow: false, reason: `bash allow came from ${String(result.decisionReason?.type)}, not a remembered rule` };
|
|
651446
|
+
}
|
|
651447
|
+
return { allow: true, reason: "remembered Bash allow rule" };
|
|
651448
|
+
}
|
|
651449
|
+
function fsWriteVerdict(ctx, canonical2, pathKey2, args) {
|
|
651450
|
+
const perms = permissionsModule();
|
|
651451
|
+
const tool = { name: canonical2, mcpInfo: void 0 };
|
|
651452
|
+
if (perms.getDenyRuleForTool(ctx, tool) !== null) return { allow: false, reason: "tool-level deny rule" };
|
|
651453
|
+
if (perms.getAskRuleForTool(ctx, tool) !== null) return { allow: false, reason: "tool-level ask rule" };
|
|
651454
|
+
const path28 = args[pathKey2];
|
|
651455
|
+
if (typeof path28 === "string" && path28 !== "") {
|
|
651456
|
+
const fs15 = filesystemModule();
|
|
651457
|
+
if (fs15.matchingRuleForInput(path28, ctx, "edit", "deny") !== null) return { allow: false, reason: "path deny rule" };
|
|
651458
|
+
if (fs15.matchingRuleForInput(path28, ctx, "edit", "ask") !== null) return { allow: false, reason: "path ask rule" };
|
|
651459
|
+
if (fs15.matchingRuleForInput(path28, ctx, "edit", "allow") !== null) {
|
|
651460
|
+
return { allow: true, reason: "remembered path allow rule" };
|
|
651461
|
+
}
|
|
651462
|
+
}
|
|
651463
|
+
if (perms.toolAlwaysAllowedRule(ctx, tool) !== null) {
|
|
651464
|
+
return { allow: true, reason: "remembered whole-tool allow rule" };
|
|
651465
|
+
}
|
|
651466
|
+
return { allow: false, reason: "no remembered allow rule for this write" };
|
|
651467
|
+
}
|
|
651468
|
+
function genericVerdict(ctx, canonical2) {
|
|
651469
|
+
const perms = permissionsModule();
|
|
651470
|
+
const tool = { name: canonical2, mcpInfo: void 0 };
|
|
651471
|
+
if (perms.getDenyRuleForTool(ctx, tool) !== null) return { allow: false, reason: "tool-level deny rule" };
|
|
651472
|
+
if (perms.getAskRuleForTool(ctx, tool) !== null) return { allow: false, reason: "tool-level ask rule" };
|
|
651473
|
+
if (perms.toolAlwaysAllowedRule(ctx, tool) !== null) {
|
|
651474
|
+
return { allow: true, reason: "remembered whole-tool allow rule" };
|
|
651475
|
+
}
|
|
651476
|
+
return { allow: false, reason: "no remembered allow rule for this tool" };
|
|
651477
|
+
}
|
|
651478
|
+
function _evaluateWithContextForTest(ctx, req) {
|
|
651479
|
+
if (ctx === null) return { allow: false, reason: "no toolPermissionContext on this lane" };
|
|
651480
|
+
if (!SYNC_ALLOW_MODES.has(ctx.mode)) return { allow: false, reason: `mode ${ctx.mode} never auto-allows` };
|
|
651481
|
+
if (typeof req.args !== "object" || req.args === null) {
|
|
651482
|
+
return { allow: false, reason: "gate carries no tool input (argsOmitted?)" };
|
|
651483
|
+
}
|
|
651484
|
+
const args = req.args;
|
|
651485
|
+
const { canonical: canonical2, family, pathKey: pathKey2 } = canonicalToolName(req.toolName);
|
|
651486
|
+
try {
|
|
651487
|
+
if (family === "bash") return bashVerdict(ctx, args);
|
|
651488
|
+
if (family === "fsWrite") return fsWriteVerdict(ctx, canonical2, pathKey2 ?? "file_path", args);
|
|
651489
|
+
return genericVerdict(ctx, canonical2);
|
|
651490
|
+
} catch (e) {
|
|
651491
|
+
logForDebugging(`engineGateSyncAllow: rule evaluation threw for "${req.toolName}": ${String(e)}`);
|
|
651492
|
+
return { allow: false, reason: "rule evaluation failed" };
|
|
651493
|
+
}
|
|
651494
|
+
}
|
|
651495
|
+
function evaluateEngineGateSyncAllow(req) {
|
|
651496
|
+
const ctx = readPermissionContext();
|
|
651497
|
+
const verdict = _evaluateWithContextForTest(ctx, req);
|
|
651498
|
+
if (!verdict.allow) {
|
|
651499
|
+
let allowRuleCount = -1;
|
|
651500
|
+
try {
|
|
651501
|
+
if (ctx) allowRuleCount = permissionsModule().getAllowRules(ctx).length;
|
|
651502
|
+
} catch {
|
|
651503
|
+
}
|
|
651504
|
+
logForDebugging(
|
|
651505
|
+
`engineGateSyncAllow: no sync allow for "${req.toolName}" (${verdict.reason}; mode=${ctx?.mode ?? "none"}, allowRules=${allowRuleCount})`
|
|
651506
|
+
);
|
|
651507
|
+
return verdict;
|
|
651508
|
+
}
|
|
651509
|
+
if (budgetUsed >= cap()) {
|
|
651510
|
+
if (!budgetExhaustedLogged) {
|
|
651511
|
+
budgetExhaustedLogged = true;
|
|
651512
|
+
logForDebugging(
|
|
651513
|
+
`engineGateSyncAllow: programmatic-allow budget exhausted (${budgetUsed}/${cap()}) \u2014 every further gate goes back to the approval card`
|
|
651514
|
+
);
|
|
651515
|
+
}
|
|
651516
|
+
return { allow: false, reason: "programmatic-allow budget exhausted" };
|
|
651517
|
+
}
|
|
651518
|
+
budgetUsed++;
|
|
651519
|
+
return verdict;
|
|
651520
|
+
}
|
|
651521
|
+
var SYNC_ALLOW_MODES, DEFAULT_BUDGET, budgetUsed, budgetCap, budgetExhaustedLogged;
|
|
651522
|
+
var init_engineGateSyncAllow = __esm({
|
|
651523
|
+
"build-src/src/sema/engineGateSyncAllow.ts"() {
|
|
651524
|
+
init_appStateRef();
|
|
651525
|
+
init_debug();
|
|
651526
|
+
SYNC_ALLOW_MODES = /* @__PURE__ */ new Set(["default", "acceptEdits", "auto"]);
|
|
651527
|
+
DEFAULT_BUDGET = 100;
|
|
651528
|
+
budgetUsed = 0;
|
|
651529
|
+
budgetCap = null;
|
|
651530
|
+
budgetExhaustedLogged = false;
|
|
651531
|
+
}
|
|
651532
|
+
});
|
|
651533
|
+
|
|
650872
651534
|
// build-src/src/sema/liveToolApprovalWire.ts
|
|
650873
651535
|
function toolForName(name) {
|
|
650874
651536
|
const n2 = name.replace(/[\s_-]+/g, "").toLowerCase();
|
|
@@ -650915,6 +651577,13 @@ function shellApprovalCardPort(req) {
|
|
|
650915
651577
|
);
|
|
650916
651578
|
return Promise.resolve({ kind: "deny" });
|
|
650917
651579
|
}
|
|
651580
|
+
const syncAllow = evaluateEngineGateSyncAllow({ toolName: req.toolName, args: req.args });
|
|
651581
|
+
if (syncAllow.allow) {
|
|
651582
|
+
logForDebugging(
|
|
651583
|
+
`liveToolApprovalWire: gate for "${req.toolName}" auto-allowed synchronously (${syncAllow.reason}) \u2014 no card, no park`
|
|
651584
|
+
);
|
|
651585
|
+
return Promise.resolve({ kind: "allow", allowSession: false });
|
|
651586
|
+
}
|
|
650918
651587
|
const tool = toolForName(req.toolName);
|
|
650919
651588
|
if (!tool) {
|
|
650920
651589
|
return Promise.resolve({ kind: "failed", reason: `no shell tool card for gate tool "${req.toolName}"` });
|
|
@@ -651003,6 +651672,7 @@ var init_liveToolApprovalWire = __esm({
|
|
|
651003
651672
|
init_PermissionUpdate();
|
|
651004
651673
|
init_appStateRef();
|
|
651005
651674
|
init_debug();
|
|
651675
|
+
init_engineGateSyncAllow();
|
|
651006
651676
|
init_dist();
|
|
651007
651677
|
asWireTool = (t2) => t2;
|
|
651008
651678
|
installShellApprovalCardPort();
|
|
@@ -651412,6 +652082,12 @@ function toLiveRequest(req, capturedSessionId) {
|
|
|
651412
652082
|
} catch {
|
|
651413
652083
|
}
|
|
651414
652084
|
}
|
|
652085
|
+
if (out6.additionalReadDirectories === void 0) {
|
|
652086
|
+
try {
|
|
652087
|
+
out6.additionalReadDirectories = [getClaudeConfigHomeDir()];
|
|
652088
|
+
} catch {
|
|
652089
|
+
}
|
|
652090
|
+
}
|
|
651415
652091
|
if (out6.forwardSubagentEvents === void 0) {
|
|
651416
652092
|
;
|
|
651417
652093
|
out6.forwardSubagentEvents = true;
|
|
@@ -651731,6 +652407,7 @@ var init_liveClient = __esm({
|
|
|
651731
652407
|
init_sessionStorage();
|
|
651732
652408
|
init_turnCommitSignal();
|
|
651733
652409
|
init_appStateRef();
|
|
652410
|
+
init_envUtils();
|
|
651734
652411
|
init_dist();
|
|
651735
652412
|
init_agentsWire();
|
|
651736
652413
|
init_detachWire2();
|
|
@@ -651839,9 +652516,9 @@ __export(printStreamJsonContract_exports, {
|
|
|
651839
652516
|
import { randomUUID as randomUUID55 } from "crypto";
|
|
651840
652517
|
function terminalReasonForResult(msg) {
|
|
651841
652518
|
const code2 = msg.errorCode;
|
|
651842
|
-
if (code2 ===
|
|
651843
|
-
if (code2 ===
|
|
651844
|
-
if (code2 ===
|
|
652519
|
+
if (code2 === LIMITS_MAX_TURNS_EXCEEDED) return "max_turns";
|
|
652520
|
+
if (code2 === LIMITS_MAX_COST_EXCEEDED) return "budget_exhausted";
|
|
652521
|
+
if (code2 === OUTPUT_INVALID) return "structured_output_retry_exhausted";
|
|
651845
652522
|
if (msg.is_error !== true && msg.subtype === "success") {
|
|
651846
652523
|
return "completed";
|
|
651847
652524
|
}
|
|
@@ -651919,6 +652596,7 @@ async function buildPrintInitMessage(params, sessionId) {
|
|
|
651919
652596
|
var PrintStreamProjector;
|
|
651920
652597
|
var init_printStreamJsonContract = __esm({
|
|
651921
652598
|
"build-src/src/sema/printStreamJsonContract.ts"() {
|
|
652599
|
+
init_dist();
|
|
651922
652600
|
init_modelContextResolver();
|
|
651923
652601
|
PrintStreamProjector = class {
|
|
651924
652602
|
includePartial;
|
|
@@ -665124,18 +665802,18 @@ async function runBridgeLoop(config4, environmentId, environmentSecret, api2, sp
|
|
|
665124
665802
|
while (!loopSignal.aborted && activeSessions.size >= config4.maxSessions && (pollDeadline === null || Date.now() < pollDeadline)) {
|
|
665125
665803
|
const hbConfig = getPollIntervalConfig();
|
|
665126
665804
|
if (hbConfig.non_exclusive_heartbeat_interval_ms <= 0) break;
|
|
665127
|
-
const
|
|
665805
|
+
const cap2 = capacityWake.signal();
|
|
665128
665806
|
hbResult = await heartbeatActiveWorkItems();
|
|
665129
665807
|
if (hbResult === "auth_failed" || hbResult === "fatal") {
|
|
665130
|
-
|
|
665808
|
+
cap2.cleanup();
|
|
665131
665809
|
break;
|
|
665132
665810
|
}
|
|
665133
665811
|
hbCycles++;
|
|
665134
665812
|
await sleep2(
|
|
665135
665813
|
hbConfig.non_exclusive_heartbeat_interval_ms,
|
|
665136
|
-
|
|
665814
|
+
cap2.signal
|
|
665137
665815
|
);
|
|
665138
|
-
|
|
665816
|
+
cap2.cleanup();
|
|
665139
665817
|
}
|
|
665140
665818
|
const exitReason = hbResult === "auth_failed" || hbResult === "fatal" ? hbResult : loopSignal.aborted ? "shutdown" : activeSessions.size < config4.maxSessions ? "capacity_changed" : pollDeadline !== null && Date.now() >= pollDeadline ? "poll_due" : "config_disabled";
|
|
665141
665819
|
logEvent("tengu_bridge_heartbeat_mode_exited", {
|
|
@@ -665149,17 +665827,17 @@ async function runBridgeLoop(config4, environmentId, environmentSecret, api2, sp
|
|
|
665149
665827
|
);
|
|
665150
665828
|
}
|
|
665151
665829
|
if (hbResult === "auth_failed" || hbResult === "fatal") {
|
|
665152
|
-
const
|
|
665830
|
+
const cap2 = capacityWake.signal();
|
|
665153
665831
|
await sleep2(
|
|
665154
665832
|
atCapMs > 0 ? atCapMs : pollConfig.non_exclusive_heartbeat_interval_ms,
|
|
665155
|
-
|
|
665833
|
+
cap2.signal
|
|
665156
665834
|
);
|
|
665157
|
-
|
|
665835
|
+
cap2.cleanup();
|
|
665158
665836
|
}
|
|
665159
665837
|
} else if (atCapMs > 0) {
|
|
665160
|
-
const
|
|
665161
|
-
await sleep2(atCapMs,
|
|
665162
|
-
|
|
665838
|
+
const cap2 = capacityWake.signal();
|
|
665839
|
+
await sleep2(atCapMs, cap2.signal);
|
|
665840
|
+
cap2.cleanup();
|
|
665163
665841
|
}
|
|
665164
665842
|
} else {
|
|
665165
665843
|
const interval = activeSessions.size > 0 ? pollConfig.multisession_poll_interval_ms_partial_capacity : pollConfig.multisession_poll_interval_ms_not_at_capacity;
|
|
@@ -665173,20 +665851,20 @@ async function runBridgeLoop(config4, environmentId, environmentSecret, api2, sp
|
|
|
665173
665851
|
`[bridge:work] Skipping already-completed workId=${work.id}`
|
|
665174
665852
|
);
|
|
665175
665853
|
if (atCapacityBeforeSwitch) {
|
|
665176
|
-
const
|
|
665854
|
+
const cap2 = capacityWake.signal();
|
|
665177
665855
|
if (pollConfig.non_exclusive_heartbeat_interval_ms > 0) {
|
|
665178
665856
|
await heartbeatActiveWorkItems();
|
|
665179
665857
|
await sleep2(
|
|
665180
665858
|
pollConfig.non_exclusive_heartbeat_interval_ms,
|
|
665181
|
-
|
|
665859
|
+
cap2.signal
|
|
665182
665860
|
);
|
|
665183
665861
|
} else if (pollConfig.multisession_poll_interval_ms_at_capacity > 0) {
|
|
665184
665862
|
await sleep2(
|
|
665185
665863
|
pollConfig.multisession_poll_interval_ms_at_capacity,
|
|
665186
|
-
|
|
665864
|
+
cap2.signal
|
|
665187
665865
|
);
|
|
665188
665866
|
}
|
|
665189
|
-
|
|
665867
|
+
cap2.cleanup();
|
|
665190
665868
|
} else {
|
|
665191
665869
|
await sleep2(1e3, loopSignal);
|
|
665192
665870
|
}
|
|
@@ -665212,20 +665890,20 @@ async function runBridgeLoop(config4, environmentId, environmentSecret, api2, sp
|
|
|
665212
665890
|
)
|
|
665213
665891
|
);
|
|
665214
665892
|
if (atCapacityBeforeSwitch) {
|
|
665215
|
-
const
|
|
665893
|
+
const cap2 = capacityWake.signal();
|
|
665216
665894
|
if (pollConfig.non_exclusive_heartbeat_interval_ms > 0) {
|
|
665217
665895
|
await heartbeatActiveWorkItems();
|
|
665218
665896
|
await sleep2(
|
|
665219
665897
|
pollConfig.non_exclusive_heartbeat_interval_ms,
|
|
665220
|
-
|
|
665898
|
+
cap2.signal
|
|
665221
665899
|
);
|
|
665222
665900
|
} else if (pollConfig.multisession_poll_interval_ms_at_capacity > 0) {
|
|
665223
665901
|
await sleep2(
|
|
665224
665902
|
pollConfig.multisession_poll_interval_ms_at_capacity,
|
|
665225
|
-
|
|
665903
|
+
cap2.signal
|
|
665226
665904
|
);
|
|
665227
665905
|
}
|
|
665228
|
-
|
|
665906
|
+
cap2.cleanup();
|
|
665229
665907
|
}
|
|
665230
665908
|
continue;
|
|
665231
665909
|
}
|
|
@@ -665520,20 +666198,20 @@ async function runBridgeLoop(config4, environmentId, environmentSecret, api2, sp
|
|
|
665520
666198
|
break;
|
|
665521
666199
|
}
|
|
665522
666200
|
if (atCapacityBeforeSwitch) {
|
|
665523
|
-
const
|
|
666201
|
+
const cap2 = capacityWake.signal();
|
|
665524
666202
|
if (pollConfig.non_exclusive_heartbeat_interval_ms > 0) {
|
|
665525
666203
|
await heartbeatActiveWorkItems();
|
|
665526
666204
|
await sleep2(
|
|
665527
666205
|
pollConfig.non_exclusive_heartbeat_interval_ms,
|
|
665528
|
-
|
|
666206
|
+
cap2.signal
|
|
665529
666207
|
);
|
|
665530
666208
|
} else if (pollConfig.multisession_poll_interval_ms_at_capacity > 0) {
|
|
665531
666209
|
await sleep2(
|
|
665532
666210
|
pollConfig.multisession_poll_interval_ms_at_capacity,
|
|
665533
|
-
|
|
666211
|
+
cap2.signal
|
|
665534
666212
|
);
|
|
665535
666213
|
}
|
|
665536
|
-
|
|
666214
|
+
cap2.cleanup();
|
|
665537
666215
|
}
|
|
665538
666216
|
} catch (err8) {
|
|
665539
666217
|
if (loopSignal.aborted) {
|
|
@@ -670517,7 +671195,11 @@ function HubHeader({
|
|
|
670517
671195
|
] })
|
|
670518
671196
|
] }),
|
|
670519
671197
|
/* @__PURE__ */ (0, import_jsx_runtime492.jsx)(ThemedText, { dimColor: true, children: subtitle }),
|
|
670520
|
-
intro ?
|
|
671198
|
+
intro ? (
|
|
671199
|
+
// BUG-0006:固定 width=96 在 80×24 终端下每个换行行都被硬裁掉 81-96 列丢字
|
|
671200
|
+
// (裁点恰在 ~80 字节,截断处接空行的签名即由此来);maxWidth 让盒随终端收缩换行。
|
|
671201
|
+
/* @__PURE__ */ (0, import_jsx_runtime492.jsx)(ThemedBox_default, { marginTop: 1, maxWidth: 96, children: /* @__PURE__ */ (0, import_jsx_runtime492.jsx)(ThemedText, { dimColor: true, children: intro }) })
|
|
671202
|
+
) : null
|
|
670521
671203
|
] });
|
|
670522
671204
|
}
|
|
670523
671205
|
function FormField({
|
|
@@ -670985,11 +671667,11 @@ function modelFormScreen(opts) {
|
|
|
670985
671667
|
// 新增流程压根不显示,用户会误以为 Label 就是那个"身份"字段,而它的旧文案「display name in
|
|
670986
671668
|
// the Hub」没说清楚留空会怎样。实际行为(modelChannels.ts:717):留空 → provider 分组名回落
|
|
670987
671669
|
// 成通用的 channel 名(如"Custom provider"),不是回落到 Model ID。文案说清楚这一后果。
|
|
670988
|
-
{ label: `Label: ${draft.label || "(optional)"}`, value: "label", description: `edit \xB7 override how this entry's provider groups in the Hub (blank \u2192 generic "Custom provider")`, dimDescription: true },
|
|
670989
|
-
{ label: `Endpoint: ${draft.baseUrl || "(required \u2014 edit)"}`, value: "url", description: "edit", dimDescription: true },
|
|
671670
|
+
{ label: `Label: ${clampShown(draft.label) || "(optional)"}`, value: "label", description: `edit \xB7 override how this entry's provider groups in the Hub (blank \u2192 generic "Custom provider")`, dimDescription: true },
|
|
671671
|
+
{ label: `Endpoint: ${clampShown(draft.baseUrl) || "(required \u2014 edit)"}`, value: "url", description: "edit", dimDescription: true },
|
|
670990
671672
|
{ label: `API shape: ${draft.api}`, value: "api", description: "edit", dimDescription: true },
|
|
670991
671673
|
{ label: `API key: ${draft.apiKey ? "\u2022\u2022\u2022\u2022" + draft.apiKey.slice(-4) : "(not set)"}`, value: "key", description: "edit", dimDescription: true },
|
|
670992
|
-
{ label: `Model ID: ${draft.modelId || "(required \u2014 edit)"}`, value: "id", description: "edit", dimDescription: true },
|
|
671674
|
+
{ label: `Model ID: ${clampShown(draft.modelId) || "(required \u2014 edit)"}`, value: "id", description: "edit", dimDescription: true },
|
|
670993
671675
|
{ label: `Context window: ${fmt(draft.contextWindow)}`, value: "ctx", description: "pick 64K/128K/200K/256K/512K/1M or custom", dimDescription: true },
|
|
670994
671676
|
{
|
|
670995
671677
|
label: `Max output tokens: ${fmt(draft.maxTokens)}`,
|
|
@@ -671000,10 +671682,13 @@ function modelFormScreen(opts) {
|
|
|
671000
671682
|
];
|
|
671001
671683
|
return /* @__PURE__ */ (0, import_jsx_runtime494.jsxs)(ThemedBox_default, { flexDirection: "column", paddingLeft: 1, children: [
|
|
671002
671684
|
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(HubHeader, { subtitle: opts.title, intro: opts.intro }),
|
|
671003
|
-
opts.hint ?
|
|
671685
|
+
opts.hint ? (
|
|
671686
|
+
// BUG-0006:固定 width 在 80 列终端下溢出被硬裁丢字;maxWidth 让盒随终端收缩换行
|
|
671687
|
+
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 96, children: /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { color: "yellow", children: opts.hint }) })
|
|
671688
|
+
) : null,
|
|
671004
671689
|
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedBox_default, { flexDirection: "column", paddingLeft: 1, marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime494.jsxs)(ThemedText, { children: [
|
|
671005
671690
|
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { dimColor: true, children: "Endpoint " }),
|
|
671006
|
-
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { children: draft.baseUrl || "(not set)" }),
|
|
671691
|
+
/* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { children: clampShown(draft.baseUrl) || "(not set)" }),
|
|
671007
671692
|
/* @__PURE__ */ (0, import_jsx_runtime494.jsxs)(ThemedText, { dimColor: true, children: [
|
|
671008
671693
|
" ",
|
|
671009
671694
|
draft.api
|
|
@@ -671625,7 +672310,7 @@ function ModelHubBody({
|
|
|
671625
672310
|
slimHeader: onboard?.slimHeader
|
|
671626
672311
|
}
|
|
671627
672312
|
),
|
|
671628
|
-
onboard ? /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
672313
|
+
onboard ? /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { dimColor: true, children: onboard.blurb }) }) : null,
|
|
671629
672314
|
message ? /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedBox_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime494.jsx)(ThemedText, { color: "yellow", children: message }) }) : null,
|
|
671630
672315
|
confirmDelete ? /* @__PURE__ */ (0, import_jsx_runtime494.jsxs)(ThemedBox_default, { marginBottom: 1, flexDirection: "column", children: [
|
|
671631
672316
|
/* @__PURE__ */ (0, import_jsx_runtime494.jsxs)(ThemedText, { color: "red", children: [
|
|
@@ -671708,7 +672393,7 @@ function ModelHubBody({
|
|
|
671708
672393
|
] }) })
|
|
671709
672394
|
] });
|
|
671710
672395
|
}
|
|
671711
|
-
var React184, import_jsx_runtime494, hostOf3, SUPPORTED_CHANNELS, channelModelCount;
|
|
672396
|
+
var React184, import_jsx_runtime494, clampShown, hostOf3, SUPPORTED_CHANNELS, channelModelCount;
|
|
671712
672397
|
var init_ModelHub = __esm({
|
|
671713
672398
|
"build-src/src/sema/config/ModelHub.tsx"() {
|
|
671714
672399
|
React184 = __toESM(require_react(), 1);
|
|
@@ -671727,11 +672412,12 @@ var init_ModelHub = __esm({
|
|
|
671727
672412
|
init_catalogScreens();
|
|
671728
672413
|
init_providerLinks();
|
|
671729
672414
|
import_jsx_runtime494 = __toESM(require_jsx_runtime(), 1);
|
|
672415
|
+
clampShown = (v2, max2 = 64) => v2 && v2.length > max2 ? `${v2.slice(0, 30)}\u2026${v2.slice(-30)}` : v2 ?? "";
|
|
671730
672416
|
hostOf3 = (u) => {
|
|
671731
672417
|
try {
|
|
671732
672418
|
return new URL(u).host;
|
|
671733
672419
|
} catch {
|
|
671734
|
-
return u;
|
|
672420
|
+
return clampShown(u);
|
|
671735
672421
|
}
|
|
671736
672422
|
};
|
|
671737
672423
|
SUPPORTED_CHANNELS = ["claude-code", "openclaw", "hermes"];
|
|
@@ -671861,7 +672547,10 @@ function ManualAddBody({
|
|
|
671861
672547
|
intro: "Point sema at any MCP server by hand. It's saved to your user scope (all projects) when you confirm."
|
|
671862
672548
|
}
|
|
671863
672549
|
),
|
|
671864
|
-
error51 ?
|
|
672550
|
+
error51 ? (
|
|
672551
|
+
// BUG-0006 同族:固定 width 窄终端溢出硬裁,maxWidth 随终端收缩换行
|
|
672552
|
+
/* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 96, children: /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedText, { color: "red", children: error51 }) })
|
|
672553
|
+
) : null,
|
|
671865
672554
|
/* @__PURE__ */ (0, import_jsx_runtime495.jsx)(
|
|
671866
672555
|
Select,
|
|
671867
672556
|
{
|
|
@@ -672069,7 +672758,7 @@ function McpHubBody({
|
|
|
672069
672758
|
slimHeader: onboard?.slimHeader
|
|
672070
672759
|
}
|
|
672071
672760
|
),
|
|
672072
|
-
onboard ? /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
672761
|
+
onboard ? /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedText, { dimColor: true, children: onboard.blurb }) }) : null,
|
|
672073
672762
|
message ? /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedBox_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime495.jsx)(ThemedText, { color: "yellow", children: message }) }) : null,
|
|
672074
672763
|
confirmDelete ? /* @__PURE__ */ (0, import_jsx_runtime495.jsxs)(ThemedBox_default, { marginBottom: 1, flexDirection: "column", children: [
|
|
672075
672764
|
/* @__PURE__ */ (0, import_jsx_runtime495.jsxs)(ThemedText, { color: "red", children: [
|
|
@@ -672516,8 +673205,8 @@ function PluginsHubBody({
|
|
|
672516
673205
|
slimHeader: onboard?.slimHeader
|
|
672517
673206
|
}
|
|
672518
673207
|
),
|
|
672519
|
-
onboard ? /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
672520
|
-
message ? /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
673208
|
+
onboard ? /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedText, { dimColor: true, children: onboard.blurb }) }) : null,
|
|
673209
|
+
message ? /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime497.jsx)(ThemedText, { color: "yellow", children: message }) }) : null,
|
|
672521
673210
|
confirmDelete ? /* @__PURE__ */ (0, import_jsx_runtime497.jsxs)(ThemedBox_default, { marginBottom: 1, flexDirection: "column", children: [
|
|
672522
673211
|
/* @__PURE__ */ (0, import_jsx_runtime497.jsxs)(ThemedText, { color: "red", children: [
|
|
672523
673212
|
"Uninstall ",
|
|
@@ -672729,7 +673418,7 @@ function TiersHubBody({
|
|
|
672729
673418
|
}
|
|
672730
673419
|
return /* @__PURE__ */ (0, import_jsx_runtime498.jsxs)(ThemedBox_default, { flexDirection: "column", paddingLeft: 1, children: [
|
|
672731
673420
|
/* @__PURE__ */ (0, import_jsx_runtime498.jsx)(TiersHeader, { subtitle: "Model tiers \u2014 named tier bindings, switch as a set" }),
|
|
672732
|
-
message ? /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
673421
|
+
message ? /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedText, { color: "yellow", children: message }) }) : null,
|
|
672733
673422
|
confirmDelete ? /* @__PURE__ */ (0, import_jsx_runtime498.jsxs)(ThemedBox_default, { marginBottom: 1, flexDirection: "column", children: [
|
|
672734
673423
|
/* @__PURE__ */ (0, import_jsx_runtime498.jsxs)(ThemedText, { color: "red", children: [
|
|
672735
673424
|
'Delete group "',
|
|
@@ -672931,7 +673620,7 @@ function GroupEditBody({
|
|
|
672931
673620
|
slimHeader: Boolean(onboard)
|
|
672932
673621
|
}
|
|
672933
673622
|
),
|
|
672934
|
-
onboard ? /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
673623
|
+
onboard ? /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime498.jsx)(ThemedText, { dimColor: true, children: onboard.blurb }) }) : null,
|
|
672935
673624
|
/* @__PURE__ */ (0, import_jsx_runtime498.jsx)(
|
|
672936
673625
|
Select,
|
|
672937
673626
|
{
|
|
@@ -673179,7 +673868,7 @@ function skillDetailScreen(skill) {
|
|
|
673179
673868
|
formatTokens(skill.tokens),
|
|
673180
673869
|
" tok"
|
|
673181
673870
|
] }),
|
|
673182
|
-
/* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedBox_default, { marginTop: 1,
|
|
673871
|
+
/* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedBox_default, { marginTop: 1, maxWidth: 96, children: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedText, { children: skill.description ?? /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedText, { dimColor: true, children: "(no description in frontmatter)" }) }) })
|
|
673183
673872
|
] }),
|
|
673184
673873
|
/* @__PURE__ */ (0, import_jsx_runtime499.jsx)(
|
|
673185
673874
|
Select,
|
|
@@ -673329,7 +674018,7 @@ function SkillsHubBody({
|
|
|
673329
674018
|
slimHeader: onboard?.slimHeader
|
|
673330
674019
|
}
|
|
673331
674020
|
),
|
|
673332
|
-
onboard ? /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedBox_default, { marginBottom: 1,
|
|
674021
|
+
onboard ? /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedBox_default, { marginBottom: 1, maxWidth: 100, children: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedText, { dimColor: true, children: onboard.blurb }) }) : null,
|
|
673333
674022
|
message ? /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedBox_default, { marginBottom: 1, children: /* @__PURE__ */ (0, import_jsx_runtime499.jsx)(ThemedText, { color: "yellow", children: message }) }) : null,
|
|
673334
674023
|
confirmDelete ? /* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(ThemedBox_default, { marginBottom: 1, flexDirection: "column", children: [
|
|
673335
674024
|
/* @__PURE__ */ (0, import_jsx_runtime499.jsxs)(ThemedText, { color: "red", children: [
|
|
@@ -674986,7 +675675,7 @@ async function run() {
|
|
|
674986
675675
|
throw new InvalidArgumentError(`It must be one of: ${allowed.join(", ")}`);
|
|
674987
675676
|
}
|
|
674988
675677
|
return value;
|
|
674989
|
-
})).option("--sandbox <profile>", `Sandbox image profile for submitted runs: a profile name (explicit; k8s-lane workers only \u2014 list with 'sema cloud images list'), or 'auto' to let the model pick via its SelectEnvironment tool (advisory; choice + reason are echoed in the reply). Omit for the worker default image.`).option("--scenario <name>", `Engine scenario for submitted runs (only works with --print): route the run through a deployment-defined scenario (tool roster + system prompt). Unknown names fall back to the default scenario. Omit for the default scenario; a persistent default can be set via SEMA_HEADLESS_SCENARIO in the settings.json env block.`).option("--
|
|
675678
|
+
})).option("--sandbox <profile>", `Sandbox image profile for submitted runs: a profile name (explicit; k8s-lane workers only \u2014 list with 'sema cloud images list'), or 'auto' to let the model pick via its SelectEnvironment tool (advisory; choice + reason are echoed in the reply). Omit for the worker default image.`).option("--scenario <name>", `Engine scenario for submitted runs (only works with --print): route the run through a deployment-defined scenario (tool roster + system prompt). Unknown names fall back to the default scenario. Omit for the default scenario; a persistent default can be set via SEMA_HEADLESS_SCENARIO in the settings.json env block.`).option("--final-verify", `Enable a final-verification pass for submitted runs (only works with --print; off by default). When enabled, headless -p runs that write files get up to two extra verification turns before finishing. A persistent default can be set via SEMA_HEADLESS_FINAL_VERIFY=true in the settings.json env block. Yields automatically (with a notice) when a Stop hook is configured.`).option("--no-final-verify", `Explicitly disable the final-verification pass for submitted runs (only works with --print). Verification is off by default, so this flag only matters to override --final-verify or a persistent SEMA_HEADLESS_FINAL_VERIFY=true default; it always wins.`).option("--deadline <sec>", `Wall-clock limit in seconds for submitted runs (only works with --print; sema superset \u2014 no upstream equivalent). The run fails loudly with its partial output when the limit is hit; integer between 30 and 86400. A persistent default can be set via SEMA_HEADLESS_DEADLINE_SEC in the settings.json env block.`).option("--max-tokens <n>", `Per-request output-token cap for submitted runs (only works with --print; sema superset \u2014 no upstream equivalent). Caps each model response rather than the whole run: hitting the cap cuts generation mid-stream, and a cut inside tool-call arguments surfaces as a provider truncation error; positive integer. A persistent default can be set via SEMA_HEADLESS_MAX_TOKENS in the settings.json env block.`).option("--agent <agent>", `Agent for the current session. Overrides the 'agent' setting.`).option("--betas <betas...>", "Beta headers to include in API requests (API key users only)").option("--fallback-model <model>", "Enable automatic fallback to specified model when default model is overloaded (only works with --print)").addOption(new Option("--workload <tag>", "Workload tag for billing-header attribution (cc_workload). Process-scoped; set by SDK daemon callers that spawn subprocesses for cron work. (only works with --print)").hideHelp()).option("--settings <file-or-json>", "Path to a settings JSON file or a JSON string to load additional settings from").option("--add-dir <directories...>", "Additional directories to allow tool access to").option("--ide", "Automatically connect to IDE on startup if exactly one valid IDE is available", () => true).option("--strict-mcp-config", "Only use MCP servers from --mcp-config, ignoring all other MCP configurations", () => true).option("--session-id <uuid>", "Use a specific session ID for the conversation (must be a valid UUID)").option("-n, --name <name>", "Set a display name for this session (shown in /resume and terminal title)").option("--agents <json>", `JSON object defining custom agents (e.g. '{"reviewer": {"description": "Reviews code", "prompt": "You are a code reviewer"}}')`).option("--setting-sources <sources>", "Comma-separated list of setting sources to load (user, project, local).").option("--plugin-dir <path>", "Load plugins from a directory for this session only (repeatable: --plugin-dir A --plugin-dir B)", (val, prev) => [...prev, val], []).addOption(new Option("--plugin-dir-no-mcp <path>", "Like --plugin-dir but the engine will not read this plugin's .mcp.json (caller owns its MCP connections)").argParser((val, prev) => [...prev, val]).default([]).hideHelp()).option("--plugin-url <url>", "Fetch a plugin .zip from a URL for this session only (repeatable: --plugin-url A --plugin-url B)", (val, prev) => [...prev, ...val.split(/\s+/).filter(Boolean)], []).option("--disable-slash-commands", "Disable all skills", () => true).option("--chrome", "Enable Claude in Chrome integration").option("--no-chrome", "Disable Claude in Chrome integration").option("--file <specs...>", "File resources to download at startup. Format: file_id:relative_path (e.g., --file file_abc:doc.txt file_def:img.png)").action(async (prompt, options) => {
|
|
674990
675679
|
profileCheckpoint("action_handler_start");
|
|
674991
675680
|
{
|
|
674992
675681
|
const UNWIRED_FLAGS = [
|
|
@@ -677125,7 +677814,7 @@ Auth: unix socket -R \u2192 local proxy`, "info");
|
|
|
677125
677814
|
pendingHookMessages
|
|
677126
677815
|
}, renderAndRun);
|
|
677127
677816
|
}
|
|
677128
|
-
}).version("sema 1.0.
|
|
677817
|
+
}).version("sema 1.0.68", "-v, --version", "Output the version number");
|
|
677129
677818
|
program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
677130
677819
|
program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
677131
677820
|
if (canUserConfigureAdvisor()) {
|
|
@@ -682052,6 +682741,7 @@ var init_engineWireInjection = __esm({
|
|
|
682052
682741
|
// build-src/src/sema/workflowLiveActivity.ts
|
|
682053
682742
|
var workflowLiveActivity_exports = {};
|
|
682054
682743
|
__export(workflowLiveActivity_exports, {
|
|
682744
|
+
__feedWorkflowActivityFrameForTests: () => __feedWorkflowActivityFrameForTests,
|
|
682055
682745
|
ensureWorkflowActivityLedger: () => ensureWorkflowActivityLedger,
|
|
682056
682746
|
resetWorkflowActivityLedgers: () => resetWorkflowActivityLedgers,
|
|
682057
682747
|
stopWorkflowActivityLedger: () => stopWorkflowActivityLedger,
|
|
@@ -682079,13 +682769,17 @@ function onFrame(ledger, frame) {
|
|
|
682079
682769
|
const n2 = (ledger.startedLabels.get(label) ?? 0) + 1;
|
|
682080
682770
|
ledger.startedLabels.set(label, n2);
|
|
682081
682771
|
if (n2 > 1 && frame.data.replayed !== true) ledger.ambiguous.add(label);
|
|
682772
|
+
const requested = frame.data.model;
|
|
682773
|
+
if (typeof requested === "string" && requested) accFor(label).requestedModel = requested;
|
|
682082
682774
|
}
|
|
682083
682775
|
return;
|
|
682084
682776
|
}
|
|
682085
682777
|
if (frame.event === "agent_end") {
|
|
682086
682778
|
const label = frame.data.label;
|
|
682087
|
-
if (typeof label === "string" && label
|
|
682088
|
-
accFor(label).endedToolCalls = frame.data.toolCalls;
|
|
682779
|
+
if (typeof label === "string" && label) {
|
|
682780
|
+
if (typeof frame.data.toolCalls === "number") accFor(label).endedToolCalls = frame.data.toolCalls;
|
|
682781
|
+
const resolved = frame.data.modelResolved;
|
|
682782
|
+
if (typeof resolved === "string" && resolved) accFor(label).resolvedModel = resolved;
|
|
682089
682783
|
}
|
|
682090
682784
|
return;
|
|
682091
682785
|
}
|
|
@@ -682179,6 +682873,20 @@ function resetWorkflowActivityLedgers() {
|
|
|
682179
682873
|
for (const l3 of ledgers.values()) l3.abort.abort();
|
|
682180
682874
|
ledgers.clear();
|
|
682181
682875
|
}
|
|
682876
|
+
function __feedWorkflowActivityFrameForTests(workflowId, frame) {
|
|
682877
|
+
let ledger = ledgers.get(workflowId);
|
|
682878
|
+
if (!ledger) {
|
|
682879
|
+
ledger = {
|
|
682880
|
+
byLabel: /* @__PURE__ */ new Map(),
|
|
682881
|
+
startedLabels: /* @__PURE__ */ new Map(),
|
|
682882
|
+
ambiguous: /* @__PURE__ */ new Set(),
|
|
682883
|
+
closed: true,
|
|
682884
|
+
abort: new AbortController()
|
|
682885
|
+
};
|
|
682886
|
+
ledgers.set(workflowId, ledger);
|
|
682887
|
+
}
|
|
682888
|
+
onFrame(ledger, frame);
|
|
682889
|
+
}
|
|
682182
682890
|
function wrapWorkflowDetailWithLiveActivity(base, opts) {
|
|
682183
682891
|
ensureWorkflowActivityLedger(opts);
|
|
682184
682892
|
const baseSubscribe = base.subscribe?.bind(base);
|
|
@@ -682205,6 +682913,10 @@ function wrapWorkflowDetailWithLiveActivity(base, opts) {
|
|
|
682205
682913
|
if (tail.summary) patch2.lastToolSummary = tail.summary;
|
|
682206
682914
|
}
|
|
682207
682915
|
}
|
|
682916
|
+
if (a.model == null && acc.requestedModel !== void 0) patch2.model = acc.requestedModel;
|
|
682917
|
+
if (a.fallbackModel == null && acc.resolvedModel !== void 0) {
|
|
682918
|
+
patch2.fallbackModel = acc.resolvedModel;
|
|
682919
|
+
}
|
|
682208
682920
|
if (acc.lastTs !== void 0 && (a.lastProgressAt == null || acc.lastTs > a.lastProgressAt)) {
|
|
682209
682921
|
patch2.lastProgressAt = acc.lastTs;
|
|
682210
682922
|
}
|
|
@@ -687183,6 +687895,27 @@ async function launchReplProduction() {
|
|
|
687183
687895
|
} catch (e) {
|
|
687184
687896
|
if (process.env.SEMA_DEBUG) console.error("[sema] permission-flag plumbing soft-failed:", e);
|
|
687185
687897
|
}
|
|
687898
|
+
try {
|
|
687899
|
+
const tpc = initialState.toolPermissionContext;
|
|
687900
|
+
const { loadAllPermissionRulesFromDisk: loadAllPermissionRulesFromDisk2 } = await Promise.resolve().then(() => (init_permissionsLoader(), permissionsLoader_exports));
|
|
687901
|
+
const { applyPermissionRulesToPermissionContext: applyPermissionRulesToPermissionContext2 } = await Promise.resolve().then(() => (init_permissions2(), permissions_exports2));
|
|
687902
|
+
const rulesFromDisk = loadAllPermissionRulesFromDisk2();
|
|
687903
|
+
if (rulesFromDisk.length > 0) {
|
|
687904
|
+
let next = applyPermissionRulesToPermissionContext2(tpc, rulesFromDisk);
|
|
687905
|
+
if (tpc.mode === "auto") {
|
|
687906
|
+
const { stripDangerousPermissionsForAutoMode: stripDangerousPermissionsForAutoMode2 } = await Promise.resolve().then(() => (init_permissionSetup(), permissionSetup_exports));
|
|
687907
|
+
next = stripDangerousPermissionsForAutoMode2(next);
|
|
687908
|
+
}
|
|
687909
|
+
Object.assign(tpc, next);
|
|
687910
|
+
}
|
|
687911
|
+
if (process.env.SEMA_DEBUG) {
|
|
687912
|
+
console.error(
|
|
687913
|
+
`[sema] permission rules from disk: ${rulesFromDisk.length} loaded (mode=${String(tpc.mode)})`
|
|
687914
|
+
);
|
|
687915
|
+
}
|
|
687916
|
+
} catch (e) {
|
|
687917
|
+
if (process.env.SEMA_DEBUG) console.error("[sema] permission-rule load soft-failed (rules stay empty):", e);
|
|
687918
|
+
}
|
|
687186
687919
|
let mcpDynamicConfig = {};
|
|
687187
687920
|
try {
|
|
687188
687921
|
const mcpState = initialState.mcp;
|