arcane-os 0.53.0 → 0.54.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/CHANGELOG.md +24 -0
- package/NOTICE +4 -1
- package/README.md +1 -1
- package/bin/arcane-test.mjs +2 -1
- package/browser-runtime/ai/browser-decisions.mjs +405 -0
- package/browser-runtime/ai/decision-runtime.mjs +281 -0
- package/browser-runtime/ai/decision-worker.mjs +67 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/index.js +1151 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/licence +21 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/package.json +61 -0
- package/browser-runtime/dependencies/event-pubsub/index.js +2 -2
- package/browser-runtime/dependencies/event-pubsub/package.json +11 -4
- package/browser-runtime/dependencies/ws-share/WS.js +128 -0
- package/browser-runtime/dependencies/ws-share/licence.md +27 -0
- package/browser-runtime/dependencies/ws-share/package.json +64 -0
- package/browser-runtime/websocket-client.mjs +1 -0
- package/docs/event-manager.md +7 -4
- package/docs/reference/ai/browser-decisions.md +184 -0
- package/docs/reference/inventory/package-api.json +30 -2
- package/docs/reference/inventory/runtime-modules.json +17 -4
- package/docs/reference/protocols.md +76 -1
- package/docs/reference/runtime-modules.md +45 -2
- package/docs/reference/sdk-api.md +133 -9
- package/docs/reference/websocket-client.md +132 -0
- package/node_modules/event-pubsub/CHANGELOG.md +12 -1
- package/node_modules/event-pubsub/MIGRATION.md +8 -5
- package/node_modules/event-pubsub/README.md +75 -19
- package/node_modules/event-pubsub/SECURITY.md +3 -3
- package/node_modules/event-pubsub/index.js +2 -2
- package/node_modules/event-pubsub/package.json +11 -4
- package/package.json +8 -5
- package/runtime/arcane/modules/HTMLImport.js +81 -26
- package/runtime/arcane/modules/HTMLImportScript.js +3 -0
- package/src/import-map.mjs +416 -59
- package/src/index.mjs +1 -0
- package/src/packager/core.mjs +24 -6
- package/src/packager/native-modules.mjs +458 -0
- package/src/testing-loader.mjs +41 -20
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Brandon Nozaki Miller
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "strong-type",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Dependency-free native ESM type enforcement for JavaScript values, objects, classes, browsers, and Node.",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./index.js": "./index.js",
|
|
10
|
+
"./node": "./node.js",
|
|
11
|
+
"./node.js": "./node.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"index.js",
|
|
16
|
+
"node.js",
|
|
17
|
+
"assets/strong-type-header.png",
|
|
18
|
+
"README.md",
|
|
19
|
+
"licence"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"directories": {
|
|
23
|
+
"example": "example"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=12.21.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "node scripts/test.js",
|
|
30
|
+
"test:core": "node scripts/test.js core",
|
|
31
|
+
"test:node": "node scripts/test.js node",
|
|
32
|
+
"test:docs": "node scripts/test.js docs",
|
|
33
|
+
"test:legacy": "node scripts/test.js legacy",
|
|
34
|
+
"coverage": "node --test --experimental-test-coverage --test-coverage-include=index.js --test-coverage-include=node.js --test-coverage-lines=95 --test-coverage-branches=90 --test-coverage-functions=95 test/CI.js test/node.js test/docs.js",
|
|
35
|
+
"start": "node scripts/serve.js",
|
|
36
|
+
"nodeExample": "node ./example/node/typecheck.js",
|
|
37
|
+
"check": "npm test"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/RIAEvangelist/strong-type.git"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"strong",
|
|
45
|
+
"type",
|
|
46
|
+
"validation",
|
|
47
|
+
"validate",
|
|
48
|
+
"check",
|
|
49
|
+
"checking",
|
|
50
|
+
"esm",
|
|
51
|
+
"isomorphic",
|
|
52
|
+
"browser",
|
|
53
|
+
"node"
|
|
54
|
+
],
|
|
55
|
+
"author": "Roshi _ _",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/RIAEvangelist/strong-type/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://riaevangelist.github.io/strong-type/"
|
|
61
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
import Is from '
|
|
1
|
+
// Preserve the package manager's dependency boundary instead of reaching for a consumer-root sibling.
|
|
2
|
+
import Is from 'strong-type';
|
|
3
3
|
|
|
4
4
|
const is = new Is();
|
|
5
5
|
const ALL_EVENTS = Symbol.for('event-pubsub-all');
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "event-pubsub",
|
|
3
|
-
"version": "6.1.
|
|
4
|
-
"description": "Small, synchronous
|
|
3
|
+
"version": "6.1.1",
|
|
4
|
+
"description": "Small, synchronous publish/subscribe events for Node.js plus bundled and unbundled browsers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
7
|
+
"browser": "./index.js",
|
|
7
8
|
"engines": {
|
|
8
9
|
"node": ">=22.12.0"
|
|
9
10
|
},
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
"test:unit": "npm run stage && node ./test-runtime/event-pubsub/test/node.js unit",
|
|
14
15
|
"test:functional": "npm run stage && node ./test-runtime/event-pubsub/test/node.js functional",
|
|
15
16
|
"test:integration": "npm run stage && node ./test-runtime/event-pubsub/test/node.js integration",
|
|
17
|
+
"test:behavioral": "npm run stage && node ./test-runtime/event-pubsub/test/node.js behavioral",
|
|
16
18
|
"test:regression": "npm run stage && node ./test-runtime/event-pubsub/test/node.js regression",
|
|
17
19
|
"test:interface": "npm run stage && node ./test-runtime/event-pubsub/test/node.js interface",
|
|
18
20
|
"coverage": "npm run stage && vanilla-test coverage all",
|
|
@@ -23,11 +25,12 @@
|
|
|
23
25
|
"benchmark:chart": "node ./scripts/benchmark-chart.js",
|
|
24
26
|
"benchmark:chart:check": "node ./scripts/benchmark-chart.js --check",
|
|
25
27
|
"test:package": "node ./scripts/package-smoke.js",
|
|
28
|
+
"test:browser-consumer": "node ./scripts/browser-consumer-smoke.js",
|
|
26
29
|
"site:check": "npm run stage && npm run benchmark:chart:check && node ./scripts/site-check.js",
|
|
27
30
|
"site:assemble": "node ./scripts/assemble-site.js _site",
|
|
28
31
|
"site:deployment-check": "node ./scripts/deployment-check.js _site",
|
|
29
32
|
"start": "node ./scripts/serve.js",
|
|
30
|
-
"verify": "npm test && npm run coverage && npm run benchmark:smoke && npm run test:package && npm run site:check && npm run site:assemble && npm run site:deployment-check"
|
|
33
|
+
"verify": "npm test && npm run coverage && npm run benchmark:smoke && npm run test:package && npm run test:browser-consumer && npm run site:check && npm run site:assemble && npm run site:deployment-check"
|
|
31
34
|
},
|
|
32
35
|
"repository": {
|
|
33
36
|
"type": "git",
|
|
@@ -46,7 +49,9 @@
|
|
|
46
49
|
"event-emitter",
|
|
47
50
|
"node",
|
|
48
51
|
"browser",
|
|
49
|
-
"esm"
|
|
52
|
+
"esm",
|
|
53
|
+
"import-map",
|
|
54
|
+
"unbundled"
|
|
50
55
|
],
|
|
51
56
|
"author": "Brandon Nozaki Miller",
|
|
52
57
|
"license": "MIT",
|
|
@@ -54,6 +59,8 @@
|
|
|
54
59
|
"strong-type": "2.0.0"
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|
|
62
|
+
"@rollup/plugin-node-resolve": "16.0.3",
|
|
63
|
+
"rollup": "4.62.5",
|
|
57
64
|
"vanilla-test": "2.1.1"
|
|
58
65
|
}
|
|
59
66
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const wsList = new Map();
|
|
2
|
+
const connections = new Set();
|
|
3
|
+
let nextId = 0;
|
|
4
|
+
let events;
|
|
5
|
+
|
|
6
|
+
class WS {
|
|
7
|
+
static async observe() {
|
|
8
|
+
if (!events) {
|
|
9
|
+
const {default: EventPubSub} = await import('event-pubsub');
|
|
10
|
+
events ??= new EventPubSub();
|
|
11
|
+
}
|
|
12
|
+
return events;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static getConnections() {
|
|
16
|
+
return Array.from(connections, describeConnection);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor(uri, protocols) {
|
|
20
|
+
if (!uri) {
|
|
21
|
+
throw new TypeError('WS requires a uri to initialize');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const address = String(uri);
|
|
25
|
+
const requestedProtocols = !protocols
|
|
26
|
+
? []
|
|
27
|
+
: typeof protocols !== 'string' && protocols[Symbol.iterator]
|
|
28
|
+
? Array.from(protocols, String)
|
|
29
|
+
: [String(protocols)];
|
|
30
|
+
const protocolKey = JSON.stringify(requestedProtocols);
|
|
31
|
+
let sockets = wsList.get(address);
|
|
32
|
+
const shared = sockets?.get(protocolKey);
|
|
33
|
+
|
|
34
|
+
if (shared && shared.readyState < 2) {
|
|
35
|
+
return shared;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ws = new globalThis.WebSocket(address, requestedProtocols);
|
|
39
|
+
|
|
40
|
+
if (!sockets) {
|
|
41
|
+
sockets = new Map();
|
|
42
|
+
wsList.set(address, sockets);
|
|
43
|
+
}
|
|
44
|
+
sockets.set(protocolKey, ws);
|
|
45
|
+
|
|
46
|
+
ws.addListener = ws.addEventListener;
|
|
47
|
+
ws.removeListener = ws.removeEventListener;
|
|
48
|
+
|
|
49
|
+
Object.defineProperties(
|
|
50
|
+
ws,
|
|
51
|
+
{
|
|
52
|
+
uri: {enumerable: true, value: uri},
|
|
53
|
+
protocols: {enumerable: true, value: protocols},
|
|
54
|
+
on: {enumerable: true, value: ws.addEventListener},
|
|
55
|
+
off: {enumerable: true, value: ws.removeEventListener}
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const connection = {id: ++nextId, socket: ws, protocols: requestedProtocols};
|
|
60
|
+
connections.add(connection);
|
|
61
|
+
|
|
62
|
+
function publishOpen(event) {
|
|
63
|
+
emitLifecycle(connection, 'open', event);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function publishError(event) {
|
|
67
|
+
emitLifecycle(connection, 'error', event);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ws.addEventListener(
|
|
71
|
+
'open',
|
|
72
|
+
publishOpen,
|
|
73
|
+
{once: true}
|
|
74
|
+
);
|
|
75
|
+
ws.addEventListener('error', publishError);
|
|
76
|
+
ws.addEventListener(
|
|
77
|
+
'close',
|
|
78
|
+
function releaseSocket(event) {
|
|
79
|
+
ws.removeEventListener('open', publishOpen);
|
|
80
|
+
ws.removeEventListener('error', publishError);
|
|
81
|
+
connections.delete(connection);
|
|
82
|
+
|
|
83
|
+
// A closing connection may already have a replacement.
|
|
84
|
+
if (sockets.get(protocolKey) === ws) {
|
|
85
|
+
sockets.delete(protocolKey);
|
|
86
|
+
if (sockets.size === 0) {
|
|
87
|
+
wsList.delete(address);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
emitLifecycle(connection, 'close', event);
|
|
91
|
+
},
|
|
92
|
+
{once: true}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (events) {
|
|
96
|
+
// Observer failures must not turn successful construction into a throw.
|
|
97
|
+
queueMicrotask(
|
|
98
|
+
function publishCreated() {
|
|
99
|
+
emitLifecycle(connection, 'created');
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return ws;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function describeConnection(connection) {
|
|
109
|
+
return {
|
|
110
|
+
id: connection.id,
|
|
111
|
+
socket: connection.socket,
|
|
112
|
+
url: connection.socket.url,
|
|
113
|
+
protocols: [...connection.protocols],
|
|
114
|
+
readyState: connection.socket.readyState
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function emitLifecycle(connection, type, event) {
|
|
119
|
+
if (!events) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const detail = describeConnection(connection);
|
|
123
|
+
detail.event = event;
|
|
124
|
+
events.emit(type, detail);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export {WS, WS as 'module.exports'};
|
|
128
|
+
export default WS;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# DON'T BE A DICK PUBLIC LICENSE
|
|
2
|
+
|
|
3
|
+
> Version 1, December 2009
|
|
4
|
+
|
|
5
|
+
> Copyright (C) 2009 Philip Sturgeon <email@philsturgeon.co.uk>
|
|
6
|
+
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
8
|
+
copies of this license document, and changing it is allowed as long
|
|
9
|
+
as the name is changed.
|
|
10
|
+
|
|
11
|
+
> DON'T BE A DICK PUBLIC LICENSE
|
|
12
|
+
> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
13
|
+
|
|
14
|
+
1. Do whatever you like with the original work, just don't be a dick.
|
|
15
|
+
|
|
16
|
+
Being a dick includes - but is not limited to - the following instances:
|
|
17
|
+
|
|
18
|
+
1a. Outright copyright infringement - Don't just copy this and change the name.
|
|
19
|
+
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
|
|
20
|
+
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
|
|
21
|
+
|
|
22
|
+
2. If you become rich through modifications, related works/services, or supporting the original work,
|
|
23
|
+
share the love. Only a dick would make loads off this work and not buy the original work's
|
|
24
|
+
creator(s) a pint.
|
|
25
|
+
|
|
26
|
+
3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
|
|
27
|
+
you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ws-share",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "Share native WebSocket connections across Node.js modules and browser components, with optional lifecycle events.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./WS.js",
|
|
7
|
+
"browser": "./WS.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"WS.js",
|
|
10
|
+
"ws-share-vanilla.js",
|
|
11
|
+
"CHANGELOG.md",
|
|
12
|
+
"licence.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "node test/ws-share.test.js",
|
|
16
|
+
"build:browser": "node scripts/browser.js",
|
|
17
|
+
"prepack": "npm run build:browser",
|
|
18
|
+
"start": "node devServer.js"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/RIAEvangelist/ws-share.git"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.13.0"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react",
|
|
29
|
+
"react.js",
|
|
30
|
+
"reactjs",
|
|
31
|
+
"websocket",
|
|
32
|
+
"websockets",
|
|
33
|
+
"web",
|
|
34
|
+
"socket",
|
|
35
|
+
"sockets",
|
|
36
|
+
"share",
|
|
37
|
+
"shared",
|
|
38
|
+
"sharing",
|
|
39
|
+
"ws",
|
|
40
|
+
"list",
|
|
41
|
+
"common",
|
|
42
|
+
"flux",
|
|
43
|
+
"reflux",
|
|
44
|
+
"component",
|
|
45
|
+
"components",
|
|
46
|
+
"store",
|
|
47
|
+
"stores",
|
|
48
|
+
"action",
|
|
49
|
+
"actions",
|
|
50
|
+
"vanilla"
|
|
51
|
+
],
|
|
52
|
+
"author": "Brandon Nozaki Miller",
|
|
53
|
+
"license": "DBAD",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/RIAEvangelist/ws-share/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://riaevangelist.github.io/ws-share/",
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"event-pubsub": "6.1.1"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"vanilla-test": "2.1.3"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default, WS} from 'ws-share';
|
package/docs/event-manager.md
CHANGED
|
@@ -253,10 +253,13 @@ other privileged effects.
|
|
|
253
253
|
## Browser delivery boundary
|
|
254
254
|
|
|
255
255
|
The package entry point works directly in Node and through browser bundlers.
|
|
256
|
-
The npm artifact
|
|
257
|
-
`event-pubsub@6.1.
|
|
258
|
-
|
|
259
|
-
for the public SDK entry and
|
|
256
|
+
The npm artifact retains its bundled `event-pubsub` and `strong-type`
|
|
257
|
+
dependencies. `event-pubsub@6.1.1` resolves its declared `strong-type@2.0.0`
|
|
258
|
+
through the package boundary, while the SDK's direct version remains 2.0.1.
|
|
259
|
+
Unbundled browser use provides mappings for the public SDK entry and
|
|
260
|
+
`event-pubsub`, plus the event package's scoped strong-type mapping. The
|
|
261
|
+
canonical browser projection generator copies those installed runtime files
|
|
262
|
+
unchanged; managed physical and installed-package maps preserve their scope.
|
|
260
263
|
|
|
261
264
|
The managed Arcane browser runtime ships the focused entry and its
|
|
262
265
|
dependency closure. Its import map resolves `arcane-os/event-manager` exactly;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Browser typed decisions
|
|
2
|
+
|
|
3
|
+
`arcane-os/ai/browser-decisions` owns browser-local Laya typed-decisions FP16
|
|
4
|
+
and Julia-1 FP32 inference. It is separate from chat and speech because these
|
|
5
|
+
models score caller-supplied options instead of generating conversational text.
|
|
6
|
+
Applications supply the model repository, state, questions, option meanings and
|
|
7
|
+
policy; the SDK owns the reusable tokenizer, tensors, inference and lifecycle.
|
|
8
|
+
|
|
9
|
+
## Explicit use
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import {createBrowserDecisionModel} from 'arcane-os/ai/browser-decisions';
|
|
13
|
+
|
|
14
|
+
const model = createBrowserDecisionModel(
|
|
15
|
+
{
|
|
16
|
+
family: 'laya',
|
|
17
|
+
model: 'onnx-community/laya-typed-decisions-ONNX',
|
|
18
|
+
revision: 'main',
|
|
19
|
+
device: 'webgpu'
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const unsubscribe = model.subscribe(
|
|
24
|
+
function showModelStatus(state) {
|
|
25
|
+
status.textContent = state.progress?.phase ?? state.state;
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
runButton.addEventListener(
|
|
30
|
+
'click',
|
|
31
|
+
async function decideDragonTea() {
|
|
32
|
+
try {
|
|
33
|
+
const result = await model.evaluate(
|
|
34
|
+
[
|
|
35
|
+
{
|
|
36
|
+
state: 'A sleeping dragon blocks the kitchen. The kettle whistles.',
|
|
37
|
+
question: 'What should the tea robot do?',
|
|
38
|
+
options: ['Wait quietly', 'Boil the kettle']
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
);
|
|
42
|
+
output.textContent = result.decisions[0].value;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('The decision request failed.', error);
|
|
45
|
+
status.textContent = 'The decision could not be completed.';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Here `status`, `runButton` and `output` are application DOM elements. Changing
|
|
52
|
+
the state, question or options changes the actual model request. Importing the
|
|
53
|
+
module and constructing the client start no Worker or download. Only explicit
|
|
54
|
+
`load()` or `evaluate()` use loads the selected runtime and model. Concurrent
|
|
55
|
+
requests share the same activation; ready inference reuses that model session.
|
|
56
|
+
|
|
57
|
+
For Julia, select `family: 'julia'` and
|
|
58
|
+
`model: 'SupersonicLabs/Julia-1-ONNX'`. This selects the official FP32 graph;
|
|
59
|
+
it does not substitute a quantized graph or another model.
|
|
60
|
+
|
|
61
|
+
## Configuration and upstream delivery
|
|
62
|
+
|
|
63
|
+
| Field | Meaning |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `family` | Required `laya` or `julia`; chooses the model's encoding and graph layout. |
|
|
66
|
+
| `model` | Required upstream repository/base URL accepted by Transformers.js. The application owns its selection. |
|
|
67
|
+
| `revision` | Upstream revision, default `main`; select a stable revision when repeatable model selection is needed. |
|
|
68
|
+
| `device` | Transformers.js backend, default `webgpu`; an explicit supported alternative is caller-owned. No automatic backend fallback. |
|
|
69
|
+
| `runtime.moduleUrl` | Defaults to `https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0/dist/transformers.web.js`. An explicit compatible public runtime URL may be supplied. |
|
|
70
|
+
| `runtime.wasmPaths` | Optional upstream ONNX WASM location passed to the selected runtime's public environment API. |
|
|
71
|
+
|
|
72
|
+
The runtime, tokenizer and weights use normal upstream loading and caching;
|
|
73
|
+
the SDK does not redistribute them or create a second model store. Browser
|
|
74
|
+
network, cross-origin and backend availability still apply. WebGPU needs a
|
|
75
|
+
compatible browser/device context. Unsupported precision or backend errors
|
|
76
|
+
are returned, not replaced with a different model, backend or precision.
|
|
77
|
+
|
|
78
|
+
Laya selects `dtype: 'fp16'`, loading `onnx/model_fp16.onnx` and its
|
|
79
|
+
`model_fp16.onnx_data` companion through Transformers.js. The published mixed
|
|
80
|
+
precision graph retains selected operations/outputs in FP32; FP16 selection
|
|
81
|
+
does not claim every graph operation runs in half precision.
|
|
82
|
+
|
|
83
|
+
Julia selects `dtype: 'fp32'`, loading root `model.onnx` with the exact
|
|
84
|
+
`model.onnx.data` external-data name. Its custom five-input graph is loaded
|
|
85
|
+
through the public generic `PreTrainedModel` API, not a text-generation
|
|
86
|
+
pipeline. Existing Wllama, cloud, speech and chat APIs are unchanged.
|
|
87
|
+
|
|
88
|
+
## Complete rows and results
|
|
89
|
+
|
|
90
|
+
`evaluate(rows, {signal})` accepts an array in caller order. Each row has
|
|
91
|
+
string `state`, string `question`, string-array `options`, and optional
|
|
92
|
+
`type` defaulting to `choice`. Additional row fields remain in the returned
|
|
93
|
+
row without affecting inference. Neither strings nor option arrays are
|
|
94
|
+
trimmed, rewritten, clipped or capped by the SDK.
|
|
95
|
+
|
|
96
|
+
The model's required token framing puts the complete type/question header,
|
|
97
|
+
option markers/options and state into `input_ids`; accompanying inputs are
|
|
98
|
+
`attention_mask`, `marker_pos`, `marker_mask` and `qtype`. Right padding aligns
|
|
99
|
+
rows in a batch. Literal marker text inside supplied content remains content;
|
|
100
|
+
option positions identify only markers inserted by the encoding owner.
|
|
101
|
+
Tokenizer encoding is called without special-token insertion and without
|
|
102
|
+
the upstream batch-tokenizer truncation path.
|
|
103
|
+
|
|
104
|
+
The result is `{decisions, outputs}`. `decisions` follows input order and each
|
|
105
|
+
entry contains the original row record, option `logits`, unrounded raw-softmax
|
|
106
|
+
`probabilities`, the highest-logit `answerIndex`, and `value`:
|
|
107
|
+
|
|
108
|
+
| Type | `value` |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| `choice` | The complete selected option string. |
|
|
111
|
+
| `score` | Raw-softmax weighted zero-based option index. Applications map this to their own score scale. |
|
|
112
|
+
| `noul` | Probability of option 1; supply exactly `[falseOption, trueOption]` in that order. |
|
|
113
|
+
|
|
114
|
+
If the actual graph supplies `act_logits`, the entry additionally includes
|
|
115
|
+
complete `actionLogits`, unrounded `actionProbabilities`, and raw-softmax
|
|
116
|
+
`actProbability` at index 0. Julia's
|
|
117
|
+
published ONNX export has no action head; the SDK does not invent one.
|
|
118
|
+
|
|
119
|
+
`outputs` preserves every returned graph tensor, including padding and extra
|
|
120
|
+
named outputs, as `{type, dims, data}` with complete copied typed data. This
|
|
121
|
+
keeps model results available for explicit application interpretation and
|
|
122
|
+
diagnostics. Probabilities are raw model scores, not claimed calibrated
|
|
123
|
+
confidence, probabilities rounded to two decimal places, or policy decisions.
|
|
124
|
+
No result is inserted into chat history, memory extraction or DBOPFS.
|
|
125
|
+
|
|
126
|
+
## Lifecycle, events and cancellation
|
|
127
|
+
|
|
128
|
+
`status()` returns `{family, model, revision, device, dtype, state, loaded,
|
|
129
|
+
busy, activeRequests, progress, error}`. States are `unloaded`, `loading`,
|
|
130
|
+
`ready`, `error` and `disposed`. `subscribe(listener, {emitCurrent: true,
|
|
131
|
+
signal})` observes the owning Arcane event source, replays current state by
|
|
132
|
+
default and returns an unsubscribe function. Successful rows and graph results
|
|
133
|
+
return to the calling operation rather than lifecycle notifications. Complete
|
|
134
|
+
errors, including graph diagnostics when decoding fails, remain available in
|
|
135
|
+
`error`; they belong in developer diagnostics, not ordinary status text.
|
|
136
|
+
|
|
137
|
+
Work is acknowledged synchronously before loading/inference waits. Progress
|
|
138
|
+
reports real semantic phases such as `waiting-for-model`, `loading-runtime`, `loading-tokenizer`,
|
|
139
|
+
`loading-model`, `ready`, `evaluating` and `complete`; it is not a synthetic
|
|
140
|
+
percentage. Loading the model and tokenizer proceeds concurrently. Repeated
|
|
141
|
+
identical state text is tokenized once per batch. Independent requests are
|
|
142
|
+
accepted concurrently; the selected backend still owns its execution ordering.
|
|
143
|
+
|
|
144
|
+
`load({signal})` explicitly prepares the shared activation. `evaluate()` also
|
|
145
|
+
loads on its first explicit use. An `AbortSignal`, `unload()` or `dispose()`
|
|
146
|
+
terminates the client's dedicated Worker and rejects all its outstanding
|
|
147
|
+
operations. Cancellation is client-wide because the model session and GPU
|
|
148
|
+
work belong to that Worker. Use separate clients when independent cancellation
|
|
149
|
+
is required. `unload()` permits later explicit reactivation; `dispose()` is
|
|
150
|
+
terminal. Old Worker replies cannot affect a replacement activation.
|
|
151
|
+
|
|
152
|
+
A Worker operation failure releases the failed activation and rejects its
|
|
153
|
+
waiting calls. The next explicit use starts a fresh Worker rather than reusing
|
|
154
|
+
an upstream inference queue that may remain rejected after a backend failure.
|
|
155
|
+
Error records preserve the original
|
|
156
|
+
name, message, stack, code, cause and available custom fields across the Worker
|
|
157
|
+
boundary. Applications keep technical diagnostics out of ordinary user status.
|
|
158
|
+
|
|
159
|
+
## Model limits and evidence
|
|
160
|
+
|
|
161
|
+
The published Laya and Julia families advertise an 8192-token native context.
|
|
162
|
+
Their reference wrappers apply smaller budgets and, for Julia, a documented
|
|
163
|
+
2–20-option interface. The SDK does not reproduce those wrapper clipping or
|
|
164
|
+
rounding policies or claim arbitrary lengths are supported by the graph.
|
|
165
|
+
Actual model/backend failures remain observable. Long-input quality and
|
|
166
|
+
option-count behavior must be established for the application's selected
|
|
167
|
+
model; no hidden windowing or result aggregation is performed.
|
|
168
|
+
|
|
169
|
+
Julia's Transformers.js tokenizer route exists in the official browser
|
|
170
|
+
adapter, alongside a Rust tokenizer. Repeated-space/Metaspace segmentation can
|
|
171
|
+
differ between those tokenizer implementations. Complete text is preserved at
|
|
172
|
+
the tokenizer boundary, and Python/Rust token-ID or numerical parity is not
|
|
173
|
+
claimed. Applications needing that parity must use an established compatible
|
|
174
|
+
tokenizer contract rather than silently rewriting text.
|
|
175
|
+
|
|
176
|
+
Upstream graph/loading contracts were reviewed from primary source. Browser
|
|
177
|
+
model loading, FP16/FP32 inference, cancellation and numerical behavior require
|
|
178
|
+
selected-output verification; static compatibility review alone is not a
|
|
179
|
+
runtime pass.
|
|
180
|
+
|
|
181
|
+
Primary references: [Laya ONNX](https://huggingface.co/onnx-community/laya-typed-decisions-ONNX),
|
|
182
|
+
[Laya reference](https://github.com/NandhaKishorM/laya),
|
|
183
|
+
[Julia-1 ONNX](https://huggingface.co/SupersonicLabs/Julia-1-ONNX),
|
|
184
|
+
[Transformers.js 4.3.0](https://github.com/huggingface/transformers.js/tree/4.3.0/packages/transformers).
|
|
@@ -6,12 +6,40 @@
|
|
|
6
6
|
"minimumVersion": "22.23.2 for Node entrypoints",
|
|
7
7
|
"moduleSystem": "ESM"
|
|
8
8
|
},
|
|
9
|
-
"memberCount":
|
|
9
|
+
"memberCount": 226,
|
|
10
10
|
"runtimeSubpathPatterns": {
|
|
11
11
|
"arcane-os/modules/*": "./runtime/arcane/modules/*",
|
|
12
12
|
"arcane-os/entities/*": "./runtime/arcane/entities/*"
|
|
13
13
|
},
|
|
14
14
|
"members": [
|
|
15
|
+
{
|
|
16
|
+
"id": "root:WS",
|
|
17
|
+
"name": "WS",
|
|
18
|
+
"displayName": "WS",
|
|
19
|
+
"kind": "class",
|
|
20
|
+
"signature": "new WS(uri,protocols?)",
|
|
21
|
+
"entrypoints": ["arcane-os", "arcane-os/websocket-client"],
|
|
22
|
+
"primaryImport": "arcane-os/websocket-client",
|
|
23
|
+
"group": "Shared WebSocket clients",
|
|
24
|
+
"summary": "Published ws-share constructor with shared native sockets, one lifecycle observer and current connection snapshots.",
|
|
25
|
+
"availability": "Node and browser hosts with native WebSocket; browser use requires the focused managed module entry",
|
|
26
|
+
"protocol": "Native WebSocket per-socket events plus event-pubsub created/open/error/close and wildcard lifecycle records",
|
|
27
|
+
"normalization": "Exact native socket and complete messages; URI plus ordered requested protocols select the per-loaded-module pool"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "browser-decisions:createBrowserDecisionModel",
|
|
31
|
+
"name": "createBrowserDecisionModel",
|
|
32
|
+
"displayName": "createBrowserDecisionModel()",
|
|
33
|
+
"kind": "function",
|
|
34
|
+
"signature": "createBrowserDecisionModel({family,model,revision,device,runtime})",
|
|
35
|
+
"entrypoints": ["arcane-os/ai/browser-decisions"],
|
|
36
|
+
"primaryImport": "arcane-os/ai/browser-decisions",
|
|
37
|
+
"group": "Browser typed decisions",
|
|
38
|
+
"summary": "Explicit-load Laya FP16 and Julia-1 FP32 decisions with complete inputs and graph results.",
|
|
39
|
+
"availability": "Browser module Workers and the selected Transformers.js backend; import/construction starts no model load",
|
|
40
|
+
"protocol": "Caller-owned state/question/options rows; five-input decision graph; native Worker request/result lifecycle",
|
|
41
|
+
"normalization": "Full field tokenization, raw logits and unrounded softmax; no policy thresholds, storage or precision fallback"
|
|
42
|
+
},
|
|
15
43
|
{
|
|
16
44
|
"id": "root:acceptWebSocket",
|
|
17
45
|
"name": "acceptWebSocket",
|
|
@@ -2137,7 +2165,7 @@
|
|
|
2137
2165
|
"name": "verifyApp",
|
|
2138
2166
|
"displayName": "verifyApp()",
|
|
2139
2167
|
"kind": "function",
|
|
2140
|
-
"signature": "async verifyApp({workspaceRoot, appId, signal, onEvent})",
|
|
2168
|
+
"signature": "async verifyApp({workspaceRoot, appId, outputDirectory, signal, onEvent})",
|
|
2141
2169
|
"entrypoints": [
|
|
2142
2170
|
"arcane-os",
|
|
2143
2171
|
"arcane-os/packager"
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"sdkVersion": "0.51.1",
|
|
9
9
|
"protocol": "arcane/1"
|
|
10
10
|
},
|
|
11
|
-
"artifactCount":
|
|
12
|
-
"javascriptArtifactCount":
|
|
13
|
-
"esmExportCount":
|
|
11
|
+
"artifactCount": 93,
|
|
12
|
+
"javascriptArtifactCount": 91,
|
|
13
|
+
"esmExportCount": 373,
|
|
14
14
|
"artifacts": [
|
|
15
15
|
{
|
|
16
16
|
"file": "runtime/arcane/modules/AI.js",
|
|
@@ -719,12 +719,25 @@
|
|
|
719
719
|
"exports": [
|
|
720
720
|
"default"
|
|
721
721
|
],
|
|
722
|
-
"summary": "Defines the same-origin `<html-import>` loader with open shadow root, inline script execution, and readiness/error events.",
|
|
722
|
+
"summary": "Defines the same-origin `<html-import>` loader with open shadow root, inline or packaged external script execution, and readiness/error events.",
|
|
723
723
|
"availability": "Browser / native WebView",
|
|
724
724
|
"protocol": "Same-origin fetch + DOM",
|
|
725
725
|
"normalization": "Public error detail normalized; fetch/DOM failure preserved.",
|
|
726
726
|
"surface": "default `HTMLImport`; registers `html-import`; `connectedCallback()` and `ready`."
|
|
727
727
|
},
|
|
728
|
+
{
|
|
729
|
+
"file": "runtime/arcane/modules/HTMLImportScript.js",
|
|
730
|
+
"name": "HTMLImportScript.js",
|
|
731
|
+
"kind": "esm",
|
|
732
|
+
"exports": [
|
|
733
|
+
"createHTMLImportScript"
|
|
734
|
+
],
|
|
735
|
+
"summary": "Renders the complete classic-script host wrapper shared by HTMLImport and native-module packaging.",
|
|
736
|
+
"availability": "Cross-host",
|
|
737
|
+
"protocol": "In-process only",
|
|
738
|
+
"normalization": "Complete source retained with a terminating newline before the wrapper closes.",
|
|
739
|
+
"surface": "`createHTMLImportScript(source)` returns the script text without executing it."
|
|
740
|
+
},
|
|
728
741
|
{
|
|
729
742
|
"file": "runtime/arcane/modules/InMemoryCommunicationProvider.js",
|
|
730
743
|
"name": "InMemoryCommunicationProvider.js",
|