@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
package/lib/commands.js
CHANGED
|
@@ -8,6 +8,8 @@ export function parseDeepworkCommandInput(rawInput) {
|
|
|
8
8
|
}
|
|
9
9
|
async function handleDeepworkCommand(controller, getSettings, invocation) {
|
|
10
10
|
const parsed = parseDeepworkCommandInput(invocation.rawInput);
|
|
11
|
+
if (parsed.action === "on" && getSettings.subagentRuntime !== undefined && !getSettings.subagentRuntime().deliveryFenceReady)
|
|
12
|
+
return { kind: "error", text: "Deepwork runtime is unavailable; check native runtime settings and restart status." };
|
|
11
13
|
if (parsed.action === "on" && !getSettings(invocation.agent).modules.deepwork.enabled)
|
|
12
14
|
return { kind: "error", text: "Deepwork module is not admitted in this session; mode cannot enable it." };
|
|
13
15
|
await controller.select(invocation.agent, parsed.action === "on", getSettings(invocation.agent).defaultActive);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProfileStoreOptions } from "./profile-store.js";
|
|
2
2
|
export declare const MAX_CONFIG_FILE_BYTES = 65536;
|
|
3
3
|
export interface ConfigFileReadResult {
|
|
4
|
+
refreshRequired?: true;
|
|
4
5
|
content: string | null;
|
|
5
6
|
revision: string;
|
|
6
7
|
}
|
|
@@ -12,11 +13,13 @@ export declare class FixedConfigFileStore {
|
|
|
12
13
|
private readonly timeoutMs;
|
|
13
14
|
private readonly pollMs;
|
|
14
15
|
private readonly rename;
|
|
16
|
+
private readonly observe?;
|
|
15
17
|
constructor(home: string, options?: ProfileStoreOptions);
|
|
16
18
|
read(): ConfigFileReadResult;
|
|
17
19
|
save(content: string, expectedRevision: string, assertCurrent?: () => void): Promise<{
|
|
18
20
|
content: string;
|
|
19
21
|
revision: string;
|
|
22
|
+
refreshRequired?: true;
|
|
20
23
|
}>;
|
|
21
24
|
private validateRoot;
|
|
22
25
|
}
|
package/lib/config-file-store.js
CHANGED
|
@@ -11,12 +11,14 @@ export class FixedConfigFileStore {
|
|
|
11
11
|
timeoutMs;
|
|
12
12
|
pollMs;
|
|
13
13
|
rename;
|
|
14
|
+
observe;
|
|
14
15
|
constructor(home, options = {}) {
|
|
15
16
|
this.directory = join(files.trustedHome(home), "plugins", "dsmm");
|
|
16
17
|
this.path = join(this.directory, "config.json");
|
|
17
18
|
this.timeoutMs = files.boundedOption(options.lockTimeoutMs, 2000, 0, 30000);
|
|
18
19
|
this.pollMs = files.boundedOption(options.lockPollMs, 25, 1, 1000);
|
|
19
20
|
this.rename = options.rename ?? renameSync;
|
|
21
|
+
this.observe = options.observe;
|
|
20
22
|
this.validateRoot(false);
|
|
21
23
|
}
|
|
22
24
|
read() {
|
|
@@ -56,8 +58,8 @@ export class FixedConfigFileStore {
|
|
|
56
58
|
throw new DsmmProfileError("conflict", "Global configuration changed. Refresh before saving; existing bytes were retained.");
|
|
57
59
|
};
|
|
58
60
|
recheck();
|
|
59
|
-
files.atomicReplace(this.path, bytes, recheck, assertLock, this.rename, assertCurrent);
|
|
60
|
-
return { content,
|
|
61
|
+
const owned = files.atomicReplace(this.path, bytes, recheck, assertLock, this.rename, assertCurrent);
|
|
62
|
+
return { content, ...files.observeCommitted(this.path, owned, this.observe) };
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
validateRoot(create) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Configuration versions are metadata markers, not content-integrity proofs. */
|
|
2
|
+
export declare function isConfigRevision(value: unknown): value is string;
|
|
3
|
+
/** Immutable snapshot references are bounded path components, including historical IDs. */
|
|
4
|
+
export declare function isProfileReference(value: unknown): value is string;
|
|
5
|
+
//# sourceMappingURL=config-revision.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Configuration versions are metadata markers, not content-integrity proofs. */
|
|
2
|
+
export function isConfigRevision(value) {
|
|
3
|
+
return typeof value === "string" && (/^[a-f0-9]{64}$/u.test(value)
|
|
4
|
+
|| /^stat-v1--?\d{1,24}--?\d{1,24}$/u.test(value));
|
|
5
|
+
}
|
|
6
|
+
/** Immutable snapshot references are bounded path components, including historical IDs. */
|
|
7
|
+
export function isProfileReference(value) {
|
|
8
|
+
return typeof value === "string" && (/^[a-f0-9]{64}$/u.test(value)
|
|
9
|
+
|| /^snapshot-v1-[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u.test(value));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=config-revision.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { scopeLifetime } from "./
|
|
2
|
+
import { scopeLifetime } from "./lifetime.js";
|
|
3
3
|
import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
|
|
4
|
-
import { capturedRoleInvocation } from "./role-invocation.js";
|
|
5
|
-
import { RoleRunHolder } from "./role-runs.js";
|
|
6
4
|
import { DSMM_ROLES } from "./roles.js";
|
|
7
5
|
import { classifyDsmmAgent } from "./runtime-integration.js";
|
|
8
6
|
function sameFacts(a, b) {
|
|
@@ -23,7 +21,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
23
21
|
const integration = () => {
|
|
24
22
|
if (lifetimeSignal.aborted)
|
|
25
23
|
throw new PermissionRefusal("cancelled");
|
|
26
|
-
return ctx.get("
|
|
24
|
+
return ctx.get("dsmmNativeAdmission");
|
|
27
25
|
};
|
|
28
26
|
/** Registry ownership is direct, so each physical edge must be walked independently. */
|
|
29
27
|
const ancestry = (exec) => {
|
|
@@ -83,7 +81,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
83
81
|
if (managed && host === undefined)
|
|
84
82
|
throw new PermissionRefusal("unavailable");
|
|
85
83
|
const entry = managed ? permissionOriginal(host) : undefined;
|
|
86
|
-
const owner = managed ? host
|
|
84
|
+
const owner = managed ? host : coreOwner;
|
|
87
85
|
const facts = [root, agent.ctx, parent?.authority.signal, permissionOriginal(ctx.get("dsmmCoreLlmOwner")),
|
|
88
86
|
permissionOriginal(ctx.get("dsmmProfileRuntime")), permissionOriginal(tools),
|
|
89
87
|
approval === undefined ? undefined : permissionOriginal(approval),
|
|
@@ -91,22 +89,18 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
91
89
|
JSON.stringify(identity?.toolFilter)];
|
|
92
90
|
if (previous !== undefined && !previous.authority.signal.aborted && previous.integration === entry
|
|
93
91
|
&& previous.authority.owner === owner && previous.admission === admission && sameFacts(previous.facts, facts)) {
|
|
94
|
-
if (
|
|
95
|
-
host.
|
|
92
|
+
if (managed)
|
|
93
|
+
host.assert(agent);
|
|
96
94
|
return previous;
|
|
97
95
|
}
|
|
98
96
|
previous?.revoke();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
host.runtime.authority.assertTicket(ticket);
|
|
102
|
-
if (ticket.parent !== agent || ticket.owner !== host.owner || ticket.admission !== admission || ticket.parentEpoch !== admission.epoch)
|
|
103
|
-
throw new PermissionRefusal("not-owned");
|
|
104
|
-
}
|
|
97
|
+
if (managed && host.assert(agent) !== admission)
|
|
98
|
+
throw new PermissionRefusal("not-owned");
|
|
105
99
|
const controller = new AbortController();
|
|
106
|
-
const signal = AbortSignal.any([controller.signal, lifetimeSignal, ...
|
|
100
|
+
const signal = AbortSignal.any([controller.signal, lifetimeSignal, ...parent === undefined ? [] : [parent.authority.signal]]);
|
|
107
101
|
const detach = [];
|
|
108
102
|
let revoked = false;
|
|
109
|
-
const generation = { nativeChild, controlled: managed || identity?.role !== undefined, integration: entry,
|
|
103
|
+
const generation = { nativeChild, controlled: managed || identity?.role !== undefined, integration: entry, admission, facts,
|
|
110
104
|
authority: Object.freeze({ agent, root, realm: agent.ctx, owner, ownerGeneration: admission.epoch,
|
|
111
105
|
admissionRevision: admission.epoch, permissionRevision: randomUUID(), signal }),
|
|
112
106
|
revoke() {
|
|
@@ -139,29 +133,6 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
139
133
|
throw error;
|
|
140
134
|
}
|
|
141
135
|
};
|
|
142
|
-
const runFor = (host, agent, parent) => {
|
|
143
|
-
if (parent === undefined)
|
|
144
|
-
return undefined;
|
|
145
|
-
const invocation = capturedRoleInvocation(agent);
|
|
146
|
-
if (invocation === undefined)
|
|
147
|
-
return undefined;
|
|
148
|
-
if (host === undefined)
|
|
149
|
-
throw new PermissionRefusal("unavailable");
|
|
150
|
-
const ticket = host.runtime.authority.acquireParentTicket(parent.authority.agent);
|
|
151
|
-
host.runtime.authority.assertTicket(ticket);
|
|
152
|
-
if (ticket.owner !== host.owner || ticket.admission !== parent.admission || ticket.parentEpoch !== parent.admission.epoch)
|
|
153
|
-
throw new PermissionRefusal("not-owned");
|
|
154
|
-
const matching = host.registry.list(parent.authority.agent, host.owner).filter(holder => {
|
|
155
|
-
const held = holder.invocation;
|
|
156
|
-
return holder instanceof RoleRunHolder && !holder.holderSignal.aborted && (holder.state === "running" || holder.state === "background")
|
|
157
|
-
&& held?.parent === parent.authority.agent && held.owner === host.owner && held.childId === agent.id
|
|
158
|
-
&& held.admissionEpoch === ticket.parentEpoch && held.capture.admission === ticket.admission
|
|
159
|
-
&& held.capture.invocation === invocation && host.registry.get(held.parent, held.owner, held) === holder;
|
|
160
|
-
});
|
|
161
|
-
if (matching.length > 1)
|
|
162
|
-
throw new PermissionRefusal("not-owned");
|
|
163
|
-
return matching[0];
|
|
164
|
-
};
|
|
165
136
|
const current = exec => {
|
|
166
137
|
const host = integration(), chain = ancestry(exec), root = chain.at(-1);
|
|
167
138
|
let parent, generation;
|
|
@@ -170,8 +141,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
170
141
|
if (agent !== exec.agent)
|
|
171
142
|
parent = generation;
|
|
172
143
|
}
|
|
173
|
-
|
|
174
|
-
return run === undefined ? generation.authority : Object.freeze({ ...generation.authority, run });
|
|
144
|
+
return generation.authority;
|
|
175
145
|
};
|
|
176
146
|
const authority = {
|
|
177
147
|
current,
|
|
@@ -212,7 +182,7 @@ export function createCorePermissionAuthority(ctx, options) {
|
|
|
212
182
|
const live = current(exec);
|
|
213
183
|
if (authority.agent !== live.agent || authority.root !== live.root || authority.realm !== live.realm || authority.owner !== live.owner
|
|
214
184
|
|| authority.ownerGeneration !== live.ownerGeneration || authority.admissionRevision !== live.admissionRevision
|
|
215
|
-
|| authority.permissionRevision !== live.permissionRevision || authority.signal !== live.signal
|
|
185
|
+
|| authority.permissionRevision !== live.permissionRevision || authority.signal !== live.signal)
|
|
216
186
|
throw new PermissionRefusal("stale");
|
|
217
187
|
const tools = live.agent.ctx.get("tools");
|
|
218
188
|
if (tools?.get(exec.name, live.agent) === undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { DshContext } from "./dsh-types.js";
|
|
3
3
|
import { FixedConfigFileStore } from "./config-file-store.js";
|
|
4
|
-
import type { DsmmDeploymentSnapshot, DsmmPluginConfig } from "./settings.js";
|
|
4
|
+
import type { DsmmDeploymentSnapshot, DsmmPluginConfig, DsmmNativeConfig } from "./settings.js";
|
|
5
5
|
export type DeploymentPathEdit = {
|
|
6
6
|
op: "set";
|
|
7
7
|
path: string[];
|
|
@@ -17,6 +17,12 @@ export interface GlobalConfigSaveRequest {
|
|
|
17
17
|
export interface GlobalConfigSnapshot {
|
|
18
18
|
config: DsmmPluginConfig;
|
|
19
19
|
revision: string;
|
|
20
|
+
refreshRequired?: true;
|
|
21
|
+
}
|
|
22
|
+
declare module "@deepseek-ai/cordis" {
|
|
23
|
+
interface Context {
|
|
24
|
+
dsmmDeploymentConfig: DsmmDeploymentConfig;
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
export interface DeploymentWriteCoordinator {
|
|
22
28
|
global(request: GlobalConfigSaveRequest, config: DsmmPluginConfig, assertAuthority: () => void, write: (config: DsmmPluginConfig) => Promise<GlobalConfigSnapshot>): Promise<GlobalConfigSnapshot>;
|
|
@@ -29,6 +35,7 @@ export declare class DsmmDeploymentConfig {
|
|
|
29
35
|
private readonly ctx;
|
|
30
36
|
private readonly config;
|
|
31
37
|
private writeCoordinator?;
|
|
38
|
+
private permissionObservation?;
|
|
32
39
|
readonly home: string;
|
|
33
40
|
readonly store: FixedConfigFileStore;
|
|
34
41
|
readonly entryId: string;
|
|
@@ -51,7 +58,7 @@ export declare class DsmmDeploymentConfig {
|
|
|
51
58
|
rules: readonly import("./permission-rules.js").PermissionRule[];
|
|
52
59
|
};
|
|
53
60
|
};
|
|
54
|
-
constructor(ctx: DshContext, config:
|
|
61
|
+
constructor(ctx: DshContext, config: DsmmNativeConfig);
|
|
55
62
|
private profile;
|
|
56
63
|
readGlobal(): Promise<GlobalConfigSnapshot>;
|
|
57
64
|
readDesired(): Promise<DsmmDeploymentSnapshot>;
|
package/lib/deployment-config.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { Context, symbols } from "@deepseek-ai/cordis";
|
|
3
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
4
|
import { resolveDshHome } from "./dsh-home.js";
|
|
4
5
|
import { FixedConfigFileStore } from "./config-file-store.js";
|
|
5
|
-
import { copyJson, freezeSettings, resolveDeployment, validateDeploymentPath, validateSparseConfig } from "./settings.js";
|
|
6
|
+
import { copyJson, freezeSettings, resolveDeployment, validateDeploymentPath, validateSparseConfig, validateNativeConfig } from "./settings.js";
|
|
6
7
|
import { DsmmProfileError } from "./profiles.js";
|
|
7
8
|
import { resolve } from "node:path";
|
|
8
9
|
import { diagnosticSourcePath, DsmmConfigValidationError, fieldLocation, inspectJsonDocument } from "./profile-diagnostics.js";
|
|
@@ -96,6 +97,7 @@ export class DsmmDeploymentConfig {
|
|
|
96
97
|
ctx;
|
|
97
98
|
config;
|
|
98
99
|
writeCoordinator;
|
|
100
|
+
permissionObservation;
|
|
99
101
|
home;
|
|
100
102
|
store;
|
|
101
103
|
entryId;
|
|
@@ -111,8 +113,23 @@ export class DsmmDeploymentConfig {
|
|
|
111
113
|
/** Synchronous source identity for permission dispatch fences; no form revision or process identity. */
|
|
112
114
|
permissionSource() {
|
|
113
115
|
const profile = this.profile(), file = this.store.read(), global = parseGlobalConfig(file.content);
|
|
116
|
+
if (profile.revision === "unavailable")
|
|
117
|
+
throw new DsmmProfileError("unavailable", "Native settings version is unavailable; permission authority requires a current Host descriptor.");
|
|
114
118
|
const settings = resolveDeployment(global, profile.config);
|
|
115
|
-
|
|
119
|
+
const original = (value) => value === undefined ? undefined : Reflect.get(value, symbols.original) ?? value;
|
|
120
|
+
const profileContext = this.ctx.get?.("profileContext");
|
|
121
|
+
const scope = [original(this.ctx.get?.("settings")), original(profileContext), profileContext?.home, profileContext?.dir,
|
|
122
|
+
this.nativeEntry, this.nativeEntry?.fiber?.ctx];
|
|
123
|
+
const previous = this.permissionObservation;
|
|
124
|
+
if (previous !== undefined && scope.some((owner, index) => owner !== previous.scope[index])) {
|
|
125
|
+
throw new DsmmProfileError("unavailable", "Permission source authority changed; the previous deployment owner cannot adopt it.");
|
|
126
|
+
}
|
|
127
|
+
const unchangedPolicy = previous !== undefined && previous.globalRevision === file.revision && isDeepStrictEqual(previous.config, profile.config);
|
|
128
|
+
const revision = unchangedPolicy && previous.nativeRevision === profile.revision ? previous.revision
|
|
129
|
+
: `deployment-v1:${this.hostProfileKey}:${file.revision}:${profile.revision}`;
|
|
130
|
+
this.permissionObservation = { scope, globalRevision: file.revision, nativeRevision: profile.revision, revision,
|
|
131
|
+
config: profile.config };
|
|
132
|
+
return freezeSettings({ revision,
|
|
116
133
|
globalRevision: file.revision, nativeRevision: profile.revision, global, profile: profile.config,
|
|
117
134
|
policy: { ...settings.permissionControl, nativeCommands: parseHostNativeCommands(settings.permissionControl.nativeCommands) } });
|
|
118
135
|
}
|
|
@@ -134,17 +151,18 @@ export class DsmmDeploymentConfig {
|
|
|
134
151
|
return value === undefined ? [] : [[key, value]];
|
|
135
152
|
})) : entry.options.config ?? {};
|
|
136
153
|
try {
|
|
137
|
-
const presence =
|
|
154
|
+
const presence = validateNativeConfig(raw);
|
|
138
155
|
const snapshot = {};
|
|
139
156
|
for (const key of Object.keys(presence)) {
|
|
140
157
|
const parsed = Reflect.get(this.config, key);
|
|
141
158
|
const value = parsed !== null && typeof parsed === "object" && "get" in parsed && typeof parsed.get === "function" ? parsed.get() : parsed;
|
|
142
159
|
snapshot[key] = presentValue(value, Reflect.get(presence, key));
|
|
143
160
|
}
|
|
144
|
-
const config =
|
|
161
|
+
const config = validateNativeConfig(snapshot);
|
|
145
162
|
if (config.permissionControl?.nativeCommands !== undefined)
|
|
146
163
|
parseHostNativeCommands(config.permissionControl.nativeCommands);
|
|
147
|
-
|
|
164
|
+
const descriptor = entry === undefined ? undefined : this.ctx.get?.("settings")?.describe({ redactSecrets: true }).find(row => row.ns === entry.options.id);
|
|
165
|
+
return { config, revision: descriptor === undefined ? "unavailable" : `native-v1-${descriptor.revision}` };
|
|
148
166
|
}
|
|
149
167
|
catch (error) {
|
|
150
168
|
if (error instanceof DsmmConfigValidationError)
|
|
@@ -192,14 +210,23 @@ export class DsmmDeploymentConfig {
|
|
|
192
210
|
throw error;
|
|
193
211
|
configurationError();
|
|
194
212
|
}
|
|
213
|
+
let committed;
|
|
195
214
|
const write = async (candidate) => {
|
|
196
215
|
const validated = validateSparseConfig(candidate, true);
|
|
197
216
|
resolveDeployment(validated, this.profile().config);
|
|
198
217
|
assertAuthority();
|
|
199
218
|
const saved = await this.store.save(`${JSON.stringify(validated, null, 2)}\n`, request.expectedRevision, assertAuthority);
|
|
200
|
-
|
|
219
|
+
committed = { config: validated, revision: saved.revision, ...(saved.refreshRequired ? { refreshRequired: true } : {}) };
|
|
220
|
+
return committed;
|
|
201
221
|
};
|
|
202
|
-
|
|
222
|
+
try {
|
|
223
|
+
return await (this.writeCoordinator === undefined ? write(config) : this.writeCoordinator.global(request, config, assertAuthority, write));
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (committed !== undefined)
|
|
227
|
+
return { ...committed, refreshRequired: true };
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
203
230
|
}
|
|
204
231
|
}
|
|
205
232
|
//# sourceMappingURL=deployment-config.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
|
|
2
2
|
import { applyPermissionRulesSave, importPermissionRules, operatorPermissionRulesSource, parsePermissionRules, parsePermissionRulesSave, PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
3
|
-
import { copyJson, validateSparseConfig } from "./settings.js";
|
|
3
|
+
import { copyJson, validateSparseConfig, validateNativeConfig } from "./settings.js";
|
|
4
4
|
import { parseHostNativeCommands } from "./permission-native-command.js";
|
|
5
5
|
const entries = new WeakMap();
|
|
6
6
|
const claimed = new WeakSet();
|
|
@@ -225,7 +225,7 @@ export class DeploymentPermissionRules {
|
|
|
225
225
|
if (failures.length)
|
|
226
226
|
throw new AggregateError(failures, "Permission configuration is not synchronized.");
|
|
227
227
|
}
|
|
228
|
-
async transaction(participants, write) {
|
|
228
|
+
async transaction(participants, write, deferBegin = false) {
|
|
229
229
|
for (const participant of participants) {
|
|
230
230
|
if (participant.busy)
|
|
231
231
|
throw new PermissionRefusal("stale");
|
|
@@ -242,9 +242,15 @@ export class DeploymentPermissionRules {
|
|
|
242
242
|
throw new PermissionRefusal("stale");
|
|
243
243
|
participant.busy = true;
|
|
244
244
|
locked.add(participant);
|
|
245
|
-
updates.set(participant, participant.runtime.begin(participant.snapshot().revision));
|
|
246
245
|
}
|
|
247
|
-
|
|
246
|
+
const begin = () => {
|
|
247
|
+
for (const participant of participants)
|
|
248
|
+
if (!updates.has(participant))
|
|
249
|
+
updates.set(participant, participant.runtime.begin(participant.snapshot().revision));
|
|
250
|
+
};
|
|
251
|
+
if (!deferBegin)
|
|
252
|
+
begin();
|
|
253
|
+
result = await write(begin);
|
|
248
254
|
}
|
|
249
255
|
catch (error) {
|
|
250
256
|
try {
|
|
@@ -256,6 +262,10 @@ export class DeploymentPermissionRules {
|
|
|
256
262
|
throw error;
|
|
257
263
|
}
|
|
258
264
|
await this.synchronize(updates, false);
|
|
265
|
+
// A deferred native edit still observes source/lifetime changes before returning.
|
|
266
|
+
for (const participant of participants)
|
|
267
|
+
if (!updates.has(participant))
|
|
268
|
+
participant.runtime.getPolicy();
|
|
259
269
|
return result;
|
|
260
270
|
}
|
|
261
271
|
finally {
|
|
@@ -264,14 +274,16 @@ export class DeploymentPermissionRules {
|
|
|
264
274
|
}
|
|
265
275
|
}
|
|
266
276
|
async editNative(editor, entry, change) {
|
|
267
|
-
await this.transaction([this],
|
|
268
|
-
const next =
|
|
277
|
+
await this.transaction([this], begin => editor.edit(entry, (current, inherited) => {
|
|
278
|
+
const next = validateNativeConfig(change(current, inherited));
|
|
269
279
|
if (next.permissionControl?.nativeCommands !== undefined)
|
|
270
280
|
parseHostNativeCommands(next.permissionControl.nativeCommands);
|
|
281
|
+
validateNativeConfig(current);
|
|
282
|
+
begin();
|
|
271
283
|
if (JSON.stringify(next.permissionControl?.rules) === JSON.stringify(current.permissionControl && typeof current.permissionControl === "object" ? Reflect.get(current.permissionControl, "rules") : undefined))
|
|
272
284
|
return copyJson(next);
|
|
273
285
|
return copyJson(imported(next, "native-profile-settings", false));
|
|
274
|
-
}));
|
|
286
|
+
}), true);
|
|
275
287
|
}
|
|
276
288
|
}
|
|
277
289
|
/** Install in the owned Core fiber with the public `agents` service injected. */
|
package/lib/dsh-types.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ export interface DshContext {
|
|
|
257
257
|
commands?: DshCommandsRegistry;
|
|
258
258
|
tools?: DshToolRuntime;
|
|
259
259
|
llm?: DshLlmRuntime;
|
|
260
|
-
|
|
260
|
+
dsmmNativeAdmission?: import("./native-admission.js").NativeAdmission;
|
|
261
261
|
get?<T = unknown>(name: string): T | undefined;
|
|
262
262
|
provide?(name: string, service: unknown): unknown;
|
|
263
263
|
plugin?(plugin: unknown, config?: unknown): PromiseLike<unknown>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { SessionInspection } from "@deepseek-ai/dsh-session-persistence";
|
|
3
|
+
import type { NativeAdmission } from "./native-admission.js";
|
|
4
|
+
import type { DsmmProfileRuntime } from "./profile-runtime.js";
|
|
5
|
+
import type { DsmmDeploymentConfig } from "./deployment-config.js";
|
|
6
|
+
import type { HistoryCandidate, HistoryCandidates } from "./history-contract.js";
|
|
7
|
+
import type { HistoryPreviewRequest } from "./history-types.js";
|
|
8
|
+
/** Current deployment/profile and native composition only; history supplies content and restrictive ceilings. */
|
|
9
|
+
export declare class DsmmHistoryCandidates implements HistoryCandidates {
|
|
10
|
+
private readonly ctx;
|
|
11
|
+
private readonly profiles;
|
|
12
|
+
private readonly deployment;
|
|
13
|
+
private readonly admission;
|
|
14
|
+
readonly signal: AbortSignal;
|
|
15
|
+
private modelGeneration;
|
|
16
|
+
constructor(ctx: Context, profiles: DsmmProfileRuntime, deployment: DsmmDeploymentConfig, admission: NativeAdmission);
|
|
17
|
+
checkCompatibility(): Promise<void>;
|
|
18
|
+
choices(signal: AbortSignal): Promise<{
|
|
19
|
+
presets: {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}[];
|
|
23
|
+
profiles: {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
28
|
+
prepare(request: HistoryPreviewRequest, inspection: SessionInspection, signal: AbortSignal): Promise<HistoryCandidate>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=history-candidates.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import { symbols } from "@deepseek-ai/cordis";
|
|
4
|
+
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
5
|
+
import { setSandboxMode } from "@deepseek-ai/dsh-sandbox-policy";
|
|
6
|
+
import { setApprovalPolicy } from "@deepseek-ai/dsh-user-approval";
|
|
7
|
+
import { HistoryRefusal } from "./history-controller.js";
|
|
8
|
+
import { DSMM_ROLES, isDsmmRoleId } from "./roles.js";
|
|
9
|
+
import { isRootRoleEnabled } from "./settings.js";
|
|
10
|
+
import { appendModeRecord } from "./session-metadata.js";
|
|
11
|
+
import { effectiveHistoryGitWriteGuard } from "./history-policy.js";
|
|
12
|
+
const require = createRequire(import.meta.url), sdk = createRequire(require.resolve("@deepseek-ai/dsh-agent-preset-registry"));
|
|
13
|
+
const { createScope, scopeParentOf } = sdk("@deepseek-ai/dsh-scope");
|
|
14
|
+
const original = (value) => Reflect.get(value, symbols.original) ?? value;
|
|
15
|
+
const services = ["llm", "tools", "systemPrompt", "skills", "sandboxPolicy", "approval"];
|
|
16
|
+
function requireCurrentLease(lease) {
|
|
17
|
+
if (!("assertCurrent" in lease) || typeof lease.assertCurrent !== "function")
|
|
18
|
+
throw new HistoryRefusal("unsupported-host");
|
|
19
|
+
}
|
|
20
|
+
/** Current deployment/profile and native composition only; history supplies content and restrictive ceilings. */
|
|
21
|
+
export class DsmmHistoryCandidates {
|
|
22
|
+
ctx;
|
|
23
|
+
profiles;
|
|
24
|
+
deployment;
|
|
25
|
+
admission;
|
|
26
|
+
signal;
|
|
27
|
+
modelGeneration = 0;
|
|
28
|
+
constructor(ctx, profiles, deployment, admission) {
|
|
29
|
+
this.ctx = ctx;
|
|
30
|
+
this.profiles = profiles;
|
|
31
|
+
this.deployment = deployment;
|
|
32
|
+
this.admission = admission;
|
|
33
|
+
this.signal = admission.lifetime.signal;
|
|
34
|
+
ctx.on("llm/adapters-updated", () => { this.modelGeneration++; }, { global: true });
|
|
35
|
+
}
|
|
36
|
+
async checkCompatibility() {
|
|
37
|
+
this.signal.throwIfAborted();
|
|
38
|
+
const registry = this.ctx.agentPresets, preset = (await registry.list()).find(row => !row.broken);
|
|
39
|
+
if (!preset)
|
|
40
|
+
throw new HistoryRefusal("unavailable");
|
|
41
|
+
const lease = await registry.acquireScope(preset.id);
|
|
42
|
+
try {
|
|
43
|
+
requireCurrentLease(lease);
|
|
44
|
+
lease.assertCurrent();
|
|
45
|
+
this.signal.throwIfAborted();
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
await lease[Symbol.asyncDispose]();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async choices(signal) {
|
|
52
|
+
signal.throwIfAborted();
|
|
53
|
+
this.signal.throwIfAborted();
|
|
54
|
+
const desired = await this.deployment.readDesired(), rows = await this.ctx.agentPresets.list(), profiles = await this.profiles.describe();
|
|
55
|
+
signal.throwIfAborted();
|
|
56
|
+
this.signal.throwIfAborted();
|
|
57
|
+
return { presets: rows.filter(row => !row.broken && (!row.id.startsWith("dsmm-") || isDsmmRoleId(row.id) && isRootRoleEnabled(desired.settings, row.id)))
|
|
58
|
+
.map(row => ({ id: row.id, label: (row.name ?? row.id).slice(0, 120) })),
|
|
59
|
+
profiles: profiles.profiles.filter(row => row.revision !== null && row.error === undefined).map(row => ({ id: row.id, label: (row.label ?? row.id).slice(0, 120) })) };
|
|
60
|
+
}
|
|
61
|
+
async prepare(request, inspection, signal) {
|
|
62
|
+
signal.throwIfAborted();
|
|
63
|
+
this.signal.throwIfAborted();
|
|
64
|
+
if (inspection.meta.origin === "subagent")
|
|
65
|
+
throw new HistoryRefusal("child-owner-required");
|
|
66
|
+
const profile = await this.profiles.prepareHistory(request.profileId, this.signal), settings = profile.admission.settings;
|
|
67
|
+
if (request.preset.startsWith("dsmm-") && (!isDsmmRoleId(request.preset) || !isRootRoleEnabled(settings, request.preset)))
|
|
68
|
+
throw new HistoryRefusal("unavailable");
|
|
69
|
+
const registry = this.ctx.agentPresets, metadata = await registry.resolve(request.preset);
|
|
70
|
+
if (metadata.broken)
|
|
71
|
+
throw new HistoryRefusal("unavailable");
|
|
72
|
+
const lease = await registry.acquireScope(request.preset);
|
|
73
|
+
try {
|
|
74
|
+
requireCurrentLease(lease);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
await lease[Symbol.asyncDispose]();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
const scope = createScope(this.ctx, {}, { parent: lease.key });
|
|
81
|
+
const dispose = async () => { try {
|
|
82
|
+
await scope.dispose();
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
await lease[Symbol.asyncDispose]();
|
|
86
|
+
} };
|
|
87
|
+
try {
|
|
88
|
+
const get = (name) => registry.serviceFor({ ctx: scope.ctx }, name) ?? this.ctx.get(name);
|
|
89
|
+
const captured = services.map(name => get(name));
|
|
90
|
+
if (captured.some(value => value === undefined))
|
|
91
|
+
throw new HistoryRefusal("unavailable");
|
|
92
|
+
const llm = get("llm"), sandbox = get("sandboxPolicy"), approval = get("approval");
|
|
93
|
+
const permissions = this.ctx.get("dsmmPermissionController");
|
|
94
|
+
if (!permissions)
|
|
95
|
+
throw new HistoryRefusal("unavailable");
|
|
96
|
+
await permissions.rules.refresh();
|
|
97
|
+
const rules = permissions.rules.getPolicy(), permissionSignal = permissions.rules.signal;
|
|
98
|
+
const source = this.deployment.permissionSource();
|
|
99
|
+
if (source.globalRevision !== profile.admission.deployment?.globalRevision || source.nativeRevision !== profile.admission.deployment?.nativeRevision)
|
|
100
|
+
throw new HistoryRefusal("stale");
|
|
101
|
+
const generation = this.modelGeneration;
|
|
102
|
+
const active = settings.modules.deepwork.enabled && (isDsmmRoleId(request.preset) || request.preset !== "minimal" && settings.defaultActive);
|
|
103
|
+
const role = isDsmmRoleId(request.preset) ? request.preset : active ? "dsmm-orchestrator" : undefined;
|
|
104
|
+
const route = role === undefined ? undefined : settings.roleRouting[role]?.primary;
|
|
105
|
+
const defaultModel = this.ctx.get?.("agentDefaultModel");
|
|
106
|
+
if (!route && !defaultModel)
|
|
107
|
+
throw new HistoryRefusal("unavailable");
|
|
108
|
+
const model = route === undefined ? structuredClone(defaultModel.currentSelection()) : { provider: route.provider, model: route.model,
|
|
109
|
+
...(route.reasoningEffort === undefined ? {} : { reasoningEffort: ReasoningEffortId(route.reasoningEffort) }) };
|
|
110
|
+
await llm.resolveCallConfig(model, signal);
|
|
111
|
+
const oldSandbox = inspection.events.filter(event => event.type === "sandbox/mode").at(-1);
|
|
112
|
+
const oldApproval = inspection.events.filter(event => event.type === "approval/policy").at(-1);
|
|
113
|
+
const oldPreset = inspection.events.filter(event => event.type === "agent-preset/selected").at(-1)?.data.agentPreset ?? inspection.meta.agentPreset;
|
|
114
|
+
const readOnlyHistory = oldSandbox?.data.mode === "read-only" || DSMM_ROLES.some(role => role.id === oldPreset && role.access === "read-only");
|
|
115
|
+
const defaultMode = sandbox.defaultMode, defaultApproval = approval.config.policy ?? "ask";
|
|
116
|
+
const mode = readOnlyHistory ? "read-only" : defaultMode;
|
|
117
|
+
const approvalPolicy = oldApproval?.data.policy === "never" ? "never" : defaultApproval;
|
|
118
|
+
const check = () => {
|
|
119
|
+
this.signal.throwIfAborted();
|
|
120
|
+
permissionSignal.throwIfAborted();
|
|
121
|
+
try {
|
|
122
|
+
lease.assertCurrent();
|
|
123
|
+
profile.assertCurrent();
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
throw new HistoryRefusal("stale");
|
|
127
|
+
}
|
|
128
|
+
const current = this.ctx.get("dsmmPermissionController");
|
|
129
|
+
const currentDefault = this.ctx.get?.("agentDefaultModel");
|
|
130
|
+
if (!this.admission.isReady || original(this.ctx.agentPresets) !== original(registry) || this.modelGeneration !== generation
|
|
131
|
+
|| current === undefined || original(current) !== original(permissions) || current.rules.signal !== permissionSignal
|
|
132
|
+
|| current.rules.getPolicy().revision !== rules.revision || this.deployment.permissionSource().revision !== source.revision
|
|
133
|
+
|| captured.some((value, index) => { const now = get(services[index]); return value === undefined || now === undefined || original(value) !== original(now); })
|
|
134
|
+
|| route === undefined && (currentDefault === undefined || original(currentDefault) !== original(defaultModel) || !isDeepStrictEqual(currentDefault.currentSelection(), model))
|
|
135
|
+
|| sandbox.defaultMode !== defaultMode || (approval.config.policy ?? "ask") !== defaultApproval)
|
|
136
|
+
throw new HistoryRefusal("stale");
|
|
137
|
+
};
|
|
138
|
+
check();
|
|
139
|
+
signal.throwIfAborted();
|
|
140
|
+
return { admission: profile.admission, model, signal: AbortSignal.any([this.signal, permissionSignal]),
|
|
141
|
+
view: { preset: { id: request.preset, label: (metadata.name ?? metadata.id).slice(0, 120) }, profile: request.profileId === null ? null : { id: request.profileId, label: (profile.label ?? request.profileId).slice(0, 120) }, model,
|
|
142
|
+
roles: DSMM_ROLES.filter(role => active && settings.roles[role.id]).map(role => ({ id: role.id, label: role.name })),
|
|
143
|
+
restrictions: [`sandbox: ${mode}`, `approval: ${approvalPolicy}`, `Deepwork: ${active ? "on" : "off"}`, `DSMM Git-write guard: ${effectiveHistoryGitWriteGuard(settings, mode === "danger-full-access", active)}`],
|
|
144
|
+
differences: ["Current preset, saved configuration and current native permissions replace historical execution settings. Historical approval outcomes and temporary grants are not reused."] },
|
|
145
|
+
assertCurrent: check,
|
|
146
|
+
revalidate: async (currentSignal) => {
|
|
147
|
+
check();
|
|
148
|
+
await profile.revalidate(currentSignal);
|
|
149
|
+
await llm.resolveCallConfig(model, currentSignal);
|
|
150
|
+
check();
|
|
151
|
+
currentSignal.throwIfAborted();
|
|
152
|
+
},
|
|
153
|
+
install: async (agent, currentSignal) => {
|
|
154
|
+
check();
|
|
155
|
+
currentSignal.throwIfAborted();
|
|
156
|
+
if (scopeParentOf(agent) !== lease.key || registry.composedPreset(agent.ctx) !== request.preset
|
|
157
|
+
|| captured.some((value, index) => { const actual = registry.serviceFor(agent, services[index]) ?? agent.ctx.get(services[index]); return value === undefined || actual === undefined || original(value) !== original(actual); }))
|
|
158
|
+
throw new HistoryRefusal("stale");
|
|
159
|
+
setSandboxMode(agent.session, mode);
|
|
160
|
+
check();
|
|
161
|
+
setApprovalPolicy(agent.session, approvalPolicy);
|
|
162
|
+
check();
|
|
163
|
+
appendModeRecord(agent.session, active);
|
|
164
|
+
check();
|
|
165
|
+
await this.admission.prepareHistory(agent, profile.admission, currentSignal);
|
|
166
|
+
check();
|
|
167
|
+
currentSignal.throwIfAborted();
|
|
168
|
+
}, dispose };
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
await dispose();
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=history-candidates.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HistoryChoices, HistoryConfirmRequest, HistoryContinuationResult, HistoryFailure, HistoryJson, HistoryPreview, HistoryPreviewRequest, HistoryStatus } from "./history-types.js";
|
|
2
|
+
export declare function historySessionId(input: unknown): string;
|
|
3
|
+
export declare function historyJson(input: unknown, depth?: number, active?: Set<object>): HistoryJson;
|
|
4
|
+
export declare function parseHistoryFailure(input: unknown): HistoryFailure;
|
|
5
|
+
export declare function parseHistoryStatus(input: unknown): HistoryStatus;
|
|
6
|
+
export declare function parseHistoryChoices(input: unknown): HistoryChoices;
|
|
7
|
+
export declare function parseHistoryPreviewRequest(input: unknown): HistoryPreviewRequest;
|
|
8
|
+
export declare function parseHistoryConfirmRequest(input: unknown): HistoryConfirmRequest;
|
|
9
|
+
export declare function parseHistoryPreview(input: unknown): HistoryPreview;
|
|
10
|
+
export declare function parseHistoryResult(input: unknown): HistoryContinuationResult;
|
|
11
|
+
//# sourceMappingURL=history-codec.d.ts.map
|