@runuai/host 0.9.135 → 0.9.136

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.
@@ -308,6 +308,8 @@ export class CodexSession implements AgentSession {
308
308
  environment: TaskEnvironmentAgentSessionSurface;
309
309
  systemPreamble: string;
310
310
  agentEnv?: Record<string, string>;
311
+ /** ADR-128: `-c key=value` overrides a delegating adapter prepends. */
312
+ cliConfigOverrides?: string[];
311
313
  }) {
312
314
  this.agentId = args.agent.id;
313
315
  this.systemPreamble = args.systemPreamble;
@@ -327,6 +329,9 @@ export class CodexSession implements AgentSession {
327
329
  if (args.agent.effort) {
328
330
  codexArgs.push("-c", `model_reasoning_effort=${args.agent.effort}`);
329
331
  }
332
+ for (const override of args.cliConfigOverrides ?? []) {
333
+ codexArgs.push("-c", override);
334
+ }
330
335
  codexArgs.push("app-server");
331
336
  // ADR-061: the CLI is owned by an in-container runner (durable across
332
337
  // host restarts); legacy pipes behind UAI_DURABLE_SESSIONS=0. Codex
@@ -187,5 +187,9 @@ export interface AgentSessionFactory {
187
187
  /** ADR-048: extra per-agent process environment (e.g. this agent's own
188
188
  * UAI_TASK_TOKEN so its `uai` CLI carries only its own permissions). */
189
189
  agentEnv?: Record<string, string>;
190
+ /** ADR-128: engine config overrides a DELEGATING adapter prepends (codex
191
+ * `-c key=value`), e.g. the Uai Managed Engine's model-provider block
192
+ * that points codex at the inference gateway. Never from the roster. */
193
+ cliConfigOverrides?: string[];
190
194
  }): Promise<AgentSession>;
191
195
  }
package/lib/agents/uai.ts CHANGED
@@ -34,6 +34,8 @@ export function uaiGatewayEnv(
34
34
  return {
35
35
  OPENAI_BASE_URL: url,
36
36
  OPENAI_API_KEY: taskToken,
37
+ // Read by the `uai` model provider's `env_key` (see uaiCodexOverrides).
38
+ UAI_INFERENCE_TOKEN: taskToken,
37
39
  };
38
40
  }
39
41
  return {
@@ -47,6 +49,30 @@ export function uaiGatewayEnv(
47
49
  };
48
50
  }
49
51
 
52
+ /**
53
+ * Codex does NOT follow `OPENAI_BASE_URL` / `OPENAI_API_KEY` for its default
54
+ * provider any more: with a ChatGPT login present it opens
55
+ * `wss://api.openai.com/v1/responses` directly and sends no bearer (live
56
+ * 2026-09-12: "401 Missing bearer or basic authentication", five
57
+ * reconnects, turn never answered). A dedicated model provider pins the
58
+ * gateway as the base URL, the HTTP Responses wire (the gateway serves
59
+ * `/v1/responses`, not WebSockets), and the task token via `env_key`;
60
+ * `requires_openai_auth=false` keeps the host's Codex login out of a
61
+ * gateway-billed session. Codex parses `-c` values as TOML, hence the
62
+ * quotes on strings.
63
+ */
64
+ export function uaiCodexOverrides(url: string): string[] {
65
+ const base = `${url.replace(/\/+$/, "")}/v1`;
66
+ return [
67
+ "model_provider=uai",
68
+ 'model_providers.uai.name="Uai Managed Engine"',
69
+ `model_providers.uai.base_url="${base}"`,
70
+ 'model_providers.uai.env_key="UAI_INFERENCE_TOKEN"',
71
+ 'model_providers.uai.wire_api="responses"',
72
+ "model_providers.uai.requires_openai_auth=false",
73
+ ];
74
+ }
75
+
50
76
  const create: AgentSessionFactory["create"] = async (args): Promise<AgentSession> => {
51
77
  const provider = args.agent.uaiProvider === "openai" ? "openai" : "anthropic";
52
78
  const delegateKind = provider === "openai" ? "codex" : "claude";
@@ -69,6 +95,7 @@ const create: AgentSessionFactory["create"] = async (args): Promise<AgentSession
69
95
  ...(args.agentEnv ?? {}),
70
96
  ...uaiGatewayEnv(provider, gatewayUrl(), taskToken),
71
97
  },
98
+ ...(provider === "openai" ? { cliConfigOverrides: uaiCodexOverrides(gatewayUrl()) } : {}),
72
99
  });
73
100
  };
74
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runuai/host",
3
- "version": "0.9.135",
3
+ "version": "0.9.136",
4
4
  "description": "Uai host — runs ephemeral AI tasks in containers on a machine you control.",
5
5
  "license": "MIT",
6
6
  "author": "Uai Tech <team@runuai.com>",