@dsmm/dsmm 0.3.0 → 0.3.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 +26 -40
- package/cordis.patch.yml +9 -13
- package/docs/agent-presets.md +26 -14
- package/docs/compatibility.md +24 -68
- 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 +25 -311
- package/docs/roadmap.md +52 -241
- 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 +12 -2
- package/lib/child-capture.js +22 -5
- package/lib/client/ChildPermissions.d.ts +43 -0
- package/lib/client/ChildPermissions.js +100 -0
- package/lib/client/ChildrenPanel.d.ts +5 -5
- package/lib/client/ChildrenPanel.js +6 -18
- package/lib/client/DeploymentFields.d.ts +32 -0
- package/lib/client/DeploymentFields.js +70 -0
- package/lib/client/DeploymentPage.d.ts +21 -6
- package/lib/client/DeploymentPage.js +80 -112
- package/lib/client/HistoryContinuation.d.ts +7 -0
- package/lib/client/HistoryContinuation.js +22 -0
- package/lib/client/NativeCommandEntries.d.ts +17 -0
- package/lib/client/NativeCommandEntries.js +68 -0
- package/lib/client/PermissionPanelEntry.d.ts +8 -0
- package/lib/client/PermissionPanelEntry.js +11 -0
- package/lib/client/PermissionsPanel.d.ts +3 -1
- package/lib/client/PermissionsPanel.js +10 -9
- package/lib/client/ProfilesSection.js +8 -6
- package/lib/client/RoleAvailability.js +1 -1
- 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 +51 -24
- package/lib/client/TemporaryPermissions.d.ts +21 -0
- package/lib/client/TemporaryPermissions.js +94 -0
- package/lib/client/children-controller.d.ts +2 -8
- package/lib/client/children-controller.js +1 -26
- package/lib/client/children-locales.d.ts +27 -52
- 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 +18 -0
- package/lib/client/controller.js +118 -28
- package/lib/client/deployment-controller.d.ts +13 -1
- package/lib/client/deployment-controller.js +84 -24
- 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 +45 -19
- 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/history-controller.d.ts +29 -0
- package/lib/client/history-controller.js +111 -0
- package/lib/client/history-entry.d.ts +11 -0
- package/lib/client/history-entry.js +106 -0
- package/lib/client/history-locales.d.ts +95 -0
- package/lib/client/history-locales.js +41 -0
- package/lib/client/index.js +26 -76
- package/lib/client/locales.d.ts +13 -0
- package/lib/client/locales.js +104 -86
- package/lib/client/permission-controller.d.ts +1 -0
- package/lib/client/permission-controller.js +3 -2
- package/lib/client/permission-locales.d.ts +51 -0
- package/lib/client/permission-locales.js +59 -19
- 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/temporary-permission-client.d.ts +20 -0
- package/lib/client/temporary-permission-client.js +52 -0
- package/lib/client/temporary-permission-entry.d.ts +6 -0
- package/lib/client/temporary-permission-entry.js +56 -0
- package/lib/client.js +5691 -3439
- 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/history-candidates.d.ts +30 -0
- package/lib/history-candidates.js +176 -0
- package/lib/history-codec.d.ts +11 -0
- package/lib/history-codec.js +102 -0
- package/lib/history-contract.d.ts +44 -0
- package/lib/history-contract.js +2 -0
- package/lib/history-controller.d.ts +42 -0
- package/lib/history-controller.js +329 -0
- package/lib/history-policy.d.ts +4 -0
- package/lib/history-policy.js +8 -0
- package/lib/history-remote.d.ts +28 -0
- package/lib/history-remote.js +17 -0
- package/lib/history-rpc.d.ts +24 -0
- package/lib/history-rpc.js +136 -0
- package/lib/history-support.d.ts +15 -0
- package/lib/history-support.js +21 -0
- package/lib/history-types.d.ts +67 -0
- package/lib/history-types.js +2 -0
- 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 +18 -20
- package/lib/index.js +147 -415
- 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 +77 -0
- package/lib/native-admission.js +503 -0
- package/lib/native-pi-ai-wire.d.ts +3 -1
- package/lib/native-pi-ai-wire.js +47 -13
- package/lib/permission-child-control.d.ts +36 -0
- package/lib/permission-child-control.js +164 -0
- package/lib/permission-control.d.ts +2 -3
- package/lib/permission-control.js +7 -0
- package/lib/permission-controller.js +2 -2
- package/lib/permission-exec-argv.d.ts +32 -0
- package/lib/permission-exec-argv.js +171 -0
- package/lib/permission-fs-search.js +2 -1
- package/lib/permission-fs.js +2 -1
- package/lib/permission-native-rules.js +3 -3
- package/lib/permission-temporary-files.d.ts +19 -0
- package/lib/permission-temporary-files.js +248 -0
- package/lib/permission-temporary-grants.d.ts +106 -0
- package/lib/permission-temporary-grants.js +198 -0
- package/lib/permission-temporary-install.d.ts +25 -0
- package/lib/permission-temporary-install.js +86 -0
- package/lib/permission-temporary-remote.d.ts +19 -0
- package/lib/permission-temporary-remote.js +75 -0
- package/lib/permission-temporary-rpc.d.ts +37 -0
- package/lib/permission-temporary-rpc.js +154 -0
- package/lib/permission-temporary-types.d.ts +47 -0
- package/lib/permission-temporary-types.js +2 -0
- package/lib/permission-temporary-web.d.ts +11 -0
- package/lib/permission-temporary-web.js +154 -0
- package/lib/permission-web.js +2 -1
- 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 +35 -37
- package/lib/profile-runtime.d.ts +42 -74
- package/lib/profile-runtime.js +314 -617
- package/lib/profile-store.d.ts +20 -8
- package/lib/profile-store.js +112 -63
- package/lib/profile-types.d.ts +19 -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 -269
- 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 +3 -3
- package/lib/role-invocation.js +2 -2
- package/lib/role-llm-runtime.js +5 -11
- package/lib/role-policy.d.ts +19 -50
- package/lib/role-policy.js +136 -508
- package/lib/role-providers.d.ts +5 -8
- package/lib/role-providers.js +20 -86
- 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 +163 -108
- package/lib/runtime-integration.d.ts +5 -78
- package/lib/runtime-integration.js +11 -697
- package/lib/session-metadata.d.ts +13 -12
- package/lib/session-metadata.js +6 -31
- package/lib/session-scope.js +2 -1
- package/lib/settings.d.ts +5 -18
- package/lib/settings.js +19 -43
- package/lib/skills.d.ts +1 -0
- package/lib/skills.js +5 -1
- 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 +124 -106
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
- package/patches/dsh-approval-settlement/README.md +41 -0
- package/patches/dsh-approval-settlement/metadata.json +10 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
- package/docs/research/deepseek-v4-pro.md +0 -74
- package/docs/research/oh-dsh.md +0 -96
- package/lib/agent-registry.d.ts +0 -36
- package/lib/agent-registry.js +0 -75
- package/lib/child-admission.d.ts +0 -40
- package/lib/child-admission.js +0 -151
- package/lib/delivery-authority.d.ts +0 -83
- package/lib/delivery-authority.js +0 -397
- package/lib/native-child-evidence.d.ts +0 -40
- package/lib/native-child-evidence.js +0 -104
- package/lib/role-runs.d.ts +0 -138
- package/lib/role-runs.js +0 -335
- package/lib/session-persistence.d.ts +0 -36
- package/lib/session-persistence.js +0 -304
- package/lib/subagent-runtime.d.ts +0 -57
- package/lib/subagent-runtime.js +0 -257
- package/prompts/deepseek-flash.md +0 -11
- package/prompts/deepseek-v4-pro.md +0 -14
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isNativeSessionId, isProfileId } from "./profile-remote.js";
|
|
2
|
+
const codes = ["validation", "not-owned", "not-found", "unsupported-host", "unsupported-backend", "unavailable", "busy", "stale", "cancelled", "authorization-required", "child-owner-required", "format-unavailable", "initialization-failed"];
|
|
3
|
+
function invalid() { throw new TypeError("Invalid history continuation request or response"); }
|
|
4
|
+
function object(input, required, optional = []) {
|
|
5
|
+
if (!input || typeof input !== "object" || Array.isArray(input)
|
|
6
|
+
|| ![Object.prototype, null].includes(Object.getPrototypeOf(input)) || Object.getOwnPropertySymbols(input).length
|
|
7
|
+
|| Object.values(Object.getOwnPropertyDescriptors(input)).some(row => !Object.hasOwn(row, "value") || !row.enumerable))
|
|
8
|
+
invalid();
|
|
9
|
+
const row = input;
|
|
10
|
+
if (required.some(key => !Object.hasOwn(row, key)) || Object.keys(row).some(key => !required.includes(key) && !optional.includes(key)))
|
|
11
|
+
invalid();
|
|
12
|
+
return row;
|
|
13
|
+
}
|
|
14
|
+
function text(input, maximum = 4096) { if (typeof input !== "string" || input.length > maximum)
|
|
15
|
+
invalid(); return input; }
|
|
16
|
+
function bool(input) { if (typeof input !== "boolean")
|
|
17
|
+
invalid(); return input; }
|
|
18
|
+
function list(input, parse) { if (!Array.isArray(input))
|
|
19
|
+
invalid(); return input.map(value => parse(value)); }
|
|
20
|
+
function code(input) { if (!codes.includes(input))
|
|
21
|
+
invalid(); return input; }
|
|
22
|
+
export function historySessionId(input) { if (!isNativeSessionId(input))
|
|
23
|
+
invalid(); return input; }
|
|
24
|
+
function intentId(input) { const id = text(input, 36); if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u.test(id))
|
|
25
|
+
invalid(); return id; }
|
|
26
|
+
function profileId(input) { if (input === null)
|
|
27
|
+
return null; if (!isProfileId(input))
|
|
28
|
+
invalid(); return input; }
|
|
29
|
+
function presetId(input) { return historySessionId(input); }
|
|
30
|
+
function choice(input) { const row = object(input, ["id", "label"]); return { id: text(row.id, 256), label: text(row.label, 120) }; }
|
|
31
|
+
export function historyJson(input, depth = 0, active = new Set()) {
|
|
32
|
+
if (depth > 32)
|
|
33
|
+
invalid();
|
|
34
|
+
if (input === null || typeof input === "boolean" || typeof input === "string")
|
|
35
|
+
return input;
|
|
36
|
+
if (typeof input === "number") {
|
|
37
|
+
if (!Number.isFinite(input))
|
|
38
|
+
invalid();
|
|
39
|
+
return input;
|
|
40
|
+
}
|
|
41
|
+
if (!input || typeof input !== "object")
|
|
42
|
+
invalid();
|
|
43
|
+
if (active.has(input))
|
|
44
|
+
invalid();
|
|
45
|
+
active.add(input);
|
|
46
|
+
try {
|
|
47
|
+
if (Array.isArray(input)) {
|
|
48
|
+
if (Object.getOwnPropertySymbols(input).length || Object.entries(Object.getOwnPropertyDescriptors(input)).some(([key, property]) => key !== "length" && (!/^(0|[1-9][0-9]*)$/u.test(key) || !Object.hasOwn(property, "value") || !property.enumerable)))
|
|
49
|
+
invalid();
|
|
50
|
+
return input.map(value => historyJson(value, depth + 1, active));
|
|
51
|
+
}
|
|
52
|
+
const row = object(input, Object.keys(input));
|
|
53
|
+
return Object.fromEntries(Object.entries(row).map(([key, value]) => [key, historyJson(value, depth + 1, active)]));
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
active.delete(input);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function parseHistoryFailure(input) {
|
|
60
|
+
const row = object(input, ["code", "storageEffects"]);
|
|
61
|
+
if (row.storageEffects !== "none" && row.storageEffects !== "may-have-committed")
|
|
62
|
+
invalid();
|
|
63
|
+
return { code: code(row.code), storageEffects: row.storageEffects };
|
|
64
|
+
}
|
|
65
|
+
export function parseHistoryStatus(input) {
|
|
66
|
+
const row = object(input, ["sessionId", "readable", "execution", "compatibleHost"], ["reason"]);
|
|
67
|
+
if (row.readable !== "readable" && row.readable !== "unavailable")
|
|
68
|
+
invalid();
|
|
69
|
+
if (!["authorization-required", "activating", "active", "unavailable"].includes(String(row.execution)))
|
|
70
|
+
invalid();
|
|
71
|
+
return { sessionId: historySessionId(row.sessionId), readable: row.readable, execution: row.execution, compatibleHost: bool(row.compatibleHost), ...(row.reason === undefined ? {} : { reason: code(row.reason) }) };
|
|
72
|
+
}
|
|
73
|
+
export function parseHistoryChoices(input) {
|
|
74
|
+
const row = object(input, ["presets", "profiles"]);
|
|
75
|
+
return { presets: list(row.presets, value => { const result = choice(value); presetId(result.id); return result; }), profiles: list(row.profiles, value => { const result = choice(value); profileId(result.id); return result; }) };
|
|
76
|
+
}
|
|
77
|
+
export function parseHistoryPreviewRequest(input) {
|
|
78
|
+
const row = object(input, ["sessionId", "preset", "profileId"]);
|
|
79
|
+
return { sessionId: historySessionId(row.sessionId), preset: presetId(row.preset), profileId: profileId(row.profileId) };
|
|
80
|
+
}
|
|
81
|
+
export function parseHistoryConfirmRequest(input) {
|
|
82
|
+
const row = object(input, ["sessionId", "intentId", "processPending", "acceptMigration"]);
|
|
83
|
+
return { sessionId: historySessionId(row.sessionId), intentId: intentId(row.intentId), processPending: bool(row.processPending), acceptMigration: bool(row.acceptMigration) };
|
|
84
|
+
}
|
|
85
|
+
function candidate(input) {
|
|
86
|
+
const row = object(input, ["preset", "profile", "model", "roles", "restrictions", "differences"]);
|
|
87
|
+
const model = object(row.model, ["provider", "model"], ["reasoningEffort"]);
|
|
88
|
+
return { preset: choice(row.preset), profile: row.profile === null ? null : choice(row.profile),
|
|
89
|
+
model: { provider: text(model.provider, 256), model: text(model.model, 256), ...(model.reasoningEffort === undefined ? {} : { reasoningEffort: text(model.reasoningEffort, 128) }) },
|
|
90
|
+
roles: list(row.roles, choice), restrictions: list(row.restrictions, value => text(value)), differences: list(row.differences, value => text(value)) };
|
|
91
|
+
}
|
|
92
|
+
export function parseHistoryPreview(input) {
|
|
93
|
+
const row = object(input, ["sessionId", "intentId", "cwd", "candidate", "migrationRequired", "pending"]), pending = object(row.pending, ["nextTurn", "nextStep"]);
|
|
94
|
+
return { sessionId: historySessionId(row.sessionId), intentId: intentId(row.intentId), cwd: text(row.cwd), candidate: candidate(row.candidate), migrationRequired: bool(row.migrationRequired), pending: { nextTurn: list(pending.nextTurn, historyJson), nextStep: list(pending.nextStep, historyJson) } };
|
|
95
|
+
}
|
|
96
|
+
export function parseHistoryResult(input) {
|
|
97
|
+
const row = object(input, ["sessionId", "execution"]);
|
|
98
|
+
if (row.execution !== "active")
|
|
99
|
+
invalid();
|
|
100
|
+
return { sessionId: historySessionId(row.sessionId), execution: "active" };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=history-codec.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Agent, ModelSelection } from "@deepseek-ai/dsh-agent";
|
|
2
|
+
import type { SessionInspection } from "@deepseek-ai/dsh-session-persistence";
|
|
3
|
+
import type { DsmmProfileAdmission } from "./settings.js";
|
|
4
|
+
import type { HistoryCandidateView, HistoryChoices, HistoryPreviewRequest } from "./history-types.js";
|
|
5
|
+
/** A current profile/preset/policy preparation, never reconstructed from old epochs or approvals. */
|
|
6
|
+
export interface HistoryCandidate {
|
|
7
|
+
readonly admission: DsmmProfileAdmission;
|
|
8
|
+
readonly view: HistoryCandidateView;
|
|
9
|
+
readonly model: ModelSelection;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
/** Re-read current configuration and availability without touching the historical log. */
|
|
12
|
+
revalidate(signal: AbortSignal): Promise<void>;
|
|
13
|
+
/** Synchronous revision/owner/policy fence, including across native created notifications. */
|
|
14
|
+
assertCurrent(): undefined;
|
|
15
|
+
/** Install current native restrictions in the unpublished Agent; registrations belong to that Agent. */
|
|
16
|
+
install(agent: Agent, signal: AbortSignal): Promise<void>;
|
|
17
|
+
/** Release preparation resources, not successfully installed Agent policy. */
|
|
18
|
+
dispose(): void | Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export interface HistoryCandidates {
|
|
21
|
+
readonly signal: AbortSignal;
|
|
22
|
+
checkCompatibility?(): Promise<void>;
|
|
23
|
+
choices(signal: AbortSignal): Promise<HistoryChoices>;
|
|
24
|
+
prepare(request: HistoryPreviewRequest, inspection: SessionInspection, signal: AbortSignal): Promise<HistoryCandidate>;
|
|
25
|
+
}
|
|
26
|
+
/** Existing NativeAdmission surface; the bridge adds no second admission owner. */
|
|
27
|
+
export interface HistoryNativeAdmission {
|
|
28
|
+
readonly lifetime: AbortController;
|
|
29
|
+
readonly isReady: boolean;
|
|
30
|
+
get(agent: Agent): DsmmProfileAdmission | undefined;
|
|
31
|
+
assert(agent: Agent): DsmmProfileAdmission;
|
|
32
|
+
}
|
|
33
|
+
/** Host-created identity. None of these fields is accepted from the wire. */
|
|
34
|
+
export interface HistoryOperator {
|
|
35
|
+
readonly peer: object;
|
|
36
|
+
readonly connection: object;
|
|
37
|
+
readonly peerSignal: AbortSignal;
|
|
38
|
+
readonly signal: AbortSignal;
|
|
39
|
+
assertCurrent(): void;
|
|
40
|
+
/** Does not retain a completed preview RPC's cancellation signal. */
|
|
41
|
+
assertOwner(): void;
|
|
42
|
+
assertVisible(sessionId: string): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=history-contract.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
4
|
+
import type { DsmmProfileAdmission } from "./settings.js";
|
|
5
|
+
import type { HistoryCandidates, HistoryNativeAdmission, HistoryOperator } from "./history-contract.js";
|
|
6
|
+
import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryFailure, HistoryFailureCode, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
|
|
7
|
+
export declare class HistoryRefusal extends Error {
|
|
8
|
+
readonly code: HistoryFailureCode;
|
|
9
|
+
readonly storageEffects: HistoryFailure["storageEffects"];
|
|
10
|
+
constructor(code: HistoryFailureCode, storageEffects?: HistoryFailure["storageEffects"]);
|
|
11
|
+
}
|
|
12
|
+
/** Host-only one-operation intents around the native history and activation APIs. */
|
|
13
|
+
export declare class HistoryContinuations extends Service {
|
|
14
|
+
private readonly candidates;
|
|
15
|
+
private readonly admission;
|
|
16
|
+
readonly lifetime: AbortController;
|
|
17
|
+
private readonly intents;
|
|
18
|
+
private readonly prepared;
|
|
19
|
+
private guardedLoop;
|
|
20
|
+
private readonly cleanups;
|
|
21
|
+
constructor(ctx: Context, candidates: HistoryCandidates, admission: HistoryNativeAdmission);
|
|
22
|
+
private compatibility;
|
|
23
|
+
private visible;
|
|
24
|
+
private ready;
|
|
25
|
+
private compatible;
|
|
26
|
+
describe(input: string, operator: HistoryOperator): Promise<HistoryStatus>;
|
|
27
|
+
choices(operator: HistoryOperator): Promise<HistoryChoices>;
|
|
28
|
+
preview(input: HistoryPreviewRequest, operator: HistoryOperator): Promise<HistoryPreview>;
|
|
29
|
+
private check;
|
|
30
|
+
/** Called only by NativeAdmission.created for the exact unpublished continuation candidate. */
|
|
31
|
+
admissionForCreated(agent: Agent): DsmmProfileAdmission | undefined;
|
|
32
|
+
private authorize;
|
|
33
|
+
confirm(input: HistoryConfirmRequest, operator: HistoryOperator): Promise<HistoryContinuationResult>;
|
|
34
|
+
private release;
|
|
35
|
+
}
|
|
36
|
+
declare module "@deepseek-ai/cordis" {
|
|
37
|
+
interface Context {
|
|
38
|
+
dsmmHistoryContinuation: HistoryContinuations;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export declare function historyFailure(error: unknown): HistoryFailure;
|
|
42
|
+
//# sourceMappingURL=history-controller.d.ts.map
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { Service, symbols } from "@deepseek-ai/cordis";
|
|
4
|
+
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
5
|
+
import { scopeLifetime } from "./lifetime.js";
|
|
6
|
+
import { historyJson, historySessionId, parseHistoryChoices, parseHistoryConfirmRequest, parseHistoryPreview, parseHistoryPreviewRequest } from "./history-codec.js";
|
|
7
|
+
export class HistoryRefusal extends Error {
|
|
8
|
+
code;
|
|
9
|
+
storageEffects;
|
|
10
|
+
constructor(code, storageEffects = "none") {
|
|
11
|
+
super(`History continuation refused: ${code}`);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.storageEffects = storageEffects;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function original(value) { return Reflect.get(value, symbols.original) ?? value; }
|
|
17
|
+
/** Host-only one-operation intents around the native history and activation APIs. */
|
|
18
|
+
export class HistoryContinuations extends Service {
|
|
19
|
+
candidates;
|
|
20
|
+
admission;
|
|
21
|
+
lifetime = new AbortController();
|
|
22
|
+
intents = new Map();
|
|
23
|
+
prepared = new WeakMap();
|
|
24
|
+
guardedLoop;
|
|
25
|
+
cleanups = new Set();
|
|
26
|
+
constructor(ctx, candidates, admission) {
|
|
27
|
+
super(ctx, "dsmmHistoryContinuation");
|
|
28
|
+
this.candidates = candidates;
|
|
29
|
+
this.admission = admission;
|
|
30
|
+
ctx.effect(() => async () => { await Promise.all(this.cleanups); }, "dsmm: release history preparations");
|
|
31
|
+
const loop = ctx.get("agentLoop");
|
|
32
|
+
if (typeof loop?.requireActivationAdmission === "function" && typeof loop.registerActivationGuard === "function") {
|
|
33
|
+
loop.requireActivationAdmission();
|
|
34
|
+
ctx.effect(() => {
|
|
35
|
+
const remove = loop.registerActivationGuard(request => this.authorize(request));
|
|
36
|
+
this.guardedLoop = original(loop);
|
|
37
|
+
return () => { this.guardedLoop = undefined; remove(); };
|
|
38
|
+
}, "dsmm: history activation admission");
|
|
39
|
+
}
|
|
40
|
+
const controller = ctx.get("sessionController");
|
|
41
|
+
if (typeof controller?.registerHistoryOpenGuard === "function") {
|
|
42
|
+
const owner = original(controller);
|
|
43
|
+
ctx.effect(() => controller.registerHistoryOpenGuard({
|
|
44
|
+
signal: AbortSignal.any([this.lifetime.signal, admission.lifetime.signal, candidates.signal]),
|
|
45
|
+
assertCurrent: () => {
|
|
46
|
+
this.ready();
|
|
47
|
+
if (original(this.ctx.sessionController) !== owner)
|
|
48
|
+
throw new HistoryRefusal("unsupported-host");
|
|
49
|
+
},
|
|
50
|
+
}), "dsmm: history opening readiness");
|
|
51
|
+
}
|
|
52
|
+
scopeLifetime(ctx, "dsmm: revoke history intents", () => {
|
|
53
|
+
this.lifetime.abort();
|
|
54
|
+
for (const intent of this.intents.values()) {
|
|
55
|
+
try {
|
|
56
|
+
this.release(intent);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
ctx.logger.error(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
compatibility() {
|
|
65
|
+
const loop = this.ctx.get("agentLoop"), controller = this.ctx.get("sessionController");
|
|
66
|
+
if (typeof loop?.registerActivationGuard !== "function" || this.guardedLoop === undefined || original(loop) !== original(this.guardedLoop) || typeof loop.activationState !== "function"
|
|
67
|
+
|| typeof controller?.activateSession !== "function" || controller.activateOnFollow !== false)
|
|
68
|
+
return "unsupported-host";
|
|
69
|
+
if (this.ctx.get("sessionPersistence")?.writeAdmission?.lockedInspection !== 1)
|
|
70
|
+
return "unsupported-backend";
|
|
71
|
+
if (!this.admission.isReady || this.admission.lifetime.signal.aborted || this.candidates.signal.aborted || this.lifetime.signal.aborted)
|
|
72
|
+
return "unavailable";
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
visible(id, operator) {
|
|
76
|
+
operator.assertCurrent();
|
|
77
|
+
operator.assertVisible(id);
|
|
78
|
+
}
|
|
79
|
+
ready() { const reason = this.compatibility(); if (reason)
|
|
80
|
+
throw new HistoryRefusal(reason); }
|
|
81
|
+
async compatible() {
|
|
82
|
+
const reason = this.compatibility();
|
|
83
|
+
if (reason)
|
|
84
|
+
return reason;
|
|
85
|
+
try {
|
|
86
|
+
await this.candidates.checkCompatibility?.();
|
|
87
|
+
return this.compatibility();
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return historyFailure(error).code;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async describe(input, operator) {
|
|
94
|
+
const sessionId = historySessionId(input);
|
|
95
|
+
this.visible(sessionId, operator);
|
|
96
|
+
const reason = await this.compatible();
|
|
97
|
+
let child = false;
|
|
98
|
+
try {
|
|
99
|
+
const observation = await this.ctx.sessionQuery.observeSession(SessionId(sessionId), { signal: operator.signal, projectionMode: "none" });
|
|
100
|
+
try {
|
|
101
|
+
child = observation.header.origin === "subagent";
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
observation[Symbol.dispose]();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
this.visible(sessionId, operator);
|
|
109
|
+
return { sessionId, readable: "unavailable", execution: "unavailable", compatibleHost: reason !== "unsupported-host", reason: reason ?? "format-unavailable" };
|
|
110
|
+
}
|
|
111
|
+
this.visible(sessionId, operator);
|
|
112
|
+
if (reason || child)
|
|
113
|
+
return { sessionId, readable: "readable", execution: "unavailable", compatibleHost: reason !== "unsupported-host", reason: reason ?? "child-owner-required" };
|
|
114
|
+
const state = this.ctx.agentLoop.activationState(SessionId(sessionId));
|
|
115
|
+
const live = this.ctx.agents.get(SessionId(sessionId));
|
|
116
|
+
return { sessionId, readable: "readable", compatibleHost: true,
|
|
117
|
+
execution: state?.phase === "initializing" || [...this.intents.values()].some(intent => intent.request.sessionId === sessionId && intent.operation !== undefined) ? "activating"
|
|
118
|
+
: live && this.admission.get(live) ? "active" : live ? "unavailable" : "authorization-required", ...(live && !this.admission.get(live) ? { reason: "unavailable" } : {}) };
|
|
119
|
+
}
|
|
120
|
+
async choices(operator) {
|
|
121
|
+
operator.assertCurrent();
|
|
122
|
+
this.ready();
|
|
123
|
+
await this.candidates.checkCompatibility?.();
|
|
124
|
+
operator.assertCurrent();
|
|
125
|
+
this.ready();
|
|
126
|
+
const result = await this.candidates.choices(operator.signal);
|
|
127
|
+
operator.assertCurrent();
|
|
128
|
+
this.ready();
|
|
129
|
+
return parseHistoryChoices(result);
|
|
130
|
+
}
|
|
131
|
+
async preview(input, operator) {
|
|
132
|
+
const request = parseHistoryPreviewRequest(input), sessionId = SessionId(request.sessionId);
|
|
133
|
+
this.visible(sessionId, operator);
|
|
134
|
+
this.ready();
|
|
135
|
+
await this.candidates.checkCompatibility?.();
|
|
136
|
+
this.visible(sessionId, operator);
|
|
137
|
+
this.ready();
|
|
138
|
+
if (this.ctx.agents.get(sessionId) || this.ctx.agentLoop.activationState(sessionId))
|
|
139
|
+
throw new HistoryRefusal("busy");
|
|
140
|
+
const persistence = this.ctx.sessionPersistence, controller = this.ctx.sessionController;
|
|
141
|
+
const stat = await persistence.stat(sessionId, { signal: operator.signal });
|
|
142
|
+
this.visible(sessionId, operator);
|
|
143
|
+
this.ready();
|
|
144
|
+
if (!stat)
|
|
145
|
+
throw new HistoryRefusal("not-found");
|
|
146
|
+
const observation = await this.ctx.sessionQuery.observeSession(sessionId, { signal: operator.signal, projectionMode: "all" });
|
|
147
|
+
let inspection, pending;
|
|
148
|
+
try {
|
|
149
|
+
if (observation.source !== "prepared")
|
|
150
|
+
throw new HistoryRefusal("busy");
|
|
151
|
+
if (observation.header.origin === "subagent")
|
|
152
|
+
throw new HistoryRefusal("child-owner-required");
|
|
153
|
+
if (!observation.header.cwd)
|
|
154
|
+
throw new HistoryRefusal("unavailable");
|
|
155
|
+
const inbox = observation.projections?.values.inbox;
|
|
156
|
+
if (!inbox)
|
|
157
|
+
throw new HistoryRefusal("unsupported-host");
|
|
158
|
+
inspection = structuredClone({ meta: observation.header, inheritedEventCount: observation.inheritedEventCount, events: [...observation.events] });
|
|
159
|
+
pending = { nextTurn: inbox["next-turn"].map(value => historyJson(value)), nextStep: inbox["next-step"].map(value => historyJson(value)) };
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
observation[Symbol.dispose]();
|
|
163
|
+
}
|
|
164
|
+
this.visible(sessionId, operator);
|
|
165
|
+
this.ready();
|
|
166
|
+
const candidate = await this.candidates.prepare(Object.freeze(request), structuredClone(inspection), operator.signal);
|
|
167
|
+
let intent;
|
|
168
|
+
try {
|
|
169
|
+
this.visible(sessionId, operator);
|
|
170
|
+
this.ready();
|
|
171
|
+
candidate.assertCurrent();
|
|
172
|
+
if (candidate.view.preset.id !== request.preset || (candidate.view.profile?.id ?? null) !== request.profileId
|
|
173
|
+
|| !isDeepStrictEqual(candidate.view.model, candidate.model))
|
|
174
|
+
throw new HistoryRefusal("stale");
|
|
175
|
+
for (const previous of this.intents.values())
|
|
176
|
+
if (previous.operator.peer === operator.peer && previous.request.sessionId === sessionId) {
|
|
177
|
+
if (previous.operation)
|
|
178
|
+
throw new HistoryRefusal("busy");
|
|
179
|
+
this.release(previous);
|
|
180
|
+
}
|
|
181
|
+
const abort = new AbortController();
|
|
182
|
+
const signal = AbortSignal.any([abort.signal, operator.peerSignal, this.lifetime.signal, this.admission.lifetime.signal, this.candidates.signal, candidate.signal]);
|
|
183
|
+
const expired = () => { if (intent && !intent.operation)
|
|
184
|
+
this.release(intent); };
|
|
185
|
+
intent = { id: randomUUID(), request, operator, inspection, persistence, persistenceIdentity: persistence.identity, controller, candidate, view: structuredClone(candidate.view), model: structuredClone(candidate.model), migrationRequired: stat.formatStatus === "migration-required", signal, abort,
|
|
186
|
+
detach: () => signal.removeEventListener("abort", expired), effects: "none" };
|
|
187
|
+
this.intents.set(intent.id, intent);
|
|
188
|
+
signal.addEventListener("abort", expired, { once: true });
|
|
189
|
+
this.check(intent);
|
|
190
|
+
return parseHistoryPreview({ sessionId, intentId: intent.id, cwd: inspection.meta.cwd, candidate: intent.view, migrationRequired: intent.migrationRequired, pending });
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (intent)
|
|
194
|
+
this.release(intent);
|
|
195
|
+
else
|
|
196
|
+
await candidate.dispose();
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
check(intent) {
|
|
201
|
+
if (intent.signal.aborted)
|
|
202
|
+
throw new HistoryRefusal("cancelled", intent.effects);
|
|
203
|
+
intent.operator.assertOwner();
|
|
204
|
+
this.ready();
|
|
205
|
+
if (this.intents.get(intent.id) !== intent || original(this.ctx.sessionPersistence) !== original(intent.persistence) || this.ctx.sessionPersistence.identity !== intent.persistenceIdentity
|
|
206
|
+
|| original(this.ctx.sessionController) !== original(intent.controller))
|
|
207
|
+
throw new HistoryRefusal("stale", intent.effects);
|
|
208
|
+
intent.operator.assertVisible(intent.request.sessionId);
|
|
209
|
+
if (!isDeepStrictEqual(intent.candidate.view, intent.view) || !isDeepStrictEqual(intent.candidate.model, intent.model))
|
|
210
|
+
throw new HistoryRefusal("stale", intent.effects);
|
|
211
|
+
intent.candidate.assertCurrent();
|
|
212
|
+
}
|
|
213
|
+
/** Called only by NativeAdmission.created for the exact unpublished continuation candidate. */
|
|
214
|
+
admissionForCreated(agent) {
|
|
215
|
+
const intent = this.prepared.get(agent);
|
|
216
|
+
if (!intent)
|
|
217
|
+
return undefined;
|
|
218
|
+
this.check(intent);
|
|
219
|
+
if (intent.agent !== agent || agent.id !== intent.request.sessionId || agent.session.header.origin === "subagent")
|
|
220
|
+
throw new HistoryRefusal("not-owned", intent.effects);
|
|
221
|
+
return intent.candidate.admission;
|
|
222
|
+
}
|
|
223
|
+
authorize(request) {
|
|
224
|
+
const intent = [...this.intents.values()].find(row => row.options === request.options);
|
|
225
|
+
if (!intent || request.parentAgent || !request.processPending || request.sessionId !== intent.request.sessionId || request.setup !== intent.options?.setup
|
|
226
|
+
|| original(request.persistence) !== original(intent.persistence) || request.persistence.identity !== intent.persistenceIdentity || original(request.owner.fiber) !== intent.nativeOwner)
|
|
227
|
+
throw new HistoryRefusal("authorization-required");
|
|
228
|
+
const check = () => { request.signal.throwIfAborted(); this.check(intent); };
|
|
229
|
+
check();
|
|
230
|
+
return {
|
|
231
|
+
assertCurrent: check,
|
|
232
|
+
validateLoaded: loaded => {
|
|
233
|
+
check();
|
|
234
|
+
if (!isDeepStrictEqual({ meta: loaded.meta, inheritedEventCount: loaded.inheritedEventCount, events: loaded.events }, intent.inspection)
|
|
235
|
+
|| loaded.migrationRequired !== intent.migrationRequired)
|
|
236
|
+
throw new HistoryRefusal("stale");
|
|
237
|
+
intent.effects = "may-have-committed";
|
|
238
|
+
},
|
|
239
|
+
validatePublish: agent => {
|
|
240
|
+
check();
|
|
241
|
+
if (this.prepared.get(agent) !== intent || intent.agent !== agent)
|
|
242
|
+
throw new HistoryRefusal("not-owned", intent.effects);
|
|
243
|
+
if (this.ctx.agents.get(agent.id) === agent && this.admission.assert(agent) !== intent.candidate.admission)
|
|
244
|
+
throw new HistoryRefusal("stale", intent.effects);
|
|
245
|
+
},
|
|
246
|
+
dispose() { },
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
confirm(input, operator) {
|
|
250
|
+
const request = parseHistoryConfirmRequest(input), intent = this.intents.get(request.intentId);
|
|
251
|
+
this.visible(request.sessionId, operator);
|
|
252
|
+
this.ready();
|
|
253
|
+
if (!intent || intent.request.sessionId !== request.sessionId || intent.operator.peer !== operator.peer || intent.operator.connection !== operator.connection)
|
|
254
|
+
throw new HistoryRefusal("authorization-required");
|
|
255
|
+
try {
|
|
256
|
+
this.check(intent);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (!intent.operation)
|
|
260
|
+
this.release(intent);
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
if (!request.processPending || intent.migrationRequired && !request.acceptMigration)
|
|
264
|
+
throw new HistoryRefusal("authorization-required");
|
|
265
|
+
if (intent.operation)
|
|
266
|
+
return intent.operation;
|
|
267
|
+
const signal = AbortSignal.any([operator.signal, intent.signal]);
|
|
268
|
+
const operation = (async () => {
|
|
269
|
+
let committed = false;
|
|
270
|
+
try {
|
|
271
|
+
await intent.candidate.revalidate(signal);
|
|
272
|
+
operator.assertCurrent();
|
|
273
|
+
this.check(intent);
|
|
274
|
+
const activation = {
|
|
275
|
+
sessionId: SessionId(request.sessionId), agentPreset: intent.request.preset, modelSelection: intent.model,
|
|
276
|
+
agentOptions: { provider: intent.model.provider, model: intent.model.model }, signal, processPending: true,
|
|
277
|
+
authorize: (options, owner) => { operator.assertCurrent(); this.check(intent); intent.options = options; intent.nativeOwner = original(owner.fiber); },
|
|
278
|
+
setup: async (_ctx, agent) => {
|
|
279
|
+
operator.assertCurrent();
|
|
280
|
+
this.check(intent);
|
|
281
|
+
intent.agent = agent;
|
|
282
|
+
this.prepared.set(agent, intent);
|
|
283
|
+
await intent.candidate.install(agent, signal);
|
|
284
|
+
operator.assertCurrent();
|
|
285
|
+
this.check(intent);
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
await intent.controller.activateSession(activation);
|
|
289
|
+
committed = true;
|
|
290
|
+
return { sessionId: request.sessionId, execution: "active" };
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
throw new HistoryRefusal(historyFailure(error).code, intent.effects);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
this.release(intent, !committed);
|
|
297
|
+
}
|
|
298
|
+
})();
|
|
299
|
+
intent.operation = operation;
|
|
300
|
+
return operation;
|
|
301
|
+
}
|
|
302
|
+
release(intent, abort = true) {
|
|
303
|
+
if (this.intents.get(intent.id) !== intent)
|
|
304
|
+
return;
|
|
305
|
+
this.intents.delete(intent.id);
|
|
306
|
+
intent.detach();
|
|
307
|
+
if (abort)
|
|
308
|
+
intent.abort.abort();
|
|
309
|
+
if (intent.agent)
|
|
310
|
+
this.prepared.delete(intent.agent);
|
|
311
|
+
const result = intent.candidate.dispose();
|
|
312
|
+
if (result) {
|
|
313
|
+
const cleanup = Promise.resolve(result);
|
|
314
|
+
this.cleanups.add(cleanup);
|
|
315
|
+
void cleanup.then(() => this.cleanups.delete(cleanup), error => { this.ctx.logger.error(error); this.cleanups.delete(cleanup); });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
export function historyFailure(error) {
|
|
320
|
+
if (error instanceof HistoryRefusal)
|
|
321
|
+
return { code: error.code, storageEffects: error.storageEffects };
|
|
322
|
+
if (error instanceof TypeError)
|
|
323
|
+
return { code: "validation", storageEffects: "none" };
|
|
324
|
+
const category = error && typeof error === "object" ? Reflect.get(error, "category") : undefined;
|
|
325
|
+
const code = category === "initializing" ? "busy" : category === "stale" || category === "cancelled" || category === "unsupported-backend" || category === "authorization-required" ? category
|
|
326
|
+
: error instanceof Error && error.name === "SessionAlreadyOwnedError" ? "busy" : error instanceof Error && error.name === "AbortError" ? "cancelled" : "initialization-failed";
|
|
327
|
+
return { code, storageEffects: "none" };
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=history-controller.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DsmmGitWritePolicy, DsmmSettings } from "./settings.js";
|
|
2
|
+
/** The DSMM Git guard for the candidate's effective mode, not a grant from other policy layers. */
|
|
3
|
+
export declare function effectiveHistoryGitWriteGuard(settings: DsmmSettings, nativeFullAccess: boolean, deepworkActive: boolean): DsmmGitWritePolicy;
|
|
4
|
+
//# sourceMappingURL=history-policy.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The DSMM Git guard for the candidate's effective mode, not a grant from other policy layers. */
|
|
2
|
+
export function effectiveHistoryGitWriteGuard(settings, nativeFullAccess, deepworkActive) {
|
|
3
|
+
const inScope = settings.guards.scope === "always" || settings.guards.scope !== "off" && deepworkActive;
|
|
4
|
+
if (!inScope || nativeFullAccess && settings.guards.gitWriteGuard !== "deny")
|
|
5
|
+
return "off";
|
|
6
|
+
return settings.guards.gitWriteGuard;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=history-policy.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
+
import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryFailure, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
|
|
4
|
+
import { parseHistoryFailure } from "./history-codec.js";
|
|
5
|
+
export interface DsmmHistoryRemote {
|
|
6
|
+
describe(sessionId: string): Promise<RemoteResult<HistoryStatus>>;
|
|
7
|
+
choices(): Promise<RemoteResult<HistoryChoices>>;
|
|
8
|
+
preview(sessionId: string, request: HistoryPreviewRequest): Promise<RemoteResult<HistoryPreview>>;
|
|
9
|
+
confirm(sessionId: string, request: HistoryConfirmRequest): Promise<RemoteResult<HistoryContinuationResult>>;
|
|
10
|
+
}
|
|
11
|
+
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
12
|
+
interface TypertRemoteMap {
|
|
13
|
+
"dsmmHistory/describe": DsmmHistoryRemote["describe"];
|
|
14
|
+
"dsmmHistory/choices": DsmmHistoryRemote["choices"];
|
|
15
|
+
"dsmmHistory/preview": DsmmHistoryRemote["preview"];
|
|
16
|
+
"dsmmHistory/confirm": DsmmHistoryRemote["confirm"];
|
|
17
|
+
}
|
|
18
|
+
interface TypertRemoteNamespaceMap {
|
|
19
|
+
dsmmHistory: DsmmHistoryRemote;
|
|
20
|
+
}
|
|
21
|
+
interface RemoteErrorDetailsMap {
|
|
22
|
+
"dsmm-history/refused": HistoryFailure;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export declare const HISTORY_REMOTE: TypertRemoteContribution;
|
|
26
|
+
export declare const HISTORY_HOST: TypertContribution;
|
|
27
|
+
export { parseHistoryFailure };
|
|
28
|
+
//# sourceMappingURL=history-remote.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { historyJson, historySessionId, parseHistoryChoices, parseHistoryConfirmRequest, parseHistoryFailure, parseHistoryPreview, parseHistoryPreviewRequest, parseHistoryResult, parseHistoryStatus } from "./history-codec.js";
|
|
2
|
+
function codec(name, parse) {
|
|
3
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${name}`, create: () => ({ parse: value => parse(historyJson(value)) }) };
|
|
4
|
+
}
|
|
5
|
+
function descriptor(method, result, request, session = true) {
|
|
6
|
+
return { id: `@dsmm/dsmm-history#dsmmHistory/${method}`, service: "dsmmHistory", namespace: "dsmmHistory", method, invocation: { kind: "direct" },
|
|
7
|
+
parameters: [...session ? [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("HistorySessionId", historySessionId) }] : [], ...request ? [{ name: "request", wire: "request", source: "json", codec: request }] : []], result };
|
|
8
|
+
}
|
|
9
|
+
export const HISTORY_REMOTE = { package: "@dsmm/dsmm-history", descriptors: [
|
|
10
|
+
descriptor("describe", codec("HistoryStatus", parseHistoryStatus)),
|
|
11
|
+
descriptor("choices", codec("HistoryChoices", parseHistoryChoices), undefined, false),
|
|
12
|
+
descriptor("preview", codec("HistoryPreview", parseHistoryPreview), codec("HistoryPreviewRequest", parseHistoryPreviewRequest)),
|
|
13
|
+
descriptor("confirm", codec("HistoryContinuationResult", parseHistoryResult), codec("HistoryConfirmRequest", parseHistoryConfirmRequest)),
|
|
14
|
+
] };
|
|
15
|
+
export const HISTORY_HOST = { package: HISTORY_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: HISTORY_REMOTE.descriptors };
|
|
16
|
+
export { parseHistoryFailure };
|
|
17
|
+
//# sourceMappingURL=history-remote.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
+
import { HistoryContinuations } from "./history-controller.js";
|
|
4
|
+
import type { HistoryCandidates, HistoryNativeAdmission } from "./history-contract.js";
|
|
5
|
+
import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
|
|
6
|
+
/** Native authenticated local-operator RPC; browser payloads carry no admission authority. */
|
|
7
|
+
export declare class DsmmHistoryHost extends TypertRemoteService {
|
|
8
|
+
private readonly history;
|
|
9
|
+
private readonly lifetime;
|
|
10
|
+
constructor(ctx: Context, history: HistoryContinuations);
|
|
11
|
+
private operator;
|
|
12
|
+
private invoke;
|
|
13
|
+
describe(sessionId: string): Promise<HistoryStatus>;
|
|
14
|
+
choices(): Promise<HistoryChoices>;
|
|
15
|
+
preview(sessionId: string, input: HistoryPreviewRequest): Promise<HistoryPreview>;
|
|
16
|
+
confirm(sessionId: string, input: HistoryConfirmRequest): Promise<HistoryContinuationResult>;
|
|
17
|
+
}
|
|
18
|
+
declare module "@deepseek-ai/cordis" {
|
|
19
|
+
interface Context {
|
|
20
|
+
dsmmHistory: DsmmHistoryHost;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare function registerHistoryContinuationRpc(ctx: Context, candidates: HistoryCandidates, admission: HistoryNativeAdmission): DsmmHistoryHost;
|
|
24
|
+
//# sourceMappingURL=history-rpc.d.ts.map
|