@sema-agent/server 7.68.0 → 7.70.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 +3 -0
- package/README.zh-CN.md +3 -0
- package/USAGE.md +122 -9
- package/dist/adoption/plan.js +11 -0
- package/dist/approval-ask-machine.d.ts +1 -1
- package/dist/approval-card.d.ts +27 -0
- package/dist/approval-card.js +11 -0
- package/dist/approval-reconciler.d.ts +0 -54
- package/dist/approval-reconciler.js +2 -2
- package/dist/approval.js +5 -4
- package/dist/boot/config-center.d.ts +6 -7
- package/dist/boot/config-center.js +31 -8
- package/dist/boot/leader.js +1 -1
- package/dist/boot/parked-revive-gate.js +10 -9
- package/dist/boot/runner-deps.d.ts +35 -4
- package/dist/boot/runner-deps.js +2 -6
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +10 -2
- package/dist/budget.js +3 -2
- package/dist/config-catalog.d.ts +31 -2
- package/dist/config-catalog.js +61 -24
- package/dist/config-center/apply-effective.d.ts +8 -1
- package/dist/config-center/apply-effective.js +23 -9
- package/dist/config-center/facade.d.ts +1 -1
- package/dist/config-center/facade.js +1 -1
- package/dist/config-center/read-face.d.ts +30 -1
- package/dist/config-center/read-face.js +33 -15
- package/dist/config-center/restart-signal.js +2 -1
- package/dist/config-center/types.d.ts +20 -5
- package/dist/config-provider.js +1 -0
- package/dist/config-types.d.ts +17 -2
- package/dist/config.d.ts +0 -21
- package/dist/config.js +19 -6
- package/dist/http/route-ctx.d.ts +39 -1
- package/dist/http/routes/approvals-assistant.js +4 -12
- package/dist/http/routes/capabilities.js +1 -0
- package/dist/http/routes/diagnostics.js +4 -0
- package/dist/http/routes/runs.js +2 -3
- package/dist/http/routes/tasks.js +22 -18
- package/dist/http/routes/workflows.js +15 -7
- package/dist/http/server.d.ts +10 -2
- package/dist/http/server.js +74 -26
- package/dist/leader/wire.d.ts +9 -2
- package/dist/leader/wire.js +6 -6
- package/dist/main.js +8 -7
- package/dist/model-compat.d.ts +81 -0
- package/dist/model-compat.js +52 -0
- package/dist/observability/fail-open.d.ts +4 -0
- package/dist/observability/fail-open.js +4 -0
- package/dist/observability/metrics.d.ts +0 -6
- package/dist/observability/metrics.js +3 -1
- package/dist/observability/permission-rule-events.d.ts +20 -0
- package/dist/observability/permission-rule-events.js +28 -0
- package/dist/observability/run-terminal-log.d.ts +9 -19
- package/dist/observability/run-terminal-log.js +183 -32
- package/dist/observability/tool-trace.d.ts +12 -0
- package/dist/observability/tool-trace.js +5 -1
- package/dist/operator-ask.d.ts +46 -0
- package/dist/operator-ask.js +4 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +96 -0
- package/dist/orchestration/workflow-agent-session-index.js +146 -0
- package/dist/orchestration/workflow-journal-entry.d.ts +78 -0
- package/dist/orchestration/workflow-journal-entry.js +20 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +43 -1
- package/dist/orchestration/workflow-notify-journal.js +43 -3
- package/dist/parked-decide.d.ts +115 -5
- package/dist/parked-decide.js +94 -26
- package/dist/plugins/pg-pool.js +8 -0
- package/dist/plugins/store-backend.d.ts +7 -1
- package/dist/plugins/store-backend.js +3 -1
- package/dist/plugins/tidb-pool.js +8 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +1 -1
- package/dist/plugins/workflow-journal-store-sql.js +5 -5
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -0
- package/dist/plugins/workflow-run-store-sql.js +40 -0
- package/dist/posture-source.d.ts +23 -3
- package/dist/posture-source.js +1 -1
- package/dist/read-face-posture.d.ts +8 -1
- package/dist/read-face-posture.js +1 -0
- package/dist/router/route-orchestration.js +2 -1
- package/dist/run-cancel-context.d.ts +50 -1
- package/dist/run-cancel-context.js +22 -0
- package/dist/run-local.d.ts +14 -6
- package/dist/run-local.js +2 -2
- package/dist/runs.d.ts +0 -51
- package/dist/runs.js +40 -23
- package/dist/runtime-governance.js +5 -4
- package/dist/tool-approval.d.ts +31 -5
- package/dist/tool-approval.js +5 -4
- package/dist/trace/core-keyset-guard.d.ts +9 -5
- 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 +17 -1
- package/dist/trace/ledger-events.js +6 -1
- package/dist/trace/ledger-sink.d.ts +10 -8
- package/dist/trace/ledger-sink.js +2 -1
- package/dist/trace/project.d.ts +3 -2
- package/dist/trace/redact.d.ts +28 -0
- package/dist/trace/redact.js +50 -27
- package/package.json +4 -4
package/dist/trace/redact.js
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
|
+
import { stripFormatCharacters } from "@sema-agent/core";
|
|
1
2
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
|
+
export const normalizeForRedaction = stripFormatCharacters;
|
|
2
4
|
const REDACTION_TOKEN_RE_SRC = String.raw `«redacted(?::[a-z-]{1,16}){0,2}»`;
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
+
const ENTROPY_SCAN_MAX = 96;
|
|
6
|
+
const twoStrongAhead = (valueClass) => String.raw `(?=${valueClass}{0,${ENTROPY_SCAN_MAX}}[0-9A-Z]${valueClass}{0,${ENTROPY_SCAN_MAX}}[0-9A-Z])`;
|
|
7
|
+
const valueArm = (prefixSrc, valueClass, min) => new RegExp(`${prefixSrc}${twoStrongAhead(valueClass)}${valueClass}{${min},}`, "g");
|
|
8
|
+
const keywordArm = (keywordSrc, valueClass, min, tailSrc = "") => new RegExp(`(?:${keywordSrc}\\s+${valueClass}{${min},}${tailSrc}` +
|
|
9
|
+
`|(?<!${valueClass})${keywordSrc}${twoStrongAhead(valueClass)}${valueClass}{${min},}${tailSrc})`, "g");
|
|
10
|
+
const STRUCTURAL_SECRET_PATTERNS = [
|
|
11
|
+
[/-----BEGIN(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,8192}?-----END(?:[^-](?:[^-](?:[^-]|-(?!-))*)?)?PRIVATE KEY(?: BLOCK)?-----/g, "«redacted:private-key»"],
|
|
5
12
|
[/---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----[\s\S]{0,8192}?---- END SSH2 ENCRYPTED PRIVATE KEY ----/g, "«redacted:private-key»"],
|
|
6
|
-
[
|
|
7
|
-
[/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b/g, "«redacted:gh-token»"],
|
|
8
|
-
[/\bgithub_pat_[A-Za-z0-9]{22}_[A-Za-z0-9]{59}\b/g, "«redacted:gh-token»"],
|
|
9
|
-
[/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g, "«redacted:slack-token»"],
|
|
10
|
-
[/\bAKIA[0-9A-Z]{16}\b/g, "«redacted:aws-key»"],
|
|
11
|
-
[/\bASIA[0-9A-Z]{16}\b/g, "«redacted:aws-key»"],
|
|
12
|
-
[/\b(?:gl(?:pat|dt|rt|rtr|cbt|ptt|oas|ft|imt|agent|wt|soat|ffct)-[A-Za-z0-9_-]{20,}|(?:sk|rk)_(?:live|test|org)_[A-Za-z0-9]{24,}|pypi-[A-Za-z0-9_-]{85,})\b/g, "«redacted:key»"],
|
|
13
|
-
[/\bxapp-\d-[A-Za-z0-9-]{20,}\b/g, "«redacted:slack-token»"],
|
|
14
|
-
[/\b[Bb]earer\s+[A-Za-z0-9._~+/-]{20,}=*/g, "Bearer «redacted»"],
|
|
15
|
-
[/\bBasic\s+[A-Za-z0-9+/]{16,}={0,2}/g, "Basic «redacted»"],
|
|
16
|
-
[/:(?<=\b[A-Za-z][A-Za-z0-9+.-]*:)\/\//g, "$1:«redacted»@"],
|
|
17
|
-
[/\b[Tt]oken\s+[A-Za-z0-9._~+/-]{20,}/g, "token «redacted»"],
|
|
13
|
+
[/:(?<=[A-Za-z][A-Za-z0-9+.-]*:)\/\//g, "$1:«redacted»@"],
|
|
18
14
|
[/("(?:private_key|client_secret|password|api[_-]?key|secret|token)"\s*:\s*)"[^"\\]*(?:\\.[^"\\]*)*"/gi, '$1"«redacted»"'],
|
|
19
15
|
];
|
|
16
|
+
const KEYWORD_SECRET_PATTERNS = [
|
|
17
|
+
[keywordArm("[Bb]earer", "[A-Za-z0-9._~+/-]", 20, "=*"), "Bearer «redacted»"],
|
|
18
|
+
[keywordArm("Basic", "[A-Za-z0-9+/]", 16, "={0,2}"), "Basic «redacted»"],
|
|
19
|
+
[keywordArm("[Tt]oken", "[A-Za-z0-9._~+/-]", 20), "token «redacted»"],
|
|
20
|
+
];
|
|
21
|
+
const SHAPE_SECRET_PATTERNS = [
|
|
22
|
+
[valueArm("sk-", "[A-Za-z0-9_-]", 16), "«redacted:key»"],
|
|
23
|
+
[/(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g, "«redacted:gh-token»"],
|
|
24
|
+
[/github_pat_[A-Za-z0-9]{22}_[A-Za-z0-9]{59,}/g, "«redacted:gh-token»"],
|
|
25
|
+
[/xox[baprs]-[A-Za-z0-9-]{10,}/g, "«redacted:slack-token»"],
|
|
26
|
+
[/AKIA[0-9A-Z]{16,}/g, "«redacted:aws-key»"],
|
|
27
|
+
[/ASIA[0-9A-Z]{16,}/g, "«redacted:aws-key»"],
|
|
28
|
+
[/(?:gl(?:pat|dt|rt|rtr|cbt|ptt|oas|ft|imt|agent|wt|soat|ffct)-[A-Za-z0-9_-]{20,}|(?:sk|rk)_(?:live|test|org)_[A-Za-z0-9]{24,}|pypi-[A-Za-z0-9_-]{85,})/g, "«redacted:key»"],
|
|
29
|
+
[/xapp-\d-[A-Za-z0-9-]{20,}/g, "«redacted:slack-token»"],
|
|
30
|
+
];
|
|
31
|
+
const FULL_SECRET_PATTERNS = [...STRUCTURAL_SECRET_PATTERNS, ...KEYWORD_SECRET_PATTERNS, ...SHAPE_SECRET_PATTERNS];
|
|
20
32
|
const PEM_FRAGMENT_TOKEN = "«redacted:private-key:partial»";
|
|
21
33
|
const PEM_HEADER_IDENT_MAX = 31;
|
|
22
34
|
const PEM_BODY_RUN_MIN = 8;
|
|
@@ -216,7 +228,7 @@ function isPemFenceLabel(s, from, to) {
|
|
|
216
228
|
let end = to;
|
|
217
229
|
if (end - from > PEM_BLOCK_WORD.length && s.startsWith(PEM_BLOCK_WORD, end - PEM_BLOCK_WORD.length))
|
|
218
230
|
end -= PEM_BLOCK_WORD.length;
|
|
219
|
-
if (end - from
|
|
231
|
+
if (end - from < PEM_KEY_WORD.length)
|
|
220
232
|
return false;
|
|
221
233
|
if (!s.startsWith(PEM_KEY_WORD, end - PEM_KEY_WORD.length))
|
|
222
234
|
return false;
|
|
@@ -399,14 +411,14 @@ function redactHeadlessPpkBodies(text) {
|
|
|
399
411
|
return count === 0 ? { out: text, count: 0 } : { out: out + text.slice(last), count };
|
|
400
412
|
}
|
|
401
413
|
const FRAGMENT_SECRET_PATTERNS = [
|
|
402
|
-
[
|
|
403
|
-
[
|
|
404
|
-
[
|
|
405
|
-
[
|
|
406
|
-
[
|
|
407
|
-
[
|
|
408
|
-
[
|
|
409
|
-
[
|
|
414
|
+
[valueArm("sk-", "[A-Za-z0-9_-]", 6), "«redacted:key:partial»"],
|
|
415
|
+
[valueArm("(?:ghp|gho|ghu|ghs|ghr)_", "[A-Za-z0-9]", 8), "«redacted:gh-token:partial»"],
|
|
416
|
+
[/github_pat_[A-Za-z0-9_]{8,}/g, "«redacted:gh-token:partial»"],
|
|
417
|
+
[valueArm("xox[baprs]-", "[A-Za-z0-9-]", 4), "«redacted:slack-token:partial»"],
|
|
418
|
+
[valueArm("AKIA", "[0-9A-Z]", 6), "«redacted:aws-key:partial»"],
|
|
419
|
+
[valueArm("ASIA", "[0-9A-Z]", 8), "«redacted:aws-key:partial»"],
|
|
420
|
+
[valueArm("(?:gl(?:pat|dt|rt|rtr|cbt|ptt|oas|ft|imt|agent|wt|soat|ffct)-|(?:sk|rk)_(?:live|test|org)_|pypi-)", "[A-Za-z0-9_-]", 8), "«redacted:key:partial»"],
|
|
421
|
+
[valueArm("xapp-\\d-", "[A-Za-z0-9-]", 4), "«redacted:slack-token:partial»"],
|
|
410
422
|
];
|
|
411
423
|
const REDACTION_TOKENS = new Set([...FULL_SECRET_PATTERNS.map(([, r]) => r), PEM_FRAGMENT_TOKEN, ...FRAGMENT_SECRET_PATTERNS.map(([, r]) => r)]
|
|
412
424
|
.flatMap((r) => r.match(/«[^»]*»/g) ?? []));
|
|
@@ -490,21 +502,33 @@ function scanUserinfoRun(text, i, kind, json) {
|
|
|
490
502
|
return i;
|
|
491
503
|
}
|
|
492
504
|
const REDACTION_TOKEN_Y = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
|
|
505
|
+
const SHAPE_STICKY = SHAPE_SECRET_PATTERNS.map(([re]) => new RegExp(re.source, "y"));
|
|
506
|
+
function keyShapedUsernameEnd(text, p) {
|
|
507
|
+
for (const re of SHAPE_STICKY) {
|
|
508
|
+
re.lastIndex = p;
|
|
509
|
+
if (re.test(text))
|
|
510
|
+
return re.lastIndex;
|
|
511
|
+
}
|
|
512
|
+
return -1;
|
|
513
|
+
}
|
|
493
514
|
function matchUserinfoAt(text, p, json) {
|
|
494
515
|
REDACTION_TOKEN_Y.lastIndex = p;
|
|
495
516
|
const tokEnd = REDACTION_TOKEN_Y.test(text) ? REDACTION_TOKEN_Y.lastIndex : -1;
|
|
496
517
|
const afterTok = tokEnd >= 0 ? text.charCodeAt(tokEnd) : -1;
|
|
497
518
|
if (afterTok === 64)
|
|
498
519
|
return null;
|
|
499
|
-
let userEnd;
|
|
520
|
+
let userEnd = -1;
|
|
500
521
|
let kind;
|
|
501
522
|
if (afterTok === 58) {
|
|
502
523
|
userEnd = tokEnd;
|
|
503
524
|
kind = "token-pass";
|
|
504
525
|
}
|
|
526
|
+
else if ((() => { const e = keyShapedUsernameEnd(text, p); return e >= 0 && text.charCodeAt(e) === 58 ? ((userEnd = e), true) : false; })()) {
|
|
527
|
+
kind = "token-pass";
|
|
528
|
+
}
|
|
505
529
|
else {
|
|
506
530
|
userEnd = scanUserinfoRun(text, p, "plain-user", json);
|
|
507
|
-
if (
|
|
531
|
+
if (text.charCodeAt(userEnd) !== 58)
|
|
508
532
|
return null;
|
|
509
533
|
kind = "plain-pass";
|
|
510
534
|
}
|
|
@@ -670,8 +694,7 @@ function reportHits(hits) {
|
|
|
670
694
|
export function redactSecrets(text, opts) {
|
|
671
695
|
const wantCount = onRedaction !== undefined && (opts?.observe ?? true);
|
|
672
696
|
const json = opts?.json === true;
|
|
673
|
-
|
|
674
|
-
r = applyRules(text, wantCount, json, opts?.observe ?? true);
|
|
697
|
+
const r = applyRules(normalizeForRedaction(text), wantCount, json, opts?.observe ?? true);
|
|
675
698
|
reportHits(r.hits);
|
|
676
699
|
return r.out;
|
|
677
700
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.70.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,8 +54,8 @@
|
|
|
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.
|
|
58
|
-
"@sema-agent/settings-schema": "1.
|
|
57
|
+
"@sema-agent/core": "7.12.0",
|
|
58
|
+
"@sema-agent/settings-schema": "1.10.0",
|
|
59
59
|
"e2b": "^2.28.0",
|
|
60
60
|
"libsodium-wrappers": "^0.8.4",
|
|
61
61
|
"mysql2": "^3.22.4",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"sharp": "^0.35.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@sema-agent/sdk": "
|
|
72
|
+
"@sema-agent/sdk": "9.0.0",
|
|
73
73
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
74
74
|
"@types/node": "22.10.2",
|
|
75
75
|
"@types/pg": "^8.20.0",
|