@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,226 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
3
+ export declare const connectedAccountProviderSchema: Schema.Literals<readonly ["claude", "codex", "github"]>;
4
+ export type ConnectedAccountProvider = typeof connectedAccountProviderSchema.Type;
5
+ export declare const connectedAccountStatusSchema: Schema.Literals<readonly ["active", "invalid", "archived"]>;
6
+ export type ConnectedAccountStatus = typeof connectedAccountStatusSchema.Type;
7
+ /**
8
+ * What the control plane observed about a credential's life, so a consumer can say "expired" as an
9
+ * observation instead of parsing a payload it must never see. Every field is null when nothing was
10
+ * observed: a setup token has no expiry, a row connected before this shipped has no stored one, and
11
+ * an account that has never been swept has no refresh outcome.
12
+ */
13
+ export declare const connectedAccountCredentialSchema: Schema.Struct<{
14
+ /** When the access token expires. Hours, for a Claude session credential. */
15
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
16
+ /** When the grant itself expires, after which reconnecting is the only way back. */
17
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
18
+ /** When the platform last rotated or checked this credential. */
19
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
20
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
21
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
22
+ }>;
23
+ export type ConnectedAccountCredential = typeof connectedAccountCredentialSchema.Type;
24
+ export declare const connectedAccountSummarySchema: Schema.Struct<{
25
+ readonly connectedAccountId: Schema.String;
26
+ readonly ownerUserId: Schema.String;
27
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
28
+ readonly name: Schema.String;
29
+ readonly kind: Schema.String;
30
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
31
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
32
+ readonly connectedAt: Schema.String;
33
+ readonly updatedAt: Schema.String;
34
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
35
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
36
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
37
+ readonly credential: Schema.Struct<{
38
+ /** When the access token expires. Hours, for a Claude session credential. */
39
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
40
+ /** When the grant itself expires, after which reconnecting is the only way back. */
41
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
42
+ /** When the platform last rotated or checked this credential. */
43
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
44
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
45
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
46
+ }>;
47
+ }>;
48
+ export type ConnectedAccountSummary = typeof connectedAccountSummarySchema.Type;
49
+ export declare const createConnectedAccountRequestSchema: Schema.Struct<{
50
+ readonly ownerUserId: Schema.String;
51
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
52
+ readonly name: Schema.optional<Schema.String>;
53
+ readonly secret: Schema.String;
54
+ }>;
55
+ export type CreateConnectedAccountRequest = typeof createConnectedAccountRequestSchema.Type;
56
+ export declare const listConnectedAccountsQuerySchema: Schema.Struct<{
57
+ readonly ownerUserId: Schema.String;
58
+ }>;
59
+ export type ListConnectedAccountsQuery = typeof listConnectedAccountsQuerySchema.Type;
60
+ export declare const listConnectedAccountsResponseSchema: Schema.Struct<{
61
+ readonly items: Schema.$Array<Schema.Struct<{
62
+ readonly connectedAccountId: Schema.String;
63
+ readonly ownerUserId: Schema.String;
64
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
65
+ readonly name: Schema.String;
66
+ readonly kind: Schema.String;
67
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
68
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
69
+ readonly connectedAt: Schema.String;
70
+ readonly updatedAt: Schema.String;
71
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
72
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
73
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
74
+ readonly credential: Schema.Struct<{
75
+ /** When the access token expires. Hours, for a Claude session credential. */
76
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
77
+ /** When the grant itself expires, after which reconnecting is the only way back. */
78
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
79
+ /** When the platform last rotated or checked this credential. */
80
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
81
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
82
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
83
+ }>;
84
+ }>>;
85
+ }>;
86
+ export type ListConnectedAccountsResponse = typeof listConnectedAccountsResponseSchema.Type;
87
+ export declare const markConnectedAccountInvalidRequestSchema: Schema.Struct<{
88
+ readonly ownerUserId: Schema.String;
89
+ }>;
90
+ export type MarkConnectedAccountInvalidRequest = typeof markConnectedAccountInvalidRequestSchema.Type;
91
+ declare const ConnectedAccountBadRequestError_base: Schema.Class<ConnectedAccountBadRequestError, Schema.TaggedStruct<"ConnectedAccountBadRequestError", {
92
+ readonly message: Schema.String;
93
+ }>, import("effect/Cause").YieldableError>;
94
+ export declare class ConnectedAccountBadRequestError extends ConnectedAccountBadRequestError_base {
95
+ }
96
+ declare const ConnectedAccountNotFoundError_base: Schema.Class<ConnectedAccountNotFoundError, Schema.TaggedStruct<"ConnectedAccountNotFoundError", {
97
+ readonly message: Schema.String;
98
+ }>, import("effect/Cause").YieldableError>;
99
+ export declare class ConnectedAccountNotFoundError extends ConnectedAccountNotFoundError_base {
100
+ }
101
+ declare const ConnectedAccountConflictError_base: Schema.Class<ConnectedAccountConflictError, Schema.TaggedStruct<"ConnectedAccountConflictError", {
102
+ readonly message: Schema.String;
103
+ }>, import("effect/Cause").YieldableError>;
104
+ export declare class ConnectedAccountConflictError extends ConnectedAccountConflictError_base {
105
+ }
106
+ declare const ConnectedAccountServiceUnavailableError_base: Schema.Class<ConnectedAccountServiceUnavailableError, Schema.TaggedStruct<"ConnectedAccountServiceUnavailableError", {
107
+ readonly message: Schema.String;
108
+ }>, import("effect/Cause").YieldableError>;
109
+ export declare class ConnectedAccountServiceUnavailableError extends ConnectedAccountServiceUnavailableError_base {
110
+ }
111
+ declare const ConnectedAccountInternalServerError_base: Schema.Class<ConnectedAccountInternalServerError, Schema.TaggedStruct<"ConnectedAccountInternalServerError", {
112
+ readonly message: Schema.String;
113
+ }>, import("effect/Cause").YieldableError>;
114
+ export declare class ConnectedAccountInternalServerError extends ConnectedAccountInternalServerError_base {
115
+ }
116
+ export declare const ConnectedAccountsGroup: HttpApiGroup.HttpApiGroup<"connectedAccounts", HttpApiEndpoint.HttpApiEndpoint<"archiveConnectedAccount", "DELETE", "/:connectedAccountId", HttpApiEndpoint.StringTree<Schema.Struct<{
117
+ readonly connectedAccountId: Schema.String;
118
+ }>>, HttpApiEndpoint.StringTree<Schema.Struct<{
119
+ readonly ownerUserId: Schema.String;
120
+ }>>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
121
+ readonly connectedAccountId: Schema.String;
122
+ readonly ownerUserId: Schema.String;
123
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
124
+ readonly name: Schema.String;
125
+ readonly kind: Schema.String;
126
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
127
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
128
+ readonly connectedAt: Schema.String;
129
+ readonly updatedAt: Schema.String;
130
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
131
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
132
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
133
+ readonly credential: Schema.Struct<{
134
+ /** When the access token expires. Hours, for a Claude session credential. */
135
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
136
+ /** When the grant itself expires, after which reconnecting is the only way back. */
137
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
138
+ /** When the platform last rotated or checked this credential. */
139
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
140
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
141
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
142
+ }>;
143
+ }>>, HttpApiEndpoint.Json<typeof ConnectedAccountNotFoundError | typeof ConnectedAccountInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"createConnectedAccount", "POST", "/", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
144
+ readonly ownerUserId: Schema.String;
145
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
146
+ readonly name: Schema.optional<Schema.String>;
147
+ readonly secret: Schema.String;
148
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
149
+ readonly connectedAccountId: Schema.String;
150
+ readonly ownerUserId: Schema.String;
151
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
152
+ readonly name: Schema.String;
153
+ readonly kind: Schema.String;
154
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
155
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
156
+ readonly connectedAt: Schema.String;
157
+ readonly updatedAt: Schema.String;
158
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
159
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
160
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
161
+ readonly credential: Schema.Struct<{
162
+ /** When the access token expires. Hours, for a Claude session credential. */
163
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
164
+ /** When the grant itself expires, after which reconnecting is the only way back. */
165
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
166
+ /** When the platform last rotated or checked this credential. */
167
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
168
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
169
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
170
+ }>;
171
+ }>>, HttpApiEndpoint.Json<typeof ConnectedAccountBadRequestError | typeof ConnectedAccountNotFoundError | typeof ConnectedAccountConflictError | typeof ConnectedAccountServiceUnavailableError | typeof ConnectedAccountInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listConnectedAccounts", "GET", "/", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
172
+ readonly ownerUserId: Schema.String;
173
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
174
+ readonly items: Schema.$Array<Schema.Struct<{
175
+ readonly connectedAccountId: Schema.String;
176
+ readonly ownerUserId: Schema.String;
177
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
178
+ readonly name: Schema.String;
179
+ readonly kind: Schema.String;
180
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
181
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
182
+ readonly connectedAt: Schema.String;
183
+ readonly updatedAt: Schema.String;
184
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
185
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
186
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
187
+ readonly credential: Schema.Struct<{
188
+ /** When the access token expires. Hours, for a Claude session credential. */
189
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
190
+ /** When the grant itself expires, after which reconnecting is the only way back. */
191
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
192
+ /** When the platform last rotated or checked this credential. */
193
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
194
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
195
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
196
+ }>;
197
+ }>>;
198
+ }>>, HttpApiEndpoint.Json<typeof ConnectedAccountInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"markConnectedAccountInvalid", "POST", "/:connectedAccountId/mark-invalid", HttpApiEndpoint.StringTree<Schema.Struct<{
199
+ readonly connectedAccountId: Schema.String;
200
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
201
+ readonly ownerUserId: Schema.String;
202
+ }>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
203
+ readonly connectedAccountId: Schema.String;
204
+ readonly ownerUserId: Schema.String;
205
+ readonly provider: Schema.Literals<readonly ["claude", "codex", "github"]>;
206
+ readonly name: Schema.String;
207
+ readonly kind: Schema.String;
208
+ readonly status: Schema.Literals<readonly ["active", "invalid", "archived"]>;
209
+ readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
210
+ readonly connectedAt: Schema.String;
211
+ readonly updatedAt: Schema.String;
212
+ readonly lastUsedAt: Schema.NullOr<Schema.String>;
213
+ readonly lastSyncedAt: Schema.NullOr<Schema.String>;
214
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
215
+ readonly credential: Schema.Struct<{
216
+ /** When the access token expires. Hours, for a Claude session credential. */
217
+ readonly accessExpiresAt: Schema.NullOr<Schema.String>;
218
+ /** When the grant itself expires, after which reconnecting is the only way back. */
219
+ readonly refreshExpiresAt: Schema.NullOr<Schema.String>;
220
+ /** When the platform last rotated or checked this credential. */
221
+ readonly lastRefreshAt: Schema.NullOr<Schema.String>;
222
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
223
+ readonly lastRefreshOutcome: Schema.NullOr<Schema.Literals<readonly ["refreshed", "fresh", "failed"]>>;
224
+ }>;
225
+ }>>, HttpApiEndpoint.Json<typeof ConnectedAccountNotFoundError | typeof ConnectedAccountInternalServerError>, never, never>, false>;
226
+ export {};
@@ -0,0 +1,128 @@
1
+ import { Schema } from "effect";
2
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
3
+ const NonEmptyString = Schema.String.check(Schema.isNonEmpty(), Schema.isTrimmed());
4
+ /*
5
+ Connected provider accounts (Claude / Codex / GitHub credentials). Same trust model as ssh-keys:
6
+ the internal API trusts the caller-supplied `ownerUserId`; the web tRPC proxy and the CLI inject
7
+ the session/configured user inside the deployment's trust boundary.
8
+
9
+ Secret material flows exactly one way: `createConnectedAccountRequestSchema.secret` carries the
10
+ provider-shaped plaintext INTO the API, where it is validated, encrypted (AES-256-GCM via
11
+ @sealant/credentials), and stored sealed. NO endpoint ever returns secret material — summaries
12
+ expose only non-secret metadata (token suffix, codex account id/email, github login+scopes).
13
+ `markConnectedAccountInvalid` is the internal 401-feedback hook (worker/sync-back observed the
14
+ provider rejecting the credential).
15
+ */
16
+ export const connectedAccountProviderSchema = Schema.Literals(["claude", "codex", "github"]);
17
+ export const connectedAccountStatusSchema = Schema.Literals(["active", "invalid", "archived"]);
18
+ /**
19
+ * What the control plane observed about a credential's life, so a consumer can say "expired" as an
20
+ * observation instead of parsing a payload it must never see. Every field is null when nothing was
21
+ * observed: a setup token has no expiry, a row connected before this shipped has no stored one, and
22
+ * an account that has never been swept has no refresh outcome.
23
+ */
24
+ export const connectedAccountCredentialSchema = Schema.Struct({
25
+ /** When the access token expires. Hours, for a Claude session credential. */
26
+ accessExpiresAt: Schema.NullOr(Schema.String),
27
+ /** When the grant itself expires, after which reconnecting is the only way back. */
28
+ refreshExpiresAt: Schema.NullOr(Schema.String),
29
+ /** When the platform last rotated or checked this credential. */
30
+ lastRefreshAt: Schema.NullOr(Schema.String),
31
+ /** What that attempt did: `refreshed`, `fresh` (nothing to do), or `failed`. */
32
+ lastRefreshOutcome: Schema.NullOr(Schema.Literals(["refreshed", "fresh", "failed"])),
33
+ });
34
+ export const connectedAccountSummarySchema = Schema.Struct({
35
+ connectedAccountId: NonEmptyString,
36
+ ownerUserId: NonEmptyString,
37
+ provider: connectedAccountProviderSchema,
38
+ name: NonEmptyString,
39
+ // "oauth-token" | "credentials-json" (claude) | "auth-json" (codex) | "gh-cli-token" (github).
40
+ kind: NonEmptyString,
41
+ status: connectedAccountStatusSchema,
42
+ // NON-secret display/ops data (claude token suffix, codex account id/email, github login+scopes).
43
+ metadata: Schema.Record(Schema.String, Schema.Unknown),
44
+ connectedAt: Schema.String,
45
+ updatedAt: Schema.String,
46
+ lastUsedAt: Schema.NullOr(Schema.String),
47
+ lastSyncedAt: Schema.NullOr(Schema.String),
48
+ /** Freshness as the control plane observed it; see the schema above for what null means. */
49
+ credential: connectedAccountCredentialSchema,
50
+ });
51
+ export const createConnectedAccountRequestSchema = Schema.Struct({
52
+ ownerUserId: NonEmptyString,
53
+ provider: connectedAccountProviderSchema,
54
+ // Multiple accounts per provider are allowed; defaults to "default".
55
+ name: Schema.optional(NonEmptyString),
56
+ // Provider-shaped plaintext: claude setup-token or verbatim .credentials.json contents /
57
+ // verbatim codex auth.json contents / github token. Encrypted server-side; never stored or
58
+ // echoed back as-is. Not trimmed here — pasted credential files are stored verbatim.
59
+ secret: Schema.String.check(Schema.isNonEmpty()),
60
+ });
61
+ export const listConnectedAccountsQuerySchema = Schema.Struct({
62
+ ownerUserId: NonEmptyString,
63
+ });
64
+ export const listConnectedAccountsResponseSchema = Schema.Struct({
65
+ items: Schema.Array(connectedAccountSummarySchema),
66
+ });
67
+ export const markConnectedAccountInvalidRequestSchema = Schema.Struct({
68
+ ownerUserId: NonEmptyString,
69
+ });
70
+ export class ConnectedAccountBadRequestError extends Schema.TaggedErrorClass()("ConnectedAccountBadRequestError", {
71
+ message: Schema.String,
72
+ }, { httpApiStatus: 400 }) {
73
+ }
74
+ export class ConnectedAccountNotFoundError extends Schema.TaggedErrorClass()("ConnectedAccountNotFoundError", {
75
+ message: Schema.String,
76
+ }, { httpApiStatus: 404 }) {
77
+ }
78
+ export class ConnectedAccountConflictError extends Schema.TaggedErrorClass()("ConnectedAccountConflictError", {
79
+ message: Schema.String,
80
+ }, { httpApiStatus: 409 }) {
81
+ }
82
+ export class ConnectedAccountServiceUnavailableError extends Schema.TaggedErrorClass()("ConnectedAccountServiceUnavailableError", {
83
+ message: Schema.String,
84
+ }, { httpApiStatus: 503 }) {
85
+ }
86
+ export class ConnectedAccountInternalServerError extends Schema.TaggedErrorClass()("ConnectedAccountInternalServerError", {
87
+ message: Schema.String,
88
+ }, { httpApiStatus: 500 }) {
89
+ }
90
+ const connectedAccountIdParams = Schema.Struct({ connectedAccountId: NonEmptyString });
91
+ export const ConnectedAccountsGroup = HttpApiGroup.make("connectedAccounts")
92
+ .add(
93
+ // Connect/replace: upserts on (owner, provider, name), so reconnecting swaps the sealed
94
+ // payload in place instead of erroring.
95
+ HttpApiEndpoint.post("createConnectedAccount", "/", {
96
+ payload: createConnectedAccountRequestSchema,
97
+ success: connectedAccountSummarySchema.pipe(HttpApiSchema.status(201)),
98
+ error: [
99
+ ConnectedAccountBadRequestError,
100
+ ConnectedAccountNotFoundError,
101
+ ConnectedAccountConflictError,
102
+ ConnectedAccountServiceUnavailableError,
103
+ ConnectedAccountInternalServerError,
104
+ ],
105
+ }))
106
+ .add(HttpApiEndpoint.get("listConnectedAccounts", "/", {
107
+ query: listConnectedAccountsQuerySchema,
108
+ success: listConnectedAccountsResponseSchema,
109
+ error: [ConnectedAccountInternalServerError],
110
+ }))
111
+ .add(
112
+ // Soft archive; uniform 404 for "does not exist" and "not yours".
113
+ HttpApiEndpoint.delete("archiveConnectedAccount", "/:connectedAccountId", {
114
+ params: connectedAccountIdParams,
115
+ query: listConnectedAccountsQuerySchema,
116
+ success: connectedAccountSummarySchema,
117
+ error: [ConnectedAccountNotFoundError, ConnectedAccountInternalServerError],
118
+ }))
119
+ .add(
120
+ // Internal feedback hook: the worker observed the provider rejecting this credential (401),
121
+ // so surfaces should prompt a re-auth.
122
+ HttpApiEndpoint.post("markConnectedAccountInvalid", "/:connectedAccountId/mark-invalid", {
123
+ params: connectedAccountIdParams,
124
+ payload: markConnectedAccountInvalidRequestSchema,
125
+ success: connectedAccountSummarySchema,
126
+ error: [ConnectedAccountNotFoundError, ConnectedAccountInternalServerError],
127
+ }))
128
+ .annotate(OpenApi.Description, "Connected provider accounts (Claude / Codex / GitHub credentials). Secret material is never returned by any endpoint.");