@dsmm/dsmm 0.3.21 → 0.3.23
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 +4 -4
- package/agent-presets/dsmm-builder/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-code-search/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-coding/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-complex/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-creative/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-deep/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-documenting/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-frontend/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-oracle/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-planner/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-quick/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-research/agent.cordis.yml +1 -7
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +1 -7
- package/cordis.patch.yml +3 -0
- package/docs/compatibility.md +13 -1
- package/docs/maintenance.md +26 -7
- package/docs/model-routing.md +25 -3
- package/docs/native-permissions.md +20 -4
- package/docs/releasing.md +3 -3
- package/docs/roadmap.md +40 -8
- package/docs/runtime-recovery.md +5 -3
- package/docs/testing.md +10 -0
- package/docs/web-fetch-fakeip.md +8 -2
- package/dsh-plugin.json +1 -1
- package/lib/agent-prompt-scope.d.ts +6 -0
- package/lib/agent-prompt-scope.js +66 -0
- package/lib/client/RoleToolView-data.d.ts +4 -2
- package/lib/client/RoleToolView-data.js +18 -4
- package/lib/client/RoleToolView-locales.d.ts +4 -0
- package/lib/client/RoleToolView-locales.js +2 -0
- package/lib/client/RoleToolView.d.ts +9 -3
- package/lib/client/RoleToolView.js +27 -8
- package/lib/client/children-locales.d.ts +4 -4
- package/lib/client/index.js +6 -1
- package/lib/client/role-call-observations.d.ts +21 -0
- package/lib/client/role-call-observations.js +150 -0
- package/lib/client.js +401 -96
- package/lib/dsh-types.d.ts +15 -0
- package/lib/index.js +4 -1
- package/lib/live-pi-ai-owner.d.ts +1 -2
- package/lib/live-pi-ai-owner.js +10 -7
- package/lib/locale-guidance.d.ts +3 -0
- package/lib/locale-guidance.js +12 -0
- package/lib/model-family.d.ts +14 -0
- package/lib/model-family.js +138 -35
- package/lib/model-routing.d.ts +23 -2
- package/lib/model-routing.js +145 -7
- package/lib/native-admission.d.ts +36 -1
- package/lib/native-admission.js +408 -24
- package/lib/native-pi-ai-wire.js +17 -4
- package/lib/profile-remote.d.ts +2 -0
- package/lib/profile-remote.js +12 -3
- package/lib/profile-types.d.ts +5 -0
- package/lib/prompts.d.ts +3 -2
- package/lib/prompts.js +20 -38
- package/lib/role-control-remote.d.ts +5 -2
- package/lib/role-control-remote.js +84 -4
- package/lib/role-control-rpc.d.ts +8 -1
- package/lib/role-control-rpc.js +122 -50
- package/lib/role-control-types.d.ts +62 -1
- package/lib/role-control-types.js +3 -0
- package/lib/role-invocation.js +1 -1
- package/lib/role-llm-runtime.js +2 -2
- package/lib/role-routing.d.ts +27 -7
- package/lib/role-routing.js +129 -16
- package/lib/role-subagents.js +8 -23
- package/lib/runtime-recovery.js +23 -6
- package/lib/session-metadata.d.ts +13 -1
- package/lib/session-metadata.js +21 -1
- package/lib/web-fetch-address-policy.d.ts +6 -2
- package/lib/web-fetch-fakeip.d.ts +6 -0
- package/lib/web-fetch-fakeip.js +29 -2
- package/package.json +2 -2
- package/prompts/deepwork.md +0 -1
- package/prompts/source/deepwork/claude-opus-5.md +2 -8
- package/prompts/source/deepwork/codex.md +2 -8
- package/prompts/source/deepwork/gemini-4.md +1 -7
- package/prompts/source/deepwork/gemini.md +0 -6
- package/prompts/source/deepwork/glm.md +3 -10
- package/prompts/source/deepwork/gpt.md +16 -15
- package/prompts/source/deepwork/kimi.md +1 -7
- package/prompts/source/deepwork/planner.md +0 -4
- package/prompts/source/deepwork/swe-2.md +2 -8
- package/prompts/source/shared/dsh-host-contract.md +0 -1
- package/prompts/source/shared/locale.md +1 -6
package/lib/native-pi-ai-wire.js
CHANGED
|
@@ -9,6 +9,15 @@ import { LlmError, ReasoningEffortId, assertUsableApiKey, attributionHeaders, fr
|
|
|
9
9
|
import { singleUsePreparedStream, snapshotDsmmCall } from "./host-llm.js";
|
|
10
10
|
import { DsmmMissingProviderError, modelRouteToCall } from "./role-llm.js";
|
|
11
11
|
import { normalizeModelRouteJson } from "./route-json.js";
|
|
12
|
+
function imageOffloadProfileFields(profile) {
|
|
13
|
+
const extended = profile;
|
|
14
|
+
if (extended.maxRequestImages === undefined && extended.imageOffloadCountQuantum === undefined) {
|
|
15
|
+
// 0.2.1 profiles carry no image-offload fields and its adapter has no such contract.
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const maxRequestImages = extended.maxRequestImages ?? 50;
|
|
19
|
+
return { maxRequestImages, imageOffloadCountQuantum: extended.imageOffloadCountQuantum ?? Math.min(10, maxRequestImages) };
|
|
20
|
+
}
|
|
12
21
|
function normalizeDeclaredProfiles(config) {
|
|
13
22
|
const profiles = new Map();
|
|
14
23
|
const normalized = Config(config);
|
|
@@ -58,6 +67,7 @@ function normalizeDeclaredProfiles(config) {
|
|
|
58
67
|
apiKeyEnv: brandString(profile.apiKeyEnv),
|
|
59
68
|
streamIdleTimeoutMs: profile.streamIdleTimeoutMs, maxRequestImageBytes: profile.maxRequestImageBytes,
|
|
60
69
|
requestImagePixelBudget: profile.requestImagePixelBudget, requestImageMaxBytes: profile.requestImageMaxBytes,
|
|
70
|
+
...imageOffloadProfileFields(profile),
|
|
61
71
|
retryPolicy: resolveRetryPolicy(profile.retryPolicy?.mode === "normal" ? { ...profile.retryPolicy,
|
|
62
72
|
retryableCodes: profile.retryPolicy.retryableCodes === undefined ? undefined : [...profile.retryPolicy.retryableCodes] } : profile.retryPolicy, `dsmm.providers.${provider}.retryPolicy`), piProvider, modelErrors: new Map(),
|
|
63
73
|
configuredMaxTokens: new Map(profile.models.flatMap(model => model.maxTokens === undefined ? [] : [[model.id, model.maxTokens]])),
|
|
@@ -127,9 +137,12 @@ export function createDsmmPiAiProviderPlugin(options, ready) {
|
|
|
127
137
|
if (!isDeepStrictEqual(config.providers.get(), expected))
|
|
128
138
|
throw new LlmError("Cold provider entry differs from the Host-owned declaration", "INVALID_CONFIG");
|
|
129
139
|
ctx.effect(() => ctx.settings.configure({ auto: false }, ctx.fiber));
|
|
130
|
-
ctx.on("internal/config", function (
|
|
140
|
+
ctx.on("internal/config", function (first, next) {
|
|
131
141
|
const candidate = next();
|
|
132
|
-
|
|
142
|
+
// cordis 4.0.5 invokes this listener as (this: Fiber, rawConfig, next);
|
|
143
|
+
// 4.1.0 passes the fiber as the first argument and no raw config.
|
|
144
|
+
if ((this === ctx.fiber || first === ctx.fiber)
|
|
145
|
+
&& !isDeepStrictEqual(Config(candidate).providers.get(), expected))
|
|
133
146
|
throw new LlmError("Provider ownership changes require a cold Host restart", "INVALID_CONFIG");
|
|
134
147
|
return candidate;
|
|
135
148
|
});
|
|
@@ -169,10 +182,10 @@ export function createDsmmPiAiProviderOwner(ctx, options, borrowed) {
|
|
|
169
182
|
};
|
|
170
183
|
const resolveApiKey = (provider, profile) => resolveNamedKey(provider, profile, life.signal);
|
|
171
184
|
const adapterOptions = { profiles: () => profiles, resolveApiKey, auth: options.auth,
|
|
185
|
+
prepareHeaders: (request, headers) => ctx.waterfall("llm-pi-ai/request-headers", request, headers, () => headers),
|
|
172
186
|
resolveAttachments: () => ctx.get("attachments"),
|
|
173
187
|
resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, path => ctx.get("fs")?.processPathFromHostPath(path), ref),
|
|
174
|
-
onReplayDegrade: () => ctx.logger.warn("DSMM provider replay degraded to native content"),
|
|
175
|
-
};
|
|
188
|
+
onReplayDegrade: () => ctx.logger.warn("DSMM provider replay degraded to native content"), };
|
|
176
189
|
const stockStream = (request, preparationSignal) => {
|
|
177
190
|
assertCurrent();
|
|
178
191
|
const signal = AbortSignal.any([life.signal, ...request.signal === undefined ? [] : [request.signal], ...preparationSignal === undefined ? [] : [preparationSignal]]);
|
package/lib/profile-remote.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
2
|
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
3
|
import type { ProfileErrorInfo, ProfileReadResult, ProfileSaveRequest, ProfileSelectRequest, ProfileSnapshot, SessionModeSelectRequest, SessionProfileSelectRequest, SessionProfileSnapshot } from "./profile-types.js";
|
|
4
|
+
import type { DsmmRoleId } from "./roles.js";
|
|
4
5
|
import type { GlobalConfigSaveRequest, GlobalConfigSnapshot } from "./deployment-config.js";
|
|
5
6
|
import type { DsmmModuleState } from "./modules.js";
|
|
6
7
|
import type { DeploymentEditorSnapshot } from "./profile-types.js";
|
|
@@ -48,6 +49,7 @@ declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
|
48
49
|
export declare function isProfileId(value: unknown): value is string;
|
|
49
50
|
/** Opaque native identities are never interpreted as paths. */
|
|
50
51
|
export declare function isNativeSessionId(value: unknown): value is string;
|
|
52
|
+
export declare function parseDsmmRoleId(value: unknown): DsmmRoleId;
|
|
51
53
|
export declare function parseProfileErrorInfo(value: unknown): ProfileErrorInfo;
|
|
52
54
|
export declare function parseProfileDiagnostic(value: unknown): ProfileDiagnostic;
|
|
53
55
|
export declare function parseRoleAvailability(value: unknown): DsmmRoleAvailabilityState;
|
package/lib/profile-remote.js
CHANGED
|
@@ -74,11 +74,12 @@ function integer(value, field, maximum = Number.MAX_SAFE_INTEGER) {
|
|
|
74
74
|
fail(field);
|
|
75
75
|
return value;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
export function parseDsmmRoleId(value) {
|
|
78
78
|
if (typeof value !== "string" || !rolePattern.test(value))
|
|
79
79
|
fail("role");
|
|
80
80
|
return value;
|
|
81
81
|
}
|
|
82
|
+
const role = parseDsmmRoleId;
|
|
82
83
|
function object(value, required, optional = []) {
|
|
83
84
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
84
85
|
fail("object");
|
|
@@ -262,16 +263,24 @@ export function parseDsmmRoleRouteComparison(value) {
|
|
|
262
263
|
return { childId: sessionId(row.childId), initialRoute: initialRoleRoute(row.initialRoute), liveRoute: liveRoleRoute(row.liveRoute) };
|
|
263
264
|
}
|
|
264
265
|
export function parseDsmmInvocationView(value) {
|
|
265
|
-
const row = object(jsonData(value), ["role", "label", "level", "routeSource", "mode"], ["route", "runId", "childId", "jobId", "routeComparison"]);
|
|
266
|
+
const row = object(jsonData(value), ["role", "label", "level", "routeSource", "mode"], ["route", "runId", "childId", "jobId", "routeComparison", "delivery", "phase", "stopReason"]);
|
|
266
267
|
if (typeof row.level !== "string" || !["normal", "low", "high", "max"].includes(row.level) || !DSMM_ROUTE_SOURCES.includes(row.routeSource) || typeof row.mode !== "string" || !["one-shot", "continuable"].includes(row.mode))
|
|
267
268
|
fail("invocation");
|
|
269
|
+
if (Object.hasOwn(row, "delivery") && !["caller", "parent"].includes(row.delivery)
|
|
270
|
+
|| Object.hasOwn(row, "phase") && !["reserved", "active", "settled"].includes(row.phase)
|
|
271
|
+
|| Object.hasOwn(row, "stopReason") && !["completed", "aborted", "error", "max-tokens", "refusal"].includes(row.stopReason)
|
|
272
|
+
|| Object.hasOwn(row, "stopReason") && row.phase !== "settled")
|
|
273
|
+
fail("invocation lifecycle");
|
|
268
274
|
const target = role(row.role);
|
|
269
275
|
if (target === "dsmm-orchestrator")
|
|
270
276
|
fail("invocation target");
|
|
271
277
|
const routeComparison = Object.hasOwn(row, "routeComparison") ? parseDsmmRoleRouteComparison(row.routeComparison) : undefined;
|
|
272
278
|
if (routeComparison !== undefined && (!Object.hasOwn(row, "childId") || routeComparison.childId !== row.childId))
|
|
273
279
|
fail("invocation routeComparison childId");
|
|
274
|
-
return { role: target, label: text(row.label, "label", 120), level: row.level, routeSource: row.routeSource, mode: row.mode, ...optional(row, "route", modelRoute), ...optional(row, "runId", sessionId), ...optional(row, "childId", sessionId), ...optional(row, "jobId", sessionId), ...(routeComparison === undefined ? {} : { routeComparison })
|
|
280
|
+
return { role: target, label: text(row.label, "label", 120), level: row.level, routeSource: row.routeSource, mode: row.mode, ...optional(row, "route", modelRoute), ...optional(row, "runId", sessionId), ...optional(row, "childId", sessionId), ...optional(row, "jobId", sessionId), ...(routeComparison === undefined ? {} : { routeComparison }),
|
|
281
|
+
...(Object.hasOwn(row, "delivery") ? { delivery: row.delivery } : {}),
|
|
282
|
+
...(Object.hasOwn(row, "phase") ? { phase: row.phase } : {}),
|
|
283
|
+
...(Object.hasOwn(row, "stopReason") ? { stopReason: row.stopReason } : {}) };
|
|
275
284
|
}
|
|
276
285
|
function selectionState(value) {
|
|
277
286
|
const item = object(value, ["selectedId", "appliedRevision", "selectionRevision"], ["sourceRevision", "refreshRequired"]);
|
package/lib/profile-types.d.ts
CHANGED
|
@@ -40,6 +40,11 @@ export interface DsmmInvocationView {
|
|
|
40
40
|
childId?: string;
|
|
41
41
|
jobId?: string;
|
|
42
42
|
routeComparison?: DsmmRoleRouteComparison;
|
|
43
|
+
/** Native activation delivery is independent of whether the child is continuable. */
|
|
44
|
+
delivery?: "caller" | "parent";
|
|
45
|
+
/** Exact observation phase for this invocation, when a live call correlation supplied it. */
|
|
46
|
+
phase?: "reserved" | "active" | "settled";
|
|
47
|
+
stopReason?: "completed" | "aborted" | "error" | "max-tokens" | "refusal";
|
|
43
48
|
}
|
|
44
49
|
export interface SubagentRuntimeAdmissionView {
|
|
45
50
|
binding: "stock" | "unavailable";
|
package/lib/prompts.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SourceRoleContent } from "./prompt-content.js";
|
|
|
4
4
|
import type { DsmmSettings } from "./settings.js";
|
|
5
5
|
import type { DsmmInvocationView, DsmmRoleAvailabilityState, SubagentRuntimeAdmissionView } from "./profile-types.js";
|
|
6
6
|
import type { DsmmCallableEntry } from "./role-subagents.js";
|
|
7
|
+
export { buildDsmmLocaleGuidance } from "./locale-guidance.js";
|
|
7
8
|
export { SOURCE_ROLE_CATALOG, buildRolePersona } from "./prompt-content.js";
|
|
8
9
|
export type { SourceRoleContent } from "./prompt-content.js";
|
|
9
10
|
export declare const BASE_DEEPWORK_PROMPT: string;
|
|
@@ -37,8 +38,8 @@ export interface DsmmPromptObservation {
|
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
/** Render callable delegation and lifecycle observations without repeating Agent locale. */
|
|
42
|
+
export declare function buildDsmmDelegationGuidance(settings: DsmmSettings, observed: DsmmPromptObservation): string;
|
|
42
43
|
export declare function buildDsmmAgentGuidance(settings: DsmmSettings, observed: DsmmPromptObservation): string;
|
|
43
44
|
export declare function buildDeepworkPrompt(settings: DsmmSettings, options?: DeepworkPromptOptions): string;
|
|
44
45
|
//# sourceMappingURL=prompts.d.ts.map
|
package/lib/prompts.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { readPromptAsset as asset, readSharedPromptAsset, SOURCE_ROLE_CATALOG, splitCategory } from "./prompt-content.js";
|
|
2
|
+
import { recognizeModelName } from "./model-family.js";
|
|
3
|
+
import { buildDsmmLocaleGuidance } from "./locale-guidance.js";
|
|
4
|
+
export { buildDsmmLocaleGuidance } from "./locale-guidance.js";
|
|
2
5
|
export { SOURCE_ROLE_CATALOG, buildRolePersona } from "./prompt-content.js";
|
|
3
6
|
const activation = `<dsmm-deepwork-mode>
|
|
4
7
|
Use this workflow only while the \`{{modeName}}\` mode is effectively active. This is an opt-in boundary: ordinary presets default off; DW roles default on, but explicit off wins and retains only persona/access. Never force common workflow or skills on merely from a role name.
|
|
@@ -8,26 +11,13 @@ Understand the requested outcome and relevant facts first. Load the full \`brain
|
|
|
8
11
|
</dsmm-deepwork-mode>`;
|
|
9
12
|
const commonDeepworkPrompt = [activation, asset("deepwork/default.md"), asset("shared/shell-safety.md"), asset("shared/dsh-host-contract.md")].join("\n\n---\n\n");
|
|
10
13
|
export const BASE_DEEPWORK_PROMPT = [commonDeepworkPrompt, readSharedPromptAsset("avoid-ai-slop.md")].join("\n\n---\n\n");
|
|
11
|
-
// Prompt-only matching is independent of model-family routing and effort parameters.
|
|
12
|
-
function modelName(fullId) {
|
|
13
|
-
const name = fullId.slice(fullId.lastIndexOf("/") + 1).toLowerCase();
|
|
14
|
-
const vendors = { openai: /^(?:gpt-|o\d|chatgpt-|codex-)/u, anthropic: /^claude-/u, google: /^gemini-/u, zhipu: /^glm-/u, deepseek: /^deepseek-/u };
|
|
15
|
-
const parts = name.split("."), direct = parts.slice(1).join("."), regional = parts.slice(2).join(".");
|
|
16
|
-
if (vendors[parts[0]]?.test(direct))
|
|
17
|
-
return direct;
|
|
18
|
-
if (/^(?:global|[a-z]{2}|[a-z]{2}-[a-z]+-\d+)$/u.test(parts[0]) && vendors[parts[1]]?.test(regional))
|
|
19
|
-
return regional;
|
|
20
|
-
return name;
|
|
21
|
-
}
|
|
22
14
|
export function promptModelVariants(role, model) {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const base = role === "planner" ? "planner" : role === "orchestrator" && opus ? "claude-opus-5"
|
|
30
|
-
: model.toLowerCase().includes("codex") ? "codex" : gpt ? "gpt" : name.startsWith("gemini-") ? "gemini" : name.includes("glm") ? "glm" : "default";
|
|
15
|
+
const recognized = recognizeModelName(model);
|
|
16
|
+
const identifier = recognized?.identifier;
|
|
17
|
+
const gpt = identifier === "gpt" || identifier === "codex";
|
|
18
|
+
const additive = gpt ? ["gpt"] : identifier === "kimi" ? ["kimi"] : recognized?.gemini4 ? ["gemini-4"] : identifier === "swe-2" ? ["swe-2"] : [];
|
|
19
|
+
const base = role === "planner" ? "planner" : role === "orchestrator" && recognized?.opus5 ? "claude-opus-5"
|
|
20
|
+
: recognized?.family === "codex" ? "codex" : gpt ? "gpt" : identifier === "gemini" ? "gemini" : identifier === "glm" ? "glm" : "default";
|
|
31
21
|
return [...new Set([base, ...additive])].filter((variant) => variant !== "default");
|
|
32
22
|
}
|
|
33
23
|
export function roleModelCalibration(role, model) {
|
|
@@ -35,40 +25,29 @@ export function roleModelCalibration(role, model) {
|
|
|
35
25
|
const layers = variants.map((variant) => asset(`deepwork/${variant}.md`));
|
|
36
26
|
if (role?.kind === "category" && role.promptArtifact !== null) {
|
|
37
27
|
const category = splitCategory(asset(role.promptArtifact.replace("prompts/source/", "")));
|
|
38
|
-
const
|
|
39
|
-
const family =
|
|
28
|
+
const identifier = recognizeModelName(model)?.identifier;
|
|
29
|
+
const family = identifier === "gpt" || identifier === "codex" ? "gpt"
|
|
30
|
+
: identifier === "gemini" || identifier === "glm" || identifier === "claude" ? identifier : "unknown";
|
|
40
31
|
// Categories carry only their own family layer + additive model calibration,
|
|
41
32
|
// not the base-agent Gemini/GLM/planner workflow variants.
|
|
42
33
|
return [category.calibrations.get(family), ...layers.filter((_layer, index) => ["gpt", "kimi", "gemini-4", "swe-2"].includes(variants[index]))].filter(Boolean).join("\n\n---\n\n");
|
|
43
34
|
}
|
|
44
35
|
return layers.join("\n\n---\n\n");
|
|
45
36
|
}
|
|
46
|
-
const localeNames = {
|
|
47
|
-
en: "English", "zh-Hans": "Simplified Chinese", "zh-Hant": "Traditional Chinese", ja: "Japanese", ko: "Korean",
|
|
48
|
-
de: "German", fr: "French", es: "Spanish", "pt-BR": "Brazilian Portuguese", ru: "Russian"
|
|
49
|
-
};
|
|
50
|
-
export function buildDsmmLocaleGuidance(settings) {
|
|
51
|
-
return `<dsmm-visible-output-language>
|
|
52
|
-
${JSON.stringify({ capturedLocale: settings.locale ?? null, visibleOutputLanguage: settings.locale === undefined ? null : localeNames[settings.locale] })}
|
|
53
|
-
${settings.locale === undefined ? "No DSMM locale is captured; inherit applicable host/user language guidance, otherwise use the current request and conversation context." : `This Agent's immutable captured locale is ${settings.locale} (${localeNames[settings.locale]}). Use it as the default for visible replies, plans and role/category output.`}
|
|
54
|
-
The current user's explicit output-language request takes precedence. Preserve that instruction in child assignments. A parent's later profile change does not rewrite this child's captured preference. Preserve code, identifiers, commands, paths, protocol fields and exact quotations verbatim. This affects visible output only: it neither promises an internal reasoning language nor changes the host UI/project locale. Do not infer configuration or authority with natural-language matching.
|
|
55
|
-
</dsmm-visible-output-language>`;
|
|
56
|
-
}
|
|
57
37
|
function toolProperties(tool) {
|
|
58
38
|
return (tool.parameters.properties ?? {});
|
|
59
39
|
}
|
|
60
40
|
// Output projection must not serialize credentials/extra properties on structurally compatible DTOs.
|
|
61
41
|
function projectInvocation({ routeKind, view }) {
|
|
62
42
|
return { routeKind, view: {
|
|
63
|
-
role: view.role,
|
|
64
|
-
...(view.route === undefined ? {} : { route: {
|
|
65
|
-
...(view.route.reasoningEffort === undefined ? {} : { reasoningEffort: view.route.reasoningEffort }) } }),
|
|
43
|
+
role: view.role, level: view.level, routeSource: view.routeSource, mode: view.mode,
|
|
44
|
+
...(view.route?.reasoningEffort === undefined ? {} : { route: { reasoningEffort: view.route.reasoningEffort } }),
|
|
66
45
|
...(view.runId === undefined ? {} : { runId: view.runId }), ...(view.childId === undefined ? {} : { childId: view.childId }),
|
|
67
46
|
...(view.jobId === undefined ? {} : { jobId: view.jobId })
|
|
68
47
|
} };
|
|
69
48
|
}
|
|
70
|
-
/**
|
|
71
|
-
export function
|
|
49
|
+
/** Render callable delegation and lifecycle observations without repeating Agent locale. */
|
|
50
|
+
export function buildDsmmDelegationGuidance(settings, observed) {
|
|
72
51
|
const availability = new Map(observed.roleAvailability?.map(row => [row.id, row]));
|
|
73
52
|
const delegation = observed.delegation.flatMap(entry => {
|
|
74
53
|
const tool = observed.tools.find(tool => tool.name === entry.name);
|
|
@@ -106,7 +85,7 @@ export function buildDsmmAgentGuidance(settings, observed) {
|
|
|
106
85
|
browserPromptSurface: liveDelivery ? observed.capabilities?.nativeBrowserPrompt?.surface ?? null : null,
|
|
107
86
|
...(runtime === undefined ? {} : { runtimeAdmission: runtime })
|
|
108
87
|
};
|
|
109
|
-
const sections = [
|
|
88
|
+
const sections = [`<dsmm-admitted-delegation>
|
|
110
89
|
${JSON.stringify({ scope: observed.scope, topology: settings.subagents.toolTopology, delegation,
|
|
111
90
|
controls: controls.map(tool => ({ tool: tool.name, parameters: Object.keys(toolProperties(tool)) })),
|
|
112
91
|
...(observed.roleAvailability === undefined ? {} : { roleAvailability: observed.roleAvailability.map(row => ({ id: row.id, admitted: row.admitted, ...(row.reason === undefined ? {} : { reason: row.reason }) })) }) }, null, 2)}
|
|
@@ -128,6 +107,9 @@ Native capacity/depth, provider support, direct-parent ownership, captured permi
|
|
|
128
107
|
</dsmm-child-lifecycle>`);
|
|
129
108
|
return sections.join("\n\n---\n\n");
|
|
130
109
|
}
|
|
110
|
+
export function buildDsmmAgentGuidance(settings, observed) {
|
|
111
|
+
return [buildDsmmLocaleGuidance(settings), buildDsmmDelegationGuidance(settings, observed)].join("\n\n---\n\n");
|
|
112
|
+
}
|
|
131
113
|
export function buildDeepworkPrompt(settings, options = {}) {
|
|
132
114
|
const role = SOURCE_ROLE_CATALOG.find((role) => role.id === (options.roleId === undefined ? options.selectedPreset : options.roleId));
|
|
133
115
|
const common = role === undefined ? commonDeepworkPrompt : [activation, asset("deepwork/default.md")].join("\n\n---\n\n");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { RemoteResult, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
1
|
+
import type { RemoteResult, RemoteStreamHandle, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
2
|
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
-
import type { ChildSessionSnapshot, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlErrorInfo, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
|
|
3
|
+
import type { ChildSessionSnapshot, RoleCallObservationFrame, RoleControlCapabilities, RoleControlDescendantsSnapshot, RoleControlErrorInfo, RoleControlInterruptRequest, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "./role-control-types.js";
|
|
4
4
|
export interface DsmmChildrenRemote {
|
|
5
|
+
observe(sessionId: string, signal?: AbortSignal): RemoteStreamHandle<RoleCallObservationFrame, never>;
|
|
5
6
|
describe(sessionId: string): Promise<RemoteResult<ChildSessionSnapshot>>;
|
|
6
7
|
descendants(sessionId: string): Promise<RemoteResult<RoleControlDescendantsSnapshot>>;
|
|
7
8
|
prompt(sessionId: string, request: SubagentPromptRequest): Promise<RemoteResult<SubagentPromptReceipt>>;
|
|
@@ -9,6 +10,7 @@ export interface DsmmChildrenRemote {
|
|
|
9
10
|
}
|
|
10
11
|
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
11
12
|
interface TypertRemoteMap {
|
|
13
|
+
"dsmmChildren/observe": DsmmChildrenRemote["observe"];
|
|
12
14
|
"dsmmChildren/describe": DsmmChildrenRemote["describe"];
|
|
13
15
|
"dsmmChildren/descendants": DsmmChildrenRemote["descendants"];
|
|
14
16
|
"dsmmChildren/prompt": DsmmChildrenRemote["prompt"];
|
|
@@ -21,6 +23,7 @@ declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
|
21
23
|
"dsmm-children/refused": RoleControlErrorInfo;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
export declare const parseRoleCallObservationFrame: (value: unknown) => RoleCallObservationFrame;
|
|
24
27
|
export declare const parseRoleControlErrorInfo: (value: unknown) => RoleControlErrorInfo;
|
|
25
28
|
export declare const parseChildSessionSnapshot: (value: unknown) => ChildSessionSnapshot;
|
|
26
29
|
export declare const parseRoleControlDescendants: (value: unknown) => RoleControlDescendantsSnapshot;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { parseDsmmInvocationView, parseDsmmRoleRouteComparison, parseSubagentRuntimeAdmissionView, isNativeSessionId } from "./profile-remote.js";
|
|
2
|
-
import { ROLE_CONTROL_DISABLED_REASONS, ROLE_CONTROL_ERROR_CODES, ROLE_CONTROL_ERROR_FIELDS } from "./role-control-types.js";
|
|
1
|
+
import { parseDsmmInvocationView, parseDsmmRoleId, parseDsmmRoleRouteComparison, parseSubagentRuntimeAdmissionView, isNativeSessionId } from "./profile-remote.js";
|
|
2
|
+
import { ROLE_CALL_DELIVERIES, ROLE_CALL_PHASES, ROLE_CALL_STOP_REASONS, ROLE_CONTROL_DISABLED_REASONS, ROLE_CONTROL_ERROR_CODES, ROLE_CONTROL_ERROR_FIELDS } from "./role-control-types.js";
|
|
3
|
+
import { DSMM_ROUTE_SOURCES } from "./profile-types.js";
|
|
3
4
|
function fail() { throw new TypeError("Invalid Deepwork child control DTO."); }
|
|
4
5
|
/** Reject executable/non-JSON shapes before accessing any properties. */
|
|
5
6
|
function json(value, depth = 0, active = new Set()) {
|
|
@@ -87,6 +88,82 @@ function child(value) {
|
|
|
87
88
|
controls: { prompt, interrupt }, ...(Object.hasOwn(row, "label") ? { label: text(row.label, 120) } : {}),
|
|
88
89
|
...(invocation === undefined ? {} : { invocation }), ...(routeComparison === undefined ? {} : { routeComparison }) };
|
|
89
90
|
}
|
|
91
|
+
function callIdentity(value) { const valueText = text(value, 512); if (valueText.length === 0)
|
|
92
|
+
fail(); return valueText; }
|
|
93
|
+
function observedRoute(value) {
|
|
94
|
+
const row = object(value, ["provider", "model"], ["reasoningEffort"]);
|
|
95
|
+
const provider = text(row.provider, 1024), model = text(row.model, 4096);
|
|
96
|
+
const reasoningEffort = Object.hasOwn(row, "reasoningEffort") ? text(row.reasoningEffort, 128) : undefined;
|
|
97
|
+
if (provider.length === 0 || model.length === 0 || reasoningEffort === "")
|
|
98
|
+
fail();
|
|
99
|
+
return { provider, model, ...(reasoningEffort === undefined ? {} : { reasoningEffort }) };
|
|
100
|
+
}
|
|
101
|
+
function observedInitialRoute(value) {
|
|
102
|
+
const row = object(value, ["status"], ["source", "route", "reason"]);
|
|
103
|
+
if (row.status === "known") {
|
|
104
|
+
object(row, ["status", "source", "route"]);
|
|
105
|
+
if (row.source !== "invocation-capture")
|
|
106
|
+
fail();
|
|
107
|
+
return { status: "known", source: "invocation-capture", route: observedRoute(row.route) };
|
|
108
|
+
}
|
|
109
|
+
object(row, ["status", "reason"]);
|
|
110
|
+
if (row.status !== "unknown" || row.reason !== "missing-invocation-capture")
|
|
111
|
+
fail();
|
|
112
|
+
return { status: "unknown", reason: "missing-invocation-capture" };
|
|
113
|
+
}
|
|
114
|
+
function observedActualRoute(value) {
|
|
115
|
+
const row = object(value, ["status"], ["source", "route", "reason"]);
|
|
116
|
+
if (row.status === "known") {
|
|
117
|
+
object(row, ["status", "source", "route"]);
|
|
118
|
+
if (row.source !== "own-native-request-header")
|
|
119
|
+
fail();
|
|
120
|
+
return { status: "known", source: "own-native-request-header", route: observedRoute(row.route) };
|
|
121
|
+
}
|
|
122
|
+
object(row, ["status", "reason"]);
|
|
123
|
+
if (row.status !== "unknown" || !["no-own-request-header", "invalid-own-request-header", "not-observed"].includes(row.reason))
|
|
124
|
+
fail();
|
|
125
|
+
return { status: "unknown", reason: row.reason };
|
|
126
|
+
}
|
|
127
|
+
function roleCall(value) {
|
|
128
|
+
const row = object(value, ["parentSessionId", "parentAdmissionEpoch", "callId", "rootCallId", "childId", "role", "level", "routeSource", "initialRoute", "actualRoute", "phase", "delivery"], ["childAdmissionEpoch", "runId", "stopReason"]);
|
|
129
|
+
const role = parseDsmmRoleId(row.role);
|
|
130
|
+
if (role === "dsmm-orchestrator")
|
|
131
|
+
fail();
|
|
132
|
+
const childId = identity(row.childId), initialRoute = observedInitialRoute(row.initialRoute), actualRoute = observedActualRoute(row.actualRoute);
|
|
133
|
+
const phase = choice(row.phase, ROLE_CALL_PHASES), delivery = choice(row.delivery, ROLE_CALL_DELIVERIES);
|
|
134
|
+
const stopReason = Object.hasOwn(row, "stopReason") ? choice(row.stopReason, ROLE_CALL_STOP_REASONS) : undefined;
|
|
135
|
+
if (stopReason !== undefined && phase !== "settled")
|
|
136
|
+
fail();
|
|
137
|
+
return { parentSessionId: identity(row.parentSessionId), parentAdmissionEpoch: epoch(row.parentAdmissionEpoch),
|
|
138
|
+
...(Object.hasOwn(row, "childAdmissionEpoch") ? { childAdmissionEpoch: epoch(row.childAdmissionEpoch) } : {}),
|
|
139
|
+
callId: callIdentity(row.callId), rootCallId: callIdentity(row.rootCallId), childId,
|
|
140
|
+
...(Object.hasOwn(row, "runId") ? { runId: identity(row.runId) } : {}), role,
|
|
141
|
+
level: choice(row.level, ["normal", "low", "high", "max"]), routeSource: choice(row.routeSource, DSMM_ROUTE_SOURCES),
|
|
142
|
+
initialRoute, actualRoute, phase, delivery,
|
|
143
|
+
...(stopReason === undefined ? {} : { stopReason }) };
|
|
144
|
+
}
|
|
145
|
+
function observationFrame(value) {
|
|
146
|
+
const row = object(value, ["type", "sessionId", "admissionEpoch"], ["calls", "call", "callId"]), sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch);
|
|
147
|
+
if (row.type === "snapshot") {
|
|
148
|
+
object(row, ["type", "sessionId", "admissionEpoch", "calls"]);
|
|
149
|
+
const calls = array(row.calls).map(roleCall);
|
|
150
|
+
if (calls.some(call => call.parentSessionId !== sessionId || call.parentAdmissionEpoch !== admissionEpoch)
|
|
151
|
+
|| new Set(calls.map(call => call.callId)).size !== calls.length)
|
|
152
|
+
fail();
|
|
153
|
+
return { type: "snapshot", sessionId, admissionEpoch, calls };
|
|
154
|
+
}
|
|
155
|
+
if (row.type === "update") {
|
|
156
|
+
object(row, ["type", "sessionId", "admissionEpoch", "call"]);
|
|
157
|
+
const call = roleCall(row.call);
|
|
158
|
+
if (call.parentSessionId !== sessionId || call.parentAdmissionEpoch !== admissionEpoch)
|
|
159
|
+
fail();
|
|
160
|
+
return { type: "update", sessionId, admissionEpoch, call };
|
|
161
|
+
}
|
|
162
|
+
object(row, ["type", "sessionId", "admissionEpoch", "callId"]);
|
|
163
|
+
if (row.type !== "remove")
|
|
164
|
+
fail();
|
|
165
|
+
return { type: "remove", sessionId, admissionEpoch, callId: callIdentity(row.callId) };
|
|
166
|
+
}
|
|
90
167
|
function snapshot(value) {
|
|
91
168
|
const row = object(value, ["sessionId", "admissionEpoch", "children", "capabilities"]);
|
|
92
169
|
const sessionId = identity(row.sessionId), admissionEpoch = epoch(row.admissionEpoch), children = array(row.children).map(child);
|
|
@@ -156,6 +233,7 @@ function errorInfo(value) {
|
|
|
156
233
|
return { code: choice(row.code, ROLE_CONTROL_ERROR_CODES), ...(Object.hasOwn(row, "field") ? { field: choice(row.field, ROLE_CONTROL_ERROR_FIELDS) } : {}),
|
|
157
234
|
...(Object.hasOwn(row, "reason") ? { reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) } : {}) };
|
|
158
235
|
}
|
|
236
|
+
export const parseRoleCallObservationFrame = (value) => observationFrame(json(value));
|
|
159
237
|
export const parseRoleControlErrorInfo = (value) => errorInfo(json(value));
|
|
160
238
|
export const parseChildSessionSnapshot = (value) => snapshot(json(value));
|
|
161
239
|
export const parseRoleControlDescendants = (value) => descendants(json(value));
|
|
@@ -166,13 +244,15 @@ export const parseRoleControlSessionId = (value) => identity(value);
|
|
|
166
244
|
function codec(symbol, parse) {
|
|
167
245
|
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: value => parse(json(value)) }) };
|
|
168
246
|
}
|
|
169
|
-
function descriptor(method, result, request) {
|
|
170
|
-
return { id: `@dsmm/dsmm-children#dsmmChildren/${method}`, service: "dsmmChildren", namespace: "dsmmChildren", method,
|
|
247
|
+
function descriptor(method, result, request, stream = false) {
|
|
248
|
+
return { id: `@dsmm/dsmm-children#dsmmChildren/${method}`, service: "dsmmChildren", namespace: "dsmmChildren", method,
|
|
249
|
+
...(stream ? { mode: "stream", cancellation: { parameter: "signal" } } : {}), invocation: { kind: "direct" },
|
|
171
250
|
parameters: [{ name: "sessionId", wire: "sessionId", source: "json", codec: codec("ChildControlSessionId", identity) },
|
|
172
251
|
...(request === undefined ? [] : [{ name: "request", wire: "request", source: "json", codec: request }])], result };
|
|
173
252
|
}
|
|
174
253
|
/** Separate package identity prevents replacing the Profiles contribution. */
|
|
175
254
|
export const ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
|
|
255
|
+
descriptor("observe", codec("RoleCallObservationFrame", observationFrame), undefined, true),
|
|
176
256
|
descriptor("describe", codec("ChildSessionSnapshot", snapshot)),
|
|
177
257
|
descriptor("descendants", codec("RoleControlDescendantsSnapshot", descendants)),
|
|
178
258
|
descriptor("prompt", codec("SubagentPromptReceipt", promptReceipt), codec("SubagentPromptRequest", promptRequest)),
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
+
import type { RemoteStream } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
4
|
import type { NativeAdmission } from "./native-admission.js";
|
|
4
|
-
import type { ChildSessionSnapshot, RoleControlDescendantsSnapshot, RoleControlInterruptRequest, SubagentPromptRequest, SubagentPromptReceipt, SubagentInterruptReceipt } from "./role-control-types.js";
|
|
5
|
+
import type { ChildSessionSnapshot, RoleCallObservationFrame, RoleControlDescendantsSnapshot, RoleControlInterruptRequest, SubagentPromptRequest, SubagentPromptReceipt, SubagentInterruptReceipt } from "./role-control-types.js";
|
|
5
6
|
/** Authenticated projection of the native catalog. Listing never wakes a session. */
|
|
6
7
|
export declare class DsmmChildrenHost extends TypertRemoteService {
|
|
7
8
|
private readonly admission;
|
|
8
9
|
private readonly lifetime;
|
|
9
10
|
constructor(ctx: Context, admission: NativeAdmission);
|
|
11
|
+
private openScope;
|
|
12
|
+
private observationRoot;
|
|
13
|
+
private openObservationScope;
|
|
14
|
+
private refusal;
|
|
10
15
|
private scoped;
|
|
11
16
|
private capabilities;
|
|
12
17
|
private child;
|
|
18
|
+
observe(sessionId: string, signal: AbortSignal): RemoteStream<RoleCallObservationFrame>;
|
|
19
|
+
private followObservedCalls;
|
|
13
20
|
describe(sessionId: string): Promise<ChildSessionSnapshot>;
|
|
14
21
|
descendants(sessionId: string): Promise<RoleControlDescendantsSnapshot>;
|
|
15
22
|
private direct;
|