@dsmm/dsmm 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -42
- package/cordis.patch.yml +1 -0
- package/docs/agent-presets.md +26 -14
- package/docs/compatibility.md +20 -79
- package/docs/deferred-native-approval-risk.md +8 -12
- package/docs/design.md +25 -254
- package/docs/lsp.md +2 -2
- package/docs/migration-from-ocmm.md +38 -51
- package/docs/model-routing.md +21 -21
- package/docs/native-permissions.md +17 -7
- package/docs/profiles.md +13 -9
- package/docs/releasing.md +34 -240
- package/docs/roadmap.md +23 -254
- package/docs/runtime-recovery.md +29 -91
- package/docs/safety-guards.md +19 -16
- package/docs/settings-status.md +23 -11
- package/docs/skill-sync.md +17 -17
- package/docs/web-fetch-fakeip.md +82 -0
- package/lib/child-capture.d.ts +16 -2
- package/lib/child-capture.js +29 -10
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +4 -16
- package/lib/client/DeploymentFields.d.ts +28 -0
- package/lib/client/DeploymentFields.js +68 -0
- package/lib/client/DeploymentPage.d.ts +17 -5
- package/lib/client/DeploymentPage.js +79 -112
- package/lib/client/NativeCommandEntries.d.ts +17 -0
- package/lib/client/NativeCommandEntries.js +68 -0
- package/lib/client/PermissionsPanel.d.ts +1 -1
- package/lib/client/PermissionsPanel.js +8 -8
- package/lib/client/ProfilesSection.js +7 -5
- package/lib/client/RoleToolView-data.d.ts +35 -0
- package/lib/client/RoleToolView-data.js +52 -0
- package/lib/client/RoleToolView-locales.d.ts +36 -0
- package/lib/client/RoleToolView-locales.js +20 -0
- package/lib/client/RoleToolView.d.ts +10 -0
- package/lib/client/RoleToolView.js +47 -0
- package/lib/client/SessionProfiles.js +39 -15
- package/lib/client/children-controller.d.ts +2 -8
- package/lib/client/children-controller.js +1 -26
- package/lib/client/children-locales.d.ts +26 -51
- package/lib/client/children-locales.js +8 -12
- package/lib/client/configuration-display.d.ts +5 -0
- package/lib/client/configuration-display.js +11 -0
- package/lib/client/controller.d.ts +1 -0
- package/lib/client/controller.js +20 -13
- package/lib/client/deployment-controller.d.ts +13 -1
- package/lib/client/deployment-controller.js +85 -25
- package/lib/client/deployment-data.d.ts +1 -0
- package/lib/client/deployment-data.js +4 -1
- package/lib/client/deployment-locales.d.ts +43 -0
- package/lib/client/deployment-locales.js +35 -9
- package/lib/client/deployment-modules.d.ts +9 -0
- package/lib/client/deployment-modules.js +24 -0
- package/lib/client/deployment-workspace.d.ts +48 -0
- package/lib/client/deployment-workspace.js +123 -0
- package/lib/client/index.js +11 -74
- package/lib/client/locales.d.ts +7 -0
- package/lib/client/locales.js +12 -6
- package/lib/client/permission-controller.d.ts +1 -0
- package/lib/client/permission-controller.js +3 -2
- package/lib/client/permission-locales.d.ts +25 -0
- package/lib/client/permission-locales.js +24 -4
- package/lib/client/session-labels.js +4 -3
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +9 -8
- package/lib/client.js +2716 -2364
- package/lib/commands.js +2 -0
- package/lib/config-file-store.d.ts +3 -0
- package/lib/config-file-store.js +4 -2
- package/lib/config-revision.d.ts +5 -0
- package/lib/config-revision.js +11 -0
- package/lib/core-permission-authority.js +11 -41
- package/lib/deployment-config.d.ts +9 -2
- package/lib/deployment-config.js +35 -8
- package/lib/deployment-permission-rules.js +19 -7
- package/lib/dsh-types.d.ts +1 -1
- package/lib/host-llm-startup.js +3 -3
- package/lib/host-llm.d.ts +9 -3
- package/lib/host-llm.js +48 -8
- package/lib/index.d.ts +17 -21
- package/lib/index.js +131 -430
- package/lib/lifetime.d.ts +4 -0
- package/lib/lifetime.js +22 -0
- package/lib/live-pi-ai-owner.d.ts +1 -0
- package/lib/live-pi-ai-owner.js +8 -4
- package/lib/mode.d.ts +3 -2
- package/lib/mode.js +28 -41
- package/lib/model-routing.d.ts +2 -8
- package/lib/model-routing.js +59 -175
- package/lib/native-admission.d.ts +56 -0
- package/lib/native-admission.js +313 -0
- package/lib/native-pi-ai-wire.d.ts +3 -1
- package/lib/native-pi-ai-wire.js +47 -13
- package/lib/permission-control.d.ts +0 -3
- package/lib/permission-rpc.js +3 -3
- package/lib/preset-registry.js +3 -2
- package/lib/preset-skills.d.ts +3 -12
- package/lib/preset-skills.js +28 -58
- package/lib/profile-diagnostics.d.ts +1 -1
- package/lib/profile-diagnostics.js +2 -2
- package/lib/profile-remote.js +61 -22
- package/lib/profile-rpc.d.ts +4 -3
- package/lib/profile-rpc.js +39 -41
- package/lib/profile-runtime.d.ts +31 -74
- package/lib/profile-runtime.js +224 -639
- package/lib/profile-store.d.ts +18 -6
- package/lib/profile-store.js +106 -64
- package/lib/profile-types.d.ts +18 -4
- package/lib/profiles.d.ts +3 -1
- package/lib/profiles.js +9 -7
- package/lib/prompt-content.d.ts +1 -0
- package/lib/prompt-content.js +4 -1
- package/lib/prompts.d.ts +2 -12
- package/lib/prompts.js +11 -66
- package/lib/role-control-remote.d.ts +1 -4
- package/lib/role-control-remote.js +8 -36
- package/lib/role-control-rpc.d.ts +10 -36
- package/lib/role-control-rpc.js +112 -265
- package/lib/role-control-types.d.ts +3 -26
- package/lib/role-control-types.js +3 -4
- package/lib/role-identity.d.ts +5 -0
- package/lib/role-identity.js +10 -0
- package/lib/role-invocation.d.ts +2 -2
- package/lib/role-llm-runtime.js +5 -11
- package/lib/role-policy.d.ts +19 -53
- package/lib/role-policy.js +136 -525
- package/lib/role-providers.d.ts +5 -8
- package/lib/role-providers.js +20 -126
- package/lib/role-routing.d.ts +1 -3
- package/lib/role-routing.js +24 -34
- package/lib/role-subagents.d.ts +5 -14
- package/lib/role-subagents.js +149 -97
- package/lib/runtime-integration.d.ts +5 -109
- package/lib/runtime-integration.js +11 -779
- package/lib/session-metadata.d.ts +13 -12
- package/lib/session-metadata.js +6 -31
- package/lib/session-scope.js +6 -2
- package/lib/settings.d.ts +5 -18
- package/lib/settings.js +19 -43
- package/lib/state.d.ts +3 -2
- package/lib/state.js +26 -10
- package/lib/status.d.ts +1 -9
- package/lib/status.js +3 -55
- package/lib/web-fetch-address-policy.d.ts +24 -0
- package/lib/web-fetch-address-policy.js +189 -0
- package/lib/web-fetch-fakeip.d.ts +25 -0
- package/lib/web-fetch-fakeip.js +107 -0
- package/package.json +133 -113
- package/docs/research/deepseek-v4-pro.md +0 -74
- package/docs/research/oh-dsh.md +0 -96
- package/lib/child-admission.d.ts +0 -42
- package/lib/child-admission.js +0 -162
- package/lib/delivery-authority.d.ts +0 -68
- package/lib/delivery-authority.js +0 -260
- package/lib/legacy-child-policy.d.ts +0 -51
- package/lib/legacy-child-policy.js +0 -123
- package/lib/legacy-read-composition.d.ts +0 -20
- package/lib/legacy-read-composition.js +0 -144
- package/lib/legacy-read-contracts.d.ts +0 -157
- package/lib/legacy-read-contracts.js +0 -39
- package/lib/legacy-read-host.d.ts +0 -19
- package/lib/legacy-read-host.js +0 -67
- package/lib/legacy-read-integration.d.ts +0 -121
- package/lib/legacy-read-integration.js +0 -522
- package/lib/legacy-read-proxy.d.ts +0 -26
- package/lib/legacy-read-proxy.js +0 -237
- package/lib/native-child-evidence.d.ts +0 -42
- package/lib/native-child-evidence.js +0 -133
- package/lib/role-runs.d.ts +0 -135
- package/lib/role-runs.js +0 -304
- package/lib/session-persistence.d.ts +0 -35
- package/lib/session-persistence.js +0 -304
- package/lib/subagent-runtime.d.ts +0 -45
- package/lib/subagent-runtime.js +0 -131
- package/prompts/deepseek-flash.md +0 -11
- package/prompts/deepseek-v4-pro.md +0 -14
- package/scripts/cold-profile-composition.mjs +0 -329
- package/scripts/cold-profile-sources.mjs +0 -238
- package/scripts/migrate-cold-profile.mjs +0 -315
- package/scripts/repair-session-log.mjs +0 -476
- package/scripts/session-repair-native-verifier.mjs +0 -367
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>;
|
package/lib/host-llm-startup.js
CHANGED
|
@@ -12,7 +12,7 @@ export function createDsmmLlmColdStartup(options) {
|
|
|
12
12
|
let failure;
|
|
13
13
|
let mounted;
|
|
14
14
|
let provider;
|
|
15
|
-
const dependencies = [...AgentLoop.inject, "dsmmProfileRuntime", "
|
|
15
|
+
const dependencies = [...AgentLoop.inject, "dsmmProfileRuntime", "dsmmNativeAdmission", "sessionPersistence", "dsmmLlmProviderOwner"];
|
|
16
16
|
const builtin = "dsmm-llm-provider-owner";
|
|
17
17
|
return {
|
|
18
18
|
patches: [{ id: "agent-loop", disabled: true }, { insert: [{ id: options.provider.settingsNamespace, name: `cordis:${builtin}`, config: options.provider.config }] }],
|
|
@@ -33,8 +33,8 @@ export function createDsmmLlmColdStartup(options) {
|
|
|
33
33
|
try {
|
|
34
34
|
if (scope.get("agentLoop") !== undefined || provider === undefined)
|
|
35
35
|
throw new Error("DSMM LLM cold ownership was not established before AgentLoop");
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
36
|
+
const admission = scope.get("dsmmNativeAdmission");
|
|
37
|
+
if (admission === undefined || admission.lifetime.signal.aborted)
|
|
38
38
|
throw new Error("DSMM admission guards are not ready");
|
|
39
39
|
const original = scope.llm;
|
|
40
40
|
const stock = Reflect.get(original, symbols.original) ?? original;
|
package/lib/host-llm.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Context } from "@deepseek-ai/cordis";
|
|
|
2
2
|
import type { Events } from "@deepseek-ai/cordis";
|
|
3
3
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
4
4
|
import { LlmRuntime } from "@deepseek-ai/dsh-llm";
|
|
5
|
-
import type { GenerateOptions, LlmCallConfig, PreparedLlmCall, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
5
|
+
import type { ConfigureCall, GenerateOptions, LlmCallConfig, PreparedLlmCall, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
6
6
|
export type DsmmJson = null | boolean | number | string | readonly DsmmJson[] | {
|
|
7
7
|
readonly [key: string]: DsmmJson;
|
|
8
8
|
};
|
|
@@ -12,7 +12,10 @@ export interface DsmmLlmCallConfig extends LlmCallConfig {
|
|
|
12
12
|
}
|
|
13
13
|
export interface DsmmLlmCallClassifier {
|
|
14
14
|
requiresRaw?(config: DsmmLlmCallConfig): boolean;
|
|
15
|
+
supportsNativeStop?(provider: string): boolean;
|
|
15
16
|
}
|
|
17
|
+
export type DsmmEffortSource = "native" | "dsmm-config";
|
|
18
|
+
export declare function captureDsmmEffortSource(agent: Agent): DsmmEffortSource;
|
|
16
19
|
/** Use the live provider owner and this call's complete frozen parameters, not envelope presence alone. */
|
|
17
20
|
export declare function requiresDsmmCallAdmission(config: DsmmLlmCallConfig, classifier?: DsmmLlmCallClassifier, uncapturedAgent?: Agent): boolean;
|
|
18
21
|
/** A Host-held admission, not a credential or a value accepted from serialized configuration. */
|
|
@@ -30,7 +33,7 @@ export interface DsmmLlmGeneration {
|
|
|
30
33
|
readonly retryPolicy: ResolvedRetryPolicy;
|
|
31
34
|
readonly defaultReasoningEffort?: LlmCallConfig["reasoningEffort"];
|
|
32
35
|
assertCurrent(): void;
|
|
33
|
-
prepareCall(provider: string, model: string, signal: AbortSignal, assertAdmission?: () => void): Promise<PreparedAdapterCall>;
|
|
36
|
+
prepareCall(provider: string, model: string, signal: AbortSignal, assertAdmission?: () => void, effortSource?: () => DsmmEffortSource): Promise<PreparedAdapterCall>;
|
|
34
37
|
}
|
|
35
38
|
export interface DsmmLlmHostOwner {
|
|
36
39
|
/** Classification must reject lost DSMM evidence instead of returning native. */
|
|
@@ -40,11 +43,13 @@ export interface DsmmLlmHostOwner {
|
|
|
40
43
|
readonly kind: "stock";
|
|
41
44
|
readonly admission: DsmmLlmAdmission;
|
|
42
45
|
readonly config: LlmCallConfig;
|
|
46
|
+
readonly effortSource?: DsmmEffortSource;
|
|
43
47
|
} | {
|
|
44
48
|
readonly kind: "dsmm";
|
|
45
49
|
readonly admission: DsmmLlmAdmission;
|
|
46
50
|
readonly generation: DsmmLlmGeneration;
|
|
47
51
|
readonly config: DsmmLlmCallConfig;
|
|
52
|
+
readonly effortSource?: DsmmEffortSource;
|
|
48
53
|
}>;
|
|
49
54
|
}
|
|
50
55
|
export declare function freezeDsmmJson<T>(value: T): T;
|
|
@@ -71,7 +76,8 @@ export declare class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
71
76
|
private assertCaptured;
|
|
72
77
|
private finishCaptured;
|
|
73
78
|
private uncapturedNativeConfig;
|
|
74
|
-
prepareCall(proposal: LlmCallConfig, signal?: AbortSignal): Promise<PreparedLlmCall>;
|
|
79
|
+
prepareCall(proposal: LlmCallConfig, signal?: AbortSignal, configure?: ConfigureCall): Promise<PreparedLlmCall>;
|
|
80
|
+
private prepareNativeCall;
|
|
75
81
|
private prepareAdmittedCall;
|
|
76
82
|
private bindPrepared;
|
|
77
83
|
private adapterStreamFor;
|
package/lib/host-llm.js
CHANGED
|
@@ -5,6 +5,17 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
5
5
|
import { copyRouteJson } from "./route-json.js";
|
|
6
6
|
import { modelRouteFromCall } from "./role-llm.js";
|
|
7
7
|
import { classifyDsmmAgent } from "./runtime-integration.js";
|
|
8
|
+
import { latestNativeModelSelection } from "./role-routing.js";
|
|
9
|
+
import { resolveSelectedAgentPreset } from "./session-scope.js";
|
|
10
|
+
import { capturedRoleInvocation } from "./role-invocation.js";
|
|
11
|
+
export function captureDsmmEffortSource(agent) {
|
|
12
|
+
const current = agent;
|
|
13
|
+
const invocation = capturedRoleInvocation(current);
|
|
14
|
+
if (latestNativeModelSelection(current) !== undefined
|
|
15
|
+
|| agent.session.header.origin !== "subagent" && !resolveSelectedAgentPreset(current.session)?.startsWith("dsmm-"))
|
|
16
|
+
return "native";
|
|
17
|
+
return invocation?.effortSource ?? (invocation?.routeSource === "inherited" ? "native" : "dsmm-config");
|
|
18
|
+
}
|
|
8
19
|
/** Use the live provider owner and this call's complete frozen parameters, not envelope presence alone. */
|
|
9
20
|
export function requiresDsmmCallAdmission(config, classifier, uncapturedAgent) {
|
|
10
21
|
return uncapturedAgent !== undefined && classifyDsmmAgent(uncapturedAgent) === "dsmm"
|
|
@@ -107,7 +118,7 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
107
118
|
if (result.admission.agent !== frame.agent)
|
|
108
119
|
throw new LlmError("LLM admission belongs to another Agent", "INVALID_PREPARED_CALL");
|
|
109
120
|
this.active.get(frame.agent)?.revocation.abort();
|
|
110
|
-
const captured = { frame: Object.freeze({ ...frame }), admission: result.admission,
|
|
121
|
+
const captured = { frame: Object.freeze({ ...frame }), admission: result.admission, effortSource: result.effortSource ?? captureDsmmEffortSource(frame.agent),
|
|
111
122
|
...(result.kind === "dsmm" ? { generation: result.generation } : {}), revocation: new AbortController() };
|
|
112
123
|
this.active.set(frame.agent, captured);
|
|
113
124
|
const retire = () => {
|
|
@@ -167,7 +178,7 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
167
178
|
throw new LlmError("Enhanced requests require their exact Host proposal", "INVALID_PREPARED_CALL");
|
|
168
179
|
return config;
|
|
169
180
|
}
|
|
170
|
-
async prepareCall(proposal, signal) {
|
|
181
|
+
async prepareCall(proposal, signal, configure) {
|
|
171
182
|
const initiator = this.ctx.get("agents")?.currentInitiator();
|
|
172
183
|
if (initiator !== undefined && this.pending.has(initiator) && this.pending.get(initiator) !== proposal)
|
|
173
184
|
throw new LlmError("DSMM request lost its exact proposal identity", "INVALID_PREPARED_CALL");
|
|
@@ -176,14 +187,17 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
176
187
|
if (this.admitted.has(proposal))
|
|
177
188
|
throw new LlmError("DSMM proposal was already consumed", "INVALID_PREPARED_CALL");
|
|
178
189
|
const config = this.uncapturedNativeConfig(proposal, initiator, signal);
|
|
179
|
-
|
|
190
|
+
const prepared = await this.prepareNativeCall(config, signal, configure);
|
|
191
|
+
this.lifetime.signal.throwIfAborted();
|
|
192
|
+
signal?.throwIfAborted();
|
|
193
|
+
return prepared;
|
|
180
194
|
}
|
|
181
195
|
this.calls.delete(proposal);
|
|
182
196
|
this.pending.delete(captured.frame.agent);
|
|
183
197
|
try {
|
|
184
198
|
if (signal !== captured.frame.signal)
|
|
185
199
|
throw new LlmError("LLM request signal does not match admission", "INVALID_PREPARED_CALL");
|
|
186
|
-
return await this.prepareAdmittedCall(proposal, signal, captured);
|
|
200
|
+
return await this.prepareAdmittedCall(proposal, signal, captured, configure);
|
|
187
201
|
}
|
|
188
202
|
catch (error) {
|
|
189
203
|
// NO_ADAPTER is the official loop's signal to dispatch without a prepared call.
|
|
@@ -192,18 +206,39 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
192
206
|
throw error;
|
|
193
207
|
}
|
|
194
208
|
}
|
|
195
|
-
|
|
209
|
+
prepareNativeCall(config, signal, configure) {
|
|
210
|
+
const classifier = this.ctx.get("dsmmLlmRoutes");
|
|
211
|
+
const supportsStop = classifier?.supportsNativeStop?.(config.provider) ?? true;
|
|
212
|
+
const select = (controls, model) => {
|
|
213
|
+
const selected = configure === undefined ? controls : configure(controls, model);
|
|
214
|
+
const final = snapshotDsmmCall({ ...selected, provider: config.provider, model: config.model });
|
|
215
|
+
if (final.customParameters !== undefined || !supportsStop && final.stop !== undefined) {
|
|
216
|
+
throw new LlmError("Final controls require raw parameter admission before preparation", "UNSUPPORTED_ROUTE_PARAMETERS");
|
|
217
|
+
}
|
|
218
|
+
return selected;
|
|
219
|
+
};
|
|
220
|
+
return this.stock === undefined ? super.prepareCall(config, signal, select) : this.stock.prepareCall(config, signal, select);
|
|
221
|
+
}
|
|
222
|
+
async prepareAdmittedCall(proposal, signal, captured, configure) {
|
|
196
223
|
this.assertCaptured(captured);
|
|
197
224
|
if (captured.generation === undefined) {
|
|
198
225
|
const preparationSignal = AbortSignal.any([signal, captured.admission.signal, captured.revocation.signal, this.lifetime.signal]);
|
|
199
|
-
const prepared = await
|
|
226
|
+
const prepared = await this.prepareNativeCall(proposal, preparationSignal, configure);
|
|
200
227
|
this.assertCaptured(captured);
|
|
201
|
-
return this.bindPrepared(captured, signal, prepared, request => prepared.stream(request));
|
|
228
|
+
return this.bindPrepared(captured, signal, prepared, (request, providerSignal) => prepared.stream(Object.freeze({ ...request, signal: providerSignal })));
|
|
202
229
|
}
|
|
203
|
-
|
|
230
|
+
let streamEffortSource = captured.effortSource;
|
|
231
|
+
const preparationSignal = AbortSignal.any([signal, captured.admission.signal, captured.generation.signal, captured.revocation.signal, this.lifetime.signal]);
|
|
232
|
+
const bound = await captured.generation.prepareCall(proposal.provider, proposal.model, preparationSignal, () => this.assertCaptured(captured), () => streamEffortSource);
|
|
204
233
|
this.assertCaptured(captured);
|
|
205
234
|
if (bound.model.provider !== proposal.provider || bound.model.id !== proposal.model)
|
|
206
235
|
throw new LlmError("Provider resolved another model", "INVALID_ADAPTER");
|
|
236
|
+
if (configure !== undefined) {
|
|
237
|
+
const { provider, model, customParameters, ...controls } = proposal;
|
|
238
|
+
const selected = configure(freezeDsmmJson(controls), freezeDsmmJson(bound.model));
|
|
239
|
+
proposal = snapshotDsmmCall({ ...selected, provider, model, ...(customParameters === undefined ? {} : { customParameters }) });
|
|
240
|
+
this.assertCaptured(captured);
|
|
241
|
+
}
|
|
207
242
|
const customParameters = proposal.customParameters;
|
|
208
243
|
const defaultReasoningEffort = captured.generation.defaultReasoningEffort ?? bound.model.reasoning?.defaultEffort;
|
|
209
244
|
const adapterDefaults = Object.freeze({
|
|
@@ -212,6 +247,11 @@ export class DsmmAwareLlmRuntime extends LlmRuntime {
|
|
|
212
247
|
});
|
|
213
248
|
const config = snapshotDsmmCall({ ...proposal, ...(adapterDefaults.maxTokens ? { maxTokens: bound.model.defaultMaxTokens } : {}),
|
|
214
249
|
...(adapterDefaults.reasoningEffort ? { reasoningEffort: defaultReasoningEffort } : {}) });
|
|
250
|
+
if (adapterDefaults.reasoningEffort)
|
|
251
|
+
streamEffortSource = "native";
|
|
252
|
+
if (streamEffortSource === "native" && config.reasoningEffort !== undefined && !bound.model.reasoning?.efforts.some(effort => effort.id === config.reasoningEffort)) {
|
|
253
|
+
throw new LlmError("The native selection's reasoning effort is not supported by this model", "UNSUPPORTED_REASONING_EFFORT");
|
|
254
|
+
}
|
|
215
255
|
return this.bindPrepared(captured, signal, {
|
|
216
256
|
config, adapterDefaults, retryPolicy: freezeDsmmJson(captured.generation.retryPolicy),
|
|
217
257
|
...(bound.model.context === undefined ? {} : { context: freezeDsmmJson(bound.model.context) }),
|