@jacobbd/relay-ai 0.12.3 → 0.12.5

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.
@@ -10,7 +10,7 @@ import {
10
10
  supportsManualModels,
11
11
  translateRequest,
12
12
  validateCustomEndpointUrl
13
- } from "./chunk-C7TTIGMR.js";
13
+ } from "./chunk-2LUDFIZX.js";
14
14
 
15
15
  // src/registry/validate-manual-model.ts
16
16
  import { randomUUID } from "crypto";
@@ -149,4 +149,4 @@ export {
149
149
  addManualModel,
150
150
  removeManualModel
151
151
  };
152
- //# sourceMappingURL=chunk-3K2DFBNP.js.map
152
+ //# sourceMappingURL=chunk-SJEJAHKL.js.map
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  addManualModel,
4
4
  removeManualModel
5
- } from "./chunk-3K2DFBNP.js";
5
+ } from "./chunk-SJEJAHKL.js";
6
6
  import {
7
7
  CODEX_APP_AUTO_COMPACT_RATIO,
8
8
  CODEX_APP_PROVIDER_ID,
@@ -148,7 +148,7 @@ import {
148
148
  waitForCodexAppQuit,
149
149
  writeSecureLogLine,
150
150
  zenRegistryStub
151
- } from "./chunk-R427D6VA.js";
151
+ } from "./chunk-S7HYE2FI.js";
152
152
  import {
153
153
  filterTemplates,
154
154
  getTemplateById,
@@ -222,7 +222,7 @@ import {
222
222
  thinkingProviderOptions,
223
223
  upstreamHttpStatus,
224
224
  validateCustomEndpointUrl
225
- } from "./chunk-C7TTIGMR.js";
225
+ } from "./chunk-2LUDFIZX.js";
226
226
  import "./chunk-JIDIH7DS.js";
227
227
 
228
228
  // src/cli.ts
@@ -2316,7 +2316,7 @@ import * as p9 from "@clack/prompts";
2316
2316
  import { join as join6 } from "path";
2317
2317
 
2318
2318
  // src/codex-proxy.ts
2319
- import { createHash as createHash2 } from "crypto";
2319
+ import { createHash as createHash3 } from "crypto";
2320
2320
  import { createServer } from "http";
2321
2321
  import { WebSocket } from "ws";
2322
2322
 
@@ -2368,13 +2368,20 @@ function applyClaudeCodeOAuthIdentity(input, sdkParams) {
2368
2368
  }
2369
2369
 
2370
2370
  // src/codex-responses-adapter.ts
2371
+ import { createHash } from "crypto";
2371
2372
  import { streamText, generateText, tool, jsonSchema } from "ai";
2372
2373
  function createCodexToolContext() {
2373
2374
  return { namespaceByFlatName: /* @__PURE__ */ new Map(), customToolNames: /* @__PURE__ */ new Set() };
2374
2375
  }
2375
2376
  var TOOL_SEARCH_NAME = "tool_search";
2377
+ var MAX_MODEL_TOOL_NAME_LENGTH = 64;
2378
+ var TOOL_NAME_DIGEST_LENGTH = 10;
2376
2379
  function flatNamespaceName(namespace, name) {
2377
- return `${namespace}__${name}`;
2380
+ const flat = `${namespace}__${name}`;
2381
+ if (flat.length <= MAX_MODEL_TOOL_NAME_LENGTH) return flat;
2382
+ const digest = createHash("sha256").update(flat).digest("hex").slice(0, TOOL_NAME_DIGEST_LENGTH);
2383
+ const prefixLength = MAX_MODEL_TOOL_NAME_LENGTH - digest.length - 2;
2384
+ return `${flat.slice(0, prefixLength)}__${digest}`;
2378
2385
  }
2379
2386
  function ingestToolDefs(tools, ctx) {
2380
2387
  for (const t of tools ?? []) {
@@ -3630,7 +3637,7 @@ function nativeResponsesWebSocketOptions(options) {
3630
3637
  }
3631
3638
 
3632
3639
  // src/codex/collaboration-payload.ts
3633
- import { createHash } from "crypto";
3640
+ import { createHash as createHash2 } from "crypto";
3634
3641
  var NATIVE_ENCRYPTED_TOKEN = /^gAAAAA[A-Za-z0-9_-]+={0,2}$/;
3635
3642
  var COLLABORATION_HEADER = /Message Type:\s*(?:NEW_TASK|MESSAGE|FOLLOWUP_TASK|FINAL_ANSWER)\b[\s\S]*\nPayload:\s*/i;
3636
3643
  var PAYLOAD_BOUNDARY = /^Payload:\s*$/m;
@@ -3834,7 +3841,7 @@ function createNativePayloadRelay(options) {
3834
3841
  if (ciphertext.kind !== "native-encrypted") throw new Error("Expected a native encrypted collaboration item");
3835
3842
  const accountId = context.headers["chatgpt-account-id"] ?? context.headers["ChatGPT-Account-Id"];
3836
3843
  if (!accountId) throw new Error("Native collaboration relay requires ChatGPT-Account-Id");
3837
- const key = `${accountId}\0${createHash("sha256").update(ciphertext.ciphertext).digest("hex")}`;
3844
+ const key = `${accountId}\0${createHash2("sha256").update(ciphertext.ciphertext).digest("hex")}`;
3838
3845
  pruneCache();
3839
3846
  const cached = cache.get(key);
3840
3847
  if (cached && cached.expiresAt > Date.now()) return cached.value;
@@ -4342,13 +4349,14 @@ async function startCodexProxy(routes, options = {}) {
4342
4349
  const inputItems = Array.isArray(body.input) ? body.input.length : typeof body.input === "string" ? 1 : 0;
4343
4350
  const tools = Array.isArray(body.tools) ? body.tools : [];
4344
4351
  const toolNames = tools.map((t) => t && typeof t === "object" && "name" in t ? t.name : "?").join(",");
4345
- log15(`request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${rawBody.length} tools=[${toolNames || "none"}]`);
4352
+ log15(`request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${rawBody.length} max_output_tokens=${String(body.max_output_tokens ?? "(none)")} tools=[${toolNames || "none"}]`);
4346
4353
  appendCodexBodyDump({
4347
4354
  ts: (/* @__PURE__ */ new Date()).toISOString(),
4348
4355
  transport: "http",
4349
4356
  direction: "request",
4350
4357
  model: String(body.model ?? ""),
4351
4358
  previous_response_id: prevId,
4359
+ max_output_tokens: body.max_output_tokens,
4352
4360
  tools: body.tools,
4353
4361
  input: body.input
4354
4362
  });
@@ -4502,7 +4510,7 @@ async function startCodexProxy(routes, options = {}) {
4502
4510
  }
4503
4511
  if (debug) {
4504
4512
  const effort = body.reasoning?.effort;
4505
- log15(`model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
4513
+ log15(`model=${route.modelId} effort=${effort ?? "(none)"} maxOutputTokens=${String(params.maxOutputTokens ?? "(omitted)")} providerOptions=${JSON.stringify(params.providerOptions)}`);
4506
4514
  }
4507
4515
  if (body.stream) {
4508
4516
  res.writeHead(200, {
@@ -4633,7 +4641,7 @@ async function startCodexProxy(routes, options = {}) {
4633
4641
  sendJson(res, 404, { error: { message: "Not found", type: "invalid_request_error" } });
4634
4642
  });
4635
4643
  function wsAcceptKey(clientKey) {
4636
- return createHash2("sha1").update(clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
4644
+ return createHash3("sha1").update(clientKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
4637
4645
  }
4638
4646
  function wsDecodeFrame(buf) {
4639
4647
  if (buf.length < 2) return null;
@@ -4871,7 +4879,7 @@ data: ${JSON.stringify({ error: { message: "Invalid JSON", type: "invalid_reques
4871
4879
  const inputItems = Array.isArray(body.input) ? body.input.length : typeof body.input === "string" ? 1 : 0;
4872
4880
  const tools = Array.isArray(body.tools) ? body.tools : [];
4873
4881
  const toolNames = tools.map((t) => t && typeof t === "object" && "name" in t ? t.name : "?").join(",");
4874
- log15(`WS request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${frameText.length} tools=[${toolNames || "none"}]`);
4882
+ log15(`WS request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${frameText.length} max_output_tokens=${String(body.max_output_tokens ?? "(none)")} tools=[${toolNames || "none"}]`);
4875
4883
  const reasoning = body.reasoning && typeof body.reasoning === "object" ? Object.keys(body.reasoning).join(",") : typeof body.reasoning;
4876
4884
  const clientMetadata = body.client_metadata && typeof body.client_metadata === "object" ? Object.keys(body.client_metadata).join(",") : typeof body.client_metadata;
4877
4885
  log15(`WS request shape: stream=${String(body.stream)} store=${String(body.store)} generate=${String(body.generate)} parallel_tool_calls=${String(body.parallel_tool_calls)} reasoning_keys=[${reasoning || "none"}] include=${Array.isArray(body.include) ? body.include.join(",") : String(body.include)} client_metadata_keys=[${clientMetadata || "none"}]`);
@@ -4881,6 +4889,7 @@ data: ${JSON.stringify({ error: { message: "Invalid JSON", type: "invalid_reques
4881
4889
  direction: "request",
4882
4890
  model: String(body.model ?? ""),
4883
4891
  previous_response_id: prevId,
4892
+ max_output_tokens: body.max_output_tokens,
4884
4893
  tools: body.tools,
4885
4894
  input: body.input
4886
4895
  });
@@ -5157,7 +5166,7 @@ data: ${JSON.stringify({ error: { message: `Unknown model: ${modelId}` } })}
5157
5166
  }
5158
5167
  if (debug) {
5159
5168
  const effort = body.reasoning?.effort;
5160
- log15(`WS model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
5169
+ log15(`WS model=${route.modelId} effort=${effort ?? "(none)"} maxOutputTokens=${String(params.maxOutputTokens ?? "(omitted)")} providerOptions=${JSON.stringify(params.providerOptions)}`);
5161
5170
  }
5162
5171
  if (v2Compaction) {
5163
5172
  await streamCompactionResponse(languageModel, params, modelId, sendWsEvent);
@@ -11612,7 +11621,7 @@ import {
11612
11621
  statSync as statSync2
11613
11622
  } from "fs";
11614
11623
  import { basename as basename2, join as join12 } from "path";
11615
- import { createHash as createHash3 } from "crypto";
11624
+ import { createHash as createHash4 } from "crypto";
11616
11625
  function getAppSessionLockPath(env = process.env) {
11617
11626
  return join12(getRelayAiCodexDir(env), "session-app.json");
11618
11627
  }
@@ -11623,7 +11632,7 @@ function getAppCatalogPath(providerId, env = process.env) {
11623
11632
  return join12(getRelayAiCodexDir(env), `app-models-${providerId}.json`);
11624
11633
  }
11625
11634
  function fileSha256(path3) {
11626
- return createHash3("sha256").update(readFileSync5(path3)).digest("hex");
11635
+ return createHash4("sha256").update(readFileSync5(path3)).digest("hex");
11627
11636
  }
11628
11637
  function readAppSessionLock(env = process.env) {
11629
11638
  const path3 = getAppSessionLockPath(env);
@@ -16042,7 +16051,7 @@ Options:
16042
16051
  --trace Write debug logs under ~/.relay-ai/logs/`);
16043
16052
  return 0;
16044
16053
  }
16045
- const { runUiCommand } = await import("./ui-command-Q27TKD53.js");
16054
+ const { runUiCommand } = await import("./ui-command-7AZ7SLTB.js");
16046
16055
  return runUiCommand({ trace: parsed.trace, serverMode: parsed.uiServerMode });
16047
16056
  }
16048
16057
  if (parsed.command === "models") {