@opencode-ai/protocol 0.0.0-next-14722 → 0.0.0-next-14730
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 +11 -8
- package/dist/api.js +5 -5
- package/dist/client.d.ts +3 -3
- package/dist/client.js +5 -2
- package/dist/errors.d.ts +15 -3
- package/dist/errors.js +12 -2
- package/dist/groups/event.d.ts +1711 -1227
- package/dist/groups/event.js +11 -3
- package/dist/groups/form.d.ts +823 -0
- package/dist/groups/form.js +110 -0
- package/dist/groups/message.d.ts +1 -0
- package/dist/groups/message.js +5 -0
- package/dist/groups/session.d.ts +322 -2990
- package/dist/groups/session.js +23 -29
- package/package.json +2 -2
- package/dist/groups/question.d.ts +0 -92
- package/dist/groups/question.js +0 -56
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Form } from "@opencode-ai/schema/form";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Context, Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
import { ConflictError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidRequestError } from "../errors.js";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
const CreatePayload = Schema.Struct({
|
|
8
|
+
id: Form.ID.pipe(Schema.optional),
|
|
9
|
+
title: Form.FormInfo.fields.title,
|
|
10
|
+
metadata: Form.FormInfo.fields.metadata,
|
|
11
|
+
mode: Schema.Literals(["form", "url"]),
|
|
12
|
+
fields: Form.FormInfo.fields.fields.pipe(Schema.optional),
|
|
13
|
+
url: Form.UrlInfo.fields.url.pipe(Schema.optional),
|
|
14
|
+
}).annotate({ identifier: "Form.CreatePayload" });
|
|
15
|
+
// Form routes intentionally look session-scoped, but use a form-specific middleware instead of
|
|
16
|
+
// SessionLocationMiddleware. The middleware treats real session IDs normally and has an
|
|
17
|
+
// undocumented `global` sentinel branch for MCP elicitation forms that are still Location-scoped
|
|
18
|
+
// but not session-owned. This is temporary and should disappear once elicitations are attributable.
|
|
19
|
+
export const makeFormGroup = (locationMiddleware, formLocationMiddleware) => HttpApiGroup.make("server.form")
|
|
20
|
+
.add(HttpApiEndpoint.get("form.request.list", "/api/form/request", {
|
|
21
|
+
query: LocationQuery,
|
|
22
|
+
success: Location.response(Schema.Array(Form.Info)),
|
|
23
|
+
})
|
|
24
|
+
.annotateMerge(locationQueryOpenApi)
|
|
25
|
+
.annotateMerge(OpenApi.annotations({
|
|
26
|
+
identifier: "v2.form.request.list",
|
|
27
|
+
summary: "List pending form requests",
|
|
28
|
+
description: "Retrieve pending forms for a location.",
|
|
29
|
+
})))
|
|
30
|
+
.middleware(locationMiddleware)
|
|
31
|
+
.add(HttpApiEndpoint.get("session.form.list", "/api/session/:sessionID/form", {
|
|
32
|
+
params: { sessionID: Schema.String },
|
|
33
|
+
query: LocationQuery,
|
|
34
|
+
success: Location.response(Schema.Array(Form.Info)),
|
|
35
|
+
})
|
|
36
|
+
.annotateMerge(locationQueryOpenApi)
|
|
37
|
+
.annotateMerge(OpenApi.annotations({
|
|
38
|
+
identifier: "v2.session.form.list",
|
|
39
|
+
summary: "List session forms",
|
|
40
|
+
description: "Retrieve pending forms for a session.",
|
|
41
|
+
}))
|
|
42
|
+
.middleware(formLocationMiddleware))
|
|
43
|
+
.add(HttpApiEndpoint.post("session.form.create", "/api/session/:sessionID/form", {
|
|
44
|
+
params: { sessionID: Schema.String },
|
|
45
|
+
query: LocationQuery,
|
|
46
|
+
payload: CreatePayload,
|
|
47
|
+
success: Location.response(Form.Info),
|
|
48
|
+
error: [ConflictError, InvalidRequestError],
|
|
49
|
+
})
|
|
50
|
+
.annotateMerge(locationQueryOpenApi)
|
|
51
|
+
.annotateMerge(OpenApi.annotations({
|
|
52
|
+
identifier: "v2.session.form.create",
|
|
53
|
+
summary: "Create session form",
|
|
54
|
+
description: "Create a form for a session.",
|
|
55
|
+
}))
|
|
56
|
+
.middleware(formLocationMiddleware))
|
|
57
|
+
.add(HttpApiEndpoint.get("session.form.get", "/api/session/:sessionID/form/:formID", {
|
|
58
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
59
|
+
query: LocationQuery,
|
|
60
|
+
success: Location.response(Form.Info),
|
|
61
|
+
error: FormNotFoundError,
|
|
62
|
+
})
|
|
63
|
+
.annotateMerge(locationQueryOpenApi)
|
|
64
|
+
.annotateMerge(OpenApi.annotations({
|
|
65
|
+
identifier: "v2.session.form.get",
|
|
66
|
+
summary: "Get session form",
|
|
67
|
+
description: "Retrieve a form for a session.",
|
|
68
|
+
}))
|
|
69
|
+
.middleware(formLocationMiddleware))
|
|
70
|
+
.add(HttpApiEndpoint.get("session.form.state", "/api/session/:sessionID/form/:formID/state", {
|
|
71
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
72
|
+
query: LocationQuery,
|
|
73
|
+
success: Location.response(Form.State),
|
|
74
|
+
error: FormNotFoundError,
|
|
75
|
+
})
|
|
76
|
+
.annotateMerge(locationQueryOpenApi)
|
|
77
|
+
.annotateMerge(OpenApi.annotations({
|
|
78
|
+
identifier: "v2.session.form.state",
|
|
79
|
+
summary: "Get form state",
|
|
80
|
+
description: "Retrieve the current state for a form.",
|
|
81
|
+
}))
|
|
82
|
+
.middleware(formLocationMiddleware))
|
|
83
|
+
.add(HttpApiEndpoint.post("session.form.reply", "/api/session/:sessionID/form/:formID/reply", {
|
|
84
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
85
|
+
query: LocationQuery,
|
|
86
|
+
payload: Form.Reply,
|
|
87
|
+
success: HttpApiSchema.NoContent,
|
|
88
|
+
error: [FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError],
|
|
89
|
+
})
|
|
90
|
+
.annotateMerge(locationQueryOpenApi)
|
|
91
|
+
.annotateMerge(OpenApi.annotations({
|
|
92
|
+
identifier: "v2.session.form.reply",
|
|
93
|
+
summary: "Reply to form",
|
|
94
|
+
description: "Submit an answer to a pending form.",
|
|
95
|
+
}))
|
|
96
|
+
.middleware(formLocationMiddleware))
|
|
97
|
+
.add(HttpApiEndpoint.post("session.form.cancel", "/api/session/:sessionID/form/:formID/cancel", {
|
|
98
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
99
|
+
query: LocationQuery,
|
|
100
|
+
success: HttpApiSchema.NoContent,
|
|
101
|
+
error: [FormAlreadySettledError, FormNotFoundError],
|
|
102
|
+
})
|
|
103
|
+
.annotateMerge(locationQueryOpenApi)
|
|
104
|
+
.annotateMerge(OpenApi.annotations({
|
|
105
|
+
identifier: "v2.session.form.cancel",
|
|
106
|
+
summary: "Cancel form",
|
|
107
|
+
description: "Cancel a pending form.",
|
|
108
|
+
}))
|
|
109
|
+
.middleware(formLocationMiddleware))
|
|
110
|
+
.annotateMerge(OpenApi.annotations({ title: "forms", description: "Session form routes." }));
|
package/dist/groups/message.d.ts
CHANGED
|
@@ -402,6 +402,7 @@ export declare const MessageGroup: HttpApiGroup.HttpApiGroup<"server.message", H
|
|
|
402
402
|
readonly summary: Schema.String;
|
|
403
403
|
readonly recent: Schema.String;
|
|
404
404
|
}>]>>;
|
|
405
|
+
readonly watermark: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Int, "Event.Seq">>>, Schema.optionalKey<Schema.brand<Schema.Int, "Event.Seq">>, never, never>;
|
|
405
406
|
readonly cursor: Schema.Struct<{
|
|
406
407
|
readonly previous: Schema.optional<Schema.String>;
|
|
407
408
|
readonly next: Schema.optional<Schema.String>;
|
package/dist/groups/message.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Session } from "@opencode-ai/schema/session";
|
|
2
2
|
import { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
3
|
+
import { optional } from "@opencode-ai/schema/schema";
|
|
4
|
+
import { Event } from "@opencode-ai/schema/event";
|
|
3
5
|
import { Schema } from "effect";
|
|
4
6
|
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
5
7
|
import { InvalidCursorError, SessionNotFoundError, UnknownError } from "../errors.js";
|
|
@@ -20,6 +22,9 @@ export const MessageGroup = HttpApiGroup.make("server.message")
|
|
|
20
22
|
query: SessionMessagesQuery,
|
|
21
23
|
success: Schema.Struct({
|
|
22
24
|
data: Schema.Array(SessionMessage.Message),
|
|
25
|
+
watermark: optional(Event.Seq).annotate({
|
|
26
|
+
description: "Durable log seq this snapshot was computed at, read before the snapshot. Attach a live log read after the watermark to compose fetch and stream gap-free; events between the watermark and the snapshot read may be redelivered by the tail and are safe to re-apply. Absent when the session has no durable events.",
|
|
27
|
+
}),
|
|
23
28
|
cursor: Schema.Struct({
|
|
24
29
|
previous: Schema.String.pipe(Schema.optional),
|
|
25
30
|
next: Schema.String.pipe(Schema.optional),
|