@loomcycle/client 1.108.1 → 1.109.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 +2 -0
- package/dist/client.js +2 -0
- package/dist/types.d.ts +100 -3
- package/package.json +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -1583,6 +1583,8 @@ class LoomcycleClient {
|
|
|
1583
1583
|
body.review = target.review;
|
|
1584
1584
|
if (target.reviewTtlSeconds !== undefined)
|
|
1585
1585
|
body.review_ttl_seconds = target.reviewTtlSeconds;
|
|
1586
|
+
if (target.idempotencyKey !== undefined)
|
|
1587
|
+
body.idempotency_key = target.idempotencyKey;
|
|
1586
1588
|
return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/_teamdef", body, opts);
|
|
1587
1589
|
}
|
|
1588
1590
|
/** Read the debug breakpoints armed on a live team walk
|
package/dist/client.js
CHANGED
|
@@ -1580,6 +1580,8 @@ export class LoomcycleClient {
|
|
|
1580
1580
|
body.review = target.review;
|
|
1581
1581
|
if (target.reviewTtlSeconds !== undefined)
|
|
1582
1582
|
body.review_ttl_seconds = target.reviewTtlSeconds;
|
|
1583
|
+
if (target.idempotencyKey !== undefined)
|
|
1584
|
+
body.idempotency_key = target.idempotencyKey;
|
|
1583
1585
|
return postJSON(this.ctx, "/v1/_teamdef", body, opts);
|
|
1584
1586
|
}
|
|
1585
1587
|
/** Read the debug breakpoints armed on a live team walk
|
package/dist/types.d.ts
CHANGED
|
@@ -2373,7 +2373,7 @@ export interface TeamVerification {
|
|
|
2373
2373
|
}
|
|
2374
2374
|
/** What a {@link TeamIssue} is about. A wire enum that only grows: a kind this
|
|
2375
2375
|
* client does not know is still a `string`, so a new one never breaks a build. */
|
|
2376
|
-
export type TeamIssueKind = "name_invalid" | "parent_not_found" | "overlay_invalid" | "graph_invalid" | "size_cap" | "channel_reserved" | "channel_authority" | "acl_missing" | "channel_undeclared" | "local_channel_invalid" | "local_channel_missing" | "local_agent_invalid" | "local_agent_authority" | "local_agent_collision" | "local_agent_missing" | "local_agent_unreferenced" | "local_skill_invalid" | "local_webhook_authority" | "local_webhook_invalid" | "agent_missing" | "uncheckable" | (string & {});
|
|
2376
|
+
export type TeamIssueKind = "name_invalid" | "parent_not_found" | "overlay_invalid" | "graph_invalid" | "size_cap" | "channel_reserved" | "channel_authority" | "acl_missing" | "channel_undeclared" | "local_channel_invalid" | "local_channel_missing" | "local_agent_invalid" | "local_agent_authority" | "local_agent_collision" | "local_agent_missing" | "local_agent_unreferenced" | "local_skill_invalid" | "local_webhook_authority" | "local_webhook_invalid" | "agent_missing" | "decision_authority" | "decision_unconfigured" | "decision_model_unknown" | "decision_limits" | "uncheckable" | (string & {});
|
|
2377
2377
|
/** One problem with a team definition, from {@link LoomcycleClient.verifyTeam}.
|
|
2378
2378
|
*
|
|
2379
2379
|
* `severity`: `refused` — a create or fork would be refused (its `detail` is
|
|
@@ -2430,6 +2430,79 @@ export interface TeamDraftVerification extends TeamVerification {
|
|
|
2430
2430
|
* empty when there are none. */
|
|
2431
2431
|
issues: TeamIssue[];
|
|
2432
2432
|
}
|
|
2433
|
+
/** One question of a `decision` state: the shape {@link DecisionQuestion}
|
|
2434
|
+
* has on a decision call. */
|
|
2435
|
+
export interface TeamDecisionQuestion {
|
|
2436
|
+
type: "choice" | "noul" | "score";
|
|
2437
|
+
/** The question itself, in plain words. */
|
|
2438
|
+
instructions: string;
|
|
2439
|
+
/** `choice` (required): each option mapped to a description, or to `null`
|
|
2440
|
+
* when the option explains itself; the option names are the answers a state
|
|
2441
|
+
* routes on. `noul` (optional): descriptions of `"true"` and/or `"false"`.
|
|
2442
|
+
* `score` (required): level descriptions, lowest first. */
|
|
2443
|
+
criteria?: Record<string, string | null> | string[];
|
|
2444
|
+
}
|
|
2445
|
+
/** The handler of a team state of kind `decision`: one call to a decision
|
|
2446
|
+
* model, with no agent run. It binds what was answered through `capture`
|
|
2447
|
+
* and, when it names a `route`, takes the transition that answer selects.
|
|
2448
|
+
*
|
|
2449
|
+
* A save refuses a routed answer with nowhere to go: every option of a routed
|
|
2450
|
+
* `choice` needs a `conditional:<option>` transition, and a routed `noul`
|
|
2451
|
+
* both `conditional:true` and `conditional:false`, unless the state has a
|
|
2452
|
+
* `success` transition, which takes any answer without its own. */
|
|
2453
|
+
export interface TeamDecisionHandler {
|
|
2454
|
+
kind: "decision";
|
|
2455
|
+
/** One of the operator's decision models; omitted means the default. A
|
|
2456
|
+
* model this deployment does not offer is stored and reported by
|
|
2457
|
+
* `verifyTeam` as `decision_model_unknown`. */
|
|
2458
|
+
model?: string;
|
|
2459
|
+
/** The JSON object the questions are about. Its string values, at any
|
|
2460
|
+
* depth, are expanded when the state runs: `${var.<name>}`, `${now.*}`,
|
|
2461
|
+
* `${team.*}`, and `{{thread.output}}` for what the previous state handed
|
|
2462
|
+
* over. No other `{{…}}` placeholder is allowed. */
|
|
2463
|
+
about: Record<string, unknown>;
|
|
2464
|
+
questions: Record<string, TeamDecisionQuestion>;
|
|
2465
|
+
/** The question whose answer picks the transition: a `choice` or a `noul`.
|
|
2466
|
+
* Omitted: the state advances on `success`. */
|
|
2467
|
+
route?: string;
|
|
2468
|
+
/** For a routed `noul`: the probability of yes at or above which the answer
|
|
2469
|
+
* is `true`. Default 0.5; above 0 and below 1. */
|
|
2470
|
+
threshold?: number;
|
|
2471
|
+
/** Variable name → JSONPath into the answer, e.g. `$.answers.route.choice`,
|
|
2472
|
+
* `$.answers.urgent.noul`, `$.answers.route.probabilities.billing`. */
|
|
2473
|
+
capture?: Record<string, string>;
|
|
2474
|
+
/** Bounds the call. 0 or omitted: the model's own timeout. */
|
|
2475
|
+
timeout_ms?: number;
|
|
2476
|
+
}
|
|
2477
|
+
/** What a `decision` state's model answered: the object a decision call
|
|
2478
|
+
* returns. On a walk's step as `answer`. */
|
|
2479
|
+
export interface TeamDecisionAnswer {
|
|
2480
|
+
/** The model asked, by the operator's name for it. */
|
|
2481
|
+
model: string;
|
|
2482
|
+
provider: string;
|
|
2483
|
+
served_model: string;
|
|
2484
|
+
/** One entry per question, under the question's name. */
|
|
2485
|
+
answers: Record<string, Record<string, unknown>>;
|
|
2486
|
+
usage: {
|
|
2487
|
+
input_tokens: number;
|
|
2488
|
+
output_tokens: number;
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
/** One executed state of a team walk, in {@link TeamRunResult.steps}. */
|
|
2492
|
+
export interface TeamRunStep {
|
|
2493
|
+
state: string;
|
|
2494
|
+
/** The state's agent, for an `agent` or `consolidator` state; else "". */
|
|
2495
|
+
agent: string;
|
|
2496
|
+
/** The transition label taken, and the state it led to. */
|
|
2497
|
+
edge: string;
|
|
2498
|
+
next: string;
|
|
2499
|
+
/** What the state handed to the next one. A `decision`, `vars` or `channel`
|
|
2500
|
+
* state hands on what it was handed. */
|
|
2501
|
+
output: string;
|
|
2502
|
+
/** A `decision` state's answer. Absent on every other kind. */
|
|
2503
|
+
answer?: TeamDecisionAnswer;
|
|
2504
|
+
[extra: string]: unknown;
|
|
2505
|
+
}
|
|
2433
2506
|
/** Result of {@link LoomcycleClient.runTeam} (op=run) — the walk trace. `status`
|
|
2434
2507
|
* is `"completed"` (a terminal state was reached) or `"iteration_cap"` (a
|
|
2435
2508
|
* state's cycle cap tripped; `capped_state` + `iteration_count` describe it).
|
|
@@ -2451,7 +2524,12 @@ export interface TeamRunResult {
|
|
|
2451
2524
|
capped_state?: string;
|
|
2452
2525
|
max_iterations?: number;
|
|
2453
2526
|
iteration_count?: number;
|
|
2454
|
-
|
|
2527
|
+
/** The per-state trace. Absent when `deduplicated` is set. */
|
|
2528
|
+
steps: TeamRunStep[];
|
|
2529
|
+
/** Set (true) when the request's `idempotencyKey` was already held: nothing
|
|
2530
|
+
* was started, and this is the walk that holds it, as it is now — `status`
|
|
2531
|
+
* may be "running", and there are no `steps`. */
|
|
2532
|
+
deduplicated?: boolean;
|
|
2455
2533
|
[extra: string]: unknown;
|
|
2456
2534
|
}
|
|
2457
2535
|
/** What team {@link LoomcycleClient.runTeam} walks, and how. */
|
|
@@ -2503,6 +2581,21 @@ export interface TeamRunTarget {
|
|
|
2503
2581
|
* seconds as rejected. Omit for no deadline. Changeable while the walk
|
|
2504
2582
|
* runs — see {@link LoomcycleClient.setRunBreakpoints}. */
|
|
2505
2583
|
reviewTtlSeconds?: number;
|
|
2584
|
+
/** Makes starting this walk safe to retry: 1 to 200 characters of
|
|
2585
|
+
* `[A-Za-z0-9:._-]`. A second `runTeam` with the same key, from the same
|
|
2586
|
+
* tenant and user, starts nothing and is answered with the walk the key
|
|
2587
|
+
* already holds, marked `deduplicated: true`.
|
|
2588
|
+
*
|
|
2589
|
+
* Use one key per press of Start and send it again on a retry of that
|
|
2590
|
+
* press: a start whose answer was lost then returns the walk it started,
|
|
2591
|
+
* not a second one. The rest of the request is not compared.
|
|
2592
|
+
*
|
|
2593
|
+
* The answer to a retry is the walk's `run_id` and `status`, plus
|
|
2594
|
+
* `final_state` and `final_output` once it has ended. It is returned at
|
|
2595
|
+
* once in every mode (a retry does not wait for a walk still running), and
|
|
2596
|
+
* it has no `steps`: read the walk's member runs for those. Refused with
|
|
2597
|
+
* `boardChunkId`, which already resumes a stored position. */
|
|
2598
|
+
idempotencyKey?: string;
|
|
2506
2599
|
}
|
|
2507
2600
|
/** What {@link LoomcycleClient.runTeam} returns for `mode: "detach"` — the
|
|
2508
2601
|
* handle, immediately, with the walk still running behind it.
|
|
@@ -2516,8 +2609,12 @@ export interface TeamRunDetached {
|
|
|
2516
2609
|
def_id: string;
|
|
2517
2610
|
/** Address every other run surface with this. */
|
|
2518
2611
|
run_id: string;
|
|
2519
|
-
/**
|
|
2612
|
+
/** "running" for a walk this call started. For a retry answered from an
|
|
2613
|
+
* `idempotencyKey`, the walk's status now, which may be an ended one. */
|
|
2520
2614
|
status: string;
|
|
2615
|
+
/** Set (true) when the request's `idempotencyKey` was already held: nothing
|
|
2616
|
+
* was started, and this is the walk that holds it. */
|
|
2617
|
+
deduplicated?: boolean;
|
|
2521
2618
|
[extra: string]: unknown;
|
|
2522
2619
|
}
|
|
2523
2620
|
/** The armed debug breakpoints of a live team walk, as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcycle/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.109.0",
|
|
4
4
|
"description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 71 methods covering run streaming, agent metadata, pause/resume/state, resolver re-probe (resolveProbe — issue #88 operator escape hatch), operator-token admin (operatorTokenDef — RFC L OSS multi-tenant auth) + whoami (RFC L authoritative principal, v0.17.0) + tenant-scoped listUsers / listUserAgents, dynamic MCP registration (mcpServerDef + v0.18.0 typed mcpServerDefVerify + ensureMcpServer idempotent register-if-changed), snapshot lifecycle, memory admin (incl. v0.9.0 Vector Memory embed_stats + reembed AND v0.11.5 setMemoryEntry + deleteMemoryEntry), interruption resolve, hook management, v0.8.22 substrate admin (agentDef + skillDef), v0.9.x n8n Phase 0 (listChannels + streamUserRunStates), v0.9.x Channel CRUD (publishChannel + subscribeChannel + peekChannel + ackChannel), v0.11.5 Channel admin CRUD (createChannel + updateChannel + deleteChannel — runtime substrate; yaml channels refuse mutation with HTTP 409), v0.9.x content_sha256 verify, v0.9.1 transcript first-cycle, v0.9.x dynamic MCP server registration (mcpServerDef + MCPServerDefVerifyResult), v0.10.3 Library v2 enumeration (listLibraryAgents + listLibrarySkills + listLibraryMcpServers), and v0.11.0 LLM Gateway (llmChat + llmStream — direct provider routing without agent overhead; primary target is n8n's LoomCycleChatModel AI Agent sub-node and any LangChain-compatible consumer). v0.10.1 — dual ESM + CommonJS distribution (additive — ESM consumers unchanged; CJS consumers like n8n's community-node loader now work). v0.19.0 — typed inline code-js agent ingestion (AgentDefOverlay.code_body + ensureCodeAgent — register a deterministic code agent through the substrate with no host filesystem bind; RFC J). v0.20.0 — ensureMcpServer surfaces discoveredToolCount straight from create (loomcycle now auto-discovers MCP tools at ingestion); rediscover is now an explicit force-refresh. v0.21.0 — run/continue accept optional non-secret `metadata` (repo name, review policy, …) passed to the agent, symmetric with the WebHook/Schedule trigger paths. v0.22.0 — version-aligned lockstep release; no client-surface change (RFC N tenant isolation of the agent/skill/MCP/Schedule/Webhook definition plane + real op-schemas on the builtin MCP meta-tools are both server-side). v0.23.0 — version-aligned lockstep release; no client-surface change (RFCs O/P/R MCP-server hardening + thin client and the RFC Q DeepSeek tool-content fix are all server-side / MCP-transport-side). v0.24.0 — purgeChannel clears a channel's buffered messages without deleting its definition (allowed on yaml-declared channels too, unlike deleteChannel — F20); AgentDefOverlay gains channels / evaluation_scopes / interruption so a COMPLETE interactive/multi-agent agent round-trips over the substrate (F14). (Consolidates the interim 0.24/0.25 package bumps, which were never tag-published, back into lockstep with the loomcycle v0.24.0 tag.) v0.25.0 — adds the RFC S channel fan-in/fan-out client twins: awaitChannels() (wait for any/all/at_least N messages across channels, or a timeout — non-committing) + broadcastChannels() (publish one payload to N channels in one atomic-pre-flight call), the client-facing counterparts of the in-band Channel.await / Channel.broadcast tool ops (the rest of v0.25.0 — the manual-management Web UI console + Context op=time + max_fires self-retiring schedules — is server-side / in-band, no client-surface change). v0.29.1 — Usage gains optional `max_context_tokens` (the serving model's context-window ceiling, stamped by the loop from Provider.Capabilities() on each usage event) so a consumer can render a 'context used / max' gauge without a hard-coded per-model table; additive + optional, no behavior change. (Lockstep catch-up: the field landed in loomcycle v0.29.0 but the adapter publish skipped on a version mismatch; v0.29.1 realigns the package version with the release tag so it publishes.) v0.33.0 — gRPC + TS client parity for the RFC Y external fan-out and the compaction surface: spawnRunBatch() (POST /v1/runs:batch — spawn up to 32 fresh runs concurrently in one call, combined index-aligned envelope, per-child failures in-envelope) + compactRun(runId) (POST /v1/runs/{run_id}/compact — summarize a parked run's context); plus per-run sampling + compaction overrides now accepted on runStreaming / continueSession (an explicit temperature 0 is preserved as deterministic, not dropped as falsy). (The gRPC half adds the matching SpawnRunBatch / CompactRun RPCs + the sampling/compaction fields on RunRequest/ContinueRequest — server-side.) v0.34.0 — version-aligned lockstep release; no client-surface change (context-transform plugins / RFC Z Phase 1a are server-side config; the exp7 hardening pass is server-side; the R2 cross-provider thinking-model downgrade surfaces a new `model_downgraded` SSE event the generic stream passes through unchanged). v0.35.0 — RFC AH dynamic filesystem volumes: volumeDef() (POST /v1/_volumedef — op-discriminated create/get/list/delete/purge; a Volume is flat, so delete unmaps + purge RemoveAll's, no retire/promote/fork) + listVolumes() / listEphemeralVolumes() (GET /v1/_volumes[/ephemeral] — tenant-scoped; host paths redacted for non-operator callers). Tenant-confined; the runtime derives the path inside an operator-blessed dynamic_root, so callers pass name + mode, never a host path. v1.1.1 — RFC AI interactive agentic sessions: an `interactive: true` flag on runStreaming/continueSession (a run that parks at end_turn for steering) + sendRunInput(runId, text) (POST /v1/runs/{id}/input — steer a live run) + streamRunByID(runId, {fromSeq}) (GET /v1/runs/{id}/stream — re-attach by run_id; the operator's prior turns replay as `steer` events so a cold client reconstructs the whole conversation) + a high-level InteractiveSession driver (client.interactiveSession / attachInteractiveSession — events()/send()/cancel(), the adapter port of the Web UI run terminal). The AgentEvent union gains awaiting_input/steer/context_compaction frames. Version-aligned with the loomcycle v1.1.x line so the v1.1.1 tag publishes it (also carrying the previously-unpublished v0.35.0 volume surface). v1.4.0 — RFC AL Path VFS + RFC AK Document on the wire: path(input) (POST /v1/_path — a Unix-like filesystem over Memory/Volumes/Documents; resolve/ls/stat/mkdir/mv/rm) + document(input) (POST /v1/_document — chunked-graph documents; 13 ops, needs SQL Memory on the sidecar). Scope (agent/user/tenant) + tenant are resolved server-side from the authenticated principal, never the wire; an off-run scope:'user' op keys on the principal subject so it interoperates with that user's agent runs. New PathToolInput / DocumentToolInput types; responses are op-varying (unknown — narrow as needed). v1.7.0 — RFC AT image/vision input: the PromptContent union gains an `image` variant ({ type:'image'; media_type: ImageMediaType; data: base64-no-prefix }) accepted in a user segment by runStreaming / continueSession (segments pass through unchanged — no method change). The model must be vision-capable or the run errors before the call. New ImageMediaType type (image/png|jpeg|gif|webp). v1.12.1 — Path/Document browse-by-subject + the full Document op set (RFC AS/AK): path(input, opts) / document(input, opts) accept optional scopeId / tenant browse overrides sent as ?scope_id= / ?tenant= query params (server reads them from the URL, re-checks authorization; omit both to browse your own subject — byte-identical to the pre-RFC-AS request), and DocumentToolInput.op now covers all 16 backend ops (adds set_path, export_md, import_md) with the matching include_metadata / markdown fields. Additive — existing path() / document() callers are unchanged. v1.16.0 — RFC BC client-executed tools (local tool host): connectClientTools({tools,onInvoke}) opens a persistent WebSocket to /v1/client-tools, registers tools this client runs on the user's machine (browser DOM / files / shell), and answers the invoke frames loomcycle routes when an agent of your principal calls a client:<tool> — returning your reply as an ordinary tool result. Returns a ClientToolHost driver (.close() to stop; auto-reconnect); dependency-free (global WebSocket in browsers / Node 22+, or an injected WebSocketImpl like the ws package on older Node); the bearer rides the Sec-WebSocket-Protocol subprotocol (browsers can't set an Authorization header on a WebSocket). The runtime's first WebSocket surface. v1.45.0 — RFC BL P5 subject erasure: erasureReport(subject, {tenant}) (GET /v1/_erasure — what this deployment holds about one subject, in three tiers: deletable with existing primitives, subject-keyed but not deletable, and facts ABOUT the subject in scopes they do not own) + erasureExecute(subject, {dryRun, confirm, tenant}) (POST /v1/_erasure — removes tiers 1 and 2). DEFAULTS TO A DRY RUN: dryRun defaults true and a live run also requires confirm === subject. The tier-3 residue is traceable only through the subject's chats, which a live run deletes, so a report afterwards shows rows: 0 while those facts remain — the returned object is the only durable record of what was not reached; persist it. New ErasureReport / ErasureResult / ErasureTier / ErasureResidue types. v1.47.0 — RFC BV memory-view SDK: memorySearch() (POST /v1/_memory/search — off-run unified semantic search spanning k/v entries AND document-chunk bodies in one ranked list, each hit tagged kind memory|document with chunk_id on document hits) + memoryEmbedStats(scope) + reembedMemory(scope, scopeId, {dryRun,limit}) (the Vector Memory embed-admin reads the memory-view console needs; dry_run defaults true). Fact reads (list_facts + get_chunk's entity block) ride the existing document() passthrough. Additive — existing callers unchanged. v1.61.0 — RFC CJ per-run context-window override: runStreaming / continueSession accept an optional maxContextTokens (integer tokens) that wins over the agent's own max_context_tokens; omitted inherits it (which defers to the provider/driver default). Distinct from a model's output cap; primarily for local inference (Ollama num_ctx). Serialized as the snake_case max_context_tokens field on POST /v1/runs + the continuation body; additive, existing callers unchanged. v1.72.1 — the TeamDef version lifecycle: listTeamVersions(name) (op=list — every version of one team, newest first), promoteTeam(defId) (op=promote — point the active pointer, which is what a run BY NAME executes; forkTeam defaults to promote:false, so authoring and putting in force stay two steps), retireTeam(defId, retired) (op=retire — reversible and version-scoped, unlike deleteTeam) and verifyTeam(name, contentSha256) (op=verify — the drift check for a workflow kept in source control and pushed to several deployments; an absent team answers deployed:false rather than raising). The ops existed on the substrate and over HTTP; a client that could author a team could not put one in force.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|