@deepseek-ai/dsh-client-ui-cordis 0.0.1-rc.3
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/LICENSE +28 -0
- package/README.i18n.yaml +6 -0
- package/README.md +36 -0
- package/README.zh.md +36 -0
- package/lib/client.js +1433 -0
- package/lib/index.js +11 -0
- package/lib/invariant.js +26 -0
- package/lib/types/client/CordisActionRow.d.ts +8 -0
- package/lib/types/client/CordisDefineRow.d.ts +9 -0
- package/lib/types/client/CordisPanel.d.ts +8 -0
- package/lib/types/client/CordisRunRow.d.ts +9 -0
- package/lib/types/client/card-model.d.ts +56 -0
- package/lib/types/client/dynamic-port.d.ts +22 -0
- package/lib/types/client/events.d.ts +3 -0
- package/lib/types/client/index.d.ts +15 -0
- package/lib/types/client/inventory.d.ts +51 -0
- package/lib/types/client/locales.d.ts +115 -0
- package/lib/types/client/run-card-index.d.ts +36 -0
- package/lib/types/client/slots.d.ts +62 -0
- package/lib/types/client/status.d.ts +21 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/invariant.d.ts +16 -0
- package/package.json +89 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1433 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@deepseek-ai/dsh-client-ui-cordis",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
|
+
let react = require("react");
|
|
10
|
+
//#region lib/types/client/card-model.js
|
|
11
|
+
/** Replay-stable view models for Cordis lifecycle Tool calls. */
|
|
12
|
+
function firstLine(text) {
|
|
13
|
+
const newline = text.indexOf("\n");
|
|
14
|
+
return newline === -1 ? text : text.slice(0, newline);
|
|
15
|
+
}
|
|
16
|
+
function stringAt(source, key) {
|
|
17
|
+
const value = source[key];
|
|
18
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
19
|
+
}
|
|
20
|
+
function objectAt(source, key) {
|
|
21
|
+
const value = source[key];
|
|
22
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
23
|
+
}
|
|
24
|
+
function parseArgs(argsRaw) {
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(argsRaw);
|
|
27
|
+
return typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function resultText(block) {
|
|
33
|
+
const text = block.content.map((item) => item.type === "text" ? item.text : JSON.stringify(item, null, 2)).join("\n");
|
|
34
|
+
if (text !== "") return text;
|
|
35
|
+
return block.error === void 0 ? null : `${block.error.name}: ${block.error.code}`;
|
|
36
|
+
}
|
|
37
|
+
function stateOf(block) {
|
|
38
|
+
if (!("kind" in block)) return "running";
|
|
39
|
+
if (block.error?.code === "interrupted") return "stopped";
|
|
40
|
+
return block.isError ? "error" : "ok";
|
|
41
|
+
}
|
|
42
|
+
function metaObject(block) {
|
|
43
|
+
if (!("kind" in block) || block.isError || typeof block.meta !== "object" || block.meta === null) return null;
|
|
44
|
+
return block.meta;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Derive one Define card from its frozen call/result slice.
|
|
48
|
+
* @param block - active or settled tool-call block.
|
|
49
|
+
* @returns normalized Define card fields.
|
|
50
|
+
*/
|
|
51
|
+
function cordisDefineCard(block) {
|
|
52
|
+
const settled = "kind" in block;
|
|
53
|
+
const argsRaw = (settled ? block.call?.argsRaw : block.argsRaw) ?? "";
|
|
54
|
+
const args = parseArgs(argsRaw);
|
|
55
|
+
const code = args === null ? null : objectAt(args, "code");
|
|
56
|
+
const state = stateOf(block);
|
|
57
|
+
const output = settled ? resultText(block) : null;
|
|
58
|
+
const meta = metaObject(block);
|
|
59
|
+
const rawName = argsRaw === "" ? null : firstLine(argsRaw);
|
|
60
|
+
return {
|
|
61
|
+
pluginId: meta === null ? null : stringAt(meta, "pluginId"),
|
|
62
|
+
packageId: meta === null ? null : stringAt(meta, "packageId"),
|
|
63
|
+
name: args === null ? rawName : stringAt(args, "name") ?? rawName,
|
|
64
|
+
purpose: args === null ? null : stringAt(args, "purpose"),
|
|
65
|
+
hostCode: code === null ? null : stringAt(code, "host"),
|
|
66
|
+
clientCode: code === null ? null : stringAt(code, "client"),
|
|
67
|
+
output,
|
|
68
|
+
errorSummary: state === "error" && output !== null ? firstLine(output) : null,
|
|
69
|
+
state
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Derive one Run card and its successful activation metadata.
|
|
74
|
+
* @param block - active or settled tool-call block.
|
|
75
|
+
* @returns normalized Run card fields.
|
|
76
|
+
*/
|
|
77
|
+
function cordisRunCard(block) {
|
|
78
|
+
const settled = "kind" in block;
|
|
79
|
+
const args = parseArgs((settled ? block.call?.argsRaw : block.argsRaw) ?? "");
|
|
80
|
+
const meta = metaObject(block);
|
|
81
|
+
const state = stateOf(block);
|
|
82
|
+
const output = settled ? resultText(block) : null;
|
|
83
|
+
const rawMode = args === null ? null : stringAt(args, "mode");
|
|
84
|
+
const argsPluginId = args === null ? null : stringAt(args, "pluginId");
|
|
85
|
+
const argsPackageId = args === null ? null : stringAt(args, "packageId");
|
|
86
|
+
return {
|
|
87
|
+
pluginId: meta === null ? argsPluginId : stringAt(meta, "pluginId") ?? argsPluginId,
|
|
88
|
+
packageId: meta === null ? argsPackageId : stringAt(meta, "packageId") ?? argsPackageId,
|
|
89
|
+
pluginRunId: meta === null ? null : stringAt(meta, "pluginRunId"),
|
|
90
|
+
mode: rawMode === "run" || rawMode === "update" ? rawMode : null,
|
|
91
|
+
seq: settled ? block.seq : null,
|
|
92
|
+
output,
|
|
93
|
+
errorSummary: state === "error" && output !== null ? firstLine(output) : null,
|
|
94
|
+
state
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Derive one Stop or Remove card from its frozen call/result slice.
|
|
99
|
+
* @param block - active or settled tool-call block.
|
|
100
|
+
* @returns normalized lifecycle-action card fields.
|
|
101
|
+
*/
|
|
102
|
+
function cordisActionCard(block) {
|
|
103
|
+
const settled = "kind" in block;
|
|
104
|
+
const args = parseArgs((settled ? block.call?.argsRaw : block.argsRaw) ?? "");
|
|
105
|
+
const state = stateOf(block);
|
|
106
|
+
const output = settled ? resultText(block) : null;
|
|
107
|
+
return {
|
|
108
|
+
pluginId: args === null ? null : stringAt(args, "pluginId") ?? stringAt(args, "id"),
|
|
109
|
+
output,
|
|
110
|
+
errorSummary: state === "error" && output !== null ? firstLine(output) : null,
|
|
111
|
+
state
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/extensions/ui-cordis/src/client/CordisRunRow.module.css.mjs
|
|
116
|
+
const css$2 = ".cvtE3a_card{flex-direction:column;gap:8px;display:flex}.cvtE3a_row{align-items:center;min-height:32px;display:flex}.cvtE3a_icon{color:var(--dsw-alias-state-business-primary);flex:none;margin-right:8px;display:inline-flex}.cvtE3a_title{color:var(--dsw-alias-state-business-primary);flex:none;font-size:14px;font-weight:500;line-height:24px}.cvtE3a_separator{background:var(--dsw-alias-state-business-primary);border-radius:50%;flex:none;width:2px;height:2px;margin:0 8px}.cvtE3a_summary,.cvtE3a_error{min-width:0;color:var(--dsw-alias-label-secondary);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:13px;line-height:24px;overflow:hidden}.cvtE3a_error{color:var(--dsw-alias-state-error-primary)}.cvtE3a_status{color:var(--dsw-alias-label-caption);flex:none;margin-left:8px;font-size:12px;line-height:24px}.cvtE3a_card[data-cordis-status=awaiting-approval] .cvtE3a_status,.cvtE3a_card[data-cordis-status=client-pending] .cvtE3a_status{color:var(--dsw-alias-state-warn-label)}.cvtE3a_card[data-cordis-status=running] .cvtE3a_status{color:var(--dsw-alias-state-success-primary)}.cvtE3a_card[data-cordis-status=failed] .cvtE3a_status{color:var(--dsw-alias-state-error-primary)}.cvtE3a_inspect{width:24px;height:24px;color:var(--dsw-alias-label-tertiary);cursor:pointer;opacity:0;background:0 0;border:none;border-radius:999px;justify-content:center;align-items:center;margin-left:4px;padding:0;display:inline-flex}.cvtE3a_card:hover .cvtE3a_inspect,.cvtE3a_inspect:focus-visible{opacity:1}.cvtE3a_inspect:hover{background:var(--dsw-alias-interactive-bg-hover)}.cvtE3a_message{background:var(--dsw-alias-button-ghost-active-fill);color:var(--dsw-alias-label-tertiary);border-radius:8px;padding:8px 12px;font-size:12px;line-height:18px}.cvtE3a_business{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);border-radius:12px;min-width:0;overflow:hidden}.cvtE3a_output{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-secondary);font:var(--dsw-font-markdown-code-block-small);white-space:pre-wrap;overflow-wrap:anywhere;border-radius:8px;margin:0;padding:10px 12px;overflow:auto}.cvtE3a_business .cvtE3a_output{border:none;border-radius:0}";
|
|
117
|
+
const tagId$2 = "@deepseek-ai/dsh-client-ui-cordis/CordisRunRow.module.css";
|
|
118
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
119
|
+
const tag = document.createElement("style");
|
|
120
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-cordis";
|
|
121
|
+
tag.dataset.pluginCss = tagId$2;
|
|
122
|
+
tag.textContent = css$2;
|
|
123
|
+
document.head.appendChild(tag);
|
|
124
|
+
}
|
|
125
|
+
var CordisRunRow_module_css_default = {
|
|
126
|
+
"separator": "cvtE3a_separator",
|
|
127
|
+
"message": "cvtE3a_message",
|
|
128
|
+
"status": "cvtE3a_status",
|
|
129
|
+
"business": "cvtE3a_business",
|
|
130
|
+
"inspect": "cvtE3a_inspect",
|
|
131
|
+
"title": "cvtE3a_title",
|
|
132
|
+
"summary": "cvtE3a_summary",
|
|
133
|
+
"error": "cvtE3a_error",
|
|
134
|
+
"icon": "cvtE3a_icon",
|
|
135
|
+
"row": "cvtE3a_row",
|
|
136
|
+
"card": "cvtE3a_card",
|
|
137
|
+
"output": "cvtE3a_output"
|
|
138
|
+
};
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region lib/types/client/CordisActionRow.js
|
|
141
|
+
/** Localized cards for `cordis_stop` and `cordis_undefine`. */
|
|
142
|
+
/** Render one Stop or Remove call with Cordis-owned localized copy. */
|
|
143
|
+
function CordisActionRow({ callId, toolName, block, inspect, t }) {
|
|
144
|
+
const card = cordisActionCard(block);
|
|
145
|
+
const remove = toolName === "cordis_undefine";
|
|
146
|
+
const summary = card.errorSummary ?? card.pluginId ?? callId;
|
|
147
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
148
|
+
className: CordisRunRow_module_css_default.card,
|
|
149
|
+
"data-tool": toolName,
|
|
150
|
+
"data-state": card.state,
|
|
151
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
152
|
+
className: CordisRunRow_module_css_default.row,
|
|
153
|
+
children: [
|
|
154
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
155
|
+
className: CordisRunRow_module_css_default.icon,
|
|
156
|
+
children: card.state === "error" ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "error" }) : card.state === "stopped" ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "warning" }) : remove ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 }) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconStopFill16, { size: 14 })
|
|
157
|
+
}),
|
|
158
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
159
|
+
className: CordisRunRow_module_css_default.title,
|
|
160
|
+
children: t(remove ? "row.removeTitle" : "row.stopTitle")
|
|
161
|
+
}),
|
|
162
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
163
|
+
className: CordisRunRow_module_css_default.separator,
|
|
164
|
+
"aria-hidden": true
|
|
165
|
+
}),
|
|
166
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
167
|
+
className: card.errorSummary === null ? CordisRunRow_module_css_default.summary : CordisRunRow_module_css_default.error,
|
|
168
|
+
children: summary
|
|
169
|
+
}),
|
|
170
|
+
inspect !== void 0 && (0, react_jsx_runtime.jsx)("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
className: CordisRunRow_module_css_default.inspect,
|
|
173
|
+
"aria-label": "Inspect",
|
|
174
|
+
onClick: inspect,
|
|
175
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutline12, {})
|
|
176
|
+
})
|
|
177
|
+
]
|
|
178
|
+
}), card.output !== null && (0, react_jsx_runtime.jsx)("pre", {
|
|
179
|
+
className: CordisRunRow_module_css_default.output,
|
|
180
|
+
children: card.output
|
|
181
|
+
})]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region lib/types/client/status.js
|
|
186
|
+
/** Shared status derivation over Host inventory and this page's Client live set. */
|
|
187
|
+
/**
|
|
188
|
+
* Locate one immutable Package inside a Plugin row.
|
|
189
|
+
* @param row - owning Plugin inventory row.
|
|
190
|
+
* @param packageId - immutable Package identity to locate.
|
|
191
|
+
* @returns the matching Package metadata, or `undefined` when absent.
|
|
192
|
+
*/
|
|
193
|
+
function packageOf(row, packageId) {
|
|
194
|
+
return row.packages.find((pkg) => pkg.packageId === packageId);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Derive the visible state of one Package.
|
|
198
|
+
* @param row - owning Plugin inventory row.
|
|
199
|
+
* @param packageId - Package being described.
|
|
200
|
+
* @param loaded - Client activations loaded in this page.
|
|
201
|
+
* @returns idle, Host-running/Client-pending, or fully running.
|
|
202
|
+
*/
|
|
203
|
+
function cordisVisibleStatus(row, packageId, loaded) {
|
|
204
|
+
const run = row.activeRun;
|
|
205
|
+
if (run === void 0 || run.packageId !== packageId) return "idle";
|
|
206
|
+
if (packageOf(row, packageId)?.hasClientHalf !== true) return "running";
|
|
207
|
+
return loaded.some((live) => live.pluginId === row.pluginId && live.packageId === packageId && live.pluginRunId === run.pluginRunId) ? "running" : "client-pending";
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/extensions/ui-cordis/src/client/CordisDefineRow.module.css.mjs
|
|
211
|
+
const css$1 = ".gNWCoW_card{flex-direction:column;display:flex}.gNWCoW_card .gNWCoW_title,.gNWCoW_card .gNWCoW_chevron{color:var(--dsw-alias-state-business-primary)}.gNWCoW_title{flex:none;font-size:14px;font-weight:500;line-height:24px}.gNWCoW_row{gap:0}.gNWCoW_separator{background:var(--dsw-alias-state-business-primary);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.gNWCoW_name{text-overflow:ellipsis;white-space:nowrap;max-width:40%;color:var(--dsw-alias-label-secondary);flex:none;font-size:14px;line-height:24px;overflow:hidden}.gNWCoW_purpose{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-tertiary);flex:auto;margin-left:8px;font-size:13px;line-height:24px;overflow:hidden}.gNWCoW_errorSummary{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-state-error-primary);flex:auto;font-size:14px;line-height:24px;overflow:hidden}.gNWCoW_requestError{text-overflow:ellipsis;white-space:nowrap;max-width:40%;color:var(--dsw-alias-state-error-primary);flex:none;margin-left:8px;font-size:12px;line-height:24px;overflow:hidden}.gNWCoW_readout{flex:none;align-items:center;margin-left:8px;display:inline-flex}.gNWCoW_panelHint{color:var(--dsw-alias-label-caption);margin:4px 0 2px 4px;font-size:11px;line-height:16px}.gNWCoW_statusLabel{color:var(--dsw-alias-label-caption);font-size:12px;line-height:24px}.gNWCoW_approvalPrompt{text-overflow:ellipsis;white-space:nowrap;max-width:40%;color:var(--dsw-alias-label-secondary);flex:none;margin-left:8px;font-size:12px;line-height:24px;overflow:hidden}.gNWCoW_notice{text-overflow:ellipsis;white-space:nowrap;max-width:40%;color:var(--dsw-alias-label-caption);flex:none;margin-left:8px;font-size:12px;line-height:24px;overflow:hidden}.gNWCoW_switch{height:22px;padding:0 8px;font-size:12px}.gNWCoW_card[data-terminal] .gNWCoW_title,.gNWCoW_card[data-terminal] .gNWCoW_name,.gNWCoW_card[data-terminal] .gNWCoW_purpose,.gNWCoW_card[data-terminal] .gNWCoW_statusLabel{color:var(--dsw-alias-label-caption)}.gNWCoW_card[data-terminal] .gNWCoW_separator{background:var(--dsw-alias-label-caption)}.gNWCoW_bodyWrap{flex-direction:column;display:flex}.gNWCoW_sourceCard{flex-direction:column;margin:4px 0 4px 4px;display:flex}.gNWCoW_sourceTabs{border-bottom:1px solid var(--dsw-alias-border-l2);height:32px;display:flex}.gNWCoW_sourceTab{color:var(--dsw-alias-label-tertiary);cursor:pointer;font:var(--dsw-font-xs-13);background:0 0;border:0;padding:0 10px;position:relative}.gNWCoW_sourceTab:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.gNWCoW_sourceTab:disabled{cursor:default;opacity:.4}.gNWCoW_sourceTabActive{color:var(--dsw-alias-state-business-primary)}.gNWCoW_sourceTabActive:after{background:var(--dsw-alias-state-business-primary);content:\"\";border-radius:1px 1px 0 0;height:2px;position:absolute;bottom:0;left:10px;right:10px}.gNWCoW_sourceTab:focus-visible{outline:1px solid var(--dsw-alias-state-business-primary);outline-offset:-1px}.gNWCoW_sourcePanel{max-height:260px;overflow:auto}.gNWCoW_sourceCode{margin:0}.gNWCoW_codeSection{flex-direction:column;max-height:260px;margin:4px 0 4px 4px;display:flex;overflow:auto}.gNWCoW_sectionLabel{color:var(--dsw-alias-label-caption);text-transform:uppercase;letter-spacing:.04em;flex:none;padding:2px 0;font-size:11px;font-weight:500;line-height:16px}.gNWCoW_output{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-markdown-code-block);white-space:pre-wrap;overflow-wrap:anywhere;font:var(--dsw-font-markdown-code-block-small);color:var(--dsw-alias-label-secondary);border-radius:8px;margin:0;padding:8px 10px}.gNWCoW_output[data-error]{color:var(--dsw-alias-state-error-primary)}.gNWCoW_inspectButton{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);cursor:pointer;opacity:0;border-radius:999px;align-self:flex-start;align-items:center;gap:4px;margin:4px 0 2px 4px;padding:2px 8px;font-size:11px;line-height:16px;transition:opacity .1s;display:inline-flex}.gNWCoW_card:hover .gNWCoW_inspectButton,.gNWCoW_inspectButton:focus-visible{opacity:1}.gNWCoW_inspectButton:hover{background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}.gNWCoW_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.gNWCoW_inspectButton{transition:none}}";
|
|
212
|
+
const tagId$1 = "@deepseek-ai/dsh-client-ui-cordis/CordisDefineRow.module.css";
|
|
213
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
214
|
+
const tag = document.createElement("style");
|
|
215
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-cordis";
|
|
216
|
+
tag.dataset.pluginCss = tagId$1;
|
|
217
|
+
tag.textContent = css$1;
|
|
218
|
+
document.head.appendChild(tag);
|
|
219
|
+
}
|
|
220
|
+
var CordisDefineRow_module_css_default = {
|
|
221
|
+
"sourceCode": "gNWCoW_sourceCode",
|
|
222
|
+
"inspectButton": "gNWCoW_inspectButton",
|
|
223
|
+
"purpose": "gNWCoW_purpose",
|
|
224
|
+
"readout": "gNWCoW_readout",
|
|
225
|
+
"approvalPrompt": "gNWCoW_approvalPrompt",
|
|
226
|
+
"chevron": "gNWCoW_chevron",
|
|
227
|
+
"bodyWrap": "gNWCoW_bodyWrap",
|
|
228
|
+
"sourceTabs": "gNWCoW_sourceTabs",
|
|
229
|
+
"sourcePanel": "gNWCoW_sourcePanel",
|
|
230
|
+
"sourceCard": "gNWCoW_sourceCard",
|
|
231
|
+
"codeSection": "gNWCoW_codeSection",
|
|
232
|
+
"output": "gNWCoW_output",
|
|
233
|
+
"panelHint": "gNWCoW_panelHint",
|
|
234
|
+
"title": "gNWCoW_title",
|
|
235
|
+
"separator": "gNWCoW_separator",
|
|
236
|
+
"name": "gNWCoW_name",
|
|
237
|
+
"card": "gNWCoW_card",
|
|
238
|
+
"errorSummary": "gNWCoW_errorSummary",
|
|
239
|
+
"requestError": "gNWCoW_requestError",
|
|
240
|
+
"sourceTab": "gNWCoW_sourceTab",
|
|
241
|
+
"sourceTabActive": "gNWCoW_sourceTabActive",
|
|
242
|
+
"visuallyHidden": "gNWCoW_visuallyHidden",
|
|
243
|
+
"notice": "gNWCoW_notice",
|
|
244
|
+
"row": "gNWCoW_row",
|
|
245
|
+
"statusLabel": "gNWCoW_statusLabel",
|
|
246
|
+
"switch": "gNWCoW_switch",
|
|
247
|
+
"sectionLabel": "gNWCoW_sectionLabel"
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region lib/types/client/CordisDefineRow.js
|
|
251
|
+
/** Read-only `cordis_define` card with Host and Client source tabs. */
|
|
252
|
+
const READING_LABELS$1 = {
|
|
253
|
+
idle: "status.idle",
|
|
254
|
+
"client-pending": "status.clientPending",
|
|
255
|
+
running: "status.running",
|
|
256
|
+
removed: "status.removed"
|
|
257
|
+
};
|
|
258
|
+
function stateStatus(state) {
|
|
259
|
+
switch (state) {
|
|
260
|
+
case "running": return "a11y.defining";
|
|
261
|
+
case "error": return "a11y.failed";
|
|
262
|
+
case "stopped": return "a11y.stopped";
|
|
263
|
+
default: return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function leadingFor(state) {
|
|
267
|
+
switch (state) {
|
|
268
|
+
case "error": return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "error" });
|
|
269
|
+
case "stopped": return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "warning" });
|
|
270
|
+
default: return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCodeOutline16, { size: 14 });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/** Render one immutable Package definition. */
|
|
274
|
+
function CordisDefineRow({ callId, block, inspect, useInventory, useLoaded, t }) {
|
|
275
|
+
const card = cordisDefineCard(block);
|
|
276
|
+
const inventory = useInventory((snapshot) => snapshot);
|
|
277
|
+
const loaded = useLoaded((snapshot) => snapshot);
|
|
278
|
+
const [expanded, setExpanded] = (0, react.useState)(false);
|
|
279
|
+
const [selectedSource, setSelectedSource] = (0, react.useState)(card.clientCode !== null ? "client" : "host");
|
|
280
|
+
const sourcePanelId = (0, react.useId)();
|
|
281
|
+
const row = card.pluginId === null ? void 0 : inventory.rows.find((candidate) => candidate.pluginId === card.pluginId);
|
|
282
|
+
const reading = card.pluginId !== null && inventory.removed.has(card.pluginId) ? "removed" : row !== void 0 && card.packageId !== null ? cordisVisibleStatus(row, card.packageId, loaded) : "idle";
|
|
283
|
+
const name = card.name ?? callId;
|
|
284
|
+
const expandable = card.hostCode !== null || card.clientCode !== null || card.output !== null;
|
|
285
|
+
const open = expanded && expandable;
|
|
286
|
+
const a11yState = stateStatus(card.state);
|
|
287
|
+
const hasSource = card.clientCode !== null || card.hostCode !== null;
|
|
288
|
+
const activeSource = selectedSource === "client" && card.clientCode !== null ? "client" : selectedSource === "host" && card.hostCode !== null ? "host" : card.clientCode !== null ? "client" : "host";
|
|
289
|
+
const activeCode = activeSource === "client" ? card.clientCode : card.hostCode;
|
|
290
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
291
|
+
className: CordisDefineRow_module_css_default.card,
|
|
292
|
+
"data-tool": "cordis_define",
|
|
293
|
+
"data-state": card.state,
|
|
294
|
+
"data-terminal": reading === "removed" || void 0,
|
|
295
|
+
"data-cordis-plugin-id": card.pluginId ?? void 0,
|
|
296
|
+
"data-cordis-package-id": card.packageId ?? void 0,
|
|
297
|
+
"data-cordis-status": reading,
|
|
298
|
+
children: [a11yState !== null && (0, react_jsx_runtime.jsx)("span", {
|
|
299
|
+
className: CordisDefineRow_module_css_default.visuallyHidden,
|
|
300
|
+
children: t(a11yState)
|
|
301
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.DisclosureRow, {
|
|
302
|
+
rowClassName: CordisDefineRow_module_css_default.row,
|
|
303
|
+
titleClassName: CordisDefineRow_module_css_default.title,
|
|
304
|
+
chevronClassName: CordisDefineRow_module_css_default.chevron,
|
|
305
|
+
icon: leadingFor(card.state),
|
|
306
|
+
title: t("row.defineTitle"),
|
|
307
|
+
open,
|
|
308
|
+
expandable,
|
|
309
|
+
expandOnRowClick: true,
|
|
310
|
+
keepContentWhenOpen: true,
|
|
311
|
+
onToggle: () => {
|
|
312
|
+
setExpanded((value) => !value);
|
|
313
|
+
},
|
|
314
|
+
collapsedContent: (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
315
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
316
|
+
className: CordisDefineRow_module_css_default.separator,
|
|
317
|
+
"aria-hidden": true
|
|
318
|
+
}),
|
|
319
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
320
|
+
className: card.errorSummary === null ? CordisDefineRow_module_css_default.name : CordisDefineRow_module_css_default.errorSummary,
|
|
321
|
+
children: card.errorSummary ?? name
|
|
322
|
+
}),
|
|
323
|
+
card.errorSummary === null && (0, react_jsx_runtime.jsx)("span", {
|
|
324
|
+
className: CordisDefineRow_module_css_default.purpose,
|
|
325
|
+
children: card.purpose ?? t("purpose.missing")
|
|
326
|
+
}),
|
|
327
|
+
card.pluginId !== null && (0, react_jsx_runtime.jsx)("span", {
|
|
328
|
+
className: CordisDefineRow_module_css_default.readout,
|
|
329
|
+
children: (0, react_jsx_runtime.jsx)("span", {
|
|
330
|
+
className: CordisDefineRow_module_css_default.statusLabel,
|
|
331
|
+
children: t(READING_LABELS$1[reading])
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
] }),
|
|
335
|
+
children: (0, react_jsx_runtime.jsxs)("div", {
|
|
336
|
+
className: CordisDefineRow_module_css_default.bodyWrap,
|
|
337
|
+
children: [
|
|
338
|
+
hasSource && activeCode !== null && (0, react_jsx_runtime.jsxs)("section", {
|
|
339
|
+
className: CordisDefineRow_module_css_default.sourceCard,
|
|
340
|
+
children: [(0, react_jsx_runtime.jsx)("div", {
|
|
341
|
+
className: CordisDefineRow_module_css_default.sourceTabs,
|
|
342
|
+
role: "tablist",
|
|
343
|
+
"aria-label": t("body.source"),
|
|
344
|
+
children: ["client", "host"].map((source) => {
|
|
345
|
+
const available = source === "client" ? card.clientCode !== null : card.hostCode !== null;
|
|
346
|
+
return (0, react_jsx_runtime.jsx)("button", {
|
|
347
|
+
id: `${sourcePanelId}-${source}`,
|
|
348
|
+
type: "button",
|
|
349
|
+
role: "tab",
|
|
350
|
+
"aria-controls": sourcePanelId,
|
|
351
|
+
"aria-selected": activeSource === source,
|
|
352
|
+
className: activeSource === source ? `${CordisDefineRow_module_css_default.sourceTab} ${CordisDefineRow_module_css_default.sourceTabActive}` : CordisDefineRow_module_css_default.sourceTab,
|
|
353
|
+
disabled: !available,
|
|
354
|
+
onClick: () => {
|
|
355
|
+
setSelectedSource(source);
|
|
356
|
+
},
|
|
357
|
+
children: t(source === "client" ? "body.clientCode" : "body.hostCode")
|
|
358
|
+
}, source);
|
|
359
|
+
})
|
|
360
|
+
}), (0, react_jsx_runtime.jsx)("div", {
|
|
361
|
+
id: sourcePanelId,
|
|
362
|
+
className: CordisDefineRow_module_css_default.sourcePanel,
|
|
363
|
+
role: "tabpanel",
|
|
364
|
+
"aria-labelledby": `${sourcePanelId}-${activeSource}`,
|
|
365
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.CodeBlock, {
|
|
366
|
+
code: activeCode,
|
|
367
|
+
lang: "javascript",
|
|
368
|
+
copyLabel: t("body.copy"),
|
|
369
|
+
copiedLabel: t("body.copied"),
|
|
370
|
+
className: CordisDefineRow_module_css_default.sourceCode
|
|
371
|
+
})
|
|
372
|
+
})]
|
|
373
|
+
}),
|
|
374
|
+
card.output !== null && (0, react_jsx_runtime.jsxs)("section", {
|
|
375
|
+
className: CordisDefineRow_module_css_default.codeSection,
|
|
376
|
+
children: [(0, react_jsx_runtime.jsx)("div", {
|
|
377
|
+
className: CordisDefineRow_module_css_default.sectionLabel,
|
|
378
|
+
children: t("body.output")
|
|
379
|
+
}), (0, react_jsx_runtime.jsx)("pre", {
|
|
380
|
+
className: CordisDefineRow_module_css_default.output,
|
|
381
|
+
"data-error": card.state === "error" || void 0,
|
|
382
|
+
children: card.output
|
|
383
|
+
})]
|
|
384
|
+
}),
|
|
385
|
+
card.pluginId !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
386
|
+
className: CordisDefineRow_module_css_default.panelHint,
|
|
387
|
+
children: t("panel.hint")
|
|
388
|
+
}),
|
|
389
|
+
inspect !== void 0 && (0, react_jsx_runtime.jsxs)("button", {
|
|
390
|
+
type: "button",
|
|
391
|
+
className: CordisDefineRow_module_css_default.inspectButton,
|
|
392
|
+
onClick: inspect,
|
|
393
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutline12, {}), "Inspect"]
|
|
394
|
+
})
|
|
395
|
+
]
|
|
396
|
+
})
|
|
397
|
+
})]
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region lib/types/client/run-card-index.js
|
|
402
|
+
/** Session-local ownership index for Package business views on `cordis_run` cards. */
|
|
403
|
+
function createStore() {
|
|
404
|
+
const pointers = /* @__PURE__ */ new Map();
|
|
405
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
406
|
+
let cache;
|
|
407
|
+
return {
|
|
408
|
+
getSnapshot: () => cache ??= new Map(pointers),
|
|
409
|
+
subscribe: (listener) => {
|
|
410
|
+
listeners.add(listener);
|
|
411
|
+
return () => {
|
|
412
|
+
listeners.delete(listener);
|
|
413
|
+
};
|
|
414
|
+
},
|
|
415
|
+
observe: (pointer) => {
|
|
416
|
+
const current = pointers.get(pointer.key);
|
|
417
|
+
if (current !== void 0 && current.seq >= pointer.seq) return;
|
|
418
|
+
pointers.set(pointer.key, pointer);
|
|
419
|
+
cache = void 0;
|
|
420
|
+
for (const listener of [...listeners]) listener();
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
/** Page-lifetime registry that gives all cards of one session the same Store. */
|
|
425
|
+
var CordisRunCardRegistry = class {
|
|
426
|
+
sessions = /* @__PURE__ */ new Map();
|
|
427
|
+
/**
|
|
428
|
+
* Return the persistent page-local Store for a session.
|
|
429
|
+
* @param sessionId - session whose cards share supersession state.
|
|
430
|
+
* @returns the page-local Store retained for that session.
|
|
431
|
+
*/
|
|
432
|
+
forSession(sessionId) {
|
|
433
|
+
let store = this.sessions.get(sessionId);
|
|
434
|
+
if (store === void 0) {
|
|
435
|
+
store = createStore();
|
|
436
|
+
this.sessions.set(sessionId, store);
|
|
437
|
+
}
|
|
438
|
+
return store;
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Build the Package business-view key shared by registrations and Run cards.
|
|
443
|
+
* @param pluginId - stable Plugin identity.
|
|
444
|
+
* @param packageId - immutable Package identity.
|
|
445
|
+
* @returns the shared business-view key.
|
|
446
|
+
*/
|
|
447
|
+
function cordisToolViewKey(pluginId, packageId) {
|
|
448
|
+
return `${pluginId}.${packageId}`;
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region lib/types/client/CordisRunRow.js
|
|
452
|
+
/** `cordis_run` card and the host seat for Package-owned interactive UI. */
|
|
453
|
+
const READING_LABELS = {
|
|
454
|
+
idle: "status.idle",
|
|
455
|
+
"awaiting-approval": "status.awaitingApproval",
|
|
456
|
+
failed: "status.failed",
|
|
457
|
+
"client-pending": "status.clientPending",
|
|
458
|
+
running: "status.running",
|
|
459
|
+
removed: "status.removed",
|
|
460
|
+
superseded: "status.superseded"
|
|
461
|
+
};
|
|
462
|
+
/** Render one activation result and, when eligible, its Package-owned view. */
|
|
463
|
+
function CordisRunRow({ callId, block, inspect, renderSlot, useInventory, useLoaded, useRunCards, useActiveRuns, onObserveRunCard, t }) {
|
|
464
|
+
const card = cordisRunCard(block);
|
|
465
|
+
const inventory = useInventory((snapshot) => snapshot);
|
|
466
|
+
const loaded = useLoaded((snapshot) => snapshot);
|
|
467
|
+
const latest = useRunCards((snapshot) => snapshot);
|
|
468
|
+
const activeRuns = useActiveRuns((snapshot) => snapshot);
|
|
469
|
+
const key = card.state === "ok" && card.pluginId !== null && card.packageId !== null && card.pluginRunId !== null && card.seq !== null ? cordisToolViewKey(card.pluginId, card.packageId) : null;
|
|
470
|
+
(0, react.useEffect)(() => {
|
|
471
|
+
if (key === null || card.seq === null || card.pluginRunId === null) return;
|
|
472
|
+
onObserveRunCard({
|
|
473
|
+
key,
|
|
474
|
+
callId,
|
|
475
|
+
seq: card.seq,
|
|
476
|
+
pluginRunId: card.pluginRunId
|
|
477
|
+
});
|
|
478
|
+
}, [
|
|
479
|
+
callId,
|
|
480
|
+
card.pluginRunId,
|
|
481
|
+
card.seq,
|
|
482
|
+
key,
|
|
483
|
+
onObserveRunCard
|
|
484
|
+
]);
|
|
485
|
+
const row = card.pluginId === null ? void 0 : inventory.rows.find((candidate) => candidate.pluginId === card.pluginId);
|
|
486
|
+
const pointer = key === null ? void 0 : latest.get(key);
|
|
487
|
+
const superseded = pointer !== void 0 && pointer.callId !== callId && pointer.seq >= (card.seq ?? -1);
|
|
488
|
+
const activity = card.pluginId === null ? void 0 : activeRuns.get(card.pluginId);
|
|
489
|
+
const attempt = card.pluginRunId !== null && row?.latestRun?.pluginRunId === card.pluginRunId ? row.latestRun : void 0;
|
|
490
|
+
const awaitingApproval = attempt?.status === "awaiting-approval" || card.packageId !== null && activity?.phase === "awaiting-approval" && activity.packageId === card.packageId && (card.mode === null || activity.mode === card.mode);
|
|
491
|
+
const reading = card.pluginId !== null && inventory.removed.has(card.pluginId) ? "removed" : superseded ? "superseded" : awaitingApproval ? "awaiting-approval" : attempt?.status === "failed" ? "failed" : row !== void 0 && card.packageId !== null ? cordisVisibleStatus(row, card.packageId, loaded) : "idle";
|
|
492
|
+
const status = t(READING_LABELS[reading]);
|
|
493
|
+
const summary = card.errorSummary ?? (card.pluginId === null ? callId : `${card.pluginId}${card.packageId === null ? "" : ` · ${card.packageId}`}`);
|
|
494
|
+
const showBusiness = reading === "running" && key !== null;
|
|
495
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
496
|
+
className: CordisRunRow_module_css_default.card,
|
|
497
|
+
"data-tool": "cordis_run",
|
|
498
|
+
"data-state": card.state,
|
|
499
|
+
"data-cordis-plugin-id": card.pluginId ?? void 0,
|
|
500
|
+
"data-cordis-package-id": card.packageId ?? void 0,
|
|
501
|
+
"data-cordis-run-id": card.pluginRunId ?? void 0,
|
|
502
|
+
"data-cordis-status": reading,
|
|
503
|
+
children: [
|
|
504
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
505
|
+
className: CordisRunRow_module_css_default.row,
|
|
506
|
+
children: [
|
|
507
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
508
|
+
className: CordisRunRow_module_css_default.icon,
|
|
509
|
+
children: card.state === "error" ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "error" }) : card.state === "stopped" ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "warning" }) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCodeOutline16, { size: 14 })
|
|
510
|
+
}),
|
|
511
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
512
|
+
className: CordisRunRow_module_css_default.title,
|
|
513
|
+
children: t(card.mode === "update" ? "row.updateTitle" : "row.runTitle")
|
|
514
|
+
}),
|
|
515
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
516
|
+
className: CordisRunRow_module_css_default.separator,
|
|
517
|
+
"aria-hidden": true
|
|
518
|
+
}),
|
|
519
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
520
|
+
className: card.errorSummary === null ? CordisRunRow_module_css_default.summary : CordisRunRow_module_css_default.error,
|
|
521
|
+
children: summary
|
|
522
|
+
}),
|
|
523
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
524
|
+
className: CordisRunRow_module_css_default.status,
|
|
525
|
+
children: status
|
|
526
|
+
}),
|
|
527
|
+
inspect !== void 0 && (0, react_jsx_runtime.jsx)("button", {
|
|
528
|
+
type: "button",
|
|
529
|
+
className: CordisRunRow_module_css_default.inspect,
|
|
530
|
+
"aria-label": "Inspect",
|
|
531
|
+
onClick: inspect,
|
|
532
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconInspectOutline12, {})
|
|
533
|
+
})
|
|
534
|
+
]
|
|
535
|
+
}),
|
|
536
|
+
reading === "removed" && (0, react_jsx_runtime.jsx)("div", {
|
|
537
|
+
className: CordisRunRow_module_css_default.message,
|
|
538
|
+
children: t("run.removed")
|
|
539
|
+
}),
|
|
540
|
+
reading === "superseded" && (0, react_jsx_runtime.jsx)("div", {
|
|
541
|
+
className: CordisRunRow_module_css_default.message,
|
|
542
|
+
children: t("run.superseded")
|
|
543
|
+
}),
|
|
544
|
+
reading === "failed" && attempt?.error !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
545
|
+
className: CordisRunRow_module_css_default.message,
|
|
546
|
+
children: attempt.error.message
|
|
547
|
+
}),
|
|
548
|
+
showBusiness && card.pluginId !== null && card.packageId !== null && card.pluginRunId !== null && (0, react_jsx_runtime.jsx)("div", {
|
|
549
|
+
className: CordisRunRow_module_css_default.business,
|
|
550
|
+
"data-cordis-business-view": key,
|
|
551
|
+
children: renderSlot("tool.view.cordis", {
|
|
552
|
+
pluginId: card.pluginId,
|
|
553
|
+
packageId: card.packageId,
|
|
554
|
+
pluginRunId: card.pluginRunId
|
|
555
|
+
}, {
|
|
556
|
+
entryKey: key,
|
|
557
|
+
fallback: card.output === null ? null : (0, react_jsx_runtime.jsx)("pre", {
|
|
558
|
+
className: CordisRunRow_module_css_default.output,
|
|
559
|
+
children: card.output
|
|
560
|
+
})
|
|
561
|
+
})
|
|
562
|
+
}),
|
|
563
|
+
!showBusiness && reading !== "removed" && reading !== "superseded" && card.output !== null && (0, react_jsx_runtime.jsx)("pre", {
|
|
564
|
+
className: CordisRunRow_module_css_default.output,
|
|
565
|
+
children: card.output
|
|
566
|
+
})
|
|
567
|
+
]
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/extensions/ui-cordis/src/client/CordisPanel.module.css.mjs
|
|
572
|
+
const css = ".Nqubda_layer{flex:none;align-items:center;width:100%;height:49px;margin:8px 0 0;display:flex;position:relative}.Nqubda_footerButtons{align-items:center;width:100%;display:flex}.Nqubda_badge{width:100%;height:49px;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:none;border-radius:12px;align-items:center;gap:8px;padding:0 8px 0 6px;font-family:inherit;font-size:14px;display:inline-flex;overflow:hidden}.Nqubda_badge:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}.Nqubda_badge[data-active]{background:var(--dsw-alias-interactive-bg-hover)}.Nqubda_badgeLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.Nqubda_badgeCount{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;margin-left:auto;font-size:12px;line-height:16px}.Nqubda_layer.Nqubda_rail{width:36px;height:36px;margin:0}.Nqubda_rail .Nqubda_badge{border-radius:50%;justify-content:center;gap:0;width:36px;height:36px;padding:0}.Nqubda_rail .Nqubda_footerButtons{flex-direction:column;gap:2px}.Nqubda_panel{z-index:30;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);width:420px;max-width:calc(100vw - 24px);max-height:60vh;box-shadow:var(--dsw-shadow-lv2);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;display:flex;position:fixed;bottom:128px;left:12px;overflow:hidden}.Nqubda_header{box-sizing:border-box;border-bottom:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);flex:none;justify-content:space-between;align-items:center;min-height:44px;padding:10px 12px;display:flex}.Nqubda_body{flex:1;min-height:0;padding:4px 12px 12px;overflow-y:auto}.Nqubda_title{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500;line-height:20px}.Nqubda_note,.Nqubda_readError{color:var(--dsw-alias-label-tertiary);margin:4px 0;font-size:12px;line-height:18px}.Nqubda_readError{color:var(--dsw-alias-state-error-primary)}.Nqubda_group{color:var(--dsw-alias-label-caption);text-transform:uppercase;letter-spacing:.04em;margin:8px 0 4px;font-size:11px;font-weight:500;line-height:16px}.Nqubda_rows{flex-direction:column;gap:8px;margin:0;padding:0;list-style:none;display:flex}.Nqubda_row{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);border-radius:12px;flex-direction:column;gap:8px;padding:10px 12px;display:flex}.Nqubda_row[data-cordis-awaiting]{border-color:var(--dsw-alias-state-business-primary)}.Nqubda_rowHead{align-items:center;gap:8px;display:flex}.Nqubda_rowId{color:var(--dsw-alias-label-tertiary);font-family:var(--dsh-font-mono,monospace);flex:none;font-size:11px;line-height:20px}.Nqubda_rowName{min-width:0;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:13px;font-weight:500;line-height:20px;overflow:hidden}.Nqubda_rowStatus{background:var(--dsw-alias-button-ghost-active-fill);height:20px;color:var(--dsw-alias-label-caption);border-radius:10px;flex:none;align-items:center;padding:0 6px;font-size:11px;line-height:20px;display:inline-flex}.Nqubda_row[data-cordis-status=idle] .Nqubda_rowStatus{background:var(--dsw-alias-button-ghost-active-fill);color:var(--dsw-alias-label-caption)}.Nqubda_row[data-cordis-status=awaiting-approval] .Nqubda_rowStatus,.Nqubda_row[data-cordis-status=client-pending] .Nqubda_rowStatus{background:var(--dsw-alias-state-warn-tertiary);color:var(--dsw-alias-state-warn-label)}.Nqubda_row[data-cordis-status=failed] .Nqubda_rowStatus{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}.Nqubda_row[data-cordis-status=running] .Nqubda_rowStatus{background:var(--dsw-alias-state-success-tertiary);color:var(--dsw-alias-state-success-primary)}.Nqubda_rowDetail{align-items:center;gap:8px;min-height:28px;display:flex}.Nqubda_versionPicker{color:var(--dsw-alias-label-caption);align-items:center;gap:8px;font-size:11px;line-height:18px;display:flex}.Nqubda_versionPicker select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);min-width:0;height:26px;color:var(--dsw-alias-label-secondary);font:inherit;border-radius:7px;flex:1;padding:0 8px}.Nqubda_rowPurpose{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:1;font-size:12px;line-height:18px;overflow:hidden}.Nqubda_rowError{color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:18px}.Nqubda_rowActions{flex:none;align-items:center;gap:10px;display:flex}.Nqubda_transition{min-width:0;color:var(--dsw-alias-label-caption);align-items:center;gap:8px;font-size:11px;line-height:18px;display:flex}.Nqubda_transitionActions{gap:6px;margin-left:auto;display:flex}.Nqubda_transitionActions button{border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border-radius:999px;padding:2px 8px}.Nqubda_transitionActions button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.Nqubda_transitionActions button:disabled{opacity:.4;cursor:default}.Nqubda_activeVersion{color:var(--dsw-alias-label-caption);font-size:11px;line-height:16px}.Nqubda_actionButton{width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:999px;justify-content:center;align-items:center;padding:0;display:inline-flex}.Nqubda_actionButton:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.Nqubda_actionButton:disabled{opacity:.4;cursor:default}.Nqubda_doubleCheck{width:17px;height:14px;display:inline-block;position:relative}.Nqubda_doubleCheck svg{position:absolute;top:1px}.Nqubda_doubleCheck svg:first-child{opacity:.7;left:0}.Nqubda_doubleCheck svg:last-child{left:5px}";
|
|
573
|
+
const tagId = "@deepseek-ai/dsh-client-ui-cordis/CordisPanel.module.css";
|
|
574
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
575
|
+
const tag = document.createElement("style");
|
|
576
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-cordis";
|
|
577
|
+
tag.dataset.pluginCss = tagId;
|
|
578
|
+
tag.textContent = css;
|
|
579
|
+
document.head.appendChild(tag);
|
|
580
|
+
}
|
|
581
|
+
var CordisPanel_module_css_default = {
|
|
582
|
+
"title": "Nqubda_title",
|
|
583
|
+
"doubleCheck": "Nqubda_doubleCheck",
|
|
584
|
+
"rail": "Nqubda_rail",
|
|
585
|
+
"rowActions": "Nqubda_rowActions",
|
|
586
|
+
"note": "Nqubda_note",
|
|
587
|
+
"group": "Nqubda_group",
|
|
588
|
+
"versionPicker": "Nqubda_versionPicker",
|
|
589
|
+
"transition": "Nqubda_transition",
|
|
590
|
+
"actionButton": "Nqubda_actionButton",
|
|
591
|
+
"badge": "Nqubda_badge",
|
|
592
|
+
"rowName": "Nqubda_rowName",
|
|
593
|
+
"rowStatus": "Nqubda_rowStatus",
|
|
594
|
+
"activeVersion": "Nqubda_activeVersion",
|
|
595
|
+
"readError": "Nqubda_readError",
|
|
596
|
+
"rows": "Nqubda_rows",
|
|
597
|
+
"badgeLabel": "Nqubda_badgeLabel",
|
|
598
|
+
"panel": "Nqubda_panel",
|
|
599
|
+
"body": "Nqubda_body",
|
|
600
|
+
"rowError": "Nqubda_rowError",
|
|
601
|
+
"transitionActions": "Nqubda_transitionActions",
|
|
602
|
+
"badgeCount": "Nqubda_badgeCount",
|
|
603
|
+
"footerButtons": "Nqubda_footerButtons",
|
|
604
|
+
"rowHead": "Nqubda_rowHead",
|
|
605
|
+
"row": "Nqubda_row",
|
|
606
|
+
"layer": "Nqubda_layer",
|
|
607
|
+
"rowDetail": "Nqubda_rowDetail",
|
|
608
|
+
"rowPurpose": "Nqubda_rowPurpose",
|
|
609
|
+
"rowId": "Nqubda_rowId",
|
|
610
|
+
"header": "Nqubda_header"
|
|
611
|
+
};
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region lib/types/client/CordisPanel.js
|
|
614
|
+
/** Frame-wide dynamic Plugin inventory, approvals, versions, and lifecycle actions. */
|
|
615
|
+
const STATUS_LABELS = {
|
|
616
|
+
idle: "status.idle",
|
|
617
|
+
"awaiting-approval": "status.awaitingApproval",
|
|
618
|
+
"client-pending": "status.clientPending",
|
|
619
|
+
running: "status.running",
|
|
620
|
+
failed: "status.failed"
|
|
621
|
+
};
|
|
622
|
+
const RENDER_FAILURE_LABELS = {
|
|
623
|
+
abdicated: "render.failedAbdicated",
|
|
624
|
+
held: "render.failedHeld"
|
|
625
|
+
};
|
|
626
|
+
function selectedPackageIdOf({ pluginId, listed, activity }, selected) {
|
|
627
|
+
const selectedPackageId = selected[pluginId];
|
|
628
|
+
if (selectedPackageId !== void 0 && listed?.packages.some((pkg) => pkg.packageId === selectedPackageId)) return selectedPackageId;
|
|
629
|
+
return listed?.nextPackageId ?? listed?.currentPackageId ?? listed?.packages.at(-1)?.packageId ?? activity?.packageId;
|
|
630
|
+
}
|
|
631
|
+
function visiblePanelStatus(view, selectedPackageId, loaded) {
|
|
632
|
+
const { listed, activity } = view;
|
|
633
|
+
const latest = listed?.latestRun;
|
|
634
|
+
if (activity?.phase === "awaiting-approval" || latest?.status === "awaiting-approval") return "awaiting-approval";
|
|
635
|
+
if (latest?.status === "failed" && latest.packageId === selectedPackageId) return "failed";
|
|
636
|
+
if (listed?.activeRun === void 0) return "idle";
|
|
637
|
+
return cordisVisibleStatus(listed, listed.activeRun.packageId, loaded);
|
|
638
|
+
}
|
|
639
|
+
function blockingFirst(rows) {
|
|
640
|
+
return [...rows.filter((row) => row.activity?.phase === "awaiting-approval"), ...rows.filter((row) => row.activity?.phase !== "awaiting-approval")];
|
|
641
|
+
}
|
|
642
|
+
function RowAction({ label, children, ...props }) {
|
|
643
|
+
return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
644
|
+
label,
|
|
645
|
+
side: "bottom",
|
|
646
|
+
delayMs: 500,
|
|
647
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
648
|
+
type: "button",
|
|
649
|
+
className: CordisPanel_module_css_default.actionButton,
|
|
650
|
+
"aria-label": label,
|
|
651
|
+
...props,
|
|
652
|
+
children
|
|
653
|
+
})
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function DoubleCheckIcon() {
|
|
657
|
+
return (0, react_jsx_runtime.jsxs)("span", {
|
|
658
|
+
className: CordisPanel_module_css_default.doubleCheck,
|
|
659
|
+
"aria-hidden": true,
|
|
660
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 12 }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 12 })]
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
/** Render the inventory panel and its unified footer action. */
|
|
664
|
+
function CordisPanel({ wide, useSessions, useInventory, useActiveRuns, useRunErrors, useLoaded, useRenderFailures, onApprove, onDecline, onRun, onStop, onRemove, onRefresh, t }) {
|
|
665
|
+
const inventory = useInventory((snapshot) => snapshot);
|
|
666
|
+
const activeRuns = useActiveRuns((snapshot) => snapshot);
|
|
667
|
+
const errors = useRunErrors((snapshot) => snapshot);
|
|
668
|
+
const loaded = useLoaded((snapshot) => snapshot);
|
|
669
|
+
const renderFailures = useRenderFailures((snapshot) => snapshot);
|
|
670
|
+
const current = useSessions((state) => state.current);
|
|
671
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
672
|
+
const [selected, setSelected] = (0, react.useState)({});
|
|
673
|
+
const [pending, setPending] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
674
|
+
const [actionErrors, setActionErrors] = (0, react.useState)(/* @__PURE__ */ new Map());
|
|
675
|
+
const visibleRequests = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
676
|
+
(0, react.useEffect)(() => {
|
|
677
|
+
const now = /* @__PURE__ */ new Set();
|
|
678
|
+
for (const activity of activeRuns.values()) if (activity.phase === "awaiting-approval") now.add(activity.requestId);
|
|
679
|
+
const discovered = [...now].some((requestId) => !visibleRequests.current.has(requestId));
|
|
680
|
+
visibleRequests.current = now;
|
|
681
|
+
if (discovered) setOpen(true);
|
|
682
|
+
}, [activeRuns]);
|
|
683
|
+
(0, react.useEffect)(() => {
|
|
684
|
+
onRefresh();
|
|
685
|
+
}, [onRefresh]);
|
|
686
|
+
(0, react.useEffect)(() => {
|
|
687
|
+
if (open) onRefresh();
|
|
688
|
+
}, [onRefresh, open]);
|
|
689
|
+
const byPlugin = /* @__PURE__ */ new Map();
|
|
690
|
+
for (const listed of inventory.rows) {
|
|
691
|
+
const activity = activeRuns.get(listed.pluginId);
|
|
692
|
+
byPlugin.set(listed.pluginId, {
|
|
693
|
+
pluginId: listed.pluginId,
|
|
694
|
+
agentId: activity?.agentId ?? listed.agentId,
|
|
695
|
+
listed,
|
|
696
|
+
...activity === void 0 ? {} : { activity }
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
for (const [pluginId, activity] of activeRuns) {
|
|
700
|
+
if (byPlugin.has(pluginId)) continue;
|
|
701
|
+
byPlugin.set(pluginId, {
|
|
702
|
+
pluginId,
|
|
703
|
+
agentId: activity.agentId,
|
|
704
|
+
activity
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
const all = [...byPlugin.values()];
|
|
708
|
+
const mine = blockingFirst(all.filter((row) => current !== void 0 && row.agentId === current));
|
|
709
|
+
const theirs = blockingFirst(all.filter((row) => current === void 0 || row.agentId !== current));
|
|
710
|
+
const approvals = [...activeRuns.values()].filter((activity) => activity.phase === "awaiting-approval").length;
|
|
711
|
+
const running = all.filter((view) => visiblePanelStatus(view, selectedPackageIdOf(view, selected), loaded) === "running").length;
|
|
712
|
+
if (all.length === 0) return null;
|
|
713
|
+
const runAction = async (pluginId, action) => {
|
|
714
|
+
if (pending.has(pluginId)) return;
|
|
715
|
+
setPending((currentPending) => new Set(currentPending).add(pluginId));
|
|
716
|
+
setActionErrors((currentErrors) => {
|
|
717
|
+
const next = new Map(currentErrors);
|
|
718
|
+
next.delete(pluginId);
|
|
719
|
+
return next;
|
|
720
|
+
});
|
|
721
|
+
try {
|
|
722
|
+
const result = await action();
|
|
723
|
+
if (result !== void 0 && !result.ok) setActionErrors((currentErrors) => new Map(currentErrors).set(pluginId, result.message ?? "operation failed"));
|
|
724
|
+
} catch (error) {
|
|
725
|
+
setActionErrors((currentErrors) => new Map(currentErrors).set(pluginId, error instanceof Error ? error.message : String(error)));
|
|
726
|
+
} finally {
|
|
727
|
+
setPending((currentPending) => {
|
|
728
|
+
const next = new Set(currentPending);
|
|
729
|
+
next.delete(pluginId);
|
|
730
|
+
return next;
|
|
731
|
+
});
|
|
732
|
+
onRefresh();
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const renderRow = (view) => {
|
|
736
|
+
const { pluginId, listed, activity } = view;
|
|
737
|
+
const selectedPackageId = selectedPackageIdOf(view, selected);
|
|
738
|
+
const selectedPackage = listed !== void 0 && selectedPackageId !== void 0 ? packageOf(listed, selectedPackageId) : void 0;
|
|
739
|
+
const activePackage = listed?.activeRun === void 0 ? void 0 : packageOf(listed, listed.activeRun.packageId);
|
|
740
|
+
const name = selectedPackage?.name ?? (activity?.phase === "awaiting-approval" ? activity.name : pluginId);
|
|
741
|
+
const purpose = selectedPackage?.purpose ?? (activity?.phase === "awaiting-approval" ? activity.purpose : "");
|
|
742
|
+
const latest = listed?.latestRun;
|
|
743
|
+
const awaiting = activity?.phase === "awaiting-approval" ? activity.requestId : latest?.status === "awaiting-approval" ? latest.approvalRequestId : void 0;
|
|
744
|
+
const status = visiblePanelStatus(view, selectedPackageId, loaded);
|
|
745
|
+
const busy = pending.has(pluginId) || activity?.phase === "orchestrating";
|
|
746
|
+
const failure = errors.get(pluginId);
|
|
747
|
+
const hostFailure = latest?.status === "failed" ? latest.error : void 0;
|
|
748
|
+
const renderFailure = renderFailures.get(pluginId);
|
|
749
|
+
const actionError = actionErrors.get(pluginId);
|
|
750
|
+
const nextPackageId = listed?.nextPackageId !== void 0 && listed.nextPackageId !== listed.currentPackageId ? listed.nextPackageId : void 0;
|
|
751
|
+
const currentPackageId = listed?.currentPackageId;
|
|
752
|
+
const runMode = listed?.currentPackageId !== void 0 && selectedPackageId !== listed.currentPackageId ? "update" : "run";
|
|
753
|
+
return (0, react_jsx_runtime.jsxs)("li", {
|
|
754
|
+
className: CordisPanel_module_css_default.row,
|
|
755
|
+
"data-cordis-row": pluginId,
|
|
756
|
+
"data-cordis-status": status,
|
|
757
|
+
"data-cordis-awaiting": awaiting !== void 0 || void 0,
|
|
758
|
+
children: [
|
|
759
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
760
|
+
className: CordisPanel_module_css_default.rowHead,
|
|
761
|
+
children: [
|
|
762
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
763
|
+
className: CordisPanel_module_css_default.rowId,
|
|
764
|
+
children: pluginId
|
|
765
|
+
}),
|
|
766
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
767
|
+
className: CordisPanel_module_css_default.rowName,
|
|
768
|
+
children: name
|
|
769
|
+
}),
|
|
770
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
771
|
+
className: CordisPanel_module_css_default.rowStatus,
|
|
772
|
+
children: t(STATUS_LABELS[status])
|
|
773
|
+
})
|
|
774
|
+
]
|
|
775
|
+
}),
|
|
776
|
+
listed !== void 0 && listed.packages.length > 1 && selectedPackageId !== void 0 && (0, react_jsx_runtime.jsxs)("label", {
|
|
777
|
+
className: CordisPanel_module_css_default.versionPicker,
|
|
778
|
+
children: [(0, react_jsx_runtime.jsx)("span", { children: t("panel.version") }), (0, react_jsx_runtime.jsx)("select", {
|
|
779
|
+
value: selectedPackageId,
|
|
780
|
+
disabled: busy,
|
|
781
|
+
onChange: (event) => {
|
|
782
|
+
setSelected((currentSelected) => ({
|
|
783
|
+
...currentSelected,
|
|
784
|
+
[pluginId]: event.target.value
|
|
785
|
+
}));
|
|
786
|
+
},
|
|
787
|
+
children: listed.packages.map((pkg) => (0, react_jsx_runtime.jsx)("option", {
|
|
788
|
+
value: pkg.packageId,
|
|
789
|
+
children: `${pkg.name} · ${pkg.packageId}`
|
|
790
|
+
}, pkg.packageId))
|
|
791
|
+
})]
|
|
792
|
+
}),
|
|
793
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
794
|
+
className: CordisPanel_module_css_default.rowDetail,
|
|
795
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
796
|
+
className: CordisPanel_module_css_default.rowPurpose,
|
|
797
|
+
children: purpose
|
|
798
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
799
|
+
className: CordisPanel_module_css_default.rowActions,
|
|
800
|
+
children: [
|
|
801
|
+
awaiting !== void 0 && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
802
|
+
(0, react_jsx_runtime.jsx)(RowAction, {
|
|
803
|
+
label: t("action.approveOnce"),
|
|
804
|
+
"data-cordis-approve": awaiting,
|
|
805
|
+
disabled: busy,
|
|
806
|
+
onClick: () => {
|
|
807
|
+
runAction(pluginId, async () => {
|
|
808
|
+
await onApprove(awaiting, false);
|
|
809
|
+
setOpen(false);
|
|
810
|
+
});
|
|
811
|
+
},
|
|
812
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, { size: 14 })
|
|
813
|
+
}),
|
|
814
|
+
(0, react_jsx_runtime.jsx)(RowAction, {
|
|
815
|
+
label: t("action.approvePlugin"),
|
|
816
|
+
"data-cordis-approve-plugin": awaiting,
|
|
817
|
+
disabled: busy,
|
|
818
|
+
onClick: () => {
|
|
819
|
+
runAction(pluginId, async () => {
|
|
820
|
+
await onApprove(awaiting, true);
|
|
821
|
+
setOpen(false);
|
|
822
|
+
});
|
|
823
|
+
},
|
|
824
|
+
children: (0, react_jsx_runtime.jsx)(DoubleCheckIcon, {})
|
|
825
|
+
}),
|
|
826
|
+
(0, react_jsx_runtime.jsx)(RowAction, {
|
|
827
|
+
label: t("action.decline"),
|
|
828
|
+
"data-cordis-decline": awaiting,
|
|
829
|
+
disabled: busy,
|
|
830
|
+
onClick: () => {
|
|
831
|
+
runAction(pluginId, async () => {
|
|
832
|
+
await onDecline(awaiting);
|
|
833
|
+
setOpen(false);
|
|
834
|
+
});
|
|
835
|
+
},
|
|
836
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCloseOutline16, { size: 14 })
|
|
837
|
+
})
|
|
838
|
+
] }),
|
|
839
|
+
awaiting === void 0 && listed !== void 0 && selectedPackageId !== void 0 && listed.activeRun === void 0 && (0, react_jsx_runtime.jsx)(RowAction, {
|
|
840
|
+
label: t("action.run"),
|
|
841
|
+
"data-cordis-switch": "run",
|
|
842
|
+
disabled: busy,
|
|
843
|
+
onClick: () => {
|
|
844
|
+
runAction(pluginId, () => onRun({
|
|
845
|
+
agentId: listed.agentId,
|
|
846
|
+
pluginId,
|
|
847
|
+
packageId: selectedPackageId,
|
|
848
|
+
mode: runMode,
|
|
849
|
+
hasClientHalf: selectedPackage?.hasClientHalf === true
|
|
850
|
+
}));
|
|
851
|
+
},
|
|
852
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutline16, { size: 14 })
|
|
853
|
+
}),
|
|
854
|
+
awaiting === void 0 && listed !== void 0 && listed.activeRun !== void 0 && selectedPackageId !== listed.activeRun.packageId && selectedPackage !== void 0 && (0, react_jsx_runtime.jsx)(RowAction, {
|
|
855
|
+
label: t("action.run"),
|
|
856
|
+
"data-cordis-switch": "run",
|
|
857
|
+
disabled: busy,
|
|
858
|
+
onClick: () => {
|
|
859
|
+
runAction(pluginId, () => onRun({
|
|
860
|
+
agentId: listed.agentId,
|
|
861
|
+
pluginId,
|
|
862
|
+
packageId: selectedPackage.packageId,
|
|
863
|
+
mode: runMode,
|
|
864
|
+
hasClientHalf: selectedPackage.hasClientHalf
|
|
865
|
+
}));
|
|
866
|
+
},
|
|
867
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutline16, { size: 14 })
|
|
868
|
+
}),
|
|
869
|
+
awaiting === void 0 && listed !== void 0 && listed.activeRun !== void 0 && status === "client-pending" && activePackage !== void 0 && selectedPackageId === listed.activeRun.packageId && (0, react_jsx_runtime.jsx)(RowAction, {
|
|
870
|
+
label: t("action.run"),
|
|
871
|
+
"data-cordis-switch": "run",
|
|
872
|
+
disabled: busy,
|
|
873
|
+
onClick: () => {
|
|
874
|
+
runAction(pluginId, () => onRun({
|
|
875
|
+
agentId: listed.agentId,
|
|
876
|
+
pluginId,
|
|
877
|
+
packageId: activePackage.packageId,
|
|
878
|
+
mode: "run",
|
|
879
|
+
hasClientHalf: true
|
|
880
|
+
}));
|
|
881
|
+
},
|
|
882
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconPlayOutline16, { size: 14 })
|
|
883
|
+
}),
|
|
884
|
+
awaiting === void 0 && listed !== void 0 && listed.activeRun !== void 0 && (0, react_jsx_runtime.jsx)(RowAction, {
|
|
885
|
+
label: t("action.stop"),
|
|
886
|
+
"data-cordis-switch": "stop",
|
|
887
|
+
disabled: busy,
|
|
888
|
+
onClick: () => {
|
|
889
|
+
runAction(pluginId, () => onStop(listed.agentId, pluginId));
|
|
890
|
+
},
|
|
891
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconStopFill16, { size: 14 })
|
|
892
|
+
}),
|
|
893
|
+
awaiting === void 0 && listed !== void 0 && (0, react_jsx_runtime.jsx)(RowAction, {
|
|
894
|
+
label: t("action.remove"),
|
|
895
|
+
"data-cordis-remove": pluginId,
|
|
896
|
+
disabled: busy,
|
|
897
|
+
onClick: () => {
|
|
898
|
+
runAction(pluginId, () => onRemove(listed.agentId, pluginId));
|
|
899
|
+
},
|
|
900
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconTrashOutline16, { size: 14 })
|
|
901
|
+
})
|
|
902
|
+
]
|
|
903
|
+
})]
|
|
904
|
+
}),
|
|
905
|
+
awaiting === void 0 && nextPackageId !== void 0 && listed !== void 0 && (0, react_jsx_runtime.jsxs)("div", {
|
|
906
|
+
className: CordisPanel_module_css_default.transition,
|
|
907
|
+
children: [
|
|
908
|
+
(0, react_jsx_runtime.jsx)("span", { children: currentPackageId === void 0 ? "" : t("panel.current", { packageId: currentPackageId }) }),
|
|
909
|
+
(0, react_jsx_runtime.jsx)("span", { children: t("panel.next", { packageId: nextPackageId }) }),
|
|
910
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
911
|
+
className: CordisPanel_module_css_default.transitionActions,
|
|
912
|
+
children: [(0, react_jsx_runtime.jsx)("button", {
|
|
913
|
+
type: "button",
|
|
914
|
+
disabled: busy,
|
|
915
|
+
onClick: () => {
|
|
916
|
+
runAction(pluginId, () => onRun({
|
|
917
|
+
agentId: listed.agentId,
|
|
918
|
+
pluginId,
|
|
919
|
+
packageId: nextPackageId,
|
|
920
|
+
mode: currentPackageId === void 0 ? "run" : "update",
|
|
921
|
+
hasClientHalf: packageOf(listed, nextPackageId)?.hasClientHalf === true
|
|
922
|
+
}));
|
|
923
|
+
},
|
|
924
|
+
children: t("action.retry")
|
|
925
|
+
}), currentPackageId !== void 0 && (0, react_jsx_runtime.jsx)("button", {
|
|
926
|
+
type: "button",
|
|
927
|
+
disabled: busy,
|
|
928
|
+
onClick: () => {
|
|
929
|
+
runAction(pluginId, () => onRun({
|
|
930
|
+
agentId: listed.agentId,
|
|
931
|
+
pluginId,
|
|
932
|
+
packageId: currentPackageId,
|
|
933
|
+
mode: "run",
|
|
934
|
+
hasClientHalf: packageOf(listed, currentPackageId)?.hasClientHalf === true
|
|
935
|
+
}));
|
|
936
|
+
},
|
|
937
|
+
children: t("action.rollback")
|
|
938
|
+
})]
|
|
939
|
+
})
|
|
940
|
+
]
|
|
941
|
+
}),
|
|
942
|
+
failure !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
943
|
+
className: CordisPanel_module_css_default.rowError,
|
|
944
|
+
role: "alert",
|
|
945
|
+
children: `${failure.message} (${failure.reason})`
|
|
946
|
+
}),
|
|
947
|
+
failure === void 0 && hostFailure !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
948
|
+
className: CordisPanel_module_css_default.rowError,
|
|
949
|
+
role: "alert",
|
|
950
|
+
children: `${hostFailure.message} (${hostFailure.phase})`
|
|
951
|
+
}),
|
|
952
|
+
actionError !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
953
|
+
className: CordisPanel_module_css_default.rowError,
|
|
954
|
+
role: "alert",
|
|
955
|
+
children: actionError
|
|
956
|
+
}),
|
|
957
|
+
renderFailure !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
958
|
+
className: CordisPanel_module_css_default.rowError,
|
|
959
|
+
role: "alert",
|
|
960
|
+
"data-cordis-render-failure": renderFailure.slot,
|
|
961
|
+
"data-cordis-render-abdicated": renderFailure.abdicated || void 0,
|
|
962
|
+
children: `${t(RENDER_FAILURE_LABELS[renderFailure.abdicated ? "abdicated" : "held"], { slot: renderFailure.slot })} ${renderFailure.message}`
|
|
963
|
+
}),
|
|
964
|
+
activePackage !== void 0 && activePackage.packageId !== selectedPackageId && (0, react_jsx_runtime.jsx)("span", {
|
|
965
|
+
className: CordisPanel_module_css_default.activeVersion,
|
|
966
|
+
children: `${t("status.running")}: ${activePackage.name} · ${activePackage.packageId}`
|
|
967
|
+
})
|
|
968
|
+
]
|
|
969
|
+
}, pluginId);
|
|
970
|
+
};
|
|
971
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
972
|
+
className: wide ? CordisPanel_module_css_default.layer : `${CordisPanel_module_css_default.layer} ${CordisPanel_module_css_default.rail}`,
|
|
973
|
+
children: [open && (0, react_jsx_runtime.jsxs)("section", {
|
|
974
|
+
className: CordisPanel_module_css_default.panel,
|
|
975
|
+
"data-cordis-panel": true,
|
|
976
|
+
"aria-label": t("panel.title"),
|
|
977
|
+
children: [(0, react_jsx_runtime.jsx)("header", {
|
|
978
|
+
className: CordisPanel_module_css_default.header,
|
|
979
|
+
children: (0, react_jsx_runtime.jsx)("span", {
|
|
980
|
+
className: CordisPanel_module_css_default.title,
|
|
981
|
+
children: t("panel.title")
|
|
982
|
+
})
|
|
983
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
984
|
+
className: CordisPanel_module_css_default.body,
|
|
985
|
+
children: [
|
|
986
|
+
inventory.error !== void 0 && (0, react_jsx_runtime.jsx)("p", {
|
|
987
|
+
className: CordisPanel_module_css_default.readError,
|
|
988
|
+
role: "alert",
|
|
989
|
+
children: t("panel.readFailed", { message: inventory.error })
|
|
990
|
+
}),
|
|
991
|
+
!inventory.read && inventory.error === void 0 && (0, react_jsx_runtime.jsx)("p", {
|
|
992
|
+
className: CordisPanel_module_css_default.note,
|
|
993
|
+
children: t("panel.loading")
|
|
994
|
+
}),
|
|
995
|
+
inventory.read && all.length === 0 && (0, react_jsx_runtime.jsx)("p", {
|
|
996
|
+
className: CordisPanel_module_css_default.note,
|
|
997
|
+
children: t("panel.empty")
|
|
998
|
+
}),
|
|
999
|
+
mine.length > 0 && (0, react_jsx_runtime.jsxs)("section", { children: [(0, react_jsx_runtime.jsx)("h3", {
|
|
1000
|
+
className: CordisPanel_module_css_default.group,
|
|
1001
|
+
children: t("panel.group.current")
|
|
1002
|
+
}), (0, react_jsx_runtime.jsx)("ul", {
|
|
1003
|
+
className: CordisPanel_module_css_default.rows,
|
|
1004
|
+
children: mine.map(renderRow)
|
|
1005
|
+
})] }),
|
|
1006
|
+
theirs.length > 0 && (0, react_jsx_runtime.jsxs)("section", { children: [(0, react_jsx_runtime.jsx)("h3", {
|
|
1007
|
+
className: CordisPanel_module_css_default.group,
|
|
1008
|
+
children: t("panel.group.others")
|
|
1009
|
+
}), (0, react_jsx_runtime.jsx)("ul", {
|
|
1010
|
+
className: CordisPanel_module_css_default.rows,
|
|
1011
|
+
children: theirs.map(renderRow)
|
|
1012
|
+
})] })
|
|
1013
|
+
]
|
|
1014
|
+
})]
|
|
1015
|
+
}), (0, react_jsx_runtime.jsx)("div", {
|
|
1016
|
+
className: CordisPanel_module_css_default.footerButtons,
|
|
1017
|
+
children: (0, react_jsx_runtime.jsxs)("button", {
|
|
1018
|
+
type: "button",
|
|
1019
|
+
className: CordisPanel_module_css_default.badge,
|
|
1020
|
+
"data-cordis-badge": all.length,
|
|
1021
|
+
"data-cordis-approval-badge": approvals,
|
|
1022
|
+
"data-active": approvals > 0 || void 0,
|
|
1023
|
+
"aria-label": t("panel.plugins.aria"),
|
|
1024
|
+
"aria-expanded": open,
|
|
1025
|
+
onClick: () => {
|
|
1026
|
+
setOpen((value) => !value);
|
|
1027
|
+
},
|
|
1028
|
+
children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCordisPluginOutline14, {}), wide && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)("span", {
|
|
1029
|
+
className: CordisPanel_module_css_default.badgeLabel,
|
|
1030
|
+
children: t("panel.trigger")
|
|
1031
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
1032
|
+
className: CordisPanel_module_css_default.badgeCount,
|
|
1033
|
+
children: t("panel.runningCount", { count: running })
|
|
1034
|
+
})] })]
|
|
1035
|
+
})
|
|
1036
|
+
})]
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region lib/types/client/inventory.js
|
|
1041
|
+
/**
|
|
1042
|
+
* The host's definition registry as this page last read it, owned by the
|
|
1043
|
+
* plugin's apply closure.
|
|
1044
|
+
*
|
|
1045
|
+
* The panel is a frame-wide surface, so it cannot derive this from any session:
|
|
1046
|
+
* the registry is global and the read is a single global call. The rows are
|
|
1047
|
+
* re-read rather than patched, because the wire announcements
|
|
1048
|
+
* (`cordis/dynamic-package` / `/retract`) carry no labels and a definition
|
|
1049
|
+
* can appear or disappear between them — a patch-in-place cache would drift into
|
|
1050
|
+
* showing definitions the host no longer holds.
|
|
1051
|
+
*
|
|
1052
|
+
* Reads are single-flight: several announcements settling at once, or a badge
|
|
1053
|
+
* opening while a reconnect re-reads, must not multiply the call. Single-flight
|
|
1054
|
+
* alone would be wrong across a reconnect, though — the in-flight read belongs to
|
|
1055
|
+
* the previous connection, so a reset both discards its answer and frees the slot
|
|
1056
|
+
* for a fresh one. Without that, a reconnect either loses its re-read to the old
|
|
1057
|
+
* call or has the old host's rows published on top of it.
|
|
1058
|
+
*/
|
|
1059
|
+
/**
|
|
1060
|
+
* Create the inventory source.
|
|
1061
|
+
* @param port - the RPC seam the read goes through.
|
|
1062
|
+
* @param onError - reporter for a failed read (console in production, captured in specs).
|
|
1063
|
+
* @returns the inventory observable and its read trigger.
|
|
1064
|
+
*/
|
|
1065
|
+
function createCordisInventory(port, onError) {
|
|
1066
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1067
|
+
let snapshot = {
|
|
1068
|
+
rows: [],
|
|
1069
|
+
removed: /* @__PURE__ */ new Set(),
|
|
1070
|
+
read: false
|
|
1071
|
+
};
|
|
1072
|
+
let inFlight;
|
|
1073
|
+
let generation = 0;
|
|
1074
|
+
const publish = (next) => {
|
|
1075
|
+
snapshot = next;
|
|
1076
|
+
for (const listener of [...listeners]) listener();
|
|
1077
|
+
};
|
|
1078
|
+
return {
|
|
1079
|
+
getSnapshot: () => snapshot,
|
|
1080
|
+
subscribe: (fn) => {
|
|
1081
|
+
listeners.add(fn);
|
|
1082
|
+
return () => {
|
|
1083
|
+
listeners.delete(fn);
|
|
1084
|
+
};
|
|
1085
|
+
},
|
|
1086
|
+
refresh: () => {
|
|
1087
|
+
if (inFlight !== void 0) return;
|
|
1088
|
+
const issued = generation;
|
|
1089
|
+
inFlight = port.inventory().then((rows) => {
|
|
1090
|
+
if (issued !== generation) return;
|
|
1091
|
+
const removed = new Set(snapshot.removed);
|
|
1092
|
+
const live = new Set(rows.map((row) => row.pluginId));
|
|
1093
|
+
for (const previous of snapshot.rows) if (!live.has(previous.pluginId)) removed.add(previous.pluginId);
|
|
1094
|
+
publish({
|
|
1095
|
+
rows,
|
|
1096
|
+
removed,
|
|
1097
|
+
read: true
|
|
1098
|
+
});
|
|
1099
|
+
}, (error) => {
|
|
1100
|
+
if (issued !== generation) return;
|
|
1101
|
+
onError(error);
|
|
1102
|
+
publish({
|
|
1103
|
+
rows: snapshot.rows,
|
|
1104
|
+
removed: snapshot.removed,
|
|
1105
|
+
read: snapshot.read,
|
|
1106
|
+
error: error instanceof Error ? error.message : "reading the cordis inventory failed"
|
|
1107
|
+
});
|
|
1108
|
+
}).then(() => {
|
|
1109
|
+
if (issued === generation) inFlight = void 0;
|
|
1110
|
+
});
|
|
1111
|
+
},
|
|
1112
|
+
retire: (pluginId) => {
|
|
1113
|
+
const removed = new Set(snapshot.removed);
|
|
1114
|
+
removed.add(pluginId);
|
|
1115
|
+
publish({
|
|
1116
|
+
...snapshot,
|
|
1117
|
+
rows: snapshot.rows.filter((row) => row.pluginId !== pluginId),
|
|
1118
|
+
removed
|
|
1119
|
+
});
|
|
1120
|
+
},
|
|
1121
|
+
reset: () => {
|
|
1122
|
+
generation += 1;
|
|
1123
|
+
inFlight = void 0;
|
|
1124
|
+
publish({
|
|
1125
|
+
rows: [],
|
|
1126
|
+
removed: snapshot.removed,
|
|
1127
|
+
read: false
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region lib/types/client/locales.js
|
|
1134
|
+
/** Cordis dynamic-plugin UI dictionaries. */
|
|
1135
|
+
const NS = "cordis";
|
|
1136
|
+
/** Simplified Chinese Cordis UI messages. */
|
|
1137
|
+
const zh = {
|
|
1138
|
+
"row.defineTitle": "注册 Cordis 插件",
|
|
1139
|
+
"row.runTitle": "运行 Cordis 插件",
|
|
1140
|
+
"row.updateTitle": "更新 Cordis 插件",
|
|
1141
|
+
"row.stopTitle": "停止 Cordis 插件",
|
|
1142
|
+
"row.removeTitle": "移除 Cordis 插件",
|
|
1143
|
+
"purpose.missing": "(未填写用途)",
|
|
1144
|
+
"status.idle": "待激活",
|
|
1145
|
+
"status.awaitingApproval": "待审批",
|
|
1146
|
+
"status.failed": "运行失败",
|
|
1147
|
+
"status.clientPending": "Client 待激活",
|
|
1148
|
+
"status.running": "运行中",
|
|
1149
|
+
"status.removed": "已移除",
|
|
1150
|
+
"status.superseded": "已有更新",
|
|
1151
|
+
"run.removed": "包已不存在",
|
|
1152
|
+
"run.superseded": "已有更新的运行卡片,请查看下方",
|
|
1153
|
+
"panel.hint": "运行控制在左下角设置上方的 Cordis 面板",
|
|
1154
|
+
"panel.plugins.aria": "Cordis 插件",
|
|
1155
|
+
"panel.approvals.aria": "Cordis 审批",
|
|
1156
|
+
"panel.trigger": "Cordis Plugin",
|
|
1157
|
+
"panel.runningCount": "{count} running",
|
|
1158
|
+
"panel.title": "Cordis 插件",
|
|
1159
|
+
"panel.empty": "还没有定义任何插件",
|
|
1160
|
+
"panel.loading": "读取中…",
|
|
1161
|
+
"panel.readFailed": "读取插件清单失败:{message}",
|
|
1162
|
+
"panel.group.current": "当前会话",
|
|
1163
|
+
"panel.group.others": "其他会话",
|
|
1164
|
+
"panel.version": "版本",
|
|
1165
|
+
"panel.current": "当前:{packageId}",
|
|
1166
|
+
"panel.next": "待切换:{packageId}",
|
|
1167
|
+
"action.approve": "允许",
|
|
1168
|
+
"action.approveOnce": "仅允许此版本",
|
|
1169
|
+
"action.approvePlugin": "允许此插件的后续版本",
|
|
1170
|
+
"action.decline": "拒绝",
|
|
1171
|
+
"action.run": "运行",
|
|
1172
|
+
"action.stop": "停止",
|
|
1173
|
+
"action.remove": "移除",
|
|
1174
|
+
"action.retry": "重试",
|
|
1175
|
+
"action.rollback": "回退",
|
|
1176
|
+
"render.failedAbdicated": "{slot} 渲染失败,已恢复默认界面:",
|
|
1177
|
+
"render.failedHeld": "{slot} 渲染失败:",
|
|
1178
|
+
"a11y.defining": "正在定义插件",
|
|
1179
|
+
"a11y.failed": "定义失败",
|
|
1180
|
+
"a11y.stopped": "定义已中断",
|
|
1181
|
+
"body.source": "插件代码",
|
|
1182
|
+
"body.hostCode": "Host",
|
|
1183
|
+
"body.clientCode": "Client",
|
|
1184
|
+
"body.output": "结果",
|
|
1185
|
+
"body.copy": "复制",
|
|
1186
|
+
"body.copied": "已复制"
|
|
1187
|
+
};
|
|
1188
|
+
/** English Cordis UI messages. */
|
|
1189
|
+
const en = {
|
|
1190
|
+
"row.defineTitle": "Register Cordis Plugin",
|
|
1191
|
+
"row.runTitle": "Run Cordis Plugin",
|
|
1192
|
+
"row.updateTitle": "Update Cordis Plugin",
|
|
1193
|
+
"row.stopTitle": "Stop Cordis Plugin",
|
|
1194
|
+
"row.removeTitle": "Remove Cordis Plugin",
|
|
1195
|
+
"purpose.missing": "(no purpose given)",
|
|
1196
|
+
"status.idle": "Ready",
|
|
1197
|
+
"status.awaitingApproval": "Awaiting approval",
|
|
1198
|
+
"status.failed": "Run failed",
|
|
1199
|
+
"status.clientPending": "Client ready to activate",
|
|
1200
|
+
"status.running": "Running",
|
|
1201
|
+
"status.removed": "Removed",
|
|
1202
|
+
"status.superseded": "Newer run available",
|
|
1203
|
+
"run.removed": "This package no longer exists",
|
|
1204
|
+
"run.superseded": "A newer run card is available below",
|
|
1205
|
+
"panel.hint": "Run controls live in the Cordis panel above Settings",
|
|
1206
|
+
"panel.plugins.aria": "Cordis plugins",
|
|
1207
|
+
"panel.approvals.aria": "Cordis approvals",
|
|
1208
|
+
"panel.trigger": "Cordis Plugin",
|
|
1209
|
+
"panel.runningCount": "{count} running",
|
|
1210
|
+
"panel.title": "Cordis plugins",
|
|
1211
|
+
"panel.empty": "No plugins defined yet",
|
|
1212
|
+
"panel.loading": "Reading…",
|
|
1213
|
+
"panel.readFailed": "Reading the plugin inventory failed: {message}",
|
|
1214
|
+
"panel.group.current": "This session",
|
|
1215
|
+
"panel.group.others": "Other sessions",
|
|
1216
|
+
"panel.version": "Version",
|
|
1217
|
+
"panel.current": "Current: {packageId}",
|
|
1218
|
+
"panel.next": "Next: {packageId}",
|
|
1219
|
+
"action.approve": "Allow",
|
|
1220
|
+
"action.approveOnce": "Allow this version only",
|
|
1221
|
+
"action.approvePlugin": "Allow future versions of this plugin",
|
|
1222
|
+
"action.decline": "Decline",
|
|
1223
|
+
"action.run": "Run",
|
|
1224
|
+
"action.stop": "Stop",
|
|
1225
|
+
"action.remove": "Remove",
|
|
1226
|
+
"action.retry": "Retry",
|
|
1227
|
+
"action.rollback": "Roll back",
|
|
1228
|
+
"render.failedAbdicated": "Rendering failed in {slot}; the default UI was restored:",
|
|
1229
|
+
"render.failedHeld": "Rendering failed in {slot}:",
|
|
1230
|
+
"a11y.defining": "Defining the plugin",
|
|
1231
|
+
"a11y.failed": "Definition failed",
|
|
1232
|
+
"a11y.stopped": "Definition interrupted",
|
|
1233
|
+
"body.source": "Plugin source",
|
|
1234
|
+
"body.hostCode": "Host",
|
|
1235
|
+
"body.clientCode": "Client",
|
|
1236
|
+
"body.output": "Result",
|
|
1237
|
+
"body.copy": "Copy",
|
|
1238
|
+
"body.copied": "Copied"
|
|
1239
|
+
};
|
|
1240
|
+
//#endregion
|
|
1241
|
+
//#region lib/types/client/index.js
|
|
1242
|
+
/** Cordis dynamic-plugin cards, inventory panel, business-view host, and `@pluginId` source. */
|
|
1243
|
+
/** Required services for the two Tool cards, panel, Remote lifecycle, and Slash source. */
|
|
1244
|
+
const inject = [
|
|
1245
|
+
"slots",
|
|
1246
|
+
"locale",
|
|
1247
|
+
"inputTriggers",
|
|
1248
|
+
"remote",
|
|
1249
|
+
"remote.dynamicCordisRunner",
|
|
1250
|
+
"dynamicCordisRunner"
|
|
1251
|
+
];
|
|
1252
|
+
/** Mount every Cordis browser surface over the shared Host inventory. */
|
|
1253
|
+
function apply(ctx) {
|
|
1254
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
1255
|
+
zh,
|
|
1256
|
+
en
|
|
1257
|
+
}), "ui-cordis: dictionaries");
|
|
1258
|
+
const port = {
|
|
1259
|
+
stop: async (sessionId, pluginId) => {
|
|
1260
|
+
const answered = await ctx.remote.dynamicCordisRunner.stopFromPanel(sessionId, pluginId);
|
|
1261
|
+
if (!answered.ok) return {
|
|
1262
|
+
ok: false,
|
|
1263
|
+
message: `${answered.error.code}: ${answered.error.message}`
|
|
1264
|
+
};
|
|
1265
|
+
if (answered.value.ok || answered.value.reason === "not-running") return { ok: true };
|
|
1266
|
+
return {
|
|
1267
|
+
ok: false,
|
|
1268
|
+
message: answered.value.message
|
|
1269
|
+
};
|
|
1270
|
+
},
|
|
1271
|
+
remove: async (sessionId, pluginId) => {
|
|
1272
|
+
const answered = await ctx.remote.dynamicCordisRunner.undefineFromPanel(sessionId, pluginId);
|
|
1273
|
+
if (!answered.ok) return {
|
|
1274
|
+
ok: false,
|
|
1275
|
+
message: `${answered.error.code}: ${answered.error.message}`
|
|
1276
|
+
};
|
|
1277
|
+
return answered.value.ok ? { ok: true } : {
|
|
1278
|
+
ok: false,
|
|
1279
|
+
message: answered.value.message
|
|
1280
|
+
};
|
|
1281
|
+
},
|
|
1282
|
+
inventory: async () => {
|
|
1283
|
+
const answered = await ctx.remote.dynamicCordisRunner.inventory();
|
|
1284
|
+
if (!answered.ok) throw new Error(`${answered.error.code}: ${answered.error.message}`);
|
|
1285
|
+
return answered.value;
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
const inventory = createCordisInventory(port, (error) => {
|
|
1289
|
+
console.error("[ui-cordis] reading the Cordis inventory failed:", error);
|
|
1290
|
+
});
|
|
1291
|
+
const runner = ctx.dynamicCordisRunner;
|
|
1292
|
+
const loaded = {
|
|
1293
|
+
getSnapshot: () => runner.getSnapshot(),
|
|
1294
|
+
subscribe: (fn) => runner.subscribe(fn)
|
|
1295
|
+
};
|
|
1296
|
+
const runCards = new CordisRunCardRegistry();
|
|
1297
|
+
ctx.effect(() => inventory.subscribe(() => {
|
|
1298
|
+
const snapshot = inventory.getSnapshot();
|
|
1299
|
+
if (snapshot.read) runner.reconcileApprovals(snapshot.rows);
|
|
1300
|
+
}), "ui-cordis: reconcile pending approvals");
|
|
1301
|
+
ctx.remote.$on("cordis/dynamic-package", () => {
|
|
1302
|
+
inventory.refresh();
|
|
1303
|
+
});
|
|
1304
|
+
ctx.remote.$on("cordis/dynamic-retract", () => {
|
|
1305
|
+
inventory.refresh();
|
|
1306
|
+
});
|
|
1307
|
+
ctx.remote.$on("cordis/request-run", (request) => {
|
|
1308
|
+
if (!inventory.getSnapshot().rows.some((row) => row.pluginId === request.pluginId)) inventory.refresh();
|
|
1309
|
+
});
|
|
1310
|
+
ctx.remote.$on("cordis/request-run-resolved", () => {
|
|
1311
|
+
inventory.refresh();
|
|
1312
|
+
});
|
|
1313
|
+
ctx.on("connection/reset", () => {
|
|
1314
|
+
inventory.reset();
|
|
1315
|
+
inventory.refresh();
|
|
1316
|
+
});
|
|
1317
|
+
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
1318
|
+
name: "sidebar.footer.action",
|
|
1319
|
+
id: "cordis-panel",
|
|
1320
|
+
locale: NS,
|
|
1321
|
+
inject: () => ({
|
|
1322
|
+
hooks: {
|
|
1323
|
+
inventory,
|
|
1324
|
+
activeRuns: runner.activeRuns,
|
|
1325
|
+
runErrors: runner.lastRunError,
|
|
1326
|
+
loaded,
|
|
1327
|
+
renderFailures: runner.renderFailures
|
|
1328
|
+
},
|
|
1329
|
+
onApprove: (requestId, approveFutureVersions) => runner.approve(requestId, approveFutureVersions),
|
|
1330
|
+
onDecline: (requestId) => runner.decline(requestId),
|
|
1331
|
+
onRun: (request) => runner.startUserRun(request),
|
|
1332
|
+
onStop: async (sessionId, pluginId) => {
|
|
1333
|
+
const result = await port.stop(sessionId, pluginId);
|
|
1334
|
+
inventory.refresh();
|
|
1335
|
+
return result;
|
|
1336
|
+
},
|
|
1337
|
+
onRemove: async (sessionId, pluginId) => {
|
|
1338
|
+
const result = await port.remove(sessionId, pluginId);
|
|
1339
|
+
if (result.ok) inventory.retire(pluginId);
|
|
1340
|
+
inventory.refresh();
|
|
1341
|
+
return result;
|
|
1342
|
+
},
|
|
1343
|
+
onRefresh: () => {
|
|
1344
|
+
inventory.refresh();
|
|
1345
|
+
}
|
|
1346
|
+
})
|
|
1347
|
+
}, CordisPanel));
|
|
1348
|
+
const cardFace = () => ({ hooks: {
|
|
1349
|
+
inventory,
|
|
1350
|
+
loaded
|
|
1351
|
+
} });
|
|
1352
|
+
ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
|
|
1353
|
+
name: "tool.call.toolview",
|
|
1354
|
+
key: "cordis_define",
|
|
1355
|
+
locale: NS,
|
|
1356
|
+
inject: cardFace
|
|
1357
|
+
}, CordisDefineRow));
|
|
1358
|
+
ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
|
|
1359
|
+
name: "tool.call.toolview",
|
|
1360
|
+
key: "cordis_run",
|
|
1361
|
+
locale: NS,
|
|
1362
|
+
children: { "tool.view.cordis": {
|
|
1363
|
+
kind: "keyed",
|
|
1364
|
+
scope: "session"
|
|
1365
|
+
} },
|
|
1366
|
+
inject: (sessionId) => {
|
|
1367
|
+
const store = runCards.forSession(sessionId);
|
|
1368
|
+
return {
|
|
1369
|
+
hooks: {
|
|
1370
|
+
inventory,
|
|
1371
|
+
loaded,
|
|
1372
|
+
runCards: store,
|
|
1373
|
+
activeRuns: runner.activeRuns
|
|
1374
|
+
},
|
|
1375
|
+
onObserveRunCard: (pointer) => {
|
|
1376
|
+
store.observe(pointer);
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
}, CordisRunRow));
|
|
1381
|
+
ctx.slots.inject("tool.call.toolview", function* () {
|
|
1382
|
+
yield ctx.slots.register({
|
|
1383
|
+
name: "tool.call.toolview",
|
|
1384
|
+
key: "cordis_stop",
|
|
1385
|
+
locale: NS
|
|
1386
|
+
}, CordisActionRow);
|
|
1387
|
+
yield ctx.slots.register({
|
|
1388
|
+
name: "tool.call.toolview",
|
|
1389
|
+
key: "cordis_undefine",
|
|
1390
|
+
locale: NS
|
|
1391
|
+
}, CordisActionRow);
|
|
1392
|
+
});
|
|
1393
|
+
const rowsOf = (sessionId, query) => inventory.getSnapshot().rows.filter((row) => row.agentId === sessionId && String(row.pluginId).includes(query));
|
|
1394
|
+
const source = {
|
|
1395
|
+
trigger: "@",
|
|
1396
|
+
name: "cordis",
|
|
1397
|
+
order: 1,
|
|
1398
|
+
candidates(session, { query }) {
|
|
1399
|
+
const rows = rowsOf(session.sessionId, query);
|
|
1400
|
+
return Promise.resolve(rows.map((row) => {
|
|
1401
|
+
const packageId = row.nextPackageId ?? row.currentPackageId ?? row.packages.at(-1)?.packageId;
|
|
1402
|
+
const pkg = packageId === void 0 ? void 0 : row.packages.find((candidate) => candidate.packageId === packageId);
|
|
1403
|
+
return {
|
|
1404
|
+
name: String(row.pluginId),
|
|
1405
|
+
...pkg === void 0 ? {} : { description: pkg.purpose }
|
|
1406
|
+
};
|
|
1407
|
+
}));
|
|
1408
|
+
},
|
|
1409
|
+
warm() {
|
|
1410
|
+
inventory.refresh();
|
|
1411
|
+
},
|
|
1412
|
+
lexicon(session) {
|
|
1413
|
+
return rowsOf(session.sessionId, "").map((row) => String(row.pluginId));
|
|
1414
|
+
},
|
|
1415
|
+
subscribeLexicon(_session, listener) {
|
|
1416
|
+
return inventory.subscribe(listener);
|
|
1417
|
+
},
|
|
1418
|
+
onPick({ candidate }) {
|
|
1419
|
+
return { text: `@${candidate.name} ` };
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
const slash = ctx.get("inputTriggers");
|
|
1423
|
+
ctx.effect(() => slash.registerSource(source), "ui-cordis: @pluginId source");
|
|
1424
|
+
inventory.refresh();
|
|
1425
|
+
}
|
|
1426
|
+
//#endregion
|
|
1427
|
+
exports.apply = apply;
|
|
1428
|
+
exports.inject = inject;
|
|
1429
|
+
return module.exports;
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
//# sourceMappingURL=client.js.map
|