@weaveintel/core 0.0.1
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 +91 -0
- package/dist/a2a.d.ts +304 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +68 -0
- package/dist/a2a.js.map +1 -0
- package/dist/admin-capabilities.d.ts +60 -0
- package/dist/admin-capabilities.d.ts.map +1 -0
- package/dist/admin-capabilities.js +31 -0
- package/dist/admin-capabilities.js.map +1 -0
- package/dist/agents.d.ts +214 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +12 -0
- package/dist/agents.js.map +1 -0
- package/dist/artifacts.d.ts +70 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +5 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/cache.d.ts +177 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +9 -0
- package/dist/cache.js.map +1 -0
- package/dist/callables.d.ts +34 -0
- package/dist/callables.d.ts.map +1 -0
- package/dist/callables.js +35 -0
- package/dist/callables.js.map +1 -0
- package/dist/capabilities.d.ts +77 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +82 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/capability-policy.d.ts +41 -0
- package/dist/capability-policy.d.ts.map +1 -0
- package/dist/capability-policy.js +34 -0
- package/dist/capability-policy.js.map +1 -0
- package/dist/collaboration.d.ts +45 -0
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +5 -0
- package/dist/collaboration.js.map +1 -0
- package/dist/compliance.d.ts +71 -0
- package/dist/compliance.d.ts.map +1 -0
- package/dist/compliance.js +5 -0
- package/dist/compliance.js.map +1 -0
- package/dist/connectors.d.ts +109 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +24 -0
- package/dist/connectors.js.map +1 -0
- package/dist/context.d.ts +52 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +70 -0
- package/dist/context.js.map +1 -0
- package/dist/contracts.d.ts +70 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +5 -0
- package/dist/contracts.js.map +1 -0
- package/dist/documents.d.ts +55 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +9 -0
- package/dist/documents.js.map +1 -0
- package/dist/error-classifier.d.ts +67 -0
- package/dist/error-classifier.d.ts.map +1 -0
- package/dist/error-classifier.js +129 -0
- package/dist/error-classifier.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +63 -0
- package/dist/errors.js.map +1 -0
- package/dist/evals.d.ts +55 -0
- package/dist/evals.d.ts.map +1 -0
- package/dist/evals.js +9 -0
- package/dist/evals.js.map +1 -0
- package/dist/events.d.ts +60 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +108 -0
- package/dist/events.js.map +1 -0
- package/dist/extraction.d.ts +71 -0
- package/dist/extraction.d.ts.map +1 -0
- package/dist/extraction.js +5 -0
- package/dist/extraction.js.map +1 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +9 -0
- package/dist/files.js.map +1 -0
- package/dist/finetuning.d.ts +58 -0
- package/dist/finetuning.d.ts.map +1 -0
- package/dist/finetuning.js +9 -0
- package/dist/finetuning.js.map +1 -0
- package/dist/graph.d.ts +70 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +5 -0
- package/dist/graph.js.map +1 -0
- package/dist/guardrails.d.ts +221 -0
- package/dist/guardrails.d.ts.map +1 -0
- package/dist/guardrails.js +2 -0
- package/dist/guardrails.js.map +1 -0
- package/dist/hardened-fetch.d.ts +80 -0
- package/dist/hardened-fetch.d.ts.map +1 -0
- package/dist/hardened-fetch.js +251 -0
- package/dist/hardened-fetch.js.map +1 -0
- package/dist/human-tasks.d.ts +141 -0
- package/dist/human-tasks.d.ts.map +1 -0
- package/dist/human-tasks.js +5 -0
- package/dist/human-tasks.js.map +1 -0
- package/dist/identity.d.ts +53 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +5 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +163 -0
- package/dist/index.js.map +1 -0
- package/dist/json-patch.d.ts +72 -0
- package/dist/json-patch.d.ts.map +1 -0
- package/dist/json-patch.js +239 -0
- package/dist/json-patch.js.map +1 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +74 -0
- package/dist/logger.js.map +1 -0
- package/dist/managed-vectorstore.d.ts +88 -0
- package/dist/managed-vectorstore.d.ts.map +1 -0
- package/dist/managed-vectorstore.js +10 -0
- package/dist/managed-vectorstore.js.map +1 -0
- package/dist/mcp.d.ts +195 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +9 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +152 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +10 -0
- package/dist/memory.js.map +1 -0
- package/dist/middleware.d.ts +40 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +79 -0
- package/dist/middleware.js.map +1 -0
- package/dist/models.d.ts +279 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +12 -0
- package/dist/models.js.map +1 -0
- package/dist/moderation.d.ts +39 -0
- package/dist/moderation.d.ts.map +1 -0
- package/dist/moderation.js +10 -0
- package/dist/moderation.js.map +1 -0
- package/dist/net-guard.d.ts +60 -0
- package/dist/net-guard.d.ts.map +1 -0
- package/dist/net-guard.js +250 -0
- package/dist/net-guard.js.map +1 -0
- package/dist/notifications.d.ts +121 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +12 -0
- package/dist/notifications.js.map +1 -0
- package/dist/observability-runtime.d.ts +16 -0
- package/dist/observability-runtime.d.ts.map +1 -0
- package/dist/observability-runtime.js +34 -0
- package/dist/observability-runtime.js.map +1 -0
- package/dist/observability.d.ts +130 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +9 -0
- package/dist/observability.js.map +1 -0
- package/dist/plugins.d.ts +46 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +5 -0
- package/dist/plugins.js.map +1 -0
- package/dist/prompts.d.ts +219 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +5 -0
- package/dist/prompts.js.map +1 -0
- package/dist/registry.d.ts +31 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +34 -0
- package/dist/registry.js.map +1 -0
- package/dist/reliability.d.ts +68 -0
- package/dist/reliability.d.ts.map +1 -0
- package/dist/reliability.js +5 -0
- package/dist/reliability.js.map +1 -0
- package/dist/replay.d.ts +91 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +5 -0
- package/dist/replay.js.map +1 -0
- package/dist/responses.d.ts +273 -0
- package/dist/responses.d.ts.map +1 -0
- package/dist/responses.js +11 -0
- package/dist/responses.js.map +1 -0
- package/dist/routing.d.ts +171 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +5 -0
- package/dist/routing.js.map +1 -0
- package/dist/run-events.d.ts +199 -0
- package/dist/run-events.d.ts.map +1 -0
- package/dist/run-events.js +88 -0
- package/dist/run-events.js.map +1 -0
- package/dist/run-journal.d.ts +66 -0
- package/dist/run-journal.d.ts.map +1 -0
- package/dist/run-journal.js +153 -0
- package/dist/run-journal.js.map +1 -0
- package/dist/run-registry.d.ts +49 -0
- package/dist/run-registry.d.ts.map +1 -0
- package/dist/run-registry.js +154 -0
- package/dist/run-registry.js.map +1 -0
- package/dist/run-substrate-contract.d.ts +48 -0
- package/dist/run-substrate-contract.d.ts.map +1 -0
- package/dist/run-substrate-contract.js +124 -0
- package/dist/run-substrate-contract.js.map +1 -0
- package/dist/runs.d.ts +94 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +12 -0
- package/dist/runs.js.map +1 -0
- package/dist/runtime.d.ts +665 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +436 -0
- package/dist/runtime.js.map +1 -0
- package/dist/sandbox.d.ts +50 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +5 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/secrets.d.ts +34 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +68 -0
- package/dist/secrets.js.map +1 -0
- package/dist/security.d.ts +97 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +9 -0
- package/dist/security.js.map +1 -0
- package/dist/sse-parser.d.ts +67 -0
- package/dist/sse-parser.d.ts.map +1 -0
- package/dist/sse-parser.js +156 -0
- package/dist/sse-parser.js.map +1 -0
- package/dist/sse-writer.d.ts +63 -0
- package/dist/sse-writer.d.ts.map +1 -0
- package/dist/sse-writer.js +87 -0
- package/dist/sse-writer.js.map +1 -0
- package/dist/surface-catalog.d.ts +68 -0
- package/dist/surface-catalog.d.ts.map +1 -0
- package/dist/surface-catalog.js +13 -0
- package/dist/surface-catalog.js.map +1 -0
- package/dist/tenancy.d.ts +67 -0
- package/dist/tenancy.d.ts.map +1 -0
- package/dist/tenancy.js +5 -0
- package/dist/tenancy.js.map +1 -0
- package/dist/tool-lifecycle.d.ts +118 -0
- package/dist/tool-lifecycle.d.ts.map +1 -0
- package/dist/tool-lifecycle.js +5 -0
- package/dist/tool-lifecycle.js.map +1 -0
- package/dist/tools.d.ts +96 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +71 -0
- package/dist/tools.js.map +1 -0
- package/dist/triggers.d.ts +48 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +5 -0
- package/dist/triggers.js.map +1 -0
- package/dist/ui-events.d.ts +96 -0
- package/dist/ui-events.d.ts.map +1 -0
- package/dist/ui-events.js +5 -0
- package/dist/ui-events.js.map +1 -0
- package/dist/uuid.d.ts +27 -0
- package/dist/uuid.d.ts.map +1 -0
- package/dist/uuid.js +54 -0
- package/dist/uuid.js.map +1 -0
- package/dist/vectorstore.d.ts +76 -0
- package/dist/vectorstore.d.ts.map +1 -0
- package/dist/vectorstore.js +9 -0
- package/dist/vectorstore.js.map +1 -0
- package/dist/workflows.d.ts +554 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +29 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @weaveintel/core — Run-event stream contract (Phase 0)
|
|
3
|
+
*
|
|
4
|
+
* The single source of truth for:
|
|
5
|
+
* - the run-event wire envelope (`RunEventEnvelope`),
|
|
6
|
+
* - the canonical event-kind taxonomy (`RUN_EVENT_KINDS`), and
|
|
7
|
+
* - the default stream-tuning constants (`RUN_STREAM_CONFIG_DEFAULTS`).
|
|
8
|
+
*
|
|
9
|
+
* The geneweave server executor and the `@weaveintel/client` browser reducer
|
|
10
|
+
* each used to declare their own duplicate `RunEventEnvelope`; both now import
|
|
11
|
+
* this so the producer and consumer can never drift. The geneweave DB
|
|
12
|
+
* `run_stream_config` single-row table seeds from `RUN_STREAM_CONFIG_DEFAULTS`,
|
|
13
|
+
* and clients fall back to it when no server-served config is present.
|
|
14
|
+
*/
|
|
15
|
+
/** A single ordered run event as it crosses the SSE wire. */
|
|
16
|
+
export interface RunEventEnvelope {
|
|
17
|
+
runId: string;
|
|
18
|
+
sequence: number;
|
|
19
|
+
kind: string;
|
|
20
|
+
payload: Record<string, unknown>;
|
|
21
|
+
/** Epoch ms. The server always stamps it; optional on the client. */
|
|
22
|
+
timestamp?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Canonical run-event kinds emitted by the run executor and consumed by the
|
|
26
|
+
* client reducer. Producer and consumer share this list so a kind cannot be
|
|
27
|
+
* emitted that the reducer silently drops (or vice-versa) without a type error.
|
|
28
|
+
*/
|
|
29
|
+
export declare const RUN_EVENT_KINDS: readonly ["run.started", "run.completed", "run.failed", "run.cancelled", "text.delta", "tool.invoked", "tool.completed", "tool.errored", "widget.update", "reasoning.delta", "step.update", "usage.update", "citation.add", "artifact.update", "diagnostic", "tool.input.start", "tool.input.delta", "approval.request", "approval.resolved", "object.delta", "object.complete", "file.part", "presence.update"];
|
|
30
|
+
export type RunEventKind = (typeof RUN_EVENT_KINDS)[number];
|
|
31
|
+
/** Token usage + cost + timing for a run (from the chat `done` frame). */
|
|
32
|
+
export interface RunUsage {
|
|
33
|
+
promptTokens?: number;
|
|
34
|
+
completionTokens?: number;
|
|
35
|
+
totalTokens?: number;
|
|
36
|
+
costUsd?: number;
|
|
37
|
+
latencyMs?: number;
|
|
38
|
+
model?: string;
|
|
39
|
+
provider?: string;
|
|
40
|
+
mode?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A single agent/supervisor plan step. */
|
|
43
|
+
export interface RunStep {
|
|
44
|
+
index?: number;
|
|
45
|
+
type?: string;
|
|
46
|
+
content?: string;
|
|
47
|
+
toolName?: string;
|
|
48
|
+
durationMs?: number;
|
|
49
|
+
/** Lifecycle phase, when known. */
|
|
50
|
+
phase?: 'step_start' | 'step_end';
|
|
51
|
+
}
|
|
52
|
+
/** A reference to an artifact produced by the run. */
|
|
53
|
+
export interface RunArtifactRef {
|
|
54
|
+
id: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
title?: string;
|
|
57
|
+
mimeType?: string;
|
|
58
|
+
url?: string;
|
|
59
|
+
}
|
|
60
|
+
/** A source / citation surfaced during the run. */
|
|
61
|
+
export interface RunCitation {
|
|
62
|
+
id: string;
|
|
63
|
+
text?: string;
|
|
64
|
+
source?: string;
|
|
65
|
+
url?: string;
|
|
66
|
+
}
|
|
67
|
+
/** A non-output diagnostic frame (guardrail / policy / eval / cognitive / ensemble). */
|
|
68
|
+
export interface RunDiagnostic {
|
|
69
|
+
channel: string;
|
|
70
|
+
data?: unknown;
|
|
71
|
+
}
|
|
72
|
+
/** A human-in-the-loop approval request emitted when a gated tool needs a decision. */
|
|
73
|
+
export interface RunApprovalRequest {
|
|
74
|
+
/** Correlates the request with the client's `approval.decision` reply. */
|
|
75
|
+
taskId: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
args?: Record<string, unknown>;
|
|
78
|
+
title?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
riskLevel?: string;
|
|
81
|
+
/** Available decisions (e.g. Approve / Deny). */
|
|
82
|
+
actions?: Array<{
|
|
83
|
+
label: string;
|
|
84
|
+
value: string;
|
|
85
|
+
style?: string;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
/** Resolution of a prior approval request. */
|
|
89
|
+
export interface RunApprovalResolution {
|
|
90
|
+
taskId: string;
|
|
91
|
+
/** 'approve' | 'reject' | 'modify'. */
|
|
92
|
+
action: string;
|
|
93
|
+
feedback?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Phase 7 — an incremental chunk of a streamed structured (JSON) object. */
|
|
96
|
+
export interface RunObjectDelta {
|
|
97
|
+
/** Raw JSON text fragment to append to the object buffer. */
|
|
98
|
+
delta: string;
|
|
99
|
+
}
|
|
100
|
+
/** Phase 7 — the structured object finished; carries the final parsed value. */
|
|
101
|
+
export interface RunObjectComplete {
|
|
102
|
+
/** The fully-parsed object (when the server could parse it). */
|
|
103
|
+
value?: unknown;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Collaboration Phase 1 — one participant currently present on a run.
|
|
107
|
+
*
|
|
108
|
+
* "Presence" = who is watching/working on this run right now. A participant can
|
|
109
|
+
* be a human (`peerType: 'human'`) or an AI agent (`peerType: 'agent'`, the
|
|
110
|
+
* mid-2026 "agent as a first-class peer" pattern — the server shows the agent as
|
|
111
|
+
* present with a `working`/`streaming` status while the run produces output).
|
|
112
|
+
*
|
|
113
|
+
* Identity (`userId`, `displayName`) is SERVER-DERIVED from the caller's auth —
|
|
114
|
+
* never client-supplied — so presence cannot be spoofed.
|
|
115
|
+
*/
|
|
116
|
+
export interface RunPresenceParticipant {
|
|
117
|
+
/** Stable identity (server-derived). For agents, a reserved id like `__agent`. */
|
|
118
|
+
userId: string;
|
|
119
|
+
/** Display label only — no PII (no email / internal ids). */
|
|
120
|
+
displayName: string;
|
|
121
|
+
/** Human: online/idle/typing/away/offline. Agent: working/streaming/thinking/idle. */
|
|
122
|
+
presence: string;
|
|
123
|
+
/** `'human'` or `'agent'`. */
|
|
124
|
+
peerType: 'human' | 'agent';
|
|
125
|
+
/** Optional UI color for the participant's cursor/badge. */
|
|
126
|
+
color?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Collaboration Phase 2 — the participant's role in the shared session
|
|
129
|
+
* (`owner` / `collaborator` / `viewer`), when the run is shared. Surfaced so a
|
|
130
|
+
* UI can badge who can edit vs only watch.
|
|
131
|
+
*/
|
|
132
|
+
role?: 'owner' | 'collaborator' | 'viewer';
|
|
133
|
+
/** Epoch ms of the participant's last heartbeat (drives TTL expiry). */
|
|
134
|
+
lastHeartbeatAt?: number;
|
|
135
|
+
/** Optional cursor / viewport the participant is looking at. */
|
|
136
|
+
cursor?: Record<string, unknown>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Collaboration Phase 1 — the `presence.update` payload: the FULL set of
|
|
140
|
+
* currently-present participants (a snapshot, not a delta). Snapshots are
|
|
141
|
+
* idempotent and gap-safe over SSE — the client replaces its whole presence set
|
|
142
|
+
* on each update, so a dropped/reordered event self-corrects on the next one.
|
|
143
|
+
*/
|
|
144
|
+
export interface RunPresenceSnapshot {
|
|
145
|
+
participants: RunPresenceParticipant[];
|
|
146
|
+
}
|
|
147
|
+
/** Phase 7 — a multimodal file part (image / document) attached to a run. */
|
|
148
|
+
export interface RunFilePart {
|
|
149
|
+
id: string;
|
|
150
|
+
/** MIME type, e.g. `image/png`. */
|
|
151
|
+
mediaType: string;
|
|
152
|
+
name?: string;
|
|
153
|
+
/** A URL the client can fetch (mutually exclusive with `dataBase64`). */
|
|
154
|
+
url?: string;
|
|
155
|
+
/** Inline base64 payload (no `data:` prefix). */
|
|
156
|
+
dataBase64?: string;
|
|
157
|
+
size?: number;
|
|
158
|
+
/** `'input'` (sent to the model) or `'output'` (produced by the run). */
|
|
159
|
+
direction?: 'input' | 'output';
|
|
160
|
+
}
|
|
161
|
+
/** Kinds that close a run — exactly one is emitted per run. */
|
|
162
|
+
export declare const TERMINAL_RUN_EVENT_KINDS: readonly ["run.completed", "run.failed", "run.cancelled"];
|
|
163
|
+
export type TerminalRunEventKind = (typeof TERMINAL_RUN_EVENT_KINDS)[number];
|
|
164
|
+
/** True when `kind` is a terminal (run-closing) event kind. */
|
|
165
|
+
export declare function isTerminalRunEventKind(kind: string): boolean;
|
|
166
|
+
/** True when `kind` is part of the canonical taxonomy. */
|
|
167
|
+
export declare function isKnownRunEventKind(kind: string): kind is RunEventKind;
|
|
168
|
+
/**
|
|
169
|
+
* Run/stream tuning shared by server (SSE keepalive, journal retention) and
|
|
170
|
+
* client (reconnect backoff, stall timeout, UI throttle). The geneweave DB
|
|
171
|
+
* `run_stream_config` row is the runtime source of truth; these are the seeded
|
|
172
|
+
* defaults and the client-side fallback.
|
|
173
|
+
*/
|
|
174
|
+
export interface RunStreamConfig {
|
|
175
|
+
/** SSE keepalive comment interval (ms). */
|
|
176
|
+
heartbeatMs: number;
|
|
177
|
+
/** Max client reconnect attempts before giving up. 0 disables auto-reconnect. */
|
|
178
|
+
maxReconnects: number;
|
|
179
|
+
/** Reconnect backoff schedule (ms), indexed by attempt number (clamped to last). */
|
|
180
|
+
backoffMs: number[];
|
|
181
|
+
/** Tear down a stream that delivers no bytes within this window (ms). 0 = disabled. */
|
|
182
|
+
stallTimeoutMs: number;
|
|
183
|
+
/** Client UI-update throttle (ms). */
|
|
184
|
+
throttleMs: number;
|
|
185
|
+
/** Journal retention horizon (hours) for `user_run_events` pruning. */
|
|
186
|
+
journalRetentionHours: number;
|
|
187
|
+
/** Max persisted events kept per run. */
|
|
188
|
+
journalMaxEvents: number;
|
|
189
|
+
/** Window within which a refreshed client may resume an in-flight run (seconds). */
|
|
190
|
+
resumeWindowSeconds: number;
|
|
191
|
+
}
|
|
192
|
+
export declare const RUN_STREAM_CONFIG_DEFAULTS: RunStreamConfig;
|
|
193
|
+
/**
|
|
194
|
+
* Pick the backoff delay (ms) for a given zero-based reconnect attempt,
|
|
195
|
+
* clamping to the last entry of the schedule. Shared by client + tests so the
|
|
196
|
+
* reconnect cadence is defined once.
|
|
197
|
+
*/
|
|
198
|
+
export declare function reconnectBackoffMs(attempt: number, schedule?: readonly number[]): number;
|
|
199
|
+
//# sourceMappingURL=run-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-events.d.ts","sourceRoot":"","sources":["../src/run-events.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,kZAiClB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAM5D,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;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MAAM,CAAC;IACd,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAChC;AAED,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,2DAA4D,CAAC;AAClG,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI7E,+DAA+D;AAC/D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAID,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,YAAY,CAEtE;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uFAAuF;IACvF,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,0BAA0B,EAAE,eASxC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAyC,GAAG,MAAM,CAI9H"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* @weaveintel/core — Run-event stream contract (Phase 0)
|
|
4
|
+
*
|
|
5
|
+
* The single source of truth for:
|
|
6
|
+
* - the run-event wire envelope (`RunEventEnvelope`),
|
|
7
|
+
* - the canonical event-kind taxonomy (`RUN_EVENT_KINDS`), and
|
|
8
|
+
* - the default stream-tuning constants (`RUN_STREAM_CONFIG_DEFAULTS`).
|
|
9
|
+
*
|
|
10
|
+
* The geneweave server executor and the `@weaveintel/client` browser reducer
|
|
11
|
+
* each used to declare their own duplicate `RunEventEnvelope`; both now import
|
|
12
|
+
* this so the producer and consumer can never drift. The geneweave DB
|
|
13
|
+
* `run_stream_config` single-row table seeds from `RUN_STREAM_CONFIG_DEFAULTS`,
|
|
14
|
+
* and clients fall back to it when no server-served config is present.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Canonical run-event kinds emitted by the run executor and consumed by the
|
|
18
|
+
* client reducer. Producer and consumer share this list so a kind cannot be
|
|
19
|
+
* emitted that the reducer silently drops (or vice-versa) without a type error.
|
|
20
|
+
*/
|
|
21
|
+
export const RUN_EVENT_KINDS = [
|
|
22
|
+
'run.started',
|
|
23
|
+
'run.completed',
|
|
24
|
+
'run.failed',
|
|
25
|
+
'run.cancelled',
|
|
26
|
+
'text.delta',
|
|
27
|
+
'tool.invoked',
|
|
28
|
+
'tool.completed',
|
|
29
|
+
'tool.errored',
|
|
30
|
+
'widget.update',
|
|
31
|
+
// Phase 1 — lossless chat→run parity. Previously dropped by the bridge.
|
|
32
|
+
'reasoning.delta', // model thinking, as a DISTINCT channel (not folded into text)
|
|
33
|
+
'step.update', // agent/supervisor plan step lifecycle
|
|
34
|
+
'usage.update', // token usage, cost, latency, model (from the chat `done` frame)
|
|
35
|
+
'citation.add', // source/citation (forward-compatible; no producer yet)
|
|
36
|
+
'artifact.update', // artifact reference produced by the run
|
|
37
|
+
'diagnostic', // guardrail / policy / eval / cognitive / ensemble metadata
|
|
38
|
+
// Phase 2 — streaming partial tool input (per-part state machine).
|
|
39
|
+
'tool.input.start', // a tool call's input args begin streaming
|
|
40
|
+
'tool.input.delta', // a partial chunk of the tool's input args (JSON text)
|
|
41
|
+
// Phase 4 — human-in-the-loop tool approval (the run pauses awaiting a decision).
|
|
42
|
+
'approval.request', // a gated tool needs a human approve/deny decision
|
|
43
|
+
'approval.resolved', // the decision arrived (approved / denied / modified)
|
|
44
|
+
// Phase 7 — structured object streaming + multimodal file parts.
|
|
45
|
+
'object.delta', // an incremental chunk of a streamed structured (JSON) object
|
|
46
|
+
'object.complete', // the structured object finished (carries the final value)
|
|
47
|
+
'file.part', // a multimodal file part (image / document) in/out of the run
|
|
48
|
+
// Collaboration Phase 1 — presence ("who else is watching this run").
|
|
49
|
+
// EPHEMERAL: this is a live snapshot broadcast to current subscribers; it is
|
|
50
|
+
// NEVER written to the run journal (presence is high-churn, last-write-wins,
|
|
51
|
+
// disposable — it only ever means "current"). A run_presence table holds the
|
|
52
|
+
// current state; this event is the realtime push of that state.
|
|
53
|
+
'presence.update', // the full set of currently-present participants (a snapshot)
|
|
54
|
+
];
|
|
55
|
+
/** Kinds that close a run — exactly one is emitted per run. */
|
|
56
|
+
export const TERMINAL_RUN_EVENT_KINDS = ['run.completed', 'run.failed', 'run.cancelled'];
|
|
57
|
+
const TERMINAL_SET = new Set(TERMINAL_RUN_EVENT_KINDS);
|
|
58
|
+
/** True when `kind` is a terminal (run-closing) event kind. */
|
|
59
|
+
export function isTerminalRunEventKind(kind) {
|
|
60
|
+
return TERMINAL_SET.has(kind);
|
|
61
|
+
}
|
|
62
|
+
const KNOWN_SET = new Set(RUN_EVENT_KINDS);
|
|
63
|
+
/** True when `kind` is part of the canonical taxonomy. */
|
|
64
|
+
export function isKnownRunEventKind(kind) {
|
|
65
|
+
return KNOWN_SET.has(kind);
|
|
66
|
+
}
|
|
67
|
+
export const RUN_STREAM_CONFIG_DEFAULTS = {
|
|
68
|
+
heartbeatMs: 15_000,
|
|
69
|
+
maxReconnects: 8,
|
|
70
|
+
backoffMs: [250, 500, 1000, 2000, 4000, 8000, 16000, 30000],
|
|
71
|
+
stallTimeoutMs: 60_000,
|
|
72
|
+
throttleMs: 50,
|
|
73
|
+
journalRetentionHours: 24,
|
|
74
|
+
journalMaxEvents: 2000,
|
|
75
|
+
resumeWindowSeconds: 900,
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Pick the backoff delay (ms) for a given zero-based reconnect attempt,
|
|
79
|
+
* clamping to the last entry of the schedule. Shared by client + tests so the
|
|
80
|
+
* reconnect cadence is defined once.
|
|
81
|
+
*/
|
|
82
|
+
export function reconnectBackoffMs(attempt, schedule = RUN_STREAM_CONFIG_DEFAULTS.backoffMs) {
|
|
83
|
+
if (schedule.length === 0)
|
|
84
|
+
return 0;
|
|
85
|
+
const i = Math.max(0, Math.min(attempt, schedule.length - 1));
|
|
86
|
+
return schedule[i];
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=run-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-events.js","sourceRoot":"","sources":["../src/run-events.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B;;;;;;;;;;;;;GAaG;AAYH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa;IACb,eAAe;IACf,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,eAAe;IACf,wEAAwE;IACxE,iBAAiB,EAAG,+DAA+D;IACnF,aAAa,EAAO,uCAAuC;IAC3D,cAAc,EAAM,iEAAiE;IACrF,cAAc,EAAM,wDAAwD;IAC5E,iBAAiB,EAAG,yCAAyC;IAC7D,YAAY,EAAQ,4DAA4D;IAChF,mEAAmE;IACnE,kBAAkB,EAAE,2CAA2C;IAC/D,kBAAkB,EAAE,uDAAuD;IAC3E,kFAAkF;IAClF,kBAAkB,EAAG,mDAAmD;IACxE,mBAAmB,EAAE,sDAAsD;IAC3E,iEAAiE;IACjE,cAAc,EAAM,8DAA8D;IAClF,iBAAiB,EAAG,2DAA2D;IAC/E,WAAW,EAAS,8DAA8D;IAClF,sEAAsE;IACtE,6EAA6E;IAC7E,6EAA6E;IAC7E,6EAA6E;IAC7E,gEAAgE;IAChE,iBAAiB,EAAG,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1
|
+
import type { WeaveRuntime } from './runtime.js';
|
|
2
|
+
import type { RunEventEnvelope } from './run-events.js';
|
|
3
|
+
import type { RunEventCursor } from './runs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Journal defaults, derived from {@link RUN_STREAM_CONFIG_DEFAULTS} so retention
|
|
6
|
+
* and the per-run cap are defined exactly once. geneWeave's `run_stream_config`
|
|
7
|
+
* table (`journal_retention_hours` / `journal_max_events`) seeds from the same
|
|
8
|
+
* source — there is no second hardcoded copy.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RUN_JOURNAL_DEFAULTS: {
|
|
11
|
+
readonly retentionMs: number;
|
|
12
|
+
readonly maxEnvelopesPerRun: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Thrown by `readAfter` when the requested `afterSequence` is older than the
|
|
16
|
+
* oldest event still retained (the size cap or TTL pruned it). The consumer must
|
|
17
|
+
* recover by re-reading from the beginning (`afterSequence: -1`) — its prior
|
|
18
|
+
* cursor is unrecoverable. This is the "gap-safe resume" guarantee: a laggy
|
|
19
|
+
* client gets a loud, typed error instead of a silently-skipped event gap.
|
|
20
|
+
*/
|
|
21
|
+
export declare class RunCursorTooOldError extends Error {
|
|
22
|
+
readonly runId: string;
|
|
23
|
+
readonly requestedAfter: number;
|
|
24
|
+
readonly minRetainedSequence: number;
|
|
25
|
+
constructor(runId: string, requestedAfter: number, minRetainedSequence: number);
|
|
26
|
+
}
|
|
27
|
+
export interface RunJournalAppendOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Optimistic concurrency: if set, the append is rejected unless the run's
|
|
30
|
+
* current head sequence equals `expectedSequence - 1`. Adapters that derive
|
|
31
|
+
* the sequence server-side (like the SQL one) may ignore this.
|
|
32
|
+
*/
|
|
33
|
+
expectedSequence?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface RunJournalReadOptions {
|
|
36
|
+
/** Max events to return. Default 100. */
|
|
37
|
+
limit?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface RunJournal {
|
|
40
|
+
/**
|
|
41
|
+
* Append one event to a run's journal. Returns the assigned `sequence`.
|
|
42
|
+
* Implementations MUST keep the per-run sequence contiguous and monotonic.
|
|
43
|
+
*/
|
|
44
|
+
append(envelope: RunEventEnvelope, opts?: RunJournalAppendOptions): Promise<{
|
|
45
|
+
sequence: number;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Read events with `sequence > cursor.afterSequence`, ascending, up to `limit`.
|
|
49
|
+
* Throws {@link RunCursorTooOldError} when the cursor is below the retained
|
|
50
|
+
* watermark (gap-safe resume).
|
|
51
|
+
*/
|
|
52
|
+
readAfter(cursor: RunEventCursor, opts?: RunJournalReadOptions): Promise<RunEventEnvelope[]>;
|
|
53
|
+
/** Delete every journal entry for a run (e.g. after archival). */
|
|
54
|
+
purgeRun(runId: string): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface KvRunJournalOptions {
|
|
57
|
+
runtime?: WeaveRuntime;
|
|
58
|
+
/** KV namespace prefix. Default `'run-journal'`. */
|
|
59
|
+
namespace?: string;
|
|
60
|
+
/** Entry TTL in ms. Default {@link RUN_JOURNAL_DEFAULTS}.retentionMs (24h). */
|
|
61
|
+
retentionMs?: number;
|
|
62
|
+
/** Max envelopes retained per run. Default {@link RUN_JOURNAL_DEFAULTS}.maxEnvelopesPerRun (2000). */
|
|
63
|
+
maxEnvelopesPerRun?: number;
|
|
64
|
+
}
|
|
65
|
+
export declare function createKvRunJournal(opts?: KvRunJournalOptions): RunJournal;
|
|
66
|
+
//# sourceMappingURL=run-journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-journal.d.ts","sourceRoot":"","sources":["../src/run-journal.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run event journal — the canonical append-only run-event log contract.
|
|
3
|
+
*
|
|
4
|
+
* Collaboration Phase 0: this used to live in `@weaveintel/collaboration` as a
|
|
5
|
+
* second, parallel implementation of the run journal that geneWeave already had
|
|
6
|
+
* in SQL. The journal is *run-lifecycle substrate*, not a collaboration concern,
|
|
7
|
+
* and its vocabulary (`RunEventEnvelope`, `RunEventCursor`) already lives here —
|
|
8
|
+
* so the PORT (interface) + a reference KV adapter now live in `@weaveintel/core`,
|
|
9
|
+
* and geneWeave's SQL tables are just another adapter behind the same interface.
|
|
10
|
+
*
|
|
11
|
+
* --- For someone new to this ---
|
|
12
|
+
* A "journal" here is an append-only list of everything that happened during a
|
|
13
|
+
* run (each token, tool call, status change…), numbered 0, 1, 2, … A client that
|
|
14
|
+
* disconnects can reconnect and say "I last saw event 41 — give me everything
|
|
15
|
+
* after that" (`readAfter`), so it never misses or repeats an event. That single
|
|
16
|
+
* idea — a numbered, append-only log you can resume from — is what makes a live
|
|
17
|
+
* agent stream survive a dropped connection.
|
|
18
|
+
*
|
|
19
|
+
* Two implementations conform to the {@link RunJournal} port:
|
|
20
|
+
* - {@link createKvRunJournal} (here) — a key-value reference adapter, used by
|
|
21
|
+
* non-SQL hosts and as the fast in-memory test double.
|
|
22
|
+
* - geneWeave's `SqlRunJournal` — backed by the `user_run_events` table.
|
|
23
|
+
* Both are validated by the same {@link runJournalContract} conformance suite.
|
|
24
|
+
*
|
|
25
|
+
* Standards followed (see the mid-2026 research): per-run contiguous sequence,
|
|
26
|
+
* EXCLUSIVE cursor (`readAfter(N)` ⇒ events with `sequence > N`), retention +
|
|
27
|
+
* size cap, and — crucially — **gap-safe resume**: if a cursor falls below the
|
|
28
|
+
* oldest still-retained event (because the size cap pruned it), `readAfter`
|
|
29
|
+
* throws {@link RunCursorTooOldError} instead of silently skipping events.
|
|
30
|
+
*/
|
|
31
|
+
import { weaveInMemoryPersistence } from './runtime.js';
|
|
32
|
+
import { RUN_STREAM_CONFIG_DEFAULTS } from './run-events.js';
|
|
33
|
+
// ─── Defaults (ONE place — also seeds the geneWeave `run_stream_config` row) ────
|
|
34
|
+
/**
|
|
35
|
+
* Journal defaults, derived from {@link RUN_STREAM_CONFIG_DEFAULTS} so retention
|
|
36
|
+
* and the per-run cap are defined exactly once. geneWeave's `run_stream_config`
|
|
37
|
+
* table (`journal_retention_hours` / `journal_max_events`) seeds from the same
|
|
38
|
+
* source — there is no second hardcoded copy.
|
|
39
|
+
*/
|
|
40
|
+
export const RUN_JOURNAL_DEFAULTS = {
|
|
41
|
+
retentionMs: RUN_STREAM_CONFIG_DEFAULTS.journalRetentionHours * 60 * 60 * 1000,
|
|
42
|
+
maxEnvelopesPerRun: RUN_STREAM_CONFIG_DEFAULTS.journalMaxEvents,
|
|
43
|
+
};
|
|
44
|
+
// ─── Typed errors ──────────────────────────────────────────────────────────────
|
|
45
|
+
/**
|
|
46
|
+
* Thrown by `readAfter` when the requested `afterSequence` is older than the
|
|
47
|
+
* oldest event still retained (the size cap or TTL pruned it). The consumer must
|
|
48
|
+
* recover by re-reading from the beginning (`afterSequence: -1`) — its prior
|
|
49
|
+
* cursor is unrecoverable. This is the "gap-safe resume" guarantee: a laggy
|
|
50
|
+
* client gets a loud, typed error instead of a silently-skipped event gap.
|
|
51
|
+
*/
|
|
52
|
+
export class RunCursorTooOldError extends Error {
|
|
53
|
+
runId;
|
|
54
|
+
requestedAfter;
|
|
55
|
+
minRetainedSequence;
|
|
56
|
+
constructor(runId, requestedAfter, minRetainedSequence) {
|
|
57
|
+
super(`Run '${runId}' cursor too old: afterSequence ${requestedAfter} < oldest retained ${minRetainedSequence}. ` +
|
|
58
|
+
`Re-read from the beginning (afterSequence: -1).`);
|
|
59
|
+
this.name = 'RunCursorTooOldError';
|
|
60
|
+
this.runId = runId;
|
|
61
|
+
this.requestedAfter = requestedAfter;
|
|
62
|
+
this.minRetainedSequence = minRetainedSequence;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// ─── KV reference adapter ──────────────────────────────────────────────────────
|
|
66
|
+
function resolveKv(runtime) {
|
|
67
|
+
return runtime?.persistence?.kv ?? weaveInMemoryPersistence().kv;
|
|
68
|
+
}
|
|
69
|
+
/** Pad sequence to 10 digits so KV lexical order == ascending sequence order. */
|
|
70
|
+
function pad(seq) {
|
|
71
|
+
return seq.toString().padStart(10, '0');
|
|
72
|
+
}
|
|
73
|
+
export function createKvRunJournal(opts = {}) {
|
|
74
|
+
const kv = resolveKv(opts.runtime);
|
|
75
|
+
const ns = opts.namespace ?? 'run-journal';
|
|
76
|
+
const retentionMs = opts.retentionMs ?? RUN_JOURNAL_DEFAULTS.retentionMs;
|
|
77
|
+
const maxPerRun = opts.maxEnvelopesPerRun ?? RUN_JOURNAL_DEFAULTS.maxEnvelopesPerRun;
|
|
78
|
+
const key = (runId, seq) => `${ns}:${runId}:${pad(seq)}`;
|
|
79
|
+
const prefix = (runId) => `${ns}:${runId}:`;
|
|
80
|
+
/** The lowest sequence still retained for a run (the prune watermark), or -1. */
|
|
81
|
+
async function minRetained(runId) {
|
|
82
|
+
const all = await kv.list(prefix(runId));
|
|
83
|
+
if (all.length === 0)
|
|
84
|
+
return -1;
|
|
85
|
+
let min = Number.MAX_SAFE_INTEGER;
|
|
86
|
+
for (const e of all) {
|
|
87
|
+
try {
|
|
88
|
+
const seq = JSON.parse(e.value).sequence;
|
|
89
|
+
if (seq < min)
|
|
90
|
+
min = seq;
|
|
91
|
+
}
|
|
92
|
+
catch { /* skip corrupt */ }
|
|
93
|
+
}
|
|
94
|
+
return min === Number.MAX_SAFE_INTEGER ? -1 : min;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
async append(envelope, appendOpts) {
|
|
98
|
+
const { runId, sequence } = envelope;
|
|
99
|
+
if (appendOpts?.expectedSequence !== undefined && sequence !== appendOpts.expectedSequence) {
|
|
100
|
+
throw new Error(`Run '${runId}' sequence conflict: expected ${appendOpts.expectedSequence}, got ${sequence}`);
|
|
101
|
+
}
|
|
102
|
+
await kv.set(key(runId, sequence), JSON.stringify(envelope), { ttlMs: retentionMs });
|
|
103
|
+
// Size cap: prune the oldest entries past the per-run limit (best-effort —
|
|
104
|
+
// never fail the append). This is what can advance the retained watermark.
|
|
105
|
+
try {
|
|
106
|
+
const all = await kv.list(prefix(runId));
|
|
107
|
+
if (all.length > maxPerRun) {
|
|
108
|
+
for (const entry of all.slice(0, all.length - maxPerRun)) {
|
|
109
|
+
await kv.delete(entry.key);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch { /* best-effort prune */ }
|
|
114
|
+
return { sequence };
|
|
115
|
+
},
|
|
116
|
+
async readAfter(cursor, readOpts) {
|
|
117
|
+
const limit = readOpts?.limit ?? 100;
|
|
118
|
+
const all = await kv.list(prefix(cursor.runId));
|
|
119
|
+
// Gap-safe resume: if the caller's cursor is below the oldest retained
|
|
120
|
+
// event, the events between are gone — surface a typed error rather than
|
|
121
|
+
// silently returning a gap. (afterSequence < 0 == "from the beginning",
|
|
122
|
+
// always valid.)
|
|
123
|
+
if (cursor.afterSequence >= 0 && all.length > 0) {
|
|
124
|
+
const min = await minRetained(cursor.runId);
|
|
125
|
+
if (min > 0 && cursor.afterSequence < min - 1) {
|
|
126
|
+
throw new RunCursorTooOldError(cursor.runId, cursor.afterSequence, min);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const out = [];
|
|
130
|
+
for (const entry of all) {
|
|
131
|
+
try {
|
|
132
|
+
const env = JSON.parse(entry.value);
|
|
133
|
+
if (env.sequence > cursor.afterSequence)
|
|
134
|
+
out.push(env);
|
|
135
|
+
}
|
|
136
|
+
catch { /* skip corrupt */ }
|
|
137
|
+
if (out.length >= limit)
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return out.sort((a, b) => a.sequence - b.sequence);
|
|
141
|
+
},
|
|
142
|
+
async purgeRun(runId) {
|
|
143
|
+
const all = await kv.list(prefix(runId));
|
|
144
|
+
for (const entry of all) {
|
|
145
|
+
try {
|
|
146
|
+
await kv.delete(entry.key);
|
|
147
|
+
}
|
|
148
|
+
catch { /* best-effort */ }
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=run-journal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-journal.js","sourceRoot":"","sources":["../src/run-journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAG7D,mFAAmF;AAEnF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW,EAAE,0BAA0B,CAAC,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAC9E,kBAAkB,EAAE,0BAA0B,CAAC,gBAAgB;CACvD,CAAC;AAEX,kFAAkF;AAElF;;;;;;GAMG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,KAAK,CAAS;IACd,cAAc,CAAS;IACvB,mBAAmB,CAAS;IACrC,YAAY,KAAa,EAAE,cAAsB,EAAE,mBAA2B;QAC5E,KAAK,CACH,QAAQ,KAAK,mCAAmC,cAAc,sBAAsB,mBAAmB,IAAI;YACzG,iDAAiD,CACpD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;CACF;AA4CD,kFAAkF;AAElF,SAAS,SAAS,CAAC,OAAiC;IAClD,OAAO,OAAO,EAAE,WAAW,EAAE,EAAE,IAAI,wBAAwB,EAAE,CA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AAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACzC,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;gBACxB,IAAI,CAAC;oBAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { WeaveRuntime } from './runtime.js';
|
|
2
|
+
import type { RunHandle, RunStatus } from './runs.js';
|
|
3
|
+
import type { EventBus } from './events.js';
|
|
4
|
+
import type { ExecutionContext } from './context.js';
|
|
5
|
+
export interface RunListFilter {
|
|
6
|
+
status?: RunStatus[];
|
|
7
|
+
origin?: RunHandle['origin'][];
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RunRegistry {
|
|
11
|
+
/**
|
|
12
|
+
* Persist a new `RunHandle`. Asserts the handle's `tenantId` matches the
|
|
13
|
+
* calling context (no cross-tenant writes). Re-registering the same `runId`
|
|
14
|
+
* overwrites — callers own run-id uniqueness.
|
|
15
|
+
*/
|
|
16
|
+
register(ctx: ExecutionContext, handle: RunHandle): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Update status (and optionally progress/error) for an existing run.
|
|
19
|
+
* Idempotent per `(status, sequence)`; emits a lifecycle event on the bus.
|
|
20
|
+
* Throws if not found or cross-tenant.
|
|
21
|
+
*/
|
|
22
|
+
updateStatus(ctx: ExecutionContext, runId: string, status: RunStatus, opts?: {
|
|
23
|
+
progress?: number;
|
|
24
|
+
error?: {
|
|
25
|
+
code: string;
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
sequence?: number;
|
|
29
|
+
}): Promise<RunHandle>;
|
|
30
|
+
/** Retrieve one run (tenant-scoped). Returns null if not found. */
|
|
31
|
+
get(ctx: ExecutionContext, runId: string): Promise<RunHandle | null>;
|
|
32
|
+
/** List runs owned by `principalId` in the caller's tenant, newest first. */
|
|
33
|
+
listByPrincipal(ctx: ExecutionContext, principalId: string, filter?: RunListFilter): Promise<RunHandle[]>;
|
|
34
|
+
/** Advance the run's `lastSequence` watermark (the resume cursor). */
|
|
35
|
+
markSequence(ctx: ExecutionContext, runId: string, sequence: number): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export interface KvRunRegistryOptions {
|
|
38
|
+
runtime?: WeaveRuntime;
|
|
39
|
+
/** KV namespace prefix for run rows. Default `'run-registry'`. */
|
|
40
|
+
namespace?: string;
|
|
41
|
+
/** KV namespace prefix for idempotency records. Default `'run-idempotency'`. */
|
|
42
|
+
idempotencyNamespace?: string;
|
|
43
|
+
/** TTL for idempotency records, ms. Default 5 minutes. */
|
|
44
|
+
idempotencyTtlMs?: number;
|
|
45
|
+
/** Optional bus — lifecycle events are emitted when provided. */
|
|
46
|
+
bus?: EventBus;
|
|
47
|
+
}
|
|
48
|
+
export declare function createKvRunRegistry(opts?: KvRunRegistryOptions): RunRegistry;
|
|
49
|
+
//# sourceMappingURL=run-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-registry.d.ts","sourceRoot":"","sources":["../src/run-registry.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;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