@eddyskywalker/dsh-chatgpt-subscription 0.1.23 → 0.1.25

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/lib/index.js CHANGED
@@ -1155,9 +1155,39 @@ function hiddenSandboxControlToolNames(options) {
1155
1155
  const retryTools = recentSandboxRetryToolNames(options.messages);
1156
1156
  return new Set(options.tools?.filter((tool) => hasSandboxControls(tool.parameters) && !retryTools.has(tool.name)).map((tool) => tool.name) ?? []);
1157
1157
  }
1158
+ function createCallIdNormalizer() {
1159
+ const normalizedByOriginal = /* @__PURE__ */ new Map();
1160
+ const originalByNormalized = /* @__PURE__ */ new Map();
1161
+ return (value) => {
1162
+ const original = String(value);
1163
+ const existing = normalizedByOriginal.get(original);
1164
+ if (existing !== void 0) return existing;
1165
+ const claim = (candidate) => {
1166
+ const owner = originalByNormalized.get(candidate);
1167
+ if (owner !== void 0 && owner !== original) return false;
1168
+ normalizedByOriginal.set(original, candidate);
1169
+ originalByNormalized.set(candidate, original);
1170
+ return true;
1171
+ };
1172
+ if (original.length <= 64 && claim(original)) return original;
1173
+ for (let attempt = 0;; attempt++) {
1174
+ const material = attempt === 0 ? original : `${original}\0${attempt}`;
1175
+ const candidate = `dsh_${createHash("sha256").update(material).digest("hex").slice(0, 60)}`;
1176
+ if (claim(candidate)) return candidate;
1177
+ }
1178
+ };
1179
+ }
1180
+ function normalizeReplayCallIds(items, normalizeCallId) {
1181
+ if (items === null) return null;
1182
+ return items.map((item) => typeof item.call_id === "string" ? {
1183
+ ...item,
1184
+ call_id: normalizeCallId(item.call_id)
1185
+ } : item);
1186
+ }
1158
1187
  async function buildResponsesPayload(options, attachments, localRawImages = {}) {
1159
1188
  const sandboxRetryTools = recentSandboxRetryToolNames(options.messages);
1160
1189
  const resolveLocalRawImages = supportsImageInput(options);
1190
+ const normalizeCallId = createCallIdNormalizer();
1161
1191
  const instructionParts = [
1162
1192
  options.system?.trim(),
1163
1193
  ...options.messages.filter((message) => message.role === "system").map((message) => blocksToText(message.content).trim()),
@@ -1174,7 +1204,7 @@ async function buildResponsesPayload(options, attachments, localRawImages = {})
1174
1204
  };
1175
1205
  for (const message of options.messages) {
1176
1206
  if (message.role === "system") continue;
1177
- const replayItems = replayOutputItems(message);
1207
+ const replayItems = normalizeReplayCallIds(replayOutputItems(message), normalizeCallId);
1178
1208
  if (message.role === "assistant" && replayItems !== null) {
1179
1209
  input.push(...replayItems);
1180
1210
  for (const item of replayItems) if (item.type === "function_call" && typeof item.call_id === "string") knownToolCalls.set(item.call_id, typeof item.name === "string" ? item.name : void 0);
@@ -1185,12 +1215,13 @@ async function buildResponsesPayload(options, attachments, localRawImages = {})
1185
1215
  content
1186
1216
  });
1187
1217
  }
1188
- appendMissingToolCalls(input, knownToolCalls, message);
1218
+ appendMissingToolCalls(input, knownToolCalls, message, normalizeCallId);
1189
1219
  continue;
1190
1220
  }
1191
1221
  const toolResult = message.content.find((block) => block.type === "tool-result");
1192
1222
  if (toolResult?.type === "tool-result") {
1193
- const callId = String(toolResult.toolCallId);
1223
+ const originalCallId = String(toolResult.toolCallId);
1224
+ const callId = normalizeCallId(originalCallId);
1194
1225
  const rawOutput = blocksToText(toolResult.content);
1195
1226
  if (knownToolCalls.has(callId)) {
1196
1227
  const output = toolResult.isError && knownToolCalls.get(callId) === "run_code" ? runCodeErrorOutput(rawOutput) : rawOutput;
@@ -1203,7 +1234,7 @@ async function buildResponsesPayload(options, attachments, localRawImages = {})
1203
1234
  role: "user",
1204
1235
  content: [{
1205
1236
  type: "input_text",
1206
- text: `Tool result for unavailable call ${callId}${toolResult.isError ? " (error)" : ""}:\n${rawOutput}`
1237
+ text: `Tool result for unavailable call ${originalCallId}${toolResult.isError ? " (error)" : ""}:\n${rawOutput}`
1207
1238
  }]
1208
1239
  });
1209
1240
  continue;
@@ -1213,7 +1244,7 @@ async function buildResponsesPayload(options, attachments, localRawImages = {})
1213
1244
  role: message.role,
1214
1245
  content
1215
1246
  });
1216
- if (message.role === "assistant") appendMissingToolCalls(input, knownToolCalls, message);
1247
+ if (message.role === "assistant") appendMissingToolCalls(input, knownToolCalls, message, normalizeCallId);
1217
1248
  }
1218
1249
  const payload = {
1219
1250
  model: options.model,
@@ -1343,10 +1374,10 @@ function recentSandboxRetryToolNames(messages) {
1343
1374
  function isSandboxDenial(output) {
1344
1375
  return /\[sandbox:\s*file access denied\b/i.test(output) || /\bsandbox\b.*\b(?:access denied|denied access|EPERM)\b/i.test(output);
1345
1376
  }
1346
- function appendMissingToolCalls(input, knownToolCalls, message) {
1377
+ function appendMissingToolCalls(input, knownToolCalls, message, normalizeCallId) {
1347
1378
  for (const block of message.content) {
1348
1379
  if (block.type !== "tool-call") continue;
1349
- const callId = String(block.id);
1380
+ const callId = normalizeCallId(block.id);
1350
1381
  if (knownToolCalls.has(callId)) continue;
1351
1382
  input.push({
1352
1383
  type: "function_call",
@@ -1 +1 @@
1
- {"version":3,"file":"responses-mapper.d.ts","sourceRoot":"","sources":["../../../src/host/responses-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAsC,MAAM,6BAA6B,CAAA;AACtG,OAAO,KAAK,EAAgB,eAAe,EAAW,MAAM,sBAAsB,CAAA;AAGlF,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACrC,MAAM,EAAE,IAAI,CAAA;IACZ,KAAK,EAAE,KAAK,CAAA;CACb;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhG,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CA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,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,EAC/F,cAAc,GAAE,oBAAyB,GACxC,OAAO,CAAC,gBAAgB,CAAC,CAiG3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eddyskywalker/dsh-chatgpt-subscription",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "DSH provider plugin for Codex access through a ChatGPT subscription.",
5
5
  "author": {
6
6
  "name": "eddyskywalker",