@agentorg/cli 0.0.3 → 0.0.4
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 +14 -10
- package/dist/bundled/index.json +4 -4
- package/dist/bundled/{sha256-87e121cbe58279f3a633e61c9773b61fc17fd53eac3d7c6f037925cbfd5d5384.agentorg → sha256-01d69bc3888c2a53963f4413d47de909d129ad27c78e9af6d830bb50c3478419.agentorg} +0 -0
- package/dist/bundled/{sha256-51ecf151e590f5e57f28229d4cb36e4932a2f1670e50ddf1a3ccf335a1ee146d.agentorg → sha256-84165e3be5c904fc971d983dab31102e07cca725d8629a6fd7d118fa3a0a88b8.agentorg} +0 -0
- package/dist/bundled/sha256-ade9132b3f34b4c39db92adeadc7e540dc745e4a81b5b54f5d45bf9ec92bca75.agentorg +0 -0
- package/dist/bundled/{sha256-b76ec31282e5b863ee9569dfd9d50b283a21101cbe1b3fac23d1cbcf16b9a408.agentorg → sha256-f4330f5987f37d8cf3aeb44d2f831b573641a87186daa2f811f0c35ba04804f0.agentorg} +0 -0
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/build.d.ts +2 -2
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/build.js +14 -4
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/hub-actor.js +8 -0
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/index.d.ts +1 -1
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/index.js +1 -1
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/router.js +40 -16
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/state.d.ts +63 -0
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/state.js +177 -36
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/storage.d.ts +2 -1
- package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/storage.js +3 -2
- package/{node_modules → dist/node_modules}/@agentorg/hub/package.json +3 -0
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/hub.d.ts +43 -3
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/hub.js +40 -3
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/index.d.ts +1 -0
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/index.js +1 -0
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/installer.d.ts +37 -0
- package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/installer.js +34 -3
- package/dist/node_modules/@agentorg/interfaces/dist/src/rules.d.ts +35 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/rules.js +37 -0
- package/dist/node_modules/@agentorg/kit/dist/src/chat.d.ts +37 -0
- package/dist/node_modules/@agentorg/kit/dist/src/chat.js +131 -0
- package/dist/node_modules/@agentorg/kit/dist/src/components.d.ts +94 -0
- package/dist/node_modules/@agentorg/kit/dist/src/components.js +66 -0
- package/dist/node_modules/@agentorg/kit/dist/src/icons.d.ts +17 -0
- package/dist/node_modules/@agentorg/kit/dist/src/icons.js +30 -0
- package/dist/node_modules/@agentorg/kit/dist/src/index.d.ts +6 -0
- package/dist/node_modules/@agentorg/kit/dist/src/index.js +10 -0
- package/dist/node_modules/@agentorg/kit/dist/src/markdown.d.ts +9 -0
- package/dist/node_modules/@agentorg/kit/dist/src/markdown.js +14 -0
- package/dist/node_modules/@agentorg/kit/dist/src/resizable.d.ts +5 -0
- package/dist/node_modules/@agentorg/kit/dist/src/resizable.js +8 -0
- package/dist/node_modules/@agentorg/kit/dist/src/styles.d.ts +11 -0
- package/dist/node_modules/@agentorg/kit/dist/src/styles.js +166 -0
- package/dist/node_modules/@agentorg/kit/package.json +44 -0
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/frame/runtime.js +172 -17
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/host/runner.js +168 -11
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/client.d.ts +18 -0
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/client.js +24 -3
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.d.ts +8 -0
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.js +64 -0
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-entry.js +4 -4
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-host.d.ts +1 -10
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-host.js +0 -23
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-protocol.d.ts +0 -8
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame.d.ts +0 -2
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame.js +0 -8
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/host.js +5 -0
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/index.d.ts +1 -1
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/module-host.d.ts +6 -1
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/module-host.js +24 -1
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/module.d.ts +30 -1
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/package.js +111 -6
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/runtime.d.ts +22 -1
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/runtime.js +114 -0
- package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/testing.d.ts +14 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/testing.js +89 -0
- package/{node_modules → dist/node_modules}/@agentorg/shell/dist/app.css +27 -144
- package/dist/node_modules/@agentorg/shell/dist/app.js +219 -0
- package/{node_modules → dist/node_modules}/@agentorg/shell/package.json +1 -0
- package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/index.d.ts +1 -1
- package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/ops.d.ts +14 -1
- package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/ops.js +22 -2
- package/dist/src/cli.js +23 -0
- package/dist/src/gateway.js +42 -1
- package/dist/src/rules.d.ts +71 -0
- package/dist/src/rules.js +157 -0
- package/package.json +13 -16
- package/dist/bundled/sha256-e4c0e857cea3a721998effe2ca859c4011978b9bc36e63c058bfc17c27a1772e.agentorg +0 -0
- package/node_modules/@agentorg/sdk/dist/src/testing.js +0 -51
- package/node_modules/@agentorg/shell/dist/app.js +0 -9
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/hub-actor.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/logs.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/logs.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/net.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/net.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/processes.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/processes.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/router.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/server.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/server.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/validate-worker.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/validate-worker.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/validate.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/hub/dist/src/validate.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/account-login.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/account-login.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/chat.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/chat.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/http-egress.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/http-egress.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/kv.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/kv.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/layout.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/layout.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/llm-session.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/llm-session.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/storage-admin.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/storage-admin.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/ui-shell.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/ui-shell.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/ui-view.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/dist/src/ui-view.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/interfaces/package.json +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/build.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/build.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/canonical.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/canonical.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/cli.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/cli.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/client-http.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/client-http.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/describe.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/describe.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/errors.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/errors.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-entry.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/frame-protocol.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/host-main.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/host-main.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/host.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/index.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/interface.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/interface.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/manifest-api.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/manifest-api.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/manifest.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/manifest.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/module.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/package.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/person-commands.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/person-commands.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/tar.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/dist/src/tar.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/sdk/package.json +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/shell/dist/agent-bindings.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/shell/dist/index.html +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/shell/src/agent-bindings.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/bytes.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/bytes.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/frames.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/frames.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/index.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/transports.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/transports.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/yamux.d.ts +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/dist/src/yamux.js +0 -0
- /package/{node_modules → dist/node_modules}/@agentorg/wire/package.json +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base stylesheet every view's frame gets first, before the view's own: the document fills the
|
|
3
|
+
* frame on a transparent background, and plain HTML looks like the shell, drawn with the theme's
|
|
4
|
+
* tokens (`--fg`, `--surface`, `--accent`, … as the shell sends them at mount). Every rule is in
|
|
5
|
+
* `:where()`, so it has no specificity: any selector a view writes wins, and a view that wants its
|
|
6
|
+
* own look draws it.
|
|
7
|
+
*/
|
|
8
|
+
export const FRAME_BASE = `
|
|
9
|
+
:where(*, *::before, *::after) { box-sizing: border-box; }
|
|
10
|
+
:where(html, body) { height: 100%; margin: 0; background: transparent; }
|
|
11
|
+
:where(body) {
|
|
12
|
+
overflow: auto; scrollbar-width: none;
|
|
13
|
+
color: var(--fg); font: 14px/1.45 var(--font, ui-sans-serif, system-ui, sans-serif);
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
}
|
|
16
|
+
:where(body)::-webkit-scrollbar { display: none; }
|
|
17
|
+
:where(body > :only-child) { min-height: 100%; }
|
|
18
|
+
:where(h1, h2, h3, h4) { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.01em; }
|
|
19
|
+
:where(h1) { font-size: 20px; }
|
|
20
|
+
:where(h2) { font-size: 16px; }
|
|
21
|
+
:where(h3, h4) { font-size: 14px; }
|
|
22
|
+
:where(p) { margin: 0 0 8px; }
|
|
23
|
+
:where(small) { color: var(--muted); font-size: 12.5px; }
|
|
24
|
+
:where(a) { color: inherit; text-underline-offset: 2px; }
|
|
25
|
+
:where(hr) { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
|
|
26
|
+
:where(ul, ol) { margin: 0 0 10px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
|
|
27
|
+
:where(li) { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--raised); }
|
|
28
|
+
:where(button) {
|
|
29
|
+
height: 34px; padding: 0 12px; border: 0; border-radius: 9px; cursor: pointer;
|
|
30
|
+
background: var(--hover); color: var(--fg); font: inherit; font-weight: 500;
|
|
31
|
+
}
|
|
32
|
+
:where(button:hover) { background: var(--selected); }
|
|
33
|
+
:where(button:disabled) { opacity: 0.5; cursor: default; }
|
|
34
|
+
:where(button[type="submit"], button.primary) { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
|
|
35
|
+
:where(input:not([type]), input[type="text"], input[type="search"], input[type="number"], input[type="url"], input[type="email"], select) {
|
|
36
|
+
height: 34px; padding: 0 10px; border: 0; border-radius: 9px; outline: 0;
|
|
37
|
+
background: var(--raised); color: var(--fg); font: inherit;
|
|
38
|
+
}
|
|
39
|
+
:where(textarea) { padding: 8px 10px; border: 0; border-radius: 9px; outline: 0; resize: none; background: var(--raised); color: var(--fg); font: inherit; }
|
|
40
|
+
:where(input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible) { box-shadow: 0 0 0 1.5px var(--ring); outline: 0; }
|
|
41
|
+
:where(input[type="checkbox"]) {
|
|
42
|
+
appearance: none; width: 16px; height: 16px; margin: 0; flex: none; display: grid; place-items: center;
|
|
43
|
+
border: 1.5px solid var(--faint); border-radius: 5px; cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
:where(input[type="checkbox"]:checked) { background: var(--ok); border-color: var(--ok); }
|
|
46
|
+
:where(input[type="checkbox"]:checked)::after {
|
|
47
|
+
content: ""; width: 4px; height: 8px; border: solid white; border-width: 0 2px 2px 0;
|
|
48
|
+
transform: translateY(-1px) rotate(45deg);
|
|
49
|
+
}
|
|
50
|
+
:where(li:has(> input[type="checkbox"]:checked) > span) { color: var(--faint); text-decoration: line-through; }
|
|
51
|
+
:where(form) { display: flex; gap: 6px; }
|
|
52
|
+
:where(form > input, form > textarea) { flex: 1; min-width: 0; }
|
|
53
|
+
:where(table) { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
54
|
+
:where(th) { padding: 0 8px 6px; text-align: left; color: var(--faint); font-weight: 500; font-size: 12px; }
|
|
55
|
+
:where(td) { padding: 7px 8px; border-top: 1px solid var(--line); }
|
|
56
|
+
:where(code, pre) { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
57
|
+
:where(code) { padding: 1px 5px; border-radius: 5px; background: var(--raised); }
|
|
58
|
+
:where(pre) { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--raised); overflow: auto; }
|
|
59
|
+
:where(pre code) { padding: 0; background: none; }
|
|
60
|
+
:where(progress) { appearance: none; width: 100%; height: 4px; border: 0; border-radius: 2px; background: var(--raised); }
|
|
61
|
+
:where(progress)::-webkit-progress-bar { background: var(--raised); border-radius: 2px; }
|
|
62
|
+
:where(progress)::-webkit-progress-value { background: var(--ok); border-radius: 2px; }
|
|
63
|
+
:where(progress)::-moz-progress-bar { background: var(--ok); border-radius: 2px; }
|
|
64
|
+
`;
|
|
@@ -7,9 +7,13 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
import { runFrame } from "./frame.js";
|
|
10
|
+
import { FRAME_BASE } from "./frame-base.js";
|
|
10
11
|
import { FRAME_HELLO } from "./frame-protocol.js";
|
|
11
12
|
const self = globalThis;
|
|
12
13
|
let frame;
|
|
14
|
+
const base = self.document.createElement("style");
|
|
15
|
+
base.textContent = FRAME_BASE;
|
|
16
|
+
self.document.head.prepend(base);
|
|
13
17
|
self.addEventListener("message", (event) => {
|
|
14
18
|
const port = event.ports[0];
|
|
15
19
|
if (frame || event.source !== self.parent || event.data !== FRAME_HELLO || !port)
|
|
@@ -25,10 +29,6 @@ self.addEventListener("message", (event) => {
|
|
|
25
29
|
self.document.documentElement.style.setProperty(name, value);
|
|
26
30
|
},
|
|
27
31
|
});
|
|
28
|
-
// The body's height is its content's (the frame's document sets no height): the shell hears each
|
|
29
|
-
// change while the view is mounted, and may size the frame to it.
|
|
30
|
-
const body = self.document.body;
|
|
31
|
-
new self.ResizeObserver(() => frame?.size(Math.ceil(body.getBoundingClientRect().height))).observe(body);
|
|
32
32
|
});
|
|
33
33
|
// What the view doesn't catch goes to its Actor's log.
|
|
34
34
|
self.addEventListener("error", (event) => frame?.failed(event.error ?? event.message));
|
|
@@ -17,21 +17,11 @@ export interface FrameHandlers {
|
|
|
17
17
|
};
|
|
18
18
|
/** A line for the view's Actor's log. */
|
|
19
19
|
log(level: "info" | "warn" | "error", message: string, fields?: Record<string, unknown>): void;
|
|
20
|
-
/**
|
|
21
|
-
* The view's content height, within 120–2,000 px and at most once per 100 ms (the latest one
|
|
22
|
-
* wins), for a shell that sizes the frame to its content. Without it, sizes are dropped.
|
|
23
|
-
*/
|
|
24
|
-
size?(height: number): void;
|
|
25
20
|
}
|
|
26
21
|
type Size = {
|
|
27
22
|
width: number;
|
|
28
23
|
height: number;
|
|
29
24
|
};
|
|
30
|
-
/** The heights a view's frame may take from its content, and how often it may change. */
|
|
31
|
-
export declare const FRAME_HEIGHT: {
|
|
32
|
-
min: number;
|
|
33
|
-
max: number;
|
|
34
|
-
};
|
|
35
25
|
/**
|
|
36
26
|
* Hand a frame its port: post the hello with the other end to the frame's window, which has an
|
|
37
27
|
* opaque origin, so the target origin is `*`; the frame accepts it only from its parent.
|
|
@@ -47,6 +37,7 @@ export declare function openFrame(frameWindow: {
|
|
|
47
37
|
*/
|
|
48
38
|
export declare class FrameHost {
|
|
49
39
|
#private;
|
|
40
|
+
/** The latest height not yet passed on, and the wait before the next may be. */
|
|
50
41
|
constructor(port: PortLike, handlers: FrameHandlers);
|
|
51
42
|
/** Import the view's bundle in the frame and run its `start`; `slots` says which are bound. */
|
|
52
43
|
load(options: {
|
|
@@ -16,9 +16,6 @@ const LOG_WINDOW_MS = 10_000;
|
|
|
16
16
|
const MAX_SUBSCRIPTIONS = 64;
|
|
17
17
|
/** Calls on its slots one frame may have in flight; past it, `busy`. */
|
|
18
18
|
const MAX_CALLS = 64;
|
|
19
|
-
/** The heights a view's frame may take from its content, and how often it may change. */
|
|
20
|
-
export const FRAME_HEIGHT = { min: 120, max: 2000 };
|
|
21
|
-
const SIZE_MS = 100;
|
|
22
19
|
/**
|
|
23
20
|
* A frame's log fields, rebuilt: a fresh object of at most `MAX_FIELDS` plain keys (no prototype
|
|
24
21
|
* keys), each value a primitive or JSON text, cut to `MAX_FIELD`.
|
|
@@ -110,7 +107,6 @@ export class FrameHost {
|
|
|
110
107
|
#calls = 0;
|
|
111
108
|
#closed = false;
|
|
112
109
|
/** The latest height not yet passed on, and the wait before the next may be. */
|
|
113
|
-
#sizing = {};
|
|
114
110
|
constructor(port, handlers) {
|
|
115
111
|
this.#port = port;
|
|
116
112
|
this.#handlers = handlers;
|
|
@@ -144,7 +140,6 @@ export class FrameHost {
|
|
|
144
140
|
if (this.#closed)
|
|
145
141
|
return;
|
|
146
142
|
this.#closed = true;
|
|
147
|
-
clearTimeout(this.#sizing.timer);
|
|
148
143
|
this.#port.onmessage = null;
|
|
149
144
|
for (const { stop } of this.#subscriptions.values())
|
|
150
145
|
stop();
|
|
@@ -155,14 +150,6 @@ export class FrameHost {
|
|
|
155
150
|
this.#pending.clear();
|
|
156
151
|
this.#port.close();
|
|
157
152
|
}
|
|
158
|
-
#flushSize() {
|
|
159
|
-
const { height } = this.#sizing;
|
|
160
|
-
this.#sizing = {};
|
|
161
|
-
if (height === undefined || this.#closed)
|
|
162
|
-
return;
|
|
163
|
-
this.#handlers.size?.(height);
|
|
164
|
-
this.#sizing.timer = setTimeout(() => this.#flushSize(), SIZE_MS);
|
|
165
|
-
}
|
|
166
153
|
#post(message) {
|
|
167
154
|
if (!this.#closed)
|
|
168
155
|
this.#port.postMessage(message);
|
|
@@ -267,16 +254,6 @@ export class FrameHost {
|
|
|
267
254
|
}
|
|
268
255
|
return;
|
|
269
256
|
}
|
|
270
|
-
case "size": {
|
|
271
|
-
const { height } = message;
|
|
272
|
-
if (typeof height !== "number" || !Number.isFinite(height) || !this.#handlers.size)
|
|
273
|
-
return;
|
|
274
|
-
this.#sizing.height = Math.round(Math.min(FRAME_HEIGHT.max, Math.max(FRAME_HEIGHT.min, height)));
|
|
275
|
-
// The first at once, then at most one per window: the latest at its end.
|
|
276
|
-
if (!this.#sizing.timer)
|
|
277
|
-
this.#flushSize();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
257
|
case "unsubscribe": {
|
|
281
258
|
const live = isId(message.sub) ? this.#subscriptions.get(message.sub) : undefined;
|
|
282
259
|
if (!live)
|
|
@@ -98,14 +98,6 @@ export type FromFrame =
|
|
|
98
98
|
message: string;
|
|
99
99
|
fields?: Record<string, unknown>;
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
102
|
-
* The mounted view's content height in CSS pixels, each time it changes: the frame runtime's
|
|
103
|
-
* own, not `ui.view@1`'s. The shell may size the frame to it.
|
|
104
|
-
*/
|
|
105
|
-
| {
|
|
106
|
-
op: "size";
|
|
107
|
-
height: number;
|
|
108
|
-
}
|
|
109
101
|
/** The answer to one of the shell's requests. */
|
|
110
102
|
| {
|
|
111
103
|
op: "reply";
|
|
@@ -14,8 +14,6 @@ export interface FrameOptions {
|
|
|
14
14
|
export interface Frame {
|
|
15
15
|
/** An error the view didn't catch, for its Actor's log. */
|
|
16
16
|
failed(error: unknown): void;
|
|
17
|
-
/** The root's content height changed: the shell hears it while the view is mounted. */
|
|
18
|
-
size(height: number): void;
|
|
19
17
|
close(): void;
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
@@ -231,15 +231,7 @@ export function runFrame(options) {
|
|
|
231
231
|
log.error("The frame couldn't handle a message from the shell.", { error: String(error) });
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
let told;
|
|
235
234
|
return {
|
|
236
|
-
size(height) {
|
|
237
|
-
// Empty before mount and after unmount: those aren't the view's size.
|
|
238
|
-
if (!mounted || height === told)
|
|
239
|
-
return;
|
|
240
|
-
told = height;
|
|
241
|
-
send({ op: "size", height });
|
|
242
|
-
},
|
|
243
235
|
failed(error) {
|
|
244
236
|
log.error(error instanceof Error ? error.message : String(error), {
|
|
245
237
|
...(error instanceof Error && error.stack ? { stack: error.stack } : {}),
|
|
@@ -62,6 +62,11 @@ export async function runHost(options) {
|
|
|
62
62
|
const found = route(name);
|
|
63
63
|
found?.[0].onSlot(found[1], bound);
|
|
64
64
|
},
|
|
65
|
+
// A slot made at run time is the Actor's: every host module has it.
|
|
66
|
+
onExposed(name, exposure) {
|
|
67
|
+
for (const host of hosts.values())
|
|
68
|
+
host.onExposed(name, exposure);
|
|
69
|
+
},
|
|
65
70
|
serve: {
|
|
66
71
|
call: (serve, value) => {
|
|
67
72
|
const [handlers, local] = routed(serve);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { canonicalJson, hashOf, sha256 } from "./canonical.js";
|
|
2
2
|
export { NotConnected, OutcomeUnknown, Refused, type RefusedCode } from "./errors.js";
|
|
3
3
|
export { compareInterfaces, type DescribedInterface, defineInterface, describeInterface, type EventSpec, type Events, event, type HttpInterface, hashInterface, type Interface, type InterfaceSchemas, interfaceId, type JsonSchema, type MethodSpec, type Methods, method, normalizeSchema, type RpcInterface, type StreamInterface, } from "./interface.js";
|
|
4
|
-
export { type CallInfo, type Context, type Duplex, defineActor, defineWidget, type EmitOptions, type Export, type ExportMap, type FrameRoot, type Handlers, type HttpExport, type HttpSlot, type InterfaceMap, isFrameInterface, isModuleDefinition, type Log, MODULE, type ModuleDefinition, type ModuleSpec, type Placement, type RpcExport, type RpcSlot, type Slot, type StreamExport, type StreamSlot, type ViewExport, } from "./module.js";
|
|
4
|
+
export { type CallInfo, type Context, type Duplex, defineActor, defineWidget, type EmitOptions, type Export, type ExportMap, type ExposedSlot, type FrameRoot, type Handlers, type HttpExport, type HttpSlot, type InterfaceMap, isFrameInterface, isModuleDefinition, type Log, MODULE, type ModuleDefinition, type ModuleSpec, type Placement, type RpcExport, type RpcSlot, type Slot, type StreamExport, type StreamSlot, type ViewExport, } from "./module.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Channel, Serve, ServeHandlers } from "./client.js";
|
|
1
|
+
import type { Channel, ChannelExposure, Serve, ServeHandlers } from "./client.js";
|
|
2
2
|
import { Refused } from "./errors.js";
|
|
3
3
|
import type { InterfaceMap, Log } from "./module.js";
|
|
4
4
|
import type { ModuleRuntime, RuntimeOptions } from "./runtime.js";
|
|
@@ -21,6 +21,11 @@ export declare class ModuleHost {
|
|
|
21
21
|
* slot already bound) usable again because its provider came back.
|
|
22
22
|
*/
|
|
23
23
|
onSlot(slot: string, isBound: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* A notice for a slot made at run time: bound (or usable again) with its exposure, or gone. Its
|
|
26
|
+
* name is the Actor's, with no module prefix: every module of the Actor has it.
|
|
27
|
+
*/
|
|
28
|
+
onExposed(slot: string, exposure: ChannelExposure | undefined): void;
|
|
24
29
|
/** How this module serves the Hub's streams, by its local export names. */
|
|
25
30
|
readonly serve: ServeHandlers;
|
|
26
31
|
/**
|
|
@@ -168,6 +168,25 @@ export class ModuleHost {
|
|
|
168
168
|
}));
|
|
169
169
|
this.#resubscribe(slot);
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* A notice for a slot made at run time: bound (or usable again) with its exposure, or gone. Its
|
|
173
|
+
* name is the Actor's, with no module prefix: every module of the Actor has it.
|
|
174
|
+
*/
|
|
175
|
+
onExposed(slot, exposure) {
|
|
176
|
+
if (!this.#channel)
|
|
177
|
+
return;
|
|
178
|
+
if (!exposure) {
|
|
179
|
+
this.runtime.unexpose(slot);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const open = this.#channel;
|
|
183
|
+
this.runtime.expose(slot, {
|
|
184
|
+
described: exposure.interface,
|
|
185
|
+
provider: exposure.provider,
|
|
186
|
+
call: (method, value) => open.call(slot, method, value),
|
|
187
|
+
subscribe: (event, onEvent, onEnd) => open.subscribe(slot, event, onEvent, () => onEnd()),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
171
190
|
/** How this module serves the Hub's streams, by its local export names. */
|
|
172
191
|
serve = {
|
|
173
192
|
call: (serve, value) => this.runtime.call(serve.export, serve.method ?? "", value, serve.caller),
|
|
@@ -210,11 +229,15 @@ export class ModuleHost {
|
|
|
210
229
|
for (const [name, { handle, iface }] of this.#added)
|
|
211
230
|
this.#offer(channel, name, iface, handle);
|
|
212
231
|
for (const name of channel.bound)
|
|
213
|
-
if (name.startsWith(this.#prefix))
|
|
232
|
+
if (name.startsWith(this.#prefix) && !channel.exposed.has(name))
|
|
214
233
|
this.onSlot(name.slice(this.#prefix.length), true);
|
|
234
|
+
for (const [name, exposure] of channel.exposed)
|
|
235
|
+
this.onExposed(name, exposure);
|
|
215
236
|
void channel.closed.then(() => {
|
|
216
237
|
for (const slot of [...this.#bindings.keys()])
|
|
217
238
|
this.onSlot(slot, false);
|
|
239
|
+
for (const { slot } of this.runtime.ctx.exposed())
|
|
240
|
+
this.runtime.unexpose(slot);
|
|
218
241
|
for (const ends of this.#subscribers.values())
|
|
219
242
|
for (const end of [...ends])
|
|
220
243
|
end();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import type { Events, Interface, Methods, RpcInterface, StreamInterface } from "./interface.js";
|
|
2
|
+
import type { DescribedInterface, Events, Interface, Methods, RpcInterface, StreamInterface } from "./interface.js";
|
|
3
3
|
/** Where a module runs: `host` in its own process, `view` in a sandboxed frame. */
|
|
4
4
|
export type Placement = "host" | "view";
|
|
5
5
|
/** A byte stream both ways, the same in a host process and in a view. */
|
|
@@ -108,6 +108,28 @@ export type ExportMap = InterfaceMap & {
|
|
|
108
108
|
};
|
|
109
109
|
/** Whether an interface is `ui.view@1`, the one in-frame interface, with its own export handle. */
|
|
110
110
|
export declare function isFrameInterface(iface: Interface): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* A slot made at run time: another Actor's export, exposed to this Actor with `hub.grants.expose`
|
|
113
|
+
* rather than declared by its package. It is here exactly while it is bound. Its values are JSON,
|
|
114
|
+
* checked against `described` by the Hub both ways, not here, so a misfit comes back as
|
|
115
|
+
* `Refused` (code `invalid`). A call on a slot that's gone, or whose provider isn't running, throws
|
|
116
|
+
* `NotConnected`, as a declared slot's does.
|
|
117
|
+
*/
|
|
118
|
+
export interface ExposedSlot {
|
|
119
|
+
/** Its name on this Actor. */
|
|
120
|
+
readonly slot: string;
|
|
121
|
+
/** The export's interface: its methods' input and output JSON Schemas, and its events'. */
|
|
122
|
+
readonly described: DescribedInterface;
|
|
123
|
+
/** Whose export it is. */
|
|
124
|
+
readonly provider: {
|
|
125
|
+
readonly actor: string;
|
|
126
|
+
readonly export: string;
|
|
127
|
+
};
|
|
128
|
+
/** One function per method of an `rpc` interface; none for another kind. */
|
|
129
|
+
readonly call: Readonly<Record<string, (input: unknown) => Promise<unknown>>>;
|
|
130
|
+
/** Live events from the export while the slot is here; returns a function that unsubscribes. */
|
|
131
|
+
on(event: string, fn: (payload: unknown) => void): () => void;
|
|
132
|
+
}
|
|
111
133
|
/** Everything a module gets. There are no files, network, environment or Hub access besides. */
|
|
112
134
|
export interface Context<S extends InterfaceMap, X extends InterfaceMap> {
|
|
113
135
|
readonly slots: {
|
|
@@ -124,6 +146,13 @@ export interface Context<S extends InterfaceMap, X extends InterfaceMap> {
|
|
|
124
146
|
readonly module: string;
|
|
125
147
|
};
|
|
126
148
|
readonly log: Log;
|
|
149
|
+
/**
|
|
150
|
+
* The slots made for this Actor at run time and bound now, in the order they came. Every host
|
|
151
|
+
* module of the Actor sees them all; a view module sees none.
|
|
152
|
+
*/
|
|
153
|
+
exposed(): readonly ExposedSlot[];
|
|
154
|
+
/** Runs after one is added or removed, so `exposed()` is read again; returns how to stop it. */
|
|
155
|
+
onExposed(fn: () => void): () => void;
|
|
127
156
|
}
|
|
128
157
|
/** The marker the build looks for on a module's default export. */
|
|
129
158
|
export declare const MODULE = "agentorg.module/1";
|
|
@@ -2,7 +2,7 @@ import { execFile, spawn } from "node:child_process";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { mkdir, mkdtemp, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { context as esbuildContext, } from "esbuild";
|
|
8
8
|
import { compareInterfaces } from "./interface.js";
|
|
@@ -140,9 +140,9 @@ async function bundle(root, input, packages) {
|
|
|
140
140
|
...input,
|
|
141
141
|
// A limited build reads no tsconfig or jsconfig (one could name any file to read), and
|
|
142
142
|
// loads only what its plugin resolved.
|
|
143
|
-
...(packages
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
...(packages ? { plugins: [limitImports(root, packages, loadable)], tsconfigRaw: "{}" } : {}),
|
|
144
|
+
// Its inputs, by the names the bundle gives them: a library's are renamed after.
|
|
145
|
+
metafile: true,
|
|
146
146
|
absWorkingDir: root,
|
|
147
147
|
bundle: true,
|
|
148
148
|
format: "esm",
|
|
@@ -150,6 +150,11 @@ async function bundle(root, input, packages) {
|
|
|
150
150
|
mainFields: ["module", "main"],
|
|
151
151
|
conditions: ["import", "module", "default"],
|
|
152
152
|
target: "es2023",
|
|
153
|
+
// A view may be written in JSX with React (the kit's components): the automatic runtime,
|
|
154
|
+
// so no file needs React in scope, and React's production build, since a frame has no
|
|
155
|
+
// `process` for React to read its mode from.
|
|
156
|
+
jsx: "automatic",
|
|
157
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
153
158
|
minifyWhitespace: true,
|
|
154
159
|
legalComments: "none",
|
|
155
160
|
write: false,
|
|
@@ -174,7 +179,8 @@ async function bundle(root, input, packages) {
|
|
|
174
179
|
if (input !== (input_.stdin?.sourcefile ?? "<stdin>") &&
|
|
175
180
|
!loadable.has(resolve(root, input)))
|
|
176
181
|
throw new BuildError("The bundle reached a file the package didn't import.");
|
|
177
|
-
|
|
182
|
+
const code = (result.outputFiles ?? [])[0]?.contents ?? new Uint8Array();
|
|
183
|
+
return nameLibraries(code, Object.keys(result.metafile?.inputs ?? {}), root);
|
|
178
184
|
}
|
|
179
185
|
catch (error) {
|
|
180
186
|
if (error instanceof BuildError)
|
|
@@ -212,6 +218,95 @@ function inPackage(path, name) {
|
|
|
212
218
|
return false;
|
|
213
219
|
}
|
|
214
220
|
}
|
|
221
|
+
/** The name a library's file is given in the bundle, after this prefix. */
|
|
222
|
+
const LIBRARY = "agentorg-library:";
|
|
223
|
+
/**
|
|
224
|
+
* A library's file as the bundle names it: its package's name and version and its path in that
|
|
225
|
+
* package, never where it is installed. Undefined for a file in no named, versioned package.
|
|
226
|
+
*/
|
|
227
|
+
function libraryName(path, packageOfFolder) {
|
|
228
|
+
const seen = [];
|
|
229
|
+
let found = null;
|
|
230
|
+
for (let dir = dirname(path); dirname(dir) !== dir; dir = dirname(dir)) {
|
|
231
|
+
const known = packageOfFolder.get(dir);
|
|
232
|
+
if (known !== undefined) {
|
|
233
|
+
found = known;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
seen.push(dir);
|
|
237
|
+
let manifest;
|
|
238
|
+
try {
|
|
239
|
+
manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// No package.json here, or not one to read.
|
|
243
|
+
}
|
|
244
|
+
if (typeof manifest?.name === "string" && typeof manifest.version === "string") {
|
|
245
|
+
found = { name: manifest.name, version: manifest.version, dir };
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const dir of seen)
|
|
250
|
+
packageOfFolder.set(dir, found);
|
|
251
|
+
return found
|
|
252
|
+
? `${found.name}@${found.version}/${relative(found.dir, path).split(sep).join("/")}`
|
|
253
|
+
: undefined;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The bundle with each wrapped library module named by its library, not by where it sits.
|
|
257
|
+
* esbuild names each CommonJS (and lazily run ESM) module it wraps by its path from the build's
|
|
258
|
+
* folder, which for an installed library spells out the machine's folders and changes with them:
|
|
259
|
+
* React's, for one, would carry the builder's home into every package built with it. Only those
|
|
260
|
+
* names change, and only for a library's files: in a named, versioned package, outside the
|
|
261
|
+
* package's folder or in a node_modules within it.
|
|
262
|
+
*/
|
|
263
|
+
function nameLibraries(code, inputs, root) {
|
|
264
|
+
const names = new Map();
|
|
265
|
+
const packages = new Map();
|
|
266
|
+
for (const input of inputs) {
|
|
267
|
+
const path = resolve(root, input);
|
|
268
|
+
// The package's own files keep their paths; a library is named, even one installed inside.
|
|
269
|
+
if (within(path, root) && !path.slice(root.length).split(sep).includes("node_modules"))
|
|
270
|
+
continue;
|
|
271
|
+
const name = libraryName(path, packages);
|
|
272
|
+
if (name)
|
|
273
|
+
names.set(input, `${LIBRARY}${name}`);
|
|
274
|
+
}
|
|
275
|
+
if (!names.size)
|
|
276
|
+
return code;
|
|
277
|
+
const text = new TextDecoder().decode(code);
|
|
278
|
+
// A wrapper's key: the method name after `__commonJS({` or `__esm({` (`async` before it for a
|
|
279
|
+
// module with top-level await), in either quote, followed by its parameter list.
|
|
280
|
+
const named = text.replace(/(\b__(?:commonJS|esm)\d*\(\{(?:async\s*)?)("(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*')(?=\()/g, (whole, call, literal) => {
|
|
281
|
+
const name = names.get(stringOf(literal));
|
|
282
|
+
return name ? `${call}${JSON.stringify(name)}` : whole;
|
|
283
|
+
});
|
|
284
|
+
return new TextEncoder().encode(named);
|
|
285
|
+
}
|
|
286
|
+
/** A JavaScript string literal's value, as esbuild prints one: its escapes read, never thrown. */
|
|
287
|
+
function stringOf(literal) {
|
|
288
|
+
return literal
|
|
289
|
+
.slice(1, -1)
|
|
290
|
+
.replace(/\\(u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([0-7]{1,3})|\r\n|[\s\S])/g, (_, sequence, point, unit, byte, octal) => {
|
|
291
|
+
const code = point ?? unit ?? byte;
|
|
292
|
+
if (code !== undefined)
|
|
293
|
+
return String.fromCodePoint(Number.parseInt(code, 16));
|
|
294
|
+
if (octal !== undefined)
|
|
295
|
+
return String.fromCharCode(Number.parseInt(octal, 8));
|
|
296
|
+
const simple = {
|
|
297
|
+
n: "\n",
|
|
298
|
+
r: "\r",
|
|
299
|
+
t: "\t",
|
|
300
|
+
b: "\b",
|
|
301
|
+
f: "\f",
|
|
302
|
+
v: "\v",
|
|
303
|
+
};
|
|
304
|
+
// A line continuation is nothing; any other escaped character is itself.
|
|
305
|
+
return sequence === "\n" || sequence === "\r\n" || sequence === "\r"
|
|
306
|
+
? ""
|
|
307
|
+
: (simple[sequence] ?? sequence);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
215
310
|
/**
|
|
216
311
|
* Imports from the package's own files (and its module entries): by name, only an allowed
|
|
217
312
|
* package, found from `from`, and only a file inside it; by relative path, only inside the
|
|
@@ -262,7 +357,17 @@ function limitImports(root, packages, loadable) {
|
|
|
262
357
|
// A library's own import is its business, but only what was resolved here is loaded.
|
|
263
358
|
if (found.namespace === "file")
|
|
264
359
|
loadable.add(found.path);
|
|
265
|
-
|
|
360
|
+
// A library's own import is resolved again by esbuild itself, to the same file, so it
|
|
361
|
+
// keeps what only esbuild's resolution carries: the module type ("type": "module").
|
|
362
|
+
if (!ours)
|
|
363
|
+
return undefined;
|
|
364
|
+
// As resolved, with what tree-shaking reads.
|
|
365
|
+
return {
|
|
366
|
+
path: found.path,
|
|
367
|
+
namespace: found.namespace,
|
|
368
|
+
external: found.external,
|
|
369
|
+
sideEffects: found.sideEffects,
|
|
370
|
+
};
|
|
266
371
|
});
|
|
267
372
|
// A file esbuild found any other way (a pattern in a template-string import or require
|
|
268
373
|
// matches files without resolving them) is never read.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Interface } from "./interface.js";
|
|
1
|
+
import type { DescribedInterface, Interface } from "./interface.js";
|
|
2
2
|
import { type Context, type Duplex, type FrameRoot, type InterfaceMap, type Log, type ModuleDefinition } from "./module.js";
|
|
3
3
|
/**
|
|
4
4
|
* What serves a bound slot, as the host side sees it: one function per kind. The runtime validates
|
|
@@ -13,6 +13,20 @@ export interface SlotProvider {
|
|
|
13
13
|
export interface Binding {
|
|
14
14
|
emit(event: string, payload: unknown): void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* A slot made at run time, as the host side gives it: the export's interface as described, whose
|
|
18
|
+
* it is, and how to reach it. Values pass as they are: the Hub checks them.
|
|
19
|
+
*/
|
|
20
|
+
export interface ExposedProvider {
|
|
21
|
+
described: DescribedInterface;
|
|
22
|
+
provider: {
|
|
23
|
+
actor: string;
|
|
24
|
+
export: string;
|
|
25
|
+
};
|
|
26
|
+
call(method: string, input: unknown): Promise<unknown>;
|
|
27
|
+
/** Deliver an event's payloads until it ends (`onEnd`); returns how to stop. */
|
|
28
|
+
subscribe(event: string, onEvent: (payload: unknown) => void, onEnd: () => void): () => void;
|
|
29
|
+
}
|
|
16
30
|
/** A mounted view, seen from the frame runtime's side. */
|
|
17
31
|
export interface MountedView {
|
|
18
32
|
resize(size: unknown): void;
|
|
@@ -32,6 +46,13 @@ export interface ModuleRuntime<S extends InterfaceMap, X extends InterfaceMap> {
|
|
|
32
46
|
unbind(slot: string): void;
|
|
33
47
|
/** A bound slot's provider came back after going away: its `onBind` handlers run again. */
|
|
34
48
|
usable(slot: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* A slot made at run time is bound. Given again for one already here, it is usable again (its
|
|
51
|
+
* provider came back): its events resume.
|
|
52
|
+
*/
|
|
53
|
+
expose(slot: string, provider: ExposedProvider): void;
|
|
54
|
+
/** A slot made at run time is gone with its binding. */
|
|
55
|
+
unexpose(slot: string): void;
|
|
35
56
|
/** Call an export's method for `caller`, the calling Actor as the Hub names it. */
|
|
36
57
|
call(exportName: string, method: string, input: unknown, caller: string): Promise<unknown>;
|
|
37
58
|
open(exportName: string, params: unknown, stream: Duplex): Promise<void>;
|