@sema-agent/server 7.131.0 → 7.133.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 +575 -0
- package/README.md +12 -9
- package/README.zh-CN.md +9 -6
- package/USAGE.md +326 -98
- package/deploy/sema-up/README.md +19 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -2
- package/deploy/sema-up/chart/templates/server.yaml +5 -2
- package/deploy/sema-up/stack/compose.yaml +3 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +4 -2
- package/dist/adoption/plan.d.ts +3 -2
- package/dist/adoption/plan.js +7 -5
- package/dist/adoption/runner.js +3 -10
- package/dist/adoption/sql.d.ts +3 -2
- package/dist/adoption/sql.js +3 -5
- package/dist/adoption/wire.d.ts +4 -1
- package/dist/adoption/wire.js +1 -0
- package/dist/approval-ask-audit-store.d.ts +31 -13
- package/dist/approval-ask-audit-store.js +272 -74
- package/dist/approval-ask-machine.d.ts +15 -0
- package/dist/approval-ask-machine.js +6 -0
- package/dist/approval-ask-retention.d.ts +136 -0
- package/dist/approval-ask-retention.js +102 -0
- package/dist/approval-card.d.ts +82 -20
- package/dist/approval-card.js +46 -16
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval.d.ts +9 -0
- package/dist/approval.js +24 -3
- package/dist/audit.d.ts +33 -19
- package/dist/audit.js +12 -16
- package/dist/auth-bridge.d.ts +4 -0
- package/dist/auth-bridge.js +10 -11
- package/dist/bake-runner/main.js +3 -2
- package/dist/boot/deferred-sandbox-path-env.js +1 -1
- 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 +27 -12
- package/dist/boot/execution-lane.js +11 -0
- package/dist/boot/leader.js +2 -0
- package/dist/boot/memory-boundary.d.ts +2 -2
- package/dist/boot/memory-boundary.js +2 -2
- package/dist/boot/memory-consolidation.d.ts +5 -4
- package/dist/boot/memory-consolidation.js +7 -6
- package/dist/boot/org-delivery.d.ts +28 -0
- package/dist/boot/org-delivery.js +20 -0
- package/dist/boot/read-deny-anchor-audit.d.ts +17 -0
- package/dist/boot/read-deny-anchor-audit.js +36 -0
- package/dist/boot/reapers.d.ts +3 -0
- package/dist/boot/reapers.js +21 -1
- package/dist/boot/resolve-spec.d.ts +4 -5
- package/dist/boot/resolve-spec.js +74 -123
- package/dist/boot/runner-deps.d.ts +19 -8
- package/dist/boot/runner-deps.js +15 -2
- package/dist/boot/session-faces.d.ts +2 -7
- package/dist/boot/session-faces.js +4 -2
- package/dist/boot/stage-02-web-admin-pull.js +4 -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 +4 -2
- package/dist/boot/stage-06-runners.js +11 -7
- package/dist/boot/stage-07-capability-layer.d.ts +4 -2
- package/dist/boot/stage-07-capability-layer.js +27 -6
- package/dist/boot/stage-08-reapers.d.ts +4 -2
- package/dist/boot/stage-08-reapers.js +2 -2
- package/dist/boot/stage-09-leader.d.ts +6 -9
- package/dist/boot/stage-10-http-server.d.ts +6 -9
- package/dist/boot/stage-10-http-server.js +7 -9
- package/dist/boot/stores.d.ts +1 -1
- package/dist/boot/stores.js +7 -8
- package/dist/boot/web-admin.d.ts +4 -3
- package/dist/boot/web-admin.js +186 -98
- package/dist/boot/workflow-orchestration.d.ts +2 -0
- package/dist/boot/workflow-orchestration.js +2 -1
- package/dist/brain.js +25 -25
- package/dist/breaker-key.d.ts +6 -0
- package/dist/breaker-key.js +29 -0
- package/dist/budget.js +5 -4
- package/dist/caller-text-echo.d.ts +23 -0
- package/dist/caller-text-echo.js +21 -0
- package/dist/capabilities/brand-identity.d.ts +26 -0
- package/dist/capabilities/brand-identity.js +27 -0
- package/dist/capabilities/center-plugins.d.ts +7 -0
- 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 -1
- package/dist/capabilities/composite-members.js +1 -1
- package/dist/capabilities/engine-capabilities.js +2 -1
- package/dist/capabilities/execution-lane.js +2 -2
- package/dist/capabilities/hands-lane.d.ts +30 -6
- package/dist/capabilities/hands-lane.js +11 -1
- package/dist/capabilities/mcp-probe.d.ts +48 -3
- package/dist/capabilities/mcp-probe.js +47 -135
- package/dist/capabilities/scenarios.d.ts +95 -45
- package/dist/capabilities/scenarios.js +53 -38
- package/dist/capabilities/skills.d.ts +19 -4
- package/dist/capabilities/skills.js +30 -10
- package/dist/capability-facts.d.ts +34 -4
- package/dist/capability-facts.js +28 -2
- package/dist/center-config-tier.d.ts +69 -0
- package/dist/center-config-tier.js +42 -0
- package/dist/checkpoint-identity.d.ts +16 -0
- package/dist/checkpoint-identity.js +19 -0
- package/dist/config-catalog.d.ts +17 -10
- package/dist/config-catalog.js +47 -32
- package/dist/config-d-migration.d.ts +3 -1
- package/dist/config-d-migration.js +2 -2
- package/dist/config-dir-trust.d.ts +114 -0
- package/dist/config-dir-trust.js +388 -0
- package/dist/config-invariants.d.ts +18 -5
- package/dist/config-invariants.js +35 -3
- package/dist/config-lkg.d.ts +9 -9
- package/dist/config-lkg.js +20 -4
- package/dist/config-provider.d.ts +9 -2
- package/dist/config-provider.js +18 -6
- package/dist/config-types.d.ts +75 -20
- package/dist/config-types.js +8 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +137 -62
- package/dist/delegated-session-owner.d.ts +185 -0
- package/dist/delegated-session-owner.js +119 -0
- package/dist/device-protocol.d.ts +5 -3
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +21 -2
- package/dist/device-ws-protocol.d.ts +70 -6
- package/dist/device-ws-protocol.js +50 -22
- package/dist/elicitation.js +3 -2
- package/dist/entry-problems.d.ts +34 -0
- package/dist/entry-problems.js +14 -0
- 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 +56 -10
- package/dist/execution-lane-caps.js +50 -0
- package/dist/field-conflict.d.ts +43 -0
- package/dist/field-conflict.js +20 -0
- package/dist/fleet/fleet-bus.d.ts +80 -6
- package/dist/fleet/fleet-bus.js +41 -9
- package/dist/hooks/classic-stations.d.ts +91 -0
- package/dist/hooks/classic-stations.js +27 -0
- package/dist/hooks/command-spawn.d.ts +57 -0
- package/dist/hooks/command-spawn.js +139 -0
- package/dist/hooks/hook-llm.d.ts +8 -5
- package/dist/hooks/hook-llm.js +79 -36
- package/dist/hooks/hook-runner.d.ts +349 -95
- package/dist/hooks/hook-runner.js +855 -568
- package/dist/hooks/hook-source.d.ts +44 -0
- package/dist/hooks/hook-source.js +40 -0
- package/dist/http/active-run-conflict.d.ts +5 -13
- package/dist/http/active-run-conflict.js +17 -27
- package/dist/http/admission.d.ts +8 -2
- package/dist/http/admission.js +188 -101
- package/dist/http/approval-sweeps.js +99 -21
- package/dist/http/caller-trust.d.ts +77 -0
- package/dist/http/caller-trust.js +143 -0
- package/dist/http/checkpoint-ctx.d.ts +41 -24
- package/dist/http/checkpoint-ctx.js +23 -16
- package/dist/http/claimed-run.d.ts +14 -0
- package/dist/http/claimed-run.js +15 -0
- package/dist/http/device-placement.d.ts +2 -4
- package/dist/http/device-placement.js +7 -11
- package/dist/http/dispatch.d.ts +0 -4
- package/dist/http/dispatch.js +15 -13
- package/dist/http/durable-run-leg.d.ts +6 -33
- package/dist/http/durable-run-leg.js +36 -10
- package/dist/http/health-self-report.d.ts +7 -5
- package/dist/http/health-self-report.js +4 -18
- package/dist/http/owner-access.d.ts +56 -0
- package/dist/http/owner-access.js +42 -0
- package/dist/http/principal-gate.d.ts +70 -28
- package/dist/http/principal-gate.js +61 -15
- package/dist/http/readiness.d.ts +11 -5
- package/dist/http/readiness.js +10 -3
- package/dist/http/refusal-body.d.ts +21 -0
- package/dist/http/refusal-body.js +4 -0
- package/dist/http/request-guards.d.ts +43 -23
- package/dist/http/request-guards.js +53 -17
- package/dist/http/resume-ctx-read.d.ts +2 -5
- package/dist/http/resume-ctx-read.js +7 -4
- package/dist/http/resume-legs.d.ts +28 -4
- package/dist/http/resume-legs.js +169 -91
- package/dist/http/retired-service-deps.d.ts +43 -0
- package/dist/http/retired-service-deps.js +18 -0
- package/dist/http/route-ctx.d.ts +44 -28
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.js +2 -0
- package/dist/http/routes/a2a-serve.js +3 -4
- package/dist/http/routes/admin-config-refresh.js +1 -1
- package/dist/http/routes/admin-drain.js +1 -1
- package/dist/http/routes/admin-memory-optout.js +5 -1
- package/dist/http/routes/adoption.js +2 -9
- package/dist/http/routes/approvals-assistant.js +49 -48
- package/dist/http/routes/background.js +3 -2
- package/dist/http/routes/capabilities.js +21 -5
- package/dist/http/routes/config-catalog.d.ts +3 -3
- package/dist/http/routes/config-catalog.js +1 -1
- package/dist/http/routes/devices.js +3 -17
- package/dist/http/routes/diagnostics.js +6 -2
- package/dist/http/routes/images.js +6 -7
- package/dist/http/routes/leader.js +1 -8
- package/dist/http/routes/mcp-reconnect.d.ts +1 -1
- package/dist/http/routes/mcp-reconnect.js +3 -2
- package/dist/http/routes/memory-bundle.js +1 -1
- package/dist/http/routes/memory-compliance.js +1 -1
- package/dist/http/routes/memory-consolidation.js +1 -1
- package/dist/http/routes/memory-origin.js +1 -1
- package/dist/http/routes/memory-policy.d.ts +1 -1
- package/dist/http/routes/memory-policy.js +3 -2
- package/dist/http/routes/notify-wake.js +8 -21
- package/dist/http/routes/observability.js +2 -2
- package/dist/http/routes/principal-inbox.d.ts +39 -0
- package/dist/http/routes/principal-inbox.js +76 -0
- package/dist/http/routes/retention-ops.js +2 -9
- package/dist/http/routes/rules.js +5 -18
- package/dist/http/routes/runs.d.ts +5 -0
- package/dist/http/routes/runs.js +34 -107
- package/dist/http/routes/session-sync.js +15 -26
- package/dist/http/routes/sessions.js +30 -40
- package/dist/http/routes/shared-memory.js +2 -13
- package/dist/http/routes/side-query.js +8 -7
- package/dist/http/routes/tasks.js +67 -21
- package/dist/http/routes/workflows.d.ts +351 -0
- package/dist/http/routes/workflows.js +153 -119
- package/dist/http/send.d.ts +33 -10
- package/dist/http/send.js +21 -4
- package/dist/http/server.d.ts +27 -18
- package/dist/http/server.js +34 -6
- package/dist/http/stored-body-replay.js +17 -4
- package/dist/http/submit-ctx.d.ts +25 -0
- package/dist/http/submit-ctx.js +40 -0
- package/dist/http/submit-replay.d.ts +4 -3
- package/dist/http/submit-replay.js +5 -4
- package/dist/http/wire-types.d.ts +11 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/lane-home-probe.d.ts +112 -0
- package/dist/lane-home-probe.js +101 -0
- package/dist/leader/endpoint.d.ts +4 -1
- package/dist/leader/endpoint.js +11 -10
- package/dist/limit-refusal.d.ts +59 -0
- package/dist/limit-refusal.js +15 -0
- package/dist/main.js +1 -1
- package/dist/mcp-assertion-header.d.ts +32 -19
- package/dist/mcp-assertion-header.js +10 -9
- package/dist/mcp-tool-faces.d.ts +5 -0
- package/dist/mcp-tool-faces.js +6 -4
- package/dist/memory-project-layer.d.ts +37 -0
- package/dist/memory-project-layer.js +46 -0
- package/dist/memory-scope.d.ts +24 -17
- package/dist/memory-scope.js +24 -8
- package/dist/memory-sync-client.d.ts +27 -13
- package/dist/memory-sync-client.js +107 -18
- package/dist/model-entry-refusal.d.ts +9 -1
- package/dist/model-entry-refusal.js +6 -1
- package/dist/model-plane-face.d.ts +51 -0
- package/dist/model-plane-face.js +24 -0
- package/dist/model-provider.d.ts +44 -12
- package/dist/model-provider.js +21 -2
- package/dist/model-route-endpoint.d.ts +9 -12
- package/dist/model-route-endpoint.js +8 -11
- package/dist/model-route-env.d.ts +22 -0
- package/dist/model-route-env.js +2 -0
- package/dist/model-route-gap.d.ts +60 -30
- package/dist/model-route-gap.js +21 -15
- package/dist/observability/corrupt-read-seat.d.ts +7 -0
- package/dist/observability/corrupt-read-seat.js +9 -0
- package/dist/observability/cost-taxonomy.d.ts +7 -7
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +18 -4
- package/dist/observability/fail-open.d.ts +76 -14
- package/dist/observability/fail-open.js +76 -14
- package/dist/observability/metrics.js +4 -1
- package/dist/observability/prompt-manifest.d.ts +33 -82
- package/dist/observability/prompt-manifest.js +122 -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 +58 -49
- package/dist/operator-ask.d.ts +10 -0
- package/dist/operator-ask.js +3 -0
- package/dist/orchestration/workflow-agent-session-index.d.ts +12 -12
- package/dist/orchestration/workflow-agent-session-index.js +9 -13
- package/dist/orchestration/workflow-completion-inbox.d.ts +42 -15
- package/dist/orchestration/workflow-completion-inbox.js +13 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +13 -32
- package/dist/orchestration/workflow-notify-journal.js +27 -34
- package/dist/orchestration/workflow-park-decision.d.ts +89 -0
- package/dist/orchestration/workflow-park-decision.js +118 -0
- package/dist/org-delivery-gate.d.ts +81 -0
- package/dist/org-delivery-gate.js +59 -0
- package/dist/panel-tool-names.d.ts +23 -0
- package/dist/panel-tool-names.js +8 -0
- package/dist/parked-decide.d.ts +39 -6
- package/dist/parked-decide.js +98 -51
- package/dist/parked-revive-surface.d.ts +9 -2
- package/dist/parked-revive-surface.js +11 -8
- package/dist/per-task-image.d.ts +7 -1
- package/dist/per-task-image.js +3 -3
- package/dist/permission-rule-list.d.ts +1 -1
- package/dist/permission-rule-list.js +2 -2
- package/dist/plain-string-record.d.ts +25 -0
- package/dist/plain-string-record.js +32 -0
- package/dist/plugins/approval-ask-store-file.d.ts +16 -1
- package/dist/plugins/approval-ask-store-file.js +21 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +18 -1
- package/dist/plugins/approval-ask-store-memory.js +34 -2
- package/dist/plugins/approval-ask-store-sql.d.ts +25 -0
- package/dist/plugins/approval-ask-store-sql.js +37 -1
- package/dist/plugins/blob-backend.d.ts +83 -15
- package/dist/plugins/blob-backend.js +68 -15
- package/dist/plugins/breaker-state-sql.d.ts +2 -2
- package/dist/plugins/breaker-state-sql.js +4 -4
- package/dist/plugins/caching-session-store.d.ts +3 -0
- package/dist/plugins/caching-session-store.js +3 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +28 -4
- package/dist/plugins/checkpoint-store-sql.js +59 -28
- package/dist/plugins/file-history-store-sql.d.ts +5 -2
- package/dist/plugins/file-history-store-sql.js +3 -1
- package/dist/plugins/file-run-store.d.ts +5 -13
- package/dist/plugins/file-run-store.js +9 -0
- package/dist/plugins/fork-routing-session-store.d.ts +9 -1
- package/dist/plugins/fork-routing-session-store.js +12 -1
- package/dist/plugins/host-platform.d.ts +2 -0
- package/dist/plugins/host-platform.js +2 -1
- 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.d.ts +2 -0
- package/dist/plugins/local-checkpoint-store.js +11 -3
- package/dist/plugins/local-session-store.d.ts +1 -1
- package/dist/plugins/local-session-store.js +1 -1
- package/dist/plugins/local-session-window.d.ts +39 -0
- package/dist/plugins/local-session-window.js +54 -0
- package/dist/plugins/mailbox-recipient-lifecycle.d.ts +3 -2
- package/dist/plugins/mailbox-store-sql.d.ts +30 -48
- package/dist/plugins/mailbox-store-sql.js +77 -52
- package/dist/plugins/memory-embedder-fingerprint.js +2 -1
- package/dist/plugins/memory-run-store.d.ts +5 -13
- package/dist/plugins/memory-run-store.js +8 -0
- package/dist/plugins/one-time-migrations.d.ts +245 -93
- package/dist/plugins/one-time-migrations.js +668 -207
- package/dist/plugins/org-delivery-quota-store.d.ts +123 -0
- package/dist/plugins/org-delivery-quota-store.js +228 -0
- 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-pool.js +39 -7
- package/dist/plugins/pg-session-storage.d.ts +20 -8
- package/dist/plugins/pg-session-storage.js +34 -21
- package/dist/plugins/remote-env-adb.d.ts +12 -12
- package/dist/plugins/remote-env-adb.js +21 -6
- 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 +103 -38
- package/dist/plugins/remote-env-k8s.js +288 -95
- package/dist/plugins/remote-env-local-docker.d.ts +27 -13
- package/dist/plugins/remote-env-local-docker.js +82 -11
- package/dist/plugins/remote-env-ssh.d.ts +21 -12
- package/dist/plugins/remote-env-ssh.js +117 -5
- 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/run-store-sql.d.ts +16 -14
- package/dist/plugins/run-store-sql.js +22 -2
- package/dist/plugins/schema-consistency.d.ts +54 -0
- package/dist/plugins/schema-consistency.js +52 -0
- package/dist/plugins/schema-indexes.js +2 -0
- package/dist/plugins/send-user-file.js +2 -2
- package/dist/plugins/session-epoch-anchor.d.ts +39 -0
- package/dist/plugins/session-epoch-anchor.js +22 -0
- package/dist/plugins/session-store.d.ts +18 -8
- package/dist/plugins/session-store.js +15 -4
- 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 +205 -1
- package/dist/plugins/sql-driver.js +325 -13
- package/dist/plugins/sql-errors.d.ts +64 -0
- package/dist/plugins/sql-errors.js +57 -0
- package/dist/plugins/store-backend.d.ts +36 -1
- package/dist/plugins/store-backend.js +42 -15
- package/dist/plugins/store-contracts.d.ts +42 -0
- package/dist/plugins/store-contracts.js +1 -0
- package/dist/plugins/tidb-pool.d.ts +6 -1
- package/dist/plugins/tidb-pool.js +44 -10
- package/dist/plugins/tidb-session-storage.d.ts +8 -11
- package/dist/plugins/tidb-session-storage.js +6 -16
- package/dist/plugins/tidb-session-store.d.ts +24 -4
- package/dist/plugins/tidb-session-store.js +29 -5
- package/dist/plugins/workflow-journal-store-sql.d.ts +73 -19
- package/dist/plugins/workflow-journal-store-sql.js +19 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +30 -8
- package/dist/plugins/workflow-run-store-sql.js +50 -9
- package/dist/posture-source.d.ts +18 -10
- package/dist/posture-source.js +4 -1
- package/dist/project-identity.d.ts +45 -6
- package/dist/project-identity.js +162 -8
- package/dist/project-layer-key.d.ts +28 -0
- package/dist/project-layer-key.js +29 -0
- package/dist/prompts-domain-validate.d.ts +17 -61
- package/dist/prompts-domain-validate.js +9 -119
- package/dist/question.js +3 -2
- package/dist/read-deny-entry.d.ts +25 -0
- package/dist/read-deny-entry.js +12 -0
- package/dist/read-face-posture.d.ts +37 -11
- package/dist/read-face-posture.js +32 -3
- package/dist/request-key-closure.d.ts +9 -2
- package/dist/request-key-closure.js +11 -5
- package/dist/request-value-closure.d.ts +5 -0
- package/dist/request-value-closure.js +11 -3
- package/dist/rule-entry-list.d.ts +38 -11
- package/dist/rule-entry-list.js +106 -30
- package/dist/rules-consent.js +3 -4
- package/dist/run-acceptance.d.ts +19 -3
- package/dist/run-acceptance.js +13 -1
- package/dist/run-local.js +54 -24
- package/dist/runs.d.ts +15 -8
- package/dist/runs.js +35 -1
- package/dist/runtime-caps-resolver.d.ts +16 -6
- package/dist/runtime-caps-resolver.js +18 -5
- package/dist/sandbox-pkg-source.d.ts +19 -1
- package/dist/sandbox-pkg-source.js +29 -7
- package/dist/security.d.ts +87 -9
- package/dist/security.js +52 -9
- package/dist/server-secret-env.d.ts +44 -18
- package/dist/server-secret-env.js +49 -8
- package/dist/session-error-wire.d.ts +19 -2
- package/dist/session-error-wire.js +5 -1
- package/dist/session-incarnation.d.ts +15 -5
- package/dist/session-incarnation.js +16 -9
- package/dist/session-titled-frame.d.ts +33 -0
- package/dist/session-titled-frame.js +4 -0
- package/dist/session-titler.d.ts +9 -1
- package/dist/session-titler.js +27 -6
- package/dist/spec-fields.d.ts +28 -16
- package/dist/spec-fields.js +66 -54
- package/dist/sql-engine-posture.d.ts +31 -4
- package/dist/sql-engine-posture.js +36 -1
- package/dist/stored-request-tool-axes-m19.d.ts +19 -4
- 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-cwd.d.ts +1 -1
- package/dist/task-mcp.d.ts +46 -58
- package/dist/task-mcp.js +82 -107
- package/dist/task-settings.d.ts +95 -108
- package/dist/task-settings.js +77 -98
- package/dist/text-bidi.d.ts +1 -48
- package/dist/text-bidi.js +3 -5
- package/dist/tighten-only-seats.d.ts +150 -0
- package/dist/tighten-only-seats.js +196 -0
- package/dist/tool-approval.d.ts +304 -88
- package/dist/tool-approval.js +623 -239
- package/dist/trace/core-keyset-guard.d.ts +122 -20
- package/dist/trace/engine-notice-wire.d.ts +11 -3
- package/dist/trace/engine-notice-wire.js +8 -1
- package/dist/trace/exit-seat.d.ts +28 -0
- package/dist/trace/exit-seat.js +76 -0
- package/dist/trace/ledger-events.d.ts +6 -3
- package/dist/trace/ledger-sink.js +4 -1
- package/dist/trace/model-segment.js +1 -1
- package/dist/trace/project.d.ts +98 -17
- package/dist/trace/project.js +98 -50
- package/dist/trace/projection-table.d.ts +100 -0
- package/dist/trace/projection-table.js +130 -0
- package/dist/trace/redact.d.ts +54 -0
- package/dist/trace/redact.js +778 -152
- package/dist/trace/self-minted-wire.d.ts +345 -1
- package/dist/trace/self-minted-wire.js +117 -1
- package/dist/trace/wire-projection-faces.d.ts +377 -3
- package/dist/trace/wire-projection-faces.js +164 -1
- package/dist/url-refusal.js +2 -0
- package/dist/web-admin-client/apply-effective.d.ts +12 -0
- package/dist/web-admin-client/apply-effective.js +56 -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/facade.d.ts +1 -1
- package/dist/web-admin-client/facade.js +1 -1
- package/dist/web-admin-client/http-client.js +0 -6
- package/dist/web-admin-client/read-face.js +5 -9
- 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 +11 -9
- package/dist/web-admin-client/types.d.ts +2 -3
- 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 +65 -10
- package/package.json +8 -4
- package/scripts/drain-check-local.mjs +34 -1
- 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,4 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { type WorkflowRun } from "@sema-agent/core";
|
|
3
|
+
import { type Admit } from "../../trace/projection-table.js";
|
|
2
4
|
import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
3
5
|
/** SVC-5 的 steer 路——`handle()` 里位置在 tasks/runs 之后(鉴权门之后),故是**独立**的域入口。 */
|
|
4
6
|
/** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;`
|
|
@@ -6,6 +8,354 @@ import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
|
6
8
|
export declare function handleWorkflows(req: IncomingMessage, res: ServerResponse, match: RouteMatch<WorkflowsRouteId>, ctx: RouteCtx): Promise<void>;
|
|
7
9
|
/** 同上纪律(SVC-5 steer 段)。 */
|
|
8
10
|
export declare function handleWorkflowAgentSteer(req: IncomingMessage, res: ServerResponse, match: RouteMatch<WorkflowAgentSteerRouteId>, ctx: RouteCtx): Promise<void>;
|
|
11
|
+
type WorkflowPhaseRow = WorkflowRun["phases"][number];
|
|
12
|
+
type WorkflowAgentRow = WorkflowRun["agents"][number];
|
|
13
|
+
type WorkflowGroupRow = WorkflowRun["groups"][number];
|
|
14
|
+
/**
|
|
15
|
+
* 组森林(`groups` 的 `rows` 与节点的 `children` 读同一份,每次投影建一次,经根传给两处):按 `groupId` 建索引(重号后写赢、位次取首次出现),父在索引里、
|
|
16
|
+
* 不是自己、且自己不在环上 ⇒ 挂到父下;否则(顶层 / 悬挂父 / 环成员)⇒ 挂到根下,一个都不丢。环判走父链、有界,坏存量既挂不住也
|
|
17
|
+
* 造不出 `JSON.stringify` 会抛的环。不跨调用记忆(内存店交出的可能是一只还在长的活对象),也不按节点重建(那是 O(N²·深度))。
|
|
18
|
+
*/
|
|
19
|
+
export interface GroupForest {
|
|
20
|
+
readonly roots: readonly WorkflowGroupRow[];
|
|
21
|
+
readonly childrenOf: ReadonlyMap<WorkflowGroupRow, readonly WorkflowGroupRow[]>;
|
|
22
|
+
}
|
|
23
|
+
/** 详情面九张表的铸键与 `rows` 读到的根:原记录 + 本次投影建一次的组森林。 */
|
|
24
|
+
export interface WorkflowDetailRoot {
|
|
25
|
+
readonly run: WorkflowRun;
|
|
26
|
+
readonly forest: GroupForest;
|
|
27
|
+
}
|
|
28
|
+
/** `parks[]`(core 7.17.0 [ref] 义务①:park 真值来自店;读面**逐键挑**,不是展开)。 */
|
|
29
|
+
export declare const WORKFLOW_PARK_ROW_DISPOSITIONS: {
|
|
30
|
+
readonly callKey: "forward";
|
|
31
|
+
readonly sessionId: "forward";
|
|
32
|
+
readonly token: "strip";
|
|
33
|
+
readonly originRunId: "forward";
|
|
34
|
+
readonly originUnconfirmed: {
|
|
35
|
+
readonly forward: Admit;
|
|
36
|
+
};
|
|
37
|
+
readonly parkedBy: "forward";
|
|
38
|
+
readonly generation: "forward";
|
|
39
|
+
};
|
|
40
|
+
export declare const WORKFLOW_PHASE_DISPOSITIONS: {
|
|
41
|
+
readonly title: {
|
|
42
|
+
readonly redact: "redactSecrets";
|
|
43
|
+
};
|
|
44
|
+
readonly status: "forward";
|
|
45
|
+
readonly detail: "strip";
|
|
46
|
+
readonly model: "strip";
|
|
47
|
+
readonly agentFailures: "strip";
|
|
48
|
+
readonly startedAt: "forward";
|
|
49
|
+
readonly endedAt: "forward";
|
|
50
|
+
readonly durationMs: {
|
|
51
|
+
readonly mint: (p: WorkflowPhaseRow) => number | undefined;
|
|
52
|
+
};
|
|
53
|
+
readonly done: {
|
|
54
|
+
readonly mint: (p: WorkflowPhaseRow, root: WorkflowDetailRoot) => number;
|
|
55
|
+
};
|
|
56
|
+
readonly total: {
|
|
57
|
+
readonly mint: (p: WorkflowPhaseRow, root: WorkflowDetailRoot) => number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/** 活动拍(core 1.295 起两拍都带 `at`):结构位 + core 已脱敏的短 `arg`。表序让两拍各自保持生产者的键序(start 无 `isError`、end 无 `arg`)。 */
|
|
61
|
+
export declare const WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS: {
|
|
62
|
+
readonly phase: "forward";
|
|
63
|
+
readonly toolCallId: "forward";
|
|
64
|
+
readonly toolName: "forward";
|
|
65
|
+
readonly isError: "forward";
|
|
66
|
+
readonly at: "forward";
|
|
67
|
+
readonly arg: "forward";
|
|
68
|
+
};
|
|
69
|
+
export declare const WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS: {
|
|
70
|
+
readonly askIds: "forward";
|
|
71
|
+
readonly oldestCreatedAtMs: "forward";
|
|
72
|
+
};
|
|
73
|
+
export declare const WORKFLOW_AGENT_DISPOSITIONS: {
|
|
74
|
+
readonly label: {
|
|
75
|
+
readonly redact: "redactSecrets";
|
|
76
|
+
};
|
|
77
|
+
readonly status: "forward";
|
|
78
|
+
readonly displayStatus: {
|
|
79
|
+
readonly mint: (a: WorkflowAgentRow, root: WorkflowDetailRoot) => import("@sema-agent/core").AgentDisplayStatus;
|
|
80
|
+
};
|
|
81
|
+
readonly taskStatus: "forward";
|
|
82
|
+
readonly callKey: "forward";
|
|
83
|
+
readonly groupId: "forward";
|
|
84
|
+
readonly phase: {
|
|
85
|
+
readonly redact: "redactSecrets";
|
|
86
|
+
};
|
|
87
|
+
readonly model: "forward";
|
|
88
|
+
readonly tokens: {
|
|
89
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
90
|
+
};
|
|
91
|
+
readonly turns: {
|
|
92
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
93
|
+
};
|
|
94
|
+
readonly toolCalls: "forward";
|
|
95
|
+
readonly activity: {
|
|
96
|
+
readonly nested: {
|
|
97
|
+
readonly phase: "forward";
|
|
98
|
+
readonly toolCallId: "forward";
|
|
99
|
+
readonly toolName: "forward";
|
|
100
|
+
readonly isError: "forward";
|
|
101
|
+
readonly at: "forward";
|
|
102
|
+
readonly arg: "forward";
|
|
103
|
+
};
|
|
104
|
+
readonly rows: "each";
|
|
105
|
+
};
|
|
106
|
+
readonly lastActivityAt: {
|
|
107
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
108
|
+
};
|
|
109
|
+
readonly durationMs: {
|
|
110
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
111
|
+
};
|
|
112
|
+
readonly queuedAt: "forward";
|
|
113
|
+
readonly startedAt: "forward";
|
|
114
|
+
readonly endedAt: "forward";
|
|
115
|
+
readonly replayed: "forward";
|
|
116
|
+
readonly prompt: "forward";
|
|
117
|
+
readonly output: "forward";
|
|
118
|
+
readonly pendingApproval: {
|
|
119
|
+
readonly nested: {
|
|
120
|
+
readonly askIds: "forward";
|
|
121
|
+
readonly oldestCreatedAtMs: "forward";
|
|
122
|
+
};
|
|
123
|
+
readonly admit: (raw: unknown) => boolean;
|
|
124
|
+
};
|
|
125
|
+
readonly approvalWaitedMs: {
|
|
126
|
+
readonly forward: (raw: unknown) => boolean;
|
|
127
|
+
};
|
|
128
|
+
readonly taskRunId: "forward";
|
|
129
|
+
readonly errorCode: "strip";
|
|
130
|
+
readonly errorMessage: "strip";
|
|
131
|
+
readonly stats: "strip";
|
|
132
|
+
readonly attempts: "strip";
|
|
133
|
+
readonly lastAttemptReason: "strip";
|
|
134
|
+
readonly sessionId: "strip";
|
|
135
|
+
readonly parkedCheckpointToken: "strip";
|
|
136
|
+
readonly worktreeDir: "strip";
|
|
137
|
+
};
|
|
138
|
+
export declare const WORKFLOW_GROUP_DISPOSITIONS: {
|
|
139
|
+
readonly groupId: "forward";
|
|
140
|
+
readonly parentGroupId: "forward";
|
|
141
|
+
readonly status: "forward";
|
|
142
|
+
readonly startedAt: "forward";
|
|
143
|
+
readonly endedAt: "forward";
|
|
144
|
+
readonly durationMs: {
|
|
145
|
+
readonly mint: (g: WorkflowGroupRow) => number | undefined;
|
|
146
|
+
};
|
|
147
|
+
readonly agentCallKeys: {
|
|
148
|
+
readonly mint: (g: WorkflowGroupRow, root: WorkflowDetailRoot) => string[];
|
|
149
|
+
};
|
|
150
|
+
readonly children: {
|
|
151
|
+
readonly mint: (g: WorkflowGroupRow, root: WorkflowDetailRoot) => unknown;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
export declare const WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS: {
|
|
155
|
+
readonly tokens: "forward";
|
|
156
|
+
readonly turns: "forward";
|
|
157
|
+
readonly tasks: "forward";
|
|
158
|
+
readonly costMicroUsd: "forward";
|
|
159
|
+
};
|
|
160
|
+
/** run 级用量(本 run 自己的 + 嵌套的,core R-5 分开记)。 */
|
|
161
|
+
export declare const WORKFLOW_RUN_STATS_DISPOSITIONS: {
|
|
162
|
+
readonly tokens: "forward";
|
|
163
|
+
readonly turns: "forward";
|
|
164
|
+
readonly costMicroUsd: "forward";
|
|
165
|
+
readonly nested: {
|
|
166
|
+
readonly nested: {
|
|
167
|
+
readonly tokens: "forward";
|
|
168
|
+
readonly turns: "forward";
|
|
169
|
+
readonly tasks: "forward";
|
|
170
|
+
readonly costMicroUsd: "forward";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
export declare const WORKFLOW_RUN_DISPOSITIONS: {
|
|
175
|
+
readonly id: "forward";
|
|
176
|
+
readonly scope: "forward";
|
|
177
|
+
readonly status: "forward";
|
|
178
|
+
readonly name: {
|
|
179
|
+
readonly redact: "redactSecrets";
|
|
180
|
+
};
|
|
181
|
+
readonly description: {
|
|
182
|
+
readonly redact: "redactSecrets";
|
|
183
|
+
};
|
|
184
|
+
readonly stats: {
|
|
185
|
+
readonly nested: {
|
|
186
|
+
readonly tokens: "forward";
|
|
187
|
+
readonly turns: "forward";
|
|
188
|
+
readonly costMicroUsd: "forward";
|
|
189
|
+
readonly nested: {
|
|
190
|
+
readonly nested: {
|
|
191
|
+
readonly tokens: "forward";
|
|
192
|
+
readonly turns: "forward";
|
|
193
|
+
readonly tasks: "forward";
|
|
194
|
+
readonly costMicroUsd: "forward";
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
readonly agentFailures: "forward";
|
|
200
|
+
readonly startedAt: "forward";
|
|
201
|
+
readonly endedAt: "forward";
|
|
202
|
+
readonly createdAt: "forward";
|
|
203
|
+
readonly durationMs: {
|
|
204
|
+
readonly mint: (run: WorkflowRun) => number | undefined;
|
|
205
|
+
};
|
|
206
|
+
readonly rev: "forward";
|
|
207
|
+
readonly error: {
|
|
208
|
+
readonly redact: "redactErrorMessage";
|
|
209
|
+
};
|
|
210
|
+
readonly errorCode: "forward";
|
|
211
|
+
readonly parks: {
|
|
212
|
+
readonly nested: {
|
|
213
|
+
readonly callKey: "forward";
|
|
214
|
+
readonly sessionId: "forward";
|
|
215
|
+
readonly token: "strip";
|
|
216
|
+
readonly originRunId: "forward";
|
|
217
|
+
readonly originUnconfirmed: {
|
|
218
|
+
readonly forward: Admit;
|
|
219
|
+
};
|
|
220
|
+
readonly parkedBy: "forward";
|
|
221
|
+
readonly generation: "forward";
|
|
222
|
+
};
|
|
223
|
+
readonly rows: "each";
|
|
224
|
+
};
|
|
225
|
+
readonly resumeAdmissionIncomplete: {
|
|
226
|
+
readonly forward: Admit;
|
|
227
|
+
};
|
|
228
|
+
readonly result: {
|
|
229
|
+
readonly redact: "redactSecrets";
|
|
230
|
+
};
|
|
231
|
+
readonly phases: {
|
|
232
|
+
readonly nested: {
|
|
233
|
+
readonly title: {
|
|
234
|
+
readonly redact: "redactSecrets";
|
|
235
|
+
};
|
|
236
|
+
readonly status: "forward";
|
|
237
|
+
readonly detail: "strip";
|
|
238
|
+
readonly model: "strip";
|
|
239
|
+
readonly agentFailures: "strip";
|
|
240
|
+
readonly startedAt: "forward";
|
|
241
|
+
readonly endedAt: "forward";
|
|
242
|
+
readonly durationMs: {
|
|
243
|
+
readonly mint: (p: WorkflowPhaseRow) => number | undefined;
|
|
244
|
+
};
|
|
245
|
+
readonly done: {
|
|
246
|
+
readonly mint: (p: WorkflowPhaseRow, root: WorkflowDetailRoot) => number;
|
|
247
|
+
};
|
|
248
|
+
readonly total: {
|
|
249
|
+
readonly mint: (p: WorkflowPhaseRow, root: WorkflowDetailRoot) => number;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
readonly rows: "each";
|
|
253
|
+
};
|
|
254
|
+
readonly unphased: {
|
|
255
|
+
readonly mint: (run: WorkflowRun) => {
|
|
256
|
+
done: number;
|
|
257
|
+
total: number;
|
|
258
|
+
} | undefined;
|
|
259
|
+
};
|
|
260
|
+
readonly agents: {
|
|
261
|
+
readonly nested: {
|
|
262
|
+
readonly label: {
|
|
263
|
+
readonly redact: "redactSecrets";
|
|
264
|
+
};
|
|
265
|
+
readonly status: "forward";
|
|
266
|
+
readonly displayStatus: {
|
|
267
|
+
readonly mint: (a: WorkflowAgentRow, root: WorkflowDetailRoot) => import("@sema-agent/core").AgentDisplayStatus;
|
|
268
|
+
};
|
|
269
|
+
readonly taskStatus: "forward";
|
|
270
|
+
readonly callKey: "forward";
|
|
271
|
+
readonly groupId: "forward";
|
|
272
|
+
readonly phase: {
|
|
273
|
+
readonly redact: "redactSecrets";
|
|
274
|
+
};
|
|
275
|
+
readonly model: "forward";
|
|
276
|
+
readonly tokens: {
|
|
277
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
278
|
+
};
|
|
279
|
+
readonly turns: {
|
|
280
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
281
|
+
};
|
|
282
|
+
readonly toolCalls: "forward";
|
|
283
|
+
readonly activity: {
|
|
284
|
+
readonly nested: {
|
|
285
|
+
readonly phase: "forward";
|
|
286
|
+
readonly toolCallId: "forward";
|
|
287
|
+
readonly toolName: "forward";
|
|
288
|
+
readonly isError: "forward";
|
|
289
|
+
readonly at: "forward";
|
|
290
|
+
readonly arg: "forward";
|
|
291
|
+
};
|
|
292
|
+
readonly rows: "each";
|
|
293
|
+
};
|
|
294
|
+
readonly lastActivityAt: {
|
|
295
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
296
|
+
};
|
|
297
|
+
readonly durationMs: {
|
|
298
|
+
readonly mint: (a: WorkflowAgentRow) => number | undefined;
|
|
299
|
+
};
|
|
300
|
+
readonly queuedAt: "forward";
|
|
301
|
+
readonly startedAt: "forward";
|
|
302
|
+
readonly endedAt: "forward";
|
|
303
|
+
readonly replayed: "forward";
|
|
304
|
+
readonly prompt: "forward";
|
|
305
|
+
readonly output: "forward";
|
|
306
|
+
readonly pendingApproval: {
|
|
307
|
+
readonly nested: {
|
|
308
|
+
readonly askIds: "forward";
|
|
309
|
+
readonly oldestCreatedAtMs: "forward";
|
|
310
|
+
};
|
|
311
|
+
readonly admit: (raw: unknown) => boolean;
|
|
312
|
+
};
|
|
313
|
+
readonly approvalWaitedMs: {
|
|
314
|
+
readonly forward: (raw: unknown) => boolean;
|
|
315
|
+
};
|
|
316
|
+
readonly taskRunId: "forward";
|
|
317
|
+
readonly errorCode: "strip";
|
|
318
|
+
readonly errorMessage: "strip";
|
|
319
|
+
readonly stats: "strip";
|
|
320
|
+
readonly attempts: "strip";
|
|
321
|
+
readonly lastAttemptReason: "strip";
|
|
322
|
+
readonly sessionId: "strip";
|
|
323
|
+
readonly parkedCheckpointToken: "strip";
|
|
324
|
+
readonly worktreeDir: "strip";
|
|
325
|
+
};
|
|
326
|
+
readonly rows: "each";
|
|
327
|
+
};
|
|
328
|
+
readonly groups: {
|
|
329
|
+
readonly nested: {
|
|
330
|
+
readonly groupId: "forward";
|
|
331
|
+
readonly parentGroupId: "forward";
|
|
332
|
+
readonly status: "forward";
|
|
333
|
+
readonly startedAt: "forward";
|
|
334
|
+
readonly endedAt: "forward";
|
|
335
|
+
readonly durationMs: {
|
|
336
|
+
readonly mint: (g: WorkflowGroupRow) => number | undefined;
|
|
337
|
+
};
|
|
338
|
+
readonly agentCallKeys: {
|
|
339
|
+
readonly mint: (g: WorkflowGroupRow, root: WorkflowDetailRoot) => string[];
|
|
340
|
+
};
|
|
341
|
+
readonly children: {
|
|
342
|
+
readonly mint: (g: WorkflowGroupRow, root: WorkflowDetailRoot) => unknown;
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
readonly rows: (_groups: readonly WorkflowGroupRow[], root: WorkflowDetailRoot) => readonly import("@sema-agent/core").WorkflowGroup[];
|
|
346
|
+
};
|
|
347
|
+
readonly sourceTaskId: "strip";
|
|
348
|
+
readonly originatingSessionId: "strip";
|
|
349
|
+
readonly effectiveArgs: "strip";
|
|
350
|
+
readonly budgetOvershoot: "strip";
|
|
351
|
+
readonly timeoutInterruption: "strip";
|
|
352
|
+
readonly resultFull: "strip";
|
|
353
|
+
readonly completionId: "strip";
|
|
354
|
+
readonly resume: "strip";
|
|
355
|
+
readonly journalSkips: "strip";
|
|
356
|
+
};
|
|
357
|
+
/** SVC-4 v1 详情体 = 根表的一次解释(见上方表头注);组森林在这里建一次,经根交给 `rows` 与 `children`。 */
|
|
358
|
+
export declare function summarizeWorkflowDetail(run: WorkflowRun): Record<string, unknown>;
|
|
9
359
|
export declare const WORKFLOWS_ROUTES: readonly [{
|
|
10
360
|
readonly id: "workflows-list";
|
|
11
361
|
readonly path: "/v1/workflows";
|
|
@@ -36,4 +386,5 @@ export declare const WORKFLOW_AGENT_STEER_ROUTES: readonly [{
|
|
|
36
386
|
readonly methods: readonly ["POST"];
|
|
37
387
|
}];
|
|
38
388
|
export type WorkflowAgentSteerRouteId = RouteIdsOf<typeof WORKFLOW_AGENT_STEER_ROUTES>;
|
|
389
|
+
export {};
|
|
39
390
|
//# sourceMappingURL=workflows.d.ts.map
|
|
@@ -6,7 +6,8 @@ import { journalEntryOfBody, journalEntryPayload, journalRowPayloadOf, readJourn
|
|
|
6
6
|
import { decodeJsonColumn } from "../../plugins/sql-json-column.js";
|
|
7
7
|
import { redactSecrets } from "../../trace/redact.js";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
|
-
import {
|
|
9
|
+
import { redactHead } from "../../observability/run-terminal.js";
|
|
10
|
+
import { projectByTable } from "../../trace/projection-table.js";
|
|
10
11
|
const JOURNAL_PROJECTION_MEMO_CAP = 1024;
|
|
11
12
|
const journalProjectionMemo = new Map();
|
|
12
13
|
import { sendJson, sendError, sseHeaders } from "../send.js";
|
|
@@ -177,14 +178,7 @@ export async function handleWorkflowAgentSteer(req, res, match, ctx) {
|
|
|
177
178
|
sendError(res, 400, "request.path_malformed", "malformed workflow path (invalid percent-encoding)");
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
try {
|
|
182
|
-
body = (await readJson(req));
|
|
183
|
-
}
|
|
184
|
-
catch {
|
|
185
|
-
sendError(res, 400, "request.invalid_json", "invalid JSON body");
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
181
|
+
const body = (await readJson(req));
|
|
188
182
|
if (typeof body.content !== "string" || body.content.length === 0) {
|
|
189
183
|
sendError(res, 400, "request.body_shape", "body must be { content: string (non-empty) }");
|
|
190
184
|
return;
|
|
@@ -200,7 +194,7 @@ export async function handleWorkflowAgentSteer(req, res, match, ctx) {
|
|
|
200
194
|
sendError(res, 413, "steer.content_too_large", `content exceeds ${STEER_IN_MAX_REQUEST_CHARS} characters (got ${body.content.length}); note only the first ${STEER_IN_MAX_CHARS} are delivered anyway`);
|
|
201
195
|
return;
|
|
202
196
|
}
|
|
203
|
-
const trusted = explicitOperatorOk(principal, deps.config
|
|
197
|
+
const trusted = explicitOperatorOk(principal, deps.config);
|
|
204
198
|
const ownerScope = principal ?? "default";
|
|
205
199
|
const wfRun = await getWorkflowRun(runs.store, wfRunId, ownerScope);
|
|
206
200
|
if (!trusted && !wfRun) {
|
|
@@ -240,92 +234,18 @@ export async function handleWorkflowAgentSteer(req, res, match, ctx) {
|
|
|
240
234
|
return;
|
|
241
235
|
}
|
|
242
236
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const parsed = LegApprovalKeysSchema.safeParse(agent);
|
|
251
|
-
if (!parsed.success)
|
|
252
|
-
return {};
|
|
253
|
-
const { pendingApproval, approvalWaitedMs } = parsed.data;
|
|
254
|
-
return {
|
|
255
|
-
...(pendingApproval !== undefined ? { pendingApproval: { askIds: [...pendingApproval.askIds], oldestCreatedAtMs: pendingApproval.oldestCreatedAtMs } } : {}),
|
|
256
|
-
...(approvalWaitedMs !== undefined ? { approvalWaitedMs } : {}),
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function projectParkRow(p) {
|
|
260
|
-
return {
|
|
261
|
-
callKey: p.callKey,
|
|
262
|
-
sessionId: p.sessionId,
|
|
263
|
-
originRunId: p.originRunId,
|
|
264
|
-
...(p.originUnconfirmed === true ? { originUnconfirmed: true } : {}),
|
|
265
|
-
...(p.parkedBy !== undefined ? { parkedBy: p.parkedBy } : {}),
|
|
266
|
-
...(p.generation !== undefined ? { generation: p.generation } : {}),
|
|
267
|
-
};
|
|
237
|
+
const isTerminalAgentStatus = (s) => s === "completed" || s === "failed";
|
|
238
|
+
const durationOf = (a) => a.startedAt === undefined || a.endedAt === undefined ? undefined : a.endedAt - a.startedAt;
|
|
239
|
+
const isLiteralTrue = (raw) => raw === true;
|
|
240
|
+
const LegPendingApprovalSchema = z.object({ askIds: z.array(z.string().min(1)).min(1), oldestCreatedAtMs: z.number().finite() });
|
|
241
|
+
const LegApprovalWaitedMsSchema = z.number().finite().nonnegative();
|
|
242
|
+
function rowsOf(list) {
|
|
243
|
+
return Array.isArray(list) ? list.filter((row) => typeof row === "object" && row !== null && !Array.isArray(row)) : [];
|
|
268
244
|
}
|
|
269
|
-
function
|
|
270
|
-
const isDone = (s) => s === "completed" || s === "failed";
|
|
271
|
-
const durationOf = (a) => a.startedAt === undefined || a.endedAt === undefined ? undefined : a.endedAt - a.startedAt;
|
|
272
|
-
const runPhases = run.phases ?? [];
|
|
273
|
-
const runAgents = run.agents ?? [];
|
|
274
|
-
const runGroups = run.groups ?? [];
|
|
275
|
-
const phases = runPhases.map((p) => {
|
|
276
|
-
const inPhase = runAgents.filter((a) => a.phase === p.title);
|
|
277
|
-
return {
|
|
278
|
-
title: redactSecrets(p.title),
|
|
279
|
-
status: p.status,
|
|
280
|
-
startedAt: p.startedAt,
|
|
281
|
-
endedAt: p.endedAt,
|
|
282
|
-
durationMs: durationOf(p),
|
|
283
|
-
done: inPhase.filter((a) => isDone(a.status)).length,
|
|
284
|
-
total: inPhase.length,
|
|
285
|
-
};
|
|
286
|
-
});
|
|
287
|
-
const phaseTitleSet = new Set(runPhases.map((p) => p.title));
|
|
288
|
-
const unphased = runAgents.filter((a) => a.phase === undefined || a.phase === "" || !phaseTitleSet.has(a.phase));
|
|
289
|
-
const unphasedView = unphased.length > 0
|
|
290
|
-
? { done: unphased.filter((a) => isDone(a.status)).length, total: unphased.length }
|
|
291
|
-
: undefined;
|
|
292
|
-
const agents = runAgents.map((a) => ({
|
|
293
|
-
label: redactSecrets(a.label),
|
|
294
|
-
status: a.status,
|
|
295
|
-
displayStatus: deriveAgentDisplayStatus(a, run.status),
|
|
296
|
-
taskStatus: a.taskStatus,
|
|
297
|
-
callKey: a.callKey,
|
|
298
|
-
groupId: a.groupId,
|
|
299
|
-
phase: a.phase !== undefined ? redactSecrets(a.phase) : undefined,
|
|
300
|
-
model: a.model,
|
|
301
|
-
tokens: a.stats?.tokens,
|
|
302
|
-
turns: a.stats?.turns,
|
|
303
|
-
toolCalls: a.toolCalls,
|
|
304
|
-
activity: a.activity,
|
|
305
|
-
lastActivityAt: a.activity && a.activity.length > 0 ? a.activity[a.activity.length - 1].at : undefined,
|
|
306
|
-
durationMs: durationOf(a),
|
|
307
|
-
queuedAt: a.queuedAt,
|
|
308
|
-
startedAt: a.startedAt,
|
|
309
|
-
endedAt: a.endedAt,
|
|
310
|
-
replayed: a.replayed,
|
|
311
|
-
prompt: a.prompt,
|
|
312
|
-
output: a.output,
|
|
313
|
-
...projectLegApprovalKeys(a),
|
|
314
|
-
taskRunId: a.taskRunId,
|
|
315
|
-
}));
|
|
245
|
+
function groupForestOf(run) {
|
|
316
246
|
const byId = new Map();
|
|
317
|
-
for (const g of
|
|
318
|
-
byId.set(g.groupId,
|
|
319
|
-
groupId: g.groupId,
|
|
320
|
-
parentGroupId: g.parentGroupId,
|
|
321
|
-
status: g.status,
|
|
322
|
-
startedAt: g.startedAt,
|
|
323
|
-
endedAt: g.endedAt,
|
|
324
|
-
durationMs: durationOf(g),
|
|
325
|
-
agentCallKeys: runAgents.filter((a) => a.groupId === g.groupId).map((a) => a.callKey),
|
|
326
|
-
children: [],
|
|
327
|
-
});
|
|
328
|
-
}
|
|
247
|
+
for (const g of rowsOf(run.groups))
|
|
248
|
+
byId.set(g.groupId, g);
|
|
329
249
|
const inCycle = (start) => {
|
|
330
250
|
const seen = new Set();
|
|
331
251
|
let cur = start;
|
|
@@ -338,36 +258,150 @@ function summarizeWorkflowDetail(run) {
|
|
|
338
258
|
return false;
|
|
339
259
|
};
|
|
340
260
|
const roots = [];
|
|
261
|
+
const childrenOf = new Map();
|
|
341
262
|
for (const node of byId.values()) {
|
|
263
|
+
childrenOf.set(node, childrenOf.get(node) ?? []);
|
|
342
264
|
const parent = node.parentGroupId !== undefined ? byId.get(node.parentGroupId) : undefined;
|
|
343
|
-
if (parent && parent !== node && !inCycle(node))
|
|
344
|
-
|
|
265
|
+
if (parent && parent !== node && !inCycle(node)) {
|
|
266
|
+
const siblings = childrenOf.get(parent) ?? [];
|
|
267
|
+
siblings.push(node);
|
|
268
|
+
childrenOf.set(parent, siblings);
|
|
269
|
+
}
|
|
345
270
|
else
|
|
346
271
|
roots.push(node);
|
|
347
272
|
}
|
|
348
|
-
return {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
273
|
+
return { roots, childrenOf };
|
|
274
|
+
}
|
|
275
|
+
export const WORKFLOW_PARK_ROW_DISPOSITIONS = {
|
|
276
|
+
callKey: "forward",
|
|
277
|
+
sessionId: "forward",
|
|
278
|
+
token: "strip",
|
|
279
|
+
originRunId: "forward",
|
|
280
|
+
originUnconfirmed: { forward: isLiteralTrue },
|
|
281
|
+
parkedBy: "forward",
|
|
282
|
+
generation: "forward",
|
|
283
|
+
};
|
|
284
|
+
export const WORKFLOW_PHASE_DISPOSITIONS = {
|
|
285
|
+
title: { redact: "redactSecrets" },
|
|
286
|
+
status: "forward",
|
|
287
|
+
detail: "strip",
|
|
288
|
+
model: "strip",
|
|
289
|
+
agentFailures: "strip",
|
|
290
|
+
startedAt: "forward",
|
|
291
|
+
endedAt: "forward",
|
|
292
|
+
durationMs: { mint: (p) => durationOf(p) },
|
|
293
|
+
done: { mint: (p, root) => rowsOf(root.run.agents).filter((a) => a.phase === p.title && isTerminalAgentStatus(a.status)).length },
|
|
294
|
+
total: { mint: (p, root) => rowsOf(root.run.agents).filter((a) => a.phase === p.title).length },
|
|
295
|
+
};
|
|
296
|
+
export const WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS = {
|
|
297
|
+
phase: "forward",
|
|
298
|
+
toolCallId: "forward",
|
|
299
|
+
toolName: "forward",
|
|
300
|
+
isError: "forward",
|
|
301
|
+
at: "forward",
|
|
302
|
+
arg: "forward",
|
|
303
|
+
};
|
|
304
|
+
export const WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS = {
|
|
305
|
+
askIds: "forward",
|
|
306
|
+
oldestCreatedAtMs: "forward",
|
|
307
|
+
};
|
|
308
|
+
export const WORKFLOW_AGENT_DISPOSITIONS = {
|
|
309
|
+
label: { redact: "redactSecrets" },
|
|
310
|
+
status: "forward",
|
|
311
|
+
displayStatus: { mint: (a, root) => deriveAgentDisplayStatus(a, root.run.status) },
|
|
312
|
+
taskStatus: "forward",
|
|
313
|
+
callKey: "forward",
|
|
314
|
+
groupId: "forward",
|
|
315
|
+
phase: { redact: "redactSecrets" },
|
|
316
|
+
model: "forward",
|
|
317
|
+
tokens: { mint: (a) => a.stats?.tokens },
|
|
318
|
+
turns: { mint: (a) => a.stats?.turns },
|
|
319
|
+
toolCalls: "forward",
|
|
320
|
+
activity: { nested: WORKFLOW_AGENT_ACTIVITY_DISPOSITIONS, rows: "each" },
|
|
321
|
+
lastActivityAt: { mint: (a) => rowsOf(a.activity).at(-1)?.at },
|
|
322
|
+
durationMs: { mint: (a) => durationOf(a) },
|
|
323
|
+
queuedAt: "forward",
|
|
324
|
+
startedAt: "forward",
|
|
325
|
+
endedAt: "forward",
|
|
326
|
+
replayed: "forward",
|
|
327
|
+
prompt: "forward",
|
|
328
|
+
output: "forward",
|
|
329
|
+
pendingApproval: { nested: WORKFLOW_AGENT_PENDING_APPROVAL_DISPOSITIONS, admit: (raw) => LegPendingApprovalSchema.safeParse(raw).success },
|
|
330
|
+
approvalWaitedMs: { forward: (raw) => LegApprovalWaitedMsSchema.safeParse(raw).success },
|
|
331
|
+
taskRunId: "forward",
|
|
332
|
+
errorCode: "strip",
|
|
333
|
+
errorMessage: "strip",
|
|
334
|
+
stats: "strip",
|
|
335
|
+
attempts: "strip",
|
|
336
|
+
lastAttemptReason: "strip",
|
|
337
|
+
sessionId: "strip",
|
|
338
|
+
parkedCheckpointToken: "strip",
|
|
339
|
+
worktreeDir: "strip",
|
|
340
|
+
};
|
|
341
|
+
export const WORKFLOW_GROUP_DISPOSITIONS = {
|
|
342
|
+
groupId: "forward",
|
|
343
|
+
parentGroupId: "forward",
|
|
344
|
+
status: "forward",
|
|
345
|
+
startedAt: "forward",
|
|
346
|
+
endedAt: "forward",
|
|
347
|
+
durationMs: { mint: (g) => durationOf(g) },
|
|
348
|
+
agentCallKeys: { mint: (g, root) => rowsOf(root.run.agents).filter((a) => a.groupId === g.groupId).map((a) => a.callKey) },
|
|
349
|
+
children: {
|
|
350
|
+
mint: (g, root) => (root.forest.childrenOf.get(g) ?? []).map((c) => projectByTable("workflow_detail.groups[]", WORKFLOW_GROUP_DISPOSITIONS, c, root)),
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
export const WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS = {
|
|
354
|
+
tokens: "forward",
|
|
355
|
+
turns: "forward",
|
|
356
|
+
tasks: "forward",
|
|
357
|
+
costMicroUsd: "forward",
|
|
358
|
+
};
|
|
359
|
+
export const WORKFLOW_RUN_STATS_DISPOSITIONS = {
|
|
360
|
+
tokens: "forward",
|
|
361
|
+
turns: "forward",
|
|
362
|
+
costMicroUsd: "forward",
|
|
363
|
+
nested: { nested: WORKFLOW_RUN_STATS_NESTED_DISPOSITIONS },
|
|
364
|
+
};
|
|
365
|
+
export const WORKFLOW_RUN_DISPOSITIONS = {
|
|
366
|
+
id: "forward",
|
|
367
|
+
scope: "forward",
|
|
368
|
+
status: "forward",
|
|
369
|
+
name: { redact: "redactSecrets" },
|
|
370
|
+
description: { redact: "redactSecrets" },
|
|
371
|
+
stats: { nested: WORKFLOW_RUN_STATS_DISPOSITIONS },
|
|
372
|
+
agentFailures: "forward",
|
|
373
|
+
startedAt: "forward",
|
|
374
|
+
endedAt: "forward",
|
|
375
|
+
createdAt: "forward",
|
|
376
|
+
durationMs: { mint: (run) => durationOf(run) },
|
|
377
|
+
rev: "forward",
|
|
378
|
+
error: { redact: "redactErrorMessage" },
|
|
379
|
+
errorCode: "forward",
|
|
380
|
+
parks: { nested: WORKFLOW_PARK_ROW_DISPOSITIONS, rows: "each" },
|
|
381
|
+
resumeAdmissionIncomplete: { forward: isLiteralTrue },
|
|
382
|
+
result: { redact: "redactSecrets" },
|
|
383
|
+
phases: { nested: WORKFLOW_PHASE_DISPOSITIONS, rows: "each" },
|
|
384
|
+
unphased: {
|
|
385
|
+
mint: (run) => {
|
|
386
|
+
const titles = new Set(rowsOf(run.phases).map((p) => p.title));
|
|
387
|
+
const loose = rowsOf(run.agents).filter((a) => a.phase === undefined || a.phase === "" || !titles.has(a.phase));
|
|
388
|
+
return loose.length > 0 ? { done: loose.filter((a) => isTerminalAgentStatus(a.status)).length, total: loose.length } : undefined;
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
agents: { nested: WORKFLOW_AGENT_DISPOSITIONS, rows: "each" },
|
|
392
|
+
groups: { nested: WORKFLOW_GROUP_DISPOSITIONS, rows: (_groups, root) => root.forest.roots },
|
|
393
|
+
sourceTaskId: "strip",
|
|
394
|
+
originatingSessionId: "strip",
|
|
395
|
+
effectiveArgs: "strip",
|
|
396
|
+
budgetOvershoot: "strip",
|
|
397
|
+
timeoutInterruption: "strip",
|
|
398
|
+
resultFull: "strip",
|
|
399
|
+
completionId: "strip",
|
|
400
|
+
resume: "strip",
|
|
401
|
+
journalSkips: "strip",
|
|
402
|
+
};
|
|
403
|
+
export function summarizeWorkflowDetail(run) {
|
|
404
|
+
return projectByTable("workflow_detail", WORKFLOW_RUN_DISPOSITIONS, run, { run, forest: groupForestOf(run) });
|
|
371
405
|
}
|
|
372
406
|
async function streamWorkflowRun(req, res, runId, scope) {
|
|
373
407
|
sseHeaders(res);
|