@loomcycle/client 1.114.0 → 1.116.0

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/README.md CHANGED
@@ -596,6 +596,33 @@ const meta = await client.getCredential({ scope: "user", name: "GIT_TOKEN" });
596
596
  console.log(meta.allowed_urls ?? "unrestricted");
597
597
  ```
598
598
 
599
+ ### Crypto keys + the Crypto tool (RFC EP)
600
+
601
+ A **crypto key** is a credential with `usage: "crypto"`: a `key_type` fixed for its life, numbered versions, and a `min_version` below which versions are retired. No call ever returns key material. `getCredential` / `listCredentials` report a crypto key's `usage`, `key_type`, `current_version`, `min_version` and `versions` (`{version, created_at, retired}`).
602
+
603
+ | Method | Returns | Notes |
604
+ |---|---|---|
605
+ | `generateCryptoKey({ scope, name, key_type, expires_at? })` | `Promise<CredentialMeta>` | The server makes the material; nobody sees it. `{op: "generate"}`. |
606
+ | `createCryptoKey({ scope, name, key_type, value, key_encoding?, expires_at? })` | `Promise<CredentialMeta>` | Bring material you already have; `value` is write-only. `{op: "create", usage: "crypto"}`. |
607
+ | `createKmsCryptoKey({ scope, name, key_type, external, expires_at? })` | `Promise<CredentialMeta>` | Reference a key held in Vault Transit, AWS KMS or Google Cloud KMS (`external.backend`); only the reference is stored and every op is a KMS call. Credential fields are `$cred:<name>` in the key's scope. Rotate and retire it in the KMS. `{op: "create", usage: "crypto", backend, external}`. |
608
+ | `rotateCryptoKey({ scope, name, value?, key_encoding? })` | `Promise<CredentialMeta>` | Adds a version and makes it current (generated unless `value` is given). `{op: "rotate"}`. |
609
+ | `setCryptoKeyMinVersion({ scope, name, min_version })` | `Promise<CredentialMeta>` | Retires every version below it. Only goes up, at most to current+1. `{op: "set_min_version"}`. |
610
+ | `deleteCryptoKeyVersion({ scope, name, version })` | `Promise<CredentialMeta>` | Deletes one **retired** version. `{op: "delete_version"}`. |
611
+ | `exportCryptoKey({ scope, name, passphrase })` | `Promise<CryptoKeyExport>` | `{name, scope, blob}`: every version, encrypted under the passphrase (≥ 16 chars). Admin only, outside any run. `{op: "export_key"}`. |
612
+ | `importCryptoKey({ scope, name, blob, passphrase })` | `Promise<CredentialMeta>` | The other side of `exportCryptoKey`, under the same `name`. Admin only, outside any run. `{op: "import_key"}`. |
613
+
614
+ All post to `POST /v1/_credentialdef`. To delete a crypto key, retire every version (`min_version` = current+1), then `deleteCredential`.
615
+
616
+ `crypto(input)` runs one Crypto-tool operation outside any run (`POST /v1/_crypto`): `encrypt` / `decrypt` / `rewrap` / `mac` / `verify_mac` / `sign` / `verify` / `public_key` / `totp` with a held key (`key`, or `cred` + `key_type`), and `hash` / `random` with none. The input is a `CryptoRequest` discriminated by `op`, and the return type follows it (`CryptoResultByOp`). The reachable keys are the token's tenant's and its own subject's user keys; an admin may add `tenant` to use another tenant's keys. Needs `substrate:tenant` (a tenant member's token gets a 403). A refusal — including a failed decrypt, which never says why — raises `SubstrateToolRefusedError`; each call counts against the token's run-start rate, and a spent rate raises `RateLimitedError` (`retryAfterMs`).
617
+
618
+ ```ts
619
+ await client.generateCryptoKey({ scope: "tenant", name: "customer-fields", key_type: "aes-256-gcm" });
620
+ const { ciphertext } = await client.crypto({
621
+ op: "encrypt", key: "customer-fields", plaintext: card, context: "customer:42/card",
622
+ });
623
+ const { plaintext } = await client.crypto({ op: "decrypt", ciphertext, context: "customer:42/card" });
624
+ ```
625
+
599
626
  ### Evaluations
600
627
 
601
628
  Scores attached to runs: record a verdict on a run, read the scores back, and roll them up per definition version to compare versions. All of these post to `POST /v1/_evaluation`; `evaluation(input)` takes the op-discriminated input directly and its return type follows `op`.
@@ -519,8 +519,10 @@ class LoomcycleClient {
519
519
  *
520
520
  * Blocking by default: resolves only when the slowest child finishes (or
521
521
  * `timeoutMs` elapses). With `mode: "detach"` it resolves once every child
522
- * has started — each with `status: "running"` and its `run_id` — and the
523
- * runs go on; read one with {@link LoomcycleClient.getRun}. Mirrors
522
+ * has started or queued — each with `status: "running"` (or `"queued"` while
523
+ * it waits for a run slot; it starts by itself when one frees) and its
524
+ * `run_id` — and the runs go on; read one with
525
+ * {@link LoomcycleClient.getRun}. Mirrors
524
526
  * POST /v1/runs:batch.
525
527
  */
526
528
  async spawnRunBatch(opts) {
@@ -2938,6 +2940,101 @@ class LoomcycleClient {
2938
2940
  async deleteCredential(input, opts) {
2939
2941
  return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "delete", ...input }, opts);
2940
2942
  }
2943
+ // ── Crypto keys (RFC EP) ─────────────────────────────────────────────────
2944
+ //
2945
+ // A crypto key is a credential with usage "crypto": a key type fixed at
2946
+ // creation, numbered versions, and a min_version below which versions are
2947
+ // retired. Its material is never returned by any of these calls; the Crypto
2948
+ // tool (`crypto()` here, or an agent's Crypto tool) uses it by name. Each
2949
+ // returns the key's metadata (`CredentialMeta` with `usage`, `key_type`,
2950
+ // `versions`, `current_version`, `min_version`). Delete a key with
2951
+ // `deleteCredential` once every version is retired (min_version raised to
2952
+ // current+1). All post to `POST /v1/_credentialdef`.
2953
+ /** Make a new crypto key nobody ever sees: the server generates the
2954
+ * material. Version 1 is current. Mirrors `{op:generate}`. A name another
2955
+ * reachable scope already uses for a crypto key is refused
2956
+ * ({@link SubstrateToolRefusedError}), since a bare name would then be
2957
+ * ambiguous. */
2958
+ async generateCryptoKey(input, opts) {
2959
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "generate", ...input }, opts);
2960
+ }
2961
+ /** Store key material you already have as a crypto key (version 1). `value`
2962
+ * is write-only: masked from the transcript, never returned. Use this to
2963
+ * bring in an existing key; to move a key from another loomcycle
2964
+ * deployment use {@link importCryptoKey}. Mirrors
2965
+ * `{op:create, usage:"crypto"}`. */
2966
+ async createCryptoKey(input, opts) {
2967
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "create", usage: "crypto", ...input }, opts);
2968
+ }
2969
+ /** Reference a key held in an external KMS (Vault Transit, AWS KMS or
2970
+ * Google Cloud KMS) as a crypto key: loomcycle stores only where the key
2971
+ * is, and every Crypto op on it is a call to the KMS. The server asks the
2972
+ * KMS that the key exists, is enabled and is of `key_type` before storing
2973
+ * it. Rotate and retire such a key in the KMS; deleting it removes only
2974
+ * the reference. Mirrors `{op:create, usage:"crypto", backend, external}`. */
2975
+ async createKmsCryptoKey(input, opts) {
2976
+ const { backend, ...external } = input.external;
2977
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "create", usage: "crypto", ...input, backend, external }, opts);
2978
+ }
2979
+ /** Add a new version and make it current. Without `value` the server
2980
+ * generates it; with one, it is the new version's material (write-only).
2981
+ * Older versions keep decrypting and verifying until `min_version` passes
2982
+ * them; `rewrap` moves ciphertexts to the new version. Mirrors
2983
+ * `{op:rotate}`. */
2984
+ async rotateCryptoKey(input, opts) {
2985
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "rotate", ...input }, opts);
2986
+ }
2987
+ /** Retire every version below `min_version`: nothing decrypts or verifies
2988
+ * with them any more, and only they can be deleted. It only goes up, and
2989
+ * at most to current+1 (which retires every version — the step before
2990
+ * deleting the key). A lower value, or one past current+1, is refused
2991
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:set_min_version}`. */
2992
+ async setCryptoKeyMinVersion(input, opts) {
2993
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "set_min_version", ...input }, opts);
2994
+ }
2995
+ /** Delete one retired version (below `min_version`) and its material. A
2996
+ * version still in use is refused ({@link SubstrateToolRefusedError}).
2997
+ * Mirrors `{op:delete_version}`. */
2998
+ async deleteCryptoKeyVersion(input, opts) {
2999
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "delete_version", ...input }, opts);
3000
+ }
3001
+ /** Export a crypto key, every version of it, encrypted under `passphrase`
3002
+ * (at least 16 characters), to move it to another deployment with
3003
+ * {@link importCryptoKey}. The blob plus the passphrase IS the key: keep
3004
+ * them apart. Admin only (the legacy token, `substrate:admin`, or open
3005
+ * mode) and only outside a run; anyone else is refused
3006
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:export_key}`. */
3007
+ async exportCryptoKey(input, opts) {
3008
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "export_key", ...input }, opts);
3009
+ }
3010
+ /** Import what {@link exportCryptoKey} returned on another deployment, with
3011
+ * the passphrase it was exported with, into `scope`. `name` must be the
3012
+ * name it was exported under (the blob is bound to it); the server
3013
+ * refuses another. Versions and `min_version` come with it. Admin only
3014
+ * and outside a run, like export. Mirrors `{op:import_key}`. */
3015
+ async importCryptoKey(input, opts) {
3016
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_credentialdef", { op: "import_key", ...input }, opts);
3017
+ }
3018
+ /** Run one Crypto-tool operation outside any run (`POST /v1/_crypto`, RFC
3019
+ * EP): encrypt / decrypt / rewrap / mac / verify_mac / sign / verify /
3020
+ * public_key / totp with a key the runtime holds, or hash / random with
3021
+ * none. The return type follows `op`. Key material never leaves the
3022
+ * server.
3023
+ *
3024
+ * Keys reachable: the token's tenant's and its own subject's user keys
3025
+ * (agent keys belong to their agent's runs, and there are no `run`
3026
+ * credentials outside a run). An admin may pass `tenant` to use another
3027
+ * tenant's keys (and then no user keys). A ciphertext sealed here
3028
+ * decrypts in that tenant's runs, and the reverse.
3029
+ *
3030
+ * Needs `substrate:tenant`; a tenant member's or run token gets a 403. A
3031
+ * refusal (a wrong key name, a key type that does not do the op, a failed
3032
+ * decrypt — which never says why) raises {@link SubstrateToolRefusedError};
3033
+ * each call takes one from the token's run-start rate, and a spent rate
3034
+ * raises {@link RateLimitedError} with the server's `retryAfterMs`. */
3035
+ async crypto(input, opts) {
3036
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_crypto", input, opts);
3037
+ }
2941
3038
  }
2942
3039
  exports.LoomcycleClient = LoomcycleClient;
2943
3040
  /** Lightweight SSE parser tailored to the run-state stream. Each
package/dist/client.d.ts CHANGED
@@ -25,7 +25,7 @@
25
25
  */
26
26
  import { InteractiveSession } from "./interactive.js";
27
27
  import { ClientToolHost, type ConnectClientToolsOptions } from "./client-tools.js";
28
- import type { ChangeFeedFrame, StreamChangesOptions, CredentialListResponse, CredentialMeta, DecideRequest, DecideResponse, DecisionModelsResponse, CredentialScope, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResult, Agent, AgentEvent, AgentList, CancelAgentResult, ClientOptions, ContinueOptions, RunOverrideOptions, EffectiveConfigResponse, AgentOverridableResponse, RetuneRunResponse, RunConfigResponse, RunPromptResponse, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureHookDefOptions, EnsureHookDefResult, HookDefInput, HookDefOverlay, HookDefRowResponse, CreateDefOptions, ForkDefOptions, HookDefForkOverlay, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, WebhookDefInput, WebhookDefOverlay, WebhookDefRowResponse, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, InterruptListResponse, InterruptStatus, ListUserAgentsOptions, WalkRunsPage, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelPeekResult, TeamChannelReleaseResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, ReleaseChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, ListUserTokensResponse, RunnableAgentsResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEmbedStatsResponse, MemoryEntriesResponse, MemoryEntryResponse, MemoryBackfillResponse, MemoryPurgeResponse, MemoryReembedResponse, MemoryScopeIDsResponse, MemoryScopesResponse, MemorySearchInput, MemorySearchResponse, PauseResult, RetentionOverride, PersistentVolumesResponse, EphemeralVolumesResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunTreeDeletion, ReplaySessionResult, CancelTurnResult, ReviewRunResult, RunBatchOptions, RunBatchResult, RunOptions, ConfiguredRun, ConfiguredRunPatch, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, CreatedTeam, CreateTeamOptions, DefNamesResponse, ForkTeamOptions, ModelAliasesResponse, OperatorTokenDefNamesResponse, ProviderModelsResponse, RoutingResponse, ScheduleListResponse, SchedulePauseResult, ScheduleRunNowResult, ScheduleStateView, ListTeamsResponse, PromotedTeam, RetiredTeam, TeamBreakpoints, TeamDefDetail, TeamRunDetached, TeamRunTarget, TeamVerification, TeamDraft, TeamDraftVerification, TeamVersionList, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationAggregate, TranscriptResponse, WhoamiResponse, UsageDimension, UsageReportResponse, TokenLimit, TokenLimitsResponse, ConfigResponse, SetTokenLimitRequest } from "./types.js";
28
+ import type { ChangeFeedFrame, StreamChangesOptions, CredentialListResponse, CredentialMeta, CryptoKeyEncoding, CryptoKeyExport, CryptoKeyExternal, CryptoKeyType, CryptoRequest, CryptoResultByOp, DecideRequest, DecideResponse, DecisionModelsResponse, CredentialScope, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResult, Agent, AgentEvent, AgentList, CancelAgentResult, ClientOptions, ContinueOptions, RunOverrideOptions, EffectiveConfigResponse, AgentOverridableResponse, RetuneRunResponse, RunConfigResponse, RunPromptResponse, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureHookDefOptions, EnsureHookDefResult, HookDefInput, HookDefOverlay, HookDefRowResponse, CreateDefOptions, ForkDefOptions, HookDefForkOverlay, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, WebhookDefInput, WebhookDefOverlay, WebhookDefRowResponse, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, InterruptListResponse, InterruptStatus, ListUserAgentsOptions, WalkRunsPage, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelPeekResult, TeamChannelReleaseResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, ReleaseChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, ListUserTokensResponse, RunnableAgentsResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEmbedStatsResponse, MemoryEntriesResponse, MemoryEntryResponse, MemoryBackfillResponse, MemoryPurgeResponse, MemoryReembedResponse, MemoryScopeIDsResponse, MemoryScopesResponse, MemorySearchInput, MemorySearchResponse, PauseResult, RetentionOverride, PersistentVolumesResponse, EphemeralVolumesResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunTreeDeletion, ReplaySessionResult, CancelTurnResult, ReviewRunResult, RunBatchOptions, RunBatchResult, RunOptions, ConfiguredRun, ConfiguredRunPatch, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, CreatedTeam, CreateTeamOptions, DefNamesResponse, ForkTeamOptions, ModelAliasesResponse, OperatorTokenDefNamesResponse, ProviderModelsResponse, RoutingResponse, ScheduleListResponse, SchedulePauseResult, ScheduleRunNowResult, ScheduleStateView, ListTeamsResponse, PromotedTeam, RetiredTeam, TeamBreakpoints, TeamDefDetail, TeamRunDetached, TeamRunTarget, TeamVerification, TeamDraft, TeamDraftVerification, TeamVersionList, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationAggregate, TranscriptResponse, WhoamiResponse, UsageDimension, UsageReportResponse, TokenLimit, TokenLimitsResponse, ConfigResponse, SetTokenLimitRequest } from "./types.js";
29
29
  export declare class LoomcycleClient {
30
30
  private ctx;
31
31
  constructor(opts?: ClientOptions);
@@ -244,8 +244,10 @@ export declare class LoomcycleClient {
244
244
  *
245
245
  * Blocking by default: resolves only when the slowest child finishes (or
246
246
  * `timeoutMs` elapses). With `mode: "detach"` it resolves once every child
247
- * has started — each with `status: "running"` and its `run_id` — and the
248
- * runs go on; read one with {@link LoomcycleClient.getRun}. Mirrors
247
+ * has started or queued — each with `status: "running"` (or `"queued"` while
248
+ * it waits for a run slot; it starts by itself when one frees) and its
249
+ * `run_id` — and the runs go on; read one with
250
+ * {@link LoomcycleClient.getRun}. Mirrors
249
251
  * POST /v1/runs:batch.
250
252
  */
251
253
  spawnRunBatch(opts: RunBatchOptions): Promise<RunBatchResult>;
@@ -2008,4 +2010,128 @@ export declare class LoomcycleClient {
2008
2010
  scope: string;
2009
2011
  deleted: boolean;
2010
2012
  }>;
2013
+ /** Make a new crypto key nobody ever sees: the server generates the
2014
+ * material. Version 1 is current. Mirrors `{op:generate}`. A name another
2015
+ * reachable scope already uses for a crypto key is refused
2016
+ * ({@link SubstrateToolRefusedError}), since a bare name would then be
2017
+ * ambiguous. */
2018
+ generateCryptoKey(input: {
2019
+ scope: CredentialScope;
2020
+ name: string;
2021
+ key_type: CryptoKeyType;
2022
+ expires_at?: string;
2023
+ }, opts?: {
2024
+ signal?: AbortSignal;
2025
+ }): Promise<CredentialMeta>;
2026
+ /** Store key material you already have as a crypto key (version 1). `value`
2027
+ * is write-only: masked from the transcript, never returned. Use this to
2028
+ * bring in an existing key; to move a key from another loomcycle
2029
+ * deployment use {@link importCryptoKey}. Mirrors
2030
+ * `{op:create, usage:"crypto"}`. */
2031
+ createCryptoKey(input: {
2032
+ scope: CredentialScope;
2033
+ name: string;
2034
+ key_type: CryptoKeyType;
2035
+ value: string;
2036
+ key_encoding?: CryptoKeyEncoding;
2037
+ expires_at?: string;
2038
+ }, opts?: {
2039
+ signal?: AbortSignal;
2040
+ }): Promise<CredentialMeta>;
2041
+ /** Reference a key held in an external KMS (Vault Transit, AWS KMS or
2042
+ * Google Cloud KMS) as a crypto key: loomcycle stores only where the key
2043
+ * is, and every Crypto op on it is a call to the KMS. The server asks the
2044
+ * KMS that the key exists, is enabled and is of `key_type` before storing
2045
+ * it. Rotate and retire such a key in the KMS; deleting it removes only
2046
+ * the reference. Mirrors `{op:create, usage:"crypto", backend, external}`. */
2047
+ createKmsCryptoKey(input: {
2048
+ scope: CredentialScope;
2049
+ name: string;
2050
+ key_type: CryptoKeyType;
2051
+ external: CryptoKeyExternal;
2052
+ expires_at?: string;
2053
+ }, opts?: {
2054
+ signal?: AbortSignal;
2055
+ }): Promise<CredentialMeta>;
2056
+ /** Add a new version and make it current. Without `value` the server
2057
+ * generates it; with one, it is the new version's material (write-only).
2058
+ * Older versions keep decrypting and verifying until `min_version` passes
2059
+ * them; `rewrap` moves ciphertexts to the new version. Mirrors
2060
+ * `{op:rotate}`. */
2061
+ rotateCryptoKey(input: {
2062
+ scope: CredentialScope;
2063
+ name: string;
2064
+ value?: string;
2065
+ key_encoding?: CryptoKeyEncoding;
2066
+ }, opts?: {
2067
+ signal?: AbortSignal;
2068
+ }): Promise<CredentialMeta>;
2069
+ /** Retire every version below `min_version`: nothing decrypts or verifies
2070
+ * with them any more, and only they can be deleted. It only goes up, and
2071
+ * at most to current+1 (which retires every version — the step before
2072
+ * deleting the key). A lower value, or one past current+1, is refused
2073
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:set_min_version}`. */
2074
+ setCryptoKeyMinVersion(input: {
2075
+ scope: CredentialScope;
2076
+ name: string;
2077
+ min_version: number;
2078
+ }, opts?: {
2079
+ signal?: AbortSignal;
2080
+ }): Promise<CredentialMeta>;
2081
+ /** Delete one retired version (below `min_version`) and its material. A
2082
+ * version still in use is refused ({@link SubstrateToolRefusedError}).
2083
+ * Mirrors `{op:delete_version}`. */
2084
+ deleteCryptoKeyVersion(input: {
2085
+ scope: CredentialScope;
2086
+ name: string;
2087
+ version: number;
2088
+ }, opts?: {
2089
+ signal?: AbortSignal;
2090
+ }): Promise<CredentialMeta>;
2091
+ /** Export a crypto key, every version of it, encrypted under `passphrase`
2092
+ * (at least 16 characters), to move it to another deployment with
2093
+ * {@link importCryptoKey}. The blob plus the passphrase IS the key: keep
2094
+ * them apart. Admin only (the legacy token, `substrate:admin`, or open
2095
+ * mode) and only outside a run; anyone else is refused
2096
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:export_key}`. */
2097
+ exportCryptoKey(input: {
2098
+ scope: CredentialScope;
2099
+ name: string;
2100
+ passphrase: string;
2101
+ }, opts?: {
2102
+ signal?: AbortSignal;
2103
+ }): Promise<CryptoKeyExport>;
2104
+ /** Import what {@link exportCryptoKey} returned on another deployment, with
2105
+ * the passphrase it was exported with, into `scope`. `name` must be the
2106
+ * name it was exported under (the blob is bound to it); the server
2107
+ * refuses another. Versions and `min_version` come with it. Admin only
2108
+ * and outside a run, like export. Mirrors `{op:import_key}`. */
2109
+ importCryptoKey(input: {
2110
+ scope: CredentialScope;
2111
+ name: string;
2112
+ blob: string;
2113
+ passphrase: string;
2114
+ }, opts?: {
2115
+ signal?: AbortSignal;
2116
+ }): Promise<CredentialMeta>;
2117
+ /** Run one Crypto-tool operation outside any run (`POST /v1/_crypto`, RFC
2118
+ * EP): encrypt / decrypt / rewrap / mac / verify_mac / sign / verify /
2119
+ * public_key / totp with a key the runtime holds, or hash / random with
2120
+ * none. The return type follows `op`. Key material never leaves the
2121
+ * server.
2122
+ *
2123
+ * Keys reachable: the token's tenant's and its own subject's user keys
2124
+ * (agent keys belong to their agent's runs, and there are no `run`
2125
+ * credentials outside a run). An admin may pass `tenant` to use another
2126
+ * tenant's keys (and then no user keys). A ciphertext sealed here
2127
+ * decrypts in that tenant's runs, and the reverse.
2128
+ *
2129
+ * Needs `substrate:tenant`; a tenant member's or run token gets a 403. A
2130
+ * refusal (a wrong key name, a key type that does not do the op, a failed
2131
+ * decrypt — which never says why) raises {@link SubstrateToolRefusedError};
2132
+ * each call takes one from the token's run-start rate, and a spent rate
2133
+ * raises {@link RateLimitedError} with the server's `retryAfterMs`. */
2134
+ crypto<R extends CryptoRequest>(input: R, opts?: {
2135
+ signal?: AbortSignal;
2136
+ }): Promise<CryptoResultByOp[R["op"]]>;
2011
2137
  }
package/dist/client.js CHANGED
@@ -516,8 +516,10 @@ export class LoomcycleClient {
516
516
  *
517
517
  * Blocking by default: resolves only when the slowest child finishes (or
518
518
  * `timeoutMs` elapses). With `mode: "detach"` it resolves once every child
519
- * has started — each with `status: "running"` and its `run_id` — and the
520
- * runs go on; read one with {@link LoomcycleClient.getRun}. Mirrors
519
+ * has started or queued — each with `status: "running"` (or `"queued"` while
520
+ * it waits for a run slot; it starts by itself when one frees) and its
521
+ * `run_id` — and the runs go on; read one with
522
+ * {@link LoomcycleClient.getRun}. Mirrors
521
523
  * POST /v1/runs:batch.
522
524
  */
523
525
  async spawnRunBatch(opts) {
@@ -2935,6 +2937,101 @@ export class LoomcycleClient {
2935
2937
  async deleteCredential(input, opts) {
2936
2938
  return postJSON(this.ctx, "/v1/_credentialdef", { op: "delete", ...input }, opts);
2937
2939
  }
2940
+ // ── Crypto keys (RFC EP) ─────────────────────────────────────────────────
2941
+ //
2942
+ // A crypto key is a credential with usage "crypto": a key type fixed at
2943
+ // creation, numbered versions, and a min_version below which versions are
2944
+ // retired. Its material is never returned by any of these calls; the Crypto
2945
+ // tool (`crypto()` here, or an agent's Crypto tool) uses it by name. Each
2946
+ // returns the key's metadata (`CredentialMeta` with `usage`, `key_type`,
2947
+ // `versions`, `current_version`, `min_version`). Delete a key with
2948
+ // `deleteCredential` once every version is retired (min_version raised to
2949
+ // current+1). All post to `POST /v1/_credentialdef`.
2950
+ /** Make a new crypto key nobody ever sees: the server generates the
2951
+ * material. Version 1 is current. Mirrors `{op:generate}`. A name another
2952
+ * reachable scope already uses for a crypto key is refused
2953
+ * ({@link SubstrateToolRefusedError}), since a bare name would then be
2954
+ * ambiguous. */
2955
+ async generateCryptoKey(input, opts) {
2956
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "generate", ...input }, opts);
2957
+ }
2958
+ /** Store key material you already have as a crypto key (version 1). `value`
2959
+ * is write-only: masked from the transcript, never returned. Use this to
2960
+ * bring in an existing key; to move a key from another loomcycle
2961
+ * deployment use {@link importCryptoKey}. Mirrors
2962
+ * `{op:create, usage:"crypto"}`. */
2963
+ async createCryptoKey(input, opts) {
2964
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "create", usage: "crypto", ...input }, opts);
2965
+ }
2966
+ /** Reference a key held in an external KMS (Vault Transit, AWS KMS or
2967
+ * Google Cloud KMS) as a crypto key: loomcycle stores only where the key
2968
+ * is, and every Crypto op on it is a call to the KMS. The server asks the
2969
+ * KMS that the key exists, is enabled and is of `key_type` before storing
2970
+ * it. Rotate and retire such a key in the KMS; deleting it removes only
2971
+ * the reference. Mirrors `{op:create, usage:"crypto", backend, external}`. */
2972
+ async createKmsCryptoKey(input, opts) {
2973
+ const { backend, ...external } = input.external;
2974
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "create", usage: "crypto", ...input, backend, external }, opts);
2975
+ }
2976
+ /** Add a new version and make it current. Without `value` the server
2977
+ * generates it; with one, it is the new version's material (write-only).
2978
+ * Older versions keep decrypting and verifying until `min_version` passes
2979
+ * them; `rewrap` moves ciphertexts to the new version. Mirrors
2980
+ * `{op:rotate}`. */
2981
+ async rotateCryptoKey(input, opts) {
2982
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "rotate", ...input }, opts);
2983
+ }
2984
+ /** Retire every version below `min_version`: nothing decrypts or verifies
2985
+ * with them any more, and only they can be deleted. It only goes up, and
2986
+ * at most to current+1 (which retires every version — the step before
2987
+ * deleting the key). A lower value, or one past current+1, is refused
2988
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:set_min_version}`. */
2989
+ async setCryptoKeyMinVersion(input, opts) {
2990
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "set_min_version", ...input }, opts);
2991
+ }
2992
+ /** Delete one retired version (below `min_version`) and its material. A
2993
+ * version still in use is refused ({@link SubstrateToolRefusedError}).
2994
+ * Mirrors `{op:delete_version}`. */
2995
+ async deleteCryptoKeyVersion(input, opts) {
2996
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "delete_version", ...input }, opts);
2997
+ }
2998
+ /** Export a crypto key, every version of it, encrypted under `passphrase`
2999
+ * (at least 16 characters), to move it to another deployment with
3000
+ * {@link importCryptoKey}. The blob plus the passphrase IS the key: keep
3001
+ * them apart. Admin only (the legacy token, `substrate:admin`, or open
3002
+ * mode) and only outside a run; anyone else is refused
3003
+ * ({@link SubstrateToolRefusedError}). Mirrors `{op:export_key}`. */
3004
+ async exportCryptoKey(input, opts) {
3005
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "export_key", ...input }, opts);
3006
+ }
3007
+ /** Import what {@link exportCryptoKey} returned on another deployment, with
3008
+ * the passphrase it was exported with, into `scope`. `name` must be the
3009
+ * name it was exported under (the blob is bound to it); the server
3010
+ * refuses another. Versions and `min_version` come with it. Admin only
3011
+ * and outside a run, like export. Mirrors `{op:import_key}`. */
3012
+ async importCryptoKey(input, opts) {
3013
+ return postJSON(this.ctx, "/v1/_credentialdef", { op: "import_key", ...input }, opts);
3014
+ }
3015
+ /** Run one Crypto-tool operation outside any run (`POST /v1/_crypto`, RFC
3016
+ * EP): encrypt / decrypt / rewrap / mac / verify_mac / sign / verify /
3017
+ * public_key / totp with a key the runtime holds, or hash / random with
3018
+ * none. The return type follows `op`. Key material never leaves the
3019
+ * server.
3020
+ *
3021
+ * Keys reachable: the token's tenant's and its own subject's user keys
3022
+ * (agent keys belong to their agent's runs, and there are no `run`
3023
+ * credentials outside a run). An admin may pass `tenant` to use another
3024
+ * tenant's keys (and then no user keys). A ciphertext sealed here
3025
+ * decrypts in that tenant's runs, and the reverse.
3026
+ *
3027
+ * Needs `substrate:tenant`; a tenant member's or run token gets a 403. A
3028
+ * refusal (a wrong key name, a key type that does not do the op, a failed
3029
+ * decrypt — which never says why) raises {@link SubstrateToolRefusedError};
3030
+ * each call takes one from the token's run-start rate, and a spent rate
3031
+ * raises {@link RateLimitedError} with the server's `retryAfterMs`. */
3032
+ async crypto(input, opts) {
3033
+ return postJSON(this.ctx, "/v1/_crypto", input, opts);
3034
+ }
2938
3035
  }
2939
3036
  /** Lightweight SSE parser tailored to the run-state stream. Each
2940
3037
  * frame's event name distinguishes the two kinds; data is JSON.
package/dist/index.d.ts CHANGED
@@ -176,5 +176,5 @@ export { verifyLoomcycleSignature, verifyLoomcycleDelivery } from "./signature.j
176
176
  export type { VerifySignatureOptions, VerifiedDelivery } from "./signature.js";
177
177
  export { ClientToolHost, clientToolsURL, CLIENT_TOOL_SUBPROTOCOL } from "./client-tools.js";
178
178
  export type { ClientToolSchema, ClientToolInvocation, ConnectClientToolsOptions, WebSocketLike, WebSocketCtor, } from "./client-tools.js";
179
- export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, RunOverrideOptions, SamplingOptions, CompactionOptions, ContextOptions, ToolUse, Usage, CallTiming, Agent, AgentStatus, AwaitedState, AgentUsage, RunResult, RunSpec, RunSpecTeam, ConfiguredRun, ConfiguredRunPatch, ToolChoiceOptions, OutputFormatOptions, CancelAgentResult, ListAgentsResponse, ListUserAgentsOptions, AgentList, WalkRunsPage, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, RunTreeDeletion, RunTreeNotReached, DirectoryBudget, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchInput, MemorySource, MemoryWhen, MemoryTimeFilter, MemorySearchEntry, MemorySearchResponse, MemoryEmbedModelStats, MemoryEmbedStatsResponse, MemoryReembedConfigured, MemoryReembedResponse, MemoryBackfillResponse, MemoryPurgeResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, ChannelHookCall, ChannelHookResult, HookFailMode, HookPhase, HookToolCall, HookToolResult, PostHookCall, PostHookResult, PreHookCall, PreHookResult, SubstrateToolInput, SubstrateToolResponse, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, PromotedTeam, RetiredTeam, TeamDefDetail, TeamVerification, TeamDraft, TeamDraftVerification, TeamIssue, TeamIssueKind, TeamVersion, TeamVersionList, TeamBreakpoints, TeamRunDetached, TeamRunResult, TeamRunTarget, CreateTeamOptions, ForkTeamOptions, DefNameSummary, DefNamesResponse, OperatorTokenDefNameSummary, OperatorTokenDefNamesResponse, ScheduleListEntry, ScheduleListResponse, ScheduleActiveRun, ScheduleStateView, ScheduleRunNowResult, SchedulePauseResult, ModelAlias, ModelAliasesResponse, RoutingResponse, RoutingUserTier, RoutingTier, RoutingCandidate, RoutingThroughput, RoutingProvider, SearchRoutingProvider, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationEmitterRole, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationScoreStats, EvaluationAggregate, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, ChangeFeedError, ChangeFeedFrame, ChangeFeedStatus, EmbedderHealth, MemoryChange, MemoryChangeScope, MemoryChangeType, StreamChangesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelReleaseResult, TeamChannelDeclaredIn, TeamChannelDescriptor, TeamChannelPeekResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, ReleaseChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, AgentRouting, AgentChannelACL, AgentInterruptionACL, AgentDecision, MemoryRerank, AgentSampling, AgentCompaction, AgentContext, TierCandidate, CoreBlock, HookEvent, InlineWebhook, HookEntry, EventHooks, ToolEntry, ToolHooksByTool, EnsureCodeAgentOptions, EnsureCodeAgentResult, CreateDefOptions, ForkDefOptions, EnsureHookDefOptions, EnsureHookDefResult, HookDefBody, HookDefForkOverlay, HookDefInput, HookDefMatch, HookDefOverlay, HookDefRowResponse, HookDefVerifyResult, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, ScheduledRunHook, ScheduledRunPromptContent, ScheduledRunPromptSegment, WebhookDefAuth, WebhookDefFilter, WebhookDefInput, WebhookDefOverlay, WebhookDefRateLimit, WebhookDefRowResponse, WebhookDefDeliveries, WebhookDefSyncResponse, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, UsageDimension, UsageAggregate, UsageReportResponse, CapabilityInertInfo, LimitInfo, AdmissionInfo, ErrorInfo, CallFormat, CallRef, HookDecisionInfo, TeamDecisionInfo, OverrideInfo, FallbackInfo, InterruptionEventInfo, SpawnChildInfo, TurnCancelledInfo, ChannelEventInfo, ContextCompactionInfo, ContextRecapInfo, ContextStateInfo, ContextExhaustedInfo, ContextTierVerdict, ContextDistillDeclinedInfo, EffectiveConfigResponse, EffectiveConfigSource, EffectiveValue, InertContextSetting, AgentOverridableResponse, OverridableField, OverrideLockReason, RetuneRunResponse, RunConfigRecord, SubagentHoldInfo, RunConfigResponse, RunPromptResponse, RunPromptSnapshot, PromptBlock, TokenLimit, TokenLimitsResponse, ConfigResponse, ConfigProvider, ConfigModel, ConfigSearch, ConfigInstance, SetTokenLimitRequest, CredentialScope, CredentialMeta, CredentialListResponse, DecideRequest, DecideResponse, DecisionQuestion, DecisionChoiceQuestion, DecisionNoulQuestion, DecisionScoreQuestion, DecisionAnswer, DecisionChoiceAnswer, DecisionNoulAnswer, DecisionScoreAnswer, DecisionModel, DecisionModelsResponse, } from "./types.js";
179
+ export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, RunOverrideOptions, SamplingOptions, CompactionOptions, ContextOptions, ToolUse, Usage, CallTiming, Agent, AgentStatus, AwaitedState, AgentUsage, RunResult, RunSpec, RunSpecTeam, ConfiguredRun, ConfiguredRunPatch, ToolChoiceOptions, OutputFormatOptions, CancelAgentResult, ListAgentsResponse, ListUserAgentsOptions, AgentList, WalkRunsPage, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, RunTreeDeletion, RunTreeNotReached, DirectoryBudget, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchInput, MemorySource, MemoryWhen, MemoryTimeFilter, MemorySearchEntry, MemorySearchResponse, MemoryEmbedModelStats, MemoryEmbedStatsResponse, MemoryReembedConfigured, MemoryReembedResponse, MemoryBackfillResponse, MemoryPurgeResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, ChannelHookCall, ChannelHookResult, HookFailMode, HookPhase, HookToolCall, HookToolResult, PostHookCall, PostHookResult, PreHookCall, PreHookResult, SubstrateToolInput, SubstrateToolResponse, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, PromotedTeam, RetiredTeam, TeamDefDetail, TeamVerification, TeamDraft, TeamDraftVerification, TeamIssue, TeamIssueKind, TeamVersion, TeamVersionList, TeamBreakpoints, TeamRunDetached, TeamRunResult, TeamRunTarget, CreateTeamOptions, ForkTeamOptions, DefNameSummary, DefNamesResponse, OperatorTokenDefNameSummary, OperatorTokenDefNamesResponse, ScheduleListEntry, ScheduleListResponse, ScheduleActiveRun, ScheduleStateView, ScheduleRunNowResult, SchedulePauseResult, ModelAlias, ModelAliasesResponse, RoutingResponse, RoutingUserTier, RoutingTier, RoutingCandidate, RoutingThroughput, RoutingProvider, SearchRoutingProvider, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationEmitterRole, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationScoreStats, EvaluationAggregate, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, ChangeFeedError, ChangeFeedFrame, ChangeFeedStatus, EmbedderHealth, MemoryChange, MemoryChangeScope, MemoryChangeType, StreamChangesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelReleaseResult, TeamChannelDeclaredIn, TeamChannelDescriptor, TeamChannelPeekResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, ReleaseChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, AgentRouting, AgentChannelACL, AgentInterruptionACL, AgentDecision, MemoryRerank, AgentSampling, AgentCompaction, AgentContext, TierCandidate, CoreBlock, HookEvent, InlineWebhook, HookEntry, EventHooks, ToolEntry, ToolHooksByTool, EnsureCodeAgentOptions, EnsureCodeAgentResult, CreateDefOptions, ForkDefOptions, EnsureHookDefOptions, EnsureHookDefResult, HookDefBody, HookDefForkOverlay, HookDefInput, HookDefMatch, HookDefOverlay, HookDefRowResponse, HookDefVerifyResult, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, ScheduledRunHook, ScheduledRunPromptContent, ScheduledRunPromptSegment, WebhookDefAuth, WebhookDefFilter, WebhookDefInput, WebhookDefOverlay, WebhookDefRateLimit, WebhookDefRowResponse, WebhookDefDeliveries, WebhookDefSyncResponse, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, UsageDimension, UsageAggregate, UsageReportResponse, CapabilityInertInfo, LimitInfo, AdmissionInfo, ErrorInfo, CallFormat, CallRef, HookDecisionInfo, TeamDecisionInfo, OverrideInfo, FallbackInfo, InterruptionEventInfo, SpawnChildInfo, TurnCancelledInfo, ChannelEventInfo, ContextCompactionInfo, ContextRecapInfo, ContextStateInfo, ContextExhaustedInfo, ContextTierVerdict, ContextDistillDeclinedInfo, EffectiveConfigResponse, EffectiveConfigSource, EffectiveValue, InertContextSetting, AgentOverridableResponse, OverridableField, OverrideLockReason, RetuneRunResponse, RunConfigRecord, SubagentHoldInfo, RunConfigResponse, RunPromptResponse, RunPromptSnapshot, PromptBlock, TokenLimit, TokenLimitsResponse, ConfigResponse, ConfigProvider, ConfigModel, ConfigSearch, ConfigInstance, SetTokenLimitRequest, CredentialScope, CredentialMeta, CredentialListResponse, CryptoKeyVersion, CryptoKeyExport, CryptoKeyType, CryptoKeyEncoding, CryptoKeyBackend, CryptoKeyExternal, CryptoOp, CryptoRequestBase, CryptoKeyRef, CryptoEncryptRequest, CryptoDecryptRequest, CryptoRewrapRequest, CryptoMacRequest, CryptoVerifyMacRequest, CryptoSignRequest, CryptoVerifyRequest, CryptoPublicKeyRequest, CryptoTotpRequest, CryptoHashRequest, CryptoRandomRequest, CryptoHashPasswordRequest, CryptoVerifyPasswordRequest, CryptoRequest, CryptoEncryptResult, CryptoDecryptResult, CryptoRewrapResult, CryptoMacResult, CryptoVerifyResult, CryptoSignResult, CryptoPublicJWK, CryptoPublicKeyResult, CryptoTotpResult, CryptoHashResult, CryptoRandomResult, CryptoHashPasswordResult, CryptoVerifyPasswordResult, CryptoResultByOp, CryptoResult, DecideRequest, DecideResponse, DecisionQuestion, DecisionChoiceQuestion, DecisionNoulQuestion, DecisionScoreQuestion, DecisionAnswer, DecisionChoiceAnswer, DecisionNoulAnswer, DecisionScoreAnswer, DecisionModel, DecisionModelsResponse, } from "./types.js";
180
180
  export { AgentIDInUseError, AgentNotFoundError, AlreadyPausingError, AuthError, BackpressureError, NotFoundError, InsufficientScopeError, InvalidArgumentError, ChannelCursorRegressionError, LoomcycleError, NotPausedError, PauseNotConfiguredError, PerUserQuotaExhaustedError, PromptTooLargeError, RateLimitedError, RequestTooLargeError, SessionBusyError, SessionNotFoundError, SnapshotNotFoundError, SnapshotTooLargeError, SnapshotVersionError, SubstrateToolRefusedError, TokenLimitExceededError, UnavailableError, } from "./errors.js";
package/dist/types.d.ts CHANGED
@@ -1492,6 +1492,10 @@ export interface RunSpec {
1492
1492
  * replica that does not hold it; its own replica reads it before it
1493
1493
  * reaps the child as idle. */
1494
1494
  addressed_at?: number;
1495
+ /** The parent run's Crypto key scopes at spawn — the ceiling the child's
1496
+ * own `crypto_scopes` were narrowed to, and are narrowed to again on
1497
+ * resume. Absent: the parent held none. */
1498
+ crypto_scopes?: string[];
1495
1499
  };
1496
1500
  /** The iteration limit the run started with. Absent for a run with none
1497
1501
  * (unbounded, or an interactive run with no `max_iterations` of its own)
@@ -1668,9 +1672,10 @@ export interface CancelAgentResult {
1668
1672
  export interface RunBatchOptions {
1669
1673
  spawns: RunOptions[];
1670
1674
  /** "join" (default) — block until all children settle, returning the
1671
- * combined envelope. "detach" — resolve once every child has started:
1672
- * each started child reports `status: "running"` with its `run_id`, keeps
1673
- * running after the call, and is read with {@link LoomcycleClient.getRun}
1675
+ * combined envelope. "detach" — resolve once every child has started or
1676
+ * queued: each reports `status: "running"` (or `"queued"` while it waits
1677
+ * for a run slot, starting by itself when one frees) with its `run_id`,
1678
+ * goes on after the call, and is read with {@link LoomcycleClient.getRun}
1674
1679
  * and stopped with {@link LoomcycleClient.cancelAgent}; a child that could
1675
1680
  * not start is reported in its slot, as in join. */
1676
1681
  mode?: "join" | "detach";
@@ -4146,6 +4151,11 @@ export interface AgentDefOverlay {
4146
4151
  /** Evaluation tool scope gate, e.g. `["submit_self", "read_any"]`. The
4147
4152
  * Evaluation tool default-denies until granted. */
4148
4153
  evaluation_scopes?: string[];
4154
+ /** Crypto tool key scopes the agent's key-backed ops may use: `agent` |
4155
+ * `user` | `tenant` | `run`. Unset (or `["-*"]`) grants none — keyless ops
4156
+ * only. Held to the author's own grant; a sub-agent holds only what its
4157
+ * parent run also holds. */
4158
+ crypto_scopes?: string[];
4149
4159
  /** Channel tool ACL (default-deny until set). */
4150
4160
  channels?: AgentChannelACL;
4151
4161
  /** Interruption tool gate — `enabled: true` REQUIRED for the tool to work. */
@@ -4464,6 +4474,9 @@ export interface ScheduledRunPromptContent {
4464
4474
  * input. */
4465
4475
  type?: "trusted-text" | "untrusted-block";
4466
4476
  text: string;
4477
+ /** An untrusted-block's source label, as on a run's segments; `"code"`
4478
+ * keeps the text exactly as written. Default `"untrusted"`. */
4479
+ kind?: string;
4467
4480
  }
4468
4481
  /** One segment of a scheduled run's prompt. */
4469
4482
  export interface ScheduledRunPromptSegment {
@@ -5219,12 +5232,336 @@ export interface CredentialMeta {
5219
5232
  /** The user name sent with the value where a destination takes one (HTTP
5220
5233
  * basic auth for a git source). Absent when none is stored. */
5221
5234
  username?: string;
5235
+ /** Present with `expires_at`: true once that time has passed. An expired
5236
+ * credential is kept so it can be seen and rotated, but resolves nowhere. */
5237
+ expired?: boolean;
5238
+ /** `"crypto"` for a key the Crypto tool uses (RFC EP); absent for an
5239
+ * ordinary secret. The fields below are present only for a crypto key. */
5240
+ usage?: "crypto";
5241
+ /** The crypto key's type, fixed for its life. */
5242
+ key_type?: CryptoKeyType;
5243
+ /** The external KMS holding the key; absent for a key held by loomcycle.
5244
+ * Such a key's versions are the KMS's, rotated and retired there. */
5245
+ key_backend?: CryptoKeyBackend;
5246
+ /** The version new encryptions and signatures use. */
5247
+ current_version?: number;
5248
+ /** The lowest version still used; every version below it is retired. */
5249
+ min_version?: number;
5250
+ /** Every stored version, never its material. */
5251
+ versions?: CryptoKeyVersion[];
5252
+ }
5253
+ /** One version of a crypto key: when it was made and whether it is retired
5254
+ * (below `min_version` — nothing decrypts or verifies with it, and only a
5255
+ * retired version can be deleted). */
5256
+ export interface CryptoKeyVersion {
5257
+ version: number;
5258
+ /** RFC3339. */
5259
+ created_at: string;
5260
+ retired: boolean;
5222
5261
  }
5223
5262
  /** CredentialListResponse is the {op:list} result: metadata for the given scope. */
5224
5263
  export interface CredentialListResponse {
5225
5264
  scope: string;
5226
5265
  credentials: CredentialMeta[];
5227
5266
  }
5267
+ /** What {@link LoomcycleClient.exportCryptoKey} returns: the key, every
5268
+ * version of it, encrypted under the passphrase. Hand `blob` and the
5269
+ * passphrase to {@link LoomcycleClient.importCryptoKey} on the other
5270
+ * deployment. Anyone holding both holds the key. */
5271
+ export interface CryptoKeyExport {
5272
+ name: string;
5273
+ scope: string;
5274
+ blob: string;
5275
+ }
5276
+ /** A crypto key's type. AEAD (`aes-256-gcm`, `xchacha20-poly1305`):
5277
+ * encrypt / decrypt / rewrap. HMAC (`hmac-sha256`, `hmac-sha512`): mac /
5278
+ * verify_mac, and sign / verify as a JWS. Signing (`ed25519`, `ecdsa-p256`,
5279
+ * `rsa-pss-*`): sign / verify / public_key. Recipient (`x25519`,
5280
+ * `rsa-oaep-*`): encrypt (a JWE to its public half) / decrypt / public_key.
5281
+ * `totp`: totp. An RSA key either signs or decrypts, never both. */
5282
+ export type CryptoKeyType = "aes-256-gcm" | "xchacha20-poly1305" | "hmac-sha256" | "hmac-sha512" | "ed25519" | "ecdsa-p256" | "totp" | "x25519" | "rsa-oaep-2048" | "rsa-oaep-3072" | "rsa-oaep-4096" | "rsa-pss-2048" | "rsa-pss-3072" | "rsa-pss-4096";
5283
+ /** An external KMS that can hold a crypto key. */
5284
+ export type CryptoKeyBackend = "vault" | "aws_kms" | "gcp_kms";
5285
+ /** Where a key held in an external KMS lives, for
5286
+ * {@link LoomcycleClient.createKmsCryptoKey}. Each credential field is a
5287
+ * `$cred:<name>` reference to an ordinary credential in the same scope as
5288
+ * the key; loomcycle stores only the reference. */
5289
+ export type CryptoKeyExternal = {
5290
+ /** Vault Transit. The address's host must be on the operator's host
5291
+ * allowlist. */
5292
+ backend: "vault";
5293
+ address: string;
5294
+ /** The Transit mount (default `transit`). */
5295
+ mount?: string;
5296
+ /** The Transit key name. */
5297
+ key: string;
5298
+ namespace?: string;
5299
+ /** `$cred:<name>` holding a Vault token. */
5300
+ token: string;
5301
+ } | {
5302
+ backend: "aws_kms";
5303
+ region: string;
5304
+ /** A key id, key ARN, `alias/<name>` or alias ARN. */
5305
+ key_id: string;
5306
+ access_key_id: string;
5307
+ secret_access_key: string;
5308
+ session_token?: string;
5309
+ } | {
5310
+ backend: "gcp_kms";
5311
+ /** `projects/<p>/locations/<l>/keyRings/<r>/cryptoKeys/<k>`, optionally
5312
+ * `/cryptoKeyVersions/<n>` (signing and RSA keys only). */
5313
+ key: string;
5314
+ /** `$cred:<name>` holding a service-account key JSON. */
5315
+ service_account: string;
5316
+ };
5317
+ /** How key material handed in as a string is written. Default by key type:
5318
+ * base64 for AEAD and HMAC, base32 for totp, pem for the asymmetric types. */
5319
+ export type CryptoKeyEncoding = "raw" | "base64" | "hex" | "base32" | "pem";
5320
+ /** The Crypto tool's operations. */
5321
+ export type CryptoOp = "encrypt" | "decrypt" | "rewrap" | "mac" | "verify_mac" | "sign" | "verify" | "public_key" | "totp" | "hash" | "random" | "hash_password" | "verify_password";
5322
+ /** The fields every {@link CryptoRequest} may carry. */
5323
+ export interface CryptoRequestBase {
5324
+ /** Admin only (or the legacy token, or open mode): run the op with another
5325
+ * tenant's keys. It then reaches that tenant's keys and no user keys. A
5326
+ * non-admin naming a tenant other than its own is refused. */
5327
+ tenant?: string;
5328
+ }
5329
+ /** Which key an op uses: exactly one of `key` (a crypto key stored with
5330
+ * CredentialDef — type and versions come with it), `cred` (an ordinary
5331
+ * stored credential used as key material — needs `key_type`) or `run` (a
5332
+ * credential a run's caller passed; there is none outside a run, so the
5333
+ * operator API refuses it). Outside a run the reachable stored keys are the
5334
+ * token's tenant's and its own subject's user keys. */
5335
+ export interface CryptoKeyRef {
5336
+ key?: string;
5337
+ cred?: string;
5338
+ run?: string;
5339
+ /** `key` and `cred`: which scope's key, when more than one reachable scope
5340
+ * holds that name. An envelope already records it. */
5341
+ key_scope?: "agent" | "user" | "tenant";
5342
+ /** `cred` and `run`: what kind of key the value is. */
5343
+ key_type?: CryptoKeyType;
5344
+ /** `cred` and `run`: how the value is written. */
5345
+ key_encoding?: CryptoKeyEncoding;
5346
+ /** `cred` and `run`: derive an AEAD or HMAC key from any secret instead of
5347
+ * reading the value as a key. */
5348
+ derive?: boolean;
5349
+ /** `key` only: a version, for public_key or a raw ciphertext. Default: the
5350
+ * current one (decrypt of a raw ciphertext tries every usable version). */
5351
+ version?: number;
5352
+ }
5353
+ export interface CryptoEncryptRequest extends CryptoRequestBase, CryptoKeyRef {
5354
+ op: "encrypt";
5355
+ /** Text, or base64 bytes with `input_encoding: "base64"`. */
5356
+ plaintext: string;
5357
+ input_encoding?: "text" | "base64";
5358
+ /** Associated data: the ciphertext decrypts only with the same context.
5359
+ * Not with a JWE, which carries none. */
5360
+ context?: string;
5361
+ /** `envelope` (default for symmetric keys, names its key), `raw` (base64
5362
+ * nonce+ct+tag) or `jwe` (aes-256-gcm; the only form for an x25519 or
5363
+ * rsa-oaep key and for `public_key`). */
5364
+ format?: "envelope" | "raw" | "jwe";
5365
+ /** A PEM or JWK X25519 or RSA public key to encrypt to, in place of a held
5366
+ * key: the result is a JWE only that key's holder can open. */
5367
+ public_key?: string;
5368
+ }
5369
+ export interface CryptoDecryptRequest extends CryptoRequestBase, CryptoKeyRef {
5370
+ op: "decrypt";
5371
+ /** Exactly as encrypt returned it: an envelope, raw base64 or a JWE. An
5372
+ * envelope from a crypto key names its key, so `key` / `cred` / `run` may
5373
+ * be left out. */
5374
+ ciphertext: string;
5375
+ context?: string;
5376
+ /** Keeps the plaintext out of a run's stored transcript. */
5377
+ sensitive?: boolean;
5378
+ /** `text` (default when the plaintext is UTF-8) or `base64`. */
5379
+ output_encoding?: "text" | "base64";
5380
+ }
5381
+ export interface CryptoRewrapRequest extends CryptoRequestBase, CryptoKeyRef {
5382
+ op: "rewrap";
5383
+ /** A crypto key's ciphertext; `key` is needed only for a raw one. */
5384
+ ciphertext: string;
5385
+ context?: string;
5386
+ }
5387
+ export interface CryptoMacRequest extends CryptoRequestBase, CryptoKeyRef {
5388
+ op: "mac";
5389
+ data: string;
5390
+ input_encoding?: "text" | "base64";
5391
+ /** `hex` (default) or `base64`. */
5392
+ output_encoding?: "hex" | "base64";
5393
+ }
5394
+ export interface CryptoVerifyMacRequest extends CryptoRequestBase, CryptoKeyRef {
5395
+ op: "verify_mac";
5396
+ data: string;
5397
+ /** The MAC to check, hex or base64, with any `sha256=` prefix stripped. */
5398
+ mac: string;
5399
+ input_encoding?: "text" | "base64";
5400
+ }
5401
+ export interface CryptoSignRequest extends CryptoRequestBase, CryptoKeyRef {
5402
+ op: "sign";
5403
+ /** What to sign; for a JWS, the token's payload. */
5404
+ data: string;
5405
+ input_encoding?: "text" | "base64";
5406
+ /** `raw` (default for signing keys) or `jws` (the only form for a MAC key). */
5407
+ format?: "raw" | "jws";
5408
+ }
5409
+ export interface CryptoVerifyRequest extends CryptoRequestBase, CryptoKeyRef {
5410
+ op: "verify";
5411
+ /** A raw base64 signature, or a JWS token (then leave `data` out). */
5412
+ signature: string;
5413
+ data?: string;
5414
+ input_encoding?: "text" | "base64";
5415
+ /** A PEM or JWK Ed25519, P-256 or RSA (PS256) public key, in place of a
5416
+ * held key. */
5417
+ public_key?: string;
5418
+ }
5419
+ export interface CryptoPublicKeyRequest extends CryptoRequestBase, CryptoKeyRef {
5420
+ op: "public_key";
5421
+ }
5422
+ export interface CryptoTotpRequest extends CryptoRequestBase, CryptoKeyRef {
5423
+ op: "totp";
5424
+ /** Code length, 6 to 8 (default 6). */
5425
+ digits?: number;
5426
+ /** Seconds per code (default 30). */
5427
+ period?: number;
5428
+ }
5429
+ /** A digest; needs no key. Never a password store. */
5430
+ export interface CryptoHashRequest extends CryptoRequestBase {
5431
+ op: "hash";
5432
+ data: string;
5433
+ input_encoding?: "text" | "base64";
5434
+ /** Default `sha256`. */
5435
+ algorithm?: "sha256" | "sha512" | "sha3-256" | "sha3-512";
5436
+ /** `hex` (default) or `base64`. */
5437
+ output_encoding?: "hex" | "base64";
5438
+ }
5439
+ /** Secure random values; needs no key. */
5440
+ export interface CryptoRandomRequest extends CryptoRequestBase {
5441
+ op: "random";
5442
+ /** `token` (default, URL-safe base64 without padding), `bytes` or `uuid`. */
5443
+ kind?: "token" | "bytes" | "uuid";
5444
+ /** Random bytes for `token` and `bytes`, 1 to 4096 (default 32). */
5445
+ length?: number;
5446
+ /** `bytes` only: `hex` (default) or `base64`. */
5447
+ output_encoding?: "hex" | "base64";
5448
+ }
5449
+ /** An Argon2id hash of a password to store; needs no key. */
5450
+ export interface CryptoHashPasswordRequest extends CryptoRequestBase {
5451
+ op: "hash_password";
5452
+ /** Up to 1024 bytes. */
5453
+ password: string;
5454
+ }
5455
+ /** Checks a password against a hash from hash_password; needs no key. */
5456
+ export interface CryptoVerifyPasswordRequest extends CryptoRequestBase {
5457
+ op: "verify_password";
5458
+ password: string;
5459
+ /** Exactly as hash_password returned it. */
5460
+ password_hash: string;
5461
+ }
5462
+ /** The body of {@link LoomcycleClient.crypto}, discriminated by `op`. */
5463
+ export type CryptoRequest = CryptoEncryptRequest | CryptoDecryptRequest | CryptoRewrapRequest | CryptoMacRequest | CryptoVerifyMacRequest | CryptoSignRequest | CryptoVerifyRequest | CryptoPublicKeyRequest | CryptoTotpRequest | CryptoHashRequest | CryptoRandomRequest | CryptoHashPasswordRequest | CryptoVerifyPasswordRequest;
5464
+ /** `key_version` on a result is the crypto key version used; 0 for a `cred`
5465
+ * or `run` key, which has no versions. */
5466
+ export interface CryptoEncryptResult {
5467
+ /** An envelope (`lcx1:…`), base64 with `format: "raw"`, or a compact JWE. */
5468
+ ciphertext: string;
5469
+ /** `"jwe"` when the ciphertext is a JWE. */
5470
+ format?: "jwe";
5471
+ /** Absent when encrypting to a `public_key`. */
5472
+ key_version?: number;
5473
+ }
5474
+ export interface CryptoDecryptResult {
5475
+ plaintext: string;
5476
+ /** How `plaintext` is written. */
5477
+ encoding: "text" | "base64";
5478
+ key_version: number;
5479
+ }
5480
+ export interface CryptoRewrapResult {
5481
+ /** Store it in place of the old ciphertext. A JWE stays a JWE. */
5482
+ ciphertext: string;
5483
+ format?: "jwe";
5484
+ from_version: number;
5485
+ key_version: number;
5486
+ }
5487
+ export interface CryptoMacResult {
5488
+ mac: string;
5489
+ key_version: number;
5490
+ }
5491
+ /** verify_mac and verify. `valid: false` never says why and carries no
5492
+ * `key_version`. */
5493
+ export interface CryptoVerifyResult {
5494
+ valid: boolean;
5495
+ /** The held key's version that verified. */
5496
+ key_version?: number;
5497
+ /** verify of a JWS token: its `kid` header. */
5498
+ kid?: string;
5499
+ /** verify of a JWS token: its payload. */
5500
+ payload?: string;
5501
+ }
5502
+ export interface CryptoSignResult {
5503
+ signature: string;
5504
+ format: "raw" | "jws";
5505
+ key_version: number;
5506
+ }
5507
+ /** A public key as a JWK: `OKP`/`Ed25519` or `OKP`/`X25519` (x), `EC`/`P-256`
5508
+ * (x, y) or `RSA` (n, e). The `kid` matches the `kid` in tokens the key signs
5509
+ * or JWEs made to it; an RSA or X25519 key also names its `use` and `alg`. */
5510
+ export interface CryptoPublicJWK {
5511
+ kty: "OKP" | "EC" | "RSA";
5512
+ crv?: "Ed25519" | "X25519" | "P-256";
5513
+ x?: string;
5514
+ y?: string;
5515
+ n?: string;
5516
+ e?: string;
5517
+ use?: "sig" | "enc";
5518
+ alg?: "PS256" | "RSA-OAEP-256" | "ECDH-ES";
5519
+ kid?: string;
5520
+ }
5521
+ export interface CryptoPublicKeyResult {
5522
+ pem: string;
5523
+ jwk: CryptoPublicJWK;
5524
+ key_version: number;
5525
+ }
5526
+ export interface CryptoTotpResult {
5527
+ code: string;
5528
+ /** RFC3339. */
5529
+ valid_until: string;
5530
+ }
5531
+ export interface CryptoHashResult {
5532
+ algorithm: string;
5533
+ digest: string;
5534
+ }
5535
+ export interface CryptoRandomResult {
5536
+ kind: "token" | "bytes" | "uuid";
5537
+ value: string;
5538
+ }
5539
+ export interface CryptoHashPasswordResult {
5540
+ /** A PHC string (`$argon2id$v=19$m=…,t=…,p=…$salt$hash`), safe to store. */
5541
+ password_hash: string;
5542
+ algorithm: "argon2id";
5543
+ }
5544
+ export interface CryptoVerifyPasswordResult {
5545
+ valid: boolean;
5546
+ }
5547
+ /** The result type of each Crypto op. */
5548
+ export interface CryptoResultByOp {
5549
+ encrypt: CryptoEncryptResult;
5550
+ decrypt: CryptoDecryptResult;
5551
+ rewrap: CryptoRewrapResult;
5552
+ mac: CryptoMacResult;
5553
+ verify_mac: CryptoVerifyResult;
5554
+ sign: CryptoSignResult;
5555
+ verify: CryptoVerifyResult;
5556
+ public_key: CryptoPublicKeyResult;
5557
+ totp: CryptoTotpResult;
5558
+ hash: CryptoHashResult;
5559
+ random: CryptoRandomResult;
5560
+ hash_password: CryptoHashPasswordResult;
5561
+ verify_password: CryptoVerifyPasswordResult;
5562
+ }
5563
+ /** Any Crypto op's result. */
5564
+ export type CryptoResult = CryptoResultByOp[CryptoOp];
5228
5565
  /** A `choice` question: pick one of the options. Each key of `criteria` is an
5229
5566
  * option and its value describes it, or is `null` when the key explains
5230
5567
  * itself. The key is what comes back as the answer. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/client",
3
- "version": "1.114.0",
3
+ "version": "1.116.0",
4
4
  "description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 71 methods covering run streaming, agent metadata, pause/resume/state, resolver re-probe (resolveProbe — issue #88 operator escape hatch), operator-token admin (operatorTokenDef — RFC L OSS multi-tenant auth) + whoami (RFC L authoritative principal, v0.17.0) + tenant-scoped listUsers / listUserAgents, dynamic MCP registration (mcpServerDef + v0.18.0 typed mcpServerDefVerify + ensureMcpServer idempotent register-if-changed), snapshot lifecycle, memory admin (incl. v0.9.0 Vector Memory embed_stats + reembed AND v0.11.5 setMemoryEntry + deleteMemoryEntry), interruption resolve, hook management, v0.8.22 substrate admin (agentDef + skillDef), v0.9.x n8n Phase 0 (listChannels + streamUserRunStates), v0.9.x Channel CRUD (publishChannel + subscribeChannel + peekChannel + ackChannel), v0.11.5 Channel admin CRUD (createChannel + updateChannel + deleteChannel — runtime substrate; yaml channels refuse mutation with HTTP 409), v0.9.x content_sha256 verify, v0.9.1 transcript first-cycle, v0.9.x dynamic MCP server registration (mcpServerDef + MCPServerDefVerifyResult), v0.10.3 Library v2 enumeration (listLibraryAgents + listLibrarySkills + listLibraryMcpServers), and v0.11.0 LLM Gateway (llmChat + llmStream — direct provider routing without agent overhead; primary target is n8n's LoomCycleChatModel AI Agent sub-node and any LangChain-compatible consumer). v0.10.1 — dual ESM + CommonJS distribution (additive — ESM consumers unchanged; CJS consumers like n8n's community-node loader now work). v0.19.0 — typed inline code-js agent ingestion (AgentDefOverlay.code_body + ensureCodeAgent — register a deterministic code agent through the substrate with no host filesystem bind; RFC J). v0.20.0 — ensureMcpServer surfaces discoveredToolCount straight from create (loomcycle now auto-discovers MCP tools at ingestion); rediscover is now an explicit force-refresh. v0.21.0 — run/continue accept optional non-secret `metadata` (repo name, review policy, …) passed to the agent, symmetric with the WebHook/Schedule trigger paths. v0.22.0 — version-aligned lockstep release; no client-surface change (RFC N tenant isolation of the agent/skill/MCP/Schedule/Webhook definition plane + real op-schemas on the builtin MCP meta-tools are both server-side). v0.23.0 — version-aligned lockstep release; no client-surface change (RFCs O/P/R MCP-server hardening + thin client and the RFC Q DeepSeek tool-content fix are all server-side / MCP-transport-side). v0.24.0 — purgeChannel clears a channel's buffered messages without deleting its definition (allowed on yaml-declared channels too, unlike deleteChannel — F20); AgentDefOverlay gains channels / evaluation_scopes / interruption so a COMPLETE interactive/multi-agent agent round-trips over the substrate (F14). (Consolidates the interim 0.24/0.25 package bumps, which were never tag-published, back into lockstep with the loomcycle v0.24.0 tag.) v0.25.0 — adds the RFC S channel fan-in/fan-out client twins: awaitChannels() (wait for any/all/at_least N messages across channels, or a timeout — non-committing) + broadcastChannels() (publish one payload to N channels in one atomic-pre-flight call), the client-facing counterparts of the in-band Channel.await / Channel.broadcast tool ops (the rest of v0.25.0 — the manual-management Web UI console + Context op=time + max_fires self-retiring schedules — is server-side / in-band, no client-surface change). v0.29.1 — Usage gains optional `max_context_tokens` (the serving model's context-window ceiling, stamped by the loop from Provider.Capabilities() on each usage event) so a consumer can render a 'context used / max' gauge without a hard-coded per-model table; additive + optional, no behavior change. (Lockstep catch-up: the field landed in loomcycle v0.29.0 but the adapter publish skipped on a version mismatch; v0.29.1 realigns the package version with the release tag so it publishes.) v0.33.0 — gRPC + TS client parity for the RFC Y external fan-out and the compaction surface: spawnRunBatch() (POST /v1/runs:batch — spawn up to 32 fresh runs concurrently in one call, combined index-aligned envelope, per-child failures in-envelope) + compactRun(runId) (POST /v1/runs/{run_id}/compact — summarize a parked run's context); plus per-run sampling + compaction overrides now accepted on runStreaming / continueSession (an explicit temperature 0 is preserved as deterministic, not dropped as falsy). (The gRPC half adds the matching SpawnRunBatch / CompactRun RPCs + the sampling/compaction fields on RunRequest/ContinueRequest — server-side.) v0.34.0 — version-aligned lockstep release; no client-surface change (context-transform plugins / RFC Z Phase 1a are server-side config; the exp7 hardening pass is server-side; the R2 cross-provider thinking-model downgrade surfaces a new `model_downgraded` SSE event the generic stream passes through unchanged). v0.35.0 — RFC AH dynamic filesystem volumes: volumeDef() (POST /v1/_volumedef — op-discriminated create/get/list/delete/purge; a Volume is flat, so delete unmaps + purge RemoveAll's, no retire/promote/fork) + listVolumes() / listEphemeralVolumes() (GET /v1/_volumes[/ephemeral] — tenant-scoped; host paths redacted for non-operator callers). Tenant-confined; the runtime derives the path inside an operator-blessed dynamic_root, so callers pass name + mode, never a host path. v1.1.1 — RFC AI interactive agentic sessions: an `interactive: true` flag on runStreaming/continueSession (a run that parks at end_turn for steering) + sendRunInput(runId, text) (POST /v1/runs/{id}/input — steer a live run) + streamRunByID(runId, {fromSeq}) (GET /v1/runs/{id}/stream — re-attach by run_id; the operator's prior turns replay as `steer` events so a cold client reconstructs the whole conversation) + a high-level InteractiveSession driver (client.interactiveSession / attachInteractiveSession — events()/send()/cancel(), the adapter port of the Web UI run terminal). The AgentEvent union gains awaiting_input/steer/context_compaction frames. Version-aligned with the loomcycle v1.1.x line so the v1.1.1 tag publishes it (also carrying the previously-unpublished v0.35.0 volume surface). v1.4.0 — RFC AL Path VFS + RFC AK Document on the wire: path(input) (POST /v1/_path — a Unix-like filesystem over Memory/Volumes/Documents; resolve/ls/stat/mkdir/mv/rm) + document(input) (POST /v1/_document — chunked-graph documents; 13 ops, needs SQL Memory on the sidecar). Scope (agent/user/tenant) + tenant are resolved server-side from the authenticated principal, never the wire; an off-run scope:'user' op keys on the principal subject so it interoperates with that user's agent runs. New PathToolInput / DocumentToolInput types; responses are op-varying (unknown — narrow as needed). v1.7.0 — RFC AT image/vision input: the PromptContent union gains an `image` variant ({ type:'image'; media_type: ImageMediaType; data: base64-no-prefix }) accepted in a user segment by runStreaming / continueSession (segments pass through unchanged — no method change). The model must be vision-capable or the run errors before the call. New ImageMediaType type (image/png|jpeg|gif|webp). v1.12.1 — Path/Document browse-by-subject + the full Document op set (RFC AS/AK): path(input, opts) / document(input, opts) accept optional scopeId / tenant browse overrides sent as ?scope_id= / ?tenant= query params (server reads them from the URL, re-checks authorization; omit both to browse your own subject — byte-identical to the pre-RFC-AS request), and DocumentToolInput.op now covers all 16 backend ops (adds set_path, export_md, import_md) with the matching include_metadata / markdown fields. Additive — existing path() / document() callers are unchanged. v1.16.0 — RFC BC client-executed tools (local tool host): connectClientTools({tools,onInvoke}) opens a persistent WebSocket to /v1/client-tools, registers tools this client runs on the user's machine (browser DOM / files / shell), and answers the invoke frames loomcycle routes when an agent of your principal calls a client:<tool> — returning your reply as an ordinary tool result. Returns a ClientToolHost driver (.close() to stop; auto-reconnect); dependency-free (global WebSocket in browsers / Node 22+, or an injected WebSocketImpl like the ws package on older Node); the bearer rides the Sec-WebSocket-Protocol subprotocol (browsers can't set an Authorization header on a WebSocket). The runtime's first WebSocket surface. v1.45.0 — RFC BL P5 subject erasure: erasureReport(subject, {tenant}) (GET /v1/_erasure — what this deployment holds about one subject, in three tiers: deletable with existing primitives, subject-keyed but not deletable, and facts ABOUT the subject in scopes they do not own) + erasureExecute(subject, {dryRun, confirm, tenant}) (POST /v1/_erasure — removes tiers 1 and 2). DEFAULTS TO A DRY RUN: dryRun defaults true and a live run also requires confirm === subject. The tier-3 residue is traceable only through the subject's chats, which a live run deletes, so a report afterwards shows rows: 0 while those facts remain — the returned object is the only durable record of what was not reached; persist it. New ErasureReport / ErasureResult / ErasureTier / ErasureResidue types. v1.47.0 — RFC BV memory-view SDK: memorySearch() (POST /v1/_memory/search — off-run unified semantic search spanning k/v entries AND document-chunk bodies in one ranked list, each hit tagged kind memory|document with chunk_id on document hits) + memoryEmbedStats(scope) + reembedMemory(scope, scopeId, {dryRun,limit}) (the Vector Memory embed-admin reads the memory-view console needs; dry_run defaults true). Fact reads (list_facts + get_chunk's entity block) ride the existing document() passthrough. Additive — existing callers unchanged. v1.61.0 — RFC CJ per-run context-window override: runStreaming / continueSession accept an optional maxContextTokens (integer tokens) that wins over the agent's own max_context_tokens; omitted inherits it (which defers to the provider/driver default). Distinct from a model's output cap; primarily for local inference (Ollama num_ctx). Serialized as the snake_case max_context_tokens field on POST /v1/runs + the continuation body; additive, existing callers unchanged. v1.72.1 — the TeamDef version lifecycle: listTeamVersions(name) (op=list — every version of one team, newest first), promoteTeam(defId) (op=promote — point the active pointer, which is what a run BY NAME executes; forkTeam defaults to promote:false, so authoring and putting in force stay two steps), retireTeam(defId, retired) (op=retire — reversible and version-scoped, unlike deleteTeam) and verifyTeam(name, contentSha256) (op=verify — the drift check for a workflow kept in source control and pushed to several deployments; an absent team answers deployed:false rather than raising). The ops existed on the substrate and over HTTP; a client that could author a team could not put one in force.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",