@sema-agent/server 7.141.0 → 7.143.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 +657 -0
- package/USAGE.md +102 -30
- package/dist/adoption/plan.js +22 -0
- package/dist/approval-ask-audit-store.d.ts +61 -43
- package/dist/approval-ask-audit-store.js +69 -44
- package/dist/approval-ask-machine.d.ts +15 -7
- package/dist/approval-ask-machine.js +10 -4
- package/dist/approval-card.d.ts +126 -27
- package/dist/approval-card.js +103 -23
- package/dist/approval-crash-convergence.d.ts +17 -7
- package/dist/approval-crash-convergence.js +94 -22
- package/dist/approval-deny-reasons.d.ts +34 -30
- package/dist/approval-deny-reasons.js +21 -6
- package/dist/approval-policy-settlement.d.ts +1 -1
- package/dist/approval-queue-kind.d.ts +27 -0
- package/dist/approval-queue-kind.js +6 -0
- package/dist/approval-reconciler.d.ts +41 -9
- package/dist/approval-reconciler.js +45 -42
- package/dist/audit.js +4 -2
- package/dist/auth-bridge.d.ts +9 -6
- package/dist/auth-bridge.js +9 -3
- package/dist/boot/adoption.js +2 -1
- package/dist/boot/budget-tracing.d.ts +17 -1
- package/dist/boot/budget-tracing.js +10 -6
- package/dist/boot/device-lane.d.ts +1 -1
- package/dist/boot/execution-env.d.ts +24 -4
- package/dist/boot/execution-env.js +26 -23
- package/dist/boot/execution-lane.js +2 -1
- package/dist/boot/exit-boundary.js +5 -4
- package/dist/boot/governance-seams.d.ts +26 -41
- package/dist/boot/governance-seams.js +61 -28
- package/dist/boot/late-binds.d.ts +7 -4
- package/dist/boot/late-binds.js +3 -1
- package/dist/boot/leader.js +2 -4
- package/dist/boot/memory-consolidation.d.ts +0 -8
- package/dist/boot/memory-consolidation.js +5 -4
- package/dist/boot/parked-revive-gate.js +2 -1
- package/dist/boot/permission-rules-audit.d.ts +0 -28
- package/dist/boot/permission-rules-audit.js +2 -1
- package/dist/boot/read-deny-anchor-audit.js +2 -1
- package/dist/boot/reapers.js +9 -7
- package/dist/boot/resolve-spec.d.ts +1 -1
- package/dist/boot/resolve-spec.js +19 -10
- package/dist/boot/retention-lane.js +5 -3
- package/dist/boot/runner-deps.d.ts +10 -7
- package/dist/boot/runner-deps.js +20 -29
- package/dist/boot/runtime-caps.js +3 -2
- package/dist/boot/session-faces.js +4 -3
- package/dist/boot/shutdown.d.ts +9 -0
- package/dist/boot/shutdown.js +19 -4
- package/dist/boot/stage-02-web-admin-pull.js +3 -0
- package/dist/boot/stage-03-store-backend.d.ts +4 -1
- package/dist/boot/stage-03-store-backend.js +1 -2
- package/dist/boot/stage-04-stores.d.ts +5 -2
- package/dist/boot/stage-04-stores.js +6 -7
- package/dist/boot/stage-05-execution-env.d.ts +6 -3
- package/dist/boot/stage-05-execution-env.js +8 -6
- package/dist/boot/stage-06-runners.d.ts +6 -3
- package/dist/boot/stage-06-runners.js +3 -4
- package/dist/boot/stage-07-capability-layer.d.ts +6 -3
- package/dist/boot/stage-07-capability-layer.js +7 -2
- package/dist/boot/stage-08-reapers.d.ts +6 -3
- package/dist/boot/stage-08-reapers.js +3 -2
- package/dist/boot/stage-09-leader.d.ts +6 -3
- package/dist/boot/stage-10-http-server.d.ts +6 -3
- package/dist/boot/stage-10-http-server.js +14 -5
- package/dist/boot/stores.d.ts +5 -2
- package/dist/boot/stores.js +10 -9
- package/dist/boot/web-admin.d.ts +5 -1
- package/dist/boot/web-admin.js +48 -36
- package/dist/boot/webfetch-summarize-lane.js +2 -1
- package/dist/boot/workflow-orchestration.js +3 -2
- package/dist/capabilities/builtin-tools.d.ts +2 -1
- package/dist/capabilities/builtin-tools.js +2 -4
- package/dist/capabilities/composite-members.d.ts +2 -1
- package/dist/capabilities/composite-members.js +2 -1
- package/dist/capabilities/hands-lane.d.ts +9 -39
- package/dist/capabilities/hands-lane.js +8 -13
- package/dist/capabilities/mcp-probe.d.ts +3 -2
- package/dist/capabilities/scenarios.d.ts +11 -1
- package/dist/capabilities/scenarios.js +1 -0
- package/dist/capabilities/skills.d.ts +1 -17
- package/dist/capabilities/skills.js +0 -8
- package/dist/capability-facts.d.ts +31 -7
- package/dist/capability-facts.js +27 -4
- package/dist/card-void.d.ts +6 -9
- package/dist/config-catalog.js +2 -1
- package/dist/config-dir-trust.js +58 -29
- package/dist/config-invariants.d.ts +7 -1
- package/dist/config-invariants.js +7 -0
- package/dist/config-provider.d.ts +10 -0
- package/dist/config-provider.js +15 -4
- package/dist/config-root-migration.d.ts +13 -0
- package/dist/config-root-migration.js +99 -0
- package/dist/config-types.d.ts +19 -8
- package/dist/config.d.ts +10 -3
- package/dist/config.js +18 -4
- package/dist/delegated-session-owner.d.ts +5 -3
- package/dist/delegated-session-owner.js +1 -1
- package/dist/device-ws-protocol.d.ts +1 -0
- package/dist/device-ws-protocol.js +2 -1
- package/dist/env-model-table-gate.d.ts +53 -0
- package/dist/env-model-table-gate.js +53 -0
- package/dist/execution-lane-caps.d.ts +2 -1
- package/dist/fleet/fleet-bus.d.ts +34 -55
- package/dist/fleet/fleet-bus.js +35 -100
- package/dist/fleet/fleet-reconciler.d.ts +4 -4
- package/dist/fleet/fleet-reconciler.js +1 -1
- package/dist/fleet/subagent-tail-bus.d.ts +14 -11
- package/dist/fleet/subagent-tail-bus.js +15 -28
- package/dist/hooks/hook-runner.d.ts +6 -0
- package/dist/hooks/hook-runner.js +58 -8
- package/dist/host-decision.d.ts +54 -20
- package/dist/host-decision.js +42 -14
- package/dist/http/admission.d.ts +1 -1
- package/dist/http/admission.js +7 -3
- package/dist/http/approval-sweeps.js +11 -8
- package/dist/http/caller-trust.d.ts +1 -1
- package/dist/http/dispatch.js +4 -2
- package/dist/http/durable-run-leg.js +2 -2
- package/dist/http/engine-refusal.d.ts +16 -0
- package/dist/http/engine-refusal.js +17 -0
- package/dist/http/execution-context.d.ts +2 -2
- package/dist/http/idempotency.d.ts +1 -1
- package/dist/http/memory-compliance-failure-reply.d.ts +1 -3
- package/dist/http/memory-compliance-failure-reply.js +4 -6
- package/dist/http/owner-access.d.ts +11 -0
- package/dist/http/owner-access.js +13 -0
- package/dist/http/principal-gate.d.ts +3 -1
- package/dist/http/principal-gate.js +17 -8
- package/dist/http/resume-legs.d.ts +21 -7
- package/dist/http/resume-legs.js +76 -58
- package/dist/http/resume-restatement.d.ts +39 -0
- package/dist/http/resume-restatement.js +25 -0
- package/dist/http/route-ctx.d.ts +35 -10
- package/dist/http/route-ctx.js +1 -1
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/approvals-assistant.d.ts +9 -1
- package/dist/http/routes/approvals-assistant.js +142 -31
- package/dist/http/routes/attachments.js +18 -0
- package/dist/http/routes/capabilities.js +16 -4
- package/dist/http/routes/memory-policy.d.ts +2 -2
- package/dist/http/routes/memory-policy.js +27 -7
- package/dist/http/routes/notify-wake.js +23 -25
- package/dist/http/routes/rules.js +48 -13
- package/dist/http/routes/runs.js +12 -11
- package/dist/http/routes/session-memory-sync.d.ts +91 -0
- package/dist/http/routes/session-memory-sync.js +174 -0
- package/dist/http/routes/session-sync.js +13 -20
- package/dist/http/routes/sessions-list.d.ts +2 -1
- package/dist/http/routes/sessions.d.ts +2 -2
- package/dist/http/routes/sessions.js +22 -23
- package/dist/http/routes/tasks.js +34 -54
- package/dist/http/run-read-face.d.ts +7 -0
- package/dist/http/run-read-face.js +9 -3
- package/dist/http/send.d.ts +5 -0
- package/dist/http/send.js +9 -2
- package/dist/http/server.d.ts +27 -15
- package/dist/http/server.js +4 -6
- package/dist/http/stored-body-replay.js +15 -4
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +2 -2
- package/dist/http/sync-submit-body.d.ts +21 -4
- package/dist/http/sync-submit-body.js +13 -0
- package/dist/http/wire-types.d.ts +17 -7
- package/dist/identity-source.d.ts +21 -2
- package/dist/identity-source.js +6 -0
- package/dist/leader/leader.js +5 -2
- package/dist/leader/wire.d.ts +7 -1
- package/dist/leader/wire.js +6 -5
- package/dist/leg-facts.d.ts +37 -0
- package/dist/leg-facts.js +15 -0
- package/dist/memory-bundle-engine.d.ts +1 -4
- package/dist/memory-bundle-engine.js +2 -2
- package/dist/memory-incident-sink.d.ts +19 -6
- package/dist/memory-incident-sink.js +8 -4
- package/dist/memory-operator-faces.d.ts +30 -66
- package/dist/memory-operator-faces.js +17 -88
- package/dist/memory-scope-stores.d.ts +38 -40
- package/dist/memory-scope-stores.js +51 -36
- package/dist/memory-scope.d.ts +0 -9
- package/dist/memory-scope.js +0 -9
- package/dist/memory-sync-client.d.ts +21 -21
- package/dist/memory-sync-client.js +62 -43
- package/dist/memory-sync-identity.d.ts +24 -0
- package/dist/memory-sync-identity.js +57 -0
- package/dist/memory-sync.d.ts +27 -5
- package/dist/memory-sync.js +29 -7
- package/dist/model-plane-face.d.ts +13 -7
- package/dist/model-plane-face.js +2 -1
- package/dist/observability/fail-open.d.ts +47 -14
- package/dist/observability/fail-open.js +37 -11
- package/dist/observability/run-terminal.d.ts +92 -34
- package/dist/observability/run-terminal.js +171 -162
- package/dist/orchestration/workflow-completion-inbox.d.ts +5 -19
- package/dist/orchestration/workflow-completion-inbox.js +0 -12
- package/dist/orchestration/workflow-notify-journal.d.ts +3 -2
- package/dist/orchestration/workflow-park-decision.d.ts +8 -3
- package/dist/orchestration/workflow-park-decision.js +5 -3
- package/dist/org-delivery-gate.d.ts +11 -0
- package/dist/org-delivery-gate.js +19 -1
- package/dist/parked-decide.d.ts +13 -9
- package/dist/parked-decide.js +7 -7
- package/dist/parked-revive-surface.js +1 -1
- package/dist/peer-inbound-face.d.ts +127 -0
- package/dist/peer-inbound-face.js +158 -0
- package/dist/permission-rule-list.d.ts +13 -9
- package/dist/permission-rule-list.js +7 -3
- package/dist/plugins/approval-ask-store-file.d.ts +14 -4
- package/dist/plugins/approval-ask-store-file.js +64 -11
- package/dist/plugins/approval-ask-store-memory.d.ts +2 -1
- package/dist/plugins/approval-ask-store-memory.js +17 -14
- package/dist/plugins/approval-ask-store-sql.d.ts +70 -23
- package/dist/plugins/approval-ask-store-sql.js +79 -30
- package/dist/plugins/checkpoint-store-sql.d.ts +4 -4
- package/dist/plugins/checkpoint-store-sql.js +9 -7
- package/dist/plugins/file-history-store-sql.d.ts +24 -18
- package/dist/plugins/file-history-store-sql.js +24 -19
- package/dist/plugins/file-run-store.d.ts +35 -1
- package/dist/plugins/file-run-store.js +108 -9
- package/dist/plugins/imported-layer-root-retirement.d.ts +82 -0
- package/dist/plugins/imported-layer-root-retirement.js +96 -0
- package/dist/plugins/local-checkpoint-store.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.js +2 -2
- package/dist/plugins/local-session-store.d.ts +42 -9
- package/dist/plugins/local-session-store.js +83 -33
- package/dist/plugins/local-task-attachment-store.d.ts +12 -2
- package/dist/plugins/local-task-attachment-store.js +67 -43
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +9 -31
- package/dist/plugins/mailbox-recipient-lifecycle.js +4 -0
- package/dist/plugins/mailbox-store-sql.d.ts +12 -8
- package/dist/plugins/mailbox-store-sql.js +76 -7
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-run-store.d.ts +6 -1
- package/dist/plugins/memory-run-store.js +11 -1
- package/dist/plugins/memory-sync-store-pg.d.ts +15 -0
- package/dist/plugins/memory-sync-store-pg.js +21 -0
- package/dist/plugins/memory-sync-store-tidb.d.ts +2 -0
- package/dist/plugins/memory-sync-store-tidb.js +13 -1
- package/dist/plugins/one-time-migrations.d.ts +58 -2
- package/dist/plugins/one-time-migrations.js +161 -4
- package/dist/plugins/org-delivery-quota-store.d.ts +1 -1
- package/dist/plugins/org-delivery-quota-store.js +2 -12
- package/dist/plugins/park-commit-watch.d.ts +1 -1
- package/dist/plugins/permission-rule-store-file.d.ts +10 -1
- package/dist/plugins/permission-rule-store-file.js +15 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +31 -1
- package/dist/plugins/permission-rule-store-sql.js +35 -2
- package/dist/plugins/remote-env-device.d.ts +8 -11
- package/dist/plugins/remote-env-device.js +6 -3
- package/dist/plugins/remote-env-e2b.d.ts +23 -4
- package/dist/plugins/remote-env-e2b.js +111 -28
- package/dist/plugins/remote-env-k8s.d.ts +61 -22
- package/dist/plugins/remote-env-k8s.js +133 -33
- package/dist/plugins/remote-env-local-docker.d.ts +15 -3
- package/dist/plugins/remote-env-local-docker.js +40 -12
- package/dist/plugins/retention-store-sql.d.ts +2 -2
- package/dist/plugins/run-store-sql.d.ts +9 -1
- package/dist/plugins/run-store-sql.js +9 -1
- package/dist/plugins/sandbox-read-floor.d.ts +5 -7
- package/dist/plugins/sandbox-read-floor.js +2 -7
- package/dist/plugins/sql-errors.d.ts +10 -1
- package/dist/plugins/sql-errors.js +13 -0
- package/dist/plugins/store-backend.d.ts +33 -35
- package/dist/plugins/store-backend.js +10 -1
- package/dist/plugins/store-contracts.d.ts +50 -1
- package/dist/plugins/store-contracts.js +6 -0
- package/dist/plugins/task-attachment-store.d.ts +112 -14
- package/dist/plugins/task-attachment-store.js +207 -29
- package/dist/plugins/tool-result-store-sql.d.ts +9 -8
- package/dist/plugins/tool-result-store-sql.js +23 -2
- package/dist/plugins/wiring-section-codec.d.ts +32 -0
- package/dist/plugins/wiring-section-codec.js +55 -0
- package/dist/plugins/workspace-fill.d.ts +60 -0
- package/dist/plugins/workspace-fill.js +106 -0
- package/dist/project-bundle.d.ts +38 -0
- package/dist/project-bundle.js +609 -0
- package/dist/rule-entry-list.d.ts +3 -2
- package/dist/rule-entry-list.js +5 -1
- package/dist/rules-consent.d.ts +28 -5
- package/dist/rules-consent.js +40 -28
- package/dist/run-local.js +11 -13
- package/dist/runs.d.ts +12 -8
- package/dist/runs.js +6 -8
- package/dist/runtime-governance.d.ts +1 -1
- package/dist/sandbox-egress-policy.d.ts +4 -1
- package/dist/sandbox-egress-policy.js +3 -1
- package/dist/sandbox-git-plane.d.ts +31 -12
- package/dist/sandbox-git-plane.js +24 -4
- package/dist/security.d.ts +9 -0
- package/dist/security.js +8 -0
- package/dist/server-secret-env.d.ts +4 -0
- package/dist/session-error-wire.d.ts +36 -0
- package/dist/session-error-wire.js +13 -0
- package/dist/session-incarnation.d.ts +1 -1
- package/dist/session-notify-door.d.ts +106 -0
- package/dist/session-notify-door.js +93 -0
- package/dist/session-sync.d.ts +9 -14
- package/dist/session-sync.js +5 -5
- package/dist/session-workspace.d.ts +3 -13
- package/dist/session-workspace.js +0 -9
- package/dist/standing-answer-grant.d.ts +5 -0
- package/dist/standing-answer-grant.js +10 -0
- package/dist/stores-sql/session-policy-store-sql.d.ts +4 -2
- package/dist/stores-sql/session-policy-store-sql.js +3 -13
- package/dist/task-mcp.d.ts +1 -1
- package/dist/task-settings.d.ts +21 -10
- package/dist/task-settings.js +46 -13
- package/dist/terminal.d.ts +39 -19
- package/dist/terminal.js +65 -22
- package/dist/tool-approval.d.ts +56 -37
- package/dist/tool-approval.js +78 -71
- package/dist/trace/core-keyset-guard.d.ts +134 -14
- package/dist/trace/engine-notice-wire.d.ts +9 -3
- package/dist/trace/engine-notice-wire.js +7 -3
- package/dist/trace/exit-seat.d.ts +9 -2
- package/dist/trace/exit-seat.js +1 -0
- package/dist/trace/ledger-sink.d.ts +10 -6
- package/dist/trace/ledger-sink.js +2 -2
- package/dist/trace/model-segment.d.ts +55 -25
- package/dist/trace/model-segment.js +101 -33
- package/dist/trace/project.d.ts +25 -5
- package/dist/trace/project.js +22 -0
- package/dist/trace/redact.d.ts +61 -9
- package/dist/trace/redact.js +1490 -468
- package/dist/trace/self-minted-wire.d.ts +745 -24
- package/dist/trace/self-minted-wire.js +239 -9
- package/dist/trace/wire-projection-faces.d.ts +2 -2
- package/dist/trace/wire-projection-faces.js +2 -2
- package/dist/verifier-pause-card.d.ts +33 -5
- package/dist/verifier-pause-card.js +15 -10
- package/dist/web-admin-client/apply-effective.d.ts +12 -16
- package/dist/web-admin-client/apply-effective.js +109 -9
- package/dist/web-admin-client/effective-keys.js +2 -0
- package/dist/web-admin-client/types.d.ts +4 -0
- package/dist/workspace-space.d.ts +19 -3
- package/dist/workspace-space.js +8 -4
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +3 -1
- package/package.json +3 -2
- package/wire-changes/server@7.142.0.json +639 -0
- package/wire-changes/server@7.143.0.json +1167 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* ⑨⑩([ref],2026-08-31)把两个最大的 wire 面也纳入:TaskSpec 按「server 有无写点」记 Wired/Unwired,
|
|
18
18
|
* TaskResult 按「转发/摘除」记 Forwarded/Stripped —— 谁改 resolve-spec.ts / runs.ts 的发射点谁同步本文件。
|
|
19
19
|
*/
|
|
20
|
-
import type { TaskNotificationPayload, SemaProvenance, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, PendingAction, TaskEvent, TraceEvent, MailboxMessage, MailboxAppendMessage, TaskSpec, TaskResult, SideQueryResult, WiringManifest, PermissionModeReceipt, GateOutcome, GateDisposition, Settlement, PausedCause, TerminalCause, CheckpointGate, CheckpointToken, VerificationResult, CascadeRunResult, WorkflowRun, ReadRootGrantCandidate, McpReconnectResult, McpServerStatus, NodeLspManagerOptions, RunnerDeps, SessionMemoryStatus, PromptManifestIdentity, PromptIdentityLayers, PromptManifestSelectors, PromptManifestSection, PromptChainLink, SupersededOverlay, ToolDisclosureManifest } from "@sema-agent/core";
|
|
20
|
+
import type { TaskNotificationPayload, SemaProvenance, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, PendingAction, TaskEvent, TraceEvent, MailboxMessage, MailboxAppendMessage, TaskSpec, TaskResult, SideQueryResult, WiringManifest, PermissionModeReceipt, GateOutcome, GateDisposition, Settlement, PausedCause, TerminalCause, CheckpointGate, CheckpointToken, VerificationResult, CascadeRunResult, WorkflowRun, ReadRootGrantCandidate, McpReconnectResult, McpServerStatus, NodeLspManagerOptions, RunnerDeps, SessionMemoryStatus, DeploymentSessionMemoryStatus, PromptManifestIdentity, PromptIdentityLayers, PromptManifestSelectors, PromptManifestSection, PromptChainLink, SupersededOverlay, ToolDisclosureManifest } from "@sema-agent/core";
|
|
21
21
|
import type { ToolApprovalFrame } from "../tool-approval.js";
|
|
22
22
|
import type { TableCoreKeys } from "./projection-table.js";
|
|
23
23
|
import type { PauseSeat } from "../terminal.js";
|
|
@@ -45,7 +45,7 @@ type _GuardBgNotifReverse = AssertAllKeysHandled<Exclude<BgNotifProjected | BgNo
|
|
|
45
45
|
type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "modelFallback" | "createdAt";
|
|
46
46
|
type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
|
|
47
47
|
type _GuardRosterReverse = AssertAllKeysHandled<Exclude<RosterProjected, keyof RosterEntry>>;
|
|
48
|
-
type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "
|
|
48
|
+
type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceSessionId" | "agentId" | "askReasons" | "fromSubagent" | "sourceAgentName" | "delegation" | "ruleOffers" | "ruleOffersAbsence" | "allowRuleShadowed" | "probeCause" | "probeReason" | "ruleEvidence" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "readRootCandidate" | "mandated" | "mandate" | "askClass" | "classes" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "approvalCard" | "boundGrantAbsence" | "requestedBy";
|
|
49
49
|
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "editRewritten";
|
|
50
50
|
type _GuardAsk = AssertAllKeysHandled<Exclude<keyof AskRequest, AskProjected | AskExcluded>>;
|
|
51
51
|
type _GuardAskReverse = AssertAllKeysHandled<Exclude<AskProjected | AskExcluded, keyof AskRequest>>;
|
|
@@ -218,7 +218,7 @@ type _GuardPromptManifestKeysNonEmpty = AssertAllKeysHandled<{
|
|
|
218
218
|
[L in keyof ManifestCore]: [ManifestDeclared<ManifestFaces, L>] extends [never] ? L : never;
|
|
219
219
|
}[keyof ManifestCore]>;
|
|
220
220
|
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "mandated" | "mandate" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "boundGrantAbsence" | "checkpointId";
|
|
221
|
-
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "
|
|
221
|
+
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceSessionId" | "agentId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy" | "runOrigin" | "requestedByCallId";
|
|
222
222
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
223
223
|
type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected | SummaryExcluded, keyof CheckpointSummary>>;
|
|
224
224
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
@@ -234,7 +234,7 @@ type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requi
|
|
|
234
234
|
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel" | "runOrigin" | "planFile" | "classifyAllShell";
|
|
235
235
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
236
236
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
237
|
-
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction" | "resultEntryIds";
|
|
237
|
+
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction" | "resultEntryIds" | "placementRoot";
|
|
238
238
|
type TaskResultStripped = never;
|
|
239
239
|
type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
|
|
240
240
|
type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
|
|
@@ -245,14 +245,17 @@ type _GuardPausedCauseReverse = AssertAllKeysHandled<Exclude<PausedCauseForwarde
|
|
|
245
245
|
type NonPausedTerminalKeys = Exclude<TerminalCause, {
|
|
246
246
|
kind: "paused";
|
|
247
247
|
}> extends infer C ? (C extends object ? keyof C : never) : never;
|
|
248
|
-
type TerminalArmForwarded = "kind" | "code" | "message" | "nestedPause" | "detail" | "reason";
|
|
248
|
+
type TerminalArmForwarded = "kind" | "code" | "message" | "nestedPause" | "detail" | "reason" | "unstartedRow";
|
|
249
249
|
type TerminalArmStripped = never;
|
|
250
250
|
type _GuardTerminalArm = AssertAllKeysHandled<Exclude<NonPausedTerminalKeys, TerminalArmForwarded | TerminalArmStripped>>;
|
|
251
251
|
type _GuardTerminalArmReverse = AssertAllKeysHandled<Exclude<TerminalArmForwarded | TerminalArmStripped, NonPausedTerminalKeys>>;
|
|
252
252
|
type SeatDepth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
253
253
|
type JoinPath<K extends string, P extends string> = [P] extends [never] ? never : P extends "" ? K : `${K}.${P}`;
|
|
254
|
-
/**
|
|
255
|
-
type
|
|
254
|
+
/** 两个型**全同**(不是「互相可赋」:全可选成员的子对象与它的父对象互相可赋,却不是同一个型)。 */
|
|
255
|
+
type SameType<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
|
|
256
|
+
/** `T` 与祖先链上某一层**全同** ⇒ 这是递归类型的回环(如 JSON 值类型),再走只是同一棵子树换个前缀,停。只比祖先、不比兄弟。
|
|
257
|
+
* 有限型的子代不可能与祖先全同(祖先含着它),所以全同只在递归上成立;「互相可赋」会把同形的有限子代(`{text?, cause?: {text?}}` 的 `cause`)误判成回环、整枝丢掉。 */
|
|
258
|
+
type SeenOnPath<T, Seen extends readonly unknown[]> = Seen extends readonly [infer H, ...infer R extends readonly unknown[]] ? SameType<T, H> extends true ? true : SeenOnPath<T, R> : false;
|
|
256
259
|
/**
|
|
257
260
|
* `T` 里类型为 `Leaf` 的全部路径(点分;数组元素记 `[]`;`any` 不展开)。回环按祖先链判停;深度封顶 12 且**封顶响亮**:
|
|
258
261
|
* 走到底还没走完的分支产出以 `<depth-exhausted>` 收尾的路径 —— 它不在座表里 ⇒ 下面的正向对账 TS2344(封顶静默返回 `never`
|
|
@@ -311,18 +314,131 @@ type _SeatWalkTooDeep = {
|
|
|
311
314
|
};
|
|
312
315
|
};
|
|
313
316
|
type _SeatWalkCheckExhaustionLoud = AssertAllKeysHandled<Exclude<"a.b.c.d.e.f.g.h.i.j.k.l.m.<depth-exhausted>", PathsTo<_SeatWalkTooDeep, CheckpointToken>>>;
|
|
314
|
-
|
|
317
|
+
/** 本仓结算点交给封口的**全部出口结果类型**(普通腿 / verify 腿 / cascade 腿)—— ⑩f(停驻座)与 ⑩g(结果文本叶,`observability/run-terminal.ts`)同读这一组。 */
|
|
318
|
+
export type ExitResult = TaskResult | VerificationResult | CascadeRunResult;
|
|
315
319
|
type SeatPathText<P extends readonly string[]> = P extends readonly [infer H extends string, ...infer R extends readonly string[]] ? (R extends readonly [] ? H : `${H}.${SeatPathText<R>}`) : never;
|
|
316
|
-
/** 座表上某一键(凭据 / 门)
|
|
317
|
-
type SeatKeyPaths<S, K extends "token" | "gate"> = S extends PauseSeat ? `${SeatPathText<S["path"]>}.${S[K]}` : never;
|
|
320
|
+
/** 座表上某一键(凭据 / 门)的全部路径,按行分配。⑩g 的结果文本叶从派生键集里减掉这几条(它们归封口 + 门脱敏,不归文本表)。 */
|
|
321
|
+
export type SeatKeyPaths<S, K extends "token" | "gate"> = S extends PauseSeat ? `${SeatPathText<S["path"]>}.${S[K]}` : never;
|
|
318
322
|
type _GuardTokenSeats = AssertAllKeysHandled<Exclude<PathsTo<ExitResult, CheckpointToken>, SeatKeyPaths<PauseSeat, "token">>>;
|
|
319
323
|
type _GuardTokenSeatsReverse = AssertAllKeysHandled<Exclude<SeatKeyPaths<PauseSeat, "token">, PathsTo<ExitResult, CheckpointToken>>>;
|
|
320
324
|
type _GuardGateSeats = AssertAllKeysHandled<Exclude<PathsTo<ExitResult, CheckpointGate>, SeatKeyPaths<PauseSeat, "gate">>>;
|
|
321
325
|
type _GuardGateSeatsReverse = AssertAllKeysHandled<Exclude<SeatKeyPaths<PauseSeat, "gate">, PathsTo<ExitResult, CheckpointGate>>>;
|
|
326
|
+
/** 一个串型装得下任意文字 ⇔ 以它为键的记录不要求任何具名键(`string` / 模板串 / 品牌串给出索引签名或空形;闭集字面量给出必需键)。 */
|
|
327
|
+
type FreeTextString<S extends string> = {} extends Record<S, 0> ? "" : never;
|
|
328
|
+
type TextLeafSegment<K extends string | number> = K extends number ? (number extends K ? "*" : `${K}`) : string extends K ? "*" : K;
|
|
329
|
+
export type TextLeafPaths<T, Seen extends readonly unknown[] = [], D extends number = 12> = [D] extends [never] ? "<depth-exhausted>" : 0 extends 1 & T ? "" : unknown extends T ? "" : T extends string ? FreeTextString<T> : T extends number | boolean | bigint | symbol | null | undefined ? never : T extends (...args: never[]) => unknown ? never : SeenOnPath<T, Seen> extends true ? never : T extends readonly (infer E)[] ? JoinPath<"[]", TextLeafPaths<E, [...Seen, T], SeatDepth[D]>> : T extends object ? {
|
|
330
|
+
[K in keyof T & (string | number)]-?: JoinPath<TextLeafSegment<K>, TextLeafPaths<T[K], [...Seen, T], SeatDepth[D]>>;
|
|
331
|
+
}[keyof T & (string | number)] : never;
|
|
332
|
+
/** 落在某个前缀**之下或就是它**的路径折成那个前缀(子树归前缀的属主);不在任何前缀下的原样。前缀之间不许互相嵌套(嵌套 ⇒ 一条路径折成两个,表上两行同判一片叶)。 */
|
|
333
|
+
export type CollapseUnder<P extends string, Prefix extends string> = P extends unknown ? ([OwnerPrefixOf<P, Prefix>] extends [never] ? P : OwnerPrefixOf<P, Prefix>) : never;
|
|
334
|
+
type OwnerPrefixOf<P extends string, Prefix extends string> = Prefix extends unknown ? (P extends Prefix | `${Prefix}.${string}` ? Prefix : never) : never;
|
|
335
|
+
/** 判别联合各臂键的**并集**(`keyof` 一个联合给的是交集)。 */
|
|
336
|
+
type AllKeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
337
|
+
/** 联合里各臂在键 `K` 上的成员型之并(没有这一键的臂不贡献)。 */
|
|
338
|
+
type MemberOfUnion<T, K extends PropertyKey> = T extends unknown ? (K extends keyof T ? T[K] : never) : never;
|
|
339
|
+
/**
|
|
340
|
+
* 处置词 `W` 盖得住型 `V` ⇔ `V` 之下的每一片自由文本叶(相对 `V` 的路径)都在 `Covers[W]` 里。词表即盖法表:叶词盖 `""`(成员自己那片叶)、
|
|
341
|
+
* `text[]` 类词盖 `"[]"`、按自家派生表下降的词与整树词盖 `string`(下降目标的表同样是 {@link OwnerTable},逐层同一条)。
|
|
342
|
+
*/
|
|
343
|
+
export type CoveringWords<V, Covers extends Record<string, string>> = {
|
|
344
|
+
[W in keyof Covers & string]: [Exclude<TextLeafPaths<V>, Covers[W]>] extends [never] ? W : never;
|
|
345
|
+
}[keyof Covers & string];
|
|
346
|
+
/**
|
|
347
|
+
* 属主表的型:`T`(可为判别联合,取各臂键之并)的每个成员一行、少一行 / 多一行都红,且每行只许 {@link CoveringWords} —— 一个 `"verbatim"`
|
|
348
|
+
* 落在藏着自由文本叶的对象成员上(core 往 `stats.nested` 这种数字袋里加一个字符串成员)⇒ 该行不再可赋 ⇒ tsc 红,不是静默逐字。
|
|
349
|
+
*/
|
|
350
|
+
export type OwnerTable<T, Covers extends Record<string, string>> = {
|
|
351
|
+
readonly [K in AllKeysOfUnion<T>]: CoveringWords<MemberOfUnion<T, K>, Covers>;
|
|
352
|
+
};
|
|
353
|
+
type _TextWalkProbe = {
|
|
354
|
+
s: string;
|
|
355
|
+
w: "a" | "b";
|
|
356
|
+
tpl: `${string}.x`;
|
|
357
|
+
br: string & {
|
|
358
|
+
readonly brand: 1;
|
|
359
|
+
};
|
|
360
|
+
n: number;
|
|
361
|
+
f: boolean;
|
|
362
|
+
o: unknown;
|
|
363
|
+
a: any;
|
|
364
|
+
arr: {
|
|
365
|
+
t: string;
|
|
366
|
+
}[];
|
|
367
|
+
idx: Record<string, string>;
|
|
368
|
+
byNum: Record<number, string>;
|
|
369
|
+
tuple0: {
|
|
370
|
+
0: string;
|
|
371
|
+
};
|
|
372
|
+
own: {
|
|
373
|
+
x: string;
|
|
374
|
+
y: {
|
|
375
|
+
z: string;
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
nil?: null;
|
|
379
|
+
ev: {
|
|
380
|
+
text?: string;
|
|
381
|
+
cause?: {
|
|
382
|
+
text?: string;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
type _TextWalkExpected = "s" | "tpl" | "br" | "o" | "a" | "arr.[].t" | "idx.*" | "byNum.*" | "tuple0.0" | "own" | "ev.text" | "ev.cause.text";
|
|
387
|
+
type _TextWalkGot = CollapseUnder<TextLeafPaths<_TextWalkProbe>, "own">;
|
|
388
|
+
type _TextLeafWalkCheckShapes = AssertAllKeysHandled<Exclude<_TextWalkExpected, _TextWalkGot> | Exclude<_TextWalkGot, _TextWalkExpected>>;
|
|
389
|
+
type _TextWalkTooDeep = {
|
|
390
|
+
a: {
|
|
391
|
+
b: {
|
|
392
|
+
c: {
|
|
393
|
+
d: {
|
|
394
|
+
e: {
|
|
395
|
+
f: {
|
|
396
|
+
g: {
|
|
397
|
+
h: {
|
|
398
|
+
i: {
|
|
399
|
+
j: {
|
|
400
|
+
k: {
|
|
401
|
+
l: {
|
|
402
|
+
m: {
|
|
403
|
+
t: string;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
type _TextLeafWalkCheckExhaustionLoud = AssertAllKeysHandled<Exclude<"a.b.c.d.e.f.g.h.i.j.k.l.m.<depth-exhausted>", TextLeafPaths<_TextWalkTooDeep>>>;
|
|
419
|
+
type _CoverProbeWords = {
|
|
420
|
+
verbatim: "";
|
|
421
|
+
"text[]": "[]";
|
|
422
|
+
tree: string;
|
|
423
|
+
};
|
|
424
|
+
type _CoverWordsCheck = AssertAllKeysHandled<Exclude<CoveringWords<{
|
|
425
|
+
tokens: number;
|
|
426
|
+
label: string;
|
|
427
|
+
}, _CoverProbeWords>, "tree"> | Exclude<"tree", CoveringWords<{
|
|
428
|
+
tokens: number;
|
|
429
|
+
label: string;
|
|
430
|
+
}, _CoverProbeWords>> | Exclude<"verbatim" | "tree", CoveringWords<{
|
|
431
|
+
tokens: number;
|
|
432
|
+
carrier?: "header" | "query";
|
|
433
|
+
}, _CoverProbeWords>> | Exclude<"text[]" | "tree", CoveringWords<readonly string[] | undefined, _CoverProbeWords>> | Extract<"verbatim" | "text[]", CoveringWords<{
|
|
434
|
+
note: string;
|
|
435
|
+
}[], _CoverProbeWords>>>;
|
|
436
|
+
type SessionMemoryStatusSourceKey = keyof SessionMemoryStatus | keyof DeploymentSessionMemoryStatus;
|
|
322
437
|
type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "foldedCount" | "optOutSource" | "lastCaptureAt";
|
|
323
|
-
type SessionMemoryStatusExcluded = "writeHome";
|
|
324
|
-
type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<
|
|
325
|
-
type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded,
|
|
438
|
+
type SessionMemoryStatusExcluded = "writeHome" | "planes";
|
|
439
|
+
type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<SessionMemoryStatusSourceKey, SessionMemoryStatusProjected | SessionMemoryStatusExcluded>>;
|
|
440
|
+
type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded, SessionMemoryStatusSourceKey>>;
|
|
441
|
+
type _GuardSessionMemoryStatusDeploymentReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected, keyof DeploymentSessionMemoryStatus>>;
|
|
326
442
|
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut" | "account";
|
|
327
443
|
type SideQueryResultStripped = never;
|
|
328
444
|
type _GuardSideQueryResult = AssertAllKeysHandled<Exclude<keyof SideQueryResult, SideQueryResultForwarded | SideQueryResultStripped>>;
|
|
@@ -411,6 +527,7 @@ export type CoreKeysetGuards = [
|
|
|
411
527
|
_GuardTerminalArmReverse,
|
|
412
528
|
_GuardSessionMemoryStatus,
|
|
413
529
|
_GuardSessionMemoryStatusReverse,
|
|
530
|
+
_GuardSessionMemoryStatusDeploymentReverse,
|
|
414
531
|
_GuardNotificationReverse,
|
|
415
532
|
_GuardProvenance,
|
|
416
533
|
_GuardProvenanceReverse,
|
|
@@ -555,7 +672,10 @@ export type CoreKeysetGuards = [
|
|
|
555
672
|
_GuardGateSeats,
|
|
556
673
|
_GuardGateSeatsReverse,
|
|
557
674
|
_SeatWalkCheckDepth8,
|
|
558
|
-
_SeatWalkCheckExhaustionLoud
|
|
675
|
+
_SeatWalkCheckExhaustionLoud,
|
|
676
|
+
_TextLeafWalkCheckShapes,
|
|
677
|
+
_TextLeafWalkCheckExhaustionLoud,
|
|
678
|
+
_CoverWordsCheck
|
|
559
679
|
];
|
|
560
680
|
export {};
|
|
561
681
|
//# sourceMappingURL=core-keyset-guard.d.ts.map
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
|
|
17
17
|
* 刚立,立完就在下一次加码时自己咬住了)。
|
|
18
18
|
*/
|
|
19
|
-
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded", "context.
|
|
19
|
+
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded", "context.media_removed", "mcp.authorization_required", "classifier.seat_rate_limited", "context.tool_schema_removed"];
|
|
20
20
|
export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
|
|
21
21
|
/** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
|
|
22
22
|
export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
|
|
@@ -31,7 +31,7 @@ export declare function engineNoticeSessionId(notice: {
|
|
|
31
31
|
sessionId?: unknown;
|
|
32
32
|
detail?: Record<string, unknown>;
|
|
33
33
|
}): string | undefined;
|
|
34
|
-
/** wire 上的 `engine_notice` 载荷(
|
|
34
|
+
/** wire 上的 `engine_notice` 载荷(**六键固定**,设计稿 ②;`eventId` 随投递身份一并到货)。`type` 由发帧处补(SSE)/ 由账本行的 type 列承载。 */
|
|
35
35
|
export interface EngineNoticeWireRow {
|
|
36
36
|
/** 稳定机器码 —— 消费契约:cli 按 `code`+`detail` 渲染(见 {@link ENGINE_NOTICE_WIRE_CODES} 各码的 detail 形)。 */
|
|
37
37
|
code: string;
|
|
@@ -46,6 +46,12 @@ export interface EngineNoticeWireRow {
|
|
|
46
46
|
sessionId: string;
|
|
47
47
|
/** **服务端观察时刻**(ms epoch)——`EngineNotice` 自身不带时间戳,这是本仓收到它的那一拍,不是 core 铸它的那一拍。 */
|
|
48
48
|
ts: number;
|
|
49
|
+
/**
|
|
50
|
+
* 这一次投递的身份(uuidv7,非空):分流器**扇出时铸一枚**({@link EngineNoticeRouter} 的 `fanOut`,与 `ts` 同处),同腿的 live 帧与 durable 账本行是**同一只行对象**,
|
|
51
|
+
* 所以两个载体同值。live 帧因此带 `id:` 行(契约 §0.6:载荷有 `eventId` 才发行),重连后从 durable 尾(`GET /v1/runs/:id/events`,从头重放)读到的同一条通告靠这一枚认出是同一件事。
|
|
52
|
+
* 同一内容的两次投递是两件事、两枚身份。不是 core 的字段(`EngineNotice` 没有),也不可从内容推:同码同毫秒的两条内容哈希会撞。
|
|
53
|
+
*/
|
|
54
|
+
eventId: string;
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
51
57
|
* 上 wire 的**注册方写的自由文本**的唯一出口纪律:`redactSecrets` + 截到 {@link NOTICE_TEXT_MAX}。
|
|
@@ -106,7 +112,7 @@ export declare function engineNoticeEventData(notice: {
|
|
|
106
112
|
code: string;
|
|
107
113
|
message: string;
|
|
108
114
|
detail?: Record<string, unknown>;
|
|
109
|
-
}, sessionId: string, nowMs: number): EngineNoticeWireRow;
|
|
115
|
+
}, sessionId: string, nowMs: number, eventId: string): EngineNoticeWireRow;
|
|
110
116
|
/**
|
|
111
117
|
* 一条 run 腿注册进来的投递口。抛错由 {@link EngineNoticeRouter.route} 隔离(见那里的 fail-open 登记)。
|
|
112
118
|
* 返回值只对 {@link EngineNoticeRouter.routeConfirmed} 有意义([ref] codex r1-F2 / r2-F1):durable 口交回它那一次账本写的 thenable,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { uuidv7 } from "@sema-agent/core";
|
|
1
2
|
import { redactSecrets } from "./redact.js";
|
|
2
3
|
import { redactListEntry } from "../list-entry-display.js";
|
|
3
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
@@ -46,8 +47,10 @@ export const ENGINE_NOTICE_WIRE_CODES = [
|
|
|
46
47
|
"advisor.not_attached",
|
|
47
48
|
"inherit_env.names_withheld",
|
|
48
49
|
"model.capability_downgraded",
|
|
49
|
-
"context.
|
|
50
|
+
"context.media_removed",
|
|
50
51
|
"mcp.authorization_required",
|
|
52
|
+
"classifier.seat_rate_limited",
|
|
53
|
+
"context.tool_schema_removed",
|
|
51
54
|
];
|
|
52
55
|
const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
|
|
53
56
|
export function isEngineNoticeWireCode(code) {
|
|
@@ -128,13 +131,14 @@ export function redactNoticeRuleText(code, detail) {
|
|
|
128
131
|
});
|
|
129
132
|
return { ...detail, [at.array]: redacted };
|
|
130
133
|
}
|
|
131
|
-
export function engineNoticeEventData(notice, sessionId, nowMs) {
|
|
134
|
+
export function engineNoticeEventData(notice, sessionId, nowMs, eventId) {
|
|
132
135
|
return {
|
|
133
136
|
code: notice.code,
|
|
134
137
|
message: redactNoticeMessage(notice.message).slice(0, NOTICE_TEXT_MAX),
|
|
135
138
|
detail: sanitizeNoticeDetail(redactNoticeRuleText(notice.code, notice.detail)),
|
|
136
139
|
sessionId,
|
|
137
140
|
ts: nowMs,
|
|
141
|
+
eventId,
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
const isThenableResult = (v) => typeof v === "object" && v !== null && typeof v.then === "function";
|
|
@@ -189,7 +193,7 @@ export class EngineNoticeRouter {
|
|
|
189
193
|
const leg = list && list.length > 0 ? list[list.length - 1] : undefined;
|
|
190
194
|
if (!leg || leg.sinks.length === 0)
|
|
191
195
|
return [];
|
|
192
|
-
const row = engineNoticeEventData(notice, sessionId, nowMs);
|
|
196
|
+
const row = engineNoticeEventData(notice, sessionId, nowMs, uuidv7());
|
|
193
197
|
const outcomes = [];
|
|
194
198
|
for (const { slot, sink } of leg.sinks) {
|
|
195
199
|
try {
|
|
@@ -9,7 +9,8 @@ export type SafeText = string & {
|
|
|
9
9
|
* · `trace-frame-text`:trace 帧的自由文本位(子代名 / 动作行 / 通告正文与结果 / 诊断 / 注入摘录 / 压缩说明 / 人类输入的署名与附件标签 …),不设界;
|
|
10
10
|
* · `trace-frame-line`:trace 帧里一行宽的展示位(`workspace_changed.cwd` / `brain_status.detail`),界 300 码元;
|
|
11
11
|
* · `operator-log-text`:运维日志字段里的一句话 —— 读口坏行的缺陷句(core 的筛按位置点名并回显落盘标量)、`tool_trace` 行里工具的输出 / 失败句 / 拒因、
|
|
12
|
-
* hook 吐出的预览(非 JSON 的输出 / 应答体)与判词、Stop 评估者回话的头、观察面回调与唤醒投递抛出的句子、matcher
|
|
12
|
+
* hook 吐出的预览(非 JSON 的输出 / 应答体)与判词、Stop 评估者回话的头、观察面回调与唤醒投递抛出的句子、matcher 超预算的那两串、标题器的两只失败句、
|
|
13
|
+
* 起服面(`src/boot/**`)各条运维行里抛出物的句子与起服自检读数里的客户端异常原文(门 `test/boot-log-thrown-text-seat.test.ts`);界 200 码元(含截断记号);
|
|
13
14
|
* · `operator-log-arg`:运维日志字段里模型写的工具入参(`tool_trace` 的 `arg.*`:路径 / 命令 / 模式 / 非对象入参的串形);界 120 码元(含截断记号);
|
|
14
15
|
* · `operator-log-error`:运维日志字段里 hook 一侧的报错 —— hook 命令的 stderr、prompt 条目的载体失败句、起子进程 / 读会话分支抛出的句子;界 300 码元(含截断记号);
|
|
15
16
|
* · `operator-log-message`:运维日志字段里写给人看的一段话 —— hook 输出的 `systemMessage`、Stop 评估者判「做不到」的理由;界 500 码元(含截断记号);
|
|
@@ -18,12 +19,15 @@ export type SafeText = string & {
|
|
|
18
19
|
* 的 `reason` / `status.error` / `listingIncomplete.error`;引擎铸点已抹过请求回显与同主体词表(记号 `[redacted]`),这一行读同一个脱敏器(引擎记号 = 已抹的值,
|
|
19
20
|
* 引擎放过的形照抹);界 200 码元,原样出门(JSON 串值,消费方自己渲染)。
|
|
20
21
|
* · `peer-declaration-sentence`:引擎判官对一份 MCP / A2A 对端声明说的句子(`toolAxes` / `toolFaces` / `sessionMetaKey` / 启动界的原因句,逐字带着声明方写的工具名、键名),
|
|
21
|
-
* 进请求面 400
|
|
22
|
+
* 进请求面 400 拒句、续跑重放的丢弃行与重读行、名册的跳过行,以及能力读面 `GET /v1/capabilities/mcp` 上引擎整集拒(两台撞同一工具命名空间前缀)的拒句 —— 读者是调用方与运维,句子已是一行;不设界(拒句要说全判官的话),原样出门。
|
|
22
23
|
* · `inbox-diagnostics-text`:`workflow_complete` 补投帧上的诊断教学文本(`diagnostics`)—— 引擎在 workflow 完成通知上铸的「读哪里 / 怎么续跑」文本,入会话收件时洗一次,
|
|
23
24
|
* 店里(`payload` 列)只放出门安全的字节,drain 逐字带出。洗法与 live `task_notification.diagnostics` 同一个 scope(`free-text`);
|
|
24
25
|
* 这一行比 `trace-frame-text` 多一条界(4000 码元,与同族条目的文本位同额),原样出门:`payload` 列是 TEXT,无界的文本一旦超过列宽,入箱写整条失败、补投连摘要一起丢(完成已被记作送达),所以先有界。
|
|
25
26
|
* · `boot-refusal-line`:起服拒启的一行拒句 —— 部署座装配的拒句(`mods-declaration.ts`:声明的席名、包名、读包者 / 引擎准入交回的话);它经进程级 fatal 出口原样多行进 stderr,
|
|
26
27
|
* 所以必须在这里先压成一行(一句拒因里的换行会在运维的终端里伪造出第二条日志行);界 512 码元(含截断记号)。
|
|
28
|
+
* · `peer-inbound-card-text`:运维审批队列 `peer_inbound` 行(`GET /v1/approvals` 的 `pending[]` 与 `/v1/approvals/stream` 的 `pending` 帧)上被扣跨会话来信的
|
|
29
|
+
* 存储正文(`content`,core 的规范存储形 `[summary] message`)与发信方显示名(`fromName`)—— 别的会话写的自由文本,读者是收信方本人;不设界(core 存的那一份就是
|
|
30
|
+
* 收信方要审的全文,截了就审不全),原样出门(JSON 串值,消费方自己渲染)。
|
|
27
31
|
*/
|
|
28
32
|
declare const EXIT_SEATS: {
|
|
29
33
|
readonly "trace-frame-text": {
|
|
@@ -74,6 +78,9 @@ declare const EXIT_SEATS: {
|
|
|
74
78
|
readonly maxChars: 512;
|
|
75
79
|
readonly emit: "log-line";
|
|
76
80
|
};
|
|
81
|
+
readonly "peer-inbound-card-text": {
|
|
82
|
+
readonly scope: "free-text";
|
|
83
|
+
};
|
|
77
84
|
};
|
|
78
85
|
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
79
86
|
/** 设了界的座名。 */
|
package/dist/trace/exit-seat.js
CHANGED
|
@@ -16,6 +16,7 @@ const EXIT_SEATS = {
|
|
|
16
16
|
"peer-declaration-sentence": { scope: "free-text" },
|
|
17
17
|
"inbox-diagnostics-text": { scope: "free-text", maxChars: 4000 },
|
|
18
18
|
"boot-refusal-line": { scope: "free-text", maxChars: 512, emit: "log-line" },
|
|
19
|
+
"peer-inbound-card-text": { scope: "free-text" },
|
|
19
20
|
};
|
|
20
21
|
export function seatMaxChars(seat) {
|
|
21
22
|
return EXIT_SEATS[seat].maxChars;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TerminalCause } from "@sema-agent/core";
|
|
2
|
-
import { brainStatusEventData, type LegWiringSections } from "./project.js";
|
|
2
|
+
import { brainStatusEventData, type ModelUsageSeat, type LegWiringSections } from "./project.js";
|
|
3
3
|
import { NotifiedKeys } from "../orchestration/workflow-completion-inbox.js";
|
|
4
4
|
import { type LedgerEventType, type ParkLedgerEventType } from "./ledger-events.js";
|
|
5
5
|
/**
|
|
@@ -59,7 +59,8 @@ export interface LedgerSink {
|
|
|
59
59
|
onForwardEvent(e: {
|
|
60
60
|
type?: string;
|
|
61
61
|
}): void;
|
|
62
|
-
/** Park event (durable F4 suspend / [ref] D-B review pause)
|
|
62
|
+
/** Park event (durable F4 suspend / [ref] D-B review pause), written AFTER any pending `model_usage` delta of the leg (the status frame
|
|
63
|
+
* is the last frame a leg writes — `appendParkRow` owns that order): ONLY the `checkpointGate` is persisted —
|
|
63
64
|
* never the capability `checkpointToken` (search [18] Q1b).
|
|
64
65
|
* 🔴 **The gate is redacted, not "non-secret"** ([ref], 2026-09-10 — the arm [ref] R3 left open): it carries no
|
|
65
66
|
* capability token, but its `reason` and the `riskDescriptor` leaf family are model-/human-controlled display
|
|
@@ -73,8 +74,8 @@ export interface LedgerSink {
|
|
|
73
74
|
/** Terminal `done` event. `result` must already be checkpoint-token-stripped (and, on the bg leg,
|
|
74
75
|
* model-usage-attached) by the caller. */
|
|
75
76
|
appendDone(result: unknown): Promise<void>;
|
|
76
|
-
/** Convenience for the sync detach lane
|
|
77
|
-
*
|
|
77
|
+
/** Convenience for the sync detach lane: flush, then project the result to its park/terminal event exactly like the
|
|
78
|
+
* bg leg's done case (a park goes through {@link appendParked}, which settles pending model usage first). `result` must already be stripped. */
|
|
78
79
|
onDone(result: {
|
|
79
80
|
terminal: TerminalCause;
|
|
80
81
|
}): Promise<void>;
|
|
@@ -151,8 +152,11 @@ export declare function createLedgerSink(opts: {
|
|
|
151
152
|
* 各传自己看得见的那个词(位①=流事件 `ev.type`,位②=账本行 `type`);拿不到类型的打点方
|
|
152
153
|
* (core 的 onActivity 第五席、resume 腿手动打点)省参,`kind` 诚实缺席(见 turn-activity.ts)。 */
|
|
153
154
|
onActivity?: (kind?: string, statusData?: Record<string, unknown>) => void;
|
|
154
|
-
/** 这条腿的 `wiring_manifest` **本仓自铸段**(`LegWiringSections`:[ref] `instructions` 读腿的 `InstructionSelectionLeg.segment`、run 级 `skills`
|
|
155
|
-
* `
|
|
155
|
+
/** 这条腿的 `wiring_manifest` **本仓自铸段**(`LegWiringSections`:[ref] `instructions` 读腿的 `InstructionSelectionLeg.segment`、run 级 `skills` 读这条腿的部署事实
|
|
156
|
+
* `LegFacts.skills`,`leg-facts.ts`)。**必填**:账本行与 live 帧是同一条腿的两个载体,段必须来自同一只腿;在投帧那一刻读(core 推帧之前已 await 过 loader)。 */
|
|
156
157
|
legSections: () => LegWiringSections;
|
|
158
|
+
/** 这条腿的计量席(E8 累加器 + 归因键)。在场 ⇒ {@link LedgerSink.appendParked} 在停驻行之前先把未结清的用量差落成 `model_usage` 行(状态帧最后,见 `appendParkRow`);
|
|
159
|
+
* 缺席 ⇒ 这条腿没接累加器,停驻行之前无账可结(夹具、不经 `appendParked` 停驻的腿)。 */
|
|
160
|
+
usage?: ModelUsageSeat;
|
|
157
161
|
}): LedgerSink;
|
|
158
162
|
//# sourceMappingURL=ledger-sink.d.ts.map
|
|
@@ -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, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData,
|
|
4
|
+
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData, appendParkRow } 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";
|
|
@@ -179,7 +179,7 @@ export function createLedgerSink(opts) {
|
|
|
179
179
|
return append("status", statusData);
|
|
180
180
|
};
|
|
181
181
|
const appendParked = (kind, result) => {
|
|
182
|
-
return append
|
|
182
|
+
return appendParkRow(append, opts.usage, kind, result);
|
|
183
183
|
};
|
|
184
184
|
const appendDone = (result) => append("done", { result });
|
|
185
185
|
const onDone = async (result) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SegmentEndFields } from "./project.js";
|
|
1
|
+
import { type LiveEventIdentity, type SegmentEndFields } from "./project.js";
|
|
2
2
|
/**
|
|
3
3
|
* 本帧是不是模型文本的段界。**四条消费腿共用这一只**:账本投影 switch(`trace/ledger-sink.ts`)、
|
|
4
4
|
* 顶层 live 流与转发子代腿(`http/routes/tasks.ts`)、子代 tail 面(`fleet/subagent-tail-bus.ts`)。
|
|
@@ -13,43 +13,73 @@ export type ReasoningEndFrame = SegmentEndFields & {
|
|
|
13
13
|
type: "reasoning_end";
|
|
14
14
|
};
|
|
15
15
|
/** 登记册**读到的全部字段**,逐个写出来(不是 `Record<string, unknown>`):`TaskEvent` 与转发腿的原始帧
|
|
16
|
-
*
|
|
17
|
-
|
|
16
|
+
* 都结构性满足它,于是调用点一个宽断言都不必写;将来有人想读第八个键,得先在这里加一行。
|
|
17
|
+
* `type` 而不是 `interface`(与 `LiveEventIdentity` 同一条理由):`text_end` 的铸点收 `Record<string, unknown>`,别名才进得去。 */
|
|
18
|
+
export type ModelStreamEvent = {
|
|
18
19
|
type?: string;
|
|
19
20
|
delta?: unknown;
|
|
21
|
+
content?: unknown;
|
|
20
22
|
eventId?: unknown;
|
|
21
23
|
parentToolCallId?: unknown;
|
|
22
24
|
sourceTaskId?: unknown;
|
|
23
25
|
bgAgentId?: unknown;
|
|
24
|
-
}
|
|
26
|
+
};
|
|
25
27
|
/** 一条**流**的身份(不含 `eventId`:core 给每个内容事件铸各自的 eventId,拿它当流身份会把每块 delta
|
|
26
28
|
* 切成一段)。三键都缺席 = 宿主自己的流。 */
|
|
27
|
-
export interface
|
|
29
|
+
export interface ModelStreamIdent {
|
|
28
30
|
parentToolCallId?: string;
|
|
29
31
|
sourceTaskId?: string;
|
|
30
32
|
bgAgentId?: string;
|
|
31
33
|
}
|
|
34
|
+
/** live 面模型文本的帧(本登记册铸的全部四种):两族的逐块帧与各自的段末帧。 */
|
|
35
|
+
export type LiveModelTextFrame = (LiveEventIdentity & {
|
|
36
|
+
type: "text_delta" | "reasoning_delta";
|
|
37
|
+
delta: string;
|
|
38
|
+
}) | (SegmentEndFields & {
|
|
39
|
+
type: "text_end";
|
|
40
|
+
}) | ReasoningEndFrame;
|
|
32
41
|
/**
|
|
33
|
-
* 一条 live
|
|
42
|
+
* 🔴 **live 面模型文本的唯一铸点** —— 一条 live 腿上按**族 × 流身份**分账的段登记册(三条 live 腿共用:顶层流 / 转发子代腿 / 子代 tail 面)。
|
|
43
|
+
*
|
|
44
|
+
* ## 律(一条):凡出 wire 的模型文本经同一只脱敏器,不分帧
|
|
45
|
+
* 段末帧(`text_end.content` / `reasoning_end.content`)、`done.result`、账本 `text` / `reasoning` 行早就整段过 `redactModelText`;
|
|
46
|
+
* 逐块帧(`text_delta` / `reasoning_delta`)此前一个逐字、一个逐块脱敏 —— 跨块的凭据在两者上都留明文。现在逐块帧也只放**同一只脱敏器**判定过的字节:
|
|
47
|
+
* 每条流一只脱敏器的**流式口**(`trace/redact.ts` 的 `createRedactionStream`:喂入 / 取已判定前缀 / 收尾冲刷三口,同一只扫描器、同一张表):每块到达时喂入、
|
|
48
|
+
* 取出已判定的那一截放出(脱敏器自己的未决尾不出门,横跨切点的跨度整条不出);段末冲刷,余下的按整段读法放出,再发段末帧。
|
|
49
|
+
* ⇒ 一段的逐块帧依次拼接 = 该段段末帧的正文 —— 逐字节(凭据形换记号,不含凭据形的文本逐字节不变)。推理段 = 账本 `reasoning` 行(同一只段界谓词);
|
|
50
|
+
* 文字段的单位是引擎的文字块(`text_end` 收段),账本 `text` 行按 turn 拼接 —— 单文字块的 turn 上相等;锚与值分落在同一 turn 的两个文字块里时账本遮、段末帧与逐块帧不遮
|
|
51
|
+
* (单位之差随 `text_end` 既有,本登记册不另立单位;对抗复审 r1 medium)。
|
|
52
|
+
*
|
|
53
|
+
* ## 帧数与身份(消费端看得见的三件事)
|
|
54
|
+
* · 引擎的每一块 delta 仍恰好一帧、同一枚 `eventId`、原序(`delta` 可以是 `""`:那一块的字节还在窗里)—— 续流游标与 E18 的首块句柄不动;
|
|
55
|
+
* · 段末还在窗里的字节在段末帧**之前**一帧放出(同一族的逐块帧,带流身份三键、**不带** `eventId` ⇒ 不发 `id:` 行:它不是引擎的内容帧);
|
|
56
|
+
* · 延迟:一个字节在同一条流又到了脱敏器的未决尾上界(`PENDING_TAIL_UNITS` 个读法单元,由脱敏器的臂表算出)之后的下一次重扫时出门(重扫节律在流式口里);
|
|
57
|
+
* 盖住它的跨度还在判定(未收尾的栅栏 / 引号 / JSON 串值 …)⇒ 判定或段末。
|
|
58
|
+
*
|
|
59
|
+
* ## 段界(与账本腿同一只谓词)
|
|
60
|
+
* 两族都在本流的段界词({@link isModelSegmentBoundary})与腿终局 / 子代终态({@link LiveModelText.cut})收段;`text` 族另在引擎的 `text_end` 收段(它关的是散文段,
|
|
61
|
+
* 不是 turn 的结构边界 —— 推理段不因它收)。收段顺序:同一批里先散文、后推理(`text_end` 先于 `reasoning_end`,与契约的典型帧序同向)。
|
|
62
|
+
*
|
|
63
|
+
* 🔴 **为什么分账**(codex 对抗复审 R1 两根 [high],亲跑复现后按类修):一条腿上并发子代的逐块帧是**交错**到达的。一只累积器只有两种活法,两条都错:
|
|
64
|
+
* · 「换身份就收段」⇒ A 说一半、B 插一句、A 说另一半 ⇒ A 被切成两段,**跨块的凭据正好落在切口上**;
|
|
65
|
+
* · 「不换就不收」⇒ 两个子代的文字拼成一段,再盖上其中一个的身份键(串味 + 冤枉归属)。
|
|
66
|
+
* 一条流的段,只被**它自己**的段界或**它自己**的终态收走;别人说什么都与它无关。
|
|
34
67
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* ——本帧存在的唯一理由当场失效(实测:两枚 `reasoning_end` 拼起来仍是明文密钥);
|
|
39
|
-
* · 「不换就不收」⇒ 两个子代的思考拼成一段,再盖上其中一个的身份键(串味 + 冤枉归属)。
|
|
40
|
-
* 分账之后规则反而**更少**:一条流的段,只被**它自己**的段界或**它自己**的终态收走;别人说什么都与它无关。
|
|
68
|
+
* ## 投递态(tail 面:有没有人在听)
|
|
69
|
+
* `onEvent(ev, deliver)`:`deliver = false` 时只攒原文、照常按段界收段,不扫描、不出帧(tail 面的免投影快门);一条流从不投递转为投递时,放行位跳到**此刻**的段尾
|
|
70
|
+
* —— 之前的字节没人收,之后的字节仍按**整段**的上下文判定(晚到的订阅者在 `password=` 之后才开始听,值照样认得出)。段末帧的正文恒是整段。
|
|
41
71
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* 而不是「这条 run 一共派过多少子代」成为上界的那一手。
|
|
72
|
+
* 状态的界:每条流的条目在它的首块非空 delta 上建、在收段时删;腿终局 {@link LiveModelText.cut} 不带匹配器 = 全收全删。
|
|
73
|
+
* 子代终态那一次带匹配器的收段(转发腿的 `onTaskNotification`)让**活着的子代数**成为上界。
|
|
45
74
|
*/
|
|
46
|
-
export interface
|
|
47
|
-
/** 喂一帧 →
|
|
48
|
-
|
|
49
|
-
onEvent(
|
|
50
|
-
/** 收段:`match` 缺省 = 本腿**全部**流(腿终局 / 句柄终态);给了就只收匹配的那几条(某个子代终态)。
|
|
75
|
+
export interface LiveModelText {
|
|
76
|
+
/** 喂一帧 → 本帧要写的帧(按序):逐块帧 / 本流收段放出的余下字节 + 段末帧。`deliver` 缺省 = 投递。 */
|
|
77
|
+
onEvent(ev: ModelStreamEvent, deliver?: boolean): LiveModelTextFrame[];
|
|
78
|
+
/** 收段:`match` 缺省 = 本腿**全部**流(腿终局 / 句柄终态);给了就只收匹配的那几条(某个子代终态)。`deliver` 同 {@link onEvent}(缺省 = 投递)。
|
|
51
79
|
* 与账本腿 `LedgerSink.onDone → flush()` 同位同义 —— 段界表里没有终局词,终局走这扇门。 */
|
|
52
|
-
cut(match?: (ident:
|
|
80
|
+
cut(match?: (ident: ModelStreamIdent) => boolean, deliver?: boolean): LiveModelTextFrame[];
|
|
81
|
+
/** 没有开着的段(状态只有开着的段:空着的登记册与新建的一只等价,持有方可以删掉它、下一帧再建)。 */
|
|
82
|
+
isIdle(): boolean;
|
|
53
83
|
}
|
|
54
84
|
/**
|
|
55
85
|
* 一段推理的**段末事件 id** —— 唯一铸点,live 段末帧与账本 `reasoning` 行共用这一只。
|
|
@@ -78,8 +108,8 @@ export declare function reasoningSegmentEventId(anchor: unknown): string | undef
|
|
|
78
108
|
export declare function reasoningDeltaBytes(ev: {
|
|
79
109
|
delta?: unknown;
|
|
80
110
|
}): string | undefined;
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
export declare function
|
|
84
|
-
export declare function
|
|
111
|
+
/** 「这条流属于这只后台子代」—— 子代终态收段的匹配器。一只后台子代一个 id(引擎 7.61.0:它的帧的 `sourceTaskId`、
|
|
112
|
+
* 转发帧的 `bgAgentId`、完成通知的 `task_id` 都是它的注册表行 id),按那一个 id 认流。 */
|
|
113
|
+
export declare function modelStreamOfTask(taskId: string): (ident: ModelStreamIdent) => boolean;
|
|
114
|
+
export declare function createLiveModelText(): LiveModelText;
|
|
85
115
|
//# sourceMappingURL=model-segment.d.ts.map
|