@sema-agent/server 7.130.0 → 7.132.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/MIGRATION.md +396 -0
- package/README.md +13 -6
- package/README.zh-CN.md +9 -5
- package/USAGE.md +187 -50
- package/dist/approval-card.d.ts +3 -1
- package/dist/approval-card.js +2 -3
- package/dist/audit.d.ts +7 -10
- package/dist/audit.js +4 -1
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bench/s1/live-deps.js +2 -0
- package/dist/boot/deployment-mods.d.ts +31 -0
- package/dist/boot/deployment-mods.js +26 -0
- package/dist/boot/execution-env.d.ts +1 -1
- package/dist/boot/execution-env.js +19 -6
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/read-deny-anchor-audit.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/resolve-spec.d.ts +1 -5
- package/dist/boot/resolve-spec.js +56 -61
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +14 -2
- package/dist/boot/session-faces.d.ts +1 -7
- package/dist/boot/stage-02-web-admin-pull.js +9 -1
- package/dist/boot/stage-03-store-backend.d.ts +1 -1
- package/dist/boot/stage-03-store-backend.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -1
- package/dist/boot/stage-05-execution-env.d.ts +4 -4
- package/dist/boot/stage-05-execution-env.js +7 -10
- package/dist/boot/stage-06-runners.d.ts +2 -2
- package/dist/boot/stage-06-runners.js +5 -4
- package/dist/boot/stage-07-capability-layer.d.ts +2 -2
- package/dist/boot/stage-07-capability-layer.js +3 -3
- package/dist/boot/stage-08-reapers.d.ts +2 -2
- package/dist/boot/stage-09-leader.d.ts +3 -9
- package/dist/boot/stage-10-http-server.d.ts +3 -9
- package/dist/boot/stage-10-http-server.js +12 -10
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +5 -6
- package/dist/boot/web-admin.d.ts +0 -3
- package/dist/boot/web-admin.js +35 -35
- package/dist/brain.js +17 -22
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +20 -0
- package/dist/caller-text-echo.js +24 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/builtin-tools.js +2 -1
- package/dist/capabilities/center-plugins.js +1 -1
- package/dist/capabilities/center-prompts.d.ts +32 -59
- package/dist/capabilities/center-prompts.js +18 -32
- package/dist/capabilities/composite-members.d.ts +1 -0
- package/dist/capabilities/composite-members.js +1 -0
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/hands-lane.d.ts +9 -6
- package/dist/capabilities/hands-lane.js +3 -3
- package/dist/capabilities/host-tool-names.d.ts +17 -0
- package/dist/capabilities/host-tool-names.js +15 -0
- package/dist/capabilities/mcp-probe.d.ts +14 -1
- package/dist/capabilities/mcp-probe.js +22 -133
- package/dist/capabilities/repo-tools.js +4 -3
- package/dist/capabilities/scenarios.d.ts +42 -47
- package/dist/capabilities/scenarios.js +19 -35
- package/dist/capabilities/select-environment-tool.js +2 -1
- package/dist/capabilities/send-user-file-tool.d.ts +0 -1
- package/dist/capabilities/send-user-file-tool.js +2 -2
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capabilities/tool-defer.js +2 -1
- package/dist/config-catalog.js +22 -11
- package/dist/config-invariants.js +2 -2
- package/dist/config-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +3 -1
- package/dist/config-provider.js +14 -6
- package/dist/config-types.d.ts +13 -9
- package/dist/config.d.ts +2 -2
- package/dist/config.js +34 -20
- package/dist/device-ws-protocol.d.ts +1 -1
- package/dist/device-ws-protocol.js +1 -0
- package/dist/elicitation.d.ts +7 -0
- package/dist/elicitation.js +20 -5
- package/dist/env-name-allowlist-knobs.d.ts +12 -2
- package/dist/env-name-allowlist-knobs.js +5 -4
- package/dist/exec-bounds.d.ts +15 -3
- package/dist/exec-bounds.js +4 -0
- package/dist/execution-lane-caps.d.ts +9 -2
- package/dist/execution-lane-caps.js +11 -0
- package/dist/hooks/classic-stations.d.ts +86 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +80 -37
- package/dist/hooks/hook-runner.d.ts +273 -75
- package/dist/hooks/hook-runner.js +293 -317
- package/dist/http/admission.d.ts +8 -2
- package/dist/http/admission.js +103 -59
- package/dist/http/approval-sweeps.js +59 -18
- package/dist/http/checkpoint-ctx.d.ts +36 -18
- package/dist/http/checkpoint-ctx.js +14 -10
- package/dist/http/claimed-run.d.ts +13 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.js +5 -10
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +6 -10
- package/dist/http/durable-run-leg.d.ts +2 -1
- package/dist/http/durable-run-leg.js +5 -3
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/principal-gate.d.ts +23 -6
- package/dist/http/principal-gate.js +24 -5
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +27 -0
- package/dist/http/request-guards.js +24 -3
- package/dist/http/resume-legs.d.ts +25 -0
- package/dist/http/resume-legs.js +48 -26
- package/dist/http/routes/approvals-assistant.js +1 -1
- package/dist/http/routes/capabilities.js +7 -17
- package/dist/http/routes/diagnostics.js +1 -1
- package/dist/http/routes/rules.js +2 -2
- package/dist/http/routes/runs.js +13 -17
- package/dist/http/routes/session-sync.js +4 -2
- package/dist/http/routes/sessions.js +23 -11
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +2 -3
- package/dist/http/routes/tasks.js +34 -19
- package/dist/http/scenario-read-face.d.ts +14 -0
- package/dist/http/scenario-read-face.js +5 -0
- package/dist/http/send.d.ts +13 -1
- package/dist/http/send.js +12 -1
- package/dist/http/server.d.ts +37 -23
- package/dist/http/server.js +30 -4
- package/dist/http/stored-body-replay.d.ts +10 -3
- package/dist/http/stored-body-replay.js +27 -6
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +39 -0
- package/dist/http/wire-types.d.ts +18 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/lane-home-probe.d.ts +43 -0
- package/dist/lane-home-probe.js +35 -0
- package/dist/limit-refusal.d.ts +47 -0
- package/dist/limit-refusal.js +12 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +3 -11
- package/dist/mcp-assertion-header.js +3 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +5 -1
- package/dist/memory-scope.d.ts +1 -1
- package/dist/model-entry-refusal.d.ts +1 -7
- package/dist/model-provider.d.ts +39 -12
- package/dist/model-provider.js +19 -2
- package/dist/model-route-endpoint.d.ts +52 -12
- package/dist/model-route-endpoint.js +48 -26
- package/dist/model-route-gap.d.ts +5 -4
- package/dist/model-route-gap.js +1 -1
- package/dist/model-select.d.ts +58 -0
- package/dist/model-select.js +31 -0
- package/dist/namespaced-rule-name.d.ts +7 -4
- package/dist/namespaced-rule-name.js +4 -3
- package/dist/observability/cost-taxonomy.d.ts +7 -7
- package/dist/observability/fail-open.d.ts +53 -12
- package/dist/observability/fail-open.js +47 -7
- package/dist/observability/metrics.js +3 -1
- package/dist/observability/prompt-manifest.d.ts +47 -82
- package/dist/observability/prompt-manifest.js +119 -17
- package/dist/observability/run-terminal.js +14 -6
- package/dist/observability/secret-env-scrub.d.ts +13 -1
- package/dist/observability/secret-env-scrub.js +13 -1
- package/dist/observability/tool-trace.d.ts +16 -21
- package/dist/observability/tool-trace.js +51 -42
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- package/dist/plugins/blob-backend.d.ts +68 -13
- package/dist/plugins/blob-backend.js +53 -10
- package/dist/plugins/checkpoint-store-sql.d.ts +14 -4
- package/dist/plugins/checkpoint-store-sql.js +39 -26
- package/dist/plugins/k8s-bg-scripts.d.ts +11 -0
- package/dist/plugins/k8s-bg-scripts.js +22 -0
- package/dist/plugins/local-checkpoint-store.js +5 -2
- package/dist/plugins/local-session-store.js +3 -3
- package/dist/plugins/one-time-migrations.d.ts +147 -91
- package/dist/plugins/one-time-migrations.js +372 -208
- package/dist/plugins/permission-rule-store-sql.d.ts +13 -7
- package/dist/plugins/permission-rule-store-sql.js +4 -18
- package/dist/plugins/pg-session-storage.d.ts +4 -5
- package/dist/plugins/pg-session-storage.js +7 -17
- package/dist/plugins/remote-env-adb.d.ts +6 -0
- package/dist/plugins/remote-env-adb.js +9 -4
- package/dist/plugins/remote-env-device.js +3 -0
- package/dist/plugins/remote-env-e2b.d.ts +1 -1
- package/dist/plugins/remote-env-e2b.js +21 -9
- package/dist/plugins/remote-env-host.d.ts +9 -9
- package/dist/plugins/remote-env-host.js +10 -32
- package/dist/plugins/remote-env-k8s.d.ts +95 -26
- package/dist/plugins/remote-env-k8s.js +265 -90
- package/dist/plugins/remote-env-local-docker.d.ts +20 -1
- package/dist/plugins/remote-env-local-docker.js +77 -9
- package/dist/plugins/remote-env-ssh.d.ts +15 -0
- package/dist/plugins/remote-env-ssh.js +109 -3
- package/dist/plugins/remote-shell.d.ts +0 -1
- package/dist/plugins/remote-shell.js +1 -2
- package/dist/plugins/retention-store-sql.js +6 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- package/dist/plugins/session-epoch-anchor.d.ts +13 -0
- package/dist/plugins/session-epoch-anchor.js +23 -0
- package/dist/plugins/shared-memory-store-sql.d.ts +9 -3
- package/dist/plugins/shared-memory-store-sql.js +5 -16
- package/dist/plugins/sql-driver.d.ts +141 -0
- package/dist/plugins/sql-driver.js +115 -1
- package/dist/plugins/sql-errors.d.ts +41 -0
- package/dist/plugins/sql-errors.js +36 -0
- package/dist/plugins/store-backend.js +2 -1
- package/dist/plugins/tidb-session-storage.d.ts +7 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.js +1 -1
- package/dist/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- package/dist/question.d.ts +18 -9
- package/dist/question.js +21 -13
- package/dist/request-key-closure.d.ts +4 -4
- package/dist/request-key-closure.js +18 -13
- package/dist/rule-entry-list.d.ts +134 -24
- package/dist/rule-entry-list.js +162 -30
- package/dist/run-local.d.ts +3 -3
- package/dist/run-local.js +26 -25
- package/dist/runs.d.ts +48 -2
- package/dist/runs.js +61 -2
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- package/dist/session-titler.js +12 -2
- package/dist/spec-fields.d.ts +34 -18
- package/dist/spec-fields.js +46 -53
- package/dist/sql-engine-posture.d.ts +29 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-hooks-m20.d.ts +23 -0
- package/dist/stored-request-hooks-m20.js +124 -0
- package/dist/stored-request-tool-axes-m19.d.ts +20 -5
- package/dist/stored-request-tool-axes-m19.js +30 -2
- package/dist/task-a2a.d.ts +9 -1
- package/dist/task-a2a.js +73 -47
- package/dist/task-mcp.d.ts +54 -102
- package/dist/task-mcp.js +194 -92
- package/dist/task-settings.d.ts +47 -25
- package/dist/task-settings.js +46 -61
- package/dist/text-bidi.d.ts +3 -46
- package/dist/text-bidi.js +3 -3
- package/dist/tool-approval.d.ts +1 -1
- package/dist/trace/core-keyset-guard.d.ts +24 -4
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/ledger-events.d.ts +3 -1
- package/dist/trace/ledger-sink.d.ts +29 -0
- package/dist/trace/ledger-sink.js +15 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +25 -6
- package/dist/trace/project.js +68 -22
- package/dist/trace/wire-projection-faces.d.ts +80 -2
- package/dist/trace/wire-projection-faces.js +23 -1
- package/dist/user-authored-text.d.ts +7 -0
- package/dist/user-authored-text.js +3 -0
- package/dist/web-admin-client/apply-effective.js +10 -5
- package/dist/web-admin-client/candidate-gate.d.ts +6 -6
- package/dist/web-admin-client/candidate-gate.js +3 -3
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-warnings.d.ts +13 -0
- package/dist/web-admin-client/read-warnings.js +10 -0
- package/dist/web-admin-client/skills-mcp.d.ts +3 -0
- package/dist/web-admin-client/skills-mcp.js +9 -6
- package/dist/web-admin-client/types.d.ts +3 -4
- package/dist/workspace-cache.d.ts +35 -0
- package/dist/workspace-cache.js +36 -0
- package/dist/workspace-space.d.ts +3 -2
- package/dist/workspace-space.js +2 -0
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +8 -1
- package/package.json +4 -4
- package/scripts/drain-check-local.mjs +37 -3
- package/scripts/drain-check.mysql.sql +30 -2
- package/scripts/drain-check.pg.sql +29 -2
- package/dist/capabilities/memory-notice.d.ts +0 -138
- package/dist/capabilities/memory-notice.js +0 -64
- package/dist/capabilities/prompt.d.ts +0 -17
- package/dist/capabilities/prompt.js +0 -6
- package/dist/mcp-content-origin.d.ts +0 -34
- package/dist/mcp-content-origin.js +0 -10
- package/dist/tool-axis-words.d.ts +0 -27
- package/dist/tool-axis-words.js +0 -9
- package/dist/wire-name-bound.d.ts +0 -14
- package/dist/wire-name-bound.js +0 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {} from "@sema-agent/core";
|
|
2
2
|
import { outwardPlane } from "../terminal.js";
|
|
3
3
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
4
|
-
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData } from "./project.js";
|
|
4
|
+
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData } from "./project.js";
|
|
5
5
|
import { NotifiedKeys, taskNotificationStreamKeyOf } from "../orchestration/workflow-completion-inbox.js";
|
|
6
6
|
import { isParkLedgerEventType } from "./ledger-events.js";
|
|
7
7
|
import { isModelSegmentBoundary, reasoningDeltaBytes, reasoningSegmentEventId } from "./model-segment.js";
|
|
@@ -17,6 +17,17 @@ export function createSerialLedgerAppend(appendEvent, startSeq) {
|
|
|
17
17
|
export function createForwardAppendFailedNote(type) {
|
|
18
18
|
return (err) => recordFailOpen("server.ledger.forward-append-failed", `type=${type} err=${err instanceof Error ? err.message : String(err)}`);
|
|
19
19
|
}
|
|
20
|
+
export function createLedgerTwinEmit(opts) {
|
|
21
|
+
return async (frame) => {
|
|
22
|
+
if (opts.sink !== undefined) {
|
|
23
|
+
const { type, ...data } = frame;
|
|
24
|
+
await opts.sink.append(type, data);
|
|
25
|
+
if (!opts.liveReachable())
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
opts.writeLive(frame);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
export function createLedgerSink(opts) {
|
|
21
32
|
const keys = opts.notifiedKeys ?? new NotifiedKeys();
|
|
22
33
|
let seq = 0;
|
|
@@ -97,6 +108,9 @@ export function createLedgerSink(opts) {
|
|
|
97
108
|
case "compaction_outcome":
|
|
98
109
|
await append("compaction_outcome", compactionOutcomeEventData(ev));
|
|
99
110
|
break;
|
|
111
|
+
case "compaction_started":
|
|
112
|
+
await append("compaction_started", compactionStartedEventData(ev));
|
|
113
|
+
break;
|
|
100
114
|
case "workspace_changed":
|
|
101
115
|
await append("workspace_changed", workspaceChangedEventData(ev));
|
|
102
116
|
break;
|
|
@@ -2,7 +2,7 @@ import { reasoningEndEventData } from "./project.js";
|
|
|
2
2
|
const BOUNDARY = new Set([
|
|
3
3
|
"tool_start", "tool_end", "status", "context_usage", "compacted", "diagnostics",
|
|
4
4
|
"steering_injected", "compaction_outcome", "workspace_changed", "wiring_manifest",
|
|
5
|
-
"tool_roster_delta", "human_input", "task_notification", "turn_end", "tool_disclosure",
|
|
5
|
+
"tool_roster_delta", "human_input", "task_notification", "turn_end", "tool_disclosure", "compaction_started",
|
|
6
6
|
]);
|
|
7
7
|
export function isModelSegmentBoundary(type) {
|
|
8
8
|
return BOUNDARY.has(type);
|
package/dist/trace/project.d.ts
CHANGED
|
@@ -113,11 +113,7 @@ export type TraceBlock = {
|
|
|
113
113
|
parentToolCallId?: string;
|
|
114
114
|
} | {
|
|
115
115
|
type: "prompt-assembled";
|
|
116
|
-
|
|
117
|
-
totalChars: number;
|
|
118
|
-
blocks: unknown;
|
|
119
|
-
sections?: unknown;
|
|
120
|
-
tools?: unknown;
|
|
116
|
+
readonly [member: string]: unknown;
|
|
121
117
|
};
|
|
122
118
|
/**
|
|
123
119
|
* 🔴 **模型自由文本账本行(`text` / `reasoning`)的唯一载荷铸点**(B-106 / S-268,7.75.1)。
|
|
@@ -543,6 +539,21 @@ export declare function compactionOutcomeEventData(ev: {
|
|
|
543
539
|
outcome?: unknown;
|
|
544
540
|
trigger?: unknown;
|
|
545
541
|
reason?: unknown;
|
|
542
|
+
pass?: unknown;
|
|
543
|
+
eventId?: unknown;
|
|
544
|
+
parentToolCallId?: unknown;
|
|
545
|
+
}): Record<string, unknown>;
|
|
546
|
+
/**
|
|
547
|
+
* `compaction_started`(S-1732,core 7.53.0 #2008)—— 一次压缩 pass 在提交点(触发闸过了、切点在、`preCompact` 没拦)宣告开始,先于摘要调用:
|
|
548
|
+
* 一次在供应方重试表里等很久的摘要(core 实测 503 × 11、173 s)从此在流上不是静默的。**原样投影**:`{ trigger, pass, startedAt }` + 身份两键,
|
|
549
|
+
* 不自铸相位、不铸 run / session id(那是流的,不是帧的键)。三键都是引擎铸的闭形值:`trigger` 闭集词(`auto` / `manual` / `forced`,与结束帧同一张词表)、
|
|
550
|
+
* `pass` 不透明 id(结束这次 pass 的那一帧 —— `compacted` 或 `compaction_outcome` —— 带同一个 `pass`)、`startedAt` 引擎时钟 epoch 毫秒 ⇒ 不脱敏、逐字;
|
|
551
|
+
* 形不合即缺席(与 {@link compactionOutcomeEventData} 同款守卫,不编值)。三条消费腿(live 帧、两条 durable 腿)共用这一只。
|
|
552
|
+
*/
|
|
553
|
+
export declare function compactionStartedEventData(ev: {
|
|
554
|
+
trigger?: unknown;
|
|
555
|
+
pass?: unknown;
|
|
556
|
+
startedAt?: unknown;
|
|
546
557
|
eventId?: unknown;
|
|
547
558
|
parentToolCallId?: unknown;
|
|
548
559
|
}): Record<string, unknown>;
|
|
@@ -806,7 +817,7 @@ export declare function wiringManifestEventData(ev: {
|
|
|
806
817
|
* `core-keyset-guard.ts` ⑥b `WiringSectionExcluded`)。**present-iff 武装**:
|
|
807
818
|
* · 整段缺席 ⇒ **未武装**,不铸键、不计数(正面事实,不是「未知」,更不是 `{onRecommendation:false}`);
|
|
808
819
|
* · 在场且 `onRecommendation === true` ⇒ 逐字铸出(core 的在场形只有这一个,构造期门已拒掉「武装但跑不起来」);
|
|
809
|
-
* · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `
|
|
820
|
+
* · 在场但读不出那个形 ⇒ `dropProjectedFace` 留痕并整段缺席(与 `writeProtection` / `lsp` / `mods` 同一条
|
|
810
821
|
* 族规:「在场但读不出 ⇒ 计一次并丢弃」;**不**自造第三态,词表/形的属主在 core)。
|
|
811
822
|
* 🔴 代价如实登记,与 `writeProtection` 那一格逐字同源:wire 上「读不出」与「真未武装」是**同一个形**,
|
|
812
823
|
* 分得开它们的只有 `server.trace.projection-input-malformed` 这只计数 —— 而这一格比那一格更该说清楚,
|
|
@@ -851,6 +862,11 @@ export declare function wiringManifestFaceEventData(ev: {
|
|
|
851
862
|
* `[from …]` 渲染就是靠它决定加不加 `(unverified)`),剥掉它比剥掉 id 更坏:剩下一个看不出真假的名字。
|
|
852
863
|
* · `principal` —— **刻意不投影**(与 ToolApprovalFrame 的 `principal` 同裁):帧本就经 owner-scoped 流
|
|
853
864
|
* 投递,租户身份不必再由帧自述。要它请先提消费需求,别顺手加。
|
|
865
|
+
* · `attachments[]`(core 7.50.0,只在声明了附件的目标那一帧 `applied` 上)—— 逐成员挑四键:`ordinal`(引擎铸的序号)/
|
|
866
|
+
* `kind`(引擎认出的种类,闭集词;读不出种类时缺席)/ `outcome`(引擎的结局词,闭集)⇒ verbatim;`label` = 调用方**自己声明的**
|
|
867
|
+
* 路径或名字(引擎原样回声,不是解析后的落点 —— 多租户沙箱车道上它是这次 run 自己工作区里的相对 / 绝对路径串,帧上不出现任何别的租户
|
|
868
|
+
* 或宿主盘的信息),与已展示的工具实参 / `workspace_changed.cwd` 同一信任级(UNTRUSTED 的路径串)⇒ 过 `redactSecrets`。长度界由引擎定
|
|
869
|
+
* (`USER_ATTACHMENT_LABEL_MAX`),本仓不另截。非对象的成员丢、集外的成员键不投(同 `actor` 的白名单理由)。
|
|
854
870
|
*
|
|
855
871
|
* `actor` 逐键挑(禁 spread):core 已声明 `ActorAssertion` 是冻结三键形,但白名单的意义正是「core 加第
|
|
856
872
|
* 四键时由人处置」——身份对象上多出来的键裸上线是本文件反复登记的病族。
|
|
@@ -866,6 +882,7 @@ export declare function humanInputEventData(ev: {
|
|
|
866
882
|
actor?: unknown;
|
|
867
883
|
principal?: unknown;
|
|
868
884
|
entryId?: unknown;
|
|
885
|
+
attachments?: unknown;
|
|
869
886
|
eventId?: unknown;
|
|
870
887
|
parentToolCallId?: unknown;
|
|
871
888
|
}): Record<string, unknown>;
|
|
@@ -926,6 +943,8 @@ export declare function compactedEventData(ev: {
|
|
|
926
943
|
persistMs?: number;
|
|
927
944
|
ptlRetries?: number;
|
|
928
945
|
};
|
|
946
|
+
/** S-1732(core 7.53.0 #2008):这次落地的压缩 pass 的 id —— 与它的 `compaction_started` 帧同一个值(引擎在每次落地上都设;型上可选)。逐字。 */
|
|
947
|
+
pass?: string;
|
|
929
948
|
}): Record<string, unknown>;
|
|
930
949
|
export interface TraceTurn {
|
|
931
950
|
/** per-task seq = the turn's terminating event seq (so history-up-to-H splices with stream seq>H). */
|
package/dist/trace/project.js
CHANGED
|
@@ -3,6 +3,7 @@ import { MCP_DELIVERY_VERDICTS, MCP_LIVENESS_STATES, screenGateOutcome, TEAM_ROL
|
|
|
3
3
|
import { Value } from "typebox/value";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
5
|
import { redactSecrets, redactDeep } from "./redact.js";
|
|
6
|
+
import { sanitizeWireText } from "./engine-notice-wire.js";
|
|
6
7
|
import { projectToolOutput, projectToolStructured } from "./tool-output-media.js";
|
|
7
8
|
import { injectionTierOrAbsent } from "./injection-tier.js";
|
|
8
9
|
import { semaProvenanceOrAbsent } from "./sema-provenance.js";
|
|
@@ -380,6 +381,16 @@ export function compactionOutcomeEventData(ev) {
|
|
|
380
381
|
...(s(ev.outcome) !== undefined ? { outcome: s(ev.outcome) } : {}),
|
|
381
382
|
...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
|
|
382
383
|
...(ev.reason !== undefined ? { reason: redactSecrets(String(ev.reason)) } : {}),
|
|
384
|
+
...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
|
|
385
|
+
...identityFields(ev),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
export function compactionStartedEventData(ev) {
|
|
389
|
+
const s = (v) => (typeof v === "string" ? v : undefined);
|
|
390
|
+
return {
|
|
391
|
+
...(s(ev.trigger) !== undefined ? { trigger: s(ev.trigger) } : {}),
|
|
392
|
+
...(s(ev.pass) !== undefined ? { pass: s(ev.pass) } : {}),
|
|
393
|
+
...(typeof ev.startedAt === "number" && Number.isFinite(ev.startedAt) ? { startedAt: ev.startedAt } : {}),
|
|
383
394
|
...identityFields(ev),
|
|
384
395
|
};
|
|
385
396
|
}
|
|
@@ -513,26 +524,55 @@ export function wiringManifestEventData(ev, instructions) {
|
|
|
513
524
|
})();
|
|
514
525
|
const toolsIn = m.tools;
|
|
515
526
|
const tools = toolsIn === undefined ? undefined : Value.Check(ToolRoster, toolsIn) ? toolsIn : (recordFailOpen("server.trace.tool-roster-malformed", "wiring_manifest.tools did not fit core ToolRoster"), undefined);
|
|
516
|
-
const
|
|
517
|
-
const
|
|
518
|
-
|
|
527
|
+
const strList = (v) => (Array.isArray(v) && v.every((x) => typeof x === "string") ? [...v] : undefined);
|
|
528
|
+
const registrantText = (v) => {
|
|
529
|
+
const t = str(v);
|
|
530
|
+
return t === undefined ? undefined : sanitizeWireText(t);
|
|
531
|
+
};
|
|
532
|
+
const modsIn = m.mods;
|
|
533
|
+
const mods = (() => {
|
|
534
|
+
if (modsIn === undefined)
|
|
519
535
|
return undefined;
|
|
520
|
-
if (!Array.isArray(
|
|
521
|
-
return dropProjectedFace("wiring_manifest.
|
|
536
|
+
if (!Array.isArray(modsIn))
|
|
537
|
+
return dropProjectedFace("wiring_manifest.mods is not an array");
|
|
522
538
|
const rows = [];
|
|
523
|
-
for (const raw of
|
|
539
|
+
for (const raw of modsIn) {
|
|
524
540
|
const e = sec(raw);
|
|
525
|
-
|
|
526
|
-
|
|
541
|
+
const name = registrantText(e?.name);
|
|
542
|
+
const seat = str(e?.seat);
|
|
543
|
+
const tier = str(e?.tier);
|
|
544
|
+
if (e === undefined || name === undefined || seat === undefined || tier === undefined) {
|
|
545
|
+
dropProjectedFace("wiring_manifest.mods[] row is missing name/seat/tier");
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
const refusedBy = registrantText(e.refusedBy);
|
|
549
|
+
const reason = registrantText(e.reason);
|
|
550
|
+
if (refusedBy !== undefined && reason !== undefined) {
|
|
551
|
+
rows.push({ name, seat, tier, refusedBy, reason });
|
|
527
552
|
continue;
|
|
528
553
|
}
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
dropProjectedFace("wiring_manifest.hooks[] row is missing family/owner");
|
|
554
|
+
const events = strList(e.events);
|
|
555
|
+
if (events === undefined) {
|
|
556
|
+
dropProjectedFace("wiring_manifest.mods[] row is neither a mounted nor a refused record");
|
|
533
557
|
continue;
|
|
534
558
|
}
|
|
535
|
-
|
|
559
|
+
const observe = e.observe === undefined ? undefined : (strList(e.observe) ?? dropProjectedFace("wiring_manifest.mods[].observe is not a list of strings"));
|
|
560
|
+
const skipped = e.skipped === undefined
|
|
561
|
+
? undefined
|
|
562
|
+
: Array.isArray(e.skipped)
|
|
563
|
+
? e.skipped.flatMap((x) => {
|
|
564
|
+
const k = sec(x);
|
|
565
|
+
const registration = registrantText(k?.registration);
|
|
566
|
+
const cause = registrantText(k?.cause);
|
|
567
|
+
const why = registrantText(k?.reason);
|
|
568
|
+
if (registration === undefined || cause === undefined || why === undefined) {
|
|
569
|
+
dropProjectedFace("wiring_manifest.mods[].skipped[] element is missing registration/cause/reason");
|
|
570
|
+
return [];
|
|
571
|
+
}
|
|
572
|
+
return [{ registration, cause, reason: why }];
|
|
573
|
+
})
|
|
574
|
+
: dropProjectedFace("wiring_manifest.mods[].skipped is not an array");
|
|
575
|
+
rows.push({ name, seat, tier, events, ...(observe !== undefined ? { observe } : {}), ...(skipped !== undefined && skipped.length > 0 ? { skipped } : {}) });
|
|
536
576
|
}
|
|
537
577
|
return rows.length > 0 ? rows : undefined;
|
|
538
578
|
})();
|
|
@@ -606,7 +646,7 @@ export function wiringManifestEventData(ev, instructions) {
|
|
|
606
646
|
...(autoMode !== undefined ? { autoMode } : {}),
|
|
607
647
|
...(tools !== undefined ? { tools } : {}),
|
|
608
648
|
...(mcp !== undefined ? { mcp } : {}),
|
|
609
|
-
...(
|
|
649
|
+
...(mods !== undefined ? { mods } : {}),
|
|
610
650
|
...(lsp !== undefined ? { lsp } : {}),
|
|
611
651
|
...(hands !== undefined ? { hands } : {}),
|
|
612
652
|
...(writeProtection !== undefined ? { writeProtection } : {}),
|
|
@@ -665,6 +705,16 @@ export function wiringManifestFaceEventData(ev, operatorFace, instructions) {
|
|
|
665
705
|
export function humanInputEventData(ev) {
|
|
666
706
|
const str = (v) => (typeof v === "string" && v.length > 0 ? v : undefined);
|
|
667
707
|
const a = typeof ev.actor === "object" && ev.actor !== null && !Array.isArray(ev.actor) ? { ...ev.actor } : {};
|
|
708
|
+
const attachments = Array.isArray(ev.attachments)
|
|
709
|
+
? ev.attachments
|
|
710
|
+
.filter((m) => typeof m === "object" && m !== null && !Array.isArray(m))
|
|
711
|
+
.map((m) => ({
|
|
712
|
+
...(typeof m.ordinal === "number" && Number.isFinite(m.ordinal) ? { ordinal: m.ordinal } : {}),
|
|
713
|
+
...(str(m.kind) !== undefined ? { kind: m.kind } : {}),
|
|
714
|
+
...(str(m.outcome) !== undefined ? { outcome: m.outcome } : {}),
|
|
715
|
+
...(str(m.label) !== undefined ? { label: redactSecrets(String(m.label)) } : {}),
|
|
716
|
+
}))
|
|
717
|
+
: undefined;
|
|
668
718
|
const actor = {
|
|
669
719
|
...(str(a.id) !== undefined ? { id: redactSecrets(String(a.id)) } : {}),
|
|
670
720
|
...(typeof a.hostAsserted === "boolean" ? { hostAsserted: a.hostAsserted } : {}),
|
|
@@ -679,6 +729,7 @@ export function humanInputEventData(ev) {
|
|
|
679
729
|
...(str(ev.issuer) !== undefined ? { issuer: redactSecrets(String(ev.issuer)) } : {}),
|
|
680
730
|
...(Object.keys(actor).length > 0 ? { actor } : {}),
|
|
681
731
|
...(str(ev.entryId) !== undefined ? { entryId: ev.entryId } : {}),
|
|
732
|
+
...(attachments !== undefined ? { attachments } : {}),
|
|
682
733
|
...identityFields(ev),
|
|
683
734
|
};
|
|
684
735
|
}
|
|
@@ -747,6 +798,7 @@ export function compactedEventData(ev) {
|
|
|
747
798
|
})(),
|
|
748
799
|
...(num(ev.durationMs) !== undefined ? { durationMs: num(ev.durationMs) } : {}),
|
|
749
800
|
...(phaseDurations !== undefined ? { phaseDurations } : {}),
|
|
801
|
+
...(typeof ev.pass === "string" ? { pass: ev.pass } : {}),
|
|
750
802
|
};
|
|
751
803
|
}
|
|
752
804
|
export function contextUsageEventData(ev) {
|
|
@@ -869,14 +921,7 @@ export function projectEvents(events, opts = {}) {
|
|
|
869
921
|
}
|
|
870
922
|
case "prompt_assembled":
|
|
871
923
|
firstTs ??= ev.ts;
|
|
872
|
-
blocks.push({
|
|
873
|
-
type: "prompt-assembled",
|
|
874
|
-
constitution: String(d.constitution ?? ""),
|
|
875
|
-
totalChars: Number(d.totalChars ?? 0),
|
|
876
|
-
blocks: d.blocks,
|
|
877
|
-
...(d.sections !== undefined ? { sections: d.sections } : {}),
|
|
878
|
-
...(d.tools !== undefined ? { tools: d.tools } : {}),
|
|
879
|
-
});
|
|
924
|
+
blocks.push({ ...d, type: "prompt-assembled" });
|
|
880
925
|
break;
|
|
881
926
|
case "turn_end":
|
|
882
927
|
flushTurn(ev.seq, ev.ts, toContractTokens(d.usage, d.usageMissing));
|
|
@@ -955,6 +1000,7 @@ function mapTraceEventInner(type, seq, data) {
|
|
|
955
1000
|
return { event: "error", data: { type: "error", errorCode: "WORKER_DOWN", message: redactErrorMessage(String(data.errorMessage ?? "run failed")) ?? "run failed" } };
|
|
956
1001
|
case "context_usage":
|
|
957
1002
|
case "compaction_outcome":
|
|
1003
|
+
case "compaction_started":
|
|
958
1004
|
case "wiring_manifest":
|
|
959
1005
|
case "human_input":
|
|
960
1006
|
case "tool_roster_delta":
|
|
@@ -54,7 +54,7 @@ export interface WireProjectionFace {
|
|
|
54
54
|
*/
|
|
55
55
|
export declare const FRAME_ENVELOPE_KEYS: readonly ["type", "sourceTaskId", "bgAgentId"];
|
|
56
56
|
/** 探针文件要从 `@sema-agent/core` 具名导入的类型(`coreType` 表达式里用到的全部名字)。 */
|
|
57
|
-
export declare const WIRE_PROJECTION_CORE_IMPORTS: readonly ["TaskEvent", "TaskNotificationPayload", "WiringManifest", "EngineNotice", "MemoryImportReport", "OriginClearanceRow", "OriginClearanceEvent", "MemoryEntryOrigin"];
|
|
57
|
+
export declare const WIRE_PROJECTION_CORE_IMPORTS: readonly ["TaskEvent", "TaskNotificationPayload", "WiringManifest", "EngineNotice", "MemoryImportReport", "OriginClearanceRow", "OriginClearanceEvent", "MemoryEntryOrigin", "TraceEvent", "PromptManifestIdentity", "PromptIdentityLayers", "PromptManifestSelectors", "PromptManifestSection", "PromptChainLink", "SupersededOverlay", "ToolDisclosureManifest"];
|
|
58
58
|
/**
|
|
59
59
|
* `wiring_manifest` 的 **operator 面多投的那几段**(`wiringManifestOperatorEventData` 在租户形之上加的段)。
|
|
60
60
|
* operator 行的 `excluded` = 租户行减本常量(派生);四段各自的受众裁定在 `core-keyset-guard.ts` ⑥b。
|
|
@@ -158,10 +158,16 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
158
158
|
readonly excluded: readonly [];
|
|
159
159
|
readonly minted: readonly [];
|
|
160
160
|
};
|
|
161
|
+
readonly compaction_started: {
|
|
162
|
+
readonly projector: "compactionStartedEventData";
|
|
163
|
+
readonly coreType: string;
|
|
164
|
+
readonly excluded: readonly [];
|
|
165
|
+
readonly minted: readonly [];
|
|
166
|
+
};
|
|
161
167
|
readonly human_input: {
|
|
162
168
|
readonly projector: "humanInputEventData";
|
|
163
169
|
readonly coreType: string;
|
|
164
|
-
readonly excluded: readonly ["principal"
|
|
170
|
+
readonly excluded: readonly ["principal"];
|
|
165
171
|
readonly minted: readonly [];
|
|
166
172
|
};
|
|
167
173
|
readonly task_notification: {
|
|
@@ -216,6 +222,78 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
216
222
|
readonly excluded: readonly [];
|
|
217
223
|
readonly minted: readonly [];
|
|
218
224
|
};
|
|
225
|
+
readonly prompt_manifest: {
|
|
226
|
+
readonly projector: "promptManifestRecordOf";
|
|
227
|
+
readonly coreType: "Extract<TraceEvent, { kind: \"prompt.assembled\" }>";
|
|
228
|
+
readonly excluded: readonly ["kind", "version", "taskId", "snapshot", "lowering", "ts"];
|
|
229
|
+
readonly minted: readonly [];
|
|
230
|
+
};
|
|
231
|
+
readonly prompt_manifest_identity: {
|
|
232
|
+
readonly projector: "promptManifestRecordOf";
|
|
233
|
+
readonly coreType: "PromptManifestIdentity";
|
|
234
|
+
readonly excluded: readonly [];
|
|
235
|
+
readonly minted: readonly [];
|
|
236
|
+
};
|
|
237
|
+
readonly prompt_manifest_identity_layers: {
|
|
238
|
+
readonly projector: "promptManifestRecordOf";
|
|
239
|
+
readonly coreType: "PromptIdentityLayers";
|
|
240
|
+
readonly excluded: readonly [];
|
|
241
|
+
readonly minted: readonly [];
|
|
242
|
+
};
|
|
243
|
+
readonly prompt_manifest_selectors: {
|
|
244
|
+
readonly projector: "promptManifestRecordOf";
|
|
245
|
+
readonly coreType: "PromptManifestSelectors";
|
|
246
|
+
readonly excluded: readonly [];
|
|
247
|
+
readonly minted: readonly [];
|
|
248
|
+
};
|
|
249
|
+
readonly prompt_manifest_selectors_host: {
|
|
250
|
+
readonly projector: "promptManifestRecordOf";
|
|
251
|
+
readonly coreType: "PromptManifestSelectors[\"host\"]";
|
|
252
|
+
readonly excluded: readonly [];
|
|
253
|
+
readonly minted: readonly [];
|
|
254
|
+
};
|
|
255
|
+
readonly prompt_manifest_block: {
|
|
256
|
+
readonly projector: "promptManifestRecordOf";
|
|
257
|
+
readonly coreType: "Extract<TraceEvent, { kind: \"prompt.assembled\" }>[\"blocks\"][number]";
|
|
258
|
+
readonly excluded: readonly [];
|
|
259
|
+
readonly minted: readonly [];
|
|
260
|
+
};
|
|
261
|
+
readonly prompt_manifest_section: {
|
|
262
|
+
readonly projector: "promptManifestRecordOf";
|
|
263
|
+
readonly coreType: "PromptManifestSection";
|
|
264
|
+
readonly excluded: readonly [];
|
|
265
|
+
readonly minted: readonly [];
|
|
266
|
+
};
|
|
267
|
+
readonly prompt_manifest_section_renderer: {
|
|
268
|
+
readonly projector: "promptManifestRecordOf";
|
|
269
|
+
readonly coreType: "NonNullable<PromptManifestSection[\"renderer\"]>";
|
|
270
|
+
readonly excluded: readonly [];
|
|
271
|
+
readonly minted: readonly [];
|
|
272
|
+
};
|
|
273
|
+
readonly prompt_manifest_chain_link: {
|
|
274
|
+
readonly projector: "promptManifestRecordOf";
|
|
275
|
+
readonly coreType: "PromptChainLink";
|
|
276
|
+
readonly excluded: readonly [];
|
|
277
|
+
readonly minted: readonly [];
|
|
278
|
+
};
|
|
279
|
+
readonly prompt_manifest_superseded: {
|
|
280
|
+
readonly projector: "promptManifestRecordOf";
|
|
281
|
+
readonly coreType: "SupersededOverlay";
|
|
282
|
+
readonly excluded: readonly [];
|
|
283
|
+
readonly minted: readonly [];
|
|
284
|
+
};
|
|
285
|
+
readonly prompt_manifest_tool: {
|
|
286
|
+
readonly projector: "promptManifestRecordOf";
|
|
287
|
+
readonly coreType: "NonNullable<Extract<TraceEvent, { kind: \"prompt.assembled\" }>[\"tools\"]>[number]";
|
|
288
|
+
readonly excluded: readonly [];
|
|
289
|
+
readonly minted: readonly [];
|
|
290
|
+
};
|
|
291
|
+
readonly prompt_manifest_tool_disclosure: {
|
|
292
|
+
readonly projector: "promptManifestRecordOf";
|
|
293
|
+
readonly coreType: "ToolDisclosureManifest";
|
|
294
|
+
readonly excluded: readonly [];
|
|
295
|
+
readonly minted: readonly [];
|
|
296
|
+
};
|
|
219
297
|
};
|
|
220
298
|
/** 面名。 */
|
|
221
299
|
export type WireProjectionFaceName = keyof typeof WIRE_PROJECTION_FACES;
|
|
@@ -8,8 +8,17 @@ export const WIRE_PROJECTION_CORE_IMPORTS = [
|
|
|
8
8
|
"OriginClearanceRow",
|
|
9
9
|
"OriginClearanceEvent",
|
|
10
10
|
"MemoryEntryOrigin",
|
|
11
|
+
"TraceEvent",
|
|
12
|
+
"PromptManifestIdentity",
|
|
13
|
+
"PromptIdentityLayers",
|
|
14
|
+
"PromptManifestSelectors",
|
|
15
|
+
"PromptManifestSection",
|
|
16
|
+
"PromptChainLink",
|
|
17
|
+
"SupersededOverlay",
|
|
18
|
+
"ToolDisclosureManifest",
|
|
11
19
|
];
|
|
12
20
|
const arm = (name) => `Extract<TaskEvent, { type: "${name}" }>`;
|
|
21
|
+
const MANIFEST_FRAME = `Extract<TraceEvent, { kind: "prompt.assembled" }>`;
|
|
13
22
|
export const WIRING_MANIFEST_OPERATOR_ONLY_SECTIONS = ["governance", "configFingerprint", "autoConsolidation", "readDeny"];
|
|
14
23
|
function withoutSections(all, drop) {
|
|
15
24
|
return all.filter((k) => !drop.includes(k));
|
|
@@ -30,7 +39,8 @@ export const WIRE_PROJECTION_FACES = {
|
|
|
30
39
|
context_usage: { projector: "contextUsageEventData", coreType: arm("context_usage"), excluded: [], minted: [] },
|
|
31
40
|
turn_end: { projector: "turnEndEventData", coreType: arm("turn_end"), excluded: [], minted: [] },
|
|
32
41
|
compaction_outcome: { projector: "compactionOutcomeEventData", coreType: arm("compaction_outcome"), excluded: [], minted: [] },
|
|
33
|
-
|
|
42
|
+
compaction_started: { projector: "compactionStartedEventData", coreType: arm("compaction_started"), excluded: [], minted: [] },
|
|
43
|
+
human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal"], minted: [] },
|
|
34
44
|
task_notification: {
|
|
35
45
|
projector: "taskNotificationEventData",
|
|
36
46
|
coreType: `TaskNotificationPayload & ${arm("task_notification")}`,
|
|
@@ -67,5 +77,17 @@ export const WIRE_PROJECTION_FACES = {
|
|
|
67
77
|
},
|
|
68
78
|
origin_clearance_origin: { projector: "buildClearanceRowWire", coreType: "MemoryEntryOrigin", excluded: [], minted: [] },
|
|
69
79
|
origin_clearance_event: { projector: "buildClearanceRowWire", coreType: "OriginClearanceEvent", excluded: [], minted: [] },
|
|
80
|
+
prompt_manifest: { projector: "promptManifestRecordOf", coreType: MANIFEST_FRAME, excluded: ["kind", "version", "taskId", "snapshot", "lowering", "ts"], minted: [] },
|
|
81
|
+
prompt_manifest_identity: { projector: "promptManifestRecordOf", coreType: "PromptManifestIdentity", excluded: [], minted: [] },
|
|
82
|
+
prompt_manifest_identity_layers: { projector: "promptManifestRecordOf", coreType: "PromptIdentityLayers", excluded: [], minted: [] },
|
|
83
|
+
prompt_manifest_selectors: { projector: "promptManifestRecordOf", coreType: "PromptManifestSelectors", excluded: [], minted: [] },
|
|
84
|
+
prompt_manifest_selectors_host: { projector: "promptManifestRecordOf", coreType: `PromptManifestSelectors["host"]`, excluded: [], minted: [] },
|
|
85
|
+
prompt_manifest_block: { projector: "promptManifestRecordOf", coreType: `${MANIFEST_FRAME}["blocks"][number]`, excluded: [], minted: [] },
|
|
86
|
+
prompt_manifest_section: { projector: "promptManifestRecordOf", coreType: "PromptManifestSection", excluded: [], minted: [] },
|
|
87
|
+
prompt_manifest_section_renderer: { projector: "promptManifestRecordOf", coreType: `NonNullable<PromptManifestSection["renderer"]>`, excluded: [], minted: [] },
|
|
88
|
+
prompt_manifest_chain_link: { projector: "promptManifestRecordOf", coreType: "PromptChainLink", excluded: [], minted: [] },
|
|
89
|
+
prompt_manifest_superseded: { projector: "promptManifestRecordOf", coreType: "SupersededOverlay", excluded: [], minted: [] },
|
|
90
|
+
prompt_manifest_tool: { projector: "promptManifestRecordOf", coreType: `NonNullable<${MANIFEST_FRAME}["tools"]>[number]`, excluded: [], minted: [] },
|
|
91
|
+
prompt_manifest_tool_disclosure: { projector: "promptManifestRecordOf", coreType: "ToolDisclosureManifest", excluded: [], minted: [] },
|
|
70
92
|
};
|
|
71
93
|
//# sourceMappingURL=wire-projection-faces.js.map
|
|
@@ -28,4 +28,11 @@ export declare function buildObjectivePreview(text: string, chars: number): stri
|
|
|
28
28
|
export declare const RUN_OBJECTIVE_PREVIEW_CHARS = 120;
|
|
29
29
|
/** run 行的预览:用户写的那段 → 脱敏 → 截 {@link RUN_OBJECTIVE_PREVIEW_CHARS};没有用户正文 ⇒ `""`(列写空串 = 有记录、剥空)。 */
|
|
30
30
|
export declare function buildRunObjectivePreview(objective: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* 这条消息是不是**附件帧**(core 7.50.0 请求层附件:目标声明的每只文件由引擎铸成一条自己的 user 消息,紧跟目标提交)。
|
|
33
|
+
* 判据 = 引擎写在消息上的送达记录 `attachment` **在场**(core:那只记录是「这条消息是附件帧」的唯一来源,文本从不判)。坏形记录同样算在场 ——
|
|
34
|
+
* 两个读者都往「不是人写的话」那一侧落(预览走下一条;会话视图按文件字节脱敏),那是安全的一侧。
|
|
35
|
+
* 一个事实一个读法:会话视图的处置表(`audit.ts`)与本地会话列表的预览(`plugins/local-session-store.ts`)同调这一只。
|
|
36
|
+
*/
|
|
37
|
+
export declare function isAttachmentFrame(message: unknown): boolean;
|
|
31
38
|
//# sourceMappingURL=user-authored-text.d.ts.map
|
|
@@ -15,4 +15,7 @@ export const RUN_OBJECTIVE_PREVIEW_CHARS = 120;
|
|
|
15
15
|
export function buildRunObjectivePreview(objective) {
|
|
16
16
|
return buildObjectivePreview(objective, RUN_OBJECTIVE_PREVIEW_CHARS);
|
|
17
17
|
}
|
|
18
|
+
export function isAttachmentFrame(message) {
|
|
19
|
+
return typeof message === "object" && message !== null && Object.hasOwn(message, "attachment");
|
|
20
|
+
}
|
|
18
21
|
//# sourceMappingURL=user-authored-text.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expandTiers, resolveTaskModel as coreResolveTaskModel } from "@sema-agent/core";
|
|
2
2
|
import { WEB_ADMIN_ENV, narrowAtMention, resolveActiveTiers, resolveCatalogDefaultModel } from "@sema-agent/settings-schema";
|
|
3
3
|
import { modelKeyPoison } from "../key-resolver.js";
|
|
4
|
-
import { readAtMention } from "../model-select.js";
|
|
4
|
+
import { buildEnvModelIdNotServedNotice, mintCapabilityKeys, readAtMention, servedModelTableLeg } from "../model-select.js";
|
|
5
5
|
import { applyAutoCompactWindow, buildModelCostKey, parseAutonomy, unmatchableToolNamesRefusal } from "../config.js";
|
|
6
6
|
import { buildModelCompat, readModelCompat } from "../model-compat.js";
|
|
7
7
|
import { buildModelHeadersKey } from "../model-entry-headers.js";
|
|
@@ -40,8 +40,7 @@ function toModel(m, envDefaults = {}, logger) {
|
|
|
40
40
|
provider: m.provider,
|
|
41
41
|
api: m.api,
|
|
42
42
|
baseUrl: m.baseUrl ?? "",
|
|
43
|
-
reasoning: m.reasoning
|
|
44
|
-
input: m.vision ? ["text", "image"] : ["text"],
|
|
43
|
+
...mintCapabilityKeys({ reasoning: m.reasoning, vision: m.vision }),
|
|
45
44
|
contextWindow: m.contextWindow ?? envDefaults.contextWindow ?? 262144,
|
|
46
45
|
maxTokens: m.maxTokens ?? envDefaults.maxTokens ?? 4096,
|
|
47
46
|
...(charsPerTokenOf(m.charsPerToken) !== undefined || envDefaults.charsPerToken !== undefined
|
|
@@ -115,6 +114,7 @@ export function applyEffective(config, eff, logger, opts) {
|
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
}
|
|
117
|
+
const servedBefore = servedModelTableLeg(config);
|
|
118
118
|
commitStaged(config, staged);
|
|
119
119
|
if (ordered)
|
|
120
120
|
appliedGeneration.set(config, gen);
|
|
@@ -138,6 +138,11 @@ export function applyEffective(config, eff, logger, opts) {
|
|
|
138
138
|
logger?.info("web_admin_limits", { version: staged.version, keys: staged.limits.changed });
|
|
139
139
|
if (mp)
|
|
140
140
|
logger?.info("web_admin_models", mp.infoLine);
|
|
141
|
+
if (servedBefore === "env") {
|
|
142
|
+
const notServed = buildEnvModelIdNotServedNotice(config);
|
|
143
|
+
if (notServed !== undefined)
|
|
144
|
+
logger?.warn(notServed.event, notServed.fields);
|
|
145
|
+
}
|
|
141
146
|
if (staged.approvalGate.next !== undefined)
|
|
142
147
|
logger?.info("web_admin_runtime", { version: staged.version, approvalRequire: staged.approvalGate.next });
|
|
143
148
|
if (Object.keys(staged.hot.infoLine).length > 0)
|
|
@@ -248,7 +253,7 @@ function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
|
248
253
|
const modelApiKeyEnv = {};
|
|
249
254
|
const modelApiKeys = {};
|
|
250
255
|
const envModel = envDerivedModel(config);
|
|
251
|
-
const envDefaults = { maxTokens: envModel.maxTokens, contextWindow: envModel.contextWindow,
|
|
256
|
+
const envDefaults = { maxTokens: envModel.maxTokens, contextWindow: envModel.contextWindow, charsPerToken: envModel.charsPerToken, defaultThinking: envModel.defaultThinking, compat: envModel.compat };
|
|
252
257
|
for (const m of usable) {
|
|
253
258
|
if (m.baseUrl)
|
|
254
259
|
logger?.warn("web_admin_model_base_url", { model: m.name, baseUrl: buildDisplaySafeUrl(m.baseUrl), hint: "registry-directed gateway override — this model's key authenticates AGAINST THIS URL" });
|
|
@@ -343,7 +348,7 @@ function stageModelPlane(config, eff, logger, sealedKeys) {
|
|
|
343
348
|
const noDefault = crossInvariant("default-model-resolvable").check({ live: config, next: nextView });
|
|
344
349
|
if (noDefault !== undefined)
|
|
345
350
|
return refuse(DEFAULT_MODEL_MISSING_CODE, noDefault);
|
|
346
|
-
const endpoint = judgeModelRouteEndpoint(nextView);
|
|
351
|
+
const endpoint = judgeModelRouteEndpoint(nextView, "catalog");
|
|
347
352
|
if (endpoint !== undefined)
|
|
348
353
|
return refuse(endpoint.code, endpoint.reason);
|
|
349
354
|
const minted = crossInvariant("refused-names-not-minted").check({ live: config, next: nextView });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 配置候选的**唯一判官**:一份候选(中心有效视图,或本地 `config.d` 读出的那份)能不能收 —— 只有这一种判法。
|
|
3
3
|
*
|
|
4
4
|
* 判据(三件,任一即拒;每条拒因带成因词,闭集 {@link CandidateRejectReason}):读腿交出的 `domainErrors`(某个域读不懂 / 拼错键 / 坏文件:那个域已落
|
|
5
|
-
* schema 缺省)与 prompts
|
|
5
|
+
* schema 缺省)与 prompts 面的判官(`judgePromptsWire`:契约包的 wire 形再交引擎 verify —— 中心层只有一种形)—— 成因 `domain_invalid`;读腿交出的
|
|
6
6
|
* `retiredDomains`(带事实的退役域文档,契约包的墓碑;拒句点名退役版本与一次性迁移)—— 成因 `retired_domain`。任一 ⇒ `rejected`:
|
|
7
7
|
* **整份候选不收**,一个域都不应用。退役域此前在读腿整包抛、走「源不可达」那条臂(版本读不到、没有拒判行、刷新拍算失败);现在读腿只交数据,
|
|
8
8
|
* 坏候选只有本判官一种判法。
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
* `domains` 排序去重:收集器的顺序没有承诺,它是拒行去重键的一部分(同一份候选、同一组坏域只响一次)。`errors` 原样逐条
|
|
23
23
|
* (读腿的诊断在前、prompts 在后)—— 那是可操作的诊断,不是键。纯函数:不改入参,不读环境。
|
|
24
24
|
*
|
|
25
|
-
* **判官交值**:`clean` 判决带着 prompts
|
|
26
|
-
* 迟到起服 / LKG 起服 / `run-local`)直接用这一份值,不再自己判第二遍 —— `
|
|
25
|
+
* **判官交值**:`clean` 判决带着 prompts 面的判官结论(`prompts` = 引擎 verify 过的发布形 artifact;候选不带 prompts 键 ⇒ `undefined`)。采纳 prompts 的各处
|
|
26
|
+
* (起服 / 刷新 / 迟到起服 / LKG 起服 / `run-local`)直接用这一份值,不再自己判第二遍 —— `judgePromptsWire` 在 src 里只有本判官一个调用点
|
|
27
27
|
* (盘上 LKG 的读回复判也经本判官,`config-lkg.ts`)。
|
|
28
28
|
*/
|
|
29
|
-
import {
|
|
29
|
+
import type { PublishedPromptArtifact } from "@sema-agent/core";
|
|
30
30
|
import type { EffectiveConfig } from "./types.js";
|
|
31
31
|
/** 读腿交出的一条域级诊断(与 `FetchEffectiveResult.domainErrors` 同形;error 文案已在产出边界脱敏)。 */
|
|
32
32
|
export interface CandidateDomainError {
|
|
@@ -46,10 +46,10 @@ export interface ConfigCandidateRead {
|
|
|
46
46
|
readonly retiredDomains?: readonly CandidateDomainError[];
|
|
47
47
|
}
|
|
48
48
|
export type ConfigCandidateVerdict =
|
|
49
|
-
/** `prompts` =
|
|
49
|
+
/** `prompts` = 候选的中心层(引擎 verify 过的发布形 artifact;候选不带 prompts 键 ⇒ `undefined` = 撤下中心层、内置提示词服务)。 */
|
|
50
50
|
{
|
|
51
51
|
readonly verdict: "clean";
|
|
52
|
-
readonly prompts:
|
|
52
|
+
readonly prompts: PublishedPromptArtifact | undefined;
|
|
53
53
|
} | {
|
|
54
54
|
readonly verdict: "rejected";
|
|
55
55
|
readonly domains: readonly string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { judgePromptsWire } from "../prompts-domain-validate.js";
|
|
2
2
|
export function judgeConfigCandidate(r) {
|
|
3
3
|
const prompts = r.effective.prompts;
|
|
4
|
-
const promptsGate = prompts === undefined ? undefined :
|
|
4
|
+
const promptsGate = prompts === undefined ? undefined : judgePromptsWire(prompts);
|
|
5
5
|
const errors = [
|
|
6
6
|
...(r.domainErrors ?? []).map((de) => ({ domain: de.domain, error: de.error, reason: "domain_invalid" })),
|
|
7
7
|
...(promptsGate !== undefined && !promptsGate.ok ? [{ domain: "prompts", error: promptsGate.error, reason: "domain_invalid" }] : []),
|
|
8
8
|
...(r.retiredDomains ?? []).map((rd) => ({ domain: rd.domain, error: rd.error, reason: "retired_domain" })),
|
|
9
9
|
];
|
|
10
10
|
if (errors.length === 0)
|
|
11
|
-
return { verdict: "clean", prompts: promptsGate?.ok ? promptsGate.
|
|
11
|
+
return { verdict: "clean", prompts: promptsGate?.ok ? promptsGate.artifact : undefined };
|
|
12
12
|
return { verdict: "rejected", domains: [...new Set(errors.map((e) => e.domain))].sort(), errors };
|
|
13
13
|
}
|
|
14
14
|
export function buildCandidateRejectedFields(r, verdict, leg, ctx) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readEffectiveWire, PrincipalCapsWire } from "@sema-agent/settings-schema";
|
|
3
|
-
import { centerPromptsFromEffective } from "../prompts-domain-validate.js";
|
|
4
3
|
import { separateRetiredDomains, splitFoldedReadWarnings, withDroppedCatalogEntries } from "./read-warnings.js";
|
|
5
4
|
import { CENTER_PULL_TIMEOUT_MS, centerFetch } from "./center-request.js";
|
|
6
5
|
import { answerStillCurrent } from "../center-credential.js";
|
|
@@ -13,11 +12,6 @@ export async function fetchEffective(center, etag, fetchImpl = fetch, worker) {
|
|
|
13
12
|
const warnings = [];
|
|
14
13
|
const { body, retiredDomains } = separateRetiredDomains(await res.json());
|
|
15
14
|
const wire = readEffectiveWire(body, (w) => warnings.push(w));
|
|
16
|
-
const centerPrompts = centerPromptsFromEffective(wire);
|
|
17
|
-
if (centerPrompts === undefined)
|
|
18
|
-
delete wire.prompts;
|
|
19
|
-
else
|
|
20
|
-
wire.prompts = centerPrompts;
|
|
21
15
|
const { domainErrors, droppedEntries, droppedCatalogEntries, unreadFiles } = splitFoldedReadWarnings(warnings, "center");
|
|
22
16
|
const effective = withDroppedCatalogEntries(wire, droppedCatalogEntries);
|
|
23
17
|
return {
|
|
@@ -70,6 +70,19 @@ export type UnreadConfigFile = {
|
|
|
70
70
|
readonly why: "not-a-domain" | "non-portable-domain";
|
|
71
71
|
readonly domain?: string;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* `config.d` 里一份**被读**的文件中、本地读腿结构上**不读**的一键(本服务铸,不是契约告警):今天只有 `prompts.json` 的 `workers` —— 本地腿没有
|
|
75
|
+
* worker 身份,中心层的唯一选择读法(`promptArtifactFor`)对它恒以 `null` 读,只交 `artifact`。写了不生效要响:调用方在采纳路径上一键一行 `config_unread_key`
|
|
76
|
+
* (与 `config_unread_file` 同频:起服与之后每次采纳一份变了的候选),不判拒。
|
|
77
|
+
*/
|
|
78
|
+
export type UnreadConfigKey = {
|
|
79
|
+
readonly file: string;
|
|
80
|
+
readonly domain: string;
|
|
81
|
+
readonly key: string;
|
|
82
|
+
readonly names: readonly string[];
|
|
83
|
+
};
|
|
84
|
+
/** `config_unread_key` 一行的体(纯数据;起服 / 刷新 / 迟到起服与 `run-local` 同一体):`dir` = 本地读腿的配置根。 */
|
|
85
|
+
export declare function buildUnreadConfigKeyFields(k: UnreadConfigKey, dir: string | undefined): Record<string, unknown>;
|
|
73
86
|
/** `config_unread_file` 一行的体(纯数据;起服 / 刷新 / 迟到起服与 `run-local` 同一体):`dir` = 本地读腿的配置根。 */
|
|
74
87
|
export declare function buildUnreadConfigFileFields(f: UnreadConfigFile, dir: string | undefined): Record<string, unknown>;
|
|
75
88
|
/** 逐条丢弃面的一行(两条读腿的 `droppedEntries` 同形,`config_entry_dropped` 日志行读它):`entry` = 被丢那条的出门形坐标(`models.1`),
|
|
@@ -22,6 +22,16 @@ export function separateRetiredDomains(body) {
|
|
|
22
22
|
}
|
|
23
23
|
return findings.length === 0 ? { body, retiredDomains: [] } : { body: rest, retiredDomains: findings };
|
|
24
24
|
}
|
|
25
|
+
export function buildUnreadConfigKeyFields(k, dir) {
|
|
26
|
+
return {
|
|
27
|
+
...(dir !== undefined ? { dir } : {}),
|
|
28
|
+
file: k.file,
|
|
29
|
+
domain: k.domain,
|
|
30
|
+
key: k.key,
|
|
31
|
+
names: k.names,
|
|
32
|
+
note: "the local config read has no worker identity, so this key is never read — prompts.json `workers` entries are not delivered, only `artifact` is; put the artifact this engine should run under `artifact` (or remove the key if it is meant for the center)",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
25
35
|
export function buildUnreadConfigFileFields(f, dir) {
|
|
26
36
|
return {
|
|
27
37
|
...(dir !== undefined ? { dir } : {}),
|