@sema-agent/server 7.70.0 → 7.72.0
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/USAGE.md +8 -4
- package/dist/approval-card.d.ts +16 -17
- package/dist/approval-card.js +0 -9
- package/dist/approval-content-kind.d.ts +13 -7
- package/dist/approval-content-kind.js +3 -1
- package/dist/approval.js +3 -2
- package/dist/bench/s1/live-deps.js +2 -0
- package/dist/boot/execution-env.js +12 -2
- package/dist/boot/memory-consolidation.d.ts +2 -1
- package/dist/boot/parked-revive-gate.d.ts +2 -0
- package/dist/boot/parked-revive-gate.js +5 -1
- package/dist/boot/resolve-spec.js +8 -3
- package/dist/boot/runner-deps.d.ts +48 -59
- package/dist/boot/runner-deps.js +10 -4
- package/dist/brain.d.ts +3 -1
- package/dist/brain.js +2 -8
- package/dist/budget.d.ts +12 -1
- package/dist/budget.js +1 -1
- package/dist/config-catalog.js +13 -11
- package/dist/config-center/apply-effective.js +2 -4
- package/dist/config-center/facade.d.ts +1 -1
- package/dist/config-center/restart-signal.js +2 -2
- package/dist/config-center/skills-mcp.js +15 -0
- package/dist/config-types.d.ts +86 -4
- package/dist/config-types.js +19 -0
- package/dist/config.d.ts +42 -0
- package/dist/config.js +71 -22
- package/dist/deployment-governance.d.ts +6 -3
- package/dist/deployment-governance.js +2 -1
- package/dist/execution-lane-caps.d.ts +51 -37
- package/dist/execution-lane-caps.js +23 -0
- package/dist/fleet/fleet-bus.d.ts +22 -1
- package/dist/fleet/fleet-bus.js +2 -1
- package/dist/http/durable-run-leg.d.ts +64 -0
- package/dist/http/durable-run-leg.js +63 -0
- package/dist/http/route-ctx.d.ts +14 -0
- package/dist/http/route-ctx.js +3 -0
- package/dist/http/routes/approvals-assistant.js +3 -3
- package/dist/http/routes/capabilities.js +2 -2
- package/dist/http/routes/runs.js +10 -58
- package/dist/http/routes/workflows.js +1 -0
- package/dist/http/server.js +72 -22
- package/dist/index.d.ts +1 -1
- package/dist/leader/wire.js +4 -3
- package/dist/main.js +8 -3
- package/dist/memory-operator-faces.d.ts +1 -1
- package/dist/memory-scope.d.ts +24 -0
- package/dist/memory-scope.js +12 -3
- package/dist/observability/fail-open.d.ts +1 -1
- package/dist/observability/fail-open.js +1 -1
- package/dist/observability/metrics.d.ts +4 -0
- package/dist/observability/metrics.js +3 -1
- package/dist/observability/run-terminal-log.d.ts +4 -3
- package/dist/observability/run-terminal-log.js +4 -15
- package/dist/observability/tool-trace.d.ts +18 -1
- package/dist/observability/tool-trace.js +4 -3
- package/dist/orchestration/workflow-agent-session-index.d.ts +85 -2
- package/dist/orchestration/workflow-agent-session-index.js +38 -5
- package/dist/parked-decide.d.ts +40 -1
- package/dist/parked-decide.js +22 -4
- package/dist/plugins/checkpoint-store-sql.js +5 -5
- package/dist/plugins/e2b-orphan-reclaim.d.ts +4 -4
- package/dist/plugins/e2b-orphan-reclaim.js +18 -20
- package/dist/plugins/local-checkpoint-store.js +3 -3
- package/dist/plugins/remote-env-adb.d.ts +11 -0
- package/dist/plugins/remote-env-adb.js +2 -0
- package/dist/plugins/remote-env-device.d.ts +9 -0
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +11 -0
- package/dist/plugins/remote-env-e2b.js +2 -0
- package/dist/plugins/remote-env-host.d.ts +11 -0
- package/dist/plugins/remote-env-host.js +2 -0
- package/dist/plugins/remote-env-k8s.d.ts +11 -0
- package/dist/plugins/remote-env-k8s.js +2 -0
- package/dist/plugins/remote-env-local-docker.d.ts +11 -0
- package/dist/plugins/remote-env-local-docker.js +2 -0
- package/dist/plugins/remote-env-ssh.d.ts +11 -0
- package/dist/plugins/remote-env-ssh.js +2 -0
- package/dist/plugins/store-backend.d.ts +34 -12
- package/dist/plugins/store-backend.js +12 -3
- package/dist/plugins/store-contracts.d.ts +81 -18
- package/dist/plugins/store-contracts.js +18 -30
- package/dist/plugins/workflow-run-store-sql.d.ts +31 -9
- package/dist/plugins/workflow-run-store-sql.js +28 -1
- package/dist/run-cancel-context.js +1 -1
- package/dist/run-local.js +7 -1
- package/dist/runs.d.ts +16 -2
- package/dist/runs.js +2 -1
- package/dist/runtime-caps-resolver.js +5 -3
- package/dist/task-a2a.js +2 -1
- package/dist/task-mcp.js +2 -1
- package/dist/task-settings.d.ts +21 -8
- package/dist/task-settings.js +2 -2
- package/dist/tool-approval.d.ts +26 -21
- package/dist/tool-approval.js +2 -2
- package/dist/trace/core-keyset-guard.d.ts +136 -10
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +1 -0
- package/dist/trace/ledger-events.d.ts +5 -1
- package/dist/trace/ledger-sink.js +8 -1
- package/dist/trace/project.d.ts +33 -4
- package/dist/trace/project.js +24 -6
- package/dist/trace/redact.js +10 -5
- package/dist/usage-analytics.d.ts +9 -1
- package/dist/usage-analytics.js +8 -0
- package/dist/wire-name-bound.d.ts +14 -0
- package/dist/wire-name-bound.js +13 -0
- package/package.json +3 -3
package/dist/trace/redact.js
CHANGED
|
@@ -4,15 +4,21 @@ export const normalizeForRedaction = stripFormatCharacters;
|
|
|
4
4
|
const REDACTION_TOKEN_RE_SRC = String.raw `«redacted(?::[a-z-]{1,16}){0,2}»`;
|
|
5
5
|
const ENTROPY_SCAN_MAX = 96;
|
|
6
6
|
const twoStrongAhead = (valueClass) => String.raw `(?=${valueClass}{0,${ENTROPY_SCAN_MAX}}[0-9A-Z]${valueClass}{0,${ENTROPY_SCAN_MAX}}[0-9A-Z])`;
|
|
7
|
+
const IDENT_CONNECTORS = "[_./-]";
|
|
8
|
+
const noConnectorAhead = (valueClass) => String.raw `(?!${valueClass}{0,${ENTROPY_SCAN_MAX}}${IDENT_CONNECTORS}${valueClass})`;
|
|
7
9
|
const valueArm = (prefixSrc, valueClass, min) => new RegExp(`${prefixSrc}${twoStrongAhead(valueClass)}${valueClass}{${min},}`, "g");
|
|
10
|
+
const WORD_SEGMENT_CLASS = "[A-Za-z0-9._~+/-]";
|
|
8
11
|
const keywordArm = (keywordSrc, valueClass, min, tailSrc = "") => new RegExp(`(?:${keywordSrc}\\s+${valueClass}{${min},}${tailSrc}` +
|
|
9
|
-
`|(?<!${
|
|
12
|
+
`|(?<!${WORD_SEGMENT_CLASS})${keywordSrc}(?:${twoStrongAhead(valueClass)}|${noConnectorAhead(valueClass)})${valueClass}{${min},}${tailSrc})`, "g");
|
|
10
13
|
const STRUCTURAL_SECRET_PATTERNS = [
|
|
11
14
|
[/-----BEGIN(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,8192}?-----END(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----/g, "«redacted:private-key»"],
|
|
12
15
|
[/---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----[\s\S]{0,8192}?---- END SSH2 ENCRYPTED PRIVATE KEY ----/g, "«redacted:private-key»"],
|
|
13
16
|
[/:(?<=[A-Za-z][A-Za-z0-9+.-]*:)\/\//g, "$1:«redacted»@"],
|
|
14
17
|
[/("(?:private_key|client_secret|password|api[_-]?key|secret|token)"\s*:\s*)"[^"\\]*(?:\\.[^"\\]*)*"/gi, '$1"«redacted»"'],
|
|
15
18
|
];
|
|
19
|
+
const PPK_CONTAINER_TOKEN = "«redacted:private-key»";
|
|
20
|
+
const PEM_FRAGMENT_TOKEN = "«redacted:private-key:partial»";
|
|
21
|
+
const HEADLESS_PPK_TOKEN = "«redacted:private-key:partial»";
|
|
16
22
|
const KEYWORD_SECRET_PATTERNS = [
|
|
17
23
|
[keywordArm("[Bb]earer", "[A-Za-z0-9._~+/-]", 20, "=*"), "Bearer «redacted»"],
|
|
18
24
|
[keywordArm("Basic", "[A-Za-z0-9+/]", 16, "={0,2}"), "Basic «redacted»"],
|
|
@@ -29,7 +35,6 @@ const SHAPE_SECRET_PATTERNS = [
|
|
|
29
35
|
[/xapp-\d-[A-Za-z0-9-]{20,}/g, "«redacted:slack-token»"],
|
|
30
36
|
];
|
|
31
37
|
const FULL_SECRET_PATTERNS = [...STRUCTURAL_SECRET_PATTERNS, ...KEYWORD_SECRET_PATTERNS, ...SHAPE_SECRET_PATTERNS];
|
|
32
|
-
const PEM_FRAGMENT_TOKEN = "«redacted:private-key:partial»";
|
|
33
38
|
const PEM_HEADER_IDENT_MAX = 31;
|
|
34
39
|
const PEM_BODY_RUN_MIN = 8;
|
|
35
40
|
const CH_TAB = 9, CH_LF = 10, CH_CR = 13, CH_SPACE = 32, CH_PLUS = 43, CH_MINUS = 45, CH_SLASH = 47;
|
|
@@ -301,7 +306,6 @@ function redactPemFragments(text, json) {
|
|
|
301
306
|
out.push(text.slice(copied));
|
|
302
307
|
return { out: out.join(""), count };
|
|
303
308
|
}
|
|
304
|
-
const HEADLESS_PPK_TOKEN = "«redacted:private-key:partial»";
|
|
305
309
|
function redactHeadlessPpkBodies(text) {
|
|
306
310
|
const KEY = "Private-Lines: ";
|
|
307
311
|
const n = text.length;
|
|
@@ -558,7 +562,6 @@ function redactUrlUserinfo(text, json) {
|
|
|
558
562
|
}
|
|
559
563
|
return count === 0 ? { out: text, count: 0 } : { out: out + text.slice(last), count };
|
|
560
564
|
}
|
|
561
|
-
const PPK_CONTAINER_TOKEN = "«redacted:private-key»";
|
|
562
565
|
let ppkScanBytes = 0;
|
|
563
566
|
export function ppkScanBytesForTest() { return ppkScanBytes; }
|
|
564
567
|
export function resetPpkScanBytesForTest() { ppkScanBytes = 0; }
|
|
@@ -658,10 +661,12 @@ function redactPpkContainers(text, record) {
|
|
|
658
661
|
}
|
|
659
662
|
const urlUserinfoRule = { label: labelOfToken(URL_USERINFO_PATTERN[1]), arm: "full", run: (text, _wantCount, json) => redactUrlUserinfo(text, json) };
|
|
660
663
|
const SECRET_RULES = [
|
|
661
|
-
...
|
|
664
|
+
...STRUCTURAL_SECRET_PATTERNS.map((p) => (p === URL_USERINFO_PATTERN ? urlUserinfoRule : regexRule(p, "full"))),
|
|
662
665
|
{ label: labelOfToken(PPK_CONTAINER_TOKEN), arm: "full", run: (text, _wantCount, _json, observe) => redactPpkContainers(text, observe) },
|
|
663
666
|
{ label: labelOfToken(PEM_FRAGMENT_TOKEN), arm: "fragment", run: (text, _wantCount, json) => redactPemFragments(text, json) },
|
|
664
667
|
{ label: labelOfToken(HEADLESS_PPK_TOKEN), arm: "fragment", run: (text) => redactHeadlessPpkBodies(text) },
|
|
668
|
+
...KEYWORD_SECRET_PATTERNS.map((p) => regexRule(p, "full")),
|
|
669
|
+
...SHAPE_SECRET_PATTERNS.map((p) => regexRule(p, "full")),
|
|
665
670
|
...FRAGMENT_SECRET_PATTERNS.map((p) => regexRule(p, "fragment")),
|
|
666
671
|
{ ...urlUserinfoRule, run: (text, _wantCount, json) => ({ out: redactUrlUserinfo(text, json).out, count: 0 }) },
|
|
667
672
|
];
|
|
@@ -26,6 +26,11 @@ export interface UsageRow {
|
|
|
26
26
|
stats?: {
|
|
27
27
|
tokens?: number;
|
|
28
28
|
modelUsage?: Record<string, UsageModelEntry>;
|
|
29
|
+
/** core 7.14.0 [ref] C-b(`TaskResult.stats.usageMissing`):这一行的用量数字是**下界**不是测量值
|
|
30
|
+
* —— 至少有一轮模型没报用量,或整条结果是宿主/编排车道自铸的(一个模型轮都没跑过)。
|
|
31
|
+
* `true` 或缺席,**永不 `false`**;缺席 ⇔ 每轮都报了用量。fold 侧翻成既有的
|
|
32
|
+
* {@link UsageTotals.estimated}(见 `foldRow`),**不开第二条不精确轴**。 */
|
|
33
|
+
usageMissing?: true;
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
@@ -57,7 +62,10 @@ export interface UsageTotals {
|
|
|
57
62
|
* ②有 per-model echo 行**缺数值键**(该键按 0 计入,总量偏低;成本键缺席时尤其:少算 ≠ 免费);
|
|
58
63
|
* ③(S10/V2-⑤)有行的 {@link UsageModelEntry.usageBasis} 缺席或非本读端认识的分量制——存量行某族
|
|
59
64
|
* 历史上把 cache 计入 inputTokens,tokensIn 求和会**双算**,口径不可分辨。
|
|
60
|
-
*
|
|
65
|
+
* ④(7.72.0 / core 7.14.0 [ref] C-b)有行自陈 `stats.usageMissing` —— 那一行的数字是**下界**:至少一轮
|
|
66
|
+
* 模型没报用量,或整条结果是宿主自铸的零结果(取消打断 / 零执行的治理拒绝)。`tokens: 0` 在那种行上读作
|
|
67
|
+
* 「未知」而不是「免费」。
|
|
68
|
+
* 四者都只表达「别把这个总数当精确值」,消费端一视同仁。 */
|
|
61
69
|
estimated: boolean;
|
|
62
70
|
}
|
|
63
71
|
/** GET /v1/usage/summary — 窗内总量。 */
|
package/dist/usage-analytics.js
CHANGED
|
@@ -17,8 +17,13 @@ function foldModelEntry(t, d) {
|
|
|
17
17
|
if (d.usageBasis !== "uncached-components-v1")
|
|
18
18
|
t.estimated = true;
|
|
19
19
|
}
|
|
20
|
+
function markRowLowerBound(t, row) {
|
|
21
|
+
if (row.stats?.usageMissing === true)
|
|
22
|
+
t.estimated = true;
|
|
23
|
+
}
|
|
20
24
|
function foldRow(t, row) {
|
|
21
25
|
t.tasks += 1;
|
|
26
|
+
markRowLowerBound(t, row);
|
|
22
27
|
const mu = row.stats?.modelUsage;
|
|
23
28
|
if (mu && Object.keys(mu).length > 0) {
|
|
24
29
|
for (const d of Object.values(mu))
|
|
@@ -70,6 +75,7 @@ export function usageBreakdown(rows, dimension) {
|
|
|
70
75
|
const t = bucket(model);
|
|
71
76
|
t.tasks += 1;
|
|
72
77
|
foldModelEntry(t, d);
|
|
78
|
+
markRowLowerBound(t, r);
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
else {
|
|
@@ -92,6 +98,8 @@ export function projectUsageStats(result) {
|
|
|
92
98
|
const mu = stats.modelUsage;
|
|
93
99
|
if (mu && typeof mu === "object" && !Array.isArray(mu))
|
|
94
100
|
out.modelUsage = mu;
|
|
101
|
+
if (stats.usageMissing === true)
|
|
102
|
+
out.usageMissing = true;
|
|
95
103
|
return out;
|
|
96
104
|
}
|
|
97
105
|
catch {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 这个申报名能用吗 —— 四个收口共用的**那一只**谓词。
|
|
3
|
+
*
|
|
4
|
+
* 严判:非串、空串、超 `TOOL_WIRE_NAME_MAX_CHARS` 一律不可用。本层不做截断/规范化 —— 截短一个名字
|
|
5
|
+
* 就是**换一个身份**(core 自己 7.13.0 起正是为此把截断改成拒),而被换掉身份的那台 server 上挂的
|
|
6
|
+
* allowTools / toolFaces 收窄声明会一起对不上号。
|
|
7
|
+
*/
|
|
8
|
+
export declare function isUsableWireName(v: unknown): v is string;
|
|
9
|
+
/**
|
|
10
|
+
* 坏名的**可打印**摘要(进 warn 元数据)——中和 + 截长,绝不把任意长度的申报串原样回显进日志。
|
|
11
|
+
* 长度如实带上:运维要的是「我那个名字长了多少」,不是一屏乱码。
|
|
12
|
+
*/
|
|
13
|
+
export declare function describeBadWireName(v: unknown): string;
|
|
14
|
+
//# sourceMappingURL=wire-name-bound.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TOOL_WIRE_NAME_MAX_CHARS } from "@sema-agent/core";
|
|
2
|
+
export function isUsableWireName(v) {
|
|
3
|
+
return typeof v === "string" && v.length > 0 && v.length <= TOOL_WIRE_NAME_MAX_CHARS;
|
|
4
|
+
}
|
|
5
|
+
export function describeBadWireName(v) {
|
|
6
|
+
if (typeof v !== "string")
|
|
7
|
+
return v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
|
|
8
|
+
if (v.length === 0)
|
|
9
|
+
return "empty";
|
|
10
|
+
const head = v.length > 32 ? `${JSON.stringify(v.slice(0, 32))}…` : JSON.stringify(v);
|
|
11
|
+
return `${head} (${v.length} chars > ${TOOL_WIRE_NAME_MAX_CHARS})`;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=wire-name-bound.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.72.0",
|
|
4
4
|
"description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@sema-agent/core": "7.
|
|
57
|
+
"@sema-agent/core": "7.14.0",
|
|
58
58
|
"@sema-agent/settings-schema": "1.10.0",
|
|
59
59
|
"e2b": "^2.28.0",
|
|
60
60
|
"libsodium-wrappers": "^0.8.4",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"sharp": "^0.35.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@sema-agent/sdk": "9.
|
|
72
|
+
"@sema-agent/sdk": "9.1.0",
|
|
73
73
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
74
74
|
"@types/node": "22.10.2",
|
|
75
75
|
"@types/pg": "^8.20.0",
|