@opencode/schema 2.3.2 → 2.4.1

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.
@@ -185,6 +185,7 @@ export declare const User: Schema.Struct<{
185
185
  readonly time: Schema.Struct<{
186
186
  readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
187
187
  }>;
188
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
188
189
  readonly text: Schema.String;
189
190
  readonly files: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
190
191
  readonly data: Schema.String;
@@ -327,6 +328,7 @@ export declare const MediaUser: Schema.Struct<{
327
328
  readonly time: Schema.Struct<{
328
329
  readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
329
330
  }>;
331
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
330
332
  readonly text: Schema.String;
331
333
  readonly agents: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
332
334
  readonly name: Schema.String;
@@ -772,6 +774,7 @@ export interface AssistantText extends Schema.Schema.Type<typeof AssistantText>
772
774
  }
773
775
  export declare const AssistantText: Schema.Struct<{
774
776
  readonly type: Schema.tag<"text">;
777
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
775
778
  readonly text: Schema.String;
776
779
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
777
780
  }>;
@@ -791,6 +794,7 @@ export declare const AssistantReasoning: Schema.Struct<{
791
794
  }>;
792
795
  export declare const AssistantContent: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
793
796
  readonly type: Schema.tag<"text">;
797
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
794
798
  readonly text: Schema.String;
795
799
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
796
800
  }>, Schema.Struct<{
@@ -872,6 +876,7 @@ export declare const AssistantContent: Schema.toTaggedUnion<"type", readonly [Sc
872
876
  export type AssistantContent = AssistantText | AssistantReasoning | AssistantTool;
873
877
  export declare const AssistantContentEncoded: Schema.toEncoded<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
874
878
  readonly type: Schema.tag<"text">;
879
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
875
880
  readonly text: Schema.String;
876
881
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
877
882
  }>, Schema.Struct<{
@@ -1002,8 +1007,10 @@ export declare const Assistant: Schema.Struct<{
1002
1007
  readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
1003
1008
  };
1004
1009
  };
1010
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1005
1011
  readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
1006
1012
  readonly type: Schema.tag<"text">;
1013
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1007
1014
  readonly text: Schema.String;
1008
1015
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
1009
1016
  }>, Schema.Struct<{
@@ -1173,6 +1180,7 @@ export declare const Assistant: Schema.Struct<{
1173
1180
  readonly firstToken: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
1174
1181
  /** When the provider response body ended, before tool settlement. */
1175
1182
  readonly streamed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
1183
+ /** The session search index waits for this before indexing the message (`search-index.ts`). */
1176
1184
  readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
1177
1185
  }>;
1178
1186
  }>;
@@ -1277,6 +1285,7 @@ export declare const CompactionCompleted: Schema.Struct<{
1277
1285
  }>, never, never>;
1278
1286
  /** A provider compaction stores its replacement window in `native.messages`, replayed instead of `summary`. */
1279
1287
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
1288
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1280
1289
  readonly summary: Schema.String;
1281
1290
  }>;
1282
1291
  export interface CompactionFailed extends Schema.Schema.Type<typeof CompactionFailed> {
@@ -1423,6 +1432,7 @@ export declare const Compaction: Schema.Union<readonly [Schema.Struct<{
1423
1432
  }>, never, never>;
1424
1433
  /** A provider compaction stores its replacement window in `native.messages`, replayed instead of `summary`. */
1425
1434
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
1435
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1426
1436
  readonly summary: Schema.String;
1427
1437
  }>, Schema.Struct<{
1428
1438
  readonly id: Schema.brand<Schema.String, "Session.Message.ID"> & {
@@ -1674,6 +1684,7 @@ export declare const Info: Schema.Union<readonly [Schema.Struct<{
1674
1684
  readonly time: Schema.Struct<{
1675
1685
  readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
1676
1686
  }>;
1687
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1677
1688
  readonly text: Schema.String;
1678
1689
  readonly files: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
1679
1690
  readonly data: Schema.String;
@@ -1903,8 +1914,10 @@ export declare const Info: Schema.Union<readonly [Schema.Struct<{
1903
1914
  readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
1904
1915
  };
1905
1916
  };
1917
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1906
1918
  readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
1907
1919
  readonly type: Schema.tag<"text">;
1920
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
1908
1921
  readonly text: Schema.String;
1909
1922
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
1910
1923
  }>, Schema.Struct<{
@@ -2074,6 +2087,7 @@ export declare const Info: Schema.Union<readonly [Schema.Struct<{
2074
2087
  readonly firstToken: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2075
2088
  /** When the provider response body ended, before tool settlement. */
2076
2089
  readonly streamed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2090
+ /** The session search index waits for this before indexing the message (`search-index.ts`). */
2077
2091
  readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2078
2092
  }>;
2079
2093
  }>, Schema.Union<readonly [Schema.Struct<{
@@ -2172,6 +2186,7 @@ export declare const Info: Schema.Union<readonly [Schema.Struct<{
2172
2186
  }>, never, never>;
2173
2187
  /** A provider compaction stores its replacement window in `native.messages`, replayed instead of `summary`. */
2174
2188
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
2189
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
2175
2190
  readonly summary: Schema.String;
2176
2191
  }>, Schema.Struct<{
2177
2192
  readonly id: Schema.brand<Schema.String, "Session.Message.ID"> & {
@@ -2417,6 +2432,7 @@ export declare const MediaInfo: Schema.Union<readonly [Schema.Struct<{
2417
2432
  readonly time: Schema.Struct<{
2418
2433
  readonly created: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
2419
2434
  }>;
2435
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
2420
2436
  readonly text: Schema.String;
2421
2437
  readonly agents: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
2422
2438
  readonly name: Schema.String;
@@ -2692,8 +2708,10 @@ export declare const MediaInfo: Schema.Union<readonly [Schema.Struct<{
2692
2708
  readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
2693
2709
  };
2694
2710
  };
2711
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
2695
2712
  readonly content: Schema.$Array<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
2696
2713
  readonly type: Schema.tag<"text">;
2714
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
2697
2715
  readonly text: Schema.String;
2698
2716
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
2699
2717
  }>, Schema.Struct<{
@@ -2863,6 +2881,7 @@ export declare const MediaInfo: Schema.Union<readonly [Schema.Struct<{
2863
2881
  readonly firstToken: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2864
2882
  /** When the provider response body ended, before tool settlement. */
2865
2883
  readonly streamed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2884
+ /** The session search index waits for this before indexing the message (`search-index.ts`). */
2866
2885
  readonly completed: Schema.decodeTo<Schema.optional<Schema.toType<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>>, Schema.optionalKey<Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>>, never, never>;
2867
2886
  }>;
2868
2887
  }>, Schema.Union<readonly [Schema.Struct<{
@@ -2961,6 +2980,7 @@ export declare const MediaInfo: Schema.Union<readonly [Schema.Struct<{
2961
2980
  }>, never, never>;
2962
2981
  /** A provider compaction stores its replacement window in `native.messages`, replayed instead of `summary`. */
2963
2982
  readonly native: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
2983
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
2964
2984
  readonly summary: Schema.String;
2965
2985
  }>, Schema.Struct<{
2966
2986
  readonly id: Schema.brand<Schema.String, "Session.Message.ID"> & {
@@ -58,6 +58,7 @@ export const LocationSwitched = Schema.Struct({
58
58
  }).annotate({ identifier: "Session.Message.LocationSwitched" });
59
59
  export const User = Schema.Struct({
60
60
  ...Base,
61
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
61
62
  text: Prompt.fields.text,
62
63
  files: Prompt.fields.files,
63
64
  agents: Prompt.fields.agents,
@@ -140,6 +141,7 @@ export const AssistantTool = Schema.Struct({
140
141
  }).annotate({ identifier: "Session.Message.Assistant.Tool" });
141
142
  export const AssistantText = Schema.Struct({
142
143
  type: Schema.tag("text"),
144
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
143
145
  text: Schema.String,
144
146
  native: Native.pipe(optional),
145
147
  }).annotate({ identifier: "Session.Message.Assistant.Text" });
@@ -166,6 +168,7 @@ export const Assistant = Schema.Struct({
166
168
  type: Schema.tag("assistant"),
167
169
  agent: Agent.ID,
168
170
  model: Model.Ref,
171
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
169
172
  content: AssistantContent.pipe(Schema.Array),
170
173
  snapshot: Schema.Struct({
171
174
  start: Snapshot.ID.pipe(optional),
@@ -186,6 +189,7 @@ export const Assistant = Schema.Struct({
186
189
  firstToken: DateTimeUtcFromMillis.pipe(optional),
187
190
  /** When the provider response body ended, before tool settlement. */
188
191
  streamed: DateTimeUtcFromMillis.pipe(optional),
192
+ /** The session search index waits for this before indexing the message (`search-index.ts`). */
189
193
  completed: DateTimeUtcFromMillis.pipe(optional),
190
194
  }),
191
195
  }).annotate({ identifier: "Session.Message.Assistant" });
@@ -208,6 +212,7 @@ export const CompactionCompleted = Schema.Struct({
208
212
  model: Model.Ref.pipe(optional),
209
213
  /** A provider compaction stores its replacement window in `native.messages`, replayed instead of `summary`. */
210
214
  native: Native.pipe(optional),
215
+ /** Read by the session search index's SQL (`packages/core/src/session/search-index.ts`); a rename needs its `Version` bumped. */
211
216
  summary: Schema.String,
212
217
  ...CompactionUsage,
213
218
  }).annotate({ identifier: "Session.Message.Compaction.Completed" });
package/dist/tool.d.ts CHANGED
@@ -30,25 +30,28 @@ export interface Context {
30
30
  * has; a tool that does not is interrupted.
31
31
  */
32
32
  readonly cancel?: Effect.Effect<void>;
33
+ /** True when the tool is invoked from inside Code Mode (`execute`). */
34
+ readonly codemode?: boolean;
33
35
  }
34
36
  export interface Namespace {
35
37
  readonly name: string;
36
38
  readonly description: string;
37
39
  }
38
- interface BaseOptions {
40
+ export interface Options<CMInput extends ValueSchema<any> = ValueSchema<any>, CMOutput extends ValueSchema<any> | undefined = ValueSchema<any> | undefined> {
39
41
  readonly namespace?: string;
40
42
  readonly permission?: string;
41
- }
42
- export type Options = BaseOptions & ({
43
- readonly codemode?: true;
43
+ readonly codemode?: boolean | {
44
+ readonly pinned?: boolean;
45
+ readonly description?: string;
46
+ readonly input?: CMInput;
47
+ readonly output?: CMOutput;
48
+ };
49
+ /** @deprecated Use `codemode.pinned` instead. Removed in the next minor. */
44
50
  readonly pinned?: boolean;
45
- } | {
46
- readonly codemode: boolean;
47
- readonly pinned?: never;
48
- });
51
+ }
49
52
  export type ValueSchema<A = unknown> = Schema.Codec<A, any> | StandardSchemaV1<any, A> | JsonSchema.JsonSchema;
50
53
  type InputValue<S> = 0 extends 1 & S ? any : S extends Schema.Codec<infer A, any> ? A : S extends StandardSchemaV1<any, infer A> ? A : unknown;
51
- type OutputValue<S> = S extends undefined ? never : S extends Schema.Codec<infer A, any> ? A : S extends StandardSchemaV1<infer A, any> ? A : any;
54
+ type OutputValue<S> = 0 extends 1 & S ? any : S extends undefined ? never : S extends Schema.Codec<infer A, any> ? A : S extends StandardSchemaV1<infer A, any> ? A : any;
52
55
  declare const Error_base: Schema.Class<Error, Schema.TaggedStruct<"Tool.Error", {
53
56
  readonly message: Schema.String;
54
57
  readonly error: Schema.optional<Schema.Defect>;
@@ -85,12 +88,12 @@ export interface Result<Output extends ValueSchema<any> | undefined = ValueSchem
85
88
  readonly content?: string | ReadonlyArray<Content>;
86
89
  readonly metadata?: Metadata;
87
90
  }
88
- export type Info<Input extends ValueSchema<any> = ValueSchema<any>, Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined> = {
91
+ export type Info<Input extends ValueSchema<any> = ValueSchema<any>, Output extends ValueSchema<any> | undefined = ValueSchema<any> | undefined, CMInput extends ValueSchema<any> = Input, CMOutput extends ValueSchema<any> | undefined = Output> = {
89
92
  readonly name: string;
90
93
  readonly input: Input;
91
94
  readonly freeform?: Freeform;
92
95
  readonly description: string;
93
- readonly execute: (input: InputValue<Input>, context: Context) => Effect.Effect<Result<Output>, Error>;
96
+ readonly execute: (input: InputValue<Input> | InputValue<CMInput>, context: Context) => Effect.Effect<Result<Output | CMOutput>, Error>;
94
97
  readonly output?: Output;
95
- readonly options?: Options;
98
+ readonly options?: Options<CMInput, CMOutput>;
96
99
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/schema",
4
- "version": "2.3.2",
4
+ "version": "2.4.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {