opencode-aicodewith-auth 0.1.52 → 0.1.55

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 +32 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -869,6 +869,24 @@ function extractRequestUrl(input) {
869
869
  return input.toString();
870
870
  return input.url;
871
871
  }
872
+ function sanitizeRequestBody(bodyStr) {
873
+ try {
874
+ const body = JSON.parse(bodyStr);
875
+ delete body.previousResponseId;
876
+ delete body.previous_response_id;
877
+ if (Array.isArray(body.input)) {
878
+ body.input = body.input.filter((item) => item.type !== "item_reference").map((item) => {
879
+ if (item.type === "call")
880
+ return item;
881
+ const { id, ...rest } = item;
882
+ return rest;
883
+ });
884
+ }
885
+ return JSON.stringify(body);
886
+ } catch {
887
+ return bodyStr;
888
+ }
889
+ }
872
890
  async function transformRequestForCodex(init) {
873
891
  if (!init?.body || typeof init.body !== "string")
874
892
  return;
@@ -886,8 +904,15 @@ async function transformRequestForCodex(init) {
886
904
  body: transformedBody,
887
905
  updatedInit: { ...init, body: JSON.stringify(transformedBody) }
888
906
  };
889
- } catch {
890
- return;
907
+ } catch (error) {
908
+ logDebug("codex-transform-error", {
909
+ error: error instanceof Error ? error.message : String(error)
910
+ });
911
+ const sanitized = sanitizeRequestBody(init.body);
912
+ return {
913
+ body: JSON.parse(sanitized),
914
+ updatedInit: { ...init, body: sanitized }
915
+ };
891
916
  }
892
917
  }
893
918
  function createAicodewithHeaders(init, apiKey, opts) {
@@ -1976,7 +2001,11 @@ var AicodewithCodexAuthPlugin = async (ctx) => {
1976
2001
  const isCodexRequest = !isClaudeRequest && !isGeminiRequest && isCodexModel(model);
1977
2002
  if (isCodexRequest) {
1978
2003
  const transformation = await transformRequestForCodex(init);
1979
- const requestInit = transformation?.updatedInit ?? init;
2004
+ let requestInit = transformation?.updatedInit ?? init;
2005
+ if (!transformation && init.body) {
2006
+ const sanitized = sanitizeRequestBody(init.body);
2007
+ requestInit = { ...init, body: sanitized };
2008
+ }
1980
2009
  const headers = createAicodewithHeaders(requestInit, apiKey, {
1981
2010
  promptCacheKey: transformation?.body.prompt_cache_key
1982
2011
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-aicodewith-auth",
3
- "version": "0.1.52",
3
+ "version": "0.1.55",
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",