@sema-agent/core 7.62.0 → 7.64.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/CHANGELOG.md +936 -0
- package/dist/agents/cc-peer-directory.js +1 -0
- package/dist/agents/cc-peer-wire.d.ts +4 -0
- package/dist/agents/cc-peer-wire.js +1 -0
- package/dist/agents/cc-uds-peer-channel.js +5 -0
- package/dist/agents/cross-session-judge.d.ts +3 -1
- package/dist/agents/cross-session-judge.js +4 -1
- package/dist/agents/peer-directory.d.ts +8 -0
- package/dist/agents/peer-directory.js +4 -0
- package/dist/agents/peer-held-queue.d.ts +9 -3
- package/dist/agents/peer-held-queue.js +12 -9
- package/dist/agents/peer-idle.d.ts +20 -1
- package/dist/agents/peer-idle.js +23 -12
- package/dist/agents/peer-notice-route.d.ts +16 -5
- package/dist/agents/peer-notice-route.js +11 -9
- package/dist/agents/peer-notices.d.ts +25 -8
- package/dist/agents/peer-notices.js +6 -1
- package/dist/agents/peer-session-drain.d.ts +32 -6
- package/dist/agents/peer-session-drain.js +100 -26
- package/dist/agents/send-message-tool.d.ts +7 -0
- package/dist/agents/send-message-tool.js +18 -6
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.js +102 -54
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/allow-entry.d.ts +4 -0
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-origin.d.ts +1 -1
- package/dist/core/ask-origin.js +2 -2
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/ask-unresolvable-notice.d.ts +13 -4
- package/dist/core/ask-unresolvable-notice.js +10 -3
- package/dist/core/auto-compaction.d.ts +7 -5
- package/dist/core/background-agent-store.d.ts +7 -0
- package/dist/core/background-agent-store.js +3 -0
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-queries.d.ts +50 -4
- package/dist/core/checkpoint-queries.js +42 -17
- package/dist/core/checkpoint-requirements.d.ts +3 -3
- package/dist/core/checkpoint-requirements.js +2 -1
- package/dist/core/checkpoint-row-verdict.d.ts +15 -4
- package/dist/core/checkpoint-row-verdict.js +22 -2
- package/dist/core/checkpoint-store.d.ts +28 -11
- package/dist/core/checkpoint-store.js +45 -4
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/context-settings.d.ts +40 -9
- package/dist/core/context-settings.js +32 -10
- package/dist/core/engine-attestation.d.ts +27 -7
- package/dist/core/engine-attestation.js +5 -1
- package/dist/core/engine-notice.d.ts +43 -5
- package/dist/core/extension-requester.d.ts +9 -0
- package/dist/core/extension-requester.js +7 -0
- package/dist/core/file-history-store.d.ts +28 -0
- package/dist/core/file-history-store.js +48 -5
- package/dist/core/fs-write-gate-policy.js +1 -1
- package/dist/core/gate-fold.js +2 -0
- package/dist/core/gate-lanes.js +2 -0
- package/dist/core/gate-outcome.d.ts +39 -2
- package/dist/core/gate-outcome.js +20 -1
- package/dist/core/git-worktree-env.d.ts +62 -3
- package/dist/core/git-worktree-env.js +91 -30
- package/dist/core/governance-codes.d.ts +9 -3
- package/dist/core/governance-codes.js +17 -3
- package/dist/core/leg-identity.d.ts +19 -1
- package/dist/core/leg-identity.js +12 -0
- package/dist/core/mailbox-store.d.ts +39 -4
- package/dist/core/mailbox-store.js +14 -2
- package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +74 -10
- package/dist/core/memory-engine/consolidation.js +183 -11
- package/dist/core/memory-engine/control-objects.d.ts +25 -0
- package/dist/core/memory-engine/control-objects.js +151 -0
- package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
- package/dist/core/memory-engine/control-plane-adoption.js +159 -0
- package/dist/core/memory-engine/data-plane.d.ts +8 -4
- package/dist/core/memory-engine/data-plane.js +11 -6
- package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
- package/dist/core/memory-engine/delegation-settlement.js +270 -85
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +11 -7
- package/dist/core/memory-engine/engine.d.ts +136 -58
- package/dist/core/memory-engine/engine.js +491 -394
- package/dist/core/memory-engine/entry-scan.d.ts +8 -0
- package/dist/core/memory-engine/entry-scan.js +3 -0
- package/dist/core/memory-engine/file-backend.d.ts +62 -60
- package/dist/core/memory-engine/file-backend.js +122 -198
- package/dist/core/memory-engine/index.d.ts +8 -7
- package/dist/core/memory-engine/index.js +7 -6
- package/dist/core/memory-engine/landing-admission.d.ts +5 -3
- package/dist/core/memory-engine/landing-admission.js +3 -3
- package/dist/core/memory-engine/layout.d.ts +127 -46
- package/dist/core/memory-engine/layout.js +264 -109
- package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
- package/dist/core/memory-engine/memory-backend-contract.js +476 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
- package/dist/core/memory-engine/memory-deployment.js +54 -15
- package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
- package/dist/core/memory-engine/origin-clearance.js +68 -9
- package/dist/core/memory-engine/scope-contract.d.ts +52 -11
- package/dist/core/memory-engine/scope-contract.js +68 -19
- package/dist/core/memory-engine/session-write-home.d.ts +37 -2
- package/dist/core/memory-engine/session-write-home.js +38 -11
- package/dist/core/memory-engine/sync-client.d.ts +3 -1
- package/dist/core/memory-engine/sync-client.js +7 -0
- package/dist/core/memory-engine/sync-report.d.ts +3 -2
- package/dist/core/memory-engine/sync-report.js +6 -2
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +10 -10
- package/dist/core/memory-engine/types.d.ts +155 -19
- package/dist/core/memory-engine/types.js +2 -0
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +3 -3
- package/dist/core/mods/agent-stations.d.ts +18 -0
- package/dist/core/mods/agent-stations.js +8 -6
- package/dist/core/mods/extension-call.d.ts +4 -0
- package/dist/core/mods/extension-call.js +8 -0
- package/dist/core/mods/stations.d.ts +20 -1
- package/dist/core/mods/stations.js +21 -2
- package/dist/core/mods/tool-call.js +3 -4
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/park-selfcheck.js +2 -2
- package/dist/core/pause-registry.d.ts +2 -0
- package/dist/core/pause-registry.js +3 -0
- package/dist/core/peer-channel.d.ts +5 -0
- package/dist/core/permission-rule-consent.d.ts +26 -8
- package/dist/core/permission-rule-consent.js +76 -36
- package/dist/core/permission-rule-store.d.ts +72 -13
- package/dist/core/permission-rule-store.js +29 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/refusal-echo.d.ts +20 -0
- package/dist/core/refusal-echo.js +33 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/retention.d.ts +180 -10
- package/dist/core/retention.js +45 -0
- package/dist/core/retired-keys.d.ts +5 -0
- package/dist/core/retired-keys.js +3 -0
- package/dist/core/rule-offer-read.d.ts +0 -4
- package/dist/core/rule-offer-read.js +2 -18
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/classifier-ladder.d.ts +7 -1
- package/dist/core/runner/classifier-ladder.js +4 -2
- package/dist/core/runner/compact-session.js +10 -7
- package/dist/core/runner/compaction-call-options.d.ts +7 -7
- package/dist/core/runner/compaction-call-options.js +3 -2
- package/dist/core/runner/contracts.d.ts +39 -11
- package/dist/core/runner/delegation-owner.d.ts +10 -3
- package/dist/core/runner/delegation-owner.js +4 -1
- package/dist/core/runner/gate-exit.d.ts +6 -0
- package/dist/core/runner/gate-exit.js +13 -4
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
- package/dist/core/runner/memory-consolidation-driver.js +12 -9
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
- package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
- package/dist/core/runner/person-path-rows.d.ts +8 -3
- package/dist/core/runner/person-path-rows.js +5 -1
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-ask-lane.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
- package/dist/core/runner/prepare-config-doors.js +4 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +2 -2
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
- package/dist/core/runner/prepare-gate-stations.js +5 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
- package/dist/core/runner/prepare-hands-readface.js +5 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
- package/dist/core/runner/prepare-inherited-gate.js +12 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
- package/dist/core/runner/prepare-memory-engine-session.js +4 -4
- package/dist/core/runner/prepare-memory.d.ts +7 -2
- package/dist/core/runner/prepare-memory.js +41 -39
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-policy-chain.js +7 -7
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-task.js +26 -18
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +3 -2
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +2 -2
- package/dist/core/runner/resume-admission.js +2 -23
- package/dist/core/runner/role-resolution-table.d.ts +98 -0
- package/dist/core/runner/role-resolution-table.js +62 -0
- package/dist/core/runner/run-compaction-machinery.js +2 -2
- package/dist/core/runner/run-identity-wiring.js +12 -9
- package/dist/core/runner/run-leg.js +9 -5
- package/dist/core/runner/run-notification-lane.js +22 -22
- package/dist/core/runner/run-recovery-lanes.js +3 -3
- package/dist/core/runner/run-settle-and-teardown.js +3 -2
- package/dist/core/runner/run-terminal-adoption.js +1 -1
- package/dist/core/runner/run-turn-boundary.js +14 -15
- package/dist/core/runner/runtask.js +1 -1
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +4 -2
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner-deps.d.ts +7 -3
- package/dist/core/secret-env.d.ts +1 -1
- package/dist/core/secret-env.js +4 -4
- package/dist/core/session-checkout.d.ts +168 -0
- package/dist/core/session-checkout.js +579 -0
- package/dist/core/session-store.d.ts +12 -4
- package/dist/core/session-store.js +23 -3
- package/dist/core/session.d.ts +16 -2
- package/dist/core/session.js +3 -0
- package/dist/core/shell-read-silence.js +8 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
- package/dist/core/store-contracts/peer-directory-contract.js +8 -1
- package/dist/core/store-contracts/session-store-contract.js +39 -0
- package/dist/core/task-event.d.ts +30 -5
- package/dist/core/task-notification.d.ts +119 -32
- package/dist/core/task-notification.js +186 -100
- package/dist/core/task-registry-agent.d.ts +25 -2
- package/dist/core/task-registry-agent.js +56 -22
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry.d.ts +33 -9
- package/dist/core/task-registry.js +36 -18
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +27 -2
- package/dist/core/tool-errors.d.ts +14 -6
- package/dist/core/tool-errors.js +1 -1
- package/dist/core/tool-policy.d.ts +32 -13
- package/dist/core/tool-policy.js +27 -17
- package/dist/core/tool-result-store.d.ts +20 -0
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/trace.d.ts +3 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- package/dist/core/workflow-journal-store.d.ts +11 -0
- package/dist/core/workflow-journal-store.js +7 -0
- package/dist/core/workflow-run-store.d.ts +9 -0
- package/dist/core/workflow-run-store.js +6 -0
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/compaction/compaction.d.ts +2 -1
- package/dist/engine/harness/types.d.ts +67 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +30 -1
- package/dist/engine/session/session.js +48 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.js +12 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +8 -1
- package/dist/orchestration/run-workflow-tool.js +8 -0
- package/dist/orchestration/workflow-types.d.ts +2 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -2
- package/dist/stores/file/checkpoint-store.d.ts +6 -0
- package/dist/stores/file/checkpoint-store.js +4 -1
- package/dist/stores/file/file-history-store.d.ts +13 -0
- package/dist/stores/file/file-history-store.js +75 -13
- package/dist/stores/file/index.d.ts +11 -1
- package/dist/stores/file/index.js +7 -11
- package/dist/stores/file/permission-rule-store.d.ts +23 -0
- package/dist/stores/file/permission-rule-store.js +75 -7
- package/dist/stores/file/session-store.js +2 -1
- package/dist/stores/file/tool-result-store.d.ts +14 -0
- package/dist/stores/file/tool-result-store.js +39 -2
- package/dist/stores/file/workflow-journal-store.d.ts +4 -0
- package/dist/stores/file/workflow-journal-store.js +17 -0
- package/dist/stores/file/workflow-run-store.d.ts +3 -0
- package/dist/stores/file/workflow-run-store.js +15 -0
- package/dist/tools/fs/bash-program-position.js +3 -3
- package/dist/tools/fs/program-read-model.d.ts +34 -10
- package/dist/tools/fs/program-read-model.js +37 -7
- package/dist/tools/fs/program-read-model.rows.js +13 -2
- package/dist/tools/fs/read-deny.d.ts +28 -3
- package/dist/tools/fs/read-deny.js +18 -2
- package/dist/tools/fs/removal-targets.js +3 -3
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +1 -1
- package/dist/tools/fs/shell-read-argv.d.ts +8 -1
- package/dist/tools/fs/shell-read-argv.js +34 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
- package/dist/tools/fs/shell-read-bindings.js +5 -1
- package/dist/tools/fs/shell-read-brace.d.ts +18 -0
- package/dist/tools/fs/shell-read-brace.js +79 -0
- package/dist/tools/fs/shell-read-check.d.ts +8 -2
- package/dist/tools/fs/shell-read-check.js +16 -14
- package/dist/tools/fs/shell-read-establish.js +23 -16
- package/dist/tools/fs/shell-read-judge.d.ts +11 -0
- package/dist/tools/fs/shell-read-judge.js +3 -3
- package/dist/tools/fs/shell-read-plan.d.ts +10 -0
- package/dist/tools/fs/shell-read-plan.js +189 -93
- package/dist/tools/fs/shell-read-start.d.ts +19 -9
- package/dist/tools/fs/shell-read-start.js +20 -12
- package/dist/tools/fs/shell-read-word.d.ts +10 -0
- package/dist/tools/fs/shell-read-word.js +9 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
- package/dist/tools/fs/shell-read-workdir.js +73 -12
- package/dist/tools/fs/shell-read-write-targets.js +13 -8
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +7 -35
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +135 -11
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core-stores-sql@7.64.0.json +30 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/core@7.64.0.json +2653 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/mods-kernel@7.64.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/wire-changes/primitives@7.64.0.json +30 -0
- package/dist/core/credential-vocabulary.d.ts +0 -176
- package/dist/core/credential-vocabulary.js +0 -190
- package/dist/core/redaction-passes.d.ts +0 -82
- package/dist/core/redaction-passes.js +0 -377
|
@@ -4,6 +4,8 @@ import { egressText } from "./untrusted-egress.js";
|
|
|
4
4
|
import { redactThenCut } from "../agents/subagent-steps.js";
|
|
5
5
|
import { PEER_MESSAGE_NOTICE } from "../agents/peer-admission.js";
|
|
6
6
|
import { buildCrossSessionEnvelope, CROSS_PRINCIPAL_MESSAGE_NOTICE, CROSS_SESSION_MESSAGE_NOTICE, neutralizePeerBody } from "../agents/cross-session-envelope.js";
|
|
7
|
+
import { deliverEngineNotice } from "./engine-notice.js";
|
|
8
|
+
import { sameOccupant } from "./runner/delegation-owner.js";
|
|
7
9
|
export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(["completed", "failed", "killed", "cancelled"]);
|
|
8
10
|
export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate", "refused"]);
|
|
9
11
|
export function isNotificationInjectionOutcome(value) {
|
|
@@ -163,6 +165,23 @@ export const MAX_PENDING_EVENTS_PER_TASK = 50;
|
|
|
163
165
|
export const MAX_PENDING_EVENTS_PER_SESSION = 200;
|
|
164
166
|
export const MAX_PENDING_SESSIONS = 100;
|
|
165
167
|
export const MAX_SESSION_BOX_BINDINGS = 4096;
|
|
168
|
+
export function sessionAddressOf(leg) {
|
|
169
|
+
return { sessionId: leg.sessionId, occupant: leg.sessionIncarnation, ...(leg.sessionIncarnationUnread === true ? { unread: true } : {}) };
|
|
170
|
+
}
|
|
171
|
+
export function deliveryDiscardedNotice(address, current, payload, path) {
|
|
172
|
+
return {
|
|
173
|
+
code: "delegation.delivery_discarded",
|
|
174
|
+
message: `a ${inlineUntrusted(String(payload.task_type), 40)} frame of task ${inlineUntrusted(String(payload.task_id), 120)} was addressed to session ${inlineUntrusted(address.sessionId, 120)} under an occupant the session does not hold now (the id was deleted and created again, or the address carried no occupant), so it was discarded, not delivered`,
|
|
175
|
+
detail: {
|
|
176
|
+
taskId: payload.task_id,
|
|
177
|
+
taskType: payload.task_type,
|
|
178
|
+
sessionId: address.sessionId,
|
|
179
|
+
path,
|
|
180
|
+
addressed: address.occupant !== undefined ? "known" : "unknown",
|
|
181
|
+
current: current !== undefined ? "known" : "unknown",
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
166
185
|
export const HANDBACK_STATES = Object.freeze(["send", "flagged", "withheld"]);
|
|
167
186
|
export function handbackStateOf(facts) {
|
|
168
187
|
if (facts.warning !== undefined)
|
|
@@ -285,12 +304,12 @@ function malformedFacet(f) {
|
|
|
285
304
|
}
|
|
286
305
|
return undefined;
|
|
287
306
|
}
|
|
288
|
-
export function engineFrameRecordOf(payload, priority,
|
|
307
|
+
export function engineFrameRecordOf(payload, priority, to) {
|
|
289
308
|
return {
|
|
290
309
|
id: taskNotificationDedupKey(payload),
|
|
291
310
|
content: encodeEngineFrame(payload, priority),
|
|
292
311
|
sentAt: Date.now(),
|
|
293
|
-
peerMeta: { fromRoot:
|
|
312
|
+
peerMeta: { fromRoot: to.sessionId, kind: "engine_frame", ...(to.occupant !== undefined ? { occupant: to.occupant } : {}) },
|
|
294
313
|
};
|
|
295
314
|
}
|
|
296
315
|
const MAX_TOMBSTONES = 5_000;
|
|
@@ -387,6 +406,12 @@ export function retireTerminalDelivery(sink, task) {
|
|
|
387
406
|
if (typeof sink === "function")
|
|
388
407
|
LANE_OBLIGATIONS.get(sink)?.retire(task);
|
|
389
408
|
}
|
|
409
|
+
export function moveTerminalDelivery(from, to, task) {
|
|
410
|
+
if (from === to)
|
|
411
|
+
return;
|
|
412
|
+
retireTerminalDelivery(from, task);
|
|
413
|
+
oweTerminalDelivery(to, task);
|
|
414
|
+
}
|
|
390
415
|
export function createLiveNotificationLane(seat) {
|
|
391
416
|
const handedOff = new Set();
|
|
392
417
|
const enter = (admits) => (payload, priority, onDisposition) => {
|
|
@@ -420,62 +445,134 @@ export function createLiveNotificationLane(seat) {
|
|
|
420
445
|
}
|
|
421
446
|
export class SessionLiveNotificationLanes {
|
|
422
447
|
lanes = new Map();
|
|
423
|
-
register(
|
|
424
|
-
|
|
448
|
+
register(address, lane) {
|
|
449
|
+
if (address.unread === true)
|
|
450
|
+
return;
|
|
451
|
+
const existing = this.lanes.get(address.sessionId);
|
|
452
|
+
const seat = { occupant: address.occupant, lane };
|
|
425
453
|
if (existing === undefined)
|
|
426
|
-
this.lanes.set(sessionId, [
|
|
427
|
-
else if (!existing.
|
|
428
|
-
existing.push(
|
|
454
|
+
this.lanes.set(address.sessionId, [seat]);
|
|
455
|
+
else if (!existing.some((s) => s.lane === lane))
|
|
456
|
+
existing.push(seat);
|
|
429
457
|
}
|
|
430
|
-
unregister(
|
|
431
|
-
const existing = this.lanes.get(sessionId);
|
|
458
|
+
unregister(address, lane) {
|
|
459
|
+
const existing = this.lanes.get(address.sessionId);
|
|
432
460
|
if (existing === undefined)
|
|
433
461
|
return;
|
|
434
|
-
const at = existing.
|
|
462
|
+
const at = existing.findIndex((s) => s.lane === lane);
|
|
435
463
|
if (at !== -1)
|
|
436
464
|
existing.splice(at, 1);
|
|
437
465
|
if (existing.length === 0)
|
|
438
|
-
this.lanes.delete(sessionId);
|
|
466
|
+
this.lanes.delete(address.sessionId);
|
|
439
467
|
}
|
|
440
|
-
deliver(
|
|
441
|
-
const existing = this.lanes.get(sessionId);
|
|
468
|
+
deliver(address, payload, priority, opts) {
|
|
469
|
+
const existing = this.lanes.get(address.sessionId);
|
|
442
470
|
if (existing === undefined)
|
|
443
471
|
return "unavailable";
|
|
444
472
|
for (let i = existing.length - 1; i >= 0; i -= 1) {
|
|
445
|
-
const
|
|
473
|
+
const seat = existing[i];
|
|
474
|
+
if (!sameOccupant(seat.occupant, address.occupant))
|
|
475
|
+
continue;
|
|
476
|
+
const outcome = seat.lane(payload, priority, opts?.onDisposition);
|
|
446
477
|
if (outcome !== "unavailable")
|
|
447
478
|
return outcome;
|
|
448
479
|
}
|
|
449
480
|
return "unavailable";
|
|
450
481
|
}
|
|
482
|
+
holds(address) {
|
|
483
|
+
return this.lanes.get(address.sessionId)?.some((s) => sameOccupant(s.occupant, address.occupant)) === true;
|
|
484
|
+
}
|
|
451
485
|
get size() {
|
|
452
486
|
return this.lanes.size;
|
|
453
487
|
}
|
|
454
488
|
}
|
|
489
|
+
function parksDurably(payload, box) {
|
|
490
|
+
return payload.agentMessage !== undefined || (box.engineFrames === true && isEngineFrameParkable(payload));
|
|
491
|
+
}
|
|
492
|
+
function keysOf(held, address) {
|
|
493
|
+
const entry = held.get(address.sessionId);
|
|
494
|
+
return entry !== undefined && sameOccupant(entry.occupant, address.occupant) ? entry.keys : undefined;
|
|
495
|
+
}
|
|
496
|
+
function addOccupantKey(held, address, dedupKey) {
|
|
497
|
+
let mine = keysOf(held, address);
|
|
498
|
+
if (mine === undefined) {
|
|
499
|
+
held.delete(address.sessionId);
|
|
500
|
+
if (held.size >= MAX_PENDING_SESSIONS) {
|
|
501
|
+
const oldest = held.keys().next().value;
|
|
502
|
+
if (oldest !== undefined)
|
|
503
|
+
held.delete(oldest);
|
|
504
|
+
}
|
|
505
|
+
mine = new Set();
|
|
506
|
+
held.set(address.sessionId, { occupant: address.occupant, keys: mine });
|
|
507
|
+
}
|
|
508
|
+
mine.add(dedupKey);
|
|
509
|
+
if (mine.size > MAX_PENDING_EVENTS_PER_SESSION) {
|
|
510
|
+
for (const k of mine) {
|
|
511
|
+
mine.delete(k);
|
|
512
|
+
if (mine.size <= MAX_PENDING_EVENTS_PER_SESSION)
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
455
517
|
export class PendingSessionNotifications {
|
|
456
518
|
sessions = new Map();
|
|
519
|
+
noticeSeat;
|
|
520
|
+
constructor(seats) {
|
|
521
|
+
this.noticeSeat = seats?.onNotice ?? (() => undefined);
|
|
522
|
+
}
|
|
457
523
|
liveLanes = new SessionLiveNotificationLanes();
|
|
458
524
|
droppedSessions = 0;
|
|
459
525
|
evictedSessions = new Map();
|
|
460
526
|
unattributedDrops = 0;
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
if (box === undefined)
|
|
527
|
+
seats = new Map();
|
|
528
|
+
admit(address, box) {
|
|
529
|
+
if (address.unread === true)
|
|
465
530
|
return;
|
|
466
|
-
this.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (
|
|
531
|
+
this.seats.delete(address.sessionId);
|
|
532
|
+
this.seats.set(address.sessionId, { occupant: address.occupant, ...(box !== undefined ? { box } : {}) });
|
|
533
|
+
for (const id of this.seats.keys()) {
|
|
534
|
+
if (this.seats.size <= MAX_SESSION_BOX_BINDINGS)
|
|
470
535
|
break;
|
|
471
|
-
this.
|
|
536
|
+
if (!this.sessions.has(id))
|
|
537
|
+
this.seats.delete(id);
|
|
538
|
+
}
|
|
539
|
+
const parked = this.sessions.get(address.sessionId);
|
|
540
|
+
if (parked !== undefined && !sameOccupant(parked.occupant, address.occupant))
|
|
541
|
+
this.discardRecord(address.sessionId, parked, address.occupant);
|
|
542
|
+
for (const held of [this.evictedSessions, this.routed, this.durable]) {
|
|
543
|
+
const entry = held.get(address.sessionId);
|
|
544
|
+
if (entry !== undefined && !sameOccupant(entry.occupant, address.occupant))
|
|
545
|
+
held.delete(address.sessionId);
|
|
472
546
|
}
|
|
473
547
|
}
|
|
474
|
-
sessionBoxFor(
|
|
475
|
-
|
|
548
|
+
sessionBoxFor(address) {
|
|
549
|
+
const seat = this.seats.get(address.sessionId);
|
|
550
|
+
return seat !== undefined && sameOccupant(seat.occupant, address.occupant) ? seat.box : undefined;
|
|
476
551
|
}
|
|
477
|
-
|
|
478
|
-
const
|
|
552
|
+
discardsStale(address, payload) {
|
|
553
|
+
const seat = this.seats.get(address.sessionId);
|
|
554
|
+
if (address.unread !== true && (seat === undefined || sameOccupant(address.occupant, seat.occupant)))
|
|
555
|
+
return false;
|
|
556
|
+
const current = { sessionId: address.sessionId, occupant: seat?.occupant };
|
|
557
|
+
const path = seat !== undefined && this.liveLanes.holds(current) ? "live" : seat?.box !== undefined && parksDurably(payload, seat.box) ? "box" : "drain";
|
|
558
|
+
this.announceDiscard(address, seat?.occupant, payload, path);
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
announceDiscard(address, current, payload, path) {
|
|
562
|
+
deliverEngineNotice(this.noticeSeat(), deliveryDiscardedNotice(address, current, payload, path));
|
|
563
|
+
}
|
|
564
|
+
discardRecord(sessionId, record, current) {
|
|
565
|
+
if (this.sessions.get(sessionId) === record)
|
|
566
|
+
this.sessions.delete(sessionId);
|
|
567
|
+
for (const n of record.items)
|
|
568
|
+
this.announceDiscard({ sessionId, occupant: record.occupant }, current, n, "drain");
|
|
569
|
+
}
|
|
570
|
+
recordOf(address) {
|
|
571
|
+
const s = this.sessions.get(address.sessionId);
|
|
572
|
+
return s !== undefined && sameOccupant(s.occupant, address.occupant) ? s : undefined;
|
|
573
|
+
}
|
|
574
|
+
settleBoxDebts(address, signal) {
|
|
575
|
+
const owed = this.recordOf(address)?.boxDebts;
|
|
479
576
|
if (owed === undefined || owed.size === 0)
|
|
480
577
|
return undefined;
|
|
481
578
|
const debts = [...owed];
|
|
@@ -483,7 +580,7 @@ export class PendingSessionNotifications {
|
|
|
483
580
|
for (const [copy, debt] of debts) {
|
|
484
581
|
if (signal?.aborted === true)
|
|
485
582
|
return;
|
|
486
|
-
await this.settleBoxDebt(
|
|
583
|
+
await this.settleBoxDebt(address, copy, debt);
|
|
487
584
|
}
|
|
488
585
|
})();
|
|
489
586
|
}
|
|
@@ -498,11 +595,12 @@ export class PendingSessionNotifications {
|
|
|
498
595
|
if (p !== undefined)
|
|
499
596
|
tiers.set(n, p);
|
|
500
597
|
}
|
|
501
|
-
this.sessions.set(sessionId, { items: owing, dropped: new Map(), keys: new Set(owing.map((n) => taskNotificationDedupKey(n))), priorities: tiers, boxDebts: debts });
|
|
598
|
+
this.sessions.set(sessionId, { occupant: s.occupant, items: owing, dropped: new Map(), keys: new Set(owing.map((n) => taskNotificationDedupKey(n))), priorities: tiers, boxDebts: debts });
|
|
502
599
|
const rest = s.items.filter((n) => !debts.has(n));
|
|
503
600
|
return rest.length === 0 && s.dropped.size === 0 ? undefined : { ...s, items: rest };
|
|
504
601
|
}
|
|
505
|
-
async settleBoxDebt(
|
|
602
|
+
async settleBoxDebt(address, copy, debt) {
|
|
603
|
+
const sessionId = address.sessionId;
|
|
506
604
|
let answered = false;
|
|
507
605
|
try {
|
|
508
606
|
await debt.box.mailbox.append(debt.box.scope, debt.box.handle, debt.record);
|
|
@@ -515,7 +613,7 @@ export class PendingSessionNotifications {
|
|
|
515
613
|
catch {
|
|
516
614
|
}
|
|
517
615
|
}
|
|
518
|
-
const s = this.
|
|
616
|
+
const s = this.recordOf(address);
|
|
519
617
|
if (s?.boxDebts?.get(copy) !== debt)
|
|
520
618
|
return;
|
|
521
619
|
s.boxDebts.delete(copy);
|
|
@@ -526,12 +624,19 @@ export class PendingSessionNotifications {
|
|
|
526
624
|
const key = taskNotificationDedupKey(copy);
|
|
527
625
|
s.keys.delete(key);
|
|
528
626
|
s.priorities?.delete(copy);
|
|
529
|
-
this.noteDurablePark(
|
|
627
|
+
this.noteDurablePark(address, key);
|
|
530
628
|
if (s.items.length === 0 && s.dropped.size === 0)
|
|
531
629
|
this.sessions.delete(sessionId);
|
|
532
630
|
}
|
|
533
|
-
pend(
|
|
631
|
+
pend(address, n, priority, debt) {
|
|
632
|
+
if (this.discardsStale(address, n))
|
|
633
|
+
return false;
|
|
634
|
+
const sessionId = address.sessionId;
|
|
534
635
|
let s = this.sessions.get(sessionId);
|
|
636
|
+
if (s !== undefined && !sameOccupant(s.occupant, address.occupant)) {
|
|
637
|
+
this.discardRecord(sessionId, s, address.occupant);
|
|
638
|
+
s = undefined;
|
|
639
|
+
}
|
|
535
640
|
if (s === undefined) {
|
|
536
641
|
if (this.sessions.size >= MAX_PENDING_SESSIONS) {
|
|
537
642
|
const oldest = this.sessions.keys().next().value;
|
|
@@ -544,20 +649,22 @@ export class PendingSessionNotifications {
|
|
|
544
649
|
if (!this.evictedSessions.has(oldest) && this.evictedSessions.size >= MAX_TOMBSTONES) {
|
|
545
650
|
const oldestTomb = this.evictedSessions.keys().next().value;
|
|
546
651
|
if (oldestTomb !== undefined) {
|
|
547
|
-
this.unattributedDrops += this.evictedSessions.get(oldestTomb) ?? 0;
|
|
652
|
+
this.unattributedDrops += this.evictedSessions.get(oldestTomb)?.count ?? 0;
|
|
548
653
|
this.evictedSessions.delete(oldestTomb);
|
|
549
654
|
}
|
|
550
655
|
}
|
|
551
|
-
|
|
656
|
+
const tomb = this.evictedSessions.get(oldest);
|
|
657
|
+
const occupant = victim?.occupant;
|
|
658
|
+
this.evictedSessions.set(oldest, { occupant, count: (tomb !== undefined && sameOccupant(tomb.occupant, occupant) ? tomb.count : 0) + lost });
|
|
552
659
|
}
|
|
553
660
|
}
|
|
554
661
|
}
|
|
555
|
-
s = { items: [], dropped: new Map(), keys: new Set(), priorities: new Map() };
|
|
662
|
+
s = { occupant: address.occupant, items: [], dropped: new Map(), keys: new Set(), priorities: new Map() };
|
|
556
663
|
this.sessions.set(sessionId, s);
|
|
557
664
|
}
|
|
558
665
|
const key = taskNotificationDedupKey(n);
|
|
559
666
|
if (s.keys.has(key))
|
|
560
|
-
return;
|
|
667
|
+
return true;
|
|
561
668
|
s.keys.add(key);
|
|
562
669
|
s.items.push(n);
|
|
563
670
|
if (priority !== undefined)
|
|
@@ -573,10 +680,17 @@ export class PendingSessionNotifications {
|
|
|
573
680
|
evictOldest(s, (i) => taskNotificationLaneKey(i) === lane);
|
|
574
681
|
if (s.items.length > MAX_PENDING_EVENTS_PER_SESSION)
|
|
575
682
|
evictOldest(s, () => true);
|
|
683
|
+
return true;
|
|
576
684
|
}
|
|
577
|
-
drain(
|
|
685
|
+
drain(address) {
|
|
686
|
+
if (address.unread === true)
|
|
687
|
+
return undefined;
|
|
688
|
+
const sessionId = address.sessionId;
|
|
578
689
|
this.routed.delete(sessionId);
|
|
579
|
-
const
|
|
690
|
+
const held = this.sessions.get(sessionId);
|
|
691
|
+
if (held !== undefined && !sameOccupant(held.occupant, address.occupant))
|
|
692
|
+
this.discardRecord(sessionId, held, address.occupant);
|
|
693
|
+
const parked = this.recordOf(address);
|
|
580
694
|
if (parked !== undefined)
|
|
581
695
|
this.sessions.delete(sessionId);
|
|
582
696
|
const s = parked !== undefined ? this.keepBackOwing(sessionId, parked) : undefined;
|
|
@@ -587,10 +701,12 @@ export class PendingSessionNotifications {
|
|
|
587
701
|
};
|
|
588
702
|
s.items = [...s.items].sort((a, b) => rank(a) - rank(b));
|
|
589
703
|
}
|
|
590
|
-
const
|
|
704
|
+
const tombstone = this.evictedSessions.get(sessionId);
|
|
705
|
+
const tomb = tombstone !== undefined && sameOccupant(tombstone.occupant, address.occupant) ? tombstone.count : undefined;
|
|
706
|
+
if (tombstone !== undefined)
|
|
707
|
+
this.evictedSessions.delete(sessionId);
|
|
591
708
|
if (tomb === undefined && this.unattributedDrops === 0)
|
|
592
709
|
return s;
|
|
593
|
-
this.evictedSessions.delete(sessionId);
|
|
594
710
|
const carried = this.unattributedDrops;
|
|
595
711
|
this.unattributedDrops = 0;
|
|
596
712
|
const out = s ?? { items: [], dropped: new Map() };
|
|
@@ -598,57 +714,23 @@ export class PendingSessionNotifications {
|
|
|
598
714
|
return out;
|
|
599
715
|
}
|
|
600
716
|
routed = new Map();
|
|
601
|
-
holdsKey(
|
|
602
|
-
return this.
|
|
717
|
+
holdsKey(address, dedupKey) {
|
|
718
|
+
return this.recordOf(address)?.keys.has(dedupKey) === true || keysOf(this.routed, address)?.has(dedupKey) === true || keysOf(this.durable, address)?.has(dedupKey) === true;
|
|
603
719
|
}
|
|
604
720
|
durable = new Map();
|
|
605
|
-
noteDurablePark(
|
|
606
|
-
|
|
607
|
-
if (mine === undefined) {
|
|
608
|
-
if (this.durable.size >= MAX_PENDING_SESSIONS) {
|
|
609
|
-
const oldest = this.durable.keys().next().value;
|
|
610
|
-
if (oldest !== undefined)
|
|
611
|
-
this.durable.delete(oldest);
|
|
612
|
-
}
|
|
613
|
-
mine = new Set();
|
|
614
|
-
this.durable.set(sessionId, mine);
|
|
615
|
-
}
|
|
616
|
-
mine.add(dedupKey);
|
|
617
|
-
if (mine.size > MAX_PENDING_EVENTS_PER_SESSION) {
|
|
618
|
-
for (const k of mine) {
|
|
619
|
-
mine.delete(k);
|
|
620
|
-
if (mine.size <= MAX_PENDING_EVENTS_PER_SESSION)
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
721
|
+
noteDurablePark(address, dedupKey) {
|
|
722
|
+
addOccupantKey(this.durable, address, dedupKey);
|
|
624
723
|
}
|
|
625
|
-
forgetDurablePark(
|
|
626
|
-
const mine = this.durable
|
|
724
|
+
forgetDurablePark(address, dedupKey) {
|
|
725
|
+
const mine = keysOf(this.durable, address);
|
|
627
726
|
if (mine === undefined)
|
|
628
727
|
return;
|
|
629
728
|
mine.delete(dedupKey);
|
|
630
729
|
if (mine.size === 0)
|
|
631
|
-
this.durable.delete(sessionId);
|
|
632
|
-
}
|
|
633
|
-
markDelivered(
|
|
634
|
-
|
|
635
|
-
if (mine === undefined) {
|
|
636
|
-
if (this.routed.size >= MAX_PENDING_SESSIONS) {
|
|
637
|
-
const oldest = this.routed.keys().next().value;
|
|
638
|
-
if (oldest !== undefined)
|
|
639
|
-
this.routed.delete(oldest);
|
|
640
|
-
}
|
|
641
|
-
mine = new Set();
|
|
642
|
-
this.routed.set(sessionId, mine);
|
|
643
|
-
}
|
|
644
|
-
mine.add(dedupKey);
|
|
645
|
-
if (mine.size > MAX_PENDING_EVENTS_PER_SESSION) {
|
|
646
|
-
for (const k of mine) {
|
|
647
|
-
mine.delete(k);
|
|
648
|
-
if (mine.size <= MAX_PENDING_EVENTS_PER_SESSION)
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
730
|
+
this.durable.delete(address.sessionId);
|
|
731
|
+
}
|
|
732
|
+
markDelivered(address, dedupKey) {
|
|
733
|
+
addOccupantKey(this.routed, address, dedupKey);
|
|
652
734
|
}
|
|
653
735
|
get size() {
|
|
654
736
|
return this.sessions.size;
|
|
@@ -672,20 +754,23 @@ export class DurableAppendObligations {
|
|
|
672
754
|
await Promise.allSettled([...this.inFlight]);
|
|
673
755
|
}
|
|
674
756
|
}
|
|
675
|
-
export function routeOrParkNotification(store,
|
|
757
|
+
export function routeOrParkNotification(store, address, payload, priority, onDisposition) {
|
|
758
|
+
if (store.discardsStale(address, payload)) {
|
|
759
|
+
onDisposition?.("refused");
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
676
762
|
const dedupKey = taskNotificationDedupKey(payload);
|
|
677
|
-
if (store.holdsKey(
|
|
763
|
+
if (store.holdsKey(address, dedupKey)) {
|
|
678
764
|
onDisposition?.("parked");
|
|
679
765
|
return;
|
|
680
766
|
}
|
|
681
|
-
const routed = store.liveLanes.deliver(
|
|
767
|
+
const routed = store.liveLanes.deliver(address, payload, priority, { ...(onDisposition !== undefined ? { onDisposition } : {}) });
|
|
682
768
|
if (routed === "unavailable") {
|
|
683
|
-
const box = store.sessionBoxFor(
|
|
769
|
+
const box = store.sessionBoxFor(address);
|
|
684
770
|
const carrier = payload.agentMessage;
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
const record = carrier !== undefined ? sessionBoxRecordOf({ ...payload, agentMessage: carrier }, box) : engineFrameRecordOf(payload, priority, box);
|
|
771
|
+
if (box !== undefined && parksDurably(payload, box)) {
|
|
772
|
+
store.noteDurablePark(address, dedupKey);
|
|
773
|
+
const record = carrier !== undefined ? sessionBoxRecordOf({ ...payload, agentMessage: carrier }, address) : engineFrameRecordOf(payload, priority, address);
|
|
689
774
|
const ask = () => {
|
|
690
775
|
try {
|
|
691
776
|
return Promise.resolve(box.mailbox.append(box.scope, box.handle, record));
|
|
@@ -703,21 +788,21 @@ export function routeOrParkNotification(store, sessionId, payload, priority, onD
|
|
|
703
788
|
return ask();
|
|
704
789
|
});
|
|
705
790
|
const settled = appended.then(() => onDisposition?.("parked_durably"), () => {
|
|
706
|
-
store.forgetDurablePark(
|
|
707
|
-
store.pend(
|
|
708
|
-
onDisposition?.("parked");
|
|
791
|
+
store.forgetDurablePark(address, dedupKey);
|
|
792
|
+
const parked = store.pend(address, payload, priority, { box, record });
|
|
793
|
+
onDisposition?.(parked ? "parked" : "refused");
|
|
709
794
|
});
|
|
710
795
|
DurableAppendObligations.current()?.track(settled);
|
|
711
796
|
return;
|
|
712
797
|
}
|
|
713
|
-
store.pend(
|
|
714
|
-
onDisposition?.("parked");
|
|
798
|
+
const parked = store.pend(address, payload, priority);
|
|
799
|
+
onDisposition?.(parked ? "parked" : "refused");
|
|
715
800
|
}
|
|
716
801
|
else if (routed !== "taken") {
|
|
717
802
|
onDisposition?.("queued");
|
|
718
803
|
}
|
|
719
804
|
}
|
|
720
|
-
export function sessionBoxRecordOf(payload,
|
|
805
|
+
export function sessionBoxRecordOf(payload, to) {
|
|
721
806
|
const peer = payload.peer;
|
|
722
807
|
return {
|
|
723
808
|
id: taskNotificationDedupKey(payload),
|
|
@@ -728,8 +813,9 @@ export function sessionBoxRecordOf(payload, box) {
|
|
|
728
813
|
peerMeta: {
|
|
729
814
|
...(peer?.fromSession !== undefined ? { fromSession: peer.fromSession } : {}),
|
|
730
815
|
...(peer?.senderKey !== undefined ? { senderKey: peer.senderKey } : {}),
|
|
731
|
-
fromRoot:
|
|
816
|
+
fromRoot: to.sessionId,
|
|
732
817
|
kind: "peer_message",
|
|
818
|
+
...(to.occupant !== undefined ? { occupant: to.occupant } : {}),
|
|
733
819
|
},
|
|
734
820
|
};
|
|
735
821
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type BackgroundAgentRecord, type BackgroundAgentStore } from "./background-agent-store.js";
|
|
2
|
-
import { type StopSource, type TaskAccess, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type ChildSessionStore, type RegisteredTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput } from "./task-registry-shared.js";
|
|
2
|
+
import { type StopSource, type TaskAccess, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type ChildSessionStore, type RegisteredTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput, type LandedAgentTerminal } from "./task-registry-shared.js";
|
|
3
|
+
import type { ExtensionRequester } from "./task-event.js";
|
|
3
4
|
import { type AgentState } from "./agent-state.js";
|
|
4
5
|
import type { CheckpointSeat } from "./checkpoint-seat.js";
|
|
5
6
|
/**
|
|
@@ -19,6 +20,8 @@ export declare function activeDelegationHandlesLane(core: DurableAgentCore, scop
|
|
|
19
20
|
export interface DelegationOccupant {
|
|
20
21
|
readonly id: string;
|
|
21
22
|
readonly name: string;
|
|
23
|
+
/** The extension that started the row, when one did (the row's `requestedBy`); absent for every other row. */
|
|
24
|
+
readonly requestedBy?: ExtensionRequester;
|
|
22
25
|
readonly reachable: boolean;
|
|
23
26
|
}
|
|
24
27
|
/** The rows {@link activeDelegationHandlesLane} counts, with the name each is addressed by — the one selection, read in the same
|
|
@@ -193,6 +196,7 @@ export declare function parkBackgroundAgentLane(core: DurableAgentCore, id: stri
|
|
|
193
196
|
checkpointToken: string;
|
|
194
197
|
seq?: number;
|
|
195
198
|
resolveStop?: () => Promise<boolean>;
|
|
199
|
+
completionSink?: BackgroundAgentTaskHandle["parkedCompletionSink"];
|
|
196
200
|
}): "parked" | undefined;
|
|
197
201
|
/**
|
|
198
202
|
* design/153 §7.1 (件1 split-brain fence) — the registry-aware reconciliation entry an
|
|
@@ -444,7 +448,18 @@ export declare function noteBackgroundAgentActivityLane(core: DurableAgentCore,
|
|
|
444
448
|
* stale-running sweep writes, so an operator reading either face sees one explanation, and its run is
|
|
445
449
|
* aborted. Returns how many rows were collected.
|
|
446
450
|
*/
|
|
447
|
-
export declare function reapStaleSessionBackgroundAgentsLane(core: DurableAgentCore, staleMs: number, now?: number
|
|
451
|
+
export declare function reapStaleSessionBackgroundAgentsLane(core: DurableAgentCore, staleMs: number, now?: number): number;
|
|
452
|
+
/**
|
|
453
|
+
* THE announcement of a background agent's terminal the REGISTRY landed without the cycle's attempt — the session or stale
|
|
454
|
+
* reap of a running cycle (its attempt's unwind would report only once the in-flight tool honored the abort), a TaskStop
|
|
455
|
+
* that won a parked cycle's arbitration, a parked cycle's approval found expired or decided elsewhere (the attempt that
|
|
456
|
+
* parked returned at the park; nothing else would report it). Sent now, once: through the notifier the spawn lane hung on
|
|
457
|
+
* the handle, under the one terminal once-latch the attempt's own unwind claims too (`claimAgentTerminalNotify`) — the
|
|
458
|
+
* first sender wins, the other stays silent. A lane that hung no notifier (direct registry use) keeps its unwind's
|
|
459
|
+
* announcement. A parked cycle's ending names the lane its park recorded the debt on (`ending.parkLane`); a park that
|
|
460
|
+
* recorded none owes nothing in this process, and its caller announces nothing.
|
|
461
|
+
*/
|
|
462
|
+
export declare function announceLandedAgentTerminal(core: DurableAgentCore, handle: BackgroundAgentTaskHandle, notifier: BackgroundAgentTaskHandle["terminalNotifier"], ending: LandedAgentTerminal): void;
|
|
448
463
|
/** S2b — retention is REVOCABLE: every retain-ledger eviction path (TTL / LRU / abandon /
|
|
449
464
|
* parent-teardown disposeAll) runs the entry's release closure, and the spawner wraps that closure
|
|
450
465
|
* to call this — so a park can never be acknowledged against a continuation that was already
|
|
@@ -533,6 +548,14 @@ export interface AgentPollDetailsInput {
|
|
|
533
548
|
* `agentState` when given; the poll arms always give it, a serving layer may omit it. */
|
|
534
549
|
agentState?: AgentState;
|
|
535
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* The ONE reading of a delegation outcome's tool-result error bit: a delegation whose child FAILED produced no usable result,
|
|
553
|
+
* so the tool result that reports it is an error (`isError: true`) — on the synchronous card, the fork card, the live poll
|
|
554
|
+
* and the durable poll alike, so a hook or a host reading the bit never sees `false` beside `status: failed`. Every other
|
|
555
|
+
* outcome word answers `false` here: a completed, killed or still-running delegation is data, and the refusals that never
|
|
556
|
+
* start a child (a refused call, a held park, an unavailable isolation) are their own constructors, not outcomes.
|
|
557
|
+
*/
|
|
558
|
+
export declare function agentOutcomeIsError(status: string): boolean;
|
|
536
559
|
/** PUBLIC (see the doc above): a serving layer that renders its own protocol projection of a row
|
|
537
560
|
* builds the structured facts HERE, so the status gates and the untrusted-text fencing apply to it
|
|
538
561
|
* too — a third literal is exactly the drift this builder exists to prevent. Input only; it reads no
|