@loomcycle/client 1.7.0 → 1.11.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 +43 -0
- package/dist/client.d.ts +41 -1
- package/dist/client.js +43 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +85 -1
- package/package.json +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -325,6 +325,49 @@ class LoomcycleClient {
|
|
|
325
325
|
}
|
|
326
326
|
return all;
|
|
327
327
|
}
|
|
328
|
+
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
329
|
+
* tenant/user/provider/model/source over an optional time window; group by
|
|
330
|
+
* `source` for the operator-vs-tenant split. Tenant-scoped server-side: a
|
|
331
|
+
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
332
|
+
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
333
|
+
async usageReport(opts) {
|
|
334
|
+
const params = new URLSearchParams();
|
|
335
|
+
if (opts?.groupBy && opts.groupBy.length > 0)
|
|
336
|
+
params.set("group_by", opts.groupBy.join(","));
|
|
337
|
+
if (opts?.from)
|
|
338
|
+
params.set("from", opts.from);
|
|
339
|
+
if (opts?.to)
|
|
340
|
+
params.set("to", opts.to);
|
|
341
|
+
if (opts?.tenant)
|
|
342
|
+
params.set("tenant", opts.tenant);
|
|
343
|
+
const q = params.toString() ? `?${params.toString()}` : "";
|
|
344
|
+
return (0, fetch_helpers_js_1.jsonFetch)(this.ctx, `/v1/_usage${q}`, opts);
|
|
345
|
+
}
|
|
346
|
+
/** List the per-scope token budgets visible to the caller (RFC AW), each with
|
|
347
|
+
* its live month-to-date usage. Tenant-scoped server-side: a tenant operator
|
|
348
|
+
* sees only its own tenant's budgets; an admin sees all (or focuses one via
|
|
349
|
+
* `tenant`). Mirrors `GET /v1/_limits`. */
|
|
350
|
+
async listLimits(opts) {
|
|
351
|
+
const q = opts?.tenant ? `?tenant=${encodeURIComponent(opts.tenant)}` : "";
|
|
352
|
+
return (0, fetch_helpers_js_1.jsonFetch)(this.ctx, `/v1/_limits${q}`, opts);
|
|
353
|
+
}
|
|
354
|
+
/** Upsert one token budget (RFC AW). A present `soft_limit`/`hard_limit` sets
|
|
355
|
+
* that tier; omitting it clears the tier (unlimited on that axis) — a
|
|
356
|
+
* full-row upsert. The operator-global scope + any cross-tenant `tenant_id`
|
|
357
|
+
* are admin-only (403 otherwise). Mirrors `PUT /v1/_limits`. */
|
|
358
|
+
async setLimit(body, opts) {
|
|
359
|
+
return (0, fetch_helpers_js_1.putJSON)(this.ctx, "/v1/_limits", body, opts);
|
|
360
|
+
}
|
|
361
|
+
/** Delete a token budget → the scope is unlimited again (RFC AW). Same
|
|
362
|
+
* tenant-confinement as `setLimit`. Mirrors `DELETE /v1/_limits`. */
|
|
363
|
+
async deleteLimit(scope, opts) {
|
|
364
|
+
const params = new URLSearchParams({ scope });
|
|
365
|
+
if (opts?.scopeId)
|
|
366
|
+
params.set("scope_id", opts.scopeId);
|
|
367
|
+
if (opts?.tenant)
|
|
368
|
+
params.set("tenant", opts.tenant);
|
|
369
|
+
return (0, fetch_helpers_js_1.deleteRequest)(this.ctx, `/v1/_limits?${params.toString()}`, opts);
|
|
370
|
+
}
|
|
328
371
|
/** Read the full event log for a session. Each entry has seq,
|
|
329
372
|
* run_id, ts_ns, type, event (the providers.Event payload). */
|
|
330
373
|
async getTranscript(sessionId, opts) {
|
package/dist/client.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* full mapping table.
|
|
25
25
|
*/
|
|
26
26
|
import { InteractiveSession } from "./interactive.js";
|
|
27
|
-
import type { Agent, AgentEvent, AgentStatus, CancelAgentResult, ClientOptions, ContinueOptions, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, Hook, InterruptListResponse, InterruptStatus, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ChannelPublishResult, ChannelPurgeResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEntriesResponse, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopesResponse, PauseResult, PersistentVolumesResponse, EphemeralVolumesResponse, RegisterHookOptions, RegisterHookResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunBatchOptions, RunBatchResult, RunOptions, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, TranscriptResponse, WhoamiResponse } from "./types.js";
|
|
27
|
+
import type { Agent, AgentEvent, AgentStatus, CancelAgentResult, ClientOptions, ContinueOptions, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, Hook, InterruptListResponse, InterruptStatus, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ChannelPublishResult, ChannelPurgeResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEntriesResponse, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopesResponse, PauseResult, PersistentVolumesResponse, EphemeralVolumesResponse, RegisterHookOptions, RegisterHookResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunBatchOptions, RunBatchResult, RunOptions, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, TranscriptResponse, WhoamiResponse, UsageDimension, UsageReportResponse, TokenLimit, TokenLimitsResponse, SetTokenLimitRequest } from "./types.js";
|
|
28
28
|
export declare class LoomcycleClient {
|
|
29
29
|
private ctx;
|
|
30
30
|
constructor(opts?: ClientOptions);
|
|
@@ -169,6 +169,46 @@ export declare class LoomcycleClient {
|
|
|
169
169
|
tenant?: string;
|
|
170
170
|
signal?: AbortSignal;
|
|
171
171
|
}): Promise<Agent[]>;
|
|
172
|
+
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
173
|
+
* tenant/user/provider/model/source over an optional time window; group by
|
|
174
|
+
* `source` for the operator-vs-tenant split. Tenant-scoped server-side: a
|
|
175
|
+
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
176
|
+
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
177
|
+
usageReport(opts?: {
|
|
178
|
+
/** Dimensions to group by (default server-side: tenant,source). */
|
|
179
|
+
groupBy?: UsageDimension[];
|
|
180
|
+
/** RFC3339 window bounds (inclusive); omit for unbounded. */
|
|
181
|
+
from?: string;
|
|
182
|
+
to?: string;
|
|
183
|
+
/** Super-admin tenant focus (?tenant=); ignored for a tenant principal. */
|
|
184
|
+
tenant?: string;
|
|
185
|
+
signal?: AbortSignal;
|
|
186
|
+
}): Promise<UsageReportResponse>;
|
|
187
|
+
/** List the per-scope token budgets visible to the caller (RFC AW), each with
|
|
188
|
+
* its live month-to-date usage. Tenant-scoped server-side: a tenant operator
|
|
189
|
+
* sees only its own tenant's budgets; an admin sees all (or focuses one via
|
|
190
|
+
* `tenant`). Mirrors `GET /v1/_limits`. */
|
|
191
|
+
listLimits(opts?: {
|
|
192
|
+
/** Admin-only tenant focus (?tenant=); ignored for a tenant principal. */
|
|
193
|
+
tenant?: string;
|
|
194
|
+
signal?: AbortSignal;
|
|
195
|
+
}): Promise<TokenLimitsResponse>;
|
|
196
|
+
/** Upsert one token budget (RFC AW). A present `soft_limit`/`hard_limit` sets
|
|
197
|
+
* that tier; omitting it clears the tier (unlimited on that axis) — a
|
|
198
|
+
* full-row upsert. The operator-global scope + any cross-tenant `tenant_id`
|
|
199
|
+
* are admin-only (403 otherwise). Mirrors `PUT /v1/_limits`. */
|
|
200
|
+
setLimit(body: SetTokenLimitRequest, opts?: {
|
|
201
|
+
signal?: AbortSignal;
|
|
202
|
+
}): Promise<TokenLimit>;
|
|
203
|
+
/** Delete a token budget → the scope is unlimited again (RFC AW). Same
|
|
204
|
+
* tenant-confinement as `setLimit`. Mirrors `DELETE /v1/_limits`. */
|
|
205
|
+
deleteLimit(scope: string, opts?: {
|
|
206
|
+
/** Required for scope=user (the subject); empty for scope=tenant. */
|
|
207
|
+
scopeId?: string;
|
|
208
|
+
/** Admin-only target tenant; ignored for a tenant principal. */
|
|
209
|
+
tenant?: string;
|
|
210
|
+
signal?: AbortSignal;
|
|
211
|
+
}): Promise<void>;
|
|
172
212
|
/** Read the full event log for a session. Each entry has seq,
|
|
173
213
|
* run_id, ts_ns, type, event (the providers.Event payload). */
|
|
174
214
|
getTranscript(sessionId: string, opts?: {
|
package/dist/client.js
CHANGED
|
@@ -322,6 +322,49 @@ export class LoomcycleClient {
|
|
|
322
322
|
}
|
|
323
323
|
return all;
|
|
324
324
|
}
|
|
325
|
+
/** Aggregated token-usage + cost report (RFC AV). Group by any of
|
|
326
|
+
* tenant/user/provider/model/source over an optional time window; group by
|
|
327
|
+
* `source` for the operator-vs-tenant split. Tenant-scoped server-side: a
|
|
328
|
+
* tenant principal sees only its own tenant (the `tenant` focus is
|
|
329
|
+
* admin-only). Mirrors `GET /v1/_usage`. */
|
|
330
|
+
async usageReport(opts) {
|
|
331
|
+
const params = new URLSearchParams();
|
|
332
|
+
if (opts?.groupBy && opts.groupBy.length > 0)
|
|
333
|
+
params.set("group_by", opts.groupBy.join(","));
|
|
334
|
+
if (opts?.from)
|
|
335
|
+
params.set("from", opts.from);
|
|
336
|
+
if (opts?.to)
|
|
337
|
+
params.set("to", opts.to);
|
|
338
|
+
if (opts?.tenant)
|
|
339
|
+
params.set("tenant", opts.tenant);
|
|
340
|
+
const q = params.toString() ? `?${params.toString()}` : "";
|
|
341
|
+
return jsonFetch(this.ctx, `/v1/_usage${q}`, opts);
|
|
342
|
+
}
|
|
343
|
+
/** List the per-scope token budgets visible to the caller (RFC AW), each with
|
|
344
|
+
* its live month-to-date usage. Tenant-scoped server-side: a tenant operator
|
|
345
|
+
* sees only its own tenant's budgets; an admin sees all (or focuses one via
|
|
346
|
+
* `tenant`). Mirrors `GET /v1/_limits`. */
|
|
347
|
+
async listLimits(opts) {
|
|
348
|
+
const q = opts?.tenant ? `?tenant=${encodeURIComponent(opts.tenant)}` : "";
|
|
349
|
+
return jsonFetch(this.ctx, `/v1/_limits${q}`, opts);
|
|
350
|
+
}
|
|
351
|
+
/** Upsert one token budget (RFC AW). A present `soft_limit`/`hard_limit` sets
|
|
352
|
+
* that tier; omitting it clears the tier (unlimited on that axis) — a
|
|
353
|
+
* full-row upsert. The operator-global scope + any cross-tenant `tenant_id`
|
|
354
|
+
* are admin-only (403 otherwise). Mirrors `PUT /v1/_limits`. */
|
|
355
|
+
async setLimit(body, opts) {
|
|
356
|
+
return putJSON(this.ctx, "/v1/_limits", body, opts);
|
|
357
|
+
}
|
|
358
|
+
/** Delete a token budget → the scope is unlimited again (RFC AW). Same
|
|
359
|
+
* tenant-confinement as `setLimit`. Mirrors `DELETE /v1/_limits`. */
|
|
360
|
+
async deleteLimit(scope, opts) {
|
|
361
|
+
const params = new URLSearchParams({ scope });
|
|
362
|
+
if (opts?.scopeId)
|
|
363
|
+
params.set("scope_id", opts.scopeId);
|
|
364
|
+
if (opts?.tenant)
|
|
365
|
+
params.set("tenant", opts.tenant);
|
|
366
|
+
return deleteRequest(this.ctx, `/v1/_limits?${params.toString()}`, opts);
|
|
367
|
+
}
|
|
325
368
|
/** Read the full event log for a session. Each entry has seq,
|
|
326
369
|
* run_id, ts_ns, type, event (the providers.Event payload). */
|
|
327
370
|
async getTranscript(sessionId, opts) {
|
package/dist/index.d.ts
CHANGED
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
export { LoomcycleClient } from "./client.js";
|
|
94
94
|
export { InteractiveSession } from "./interactive.js";
|
|
95
95
|
export type { InteractiveSessionOps } from "./interactive.js";
|
|
96
|
-
export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, SamplingOptions, CompactionOptions, ToolUse, Usage, Agent, AgentStatus, AgentUsage, CancelAgentResult, ListAgentsResponse, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, WhoamiResponse, PauseResult, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, Hook, HookFailMode, HookPhase, HookToolCall, HookToolResult, ListHooksResponse, PostHookCall, PostHookResult, PreHookCall, PreHookResult, RegisterHookOptions, RegisterHookResponse, SubstrateToolInput, SubstrateToolResponse, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ChannelPublishResult, ChannelPurgeResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, EnsureCodeAgentOptions, EnsureCodeAgentResult, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, } from "./types.js";
|
|
96
|
+
export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, SamplingOptions, CompactionOptions, ToolUse, Usage, Agent, AgentStatus, AgentUsage, CancelAgentResult, ListAgentsResponse, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, WhoamiResponse, PauseResult, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, Hook, HookFailMode, HookPhase, HookToolCall, HookToolResult, ListHooksResponse, PostHookCall, PostHookResult, PreHookCall, PreHookResult, RegisterHookOptions, RegisterHookResponse, SubstrateToolInput, SubstrateToolResponse, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ChannelPublishResult, ChannelPurgeResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, EnsureCodeAgentOptions, EnsureCodeAgentResult, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, UsageDimension, UsageAggregate, UsageReportResponse, LimitInfo, TokenLimit, TokenLimitsResponse, SetTokenLimitRequest, } from "./types.js";
|
|
97
97
|
export { AgentIDInUseError, AgentNotFoundError, AlreadyPausingError, AuthError, BackpressureError, HookNotFoundError, NotFoundError, InvalidArgumentError, ChannelCursorRegressionError, LoomcycleError, NotPausedError, PauseNotConfiguredError, PerUserQuotaExhaustedError, SessionBusyError, SessionNotFoundError, SnapshotNotFoundError, SnapshotTooLargeError, SnapshotVersionError, SubstrateToolRefusedError, UnavailableError, } from "./errors.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `client.ts` for the input shapes (RunOptions, CreateSnapshotOptions,
|
|
8
8
|
* etc.) — those are translated to snake_case in the request body.
|
|
9
9
|
*/
|
|
10
|
-
export type EventType = "started" | "text" | "tool_call" | "tool_result" | "usage" | "done" | "error" | "retry" | "host_widened" | "session" | "agent" | "awaiting_input" | "steer" | "context_compaction" | "_meta";
|
|
10
|
+
export type EventType = "started" | "text" | "tool_call" | "tool_result" | "usage" | "done" | "error" | "retry" | "host_widened" | "session" | "agent" | "awaiting_input" | "steer" | "context_compaction" | "limit" | "_meta";
|
|
11
11
|
export interface ToolUse {
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
@@ -54,6 +54,29 @@ export interface HostWidening {
|
|
|
54
54
|
hook_name: string;
|
|
55
55
|
hosts_added: string[];
|
|
56
56
|
}
|
|
57
|
+
/** LimitInfo accompanies an `event: limit` frame (RFC AW per-scope token
|
|
58
|
+
* budgets). Names which scope tripped, how hard (`soft` warns + the run
|
|
59
|
+
* continues; `hard` means the NEXT run is refused at admission), and where the
|
|
60
|
+
* scope stands against its ceiling — so a UI can render "tenant acme at 1.2M /
|
|
61
|
+
* 1M tokens this month" without a follow-up fetch. Wire-stable; mirrors
|
|
62
|
+
* providers.LimitInfo. */
|
|
63
|
+
export interface LimitInfo {
|
|
64
|
+
/** Which axis tripped: "operator" | "tenant" | "user". */
|
|
65
|
+
scope: string;
|
|
66
|
+
/** The tripped scope's id — tenant id (scope=tenant), user subject
|
|
67
|
+
* (scope=user), "" (operator-global). */
|
|
68
|
+
scope_id?: string;
|
|
69
|
+
/** "soft" (warn, run continues) | "hard" (next run refused at admission). */
|
|
70
|
+
severity: string;
|
|
71
|
+
/** Budget window; "month" (calendar month, UTC) in Phase 1. */
|
|
72
|
+
window: string;
|
|
73
|
+
/** The scope's month-to-date token total at the crossing. */
|
|
74
|
+
used: number;
|
|
75
|
+
/** The tier that was crossed (the soft or hard ceiling). */
|
|
76
|
+
limit: number;
|
|
77
|
+
/** Human-readable banner string. Optional. */
|
|
78
|
+
message?: string;
|
|
79
|
+
}
|
|
57
80
|
export interface AgentEvent {
|
|
58
81
|
type: EventType;
|
|
59
82
|
text?: string;
|
|
@@ -82,6 +105,9 @@ export interface AgentEvent {
|
|
|
82
105
|
source?: string;
|
|
83
106
|
seen_at?: string;
|
|
84
107
|
};
|
|
108
|
+
/** Payload on `event: limit` (RFC AW) — a per-scope token-budget crossing.
|
|
109
|
+
* Nil on all other event types. */
|
|
110
|
+
limit?: LimitInfo;
|
|
85
111
|
agent_id?: string;
|
|
86
112
|
run_id?: string;
|
|
87
113
|
session_id?: string;
|
|
@@ -1660,3 +1686,61 @@ export interface LLMEmbeddingsResponse {
|
|
|
1660
1686
|
model: string;
|
|
1661
1687
|
usage: LLMEmbeddingsUsage;
|
|
1662
1688
|
}
|
|
1689
|
+
/** A whitelisted grouping dimension for the usage report. */
|
|
1690
|
+
export type UsageDimension = "tenant" | "user" | "provider" | "model" | "source";
|
|
1691
|
+
/** One grouped row of a usage report; only the grouped dimensions are set. */
|
|
1692
|
+
export interface UsageAggregate {
|
|
1693
|
+
tenant_id?: string;
|
|
1694
|
+
user_id?: string;
|
|
1695
|
+
provider?: string;
|
|
1696
|
+
model?: string;
|
|
1697
|
+
/** operator | tenant | user */
|
|
1698
|
+
credential_source?: string;
|
|
1699
|
+
input_tokens: number;
|
|
1700
|
+
output_tokens: number;
|
|
1701
|
+
cache_creation_tokens: number;
|
|
1702
|
+
cache_read_tokens: number;
|
|
1703
|
+
cost: number;
|
|
1704
|
+
currency?: string;
|
|
1705
|
+
call_count: number;
|
|
1706
|
+
unpriced_calls: number;
|
|
1707
|
+
}
|
|
1708
|
+
export interface UsageReportResponse {
|
|
1709
|
+
group_by: string[];
|
|
1710
|
+
from?: string;
|
|
1711
|
+
to?: string;
|
|
1712
|
+
rows: UsageAggregate[];
|
|
1713
|
+
}
|
|
1714
|
+
/** A per-scope token budget (RFC AW) plus its live month-to-date usage.
|
|
1715
|
+
* `soft_limit` / `hard_limit` are absent when that tier is unset (no ceiling
|
|
1716
|
+
* on that axis). Mirrors one row of GET /v1/_limits. */
|
|
1717
|
+
export interface TokenLimit {
|
|
1718
|
+
tenant_id: string;
|
|
1719
|
+
/** "operator" | "tenant" | "user" */
|
|
1720
|
+
scope: string;
|
|
1721
|
+
/** tenant id (scope=tenant), user subject (scope=user), "" (operator). */
|
|
1722
|
+
scope_id?: string;
|
|
1723
|
+
soft_limit?: number;
|
|
1724
|
+
hard_limit?: number;
|
|
1725
|
+
/** The scope's current month-to-date token total. */
|
|
1726
|
+
used: number;
|
|
1727
|
+
updated_at?: string;
|
|
1728
|
+
updated_by?: string;
|
|
1729
|
+
}
|
|
1730
|
+
export interface TokenLimitsResponse {
|
|
1731
|
+
limits: TokenLimit[];
|
|
1732
|
+
}
|
|
1733
|
+
/** The PUT /v1/_limits body (RFC AW). A present `soft_limit`/`hard_limit` sets
|
|
1734
|
+
* that tier; omitting it clears the tier (unlimited on that axis) — a full-row
|
|
1735
|
+
* upsert. `tenant_id` is an admin-only target; a tenant operator is confined to
|
|
1736
|
+
* its own tenant regardless of this field. */
|
|
1737
|
+
export interface SetTokenLimitRequest {
|
|
1738
|
+
/** Admin-only target tenant; ignored for confinement on a scoped caller. */
|
|
1739
|
+
tenant_id?: string;
|
|
1740
|
+
/** "operator" | "tenant" | "user" */
|
|
1741
|
+
scope: string;
|
|
1742
|
+
/** Required for scope=user (the subject); must be empty for scope=tenant. */
|
|
1743
|
+
scope_id?: string;
|
|
1744
|
+
soft_limit?: number;
|
|
1745
|
+
hard_limit?: number;
|
|
1746
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcycle/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 63 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).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|