deepcode-ai 1.1.36 → 1.1.38
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/dist/index.js +91 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3358,8 +3358,11 @@ function isSimpleDirectCommand(input) {
|
|
|
3358
3358
|
return normalized2.split(/\s+/).length <= 20;
|
|
3359
3359
|
}
|
|
3360
3360
|
function resolveExecutionTarget(config, session, mode, explicitProvider) {
|
|
3361
|
+
if (session.metadata.providerPinned === true && !explicitProvider) {
|
|
3362
|
+
return { provider: session.provider, model: session.model };
|
|
3363
|
+
}
|
|
3361
3364
|
const modeOverride = config.modeDefaults?.[mode];
|
|
3362
|
-
const hasPinnedProvider = Boolean(explicitProvider ?? modeOverride?.provider)
|
|
3365
|
+
const hasPinnedProvider = Boolean(explicitProvider ?? modeOverride?.provider);
|
|
3363
3366
|
const provider = explicitProvider ?? modeOverride?.provider ?? session.provider ?? config.defaultProvider ?? resolveUsableProviderTarget(config, []).provider;
|
|
3364
3367
|
const modeModel = modeOverride?.provider && modeOverride.provider !== provider ? void 0 : modeOverride?.model;
|
|
3365
3368
|
const model = modeModel ?? (provider === session.provider ? session.model : void 0) ?? resolveConfiguredModelForProvider(config, provider);
|
|
@@ -6046,6 +6049,8 @@ var OpenAICompatibleProvider = class {
|
|
|
6046
6049
|
extraHeaders;
|
|
6047
6050
|
normalizeModelId;
|
|
6048
6051
|
buildRequestBody;
|
|
6052
|
+
contentToolCallParser;
|
|
6053
|
+
contentToolCallMarker;
|
|
6049
6054
|
apiKeyOptional;
|
|
6050
6055
|
constructor(options) {
|
|
6051
6056
|
this.id = options.id;
|
|
@@ -6056,6 +6061,8 @@ var OpenAICompatibleProvider = class {
|
|
|
6056
6061
|
this.extraHeaders = options.extraHeaders ?? {};
|
|
6057
6062
|
this.normalizeModelId = options.normalizeModelId;
|
|
6058
6063
|
this.buildRequestBody = options.buildRequestBody;
|
|
6064
|
+
this.contentToolCallParser = options.contentToolCallParser;
|
|
6065
|
+
this.contentToolCallMarker = options.contentToolCallMarker;
|
|
6059
6066
|
this.apiKeyOptional = options.apiKeyOptional ?? false;
|
|
6060
6067
|
}
|
|
6061
6068
|
async *chat(messages, options) {
|
|
@@ -6089,6 +6096,7 @@ var OpenAICompatibleProvider = class {
|
|
|
6089
6096
|
await this.assertOk(response);
|
|
6090
6097
|
const pendingTools = /* @__PURE__ */ new Map();
|
|
6091
6098
|
let lastUsage = null;
|
|
6099
|
+
let contentToolBuffer = null;
|
|
6092
6100
|
for await (const event of parseSse(response)) {
|
|
6093
6101
|
const streamError = getOpenAICompatibleStreamError(event);
|
|
6094
6102
|
if (streamError) {
|
|
@@ -6100,7 +6108,19 @@ var OpenAICompatibleProvider = class {
|
|
|
6100
6108
|
const choice = event.choices?.[0];
|
|
6101
6109
|
const delta = choice?.delta;
|
|
6102
6110
|
if (delta?.content) {
|
|
6103
|
-
|
|
6111
|
+
if (this.contentToolCallParser && this.contentToolCallMarker) {
|
|
6112
|
+
if (contentToolBuffer !== null) {
|
|
6113
|
+
contentToolBuffer += delta.content;
|
|
6114
|
+
} else if (delta.content.includes(this.contentToolCallMarker)) {
|
|
6115
|
+
const markerPos = delta.content.indexOf(this.contentToolCallMarker);
|
|
6116
|
+
if (markerPos > 0) yield { type: "delta", content: delta.content.slice(0, markerPos) };
|
|
6117
|
+
contentToolBuffer = delta.content.slice(markerPos);
|
|
6118
|
+
} else {
|
|
6119
|
+
yield { type: "delta", content: delta.content };
|
|
6120
|
+
}
|
|
6121
|
+
} else {
|
|
6122
|
+
yield { type: "delta", content: delta.content };
|
|
6123
|
+
}
|
|
6104
6124
|
}
|
|
6105
6125
|
if (typeof delta?.reasoning_content === "string" && delta.reasoning_content.length > 0) {
|
|
6106
6126
|
yield { type: "reasoning", content: delta.reasoning_content };
|
|
@@ -6139,6 +6159,21 @@ var OpenAICompatibleProvider = class {
|
|
|
6139
6159
|
};
|
|
6140
6160
|
}
|
|
6141
6161
|
}
|
|
6162
|
+
if (contentToolBuffer && this.contentToolCallParser) {
|
|
6163
|
+
const parsed = this.contentToolCallParser(contentToolBuffer);
|
|
6164
|
+
if (parsed) {
|
|
6165
|
+
if (parsed.remainder) yield { type: "delta", content: parsed.remainder };
|
|
6166
|
+
for (let i = 0; i < parsed.toolCalls.length; i++) {
|
|
6167
|
+
const call = parsed.toolCalls[i];
|
|
6168
|
+
yield {
|
|
6169
|
+
type: "tool_call",
|
|
6170
|
+
call: { id: `dsml_${i}`, name: call.name, arguments: call.arguments }
|
|
6171
|
+
};
|
|
6172
|
+
}
|
|
6173
|
+
} else {
|
|
6174
|
+
yield { type: "delta", content: contentToolBuffer };
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6142
6177
|
for (const [index, call] of pendingTools) {
|
|
6143
6178
|
if (!call.name) continue;
|
|
6144
6179
|
yield {
|
|
@@ -6305,6 +6340,56 @@ function toOpenAICompatibleToolChoice(toolChoice) {
|
|
|
6305
6340
|
}
|
|
6306
6341
|
return toolChoice;
|
|
6307
6342
|
}
|
|
6343
|
+
var FF = "\uFF5C\uFF5C";
|
|
6344
|
+
var DSML_OPEN_TAG = `<${FF}DSML${FF}tool_calls>`;
|
|
6345
|
+
var DSML_CLOSE_TAG = `</${FF}DSML${FF}tool_calls>`;
|
|
6346
|
+
function parseDSMLToolCalls(content) {
|
|
6347
|
+
const startIdx = content.indexOf(DSML_OPEN_TAG);
|
|
6348
|
+
if (startIdx === -1) return null;
|
|
6349
|
+
const endIdx = content.indexOf(DSML_CLOSE_TAG, startIdx);
|
|
6350
|
+
if (endIdx === -1) return null;
|
|
6351
|
+
const remainder = (content.slice(0, startIdx) + content.slice(endIdx + DSML_CLOSE_TAG.length)).trim();
|
|
6352
|
+
const block = content.slice(startIdx + DSML_OPEN_TAG.length, endIdx);
|
|
6353
|
+
const toolCalls = [];
|
|
6354
|
+
const invokeRe = new RegExp(
|
|
6355
|
+
`<${FF}DSML${FF}invoke name="([^"]+)">(.*?)<\\/${FF}DSML${FF}invoke>`,
|
|
6356
|
+
"gis"
|
|
6357
|
+
);
|
|
6358
|
+
let invokeMatch;
|
|
6359
|
+
while ((invokeMatch = invokeRe.exec(block)) !== null) {
|
|
6360
|
+
const toolName = invokeMatch[1];
|
|
6361
|
+
const paramBlock = invokeMatch[2];
|
|
6362
|
+
const args = {};
|
|
6363
|
+
const paramRe = new RegExp(
|
|
6364
|
+
`<${FF}DSML${FF}parameter name="([^"]+)"([^>]*)>(.*?)<\\/${FF}DSML${FF}parameter>`,
|
|
6365
|
+
"gis"
|
|
6366
|
+
);
|
|
6367
|
+
let paramMatch;
|
|
6368
|
+
while ((paramMatch = paramRe.exec(paramBlock)) !== null) {
|
|
6369
|
+
const paramName = paramMatch[1];
|
|
6370
|
+
const paramAttrs = paramMatch[2];
|
|
6371
|
+
const rawValue = paramMatch[3].trim();
|
|
6372
|
+
args[paramName] = coerceDSMLParam(rawValue, paramAttrs);
|
|
6373
|
+
}
|
|
6374
|
+
toolCalls.push({ name: toolName, arguments: args });
|
|
6375
|
+
}
|
|
6376
|
+
return { toolCalls, remainder };
|
|
6377
|
+
}
|
|
6378
|
+
function coerceDSMLParam(value, attrs) {
|
|
6379
|
+
if (/\bstring="true"/i.test(attrs)) return value;
|
|
6380
|
+
if (/\bnumber="true"/i.test(attrs)) {
|
|
6381
|
+
const n = Number(value);
|
|
6382
|
+
return Number.isNaN(n) ? value : n;
|
|
6383
|
+
}
|
|
6384
|
+
if (/\bboolean="true"/i.test(attrs)) {
|
|
6385
|
+
return value.toLowerCase() === "true";
|
|
6386
|
+
}
|
|
6387
|
+
try {
|
|
6388
|
+
return JSON.parse(value);
|
|
6389
|
+
} catch {
|
|
6390
|
+
return value;
|
|
6391
|
+
}
|
|
6392
|
+
}
|
|
6308
6393
|
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 502, 503, 504]);
|
|
6309
6394
|
var MODEL_CATALOG_GRACE_MS = 250;
|
|
6310
6395
|
function isRetryableError(error) {
|
|
@@ -6365,7 +6450,9 @@ var ProviderManager = class {
|
|
|
6365
6450
|
buildRequestBody: (body, context) => ({
|
|
6366
6451
|
...body,
|
|
6367
6452
|
thinking: buildDeepSeekThinkingOverride(context.model)
|
|
6368
|
-
})
|
|
6453
|
+
}),
|
|
6454
|
+
contentToolCallParser: parseDSMLToolCalls,
|
|
6455
|
+
contentToolCallMarker: DSML_OPEN_TAG
|
|
6369
6456
|
})
|
|
6370
6457
|
);
|
|
6371
6458
|
this.register(
|
|
@@ -28341,7 +28428,7 @@ function parseVersion2(version) {
|
|
|
28341
28428
|
if (!match) return null;
|
|
28342
28429
|
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
28343
28430
|
}
|
|
28344
|
-
var VERSION = "1.1.
|
|
28431
|
+
var VERSION = "1.1.38".length > 0 ? "1.1.38" : "0.0.0-dev";
|
|
28345
28432
|
var updateCommand = {
|
|
28346
28433
|
name: "update",
|
|
28347
28434
|
description: "Check published DeepCode versions",
|