@sealant/api-contracts-next 0.0.0-next.0 → 0.39.0-next.682

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.
Files changed (40) hide show
  1. package/LICENSE +202 -0
  2. package/dist/core-api/access-tokens.d.ts +126 -0
  3. package/dist/core-api/access-tokens.js +72 -0
  4. package/dist/core-api/budgets.d.ts +15 -0
  5. package/dist/core-api/budgets.js +13 -0
  6. package/dist/core-api/connected-accounts.d.ts +226 -0
  7. package/dist/core-api/connected-accounts.js +128 -0
  8. package/dist/core-api/control-plane.d.ts +1318 -0
  9. package/dist/core-api/control-plane.js +31 -0
  10. package/dist/core-api/github.d.ts +261 -0
  11. package/dist/core-api/github.js +153 -0
  12. package/dist/core-api/inference.d.ts +223 -0
  13. package/dist/core-api/inference.js +139 -0
  14. package/dist/core-api/oci-names.d.ts +21 -0
  15. package/dist/core-api/oci-names.js +44 -0
  16. package/dist/core-api/packages.d.ts +179 -0
  17. package/dist/core-api/packages.js +60 -0
  18. package/dist/core-api/profiles.d.ts +188 -0
  19. package/dist/core-api/profiles.js +88 -0
  20. package/dist/core-api/record-events.d.ts +209 -0
  21. package/dist/core-api/record-events.js +193 -0
  22. package/dist/core-api/registries.d.ts +106 -0
  23. package/dist/core-api/registries.js +85 -0
  24. package/dist/core-api/runs.d.ts +516 -0
  25. package/dist/core-api/runs.js +284 -0
  26. package/dist/core-api/sessions.d.ts +390 -0
  27. package/dist/core-api/sessions.js +264 -0
  28. package/dist/core-api/ssh-keys.d.ts +120 -0
  29. package/dist/core-api/ssh-keys.js +108 -0
  30. package/dist/core-api/system.d.ts +51 -0
  31. package/dist/core-api/system.js +41 -0
  32. package/dist/core-api/users.d.ts +71 -0
  33. package/dist/core-api/users.js +48 -0
  34. package/dist/core-api/workspaces.d.ts +1880 -0
  35. package/dist/core-api/workspaces.js +980 -0
  36. package/dist/index.d.ts +18 -0
  37. package/dist/index.js +18 -0
  38. package/dist/workspace-environment.d.ts +124 -0
  39. package/dist/workspace-environment.js +259 -0
  40. package/package.json +31 -9
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Inference on connected accounts — run short, tool-calling inference loops on the caller's OWN
3
+ * subscription (their connected Claude or Codex account), server-side, WITHOUT the caller ever
4
+ * seeing secret material.
5
+ *
6
+ * COMPLIANCE (docs/connected-accounts-design.md, load-bearing): stored subscription credentials are
7
+ * NEVER used for raw model-API calls. The server resolves the account reference, decrypts, and
8
+ * invokes the OFFICIAL runtime for the account's provider — the Claude Agent SDK for claude
9
+ * accounts, the Codex CLI (against a private per-invocation CODEX_HOME) for codex accounts — the
10
+ * exact consumption paths the vendors document for third-party apps. Requests carry account
11
+ * REFERENCES only; responses carry assistant turns only; token material never crosses this surface
12
+ * in either direction.
13
+ *
14
+ * The tool loop is CALLER-EXECUTED: the request may define JSON-schema tools; when the model calls
15
+ * one, the server parks the run and responds with the pending `toolCalls` turn + a `sessionId`; the
16
+ * caller executes the tools on ITS side and posts the results back with that `sessionId`, repeating
17
+ * until a `text` turn arrives. Sessions are held in memory by the serving process and expire after
18
+ * a few idle minutes — callers must handle `InferenceNotFoundError` on a continuation by starting
19
+ * the exchange over. Caller-defined tools are claude-only today: a codex exchange settles in one
20
+ * turn, and sending `tools` with a codex account is a 400.
21
+ */
22
+ import { Schema } from "effect";
23
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
24
+ import { BudgetExceededError } from "./budgets.js";
25
+ /**
26
+ * Connected-account selection — the same reference shape as workspace creation: values are account
27
+ * ids (`cacc_…`) or per-provider account names; explicit entries win over the profile's bindings.
28
+ * Selecting both `claude` and `codex` in one exchange is ambiguous (400). A profileId-only
29
+ * selection prefers the profile's claude binding and falls back to its codex binding.
30
+ */
31
+ export declare const inferenceCredentialsSchema: Schema.Struct<{
32
+ readonly profileId: Schema.optional<Schema.String>;
33
+ readonly claude: Schema.optional<Schema.String>;
34
+ readonly codex: Schema.optional<Schema.String>;
35
+ }>;
36
+ export type InferenceCredentials = typeof inferenceCredentialsSchema.Type;
37
+ /** A caller-defined tool. `inputSchema` is a JSON Schema object, passed to the model verbatim. */
38
+ export declare const inferenceToolSchema: Schema.Struct<{
39
+ readonly name: Schema.String;
40
+ readonly description: Schema.optional<Schema.String>;
41
+ readonly inputSchema: Schema.Unknown;
42
+ }>;
43
+ export type InferenceTool = typeof inferenceToolSchema.Type;
44
+ /** The caller's result for one parked tool call, keyed by the server-minted `toolCallId`. */
45
+ export declare const inferenceToolResultSchema: Schema.Struct<{
46
+ readonly toolCallId: Schema.String;
47
+ readonly content: Schema.String;
48
+ readonly isError: Schema.optional<Schema.Boolean>;
49
+ }>;
50
+ export type InferenceToolResult = typeof inferenceToolResultSchema.Type;
51
+ /**
52
+ * One respond call, in one of two shapes:
53
+ *
54
+ * - NEW exchange: `credentials` + `prompt` (plus optional `system`/`model`/`tools`/
55
+ * `responseFormat`/`maxTurns`). `sessionId`/`toolResults` must be absent.
56
+ * - CONTINUATION: `sessionId` + `toolResults` for the previous turn's tool calls. The session was
57
+ * authenticated when it started; credential fields must be absent.
58
+ */
59
+ export declare const inferenceRespondRequestSchema: Schema.Struct<{
60
+ readonly ownerUserId: Schema.String;
61
+ readonly credentials: Schema.optional<Schema.Struct<{
62
+ readonly profileId: Schema.optional<Schema.String>;
63
+ readonly claude: Schema.optional<Schema.String>;
64
+ readonly codex: Schema.optional<Schema.String>;
65
+ }>>;
66
+ readonly prompt: Schema.optional<Schema.String>;
67
+ readonly system: Schema.optional<Schema.String>;
68
+ /** Model override passed to the official runtime verbatim (defaults to the runtime's default). */
69
+ readonly model: Schema.optional<Schema.String>;
70
+ /** Upper bound on agentic turns within one exchange (default 16). Claude-only; ignored by codex. */
71
+ readonly maxTurns: Schema.optional<Schema.Number>;
72
+ readonly tools: Schema.optional<Schema.$Array<Schema.Struct<{
73
+ readonly name: Schema.String;
74
+ readonly description: Schema.optional<Schema.String>;
75
+ readonly inputSchema: Schema.Unknown;
76
+ }>>>;
77
+ /**
78
+ * Structured-output option: instructs the model to answer as JSON (conforming to `schema` when
79
+ * given) and parses the final text; the parsed value arrives as the text turn's `json` field.
80
+ * Best-effort — when the text does not parse, `json` is absent and `text` still carries the raw
81
+ * answer.
82
+ */
83
+ readonly responseFormat: Schema.optional<Schema.Struct<{
84
+ readonly type: Schema.Literal<"json">;
85
+ readonly schema: Schema.optional<Schema.Unknown>;
86
+ }>>;
87
+ readonly sessionId: Schema.optional<Schema.String>;
88
+ readonly toolResults: Schema.optional<Schema.$Array<Schema.Struct<{
89
+ readonly toolCallId: Schema.String;
90
+ readonly content: Schema.String;
91
+ readonly isError: Schema.optional<Schema.Boolean>;
92
+ }>>>;
93
+ }>;
94
+ export type InferenceRespondRequest = typeof inferenceRespondRequestSchema.Type;
95
+ /** A tool call the model made; the caller executes it and posts the result back. */
96
+ export declare const inferenceToolCallSchema: Schema.Struct<{
97
+ readonly toolCallId: Schema.String;
98
+ readonly name: Schema.String;
99
+ readonly input: Schema.Unknown;
100
+ }>;
101
+ export type InferenceToolCall = typeof inferenceToolCallSchema.Type;
102
+ /** The assistant turn: either the final text (with optional parsed `json`) or pending tool calls. */
103
+ export declare const inferenceTurnSchema: Schema.Union<readonly [Schema.Struct<{
104
+ readonly type: Schema.Literal<"text">;
105
+ readonly text: Schema.String;
106
+ readonly json: Schema.optional<Schema.Unknown>;
107
+ }>, Schema.Struct<{
108
+ readonly type: Schema.Literal<"toolCalls">;
109
+ readonly calls: Schema.$Array<Schema.Struct<{
110
+ readonly toolCallId: Schema.String;
111
+ readonly name: Schema.String;
112
+ readonly input: Schema.Unknown;
113
+ }>>;
114
+ }>]>;
115
+ export type InferenceTurn = typeof inferenceTurnSchema.Type;
116
+ export declare const inferenceUsageSchema: Schema.Struct<{
117
+ readonly inputTokens: Schema.Number;
118
+ readonly outputTokens: Schema.Number;
119
+ }>;
120
+ export type InferenceUsage = typeof inferenceUsageSchema.Type;
121
+ export declare const inferenceRespondResponseSchema: Schema.Struct<{
122
+ readonly sessionId: Schema.String;
123
+ readonly turn: Schema.Union<readonly [Schema.Struct<{
124
+ readonly type: Schema.Literal<"text">;
125
+ readonly text: Schema.String;
126
+ readonly json: Schema.optional<Schema.Unknown>;
127
+ }>, Schema.Struct<{
128
+ readonly type: Schema.Literal<"toolCalls">;
129
+ readonly calls: Schema.$Array<Schema.Struct<{
130
+ readonly toolCallId: Schema.String;
131
+ readonly name: Schema.String;
132
+ readonly input: Schema.Unknown;
133
+ }>>;
134
+ }>]>;
135
+ /** Usage for the exchange so far; present on the final (text) turn. */
136
+ readonly usage: Schema.optional<Schema.Struct<{
137
+ readonly inputTokens: Schema.Number;
138
+ readonly outputTokens: Schema.Number;
139
+ }>>;
140
+ }>;
141
+ export type InferenceRespondResponse = typeof inferenceRespondResponseSchema.Type;
142
+ declare const InferenceBadRequestError_base: Schema.Class<InferenceBadRequestError, Schema.TaggedStruct<"InferenceBadRequestError", {
143
+ readonly message: Schema.String;
144
+ }>, import("effect/Cause").YieldableError>;
145
+ export declare class InferenceBadRequestError extends InferenceBadRequestError_base {
146
+ }
147
+ declare const InferenceNotFoundError_base: Schema.Class<InferenceNotFoundError, Schema.TaggedStruct<"InferenceNotFoundError", {
148
+ readonly message: Schema.String;
149
+ }>, import("effect/Cause").YieldableError>;
150
+ /** Unknown account/profile (uniform for foreign owners) or an expired/unknown inference session. */
151
+ export declare class InferenceNotFoundError extends InferenceNotFoundError_base {
152
+ }
153
+ declare const InferenceConflictError_base: Schema.Class<InferenceConflictError, Schema.TaggedStruct<"InferenceConflictError", {
154
+ readonly message: Schema.String;
155
+ }>, import("effect/Cause").YieldableError>;
156
+ /** The selected account exists but is not usable (status "invalid") — reconnect it. */
157
+ export declare class InferenceConflictError extends InferenceConflictError_base {
158
+ }
159
+ declare const InferenceUnavailableError_base: Schema.Class<InferenceUnavailableError, Schema.TaggedStruct<"InferenceUnavailableError", {
160
+ readonly message: Schema.String;
161
+ }>, import("effect/Cause").YieldableError>;
162
+ export declare class InferenceUnavailableError extends InferenceUnavailableError_base {
163
+ }
164
+ declare const InferenceInternalServerError_base: Schema.Class<InferenceInternalServerError, Schema.TaggedStruct<"InferenceInternalServerError", {
165
+ readonly message: Schema.String;
166
+ }>, import("effect/Cause").YieldableError>;
167
+ export declare class InferenceInternalServerError extends InferenceInternalServerError_base {
168
+ }
169
+ export declare const InferenceGroup: HttpApiGroup.HttpApiGroup<"inference", HttpApiEndpoint.HttpApiEndpoint<"respond", "POST", "/respond", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
170
+ readonly ownerUserId: Schema.String;
171
+ readonly credentials: Schema.optional<Schema.Struct<{
172
+ readonly profileId: Schema.optional<Schema.String>;
173
+ readonly claude: Schema.optional<Schema.String>;
174
+ readonly codex: Schema.optional<Schema.String>;
175
+ }>>;
176
+ readonly prompt: Schema.optional<Schema.String>;
177
+ readonly system: Schema.optional<Schema.String>;
178
+ /** Model override passed to the official runtime verbatim (defaults to the runtime's default). */
179
+ readonly model: Schema.optional<Schema.String>;
180
+ /** Upper bound on agentic turns within one exchange (default 16). Claude-only; ignored by codex. */
181
+ readonly maxTurns: Schema.optional<Schema.Number>;
182
+ readonly tools: Schema.optional<Schema.$Array<Schema.Struct<{
183
+ readonly name: Schema.String;
184
+ readonly description: Schema.optional<Schema.String>;
185
+ readonly inputSchema: Schema.Unknown;
186
+ }>>>;
187
+ /**
188
+ * Structured-output option: instructs the model to answer as JSON (conforming to `schema` when
189
+ * given) and parses the final text; the parsed value arrives as the text turn's `json` field.
190
+ * Best-effort — when the text does not parse, `json` is absent and `text` still carries the raw
191
+ * answer.
192
+ */
193
+ readonly responseFormat: Schema.optional<Schema.Struct<{
194
+ readonly type: Schema.Literal<"json">;
195
+ readonly schema: Schema.optional<Schema.Unknown>;
196
+ }>>;
197
+ readonly sessionId: Schema.optional<Schema.String>;
198
+ readonly toolResults: Schema.optional<Schema.$Array<Schema.Struct<{
199
+ readonly toolCallId: Schema.String;
200
+ readonly content: Schema.String;
201
+ readonly isError: Schema.optional<Schema.Boolean>;
202
+ }>>>;
203
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
204
+ readonly sessionId: Schema.String;
205
+ readonly turn: Schema.Union<readonly [Schema.Struct<{
206
+ readonly type: Schema.Literal<"text">;
207
+ readonly text: Schema.String;
208
+ readonly json: Schema.optional<Schema.Unknown>;
209
+ }>, Schema.Struct<{
210
+ readonly type: Schema.Literal<"toolCalls">;
211
+ readonly calls: Schema.$Array<Schema.Struct<{
212
+ readonly toolCallId: Schema.String;
213
+ readonly name: Schema.String;
214
+ readonly input: Schema.Unknown;
215
+ }>>;
216
+ }>]>;
217
+ /** Usage for the exchange so far; present on the final (text) turn. */
218
+ readonly usage: Schema.optional<Schema.Struct<{
219
+ readonly inputTokens: Schema.Number;
220
+ readonly outputTokens: Schema.Number;
221
+ }>>;
222
+ }>>, HttpApiEndpoint.Json<typeof BudgetExceededError | typeof InferenceBadRequestError | typeof InferenceNotFoundError | typeof InferenceConflictError | typeof InferenceUnavailableError | typeof InferenceInternalServerError>, never, never>, false>;
223
+ export {};
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Inference on connected accounts — run short, tool-calling inference loops on the caller's OWN
3
+ * subscription (their connected Claude or Codex account), server-side, WITHOUT the caller ever
4
+ * seeing secret material.
5
+ *
6
+ * COMPLIANCE (docs/connected-accounts-design.md, load-bearing): stored subscription credentials are
7
+ * NEVER used for raw model-API calls. The server resolves the account reference, decrypts, and
8
+ * invokes the OFFICIAL runtime for the account's provider — the Claude Agent SDK for claude
9
+ * accounts, the Codex CLI (against a private per-invocation CODEX_HOME) for codex accounts — the
10
+ * exact consumption paths the vendors document for third-party apps. Requests carry account
11
+ * REFERENCES only; responses carry assistant turns only; token material never crosses this surface
12
+ * in either direction.
13
+ *
14
+ * The tool loop is CALLER-EXECUTED: the request may define JSON-schema tools; when the model calls
15
+ * one, the server parks the run and responds with the pending `toolCalls` turn + a `sessionId`; the
16
+ * caller executes the tools on ITS side and posts the results back with that `sessionId`, repeating
17
+ * until a `text` turn arrives. Sessions are held in memory by the serving process and expire after
18
+ * a few idle minutes — callers must handle `InferenceNotFoundError` on a continuation by starting
19
+ * the exchange over. Caller-defined tools are claude-only today: a codex exchange settles in one
20
+ * turn, and sending `tools` with a codex account is a 400.
21
+ */
22
+ import { Schema } from "effect";
23
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
24
+ import { BudgetExceededError } from "./budgets.js";
25
+ const NonEmptyString = Schema.String.check(Schema.isNonEmpty(), Schema.isTrimmed());
26
+ /**
27
+ * Connected-account selection — the same reference shape as workspace creation: values are account
28
+ * ids (`cacc_…`) or per-provider account names; explicit entries win over the profile's bindings.
29
+ * Selecting both `claude` and `codex` in one exchange is ambiguous (400). A profileId-only
30
+ * selection prefers the profile's claude binding and falls back to its codex binding.
31
+ */
32
+ export const inferenceCredentialsSchema = Schema.Struct({
33
+ profileId: Schema.optional(NonEmptyString),
34
+ claude: Schema.optional(NonEmptyString),
35
+ codex: Schema.optional(NonEmptyString),
36
+ });
37
+ /** A caller-defined tool. `inputSchema` is a JSON Schema object, passed to the model verbatim. */
38
+ export const inferenceToolSchema = Schema.Struct({
39
+ name: NonEmptyString,
40
+ description: Schema.optional(Schema.String),
41
+ inputSchema: Schema.Unknown,
42
+ });
43
+ /** The caller's result for one parked tool call, keyed by the server-minted `toolCallId`. */
44
+ export const inferenceToolResultSchema = Schema.Struct({
45
+ toolCallId: NonEmptyString,
46
+ content: Schema.String,
47
+ isError: Schema.optional(Schema.Boolean),
48
+ });
49
+ /**
50
+ * One respond call, in one of two shapes:
51
+ *
52
+ * - NEW exchange: `credentials` + `prompt` (plus optional `system`/`model`/`tools`/
53
+ * `responseFormat`/`maxTurns`). `sessionId`/`toolResults` must be absent.
54
+ * - CONTINUATION: `sessionId` + `toolResults` for the previous turn's tool calls. The session was
55
+ * authenticated when it started; credential fields must be absent.
56
+ */
57
+ export const inferenceRespondRequestSchema = Schema.Struct({
58
+ ownerUserId: NonEmptyString,
59
+ credentials: Schema.optional(inferenceCredentialsSchema),
60
+ prompt: Schema.optional(Schema.String.check(Schema.isNonEmpty())),
61
+ system: Schema.optional(Schema.String),
62
+ /** Model override passed to the official runtime verbatim (defaults to the runtime's default). */
63
+ model: Schema.optional(NonEmptyString),
64
+ /** Upper bound on agentic turns within one exchange (default 16). Claude-only; ignored by codex. */
65
+ maxTurns: Schema.optional(Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 64 }))),
66
+ tools: Schema.optional(Schema.Array(inferenceToolSchema).check(Schema.isMaxLength(32))),
67
+ /**
68
+ * Structured-output option: instructs the model to answer as JSON (conforming to `schema` when
69
+ * given) and parses the final text; the parsed value arrives as the text turn's `json` field.
70
+ * Best-effort — when the text does not parse, `json` is absent and `text` still carries the raw
71
+ * answer.
72
+ */
73
+ responseFormat: Schema.optional(Schema.Struct({
74
+ type: Schema.Literal("json"),
75
+ schema: Schema.optional(Schema.Unknown),
76
+ })),
77
+ sessionId: Schema.optional(NonEmptyString),
78
+ toolResults: Schema.optional(Schema.Array(inferenceToolResultSchema).check(Schema.isNonEmpty())),
79
+ });
80
+ /** A tool call the model made; the caller executes it and posts the result back. */
81
+ export const inferenceToolCallSchema = Schema.Struct({
82
+ toolCallId: NonEmptyString,
83
+ name: NonEmptyString,
84
+ input: Schema.Unknown,
85
+ });
86
+ /** The assistant turn: either the final text (with optional parsed `json`) or pending tool calls. */
87
+ export const inferenceTurnSchema = Schema.Union([
88
+ Schema.Struct({
89
+ type: Schema.Literal("text"),
90
+ text: Schema.String,
91
+ json: Schema.optional(Schema.Unknown),
92
+ }),
93
+ Schema.Struct({
94
+ type: Schema.Literal("toolCalls"),
95
+ calls: Schema.Array(inferenceToolCallSchema),
96
+ }),
97
+ ]);
98
+ export const inferenceUsageSchema = Schema.Struct({
99
+ inputTokens: Schema.Number,
100
+ outputTokens: Schema.Number,
101
+ });
102
+ export const inferenceRespondResponseSchema = Schema.Struct({
103
+ sessionId: NonEmptyString,
104
+ turn: inferenceTurnSchema,
105
+ /** Usage for the exchange so far; present on the final (text) turn. */
106
+ usage: Schema.optional(inferenceUsageSchema),
107
+ });
108
+ // ---------------------------------------------------------------------------------------------
109
+ // Errors
110
+ // ---------------------------------------------------------------------------------------------
111
+ export class InferenceBadRequestError extends Schema.TaggedErrorClass()("InferenceBadRequestError", { message: Schema.String }, { httpApiStatus: 400 }) {
112
+ }
113
+ /** Unknown account/profile (uniform for foreign owners) or an expired/unknown inference session. */
114
+ export class InferenceNotFoundError extends Schema.TaggedErrorClass()("InferenceNotFoundError", { message: Schema.String }, { httpApiStatus: 404 }) {
115
+ }
116
+ /** The selected account exists but is not usable (status "invalid") — reconnect it. */
117
+ export class InferenceConflictError extends Schema.TaggedErrorClass()("InferenceConflictError", { message: Schema.String }, { httpApiStatus: 409 }) {
118
+ }
119
+ export class InferenceUnavailableError extends Schema.TaggedErrorClass()("InferenceUnavailableError", { message: Schema.String }, { httpApiStatus: 503 }) {
120
+ }
121
+ export class InferenceInternalServerError extends Schema.TaggedErrorClass()("InferenceInternalServerError", { message: Schema.String }, { httpApiStatus: 500 }) {
122
+ }
123
+ // ---------------------------------------------------------------------------------------------
124
+ // Group
125
+ // ---------------------------------------------------------------------------------------------
126
+ export const InferenceGroup = HttpApiGroup.make("inference")
127
+ .add(HttpApiEndpoint.post("respond", "/respond", {
128
+ payload: inferenceRespondRequestSchema,
129
+ success: inferenceRespondResponseSchema.pipe(HttpApiSchema.status(200)),
130
+ error: [
131
+ BudgetExceededError,
132
+ InferenceBadRequestError,
133
+ InferenceNotFoundError,
134
+ InferenceConflictError,
135
+ InferenceUnavailableError,
136
+ InferenceInternalServerError,
137
+ ],
138
+ }))
139
+ .annotate(OpenApi.Description, "Inference on connected accounts, via the official agent SDKs — never raw model-API calls.");
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Canonical OCI names (distribution-spec "Pulling manifests"). A repository or reference that does
3
+ * not match is refused, never repaired: these values become URL path segments and `docker`
4
+ * arguments, and anything the grammar does not admit (`..`, `%2e`, `?`, `#`, a scheme, a
5
+ * backslash, whitespace, an empty segment) is a way to address something else.
6
+ */
7
+ export declare const isOciRepository: (value: string) => boolean;
8
+ export declare const isOciTag: (value: string) => boolean;
9
+ export declare const isOciDigest: (value: string) => boolean;
10
+ /** A manifest reference is a tag or a digest. */
11
+ export declare const isOciReference: (value: string) => boolean;
12
+ /**
13
+ * One path component of a repository name, made from arbitrary text (a Git repository's name, an
14
+ * OS family). This is for names Sealant GENERATES; a name a caller supplies is refused, not
15
+ * rewritten. A lone `.` or `_` between alphanumerics survives, every other run of characters the
16
+ * grammar does not admit becomes one `-`, and the edges are trimmed again after the cut so a
17
+ * separator can never end the component.
18
+ */
19
+ export declare const toOciRepositoryComponent: (value: string, fallback: string, maxLength?: number) => string;
20
+ export declare const OCI_REPOSITORY_MESSAGE = "must be an OCI repository name: lowercase path components of [a-z0-9] joined by '.', '_', '__' or '-', separated by '/'";
21
+ export declare const OCI_REFERENCE_MESSAGE = "must be an OCI tag ([A-Za-z0-9_][A-Za-z0-9._-]{0,127}) or a digest (algorithm:encoded)";
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Canonical OCI names (distribution-spec "Pulling manifests"). A repository or reference that does
3
+ * not match is refused, never repaired: these values become URL path segments and `docker`
4
+ * arguments, and anything the grammar does not admit (`..`, `%2e`, `?`, `#`, a scheme, a
5
+ * backslash, whitespace, an empty segment) is a way to address something else.
6
+ */
7
+ /** `<name>` : lowercase path components separated by `/`, each `[a-z0-9]+` joined by `.`, `_`, `__` or `-`s. */
8
+ const REPOSITORY_COMPONENT = "[a-z0-9]+(?:(?:\\.|_|__|-+)[a-z0-9]+)*";
9
+ const REPOSITORY = new RegExp(`^${REPOSITORY_COMPONENT}(?:/${REPOSITORY_COMPONENT})*$`);
10
+ const REPOSITORY_MAX_LENGTH = 255;
11
+ /** `<tag>`: at most 128 of `[A-Za-z0-9_.-]`, not starting with `.` or `-`. */
12
+ const TAG = /^[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$/;
13
+ /** `<digest>`: `algorithm:encoded`; the registered algorithms are checked for their exact length. */
14
+ const DIGEST = /^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[A-Za-z0-9=_-]+$/;
15
+ const DIGEST_MAX_LENGTH = 512;
16
+ const REGISTERED_DIGEST_LENGTHS = { sha256: 64, sha512: 128 };
17
+ export const isOciRepository = (value) => value.length <= REPOSITORY_MAX_LENGTH && REPOSITORY.test(value);
18
+ export const isOciTag = (value) => TAG.test(value);
19
+ export const isOciDigest = (value) => {
20
+ if (value.length > DIGEST_MAX_LENGTH || !DIGEST.test(value))
21
+ return false;
22
+ const separator = value.indexOf(":");
23
+ const expected = REGISTERED_DIGEST_LENGTHS[value.slice(0, separator)];
24
+ if (expected === undefined)
25
+ return true;
26
+ const encoded = value.slice(separator + 1);
27
+ return encoded.length === expected && /^[a-f0-9]+$/.test(encoded);
28
+ };
29
+ /** A manifest reference is a tag or a digest. */
30
+ export const isOciReference = (value) => isOciDigest(value) || isOciTag(value);
31
+ const trimEdges = (text) => text.replace(/^[._-]+|[._-]+$/g, "");
32
+ /**
33
+ * One path component of a repository name, made from arbitrary text (a Git repository's name, an
34
+ * OS family). This is for names Sealant GENERATES; a name a caller supplies is refused, not
35
+ * rewritten. A lone `.` or `_` between alphanumerics survives, every other run of characters the
36
+ * grammar does not admit becomes one `-`, and the edges are trimmed again after the cut so a
37
+ * separator can never end the component.
38
+ */
39
+ export const toOciRepositoryComponent = (value, fallback, maxLength = 48) => {
40
+ const component = trimEdges(trimEdges(value.toLowerCase().replace(/[^a-z0-9]+/g, (run) => (run === "." || run === "_" ? run : "-"))).slice(0, maxLength));
41
+ return component.length > 0 ? component : fallback;
42
+ };
43
+ export const OCI_REPOSITORY_MESSAGE = "must be an OCI repository name: lowercase path components of [a-z0-9] joined by '.', '_', '__' or '-', separated by '/'";
44
+ export const OCI_REFERENCE_MESSAGE = "must be an OCI tag ([A-Za-z0-9_][A-Za-z0-9._-]{0,127}) or a digest (algorithm:encoded)";
@@ -0,0 +1,179 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
3
+ export declare const packageTargetOsSchema: Schema.Literals<readonly ["arch", "fedora", "nix", "ubuntu"]>;
4
+ export type PackageTargetOs = typeof packageTargetOsSchema.Type;
5
+ export declare const packageResolutionStatusSchema: Schema.Literals<readonly ["resolved", "ambiguous", "unsupported", "not-found", "invalid"]>;
6
+ export declare const packageResolutionSourceSchema: Schema.Literals<readonly ["cache", "repology", "override"]>;
7
+ export declare const packageOsSupportSchema: Schema.Struct<{
8
+ readonly supported: Schema.Boolean;
9
+ readonly repo: Schema.optional<Schema.String>;
10
+ readonly packageName: Schema.optional<Schema.String>;
11
+ readonly projectName: Schema.optional<Schema.String>;
12
+ readonly version: Schema.optional<Schema.String>;
13
+ readonly status: Schema.optional<Schema.String>;
14
+ }>;
15
+ export declare const packageResolutionAlternativeSchema: Schema.Struct<{
16
+ readonly projectName: Schema.String;
17
+ }>;
18
+ export declare const packageResolutionSchema: Schema.Struct<{
19
+ readonly requested: Schema.String;
20
+ readonly normalized: Schema.String;
21
+ readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "unsupported", "not-found", "invalid"]>;
22
+ readonly source: Schema.Literals<readonly ["cache", "repology", "override"]>;
23
+ readonly canonicalId: Schema.optional<Schema.String>;
24
+ readonly selectedProject: Schema.optional<Schema.String>;
25
+ readonly osSupport: Schema.Struct<{
26
+ readonly arch: Schema.Struct<{
27
+ readonly supported: Schema.Boolean;
28
+ readonly repo: Schema.optional<Schema.String>;
29
+ readonly packageName: Schema.optional<Schema.String>;
30
+ readonly projectName: Schema.optional<Schema.String>;
31
+ readonly version: Schema.optional<Schema.String>;
32
+ readonly status: Schema.optional<Schema.String>;
33
+ }>;
34
+ readonly fedora: Schema.Struct<{
35
+ readonly supported: Schema.Boolean;
36
+ readonly repo: Schema.optional<Schema.String>;
37
+ readonly packageName: Schema.optional<Schema.String>;
38
+ readonly projectName: Schema.optional<Schema.String>;
39
+ readonly version: Schema.optional<Schema.String>;
40
+ readonly status: Schema.optional<Schema.String>;
41
+ }>;
42
+ readonly nix: Schema.Struct<{
43
+ readonly supported: Schema.Boolean;
44
+ readonly repo: Schema.optional<Schema.String>;
45
+ readonly packageName: Schema.optional<Schema.String>;
46
+ readonly projectName: Schema.optional<Schema.String>;
47
+ readonly version: Schema.optional<Schema.String>;
48
+ readonly status: Schema.optional<Schema.String>;
49
+ }>;
50
+ readonly ubuntu: Schema.Struct<{
51
+ readonly supported: Schema.Boolean;
52
+ readonly repo: Schema.optional<Schema.String>;
53
+ readonly packageName: Schema.optional<Schema.String>;
54
+ readonly projectName: Schema.optional<Schema.String>;
55
+ readonly version: Schema.optional<Schema.String>;
56
+ readonly status: Schema.optional<Schema.String>;
57
+ }>;
58
+ }>;
59
+ readonly alternatives: Schema.$Array<Schema.Struct<{
60
+ readonly projectName: Schema.String;
61
+ }>>;
62
+ readonly fetchedAt: Schema.String;
63
+ readonly expiresAt: Schema.String;
64
+ }>;
65
+ export type PackageResolution = typeof packageResolutionSchema.Type;
66
+ export declare const resolvePackageQuerySchema: Schema.Struct<{
67
+ readonly query: Schema.String;
68
+ readonly targetOs: Schema.optional<Schema.Literals<readonly ["arch", "fedora", "nix", "ubuntu"]>>;
69
+ }>;
70
+ export type ResolvePackageQuery = typeof resolvePackageQuerySchema.Type;
71
+ export declare const resolvePackageResponseSchema: Schema.Struct<{
72
+ readonly requested: Schema.String;
73
+ readonly normalized: Schema.String;
74
+ readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "unsupported", "not-found", "invalid"]>;
75
+ readonly source: Schema.Literals<readonly ["cache", "repology", "override"]>;
76
+ readonly canonicalId: Schema.optional<Schema.String>;
77
+ readonly selectedProject: Schema.optional<Schema.String>;
78
+ readonly osSupport: Schema.Struct<{
79
+ readonly arch: Schema.Struct<{
80
+ readonly supported: Schema.Boolean;
81
+ readonly repo: Schema.optional<Schema.String>;
82
+ readonly packageName: Schema.optional<Schema.String>;
83
+ readonly projectName: Schema.optional<Schema.String>;
84
+ readonly version: Schema.optional<Schema.String>;
85
+ readonly status: Schema.optional<Schema.String>;
86
+ }>;
87
+ readonly fedora: Schema.Struct<{
88
+ readonly supported: Schema.Boolean;
89
+ readonly repo: Schema.optional<Schema.String>;
90
+ readonly packageName: Schema.optional<Schema.String>;
91
+ readonly projectName: Schema.optional<Schema.String>;
92
+ readonly version: Schema.optional<Schema.String>;
93
+ readonly status: Schema.optional<Schema.String>;
94
+ }>;
95
+ readonly nix: Schema.Struct<{
96
+ readonly supported: Schema.Boolean;
97
+ readonly repo: Schema.optional<Schema.String>;
98
+ readonly packageName: Schema.optional<Schema.String>;
99
+ readonly projectName: Schema.optional<Schema.String>;
100
+ readonly version: Schema.optional<Schema.String>;
101
+ readonly status: Schema.optional<Schema.String>;
102
+ }>;
103
+ readonly ubuntu: Schema.Struct<{
104
+ readonly supported: Schema.Boolean;
105
+ readonly repo: Schema.optional<Schema.String>;
106
+ readonly packageName: Schema.optional<Schema.String>;
107
+ readonly projectName: Schema.optional<Schema.String>;
108
+ readonly version: Schema.optional<Schema.String>;
109
+ readonly status: Schema.optional<Schema.String>;
110
+ }>;
111
+ }>;
112
+ readonly alternatives: Schema.$Array<Schema.Struct<{
113
+ readonly projectName: Schema.String;
114
+ }>>;
115
+ readonly fetchedAt: Schema.String;
116
+ readonly expiresAt: Schema.String;
117
+ }>;
118
+ export type ResolvePackageResponse = typeof resolvePackageResponseSchema.Type;
119
+ declare const PackagesBadGatewayError_base: Schema.Class<PackagesBadGatewayError, Schema.TaggedStruct<"PackagesBadGatewayError", {
120
+ readonly message: Schema.String;
121
+ }>, import("effect/Cause").YieldableError>;
122
+ export declare class PackagesBadGatewayError extends PackagesBadGatewayError_base {
123
+ }
124
+ declare const PackagesInternalServerError_base: Schema.Class<PackagesInternalServerError, Schema.TaggedStruct<"PackagesInternalServerError", {
125
+ readonly message: Schema.String;
126
+ }>, import("effect/Cause").YieldableError>;
127
+ export declare class PackagesInternalServerError extends PackagesInternalServerError_base {
128
+ }
129
+ export declare const PackagesGroup: HttpApiGroup.HttpApiGroup<"packages", HttpApiEndpoint.HttpApiEndpoint<"resolvePackage", "GET", "/resolve", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
130
+ readonly query: Schema.String;
131
+ readonly targetOs: Schema.optional<Schema.Literals<readonly ["arch", "fedora", "nix", "ubuntu"]>>;
132
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
133
+ readonly requested: Schema.String;
134
+ readonly normalized: Schema.String;
135
+ readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "unsupported", "not-found", "invalid"]>;
136
+ readonly source: Schema.Literals<readonly ["cache", "repology", "override"]>;
137
+ readonly canonicalId: Schema.optional<Schema.String>;
138
+ readonly selectedProject: Schema.optional<Schema.String>;
139
+ readonly osSupport: Schema.Struct<{
140
+ readonly arch: Schema.Struct<{
141
+ readonly supported: Schema.Boolean;
142
+ readonly repo: Schema.optional<Schema.String>;
143
+ readonly packageName: Schema.optional<Schema.String>;
144
+ readonly projectName: Schema.optional<Schema.String>;
145
+ readonly version: Schema.optional<Schema.String>;
146
+ readonly status: Schema.optional<Schema.String>;
147
+ }>;
148
+ readonly fedora: Schema.Struct<{
149
+ readonly supported: Schema.Boolean;
150
+ readonly repo: Schema.optional<Schema.String>;
151
+ readonly packageName: Schema.optional<Schema.String>;
152
+ readonly projectName: Schema.optional<Schema.String>;
153
+ readonly version: Schema.optional<Schema.String>;
154
+ readonly status: Schema.optional<Schema.String>;
155
+ }>;
156
+ readonly nix: Schema.Struct<{
157
+ readonly supported: Schema.Boolean;
158
+ readonly repo: Schema.optional<Schema.String>;
159
+ readonly packageName: Schema.optional<Schema.String>;
160
+ readonly projectName: Schema.optional<Schema.String>;
161
+ readonly version: Schema.optional<Schema.String>;
162
+ readonly status: Schema.optional<Schema.String>;
163
+ }>;
164
+ readonly ubuntu: Schema.Struct<{
165
+ readonly supported: Schema.Boolean;
166
+ readonly repo: Schema.optional<Schema.String>;
167
+ readonly packageName: Schema.optional<Schema.String>;
168
+ readonly projectName: Schema.optional<Schema.String>;
169
+ readonly version: Schema.optional<Schema.String>;
170
+ readonly status: Schema.optional<Schema.String>;
171
+ }>;
172
+ }>;
173
+ readonly alternatives: Schema.$Array<Schema.Struct<{
174
+ readonly projectName: Schema.String;
175
+ }>>;
176
+ readonly fetchedAt: Schema.String;
177
+ readonly expiresAt: Schema.String;
178
+ }>>, HttpApiEndpoint.Json<typeof PackagesBadGatewayError | typeof PackagesInternalServerError>, never, never>, false>;
179
+ export {};