@ixo/editor 5.39.0 → 6.0.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.
@@ -1,7 +1,7 @@
1
- import { a5 as ActionDefinition, a6 as ActionEventDefinition, a7 as OutputSchemaField, a8 as ActionServices, a9 as CompiledBlock, v as CompiledFlow, aa as CompiledEdge, Z as FlowAgentCommand, $ as FlowAgentContext, _ as FlowAgentCommandResult, a0 as FlowAgentExecutor, a2 as FlowAgentNodeSnapshot, ab as FlowAgentBlockerCause, a3 as FlowAgentPublicNodeState } from '../store-B-2A-Tlv.js';
2
- export { am as AcquireFlowAgentLeaseParams, ad as ActionContext, ae as ActionResult, aA as ActorConstraint, A as AuthorizationResult, B as BaseUcanFlow, X as BuildFlowAgentContextParams, aD as CompiledFlowNode, C as CompilerRegistry, az as ConditionRef, an as CreateAgentCommandParams, ao as EvaluateFlowAgentPolicyParams, E as ExecuteNodeParams, f as ExecutionContext, d as ExecutionOutcome, Y as FlowAgentActor, ar as FlowAgentCommandBase, as as FlowAgentCommandStatus, at as FlowAgentCommandType, a1 as FlowAgentLease, au as FlowAgentLedgerEvent, av as FlowAgentLedgerEventType, aw as FlowAgentMaps, ap as FlowAgentOrchestratorOptions, ax as FlowAgentPolicyDecision, ay as FlowAgentRunPhase, x as FlowAgentService, aq as FlowAgentServiceOptions, a4 as FlowAgentTickResult, u as FlowCapability, F as FlowRuntimeStateManager, w as FlowStrategy, M as MergeResult, N as NodeActionResult, R as ReadFlowOptions, q as ReadFlowResult, aC as RuntimeRef, S as SetupFlowOptions, p as SetupFlowResult, aB as TTLConstraint, aE as TriggerSpec, y as acquireFlowAgentLease, z as appendAgentLedgerEvent, a as buildAuthzFromProps, D as buildFlowAgentContext, b as buildFlowNodeFromBlock, af as canMatches, G as cleanupExpiredFlowAgentLeases, ac as clearRuntimeForTemplateClone, l as compileBaseUcanFlow, ag as computeAgentCommandId, H as createAgentCommand, c as createRuntimeStateManager, o as decompileToBaseUcanFlow, I as evaluateFlowAgentPolicy, e as executeNode, J as executeQueuedAgentCommands, k as getActiveEditor, K as getFlowAgentMaps, i as isAuthorized, ah as isCapabilityMatch, ai as isExternalMutation, aF as isRuntimeRef, n as mergeCompiledFlows, L as planRalphLoopCommands, O as queueAgentCommand, P as readAgentLedgerEvents, m as readCompiledFlowFromYDoc, h as readFlow, r as readFlowAsBaseUcan, g as readFlowFromEditor, Q as readQueuedAgentCommands, T as releaseFlowAgentLease, aj as requiredCapabilityForCommand, ak as resourceMatches, j as setActiveEditor, s as setupFlowFromBaseUcan, U as tickFlowAgent, al as updateAgentCommand, V as validateAgentCommand, W as validateFlowAgentLease } from '../store-B-2A-Tlv.js';
3
- import { a4 as IxoEditorType, a5 as FlowNodeRuntimeState, f as UcanService, U as UcanDelegationStore, S as StoredDelegation, I as InvocationStore, a6 as FlowMetadata, a7 as FlowNode } from '../index-B4Qe8xbv.js';
4
- export { af as ActionReadBackMetadata, a9 as ClaimCollectionURI, am as CreateDelegationParams, an as CreateInvocationParams, al as CreateRootDelegationParams, a8 as DID, D as DelegationChainValidationResult, k as DelegationGrant, aa as EvaluationStatus, aj as ExecutionWithInvocationResult, ak as FindProofsResult, ac as FlowNodeAuthzExtension, ag as FlowNodeBase, ah as InvocationRequest, ai as InvocationResult, ab as LinkedClaim, ad as NodeState, ae as ReadBackTerminalState, j as StoredInvocation, i as UcanCapability, g as UcanServiceConfig, h as UcanServiceHandlers, b as createInvocationStore, d as createMemoryInvocationStore, a as createMemoryUcanDelegationStore, c as createUcanDelegationStore, e as createUcanService } from '../index-B4Qe8xbv.js';
1
+ import { a5 as ActionDefinition, a6 as ActionEventDefinition, a7 as OutputSchemaField, a8 as ActionServices, a9 as ActionProofDeclaration, aa as RunRecordDetails, ab as CompiledBlock, v as CompiledFlow, ac as CompiledEdge, Z as FlowAgentCommand, $ as FlowAgentContext, ad as ActionHandlers, _ as FlowAgentCommandResult, a0 as FlowAgentExecutor, a2 as FlowAgentNodeSnapshot, ae as FlowAgentBlockerCause, a3 as FlowAgentPublicNodeState } from '../store-C_KCYNzv.js';
2
+ export { aP as AcquireFlowAgentLeaseParams, ag as ActionContext, at as ActionResult, b1 as ActorConstraint, A as AuthorizationResult, B as BaseUcanFlow, ak as BidService, X as BuildFlowAgentContextParams, ar as CarbonService, al as ClaimService, am as CollectionService, an as CollectionUsersService, b4 as CompiledFlowNode, C as CompilerRegistry, b0 as ConditionRef, aQ as CreateAgentCommandParams, ai as EmailService, as as EntityService, aR as EvaluateFlowAgentPolicyParams, E as ExecuteNodeParams, f as ExecutionContext, d as ExecutionOutcome, aH as FailedListenerRun, Y as FlowAgentActor, aU as FlowAgentCommandBase, aV as FlowAgentCommandStatus, aW as FlowAgentCommandType, a1 as FlowAgentLease, aX as FlowAgentLedgerEvent, aY as FlowAgentLedgerEventType, aZ as FlowAgentMaps, aS as FlowAgentOrchestratorOptions, a_ as FlowAgentPolicyDecision, a$ as FlowAgentRunPhase, x as FlowAgentService, aT as FlowAgentServiceOptions, a4 as FlowAgentTickResult, u as FlowCapability, F as FlowRuntimeStateManager, w as FlowStrategy, ah as HttpService, ap as IntegrationsService, ao as MatrixCredentialService, M as MergeResult, N as NodeActionResult, aj as NotifyService, aq as OracleService, aG as PendingInvocation, aF as RUN_RECORD_AUDIT_TYPE, R as ReadFlowOptions, q as ReadFlowResult, b3 as RuntimeRef, S as SetupFlowOptions, p as SetupFlowResult, b2 as TTLConstraint, b5 as TriggerSpec, y as acquireFlowAgentLease, z as appendAgentLedgerEvent, au as appendRunRecord, a as buildAuthzFromProps, D as buildFlowAgentContext, b as buildFlowNodeFromBlock, aI as canMatches, G as cleanupExpiredFlowAgentLeases, af as clearRuntimeForTemplateClone, l as compileBaseUcanFlow, aJ as computeAgentCommandId, aE as computePendingInvocationId, H as createAgentCommand, c as createRuntimeStateManager, o as decompileToBaseUcanFlow, I as evaluateFlowAgentPolicy, e as executeNode, J as executeQueuedAgentCommands, aB as findFailedListenersForSourceRun, k as getActiveEditor, K as getFlowAgentMaps, ax as getOrCreateBlockPendingMap, aw as getPendingInvocationsMap, i as isAuthorized, aK as isCapabilityMatch, aL as isExternalMutation, b6 as isRuntimeRef, n as mergeCompiledFlows, L as planRalphLoopCommands, O as queueAgentCommand, az as queuePendingInvocation, P as readAgentLedgerEvents, m as readCompiledFlowFromYDoc, h as readFlow, r as readFlowAsBaseUcan, g as readFlowFromEditor, ay as readPendingInvocations, Q as readQueuedAgentCommands, av as readRunRecords, T as releaseFlowAgentLease, aA as removePendingInvocation, aC as replayFailedListenerRun, aM as requiredCapabilityForCommand, aN as resourceMatches, j as setActiveEditor, s as setupFlowFromBaseUcan, aD as snapshotInputRefs, U as tickFlowAgent, aO as updateAgentCommand, V as validateAgentCommand, W as validateFlowAgentLease } from '../store-C_KCYNzv.js';
3
+ import { a4 as FlowNodeRuntimeState, j as StoredInvocation, a5 as IxoEditorType, f as UcanService, U as UcanDelegationStore, S as StoredDelegation, I as InvocationStore, a6 as FlowMetadata, a7 as FlowNode } from '../index-DL8Yh3Xu.js';
4
+ export { af as ActionReadBackMetadata, a9 as ClaimCollectionURI, am as CreateDelegationParams, an as CreateInvocationParams, al as CreateRootDelegationParams, a8 as DID, D as DelegationChainValidationResult, k as DelegationGrant, aa as EvaluationStatus, aj as ExecutionWithInvocationResult, ak as FindProofsResult, ac as FlowNodeAuthzExtension, ag as FlowNodeBase, ah as InvocationRequest, ai as InvocationResult, ab as LinkedClaim, ad as NodeState, ae as ReadBackTerminalState, i as UcanCapability, g as UcanServiceConfig, h as UcanServiceHandlers, b as createInvocationStore, d as createMemoryInvocationStore, a as createMemoryUcanDelegationStore, c as createUcanDelegationStore, e as createUcanService } from '../index-DL8Yh3Xu.js';
5
5
  import * as Y from 'yjs';
6
6
  import { Doc } from 'yjs';
7
7
  import 'matrix-js-sdk';
@@ -9,9 +9,21 @@ import '@blocknote/core';
9
9
  import 'react';
10
10
  import '@ixo/ucan';
11
11
 
12
+ /** Stable name of the universal completion event every step emits. */
13
+ declare const STEP_COMPLETED_EVENT_NAME = "step.completed";
14
+ /**
15
+ * The universal completion event. Every step emits this when it completes, on
16
+ * top of whatever domain events its action declares. It exists so that:
17
+ * - any step can be sequenced off a predecessor ("run after X") via a
18
+ * `(X, step.completed)` trigger, regardless of the source action's events;
19
+ * - every completion is auditable (a run record is always written).
20
+ */
21
+ declare const STEP_COMPLETED_EVENT: ActionEventDefinition;
12
22
  declare function registerAction<TInputs extends Record<string, any> = Record<string, any>>(definition: ActionDefinition<TInputs>): void;
13
23
  declare function getAction(type: string): ActionDefinition | undefined;
14
24
  declare function getAllActions(): ActionDefinition[];
25
+ /** All (alias → canonical type) pairs, for manifest generation and consistency checks. */
26
+ declare function getAliasEntries(): Array<[string, string]>;
15
27
  declare function hasAction(type: string): boolean;
16
28
  /** Look up an action by its UCAN `can` ability string, e.g., "bid/submit". */
17
29
  declare function getActionByCan(can: string): ActionDefinition | undefined;
@@ -36,6 +48,54 @@ declare function getEventsForBlock(action: ActionDefinition | undefined, inputs:
36
48
  */
37
49
  declare function getOutputSchemaForBlock(action: ActionDefinition | undefined, inputs: unknown): OutputSchemaField[];
38
50
 
51
+ /**
52
+ * Serializable proof declaration: custom `validate` functions can't cross a
53
+ * JSON boundary, so they are represented as `{ kind: 'custom' }` — consumers
54
+ * know a proof exists and is enforced kernel-side, without its logic.
55
+ */
56
+ type ManifestProofDeclaration = {
57
+ kind: 'none';
58
+ } | {
59
+ kind: 'fields';
60
+ fields: string[];
61
+ } | {
62
+ kind: 'custom';
63
+ };
64
+ interface ActionManifestEntry {
65
+ type: string;
66
+ /** Legacy names that resolve to this canonical type. */
67
+ aliases: string[];
68
+ can?: string;
69
+ sideEffect: boolean;
70
+ defaultRequiresConfirmation: boolean;
71
+ requiredCapability?: string;
72
+ proof: ManifestProofDeclaration;
73
+ /** JSON Schema for the action's inputs, when declared. */
74
+ inputSchema?: object;
75
+ /** Static output schema. Actions with dynamic schemas also set hasDynamicOutputSchema. */
76
+ outputSchema?: OutputSchemaField[];
77
+ /** Static event vocabulary. Actions with dynamic events also set hasDynamicEvents. */
78
+ events?: Array<Pick<ActionEventDefinition, 'name' | 'displayName' | 'description' | 'payloadSchema'>>;
79
+ hasDynamicEvents: boolean;
80
+ hasDynamicOutputSchema: boolean;
81
+ eligibleForEventTrigger: boolean;
82
+ }
83
+ interface ActionManifest {
84
+ /** Schema version of the manifest format itself. */
85
+ manifestVersion: '1';
86
+ actions: ActionManifestEntry[];
87
+ }
88
+ /**
89
+ * Generate the machine-readable action contract from the live registry.
90
+ *
91
+ * This is the single artifact external actors (the flow-manager oracle,
92
+ * third-party agentic Oracle actors) implement against, replacing
93
+ * hand-maintained copies of input contracts. It is emitted to
94
+ * `dist/action-manifest.json` at build time and also callable at runtime
95
+ * from `@ixo/editor/core`.
96
+ */
97
+ declare function generateActionManifest(): ActionManifest;
98
+
39
99
  /**
40
100
  * Bidirectional mapping between UCAN `can` vocabulary and registry `type` strings.
41
101
  * Derived mechanically: strip "qi/", replace "." with "/".
@@ -50,13 +110,6 @@ declare function getAllCanMappings(): ReadonlyArray<{
50
110
  type: string;
51
111
  }>;
52
112
 
53
- /**
54
- * Builds an ActionServices map from BlocknoteHandlers.
55
- * Used by block components to bridge existing DI into registry calls.
56
- *
57
- * The handlers parameter is typed as `any` to avoid a circular dependency
58
- * between core and mantine layers — BlocknoteHandlers is defined in mantine/context.
59
- */
60
113
  declare function buildServicesFromHandlers(handlers: any): ActionServices;
61
114
 
62
115
  /**
@@ -100,249 +153,68 @@ interface TriggerResolutionContext {
100
153
  */
101
154
  declare function resolveRuntimeRefs(nb: Record<string, unknown>, getNodeOutput: (nodeId: string) => Record<string, unknown> | undefined, triggerContext?: TriggerResolutionContext): Record<string, unknown>;
102
155
 
103
- /**
104
- * Run record stored in the audit trail as `type: 'block.run'`.
105
- *
106
- * Per Phase 0 #2 (eng review pass 2), run records are NOT a parallel
107
- * `_yRunHistory` structure — they ride on the existing `auditTrail` Y.Map
108
- * via `useAuditTrail.addEvent`. The shape below is what goes into the
109
- * audit trail event's `details` field.
110
- *
111
- * See `docs/events-and-triggers-plan.md` §3.4, §18, §19.
112
- */
113
- interface RunRecordDetails {
114
- /** Stable identifier for this run, deterministic from invocation context. */
115
- runId: string;
116
- /** Action's output. */
117
- output: Record<string, unknown>;
118
- /**
119
- * Events the action emitted on this run. Persisted as part of the run
120
- * record so the reconciliation loop can process them idempotently — even
121
- * across page refreshes and across multiple clients.
122
- */
123
- events: Array<{
124
- name: string;
125
- payload: Record<string, unknown>;
126
- }>;
127
- /** ISO timestamp when the action started. */
128
- startedAt: string;
129
- /** ISO timestamp when the action completed (success or failure). */
130
- completedAt: string;
131
- /** DID of the actor who signed the invocation that produced this run. */
132
- actorDid: string;
133
- /** UCAN invocation CID when execution produced one. */
134
- invocationCid?: string;
135
- /** Capability/proof CID used when no invocation CID was produced. */
136
- capabilityId?: string;
137
- /** Optional error if the run failed. */
138
- error?: {
139
- message: string;
140
- code?: string;
141
- };
142
- /** External read-back metadata associated with this run or reconciliation. */
143
- readBack?: Record<string, unknown>;
144
- /** True when this audit entry was written by external read-back reconciliation. */
145
- reconciled?: boolean;
146
- /**
147
- * If this run was triggered by a pending invocation (i.e. it's a listener
148
- * run), the id of that pending invocation. Used to dedup replays and trace
149
- * causality back through `triggeredBy`.
150
- */
151
- fromPendingInvocationId?: string;
152
- /**
153
- * If this run is a listener run, the (sourceBlockId, eventName) that
154
- * caused it. Used by the failure visibility surface to attribute failures
155
- * back to the source block (CP-1).
156
- */
157
- triggeredBy?: {
158
- sourceBlockId: string;
159
- eventName: string;
160
- };
161
- /** Source run id for listener runs, stored explicitly for failure lookups. */
162
- sourceRunId?: string;
156
+ declare const PROOF_MISSING_CODE = "PROOF_MISSING";
157
+ interface ProofValidationResult {
158
+ valid: boolean;
159
+ reason?: string;
163
160
  }
164
- declare const RUN_RECORD_AUDIT_TYPE = "block.run";
165
161
  /**
166
- * Pending invocation queued on a listener block.
167
- *
168
- * Stored in `_yPendingInvocations: Y.Map<blockId, Y.Map<id, PendingInvocation>>`.
162
+ * Validate a successful action run's output against the action's proof
163
+ * declaration. Called by `executeActionBlock` before writing
164
+ * `state: 'completed'` — success without proof becomes a failure.
169
165
  *
170
- * The id is deterministic derived from
171
- * `(sourceBlockId, sourceRunId, listenerBlockId, eventName, eventIndex)`
172
- * so the reconciliation loop can run idempotently from multiple clients
173
- * without producing duplicates.
174
- *
175
- * See `docs/events-and-triggers-plan.md` §3.4, §3.5.1, §18.
166
+ * A `sideEffect: true` action with no declaration fails closed; a
167
+ * side-effect-free action with no declaration is tolerated (legacy
168
+ * consumer-registered actions) but should declare `'none'` explicitly.
176
169
  */
177
- interface PendingInvocation {
178
- /** Deterministic id, see `computePendingInvocationId`. */
179
- id: string;
180
- /** Block that emitted the event. */
181
- triggeringBlockId: string;
182
- /** Run id of the triggering source run, used for the deterministic id. */
183
- sourceRunId: string;
184
- /** Event name from the source action's vocabulary. */
185
- eventName: string;
186
- /** Event index within the source run's `events` array (a single run can emit multiple). */
187
- eventIndex: number;
188
- /**
189
- * The frozen event payload, captured by value at emission time. The
190
- * assignee invokes the listener against this payload, not against the
191
- * source block's current state. This is the property that makes the
192
- * Sally → Mike scenario produce 10 distinct emails even when Mike acts
193
- * on them all hours later.
194
- */
195
- payload: Record<string, unknown>;
196
- /**
197
- * Snapshots of `nodeId.output.*` ref values that the listener's inputs
198
- * reference, captured at queue time. Keyed by the full ref string.
199
- *
200
- * §3.5.1: ref snapshots are the load-bearing fix for the lag-time
201
- * overwrite scenario. If a listener references a non-trigger block's
202
- * output (e.g. `evaluateBlock.output.claimId`), that value is captured
203
- * here at queue time. Resolution at invocation time prefers the snapshot
204
- * over current state, so multiple queued invocations don't drift when
205
- * the source re-runs.
206
- */
207
- refSnapshots: Record<string, unknown>;
208
- /** DID of the assigned actor who must invoke this listener. Resolved from `props.assignment.assignedActor.did`. */
209
- assigneeDid: string;
210
- /** ISO timestamp when the source emission happened. */
211
- emittedAt: string;
212
- /** ISO timestamp after which this pending invocation is considered expired. Resolved from `FlowCapability.ttl` at queue time. */
213
- expiresAt: string;
170
+ declare function validateActionProof(action: Pick<ActionDefinition, 'type' | 'sideEffect'> & {
171
+ proof?: ActionProofDeclaration;
172
+ }, output: Record<string, unknown>): ProofValidationResult;
173
+
174
+ type CompletionVerificationStatus = 'verified' | 'unverified' | 'not_completed';
175
+ interface CompletionVerification {
176
+ status: CompletionVerificationStatus;
177
+ /** Populated when status is 'unverified'. */
178
+ reason?: string;
214
179
  }
215
- /**
216
- * Compute a deterministic id for a pending invocation from its content.
217
- *
218
- * The same (sourceBlockId, sourceRunId, listenerBlockId, eventName,
219
- * eventIndex) tuple always produces the same id. This is the property that
220
- * makes the reconciliation loop idempotent re-running it from a different
221
- * client, or after a page refresh, produces the same `Y.Map.set` operation
222
- * with the same key, which Yjs converges to a single entry.
223
- *
224
- * Implementation: simple deterministic string concatenation, hashed via a
225
- * 32-bit FNV-1a. The id is short and stable; collision risk within a single
226
- * flow is negligible because the inputs are scoped (block ids are unique
227
- * within a flow, run ids are unique within a block).
228
- */
229
- declare function computePendingInvocationId(args: {
230
- sourceBlockId: string;
231
- sourceRunId: string;
232
- listenerBlockId: string;
233
- eventName: string;
234
- eventIndex: number;
235
- }): string;
236
- /**
237
- * Walk an inputs object and collect every RuntimeRef of the form
238
- * `nodeId.output.fieldPath`. Returns a map of `{refString: resolvedValue}`
239
- * suitable for storing as `PendingInvocation.refSnapshots`.
240
- *
241
- * The walker mirrors `resolveRuntimeRefs` in `flowCompiler/resolveRefs.ts`
242
- * but reads instead of resolving — it captures the current value of each
243
- * ref so the listener can later resolve against the snapshot rather than
244
- * against current state.
245
- *
246
- * See `docs/events-and-triggers-plan.md` §3.5.1.
247
- */
248
- declare function snapshotInputRefs(inputs: unknown, getNodeOutput: (nodeId: string) => Record<string, unknown> | undefined): Record<string, unknown>;
249
- /**
250
- * Get the top-level pending invocations Y.Map from the editor's yDoc.
251
- * Lazily creates it if missing.
252
- *
253
- * Shape: `Y.Map<blockId, Y.Map<pendingInvocationId, PendingInvocation>>`.
254
- * The outer map is keyed by listener block id; the inner map is keyed by
255
- * deterministic pending invocation id (see `computePendingInvocationId`).
256
- */
257
- declare function getPendingInvocationsMap(yDoc: Y.Doc): Y.Map<Y.Map<unknown>>;
258
- /**
259
- * Get the inner pending-invocations map for a specific listener block.
260
- * Lazily creates it if missing. Caller is responsible for being inside a
261
- * Yjs transaction if atomic creation matters.
262
- */
263
- declare function getOrCreateBlockPendingMap(yDoc: Y.Doc, blockId: string): Y.Map<unknown>;
264
- /**
265
- * Read all pending invocations for a block as plain JS objects.
266
- * Returns an array sorted by `emittedAt` ascending (oldest first).
267
- */
268
- declare function readPendingInvocations(yDoc: Y.Doc, blockId: string): PendingInvocation[];
269
- /**
270
- * Idempotently write a pending invocation under its deterministic id.
271
- *
272
- * Returns true if a new entry was created, false if the id already
273
- * existed (meaning another client or a previous reconciliation pass
274
- * already queued this invocation). This is the property that makes
275
- * `reconcilePendingInvocations` safe to run from multiple clients
276
- * simultaneously and across page refreshes — see plan §18.
277
- *
278
- * Wraps the write in a Yjs transaction so the existence check and the
279
- * subsequent set are atomic from the local client's perspective. Concurrent
280
- * clients each computing the same id will all converge to a single entry
281
- * because Y.Map.set with the same key is last-writer-wins on identical
282
- * content.
283
- */
284
- declare function queuePendingInvocation(yDoc: Y.Doc, listenerBlockId: string, invocation: PendingInvocation): boolean;
285
- /**
286
- * Remove a pending invocation by id. Used when the assignee completes the
287
- * invocation (transitioning to a `block.run` audit trail entry) or when
288
- * the expiration sweep marks it as expired.
289
- */
290
- declare function removePendingInvocation(yDoc: Y.Doc, listenerBlockId: string, pendingInvocationId: string): boolean;
291
- /**
292
- * Append a run record to the audit trail for a block. Run records are
293
- * stored as audit trail events with `type: 'block.run'` and the structured
294
- * data in `details`. Per Phase 0 #2 of eng review pass 2, this avoids
295
- * inventing a parallel `_yRunHistory` storage system.
296
- *
297
- * Y.Array.push from concurrent clients merges correctly — verified by the
298
- * existing `useAuditTrail` shipping in production.
299
- */
300
- declare function appendRunRecord(yDoc: Y.Doc, blockId: string, details: RunRecordDetails, userId: string): void;
301
- /**
302
- * Read all run records for a block from the audit trail. Filters audit
303
- * trail entries to only those with `type: 'block.run'`.
304
- */
305
- declare function readRunRecords(yDoc: Y.Doc, blockId: string): RunRecordDetails[];
306
- /**
307
- * A failed listener run, attributed to the source block emission that
308
- * triggered it. Used by the failure visibility surface (CP-1) on source
309
- * blocks: the source block can show "N listeners failed for your last run".
310
- */
311
- interface FailedListenerRun {
312
- /** Block id of the listener whose run failed. */
313
- listenerBlockId: string;
314
- /** The full RunRecordDetails of the failed listener invocation. */
315
- record: RunRecordDetails;
180
+ interface VerifyCompletionParams {
181
+ runtime: FlowNodeRuntimeState | undefined | null;
182
+ blockId: string;
183
+ /** Action type of the block, used to re-check the proof declaration. */
184
+ actionType?: string;
185
+ /** Invocation lookup, typically backed by the doc's `invocations` Y.Map. */
186
+ getInvocation?: (cid: string) => StoredInvocation | undefined | null;
187
+ /** Flow schema version; UCAN binding is only required when the version policy demands it. */
188
+ schemaVersion?: string;
316
189
  }
317
190
  /**
318
- * Find all failed listener runs that were triggered by a specific source
319
- * block run. Walks every block's audit trail, filters to listener runs
320
- * triggered by (sourceBlockId, sourceRunId), and returns the ones with an
321
- * error set.
322
- *
323
- * Used by the source block UI to show a failure badge linked to a specific
324
- * run if Sally evaluates 10 claims and 2 of Mike's emails fail, Sally
325
- * sees "2 failed listeners on claim-G" rather than discovering it days
326
- * later in the email service logs.
327
- */
328
- declare function findFailedListenersForSourceRun(yDoc: Y.Doc, sourceBlockId: string, sourceRunId: string, listenerBlockIds: string[]): FailedListenerRun[];
329
- /**
330
- * Replay a previously failed listener run by re-queueing a pending
331
- * invocation with the same content. Reuses the original frozen payload
332
- * and ref snapshots from the failed run record's audit trail entry, so the
333
- * replay sees exactly the same data the original invocation saw.
334
- *
335
- * CP-2 from the plan. Used by the replay button in the failure visibility
336
- * surface. Returns true if a new pending invocation was queued.
337
- *
338
- * Note: replay does NOT re-derive the deterministic id from the original
339
- * source emission, because the original pending invocation's id is already
340
- * present (or removed) in the pendingInvocations Y.Map. Instead, replay
341
- * generates a fresh id by appending a `:replay-N` suffix to the original.
342
- * This means the replay creates a NEW pending invocation that the assignee
343
- * can act on, separate from any history of the original.
344
- */
345
- declare function replayFailedListenerRun(yDoc: Y.Doc, failedRecord: RunRecordDetails, listenerBlockId: string, originalPayload: Record<string, unknown>, originalRefSnapshots: Record<string, unknown>, assigneeDid: string): boolean;
191
+ * Decide whether a block's `state: 'completed'` can be trusted.
192
+ *
193
+ * Anyone with room write access can set `completed` directly in the runtime
194
+ * Y.Map — a completion is only *verified* when it carries the evidence the
195
+ * execution kernel writes:
196
+ *
197
+ * 1. Proof of execution per the action's `proof` declaration (all versions).
198
+ * 2. On UCAN-enforced flows (policy.ucanRequired), a `lastInvocationCid`
199
+ * that resolves in the invocation store to a successful invocation for
200
+ * this block.
201
+ *
202
+ * The invocation check is store-level PRESENCE, not a cryptographic
203
+ * re-verification of the CAR bytes: signatures are validated when the
204
+ * invocation is minted, but the `invocations` Y.Map is room-writable, so a
205
+ * member with write access can forge a matching `{ result: 'success', blockId }`
206
+ * entry and pass this check. This raises the bar (a completion must at least
207
+ * reference a resolvable, successful, block-matching invocation) but does NOT
208
+ * make completions unforgeable that needs read-time CAR-signature
209
+ * re-verification against the delegation chain (open trust-model decision, H3).
210
+ * Do not describe a completion that passes here as "impossible to forge".
211
+ *
212
+ * Consumers gate on this instead of raw `state === 'completed'`:
213
+ * trigger reconciliation (event sources), flow-agent planning (Done
214
+ * classification), and the FlowView completion badge.
215
+ */
216
+ declare function verifyCompletion(params: VerifyCompletionParams): CompletionVerification;
217
+ declare function isVerifiedCompletion(params: VerifyCompletionParams): boolean;
346
218
 
347
219
  declare function reconcilePendingInvocations(editor: IxoEditorType): void;
348
220
  declare function getActionForBlock(block: any): ReturnType<typeof getAction>;
@@ -361,6 +233,62 @@ declare function writeRunRecordAndReconcile(editor: IxoEditorType, blockId: stri
361
233
  sourceRunId?: string;
362
234
  }): void;
363
235
 
236
+ /**
237
+ * Flow Version Manifest
238
+ *
239
+ * Single source of truth for what each schema version requires.
240
+ * Blocks and components read policy hints rather than checking version strings directly.
241
+ */
242
+ type FlowVersionString = '0.3' | '1.0.0';
243
+ interface VersionPolicyUi {
244
+ /** Show the delegation management panel in block config */
245
+ showDelegationPanel: boolean;
246
+ /** Show the whitelist (specific actors) option in authorization config */
247
+ showWhitelistConfig: boolean;
248
+ /** Show the "anyone with flow access" option in authorization config */
249
+ showAnyoneConfig: boolean;
250
+ /** Show a banner when a newer version is available */
251
+ showMigrationBanner: boolean;
252
+ /** Require PIN entry for block execution (invocation signing) */
253
+ requirePinForExecution: boolean;
254
+ }
255
+ interface VersionPolicy {
256
+ /** Semver-style version identifier */
257
+ version: FlowVersionString;
258
+ /** Human-readable label */
259
+ label: string;
260
+ /** Whether UCAN delegation chains are required for all executions */
261
+ ucanRequired: boolean;
262
+ /** Whether a root delegation must exist before any execution */
263
+ delegationRootRequired: boolean;
264
+ /** Whether whitelist-only authorization (no parentCapability) is acceptable */
265
+ whitelistOnlyAllowed: boolean;
266
+ /** Whether unrestricted access (no authorisedActors, no parentCapability) is acceptable */
267
+ unrestrictedAllowed: boolean;
268
+ /** Which execution path to use */
269
+ executionPath: 'legacy' | 'invocation';
270
+ /** Which authorization function to use */
271
+ authorizationFn: 'v1' | 'v2';
272
+ /** Allowed authorization modes in the UI */
273
+ allowedAuthModes: Array<'anyone' | 'actors' | 'capability'>;
274
+ /** UI rendering hints — blocks query these instead of checking version strings */
275
+ ui: VersionPolicyUi;
276
+ /** Human-readable description of this version */
277
+ description: string;
278
+ }
279
+ declare const VERSION_MANIFEST: Record<FlowVersionString, VersionPolicy>;
280
+ /** The version stamped on newly created flows */
281
+ declare const LATEST_VERSION: FlowVersionString;
282
+ /**
283
+ * Get the policy for a given schema version.
284
+ * Unknown versions fall back to the strictest (latest) policy.
285
+ */
286
+ declare function getVersionPolicy(version: string): VersionPolicy;
287
+ /**
288
+ * Check whether `current` is at least `minimum` in the migration path.
289
+ */
290
+ declare function isVersionAtLeast(current: string, minimum: FlowVersionString): boolean;
291
+
364
292
  /**
365
293
  * Writes compiled blocks into BlockNote's collaborative XmlFragment using the
366
294
  * ProseMirror/Yjs structure that BlockNote reads from collaboration.
@@ -562,7 +490,7 @@ interface ExecuteFlowAgentCoreCommandOptions {
562
490
  actorType: 'entity' | 'user';
563
491
  entityRoomId?: string;
564
492
  actionServices?: ActionServices;
565
- actionHandlers?: unknown;
493
+ actionHandlers?: ActionHandlers;
566
494
  delegationStore?: UcanDelegationStore;
567
495
  delegations?: StoredDelegation[];
568
496
  invocationStore?: InvocationStore;
@@ -583,10 +511,25 @@ interface ClassifyNodeStateInput {
583
511
  runtime: FlowNodeRuntimeState;
584
512
  now: number;
585
513
  pendingInvocationCount?: number;
514
+ /**
515
+ * Verification of a `completed` runtime entry (see
516
+ * `flowEngine/verifiedCompletion.ts`). When provided and 'unverified', the
517
+ * node classifies as Blocked instead of Done — the planner must not advance
518
+ * past a completion that lacks proof or a valid invocation. Omitted ⇒
519
+ * legacy behavior (completed = Done).
520
+ */
521
+ completionVerification?: CompletionVerification;
522
+ /**
523
+ * Whether this block's action is a repeatable ('many') capability. A
524
+ * repeatable block that has fired (`completed`) is classified 'Active', not
525
+ * 'Done' — it is a standing capability, never a finished task. See
526
+ * `ActionDefinition.cardinality`.
527
+ */
528
+ isRepeatable?: boolean;
586
529
  }
587
530
  declare function classifyBlockerCause(block: unknown, runtime: FlowNodeRuntimeState): FlowAgentBlockerCause | undefined;
588
- declare function classifyNodeState({ block, runtime, now, pendingInvocationCount }: ClassifyNodeStateInput): FlowAgentPublicNodeState;
589
- declare function snapshotNode(block: unknown, runtime: FlowNodeRuntimeState, now: number, pendingInvocationCount?: number): FlowAgentNodeSnapshot;
531
+ declare function classifyNodeState({ block, runtime, now, pendingInvocationCount, completionVerification, isRepeatable, }: ClassifyNodeStateInput): FlowAgentPublicNodeState;
532
+ declare function snapshotNode(block: unknown, runtime: FlowNodeRuntimeState, now: number, pendingInvocationCount?: number, completionVerification?: CompletionVerification, isRepeatable?: boolean): FlowAgentNodeSnapshot;
590
533
 
591
534
  /**
592
535
  * Compute an IPFS-compatible CID for arbitrary content.
@@ -715,4 +658,4 @@ declare function createOracleInitFlowTemplate(): {
715
658
  nodes: FlowNode[];
716
659
  };
717
660
 
718
- export { ActionDefinition, ActionServices, type AddFlowNodeOptions, type BlockConditionInput, type ClassifyNodeStateInput, CompiledBlock, CompiledEdge, CompiledFlow, type EvaluatorOperator, type ExecuteFlowAgentCoreCommandOptions, type ExecuteQueuedFlowAgentCoreCommandsOptions, type FailedListenerRun, FlowAgentBlockerCause, FlowAgentCommand, FlowAgentCommandResult, FlowAgentContext, FlowAgentExecutor, FlowAgentNodeSnapshot, FlowAgentPublicNodeState, type FlowDocumentNode, type FlowDocumentRead, FlowNode, FlowNodeRuntimeState, InvocationStore, OutputSchemaField, type PendingInvocation, RUN_RECORD_AUDIT_TYPE, type RunRecordDetails, StoredDelegation, type TriggerResolutionContext, UcanDelegationStore, UcanService, addFlowNode, appendRunRecord, buildBlockConditionsProp, buildServicesFromHandlers, canToType, classifyBlockerCause, classifyNodeState, computeCID, computeJsonCID, computePendingInvocationId, createOracleInitFlowTemplate, executeFlowAgentCoreCommand, executeQueuedFlowAgentCoreCommands, findFailedListenersForSourceRun, getAction, getActionByCan, getActionForBlock, getAllActions, getAllCanMappings, getEventsForBlock, getOrCreateBlockPendingMap, getOutputSchemaForBlock, getPendingInvocationsMap, hasAction, oracleInitSurveySchema, queuePendingInvocation, readBlocksFromFragment, readFlowDocument, readPendingInvocations, readRunRecords, reconcilePendingInvocations, registerAction, removeBlockFromFragment, removeFlowNode, removePendingInvocation, reorderFlowNodes, replaceBlockInFragment, replayFailedListenerRun, resetStepRuntime, resolveRuntimeRefs, setBlockProps, setFormAnswers, snapshotInputRefs, snapshotNode, swapFlowBlocks, toEvaluatorOperator, typeToCan, updateNodeRuntime, writeCompiledBlocksToFragment, writeRunRecordAndReconcile };
661
+ export { ActionDefinition, ActionHandlers, type ActionManifest, type ActionManifestEntry, ActionServices, type AddFlowNodeOptions, type BlockConditionInput, type ClassifyNodeStateInput, CompiledBlock, CompiledEdge, CompiledFlow, type CompletionVerification, type CompletionVerificationStatus, type EvaluatorOperator, type ExecuteFlowAgentCoreCommandOptions, type ExecuteQueuedFlowAgentCoreCommandsOptions, FlowAgentBlockerCause, FlowAgentCommand, FlowAgentCommandResult, FlowAgentContext, FlowAgentExecutor, FlowAgentNodeSnapshot, FlowAgentPublicNodeState, type FlowDocumentNode, type FlowDocumentRead, FlowNode, FlowNodeRuntimeState, type FlowVersionString, InvocationStore, LATEST_VERSION, type ManifestProofDeclaration, OutputSchemaField, PROOF_MISSING_CODE, type ProofValidationResult, RunRecordDetails, STEP_COMPLETED_EVENT, STEP_COMPLETED_EVENT_NAME, StoredDelegation, StoredInvocation, type TriggerResolutionContext, UcanDelegationStore, UcanService, VERSION_MANIFEST, type VersionPolicy, addFlowNode, buildBlockConditionsProp, buildServicesFromHandlers, canToType, classifyBlockerCause, classifyNodeState, computeCID, computeJsonCID, createOracleInitFlowTemplate, executeFlowAgentCoreCommand, executeQueuedFlowAgentCoreCommands, generateActionManifest, getAction, getActionByCan, getActionForBlock, getAliasEntries, getAllActions, getAllCanMappings, getEventsForBlock, getOutputSchemaForBlock, getVersionPolicy, hasAction, isVerifiedCompletion, isVersionAtLeast, oracleInitSurveySchema, readBlocksFromFragment, readFlowDocument, reconcilePendingInvocations, registerAction, removeBlockFromFragment, removeFlowNode, reorderFlowNodes, replaceBlockInFragment, resetStepRuntime, resolveRuntimeRefs, setBlockProps, setFormAnswers, snapshotNode, swapFlowBlocks, toEvaluatorOperator, typeToCan, updateNodeRuntime, validateActionProof, verifyCompletion, writeCompiledBlocksToFragment, writeRunRecordAndReconcile };
@@ -8,10 +8,15 @@ import {
8
8
  setFormAnswers,
9
9
  swapFlowBlocks,
10
10
  updateNodeRuntime
11
- } from "../chunk-JXTHVI23.js";
11
+ } from "../chunk-EOMC6ZVX.js";
12
12
  import {
13
13
  FlowAgentService,
14
+ LATEST_VERSION,
15
+ PROOF_MISSING_CODE,
14
16
  RUN_RECORD_AUDIT_TYPE,
17
+ STEP_COMPLETED_EVENT,
18
+ STEP_COMPLETED_EVENT_NAME,
19
+ VERSION_MANIFEST,
15
20
  acquireFlowAgentLease,
16
21
  appendAgentLedgerEvent,
17
22
  appendRunRecord,
@@ -43,10 +48,12 @@ import {
43
48
  executeQueuedAgentCommands,
44
49
  executeQueuedFlowAgentCoreCommands,
45
50
  findFailedListenersForSourceRun,
51
+ generateActionManifest,
46
52
  getAction,
47
53
  getActionByCan,
48
54
  getActionForBlock,
49
55
  getActiveEditor,
56
+ getAliasEntries,
50
57
  getAllActions,
51
58
  getAllCanMappings,
52
59
  getEventsForBlock,
@@ -54,11 +61,14 @@ import {
54
61
  getOrCreateBlockPendingMap,
55
62
  getOutputSchemaForBlock,
56
63
  getPendingInvocationsMap,
64
+ getVersionPolicy,
57
65
  hasAction,
58
66
  isAuthorized,
59
67
  isCapabilityMatch,
60
68
  isExternalMutation,
61
69
  isRuntimeRef,
70
+ isVerifiedCompletion,
71
+ isVersionAtLeast,
62
72
  mergeCompiledFlows,
63
73
  planRalphLoopCommands,
64
74
  queueAgentCommand,
@@ -90,11 +100,13 @@ import {
90
100
  toEvaluatorOperator,
91
101
  typeToCan,
92
102
  updateAgentCommand,
103
+ validateActionProof,
93
104
  validateAgentCommand,
94
105
  validateFlowAgentLease,
106
+ verifyCompletion,
95
107
  writeCompiledBlocksToFragment,
96
108
  writeRunRecordAndReconcile
97
- } from "../chunk-YWZJYSOP.js";
109
+ } from "../chunk-5TJK6JKV.js";
98
110
  import {
99
111
  computeCID,
100
112
  computeJsonCID
@@ -481,7 +493,12 @@ function createOracleInitFlowTemplate() {
481
493
  }
482
494
  export {
483
495
  FlowAgentService,
496
+ LATEST_VERSION,
497
+ PROOF_MISSING_CODE,
484
498
  RUN_RECORD_AUDIT_TYPE,
499
+ STEP_COMPLETED_EVENT,
500
+ STEP_COMPLETED_EVENT_NAME,
501
+ VERSION_MANIFEST,
485
502
  acquireFlowAgentLease,
486
503
  addFlowNode,
487
504
  appendAgentLedgerEvent,
@@ -517,10 +534,12 @@ export {
517
534
  executeQueuedAgentCommands,
518
535
  executeQueuedFlowAgentCoreCommands,
519
536
  findFailedListenersForSourceRun,
537
+ generateActionManifest,
520
538
  getAction,
521
539
  getActionByCan,
522
540
  getActionForBlock,
523
541
  getActiveEditor,
542
+ getAliasEntries,
524
543
  getAllActions,
525
544
  getAllCanMappings,
526
545
  getEventsForBlock,
@@ -528,11 +547,14 @@ export {
528
547
  getOrCreateBlockPendingMap,
529
548
  getOutputSchemaForBlock,
530
549
  getPendingInvocationsMap,
550
+ getVersionPolicy,
531
551
  hasAction,
532
552
  isAuthorized,
533
553
  isCapabilityMatch,
534
554
  isExternalMutation,
535
555
  isRuntimeRef,
556
+ isVerifiedCompletion,
557
+ isVersionAtLeast,
536
558
  mergeCompiledFlows,
537
559
  oracleInitSurveySchema,
538
560
  planRalphLoopCommands,
@@ -573,8 +595,10 @@ export {
573
595
  typeToCan,
574
596
  updateAgentCommand,
575
597
  updateNodeRuntime,
598
+ validateActionProof,
576
599
  validateAgentCommand,
577
600
  validateFlowAgentLease,
601
+ verifyCompletion,
578
602
  writeCompiledBlocksToFragment,
579
603
  writeRunRecordAndReconcile
580
604
  };