@zyro-sec/protocol 1.0.2 → 1.0.4
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/openapi.json +33222 -33222
- package/package.json +2 -2
- package/script/build.ts +9 -9
- package/script/generate-openapi.ts +25 -25
- package/script/openapi-parameters.ts +30 -30
- package/script/openapi-stabilize.ts +102 -102
- package/script/pack.ts +5 -5
- package/src/api.ts +264 -264
- package/src/client.ts +127 -127
- package/src/errors.ts +398 -398
- package/src/groups/agent.ts +39 -39
- package/src/groups/artifact.ts +103 -103
- package/src/groups/automation.ts +75 -75
- package/src/groups/blob.ts +20 -20
- package/src/groups/command.ts +27 -27
- package/src/groups/config.ts +46 -46
- package/src/groups/credential.ts +72 -72
- package/src/groups/debug.ts +68 -68
- package/src/groups/event.ts +86 -86
- package/src/groups/experimental.ts +19 -19
- package/src/groups/form.ts +26 -26
- package/src/groups/fs.ts +136 -136
- package/src/groups/generate.ts +120 -120
- package/src/groups/integration.ts +230 -230
- package/src/groups/job.ts +57 -57
- package/src/groups/location.ts +66 -66
- package/src/groups/machine.ts +120 -120
- package/src/groups/mcp.ts +167 -167
- package/src/groups/media.ts +23 -23
- package/src/groups/message.ts +124 -124
- package/src/groups/migration.ts +28 -28
- package/src/groups/model.ts +52 -52
- package/src/groups/permission.ts +164 -164
- package/src/groups/persistent-pty.ts +153 -153
- package/src/groups/plugin.ts +80 -80
- package/src/groups/project.ts +51 -51
- package/src/groups/provider.ts +45 -45
- package/src/groups/pty.ts +153 -153
- package/src/groups/push.ts +94 -94
- package/src/groups/reference.ts +42 -42
- package/src/groups/rpc.ts +30 -30
- package/src/groups/server.ts +80 -80
- package/src/groups/session.ts +918 -918
- package/src/groups/shell.ts +88 -88
- package/src/groups/skill.ts +46 -46
- package/src/groups/usage.ts +30 -30
- package/src/groups/vcs.ts +131 -131
- package/src/groups/voice.ts +96 -96
- package/src/groups/websearch.ts +46 -46
- package/src/groups/worktree.ts +78 -78
- package/src/middleware/authorization.ts +6 -6
- package/src/middleware/schema-error.ts +7 -7
- package/src/simulation.ts +691 -691
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +14 -14
- package/test/event.test.ts +0 -34
- package/test/experimental-identifiers.test.ts +0 -24
- package/test/openapi-parameters.test.ts +0 -43
- package/test/openapi-patterns.test.ts +0 -28
- package/test/openapi-stabilize.test.ts +0 -161
- package/test/session-cursor.test.ts +0 -7
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
import { PersistentPty } from "@zyro-sec/schema/persistent-pty"
|
|
2
|
-
import { Pty } from "@zyro-sec/schema/pty"
|
|
3
|
-
import { PtyTicket } from "@zyro-sec/schema/pty-ticket"
|
|
4
|
-
import { Session } from "@zyro-sec/schema/session"
|
|
5
|
-
import { Schema } from "effect"
|
|
6
|
-
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
7
|
-
import {
|
|
8
|
-
ForbiddenError,
|
|
9
|
-
InvalidRequestError,
|
|
10
|
-
PtyFeatureUnsupportedError,
|
|
11
|
-
PtyNotFoundError,
|
|
12
|
-
ServiceUnavailableError,
|
|
13
|
-
} from "../errors.js"
|
|
14
|
-
import { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE } from "./pty.js"
|
|
15
|
-
|
|
16
|
-
export { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE }
|
|
17
|
-
|
|
18
|
-
export const PERSISTENT_PTY_CONNECT_PATH = "/api/experimental/persistent-pty/:ptyID/connect"
|
|
19
|
-
|
|
20
|
-
const PERSISTENT_PTY_CONNECT_URL = /^\/api\/experimental\/persistent-pty\/[^/]+\/connect$/
|
|
21
|
-
|
|
22
|
-
export function hasPersistentPtyConnectTicketURL(url: URL) {
|
|
23
|
-
return PERSISTENT_PTY_CONNECT_URL.test(url.pathname) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const errors = [InvalidRequestError, ServiceUnavailableError] as const
|
|
27
|
-
const terminalErrors = [PtyNotFoundError, ServiceUnavailableError] as const
|
|
28
|
-
|
|
29
|
-
export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
|
30
|
-
.add(
|
|
31
|
-
HttpApiEndpoint.get("persistentPty.read", "/api/experimental/session/:sessionID/terminal/read", {
|
|
32
|
-
params: { sessionID: Session.ID },
|
|
33
|
-
query: {
|
|
34
|
-
lines: Schema.NumberFromString.pipe(Schema.decodeTo(PersistentPty.ReadLines), Schema.optional).annotateKey({
|
|
35
|
-
description:
|
|
36
|
-
"Number of trailing rows to read, up to 65535. Defaults to the live terminal height; larger counts include retained history.",
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
success: Schema.Struct({ data: Schema.NullOr(PersistentPty.ReadResult) }),
|
|
40
|
-
error: [ServiceUnavailableError],
|
|
41
|
-
}).annotateMerge(
|
|
42
|
-
OpenApi.annotations({
|
|
43
|
-
identifier: "experimental.persistentPty.read",
|
|
44
|
-
summary: "Read the session's most recently controlled terminal",
|
|
45
|
-
description:
|
|
46
|
-
"Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.",
|
|
47
|
-
}),
|
|
48
|
-
),
|
|
49
|
-
)
|
|
50
|
-
.add(
|
|
51
|
-
HttpApiEndpoint.get("persistentPty.list", "/api/experimental/session/:sessionID/terminal", {
|
|
52
|
-
params: { sessionID: Session.ID },
|
|
53
|
-
success: Schema.Struct({ data: Schema.Array(PersistentPty.Info) }),
|
|
54
|
-
error: errors,
|
|
55
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.list" })),
|
|
56
|
-
)
|
|
57
|
-
.add(
|
|
58
|
-
HttpApiEndpoint.post("persistentPty.create", "/api/experimental/session/:sessionID/terminal", {
|
|
59
|
-
params: { sessionID: Session.ID },
|
|
60
|
-
payload: PersistentPty.CreateInput,
|
|
61
|
-
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
62
|
-
error: errors,
|
|
63
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.create" })),
|
|
64
|
-
)
|
|
65
|
-
.add(
|
|
66
|
-
HttpApiEndpoint.post("persistentPty.shutdown", "/api/experimental/persistent-pty/shutdown", {
|
|
67
|
-
success: HttpApiSchema.NoContent,
|
|
68
|
-
error: [ServiceUnavailableError],
|
|
69
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.shutdown" })),
|
|
70
|
-
)
|
|
71
|
-
.add(
|
|
72
|
-
HttpApiEndpoint.post("persistentPty.handoff", "/api/experimental/persistent-pty/handoff", {
|
|
73
|
-
success: Schema.Struct({ handoff: Schema.NullOr(PersistentPty.Handoff) }),
|
|
74
|
-
error: [ServiceUnavailableError],
|
|
75
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.handoff" })),
|
|
76
|
-
)
|
|
77
|
-
.add(
|
|
78
|
-
HttpApiEndpoint.get("persistentPty.get", "/api/experimental/persistent-pty/:ptyID", {
|
|
79
|
-
params: { ptyID: Pty.ID },
|
|
80
|
-
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
81
|
-
error: terminalErrors,
|
|
82
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.get" })),
|
|
83
|
-
)
|
|
84
|
-
.add(
|
|
85
|
-
HttpApiEndpoint.put("persistentPty.update", "/api/experimental/persistent-pty/:ptyID", {
|
|
86
|
-
params: { ptyID: Pty.ID },
|
|
87
|
-
payload: PersistentPty.UpdateInput,
|
|
88
|
-
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
89
|
-
error: [...terminalErrors, PtyFeatureUnsupportedError],
|
|
90
|
-
}).annotateMerge(
|
|
91
|
-
OpenApi.annotations({
|
|
92
|
-
identifier: "experimental.persistentPty.update",
|
|
93
|
-
description:
|
|
94
|
-
"Resize when size is present and rename when title is present; a null title clears the user title so the shell's title shows again. Renaming fails with 501 while the terminal service predates renaming.",
|
|
95
|
-
}),
|
|
96
|
-
),
|
|
97
|
-
)
|
|
98
|
-
.add(
|
|
99
|
-
HttpApiEndpoint.get("persistentPty.snapshot", "/api/experimental/persistent-pty/:ptyID/snapshot", {
|
|
100
|
-
params: { ptyID: Pty.ID },
|
|
101
|
-
success: Schema.Struct({ data: PersistentPty.Snapshot }),
|
|
102
|
-
error: terminalErrors,
|
|
103
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.snapshot" })),
|
|
104
|
-
)
|
|
105
|
-
.add(
|
|
106
|
-
HttpApiEndpoint.delete("persistentPty.remove", "/api/experimental/persistent-pty/:ptyID", {
|
|
107
|
-
params: { ptyID: Pty.ID },
|
|
108
|
-
success: HttpApiSchema.NoContent,
|
|
109
|
-
error: terminalErrors,
|
|
110
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.remove" })),
|
|
111
|
-
)
|
|
112
|
-
.add(
|
|
113
|
-
HttpApiEndpoint.post("persistentPty.connectToken", "/api/experimental/persistent-pty/:ptyID/connect-token", {
|
|
114
|
-
params: { ptyID: Pty.ID },
|
|
115
|
-
headers: Schema.Struct({
|
|
116
|
-
[PTY_CONNECT_TOKEN_HEADER]: Schema.optional(Schema.String).annotateKey({
|
|
117
|
-
description: `Must be ${PTY_CONNECT_TOKEN_HEADER_VALUE}; requests without it are refused.`,
|
|
118
|
-
}),
|
|
119
|
-
}),
|
|
120
|
-
success: Schema.Struct({ data: PtyTicket.ConnectToken }),
|
|
121
|
-
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
122
|
-
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.connectToken" })),
|
|
123
|
-
)
|
|
124
|
-
.add(
|
|
125
|
-
HttpApiEndpoint.get("persistentPty.connect", PERSISTENT_PTY_CONNECT_PATH, {
|
|
126
|
-
params: { ptyID: Pty.ID },
|
|
127
|
-
success: Schema.Boolean,
|
|
128
|
-
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
129
|
-
}).annotateMerge(
|
|
130
|
-
OpenApi.annotations({
|
|
131
|
-
identifier: "experimental.persistentPty.connect",
|
|
132
|
-
summary: "Connect to a persistent PTY",
|
|
133
|
-
description: "Stream persistent PTY output through the OpenCode server.",
|
|
134
|
-
transform: (operation) => ({
|
|
135
|
-
...operation,
|
|
136
|
-
"x-websocket": true,
|
|
137
|
-
parameters: [
|
|
138
|
-
...(operation.parameters ?? []),
|
|
139
|
-
{ in: "query", name: "attachment_id", schema: { type: "string" } },
|
|
140
|
-
...Object.entries({
|
|
141
|
-
cursor: "Output offset to replay from. Defaults to 0.",
|
|
142
|
-
role: "Attach as controller (the default) or observer.",
|
|
143
|
-
takeover: "Set to true to take over control of the terminal.",
|
|
144
|
-
input_protocol: "Set to 1 to send framed input messages instead of raw terminal input.",
|
|
145
|
-
[PTY_CONNECT_TICKET_QUERY]:
|
|
146
|
-
"Single-use ticket from experimental.persistentPty.connectToken, which authorizes the connection without the usual credentials.",
|
|
147
|
-
}).map(([name, description]) => ({ in: "query", name, description, schema: { type: "string" } })),
|
|
148
|
-
],
|
|
149
|
-
}),
|
|
150
|
-
}),
|
|
151
|
-
),
|
|
152
|
-
)
|
|
153
|
-
.annotateMerge(OpenApi.annotations({ title: "persistentPty", description: "Prototype persistent PTY routes." }))
|
|
1
|
+
import { PersistentPty } from "@zyro-sec/schema/persistent-pty"
|
|
2
|
+
import { Pty } from "@zyro-sec/schema/pty"
|
|
3
|
+
import { PtyTicket } from "@zyro-sec/schema/pty-ticket"
|
|
4
|
+
import { Session } from "@zyro-sec/schema/session"
|
|
5
|
+
import { Schema } from "effect"
|
|
6
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
7
|
+
import {
|
|
8
|
+
ForbiddenError,
|
|
9
|
+
InvalidRequestError,
|
|
10
|
+
PtyFeatureUnsupportedError,
|
|
11
|
+
PtyNotFoundError,
|
|
12
|
+
ServiceUnavailableError,
|
|
13
|
+
} from "../errors.js"
|
|
14
|
+
import { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE } from "./pty.js"
|
|
15
|
+
|
|
16
|
+
export { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE }
|
|
17
|
+
|
|
18
|
+
export const PERSISTENT_PTY_CONNECT_PATH = "/api/experimental/persistent-pty/:ptyID/connect"
|
|
19
|
+
|
|
20
|
+
const PERSISTENT_PTY_CONNECT_URL = /^\/api\/experimental\/persistent-pty\/[^/]+\/connect$/
|
|
21
|
+
|
|
22
|
+
export function hasPersistentPtyConnectTicketURL(url: URL) {
|
|
23
|
+
return PERSISTENT_PTY_CONNECT_URL.test(url.pathname) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const errors = [InvalidRequestError, ServiceUnavailableError] as const
|
|
27
|
+
const terminalErrors = [PtyNotFoundError, ServiceUnavailableError] as const
|
|
28
|
+
|
|
29
|
+
export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
|
30
|
+
.add(
|
|
31
|
+
HttpApiEndpoint.get("persistentPty.read", "/api/experimental/session/:sessionID/terminal/read", {
|
|
32
|
+
params: { sessionID: Session.ID },
|
|
33
|
+
query: {
|
|
34
|
+
lines: Schema.NumberFromString.pipe(Schema.decodeTo(PersistentPty.ReadLines), Schema.optional).annotateKey({
|
|
35
|
+
description:
|
|
36
|
+
"Number of trailing rows to read, up to 65535. Defaults to the live terminal height; larger counts include retained history.",
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
success: Schema.Struct({ data: Schema.NullOr(PersistentPty.ReadResult) }),
|
|
40
|
+
error: [ServiceUnavailableError],
|
|
41
|
+
}).annotateMerge(
|
|
42
|
+
OpenApi.annotations({
|
|
43
|
+
identifier: "experimental.persistentPty.read",
|
|
44
|
+
summary: "Read the session's most recently controlled terminal",
|
|
45
|
+
description:
|
|
46
|
+
"Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.",
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
.add(
|
|
51
|
+
HttpApiEndpoint.get("persistentPty.list", "/api/experimental/session/:sessionID/terminal", {
|
|
52
|
+
params: { sessionID: Session.ID },
|
|
53
|
+
success: Schema.Struct({ data: Schema.Array(PersistentPty.Info) }),
|
|
54
|
+
error: errors,
|
|
55
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.list" })),
|
|
56
|
+
)
|
|
57
|
+
.add(
|
|
58
|
+
HttpApiEndpoint.post("persistentPty.create", "/api/experimental/session/:sessionID/terminal", {
|
|
59
|
+
params: { sessionID: Session.ID },
|
|
60
|
+
payload: PersistentPty.CreateInput,
|
|
61
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
62
|
+
error: errors,
|
|
63
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.create" })),
|
|
64
|
+
)
|
|
65
|
+
.add(
|
|
66
|
+
HttpApiEndpoint.post("persistentPty.shutdown", "/api/experimental/persistent-pty/shutdown", {
|
|
67
|
+
success: HttpApiSchema.NoContent,
|
|
68
|
+
error: [ServiceUnavailableError],
|
|
69
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.shutdown" })),
|
|
70
|
+
)
|
|
71
|
+
.add(
|
|
72
|
+
HttpApiEndpoint.post("persistentPty.handoff", "/api/experimental/persistent-pty/handoff", {
|
|
73
|
+
success: Schema.Struct({ handoff: Schema.NullOr(PersistentPty.Handoff) }),
|
|
74
|
+
error: [ServiceUnavailableError],
|
|
75
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.handoff" })),
|
|
76
|
+
)
|
|
77
|
+
.add(
|
|
78
|
+
HttpApiEndpoint.get("persistentPty.get", "/api/experimental/persistent-pty/:ptyID", {
|
|
79
|
+
params: { ptyID: Pty.ID },
|
|
80
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
81
|
+
error: terminalErrors,
|
|
82
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.get" })),
|
|
83
|
+
)
|
|
84
|
+
.add(
|
|
85
|
+
HttpApiEndpoint.put("persistentPty.update", "/api/experimental/persistent-pty/:ptyID", {
|
|
86
|
+
params: { ptyID: Pty.ID },
|
|
87
|
+
payload: PersistentPty.UpdateInput,
|
|
88
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
89
|
+
error: [...terminalErrors, PtyFeatureUnsupportedError],
|
|
90
|
+
}).annotateMerge(
|
|
91
|
+
OpenApi.annotations({
|
|
92
|
+
identifier: "experimental.persistentPty.update",
|
|
93
|
+
description:
|
|
94
|
+
"Resize when size is present and rename when title is present; a null title clears the user title so the shell's title shows again. Renaming fails with 501 while the terminal service predates renaming.",
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
.add(
|
|
99
|
+
HttpApiEndpoint.get("persistentPty.snapshot", "/api/experimental/persistent-pty/:ptyID/snapshot", {
|
|
100
|
+
params: { ptyID: Pty.ID },
|
|
101
|
+
success: Schema.Struct({ data: PersistentPty.Snapshot }),
|
|
102
|
+
error: terminalErrors,
|
|
103
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.snapshot" })),
|
|
104
|
+
)
|
|
105
|
+
.add(
|
|
106
|
+
HttpApiEndpoint.delete("persistentPty.remove", "/api/experimental/persistent-pty/:ptyID", {
|
|
107
|
+
params: { ptyID: Pty.ID },
|
|
108
|
+
success: HttpApiSchema.NoContent,
|
|
109
|
+
error: terminalErrors,
|
|
110
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.remove" })),
|
|
111
|
+
)
|
|
112
|
+
.add(
|
|
113
|
+
HttpApiEndpoint.post("persistentPty.connectToken", "/api/experimental/persistent-pty/:ptyID/connect-token", {
|
|
114
|
+
params: { ptyID: Pty.ID },
|
|
115
|
+
headers: Schema.Struct({
|
|
116
|
+
[PTY_CONNECT_TOKEN_HEADER]: Schema.optional(Schema.String).annotateKey({
|
|
117
|
+
description: `Must be ${PTY_CONNECT_TOKEN_HEADER_VALUE}; requests without it are refused.`,
|
|
118
|
+
}),
|
|
119
|
+
}),
|
|
120
|
+
success: Schema.Struct({ data: PtyTicket.ConnectToken }),
|
|
121
|
+
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
122
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.connectToken" })),
|
|
123
|
+
)
|
|
124
|
+
.add(
|
|
125
|
+
HttpApiEndpoint.get("persistentPty.connect", PERSISTENT_PTY_CONNECT_PATH, {
|
|
126
|
+
params: { ptyID: Pty.ID },
|
|
127
|
+
success: Schema.Boolean,
|
|
128
|
+
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
129
|
+
}).annotateMerge(
|
|
130
|
+
OpenApi.annotations({
|
|
131
|
+
identifier: "experimental.persistentPty.connect",
|
|
132
|
+
summary: "Connect to a persistent PTY",
|
|
133
|
+
description: "Stream persistent PTY output through the OpenCode server.",
|
|
134
|
+
transform: (operation) => ({
|
|
135
|
+
...operation,
|
|
136
|
+
"x-websocket": true,
|
|
137
|
+
parameters: [
|
|
138
|
+
...(operation.parameters ?? []),
|
|
139
|
+
{ in: "query", name: "attachment_id", schema: { type: "string" } },
|
|
140
|
+
...Object.entries({
|
|
141
|
+
cursor: "Output offset to replay from. Defaults to 0.",
|
|
142
|
+
role: "Attach as controller (the default) or observer.",
|
|
143
|
+
takeover: "Set to true to take over control of the terminal.",
|
|
144
|
+
input_protocol: "Set to 1 to send framed input messages instead of raw terminal input.",
|
|
145
|
+
[PTY_CONNECT_TICKET_QUERY]:
|
|
146
|
+
"Single-use ticket from experimental.persistentPty.connectToken, which authorizes the connection without the usual credentials.",
|
|
147
|
+
}).map(([name, description]) => ({ in: "query", name, description, schema: { type: "string" } })),
|
|
148
|
+
],
|
|
149
|
+
}),
|
|
150
|
+
}),
|
|
151
|
+
),
|
|
152
|
+
)
|
|
153
|
+
.annotateMerge(OpenApi.annotations({ title: "persistentPty", description: "Prototype persistent PTY routes." }))
|
package/src/groups/plugin.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
2
|
-
import { Plugin } from "@zyro-sec/schema/plugin"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
-
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "../errors.js"
|
|
6
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
7
|
-
|
|
8
|
-
export const PluginGroup = HttpApiGroup.make("server.plugin")
|
|
9
|
-
.add(
|
|
10
|
-
HttpApiEndpoint.get("plugin.list", "/api/plugin", {
|
|
11
|
-
query: LocationQuery,
|
|
12
|
-
success: Location.response(Schema.Array(Plugin.Info)),
|
|
13
|
-
})
|
|
14
|
-
.annotateMerge(locationQueryOpenApi)
|
|
15
|
-
.annotateMerge(
|
|
16
|
-
OpenApi.annotations({
|
|
17
|
-
identifier: "plugin.list",
|
|
18
|
-
summary: "List plugins",
|
|
19
|
-
description: "Retrieve enabled server plugins and their current status.",
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
)
|
|
23
|
-
.add(
|
|
24
|
-
HttpApiEndpoint.get("plugin.gui", "/api/plugin/gui", {
|
|
25
|
-
query: Schema.Struct({
|
|
26
|
-
...LocationQuery.fields,
|
|
27
|
-
id: Plugin.ID,
|
|
28
|
-
}),
|
|
29
|
-
success: Location.response(Plugin.GuiBundle),
|
|
30
|
-
error: PluginNotFoundError,
|
|
31
|
-
})
|
|
32
|
-
.annotateMerge(locationQueryOpenApi)
|
|
33
|
-
.annotateMerge(
|
|
34
|
-
OpenApi.annotations({
|
|
35
|
-
identifier: "plugin.gui",
|
|
36
|
-
summary: "Read plugin GUI bundle",
|
|
37
|
-
description:
|
|
38
|
-
"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`.",
|
|
39
|
-
}),
|
|
40
|
-
),
|
|
41
|
-
)
|
|
42
|
-
.add(
|
|
43
|
-
HttpApiEndpoint.post("plugin.check", "/api/plugin/check", {
|
|
44
|
-
query: LocationQuery,
|
|
45
|
-
payload: Schema.Struct({ target: Schema.String.pipe(Schema.optional) }),
|
|
46
|
-
success: Location.response(Schema.Array(Plugin.Info)),
|
|
47
|
-
error: InvalidRequestError,
|
|
48
|
-
})
|
|
49
|
-
.annotateMerge(locationQueryOpenApi)
|
|
50
|
-
.annotateMerge(
|
|
51
|
-
OpenApi.annotations({
|
|
52
|
-
identifier: "plugin.check",
|
|
53
|
-
summary: "Check plugin updates",
|
|
54
|
-
description: "Check one or all package plugins for available updates.",
|
|
55
|
-
}),
|
|
56
|
-
),
|
|
57
|
-
)
|
|
58
|
-
.add(
|
|
59
|
-
HttpApiEndpoint.post("plugin.update", "/api/plugin/update", {
|
|
60
|
-
query: LocationQuery,
|
|
61
|
-
payload: Schema.Struct({ targets: Schema.Array(Schema.String) }),
|
|
62
|
-
success: HttpApiSchema.NoContent,
|
|
63
|
-
error: [InvalidRequestError, ServiceUnavailableError],
|
|
64
|
-
})
|
|
65
|
-
.annotateMerge(locationQueryOpenApi)
|
|
66
|
-
.annotateMerge(
|
|
67
|
-
OpenApi.annotations({
|
|
68
|
-
identifier: "plugin.update",
|
|
69
|
-
summary: "Update plugins",
|
|
70
|
-
description:
|
|
71
|
-
"Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.",
|
|
72
|
-
}),
|
|
73
|
-
),
|
|
74
|
-
)
|
|
75
|
-
.annotateMerge(
|
|
76
|
-
OpenApi.annotations({
|
|
77
|
-
title: "plugin",
|
|
78
|
-
description: "Experimental plugin routes.",
|
|
79
|
-
}),
|
|
80
|
-
)
|
|
1
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
2
|
+
import { Plugin } from "@zyro-sec/schema/plugin"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
+
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "../errors.js"
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
7
|
+
|
|
8
|
+
export const PluginGroup = HttpApiGroup.make("server.plugin")
|
|
9
|
+
.add(
|
|
10
|
+
HttpApiEndpoint.get("plugin.list", "/api/plugin", {
|
|
11
|
+
query: LocationQuery,
|
|
12
|
+
success: Location.response(Schema.Array(Plugin.Info)),
|
|
13
|
+
})
|
|
14
|
+
.annotateMerge(locationQueryOpenApi)
|
|
15
|
+
.annotateMerge(
|
|
16
|
+
OpenApi.annotations({
|
|
17
|
+
identifier: "plugin.list",
|
|
18
|
+
summary: "List plugins",
|
|
19
|
+
description: "Retrieve enabled server plugins and their current status.",
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
.add(
|
|
24
|
+
HttpApiEndpoint.get("plugin.gui", "/api/plugin/gui", {
|
|
25
|
+
query: Schema.Struct({
|
|
26
|
+
...LocationQuery.fields,
|
|
27
|
+
id: Plugin.ID,
|
|
28
|
+
}),
|
|
29
|
+
success: Location.response(Plugin.GuiBundle),
|
|
30
|
+
error: PluginNotFoundError,
|
|
31
|
+
})
|
|
32
|
+
.annotateMerge(locationQueryOpenApi)
|
|
33
|
+
.annotateMerge(
|
|
34
|
+
OpenApi.annotations({
|
|
35
|
+
identifier: "plugin.gui",
|
|
36
|
+
summary: "Read plugin GUI bundle",
|
|
37
|
+
description:
|
|
38
|
+
"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`.",
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
.add(
|
|
43
|
+
HttpApiEndpoint.post("plugin.check", "/api/plugin/check", {
|
|
44
|
+
query: LocationQuery,
|
|
45
|
+
payload: Schema.Struct({ target: Schema.String.pipe(Schema.optional) }),
|
|
46
|
+
success: Location.response(Schema.Array(Plugin.Info)),
|
|
47
|
+
error: InvalidRequestError,
|
|
48
|
+
})
|
|
49
|
+
.annotateMerge(locationQueryOpenApi)
|
|
50
|
+
.annotateMerge(
|
|
51
|
+
OpenApi.annotations({
|
|
52
|
+
identifier: "plugin.check",
|
|
53
|
+
summary: "Check plugin updates",
|
|
54
|
+
description: "Check one or all package plugins for available updates.",
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
.add(
|
|
59
|
+
HttpApiEndpoint.post("plugin.update", "/api/plugin/update", {
|
|
60
|
+
query: LocationQuery,
|
|
61
|
+
payload: Schema.Struct({ targets: Schema.Array(Schema.String) }),
|
|
62
|
+
success: HttpApiSchema.NoContent,
|
|
63
|
+
error: [InvalidRequestError, ServiceUnavailableError],
|
|
64
|
+
})
|
|
65
|
+
.annotateMerge(locationQueryOpenApi)
|
|
66
|
+
.annotateMerge(
|
|
67
|
+
OpenApi.annotations({
|
|
68
|
+
identifier: "plugin.update",
|
|
69
|
+
summary: "Update plugins",
|
|
70
|
+
description:
|
|
71
|
+
"Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.",
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
.annotateMerge(
|
|
76
|
+
OpenApi.annotations({
|
|
77
|
+
title: "plugin",
|
|
78
|
+
description: "Experimental plugin routes.",
|
|
79
|
+
}),
|
|
80
|
+
)
|
package/src/groups/project.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { Project } from "@zyro-sec/schema/project"
|
|
2
|
-
import { Schema, SchemaGetter, Struct } from "effect"
|
|
3
|
-
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
4
|
-
import { ProjectNotFoundError } from "../errors.js"
|
|
5
|
-
|
|
6
|
-
const root = "/api/project"
|
|
7
|
-
const UpdatePayload = Schema.Struct(Struct.omit(Project.UpdateInput.fields, ["projectID"]))
|
|
8
|
-
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(
|
|
9
|
-
Schema.decodeTo(Schema.Boolean, {
|
|
10
|
-
decode: SchemaGetter.transform((value) => value === "true"),
|
|
11
|
-
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
12
|
-
}),
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
export const ProjectGroup = HttpApiGroup.make("server.project")
|
|
16
|
-
.add(
|
|
17
|
-
HttpApiEndpoint.get("project.list", root, {
|
|
18
|
-
query: Schema.Struct({
|
|
19
|
-
archived: BooleanFromString.pipe(Schema.optional).annotateKey({
|
|
20
|
-
description: "Set to true to include archived projects.",
|
|
21
|
-
}),
|
|
22
|
-
}),
|
|
23
|
-
success: Schema.Array(Project.Info),
|
|
24
|
-
}).annotateMerge(
|
|
25
|
-
OpenApi.annotations({
|
|
26
|
-
identifier: "project.list",
|
|
27
|
-
summary: "List projects",
|
|
28
|
-
description: "List known projects. Archived projects are excluded unless archived=true.",
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
31
|
-
)
|
|
32
|
-
.add(
|
|
33
|
-
HttpApiEndpoint.patch("project.update", `${root}/:projectID`, {
|
|
34
|
-
params: { projectID: Project.ID },
|
|
35
|
-
payload: UpdatePayload,
|
|
36
|
-
success: Project.Info,
|
|
37
|
-
error: ProjectNotFoundError,
|
|
38
|
-
}).annotateMerge(
|
|
39
|
-
OpenApi.annotations({
|
|
40
|
-
identifier: "project.update",
|
|
41
|
-
summary: "Update project",
|
|
42
|
-
description: "Update the project canonical directory, display metadata, and workspace commands.",
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
)
|
|
46
|
-
.annotateMerge(
|
|
47
|
-
OpenApi.annotations({
|
|
48
|
-
title: "project",
|
|
49
|
-
description: "Project routes.",
|
|
50
|
-
}),
|
|
51
|
-
)
|
|
1
|
+
import { Project } from "@zyro-sec/schema/project"
|
|
2
|
+
import { Schema, SchemaGetter, Struct } from "effect"
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
4
|
+
import { ProjectNotFoundError } from "../errors.js"
|
|
5
|
+
|
|
6
|
+
const root = "/api/project"
|
|
7
|
+
const UpdatePayload = Schema.Struct(Struct.omit(Project.UpdateInput.fields, ["projectID"]))
|
|
8
|
+
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(
|
|
9
|
+
Schema.decodeTo(Schema.Boolean, {
|
|
10
|
+
decode: SchemaGetter.transform((value) => value === "true"),
|
|
11
|
+
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
12
|
+
}),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
export const ProjectGroup = HttpApiGroup.make("server.project")
|
|
16
|
+
.add(
|
|
17
|
+
HttpApiEndpoint.get("project.list", root, {
|
|
18
|
+
query: Schema.Struct({
|
|
19
|
+
archived: BooleanFromString.pipe(Schema.optional).annotateKey({
|
|
20
|
+
description: "Set to true to include archived projects.",
|
|
21
|
+
}),
|
|
22
|
+
}),
|
|
23
|
+
success: Schema.Array(Project.Info),
|
|
24
|
+
}).annotateMerge(
|
|
25
|
+
OpenApi.annotations({
|
|
26
|
+
identifier: "project.list",
|
|
27
|
+
summary: "List projects",
|
|
28
|
+
description: "List known projects. Archived projects are excluded unless archived=true.",
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
31
|
+
)
|
|
32
|
+
.add(
|
|
33
|
+
HttpApiEndpoint.patch("project.update", `${root}/:projectID`, {
|
|
34
|
+
params: { projectID: Project.ID },
|
|
35
|
+
payload: UpdatePayload,
|
|
36
|
+
success: Project.Info,
|
|
37
|
+
error: ProjectNotFoundError,
|
|
38
|
+
}).annotateMerge(
|
|
39
|
+
OpenApi.annotations({
|
|
40
|
+
identifier: "project.update",
|
|
41
|
+
summary: "Update project",
|
|
42
|
+
description: "Update the project canonical directory, display metadata, and workspace commands.",
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
.annotateMerge(
|
|
47
|
+
OpenApi.annotations({
|
|
48
|
+
title: "project",
|
|
49
|
+
description: "Project routes.",
|
|
50
|
+
}),
|
|
51
|
+
)
|