dsh-coding-subscription-oauth 0.6.2 → 0.6.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/CHANGELOG.md +222 -206
- package/CONTRIBUTING.md +129 -120
- package/INSTALL.md +218 -218
- package/LICENSE +19 -19
- package/NOTICE +11 -11
- package/README.de.md +289 -289
- package/README.es.md +290 -290
- package/README.fr.md +290 -290
- package/README.ja.md +290 -290
- package/README.ko.md +290 -290
- package/README.md +304 -304
- package/README.pt-BR.md +290 -290
- package/README.ru.md +290 -290
- package/README.zh-CN.md +302 -302
- package/compatibility/dsh-bom.json +0 -0
- package/cordis.patch.yml +13 -13
- package/docs/00-project-rules.md +212 -195
- package/docs/02-architecture.md +130 -130
- package/docs/02-architecture.zh-CN.md +130 -130
- package/lib/bin.js.map +1 -1
- package/lib/capability-settings.d.ts +8 -2
- package/lib/capability-settings.d.ts.map +1 -1
- package/lib/capability-tools.d.ts +7 -2
- package/lib/capability-tools.d.ts.map +1 -1
- package/lib/client.js +3 -3
- package/lib/client.js.map +2 -2
- package/lib/codex-images.d.ts +8 -0
- package/lib/codex-images.d.ts.map +1 -1
- package/lib/index.js +32 -7
- package/lib/index.js.map +2 -2
- package/lib/invariant.js.map +1 -1
- package/media/en/settings_accounts.png +0 -0
- package/media/en/settings_capabilities.png +0 -0
- package/media/en/settings_gateway.png +0 -0
- package/media/settings_accounts.png +0 -0
- package/media/settings_capabilities.png +0 -0
- package/media/settings_gateway.png +0 -0
- package/media/settings_overview.png +0 -0
- package/media/zh-CN/settings_accounts.png +0 -0
- package/media/zh-CN/settings_capabilities.png +0 -0
- package/media/zh-CN/settings_gateway.png +0 -0
- package/package.json +148 -148
- package/patches/dsh-agy@0.1.2.patch +25 -25
- package/scripts/release.mjs +186 -186
- package/scripts/smoke-deployed-routes.mjs +146 -146
- package/scripts/verify-deployed-catalog.mjs +87 -87
- package/src/adapter.ts +273 -273
- package/src/alias-adapter.ts +130 -130
- package/src/auth-routes.ts +921 -921
- package/src/auth.ts +67 -67
- package/src/bin.ts +350 -350
- package/src/capability-routes.ts +279 -279
- package/src/capability-runtime.ts +314 -313
- package/src/capability-settings.ts +671 -658
- package/src/capability-tools.ts +685 -666
- package/src/catalog.ts +271 -271
- package/src/client/GrokBuildSettings.tsx +771 -770
- package/src/client/api.ts +88 -88
- package/src/client/components/AboutTab.tsx +30 -30
- package/src/client/components/AccountsTab.tsx +241 -241
- package/src/client/components/Badge.tsx +33 -33
- package/src/client/components/CapabilitiesTab.tsx +265 -265
- package/src/client/components/CliPullPreview.tsx +116 -116
- package/src/client/components/CopyButton.tsx +57 -57
- package/src/client/components/GatewayTab.tsx +469 -469
- package/src/client/components/NoticeBanner.tsx +46 -46
- package/src/client/components/ProgressBar.tsx +53 -53
- package/src/client/components/ProviderCard.tsx +606 -606
- package/src/client/components/SettingsTabs.tsx +75 -75
- package/src/client/components/ToggleSwitch.tsx +71 -71
- package/src/client/constants.ts +230 -224
- package/src/client/display.ts +61 -61
- package/src/client/dshClientAdapter.ts +127 -127
- package/src/client/gatewaySnippets.ts +37 -37
- package/src/client/index.tsx +156 -156
- package/src/client/locales.ts +540 -535
- package/src/client/microStyles.ts +52 -52
- package/src/client/parsers.ts +398 -396
- package/src/client/styles.ts +325 -325
- package/src/client/types.ts +199 -197
- package/src/codex-http.ts +447 -447
- package/src/codex-images.ts +503 -485
- package/src/codex-model-capabilities.ts +320 -320
- package/src/codex-search.ts +245 -245
- package/src/codex-usage.ts +263 -263
- package/src/compatibility.ts +41 -41
- package/src/dsh-host-adapter.ts +173 -173
- package/src/gateway-anthropic-messages.ts +84 -84
- package/src/gateway-auth.ts +102 -102
- package/src/gateway-backend.ts +274 -274
- package/src/gateway-body.ts +49 -49
- package/src/gateway-config.ts +76 -76
- package/src/gateway-http.ts +104 -104
- package/src/gateway-openai-chat.ts +124 -124
- package/src/gateway-openai-responses.ts +53 -53
- package/src/gateway-parse.ts +224 -224
- package/src/gateway-protocol.ts +52 -52
- package/src/gateway-routes.ts +158 -158
- package/src/gateway.ts +258 -258
- package/src/grok-errors.ts +24 -24
- package/src/grok-imagine.ts +1627 -1627
- package/src/grok-import.ts +151 -151
- package/src/http-json.ts +82 -82
- package/src/ids.ts +59 -59
- package/src/imagine-routes.ts +463 -463
- package/src/index.ts +709 -709
- package/src/invariant.ts +17 -17
- package/src/kimi-errors.ts +26 -26
- package/src/media-store.ts +927 -927
- package/src/oauth-import-routes.ts +324 -324
- package/src/oauth-providers.ts +152 -152
- package/src/oauth-session.ts +183 -183
- package/src/oauth-sources.ts +1104 -1104
- package/src/oauth.ts +620 -620
- package/src/provider.ts +128 -128
- package/src/proxy.ts +11 -11
- package/src/redact.ts +72 -72
- package/src/session.ts +218 -218
- package/src/store.ts +217 -217
- package/src/web-origin.ts +296 -296
- package/src/web-routes.ts +38 -38
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
|
|
5
|
-
const base = new URL(process.env.DSH_WEB_URL ?? "http://127.0.0.1:3080");
|
|
6
|
-
const origin = base.origin;
|
|
7
|
-
const timeoutMs = Number.parseInt(process.env.DSH_SMOKE_TIMEOUT_MS ?? "180000", 10);
|
|
8
|
-
const restoreProvider = process.env.DSH_RESTORE_PROVIDER;
|
|
9
|
-
const restoreModel = process.env.DSH_RESTORE_MODEL;
|
|
10
|
-
if (restoreProvider === undefined || restoreModel === undefined) {
|
|
11
|
-
throw new Error(
|
|
12
|
-
"Set DSH_RESTORE_PROVIDER and DSH_RESTORE_MODEL before running; smoke selection updates the saved default temporarily",
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
const restoreSelection = {
|
|
16
|
-
provider: restoreProvider,
|
|
17
|
-
model: restoreModel,
|
|
18
|
-
...(process.env.DSH_RESTORE_REASONING === undefined ? {} : { reasoningEffort: process.env.DSH_RESTORE_REASONING }),
|
|
19
|
-
};
|
|
20
|
-
const cases = [
|
|
21
|
-
{
|
|
22
|
-
route: "codex-oauth",
|
|
23
|
-
model: process.env.DSH_CODEX_SMOKE_MODEL ?? "gpt-5.6-sol",
|
|
24
|
-
marker: "DSH_CODEX_OAUTH_SMOKE_OK",
|
|
25
|
-
},
|
|
26
|
-
{ route: "kimi-code-oauth", model: process.env.DSH_KIMI_SMOKE_MODEL ?? "k3", marker: "DSH_KIMI_OAUTH_SMOKE_OK" },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
async function rpc(method, payload) {
|
|
30
|
-
const rpcId = randomUUID();
|
|
31
|
-
const response = await fetch(new URL(`/api/${method}`, base), {
|
|
32
|
-
method: "POST",
|
|
33
|
-
headers: { accept: "application/json", "content-type": "application/json", origin },
|
|
34
|
-
body: JSON.stringify({ type: "client-request", rpcId, method, payload }),
|
|
35
|
-
signal: AbortSignal.timeout(30_000),
|
|
36
|
-
});
|
|
37
|
-
const envelope = await response.json().catch(() => undefined);
|
|
38
|
-
if (!response.ok) throw new Error(`${method}: HTTP ${response.status}`);
|
|
39
|
-
if (envelope?.rpcId !== rpcId || envelope?.result?.ok !== true) {
|
|
40
|
-
throw new Error(`${method}: ${envelope?.result?.error?.message ?? "invalid response"}`);
|
|
41
|
-
}
|
|
42
|
-
return envelope.result.value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function waitForIdle(sessionId) {
|
|
46
|
-
const deadline = Date.now() + timeoutMs;
|
|
47
|
-
while (Date.now() < deadline) {
|
|
48
|
-
const { items } = await rpc("session.list", {});
|
|
49
|
-
const session = items.find((item) => item.sessionId === sessionId);
|
|
50
|
-
if (session === undefined) throw new Error(`session ${sessionId} disappeared`);
|
|
51
|
-
if (!session.blank && !session.running) return;
|
|
52
|
-
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
53
|
-
}
|
|
54
|
-
throw new Error(`session ${sessionId} did not finish within ${timeoutMs}ms`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function contentBlocks(value, output = []) {
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
for (const item of value) contentBlocks(item, output);
|
|
60
|
-
} else if (value !== null && typeof value === "object") {
|
|
61
|
-
if (typeof value.type === "string" && ["tool-call", "tool-result"].includes(value.type)) output.push(value);
|
|
62
|
-
for (const child of Object.values(value)) contentBlocks(child, output);
|
|
63
|
-
}
|
|
64
|
-
return output;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function runSmoke(testCase) {
|
|
68
|
-
const created = await rpc("session.create", { cwd: process.cwd() });
|
|
69
|
-
const sessionId = created.sessionId;
|
|
70
|
-
let selected = false;
|
|
71
|
-
let failure;
|
|
72
|
-
try {
|
|
73
|
-
await rpc("session.selectModel", {
|
|
74
|
-
sessionId,
|
|
75
|
-
provider: testCase.route,
|
|
76
|
-
model: testCase.model,
|
|
77
|
-
reasoningEffort: "low",
|
|
78
|
-
});
|
|
79
|
-
selected = true;
|
|
80
|
-
await rpc("session.prompt", {
|
|
81
|
-
sessionId,
|
|
82
|
-
mode: "queue",
|
|
83
|
-
clientTimeZone: "UTC",
|
|
84
|
-
content: [
|
|
85
|
-
{
|
|
86
|
-
type: "text",
|
|
87
|
-
text: `Automated OAuth smoke test. You MUST call the glob tool exactly once with pattern "package.json" in the current workspace. After receiving the tool result, reply with exactly ${testCase.marker} and no other text.`,
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
});
|
|
91
|
-
await waitForIdle(sessionId);
|
|
92
|
-
const history = await rpc("session.history", { sessionId, maxMessages: 200 });
|
|
93
|
-
const serialized = JSON.stringify(history.events);
|
|
94
|
-
const blocks = contentBlocks(history.events);
|
|
95
|
-
const toolCalls = blocks.filter((block) => block.type === "tool-call").length;
|
|
96
|
-
const toolResults = blocks.filter((block) => block.type === "tool-result").length;
|
|
97
|
-
const eventTypes = [...new Set(history.events.map((entry) => entry.event.type))];
|
|
98
|
-
const turnErrors = eventTypes.filter((type) => type.includes("error"));
|
|
99
|
-
if (!serialized.includes(testCase.marker)) throw new Error(`${testCase.route}: response marker missing`);
|
|
100
|
-
if (toolCalls === 0 || toolResults === 0) throw new Error(`${testCase.route}: tool-call round trip missing`);
|
|
101
|
-
if (turnErrors.length > 0) throw new Error(`${testCase.route}: error events: ${turnErrors.join(", ")}`);
|
|
102
|
-
|
|
103
|
-
const secondMarker = `${testCase.marker}_TURN2`;
|
|
104
|
-
await rpc("session.prompt", {
|
|
105
|
-
sessionId,
|
|
106
|
-
mode: "queue",
|
|
107
|
-
clientTimeZone: "UTC",
|
|
108
|
-
content: [
|
|
109
|
-
{ type: "text", text: `Second-turn replay test. Reply with exactly ${secondMarker} and no other text.` },
|
|
110
|
-
],
|
|
111
|
-
});
|
|
112
|
-
await waitForIdle(sessionId);
|
|
113
|
-
const secondHistory = await rpc("session.history", { sessionId, maxMessages: 200 });
|
|
114
|
-
const secondSerialized = JSON.stringify(secondHistory.events);
|
|
115
|
-
const secondEventTypes = [...new Set(secondHistory.events.map((entry) => entry.event.type))];
|
|
116
|
-
const secondTurnErrors = secondEventTypes.filter((type) => type.includes("error"));
|
|
117
|
-
if (!secondSerialized.includes(secondMarker))
|
|
118
|
-
throw new Error(`${testCase.route}: second-turn response marker missing`);
|
|
119
|
-
if (secondTurnErrors.length > 0)
|
|
120
|
-
throw new Error(`${testCase.route}: second-turn error events: ${secondTurnErrors.join(", ")}`);
|
|
121
|
-
console.log(`${testCase.route}/${testCase.model}: twoTurns=yes toolCalls=${toolCalls} toolResults=${toolResults}`);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
failure = error;
|
|
124
|
-
} finally {
|
|
125
|
-
if (selected) {
|
|
126
|
-
try {
|
|
127
|
-
await rpc("session.selectModel", { sessionId, ...restoreSelection });
|
|
128
|
-
} catch (error) {
|
|
129
|
-
failure ??= new Error(
|
|
130
|
-
`${testCase.route}: failed to restore default model: ${error instanceof Error ? error.message : String(error)}`,
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
await rpc("workspace.archiveSession", { sessionId });
|
|
136
|
-
} catch (error) {
|
|
137
|
-
failure ??= new Error(
|
|
138
|
-
`${testCase.route}: failed to archive smoke session: ${error instanceof Error ? error.message : String(error)}`,
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (failure !== undefined) throw failure;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
for (const testCase of cases) await runSmoke(testCase);
|
|
146
|
-
console.log("Deployed Codex/Kimi OAuth inference and tool-call smoke passed.");
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
const base = new URL(process.env.DSH_WEB_URL ?? "http://127.0.0.1:3080");
|
|
6
|
+
const origin = base.origin;
|
|
7
|
+
const timeoutMs = Number.parseInt(process.env.DSH_SMOKE_TIMEOUT_MS ?? "180000", 10);
|
|
8
|
+
const restoreProvider = process.env.DSH_RESTORE_PROVIDER;
|
|
9
|
+
const restoreModel = process.env.DSH_RESTORE_MODEL;
|
|
10
|
+
if (restoreProvider === undefined || restoreModel === undefined) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"Set DSH_RESTORE_PROVIDER and DSH_RESTORE_MODEL before running; smoke selection updates the saved default temporarily",
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
const restoreSelection = {
|
|
16
|
+
provider: restoreProvider,
|
|
17
|
+
model: restoreModel,
|
|
18
|
+
...(process.env.DSH_RESTORE_REASONING === undefined ? {} : { reasoningEffort: process.env.DSH_RESTORE_REASONING }),
|
|
19
|
+
};
|
|
20
|
+
const cases = [
|
|
21
|
+
{
|
|
22
|
+
route: "codex-oauth",
|
|
23
|
+
model: process.env.DSH_CODEX_SMOKE_MODEL ?? "gpt-5.6-sol",
|
|
24
|
+
marker: "DSH_CODEX_OAUTH_SMOKE_OK",
|
|
25
|
+
},
|
|
26
|
+
{ route: "kimi-code-oauth", model: process.env.DSH_KIMI_SMOKE_MODEL ?? "k3", marker: "DSH_KIMI_OAUTH_SMOKE_OK" },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
async function rpc(method, payload) {
|
|
30
|
+
const rpcId = randomUUID();
|
|
31
|
+
const response = await fetch(new URL(`/api/${method}`, base), {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: { accept: "application/json", "content-type": "application/json", origin },
|
|
34
|
+
body: JSON.stringify({ type: "client-request", rpcId, method, payload }),
|
|
35
|
+
signal: AbortSignal.timeout(30_000),
|
|
36
|
+
});
|
|
37
|
+
const envelope = await response.json().catch(() => undefined);
|
|
38
|
+
if (!response.ok) throw new Error(`${method}: HTTP ${response.status}`);
|
|
39
|
+
if (envelope?.rpcId !== rpcId || envelope?.result?.ok !== true) {
|
|
40
|
+
throw new Error(`${method}: ${envelope?.result?.error?.message ?? "invalid response"}`);
|
|
41
|
+
}
|
|
42
|
+
return envelope.result.value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function waitForIdle(sessionId) {
|
|
46
|
+
const deadline = Date.now() + timeoutMs;
|
|
47
|
+
while (Date.now() < deadline) {
|
|
48
|
+
const { items } = await rpc("session.list", {});
|
|
49
|
+
const session = items.find((item) => item.sessionId === sessionId);
|
|
50
|
+
if (session === undefined) throw new Error(`session ${sessionId} disappeared`);
|
|
51
|
+
if (!session.blank && !session.running) return;
|
|
52
|
+
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`session ${sessionId} did not finish within ${timeoutMs}ms`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function contentBlocks(value, output = []) {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
for (const item of value) contentBlocks(item, output);
|
|
60
|
+
} else if (value !== null && typeof value === "object") {
|
|
61
|
+
if (typeof value.type === "string" && ["tool-call", "tool-result"].includes(value.type)) output.push(value);
|
|
62
|
+
for (const child of Object.values(value)) contentBlocks(child, output);
|
|
63
|
+
}
|
|
64
|
+
return output;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function runSmoke(testCase) {
|
|
68
|
+
const created = await rpc("session.create", { cwd: process.cwd() });
|
|
69
|
+
const sessionId = created.sessionId;
|
|
70
|
+
let selected = false;
|
|
71
|
+
let failure;
|
|
72
|
+
try {
|
|
73
|
+
await rpc("session.selectModel", {
|
|
74
|
+
sessionId,
|
|
75
|
+
provider: testCase.route,
|
|
76
|
+
model: testCase.model,
|
|
77
|
+
reasoningEffort: "low",
|
|
78
|
+
});
|
|
79
|
+
selected = true;
|
|
80
|
+
await rpc("session.prompt", {
|
|
81
|
+
sessionId,
|
|
82
|
+
mode: "queue",
|
|
83
|
+
clientTimeZone: "UTC",
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
text: `Automated OAuth smoke test. You MUST call the glob tool exactly once with pattern "package.json" in the current workspace. After receiving the tool result, reply with exactly ${testCase.marker} and no other text.`,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
await waitForIdle(sessionId);
|
|
92
|
+
const history = await rpc("session.history", { sessionId, maxMessages: 200 });
|
|
93
|
+
const serialized = JSON.stringify(history.events);
|
|
94
|
+
const blocks = contentBlocks(history.events);
|
|
95
|
+
const toolCalls = blocks.filter((block) => block.type === "tool-call").length;
|
|
96
|
+
const toolResults = blocks.filter((block) => block.type === "tool-result").length;
|
|
97
|
+
const eventTypes = [...new Set(history.events.map((entry) => entry.event.type))];
|
|
98
|
+
const turnErrors = eventTypes.filter((type) => type.includes("error"));
|
|
99
|
+
if (!serialized.includes(testCase.marker)) throw new Error(`${testCase.route}: response marker missing`);
|
|
100
|
+
if (toolCalls === 0 || toolResults === 0) throw new Error(`${testCase.route}: tool-call round trip missing`);
|
|
101
|
+
if (turnErrors.length > 0) throw new Error(`${testCase.route}: error events: ${turnErrors.join(", ")}`);
|
|
102
|
+
|
|
103
|
+
const secondMarker = `${testCase.marker}_TURN2`;
|
|
104
|
+
await rpc("session.prompt", {
|
|
105
|
+
sessionId,
|
|
106
|
+
mode: "queue",
|
|
107
|
+
clientTimeZone: "UTC",
|
|
108
|
+
content: [
|
|
109
|
+
{ type: "text", text: `Second-turn replay test. Reply with exactly ${secondMarker} and no other text.` },
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
await waitForIdle(sessionId);
|
|
113
|
+
const secondHistory = await rpc("session.history", { sessionId, maxMessages: 200 });
|
|
114
|
+
const secondSerialized = JSON.stringify(secondHistory.events);
|
|
115
|
+
const secondEventTypes = [...new Set(secondHistory.events.map((entry) => entry.event.type))];
|
|
116
|
+
const secondTurnErrors = secondEventTypes.filter((type) => type.includes("error"));
|
|
117
|
+
if (!secondSerialized.includes(secondMarker))
|
|
118
|
+
throw new Error(`${testCase.route}: second-turn response marker missing`);
|
|
119
|
+
if (secondTurnErrors.length > 0)
|
|
120
|
+
throw new Error(`${testCase.route}: second-turn error events: ${secondTurnErrors.join(", ")}`);
|
|
121
|
+
console.log(`${testCase.route}/${testCase.model}: twoTurns=yes toolCalls=${toolCalls} toolResults=${toolResults}`);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
failure = error;
|
|
124
|
+
} finally {
|
|
125
|
+
if (selected) {
|
|
126
|
+
try {
|
|
127
|
+
await rpc("session.selectModel", { sessionId, ...restoreSelection });
|
|
128
|
+
} catch (error) {
|
|
129
|
+
failure ??= new Error(
|
|
130
|
+
`${testCase.route}: failed to restore default model: ${error instanceof Error ? error.message : String(error)}`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
await rpc("workspace.archiveSession", { sessionId });
|
|
136
|
+
} catch (error) {
|
|
137
|
+
failure ??= new Error(
|
|
138
|
+
`${testCase.route}: failed to archive smoke session: ${error instanceof Error ? error.message : String(error)}`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (failure !== undefined) throw failure;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
for (const testCase of cases) await runSmoke(testCase);
|
|
146
|
+
console.log("Deployed Codex/Kimi OAuth inference and tool-call smoke passed.");
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
|
|
5
|
-
const base = new URL(process.env.DSH_WEB_URL ?? "http://127.0.0.1:3080");
|
|
6
|
-
const origin = base.origin;
|
|
7
|
-
|
|
8
|
-
async function jsonFetch(path, init = {}) {
|
|
9
|
-
const response = await fetch(new URL(path, base), {
|
|
10
|
-
...init,
|
|
11
|
-
headers: {
|
|
12
|
-
accept: "application/json",
|
|
13
|
-
origin,
|
|
14
|
-
...init.headers,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const value = await response.json().catch(() => undefined);
|
|
18
|
-
if (!response.ok) throw new Error(`${path}: HTTP ${response.status}`);
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function rpc(method, payload = {}) {
|
|
23
|
-
const rpcId = randomUUID();
|
|
24
|
-
const envelope = await jsonFetch(`/api/${method}`, {
|
|
25
|
-
method: "POST",
|
|
26
|
-
headers: { "content-type": "application/json" },
|
|
27
|
-
body: JSON.stringify({ type: "client-request", rpcId, method, payload }),
|
|
28
|
-
});
|
|
29
|
-
if (envelope?.rpcId !== rpcId || envelope?.result?.ok !== true) {
|
|
30
|
-
throw new Error(`${method} failed: ${JSON.stringify(envelope?.result?.error ?? envelope)}`);
|
|
31
|
-
}
|
|
32
|
-
return envelope.result.value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const status = await jsonFetch("/plugins/dsh-grok-build/oauth/status");
|
|
36
|
-
const catalog = await rpc("llm.models");
|
|
37
|
-
const registered = await rpc("llm.providers");
|
|
38
|
-
const groups = new Map(catalog.groups.map((group) => [group.id, group]));
|
|
39
|
-
const routes = [
|
|
40
|
-
["grok", "grok-build"],
|
|
41
|
-
["codex", "codex-oauth"],
|
|
42
|
-
["kimi", "kimi-code-oauth"],
|
|
43
|
-
["claude", "claude-code-oauth"],
|
|
44
|
-
];
|
|
45
|
-
const failures = [];
|
|
46
|
-
const report = [];
|
|
47
|
-
for (const [slug, route] of routes) {
|
|
48
|
-
const authenticated = status?.providers?.[slug]?.status === "signed-in";
|
|
49
|
-
const group = groups.get(route);
|
|
50
|
-
if (authenticated && group === undefined) failures.push(`${route}: authenticated but absent from model catalog`);
|
|
51
|
-
if (!authenticated && group !== undefined)
|
|
52
|
-
failures.push(`${route}: unauthenticated but still advertises ${group.models.length} model(s)`);
|
|
53
|
-
if (group !== undefined && !/\(OAuth\)$/u.test(group.name))
|
|
54
|
-
failures.push(`${route}: provider name lacks (OAuth): ${group.name}`);
|
|
55
|
-
report.push(
|
|
56
|
-
`${route}: ${authenticated ? "authenticated" : "unauthenticated"} → ${group === undefined ? "hidden" : `${group.models.length} model(s), ${group.name}`}`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const providerIds = new Set(registered.providers.map((provider) => provider.provider));
|
|
61
|
-
const preservedRoutes = ["openai", "xai", "kimi-coding"];
|
|
62
|
-
for (const route of preservedRoutes) {
|
|
63
|
-
if (!providerIds.has(route)) failures.push(`${route}: legacy API-key route is no longer registered`);
|
|
64
|
-
}
|
|
65
|
-
report.push(`preserved API-key routes: ${preservedRoutes.filter((route) => providerIds.has(route)).join(", ")}`);
|
|
66
|
-
|
|
67
|
-
const agyExpectation = process.env.DSH_EXPECT_AGY_AUTH ?? "signed-out";
|
|
68
|
-
if (!["signed-out", "signed-in", "auto"].includes(agyExpectation)) {
|
|
69
|
-
throw new Error("DSH_EXPECT_AGY_AUTH must be signed-out, signed-in, or auto");
|
|
70
|
-
}
|
|
71
|
-
const agy = groups.get("agy");
|
|
72
|
-
if (agyExpectation === "signed-out" && agy !== undefined)
|
|
73
|
-
failures.push(`agy: expected signed-out but advertises ${agy.models.length} model(s)`);
|
|
74
|
-
if (agyExpectation === "signed-in" && agy === undefined)
|
|
75
|
-
failures.push("agy: expected signed-in but absent from model catalog");
|
|
76
|
-
if (agy !== undefined && agy.name !== "Google Antigravity (OAuth)")
|
|
77
|
-
failures.push(`agy: provider name lacks OAuth label: ${agy.name}`);
|
|
78
|
-
report.push(`agy: ${agy === undefined ? "hidden" : `${agy.models.length} model(s), ${agy.name}`}`);
|
|
79
|
-
|
|
80
|
-
console.log(report.join("\n"));
|
|
81
|
-
if (failures.length > 0) {
|
|
82
|
-
console.error("\nDeployment verification failed:");
|
|
83
|
-
for (const failure of failures) console.error(`- ${failure}`);
|
|
84
|
-
process.exitCode = 1;
|
|
85
|
-
} else {
|
|
86
|
-
console.log("\nOAuth model catalog verification passed.");
|
|
87
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
const base = new URL(process.env.DSH_WEB_URL ?? "http://127.0.0.1:3080");
|
|
6
|
+
const origin = base.origin;
|
|
7
|
+
|
|
8
|
+
async function jsonFetch(path, init = {}) {
|
|
9
|
+
const response = await fetch(new URL(path, base), {
|
|
10
|
+
...init,
|
|
11
|
+
headers: {
|
|
12
|
+
accept: "application/json",
|
|
13
|
+
origin,
|
|
14
|
+
...init.headers,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const value = await response.json().catch(() => undefined);
|
|
18
|
+
if (!response.ok) throw new Error(`${path}: HTTP ${response.status}`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function rpc(method, payload = {}) {
|
|
23
|
+
const rpcId = randomUUID();
|
|
24
|
+
const envelope = await jsonFetch(`/api/${method}`, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: { "content-type": "application/json" },
|
|
27
|
+
body: JSON.stringify({ type: "client-request", rpcId, method, payload }),
|
|
28
|
+
});
|
|
29
|
+
if (envelope?.rpcId !== rpcId || envelope?.result?.ok !== true) {
|
|
30
|
+
throw new Error(`${method} failed: ${JSON.stringify(envelope?.result?.error ?? envelope)}`);
|
|
31
|
+
}
|
|
32
|
+
return envelope.result.value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const status = await jsonFetch("/plugins/dsh-grok-build/oauth/status");
|
|
36
|
+
const catalog = await rpc("llm.models");
|
|
37
|
+
const registered = await rpc("llm.providers");
|
|
38
|
+
const groups = new Map(catalog.groups.map((group) => [group.id, group]));
|
|
39
|
+
const routes = [
|
|
40
|
+
["grok", "grok-build"],
|
|
41
|
+
["codex", "codex-oauth"],
|
|
42
|
+
["kimi", "kimi-code-oauth"],
|
|
43
|
+
["claude", "claude-code-oauth"],
|
|
44
|
+
];
|
|
45
|
+
const failures = [];
|
|
46
|
+
const report = [];
|
|
47
|
+
for (const [slug, route] of routes) {
|
|
48
|
+
const authenticated = status?.providers?.[slug]?.status === "signed-in";
|
|
49
|
+
const group = groups.get(route);
|
|
50
|
+
if (authenticated && group === undefined) failures.push(`${route}: authenticated but absent from model catalog`);
|
|
51
|
+
if (!authenticated && group !== undefined)
|
|
52
|
+
failures.push(`${route}: unauthenticated but still advertises ${group.models.length} model(s)`);
|
|
53
|
+
if (group !== undefined && !/\(OAuth\)$/u.test(group.name))
|
|
54
|
+
failures.push(`${route}: provider name lacks (OAuth): ${group.name}`);
|
|
55
|
+
report.push(
|
|
56
|
+
`${route}: ${authenticated ? "authenticated" : "unauthenticated"} → ${group === undefined ? "hidden" : `${group.models.length} model(s), ${group.name}`}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const providerIds = new Set(registered.providers.map((provider) => provider.provider));
|
|
61
|
+
const preservedRoutes = ["openai", "xai", "kimi-coding"];
|
|
62
|
+
for (const route of preservedRoutes) {
|
|
63
|
+
if (!providerIds.has(route)) failures.push(`${route}: legacy API-key route is no longer registered`);
|
|
64
|
+
}
|
|
65
|
+
report.push(`preserved API-key routes: ${preservedRoutes.filter((route) => providerIds.has(route)).join(", ")}`);
|
|
66
|
+
|
|
67
|
+
const agyExpectation = process.env.DSH_EXPECT_AGY_AUTH ?? "signed-out";
|
|
68
|
+
if (!["signed-out", "signed-in", "auto"].includes(agyExpectation)) {
|
|
69
|
+
throw new Error("DSH_EXPECT_AGY_AUTH must be signed-out, signed-in, or auto");
|
|
70
|
+
}
|
|
71
|
+
const agy = groups.get("agy");
|
|
72
|
+
if (agyExpectation === "signed-out" && agy !== undefined)
|
|
73
|
+
failures.push(`agy: expected signed-out but advertises ${agy.models.length} model(s)`);
|
|
74
|
+
if (agyExpectation === "signed-in" && agy === undefined)
|
|
75
|
+
failures.push("agy: expected signed-in but absent from model catalog");
|
|
76
|
+
if (agy !== undefined && agy.name !== "Google Antigravity (OAuth)")
|
|
77
|
+
failures.push(`agy: provider name lacks OAuth label: ${agy.name}`);
|
|
78
|
+
report.push(`agy: ${agy === undefined ? "hidden" : `${agy.models.length} model(s), ${agy.name}`}`);
|
|
79
|
+
|
|
80
|
+
console.log(report.join("\n"));
|
|
81
|
+
if (failures.length > 0) {
|
|
82
|
+
console.error("\nDeployment verification failed:");
|
|
83
|
+
for (const failure of failures) console.error(`- ${failure}`);
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
} else {
|
|
86
|
+
console.log("\nOAuth model catalog verification passed.");
|
|
87
|
+
}
|