@mowaos/host-browser 0.0.0-stage → 0.5.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/LICENSE +201 -0
- package/NOTICE +8 -0
- package/README.md +31 -2
- package/dist/host.d.ts +91 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +232 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +33 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +63 -0
- package/dist/kernel.js.map +1 -0
- package/dist/locks.d.ts +24 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +46 -0
- package/dist/locks.js.map +1 -0
- package/dist/outbox.d.ts +68 -0
- package/dist/outbox.d.ts.map +1 -0
- package/dist/outbox.js +212 -0
- package/dist/outbox.js.map +1 -0
- package/dist/storage.d.ts +104 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +466 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +232 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +42 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +21 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +121 -0
- package/dist/validation.js.map +1 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
MO·WA OS Kernel
|
|
2
|
+
Copyright 2026 Bruce Gardiner (ScrAtcH)
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0.
|
|
5
|
+
See the LICENSE file for the full licence text.
|
|
6
|
+
|
|
7
|
+
"MO·WA" and "MO·WA OS" are trademarks of Bruce Gardiner (ScrAtcH).
|
|
8
|
+
See TRADEMARKS.md. The Apache License does not grant trademark rights.
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mowaos/host-browser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Browser host for the [MO·WA OS kernel](../../README.md). It runs the kernel's WASM build
|
|
4
|
+
in the browser and provides what the kernel deliberately leaves out:
|
|
5
|
+
|
|
6
|
+
- **Storage:** `IndexedDbStorage` (and `MemoryStorage` for tests), with atomic commits
|
|
7
|
+
and compare-and-swap on the session version.
|
|
8
|
+
- **Locking:** `WebLocksSessionLock` serialises work per session across tabs.
|
|
9
|
+
- **Outbox:** `OutboxDispatcher` runs side effects with exponential backoff. Effects
|
|
10
|
+
that need a person's approval wait in `AWAIT_CONFIRMATION` until confirmed or rejected.
|
|
11
|
+
- **Input validation** at the boundary, before anything reaches the kernel.
|
|
12
|
+
- **Verification:** every step's event, facts and context are kept with its commit,
|
|
13
|
+
and `exportVerificationBundle(sessionIds)` exports a case so anyone can replay its
|
|
14
|
+
decisions with the open kernel.
|
|
15
|
+
|
|
16
|
+
The kernel's WASM module is passed in, not bundled, so you control which verified
|
|
17
|
+
build you run:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import init, * as wasm from "./pkg-web/mowa_wasm.js";
|
|
21
|
+
import { MowaBrowserHost, WasmKernelBridge, IndexedDbStorage, WebLocksSessionLock } from "@mowaos/host-browser";
|
|
22
|
+
|
|
23
|
+
await init();
|
|
24
|
+
const host = new MowaBrowserHost(new WasmKernelBridge(wasm), {
|
|
25
|
+
storage: new IndexedDbStorage(),
|
|
26
|
+
lock: new WebLocksSessionLock(),
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
What every host must guarantee is specified in the
|
|
31
|
+
[host contract](../../docs/host-contract.md). Each release attaches the WASM build and its
|
|
32
|
+
SHA-256 checksum. Licensed under Apache-2.0.
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MowaBrowserHost: The Primary Browser Runtime Coordinator.
|
|
3
|
+
*
|
|
4
|
+
* Implements the atomic Read-Compute-Write cycle:
|
|
5
|
+
* 1. Acquire session mutex via `SessionLock` (`navigator.locks`).
|
|
6
|
+
* 2. Idempotency fast-path lookup with `intentHash` conflict checking.
|
|
7
|
+
* 3. Read current `WorkflowSession` from `sessions` store.
|
|
8
|
+
* 4. Execute pure transition in WASM kernel via `WasmKernelBridge` (auto-reloading on handle eviction).
|
|
9
|
+
* 5. Atomic commit across `sessions`, `idempotency`, `audit_log`, `outbox`, `steps`
|
|
10
|
+
* (the step record keeps the event, facts and context, so the decision can be replayed).
|
|
11
|
+
* 6. Release lock.
|
|
12
|
+
* 7. Asynchronously trigger `OutboxDispatcher` outside the lock.
|
|
13
|
+
*/
|
|
14
|
+
import { WasmKernelBridge } from "./kernel.js";
|
|
15
|
+
import { type SessionLock } from "./locks.js";
|
|
16
|
+
import { OutboxDispatcher } from "./outbox.js";
|
|
17
|
+
import { type MowaStorage } from "./storage.js";
|
|
18
|
+
import { type Commit, type OutboxRecord, type OutboxStatus, type VerificationBundle } from "./types.js";
|
|
19
|
+
export interface MowaBrowserHostOptions {
|
|
20
|
+
storage?: MowaStorage;
|
|
21
|
+
lock?: SessionLock;
|
|
22
|
+
outboxDispatcher?: OutboxDispatcher;
|
|
23
|
+
}
|
|
24
|
+
export declare class MowaBrowserHost {
|
|
25
|
+
private readonly kernel;
|
|
26
|
+
private readonly storage;
|
|
27
|
+
private readonly lock;
|
|
28
|
+
private readonly outbox;
|
|
29
|
+
private readonly flowHandles;
|
|
30
|
+
constructor(kernel: WasmKernelBridge, options?: MowaBrowserHostOptions);
|
|
31
|
+
getStorage(): MowaStorage;
|
|
32
|
+
getOutbox(): OutboxDispatcher;
|
|
33
|
+
getOutboxByStatus(status: OutboxStatus, limit?: number): Promise<OutboxRecord[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Install and validate a flow definition.
|
|
36
|
+
* Caches in WASM memory and writes to the `flows` store ONCE.
|
|
37
|
+
*/
|
|
38
|
+
installFlow(flowRaw: unknown): Promise<{
|
|
39
|
+
flowHash: string;
|
|
40
|
+
flowHandle: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve an active flow handle, loading it from storage if not yet cached in WASM.
|
|
44
|
+
*/
|
|
45
|
+
private resolveFlow;
|
|
46
|
+
/**
|
|
47
|
+
* Operator confirmation API for human-in-the-loop review.
|
|
48
|
+
*/
|
|
49
|
+
confirmEffect(outboxId: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Operator rejection API for human-in-the-loop review.
|
|
52
|
+
*/
|
|
53
|
+
rejectEffect(outboxId: string, reason: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Operator recovery API to requeue a failed dead-letter task back to pending.
|
|
56
|
+
*/
|
|
57
|
+
requeueEffect(outboxId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns earliest timestamp when a pending outbox effect is due.
|
|
60
|
+
*/
|
|
61
|
+
getNextDueAt(): Promise<number | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Start a new workflow session.
|
|
64
|
+
*/
|
|
65
|
+
startSession(params: {
|
|
66
|
+
sessionId: string;
|
|
67
|
+
event: unknown;
|
|
68
|
+
flowHash: string;
|
|
69
|
+
ctx: unknown;
|
|
70
|
+
}): Promise<Commit>;
|
|
71
|
+
/**
|
|
72
|
+
* Advance an existing workflow session.
|
|
73
|
+
*/
|
|
74
|
+
advanceSession(params: {
|
|
75
|
+
sessionId: string;
|
|
76
|
+
event: unknown;
|
|
77
|
+
facts?: unknown;
|
|
78
|
+
ctx: unknown;
|
|
79
|
+
}): Promise<Commit>;
|
|
80
|
+
/**
|
|
81
|
+
* Export everything needed to verify the given sessions without access to this host
|
|
82
|
+
* (docs/host-contract.md, section 6.1): every step's inputs and commit, and every flow
|
|
83
|
+
* they used. `contextData` is copied into the bundle as given, for the reference data
|
|
84
|
+
* named in `contextRefs`.
|
|
85
|
+
*
|
|
86
|
+
* Throws if a session has no complete step history (for example, one committed by a
|
|
87
|
+
* host version before 0.5.0, which did not keep step inputs).
|
|
88
|
+
*/
|
|
89
|
+
exportVerificationBundle(sessionIds: string[], contextData?: Record<string, unknown>): Promise<VerificationBundle>;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAKL,KAAK,MAAM,EAIX,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAQpB,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,qBAAa,eAAe;IAOxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,IAAI,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IACG,wBAAwB,CAC5B,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACxC,OAAO,CAAC,kBAAkB,CAAC;CA2C/B"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MowaBrowserHost: The Primary Browser Runtime Coordinator.
|
|
3
|
+
*
|
|
4
|
+
* Implements the atomic Read-Compute-Write cycle:
|
|
5
|
+
* 1. Acquire session mutex via `SessionLock` (`navigator.locks`).
|
|
6
|
+
* 2. Idempotency fast-path lookup with `intentHash` conflict checking.
|
|
7
|
+
* 3. Read current `WorkflowSession` from `sessions` store.
|
|
8
|
+
* 4. Execute pure transition in WASM kernel via `WasmKernelBridge` (auto-reloading on handle eviction).
|
|
9
|
+
* 5. Atomic commit across `sessions`, `idempotency`, `audit_log`, `outbox`, `steps`
|
|
10
|
+
* (the step record keeps the event, facts and context, so the decision can be replayed).
|
|
11
|
+
* 6. Release lock.
|
|
12
|
+
* 7. Asynchronously trigger `OutboxDispatcher` outside the lock.
|
|
13
|
+
*/
|
|
14
|
+
import { MemorySessionLock } from "./locks.js";
|
|
15
|
+
import { OutboxDispatcher } from "./outbox.js";
|
|
16
|
+
import { MemoryStorage } from "./storage.js";
|
|
17
|
+
import { FlowHandleNotFoundError, IdempotencyConflictError, IncompleteStepHistoryError, } from "./types.js";
|
|
18
|
+
import { validateCanonicalEvent, validateDecisionContext, validateDecisionFacts, validateFlowDefinition, } from "./validation.js";
|
|
19
|
+
export class MowaBrowserHost {
|
|
20
|
+
kernel;
|
|
21
|
+
storage;
|
|
22
|
+
lock;
|
|
23
|
+
outbox;
|
|
24
|
+
flowHandles = new Map(); // flowHash -> flowHandle
|
|
25
|
+
constructor(kernel, options = {}) {
|
|
26
|
+
this.kernel = kernel;
|
|
27
|
+
this.storage = options.storage ?? new MemoryStorage();
|
|
28
|
+
this.lock = options.lock ?? new MemorySessionLock();
|
|
29
|
+
this.outbox = options.outboxDispatcher ?? new OutboxDispatcher(this.storage);
|
|
30
|
+
}
|
|
31
|
+
getStorage() {
|
|
32
|
+
return this.storage;
|
|
33
|
+
}
|
|
34
|
+
getOutbox() {
|
|
35
|
+
return this.outbox;
|
|
36
|
+
}
|
|
37
|
+
async getOutboxByStatus(status, limit) {
|
|
38
|
+
return await this.storage.getOutboxByStatus(status, limit);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Install and validate a flow definition.
|
|
42
|
+
* Caches in WASM memory and writes to the `flows` store ONCE.
|
|
43
|
+
*/
|
|
44
|
+
async installFlow(flowRaw) {
|
|
45
|
+
const flow = validateFlowDefinition(flowRaw);
|
|
46
|
+
const { flowHandle, flowHash } = this.kernel.loadFlow(flow);
|
|
47
|
+
await this.storage.saveFlow(flowHash, flow);
|
|
48
|
+
this.flowHandles.set(flowHash, flowHandle);
|
|
49
|
+
return { flowHash, flowHandle };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve an active flow handle, loading it from storage if not yet cached in WASM.
|
|
53
|
+
*/
|
|
54
|
+
async resolveFlow(flowHash) {
|
|
55
|
+
const cached = this.flowHandles.get(flowHash);
|
|
56
|
+
if (cached)
|
|
57
|
+
return cached;
|
|
58
|
+
const stored = await this.storage.getFlow(flowHash);
|
|
59
|
+
if (!stored) {
|
|
60
|
+
throw new Error(`Flow with hash '${flowHash}' not found in storage.`);
|
|
61
|
+
}
|
|
62
|
+
const { flowHandle } = this.kernel.loadFlow(stored);
|
|
63
|
+
this.flowHandles.set(flowHash, flowHandle);
|
|
64
|
+
return flowHandle;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Operator confirmation API for human-in-the-loop review.
|
|
68
|
+
*/
|
|
69
|
+
async confirmEffect(outboxId) {
|
|
70
|
+
await this.outbox.confirmEffect(outboxId);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Operator rejection API for human-in-the-loop review.
|
|
74
|
+
*/
|
|
75
|
+
async rejectEffect(outboxId, reason) {
|
|
76
|
+
await this.outbox.rejectEffect(outboxId, reason);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Operator recovery API to requeue a failed dead-letter task back to pending.
|
|
80
|
+
*/
|
|
81
|
+
async requeueEffect(outboxId) {
|
|
82
|
+
await this.outbox.requeueEffect(outboxId);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns earliest timestamp when a pending outbox effect is due.
|
|
86
|
+
*/
|
|
87
|
+
async getNextDueAt() {
|
|
88
|
+
return await this.outbox.getNextDueAt();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Start a new workflow session.
|
|
92
|
+
*/
|
|
93
|
+
async startSession(params) {
|
|
94
|
+
const event = validateCanonicalEvent(params.event);
|
|
95
|
+
const ctx = validateDecisionContext(params.ctx);
|
|
96
|
+
return await this.lock.acquire(params.sessionId, async () => {
|
|
97
|
+
// 1. Compute dedup key & intent hash, check idempotency store
|
|
98
|
+
const { dedupKey, intentHash } = this.kernel.dedupKey("START", params.sessionId, event);
|
|
99
|
+
const existing = await this.storage.getIdempotency(dedupKey);
|
|
100
|
+
if (existing) {
|
|
101
|
+
// Enforce intent hash match; accept legacy records without intentHash
|
|
102
|
+
if (existing.intentHash && existing.intentHash !== intentHash) {
|
|
103
|
+
throw new IdempotencyConflictError(dedupKey, existing.intentHash, intentHash);
|
|
104
|
+
}
|
|
105
|
+
return existing.commit;
|
|
106
|
+
}
|
|
107
|
+
// 2. Resolve flow handle (reloading from IDB if evicted)
|
|
108
|
+
let flow = await this.resolveFlow(params.flowHash);
|
|
109
|
+
// 3. Compute pure start transition in WASM
|
|
110
|
+
let commit;
|
|
111
|
+
try {
|
|
112
|
+
commit = this.kernel.start(params.sessionId, event, flow, ctx);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (err instanceof FlowHandleNotFoundError) {
|
|
116
|
+
this.flowHandles.delete(params.flowHash);
|
|
117
|
+
flow = await this.resolveFlow(params.flowHash);
|
|
118
|
+
commit = this.kernel.start(params.sessionId, event, flow, ctx);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// 4. Atomic commit with step inputs (INSERT expects null version)
|
|
125
|
+
await this.storage.atomicCommit(params.sessionId, null, commit, {
|
|
126
|
+
intentHash,
|
|
127
|
+
inputs: { call: "start", event, ctx },
|
|
128
|
+
});
|
|
129
|
+
return commit;
|
|
130
|
+
}).finally(() => {
|
|
131
|
+
// 5. Asynchronously trigger outbox outside the lock
|
|
132
|
+
void this.outbox.dispatchPending();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Advance an existing workflow session.
|
|
137
|
+
*/
|
|
138
|
+
async advanceSession(params) {
|
|
139
|
+
const event = validateCanonicalEvent(params.event);
|
|
140
|
+
const ctx = validateDecisionContext(params.ctx);
|
|
141
|
+
const facts = validateDecisionFacts(params.facts);
|
|
142
|
+
return await this.lock.acquire(params.sessionId, async () => {
|
|
143
|
+
// 1. Compute dedup key & intent hash, check idempotency store
|
|
144
|
+
const { dedupKey, intentHash } = this.kernel.dedupKey("ADVANCE", params.sessionId, event);
|
|
145
|
+
const existing = await this.storage.getIdempotency(dedupKey);
|
|
146
|
+
if (existing) {
|
|
147
|
+
// Enforce intent hash match; accept legacy records without intentHash
|
|
148
|
+
if (existing.intentHash && existing.intentHash !== intentHash) {
|
|
149
|
+
throw new IdempotencyConflictError(dedupKey, existing.intentHash, intentHash);
|
|
150
|
+
}
|
|
151
|
+
return existing.commit;
|
|
152
|
+
}
|
|
153
|
+
// 2. Read session snapshot
|
|
154
|
+
const session = await this.storage.getSession(params.sessionId);
|
|
155
|
+
if (!session) {
|
|
156
|
+
throw new Error(`Session '${params.sessionId}' not found.`);
|
|
157
|
+
}
|
|
158
|
+
// 3. Resolve pinned flow handle (reloading from IDB if evicted)
|
|
159
|
+
let flow = await this.resolveFlow(session.flowHash);
|
|
160
|
+
// 4. Compute pure advance transition in WASM
|
|
161
|
+
let commit;
|
|
162
|
+
try {
|
|
163
|
+
commit = this.kernel.advance(session, event, flow, facts, ctx);
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
if (err instanceof FlowHandleNotFoundError) {
|
|
167
|
+
this.flowHandles.delete(session.flowHash);
|
|
168
|
+
flow = await this.resolveFlow(session.flowHash);
|
|
169
|
+
commit = this.kernel.advance(session, event, flow, facts, ctx);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// 5. Atomic commit with step inputs and CAS check
|
|
176
|
+
await this.storage.atomicCommit(params.sessionId, session.version, commit, {
|
|
177
|
+
intentHash,
|
|
178
|
+
inputs: { call: "advance", event, facts, ctx },
|
|
179
|
+
});
|
|
180
|
+
return commit;
|
|
181
|
+
}).finally(() => {
|
|
182
|
+
// 6. Asynchronously trigger outbox outside the lock
|
|
183
|
+
void this.outbox.dispatchPending();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Export everything needed to verify the given sessions without access to this host
|
|
188
|
+
* (docs/host-contract.md, section 6.1): every step's inputs and commit, and every flow
|
|
189
|
+
* they used. `contextData` is copied into the bundle as given, for the reference data
|
|
190
|
+
* named in `contextRefs`.
|
|
191
|
+
*
|
|
192
|
+
* Throws if a session has no complete step history (for example, one committed by a
|
|
193
|
+
* host version before 0.5.0, which did not keep step inputs).
|
|
194
|
+
*/
|
|
195
|
+
async exportVerificationBundle(sessionIds, contextData = {}) {
|
|
196
|
+
const flows = {};
|
|
197
|
+
const sessions = [];
|
|
198
|
+
for (const sessionId of sessionIds) {
|
|
199
|
+
const session = await this.storage.getSession(sessionId);
|
|
200
|
+
if (!session) {
|
|
201
|
+
throw new Error(`Session '${sessionId}' not found.`);
|
|
202
|
+
}
|
|
203
|
+
const steps = await this.storage.getSteps(sessionId);
|
|
204
|
+
const complete = steps.length === session.version + 1 && steps.every((s, i) => s.version === i);
|
|
205
|
+
if (!complete) {
|
|
206
|
+
throw new IncompleteStepHistoryError(sessionId, steps.length, session.version);
|
|
207
|
+
}
|
|
208
|
+
for (const step of steps) {
|
|
209
|
+
const flowHash = step.commit.newSession.flowHash;
|
|
210
|
+
if (!(flowHash in flows)) {
|
|
211
|
+
const flow = await this.storage.getFlow(flowHash);
|
|
212
|
+
if (!flow) {
|
|
213
|
+
throw new Error(`Flow '${flowHash}' used by session '${sessionId}' is not in storage.`);
|
|
214
|
+
}
|
|
215
|
+
flows[flowHash] = flow;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
sessions.push({
|
|
219
|
+
sessionId,
|
|
220
|
+
steps: steps.map(({ call, event, facts, ctx, commit }) => call === "start" ? { call, event, ctx, commit } : { call, event, facts, ctx, commit }),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
format: "mowa.verification-bundle/1",
|
|
225
|
+
kernelVersion: this.kernel.getVersion(),
|
|
226
|
+
flows,
|
|
227
|
+
sessions,
|
|
228
|
+
contextData,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAoB,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAS3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,qBAAq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AM,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACjD,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC;oBACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oBAClD,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,sBAAsB,SAAS,sBAAsB,CAAC,CAAC;oBAC1F,CAAC;oBACD,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;gBACzB,CAAC;YACH,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC;gBACZ,SAAS;gBACT,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CACvD,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CACtF;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE,4BAA4B;YACpC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACvC,KAAK;YACL,QAAQ;YACR,WAAW;SACZ,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mowaos/host-browser - Public API
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./validation.js";
|
|
6
|
+
export * from "./storage.js";
|
|
7
|
+
export * from "./locks.js";
|
|
8
|
+
export * from "./kernel.js";
|
|
9
|
+
export * from "./outbox.js";
|
|
10
|
+
export * from "./host.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mowaos/host-browser - Public API
|
|
3
|
+
*/
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./validation.js";
|
|
6
|
+
export * from "./storage.js";
|
|
7
|
+
export * from "./locks.js";
|
|
8
|
+
export * from "./kernel.js";
|
|
9
|
+
export * from "./outbox.js";
|
|
10
|
+
export * from "./host.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/kernel.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM Kernel Bridge for MO·WA OS Browser Host.
|
|
3
|
+
* Bridges JavaScript calls to the Rust mowa-wasm module via JSON boundary.
|
|
4
|
+
*/
|
|
5
|
+
import { type CanonicalEvent, type Commit, type DecisionContext, type DecisionFacts, type FlowDefinition, type WorkflowSession } from "./types.js";
|
|
6
|
+
export interface WasmKernelModule {
|
|
7
|
+
startJson(req: string): string;
|
|
8
|
+
advanceJson(req: string): string;
|
|
9
|
+
dedupKeyJson(req: string): string;
|
|
10
|
+
loadFlowJson(flow: string): string;
|
|
11
|
+
kernelVersion(): string;
|
|
12
|
+
}
|
|
13
|
+
export declare class KernelExecutionError extends Error {
|
|
14
|
+
readonly status: string;
|
|
15
|
+
readonly details: unknown;
|
|
16
|
+
constructor(status: string, details: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare class WasmKernelBridge {
|
|
19
|
+
private readonly wasm;
|
|
20
|
+
constructor(wasm: WasmKernelModule);
|
|
21
|
+
getVersion(): string;
|
|
22
|
+
loadFlow(flow: FlowDefinition): {
|
|
23
|
+
flowHandle: string;
|
|
24
|
+
flowHash: string;
|
|
25
|
+
};
|
|
26
|
+
dedupKey(op: "START" | "ADVANCE", sessionId: string, event: CanonicalEvent): {
|
|
27
|
+
dedupKey: string;
|
|
28
|
+
intentHash: string;
|
|
29
|
+
};
|
|
30
|
+
start(sessionId: string, event: CanonicalEvent, flow: string | FlowDefinition, ctx: DecisionContext): Commit;
|
|
31
|
+
advance(session: WorkflowSession, event: CanonicalEvent, flow: string | FlowDefinition, facts: DecisionFacts, ctx: DecisionContext): Commit;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,cAAc,EAGnB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;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