@opencode/protocol 0.0.0-dev-19654 → 0.0.0-dev-19657
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/api.d.ts +3 -3
- package/dist/api.js +2 -2
- package/dist/groups/form.d.ts +3 -651
- package/dist/groups/form.js +6 -83
- package/dist/groups/permission.d.ts +6 -13
- package/dist/groups/permission.js +1 -13
- package/dist/groups/session.d.ts +540 -24
- package/dist/groups/session.js +83 -24
- package/package.json +2 -2
package/dist/groups/session.js
CHANGED
|
@@ -9,7 +9,7 @@ import { AbsolutePath, DateTimeUtcFromMillis, NonNegativeInt, PositiveInt, Relat
|
|
|
9
9
|
import { Event } from "@opencode/schema/event";
|
|
10
10
|
import { Context, Effect, Encoding, Result, Schema, SchemaGetter, Struct } from "effect";
|
|
11
11
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
12
|
-
import { ConflictError, CommandExecutionError, CommandNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
|
|
12
|
+
import { ConflictError, CommandExecutionError, CommandNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidCursorError, InvalidRequestError, MessageNotFoundError, ServiceUnavailableError, SessionBusyError, SessionNotFoundError, SkillNotFoundError, UnknownError, } from "../errors.js";
|
|
13
13
|
import { Agent } from "@opencode/schema/agent";
|
|
14
14
|
import { Skill } from "@opencode/schema/skill";
|
|
15
15
|
import { Model } from "@opencode/schema/model";
|
|
@@ -18,6 +18,7 @@ import { Location } from "@opencode/schema/location";
|
|
|
18
18
|
import { SessionEvent } from "@opencode/schema/session-event";
|
|
19
19
|
import { EventLog } from "@opencode/schema/event-log";
|
|
20
20
|
import { FileDiff } from "@opencode/schema/file-diff";
|
|
21
|
+
import { Form } from "@opencode/schema/form";
|
|
21
22
|
import { PublicSessionMessage } from "./message.js";
|
|
22
23
|
const ParentIDFilter = Schema.Union([
|
|
23
24
|
Session.ID,
|
|
@@ -98,6 +99,12 @@ const PublicInboxInfo = Schema.Union([
|
|
|
98
99
|
SessionInbox.Compaction,
|
|
99
100
|
PublicMove,
|
|
100
101
|
]).annotate({ identifier: "Session.Inbox.Info" });
|
|
102
|
+
const FormCreatePayload = Schema.Struct({
|
|
103
|
+
id: Form.ID.pipe(Schema.optional),
|
|
104
|
+
title: Form.Info.fields.title,
|
|
105
|
+
metadata: Form.Info.fields.metadata,
|
|
106
|
+
fields: Form.Info.fields.fields,
|
|
107
|
+
}).annotate({ identifier: "Form.CreatePayload" });
|
|
101
108
|
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(Schema.decodeTo(Schema.Boolean, {
|
|
102
109
|
decode: SchemaGetter.transform((value) => value === "true"),
|
|
103
110
|
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
|
@@ -112,7 +119,7 @@ export const SessionsQuery = Schema.Struct({
|
|
|
112
119
|
subpath: RelativePath.pipe(Schema.optional),
|
|
113
120
|
cursor: SessionsQueryCursor.pipe(Schema.optional),
|
|
114
121
|
}).annotate({ identifier: "SessionsQuery" });
|
|
115
|
-
export const makeSessionGroup = (sessionLocationMiddleware) => HttpApiGroup.make("server.session")
|
|
122
|
+
export const makeSessionGroup = (sessionLocationMiddleware, formLocationMiddleware) => HttpApiGroup.make("server.session")
|
|
116
123
|
.add(HttpApiEndpoint.get("session.list", "/api/session", {
|
|
117
124
|
query: SessionsQuery,
|
|
118
125
|
success: Schema.Struct({
|
|
@@ -242,17 +249,20 @@ export const makeSessionGroup = (sessionLocationMiddleware) => HttpApiGroup.make
|
|
|
242
249
|
summary: "Switch session model",
|
|
243
250
|
description: "Switch the model used by subsequent provider turns.",
|
|
244
251
|
})))
|
|
245
|
-
.add(HttpApiEndpoint.patch("session.
|
|
252
|
+
.add(HttpApiEndpoint.patch("session.update", "/api/session/:sessionID", {
|
|
246
253
|
params: { sessionID: Session.ID },
|
|
247
|
-
payload: Schema.Struct({
|
|
254
|
+
payload: Schema.Struct({
|
|
255
|
+
title: Schema.String.pipe(Schema.optional),
|
|
256
|
+
permissions: Permission.Ruleset.pipe(Schema.optional),
|
|
257
|
+
}),
|
|
248
258
|
success: HttpApiSchema.NoContent,
|
|
249
259
|
error: SessionNotFoundError,
|
|
250
260
|
})
|
|
251
261
|
.middleware(sessionLocationMiddleware)
|
|
252
262
|
.annotateMerge(OpenApi.annotations({
|
|
253
|
-
identifier: "session.
|
|
254
|
-
summary: "
|
|
255
|
-
description: "Update
|
|
263
|
+
identifier: "session.update",
|
|
264
|
+
summary: "Update session",
|
|
265
|
+
description: "Update mutable session properties.",
|
|
256
266
|
})))
|
|
257
267
|
.add(HttpApiEndpoint.post("session.move", "/api/session/:sessionID/move", {
|
|
258
268
|
params: { sessionID: Session.ID },
|
|
@@ -440,29 +450,21 @@ export const makeSessionGroup = (sessionLocationMiddleware) => HttpApiGroup.make
|
|
|
440
450
|
.add(HttpApiEndpoint.delete("session.inbox.cancel", "/api/session/:sessionID/inbox/:inboxID", {
|
|
441
451
|
params: { sessionID: Session.ID, inboxID: SessionMessage.ID },
|
|
442
452
|
success: HttpApiSchema.NoContent,
|
|
443
|
-
error:
|
|
453
|
+
error: SessionNotFoundError,
|
|
444
454
|
}).annotateMerge(OpenApi.annotations({
|
|
445
455
|
identifier: "session.inbox.cancel",
|
|
446
456
|
summary: "Cancel inbox input",
|
|
447
|
-
description: "Cancel an inbox item that has not yet been delivered.",
|
|
448
|
-
})))
|
|
449
|
-
.add(HttpApiEndpoint.post("session.inbox.steer", "/api/session/:sessionID/inbox/:inboxID/steer", {
|
|
450
|
-
params: { sessionID: Session.ID, inboxID: SessionMessage.ID },
|
|
451
|
-
success: HttpApiSchema.NoContent,
|
|
452
|
-
error: [ConflictError, SessionNotFoundError],
|
|
453
|
-
}).annotateMerge(OpenApi.annotations({
|
|
454
|
-
identifier: "session.inbox.steer",
|
|
455
|
-
summary: "Steer queued item",
|
|
456
|
-
description: "Change a queued inbox item to steer delivery and wake session execution.",
|
|
457
|
+
description: "Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.",
|
|
457
458
|
})))
|
|
458
|
-
.add(HttpApiEndpoint.
|
|
459
|
+
.add(HttpApiEndpoint.patch("session.inbox.update", "/api/session/:sessionID/inbox/:inboxID", {
|
|
459
460
|
params: { sessionID: Session.ID, inboxID: SessionMessage.ID },
|
|
461
|
+
payload: Schema.Struct({ delivery: SessionInbox.Delivery }),
|
|
460
462
|
success: HttpApiSchema.NoContent,
|
|
461
463
|
error: [ConflictError, SessionNotFoundError],
|
|
462
464
|
}).annotateMerge(OpenApi.annotations({
|
|
463
|
-
identifier: "session.inbox.
|
|
464
|
-
summary: "
|
|
465
|
-
description: "Change a
|
|
465
|
+
identifier: "session.inbox.update",
|
|
466
|
+
summary: "Update inbox item",
|
|
467
|
+
description: "Change a pending inbox item's delivery mode. Steering wakes session execution.",
|
|
466
468
|
})))
|
|
467
469
|
.add(HttpApiEndpoint.get("session.instructions.entry.list", "/api/experimental/session/:sessionID/instructions/entries", {
|
|
468
470
|
params: { sessionID: Session.ID },
|
|
@@ -563,13 +565,70 @@ export const makeSessionGroup = (sessionLocationMiddleware) => HttpApiGroup.make
|
|
|
563
565
|
summary: "Get session message",
|
|
564
566
|
description: "Retrieve one projected message owned by the Session.",
|
|
565
567
|
})))
|
|
566
|
-
.add(HttpApiEndpoint.
|
|
568
|
+
.add(HttpApiEndpoint.get("session.form.list", "/api/session/:sessionID/form", {
|
|
569
|
+
params: { sessionID: Schema.String },
|
|
570
|
+
success: Schema.Struct({ data: Schema.Array(Form.Info) }),
|
|
571
|
+
error: SessionNotFoundError,
|
|
572
|
+
})
|
|
573
|
+
.middleware(formLocationMiddleware)
|
|
574
|
+
.annotateMerge(OpenApi.annotations({
|
|
575
|
+
identifier: "session.form.list",
|
|
576
|
+
summary: "List session forms",
|
|
577
|
+
description: "Retrieve pending forms for a session.",
|
|
578
|
+
})))
|
|
579
|
+
.add(HttpApiEndpoint.post("session.form.create", "/api/session/:sessionID/form", {
|
|
580
|
+
params: { sessionID: Schema.String },
|
|
581
|
+
payload: FormCreatePayload,
|
|
582
|
+
success: Schema.Struct({ data: Form.Info }),
|
|
583
|
+
error: [SessionNotFoundError, ConflictError, InvalidRequestError],
|
|
584
|
+
})
|
|
585
|
+
.middleware(formLocationMiddleware)
|
|
586
|
+
.annotateMerge(OpenApi.annotations({
|
|
587
|
+
identifier: "session.form.create",
|
|
588
|
+
summary: "Create session form",
|
|
589
|
+
description: "Create a form for a session.",
|
|
590
|
+
})))
|
|
591
|
+
.add(HttpApiEndpoint.get("session.form.get", "/api/session/:sessionID/form/:formID", {
|
|
592
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
593
|
+
success: Schema.Struct({ data: Form.Detail }),
|
|
594
|
+
error: [SessionNotFoundError, FormNotFoundError],
|
|
595
|
+
})
|
|
596
|
+
.middleware(formLocationMiddleware)
|
|
597
|
+
.annotateMerge(OpenApi.annotations({
|
|
598
|
+
identifier: "session.form.get",
|
|
599
|
+
summary: "Get session form",
|
|
600
|
+
description: "Retrieve a form and its current state for a session.",
|
|
601
|
+
})))
|
|
602
|
+
.add(HttpApiEndpoint.post("session.form.reply", "/api/session/:sessionID/form/:formID/reply", {
|
|
603
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
604
|
+
payload: Form.Reply,
|
|
605
|
+
success: HttpApiSchema.NoContent,
|
|
606
|
+
error: [SessionNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError],
|
|
607
|
+
})
|
|
608
|
+
.middleware(formLocationMiddleware)
|
|
609
|
+
.annotateMerge(OpenApi.annotations({
|
|
610
|
+
identifier: "session.form.reply",
|
|
611
|
+
summary: "Reply to form",
|
|
612
|
+
description: "Submit an answer to a pending form.",
|
|
613
|
+
})))
|
|
614
|
+
.add(HttpApiEndpoint.delete("session.form.cancel", "/api/session/:sessionID/form/:formID", {
|
|
615
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
616
|
+
success: HttpApiSchema.NoContent,
|
|
617
|
+
error: [SessionNotFoundError, FormAlreadySettledError, FormNotFoundError],
|
|
618
|
+
})
|
|
619
|
+
.middleware(formLocationMiddleware)
|
|
620
|
+
.annotateMerge(OpenApi.annotations({
|
|
621
|
+
identifier: "session.form.cancel",
|
|
622
|
+
summary: "Cancel form",
|
|
623
|
+
description: "Cancel a pending form.",
|
|
624
|
+
})))
|
|
625
|
+
.add(HttpApiEndpoint.put("session.environment", "/api/session/:sessionID/environment", {
|
|
567
626
|
params: { sessionID: Session.ID },
|
|
568
627
|
payload: Schema.Struct({ variables: Schema.Record(Schema.String, Schema.String) }),
|
|
569
628
|
success: HttpApiSchema.NoContent,
|
|
570
629
|
error: SessionNotFoundError,
|
|
571
630
|
}).annotateMerge(OpenApi.annotations({
|
|
572
|
-
identifier: "
|
|
631
|
+
identifier: "session.environment",
|
|
573
632
|
summary: "Set session environment",
|
|
574
633
|
description: "Replace the process environment used by local shell commands for this session.",
|
|
575
634
|
})))
|
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-19657",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typecheck": "tsgo --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@opencode/schema": "0.0.0-dev-
|
|
35
|
+
"@opencode/schema": "0.0.0-dev-19657",
|
|
36
36
|
"effect": "4.0.0-rc.112"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|