@sealant/sdk-next 0.40.0-next.813 → 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.
package/dist/client.js CHANGED
@@ -7,7 +7,7 @@ import { makeWorkspace, registerHarnessExecutors, toRuntimeInfo, toWorkspaceImag
7
7
  import { buildCreateWorkspaceRequest } from "./internal/blueprint.js";
8
8
  import { resolveInternalConfig } from "./internal/config.js";
9
9
  import { parseTtlSeconds } from "./internal/duration.js";
10
- import { readFeatures, requireConnectedAccountDefaults, requireConnectedAccountLoginClass, } from "./internal/features.js";
10
+ import { readFeatures, requireConnectedAccountDefaults, requireConnectedAccountLoginClass, requireInferenceAllowedLogin, } from "./internal/features.js";
11
11
  import { imageSpecKey } from "./internal/image-key.js";
12
12
  import { buildInferenceRespondRequest, mapInferenceResponse } from "./internal/inference.js";
13
13
  import { requireSshUser } from "./internal/process-user.js";
@@ -217,6 +217,9 @@ export class Sealant {
217
217
  */
218
218
  inference = {
219
219
  respond: async (options) => {
220
+ if ("allowedLogin" in options && options.allowedLogin === "subscription") {
221
+ await requireInferenceAllowedLogin(this.#ctx);
222
+ }
220
223
  const payload = buildInferenceRespondRequest(options, this.#ctx.config.hostLocal.ownerUserId);
221
224
  const wire = await this.#runtime.run(inferenceRespondOp(payload));
222
225
  return mapInferenceResponse(wire);
@@ -308,6 +308,7 @@ declare const buildControlPlaneClient: (config: SealantInternalConfig) => Effect
308
308
  readonly type: import("effect/Schema").Literal<"json">;
309
309
  readonly schema: import("effect/Schema").optional<import("effect/Schema").Unknown>;
310
310
  }>>;
311
+ readonly allowedLogin: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["subscription", "any"]>>;
311
312
  readonly sessionId: import("effect/Schema").optional<import("effect/Schema").String>;
312
313
  readonly toolResults: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
313
314
  readonly toolCallId: import("effect/Schema").String;
@@ -332,7 +333,12 @@ declare const buildControlPlaneClient: (config: SealantInternalConfig) => Effect
332
333
  readonly inputTokens: import("effect/Schema").Number;
333
334
  readonly outputTokens: import("effect/Schema").Number;
334
335
  }>>;
335
- }>>, import("effect/Schema").toCodecJson<typeof import("@sealant/api-contracts").BudgetExceededError | typeof import("@sealant/api-contracts").InferenceBadRequestError | typeof import("@sealant/api-contracts").InferenceNotFoundError | typeof import("@sealant/api-contracts").InferenceConflictError | typeof import("@sealant/api-contracts").InferenceUnavailableError | typeof import("@sealant/api-contracts").InferenceInternalServerError>, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
336
+ readonly receipt: import("effect/Schema").optional<import("effect/Schema").Struct<{
337
+ readonly accountId: import("effect/Schema").String;
338
+ readonly revision: import("effect/Schema").Number;
339
+ readonly login: import("effect/Schema").Literals<readonly ["subscription", "api-key"]>;
340
+ }>>;
341
+ }>>, import("effect/Schema").toCodecJson<typeof import("@sealant/api-contracts").InferenceBudgetExceededError | typeof import("@sealant/api-contracts").InferenceBadRequestError | typeof import("@sealant/api-contracts").InferenceNotFoundError | typeof import("@sealant/api-contracts").InferenceConflictError | typeof import("@sealant/api-contracts").InferenceUnavailableError | typeof import("@sealant/api-contracts").InferenceInternalServerError>, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
336
342
  };
337
343
  readonly packages: {
338
344
  readonly resolvePackage: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"resolvePackage", "GET", "/v1/packages/resolve", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -1496,6 +1502,7 @@ declare const buildControlPlaneClient: (config: SealantInternalConfig) => Effect
1496
1502
  readonly kubernetesPersonLayout: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1497
1503
  readonly credentialPlacements: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1498
1504
  readonly connectedAccountApiKeys: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1505
+ readonly inferenceAllowedLogin: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1499
1506
  }>>;
1500
1507
  }>>, never, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
1501
1508
  readonly getSetupState: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getSetupState", "GET", "/v1/system/setup-state", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
@@ -2977,6 +2984,7 @@ declare const SealantApiClient_base: Context.ServiceClass<SealantApiClient, "@se
2977
2984
  readonly type: import("effect/Schema").Literal<"json">;
2978
2985
  readonly schema: import("effect/Schema").optional<import("effect/Schema").Unknown>;
2979
2986
  }>>;
2987
+ readonly allowedLogin: import("effect/Schema").optional<import("effect/Schema").Literals<readonly ["subscription", "any"]>>;
2980
2988
  readonly sessionId: import("effect/Schema").optional<import("effect/Schema").String>;
2981
2989
  readonly toolResults: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").Struct<{
2982
2990
  readonly toolCallId: import("effect/Schema").String;
@@ -3001,7 +3009,12 @@ declare const SealantApiClient_base: Context.ServiceClass<SealantApiClient, "@se
3001
3009
  readonly inputTokens: import("effect/Schema").Number;
3002
3010
  readonly outputTokens: import("effect/Schema").Number;
3003
3011
  }>>;
3004
- }>>, import("effect/Schema").toCodecJson<typeof import("@sealant/api-contracts").BudgetExceededError | typeof import("@sealant/api-contracts").InferenceBadRequestError | typeof import("@sealant/api-contracts").InferenceNotFoundError | typeof import("@sealant/api-contracts").InferenceConflictError | typeof import("@sealant/api-contracts").InferenceUnavailableError | typeof import("@sealant/api-contracts").InferenceInternalServerError>, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
3012
+ readonly receipt: import("effect/Schema").optional<import("effect/Schema").Struct<{
3013
+ readonly accountId: import("effect/Schema").String;
3014
+ readonly revision: import("effect/Schema").Number;
3015
+ readonly login: import("effect/Schema").Literals<readonly ["subscription", "api-key"]>;
3016
+ }>>;
3017
+ }>>, import("effect/Schema").toCodecJson<typeof import("@sealant/api-contracts").InferenceBudgetExceededError | typeof import("@sealant/api-contracts").InferenceBadRequestError | typeof import("@sealant/api-contracts").InferenceNotFoundError | typeof import("@sealant/api-contracts").InferenceConflictError | typeof import("@sealant/api-contracts").InferenceUnavailableError | typeof import("@sealant/api-contracts").InferenceInternalServerError>, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
3005
3018
  };
3006
3019
  readonly packages: {
3007
3020
  readonly resolvePackage: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"resolvePackage", "GET", "/v1/packages/resolve", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -4165,6 +4178,7 @@ declare const SealantApiClient_base: Context.ServiceClass<SealantApiClient, "@se
4165
4178
  readonly kubernetesPersonLayout: import("effect/Schema").optional<import("effect/Schema").Boolean>;
4166
4179
  readonly credentialPlacements: import("effect/Schema").optional<import("effect/Schema").Boolean>;
4167
4180
  readonly connectedAccountApiKeys: import("effect/Schema").optional<import("effect/Schema").Boolean>;
4181
+ readonly inferenceAllowedLogin: import("effect/Schema").optional<import("effect/Schema").Boolean>;
4168
4182
  }>>;
4169
4183
  }>>, never, import("@sealant/api-contracts").RequestBudget | import("@sealant/api-contracts").RequestRefusal, never>, never, never>;
4170
4184
  readonly getSetupState: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getSetupState", "GET", "/v1/system/setup-state", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
@@ -1291,7 +1291,12 @@ export declare const inferenceRespondOp: (payload: InferenceRespondRequest) => E
1291
1291
  readonly inputTokens: number;
1292
1292
  readonly outputTokens: number;
1293
1293
  } | undefined;
1294
- }, import("@sealant/api-contracts").BudgetExceededError | import("effect/http/HttpClientError").HttpClientError | import("@sealant/api-contracts").InferenceBadRequestError | import("@sealant/api-contracts").InferenceConflictError | import("@sealant/api-contracts").InferenceInternalServerError | import("@sealant/api-contracts").InferenceNotFoundError | import("@sealant/api-contracts").InferenceUnavailableError | import("@sealant/api-contracts").RequestRefusedError | Schema.SchemaError, SealantApiClient>;
1294
+ readonly receipt?: {
1295
+ readonly accountId: string;
1296
+ readonly revision: number;
1297
+ readonly login: "api-key" | "subscription";
1298
+ } | undefined;
1299
+ }, import("@sealant/api-contracts").BudgetExceededError | import("effect/http/HttpClientError").HttpClientError | import("@sealant/api-contracts").InferenceBadRequestError | import("@sealant/api-contracts").InferenceBudgetExceededError | import("@sealant/api-contracts").InferenceConflictError | import("@sealant/api-contracts").InferenceInternalServerError | import("@sealant/api-contracts").InferenceNotFoundError | import("@sealant/api-contracts").InferenceUnavailableError | import("@sealant/api-contracts").RequestRefusedError | Schema.SchemaError, SealantApiClient>;
1295
1300
  export declare const getIndexOp: () => Effect.Effect<{
1296
1301
  readonly name: string;
1297
1302
  readonly version: string;
@@ -1312,6 +1317,7 @@ export declare const getIndexOp: () => Effect.Effect<{
1312
1317
  readonly kubernetesPersonLayout?: boolean | undefined;
1313
1318
  readonly credentialPlacements?: boolean | undefined;
1314
1319
  readonly connectedAccountApiKeys?: boolean | undefined;
1320
+ readonly inferenceAllowedLogin?: boolean | undefined;
1315
1321
  } | undefined;
1316
1322
  }, import("@sealant/api-contracts").BudgetExceededError | import("effect/http/HttpClientError").HttpClientError | import("@sealant/api-contracts").RequestRefusedError | Schema.SchemaError, SealantApiClient>;
1317
1323
  export declare const getSetupStateOp: () => Effect.Effect<{
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { RequestBudgetRefusal, ForwardRefusalReason } from "@sealant/api-contracts";
2
- import type { ForwardResetCause } from "./types.js";
2
+ import type { ForwardResetCause, InferenceReceipt } from "./types.js";
3
3
  /**
4
4
  * Public SDK errors. The Effect core fails on a typed `Schema.TaggedError` channel; the facade maps
5
5
  * every tagged failure onto one of these PLAIN `Error` subclasses (a single `_tag` switch) so the
@@ -41,12 +41,15 @@ export declare class SealantApiError extends SealantError {
41
41
  readonly provider?: string;
42
42
  /** The accounts a `connected-account-ambiguous` connect could have meant. */
43
43
  readonly candidateAccountIds?: readonly string[];
44
+ /** An inference error after the account was resolved: the exchange's login. */
45
+ readonly receipt?: InferenceReceipt;
44
46
  constructor(message: string, options?: {
45
47
  readonly code?: string;
46
48
  readonly status?: number;
47
49
  readonly reason?: string;
48
50
  readonly provider?: string;
49
51
  readonly candidateAccountIds?: readonly string[];
52
+ readonly receipt?: InferenceReceipt;
50
53
  readonly cause?: unknown;
51
54
  });
52
55
  }
@@ -67,6 +70,7 @@ export declare class SealantBudgetExceededError extends SealantApiError {
67
70
  readonly limit: number;
68
71
  readonly retryAfterSeconds: number;
69
72
  readonly refusal?: RequestBudgetRefusal;
73
+ readonly receipt?: InferenceReceipt;
70
74
  readonly cause?: unknown;
71
75
  });
72
76
  }
package/dist/errors.js CHANGED
@@ -41,6 +41,8 @@ export class SealantApiError extends SealantError {
41
41
  provider;
42
42
  /** The accounts a `connected-account-ambiguous` connect could have meant. */
43
43
  candidateAccountIds;
44
+ /** An inference error after the account was resolved: the exchange's login. */
45
+ receipt;
44
46
  constructor(message, options) {
45
47
  super(message, {
46
48
  code: options?.code ?? "api_error",
@@ -58,6 +60,9 @@ export class SealantApiError extends SealantError {
58
60
  if (options?.candidateAccountIds !== undefined) {
59
61
  this.candidateAccountIds = options.candidateAccountIds;
60
62
  }
63
+ if (options?.receipt !== undefined) {
64
+ this.receipt = options.receipt;
65
+ }
61
66
  }
62
67
  }
63
68
  /** A control-plane budget failure, with the server's retry delay and admission metadata. */
@@ -76,6 +81,7 @@ export class SealantBudgetExceededError extends SealantApiError {
76
81
  super(message, {
77
82
  code: "BudgetExceededError",
78
83
  status: 429,
84
+ ...(options.receipt === undefined ? {} : { receipt: options.receipt }),
79
85
  ...(options.cause === undefined ? {} : { cause: options.cause }),
80
86
  });
81
87
  this.budget = options.budget;
@@ -16,3 +16,4 @@ export declare const readFeatures: (ctx: SdkContext) => Promise<SealantFeatures>
16
16
  export declare const requireConnectedAccountDefaults: (ctx: SdkContext) => Promise<void>;
17
17
  export declare const requireConnectedAccountLoginClass: (ctx: SdkContext) => Promise<void>;
18
18
  export declare const requireCredentialPlacements: (ctx: SdkContext) => Promise<void>;
19
+ export declare const requireInferenceAllowedLogin: (ctx: SdkContext) => Promise<void>;
@@ -25,6 +25,7 @@ export const toFeatures = (index) => {
25
25
  connectedAccountLoginClass: features?.connectedAccountLoginClass === true,
26
26
  kubernetesPersonLayout: features?.kubernetesPersonLayout === true,
27
27
  connectedAccountApiKeys: features?.connectedAccountApiKeys === true,
28
+ inferenceAllowedLogin: features?.inferenceAllowedLogin === true,
28
29
  };
29
30
  };
30
31
  /**
@@ -64,3 +65,9 @@ export const requireCredentialPlacements = async (ctx) => {
64
65
  if (!supported)
65
66
  throw new SealantError("This control plane cannot protect live credential placements or prune them; nothing was sent.", { code: "credential-placements-unsupported" });
66
67
  };
68
+ export const requireInferenceAllowedLogin = async (ctx) => {
69
+ const supported = await readFeatures(ctx).then((features) => features.inferenceAllowedLogin, () => false);
70
+ if (!supported) {
71
+ throw new SealantError("This control plane cannot limit inference to a subscription (it does not report the feature, or could not be asked), and would run on a key; nothing was sent.", { code: "inference-allowed-login-unsupported" });
72
+ }
73
+ };
@@ -23,6 +23,7 @@ export const buildInferenceRespondRequest = (options, ownerUserId) => {
23
23
  ...(codex === undefined ? {} : { codex }),
24
24
  },
25
25
  prompt: options.prompt,
26
+ ...(options.allowedLogin === undefined ? {} : { allowedLogin: options.allowedLogin }),
26
27
  ...(options.system === undefined ? {} : { system: options.system }),
27
28
  ...(options.model === undefined ? {} : { model: options.model }),
28
29
  ...(options.maxTurns === undefined ? {} : { maxTurns: options.maxTurns }),
@@ -68,5 +69,6 @@ export const mapInferenceResponse = (wire) => {
68
69
  ...(wire.usage === undefined
69
70
  ? {}
70
71
  : { usage: { inputTokens: wire.usage.inputTokens, outputTokens: wire.usage.outputTokens } }),
72
+ ...(wire.receipt === undefined ? {} : { receipt: { ...wire.receipt } }),
71
73
  };
72
74
  };
@@ -22,6 +22,17 @@ const extractStatus = (record) => {
22
22
  return undefined;
23
23
  };
24
24
  const nonEmptyString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
25
+ const toReceipt = (value) => {
26
+ const record = asRecord(value);
27
+ const accountId = nonEmptyString(record?.["accountId"]);
28
+ const revision = record?.["revision"];
29
+ const login = record?.["login"];
30
+ return accountId !== undefined &&
31
+ typeof revision === "number" &&
32
+ (login === "subscription" || login === "api-key")
33
+ ? { accountId, revision, login }
34
+ : undefined;
35
+ };
25
36
  export const toSealantError = (cause) => {
26
37
  if (cause instanceof SealantError) {
27
38
  return cause;
@@ -38,11 +49,13 @@ export const toSealantError = (cause) => {
38
49
  if (tag === "BudgetExceededError") {
39
50
  const budget = Schema.decodeUnknownOption(BudgetExceededError)(cause);
40
51
  if (Option.isSome(budget)) {
52
+ const receipt = toReceipt(record?.["receipt"]);
41
53
  return new SealantBudgetExceededError(message, {
42
54
  budget: budget.value.budget,
43
55
  limit: budget.value.limit,
44
56
  retryAfterSeconds: budget.value.retryAfterSeconds,
45
57
  ...(budget.value.refusal === undefined ? {} : { refusal: budget.value.refusal }),
58
+ ...(receipt === undefined ? {} : { receipt }),
46
59
  cause,
47
60
  });
48
61
  }
@@ -55,12 +68,14 @@ export const toSealantError = (cause) => {
55
68
  const candidateAccountIds = Array.isArray(candidates)
56
69
  ? candidates.filter((id) => typeof id === "string")
57
70
  : undefined;
71
+ const receipt = toReceipt(record?.["receipt"]);
58
72
  return new SealantApiError(message, {
59
73
  code: tag,
60
74
  ...(status === undefined ? {} : { status }),
61
75
  ...(reason === undefined ? {} : { reason }),
62
76
  ...(provider === undefined ? {} : { provider }),
63
77
  ...(candidateAccountIds === undefined ? {} : { candidateAccountIds }),
78
+ ...(receipt === undefined ? {} : { receipt }),
64
79
  cause,
65
80
  });
66
81
  }
package/dist/types.d.ts CHANGED
@@ -1490,6 +1490,11 @@ export interface SealantFeatures {
1490
1490
  * file an `apiKeyHelper` reads. A launch at `$HOME` still refuses a Claude key.
1491
1491
  */
1492
1492
  readonly connectedAccountApiKeys: boolean;
1493
+ /**
1494
+ * `allowedLogin` on `inference.respond()` (a key is refused when it says `subscription`),
1495
+ * `receipt` on its answers and errors, and inference on a Claude API key.
1496
+ */
1497
+ readonly inferenceAllowedLogin: boolean;
1493
1498
  }
1494
1499
  /** Tagged artifact facts reported by the control plane. */
1495
1500
  export type WorkspacePublication = WireWorkspacePublication;
@@ -2150,12 +2155,23 @@ export interface InferenceUsage {
2150
2155
  readonly inputTokens: number;
2151
2156
  readonly outputTokens: number;
2152
2157
  }
2158
+ /**
2159
+ * The login an exchange runs on, fixed when it starts: every continuation runs on it, even after
2160
+ * the account is reconnected. `revision` is the account's credential revision at the start.
2161
+ */
2162
+ export interface InferenceReceipt {
2163
+ readonly accountId: string;
2164
+ readonly revision: number;
2165
+ readonly login: "subscription" | "api-key";
2166
+ }
2153
2167
  export interface InferenceResponse {
2154
2168
  /** Continuation handle for the tool loop (held in memory server-side; expires after idle). */
2155
2169
  readonly sessionId: string;
2156
2170
  readonly turn: InferenceTurn;
2157
2171
  /** Usage for the exchange, present on the final text turn. */
2158
2172
  readonly usage?: InferenceUsage;
2173
+ /** The exchange's login; absent from a control plane without `features().inferenceAllowedLogin`. */
2174
+ readonly receipt?: InferenceReceipt;
2159
2175
  }
2160
2176
  /** Starts a new inference exchange on a connected account. */
2161
2177
  export interface InferenceRespondOptions {
@@ -2171,6 +2187,12 @@ export interface InferenceRespondOptions {
2171
2187
  readonly schema?: unknown;
2172
2188
  };
2173
2189
  readonly credentials: InferenceCredentialsOptions;
2190
+ /**
2191
+ * `subscription` refuses an account holding an API key before the provider is asked (a
2192
+ * `SealantApiError` with `reason` `login-not-allowed`); `any`, the default, runs on either.
2193
+ * `subscription` needs `features().inferenceAllowedLogin`; without it nothing is sent.
2194
+ */
2195
+ readonly allowedLogin?: "subscription" | "any";
2174
2196
  }
2175
2197
  /** Continues an exchange by posting the results of the previous turn's tool calls. */
2176
2198
  export interface InferenceContinueOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealant/sdk-next",
3
- "version": "0.40.0-next.813",
3
+ "version": "0.40.0-next.814",
4
4
  "description": "The fluent public SDK for Sealant — create a workspace, run a harness, replay the record.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,12 +26,12 @@
26
26
  "node": ">=20"
27
27
  },
28
28
  "dependencies": {
29
- "@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.813"
29
+ "@sealant/api-contracts": "npm:@sealant/api-contracts-next@0.40.0-next.814"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "effect": "^4.0.5"
33
33
  },
34
- "gitHead": "186c31b8393a0294caed6c80bfdf8afda7b1d31d",
34
+ "gitHead": "fcc1174e4f3a10476b1f7cbbe209734f557570e6",
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  }