@bitkyc08/opencodex 2.100.4 → 2.100.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.
- package/gui/dist/assets/{App-DcpyI78f.js → App-BRExzhwL.js} +21 -21
- package/gui/dist/assets/{Tray-CzjPJprT.js → Tray-DHCWAn8V.js} +1 -1
- package/gui/dist/assets/{brand-mark-BTIi7e69.js → brand-mark-C70PuQ3j.js} +1 -1
- package/gui/dist/assets/index-Dy1jIGty.js +138 -0
- package/gui/dist/assets/{segment-thumb-features-Bn6Y-g3R.js → segment-thumb-features-Bquysdn5.js} +1 -1
- package/gui/dist/classic/assets/{App-eYJAyNHM.js → App-CaC-E6Vl.js} +20 -20
- package/gui/dist/classic/assets/{Tray-xHMYxLkV.js → Tray-BG253fiL.js} +1 -1
- package/gui/dist/classic/assets/index-CR_AThOp.js +138 -0
- package/gui/dist/classic/assets/{quota-summary-DyzHlkFl.js → quota-summary-B7KQPpEC.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +1 -1
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +1 -63
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +24 -0
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/provider.ts +3 -2
- package/src/client/connect.ts +10 -2
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/main-account.ts +7 -2
- package/src/codex/native-main-credentials.ts +11 -5
- package/src/combos/failover.ts +183 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/generated/compatibility-version.json +99 -83
- package/src/generated/model-metadata.ts +3 -3
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/upstream-retry.ts +1 -1
- package/src/messaging/remote-ports.ts +22 -10
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +25 -13
- package/src/oauth/index.ts +22 -14
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +43 -14
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/responses/citation-markers.ts +26 -23
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +21 -8
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-routes.ts +8 -8
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/request-log-conversation.ts +6 -2
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-dispatch.ts +8 -8
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +43 -19
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +6 -4
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/types/request.ts +4 -3
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/index-DVgU6S3y.js +0 -138
- package/gui/dist/classic/assets/index-DSaVRW4F.js +0 -138
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { stripResponsesOnlyEncryptedMarker } from "./responses-tool-schema";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Anthropic rejects a root-level missing `type` and root-level `oneOf`/`anyOf`/`allOf` in
|
|
5
|
+
* `input_schema`. Normalize the root only: ensure `type:"object"` + `properties`, flatten root
|
|
6
|
+
* composition while preserving nested schemas, and inline local `#/...` refs (RFC 6901: the
|
|
7
|
+
* fragment is percent-decoded, numeric tokens index arrays) before flattening so a referenced
|
|
8
|
+
* branch keeps its parameters and required members. A `$ref` with siblings merges both property
|
|
9
|
+
* maps, unions `required`, and keeps a property declared on both sides conjunctive under
|
|
10
|
+
* `allOf`; composition on both sides is kept, not replaced. A property met twice on an all-`allOf`
|
|
11
|
+
* path is conjoined the same way. Composition branches and direct alias hops share one 4096-step
|
|
12
|
+
* budget. Shared by the anthropic and command-code adapters; Command Code's text-call recovery
|
|
13
|
+
* matches markup against the normalized schema and validates it against the declared one too.
|
|
14
|
+
*
|
|
15
|
+
* Flattening root alternatives is lossy: later branches win for a same-named property, and
|
|
16
|
+
* `oneOf`/`anyOf` branch `required` members are not promoted because no branch is guaranteed.
|
|
17
|
+
* A root `oneOf` whose branches declare `action.enum: ["read"]` and `action.enum: ["write"]`
|
|
18
|
+
* yields a schema that permits only `"write"`. Covered by
|
|
19
|
+
* tests/providers/command-code-tool-schema.test.ts and
|
|
20
|
+
* tests/adapters/anthropic/anthropic-tool-schema.test.ts.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const LOCAL_REF_PREFIX = "#/";
|
|
24
|
+
const COMPOSITION_KEYS = ["oneOf", "anyOf", "allOf"] as const;
|
|
25
|
+
/** Branch visits allowed while expanding root composition; shared ref graphs multiply. */
|
|
26
|
+
const ROOT_COMPOSITION_EXPANSION_LIMIT = 4096;
|
|
27
|
+
const ROOT_COMPOSITION_LIMIT_MESSAGE =
|
|
28
|
+
"tool input schema reference expansion exceeded the supported limit";
|
|
29
|
+
/** Shared work budget: composition branches and direct `$ref` alias hops both count against it. */
|
|
30
|
+
interface ExpansionBudget { count: number }
|
|
31
|
+
|
|
32
|
+
function spend(budget: ExpansionBudget): void {
|
|
33
|
+
budget.count += 1;
|
|
34
|
+
if (budget.count > ROOT_COMPOSITION_EXPANSION_LIMIT) throw new Error(ROOT_COMPOSITION_LIMIT_MESSAGE);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function decodePointerSegment(segment: string): string {
|
|
38
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* RFC 6901: a URI fragment is percent-decoded before it is split into tokens, each token then
|
|
43
|
+
* undoes `~1`/`~0`, and a canonical decimal token selects an array element. A malformed escape
|
|
44
|
+
* or a path that does not resolve leaves the reference unresolved.
|
|
45
|
+
*/
|
|
46
|
+
function resolveLocalPointer(root: Record<string, unknown>, pointer: string): Record<string, unknown> | undefined {
|
|
47
|
+
if (!pointer.startsWith(LOCAL_REF_PREFIX)) return undefined;
|
|
48
|
+
let decoded: string;
|
|
49
|
+
try {
|
|
50
|
+
decoded = decodeURIComponent(pointer.slice(2));
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
let node: unknown = root;
|
|
55
|
+
for (const segment of decoded.split("/")) {
|
|
56
|
+
const token = decodePointerSegment(segment);
|
|
57
|
+
if (Array.isArray(node)) {
|
|
58
|
+
if (!/^(?:0|[1-9]\d*)$/.test(token)) return undefined;
|
|
59
|
+
node = node[Number(token)];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!node || typeof node !== "object" || !Object.hasOwn(node, token)) return undefined;
|
|
63
|
+
node = (node as Record<string, unknown>)[token];
|
|
64
|
+
}
|
|
65
|
+
return node && typeof node === "object" && !Array.isArray(node)
|
|
66
|
+
? node as Record<string, unknown>
|
|
67
|
+
: undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function asSchemaMap(value: unknown): Record<string, unknown> | undefined {
|
|
71
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
72
|
+
? value as Record<string, unknown>
|
|
73
|
+
: undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Conjunctions this module built, so a later collision extends them instead of nesting. */
|
|
77
|
+
const builtConjunctions = new WeakSet<object>();
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Both schemas apply. A conjunction built here gains one more member; a caller's own `allOf`
|
|
81
|
+
* schema stays a single member so its meaning is not spliced into ours.
|
|
82
|
+
*/
|
|
83
|
+
function conjoin(existing: unknown, schema: unknown): Record<string, unknown> {
|
|
84
|
+
const members = existing && typeof existing === "object" && builtConjunctions.has(existing)
|
|
85
|
+
? [...((existing as { allOf: unknown[] }).allOf)]
|
|
86
|
+
: [existing];
|
|
87
|
+
if (!members.includes(schema)) members.push(schema);
|
|
88
|
+
const conjunction = { allOf: members };
|
|
89
|
+
builtConjunctions.add(conjunction);
|
|
90
|
+
return conjunction;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* JSON Schema applies a `$ref` sibling's keywords alongside the referenced schema rather than
|
|
95
|
+
* replacing them. Spread would let a sibling that adds one parameter drop the referenced ones, so
|
|
96
|
+
* merge both `properties` maps, union `required`, and keep both constraints under `allOf` when a
|
|
97
|
+
* property appears on both sides.
|
|
98
|
+
*/
|
|
99
|
+
function mergeRefSiblings(
|
|
100
|
+
resolved: Record<string, unknown>,
|
|
101
|
+
siblings: Record<string, unknown>,
|
|
102
|
+
): Record<string, unknown> {
|
|
103
|
+
const merged: Record<string, unknown> = { ...resolved, ...siblings };
|
|
104
|
+
|
|
105
|
+
const resolvedProperties = asSchemaMap(resolved.properties);
|
|
106
|
+
const siblingProperties = asSchemaMap(siblings.properties);
|
|
107
|
+
if (resolvedProperties || siblingProperties) {
|
|
108
|
+
// Null prototype keeps a parameter named "__proto__" as data instead of replacing the prototype.
|
|
109
|
+
const properties: Record<string, unknown> = Object.create(null) as Record<string, unknown>;
|
|
110
|
+
for (const [name, schema] of Object.entries(resolvedProperties ?? {})) properties[name] = schema;
|
|
111
|
+
for (const [name, schema] of Object.entries(siblingProperties ?? {})) {
|
|
112
|
+
const existing = properties[name];
|
|
113
|
+
properties[name] = existing === undefined ? schema : conjoin(existing, schema);
|
|
114
|
+
}
|
|
115
|
+
merged.properties = properties;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const required = new Set<string>();
|
|
119
|
+
for (const source of [resolved.required, siblings.required]) {
|
|
120
|
+
if (!Array.isArray(source)) continue;
|
|
121
|
+
for (const item of source) if (typeof item === "string") required.add(item);
|
|
122
|
+
}
|
|
123
|
+
if (required.size > 0) merged.required = [...required];
|
|
124
|
+
else delete merged.required;
|
|
125
|
+
|
|
126
|
+
// The spread above lets a sibling's composition replace the referenced schema's. Both sides
|
|
127
|
+
// apply, so concatenate `allOf` and keep each side's `oneOf`/`anyOf` as its own `allOf` entry.
|
|
128
|
+
const allOf: unknown[] = [];
|
|
129
|
+
for (const source of [resolved, siblings]) if (Array.isArray(source.allOf)) allOf.push(...source.allOf);
|
|
130
|
+
for (const key of ["oneOf", "anyOf"] as const) {
|
|
131
|
+
if (Array.isArray(resolved[key]) && Array.isArray(siblings[key])) {
|
|
132
|
+
allOf.push({ [key]: resolved[key] }, { [key]: siblings[key] });
|
|
133
|
+
delete merged[key];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (allOf.length > 0) merged.allOf = allOf;
|
|
137
|
+
|
|
138
|
+
return merged;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Inline a local `#/...` reference so root-composition branches keep their definitions. Each
|
|
143
|
+
* alias hop spends the shared budget, so a long direct chain fails explicitly instead of
|
|
144
|
+
* recursing until the stack or allocation gives out.
|
|
145
|
+
*/
|
|
146
|
+
function dereferenceLocal(
|
|
147
|
+
node: unknown,
|
|
148
|
+
root: Record<string, unknown>,
|
|
149
|
+
seen: ReadonlySet<string>,
|
|
150
|
+
budget: ExpansionBudget,
|
|
151
|
+
): Record<string, unknown> | undefined {
|
|
152
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return undefined;
|
|
153
|
+
const record = node as Record<string, unknown>;
|
|
154
|
+
const ref = record.$ref;
|
|
155
|
+
if (typeof ref !== "string" || !ref.startsWith(LOCAL_REF_PREFIX) || seen.has(ref)) return record;
|
|
156
|
+
spend(budget);
|
|
157
|
+
const target = resolveLocalPointer(root, ref);
|
|
158
|
+
if (!target) return record;
|
|
159
|
+
const nextSeen = new Set(seen);
|
|
160
|
+
nextSeen.add(ref);
|
|
161
|
+
const resolved = dereferenceLocal(target, root, nextSeen, budget) ?? target;
|
|
162
|
+
const { $ref: _ignored, ...siblings } = record;
|
|
163
|
+
return mergeRefSiblings(resolved, siblings);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* `allOf` applies every branch, so a property met twice on an all-`allOf` path keeps both
|
|
168
|
+
* schemas under `allOf`. On a path through `oneOf`/`anyOf` the documented last-branch-wins
|
|
169
|
+
* flattening still applies. The same schema object reached twice (a shared `$ref`) is kept once.
|
|
170
|
+
*/
|
|
171
|
+
function collectProperty(
|
|
172
|
+
properties: Record<string, unknown>,
|
|
173
|
+
name: string,
|
|
174
|
+
schema: unknown,
|
|
175
|
+
conjunctive: boolean,
|
|
176
|
+
): void {
|
|
177
|
+
const existing = properties[name];
|
|
178
|
+
if (existing === schema) return;
|
|
179
|
+
properties[name] = conjunctive && existing !== undefined ? conjoin(existing, schema) : schema;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Flatten root-equivalent composition, including composition that a resolved `$ref` branch
|
|
184
|
+
* carries. Only a node standing where the root composition stands contributes; `properties`
|
|
185
|
+
* and nested property schemas are never traversed. `chain` holds the refs already inlined on
|
|
186
|
+
* this path, so a self- or mutually-recursive definition stops instead of recursing forever.
|
|
187
|
+
* `visits` bounds the total expansion so a shared acyclic graph cannot multiply work; exceeding
|
|
188
|
+
* it throws, and the adapter build then fails as an explicit invalid request.
|
|
189
|
+
*/
|
|
190
|
+
function collectRootComposition(
|
|
191
|
+
node: Record<string, unknown>,
|
|
192
|
+
root: Record<string, unknown>,
|
|
193
|
+
chain: ReadonlySet<string>,
|
|
194
|
+
mergeRequired: boolean,
|
|
195
|
+
properties: Record<string, unknown>,
|
|
196
|
+
required: Set<string>,
|
|
197
|
+
budget: ExpansionBudget,
|
|
198
|
+
): void {
|
|
199
|
+
for (const key of COMPOSITION_KEYS) {
|
|
200
|
+
const variants = node[key];
|
|
201
|
+
if (!Array.isArray(variants)) continue;
|
|
202
|
+
const branchMergesRequired = mergeRequired && key === "allOf";
|
|
203
|
+
for (const variant of variants) {
|
|
204
|
+
const record = asSchemaMap(variant);
|
|
205
|
+
if (!record) continue;
|
|
206
|
+
const ref = typeof record.$ref === "string" ? record.$ref : undefined;
|
|
207
|
+
if (ref && chain.has(ref)) continue;
|
|
208
|
+
spend(budget);
|
|
209
|
+
const resolved = dereferenceLocal(variant, root, chain, budget);
|
|
210
|
+
if (!resolved) continue;
|
|
211
|
+
const nextChain = ref ? new Set(chain).add(ref) : chain;
|
|
212
|
+
const branchProperties = asSchemaMap(resolved.properties);
|
|
213
|
+
if (branchProperties) {
|
|
214
|
+
for (const [name, schema] of Object.entries(branchProperties)) {
|
|
215
|
+
collectProperty(properties, name, schema, branchMergesRequired);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (branchMergesRequired && Array.isArray(resolved.required)) {
|
|
219
|
+
for (const item of resolved.required) if (typeof item === "string") required.add(item);
|
|
220
|
+
}
|
|
221
|
+
collectRootComposition(resolved, root, nextChain, branchMergesRequired, properties, required, budget);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function normalizeAnthropicInputSchema(schema: unknown): Record<string, unknown> {
|
|
227
|
+
const stripped = stripResponsesOnlyEncryptedMarker(schema);
|
|
228
|
+
const obj = stripped && typeof stripped === "object" && !Array.isArray(stripped)
|
|
229
|
+
? stripped as Record<string, unknown>
|
|
230
|
+
: {};
|
|
231
|
+
const budget: ExpansionBudget = { count: 0 };
|
|
232
|
+
const root = dereferenceLocal(obj, obj, new Set(), budget) ?? obj;
|
|
233
|
+
const hasRootComposition = COMPOSITION_KEYS.some(key => Array.isArray(root[key]));
|
|
234
|
+
const type = root.type;
|
|
235
|
+
const rootObjectType = type === "object" || (Array.isArray(type) && type.includes("object"));
|
|
236
|
+
|
|
237
|
+
if (!hasRootComposition) {
|
|
238
|
+
const normalized: Record<string, unknown> = rootObjectType && type === "object"
|
|
239
|
+
? { ...root }
|
|
240
|
+
: { ...root, type: "object" };
|
|
241
|
+
if (normalized.properties === undefined || normalized.properties === null) {
|
|
242
|
+
normalized.properties = {};
|
|
243
|
+
}
|
|
244
|
+
return normalized;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Null prototype keeps a parameter literally named "__proto__" as data instead of letting
|
|
248
|
+
// Object.assign replace this object's prototype and drop the parameter from JSON output.
|
|
249
|
+
const properties: Record<string, unknown> = Object.create(null) as Record<string, unknown>;
|
|
250
|
+
const required = new Set<string>();
|
|
251
|
+
if (root.properties && typeof root.properties === "object" && !Array.isArray(root.properties)) {
|
|
252
|
+
Object.assign(properties, root.properties as Record<string, unknown>);
|
|
253
|
+
}
|
|
254
|
+
if (Array.isArray(root.required)) {
|
|
255
|
+
for (const item of root.required) if (typeof item === "string") required.add(item);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
collectRootComposition(root, root, new Set(), true, properties, required, budget);
|
|
259
|
+
|
|
260
|
+
const normalized: Record<string, unknown> = {};
|
|
261
|
+
for (const [key, value] of Object.entries(root)) {
|
|
262
|
+
if (key === "oneOf" || key === "anyOf" || key === "allOf") continue;
|
|
263
|
+
if (key === "type" || key === "properties" || key === "required") continue;
|
|
264
|
+
normalized[key] = value;
|
|
265
|
+
}
|
|
266
|
+
normalized.type = "object";
|
|
267
|
+
normalized.properties = properties;
|
|
268
|
+
if (required.size > 0) normalized.required = [...required];
|
|
269
|
+
return normalized;
|
|
270
|
+
}
|
|
@@ -26,7 +26,7 @@ import { parseDataUrl } from "./image";
|
|
|
26
26
|
import { enforceAnthropicImageLimits } from "./anthropic-image-guard";
|
|
27
27
|
import { normalizeAnthropicImages } from "./anthropic-image-normalize";
|
|
28
28
|
import { normalizeAnthropicOutputSchema } from "./anthropic-output-schema";
|
|
29
|
-
import {
|
|
29
|
+
import { normalizeAnthropicInputSchema } from "./anthropic-input-schema";
|
|
30
30
|
import { identifyRoutedModel } from "./identity";
|
|
31
31
|
import { redactSecretString } from "../lib/redact";
|
|
32
32
|
import { CLAUDE_CODE_HEADERS, claudeCodeSessionId } from "./client-fingerprint";
|
|
@@ -972,68 +972,6 @@ function withAnthropicServerTools(tools: unknown[] | undefined, parsed: OcxParse
|
|
|
972
972
|
return [...(tools ?? []), ...serverTools.map(t => ({ ...t, cache_control: undefined }))];
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
-
function normalizeAnthropicInputSchema(schema: unknown): Record<string, unknown> {
|
|
976
|
-
const stripped = stripResponsesOnlyEncryptedMarker(schema);
|
|
977
|
-
const obj = stripped && typeof stripped === "object" && !Array.isArray(stripped)
|
|
978
|
-
? stripped as Record<string, unknown>
|
|
979
|
-
: {};
|
|
980
|
-
// Anthropic rejects root-level missing type and oneOf/anyOf/allOf in input_schema.
|
|
981
|
-
// Normalize the root only: ensure type:"object" + properties, flatten root composition
|
|
982
|
-
// while preserving nested schemas. Mirrors kiro-tools.ts ensureRootObjectType.
|
|
983
|
-
// Known limitation: Object.assign on branch properties means later branches overwrite
|
|
984
|
-
// earlier ones when the same property name appears with different schemas.
|
|
985
|
-
const compositionKeys = ["oneOf", "anyOf", "allOf"] as const;
|
|
986
|
-
const hasRootComposition = compositionKeys.some(key => Array.isArray(obj[key]));
|
|
987
|
-
const type = obj.type;
|
|
988
|
-
const rootObjectType = type === "object" || (Array.isArray(type) && type.includes("object"));
|
|
989
|
-
|
|
990
|
-
if (!hasRootComposition) {
|
|
991
|
-
const normalized: Record<string, unknown> = rootObjectType && type === "object"
|
|
992
|
-
? { ...obj }
|
|
993
|
-
: { ...obj, type: "object" };
|
|
994
|
-
if (normalized.properties === undefined || normalized.properties === null) {
|
|
995
|
-
normalized.properties = {};
|
|
996
|
-
}
|
|
997
|
-
return normalized;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
const properties: Record<string, unknown> = {};
|
|
1001
|
-
const required = new Set<string>();
|
|
1002
|
-
if (obj.properties && typeof obj.properties === "object" && !Array.isArray(obj.properties)) {
|
|
1003
|
-
Object.assign(properties, obj.properties as Record<string, unknown>);
|
|
1004
|
-
}
|
|
1005
|
-
if (Array.isArray(obj.required)) {
|
|
1006
|
-
for (const item of obj.required) if (typeof item === "string") required.add(item);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
for (const key of compositionKeys) {
|
|
1010
|
-
const variants = obj[key];
|
|
1011
|
-
if (!Array.isArray(variants)) continue;
|
|
1012
|
-
const mergeRequired = key === "allOf";
|
|
1013
|
-
for (const variant of variants) {
|
|
1014
|
-
if (!variant || typeof variant !== "object" || Array.isArray(variant)) continue;
|
|
1015
|
-
const v = variant as Record<string, unknown>;
|
|
1016
|
-
if (v.properties && typeof v.properties === "object" && !Array.isArray(v.properties)) {
|
|
1017
|
-
Object.assign(properties, v.properties as Record<string, unknown>);
|
|
1018
|
-
}
|
|
1019
|
-
if (mergeRequired && Array.isArray(v.required)) {
|
|
1020
|
-
for (const item of v.required) if (typeof item === "string") required.add(item);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
const normalized: Record<string, unknown> = {};
|
|
1026
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
1027
|
-
if (key === "oneOf" || key === "anyOf" || key === "allOf") continue;
|
|
1028
|
-
if (key === "type" || key === "properties" || key === "required") continue;
|
|
1029
|
-
normalized[key] = value;
|
|
1030
|
-
}
|
|
1031
|
-
normalized.type = "object";
|
|
1032
|
-
normalized.properties = properties;
|
|
1033
|
-
if (required.size > 0) normalized.required = [...required];
|
|
1034
|
-
return normalized;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
975
|
export function createAnthropicAdapter(provider: OcxProviderConfig, cacheRetention?: "none" | "short" | "long"): ProviderAdapter {
|
|
1038
976
|
const isOAuth = provider.authMode === "oauth";
|
|
1039
977
|
const toolNames = buildToolNameTransforms(provider);
|
|
@@ -39,6 +39,12 @@ export const MAX_HELD_TOOL_TEXT_BYTES = 64 * 1024;
|
|
|
39
39
|
export interface CommandCodeDeclaredTool {
|
|
40
40
|
freeform: boolean;
|
|
41
41
|
schema: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* The caller's original schema when `schema` is a normalized wire view of it. The wire view
|
|
44
|
+
* flattens root alternatives lossily, so restored arguments must satisfy both; a declared
|
|
45
|
+
* schema the restored-value validator cannot evaluate (a `$ref`, say) fails closed.
|
|
46
|
+
*/
|
|
47
|
+
declaredSchema?: Record<string, unknown>;
|
|
42
48
|
}
|
|
43
49
|
export type CommandCodeDeclaredTools = ReadonlyMap<string, CommandCodeDeclaredTool>;
|
|
44
50
|
|
|
@@ -226,7 +232,9 @@ export function salvagedArguments(markup: ToolCallMarkup, tool: CommandCodeDecla
|
|
|
226
232
|
output[key] = decoded;
|
|
227
233
|
}
|
|
228
234
|
if (required.some(key => !Object.hasOwn(output, key))) return undefined;
|
|
229
|
-
|
|
235
|
+
if (!validatesRestoredValue(output, tool.schema)) return undefined;
|
|
236
|
+
if (tool.declaredSchema !== undefined && !validatesRestoredValue(output, tool.declaredSchema)) return undefined;
|
|
237
|
+
return JSON.stringify(output);
|
|
230
238
|
}
|
|
231
239
|
|
|
232
240
|
interface TextBlock {
|
|
@@ -14,6 +14,7 @@ import { configuredReasoningEfforts, modelRecordValue } from "../reasoning-effor
|
|
|
14
14
|
import { commandCodeReasoningEfforts, refreshCommandCodeReasoningEfforts } from "../providers/command-code-efforts";
|
|
15
15
|
import { identifyRoutedModel } from "./identity";
|
|
16
16
|
import { buildNonOpenAIToolCatalogNudgeForTools } from "./tool-catalog-nudge";
|
|
17
|
+
import { normalizeAnthropicInputSchema } from "./anthropic-input-schema";
|
|
17
18
|
import { parseDataUrl } from "./image";
|
|
18
19
|
import { createAdapterPhysicalSend } from "./physical-send";
|
|
19
20
|
import { SendBudgetExhaustedError } from "../lib/upstream-retry";
|
|
@@ -26,10 +27,25 @@ import {
|
|
|
26
27
|
import { CommandCodeToolTextFilter, type CommandCodeDeclaredTools } from "./command-code-tool-text";
|
|
27
28
|
import { EMPTY_COMMAND_CODE_PROJECT_CONTEXT, loadCommandCodeProjectContext } from "./command-code-project-context";
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Text-call recovery matches markup against the schema the model was shown (`wireTools`), so a
|
|
32
|
+
* root-composed tool keeps the top-level `properties` its markup names. Definitions are dropped
|
|
33
|
+
* because the restored-value validator accepts no `$ref`: a reference left in the normalized
|
|
34
|
+
* schema still fails closed there. The original schema is validated too (`declaredSchema`),
|
|
35
|
+
* because the wire view flattens root alternatives and would otherwise admit calls the tool
|
|
36
|
+
* itself rejects.
|
|
37
|
+
*/
|
|
38
|
+
function recoverySchema(tool: OcxTool): Record<string, unknown> {
|
|
39
|
+
const { $defs: _defs, definitions: _definitions, ...schema } = normalizeAnthropicInputSchema(tool.parameters);
|
|
40
|
+
return schema;
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
function declaredTools(tools: OcxTool[]): CommandCodeDeclaredTools {
|
|
30
44
|
return new Map(tools.map(tool => [
|
|
31
45
|
namespacedToolName(tool.namespace, tool.name),
|
|
32
|
-
|
|
46
|
+
tool.freeform === true
|
|
47
|
+
? { freeform: true, schema: tool.parameters }
|
|
48
|
+
: { freeform: false, schema: recoverySchema(tool), declaredSchema: tool.parameters },
|
|
33
49
|
]));
|
|
34
50
|
}
|
|
35
51
|
|
|
@@ -207,7 +223,7 @@ function wireTools(tools: OcxTool[]): Array<Record<string, unknown>> {
|
|
|
207
223
|
return tools.map(tool => ({
|
|
208
224
|
name: namespacedToolName(tool.namespace, tool.name),
|
|
209
225
|
description: tool.description,
|
|
210
|
-
input_schema: tool.parameters,
|
|
226
|
+
input_schema: normalizeAnthropicInputSchema(tool.parameters),
|
|
211
227
|
}));
|
|
212
228
|
}
|
|
213
229
|
|
|
@@ -663,6 +663,16 @@ const MAX_TOOL_DESC_LEN = 6998;
|
|
|
663
663
|
* bullet). Matching is flexible on case, whitespace, the open-source hyphen,
|
|
664
664
|
* and the Don't apostrophe; each rewrite swaps one required word.
|
|
665
665
|
*
|
|
666
|
+
* The three #8558 entries (Claude Code system prompt) are whole sentences
|
|
667
|
+
* Claude Code itself sends in its system prompt: "You are a Claude agent,
|
|
668
|
+
* built on Anthropic's Claude Agent SDK", the dual-use security-tools bullet,
|
|
669
|
+
* and "Claude Code is available as a CLI in the terminal…". Each one alone
|
|
670
|
+
* was refused with `permission_denied` against a live account, every
|
|
671
|
+
* sub-phrase passed, and lowercasing, a missing comma or a doubled space was
|
|
672
|
+
* still refused — so they match like the Codex entries (case-insensitive,
|
|
673
|
+
* flexible whitespace, optional commas) and every rewrite keeps the original
|
|
674
|
+
* authorization/safety meaning.
|
|
675
|
+
*
|
|
666
676
|
* Scope note: by default the sanitizer only ever touches *instruction
|
|
667
677
|
* surfaces* — tool descriptions and the #2 system prompt, where a
|
|
668
678
|
* meaning-preserving reword loses nothing. Data fields — message text (#3),
|
|
@@ -703,6 +713,20 @@ const COGNITION_BLOCKLIST_REWRITES: ReadonlyArray<[RegExp, string]> = [
|
|
|
703
713
|
/\bDon[\u0060'’]?t\s+output\s+ANSI\s+escape\s+codes\s+directly\s*[—-]\s*the\s+CLI\s+renderer\s+applies\s+them\b/gi,
|
|
704
714
|
"Don’t emit ANSI escape codes directly — the CLI renderer applies them",
|
|
705
715
|
],
|
|
716
|
+
// #8558: Claude Code system prompt. Matched like the Codex entries:
|
|
717
|
+
// case-insensitive, flexible whitespace, optional commas.
|
|
718
|
+
[
|
|
719
|
+
/\bYou\s+are\s+a\s+Claude\s+agent,?\s+built\s+on\s+Anthropic['’]?s\s+Claude\s+Agent\s+SDK\b/gi,
|
|
720
|
+
"You are a Claude agent, built on Anthropic's Claude Agent Toolkit",
|
|
721
|
+
],
|
|
722
|
+
[
|
|
723
|
+
/\bDual-use\s+security\s+tools\s+\(C2\s+frameworks,?\s+credential\s+testing,?\s+exploit\s+development\)\s+require\s+clear\s+authorization\s+context:\s+pentesting\s+engagements,?\s+CTF\s+competitions,?\s+security\s+research,?\s+or\s+defensive\s+use\s+cases\b/gi,
|
|
724
|
+
"Dual-purpose security tools (C2 frameworks, credential testing, exploit development) need clear authorization context: pentesting engagements, CTF competitions, security research, or defensive use cases",
|
|
725
|
+
],
|
|
726
|
+
[
|
|
727
|
+
/\bClaude\s+Code\s+is\s+available\s+as\s+a\s+CLI\s+in\s+the\s+terminal,?\s+desktop\s+app\s+\(Mac\/Windows\),?\s+web\s+app\s+\(claude\.ai\/code\),?\s+and\s+IDE\s+extensions\s+\(VS\s+Code,?\s+JetBrains\)/gi,
|
|
728
|
+
"Claude Code ships as a CLI in the terminal, desktop app (Mac/Windows), web app (claude.ai/code), and IDE extensions (VS Code, JetBrains)",
|
|
729
|
+
],
|
|
706
730
|
];
|
|
707
731
|
|
|
708
732
|
function sanitizeTextForCognition(text: string): string {
|
|
@@ -29,6 +29,9 @@ export const DEVIN_STATIC_MODELS = [
|
|
|
29
29
|
"gpt-6-1-sol",
|
|
30
30
|
// 261027 preemptive: GPT-6.1 Terra (mirrors Devin's GPT-6.1 Sol seed; uid unverified).
|
|
31
31
|
"gpt-6-1-terra",
|
|
32
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra (mirror Devin's GPT-6.1 Sol seed; uids unverified).
|
|
33
|
+
"gpt-6-2-sol",
|
|
34
|
+
"gpt-6-2-astra",
|
|
32
35
|
"claude-opus-4-8",
|
|
33
36
|
// 261110: Claude Fable 5.2 (docs.devin.ai/desktop/models; uid claude-fable-5-2-<effort>).
|
|
34
37
|
"claude-fable-5-2",
|
|
@@ -58,7 +61,11 @@ export const DEVIN_STATIC_MODELS = [
|
|
|
58
61
|
* number over from the model's original vendor.
|
|
59
62
|
*/
|
|
60
63
|
export const DEVIN_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
61
|
-
|
|
64
|
+
// 261112: live catalog context_window 850_000; a real turn completed at 754,971 total.
|
|
65
|
+
"swe-2": 850_000,
|
|
66
|
+
// 261112: live catalog also advertises 850_000, but observed turns terminate at
|
|
67
|
+
// totalTokens 262,140 -- the serving bound is ~256KiB, not the catalog figure.
|
|
68
|
+
"swe-2-flash": 262_000,
|
|
62
69
|
"swe-1-7": 262_000,
|
|
63
70
|
"swe-1-7-lightning": 202_752,
|
|
64
71
|
"swe-1-6": 200_000,
|
|
@@ -72,6 +79,9 @@ export const DEVIN_MODEL_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
72
79
|
"gpt-6-1-sol": 1_000_000,
|
|
73
80
|
// 261027 preemptive: GPT-6.1 Terra (unmeasured; mirrors Devin's GPT-6.1 Sol window).
|
|
74
81
|
"gpt-6-1-terra": 1_000_000,
|
|
82
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra (unmeasured; mirror Devin's GPT-6.1 Sol window).
|
|
83
|
+
"gpt-6-2-sol": 1_000_000,
|
|
84
|
+
"gpt-6-2-astra": 1_000_000,
|
|
75
85
|
"claude-opus-4-8": 1_000_000,
|
|
76
86
|
// 260923: read from the live catalog (devin/claude-opus-5-5 context_length 1_000_000).
|
|
77
87
|
"claude-opus-5-5": 1_000_000,
|
|
@@ -30,6 +30,9 @@ export const KIRO_NATIVE_EFFORT_FIELDS: Record<string, "reasoning" | "output_con
|
|
|
30
30
|
"gpt-6.1-sol": "reasoning",
|
|
31
31
|
// 261027 preemptive: GPT-6.1 Terra (mirrors GPT-6.1 Sol; see kiro-models.ts).
|
|
32
32
|
"gpt-6.1-terra": "reasoning",
|
|
33
|
+
// 261118 preemptive: GPT-6.2 Sol and Astra (mirror GPT-6.1 Sol; see kiro-models.ts).
|
|
34
|
+
"gpt-6.2-sol": "reasoning",
|
|
35
|
+
"gpt-6.2-astra": "reasoning",
|
|
33
36
|
// Claude models whose output_config.effort was accepted by a live probe on 2026-11-07, at every
|
|
34
37
|
// ladder rung except xhigh on the 4.6 pair. Haiku 4.5, Opus 4.5 and Sonnet 4.5 reject the field
|
|
35
38
|
// (HTTP 400). The probe covered these nine ids individually; no other Claude id was measured, so
|
|
@@ -89,10 +89,16 @@ function rejectAllExcept(accepted: readonly string[]): ReadonlySet<string> {
|
|
|
89
89
|
// that total as 28, one fewer than the 29 keys its own list names; the accepted keys, not the
|
|
90
90
|
// stated count, are what the exception below encodes. Its two 5.5 probes explicitly name only
|
|
91
91
|
// pattern and maximum.
|
|
92
|
+
// opus-5.5 also keeps the keys the Claude Desktop and Claude Code catalogs carry: five days of
|
|
93
|
+
// production traffic sent all of them unstripped, 10,565 HTTP 200 and no ValidationException.
|
|
92
94
|
// Other keywords and model ids retain the default strip until supported by evidence.
|
|
95
|
+
const KIRO_OPUS_55_ACCEPTED_SCHEMA_KEYS = [
|
|
96
|
+
"$schema", "additionalProperties", "pattern", "format", "minLength", "maxLength",
|
|
97
|
+
"minimum", "maximum", "exclusiveMinimum", "minItems", "maxItems", "propertyNames",
|
|
98
|
+
] as const;
|
|
93
99
|
const KIRO_SCHEMA_KEY_EXCEPTIONS: ReadonlyMap<string, ReadonlySet<string>> = new Map([
|
|
94
100
|
["claude-opus-4.5", NO_SCHEMA_KEYS],
|
|
95
|
-
["claude-opus-5.5", rejectAllExcept(
|
|
101
|
+
["claude-opus-5.5", rejectAllExcept(KIRO_OPUS_55_ACCEPTED_SCHEMA_KEYS)],
|
|
96
102
|
["claude-sonnet-5.5", rejectAllExcept(["pattern", "maximum"])],
|
|
97
103
|
]);
|
|
98
104
|
|
|
@@ -282,14 +288,13 @@ export function convertKiroToolContext(
|
|
|
282
288
|
const filled: unknown[] = [];
|
|
283
289
|
for (const entry of candidates) {
|
|
284
290
|
if (entry === reserved) continue;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
) break;
|
|
291
|
+
if (!unbounded) {
|
|
292
|
+
// Measure the projected FINAL array only while enforcing a budget. Repeatedly copying
|
|
293
|
+
// the admitted prefix would make an unbounded catalog quadratic even without measuring it.
|
|
294
|
+
const projected = reserved ? [...filled, entry.converted, reserved.converted] : [...filled, entry.converted];
|
|
295
|
+
if (projected.length > MAX_KIRO_TOOL_COUNT
|
|
296
|
+
|| serializedToolCatalogBytes(projected) > MAX_KIRO_TOOL_CATALOG_BYTES) break;
|
|
297
|
+
}
|
|
293
298
|
filled.push(entry.converted);
|
|
294
299
|
admitted.add(entry.index);
|
|
295
300
|
}
|
|
@@ -360,13 +360,15 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
|
|
|
360
360
|
outBody = injectXaiResponsesXSearch(outBody, provider, parsed._replayPrefixLen);
|
|
361
361
|
// xAI, Meta, Azure and Kimi Code (#8075) answer 400 for `output.encrypted_content`
|
|
362
362
|
// instead of ignoring it; Codex Desktop asks for it on every turn (#7878).
|
|
363
|
+
// Go multiplexes backends with different include support (#8702). Use its exact
|
|
364
|
+
// destination's common compatibility policy rather than a model-name allowlist.
|
|
363
365
|
// Azure also rejects this exact include entry, including on plain Responses routes.
|
|
364
366
|
const isAzureResponses = provider.adapter === "azure" || provider.adapter === "azure-openai"
|
|
365
367
|
|| new URL(url).hostname.toLowerCase().endsWith(".openai.azure.com");
|
|
366
368
|
const arkKimi = !forward && provider.arkKimiResponsesModels?.includes(parsed.modelId);
|
|
367
369
|
if (arkKimi) outBody = stripArkKimiOrphanCipher(outBody);
|
|
368
370
|
if (isXaiResponsesDestination(provider) || isMetaAiResponsesDestination(url) || isAzureResponses
|
|
369
|
-
|| isKimiCodingResponsesHttpsUrl(url) || arkKimi) {
|
|
371
|
+
|| isKimiCodingResponsesHttpsUrl(url) || arkKimi || isOpenCodeGoResponsesUrl(url)) {
|
|
370
372
|
outBody = stripUnsupportedOutputInclude(outBody);
|
|
371
373
|
}
|
|
372
374
|
// xAI and explicitly classified compatible gateways reject these OpenAI web_search
|
|
@@ -9,6 +9,7 @@ import { stripOpenAiOnlyWebSearchFields } from "./web-search";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Codex requests output.encrypted_content, which xAI, Meta, Azure and Kimi Code reject with HTTP 400.
|
|
12
|
+
* OpenCode Go uses the same compatibility policy because some of its Responses backends reject it.
|
|
12
13
|
* The caller gates this on the destination. Preserve reasoning.encrypted_content
|
|
13
14
|
* for stateless replay and leave unknown or malformed values for upstream validation.
|
|
14
15
|
*/
|
|
@@ -119,7 +119,7 @@ export function buildNonOpenAIToolCatalogNudgeFromNames(
|
|
|
119
119
|
"Valid tool names for this turn are exactly " + quoteNames(names) + ".",
|
|
120
120
|
"These listed names are the complete top-level tool-call surface for this turn.",
|
|
121
121
|
"Call only listed names with their listed argument keys; do not invent, translate, or rename tools.",
|
|
122
|
-
"
|
|
122
|
+
"References to other functions in text do not add callable functions.",
|
|
123
123
|
verifiedCodeModeExecName
|
|
124
124
|
? "`" + verifiedCodeModeExecName + "` is Codex code mode: its body is JavaScript evaluated in a V8 isolate. Nested helpers are called INSIDE that body as `await tools.<name>(...)`, for example `await tools.exec_command({cmd: \"ls\"})` or `await tools.codex_app__list_threads({})`. Absence from the top-level catalog or from `" + verifiedCodeModeExecName + "`'s description is not absence: deferred helpers stay callable on `tools.<name>`. Discover them from the isolate global `ALL_TOOLS`, not `tools.ALL_TOOLS`. Do not skip an available nested helper because it is omitted from the listed top-level names. " + CODE_MODE_RESULT_ECHO_SENTENCE + " Nested `tools.apply_patch(input)` is host-executed: the string must begin exactly with `*** Begin Patch` and end with `*** End Patch`, each marker line being three asterisks, one space, the two words, then end of line with no further asterisks. OpenCodex does not rewrite JavaScript inside exec, so extra asterisks on a marker line are rejected by Codex before the file is touched. " + CODE_MODE_HOST_CONTRACT_SENTENCE
|
|
125
125
|
: "If a listed tool exposes nested helpers such as a tools.* API, call the listed parent tool and use those helpers only inside that tool's input.",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAdapter } from "../adapters/base";
|
|
2
|
-
import { isAllowedToolChoice, type AdapterEvent, type OcxAssistantContentPart, type OcxContentPart, type OcxMessage, type OcxParsedRequest, type OcxTool } from "../types";
|
|
2
|
+
import { isAllowedToolChoice, toolRestrictsCallers, type AdapterEvent, type OcxAssistantContentPart, type OcxContentPart, type OcxMessage, type OcxParsedRequest, type OcxTool } from "../types";
|
|
3
3
|
import { isRec, type Rec } from "./inbound-records";
|
|
4
4
|
import { readClientToolDiscovery } from "./inbound-tool-loading";
|
|
5
5
|
|
|
@@ -62,6 +62,9 @@ function appendText(content: string | OcxContentPart[], text: string): string |
|
|
|
62
62
|
export function projectChatToolDispatch(parsed: OcxParsedRequest, raw: Rec): ChatToolDispatchProjection | null {
|
|
63
63
|
const tools = parsed.context.tools;
|
|
64
64
|
if (!Array.isArray(tools)) return null;
|
|
65
|
+
// Keep caller restrictions visible to the final adapter guard; the dispatcher cannot
|
|
66
|
+
// preserve them by moving a restricted declaration into ToolSearch result text.
|
|
67
|
+
if (tools.some(toolRestrictsCallers)) return null;
|
|
65
68
|
|
|
66
69
|
const declared = new Map<string, OcxTool>();
|
|
67
70
|
for (const tool of tools) {
|