codex-relay 1.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.
package/dist/src.js ADDED
@@ -0,0 +1,730 @@
1
+ import { z } from "zod";
2
+ //#region ../../packages/api-schema/src/index.ts
3
+ const IsoDateTimeSchema = z.string().datetime();
4
+ const ThreadStateSchema = z.enum([
5
+ "idle",
6
+ "running",
7
+ "completed",
8
+ "failed"
9
+ ]);
10
+ const ChatMessageRoleSchema = z.enum([
11
+ "user",
12
+ "assistant",
13
+ "status",
14
+ "tool",
15
+ "reasoning",
16
+ "error"
17
+ ]);
18
+ const ChatMessageStateSchema = z.enum([
19
+ "streaming",
20
+ "completed",
21
+ "failed"
22
+ ]);
23
+ const ChatMessageKindSchema = z.enum([
24
+ "chat",
25
+ "thinking",
26
+ "toolActivity",
27
+ "commandExecution",
28
+ "fileChange",
29
+ "plan",
30
+ "approvalRequest",
31
+ "structuredUserInput",
32
+ "subagentAction",
33
+ "webSearch",
34
+ "unknown"
35
+ ]);
36
+ const ApprovalModeSchema = z.enum([
37
+ "on-request",
38
+ "on-failure",
39
+ "never"
40
+ ]);
41
+ const RuntimeModeSchema = z.enum([
42
+ "default",
43
+ "auto",
44
+ "full-access",
45
+ "on-request"
46
+ ]);
47
+ const SandboxModeSchema = z.enum([
48
+ "workspace-write",
49
+ "danger-full-access",
50
+ "read-only"
51
+ ]);
52
+ const ReasoningEffortSchema = z.enum([
53
+ "minimal",
54
+ "low",
55
+ "medium",
56
+ "high",
57
+ "xhigh"
58
+ ]);
59
+ const ThreadCollaborationModeSchema = z.enum(["default", "plan"]);
60
+ const ThreadRunOptionsSchema = z.object({
61
+ model: z.string().trim().min(1).optional(),
62
+ runtimeMode: RuntimeModeSchema.default("default"),
63
+ approvalPolicy: ApprovalModeSchema.optional(),
64
+ sandboxMode: SandboxModeSchema.optional(),
65
+ reasoningEffort: ReasoningEffortSchema.optional(),
66
+ collaborationMode: ThreadCollaborationModeSchema.default("default")
67
+ });
68
+ const CodexModelSchema = z.object({
69
+ id: z.string().min(1),
70
+ model: z.string().min(1),
71
+ displayName: z.string().min(1),
72
+ description: z.string().optional(),
73
+ isDefault: z.boolean().default(false),
74
+ defaultReasoningEffort: ReasoningEffortSchema.optional(),
75
+ supportedReasoningEfforts: z.array(ReasoningEffortSchema).default([])
76
+ });
77
+ const ContextWindowUsageSchema = z.object({
78
+ tokensUsed: z.number().int().nonnegative(),
79
+ tokenLimit: z.number().int().positive()
80
+ });
81
+ const RateLimitWindowSchema = z.object({
82
+ usedPercent: z.number().int().min(0).max(100),
83
+ windowDurationMins: z.number().int().positive().nullable().optional(),
84
+ resetsAt: z.number().int().positive().nullable().optional()
85
+ });
86
+ const RateLimitBucketSchema = z.object({
87
+ limitId: z.string().min(1),
88
+ limitName: z.string().nullable().optional(),
89
+ planType: z.string().nullable().optional(),
90
+ primary: RateLimitWindowSchema.nullable().optional(),
91
+ secondary: RateLimitWindowSchema.nullable().optional(),
92
+ rateLimitReachedType: z.string().nullable().optional()
93
+ });
94
+ const RateLimitsResponseSchema = z.object({ buckets: z.array(RateLimitBucketSchema) });
95
+ const ThreadContextWindowResponseSchema = z.object({
96
+ threadId: z.string().min(1),
97
+ usage: ContextWindowUsageSchema.nullable(),
98
+ rolloutPath: z.string().nullable().optional()
99
+ });
100
+ const PromptAttachmentSchema = z.object({
101
+ type: z.literal("image"),
102
+ dataUri: z.string().trim().startsWith("data:image/"),
103
+ mimeType: z.string().trim().startsWith("image/").optional(),
104
+ name: z.string().trim().min(1).max(160).optional()
105
+ });
106
+ const ChatMessageSchema = z.object({
107
+ id: z.string().min(1),
108
+ threadId: z.string().min(1),
109
+ role: ChatMessageRoleSchema,
110
+ kind: ChatMessageKindSchema.default("chat"),
111
+ content: z.string(),
112
+ details: z.record(z.string(), z.unknown()).optional(),
113
+ createdAt: IsoDateTimeSchema,
114
+ updatedAt: IsoDateTimeSchema.optional(),
115
+ turnId: z.string().optional(),
116
+ state: ChatMessageStateSchema.optional()
117
+ });
118
+ const ThreadSummarySchema = z.object({
119
+ id: z.string().min(1),
120
+ title: z.string().min(1),
121
+ createdAt: IsoDateTimeSchema,
122
+ updatedAt: IsoDateTimeSchema,
123
+ state: ThreadStateSchema,
124
+ model: z.string().optional(),
125
+ cwd: z.string().optional(),
126
+ source: z.string().optional(),
127
+ messageCount: z.number().int().nonnegative().default(0),
128
+ lastMessagePreview: z.string().optional(),
129
+ lastActivityAt: IsoDateTimeSchema.optional(),
130
+ lastPrompt: z.string().optional(),
131
+ lastResult: z.string().optional(),
132
+ lastError: z.string().optional()
133
+ });
134
+ const StatusResponseSchema = z.object({
135
+ ok: z.boolean(),
136
+ service: z.literal("codex-relay-server"),
137
+ sdkAvailable: z.boolean(),
138
+ machineName: z.string().min(1),
139
+ workspacePath: z.string(),
140
+ threadCount: z.number().int().nonnegative(),
141
+ appServerAvailable: z.boolean().default(false)
142
+ });
143
+ const WorkspaceDirectoryEntrySchema = z.object({
144
+ name: z.string().min(1),
145
+ path: z.string().min(1)
146
+ });
147
+ const ListWorkspaceDirectoriesResponseSchema = z.object({
148
+ rootPath: z.string().min(1),
149
+ path: z.string().min(1),
150
+ parentPath: z.string().min(1).nullable(),
151
+ directories: z.array(WorkspaceDirectoryEntrySchema)
152
+ });
153
+ const WorkspaceChangesResponseSchema = z.object({
154
+ workspacePath: z.string().min(1),
155
+ status: z.string(),
156
+ diff: z.string(),
157
+ hasChanges: z.boolean(),
158
+ currentBranch: z.string().nullable().default(null),
159
+ branches: z.array(z.object({
160
+ current: z.boolean().default(false),
161
+ name: z.string().min(1)
162
+ })).default([]),
163
+ stats: z.object({
164
+ additions: z.number().int().nonnegative(),
165
+ deletions: z.number().int().nonnegative(),
166
+ filesChanged: z.number().int().nonnegative()
167
+ }).default({
168
+ additions: 0,
169
+ deletions: 0,
170
+ filesChanged: 0
171
+ }),
172
+ files: z.array(z.object({
173
+ additions: z.number().int().nonnegative(),
174
+ deletions: z.number().int().nonnegative(),
175
+ isBinary: z.boolean().default(false),
176
+ oldPath: z.string().nullable(),
177
+ path: z.string().min(1),
178
+ patch: z.string(),
179
+ stagedStatus: z.string().nullable(),
180
+ status: z.string().min(1),
181
+ worktreeStatus: z.string().nullable()
182
+ })).default([])
183
+ });
184
+ const CheckoutWorkspaceBranchRequestSchema = z.object({ branch: z.string().trim().min(1).refine((branch) => !branch.startsWith("-"), "Branch name cannot start with '-'.") });
185
+ const CommitPushWorkspaceRequestSchema = z.object({ message: z.string().trim().min(1).max(240) });
186
+ const WorkspaceGitActionResponseSchema = z.object({
187
+ branch: z.string().nullable(),
188
+ message: z.string().min(1),
189
+ output: z.string().default("")
190
+ });
191
+ const WebPreviewTargetSchema = z.object({
192
+ kind: z.literal("web"),
193
+ url: z.string().url(),
194
+ port: z.number().int().positive(),
195
+ label: z.string().min(1).optional(),
196
+ source: z.enum([
197
+ "detected-port",
198
+ "codex-output",
199
+ "user-entered"
200
+ ]),
201
+ confidence: z.enum([
202
+ "low",
203
+ "medium",
204
+ "high"
205
+ ]),
206
+ detectedAt: IsoDateTimeSchema
207
+ });
208
+ const PairRequestSchema = z.object({
209
+ clientName: z.string().trim().min(1).max(80).optional(),
210
+ secure: z.object({
211
+ clientEphemeralPublicKey: z.string().min(1),
212
+ clientNonce: z.string().min(1),
213
+ protocolVersion: z.literal(1)
214
+ }).optional()
215
+ });
216
+ const PairResponseSchema = z.object({
217
+ approvalCode: z.string().min(1).optional(),
218
+ approvalExpiresAt: IsoDateTimeSchema.optional(),
219
+ clientToken: z.string().min(1).optional(),
220
+ clientTokenExpiresAt: IsoDateTimeSchema.optional(),
221
+ secure: z.object({
222
+ encryptedPayload: z.string().min(1),
223
+ keyEpoch: z.number().int().nonnegative(),
224
+ protocolVersion: z.literal(1),
225
+ serverEphemeralPublicKey: z.string().min(1),
226
+ serverNonce: z.string().min(1),
227
+ serverSignature: z.string().min(1)
228
+ }).optional()
229
+ });
230
+ const EncryptedPayloadSchema = z.object({
231
+ ciphertext: z.string().min(1),
232
+ counter: z.number().int().nonnegative(),
233
+ keyEpoch: z.number().int().nonnegative(),
234
+ protocolVersion: z.literal(1),
235
+ sender: z.enum(["mobile", "server"])
236
+ });
237
+ z.object({
238
+ clientToken: z.string().min(1),
239
+ clientTokenExpiresAt: IsoDateTimeSchema
240
+ });
241
+ const ErrorResponseSchema = z.object({ error: z.object({
242
+ code: z.string(),
243
+ message: z.string(),
244
+ issues: z.array(z.string()).optional()
245
+ }) });
246
+ const CreateThreadRequestSchema = z.object({
247
+ attachments: z.array(PromptAttachmentSchema).max(6).optional(),
248
+ prompt: z.string().trim().min(1).optional(),
249
+ title: z.string().trim().min(1).max(120).optional(),
250
+ workspacePath: z.string().trim().min(1).optional()
251
+ }).merge(ThreadRunOptionsSchema.partial());
252
+ z.object({
253
+ thread: ThreadSummarySchema,
254
+ messages: z.array(ChatMessageSchema).default([]),
255
+ result: z.string().optional()
256
+ });
257
+ const RunThreadRequestSchema = z.object({
258
+ attachments: z.array(PromptAttachmentSchema).max(6).optional(),
259
+ prompt: z.string().trim().min(1)
260
+ }).merge(ThreadRunOptionsSchema.partial());
261
+ z.object({
262
+ thread: ThreadSummarySchema,
263
+ messages: z.array(ChatMessageSchema).default([]),
264
+ result: z.string()
265
+ });
266
+ const SubmitThreadInputResponseSchema = z.object({
267
+ acceptedAs: z.enum(["steering", "queued"]),
268
+ queueLength: z.number().int().nonnegative(),
269
+ thread: ThreadSummarySchema
270
+ });
271
+ const ApprovalDecisionSchema = z.enum([
272
+ "approve",
273
+ "approve-for-session",
274
+ "deny",
275
+ "cancel"
276
+ ]);
277
+ const ResolveApprovalRequestSchema = z.object({
278
+ decision: ApprovalDecisionSchema,
279
+ answers: z.array(z.string()).optional()
280
+ });
281
+ const ResolveApprovalResponseSchema = z.object({ ok: z.boolean() });
282
+ const ListThreadsResponseSchema = z.object({
283
+ threads: z.array(ThreadSummarySchema),
284
+ source: z.enum(["app-server", "memory"]).default("memory")
285
+ });
286
+ const ListModelsResponseSchema = z.object({ models: z.array(CodexModelSchema) });
287
+ const ThreadDetailResponseSchema = z.object({
288
+ thread: ThreadSummarySchema,
289
+ messages: z.array(ChatMessageSchema)
290
+ });
291
+ const StreamThreadRunEventSchema = z.discriminatedUnion("type", [
292
+ z.object({
293
+ type: z.literal("thread.message.created"),
294
+ thread: ThreadSummarySchema,
295
+ message: ChatMessageSchema
296
+ }),
297
+ z.object({
298
+ type: z.literal("thread.message.delta"),
299
+ threadId: z.string().min(1),
300
+ messageId: z.string().min(1),
301
+ delta: z.string()
302
+ }),
303
+ z.object({
304
+ type: z.literal("thread.message.completed"),
305
+ thread: ThreadSummarySchema,
306
+ message: ChatMessageSchema
307
+ }),
308
+ z.object({
309
+ type: z.literal("thread.state.changed"),
310
+ thread: ThreadSummarySchema
311
+ }),
312
+ z.object({
313
+ type: z.literal("thread.error"),
314
+ thread: ThreadSummarySchema.optional(),
315
+ error: ErrorResponseSchema.shape.error
316
+ }),
317
+ z.object({
318
+ type: z.literal("thread.preview_target.detected"),
319
+ threadId: z.string().min(1),
320
+ target: WebPreviewTargetSchema
321
+ })
322
+ ]);
323
+ const apiPaths = {
324
+ pair: "/v1/pair",
325
+ pairApproval: (approvalCode) => `/v1/pair/${encodeURIComponent(approvalCode)}`,
326
+ pairApprove: "/v1/pair/approve",
327
+ sessionRefresh: "/v1/session/refresh",
328
+ status: "/v1/status",
329
+ rateLimits: "/v1/rate-limits",
330
+ models: "/v1/models",
331
+ workspaceDirectories: "/v1/workspace-directories",
332
+ workspaceChanges: "/v1/workspace/changes",
333
+ workspaceCheckout: "/v1/workspace/checkout",
334
+ workspaceCommitPush: "/v1/workspace/commit-push",
335
+ threads: "/v1/threads",
336
+ thread: (threadId) => `/v1/threads/${encodeURIComponent(threadId)}`,
337
+ threadContextWindow: (threadId) => `/v1/threads/${encodeURIComponent(threadId)}/context-window`,
338
+ approval: (approvalId) => `/v1/approvals/${encodeURIComponent(approvalId)}`,
339
+ threadInput: (threadId) => `/v1/threads/${encodeURIComponent(threadId)}/input`,
340
+ threadRuns: (threadId) => `/v1/threads/${encodeURIComponent(threadId)}/runs`,
341
+ threadRunStream: (threadId) => `/v1/threads/${encodeURIComponent(threadId)}/runs/stream`
342
+ };
343
+ function createOpenApiDocument() {
344
+ return {
345
+ openapi: "3.1.0",
346
+ info: {
347
+ title: "Codex Relay Local Codex API",
348
+ version: "0.1.0"
349
+ },
350
+ paths: {
351
+ "/v1/status": { get: {
352
+ summary: "Local server status",
353
+ responses: { "200": jsonResponse("StatusResponse") }
354
+ } },
355
+ "/v1/threads": {
356
+ get: {
357
+ summary: "List locally known threads",
358
+ responses: { "200": jsonResponse("ListThreadsResponse") }
359
+ },
360
+ post: {
361
+ summary: "Start a Codex thread",
362
+ requestBody: jsonRequest("CreateThreadRequest"),
363
+ responses: {
364
+ "201": jsonResponse("CreateThreadResponse"),
365
+ "400": jsonResponse("ErrorResponse")
366
+ }
367
+ }
368
+ },
369
+ "/v1/workspace-directories": { get: {
370
+ summary: "List directories under the configured workspace",
371
+ responses: {
372
+ "200": jsonResponse("ListWorkspaceDirectoriesResponse"),
373
+ "400": jsonResponse("ErrorResponse")
374
+ }
375
+ } },
376
+ "/v1/threads/{threadId}/runs": { post: {
377
+ summary: "Run a prompt on a Codex thread",
378
+ parameters: [{
379
+ name: "threadId",
380
+ in: "path",
381
+ required: true,
382
+ schema: { type: "string" }
383
+ }],
384
+ requestBody: jsonRequest("RunThreadRequest"),
385
+ responses: {
386
+ "200": jsonResponse("RunThreadResponse"),
387
+ "400": jsonResponse("ErrorResponse"),
388
+ "404": jsonResponse("ErrorResponse")
389
+ }
390
+ } },
391
+ "/v1/threads/{threadId}/input": { post: {
392
+ summary: "Submit input to an already-running Codex thread",
393
+ requestBody: jsonRequest("RunThreadRequest"),
394
+ responses: {
395
+ "202": jsonResponse("SubmitThreadInputResponse"),
396
+ "400": jsonResponse("ErrorResponse"),
397
+ "404": jsonResponse("ErrorResponse"),
398
+ "409": jsonResponse("ErrorResponse")
399
+ }
400
+ } },
401
+ "/v1/threads/{threadId}/runs/stream": { post: {
402
+ summary: "Run a prompt on a Codex thread and stream events",
403
+ requestBody: jsonRequest("RunThreadRequest"),
404
+ responses: {
405
+ "200": {
406
+ description: "Server-sent events containing StreamThreadRunEvent payloads",
407
+ content: { "text/event-stream": { schema: { $ref: "#/components/schemas/StreamThreadRunEvent" } } }
408
+ },
409
+ "400": jsonResponse("ErrorResponse"),
410
+ "404": jsonResponse("ErrorResponse")
411
+ }
412
+ } }
413
+ },
414
+ components: { schemas: {
415
+ ThreadState: {
416
+ type: "string",
417
+ enum: ThreadStateSchema.options
418
+ },
419
+ ChatMessage: {
420
+ type: "object",
421
+ required: [
422
+ "id",
423
+ "threadId",
424
+ "role",
425
+ "content",
426
+ "createdAt"
427
+ ],
428
+ properties: {
429
+ id: { type: "string" },
430
+ threadId: { type: "string" },
431
+ role: {
432
+ type: "string",
433
+ enum: ChatMessageRoleSchema.options
434
+ },
435
+ kind: {
436
+ type: "string",
437
+ enum: ChatMessageKindSchema.options
438
+ },
439
+ content: { type: "string" },
440
+ details: {
441
+ type: "object",
442
+ additionalProperties: true
443
+ },
444
+ createdAt: {
445
+ type: "string",
446
+ format: "date-time"
447
+ },
448
+ updatedAt: {
449
+ type: "string",
450
+ format: "date-time"
451
+ },
452
+ turnId: { type: "string" },
453
+ state: {
454
+ type: "string",
455
+ enum: ChatMessageStateSchema.options
456
+ }
457
+ }
458
+ },
459
+ ThreadSummary: {
460
+ type: "object",
461
+ required: [
462
+ "id",
463
+ "title",
464
+ "createdAt",
465
+ "updatedAt",
466
+ "state",
467
+ "messageCount"
468
+ ],
469
+ properties: {
470
+ id: { type: "string" },
471
+ title: { type: "string" },
472
+ createdAt: {
473
+ type: "string",
474
+ format: "date-time"
475
+ },
476
+ updatedAt: {
477
+ type: "string",
478
+ format: "date-time"
479
+ },
480
+ state: { $ref: "#/components/schemas/ThreadState" },
481
+ messageCount: {
482
+ type: "integer",
483
+ minimum: 0
484
+ },
485
+ lastMessagePreview: { type: "string" },
486
+ lastActivityAt: {
487
+ type: "string",
488
+ format: "date-time"
489
+ },
490
+ lastPrompt: { type: "string" },
491
+ lastResult: { type: "string" },
492
+ lastError: { type: "string" }
493
+ }
494
+ },
495
+ StatusResponse: {
496
+ type: "object",
497
+ required: [
498
+ "ok",
499
+ "service",
500
+ "sdkAvailable",
501
+ "machineName",
502
+ "workspacePath",
503
+ "threadCount"
504
+ ],
505
+ properties: {
506
+ ok: { type: "boolean" },
507
+ service: {
508
+ type: "string",
509
+ const: "codex-relay-server"
510
+ },
511
+ sdkAvailable: { type: "boolean" },
512
+ machineName: { type: "string" },
513
+ workspacePath: { type: "string" },
514
+ threadCount: {
515
+ type: "integer",
516
+ minimum: 0
517
+ }
518
+ }
519
+ },
520
+ WorkspaceDirectoryEntry: {
521
+ type: "object",
522
+ required: ["name", "path"],
523
+ properties: {
524
+ name: { type: "string" },
525
+ path: { type: "string" }
526
+ }
527
+ },
528
+ ListWorkspaceDirectoriesResponse: {
529
+ type: "object",
530
+ required: [
531
+ "rootPath",
532
+ "path",
533
+ "parentPath",
534
+ "directories"
535
+ ],
536
+ properties: {
537
+ rootPath: { type: "string" },
538
+ path: { type: "string" },
539
+ parentPath: {
540
+ type: "string",
541
+ nullable: true
542
+ },
543
+ directories: {
544
+ type: "array",
545
+ items: { $ref: "#/components/schemas/WorkspaceDirectoryEntry" }
546
+ }
547
+ }
548
+ },
549
+ CreateThreadRequest: {
550
+ type: "object",
551
+ properties: {
552
+ attachments: {
553
+ type: "array",
554
+ maxItems: 6,
555
+ items: { $ref: "#/components/schemas/PromptAttachment" }
556
+ },
557
+ prompt: { type: "string" },
558
+ title: {
559
+ type: "string",
560
+ maxLength: 120
561
+ },
562
+ workspacePath: { type: "string" },
563
+ collaborationMode: {
564
+ type: "string",
565
+ enum: ["default", "plan"],
566
+ default: "default"
567
+ }
568
+ }
569
+ },
570
+ PromptAttachment: {
571
+ type: "object",
572
+ required: ["type", "dataUri"],
573
+ properties: {
574
+ type: {
575
+ type: "string",
576
+ const: "image"
577
+ },
578
+ dataUri: {
579
+ type: "string",
580
+ format: "uri",
581
+ pattern: "^data:image/"
582
+ },
583
+ mimeType: {
584
+ type: "string",
585
+ pattern: "^image/"
586
+ },
587
+ name: {
588
+ type: "string",
589
+ maxLength: 160
590
+ }
591
+ }
592
+ },
593
+ CreateThreadResponse: {
594
+ type: "object",
595
+ required: ["thread"],
596
+ properties: {
597
+ thread: { $ref: "#/components/schemas/ThreadSummary" },
598
+ messages: {
599
+ type: "array",
600
+ items: { $ref: "#/components/schemas/ChatMessage" }
601
+ },
602
+ result: { type: "string" }
603
+ }
604
+ },
605
+ RunThreadRequest: {
606
+ type: "object",
607
+ required: ["prompt"],
608
+ properties: {
609
+ attachments: {
610
+ type: "array",
611
+ maxItems: 6,
612
+ items: { $ref: "#/components/schemas/PromptAttachment" }
613
+ },
614
+ prompt: { type: "string" },
615
+ collaborationMode: {
616
+ type: "string",
617
+ enum: ["default", "plan"],
618
+ default: "default"
619
+ }
620
+ }
621
+ },
622
+ RunThreadResponse: {
623
+ type: "object",
624
+ required: ["thread", "result"],
625
+ properties: {
626
+ thread: { $ref: "#/components/schemas/ThreadSummary" },
627
+ messages: {
628
+ type: "array",
629
+ items: { $ref: "#/components/schemas/ChatMessage" }
630
+ },
631
+ result: { type: "string" }
632
+ }
633
+ },
634
+ SubmitThreadInputResponse: {
635
+ type: "object",
636
+ required: [
637
+ "acceptedAs",
638
+ "queueLength",
639
+ "thread"
640
+ ],
641
+ properties: {
642
+ acceptedAs: {
643
+ type: "string",
644
+ enum: ["steering", "queued"]
645
+ },
646
+ queueLength: {
647
+ type: "integer",
648
+ minimum: 0
649
+ },
650
+ thread: { $ref: "#/components/schemas/ThreadSummary" }
651
+ }
652
+ },
653
+ ThreadDetailResponse: {
654
+ type: "object",
655
+ required: ["thread", "messages"],
656
+ properties: {
657
+ thread: { $ref: "#/components/schemas/ThreadSummary" },
658
+ messages: {
659
+ type: "array",
660
+ items: { $ref: "#/components/schemas/ChatMessage" }
661
+ }
662
+ }
663
+ },
664
+ StreamThreadRunEvent: { oneOf: [
665
+ {
666
+ type: "object",
667
+ properties: { type: { const: "thread.message.created" } }
668
+ },
669
+ {
670
+ type: "object",
671
+ properties: { type: { const: "thread.message.delta" } }
672
+ },
673
+ {
674
+ type: "object",
675
+ properties: { type: { const: "thread.message.completed" } }
676
+ },
677
+ {
678
+ type: "object",
679
+ properties: { type: { const: "thread.state.changed" } }
680
+ },
681
+ {
682
+ type: "object",
683
+ properties: { type: { const: "thread.error" } }
684
+ },
685
+ {
686
+ type: "object",
687
+ properties: { type: { const: "thread.preview_target.detected" } }
688
+ }
689
+ ] },
690
+ ListThreadsResponse: {
691
+ type: "object",
692
+ required: ["threads"],
693
+ properties: { threads: {
694
+ type: "array",
695
+ items: { $ref: "#/components/schemas/ThreadSummary" }
696
+ } }
697
+ },
698
+ ErrorResponse: {
699
+ type: "object",
700
+ required: ["error"],
701
+ properties: { error: {
702
+ type: "object",
703
+ required: ["code", "message"],
704
+ properties: {
705
+ code: { type: "string" },
706
+ message: { type: "string" },
707
+ issues: {
708
+ type: "array",
709
+ items: { type: "string" }
710
+ }
711
+ }
712
+ } }
713
+ }
714
+ } }
715
+ };
716
+ }
717
+ function jsonRequest(schemaName) {
718
+ return {
719
+ required: true,
720
+ content: { "application/json": { schema: { $ref: `#/components/schemas/${schemaName}` } } }
721
+ };
722
+ }
723
+ function jsonResponse(schemaName) {
724
+ return {
725
+ description: schemaName,
726
+ content: { "application/json": { schema: { $ref: `#/components/schemas/${schemaName}` } } }
727
+ };
728
+ }
729
+ //#endregion
730
+ export { WorkspaceGitActionResponseSchema as C, WorkspaceChangesResponseSchema as S, createOpenApiDocument as T, StreamThreadRunEventSchema as _, CreateThreadRequestSchema as a, ThreadDetailResponseSchema as b, ListThreadsResponseSchema as c, PairResponseSchema as d, RateLimitsResponseSchema as f, StatusResponseSchema as g, RunThreadRequestSchema as h, ContextWindowUsageSchema as i, ListWorkspaceDirectoriesResponseSchema as l, ResolveApprovalResponseSchema as m, CheckoutWorkspaceBranchRequestSchema as n, EncryptedPayloadSchema as o, ResolveApprovalRequestSchema as p, CommitPushWorkspaceRequestSchema as r, ListModelsResponseSchema as s, ChatMessageSchema as t, PairRequestSchema as u, SubmitThreadInputResponseSchema as v, apiPaths as w, ThreadSummarySchema as x, ThreadContextWindowResponseSchema as y };