@tangle-network/sdk-provider-codex 0.4.77 → 0.4.78

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.mjs +14 -20
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { InteractionKind, ProxySecretBindingSchema, ProxySecretGrantSchema, ProxySecretReceiptSchema, ProxySecretUpdateControlsSchema, ProxySecretsSchema, isProxySecretScopeAttenuation, ownPropertyRecordSchema, proxySecretPresentationsEqual, resolveTangleRouterDefaults } from "@tangle-network/agent-interface";
3
3
  import { z } from "zod";
4
4
  import { HELD_SPARE_IDLE_MS, createDeferredParser, createHeldSpareRegistry, launchDifferences, resolveRawCapturePath, spawnRpcBridge } from "@tangle-network/sdk-cli-runner";
5
- import { CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, InteractionBroker, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PROMPT_SECTION_SEPARATOR, SEALED_NATIVE_HOME_LAYOUT, assertSealedNativeHome, assertSealedNativeSearchPath, codexDeveloperInstructionArgs, deriveFilePart, directStdioMcpServers, executionCorrelationHeaders, forgetSessionScopes, interactionToggleEnabled, isLoopbackEndpoint, isPlainRecord, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, provenStoreBinary, reasoningEvents, recordCliTokenUsage, refuseSecretLaunch, resolveExecutableRealpath, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, streamPartBase, textDeltaEvents, toolResultEvents, toolStartEvents, trackFilePart, turnEndReason, untilSettledOrAborted, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
5
+ import { CODEX_DISABLED_FEATURE_ARGS, CliProviderAdapterBase, InteractionBroker, McpInteractionSupport, NATIVE_SESSION_CONTRACTS, PROMPT_SECTION_SEPARATOR, SEALED_NATIVE_HOME_LAYOUT, SECRET_REFERENCE_PREFIX, assertSealedNativeHome, assertSealedNativeSearchPath, codexDeveloperInstructionArgs, deriveFilePart, directStdioMcpServers, executionCorrelationHeaders, failureAfterCleanup, forgetSessionScopes, interactionToggleEnabled, isLoopbackEndpoint, isPlainRecord, jsonEventParser, localMcpArgv, localMcpEnv, nativeEffortArgs, partitionImageAttachments, provenStoreBinary, reasoningEvents, recordCliTokenUsage, refuseSecretLaunch, resolveExecutableRealpath, secretMcpScope, secretSessionTurnQueue, servableMcpServer, servableStdioServer, sessionObservedEvents, streamPartBase, textDeltaEvents, toolResultEvents, toolStartEvents, trackFilePart, turnEndReason, untilSettledOrAborted, withTurnInteractions } from "@tangle-network/sdk-provider-cli-base";
6
6
  import { existsSync } from "node:fs";
7
7
  import path, { join } from "node:path";
8
8
  import { isDeepStrictEqual } from "node:util";
@@ -387,19 +387,12 @@ const FORBIDDEN_ENV_VAR_NAMES = new Set([
387
387
  "XDG_CACHE_HOME",
388
388
  "XDG_STATE_HOME",
389
389
  "XDG_RUNTIME_DIR",
390
- "HTTPS_PROXY",
391
- "HTTP_PROXY",
390
+ ...EGRESS_PROXY_ENV_NAMES,
391
+ ...CA_TRUST_ENV_NAMES,
392
392
  "ALL_PROXY",
393
- "NO_PROXY",
394
- "https_proxy",
395
- "http_proxy",
396
393
  "all_proxy",
397
- "no_proxy",
398
- "SSL_CERT_FILE",
399
394
  "SSL_CERT_DIR",
400
395
  "REQUESTS_CA_BUNDLE",
401
- "CURL_CA_BUNDLE",
402
- "NODE_EXTRA_CA_CERTS",
403
396
  "HOSTNAME",
404
397
  "CONTAINER_ID",
405
398
  "AGENT_WORKSPACE_ROOT",
@@ -866,11 +859,10 @@ var CodexAppServerTurn = class {
866
859
  ...this.tokenUsage ? { tokenUsage: this.tokenUsage } : {}
867
860
  };
868
861
  } catch (error) {
869
- if (this.submittedPlan) try {
870
- await this.planInteractions?.withdrawSubmittedPlan(`Codex failed to terminalize its planning turn: ${error instanceof Error ? error.message : String(error)}`);
871
- } catch (withdrawalError) {
872
- throw new AggregateError([error, withdrawalError], "Codex planning failed and its durable plan could not be withdrawn");
873
- }
862
+ const failure = await failureAfterCleanup(error, "Codex planning failed and its durable plan could not be withdrawn", async () => {
863
+ if (this.submittedPlan) await this.planInteractions?.withdrawSubmittedPlan(`Codex failed to terminalize its planning turn: ${error instanceof Error ? error.message : String(error)}`);
864
+ });
865
+ if (failure !== error) throw failure;
874
866
  throw Object.assign(error, { reason: error.reason ?? this.closeEnd ?? turnEndReason({ aborted: this.turn.input.abortSignal?.aborted }) });
875
867
  }
876
868
  }
@@ -1185,7 +1177,8 @@ var CodexNativeLaunchAdapter = class extends CliProviderAdapterBase {
1185
1177
  }
1186
1178
  buildExecEnv(config) {
1187
1179
  const env = this.agentEnvironmentValues();
1188
- if (config.runtimeHome) env.CODEX_HOME = path.join(config.runtimeHome, ".codex");
1180
+ const { CODEX_HOME } = NATIVE_SESSION_CONTRACTS.codex.storeEnv;
1181
+ if (config.runtimeHome) env.CODEX_HOME = path.join(config.runtimeHome, CODEX_HOME);
1189
1182
  if (resolveCodexAuthMode(config) === "oauth") {
1190
1183
  env.OPENAI_API_KEY = void 0;
1191
1184
  env.OPENAI_BASE_URL = void 0;
@@ -1236,7 +1229,7 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
1236
1229
  const cwd = env.TANGLE_PROFILE_REVISION_WORKSPACE;
1237
1230
  const home = this.config.runtimeHome;
1238
1231
  const identity = this.subprocessIdentity();
1239
- if (!cwd || !home || env.HOME !== home || env.CODEX_HOME !== `${home}/.codex` || env.TANGLE_SHARED_WORKSPACE !== workspace || !identity || !isReservedProfileUid(identity.uid)) this.refuse("identity or revision is invalid", home);
1232
+ if (!cwd || !home || env.HOME !== home || env.CODEX_HOME !== `${home}/${NATIVE_SESSION_CONTRACTS.codex.storeEnv.CODEX_HOME}` || env.TANGLE_SHARED_WORKSPACE !== workspace || !identity || !isReservedProfileUid(identity.uid)) this.refuse("identity or revision is invalid", home);
1240
1233
  assertSealedNativeHome(home, identity.gid, SEALED_NATIVE_HOME_LAYOUT.codex);
1241
1234
  assertSealedNativeSearchPath(cwd, [".codex", ".agents"]);
1242
1235
  const command = await provenStoreBinary(`codex-cli ${NATIVE_SESSION_CONTRACTS.codex.cliVersion}`, {
@@ -1274,7 +1267,7 @@ var CodexSecretProfileAdapter = class extends CodexNativeLaunchAdapter {
1274
1267
  bridge.notify("initialized");
1275
1268
  const servers = await this.readNativeControls(bridge, plan, cwd);
1276
1269
  const referenced = new Set(Object.values(servers).flatMap((server) => [...Object.values(server.env_http_headers ?? {}), ...server.env_vars ?? []]));
1277
- if (Object.entries(env).some(([name, value]) => value?.includes("{env:TANGLE_PROFILE_SECRET_") && !referenced.has(name))) this.refuse("secret is outside MCP", cwd);
1270
+ if (Object.entries(env).some(([name, value]) => value?.includes(`{env:${SECRET_REFERENCE_PREFIX}`) && !referenced.has(name))) this.refuse("secret is outside MCP", cwd);
1278
1271
  return {
1279
1272
  cwd,
1280
1273
  env,
@@ -1461,9 +1454,10 @@ var CodexAppServerAdapter = class extends CodexSecretProfileAdapter {
1461
1454
  if (queue) await untilSettledOrAborted(queue.previous, input.abortSignal ?? new AbortController().signal);
1462
1455
  bridge = await this.launchAppServerTurn(prepared);
1463
1456
  result = await this.runAppServerTurn(prepared, bridge);
1464
- } finally {
1465
- if (!closing) await close();
1457
+ } catch (error) {
1458
+ throw closing ? error : await failureAfterCleanup(error, "Codex app-server turn and its close failed", close);
1466
1459
  }
1460
+ if (!closing) await close();
1467
1461
  await services.recorder.markTurnCompleted?.({ result });
1468
1462
  onEvent?.({
1469
1463
  type: "status",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sdk-provider-codex",
3
- "version": "0.4.77",
3
+ "version": "0.4.78",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -18,7 +18,7 @@
18
18
  "@tangle-network/agent-backend-types": "1.3.3",
19
19
  "@tangle-network/agent-interface": "^5.10.23",
20
20
  "@tangle-network/sdk-cli-runner": "0.3.12",
21
- "@tangle-network/sdk-provider-cli-base": "0.13.99",
21
+ "@tangle-network/sdk-provider-cli-base": "0.13.100",
22
22
  "@tangle-network/sdk-session-persistence": "0.7.12",
23
23
  "zod": "4.6.7"
24
24
  },
@@ -34,8 +34,8 @@
34
34
  "registry": "https://registry.npmjs.org"
35
35
  },
36
36
  "tangleRelease": {
37
- "sourceSha": "d20b0ed9593d98d760c1337aa8bba4934a03387e",
38
- "mergedAt": "2026-11-16T01:14:23-08:00"
37
+ "sourceSha": "ab34bf1ff5768f8016d9dc772fd0e9cad38eb402",
38
+ "mergedAt": "2026-11-16T03:50:33-08:00"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsdown",