@loomcycle/client 1.133.0 → 1.135.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/README.md +2 -1
- package/dist/cjs/client.js +56 -0
- package/dist/cjs/errors.js +5 -3
- package/dist/cjs/index.js +1 -0
- package/dist/client.d.ts +27 -1
- package/dist/client.js +56 -0
- package/dist/errors.js +5 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/types.d.ts +198 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -221,7 +221,8 @@ Live SSE tails of what changed in the caller's tenant's memory and documents —
|
|
|
221
221
|
| Method | Returns | Notes |
|
|
222
222
|
|---|---|---|
|
|
223
223
|
| `streamMemoryChanges(opts?)` | `AsyncIterable<ChangeFeedFrame>` | `memory.set` / `memory.delete` / `memory.scope_deleted`. Mirrors `GET /v1/_memory/changes`. |
|
|
224
|
-
| `streamDocumentChanges(opts?)` | `AsyncIterable<ChangeFeedFrame>` | `document.chunk.updated` / `document.chunk.deleted`, naming the `chunk_id`. Mirrors `GET /v1/_document/changes`. |
|
|
224
|
+
| `streamDocumentChanges(opts?)` | `AsyncIterable<ChangeFeedFrame>` | `document.chunk.updated` / `document.chunk.deleted` / `document.edges.changed`, naming the `chunk_id` and `document_id`. Mirrors `GET /v1/_document/changes`. |
|
|
225
|
+
| `documentFeed({scope, scopeId?, tenant?, signal?})` | `AsyncIterable<DocumentFeedFrame>` | RFC FV — the reader's feed, open to a tenant member: one scope (`user` / `tenant`), only documents the caller can list, `{type, chunk_id, document_id, at}` with no cursor (a reconnect is a resync). Mirrors `GET /v1/_document/feed`. |
|
|
225
226
|
|
|
226
227
|
Each change is a **value-free coordinate** (`seq`, `type`, `scope`, `scope_id`, `key` or `chunk_id`, `at`): it says *what* changed, and you pull the current value through the data API. The first item is always `{ kind: "feed", payload: { enabled, since, embedder? } }`, then one `{ kind: "change", payload: MemoryChange }` per change, oldest first.
|
|
227
228
|
|
package/dist/cjs/client.js
CHANGED
|
@@ -3538,6 +3538,42 @@ class LoomcycleClient {
|
|
|
3538
3538
|
async *streamDocumentChanges(opts) {
|
|
3539
3539
|
yield* this.streamChangeFeed("/v1/_document/changes", opts);
|
|
3540
3540
|
}
|
|
3541
|
+
/** Watch one scope's DOCUMENTS change, as a reader (RFC FV). Mirrors
|
|
3542
|
+
* `GET /v1/_document/feed?scope=user|tenant[&scope_id=…][&tenant=…]`.
|
|
3543
|
+
*
|
|
3544
|
+
* Unlike {@link LoomcycleClient.streamDocumentChanges} (the operator's
|
|
3545
|
+
* tenant-wide feed) this is open to a tenant MEMBER, gated like
|
|
3546
|
+
* {@link LoomcycleClient.document}: it names only documents the caller can
|
|
3547
|
+
* list, in the one scope it asked for.
|
|
3548
|
+
*
|
|
3549
|
+
* - The first item is `{ kind: "feed" }`; `payload.enabled === false` means
|
|
3550
|
+
* the server captures no changes — reload on a timer instead of waiting.
|
|
3551
|
+
* - Then one `{ kind: "change" }` per change. Changes of one type to one
|
|
3552
|
+
* document inside one server poll arrive as one.
|
|
3553
|
+
* - There is NO cursor and no resume: the stream starts now. After any
|
|
3554
|
+
* disconnect, reload your view and open a new stream.
|
|
3555
|
+
* - A `{ kind: "error" }` with code `store_unavailable` is non-fatal;
|
|
3556
|
+
* `access_unavailable`, `credential_revoked` and `credential_expired`
|
|
3557
|
+
* close the stream — reload and reconnect with a valid credential.
|
|
3558
|
+
* - The server re-authenticates the stream every 30 s: a revoked grant
|
|
3559
|
+
* stops that document's changes, and a revoked token ends the stream,
|
|
3560
|
+
* within that window; a token's expiry ends it on time.
|
|
3561
|
+
* - At most a few streams per principal (`LOOMCYCLE_DOCUMENT_FEED_MAX_STREAMS`,
|
|
3562
|
+
* default 4); one more is refused with a 429 — a `BackpressureError` with
|
|
3563
|
+
* code `too_many_streams`, not retryable until you close a stream.
|
|
3564
|
+
* - Iteration ends when the server closes the stream, or throws an
|
|
3565
|
+
* `AbortError` when `signal` aborts. */
|
|
3566
|
+
async *documentFeed(opts) {
|
|
3567
|
+
if (opts.scope !== "user" && opts.scope !== "tenant") {
|
|
3568
|
+
throw new Error(`loomcycle: documentFeed scope must be "user" or "tenant", got ${String(opts.scope)}`);
|
|
3569
|
+
}
|
|
3570
|
+
const q = new URLSearchParams({ scope: opts.scope, ...browseQuery(opts) });
|
|
3571
|
+
for await (const ev of this.streamSSEGet(`/v1/_document/feed?${q.toString()}`, opts.signal)) {
|
|
3572
|
+
const frame = toDocumentFeedFrame(ev);
|
|
3573
|
+
if (frame)
|
|
3574
|
+
yield frame;
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3541
3577
|
async *streamChangeFeed(path, opts) {
|
|
3542
3578
|
const since = opts?.since;
|
|
3543
3579
|
// The server reads an unparseable or negative `since` as 0 rather than
|
|
@@ -3873,6 +3909,26 @@ function toChangeFeedFrame(raw) {
|
|
|
3873
3909
|
}
|
|
3874
3910
|
return null;
|
|
3875
3911
|
}
|
|
3912
|
+
/** toDocumentFeedFrame types one frame of the reader's document feed, or
|
|
3913
|
+
* returns null for one it does not recognise. `feed` and `error` frames are
|
|
3914
|
+
* read as on the operator feed; a reader `change` carries no `seq`, so it is
|
|
3915
|
+
* recognised by its `document_id`. */
|
|
3916
|
+
function toDocumentFeedFrame(raw) {
|
|
3917
|
+
const shared = toChangeFeedFrame(raw);
|
|
3918
|
+
if (shared?.kind === "feed") {
|
|
3919
|
+
const { since: _since, ...status } = shared.payload;
|
|
3920
|
+
return { kind: "feed", payload: status };
|
|
3921
|
+
}
|
|
3922
|
+
if (shared?.kind === "error")
|
|
3923
|
+
return shared;
|
|
3924
|
+
if (typeof raw.document_id === "string" &&
|
|
3925
|
+
typeof raw.chunk_id === "string" &&
|
|
3926
|
+
typeof raw.type === "string" &&
|
|
3927
|
+
raw.type.startsWith("document.")) {
|
|
3928
|
+
return { kind: "change", payload: raw };
|
|
3929
|
+
}
|
|
3930
|
+
return null;
|
|
3931
|
+
}
|
|
3876
3932
|
// channelOpPath builds the v0.9.x Channel CRUD URL. Two families:
|
|
3877
3933
|
// - scope === "global" → /v1/_channels/{channel}/{op}
|
|
3878
3934
|
// - scope === "user" → /v1/users/{userId}/channels/{channel}/{op}
|
package/dist/cjs/errors.js
CHANGED
|
@@ -70,9 +70,11 @@ const TRANSIENT_CODES = new Set([
|
|
|
70
70
|
/** 429 codes that do NOT clear by waiting: the caller has to act first, so
|
|
71
71
|
* a retry loop on them never ends. `configured_run_cap`: the user already
|
|
72
72
|
* holds as many configured (not yet started) runs as the operator allows,
|
|
73
|
-
* and only starting or discarding one makes room.
|
|
74
|
-
*
|
|
75
|
-
|
|
73
|
+
* and only starting or discarding one makes room. `too_many_streams`: the
|
|
74
|
+
* principal already holds as many document feed streams as allowed, and only
|
|
75
|
+
* closing one makes room. (A hard token budget, `token_limit_exceeded`, has a
|
|
76
|
+
* class of its own outside BackpressureError.) */
|
|
77
|
+
const CALLER_ACTION_429_CODES = new Set(["configured_run_cap", "too_many_streams"]);
|
|
76
78
|
/** Base class for every HTTP 404 the client surfaces. Lets callers
|
|
77
79
|
* catch any not-found case with a single `instanceof NotFoundError`
|
|
78
80
|
* check, regardless of which specific resource was missing
|
package/dist/cjs/index.js
CHANGED
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
* // Memory / document change feeds (RFC CD Part C; SSE; substrate:tenant)
|
|
79
79
|
* streamMemoryChanges(opts?): AsyncIterable<ChangeFeedFrame> // feed | change | error (non-fatal); resume with opts.since = last seq
|
|
80
80
|
* streamDocumentChanges(opts?): AsyncIterable<ChangeFeedFrame>
|
|
81
|
+
* documentFeed(opts): AsyncIterable<DocumentFeedFrame> // RFC FV: member-safe, one scope, no cursor (reconnect = resync)
|
|
81
82
|
*
|
|
82
83
|
* // Interruption (v0.8.16; decline RFC BH)
|
|
83
84
|
* listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
|
package/dist/client.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import { InteractiveSession } from "./interactive.js";
|
|
27
27
|
import { LoomcycleOAuth } from "./oauth.js";
|
|
28
28
|
import { ClientToolHost, type ConnectClientToolsOptions } from "./client-tools.js";
|
|
29
|
-
import type { ChangeFeedFrame, StreamChangesOptions, CredentialListResponse, CredentialMeta, CryptoKeyEncoding, CryptoKeyExport, CryptoKeyExternal, CryptoKeyType, CryptoRequest, CryptoResultByOp, DecideRequest, DecideResponse, DecisionModelsResponse, CredentialScope, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResult, MergeSubjectsResult, ReviewQueueFilter, ReviewQueueResult, RuleStatementsResult, RevertRulingResult, ListRulingsResult, ApplyReviewPolicyResult, BindSubjectPrincipalResult, Agent, AgentEvent, AgentList, CancelAgentResult, ClientOptions, ContinueOptions, RunOverrideOptions, EffectiveConfigResponse, RunFileInput, RunInboxDownload, AgentOverridableResponse, RetuneRunResponse, RunConfigResponse, RunPromptResponse, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureHookDefOptions, EnsureHookDefResult, HookDefInput, HookDefOverlay, HookDefRowResponse, CreateDefOptions, ForkDefOptions, HookDefForkOverlay, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, WebhookDefInput, WebhookDefOverlay, WebhookDefRowResponse, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, InterruptListResponse, InterruptStatus, ListUserAgentsOptions, WalkRunsPage, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelPeekResult, TeamChannelReleaseResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, ReleaseChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, ListUserTokensResponse, UserIdentitiesResponse, AuthGateListResponse, CreateInviteBody, CreatedInvite, AuthInviteListResponse, CreatedPasswordReset, GateIdentitiesResponse, GateTenantStatus, RunnableAgentsResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEmbedStatsResponse, MemoryEntriesResponse, MemoryEntryResponse, MemoryBackfillResponse, MemoryPurgeResponse, MemoryReembedResponse, MemoryScopeIDsResponse, MemoryScopesResponse, MemorySearchInput, MemorySearchResponse, PauseResult, RetentionOverride, PersistentVolumesResponse, EphemeralVolumesResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunTreeDeletion, ReplaySessionResult, CancelTurnResult, ReviewRunResult, RunBatchOptions, RunBatchResult, RunOptions, ConfiguredRun, ConfiguredRunPatch, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, CreatedTeam, CreateTeamOptions, DefNamesResponse, ForkTeamOptions, ModelAliasesResponse, OperatorTokenDefNamesResponse, ProviderModelsResponse, RoutingResponse, ScheduleListResponse, SchedulePauseResult, ScheduleRunNowResult, ScheduleStateView, ListTeamsResponse, PromotedTeam, RetiredTeam, TeamBreakpoints, TeamDefDetail, TeamRunDetached, TeamRunTarget, TeamVerification, TeamDraft, TeamDraftVerification, TeamVersionList, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationAggregate, TranscriptResponse, WhoamiResponse, UsageDimension, UsageBucket, UsageReportResponse, TokenLimit, TokenLimitsResponse, ConfigResponse, SetTokenLimitRequest, AclBinding, AclBindingListResponse, AclCatalog, AclDefInput, AclDefListResponse, AclDefNamesResponse, AclDefRow, AclRule, AclValidateResult, AuthzDecision, AuthzEvaluationRequest, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzExplainResponse, AuthzSimulateRequest, AuthzSimulateResponse, CreateAclBindingBody, CreateGroupBody, GroupDetail, GroupEffective, GroupListResponse, GroupMemberChange, GroupMemberKind, GroupRow, AppClientConfig, AppClientEntry, ClientDefInput, ClientDefListResponse, ClientDefNamesResponse, ClientDefRecord, ClientDefRetireResult, ClientDefVerifyResult, DeviceLoginOptions, DeviceLoginResult } from "./types.js";
|
|
29
|
+
import type { ChangeFeedFrame, StreamChangesOptions, DocumentFeedFrame, DocumentFeedOptions, CredentialListResponse, CredentialMeta, CryptoKeyEncoding, CryptoKeyExport, CryptoKeyExternal, CryptoKeyType, CryptoRequest, CryptoResultByOp, DecideRequest, DecideResponse, DecisionModelsResponse, CredentialScope, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureReport, ErasureResult, MergeSubjectsResult, ReviewQueueFilter, ReviewQueueResult, RuleStatementsResult, RevertRulingResult, ListRulingsResult, ApplyReviewPolicyResult, BindSubjectPrincipalResult, Agent, AgentEvent, AgentList, CancelAgentResult, ClientOptions, ContinueOptions, RunOverrideOptions, EffectiveConfigResponse, RunFileInput, RunInboxDownload, AgentOverridableResponse, RetuneRunResponse, RunConfigResponse, RunPromptResponse, CreateSnapshotOptions, EnsureCodeAgentOptions, EnsureCodeAgentResult, EnsureHookDefOptions, EnsureHookDefResult, HookDefInput, HookDefOverlay, HookDefRowResponse, CreateDefOptions, ForkDefOptions, HookDefForkOverlay, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, WebhookDefInput, WebhookDefOverlay, WebhookDefRowResponse, EnsureMcpServerOptions, EnsureMcpServerResult, HealthResponse, InterruptListResponse, InterruptStatus, ListUserAgentsOptions, WalkRunsPage, AckChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAckResult, ChannelAwaitResult, ChannelBroadcastResult, ChannelDescriptor, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelPeekResult, TeamChannelReleaseResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelSubscribeResult, CreateChannelOptions, ListChannelsResponse, PeekChannelOptions, PublishChannelOptions, ReleaseChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, SubscribeChannelOptions, UpdateChannelOptions, LibraryAgentDefinition, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, ListUsersResponse, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, ListUserTokensResponse, UserIdentitiesResponse, AuthGateListResponse, CreateInviteBody, CreatedInvite, AuthInviteListResponse, CreatedPasswordReset, GateIdentitiesResponse, GateTenantStatus, RunnableAgentsResponse, LLMChatOptions, LLMChatResponse, LLMChatStreamItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, MCPServerDefVerifyResult, MemoryEmbedStatsResponse, MemoryEntriesResponse, MemoryEntryResponse, MemoryBackfillResponse, MemoryPurgeResponse, MemoryReembedResponse, MemoryScopeIDsResponse, MemoryScopesResponse, MemorySearchInput, MemorySearchResponse, PauseResult, RetentionOverride, PersistentVolumesResponse, EphemeralVolumesResponse, ResolveInterruptOptions, ResumeResult, ResolverMatrix, CompactRunResult, RunTreeDeletion, ReplaySessionResult, CancelTurnResult, ReviewRunResult, RunBatchOptions, RunBatchResult, RunOptions, ConfiguredRun, ConfiguredRunPatch, RunStateStreamItem, RuntimeStateResponse, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotRestoreResponse, StreamUserRunStatesOptions, SubstrateToolInput, SubstrateToolResponse, CreatedTeam, CreateTeamOptions, DefNamesResponse, ForkTeamOptions, ModelAliasesResponse, OperatorTokenDefNamesResponse, ProviderModelsResponse, RoutingResponse, ScheduleListResponse, SchedulePauseResult, ScheduleRunNowResult, ScheduleStateView, ListTeamsResponse, PromotedTeam, RetiredTeam, TeamBreakpoints, TeamDefDetail, TeamRunDetached, TeamRunTarget, TeamVerification, TeamDraft, TeamDraftVerification, TeamVersionList, TeamDiagram, TeamRunResult, PathToolInput, PathToolResponse, DocumentToolInput, DocumentToolResponse, HistoryToolInput, HistoryToolResponse, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationAggregate, TranscriptResponse, WhoamiResponse, UsageDimension, UsageBucket, UsageReportResponse, TokenLimit, TokenLimitsResponse, ConfigResponse, SetTokenLimitRequest, AclBinding, AclBindingListResponse, AclCatalog, AclDefInput, AclDefListResponse, AclDefNamesResponse, AclDefRow, AclRule, AclValidateResult, AuthzDecision, AuthzEvaluationRequest, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzExplainResponse, AuthzSimulateRequest, AuthzSimulateResponse, CreateAclBindingBody, CreateGroupBody, GroupDetail, GroupEffective, GroupListResponse, GroupMemberChange, GroupMemberKind, GroupRow, AppClientConfig, AppClientEntry, ClientDefInput, ClientDefListResponse, ClientDefNamesResponse, ClientDefRecord, ClientDefRetireResult, ClientDefVerifyResult, DeviceLoginOptions, DeviceLoginResult } from "./types.js";
|
|
30
30
|
export declare class LoomcycleClient {
|
|
31
31
|
private ctx;
|
|
32
32
|
private readonly tokenProvider?;
|
|
@@ -2494,6 +2494,32 @@ export declare class LoomcycleClient {
|
|
|
2494
2494
|
* {@link LoomcycleClient.streamMemoryChanges}; a reader wanting both
|
|
2495
2495
|
* families opens both. */
|
|
2496
2496
|
streamDocumentChanges(opts?: StreamChangesOptions): AsyncIterable<ChangeFeedFrame>;
|
|
2497
|
+
/** Watch one scope's DOCUMENTS change, as a reader (RFC FV). Mirrors
|
|
2498
|
+
* `GET /v1/_document/feed?scope=user|tenant[&scope_id=…][&tenant=…]`.
|
|
2499
|
+
*
|
|
2500
|
+
* Unlike {@link LoomcycleClient.streamDocumentChanges} (the operator's
|
|
2501
|
+
* tenant-wide feed) this is open to a tenant MEMBER, gated like
|
|
2502
|
+
* {@link LoomcycleClient.document}: it names only documents the caller can
|
|
2503
|
+
* list, in the one scope it asked for.
|
|
2504
|
+
*
|
|
2505
|
+
* - The first item is `{ kind: "feed" }`; `payload.enabled === false` means
|
|
2506
|
+
* the server captures no changes — reload on a timer instead of waiting.
|
|
2507
|
+
* - Then one `{ kind: "change" }` per change. Changes of one type to one
|
|
2508
|
+
* document inside one server poll arrive as one.
|
|
2509
|
+
* - There is NO cursor and no resume: the stream starts now. After any
|
|
2510
|
+
* disconnect, reload your view and open a new stream.
|
|
2511
|
+
* - A `{ kind: "error" }` with code `store_unavailable` is non-fatal;
|
|
2512
|
+
* `access_unavailable`, `credential_revoked` and `credential_expired`
|
|
2513
|
+
* close the stream — reload and reconnect with a valid credential.
|
|
2514
|
+
* - The server re-authenticates the stream every 30 s: a revoked grant
|
|
2515
|
+
* stops that document's changes, and a revoked token ends the stream,
|
|
2516
|
+
* within that window; a token's expiry ends it on time.
|
|
2517
|
+
* - At most a few streams per principal (`LOOMCYCLE_DOCUMENT_FEED_MAX_STREAMS`,
|
|
2518
|
+
* default 4); one more is refused with a 429 — a `BackpressureError` with
|
|
2519
|
+
* code `too_many_streams`, not retryable until you close a stream.
|
|
2520
|
+
* - Iteration ends when the server closes the stream, or throws an
|
|
2521
|
+
* `AbortError` when `signal` aborts. */
|
|
2522
|
+
documentFeed(opts: DocumentFeedOptions): AsyncIterable<DocumentFeedFrame>;
|
|
2497
2523
|
private streamChangeFeed;
|
|
2498
2524
|
/** List credential METADATA for a scope (RFC AR) — never a secret value.
|
|
2499
2525
|
* `user` = your own subject's tokens (per-user, e.g. a personal Telegram bot
|
package/dist/client.js
CHANGED
|
@@ -3535,6 +3535,42 @@ export class LoomcycleClient {
|
|
|
3535
3535
|
async *streamDocumentChanges(opts) {
|
|
3536
3536
|
yield* this.streamChangeFeed("/v1/_document/changes", opts);
|
|
3537
3537
|
}
|
|
3538
|
+
/** Watch one scope's DOCUMENTS change, as a reader (RFC FV). Mirrors
|
|
3539
|
+
* `GET /v1/_document/feed?scope=user|tenant[&scope_id=…][&tenant=…]`.
|
|
3540
|
+
*
|
|
3541
|
+
* Unlike {@link LoomcycleClient.streamDocumentChanges} (the operator's
|
|
3542
|
+
* tenant-wide feed) this is open to a tenant MEMBER, gated like
|
|
3543
|
+
* {@link LoomcycleClient.document}: it names only documents the caller can
|
|
3544
|
+
* list, in the one scope it asked for.
|
|
3545
|
+
*
|
|
3546
|
+
* - The first item is `{ kind: "feed" }`; `payload.enabled === false` means
|
|
3547
|
+
* the server captures no changes — reload on a timer instead of waiting.
|
|
3548
|
+
* - Then one `{ kind: "change" }` per change. Changes of one type to one
|
|
3549
|
+
* document inside one server poll arrive as one.
|
|
3550
|
+
* - There is NO cursor and no resume: the stream starts now. After any
|
|
3551
|
+
* disconnect, reload your view and open a new stream.
|
|
3552
|
+
* - A `{ kind: "error" }` with code `store_unavailable` is non-fatal;
|
|
3553
|
+
* `access_unavailable`, `credential_revoked` and `credential_expired`
|
|
3554
|
+
* close the stream — reload and reconnect with a valid credential.
|
|
3555
|
+
* - The server re-authenticates the stream every 30 s: a revoked grant
|
|
3556
|
+
* stops that document's changes, and a revoked token ends the stream,
|
|
3557
|
+
* within that window; a token's expiry ends it on time.
|
|
3558
|
+
* - At most a few streams per principal (`LOOMCYCLE_DOCUMENT_FEED_MAX_STREAMS`,
|
|
3559
|
+
* default 4); one more is refused with a 429 — a `BackpressureError` with
|
|
3560
|
+
* code `too_many_streams`, not retryable until you close a stream.
|
|
3561
|
+
* - Iteration ends when the server closes the stream, or throws an
|
|
3562
|
+
* `AbortError` when `signal` aborts. */
|
|
3563
|
+
async *documentFeed(opts) {
|
|
3564
|
+
if (opts.scope !== "user" && opts.scope !== "tenant") {
|
|
3565
|
+
throw new Error(`loomcycle: documentFeed scope must be "user" or "tenant", got ${String(opts.scope)}`);
|
|
3566
|
+
}
|
|
3567
|
+
const q = new URLSearchParams({ scope: opts.scope, ...browseQuery(opts) });
|
|
3568
|
+
for await (const ev of this.streamSSEGet(`/v1/_document/feed?${q.toString()}`, opts.signal)) {
|
|
3569
|
+
const frame = toDocumentFeedFrame(ev);
|
|
3570
|
+
if (frame)
|
|
3571
|
+
yield frame;
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3538
3574
|
async *streamChangeFeed(path, opts) {
|
|
3539
3575
|
const since = opts?.since;
|
|
3540
3576
|
// The server reads an unparseable or negative `since` as 0 rather than
|
|
@@ -3869,6 +3905,26 @@ function toChangeFeedFrame(raw) {
|
|
|
3869
3905
|
}
|
|
3870
3906
|
return null;
|
|
3871
3907
|
}
|
|
3908
|
+
/** toDocumentFeedFrame types one frame of the reader's document feed, or
|
|
3909
|
+
* returns null for one it does not recognise. `feed` and `error` frames are
|
|
3910
|
+
* read as on the operator feed; a reader `change` carries no `seq`, so it is
|
|
3911
|
+
* recognised by its `document_id`. */
|
|
3912
|
+
function toDocumentFeedFrame(raw) {
|
|
3913
|
+
const shared = toChangeFeedFrame(raw);
|
|
3914
|
+
if (shared?.kind === "feed") {
|
|
3915
|
+
const { since: _since, ...status } = shared.payload;
|
|
3916
|
+
return { kind: "feed", payload: status };
|
|
3917
|
+
}
|
|
3918
|
+
if (shared?.kind === "error")
|
|
3919
|
+
return shared;
|
|
3920
|
+
if (typeof raw.document_id === "string" &&
|
|
3921
|
+
typeof raw.chunk_id === "string" &&
|
|
3922
|
+
typeof raw.type === "string" &&
|
|
3923
|
+
raw.type.startsWith("document.")) {
|
|
3924
|
+
return { kind: "change", payload: raw };
|
|
3925
|
+
}
|
|
3926
|
+
return null;
|
|
3927
|
+
}
|
|
3872
3928
|
// channelOpPath builds the v0.9.x Channel CRUD URL. Two families:
|
|
3873
3929
|
// - scope === "global" → /v1/_channels/{channel}/{op}
|
|
3874
3930
|
// - scope === "user" → /v1/users/{userId}/channels/{channel}/{op}
|
package/dist/errors.js
CHANGED
|
@@ -66,9 +66,11 @@ const TRANSIENT_CODES = new Set([
|
|
|
66
66
|
/** 429 codes that do NOT clear by waiting: the caller has to act first, so
|
|
67
67
|
* a retry loop on them never ends. `configured_run_cap`: the user already
|
|
68
68
|
* holds as many configured (not yet started) runs as the operator allows,
|
|
69
|
-
* and only starting or discarding one makes room.
|
|
70
|
-
*
|
|
71
|
-
|
|
69
|
+
* and only starting or discarding one makes room. `too_many_streams`: the
|
|
70
|
+
* principal already holds as many document feed streams as allowed, and only
|
|
71
|
+
* closing one makes room. (A hard token budget, `token_limit_exceeded`, has a
|
|
72
|
+
* class of its own outside BackpressureError.) */
|
|
73
|
+
const CALLER_ACTION_429_CODES = new Set(["configured_run_cap", "too_many_streams"]);
|
|
72
74
|
/** Base class for every HTTP 404 the client surfaces. Lets callers
|
|
73
75
|
* catch any not-found case with a single `instanceof NotFoundError`
|
|
74
76
|
* check, regardless of which specific resource was missing
|
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
* // Memory / document change feeds (RFC CD Part C; SSE; substrate:tenant)
|
|
78
78
|
* streamMemoryChanges(opts?): AsyncIterable<ChangeFeedFrame> // feed | change | error (non-fatal); resume with opts.since = last seq
|
|
79
79
|
* streamDocumentChanges(opts?): AsyncIterable<ChangeFeedFrame>
|
|
80
|
+
* documentFeed(opts): AsyncIterable<DocumentFeedFrame> // RFC FV: member-safe, one scope, no cursor (reconnect = resync)
|
|
80
81
|
*
|
|
81
82
|
* // Interruption (v0.8.16; decline RFC BH)
|
|
82
83
|
* listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
|
|
@@ -216,5 +217,5 @@ export { ClientToolHost, clientToolsURL, CLIENT_TOOL_SUBPROTOCOL } from "./clien
|
|
|
216
217
|
export type { ClientToolSchema, ClientToolInvocation, ConnectClientToolsOptions, WebSocketLike, WebSocketCtor, } from "./client-tools.js";
|
|
217
218
|
export { LoomcycleOAuth, OAuthTokenProvider, parseAuthorizeResponse, pkceChallenge } from "./oauth.js";
|
|
218
219
|
export type { LoomcycleOAuthOptions, OAuthTokenProviderOptions } from "./oauth.js";
|
|
219
|
-
export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, RunOverrideOptions, SamplingOptions, CompactionOptions, ContextOptions, ToolUse, Usage, CallTiming, Agent, AgentStatus, AwaitedState, AgentUsage, RunResult, RunSpec, RunSpecTeam, ConfiguredRun, ConfiguredRunPatch, ToolChoiceOptions, OutputFormatOptions, CancelAgentResult, ListAgentsResponse, ListUserAgentsOptions, AgentList, WalkRunsPage, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, RunTreeDeletion, RunTreeNotReached, DirectoryBudget, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureAccess, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, MergeSubjectsResult, SubjectRef, BindSubjectPrincipalResult, ReviewQueueFilter, ReviewQueueGroup, ReviewQueueResult, RuleStatementsResult, RevertRulingResult, RulingBreakdown, RulingItem, RulingSelector, RulingRecord, ListRulingsResult, PolicyRuleCount, ApplyReviewPolicyResult, ErasureBoundSubject, ErasureTokenRef, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserStatus, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, UserIdentity, UserIdentitiesResponse, AuthGateKind, AuthGate, AuthGateKey, AuthGateRemoval, AuthGateProbe, AuthGateListResponse, CreateInviteBody, CreatedInvite, AuthInviteState, AuthInvite, AuthInviteListResponse, CreatedPasswordReset, GateIdentity, GateIdentitiesResponse, GateTenantStatus, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, WhoamiEffective, WhoamiAuth, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchDocumentFilter, MemorySearchInput, MemorySource, MemoryWhen, MemoryTimeFilter, MemorySearchEntry, MemorySearchResponse, MemoryEmbedModelStats, MemoryEmbedStatsResponse, MemoryReembedConfigured, MemoryReembedResponse, MemoryBackfillResponse, MemoryPurgeResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, ChannelHookCall, ChannelHookResult, HookFailMode, HookPhase, HookToolCall, HookToolResult, PostHookCall, PostHookResult, PreHookCall, PreHookResult, SubstrateToolInput, SubstrateToolResponse, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, PromotedTeam, RetiredTeam, TeamDefDetail, TeamVerification, TeamDraft, TeamDraftVerification, TeamIssue, TeamIssueKind, TeamVersion, TeamVersionList, TeamBreakpoints, TeamRunDetached, TeamRunResult, TeamRunTarget, CreateTeamOptions, ForkTeamOptions, DefNameSummary, DefNamesResponse, OperatorTokenDefNameSummary, OperatorTokenDefNamesResponse, ScheduleListEntry, ScheduleListResponse, ScheduleActiveRun, ScheduleStateView, ScheduleRunNowResult, SchedulePauseResult, ModelAlias, ModelAliasesResponse, RoutingResponse, RoutingUserTier, RoutingTier, RoutingCandidate, RoutingThroughput, RoutingProvider, SearchRoutingProvider, RoutingEmbedder, RoutingDecision, RoutingDecisionModel, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentEdgeEvidence, DocumentToolResponse, DocumentSearchFilter, DocumentSearchHit, DocumentSearchResult, DocumentRelatedResult, HistoryToolInput, HistoryToolResponse, EvaluationEmitterRole, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationScoreStats, EvaluationAggregate, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, ChangeFeedError, ChangeFeedFrame, ChangeFeedStatus, EmbedderHealth, MemoryChange, MemoryChangeScope, MemoryChangeType, StreamChangesOptions, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelReleaseResult, TeamChannelDeclaredIn, TeamChannelDescriptor, TeamChannelPeekResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, ReleaseChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, AgentRouting, AgentChannelACL, AgentInterruptionACL, AgentDecision, MemoryRerank, AgentSampling, AgentCompaction, AgentTranscription, AgentSpeech, AgentContext, TierCandidate, CoreBlock, HookEvent, InlineWebhook, HookEntry, EventHooks, ToolEntry, ToolHooksByTool, EnsureCodeAgentOptions, EnsureCodeAgentResult, CreateDefOptions, ForkDefOptions, EnsureHookDefOptions, EnsureHookDefResult, HookDefBody, HookDefForkOverlay, HookDefInput, HookDefMatch, HookDefOverlay, HookDefRowResponse, HookDefVerifyResult, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, ScheduledRunHook, ScheduledRunPromptContent, ScheduledRunPromptSegment, WebhookDefAuth, WebhookDefFilter, WebhookDefInput, WebhookDefOverlay, WebhookDefRateLimit, WebhookDefRowResponse, WebhookDefDeliveries, WebhookDefSyncResponse, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, UsageDimension, UsageBucket, UsageAggregate, UsageReportResponse, CapabilityInertInfo, LimitInfo, FileCapturedInfo, TranscriptionInfo, AdmissionInfo, ErrorInfo, CallFormat, CallRef, HookDecisionInfo, TeamDecisionInfo, OverrideInfo, FallbackInfo, InterruptionEventInfo, SpawnChildInfo, TurnCancelledInfo, ChannelEventInfo, ContextCompactionInfo, ContextRecapInfo, ContextStateInfo, ContextExhaustedInfo, ContextTierVerdict, ContextDistillDeclinedInfo, EffectiveConfigResponse, RunFileInput, RunFileImportSource, RunFileImportHeading, RunInboxDownload, EffectiveConfigSource, EffectiveValue, InertContextSetting, AgentOverridableResponse, OverridableField, OverrideLockReason, RetuneRunResponse, RunConfigRecord, SubagentHoldInfo, RunConfigResponse, RunPromptResponse, RunPromptSnapshot, PromptBlock, TokenLimit, TokenLimitsResponse, ConfigResponse, ConfigProvider, ConfigModel, ConfigSearch, ConfigInstance, SetTokenLimitRequest, CredentialScope, CredentialMeta, CredentialListResponse, CryptoKeyVersion, CryptoKeyExport, CryptoKeyType, CryptoKeyEncoding, CryptoKeyBackend, CryptoKeyExternal, CryptoOp, CryptoRequestBase, CryptoKeyRef, CryptoEncryptRequest, CryptoDecryptRequest, CryptoRewrapRequest, CryptoMacRequest, CryptoVerifyMacRequest, CryptoSignRequest, CryptoVerifyRequest, CryptoPublicKeyRequest, CryptoTotpRequest, CryptoHashRequest, CryptoRandomRequest, CryptoHashPasswordRequest, CryptoVerifyPasswordRequest, CryptoRequest, CryptoEncryptResult, CryptoDecryptResult, CryptoRewrapResult, CryptoMacResult, CryptoVerifyResult, CryptoSignResult, CryptoPublicJWK, CryptoPublicKeyResult, CryptoTotpResult, CryptoHashResult, CryptoRandomResult, CryptoHashPasswordResult, CryptoVerifyPasswordResult, CryptoResultByOp, CryptoResult, DecideRequest, DecideResponse, DecisionQuestion, DecisionChoiceQuestion, DecisionNoulQuestion, DecisionScoreQuestion, DecisionAnswer, DecisionChoiceAnswer, DecisionNoulAnswer, DecisionScoreAnswer, DecisionModel, DecisionModelsResponse, AclMode, AclSource, AclEffect, AclSubjectKind, AclCondition, AclRule, AclList, AclDefRow, AclDefListResponse, AclDefNamesResponse, AclValidateResult, AclCatalogType, AclCatalog, AclDefOp, AclDefInput, GroupRow, GroupMemberKind, GroupMember, GroupListResponse, GroupDetail, GroupEffective, CreateGroupBody, GroupMemberChange, AclBinding, AclBindingListResponse, CreateAclBindingBody, AuthzReason, AuthzDecision, AuthzRequestContext, AuthzEvaluationRequest, AuthzEvaluationsSemantic, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzTrace, AuthzAppliedBinding, AuthzExplainResponse, AuthzDraftBinding, AuthzSimulateRequest, AuthzSimulateResult, AuthzSimulateResponse, OAuthServerMetadata, OAuthTokenResponse, OAuthTokenSet, BeginAuthorizeOptions, AuthorizeRequest, AuthorizeResponseParams, CompleteAuthorizeOptions, RefreshTokenOptions, RevokeTokenOptions, TokenProvider, AppClientRefresh, AppClientConfig, ClientDefInput, ClientDefRecord, ConfigAppClient, AppClientEntry, ClientDefListResponse, ClientDefVerifyResult, ClientDefRetireResult, ClientDefNameSummary, ClientDefNamesResponse, DeviceLoginPrompt, DeviceLoginOptions, DeviceLoginResult, } from "./types.js";
|
|
220
|
+
export type { AgentEvent, ClientOptions, ContinueOptions, EventType, HostWidening, ImageMediaType, ParentContext, PromptContent, PromptSegment, RetryInfo, RunOptions, RunOverrideOptions, SamplingOptions, CompactionOptions, ContextOptions, ToolUse, Usage, CallTiming, Agent, AgentStatus, AwaitedState, AgentUsage, RunResult, RunSpec, RunSpecTeam, ConfiguredRun, ConfiguredRunPatch, ToolChoiceOptions, OutputFormatOptions, CancelAgentResult, ListAgentsResponse, ListUserAgentsOptions, AgentList, WalkRunsPage, RunBatchOptions, RunBatchResult, SpawnRunResult, CompactRunResult, RunTreeDeletion, RunTreeNotReached, DirectoryBudget, DirectoryInspection, DirectoryTenant, DirectoryUser, ErasureAccess, ErasureReport, ErasureResidue, ErasureResult, ErasureTier, MergeSubjectsResult, SubjectRef, BindSubjectPrincipalResult, ReviewQueueFilter, ReviewQueueGroup, ReviewQueueResult, RuleStatementsResult, RevertRulingResult, RulingBreakdown, RulingItem, RulingSelector, RulingRecord, ListRulingsResult, PolicyRuleCount, ApplyReviewPolicyResult, ErasureBoundSubject, ErasureTokenRef, CancelTurnResult, ReviewRunResult, ReplaySessionResult, TranscriptEvent, TranscriptResponse, HealthResponse, ListUsersResponse, UserSummary, UserStatus, UserRecord, CreateUserBody, UpdateUserBody, MintedUserToken, TokenRestrictions, UserTokenMeta, ListUserTokensResponse, UserIdentity, UserIdentitiesResponse, AuthGateKind, AuthGate, AuthGateKey, AuthGateRemoval, AuthGateProbe, AuthGateListResponse, CreateInviteBody, CreatedInvite, AuthInviteState, AuthInvite, AuthInviteListResponse, CreatedPasswordReset, GateIdentity, GateIdentitiesResponse, GateTenantStatus, RunnableAgent, RunnableAgentsResponse, WhoamiResponse, WhoamiEffective, WhoamiAuth, PauseResult, RetentionOverride, ResumeResult, RuntimeStateResponse, RuntimeStateStatus, ResolverMatrix, ResolverModelStatus, ResolverProviderAvailability, CreateSnapshotOptions, SnapshotCreateResponse, SnapshotDescriptor, SnapshotEnvelope, SnapshotListResponse, SnapshotRestoreResponse, MemoryEntriesResponse, MemoryEntry, MemoryEntryResponse, MemoryScopeIDsResponse, MemoryScopeIDSummary, MemoryScopeKind, MemoryScopesResponse, MemorySearchDocumentFilter, MemorySearchInput, MemorySource, MemoryWhen, MemoryTimeFilter, MemorySearchEntry, MemorySearchResponse, MemoryEmbedModelStats, MemoryEmbedStatsResponse, MemoryReembedConfigured, MemoryReembedResponse, MemoryBackfillResponse, MemoryPurgeResponse, InterruptListResponse, InterruptRow, InterruptStatus, ResolveInterruptOptions, ChannelHookCall, ChannelHookResult, HookFailMode, HookPhase, HookToolCall, HookToolResult, PostHookCall, PostHookResult, PreHookCall, PreHookResult, SubstrateToolInput, SubstrateToolResponse, TeamNameSummary, ListTeamsResponse, TeamDiagram, CreatedTeam, PromotedTeam, RetiredTeam, TeamDefDetail, TeamVerification, TeamDraft, TeamDraftVerification, TeamIssue, TeamIssueKind, TeamVersion, TeamVersionList, TeamBreakpoints, TeamRunDetached, TeamRunResult, TeamRunTarget, CreateTeamOptions, ForkTeamOptions, DefNameSummary, DefNamesResponse, OperatorTokenDefNameSummary, OperatorTokenDefNamesResponse, ScheduleListEntry, ScheduleListResponse, ScheduleActiveRun, ScheduleStateView, ScheduleRunNowResult, SchedulePauseResult, ModelAlias, ModelAliasesResponse, RoutingResponse, RoutingUserTier, RoutingTier, RoutingCandidate, RoutingThroughput, RoutingProvider, SearchRoutingProvider, RoutingEmbedder, RoutingDecision, RoutingDecisionModel, ProviderModelsResponse, TeamRunStep, TeamDecisionHandler, TeamDecisionQuestion, TeamDecisionAnswer, PathToolInput, PathToolResponse, DocumentToolInput, DocumentEdgeEvidence, DocumentToolResponse, DocumentSearchFilter, DocumentSearchHit, DocumentSearchResult, DocumentRelatedResult, GraphSnapshot, HistoryToolInput, HistoryToolResponse, EvaluationEmitterRole, EvaluationSubmitInput, EvaluationGetInput, EvaluationListForRunInput, EvaluationListForDefInput, EvaluationAggregateInput, EvaluationInput, EvaluationSubmitResult, EvaluationRecord, EvaluationListForRunResult, EvaluationListForDefResult, EvaluationScoreStats, EvaluationAggregate, VolumeMode, PersistentVolumeEntry, PersistentVolumesResponse, EphemeralVolumeEntry, EphemeralVolumesResponse, SystemPromptPayload, UserInputPayload, ChannelDescriptor, ListChannelsResponse, RunStateEvent, RunStateStreamClose, RunStateStreamItem, RunStateStreamOpen, StreamUserRunStatesOptions, ChangeFeedError, ChangeFeedFrame, ChangeFeedStatus, EmbedderHealth, MemoryChange, MemoryChangeScope, MemoryChangeType, StreamChangesOptions, DocumentFeedChange, DocumentFeedChangeType, DocumentFeedFrame, DocumentFeedOptions, DocumentFeedStatus, AckChannelOptions, ChannelAckResult, ChannelMessageItem, ChannelPeekResult, ListTeamChannelsOptions, PeekTeamChannelOptions, ReleaseTeamChannelOptions, TeamChannelReleaseResult, TeamChannelDeclaredIn, TeamChannelDescriptor, TeamChannelPeekResult, TeamChannelsResult, ChannelPublishResult, ChannelPurgeResult, ChannelReleaseResult, ChannelScope, ChannelSubscribeResult, PeekChannelOptions, PublishChannelOptions, SubscribeChannelOptions, AwaitChannelsOptions, BroadcastChannelsOptions, ChannelAwaitEntry, ChannelAwaitMode, ChannelAwaitResult, ChannelBroadcastEntry, ChannelBroadcastResult, CreateChannelOptions, ReleaseChannelOptions, UpdateChannelOptions, SetMemoryEntryOptions, SetMemoryEntryResponse, AgentDefRowResponse, AgentDefVerifyResult, SkillDefVerifyResult, EnsureMcpServerOptions, EnsureMcpServerResult, MCPServerDefRowResponse, MCPServerDefVerifyResult, AgentDefOverlay, AgentRouting, AgentChannelACL, AgentInterruptionACL, AgentDecision, MemoryRerank, AgentSampling, AgentCompaction, AgentTranscription, AgentSpeech, AgentContext, TierCandidate, CoreBlock, HookEvent, InlineWebhook, HookEntry, EventHooks, ToolEntry, ToolHooksByTool, EnsureCodeAgentOptions, EnsureCodeAgentResult, CreateDefOptions, ForkDefOptions, EnsureHookDefOptions, EnsureHookDefResult, HookDefBody, HookDefForkOverlay, HookDefInput, HookDefMatch, HookDefOverlay, HookDefRowResponse, HookDefVerifyResult, ScheduleDefInput, ScheduleDefOverlay, ScheduleDefRowResponse, ScheduledRunHook, ScheduledRunPromptContent, ScheduledRunPromptSegment, WebhookDefAuth, WebhookDefFilter, WebhookDefInput, WebhookDefOverlay, WebhookDefRateLimit, WebhookDefRowResponse, WebhookDefDeliveries, WebhookDefSyncResponse, LibraryAgentDefinition, LibraryEntry, LibraryListResponse, LibraryMcpServerDefinition, LibrarySkillDefinition, LLMChatContent, LLMChatMessage, LLMChatOptions, LLMChatResponse, LLMChatStreamDelta, LLMChatStreamItem, LLMChatToolCall, LLMChatUsage, LLMTool, LLMEmbeddingItem, LLMEmbeddingsOptions, LLMEmbeddingsResponse, LLMEmbeddingsUsage, UsageDimension, UsageBucket, UsageAggregate, UsageReportResponse, CapabilityInertInfo, LimitInfo, FileCapturedInfo, TranscriptionInfo, AdmissionInfo, ErrorInfo, CallFormat, CallRef, HookDecisionInfo, TeamDecisionInfo, OverrideInfo, FallbackInfo, InterruptionEventInfo, SpawnChildInfo, TurnCancelledInfo, ChannelEventInfo, ContextCompactionInfo, ContextRecapInfo, ContextStateInfo, ContextExhaustedInfo, ContextTierVerdict, ContextDistillDeclinedInfo, EffectiveConfigResponse, RunFileInput, RunFileImportSource, RunFileImportHeading, RunInboxDownload, EffectiveConfigSource, EffectiveValue, InertContextSetting, AgentOverridableResponse, OverridableField, OverrideLockReason, RetuneRunResponse, RunConfigRecord, SubagentHoldInfo, RunConfigResponse, RunPromptResponse, RunPromptSnapshot, PromptBlock, TokenLimit, TokenLimitsResponse, ConfigResponse, ConfigProvider, ConfigModel, ConfigSearch, ConfigInstance, SetTokenLimitRequest, CredentialScope, CredentialMeta, CredentialListResponse, CryptoKeyVersion, CryptoKeyExport, CryptoKeyType, CryptoKeyEncoding, CryptoKeyBackend, CryptoKeyExternal, CryptoOp, CryptoRequestBase, CryptoKeyRef, CryptoEncryptRequest, CryptoDecryptRequest, CryptoRewrapRequest, CryptoMacRequest, CryptoVerifyMacRequest, CryptoSignRequest, CryptoVerifyRequest, CryptoPublicKeyRequest, CryptoTotpRequest, CryptoHashRequest, CryptoRandomRequest, CryptoHashPasswordRequest, CryptoVerifyPasswordRequest, CryptoRequest, CryptoEncryptResult, CryptoDecryptResult, CryptoRewrapResult, CryptoMacResult, CryptoVerifyResult, CryptoSignResult, CryptoPublicJWK, CryptoPublicKeyResult, CryptoTotpResult, CryptoHashResult, CryptoRandomResult, CryptoHashPasswordResult, CryptoVerifyPasswordResult, CryptoResultByOp, CryptoResult, DecideRequest, DecideResponse, DecisionQuestion, DecisionChoiceQuestion, DecisionNoulQuestion, DecisionScoreQuestion, DecisionAnswer, DecisionChoiceAnswer, DecisionNoulAnswer, DecisionScoreAnswer, DecisionModel, DecisionModelsResponse, AclMode, AclSource, AclEffect, AclSubjectKind, AclCondition, AclRule, AclList, AclDefRow, AclDefListResponse, AclDefNamesResponse, AclValidateResult, AclCatalogType, AclCatalog, AclDefOp, AclDefInput, GroupRow, GroupMemberKind, GroupMember, GroupListResponse, GroupDetail, GroupEffective, CreateGroupBody, GroupMemberChange, AclBinding, AclBindingListResponse, CreateAclBindingBody, AuthzReason, AuthzDecision, AuthzRequestContext, AuthzEvaluationRequest, AuthzEvaluationsSemantic, AuthzEvaluationsRequest, AuthzEvaluationsResponse, AuthzTrace, AuthzAppliedBinding, AuthzExplainResponse, AuthzDraftBinding, AuthzSimulateRequest, AuthzSimulateResult, AuthzSimulateResponse, OAuthServerMetadata, OAuthTokenResponse, OAuthTokenSet, BeginAuthorizeOptions, AuthorizeRequest, AuthorizeResponseParams, CompleteAuthorizeOptions, RefreshTokenOptions, RevokeTokenOptions, TokenProvider, AppClientRefresh, AppClientConfig, ClientDefInput, ClientDefRecord, ConfigAppClient, AppClientEntry, ClientDefListResponse, ClientDefVerifyResult, ClientDefRetireResult, ClientDefNameSummary, ClientDefNamesResponse, DeviceLoginPrompt, DeviceLoginOptions, DeviceLoginResult, } from "./types.js";
|
|
220
221
|
export { AclDeniedError, AgentIDInUseError, AgentNotFoundError, AlreadyPausingError, AuthError, BackpressureError, DeviceLoginError, NotFoundError, InsufficientScopeError, InvalidArgumentError, ChannelCursorRegressionError, LoomcycleError, NotPausedError, OAuthError, PauseNotConfiguredError, PerUserQuotaExhaustedError, PromptTooLargeError, RateLimitedError, RequestTooLargeError, SessionBusyError, SessionNotFoundError, SnapshotNotFoundError, SnapshotTooLargeError, SnapshotVersionError, SubstrateToolRefusedError, TokenLimitExceededError, UnavailableError, } from "./errors.js";
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
* // Memory / document change feeds (RFC CD Part C; SSE; substrate:tenant)
|
|
78
78
|
* streamMemoryChanges(opts?): AsyncIterable<ChangeFeedFrame> // feed | change | error (non-fatal); resume with opts.since = last seq
|
|
79
79
|
* streamDocumentChanges(opts?): AsyncIterable<ChangeFeedFrame>
|
|
80
|
+
* documentFeed(opts): AsyncIterable<DocumentFeedFrame> // RFC FV: member-safe, one scope, no cursor (reconnect = resync)
|
|
80
81
|
*
|
|
81
82
|
* // Interruption (v0.8.16; decline RFC BH)
|
|
82
83
|
* listUserInterrupts(userId, opts?): Promise<InterruptListResponse>
|
package/dist/types.d.ts
CHANGED
|
@@ -3767,7 +3767,7 @@ export type DocumentEdgeEvidence = {
|
|
|
3767
3767
|
char_end?: number;
|
|
3768
3768
|
};
|
|
3769
3769
|
export type DocumentToolInput = {
|
|
3770
|
-
op: "create_document" | "get_document" | "documents_summary" | "query_documents" | "delete_document" | "set_path" | "create_chunk" | "upsert_chunk" | "get_chunk" | "update_chunk" | "delete_chunk" | "supersede_chunk" | "graph_recall" | "move_chunk" | "reorder_chunk" | "link_chunks" | "unlink_chunks" | "get_edges" | "get_edge" | "propose_statement" | "accept_statement" | "reject_statement" | "list_statements" | "judge_statements" | "maintain_statement" | "resolve_anchor" | "lease" | "release" | "describe_ontology" | "extract_citations" | "classify" | "accept_classification" | "query_chunks" | "add_tags" | "remove_tags" | "list_tags" | "define_type" | "list_types" | "set_asset" | "get_asset" | "export_md" | "import_md" | "backlinks" | "related" | "unlinked_mentions" | "history" | "get_version" | "diff" | "export_canvas" | "import_canvas" | "list_facts" | "judge_fact" | "verbatim_answer" | "verification_stats" | "remember" | "propose_entity" | "propose_subject" | "search" | "set_remote" | "sync" | "diff_remote";
|
|
3770
|
+
op: "create_document" | "get_document" | "documents_summary" | "query_documents" | "graph_snapshot" | "delete_document" | "set_path" | "copy_documents" | "create_chunk" | "upsert_chunk" | "get_chunk" | "update_chunk" | "delete_chunk" | "supersede_chunk" | "graph_recall" | "move_chunk" | "reorder_chunk" | "link_chunks" | "unlink_chunks" | "get_edges" | "get_edge" | "propose_statement" | "accept_statement" | "reject_statement" | "list_statements" | "judge_statements" | "maintain_statement" | "resolve_anchor" | "lease" | "release" | "describe_ontology" | "extract_citations" | "classify" | "accept_classification" | "query_chunks" | "add_tags" | "remove_tags" | "list_tags" | "define_type" | "list_types" | "set_asset" | "get_asset" | "export_md" | "import_md" | "backlinks" | "related" | "unlinked_mentions" | "history" | "get_version" | "diff" | "export_canvas" | "import_canvas" | "list_facts" | "judge_fact" | "verbatim_answer" | "verification_stats" | "remember" | "propose_entity" | "propose_subject" | "search" | "set_remote" | "sync" | "diff_remote";
|
|
3771
3771
|
scope?: "agent" | "user" | "tenant";
|
|
3772
3772
|
/** Document id (get/delete_document) or chunk id (get/update/delete/move_chunk). */
|
|
3773
3773
|
id?: string;
|
|
@@ -3835,8 +3835,9 @@ export type DocumentToolInput = {
|
|
|
3835
3835
|
* names ONE source (chunk_id; session_id + event_seq; or scope + natural_key)
|
|
3836
3836
|
* and the verbatim quote, which the server checks against that source. */
|
|
3837
3837
|
evidence?: DocumentEdgeEvidence[];
|
|
3838
|
-
/** get_edges (default true) / backlinks (default false)
|
|
3839
|
-
*
|
|
3838
|
+
/** get_edges (default true) / backlinks (default false) / graph_snapshot
|
|
3839
|
+
* (default false): include relations proposed for review. graph_recall
|
|
3840
|
+
* (default false): also follow them. */
|
|
3840
3841
|
include_proposed?: boolean;
|
|
3841
3842
|
/** get_edges / backlinks / graph_recall / list_facts: also return what has been
|
|
3842
3843
|
* retired (superseded relations and facts). list_statements: also list
|
|
@@ -3848,8 +3849,9 @@ export type DocumentToolInput = {
|
|
|
3848
3849
|
/** get_edges: out | in | both (default both). reorder_chunk: up | down. sync /
|
|
3849
3850
|
* diff_remote: pull (default) | push. */
|
|
3850
3851
|
direction?: "out" | "in" | "both" | "up" | "down" | "pull" | "push";
|
|
3851
|
-
/** get_edges / backlinks / list_statements: the next_cursor
|
|
3852
|
-
* (list_statements: with the same `order
|
|
3852
|
+
/** get_edges / backlinks / list_statements / graph_snapshot: the next_cursor
|
|
3853
|
+
* of the previous page (list_statements: with the same `order`;
|
|
3854
|
+
* graph_snapshot: `page.next_cursor`). */
|
|
3853
3855
|
after?: string;
|
|
3854
3856
|
/** list_statements: only relations with an evidence row quoting a chunk of
|
|
3855
3857
|
* this document. (`document_id` keeps relations with either end in it.) */
|
|
@@ -3873,6 +3875,9 @@ export type DocumentToolInput = {
|
|
|
3873
3875
|
hops?: 1;
|
|
3874
3876
|
budget_chars?: number;
|
|
3875
3877
|
};
|
|
3878
|
+
/** search: also return `query_xyz`, the query placed on the scope's 3D map
|
|
3879
|
+
* (the axes of graph_snapshot's `projection` block). Absent without a map. */
|
|
3880
|
+
with_projection?: boolean;
|
|
3876
3881
|
/** related: a chunk whose neighbours BY RELATION to return as `linked`. */
|
|
3877
3882
|
related_to?: string;
|
|
3878
3883
|
/** import_md: the markdown is a new edition of document_id / work_key. */
|
|
@@ -3911,11 +3916,31 @@ export type DocumentToolInput = {
|
|
|
3911
3916
|
/** search / related: never chunks of documents named at or under these paths. */
|
|
3912
3917
|
exclude_under_paths?: string[];
|
|
3913
3918
|
/** documents_summary: the documents to summarize. search / related: return
|
|
3914
|
-
* only chunks of these documents. */
|
|
3919
|
+
* only chunks of these documents. copy_documents: the documents to copy. */
|
|
3915
3920
|
document_ids?: string[];
|
|
3921
|
+
/** copy_documents: the scope the copies go to (`scope` is where they are). */
|
|
3922
|
+
to_scope?: "agent" | "user" | "tenant";
|
|
3923
|
+
/** copy_documents: Path prefixes to rewrite, from → to; the longest wins. */
|
|
3924
|
+
path_map?: Record<string, string>;
|
|
3925
|
+
/** copy_documents: true (the default) reports without writing. */
|
|
3926
|
+
dry_run?: boolean;
|
|
3916
3927
|
/** search / related: never chunks of these documents (e.g. the document under
|
|
3917
3928
|
* review, so its own text is not found as evidence for itself). */
|
|
3918
3929
|
exclude_document_ids?: string[];
|
|
3930
|
+
/** graph_snapshot: only the documents holding these chunks (with
|
|
3931
|
+
* `document_ids`, the union). A chunk of a document the caller may not read
|
|
3932
|
+
* selects nothing, as a missing id does. */
|
|
3933
|
+
chunk_ids?: string[];
|
|
3934
|
+
/** graph_snapshot: the sections to return (default all but `projection`).
|
|
3935
|
+
* `chunks` needs `documents`; `edges`, `facts` and `projection` need
|
|
3936
|
+
* `chunks`. */
|
|
3937
|
+
include?: Array<"documents" | "chunks" | "edges" | "dirents" | "facts" | "projection">;
|
|
3938
|
+
/** graph_snapshot: documents per page (default 200, at most 1000 — a larger
|
|
3939
|
+
* value is lowered, never refused). A page always holds whole documents. */
|
|
3940
|
+
page_documents?: number;
|
|
3941
|
+
/** graph_snapshot: the most relations one page returns (default 50000, at
|
|
3942
|
+
* most 200000); `edges.truncated` says it was reached. */
|
|
3943
|
+
edge_budget?: number;
|
|
3919
3944
|
/** search / related: chunk types, each including its ontology subtypes (with
|
|
3920
3945
|
* `type`, the union of both). */
|
|
3921
3946
|
types?: string[];
|
|
@@ -4088,6 +4113,9 @@ export type DocumentSearchResult = {
|
|
|
4088
4113
|
filter?: DocumentSearchFilter;
|
|
4089
4114
|
reranked?: boolean;
|
|
4090
4115
|
rerank_reason?: string;
|
|
4116
|
+
/** With `with_projection` and a map for the scope: the query's place on it
|
|
4117
|
+
* (4 decimals). */
|
|
4118
|
+
query_xyz?: [number, number, number];
|
|
4091
4119
|
};
|
|
4092
4120
|
/** Response of `document({op:"related"})` — narrow a {@link DocumentToolResponse}
|
|
4093
4121
|
* to it. */
|
|
@@ -4103,6 +4131,108 @@ export type DocumentRelatedResult = {
|
|
|
4103
4131
|
}>;
|
|
4104
4132
|
filter?: DocumentSearchFilter;
|
|
4105
4133
|
};
|
|
4134
|
+
/** Response of `document({op:"graph_snapshot"})` — narrow a
|
|
4135
|
+
* {@link DocumentToolResponse} to it. Columnar: every array of a section is
|
|
4136
|
+
* parallel (position `i` of each describes one item). An `*_idx` column is a
|
|
4137
|
+
* position in another section of the same response; a `*_code` column is a
|
|
4138
|
+
* position in the matching `codes` list, `-1` = none. Timestamps are unix
|
|
4139
|
+
* nanoseconds. Documents the caller may not read are absent, with their
|
|
4140
|
+
* chunks, the relations into them and their Path names. */
|
|
4141
|
+
export type GraphSnapshot = {
|
|
4142
|
+
page: {
|
|
4143
|
+
/** Documents on this page — always whole documents, in id order. */
|
|
4144
|
+
documents: number;
|
|
4145
|
+
/** Pass as `after` for the next page; absent on the last one. */
|
|
4146
|
+
next_cursor?: string;
|
|
4147
|
+
/** Present when the SQL Memory row cap fitted fewer documents than asked. */
|
|
4148
|
+
clamped_to?: number;
|
|
4149
|
+
};
|
|
4150
|
+
codes: {
|
|
4151
|
+
types: string[];
|
|
4152
|
+
statuses: string[];
|
|
4153
|
+
kinds: string[];
|
|
4154
|
+
fact_classes: string[];
|
|
4155
|
+
methods: string[];
|
|
4156
|
+
};
|
|
4157
|
+
documents?: {
|
|
4158
|
+
ids: string[];
|
|
4159
|
+
titles: string[];
|
|
4160
|
+
root_chunk_ids: string[];
|
|
4161
|
+
type_code: number[];
|
|
4162
|
+
status_code: number[];
|
|
4163
|
+
created_at: number[];
|
|
4164
|
+
updated_at: number[];
|
|
4165
|
+
color_enabled: boolean[];
|
|
4166
|
+
color_scheme: Array<Record<string, unknown> | null>;
|
|
4167
|
+
/** Every Path name of each document, shortest first. */
|
|
4168
|
+
paths: string[][];
|
|
4169
|
+
};
|
|
4170
|
+
chunks?: {
|
|
4171
|
+
ids: string[];
|
|
4172
|
+
document_idx: number[];
|
|
4173
|
+
/** -1 = a root. Always an earlier position: parents come first. */
|
|
4174
|
+
parent_idx: number[];
|
|
4175
|
+
position: number[];
|
|
4176
|
+
type_code: number[];
|
|
4177
|
+
status_code: number[];
|
|
4178
|
+
titles: string[];
|
|
4179
|
+
valid_at: Array<number | null>;
|
|
4180
|
+
invalid_at: Array<number | null>;
|
|
4181
|
+
updated_at: number[];
|
|
4182
|
+
/** Only with `include` naming `facts`. */
|
|
4183
|
+
is_fact?: boolean[];
|
|
4184
|
+
fact_class_code?: number[];
|
|
4185
|
+
fact_confidence?: Array<number | null>;
|
|
4186
|
+
fact_retired?: boolean[];
|
|
4187
|
+
};
|
|
4188
|
+
edges?: {
|
|
4189
|
+
ids: string[];
|
|
4190
|
+
/** A chunk position, or a negative `external[].idx`. */
|
|
4191
|
+
from_idx: number[];
|
|
4192
|
+
to_idx: number[];
|
|
4193
|
+
kind_code: number[];
|
|
4194
|
+
auto: boolean[];
|
|
4195
|
+
created_at: number[];
|
|
4196
|
+
status_code: number[];
|
|
4197
|
+
method_code: number[];
|
|
4198
|
+
confidence: Array<number | null>;
|
|
4199
|
+
valid_at: Array<number | null>;
|
|
4200
|
+
invalid_at: Array<number | null>;
|
|
4201
|
+
/** Ends on another page (or outside the selection). */
|
|
4202
|
+
external: Array<{
|
|
4203
|
+
idx: number;
|
|
4204
|
+
id: string;
|
|
4205
|
+
document_id: string;
|
|
4206
|
+
}>;
|
|
4207
|
+
/** True when `edge_budget` stopped the list. */
|
|
4208
|
+
truncated: boolean;
|
|
4209
|
+
};
|
|
4210
|
+
/** First page only. */
|
|
4211
|
+
dirents?: {
|
|
4212
|
+
paths: string[];
|
|
4213
|
+
kinds: Array<"directory" | "document">;
|
|
4214
|
+
/** A position in `documents` when the document is on this page, else -1. */
|
|
4215
|
+
document_idx: number[];
|
|
4216
|
+
/** The document a name points at ("" for a directory), whatever its page. */
|
|
4217
|
+
document_ids: string[];
|
|
4218
|
+
};
|
|
4219
|
+
/** Only with `include` naming `projection`: each chunk's place on the
|
|
4220
|
+
* scope's 3D map by meaning. `method` says how the map was fitted: `pca`
|
|
4221
|
+
* (the embedding on the scope's three principal axes) or `umap` (a layout
|
|
4222
|
+
* that keeps each chunk's nearest neighbours near it, so a document's
|
|
4223
|
+
* chunks stay together); absent while the projection is off. `model` is
|
|
4224
|
+
* the embedder ("<provider>/<model>"); `basis_version` 0 means no map yet,
|
|
4225
|
+
* with `xyz` empty and every chunk missing. Otherwise `xyz` is one x, y, z
|
|
4226
|
+
* triple per chunk in `chunks.ids` order (4 decimals), and a chunk with no
|
|
4227
|
+
* place on the current map is 0, 0, 0 with its position in `missing`. */
|
|
4228
|
+
projection?: {
|
|
4229
|
+
model: string;
|
|
4230
|
+
basis_version: number;
|
|
4231
|
+
method?: "pca" | "umap";
|
|
4232
|
+
xyz: number[];
|
|
4233
|
+
missing: number[];
|
|
4234
|
+
};
|
|
4235
|
+
};
|
|
4106
4236
|
/** Input for {@link LoomcycleClient.history} — the RFC BE History tool
|
|
4107
4237
|
* (POST /v1/_history). Browse/search/annotate PAST CHATS (a chat = a session).
|
|
4108
4238
|
* Op-discriminated; the owner is resolved server-side from the authenticated
|
|
@@ -7084,7 +7214,10 @@ export interface ForkTeamOptions extends CreateTeamOptions {
|
|
|
7084
7214
|
* {@link LoomcycleClient.streamMemoryChanges}, `document.chunk.*` on
|
|
7085
7215
|
* {@link LoomcycleClient.streamDocumentChanges}. Mirrors the runtime's
|
|
7086
7216
|
* `store.MemoryChangeType`. */
|
|
7087
|
-
export type MemoryChangeType = "memory.set" | "memory.delete" | "memory.scope_deleted" | "document.chunk.updated" | "document.chunk.deleted"
|
|
7217
|
+
export type MemoryChangeType = "memory.set" | "memory.delete" | "memory.scope_deleted" | "document.chunk.updated" | "document.chunk.deleted"
|
|
7218
|
+
/** A statement (a link between chunks) was written, ruled on or removed —
|
|
7219
|
+
* one per endpoint document (RFC FV). */
|
|
7220
|
+
| "document.edges.changed";
|
|
7088
7221
|
/** The memory scope a change landed in. `global` is listed because the
|
|
7089
7222
|
* runtime's scope enum has it and the feed passes the written scope through
|
|
7090
7223
|
* unchanged, not because Memory writes it today. */
|
|
@@ -7108,6 +7241,10 @@ export interface MemoryChange {
|
|
|
7108
7241
|
scope_id: string;
|
|
7109
7242
|
key?: string;
|
|
7110
7243
|
chunk_id?: string;
|
|
7244
|
+
/** The document a `document.*` change belongs to, recorded when the write
|
|
7245
|
+
* happened (RFC FV). Absent on a row whose writer did not say, and on rows
|
|
7246
|
+
* from a runtime older than the field. */
|
|
7247
|
+
document_id?: string;
|
|
7111
7248
|
/** RFC3339 time of the write. */
|
|
7112
7249
|
at: string;
|
|
7113
7250
|
}
|
|
@@ -7187,6 +7324,60 @@ export interface StreamChangesOptions {
|
|
|
7187
7324
|
/** Abort to close the stream; the iterator then throws an `AbortError`. */
|
|
7188
7325
|
signal?: AbortSignal;
|
|
7189
7326
|
}
|
|
7327
|
+
/** The change types {@link LoomcycleClient.documentFeed} carries. */
|
|
7328
|
+
export type DocumentFeedChangeType = "document.chunk.updated" | "document.chunk.deleted" | "document.edges.changed";
|
|
7329
|
+
/** One reader-feed change: a document the caller can list changed. NO cursor
|
|
7330
|
+
* — the reader feed never sends a seq, and a reconnect is a resync. Several
|
|
7331
|
+
* changes of one type to one document inside one server poll arrive as one,
|
|
7332
|
+
* naming the latest chunk. Value-free: refetch the document (e.g. through
|
|
7333
|
+
* `document({op:"graph_snapshot", document_ids:[…]})`). */
|
|
7334
|
+
export interface DocumentFeedChange {
|
|
7335
|
+
type: DocumentFeedChangeType;
|
|
7336
|
+
/** The chunk changed; for `document.edges.changed`, the statement's endpoint
|
|
7337
|
+
* in this document. */
|
|
7338
|
+
chunk_id: string;
|
|
7339
|
+
document_id: string;
|
|
7340
|
+
/** RFC3339 time of the write. */
|
|
7341
|
+
at: string;
|
|
7342
|
+
}
|
|
7343
|
+
/** The reader feed's opening frame (`event: feed`). Only `enabled`: no
|
|
7344
|
+
* cursor, and no embedder health (that is the operator feed's). */
|
|
7345
|
+
export interface DocumentFeedStatus {
|
|
7346
|
+
/** `false` when the server does not capture changes
|
|
7347
|
+
* (`LOOMCYCLE_MEMORY_CHANGES_ENABLED` unset): the stream stays open and NO
|
|
7348
|
+
* change will arrive — fall back to reloading on a timer. */
|
|
7349
|
+
enabled: boolean;
|
|
7350
|
+
}
|
|
7351
|
+
/** Yielded by {@link LoomcycleClient.documentFeed}: `{ kind: "feed" }` first,
|
|
7352
|
+
* then one `{ kind: "change" }` per change. An `error` item with code
|
|
7353
|
+
* `store_unavailable` is non-fatal (the server retries). These end the
|
|
7354
|
+
* stream: `access_unavailable` (the caller's access could not be re-checked),
|
|
7355
|
+
* `credential_revoked` (the credential no longer authenticates or is no longer
|
|
7356
|
+
* admitted) and `credential_expired` (the token's lifetime ended) — reload,
|
|
7357
|
+
* and reconnect with a valid credential. */
|
|
7358
|
+
export type DocumentFeedFrame = {
|
|
7359
|
+
kind: "feed";
|
|
7360
|
+
payload: DocumentFeedStatus;
|
|
7361
|
+
} | {
|
|
7362
|
+
kind: "change";
|
|
7363
|
+
payload: DocumentFeedChange;
|
|
7364
|
+
} | {
|
|
7365
|
+
kind: "error";
|
|
7366
|
+
payload: ChangeFeedError;
|
|
7367
|
+
};
|
|
7368
|
+
/** Options for {@link LoomcycleClient.documentFeed}. */
|
|
7369
|
+
export interface DocumentFeedOptions {
|
|
7370
|
+
/** The scope to watch. `agent` is not served: agent scopes are private to
|
|
7371
|
+
* their runs. */
|
|
7372
|
+
scope: "user" | "tenant";
|
|
7373
|
+
/** RFC AS browse override: watch another subject's user scope you may see
|
|
7374
|
+
* (sent as `?scope_id=`). */
|
|
7375
|
+
scopeId?: string;
|
|
7376
|
+
/** An admin's tenant focus (sent as `?tenant=`); ignored for anyone else. */
|
|
7377
|
+
tenant?: string;
|
|
7378
|
+
/** Abort to close the stream; the iterator then throws an `AbortError`. */
|
|
7379
|
+
signal?: AbortSignal;
|
|
7380
|
+
}
|
|
7190
7381
|
/** The access-control rollout mode a deployment runs in. */
|
|
7191
7382
|
export type AclMode = "compat" | "shadow" | "enforce";
|
|
7192
7383
|
/** Marks an entry the config declares rather than the store holds. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomcycle/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.135.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",
|