@claudexor/schema 2.1.2 → 3.0.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.
Files changed (174) hide show
  1. package/dist/agent-capabilities.d.ts +32 -24
  2. package/dist/agent-capabilities.d.ts.map +1 -1
  3. package/dist/agent-capabilities.js +20 -11
  4. package/dist/agent-capabilities.js.map +1 -1
  5. package/dist/apply-eligibility.d.ts +166 -0
  6. package/dist/apply-eligibility.d.ts.map +1 -1
  7. package/dist/apply-eligibility.js +63 -2
  8. package/dist/apply-eligibility.js.map +1 -1
  9. package/dist/attachment.d.ts +5 -5
  10. package/dist/budget.d.ts +4 -4
  11. package/dist/config.d.ts +59 -41
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +16 -6
  14. package/dist/config.js.map +1 -1
  15. package/dist/context.d.ts +6 -6
  16. package/dist/control-operation-responses.d.ts +190 -97
  17. package/dist/control-operation-responses.d.ts.map +1 -1
  18. package/dist/control-operation-responses.js +14 -1
  19. package/dist/control-operation-responses.js.map +1 -1
  20. package/dist/control-run-detail.d.ts +380 -215
  21. package/dist/control-run-detail.d.ts.map +1 -1
  22. package/dist/control-run-detail.js +54 -8
  23. package/dist/control-run-detail.js.map +1 -1
  24. package/dist/control-thread-apply.d.ts +5 -5
  25. package/dist/control-trust.d.ts +6 -6
  26. package/dist/control.d.ts +769 -323
  27. package/dist/control.d.ts.map +1 -1
  28. package/dist/control.js +164 -71
  29. package/dist/control.js.map +1 -1
  30. package/dist/credential-profile.d.ts +400 -1
  31. package/dist/credential-profile.d.ts.map +1 -1
  32. package/dist/credential-profile.js +109 -4
  33. package/dist/credential-profile.js.map +1 -1
  34. package/dist/decision.d.ts +78 -14
  35. package/dist/decision.d.ts.map +1 -1
  36. package/dist/decision.js +53 -20
  37. package/dist/decision.js.map +1 -1
  38. package/dist/delivery.d.ts +3 -3
  39. package/dist/delivery.js +1 -1
  40. package/dist/delivery.js.map +1 -1
  41. package/dist/events.d.ts +32 -6
  42. package/dist/events.d.ts.map +1 -1
  43. package/dist/events.js +46 -11
  44. package/dist/events.js.map +1 -1
  45. package/dist/gate.d.ts +4 -4
  46. package/dist/gate.d.ts.map +1 -1
  47. package/dist/gate.js +2 -2
  48. package/dist/gate.js.map +1 -1
  49. package/dist/harness.d.ts +137 -47
  50. package/dist/harness.d.ts.map +1 -1
  51. package/dist/harness.js +65 -16
  52. package/dist/harness.js.map +1 -1
  53. package/dist/index.d.ts +4 -3
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4 -3
  56. package/dist/index.js.map +1 -1
  57. package/dist/operation.d.ts +66 -7
  58. package/dist/operation.d.ts.map +1 -1
  59. package/dist/operation.js +29 -2
  60. package/dist/operation.js.map +1 -1
  61. package/dist/output-schema.d.ts +40 -0
  62. package/dist/output-schema.d.ts.map +1 -0
  63. package/dist/output-schema.js +109 -0
  64. package/dist/output-schema.js.map +1 -0
  65. package/dist/plan.d.ts +206 -0
  66. package/dist/plan.d.ts.map +1 -0
  67. package/dist/plan.js +107 -0
  68. package/dist/plan.js.map +1 -0
  69. package/dist/primitives.d.ts +14 -10
  70. package/dist/primitives.d.ts.map +1 -1
  71. package/dist/primitives.js +14 -11
  72. package/dist/primitives.js.map +1 -1
  73. package/dist/project.d.ts +75 -0
  74. package/dist/project.d.ts.map +1 -1
  75. package/dist/project.js +17 -0
  76. package/dist/project.js.map +1 -1
  77. package/dist/quota.d.ts +119 -0
  78. package/dist/quota.d.ts.map +1 -1
  79. package/dist/quota.js +22 -0
  80. package/dist/quota.js.map +1 -1
  81. package/dist/raw.d.ts +4 -4
  82. package/dist/readiness.d.ts +14 -7
  83. package/dist/readiness.d.ts.map +1 -1
  84. package/dist/run-strategy.d.ts +17 -0
  85. package/dist/run-strategy.d.ts.map +1 -0
  86. package/dist/run-strategy.js +47 -0
  87. package/dist/run-strategy.js.map +1 -0
  88. package/dist/setup.d.ts +160 -160
  89. package/dist/status-projection.d.ts +78 -0
  90. package/dist/status-projection.d.ts.map +1 -0
  91. package/dist/status-projection.js +171 -0
  92. package/dist/status-projection.js.map +1 -0
  93. package/dist/task.d.ts +48 -316
  94. package/dist/task.d.ts.map +1 -1
  95. package/dist/task.js +3 -60
  96. package/dist/task.js.map +1 -1
  97. package/dist/telemetry.d.ts +89 -89
  98. package/dist/thread.d.ts +167 -32
  99. package/dist/thread.d.ts.map +1 -1
  100. package/dist/thread.js +92 -28
  101. package/dist/thread.js.map +1 -1
  102. package/dist/tool-ref.d.ts +1 -1
  103. package/generated/AgentCapabilityCatalog.schema.json +4 -6
  104. package/generated/ApplyEligibility.schema.json +1 -1
  105. package/generated/BudgetLease.schema.json +1 -2
  106. package/generated/ConformanceReport.schema.json +1 -2
  107. package/generated/ContinuityDisclosure.schema.json +74 -0
  108. package/generated/ControlApplyRequest.schema.json +1 -2
  109. package/generated/ControlCredentialProfileUpdateRequest.schema.json +20 -0
  110. package/generated/ControlCredentialProfileUpdateResponse.schema.json +142 -0
  111. package/generated/ControlCredentialProfilesResponse.schema.json +126 -2
  112. package/generated/ControlDeliveryResponse.schema.json +0 -1
  113. package/generated/ControlHandshakeResponse.schema.json +31 -3
  114. package/generated/ControlHarnessListResponse.schema.json +11 -6
  115. package/generated/ControlHarnessSettingsPatch.schema.json +4 -0
  116. package/generated/ControlOperationCatalog.schema.json +16 -1
  117. package/generated/ControlOperationDescriptor.schema.json +15 -0
  118. package/generated/ControlProject.schema.json +35 -0
  119. package/generated/ControlProjectListResponse.schema.json +35 -0
  120. package/generated/ControlProjectOutputsResponse.schema.json +57 -0
  121. package/generated/ControlQueuedRunInfo.schema.json +2 -11
  122. package/generated/ControlQuotaResponse.schema.json +42 -0
  123. package/generated/ControlRunAgainDraft.schema.json +37 -35
  124. package/generated/ControlRunDecisionRequest.schema.json +0 -1
  125. package/generated/ControlRunDetail.schema.json +305 -213
  126. package/generated/ControlRunListResponse.schema.json +88 -27
  127. package/generated/ControlRunStartRequest.schema.json +37 -35
  128. package/generated/ControlRunStartResponse.schema.json +2 -11
  129. package/generated/ControlRunSummary.schema.json +88 -27
  130. package/generated/ControlSettingsSnapshot.schema.json +6 -11
  131. package/generated/ControlSettingsUpdateRequest.schema.json +5 -10
  132. package/generated/ControlThread.schema.json +21 -3
  133. package/generated/ControlThreadApplyResponse.schema.json +0 -1
  134. package/generated/ControlThreadCreateRequest.schema.json +12 -3
  135. package/generated/ControlThreadDetail.schema.json +174 -16
  136. package/generated/ControlThreadListResponse.schema.json +60 -3
  137. package/generated/ControlThreadTurnRequest.schema.json +40 -34
  138. package/generated/ControlThreadUpdateRequest.schema.json +19 -0
  139. package/generated/DecisionRecord.schema.json +73 -33
  140. package/generated/GateResult.schema.json +1 -2
  141. package/generated/GlobalConfig.schema.json +7 -12
  142. package/generated/HarnessManifest.schema.json +11 -6
  143. package/generated/HarnessStatusDto.schema.json +11 -6
  144. package/generated/LaneCheckpoint.schema.json +59 -0
  145. package/generated/McpRunHandleResult.schema.json +234 -0
  146. package/generated/McpRunToolResult.schema.json +124 -2
  147. package/generated/RoutePrimaryDivergedPayload.schema.json +56 -0
  148. package/generated/RunEvent.schema.json +10 -5
  149. package/generated/RunTelemetry.schema.json +2 -4
  150. package/generated/TaskContract.schema.json +3 -135
  151. package/generated/Thread.schema.json +21 -3
  152. package/generated/ThreadTurn.schema.json +88 -0
  153. package/package.json +2 -2
  154. package/dist/control-spec.d.ts +0 -592
  155. package/dist/control-spec.d.ts.map +0 -1
  156. package/dist/control-spec.js +0 -85
  157. package/dist/control-spec.js.map +0 -1
  158. package/dist/orchestrate.d.ts +0 -556
  159. package/dist/orchestrate.d.ts.map +0 -1
  160. package/dist/orchestrate.js +0 -356
  161. package/dist/orchestrate.js.map +0 -1
  162. package/dist/spec.d.ts +0 -678
  163. package/dist/spec.d.ts.map +0 -1
  164. package/dist/spec.js +0 -186
  165. package/dist/spec.js.map +0 -1
  166. package/generated/ControlSpecAnswersRequest.schema.json +0 -74
  167. package/generated/ControlSpecQuestionsRequest.schema.json +0 -206
  168. package/generated/ControlSpecSession.schema.json +0 -249
  169. package/generated/ControlSpecSessionListResponse.schema.json +0 -261
  170. package/generated/OrchestrateContract.schema.json +0 -119
  171. package/generated/OrchestratePlan.schema.json +0 -264
  172. package/generated/OrchestratePlanProgress.schema.json +0 -164
  173. package/generated/SessionReboundLineage.schema.json +0 -73
  174. package/generated/SpecPack.schema.json +0 -483
@@ -1,356 +0,0 @@
1
- import { z } from "zod";
2
- import { zodToJsonSchema } from "zod-to-json-schema";
3
- import { Id, ModeKind } from "./primitives.js";
4
- import { RunStatus } from "./decision.js";
5
- import { PaidBudget } from "./budget.js";
6
- /**
7
- * The autonomous `orchestrate` planner. It is NOT a privileged harness: it is
8
- * an intent routed like reviewers (doctor-ok + capability + quota headroom),
9
- * sticky per thread, overridable. Its tool belt maps 1:1 onto existing engine
10
- * entry points; it never grows its own business logic.
11
- *
12
- * Detailed per-tool input/output schemas are introduced alongside their wiring
13
- * (staged-field discipline); this module fixes the tool vocabulary + contract.
14
- */
15
- export const OrchestrateToolName = z
16
- .enum(["start_run", "race", "status", "answer_question", "apply", "review"])
17
- .describe("Tool in the orchestrate planner's belt, mapping 1:1 onto engine entry points: start_run, race (best-of-N), status, answer_question, apply, and review.");
18
- /** How much the planner may act without confirmation. */
19
- export const OrchestrateAutonomy = z
20
- .enum(["suggest", "auto_safe", "auto_full"])
21
- .describe("How much the orchestrate planner may act without confirmation: suggest (user executes the plan), auto_safe (auto-runs only provably safe steps), auto_full (auto-runs everything).");
22
- const OrchestrateStepRequirement = {
23
- required: z
24
- .boolean()
25
- .default(true)
26
- .describe("Whether parent success requires this step to succeed."),
27
- };
28
- export const DEFAULT_ORCHESTRATE_TOOL_BELT = [
29
- "start_run",
30
- "race",
31
- "status",
32
- "apply",
33
- "review",
34
- // `answer_question` is intentionally NOT offered by default: safe sub-runs are
35
- // non-interactive, so an autonomously-executed plan has no pending sub-run
36
- // interaction to answer. It stays in the vocabulary + executor (honest skip) for
37
- // future interactive sub-runs; a caller can add it to a custom tool_belt.
38
- ];
39
- export const OrchestrateContract = z
40
- .object({
41
- thread_id: Id.describe("Thread the orchestration belongs to."),
42
- goal: z.string().describe("The user goal the planner is orchestrating toward."),
43
- tool_belt: z
44
- .array(OrchestrateToolName)
45
- .default([...DEFAULT_ORCHESTRATE_TOOL_BELT])
46
- .describe("Tools the planner may use this run."),
47
- budget: z
48
- .object({
49
- paid_budget: PaidBudget.default({ kind: "unlimited" }),
50
- max_tool_calls: z
51
- .number()
52
- .int()
53
- .positive()
54
- .nullable()
55
- .default(null)
56
- .describe("Maximum tool calls the executor will run; null = no cap."),
57
- })
58
- .default({})
59
- .describe("Budget limits for the orchestration."),
60
- autonomy: OrchestrateAutonomy.default("suggest"),
61
- })
62
- .describe("Contract for one orchestrate run: goal, allowed tool belt, budget, and autonomy level.");
63
- /**
64
- * Data-driven tool-risk classification. SAFE = provably no live-tree mutation
65
- * (isolated envelope sub-runs or pure reads); RISKY = mutates the live tree.
66
- * This is the SSOT the executor classifies against — never a hardcoded
67
- * enum-in-logic switch. `apply` is the only mutating tool.
68
- */
69
- export const TOOL_RISK = {
70
- start_run: "safe",
71
- race: "safe",
72
- status: "safe",
73
- answer_question: "safe",
74
- review: "safe",
75
- apply: "risky",
76
- };
77
- /**
78
- * Classify a tool's risk, FAIL-CLOSED: any unknown/undeclared tool is risky.
79
- * The executor must never auto-run a tool it cannot prove is safe.
80
- */
81
- export function toolRisk(tool) {
82
- return TOOL_RISK[tool] ?? "risky";
83
- }
84
- /**
85
- * One concrete tool invocation in a planner plan, with PER-TOOL TYPED args via a
86
- * discriminated union on `tool`. The executor (auto_safe/auto_full) runs these
87
- * in order; under `suggest` the user executes them. Args are validated by the
88
- * variant — never an open `z.record` bag — so a malformed plan fails loudly.
89
- */
90
- export const OrchestratePlanCall = z
91
- .discriminatedUnion("tool", [
92
- z
93
- .object({
94
- ...OrchestrateStepRequirement,
95
- tool: z.literal("start_run"),
96
- prompt: z.string().min(1).describe("Prompt for the sub-run."),
97
- mode: ModeKind.default("agent").describe("Mode for the sub-run."),
98
- harness: z.string().optional().describe("Harness to run on; omitted = engine routing."),
99
- why: z.string().default("").describe("Planner's reason for this step."),
100
- })
101
- .describe("Start one isolated sub-run."),
102
- z
103
- .object({
104
- ...OrchestrateStepRequirement,
105
- tool: z.literal("race"),
106
- prompt: z.string().min(1).describe("Prompt raced across harnesses."),
107
- n: z
108
- .number()
109
- .int()
110
- .min(2)
111
- .default(2)
112
- .describe("Number of race candidates (one per harness)."),
113
- why: z.string().default("").describe("Planner's reason for this step."),
114
- })
115
- .describe("Race the prompt as a best-of-N run."),
116
- z
117
- .object({
118
- ...OrchestrateStepRequirement,
119
- tool: z.literal("review"),
120
- run_id: z.string().min(1).describe("Run to review."),
121
- why: z.string().default("").describe("Planner's reason for this step."),
122
- })
123
- .describe("Review an existing run."),
124
- z
125
- .object({
126
- ...OrchestrateStepRequirement,
127
- tool: z.literal("status"),
128
- run_id: z.string().min(1).describe("Run to inspect."),
129
- why: z.string().default("").describe("Planner's reason for this step."),
130
- })
131
- .describe("Read the status of an existing run."),
132
- z
133
- .object({
134
- ...OrchestrateStepRequirement,
135
- tool: z.literal("answer_question"),
136
- interaction_id: z.string().min(1).describe("Pending interaction to answer."),
137
- answers: z
138
- .array(z.object({
139
- question_id: z.string().min(1).describe("Id of the question being answered."),
140
- selected_labels: z
141
- .array(z.string())
142
- .default([])
143
- .describe("Labels of the selected options."),
144
- free_text: z
145
- .string()
146
- .nullable()
147
- .default(null)
148
- .describe("Free-text answer; null when only options were selected."),
149
- }))
150
- .default([])
151
- .describe("Answers, one per question."),
152
- why: z.string().default("").describe("Planner's reason for this step."),
153
- })
154
- .describe("Answer a pending interactive question of a sub-run."),
155
- z
156
- .object({
157
- ...OrchestrateStepRequirement,
158
- tool: z.literal("apply"),
159
- run_id: z.string().min(1).describe("Run whose work product to deliver."),
160
- mode: z
161
- .enum(["apply", "branch", "commit", "pr"])
162
- .default("apply")
163
- .describe("Delivery mode: apply to the tree, or as a branch, commit, or PR."),
164
- why: z.string().default("").describe("Planner's reason for this step."),
165
- })
166
- .describe("Deliver a run's work product to the project (the only live-tree-mutating tool)."),
167
- ])
168
- .describe("One concrete tool invocation in a planner plan, with per-tool typed args discriminated on `tool`.");
169
- /**
170
- * The TYPED orchestration plan extracted from the planner's report (the fenced
171
- * JSON block the orchestrate prompt requires). Persisted as
172
- * `final/orchestration.yaml`; a missing/invalid block is disclosed in the
173
- * summary, never silently dropped.
174
- */
175
- export const OrchestratePlan = z
176
- .object({
177
- tool_calls: z
178
- .array(OrchestratePlanCall)
179
- .min(1)
180
- .describe("Ordered tool invocations of the plan."),
181
- })
182
- .describe("The typed orchestration plan extracted from the planner's report; persisted as final/orchestration.yaml.");
183
- /** Per-step executor status (auto_safe/auto_full). */
184
- export const OrchestrateStepStatus = z
185
- .enum(["pending", "running", "done", "skipped", "blocked", "failed"])
186
- .describe("Executor status of one plan step: pending, running, done, skipped, blocked (risky step awaiting a human), or failed.");
187
- export const OrchestrateTerminalSource = z.enum([
188
- "executor",
189
- "subrun",
190
- "review",
191
- "delivery",
192
- "policy",
193
- "budget",
194
- ]);
195
- /**
196
- * Typed executor progress over a plan's tool_calls. Persisted as
197
- * `final/orchestration_progress.yaml` and projected into the run detail so a
198
- * surface renders honest per-step outcomes (which safe steps ran, where a risky
199
- * step blocked, why it stopped). Producer: the orchestrator executor; consumer:
200
- * the control-api run-detail projection.
201
- */
202
- export const OrchestratePlanProgress = z
203
- .object({
204
- steps: z
205
- .array(z.object({
206
- index: z.number().int().nonnegative().describe("Position of the step in the plan."),
207
- tool: OrchestrateToolName,
208
- risk: z
209
- .enum(["safe", "risky"])
210
- .describe("Risk class of the step: safe (no live-tree mutation) or risky."),
211
- status: OrchestrateStepStatus,
212
- required: z.boolean().default(true),
213
- terminal_status: RunStatus.nullable()
214
- .default(null)
215
- .describe("Actual child/delivery terminal used by the parent outcome reducer."),
216
- terminal_source: OrchestrateTerminalSource.nullable()
217
- .default(null)
218
- .describe("Authority that produced terminal_status."),
219
- evidence_refs: z
220
- .array(z.string().min(1))
221
- .default([])
222
- .describe("Immutable run artifact or delivery receipt references."),
223
- /** Sub-run id this step started/targeted (start_run/race/review/status/apply), when known. */
224
- run_id: z
225
- .string()
226
- .nullable()
227
- .default(null)
228
- .describe("Sub-run id this step started/targeted, when known."),
229
- detail: z.string().nullable().default(null).describe("Human-readable step detail."),
230
- }))
231
- .default([])
232
- .describe("Per-step outcomes, in plan order."),
233
- autonomy: OrchestrateAutonomy,
234
- /** Set when the executor stopped early (first risky step under auto_safe, budget, abort). */
235
- stopped_reason: z
236
- .string()
237
- .nullable()
238
- .default(null)
239
- .describe("Set when the executor stopped early (first risky step under auto_safe, budget, abort)."),
240
- })
241
- .describe("Typed executor progress over a plan's tool calls, persisted as final/orchestration_progress.yaml and projected into run detail.");
242
- /**
243
- * JSON Schema for the planner's typed plan, computed from the LIVE Zod shape
244
- * (the SSOT) — passed as HarnessRunSpec.output_schema so schema-capable CLIs
245
- * constrain their final message to a valid OrchestratePlan.
246
- */
247
- let orchestratePlanJsonSchemaCache = null;
248
- export function orchestratePlanJsonSchema() {
249
- // INLINE root (no name/$ref wrapper): claude materializes --json-schema as
250
- // a StructuredOutput TOOL whose input_schema must carry a top-level "type"
251
- // — a $ref-wrapped root 400s (LIVE-VERIFIED). Codex accepts both.
252
- orchestratePlanJsonSchemaCache ??= strictifyForStructuredOutput(zodToJsonSchema(OrchestratePlan, { $refStrategy: "none" }));
253
- return orchestratePlanJsonSchemaCache;
254
- }
255
- /** A caller-supplied output schema the structured-output routes cannot carry. */
256
- export class UnsupportedOutputSchemaError extends Error {
257
- }
258
- /**
259
- * Validate a CALLER-supplied per-run output schema and return it UNCHANGED —
260
- * it stays the CONFORMANCE AUTHORITY (the engine validates the final answer
261
- * against exactly what the caller asked for). The vendor transport separately
262
- * strictifies via `strictifyOutputSchema`; NEVER validate the answer against
263
- * the strictified form — strictify turns an optional string into a required
264
- * `string|null`, so `{"field":null}` would falsely pass a schema that forbids it.
265
- *
266
- * Refuses — typed, at the boundary — the shapes the native routes are
267
- * LIVE-VERIFIED to reject rather than let a vendor 400 surface mid-run: the
268
- * root must be an inline `type: "object"` (claude materializes --json-schema as
269
- * a StructuredOutput tool whose input_schema needs a top-level type; a
270
- * $ref-wrapped root 400s), `$ref` is refused anywhere, and `format` is refused
271
- * while the pinned claude (<2.1.205) silently drops a format-bearing schema.
272
- */
273
- export function normalizeUserOutputSchema(schema) {
274
- if (schema["type"] !== "object" || typeof schema["properties"] !== "object") {
275
- throw new UnsupportedOutputSchemaError('outputSchema root must be an inline object schema ({"type":"object","properties":{...}}); $ref-wrapped or non-object roots are rejected by the native structured-output routes');
276
- }
277
- const hasRef = (value) => {
278
- if (Array.isArray(value))
279
- return value.some(hasRef);
280
- if (!value || typeof value !== "object")
281
- return false;
282
- const obj = value;
283
- if ("$ref" in obj)
284
- return true;
285
- return Object.values(obj).some(hasRef);
286
- };
287
- if (hasRef(schema)) {
288
- throw new UnsupportedOutputSchemaError("outputSchema must not contain $ref (native structured-output routes do not resolve references); inline the referenced shapes");
289
- }
290
- const hasFormat = (value) => {
291
- if (Array.isArray(value))
292
- return value.some(hasFormat);
293
- if (!value || typeof value !== "object")
294
- return false;
295
- const obj = value;
296
- if (typeof obj["format"] === "string")
297
- return true;
298
- return Object.values(obj).some(hasFormat);
299
- };
300
- if (hasFormat(schema)) {
301
- throw new UnsupportedOutputSchemaError("outputSchema must not use `format`: the pinned claude CLI (<2.1.205) silently drops the whole schema when format is present; express the constraint with pattern/enum instead");
302
- }
303
- return schema;
304
- }
305
- /** Vendor-strict transport form of a validated output schema (all keys
306
- * required, additionalProperties:false, optionals nullable). Used ONLY to
307
- * constrain the harness — NEVER to judge conformance (see normalizeUserOutputSchema). */
308
- export function strictifyOutputSchema(schema) {
309
- return strictifyForStructuredOutput(schema);
310
- }
311
- /**
312
- * Vendor STRICT structured-output mode (LIVE-VERIFIED against codex 0.137 /
313
- * the OpenAI Responses API): every object must list ALL property keys in
314
- * `required` and set `additionalProperties: false` — optional-with-default
315
- * fields become always-emitted (their Zod defaults make explicit values
316
- * equivalent). One owner for the transform; a schema that violates this is
317
- * rejected by the vendor with invalid_json_schema.
318
- */
319
- function strictifyForStructuredOutput(node) {
320
- const walk = (value) => {
321
- if (Array.isArray(value))
322
- return value.map(walk);
323
- if (!value || typeof value !== "object")
324
- return value;
325
- const obj = { ...value };
326
- for (const key of Object.keys(obj))
327
- obj[key] = walk(obj[key]);
328
- if (obj["type"] === "object" && obj["properties"] && typeof obj["properties"] === "object") {
329
- const props = obj["properties"];
330
- const originallyRequired = new Set(Array.isArray(obj["required"]) ? obj["required"] : []);
331
- // Vendor strict mode demands required = ALL keys; fields that were
332
- // OPTIONAL in the source schema stay expressible by becoming NULLABLE
333
- // (the OpenAI strict-mode recipe) — otherwise the model would be FORCED
334
- // to invent values for e.g. start_run.harness on every call.
335
- for (const key of Object.keys(props)) {
336
- if (originallyRequired.has(key))
337
- continue;
338
- const prop = props[key];
339
- if (prop && typeof prop === "object" && !Array.isArray(prop)) {
340
- const p = prop;
341
- if (typeof p["type"] === "string" && p["type"] !== "null") {
342
- p["type"] = [p["type"], "null"];
343
- }
344
- else if (Array.isArray(p["type"]) && !p["type"].includes("null")) {
345
- p["type"].push("null");
346
- }
347
- }
348
- }
349
- obj["required"] = Object.keys(props);
350
- obj["additionalProperties"] = false;
351
- }
352
- return obj;
353
- };
354
- return walk(node);
355
- }
356
- //# sourceMappingURL=orchestrate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"orchestrate.js","sourceRoot":"","sources":["../src/orchestrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,U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