@loomcycle/client 0.12.7 → 0.13.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.
@@ -91,6 +91,8 @@ class LoomcycleClient {
91
91
  body.user_bearer = opts.userBearer;
92
92
  if (opts.userCredentials !== undefined)
93
93
  body.user_credentials = opts.userCredentials;
94
+ if (opts.parentContext !== undefined)
95
+ body.parent_context = opts.parentContext;
94
96
  yield* this.streamSSE("/v1/runs", body, opts.signal, opts.debug);
95
97
  }
96
98
  /**
@@ -129,6 +131,8 @@ class LoomcycleClient {
129
131
  body.user_bearer = opts.userBearer;
130
132
  if (opts.userCredentials !== undefined)
131
133
  body.user_credentials = opts.userCredentials;
134
+ if (opts.parentContext !== undefined)
135
+ body.parent_context = opts.parentContext;
132
136
  yield* this.streamSSE(`/v1/sessions/${encodeURIComponent(opts.sessionId)}/messages`, body, opts.signal, opts.debug);
133
137
  }
134
138
  // ---- Agent metadata ----
@@ -458,6 +462,36 @@ class LoomcycleClient {
458
462
  async scheduleDef(input, opts) {
459
463
  return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_scheduledef", input, opts);
460
464
  }
465
+ /** Invoke the v1.x RFC G A2AServerCardDef substrate tool over HTTP.
466
+ * Author + fork + retire A2A server-card definitions at runtime.
467
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A server cards.
468
+ *
469
+ * Operator-admin-only: this endpoint requires the bearer token.
470
+ *
471
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
472
+ * "list" | "retire", ...}`.
473
+ *
474
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
475
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
476
+ * {@link AuthError} on 401. */
477
+ async a2aServerCardDef(input, opts) {
478
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_a2aservercarddef", input, opts);
479
+ }
480
+ /** Invoke the v1.x RFC G A2AAgentDef substrate tool over HTTP.
481
+ * Author + fork + retire A2A agent definitions at runtime.
482
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A agents.
483
+ *
484
+ * Operator-admin-only: this endpoint requires the bearer token.
485
+ *
486
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
487
+ * "list" | "retire", ...}`.
488
+ *
489
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
490
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
491
+ * {@link AuthError} on 401. */
492
+ async a2aAgentDef(input, opts) {
493
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_a2aagentdef", input, opts);
494
+ }
461
495
  // ---- v0.10.3 Library v2 enumeration (read-only, merged yaml+substrate) ----
462
496
  /** List every agent the runtime knows about — yaml-static + dynamic
463
497
  * AgentDefs merged into one envelope per name. Each entry carries
package/dist/client.d.ts CHANGED
@@ -321,6 +321,36 @@ export declare class LoomcycleClient {
321
321
  scheduleDef(input: SubstrateToolInput, opts?: {
322
322
  signal?: AbortSignal;
323
323
  }): Promise<SubstrateToolResponse>;
324
+ /** Invoke the v1.x RFC G A2AServerCardDef substrate tool over HTTP.
325
+ * Author + fork + retire A2A server-card definitions at runtime.
326
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A server cards.
327
+ *
328
+ * Operator-admin-only: this endpoint requires the bearer token.
329
+ *
330
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
331
+ * "list" | "retire", ...}`.
332
+ *
333
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
334
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
335
+ * {@link AuthError} on 401. */
336
+ a2aServerCardDef(input: SubstrateToolInput, opts?: {
337
+ signal?: AbortSignal;
338
+ }): Promise<SubstrateToolResponse>;
339
+ /** Invoke the v1.x RFC G A2AAgentDef substrate tool over HTTP.
340
+ * Author + fork + retire A2A agent definitions at runtime.
341
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A agents.
342
+ *
343
+ * Operator-admin-only: this endpoint requires the bearer token.
344
+ *
345
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
346
+ * "list" | "retire", ...}`.
347
+ *
348
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
349
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
350
+ * {@link AuthError} on 401. */
351
+ a2aAgentDef(input: SubstrateToolInput, opts?: {
352
+ signal?: AbortSignal;
353
+ }): Promise<SubstrateToolResponse>;
324
354
  /** List every agent the runtime knows about — yaml-static + dynamic
325
355
  * AgentDefs merged into one envelope per name. Each entry carries
326
356
  * `source: "static-only" | "dynamic-only" | "both"` so callers can
package/dist/client.js CHANGED
@@ -88,6 +88,8 @@ export class LoomcycleClient {
88
88
  body.user_bearer = opts.userBearer;
89
89
  if (opts.userCredentials !== undefined)
90
90
  body.user_credentials = opts.userCredentials;
91
+ if (opts.parentContext !== undefined)
92
+ body.parent_context = opts.parentContext;
91
93
  yield* this.streamSSE("/v1/runs", body, opts.signal, opts.debug);
92
94
  }
93
95
  /**
@@ -126,6 +128,8 @@ export class LoomcycleClient {
126
128
  body.user_bearer = opts.userBearer;
127
129
  if (opts.userCredentials !== undefined)
128
130
  body.user_credentials = opts.userCredentials;
131
+ if (opts.parentContext !== undefined)
132
+ body.parent_context = opts.parentContext;
129
133
  yield* this.streamSSE(`/v1/sessions/${encodeURIComponent(opts.sessionId)}/messages`, body, opts.signal, opts.debug);
130
134
  }
131
135
  // ---- Agent metadata ----
@@ -455,6 +459,36 @@ export class LoomcycleClient {
455
459
  async scheduleDef(input, opts) {
456
460
  return postJSON(this.ctx, "/v1/_scheduledef", input, opts);
457
461
  }
462
+ /** Invoke the v1.x RFC G A2AServerCardDef substrate tool over HTTP.
463
+ * Author + fork + retire A2A server-card definitions at runtime.
464
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A server cards.
465
+ *
466
+ * Operator-admin-only: this endpoint requires the bearer token.
467
+ *
468
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
469
+ * "list" | "retire", ...}`.
470
+ *
471
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
472
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
473
+ * {@link AuthError} on 401. */
474
+ async a2aServerCardDef(input, opts) {
475
+ return postJSON(this.ctx, "/v1/_a2aservercarddef", input, opts);
476
+ }
477
+ /** Invoke the v1.x RFC G A2AAgentDef substrate tool over HTTP.
478
+ * Author + fork + retire A2A agent definitions at runtime.
479
+ * Mirror of {@link LoomcycleClient.scheduleDef} for A2A agents.
480
+ *
481
+ * Operator-admin-only: this endpoint requires the bearer token.
482
+ *
483
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
484
+ * "list" | "retire", ...}`.
485
+ *
486
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals;
487
+ * {@link InvalidArgumentError} on 400 (malformed JSON);
488
+ * {@link AuthError} on 401. */
489
+ async a2aAgentDef(input, opts) {
490
+ return postJSON(this.ctx, "/v1/_a2aagentdef", input, opts);
491
+ }
458
492
  // ---- v0.10.3 Library v2 enumeration (read-only, merged yaml+substrate) ----
459
493
  /** List every agent the runtime knows about — yaml-static + dynamic
460
494
  * AgentDefs merged into one envelope per name. Each entry carries
package/dist/index.d.ts CHANGED
@@ -78,5 +78,5 @@
78
78
  * See `adapters/ts/README.md` for usage examples.
79
79
  */
80
80
  export { LoomcycleClient } from "./client.js";
81
- export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, PromptContent, PromptSegment, RetryInfo, RunOptions, ToolUse, Usage, Agent, AgentStatus, AgentUsage, CancelAgentResult, ListAgentsResponse, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, PauseResult, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, 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, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ChannelPublishResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, CreateChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, } from "./types.js";
81
+ export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, ToolUse, Usage, Agent, AgentStatus, AgentUsage, CancelAgentResult, ListAgentsResponse, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, PauseResult, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, 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, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ChannelPublishResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, CreateChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, } from "./types.js";
82
82
  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
@@ -69,6 +69,7 @@ export interface AgentEvent {
69
69
  run_id?: string;
70
70
  session_id?: string;
71
71
  parent_agent_id?: string | null;
72
+ parent_context?: ParentContext;
72
73
  meta_subtype?: "stream_open" | "stream_close";
73
74
  meta_reason?: string;
74
75
  }
@@ -139,6 +140,14 @@ export interface RunOptions {
139
140
  * field auto-promotes to `userCredentials.default` for back-compat
140
141
  * with v0.8.x flows. Never persisted; never logged. */
141
142
  userCredentials?: Record<string, string>;
143
+ /** Opaque caller-tracking lineage (v0.12.x). Carried verbatim by the
144
+ * runtime, inherited UNCHANGED by every sub-agent the Agent tool
145
+ * spawns, persisted on each run row, and echoed back on the per-agent
146
+ * report surfaces (agent status, run-state stream, the `event: agent`
147
+ * frame) — so you can attribute a child sub-agent's usage to the
148
+ * user-initiated request that spawned the whole tree. Not a secret.
149
+ * Omitted = no tracking context. */
150
+ parentContext?: ParentContext;
142
151
  /** Opt-in observability: when true, the iterator emits client-
143
152
  * synthesized `{ type: "_meta", meta_subtype: "stream_open" | "stream_close" }`
144
153
  * events around the real event stream. `meta_reason` carries the
@@ -149,6 +158,20 @@ export interface RunOptions {
149
158
  debug?: boolean;
150
159
  signal?: AbortSignal;
151
160
  }
161
+ /** Opaque caller-tracking lineage (v0.12.x) attached to a run and
162
+ * propagated to all its sub-agents. The runtime stores and echoes
163
+ * these fields verbatim and never interprets them. All fields
164
+ * optional; an all-empty object is treated as absent. */
165
+ export interface ParentContext {
166
+ /** The consumer's identifier for the user-initiated run at the root of
167
+ * the spawn tree — echoed on every descendant. */
168
+ root_agent_run_id?: string;
169
+ /** The consumer's logical-operation key for the root request. */
170
+ function_key?: string;
171
+ /** The consumer's tier marker captured at root-run time (distinct from
172
+ * `userTier`, which is loomcycle's resolver policy). */
173
+ tier_at_run?: string;
174
+ }
152
175
  export interface ContinueOptions {
153
176
  /** Required — the session to continue. */
154
177
  sessionId: string;
@@ -179,6 +202,10 @@ export interface ContinueOptions {
179
202
  * {@link RunOptions.userCredentials} for the full shape — same
180
203
  * semantics, supplied per-continuation rather than per-fresh-run. */
181
204
  userCredentials?: Record<string, string>;
205
+ /** Opaque caller-tracking lineage (v0.12.x). See
206
+ * {@link RunOptions.parentContext} — same shape; a continuation may
207
+ * (re)set the lineage for the new run it creates. */
208
+ parentContext?: ParentContext;
182
209
  /** Opt-in observability: see {@link RunOptions.debug}. Same shape. */
183
210
  debug?: boolean;
184
211
  signal?: AbortSignal;
@@ -222,6 +249,11 @@ export interface Agent {
222
249
  usage: AgentUsage;
223
250
  last_heartbeat_at: string | null;
224
251
  live: boolean;
252
+ /** Opaque caller-tracking lineage this run carries (inherited from its
253
+ * root for sub-agents), v0.12.x. Echoed here alongside `usage` so you
254
+ * can attribute a child sub-agent's cost to the user-initiated request
255
+ * in a single fetch. Omitted when the run carried no context. */
256
+ parent_context?: ParentContext;
225
257
  }
226
258
  export interface ListAgentsResponse {
227
259
  agents: Agent[];
@@ -744,6 +776,10 @@ export interface RunStateEvent {
744
776
  stop_reason?: string;
745
777
  error?: string;
746
778
  ts: string;
779
+ /** Opaque caller-tracking lineage echoed on the transition (v0.12.x),
780
+ * so a subscriber learns which root request a finishing sub-agent
781
+ * belongs to. Omitted when the run carried no context. */
782
+ parent_context?: ParentContext;
747
783
  }
748
784
  /** Initial stream_open frame emitted before the first run_state. */
749
785
  export interface RunStateStreamOpen {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/client",
3
- "version": "0.12.7",
3
+ "version": "0.13.0",
4
4
  "description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 46 methods covering run streaming, agent metadata, pause/resume/state, 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).",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",