@loomcycle/client 0.11.2 → 0.11.4

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/README.md CHANGED
@@ -6,7 +6,7 @@ TypeScript client for the [loomcycle](https://github.com/denn-gubsky/loomcycle)
6
6
 
7
7
  ## Status
8
8
 
9
- **v0.11.2** — 41 methods covering run streaming, agent metadata, transcript, pause/resume/state, snapshot lifecycle, memory admin, interruption resolve, hook registration, **v0.8.22 substrate admin (agentDef + skillDef)**, **v0.9.x n8n Phase 0 (listChannels + streamUserRunStates)**, **v0.9.x content_sha256**, **v0.9.x dynamic MCP server registration (mcpServerDef)**, **v0.10.3 Library v2 enumeration (listLibraryAgents/Skills/McpServers)**, **v0.11.0 LLM Gateway (llmChat + llmStream)**, and health.
9
+ **v0.11.4** — 42 methods covering run streaming, agent metadata, transcript, pause/resume/state, snapshot lifecycle, memory admin, interruption resolve, hook registration, **v0.8.22 substrate admin (agentDef + skillDef)**, **v0.9.x n8n Phase 0 (listChannels + streamUserRunStates)**, **v0.9.x content_sha256**, **v0.9.x dynamic MCP server registration (mcpServerDef)**, **v0.10.3 Library v2 enumeration (listLibraryAgents/Skills/McpServers)**, **v0.11.0 LLM Gateway (llmChat + llmStream)**, **v0.11.4 OpenAI Embeddings (embeddings)**, and health.
10
10
 
11
11
  > Migrating from raw `fetch` against `/v1/*`? See **[docs/MIGRATING-FROM-HTTP.md](./docs/MIGRATING-FROM-HTTP.md)** for a side-by-side walkthrough.
12
12
 
@@ -24,6 +24,8 @@ TypeScript client for the [loomcycle](https://github.com/denn-gubsky/loomcycle)
24
24
  - **Dual ESM + CJS distribution** (v0.10.1) — n8n's community-node loader (CommonJS) now works alongside ESM consumers.
25
25
  - **First-run UX on the binary** (v0.11.1) — paired CLI commands `loomcycle init` (bootstrap config) + `loomcycle doctor` (health check) + auto-discovery of `~/.config/loomcycle/loomcycle.yaml`. No adapter changes; lockstep version bump only.
26
26
  - **Docker image + brew formula polish** (v0.11.2) — multi-arch image at `docker.io/denngubsky/loomcycle`; brew formula caveats refreshed to reference `loomcycle init` / `loomcycle doctor`; new `installation` Context.help topic. No adapter changes; lockstep version bump only.
27
+ - **OpenAI Chat Completions compatibility shim** (v0.11.3) — new `POST /v1/chat/completions` endpoint serves OpenAI's exact wire shape; consumers using the OpenAI SDK can point at loomcycle by changing only base URL + auth token. `@loomcycle/client` consumers should still prefer `llmChat()` / `llmStream()` over the shim for richer typing (per-frame discriminated unions vs OpenAI's flat chunks). No adapter changes; lockstep version bump only.
28
+ - **OpenAI Embeddings compatibility shim** (v0.11.4) — new `POST /v1/embeddings` endpoint serves OpenAI's Embeddings API shape. New `embeddings()` adapter method + four typed exports (`LLMEmbeddingsOptions`, `LLMEmbeddingsResponse`, `LLMEmbeddingItem`, `LLMEmbeddingsUsage`). Dispatches to the single configured `providers.Embedder` (the same instance Memory tool uses); RAG tools / vector DBs / LangChain `OpenAIEmbeddings` consumers point at loomcycle by changing only the base URL.
27
29
 
28
30
  ## Install
29
31
 
@@ -521,6 +521,29 @@ class LoomcycleClient {
521
521
  const reader = resp.body.getReader();
522
522
  yield* parseLLMStreamFrames(reader);
523
523
  }
524
+ // ---- v0.11.4 OpenAI Embeddings compatibility shim ----
525
+ /** Compute embedding vectors via the OpenAI-compatible
526
+ * `/v1/embeddings` endpoint. Dispatches to the single configured
527
+ * `providers.Embedder` (the same instance Memory tool uses for
528
+ * `embed:true` internally). No resolver path, no tier overlay,
529
+ * no streaming — embeddings are synchronous.
530
+ *
531
+ * Accepts `input` as a string OR string array. Tokenized inputs
532
+ * (number arrays) are refused at the server boundary — send text.
533
+ * `encoding_format: "base64"` packs each float32 little-endian
534
+ * then base64-encodes (saves ~25% wire bytes on 1536-dim
535
+ * vectors); "float" (default) emits each vector as a JSON array.
536
+ *
537
+ * Raises {@link AuthError} on 401; {@link UnavailableError} on
538
+ * 503 (no embedder configured — set memory.embedder.* in
539
+ * loomcycle.yaml); {@link InvalidArgumentError} on 400 (bad
540
+ * request shape). */
541
+ async embeddings(opts) {
542
+ const { signal: _signal, ...body } = opts;
543
+ return (0, fetch_helpers_js_1.postJSON)(this.ctx, "/v1/embeddings", body, {
544
+ signal: opts.signal,
545
+ });
546
+ }
524
547
  // ---- Internal helpers ----
525
548
  /** Shared SSE POST → stream-of-AgentEvent path. Used by
526
549
  * runStreaming + continueSession.
package/dist/cjs/index.js CHANGED
@@ -56,6 +56,9 @@
56
56
  * llmChat(opts: LLMChatOptions): Promise<LLMChatResponse>
57
57
  * llmStream(opts: LLMChatOptions): AsyncIterable<LLMChatStreamItem>
58
58
  *
59
+ * // OpenAI Embeddings compatibility shim (v0.11.4)
60
+ * embeddings(opts: LLMEmbeddingsOptions): Promise<LLMEmbeddingsResponse>
61
+ *
59
62
  * Errors (typed subclasses of LoomcycleError; see README for the
60
63
  * full HTTP-status → typed-error mapping table):
61
64
  * LoomcycleError, AgentNotFoundError, SessionNotFoundError,
package/dist/client.d.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  * via fetch-helpers.ts:raiseFromResponse — see README.md for the
24
24
  * full mapping table.
25
25
  */
26
- import type { Agent, AgentEvent, AgentStatus, CancelAgentResult, ClientOptions, ContinueOptions, CreateSnapshotOptions, HealthResponse, Hook, InterruptListResponse, InterruptStatus, AckChannelOptions, ChannelAckResult, ChannelPeekResult, ChannelPublishResult, ChannelSubscribeResult, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, MemoryEntriesResponse, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopesResponse, PauseResult, RegisterHookOptions, RegisterHookResponse, ResolveInterruptOptions, ResumeResult, RunOptions, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, TranscriptResponse } from "./types.js";
26
+ import type { Agent, AgentEvent, AgentStatus, CancelAgentResult, ClientOptions, ContinueOptions, CreateSnapshotOptions, HealthResponse, Hook, InterruptListResponse, InterruptStatus, AckChannelOptions, ChannelAckResult, ChannelPeekResult, ChannelPublishResult, ChannelSubscribeResult, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MemoryEntriesResponse, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopesResponse, PauseResult, RegisterHookOptions, RegisterHookResponse, ResolveInterruptOptions, ResumeResult, RunOptions, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, TranscriptResponse } from "./types.js";
27
27
  export declare class LoomcycleClient {
28
28
  private ctx;
29
29
  constructor(opts?: ClientOptions);
@@ -361,6 +361,23 @@ export declare class LoomcycleClient {
361
361
  * Use this for live token streaming into LangChain BaseChatModel
362
362
  * `_stream` callbacks. */
363
363
  llmStream(opts: LLMChatOptions): AsyncIterable<LLMChatStreamItem>;
364
+ /** Compute embedding vectors via the OpenAI-compatible
365
+ * `/v1/embeddings` endpoint. Dispatches to the single configured
366
+ * `providers.Embedder` (the same instance Memory tool uses for
367
+ * `embed:true` internally). No resolver path, no tier overlay,
368
+ * no streaming — embeddings are synchronous.
369
+ *
370
+ * Accepts `input` as a string OR string array. Tokenized inputs
371
+ * (number arrays) are refused at the server boundary — send text.
372
+ * `encoding_format: "base64"` packs each float32 little-endian
373
+ * then base64-encodes (saves ~25% wire bytes on 1536-dim
374
+ * vectors); "float" (default) emits each vector as a JSON array.
375
+ *
376
+ * Raises {@link AuthError} on 401; {@link UnavailableError} on
377
+ * 503 (no embedder configured — set memory.embedder.* in
378
+ * loomcycle.yaml); {@link InvalidArgumentError} on 400 (bad
379
+ * request shape). */
380
+ embeddings(opts: LLMEmbeddingsOptions): Promise<LLMEmbeddingsResponse>;
364
381
  /** Shared SSE POST → stream-of-AgentEvent path. Used by
365
382
  * runStreaming + continueSession.
366
383
  *
package/dist/client.js CHANGED
@@ -518,6 +518,29 @@ export class LoomcycleClient {
518
518
  const reader = resp.body.getReader();
519
519
  yield* parseLLMStreamFrames(reader);
520
520
  }
521
+ // ---- v0.11.4 OpenAI Embeddings compatibility shim ----
522
+ /** Compute embedding vectors via the OpenAI-compatible
523
+ * `/v1/embeddings` endpoint. Dispatches to the single configured
524
+ * `providers.Embedder` (the same instance Memory tool uses for
525
+ * `embed:true` internally). No resolver path, no tier overlay,
526
+ * no streaming — embeddings are synchronous.
527
+ *
528
+ * Accepts `input` as a string OR string array. Tokenized inputs
529
+ * (number arrays) are refused at the server boundary — send text.
530
+ * `encoding_format: "base64"` packs each float32 little-endian
531
+ * then base64-encodes (saves ~25% wire bytes on 1536-dim
532
+ * vectors); "float" (default) emits each vector as a JSON array.
533
+ *
534
+ * Raises {@link AuthError} on 401; {@link UnavailableError} on
535
+ * 503 (no embedder configured — set memory.embedder.* in
536
+ * loomcycle.yaml); {@link InvalidArgumentError} on 400 (bad
537
+ * request shape). */
538
+ async embeddings(opts) {
539
+ const { signal: _signal, ...body } = opts;
540
+ return postJSON(this.ctx, "/v1/embeddings", body, {
541
+ signal: opts.signal,
542
+ });
543
+ }
521
544
  // ---- Internal helpers ----
522
545
  /** Shared SSE POST → stream-of-AgentEvent path. Used by
523
546
  * runStreaming + continueSession.
package/dist/index.d.ts CHANGED
@@ -55,6 +55,9 @@
55
55
  * llmChat(opts: LLMChatOptions): Promise<LLMChatResponse>
56
56
  * llmStream(opts: LLMChatOptions): AsyncIterable<LLMChatStreamItem>
57
57
  *
58
+ * // OpenAI Embeddings compatibility shim (v0.11.4)
59
+ * embeddings(opts: LLMEmbeddingsOptions): Promise<LLMEmbeddingsResponse>
60
+ *
58
61
  * Errors (typed subclasses of LoomcycleError; see README for the
59
62
  * full HTTP-status → typed-error mapping table):
60
63
  * LoomcycleError, AgentNotFoundError, SessionNotFoundError,
@@ -73,5 +76,5 @@
73
76
  * See `adapters/ts/README.md` for usage examples.
74
77
  */
75
78
  export { LoomcycleClient } from "./client.js";
76
- 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, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, } from "./types.js";
79
+ 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, 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";
77
80
  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
@@ -55,6 +55,9 @@
55
55
  * llmChat(opts: LLMChatOptions): Promise<LLMChatResponse>
56
56
  * llmStream(opts: LLMChatOptions): AsyncIterable<LLMChatStreamItem>
57
57
  *
58
+ * // OpenAI Embeddings compatibility shim (v0.11.4)
59
+ * embeddings(opts: LLMEmbeddingsOptions): Promise<LLMEmbeddingsResponse>
60
+ *
58
61
  * Errors (typed subclasses of LoomcycleError; see README for the
59
62
  * full HTTP-status → typed-error mapping table):
60
63
  * LoomcycleError, AgentNotFoundError, SessionNotFoundError,
package/dist/types.d.ts CHANGED
@@ -1027,3 +1027,49 @@ export interface LLMChatStreamDelta {
1027
1027
  text?: string;
1028
1028
  partial_json?: string;
1029
1029
  }
1030
+ /** Request body for `embeddings()`. */
1031
+ export interface LLMEmbeddingsOptions {
1032
+ /** Consumer's requested model id (echoed in the response).
1033
+ * Loomcycle uses the single configured embedder regardless;
1034
+ * the field is informational for drop-in compatibility. */
1035
+ model: string;
1036
+ /** Text(s) to embed. v1 accepts string or string[]; tokenized
1037
+ * inputs (number arrays) are refused — send text. */
1038
+ input: string | string[];
1039
+ /** "float" (default) emits each vector as a JSON array of
1040
+ * numbers; "base64" packs each float32 little-endian then
1041
+ * base64-encodes (saves ~25% wire bytes on 1536-dim vectors). */
1042
+ encoding_format?: "float" | "base64";
1043
+ /** OpenAI's post-hoc dimension reduction parameter. Accepted-
1044
+ * but-ignored in v0.11.4 (the providers.Embedder interface
1045
+ * doesn't take a dimension parameter today). */
1046
+ dimensions?: number;
1047
+ /** OpenAI-standard opaque end-user identifier. Maps to
1048
+ * loomcycle's per-user quota tracking + audit log. */
1049
+ user?: string;
1050
+ /** Optional AbortSignal for caller-driven cancellation. */
1051
+ signal?: AbortSignal;
1052
+ }
1053
+ /** Per-embedding entry in the response data array. */
1054
+ export interface LLMEmbeddingItem {
1055
+ object: "embedding";
1056
+ /** float[] when the request used encoding_format:"float"
1057
+ * (default); base64 string when encoding_format:"base64". */
1058
+ embedding: number[] | string;
1059
+ index: number;
1060
+ }
1061
+ /** Token-accounting payload. v0.11.4 leaves both fields at 0 — the
1062
+ * substrate's Embedder interface doesn't return per-call token
1063
+ * counts today. When that lands, the shim's translator populates
1064
+ * these automatically. */
1065
+ export interface LLMEmbeddingsUsage {
1066
+ prompt_tokens: number;
1067
+ total_tokens: number;
1068
+ }
1069
+ /** Response shape mirrors OpenAI's /v1/embeddings exactly. */
1070
+ export interface LLMEmbeddingsResponse {
1071
+ object: "list";
1072
+ data: LLMEmbeddingItem[];
1073
+ model: string;
1074
+ usage: LLMEmbeddingsUsage;
1075
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcycle/client",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "TypeScript client for the loomcycle sidecar (HTTP+SSE). 41 methods covering run streaming, agent metadata, pause/resume/state, snapshot lifecycle, memory admin (incl. v0.9.0 Vector Memory embed_stats + reembed), 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.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",