@dsmm/dsmm 0.2.0 → 0.2.2
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/README.md +38 -66
- package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
- package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
- package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
- package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
- package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
- package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
- package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
- package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
- package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
- package/docs/agent-presets.md +36 -52
- package/docs/compatibility.md +50 -108
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +2 -2
- package/docs/lsp.md +11 -21
- package/docs/migration-from-ocmm.md +2 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +40 -87
- package/docs/releasing.md +83 -2
- package/docs/roadmap.md +71 -17
- package/docs/settings-status.md +34 -169
- package/docs/skill-sync.md +52 -15
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.js +15 -8
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +30 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-data.d.ts +2 -1
- package/lib/client/deployment-data.js +34 -5
- package/lib/client/deployment-locales.d.ts +4 -0
- package/lib/client/deployment-locales.js +11 -2
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +96 -2
- package/lib/client/locales.d.ts +54 -0
- package/lib/client/locales.js +34 -16
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +20 -0
- package/lib/client.js +5780 -1679
- package/lib/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +68 -0
- package/lib/delivery-authority.js +260 -0
- package/lib/deployment-config.d.ts +23 -0
- package/lib/deployment-config.js +61 -40
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-types.d.ts +10 -4
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +29 -8
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +15 -4
- package/lib/index.js +300 -47
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +28 -17
- package/lib/modules.d.ts +13 -5
- package/lib/modules.js +17 -1
- package/lib/native-child-evidence.d.ts +42 -0
- package/lib/native-child-evidence.js +133 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.js +1 -1
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -0
- package/lib/preset-registry.js +36 -25
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +8 -0
- package/lib/profile-remote.js +163 -39
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +14 -12
- package/lib/profile-runtime.d.ts +40 -1
- package/lib/profile-runtime.js +368 -93
- package/lib/profile-store.d.ts +11 -0
- package/lib/profile-store.js +143 -11
- package/lib/profile-types.d.ts +70 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.js +1 -1
- package/lib/prompts.d.ts +37 -2
- package/lib/prompts.js +111 -9
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +377 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +49 -8
- package/lib/role-policy.js +437 -60
- package/lib/role-providers.d.ts +1 -1
- package/lib/role-providers.js +30 -35
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +58 -3
- package/lib/role-subagents.js +169 -56
- package/lib/roles.d.ts +5 -6
- package/lib/roles.js +10 -39
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +18 -8
- package/lib/settings.d.ts +47 -13
- package/lib/settings.js +217 -82
- package/lib/skills.js +2 -2
- package/lib/status.d.ts +10 -1
- package/lib/status.js +11 -8
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/package.json +106 -56
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +27 -18
- package/prompts/source/agents/clarifier.md +5 -3
- package/prompts/source/agents/orchestrator.md +18 -9
- package/prompts/source/agents/plan-critic.md +5 -1
- package/prompts/source/agents/planner.md +4 -2
- package/prompts/source/agents/reviewer.md +6 -0
- package/prompts/source/category/complex.md +4 -4
- package/prompts/source/category/creative.md +6 -4
- package/prompts/source/category/cross-cutting.md +10 -8
- package/prompts/source/category/deep.md +5 -3
- package/prompts/source/category/documenting.md +7 -1
- package/prompts/source/category/frontend.md +2 -2
- package/prompts/source/category/hard-reasoning.md +3 -3
- package/prompts/source/category/research.md +4 -2
- package/prompts/source/deepwork/claude-opus-5.md +2 -2
- package/prompts/source/deepwork/codex.md +1 -1
- package/prompts/source/deepwork/default.md +22 -15
- package/prompts/source/deepwork/gemini.md +23 -16
- package/prompts/source/deepwork/glm.md +21 -14
- package/prompts/source/deepwork/gpt.md +12 -6
- package/prompts/source/deepwork/planner.md +8 -5
- package/prompts/source/manifest.json +178 -63
- package/prompts/source/shared/dsh-host-contract.md +5 -3
- package/prompts/source/shared/locale.md +2 -2
- package/prompts/source/terminal/orchestrator.md +1 -1
- package/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- package/skills/ast-grep/SKILL.md +7 -4
- package/skills/brainstorming/SKILL.md +43 -22
- package/skills/coding-agent-sessions/SKILL.md +7 -4
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
- package/skills/debugging/SKILL.md +14 -9
- package/skills/debugging/references/methodology/00-setup.md +14 -62
- package/skills/debugging/references/methodology/02-investigate.md +4 -4
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
- package/skills/debugging/references/methodology/06-fix.md +6 -6
- package/skills/debugging/references/methodology/08-qa.md +5 -5
- package/skills/debugging/references/methodology/09-cleanup.md +15 -153
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
- package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
- package/skills/debugging/references/runtimes/native-binary.md +9 -54
- package/skills/debugging/references/runtimes/node.md +4 -15
- package/skills/debugging/references/runtimes/python.md +3 -15
- package/skills/debugging/references/runtimes/rust.md +2 -18
- package/skills/debugging/references/tools/dap.md +1 -1
- package/skills/debugging/references/tools/ghidra.md +4 -15
- package/skills/debugging/references/tools/playwright-cli.md +3 -15
- package/skills/debugging/references/tools/pwntools.md +4 -16
- package/skills/dispatching-parallel-agents/SKILL.md +18 -16
- package/skills/frontend/SKILL.md +7 -4
- package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
- package/skills/git-master/SKILL.md +7 -4
- package/skills/init-deep/SKILL.md +7 -4
- package/skills/receiving-code-review/SKILL.md +17 -12
- package/skills/remove-ai-slops/SKILL.md +39 -38
- package/skills/requesting-code-review/SKILL.md +19 -17
- package/skills/requesting-code-review/code-reviewer.md +13 -1
- package/skills/subagent-driven-development/SKILL.md +29 -26
- package/skills/subagent-driven-development/implementer-prompt.md +29 -11
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
- package/skills/using-git-worktrees/SKILL.md +7 -4
- package/skills/writing-plans/SKILL.md +29 -24
- package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { symbols } from "@deepseek-ai/cordis";
|
|
3
|
+
import { createScope } from "@deepseek-ai/dsh-scope";
|
|
4
|
+
import { foldSubagentDescriptor } from "@deepseek-ai/dsh-subagent";
|
|
5
|
+
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
6
|
+
import { scopeLifetime } from "./delivery-authority.js";
|
|
7
|
+
import { createLegacyReadOperationCapability, LegacyChildToolPolicy } from "./legacy-child-policy.js";
|
|
8
|
+
import { createLegacyReadHost, createLegacyReadHostOwner, LegacyReadUnavailable } from "./legacy-read-host.js";
|
|
9
|
+
import { NativeChildEvidenceReader, legacyEvidenceFromNativeFacts } from "./native-child-evidence.js";
|
|
10
|
+
function assertReadArguments(args, binding) {
|
|
11
|
+
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
12
|
+
throw new LegacyReadUnavailable("arguments-unavailable");
|
|
13
|
+
const row = args;
|
|
14
|
+
if (Reflect.ownKeys(row).some(key => typeof key !== "string" || !["file_path", "offset", "limit"].includes(key))
|
|
15
|
+
|| typeof row.file_path !== "string" || !row.file_path.trim() || row.file_path.includes("\0")
|
|
16
|
+
|| [row.offset, row.limit].some(value => value !== undefined && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1))
|
|
17
|
+
|| typeof row.limit === "number" && row.limit > binding.caps.limit)
|
|
18
|
+
throw new LegacyReadUnavailable("arguments-unavailable");
|
|
19
|
+
}
|
|
20
|
+
/** Explicit Host programmatic composition only. Owns glue, not a second permission, retry or audit service. */
|
|
21
|
+
export function createLegacyReadIntegration(options) {
|
|
22
|
+
const { ctx, authority, authorityOwner, admissions, nativeHistory, trustedHostStartup: startup } = options;
|
|
23
|
+
const coldCore = startup !== undefined && options.coreAdmissions !== undefined;
|
|
24
|
+
if (coldCore) {
|
|
25
|
+
if (authority.view().deliveryFenceReady)
|
|
26
|
+
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
27
|
+
if (typeof options.coreAdmissions.resolveOriginalChildEvidence !== "function" || typeof options.coreAdmissions.assertDelivery !== "function"
|
|
28
|
+
|| typeof options.proxyDefinitions?.admit !== "function" || typeof options.proxyDefinitions.assertAdmitted !== "function")
|
|
29
|
+
throw new LegacyReadUnavailable("provenance-unavailable");
|
|
30
|
+
}
|
|
31
|
+
const children = new Map();
|
|
32
|
+
const failedAttachments = new Map();
|
|
33
|
+
const attachmentErrors = new WeakMap();
|
|
34
|
+
const disposedChildren = new WeakSet();
|
|
35
|
+
const capabilities = new WeakMap();
|
|
36
|
+
const admissionGuards = new WeakMap();
|
|
37
|
+
const retired = new WeakMap();
|
|
38
|
+
const reader = new NativeChildEvidenceReader(ctx, ticket => assertTicket(ticket), nativeHistory);
|
|
39
|
+
let serial = Promise.resolve();
|
|
40
|
+
let pendingChanges = 0;
|
|
41
|
+
let recoveryRequested = false;
|
|
42
|
+
let disposal;
|
|
43
|
+
const assertTicket = (ticket) => {
|
|
44
|
+
authority.assertTicket(ticket);
|
|
45
|
+
if (ticket.owner !== authorityOwner || ctx.agents.get(ticket.parent.id) !== ticket.parent || !Object.isFrozen(ticket.admission)) {
|
|
46
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const current = (parent, child, evidence, ticket) => {
|
|
50
|
+
assertTicket(ticket);
|
|
51
|
+
const resident = children.get(child);
|
|
52
|
+
if (resident === undefined || resident.retired || resident.attachment.parent !== parent || resident.attachment.evidence !== evidence
|
|
53
|
+
|| admissions.childAdmission(child) !== resident.attachment.admission || child.session.header.parentSession !== parent.id
|
|
54
|
+
|| ctx.agents.get(child.id) !== child || !ctx.agents.isOwnedBy(child.id, parent))
|
|
55
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
56
|
+
resident.lifetime.signal.throwIfAborted();
|
|
57
|
+
options.proxyDefinitions.assertAdmitted(child, resident.attachment.proxy.definition);
|
|
58
|
+
if (!ticket.admission.settings.modules.deepwork.enabled || !ticket.admission.settings.roles[evidence.role])
|
|
59
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
60
|
+
admissions.assertCurrentParent(ticket, child, evidence);
|
|
61
|
+
assertTicket(ticket);
|
|
62
|
+
return resident;
|
|
63
|
+
};
|
|
64
|
+
const owner = createLegacyReadHostOwner({
|
|
65
|
+
captureClosedComposition() {
|
|
66
|
+
if (startup === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
if ([startup.captureClosedComposition, startup.resolveReadBindings, startup.acquireCallContext, startup.reportAuditFault,
|
|
69
|
+
startup.reportRetirementFault, startup.revoke].some(callback => typeof callback !== "function"))
|
|
70
|
+
return undefined;
|
|
71
|
+
const attachments = [...children.values()].filter(value => !value.retired).map(value => value.attachment);
|
|
72
|
+
if (!attachments.length)
|
|
73
|
+
return undefined;
|
|
74
|
+
const snapshot = startup.captureClosedComposition(Object.freeze(attachments));
|
|
75
|
+
if (snapshot === undefined)
|
|
76
|
+
return undefined;
|
|
77
|
+
if (!Array.isArray(snapshot.scopes) || !Array.isArray(snapshot.policies))
|
|
78
|
+
throw new LegacyReadUnavailable("composition-unavailable");
|
|
79
|
+
// The Host must close each actual child effective scope independently, not collapse them into one session entry.
|
|
80
|
+
for (const attachment of attachments) {
|
|
81
|
+
options.proxyDefinitions.assertAdmitted(attachment.child, attachment.proxy.definition);
|
|
82
|
+
if (![attachment.policyScope, attachment.proxy.proxyScope, attachment.proxy.standingScope].every(scope => snapshot.scopes.some(row => row.ctx === scope.ctx))
|
|
83
|
+
|| attachment.contributions.some(contribution => !snapshot.policies.some(row => row.scope === contribution.scope && row.reference === contribution.reference
|
|
84
|
+
&& row.stage === contribution.stage && row.semantics === "audited-zero-or-once")))
|
|
85
|
+
throw new LegacyReadUnavailable("composition-unavailable");
|
|
86
|
+
}
|
|
87
|
+
return { ...snapshot, owner, bindings: attachments.map(value => value.bindings) };
|
|
88
|
+
},
|
|
89
|
+
acquireParentTicket(parent) { const ticket = authority.acquireParentTicket(parent); assertTicket(ticket); return ticket; },
|
|
90
|
+
assertParentTicket(ticket) { assertTicket(ticket); },
|
|
91
|
+
resolveChildAdmission(parent, child, evidence, ticket) {
|
|
92
|
+
return current(parent, child, evidence, ticket).evidenceBinding;
|
|
93
|
+
},
|
|
94
|
+
resolveReadBindings(parent, child, lease) {
|
|
95
|
+
const resident = current(parent, child, children.get(child).attachment.evidence, lease.ticket);
|
|
96
|
+
if (startup?.resolveReadBindings(parent, child) !== resident.attachment.bindings)
|
|
97
|
+
throw new LegacyReadUnavailable("provenance-unavailable");
|
|
98
|
+
return resident.attachment.bindings;
|
|
99
|
+
},
|
|
100
|
+
async acquireCallContext(parent, child, exec, lease) {
|
|
101
|
+
if (startup === undefined)
|
|
102
|
+
throw new LegacyReadUnavailable("audit-unavailable");
|
|
103
|
+
lease.signal.throwIfAborted();
|
|
104
|
+
current(parent, child, children.get(child).attachment.evidence, lease.ticket);
|
|
105
|
+
return startup.acquireCallContext(parent, child, exec, lease);
|
|
106
|
+
},
|
|
107
|
+
revoke(reason) {
|
|
108
|
+
authority.revokeOwner(authorityOwner, reason);
|
|
109
|
+
for (const resident of children.values())
|
|
110
|
+
resident.lifetime.abort(reason);
|
|
111
|
+
startup?.revoke(reason);
|
|
112
|
+
},
|
|
113
|
+
reportAuditFault(error, outcomes) { startup?.reportAuditFault(error, outcomes); },
|
|
114
|
+
});
|
|
115
|
+
const host = createLegacyReadHost(owner);
|
|
116
|
+
const classifyTool = (name, tools, child) => {
|
|
117
|
+
if (name !== "read") {
|
|
118
|
+
const report = options.classifyChildReport?.(name, tools, child);
|
|
119
|
+
return report?.kind === "child-report" ? report : undefined;
|
|
120
|
+
}
|
|
121
|
+
const resident = children.get(child);
|
|
122
|
+
if (resident === undefined || resident.retired || resident.lifetime.signal.aborted)
|
|
123
|
+
return undefined;
|
|
124
|
+
return tools.get(name, child) === resident.attachment.proxy.definition ? capabilities.get(child) : undefined;
|
|
125
|
+
};
|
|
126
|
+
const legacyCapabilities = {
|
|
127
|
+
classifyTool,
|
|
128
|
+
onGuardInstalled(child, guard) {
|
|
129
|
+
const previous = admissionGuards.get(child) ?? [];
|
|
130
|
+
admissionGuards.set(child, Object.freeze([...previous, { side: "child", stage: "guard", scope: child.ctx,
|
|
131
|
+
reference: guard, order: 0, semantics: "audited-zero-or-once" }]));
|
|
132
|
+
},
|
|
133
|
+
assertParentReport(parent, child, args, definition, evidence) {
|
|
134
|
+
const ticket = authority.acquireParentTicket(parent);
|
|
135
|
+
assertTicket(ticket);
|
|
136
|
+
const admission = admissions.childAdmission(child);
|
|
137
|
+
if (!Object.isFrozen(admission) || admission.childEvidence?.mode !== "legacy-conservative" || ctx.agents.get(child.id) !== child
|
|
138
|
+
|| child.session.header.parentSession !== parent.id || !ctx.agents.isOwnedBy(child.id, parent)
|
|
139
|
+
|| !ticket.admission.settings.modules.deepwork.enabled || !ticket.admission.settings.roles[evidence.role])
|
|
140
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
141
|
+
admissions.assertCurrentParent(ticket, child, evidence);
|
|
142
|
+
const report = options.classifyChildReport?.("send_message", child.ctx.tools, child);
|
|
143
|
+
if (report?.kind !== "child-report" || report.definition !== definition || child.ctx.tools.get("send_message", child) !== definition
|
|
144
|
+
|| args === null || typeof args !== "object" || args.agent_id !== parent.id)
|
|
145
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
146
|
+
report.assertArguments(args);
|
|
147
|
+
assertTicket(ticket);
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const enqueue = (work) => {
|
|
151
|
+
pendingChanges++;
|
|
152
|
+
const run = async () => {
|
|
153
|
+
try {
|
|
154
|
+
await work();
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
pendingChanges--;
|
|
158
|
+
if (pendingChanges === 0 && recoveryRequested && disposal === undefined && failedAttachments.size === 0) {
|
|
159
|
+
recoveryRequested = false;
|
|
160
|
+
if (host.composition.view().state !== "ready" && [...children.values()].some(value => !value.retired)) {
|
|
161
|
+
try {
|
|
162
|
+
host.publishCheckedGeneration();
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
ctx.logger.warn("Legacy read attachment recovery could not attest the current composition", error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const result = serial.then(run, run);
|
|
172
|
+
serial = result.catch(() => { });
|
|
173
|
+
return result;
|
|
174
|
+
};
|
|
175
|
+
const reportRetirementFault = (error, child) => {
|
|
176
|
+
try {
|
|
177
|
+
startup?.reportRetirementFault(error, child);
|
|
178
|
+
}
|
|
179
|
+
catch (reportError) {
|
|
180
|
+
ctx.logger.warn("Legacy read retirement fault reporter failed", reportError);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const releaseFailedAttachment = (child) => {
|
|
184
|
+
const failed = failedAttachments.get(child);
|
|
185
|
+
if (failed === undefined || failed.release !== undefined || !disposedChildren.has(child))
|
|
186
|
+
return;
|
|
187
|
+
failed.release = enqueue(async () => {
|
|
188
|
+
await host.composition.closeForChange("failed-child-disposed");
|
|
189
|
+
await host.releaseAfterChildDispose(child);
|
|
190
|
+
await failed.policyScope.dispose();
|
|
191
|
+
failedAttachments.delete(child);
|
|
192
|
+
});
|
|
193
|
+
void failed.release.then(failed.complete, error => { reportRetirementFault(error, child); failed.fail(error); });
|
|
194
|
+
};
|
|
195
|
+
const retire = (child, reason) => {
|
|
196
|
+
const resident = children.get(child);
|
|
197
|
+
if (resident === undefined)
|
|
198
|
+
return failedAttachments.get(child)?.completion ?? retired.get(child) ?? Promise.resolve();
|
|
199
|
+
if (resident.retirement !== undefined)
|
|
200
|
+
return resident.retirement;
|
|
201
|
+
resident.retired = true;
|
|
202
|
+
resident.lifetime.abort(reason);
|
|
203
|
+
authority.revokeParent(child, reason);
|
|
204
|
+
const drain = host.composition.closeForChange(reason);
|
|
205
|
+
const result = enqueue(async () => {
|
|
206
|
+
await drain;
|
|
207
|
+
await resident.disposed;
|
|
208
|
+
await host.releaseAfterChildDispose(child);
|
|
209
|
+
await resident.attachment.policyScope.dispose();
|
|
210
|
+
children.delete(child);
|
|
211
|
+
if (disposal === undefined && pendingChanges === 1 && [...children.values()].some(value => !value.retired))
|
|
212
|
+
host.publishCheckedGeneration();
|
|
213
|
+
});
|
|
214
|
+
resident.retirement = result;
|
|
215
|
+
retired.set(child, result);
|
|
216
|
+
void result.catch(error => reportRetirementFault(error, child));
|
|
217
|
+
return result;
|
|
218
|
+
};
|
|
219
|
+
ctx.on("agent/disposed", ({ agent }) => {
|
|
220
|
+
disposedChildren.add(agent);
|
|
221
|
+
releaseFailedAttachment(agent);
|
|
222
|
+
const resident = children.get(agent);
|
|
223
|
+
if (resident === undefined)
|
|
224
|
+
return;
|
|
225
|
+
resident.markDisposed();
|
|
226
|
+
void retire(agent, "child-registry-disposed");
|
|
227
|
+
}, { global: true });
|
|
228
|
+
scopeLifetime(ctx, "dsmm.legacyRead: close Host operation leases", () => {
|
|
229
|
+
void host.composition.closeForDispose("host-lifetime-ended");
|
|
230
|
+
});
|
|
231
|
+
const integration = {
|
|
232
|
+
host,
|
|
233
|
+
legacyCapabilities,
|
|
234
|
+
/** B consumes this same classifier when validating the child report/tool definition. */
|
|
235
|
+
classifyLegacyTool: classifyTool,
|
|
236
|
+
view() {
|
|
237
|
+
const raw = host.composition.view();
|
|
238
|
+
const state = startup === undefined ? "off" : raw.state === "ready" ? "ready" : raw.state === "off" ? "off"
|
|
239
|
+
: raw.state === "closed" && raw.activeCalls > 0 ? "quiescing" : "unavailable";
|
|
240
|
+
return { state, operation: "read", activeCalls: raw.activeCalls, ...(raw.generation ? { generation: raw.generation } : {}),
|
|
241
|
+
...(startup === undefined ? { reason: "startup-opt-in-required" } : raw.reason === "audit-fault" ? { reason: "audit-unavailable" }
|
|
242
|
+
: state === "unavailable" && raw.state !== "disposed" ? { reason: "unknown-chain" } : {}) };
|
|
243
|
+
},
|
|
244
|
+
async attachChild(parent, child, signal) {
|
|
245
|
+
signal.throwIfAborted();
|
|
246
|
+
if (attachmentErrors.has(child))
|
|
247
|
+
throw attachmentErrors.get(child);
|
|
248
|
+
if (startup === undefined || disposal !== undefined || children.has(child))
|
|
249
|
+
throw new LegacyReadUnavailable("composition-unavailable");
|
|
250
|
+
if (typeof options.proxyDefinitions?.admit !== "function" || typeof options.proxyDefinitions.assertAdmitted !== "function")
|
|
251
|
+
throw new LegacyReadUnavailable("provenance-unavailable");
|
|
252
|
+
const drain = host.composition.closeForChange("child-attachment");
|
|
253
|
+
let attachment;
|
|
254
|
+
await enqueue(async () => {
|
|
255
|
+
let policyScope, proxy, lifetime, detachLifetime;
|
|
256
|
+
try {
|
|
257
|
+
await drain;
|
|
258
|
+
await host.composition.closeForChange("child-attachment");
|
|
259
|
+
signal.throwIfAborted();
|
|
260
|
+
if (attachmentErrors.has(child))
|
|
261
|
+
throw attachmentErrors.get(child);
|
|
262
|
+
if (disposal !== undefined || children.has(child))
|
|
263
|
+
throw new LegacyReadUnavailable("composition-unavailable");
|
|
264
|
+
const ticket = authority.acquireParentTicket(parent);
|
|
265
|
+
assertTicket(ticket);
|
|
266
|
+
const merged = AbortSignal.any([signal, ticket.signal]);
|
|
267
|
+
merged.throwIfAborted();
|
|
268
|
+
const evidence = await admissions.resolveOriginalChildEvidence(ticket, child.id, merged);
|
|
269
|
+
merged.throwIfAborted();
|
|
270
|
+
assertTicket(ticket);
|
|
271
|
+
if (!("mode" in evidence) || !evidence.toolFilter?.allow?.includes("read") || evidence.toolFilter.deny?.includes("read"))
|
|
272
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
273
|
+
const facts = await reader.read(ticket, child.id, merged);
|
|
274
|
+
if (!isDeepStrictEqual(evidence, legacyEvidenceFromNativeFacts(facts)))
|
|
275
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
276
|
+
const admission = admissions.childAdmission(child);
|
|
277
|
+
if (!Object.isFrozen(admission) || admission.childEvidence?.mode !== "legacy-conservative")
|
|
278
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
279
|
+
const observation = await nativeHistory.observeSession(child.id, { signal: merged, projectionMode: "none" });
|
|
280
|
+
let physicalRecords;
|
|
281
|
+
try {
|
|
282
|
+
const own = observation.events.slice(observation.inheritedEventCount);
|
|
283
|
+
if (observation.header.id !== child.id || observation.header.parentSession !== parent.id || own.filter(event => event.type === "subagent/descriptor").length !== 1
|
|
284
|
+
|| !isDeepStrictEqual(foldSubagentDescriptor(own), facts.descriptor))
|
|
285
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
286
|
+
physicalRecords = Object.freeze([observation.header, ...own]);
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
observation[Symbol.dispose]();
|
|
290
|
+
}
|
|
291
|
+
merged.throwIfAborted();
|
|
292
|
+
assertTicket(ticket);
|
|
293
|
+
if (admissions.childAdmission(child) !== admission || ctx.agents.get(child.id) !== child || !ctx.agents.isOwnedBy(child.id, parent)
|
|
294
|
+
|| !ticket.admission.settings.modules.deepwork.enabled || !ticket.admission.settings.roles[evidence.role])
|
|
295
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
296
|
+
admissions.assertCurrentParent(ticket, child, evidence);
|
|
297
|
+
const bindings = typeof startup.resolveReadBindings === "function" ? startup.resolveReadBindings(parent, child) : undefined;
|
|
298
|
+
const original = (value) => value === undefined ? undefined : Reflect.get(value, symbols.original) ?? value;
|
|
299
|
+
if (bindings === undefined || bindings.parent !== parent || bindings.child !== child || parent.ctx.tools.get("read", parent) !== bindings.definition
|
|
300
|
+
|| original(parent.ctx.get("fs")) !== original(bindings.parentFs) || original(child.ctx.get("fs")) !== original(bindings.childFs))
|
|
301
|
+
throw new LegacyReadUnavailable("provenance-unavailable");
|
|
302
|
+
merged.throwIfAborted();
|
|
303
|
+
assertTicket(ticket);
|
|
304
|
+
if (ctx.agents.get(child.id) !== child)
|
|
305
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
306
|
+
lifetime = new AbortController();
|
|
307
|
+
const calls = new Map();
|
|
308
|
+
policyScope = createScope(child.ctx, child);
|
|
309
|
+
let markDisposed;
|
|
310
|
+
const disposed = new Promise(resolve => { markDisposed = resolve; });
|
|
311
|
+
// L owns a private token map; this guard lease authenticates the same full invocation without executing its body.
|
|
312
|
+
const pre = async (exec, next) => {
|
|
313
|
+
if (exec.agent !== child || exec.name !== "read")
|
|
314
|
+
return next();
|
|
315
|
+
let lease;
|
|
316
|
+
try {
|
|
317
|
+
lease = host.composition.acquireLease(parent, child, evidence, exec.signal);
|
|
318
|
+
calls.set(exec.token, lease);
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
return { kind: "deny", reason: "Legacy read requires the actual leased operation", info: { name: "LegacyReadUnavailable", code: "composition-unavailable" } };
|
|
322
|
+
}
|
|
323
|
+
const result = await next();
|
|
324
|
+
if (result.kind === "deny" || result.kind === "cancel")
|
|
325
|
+
return result;
|
|
326
|
+
lease.assertActive();
|
|
327
|
+
return result;
|
|
328
|
+
};
|
|
329
|
+
const finish = (exec) => { const lease = calls.get(exec.token); calls.delete(exec.token); lease?.release(); };
|
|
330
|
+
policyScope.ctx.on("tools/pre-execute", pre, { prepend: true });
|
|
331
|
+
policyScope.ctx.on("tools/result", finish);
|
|
332
|
+
const policy = new LegacyChildToolPolicy(evidence, parent, child, legacyCapabilities);
|
|
333
|
+
const guard = exec => exec.agent !== child || policy.denial(exec.name, exec.arguments, child.ctx.tools, exec) !== undefined
|
|
334
|
+
? "Legacy capability requires original evidence and its real Host operation path" : undefined;
|
|
335
|
+
policyScope.ctx.tools.guard(guard);
|
|
336
|
+
proxy = host.attachChild(parent, child, evidence, bindings.definition);
|
|
337
|
+
const operation = createLegacyReadOperationCapability(proxy, exec => calls.get(exec.token));
|
|
338
|
+
const contributions = Object.freeze([
|
|
339
|
+
...(admissionGuards.get(child) ?? []),
|
|
340
|
+
{ side: "child", stage: "pre", scope: policyScope.ctx, reference: pre, order: 1, semantics: "audited-zero-or-once" },
|
|
341
|
+
{ side: "child", stage: "guard", scope: policyScope.ctx, reference: guard, order: 1, semantics: "audited-zero-or-once" },
|
|
342
|
+
{ side: "child", stage: "finalization", scope: policyScope.ctx, reference: finish, order: 1, semantics: "audited-zero-or-once" },
|
|
343
|
+
...proxy.contributions.map(value => ({ side: "child", stage: value.stage, scope: value.scope.ctx, reference: value.reference,
|
|
344
|
+
order: value.stage === "pre" || value.stage === "around" ? -1 : value.order, semantics: "audited-zero-or-once" })),
|
|
345
|
+
]);
|
|
346
|
+
attachment = Object.freeze({ parent, child, evidence, admission, bindings, proxy, policyScope, contributions });
|
|
347
|
+
const resident = { attachment, evidenceBinding: Object.freeze({ evidence, admission, source: "physical-old", physicalRecords,
|
|
348
|
+
childLifetime: lifetime.signal }), lifetime, disposed, markDisposed, retired: false };
|
|
349
|
+
await options.proxyDefinitions.admit(parent, child, proxy.definition);
|
|
350
|
+
options.proxyDefinitions.assertAdmitted(child, proxy.definition);
|
|
351
|
+
merged.throwIfAborted();
|
|
352
|
+
assertTicket(ticket);
|
|
353
|
+
if (admissions.childAdmission(child) !== admission || ctx.agents.get(child.id) !== child || !ctx.agents.isOwnedBy(child.id, parent))
|
|
354
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
355
|
+
admissions.assertCurrentParent(ticket, child, evidence);
|
|
356
|
+
merged.throwIfAborted();
|
|
357
|
+
assertTicket(ticket);
|
|
358
|
+
detachLifetime = scopeLifetime(child.ctx, "dsmm.legacyRead: retire exact child operation path", () => {
|
|
359
|
+
resident.lifetime.abort("child-lifetime-ended");
|
|
360
|
+
if (children.get(child) === resident)
|
|
361
|
+
void retire(child, "child-lifetime-ended");
|
|
362
|
+
});
|
|
363
|
+
merged.throwIfAborted();
|
|
364
|
+
assertTicket(ticket);
|
|
365
|
+
lifetime.signal.throwIfAborted();
|
|
366
|
+
capabilities.set(child, Object.freeze({ kind: "read", definition: proxy.definition, operation, assertArguments: (args) => assertReadArguments(args, bindings) }));
|
|
367
|
+
children.set(child, resident);
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
lifetime?.abort(error);
|
|
371
|
+
if (detachLifetime !== undefined) {
|
|
372
|
+
try {
|
|
373
|
+
detachLifetime();
|
|
374
|
+
}
|
|
375
|
+
catch (cleanupError) {
|
|
376
|
+
reportRetirementFault(cleanupError, child);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// The failed proxy is no longer a residency. L's Host slot/standing deny can retire only after actual disposal.
|
|
380
|
+
if (proxy !== undefined) {
|
|
381
|
+
capabilities.delete(child);
|
|
382
|
+
if (children.get(child)?.attachment.proxy === proxy)
|
|
383
|
+
children.delete(child);
|
|
384
|
+
attachmentErrors.set(child, error);
|
|
385
|
+
let complete, fail;
|
|
386
|
+
const completion = new Promise((resolve, reject) => { complete = resolve; fail = reject; });
|
|
387
|
+
const failed = { policyScope: policyScope, completion, complete, fail };
|
|
388
|
+
failedAttachments.set(child, failed);
|
|
389
|
+
retired.set(child, completion);
|
|
390
|
+
void completion.catch(() => { });
|
|
391
|
+
try {
|
|
392
|
+
await proxy.removeProxy();
|
|
393
|
+
}
|
|
394
|
+
catch (cleanupError) {
|
|
395
|
+
reportRetirementFault(cleanupError, child);
|
|
396
|
+
}
|
|
397
|
+
releaseFailedAttachment(child);
|
|
398
|
+
}
|
|
399
|
+
if (policyScope !== undefined) {
|
|
400
|
+
try {
|
|
401
|
+
await policyScope.dispose();
|
|
402
|
+
}
|
|
403
|
+
catch (cleanupError) {
|
|
404
|
+
reportRetirementFault(cleanupError, child);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (host.composition.view().generation !== undefined)
|
|
408
|
+
recoveryRequested = true;
|
|
409
|
+
throw error;
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
return attachment;
|
|
413
|
+
},
|
|
414
|
+
publishCheckedGeneration() {
|
|
415
|
+
if (pendingChanges)
|
|
416
|
+
throw new LegacyReadUnavailable("composition-unavailable");
|
|
417
|
+
host.publishCheckedGeneration();
|
|
418
|
+
},
|
|
419
|
+
/** Close synchronously; mutate only after real pipelines AND audit leases have drained. */
|
|
420
|
+
change(reason, mutate) {
|
|
421
|
+
const drain = host.composition.closeForChange(reason);
|
|
422
|
+
return enqueue(async () => {
|
|
423
|
+
await drain;
|
|
424
|
+
await host.composition.closeForChange(reason);
|
|
425
|
+
if (disposal !== undefined)
|
|
426
|
+
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
427
|
+
await mutate();
|
|
428
|
+
if (pendingChanges === 1)
|
|
429
|
+
host.publishCheckedGeneration();
|
|
430
|
+
});
|
|
431
|
+
},
|
|
432
|
+
async removeProxy(child) {
|
|
433
|
+
const drain = host.composition.closeForChange("proxy-removal");
|
|
434
|
+
await enqueue(async () => {
|
|
435
|
+
await drain;
|
|
436
|
+
await host.composition.closeForChange("proxy-removal");
|
|
437
|
+
const resident = children.get(child);
|
|
438
|
+
if (resident !== undefined)
|
|
439
|
+
await resident.attachment.proxy.removeProxy();
|
|
440
|
+
});
|
|
441
|
+
},
|
|
442
|
+
/** Opaque native holders call before beginning disposal; ordinary residency teardown also retires automatically. */
|
|
443
|
+
async revokeChildBeforeDispose(child, nativeDispose) {
|
|
444
|
+
const retirement = retire(child, "holder-disposed");
|
|
445
|
+
await host.composition.closeForChange("holder-disposed");
|
|
446
|
+
await nativeDispose();
|
|
447
|
+
await retirement;
|
|
448
|
+
},
|
|
449
|
+
whenChildRetired(child) {
|
|
450
|
+
const resident = children.get(child);
|
|
451
|
+
return resident?.retirement ?? retired.get(child) ?? (resident === undefined ? Promise.resolve() : resident.disposed.then(() => resident.retirement));
|
|
452
|
+
},
|
|
453
|
+
dispose(nativeDrain) {
|
|
454
|
+
if (disposal === undefined)
|
|
455
|
+
disposal = host.dispose(async () => {
|
|
456
|
+
await nativeDrain();
|
|
457
|
+
for (const resident of children.values())
|
|
458
|
+
await resident.attachment.policyScope.dispose();
|
|
459
|
+
});
|
|
460
|
+
return disposal;
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
const core = !coldCore ? undefined : Object.freeze({
|
|
464
|
+
legacyCapabilities,
|
|
465
|
+
classifyLegacyTool: classifyTool,
|
|
466
|
+
resolveOriginalChildEvidence: options.coreAdmissions.resolveOriginalChildEvidence.bind(options.coreAdmissions),
|
|
467
|
+
assertLegacyDelivery(ticket, childId, evidence) {
|
|
468
|
+
ticket.signal.throwIfAborted();
|
|
469
|
+
const parent = ticket.parent.id === undefined ? undefined : ctx.agents.get(SessionId(ticket.parent.id));
|
|
470
|
+
if (parent === undefined || parent !== ticket.parent)
|
|
471
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
472
|
+
const issued = authority.acquireParentTicket(parent);
|
|
473
|
+
assertTicket(issued);
|
|
474
|
+
if (ticket.owner !== authorityOwner || ticket.admission !== issued.admission || ticket.parentEpoch !== issued.parentEpoch
|
|
475
|
+
|| evidence.parentSessionId !== parent.id || evidence.childSessionId !== childId)
|
|
476
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
477
|
+
options.coreAdmissions.assertDelivery(ticket, childId, evidence);
|
|
478
|
+
ticket.signal.throwIfAborted();
|
|
479
|
+
assertTicket(issued);
|
|
480
|
+
},
|
|
481
|
+
async afterChildAdmission(parent, child, signal) {
|
|
482
|
+
const admission = admissions.childAdmission(child);
|
|
483
|
+
if (!Object.isFrozen(admission))
|
|
484
|
+
throw new LegacyReadUnavailable("evidence-unavailable");
|
|
485
|
+
if (admission.childEvidence?.mode !== "legacy-conservative")
|
|
486
|
+
return undefined;
|
|
487
|
+
const ticket = authority.acquireParentTicket(parent);
|
|
488
|
+
assertTicket(ticket);
|
|
489
|
+
const merged = AbortSignal.any([signal, ticket.signal]);
|
|
490
|
+
merged.throwIfAborted();
|
|
491
|
+
const evidence = await admissions.resolveOriginalChildEvidence(ticket, child.id, merged);
|
|
492
|
+
merged.throwIfAborted();
|
|
493
|
+
assertTicket(ticket);
|
|
494
|
+
// This decides enrollment only. A + physical history, exact definitions and L's real operation lease still prove the read.
|
|
495
|
+
if (!("mode" in evidence) || !evidence.toolFilter?.allow?.includes("read") || evidence.toolFilter.deny?.includes("read"))
|
|
496
|
+
return undefined;
|
|
497
|
+
const attachment = await integration.attachChild(parent, child, merged);
|
|
498
|
+
// Concurrent serial-created admissions share the existing Host change queue and publish one closed cohort.
|
|
499
|
+
while (pendingChanges)
|
|
500
|
+
await serial;
|
|
501
|
+
merged.throwIfAborted();
|
|
502
|
+
if (children.get(child)?.retired || child.ctx.tools.get("read", child) !== attachment.proxy.definition)
|
|
503
|
+
throw new LegacyReadUnavailable("lifetime-unavailable");
|
|
504
|
+
if (host.composition.view().state !== "ready")
|
|
505
|
+
integration.publishCheckedGeneration();
|
|
506
|
+
return attachment;
|
|
507
|
+
},
|
|
508
|
+
publishCheckedGeneration: integration.publishCheckedGeneration,
|
|
509
|
+
changeConfiguration: integration.change,
|
|
510
|
+
async revokeBeforeDispose(agent, nativeDrainAndDispose) {
|
|
511
|
+
authority.revokeParent(agent, "holder-disposed");
|
|
512
|
+
const retiring = [...children.values()].filter(value => value.attachment.child === agent || value.attachment.parent === agent
|
|
513
|
+
|| ctx.agents.isOwnedBy(value.attachment.child.id, agent)).map(value => retire(value.attachment.child, "holder-disposed"));
|
|
514
|
+
await host.composition.closeForChange("holder-disposed");
|
|
515
|
+
await nativeDrainAndDispose();
|
|
516
|
+
await Promise.all(retiring);
|
|
517
|
+
},
|
|
518
|
+
dispose: integration.dispose,
|
|
519
|
+
});
|
|
520
|
+
return { ...integration, core };
|
|
521
|
+
}
|
|
522
|
+
//# sourceMappingURL=legacy-read-integration.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
|
+
import type { Scope } from "@deepseek-ai/dsh-scope";
|
|
3
|
+
import type { ToolDefinition } from "@deepseek-ai/dsh-tools";
|
|
4
|
+
import type { LegacyChildEvidence } from "./child-capture.js";
|
|
5
|
+
import type { LegacyReadComposition } from "./legacy-read-composition.js";
|
|
6
|
+
export interface LegacyReadProxy {
|
|
7
|
+
readonly parent: Agent;
|
|
8
|
+
readonly child: Agent;
|
|
9
|
+
readonly definition: ToolDefinition;
|
|
10
|
+
readonly nativeDefinition: ToolDefinition;
|
|
11
|
+
readonly proxyScope: Scope;
|
|
12
|
+
readonly standingScope: Scope;
|
|
13
|
+
/** Actual registrations contributed by this adapter, for the owning Host's closed inventory. */
|
|
14
|
+
readonly contributions: readonly {
|
|
15
|
+
readonly stage: "pre" | "guard" | "around" | "project" | "finalization";
|
|
16
|
+
readonly scope: Scope;
|
|
17
|
+
readonly reference: object;
|
|
18
|
+
readonly order: number;
|
|
19
|
+
}[];
|
|
20
|
+
/** Requires closed admission and drained leases; standing deny is retained. */
|
|
21
|
+
removeProxy(): Promise<void>;
|
|
22
|
+
/** Called by the Host ONLY after actual child disposal, never proxy removal. */
|
|
23
|
+
releaseAfterChildDispose(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare function installLegacyReadProxy(composition: LegacyReadComposition, parent: Agent, child: Agent, evidence: LegacyChildEvidence, nativeDefinition: ToolDefinition): LegacyReadProxy;
|
|
26
|
+
//# sourceMappingURL=legacy-read-proxy.d.ts.map
|