@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
package/src/groups/agent.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Agent } from "@zyro-sec/schema/agent"
|
|
2
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
-
import { AgentNotFoundError } from "../errors.js"
|
|
7
|
-
|
|
8
|
-
export const AgentGroup = HttpApiGroup.make("server.agent")
|
|
9
|
-
.add(
|
|
10
|
-
HttpApiEndpoint.get("agent.list", "/api/agent", {
|
|
11
|
-
query: LocationQuery,
|
|
12
|
-
success: Location.response(Schema.Array(Agent.Info)),
|
|
13
|
-
})
|
|
14
|
-
.annotateMerge(locationQueryOpenApi)
|
|
15
|
-
.annotateMerge(
|
|
16
|
-
OpenApi.annotations({
|
|
17
|
-
identifier: "agent.list",
|
|
18
|
-
summary: "List agents",
|
|
19
|
-
description: "Retrieve currently registered agents.",
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
)
|
|
23
|
-
.add(
|
|
24
|
-
HttpApiEndpoint.get("agent.get", "/api/agent/:agentID", {
|
|
25
|
-
params: { agentID: Agent.ID },
|
|
26
|
-
query: LocationQuery,
|
|
27
|
-
success: Location.response(Agent.Info),
|
|
28
|
-
error: AgentNotFoundError,
|
|
29
|
-
})
|
|
30
|
-
.annotateMerge(locationQueryOpenApi)
|
|
31
|
-
.annotateMerge(
|
|
32
|
-
OpenApi.annotations({
|
|
33
|
-
identifier: "agent.get",
|
|
34
|
-
summary: "Get agent",
|
|
35
|
-
description: "Retrieve a single currently registered agent.",
|
|
36
|
-
}),
|
|
37
|
-
),
|
|
38
|
-
)
|
|
39
|
-
.annotateMerge(OpenApi.annotations({ title: "agent" }))
|
|
1
|
+
import { Agent } from "@zyro-sec/schema/agent"
|
|
2
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
+
import { AgentNotFoundError } from "../errors.js"
|
|
7
|
+
|
|
8
|
+
export const AgentGroup = HttpApiGroup.make("server.agent")
|
|
9
|
+
.add(
|
|
10
|
+
HttpApiEndpoint.get("agent.list", "/api/agent", {
|
|
11
|
+
query: LocationQuery,
|
|
12
|
+
success: Location.response(Schema.Array(Agent.Info)),
|
|
13
|
+
})
|
|
14
|
+
.annotateMerge(locationQueryOpenApi)
|
|
15
|
+
.annotateMerge(
|
|
16
|
+
OpenApi.annotations({
|
|
17
|
+
identifier: "agent.list",
|
|
18
|
+
summary: "List agents",
|
|
19
|
+
description: "Retrieve currently registered agents.",
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
.add(
|
|
24
|
+
HttpApiEndpoint.get("agent.get", "/api/agent/:agentID", {
|
|
25
|
+
params: { agentID: Agent.ID },
|
|
26
|
+
query: LocationQuery,
|
|
27
|
+
success: Location.response(Agent.Info),
|
|
28
|
+
error: AgentNotFoundError,
|
|
29
|
+
})
|
|
30
|
+
.annotateMerge(locationQueryOpenApi)
|
|
31
|
+
.annotateMerge(
|
|
32
|
+
OpenApi.annotations({
|
|
33
|
+
identifier: "agent.get",
|
|
34
|
+
summary: "Get agent",
|
|
35
|
+
description: "Retrieve a single currently registered agent.",
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
.annotateMerge(OpenApi.annotations({ title: "agent" }))
|
package/src/groups/artifact.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import { Artifact } from "@zyro-sec/schema/artifact"
|
|
2
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
-
import { Session } from "@zyro-sec/schema/session"
|
|
4
|
-
import { Schema } from "effect"
|
|
5
|
-
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
-
import {
|
|
7
|
-
ArtifactNotFoundError,
|
|
8
|
-
FileNotFoundError,
|
|
9
|
-
ForbiddenError,
|
|
10
|
-
InvalidRequestError,
|
|
11
|
-
LocationNotFoundError,
|
|
12
|
-
ProviderNotFoundError,
|
|
13
|
-
ServiceUnavailableError,
|
|
14
|
-
SessionNotFoundError,
|
|
15
|
-
} from "../errors.js"
|
|
16
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
17
|
-
|
|
18
|
-
const EXPERIMENTAL =
|
|
19
|
-
"Experimental: needs experimental.artifacts in the Location's config and may change without notice."
|
|
20
|
-
|
|
21
|
-
const params = { artifactID: Artifact.ID }
|
|
22
|
-
|
|
23
|
-
const ListQuery = Schema.Struct({
|
|
24
|
-
...LocationQuery.fields,
|
|
25
|
-
sessionID: Schema.optional(Session.ID),
|
|
26
|
-
provider: Schema.optional(Artifact.ProviderID),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const annotations = (identifier: string, summary: string, description: string) =>
|
|
30
|
-
OpenApi.annotations({
|
|
31
|
-
identifier: `experimental.artifacts.${identifier}`,
|
|
32
|
-
summary,
|
|
33
|
-
description: `${description} ${EXPERIMENTAL}`,
|
|
34
|
-
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const commonErrors = [ForbiddenError, LocationNotFoundError, ServiceUnavailableError] as const
|
|
38
|
-
const itemErrors = [ArtifactNotFoundError, ...commonErrors] as const
|
|
39
|
-
|
|
40
|
-
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
41
|
-
export const ArtifactEndpoints = [
|
|
42
|
-
HttpApiEndpoint.get("artifacts.providers", "/api/experimental/artifacts/providers", {
|
|
43
|
-
query: LocationQuery,
|
|
44
|
-
success: Location.response(Schema.Array(Artifact.Provider)),
|
|
45
|
-
error: commonErrors,
|
|
46
|
-
})
|
|
47
|
-
.annotateMerge(locationQueryOpenApi)
|
|
48
|
-
.annotateMerge(annotations("providers", "List artifact providers", "Return active artifact providers and default.")),
|
|
49
|
-
HttpApiEndpoint.get("artifacts.list", "/api/experimental/artifacts", {
|
|
50
|
-
query: ListQuery,
|
|
51
|
-
success: Location.response(Schema.Array(Artifact.Info)),
|
|
52
|
-
error: [SessionNotFoundError, ...commonErrors],
|
|
53
|
-
})
|
|
54
|
-
.annotateMerge(locationQueryOpenApi)
|
|
55
|
-
.annotateMerge(annotations("list", "List artifacts", "List published artifacts, newest update first.")),
|
|
56
|
-
HttpApiEndpoint.post("artifacts.create", "/api/experimental/artifacts", {
|
|
57
|
-
query: LocationQuery,
|
|
58
|
-
payload: Artifact.CreateInput,
|
|
59
|
-
success: Location.response(Artifact.Info),
|
|
60
|
-
error: [InvalidRequestError, ProviderNotFoundError, SessionNotFoundError, ...commonErrors],
|
|
61
|
-
})
|
|
62
|
-
.annotateMerge(locationQueryOpenApi)
|
|
63
|
-
.annotateMerge(
|
|
64
|
-
annotations(
|
|
65
|
-
"create",
|
|
66
|
-
"Create artifact",
|
|
67
|
-
"Publish a new artifact through the selected or default artifact provider.",
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
HttpApiEndpoint.get("artifacts.get", "/api/experimental/artifacts/:artifactID", {
|
|
71
|
-
params,
|
|
72
|
-
query: LocationQuery,
|
|
73
|
-
success: Location.response(Artifact.Content),
|
|
74
|
-
error: itemErrors,
|
|
75
|
-
})
|
|
76
|
-
.annotateMerge(locationQueryOpenApi)
|
|
77
|
-
.annotateMerge(annotations("get", "Read artifact", "Read an artifact's metadata and file contents.")),
|
|
78
|
-
HttpApiEndpoint.patch("artifacts.update", "/api/experimental/artifacts/:artifactID", {
|
|
79
|
-
params,
|
|
80
|
-
query: LocationQuery,
|
|
81
|
-
payload: Artifact.UpdateInput,
|
|
82
|
-
success: Location.response(Artifact.Info),
|
|
83
|
-
error: [InvalidRequestError, SessionNotFoundError, ...itemErrors],
|
|
84
|
-
})
|
|
85
|
-
.annotateMerge(locationQueryOpenApi)
|
|
86
|
-
.annotateMerge(annotations("update", "Update artifact", "Replace an artifact's files at the same ID and URL.")),
|
|
87
|
-
HttpApiEndpoint.delete("artifacts.delete", "/api/experimental/artifacts/:artifactID", {
|
|
88
|
-
params,
|
|
89
|
-
query: LocationQuery,
|
|
90
|
-
success: HttpApiSchema.NoContent,
|
|
91
|
-
error: itemErrors,
|
|
92
|
-
})
|
|
93
|
-
.annotateMerge(locationQueryOpenApi)
|
|
94
|
-
.annotateMerge(annotations("delete", "Delete artifact", "Remove an artifact and its stored files.")),
|
|
95
|
-
HttpApiEndpoint.get("artifacts.view", "/api/experimental/artifacts/:artifactID/view/*", {
|
|
96
|
-
params,
|
|
97
|
-
query: LocationQuery,
|
|
98
|
-
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
99
|
-
error: [FileNotFoundError, InvalidRequestError, ...itemErrors],
|
|
100
|
-
})
|
|
101
|
-
.annotateMerge(locationQueryOpenApi)
|
|
102
|
-
.annotateMerge(annotations("view", "View local artifact", "Serve HTML and static files from the local provider.")),
|
|
103
|
-
] as const
|
|
1
|
+
import { Artifact } from "@zyro-sec/schema/artifact"
|
|
2
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
+
import { Session } from "@zyro-sec/schema/session"
|
|
4
|
+
import { Schema } from "effect"
|
|
5
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
+
import {
|
|
7
|
+
ArtifactNotFoundError,
|
|
8
|
+
FileNotFoundError,
|
|
9
|
+
ForbiddenError,
|
|
10
|
+
InvalidRequestError,
|
|
11
|
+
LocationNotFoundError,
|
|
12
|
+
ProviderNotFoundError,
|
|
13
|
+
ServiceUnavailableError,
|
|
14
|
+
SessionNotFoundError,
|
|
15
|
+
} from "../errors.js"
|
|
16
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
17
|
+
|
|
18
|
+
const EXPERIMENTAL =
|
|
19
|
+
"Experimental: needs experimental.artifacts in the Location's config and may change without notice."
|
|
20
|
+
|
|
21
|
+
const params = { artifactID: Artifact.ID }
|
|
22
|
+
|
|
23
|
+
const ListQuery = Schema.Struct({
|
|
24
|
+
...LocationQuery.fields,
|
|
25
|
+
sessionID: Schema.optional(Session.ID),
|
|
26
|
+
provider: Schema.optional(Artifact.ProviderID),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const annotations = (identifier: string, summary: string, description: string) =>
|
|
30
|
+
OpenApi.annotations({
|
|
31
|
+
identifier: `experimental.artifacts.${identifier}`,
|
|
32
|
+
summary,
|
|
33
|
+
description: `${description} ${EXPERIMENTAL}`,
|
|
34
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const commonErrors = [ForbiddenError, LocationNotFoundError, ServiceUnavailableError] as const
|
|
38
|
+
const itemErrors = [ArtifactNotFoundError, ...commonErrors] as const
|
|
39
|
+
|
|
40
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
41
|
+
export const ArtifactEndpoints = [
|
|
42
|
+
HttpApiEndpoint.get("artifacts.providers", "/api/experimental/artifacts/providers", {
|
|
43
|
+
query: LocationQuery,
|
|
44
|
+
success: Location.response(Schema.Array(Artifact.Provider)),
|
|
45
|
+
error: commonErrors,
|
|
46
|
+
})
|
|
47
|
+
.annotateMerge(locationQueryOpenApi)
|
|
48
|
+
.annotateMerge(annotations("providers", "List artifact providers", "Return active artifact providers and default.")),
|
|
49
|
+
HttpApiEndpoint.get("artifacts.list", "/api/experimental/artifacts", {
|
|
50
|
+
query: ListQuery,
|
|
51
|
+
success: Location.response(Schema.Array(Artifact.Info)),
|
|
52
|
+
error: [SessionNotFoundError, ...commonErrors],
|
|
53
|
+
})
|
|
54
|
+
.annotateMerge(locationQueryOpenApi)
|
|
55
|
+
.annotateMerge(annotations("list", "List artifacts", "List published artifacts, newest update first.")),
|
|
56
|
+
HttpApiEndpoint.post("artifacts.create", "/api/experimental/artifacts", {
|
|
57
|
+
query: LocationQuery,
|
|
58
|
+
payload: Artifact.CreateInput,
|
|
59
|
+
success: Location.response(Artifact.Info),
|
|
60
|
+
error: [InvalidRequestError, ProviderNotFoundError, SessionNotFoundError, ...commonErrors],
|
|
61
|
+
})
|
|
62
|
+
.annotateMerge(locationQueryOpenApi)
|
|
63
|
+
.annotateMerge(
|
|
64
|
+
annotations(
|
|
65
|
+
"create",
|
|
66
|
+
"Create artifact",
|
|
67
|
+
"Publish a new artifact through the selected or default artifact provider.",
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
HttpApiEndpoint.get("artifacts.get", "/api/experimental/artifacts/:artifactID", {
|
|
71
|
+
params,
|
|
72
|
+
query: LocationQuery,
|
|
73
|
+
success: Location.response(Artifact.Content),
|
|
74
|
+
error: itemErrors,
|
|
75
|
+
})
|
|
76
|
+
.annotateMerge(locationQueryOpenApi)
|
|
77
|
+
.annotateMerge(annotations("get", "Read artifact", "Read an artifact's metadata and file contents.")),
|
|
78
|
+
HttpApiEndpoint.patch("artifacts.update", "/api/experimental/artifacts/:artifactID", {
|
|
79
|
+
params,
|
|
80
|
+
query: LocationQuery,
|
|
81
|
+
payload: Artifact.UpdateInput,
|
|
82
|
+
success: Location.response(Artifact.Info),
|
|
83
|
+
error: [InvalidRequestError, SessionNotFoundError, ...itemErrors],
|
|
84
|
+
})
|
|
85
|
+
.annotateMerge(locationQueryOpenApi)
|
|
86
|
+
.annotateMerge(annotations("update", "Update artifact", "Replace an artifact's files at the same ID and URL.")),
|
|
87
|
+
HttpApiEndpoint.delete("artifacts.delete", "/api/experimental/artifacts/:artifactID", {
|
|
88
|
+
params,
|
|
89
|
+
query: LocationQuery,
|
|
90
|
+
success: HttpApiSchema.NoContent,
|
|
91
|
+
error: itemErrors,
|
|
92
|
+
})
|
|
93
|
+
.annotateMerge(locationQueryOpenApi)
|
|
94
|
+
.annotateMerge(annotations("delete", "Delete artifact", "Remove an artifact and its stored files.")),
|
|
95
|
+
HttpApiEndpoint.get("artifacts.view", "/api/experimental/artifacts/:artifactID/view/*", {
|
|
96
|
+
params,
|
|
97
|
+
query: LocationQuery,
|
|
98
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
99
|
+
error: [FileNotFoundError, InvalidRequestError, ...itemErrors],
|
|
100
|
+
})
|
|
101
|
+
.annotateMerge(locationQueryOpenApi)
|
|
102
|
+
.annotateMerge(annotations("view", "View local artifact", "Serve HTML and static files from the local provider.")),
|
|
103
|
+
] as const
|
package/src/groups/automation.ts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { Automation } from "@zyro-sec/schema/automation"
|
|
2
|
-
import { Session } from "@zyro-sec/schema/session"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
-
import { AutomationNotFoundError, ForbiddenError, InvalidRequestError, SessionNotFoundError } from "../errors.js"
|
|
6
|
-
|
|
7
|
-
const EXPERIMENTAL =
|
|
8
|
-
"Experimental: may change without compatibility guarantees. Set automations to false in the directory's config to disable access."
|
|
9
|
-
const errors = [AutomationNotFoundError, ForbiddenError] as const
|
|
10
|
-
const params = { automationID: Automation.ID }
|
|
11
|
-
const annotations = (identifier: string, summary: string, description: string) =>
|
|
12
|
-
OpenApi.annotations({
|
|
13
|
-
identifier: `experimental.automation.${identifier}`,
|
|
14
|
-
summary,
|
|
15
|
-
description: `${description} ${EXPERIMENTAL}`,
|
|
16
|
-
// The routes share the `server.experimental` group with the persistent PTY prototype; tag them on their own.
|
|
17
|
-
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
export const CreatePayload = Automation.CreateInput.annotate({ identifier: "Automation.CreatePayload" })
|
|
21
|
-
export type CreatePayload = typeof CreatePayload.Type
|
|
22
|
-
|
|
23
|
-
export const ListQuery = Schema.Struct({
|
|
24
|
-
sessionID: Session.ID.pipe(Schema.optional).annotate({ description: "Only automations created by this Session." }),
|
|
25
|
-
directory: Schema.String.pipe(Schema.optional).annotate({
|
|
26
|
-
description: "Only automations in the project that owns this directory.",
|
|
27
|
-
}),
|
|
28
|
-
}).annotate({ identifier: "Automation.ListQuery" })
|
|
29
|
-
export type ListQuery = typeof ListQuery.Type
|
|
30
|
-
|
|
31
|
-
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
32
|
-
export const AutomationEndpoints = [
|
|
33
|
-
HttpApiEndpoint.post("automation.create", "/api/experimental/automation", {
|
|
34
|
-
payload: CreatePayload,
|
|
35
|
-
success: Schema.Struct({ data: Automation.Info }),
|
|
36
|
-
error: [InvalidRequestError, SessionNotFoundError, ForbiddenError],
|
|
37
|
-
}).annotateMerge(
|
|
38
|
-
annotations(
|
|
39
|
-
"create",
|
|
40
|
-
"Create automation",
|
|
41
|
-
"Create an automation that sends a prompt, runs a Code Mode program, or runs a shell command at a time, every interval, or on a cron. Creating an MCP event watch requires the automation_create tool in a local session; a session ID over HTTP is not a watch authorization.",
|
|
42
|
-
),
|
|
43
|
-
),
|
|
44
|
-
HttpApiEndpoint.get("automation.list", "/api/experimental/automation", {
|
|
45
|
-
query: ListQuery,
|
|
46
|
-
success: Schema.Struct({ data: Schema.Array(Automation.Info) }),
|
|
47
|
-
error: [SessionNotFoundError, ForbiddenError, InvalidRequestError],
|
|
48
|
-
}).annotateMerge(annotations("list", "List automations", "List automations, oldest first.")),
|
|
49
|
-
HttpApiEndpoint.get("automation.get", "/api/experimental/automation/:automationID", {
|
|
50
|
-
params,
|
|
51
|
-
success: Schema.Struct({ data: Automation.Info }),
|
|
52
|
-
error: errors,
|
|
53
|
-
}).annotateMerge(annotations("get", "Get automation", "Read one automation.")),
|
|
54
|
-
HttpApiEndpoint.post("automation.pause", "/api/experimental/automation/:automationID/pause", {
|
|
55
|
-
params,
|
|
56
|
-
success: Schema.Struct({ data: Automation.Info }),
|
|
57
|
-
error: errors,
|
|
58
|
-
}).annotateMerge(annotations("pause", "Pause automation", "Stop an automation from running until it is resumed.")),
|
|
59
|
-
HttpApiEndpoint.post("automation.resume", "/api/experimental/automation/:automationID/resume", {
|
|
60
|
-
params,
|
|
61
|
-
success: Schema.Struct({ data: Automation.Info }),
|
|
62
|
-
error: errors,
|
|
63
|
-
}).annotateMerge(
|
|
64
|
-
annotations(
|
|
65
|
-
"resume",
|
|
66
|
-
"Resume automation",
|
|
67
|
-
"Resume a paused automation. A missed `at` runs once; repeating timers resume at their next slot. Event watches request replay from their saved cursor.",
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
HttpApiEndpoint.delete("automation.delete", "/api/experimental/automation/:automationID", {
|
|
71
|
-
params,
|
|
72
|
-
success: HttpApiSchema.NoContent,
|
|
73
|
-
error: errors,
|
|
74
|
-
}).annotateMerge(annotations("delete", "Delete automation", "Delete an automation.")),
|
|
75
|
-
] as const
|
|
1
|
+
import { Automation } from "@zyro-sec/schema/automation"
|
|
2
|
+
import { Session } from "@zyro-sec/schema/session"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
+
import { AutomationNotFoundError, ForbiddenError, InvalidRequestError, SessionNotFoundError } from "../errors.js"
|
|
6
|
+
|
|
7
|
+
const EXPERIMENTAL =
|
|
8
|
+
"Experimental: may change without compatibility guarantees. Set automations to false in the directory's config to disable access."
|
|
9
|
+
const errors = [AutomationNotFoundError, ForbiddenError] as const
|
|
10
|
+
const params = { automationID: Automation.ID }
|
|
11
|
+
const annotations = (identifier: string, summary: string, description: string) =>
|
|
12
|
+
OpenApi.annotations({
|
|
13
|
+
identifier: `experimental.automation.${identifier}`,
|
|
14
|
+
summary,
|
|
15
|
+
description: `${description} ${EXPERIMENTAL}`,
|
|
16
|
+
// The routes share the `server.experimental` group with the persistent PTY prototype; tag them on their own.
|
|
17
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const CreatePayload = Automation.CreateInput.annotate({ identifier: "Automation.CreatePayload" })
|
|
21
|
+
export type CreatePayload = typeof CreatePayload.Type
|
|
22
|
+
|
|
23
|
+
export const ListQuery = Schema.Struct({
|
|
24
|
+
sessionID: Session.ID.pipe(Schema.optional).annotate({ description: "Only automations created by this Session." }),
|
|
25
|
+
directory: Schema.String.pipe(Schema.optional).annotate({
|
|
26
|
+
description: "Only automations in the project that owns this directory.",
|
|
27
|
+
}),
|
|
28
|
+
}).annotate({ identifier: "Automation.ListQuery" })
|
|
29
|
+
export type ListQuery = typeof ListQuery.Type
|
|
30
|
+
|
|
31
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
32
|
+
export const AutomationEndpoints = [
|
|
33
|
+
HttpApiEndpoint.post("automation.create", "/api/experimental/automation", {
|
|
34
|
+
payload: CreatePayload,
|
|
35
|
+
success: Schema.Struct({ data: Automation.Info }),
|
|
36
|
+
error: [InvalidRequestError, SessionNotFoundError, ForbiddenError],
|
|
37
|
+
}).annotateMerge(
|
|
38
|
+
annotations(
|
|
39
|
+
"create",
|
|
40
|
+
"Create automation",
|
|
41
|
+
"Create an automation that sends a prompt, runs a Code Mode program, or runs a shell command at a time, every interval, or on a cron. Creating an MCP event watch requires the automation_create tool in a local session; a session ID over HTTP is not a watch authorization.",
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
HttpApiEndpoint.get("automation.list", "/api/experimental/automation", {
|
|
45
|
+
query: ListQuery,
|
|
46
|
+
success: Schema.Struct({ data: Schema.Array(Automation.Info) }),
|
|
47
|
+
error: [SessionNotFoundError, ForbiddenError, InvalidRequestError],
|
|
48
|
+
}).annotateMerge(annotations("list", "List automations", "List automations, oldest first.")),
|
|
49
|
+
HttpApiEndpoint.get("automation.get", "/api/experimental/automation/:automationID", {
|
|
50
|
+
params,
|
|
51
|
+
success: Schema.Struct({ data: Automation.Info }),
|
|
52
|
+
error: errors,
|
|
53
|
+
}).annotateMerge(annotations("get", "Get automation", "Read one automation.")),
|
|
54
|
+
HttpApiEndpoint.post("automation.pause", "/api/experimental/automation/:automationID/pause", {
|
|
55
|
+
params,
|
|
56
|
+
success: Schema.Struct({ data: Automation.Info }),
|
|
57
|
+
error: errors,
|
|
58
|
+
}).annotateMerge(annotations("pause", "Pause automation", "Stop an automation from running until it is resumed.")),
|
|
59
|
+
HttpApiEndpoint.post("automation.resume", "/api/experimental/automation/:automationID/resume", {
|
|
60
|
+
params,
|
|
61
|
+
success: Schema.Struct({ data: Automation.Info }),
|
|
62
|
+
error: errors,
|
|
63
|
+
}).annotateMerge(
|
|
64
|
+
annotations(
|
|
65
|
+
"resume",
|
|
66
|
+
"Resume automation",
|
|
67
|
+
"Resume a paused automation. A missed `at` runs once; repeating timers resume at their next slot. Event watches request replay from their saved cursor.",
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
HttpApiEndpoint.delete("automation.delete", "/api/experimental/automation/:automationID", {
|
|
71
|
+
params,
|
|
72
|
+
success: HttpApiSchema.NoContent,
|
|
73
|
+
error: errors,
|
|
74
|
+
}).annotateMerge(annotations("delete", "Delete automation", "Delete an automation.")),
|
|
75
|
+
] as const
|
package/src/groups/blob.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlobStore } from "@zyro-sec/schema/blob-store"
|
|
2
|
-
import { Schema } from "effect"
|
|
3
|
-
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
4
|
-
import { BlobNotFoundError } from "../errors.js"
|
|
5
|
-
|
|
6
|
-
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
7
|
-
export const BlobGetEndpoint = HttpApiEndpoint.get("blob.get", "/api/experimental/blob/:id", {
|
|
8
|
-
params: { id: BlobStore.ID },
|
|
9
|
-
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
10
|
-
error: [BlobNotFoundError],
|
|
11
|
-
}).annotateMerge(
|
|
12
|
-
OpenApi.annotations({
|
|
13
|
-
identifier: "experimental.blob.get",
|
|
14
|
-
summary: "Read a blob",
|
|
15
|
-
description:
|
|
16
|
-
"Stream a stored blob's bytes, such as a generated video, with single byte Range, ETag and 304 Not Modified support. A blob is deleted a week after it was stored. Experimental: may change without compatibility guarantees.",
|
|
17
|
-
// The route shares the `server.experimental` group with the persistent PTY prototype; tag it on its own.
|
|
18
|
-
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
19
|
-
}),
|
|
20
|
-
)
|
|
1
|
+
import { BlobStore } from "@zyro-sec/schema/blob-store"
|
|
2
|
+
import { Schema } from "effect"
|
|
3
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
4
|
+
import { BlobNotFoundError } from "../errors.js"
|
|
5
|
+
|
|
6
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
7
|
+
export const BlobGetEndpoint = HttpApiEndpoint.get("blob.get", "/api/experimental/blob/:id", {
|
|
8
|
+
params: { id: BlobStore.ID },
|
|
9
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
10
|
+
error: [BlobNotFoundError],
|
|
11
|
+
}).annotateMerge(
|
|
12
|
+
OpenApi.annotations({
|
|
13
|
+
identifier: "experimental.blob.get",
|
|
14
|
+
summary: "Read a blob",
|
|
15
|
+
description:
|
|
16
|
+
"Stream a stored blob's bytes, such as a generated video, with single byte Range, ETag and 304 Not Modified support. A blob is deleted a week after it was stored. Experimental: may change without compatibility guarantees.",
|
|
17
|
+
// The route shares the `server.experimental` group with the persistent PTY prototype; tag it on its own.
|
|
18
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
19
|
+
}),
|
|
20
|
+
)
|
package/src/groups/command.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Command } from "@zyro-sec/schema/command"
|
|
2
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
-
|
|
7
|
-
export const CommandGroup = HttpApiGroup.make("server.command")
|
|
8
|
-
.add(
|
|
9
|
-
HttpApiEndpoint.get("command.list", "/api/command", {
|
|
10
|
-
query: LocationQuery,
|
|
11
|
-
success: Location.response(Schema.Array(Command.Info)),
|
|
12
|
-
})
|
|
13
|
-
.annotateMerge(locationQueryOpenApi)
|
|
14
|
-
.annotateMerge(
|
|
15
|
-
OpenApi.annotations({
|
|
16
|
-
identifier: "command.list",
|
|
17
|
-
summary: "List commands",
|
|
18
|
-
description: "Retrieve currently registered commands.",
|
|
19
|
-
}),
|
|
20
|
-
),
|
|
21
|
-
)
|
|
22
|
-
.annotateMerge(
|
|
23
|
-
OpenApi.annotations({
|
|
24
|
-
title: "command",
|
|
25
|
-
description: "Experimental command routes.",
|
|
26
|
-
}),
|
|
27
|
-
)
|
|
1
|
+
import { Command } from "@zyro-sec/schema/command"
|
|
2
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
+
|
|
7
|
+
export const CommandGroup = HttpApiGroup.make("server.command")
|
|
8
|
+
.add(
|
|
9
|
+
HttpApiEndpoint.get("command.list", "/api/command", {
|
|
10
|
+
query: LocationQuery,
|
|
11
|
+
success: Location.response(Schema.Array(Command.Info)),
|
|
12
|
+
})
|
|
13
|
+
.annotateMerge(locationQueryOpenApi)
|
|
14
|
+
.annotateMerge(
|
|
15
|
+
OpenApi.annotations({
|
|
16
|
+
identifier: "command.list",
|
|
17
|
+
summary: "List commands",
|
|
18
|
+
description: "Retrieve currently registered commands.",
|
|
19
|
+
}),
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
.annotateMerge(
|
|
23
|
+
OpenApi.annotations({
|
|
24
|
+
title: "command",
|
|
25
|
+
description: "Experimental command routes.",
|
|
26
|
+
}),
|
|
27
|
+
)
|
package/src/groups/config.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Config } from "@zyro-sec/schema/config"
|
|
2
|
-
import { ConfigShell } from "@zyro-sec/schema/config/shell"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
-
|
|
7
|
-
export const ConfigGroup = HttpApiGroup.make("server.config")
|
|
8
|
-
.add(
|
|
9
|
-
HttpApiEndpoint.get("config.get", "/api/config", {
|
|
10
|
-
query: LocationQuery,
|
|
11
|
-
success: Schema.Array(Config.Entry),
|
|
12
|
-
})
|
|
13
|
-
.annotateMerge(locationQueryOpenApi)
|
|
14
|
-
.annotateMerge(
|
|
15
|
-
OpenApi.annotations({
|
|
16
|
-
identifier: "config.get",
|
|
17
|
-
summary: "Get configuration",
|
|
18
|
-
description:
|
|
19
|
-
"Return configuration documents and discovery sources for the requested location, from lowest to highest priority.",
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
)
|
|
23
|
-
.add(
|
|
24
|
-
HttpApiEndpoint.get("config.shells", "/api/config/shell", {
|
|
25
|
-
success: Schema.Array(ConfigShell.Option),
|
|
26
|
-
}).annotateMerge(
|
|
27
|
-
OpenApi.annotations({
|
|
28
|
-
identifier: "config.shells",
|
|
29
|
-
summary: "List available shells",
|
|
30
|
-
description: "Return shells available to terminal and agent execution.",
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
)
|
|
34
|
-
.add(
|
|
35
|
-
HttpApiEndpoint.patch("config.update", "/api/experimental/config", {
|
|
36
|
-
payload: Config.Patch,
|
|
37
|
-
success: HttpApiSchema.NoContent,
|
|
38
|
-
}).annotateMerge(
|
|
39
|
-
OpenApi.annotations({
|
|
40
|
-
identifier: "experimental.config.update",
|
|
41
|
-
summary: "Update global configuration",
|
|
42
|
-
description: "Patch supported fields in the highest-precedence global configuration document.",
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
)
|
|
46
|
-
.annotateMerge(OpenApi.annotations({ title: "config", description: "Location-scoped configuration routes." }))
|
|
1
|
+
import { Config } from "@zyro-sec/schema/config"
|
|
2
|
+
import { ConfigShell } from "@zyro-sec/schema/config/shell"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
6
|
+
|
|
7
|
+
export const ConfigGroup = HttpApiGroup.make("server.config")
|
|
8
|
+
.add(
|
|
9
|
+
HttpApiEndpoint.get("config.get", "/api/config", {
|
|
10
|
+
query: LocationQuery,
|
|
11
|
+
success: Schema.Array(Config.Entry),
|
|
12
|
+
})
|
|
13
|
+
.annotateMerge(locationQueryOpenApi)
|
|
14
|
+
.annotateMerge(
|
|
15
|
+
OpenApi.annotations({
|
|
16
|
+
identifier: "config.get",
|
|
17
|
+
summary: "Get configuration",
|
|
18
|
+
description:
|
|
19
|
+
"Return configuration documents and discovery sources for the requested location, from lowest to highest priority.",
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
.add(
|
|
24
|
+
HttpApiEndpoint.get("config.shells", "/api/config/shell", {
|
|
25
|
+
success: Schema.Array(ConfigShell.Option),
|
|
26
|
+
}).annotateMerge(
|
|
27
|
+
OpenApi.annotations({
|
|
28
|
+
identifier: "config.shells",
|
|
29
|
+
summary: "List available shells",
|
|
30
|
+
description: "Return shells available to terminal and agent execution.",
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
.add(
|
|
35
|
+
HttpApiEndpoint.patch("config.update", "/api/experimental/config", {
|
|
36
|
+
payload: Config.Patch,
|
|
37
|
+
success: HttpApiSchema.NoContent,
|
|
38
|
+
}).annotateMerge(
|
|
39
|
+
OpenApi.annotations({
|
|
40
|
+
identifier: "experimental.config.update",
|
|
41
|
+
summary: "Update global configuration",
|
|
42
|
+
description: "Patch supported fields in the highest-precedence global configuration document.",
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
.annotateMerge(OpenApi.annotations({ title: "config", description: "Location-scoped configuration routes." }))
|