@opencode-ai/ai 0.0.0-next-16211 → 0.0.0-next-16215

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.
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { HttpTransport } from "../route/transport";
3
3
  import { Protocol } from "../route/protocol";
4
- import { LLMError, LLMEvent, type LLMRequest, type MediaPart, type ProviderMetadata, type ToolDefinition } from "../schema";
4
+ import { LLMError, LLMEvent, Usage, type LLMRequest, type MediaPart, type ProviderMetadata, type ToolDefinition } from "../schema";
5
5
  import { ProviderShared } from "./shared";
6
6
  import { Lifecycle } from "./utils/lifecycle";
7
7
  import { ToolStream } from "./utils/tool-stream";
@@ -16,6 +16,73 @@ declare const MediaInput: Schema.Union<readonly [Schema.Struct<{
16
16
  readonly mime_type: Schema.optional<Schema.String>;
17
17
  }>]>;
18
18
  export type MediaInput = Schema.Schema.Type<typeof MediaInput>;
19
+ export declare const MessagePhase: Schema.Literals<readonly ["commentary", "final_answer"]>;
20
+ type MessagePhase = Schema.Schema.Type<typeof MessagePhase>;
21
+ export declare const InputItem: Schema.Union<readonly [Schema.Struct<{
22
+ readonly role: Schema.tag<"system">;
23
+ readonly content: Schema.String;
24
+ }>, Schema.Struct<{
25
+ readonly role: Schema.tag<"user">;
26
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
27
+ readonly type: Schema.tag<"input_text">;
28
+ readonly text: Schema.String;
29
+ }>, Schema.Union<readonly [Schema.Struct<{
30
+ readonly type: Schema.tag<"input_image">;
31
+ readonly image_url: Schema.String;
32
+ }>, Schema.Struct<{
33
+ readonly type: Schema.tag<"input_file">;
34
+ readonly filename: Schema.String;
35
+ readonly file_data: Schema.String;
36
+ readonly mime_type: Schema.optional<Schema.String>;
37
+ }>]>]>>;
38
+ }>, Schema.Struct<{
39
+ readonly role: Schema.tag<"assistant">;
40
+ readonly content: Schema.$Array<Schema.Struct<{
41
+ readonly type: Schema.tag<"output_text">;
42
+ readonly text: Schema.String;
43
+ }>>;
44
+ readonly phase: Schema.optionalKey<Schema.Literals<readonly ["commentary", "final_answer"]>>;
45
+ }>, Schema.Struct<{
46
+ readonly type: Schema.tag<"reasoning">;
47
+ readonly id: Schema.optionalKey<Schema.String>;
48
+ readonly summary: Schema.$Array<Schema.Struct<{
49
+ readonly type: Schema.tag<"summary_text">;
50
+ readonly text: Schema.String;
51
+ }>>;
52
+ readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
53
+ }>, Schema.Struct<{
54
+ readonly type: Schema.tag<"item_reference">;
55
+ readonly id: Schema.String;
56
+ }>, Schema.Struct<{
57
+ readonly type: Schema.tag<"function_call">;
58
+ readonly call_id: Schema.String;
59
+ readonly name: Schema.String;
60
+ readonly arguments: Schema.String;
61
+ }>, Schema.Struct<{
62
+ readonly type: Schema.tag<"function_call_output">;
63
+ readonly call_id: Schema.String;
64
+ readonly output: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
65
+ readonly type: Schema.tag<"input_text">;
66
+ readonly text: Schema.String;
67
+ }>, Schema.Struct<{
68
+ readonly type: Schema.tag<"input_image">;
69
+ readonly image_url: Schema.String;
70
+ }>, Schema.Struct<{
71
+ readonly type: Schema.tag<"input_file">;
72
+ readonly filename: Schema.String;
73
+ readonly file_data: Schema.String;
74
+ readonly mime_type: Schema.optional<Schema.String>;
75
+ }>]>>]>;
76
+ }>]>;
77
+ type OpenResponsesInputItem = Schema.Schema.Type<typeof InputItem>;
78
+ type LoweredInputItem = OpenResponsesInputItem | {
79
+ readonly role: "assistant";
80
+ readonly content: ReadonlyArray<{
81
+ readonly type: "output_text";
82
+ readonly text: string;
83
+ }>;
84
+ readonly phase?: MessagePhase | null;
85
+ };
19
86
  export declare const Tool: Schema.Struct<{
20
87
  readonly type: Schema.tag<"function">;
21
88
  readonly name: Schema.String;
@@ -52,6 +119,7 @@ export declare const coreFields: {
52
119
  readonly type: Schema.tag<"output_text">;
53
120
  readonly text: Schema.String;
54
121
  }>>;
122
+ readonly phase: Schema.optionalKey<Schema.Literals<readonly ["commentary", "final_answer"]>>;
55
123
  }>, Schema.Struct<{
56
124
  readonly type: Schema.tag<"reasoning">;
57
125
  readonly id: Schema.optionalKey<Schema.String>;
@@ -137,6 +205,7 @@ declare const OpenResponsesBody: Schema.Struct<{
137
205
  readonly type: Schema.tag<"output_text">;
138
206
  readonly text: Schema.String;
139
207
  }>>;
208
+ readonly phase: Schema.optionalKey<Schema.Literals<readonly ["commentary", "final_answer"]>>;
140
209
  }>, Schema.Struct<{
141
210
  readonly type: Schema.tag<"reasoning">;
142
211
  readonly id: Schema.optionalKey<Schema.String>;
@@ -209,6 +278,7 @@ export type StreamItem = Schema.Schema.Type<typeof StreamItem>;
209
278
  export declare const Event: Schema.StructWithRest<Schema.Struct<{
210
279
  readonly type: Schema.String;
211
280
  readonly delta: Schema.optional<Schema.String>;
281
+ readonly text: Schema.optional<Schema.String>;
212
282
  readonly item_id: Schema.optional<Schema.String>;
213
283
  readonly summary_index: Schema.optional<Schema.Number>;
214
284
  readonly item: Schema.optional<Schema.StructWithRest<Schema.Struct<{
@@ -261,6 +331,7 @@ export interface Extension {
261
331
  readonly media: ProviderShared.ValidatedMedia;
262
332
  readonly request: LLMRequest;
263
333
  }) => MediaInput | undefined;
334
+ readonly messagePhase?: (value: unknown) => MessagePhase | null | undefined;
264
335
  }
265
336
  export interface ParserState {
266
337
  readonly id: string;
@@ -269,6 +340,9 @@ export interface ParserState {
269
340
  readonly tools: ToolStream.State<string>;
270
341
  readonly hasFunctionCall: boolean;
271
342
  readonly lifecycle: Lifecycle.State;
343
+ readonly messageItems: ReadonlySet<string>;
344
+ readonly messagePhase: (value: unknown) => MessagePhase | null | undefined;
345
+ readonly messagePhases: Readonly<Record<string, MessagePhase | null>>;
272
346
  readonly reasoningItems: Readonly<Record<string, ReasoningStreamItem>>;
273
347
  readonly store: boolean | undefined;
274
348
  }
@@ -292,7 +366,7 @@ export declare const lowerToolChoice: (protocolName: string, toolChoice: NonNull
292
366
  type: "function";
293
367
  name: string;
294
368
  }, LLMError, never>;
295
- export declare const fromRequest: (request: LLMRequest, extension?: Extension | undefined) => Effect.Effect<{
369
+ export declare const fromRequestWithExtension: (request: LLMRequest, extension: Extension) => Effect.Effect<{
296
370
  service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
297
371
  text?: {
298
372
  verbosity: "low" | "medium" | "high";
@@ -306,7 +380,27 @@ export declare const fromRequest: (request: LLMRequest, extension?: Extension |
306
380
  store?: boolean | undefined;
307
381
  instructions?: string | undefined;
308
382
  model: string & import("effect/Brand").Brand<"LLM.ModelID">;
309
- input: ({
383
+ input: LoweredInputItem[];
384
+ tools: {
385
+ type: "function";
386
+ name: string;
387
+ description: string;
388
+ parameters: {
389
+ readonly [x: string]: unknown;
390
+ };
391
+ strict: boolean;
392
+ }[] | undefined;
393
+ tool_choice: "required" | "none" | "auto" | {
394
+ type: "function";
395
+ name: string;
396
+ } | undefined;
397
+ stream: true;
398
+ max_output_tokens: number | undefined;
399
+ temperature: number | undefined;
400
+ top_p: number | undefined;
401
+ }, LLMError, never>;
402
+ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
403
+ readonly input: readonly ({
310
404
  readonly type: "reasoning";
311
405
  readonly summary: readonly Schema.Struct.ReadonlySide<{
312
406
  readonly type: Schema.tag<"summary_text">;
@@ -334,13 +428,14 @@ export declare const fromRequest: (request: LLMRequest, extension?: Extension |
334
428
  readonly file_data: Schema.String;
335
429
  readonly mime_type: Schema.optional<Schema.String>;
336
430
  }>]>]>>;
337
- }, "Type"> | Schema.Struct.ReadonlySide<{
338
- readonly role: Schema.tag<"assistant">;
339
- readonly content: Schema.$Array<Schema.Struct<{
431
+ }, "Type"> | {
432
+ readonly content: readonly Schema.Struct.ReadonlySide<{
340
433
  readonly type: Schema.tag<"output_text">;
341
434
  readonly text: Schema.String;
342
- }>>;
343
- }, "Type"> | Schema.Struct.ReadonlySide<{
435
+ }, "Type">[];
436
+ readonly role: "assistant";
437
+ readonly phase?: "commentary" | "final_answer" | undefined;
438
+ } | Schema.Struct.ReadonlySide<{
344
439
  readonly type: Schema.tag<"function_call">;
345
440
  readonly call_id: Schema.String;
346
441
  readonly name: Schema.String;
@@ -361,30 +456,224 @@ export declare const fromRequest: (request: LLMRequest, extension?: Extension |
361
456
  readonly mime_type: Schema.optional<Schema.String>;
362
457
  }>]>>]>;
363
458
  }, "Type">)[];
364
- tools: {
365
- type: "function";
366
- name: string;
367
- description: string;
368
- parameters: {
459
+ readonly model: string;
460
+ readonly stream: true;
461
+ readonly text?: {
462
+ readonly verbosity?: "low" | "medium" | "high" | undefined;
463
+ } | undefined;
464
+ readonly reasoning?: {
465
+ readonly effort?: string | undefined;
466
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
467
+ } | undefined;
468
+ readonly tools?: readonly {
469
+ readonly type: "function";
470
+ readonly name: string;
471
+ readonly description: string;
472
+ readonly parameters: {
369
473
  readonly [x: string]: unknown;
370
474
  };
371
- strict: boolean;
475
+ readonly strict?: boolean | undefined;
372
476
  }[] | undefined;
373
- tool_choice: "required" | "none" | "auto" | {
374
- type: "function";
375
- name: string;
376
- } | undefined;
377
- stream: true;
378
- max_output_tokens: number | undefined;
379
- temperature: number | undefined;
380
- top_p: number | undefined;
477
+ readonly temperature?: number | undefined;
478
+ readonly tool_choice?: "required" | "none" | "auto" | Schema.Struct.ReadonlySide<{
479
+ readonly type: Schema.tag<"function">;
480
+ readonly name: Schema.String;
481
+ }, "Type"> | undefined;
482
+ readonly top_p?: number | undefined;
483
+ readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
484
+ readonly instructions?: string | undefined;
485
+ readonly store?: boolean | undefined;
486
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
487
+ readonly prompt_cache_key?: string | undefined;
488
+ readonly max_output_tokens?: number | undefined;
381
489
  }, LLMError, never>;
382
490
  export declare const providerMetadata: (state: ParserState, metadata: Record<string, unknown>) => ProviderMetadata;
383
491
  export type StepResult = readonly [ParserState, ReadonlyArray<LLMEvent>];
384
492
  export declare const terminal: (event: Event) => boolean;
385
- export declare const onReasoningDelta: (state: ParserState, event: Event) => StepResult;
493
+ export declare const onReasoningDelta: (state: ParserState, event: Event, itemID: string) => StepResult;
386
494
  export declare const onReasoningDone: (state: ParserState, _event: Event) => StepResult;
387
- export declare const step: (state: ParserState, event: Event) => LLMError | Effect.Effect<StepResult, LLMError, never>;
495
+ export declare const step: (state: ParserState, event: Event) => LLMError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly (Schema.Struct.ReadonlySide<{
496
+ readonly type: Schema.tag<"step-start">;
497
+ readonly index: Schema.Number;
498
+ }, "Type"> | {
499
+ readonly type: "text-start";
500
+ readonly id: string;
501
+ readonly providerMetadata?: {
502
+ readonly [x: string]: {
503
+ readonly [x: string]: unknown;
504
+ };
505
+ } | undefined;
506
+ } | {
507
+ readonly type: "text-delta";
508
+ readonly text: string;
509
+ readonly id: string;
510
+ readonly providerMetadata?: {
511
+ readonly [x: string]: {
512
+ readonly [x: string]: unknown;
513
+ };
514
+ } | undefined;
515
+ } | {
516
+ readonly type: "text-end";
517
+ readonly id: string;
518
+ readonly providerMetadata?: {
519
+ readonly [x: string]: {
520
+ readonly [x: string]: unknown;
521
+ };
522
+ } | undefined;
523
+ } | {
524
+ readonly type: "reasoning-start";
525
+ readonly id: string;
526
+ readonly providerMetadata?: {
527
+ readonly [x: string]: {
528
+ readonly [x: string]: unknown;
529
+ };
530
+ } | undefined;
531
+ } | {
532
+ readonly type: "reasoning-delta";
533
+ readonly text: string;
534
+ readonly id: string;
535
+ readonly providerMetadata?: {
536
+ readonly [x: string]: {
537
+ readonly [x: string]: unknown;
538
+ };
539
+ } | undefined;
540
+ } | {
541
+ readonly type: "reasoning-end";
542
+ readonly id: string;
543
+ readonly providerMetadata?: {
544
+ readonly [x: string]: {
545
+ readonly [x: string]: unknown;
546
+ };
547
+ } | undefined;
548
+ } | {
549
+ readonly type: "tool-input-start";
550
+ readonly name: string;
551
+ readonly id: string;
552
+ readonly providerMetadata?: {
553
+ readonly [x: string]: {
554
+ readonly [x: string]: unknown;
555
+ };
556
+ } | undefined;
557
+ readonly providerExecuted?: boolean | undefined;
558
+ } | Schema.Struct.ReadonlySide<{
559
+ readonly type: Schema.tag<"tool-input-delta">;
560
+ readonly id: Schema.String;
561
+ readonly name: Schema.String;
562
+ readonly text: Schema.String;
563
+ }, "Type"> | {
564
+ readonly type: "tool-input-end";
565
+ readonly name: string;
566
+ readonly id: string;
567
+ readonly providerMetadata?: {
568
+ readonly [x: string]: {
569
+ readonly [x: string]: unknown;
570
+ };
571
+ } | undefined;
572
+ } | Schema.Struct.ReadonlySide<{
573
+ readonly type: Schema.tag<"tool-input-error">;
574
+ readonly id: Schema.String;
575
+ readonly name: Schema.String;
576
+ readonly raw: Schema.String;
577
+ }, "Type"> | {
578
+ readonly type: "tool-call";
579
+ readonly name: string;
580
+ readonly id: string;
581
+ readonly input: unknown;
582
+ readonly providerMetadata?: {
583
+ readonly [x: string]: {
584
+ readonly [x: string]: unknown;
585
+ };
586
+ } | undefined;
587
+ readonly providerExecuted?: boolean | undefined;
588
+ } | {
589
+ readonly type: "tool-result";
590
+ readonly name: string;
591
+ readonly id: string;
592
+ readonly result: Schema.Struct.ReadonlySide<{
593
+ readonly type: Schema.Literal<"json">;
594
+ readonly value: Schema.Unknown;
595
+ }, "Type"> | Schema.Struct.ReadonlySide<{
596
+ readonly type: Schema.Literal<"text">;
597
+ readonly value: Schema.Unknown;
598
+ }, "Type"> | Schema.Struct.ReadonlySide<{
599
+ readonly type: Schema.Literal<"error">;
600
+ readonly value: Schema.Unknown;
601
+ }, "Type"> | Schema.Struct.ReadonlySide<{
602
+ readonly type: Schema.Literal<"content">;
603
+ readonly value: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
604
+ readonly type: Schema.Literal<"text">;
605
+ readonly text: Schema.String;
606
+ }>, Schema.Struct<{
607
+ readonly type: Schema.Literal<"file">;
608
+ readonly uri: Schema.String;
609
+ readonly mime: Schema.String;
610
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
611
+ }>]>>;
612
+ }, "Type">;
613
+ readonly providerMetadata?: {
614
+ readonly [x: string]: {
615
+ readonly [x: string]: unknown;
616
+ };
617
+ } | undefined;
618
+ readonly providerExecuted?: boolean | undefined;
619
+ readonly output?: Schema.Struct.ReadonlySide<{
620
+ readonly structured: Schema.Unknown;
621
+ readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
622
+ readonly type: Schema.Literal<"text">;
623
+ readonly text: Schema.String;
624
+ }>, Schema.Struct<{
625
+ readonly type: Schema.Literal<"file">;
626
+ readonly uri: Schema.String;
627
+ readonly mime: Schema.String;
628
+ readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
629
+ }>]>>;
630
+ }, "Type"> | undefined;
631
+ } | {
632
+ readonly type: "tool-error";
633
+ readonly name: string;
634
+ readonly id: string;
635
+ readonly message: string;
636
+ readonly error?: unknown;
637
+ readonly providerMetadata?: {
638
+ readonly [x: string]: {
639
+ readonly [x: string]: unknown;
640
+ };
641
+ } | undefined;
642
+ } | {
643
+ readonly type: "step-finish";
644
+ readonly reason: {
645
+ readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
646
+ readonly raw?: string | undefined;
647
+ };
648
+ readonly index: number;
649
+ readonly providerMetadata?: {
650
+ readonly [x: string]: {
651
+ readonly [x: string]: unknown;
652
+ };
653
+ } | undefined;
654
+ readonly usage?: Usage | undefined;
655
+ } | {
656
+ readonly type: "finish";
657
+ readonly reason: {
658
+ readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
659
+ readonly raw?: string | undefined;
660
+ };
661
+ readonly providerMetadata?: {
662
+ readonly [x: string]: {
663
+ readonly [x: string]: unknown;
664
+ };
665
+ } | undefined;
666
+ readonly usage?: Usage | undefined;
667
+ } | {
668
+ readonly type: "provider-error";
669
+ readonly message: string;
670
+ readonly providerMetadata?: {
671
+ readonly [x: string]: {
672
+ readonly [x: string]: unknown;
673
+ };
674
+ } | undefined;
675
+ readonly classification?: "context-overflow" | undefined;
676
+ })[]], LLMError, never>;
388
677
  /**
389
678
  * The provider-neutral Open Responses protocol. Provider-specific Responses
390
679
  * implementations compose this baseline with their own tools and event variants.
@@ -419,13 +708,14 @@ export declare const protocol: Protocol<{
419
708
  readonly file_data: Schema.String;
420
709
  readonly mime_type: Schema.optional<Schema.String>;
421
710
  }>]>]>>;
422
- }, "Type"> | Schema.Struct.ReadonlySide<{
423
- readonly role: Schema.tag<"assistant">;
424
- readonly content: Schema.$Array<Schema.Struct<{
711
+ }, "Type"> | {
712
+ readonly content: readonly Schema.Struct.ReadonlySide<{
425
713
  readonly type: Schema.tag<"output_text">;
426
714
  readonly text: Schema.String;
427
- }>>;
428
- }, "Type"> | Schema.Struct.ReadonlySide<{
715
+ }, "Type">[];
716
+ readonly role: "assistant";
717
+ readonly phase?: "commentary" | "final_answer" | undefined;
718
+ } | Schema.Struct.ReadonlySide<{
429
719
  readonly type: Schema.tag<"function_call">;
430
720
  readonly call_id: Schema.String;
431
721
  readonly name: Schema.String;
@@ -484,6 +774,7 @@ export declare const protocol: Protocol<{
484
774
  readonly code?: string | null | undefined;
485
775
  readonly param?: string | null | undefined;
486
776
  } | null | undefined;
777
+ readonly text?: string | undefined;
487
778
  readonly response?: {
488
779
  readonly [x: string]: unknown;
489
780
  readonly error?: {
@@ -554,13 +845,14 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
554
845
  readonly file_data: Schema.String;
555
846
  readonly mime_type: Schema.optional<Schema.String>;
556
847
  }>]>]>>;
557
- }, "Type"> | Schema.Struct.ReadonlySide<{
558
- readonly role: Schema.tag<"assistant">;
559
- readonly content: Schema.$Array<Schema.Struct<{
848
+ }, "Type"> | {
849
+ readonly content: readonly Schema.Struct.ReadonlySide<{
560
850
  readonly type: Schema.tag<"output_text">;
561
851
  readonly text: Schema.String;
562
- }>>;
563
- }, "Type"> | Schema.Struct.ReadonlySide<{
852
+ }, "Type">[];
853
+ readonly role: "assistant";
854
+ readonly phase?: "commentary" | "final_answer" | undefined;
855
+ } | Schema.Struct.ReadonlySide<{
564
856
  readonly type: Schema.tag<"function_call">;
565
857
  readonly call_id: Schema.String;
566
858
  readonly name: Schema.String;