comfyui-mcp 0.30.0 → 0.31.0

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.
Files changed (111) hide show
  1. package/README.md +17 -1
  2. package/dist/config.js +27 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/orchestrator/agent-backend.js +42 -0
  5. package/dist/orchestrator/agent-backend.js.map +1 -1
  6. package/dist/orchestrator/ai-proposer.js +106 -0
  7. package/dist/orchestrator/ai-proposer.js.map +1 -0
  8. package/dist/orchestrator/backend-readiness.js +78 -1
  9. package/dist/orchestrator/backend-readiness.js.map +1 -1
  10. package/dist/orchestrator/chatgpt-oauth-backend.js +349 -0
  11. package/dist/orchestrator/chatgpt-oauth-backend.js.map +1 -0
  12. package/dist/orchestrator/claude-backend.js +8 -0
  13. package/dist/orchestrator/claude-backend.js.map +1 -1
  14. package/dist/orchestrator/copilot-backend.js +265 -0
  15. package/dist/orchestrator/copilot-backend.js.map +1 -0
  16. package/dist/orchestrator/glm-backend.js +20 -0
  17. package/dist/orchestrator/glm-backend.js.map +1 -0
  18. package/dist/orchestrator/grok-backend.js +1470 -0
  19. package/dist/orchestrator/grok-backend.js.map +1 -0
  20. package/dist/orchestrator/history.js +181 -0
  21. package/dist/orchestrator/history.js.map +1 -0
  22. package/dist/orchestrator/index.js +620 -138
  23. package/dist/orchestrator/index.js.map +1 -1
  24. package/dist/orchestrator/kimi-backend.js +26 -0
  25. package/dist/orchestrator/kimi-backend.js.map +1 -0
  26. package/dist/orchestrator/oauth-bridge.js +92 -0
  27. package/dist/orchestrator/oauth-bridge.js.map +1 -0
  28. package/dist/orchestrator/oauth-bridge.test.js +129 -0
  29. package/dist/orchestrator/oauth-bridge.test.js.map +1 -0
  30. package/dist/orchestrator/ollama-backend.js +71 -8
  31. package/dist/orchestrator/ollama-backend.js.map +1 -1
  32. package/dist/orchestrator/panel-agent.js +25 -0
  33. package/dist/orchestrator/panel-agent.js.map +1 -1
  34. package/dist/orchestrator/panel-console-http.js +470 -0
  35. package/dist/orchestrator/panel-console-http.js.map +1 -0
  36. package/dist/orchestrator/panel-mcp-http.js +2 -2
  37. package/dist/orchestrator/panel-mcp-http.js.map +1 -1
  38. package/dist/orchestrator/panel-tools.js +71 -7
  39. package/dist/orchestrator/panel-tools.js.map +1 -1
  40. package/dist/services/a2ui-spec.js +207 -0
  41. package/dist/services/a2ui-spec.js.map +1 -0
  42. package/dist/services/a2ui-spec.test.js +174 -0
  43. package/dist/services/a2ui-spec.test.js.map +1 -0
  44. package/dist/services/civitai-lookup.js +5 -0
  45. package/dist/services/civitai-lookup.js.map +1 -1
  46. package/dist/services/civitai-resolver.js +160 -3
  47. package/dist/services/civitai-resolver.js.map +1 -1
  48. package/dist/services/code-provider-auth-redact.test.js +83 -0
  49. package/dist/services/code-provider-auth-redact.test.js.map +1 -0
  50. package/dist/services/code-provider-auth.js +561 -0
  51. package/dist/services/code-provider-auth.js.map +1 -0
  52. package/dist/services/comfy-cli.js +276 -0
  53. package/dist/services/comfy-cli.js.map +1 -0
  54. package/dist/services/download-cache.js +7 -1
  55. package/dist/services/download-cache.js.map +1 -1
  56. package/dist/services/lora-catalog.js +329 -0
  57. package/dist/services/lora-catalog.js.map +1 -0
  58. package/dist/services/model-resolver.js +65 -4
  59. package/dist/services/model-resolver.js.map +1 -1
  60. package/dist/services/node-management.js +36 -53
  61. package/dist/services/node-management.js.map +1 -1
  62. package/dist/services/oauth-flow.js +314 -0
  63. package/dist/services/oauth-flow.js.map +1 -0
  64. package/dist/services/oauth-flow.test.js +179 -0
  65. package/dist/services/oauth-flow.test.js.map +1 -0
  66. package/dist/services/oauth-landing.test.js +45 -0
  67. package/dist/services/oauth-landing.test.js.map +1 -0
  68. package/dist/services/panel-secrets.js +132 -1
  69. package/dist/services/panel-secrets.js.map +1 -1
  70. package/dist/services/prompt-overrides.js +103 -0
  71. package/dist/services/prompt-overrides.js.map +1 -0
  72. package/dist/services/ui-bridge.js +52 -2
  73. package/dist/services/ui-bridge.js.map +1 -1
  74. package/dist/services/workflow-health.js +13 -0
  75. package/dist/services/workflow-health.js.map +1 -1
  76. package/dist/services/workflow-target-store.js +64 -0
  77. package/dist/services/workflow-target-store.js.map +1 -0
  78. package/dist/tools/comfy-cli.js +257 -0
  79. package/dist/tools/comfy-cli.js.map +1 -0
  80. package/dist/tools/index.js +6 -0
  81. package/dist/tools/index.js.map +1 -1
  82. package/dist/tools/model-explorer.js +114 -0
  83. package/dist/tools/model-explorer.js.map +1 -0
  84. package/dist/tools/model-extras.js +146 -3
  85. package/dist/tools/model-extras.js.map +1 -1
  86. package/dist/tools/model-management.js +11 -2
  87. package/dist/tools/model-management.js.map +1 -1
  88. package/dist/tools/node-management.js +21 -10
  89. package/dist/tools/node-management.js.map +1 -1
  90. package/dist/tools/prompt-director.js +32 -0
  91. package/dist/tools/prompt-director.js.map +1 -0
  92. package/dist/tools/workflow-compose.js +67 -5
  93. package/dist/tools/workflow-compose.js.map +1 -1
  94. package/dist/utils/html-to-markdown.js +86 -0
  95. package/dist/utils/html-to-markdown.js.map +1 -0
  96. package/package.json +1 -1
  97. package/packs/ltx23-distill-3stage/install-runpod.sh +58 -0
  98. package/packs/ltx23-distill-3stage/install-windows.bat +63 -0
  99. package/packs/ltx23-distill-3stage/manifest.yaml +63 -0
  100. package/packs/ltx23-distill-3stage/pack.yaml +37 -0
  101. package/packs/ltx23-distill-3stage/workflow.json +906 -0
  102. package/plugin/.mcp.json +4 -8
  103. package/plugin/hooks/vram-check.mjs +52 -9
  104. package/plugin/skills/civitai/SKILL.md +52 -78
  105. package/plugin/skills/comfyui-core/SKILL.md +2 -2
  106. package/plugin/skills/local-llm-free/SKILL.md +2 -2
  107. package/scripts/check-pack-models.mjs +11 -1
  108. package/scripts/gen-tool-docs.ts +2 -0
  109. package/scripts/mock-panel.mjs +92 -52
  110. package/scripts/runpod-release.mjs +18 -2
  111. package/scripts/test-generate.mjs +61 -0
@@ -0,0 +1,265 @@
1
+ // GitHub Copilot chat backend — Task 5b of the in-panel OAuth plan.
2
+ // EXPERIMENTAL, ISOLATED, ToS-risk (the user explicitly accepted this when
3
+ // asking for it): a failure anywhere in this module must surface only as a
4
+ // normal turn/prepare error on THIS backend — it can never affect
5
+ // Grok/Codex/Claude/other backends. See OAUTH_PROVIDERS.copilot
6
+ // (experimental: true, in oauth-flow.ts) and oauth-bridge.ts's
7
+ // allow_experimental gate, which is what makes a `~/.comfyui-mcp/copilot-
8
+ // auth.json` ghu_ token exist in the first place.
9
+ //
10
+ // REUSE vs COPILOT-SPECIFIC:
11
+ // Copilot's chat endpoint is OpenAI chat-completions compatible, so this
12
+ // backend is a THIN subclass of OllamaBackend's "openai" dialect — exactly the
13
+ // GlmBackend/KimiBackend pattern (glm-backend.ts / kimi-backend.ts), NOT the
14
+ // Grok/Codex Responses-API adapter (grok-backend.ts's GrokDirectBackend),
15
+ // because Copilot is a real /chat/completions endpoint, not /responses. The
16
+ // inherited chatStream/readOpenAiSse/run/runTurn/dispatch/buildModelTools all
17
+ // apply unchanged. The ONLY Copilot-specific parts, all isolated to this file:
18
+ // 1. the ghu_ → short-lived Copilot bearer exchange
19
+ // (GET https://api.github.com/copilot_internal/v2/token)
20
+ // 2. the "editor identity" headers GitHub requires on BOTH the exchange and
21
+ // every chat/completions call (Editor-Version / Editor-Plugin-Version /
22
+ // User-Agent / Copilot-Integration-Id) — GitHub 403s the exchange
23
+ // WITHOUT them even on a fully licensed Copilot account (this is the
24
+ // documented `github-copilot-token-exchange-needs-editor-headers` gotcha)
25
+ // 3. the token source: ~/.comfyui-mcp/copilot-auth.json via
26
+ // `resolveCopilotOAuth` (code-provider-auth.ts), mirroring
27
+ // `resolveGrokOAuth` but WITHOUT refresh — ghu_ has no refresh_token; a
28
+ // dead/revoked one can only be fixed by re-running Copilot sign-in.
29
+ //
30
+ // UNVERIFIED AGAINST THE LIVE api.githubcopilot.com CONTRACT (flagged per the
31
+ // task brief — Task 8 validates live with a real, licensed account):
32
+ // - the exact exchange response shape ({token, expires_at, endpoints:{api}})
33
+ // - the chat/completions and /models paths and their exact request/response
34
+ // shapes
35
+ // - whether the signed-in account is Copilot-licensed at all (a 403 from the
36
+ // exchange is ambiguous between "no license" and "bad/stale editor
37
+ // headers" — see the skill note above)
38
+ // - the default model slug (Copilot's catalog changes over time; utility
39
+ // models share a rate-limit bucket per the `copilot-utility-models-
40
+ // shared-rate-limit` gotcha, so a busy account may 429 even with a
41
+ // correct slug — this backend does not special-case that; it surfaces the
42
+ // 429 like any other HTTP error)
43
+ // Both base URLs AND the default model are overridable via env so a live
44
+ // mismatch is a config flip, not a code change.
45
+ import { ValidationError } from "../utils/errors.js";
46
+ import { logger } from "../utils/logger.js";
47
+ import { COPILOT_CAPABILITIES } from "./agent-backend.js";
48
+ import { OllamaBackend } from "./ollama-backend.js";
49
+ import { resolveCopilotOAuth, } from "../services/code-provider-auth.js";
50
+ import { assertAllowedTokenHost, OAUTH_PROVIDERS, redactTokens } from "../services/oauth-flow.js";
51
+ function msgOf(err) {
52
+ return err instanceof Error ? err.message : String(err);
53
+ }
54
+ /** GET endpoint that exchanges the long-lived `ghu_` token for a short-lived
55
+ * Copilot API bearer. Overridable — the exact host/path is UNVERIFIED
56
+ * offline (see the module doc above). */
57
+ export const COPILOT_TOKEN_EXCHANGE_URL = process.env.COMFYUI_MCP_COPILOT_TOKEN_URL?.trim() ||
58
+ "https://api.github.com/copilot_internal/v2/token";
59
+ /** Base URL for Copilot's OpenAI-compatible chat/completions + /models.
60
+ * Overridable — a live exchange response's `endpoints.api` (when present)
61
+ * wins over this default for the REST of that token's lifetime (individual
62
+ * vs. business accounts may route to different hosts per the exchange
63
+ * response, per research). */
64
+ export const COPILOT_API_BASE = process.env.COMFYUI_MCP_COPILOT_API_BASE?.trim().replace(/\/+$/, "") ||
65
+ "https://api.githubcopilot.com";
66
+ /** UNVERIFIED against the live Copilot model catalog (slugs change — see the
67
+ * module doc). Override with COMFYUI_MCP_COPILOT_MODEL, or rely on the
68
+ * inherited listModels() (a live GET /models probe) to surface the account's
69
+ * real, currently-provisioned slugs. */
70
+ export const COPILOT_DEFAULT_MODEL = process.env.COMFYUI_MCP_COPILOT_MODEL?.trim() || "gpt-4.1";
71
+ /**
72
+ * GitHub's VS Code Copilot Chat "editor identity" — REQUIRED on both the
73
+ * token exchange and every chat/completions call, or GitHub 403s even a fully
74
+ * licensed account (see the `github-copilot-token-exchange-needs-editor-
75
+ * headers` gotcha). Exact version numbers are not strictly validated by
76
+ * GitHub — kept as a plausible, recognizable VS Code Copilot Chat identity
77
+ * rather than an app-branded User-Agent (which IS rejected).
78
+ */
79
+ const EDITOR_IDENTITY_HEADERS = {
80
+ "Editor-Version": "vscode/1.95.0",
81
+ "Editor-Plugin-Version": "copilot-chat/0.22.0",
82
+ "User-Agent": "GitHubCopilotChat/0.22.0",
83
+ "Copilot-Integration-Id": "vscode-chat",
84
+ };
85
+ // Uses the shared `redactTokens` from oauth-flow.ts (single source of truth —
86
+ // this file used to carry a local `redactCopilotTokens` copy; its extra
87
+ // ghp_/`token\s+` rules were folded into the exported superset, no coverage
88
+ // lost) to strip token-shaped material from provider error text before it
89
+ // can reach a thrown message or a log line. Never logs/throws the raw ghu_ or
90
+ // the exchanged short-lived bearer.
91
+ /** `github.com` / `githubcopilot.com` — the same allowlist the OAuth engine
92
+ * already enforces for Copilot's device-code flow (oauth-flow.ts), reused
93
+ * here for the token-exchange + chat/completions DATA calls. */
94
+ function copilotApiHostAllowlist() {
95
+ return OAUTH_PROVIDERS.copilot?.apiHostAllowlist ?? ["github.com", "githubcopilot.com"];
96
+ }
97
+ /** Append a "re-run Copilot sign-in" hint to a 401/403 error message exactly
98
+ * once (idempotent — never double-appends if the message already carries a
99
+ * hint, e.g. from `exchangeCopilotToken` below). */
100
+ function withCopilotAuthHint(err) {
101
+ const message = msgOf(err);
102
+ if (/\b(401|403)\b/.test(message) && !/re-run copilot sign-in/i.test(message)) {
103
+ return new Error(`${message} Re-run Copilot sign-in from the panel.`);
104
+ }
105
+ return err instanceof Error ? err : new Error(message);
106
+ }
107
+ /**
108
+ * Step 1 of the two-step Copilot contract: exchange the long-lived `ghu_`
109
+ * token for a short-lived Copilot API bearer. Host-allowlisted before any
110
+ * network call; any error body is redacted before it can reach a thrown
111
+ * message. A 401/403 here is the PRIMARY "you're not signed in / not
112
+ * licensed" failure mode, so it gets the explicit re-sign-in hint.
113
+ */
114
+ async function exchangeCopilotToken(ghuToken, fetchFn) {
115
+ assertAllowedTokenHost(COPILOT_TOKEN_EXCHANGE_URL, copilotApiHostAllowlist());
116
+ const res = await fetchFn(COPILOT_TOKEN_EXCHANGE_URL, {
117
+ method: "GET",
118
+ headers: {
119
+ Authorization: `token ${ghuToken}`,
120
+ Accept: "application/json",
121
+ ...EDITOR_IDENTITY_HEADERS,
122
+ },
123
+ signal: AbortSignal.timeout(15_000),
124
+ });
125
+ const text = await res.text();
126
+ if (!res.ok) {
127
+ const hint = res.status === 401 || res.status === 403
128
+ ? " Re-run Copilot sign-in from the panel (this also happens if the signed-in account has no active Copilot subscription)."
129
+ : "";
130
+ throw new ValidationError(`GitHub Copilot token exchange failed (${res.status}): ${redactTokens(text).slice(0, 300)}.${hint}`);
131
+ }
132
+ let payload;
133
+ try {
134
+ payload = JSON.parse(text);
135
+ }
136
+ catch {
137
+ throw new ValidationError("GitHub Copilot token exchange returned an unparseable response.");
138
+ }
139
+ const token = payload.token?.trim();
140
+ if (!token) {
141
+ throw new ValidationError("GitHub Copilot token exchange response is missing 'token'.");
142
+ }
143
+ const expiresAtMs = typeof payload.expires_at === "number" && Number.isFinite(payload.expires_at)
144
+ ? payload.expires_at * 1000
145
+ : Date.now() + 20 * 60_000; // conservative fallback if the field is absent/renamed
146
+ // The exchange response's endpoints.api can route to a per-account host, but a
147
+ // server-supplied host is UNTRUSTED — if it isn't allowlisted, DROP it and
148
+ // fall back to the default base rather than dialing an off-allowlist host with
149
+ // the live bearer. (The default base itself is re-checked in
150
+ // ensureFreshCopilotToken before setOpenAiAuth, so a bad env override there is
151
+ // rejected outright — see below.)
152
+ const advertised = payload.endpoints?.api?.trim().replace(/\/+$/, "");
153
+ let apiBase = COPILOT_API_BASE;
154
+ if (advertised) {
155
+ try {
156
+ assertAllowedTokenHost(advertised, copilotApiHostAllowlist());
157
+ apiBase = advertised;
158
+ }
159
+ catch {
160
+ logger.warn(`[copilot-backend] token exchange advertised a non-allowlisted api host — ignoring it and using the default base.`);
161
+ }
162
+ }
163
+ return { token, expiresAtMs, apiBase };
164
+ }
165
+ /** Refresh 60s before the bearer's reported expiry — matches the skew used
166
+ * elsewhere in code-provider-auth.ts (TOKEN_REFRESH_SKEW_MS-style guard). */
167
+ const COPILOT_TOKEN_REFRESH_SKEW_MS = 60_000;
168
+ /**
169
+ * GitHub Copilot chat — OpenAI-compatible chat/completions + the same 6-tool
170
+ * router as Ollama/GLM/Kimi. See the module doc above for the full contract,
171
+ * the reuse rationale, and the unverified-offline items.
172
+ */
173
+ export class CopilotBackend extends OllamaBackend {
174
+ capabilities = COPILOT_CAPABILITIES;
175
+ ghuToken = null;
176
+ copilotBearer = null;
177
+ copilotBearerExpiresAtMs = 0;
178
+ resolveOAuth;
179
+ fetchFn;
180
+ constructor(deps = {}) {
181
+ super({
182
+ ...deps,
183
+ backendId: "copilot",
184
+ api: "openai",
185
+ host: COPILOT_API_BASE, // placeholder until the first exchange resolves endpoints.api
186
+ apiKey: "pending-oauth", // never dialed with this value — ensureFreshCopilotToken() runs first
187
+ model: deps.model ?? COPILOT_DEFAULT_MODEL,
188
+ });
189
+ this.resolveOAuth = deps.resolveCopilotOAuth ?? resolveCopilotOAuth;
190
+ this.fetchFn = deps.fetch ?? fetch;
191
+ }
192
+ /** Adds GitHub's required editor-identity headers on top of the inherited
193
+ * Bearer-token header — applies to every chat/completions and /models call
194
+ * (OllamaBackend's "openai" dialect reads authHeaders() for both). */
195
+ authHeaders() {
196
+ const base = super.authHeaders();
197
+ if (!base.authorization)
198
+ return base;
199
+ return { ...base, ...EDITOR_IDENTITY_HEADERS };
200
+ }
201
+ /**
202
+ * Exchange (or reuse a cached, still-fresh) short-lived Copilot bearer.
203
+ * Called from prepare() (session start) AND before EVERY turn (see run()
204
+ * below) so a long-lived panel session survives the token's short,
205
+ * GitHub-controlled lifetime. The short-lived bearer is held ONLY in this
206
+ * instance's memory — never written to disk (only the ghu_ persists, in
207
+ * copilot-auth.json, and this function never rewrites that file).
208
+ */
209
+ async ensureFreshCopilotToken() {
210
+ const nowMs = Date.now();
211
+ if (this.copilotBearer && nowMs < this.copilotBearerExpiresAtMs - COPILOT_TOKEN_REFRESH_SKEW_MS) {
212
+ return;
213
+ }
214
+ if (!this.ghuToken) {
215
+ const creds = await this.resolveOAuth();
216
+ this.ghuToken = creds.ghuToken;
217
+ }
218
+ const { token, expiresAtMs, apiBase } = await exchangeCopilotToken(this.ghuToken, this.fetchFn);
219
+ // FINAL GATE before the live bearer is ever attached to a host: apiBase is
220
+ // either the allowlist-checked exchange endpoint or COPILOT_API_BASE (which
221
+ // may be a COMFYUI_MCP_COPILOT_API_BASE env override). An off-allowlist
222
+ // override must be REJECTED here — never silently dialed — so the inherited
223
+ // ollama-backend prepare()/chatStream()/listModels() (which attach the
224
+ // bearer to this.host) can only ever hit an allowlisted host.
225
+ assertAllowedTokenHost(apiBase, copilotApiHostAllowlist());
226
+ this.copilotBearer = token;
227
+ this.copilotBearerExpiresAtMs = expiresAtMs;
228
+ this.setOpenAiAuth(apiBase, token);
229
+ }
230
+ async prepare() {
231
+ await this.ensureFreshCopilotToken();
232
+ try {
233
+ await super.prepare(); // GET {apiBase}/models reachability check + connectTools()
234
+ }
235
+ catch (err) {
236
+ throw withCopilotAuthHint(err);
237
+ }
238
+ logger.info(`[copilot-backend] ready (experimental — see task-5b report for the unverified contract items)`);
239
+ }
240
+ /**
241
+ * Wrap the incoming turn channel so the Copilot bearer is refreshed BEFORE
242
+ * every turn, not just once at session start — a panel session can easily
243
+ * outlive the short-lived exchange token. Best-effort: a refresh failure
244
+ * mid-session is logged and the turn proceeds with whatever token is
245
+ * cached; if that token is actually stale the ensuing chat/completions call
246
+ * 401s and is surfaced through OllamaBackend's own turn-error path (a
247
+ * normal `result:false` + assistant error — never an unhandled rejection
248
+ * that could park the panel's turn-gate).
249
+ */
250
+ async *wrapChannel(channel) {
251
+ for await (const turn of channel) {
252
+ try {
253
+ await this.ensureFreshCopilotToken();
254
+ }
255
+ catch (err) {
256
+ logger.warn(`[copilot-backend] token refresh before turn failed (${msgOf(err)}) — attempting the turn with the existing token.`);
257
+ }
258
+ yield turn;
259
+ }
260
+ }
261
+ async *run(opts) {
262
+ yield* super.run({ ...opts, channel: this.wrapChannel(opts.channel) });
263
+ }
264
+ }
265
+ //# sourceMappingURL=copilot-backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-backend.js","sourceRoot":"","sources":["../../src/orchestrator/copilot-backend.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,2EAA2E;AAC3E,2EAA2E;AAC3E,kEAAkE;AAClE,gEAAgE;AAChE,+DAA+D;AAC/D,0EAA0E;AAC1E,kDAAkD;AAClD,EAAE;AACF,6BAA6B;AAC7B,yEAAyE;AACzE,+EAA+E;AAC/E,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,sDAAsD;AACtD,8DAA8D;AAC9D,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,0EAA0E;AAC1E,+EAA+E;AAC/E,8DAA8D;AAC9D,gEAAgE;AAChE,6EAA6E;AAC7E,yEAAyE;AACzE,EAAE;AACF,8EAA8E;AAC9E,qEAAqE;AACrE,+EAA+E;AAC/E,8EAA8E;AAC9E,aAAa;AACb,+EAA+E;AAC/E,uEAAuE;AACvE,2CAA2C;AAC3C,2EAA2E;AAC3E,wEAAwE;AACxE,uEAAuE;AACvE,8EAA8E;AAC9E,qCAAqC;AACrC,yEAAyE;AACzE,gDAAgD;AAEhD,OAAO,EAAE,eAAe,EAAE,M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KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { GLM_CAPABILITIES } from "./agent-backend.js";
2
+ import { OllamaBackend } from "./ollama-backend.js";
3
+ import { resolveGlmCodeCredentials } from "../services/code-provider-auth.js";
4
+ export const GLM_DEFAULT_MODEL = process.env.COMFYUI_MCP_GLM_MODEL?.trim() || "glm-4.7";
5
+ /** Z.AI GLM Coding Plan — OpenAI-compatible chat/completions + 6-tool router. */
6
+ export class GlmBackend extends OllamaBackend {
7
+ capabilities = GLM_CAPABILITIES;
8
+ constructor(deps = {}) {
9
+ const creds = resolveGlmCodeCredentials();
10
+ super({
11
+ ...deps,
12
+ backendId: "glm",
13
+ api: "openai",
14
+ host: creds.baseUrl,
15
+ apiKey: creds.apiKey,
16
+ model: deps.model ?? GLM_DEFAULT_MODEL,
17
+ });
18
+ }
19
+ }
20
+ //# sourceMappingURL=glm-backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glm-backend.js","sourceRoot":"","sources":["../../src/orchestrator/glm-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;AAExF,iFAAiF;AACjF,MAAM,OAAO,UAAW,SAAQ,aAAa;IAClC,YAAY,GAAG,gBAAgB,CAAC;IAEzC,YAAY,OAAyE,EAAE;QACrF,MAAM,KAAK,GAAG,yBAAyB,EAAE,CAAC;QAC1C,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS,EAAE,KAAK;YAChB,GAAG,EAAE,QAAQ;YACb,IAAI,EAAE,KAAK,CAAC,OAAO;YACnB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,iBAAiB;SACvC,CAAC,CAAC;IACL,CAAC;CACF"}