opencode-aicodewith-auth 0.1.56 → 0.1.58

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -695,30 +695,23 @@ function resolveInclude(body) {
695
695
  return include;
696
696
  }
697
697
  function sanitizeItemIds(input) {
698
- const outputCallIds = new Set;
699
- for (const item of input) {
700
- if (item.type === "function_call_output" || item.type === "local_shell_call_output" || item.type === "custom_tool_call_output") {
701
- const callId = item.call_id;
702
- if (typeof callId === "string" && callId.trim().length > 0) {
703
- outputCallIds.add(callId.trim());
704
- }
705
- }
706
- }
707
- return input.filter((item) => item.type !== "item_reference").map((item) => {
708
- if (!("id" in item)) {
698
+ const strippedIds = [];
699
+ const result = input.filter((item) => item.type !== "item_reference").map((item) => {
700
+ if (!("id" in item))
709
701
  return item;
710
- }
711
- const isCallItem = item.type === "function_call" || item.type === "local_shell_call" || item.type === "custom_tool_call";
712
- if (isCallItem) {
713
- const callId = item.call_id;
714
- const hasMatchingOutput = typeof callId === "string" && callId.trim().length > 0 && outputCallIds.has(callId.trim());
715
- if (hasMatchingOutput) {
716
- return item;
717
- }
702
+ const itemId = item.id;
703
+ if (typeof itemId === "string") {
704
+ strippedIds.push(itemId);
718
705
  }
719
706
  const { id, ...rest } = item;
720
707
  return rest;
721
708
  });
709
+ if (strippedIds.length > 0) {
710
+ logDebug(`Stripped ${strippedIds.length} item IDs from input (stateless mode)`, {
711
+ ids: strippedIds
712
+ });
713
+ }
714
+ return result;
722
715
  }
723
716
  function filterOpenCodeSystemPrompts(input) {
724
717
  if (!Array.isArray(input))
@@ -765,6 +758,8 @@ async function transformRequestBody(body, codexInstructions) {
765
758
  logDebug(`Model lookup: "${originalModel}" -> "${normalizedModel}"`, {
766
759
  hasTools: !!body.tools
767
760
  });
761
+ const hadPreviousResponseId = !!(body.previousResponseId || body.previous_response_id);
762
+ const hadItemReferences = Array.isArray(body.input) && body.input.some((item) => item.type === "item_reference");
768
763
  body.model = normalizedModel;
769
764
  body.stream = true;
770
765
  body.store = false;
@@ -777,6 +772,12 @@ async function transformRequestBody(body, codexInstructions) {
777
772
  body.input = addCodexBridgeMessage(body.input, !!body.tools);
778
773
  if (body.input) {
779
774
  body.input = normalizeOrphanedToolOutputs(body.input);
775
+ if (hadPreviousResponseId || hadItemReferences) {
776
+ const hasAssistantOrToolHistory = body.input.some((item) => item.role === "assistant" || item.type === "function_call" || item.type === "function_call_output" || item.type === "local_shell_call" || item.type === "local_shell_call_output" || item.type === "custom_tool_call" || item.type === "custom_tool_call_output");
777
+ if (!hasAssistantOrToolHistory) {
778
+ logDebug("WARNING: Request had previous_response_id/item_reference but input lacks assistant/tool history. " + "Context may be lost in store:false mode. Upstream should send full conversation history in input.", { hadPreviousResponseId, hadItemReferences, inputLength: body.input.length });
779
+ }
780
+ }
780
781
  }
781
782
  }
782
783
  const reasoningConfig = resolveReasoningConfig(normalizedModel, body);
@@ -1891,8 +1892,9 @@ var isGeminiUrl = (url) => url.includes(":generateContent") || url.includes(":st
1891
1892
  var isClaudeUrl = (url) => url.includes("/v1/messages");
1892
1893
  var isThirdPartyModel = (model) => Boolean(model && model.endsWith("-third-party"));
1893
1894
  var stripThirdPartySuffix = (model) => model.replace(/-third-party$/, "");
1894
- var isModel = (model, prefix) => Boolean(model && model.startsWith(prefix));
1895
- var isCodexModel = (model) => Boolean(model && CODEX_MODEL_PREFIXES.some((prefix) => model.startsWith(prefix)));
1895
+ var stripProviderPrefix = (model) => model.includes("/") ? model.split("/").pop() : model;
1896
+ var isModel = (model, prefix) => Boolean(model && stripProviderPrefix(model).startsWith(prefix));
1897
+ var isCodexModel = (model) => Boolean(model && CODEX_MODEL_PREFIXES.some((prefix) => stripProviderPrefix(model).startsWith(prefix)));
1896
1898
  var saveResponseIfEnabled = async (response, provider, metadata) => {
1897
1899
  if (!SAVE_RAW_RESPONSE_ENABLED)
1898
1900
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-aicodewith-auth",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "OpenCode plugin for AICodewith authentication - Access GPT-5.3 Codex, GPT-5.2, Claude, and Gemini models through AICodewith API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",