@loomcycle/client 0.11.5 → 0.12.7

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.
@@ -89,6 +89,8 @@ class LoomcycleClient {
89
89
  body.user_tier = opts.userTier;
90
90
  if (opts.userBearer !== undefined)
91
91
  body.user_bearer = opts.userBearer;
92
+ if (opts.userCredentials !== undefined)
93
+ body.user_credentials = opts.userCredentials;
92
94
  yield* this.streamSSE("/v1/runs", body, opts.signal, opts.debug);
93
95
  }
94
96
  /**
@@ -125,6 +127,8 @@ class LoomcycleClient {
125
127
  body.user_tier = opts.userTier;
126
128
  if (opts.userBearer !== undefined)
127
129
  body.user_bearer = opts.userBearer;
130
+ if (opts.userCredentials !== undefined)
131
+ body.user_credentials = opts.userCredentials;
128
132
  yield* this.streamSSE(`/v1/sessions/${encodeURIComponent(opts.sessionId)}/messages`, body, opts.signal, opts.debug);
129
133
  }
130
134
  // ---- Agent metadata ----
@@ -422,6 +426,38 @@ class LoomcycleClient {
422
426
  async mcpServerDef(input, opts) {
423
427
  return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_mcpserverdef", input, opts);
424
428
  }
429
+ /** Invoke the v1.x RFC E ScheduleDef substrate tool over HTTP.
430
+ * Author + fork + retire scheduled-run definitions at runtime.
431
+ * Mirror of {@link LoomcycleClient.agentDef} for schedules — the
432
+ * primary use case is JobEmber-style "fork a yaml template
433
+ * per-user with their bearer + tier cron" workflows.
434
+ *
435
+ * Operator-admin-only: this endpoint requires the bearer token.
436
+ *
437
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
438
+ * "list" | "retire", ...}`. Note that ScheduleDef has 5 ops
439
+ * (no separate `promote` — forks auto-promote by default per
440
+ * RFC E's worked example; no `verify` — no content_sha256 in
441
+ * v1.x).
442
+ *
443
+ * Sharp edges (substrate refuses these):
444
+ * - Name colliding with a static cfg.ScheduledRuns entry is
445
+ * refused on `create` (yaml is ground truth; use `fork` to
446
+ * derive a new version).
447
+ * - Fork against a template with `required_credentials` must
448
+ * supply all keys in `user_credentials` — loud-fail at fork
449
+ * time rather than silent ingestion-time failure when the
450
+ * sweeper fires.
451
+ * - Cron syntax is validated server-side; invalid expressions
452
+ * refuse with a parse error.
453
+ *
454
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals
455
+ * (static-name collision, missing required credential, invalid
456
+ * cron, etc.); {@link InvalidArgumentError} on 400 (malformed
457
+ * JSON); {@link AuthError} on 401. */
458
+ async scheduleDef(input, opts) {
459
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_scheduledef", input, opts);
460
+ }
425
461
  // ---- v0.10.3 Library v2 enumeration (read-only, merged yaml+substrate) ----
426
462
  /** List every agent the runtime knows about — yaml-static + dynamic
427
463
  * AgentDefs merged into one envelope per name. Each entry carries
package/dist/cjs/index.js CHANGED
@@ -43,9 +43,11 @@
43
43
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
44
44
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
45
45
  *
46
- * // Substrate admin (v0.8.22)
46
+ * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
47
47
  * agentDef(input): Promise<SubstrateToolResponse>
48
48
  * skillDef(input): Promise<SubstrateToolResponse>
49
+ * mcpServerDef(input): Promise<SubstrateToolResponse>
50
+ * scheduleDef(input): Promise<SubstrateToolResponse>
49
51
  *
50
52
  * // Library v2 enumeration (v0.10.3 — yaml+substrate merged)
51
53
  * listLibraryAgents(): Promise<LibraryListResponse<LibraryAgentDefinition>>
package/dist/client.d.ts CHANGED
@@ -289,6 +289,38 @@ export declare class LoomcycleClient {
289
289
  mcpServerDef(input: SubstrateToolInput, opts?: {
290
290
  signal?: AbortSignal;
291
291
  }): Promise<SubstrateToolResponse>;
292
+ /** Invoke the v1.x RFC E ScheduleDef substrate tool over HTTP.
293
+ * Author + fork + retire scheduled-run definitions at runtime.
294
+ * Mirror of {@link LoomcycleClient.agentDef} for schedules — the
295
+ * primary use case is JobEmber-style "fork a yaml template
296
+ * per-user with their bearer + tier cron" workflows.
297
+ *
298
+ * Operator-admin-only: this endpoint requires the bearer token.
299
+ *
300
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
301
+ * "list" | "retire", ...}`. Note that ScheduleDef has 5 ops
302
+ * (no separate `promote` — forks auto-promote by default per
303
+ * RFC E's worked example; no `verify` — no content_sha256 in
304
+ * v1.x).
305
+ *
306
+ * Sharp edges (substrate refuses these):
307
+ * - Name colliding with a static cfg.ScheduledRuns entry is
308
+ * refused on `create` (yaml is ground truth; use `fork` to
309
+ * derive a new version).
310
+ * - Fork against a template with `required_credentials` must
311
+ * supply all keys in `user_credentials` — loud-fail at fork
312
+ * time rather than silent ingestion-time failure when the
313
+ * sweeper fires.
314
+ * - Cron syntax is validated server-side; invalid expressions
315
+ * refuse with a parse error.
316
+ *
317
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals
318
+ * (static-name collision, missing required credential, invalid
319
+ * cron, etc.); {@link InvalidArgumentError} on 400 (malformed
320
+ * JSON); {@link AuthError} on 401. */
321
+ scheduleDef(input: SubstrateToolInput, opts?: {
322
+ signal?: AbortSignal;
323
+ }): Promise<SubstrateToolResponse>;
292
324
  /** List every agent the runtime knows about — yaml-static + dynamic
293
325
  * AgentDefs merged into one envelope per name. Each entry carries
294
326
  * `source: "static-only" | "dynamic-only" | "both"` so callers can
package/dist/client.js CHANGED
@@ -86,6 +86,8 @@ export class LoomcycleClient {
86
86
  body.user_tier = opts.userTier;
87
87
  if (opts.userBearer !== undefined)
88
88
  body.user_bearer = opts.userBearer;
89
+ if (opts.userCredentials !== undefined)
90
+ body.user_credentials = opts.userCredentials;
89
91
  yield* this.streamSSE("/v1/runs", body, opts.signal, opts.debug);
90
92
  }
91
93
  /**
@@ -122,6 +124,8 @@ export class LoomcycleClient {
122
124
  body.user_tier = opts.userTier;
123
125
  if (opts.userBearer !== undefined)
124
126
  body.user_bearer = opts.userBearer;
127
+ if (opts.userCredentials !== undefined)
128
+ body.user_credentials = opts.userCredentials;
125
129
  yield* this.streamSSE(`/v1/sessions/${encodeURIComponent(opts.sessionId)}/messages`, body, opts.signal, opts.debug);
126
130
  }
127
131
  // ---- Agent metadata ----
@@ -419,6 +423,38 @@ export class LoomcycleClient {
419
423
  async mcpServerDef(input, opts) {
420
424
  return postJSON(this.ctx, "/v1/_mcpserverdef", input, opts);
421
425
  }
426
+ /** Invoke the v1.x RFC E ScheduleDef substrate tool over HTTP.
427
+ * Author + fork + retire scheduled-run definitions at runtime.
428
+ * Mirror of {@link LoomcycleClient.agentDef} for schedules — the
429
+ * primary use case is JobEmber-style "fork a yaml template
430
+ * per-user with their bearer + tier cron" workflows.
431
+ *
432
+ * Operator-admin-only: this endpoint requires the bearer token.
433
+ *
434
+ * Op-discriminated input: `{op: "create" | "fork" | "get" |
435
+ * "list" | "retire", ...}`. Note that ScheduleDef has 5 ops
436
+ * (no separate `promote` — forks auto-promote by default per
437
+ * RFC E's worked example; no `verify` — no content_sha256 in
438
+ * v1.x).
439
+ *
440
+ * Sharp edges (substrate refuses these):
441
+ * - Name colliding with a static cfg.ScheduledRuns entry is
442
+ * refused on `create` (yaml is ground truth; use `fork` to
443
+ * derive a new version).
444
+ * - Fork against a template with `required_credentials` must
445
+ * supply all keys in `user_credentials` — loud-fail at fork
446
+ * time rather than silent ingestion-time failure when the
447
+ * sweeper fires.
448
+ * - Cron syntax is validated server-side; invalid expressions
449
+ * refuse with a parse error.
450
+ *
451
+ * Raises {@link SubstrateToolRefusedError} on tool-level refusals
452
+ * (static-name collision, missing required credential, invalid
453
+ * cron, etc.); {@link InvalidArgumentError} on 400 (malformed
454
+ * JSON); {@link AuthError} on 401. */
455
+ async scheduleDef(input, opts) {
456
+ return postJSON(this.ctx, "/v1/_scheduledef", input, opts);
457
+ }
422
458
  // ---- v0.10.3 Library v2 enumeration (read-only, merged yaml+substrate) ----
423
459
  /** List every agent the runtime knows about — yaml-static + dynamic
424
460
  * AgentDefs merged into one envelope per name. Each entry carries
package/dist/index.d.ts CHANGED
@@ -42,9 +42,11 @@
42
42
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
43
43
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
44
44
  *
45
- * // Substrate admin (v0.8.22)
45
+ * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
46
46
  * agentDef(input): Promise<SubstrateToolResponse>
47
47
  * skillDef(input): Promise<SubstrateToolResponse>
48
+ * mcpServerDef(input): Promise<SubstrateToolResponse>
49
+ * scheduleDef(input): Promise<SubstrateToolResponse>
48
50
  *
49
51
  * // Library v2 enumeration (v0.10.3 — yaml+substrate merged)
50
52
  * listLibraryAgents(): Promise<LibraryListResponse<LibraryAgentDefinition>>
package/dist/index.js CHANGED
@@ -42,9 +42,11 @@
42
42
  * listRunInterrupts(runId, opts?): Promise<InterruptListResponse>
43
43
  * resolveInterrupt(runId, interruptId, opts): Promise<unknown>
44
44
  *
45
- * // Substrate admin (v0.8.22)
45
+ * // Substrate admin (v0.8.22; mcpServerDef v0.9.x; scheduleDef v1.x)
46
46
  * agentDef(input): Promise<SubstrateToolResponse>
47
47
  * skillDef(input): Promise<SubstrateToolResponse>
48
+ * mcpServerDef(input): Promise<SubstrateToolResponse>
49
+ * scheduleDef(input): Promise<SubstrateToolResponse>
48
50
  *
49
51
  * // Library v2 enumeration (v0.10.3 — yaml+substrate merged)
50
52
  * listLibraryAgents(): Promise<LibraryListResponse<LibraryAgentDefinition>>
package/dist/types.d.ts CHANGED
@@ -130,6 +130,15 @@ export interface RunOptions {
130
130
  * (static-bearer setups unaffected). Sub-agents inherit identically.
131
131
  * Never persisted; never logged in full. */
132
132
  userBearer?: string;
133
+ /** Per-tool named credentials map (v1.x RFC F). Per-MCP-server bearers
134
+ * keyed by operator-chosen name (convention: the `mcp_servers.<name>`
135
+ * yaml key). Substituted into MCP HTTP header values containing
136
+ * `${run.credentials.<name>}` at outbound request-build time. Keys
137
+ * match `[a-zA-Z0-9_-]{1,64}`; values arbitrary strings. Sub-agents
138
+ * inherit the whole map. Coexists with `userBearer` — the legacy
139
+ * field auto-promotes to `userCredentials.default` for back-compat
140
+ * with v0.8.x flows. Never persisted; never logged. */
141
+ userCredentials?: Record<string, string>;
133
142
  /** Opt-in observability: when true, the iterator emits client-
134
143
  * synthesized `{ type: "_meta", meta_subtype: "stream_open" | "stream_close" }`
135
144
  * events around the real event stream. `meta_reason` carries the
@@ -166,6 +175,10 @@ export interface ContinueOptions {
166
175
  * so different continuations in the same session may carry
167
176
  * different end-user tokens. */
168
177
  userBearer?: string;
178
+ /** Per-tool named credentials map (v1.x RFC F). See
179
+ * {@link RunOptions.userCredentials} for the full shape — same
180
+ * semantics, supplied per-continuation rather than per-fresh-run. */
181
+ userCredentials?: Record<string, string>;
169
182
  /** Opt-in observability: see {@link RunOptions.debug}. Same shape. */
170
183
  debug?: boolean;
171
184
  signal?: AbortSignal;
@@ -192,6 +205,7 @@ export interface AgentUsage {
192
205
  cache_creation_tokens?: number;
193
206
  cache_read_tokens?: number;
194
207
  model?: string;
208
+ provider?: string;
195
209
  }
196
210
  export interface Agent {
197
211
  agent_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/client",
3
- "version": "0.11.5",
3
+ "version": "0.12.7",
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",