@feltdb/core 0.2.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 +184 -0
- package/dist/agent-decision.d.ts +81 -0
- package/dist/agent-decision.d.ts.map +1 -0
- package/dist/agent-decision.js +18 -0
- package/dist/agent-memory.d.ts +91 -0
- package/dist/agent-memory.d.ts.map +1 -0
- package/dist/agent-memory.js +21 -0
- package/dist/agent-observation.d.ts +61 -0
- package/dist/agent-observation.d.ts.map +1 -0
- package/dist/agent-observation.js +12 -0
- package/dist/agent-registry.d.ts +92 -0
- package/dist/agent-registry.d.ts.map +1 -0
- package/dist/agent-registry.js +134 -0
- package/dist/agent-runtime.d.ts +147 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +240 -0
- package/dist/agent.d.ts +132 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +58 -0
- package/dist/capability.d.ts +21 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +23 -0
- package/dist/collection.d.ts +95 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +289 -0
- package/dist/db.d.ts +504 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +700 -0
- package/dist/execution.d.ts +148 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +18 -0
- package/dist/feltdb.d.ts +82 -0
- package/dist/feltdb.d.ts.map +1 -0
- package/dist/feltdb.js +6 -0
- package/dist/flowspec.d.ts +64 -0
- package/dist/flowspec.d.ts.map +1 -0
- package/dist/flowspec.js +272 -0
- package/dist/http-db.d.ts +50 -0
- package/dist/http-db.d.ts.map +1 -0
- package/dist/http-db.js +205 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/indexeddb-db.d.ts +54 -0
- package/dist/indexeddb-db.d.ts.map +1 -0
- package/dist/indexeddb-db.js +175 -0
- package/dist/memory-db.d.ts +49 -0
- package/dist/memory-db.d.ts.map +1 -0
- package/dist/memory-db.js +97 -0
- package/dist/operation.d.ts +25 -0
- package/dist/operation.d.ts.map +1 -0
- package/dist/operation.js +16 -0
- package/dist/reactive-graph.d.ts +67 -0
- package/dist/reactive-graph.d.ts.map +1 -0
- package/dist/reactive-graph.js +118 -0
- package/dist/recovery.d.ts +68 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +104 -0
- package/dist/storage.d.ts +48 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +6 -0
- package/dist/workflow.d.ts +20 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +12 -0
- package/package.json +43 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeltDB Execution API
|
|
3
|
+
*
|
|
4
|
+
* Event-driven execution runtime for triggering capabilities based on
|
|
5
|
+
* operations or scheduled events.
|
|
6
|
+
*/
|
|
7
|
+
import type { StateFirstDB } from './db.js';
|
|
8
|
+
/**
|
|
9
|
+
* Execution status
|
|
10
|
+
*/
|
|
11
|
+
export declare enum ExecutionStatus {
|
|
12
|
+
Pending = "Pending",
|
|
13
|
+
Running = "Running",
|
|
14
|
+
Succeeded = "Succeeded",
|
|
15
|
+
Failed = "Failed",
|
|
16
|
+
RetryScheduled = "RetryScheduled",
|
|
17
|
+
DeadLettered = "DeadLettered"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retry policy for execution
|
|
21
|
+
*/
|
|
22
|
+
export interface RetryPolicy {
|
|
23
|
+
/** Maximum number of retry attempts */
|
|
24
|
+
maxAttempts: number;
|
|
25
|
+
/** Initial backoff in milliseconds */
|
|
26
|
+
initialBackoffMs: number;
|
|
27
|
+
/** Maximum backoff in milliseconds */
|
|
28
|
+
maxBackoffMs: number;
|
|
29
|
+
/** Backoff multiplier for exponential backoff */
|
|
30
|
+
backoffMultiplier: number;
|
|
31
|
+
/** Timeout per attempt in milliseconds */
|
|
32
|
+
timeoutMs: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A durable execution record
|
|
36
|
+
* Tracks the execution of a capability triggered by an operation
|
|
37
|
+
*/
|
|
38
|
+
export interface Execution {
|
|
39
|
+
/** Unique execution identifier */
|
|
40
|
+
executionId: string;
|
|
41
|
+
/** The trigger that caused this execution */
|
|
42
|
+
triggerId: string;
|
|
43
|
+
/** Source operation that triggered this execution */
|
|
44
|
+
sourceOperation: {
|
|
45
|
+
op_id: number;
|
|
46
|
+
instance_id: string;
|
|
47
|
+
sequence: number;
|
|
48
|
+
op_type: 'Insert' | 'Update' | 'Delete';
|
|
49
|
+
key: string;
|
|
50
|
+
value?: any;
|
|
51
|
+
timestamp_ms: number;
|
|
52
|
+
rust_type: string;
|
|
53
|
+
capability: string;
|
|
54
|
+
};
|
|
55
|
+
/** Capability to execute */
|
|
56
|
+
capability: string;
|
|
57
|
+
/** Attempt number (1-based) */
|
|
58
|
+
attempt: number;
|
|
59
|
+
/** Current status */
|
|
60
|
+
status: ExecutionStatus;
|
|
61
|
+
/** Optional result value */
|
|
62
|
+
result?: any;
|
|
63
|
+
/** Optional error message */
|
|
64
|
+
error?: string;
|
|
65
|
+
/** Timestamp when execution was created */
|
|
66
|
+
created_ms: number;
|
|
67
|
+
/** Timestamp when execution started */
|
|
68
|
+
started_ms?: number;
|
|
69
|
+
/** Timestamp when execution completed */
|
|
70
|
+
completed_ms?: number;
|
|
71
|
+
/** Claim token for single-owner execution semantics */
|
|
72
|
+
claimed_by?: string;
|
|
73
|
+
/** Retry policy settings */
|
|
74
|
+
retry_policy: RetryPolicy;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Capability-scoped execution runtime
|
|
78
|
+
* Provides restricted execution context for a capability
|
|
79
|
+
*/
|
|
80
|
+
export interface ExecutionContext {
|
|
81
|
+
/** Execution being performed */
|
|
82
|
+
execution: Execution;
|
|
83
|
+
/** Database reference (scoped to capability permissions) */
|
|
84
|
+
db: StateFirstDB;
|
|
85
|
+
/** Whether this is a retry attempt */
|
|
86
|
+
isRetry: boolean;
|
|
87
|
+
/** Attempt number */
|
|
88
|
+
attempt: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Execution handler function
|
|
92
|
+
* Called when an execution event is triggered
|
|
93
|
+
*/
|
|
94
|
+
export type ExecutionHandler = (context: ExecutionContext) => Promise<any>;
|
|
95
|
+
/**
|
|
96
|
+
* Execution manager for a StateFirstDB instance
|
|
97
|
+
*/
|
|
98
|
+
export interface ExecutionManager {
|
|
99
|
+
/**
|
|
100
|
+
* Register a handler for a capability
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* execManager.handle("process_order", async (ctx) => {
|
|
104
|
+
* const { execution, db } = ctx;
|
|
105
|
+
* // Execute capability logic
|
|
106
|
+
* return { success: true };
|
|
107
|
+
* });
|
|
108
|
+
*/
|
|
109
|
+
handle(capability: string, handler: ExecutionHandler): void;
|
|
110
|
+
/**
|
|
111
|
+
* Unregister a handler for a capability
|
|
112
|
+
*/
|
|
113
|
+
unhandle(capability: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Get pending executions for a capability
|
|
116
|
+
*/
|
|
117
|
+
getPending(capability?: string): Promise<Execution[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Get execution by ID
|
|
120
|
+
*/
|
|
121
|
+
get(executionId: string): Promise<Execution | null>;
|
|
122
|
+
/**
|
|
123
|
+
* Get all executions
|
|
124
|
+
*/
|
|
125
|
+
all(): Promise<Execution[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Mark execution as running
|
|
128
|
+
*/
|
|
129
|
+
markRunning(executionId: string): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Mark execution as succeeded
|
|
132
|
+
*/
|
|
133
|
+
markSucceeded(executionId: string, result: any): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Mark execution as failed
|
|
136
|
+
*/
|
|
137
|
+
markFailed(executionId: string, error: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Schedule retry for a failed execution
|
|
140
|
+
*/
|
|
141
|
+
scheduleRetry(executionId: string): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Process all pending executions
|
|
144
|
+
* Runs handlers for matched capabilities
|
|
145
|
+
*/
|
|
146
|
+
processPending(): Promise<number>;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,gBAAgB,EAAE,MAAM,CAAC;IAEzB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IAErB,iDAAiD;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IAEpB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAElB,qDAAqD;IACrD,eAAe,EAAE;QACf,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACxC,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,GAAG,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E,CAAC,CAAC;IAEtD;;OAEG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,GAAG,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAE5B;;OAEG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/D;;OAEG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;;OAGG;IACH,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeltDB Execution API
|
|
3
|
+
*
|
|
4
|
+
* Event-driven execution runtime for triggering capabilities based on
|
|
5
|
+
* operations or scheduled events.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Execution status
|
|
9
|
+
*/
|
|
10
|
+
export var ExecutionStatus;
|
|
11
|
+
(function (ExecutionStatus) {
|
|
12
|
+
ExecutionStatus["Pending"] = "Pending";
|
|
13
|
+
ExecutionStatus["Running"] = "Running";
|
|
14
|
+
ExecutionStatus["Succeeded"] = "Succeeded";
|
|
15
|
+
ExecutionStatus["Failed"] = "Failed";
|
|
16
|
+
ExecutionStatus["RetryScheduled"] = "RetryScheduled";
|
|
17
|
+
ExecutionStatus["DeadLettered"] = "DeadLettered";
|
|
18
|
+
})(ExecutionStatus || (ExecutionStatus = {}));
|
package/dist/feltdb.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM FeltDB Binding
|
|
3
|
+
*
|
|
4
|
+
* This is the FFI interface to the Rust WASM implementation.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* WASM database instance
|
|
8
|
+
*/
|
|
9
|
+
export interface JsDb {
|
|
10
|
+
/**
|
|
11
|
+
* Execute an operation
|
|
12
|
+
*/
|
|
13
|
+
execute_op(operation: any): any;
|
|
14
|
+
/**
|
|
15
|
+
* Get sync info
|
|
16
|
+
*/
|
|
17
|
+
sync_info(): any;
|
|
18
|
+
/**
|
|
19
|
+
* Add a peer
|
|
20
|
+
*/
|
|
21
|
+
add_peer(peer_id: string): any;
|
|
22
|
+
/**
|
|
23
|
+
* Add sync peer
|
|
24
|
+
*/
|
|
25
|
+
add_sync_peer(peer_id: string): any;
|
|
26
|
+
/**
|
|
27
|
+
* Remove sync peer
|
|
28
|
+
*/
|
|
29
|
+
remove_sync_peer(peer_id: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Get pending operations for peer
|
|
32
|
+
*/
|
|
33
|
+
get_pending_for_peer(peer_id: string, since_sequence: number): any;
|
|
34
|
+
/**
|
|
35
|
+
* Acknowledge peer operations
|
|
36
|
+
*/
|
|
37
|
+
acknowledge_peer_operations(peer_id: string, sequence: number): any;
|
|
38
|
+
/**
|
|
39
|
+
* Query data
|
|
40
|
+
*/
|
|
41
|
+
query(query: string): any | Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a record
|
|
44
|
+
*/
|
|
45
|
+
get(key: string): any | Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Insert a record
|
|
48
|
+
*/
|
|
49
|
+
insert(key: string, value: string): any | Promise<any>;
|
|
50
|
+
/** Update a record without changing collection semantics. */
|
|
51
|
+
update?(key: string, value: string): any | Promise<any>;
|
|
52
|
+
/** Delete a record when supported by the runtime. */
|
|
53
|
+
delete?(key: string): any | Promise<any>;
|
|
54
|
+
/** Subscribe to runtime-originated changes, including remote mutations. */
|
|
55
|
+
subscribe_changes?(callback: (collection: string) => void): () => void;
|
|
56
|
+
close?(): void | Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Get capability records
|
|
59
|
+
*/
|
|
60
|
+
get_capability_records(capability: string): any;
|
|
61
|
+
/**
|
|
62
|
+
* Get instance ID
|
|
63
|
+
*/
|
|
64
|
+
instance_id(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Get sequence number
|
|
67
|
+
*/
|
|
68
|
+
get_sequence(): number;
|
|
69
|
+
/** Read durable mutation events when the runtime exposes an audit log. */
|
|
70
|
+
audit_events?(): any | Promise<any>;
|
|
71
|
+
/** Export and merge portable embedded-runtime operations. */
|
|
72
|
+
export_operations?(since_sequence: number): any | Promise<any>;
|
|
73
|
+
apply_remote_operations?(operations: any[]): any | Promise<any>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A row stored in the database
|
|
77
|
+
*/
|
|
78
|
+
export interface StoredRow {
|
|
79
|
+
id: string | number;
|
|
80
|
+
[key: string]: any;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=feltdb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feltdb.d.ts","sourceRoot":"","sources":["../src/feltdb.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,GAAG,GAAG,GAAG,CAAC;IAEhC;;OAEG;IACH,SAAS,IAAI,GAAG,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAE/B;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAEvC;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,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uB,CAAC,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/dist/feltdb.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface FlowField {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
optional: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface FlowIndex {
|
|
7
|
+
name: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
expression: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FlowCollection {
|
|
12
|
+
name: string;
|
|
13
|
+
fields: FlowField[];
|
|
14
|
+
indexes: FlowIndex[];
|
|
15
|
+
}
|
|
16
|
+
export interface FlowBlock {
|
|
17
|
+
name: string;
|
|
18
|
+
statements: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface FlowStep extends FlowBlock {
|
|
21
|
+
}
|
|
22
|
+
export interface FlowWorkflow {
|
|
23
|
+
name: string;
|
|
24
|
+
parameters: string;
|
|
25
|
+
steps: FlowStep[];
|
|
26
|
+
}
|
|
27
|
+
export interface FlowTrigger {
|
|
28
|
+
event: string;
|
|
29
|
+
statements: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface FlowSpec {
|
|
32
|
+
version: 1;
|
|
33
|
+
app: string;
|
|
34
|
+
collections: FlowCollection[];
|
|
35
|
+
capabilities: FlowBlock[];
|
|
36
|
+
agents: FlowBlock[];
|
|
37
|
+
workflows: FlowWorkflow[];
|
|
38
|
+
triggers: FlowTrigger[];
|
|
39
|
+
policies: FlowBlock[];
|
|
40
|
+
schedules: FlowBlock[];
|
|
41
|
+
}
|
|
42
|
+
export interface FlowDiagnostic {
|
|
43
|
+
severity: 'error' | 'warning';
|
|
44
|
+
message: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface FlowSpecDiff {
|
|
48
|
+
added: string[];
|
|
49
|
+
removed: string[];
|
|
50
|
+
changed: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface FlowMigrationOperation {
|
|
53
|
+
kind: 'add' | 'change' | 'remove';
|
|
54
|
+
target: string;
|
|
55
|
+
safety: 'safe' | 'requires_transform' | 'destructive';
|
|
56
|
+
detail: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function parseFlowSpec(source: string): FlowSpec;
|
|
59
|
+
export declare function validateFlowSpec(spec: FlowSpec): FlowDiagnostic[];
|
|
60
|
+
export declare function formatFlowSpec(spec: FlowSpec): string;
|
|
61
|
+
export declare function diffFlowSpec(before: FlowSpec, after: FlowSpec): FlowSpecDiff;
|
|
62
|
+
export declare function planFlowSpecMigration(before: FlowSpec, after: FlowSpec): FlowMigrationOperation[];
|
|
63
|
+
export declare function emptyFlowSpec(app?: string): FlowSpec;
|
|
64
|
+
//# sourceMappingURL=flowspec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowspec.d.ts","sourceRoot":"","sources":["../src/flowspec.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAC5E,MAAM,WAAW,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AAC7E,MAAM,WAAW,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE;AAC3F,MAAM,WAAW,SAAS;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE;AAC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CAWjE;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAUrD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,YAAY,CAQ5E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAsBjG;AAED,wBAAgB,aAAa,CAAC,GAAG,SAAU,GAAG,QAAQ,CAAyI"}
|
package/dist/flowspec.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
function lex(source) {
|
|
2
|
+
const tokens = [];
|
|
3
|
+
let line = 1;
|
|
4
|
+
for (let index = 0; index < source.length;) {
|
|
5
|
+
const char = source[index];
|
|
6
|
+
if (char === '\n') {
|
|
7
|
+
tokens.push({ value: '\n', line });
|
|
8
|
+
line++;
|
|
9
|
+
index++;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (/\s/.test(char)) {
|
|
13
|
+
index++;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (source.startsWith('//', index)) {
|
|
17
|
+
while (index < source.length && source[index] !== '\n')
|
|
18
|
+
index++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (char === '"') {
|
|
22
|
+
let value = '"';
|
|
23
|
+
index++;
|
|
24
|
+
while (index < source.length) {
|
|
25
|
+
const next = source[index++];
|
|
26
|
+
value += next;
|
|
27
|
+
if (next === '\\' && index < source.length)
|
|
28
|
+
value += source[index++];
|
|
29
|
+
else if (next === '"')
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
tokens.push({ value, line });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const arrow = source.slice(index, index + 2);
|
|
36
|
+
if (arrow === '->') {
|
|
37
|
+
tokens.push({ value: arrow, line });
|
|
38
|
+
index += 2;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if ('{}():?,'.includes(char)) {
|
|
42
|
+
tokens.push({ value: char, line });
|
|
43
|
+
index++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
let value = '';
|
|
47
|
+
while (index < source.length && !/\s/.test(source[index]) && !'{}():?,'.includes(source[index]))
|
|
48
|
+
value += source[index++];
|
|
49
|
+
tokens.push({ value, line });
|
|
50
|
+
}
|
|
51
|
+
return tokens;
|
|
52
|
+
}
|
|
53
|
+
class Parser {
|
|
54
|
+
constructor(tokens) {
|
|
55
|
+
this.tokens = tokens;
|
|
56
|
+
this.index = 0;
|
|
57
|
+
}
|
|
58
|
+
peek(value) { return this.index < this.tokens.length && (value === undefined || this.tokens[this.index].value === value); }
|
|
59
|
+
take(value) { const token = this.tokens[this.index++]; if (!token || (value && token.value !== value))
|
|
60
|
+
throw new Error(`Expected ${value ?? 'token'} at line ${token?.line ?? 'EOF'}`); return token; }
|
|
61
|
+
newlines() { while (this.peek('\n'))
|
|
62
|
+
this.take(); }
|
|
63
|
+
identifier() { const token = this.take(); if (!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(token.value))
|
|
64
|
+
throw new Error(`Invalid identifier ${token.value} at line ${token.line}`); return token.value; }
|
|
65
|
+
line() {
|
|
66
|
+
const values = [];
|
|
67
|
+
while (this.peek() && !this.peek('\n') && !this.peek('}'))
|
|
68
|
+
values.push(this.take().value);
|
|
69
|
+
this.newlines();
|
|
70
|
+
return values.join(' ').replace(/\s+([,?)])/g, '$1').replace(/([(])\s+/g, '$1').trim();
|
|
71
|
+
}
|
|
72
|
+
statements() {
|
|
73
|
+
this.take('{');
|
|
74
|
+
this.newlines();
|
|
75
|
+
const output = [];
|
|
76
|
+
while (!this.peek('}')) {
|
|
77
|
+
const statement = this.line();
|
|
78
|
+
if (statement)
|
|
79
|
+
output.push(statement);
|
|
80
|
+
else if (!this.peek())
|
|
81
|
+
throw new Error('Unclosed block');
|
|
82
|
+
}
|
|
83
|
+
this.take('}');
|
|
84
|
+
this.newlines();
|
|
85
|
+
return output;
|
|
86
|
+
}
|
|
87
|
+
parse() {
|
|
88
|
+
this.newlines();
|
|
89
|
+
this.take('app');
|
|
90
|
+
const app = this.identifier();
|
|
91
|
+
this.take('{');
|
|
92
|
+
this.newlines();
|
|
93
|
+
const spec = { version: 1, app, collections: [], capabilities: [], agents: [], workflows: [], triggers: [], policies: [], schedules: [] };
|
|
94
|
+
while (!this.peek('}')) {
|
|
95
|
+
const kind = this.take().value;
|
|
96
|
+
if (kind === 'collection')
|
|
97
|
+
spec.collections.push(this.collection());
|
|
98
|
+
else if (kind === 'workflow')
|
|
99
|
+
spec.workflows.push(this.workflow());
|
|
100
|
+
else if (kind === 'trigger')
|
|
101
|
+
spec.triggers.push(this.trigger());
|
|
102
|
+
else if (['capability', 'agent', 'policy', 'schedule'].includes(kind)) {
|
|
103
|
+
const block = { name: this.identifier(), statements: this.statements() };
|
|
104
|
+
if (kind === 'capability')
|
|
105
|
+
spec.capabilities.push(block);
|
|
106
|
+
else if (kind === 'agent')
|
|
107
|
+
spec.agents.push(block);
|
|
108
|
+
else if (kind === 'policy')
|
|
109
|
+
spec.policies.push(block);
|
|
110
|
+
else
|
|
111
|
+
spec.schedules.push(block);
|
|
112
|
+
}
|
|
113
|
+
else
|
|
114
|
+
throw new Error(`Unknown declaration ${kind} at line ${this.tokens[this.index - 1].line}`);
|
|
115
|
+
this.newlines();
|
|
116
|
+
}
|
|
117
|
+
this.take('}');
|
|
118
|
+
this.newlines();
|
|
119
|
+
if (this.peek())
|
|
120
|
+
throw new Error(`Unexpected token ${this.take().value}`);
|
|
121
|
+
return spec;
|
|
122
|
+
}
|
|
123
|
+
collection() {
|
|
124
|
+
const name = this.identifier();
|
|
125
|
+
this.take('{');
|
|
126
|
+
this.newlines();
|
|
127
|
+
const fields = [];
|
|
128
|
+
const indexes = [];
|
|
129
|
+
while (!this.peek('}')) {
|
|
130
|
+
const first = this.identifier();
|
|
131
|
+
if (first === 'index') {
|
|
132
|
+
const indexName = this.identifier();
|
|
133
|
+
this.take('using');
|
|
134
|
+
const kind = this.identifier();
|
|
135
|
+
const expression = this.line();
|
|
136
|
+
indexes.push({ name: indexName, kind, expression });
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.take(':');
|
|
140
|
+
const typeParts = [];
|
|
141
|
+
while (this.peek() && !this.peek('\n') && !this.peek('}'))
|
|
142
|
+
typeParts.push(this.take().value);
|
|
143
|
+
this.newlines();
|
|
144
|
+
let optional = false;
|
|
145
|
+
if (typeParts.at(-1) === '?') {
|
|
146
|
+
optional = true;
|
|
147
|
+
typeParts.pop();
|
|
148
|
+
}
|
|
149
|
+
fields.push({ name: first, type: typeParts.join(' ').replace(/\s+([,)])/g, '$1').replace(/([(])\s+/g, '$1'), optional });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.take('}');
|
|
153
|
+
this.newlines();
|
|
154
|
+
return { name, fields, indexes };
|
|
155
|
+
}
|
|
156
|
+
workflow() {
|
|
157
|
+
const name = this.identifier();
|
|
158
|
+
let parameters = '';
|
|
159
|
+
if (this.peek('(')) {
|
|
160
|
+
this.take();
|
|
161
|
+
const values = [];
|
|
162
|
+
while (!this.peek(')'))
|
|
163
|
+
values.push(this.take().value);
|
|
164
|
+
this.take(')');
|
|
165
|
+
parameters = values.join(' ').replace(/\s+([,])/g, '$1');
|
|
166
|
+
}
|
|
167
|
+
this.take('{');
|
|
168
|
+
this.newlines();
|
|
169
|
+
const steps = [];
|
|
170
|
+
while (!this.peek('}')) {
|
|
171
|
+
this.take('step');
|
|
172
|
+
const step = this.identifier();
|
|
173
|
+
steps.push({ name: step, statements: this.statements() });
|
|
174
|
+
}
|
|
175
|
+
this.take('}');
|
|
176
|
+
this.newlines();
|
|
177
|
+
return { name, parameters, steps };
|
|
178
|
+
}
|
|
179
|
+
trigger() {
|
|
180
|
+
this.take('on');
|
|
181
|
+
const eventParts = [];
|
|
182
|
+
while (!this.peek('{'))
|
|
183
|
+
eventParts.push(this.take().value);
|
|
184
|
+
return { event: eventParts.join(' '), statements: this.statements() };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
export function parseFlowSpec(source) { return new Parser(lex(source)).parse(); }
|
|
188
|
+
export function validateFlowSpec(spec) {
|
|
189
|
+
const diagnostics = [];
|
|
190
|
+
const duplicate = (kind, values) => values.filter((value, index) => values.indexOf(value) !== index).forEach(value => diagnostics.push({ severity: 'error', message: `Duplicate ${kind}: ${value}` }));
|
|
191
|
+
duplicate('collection', spec.collections.map(value => value.name));
|
|
192
|
+
duplicate('capability', spec.capabilities.map(value => value.name));
|
|
193
|
+
duplicate('agent', spec.agents.map(value => value.name));
|
|
194
|
+
duplicate('workflow', spec.workflows.map(value => value.name));
|
|
195
|
+
const collections = new Set(spec.collections.map(value => value.name));
|
|
196
|
+
for (const collection of spec.collections) {
|
|
197
|
+
duplicate(`field in ${collection.name}`, collection.fields.map(value => value.name));
|
|
198
|
+
for (const field of collection.fields)
|
|
199
|
+
if (field.type.startsWith('ref ') && !collections.has(field.type.slice(4)))
|
|
200
|
+
diagnostics.push({ severity: 'error', path: `${collection.name}.${field.name}`, message: `Unknown referenced collection ${field.type.slice(4)}` });
|
|
201
|
+
}
|
|
202
|
+
for (const workflow of spec.workflows) {
|
|
203
|
+
duplicate(`step in ${workflow.name}`, workflow.steps.map(value => value.name));
|
|
204
|
+
if (!workflow.steps.length)
|
|
205
|
+
diagnostics.push({ severity: 'error', message: `Workflow ${workflow.name} has no steps` });
|
|
206
|
+
}
|
|
207
|
+
return diagnostics;
|
|
208
|
+
}
|
|
209
|
+
function block(kind, value, indent = ' ') { return `${indent}${kind} ${value.name} {\n${value.statements.map(line => `${indent} ${line}`).join('\n')}\n${indent}}`; }
|
|
210
|
+
export function formatFlowSpec(spec) {
|
|
211
|
+
const declarations = [];
|
|
212
|
+
for (const value of spec.collections)
|
|
213
|
+
declarations.push(` collection ${value.name} {\n${value.fields.map(field => ` ${field.name}: ${field.type}${field.optional ? '?' : ''}`).concat(value.indexes.map(index => ` index ${index.name} using ${index.kind} ${index.expression}`)).join('\n')}\n }`);
|
|
214
|
+
for (const value of spec.capabilities)
|
|
215
|
+
declarations.push(block('capability', value));
|
|
216
|
+
for (const value of spec.agents)
|
|
217
|
+
declarations.push(block('agent', value));
|
|
218
|
+
for (const value of spec.workflows)
|
|
219
|
+
declarations.push(` workflow ${value.name}${value.parameters ? `(${value.parameters})` : ''} {\n${value.steps.map(step => ` step ${step.name} {\n${step.statements.map(line => ` ${line}`).join('\n')}\n }`).join('\n')}\n }`);
|
|
220
|
+
for (const value of spec.triggers)
|
|
221
|
+
declarations.push(` trigger on ${value.event} {\n${value.statements.map(line => ` ${line}`).join('\n')}\n }`);
|
|
222
|
+
for (const value of spec.policies)
|
|
223
|
+
declarations.push(block('policy', value));
|
|
224
|
+
for (const value of spec.schedules)
|
|
225
|
+
declarations.push(block('schedule', value));
|
|
226
|
+
return `app ${spec.app} {\n${declarations.join('\n\n')}\n}\n`;
|
|
227
|
+
}
|
|
228
|
+
export function diffFlowSpec(before, after) {
|
|
229
|
+
const flatten = (spec) => new Map([
|
|
230
|
+
...spec.collections.map(value => [`collection ${value.name}`, JSON.stringify(value)]), ...spec.capabilities.map(value => [`capability ${value.name}`, JSON.stringify(value)]),
|
|
231
|
+
...spec.agents.map(value => [`agent ${value.name}`, JSON.stringify(value)]), ...spec.workflows.map(value => [`workflow ${value.name}`, JSON.stringify(value)]),
|
|
232
|
+
...spec.triggers.map(value => [`trigger ${value.event}`, JSON.stringify(value)]), ...spec.policies.map(value => [`policy ${value.name}`, JSON.stringify(value)]), ...spec.schedules.map(value => [`schedule ${value.name}`, JSON.stringify(value)]),
|
|
233
|
+
]);
|
|
234
|
+
const left = flatten(before), right = flatten(after);
|
|
235
|
+
return { added: [...right.keys()].filter(key => !left.has(key)), removed: [...left.keys()].filter(key => !right.has(key)), changed: [...right.keys()].filter(key => left.has(key) && left.get(key) !== right.get(key)) };
|
|
236
|
+
}
|
|
237
|
+
export function planFlowSpecMigration(before, after) {
|
|
238
|
+
const operations = [];
|
|
239
|
+
const oldCollections = new Map(before.collections.map(value => [value.name, value]));
|
|
240
|
+
const newCollections = new Map(after.collections.map(value => [value.name, value]));
|
|
241
|
+
for (const [name, collection] of newCollections) {
|
|
242
|
+
const previous = oldCollections.get(name);
|
|
243
|
+
if (!previous) {
|
|
244
|
+
operations.push({ kind: 'add', target: `collection ${name}`, safety: 'safe', detail: 'Create collection model' });
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const oldFields = new Map(previous.fields.map(value => [value.name, value]));
|
|
248
|
+
const newFields = new Map(collection.fields.map(value => [value.name, value]));
|
|
249
|
+
for (const [field, definition] of newFields) {
|
|
250
|
+
const old = oldFields.get(field);
|
|
251
|
+
if (!old)
|
|
252
|
+
operations.push({ kind: 'add', target: `${name}.${field}`, safety: definition.optional ? 'safe' : 'requires_transform', detail: definition.optional ? 'Add optional field' : 'Required field needs a backfill' });
|
|
253
|
+
else if (old.type !== definition.type || old.optional !== definition.optional)
|
|
254
|
+
operations.push({ kind: 'change', target: `${name}.${field}`, safety: 'requires_transform', detail: `${old.type}${old.optional ? '?' : ''} → ${definition.type}${definition.optional ? '?' : ''}` });
|
|
255
|
+
}
|
|
256
|
+
for (const field of oldFields.keys())
|
|
257
|
+
if (!newFields.has(field))
|
|
258
|
+
operations.push({ kind: 'remove', target: `${name}.${field}`, safety: 'destructive', detail: 'Field is no longer declared' });
|
|
259
|
+
}
|
|
260
|
+
for (const name of oldCollections.keys())
|
|
261
|
+
if (!newCollections.has(name))
|
|
262
|
+
operations.push({ kind: 'remove', target: `collection ${name}`, safety: 'destructive', detail: 'Collection model is no longer declared' });
|
|
263
|
+
const diff = diffFlowSpec(before, after);
|
|
264
|
+
for (const target of diff.added.filter(value => !value.startsWith('collection ')))
|
|
265
|
+
operations.push({ kind: 'add', target, safety: 'safe', detail: 'Deploy application primitive' });
|
|
266
|
+
for (const target of diff.changed.filter(value => !value.startsWith('collection ')))
|
|
267
|
+
operations.push({ kind: 'change', target, safety: 'safe', detail: 'Version application primitive' });
|
|
268
|
+
for (const target of diff.removed.filter(value => !value.startsWith('collection ')))
|
|
269
|
+
operations.push({ kind: 'remove', target, safety: 'destructive', detail: 'Application primitive is no longer declared' });
|
|
270
|
+
return operations;
|
|
271
|
+
}
|
|
272
|
+
export function emptyFlowSpec(app = 'MyApp') { return { version: 1, app, collections: [], capabilities: [], agents: [], workflows: [], triggers: [], policies: [], schedules: [] }; }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { JsDb } from './feltdb.js';
|
|
2
|
+
interface JsResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
data?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
}
|
|
7
|
+
interface HttpRuntimeOptions {
|
|
8
|
+
url: string;
|
|
9
|
+
token: string;
|
|
10
|
+
}
|
|
11
|
+
/** Network adapter implementing the same collection runtime contract as WASM. */
|
|
12
|
+
export declare class HttpJsDb implements JsDb {
|
|
13
|
+
private readonly url;
|
|
14
|
+
private readonly token;
|
|
15
|
+
constructor(options: HttpRuntimeOptions);
|
|
16
|
+
private headers;
|
|
17
|
+
private splitKey;
|
|
18
|
+
get(key: string): Promise<JsResult>;
|
|
19
|
+
query(collection: string): Promise<JsResult>;
|
|
20
|
+
insert(key: string, value: string): Promise<JsResult>;
|
|
21
|
+
update(key: string, value: string): Promise<JsResult>;
|
|
22
|
+
delete(key: string): Promise<JsResult>;
|
|
23
|
+
/** Acquire a reference through the server's causal peer fabric. */
|
|
24
|
+
acquire(collection: string, id: string): Promise<unknown | null>;
|
|
25
|
+
/** Execute the built-in state-derived search capability remotely. */
|
|
26
|
+
search(collection: string, query: string, limit?: number): Promise<unknown[]>;
|
|
27
|
+
provenance(collection: string, id: string): Promise<any>;
|
|
28
|
+
storeContent(content: Uint8Array): Promise<{
|
|
29
|
+
hash: string;
|
|
30
|
+
bytes: number;
|
|
31
|
+
ref: string;
|
|
32
|
+
}>;
|
|
33
|
+
acquireContent(hash: string): Promise<Uint8Array | null>;
|
|
34
|
+
command(path: string, body: unknown): Promise<any>;
|
|
35
|
+
subscribe_changes(callback: (collection: string) => void): () => void;
|
|
36
|
+
private consumeEvents;
|
|
37
|
+
private failure;
|
|
38
|
+
get_capability_records(capability: string): Promise<JsResult>;
|
|
39
|
+
execute_op(): JsResult;
|
|
40
|
+
sync_info(): JsResult;
|
|
41
|
+
add_peer(): JsResult;
|
|
42
|
+
add_sync_peer(): JsResult;
|
|
43
|
+
remove_sync_peer(): JsResult;
|
|
44
|
+
get_pending_for_peer(): JsResult;
|
|
45
|
+
acknowledge_peer_operations(): JsResult;
|
|
46
|
+
instance_id(): string;
|
|
47
|
+
get_sequence(): number;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=http-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-db.d.ts","sourceRoot":"","sources":["../src/http-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,UAAU,QAAQ;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,iFAAiF;AACjF,qBAAa,QAAS,YAAW,IAAI;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,OAAO,EAAE,kBAAkB;IAKvC,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,QAAQ;IAQV,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAenC,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CA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