@opencode/protocol 0.0.0-dev-21086 → 0.0.0-dev-21090
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/groups/session.d.ts +175 -76
- package/dist/groups/session.js +11 -68
- package/package.json +2 -2
package/dist/groups/session.d.ts
CHANGED
|
@@ -1,63 +1,43 @@
|
|
|
1
1
|
import { PromptInput } from "@opencode/schema/prompt-input";
|
|
2
|
+
import { Session } from "@opencode/schema/session";
|
|
2
3
|
import { InstructionEntry } from "@opencode/schema/instruction-entry";
|
|
3
4
|
import { Event } from "@opencode/schema/event";
|
|
4
|
-
import { Context,
|
|
5
|
+
import { Context, Schema } from "effect";
|
|
5
6
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema } from "effect/http-api";
|
|
6
7
|
import { ConflictError, LocationNotFoundError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError } from "../errors.js";
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly order: Schema.optional<Schema.Union<readonly [Schema.Literal<"asc">, Schema.Literal<"desc">]>>;
|
|
15
|
-
readonly anchor: Schema.Struct<{
|
|
16
|
-
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
17
|
-
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
18
|
-
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
8
|
+
export declare const SessionsCursor: Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
9
|
+
make: (input: {
|
|
10
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
11
|
+
readonly anchor: {
|
|
12
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
13
|
+
readonly time: number;
|
|
14
|
+
readonly direction: "previous" | "next";
|
|
19
15
|
};
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
30
|
-
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
31
|
-
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
32
|
-
readonly search: Schema.optional<Schema.String>;
|
|
33
|
-
readonly order: Schema.optional<Schema.Union<readonly [Schema.Literal<"asc">, Schema.Literal<"desc">]>>;
|
|
34
|
-
readonly anchor: Schema.Struct<{
|
|
35
|
-
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
36
|
-
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
37
|
-
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
16
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
17
|
+
readonly search?: string | undefined;
|
|
18
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
21
|
+
readonly anchor: {
|
|
22
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
23
|
+
readonly time: number;
|
|
24
|
+
readonly direction: "previous" | "next";
|
|
38
25
|
};
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
readonly order: Schema.optional<Schema.Union<readonly [Schema.Literal<"asc">, Schema.Literal<"desc">]>>;
|
|
49
|
-
readonly anchor: Schema.Struct<{
|
|
50
|
-
readonly id: Schema.brand<Schema.String, "SessionID"> & {
|
|
51
|
-
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
52
|
-
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
26
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
27
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
28
|
+
readonly search?: string | undefined;
|
|
29
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
readonly anchor: {
|
|
32
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
33
|
+
readonly time: number;
|
|
34
|
+
readonly direction: "previous" | "next";
|
|
53
35
|
};
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
make: (input: typeof SessionsCursorInput.Type) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
60
|
-
parse: (input: string) => Effect.Effect<{
|
|
36
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
37
|
+
readonly search?: string | undefined;
|
|
38
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
39
|
+
}) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
40
|
+
parse: (input: string) => import("effect/Effect").Effect<{
|
|
61
41
|
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
62
42
|
readonly anchor: {
|
|
63
43
|
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
@@ -89,16 +69,41 @@ export declare const SessionsCursor: Schema.brand<Schema.String, "SessionsCursor
|
|
|
89
69
|
readonly order?: "asc" | "desc" | undefined;
|
|
90
70
|
}, "Invalid cursor", never>;
|
|
91
71
|
};
|
|
92
|
-
export type SessionsCursor =
|
|
72
|
+
export type SessionsCursor = Session.ListCursor;
|
|
93
73
|
export declare const SessionsQuery: Schema.Struct<{
|
|
94
|
-
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
95
|
-
readonly project: Schema.optional<Schema.brand<Schema.String, "Project.ID"> & {
|
|
96
|
-
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
97
|
-
}>;
|
|
98
|
-
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
99
74
|
readonly cursor: Schema.optional<Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
100
|
-
make: (input:
|
|
101
|
-
|
|
75
|
+
make: (input: {
|
|
76
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
77
|
+
readonly anchor: {
|
|
78
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
79
|
+
readonly time: number;
|
|
80
|
+
readonly direction: "previous" | "next";
|
|
81
|
+
};
|
|
82
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
83
|
+
readonly search?: string | undefined;
|
|
84
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
87
|
+
readonly anchor: {
|
|
88
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
89
|
+
readonly time: number;
|
|
90
|
+
readonly direction: "previous" | "next";
|
|
91
|
+
};
|
|
92
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
93
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
94
|
+
readonly search?: string | undefined;
|
|
95
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
readonly anchor: {
|
|
98
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
99
|
+
readonly time: number;
|
|
100
|
+
readonly direction: "previous" | "next";
|
|
101
|
+
};
|
|
102
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
103
|
+
readonly search?: string | undefined;
|
|
104
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
105
|
+
}) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
106
|
+
parse: (input: string) => import("effect/Effect").Effect<{
|
|
102
107
|
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
103
108
|
readonly anchor: {
|
|
104
109
|
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
@@ -130,23 +135,53 @@ export declare const SessionsQuery: Schema.Struct<{
|
|
|
130
135
|
readonly order?: "asc" | "desc" | undefined;
|
|
131
136
|
}, "Invalid cursor", never>;
|
|
132
137
|
}>;
|
|
133
|
-
readonly
|
|
134
|
-
readonly
|
|
138
|
+
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
139
|
+
readonly project: Schema.optional<Schema.brand<Schema.String, "Project.ID"> & {
|
|
140
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
141
|
+
}>;
|
|
142
|
+
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
143
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
135
144
|
readonly search: Schema.optional<Schema.String>;
|
|
136
145
|
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
137
146
|
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
138
147
|
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
139
148
|
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
149
|
+
readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
|
|
140
150
|
}>;
|
|
141
151
|
export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, FormI extends HttpApiMiddleware.AnyId, FormS>(sessionLocationMiddleware: Context.Key<I, S>, formLocationMiddleware: Context.Key<FormI, FormS>) => HttpApiGroup.HttpApiGroup<"server.session", HttpApiEndpoint.HttpApiEndpoint<"session.list", "GET", "/api/session", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
142
|
-
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
143
|
-
readonly project: Schema.optional<Schema.brand<Schema.String, "Project.ID"> & {
|
|
144
|
-
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
145
|
-
}>;
|
|
146
|
-
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
147
152
|
readonly cursor: Schema.optional<Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
148
|
-
make: (input:
|
|
149
|
-
|
|
153
|
+
make: (input: {
|
|
154
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
155
|
+
readonly anchor: {
|
|
156
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
157
|
+
readonly time: number;
|
|
158
|
+
readonly direction: "previous" | "next";
|
|
159
|
+
};
|
|
160
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
161
|
+
readonly search?: string | undefined;
|
|
162
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
165
|
+
readonly anchor: {
|
|
166
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
167
|
+
readonly time: number;
|
|
168
|
+
readonly direction: "previous" | "next";
|
|
169
|
+
};
|
|
170
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
171
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
172
|
+
readonly search?: string | undefined;
|
|
173
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
174
|
+
} | {
|
|
175
|
+
readonly anchor: {
|
|
176
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
177
|
+
readonly time: number;
|
|
178
|
+
readonly direction: "previous" | "next";
|
|
179
|
+
};
|
|
180
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
181
|
+
readonly search?: string | undefined;
|
|
182
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
183
|
+
}) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
184
|
+
parse: (input: string) => import("effect/Effect").Effect<{
|
|
150
185
|
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
151
186
|
readonly anchor: {
|
|
152
187
|
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
@@ -178,13 +213,18 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
|
|
|
178
213
|
readonly order?: "asc" | "desc" | undefined;
|
|
179
214
|
}, "Invalid cursor", never>;
|
|
180
215
|
}>;
|
|
181
|
-
readonly
|
|
182
|
-
readonly
|
|
216
|
+
readonly directory: Schema.optional<Schema.brand<Schema.String, "AbsolutePath">>;
|
|
217
|
+
readonly project: Schema.optional<Schema.brand<Schema.String, "Project.ID"> & {
|
|
218
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
219
|
+
}>;
|
|
220
|
+
readonly subpath: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
221
|
+
readonly order: Schema.optional<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
183
222
|
readonly search: Schema.optional<Schema.String>;
|
|
184
223
|
readonly parentID: Schema.optional<Schema.Union<readonly [Schema.brand<Schema.String, "SessionID"> & {
|
|
185
224
|
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
186
225
|
descending: (id?: string) => string & import("effect/Brand").Brand<"SessionID">;
|
|
187
226
|
}, Schema.decodeTo<Schema.Null, Schema.Literal<"null">, never, never>]>>;
|
|
227
|
+
readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
|
|
188
228
|
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
189
229
|
readonly data: Schema.$Array<Schema.Struct<{
|
|
190
230
|
readonly location: Schema.Struct<{
|
|
@@ -363,8 +403,38 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
|
|
|
363
403
|
}>>;
|
|
364
404
|
readonly cursor: Schema.Struct<{
|
|
365
405
|
readonly previous: Schema.optional<Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
366
|
-
make: (input:
|
|
367
|
-
|
|
406
|
+
make: (input: {
|
|
407
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
408
|
+
readonly anchor: {
|
|
409
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
410
|
+
readonly time: number;
|
|
411
|
+
readonly direction: "previous" | "next";
|
|
412
|
+
};
|
|
413
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
414
|
+
readonly search?: string | undefined;
|
|
415
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
416
|
+
} | {
|
|
417
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
418
|
+
readonly anchor: {
|
|
419
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
420
|
+
readonly time: number;
|
|
421
|
+
readonly direction: "previous" | "next";
|
|
422
|
+
};
|
|
423
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
424
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
425
|
+
readonly search?: string | undefined;
|
|
426
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
427
|
+
} | {
|
|
428
|
+
readonly anchor: {
|
|
429
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
430
|
+
readonly time: number;
|
|
431
|
+
readonly direction: "previous" | "next";
|
|
432
|
+
};
|
|
433
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
434
|
+
readonly search?: string | undefined;
|
|
435
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
436
|
+
}) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
437
|
+
parse: (input: string) => import("effect/Effect").Effect<{
|
|
368
438
|
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
369
439
|
readonly anchor: {
|
|
370
440
|
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
@@ -397,8 +467,38 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
|
|
|
397
467
|
}, "Invalid cursor", never>;
|
|
398
468
|
}>;
|
|
399
469
|
readonly next: Schema.optional<Schema.brand<Schema.String, "SessionsCursor"> & {
|
|
400
|
-
make: (input:
|
|
401
|
-
|
|
470
|
+
make: (input: {
|
|
471
|
+
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
472
|
+
readonly anchor: {
|
|
473
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
474
|
+
readonly time: number;
|
|
475
|
+
readonly direction: "previous" | "next";
|
|
476
|
+
};
|
|
477
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
478
|
+
readonly search?: string | undefined;
|
|
479
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
480
|
+
} | {
|
|
481
|
+
readonly project: string & import("effect/Brand").Brand<"Project.ID">;
|
|
482
|
+
readonly anchor: {
|
|
483
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
484
|
+
readonly time: number;
|
|
485
|
+
readonly direction: "previous" | "next";
|
|
486
|
+
};
|
|
487
|
+
readonly subpath?: (string & import("effect/Brand").Brand<"RelativePath">) | undefined;
|
|
488
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
489
|
+
readonly search?: string | undefined;
|
|
490
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
491
|
+
} | {
|
|
492
|
+
readonly anchor: {
|
|
493
|
+
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
494
|
+
readonly time: number;
|
|
495
|
+
readonly direction: "previous" | "next";
|
|
496
|
+
};
|
|
497
|
+
readonly parentID?: (string & import("effect/Brand").Brand<"SessionID">) | null | undefined;
|
|
498
|
+
readonly search?: string | undefined;
|
|
499
|
+
readonly order?: "asc" | "desc" | undefined;
|
|
500
|
+
}) => string & import("effect/Brand").Brand<"SessionsCursor">;
|
|
501
|
+
parse: (input: string) => import("effect/Effect").Effect<{
|
|
402
502
|
readonly directory: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
403
503
|
readonly anchor: {
|
|
404
504
|
readonly id: string & import("effect/Brand").Brand<"SessionID">;
|
|
@@ -11600,4 +11700,3 @@ export declare const makeSessionGroup: <I extends HttpApiMiddleware.AnyId, S, Fo
|
|
|
11600
11700
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
11601
11701
|
readonly idle: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
|
|
11602
11702
|
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof SessionNotFoundError>, never, never>, false>;
|
|
11603
|
-
export {};
|
package/dist/groups/session.js
CHANGED
|
@@ -5,10 +5,9 @@ import { Session } from "@opencode/schema/session";
|
|
|
5
5
|
import { SessionStats } from "@opencode/schema/session-stats";
|
|
6
6
|
import { InstructionEntry } from "@opencode/schema/instruction-entry";
|
|
7
7
|
import { Project } from "@opencode/schema/project";
|
|
8
|
-
import {
|
|
8
|
+
import { DateTimeUtcFromMillis, NonNegativeInt, PositiveInt } from "@opencode/schema/schema";
|
|
9
9
|
import { Event } from "@opencode/schema/event";
|
|
10
|
-
import { Context,
|
|
11
|
-
import { Base64Url } from "effect/encoding";
|
|
10
|
+
import { Context, Schema, SchemaGetter, Struct } from "effect";
|
|
12
11
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
13
12
|
import { ConflictError, LocationNotFoundError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
|
|
14
13
|
import { Agent } from "@opencode/schema/agent";
|
|
@@ -21,64 +20,6 @@ import { EventLog } from "@opencode/schema/event-log";
|
|
|
21
20
|
import { FileDiff } from "@opencode/schema/file-diff";
|
|
22
21
|
import { Form } from "@opencode/schema/form";
|
|
23
22
|
import { PublicSessionMessage } from "./message.js";
|
|
24
|
-
const ParentIDFilter = Schema.Union([
|
|
25
|
-
Session.ID,
|
|
26
|
-
Schema.Null.pipe(Schema.encodeTo(Schema.Literal("null"), {
|
|
27
|
-
decode: SchemaGetter.transform(() => null),
|
|
28
|
-
encode: SchemaGetter.transform(() => "null"),
|
|
29
|
-
})),
|
|
30
|
-
]).annotate({
|
|
31
|
-
description: "Filter by parent session. Use null to return only root sessions.",
|
|
32
|
-
});
|
|
33
|
-
const SessionsQueryFields = {
|
|
34
|
-
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional).annotate({
|
|
35
|
-
description: "Maximum number of sessions to return. Defaults to the newest 50 sessions.",
|
|
36
|
-
}),
|
|
37
|
-
order: Schema.optional(Schema.Union([Schema.Literal("asc"), Schema.Literal("desc")])).annotate({
|
|
38
|
-
description: "Session order for the first page. Use desc for newest first or asc for oldest first.",
|
|
39
|
-
}),
|
|
40
|
-
search: Schema.optional(Schema.String),
|
|
41
|
-
parentID: ParentIDFilter.pipe(Schema.optional),
|
|
42
|
-
};
|
|
43
|
-
const SessionsDirectoryQuery = Schema.Struct({
|
|
44
|
-
...SessionsQueryFields,
|
|
45
|
-
directory: AbsolutePath,
|
|
46
|
-
});
|
|
47
|
-
const SessionsProjectQuery = Schema.Struct({
|
|
48
|
-
...SessionsQueryFields,
|
|
49
|
-
project: Project.ID,
|
|
50
|
-
subpath: RelativePath.pipe(Schema.optional),
|
|
51
|
-
});
|
|
52
|
-
const SessionsAllQuery = Schema.Struct(SessionsQueryFields);
|
|
53
|
-
const withCursor = (schema) => schema.mapFields((fields) => ({
|
|
54
|
-
...Struct.omit(fields, ["limit"]),
|
|
55
|
-
anchor: Session.ListAnchor,
|
|
56
|
-
}));
|
|
57
|
-
const SessionsCursorInput = Schema.Union([
|
|
58
|
-
withCursor(SessionsDirectoryQuery),
|
|
59
|
-
withCursor(SessionsProjectQuery),
|
|
60
|
-
withCursor(SessionsAllQuery),
|
|
61
|
-
]);
|
|
62
|
-
const SessionsCursorJson = Schema.fromJsonString(SessionsCursorInput);
|
|
63
|
-
const encodeSessionsCursor = Schema.encodeSync(SessionsCursorJson);
|
|
64
|
-
const decodeSessionsCursor = Schema.decodeUnknownEffect(SessionsCursorJson);
|
|
65
|
-
const invalidCursor = "Invalid cursor";
|
|
66
|
-
export const SessionsCursor = Schema.String.pipe(Schema.brand("SessionsCursor"), Schema.annotate({
|
|
67
|
-
identifier: "SessionsCursor",
|
|
68
|
-
description: "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response.",
|
|
69
|
-
}), statics((schema) => {
|
|
70
|
-
// Read the default constructor without caching it on the schema, so `make` can be replaced.
|
|
71
|
-
const make = SchemaParser.make(schema);
|
|
72
|
-
return {
|
|
73
|
-
make: (input) => make(Base64Url.encode(encodeSessionsCursor(input))),
|
|
74
|
-
parse: (input) => Effect.suspend(() => {
|
|
75
|
-
const result = Base64Url.decodeString(input);
|
|
76
|
-
return Result.isFailure(result)
|
|
77
|
-
? Effect.fail(invalidCursor)
|
|
78
|
-
: decodeSessionsCursor(result.success).pipe(Effect.mapError(() => invalidCursor));
|
|
79
|
-
}),
|
|
80
|
-
};
|
|
81
|
-
}));
|
|
82
23
|
const SessionActive = Schema.Struct({
|
|
83
24
|
type: Schema.Literal("running"),
|
|
84
25
|
}).annotate({ identifier: "SessionActive" });
|
|
@@ -114,12 +55,14 @@ const BooleanFromString = Schema.Literals(["true", "false"]).pipe(Schema.decodeT
|
|
|
114
55
|
decode: SchemaGetter.transform((value) => value === "true"),
|
|
115
56
|
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
|
116
57
|
}));
|
|
58
|
+
// Kept so existing imports of SessionsCursor from Protocol keep working.
|
|
59
|
+
export const SessionsCursor = Session.ListCursor;
|
|
117
60
|
export const SessionsQuery = Schema.Struct({
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
cursor:
|
|
61
|
+
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional).annotate({
|
|
62
|
+
description: "Maximum number of sessions to return. Defaults to the newest 50 sessions.",
|
|
63
|
+
}),
|
|
64
|
+
...Session.ListFilter.fields,
|
|
65
|
+
cursor: Session.ListCursor.pipe(Schema.optional),
|
|
123
66
|
}).annotate({ identifier: "SessionsQuery" });
|
|
124
67
|
export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddleware) => HttpApiGroup.make("server.session")
|
|
125
68
|
.add(HttpApiEndpoint.get("session.list", "/api/session", {
|
|
@@ -127,8 +70,8 @@ export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddlewa
|
|
|
127
70
|
success: Schema.Struct({
|
|
128
71
|
data: Schema.Array(PublicSessionInfo),
|
|
129
72
|
cursor: Schema.Struct({
|
|
130
|
-
previous:
|
|
131
|
-
next:
|
|
73
|
+
previous: Session.ListCursor.pipe(Schema.optional),
|
|
74
|
+
next: Session.ListCursor.pipe(Schema.optional),
|
|
132
75
|
}),
|
|
133
76
|
}).annotate({ identifier: "SessionsResponse" }),
|
|
134
77
|
error: [InvalidCursorError, InvalidRequestError],
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/protocol",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-21090",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typecheck": "tsgo --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@opencode/schema": "0.0.0-dev-
|
|
36
|
+
"@opencode/schema": "0.0.0-dev-21090",
|
|
37
37
|
"effect": "4.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|