@sema-agent/server 7.150.0 → 7.151.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 +185 -0
- package/USAGE.md +53 -25
- package/deploy/sema-up/README.md +7 -1
- package/deploy/sema-up/chart/Chart.yaml +1 -1
- package/deploy/sema-up/chart/templates/NOTES.txt +5 -0
- package/deploy/sema-up/chart/templates/_helpers.tpl +15 -16
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +5 -3
- package/deploy/sema-up/chart/templates/server.yaml +5 -3
- package/deploy/sema-up/chart/values-full-single.yaml +3 -1
- package/deploy/sema-up/chart/values.yaml +8 -1
- package/deploy/sema-up/cluster-up.sh +1 -0
- package/deploy/sema-up/kube-up.sh +1 -1
- package/deploy/sema-up/lib/flagshape.sh +1 -1
- package/deploy/sema-up/lib/helm-values-cluster.py +2 -0
- package/deploy/sema-up/lib/helm-values-kube.py +2 -0
- package/dist/adoption/import.js +3 -3
- package/dist/approval-ask-machine.d.ts +1 -1
- package/dist/approval-card.d.ts +2 -2
- package/dist/approval-gate-currency.d.ts +1 -1
- package/dist/auth-bridge.d.ts +20 -0
- package/dist/auth-bridge.js +9 -0
- package/dist/background-session-reap.d.ts +1 -1
- package/dist/bake-runner/main.d.ts +4 -2
- package/dist/bind-host.d.ts +2 -3
- package/dist/bind-host.js +2 -4
- package/dist/boot/budget-tracing.js +1 -1
- package/dist/boot/engine-lease.d.ts +5 -0
- package/dist/boot/engine-lease.js +1 -0
- package/dist/boot/execution-env.d.ts +8 -14
- package/dist/boot/execution-env.js +54 -17
- package/dist/boot/execution-lane.js +32 -5
- package/dist/boot/late-binds.d.ts +8 -4
- package/dist/boot/late-binds.js +7 -1
- package/dist/boot/memory-consolidation.d.ts +3 -2
- package/dist/boot/memory-consolidation.js +6 -6
- package/dist/boot/reapers.d.ts +5 -0
- package/dist/boot/reapers.js +12 -1
- package/dist/boot/resolve-spec.d.ts +3 -3
- package/dist/boot/resolve-spec.js +31 -22
- package/dist/boot/runner-deps.d.ts +9 -2
- package/dist/boot/runner-deps.js +3 -3
- package/dist/boot/session-age-out.d.ts +36 -0
- package/dist/boot/session-age-out.js +101 -0
- package/dist/boot/session-faces.d.ts +5 -14
- package/dist/boot/session-faces.js +9 -5
- package/dist/boot/stage-01-config.js +2 -0
- package/dist/boot/stage-05-execution-env.d.ts +5 -3
- package/dist/boot/stage-05-execution-env.js +2 -2
- package/dist/boot/stage-06-runners.d.ts +7 -4
- package/dist/boot/stage-06-runners.js +15 -6
- package/dist/boot/stage-07-capability-layer.d.ts +7 -4
- package/dist/boot/stage-07-capability-layer.js +2 -1
- package/dist/boot/stage-08-reapers.d.ts +7 -4
- package/dist/boot/stage-08-reapers.js +4 -2
- package/dist/boot/stage-09-leader.d.ts +11 -5
- package/dist/boot/stage-09-leader.js +12 -3
- package/dist/boot/stage-10-http-server.d.ts +11 -5
- package/dist/boot/stage-10-http-server.js +3 -6
- package/dist/boot/web-admin.js +3 -1
- package/dist/boot/workflow-orchestration.d.ts +7 -2
- package/dist/boot/workflow-orchestration.js +24 -7
- package/dist/bounded-rotation.d.ts +29 -0
- package/dist/bounded-rotation.js +24 -0
- package/dist/capability-facts.d.ts +22 -13
- package/dist/capability-facts.js +28 -18
- package/dist/center-credential.d.ts +25 -6
- package/dist/center-credential.js +25 -5
- package/dist/config-catalog.d.ts +26 -7
- package/dist/config-catalog.js +14 -11
- package/dist/config-invariants.d.ts +2 -1
- package/dist/config-invariants.js +4 -4
- package/dist/config-types.d.ts +10 -4
- package/dist/config.d.ts +51 -2
- package/dist/config.js +35 -24
- package/dist/deployment-shape.d.ts +9 -1
- package/dist/deployment-shape.js +2 -1
- package/dist/device-protocol.d.ts +5 -4
- package/dist/device-protocol.js +1 -1
- package/dist/device-ws-hub.js +3 -2
- package/dist/device-ws-protocol.d.ts +63 -10
- package/dist/device-ws-protocol.js +56 -25
- package/dist/engine-identity.d.ts +19 -7
- package/dist/engine-identity.js +10 -2
- package/dist/entry-mode-clamp-notice.d.ts +2 -1
- package/dist/execution-env-refusal.d.ts +23 -0
- package/dist/execution-env-refusal.js +5 -0
- package/dist/execution-lane-caps.d.ts +3 -1
- package/dist/field-conflict.d.ts +1 -1
- package/dist/file-history-capture.d.ts +11 -4
- package/dist/file-history-capture.js +9 -6
- package/dist/file-history-disclosure.d.ts +7 -5
- package/dist/file-history-disclosure.js +7 -5
- package/dist/fleet/drain-entry.d.ts +4 -0
- package/dist/hooks/hook-runner.js +2 -2
- package/dist/host-lsp-manager.d.ts +2 -2
- package/dist/http/admission.js +17 -2
- package/dist/http/approval-sweeps.js +5 -5
- package/dist/http/checkpoint-ctx.d.ts +2 -0
- package/dist/http/checkpoint-ctx.js +1 -0
- package/dist/http/dispatch.d.ts +2 -1
- package/dist/http/dispatch.js +34 -27
- package/dist/http/durable-run-leg.js +16 -16
- package/dist/http/health-self-report.d.ts +9 -1
- package/dist/http/health-self-report.js +2 -0
- package/dist/http/owner-access.d.ts +31 -11
- package/dist/http/owner-access.js +37 -6
- package/dist/http/resume-ctx-read.js +25 -3
- package/dist/http/resume-legs.d.ts +2 -1
- package/dist/http/resume-legs.js +259 -79
- package/dist/http/route-ctx.d.ts +18 -8
- package/dist/http/route-table.d.ts +1 -1
- package/dist/http/routes/admin-memory-optout.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +2 -3
- package/dist/http/routes/approvals-assistant.js +4 -3
- package/dist/http/routes/background.d.ts +3 -3
- package/dist/http/routes/capabilities.js +8 -5
- package/dist/http/routes/fleet.js +10 -8
- package/dist/http/routes/projects.d.ts +3 -2
- package/dist/http/routes/projects.js +4 -5
- package/dist/http/routes/runs.js +102 -36
- package/dist/http/routes/session-sync.d.ts +4 -3
- package/dist/http/routes/session-sync.js +172 -77
- package/dist/http/routes/sessions-list.js +13 -7
- package/dist/http/routes/sessions.js +10 -6
- package/dist/http/routes/tasks.js +30 -16
- package/dist/http/routes/trace-usage.js +2 -2
- package/dist/http/server.d.ts +21 -27
- package/dist/http/server.js +2 -2
- package/dist/http/submit-ctx.js +5 -4
- package/dist/http/wire-types.d.ts +14 -4
- package/dist/identity-source.d.ts +20 -3
- package/dist/identity-source.js +14 -0
- package/dist/index.d.ts +4 -0
- package/dist/lane-home-probe.d.ts +3 -7
- package/dist/lane-home-probe.js +0 -1
- package/dist/leader/leader.d.ts +2 -1
- package/dist/leg-facts.d.ts +13 -5
- package/dist/leg-facts.js +2 -1
- package/dist/memory-scope.d.ts +5 -4
- package/dist/memory-scope.js +4 -4
- package/dist/memory-sync-client.d.ts +30 -2
- package/dist/memory-sync-client.js +16 -9
- package/dist/observability/err-text.d.ts +7 -0
- package/dist/observability/err-text.js +5 -0
- package/dist/observability/fail-open.d.ts +7 -3
- package/dist/observability/fail-open.js +7 -3
- package/dist/observability/metrics.js +1 -0
- package/dist/orchestration/workflow-notify-journal.d.ts +18 -1
- package/dist/orchestration/workflow-notify-journal.js +12 -1
- package/dist/orchestration/workflow-park-decision.d.ts +70 -18
- package/dist/orchestration/workflow-park-decision.js +49 -10
- package/dist/orchestration/workflow-park-holder.d.ts +65 -0
- package/dist/orchestration/workflow-park-holder.js +98 -0
- package/dist/orchestration/workflow-record-fence.d.ts +36 -0
- package/dist/orchestration/workflow-record-fence.js +42 -0
- package/dist/owner-faces.d.ts +1 -1
- package/dist/parked-decide.d.ts +104 -53
- package/dist/parked-decide.js +153 -117
- package/dist/peer-directory.d.ts +2 -2
- package/dist/peer-inbound-face.d.ts +2 -6
- package/dist/peer-inbound-face.js +0 -3
- package/dist/permission-mode-admission.d.ts +41 -5
- package/dist/permission-mode-admission.js +29 -3
- package/dist/plugins/adoption-log-sql.d.ts +3 -1
- package/dist/plugins/adoption-log-sql.js +7 -1
- package/dist/plugins/approval-ask-store-file.d.ts +10 -2
- package/dist/plugins/approval-ask-store-file.js +8 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +6 -1
- package/dist/plugins/approval-ask-store-memory.js +28 -9
- package/dist/plugins/approval-ask-store-sql.d.ts +43 -2
- package/dist/plugins/approval-ask-store-sql.js +34 -5
- package/dist/plugins/approval-exemption-store.js +3 -0
- package/dist/plugins/approval-nonce-store.js +2 -0
- package/dist/plugins/breaker-state-sql.js +2 -0
- package/dist/plugins/caching-session-store.d.ts +9 -15
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/device-store-sql.js +6 -0
- package/dist/plugins/error-origin.d.ts +18 -0
- package/dist/plugins/error-origin.js +10 -0
- package/dist/plugins/execution-placement-sql.js +6 -6
- package/dist/plugins/image-bake-store-sql.js +6 -0
- package/dist/plugins/image-index-sql.js +4 -0
- package/dist/plugins/landed-attendants.d.ts +212 -0
- package/dist/plugins/landed-attendants.js +161 -0
- package/dist/plugins/leader-run-store-sql.js +4 -0
- package/dist/plugins/local-session-live-reference.d.ts +40 -0
- package/dist/plugins/local-session-live-reference.js +39 -0
- package/dist/plugins/local-session-store.d.ts +71 -33
- package/dist/plugins/local-session-store.js +129 -27
- package/dist/plugins/memory-engine-pg.js +4 -0
- package/dist/plugins/memory-engine-sql-apply.js +5 -2
- package/dist/plugins/memory-engine-tidb.js +4 -0
- package/dist/plugins/memory-optout-grant-store-sql.js +4 -0
- package/dist/plugins/memory-sync-store-pg.js +5 -0
- package/dist/plugins/memory-sync-store-tidb.js +5 -0
- package/dist/plugins/one-time-migrations.d.ts +57 -63
- package/dist/plugins/one-time-migrations.js +162 -90
- package/dist/plugins/org-delivery-quota-store.js +4 -1
- package/dist/plugins/outcome-ledger-sql.js +2 -0
- package/dist/plugins/permission-rule-store-sql.js +11 -4
- package/dist/plugins/pg-cost-quota.js +4 -0
- package/dist/plugins/pg-pool.js +24 -1
- package/dist/plugins/pg-rate-limiter.js +2 -0
- package/dist/plugins/posix-shell-fs.d.ts +6 -1
- package/dist/plugins/posix-shell-fs.js +4 -1
- package/dist/plugins/remote-env-adb.d.ts +19 -15
- package/dist/plugins/remote-env-adb.js +41 -15
- package/dist/plugins/remote-env-connect-seat.d.ts +105 -0
- package/dist/plugins/remote-env-connect-seat.js +72 -0
- package/dist/plugins/remote-env-device.d.ts +22 -5
- package/dist/plugins/remote-env-device.js +106 -8
- package/dist/plugins/remote-env-e2b.d.ts +15 -6
- package/dist/plugins/remote-env-e2b.js +42 -32
- package/dist/plugins/remote-env-file-error.js +6 -2
- package/dist/plugins/remote-env-host.d.ts +17 -0
- package/dist/plugins/remote-env-host.js +30 -38
- package/dist/plugins/remote-env-k8s.d.ts +41 -39
- package/dist/plugins/remote-env-k8s.js +53 -30
- package/dist/plugins/remote-env-local-docker.d.ts +13 -8
- package/dist/plugins/remote-env-local-docker.js +34 -41
- package/dist/plugins/remote-env-ssh.d.ts +18 -12
- package/dist/plugins/remote-env-ssh.js +60 -59
- package/dist/plugins/remote-shell.d.ts +98 -1
- package/dist/plugins/remote-shell.js +218 -0
- package/dist/plugins/resume-anchor-store-sql.d.ts +11 -2
- package/dist/plugins/resume-anchor-store-sql.js +12 -5
- package/dist/plugins/retention-lane-store-sql.js +4 -0
- package/dist/plugins/retention-sql.d.ts +20 -2
- package/dist/plugins/retention-sql.js +11 -0
- package/dist/plugins/run-store-sql.d.ts +21 -2
- package/dist/plugins/run-store-sql.js +31 -7
- package/dist/plugins/scenario-prefix-switch-m42.d.ts +1 -1
- package/dist/plugins/scenario-prefix-switch-m42.js +2 -2
- package/dist/plugins/schema-consistency.d.ts +4 -2
- package/dist/plugins/schema-consistency.js +19 -2
- package/dist/plugins/send-file-ledger.js +3 -0
- package/dist/plugins/serving-requirement.d.ts +26 -7
- package/dist/plugins/serving-requirement.js +11 -4
- package/dist/plugins/session-birth.d.ts +6 -2
- package/dist/plugins/session-capture-record-store-sql.js +2 -0
- package/dist/plugins/session-ext-table.d.ts +14 -1
- package/dist/plugins/session-ext-table.js +5 -1
- package/dist/plugins/session-row-sql.d.ts +49 -2
- package/dist/plugins/session-row-sql.js +56 -13
- package/dist/plugins/session-store-sql.d.ts +34 -18
- package/dist/plugins/session-store-sql.js +98 -17
- package/dist/plugins/shared-memory-store-sql.d.ts +1 -0
- package/dist/plugins/shared-memory-store-sql.js +6 -2
- package/dist/plugins/sql-driver.d.ts +2 -1
- package/dist/plugins/sql-driver.js +18 -3
- package/dist/plugins/sql-errors.d.ts +11 -6
- package/dist/plugins/sql-errors.js +5 -6
- package/dist/plugins/stop-then-start-sentence.d.ts +10 -4
- package/dist/plugins/stop-then-start-sentence.js +14 -10
- package/dist/plugins/stop-then-start.d.ts +109 -0
- package/dist/plugins/stop-then-start.js +104 -0
- package/dist/plugins/store-backend.d.ts +40 -13
- package/dist/plugins/store-backend.js +169 -27
- package/dist/plugins/store-boundary.d.ts +57 -0
- package/dist/plugins/store-boundary.js +139 -0
- package/dist/plugins/store-contracts.d.ts +17 -0
- package/dist/plugins/store-fault-sentence-m53.d.ts +7 -0
- package/dist/plugins/store-fault-sentence-m53.js +25 -0
- package/dist/plugins/store-fault.d.ts +26 -7
- package/dist/plugins/store-fault.js +18 -2
- package/dist/plugins/task-attachment-store.js +9 -0
- package/dist/plugins/task-list-store-sql.d.ts +2 -2
- package/dist/plugins/task-list-store-sql.js +10 -8
- package/dist/plugins/tidb-cost-quota.js +4 -0
- package/dist/plugins/tidb-pool.js +2 -1
- package/dist/plugins/tidb-rate-limiter.js +4 -0
- package/dist/plugins/user-input-ledger-sql.js +4 -0
- package/dist/plugins/workflow-run-store-sql.d.ts +28 -10
- package/dist/plugins/workflow-run-store-sql.js +64 -4
- package/dist/plugins/workspace-fill.d.ts +4 -7
- package/dist/plugins/workspace-fill.js +2 -1
- package/dist/plugins/write-behind-counter.js +5 -0
- package/dist/project-context.d.ts +0 -2
- package/dist/project-context.js +4 -8
- package/dist/project-registry.d.ts +46 -0
- package/dist/project-registry.js +44 -0
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +4 -0
- package/dist/request-value-closure.js +10 -0
- package/dist/run-acceptance.d.ts +3 -2
- package/dist/run-acceptance.js +4 -6
- package/dist/run-local.js +1 -0
- package/dist/runs.d.ts +37 -8
- package/dist/runs.js +53 -12
- package/dist/runtime-governance.d.ts +5 -4
- package/dist/security.d.ts +30 -32
- package/dist/security.js +41 -7
- package/dist/server-secret-env.d.ts +12 -10
- package/dist/server-secret-env.js +24 -15
- package/dist/session-bindings.d.ts +82 -0
- package/dist/session-bindings.js +18 -0
- package/dist/session-children-retire.d.ts +2 -2
- package/dist/session-children-retire.js +2 -6
- package/dist/session-deletion.d.ts +16 -1
- package/dist/session-error-wire.d.ts +3 -3
- package/dist/session-error-wire.js +3 -3
- package/dist/session-incarnation.d.ts +10 -0
- package/dist/session-incarnation.js +10 -1
- package/dist/session-kind.d.ts +57 -0
- package/dist/session-kind.js +22 -0
- package/dist/session-row.d.ts +21 -1
- package/dist/session-row.js +7 -1
- package/dist/session-sync-kernel.d.ts +24 -14
- package/dist/session-sync-kernel.js +3 -6
- package/dist/session-sync.d.ts +4 -98
- package/dist/session-sync.js +1 -71
- package/dist/session-titler.d.ts +10 -3
- package/dist/session-titler.js +19 -6
- package/dist/ssh-host-key.d.ts +5 -0
- package/dist/ssh-host-key.js +3 -0
- package/dist/stores-sql/file-history-store-sql.d.ts +52 -2
- package/dist/stores-sql/file-history-store-sql.js +108 -70
- package/dist/stores-sql/pg-session-storage.d.ts +34 -7
- package/dist/stores-sql/pg-session-storage.js +37 -13
- package/dist/stores-sql/retention-store-sql.d.ts +1 -9
- package/dist/stores-sql/retention-store-sql.js +2 -10
- package/dist/stores-sql/session-policy-store-sql.d.ts +30 -7
- package/dist/stores-sql/session-policy-store-sql.js +61 -44
- package/dist/stores-sql/session-write-hooks.d.ts +11 -0
- package/dist/stores-sql/tidb-session-store.d.ts +58 -7
- package/dist/stores-sql/tidb-session-store.js +37 -13
- package/dist/submission-exit.d.ts +3 -2
- package/dist/submission-exit.js +9 -1
- package/dist/task-cwd.d.ts +2 -2
- package/dist/task-settings.d.ts +6 -5
- package/dist/terminal.d.ts +33 -2
- package/dist/terminal.js +139 -9
- package/dist/tool-approval.d.ts +140 -6
- package/dist/tool-approval.js +165 -72
- package/dist/trace/self-minted-wire.d.ts +290 -27
- package/dist/trace/self-minted-wire.js +101 -13
- package/docs/DEVICE-EXECUTOR-PROTOCOL.md +78 -27
- package/package.json +2 -2
- package/wire-changes/server@7.151.0.json +762 -0
- package/dist/http/session-inherit-env.d.ts +0 -36
- package/dist/http/session-inherit-env.js +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { redactErrorMessage, redactHead, redactTerminalResult } from "../../observability/run-terminal.js";
|
|
2
2
|
import { runWithVerification, runCascade, taskNotificationDedupKey, uuidv7 } from "@sema-agent/core";
|
|
3
3
|
import { heldFor } from "../../peer-seat.js";
|
|
4
|
-
import { beatRunHeartbeat, graftParkToolCallId, heldParkOf, markChildrenStoppedByUserOnAbort, syncRefusalHttpStatus, zeroWorkRefusalFacts, releaseKeyIfZeroWorkRefusal, createPromptCommitReader, settleResumeAnchor, TurnAnchorCapture, HEARTBEAT_MS } from "../../runs.js";
|
|
4
|
+
import { beatRunHeartbeat, createRunAnchorWriter, graftParkToolCallId, heldParkOf, markChildrenStoppedByUserOnAbort, syncRefusalHttpStatus, zeroWorkRefusalFacts, releaseKeyIfZeroWorkRefusal, createPromptCommitReader, settleResumeAnchor, TurnAnchorCapture, HEARTBEAT_MS } from "../../runs.js";
|
|
5
5
|
import { commitParkRow } from "../../park-row-commit.js";
|
|
6
6
|
import { atHostBoundary, failureCodeOf, sealResultForExit, outwardPlane } from "../../terminal.js";
|
|
7
7
|
import { voidVerifierPauseCard } from "../../verifier-pause-card.js";
|
|
@@ -22,7 +22,7 @@ import { contextUsageEventData, turnEndEventData, toolStartEventData, toolEndEve
|
|
|
22
22
|
import { cascadeConfig, fillRunPreviewOnDelivery, runMeta } from "../run-meta.js";
|
|
23
23
|
import { idemCallerOf, inflightKeyOf, submissionIdemOf } from "../idempotency.js";
|
|
24
24
|
import { answerReplay, isReplayedOutcome, replayedOutcome, replayOfExistingRun } from "../submit-replay.js";
|
|
25
|
-
import { readReplayHit, runFactsOf } from "../owner-access.js";
|
|
25
|
+
import { readReplayHit, runFactsOf, sessionOccupantReadOf } from "../owner-access.js";
|
|
26
26
|
import { httpErrorCode, sendJson, sseHeaders } from "../send.js";
|
|
27
27
|
import { collectSsePreamble } from "../sse-log.js";
|
|
28
28
|
import { buildApprovalPreamble } from "../../approval-card.js";
|
|
@@ -33,7 +33,7 @@ import { SUBMISSION_CLAIM_FACE, commitExecutionContext, faultedAnswerOf } from "
|
|
|
33
33
|
import { rootSessionAbsentAnswer } from "../execution-context.js";
|
|
34
34
|
import { recheckClaimBeforeLaunch, startClaimHeartbeat } from "../claim-heartbeat.js";
|
|
35
35
|
import { timeClaim } from "../claim-latency.js";
|
|
36
|
-
import {
|
|
36
|
+
import { commitLegBindings } from "../../session-bindings.js";
|
|
37
37
|
import { headerStr, gatedPerson, gatedSubject, explicitOperatorOk, runIdentityOf } from "../principal-gate.js";
|
|
38
38
|
import { recoveredSubject } from "../../owner-faces.js";
|
|
39
39
|
import { recordFailOpen } from "../../observability/fail-open.js";
|
|
@@ -295,13 +295,20 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
295
295
|
const promptCommit = createPromptCommitReader();
|
|
296
296
|
let anchorPut = false;
|
|
297
297
|
const putRewindAnchor = async () => {
|
|
298
|
-
const store = deps.resumeAnchorStore;
|
|
299
|
-
const key = durableTaskId;
|
|
300
298
|
const entryId = userMsgEntryId;
|
|
301
|
-
|
|
299
|
+
const write = createRunAnchorWriter({
|
|
300
|
+
seat: deps.backend?.landedAttendants(),
|
|
301
|
+
sessionId: prepared.spec.sessionId,
|
|
302
|
+
owner: principal ?? null,
|
|
303
|
+
promptKey: durableTaskId,
|
|
304
|
+
witness: prepared.legFacts?.sessionWitness,
|
|
305
|
+
occupantOf: sessionOccupantReadOf(deps.sessionStorage),
|
|
306
|
+
leafOf: undefined,
|
|
307
|
+
}).prompt;
|
|
308
|
+
if (anchorPut || !entryId || write === undefined)
|
|
302
309
|
return;
|
|
303
310
|
anchorPut = true;
|
|
304
|
-
await settleResumeAnchor(() =>
|
|
311
|
+
await settleResumeAnchor((held) => write(entryId, held), { leg: "stream", kind: "prompt" });
|
|
305
312
|
};
|
|
306
313
|
try {
|
|
307
314
|
if (deps.runStore) {
|
|
@@ -358,7 +365,7 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
358
365
|
writeTerminalFrame(doneFrameOfOutcome(claimFault));
|
|
359
366
|
return claimFault;
|
|
360
367
|
}
|
|
361
|
-
|
|
368
|
+
commitLegBindings(deps, prepared.seat, prepared.spec.sessionId, prepared.legFacts?.sessionBindings);
|
|
362
369
|
markChildrenStoppedByUserOnAbort(ac.signal, durableTaskId ?? prepared.spec.sessionId, prepared.auth?.subject);
|
|
363
370
|
let ledgerSink;
|
|
364
371
|
let ledgerTerminal = false;
|
|
@@ -531,7 +538,7 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
531
538
|
await deps.userInputLedger?.observeLegEvent(liveStream, ev);
|
|
532
539
|
await prepared.acceptance.observe(ev);
|
|
533
540
|
if (ev.type === "done")
|
|
534
|
-
prepared.acceptance.settle(ev.result);
|
|
541
|
+
await prepared.acceptance.settle(ev.result);
|
|
535
542
|
await liveWorkspace.observe(ev);
|
|
536
543
|
if (ledgerSink)
|
|
537
544
|
await manifestSeat?.drain(ledgerSink.append);
|
|
@@ -939,7 +946,7 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
939
946
|
catch (e) {
|
|
940
947
|
return faultedAnswerOf(e, SUBMISSION_CLAIM_FACE.faulted);
|
|
941
948
|
}
|
|
942
|
-
|
|
949
|
+
commitLegBindings(deps, prepared.seat, prepared.spec.sessionId, prepared.legFacts?.sessionBindings);
|
|
943
950
|
const syncCancelCtrl = createRunAbort(principal ?? null);
|
|
944
951
|
markChildrenStoppedByUserOnAbort(syncCancelCtrl.signal, durableTaskId ?? prepared.spec.sessionId, prepared.auth?.subject);
|
|
945
952
|
if (durableTaskId && deps.runStore) {
|
|
@@ -975,15 +982,22 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
975
982
|
counters.uncountedBillableInflight++;
|
|
976
983
|
try {
|
|
977
984
|
const heldDecisions = await heldWorkflowParkDecisions(deps, prepared.spec.sessionId);
|
|
978
|
-
const compositionInternals = { ...heldDecisions, ...compositionLegRoot(prepared.legFacts?.
|
|
985
|
+
const compositionInternals = { ...heldDecisions, ...compositionLegRoot(prepared.legFacts?.sessionBindings.cwd) };
|
|
979
986
|
const verifyLeg = (v) => runWithVerification(prepared.runner, specWithSignal, v, compositionInternals);
|
|
980
987
|
const cascadeLeg = () => runCascade(prepared.runner, specWithSignal, cascadeConfig(deps.config.cascadeLadder, prepared.spec.limits?.maxCostUsd), compositionInternals);
|
|
981
988
|
const plainLeg = async () => {
|
|
982
989
|
const stream = prepared.runner.runTaskStream(specWithSignal, undefined, heldDecisions);
|
|
983
990
|
const syncWorkspace = createSessionWorkspaceRecorder(sessionWorkspaceStoreOf(deps.sessionStorage), prepared.legFacts?.sessionWitness);
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
991
|
+
const anchorWriter = createRunAnchorWriter({
|
|
992
|
+
seat: deps.backend?.landedAttendants(),
|
|
993
|
+
sessionId: prepared.spec.sessionId,
|
|
994
|
+
owner: principal ?? null,
|
|
995
|
+
promptKey: durableTaskId,
|
|
996
|
+
witness: prepared.legFacts?.sessionWitness,
|
|
997
|
+
occupantOf: sessionOccupantReadOf(deps.sessionStorage),
|
|
998
|
+
leafOf: undefined,
|
|
999
|
+
});
|
|
1000
|
+
const anchor = new TurnAnchorCapture(undefined, "sync", anchorWriter.prompt);
|
|
987
1001
|
for await (const ev of stream) {
|
|
988
1002
|
observeSyncLegEvent(ev);
|
|
989
1003
|
switch (ev.type) {
|
|
@@ -1040,18 +1054,18 @@ export async function handleTasks(req, res, match, ctx) {
|
|
|
1040
1054
|
const syncPlane = outwardPlane(result.terminal);
|
|
1041
1055
|
const syncHeld = heldParkOf(result);
|
|
1042
1056
|
if (syncHeld !== undefined && deps.checkpointStore && deps.runStore && durableTaskId) {
|
|
1057
|
+
await prepared.acceptance.settle(result);
|
|
1043
1058
|
const parked = await commitParkRow({
|
|
1044
1059
|
runStore: deps.runStore, taskId: durableTaskId, word: syncHeld.word, result: exitResult, card: { token: syncHeld.token, sessionId: prepared.spec.sessionId }, cards: deps.checkpointStore, leg: "sync",
|
|
1045
1060
|
legId: heldLegOf(durableLegId, durableTaskId), staleWindowMs: deps.config.runStaleSec * 1000,
|
|
1046
1061
|
});
|
|
1047
|
-
prepared.acceptance.settle(result);
|
|
1048
1062
|
if (parked.kind === "ended")
|
|
1049
1063
|
return { status: 200, body: withSyncSubmitKeys(parked.row !== undefined ? syncSubmitBodyOfRow(parked.row) : { taskId: durableTaskId, sessionId: prepared.spec.sessionId, status: "failed" }) };
|
|
1050
1064
|
return { status: 200, body: withSyncSubmitKeys(buildSyncSubmitBody(exitResult, { taskId: durableTaskId, sessionId: prepared.spec.sessionId, status: syncHeld.word })) };
|
|
1051
1065
|
}
|
|
1066
|
+
await prepared.acceptance.settle(result);
|
|
1052
1067
|
if (durableTaskId && deps.runStore)
|
|
1053
1068
|
await deps.runStore.setTerminal(durableTaskId, syncPlane.status, exitResult, syncPlane.errorMessage ?? null);
|
|
1054
|
-
prepared.acceptance.settle(result);
|
|
1055
1069
|
finalizeTaskResult(result, principal, prepared.spec.objective);
|
|
1056
1070
|
noteRunOutcome(result);
|
|
1057
1071
|
return { status: 200, body: withSyncSubmitKeys(buildSyncSubmitBody(exitResult)) };
|
|
@@ -9,7 +9,7 @@ import { bindSseLifecycle } from "../sse-lifecycle.js";
|
|
|
9
9
|
import { sendJson, sendError, sseHeaders, SSE_MAX_STREAM_MS, SSE_HEARTBEAT_IDLE_MS } from "../send.js";
|
|
10
10
|
import { filterFingerprint } from "../cursor-fingerprint.js";
|
|
11
11
|
import { sendUnauthorized } from "../principal-gate.js";
|
|
12
|
-
import { admitRunById, enter, entryIsFleet, listVisibleRuns, readVisibleRun, routeListFilter,
|
|
12
|
+
import { admitRunById, enter, entryIsFleet, listVisibleRuns, readVisibleRun, routeListFilter, listOwnerOf, toolResultRefOwned } from "../owner-access.js";
|
|
13
13
|
import { listFilterOf } from "../../owner-faces.js";
|
|
14
14
|
import { assertNever } from "../route-ctx.js";
|
|
15
15
|
import * as facts from "../../capability-facts.js";
|
|
@@ -166,7 +166,7 @@ async function handleTaskList(res, runStore, query, filter) {
|
|
|
166
166
|
const jobId = query.get("jobId") ?? undefined;
|
|
167
167
|
const source = query.get("source") ?? undefined;
|
|
168
168
|
const namedOwner = query.get("owner") ?? undefined;
|
|
169
|
-
const owner =
|
|
169
|
+
const owner = listOwnerOf(filter, namedOwner);
|
|
170
170
|
const limit = Math.min(100, Math.max(1, Number(query.get("limit") ?? 50) || 50));
|
|
171
171
|
const f = filterFingerprint([status, jobId, source, owner]);
|
|
172
172
|
const cursor = decodeCursor(query.get("cursor"), f);
|
package/dist/http/server.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import type { MemoryComplianceFaces, MemoryOriginFaces, SessionMemoryStatusFace } from "../memory-operator-faces.js";
|
|
3
3
|
import type { SideQueryAccounting } from "../budget.js";
|
|
4
|
-
import type { SessionPurgeOutcome } from "../session-deletion.js";
|
|
4
|
+
import type { SessionAgeOutExpectation, SessionPurgeOutcome } from "../session-deletion.js";
|
|
5
5
|
import type { IncomingMessage } from "node:http";
|
|
6
6
|
import { type Runner, type RunnerDeps, type TaskSpec, type TaskResult, type WorkflowRunStore, type MemoryEntry, type MemoryExportBundle, type MemoryImportReport, type SideQuerySpec, type SideQueryResult, type Brain, type EngineNotice } from "@sema-agent/core";
|
|
7
7
|
import type { ProjectContext } from "../project-context.js";
|
|
8
|
+
import type { MemorySeed } from "../project-registry.js";
|
|
8
9
|
import type { TaskRequestBody } from "./wire-types.js";
|
|
9
10
|
import type { ServiceConfig } from "../config-types.js";
|
|
10
11
|
import { type SessionMirrorRuling } from "../web-admin-client/facade.js";
|
|
@@ -12,7 +13,7 @@ import type { RestartSignal } from "@sema-agent/settings-schema/fleet";
|
|
|
12
13
|
import { type AuthorizeInput, type OwnerAwareSessionStore } from "../security.js";
|
|
13
14
|
import type { PeerDesk, PeerLease } from "../peer-seat.js";
|
|
14
15
|
import type { ExecutionRoot, ResolvedTaskSpec } from "./execution-context.js";
|
|
15
|
-
import type { RunStore, ImageIndex, ImageBake, CheckpointStoreFull,
|
|
16
|
+
import type { RunStore, ImageIndex, ImageBake, CheckpointStoreFull, ApprovalExemptionStore, ApprovalNonceStore, ToolResultStoreFull, StoreBackend } from "../plugins/store-backend.js";
|
|
16
17
|
import type { RuleConsentLane } from "../rules-consent.js";
|
|
17
18
|
import { type MemorySyncAnswer, type MemorySyncRequest } from "../memory-sync.js";
|
|
18
19
|
import type { MemorySyncRunner } from "../memory-sync-client.js";
|
|
@@ -58,9 +59,9 @@ export interface RequestAuth {
|
|
|
58
59
|
sessionId: string;
|
|
59
60
|
memoryScope?: string;
|
|
60
61
|
/** 142-S4:the SHAPE-VALIDATED **且已归一(小写)** 的 `body.projectId`(authorizer 的 core
|
|
61
|
-
* `PROJECT_ID_REGEX` 门通过后折小写回传;[ref]/[ref] 宽读严写)
|
|
62
|
-
*
|
|
63
|
-
* body.projectId(
|
|
62
|
+
* `PROJECT_ID_REGEX` 门通过后折小写回传;[ref]/[ref] 宽读严写)。装配器拿它判 memory.scopes 种子项目(对提交者可见才算,
|
|
63
|
+
* `project-registry.ts`)与这条腿的项目。resume 腿(checkpoint 重建 auth)缺席 — 项目回落持久化的
|
|
64
|
+
* body.projectId(原始提交已验形,那条回落腿自己再折一次小写);种子不回落,读冻结的种子项目。 */
|
|
64
65
|
resolvedProjectId?: string;
|
|
65
66
|
/** authorizer 判过的头(`security.ts` `createAuthorizer` 交出;语义见 `AuthContext.head`)⇒ fresh 执行上下文的 `judged`。自建 authorizer 不给 = 解析器不比住客。 */
|
|
66
67
|
head?: import("@sema-agent/core").SessionHead;
|
|
@@ -133,7 +134,9 @@ export interface ServiceCoreDeps {
|
|
|
133
134
|
* 装配器在**全部折叠之后**经首跑同一只合并口 `withUnattendedLeg` 重挂那条腿(`default` + 按类作答的 onAsk)。只由续跑腿
|
|
134
135
|
* 按服务端写的 ctx 位递,绝不从请求体读。
|
|
135
136
|
* `opts.projectContext`(项目上下文继承):续跑家族把提交腿冻结的那一份(`CheckpointCtx.projectContext`,服务端写)原样递回 —— 装配器在续跑腿上只重放它、不读登记簿;
|
|
136
|
-
* 新提交腿不递(装配器自己在头部判)。同样只由续跑腿按服务端写的 ctx 位递,绝不从请求体读。
|
|
137
|
+
* 新提交腿不递(装配器自己在头部判)。同样只由续跑腿按服务端写的 ctx 位递,绝不从请求体读。
|
|
138
|
+
* `opts.memorySeed`(登记簿默认读层种子):续跑家族把提交腿冻结的种子(`CheckpointCtx.memorySeed`:种子项目 + 判出它的那一位观者,服务端写)原样递回 —— 装配器在续跑腿上
|
|
139
|
+
* 只认它(以冻结的观者经同一只可见性判读此刻的登记)、不推观者、不按存体的 `projectId` 现查;新提交腿不递(装配器自己在头部判)。只由续跑腿按服务端写的 ctx 位递,绝不从请求体读。 */
|
|
137
140
|
/** `opts.execution`(必填):这条腿的执行上下文(`http/execution-context.ts`;只 `fresh` / `continuation` 两形,`root` 恒在)。装配器要用这条腿的根会话
|
|
138
141
|
* (场景设施的分区键、受理见证)读 `opts.execution.root` —— 它与 server 随后盖进 spec 的根是同一个值,装配器自己不写根。 */
|
|
139
142
|
/** `opts.lease`(必填):这条腿的**宿主租约** —— 装配在它之下登记本腿交给引擎的对端声明(`peerDesk.declare(草稿, opts.lease)`)。
|
|
@@ -145,6 +148,7 @@ export interface ServiceCoreDeps {
|
|
|
145
148
|
onNotice?: (notice: EngineNotice) => void;
|
|
146
149
|
unattendedLeg?: true;
|
|
147
150
|
projectContext?: ProjectContext;
|
|
151
|
+
memorySeed?: MemorySeed | null;
|
|
148
152
|
lease: PeerLease;
|
|
149
153
|
execution: ExecutionRoot;
|
|
150
154
|
}) => ResolvedTaskSpec | Promise<ResolvedTaskSpec>;
|
|
@@ -196,9 +200,6 @@ export interface ServiceCoreDeps {
|
|
|
196
200
|
export interface ServiceStoreDeps {
|
|
197
201
|
/** Durable async-run registry + event log (S1/S2). Enables /v1/runs when present. */
|
|
198
202
|
runStore?: RunStore;
|
|
199
|
-
/** E18 resume-at: the eventId→entryId anchor map (tidb/pg/local). Present whenever a backend is — resolveSpec
|
|
200
|
-
* resolves body.resumeAt(eventId)→entryId, the run lifecycle captures per-turn anchors, E21 purges them. */
|
|
201
|
-
resumeAnchorStore?: ResumeAnchorStore;
|
|
202
203
|
/** Per-session approval exemption store — enables decide body `remember:"session"` + the
|
|
203
204
|
* exemptions list/revoke surfaces on /v1/approvals. The ask-gate probe is wired separately (main.ts). */
|
|
204
205
|
approvalExemptionStore?: ApprovalExemptionStore;
|
|
@@ -215,9 +216,6 @@ export interface ServiceStoreDeps {
|
|
|
215
216
|
* 封不了就不落,没有「明文照写」的第二种装配。嵌入方:`checkpointCtxSealing: await ensureCheckpointCtxSealing(sealedKeyDir)`
|
|
216
217
|
* (保管目录要跨重启持久、多副本各副本是同一份钥匙,否则封它的那把钥匙不在 ⇒ 409 `conflict.checkpoint_ctx_unsealable` `reason:"key_not_held"`)。 */
|
|
217
218
|
checkpointCtxSealing?: import("./checkpoint-ctx.js").CheckpointCtxSealing;
|
|
218
|
-
/** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). Enables PUT/GET /v1/sessions/:id/policy
|
|
219
|
-
* when present; core reads the rules at prepare-time (subtract-only) via RunnerDeps.sessionPolicyStore (wired separately). */
|
|
220
|
-
sessionPolicyStore?: ServiceSessionPolicyStore;
|
|
221
219
|
/** [ref] tool-results 读面([ref] 请求,core [ref] `buildToolResultRef` 到货):`GET /v1/tasks/:id/
|
|
222
220
|
* tool-results/:ref` 的数据源 —— 与 RunnerDeps 侧的 offload 店**同实例**(main.ts 的 `toolResultStore`,
|
|
223
221
|
* 即「durable 后端在场」那一只;无 backend 部署里 Runner 用的内存兜底 `runnerOffloadStore` **不接**这里)。
|
|
@@ -225,14 +223,6 @@ export interface ServiceStoreDeps {
|
|
|
225
223
|
* 与 unknown-ref / 归属不符两臂**同形** 404 才是防 oracle 的收口([ref] 的「另定」项按防 oracle 收紧)。
|
|
226
224
|
* 这是本组「absent ⇒ 501 诚实缺席」通例的**唯一具名例外**,例外理由即上一句。 */
|
|
227
225
|
toolResultStore?: ToolResultStoreFull;
|
|
228
|
-
/** [ref] per-edited-file rewind history store. Present ⇒ the rewind capabilities are advertised; core uses it
|
|
229
|
-
* via RunnerDeps.fileHistoryStore (first-touch tracking + per-turn boundaries + tracked-set restore, ANY
|
|
230
|
-
* env). Also the 2c history-transfer store (exportHistory/importHistory + blob negotiation faces).
|
|
231
|
-
* 🔴 [ref]:这是装配单点 `assembleFileHistory` 的**店**(后端在即在,与 `FILE_HISTORY_CAPTURE` 无关 —— 旋钮只关捕获,
|
|
232
|
-
* 落在 core 的 `RunnerDeps.fileHistoryCapture` 上)。rewind 族四位与 2c sync 路由族跟它走;能力词 `fileHistoryCapture`
|
|
233
|
-
* = `fileHistoryCaptureOf(本键, config.fileHistoryCapture)`(与 core 捕获位同一只判定)。
|
|
234
|
-
* 擦除(E21 / 孤儿 blob GC)不读本键,读 boot 侧的擦除脸。 */
|
|
235
|
-
fileHistoryStore?: ServiceFileHistoryStore;
|
|
236
226
|
/** D-1 通用文件上传(clay 拍 2026-07-27:独立附件 store,不骑 snapshot blob 面):enables
|
|
237
227
|
* POST/GET/DELETE /v1/attachments*。缺席 ⇒ 501(与其他可选 store 面同姿)。绑定/物化半场在
|
|
238
228
|
* main.ts(resolveSpec + env factory 包装);本面只管上传/取回/删除三动词 + server 权威上限。 */
|
|
@@ -423,11 +413,11 @@ export interface ServiceSeamDeps {
|
|
|
423
413
|
*/
|
|
424
414
|
deviceEnrollment?: import("../device-enrollment.js").DeviceEnrollment;
|
|
425
415
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
416
|
+
* 会话登记簿的**绑定写座**(`boot/execution-env.ts` `createSessionScopedRegistries`:cwd / shellEnv / inheritEnv 三格写一笔、按回执撤一笔)。
|
|
417
|
+
* 唯一写者 = `session-bindings.ts` 的 `commitLegBindings`(四个 run 认领点在认领之后调);唯一撤回者 = 提交出口(`submission-exit.ts`,
|
|
418
|
+
* 写了之后才收场 `refused` 的提交)。律与残余见 `session-bindings.ts` 头注。缺席(夹具 / 嵌入方没接)= 没有登记簿 ⇒ 提交点 no-op。
|
|
429
419
|
*/
|
|
430
|
-
|
|
420
|
+
sessionBindings?: import("../session-bindings.js").SessionBindingSeat;
|
|
431
421
|
/**
|
|
432
422
|
* 会话登记簿四表(cwd / shellEnv / inheritEnv / 属主,`boot/execution-env.ts` `createSessionScopedRegistries` 的 `dropSessionOf`)按**住客**清掉一只 ——
|
|
433
423
|
* 记下的住客恰是交来的化身才清、答 `true`。读者只有提交出口(`submission-exit.ts`):被拒提交铸下的会话撤回之后清(同 id 的下一位已登记、写下的条目不动)。
|
|
@@ -442,12 +432,14 @@ export interface ServiceSeamDeps {
|
|
|
442
432
|
} & Record<string, unknown>) | undefined>;
|
|
443
433
|
/** E21 删除协调器(会话三态 活 → 在删 → 没了,`session-deletion.ts`):删会话的对话史与服务自己的 run 账 / 检查点 / 卸载结果等全部挂靠行,一次调用。
|
|
444
434
|
* 结局 = {@link SessionPurgeOutcome}(删了 / 不在 · 围栏判到认领 · 子代预检拒 · 被接管)。点亮 DELETE /v1/sessions/:id。 */
|
|
445
|
-
purgeSession?: (sessionId: string, owner: string | null
|
|
435
|
+
purgeSession?: (sessionId: string, owner: string | null, opts?: {
|
|
436
|
+
readonly ageOut?: SessionAgeOutExpectation;
|
|
437
|
+
}) => Promise<SessionPurgeOutcome>;
|
|
446
438
|
/** [ref]③(b): read a BACKGROUND agent-handle child's final report / current status out of the core
|
|
447
439
|
* TaskRegistry (the same face the TaskOutput tool reads — agent handles are NEVER in the run store).
|
|
448
440
|
* Wired in main.ts to `defaultTaskRegistry.pollTask` (non-blocking). Access is the REGISTRATION tuple:
|
|
449
441
|
* owner = the parent run's taskId (resume legs register children under the sessionId — the registry's
|
|
450
|
-
* sessionScoped arm matches via `access.sessionId`), scope = the run's
|
|
442
|
+
* sessionScoped arm matches via `access.sessionId`), scope = the run owner's engine-identity cell (`engineScopeOfOwner`). */
|
|
451
443
|
subagentTaskOutput?: (handle: string, access: {
|
|
452
444
|
owner: string;
|
|
453
445
|
scope: string;
|
|
@@ -724,7 +716,7 @@ export interface ServiceDeploymentDeps {
|
|
|
724
716
|
*/
|
|
725
717
|
deploymentModPackages?: number;
|
|
726
718
|
/**
|
|
727
|
-
* 会话 →
|
|
719
|
+
* 会话 → 登记的工作目录(受理的提交经绑定写座 {@link ServiceDeps.sessionBindings} 写的那一张进程内表,`boot/execution-env.ts` `createSessionScopedRegistries`)。
|
|
728
720
|
* **只读**,读者只有 run 外回退口(`POST /v1/sessions/:id/rewind-files`):host 工厂按 `effectiveHostWorkspace(本表.get(会话), ctx)` 定根(`execution-env.ts`
|
|
729
721
|
* host 臂),口在交引擎之前用**同一只函数、同一份入参**问「工厂这一次会不会落到一只用完即删的临时目录」—— 会 ⇒ 拒,不让台账说恢复了而项目没动。
|
|
730
722
|
* 缺席(夹具 / 嵌入方没接)⇒ 读作「没有登记」⇒ host 车道上口拒(fail-closed)。
|
|
@@ -950,6 +942,8 @@ export declare function createHttpServer(rawDeps: ServiceDeps): http.Server & {
|
|
|
950
942
|
redeemParkedAsk: ParkedAskRedeem;
|
|
951
943
|
/** 会话通知门(装配层把它接进场景层后台完成 sink 的晚绑座;门与律见 `session-notify-door.ts`)。 */
|
|
952
944
|
sessionNotifyDoor: SessionNotifyDoor;
|
|
945
|
+
/** run 收场送达的转交(装配层把它接进 workflow 编排面完成送达的晚绑座;律见 `resume-legs.ts` 的 `handOverRunEndedDecisions`)。 */
|
|
946
|
+
handOverRunEndedDecisions: (runId: string) => Promise<void>;
|
|
953
947
|
};
|
|
954
948
|
/** SSE: replay durable events after Last-Event-ID, then tail until the run is terminal (or stale). */
|
|
955
949
|
/**
|
package/dist/http/server.js
CHANGED
|
@@ -226,7 +226,7 @@ export function createHttpServer(rawDeps) {
|
|
|
226
226
|
const { quotaExceeded, ownerCostQuotaDenied, ownerFleetLeaseDenied, ownerLeaseDenied, ownerQuotaDenied, leaseDenied, usageWindowDenialFor, usageWindowDenied, rateLimited, safeDecode, readJson, readRawBody } = createRequestGuards({ deps });
|
|
227
227
|
const { prepareSpec } = createAdmission({ deps, readJson, runnerFor });
|
|
228
228
|
const { admitRun } = createRunConcurrencyGate({ deps, inflightRuns, steerableRuns });
|
|
229
|
-
const { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg, decisionRowAdmits, resumePreempted, startFreshHostTurn, resumeWake, sessionNotifyDoor } = createResumeLegs({ deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode, prepareSpec, finalizeTaskResult, ownerCostQuotaDenied, ownerFleetLeaseDenied, usageWindowDenialFor });
|
|
229
|
+
const { routeCtxBase, resumeCheckpoint, driveResumeIntoRunLog, driveResumeLeg, decisionRowAdmits, resumePreempted, startFreshHostTurn, resumeWake, sessionNotifyDoor, handOverRunEndedDecisions } = createResumeLegs({ deps, runnerFor, idemCache, inflightRuns, preemptableRuns, steerableRuns, wakeParkMints, counters, readJson, readRawBody, rateLimited, quotaExceeded, ownerQuotaDenied, leaseDenied, ownerLeaseDenied, usageWindowDenied, admitRun, safeDecode, prepareSpec, finalizeTaskResult, ownerCostQuotaDenied, ownerFleetLeaseDenied, usageWindowDenialFor });
|
|
230
230
|
const { denyExpiredApprovals, redeemParkedAsk } = createApprovalSweeps({ deps, resumeCheckpoint, decisionRowAdmits });
|
|
231
231
|
const { handle } = createDispatch({ deps, noteActivity, routeCtxBase, counters });
|
|
232
232
|
const server = http.createServer((req, res) => {
|
|
@@ -289,6 +289,6 @@ export function createHttpServer(rawDeps) {
|
|
|
289
289
|
deps.planCacheProbe?.record(principal, objective, result.terminal.kind === "completed");
|
|
290
290
|
}
|
|
291
291
|
const isRunLiveOnThisReplica = (taskId) => liveRunIdsOf(inflightRuns, steerableRuns).has(taskId);
|
|
292
|
-
return Object.assign(server, { denyExpiredApprovals, isRunLiveOnThisReplica, redeemParkedAsk, sessionNotifyDoor });
|
|
292
|
+
return Object.assign(server, { denyExpiredApprovals, isRunLiveOnThisReplica, redeemParkedAsk, sessionNotifyDoor, handOverRunEndedDecisions });
|
|
293
293
|
}
|
|
294
294
|
//# sourceMappingURL=server.js.map
|
package/dist/http/submit-ctx.js
CHANGED
|
@@ -29,11 +29,11 @@ function unsealableRefusal(e) {
|
|
|
29
29
|
function rowTooLargeRefusal(tooLarge) {
|
|
30
30
|
switch (tooLarge.wall) {
|
|
31
31
|
case "row":
|
|
32
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row
|
|
32
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database keeps in one row — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's single-row limit (TiDB performance.txn-entry-size-limit)`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
33
33
|
case "statement":
|
|
34
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement
|
|
34
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than the database accepts in one statement — nothing was run; shrink the inline images / userAttachments, or ask the operator to raise the database's max_allowed_packet`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
35
35
|
case "value":
|
|
36
|
-
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value
|
|
36
|
+
return { status: 413, body: refusalBody({ errorCode: "request.payload_too_large", message: `the database refused to store this task: it is larger than PostgreSQL holds in one value — nothing was run; shrink the inline images / userAttachments`, facts: limitFactsUnmeasured("body", "bytes") }) };
|
|
37
37
|
default: {
|
|
38
38
|
const unhandled = tooLarge.wall;
|
|
39
39
|
throw new Error(`row-too-large refusal without an HTTP answer: ${String(unhandled)}`);
|
|
@@ -62,7 +62,7 @@ export async function persistSubmitCtx(store, deps, claim, sessionId, fields) {
|
|
|
62
62
|
}
|
|
63
63
|
if (tooLarge === undefined)
|
|
64
64
|
throw err;
|
|
65
|
-
deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall
|
|
65
|
+
deps.logger?.warn("submit_ctx_row_too_large", { sessionId, taskId: claim?.taskId, wall: tooLarge.wall });
|
|
66
66
|
return rowTooLargeRefusal(tooLarge);
|
|
67
67
|
}
|
|
68
68
|
return landed === "claim_released" ? SUBMIT_CTX_CLAIM_LOST : undefined;
|
|
@@ -77,6 +77,7 @@ export async function persistSubmissionCtx(store, deps, claim, prepared) {
|
|
|
77
77
|
memoryScope: prepared.auth?.memoryScope,
|
|
78
78
|
...(screened || prepared.bodyFromScreenedCtx === true ? { promptScreened: true } : {}),
|
|
79
79
|
...(prepared.legFacts?.projectContext !== undefined ? { projectContext: prepared.legFacts.projectContext } : {}),
|
|
80
|
+
...(prepared.legFacts?.memorySeed !== undefined ? { memorySeed: prepared.legFacts.memorySeed } : {}),
|
|
80
81
|
writerVersion: serviceVersion(),
|
|
81
82
|
});
|
|
82
83
|
}
|
|
@@ -41,6 +41,14 @@ export interface TaskRequestAttachments {
|
|
|
41
41
|
export interface TaskRequestBody {
|
|
42
42
|
objective: string;
|
|
43
43
|
sessionId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 这一次提交建的会话是哪一**种**(闭集一词 `"sidechain"` = 客户端放置的子代对话;缺席 = 顶层对话;律在 `session-kind.ts`)。
|
|
46
|
+
* 只在**建这只会话的那一笔**写下(不带 `sessionId` / 带一只还不存在的 id),此后终身不改:带键提交到一只既有的会话 ⇒ 种类相等照常、不等 409
|
|
47
|
+
* `conflict.session_kind_mismatch`(会话一字节不变,体上机读位 `sessionKind` = 行上的词,顶层行缺席);不带键 = 不声明(续轮不必重发)。
|
|
48
|
+
* 词表外 ⇒ 400 `request.field_invalid`;部署记不了种类(能力位 `sessionKinds` 为空)⇒ 400 `request.precondition_unmet`,都在任何写之前。
|
|
49
|
+
* 续跑腿不读不判(键随存体留着)。
|
|
50
|
+
*/
|
|
51
|
+
sessionKind?: "sidechain";
|
|
44
52
|
/** Which deployment SCENARIO assembles this task's tools/prompt/skills (the keys of the worker's scenario
|
|
45
53
|
* table — e.g. "default"/"code"/"code-review"/"scan"/"cowork"). An INTENT bounded by the deployment's own table AND,
|
|
46
54
|
* on a governed worker, by the principal's center-resolved allowlist: an unknown name is a typed 400
|
|
@@ -240,7 +248,9 @@ export interface TaskRequestBody {
|
|
|
240
248
|
* (unknown ⇒ 404 `rewind_files_to.unknown_event`). Honored ONLY when `resumeAt` is ABSENT (the two modes are mutually
|
|
241
249
|
* exclusive). Requires the anchor map + a FileHistoryStore + the session store's head read (capability
|
|
242
250
|
* `rewindFilesTo`). Its out-of-run twin — no run, no model call — is `POST /v1/sessions/:id/rewind-files` with the same
|
|
243
|
-
* handle in `to` (capability `sessionRewindFiles`).
|
|
251
|
+
* handle in `to` (capability `sessionRewindFiles`). Not accepted together with `cascade: true` — the ladder's rungs
|
|
252
|
+
* run on sessions the engine mints, so there is no history of this session to restore from ⇒ 400 `request.field_conflict`
|
|
253
|
+
* (`reason: "cascade_verify"`, `fields: ["rewindFilesTo", "cascade"]`) at admission, before any side effect. */
|
|
244
254
|
rewindFilesTo?: string;
|
|
245
255
|
/** [ref](core 7.31.0 [ref] `TaskSpec.fileHistory`)—— 请求级的**文件历史关断词**,唯一词 `"disabled"`(core 的拼法,
|
|
246
256
|
* 与 `checkpointStore` 同;没有 `"enabled"` —— 缺席就是「部署说了算」的唯一形,声明只能单向收紧)。`"disabled"` ⇒
|
|
@@ -449,9 +459,9 @@ export interface TaskRequestBody {
|
|
|
449
459
|
* authorizer(core `PROJECT_ID_REGEX`,不合形状=422 typed `invalid_project_id`)。**大小写不敏感收、
|
|
450
460
|
* 归一小写用**([ref]/[ref]:词法与 core 的格式单源对齐,带 /i;收下后折小写再派生 scope/查表 ——
|
|
451
461
|
* 同一个 id 的两种大小写写法落同一只记忆盘)。多租户 DB 记忆面下它把派生
|
|
452
|
-
* scope 从 user 盘切到项目盘(`proj:<tenant>/<projectId>`)
|
|
453
|
-
* 作 memory.scopes
|
|
454
|
-
* Rides the persisted body onto resume legs(与 memoryWrite 同姿势)。
|
|
462
|
+
* scope 从 user 盘切到项目盘(`proj:<tenant>/<projectId>`);它对提交者**可见**时(`project-registry.ts`,与 `GET /v1/projects/:id` 同一只判)
|
|
463
|
+
* 那只登记的 defaultScopes 作 memory.scopes 种子(看不见 / 未登记 ⇒ 无种子,同答);单用户部署忽略派生(memoryScopeFor 不变),仅种子生效。
|
|
464
|
+
* Rides the persisted body onto resume legs(与 memoryWrite 同姿势)—— 种子不随体:续跑腿只认提交腿冻结的种子(`CheckpointCtx.memorySeed`,以冻结的观者重判)。
|
|
455
465
|
* 7.150.0 起它(或会话行上声明过的项目)也选这条 run **继承的项目上下文**(`project-context.ts`;能力位 `projectInheritance`):登记对提交者可见且带内容证明 ⇒
|
|
456
466
|
* 项目简报进系统提示追加折叠的中段、射程内第一条 folder 填缺席的 `cwd`;判一次、随 run 冻结。项目继承来的成员参与的拒,`fields` 以本键为坐标。 */
|
|
457
467
|
projectId?: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* **身份来源闭集 + run 行身份元组** —— 叶子模块(零依赖):凭据门(`http/principal-gate.ts`)、run 店契约(`plugins/store-contracts.ts`)、
|
|
3
3
|
* 三只 run 店与 leader run 店(`plugins/leader-run-store-sql.ts`)、中央建表语句(`plugins/tidb-pool.ts` / `plugins/pg-pool.ts`)与 `/health` 自报位读同一份。
|
|
4
4
|
*
|
|
5
|
-
* ## 律(
|
|
5
|
+
* ## 律(五条;全仓只在这里写一次)
|
|
6
6
|
* 1. **一张表、一个次序**:{@link IDENTITY_SOURCES} 的序 = 凭据门的判定次序(`verifiedIdentitySource` 答表里第一个验得过的词)= `/health.auth.kinds` 的出现序。
|
|
7
7
|
* 出示了部署的 service 凭据就是 `service_token` —— 哪怕同一枚 Bearer 也被鉴权桥验成登录令牌、哪怕运维给这枚凭据起的系统名叫 `sso`;
|
|
8
8
|
* 验不过 service 凭据而鉴权桥挂了身份 ⇒ `sso`;都没有而直连门 principal 令牌验过 ⇒ `direct_door_jwt`。
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* 4. **令牌声明装不进它的列就不记**(不截断:截断 = 两个不同的值折成一个):`sso` 臂从验过的令牌铸元组时,某一格装不进它的列宽({@link RUN_IDENTITY_CLAIM_COLUMNS})
|
|
16
16
|
* ⇒ 那一格「未记录」—— 可空的格(化身号)记 `null`;必填的格(scope)装不下就铸不出合形元组 ⇒ 无元组。两格结果不同来自元组的型,不是两条规则:
|
|
17
17
|
* 同一只判({@link runIdentityClaimOverflow})、同一行告警 `run_identity_claim_unrecorded { claim, chars, max }`(凭据门的铸点发;只名与长度,不带值)。
|
|
18
|
+
* 5. **凭据门认哪几类来源,一列答**({@link passesCredentialGate}):service 凭据与鉴权桥验过的登录令牌过门,直连门 principal 令牌不过(它只证审批决定者是谁)。
|
|
19
|
+
* 两道门读这同一列、各问各的事:全局凭据门(401)只在部署配了 service 凭据时武装({@link hasServiceAuth});fail-closed 写门(503:计费提交 / bake / 改写门 /
|
|
20
|
+
* 破坏性会话写 / 停驻赎回开新腿)恒武装,问的是**这次请求**带没带过门的凭据,`ALLOW_UNAUTHED_WRITES` 是它唯一的逃生口 —— 写门不读任何部署级布尔:
|
|
21
|
+
* 部署接没接过门的来源,落在「这次请求验不验得出」里(没接 ⇒ 没有一次请求验得出 ⇒ 照拒)。
|
|
18
22
|
*
|
|
19
23
|
* 化身号 `principalInc`:令牌 `sub_inc` 声明原样(契约包 `VerifiedIdentity.principalInc`)。来源链只有一条 —— 验证器读出 → 注入边界再判形(`auth-bridge.ts` 的
|
|
20
24
|
* `admitBridgeIdentity`)→ 入口预认证挂 request-local(`security.ts` 的 `setSsoPrincipalInc`)→ 凭据门 `admitRunIdentity` 的 `sso` 臂铸进元组(律 4)→ 建行原样写入。
|
|
@@ -46,9 +50,22 @@ export declare function authBridgeIssuerOf(config: Pick<IdentitySourceConfig, "a
|
|
|
46
50
|
readonly issuer: string;
|
|
47
51
|
readonly source: "explicit" | "fallback";
|
|
48
52
|
} | undefined;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
53
|
+
/**
|
|
54
|
+
* 「这台部署配了任何一把 service 凭证吗」—— 身份来源 `service_token` 接没接线的那一句,也是**全局凭据门的武装谓词**(配了 ⇒ 门后各口不带过门凭据就 401;
|
|
55
|
+
* 没配 ⇒ 门不武装,写门照样只认过门的凭据,见文件头律 5)。**单一属主**(手抄迟早只改一处):全局凭据门的武装(`http/dispatch.ts`)、门前读路谓词与 `/health` 读者档
|
|
56
|
+
* (同文件 `readCredentialOk` / `healthReaderOf`,问的都是「门武装没有」)、监听收窄与两条单用户边界不变量(`bind-host.ts` 的 `bindMustNarrow`,`config-invariants.ts`)、
|
|
57
|
+
* 多租无 fleet 凭据的启动期告警(`boot/stage-07-capability-layer.ts`)、以及 {@link configuredIdentitySources} 读同一句。**不是**写门的判据(写门问请求,律 5)。
|
|
58
|
+
*/
|
|
51
59
|
export declare function hasServiceAuth(config: Pick<IdentitySourceConfig, "authToken" | "authTokens">): boolean;
|
|
60
|
+
/** 凭据门认的那几类来源(律 5;{@link passesCredentialGate} 收窄到它)。 */
|
|
61
|
+
export type CredentialGateSource = Extract<IdentitySource, "service_token" | "sso">;
|
|
62
|
+
/**
|
|
63
|
+
* 🔴 **律 5 的那一列:这一类来源过不过凭据门**(缺席 = 这次请求没有验过的来源 ⇒ 不过)。service 凭据是部署发的凭据;鉴权桥验过的登录令牌由本部署信任的签发方签、
|
|
64
|
+
* 主体就是令牌里的那一位(主体头盖不过它);直连门 principal 令牌只证审批决定者是谁,从来不替代凭据。穷举:加一个来源不接这里 ⇒ 编译红。
|
|
65
|
+
* 读者:全局凭据门的 401 与 fail-closed 写门的 503(`http/dispatch.ts`,读同一次 `verifiedIdentitySource` 的答案)、停驻赎回席(`http/approval-sweeps.ts`)、
|
|
66
|
+
* 以及它在部署上的投影 —— 部署形表行 `credentialGateSource`(`deployment-shape.ts`;请求面不读那一行,写门问的是请求)。
|
|
67
|
+
*/
|
|
68
|
+
export declare function passesCredentialGate(kind: IdentitySource | undefined): kind is CredentialGateSource;
|
|
52
69
|
/**
|
|
53
70
|
* 🔴 **「这台部署能回哪几个身份来源」的唯一读法**({@link IDENTITY_SOURCES} 里配置接了线的那几个词,序同表)。读者:部署形表的 `identity` 轴
|
|
54
71
|
* (`deployment-shape.ts`,「有没有身份边界」那一行由它答)、`/health.auth`(自报位,`http/health-self-report.ts`)、server-as-peer 受众门(`http/server.ts`)。
|
package/dist/identity-source.js
CHANGED
|
@@ -23,6 +23,20 @@ function identitySourceConfigured(kind, config) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
export function passesCredentialGate(kind) {
|
|
27
|
+
switch (kind) {
|
|
28
|
+
case "service_token":
|
|
29
|
+
case "sso":
|
|
30
|
+
return true;
|
|
31
|
+
case "direct_door_jwt":
|
|
32
|
+
case undefined:
|
|
33
|
+
return false;
|
|
34
|
+
default: {
|
|
35
|
+
const unknownKind = kind;
|
|
36
|
+
throw new Error(`identity sources: unknown identity source ${String(unknownKind)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
26
40
|
export function configuredIdentitySources(config) {
|
|
27
41
|
return IDENTITY_SOURCES.filter((k) => identitySourceConfigured(k, config));
|
|
28
42
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -41,5 +41,9 @@ export { judgeServedModelRoute, type ServedModelRouteView, type ServedModelRoute
|
|
|
41
41
|
export type { UserInputLedgerStore, UserInputAcceptance, NewUserInputAcceptance, OpenScanCursor, OpenScanPage, SettleHow, WriterGoneEvidence } from "./user-input-ledger.js";
|
|
42
42
|
export type { OrgDeliveryQuotaStore, OrgDeliveryQuotaPolicy, OrgDeliveryQuotaVerdict } from "./plugins/org-delivery-quota-store.js";
|
|
43
43
|
export type { ServerOrgDeliveryGate, ServerOrgDeliveryOutcome } from "./org-delivery-gate.js";
|
|
44
|
+
export type { LandedAttendantSeat, LandedAnchor, FileHistoryReplayResult, FileHistoryReplayFailure } from "./plugins/landed-attendants.js";
|
|
45
|
+
export type { LandedOutcome } from "./session-row.js";
|
|
46
|
+
export type { SessionFace } from "./session-incarnation.js";
|
|
47
|
+
export type { BlobGetter } from "./session-sync.js";
|
|
44
48
|
export { APPROVAL_GATE_KINDS, type ApprovalGateKind } from "./approval-content-kind.js";
|
|
45
49
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* 读不了家目录的车道(device:设备协议没有读数)不持座 —— 声明就是座,起服披露「来自声明、未实测」(`execution-lane-caps.ts` `buildLaneHomeBootNote`)。
|
|
24
24
|
* 规则基与 422 门在下单那一刻就要家目录,而那一刻执行环境还没开 —— 它们只读主张(`executionLaneHomeDir`);环境开起来时主张被证,证不了的环境不开。
|
|
25
25
|
*/
|
|
26
|
+
import type { ExecutionEnvRefusalCode } from "./execution-env-refusal.js";
|
|
26
27
|
/** 探针答案的行首标记:登录脚本 / profile 往 stdout 打的横幅不会被读成家目录 —— 只认带这个标记的那一行(恰一条,见 `markedHome`)。 */
|
|
27
28
|
export declare const LANE_HOME_PROBE_MARKER = "sema-lane-home=";
|
|
28
29
|
/**
|
|
@@ -72,14 +73,9 @@ export type LanePathFlavor = "posix" | "win32";
|
|
|
72
73
|
*/
|
|
73
74
|
export declare function judgeLaneHome(lane: string, claim: LaneHomeClaim, probe: LaneHomeProbe, paths?: LanePathFlavor): LaneHomeVerdict;
|
|
74
75
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* · `env.home_unconfirmed` —— 家目录主张证不了({@link judgeLaneHome} 的三形拒句:读不出 / 不是绝对路径 / 与实测不一致)。三形一个码:出路都在部署
|
|
78
|
-
* (声明、环境里的 `HOME`,或会话 `settings.env` 里的 `HOME`),消费端不按形分岔;是哪一形、怎么改,句子里说。
|
|
76
|
+
* 家目录拒的带码错误:句 = 判官的拒句原文,码 = `env.home_unconfirmed`(本仓 `env.*` 族的一员,闭集属主 `execution-env-refusal.ts`)。读数在铸环境时就到手的车道(host)
|
|
77
|
+
* 构造时抛它,工厂原样抛出;读数要环境起来才有的车道在建连时以同一码答(建连座的拒因表 `home_unconfirmed`)。
|
|
79
78
|
*/
|
|
80
|
-
export declare const EXECUTION_ENV_REFUSAL_CODES: readonly ["env.home_unconfirmed"];
|
|
81
|
-
export type ExecutionEnvRefusalCode = (typeof EXECUTION_ENV_REFUSAL_CODES)[number];
|
|
82
|
-
/** 家目录拒的带码错误:句 = 判官的拒句原文,码 = `env.home_unconfirmed`。读数在铸环境时就到手的车道(host)构造时抛它,工厂原样抛出。 */
|
|
83
79
|
export declare function laneHomeRefusal(verdict: NonNullable<LaneHomeVerdict>): Error & {
|
|
84
80
|
readonly code: Extract<ExecutionEnvRefusalCode, "env.home_unconfirmed">;
|
|
85
81
|
};
|
package/dist/lane-home-probe.js
CHANGED
|
@@ -61,7 +61,6 @@ export function judgeLaneHome(lane, claim, probe, paths = "posix") {
|
|
|
61
61
|
answered: true,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
export const EXECUTION_ENV_REFUSAL_CODES = ["env.home_unconfirmed"];
|
|
65
64
|
export function laneHomeRefusal(verdict) {
|
|
66
65
|
return Object.assign(new Error(verdict.refusal), { code: "env.home_unconfirmed" });
|
|
67
66
|
}
|
package/dist/leader/leader.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export interface ProvisionedWorker {
|
|
|
70
70
|
* (`runtime-governance.ts` `entryPermissionMode`)得出的入口词(`run-entry.ts` `leaderRunEntry`);地板缺席 ⇒ `{}`。leader 请求不带调用方的模式词,所以入口词就是地板本身(与 run-local 同)。
|
|
71
71
|
* 本 run 铸的每一条 spec 经 {@link withLeaderLeg} 从这一份取词;worker 的续跑体由它展开(`{ ...entry, objective }`)⇒ 首跑、续跑、修复腿同一个词。
|
|
72
72
|
* 入口词是 `plan` 的 run 进不了这条车道(`run-entry.ts` `leaderEntryRefusal`:worker 会话没有计划审阅通道)—— 受理口与出生处同判,到不了 worker。
|
|
73
|
-
* 热改 `AUTONOMY` 只影响之后起的 leader run:在飞的 run
|
|
73
|
+
* 热改 `AUTONOMY` 只影响之后起的 leader run:在飞的 run(含它后来 provision 的 worker,与经 HTTP 续跑腿赎回的停驻 worker —— 续跑口对带无人值守标的行照写下的体重放,
|
|
74
|
+
* `http/resume-legs.ts` `replayCtxOf`)保持它出生时盖下的这一份。
|
|
74
75
|
*/
|
|
75
76
|
export interface LeaderRunEntry {
|
|
76
77
|
readonly permissionMode?: PermissionMode;
|
package/dist/leg-facts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 一条腿的**部署事实**(执行车道 · run 技能名册 · 受理见证 ·
|
|
2
|
+
* 一条腿的**部署事实**(执行车道 · run 技能名册 · 受理见证 · 会话绑定 · 继承的项目上下文 · 登记簿默认读层的种子项目)—— server 自有的载体,**不搭引擎 spec 的车**。
|
|
3
3
|
*
|
|
4
|
-
* 规则:`TaskSpec` 是引擎的类型面,上面只放引擎读的成员。本仓装配器(`boot/resolve-spec.ts` 的 `createResolveSpec`)
|
|
4
|
+
* 规则:`TaskSpec` 是引擎的类型面,上面只放引擎读的成员。本仓装配器(`boot/resolve-spec.ts` 的 `createResolveSpec`)同时还判出六件
|
|
5
5
|
* 只有 server 自己读的事实 —— 它们以装配器**自己的输出对象**为键登记在这一张表里(单一铸点 {@link mintLegFacts}),由两只漏斗
|
|
6
6
|
* (受理 `http/admission.ts` 的 `prepareSpec` · 续跑 `http/resume-legs.ts` 的 `resolveResumeSpec`)在拿到装配输出的**同一只对象**时
|
|
7
7
|
* 读一次(唯一读口 {@link legFactsOf},读在 `stampSpecRoot` 复制之前),此后作普通值随 `PreparedTaskSubmission.legFacts` /
|
|
@@ -19,6 +19,8 @@ import type { ScenarioHands } from "./capabilities/hands-lane.js";
|
|
|
19
19
|
import type { RunSkillEntry } from "./capabilities/skills.js";
|
|
20
20
|
import type { DelegationRootWitness } from "./delegated-session-owner.js";
|
|
21
21
|
import type { ProjectContext } from "./project-context.js";
|
|
22
|
+
import type { MemorySeed } from "./project-registry.js";
|
|
23
|
+
import type { SessionBindings } from "./session-bindings.js";
|
|
22
24
|
/** 一条腿的部署事实(冻结记录)。 */
|
|
23
25
|
export interface LegFacts {
|
|
24
26
|
/** 执行车道:`none` ⇒ 无手孪生 Runner。读者 = 生产选路器。 */
|
|
@@ -28,15 +30,21 @@ export interface LegFacts {
|
|
|
28
30
|
/** 受理时读根会话行的那一读(会话 id + 住客)。读者 = 腿的会话行记录座(`session-workspace.ts`)。 */
|
|
29
31
|
readonly sessionWitness: DelegationRootWitness;
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
+
* 这条腿要写在根会话上的绑定(工作目录 · shell 环境 · 继承策略;装配器只算)。读者 = run 认领之后的唯一提交点(`session-bindings.ts` 的 `commitLegBindings`):
|
|
34
|
+
* 受理的那一刻写这一笔,写了之后才收场 `refused` 的提交由提交出口按回执撤回;以及三只组合入口(同步 / 后台 / 续跑腿的梯子与验证门):工作目录那一格
|
|
35
|
+
* (这条腿跑在的那一枚)经 `compositionLegRoot`(`task-cwd.ts`)交给它们驱动的每一条腿当交活方的工作目录。
|
|
33
36
|
*/
|
|
34
|
-
readonly
|
|
37
|
+
readonly sessionBindings: SessionBindings;
|
|
35
38
|
/**
|
|
36
39
|
* 这条 run 继承到的项目上下文(`project-context.ts`):新提交腿在装配器头部判出的那一份,续跑腿是从续跑重建输入重放的那一份。缺席 = 没继承。
|
|
37
40
|
* 读者 = 提交腿写续跑重建输入的那一笔(`submit-ctx.ts` `persistSubmissionCtx` → `CheckpointCtx.projectContext`):判一次、随 run 冻结。
|
|
38
41
|
*/
|
|
39
42
|
readonly projectContext?: ProjectContext;
|
|
43
|
+
/**
|
|
44
|
+
* 这条 run 的登记簿默认读层种子(`project-registry.ts`:种子项目 + 判出它的那一位观者;`null` = 提交带了项目、判过,无):新提交腿判出的,续跑腿是从续跑重建输入重放的那一份。
|
|
45
|
+
* 缺席 = 没什么可判(提交没带项目)或没判过(续跑重放的行早于种子判)。读者 = 提交腿写续跑重建输入的那一笔(`submit-ctx.ts` `persistSubmissionCtx` → `CheckpointCtx.memorySeed`):判一次、随 run 冻结。
|
|
46
|
+
*/
|
|
47
|
+
readonly memorySeed?: MemorySeed | null;
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* 铸事实(**单一属主**:只允许 `createResolveSpec` 的出口调用)。同一只对象被第二次铸 ⇒ 当场抛 —— 两个写者是漂移的成因,
|
package/dist/leg-facts.js
CHANGED
|
@@ -6,8 +6,9 @@ export function mintLegFacts(resolved, facts) {
|
|
|
6
6
|
hands: facts.hands,
|
|
7
7
|
skills: Object.freeze(facts.skills.map((e) => Object.freeze({ ...e }))),
|
|
8
8
|
sessionWitness: Object.freeze({ ...facts.sessionWitness }),
|
|
9
|
-
...(facts.
|
|
9
|
+
sessionBindings: Object.freeze({ ...facts.sessionBindings, ...(facts.sessionBindings.shellEnv !== undefined ? { shellEnv: Object.freeze({ ...facts.sessionBindings.shellEnv }) } : {}) }),
|
|
10
10
|
...(facts.projectContext !== undefined ? { projectContext: Object.freeze({ ...facts.projectContext }) } : {}),
|
|
11
|
+
...(facts.memorySeed !== undefined ? { memorySeed: facts.memorySeed === null ? null : Object.freeze({ projectId: facts.memorySeed.projectId, viewer: Object.freeze({ ...facts.memorySeed.viewer }) }) } : {}),
|
|
11
12
|
}));
|
|
12
13
|
return resolved;
|
|
13
14
|
}
|
package/dist/memory-scope.d.ts
CHANGED
|
@@ -175,8 +175,8 @@ export declare function memoryEngineRootFor(config: Pick<ServiceConfig, "memoryE
|
|
|
175
175
|
* 记忆搬到 `<localDataRoot>/memory-work`,存量记忆与控制面升级后隐形)。 */
|
|
176
176
|
export declare function fileMemoryEngineRoot(config: Pick<ServiceConfig, "memoryEngineDir">, fallbackRoot?: string): string;
|
|
177
177
|
/**
|
|
178
|
-
* 一条路径的**规范形**(给 {@link judgeMemoryRootOutsideDataRoot} 的 `canonical`
|
|
179
|
-
* · 既存的绝对路径 ⇒ **原样**交给 `realpath`(
|
|
178
|
+
* 一条路径的**规范形**(给 {@link judgeMemoryRootOutsideDataRoot} 的 `canonical` 座用的生产实现;host 车道的工作区托管判也读它):
|
|
179
|
+
* · 既存的绝对路径 ⇒ **原样**交给 `realpath`(core `physicalPathOf` = realpath(3):大小写不敏感的文件系统上返回盘上的拼写;符号链接、macOS 的 `/var` → `/private/var` 在这一步展平)。
|
|
180
180
|
* 不先在字串上折 `..`:操作系统在展开符号链接**之后**才折 `..`,`/link/..` 的真身是链接目标的父目录,字串折叠会把它读成 `/`;
|
|
181
181
|
* · 其余(尚不存在 / 相对)⇒ 绝对化(**不折叠**)后逐段走:既存的前缀每进一段取一次 `realpath`(符号链接在这一步展开),`..` 折在**已展开**的前缀上 ——
|
|
182
182
|
* 与操作系统同序(`/别名/../新目录` 的真身在链接目标的父目录下;先在字串上折会读成别名的父目录,判到另一只挂载上);第一段不存在起,余下是尚不存在的尾巴
|
|
@@ -194,8 +194,9 @@ export declare function canonicalPathOf(p: string): string;
|
|
|
194
194
|
/**
|
|
195
195
|
* **路径包含**(含相等)的判官:`child` 是不是 `root` 本身或它的后代 —— `path.relative(canonical(root), canonical(child))` 不是 `..`、不以 `..` 加分隔符起头、也不是绝对路径(跨盘符)。
|
|
196
196
|
* `..` 要按**整段**判:名为 `..data` 的子目录在其下;`startsWith("..")` 会把它读成在其外。`canonical` 座缺省 `path.resolve`(字串规范形),boot 递 {@link canonicalPathOf} 取符号链接展平后的形;
|
|
197
|
-
* 两侧同一只座(先 root、后 child)
|
|
198
|
-
*
|
|
197
|
+
* 两侧同一只座(先 root、后 child)。读者三处:记忆根「在数据根之外」那一判({@link judgeMemoryRootOutsideDataRoot})、起服时「配置根是不是工作区的祖先」那一判(`sema-config-dir.ts`)
|
|
198
|
+
* 与 host 车道工厂「腿的目录落在哪只本服务铸的临时根里」那一判(`plugins/remote-env-host.ts`,座 = {@link canonicalPathOf});
|
|
199
|
+
* 树里别处内联的同形表达式(`boot/deployment-mods.ts` · `plugins/local-data-dir-modes-m39.ts` · `plugins/remote-env-host.ts` 的残余镜像写判 · `plugins/worktree-isolation.ts`)不在本次收口范围。
|
|
199
200
|
*/
|
|
200
201
|
export declare function pathIsWithin(root: string, child: string, canonical?: (p: string) => string): boolean;
|
|
201
202
|
/** {@link judgeMemoryRootOutsideDataRoot} 的读数:记忆引擎的根落在本机数据根**之外**。三键即 boot 日志行的字段(`hint` 是一句带两条真路径的人话)。 */
|