@pure01fx/dsh-openai-codex-auth 0.10.0 → 0.11.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.11.0
6
+
7
+ - Removes plugin payload byte ceilings for native and cloud requests, SSE events, WebSocket messages and queues, response accumulation, encrypted replay state, model catalogs, and image data; removes the corresponding transport options, including `maxRequestBodyBytes`. WebSocket disables the underlying `ws` message-size ceiling explicitly.
8
+ - Keeps WebSocket incremental request preparation separate from HTTP serialization, preserving image history across incremental reuse, reconnects, and HTTP fallback.
9
+ - Preserves complete search output and result arrays, processes all inline result images, forwards selected human search context in full, and removes search batch/domain count ceilings and image-tool prompt length ceilings. Protocol validation, service errors, cancellation, retry/session lifecycle controls, and DSH attachment/file policies still apply.
10
+
11
+ ## 0.10.1
12
+
13
+ - Targets DSH 0.1.5-rc.1 with exact SDK peers and runtime helpers; migrates Responses tool calls to ToolCallId.
14
+ - Keeps browser-local model hiding active during catalog, selection projection, and reconnection updates, filtering before subscribers receive snapshots.
15
+ - Accepts the real Node/ws successful send callback (`null`), avoiding false WebSocket send failures and unintended HTTP fallback; replaces the local ws declaration with official types and handles bounded RawData variants.
16
+ - Adds actual target directory and LLM/tools service protocol regression coverage. Older DSH releases are not claimed by this candidate.
17
+
5
18
  ## 0.10.0
6
19
 
7
20
  ### Codex cloud tools
@@ -1,6 +1,12 @@
1
1
  # Codex 云端能力兼容性跟踪
2
2
 
3
- ## 当前实现与验证边界
3
+ ## DSH 0.1.5-rc.1 版本适配
4
+
5
+ `0.10.1` 迁移 ToolCallId、精确 SDK 依赖和客户端服务提供包,隐藏策略在目录发布投影之前执行。`tests/target-directory.spec.ts` 执行官方 shell 的真实 store/Zustand/Immer 与目标目录/catalog 类,使用合成 Remote 响应和投影输入;这不是浏览器联合验收。`tests/target-services.spec.ts` 使用真实 Cordis/LlmRuntime/ToolRuntime、真实 loopback HTTP/SSE/WebSocket,验证工具 ID、工具执行、含加密 reasoning 的历史回放、永久错误和取消,并确认 WS 没有偷偷回退 HTTP。实际 socket 测试也修复了 ws 成功回调为 null 时的误判。
6
+
7
+ 该版本不运行真实 OAuth、账号刷新或付费请求,不改写既有用户数据;旧版兼容性不在声明范围。下面的线上账号结果来自原 0.10.0 验证,不能视作本版本的新验证。升级/回滚建议见 README。
8
+
9
+ ## 原 0.10.0 实现与验证边界
4
10
 
5
11
  本次范围为已确认的非语音 Codex 云端服务。参考上游 b348fc26674189f758d5941cdab3f78f258b2aa7(cloud 专用跟踪常量在 src/upstream.ts);原 Provider 协议基线仍单独保留。四个工具是普通 DSH function 工具,不依赖专用模式,不覆盖现有工具。
6
12
 
package/README.md CHANGED
@@ -17,7 +17,11 @@
17
17
 
18
18
  ## 快速开始
19
19
 
20
- 当前 `0.10.0` 版本要求 DeepSeek Harness `0.1.1-rc.2`;仍运行 DSH `0.1.0-rc.6` profile 应继续使用插件 `0.6.1`。
20
+ 版本 `0.11.0` 明确适配 DeepSeek Harness `0.1.5-rc.1`,SDK peers/runtime helpers 精确锁定该版本;不声明兼容旧 SDK。旧 DSH `0.1.1-rc.2` profile 应保留原插件 `0.10.0`,升级时在独立 profile 安装新版插件并保留原 profile/锁文件以便回滚。无需迁移账号文件或浏览器隐藏列表;`dsh.engines` 仅作兼容性说明,不当作宿主硬门禁。
21
+
22
+ 本版本通过真实目标 LLM/tools 服务与本地 HTTP/SSE/WebSocket 回放、错误/取消回归;模型隐藏覆盖真实目录/catalog/store 的投影更新、重连和重新加载。验证命令为 `pnpm typecheck && pnpm build && pnpm test`;当前版本未执行线上 OAuth/付费模型验收。
23
+
24
+ `0.11.0` 移除了插件额外设置的请求、响应、SSE/WebSocket、图片和重放状态大小上限,以及相应的 transport 选项(含 `maxRequestBodyBytes`);旧配置中的该字段应删除。搜索结果完整保留,WebSocket 继续优先复用增量上下文。服务端限制、协议校验及 DSH 文件/附件策略仍生效。
21
25
 
22
26
  将插件安装到 DSH 的 `web` profile:
23
27
 
package/client.js CHANGED
@@ -112,6 +112,9 @@ window.__ModuleLoader__.load({
112
112
  dispose: directory.dispose,
113
113
  wrappedLoad: undefined,
114
114
  wrappedDispose: undefined,
115
+ set: directory.store && directory.store.set,
116
+ wrappedSet: undefined,
117
+ visibleGroups: undefined,
115
118
  generation: 0,
116
119
  rawGroups: directory.store && typeof directory.store.getSnapshot === 'function'
117
120
  ? directory.store.getSnapshot().groups : [],
@@ -124,15 +127,30 @@ window.__ModuleLoader__.load({
124
127
  const groups = visibleModelGroups(rawGroups)
125
128
  return value && typeof value === 'object' ? { ...value, groups } : value
126
129
  }
127
- record.rawGroups = rawGroups
130
+ if (rawGroups !== record.visibleGroups) record.rawGroups = rawGroups
128
131
  const groups = render(directory, record.rawGroups)
132
+ record.visibleGroups = groups
129
133
  return value && typeof value === 'object' ? { ...value, groups } : value
130
134
  }
131
135
  record.wrappedDispose = function (...args) {
132
136
  ++record.generation
133
137
  tracked.delete(directory)
138
+ if (directory.store.set === record.wrappedSet) directory.store.set = record.set
134
139
  return record.dispose.apply(this, args)
135
140
  }
141
+ // Target ModelDirectory publishes catalog/selection/reconnect snapshots through set.
142
+ // Filter before publication so no subscriber can observe a hidden row.
143
+ if (typeof record.set === 'function') {
144
+ record.wrappedSet = function (state) {
145
+ if (state.groups !== record.visibleGroups) record.rawGroups = state.groups
146
+ const available = codexModels(record.rawGroups)
147
+ if (available.length > 0) writeAvailableModels(available)
148
+ const groups = visibleModelGroups(record.rawGroups)
149
+ record.visibleGroups = groups
150
+ return record.set.call(this, { ...state, groups })
151
+ }
152
+ directory.store.set = record.wrappedSet
153
+ }
136
154
  directory.load = record.wrappedLoad
137
155
  directory.dispose = record.wrappedDispose
138
156
  tracked.set(directory, record)
@@ -148,7 +166,9 @@ window.__ModuleLoader__.load({
148
166
  for (const directory of resolver.live.directories.values()) track(directory)
149
167
  }
150
168
  const refresh = () => {
151
- for (const [directory, record] of tracked) render(directory, record.rawGroups)
169
+ for (const [directory, record] of tracked) {
170
+ record.visibleGroups = render(directory, record.rawGroups)
171
+ }
152
172
  }
153
173
  window.addEventListener(MODEL_VISIBILITY_EVENT, refresh)
154
174
 
@@ -159,6 +179,7 @@ window.__ModuleLoader__.load({
159
179
  ++record.generation
160
180
  if (directory.load === record.wrappedLoad) directory.load = record.load
161
181
  if (directory.dispose === record.wrappedDispose) directory.dispose = record.dispose
182
+ if (directory.store.set === record.wrappedSet) directory.store.set = record.set
162
183
  }
163
184
  tracked.clear()
164
185
  }
package/lib/catalog.js CHANGED
@@ -8,7 +8,6 @@ export const CODEX_MODELS_URL = 'https://chatgpt.com/backend-api/codex/models';
8
8
  export const CODEX_CATALOG_CACHE_TTL_MS = 5 * 60_000;
9
9
  const CODEX_CATALOG_MAX_STALE_MS = 7 * 24 * 60 * 60_000;
10
10
  const CODEX_CATALOG_TIMEOUT_MS = 5_000;
11
- const MAX_CATALOG_BODY_LENGTH = 2 * 1024 * 1024;
12
11
  const ORIGINATOR = 'dsh';
13
12
  class CatalogFetchError extends LlmError {
14
13
  allowsStale;
@@ -92,7 +91,7 @@ function parseServiceTiers(value) {
92
91
  }
93
92
  return tiers;
94
93
  }
95
- async function boundedResponseText(response) {
94
+ async function responseText(response) {
96
95
  if (response.body === null)
97
96
  return '';
98
97
  const reader = response.body.getReader();
@@ -104,10 +103,6 @@ async function boundedResponseText(response) {
104
103
  if (done)
105
104
  break;
106
105
  total += value.byteLength;
107
- if (total > MAX_CATALOG_BODY_LENGTH) {
108
- await reader.cancel();
109
- throw new CatalogFetchError('native Codex catalog response exceeded the size limit', 'CATALOG_INVALID_RESPONSE', true);
110
- }
111
106
  chunks.push(value);
112
107
  }
113
108
  }
@@ -366,7 +361,7 @@ export class NativeCodexCatalog {
366
361
  }
367
362
  let body;
368
363
  try {
369
- body = await boundedResponseText(response);
364
+ body = await responseText(response);
370
365
  }
371
366
  catch (error) {
372
367
  if (error instanceof CatalogFetchError)
@@ -13,7 +13,7 @@ export declare function chooseCloudModel(params: {
13
13
  export declare function visibleCloudImages(messages: readonly Message[]): ImageAttachmentRef[];
14
14
  /** Last two human texts plus intervening visible assistant text. UTF-8 bytes conservatively
15
15
  * upper-bound byte-level tokenizer tokens; a single 1000-byte assistant budget avoids
16
- * relying on an unavailable model tokenizer. User text has a separate 64 KiB cap. */
16
+ * relying on an unavailable model tokenizer. The selected human texts are preserved in full. */
17
17
  export declare function recentSearchInput(messages: readonly Message[]): {
18
18
  role: 'user' | 'assistant';
19
19
  content: string;
@@ -61,14 +61,13 @@ function boundedText(text, bytes, tail = false) {
61
61
  }
62
62
  /** Last two human texts plus intervening visible assistant text. UTF-8 bytes conservatively
63
63
  * upper-bound byte-level tokenizer tokens; a single 1000-byte assistant budget avoids
64
- * relying on an unavailable model tokenizer. User text has a separate 64 KiB cap. */
64
+ * relying on an unavailable model tokenizer. The selected human texts are preserved in full. */
65
65
  export function recentSearchInput(messages) {
66
66
  const users = messages.map((message, i) => message.role === 'user' && message.source.kind === 'user' && message.content.some(block => block.type === 'text') ? i : -1).filter(i => i >= 0).slice(-2);
67
67
  if (!users.length)
68
68
  return [];
69
69
  const selected = [];
70
70
  let assistantBytes = 1000;
71
- let userBytes = 64 * 1024;
72
71
  // Budget newest text first, then restore chronology.
73
72
  for (let i = messages.length - 1; i >= users[0]; i--) {
74
73
  const message = messages[i];
@@ -76,12 +75,10 @@ export function recentSearchInput(messages) {
76
75
  if (!user && (message.role !== 'assistant' || message.source.kind !== 'model'))
77
76
  continue;
78
77
  const text = message.content.filter(block => block.type === 'text').map(block => block.text).join('\n');
79
- const content = boundedText(text, user ? userBytes : assistantBytes, true);
78
+ const content = user ? text : boundedText(text, assistantBytes, true);
80
79
  if (!content)
81
80
  continue;
82
- if (user)
83
- userBytes -= Buffer.byteLength(content);
84
- else
81
+ if (!user)
85
82
  assistantBytes -= Buffer.byteLength(content);
86
83
  selected.push({ role: user ? 'user' : 'assistant', content });
87
84
  }
@@ -5,15 +5,12 @@ export interface NativeCodexCloudOptions {
5
5
  fetch?: typeof fetch;
6
6
  endpoint?: string;
7
7
  requestTimeoutMs?: number;
8
- maxRequestBodyBytes?: number;
9
- maxResponseBytes?: number;
10
8
  }
11
9
  export interface NativeCodexCloudPostOptions {
12
10
  credential: NativeCodexCredential;
13
11
  signal: AbortSignal;
14
12
  headers?: Record<string, string>;
15
13
  timeoutMs?: number;
16
- maxResponseBytes?: number;
17
14
  }
18
15
  export type NativeCodexCloudPath = 'alpha/search' | 'images/generations' | 'images/edits';
19
16
  export declare class NativeCodexCloudClient {
package/lib/cloud-http.js CHANGED
@@ -1,4 +1,4 @@
1
- /** Bounded, nonstreaming Codex cloud requests. Never retry ambiguous POST failures. */
1
+ /** Nonstreaming Codex cloud requests. Never retry ambiguous POST failures. */
2
2
  import { attributionHeaders, LlmError } from '@deepseek-ai/dsh-llm';
3
3
  import { nativeCodexEndpoint } from './endpoint.js';
4
4
  const fail = (message, code = 'CODEX_CLOUD_FAILED') => new LlmError(message, code);
@@ -54,8 +54,6 @@ export class NativeCodexCloudClient {
54
54
  if (!['alpha/search', 'images/generations', 'images/edits'].includes(path))
55
55
  throw fail('Invalid Codex cloud path', 'INVALID_ARGS');
56
56
  const timeoutMs = positive(options.timeoutMs ?? this.options.requestTimeoutMs, 120_000);
57
- const maxBytes = positive(options.maxResponseBytes ?? this.options.maxResponseBytes, 48 * 1024 * 1024);
58
- const requestLimit = positive(this.options.maxRequestBodyBytes, 48 * 1024 * 1024);
59
57
  let encoded;
60
58
  try {
61
59
  encoded = JSON.stringify(body);
@@ -63,8 +61,8 @@ export class NativeCodexCloudClient {
63
61
  catch {
64
62
  throw fail('Invalid cloud JSON request', 'INVALID_ARGS');
65
63
  }
66
- if (typeof encoded !== 'string' || Buffer.byteLength(encoded) > requestLimit)
67
- throw fail('Cloud request exceeds byte limit', 'INVALID_ARGS');
64
+ if (typeof encoded !== 'string')
65
+ throw fail('Invalid cloud JSON request', 'INVALID_ARGS');
68
66
  let credential = credentialCopy(options.credential);
69
67
  const accountId = credential.accountId;
70
68
  const controller = new AbortController();
@@ -118,11 +116,7 @@ export class NativeCodexCloudClient {
118
116
  if (!reader)
119
117
  throw fail('Codex cloud response is empty');
120
118
  const chunks = [];
121
- let size = 0;
122
119
  try {
123
- const declared = response.headers.get('content-length');
124
- if (declared !== null && Number(declared) > maxBytes)
125
- throw fail('Codex cloud response exceeds byte limit');
126
120
  while (true) {
127
121
  let part;
128
122
  try {
@@ -133,9 +127,6 @@ export class NativeCodexCloudClient {
133
127
  }
134
128
  if (part.done)
135
129
  break;
136
- size += part.value.byteLength;
137
- if (size > maxBytes)
138
- throw fail('Codex cloud response exceeds byte limit');
139
130
  chunks.push(part.value);
140
131
  }
141
132
  }
@@ -1,6 +1,5 @@
1
- /** Pure image endpoint validation and bounded decoding. */
1
+ /** Pure image endpoint validation and decoding. */
2
2
  import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
3
- export declare const MAX_IMAGE_BYTES: number;
4
3
  export type ImageSource = {
5
4
  attachment_id: string;
6
5
  } | {
@@ -36,7 +35,7 @@ export declare function buildImageEditRequest(value: unknown, images: readonly {
36
35
  size: string;
37
36
  n?: number;
38
37
  };
39
- export declare function decodeImageBase64(value: unknown, maxBytes?: number): Uint8Array;
38
+ export declare function decodeImageBase64(value: unknown): Uint8Array;
40
39
  export declare function imageMediaType(data: Uint8Array): ImageMediaType;
41
40
  export interface ParsedCloudImage {
42
41
  data: Uint8Array;
@@ -1,12 +1,11 @@
1
- export const MAX_IMAGE_BYTES = 32 * 1024 * 1024;
2
1
  function object(value, label) {
3
2
  if (!value || typeof value !== 'object' || Array.isArray(value))
4
3
  throw new Error(label + ' must be an object');
5
4
  return value;
6
5
  }
7
- function text(value, label, max = 32_000) {
8
- if (typeof value !== 'string' || !value.trim() || value.length > max)
9
- throw new Error(label + ' must be a nonempty bounded string');
6
+ function text(value, label, max) {
7
+ if (typeof value !== 'string' || !value.trim() || (max !== undefined && value.length > max))
8
+ throw new Error(label + ' must be a valid nonempty string');
10
9
  return value;
11
10
  }
12
11
  function count(value, label, max) {
@@ -68,16 +67,14 @@ export function buildImageEditRequest(value, images, defaultModel) {
68
67
  }
69
68
  return { ...validateImageGenerateArgs(value, defaultModel), images: images.map(({ image_url }) => ({ image_url })) };
70
69
  }
71
- export function decodeImageBase64(value, maxBytes = MAX_IMAGE_BYTES) {
72
- const cap = Math.min(maxBytes, MAX_IMAGE_BYTES);
73
- if (typeof value !== 'string' || !value.length || value.length > 4 * Math.ceil(cap / 3))
74
- throw new Error('Image base64 is empty or exceeds byte limit');
75
- // Check length before scanning or allocating the decoded payload.
70
+ export function decodeImageBase64(value) {
71
+ if (typeof value !== 'string' || !value.length)
72
+ throw new Error('Image base64 is empty');
76
73
  if (value.length % 4 !== 0 || /[^A-Za-z0-9+/=]/.test(value) || !/^[A-Za-z0-9+/]*={0,2}$/.test(value))
77
74
  throw new Error('Invalid image base64');
78
75
  const data = Buffer.from(value, 'base64');
79
- if (!data.length || data.length > cap || data.toString('base64') !== value)
80
- throw new Error('Invalid image base64 or byte limit exceeded');
76
+ if (!data.length || data.toString('base64') !== value)
77
+ throw new Error('Invalid image base64');
81
78
  return data;
82
79
  }
83
80
  export function imageMediaType(data) {
@@ -108,11 +105,9 @@ export function parseImageResponse(value, requestId) {
108
105
  metadata.size = text(response.size, 'response size', 64);
109
106
  if (requestId !== undefined)
110
107
  metadata.request_id = text(requestId, 'request_id', 512);
111
- let total = 0;
112
108
  const images = response.data.map((entry) => {
113
109
  const item = object(entry, 'Image response data');
114
- const data = decodeImageBase64(item.b64_json, MAX_IMAGE_BYTES - total);
115
- total += data.length;
110
+ const data = decodeImageBase64(item.b64_json);
116
111
  const generation_id = item.generation_id == null ? undefined : text(item.generation_id, 'generation_id', 512);
117
112
  // Unknown fields may contain payloads or private service state; never copy them to history.
118
113
  return { data, mediaType: imageMediaType(data), metadata: generation_id === undefined ? {} : { generation_id },
@@ -2,7 +2,7 @@
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { posix, win32 } from 'node:path';
4
4
  import { imageSize } from 'image-size';
5
- import { MAX_IMAGE_BYTES, imageMediaType, validateImageSelection } from './cloud-images.js';
5
+ import { imageMediaType, validateImageSelection } from './cloud-images.js';
6
6
  // Check both process-world grammars without resolving against the plugin host OS.
7
7
  function absoluteWorldPath(path) {
8
8
  return !path.includes('\0') && (posix.isAbsolute(path) || (win32.isAbsolute(path) && /^[A-Za-z]:|^\\\\[^\\]+\\[^\\]+/.test(path)));
@@ -25,7 +25,6 @@ export async function resolveImageSources(value, deps) {
25
25
  if ('attachment_id' in source && !refs.has(source.attachment_id))
26
26
  throw new Error('Image attachment is not visible in this session: ' + source.attachment_id);
27
27
  const result = [];
28
- let total = 0;
29
28
  for (const source of sources) {
30
29
  deps.signal?.throwIfAborted();
31
30
  let data;
@@ -33,8 +32,8 @@ export async function resolveImageSources(value, deps) {
33
32
  let path;
34
33
  if ('attachment_id' in source) {
35
34
  attachment = refs.get(source.attachment_id);
36
- if (!Number.isSafeInteger(attachment.bytes) || attachment.bytes <= 0 || attachment.bytes > MAX_IMAGE_BYTES - total)
37
- throw new Error('Image inputs exceed byte limit');
35
+ if (!Number.isSafeInteger(attachment.bytes) || attachment.bytes <= 0)
36
+ throw new Error('Invalid image byte count');
38
37
  const stored = await deps.attachments.readImage(attachment, deps.signal);
39
38
  data = stored.data;
40
39
  if (stored.ref.attachmentId !== attachment.attachmentId || stored.ref.bytes !== attachment.bytes ||
@@ -46,12 +45,12 @@ export async function resolveImageSources(value, deps) {
46
45
  if (!absoluteWorldPath(source.path))
47
46
  throw new Error('Image path must be absolute');
48
47
  const target = await deps.fs.resolve(source.path, { cwd: deps.workspace, ...(deps.signal ? { signal: deps.signal } : {}) });
49
- data = await deps.fs.readBytes(target, deps.signal, MAX_IMAGE_BYTES - total);
48
+ // The filesystem API requires a numeric bound; impose no plugin-specific byte ceiling.
49
+ data = await deps.fs.readBytes(target, deps.signal, Number.MAX_SAFE_INTEGER);
50
50
  path = deps.fs.processPath(target);
51
51
  }
52
- total += data.length;
53
- if (!data.length || total > MAX_IMAGE_BYTES)
54
- throw new Error('Image inputs are empty or exceed byte limit');
52
+ if (!data.length)
53
+ throw new Error('Image inputs are empty');
55
54
  const mediaType = imageMediaType(data);
56
55
  await deps.attachments.validateImage({ data, mediaType });
57
56
  const dimensions = encodedDimensions(data);
@@ -74,13 +73,11 @@ export async function saveImageOutputs(response, deps) {
74
73
  throw new Error('Caller workspace must be absolute');
75
74
  if (!deps.policy || !deps.shell.sandboxMode)
76
75
  throw new Error('Original image writes require a policy-enforcing DSH shell');
77
- let total = 0;
78
76
  const dimensions = [];
79
77
  for (const image of response.images) {
80
78
  deps.signal?.throwIfAborted();
81
- total += image.data.length;
82
- if (!image.data.length || total > MAX_IMAGE_BYTES)
83
- throw new Error('Image outputs exceed byte limit');
79
+ if (!image.data.length)
80
+ throw new Error('Image outputs are empty');
84
81
  if (imageMediaType(image.data) !== image.mediaType)
85
82
  throw new Error('Output media type does not match bytes');
86
83
  await deps.attachments.validateImage({ data: image.data, mediaType: image.mediaType });
@@ -22,7 +22,7 @@ export declare function buildCloudSearchRequest(args: CloudSearchArgs, context:
22
22
  model: string;
23
23
  input?: unknown;
24
24
  }): Record<string, unknown>;
25
- /** Keep whole opaque result entries and identify any omitted data explicitly. */
25
+ /** Preserve complete output and opaque result entries. */
26
26
  export declare function parseCloudSearchResponse(body: unknown): {
27
27
  output: string;
28
28
  results?: unknown[];
@@ -1,9 +1,6 @@
1
1
  /** Wire contract: Codex b348fc26674189f758d5941cdab3f78f258b2aa7, codex-api/src/search.rs. */
2
2
  import { createHash } from 'node:crypto';
3
3
  import { LlmError } from '@deepseek-ai/dsh-llm';
4
- const MAX_REQUEST_BYTES = 256 * 1024;
5
- const MAX_OUTPUT_BYTES = 128 * 1024;
6
- const MAX_RESULTS_BYTES = 256 * 1024;
7
4
  const invalid = () => new LlmError('Invalid codex_web arguments; check command fields and limits', 'INVALID_ARGS');
8
5
  function object(value) {
9
6
  if (!value || typeof value !== 'object' || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype)
@@ -11,7 +8,7 @@ function object(value) {
11
8
  return value;
12
9
  }
13
10
  function text(value, empty = false) {
14
- if (typeof value !== 'string' || (!empty && !value.trim()) || value.length > MAX_REQUEST_BYTES)
11
+ if (typeof value !== 'string' || (!empty && !value.trim()))
15
12
  throw invalid();
16
13
  return value;
17
14
  }
@@ -22,7 +19,7 @@ const uint = value => {
22
19
  return value;
23
20
  };
24
21
  const strings = value => {
25
- if (!Array.isArray(value) || value.length > 100)
22
+ if (!Array.isArray(value))
26
23
  throw invalid();
27
24
  return value.map(item => text(item));
28
25
  };
@@ -67,10 +64,9 @@ const operations = {
67
64
  return s;
68
65
  } }, required: ['utc_offset'] },
69
66
  };
70
- function boundedRequest(value) {
67
+ function validateRequestJson(value) {
71
68
  try {
72
- if (Buffer.byteLength(JSON.stringify(value)) > MAX_REQUEST_BYTES)
73
- throw invalid();
69
+ JSON.stringify(value);
74
70
  }
75
71
  catch {
76
72
  throw invalid();
@@ -88,13 +84,13 @@ export function parseCloudSearchArgs(value) {
88
84
  result[key] = choice('short', 'medium', 'long')(items);
89
85
  continue;
90
86
  }
91
- if (!Object.hasOwn(operations, key) || !Array.isArray(items) || items.length === 0 || items.length > 100)
87
+ if (!Object.hasOwn(operations, key) || !Array.isArray(items) || items.length === 0)
92
88
  throw invalid();
93
89
  const operation = operations[key];
94
90
  count += items.length;
95
91
  result[key] = items.map(item => fields(item, operation.rules, operation.required));
96
92
  }
97
- if (count === 0 || count > 100)
93
+ if (count === 0)
98
94
  throw invalid();
99
95
  return result;
100
96
  },
@@ -104,7 +100,7 @@ export function parseCloudSearchArgs(value) {
104
100
  filters: value => fields(value, { allowed_domains: strings, blocked_domains: strings }),
105
101
  image_settings: value => fields(value, { max_results: uint, caption: bool }),
106
102
  }, ['commands']);
107
- boundedRequest(parsed);
103
+ validateRequestJson(parsed);
108
104
  return parsed;
109
105
  }
110
106
  /** The caller selects the model and visible context using the same request credential. */
@@ -122,10 +118,10 @@ export function buildCloudSearchRequest(args, context) {
122
118
  if (input !== undefined && typeof input !== 'string' && !Array.isArray(input))
123
119
  throw invalid();
124
120
  const result = { id, model: text(context.model), commands: parsed.commands, settings, ...(input === undefined ? {} : { input }) };
125
- boundedRequest(result);
121
+ validateRequestJson(result);
126
122
  return result;
127
123
  }
128
- /** Keep whole opaque result entries and identify any omitted data explicitly. */
124
+ /** Preserve complete output and opaque result entries. */
129
125
  export function parseCloudSearchResponse(body) {
130
126
  let data;
131
127
  try {
@@ -136,17 +132,10 @@ export function parseCloudSearchResponse(body) {
136
132
  }
137
133
  if (typeof data.output !== 'string' || (data.results != null && !Array.isArray(data.results)))
138
134
  throw new LlmError('Invalid Codex search response', 'CODEX_CLOUD_FAILED');
139
- let output = data.output;
140
- let truncated = false;
141
- if (Buffer.byteLength(output) > MAX_OUTPUT_BYTES) {
142
- // Truncate only at complete UTF-8 boundaries; the notice warns that references may be omitted.
143
- output = new TextDecoder().decode(Buffer.from(output).subarray(0, MAX_OUTPUT_BYTES)).replace(/\uFFFD$/, '');
144
- truncated = true;
145
- }
135
+ const output = data.output;
146
136
  let results;
147
137
  if (Array.isArray(data.results)) {
148
138
  results = [];
149
- let bytes = 2;
150
139
  for (const item of data.results) {
151
140
  let serialized;
152
141
  try {
@@ -157,16 +146,8 @@ export function parseCloudSearchResponse(body) {
157
146
  }
158
147
  if (serialized === undefined)
159
148
  throw new LlmError('Invalid Codex search results', 'CODEX_CLOUD_FAILED');
160
- const size = Buffer.byteLength(serialized) + 1;
161
- if (results.length >= 100 || bytes + size > MAX_RESULTS_BYTES) {
162
- truncated = true;
163
- continue;
164
- }
165
149
  results.push(JSON.parse(serialized));
166
- bytes += size;
167
150
  }
168
151
  }
169
- if (truncated)
170
- output += '\n[Search response truncated; some content or references were omitted. Narrow the request to retrieve them.]';
171
- return { output, ...(results === undefined ? {} : { results }), truncated };
152
+ return { output, ...(results === undefined ? {} : { results }), truncated: false };
172
153
  }
@@ -10,7 +10,7 @@ const imageRefs = { type: 'array', minItems: 1, maxItems: 5, description: 'Image
10
10
  ],
11
11
  } };
12
12
  const common = {
13
- prompt: { type: 'string', description: 'Describe the image to generate or the edits to perform.', minLength: 1, maxLength: 32000 },
13
+ prompt: { type: 'string', description: 'Describe the image to generate or the edits to perform.', minLength: 1 },
14
14
  model: { type: 'string', description: 'Optional Codex image model; defaults to configured imageModel or gpt-image-2.' },
15
15
  quality: { type: 'string', enum: ['auto', 'low', 'medium', 'high'] },
16
16
  background: { type: 'string', enum: ['auto', 'transparent', 'opaque'] },
@@ -105,7 +105,7 @@ export function registerCodexImageTools(ctx, deps) {
105
105
  name: 'codex_image_inspect',
106
106
  description: 'Ask a Codex vision model to analyze images, OCR, screenshots or charts. This makes one additional cloud inference call, without recursive tools. Use explicit model or configured visionModel for non-Codex callers. Reports effective detail and actual dimensions.',
107
107
  parameters: { type: 'object', additionalProperties: false, required: ['prompt', 'images'], properties: {
108
- prompt: { type: 'string', minLength: 1, maxLength: 32000 }, images: imageRefs,
108
+ prompt: { type: 'string', minLength: 1 }, images: imageRefs,
109
109
  model: { type: 'string' }, detail: { type: 'string', enum: ['auto', 'low', 'high', 'original'] }, reasoning_effort: { type: 'string' },
110
110
  } },
111
111
  output, timeoutMs: 120_000, isConcurrencySafe: () => true,
@@ -10,8 +10,8 @@ export function parseCloudVisionArgs(value) {
10
10
  const row = value;
11
11
  if (Object.keys(row).some(key => !['prompt', 'images', 'model', 'detail', 'reasoning_effort'].includes(key)))
12
12
  throw new Error('Unknown vision argument');
13
- if (typeof row.prompt !== 'string' || !row.prompt.trim() || Buffer.byteLength(row.prompt) > 32_000)
14
- throw new Error('Vision prompt must be a nonempty bounded string');
13
+ if (typeof row.prompt !== 'string' || !row.prompt.trim())
14
+ throw new Error('Vision prompt must be a nonempty string');
15
15
  const selection = validateImageSelection(row);
16
16
  if (!selection.images)
17
17
  throw new Error('Vision requires explicit images');
@@ -73,21 +73,13 @@ export async function inspectCloudImages(args, deps) {
73
73
  ...(model.instructionsTemplate === undefined ? {} : { instructionsTemplate: model.instructionsTemplate }),
74
74
  } } : {}) });
75
75
  const texts = new Map();
76
- let visibleBytes = 0;
77
76
  let usage;
78
77
  let finished = false;
79
78
  for await (const chunk of chunks) {
80
79
  if (chunk.type === 'tool-call-delta' || (chunk.type === 'block-start' && chunk.blockType === 'tool-call'))
81
80
  throw new LlmError('Image inspection returned an unexpected tool call', 'UNSUPPORTED');
82
- if (chunk.type === 'text-delta') {
83
- visibleBytes += Buffer.byteLength(chunk.text);
84
- if (visibleBytes > 128 * 1024)
85
- throw new LlmError('Image inspection output exceeded limit', 'RESPONSE_TOO_LARGE');
86
- }
87
81
  if (chunk.type === 'block-end' && chunk.block.type === 'text') {
88
82
  texts.set(chunk.index, chunk.block.text);
89
- if ([...texts.values()].reduce((bytes, text) => bytes + Buffer.byteLength(text), 0) > 128 * 1024)
90
- throw new LlmError('Image inspection output exceeded limit', 'RESPONSE_TOO_LARGE');
91
83
  }
92
84
  if (chunk.type === 'usage')
93
85
  usage = chunk.usage;
@@ -22,7 +22,7 @@ const operations = {
22
22
  response_length: enumeration('short', 'medium', 'long'),
23
23
  };
24
24
  const parameters = object({
25
- commands: { ...object(operations), description: 'One or more nonempty command arrays; at most 100 operations total. Dependent actions require separate calls. screenshot only supports zero-indexed PDF pages.' },
25
+ commands: { ...object(operations), description: 'One or more nonempty command arrays. Dependent actions require separate calls. screenshot only supports zero-indexed PDF pages.' },
26
26
  model: { ...str, description: 'Explicit Codex catalog model; otherwise cloudTools.searchModel, then current openai-codex model. No guessed fallback.' },
27
27
  context: { ...str, description: 'Optional explicit text. Default includes last two visible human texts and at most 1000 UTF-8 bytes of visible assistant text.' },
28
28
  mode: enumeration('cached', 'indexed', 'live'), search_context_size: enumeration('low', 'medium', 'high'),
@@ -51,12 +51,8 @@ function inputImage(value) {
51
51
  async function admitSearchImages(body, attachments, signal) {
52
52
  const images = [];
53
53
  const notes = new Set();
54
- let seen = 0;
55
- let bytes = 0;
56
- const visit = async (item, depth) => {
54
+ const visit = async (item) => {
57
55
  signal.throwIfAborted();
58
- if (depth > 8)
59
- return item;
60
56
  if (inputImage(item)) {
61
57
  if (publicUrl(item.image_url)) {
62
58
  notes.add('Remote image unavailable: the public DSH web boundary has no binary image retrieval. Image and source links are preserved.');
@@ -69,12 +65,9 @@ async function admitSearchImages(body, attachments, signal) {
69
65
  try {
70
66
  if (!attachments)
71
67
  throw new Error('Attachment service unavailable');
72
- if (++seen > 4 || match[2].length > 12 * 1024 * 1024)
73
- throw new Error('Image count or byte limit');
74
68
  const data = Buffer.from(match[2], 'base64');
75
- bytes += data.length;
76
- if (!data.length || bytes > 8 * 1024 * 1024 || data.toString('base64') !== match[2])
77
- throw new Error('Invalid or oversized inline image');
69
+ if (!data.length || data.toString('base64') !== match[2])
70
+ throw new Error('Invalid inline image');
78
71
  signal.throwIfAborted();
79
72
  ref = await attachments.saveImage({ data, mediaType: match[1] });
80
73
  signal.throwIfAborted();
@@ -87,26 +80,23 @@ async function admitSearchImages(body, attachments, signal) {
87
80
  // Binary transfer data must not become historical text; unknown fields remain opaque.
88
81
  return { ...item, image_url: ref ? '[DSH attachment ' + ref.attachmentId + ']' : '[inline image unavailable]' };
89
82
  }
90
- // Bounded structural walk permits known content blocks nested in evolving result DTOs.
83
+ // Visit known content blocks while keeping unknown object fields opaque.
91
84
  if (Array.isArray(item)) {
92
- if (item.length > 100)
93
- return item; // Unknown large arrays stay opaque for bounded parsing.
94
85
  const result = [];
95
86
  for (const value of item)
96
- result.push(await visit(value, depth + 1));
87
+ result.push(await visit(value));
97
88
  return result;
98
89
  }
99
- if (record(item) && Array.isArray(item.content) && item.content.length <= 100) {
100
- return { ...item, content: await visit(item.content, depth + 1) };
90
+ if (record(item) && Array.isArray(item.content)) {
91
+ return { ...item, content: await visit(item.content) };
101
92
  }
102
93
  return item;
103
94
  };
104
95
  if (!record(body) || !Array.isArray(body.results))
105
96
  return { body, images, notes };
106
- // Leave excess entries for the response parser to mark explicitly as truncated.
107
97
  const results = [];
108
- for (let i = 0; i < body.results.length; i++)
109
- results.push(i < 100 ? await visit(body.results[i], 0) : body.results[i]);
98
+ for (const item of body.results)
99
+ results.push(await visit(item));
110
100
  return { body: { ...body, results }, images, notes };
111
101
  }
112
102
  const markerPrefix = '[codex_web context: ';
@@ -208,7 +198,7 @@ export function registerCodexWeb(ctx, deps) {
208
198
  checkReferences(args, messages, id, recent);
209
199
  const response = await deps.client.post('alpha/search', body, { credential, signal: exec.signal });
210
200
  // Validate the envelope before any attachment write; image bytes are replaced
211
- // before the final bounded result projection so large valid images can attach.
201
+ // before the final result projection so inline images become attachments.
212
202
  if (!record(response.body) || typeof response.body.output !== 'string' || (response.body.results != null && !Array.isArray(response.body.results)))
213
203
  throw new LlmError('Invalid Codex search response', 'CODEX_CLOUD_FAILED');
214
204
  const media = await admitSearchImages(response.body, agent.ctx.attachments, exec.signal);