@loomcycle/client 1.124.0 → 1.125.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/dist/cjs/client.js +72 -2
- package/dist/client.d.ts +32 -3
- package/dist/client.js +72 -2
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +86 -6
- package/package.json +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -446,6 +446,51 @@ class LoomcycleClient {
|
|
|
446
446
|
async getEffectiveConfig(runId, opts) {
|
|
447
447
|
return (0, fetch_helpers_js_1.jsonFetch)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/effective-config`, opts);
|
|
448
448
|
}
|
|
449
|
+
/** Run one File-tool op on a run's inbox from outside the run — the files the
|
|
450
|
+
* run's tools returned. Mirrors `POST /v1/runs/{run_id}/file`, the HTTP twin
|
|
451
|
+
* of the MCP `file` tool. Ops: stat, ls, extract, import, keep, rm, clear.
|
|
452
|
+
* The response is the op's own JSON (narrow as needed).
|
|
453
|
+
*
|
|
454
|
+
* Needs `runs:read`, and works on any run you can read; another tenant's run
|
|
455
|
+
* is an opaque {@link NotFoundError}. extract, keep, rm and clear write, so
|
|
456
|
+
* they need the run's owner or an admin — a tenant operator counts as one
|
|
457
|
+
* for its own tenant's runs; anyone else gets a
|
|
458
|
+
* {@link SubstrateToolRefusedError}, as does a refused op. */
|
|
459
|
+
async runFile(runId, input, opts) {
|
|
460
|
+
return (0, fetch_helpers_js_1.postJSON)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/file`, input, opts);
|
|
461
|
+
}
|
|
462
|
+
/** Download one file of a run's inbox. Mirrors
|
|
463
|
+
* `GET /v1/runs/{run_id}/inbox/{path}` (HEAD with `head: true`). `path` is
|
|
464
|
+
* relative to the inbox root (`documents/a.pdf`) or a reference
|
|
465
|
+
* (`volume:inbox:documents/a.pdf`).
|
|
466
|
+
*
|
|
467
|
+
* Any reader of the run may download (`runs:read`). `range` is sent as the
|
|
468
|
+
* Range header (`bytes=0-1023`). The inbox is deleted when its run ends, so
|
|
469
|
+
* a finished run's file — like a missing file, run, or another tenant's run —
|
|
470
|
+
* is a {@link NotFoundError}. */
|
|
471
|
+
async downloadRunInboxFile(runId, path, opts) {
|
|
472
|
+
const rel = path.replace(/^volume:inbox:/, "");
|
|
473
|
+
const encoded = rel.split("/").map(encodeURIComponent).join("/");
|
|
474
|
+
const headers = {};
|
|
475
|
+
if (this.ctx.authToken)
|
|
476
|
+
headers.Authorization = `Bearer ${this.ctx.authToken}`;
|
|
477
|
+
if (opts?.range)
|
|
478
|
+
headers.Range = opts.range;
|
|
479
|
+
const resp = await this.ctx.fetchImpl(`${this.ctx.baseUrl}/v1/runs/${encodeURIComponent(runId)}/inbox/${encoded}`, { method: opts?.head ? "HEAD" : "GET", headers, signal: opts?.signal });
|
|
480
|
+
if (!resp.ok) {
|
|
481
|
+
await (0, fetch_helpers_js_1.raiseFromResponse)(resp);
|
|
482
|
+
}
|
|
483
|
+
const bytes = opts?.head ? new Uint8Array() : new Uint8Array(await resp.arrayBuffer());
|
|
484
|
+
return {
|
|
485
|
+
bytes,
|
|
486
|
+
status: resp.status,
|
|
487
|
+
contentType: resp.headers.get("Content-Type") ?? "",
|
|
488
|
+
filename: dispositionFilename(resp.headers.get("Content-Disposition")) ?? rel.split("/").pop() ?? "",
|
|
489
|
+
sha256: resp.headers.get("X-Loomcycle-SHA256") ?? "",
|
|
490
|
+
origin: resp.headers.get("X-Loomcycle-Origin") ?? "",
|
|
491
|
+
headers: resp.headers,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
449
494
|
/** Which per-run overrides a run of `name` may set, for this caller — what a
|
|
450
495
|
* run form needs before it sends anything. Mirrors
|
|
451
496
|
* `GET /v1/_agentdef/{name}/overridable`.
|
|
@@ -799,8 +844,10 @@ class LoomcycleClient {
|
|
|
799
844
|
return { agents: resp.agents ?? [], next_cursor: resp.next_cursor ?? "" };
|
|
800
845
|
}
|
|
801
846
|
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
802
|
-
* tenant/user/provider/model/source over an optional time window;
|
|
803
|
-
* `source` for the operator-vs-tenant split
|
|
847
|
+
* tenant/user/provider/model/source/purpose over an optional time window;
|
|
848
|
+
* group by `source` for the operator-vs-tenant split, by `purpose` to see
|
|
849
|
+
* what OCR and speech-to-text cost (a row's `audio_seconds` is the audio its
|
|
850
|
+
* speech-to-text calls transcribed). Tenant-scoped server-side: a
|
|
804
851
|
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
805
852
|
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
806
853
|
async usageReport(opts) {
|
|
@@ -1275,6 +1322,12 @@ class LoomcycleClient {
|
|
|
1275
1322
|
body.document_ids = input.documentIds;
|
|
1276
1323
|
if (input.excludeDocumentIds !== undefined)
|
|
1277
1324
|
body.exclude_document_ids = input.excludeDocumentIds;
|
|
1325
|
+
// The second scope's documents: sent only when set, so a one-scope search's
|
|
1326
|
+
// response stays byte-identical (no per-entry `scope`).
|
|
1327
|
+
if (input.documentsScope !== undefined)
|
|
1328
|
+
body.documents_scope = input.documentsScope;
|
|
1329
|
+
if (input.documentsScopeId !== undefined)
|
|
1330
|
+
body.documents_scope_id = input.documentsScopeId;
|
|
1278
1331
|
return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_memory/search", body, {
|
|
1279
1332
|
signal: opts?.signal,
|
|
1280
1333
|
});
|
|
@@ -3219,6 +3272,23 @@ class LoomcycleClient {
|
|
|
3219
3272
|
}
|
|
3220
3273
|
}
|
|
3221
3274
|
exports.LoomcycleClient = LoomcycleClient;
|
|
3275
|
+
/** The file name of an RFC 8187 `filename*=UTF-8''…` Content-Disposition, or
|
|
3276
|
+
* a plain quoted `filename="…"`; undefined when there is neither. */
|
|
3277
|
+
function dispositionFilename(header) {
|
|
3278
|
+
if (!header)
|
|
3279
|
+
return undefined;
|
|
3280
|
+
const star = /filename\*=UTF-8''([^;]+)/i.exec(header);
|
|
3281
|
+
if (star) {
|
|
3282
|
+
try {
|
|
3283
|
+
return decodeURIComponent(star[1].trim());
|
|
3284
|
+
}
|
|
3285
|
+
catch {
|
|
3286
|
+
return undefined;
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
const plain = /filename="([^"]*)"/i.exec(header);
|
|
3290
|
+
return plain ? plain[1] : undefined;
|
|
3291
|
+
}
|
|
3222
3292
|
/** Lightweight SSE parser tailored to the run-state stream. Each
|
|
3223
3293
|
* frame's event name distinguishes the two kinds; data is JSON.
|
|
3224
3294
|
* Comment lines (": keepalive") are ignored. */
|
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, 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, AclBinding, AclBindingListResponse, AclCatalog, AclDefInput, AclDefListResponse, AclDefNamesResponse, AclDefRow, AclRule, AclValidateResult, AuthzDecision, AuthzEvaluationRequest, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzExplainResponse, AuthzSimulateRequest, AuthzSimulateResponse, CreateAclBindingBody, CreateGroupBody, GroupDetail, GroupEffective, GroupListResponse, GroupMemberChange, GroupMemberKind, GroupRow } 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, RunFileInput, RunInboxDownload, 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, AclBinding, AclBindingListResponse, AclCatalog, AclDefInput, AclDefListResponse, AclDefNamesResponse, AclDefRow, AclRule, AclValidateResult, AuthzDecision, AuthzEvaluationRequest, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzExplainResponse, AuthzSimulateRequest, AuthzSimulateResponse, CreateAclBindingBody, CreateGroupBody, GroupDetail, GroupEffective, GroupListResponse, GroupMemberChange, GroupMemberKind, GroupRow } from "./types.js";
|
|
29
29
|
export declare class LoomcycleClient {
|
|
30
30
|
private ctx;
|
|
31
31
|
constructor(opts?: ClientOptions);
|
|
@@ -183,6 +183,33 @@ export declare class LoomcycleClient {
|
|
|
183
183
|
getEffectiveConfig(runId: string, opts?: {
|
|
184
184
|
signal?: AbortSignal;
|
|
185
185
|
}): Promise<EffectiveConfigResponse>;
|
|
186
|
+
/** Run one File-tool op on a run's inbox from outside the run — the files the
|
|
187
|
+
* run's tools returned. Mirrors `POST /v1/runs/{run_id}/file`, the HTTP twin
|
|
188
|
+
* of the MCP `file` tool. Ops: stat, ls, extract, import, keep, rm, clear.
|
|
189
|
+
* The response is the op's own JSON (narrow as needed).
|
|
190
|
+
*
|
|
191
|
+
* Needs `runs:read`, and works on any run you can read; another tenant's run
|
|
192
|
+
* is an opaque {@link NotFoundError}. extract, keep, rm and clear write, so
|
|
193
|
+
* they need the run's owner or an admin — a tenant operator counts as one
|
|
194
|
+
* for its own tenant's runs; anyone else gets a
|
|
195
|
+
* {@link SubstrateToolRefusedError}, as does a refused op. */
|
|
196
|
+
runFile<T = unknown>(runId: string, input: RunFileInput, opts?: {
|
|
197
|
+
signal?: AbortSignal;
|
|
198
|
+
}): Promise<T>;
|
|
199
|
+
/** Download one file of a run's inbox. Mirrors
|
|
200
|
+
* `GET /v1/runs/{run_id}/inbox/{path}` (HEAD with `head: true`). `path` is
|
|
201
|
+
* relative to the inbox root (`documents/a.pdf`) or a reference
|
|
202
|
+
* (`volume:inbox:documents/a.pdf`).
|
|
203
|
+
*
|
|
204
|
+
* Any reader of the run may download (`runs:read`). `range` is sent as the
|
|
205
|
+
* Range header (`bytes=0-1023`). The inbox is deleted when its run ends, so
|
|
206
|
+
* a finished run's file — like a missing file, run, or another tenant's run —
|
|
207
|
+
* is a {@link NotFoundError}. */
|
|
208
|
+
downloadRunInboxFile(runId: string, path: string, opts?: {
|
|
209
|
+
range?: string;
|
|
210
|
+
head?: boolean;
|
|
211
|
+
signal?: AbortSignal;
|
|
212
|
+
}): Promise<RunInboxDownload>;
|
|
186
213
|
/** Which per-run overrides a run of `name` may set, for this caller — what a
|
|
187
214
|
* run form needs before it sends anything. Mirrors
|
|
188
215
|
* `GET /v1/_agentdef/{name}/overridable`.
|
|
@@ -474,8 +501,10 @@ export declare class LoomcycleClient {
|
|
|
474
501
|
signal?: AbortSignal;
|
|
475
502
|
}): Promise<WalkRunsPage>;
|
|
476
503
|
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
477
|
-
* tenant/user/provider/model/source over an optional time window;
|
|
478
|
-
* `source` for the operator-vs-tenant split
|
|
504
|
+
* tenant/user/provider/model/source/purpose over an optional time window;
|
|
505
|
+
* group by `source` for the operator-vs-tenant split, by `purpose` to see
|
|
506
|
+
* what OCR and speech-to-text cost (a row's `audio_seconds` is the audio its
|
|
507
|
+
* speech-to-text calls transcribed). Tenant-scoped server-side: a
|
|
479
508
|
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
480
509
|
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
481
510
|
usageReport(opts?: {
|
package/dist/client.js
CHANGED
|
@@ -443,6 +443,51 @@ export class LoomcycleClient {
|
|
|
443
443
|
async getEffectiveConfig(runId, opts) {
|
|
444
444
|
return jsonFetch(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/effective-config`, opts);
|
|
445
445
|
}
|
|
446
|
+
/** Run one File-tool op on a run's inbox from outside the run — the files the
|
|
447
|
+
* run's tools returned. Mirrors `POST /v1/runs/{run_id}/file`, the HTTP twin
|
|
448
|
+
* of the MCP `file` tool. Ops: stat, ls, extract, import, keep, rm, clear.
|
|
449
|
+
* The response is the op's own JSON (narrow as needed).
|
|
450
|
+
*
|
|
451
|
+
* Needs `runs:read`, and works on any run you can read; another tenant's run
|
|
452
|
+
* is an opaque {@link NotFoundError}. extract, keep, rm and clear write, so
|
|
453
|
+
* they need the run's owner or an admin — a tenant operator counts as one
|
|
454
|
+
* for its own tenant's runs; anyone else gets a
|
|
455
|
+
* {@link SubstrateToolRefusedError}, as does a refused op. */
|
|
456
|
+
async runFile(runId, input, opts) {
|
|
457
|
+
return postJSON(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/file`, input, opts);
|
|
458
|
+
}
|
|
459
|
+
/** Download one file of a run's inbox. Mirrors
|
|
460
|
+
* `GET /v1/runs/{run_id}/inbox/{path}` (HEAD with `head: true`). `path` is
|
|
461
|
+
* relative to the inbox root (`documents/a.pdf`) or a reference
|
|
462
|
+
* (`volume:inbox:documents/a.pdf`).
|
|
463
|
+
*
|
|
464
|
+
* Any reader of the run may download (`runs:read`). `range` is sent as the
|
|
465
|
+
* Range header (`bytes=0-1023`). The inbox is deleted when its run ends, so
|
|
466
|
+
* a finished run's file — like a missing file, run, or another tenant's run —
|
|
467
|
+
* is a {@link NotFoundError}. */
|
|
468
|
+
async downloadRunInboxFile(runId, path, opts) {
|
|
469
|
+
const rel = path.replace(/^volume:inbox:/, "");
|
|
470
|
+
const encoded = rel.split("/").map(encodeURIComponent).join("/");
|
|
471
|
+
const headers = {};
|
|
472
|
+
if (this.ctx.authToken)
|
|
473
|
+
headers.Authorization = `Bearer ${this.ctx.authToken}`;
|
|
474
|
+
if (opts?.range)
|
|
475
|
+
headers.Range = opts.range;
|
|
476
|
+
const resp = await this.ctx.fetchImpl(`${this.ctx.baseUrl}/v1/runs/${encodeURIComponent(runId)}/inbox/${encoded}`, { method: opts?.head ? "HEAD" : "GET", headers, signal: opts?.signal });
|
|
477
|
+
if (!resp.ok) {
|
|
478
|
+
await raiseFromResponse(resp);
|
|
479
|
+
}
|
|
480
|
+
const bytes = opts?.head ? new Uint8Array() : new Uint8Array(await resp.arrayBuffer());
|
|
481
|
+
return {
|
|
482
|
+
bytes,
|
|
483
|
+
status: resp.status,
|
|
484
|
+
contentType: resp.headers.get("Content-Type") ?? "",
|
|
485
|
+
filename: dispositionFilename(resp.headers.get("Content-Disposition")) ?? rel.split("/").pop() ?? "",
|
|
486
|
+
sha256: resp.headers.get("X-Loomcycle-SHA256") ?? "",
|
|
487
|
+
origin: resp.headers.get("X-Loomcycle-Origin") ?? "",
|
|
488
|
+
headers: resp.headers,
|
|
489
|
+
};
|
|
490
|
+
}
|
|
446
491
|
/** Which per-run overrides a run of `name` may set, for this caller — what a
|
|
447
492
|
* run form needs before it sends anything. Mirrors
|
|
448
493
|
* `GET /v1/_agentdef/{name}/overridable`.
|
|
@@ -796,8 +841,10 @@ export class LoomcycleClient {
|
|
|
796
841
|
return { agents: resp.agents ?? [], next_cursor: resp.next_cursor ?? "" };
|
|
797
842
|
}
|
|
798
843
|
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
799
|
-
* tenant/user/provider/model/source over an optional time window;
|
|
800
|
-
* `source` for the operator-vs-tenant split
|
|
844
|
+
* tenant/user/provider/model/source/purpose over an optional time window;
|
|
845
|
+
* group by `source` for the operator-vs-tenant split, by `purpose` to see
|
|
846
|
+
* what OCR and speech-to-text cost (a row's `audio_seconds` is the audio its
|
|
847
|
+
* speech-to-text calls transcribed). Tenant-scoped server-side: a
|
|
801
848
|
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
802
849
|
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
803
850
|
async usageReport(opts) {
|
|
@@ -1272,6 +1319,12 @@ export class LoomcycleClient {
|
|
|
1272
1319
|
body.document_ids = input.documentIds;
|
|
1273
1320
|
if (input.excludeDocumentIds !== undefined)
|
|
1274
1321
|
body.exclude_document_ids = input.excludeDocumentIds;
|
|
1322
|
+
// The second scope's documents: sent only when set, so a one-scope search's
|
|
1323
|
+
// response stays byte-identical (no per-entry `scope`).
|
|
1324
|
+
if (input.documentsScope !== undefined)
|
|
1325
|
+
body.documents_scope = input.documentsScope;
|
|
1326
|
+
if (input.documentsScopeId !== undefined)
|
|
1327
|
+
body.documents_scope_id = input.documentsScopeId;
|
|
1275
1328
|
return postJSON(this.ctx, "/v1/_memory/search", body, {
|
|
1276
1329
|
signal: opts?.signal,
|
|
1277
1330
|
});
|
|
@@ -3215,6 +3268,23 @@ export class LoomcycleClient {
|
|
|
3215
3268
|
return postJSON(this.ctx, "/v1/_crypto", input, opts);
|
|
3216
3269
|
}
|
|
3217
3270
|
}
|
|
3271
|
+
/** The file name of an RFC 8187 `filename*=UTF-8''…` Content-Disposition, or
|
|
3272
|
+
* a plain quoted `filename="…"`; undefined when there is neither. */
|
|
3273
|
+
function dispositionFilename(header) {
|
|
3274
|
+
if (!header)
|
|
3275
|
+
return undefined;
|
|
3276
|
+
const star = /filename\*=UTF-8''([^;]+)/i.exec(header);
|
|
3277
|
+
if (star) {
|
|
3278
|
+
try {
|
|
3279
|
+
return decodeURIComponent(star[1].trim());
|
|
3280
|
+
}
|
|
3281
|
+
catch {
|
|
3282
|
+
return undefined;
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
const plain = /filename="([^"]*)"/i.exec(header);
|
|
3286
|
+
return plain ? plain[1] : undefined;
|
|
3287
|
+
}
|
|
3218
3288
|
/** Lightweight SSE parser tailored to the run-state stream. Each
|
|
3219
3289
|
* frame's event name distinguishes the two kinds; data is JSON.
|
|
3220
3290
|
* Comment lines (": keepalive") are ignored. */
|
package/dist/index.d.ts
CHANGED
|
@@ -187,5 +187,5 @@ export { verifyLoomcycleSignature, verifyLoomcycleDelivery } from "./signature.j
|
|
|
187
187
|
export type { VerifySignatureOptions, VerifiedDelivery } from "./signature.js";
|
|
188
188
|
export { ClientToolHost, clientToolsURL, CLIENT_TOOL_SUBPROTOCOL } from "./client-tools.js";
|
|
189
189
|
export type { ClientToolSchema, ClientToolInvocation, ConnectClientToolsOptions, WebSocketLike, WebSocketCtor, } from "./client-tools.js";
|
|
190
|
-
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, ErasureAccess, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, ErasureTokenRef, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, WhoamiEffective, WhoamiAuth, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchDocumentFilter, 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, RoutingEmbedder, RoutingDecision, RoutingDecisionModel, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, DocumentSearchFilter, DocumentSearchHit, DocumentSearchResult, DocumentRelatedResult, 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, AgentTranscription, 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, FileCapturedInfo, TranscriptionInfo, 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, AclMode, AclSource, AclEffect, AclSubjectKind, AclCondition, AclRule, AclList, AclDefRow, AclDefListResponse, AclDefNamesResponse, AclValidateResult, AclCatalogType, AclCatalog, AclDefOp, AclDefInput, GroupRow, GroupMemberKind, GroupMember, GroupListResponse, GroupDetail, GroupEffective, CreateGroupBody, GroupMemberChange, AclBinding, AclBindingListResponse, CreateAclBindingBody, AuthzReason, AuthzDecision, AuthzRequestContext, AuthzEvaluationRequest, AuthzEvaluationsSemantic, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzTrace, AuthzAppliedBinding, AuthzExplainResponse, AuthzDraftBinding, AuthzSimulateRequest, AuthzSimulateResult, AuthzSimulateResponse, } from "./types.js";
|
|
190
|
+
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, ErasureAccess, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, ErasureTokenRef, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, WhoamiEffective, WhoamiAuth, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchDocumentFilter, 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, RoutingEmbedder, RoutingDecision, RoutingDecisionModel, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, DocumentSearchFilter, DocumentSearchHit, DocumentSearchResult, DocumentRelatedResult, 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, AgentTranscription, 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, FileCapturedInfo, TranscriptionInfo, AdmissionInfo, ErrorInfo, CallFormat, CallRef, HookDecisionInfo, TeamDecisionInfo, OverrideInfo, FallbackInfo, InterruptionEventInfo, SpawnChildInfo, TurnCancelledInfo, ChannelEventInfo, ContextCompactionInfo, ContextRecapInfo, ContextStateInfo, ContextExhaustedInfo, ContextTierVerdict, ContextDistillDeclinedInfo, EffectiveConfigResponse, RunFileInput, RunInboxDownload, 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, AclMode, AclSource, AclEffect, AclSubjectKind, AclCondition, AclRule, AclList, AclDefRow, AclDefListResponse, AclDefNamesResponse, AclValidateResult, AclCatalogType, AclCatalog, AclDefOp, AclDefInput, GroupRow, GroupMemberKind, GroupMember, GroupListResponse, GroupDetail, GroupEffective, CreateGroupBody, GroupMemberChange, AclBinding, AclBindingListResponse, CreateAclBindingBody, AuthzReason, AuthzDecision, AuthzRequestContext, AuthzEvaluationRequest, AuthzEvaluationsSemantic, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzTrace, AuthzAppliedBinding, AuthzExplainResponse, AuthzDraftBinding, AuthzSimulateRequest, AuthzSimulateResult, AuthzSimulateResponse, } from "./types.js";
|
|
191
191
|
export { AclDeniedError, 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
|
@@ -187,6 +187,49 @@ export interface RunPromptResponse {
|
|
|
187
187
|
system: PromptBlock[];
|
|
188
188
|
input: PromptBlock[];
|
|
189
189
|
}
|
|
190
|
+
/** Input for {@link LoomcycleClient.runFile} — one File-tool op on the inbox of
|
|
191
|
+
* a run, from outside the run (`POST /v1/runs/{run_id}/file`). The run is the
|
|
192
|
+
* path's; the fields are the tool's own, snake_case as on the wire. download
|
|
193
|
+
* and upload are not offered here: they need a run's HTTP allowlist. */
|
|
194
|
+
export type RunFileInput = {
|
|
195
|
+
op: "stat" | "ls" | "extract" | "import" | "keep" | "rm" | "clear";
|
|
196
|
+
/** stat / ls / rm / extract / import: `volume:inbox:<path>`, or a bare path in the inbox. */
|
|
197
|
+
path?: string;
|
|
198
|
+
/** keep: the inbox file to copy. */
|
|
199
|
+
from?: string;
|
|
200
|
+
/** keep: `volume:<name>:<path>` in a read-write dynamic volume of your tenant. */
|
|
201
|
+
to?: string;
|
|
202
|
+
overwrite?: boolean;
|
|
203
|
+
recursive?: boolean;
|
|
204
|
+
/** clear: one folder of the inbox to empty instead of all of it. */
|
|
205
|
+
prefix?: string;
|
|
206
|
+
images?: boolean;
|
|
207
|
+
max_rows?: number;
|
|
208
|
+
excerpt_chars?: number;
|
|
209
|
+
title?: string;
|
|
210
|
+
doc_path?: string;
|
|
211
|
+
scope?: string;
|
|
212
|
+
tags?: string[];
|
|
213
|
+
};
|
|
214
|
+
/** What {@link LoomcycleClient.downloadRunInboxFile} returns: one inbox file's
|
|
215
|
+
* bytes and what the server says about them. */
|
|
216
|
+
export interface RunInboxDownload {
|
|
217
|
+
/** The bytes (empty for a HEAD request). */
|
|
218
|
+
bytes: Uint8Array;
|
|
219
|
+
/** 200, or 206 for a range. */
|
|
220
|
+
status: number;
|
|
221
|
+
/** The type the server served: the recorded type when it is one a browser
|
|
222
|
+
* cannot run, else `application/octet-stream`. */
|
|
223
|
+
contentType: string;
|
|
224
|
+
/** The file's name, from Content-Disposition. */
|
|
225
|
+
filename: string;
|
|
226
|
+
/** SHA-256 (hex) of the file's bytes as served — the whole file, also for a range. */
|
|
227
|
+
sha256: string;
|
|
228
|
+
/** The producer the runtime recorded (`mcp:<server>/<tool>`, `http`, …), or
|
|
229
|
+
* `unknown` when the file changed since it was kept. */
|
|
230
|
+
origin: string;
|
|
231
|
+
headers: Headers;
|
|
232
|
+
}
|
|
190
233
|
/** The reply from `GET /v1/runs/{run_id}/effective-config` — for every
|
|
191
234
|
* overridable field, the value this run will actually use and which layer
|
|
192
235
|
* decided it.
|
|
@@ -2391,11 +2434,12 @@ export interface MemorySearchInput {
|
|
|
2391
2434
|
*
|
|
2392
2435
|
* The four document filters need a search that can return documents (no
|
|
2393
2436
|
* `sources`, or `sources` including `"documents"`; otherwise 400
|
|
2394
|
-
* `invalid_filter`)
|
|
2395
|
-
*
|
|
2396
|
-
*
|
|
2397
|
-
* MemorySearchResponse.filter}. For chunk-level
|
|
2398
|
-
*
|
|
2437
|
+
* `invalid_filter`) and SQL Memory on the server (400 `filter_unavailable`).
|
|
2438
|
+
* They resolve in the caller's own tenant. With a {@link documentsScope}
|
|
2439
|
+
* different from `scope` they aim at that scope's documents instead. The
|
|
2440
|
+
* response then carries {@link MemorySearchResponse.filter}. For chunk-level
|
|
2441
|
+
* filters (type, status, tags, a validity instant) use
|
|
2442
|
+
* `document({ op: "search" })`. */
|
|
2399
2443
|
underPaths?: string[];
|
|
2400
2444
|
/** Never return the chunks of documents named at or under these paths (sent as
|
|
2401
2445
|
* `exclude_under_paths`). Documents only, as {@link underPaths}. */
|
|
@@ -2406,6 +2450,23 @@ export interface MemorySearchInput {
|
|
|
2406
2450
|
/** Never return the chunks of these documents (sent as
|
|
2407
2451
|
* `exclude_document_ids`). Documents only, as {@link underPaths}. */
|
|
2408
2452
|
excludeDocumentIds?: string[];
|
|
2453
|
+
/** Also search the DOCUMENTS of this scope in the same call (sent as
|
|
2454
|
+
* `documents_scope`): for example a user's own notes together with the
|
|
2455
|
+
* tenant's reference documents. Both are ranked into one list under one
|
|
2456
|
+
* `topK`, and each entry then carries {@link MemorySearchEntry.scope}. Only
|
|
2457
|
+
* documents come from this scope; facts and notes still come from `scope`.
|
|
2458
|
+
* The four document filters aim at this scope's documents.
|
|
2459
|
+
*
|
|
2460
|
+
* Equal to `scope` (and {@link documentsScopeId} omitted or equal to
|
|
2461
|
+
* `scopeId`), it is the same as adding `"documents"` to `sources`. It cannot
|
|
2462
|
+
* be combined with `sources: ["traces"]` (400 `invalid_documents_scope`). A
|
|
2463
|
+
* caller whose access does not reach that scope's documents gets 403. */
|
|
2464
|
+
documentsScope?: "agent" | "user" | "tenant";
|
|
2465
|
+
/** The subject of {@link documentsScope} (sent as `documents_scope_id`): the
|
|
2466
|
+
* agent name or user id. Required when `documentsScope` is `"agent"` or
|
|
2467
|
+
* `"user"` and differs from `scope`; ignored for `"tenant"`. The tenant is
|
|
2468
|
+
* always the caller's own. */
|
|
2469
|
+
documentsScopeId?: string;
|
|
2409
2470
|
}
|
|
2410
2471
|
/** What a document filter on {@link LoomcycleClient.memorySearch} resolved to —
|
|
2411
2472
|
* present on the response ONLY when a filter was sent. */
|
|
@@ -2427,6 +2488,9 @@ export interface MemorySearchDocumentFilter {
|
|
|
2427
2488
|
* false while access-control rules can deny the caller reading part of the
|
|
2428
2489
|
* scope — the counts then cover only documents it may read. */
|
|
2429
2490
|
inverted: boolean;
|
|
2491
|
+
/** The scope the filter resolved in — present when it aimed at a
|
|
2492
|
+
* {@link MemorySearchInput.documentsScope} different from `scope`. */
|
|
2493
|
+
scope?: "agent" | "user" | "tenant";
|
|
2430
2494
|
}
|
|
2431
2495
|
/** The observed-time predicate on {@link MemorySearchInput}. Timestamps are
|
|
2432
2496
|
* RFC3339 instants — resolve phrases like "the first weekend of October"
|
|
@@ -2501,6 +2565,10 @@ export interface MemorySearchEntry {
|
|
|
2501
2565
|
kind: "description" | "claim" | "question";
|
|
2502
2566
|
text: string;
|
|
2503
2567
|
};
|
|
2568
|
+
/** The scope this hit came from — present on every entry when the request
|
|
2569
|
+
* set a {@link MemorySearchInput.documentsScope} different from `scope`, so
|
|
2570
|
+
* the caller's own memory can be told from the other scope's documents. */
|
|
2571
|
+
scope?: "agent" | "user" | "tenant";
|
|
2504
2572
|
}
|
|
2505
2573
|
export interface MemorySearchResponse {
|
|
2506
2574
|
scope: string;
|
|
@@ -2518,6 +2586,11 @@ export interface MemorySearchResponse {
|
|
|
2518
2586
|
/** What the document filter resolved to — present only when one was sent
|
|
2519
2587
|
* ({@link MemorySearchInput.underPaths} and its siblings). */
|
|
2520
2588
|
filter?: MemorySearchDocumentFilter;
|
|
2589
|
+
/** The second scope searched for documents and its store scope id ("" for
|
|
2590
|
+
* tenant) — present only when the request set a
|
|
2591
|
+
* {@link MemorySearchInput.documentsScope} different from `scope`. */
|
|
2592
|
+
documents_scope?: "agent" | "user" | "tenant";
|
|
2593
|
+
documents_scope_id?: string;
|
|
2521
2594
|
}
|
|
2522
2595
|
export interface MemoryTimeFilter {
|
|
2523
2596
|
mode: "prefer" | "require";
|
|
@@ -5409,7 +5482,9 @@ export interface LLMEmbeddingsResponse {
|
|
|
5409
5482
|
usage: LLMEmbeddingsUsage;
|
|
5410
5483
|
}
|
|
5411
5484
|
/** A whitelisted grouping dimension for the usage report. */
|
|
5412
|
-
export type UsageDimension = "tenant" | "user" | "provider" | "model" | "source"
|
|
5485
|
+
export type UsageDimension = "tenant" | "user" | "provider" | "model" | "source"
|
|
5486
|
+
/** What the calls were for: chat | ocr | stt. */
|
|
5487
|
+
| "purpose";
|
|
5413
5488
|
/** One grouped row of a usage report; only the grouped dimensions are set. */
|
|
5414
5489
|
export interface UsageAggregate {
|
|
5415
5490
|
tenant_id?: string;
|
|
@@ -5418,6 +5493,8 @@ export interface UsageAggregate {
|
|
|
5418
5493
|
model?: string;
|
|
5419
5494
|
/** operator | tenant | user */
|
|
5420
5495
|
credential_source?: string;
|
|
5496
|
+
/** chat | ocr | stt — set when grouped by `purpose`. */
|
|
5497
|
+
purpose?: string;
|
|
5421
5498
|
input_tokens: number;
|
|
5422
5499
|
output_tokens: number;
|
|
5423
5500
|
cache_creation_tokens: number;
|
|
@@ -5426,6 +5503,9 @@ export interface UsageAggregate {
|
|
|
5426
5503
|
currency?: string;
|
|
5427
5504
|
call_count: number;
|
|
5428
5505
|
unpriced_calls: number;
|
|
5506
|
+
/** Seconds of audio the group's speech-to-text calls transcribed (the unit
|
|
5507
|
+
* their per-minute price is computed from); absent when it has none. */
|
|
5508
|
+
audio_seconds?: number;
|
|
5429
5509
|
}
|
|
5430
5510
|
export interface UsageReportResponse {
|
|
5431
5511
|
group_by: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcycle/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.125.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",
|