@zyro-sec/protocol 1.0.1 → 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 +6 -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/fs.ts
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import { FileSystem } from "@zyro-sec/schema/filesystem"
|
|
2
|
-
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
-
import { PositiveInt } from "@zyro-sec/schema/schema"
|
|
4
|
-
import { Schema } from "effect"
|
|
5
|
-
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
-
import { FileNotFoundError, ServiceUnavailableError } from "../errors.js"
|
|
7
|
-
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
8
|
-
|
|
9
|
-
const ListQuery = Schema.Struct({
|
|
10
|
-
...LocationQuery.fields,
|
|
11
|
-
path: Schema.String.pipe(Schema.optional).annotate({
|
|
12
|
-
description: "An absolute path or a path relative to the requested location. Defaults to the location directory.",
|
|
13
|
-
}),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const WriteQuery = Schema.Struct({
|
|
17
|
-
...LocationQuery.fields,
|
|
18
|
-
path: Schema.String.annotate({
|
|
19
|
-
description:
|
|
20
|
-
"An absolute path or a path relative to the requested location. Missing parent directories are created.",
|
|
21
|
-
}),
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const WatchPayload = Schema.Struct({
|
|
25
|
-
path: Schema.String.annotate({ description: "A file path relative to the requested location." }),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const FindQuery = Schema.Struct({
|
|
29
|
-
...LocationQuery.fields,
|
|
30
|
-
query: FileSystem.FindInput.fields.query,
|
|
31
|
-
type: FileSystem.FindInput.fields.type,
|
|
32
|
-
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
|
36
|
-
.add(
|
|
37
|
-
HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
|
|
38
|
-
query: LocationQuery,
|
|
39
|
-
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
40
|
-
error: FileNotFoundError,
|
|
41
|
-
})
|
|
42
|
-
.annotateMerge(locationQueryOpenApi)
|
|
43
|
-
.annotateMerge(
|
|
44
|
-
OpenApi.annotations({
|
|
45
|
-
identifier: "fs.read",
|
|
46
|
-
summary: "Read file",
|
|
47
|
-
description:
|
|
48
|
-
"Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).",
|
|
49
|
-
}),
|
|
50
|
-
),
|
|
51
|
-
)
|
|
52
|
-
.add(
|
|
53
|
-
HttpApiEndpoint.get("fs.list", "/api/fs/list", {
|
|
54
|
-
query: ListQuery,
|
|
55
|
-
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
56
|
-
error: FileNotFoundError,
|
|
57
|
-
})
|
|
58
|
-
.annotateMerge(locationQueryOpenApi)
|
|
59
|
-
.annotateMerge(
|
|
60
|
-
OpenApi.annotations({
|
|
61
|
-
identifier: "fs.list",
|
|
62
|
-
summary: "List directory",
|
|
63
|
-
description:
|
|
64
|
-
"List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.",
|
|
65
|
-
}),
|
|
66
|
-
),
|
|
67
|
-
)
|
|
68
|
-
.add(
|
|
69
|
-
HttpApiEndpoint.get("fs.find", "/api/fs/find", {
|
|
70
|
-
query: FindQuery,
|
|
71
|
-
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
72
|
-
})
|
|
73
|
-
.annotateMerge(locationQueryOpenApi)
|
|
74
|
-
.annotateMerge(
|
|
75
|
-
OpenApi.annotations({
|
|
76
|
-
identifier: "fs.find",
|
|
77
|
-
summary: "Find files",
|
|
78
|
-
description: "Find recursively ranked filesystem entries relative to the requested location.",
|
|
79
|
-
}),
|
|
80
|
-
),
|
|
81
|
-
)
|
|
82
|
-
.add(
|
|
83
|
-
HttpApiEndpoint.post("fs.write", "/api/experimental/fs/write", {
|
|
84
|
-
query: WriteQuery,
|
|
85
|
-
payload: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
86
|
-
success: Location.response(FileSystem.Write),
|
|
87
|
-
})
|
|
88
|
-
.annotateMerge(locationQueryOpenApi)
|
|
89
|
-
.annotateMerge(
|
|
90
|
-
OpenApi.annotations({
|
|
91
|
-
identifier: "experimental.fs.write",
|
|
92
|
-
summary: "Write file",
|
|
93
|
-
description:
|
|
94
|
-
"Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.",
|
|
95
|
-
}),
|
|
96
|
-
),
|
|
97
|
-
)
|
|
98
|
-
.add(
|
|
99
|
-
HttpApiEndpoint.post("fs.watch", "/api/experimental/fs/watch", {
|
|
100
|
-
query: LocationQuery,
|
|
101
|
-
payload: WatchPayload,
|
|
102
|
-
success: HttpApiSchema.NoContent,
|
|
103
|
-
error: [FileNotFoundError, ServiceUnavailableError],
|
|
104
|
-
})
|
|
105
|
-
.annotateMerge(locationQueryOpenApi)
|
|
106
|
-
.annotateMerge(
|
|
107
|
-
OpenApi.annotations({
|
|
108
|
-
identifier: "experimental.fs.watch",
|
|
109
|
-
summary: "Watch file",
|
|
110
|
-
description:
|
|
111
|
-
"Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.",
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
114
|
-
)
|
|
115
|
-
.add(
|
|
116
|
-
HttpApiEndpoint.delete("fs.unwatch", "/api/experimental/fs/watch", {
|
|
117
|
-
query: LocationQuery,
|
|
118
|
-
payload: WatchPayload,
|
|
119
|
-
success: HttpApiSchema.NoContent,
|
|
120
|
-
})
|
|
121
|
-
.annotateMerge(locationQueryOpenApi)
|
|
122
|
-
.annotateMerge(
|
|
123
|
-
OpenApi.annotations({
|
|
124
|
-
identifier: "experimental.fs.unwatch",
|
|
125
|
-
summary: "Unwatch file",
|
|
126
|
-
description:
|
|
127
|
-
"Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.",
|
|
128
|
-
}),
|
|
129
|
-
),
|
|
130
|
-
)
|
|
131
|
-
.annotateMerge(
|
|
132
|
-
OpenApi.annotations({
|
|
133
|
-
title: "filesystem",
|
|
134
|
-
description: "Experimental location-scoped filesystem routes.",
|
|
135
|
-
}),
|
|
136
|
-
)
|
|
1
|
+
import { FileSystem } from "@zyro-sec/schema/filesystem"
|
|
2
|
+
import { Location } from "@zyro-sec/schema/location"
|
|
3
|
+
import { PositiveInt } from "@zyro-sec/schema/schema"
|
|
4
|
+
import { Schema } from "effect"
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
|
|
6
|
+
import { FileNotFoundError, ServiceUnavailableError } from "../errors.js"
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js"
|
|
8
|
+
|
|
9
|
+
const ListQuery = Schema.Struct({
|
|
10
|
+
...LocationQuery.fields,
|
|
11
|
+
path: Schema.String.pipe(Schema.optional).annotate({
|
|
12
|
+
description: "An absolute path or a path relative to the requested location. Defaults to the location directory.",
|
|
13
|
+
}),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const WriteQuery = Schema.Struct({
|
|
17
|
+
...LocationQuery.fields,
|
|
18
|
+
path: Schema.String.annotate({
|
|
19
|
+
description:
|
|
20
|
+
"An absolute path or a path relative to the requested location. Missing parent directories are created.",
|
|
21
|
+
}),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const WatchPayload = Schema.Struct({
|
|
25
|
+
path: Schema.String.annotate({ description: "A file path relative to the requested location." }),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const FindQuery = Schema.Struct({
|
|
29
|
+
...LocationQuery.fields,
|
|
30
|
+
query: FileSystem.FindInput.fields.query,
|
|
31
|
+
type: FileSystem.FindInput.fields.type,
|
|
32
|
+
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
|
36
|
+
.add(
|
|
37
|
+
HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
|
|
38
|
+
query: LocationQuery,
|
|
39
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
40
|
+
error: FileNotFoundError,
|
|
41
|
+
})
|
|
42
|
+
.annotateMerge(locationQueryOpenApi)
|
|
43
|
+
.annotateMerge(
|
|
44
|
+
OpenApi.annotations({
|
|
45
|
+
identifier: "fs.read",
|
|
46
|
+
summary: "Read file",
|
|
47
|
+
description:
|
|
48
|
+
"Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).",
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
.add(
|
|
53
|
+
HttpApiEndpoint.get("fs.list", "/api/fs/list", {
|
|
54
|
+
query: ListQuery,
|
|
55
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
56
|
+
error: FileNotFoundError,
|
|
57
|
+
})
|
|
58
|
+
.annotateMerge(locationQueryOpenApi)
|
|
59
|
+
.annotateMerge(
|
|
60
|
+
OpenApi.annotations({
|
|
61
|
+
identifier: "fs.list",
|
|
62
|
+
summary: "List directory",
|
|
63
|
+
description:
|
|
64
|
+
"List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.",
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
.add(
|
|
69
|
+
HttpApiEndpoint.get("fs.find", "/api/fs/find", {
|
|
70
|
+
query: FindQuery,
|
|
71
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
72
|
+
})
|
|
73
|
+
.annotateMerge(locationQueryOpenApi)
|
|
74
|
+
.annotateMerge(
|
|
75
|
+
OpenApi.annotations({
|
|
76
|
+
identifier: "fs.find",
|
|
77
|
+
summary: "Find files",
|
|
78
|
+
description: "Find recursively ranked filesystem entries relative to the requested location.",
|
|
79
|
+
}),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
.add(
|
|
83
|
+
HttpApiEndpoint.post("fs.write", "/api/experimental/fs/write", {
|
|
84
|
+
query: WriteQuery,
|
|
85
|
+
payload: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
86
|
+
success: Location.response(FileSystem.Write),
|
|
87
|
+
})
|
|
88
|
+
.annotateMerge(locationQueryOpenApi)
|
|
89
|
+
.annotateMerge(
|
|
90
|
+
OpenApi.annotations({
|
|
91
|
+
identifier: "experimental.fs.write",
|
|
92
|
+
summary: "Write file",
|
|
93
|
+
description:
|
|
94
|
+
"Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.",
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
.add(
|
|
99
|
+
HttpApiEndpoint.post("fs.watch", "/api/experimental/fs/watch", {
|
|
100
|
+
query: LocationQuery,
|
|
101
|
+
payload: WatchPayload,
|
|
102
|
+
success: HttpApiSchema.NoContent,
|
|
103
|
+
error: [FileNotFoundError, ServiceUnavailableError],
|
|
104
|
+
})
|
|
105
|
+
.annotateMerge(locationQueryOpenApi)
|
|
106
|
+
.annotateMerge(
|
|
107
|
+
OpenApi.annotations({
|
|
108
|
+
identifier: "experimental.fs.watch",
|
|
109
|
+
summary: "Watch file",
|
|
110
|
+
description:
|
|
111
|
+
"Watch one file relative to the requested location for 24 hours, publishing filesystem.changed on that location when it changes. Watching an already watched file resets its expiry. Paths follow read confinement. Experimental: may change without compatibility guarantees.",
|
|
112
|
+
}),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
.add(
|
|
116
|
+
HttpApiEndpoint.delete("fs.unwatch", "/api/experimental/fs/watch", {
|
|
117
|
+
query: LocationQuery,
|
|
118
|
+
payload: WatchPayload,
|
|
119
|
+
success: HttpApiSchema.NoContent,
|
|
120
|
+
})
|
|
121
|
+
.annotateMerge(locationQueryOpenApi)
|
|
122
|
+
.annotateMerge(
|
|
123
|
+
OpenApi.annotations({
|
|
124
|
+
identifier: "experimental.fs.unwatch",
|
|
125
|
+
summary: "Unwatch file",
|
|
126
|
+
description:
|
|
127
|
+
"Stop watching one file relative to the requested location. Experimental: may change without compatibility guarantees.",
|
|
128
|
+
}),
|
|
129
|
+
),
|
|
130
|
+
)
|
|
131
|
+
.annotateMerge(
|
|
132
|
+
OpenApi.annotations({
|
|
133
|
+
title: "filesystem",
|
|
134
|
+
description: "Experimental location-scoped filesystem routes.",
|
|
135
|
+
}),
|
|
136
|
+
)
|
package/src/groups/generate.ts
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
import { Generate } from "@zyro-sec/schema/generate"
|
|
2
|
-
import { Model } from "@zyro-sec/schema/model"
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
-
import {
|
|
6
|
-
VideoNotFoundError,
|
|
7
|
-
InvalidRequestError,
|
|
8
|
-
LocationNotFoundError,
|
|
9
|
-
ModelNotFoundError,
|
|
10
|
-
ProviderNotFoundError,
|
|
11
|
-
ProviderRequestError,
|
|
12
|
-
ServiceUnavailableError,
|
|
13
|
-
UnsupportedModelError,
|
|
14
|
-
} from "../errors.js"
|
|
15
|
-
|
|
16
|
-
const errors = [
|
|
17
|
-
InvalidRequestError,
|
|
18
|
-
ProviderNotFoundError,
|
|
19
|
-
ModelNotFoundError,
|
|
20
|
-
UnsupportedModelError,
|
|
21
|
-
ProviderRequestError,
|
|
22
|
-
ServiceUnavailableError,
|
|
23
|
-
LocationNotFoundError,
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
const textContract = {
|
|
27
|
-
payload: Schema.Struct({
|
|
28
|
-
prompt: Schema.String,
|
|
29
|
-
model: Model.Ref.pipe(Schema.optional),
|
|
30
|
-
}),
|
|
31
|
-
success: Schema.Struct({
|
|
32
|
-
data: Schema.Struct({ text: Schema.String }),
|
|
33
|
-
}).annotate({ identifier: "GenerateTextResponse" }),
|
|
34
|
-
error: errors,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
38
|
-
.add(
|
|
39
|
-
HttpApiEndpoint.post("generate.text", "/api/experimental/generate/text", textContract).annotateMerge(
|
|
40
|
-
OpenApi.annotations({
|
|
41
|
-
identifier: "experimental.generate.text",
|
|
42
|
-
summary: "Generate text",
|
|
43
|
-
description:
|
|
44
|
-
"Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.",
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
47
|
-
)
|
|
48
|
-
// Kept so clients built before the move to /generate/text keep working; omitted from generated clients.
|
|
49
|
-
.add(
|
|
50
|
-
HttpApiEndpoint.post("generate.textLegacy", "/api/experimental/generate", textContract).annotateMerge(
|
|
51
|
-
OpenApi.annotations({
|
|
52
|
-
identifier: "experimental.generate.textLegacy",
|
|
53
|
-
summary: "Generate text (deprecated path)",
|
|
54
|
-
description: "Deprecated alias of POST /api/experimental/generate/text.",
|
|
55
|
-
deprecated: true,
|
|
56
|
-
}),
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
.add(
|
|
60
|
-
HttpApiEndpoint.post("generate.image", "/api/experimental/generate/image", {
|
|
61
|
-
payload: Generate.ImageRequest,
|
|
62
|
-
success: Schema.Struct({ data: Generate.ImageResult }).annotate({ identifier: "GenerateImageResponse" }),
|
|
63
|
-
error: errors,
|
|
64
|
-
}).annotateMerge(
|
|
65
|
-
OpenApi.annotations({
|
|
66
|
-
identifier: "experimental.generate.image",
|
|
67
|
-
summary: "Generate images",
|
|
68
|
-
description:
|
|
69
|
-
"Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.",
|
|
70
|
-
}),
|
|
71
|
-
),
|
|
72
|
-
)
|
|
73
|
-
.add(
|
|
74
|
-
HttpApiEndpoint.post("generate.video.create", "/api/experimental/generate/video", {
|
|
75
|
-
payload: Generate.VideoRequest,
|
|
76
|
-
success: Schema.Struct({ data: Generate.VideoRunning }).annotate({ identifier: "GenerateVideoCreateResponse" }),
|
|
77
|
-
error: errors,
|
|
78
|
-
}).annotateMerge(
|
|
79
|
-
OpenApi.annotations({
|
|
80
|
-
identifier: "experimental.generate.video.create",
|
|
81
|
-
summary: "Create a video generation",
|
|
82
|
-
description:
|
|
83
|
-
"Submit a video job to a video model using the server's base configuration and return its ID once the provider accepted it. The server polls the job and stores the finished videos as blobs; read the job with GET /api/experimental/generate/video/:id and the video with GET /api/experimental/blob/:id. Experimental: may change without compatibility guarantees.",
|
|
84
|
-
}),
|
|
85
|
-
),
|
|
86
|
-
)
|
|
87
|
-
.add(
|
|
88
|
-
HttpApiEndpoint.get("generate.video.get", "/api/experimental/generate/video/:id", {
|
|
89
|
-
params: { id: Generate.VideoID },
|
|
90
|
-
success: Schema.Struct({ data: Generate.VideoJob }).annotate({ identifier: "GenerateVideoGetResponse" }),
|
|
91
|
-
error: [VideoNotFoundError, LocationNotFoundError],
|
|
92
|
-
}).annotateMerge(
|
|
93
|
-
OpenApi.annotations({
|
|
94
|
-
identifier: "experimental.generate.video.get",
|
|
95
|
-
summary: "Read a video generation",
|
|
96
|
-
description:
|
|
97
|
-
"Read a video job: running, completed with its videos' blobs, or error with a reason. Jobs survive a server restart, which resumes polling running ones. A job is not found 24 hours after it finished, or once none of its blobs remain. Experimental: may change without compatibility guarantees.",
|
|
98
|
-
}),
|
|
99
|
-
),
|
|
100
|
-
)
|
|
101
|
-
.add(
|
|
102
|
-
HttpApiEndpoint.post("generate.decisions", "/api/experimental/generate/decisions", {
|
|
103
|
-
payload: Generate.DecisionRequest,
|
|
104
|
-
success: Schema.Struct({ data: Generate.DecisionResult }).annotate({ identifier: "GenerateDecisionsResponse" }),
|
|
105
|
-
error: errors,
|
|
106
|
-
}).annotateMerge(
|
|
107
|
-
OpenApi.annotations({
|
|
108
|
-
identifier: "experimental.generate.decisions",
|
|
109
|
-
summary: "Generate decisions",
|
|
110
|
-
description:
|
|
111
|
-
"Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.",
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
114
|
-
)
|
|
115
|
-
.annotateMerge(
|
|
116
|
-
OpenApi.annotations({
|
|
117
|
-
title: "generate",
|
|
118
|
-
description: "Experimental one-shot generation routes.",
|
|
119
|
-
}),
|
|
120
|
-
)
|
|
1
|
+
import { Generate } from "@zyro-sec/schema/generate"
|
|
2
|
+
import { Model } from "@zyro-sec/schema/model"
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api"
|
|
5
|
+
import {
|
|
6
|
+
VideoNotFoundError,
|
|
7
|
+
InvalidRequestError,
|
|
8
|
+
LocationNotFoundError,
|
|
9
|
+
ModelNotFoundError,
|
|
10
|
+
ProviderNotFoundError,
|
|
11
|
+
ProviderRequestError,
|
|
12
|
+
ServiceUnavailableError,
|
|
13
|
+
UnsupportedModelError,
|
|
14
|
+
} from "../errors.js"
|
|
15
|
+
|
|
16
|
+
const errors = [
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
ProviderNotFoundError,
|
|
19
|
+
ModelNotFoundError,
|
|
20
|
+
UnsupportedModelError,
|
|
21
|
+
ProviderRequestError,
|
|
22
|
+
ServiceUnavailableError,
|
|
23
|
+
LocationNotFoundError,
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const textContract = {
|
|
27
|
+
payload: Schema.Struct({
|
|
28
|
+
prompt: Schema.String,
|
|
29
|
+
model: Model.Ref.pipe(Schema.optional),
|
|
30
|
+
}),
|
|
31
|
+
success: Schema.Struct({
|
|
32
|
+
data: Schema.Struct({ text: Schema.String }),
|
|
33
|
+
}).annotate({ identifier: "GenerateTextResponse" }),
|
|
34
|
+
error: errors,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
38
|
+
.add(
|
|
39
|
+
HttpApiEndpoint.post("generate.text", "/api/experimental/generate/text", textContract).annotateMerge(
|
|
40
|
+
OpenApi.annotations({
|
|
41
|
+
identifier: "experimental.generate.text",
|
|
42
|
+
summary: "Generate text",
|
|
43
|
+
description:
|
|
44
|
+
"Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.",
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
// Kept so clients built before the move to /generate/text keep working; omitted from generated clients.
|
|
49
|
+
.add(
|
|
50
|
+
HttpApiEndpoint.post("generate.textLegacy", "/api/experimental/generate", textContract).annotateMerge(
|
|
51
|
+
OpenApi.annotations({
|
|
52
|
+
identifier: "experimental.generate.textLegacy",
|
|
53
|
+
summary: "Generate text (deprecated path)",
|
|
54
|
+
description: "Deprecated alias of POST /api/experimental/generate/text.",
|
|
55
|
+
deprecated: true,
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
.add(
|
|
60
|
+
HttpApiEndpoint.post("generate.image", "/api/experimental/generate/image", {
|
|
61
|
+
payload: Generate.ImageRequest,
|
|
62
|
+
success: Schema.Struct({ data: Generate.ImageResult }).annotate({ identifier: "GenerateImageResponse" }),
|
|
63
|
+
error: errors,
|
|
64
|
+
}).annotateMerge(
|
|
65
|
+
OpenApi.annotations({
|
|
66
|
+
identifier: "experimental.generate.image",
|
|
67
|
+
summary: "Generate images",
|
|
68
|
+
description:
|
|
69
|
+
"Generate or edit images with an image model using the server's base configuration and return them as base64. Stateless: nothing is stored.",
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
.add(
|
|
74
|
+
HttpApiEndpoint.post("generate.video.create", "/api/experimental/generate/video", {
|
|
75
|
+
payload: Generate.VideoRequest,
|
|
76
|
+
success: Schema.Struct({ data: Generate.VideoRunning }).annotate({ identifier: "GenerateVideoCreateResponse" }),
|
|
77
|
+
error: errors,
|
|
78
|
+
}).annotateMerge(
|
|
79
|
+
OpenApi.annotations({
|
|
80
|
+
identifier: "experimental.generate.video.create",
|
|
81
|
+
summary: "Create a video generation",
|
|
82
|
+
description:
|
|
83
|
+
"Submit a video job to a video model using the server's base configuration and return its ID once the provider accepted it. The server polls the job and stores the finished videos as blobs; read the job with GET /api/experimental/generate/video/:id and the video with GET /api/experimental/blob/:id. Experimental: may change without compatibility guarantees.",
|
|
84
|
+
}),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
.add(
|
|
88
|
+
HttpApiEndpoint.get("generate.video.get", "/api/experimental/generate/video/:id", {
|
|
89
|
+
params: { id: Generate.VideoID },
|
|
90
|
+
success: Schema.Struct({ data: Generate.VideoJob }).annotate({ identifier: "GenerateVideoGetResponse" }),
|
|
91
|
+
error: [VideoNotFoundError, LocationNotFoundError],
|
|
92
|
+
}).annotateMerge(
|
|
93
|
+
OpenApi.annotations({
|
|
94
|
+
identifier: "experimental.generate.video.get",
|
|
95
|
+
summary: "Read a video generation",
|
|
96
|
+
description:
|
|
97
|
+
"Read a video job: running, completed with its videos' blobs, or error with a reason. Jobs survive a server restart, which resumes polling running ones. A job is not found 24 hours after it finished, or once none of its blobs remain. Experimental: may change without compatibility guarantees.",
|
|
98
|
+
}),
|
|
99
|
+
),
|
|
100
|
+
)
|
|
101
|
+
.add(
|
|
102
|
+
HttpApiEndpoint.post("generate.decisions", "/api/experimental/generate/decisions", {
|
|
103
|
+
payload: Generate.DecisionRequest,
|
|
104
|
+
success: Schema.Struct({ data: Generate.DecisionResult }).annotate({ identifier: "GenerateDecisionsResponse" }),
|
|
105
|
+
error: errors,
|
|
106
|
+
}).annotateMerge(
|
|
107
|
+
OpenApi.annotations({
|
|
108
|
+
identifier: "experimental.generate.decisions",
|
|
109
|
+
summary: "Generate decisions",
|
|
110
|
+
description:
|
|
111
|
+
"Ask a decision model typed predicate, choice and score questions about the input and return one probability-bearing answer per question, in question order. Stateless: nothing is stored.",
|
|
112
|
+
}),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
.annotateMerge(
|
|
116
|
+
OpenApi.annotations({
|
|
117
|
+
title: "generate",
|
|
118
|
+
description: "Experimental one-shot generation routes.",
|
|
119
|
+
}),
|
|
120
|
+
)
|