gemus-dsh-plugin 0.0.0-stage → 0.2.11

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 CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # Gemus — DeepSeek Harness desktop plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Connect the [Gemus](https://gemus.ai) design canvas from the official DeepSeek Harness app.
4
+ This bundle includes a Host connection owner and an in-app configuration page. It uses DSH's official MCP client; tools keep their `mcp__gemus__*` names.
5
+
6
+ ## Desktop setup (recommended)
7
+
8
+ Requires the official DSH Desktop **0.2.2-rc.1 or later** in the 0.2 line and a Gemus account and Key; generations spend Gemus credits.
9
+ [Download the official app](https://github.com/deepseek-ai/deepseek-harness/releases).
10
+ The app includes its runtime; no system Node.js, global CLI, or terminal is required.
11
+
12
+ 1. In DSH, open **Plugins → Add plugin** and enter `github:Gemus-AI/gemus-dsh-plugin`.
13
+ 2. Install and enable Gemus, then open its page in the installed plugins list.
14
+ 3. Choose **Domestic** (`gemus.cn`) or **International** (`gemus.ai`) in the plugin. Create a Key on that site, paste it into **Gemus Key**, and connect. Confirm the displayed actual site, account and personal space. An optional expected account ID is checked for equality; it never grants access.
15
+ 4. In a normal DSH chat, ask: “Use Gemus workflow_list to list workflows in my personal space. Do not create workflows or generate content.”
16
+
17
+ A successful check confirms identity and observed tool registration at the shown time, not continuous online status. A normal chat call verifies actual use. Connection checks spend no Gemus generation credits; DSH chat may consume model credits. Model credentials and working-directory selection belong to DSH and remain separate.
18
+
19
+ Version 0.2.5 verifies the destination and authenticated site/account before saving or mounting tools, including after reopening. New Keys use `mak_cn_…` or `mak_global_…`; strict legacy Keys belong only to International. The connection is saved by DSH's credentials service and restored only after successful identity verification. Failed checks preserve the credential for retry and do not mount tools. Older International servers are compatible only with strict legacy-global Keys; Domestic and tagged Keys require the new identity response. This local storage is not an encrypted keychain and does not protect secrets from other processes running as the same OS user.
20
+
21
+ ## Recovery and upgrade
22
+
23
+ Use **Check again** after a network failure or exhausted automatic retries. It rebuilds one official MCP instance and checks again. Use **Change Key** for the wrong account or a revoked Key. **Disconnect** clears this plugin's stored Key and prevents legacy environment fallback; it does not revoke a Gemus Key or alter other clients.
24
+
25
+ From 0.1.3, use the native Plugins page to uninstall and reinstall, then enter your Key again. Keep your models, chats, and other plugins. Unknown user YAML overrides are not automatically removed; a conflicting Gemus MCP row must be resolved through the host's existing management UI. No build scripts or allowBuilds grant are needed.
26
+
27
+ Windows and macOS require separate end-to-end verification. Version 0.2.11 declares DSH `>=0.2.2-rc.1 <0.3.0-0`; it was checked on 0.2.2-rc.1, 0.2.2-rc.5 and 0.2.3-alpha.2. DSH 0.2.1-rc.5 refuses it: update DSH, or install the last build for that host with `github:Gemus-AI/gemus-dsh-plugin#847e0b612437ae9a025781696b405ea831abc924` (0.2.10, no further fixes).
28
+
29
+ ## Advanced CLI setup
30
+
31
+ The existing published installer below is an International legacy path and has no installation identity preflight. Domestic users should use Desktop or the explicit manual environment below. It requires Node.js and a `dsh` command on PATH:
32
+
33
+ ```sh
34
+ npx -y @gemus/mcp-proxy@0.1.16 setup-dsh
35
+ ```
36
+
37
+ It configures the **web** CLI profile, not Desktop. Alternatively:
38
+
39
+ ```sh
40
+ dsh plugin --profile web add github:Gemus-AI/gemus-dsh-plugin
41
+ export GEMUS_KEY="mak_cn_…"
42
+ export GEMUS_URL="https://gemus.cn/api/mcp"
43
+ dsh --profile web
44
+ ```
45
+
46
+ For International use its own Key and `https://gemus.ai/api/mcp`. In PowerShell set both `$env:GEMUS_KEY = "mak_cn_…"` and `$env:GEMUS_URL = "https://gemus.cn/api/mcp"` before launching `dsh --profile web` in that same terminal. Child processes inherit the current shell environment. Updating the Windows user environment or a shell startup file requires a new terminal.
47
+
48
+ Legacy `GEMUS_KEY` / `GEMUS_URL` are read together only when no desktop credential record exists. `GEMUS_URL` is the full MCP URL; the default is `https://gemus.ai/api/mcp`. Supported destinations are official Gemus HTTPS port 443 `/api/mcp` endpoints and explicit localhost / 127.0.0.1 / [::1] development `/api/mcp` endpoints. Unknown hosts, other paths/official ports, URL credentials, query and fragment are rejected before sending a Key. Redirects are refused. Local development is global-only.
49
+
50
+ The next CLI source release adds installation preflight and optional `--expected-user <account ID>`. Its launched session carries a one-use setup intent and the verified account ID; the Host verifies again and updates the existing DSH credential through the connection owner. This makes an explicit setup replace a previously saved connection without changing ordinary environment precedence or the disconnect tombstone. Setup-intent fields are removed from the Host environment and are never persisted in shell profiles or user environment. It must be published from merged master and verified before updating live installer pins; this PR does not publish or point users to an unavailable package.
51
+
52
+ Use `dsh --profile web --dump-config` to inspect the Gemus layer. For reproducibility, pin `github:Gemus-AI/gemus-dsh-plugin#<published-sha>`.
53
+
54
+ ## What the agent gets
55
+
56
+ | Tool | Purpose |
57
+ | --- | --- |
58
+ | `edit` | Plan operations, multi-node graphs, focused edits and capability-backed imports |
59
+ | `read` | Canvas, node/model contract, assets, figures, history and PPT read targets |
60
+ | `execute` | Run one or several nodes, then deliver content, renew leases or report client failures |
61
+ | `view_image` | View produced images as pixels |
62
+ | `workflow_list`, `open_canvas` | Resolve and open an existing workflow |
63
+ | `search`, `fetch` | Discover and read community work |
64
+ | `ppt_edit`, `publish_workflow` | Deck authoring and confirmed publishing |
65
+
66
+ Writes require an explicit idempotencyKey. Use the same key only for an identical retry. Read item status and resource identities; execute.wait reports current progress. ask_user_question is available only in Bridge mode.
67
+
68
+ ## Known limits
69
+
70
+ - **`view_image` depends on your model route, not on dsh.** dsh admits MCP image blocks only after
71
+ the active model positively declares image input. The default route (`deepseek-official` /
72
+ `deepseek-v4-flash`) declares text only, so every image degrades to
73
+ `[image unavailable: …; model "…" does not declare image input; …]` — the model is told it cannot
74
+ see, rather than shown a blank. Route the agent to a model that declares image input and
75
+ `view_image` works as it does on any other host; the attachment store it needs is already mounted
76
+ in this profile.
77
+ - **Prefer letting the canvas do the looking.** Independent of the model route, `execute` an
78
+ `analyzer` node with the image wired to its `reference` port and read back the structured text
79
+ report. If that node's model already accepts images (Gemini, Claude, Kimi, GPT, Grok) it sees them
80
+ directly; otherwise the platform routes that run to its own vision provider. Either way the visual
81
+ judgement is made by a vision model on the canvas, not by the agent's model, and it costs no image
82
+ tokens in this session.
83
+ - **Audio and embedded resources are never visible.** dsh has no admission path for those blocks;
84
+ they are always replaced by a placeholder. Use `open_canvas` to hand the result to a browser.
85
+ - **Generations are billed and slow.** A call blocks until the job finishes. `toolCallTimeoutMs` is
86
+ raised to 600000 (10 min) by this bundle; the server-side ceiling is 45 min. If a call does time
87
+ out, the job usually still completes — re-read the canvas with `read` rather than
88
+ re-running, which would spend credits twice.
89
+ - **One key, one account.** All work runs as the owner of the `mak_` key.
90
+
91
+ ## Uninstall
92
+
93
+ In Desktop, first **Disconnect** on the Gemus plugin page to clear this plugin's stored Key, then use **Uninstall** in Plugins. This does not revoke the Key or change other clients.
94
+
95
+ For the CLI web profile only:
96
+
97
+ ```sh
98
+ dsh plugin --profile web remove gemus-dsh-plugin
99
+ ```
100
+
101
+ If you used the one-command installer, also drop the saved key: delete the
102
+ `# >>> gemus >>>` … `# <<< gemus <<<` block from your shell startup file (macOS / Linux), or clear
103
+ `GEMUS_KEY` from your Windows user environment.
104
+
105
+ ---
106
+
107
+ Generated from the Gemus monorepo (`.dsh-plugin/`, `scripts/pack-dsh-plugin.mjs`) — edit upstream,
108
+ not here. Third-party names are used for interoperability only.
109
+
110
+ Codex-generated images without a corresponding node remain on the local machine and do not land on the canvas.
111
+ New workflows use `workflow_create({workspaceTarget:"personal"|"active",name,idempotencyKey})`; retain the returned `workflowId`, then use `edit`.
@@ -0,0 +1,4 @@
1
+ # Keep the legacy row id; Host owns one official MCP child and Client owns configuration.
2
+ - insert:
3
+ - id: gemus
4
+ name: gemus-dsh-plugin
package/dist/client.js ADDED
@@ -0,0 +1,489 @@
1
+ window.__ModuleLoader__.load({ id: "gemus-dsh-plugin", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/client.tsx
22
+ var client_exports = {};
23
+ __export(client_exports, {
24
+ ConnectionPanel: () => ConnectionPanel,
25
+ apply: () => apply,
26
+ inject: () => inject
27
+ });
28
+ module.exports = __toCommonJS(client_exports);
29
+ var import_react = require("react");
30
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
31
+
32
+ // src/remote.ts
33
+ var import_zod = require("zod");
34
+
35
+ // ../../node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@_7zfn36al5jimdl7e74ixplvi5i/node_modules/@deepseek-ai/dsh-typert-protocol/lib/types/remote-info.js
36
+ function createTypertRemoteInfo(spec, zod) {
37
+ return new RemoteInfo(spec, zod);
38
+ }
39
+ var RemoteInfo = class {
40
+ spec;
41
+ zod;
42
+ index;
43
+ constructor(spec, zod) {
44
+ this.spec = spec;
45
+ this.zod = zod;
46
+ }
47
+ get package() {
48
+ return this.spec.package;
49
+ }
50
+ get descriptors() {
51
+ return this.resolve().descriptors;
52
+ }
53
+ get methods() {
54
+ return this.resolve().methods;
55
+ }
56
+ resolve() {
57
+ if (this.index !== void 0)
58
+ return this.index;
59
+ const zod = this.zod;
60
+ const descriptors = [];
61
+ const methods = /* @__PURE__ */ Object.create(null);
62
+ for (const [endpoint, definition] of Object.entries(this.spec.methods)) {
63
+ const separator = endpoint.indexOf("/");
64
+ const namespace = endpoint.slice(0, separator);
65
+ const method2 = endpoint.slice(separator + 1);
66
+ const parameters = definition.parameters.map((parameter) => ({ ...parameter, wire: parameter.wire ?? parameter.name }));
67
+ const descriptor = {
68
+ ...definition,
69
+ id: `${this.spec.package}#${endpoint}`,
70
+ namespace,
71
+ method: method2,
72
+ parameters,
73
+ result: definition.result.description === void 0 ? definition.result : new ResultValue(definition.result)
74
+ };
75
+ if (definition.invocation.kind === "direct") {
76
+ const inputs = [];
77
+ const direct = Object.assign(descriptor, {
78
+ input(options) {
79
+ const strict = options?.strict === true;
80
+ return inputs[strict ? 1 : 0] ??= new NamedInput(parameters, strict, zod);
81
+ },
82
+ invoke(remote, input, signal) {
83
+ const named = input;
84
+ const values = parameters.map((parameter) => named[parameter.wire]);
85
+ if (definition.cancellation !== void 0)
86
+ values.push(signal);
87
+ const receiver = Reflect.get(remote, namespace);
88
+ const call = Reflect.get(receiver, method2);
89
+ return call.apply(receiver, values);
90
+ }
91
+ });
92
+ methods[endpoint] = direct;
93
+ }
94
+ descriptors.push(descriptor);
95
+ }
96
+ return this.index = { descriptors, methods };
97
+ }
98
+ };
99
+ function optional(parameter) {
100
+ return parameter.source === "json" && parameter.acceptsUndefined === true;
101
+ }
102
+ var NamedInput = class {
103
+ parameters;
104
+ strict;
105
+ zod;
106
+ schema;
107
+ projection;
108
+ constructor(parameters, strict, zod) {
109
+ this.parameters = parameters;
110
+ this.strict = strict;
111
+ this.zod = zod;
112
+ }
113
+ codec(parameter) {
114
+ return this.strict ? parameter.strictCodec : parameter.codec;
115
+ }
116
+ create = () => this.schema ??= this.zod.strictObject(Object.fromEntries(this.parameters.map((parameter) => {
117
+ const value = this.codec(parameter).create();
118
+ return [parameter.wire, optional(parameter) ? value.optional() : value.nonoptional()];
119
+ })));
120
+ get jsonSchema() {
121
+ return this.project().jsonSchema;
122
+ }
123
+ get jsonSchemaError() {
124
+ return this.project().jsonSchemaError;
125
+ }
126
+ project() {
127
+ if (this.projection !== void 0)
128
+ return this.projection;
129
+ const unavailable = this.parameters.find((parameter) => this.codec(parameter).jsonSchema === void 0);
130
+ if (unavailable !== void 0) {
131
+ return this.projection = { jsonSchemaError: this.codec(unavailable).jsonSchemaError ?? `No JSON Schema for parameter ${unavailable.wire}` };
132
+ }
133
+ return this.projection = {
134
+ jsonSchema: {
135
+ type: "object",
136
+ properties: Object.fromEntries(this.parameters.map((parameter) => [parameter.wire, {
137
+ ...this.codec(parameter).jsonSchema,
138
+ ...parameter.description === void 0 ? {} : { description: parameter.description }
139
+ }])),
140
+ required: this.parameters.filter((parameter) => !optional(parameter)).map((parameter) => parameter.wire),
141
+ additionalProperties: false
142
+ }
143
+ };
144
+ }
145
+ };
146
+ var ResultValue = class {
147
+ spec;
148
+ projection;
149
+ constructor(spec) {
150
+ this.spec = spec;
151
+ }
152
+ get mode() {
153
+ return this.spec.mode;
154
+ }
155
+ get typeSymbol() {
156
+ return this.spec.typeSymbol;
157
+ }
158
+ get create() {
159
+ return this.spec.create;
160
+ }
161
+ get decode() {
162
+ return this.spec.decode;
163
+ }
164
+ get encode() {
165
+ return this.spec.encode;
166
+ }
167
+ get description() {
168
+ return this.spec.description;
169
+ }
170
+ get jsonSchemaError() {
171
+ return this.spec.jsonSchemaError;
172
+ }
173
+ get jsonSchema() {
174
+ if (this.projection === void 0) {
175
+ const schema = this.spec.jsonSchema;
176
+ this.projection = { value: schema === void 0 ? void 0 : { ...schema, description: this.spec.description } };
177
+ }
178
+ return this.projection.value;
179
+ }
180
+ };
181
+
182
+ // src/remote.ts
183
+ var identity = import_zod.z.object({ instance: import_zod.z.enum(["cn", "global"]), endpoint: import_zod.z.string(), user: import_zod.z.object({ id: import_zod.z.string(), username: import_zod.z.string().nullable(), displayName: import_zod.z.string() }), personalWorkspace: import_zod.z.object({ id: import_zod.z.string(), name: import_zod.z.string() }).nullable() });
184
+ var view = import_zod.z.object({
185
+ status: import_zod.z.enum(["disconnected", "checking", "verified", "needs-check", "auth-required", "network-error", "server-incompatible", "host-incompatible", "storage-error"]),
186
+ revision: import_zod.z.string(),
187
+ operationId: import_zod.z.number(),
188
+ endpoint: import_zod.z.string(),
189
+ source: import_zod.z.enum(["none", "saved", "environment"]),
190
+ saved: import_zod.z.boolean(),
191
+ identity: identity.nullable(),
192
+ toolCount: import_zod.z.number(),
193
+ checkedAt: import_zod.z.string().nullable(),
194
+ identityCheckedAt: import_zod.z.string().nullable(),
195
+ toolsCheckedAt: import_zod.z.string().nullable(),
196
+ error: import_zod.z.enum(["auth-required", "network-error", "server-incompatible", "storage-error", "conflict", "invalid-endpoint", "host-incompatible", "cancelled", "identity-mismatch"]).nullable()
197
+ });
198
+ function codec(schema, name) {
199
+ return { mode: "strict", typeSymbol: `gemus/${name}`, create: () => schema };
200
+ }
201
+ function method(name, schema) {
202
+ return {
203
+ service: "gemusConnection",
204
+ invocation: { kind: "direct" },
205
+ parameters: name && schema ? [{ name, source: "json", codec: codec(schema, name), strictCodec: codec(schema, name) }] : [],
206
+ result: codec(view, "ConnectionView")
207
+ };
208
+ }
209
+ var GEMUS_REMOTE = createTypertRemoteInfo({ package: "gemus-dsh-plugin", methods: {
210
+ "gemusConnection/getStatus": method(),
211
+ "gemusConnection/connect": method("input", import_zod.z.strictObject({ apiKey: import_zod.z.string().max(512), endpoint: import_zod.z.string().max(2048), expectedRevision: import_zod.z.string().max(128), expectedUserId: import_zod.z.string().max(128).optional() })),
212
+ "gemusConnection/recheck": method("expectedRevision", import_zod.z.string().max(128)),
213
+ "gemusConnection/disconnect": method("expectedRevision", import_zod.z.string().max(128))
214
+ } }, import_zod.z);
215
+
216
+ // src/contracts.ts
217
+ var DEFAULT_ENDPOINT = "https://gemus.ai/api/mcp";
218
+
219
+ // src/locales/en.ts
220
+ var en = {
221
+ title: "Connect Gemus",
222
+ site: "Gemus site",
223
+ "site.cn": "Domestic",
224
+ "site.global": "International",
225
+ "site.local": "Local development",
226
+ connectedSite: "Connected site",
227
+ expectedUser: "Expected account ID (optional)",
228
+ key: "Gemus Key",
229
+ keyHint: "Create a Gemus Key on the Connect page, then paste it here. It is saved by this DSH installation; your model key is separate.",
230
+ connect: "Connect Gemus",
231
+ replace: "Change Key",
232
+ recheck: "Check again",
233
+ disconnect: "Disconnect",
234
+ advanced: "Advanced: local development endpoint",
235
+ endpoint: "MCP endpoint",
236
+ account: "Gemus account",
237
+ space: "Personal space",
238
+ noSpace: "No personal space yet",
239
+ saved: "Saved in DSH",
240
+ environment: "Using GEMUS_KEY / GEMUS_URL from the environment. Connect to save a desktop credential.",
241
+ tools: "Registered tools",
242
+ lastCheck: "Last check",
243
+ snapshot: "This is a check result, not a live online indicator. Confirm actual use in a DSH chat.",
244
+ prompt: "Use Gemus workflow_list to list workflows in my personal space. Do not create workflows or generate content.",
245
+ copy: "Copy first task",
246
+ copied: "Copied",
247
+ model: "If chat reports no model, sign in or configure a model in DSH. Gemus Key does not configure the model. Normal chat may use model credits.",
248
+ "status.disconnected": "Not connected",
249
+ "status.checking": "Checking\u2026",
250
+ "status.verified": "Account verified and tools registered",
251
+ "status.needs-check": "Not verified. Check again before using Gemus tools.",
252
+ "status.auth-required": "Key is invalid or revoked. Enter a new Gemus Key.",
253
+ "status.network-error": "Cannot reach Gemus. Check your network and try again.",
254
+ "status.host-incompatible": "Plugin could not activate. Check your DSH version or conflicting Gemus plugins.",
255
+ "status.storage-error": "Could not save the connection. Your previous credential is unchanged.",
256
+ "error.identity-mismatch": "The Key, site, endpoint or expected account does not match. Check your site selection and account ID.",
257
+ "error.auth-required": "This Key was not accepted. The previous connection has not been replaced.",
258
+ "error.network-error": "Gemus could not be verified. Check your network and endpoint.",
259
+ "error.storage-error": "Saving failed. The connection has not been saved.",
260
+ "error.conflict": "The connection changed elsewhere. Check again to load the current connection.",
261
+ "status.server-incompatible": "This Gemus service does not support account verification yet.",
262
+ "error.server-incompatible": "Ask the Gemus service administrator to update the service, then check again. Tools remain disconnected until account verification succeeds.",
263
+ "error.invalid-endpoint": "Use the official Gemus HTTPS /api/mcp endpoint, or an explicit localhost development endpoint.",
264
+ "error.host-incompatible": "Check the DSH version and whether another Gemus plugin owns the tools.",
265
+ "error.cancelled": "The operation was superseded. Check again.",
266
+ loading: "Loading Gemus connection\u2026",
267
+ unavailable: "Cannot read the plugin connection. Reopen this page or check the DSH connection.",
268
+ retry: "Retry"
269
+ };
270
+
271
+ // src/locales/zh.ts
272
+ var zh = {
273
+ title: "\u8FDE\u63A5 Gemus",
274
+ site: "Gemus \u7AD9\u70B9",
275
+ "site.cn": "\u56FD\u5185\u7AD9",
276
+ "site.global": "\u56FD\u9645\u7AD9",
277
+ "site.local": "\u672C\u673A\u5F00\u53D1",
278
+ connectedSite: "\u5B9E\u9645\u8FDE\u63A5\u7AD9\u70B9",
279
+ expectedUser: "\u9884\u671F\u8D26\u6237 ID\uFF08\u53EF\u9009\uFF09",
280
+ key: "Gemus Key",
281
+ keyHint: "\u5728 Gemus \u63A5\u5165\u9875\u521B\u5EFA Key\uFF0C\u518D\u7C98\u8D34\u5230\u8FD9\u91CC\u3002\u7531\u5F53\u524D DSH \u4FDD\u5B58\uFF1B\u6A21\u578B\u51ED\u636E\u9700\u53E6\u884C\u914D\u7F6E\u3002",
282
+ connect: "\u8FDE\u63A5 Gemus",
283
+ replace: "\u66F4\u6362 Key",
284
+ recheck: "\u91CD\u65B0\u68C0\u6D4B",
285
+ disconnect: "\u65AD\u5F00\u8FDE\u63A5",
286
+ advanced: "\u9AD8\u7EA7\uFF1A\u672C\u673A\u5F00\u53D1\u5730\u5740",
287
+ endpoint: "MCP \u670D\u52A1\u5730\u5740",
288
+ account: "Gemus \u8D26\u6237",
289
+ space: "\u4E2A\u4EBA\u7A7A\u95F4",
290
+ noSpace: "\u5C1A\u65E0\u4E2A\u4EBA\u7A7A\u95F4",
291
+ saved: "\u5DF2\u4FDD\u5B58\u5230 DSH",
292
+ environment: "\u5F53\u524D\u4F7F\u7528\u73AF\u5883\u53D8\u91CF GEMUS_KEY / GEMUS_URL\u3002\u8FDE\u63A5\u540E\u4FDD\u5B58\u4E3A\u684C\u9762\u51ED\u636E\u3002",
293
+ tools: "\u5DF2\u6CE8\u518C\u5DE5\u5177",
294
+ lastCheck: "\u4E0A\u6B21\u68C0\u6D4B",
295
+ snapshot: "\u6B64\u7ED3\u679C\u662F\u68C0\u6D4B\u5FEB\u7167\uFF0C\u4E0D\u4EE3\u8868\u5B9E\u65F6\u5728\u7EBF\u3002\u8BF7\u5728\u6B63\u5E38 DSH \u4F1A\u8BDD\u4E2D\u786E\u8BA4\u5B9E\u9645\u8C03\u7528\u3002",
296
+ prompt: "\u8BF7\u8C03\u7528 Gemus \u7684 workflow_list\uFF0C\u5217\u51FA\u6211\u7684\u4E2A\u4EBA\u7A7A\u95F4\u5DE5\u4F5C\u6D41\u3002\u4E0D\u8981\u521B\u5EFA\u5DE5\u4F5C\u6D41\u6216\u751F\u6210\u5185\u5BB9\u3002",
297
+ copy: "\u590D\u5236\u9996\u6B21\u4EFB\u52A1",
298
+ copied: "\u5DF2\u590D\u5236",
299
+ model: "\u82E5\u4F1A\u8BDD\u63D0\u793A\u5C1A\u65E0\u6A21\u578B\uFF0C\u8BF7\u5728 DSH \u767B\u5F55\u6216\u914D\u7F6E\u6A21\u578B\u3002Gemus Key \u4E0D\u8D1F\u8D23\u914D\u7F6E\u6A21\u578B\uFF1B\u6B63\u5E38\u804A\u5929\u53EF\u80FD\u6D88\u8017\u6A21\u578B\u989D\u5EA6\u3002",
300
+ "status.disconnected": "\u672A\u8FDE\u63A5",
301
+ "status.checking": "\u68C0\u6D4B\u4E2D\u2026",
302
+ "status.verified": "\u8D26\u6237\u9A8C\u8BC1\u901A\u8FC7\uFF0C\u5DE5\u5177\u5DF2\u6CE8\u518C",
303
+ "status.needs-check": "\u5C1A\u672A\u9A8C\u8BC1\uFF0C\u8BF7\u91CD\u65B0\u68C0\u6D4B\u540E\u518D\u4F7F\u7528 Gemus \u5DE5\u5177\u3002",
304
+ "status.auth-required": "Key \u65E0\u6548\u6216\u5DF2\u64A4\u9500\uFF0C\u8BF7\u8F93\u5165\u65B0\u7684 Gemus Key\u3002",
305
+ "status.network-error": "\u65E0\u6CD5\u8FDE\u63A5 Gemus\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u65B0\u68C0\u6D4B\u3002",
306
+ "status.host-incompatible": "\u63D2\u4EF6\u672A\u80FD\u6FC0\u6D3B\uFF0C\u8BF7\u68C0\u67E5 DSH \u7248\u672C\u6216\u5176\u4ED6 Gemus \u63D2\u4EF6\u51B2\u7A81\u3002",
307
+ "status.storage-error": "\u65E0\u6CD5\u4FDD\u5B58\u8FDE\u63A5\uFF0C\u539F\u51ED\u636E\u4FDD\u6301\u4E0D\u53D8\u3002",
308
+ "error.identity-mismatch": "Key\u3001\u7AD9\u70B9\u3001\u670D\u52A1\u5730\u5740\u6216\u9884\u671F\u8D26\u6237\u4E0D\u5339\u914D\uFF0C\u8BF7\u68C0\u67E5\u6240\u9009\u7AD9\u70B9\u548C\u8D26\u6237 ID\u3002",
309
+ "error.auth-required": "\u672A\u63A5\u53D7\u8FD9\u4E2A Key\uFF0C\u539F\u8FDE\u63A5\u5C1A\u672A\u88AB\u66FF\u6362\u3002",
310
+ "error.network-error": "\u65E0\u6CD5\u9A8C\u8BC1 Gemus\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C\u670D\u52A1\u5730\u5740\u3002",
311
+ "error.storage-error": "\u4FDD\u5B58\u5931\u8D25\uFF0C\u8FDE\u63A5\u5C1A\u672A\u4FDD\u5B58\u3002",
312
+ "error.conflict": "\u8FDE\u63A5\u5DF2\u5728\u5176\u4ED6\u4F4D\u7F6E\u66F4\u6539\uFF0C\u8BF7\u91CD\u65B0\u68C0\u6D4B\u4EE5\u52A0\u8F7D\u5F53\u524D\u8FDE\u63A5\u3002",
313
+ "status.server-incompatible": "\u5F53\u524D Gemus \u670D\u52A1\u6682\u4E0D\u652F\u6301\u8D26\u6237\u9A8C\u8BC1\u3002",
314
+ "error.server-incompatible": "\u8BF7\u8054\u7CFB Gemus \u670D\u52A1\u7BA1\u7406\u5458\u66F4\u65B0\u670D\u52A1\u540E\u91CD\u65B0\u68C0\u6D4B\u3002\u8D26\u6237\u9A8C\u8BC1\u6210\u529F\u524D\u4E0D\u4F1A\u6302\u8F7D\u5DE5\u5177\u3002",
315
+ "error.invalid-endpoint": "\u8BF7\u4F7F\u7528 Gemus \u5B98\u65B9 HTTPS /api/mcp \u5730\u5740\uFF0C\u6216\u660E\u786E\u7684\u672C\u673A\u5F00\u53D1\u5730\u5740\u3002",
316
+ "error.host-incompatible": "\u8BF7\u68C0\u67E5 DSH \u7248\u672C\uFF0C\u4EE5\u53CA\u662F\u5426\u6709\u5176\u4ED6 Gemus \u63D2\u4EF6\u5360\u7528\u4E86\u5DE5\u5177\u3002",
317
+ "error.cancelled": "\u64CD\u4F5C\u5DF2\u88AB\u66F4\u65B0\u7684\u8BF7\u6C42\u53D6\u4EE3\uFF0C\u8BF7\u91CD\u65B0\u68C0\u6D4B\u3002",
318
+ loading: "\u6B63\u5728\u8BFB\u53D6 Gemus \u8FDE\u63A5\u2026",
319
+ unavailable: "\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6\u8FDE\u63A5\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u6B64\u9875\u6216\u68C0\u67E5 DSH \u8FDE\u63A5\u3002",
320
+ retry: "\u91CD\u8BD5"
321
+ };
322
+
323
+ // src/client.tsx
324
+ var import_jsx_runtime = require("react/jsx-runtime");
325
+ var NS = "gemusConnection";
326
+ var stack = { display: "flex", flexDirection: "column", gap: 12, color: "var(--dsw-alias-text-primary)" };
327
+ var hint = { color: "var(--dsw-alias-text-secondary)", fontSize: 13, margin: 0 };
328
+ function connectPageUrl(endpoint) {
329
+ try {
330
+ const url = new URL(endpoint);
331
+ if (url.protocol === "https:" || url.protocol === "http:") return new URL("/connect", url).href;
332
+ } catch {
333
+ }
334
+ return "https://gemus.ai/connect";
335
+ }
336
+ function ConnectionPanel({ api, t }) {
337
+ const [view2, setView] = (0, import_react.useState)(null);
338
+ const [key, setKey] = (0, import_react.useState)("");
339
+ const [endpoint, setEndpoint] = (0, import_react.useState)(DEFAULT_ENDPOINT);
340
+ const [expectedUserId, setExpectedUserId] = (0, import_react.useState)("");
341
+ const [busy, setBusy] = (0, import_react.useState)(false);
342
+ const [failed, setFailed] = (0, import_react.useState)(false);
343
+ const [copied, setCopied] = (0, import_react.useState)(false);
344
+ const sequence = (0, import_react.useRef)(0);
345
+ const connectPage = connectPageUrl(endpoint);
346
+ const site = endpoint === "https://gemus.cn/api/mcp" ? "cn" : endpoint === DEFAULT_ENDPOINT ? "global" : "local";
347
+ const perform = async (operation) => {
348
+ const id = ++sequence.current;
349
+ setBusy(true);
350
+ setFailed(false);
351
+ try {
352
+ const next = await operation();
353
+ if (sequence.current === id) {
354
+ setView(next);
355
+ setEndpoint(next.endpoint);
356
+ setExpectedUserId(next.identity?.user.id ?? "");
357
+ }
358
+ } catch {
359
+ if (sequence.current === id) setFailed(true);
360
+ } finally {
361
+ if (sequence.current === id) setBusy(false);
362
+ }
363
+ };
364
+ (0, import_react.useEffect)(() => {
365
+ void perform(() => api.getStatus());
366
+ return () => {
367
+ sequence.current++;
368
+ };
369
+ }, [api]);
370
+ const submit = (event) => {
371
+ event.preventDefault();
372
+ if (!view2 || busy) return;
373
+ const input = { apiKey: key, endpoint, expectedRevision: view2.revision, ...expectedUserId.trim() ? { expectedUserId: expectedUserId.trim() } : {} };
374
+ setKey("");
375
+ void perform(() => api.connect(input));
376
+ };
377
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { style: stack, "aria-label": t("title"), children: [
378
+ !view2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: t(failed ? "unavailable" : "loading") }),
379
+ failed && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
380
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", children: t("unavailable") }),
381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: busy, onClick: () => void perform(() => api.getStatus()), children: t("retry") })
382
+ ] }),
383
+ view2 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
384
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: t(busy ? "status.checking" : `status.${view2.status}`) }),
385
+ view2.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", children: t(`error.${view2.error}`) }),
386
+ view2.identity && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: stack, children: [
387
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
388
+ t("connectedSite"),
389
+ ": ",
390
+ t(`site.${view2.identity.instance}`),
391
+ " \xB7 ",
392
+ view2.identity.endpoint
393
+ ] }),
394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
395
+ t("account"),
396
+ ": ",
397
+ view2.identity.user.displayName,
398
+ " ",
399
+ view2.identity.user.username && `(@${view2.identity.user.username})`
400
+ ] }),
401
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
402
+ t("space"),
403
+ ": ",
404
+ view2.identity.personalWorkspace?.name ?? t("noSpace")
405
+ ] })
406
+ ] }),
407
+ view2.saved && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: hint, children: t("saved") }),
408
+ view2.source === "environment" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: hint, children: t("environment") }),
409
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: submit, style: stack, autoComplete: "off", children: [
410
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "gemus-site", children: t("site") }),
411
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { id: "gemus-site", value: site, disabled: busy, onChange: (event) => {
412
+ setEndpoint(event.target.value === "cn" ? "https://gemus.cn/api/mcp" : event.target.value === "global" ? DEFAULT_ENDPOINT : "http://localhost:3000/api/mcp");
413
+ setKey("");
414
+ setExpectedUserId("");
415
+ }, style: { color: "var(--dsw-alias-text-primary)", background: "var(--dsw-alias-background-primary)" }, children: [
416
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "cn", children: t("site.cn") }),
417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "global", children: t("site.global") }),
418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "local", children: t("site.local") })
419
+ ] }),
420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "gemus-key", children: t("key") }),
421
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { id: "gemus-key", type: "password", value: key, autoComplete: "off", spellCheck: false, disabled: busy, onChange: (event) => setKey(event.target.value), "aria-describedby": "gemus-key-hint" }),
422
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { id: "gemus-key-hint", style: hint, children: [
423
+ t("keyHint"),
424
+ " ",
425
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: connectPage, target: "_blank", rel: "noreferrer", children: connectPage.replace(/^https?:\/\//, "") })
426
+ ] }),
427
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "gemus-expected-user", children: t("expectedUser") }),
428
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { id: "gemus-expected-user", value: expectedUserId, disabled: busy, autoComplete: "off", onChange: (event) => setExpectedUserId(event.target.value) }),
429
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { children: [
430
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: t("advanced") }),
431
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: stack, children: [
432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "gemus-endpoint", children: t("endpoint") }),
433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { id: "gemus-endpoint", type: "url", value: endpoint, disabled: busy, onChange: (event) => {
434
+ setEndpoint(event.target.value);
435
+ setKey("");
436
+ setExpectedUserId("");
437
+ } })
438
+ ] })
439
+ ] }),
440
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexWrap: "wrap", gap: 8 }, children: [
441
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { variant: "primary", type: "submit", disabled: busy || !key.trim(), children: t(view2.identity ? "replace" : "connect") }),
442
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", disabled: busy, onClick: () => void perform(() => api.recheck(view2.revision)), children: t("recheck") }),
443
+ view2.source !== "none" && view2.status !== "disconnected" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", disabled: busy, onClick: () => void perform(() => api.disconnect(view2.revision)), children: t("disconnect") })
444
+ ] })
445
+ ] }),
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: hint, children: [
447
+ t("tools"),
448
+ ": ",
449
+ view2.toolCount
450
+ ] }),
451
+ view2.checkedAt && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: hint, children: [
452
+ t("lastCheck"),
453
+ ": ",
454
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", { dateTime: view2.checkedAt, children: new Date(view2.checkedAt).toLocaleString() })
455
+ ] }),
456
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: hint, children: t("snapshot") }),
457
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: !view2.identity || busy, onClick: async () => {
458
+ if (await (0, import_dsh_client_ui_primitives.writeClipboard)(t("prompt"))) setCopied(true);
459
+ }, children: t(copied ? "copied" : "copy") }),
460
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: hint, children: t("model") })
461
+ ] })
462
+ ] });
463
+ }
464
+ var inject = ["slots", "locale", "remote"];
465
+ async function apply(ctx) {
466
+ ctx.effect(() => ctx.locale.register(NS, { en, zh }));
467
+ const unmount = await ctx.remote.$mount(GEMUS_REMOTE);
468
+ ctx.effect(() => unmount);
469
+ const call = async (operation) => {
470
+ const result = await operation;
471
+ if (!result.ok) throw new Error("Gemus configuration unavailable");
472
+ return result.value;
473
+ };
474
+ ctx.inject(["remote.gemusConnection"], (scope) => {
475
+ const api = {
476
+ getStatus: () => call(scope.remote.gemusConnection.getStatus()),
477
+ connect: (input) => call(scope.remote.gemusConnection.connect(input)),
478
+ recheck: (revision) => call(scope.remote.gemusConnection.recheck(revision)),
479
+ disconnect: (revision) => call(scope.remote.gemusConnection.disconnect(revision))
480
+ };
481
+ scope.effect(() => scope.slots.inject("plugins.bundle.config", () => scope.slots.register({
482
+ name: "plugins.bundle.config",
483
+ key: "gemus-dsh-plugin",
484
+ locale: NS,
485
+ inject: () => ({ api })
486
+ }, ConnectionPanel)));
487
+ });
488
+ }
489
+ return module.exports; } });