@zyro-sec/protocol 1.0.2 → 1.0.3
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,230 +1,230 @@
|
|
|
1
|
-
import { Integration } from "@zyro-sec/schema/integration"
|
|
2
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
-
import { Form } from "@zyro-sec/schema/form"
|
|
4
|
-
import { Schema } from "effect"
|
|
5
|
-
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
-
import {
|
|
7
|
-
IntegrationAttemptNotFoundError,
|
|
8
|
-
IntegrationMethodNotFoundError,
|
|
9
|
-
IntegrationNotFoundError,
|
|
10
|
-
InvalidRequestError,
|
|
11
|
-
} from "../errors.js"
|
|
12
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
13
|
-
|
|
14
|
-
export const IntegrationGroup = HttpApiGroup.make("server.integration")
|
|
15
|
-
.add(
|
|
16
|
-
HttpApiEndpoint.get("integration.list", "/api/integration", {
|
|
17
|
-
query: LocationQuery,
|
|
18
|
-
success: Location.response(Schema.Array(Integration.Info)),
|
|
19
|
-
})
|
|
20
|
-
.annotateMerge(locationQueryOpenApi)
|
|
21
|
-
.annotateMerge(
|
|
22
|
-
OpenApi.annotations({
|
|
23
|
-
identifier: "integration.list",
|
|
24
|
-
summary: "List integrations",
|
|
25
|
-
description: "Retrieve available integrations and their authentication methods.",
|
|
26
|
-
}),
|
|
27
|
-
),
|
|
28
|
-
)
|
|
29
|
-
.add(
|
|
30
|
-
HttpApiEndpoint.get("integration.get", "/api/integration/:integrationID", {
|
|
31
|
-
params: { integrationID: Integration.ID },
|
|
32
|
-
query: LocationQuery,
|
|
33
|
-
success: Location.response(Integration.Info),
|
|
34
|
-
error: IntegrationNotFoundError,
|
|
35
|
-
})
|
|
36
|
-
.annotateMerge(locationQueryOpenApi)
|
|
37
|
-
.annotateMerge(
|
|
38
|
-
OpenApi.annotations({
|
|
39
|
-
identifier: "integration.get",
|
|
40
|
-
summary: "Get integration",
|
|
41
|
-
description: "Retrieve one integration and its authentication methods.",
|
|
42
|
-
}),
|
|
43
|
-
),
|
|
44
|
-
)
|
|
45
|
-
.add(
|
|
46
|
-
HttpApiEndpoint.post("integration.wellknown.add", "/api/experimental/integration/wellknown", {
|
|
47
|
-
query: LocationQuery,
|
|
48
|
-
payload: Schema.Struct({ url: Schema.String }),
|
|
49
|
-
success: HttpApiSchema.NoContent,
|
|
50
|
-
error: InvalidRequestError,
|
|
51
|
-
})
|
|
52
|
-
.annotateMerge(locationQueryOpenApi)
|
|
53
|
-
.annotateMerge(
|
|
54
|
-
OpenApi.annotations({
|
|
55
|
-
identifier: "experimental.integration.wellknown.add",
|
|
56
|
-
summary: "Add wellknown integration",
|
|
57
|
-
description: "Discover and persist an experimental wellknown integration source.",
|
|
58
|
-
}),
|
|
59
|
-
),
|
|
60
|
-
)
|
|
61
|
-
.add(
|
|
62
|
-
HttpApiEndpoint.post("integration.connect.key", "/api/integration/:integrationID/connect/key", {
|
|
63
|
-
params: { integrationID: Integration.ID },
|
|
64
|
-
query: LocationQuery,
|
|
65
|
-
payload: Schema.Struct({
|
|
66
|
-
key: Schema.String,
|
|
67
|
-
answer: Schema.optional(Form.Answer),
|
|
68
|
-
label: Schema.optional(Schema.String),
|
|
69
|
-
}),
|
|
70
|
-
success: HttpApiSchema.NoContent,
|
|
71
|
-
error: [IntegrationNotFoundError, InvalidRequestError],
|
|
72
|
-
})
|
|
73
|
-
.annotateMerge(locationQueryOpenApi)
|
|
74
|
-
.annotateMerge(
|
|
75
|
-
OpenApi.annotations({
|
|
76
|
-
identifier: "integration.connect.key",
|
|
77
|
-
summary: "Connect with key",
|
|
78
|
-
description: "Run a key authentication method and store the resulting credential.",
|
|
79
|
-
}),
|
|
80
|
-
),
|
|
81
|
-
)
|
|
82
|
-
.add(
|
|
83
|
-
HttpApiEndpoint.post("integration.connect.external", "/api/integration/:integrationID/connect/external", {
|
|
84
|
-
params: { integrationID: Integration.ID },
|
|
85
|
-
query: LocationQuery,
|
|
86
|
-
payload: Schema.Struct({
|
|
87
|
-
methodID: Integration.MethodID,
|
|
88
|
-
answer: Schema.optional(Form.Answer),
|
|
89
|
-
label: Schema.optional(Schema.String),
|
|
90
|
-
}),
|
|
91
|
-
success: HttpApiSchema.NoContent,
|
|
92
|
-
error: [IntegrationNotFoundError, InvalidRequestError],
|
|
93
|
-
})
|
|
94
|
-
.annotateMerge(locationQueryOpenApi)
|
|
95
|
-
.annotateMerge(
|
|
96
|
-
OpenApi.annotations({
|
|
97
|
-
identifier: "integration.connect.external",
|
|
98
|
-
summary: "Connect with external credentials",
|
|
99
|
-
description: "Run an external authentication method and store a reference to its credential source.",
|
|
100
|
-
}),
|
|
101
|
-
),
|
|
102
|
-
)
|
|
103
|
-
.add(
|
|
104
|
-
HttpApiEndpoint.post("integration.oauth.connect", "/api/integration/:integrationID/connect/oauth", {
|
|
105
|
-
params: { integrationID: Integration.ID },
|
|
106
|
-
query: LocationQuery,
|
|
107
|
-
payload: Schema.Struct({
|
|
108
|
-
methodID: Integration.MethodID,
|
|
109
|
-
answer: Schema.optional(Form.Answer),
|
|
110
|
-
label: Schema.optional(Schema.String),
|
|
111
|
-
}),
|
|
112
|
-
success: Location.response(Integration.Attempt),
|
|
113
|
-
error: InvalidRequestError,
|
|
114
|
-
})
|
|
115
|
-
.annotateMerge(locationQueryOpenApi)
|
|
116
|
-
.annotateMerge(
|
|
117
|
-
OpenApi.annotations({
|
|
118
|
-
identifier: "integration.oauth.connect",
|
|
119
|
-
summary: "Begin OAuth connection",
|
|
120
|
-
description: "Start an OAuth attempt and return the authorization details.",
|
|
121
|
-
}),
|
|
122
|
-
),
|
|
123
|
-
)
|
|
124
|
-
.add(
|
|
125
|
-
HttpApiEndpoint.get("integration.oauth.status", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
126
|
-
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
127
|
-
query: LocationQuery,
|
|
128
|
-
success: Location.response(Integration.AttemptStatus),
|
|
129
|
-
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError],
|
|
130
|
-
})
|
|
131
|
-
.annotateMerge(locationQueryOpenApi)
|
|
132
|
-
.annotateMerge(
|
|
133
|
-
OpenApi.annotations({
|
|
134
|
-
identifier: "integration.oauth.status",
|
|
135
|
-
summary: "Get OAuth attempt status",
|
|
136
|
-
description: "Poll the current status of an OAuth attempt.",
|
|
137
|
-
}),
|
|
138
|
-
),
|
|
139
|
-
)
|
|
140
|
-
.add(
|
|
141
|
-
HttpApiEndpoint.post(
|
|
142
|
-
"integration.oauth.complete",
|
|
143
|
-
"/api/integration/:integrationID/connect/oauth/:attemptID/complete",
|
|
144
|
-
{
|
|
145
|
-
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
146
|
-
query: LocationQuery,
|
|
147
|
-
payload: Schema.Struct({ code: Schema.optional(Schema.String) }),
|
|
148
|
-
success: HttpApiSchema.NoContent,
|
|
149
|
-
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError, InvalidRequestError],
|
|
150
|
-
},
|
|
151
|
-
)
|
|
152
|
-
.annotateMerge(locationQueryOpenApi)
|
|
153
|
-
.annotateMerge(
|
|
154
|
-
OpenApi.annotations({
|
|
155
|
-
identifier: "integration.oauth.complete",
|
|
156
|
-
summary: "Complete OAuth connection",
|
|
157
|
-
description:
|
|
158
|
-
"Complete a code-based OAuth attempt and store the resulting credential. For an automatic attempt with `paste`, `code` is the redirect URL copied from the browser, and the result arrives through the attempt status.",
|
|
159
|
-
}),
|
|
160
|
-
),
|
|
161
|
-
)
|
|
162
|
-
.add(
|
|
163
|
-
HttpApiEndpoint.delete("integration.oauth.cancel", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
164
|
-
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
165
|
-
query: LocationQuery,
|
|
166
|
-
success: HttpApiSchema.NoContent,
|
|
167
|
-
})
|
|
168
|
-
.annotateMerge(locationQueryOpenApi)
|
|
169
|
-
.annotateMerge(
|
|
170
|
-
OpenApi.annotations({
|
|
171
|
-
identifier: "integration.oauth.cancel",
|
|
172
|
-
summary: "Cancel OAuth connection",
|
|
173
|
-
description: "Cancel an OAuth attempt and release its resources.",
|
|
174
|
-
}),
|
|
175
|
-
),
|
|
176
|
-
)
|
|
177
|
-
.add(
|
|
178
|
-
HttpApiEndpoint.post("integration.command.connect", "/api/integration/:integrationID/connect/command", {
|
|
179
|
-
params: { integrationID: Integration.ID },
|
|
180
|
-
query: LocationQuery,
|
|
181
|
-
payload: Schema.Struct({
|
|
182
|
-
methodID: Integration.MethodID,
|
|
183
|
-
label: Schema.optional(Schema.String),
|
|
184
|
-
}),
|
|
185
|
-
success: Location.response(Integration.CommandAttempt),
|
|
186
|
-
error: [IntegrationNotFoundError, IntegrationMethodNotFoundError, InvalidRequestError],
|
|
187
|
-
})
|
|
188
|
-
.annotateMerge(locationQueryOpenApi)
|
|
189
|
-
.annotateMerge(
|
|
190
|
-
OpenApi.annotations({
|
|
191
|
-
identifier: "integration.command.connect",
|
|
192
|
-
summary: "Begin command connection",
|
|
193
|
-
description: "Start a command authentication attempt.",
|
|
194
|
-
}),
|
|
195
|
-
),
|
|
196
|
-
)
|
|
197
|
-
.add(
|
|
198
|
-
HttpApiEndpoint.get("integration.command.status", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
199
|
-
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
200
|
-
query: LocationQuery,
|
|
201
|
-
success: Location.response(Integration.CommandAttemptStatus),
|
|
202
|
-
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError],
|
|
203
|
-
})
|
|
204
|
-
.annotateMerge(locationQueryOpenApi)
|
|
205
|
-
.annotateMerge(
|
|
206
|
-
OpenApi.annotations({
|
|
207
|
-
identifier: "integration.command.status",
|
|
208
|
-
summary: "Get command attempt status",
|
|
209
|
-
description: "Poll the current status and output of a command authentication attempt.",
|
|
210
|
-
}),
|
|
211
|
-
),
|
|
212
|
-
)
|
|
213
|
-
.add(
|
|
214
|
-
HttpApiEndpoint.delete("integration.command.cancel", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
215
|
-
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
216
|
-
query: LocationQuery,
|
|
217
|
-
success: HttpApiSchema.NoContent,
|
|
218
|
-
})
|
|
219
|
-
.annotateMerge(locationQueryOpenApi)
|
|
220
|
-
.annotateMerge(
|
|
221
|
-
OpenApi.annotations({
|
|
222
|
-
identifier: "integration.command.cancel",
|
|
223
|
-
summary: "Cancel command connection",
|
|
224
|
-
description: "Cancel a command authentication attempt and terminate its process.",
|
|
225
|
-
}),
|
|
226
|
-
),
|
|
227
|
-
)
|
|
228
|
-
.annotateMerge(
|
|
229
|
-
OpenApi.annotations({ title: "integration", description: "Integration discovery and authentication routes." }),
|
|
230
|
-
)
|
|
1
|
+
import { Integration } from "@zyro-sec/schema/integration"
|
|
2
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
+
import { Form } from "@zyro-sec/schema/form"
|
|
4
|
+
import { Schema } from "effect"
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
+
import {
|
|
7
|
+
IntegrationAttemptNotFoundError,
|
|
8
|
+
IntegrationMethodNotFoundError,
|
|
9
|
+
IntegrationNotFoundError,
|
|
10
|
+
InvalidRequestError,
|
|
11
|
+
} from "../errors.js"
|
|
12
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
13
|
+
|
|
14
|
+
export const IntegrationGroup = HttpApiGroup.make("server.integration")
|
|
15
|
+
.add(
|
|
16
|
+
HttpApiEndpoint.get("integration.list", "/api/integration", {
|
|
17
|
+
query: LocationQuery,
|
|
18
|
+
success: Location.response(Schema.Array(Integration.Info)),
|
|
19
|
+
})
|
|
20
|
+
.annotateMerge(locationQueryOpenApi)
|
|
21
|
+
.annotateMerge(
|
|
22
|
+
OpenApi.annotations({
|
|
23
|
+
identifier: "integration.list",
|
|
24
|
+
summary: "List integrations",
|
|
25
|
+
description: "Retrieve available integrations and their authentication methods.",
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
)
|
|
29
|
+
.add(
|
|
30
|
+
HttpApiEndpoint.get("integration.get", "/api/integration/:integrationID", {
|
|
31
|
+
params: { integrationID: Integration.ID },
|
|
32
|
+
query: LocationQuery,
|
|
33
|
+
success: Location.response(Integration.Info),
|
|
34
|
+
error: IntegrationNotFoundError,
|
|
35
|
+
})
|
|
36
|
+
.annotateMerge(locationQueryOpenApi)
|
|
37
|
+
.annotateMerge(
|
|
38
|
+
OpenApi.annotations({
|
|
39
|
+
identifier: "integration.get",
|
|
40
|
+
summary: "Get integration",
|
|
41
|
+
description: "Retrieve one integration and its authentication methods.",
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
.add(
|
|
46
|
+
HttpApiEndpoint.post("integration.wellknown.add", "/api/experimental/integration/wellknown", {
|
|
47
|
+
query: LocationQuery,
|
|
48
|
+
payload: Schema.Struct({ url: Schema.String }),
|
|
49
|
+
success: HttpApiSchema.NoContent,
|
|
50
|
+
error: InvalidRequestError,
|
|
51
|
+
})
|
|
52
|
+
.annotateMerge(locationQueryOpenApi)
|
|
53
|
+
.annotateMerge(
|
|
54
|
+
OpenApi.annotations({
|
|
55
|
+
identifier: "experimental.integration.wellknown.add",
|
|
56
|
+
summary: "Add wellknown integration",
|
|
57
|
+
description: "Discover and persist an experimental wellknown integration source.",
|
|
58
|
+
}),
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
.add(
|
|
62
|
+
HttpApiEndpoint.post("integration.connect.key", "/api/integration/:integrationID/connect/key", {
|
|
63
|
+
params: { integrationID: Integration.ID },
|
|
64
|
+
query: LocationQuery,
|
|
65
|
+
payload: Schema.Struct({
|
|
66
|
+
key: Schema.String,
|
|
67
|
+
answer: Schema.optional(Form.Answer),
|
|
68
|
+
label: Schema.optional(Schema.String),
|
|
69
|
+
}),
|
|
70
|
+
success: HttpApiSchema.NoContent,
|
|
71
|
+
error: [IntegrationNotFoundError, InvalidRequestError],
|
|
72
|
+
})
|
|
73
|
+
.annotateMerge(locationQueryOpenApi)
|
|
74
|
+
.annotateMerge(
|
|
75
|
+
OpenApi.annotations({
|
|
76
|
+
identifier: "integration.connect.key",
|
|
77
|
+
summary: "Connect with key",
|
|
78
|
+
description: "Run a key authentication method and store the resulting credential.",
|
|
79
|
+
}),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
.add(
|
|
83
|
+
HttpApiEndpoint.post("integration.connect.external", "/api/integration/:integrationID/connect/external", {
|
|
84
|
+
params: { integrationID: Integration.ID },
|
|
85
|
+
query: LocationQuery,
|
|
86
|
+
payload: Schema.Struct({
|
|
87
|
+
methodID: Integration.MethodID,
|
|
88
|
+
answer: Schema.optional(Form.Answer),
|
|
89
|
+
label: Schema.optional(Schema.String),
|
|
90
|
+
}),
|
|
91
|
+
success: HttpApiSchema.NoContent,
|
|
92
|
+
error: [IntegrationNotFoundError, InvalidRequestError],
|
|
93
|
+
})
|
|
94
|
+
.annotateMerge(locationQueryOpenApi)
|
|
95
|
+
.annotateMerge(
|
|
96
|
+
OpenApi.annotations({
|
|
97
|
+
identifier: "integration.connect.external",
|
|
98
|
+
summary: "Connect with external credentials",
|
|
99
|
+
description: "Run an external authentication method and store a reference to its credential source.",
|
|
100
|
+
}),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
.add(
|
|
104
|
+
HttpApiEndpoint.post("integration.oauth.connect", "/api/integration/:integrationID/connect/oauth", {
|
|
105
|
+
params: { integrationID: Integration.ID },
|
|
106
|
+
query: LocationQuery,
|
|
107
|
+
payload: Schema.Struct({
|
|
108
|
+
methodID: Integration.MethodID,
|
|
109
|
+
answer: Schema.optional(Form.Answer),
|
|
110
|
+
label: Schema.optional(Schema.String),
|
|
111
|
+
}),
|
|
112
|
+
success: Location.response(Integration.Attempt),
|
|
113
|
+
error: InvalidRequestError,
|
|
114
|
+
})
|
|
115
|
+
.annotateMerge(locationQueryOpenApi)
|
|
116
|
+
.annotateMerge(
|
|
117
|
+
OpenApi.annotations({
|
|
118
|
+
identifier: "integration.oauth.connect",
|
|
119
|
+
summary: "Begin OAuth connection",
|
|
120
|
+
description: "Start an OAuth attempt and return the authorization details.",
|
|
121
|
+
}),
|
|
122
|
+
),
|
|
123
|
+
)
|
|
124
|
+
.add(
|
|
125
|
+
HttpApiEndpoint.get("integration.oauth.status", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
126
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
127
|
+
query: LocationQuery,
|
|
128
|
+
success: Location.response(Integration.AttemptStatus),
|
|
129
|
+
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError],
|
|
130
|
+
})
|
|
131
|
+
.annotateMerge(locationQueryOpenApi)
|
|
132
|
+
.annotateMerge(
|
|
133
|
+
OpenApi.annotations({
|
|
134
|
+
identifier: "integration.oauth.status",
|
|
135
|
+
summary: "Get OAuth attempt status",
|
|
136
|
+
description: "Poll the current status of an OAuth attempt.",
|
|
137
|
+
}),
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
.add(
|
|
141
|
+
HttpApiEndpoint.post(
|
|
142
|
+
"integration.oauth.complete",
|
|
143
|
+
"/api/integration/:integrationID/connect/oauth/:attemptID/complete",
|
|
144
|
+
{
|
|
145
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
146
|
+
query: LocationQuery,
|
|
147
|
+
payload: Schema.Struct({ code: Schema.optional(Schema.String) }),
|
|
148
|
+
success: HttpApiSchema.NoContent,
|
|
149
|
+
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError, InvalidRequestError],
|
|
150
|
+
},
|
|
151
|
+
)
|
|
152
|
+
.annotateMerge(locationQueryOpenApi)
|
|
153
|
+
.annotateMerge(
|
|
154
|
+
OpenApi.annotations({
|
|
155
|
+
identifier: "integration.oauth.complete",
|
|
156
|
+
summary: "Complete OAuth connection",
|
|
157
|
+
description:
|
|
158
|
+
"Complete a code-based OAuth attempt and store the resulting credential. For an automatic attempt with `paste`, `code` is the redirect URL copied from the browser, and the result arrives through the attempt status.",
|
|
159
|
+
}),
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
.add(
|
|
163
|
+
HttpApiEndpoint.delete("integration.oauth.cancel", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
164
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
165
|
+
query: LocationQuery,
|
|
166
|
+
success: HttpApiSchema.NoContent,
|
|
167
|
+
})
|
|
168
|
+
.annotateMerge(locationQueryOpenApi)
|
|
169
|
+
.annotateMerge(
|
|
170
|
+
OpenApi.annotations({
|
|
171
|
+
identifier: "integration.oauth.cancel",
|
|
172
|
+
summary: "Cancel OAuth connection",
|
|
173
|
+
description: "Cancel an OAuth attempt and release its resources.",
|
|
174
|
+
}),
|
|
175
|
+
),
|
|
176
|
+
)
|
|
177
|
+
.add(
|
|
178
|
+
HttpApiEndpoint.post("integration.command.connect", "/api/integration/:integrationID/connect/command", {
|
|
179
|
+
params: { integrationID: Integration.ID },
|
|
180
|
+
query: LocationQuery,
|
|
181
|
+
payload: Schema.Struct({
|
|
182
|
+
methodID: Integration.MethodID,
|
|
183
|
+
label: Schema.optional(Schema.String),
|
|
184
|
+
}),
|
|
185
|
+
success: Location.response(Integration.CommandAttempt),
|
|
186
|
+
error: [IntegrationNotFoundError, IntegrationMethodNotFoundError, InvalidRequestError],
|
|
187
|
+
})
|
|
188
|
+
.annotateMerge(locationQueryOpenApi)
|
|
189
|
+
.annotateMerge(
|
|
190
|
+
OpenApi.annotations({
|
|
191
|
+
identifier: "integration.command.connect",
|
|
192
|
+
summary: "Begin command connection",
|
|
193
|
+
description: "Start a command authentication attempt.",
|
|
194
|
+
}),
|
|
195
|
+
),
|
|
196
|
+
)
|
|
197
|
+
.add(
|
|
198
|
+
HttpApiEndpoint.get("integration.command.status", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
199
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
200
|
+
query: LocationQuery,
|
|
201
|
+
success: Location.response(Integration.CommandAttemptStatus),
|
|
202
|
+
error: [IntegrationNotFoundError, IntegrationAttemptNotFoundError],
|
|
203
|
+
})
|
|
204
|
+
.annotateMerge(locationQueryOpenApi)
|
|
205
|
+
.annotateMerge(
|
|
206
|
+
OpenApi.annotations({
|
|
207
|
+
identifier: "integration.command.status",
|
|
208
|
+
summary: "Get command attempt status",
|
|
209
|
+
description: "Poll the current status and output of a command authentication attempt.",
|
|
210
|
+
}),
|
|
211
|
+
),
|
|
212
|
+
)
|
|
213
|
+
.add(
|
|
214
|
+
HttpApiEndpoint.delete("integration.command.cancel", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
215
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
216
|
+
query: LocationQuery,
|
|
217
|
+
success: HttpApiSchema.NoContent,
|
|
218
|
+
})
|
|
219
|
+
.annotateMerge(locationQueryOpenApi)
|
|
220
|
+
.annotateMerge(
|
|
221
|
+
OpenApi.annotations({
|
|
222
|
+
identifier: "integration.command.cancel",
|
|
223
|
+
summary: "Cancel command connection",
|
|
224
|
+
description: "Cancel a command authentication attempt and terminate its process.",
|
|
225
|
+
}),
|
|
226
|
+
),
|
|
227
|
+
)
|
|
228
|
+
.annotateMerge(
|
|
229
|
+
OpenApi.annotations({ title: "integration", description: "Integration discovery and authentication routes." }),
|
|
230
|
+
)
|
package/src/groups/job.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { Job } from "@zyro-sec/schema/job"
|
|
2
|
-
import { Session } from "@zyro-sec/schema/session"
|
|
3
|
-
import { Schema, SchemaGetter } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
-
import { InvalidRequestError, SessionNotFoundError } from "../errors.js"
|
|
6
|
-
|
|
7
|
-
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(
|
|
8
|
-
Schema.decodeTo(Schema.Boolean, {
|
|
9
|
-
decode: SchemaGetter.transform((value) => value === "true"),
|
|
10
|
-
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
11
|
-
}),
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
export const ListQuery = Schema.Struct({
|
|
15
|
-
sessionID: Schema.optional(Session.ID).annotate({
|
|
16
|
-
description: "Filter to background jobs owned by this session.",
|
|
17
|
-
}),
|
|
18
|
-
kind: Schema.optional(Job.Kind).annotate({
|
|
19
|
-
description: "Filter by background job kind.",
|
|
20
|
-
}),
|
|
21
|
-
status: Schema.optional(Job.Status).annotate({
|
|
22
|
-
description: "Filter by job status (running, completed, error, or cancelled).",
|
|
23
|
-
}),
|
|
24
|
-
descendants: Schema.optional(BooleanFromString).annotate({
|
|
25
|
-
description: "When sessionID is set, also include background jobs owned by child and nested subagent sessions.",
|
|
26
|
-
}),
|
|
27
|
-
}).annotate({ identifier: "Job.ListQuery" })
|
|
28
|
-
export type ListQuery = typeof ListQuery.Type
|
|
29
|
-
|
|
30
|
-
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
31
|
-
export const JobEndpoints = [
|
|
32
|
-
HttpApiEndpoint.get("job.list", "/api/experimental/job", {
|
|
33
|
-
query: ListQuery,
|
|
34
|
-
success: Schema.Struct({ data: Schema.Array(Job.Info) }),
|
|
35
|
-
error: [InvalidRequestError, SessionNotFoundError],
|
|
36
|
-
}).annotateMerge(
|
|
37
|
-
OpenApi.annotations({
|
|
38
|
-
identifier: "experimental.job.list",
|
|
39
|
-
summary: "List background jobs",
|
|
40
|
-
description:
|
|
41
|
-
"List active and unconsumed background jobs, optionally filtered by owning session, descendants, or kind. Experimental: may change without compatibility guarantees.",
|
|
42
|
-
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
HttpApiEndpoint.post("job.cancel", "/api/experimental/job/:id/cancel", {
|
|
46
|
-
params: { id: Schema.String },
|
|
47
|
-
success: HttpApiSchema.NoContent,
|
|
48
|
-
}).annotateMerge(
|
|
49
|
-
OpenApi.annotations({
|
|
50
|
-
identifier: "experimental.job.cancel",
|
|
51
|
-
summary: "Cancel background job",
|
|
52
|
-
description:
|
|
53
|
-
"Cancel a running background job, interrupting the work it started. Cancelling a job that already finished does nothing. Experimental: may change without compatibility guarantees.",
|
|
54
|
-
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
55
|
-
}),
|
|
56
|
-
),
|
|
57
|
-
] as const
|
|
1
|
+
import { Job } from "@zyro-sec/schema/job"
|
|
2
|
+
import { Session } from "@zyro-sec/schema/session"
|
|
3
|
+
import { Schema, SchemaGetter } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
+
import { InvalidRequestError, SessionNotFoundError } from "../errors.js"
|
|
6
|
+
|
|
7
|
+
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(
|
|
8
|
+
Schema.decodeTo(Schema.Boolean, {
|
|
9
|
+
decode: SchemaGetter.transform((value) => value === "true"),
|
|
10
|
+
encode: SchemaGetter.transform((value): "true" | "false" => (value ? "true" : "false")),
|
|
11
|
+
}),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const ListQuery = Schema.Struct({
|
|
15
|
+
sessionID: Schema.optional(Session.ID).annotate({
|
|
16
|
+
description: "Filter to background jobs owned by this session.",
|
|
17
|
+
}),
|
|
18
|
+
kind: Schema.optional(Job.Kind).annotate({
|
|
19
|
+
description: "Filter by background job kind.",
|
|
20
|
+
}),
|
|
21
|
+
status: Schema.optional(Job.Status).annotate({
|
|
22
|
+
description: "Filter by job status (running, completed, error, or cancelled).",
|
|
23
|
+
}),
|
|
24
|
+
descendants: Schema.optional(BooleanFromString).annotate({
|
|
25
|
+
description: "When sessionID is set, also include background jobs owned by child and nested subagent sessions.",
|
|
26
|
+
}),
|
|
27
|
+
}).annotate({ identifier: "Job.ListQuery" })
|
|
28
|
+
export type ListQuery = typeof ListQuery.Type
|
|
29
|
+
|
|
30
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
31
|
+
export const JobEndpoints = [
|
|
32
|
+
HttpApiEndpoint.get("job.list", "/api/experimental/job", {
|
|
33
|
+
query: ListQuery,
|
|
34
|
+
success: Schema.Struct({ data: Schema.Array(Job.Info) }),
|
|
35
|
+
error: [InvalidRequestError, SessionNotFoundError],
|
|
36
|
+
}).annotateMerge(
|
|
37
|
+
OpenApi.annotations({
|
|
38
|
+
identifier: "experimental.job.list",
|
|
39
|
+
summary: "List background jobs",
|
|
40
|
+
description:
|
|
41
|
+
"List active and unconsumed background jobs, optionally filtered by owning session, descendants, or kind. Experimental: may change without compatibility guarantees.",
|
|
42
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
HttpApiEndpoint.post("job.cancel", "/api/experimental/job/:id/cancel", {
|
|
46
|
+
params: { id: Schema.String },
|
|
47
|
+
success: HttpApiSchema.NoContent,
|
|
48
|
+
}).annotateMerge(
|
|
49
|
+
OpenApi.annotations({
|
|
50
|
+
identifier: "experimental.job.cancel",
|
|
51
|
+
summary: "Cancel background job",
|
|
52
|
+
description:
|
|
53
|
+
"Cancel a running background job, interrupting the work it started. Cancelling a job that already finished does nothing. Experimental: may change without compatibility guarantees.",
|
|
54
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
] as const
|