dsh-agy 0.1.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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/bin/dsh-agy.js +6 -0
- package/cordis.patch.yml +13 -0
- package/lib/blob-D1e7_uT1.mjs +63 -0
- package/lib/blob-D1e7_uT1.mjs.map +1 -0
- package/lib/cli/index.d.mts +10 -0
- package/lib/cli/index.d.mts.map +1 -0
- package/lib/cli/index.mjs +317 -0
- package/lib/cli/index.mjs.map +1 -0
- package/lib/exchange-MhFUiBAm.mjs +240 -0
- package/lib/exchange-MhFUiBAm.mjs.map +1 -0
- package/lib/import-DnKzgr-0.mjs +187 -0
- package/lib/import-DnKzgr-0.mjs.map +1 -0
- package/lib/index.d.mts +8 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +15 -0
- package/lib/index.mjs.map +1 -0
- package/lib/models-Cu1g7AXV.mjs +222 -0
- package/lib/models-Cu1g7AXV.mjs.map +1 -0
- package/lib/parse-CiEzD9d_.mjs +174 -0
- package/lib/parse-CiEzD9d_.mjs.map +1 -0
- package/lib/plugin-common-I56kmGjr.mjs +270 -0
- package/lib/plugin-common-I56kmGjr.mjs.map +1 -0
- package/lib/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/lib/session-tawi2_uh.mjs +1221 -0
- package/lib/session-tawi2_uh.mjs.map +1 -0
- package/lib/translate-h2bjH7ub.mjs +148 -0
- package/lib/translate-h2bjH7ub.mjs.map +1 -0
- package/lib/web/plugin.d.mts +8 -0
- package/lib/web/plugin.d.mts.map +1 -0
- package/lib/web/plugin.mjs +1618 -0
- package/lib/web/plugin.mjs.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { D as getAgyBootstrapUserAgent, b as AGY_ENDPOINT_FALLBACKS } from "./session-tawi2_uh.mjs";
|
|
3
|
+
//#region src/adapter/catalog.ts
|
|
4
|
+
const AGY_PUBLIC_MODELS = [
|
|
5
|
+
{
|
|
6
|
+
id: "gemini-3.6-flash-high",
|
|
7
|
+
name: "Gemini 3.6 Flash (High)",
|
|
8
|
+
contextLength: 1048576,
|
|
9
|
+
maxOutputTokens: 65536,
|
|
10
|
+
supportsReasoning: true,
|
|
11
|
+
supportsVision: true,
|
|
12
|
+
toolCalling: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "gemini-3.6-flash-medium",
|
|
16
|
+
name: "Gemini 3.6 Flash (Medium)",
|
|
17
|
+
contextLength: 1048576,
|
|
18
|
+
maxOutputTokens: 65536,
|
|
19
|
+
supportsReasoning: true,
|
|
20
|
+
supportsVision: true,
|
|
21
|
+
toolCalling: true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "gemini-3.6-flash-low",
|
|
25
|
+
name: "Gemini 3.6 Flash (Low)",
|
|
26
|
+
contextLength: 1048576,
|
|
27
|
+
maxOutputTokens: 65536,
|
|
28
|
+
supportsReasoning: true,
|
|
29
|
+
supportsVision: true,
|
|
30
|
+
toolCalling: true
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "claude-opus-4-6-thinking",
|
|
34
|
+
name: "Claude Opus 4.6 (Thinking)",
|
|
35
|
+
contextLength: 1048576,
|
|
36
|
+
maxOutputTokens: 65536,
|
|
37
|
+
supportsReasoning: true,
|
|
38
|
+
supportsVision: true,
|
|
39
|
+
toolCalling: true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "claude-sonnet-4-6",
|
|
43
|
+
name: "Claude Sonnet 4.6 (Thinking)",
|
|
44
|
+
contextLength: 1048576,
|
|
45
|
+
maxOutputTokens: 65536,
|
|
46
|
+
supportsReasoning: true,
|
|
47
|
+
supportsVision: true,
|
|
48
|
+
toolCalling: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "gemini-pro-agent",
|
|
52
|
+
name: "Gemini 3.1 Pro (High)",
|
|
53
|
+
contextLength: 1048576,
|
|
54
|
+
maxOutputTokens: 65535,
|
|
55
|
+
supportsReasoning: true,
|
|
56
|
+
supportsVision: true,
|
|
57
|
+
toolCalling: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "gemini-3.1-pro-low",
|
|
61
|
+
name: "Gemini 3.1 Pro (Low)",
|
|
62
|
+
contextLength: 1048576,
|
|
63
|
+
maxOutputTokens: 65535,
|
|
64
|
+
supportsReasoning: true,
|
|
65
|
+
supportsVision: true,
|
|
66
|
+
toolCalling: true
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "gemini-3-flash-agent",
|
|
70
|
+
name: "Gemini 3.5 Flash (High)",
|
|
71
|
+
contextLength: 1048576,
|
|
72
|
+
maxOutputTokens: 65536,
|
|
73
|
+
supportsReasoning: true,
|
|
74
|
+
supportsVision: true,
|
|
75
|
+
toolCalling: true
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "gemini-3.5-flash-low",
|
|
79
|
+
name: "Gemini 3.5 Flash (Medium)",
|
|
80
|
+
contextLength: 1048576,
|
|
81
|
+
maxOutputTokens: 65536,
|
|
82
|
+
supportsReasoning: true,
|
|
83
|
+
supportsVision: true,
|
|
84
|
+
toolCalling: true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "gemini-3.5-flash-extra-low",
|
|
88
|
+
name: "Gemini 3.5 Flash (Low)",
|
|
89
|
+
contextLength: 1048576,
|
|
90
|
+
maxOutputTokens: 65536,
|
|
91
|
+
supportsReasoning: true,
|
|
92
|
+
supportsVision: true,
|
|
93
|
+
toolCalling: true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "gemini-3.1-flash-lite",
|
|
97
|
+
name: "Gemini 3.1 Flash Lite",
|
|
98
|
+
contextLength: 1048576,
|
|
99
|
+
maxOutputTokens: 65535,
|
|
100
|
+
toolCalling: true
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "gemini-2.5-flash-thinking",
|
|
104
|
+
name: "Gemini 2.5 Flash Thinking",
|
|
105
|
+
contextLength: 1048576,
|
|
106
|
+
maxOutputTokens: 65535,
|
|
107
|
+
supportsReasoning: true,
|
|
108
|
+
toolCalling: true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "gemini-2.5-flash",
|
|
112
|
+
name: "Gemini 2.5 Flash",
|
|
113
|
+
contextLength: 1048576,
|
|
114
|
+
maxOutputTokens: 65535,
|
|
115
|
+
toolCalling: true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: "gemini-2.5-flash-lite",
|
|
119
|
+
name: "Gemini 2.5 Flash Lite",
|
|
120
|
+
contextLength: 1048576,
|
|
121
|
+
maxOutputTokens: 65535,
|
|
122
|
+
toolCalling: true
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "gpt-oss-120b-medium",
|
|
126
|
+
name: "GPT-OSS 120B (Medium)",
|
|
127
|
+
contextLength: 131072,
|
|
128
|
+
maxOutputTokens: 32768,
|
|
129
|
+
supportsReasoning: true,
|
|
130
|
+
toolCalling: true
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
const CATALOG_BY_ID = new Map(AGY_PUBLIC_MODELS.map((m) => [m.id, m]));
|
|
134
|
+
/** Tab-completion models are discoverable but not chat-callable. */
|
|
135
|
+
function isChatCallableModelId(modelId) {
|
|
136
|
+
return !modelId.startsWith("tab_");
|
|
137
|
+
}
|
|
138
|
+
function catalogModel(modelId) {
|
|
139
|
+
return CATALOG_BY_ID.get(modelId);
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/adapter/models.ts
|
|
143
|
+
var models_exports = /* @__PURE__ */ __exportAll({
|
|
144
|
+
AGY_PROVIDER: () => "agy",
|
|
145
|
+
catalogModelList: () => catalogModelList,
|
|
146
|
+
fetchAvailableModels: () => fetchAvailableModels,
|
|
147
|
+
listAgyModels: () => listAgyModels,
|
|
148
|
+
mergeModelCatalog: () => mergeModelCatalog,
|
|
149
|
+
resolveAgyModel: () => resolveAgyModel
|
|
150
|
+
});
|
|
151
|
+
/** Fetch the account's available models from the first reachable endpoint. */
|
|
152
|
+
async function fetchAvailableModels(accessToken, projectId, fetchImpl = fetch) {
|
|
153
|
+
let lastError = null;
|
|
154
|
+
const body = projectId ? { project: projectId } : {};
|
|
155
|
+
for (const baseEndpoint of AGY_ENDPOINT_FALLBACKS) try {
|
|
156
|
+
const response = await fetchImpl(`${baseEndpoint}/v1internal:fetchAvailableModels`, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
headers: {
|
|
159
|
+
Authorization: `Bearer ${accessToken}`,
|
|
160
|
+
"Content-Type": "application/json",
|
|
161
|
+
"User-Agent": getAgyBootstrapUserAgent()
|
|
162
|
+
},
|
|
163
|
+
body: JSON.stringify(body)
|
|
164
|
+
});
|
|
165
|
+
if (response.ok) return await response.json();
|
|
166
|
+
lastError = /* @__PURE__ */ new Error(`fetchAvailableModels ${response.status} at ${baseEndpoint}`);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
lastError = error;
|
|
169
|
+
}
|
|
170
|
+
throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error("fetchAvailableModels: all endpoints failed");
|
|
171
|
+
}
|
|
172
|
+
/** Merge dynamic ids with catalog metadata; non-chat models and unknowns keep minimal info. */
|
|
173
|
+
function mergeModelCatalog(dynamic) {
|
|
174
|
+
const entries = [];
|
|
175
|
+
for (const [id, entry] of Object.entries(dynamic.models ?? {})) {
|
|
176
|
+
if (!isChatCallableModelId(id)) continue;
|
|
177
|
+
const meta = catalogModel(id);
|
|
178
|
+
entries.push({
|
|
179
|
+
provider: "agy",
|
|
180
|
+
id,
|
|
181
|
+
name: entry.displayName ?? meta?.name ?? entry.modelName ?? id,
|
|
182
|
+
...meta ? { context: { contextWindow: meta.contextLength } } : {}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return entries;
|
|
186
|
+
}
|
|
187
|
+
/** Catalog-only model list used when the endpoint is unreachable. */
|
|
188
|
+
function catalogModelList() {
|
|
189
|
+
return AGY_PUBLIC_MODELS.map((model) => ({
|
|
190
|
+
provider: "agy",
|
|
191
|
+
id: model.id,
|
|
192
|
+
name: model.name,
|
|
193
|
+
context: { contextWindow: model.contextLength }
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
/** Adapter-facing listing: dynamic first, catalog fallback. */
|
|
197
|
+
async function listAgyModels(accessToken, projectId, fetchImpl = fetch) {
|
|
198
|
+
if (!accessToken) return catalogModelList();
|
|
199
|
+
try {
|
|
200
|
+
const merged = mergeModelCatalog(await fetchAvailableModels(accessToken, projectId, fetchImpl));
|
|
201
|
+
return merged.length > 0 ? merged : catalogModelList();
|
|
202
|
+
} catch {
|
|
203
|
+
return catalogModelList();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Resolve one exact model's metadata (catalog-backed; dynamic ids pass through). */
|
|
207
|
+
function resolveAgyModel(provider, model) {
|
|
208
|
+
const meta = catalogModel(model);
|
|
209
|
+
return {
|
|
210
|
+
provider,
|
|
211
|
+
id: model,
|
|
212
|
+
name: meta?.name ?? model,
|
|
213
|
+
...meta ? {
|
|
214
|
+
context: { contextWindow: meta.contextLength },
|
|
215
|
+
defaultMaxTokens: meta.maxOutputTokens
|
|
216
|
+
} : {}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
export { models_exports as n, resolveAgyModel as r, listAgyModels as t };
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=models-Cu1g7AXV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models-Cu1g7AXV.mjs","names":[],"sources":["../src/adapter/catalog.ts","../src/adapter/models.ts"],"sourcesContent":["/**\n * Pinned agy model catalog (metadata only — dynamic discovery is primary).\n *\n * Adapted from OmniRoute's `AGY_PUBLIC_MODELS` (MIT, see NOTICE.md), which was\n * pinned from the live `v1internal:fetchAvailableModels` endpoint. The dynamic\n * endpoint supplies ids + quotaInfo; this catalog supplies the capability\n * metadata the endpoint omits (context length, output cap, reasoning/vision/\n * tool-calling). Tab-completion models are intentionally excluded.\n */\n\nexport interface CatalogModel {\n id: string\n name: string\n contextLength: number\n maxOutputTokens: number\n supportsReasoning?: boolean\n supportsVision?: boolean\n toolCalling?: boolean\n}\n\nexport const AGY_PUBLIC_MODELS: readonly CatalogModel[] = [\n { id: 'gemini-3.6-flash-high', name: 'Gemini 3.6 Flash (High)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.6-flash-medium', name: 'Gemini 3.6 Flash (Medium)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.6-flash-low', name: 'Gemini 3.6 Flash (Low)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'claude-opus-4-6-thinking', name: 'Claude Opus 4.6 (Thinking)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6 (Thinking)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-pro-agent', name: 'Gemini 3.1 Pro (High)', contextLength: 1048576, maxOutputTokens: 65535, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.1-pro-low', name: 'Gemini 3.1 Pro (Low)', contextLength: 1048576, maxOutputTokens: 65535, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3-flash-agent', name: 'Gemini 3.5 Flash (High)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.5-flash-low', name: 'Gemini 3.5 Flash (Medium)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.5-flash-extra-low', name: 'Gemini 3.5 Flash (Low)', contextLength: 1048576, maxOutputTokens: 65536, supportsReasoning: true, supportsVision: true, toolCalling: true },\n { id: 'gemini-3.1-flash-lite', name: 'Gemini 3.1 Flash Lite', contextLength: 1048576, maxOutputTokens: 65535, toolCalling: true },\n { id: 'gemini-2.5-flash-thinking', name: 'Gemini 2.5 Flash Thinking', contextLength: 1048576, maxOutputTokens: 65535, supportsReasoning: true, toolCalling: true },\n { id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', contextLength: 1048576, maxOutputTokens: 65535, toolCalling: true },\n { id: 'gemini-2.5-flash-lite', name: 'Gemini 2.5 Flash Lite', contextLength: 1048576, maxOutputTokens: 65535, toolCalling: true },\n { id: 'gpt-oss-120b-medium', name: 'GPT-OSS 120B (Medium)', contextLength: 131072, maxOutputTokens: 32768, supportsReasoning: true, toolCalling: true },\n]\n\nconst CATALOG_BY_ID = new Map(AGY_PUBLIC_MODELS.map((m) => [m.id, m]))\n\n/** Tab-completion models are discoverable but not chat-callable. */\nexport function isChatCallableModelId(modelId: string): boolean {\n return !modelId.startsWith('tab_')\n}\n\nexport function catalogModel(modelId: string): CatalogModel | undefined {\n return CATALOG_BY_ID.get(modelId)\n}\n","/**\n * Model discovery: dynamic `v1internal:fetchAvailableModels` as the primary\n * source (fresh ids + per-model quotaInfo), the pinned catalog merged in for\n * capability metadata, and catalog fallback when the endpoint is unreachable.\n */\n\nimport type { LlmModelInfo, LlmResolvedModelInfo } from '@deepseek-ai/dsh-llm'\nimport { AGY_ENDPOINT_FALLBACKS, getAgyBootstrapUserAgent } from '../oauth/constants.ts'\nimport { AGY_PUBLIC_MODELS, catalogModel, isChatCallableModelId } from './catalog.ts'\n\nexport const AGY_PROVIDER = 'agy'\n\nexport interface DiscoveredModelEntry {\n quotaInfo?: {\n remainingFraction?: number\n resetTime?: string\n }\n displayName?: string\n modelName?: string\n}\n\nexport interface DiscoveredModels {\n models?: Record<string, DiscoveredModelEntry>\n}\n\n/** Fetch the account's available models from the first reachable endpoint. */\nexport async function fetchAvailableModels(\n accessToken: string,\n projectId?: string,\n fetchImpl: typeof fetch = fetch,\n): Promise<DiscoveredModels> {\n let lastError: unknown = null\n const body = projectId ? { project: projectId } : {}\n for (const baseEndpoint of AGY_ENDPOINT_FALLBACKS) {\n try {\n const response = await fetchImpl(`${baseEndpoint}/v1internal:fetchAvailableModels`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'User-Agent': getAgyBootstrapUserAgent(),\n },\n body: JSON.stringify(body),\n })\n if (response.ok) {\n return (await response.json()) as DiscoveredModels\n }\n lastError = new Error(`fetchAvailableModels ${response.status} at ${baseEndpoint}`)\n } catch (error) {\n lastError = error\n }\n }\n throw lastError instanceof Error ? lastError : new Error('fetchAvailableModels: all endpoints failed')\n}\n\n/** Merge dynamic ids with catalog metadata; non-chat models and unknowns keep minimal info. */\nexport function mergeModelCatalog(dynamic: DiscoveredModels): LlmModelInfo[] {\n const entries: LlmModelInfo[] = []\n for (const [id, entry] of Object.entries(dynamic.models ?? {})) {\n if (!isChatCallableModelId(id)) continue\n const meta = catalogModel(id)\n entries.push({\n provider: AGY_PROVIDER,\n id,\n name: entry.displayName ?? meta?.name ?? entry.modelName ?? id,\n ...(meta ? { context: { contextWindow: meta.contextLength } } : {}),\n })\n }\n return entries\n}\n\n/** Catalog-only model list used when the endpoint is unreachable. */\nexport function catalogModelList(): LlmModelInfo[] {\n return AGY_PUBLIC_MODELS.map((model) => ({\n provider: AGY_PROVIDER,\n id: model.id,\n name: model.name,\n context: { contextWindow: model.contextLength },\n }))\n}\n\n/** Adapter-facing listing: dynamic first, catalog fallback. */\nexport async function listAgyModels(\n accessToken: string | undefined,\n projectId: string | undefined,\n fetchImpl: typeof fetch = fetch,\n): Promise<readonly LlmModelInfo[]> {\n if (!accessToken) return catalogModelList()\n try {\n const dynamic = await fetchAvailableModels(accessToken, projectId, fetchImpl)\n const merged = mergeModelCatalog(dynamic)\n return merged.length > 0 ? merged : catalogModelList()\n } catch {\n return catalogModelList()\n }\n}\n\n/** Resolve one exact model's metadata (catalog-backed; dynamic ids pass through). */\nexport function resolveAgyModel(provider: string, model: string): LlmResolvedModelInfo {\n const meta = catalogModel(model)\n return {\n provider,\n id: model,\n name: meta?.name ?? model,\n ...(meta ? { context: { contextWindow: meta.contextLength }, defaultMaxTokens: meta.maxOutputTokens } : {}),\n }\n}\n"],"mappings":";;;AAoBA,MAAa,oBAA6C;CACxD;EAAE,IAAI;EAAyB,MAAM;EAA2B,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CACjL;EAAE,IAAI;EAA2B,MAAM;EAA6B,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CACrL;EAAE,IAAI;EAAwB,MAAM;EAA0B,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CAC/K;EAAE,IAAI;EAA4B,MAAM;EAA8B,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CACvL;EAAE,IAAI;EAAqB,MAAM;EAAgC,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CAClL;EAAE,IAAI;EAAoB,MAAM;EAAyB,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CAC1K;EAAE,IAAI;EAAsB,MAAM;EAAwB,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK;CAC3K;EAAE,IAAI;EAAwB,MAAM;EAA2B,eAAe;EAAS,iBAAiB;EAAO,mBAAmB;EAAM,gBAAgB;EAAM,aAAa;CAAK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|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { CallId } from "@deepseek-ai/dsh-llm";
|
|
3
|
+
//#region src/adapter/parse.ts
|
|
4
|
+
var parse_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
parseAgySse: () => parseAgySse,
|
|
6
|
+
parseSseDataLine: () => parseSseDataLine
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Parse one SSE `data:` line; returns null for `[DONE]` or empty lines.
|
|
10
|
+
* Accepts the `{"response": {...}}` envelope (daily endpoint wire shape) and
|
|
11
|
+
* the bare array/object shapes older clients emitted.
|
|
12
|
+
*/
|
|
13
|
+
function parseSseDataLine(line) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
if (!trimmed.startsWith("data:")) return null;
|
|
16
|
+
const data = trimmed.slice(5).trim();
|
|
17
|
+
if (data === "" || data === "[DONE]") return null;
|
|
18
|
+
const parsed = JSON.parse(data);
|
|
19
|
+
const root = parsed?.response ?? parsed;
|
|
20
|
+
return (Array.isArray(root) ? root[0] : root) ?? null;
|
|
21
|
+
}
|
|
22
|
+
function mapFinishReason(reason) {
|
|
23
|
+
switch (reason) {
|
|
24
|
+
case "MAX_TOKENS": return { kind: "max-tokens" };
|
|
25
|
+
case "STOP": return { kind: "stop" };
|
|
26
|
+
case "TOOL_CALLS":
|
|
27
|
+
case "FUNCTION_CALL": return { kind: "tool-calls" };
|
|
28
|
+
default: return { kind: "stop" };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function* parseAgySse(body, options = {}) {
|
|
32
|
+
const { signal } = options;
|
|
33
|
+
const reader = body.getReader();
|
|
34
|
+
const decoder = new TextDecoder();
|
|
35
|
+
let buffer = "";
|
|
36
|
+
let blockIndex = 0;
|
|
37
|
+
let finishReason = { kind: "stop" };
|
|
38
|
+
let sawUsage = false;
|
|
39
|
+
let lastUsage = null;
|
|
40
|
+
let open = null;
|
|
41
|
+
const closeBlock = () => {
|
|
42
|
+
if (!open) return null;
|
|
43
|
+
const block = open.kind === "tool-call" ? {
|
|
44
|
+
type: "block-end",
|
|
45
|
+
index: blockIndex,
|
|
46
|
+
block: {
|
|
47
|
+
type: "tool-call",
|
|
48
|
+
id: CallId(open.id ?? `call-${blockIndex}`),
|
|
49
|
+
name: open.name ?? "",
|
|
50
|
+
arguments: open.arguments
|
|
51
|
+
}
|
|
52
|
+
} : {
|
|
53
|
+
type: "block-end",
|
|
54
|
+
index: blockIndex,
|
|
55
|
+
block: {
|
|
56
|
+
type: open.kind,
|
|
57
|
+
text: open.text
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
open = null;
|
|
61
|
+
blockIndex += 1;
|
|
62
|
+
return block;
|
|
63
|
+
};
|
|
64
|
+
const ensureBlock = (kind, meta = {}) => {
|
|
65
|
+
if (open && open.kind !== kind) closeBlock();
|
|
66
|
+
if (!open) {
|
|
67
|
+
open = {
|
|
68
|
+
kind,
|
|
69
|
+
arguments: "",
|
|
70
|
+
text: "",
|
|
71
|
+
id: meta.id,
|
|
72
|
+
name: meta.name
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
type: "block-start",
|
|
76
|
+
index: blockIndex,
|
|
77
|
+
blockType: kind === "tool-call" ? "tool-call" : kind
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
while (true) {
|
|
84
|
+
if (signal?.aborted) throw new DOMException("aborted", "AbortError");
|
|
85
|
+
const { done, value } = await reader.read();
|
|
86
|
+
if (done) break;
|
|
87
|
+
buffer += decoder.decode(value, { stream: true });
|
|
88
|
+
let newlineIndex;
|
|
89
|
+
while ((newlineIndex = buffer.indexOf("\n")) !== -1) {
|
|
90
|
+
const line = buffer.slice(0, newlineIndex);
|
|
91
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
92
|
+
if (!line.startsWith("data:")) continue;
|
|
93
|
+
const payload = parseSseDataLine(line);
|
|
94
|
+
if (!payload) continue;
|
|
95
|
+
if (payload.error) {
|
|
96
|
+
const message = payload.error.message ?? payload.error.status ?? "upstream error";
|
|
97
|
+
throw new Error(`agy stream error (${payload.error.code ?? "unknown"}): ${message}`);
|
|
98
|
+
}
|
|
99
|
+
for (const candidate of payload.candidates ?? []) {
|
|
100
|
+
if (candidate.finishReason) finishReason = mapFinishReason(candidate.finishReason);
|
|
101
|
+
for (const part of candidate.content?.parts ?? []) if (part.text !== void 0 && part.thought !== true) {
|
|
102
|
+
const start = ensureBlock("text");
|
|
103
|
+
if (start) yield start;
|
|
104
|
+
open.text += part.text;
|
|
105
|
+
yield {
|
|
106
|
+
type: "text-delta",
|
|
107
|
+
index: blockIndex,
|
|
108
|
+
text: part.text
|
|
109
|
+
};
|
|
110
|
+
} else if (part.text !== void 0 && part.thought === true) {
|
|
111
|
+
const start = ensureBlock("reasoning");
|
|
112
|
+
if (start) yield start;
|
|
113
|
+
open.text += part.text;
|
|
114
|
+
yield {
|
|
115
|
+
type: "reasoning-delta",
|
|
116
|
+
index: blockIndex,
|
|
117
|
+
text: part.text
|
|
118
|
+
};
|
|
119
|
+
} else if (part.functionCall) {
|
|
120
|
+
const upstreamId = part.functionCall.id || String(blockIndex);
|
|
121
|
+
const start = ensureBlock("tool-call", {
|
|
122
|
+
id: upstreamId,
|
|
123
|
+
name: part.functionCall.name
|
|
124
|
+
});
|
|
125
|
+
if (start) yield start;
|
|
126
|
+
if (part.thoughtSignature) options.onToolSignature?.(upstreamId, part.thoughtSignature);
|
|
127
|
+
const argsJson = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify(part.functionCall.args ?? {});
|
|
128
|
+
open.arguments += argsJson;
|
|
129
|
+
yield {
|
|
130
|
+
type: "tool-call-delta",
|
|
131
|
+
index: blockIndex,
|
|
132
|
+
id: CallId(open.id ?? ""),
|
|
133
|
+
name: open.name,
|
|
134
|
+
argumentsDelta: argsJson
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (payload.usageMetadata) {
|
|
139
|
+
sawUsage = true;
|
|
140
|
+
const promptTokens = payload.usageMetadata.promptTokenCount ?? 0;
|
|
141
|
+
const cachedTokens = payload.usageMetadata.cachedContentTokenCount ?? 0;
|
|
142
|
+
lastUsage = {
|
|
143
|
+
inputTokens: Math.max(0, promptTokens - cachedTokens),
|
|
144
|
+
outputTokens: payload.usageMetadata.candidatesTokenCount ?? 0,
|
|
145
|
+
cacheReadTokens: cachedTokens
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const closed = closeBlock();
|
|
151
|
+
if (closed) yield closed;
|
|
152
|
+
if (lastUsage) yield {
|
|
153
|
+
type: "usage",
|
|
154
|
+
usage: lastUsage
|
|
155
|
+
};
|
|
156
|
+
else if (sawUsage) yield {
|
|
157
|
+
type: "usage",
|
|
158
|
+
usage: {
|
|
159
|
+
inputTokens: 0,
|
|
160
|
+
outputTokens: 0
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
yield {
|
|
164
|
+
type: "finish",
|
|
165
|
+
reason: finishReason
|
|
166
|
+
};
|
|
167
|
+
} finally {
|
|
168
|
+
reader.releaseLock();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { parse_exports as n, parseAgySse as t };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=parse-CiEzD9d_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-CiEzD9d_.mjs","names":[],"sources":["../src/adapter/parse.ts"],"sourcesContent":["/**\n * Parse Antigravity SSE responses (Gemini-style `candidates[]` events) into the\n * DSH StreamChunk protocol: block-start / text-delta / reasoning-delta /\n * tool-call-delta / block-end / usage / finish.\n *\n * Wire shape: each `data:` payload is a JSON array of candidate objects with\n * `content.parts[]` (text / {thought:true} / functionCall), `usageMetadata`,\n * and `finishReason`. Streams terminate with `data: [DONE]`.\n */\n\nimport type { FinishReason, StreamChunk } from '@deepseek-ai/dsh-llm'\nimport { CallId } from '@deepseek-ai/dsh-llm'\n\nexport interface SsePart {\n text?: string\n thought?: boolean\n thoughtSignature?: string\n functionCall?: { id?: string; name?: string; args?: unknown }\n}\n\nexport interface SseCandidate {\n index?: number\n content?: {\n role?: string\n parts?: SsePart[]\n }\n finishReason?: string\n}\n\nexport interface SsePayload {\n candidates?: SseCandidate[]\n usageMetadata?: {\n promptTokenCount?: number\n candidatesTokenCount?: number\n totalTokenCount?: number\n cachedContentTokenCount?: number\n }\n error?: { code?: number; status?: string; message?: string }\n}\n\n/**\n * Parse one SSE `data:` line; returns null for `[DONE]` or empty lines.\n * Accepts the `{\"response\": {...}}` envelope (daily endpoint wire shape) and\n * the bare array/object shapes older clients emitted.\n */\nexport function parseSseDataLine(line: string): SsePayload | null {\n const trimmed = line.trim()\n if (!trimmed.startsWith('data:')) return null\n const data = trimmed.slice(5).trim()\n if (data === '' || data === '[DONE]') return null\n const parsed = JSON.parse(data) as unknown\n const root = (parsed as { response?: unknown })?.response ?? parsed\n const payload = (Array.isArray(root) ? root[0] : root) as SsePayload | undefined\n return payload ?? null\n}\n\nfunction mapFinishReason(reason: string | undefined): FinishReason {\n switch (reason) {\n case 'MAX_TOKENS':\n return { kind: 'max-tokens' }\n case 'STOP':\n return { kind: 'stop' }\n case 'TOOL_CALLS':\n case 'FUNCTION_CALL':\n return { kind: 'tool-calls' }\n default:\n return { kind: 'stop' }\n }\n}\n\n/**\n * Consume an SSE text stream and yield StreamChunks. One accumulating block is\n * kept open at a time; tool-call argument deltas accumulate until a different\n * part kind, usage metadata, or stream end closes it.\n */\nexport interface ParseAgySseOptions {\n signal?: AbortSignal\n /**\n * Invoked when a functionCall part carries a sibling thoughtSignature, and\n * when a thought part carries one, keyed by the functionCall id (or the\n * thought signature is ignored unless paired). The adapter persists these\n * for replay on the next turn (see signature-cache.ts).\n */\n onToolSignature?(toolCallId: string, signature: string): void\n}\n\nexport async function* parseAgySse(\n body: ReadableStream<Uint8Array>,\n options: ParseAgySseOptions = {},\n): AsyncGenerator<StreamChunk> {\n const { signal } = options\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let blockIndex = 0\n let finishReason: FinishReason = { kind: 'stop' }\n let sawUsage = false\n let lastUsage: { inputTokens: number; outputTokens: number; cacheReadTokens?: number } | null = null\n\n interface OpenBlock {\n kind: 'text' | 'reasoning' | 'tool-call'\n id?: string\n name?: string\n arguments: string\n text: string\n }\n let open: OpenBlock | null = null\n\n const closeBlock = (): StreamChunk | null => {\n if (!open) return null\n const block: StreamChunk = open.kind === 'tool-call'\n ? {\n type: 'block-end',\n index: blockIndex,\n block: {\n type: 'tool-call',\n id: CallId(open.id ?? `call-${blockIndex}`),\n name: open.name ?? '',\n arguments: open.arguments,\n },\n }\n : {\n type: 'block-end',\n index: blockIndex,\n block: { type: open.kind, text: open.text },\n }\n open = null\n blockIndex += 1\n return block\n }\n\n const ensureBlock = (kind: OpenBlock['kind'], meta: { id?: string; name?: string } = {}): StreamChunk | null => {\n if (open && open.kind !== kind) {\n void closeBlock()\n }\n if (!open) {\n open = { kind, arguments: '', text: '', id: meta.id, name: meta.name }\n const blockType = kind === 'tool-call' ? 'tool-call' : kind\n return { type: 'block-start', index: blockIndex, blockType }\n }\n return null\n }\n\n try {\n while (true) {\n if (signal?.aborted) {\n throw new DOMException('aborted', 'AbortError')\n }\n const { done, value } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let newlineIndex: number\n while ((newlineIndex = buffer.indexOf('\\n')) !== -1) {\n const line = buffer.slice(0, newlineIndex)\n buffer = buffer.slice(newlineIndex + 1)\n if (!line.startsWith('data:')) continue\n const payload = parseSseDataLine(line)\n if (!payload) continue\n if (payload.error) {\n const message = payload.error.message ?? payload.error.status ?? 'upstream error'\n throw new Error(`agy stream error (${payload.error.code ?? 'unknown'}): ${message}`)\n }\n for (const candidate of payload.candidates ?? []) {\n if (candidate.finishReason) {\n finishReason = mapFinishReason(candidate.finishReason)\n }\n for (const part of candidate.content?.parts ?? []) {\n if (part.text !== undefined && part.thought !== true) {\n const start = ensureBlock('text')\n if (start) yield start\n open!.text += part.text\n yield { type: 'text-delta', index: blockIndex, text: part.text }\n } else if (part.text !== undefined && part.thought === true) {\n const start = ensureBlock('reasoning')\n if (start) yield start\n open!.text += part.text\n yield { type: 'reasoning-delta', index: blockIndex, text: part.text }\n } else if (part.functionCall) {\n // Use the upstream functionCall id when present so the signature\n // captured on this part can be replayed for the same id next turn.\n const upstreamId = part.functionCall.id || String(blockIndex)\n const start = ensureBlock('tool-call', {\n id: upstreamId,\n name: part.functionCall.name,\n })\n if (start) yield start\n if (part.thoughtSignature) {\n options.onToolSignature?.(upstreamId, part.thoughtSignature)\n }\n const argsJson = typeof part.functionCall.args === 'string'\n ? part.functionCall.args\n : JSON.stringify(part.functionCall.args ?? {})\n open!.arguments += argsJson\n yield {\n type: 'tool-call-delta',\n index: blockIndex,\n id: CallId(open!.id ?? ''),\n name: open!.name,\n argumentsDelta: argsJson,\n }\n }\n }\n }\n if (payload.usageMetadata) {\n // The upstream sends usageMetadata on EVERY SSE event (cumulative).\n // Do NOT close the block here: closing per event would split one\n // continuous text stream into a block per chunk (frontend renders\n // block boundaries as line breaks). Stash the last (full) totals\n // and emit one usage chunk at stream end.\n sawUsage = true\n // DSH TokenUsage buckets are DISJOINT: inputTokens must be the\n // uncached portion only; cache reads are reported separately.\n // Reporting the full promptTokenCount here double-counts cached\n // tokens in the stats line's cache-hit percentage (it divides by\n // uncached + cacheRead + cacheWrite).\n const promptTokens = payload.usageMetadata.promptTokenCount ?? 0\n const cachedTokens = payload.usageMetadata.cachedContentTokenCount ?? 0\n lastUsage = {\n inputTokens: Math.max(0, promptTokens - cachedTokens),\n outputTokens: payload.usageMetadata.candidatesTokenCount ?? 0,\n cacheReadTokens: cachedTokens,\n }\n }\n }\n }\n const closed = closeBlock()\n if (closed) yield closed\n if (lastUsage) {\n yield { type: 'usage', usage: lastUsage }\n } else if (sawUsage) {\n yield { type: 'usage', usage: { inputTokens: 0, outputTokens: 0 } }\n }\n yield { type: 'finish', reason: finishReason }\n } finally {\n reader.releaseLock()\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,SAAgB,iBAAiB,MAAiC;CAChE,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,QAAQ,WAAW,OAAO,GAAG,OAAO;CACzC,MAAM,OAAO,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK;CACnC,IAAI,SAAS,MAAM,SAAS,UAAU,OAAO;CAC7C,MAAM,SAAS,KAAK,MAAM,IAAI;CAC9B,MAAM,OAAQ,QAAmC,YAAY;CAE7D,QADiB,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,SAC/B;AACpB;AAEA,SAAS,gBAAgB,QAA0C;CACjE,QAAQ,QAAR;EACE,KAAK,cACH,OAAO,EAAE,MAAM,aAAa;EAC9B,KAAK,QACH,OAAO,EAAE,MAAM,OAAO;EACxB,KAAK;EACL,KAAK,iBACH,OAAO,EAAE,MAAM,aAAa;EAC9B,SACE,OAAO,EAAE,MAAM,OAAO;CAC1B;AACF;AAkBA,gBAAuB,YACrB,MACA,UAA8B,CAAC,GACF;CAC7B,MAAM,EAAE,WAAW;CACnB,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,UAAU,IAAI,YAAY;CAChC,IAAI,SAAS;CACb,IAAI,aAAa;CACjB,IAAI,eAA6B,EAAE,MAAM,OAAO;CAChD,IAAI,WAAW;CACf,IAAI,YAA4F;CAShG,IAAI,OAAyB;CAE7B,MAAM,mBAAuC;EAC3C,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,QAAqB,KAAK,SAAS,cACrC;GACE,MAAM;GACN,OAAO;GACP,OAAO;IACL,MAAM;IACN,IAAI,OAAO,KAAK,MAAM,QAAQ,YAAY;IAC1C,MAAM,KAAK,QAAQ;IACnB,WAAW,KAAK;GAClB;EACF,IACA;GAC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