@dsmm/dsmm 0.2.2 → 0.3.1
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 +26 -42
- package/cordis.patch.yml +1 -0
- package/docs/agent-presets.md +26 -14
- package/docs/compatibility.md +20 -79
- package/docs/deferred-native-approval-risk.md +8 -12
- package/docs/design.md +25 -254
- package/docs/lsp.md +2 -2
- package/docs/migration-from-ocmm.md +38 -51
- package/docs/model-routing.md +21 -21
- package/docs/native-permissions.md +17 -7
- package/docs/profiles.md +13 -9
- package/docs/releasing.md +34 -240
- package/docs/roadmap.md +23 -254
- package/docs/runtime-recovery.md +29 -91
- package/docs/safety-guards.md +19 -16
- package/docs/settings-status.md +23 -11
- package/docs/skill-sync.md +17 -17
- package/docs/web-fetch-fakeip.md +82 -0
- package/lib/child-capture.d.ts +16 -2
- package/lib/child-capture.js +29 -10
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +4 -16
- package/lib/client/DeploymentFields.d.ts +28 -0
- package/lib/client/DeploymentFields.js +68 -0
- package/lib/client/DeploymentPage.d.ts +17 -5
- package/lib/client/DeploymentPage.js +79 -112
- package/lib/client/NativeCommandEntries.d.ts +17 -0
- package/lib/client/NativeCommandEntries.js +68 -0
- package/lib/client/PermissionsPanel.d.ts +1 -1
- package/lib/client/PermissionsPanel.js +8 -8
- package/lib/client/ProfilesSection.js +7 -5
- package/lib/client/RoleToolView-data.d.ts +35 -0
- package/lib/client/RoleToolView-data.js +52 -0
- package/lib/client/RoleToolView-locales.d.ts +36 -0
- package/lib/client/RoleToolView-locales.js +20 -0
- package/lib/client/RoleToolView.d.ts +10 -0
- package/lib/client/RoleToolView.js +47 -0
- package/lib/client/SessionProfiles.js +39 -15
- package/lib/client/children-controller.d.ts +2 -8
- package/lib/client/children-controller.js +1 -26
- package/lib/client/children-locales.d.ts +26 -51
- package/lib/client/children-locales.js +8 -12
- package/lib/client/configuration-display.d.ts +5 -0
- package/lib/client/configuration-display.js +11 -0
- package/lib/client/controller.d.ts +1 -0
- package/lib/client/controller.js +20 -13
- package/lib/client/deployment-controller.d.ts +13 -1
- package/lib/client/deployment-controller.js +85 -25
- package/lib/client/deployment-data.d.ts +1 -0
- package/lib/client/deployment-data.js +4 -1
- package/lib/client/deployment-locales.d.ts +43 -0
- package/lib/client/deployment-locales.js +35 -9
- package/lib/client/deployment-modules.d.ts +9 -0
- package/lib/client/deployment-modules.js +24 -0
- package/lib/client/deployment-workspace.d.ts +48 -0
- package/lib/client/deployment-workspace.js +123 -0
- package/lib/client/index.js +11 -74
- package/lib/client/locales.d.ts +7 -0
- package/lib/client/locales.js +12 -6
- package/lib/client/permission-controller.d.ts +1 -0
- package/lib/client/permission-controller.js +3 -2
- package/lib/client/permission-locales.d.ts +25 -0
- package/lib/client/permission-locales.js +24 -4
- package/lib/client/session-labels.js +4 -3
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +9 -8
- package/lib/client.js +2716 -2364
- package/lib/commands.js +2 -0
- package/lib/config-file-store.d.ts +3 -0
- package/lib/config-file-store.js +4 -2
- package/lib/config-revision.d.ts +5 -0
- package/lib/config-revision.js +11 -0
- package/lib/core-permission-authority.js +11 -41
- package/lib/deployment-config.d.ts +9 -2
- package/lib/deployment-config.js +35 -8
- package/lib/deployment-permission-rules.js +19 -7
- package/lib/dsh-types.d.ts +1 -1
- package/lib/host-llm-startup.js +3 -3
- package/lib/host-llm.d.ts +9 -3
- package/lib/host-llm.js +48 -8
- package/lib/index.d.ts +17 -21
- package/lib/index.js +131 -430
- package/lib/lifetime.d.ts +4 -0
- package/lib/lifetime.js +22 -0
- package/lib/live-pi-ai-owner.d.ts +1 -0
- package/lib/live-pi-ai-owner.js +8 -4
- package/lib/mode.d.ts +3 -2
- package/lib/mode.js +28 -41
- package/lib/model-routing.d.ts +2 -8
- package/lib/model-routing.js +59 -175
- package/lib/native-admission.d.ts +56 -0
- package/lib/native-admission.js +313 -0
- package/lib/native-pi-ai-wire.d.ts +3 -1
- package/lib/native-pi-ai-wire.js +47 -13
- package/lib/permission-control.d.ts +0 -3
- package/lib/permission-rpc.js +3 -3
- package/lib/preset-registry.js +3 -2
- package/lib/preset-skills.d.ts +3 -12
- package/lib/preset-skills.js +28 -58
- package/lib/profile-diagnostics.d.ts +1 -1
- package/lib/profile-diagnostics.js +2 -2
- package/lib/profile-remote.js +61 -22
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +39 -41
- package/lib/profile-runtime.d.ts +31 -74
- package/lib/profile-runtime.js +224 -639
- package/lib/profile-store.d.ts +18 -6
- package/lib/profile-store.js +106 -64
- package/lib/profile-types.d.ts +18 -4
- package/lib/profiles.d.ts +3 -1
- package/lib/profiles.js +9 -7
- package/lib/prompt-content.d.ts +1 -0
- package/lib/prompt-content.js +4 -1
- package/lib/prompts.d.ts +2 -12
- package/lib/prompts.js +11 -66
- package/lib/role-control-remote.d.ts +1 -4
- package/lib/role-control-remote.js +8 -36
- package/lib/role-control-rpc.d.ts +10 -36
- package/lib/role-control-rpc.js +112 -265
- package/lib/role-control-types.d.ts +3 -26
- package/lib/role-control-types.js +3 -4
- package/lib/role-identity.d.ts +5 -0
- package/lib/role-identity.js +10 -0
- package/lib/role-invocation.d.ts +2 -2
- package/lib/role-llm-runtime.js +5 -11
- package/lib/role-policy.d.ts +19 -53
- package/lib/role-policy.js +136 -525
- package/lib/role-providers.d.ts +5 -8
- package/lib/role-providers.js +20 -126
- package/lib/role-routing.d.ts +1 -3
- package/lib/role-routing.js +24 -34
- package/lib/role-subagents.d.ts +5 -14
- package/lib/role-subagents.js +149 -97
- package/lib/runtime-integration.d.ts +5 -109
- package/lib/runtime-integration.js +11 -779
- package/lib/session-metadata.d.ts +13 -12
- package/lib/session-metadata.js +6 -31
- package/lib/session-scope.js +6 -2
- package/lib/settings.d.ts +5 -18
- package/lib/settings.js +19 -43
- package/lib/state.d.ts +3 -2
- package/lib/state.js +26 -10
- package/lib/status.d.ts +1 -9
- package/lib/status.js +3 -55
- package/lib/web-fetch-address-policy.d.ts +24 -0
- package/lib/web-fetch-address-policy.js +189 -0
- package/lib/web-fetch-fakeip.d.ts +25 -0
- package/lib/web-fetch-fakeip.js +107 -0
- package/package.json +133 -113
- package/docs/research/deepseek-v4-pro.md +0 -74
- package/docs/research/oh-dsh.md +0 -96
- package/lib/child-admission.d.ts +0 -42
- package/lib/child-admission.js +0 -162
- package/lib/delivery-authority.d.ts +0 -68
- package/lib/delivery-authority.js +0 -260
- package/lib/legacy-child-policy.d.ts +0 -51
- package/lib/legacy-child-policy.js +0 -123
- package/lib/legacy-read-composition.d.ts +0 -20
- package/lib/legacy-read-composition.js +0 -144
- package/lib/legacy-read-contracts.d.ts +0 -157
- package/lib/legacy-read-contracts.js +0 -39
- package/lib/legacy-read-host.d.ts +0 -19
- package/lib/legacy-read-host.js +0 -67
- package/lib/legacy-read-integration.d.ts +0 -121
- package/lib/legacy-read-integration.js +0 -522
- package/lib/legacy-read-proxy.d.ts +0 -26
- package/lib/legacy-read-proxy.js +0 -237
- package/lib/native-child-evidence.d.ts +0 -42
- package/lib/native-child-evidence.js +0 -133
- package/lib/role-runs.d.ts +0 -135
- package/lib/role-runs.js +0 -304
- package/lib/session-persistence.d.ts +0 -35
- package/lib/session-persistence.js +0 -304
- package/lib/subagent-runtime.d.ts +0 -45
- package/lib/subagent-runtime.js +0 -131
- package/prompts/deepseek-flash.md +0 -11
- package/prompts/deepseek-v4-pro.md +0 -14
- package/scripts/cold-profile-composition.mjs +0 -329
- package/scripts/cold-profile-sources.mjs +0 -238
- package/scripts/migrate-cold-profile.mjs +0 -315
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# DeepSeek V4 Pro Prompt Calibration Notes
|
|
2
|
-
|
|
3
|
-
Date: 2026-08-21
|
|
4
|
-
|
|
5
|
-
## Status of evidence
|
|
6
|
-
|
|
7
|
-
The user reports that DeepSeek V4 Pro currently shows an overfitting-like behavior and needs specialized prompting to activate its full capability. Public official sources reviewed for this design do not state that diagnosis directly. The design therefore treats "overfitting" as a field observation and uses official model behavior to derive safe calibration rules.
|
|
8
|
-
|
|
9
|
-
## Official and public facts used
|
|
10
|
-
|
|
11
|
-
1. The DeepSeek API documents `deepseek-v4-pro` thinking mode with `reasoning_effort` and `extra_body: { "thinking": { "type": "enabled" } }`.
|
|
12
|
-
2. In thinking mode, sampling controls such as `temperature`, `top_p`, `presence_penalty`, and `frequency_penalty` are documented as ineffective in the official API path.
|
|
13
|
-
3. Thinking mode supports tool calls.
|
|
14
|
-
4. Tool-calling conversations in thinking mode require reasoning content to be preserved across subsequent user interaction turns; otherwise the integration can fail or lose the model's reasoning continuity.
|
|
15
|
-
5. DeepSeek V4 Pro public model material describes non-think, think-high, and think-max operating modes. Think-max uses an additional prompt/prefix mechanism and is intended for the hardest reasoning tasks.
|
|
16
|
-
6. General API usage does not accept the `developer` role, even though the open encoding docs mention it for an internal search-agent pipeline.
|
|
17
|
-
|
|
18
|
-
## dsmm calibration implications
|
|
19
|
-
|
|
20
|
-
### Prompt structure
|
|
21
|
-
|
|
22
|
-
DeepSeek V4 Pro calibration should be concrete and trigger-based:
|
|
23
|
-
|
|
24
|
-
- classify the task before acting;
|
|
25
|
-
- decompose architectural/debugging/migration work before editing;
|
|
26
|
-
- use tools for repository-specific facts;
|
|
27
|
-
- avoid claiming file state without reading/searching;
|
|
28
|
-
- keep the final answer concise while letting reasoning effort do the heavy lifting;
|
|
29
|
-
- make review and evidence gates explicit.
|
|
30
|
-
|
|
31
|
-
Avoid vague text such as "use your full intelligence" as the primary mechanism. It is acceptable as a short reinforcement, but the main prompt should specify observable behaviors.
|
|
32
|
-
|
|
33
|
-
### Reasoning policy
|
|
34
|
-
|
|
35
|
-
Recommended default policy for dsmm settings:
|
|
36
|
-
|
|
37
|
-
```yaml
|
|
38
|
-
dsmm:
|
|
39
|
-
prompts:
|
|
40
|
-
deepseekV4ProCalibration: auto
|
|
41
|
-
models:
|
|
42
|
-
defaultReasoningEffort: high
|
|
43
|
-
maxReasoningForArchitecturalWork: true
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Interpretation:
|
|
47
|
-
|
|
48
|
-
- `off`: no DeepSeek-specific overlay.
|
|
49
|
-
- `auto`: apply overlay only when the active model is detected as DeepSeek V4 Pro.
|
|
50
|
-
- `strict`: apply overlay and prefer max reasoning for architecture, migration, review, runtime-safety, or hard-reasoning tasks.
|
|
51
|
-
|
|
52
|
-
### Tool-call continuity
|
|
53
|
-
|
|
54
|
-
dsmm should not itself assume it can manage DeepSeek API message encoding. If dsh exposes a hook or adapter setting for reasoning-content retention, dsmm v0.6 should verify it for DeepSeek V4 Pro tool calls. Until then, dsmm docs should warn that provider/adapter correctness matters for thinking-mode tool use.
|
|
55
|
-
|
|
56
|
-
### Mode boundary
|
|
57
|
-
|
|
58
|
-
The calibration overlay belongs inside dsmm's `deepwork` custom mode or dsmm-managed role scopes. It should not be global, because ordinary dsh sessions may prefer concise non-think behavior.
|
|
59
|
-
|
|
60
|
-
## Draft calibration text shape
|
|
61
|
-
|
|
62
|
-
The final prompt should be maintained in source files, but its shape should remain close to this:
|
|
63
|
-
|
|
64
|
-
```text
|
|
65
|
-
When the active model is DeepSeek V4 Pro and dsmm deepwork mode is active:
|
|
66
|
-
- Treat complex coding, architecture, migration, debugging, and review tasks as deliberate reasoning tasks.
|
|
67
|
-
- First classify the task and identify the evidence needed.
|
|
68
|
-
- Use repository and documentation tools before making repo-specific claims.
|
|
69
|
-
- For multi-step work, maintain a visible plan or task list and verify each completed boundary.
|
|
70
|
-
- Use concise user-facing answers; do not expose private chain-of-thought.
|
|
71
|
-
- Prefer high reasoning effort by default; use max only for configured high-rigor tasks.
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
This text is intentionally behavioral rather than motivational. It should compose with dsh's own model adapter rather than fighting the adapter's chat template.
|
package/docs/research/oh-dsh.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# oh-dsh Research Notes
|
|
2
|
-
|
|
3
|
-
Source target: `https://github.com/hust-open-atom-club/oh-dsh`
|
|
4
|
-
|
|
5
|
-
## Project shape
|
|
6
|
-
|
|
7
|
-
oh-dsh is a dsh runtime distribution that combines desktop, web, and TUI surfaces. The repo is organized around a top-level package plus workspace plugins under `plugins/`, with separate patch layers for desktop and web profiles.
|
|
8
|
-
|
|
9
|
-
Relevant observed structure:
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
oh-dsh/
|
|
13
|
-
bin/
|
|
14
|
-
src/
|
|
15
|
-
cli.ts
|
|
16
|
-
profile.ts
|
|
17
|
-
plugin.ts
|
|
18
|
-
contracts.ts
|
|
19
|
-
runtime*.ts
|
|
20
|
-
plugins/
|
|
21
|
-
desktop-frame/
|
|
22
|
-
better-sidebar-runtime/
|
|
23
|
-
plugin-marketplace/
|
|
24
|
-
skins/
|
|
25
|
-
vision/
|
|
26
|
-
shared/
|
|
27
|
-
tui/
|
|
28
|
-
cordis.patch.yml
|
|
29
|
-
web/cordis.patch.yml
|
|
30
|
-
docs/
|
|
31
|
-
tests/
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Bundle and profile pattern
|
|
35
|
-
|
|
36
|
-
oh-dsh follows dsh's package manifest model:
|
|
37
|
-
|
|
38
|
-
- top-level package exports the Host plugin entry, client entry, and compiled patch;
|
|
39
|
-
- `dsh.bundle.patch` points to the shipped `cordis.patch.yml`;
|
|
40
|
-
- profile assembly lists dsh base/web/headless bundles plus oh-dsh's own bundle;
|
|
41
|
-
- user patch layers remain separate from shipped bundle patches.
|
|
42
|
-
|
|
43
|
-
This is directly useful for dsmm: ship dsmm as a bundle layer and let users override it from their profile patch.
|
|
44
|
-
|
|
45
|
-
## Patch organization
|
|
46
|
-
|
|
47
|
-
oh-dsh uses patch rows to disable upstream defaults and insert its own plugin rows. The key idea is not the specific desktop plugins, but the pattern:
|
|
48
|
-
|
|
49
|
-
```yaml
|
|
50
|
-
- insert:
|
|
51
|
-
- id: oh-desktop-frame
|
|
52
|
-
name: '@oh-dsh/desktop-frame'
|
|
53
|
-
- id: oh-vision
|
|
54
|
-
name: '@oh-dsh/vision'
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
For dsmm, the equivalent is a small set of rows for the dsmm Host plugin, mode definition, settings namespace, prompts, and skill provider.
|
|
58
|
-
|
|
59
|
-
## Host/Client separation
|
|
60
|
-
|
|
61
|
-
oh-dsh packages can expose both Host and Client entries. Host plugins provide services and register prompt/tool/settings contributions. Client plugins inject browser UI surfaces.
|
|
62
|
-
|
|
63
|
-
dsmm MVP should stay Host-only. A client/settings panel can come later, after the dsh plugin APIs and dsmm settings model are stable.
|
|
64
|
-
|
|
65
|
-
## Settings seam
|
|
66
|
-
|
|
67
|
-
oh-dsh distinguishes two planes:
|
|
68
|
-
|
|
69
|
-
- composition plane: profile bundle rows and `cordis.patch.yml` decide which plugins exist;
|
|
70
|
-
- settings plane: user-editable YAML/JSON controls personal preferences.
|
|
71
|
-
|
|
72
|
-
dsmm should adopt this split. Deepwork availability is composition; mode name, auto-entry, calibration strictness, and skill toggles are settings.
|
|
73
|
-
|
|
74
|
-
## Custom mode relevance
|
|
75
|
-
|
|
76
|
-
oh-dsh tracks dsh mode/plan-mode design notes. The important behavior for dsmm is that a mode is session-scoped state, not a global prompt mutation. A mode contributes model-visible instructions while active and can be entered through commands or UI mode selection.
|
|
77
|
-
|
|
78
|
-
Current public dsh documentation exposes `@deepseek-ai/dsh-plan-mode`, not a generic arbitrary named `@deepseek-ai/dsh-mode` package. dsmm should therefore implement its own `deepwork` mode plugin using the same principles, or adapt to an upstream generic mode package if it becomes available. This satisfies the requirement that deepwork should be opt-in rather than global.
|
|
79
|
-
|
|
80
|
-
## Borrowed design decisions
|
|
81
|
-
|
|
82
|
-
1. Ship defaults as a bundle patch, not as instructions for users to paste manually.
|
|
83
|
-
2. Keep profile/user patch layers override-friendly.
|
|
84
|
-
3. Separate Host capability registration from optional Client UI.
|
|
85
|
-
4. Use a settings namespace for user-editable behavior.
|
|
86
|
-
5. Treat mode as the activation boundary for workflow behavior.
|
|
87
|
-
|
|
88
|
-
## Not copied into MVP
|
|
89
|
-
|
|
90
|
-
- Electron desktop shell.
|
|
91
|
-
- Web/TUI UI composition.
|
|
92
|
-
- Plugin marketplace transaction system.
|
|
93
|
-
- Vision tool integration.
|
|
94
|
-
- Sidebar and panel controls.
|
|
95
|
-
|
|
96
|
-
Those features are valuable in oh-dsh, but dsmm's MVP is a workflow/mode bundle rather than a UI runtime distribution.
|
package/lib/child-admission.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { ChildAdmissionCompletion, DsmmChildAdmissionAuthority, LegacyChildEvidenceReader, ParentAdmissionTicket } from "./child-admission-contract.js";
|
|
4
|
-
import type { ChildAdmissionEvidence, ChildAdmissionEvidenceView, ChildEvidenceField } from "./child-capture.js";
|
|
5
|
-
import type { DeliveryPolicyBinding, DsmmDeliveryAuthority } from "./delivery-authority.js";
|
|
6
|
-
import type { DshAgent } from "./dsh-types.js";
|
|
7
|
-
import type { NativeChildHistory } from "./native-child-evidence.js";
|
|
8
|
-
import type { LegacyCapabilityCollaborators } from "./legacy-child-policy.js";
|
|
9
|
-
import type { DsmmProfileAdmission, DsmmSettings } from "./settings.js";
|
|
10
|
-
export interface ChildAdmissionCollaborators {
|
|
11
|
-
/** A owns resident/durable capture lookup and corruption-vs-absence decisions. */
|
|
12
|
-
resolveOriginalChildEvidence(ticket: ParentAdmissionTicket, childId: string, signal: AbortSignal, readLegacy: LegacyChildEvidenceReader): Promise<ChildAdmissionEvidence>;
|
|
13
|
-
/** B owns fresh invocation capture, role identity and target ceiling validation. */
|
|
14
|
-
childAdmission: ChildAdmissionCompletion;
|
|
15
|
-
assertDelivery(ticket: ParentAdmissionTicket, childId: string, evidence: ChildAdmissionEvidence): void;
|
|
16
|
-
classifyParent(parent: Agent): "dsmm" | "native";
|
|
17
|
-
}
|
|
18
|
-
export interface ChildAdmissionBindingOptions {
|
|
19
|
-
readonly ctx: Context;
|
|
20
|
-
readonly owner: object;
|
|
21
|
-
readonly deliveryAuthority: DsmmDeliveryAuthority<DsmmProfileAdmission, ChildAdmissionEvidence>;
|
|
22
|
-
readonly collaborators: ChildAdmissionCollaborators;
|
|
23
|
-
readonly nativeSubstrate: DsmmSettings;
|
|
24
|
-
/** The exact public Host query service, borrowed in the same scope as the native catalog. */
|
|
25
|
-
readonly nativeHistory: NativeChildHistory;
|
|
26
|
-
readonly legacyCapabilities: LegacyCapabilityCollaborators;
|
|
27
|
-
}
|
|
28
|
-
/** Connects A's structural contract to C1's opaque ticket provenance without manufacturing Agents. */
|
|
29
|
-
export declare function createChildAdmissionBinding(options: ChildAdmissionBindingOptions): {
|
|
30
|
-
authority: DsmmChildAdmissionAuthority;
|
|
31
|
-
policy: DeliveryPolicyBinding<DsmmProfileAdmission, ChildAdmissionEvidence>;
|
|
32
|
-
childAdmission: ChildAdmissionCompletion;
|
|
33
|
-
readLegacy: LegacyChildEvidenceReader;
|
|
34
|
-
resolveOriginalEvidence: (ticket: ParentAdmissionTicket, id: string, signal: AbortSignal) => Promise<ChildAdmissionEvidence>;
|
|
35
|
-
bind(scope: Context): () => void;
|
|
36
|
-
onAdmissionGuardsInstalled(): void;
|
|
37
|
-
/** Holder owner calls this before native disposal/drain; no replacement residency is revoked. */
|
|
38
|
-
revokeBeforeDispose(parent: DshAgent, dispose: () => void | Promise<void>): Promise<void>;
|
|
39
|
-
};
|
|
40
|
-
/** DTO consumers supply the CURRENT direct-parent epoch; original epochs are not an authorization equality test. */
|
|
41
|
-
export declare function projectChildAdmissionEvidence(evidence: ChildAdmissionEvidence, parentAdmissionEpoch: string, parentDenied?: readonly ChildEvidenceField[]): ChildAdmissionEvidenceView;
|
|
42
|
-
//# sourceMappingURL=child-admission.d.ts.map
|
package/lib/child-admission.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
2
|
-
import { SubagentError } from "@deepseek-ai/dsh-subagent";
|
|
3
|
-
import { parseChildAdmissionCapture, parseChildAdmissionEvidenceView, parseLegacyChildEvidence } from "./child-capture.js";
|
|
4
|
-
import { NativeChildEvidenceReader, assertNativeChildCapture, legacyEvidenceFromNativeFacts } from "./native-child-evidence.js";
|
|
5
|
-
import { createConservativeLegacyAdmission, installLegacyChildToolPolicy } from "./legacy-child-policy.js";
|
|
6
|
-
function unauthorized() { throw new SubagentError("Child admission requires an issued ticket and exact native Agent owner", "UNAUTHORIZED"); }
|
|
7
|
-
/** Connects A's structural contract to C1's opaque ticket provenance without manufacturing Agents. */
|
|
8
|
-
export function createChildAdmissionBinding(options) {
|
|
9
|
-
const { ctx, owner, deliveryAuthority: delivery, collaborators } = options;
|
|
10
|
-
const nativeTickets = new WeakMap();
|
|
11
|
-
const profileTickets = new WeakMap();
|
|
12
|
-
const registeredParents = new WeakMap();
|
|
13
|
-
const exact = (parent) => {
|
|
14
|
-
if (parent.id === undefined)
|
|
15
|
-
unauthorized();
|
|
16
|
-
const actual = ctx.agents.get(SessionId(parent.id));
|
|
17
|
-
if (actual === undefined || actual !== parent)
|
|
18
|
-
unauthorized();
|
|
19
|
-
return actual;
|
|
20
|
-
};
|
|
21
|
-
const assertNative = (ticket) => {
|
|
22
|
-
delivery.assertTicket(ticket);
|
|
23
|
-
if (ticket.owner !== owner || exact(ticket.parent) !== ticket.parent)
|
|
24
|
-
unauthorized();
|
|
25
|
-
};
|
|
26
|
-
const profileTicket = (ticket) => {
|
|
27
|
-
assertNative(ticket);
|
|
28
|
-
let borrowed = profileTickets.get(ticket);
|
|
29
|
-
if (borrowed === undefined) {
|
|
30
|
-
borrowed = Object.freeze({ parent: ticket.parent, owner: ticket.owner, admission: ticket.admission,
|
|
31
|
-
parentEpoch: ticket.parentEpoch, signal: ticket.signal });
|
|
32
|
-
profileTickets.set(ticket, borrowed);
|
|
33
|
-
nativeTickets.set(borrowed, ticket);
|
|
34
|
-
}
|
|
35
|
-
return borrowed;
|
|
36
|
-
};
|
|
37
|
-
const nativeTicket = (ticket) => {
|
|
38
|
-
const actual = nativeTickets.get(ticket);
|
|
39
|
-
if (actual === undefined)
|
|
40
|
-
unauthorized();
|
|
41
|
-
assertNative(actual);
|
|
42
|
-
return actual;
|
|
43
|
-
};
|
|
44
|
-
const reader = new NativeChildEvidenceReader(ctx, assertNative, options.nativeHistory);
|
|
45
|
-
const readLegacy = (ticket, id, signal) => reader.legacy(nativeTicket(ticket), id, signal);
|
|
46
|
-
const resolve = async (ticket, id, callerSignal) => {
|
|
47
|
-
assertNative(ticket);
|
|
48
|
-
const signal = AbortSignal.any([ticket.signal, callerSignal]);
|
|
49
|
-
signal.throwIfAborted();
|
|
50
|
-
const evidence = await collaborators.resolveOriginalChildEvidence(profileTicket(ticket), id, signal, readLegacy);
|
|
51
|
-
signal.throwIfAborted();
|
|
52
|
-
assertNative(ticket);
|
|
53
|
-
const parsed = "mode" in evidence ? parseLegacyChildEvidence(evidence) : parseChildAdmissionCapture(evidence);
|
|
54
|
-
const facts = await reader.read(ticket, id, signal);
|
|
55
|
-
signal.throwIfAborted();
|
|
56
|
-
assertNative(ticket);
|
|
57
|
-
if ("mode" in parsed) {
|
|
58
|
-
const physical = legacyEvidenceFromNativeFacts(facts);
|
|
59
|
-
if (!sameLegacyEvidence(parsed, physical))
|
|
60
|
-
unauthorized();
|
|
61
|
-
}
|
|
62
|
-
else
|
|
63
|
-
assertNativeChildCapture(parsed, facts);
|
|
64
|
-
return evidence;
|
|
65
|
-
};
|
|
66
|
-
const authority = {
|
|
67
|
-
view: () => delivery.view(),
|
|
68
|
-
registerParent: (parent, admission, requestedOwner) => {
|
|
69
|
-
if (requestedOwner !== owner)
|
|
70
|
-
unauthorized();
|
|
71
|
-
const actual = exact(parent);
|
|
72
|
-
delivery.registerParent(actual, admission, owner);
|
|
73
|
-
registeredParents.set(parent, actual);
|
|
74
|
-
},
|
|
75
|
-
acquireParentTicket: parent => profileTicket(delivery.acquireParentTicket(exact(parent))),
|
|
76
|
-
resolveChildEvidence: async (ticket, id, signal) => resolve(nativeTicket(ticket), id, signal),
|
|
77
|
-
prepareParentAdmission: (parent, epoch, next) => delivery.prepareParentAdmission(exact(parent), epoch, next),
|
|
78
|
-
assertCoreParentAdmission: (parent, requestedOwner, expected) => {
|
|
79
|
-
if (requestedOwner !== owner)
|
|
80
|
-
unauthorized();
|
|
81
|
-
delivery.assertCoreParentAdmission(exact(parent), owner, expected);
|
|
82
|
-
},
|
|
83
|
-
prepareCoreParentAdmission: (parent, requestedOwner, expected, next) => {
|
|
84
|
-
if (requestedOwner !== owner)
|
|
85
|
-
unauthorized();
|
|
86
|
-
delivery.prepareCoreParentAdmission(exact(parent), owner, expected, next);
|
|
87
|
-
},
|
|
88
|
-
publishParentAdmission: (parent, epoch, next, install) => delivery.publishParentAdmission(exact(parent), epoch, next, install),
|
|
89
|
-
// Revocation may run during registry removal: use the exact object, never look up a replacement by ID.
|
|
90
|
-
revokeParent: (parent, reason) => {
|
|
91
|
-
const actual = registeredParents.get(parent);
|
|
92
|
-
if (actual !== undefined) {
|
|
93
|
-
delivery.revokeParent(actual, reason);
|
|
94
|
-
registeredParents.delete(parent);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
const policy = {
|
|
99
|
-
classifyParent: collaborators.classifyParent,
|
|
100
|
-
resolveChildEvidence: resolve,
|
|
101
|
-
assertDelivery(ticket, id, evidence) { assertNative(ticket); collaborators.assertDelivery(profileTicket(ticket), id, evidence); assertNative(ticket); },
|
|
102
|
-
};
|
|
103
|
-
const childAdmission = {
|
|
104
|
-
async prepare(agent, parent, ticket, signal) {
|
|
105
|
-
const issued = nativeTicket(ticket);
|
|
106
|
-
if (exact(parent) !== issued.parent || ctx.agents.get(SessionId(agent.id)) !== agent || !ctx.agents.isOwnedBy(SessionId(agent.id), issued.parent))
|
|
107
|
-
unauthorized();
|
|
108
|
-
const merged = AbortSignal.any([signal, issued.signal]);
|
|
109
|
-
merged.throwIfAborted();
|
|
110
|
-
const prepared = await collaborators.childAdmission.prepare(agent, parent, ticket, merged);
|
|
111
|
-
merged.throwIfAborted();
|
|
112
|
-
assertNative(issued);
|
|
113
|
-
return "mode" in prepared.evidence ? { ...prepared,
|
|
114
|
-
admission: createConservativeLegacyAdmission(prepared.evidence, ticket.admission, options.nativeSubstrate) } : prepared;
|
|
115
|
-
},
|
|
116
|
-
validateRole(agent, parent, candidate) {
|
|
117
|
-
collaborators.childAdmission.validateRole(agent, parent, candidate);
|
|
118
|
-
if ("mode" in candidate.evidence && !candidate.retained) {
|
|
119
|
-
installLegacyChildToolPolicy(candidate.evidence, exact(parent), exact(agent), options.legacyCapabilities);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
return { authority, policy, childAdmission, readLegacy,
|
|
124
|
-
resolveOriginalEvidence: (ticket, id, signal) => resolve(nativeTicket(ticket), id, signal),
|
|
125
|
-
bind(scope) { return delivery.bindPolicy(scope, owner, policy); },
|
|
126
|
-
onAdmissionGuardsInstalled() { delivery.enablePolicy(owner); },
|
|
127
|
-
/** Holder owner calls this before native disposal/drain; no replacement residency is revoked. */
|
|
128
|
-
async revokeBeforeDispose(parent, dispose) {
|
|
129
|
-
authority.revokeParent(parent, "holder-disposed");
|
|
130
|
-
await dispose();
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function sameLegacyEvidence(left, right) {
|
|
135
|
-
return left.childSessionId === right.childSessionId && left.parentSessionId === right.parentSessionId && left.role === right.role
|
|
136
|
-
&& left.depth === right.depth && JSON.stringify(left.route) === JSON.stringify(right.route)
|
|
137
|
-
&& JSON.stringify(left.toolFilter) === JSON.stringify(right.toolFilter)
|
|
138
|
-
&& left.provenFields.every(field => right.provenFields.includes(field));
|
|
139
|
-
}
|
|
140
|
-
/** DTO consumers supply the CURRENT direct-parent epoch; original epochs are not an authorization equality test. */
|
|
141
|
-
export function projectChildAdmissionEvidence(evidence, parentAdmissionEpoch, parentDenied = []) {
|
|
142
|
-
let view;
|
|
143
|
-
if ("mode" in evidence) {
|
|
144
|
-
const legacy = parseLegacyChildEvidence(evidence);
|
|
145
|
-
view = parseChildAdmissionEvidenceView({ mode: "legacy-conservative", parentAdmissionEpoch, provenFields: legacy.provenFields, limitations: legacy.limitations });
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
const capture = parseChildAdmissionCapture(evidence);
|
|
149
|
-
const provenFields = ["lineage", "role", "route", "profile-pin", "admission-epoch", "invocation-level", "runtime-policy", "modules", "roles",
|
|
150
|
-
"read-only", "route-override", "max-depth", "locale", "tool-topology", "guards", "git-write", "shell", "delegation"];
|
|
151
|
-
if (capture.authorityCeiling.toolFilter !== undefined)
|
|
152
|
-
provenFields.push("tool-filter");
|
|
153
|
-
view = parseChildAdmissionEvidenceView({ mode: "captured", parentAdmissionEpoch, originalAdmissionEpoch: capture.originalAdmissionEpoch, provenFields,
|
|
154
|
-
limitations: [{ field: "active-intent", code: "missing-evidence", effect: "display-only" }, { field: "max-tokens", code: "not-persisted", effect: "native-default" },
|
|
155
|
-
{ field: "output-schema", code: "unverified", effect: "capability-denied" }] });
|
|
156
|
-
}
|
|
157
|
-
const limitations = new Map(view.limitations.map(item => [item.field, item]));
|
|
158
|
-
for (const field of parentDenied)
|
|
159
|
-
limitations.set(field, { field, code: "parent-denied", effect: "capability-denied" });
|
|
160
|
-
return parseChildAdmissionEvidenceView({ ...view, limitations: [...limitations.values()] });
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=child-admission.js.map
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { SessionId } from "@deepseek-ai/dsh-session";
|
|
4
|
-
/** A borrowed immutable admission, never reconstructed from current settings. */
|
|
5
|
-
export interface DeliveryAdmission {
|
|
6
|
-
readonly epoch: string;
|
|
7
|
-
}
|
|
8
|
-
export type DeliveryParentClassifier = (parent: Agent) => "dsmm" | "native";
|
|
9
|
-
export interface ParentAdmissionTicket<A extends DeliveryAdmission = DeliveryAdmission> {
|
|
10
|
-
readonly parent: Agent;
|
|
11
|
-
readonly owner: object;
|
|
12
|
-
readonly admission: A;
|
|
13
|
-
readonly parentEpoch: string;
|
|
14
|
-
readonly signal: AbortSignal;
|
|
15
|
-
}
|
|
16
|
-
/** Host-only collaborators supply the original capture/evidence and role policy. */
|
|
17
|
-
export interface DeliveryPolicyBinding<A extends DeliveryAdmission, E> {
|
|
18
|
-
/** Inspect trusted DSMM origin/role facts; missing registration is not proof of native identity. */
|
|
19
|
-
classifyParent: DeliveryParentClassifier;
|
|
20
|
-
resolveChildEvidence(ticket: ParentAdmissionTicket<A>, childId: SessionId, signal: AbortSignal): Promise<E>;
|
|
21
|
-
/** Check direct target identity, original ceiling AND current parent authorization. */
|
|
22
|
-
assertDelivery(ticket: ParentAdmissionTicket<A>, childId: SessionId, evidence: E): void;
|
|
23
|
-
}
|
|
24
|
-
export interface DeliveryFenceView {
|
|
25
|
-
readonly binding: "dsmm";
|
|
26
|
-
readonly deliveryFenceReady: boolean;
|
|
27
|
-
readonly restartRequired: false;
|
|
28
|
-
readonly reason?: "authority-not-ready";
|
|
29
|
-
}
|
|
30
|
-
/** Public plugin/status dispatch precedes async cleanup, including ancestor Host teardown. */
|
|
31
|
-
export declare function scopeLifetime(scope: Context, label: string, revoke: () => void, install?: () => void): () => void;
|
|
32
|
-
/** Stable Host lifetime; profile entry disposal must not replace this object. */
|
|
33
|
-
export declare class DsmmDeliveryAuthority<A extends DeliveryAdmission = DeliveryAdmission, E = unknown> {
|
|
34
|
-
private readonly ctx;
|
|
35
|
-
private readonly lifetime;
|
|
36
|
-
private readonly parents;
|
|
37
|
-
private readonly tickets;
|
|
38
|
-
private readonly managedIds;
|
|
39
|
-
private binding?;
|
|
40
|
-
private connection?;
|
|
41
|
-
private readonly providersReady;
|
|
42
|
-
private readonly changed;
|
|
43
|
-
private readonly hostClassifier?;
|
|
44
|
-
constructor(ctx: Context, providersReady?: () => boolean, changed?: () => void, hostClassifier?: DeliveryParentClassifier);
|
|
45
|
-
view(): DeliveryFenceView;
|
|
46
|
-
/** Bind once per entry scope; teardown revokes its pending tickets synchronously. */
|
|
47
|
-
bindPolicy(scope: Context, owner: object, policy: DeliveryPolicyBinding<A, E>): () => void;
|
|
48
|
-
/** Called after A/B admission/capture guards are installed, not at service mount. */
|
|
49
|
-
enablePolicy(owner: object): void;
|
|
50
|
-
isManaged(parent: Agent): boolean;
|
|
51
|
-
registerParent(parent: Agent, admission: A, owner: object): void;
|
|
52
|
-
acquireParentTicket(parent: Agent): ParentAdmissionTicket<A>;
|
|
53
|
-
assertTicket(ticket: ParentAdmissionTicket<A>): void;
|
|
54
|
-
resolveChildEvidence(ticket: ParentAdmissionTicket<A>, childId: SessionId, signal: AbortSignal): Promise<E>;
|
|
55
|
-
assertDelivery(ticket: ParentAdmissionTicket<A>, childId: SessionId, evidence: E): void;
|
|
56
|
-
prepareParentAdmission(parent: Agent, expectedEpoch: string, nextAdmission: A): void;
|
|
57
|
-
/** Core configuration uses the same exact parent state without acquiring delivery capability. */
|
|
58
|
-
assertCoreParentAdmission(parent: Agent, owner: object, expected: A): void;
|
|
59
|
-
prepareCoreParentAdmission(parent: Agent, owner: object, expected: A, nextAdmission: A): void;
|
|
60
|
-
/** Trusted successful-commit callback: install MUST be synchronous and nonthrowing. */
|
|
61
|
-
publishParentAdmission(parent: Agent, expectedEpoch: string, nextAdmission: A, install: () => void): void;
|
|
62
|
-
revokeParent(parent: Agent, _reason: string): void;
|
|
63
|
-
revokeOwner(owner: object, reason: string): void;
|
|
64
|
-
/** Only the native exact operator/Connection can authorize browser delivery. */
|
|
65
|
-
acquireBrowserSignal(callerCtx: Context): AbortSignal;
|
|
66
|
-
private current;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=delivery-authority.d.ts.map
|