@runuai/host 0.9.134 → 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/lib/skills.ts CHANGED
@@ -220,15 +220,32 @@ export function nonInteractiveInstallCommand(command: string): string {
220
220
  const found = add.exec(command);
221
221
  if (!found) return command;
222
222
  // Only the flags AFTER the subcommand count: `npx -y skills add …` is npx's
223
- // own -y, not the CLI's.
224
- const rest = command.slice(found.index + found[0].length);
223
+ // own -y, not the CLI's. And the CLI wants its options AFTER the source —
224
+ // put before it, the parser reports "Missing required argument: source"
225
+ // (live 2026-09-10, smoke 14) — so the flags go right after the source
226
+ // token: the first token past `add` that is not an option or an option's
227
+ // value, stopping at a shell operator.
228
+ const afterAdd = found.index + found[0].length;
229
+ const rest = command.slice(afterAdd);
230
+ const tail = rest.split(/(?=\s(?:&&|\|\||[|;]))/)[0] ?? rest;
225
231
  const flags: string[] = [];
226
- if (!/(^|\s)(-y|--yes)(\s|$)/.test(rest)) flags.push("-y");
227
- if (!/(^|\s)(-a|--agent)(\s|=)/.test(rest)) flags.push("--agent claude-code");
232
+ if (!/(^|\s)(-y|--yes)(\s|$)/.test(tail)) flags.push("-y");
233
+ if (!/(^|\s)(-a|--agent)(\s|=)/.test(tail)) flags.push("--agent claude-code");
228
234
  if (flags.length === 0) return command;
229
- return (
230
- command.slice(0, found.index + found[0].length) + ` ${flags.join(" ")}` + rest
231
- );
235
+ const valued = /^(-a|--agent|-s|--skill)$/;
236
+ const tokens = [...tail.matchAll(/\S+/g)];
237
+ let sourceEnd = -1;
238
+ for (let i = 0; i < tokens.length; i++) {
239
+ const token = tokens[i]![0];
240
+ if (token.startsWith("-")) {
241
+ if (valued.test(token)) i += 1; // skip the option's value
242
+ continue;
243
+ }
244
+ sourceEnd = tokens[i]!.index! + token.length;
245
+ break;
246
+ }
247
+ const at = sourceEnd >= 0 ? afterAdd + sourceEnd : afterAdd + tail.length;
248
+ return `${command.slice(0, at)} ${flags.join(" ")}${command.slice(at)}`;
232
249
  }
233
250
 
234
251
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runuai/host",
3
- "version": "0.9.134",
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>",