@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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getTraceable, symbols } from "@deepseek-ai/cordis";
|
|
2
|
+
import { buildDsmmLocaleGuidance } from "./locale-guidance.js";
|
|
3
|
+
import { agentForScope, nativeAgentContext } from "./native-scope.js";
|
|
4
|
+
import { registerRoleHarnessIdentity } from "./role-identity.js";
|
|
5
|
+
const agentPrompts = new WeakMap();
|
|
6
|
+
export function registerAgentPromptScope(ctx, controller, getSettings, policy, agent, signal) {
|
|
7
|
+
signal.throwIfAborted();
|
|
8
|
+
const existing = agentPrompts.get(agent);
|
|
9
|
+
if (existing !== undefined) {
|
|
10
|
+
existing.reconcile();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const agentCtx = nativeAgentContext(agent);
|
|
14
|
+
let retired = false;
|
|
15
|
+
const state = { reconcile() {
|
|
16
|
+
if (retired)
|
|
17
|
+
return;
|
|
18
|
+
const prompt = agentCtx.get("agentPresets")?.serviceFor({ ctx: agentCtx }, "systemPrompt") ?? agentCtx.get("systemPrompt");
|
|
19
|
+
const realm = Reflect.get(prompt, symbols.original) ?? prompt;
|
|
20
|
+
if (state.promptRealm !== realm) {
|
|
21
|
+
state.identity?.();
|
|
22
|
+
state.locale?.();
|
|
23
|
+
state.identity = undefined;
|
|
24
|
+
state.role = undefined;
|
|
25
|
+
state.child = undefined;
|
|
26
|
+
state.locale = getTraceable(agentCtx, prompt).section({ name: "dsmm:locale", order: 49, text(context) {
|
|
27
|
+
if (context.scope !== agent && agentForScope(ctx, context.scope) !== agent)
|
|
28
|
+
return "";
|
|
29
|
+
const settings = getSettings(agent);
|
|
30
|
+
return settings.locale === undefined ? "" : buildDsmmLocaleGuidance(settings);
|
|
31
|
+
} });
|
|
32
|
+
state.promptRealm = realm;
|
|
33
|
+
}
|
|
34
|
+
const identity = policy.identity(agent);
|
|
35
|
+
if (state.role === identity.role && state.child === identity.child)
|
|
36
|
+
return;
|
|
37
|
+
state.identity?.();
|
|
38
|
+
state.identity = identity.role === undefined ? undefined : registerRoleHarnessIdentity(agent, identity.role, identity.child);
|
|
39
|
+
state.role = identity.role;
|
|
40
|
+
state.child = identity.child;
|
|
41
|
+
} };
|
|
42
|
+
const retire = () => {
|
|
43
|
+
if (retired)
|
|
44
|
+
return;
|
|
45
|
+
retired = true;
|
|
46
|
+
signal.removeEventListener("abort", retire);
|
|
47
|
+
state.stopMode?.();
|
|
48
|
+
state.identity?.();
|
|
49
|
+
state.locale?.();
|
|
50
|
+
if (agentPrompts.get(agent) === state)
|
|
51
|
+
agentPrompts.delete(agent);
|
|
52
|
+
};
|
|
53
|
+
state.stopMode = controller.watch(changed => { if (changed === agent)
|
|
54
|
+
state.reconcile(); });
|
|
55
|
+
agentPrompts.set(agent, state);
|
|
56
|
+
signal.addEventListener("abort", retire, { once: true });
|
|
57
|
+
agentCtx.effect(() => retire);
|
|
58
|
+
try {
|
|
59
|
+
state.reconcile();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
retire();
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=agent-prompt-scope.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DsmmInvocationView } from "../profile-types.js";
|
|
2
|
+
import type { RoleCallObservation } from "../role-control-types.js";
|
|
2
3
|
import type { ToolArgs } from "@deepseek-ai/dsh-client-ui-conversation/client";
|
|
3
4
|
/** Presentation keys only; this table does not describe callable admission. */
|
|
4
5
|
export declare const roleToolKeys: {
|
|
@@ -31,12 +32,13 @@ export declare function preparingRoleTool(toolName: string, args: ToolArgs): {
|
|
|
31
32
|
preview: string;
|
|
32
33
|
};
|
|
33
34
|
export declare function actualRoleTool(toolName: string, meta: unknown, failed: boolean): DsmmInvocationView | undefined;
|
|
35
|
+
export declare function observedRoleTool(toolName: string, observation: RoleCallObservation): DsmmInvocationView | undefined;
|
|
34
36
|
export declare function roleToolDisplay(target: string): string;
|
|
35
37
|
export interface TechnicalRow {
|
|
36
38
|
property: string;
|
|
37
39
|
value: unknown;
|
|
38
40
|
isComplex: boolean;
|
|
39
41
|
}
|
|
40
|
-
export declare function technicalTableRows(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string): TechnicalRow[];
|
|
41
|
-
export declare function technicalJsonData(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string): Record<string, unknown>;
|
|
42
|
+
export declare function technicalTableRows(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string, observation?: RoleCallObservation): TechnicalRow[];
|
|
43
|
+
export declare function technicalJsonData(toolName: string, callId: string, rawArgs: string, meta?: unknown, routeSource?: string, observation?: RoleCallObservation): Record<string, unknown>;
|
|
42
44
|
//# sourceMappingURL=RoleToolView-data.d.ts.map
|
|
@@ -48,10 +48,21 @@ export function actualRoleTool(toolName, meta, failed) {
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
export function observedRoleTool(toolName, observation) {
|
|
52
|
+
if (!(toolName === "dsmm_category" ? categories : roles).has(observation.role))
|
|
53
|
+
return undefined;
|
|
54
|
+
return { role: observation.role, label: roleToolDisplay(observation.role), level: observation.level,
|
|
55
|
+
routeSource: observation.routeSource, mode: "continuable", childId: observation.childId,
|
|
56
|
+
...(observation.runId === undefined ? {} : { runId: observation.runId }),
|
|
57
|
+
...(observation.initialRoute.status === "known" ? { route: { ...observation.initialRoute.route } } : {}),
|
|
58
|
+
routeComparison: { childId: observation.childId, initialRoute: observation.initialRoute, liveRoute: observation.actualRoute },
|
|
59
|
+
delivery: observation.delivery, phase: observation.phase,
|
|
60
|
+
...(observation.stopReason === undefined ? {} : { stopReason: observation.stopReason }) };
|
|
61
|
+
}
|
|
51
62
|
export function roleToolDisplay(target) {
|
|
52
63
|
return target.slice("dsmm-".length).split("-").map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
53
64
|
}
|
|
54
|
-
export function technicalTableRows(toolName, callId, rawArgs, meta, routeSource) {
|
|
65
|
+
export function technicalTableRows(toolName, callId, rawArgs, meta, routeSource, observation) {
|
|
55
66
|
const rows = [];
|
|
56
67
|
rows.push({ property: "toolName", value: toolName, isComplex: false });
|
|
57
68
|
rows.push({ property: "callId", value: callId, isComplex: false });
|
|
@@ -79,9 +90,11 @@ export function technicalTableRows(toolName, callId, rawArgs, meta, routeSource)
|
|
|
79
90
|
rows.push({ property: "meta", value: meta, isComplex: typeof meta === "object" });
|
|
80
91
|
}
|
|
81
92
|
}
|
|
93
|
+
if (observation !== undefined)
|
|
94
|
+
rows.push({ property: "observation", value: observation, isComplex: true });
|
|
82
95
|
return rows;
|
|
83
96
|
}
|
|
84
|
-
export function technicalJsonData(toolName, callId, rawArgs, meta, routeSource) {
|
|
97
|
+
export function technicalJsonData(toolName, callId, rawArgs, meta, routeSource, observation) {
|
|
85
98
|
const parsedArgs = roleToolArguments(rawArgs);
|
|
86
99
|
const data = {
|
|
87
100
|
toolName,
|
|
@@ -91,9 +104,10 @@ export function technicalJsonData(toolName, callId, rawArgs, meta, routeSource)
|
|
|
91
104
|
data.routeSource = routeSource;
|
|
92
105
|
}
|
|
93
106
|
data.args = parsedArgs !== undefined ? parsedArgs : rawArgs;
|
|
94
|
-
if (meta !== undefined && meta !== null)
|
|
107
|
+
if (meta !== undefined && meta !== null)
|
|
95
108
|
data.meta = meta;
|
|
96
|
-
|
|
109
|
+
if (observation !== undefined)
|
|
110
|
+
data.observation = observation;
|
|
97
111
|
return data;
|
|
98
112
|
}
|
|
99
113
|
//# sourceMappingURL=RoleToolView-data.js.map
|
|
@@ -29,6 +29,10 @@ export declare const roleToolEn: {
|
|
|
29
29
|
readonly level: "Level";
|
|
30
30
|
readonly route: "Reported route";
|
|
31
31
|
readonly routeSource: "Route source";
|
|
32
|
+
readonly initialRoute: "Initial";
|
|
33
|
+
readonly actualRoute: "Actual";
|
|
34
|
+
readonly routeUnknown: "unknown";
|
|
35
|
+
readonly effortUnreported: "effort not reported";
|
|
32
36
|
readonly table: "Table";
|
|
33
37
|
readonly json: "JSON";
|
|
34
38
|
readonly viewMode: "View mode";
|
|
@@ -9,6 +9,7 @@ export const roleToolEn = {
|
|
|
9
9
|
args: "Original arguments", preparingArgs: "Arguments received so far", output: "Complete result content", failure: "Error details", metadata: "Invocation metadata",
|
|
10
10
|
inspect: "View call details", copy: "Copy", copied: "Copied", emptyArgs: "Arguments not available yet",
|
|
11
11
|
unavailable: "Actual identity unavailable; requested identity only", level: "Level", route: "Reported route", routeSource: "Route source",
|
|
12
|
+
initialRoute: "Initial", actualRoute: "Actual", routeUnknown: "unknown", effortUnreported: "effort not reported",
|
|
12
13
|
table: "Table", json: "JSON", viewMode: "View mode", property: "Property", value: "Value",
|
|
13
14
|
};
|
|
14
15
|
export const roleToolZh = {
|
|
@@ -21,6 +22,7 @@ export const roleToolZh = {
|
|
|
21
22
|
args: "原始参数", preparingArgs: "目前已收到的参数", output: "完整结果内容", failure: "错误详情", metadata: "调用元数据",
|
|
22
23
|
inspect: "查看调用详情", copy: "复制", copied: "已复制", emptyArgs: "参数尚不可用",
|
|
23
24
|
unavailable: "实际身份不可用,仅显示请求身份", level: "等级", route: "报告的路由", routeSource: "路由来源",
|
|
25
|
+
initialRoute: "初始", actualRoute: "实际", routeUnknown: "未知", effortUnreported: "effort 未报告",
|
|
24
26
|
table: "表格", json: "JSON", viewMode: "视图模式", property: "属性", value: "值",
|
|
25
27
|
};
|
|
26
28
|
//# sourceMappingURL=RoleToolView-locales.js.map
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { ToolCallViewProps } from "@deepseek-ai/dsh-client-ui-tool/client";
|
|
3
|
-
import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
|
+
import type { HostObservable, InjectFace, PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
|
|
4
4
|
import { ROLE_TOOL_NS } from "./RoleToolView-locales.js";
|
|
5
|
-
type
|
|
5
|
+
import type { RoleCallObservationController, RoleCallObservationState } from "./role-call-observations.js";
|
|
6
|
+
type ObservationInject = {
|
|
7
|
+
hooks: {
|
|
8
|
+
roleCalls: HostObservable<RoleCallObservationState>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type Props = ToolCallViewProps & PropsLocale<typeof ROLE_TOOL_NS> & InjectFace<ObservationInject>;
|
|
6
12
|
export declare function RoleToolView(props: Props): import("react").JSX.Element;
|
|
7
13
|
/** Called once by the parent client apply(ctx), alongside the other slot registrations. */
|
|
8
|
-
export declare function registerRoleToolViews(ctx: Context): void;
|
|
14
|
+
export declare function registerRoleToolViews(ctx: Context, observations: RoleCallObservationController): void;
|
|
9
15
|
export {};
|
|
10
16
|
//# sourceMappingURL=RoleToolView.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Button, CodeBlock, DisclosureRow, IconAgentPresetOutlineRegular, SegmentedControl, StateDot, TextShimmer } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
4
|
-
import { actualRoleTool, preparingRoleTool, requestedRoleTool, roleToolDisplay, roleToolKeys, technicalJsonData, technicalTableRows } from "./RoleToolView-data.js";
|
|
4
|
+
import { actualRoleTool, observedRoleTool, preparingRoleTool, requestedRoleTool, roleToolDisplay, roleToolKeys, technicalJsonData, technicalTableRows } from "./RoleToolView-data.js";
|
|
5
5
|
import { ROLE_TOOL_NS, roleToolEn, roleToolZh } from "./RoleToolView-locales.js";
|
|
6
6
|
const styles = `
|
|
7
7
|
.dsmm-role-tool{min-width:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:14px;line-height:22px}
|
|
@@ -39,16 +39,31 @@ export function RoleToolView(props) {
|
|
|
39
39
|
const { t } = props;
|
|
40
40
|
const raw = props.phase === "preparing" ? partial.preview : props.phase === "start" ? props.block.argsRaw : props.block.call?.argsRaw ?? "";
|
|
41
41
|
const requested = partial?.requested ?? requestedRoleTool(props.toolName, raw);
|
|
42
|
+
const observation = props.useRoleCalls(state => state.calls.get(props.callId));
|
|
42
43
|
const result = props.phase === "result" ? props.block : undefined;
|
|
43
44
|
const failed = result !== undefined && (result.isError || result.error != null);
|
|
44
|
-
const
|
|
45
|
+
const persisted = result === undefined ? undefined : actualRoleTool(props.toolName, result.meta, failed);
|
|
46
|
+
const observed = observation === undefined ? undefined : observedRoleTool(props.toolName, observation);
|
|
47
|
+
const inactivePersisted = persisted === undefined || persisted.phase === "settled" ? persisted : persisted.childId === undefined
|
|
48
|
+
? { ...persisted, routeComparison: undefined }
|
|
49
|
+
: { ...persisted, routeComparison: { childId: persisted.childId,
|
|
50
|
+
initialRoute: persisted.routeComparison?.initialRoute ?? (persisted.route === undefined
|
|
51
|
+
? { status: "unknown", reason: "missing-invocation-capture" }
|
|
52
|
+
: { status: "known", source: "invocation-capture", route: persisted.route }),
|
|
53
|
+
liveRoute: { status: "unknown", reason: "not-observed" } } };
|
|
54
|
+
const actual = persisted?.phase === "settled" ? persisted : observed ?? inactivePersisted;
|
|
55
|
+
const comparison = actual?.routeComparison;
|
|
45
56
|
const target = actual?.role ?? requested.target;
|
|
46
57
|
const action = props.phase === "preparing" ? t("calling") : t("call");
|
|
47
58
|
const targetLabel = target === undefined ? t("unknownTarget") : roleToolDisplay(target);
|
|
48
59
|
const rawDesc = requested.description?.trim();
|
|
49
60
|
const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : undefined;
|
|
50
61
|
const title = `${action} ${targetLabel}`;
|
|
51
|
-
const
|
|
62
|
+
const observedStop = actual?.phase === "settled" ? actual.stopReason : undefined;
|
|
63
|
+
const state = result?.error?.code === "interrupted" || observedStop === "aborted" ? "stopped"
|
|
64
|
+
: failed || observedStop !== undefined && observedStop !== "completed" ? "error"
|
|
65
|
+
: result === undefined ? props.phase === "preparing" ? "preparing" : "running"
|
|
66
|
+
: actual?.delivery === "parent" && actual.phase !== "settled" ? "background" : "result";
|
|
52
67
|
const isOngoing = state === "running" || props.phase === "preparing";
|
|
53
68
|
const code = (value) => _jsx(CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
|
|
54
69
|
const [viewMode, setViewMode] = useState("table");
|
|
@@ -57,19 +72,22 @@ export function RoleToolView(props) {
|
|
|
57
72
|
{ value: "table", label: t("table") },
|
|
58
73
|
{ value: "json", label: t("json") },
|
|
59
74
|
];
|
|
60
|
-
const tableRows = technicalTableRows(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
|
|
61
|
-
const jsonData = technicalJsonData(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
|
|
75
|
+
const tableRows = technicalTableRows(props.toolName, props.callId, raw, result?.meta, actual?.routeSource, observation);
|
|
76
|
+
const jsonData = technicalJsonData(props.toolName, props.callId, raw, result?.meta, actual?.routeSource, observation);
|
|
62
77
|
const roleDiffers = requested.target !== undefined && actual !== undefined && actual.role !== requested.target;
|
|
63
78
|
const levelDiffers = requested.level !== undefined && actual !== undefined && actual.level !== requested.level;
|
|
64
79
|
const showRequestedVsActual = roleDiffers || levelDiffers;
|
|
80
|
+
const initialRoute = comparison?.initialRoute ?? (actual?.route === undefined ? undefined : { status: "known", source: "invocation-capture", route: actual.route });
|
|
81
|
+
const actualRoute = comparison?.liveRoute;
|
|
82
|
+
const routeLabel = (route, missingEffort = false) => `${route.provider}/${route.model}${route.reasoningEffort === undefined ? missingEffort ? ` · ${t("effortUnreported")}` : "" : ` · ${route.reasoningEffort}`}`;
|
|
65
83
|
const collapsedContent = singleLineDesc ? _jsxs(_Fragment, { children: [_jsx("span", { className: "dsmm-role-sep", "aria-hidden": "true" }), _jsx("span", { className: "dsmm-role-summary", children: _jsx(TextShimmer, { active: isOngoing, children: singleLineDesc }) })] }) : undefined;
|
|
66
84
|
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" : result === undefined ? "ongoing" : state === "background" ? "idle" : "done";
|
|
67
|
-
return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, "data-expanded": expanded ? "true" : "false", children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(IconAgentPresetOutlineRegular, { size: 14, className: "dsmm-role-icon" }), collapsedContent: collapsedContent, keepContentWhenOpen: true, running: isOngoing, open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { className: "dsmm-role-identity", children: [showRequestedVsActual ? _jsxs(_Fragment, { children: [_jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), _jsxs("span", { children: [requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target), requested.level ? ` (${requested.level})` : ""] }), _jsx("span", { className: "dsmm-role-dim", children: " \u2192 " }), _jsxs("span", { className: "dsmm-role-dim", children: [t("actual"), ": "] }), _jsxs("span", { children: [roleToolDisplay(actual.role), " (", actual.level, ")"] })] }) : _jsxs("span", { children: [actual !== undefined ? roleToolDisplay(actual.role) : requested.target === undefined ? t("unknownTarget") : roleToolDisplay(requested.target), (actual?.level ?? requested.level) !== undefined && ` · ${actual?.level ?? requested.level}`,
|
|
85
|
+
return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, "data-delivery": actual?.delivery, "data-phase": actual?.phase, "data-expanded": expanded ? "true" : "false", children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(IconAgentPresetOutlineRegular, { size: 14, className: "dsmm-role-icon" }), collapsedContent: collapsedContent, keepContentWhenOpen: true, running: isOngoing, open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { className: "dsmm-role-identity", children: [showRequestedVsActual ? _jsxs(_Fragment, { children: [_jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), _jsxs("span", { children: [requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target), requested.level ? ` (${requested.level})` : ""] }), _jsx("span", { className: "dsmm-role-dim", children: " \u2192 " }), _jsxs("span", { className: "dsmm-role-dim", children: [t("actual"), ": "] }), _jsxs("span", { children: [roleToolDisplay(actual.role), " (", actual.level, ")"] })] }) : _jsxs("span", { children: [actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), actual !== undefined ? roleToolDisplay(actual.role) : requested.target === undefined ? t("unknownTarget") : roleToolDisplay(requested.target), (actual?.level ?? requested.level) !== undefined && ` · ${actual?.level ?? requested.level}`, props.phase !== "preparing" && actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [" \u00B7 ", t("actualUnknown")] })] }), initialRoute !== undefined && _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("initialRoute"), ": ", initialRoute.status === "known" ? routeLabel(initialRoute.route) : t("routeUnknown")] }), actualRoute !== undefined ? _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("actualRoute"), ": ", actualRoute.status === "known" ? routeLabel(actualRoute.route, true) : t("routeUnknown")] }) : props.phase !== "preparing" && _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("actualRoute"), ": ", t("routeUnknown")] })] }), requested.description !== undefined && _jsx("p", { className: "dsmm-role-task", children: requested.description }), result?.error != null && _jsxs("div", { className: "dsmm-role-failure", children: [_jsx("p", { className: "dsmm-role-section-title", children: t("failure") }), code(JSON.stringify(result.error, null, 2))] }), _jsxs("details", { className: "dsmm-role-details", children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-role-details-body", children: [_jsx("div", { className: "dsmm-role-details-header", children: _jsx(SegmentedControl, { id: controlId, value: viewMode, options: viewOptions, onChange: setViewMode, label: t("viewMode"), className: "dsmm-role-view-switch" }) }), _jsx("div", { id: `${controlId}-table-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-table`, hidden: viewMode !== "table", tabIndex: 0, children: viewMode === "table" && _jsxs("table", { className: "dsmm-role-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: t("property") }), _jsx("th", { scope: "col", children: t("value") })] }) }), _jsx("tbody", { children: tableRows.map(row => _jsxs("tr", { children: [_jsx("td", { className: "dsmm-role-prop-cell", children: row.property }), _jsx("td", { className: "dsmm-role-val-cell", children: row.isComplex ? _jsx("pre", { className: "dsmm-role-cell-code", children: JSON.stringify(row.value, null, 2) })
|
|
68
86
|
: typeof row.value === "string" ? _jsx("span", { className: "dsmm-role-cell-text", children: row.value })
|
|
69
87
|
: _jsx("span", { children: row.value === null ? "null" : row.value === undefined ? "undefined" : String(row.value) }) })] }, row.property)) })] }) }), _jsx("div", { id: `${controlId}-json-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-json`, hidden: viewMode !== "json", tabIndex: 0, children: viewMode === "json" && code(JSON.stringify(jsonData, null, 2)) })] })] })] }) }), _jsxs("div", { className: "dsmm-role-actions", children: [_jsx(StateDot, { state: stateDotState }), _jsx("p", { className: "dsmm-role-status", role: "status", children: t(state) }), props.inspect !== undefined && _jsx(Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })] })] });
|
|
70
88
|
}
|
|
71
89
|
/** Called once by the parent client apply(ctx), alongside the other slot registrations. */
|
|
72
|
-
export function registerRoleToolViews(ctx) {
|
|
90
|
+
export function registerRoleToolViews(ctx, observations) {
|
|
73
91
|
ctx.effect(() => ctx.locale.register(ROLE_TOOL_NS, { en: roleToolEn, zh: roleToolZh }), "dsmm: role tool locale");
|
|
74
92
|
ctx.effect(() => {
|
|
75
93
|
const style = document.createElement("style");
|
|
@@ -79,7 +97,8 @@ export function registerRoleToolViews(ctx) {
|
|
|
79
97
|
return () => style.remove();
|
|
80
98
|
}, "dsmm: role tool styles");
|
|
81
99
|
ctx.slots.inject("tool.call.toolview", () => {
|
|
82
|
-
const disposers = [...Object.keys(roleToolKeys), "dsmm_role", "dsmm_category"].map(key => ctx.slots.register({ name: "tool.call.toolview", key, locale: ROLE_TOOL_NS
|
|
100
|
+
const disposers = [...Object.keys(roleToolKeys), "dsmm_role", "dsmm_category"].map(key => ctx.slots.register({ name: "tool.call.toolview", key, locale: ROLE_TOOL_NS,
|
|
101
|
+
inject: sessionId => ({ hooks: { roleCalls: observations.source(sessionId) } }) }, RoleToolView));
|
|
83
102
|
return () => { for (const dispose of disposers.reverse())
|
|
84
103
|
dispose(); };
|
|
85
104
|
});
|
|
@@ -252,25 +252,25 @@ export declare const childrenLocaleZh: {
|
|
|
252
252
|
initialRoute: string;
|
|
253
253
|
routeSource: string;
|
|
254
254
|
description: string;
|
|
255
|
-
|
|
255
|
+
pending: string;
|
|
256
256
|
runId: string;
|
|
257
257
|
childId: string;
|
|
258
258
|
jobId: string;
|
|
259
|
-
|
|
259
|
+
delivery: string;
|
|
260
|
+
epoch: string;
|
|
260
261
|
yes: string;
|
|
261
262
|
no: string;
|
|
263
|
+
liveRoute: string;
|
|
262
264
|
runtime: string;
|
|
263
265
|
activity: string;
|
|
264
266
|
refresh: string;
|
|
265
267
|
images: string;
|
|
266
268
|
restart: string;
|
|
267
269
|
title: string;
|
|
268
|
-
liveRoute: string;
|
|
269
270
|
descendants: string;
|
|
270
271
|
interrupt: string;
|
|
271
272
|
readonly: string;
|
|
272
273
|
children: string;
|
|
273
|
-
delivery: string;
|
|
274
274
|
queue: string;
|
|
275
275
|
steer: string;
|
|
276
276
|
foreign: string;
|
package/lib/client/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { bindPermissionSession } from "./permission-session.js";
|
|
|
15
15
|
import { PermissionController } from "./permission-controller.js";
|
|
16
16
|
import { PERMISSIONS_NS, permissionEn, permissionZh } from "./permission-locales.js";
|
|
17
17
|
import { registerRoleToolViews } from "./RoleToolView.js";
|
|
18
|
+
import { RoleCallObservationController } from "./role-call-observations.js";
|
|
18
19
|
import { profileBlankNative } from "./profile-blank.js";
|
|
19
20
|
export { ProfilesController, NEW_PROFILE_CONTENT } from "./controller.js";
|
|
20
21
|
export { ProfilesSection } from "./ProfilesSection.js";
|
|
@@ -28,7 +29,9 @@ export { ROLE_CONTROL_REMOTE } from "../role-control-remote.js";
|
|
|
28
29
|
/** No self-dependency on a namespace that this contribution has not mounted. */
|
|
29
30
|
export const inject = ["slots", "locale", "remote"];
|
|
30
31
|
export async function apply(ctx) {
|
|
31
|
-
|
|
32
|
+
const roleCalls = new RoleCallObservationController();
|
|
33
|
+
registerRoleToolViews(ctx, roleCalls);
|
|
34
|
+
ctx.effect(() => () => roleCalls.dispose(), "dsmm: role call observations");
|
|
32
35
|
await ctx.remote.$mount(TYPERT_REMOTE);
|
|
33
36
|
await ctx.remote.$mount(ROLE_CONTROL_REMOTE);
|
|
34
37
|
await ctx.remote.$mount(PERMISSION_REMOTE);
|
|
@@ -37,6 +40,8 @@ export async function apply(ctx) {
|
|
|
37
40
|
ctx.effect(() => ctx.locale.register(PERMISSIONS_NS, { en: permissionEn, zh: permissionZh }), "dsmm: permission locale");
|
|
38
41
|
void ctx.inject(["connection"], connectionCtx => {
|
|
39
42
|
const handle = connectionCtx.connection, invoke = permissionClient(handle);
|
|
43
|
+
const unbindRoleCalls = roleCalls.bindConnection(connectionCtx.remote, (sessionId, signal) => connectionCtx.remote.dsmmChildren.observe(sessionId, signal));
|
|
44
|
+
connectionCtx.effect(() => unbindRoleCalls, "dsmm: role call connection withdrawal");
|
|
40
45
|
const update = () => { const generation = handle.generation.getSnapshot(); permissions.bindConnection(generation === undefined ? null : invoke, generation); };
|
|
41
46
|
update();
|
|
42
47
|
connectionCtx.effect(() => handle.generation.subscribe(update));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RemoteStream, RemoteStreamOptions } from "@deepseek-ai/dsh-api-gateway/client";
|
|
2
|
+
import type { HostObservable } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
|
+
import type { RoleCallObservation, RoleCallObservationFrame } from "../role-control-types.js";
|
|
4
|
+
export interface RoleCallObservationState {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly status: "unavailable" | "connecting" | "live" | "stale";
|
|
7
|
+
readonly admissionEpoch?: string;
|
|
8
|
+
readonly calls: ReadonlyMap<string, RoleCallObservation>;
|
|
9
|
+
}
|
|
10
|
+
export type RoleCallStreamOpen = (sessionId: string, signal: AbortSignal) => AsyncIterable<RoleCallObservationFrame>;
|
|
11
|
+
export interface RoleCallStreamFactory {
|
|
12
|
+
$stream<Item>(options: RemoteStreamOptions<Item>): RemoteStream<Item>;
|
|
13
|
+
}
|
|
14
|
+
export declare class RoleCallObservationController {
|
|
15
|
+
private binding;
|
|
16
|
+
private readonly sources;
|
|
17
|
+
source(sessionId: string): HostObservable<RoleCallObservationState>;
|
|
18
|
+
bindConnection(factory: RoleCallStreamFactory, open: RoleCallStreamOpen): () => void;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=role-call-observations.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export class RoleCallObservationController {
|
|
2
|
+
binding = null;
|
|
3
|
+
sources = new Map();
|
|
4
|
+
source(sessionId) {
|
|
5
|
+
let source = this.sources.get(sessionId);
|
|
6
|
+
if (source === undefined) {
|
|
7
|
+
source = new RoleCallObservationSource(sessionId);
|
|
8
|
+
source.bind(this.binding);
|
|
9
|
+
this.sources.set(sessionId, source);
|
|
10
|
+
}
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
13
|
+
bindConnection(factory, open) {
|
|
14
|
+
const binding = { identity: {}, factory, open };
|
|
15
|
+
this.binding = binding;
|
|
16
|
+
for (const source of this.sources.values())
|
|
17
|
+
source.bind(binding);
|
|
18
|
+
return () => {
|
|
19
|
+
if (this.binding !== binding)
|
|
20
|
+
return;
|
|
21
|
+
this.binding = null;
|
|
22
|
+
for (const source of this.sources.values())
|
|
23
|
+
source.bind(null);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
this.binding = null;
|
|
28
|
+
for (const source of this.sources.values())
|
|
29
|
+
source.dispose();
|
|
30
|
+
this.sources.clear();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class RoleCallObservationSource {
|
|
34
|
+
sessionId;
|
|
35
|
+
snapshot;
|
|
36
|
+
listeners = new Set();
|
|
37
|
+
binding = null;
|
|
38
|
+
revision = 0;
|
|
39
|
+
stream;
|
|
40
|
+
constructor(sessionId) {
|
|
41
|
+
this.sessionId = sessionId;
|
|
42
|
+
this.snapshot = { sessionId, status: "unavailable", calls: new Map() };
|
|
43
|
+
}
|
|
44
|
+
getSnapshot() { return this.snapshot; }
|
|
45
|
+
subscribe(listener) {
|
|
46
|
+
this.listeners.add(listener);
|
|
47
|
+
if (this.listeners.size === 1)
|
|
48
|
+
this.start();
|
|
49
|
+
return () => {
|
|
50
|
+
this.listeners.delete(listener);
|
|
51
|
+
if (this.listeners.size !== 0)
|
|
52
|
+
return;
|
|
53
|
+
this.revision++;
|
|
54
|
+
const stream = this.stream;
|
|
55
|
+
this.stream = undefined;
|
|
56
|
+
if (stream !== undefined)
|
|
57
|
+
void stream.dispose();
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
bind(binding) {
|
|
61
|
+
if (this.binding?.identity === binding?.identity)
|
|
62
|
+
return;
|
|
63
|
+
this.binding = binding;
|
|
64
|
+
this.revision++;
|
|
65
|
+
const stream = this.stream;
|
|
66
|
+
this.stream = undefined;
|
|
67
|
+
if (stream !== undefined)
|
|
68
|
+
void stream.dispose();
|
|
69
|
+
this.publish({ sessionId: this.sessionId, status: "unavailable", calls: new Map() });
|
|
70
|
+
if (this.listeners.size > 0)
|
|
71
|
+
this.start();
|
|
72
|
+
}
|
|
73
|
+
dispose() {
|
|
74
|
+
this.binding = null;
|
|
75
|
+
this.revision++;
|
|
76
|
+
const stream = this.stream;
|
|
77
|
+
this.stream = undefined;
|
|
78
|
+
if (stream !== undefined)
|
|
79
|
+
void stream.dispose();
|
|
80
|
+
this.listeners.clear();
|
|
81
|
+
}
|
|
82
|
+
start() {
|
|
83
|
+
const binding = this.binding;
|
|
84
|
+
if (binding === null || this.listeners.size === 0 || this.stream !== undefined)
|
|
85
|
+
return;
|
|
86
|
+
const revision = ++this.revision;
|
|
87
|
+
this.publish({ sessionId: this.sessionId, status: "connecting", calls: new Map() });
|
|
88
|
+
const stream = binding.factory.$stream({
|
|
89
|
+
name: `DSMM role calls for ${this.sessionId}`,
|
|
90
|
+
open: signal => binding.open(this.sessionId, signal),
|
|
91
|
+
ended: accepted => new Error(`DSMM role call stream ended ${accepted ? "after" : "before"} its snapshot`),
|
|
92
|
+
carrierFailed: () => {
|
|
93
|
+
if (this.revision === revision && this.stream === stream)
|
|
94
|
+
this.invalidate("stale");
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
this.stream = stream;
|
|
98
|
+
void this.consume(stream, revision);
|
|
99
|
+
}
|
|
100
|
+
async consume(stream, revision) {
|
|
101
|
+
let generation = 0, admissionEpoch;
|
|
102
|
+
try {
|
|
103
|
+
for await (const item of stream) {
|
|
104
|
+
if (this.revision !== revision || this.stream !== stream)
|
|
105
|
+
return;
|
|
106
|
+
const frame = item.value;
|
|
107
|
+
if (frame.sessionId !== this.sessionId)
|
|
108
|
+
throw new Error("DSMM role call stream changed sessions");
|
|
109
|
+
if (item.generation !== generation) {
|
|
110
|
+
if (frame.type !== "snapshot")
|
|
111
|
+
throw new Error("DSMM role call generation omitted its snapshot");
|
|
112
|
+
generation = item.generation;
|
|
113
|
+
admissionEpoch = frame.admissionEpoch;
|
|
114
|
+
this.publish({ sessionId: this.sessionId, status: "live", admissionEpoch,
|
|
115
|
+
calls: new Map(frame.calls.map(call => [call.callId, call])) });
|
|
116
|
+
item.accept();
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (frame.type === "snapshot" || frame.admissionEpoch !== admissionEpoch)
|
|
120
|
+
throw new Error("DSMM role call update crossed its admission");
|
|
121
|
+
const calls = new Map(this.snapshot.calls);
|
|
122
|
+
if (frame.type === "update")
|
|
123
|
+
calls.set(frame.call.callId, frame.call);
|
|
124
|
+
else
|
|
125
|
+
calls.delete(frame.callId);
|
|
126
|
+
this.publish({ sessionId: this.sessionId, status: "live", admissionEpoch, calls });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
if (this.revision === revision && this.stream === stream)
|
|
131
|
+
this.invalidate("unavailable");
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
if (this.revision === revision && this.stream === stream)
|
|
135
|
+
this.stream = undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
invalidate(status) {
|
|
139
|
+
const calls = new Map([...this.snapshot.calls].map(([callId, call]) => [callId, call.phase === "settled" ? call : Object.freeze({
|
|
140
|
+
...call, actualRoute: Object.freeze({ status: "unknown", reason: "not-observed" }),
|
|
141
|
+
})]));
|
|
142
|
+
this.publish({ ...this.snapshot, status, calls });
|
|
143
|
+
}
|
|
144
|
+
publish(snapshot) {
|
|
145
|
+
this.snapshot = snapshot;
|
|
146
|
+
for (const listener of this.listeners)
|
|
147
|
+
listener();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=role-call-observations.js.map
|