@xiaoso/dsh-tool-plus 0.1.5 → 0.1.7-beta.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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +9 -3
- package/lib/{abort-Cwwm4Err.mjs → abort-Caqff3M6.mjs} +2 -2
- package/lib/alibaba-coding-plan-DTupMiAi.mjs +73 -0
- package/lib/alibaba-token-plan-CHGyWOfX.mjs +46 -0
- package/lib/alibaba-token-plan-Dj3OZhEE.mjs +82 -0
- package/lib/{amazon-bedrock-TVMpUTRG.mjs → amazon-bedrock-DbFSYXfJ.mjs} +117 -38
- package/lib/{anthropic-BL6LFDQS.mjs → anthropic-CTJ3IQVa.mjs} +675 -166
- package/lib/anthropic-CXfWlp-x.mjs +105 -0
- package/lib/{aws-credentials-B20dliS7.mjs → anthropic-wire-CKuhDwZ1.mjs} +74 -14
- package/lib/{api-key-login-CIDnXeYd.mjs → api-key-validation-CGCJFbFr.mjs} +27 -68
- package/lib/{azure-openai-responses-BkhsLmN3.mjs → azure-openai-responses-ChFbWaGj.mjs} +27 -16
- package/lib/{browser-render-CmgvSNte.mjs → browser-render-9o0Rknop.mjs} +4 -4
- package/lib/bun-shim.mjs +71 -2
- package/lib/{bundled-references-ChZSPDFw.mjs → bundled-references-DY3EJxZV.mjs} +6 -5
- package/lib/cline-pass-Bwg3esu9.mjs +44 -0
- package/lib/cloudflare-ai-gateway-BupNXyKK.mjs +35 -0
- package/lib/cloudflare-ai-gateway-EWo0VkP5.mjs +44 -0
- package/lib/collapse-DOR8sOGf.mjs +2304 -0
- package/lib/coreweave-C82HrLpb.mjs +31 -0
- package/lib/coreweave-Ct8cF-da.mjs +14 -0
- package/lib/{cursor-B6HcmplF.mjs → cursor-B95LzVWV.mjs} +11 -3
- package/lib/{cursor-CRpLpaZ3.mjs → cursor-DJV_dcgB.mjs} +887 -1784
- package/lib/{cursor-B8m6SqAH.mjs → cursor-LKGjucn2.mjs} +48 -38
- package/lib/cursor-proto-B8Wj8bv9.mjs +10513 -0
- package/lib/{deterministic-id-D-yIV_eI.mjs → deterministic-id-CUEIMSqR.mjs} +1 -1
- package/lib/devin-BMTdx_hx.mjs +316 -0
- package/lib/{devin-DUAfvBsW.mjs → devin-DSp0Rw_E.mjs} +172 -86
- package/lib/devin-ExGIghmx.mjs +69 -0
- package/lib/devin-proto-Br8fdyNl.mjs +2888 -0
- package/lib/{dom-CawWi8fa.mjs → dom-DG3sPESc.mjs} +8 -8
- package/lib/effort-BdtQMN-_.mjs +23 -0
- package/lib/{error-C-f_Wnw4.mjs → error-CORgGg5a.mjs} +275 -154
- package/lib/{event-stream-Dh2guZxS.mjs → event-stream-ulcDenZD.mjs} +20 -4
- package/lib/{gemini-headers-DKUShltF.mjs → gemini-headers-Co9cVvex.mjs} +2 -2
- package/lib/{github-copilot-suDymKrx.mjs → github-copilot-Dstq1D3s.mjs} +69 -29
- package/lib/github-copilot-headers-DOh1gt_w.mjs +312 -0
- package/lib/gitlab-duo-DSCMrU0m.mjs +11 -0
- package/lib/google-CtsKkOQK.mjs +38 -0
- package/lib/google-antigravity-z-5KsEci.mjs +252 -0
- package/lib/{google-auth-DYJLM792.mjs → google-auth-ieLBaneO.mjs} +4 -4
- package/lib/{google-gemini-cli-8BT513Ul.mjs → google-gemini-cli-C6NE5mWz.mjs} +28 -54
- package/lib/{google-gemini-cli-D6cSmfvB.mjs → google-gemini-cli-CAIPSl7e.mjs} +23 -29
- package/lib/google-oauth-shared-DhMllAkt.mjs +53 -0
- package/lib/{google-shared-CVbHK5vZ.mjs → google-shared-B0aNCYEH.mjs} +140 -44
- package/lib/{google-validation-Cgbn3tWJ.mjs → google-validation-BEkNs-Bx.mjs} +1 -1
- package/lib/{google-vertex-Bui-ypAe.mjs → google-vertex-Bbd1tYNc.mjs} +8 -8
- package/lib/hosts-00rjRzUD.mjs +203 -0
- package/lib/id-AL5obQzR.mjs +71 -0
- package/lib/{idle-iterator-CYAxUkSD.mjs → idle-iterator-DlUkEfzW.mjs} +3 -3
- package/lib/index.mjs +587 -5266
- package/lib/kilo-ChJL54wq.mjs +81 -0
- package/lib/kimi-C2c_Zq8A.mjs +67 -0
- package/lib/{launch-BmgEUycu.mjs → launch-DKDH71En.mjs} +1 -1
- package/lib/markit-CmRfm4E2.mjs +9885 -0
- package/lib/models-DnXMYGcJ.mjs +381604 -0
- package/lib/muse-code-Di1VZmB1.mjs +143 -0
- package/lib/{ollama-Df9ce-Cp.mjs → ollama-B8ic3sEp.mjs} +15 -30
- package/lib/{openai-codex-CAVI3Me-.mjs → openai-codex-DuJNC99x.mjs} +29 -99
- package/lib/{openai-codex-responses-BcnOotRB.mjs → openai-codex-responses-BL29nh9K.mjs} +204 -116
- package/lib/{openai-completions-Bq4WT47M.mjs → openai-completions-BK2f2dBv.mjs} +152 -82
- package/lib/openai-configuration-update-xMYUjaK_.mjs +150 -0
- package/lib/{openai-reasoning-fallback-DXsfiSXO.mjs → openai-reasoning-fallback-BdB3RCbj.mjs} +106 -12
- package/lib/{openai-responses-Mq_-PjvE.mjs → openai-responses-CGQPlIIy.mjs} +76 -82
- package/lib/{perplexity-XgLF73E7.mjs → perplexity-TBjz3VMB.mjs} +52 -9
- package/lib/{pkce-BlQikGPu.mjs → pkce-BYjmugmw.mjs} +1 -1
- package/lib/protobuf-aab1UGVn.mjs +717 -0
- package/lib/{provider-response-C6vcbQyO.mjs → provider-response-SqKSkkUc.mjs} +1 -1
- package/lib/{proxy-D9lm7ONA.mjs → proxy-5nWqRL1f.mjs} +45 -5
- package/lib/{readability-Cpm-ocau.mjs → readability-uGhqb4GC.mjs} +2 -2
- package/lib/reference-CtvM4zLU.mjs +114 -0
- package/lib/{request-debug-HJMoJncL.mjs → request-debug-NQN0BjHH.mjs} +1 -1
- package/lib/{sanitize-text-CfcXzw5X.mjs → sanitize-text-BCf5KmCf.mjs} +1 -1
- package/lib/{scrapers-CE_qK1yk.mjs → scrapers-D8oWspgW.mjs} +12 -12
- package/lib/{src-BcD0_rQR.mjs → src-BwW51vA5.mjs} +979 -388
- package/lib/{sse-debug-CYdjOC96.mjs → sse-debug-B-tkLCPW.mjs} +1 -1
- package/lib/{stream-Bjq8wjfr.mjs → stream-B_7qN-bA.mjs} +3802 -2623
- package/lib/stream-markup-healing-DKT1lnkW.mjs +267 -0
- package/lib/{strict-tool-validation-imVLUcbI.mjs → strict-tool-validation-CBTz1dAA.mjs} +2 -2
- package/lib/taxonomy-DSIM99rS.mjs +15392 -0
- package/lib/{stream-markup-healing-DZ6bVDxH.mjs → thinking-CiLa2LFB.mjs} +31 -186
- package/lib/{turndown-DN7ByzEI.mjs → turndown-DrX1M4WG.mjs} +4 -4
- package/lib/{type-guards-B9VVjRDK.mjs → type-guards-CttAANEx.mjs} +1 -1
- package/lib/{types-DX_bvuus.mjs → types-PVueGi9S.mjs} +2 -2
- package/lib/{utils-APrc-TBB.mjs → utils-CCfhUQen.mjs} +2364 -2676
- package/lib/{utils-Cp2Mxf_U.mjs → utils-CUPhpw9A.mjs} +413 -134
- package/lib/{utils-CQHPEQ3W.mjs → utils-DeWqNWV8.mjs} +2 -2
- package/lib/{vision-guard-mBmtAHx0.mjs → vision-guard-_XwsL1DF.mjs} +14 -29
- package/lib/xai-oauth-CXhnz0gO.mjs +210 -0
- package/lib/{xiaomi-7mE345KX.mjs → xiaomi-psoUItal.mjs} +8 -37
- package/lib/{zai-CeNpMV3W.mjs → zai-ApJ8HBgT.mjs} +8 -71
- package/lib/{zip-BK7UHCwX.mjs → zip-Kd602XNe.mjs} +1 -1
- package/package.json +43 -41
- package/presets/package.json +1 -1
- package/presets/tool-plus-ptc/agent.cordis.yml +13 -4
- package/presets/tool-plus-standard/agent.cordis.yml +11 -3
- package/lib/agent_pb-Rizyt9Zg.mjs +0 -805
- package/lib/anthropic-CDmj476p.mjs +0 -262
- package/lib/api_server_pb-CDZgLMta.mjs +0 -252
- package/lib/callback-server-CFJK-jvK.mjs +0 -398
- package/lib/codex-P1dGpX7G.mjs +0 -54
- package/lib/device-code-CuXTWYwY.mjs +0 -51
- package/lib/devin-BcQwht1W.mjs +0 -114
- package/lib/devin-BvMfGevz.mjs +0 -95
- package/lib/github-copilot-B3kQl0g0.mjs +0 -104
- package/lib/gitlab-duo-BriUTP8k.mjs +0 -155
- package/lib/gitlab-duo-workflow-wK5Ljzmc.mjs +0 -91
- package/lib/google-CE5tFDod.mjs +0 -30
- package/lib/google-antigravity-C1jgNljz.mjs +0 -198
- package/lib/google-oauth-shared-BLVTvokk.mjs +0 -147
- package/lib/grammar-D-NqNUxQ.mjs +0 -49
- package/lib/identity-HNO1Oe9B.mjs +0 -219
- package/lib/kimi-DgcUpPtK.mjs +0 -236
- package/lib/markit-DtGoRE6M.mjs +0 -1417
- package/lib/minimax-code-Y3h5li9N.mjs +0 -53
- package/lib/models-DRA2c_8U.mjs +0 -104660
- package/lib/opencode-BsVw9rCD.mjs +0 -38
- package/lib/to-binary-B1BEBIPC.mjs +0 -6002
- package/lib/wafer-BlhWLweO.mjs +0 -17
- package/lib/xai-oauth-5pORHUrg.mjs +0 -446
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
2
|
__installBunShim();
|
|
3
|
-
import { C as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as calculateCost } from "./models-
|
|
7
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
3
|
+
import { C as warn, _ as parseStreamingJson, b as debug, v as parseStreamingJsonThrottled, x as error } from "./src-BwW51vA5.mjs";
|
|
4
|
+
import { S as attach, T as create, c as finalize, o as DevinApiError, r as ValidationError, s as ProviderResponseError, v as Flag } from "./error-CORgGg5a.mjs";
|
|
5
|
+
import { A as toolWireSchema, _ as isDemotedThinking, h as transformMessages, o as normalizeSystemPrompts } from "./utils-CUPhpw9A.mjs";
|
|
6
|
+
import { t as calculateCost } from "./models-DnXMYGcJ.mjs";
|
|
7
|
+
import { t as AssistantMessageEventStream } from "./event-stream-ulcDenZD.mjs";
|
|
8
|
+
import { n as devinCliMetadata, t as DEVIN_DEFAULT_BASE_URL } from "./devin-ExGIghmx.mjs";
|
|
9
|
+
import { i as fromBinary, o as toBinary, t as create$1 } from "./protobuf-aab1UGVn.mjs";
|
|
10
|
+
import { _ as ImageDataSchema, a as ChatToolCallSchema, c as CompletionConfigurationSchema, i as ChatMessagePromptSchema, l as GetChatMessageRequestSchema, m as GetUserJwtResponseSchema, n as AssignModelRequestSchema, o as ChatToolChoiceSchema, p as GetUserJwtRequestSchema, r as AssignModelResponseSchema, s as ChatToolDefinitionSchema, t as decodeDevinUnaryMessage, u as GetChatMessageResponseSchema, v as MetadataSchema, y as PromptCacheOptionsSchema } from "./devin-proto-Br8fdyNl.mjs";
|
|
11
|
+
import { t as deterministicUuid } from "./deterministic-id-CUEIMSqR.mjs";
|
|
11
12
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
12
|
-
//#region node_modules/.pnpm/@oh-my-pi+pi-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
const file_exa_auth_pb_auth = /*@__PURE__*/ fileDesc("ChZleGEvYXV0aF9wYi9hdXRoLnByb3RvEgtleGEuYXV0aF9wYiJGChFHZXRVc2VySnd0UmVxdWVzdBIxCghtZXRhZGF0YRgBIAEoCzIfLmV4YS5jb2RlaXVtX2NvbW1vbl9wYi5NZXRhZGF0YSJFChJHZXRVc2VySnd0UmVzcG9uc2USEAoIdXNlcl9qd3QYASABKAkSHQoVY3VzdG9tX2FwaV9zZXJ2ZXJfdXJsGAIgASgJMlwKC0F1dGhTZXJ2aWNlEk0KCkdldFVzZXJKd3QSHi5leGEuYXV0aF9wYi5HZXRVc2VySnd0UmVxdWVzdBofLmV4YS5hdXRoX3BiLkdldFVzZXJKd3RSZXNwb25zZWIGcHJvdG8z", [file_buf_validate_validate, file_exa_codeium_common_pb_codeium_common]);
|
|
17
|
-
/**
|
|
18
|
-
* Describes the message exa.auth_pb.GetUserJwtRequest.
|
|
19
|
-
* Use `create(GetUserJwtRequestSchema)` to create a new message.
|
|
20
|
-
*/
|
|
21
|
-
const GetUserJwtRequestSchema = /*@__PURE__*/ messageDesc(file_exa_auth_pb_auth, 0);
|
|
22
|
-
/**
|
|
23
|
-
* Describes the message exa.auth_pb.GetUserJwtResponse.
|
|
24
|
-
* Use `create(GetUserJwtResponseSchema)` to create a new message.
|
|
25
|
-
*/
|
|
26
|
-
const GetUserJwtResponseSchema = /*@__PURE__*/ messageDesc(file_exa_auth_pb_auth, 1);
|
|
13
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-ai@18.1.17/node_modules/@oh-my-pi/pi-ai/src/providers/devin.ts
|
|
14
|
+
/** Base host for Codeium/Windsurf's Cascade chat API (Connect protocol over HTTP/1.1). */
|
|
15
|
+
const DEVIN_API_URL = DEVIN_DEFAULT_BASE_URL;
|
|
27
16
|
const CHAT_MESSAGE_PATH = "/exa.api_server_pb.ApiServerService/GetChatMessage";
|
|
28
|
-
const
|
|
29
|
-
const DEVIN_EXTENSION_VERSION = "1.48.2";
|
|
30
|
-
const DEVIN_SESSION_TOKEN_PREFIX = "devin-session-token$";
|
|
17
|
+
const DEVIN_ASSIGN_MODEL_PATH = "/exa.api_server_pb.ApiServerService/AssignModel";
|
|
31
18
|
const DEVIN_AUTH_PATH = "/exa.auth_pb.AuthService/GetUserJwt";
|
|
32
19
|
const DEVIN_DEFAULT_STOP_PATTERNS = [
|
|
33
20
|
"<|user|>",
|
|
@@ -117,11 +104,21 @@ const streamDevin = (model, context, options) => {
|
|
|
117
104
|
};
|
|
118
105
|
try {
|
|
119
106
|
const fetchImpl = options?.fetch ?? fetch;
|
|
120
|
-
const baseUrl = (model.baseUrl ||
|
|
121
|
-
const
|
|
122
|
-
const auth = await fetchDevinAuthMetadata(apiKey, baseUrl, fetchImpl, options?.signal);
|
|
107
|
+
const baseUrl = (model.baseUrl || DEVIN_API_URL).replace(/\/+$/, "");
|
|
108
|
+
const auth = await fetchDevinAuthMetadata(options?.apiKey, baseUrl, fetchImpl, options?.signal);
|
|
123
109
|
const chatBaseUrl = auth.baseUrl ?? baseUrl;
|
|
124
|
-
const
|
|
110
|
+
const turn = {
|
|
111
|
+
apiKey: options?.apiKey,
|
|
112
|
+
userJwt: auth.userJwt,
|
|
113
|
+
cascadeId: options?.conversationId ?? options?.sessionId ?? crypto.randomUUID(),
|
|
114
|
+
messages: transformMessages(context.messages, model)
|
|
115
|
+
};
|
|
116
|
+
let assignment;
|
|
117
|
+
if (model.compat.modelRouter) {
|
|
118
|
+
assignment = await assignDevinModel(model, turn, chatBaseUrl, fetchImpl, options?.signal);
|
|
119
|
+
output.upstreamModel = assignment.modelUid;
|
|
120
|
+
}
|
|
121
|
+
const request = buildDevinChatRequest(model, context, options, turn, assignment);
|
|
125
122
|
const reqBytes = toBinary(GetChatMessageRequestSchema, request);
|
|
126
123
|
const gz = gzipSync(reqBytes);
|
|
127
124
|
debug("devin: sending chat request", {
|
|
@@ -143,7 +140,7 @@ const streamDevin = (model, context, options) => {
|
|
|
143
140
|
"accept-encoding": "identity",
|
|
144
141
|
"user-agent": "connect-go/1.18.1 (go1.26.3)",
|
|
145
142
|
"connect-accept-encoding": "gzip",
|
|
146
|
-
...options?.headers
|
|
143
|
+
...options?.headers
|
|
147
144
|
},
|
|
148
145
|
body: frame,
|
|
149
146
|
signal: options?.signal
|
|
@@ -179,6 +176,18 @@ const streamDevin = (model, context, options) => {
|
|
|
179
176
|
if (flag & CONNECT_END_STREAM_FLAG) {
|
|
180
177
|
const trailerError = readConnectTrailerError((flag & CONNECT_COMPRESSED_FLAG ? gunzipSync(payload) : payload).toString("utf8").trim());
|
|
181
178
|
if (trailerError) {
|
|
179
|
+
warn("devin: stream rejected via Connect trailer", {
|
|
180
|
+
model: model.id,
|
|
181
|
+
code: trailerError.code,
|
|
182
|
+
message: trailerError.message,
|
|
183
|
+
...trailerError.detail ? { detail: trailerError.detail } : {},
|
|
184
|
+
rawTrailer: trailerError.raw,
|
|
185
|
+
requestBytes: reqBytes.byteLength,
|
|
186
|
+
compressedBytes: gz.byteLength,
|
|
187
|
+
tools: context.tools?.length ?? 0,
|
|
188
|
+
messages: context.messages.length,
|
|
189
|
+
hadOutput: firstTokenTime !== void 0
|
|
190
|
+
});
|
|
182
191
|
const error = new ValidationError(trailerError.formatted);
|
|
183
192
|
if (firstTokenTime === void 0 && trailerError.code.toLowerCase() === "invalid_argument" && /\binternal error\b/i.test(trailerError.message)) {
|
|
184
193
|
let activeTailCount = 0;
|
|
@@ -210,6 +219,7 @@ const streamDevin = (model, context, options) => {
|
|
|
210
219
|
const raw = flag & CONNECT_COMPRESSED_FLAG ? gunzipSync(payload) : payload;
|
|
211
220
|
const msg = fromBinary(GetChatMessageResponseSchema, raw);
|
|
212
221
|
if (msg.messageId && !output.responseId) output.responseId = msg.messageId;
|
|
222
|
+
if (msg.actualModelUid) output.upstreamModel = msg.actualModelUid;
|
|
213
223
|
if (msg.deltaThinking) {
|
|
214
224
|
markFirstToken();
|
|
215
225
|
const block = currentThinkingBlock ?? {
|
|
@@ -310,6 +320,13 @@ const streamDevin = (model, context, options) => {
|
|
|
310
320
|
output.usage.cacheWrite = Number(msg.usage.cacheWriteTokens);
|
|
311
321
|
output.usage.totalTokens = output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
|
|
312
322
|
}
|
|
323
|
+
if (msg.creditCost || msg.committedCreditCost || msg.committedAcuCost) {
|
|
324
|
+
output.usage.credits ??= {};
|
|
325
|
+
const credits = output.usage.credits;
|
|
326
|
+
if (msg.creditCost) credits.cost = msg.creditCost;
|
|
327
|
+
if (msg.committedCreditCost) credits.committedCost = msg.committedCreditCost;
|
|
328
|
+
if (msg.committedAcuCost) credits.acuCost = msg.committedAcuCost;
|
|
329
|
+
}
|
|
313
330
|
}
|
|
314
331
|
if (done) break;
|
|
315
332
|
}
|
|
@@ -326,7 +343,7 @@ const streamDevin = (model, context, options) => {
|
|
|
326
343
|
}
|
|
327
344
|
const doneReason = toolBlocks.size > 0 ? "toolUse" : latestStopReason === 3 ? "length" : "stop";
|
|
328
345
|
output.stopReason = doneReason;
|
|
329
|
-
calculateCost(model, output.usage);
|
|
346
|
+
calculateCost(model, output.usage, output.timestamp);
|
|
330
347
|
output.duration = performance.now() - startTime;
|
|
331
348
|
if (firstTokenTime) output.ttft = firstTokenTime - startTime;
|
|
332
349
|
stream.push({
|
|
@@ -357,19 +374,8 @@ const streamDevin = (model, context, options) => {
|
|
|
357
374
|
})();
|
|
358
375
|
return stream;
|
|
359
376
|
};
|
|
360
|
-
function normalizeDevinSessionToken(apiKey) {
|
|
361
|
-
if (!apiKey) return "";
|
|
362
|
-
return apiKey.startsWith(DEVIN_SESSION_TOKEN_PREFIX) ? apiKey : `${DEVIN_SESSION_TOKEN_PREFIX}${apiKey}`;
|
|
363
|
-
}
|
|
364
377
|
async function fetchDevinAuthMetadata(apiKey, baseUrl, fetchImpl, signal) {
|
|
365
|
-
const request = create$1(GetUserJwtRequestSchema, { metadata: create$1(MetadataSchema,
|
|
366
|
-
apiKey,
|
|
367
|
-
ideName: "windsurf",
|
|
368
|
-
ideVersion: DEVIN_IDE_VERSION,
|
|
369
|
-
extensionName: "windsurf",
|
|
370
|
-
extensionVersion: DEVIN_EXTENSION_VERSION,
|
|
371
|
-
locale: "en"
|
|
372
|
-
}) });
|
|
378
|
+
const request = create$1(GetUserJwtRequestSchema, { metadata: create$1(MetadataSchema, devinCliMetadata(apiKey)) });
|
|
373
379
|
const response = await fetchImpl(`${baseUrl}${DEVIN_AUTH_PATH}`, {
|
|
374
380
|
method: "POST",
|
|
375
381
|
headers: {
|
|
@@ -382,8 +388,8 @@ async function fetchDevinAuthMetadata(apiKey, baseUrl, fetchImpl, signal) {
|
|
|
382
388
|
});
|
|
383
389
|
const payload = new Uint8Array(await response.arrayBuffer());
|
|
384
390
|
if (!response.ok) throw new DevinApiError(`Devin auth error ${response.status} ${response.statusText}: ${new TextDecoder().decode(payload)}`, response.status);
|
|
385
|
-
const decoded =
|
|
386
|
-
if (!decoded
|
|
391
|
+
const decoded = decodeDevinUnaryMessage(GetUserJwtResponseSchema, payload);
|
|
392
|
+
if (!decoded?.userJwt) throw new ProviderResponseError("Devin auth error: GetUserJwt returned an empty user JWT", {
|
|
387
393
|
provider: "devin",
|
|
388
394
|
kind: "runtime"
|
|
389
395
|
});
|
|
@@ -393,35 +399,67 @@ async function fetchDevinAuthMetadata(apiKey, baseUrl, fetchImpl, signal) {
|
|
|
393
399
|
...customBaseUrl ? { baseUrl: customBaseUrl.replace(/\/+$/, "") } : void 0
|
|
394
400
|
};
|
|
395
401
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Resolve a server-side router (`adaptive`) into the concrete model uid plus the
|
|
404
|
+
* assignment JWT that authorizes it. The router uid is never a legal
|
|
405
|
+
* `chatModelUid`, so a failed assignment must fail the turn rather than fall
|
|
406
|
+
* back to sending the router id to `GetChatMessage`.
|
|
407
|
+
*/
|
|
408
|
+
async function assignDevinModel(model, turn, baseUrl, fetchImpl, signal) {
|
|
409
|
+
const request = create$1(AssignModelRequestSchema, {
|
|
410
|
+
metadata: create$1(MetadataSchema, devinCliMetadata(turn.apiKey)),
|
|
411
|
+
modelRouterUid: model.requestModelId ?? model.id,
|
|
412
|
+
cascadeId: turn.cascadeId,
|
|
413
|
+
chatMessagePrompt: buildRouterPrompt(turn.messages)
|
|
414
|
+
});
|
|
415
|
+
const response = await fetchImpl(`${baseUrl}${DEVIN_ASSIGN_MODEL_PATH}`, {
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
"content-type": "application/proto",
|
|
419
|
+
"connect-protocol-version": "1",
|
|
420
|
+
accept: "*/*"
|
|
421
|
+
},
|
|
422
|
+
body: toBinary(AssignModelRequestSchema, request),
|
|
423
|
+
signal
|
|
424
|
+
});
|
|
425
|
+
const payload = new Uint8Array(await response.arrayBuffer());
|
|
426
|
+
if (!response.ok) throw new DevinApiError(`Devin AssignModel error ${response.status} ${response.statusText}: ${new TextDecoder().decode(payload)}`, response.status);
|
|
427
|
+
const assignment = decodeDevinUnaryMessage(AssignModelResponseSchema, payload)?.assignment;
|
|
428
|
+
if (!assignment?.assignmentJwt || !assignment.modelUid) throw new ProviderResponseError("Devin AssignModel error: response carried no assignment JWT and model uid", {
|
|
429
|
+
provider: model.provider,
|
|
430
|
+
kind: "runtime"
|
|
431
|
+
});
|
|
432
|
+
debug("devin: router assigned a model", {
|
|
433
|
+
router: model.requestModelId ?? model.id,
|
|
434
|
+
assigned: assignment.modelUid
|
|
435
|
+
});
|
|
436
|
+
return assignment;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The prompt the router scores: the current user/developer turn on its own.
|
|
440
|
+
* Native leaves `messageId` empty here — the id for the turn is minted by the
|
|
441
|
+
* chat request that follows.
|
|
442
|
+
*/
|
|
443
|
+
function buildRouterPrompt(messages) {
|
|
444
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
445
|
+
const msg = messages[index];
|
|
446
|
+
if (msg.role === "user" || msg.role === "developer") return buildUserPrompt(msg, "");
|
|
401
447
|
}
|
|
402
448
|
}
|
|
403
449
|
/**
|
|
404
450
|
* Build a {@link GetChatMessageRequest} for one Cascade turn. Auth rides inside
|
|
405
451
|
* `Metadata.apiKey`; the system prompt is the flattened `prompt` string and the
|
|
406
|
-
* conversation history maps to `chatMessagePrompts`.
|
|
452
|
+
* conversation history maps to `chatMessagePrompts`. `assignment` is present only
|
|
453
|
+
* for router models and supplies both the resolved uid and its JWT.
|
|
407
454
|
*/
|
|
408
|
-
function buildDevinChatRequest(model, context, options,
|
|
409
|
-
const cascadeId = options?.conversationId ?? options?.sessionId ?? crypto.randomUUID();
|
|
455
|
+
function buildDevinChatRequest(model, context, options, turn, assignment) {
|
|
410
456
|
const stopPatterns = options?.stopSequences && options.stopSequences.length > 0 ? [...DEVIN_DEFAULT_STOP_PATTERNS, ...options.stopSequences] : DEVIN_DEFAULT_STOP_PATTERNS;
|
|
411
|
-
const messages = transformMessages(context.messages, model);
|
|
412
457
|
return create$1(GetChatMessageRequestSchema, {
|
|
413
|
-
metadata: create$1(MetadataSchema,
|
|
414
|
-
apiKey,
|
|
415
|
-
userJwt,
|
|
416
|
-
ideName: "windsurf",
|
|
417
|
-
ideVersion: DEVIN_IDE_VERSION,
|
|
418
|
-
extensionName: "windsurf",
|
|
419
|
-
extensionVersion: DEVIN_EXTENSION_VERSION,
|
|
420
|
-
locale: "en"
|
|
421
|
-
}),
|
|
458
|
+
metadata: create$1(MetadataSchema, devinCliMetadata(turn.apiKey, turn.userJwt)),
|
|
422
459
|
prompt: normalizeSystemPrompts(context.systemPrompt).join("\n\n"),
|
|
423
|
-
chatMessagePrompts: buildChatMessagePrompts(messages, cascadeId, model),
|
|
424
|
-
chatModelUid: options?.chatModelUid ?? model.requestModelId ?? model.id,
|
|
460
|
+
chatMessagePrompts: buildChatMessagePrompts(turn.messages, turn.cascadeId, model),
|
|
461
|
+
chatModelUid: assignment?.modelUid ?? options?.chatModelUid ?? model.requestModelId ?? model.id,
|
|
462
|
+
...assignment ? { modelAssignmentJwt: assignment.assignmentJwt } : void 0,
|
|
425
463
|
requestType: 5,
|
|
426
464
|
plannerMode: 1,
|
|
427
465
|
toolChoice: create$1(ChatToolChoiceSchema, { choice: {
|
|
@@ -429,8 +467,8 @@ function buildDevinChatRequest(model, context, options, apiKey, userJwt) {
|
|
|
429
467
|
value: "auto"
|
|
430
468
|
} }),
|
|
431
469
|
systemPromptCacheOptions: create$1(PromptCacheOptionsSchema, { type: 1 }),
|
|
432
|
-
disableParallelToolCalls:
|
|
433
|
-
cascadeId,
|
|
470
|
+
disableParallelToolCalls: !model.compat.supportsParallelToolCalls,
|
|
471
|
+
cascadeId: turn.cascadeId,
|
|
434
472
|
executionId: crypto.randomUUID(),
|
|
435
473
|
configuration: create$1(CompletionConfigurationSchema, {
|
|
436
474
|
numCompletions: 1n,
|
|
@@ -451,25 +489,28 @@ function buildDevinChatRequest(model, context, options, apiKey, userJwt) {
|
|
|
451
489
|
}))
|
|
452
490
|
});
|
|
453
491
|
}
|
|
492
|
+
/** Flatten one user/developer turn into a Cascade USER prompt with inline images. */
|
|
493
|
+
function buildUserPrompt(msg, messageId) {
|
|
494
|
+
let prompt = "";
|
|
495
|
+
const images = [];
|
|
496
|
+
if (typeof msg.content === "string") prompt = msg.content;
|
|
497
|
+
else for (const part of msg.content) if (part.type === "text") prompt += part.text;
|
|
498
|
+
else if (part.type === "image") images.push(create$1(ImageDataSchema, {
|
|
499
|
+
base64Data: part.data,
|
|
500
|
+
mimeType: part.mimeType
|
|
501
|
+
}));
|
|
502
|
+
return create$1(ChatMessagePromptSchema, {
|
|
503
|
+
messageId,
|
|
504
|
+
source: 1,
|
|
505
|
+
prompt,
|
|
506
|
+
images
|
|
507
|
+
});
|
|
508
|
+
}
|
|
454
509
|
/** Map omp `Message` history onto Cascade `ChatMessagePrompt`s (USER / SYSTEM / TOOL channels). */
|
|
455
510
|
function buildChatMessagePrompts(messages, cascadeId, model) {
|
|
456
511
|
const prompts = [];
|
|
457
|
-
for (const [index, msg] of messages.entries()) if (msg.role === "user" || msg.role === "developer") {
|
|
458
|
-
|
|
459
|
-
const images = [];
|
|
460
|
-
if (typeof msg.content === "string") promptText = msg.content;
|
|
461
|
-
else for (const part of msg.content) if (part.type === "text") promptText += part.text;
|
|
462
|
-
else if (part.type === "image") images.push(create$1(ImageDataSchema, {
|
|
463
|
-
base64Data: part.data,
|
|
464
|
-
mimeType: part.mimeType
|
|
465
|
-
}));
|
|
466
|
-
prompts.push(create$1(ChatMessagePromptSchema, {
|
|
467
|
-
messageId: deterministicUuid(`${cascadeId}\0${index}\0${msg.role}`),
|
|
468
|
-
source: 1,
|
|
469
|
-
prompt: promptText,
|
|
470
|
-
images
|
|
471
|
-
}));
|
|
472
|
-
} else if (msg.role === "assistant") {
|
|
512
|
+
for (const [index, msg] of messages.entries()) if (msg.role === "user" || msg.role === "developer") prompts.push(buildUserPrompt(msg, deterministicUuid(`${cascadeId}\0${index}\0${msg.role}`)));
|
|
513
|
+
else if (msg.role === "assistant") {
|
|
473
514
|
const isNativeDevinMessage = msg.api === model.api && msg.provider === model.provider && msg.model === model.id;
|
|
474
515
|
let promptText = "";
|
|
475
516
|
let thinkingText = "";
|
|
@@ -532,11 +573,56 @@ function readConnectTrailerError(text) {
|
|
|
532
573
|
const code = "code" in err && typeof err.code === "string" ? err.code : "";
|
|
533
574
|
const message = "message" in err && typeof err.message === "string" ? err.message : "";
|
|
534
575
|
if (!code && !message) return null;
|
|
535
|
-
|
|
576
|
+
const trailer = {
|
|
536
577
|
code,
|
|
537
578
|
message,
|
|
538
|
-
formatted: `Devin stream error${code ? ` ${code}` : ""}: ${message}
|
|
579
|
+
formatted: `Devin stream error${code ? ` ${code}` : ""}: ${message}`,
|
|
580
|
+
raw: truncateTrailerEvidence(text)
|
|
539
581
|
};
|
|
582
|
+
const detail = "details" in err ? summarizeTrailerDetails(err.details) : void 0;
|
|
583
|
+
if (detail) {
|
|
584
|
+
trailer.detail = detail;
|
|
585
|
+
trailer.formatted += ` [details: ${detail}]`;
|
|
586
|
+
}
|
|
587
|
+
return trailer;
|
|
588
|
+
}
|
|
589
|
+
/** Upper bound on retained raw-trailer evidence so log entries stay bounded. */
|
|
590
|
+
const MAX_TRAILER_EVIDENCE_CHARS = 2e3;
|
|
591
|
+
function truncateTrailerEvidence(text) {
|
|
592
|
+
return text.length > MAX_TRAILER_EVIDENCE_CHARS ? `${text.slice(0, MAX_TRAILER_EVIDENCE_CHARS)}…` : text;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Summarize Connect error `details` entries (loosely `{ type, value, debug }`
|
|
596
|
+
* records). #4218's intermittent `invalid_argument` rejections arrive as
|
|
597
|
+
* end-of-stream trailers with no HTTP error body, so any detail payload here
|
|
598
|
+
* is the only server-side evidence available; previously it was discarded.
|
|
599
|
+
*/
|
|
600
|
+
function summarizeTrailerDetails(details) {
|
|
601
|
+
if (!Array.isArray(details) || details.length === 0) return void 0;
|
|
602
|
+
let summary = "";
|
|
603
|
+
for (const entry of details) {
|
|
604
|
+
if (!entry || typeof entry !== "object") continue;
|
|
605
|
+
const record = entry;
|
|
606
|
+
const type = typeof record.type === "string" && record.type ? record.type : void 0;
|
|
607
|
+
const value = typeof record.value === "string" && record.value ? record.value : void 0;
|
|
608
|
+
let debug;
|
|
609
|
+
if (record.debug !== void 0) try {
|
|
610
|
+
debug = typeof record.debug === "string" ? record.debug : JSON.stringify(record.debug);
|
|
611
|
+
} catch {
|
|
612
|
+
debug = void 0;
|
|
613
|
+
}
|
|
614
|
+
const boundedType = type ? truncateTrailerEvidence(type) : void 0;
|
|
615
|
+
const evidence = debug ?? value;
|
|
616
|
+
const boundedEvidence = evidence ? truncateTrailerEvidence(evidence) : void 0;
|
|
617
|
+
let part;
|
|
618
|
+
if (boundedType && boundedEvidence) part = `${boundedType}: ${boundedEvidence}`;
|
|
619
|
+
else part = boundedType ?? boundedEvidence;
|
|
620
|
+
if (!part) continue;
|
|
621
|
+
const next = summary ? `${summary}; ${part}` : part;
|
|
622
|
+
if (next.length > MAX_TRAILER_EVIDENCE_CHARS) return truncateTrailerEvidence(next);
|
|
623
|
+
summary = next;
|
|
624
|
+
}
|
|
625
|
+
return summary || void 0;
|
|
540
626
|
}
|
|
541
627
|
//#endregion
|
|
542
628
|
export { streamDevin };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { installBunShim as __installBunShim } from "./bun-shim.mjs";
|
|
2
|
+
__installBunShim();
|
|
3
|
+
//#region node_modules/.pnpm/@oh-my-pi+pi-catalog@18.1.17/node_modules/@oh-my-pi/pi-catalog/src/wire/devin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Devin (Codeium Cascade) wire constants shared by catalog discovery, the pi-ai
|
|
6
|
+
* provider, and account usage. This module deliberately stays free of the
|
|
7
|
+
* generated protobuf runtime so the synchronous model seed can import it
|
|
8
|
+
* without pulling devin-gen into the boot path.
|
|
9
|
+
*/
|
|
10
|
+
/** Base host for Codeium/Windsurf's Cascade API (Connect protocol over HTTP/1.1). */
|
|
11
|
+
const DEVIN_DEFAULT_BASE_URL = "https://server.codeium.com";
|
|
12
|
+
const DEVIN_SESSION_TOKEN_PREFIX = "devin-session-token$";
|
|
13
|
+
/** `Metadata.os` vocabulary; `process.platform` is fixed for the process lifetime. */
|
|
14
|
+
const DEVIN_OS = process.platform === "darwin" ? "darwin" : process.platform === "win32" ? "windows" : "linux";
|
|
15
|
+
const DEVIN_LOCALE = "en";
|
|
16
|
+
/**
|
|
17
|
+
* Released Devin CLI request identity. The backend gates behavior on this
|
|
18
|
+
* tuple: `ideType: "chisel"` is what unlocks router assignment (`AssignModel`)
|
|
19
|
+
* and the CLI model surface, which the older Windsurf identity does not reach.
|
|
20
|
+
*/
|
|
21
|
+
const DEVIN_CLI_METADATA = {
|
|
22
|
+
ideName: "devin-cli",
|
|
23
|
+
ideType: "chisel",
|
|
24
|
+
ideVersion: "3000.6.2",
|
|
25
|
+
extensionName: "chisel",
|
|
26
|
+
extensionVersion: "3000.6.2",
|
|
27
|
+
locale: DEVIN_LOCALE,
|
|
28
|
+
os: DEVIN_OS
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Native discovery identity. The Devin CLI announces itself as the `chisel`
|
|
32
|
+
* client on its dev channel for `GetCliModelConfigs`; that identity — not the
|
|
33
|
+
* released chat identity or the legacy Windsurf one — unlocks the full native
|
|
34
|
+
* config set.
|
|
35
|
+
*/
|
|
36
|
+
const DEVIN_DISCOVERY_METADATA = {
|
|
37
|
+
ideName: "chisel",
|
|
38
|
+
ideVersion: "0.0.0-dev",
|
|
39
|
+
extensionName: "chisel",
|
|
40
|
+
extensionVersion: "0.0.0-dev",
|
|
41
|
+
locale: DEVIN_LOCALE,
|
|
42
|
+
os: DEVIN_OS
|
|
43
|
+
};
|
|
44
|
+
/** Session token as the wire format carries it: the scheme prefix is required. */
|
|
45
|
+
function normalizeDevinSessionToken(apiKey) {
|
|
46
|
+
if (!apiKey) return "";
|
|
47
|
+
return apiKey.startsWith(DEVIN_SESSION_TOKEN_PREFIX) ? apiKey : `${DEVIN_SESSION_TOKEN_PREFIX}${apiKey}`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fields for `Metadata` on released-CLI calls (`GetUserJwt`, `AssignModel`,
|
|
51
|
+
* `GetChatMessage`, `GetUserStatus`). `userJwt` stays empty for the calls the
|
|
52
|
+
* CLI makes with the session token alone (auth, model assignment, usage).
|
|
53
|
+
*/
|
|
54
|
+
function devinCliMetadata(apiKey, userJwt = "") {
|
|
55
|
+
return {
|
|
56
|
+
apiKey: normalizeDevinSessionToken(apiKey),
|
|
57
|
+
userJwt,
|
|
58
|
+
...DEVIN_CLI_METADATA
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Fields for `Metadata` on the dev-channel `GetCliModelConfigs` call. */
|
|
62
|
+
function devinDiscoveryMetadata(apiKey) {
|
|
63
|
+
return {
|
|
64
|
+
apiKey: normalizeDevinSessionToken(apiKey),
|
|
65
|
+
...DEVIN_DISCOVERY_METADATA
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { normalizeDevinSessionToken as i, devinCliMetadata as n, devinDiscoveryMetadata as r, DEVIN_DEFAULT_BASE_URL as t };
|