@sealant/api-contracts-next 0.40.0-next.812 → 0.40.0-next.814

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.
@@ -21,7 +21,6 @@
21
21
  */
22
22
  import { Schema } from "effect";
23
23
  import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
24
- import { BudgetExceededError } from "./budgets.js";
25
24
  /**
26
25
  * Connected-account selection — the same reference shape as workspace creation: values are account
27
26
  * ids (`cacc_…`) or per-provider account names; explicit entries win over the profile's bindings.
@@ -84,6 +83,12 @@ export declare const inferenceRespondRequestSchema: Schema.Struct<{
84
83
  readonly type: Schema.Literal<"json">;
85
84
  readonly schema: Schema.optional<Schema.Unknown>;
86
85
  }>>;
86
+ /**
87
+ * Which login a new exchange may run on: `subscription` refuses an account holding an API key
88
+ * (409, `login-not-allowed`, before any provider request); `any` (the default) runs on either.
89
+ * Checked against the account the selection resolved to.
90
+ */
91
+ readonly allowedLogin: Schema.optional<Schema.Literals<readonly ["subscription", "any"]>>;
87
92
  readonly sessionId: Schema.optional<Schema.String>;
88
93
  readonly toolResults: Schema.optional<Schema.$Array<Schema.Struct<{
89
94
  readonly toolCallId: Schema.String;
@@ -118,6 +123,17 @@ export declare const inferenceUsageSchema: Schema.Struct<{
118
123
  readonly outputTokens: Schema.Number;
119
124
  }>;
120
125
  export type InferenceUsage = typeof inferenceUsageSchema.Type;
126
+ /**
127
+ * The login an exchange runs on, fixed when it starts: every continuation runs on it and is judged
128
+ * by it, even after the account is reconnected. `revision` is the account's credential revision at
129
+ * the start.
130
+ */
131
+ export declare const inferenceReceiptSchema: Schema.Struct<{
132
+ readonly accountId: Schema.String;
133
+ readonly revision: Schema.Number;
134
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
135
+ }>;
136
+ export type InferenceReceipt = typeof inferenceReceiptSchema.Type;
121
137
  export declare const inferenceRespondResponseSchema: Schema.Struct<{
122
138
  readonly sessionId: Schema.String;
123
139
  readonly turn: Schema.Union<readonly [Schema.Struct<{
@@ -137,27 +153,78 @@ export declare const inferenceRespondResponseSchema: Schema.Struct<{
137
153
  readonly inputTokens: Schema.Number;
138
154
  readonly outputTokens: Schema.Number;
139
155
  }>>;
156
+ /** The exchange's login. Absent from a control plane that predates receipts. */
157
+ readonly receipt: Schema.optional<Schema.Struct<{
158
+ readonly accountId: Schema.String;
159
+ readonly revision: Schema.Number;
160
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
161
+ }>>;
140
162
  }>;
141
163
  export type InferenceRespondResponse = typeof inferenceRespondResponseSchema.Type;
164
+ declare const InferenceBudgetExceededError_base: Schema.Class<InferenceBudgetExceededError, Schema.TaggedStruct<"BudgetExceededError", {
165
+ readonly message: Schema.String;
166
+ readonly budget: Schema.String;
167
+ readonly limit: Schema.Number;
168
+ readonly retryAfterSeconds: Schema.Number;
169
+ readonly refusal: Schema.optional<Schema.Struct<{
170
+ readonly phase: Schema.Literal<"before-work">;
171
+ readonly bucket: Schema.Literals<readonly ["owner", "unowned", "key", "principal"]>;
172
+ }>>;
173
+ readonly receipt: Schema.optional<Schema.Struct<{
174
+ readonly accountId: Schema.String;
175
+ readonly revision: Schema.Number;
176
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
177
+ }>>;
178
+ }>, import("effect/Cause").YieldableError>;
179
+ /**
180
+ * A budget refused the exchange (429): the same `BudgetExceededError` every other route answers,
181
+ * plus the exchange's login when the refusal came after the account was resolved (the owner's
182
+ * launch budget). The daily token budget refuses before any account is read, so it has none.
183
+ */
184
+ export declare class InferenceBudgetExceededError extends InferenceBudgetExceededError_base {
185
+ }
142
186
  declare const InferenceBadRequestError_base: Schema.Class<InferenceBadRequestError, Schema.TaggedStruct<"InferenceBadRequestError", {
143
187
  readonly message: Schema.String;
188
+ readonly receipt: Schema.optional<Schema.Struct<{
189
+ readonly accountId: Schema.String;
190
+ readonly revision: Schema.Number;
191
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
192
+ }>>;
144
193
  }>, import("effect/Cause").YieldableError>;
145
194
  export declare class InferenceBadRequestError extends InferenceBadRequestError_base {
146
195
  }
147
196
  declare const InferenceNotFoundError_base: Schema.Class<InferenceNotFoundError, Schema.TaggedStruct<"InferenceNotFoundError", {
148
197
  readonly message: Schema.String;
198
+ readonly receipt: Schema.optional<Schema.Struct<{
199
+ readonly accountId: Schema.String;
200
+ readonly revision: Schema.Number;
201
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
202
+ }>>;
149
203
  }>, import("effect/Cause").YieldableError>;
150
204
  /** Unknown account/profile (uniform for foreign owners) or an expired/unknown inference session. */
151
205
  export declare class InferenceNotFoundError extends InferenceNotFoundError_base {
152
206
  }
153
207
  declare const InferenceConflictError_base: Schema.Class<InferenceConflictError, Schema.TaggedStruct<"InferenceConflictError", {
154
208
  readonly message: Schema.String;
155
- readonly code: Schema.optional<Schema.Literals<readonly ["connected-account-unsupported"]>>;
209
+ readonly code: Schema.optional<Schema.Literals<readonly ["connected-account-unsupported", "connected-account-refused", "connected-account-superseded", "login-not-allowed"]>>;
210
+ readonly receipt: Schema.optional<Schema.Struct<{
211
+ readonly accountId: Schema.String;
212
+ readonly revision: Schema.Number;
213
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
214
+ }>>;
156
215
  }>, import("effect/Cause").YieldableError>;
157
216
  /**
158
- * The selected account exists but is not usable: its status is "invalid" (reconnect it), or, with
159
- * `code` `connected-account-unsupported`, it is a login this control plane cannot run on yet (a
160
- * Claude API key).
217
+ * The selected account exists but is not usable: its status is "invalid" (reconnect it), or the
218
+ * provider refused it. `code`, when set:
219
+ *
220
+ * - `connected-account-unsupported`: a login this control plane cannot run on (from a control plane
221
+ * that predates Claude API keys in inference).
222
+ * - `connected-account-refused`: the provider refused an API key with a 401; the account is now
223
+ * invalid.
224
+ * - `connected-account-superseded`: the provider refused an API key with a 401, but the account
225
+ * changed after the exchange started (`receipt.revision` is older), so nothing was marked.
226
+ * - `login-not-allowed`: the request's `allowedLogin` is `subscription` and the account holds an
227
+ * API key; nothing was sent to the provider.
161
228
  */
162
229
  export declare class InferenceConflictError extends InferenceConflictError_base {
163
230
  }
@@ -168,6 +235,11 @@ export declare class InferenceUnavailableError extends InferenceUnavailableError
168
235
  }
169
236
  declare const InferenceInternalServerError_base: Schema.Class<InferenceInternalServerError, Schema.TaggedStruct<"InferenceInternalServerError", {
170
237
  readonly message: Schema.String;
238
+ readonly receipt: Schema.optional<Schema.Struct<{
239
+ readonly accountId: Schema.String;
240
+ readonly revision: Schema.Number;
241
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
242
+ }>>;
171
243
  }>, import("effect/Cause").YieldableError>;
172
244
  export declare class InferenceInternalServerError extends InferenceInternalServerError_base {
173
245
  }
@@ -199,6 +271,12 @@ export declare const InferenceGroup: HttpApiGroup.HttpApiGroup<"inference", Http
199
271
  readonly type: Schema.Literal<"json">;
200
272
  readonly schema: Schema.optional<Schema.Unknown>;
201
273
  }>>;
274
+ /**
275
+ * Which login a new exchange may run on: `subscription` refuses an account holding an API key
276
+ * (409, `login-not-allowed`, before any provider request); `any` (the default) runs on either.
277
+ * Checked against the account the selection resolved to.
278
+ */
279
+ readonly allowedLogin: Schema.optional<Schema.Literals<readonly ["subscription", "any"]>>;
202
280
  readonly sessionId: Schema.optional<Schema.String>;
203
281
  readonly toolResults: Schema.optional<Schema.$Array<Schema.Struct<{
204
282
  readonly toolCallId: Schema.String;
@@ -224,5 +302,11 @@ export declare const InferenceGroup: HttpApiGroup.HttpApiGroup<"inference", Http
224
302
  readonly inputTokens: Schema.Number;
225
303
  readonly outputTokens: Schema.Number;
226
304
  }>>;
227
- }>>, Schema.toCodecJson<typeof BudgetExceededError | typeof InferenceBadRequestError | typeof InferenceNotFoundError | typeof InferenceConflictError | typeof InferenceUnavailableError | typeof InferenceInternalServerError>, never, never>, false>;
305
+ /** The exchange's login. Absent from a control plane that predates receipts. */
306
+ readonly receipt: Schema.optional<Schema.Struct<{
307
+ readonly accountId: Schema.String;
308
+ readonly revision: Schema.Number;
309
+ readonly login: Schema.Literals<readonly ["subscription", "api-key"]>;
310
+ }>>;
311
+ }>>, Schema.toCodecJson<typeof InferenceBudgetExceededError | typeof InferenceBadRequestError | typeof InferenceNotFoundError | typeof InferenceConflictError | typeof InferenceUnavailableError | typeof InferenceInternalServerError>, never, never>, false>;
228
312
  export {};
@@ -21,7 +21,8 @@
21
21
  */
22
22
  import { Schema } from "effect";
23
23
  import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
24
- import { BudgetExceededError } from "./budgets.js";
24
+ import { budgetExceededFields } from "./budgets.js";
25
+ import { connectedAccountLoginClassSchema } from "./connected-accounts.js";
25
26
  import { PersonId } from "./person-id.js";
26
27
  const NonEmptyString = Schema.String.check(Schema.isNonEmpty(), Schema.isTrimmed());
27
28
  /**
@@ -75,6 +76,12 @@ export const inferenceRespondRequestSchema = Schema.Struct({
75
76
  type: Schema.Literal("json"),
76
77
  schema: Schema.optional(Schema.Unknown),
77
78
  })),
79
+ /**
80
+ * Which login a new exchange may run on: `subscription` refuses an account holding an API key
81
+ * (409, `login-not-allowed`, before any provider request); `any` (the default) runs on either.
82
+ * Checked against the account the selection resolved to.
83
+ */
84
+ allowedLogin: Schema.optional(Schema.Literals(["subscription", "any"])),
78
85
  sessionId: Schema.optional(NonEmptyString),
79
86
  toolResults: Schema.optional(Schema.Array(inferenceToolResultSchema).check(Schema.isNonEmpty())),
80
87
  });
@@ -100,33 +107,68 @@ export const inferenceUsageSchema = Schema.Struct({
100
107
  inputTokens: Schema.Number,
101
108
  outputTokens: Schema.Number,
102
109
  });
110
+ /**
111
+ * The login an exchange runs on, fixed when it starts: every continuation runs on it and is judged
112
+ * by it, even after the account is reconnected. `revision` is the account's credential revision at
113
+ * the start.
114
+ */
115
+ export const inferenceReceiptSchema = Schema.Struct({
116
+ accountId: NonEmptyString,
117
+ revision: Schema.Number.check(Schema.isInt()),
118
+ login: connectedAccountLoginClassSchema,
119
+ });
103
120
  export const inferenceRespondResponseSchema = Schema.Struct({
104
121
  sessionId: NonEmptyString,
105
122
  turn: inferenceTurnSchema,
106
123
  /** Usage for the exchange so far; present on the final (text) turn. */
107
124
  usage: Schema.optional(inferenceUsageSchema),
125
+ /** The exchange's login. Absent from a control plane that predates receipts. */
126
+ receipt: Schema.optional(inferenceReceiptSchema),
108
127
  });
109
128
  // ---------------------------------------------------------------------------------------------
110
129
  // Errors
111
130
  // ---------------------------------------------------------------------------------------------
112
- export class InferenceBadRequestError extends Schema.TaggedError()("InferenceBadRequestError", { message: Schema.String }, { httpApiStatus: 400 }) {
131
+ /** On an error after the account was resolved: the exchange's login. */
132
+ const errorReceipt = Schema.optional(inferenceReceiptSchema);
133
+ /**
134
+ * A budget refused the exchange (429): the same `BudgetExceededError` every other route answers,
135
+ * plus the exchange's login when the refusal came after the account was resolved (the owner's
136
+ * launch budget). The daily token budget refuses before any account is read, so it has none.
137
+ */
138
+ export class InferenceBudgetExceededError extends Schema.TaggedError("InferenceBudgetExceededError")("BudgetExceededError", { ...budgetExceededFields, receipt: errorReceipt }, { httpApiStatus: 429 }) {
139
+ }
140
+ export class InferenceBadRequestError extends Schema.TaggedError()("InferenceBadRequestError", { message: Schema.String, receipt: errorReceipt }, { httpApiStatus: 400 }) {
113
141
  }
114
142
  /** Unknown account/profile (uniform for foreign owners) or an expired/unknown inference session. */
115
- export class InferenceNotFoundError extends Schema.TaggedError()("InferenceNotFoundError", { message: Schema.String }, { httpApiStatus: 404 }) {
143
+ export class InferenceNotFoundError extends Schema.TaggedError()("InferenceNotFoundError", { message: Schema.String, receipt: errorReceipt }, { httpApiStatus: 404 }) {
116
144
  }
117
145
  /**
118
- * The selected account exists but is not usable: its status is "invalid" (reconnect it), or, with
119
- * `code` `connected-account-unsupported`, it is a login this control plane cannot run on yet (a
120
- * Claude API key).
146
+ * The selected account exists but is not usable: its status is "invalid" (reconnect it), or the
147
+ * provider refused it. `code`, when set:
148
+ *
149
+ * - `connected-account-unsupported`: a login this control plane cannot run on (from a control plane
150
+ * that predates Claude API keys in inference).
151
+ * - `connected-account-refused`: the provider refused an API key with a 401; the account is now
152
+ * invalid.
153
+ * - `connected-account-superseded`: the provider refused an API key with a 401, but the account
154
+ * changed after the exchange started (`receipt.revision` is older), so nothing was marked.
155
+ * - `login-not-allowed`: the request's `allowedLogin` is `subscription` and the account holds an
156
+ * API key; nothing was sent to the provider.
121
157
  */
122
158
  export class InferenceConflictError extends Schema.TaggedError()("InferenceConflictError", {
123
159
  message: Schema.String,
124
- code: Schema.optional(Schema.Literals(["connected-account-unsupported"])),
160
+ code: Schema.optional(Schema.Literals([
161
+ "connected-account-unsupported",
162
+ "connected-account-refused",
163
+ "connected-account-superseded",
164
+ "login-not-allowed",
165
+ ])),
166
+ receipt: errorReceipt,
125
167
  }, { httpApiStatus: 409 }) {
126
168
  }
127
169
  export class InferenceUnavailableError extends Schema.TaggedError()("InferenceUnavailableError", { message: Schema.String }, { httpApiStatus: 503 }) {
128
170
  }
129
- export class InferenceInternalServerError extends Schema.TaggedError()("InferenceInternalServerError", { message: Schema.String }, { httpApiStatus: 500 }) {
171
+ export class InferenceInternalServerError extends Schema.TaggedError()("InferenceInternalServerError", { message: Schema.String, receipt: errorReceipt }, { httpApiStatus: 500 }) {
130
172
  }
131
173
  // ---------------------------------------------------------------------------------------------
132
174
  // Group
@@ -136,7 +178,7 @@ export const InferenceGroup = HttpApiGroup.make("inference")
136
178
  payload: inferenceRespondRequestSchema,
137
179
  success: inferenceRespondResponseSchema.pipe(HttpApiSchema.status(200)),
138
180
  error: [
139
- BudgetExceededError,
181
+ InferenceBudgetExceededError,
140
182
  InferenceBadRequestError,
141
183
  InferenceNotFoundError,
142
184
  InferenceConflictError,
@@ -71,6 +71,12 @@ export declare const systemIndexResponseSchema: Schema.Struct<{
71
71
  * Codex's own key file. A `$HOME` launch still refuses a Claude key.
72
72
  */
73
73
  readonly connectedAccountApiKeys: Schema.optional<Schema.Boolean>;
74
+ /**
75
+ * Inference takes `allowedLogin` and refuses a key when it says `subscription`, answers and
76
+ * errors carry the exchange's `receipt`, and a Claude API key runs inference. Without it,
77
+ * `allowedLogin` is dropped unread.
78
+ */
79
+ readonly inferenceAllowedLogin: Schema.optional<Schema.Boolean>;
74
80
  }>>;
75
81
  }>;
76
82
  export type SystemIndexResponse = typeof systemIndexResponseSchema.Type;
@@ -169,6 +175,12 @@ export declare const SystemGroup: HttpApiGroup.HttpApiGroup<"system", HttpApiEnd
169
175
  * Codex's own key file. A `$HOME` launch still refuses a Claude key.
170
176
  */
171
177
  readonly connectedAccountApiKeys: Schema.optional<Schema.Boolean>;
178
+ /**
179
+ * Inference takes `allowedLogin` and refuses a key when it says `subscription`, answers and
180
+ * errors carry the exchange's `receipt`, and a Claude API key runs inference. Without it,
181
+ * `allowedLogin` is dropped unread.
182
+ */
183
+ readonly inferenceAllowedLogin: Schema.optional<Schema.Boolean>;
172
184
  }>>;
173
185
  }>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getSetupState", "GET", "/v1/system/setup-state", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
174
186
  readonly needsSetup: Schema.Boolean;
@@ -72,6 +72,12 @@ export const systemIndexResponseSchema = Schema.Struct({
72
72
  * Codex's own key file. A `$HOME` launch still refuses a Claude key.
73
73
  */
74
74
  connectedAccountApiKeys: Schema.optional(Schema.Boolean),
75
+ /**
76
+ * Inference takes `allowedLogin` and refuses a key when it says `subscription`, answers and
77
+ * errors carry the exchange's `receipt`, and a Claude API key runs inference. Without it,
78
+ * `allowedLogin` is dropped unread.
79
+ */
80
+ inferenceAllowedLogin: Schema.optional(Schema.Boolean),
75
81
  })),
76
82
  });
77
83
  export const systemHealthResponseSchema = Schema.Struct({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealant/api-contracts-next",
3
- "version": "0.40.0-next.812",
3
+ "version": "0.40.0-next.814",
4
4
  "description": "Contract-first HTTP API definitions for Sealant services",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "peerDependencies": {
37
37
  "effect": "^4.0.5"
38
38
  },
39
- "gitHead": "7be0b815a8d5ebc630feecc626eba178736f9ba8",
39
+ "gitHead": "fcc1174e4f3a10476b1f7cbbe209734f557570e6",
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  }