@agentorg/cli 0.0.5 → 0.0.7
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 +23 -104
- package/dist/node_modules/@agentorg/computer/LICENSE +201 -0
- package/dist/node_modules/@agentorg/computer/NOTICE +2 -0
- package/dist/node_modules/@agentorg/computer/dist/THIRD_PARTY_LICENSES.txt +1321 -0
- package/dist/node_modules/@agentorg/computer/dist/sdk.js +24909 -0
- package/dist/node_modules/@agentorg/computer/dist/types/generated/schema.d.ts +860 -0
- package/dist/node_modules/@agentorg/computer/dist/types/sdk.d.ts +242 -0
- package/dist/node_modules/@agentorg/computer/package.json +12 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/index.d.ts +1 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/index.js +1 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.d.ts +24 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/provider.js +482 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.d.ts +19 -0
- package/dist/node_modules/@agentorg/computer-connector/dist/src/unit.js +149 -0
- package/dist/node_modules/@agentorg/computer-connector/package.json +33 -0
- package/dist/node_modules/@agentorg/computer-connector/skills/browser/SKILL.md +31 -0
- package/dist/node_modules/@agentorg/computer-connector/skills/computer/SKILL.md +30 -0
- package/dist/node_modules/@agentorg/computer-connector/skills/files/SKILL.md +28 -0
- package/dist/node_modules/@agentorg/computer-connector/skills/terminal/SKILL.md +39 -0
- package/dist/node_modules/@agentorg/computer-connector/skills/web-research/SKILL.md +29 -0
- package/dist/node_modules/@agentorg/hub/dist/src/hub-actor.d.ts +2 -7
- package/dist/node_modules/@agentorg/hub/dist/src/hub-actor.js +4 -144
- package/dist/node_modules/@agentorg/hub/dist/src/index.d.ts +1 -3
- package/dist/node_modules/@agentorg/hub/dist/src/index.js +1 -3
- package/dist/node_modules/@agentorg/hub/dist/src/router.d.ts +9 -58
- package/dist/node_modules/@agentorg/hub/dist/src/router.js +41 -414
- package/dist/node_modules/@agentorg/hub/dist/src/state.d.ts +17 -317
- package/dist/node_modules/@agentorg/hub/dist/src/state.js +42 -536
- package/dist/node_modules/@agentorg/hub/dist/src/validate.d.ts +1 -3
- package/dist/node_modules/@agentorg/hub/dist/src/validate.js +19 -17
- package/dist/node_modules/@agentorg/hub/package.json +0 -3
- package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.d.ts +119 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/agent-provider.js +96 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/agent-settings.d.ts +42 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/agent-settings.js +53 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/chat.d.ts +93 -38
- package/dist/node_modules/@agentorg/interfaces/dist/src/chat.js +71 -22
- package/dist/node_modules/@agentorg/interfaces/dist/src/connection.d.ts +36 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/connection.js +31 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/folders.d.ts +19 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/folders.js +25 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/hub.d.ts +16 -286
- package/dist/node_modules/@agentorg/interfaces/dist/src/hub.js +17 -159
- package/dist/node_modules/@agentorg/interfaces/dist/src/index.d.ts +9 -9
- package/dist/node_modules/@agentorg/interfaces/dist/src/index.js +9 -9
- package/dist/node_modules/@agentorg/interfaces/dist/src/kv.d.ts +2 -2
- package/dist/node_modules/@agentorg/interfaces/dist/src/kv.js +2 -2
- package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.d.ts +2 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/llm-session.js +2 -1
- package/dist/node_modules/@agentorg/interfaces/dist/src/manager.d.ts +626 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/manager.js +349 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/tools.d.ts +39 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/tools.js +43 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/units.d.ts +460 -0
- package/dist/node_modules/@agentorg/interfaces/dist/src/units.js +204 -0
- package/dist/node_modules/@agentorg/looper/dist/src/index.d.ts +5 -0
- package/dist/node_modules/@agentorg/looper/dist/src/index.js +5 -0
- package/dist/node_modules/@agentorg/looper/dist/src/loop.d.ts +75 -0
- package/dist/node_modules/@agentorg/looper/dist/src/loop.js +332 -0
- package/dist/node_modules/@agentorg/looper/dist/src/looper.d.ts +71 -0
- package/dist/node_modules/@agentorg/looper/dist/src/looper.js +282 -0
- package/dist/node_modules/@agentorg/looper/dist/src/record.d.ts +99 -0
- package/dist/node_modules/@agentorg/looper/dist/src/record.js +278 -0
- package/dist/node_modules/@agentorg/looper/dist/src/tools.d.ts +11 -0
- package/dist/node_modules/@agentorg/looper/dist/src/tools.js +42 -0
- package/dist/node_modules/@agentorg/looper/dist/src/types.d.ts +147 -0
- package/dist/node_modules/@agentorg/looper/dist/src/types.js +32 -0
- package/dist/node_modules/@agentorg/looper/package.json +24 -0
- package/dist/node_modules/@agentorg/manager/dist/src/activity.d.ts +18 -0
- package/dist/node_modules/@agentorg/manager/dist/src/activity.js +65 -0
- package/dist/node_modules/@agentorg/manager/dist/src/control.d.ts +134 -0
- package/dist/node_modules/@agentorg/manager/dist/src/control.js +1115 -0
- package/dist/node_modules/@agentorg/manager/dist/src/form.d.ts +40 -0
- package/dist/node_modules/@agentorg/manager/dist/src/form.js +191 -0
- package/dist/node_modules/@agentorg/manager/dist/src/index.d.ts +1 -0
- package/dist/node_modules/@agentorg/manager/dist/src/index.js +1 -0
- package/dist/node_modules/@agentorg/manager/dist/src/manager.d.ts +25 -0
- package/dist/node_modules/@agentorg/manager/dist/src/manager.js +680 -0
- package/dist/node_modules/@agentorg/manager/dist/src/skills.d.ts +27 -0
- package/dist/node_modules/@agentorg/manager/dist/src/skills.js +152 -0
- package/dist/node_modules/@agentorg/manager/dist/src/stack.d.ts +454 -0
- package/dist/node_modules/@agentorg/manager/dist/src/stack.js +917 -0
- package/dist/node_modules/@agentorg/manager/package.json +30 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/connection.d.ts +34 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/connection.js +296 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/index.d.ts +4 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/index.js +4 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/kinds.d.ts +158 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/kinds.js +164 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/provider.d.ts +22 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/provider.js +197 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/public.d.ts +6 -0
- package/dist/node_modules/@agentorg/mcp/dist/src/public.js +72 -0
- package/dist/node_modules/@agentorg/mcp/package.json +31 -0
- package/dist/node_modules/@agentorg/sdk/dist/src/cli.js +3 -23
- package/dist/node_modules/@agentorg/sdk/dist/src/client.d.ts +4 -25
- package/dist/node_modules/@agentorg/sdk/dist/src/client.js +5 -55
- package/dist/node_modules/@agentorg/sdk/dist/src/errors.d.ts +1 -1
- package/dist/node_modules/@agentorg/sdk/dist/src/errors.js +3 -3
- package/dist/node_modules/@agentorg/sdk/dist/src/filled.d.ts +21 -0
- package/dist/node_modules/@agentorg/sdk/dist/src/filled.js +24 -0
- package/dist/node_modules/@agentorg/sdk/dist/src/index.d.ts +3 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/index.js +2 -1
- package/dist/node_modules/@agentorg/sdk/dist/src/interface.d.ts +6 -34
- package/dist/node_modules/@agentorg/sdk/dist/src/interface.js +3 -24
- package/dist/node_modules/@agentorg/sdk/dist/src/module-host.d.ts +8 -17
- package/dist/node_modules/@agentorg/sdk/dist/src/module-host.js +15 -87
- package/dist/node_modules/@agentorg/sdk/dist/src/module.d.ts +10 -76
- package/dist/node_modules/@agentorg/sdk/dist/src/module.js +3 -23
- package/dist/node_modules/@agentorg/sdk/dist/src/person-commands.js +0 -5
- package/dist/node_modules/@agentorg/sdk/dist/src/runtime.d.ts +3 -27
- package/dist/node_modules/@agentorg/sdk/dist/src/runtime.js +5 -100
- package/dist/node_modules/@agentorg/sdk/dist/src/testing.d.ts +7 -8
- package/dist/node_modules/@agentorg/sdk/dist/src/testing.js +12 -24
- package/dist/node_modules/@agentorg/sdk/package.json +4 -37
- package/dist/node_modules/@agentorg/shell/dist/app.css +4624 -739
- package/dist/node_modules/@agentorg/shell/dist/app.js +245 -202
- package/dist/node_modules/@agentorg/shell/package.json +23 -10
- package/dist/node_modules/@agentorg/wire/dist/src/frames.d.ts +2 -3
- package/dist/node_modules/@agentorg/wire/dist/src/frames.js +2 -3
- package/dist/node_modules/@agentorg/wire/dist/src/ops.d.ts +5 -34
- package/dist/node_modules/@agentorg/wire/dist/src/ops.js +2 -17
- package/dist/node_modules/assistant/dist/src/chats.d.ts +92 -0
- package/dist/node_modules/assistant/dist/src/chats.js +357 -0
- package/dist/node_modules/assistant/dist/src/engine.d.ts +42 -0
- package/dist/node_modules/assistant/dist/src/engine.js +160 -0
- package/dist/node_modules/assistant/dist/src/local-store.d.ts +3 -0
- package/dist/node_modules/assistant/dist/src/local-store.js +58 -0
- package/dist/node_modules/assistant/dist/src/provider.d.ts +21 -0
- package/dist/node_modules/assistant/dist/src/provider.js +259 -0
- package/dist/node_modules/assistant/dist/src/settings.d.ts +17 -0
- package/dist/node_modules/assistant/dist/src/settings.js +43 -0
- package/dist/node_modules/assistant/dist/src/tools.d.ts +57 -0
- package/dist/node_modules/assistant/dist/src/tools.js +102 -0
- package/dist/node_modules/assistant/package.json +30 -0
- package/dist/node_modules/chatgpt/dist/src/account.d.ts +52 -0
- package/dist/node_modules/chatgpt/dist/src/account.js +270 -0
- package/dist/node_modules/chatgpt/dist/src/encoding.d.ts +7 -0
- package/dist/node_modules/chatgpt/dist/src/encoding.js +20 -0
- package/dist/node_modules/chatgpt/dist/src/file-store.d.ts +9 -0
- package/dist/node_modules/chatgpt/dist/src/file-store.js +68 -0
- package/dist/node_modules/chatgpt/dist/src/index.d.ts +1 -0
- package/dist/node_modules/chatgpt/dist/src/index.js +1 -0
- package/dist/node_modules/chatgpt/dist/src/jwt.d.ts +15 -0
- package/dist/node_modules/chatgpt/dist/src/jwt.js +37 -0
- package/dist/node_modules/chatgpt/dist/src/oauth.d.ts +43 -0
- package/dist/node_modules/chatgpt/dist/src/oauth.js +104 -0
- package/dist/node_modules/chatgpt/dist/src/program.d.ts +23 -0
- package/dist/node_modules/chatgpt/dist/src/program.js +41 -0
- package/dist/node_modules/chatgpt/dist/src/responses.d.ts +54 -0
- package/dist/node_modules/chatgpt/dist/src/responses.js +300 -0
- package/dist/node_modules/chatgpt/dist/src/serve.d.ts +65 -0
- package/dist/node_modules/chatgpt/dist/src/serve.js +46 -0
- package/dist/node_modules/chatgpt/package.json +33 -0
- package/dist/src/api.d.ts +5 -34
- package/dist/src/api.js +10 -68
- package/dist/src/cli.js +3 -7
- package/dist/src/folders.d.ts +2 -0
- package/dist/src/folders.js +45 -0
- package/dist/src/gateway.d.ts +13 -8
- package/dist/src/gateway.js +119 -296
- package/dist/src/index.d.ts +4 -5
- package/dist/src/index.js +3 -4
- package/dist/src/live.d.ts +17 -0
- package/dist/src/live.js +109 -0
- package/dist/src/notes.d.ts +11 -0
- package/dist/src/notes.js +64 -0
- package/dist/src/oauth.d.ts +16 -0
- package/dist/src/oauth.js +46 -0
- package/dist/src/programs.d.ts +36 -0
- package/dist/src/programs.js +198 -0
- package/dist/src/signin.d.ts +12 -3
- package/dist/src/signin.js +30 -6
- package/package.json +4 -11
- package/dist/bundled/index.json +0 -6
- package/dist/bundled/sha256-0e91cc3d0e9762b81abc2427b5496b20f383abcd6fb97d928a8d50e956b54d1f.agentorg +0 -0
- package/dist/bundled/sha256-1f64ca62a0209d767d6aa6c4feb50b0653d60f10bebbc301f79bd3a37e0153c1.agentorg +0 -0
- package/dist/bundled/sha256-4055f8fddf6b90f3d356543f554b2a9e9a2c4a8827a8774f8f87952dc1692331.agentorg +0 -0
- package/dist/bundled/sha256-e356ea3c1899138a8494baf521556831006f38534fa9e92ae873e7e6956c3a46.agentorg +0 -0
- package/dist/node_modules/@agentorg/hub/dist/src/build.d.ts +0 -17
- package/dist/node_modules/@agentorg/hub/dist/src/build.js +0 -120
- package/dist/node_modules/@agentorg/hub/dist/src/logs.d.ts +0 -33
- package/dist/node_modules/@agentorg/hub/dist/src/logs.js +0 -162
- package/dist/node_modules/@agentorg/hub/dist/src/net.d.ts +0 -41
- package/dist/node_modules/@agentorg/hub/dist/src/net.js +0 -265
- package/dist/node_modules/@agentorg/hub/dist/src/processes.d.ts +0 -78
- package/dist/node_modules/@agentorg/hub/dist/src/processes.js +0 -485
- package/dist/node_modules/@agentorg/hub/dist/src/storage.d.ts +0 -38
- package/dist/node_modules/@agentorg/hub/dist/src/storage.js +0 -194
- package/dist/node_modules/@agentorg/interfaces/dist/src/http-egress.d.ts +0 -6
- package/dist/node_modules/@agentorg/interfaces/dist/src/http-egress.js +0 -7
- package/dist/node_modules/@agentorg/interfaces/dist/src/installer.d.ts +0 -191
- package/dist/node_modules/@agentorg/interfaces/dist/src/installer.js +0 -136
- package/dist/node_modules/@agentorg/interfaces/dist/src/layout.d.ts +0 -47
- package/dist/node_modules/@agentorg/interfaces/dist/src/layout.js +0 -52
- package/dist/node_modules/@agentorg/interfaces/dist/src/rules.d.ts +0 -35
- package/dist/node_modules/@agentorg/interfaces/dist/src/rules.js +0 -37
- package/dist/node_modules/@agentorg/interfaces/dist/src/storage-admin.d.ts +0 -23
- package/dist/node_modules/@agentorg/interfaces/dist/src/storage-admin.js +0 -31
- package/dist/node_modules/@agentorg/interfaces/dist/src/ui-shell.d.ts +0 -14
- package/dist/node_modules/@agentorg/interfaces/dist/src/ui-shell.js +0 -26
- package/dist/node_modules/@agentorg/interfaces/dist/src/ui-view.d.ts +0 -27
- package/dist/node_modules/@agentorg/interfaces/dist/src/ui-view.js +0 -26
- package/dist/node_modules/@agentorg/kit/dist/src/chat.d.ts +0 -37
- package/dist/node_modules/@agentorg/kit/dist/src/chat.js +0 -131
- package/dist/node_modules/@agentorg/kit/dist/src/components.d.ts +0 -94
- package/dist/node_modules/@agentorg/kit/dist/src/components.js +0 -66
- package/dist/node_modules/@agentorg/kit/dist/src/icons.d.ts +0 -17
- package/dist/node_modules/@agentorg/kit/dist/src/icons.js +0 -30
- package/dist/node_modules/@agentorg/kit/dist/src/index.d.ts +0 -6
- package/dist/node_modules/@agentorg/kit/dist/src/index.js +0 -10
- package/dist/node_modules/@agentorg/kit/dist/src/markdown.d.ts +0 -9
- package/dist/node_modules/@agentorg/kit/dist/src/markdown.js +0 -14
- package/dist/node_modules/@agentorg/kit/dist/src/resizable.d.ts +0 -5
- package/dist/node_modules/@agentorg/kit/dist/src/resizable.js +0 -8
- package/dist/node_modules/@agentorg/kit/dist/src/styles.d.ts +0 -11
- package/dist/node_modules/@agentorg/kit/dist/src/styles.js +0 -166
- package/dist/node_modules/@agentorg/kit/package.json +0 -44
- package/dist/node_modules/@agentorg/sdk/dist/frame/runtime.js +0 -753
- package/dist/node_modules/@agentorg/sdk/dist/host/runner.js +0 -21963
- package/dist/node_modules/@agentorg/sdk/dist/src/build.d.ts +0 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/build.js +0 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/client-http.d.ts +0 -24
- package/dist/node_modules/@agentorg/sdk/dist/src/client-http.js +0 -247
- package/dist/node_modules/@agentorg/sdk/dist/src/describe.d.ts +0 -13
- package/dist/node_modules/@agentorg/sdk/dist/src/describe.js +0 -16
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.d.ts +0 -8
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-base.js +0 -64
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-entry.d.ts +0 -1
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-entry.js +0 -35
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-host.d.ts +0 -57
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-host.js +0 -293
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-protocol.d.ts +0 -124
- package/dist/node_modules/@agentorg/sdk/dist/src/frame-protocol.js +0 -16
- package/dist/node_modules/@agentorg/sdk/dist/src/frame.d.ts +0 -25
- package/dist/node_modules/@agentorg/sdk/dist/src/frame.js +0 -248
- package/dist/node_modules/@agentorg/sdk/dist/src/host-main.d.ts +0 -1
- package/dist/node_modules/@agentorg/sdk/dist/src/host-main.js +0 -60
- package/dist/node_modules/@agentorg/sdk/dist/src/host.d.ts +0 -25
- package/dist/node_modules/@agentorg/sdk/dist/src/host.js +0 -92
- package/dist/node_modules/@agentorg/sdk/dist/src/manifest-api.d.ts +0 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/manifest-api.js +0 -2
- package/dist/node_modules/@agentorg/sdk/dist/src/manifest.d.ts +0 -56
- package/dist/node_modules/@agentorg/sdk/dist/src/manifest.js +0 -165
- package/dist/node_modules/@agentorg/sdk/dist/src/package.d.ts +0 -60
- package/dist/node_modules/@agentorg/sdk/dist/src/package.js +0 -538
- package/dist/node_modules/@agentorg/sdk/dist/src/tar.d.ts +0 -7
- package/dist/node_modules/@agentorg/sdk/dist/src/tar.js +0 -71
- package/dist/node_modules/@agentorg/shell/dist/agent-bindings.js +0 -59
- package/dist/node_modules/@agentorg/shell/src/agent-bindings.ts +0 -107
- package/dist/src/frames.d.ts +0 -23
- package/dist/src/frames.js +0 -78
- package/dist/src/layout.d.ts +0 -44
- package/dist/src/layout.js +0 -90
- package/dist/src/model.d.ts +0 -54
- package/dist/src/model.js +0 -299
- package/dist/src/rules.d.ts +0 -71
- package/dist/src/rules.js +0 -157
- package/dist/src/transfer.d.ts +0 -30
- package/dist/src/transfer.js +0 -110
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NotConnected, Refused } from "./errors.js";
|
|
2
|
-
import { isFrameInterface, } from "./module.js";
|
|
3
2
|
/**
|
|
4
3
|
* A value checked against a schema. A caller's misfit is `Refused` with code `invalid`, and nothing
|
|
5
4
|
* ran. A provider's is code `bad_output`: the provider ran and its reply or event broke the
|
|
@@ -12,7 +11,6 @@ export function check(schema, value, where, code = "invalid") {
|
|
|
12
11
|
const issue = result.error.issues[0];
|
|
13
12
|
throw new Refused(code, `${where}: ${issue ? `${issue.path.map(String).join(".") || "value"} ${issue.message}` : "invalid"}`);
|
|
14
13
|
}
|
|
15
|
-
const NAME = /^[a-z][A-Za-z0-9_]*$/;
|
|
16
14
|
const own = (record, key) => Object.hasOwn(record, key) ? record[key] : undefined;
|
|
17
15
|
export function createRuntime(definition, options) {
|
|
18
16
|
const slots = new Map();
|
|
@@ -61,73 +59,34 @@ export function createRuntime(definition, options) {
|
|
|
61
59
|
return () => void set.delete(fn);
|
|
62
60
|
},
|
|
63
61
|
});
|
|
64
|
-
case "stream":
|
|
65
|
-
return Object.assign(base, {
|
|
66
|
-
async open(params) {
|
|
67
|
-
const target = provider();
|
|
68
|
-
const parsed = check(iface.open, params, `${name} open`);
|
|
69
|
-
if (!target.open)
|
|
70
|
-
throw new Refused("unimplemented", `${name} isn't served by a stream provider.`);
|
|
71
|
-
return target.open(parsed);
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
case "http":
|
|
75
|
-
return Object.assign(base, {
|
|
76
|
-
async fetch(request) {
|
|
77
|
-
const target = provider();
|
|
78
|
-
if (!target.fetch)
|
|
79
|
-
throw new Refused("unimplemented", `${name} isn't served by an http provider.`);
|
|
80
|
-
return target.fetch(request);
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
62
|
}
|
|
84
63
|
};
|
|
85
64
|
const exportHandle = (name, iface) => {
|
|
86
|
-
const state = { iface
|
|
65
|
+
const state = { iface };
|
|
87
66
|
exported.set(name, state);
|
|
88
|
-
const live = () => {
|
|
89
|
-
if (state.withdrawn)
|
|
90
|
-
throw new NotConnected(name);
|
|
91
|
-
};
|
|
92
|
-
const withdraw = () => {
|
|
93
|
-
if (state.withdrawn)
|
|
94
|
-
return;
|
|
95
|
-
state.withdrawn = true;
|
|
96
|
-
options.onWithdraw?.(name);
|
|
97
|
-
};
|
|
98
67
|
const store = (impl) => {
|
|
99
|
-
live();
|
|
100
68
|
state.impl = impl;
|
|
101
69
|
};
|
|
102
|
-
if (isFrameInterface(iface))
|
|
103
|
-
return { implement: store, withdraw };
|
|
104
70
|
switch (iface.kind) {
|
|
105
71
|
case "rpc":
|
|
106
72
|
return {
|
|
107
73
|
implement: store,
|
|
108
74
|
emit(event, payload, emitting) {
|
|
109
|
-
live();
|
|
110
75
|
const spec = own(iface.events, event);
|
|
111
76
|
if (!spec)
|
|
112
77
|
throw new TypeError(`${name} has no event ${event}.`);
|
|
113
78
|
options.onEmit(name, event, check(spec.payload, payload, `${name}.${event} payload`), emitting?.to);
|
|
114
79
|
},
|
|
115
|
-
withdraw,
|
|
116
80
|
};
|
|
117
|
-
case "stream":
|
|
118
|
-
return { accept: store, withdraw };
|
|
119
|
-
case "http":
|
|
120
|
-
return { serve: store, withdraw };
|
|
121
81
|
}
|
|
122
82
|
};
|
|
123
83
|
/** A connected export of the expected kind; implemented or not is checked after its input. */
|
|
124
84
|
const target = (name, kind) => {
|
|
125
85
|
const state = exported.get(name);
|
|
126
|
-
if (!state
|
|
86
|
+
if (!state)
|
|
127
87
|
throw new NotConnected(name);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
throw new TypeError(`${name} isn't ${kind === "frame" ? "a ui.view@1" : `an ${kind}`} export.`);
|
|
88
|
+
if (state.iface.kind !== kind)
|
|
89
|
+
throw new TypeError(`${name} isn't an ${kind} export.`);
|
|
131
90
|
return state;
|
|
132
91
|
};
|
|
133
92
|
const implemented = (state, name) => {
|
|
@@ -244,21 +203,7 @@ export function createRuntime(definition, options) {
|
|
|
244
203
|
};
|
|
245
204
|
const ctx = {
|
|
246
205
|
slots: Object.fromEntries(Object.entries(definition.slots).map(([name, iface]) => [name, slotHandle(name, iface)])),
|
|
247
|
-
exports: Object.
|
|
248
|
-
name,
|
|
249
|
-
exportHandle(name, iface),
|
|
250
|
-
])), {
|
|
251
|
-
add(name, iface) {
|
|
252
|
-
if (!NAME.test(name) || name === "add")
|
|
253
|
-
throw new TypeError(`${JSON.stringify(name)} isn't a valid export name.`);
|
|
254
|
-
const existing = exported.get(name);
|
|
255
|
-
if (existing && !existing.withdrawn)
|
|
256
|
-
throw new TypeError(`An export named ${name} is already offered.`);
|
|
257
|
-
const handle = exportHandle(name, iface);
|
|
258
|
-
options.onAdd?.(name, iface, handle);
|
|
259
|
-
return handle;
|
|
260
|
-
},
|
|
261
|
-
}),
|
|
206
|
+
exports: Object.fromEntries(Object.entries(definition.exports).map(([name, iface]) => [name, exportHandle(name, iface)])),
|
|
262
207
|
self: options.self,
|
|
263
208
|
log: options.log,
|
|
264
209
|
exposed: () => Object.freeze([...exposed.values()].map((state) => state.handle)),
|
|
@@ -267,19 +212,6 @@ export function createRuntime(definition, options) {
|
|
|
267
212
|
return () => void exposedWatchers.delete(fn);
|
|
268
213
|
},
|
|
269
214
|
};
|
|
270
|
-
const serving = (exportName) => {
|
|
271
|
-
const state = target(exportName, "http");
|
|
272
|
-
const handler = implemented(state, exportName);
|
|
273
|
-
return async (request) => handler(request);
|
|
274
|
-
};
|
|
275
|
-
const accepting = (exportName, params) => {
|
|
276
|
-
const state = target(exportName, "stream");
|
|
277
|
-
const parsed = check(state.iface.open, params, `${exportName} open`);
|
|
278
|
-
const handler = implemented(state, exportName);
|
|
279
|
-
return async (stream) => {
|
|
280
|
-
await handler(parsed, stream);
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
215
|
/** Run a slot's bind or unbind handlers; one that throws is logged and the rest still run. */
|
|
284
216
|
const notify = (slot, handlers) => {
|
|
285
217
|
const failed = (error) => options.log.error("A slot handler threw.", { slot, error: String(error) });
|
|
@@ -351,32 +283,5 @@ export function createRuntime(definition, options) {
|
|
|
351
283
|
throw new Refused("unimplemented", `${exportName}.${method} isn't implemented.`);
|
|
352
284
|
return check(spec.output, await handler(parsed, { caller }), `${exportName}.${method} output`, "bad_output");
|
|
353
285
|
},
|
|
354
|
-
accepting,
|
|
355
|
-
async open(exportName, params, stream) {
|
|
356
|
-
await accepting(exportName, params)(stream);
|
|
357
|
-
},
|
|
358
|
-
serving,
|
|
359
|
-
async fetch(exportName, request) {
|
|
360
|
-
return serving(exportName)(request);
|
|
361
|
-
},
|
|
362
|
-
mount(exportName, el, options) {
|
|
363
|
-
const state = target(exportName, "frame");
|
|
364
|
-
const methods = state.iface.methods;
|
|
365
|
-
const parsed = check(methods.mount?.input, options, `${exportName} mount`);
|
|
366
|
-
const view = implemented(state, exportName);
|
|
367
|
-
const cleanup = view.mount(el, parsed);
|
|
368
|
-
return {
|
|
369
|
-
resize(size) {
|
|
370
|
-
const { size: checked } = check(methods.resize?.input, { size }, `${exportName} resize`);
|
|
371
|
-
view.resize?.(checked);
|
|
372
|
-
},
|
|
373
|
-
unmount() {
|
|
374
|
-
cleanup?.();
|
|
375
|
-
},
|
|
376
|
-
};
|
|
377
|
-
},
|
|
378
|
-
withdrawn(exportName) {
|
|
379
|
-
return exported.get(exportName)?.withdrawn ?? false;
|
|
380
|
-
},
|
|
381
286
|
};
|
|
382
287
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type { Duplex, Handlers, InterfaceMap, ModuleDefinition } from "./module.js";
|
|
1
|
+
import { type Interface, type RpcInterface } from "./interface.js";
|
|
2
|
+
import type { Handlers, InterfaceMap, ModuleDefinition } from "./module.js";
|
|
4
3
|
import { type Binding, type ModuleRuntime } from "./runtime.js";
|
|
5
|
-
/** A fake bound to a slot in a test: handlers
|
|
6
|
-
export type Provider<I extends Interface> = I extends RpcInterface<string, infer M> ? Partial<Handlers<M>> :
|
|
4
|
+
/** A fake bound to a slot in a test: its handlers. */
|
|
5
|
+
export type Provider<I extends Interface> = I extends RpcInterface<string, infer M> ? Partial<Handlers<M>> : never;
|
|
7
6
|
export interface Emitted {
|
|
8
7
|
export: string;
|
|
9
8
|
event: string;
|
|
@@ -19,8 +18,8 @@ export interface LogLine {
|
|
|
19
18
|
/**
|
|
20
19
|
* A module run without a Hub, for tests: bind fakes to its slots, drive its exports, and read what
|
|
21
20
|
* it emitted and logged. It runs on the same runtime as a real module, so every call is validated
|
|
22
|
-
* as the Hub validates it: bad input is `Refused` with code `invalid`, and an unbound slot
|
|
23
|
-
*
|
|
21
|
+
* as the Hub validates it: bad input is `Refused` with code `invalid`, and an unbound slot throws
|
|
22
|
+
* `NotConnected`.
|
|
24
23
|
*/
|
|
25
24
|
export interface TestContext<S extends InterfaceMap, X extends InterfaceMap> extends Omit<ModuleRuntime<S, X>, "bind" | "call" | "expose"> {
|
|
26
25
|
bind<K extends keyof S & string>(slot: K, provider: Provider<S[K]>): Binding;
|
|
@@ -45,4 +44,4 @@ export declare function createTestContext<S extends InterfaceMap, X extends Inte
|
|
|
45
44
|
actorId?: string;
|
|
46
45
|
module?: string;
|
|
47
46
|
}): TestContext<S, X>;
|
|
48
|
-
export type { Binding
|
|
47
|
+
export type { Binding } from "./runtime.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Refused } from "./errors.js";
|
|
2
|
-
import { describeInterface
|
|
2
|
+
import { describeInterface } from "./interface.js";
|
|
3
3
|
import { check, createRuntime, } from "./runtime.js";
|
|
4
4
|
export function createTestContext(definition, options = {}) {
|
|
5
5
|
const emitted = [];
|
|
@@ -21,29 +21,17 @@ export function createTestContext(definition, options = {}) {
|
|
|
21
21
|
...runtime,
|
|
22
22
|
call: (exportName, method, input, caller = self) => runtime.call(exportName, method, input, caller),
|
|
23
23
|
bind(slot, fake) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return handler(input, call);
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
else if (iface.kind === "stream") {
|
|
40
|
-
const open = fake;
|
|
41
|
-
provider = { open: async (params) => open(params) };
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const fetch = fake;
|
|
45
|
-
provider = { fetch: async (request) => fetch(request) };
|
|
46
|
-
}
|
|
24
|
+
const handlers = fake;
|
|
25
|
+
// The module itself is the caller of its own slot.
|
|
26
|
+
const call = { caller: self };
|
|
27
|
+
const provider = {
|
|
28
|
+
async call(method, input) {
|
|
29
|
+
const handler = Object.hasOwn(handlers, method) ? handlers[method] : undefined;
|
|
30
|
+
if (!handler)
|
|
31
|
+
throw new Refused("unimplemented", `${slot}.${method} isn't faked.`);
|
|
32
|
+
return handler(input, call);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
47
35
|
return runtime.bind(slot, provider);
|
|
48
36
|
},
|
|
49
37
|
expose(slot, iface, fake, provider = { actor: "test-provider", export: "export" }) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@agentorg/sdk",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
|
-
"description": "Define interfaces
|
|
5
|
+
"description": "Define interfaces and Actors, and connect them to the Hub.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
@@ -14,31 +14,10 @@
|
|
|
14
14
|
"types": "./dist/src/testing.d.ts",
|
|
15
15
|
"default": "./dist/src/testing.js"
|
|
16
16
|
},
|
|
17
|
-
"./build": {
|
|
18
|
-
"types": "./dist/src/build.d.ts",
|
|
19
|
-
"default": "./dist/src/build.js"
|
|
20
|
-
},
|
|
21
|
-
"./describe": {
|
|
22
|
-
"types": "./dist/src/describe.d.ts",
|
|
23
|
-
"default": "./dist/src/describe.js"
|
|
24
|
-
},
|
|
25
|
-
"./manifest": {
|
|
26
|
-
"types": "./dist/src/manifest-api.d.ts",
|
|
27
|
-
"default": "./dist/src/manifest-api.js"
|
|
28
|
-
},
|
|
29
17
|
"./client": {
|
|
30
18
|
"types": "./dist/src/client.d.ts",
|
|
31
19
|
"default": "./dist/src/client.js"
|
|
32
20
|
},
|
|
33
|
-
"./frame": {
|
|
34
|
-
"types": "./dist/src/frame.d.ts",
|
|
35
|
-
"default": "./dist/src/frame.js"
|
|
36
|
-
},
|
|
37
|
-
"./frame/host": {
|
|
38
|
-
"types": "./dist/src/frame-host.d.ts",
|
|
39
|
-
"default": "./dist/src/frame-host.js"
|
|
40
|
-
},
|
|
41
|
-
"./frame/runtime.js": "./dist/frame/runtime.js",
|
|
42
21
|
"./cli": {
|
|
43
22
|
"types": "./dist/src/cli.d.ts",
|
|
44
23
|
"default": "./dist/src/cli.js"
|
|
@@ -46,24 +25,13 @@
|
|
|
46
25
|
"./person-commands": {
|
|
47
26
|
"types": "./dist/src/person-commands.d.ts",
|
|
48
27
|
"default": "./dist/src/person-commands.js"
|
|
49
|
-
}
|
|
50
|
-
"./http": {
|
|
51
|
-
"types": "./dist/src/client-http.d.ts",
|
|
52
|
-
"default": "./dist/src/client-http.js"
|
|
53
|
-
},
|
|
54
|
-
"./host": {
|
|
55
|
-
"types": "./dist/src/host.d.ts",
|
|
56
|
-
"default": "./dist/src/host.js"
|
|
57
|
-
},
|
|
58
|
-
"./host/runner.js": "./dist/host/runner.js"
|
|
28
|
+
}
|
|
59
29
|
},
|
|
60
30
|
"files": [
|
|
61
|
-
"dist/src"
|
|
62
|
-
"dist/frame",
|
|
63
|
-
"dist/host"
|
|
31
|
+
"dist/src"
|
|
64
32
|
],
|
|
65
33
|
"scripts": {
|
|
66
|
-
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json
|
|
34
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.json",
|
|
67
35
|
"test": "node --test --test-timeout=60000 \"dist/test/**/*.test.js\""
|
|
68
36
|
},
|
|
69
37
|
"peerDependencies": {
|
|
@@ -73,7 +41,6 @@
|
|
|
73
41
|
"zod": "^4.6.7"
|
|
74
42
|
},
|
|
75
43
|
"dependencies": {
|
|
76
|
-
"esbuild": "0.28.2",
|
|
77
44
|
"@agentorg/wire": "0.0.0"
|
|
78
45
|
},
|
|
79
46
|
"bin": {
|