dsh-multi-router 0.6.11 → 1.0.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 (56) hide show
  1. package/README.md +2 -427
  2. package/package.json +5 -81
  3. package/CHANGELOG.md +0 -237
  4. package/LICENSE +0 -21
  5. package/THIRD_PARTY_NOTICES.md +0 -171
  6. package/cordis.patch.yml +0 -3
  7. package/lib/accounts.js +0 -19
  8. package/lib/accounts.js.map +0 -7
  9. package/lib/api-service.js +0 -11
  10. package/lib/api-service.js.map +0 -7
  11. package/lib/chunk-2UM45OXY.js +0 -181
  12. package/lib/chunk-2UM45OXY.js.map +0 -7
  13. package/lib/chunk-4L2CBGXN.js +0 -674
  14. package/lib/chunk-4L2CBGXN.js.map +0 -7
  15. package/lib/chunk-4V52V5GO.js +0 -105
  16. package/lib/chunk-4V52V5GO.js.map +0 -7
  17. package/lib/chunk-DNQPZMPF.js +0 -33
  18. package/lib/chunk-DNQPZMPF.js.map +0 -7
  19. package/lib/chunk-FLL3DUVP.js +0 -2017
  20. package/lib/chunk-FLL3DUVP.js.map +0 -7
  21. package/lib/chunk-GEBZMIMA.js +0 -287
  22. package/lib/chunk-GEBZMIMA.js.map +0 -7
  23. package/lib/chunk-KWXLQJS5.js +0 -1102
  24. package/lib/chunk-KWXLQJS5.js.map +0 -7
  25. package/lib/chunk-NZF36O5I.js +0 -5421
  26. package/lib/chunk-NZF36O5I.js.map +0 -7
  27. package/lib/chunk-S5KMFAQM.js +0 -50
  28. package/lib/chunk-S5KMFAQM.js.map +0 -7
  29. package/lib/chunk-TM5XDMGY.js +0 -332
  30. package/lib/chunk-TM5XDMGY.js.map +0 -7
  31. package/lib/chunk-WDIT4E2W.js +0 -120
  32. package/lib/chunk-WDIT4E2W.js.map +0 -7
  33. package/lib/chunk-YCAO7GCT.js +0 -2059
  34. package/lib/chunk-YCAO7GCT.js.map +0 -7
  35. package/lib/cli.js +0 -103
  36. package/lib/cli.js.map +0 -7
  37. package/lib/client.js +0 -2793
  38. package/lib/client.js.map +0 -7
  39. package/lib/clients.js +0 -30
  40. package/lib/clients.js.map +0 -7
  41. package/lib/host-v0.6.11.js +0 -414
  42. package/lib/host.js +0 -414
  43. package/lib/index.js +0 -414
  44. package/lib/index.js.map +0 -7
  45. package/lib/manager.js +0 -27
  46. package/lib/manager.js.map +0 -7
  47. package/lib/region-DO3KAV7V.js +0 -15
  48. package/lib/region-DO3KAV7V.js.map +0 -7
  49. package/lib/router.js +0 -14
  50. package/lib/router.js.map +0 -7
  51. package/lib/shim.js +0 -10
  52. package/lib/shim.js.map +0 -7
  53. package/lib/upstream-VP6J7LU2.js +0 -25
  54. package/lib/upstream-VP6J7LU2.js.map +0 -7
  55. package/router.example.json +0 -289
  56. package/upstream-lock.json +0 -17
package/lib/cli.js DELETED
@@ -1,103 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- createAccountClient
4
- } from "./chunk-NZF36O5I.js";
5
- import {
6
- importAccount
7
- } from "./chunk-2UM45OXY.js";
8
- import "./chunk-FLL3DUVP.js";
9
- import "./chunk-KWXLQJS5.js";
10
- import "./chunk-S5KMFAQM.js";
11
- import "./chunk-4V52V5GO.js";
12
- import {
13
- Router
14
- } from "./chunk-4L2CBGXN.js";
15
- import {
16
- DEFAULT_ROUTES,
17
- PROVIDERS,
18
- validateConfig,
19
- writePrivateJson
20
- } from "./chunk-GEBZMIMA.js";
21
-
22
- // src/cli.mjs
23
- import { parseArgs } from "node:util";
24
- import { readFile } from "node:fs/promises";
25
- import { dirname, join, relative, resolve } from "node:path";
26
- import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
27
- import { withFileLock } from "@deepseek-ai/dsh-atomic-write";
28
- var { values, positionals } = parseArgs({ allowPositionals: true, options: Object.fromEntries(
29
- ["config", "id", "provider", "source", "edition", "identity"].map((key) => [key, { type: "string" }])
30
- ) });
31
- var file = resolve(values.config ?? process.env.DSH_MULTI_ROUTER_CONFIG ?? join(resolveDshHome(), "multi-router", "router.json"));
32
- var [command] = positionals;
33
- async function main() {
34
- if (command === "init") {
35
- await readFile(file).then(() => {
36
- throw new Error("Config already exists");
37
- }, (error) => {
38
- if (error.code !== "ENOENT") throw error;
39
- });
40
- await writePrivateJson(file, { accounts: [], routes: DEFAULT_ROUTES });
41
- console.log(`Created ${file}`);
42
- return;
43
- }
44
- if (!["add", "remove", "enable", "disable", "status", "models"].includes(command)) {
45
- console.log("dsh-multi-router init|add|remove|enable|disable|status|models [--config /path/router.json]\nadd --id wb1 --provider workbuddy --source /path/auth-file\nTrae add: --edition solo; own credential JSON: --identity /path/identity.json\nremove|enable|disable|models: --id account-id\nProviders: " + PROVIDERS.join(", "));
46
- return;
47
- }
48
- const raw = JSON.parse(await readFile(file, "utf8"));
49
- let config = validateConfig(raw, file);
50
- if (command === "status") {
51
- console.log(JSON.stringify(new Router(config, () => {
52
- }).status(), null, 2));
53
- return;
54
- }
55
- if (command === "add") {
56
- const { id, provider, source } = values;
57
- if (!/^[a-zA-Z0-9_-]{1,64}$/.test(id ?? "") || !PROVIDERS.includes(provider) || !source) throw new Error("add needs valid --id, --provider and --source");
58
- if (raw.accounts.some((a) => a.id === id)) throw new Error("Account already exists; remove it before replacing");
59
- const dir = join(dirname(file), "accounts", id);
60
- const credentialFile = join(dir, "credential.json");
61
- const identityFile = join(dir, "identity.json");
62
- await importAccount({
63
- provider,
64
- source: resolve(source),
65
- credentialFile,
66
- identityFile,
67
- edition: values.edition,
68
- identitySource: values.identity ? resolve(values.identity) : void 0
69
- });
70
- raw.accounts.push({
71
- id,
72
- provider,
73
- credentialFile: relative(dirname(file), credentialFile),
74
- ...provider.startsWith("trae") ? { identityFile: relative(dirname(file), identityFile) } : {}
75
- });
76
- validateConfig(raw, file);
77
- await writePrivateJson(file, raw);
78
- console.log(`Added ${id} (${provider}). The running plugin applies changes automatically.`);
79
- return;
80
- }
81
- const account = config.accounts.find((a) => a.id === values.id);
82
- if (!account) throw new Error("Unknown --id");
83
- if (command === "models") {
84
- const client = await createAccountClient(account, config);
85
- console.log(JSON.stringify(await client.models(AbortSignal.timeout(6e4)), null, 2));
86
- return;
87
- }
88
- if (command === "remove") {
89
- raw.accounts = raw.accounts.filter((a) => a.id !== account.id);
90
- validateConfig(raw, file);
91
- await writePrivateJson(file, raw);
92
- console.log(`Removed ${account.id} from routing; credential files kept. Changes apply automatically.`);
93
- return;
94
- }
95
- raw.accounts.find((a) => a.id === account.id).enabled = command === "enable";
96
- await writePrivateJson(file, raw);
97
- console.log(`${command} ${account.id}. Changes apply automatically.`);
98
- }
99
- (["add", "remove", "enable", "disable"].includes(command) ? withFileLock(file, main, { waitMs: 3e4 }) : main()).catch((error) => {
100
- console.error(error instanceof Error ? error.message.replace(/Bearer\s+\S+/gi, "Bearer [redacted]") : "Command failed");
101
- process.exitCode = 1;
102
- });
103
- //# sourceMappingURL=cli.js.map
package/lib/cli.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/cli.mjs"],
4
- "sourcesContent": ["#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { resolveDshHome } from '@deepseek-ai/dsh-home-paths';\nimport { withFileLock } from '@deepseek-ai/dsh-atomic-write';\nimport { PROVIDERS, DEFAULT_ROUTES, readConfig, validateConfig, writePrivateJson } from './config.mjs';\nimport { importAccount } from './accounts.mjs';\nimport { createAccountClient } from './clients.mjs';\nimport { Router } from './router.mjs';\n\nconst { values, positionals } = parseArgs({ allowPositionals: true, options: Object.fromEntries(\n ['config', 'id', 'provider', 'source', 'edition', 'identity'].map(key => [key, { type: 'string' }])) });\nconst file = resolve(values.config ?? process.env.DSH_MULTI_ROUTER_CONFIG ?? join(resolveDshHome(), 'multi-router', 'router.json'));\nconst [command] = positionals;\nasync function main() {\n if (command === 'init') {\n await readFile(file).then(() => { throw new Error('Config already exists'); }, error => { if (error.code !== 'ENOENT') throw error; });\n await writePrivateJson(file, { accounts: [], routes: DEFAULT_ROUTES });\n console.log(`Created ${file}`); return;\n }\n if (!['add', 'remove', 'enable', 'disable', 'status', 'models'].includes(command)) {\n console.log('dsh-multi-router init|add|remove|enable|disable|status|models [--config /path/router.json]\\n'\n + 'add --id wb1 --provider workbuddy --source /path/auth-file\\n'\n + 'Trae add: --edition solo; own credential JSON: --identity /path/identity.json\\n'\n + 'remove|enable|disable|models: --id account-id\\nProviders: ' + PROVIDERS.join(', ')); return;\n }\n const raw = JSON.parse(await readFile(file, 'utf8'));\n let config = validateConfig(raw, file);\n if (command === 'status') {\n console.log(JSON.stringify(new Router(config, () => {}).status(), null, 2)); return;\n }\n if (command === 'add') {\n const { id, provider, source } = values;\n if (!/^[a-zA-Z0-9_-]{1,64}$/.test(id ?? '') || !PROVIDERS.includes(provider) || !source) throw new Error('add needs valid --id, --provider and --source');\n if (raw.accounts.some(a => a.id === id)) throw new Error('Account already exists; remove it before replacing');\n const dir = join(dirname(file), 'accounts', id);\n const credentialFile = join(dir, 'credential.json');\n const identityFile = join(dir, 'identity.json');\n await importAccount({ provider, source: resolve(source), credentialFile, identityFile, edition: values.edition,\n identitySource: values.identity ? resolve(values.identity) : undefined });\n raw.accounts.push({ id, provider, credentialFile: relative(dirname(file), credentialFile),\n ...(provider.startsWith('trae') ? { identityFile: relative(dirname(file), identityFile) } : {}) });\n validateConfig(raw, file); await writePrivateJson(file, raw);\n console.log(`Added ${id} (${provider}). The running plugin applies changes automatically.`); return;\n }\n const account = config.accounts.find(a => a.id === values.id);\n if (!account) throw new Error('Unknown --id');\n if (command === 'models') {\n const client = await createAccountClient(account, config);\n console.log(JSON.stringify(await client.models(AbortSignal.timeout(60000)), null, 2)); return;\n }\n if (command === 'remove') {\n raw.accounts = raw.accounts.filter(a => a.id !== account.id);\n // Reject dangling route bindings before changing files. Credential files remain recoverable.\n validateConfig(raw, file); await writePrivateJson(file, raw);\n console.log(`Removed ${account.id} from routing; credential files kept. Changes apply automatically.`); return;\n }\n raw.accounts.find(a => a.id === account.id).enabled = command === 'enable';\n await writePrivateJson(file, raw);\n console.log(`${command} ${account.id}. Changes apply automatically.`);\n}\n(['add', 'remove', 'enable', 'disable'].includes(command) ? withFileLock(file, main, { waitMs: 30000 }) : main())\n .catch(error => { console.error(error instanceof Error ? error.message.replace(/Bearer\\s+\\S+/gi, 'Bearer [redacted]') : 'Command failed'); process.exitCode = 1; });\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,SAAS,MAAM,UAAU,eAAe;AACjD,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAM7B,IAAM,EAAE,QAAQ,YAAY,IAAI,UAAU,EAAE,kBAAkB,MAAM,SAAS,OAAO;AAAA,EAClF,CAAC,UAAU,MAAM,YAAY,UAAU,WAAW,UAAU,EAAE,IAAI,SAAO,CAAC,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC;AAAC,EAAE,CAAC;AACxG,IAAM,OAAO,QAAQ,OAAO,UAAU,QAAQ,IAAI,2BAA2B,KAAK,eAAe,GAAG,gBAAgB,aAAa,CAAC;AAClI,IAAM,CAAC,OAAO,IAAI;AAClB,eAAe,OAAO;AACpB,MAAI,YAAY,QAAQ;AACtB,UAAM,SAAS,IAAI,EAAE,KAAK,MAAM;AAAE,YAAM,IAAI,MAAM,uBAAuB;AAAA,IAAG,GAAG,WAAS;AAAE,UAAI,MAAM,SAAS,SAAU,OAAM;AAAA,IAAO,CAAC;AACrI,UAAM,iBAAiB,MAAM,EAAE,UAAU,CAAC,GAAG,QAAQ,eAAe,CAAC;AACrE,YAAQ,IAAI,WAAW,IAAI,EAAE;AAAG;AAAA,EAClC;AACA,MAAI,CAAC,CAAC,OAAO,UAAU,UAAU,WAAW,UAAU,QAAQ,EAAE,SAAS,OAAO,GAAG;AACjF,YAAQ,IAAI,sSAGuD,UAAU,KAAK,IAAI,CAAC;AAAG;AAAA,EAC5F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