@lamplitisles/dsh-nanocodex 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +65 -0
- package/NOTICE +2 -0
- package/README.md +182 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/cordis.patch.yml +52 -0
- package/dist/index.d.ts +435 -0
- package/dist/index.js +3405 -0
- package/dist/standard-preset.d.ts +7 -0
- package/dist/standard-preset.js +25 -0
- package/engine-release.json +14 -0
- package/package.json +119 -0
- package/presets/standard/agent.cordis.yml +6 -0
- package/presets/standard/preset.yml +2 -0
- package/vendor/nanocodex/README.md +1344 -0
- package/vendor/nanocodex/actions/events.d.mts +10 -0
- package/vendor/nanocodex/actions/events.mjs +163 -0
- package/vendor/nanocodex/actions/index.d.mts +13 -0
- package/vendor/nanocodex/actions/index.mjs +35 -0
- package/vendor/nanocodex/actions/session.d.mts +66 -0
- package/vendor/nanocodex/actions/session.mjs +59 -0
- package/vendor/nanocodex/actions/turn.d.mts +59 -0
- package/vendor/nanocodex/actions/turn.mjs +37 -0
- package/vendor/nanocodex/actions/voice.d.mts +22 -0
- package/vendor/nanocodex/actions/voice.mjs +50 -0
- package/vendor/nanocodex/browser/Agent.d.mts +55 -0
- package/vendor/nanocodex/browser/Agent.mjs +11 -0
- package/vendor/nanocodex/browser/ChatGptSubscription.d.mts +7 -0
- package/vendor/nanocodex/browser/ChatGptSubscription.mjs +19 -0
- package/vendor/nanocodex/browser/InlineAgent.mjs +266 -0
- package/vendor/nanocodex/browser/Transport.d.mts +74 -0
- package/vendor/nanocodex/browser/Transport.mjs +61 -0
- package/vendor/nanocodex/browser/Voice.d.mts +71 -0
- package/vendor/nanocodex/browser/Voice.mjs +291 -0
- package/vendor/nanocodex/browser/VoiceSession.mjs +688 -0
- package/vendor/nanocodex/browser/WorkerAgent.d.mts +65 -0
- package/vendor/nanocodex/browser/WorkerAgent.mjs +1472 -0
- package/vendor/nanocodex/browser/agent.worker.mjs +3 -0
- package/vendor/nanocodex/browser/config.d.mts +36 -0
- package/vendor/nanocodex/browser/config.mjs +439 -0
- package/vendor/nanocodex/browser/engine.mjs +13 -0
- package/vendor/nanocodex/browser/harness.mjs +55 -0
- package/vendor/nanocodex/browser/host.d.mts +83 -0
- package/vendor/nanocodex/browser/host.mjs +555 -0
- package/vendor/nanocodex/browser/hostManagedWebSocket.d.mts +14 -0
- package/vendor/nanocodex/browser/hostManagedWebSocket.mjs +110 -0
- package/vendor/nanocodex/browser/index.d.mts +92 -0
- package/vendor/nanocodex/browser/index.mjs +23 -0
- package/vendor/nanocodex/browser/indexeddb-durability-store.mjs +197 -0
- package/vendor/nanocodex/browser/workspace.d.mts +16 -0
- package/vendor/nanocodex/browser/workspace.mjs +107 -0
- package/vendor/nanocodex/cloud/Client.d.mts +83 -0
- package/vendor/nanocodex/cloud/Client.mjs +231 -0
- package/vendor/nanocodex/cloud/Decorator.d.mts +31 -0
- package/vendor/nanocodex/cloud/Decorator.mjs +37 -0
- package/vendor/nanocodex/cloud/Dialog.d.mts +113 -0
- package/vendor/nanocodex/cloud/Dialog.mjs +366 -0
- package/vendor/nanocodex/cloud/Errors.d.mts +22 -0
- package/vendor/nanocodex/cloud/Errors.mjs +39 -0
- package/vendor/nanocodex/cloud/Principal.d.mts +26 -0
- package/vendor/nanocodex/cloud/Principal.mjs +88 -0
- package/vendor/nanocodex/cloud/RemoteProvider.mjs +88 -0
- package/vendor/nanocodex/cloud/Transport.d.mts +47 -0
- package/vendor/nanocodex/cloud/Transport.mjs +454 -0
- package/vendor/nanocodex/cloud/actions/account.d.mts +9 -0
- package/vendor/nanocodex/cloud/actions/account.mjs +19 -0
- package/vendor/nanocodex/cloud/actions/agent.d.mts +18 -0
- package/vendor/nanocodex/cloud/actions/agent.mjs +428 -0
- package/vendor/nanocodex/cloud/actions/connection.d.mts +133 -0
- package/vendor/nanocodex/cloud/actions/connection.mjs +580 -0
- package/vendor/nanocodex/cloud/actions/grant.d.mts +10 -0
- package/vendor/nanocodex/cloud/actions/grant.mjs +12 -0
- package/vendor/nanocodex/cloud/actions/index.d.mts +7 -0
- package/vendor/nanocodex/cloud/actions/index.mjs +7 -0
- package/vendor/nanocodex/cloud/actions/machineUsd.d.mts +23 -0
- package/vendor/nanocodex/cloud/actions/machineUsd.mjs +37 -0
- package/vendor/nanocodex/cloud/actions/model.d.mts +12 -0
- package/vendor/nanocodex/cloud/actions/model.mjs +50 -0
- package/vendor/nanocodex/cloud/actions/mpp.d.mts +28 -0
- package/vendor/nanocodex/cloud/actions/mpp.mjs +39 -0
- package/vendor/nanocodex/cloud/index.d.mts +30 -0
- package/vendor/nanocodex/cloud/index.mjs +9 -0
- package/vendor/nanocodex/cloud/internal.mjs +533 -0
- package/vendor/nanocodex/cloud/mercator.mjs +108 -0
- package/vendor/nanocodex/cloud/server/HostPrincipal.d.mts +34 -0
- package/vendor/nanocodex/cloud/server/HostPrincipal.mjs +202 -0
- package/vendor/nanocodex/cloud/server/index.d.mts +1 -0
- package/vendor/nanocodex/cloud/server/index.mjs +1 -0
- package/vendor/nanocodex/cloud/types.d.mts +211 -0
- package/vendor/nanocodex/cloudflare/Agent.d.mts +133 -0
- package/vendor/nanocodex/cloudflare/Agent.mjs +811 -0
- package/vendor/nanocodex/cloudflare/egress-subject.mjs +19 -0
- package/vendor/nanocodex/cloudflare/egress.d.mts +41 -0
- package/vendor/nanocodex/cloudflare/egress.mjs +119 -0
- package/vendor/nanocodex/cloudflare/event-socket.mjs +316 -0
- package/vendor/nanocodex/cloudflare/index.d.mts +7 -0
- package/vendor/nanocodex/cloudflare/index.mjs +6 -0
- package/vendor/nanocodex/host/Agent.d.mts +55 -0
- package/vendor/nanocodex/host/Agent.mjs +1 -0
- package/vendor/nanocodex/host/index.d.mts +82 -0
- package/vendor/nanocodex/host/index.mjs +10 -0
- package/vendor/nanocodex/index.d.mts +81 -0
- package/vendor/nanocodex/index.mjs +12 -0
- package/vendor/nanocodex/internal.mjs +1275 -0
- package/vendor/nanocodex/managed/Agent.d.mts +380 -0
- package/vendor/nanocodex/managed/Agent.mjs +1694 -0
- package/vendor/nanocodex/managed/ManagedError.d.mts +9 -0
- package/vendor/nanocodex/managed/ManagedError.mjs +8 -0
- package/vendor/nanocodex/managed/README.md +241 -0
- package/vendor/nanocodex/managed/Voice.mjs +202 -0
- package/vendor/nanocodex/managed/index.d.mts +20 -0
- package/vendor/nanocodex/managed/index.mjs +2 -0
- package/vendor/nanocodex/managed/internal.mjs +119 -0
- package/vendor/nanocodex/node/Agent.d.mts +50 -0
- package/vendor/nanocodex/node/Agent.mjs +203 -0
- package/vendor/nanocodex/node/ChatGptSubscription.d.mts +9 -0
- package/vendor/nanocodex/node/ChatGptSubscription.mjs +17 -0
- package/vendor/nanocodex/node/Transport.d.mts +44 -0
- package/vendor/nanocodex/node/Transport.mjs +46 -0
- package/vendor/nanocodex/node/host.mjs +731 -0
- package/vendor/nanocodex/node/index.d.mts +73 -0
- package/vendor/nanocodex/node/index.mjs +17 -0
- package/vendor/nanocodex/node/workspace.d.mts +10 -0
- package/vendor/nanocodex/node/workspace.mjs +198 -0
- package/vendor/nanocodex/package.json +200 -0
- package/vendor/nanocodex/pkg-node/nanocodex.d.ts +675 -0
- package/vendor/nanocodex/pkg-node/nanocodex.js +2628 -0
- package/vendor/nanocodex/pkg-node/nanocodex_bg.wasm.d.ts +105 -0
- package/vendor/nanocodex/pkg-node/package.json +1 -0
- package/vendor/nanocodex/pkg-web/.nanocodex-bindgen-stamp +6 -0
- package/vendor/nanocodex/pkg-web/nanocodex-build.json +1 -0
- package/vendor/nanocodex/pkg-web/nanocodex.d.ts +805 -0
- package/vendor/nanocodex/pkg-web/nanocodex.js +2714 -0
- package/vendor/nanocodex/pkg-web/nanocodex_bg.js +2615 -0
- package/vendor/nanocodex/pkg-web/nanocodex_bg.wasm +0 -0
- package/vendor/nanocodex/pkg-web/nanocodex_bg.wasm.d.ts +105 -0
- package/vendor/nanocodex/pkg-web/nanocodex_worker.js +9 -0
- package/vendor/nanocodex/pkg-web/package.json +1 -0
- package/vendor/nanocodex/runtime/chatgpt-subscription.mjs +212 -0
- package/vendor/nanocodex/runtime/cloudflare-durability-store.d.mts +26 -0
- package/vendor/nanocodex/runtime/cloudflare-durability-store.mjs +168 -0
- package/vendor/nanocodex/runtime/code-evaluator.worker.mjs +137 -0
- package/vendor/nanocodex/runtime/code-runtime.mjs +1 -0
- package/vendor/nanocodex/runtime/durability-store.d.mts +85 -0
- package/vendor/nanocodex/runtime/durability-store.mjs +631 -0
- package/vendor/nanocodex/runtime/durability.mjs +153 -0
- package/vendor/nanocodex/runtime/managed-transport.mjs +460 -0
- package/vendor/nanocodex/runtime/mcp-runtime.mjs +534 -0
- package/vendor/nanocodex/runtime/postgres-durability-store.d.mts +64 -0
- package/vendor/nanocodex/runtime/postgres-durability-store.mjs +532 -0
- package/vendor/nanocodex/runtime/quickjs-evaluator.d.mts +17 -0
- package/vendor/nanocodex/runtime/quickjs-evaluator.mjs +236 -0
- package/vendor/nanocodex/runtime/responses-transport.mjs +22 -0
- package/vendor/nanocodex/runtime/subagents.d.mts +107 -0
- package/vendor/nanocodex/runtime/subagents.mjs +54 -0
- package/vendor/nanocodex/runtime/subscription-store.d.mts +8 -0
- package/vendor/nanocodex/runtime/subscription-store.mjs +42 -0
- package/vendor/nanocodex/runtime/tempo-provider.d.mts +125 -0
- package/vendor/nanocodex/runtime/tempo-provider.mjs +264 -0
- package/vendor/nanocodex/runtime/tool-configuration.mjs +1 -0
- package/vendor/nanocodex/runtime/tool-router.mjs +1 -0
- package/vendor/nanocodex/runtime/utf8.mjs +1 -0
- package/vendor/nanocodex/runtime/worker-evaluator.mjs +162 -0
- package/vendor/nanocodex/runtime/workspace.d.mts +1 -0
- package/vendor/nanocodex/runtime/workspace.mjs +1 -0
- package/vendor/nanocodex/tools/Tools.d.mts +56 -0
- package/vendor/nanocodex/tools/Tools.mjs +136 -0
- package/vendor/nanocodex/tools/artifact.d.mts +1 -0
- package/vendor/nanocodex/tools/artifact.mjs +1 -0
- package/vendor/nanocodex/tools/attachment.mjs +1 -0
- package/vendor/nanocodex/tools/bash.d.mts +1 -0
- package/vendor/nanocodex/tools/bash.mjs +1 -0
- package/vendor/nanocodex/tools/browser/accountInfo.mjs +795 -0
- package/vendor/nanocodex/tools/browser/browserBuffer.mjs +18 -0
- package/vendor/nanocodex/tools/browser/browserCompiler.mjs +155 -0
- package/vendor/nanocodex/tools/browser/browserEgress.mjs +161 -0
- package/vendor/nanocodex/tools/browser/browserPython.mjs +133 -0
- package/vendor/nanocodex/tools/browser/browserShell.mjs +1075 -0
- package/vendor/nanocodex/tools/browser/browserSprintf.mjs +4 -0
- package/vendor/nanocodex/tools/browser/browserSsh.mjs +201 -0
- package/vendor/nanocodex/tools/browser/browserZlib.mjs +136 -0
- package/vendor/nanocodex/tools/browser/compiler.worker.mjs +160 -0
- package/vendor/nanocodex/tools/browser/devTunnelsSshBrowser.mjs +13 -0
- package/vendor/nanocodex/tools/browser/index.d.mts +209 -0
- package/vendor/nanocodex/tools/browser/index.mjs +174 -0
- package/vendor/nanocodex/tools/browser/opfsGit.mjs +248 -0
- package/vendor/nanocodex/tools/browser/python.worker.mjs +114 -0
- package/vendor/nanocodex/tools/browser/threadGit.mjs +197 -0
- package/vendor/nanocodex/tools/browser/unsupportedNodeRsa.mjs +5 -0
- package/vendor/nanocodex/tools/browser/workspace.mjs +83 -0
- package/vendor/nanocodex/tools/dataset.d.mts +1 -0
- package/vendor/nanocodex/tools/dataset.mjs +1 -0
- package/vendor/nanocodex/tools/datasetContract.mjs +1 -0
- package/vendor/nanocodex/tools/datasetEngine.mjs +1 -0
- package/vendor/nanocodex/tools/hostedCatalog.d.mts +1 -0
- package/vendor/nanocodex/tools/hostedCatalog.mjs +1 -0
- package/vendor/nanocodex/tools/index.d.mts +49 -0
- package/vendor/nanocodex/tools/index.mjs +19 -0
- package/vendor/nanocodex/tools/namedTool.mjs +1 -0
- package/vendor/nanocodex/tools/repository-workspace.d.mts +1 -0
- package/vendor/nanocodex/tools/repository-workspace.mjs +1 -0
- package/vendor/nanocodex/tools/ssh.d.mts +1 -0
- package/vendor/nanocodex/tools/ssh.mjs +1 -0
- package/vendor/nanocodex/tools/standard.mjs +1 -0
- package/vendor/nanocodex/tools/standardDescriptions.mjs +1 -0
- package/vendor/nanocodex/types.d.mts +663 -0
- package/vendor/nanocodex/wasm.d.mts +4 -0
- package/vendor/nanocodex/worker/ChatGptSubscription.d.mts +9 -0
- package/vendor/nanocodex/worker/ChatGptSubscription.mjs +29 -0
- package/vendor/nanocodex/worker/index.d.mts +18 -0
- package/vendor/nanocodex/worker/index.mjs +5 -0
- package/vendor/nanocodex-tools/README.md +65 -0
- package/vendor/nanocodex-tools/dist/hosted/app-tool-catalog.d.ts +7 -0
- package/vendor/nanocodex-tools/dist/hosted/app-tool-catalog.js +14 -0
- package/vendor/nanocodex-tools/dist/hosted/broker-core.d.ts +172 -0
- package/vendor/nanocodex-tools/dist/hosted/broker-core.js +1278 -0
- package/vendor/nanocodex-tools/dist/hosted/index.d.ts +3 -0
- package/vendor/nanocodex-tools/dist/hosted/index.js +3 -0
- package/vendor/nanocodex-tools/dist/hosted/protocol.d.ts +120 -0
- package/vendor/nanocodex-tools/dist/hosted/protocol.js +415 -0
- package/vendor/nanocodex-tools/dist/index.d.ts +19 -0
- package/vendor/nanocodex-tools/dist/index.js +14 -0
- package/vendor/nanocodex-tools/dist/memory.d.ts +204 -0
- package/vendor/nanocodex-tools/dist/memory.js +411 -0
- package/vendor/nanocodex-tools/dist/namespace.d.ts +87 -0
- package/vendor/nanocodex-tools/dist/namespace.js +338 -0
- package/vendor/nanocodex-tools/dist/repository-archive.d.ts +4 -0
- package/vendor/nanocodex-tools/dist/repository-archive.js +104 -0
- package/vendor/nanocodex-tools/dist/runtime.d.ts +30 -0
- package/vendor/nanocodex-tools/dist/runtime.js +37 -0
- package/vendor/nanocodex-tools/dist/session.d.ts +167 -0
- package/vendor/nanocodex-tools/dist/session.js +286 -0
- package/vendor/nanocodex-tools/dist/shell.d.ts +51 -0
- package/vendor/nanocodex-tools/dist/shell.js +553 -0
- package/vendor/nanocodex-tools/dist/ssh.d.ts +29 -0
- package/vendor/nanocodex-tools/dist/ssh.js +66 -0
- package/vendor/nanocodex-tools/dist/workspace.d.ts +45 -0
- package/vendor/nanocodex-tools/dist/workspace.js +237 -0
- package/vendor/nanocodex-tools/package.json +122 -0
- package/vendor/nanocodex-tools/runtime/code-runtime.mjs +817 -0
- package/vendor/nanocodex-tools/runtime/tool-configuration.mjs +50 -0
- package/vendor/nanocodex-tools/runtime/tool-router.mjs +730 -0
- package/vendor/nanocodex-tools/runtime/utf8.d.mts +2 -0
- package/vendor/nanocodex-tools/runtime/utf8.mjs +25 -0
- package/vendor/nanocodex-tools/tools/artifact.d.mts +69 -0
- package/vendor/nanocodex-tools/tools/artifact.mjs +270 -0
- package/vendor/nanocodex-tools/tools/attachment.mjs +603 -0
- package/vendor/nanocodex-tools/tools/bash.d.mts +90 -0
- package/vendor/nanocodex-tools/tools/bash.mjs +742 -0
- package/vendor/nanocodex-tools/tools/dataset.d.mts +9 -0
- package/vendor/nanocodex-tools/tools/dataset.mjs +47 -0
- package/vendor/nanocodex-tools/tools/datasetContract.mjs +54 -0
- package/vendor/nanocodex-tools/tools/datasetEngine.mjs +1167 -0
- package/vendor/nanocodex-tools/tools/execution-contract.d.mts +5 -0
- package/vendor/nanocodex-tools/tools/execution-contract.mjs +63 -0
- package/vendor/nanocodex-tools/tools/hostedCatalog.d.mts +20 -0
- package/vendor/nanocodex-tools/tools/hostedCatalog.mjs +67 -0
- package/vendor/nanocodex-tools/tools/hostedMachine.d.mts +10 -0
- package/vendor/nanocodex-tools/tools/hostedMachine.mjs +56 -0
- package/vendor/nanocodex-tools/tools/just-bash-browser.d.mts +1 -0
- package/vendor/nanocodex-tools/tools/just-bash-browser.mjs +1 -0
- package/vendor/nanocodex-tools/tools/namedTool.d.mts +3 -0
- package/vendor/nanocodex-tools/tools/namedTool.mjs +3 -0
- package/vendor/nanocodex-tools/tools/nodeProcess.d.mts +10 -0
- package/vendor/nanocodex-tools/tools/nodeProcess.mjs +314 -0
- package/vendor/nanocodex-tools/tools/processOutput.mjs +56 -0
- package/vendor/nanocodex-tools/tools/repository-workspace.d.mts +55 -0
- package/vendor/nanocodex-tools/tools/repository-workspace.mjs +397 -0
- package/vendor/nanocodex-tools/tools/ssh.d.mts +56 -0
- package/vendor/nanocodex-tools/tools/ssh.mjs +503 -0
- package/vendor/nanocodex-tools/tools/standard.mjs +458 -0
- package/vendor/nanocodex-tools/tools/standardDescriptions.mjs +3 -0
- package/vendor/nanocodex-tools/tools/types.d.mts +83 -0
- package/vendor/nanocodex-tools/tools/workspace.d.mts +25 -0
- package/vendor/nanocodex-tools/tools/workspace.mjs +282 -0
- package/vendor/nanocodex-tools/tools/x.d.mts +30 -0
- package/vendor/nanocodex-tools/tools/x.mjs +91 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
createMemoryChatGptSubscriptionStore,
|
|
3
|
+
subscriptionRevision,
|
|
4
|
+
} from "../runtime/subscription-store.mjs";
|
|
5
|
+
export type {
|
|
6
|
+
ChatGptCredential,
|
|
7
|
+
ChatGptCredentialSeed,
|
|
8
|
+
ChatGptLoginStatus,
|
|
9
|
+
ChatGptSubscriptionHandle,
|
|
10
|
+
ChatGptSubscriptionOptions,
|
|
11
|
+
ChatGptSubscriptionStore,
|
|
12
|
+
MemoryChatGptSubscriptionStore,
|
|
13
|
+
SubscriptionCommitRequest,
|
|
14
|
+
SubscriptionCommitResult,
|
|
15
|
+
SubscriptionRevision,
|
|
16
|
+
SubscriptionStoredValue,
|
|
17
|
+
} from "../types.mjs";
|
|
18
|
+
export * as ChatGptSubscription from "./ChatGptSubscription.mjs";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# nanocodex-tools
|
|
2
|
+
|
|
3
|
+
Reusable, platform-neutral JavaScript tools for Nanocodex agents: the common
|
|
4
|
+
tool router and Code Mode runtime, attachment and hosted-tool protocols,
|
|
5
|
+
durable-memory parsing and ranking, artifact and dataset tools, persistent
|
|
6
|
+
workspace adaptation, a bounded Just Bash runtime, Git/GitHub compatibility
|
|
7
|
+
commands, repository materialization, and workspace-backed SSH composition.
|
|
8
|
+
Session-search parsing, retrieval policy, and bounded model-visible projections
|
|
9
|
+
are exposed through the dedicated `nanocodex-tools/session` entrypoint.
|
|
10
|
+
|
|
11
|
+
`nanocodex-tools/x` exports the native `browseX({ fetch })` tool, its request
|
|
12
|
+
validator, and `X_API` discovery metadata. Hosts inject transport to the
|
|
13
|
+
[Nanocodex X Worker](../x-api/README.md); provider access stays in that Worker.
|
|
14
|
+
|
|
15
|
+
Hosts own persistence, network policy, credentials, and socket transports and
|
|
16
|
+
inject those capabilities through the package's narrow interfaces.
|
|
17
|
+
|
|
18
|
+
Application tools may provide a provider-native `definition` in addition to
|
|
19
|
+
the convenience `description`, `parameters`, and `outputSchema` fields. Use a
|
|
20
|
+
`type: "custom"` definition for a grammar-constrained free-form tool; its
|
|
21
|
+
handler receives the exact input string and the usual `ToolContext`:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const applyPatch = {
|
|
25
|
+
description: "Apply one patch through the host-owned workspace.",
|
|
26
|
+
definition: {
|
|
27
|
+
type: "custom",
|
|
28
|
+
description: "Apply one patch through the host-owned workspace.",
|
|
29
|
+
format: {
|
|
30
|
+
type: "grammar",
|
|
31
|
+
syntax: "lark",
|
|
32
|
+
definition: 'start: "patch"',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
handler(input, context) {
|
|
36
|
+
return applyPatchInHost(input, context);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The router canonicalizes the definition name from the containing map key or
|
|
42
|
+
`NamedTool.name`. `ToolDefinition`, `CustomToolFormat`, and `ToolJson` are
|
|
43
|
+
exported types for hosts that want to annotate this shape directly. Nanocodex
|
|
44
|
+
executes completed custom calls once; history, snapshots, and resumed sessions
|
|
45
|
+
retain their call and output items without replaying the handler.
|
|
46
|
+
|
|
47
|
+
`nanocodex` owns the Rust/WASM agent runtime and composes WASM, workspace, and
|
|
48
|
+
MCP adapters around these capabilities. It imports and reexports this package's
|
|
49
|
+
JS-only host capabilities; `nanocodex-tools` never imports `nanocodex`.
|
|
50
|
+
|
|
51
|
+
Cloudflare Workers may supply Durable Object persistence and WebSocket
|
|
52
|
+
registries to the hosted-tools core, but Cloudflare bindings, account authority,
|
|
53
|
+
Connect grants, and storage schemas remain owned by those Workers.
|
|
54
|
+
|
|
55
|
+
`nanocodex-tools/node` supplies native `exec_command` and `write_stdin` pipe
|
|
56
|
+
sessions for explicitly authorized desktop/Node Hands. Processes use an explicit
|
|
57
|
+
workspace cwd and a small environment allowlist, and sessions are fenced by the
|
|
58
|
+
calling agent. The workspace is not an OS sandbox; hosts must make the native
|
|
59
|
+
authority clear and use a VM for isolation. Closing the runtime terminates owned
|
|
60
|
+
processes. This entrypoint imports Node APIs and must not be bundled into Workers
|
|
61
|
+
or browser applications.
|
|
62
|
+
|
|
63
|
+
Native Node Hands retain unread command output in private temporary files. Reply
|
|
64
|
+
budgets control each poll, without discarding older output. Files are removed
|
|
65
|
+
when fully consumed or when their owning session or Hand is closed.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HostedToolCatalogEntry } from "./protocol.js";
|
|
2
|
+
export declare function isAppToolCatalogDigest(value: unknown): value is `0x${string}`;
|
|
3
|
+
export declare function hostedToolCatalogEntryAllowed(grant: Readonly<{
|
|
4
|
+
grantId: string;
|
|
5
|
+
mcpIds: readonly string[];
|
|
6
|
+
appToolCatalogDigest?: `0x${string}`;
|
|
7
|
+
}> | undefined, hostConnectGrantId: string | undefined, hostAppToolCatalogDigest: string | undefined, entry: HostedToolCatalogEntry): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isAppToolCatalogDigest(value) {
|
|
2
|
+
return typeof value === "string" && /^0x[0-9a-f]{64}$/.test(value);
|
|
3
|
+
}
|
|
4
|
+
export function hostedToolCatalogEntryAllowed(grant, hostConnectGrantId, hostAppToolCatalogDigest, entry) {
|
|
5
|
+
if (grant === undefined)
|
|
6
|
+
return hostConnectGrantId === undefined;
|
|
7
|
+
if (hostConnectGrantId !== grant.grantId)
|
|
8
|
+
return false;
|
|
9
|
+
const match = /^mcp:([A-Za-z0-9_-]{43})$/.exec(entry.provider);
|
|
10
|
+
if (match !== null)
|
|
11
|
+
return grant.mcpIds.includes(match[1]);
|
|
12
|
+
return grant.appToolCatalogDigest !== undefined
|
|
13
|
+
&& hostAppToolCatalogDigest === grant.appToolCatalogDigest;
|
|
14
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type HostedToolCallOutcome, type HostedToolCatalogEntry, type HostedMachine } from "./protocol.js";
|
|
2
|
+
import type { ToolContext } from "../../tools/types.mjs";
|
|
3
|
+
export declare const HOSTED_MACHINE_TOOL_NAMES: readonly ["exec_command", "write_stdin", "preview"];
|
|
4
|
+
/**
|
|
5
|
+
* Marks the one case where an attached source is known to be absent before a
|
|
6
|
+
* durable admission. The unified ToolRouter may then select the exact
|
|
7
|
+
* same-name cloud contract. It must never infer this from an outcome message:
|
|
8
|
+
* every other unavailable, cancellation, timeout, and ambiguous outcome is
|
|
9
|
+
* pinned to the attached source and is final.
|
|
10
|
+
*/
|
|
11
|
+
export declare const HOSTED_TOOLS_PRE_ADMISSION_UNAVAILABLE: unique symbol;
|
|
12
|
+
export type HostedToolsCallState = "admitted" | "dispatched" | "completed" | "unavailable" | "ambiguous" | "cancelled";
|
|
13
|
+
export type HostedToolsStateRow = {
|
|
14
|
+
route_id: string;
|
|
15
|
+
generation: number;
|
|
16
|
+
host_id: string | null;
|
|
17
|
+
lease_id: string | null;
|
|
18
|
+
lease_expires_at: number;
|
|
19
|
+
catalog_json: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type HostedToolsCallRow = {
|
|
22
|
+
call_id: string;
|
|
23
|
+
session_id: string;
|
|
24
|
+
source_call_id: string;
|
|
25
|
+
host_id: string;
|
|
26
|
+
lease_id: string;
|
|
27
|
+
generation: number;
|
|
28
|
+
model: string;
|
|
29
|
+
name: string;
|
|
30
|
+
input_json: string;
|
|
31
|
+
output_token_budget: number;
|
|
32
|
+
output_byte_budget: number;
|
|
33
|
+
deadline_at: number;
|
|
34
|
+
cancel_requested: number;
|
|
35
|
+
state: HostedToolsCallState;
|
|
36
|
+
result_json: string | null;
|
|
37
|
+
receipt_json: string | null;
|
|
38
|
+
};
|
|
39
|
+
export type HostedToolsSocket = {
|
|
40
|
+
readonly readyState: number;
|
|
41
|
+
send(data: string): void;
|
|
42
|
+
close(code?: number, reason?: string): void;
|
|
43
|
+
};
|
|
44
|
+
export type HostedToolsBrokerCoreContext = Readonly<{
|
|
45
|
+
accept(socket: HostedToolsSocket): void;
|
|
46
|
+
sockets(): HostedToolsSocket[];
|
|
47
|
+
readAttachment(socket: HostedToolsSocket): unknown;
|
|
48
|
+
writeAttachment(socket: HostedToolsSocket, value: unknown): void;
|
|
49
|
+
}>;
|
|
50
|
+
export type HostedToolsProviderDefinition = Readonly<HostedToolCatalogEntry>;
|
|
51
|
+
export type HostedToolsInvokeRequest = Readonly<{
|
|
52
|
+
sessionId: string;
|
|
53
|
+
callId: string;
|
|
54
|
+
model: string;
|
|
55
|
+
input: Record<string, unknown> | string;
|
|
56
|
+
outputTokenBudget: number;
|
|
57
|
+
outputByteBudget?: number;
|
|
58
|
+
deadlineAt?: number;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}>;
|
|
61
|
+
export type HostedToolsPreparedTool = Readonly<{
|
|
62
|
+
routeToken: string;
|
|
63
|
+
connectGrantId?: string;
|
|
64
|
+
appToolCatalogDigest?: string;
|
|
65
|
+
canonicalName: string;
|
|
66
|
+
machine?: HostedMachine;
|
|
67
|
+
entry: HostedToolCatalogEntry;
|
|
68
|
+
invoke(request: HostedToolsInvokeRequest): Promise<HostedToolsInvocationOutcome>;
|
|
69
|
+
}>;
|
|
70
|
+
export type HostedToolsCodeDefinition = HostedToolCatalogEntry["definition"] & {
|
|
71
|
+
defer_loading: true;
|
|
72
|
+
};
|
|
73
|
+
export type HostedToolsCatalogCandidate = Readonly<Omit<HostedToolCatalogEntry, "definition"> & {
|
|
74
|
+
definition: HostedToolsCodeDefinition;
|
|
75
|
+
}>;
|
|
76
|
+
export type HostedToolsCatalogValidator = (definitions: readonly HostedToolsCatalogCandidate[]) => true;
|
|
77
|
+
export type HostedToolsCodeTool = Readonly<{
|
|
78
|
+
name: string;
|
|
79
|
+
parallelSafe: boolean;
|
|
80
|
+
/** Opaque immutable route identity for trusted broker-to-broker relays. */
|
|
81
|
+
routeToken?: string;
|
|
82
|
+
handler(input: unknown, context: HostedToolsInvocationContext): Promise<unknown>;
|
|
83
|
+
}>;
|
|
84
|
+
export type HostedToolsInvocationContext = Readonly<Pick<ToolContext, "sessionId" | "callId"> & Partial<Pick<ToolContext, "parentCallId" | "model" | "signal" | "subagent">>>;
|
|
85
|
+
export type HostedToolsAuthorizationContext = Pick<ToolContext, "sessionId" | "subagent">;
|
|
86
|
+
export type HostedMachineToolName = (typeof HOSTED_MACHINE_TOOL_NAMES)[number];
|
|
87
|
+
export interface HostedToolsDynamicProvider {
|
|
88
|
+
definitions(): readonly HostedToolsCodeDefinition[];
|
|
89
|
+
resolve(name: string): HostedToolsCodeTool | undefined;
|
|
90
|
+
/** Installed by the owning ToolRouter to reject non-parity catalogs before ACK. */
|
|
91
|
+
setCatalogValidator(validator: HostedToolsCatalogValidator | undefined): void;
|
|
92
|
+
}
|
|
93
|
+
/** Injectable durable call ledger boundary; the production default is Durable Object SQLite. */
|
|
94
|
+
export interface HostedToolsBrokerPersistence {
|
|
95
|
+
initialize(now: number): readonly HostedToolsStateRow[];
|
|
96
|
+
transaction<T>(callback: () => T): T;
|
|
97
|
+
states(): readonly HostedToolsStateRow[];
|
|
98
|
+
state(routeId: string): HostedToolsStateRow | undefined;
|
|
99
|
+
replaceHost(row: HostedToolsStateRow): void;
|
|
100
|
+
clearHost(leaseId: string, generation: number): void;
|
|
101
|
+
clearCatalog(leaseId: string, generation: number): void;
|
|
102
|
+
call(callId: string): HostedToolsCallRow | undefined;
|
|
103
|
+
callBySource(sessionId: string, sourceCallId: string): HostedToolsCallRow | undefined;
|
|
104
|
+
insertCall(row: HostedToolsCallRow, now: number): void;
|
|
105
|
+
markCancelRequested(callId: string, now: number): HostedToolsCallRow | undefined;
|
|
106
|
+
transitionCall(callId: string, from: readonly HostedToolsCallState[], state: HostedToolsCallState, resultJson: string, now: number): HostedToolsCallRow | undefined;
|
|
107
|
+
recordLateReceipt(callId: string, receiptJson: string, now: number): HostedToolsCallRow | undefined;
|
|
108
|
+
markGenerationAmbiguous(leaseId: string, generation: number, resultJson: string, now: number): void;
|
|
109
|
+
activeCallCount(leaseId: string, generation: number): number;
|
|
110
|
+
generationCallCount(leaseId: string, generation: number): number;
|
|
111
|
+
pruneReceipts(limit: number): void;
|
|
112
|
+
}
|
|
113
|
+
export type HostedToolsBrokerCoreOptions = Readonly<{
|
|
114
|
+
now?: () => number;
|
|
115
|
+
randomUUID?: () => string;
|
|
116
|
+
maxInFlight?: number;
|
|
117
|
+
maxCallsPerGeneration?: number;
|
|
118
|
+
persistence: HostedToolsBrokerPersistence;
|
|
119
|
+
/** Resume exact live hibernated sockets instead of forcing every route to reconnect. */
|
|
120
|
+
resumeRetainedSockets?: boolean;
|
|
121
|
+
onCatalogChanged?: (definitions: readonly HostedToolsProviderDefinition[]) => void;
|
|
122
|
+
entryAllowed?: (entry: HostedToolCatalogEntry, connectGrantId?: string, appToolCatalogDigest?: string, context?: HostedToolsAuthorizationContext) => boolean;
|
|
123
|
+
renewLeasedAttachment?: (renewal: HostedToolsLeasedAttachmentRenewal) => Promise<number | undefined>;
|
|
124
|
+
}>;
|
|
125
|
+
export type HostedToolsLeasedAttachmentPolicy = Readonly<{
|
|
126
|
+
expectedAttachmentId: string;
|
|
127
|
+
maximumLeaseExpiresAt: number;
|
|
128
|
+
fixedRouteId: string;
|
|
129
|
+
renewalToken: string;
|
|
130
|
+
}>;
|
|
131
|
+
export type HostedToolsLeasedAttachmentRenewal = Readonly<{
|
|
132
|
+
expectedAttachmentId: string;
|
|
133
|
+
fixedRouteId: string;
|
|
134
|
+
renewalToken: string;
|
|
135
|
+
}>;
|
|
136
|
+
/** Owns one reverse-tool attachment over an injected socket and durable ledger. */
|
|
137
|
+
export declare class HostedToolsBrokerCore {
|
|
138
|
+
#private;
|
|
139
|
+
readonly context: HostedToolsBrokerCoreContext;
|
|
140
|
+
constructor(context: HostedToolsBrokerCoreContext, options: HostedToolsBrokerCoreOptions);
|
|
141
|
+
owns(socket: HostedToolsSocket): boolean;
|
|
142
|
+
message(socket: HostedToolsSocket, message: string): Promise<void>;
|
|
143
|
+
close(socket: HostedToolsSocket, reason: string): void;
|
|
144
|
+
shutdown(reason: string): void;
|
|
145
|
+
/** Fences one attachment only when its exact durable route is still current. */
|
|
146
|
+
revokeRoute(routeId: string, reason: string): boolean;
|
|
147
|
+
isReady(): boolean;
|
|
148
|
+
hasPendingCalls(): boolean;
|
|
149
|
+
provider(): HostedToolsDynamicProvider;
|
|
150
|
+
/** Resolves one canonical machine primitive against its exact admitted attachment generation. */
|
|
151
|
+
machineTool(machineId: string, name: HostedMachineToolName, context?: HostedToolsAuthorizationContext): HostedToolsCodeTool | undefined;
|
|
152
|
+
/** Resolves one canonical machine primitive only on the named durable route. */
|
|
153
|
+
machineToolOnRoute(routeId: string, machineId: string, name: HostedMachineToolName, context?: HostedToolsAuthorizationContext): HostedToolsCodeTool | undefined;
|
|
154
|
+
/** Returns one live machine only when its exact durable route still owns it. */
|
|
155
|
+
machineOnRoute(routeId: string, machineId: string): HostedMachine | undefined;
|
|
156
|
+
/** Returns the live, non-secret user-machine snapshot for the account-owned host. */
|
|
157
|
+
machines(): readonly HostedMachine[];
|
|
158
|
+
accept(socket: HostedToolsSocket, sessionId: string, allowedMcpIds?: readonly string[], appToolCatalogDigest?: `0x${string}`, connectGrantId?: string, leasedAttachment?: HostedToolsLeasedAttachmentPolicy): void;
|
|
159
|
+
handles(socket: HostedToolsSocket): boolean;
|
|
160
|
+
webSocketMessage(socket: HostedToolsSocket, message: string | ArrayBuffer): Promise<void>;
|
|
161
|
+
webSocketClose(socket: HostedToolsSocket, code: number, reason: string): void;
|
|
162
|
+
webSocketError(socket: HostedToolsSocket): void;
|
|
163
|
+
/** May be called by an owning alarm; normal reads and call timers also expire leases lazily. */
|
|
164
|
+
expire(): void;
|
|
165
|
+
cancel(callId: string): boolean;
|
|
166
|
+
}
|
|
167
|
+
export declare function hostedToolsUnavailable(message: string): HostedToolCallOutcome;
|
|
168
|
+
type HostedToolsInvocationOutcome = HostedToolCallOutcome & {
|
|
169
|
+
[HOSTED_TOOLS_PRE_ADMISSION_UNAVAILABLE]?: true;
|
|
170
|
+
};
|
|
171
|
+
export declare function hostedToolsAmbiguous(message: string): HostedToolCallOutcome;
|
|
172
|
+
export {};
|