@loomcycle/client 1.21.0 → 1.22.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.
@@ -292,6 +292,23 @@ class LoomcycleClient {
292
292
  body.reason = opts.reason;
293
293
  return (0, fetch_helpers_js_1.postJSON)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/compact`, body, opts);
294
294
  }
295
+ /**
296
+ * Stop the CURRENT turn of a live interactive run (its in-flight generation +
297
+ * the tool calls it started) and park it at awaiting_input — session +
298
+ * transcript intact, ready for the next message. This is the "Esc" gesture,
299
+ * NOT whole-run cancel ({@link LoomcycleClient.cancelAgent}), which terminates
300
+ * the run. Returns `{ run_id, stopped, parked }`.
301
+ *
302
+ * Rejects with RunBusyError (409) when the run isn't mid-turn or isn't
303
+ * interactive, and AgentNotFoundError (404) for an unknown / cross-tenant run.
304
+ * Mirrors POST /v1/runs/{run_id}/cancel. (RFC BH)
305
+ */
306
+ async cancelTurn(runId, opts) {
307
+ const body = {};
308
+ if (opts?.reason !== undefined)
309
+ body.reason = opts.reason;
310
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/cancel`, body, opts);
311
+ }
295
312
  // ---- Agent metadata ----
296
313
  /** Read one agent's status + usage stats. Raises AgentNotFoundError
297
314
  * when the agent_id is unknown. */
@@ -556,13 +573,33 @@ class LoomcycleClient {
556
573
  /** Resolve a pending Interruption.ask from outside the agent
557
574
  * loop. Lets a TS-side dashboard or service act as the human
558
575
  * answerer when operator yaml configures the consumer-MCP
559
- * backend. */
576
+ * backend. Pass `disposition: "declined"` (or use
577
+ * {@link LoomcycleClient.cancelInterrupt}) to decline WITHOUT an
578
+ * answer so the waiting Question tool proceeds (RFC BH). */
560
579
  async resolveInterrupt(runId, interruptId, opts) {
561
- return (0, fetch_helpers_js_1.postJSON)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/interrupts/${encodeURIComponent(interruptId)}/resolve`, {
580
+ const body = {
562
581
  kind: opts.kind ?? "question",
563
- answer: opts.answer,
564
582
  resolved_by: opts.resolvedBy ?? "client",
565
- }, opts);
583
+ };
584
+ // A decline carries no answer; omit it rather than sending "" so the
585
+ // server's "declined must not carry an answer" gate isn't tripped.
586
+ if (opts.answer !== undefined)
587
+ body.answer = opts.answer;
588
+ if (opts.disposition !== undefined)
589
+ body.disposition = opts.disposition;
590
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/interrupts/${encodeURIComponent(interruptId)}/resolve`, body, opts);
591
+ }
592
+ /** Decline a pending Interruption.ask WITHOUT answering it (RFC BH) — the
593
+ * waiting Question tool returns a non-error "declined" result so the agent
594
+ * proceeds, and the run keeps going. A thin wrapper over
595
+ * {@link LoomcycleClient.resolveInterrupt} with `disposition: "declined"`
596
+ * (no answer). Mirrors POST .../resolve `{ disposition: "declined" }`. */
597
+ async cancelInterrupt(runId, interruptId, opts) {
598
+ return this.resolveInterrupt(runId, interruptId, {
599
+ disposition: "declined",
600
+ resolvedBy: opts?.resolvedBy,
601
+ signal: opts?.signal,
602
+ });
566
603
  }
567
604
  // ---- Hook management (hooks-connector series, PR C) ----
568
605
  /** Register a pre- or post-tool webhook. The callback_url must be
package/dist/cjs/index.js CHANGED
@@ -40,10 +40,14 @@
40
40
  * listMemoryEntries(scope, scopeID, opts?): Promise<MemoryEntriesResponse>
41
41
  * getMemoryEntry(scope, scopeID, key): Promise<MemoryEntryResponse>
42
42
  *
43
- * // Interruption (v0.8.16)
43
+ * // Interruption (v0.8.16; decline RFC BH)
44
44
  * listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
45
45
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
46
46
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
47
+ * cancelInterrupt(runId, interruptId, opts?): Promise<unknown>
48
+ *
49
+ * // Turn-scoped run control (RFC BH)
50
+ * cancelTurn(runId, opts?): Promise<CancelTurnResult>
47
51
  *
48
52
  * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
49
53
  * agentDef(input): Promise<SubstrateToolResponse>
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 { 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, CreatedTeam, ListTeamsResponse, TeamDefDetail, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, TranscriptResponse, WhoamiResponse, UsageDimension, UsageReportResponse, TokenLimit, TokenLimitsResponse, SetTokenLimitRequest } from "./types.js";
28
+ 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, CancelTurnResult, RunBatchOptions, RunBatchResult, RunOptions, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, CreatedTeam, ListTeamsResponse, TeamDefDetail, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, TranscriptResponse, WhoamiResponse, UsageDimension, UsageReportResponse, TokenLimit, TokenLimitsResponse, SetTokenLimitRequest } from "./types.js";
29
29
  export declare class LoomcycleClient {
30
30
  private ctx;
31
31
  constructor(opts?: ClientOptions);
@@ -143,6 +143,21 @@ export declare class LoomcycleClient {
143
143
  reason?: string;
144
144
  signal?: AbortSignal;
145
145
  }): Promise<CompactRunResult>;
146
+ /**
147
+ * Stop the CURRENT turn of a live interactive run (its in-flight generation +
148
+ * the tool calls it started) and park it at awaiting_input — session +
149
+ * transcript intact, ready for the next message. This is the "Esc" gesture,
150
+ * NOT whole-run cancel ({@link LoomcycleClient.cancelAgent}), which terminates
151
+ * the run. Returns `{ run_id, stopped, parked }`.
152
+ *
153
+ * Rejects with RunBusyError (409) when the run isn't mid-turn or isn't
154
+ * interactive, and AgentNotFoundError (404) for an unknown / cross-tenant run.
155
+ * Mirrors POST /v1/runs/{run_id}/cancel. (RFC BH)
156
+ */
157
+ cancelTurn(runId: string, opts?: {
158
+ reason?: string;
159
+ signal?: AbortSignal;
160
+ }): Promise<CancelTurnResult>;
146
161
  /** Read one agent's status + usage stats. Raises AgentNotFoundError
147
162
  * when the agent_id is unknown. */
148
163
  getAgent(agentId: string, opts?: {
@@ -347,10 +362,21 @@ export declare class LoomcycleClient {
347
362
  /** Resolve a pending Interruption.ask from outside the agent
348
363
  * loop. Lets a TS-side dashboard or service act as the human
349
364
  * answerer when operator yaml configures the consumer-MCP
350
- * backend. */
365
+ * backend. Pass `disposition: "declined"` (or use
366
+ * {@link LoomcycleClient.cancelInterrupt}) to decline WITHOUT an
367
+ * answer so the waiting Question tool proceeds (RFC BH). */
351
368
  resolveInterrupt(runId: string, interruptId: string, opts: ResolveInterruptOptions & {
352
369
  signal?: AbortSignal;
353
370
  }): Promise<unknown>;
371
+ /** Decline a pending Interruption.ask WITHOUT answering it (RFC BH) — the
372
+ * waiting Question tool returns a non-error "declined" result so the agent
373
+ * proceeds, and the run keeps going. A thin wrapper over
374
+ * {@link LoomcycleClient.resolveInterrupt} with `disposition: "declined"`
375
+ * (no answer). Mirrors POST .../resolve `{ disposition: "declined" }`. */
376
+ cancelInterrupt(runId: string, interruptId: string, opts?: {
377
+ resolvedBy?: string;
378
+ signal?: AbortSignal;
379
+ }): Promise<unknown>;
354
380
  /** Register a pre- or post-tool webhook. The callback_url must be
355
381
  * an http:// or https:// endpoint the CONSUMER runs — loomcycle
356
382
  * POSTs PreHookCall / PostHookCall payloads to it. This method
package/dist/client.js CHANGED
@@ -289,6 +289,23 @@ export class LoomcycleClient {
289
289
  body.reason = opts.reason;
290
290
  return postJSON(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/compact`, body, opts);
291
291
  }
292
+ /**
293
+ * Stop the CURRENT turn of a live interactive run (its in-flight generation +
294
+ * the tool calls it started) and park it at awaiting_input — session +
295
+ * transcript intact, ready for the next message. This is the "Esc" gesture,
296
+ * NOT whole-run cancel ({@link LoomcycleClient.cancelAgent}), which terminates
297
+ * the run. Returns `{ run_id, stopped, parked }`.
298
+ *
299
+ * Rejects with RunBusyError (409) when the run isn't mid-turn or isn't
300
+ * interactive, and AgentNotFoundError (404) for an unknown / cross-tenant run.
301
+ * Mirrors POST /v1/runs/{run_id}/cancel. (RFC BH)
302
+ */
303
+ async cancelTurn(runId, opts) {
304
+ const body = {};
305
+ if (opts?.reason !== undefined)
306
+ body.reason = opts.reason;
307
+ return postJSON(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/cancel`, body, opts);
308
+ }
292
309
  // ---- Agent metadata ----
293
310
  /** Read one agent's status + usage stats. Raises AgentNotFoundError
294
311
  * when the agent_id is unknown. */
@@ -553,13 +570,33 @@ export class LoomcycleClient {
553
570
  /** Resolve a pending Interruption.ask from outside the agent
554
571
  * loop. Lets a TS-side dashboard or service act as the human
555
572
  * answerer when operator yaml configures the consumer-MCP
556
- * backend. */
573
+ * backend. Pass `disposition: "declined"` (or use
574
+ * {@link LoomcycleClient.cancelInterrupt}) to decline WITHOUT an
575
+ * answer so the waiting Question tool proceeds (RFC BH). */
557
576
  async resolveInterrupt(runId, interruptId, opts) {
558
- return postJSON(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/interrupts/${encodeURIComponent(interruptId)}/resolve`, {
577
+ const body = {
559
578
  kind: opts.kind ?? "question",
560
- answer: opts.answer,
561
579
  resolved_by: opts.resolvedBy ?? "client",
562
- }, opts);
580
+ };
581
+ // A decline carries no answer; omit it rather than sending "" so the
582
+ // server's "declined must not carry an answer" gate isn't tripped.
583
+ if (opts.answer !== undefined)
584
+ body.answer = opts.answer;
585
+ if (opts.disposition !== undefined)
586
+ body.disposition = opts.disposition;
587
+ return postJSON(this.ctx, `/v1/runs/${encodeURIComponent(runId)}/interrupts/${encodeURIComponent(interruptId)}/resolve`, body, opts);
588
+ }
589
+ /** Decline a pending Interruption.ask WITHOUT answering it (RFC BH) — the
590
+ * waiting Question tool returns a non-error "declined" result so the agent
591
+ * proceeds, and the run keeps going. A thin wrapper over
592
+ * {@link LoomcycleClient.resolveInterrupt} with `disposition: "declined"`
593
+ * (no answer). Mirrors POST .../resolve `{ disposition: "declined" }`. */
594
+ async cancelInterrupt(runId, interruptId, opts) {
595
+ return this.resolveInterrupt(runId, interruptId, {
596
+ disposition: "declined",
597
+ resolvedBy: opts?.resolvedBy,
598
+ signal: opts?.signal,
599
+ });
563
600
  }
564
601
  // ---- Hook management (hooks-connector series, PR C) ----
565
602
  /** Register a pre- or post-tool webhook. The callback_url must be
package/dist/index.d.ts CHANGED
@@ -39,10 +39,14 @@
39
39
  * listMemoryEntries(scope, scopeID, opts?): Promise<MemoryEntriesResponse>
40
40
  * getMemoryEntry(scope, scopeID, key): Promise<MemoryEntryResponse>
41
41
  *
42
- * // Interruption (v0.8.16)
42
+ * // Interruption (v0.8.16; decline RFC BH)
43
43
  * listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
44
44
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
45
45
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
46
+ * cancelInterrupt(runId, interruptId, opts?): Promise<unknown>
47
+ *
48
+ * // Turn-scoped run control (RFC BH)
49
+ * cancelTurn(runId, opts?): Promise<CancelTurnResult>
46
50
  *
47
51
  * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
48
52
  * agentDef(input): Promise<SubstrateToolResponse>
@@ -107,5 +111,5 @@ export { InteractiveSession } from "./interactive.js";
107
111
  export type { InteractiveSessionOps } from "./interactive.js";
108
112
  export { ClientToolHost, clientToolsURL, CLIENT_TOOL_SUBPROTOCOL } from "./client-tools.js";
109
113
  export type { ClientToolSchema, ClientToolInvocation, ConnectClientToolsOptions, WebSocketLike, WebSocketCtor, } from "./client-tools.js";
110
- 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, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, TeamDefDetail, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, 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";
114
+ 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, CancelTurnResult, 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, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, TeamDefDetail, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, 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";
111
115
  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/index.js CHANGED
@@ -39,10 +39,14 @@
39
39
  * listMemoryEntries(scope, scopeID, opts?): Promise<MemoryEntriesResponse>
40
40
  * getMemoryEntry(scope, scopeID, key): Promise<MemoryEntryResponse>
41
41
  *
42
- * // Interruption (v0.8.16)
42
+ * // Interruption (v0.8.16; decline RFC BH)
43
43
  * listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
44
44
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
45
45
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
46
+ * cancelInterrupt(runId, interruptId, opts?): Promise<unknown>
47
+ *
48
+ * // Turn-scoped run control (RFC BH)
49
+ * cancelTurn(runId, opts?): Promise<CancelTurnResult>
46
50
  *
47
51
  * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
48
52
  * agentDef(input): Promise<SubstrateToolResponse>
package/dist/types.d.ts CHANGED
@@ -436,6 +436,15 @@ export interface CompactRunResult {
436
436
  after_tokens: number;
437
437
  applied: "live" | "marker" | "noop";
438
438
  }
439
+ /** Result of {@link LoomcycleClient.cancelTurn} (RFC BH) — the current turn was
440
+ * stopped and the interactive run parked at awaiting_input (session +
441
+ * transcript intact). This is NOT whole-run cancel ({@link
442
+ * LoomcycleClient.cancelAgent}). */
443
+ export interface CancelTurnResult {
444
+ run_id: string;
445
+ stopped: boolean;
446
+ parked: boolean;
447
+ }
439
448
  /** TranscriptEvent — one persisted store.Event from
440
449
  * GET /v1/sessions/{id}/transcript. The server wraps each
441
450
  * providers.Event in {seq, run_id, ts_ns, type, event:{...}}.
@@ -667,14 +676,19 @@ export interface InterruptListResponse {
667
676
  }
668
677
  export interface ResolveInterruptOptions {
669
678
  /** The human's answer. When the original ask declared options,
670
- * MUST be one of them (server-side validated). */
671
- answer: string;
679
+ * MUST be one of them (server-side validated). Optional so a
680
+ * decline ({@link LoomcycleClient.cancelInterrupt}) can omit it. */
681
+ answer?: string;
672
682
  /** Audit attribution for who resolved it (free-form). Defaults
673
683
  * server-side to "client" when omitted. */
674
684
  resolvedBy?: string;
675
685
  /** Discriminator. v0.8.16 supports only "question"; reserved
676
686
  * for v0.9.x future kinds. */
677
687
  kind?: string;
688
+ /** Disposition (RFC BH). Omit / "answer" carry the answer; "declined"
689
+ * resolves the interrupt WITHOUT an answer (skips option validation) so
690
+ * the waiting Question tool proceeds. */
691
+ disposition?: "answer" | "declined";
678
692
  }
679
693
  export type HookPhase = "pre" | "post";
680
694
  export type HookFailMode = "open" | "closed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/client",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 64 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.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",