@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,203 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import initWeb, { Nanocodex as WebNanocodex } from "../pkg-web/nanocodex.js";
|
|
3
|
+
|
|
4
|
+
import { agentActions } from "../actions/index.mjs";
|
|
5
|
+
import {
|
|
6
|
+
activateHost,
|
|
7
|
+
bindHostSession,
|
|
8
|
+
createAgentClient,
|
|
9
|
+
createEventChannel,
|
|
10
|
+
createSessionId,
|
|
11
|
+
defineRuntime,
|
|
12
|
+
loadDurabilityRuntime,
|
|
13
|
+
loadSubscriptionRuntime,
|
|
14
|
+
reportError,
|
|
15
|
+
registerDefinitionHost,
|
|
16
|
+
releaseDefinitionHost,
|
|
17
|
+
releaseHostSession,
|
|
18
|
+
toWasmConfig,
|
|
19
|
+
} from "../internal.mjs";
|
|
20
|
+
import { createNodeHost } from "./host.mjs";
|
|
21
|
+
import { resolveResponsesTransport } from "../runtime/responses-transport.mjs";
|
|
22
|
+
import {
|
|
23
|
+
createManagedAgent,
|
|
24
|
+
managedTransportOptions,
|
|
25
|
+
} from "../runtime/managed-transport.mjs";
|
|
26
|
+
import { resolveTools } from "../runtime/tool-configuration.mjs";
|
|
27
|
+
|
|
28
|
+
let initializedWeb;
|
|
29
|
+
let NodeNanocodex;
|
|
30
|
+
|
|
31
|
+
export function create(options = {}) {
|
|
32
|
+
if (managedTransportOptions(options?.transport)) return createManagedAgent(options);
|
|
33
|
+
const {
|
|
34
|
+
model,
|
|
35
|
+
thinking,
|
|
36
|
+
reasoningMode,
|
|
37
|
+
fastMode,
|
|
38
|
+
instructions,
|
|
39
|
+
additionalInstructions,
|
|
40
|
+
companionCompactionInstruction,
|
|
41
|
+
resolveCompactionInstruction,
|
|
42
|
+
historySeed,
|
|
43
|
+
sessionId,
|
|
44
|
+
workspace,
|
|
45
|
+
resume,
|
|
46
|
+
durability,
|
|
47
|
+
durabilityId,
|
|
48
|
+
transport,
|
|
49
|
+
module,
|
|
50
|
+
filesystem,
|
|
51
|
+
tools,
|
|
52
|
+
subagents = true,
|
|
53
|
+
toolMode,
|
|
54
|
+
mcp,
|
|
55
|
+
codeEvaluator,
|
|
56
|
+
} = options;
|
|
57
|
+
const stableSessionId = sessionId ?? createSessionId();
|
|
58
|
+
const {
|
|
59
|
+
apiKey,
|
|
60
|
+
subscription,
|
|
61
|
+
mpp,
|
|
62
|
+
websocketUrl,
|
|
63
|
+
apiBaseUrl,
|
|
64
|
+
websocketWarmup,
|
|
65
|
+
} = resolveResponsesTransport(transport);
|
|
66
|
+
if (typeof subagents !== "boolean") {
|
|
67
|
+
throw new TypeError("subagents must be a boolean");
|
|
68
|
+
}
|
|
69
|
+
const { tools: hostTools, subagents: subagentConfig } = resolveTools(tools, {
|
|
70
|
+
defaultSubagents: subagents,
|
|
71
|
+
});
|
|
72
|
+
if (!subagents && subagentConfig !== undefined) {
|
|
73
|
+
throw new TypeError("Subagents.create() conflicts with subagents: false");
|
|
74
|
+
}
|
|
75
|
+
const events = createEventChannel();
|
|
76
|
+
if (filesystem && workspace !== undefined && workspace !== filesystem.root) {
|
|
77
|
+
throw new TypeError("workspace must match filesystem.root when both are provided");
|
|
78
|
+
}
|
|
79
|
+
const tempoMcp = mpp?.[Symbol.for("nanocodex.tempo.mcp")];
|
|
80
|
+
let hostDefinitionId;
|
|
81
|
+
const host = createNodeHost({
|
|
82
|
+
mpp,
|
|
83
|
+
mcpServers: mcp === false
|
|
84
|
+
? undefined
|
|
85
|
+
: tempoMcp ? { ...tempoMcp, ...mcp } : mcp,
|
|
86
|
+
onEvent: events.emit,
|
|
87
|
+
filesystem,
|
|
88
|
+
tools: hostTools,
|
|
89
|
+
toolMode,
|
|
90
|
+
workspace: workspace ?? filesystem?.root ?? resume?.workspace,
|
|
91
|
+
codeEvaluator,
|
|
92
|
+
resolveCompactionInstruction,
|
|
93
|
+
onDispose: () => releaseDefinitionHost(hostDefinitionId),
|
|
94
|
+
});
|
|
95
|
+
let durabilityOwner;
|
|
96
|
+
let creationStarted = false;
|
|
97
|
+
hostDefinitionId = registerDefinitionHost(host);
|
|
98
|
+
activateHost(host);
|
|
99
|
+
const runtime = defineRuntime({
|
|
100
|
+
key: "node-wasm",
|
|
101
|
+
name: "Nanocodex Node WASM",
|
|
102
|
+
type: "node",
|
|
103
|
+
async create(config) {
|
|
104
|
+
creationStarted = true;
|
|
105
|
+
try {
|
|
106
|
+
if (durability !== undefined || durabilityId !== undefined) {
|
|
107
|
+
durabilityOwner = (await loadDurabilityRuntime()).own(
|
|
108
|
+
host,
|
|
109
|
+
durability,
|
|
110
|
+
durabilityId,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
activateHost(host);
|
|
114
|
+
await host.ready();
|
|
115
|
+
const Nanocodex = module === undefined
|
|
116
|
+
? loadNodeNanocodex()
|
|
117
|
+
: await loadWebNanocodex(module);
|
|
118
|
+
activateHost(host);
|
|
119
|
+
const configJson = JSON.stringify(toWasmConfig({
|
|
120
|
+
apiKey: apiKey ?? (subscription === undefined
|
|
121
|
+
? mpp === undefined ? undefined : "mpp-managed"
|
|
122
|
+
: "subscription-managed"),
|
|
123
|
+
websocketUrl: websocketUrl ?? (mpp === undefined
|
|
124
|
+
? undefined
|
|
125
|
+
: "wss://openai.mpp.tempo.xyz/v1/responses"),
|
|
126
|
+
apiBaseUrl,
|
|
127
|
+
websocketWarmup,
|
|
128
|
+
hostHttp: mpp === undefined,
|
|
129
|
+
subagents: subagentConfig,
|
|
130
|
+
hostDefinitionId,
|
|
131
|
+
...config,
|
|
132
|
+
durabilityHostId: durabilityOwner?.id,
|
|
133
|
+
}));
|
|
134
|
+
return subscription === undefined
|
|
135
|
+
? Nanocodex.create(configJson)
|
|
136
|
+
: Nanocodex.createWithChatGpt(
|
|
137
|
+
configJson,
|
|
138
|
+
(await loadSubscriptionRuntime()).rawSubscription(subscription),
|
|
139
|
+
);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
durabilityOwner?.abandon();
|
|
142
|
+
await host.dispose();
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
subscribe: events.subscribe,
|
|
147
|
+
adopt(raw) {
|
|
148
|
+
host.retain();
|
|
149
|
+
try {
|
|
150
|
+
durabilityOwner?.retain();
|
|
151
|
+
bindHostSession(host, raw.sessionId);
|
|
152
|
+
events.addSource(raw);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
events.removeSource(raw);
|
|
155
|
+
durabilityOwner?.release();
|
|
156
|
+
releaseHost(host);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
release(raw) {
|
|
161
|
+
events.removeSource(raw);
|
|
162
|
+
host.releaseSession(raw.sessionId);
|
|
163
|
+
releaseHostSession(host, raw.sessionId);
|
|
164
|
+
durabilityOwner?.release();
|
|
165
|
+
releaseHost(host);
|
|
166
|
+
},
|
|
167
|
+
decorate: (agent) => agent.extend(agentActions()),
|
|
168
|
+
});
|
|
169
|
+
return createAgentClient(runtime, {
|
|
170
|
+
model,
|
|
171
|
+
thinking,
|
|
172
|
+
reasoningMode,
|
|
173
|
+
fastMode,
|
|
174
|
+
instructions,
|
|
175
|
+
additionalInstructions,
|
|
176
|
+
companionCompactionInstruction,
|
|
177
|
+
resolveCompactionInstruction,
|
|
178
|
+
historySeed,
|
|
179
|
+
sessionId: stableSessionId,
|
|
180
|
+
workspace: workspace ?? filesystem?.root,
|
|
181
|
+
resume,
|
|
182
|
+
durabilityId,
|
|
183
|
+
}).catch(async (error) => {
|
|
184
|
+
if (!creationStarted) await host.dispose();
|
|
185
|
+
throw error;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function releaseHost(host) {
|
|
190
|
+
void host.release().catch(reportError);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function loadNodeNanocodex() {
|
|
194
|
+
const require = createRequire(import.meta.url);
|
|
195
|
+
NodeNanocodex ||= require("../pkg-node/nanocodex.js").Nanocodex;
|
|
196
|
+
return NodeNanocodex;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function loadWebNanocodex(module) {
|
|
200
|
+
initializedWeb ||= initWeb({ module_or_path: module });
|
|
201
|
+
await initializedWeb;
|
|
202
|
+
return WebNanocodex;
|
|
203
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatGptSubscriptionHandle,
|
|
3
|
+
ChatGptSubscriptionOptions,
|
|
4
|
+
} from "../types.mjs";
|
|
5
|
+
|
|
6
|
+
/** Opens the Rust-owned ChatGPT device-login and credential lifecycle. */
|
|
7
|
+
export function open(
|
|
8
|
+
options: Omit<ChatGptSubscriptionOptions, "module"> & { module?: never },
|
|
9
|
+
): Promise<ChatGptSubscriptionHandle>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
import { installHostBridge } from "../internal.mjs";
|
|
4
|
+
import { openSubscription } from "../runtime/chatgpt-subscription.mjs";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
let WasmChatGptSubscription;
|
|
8
|
+
|
|
9
|
+
/** Opens a Rust-managed ChatGPT subscription over caller-owned storage and fetch. */
|
|
10
|
+
export async function open(options) {
|
|
11
|
+
if (options?.module !== undefined) {
|
|
12
|
+
throw new TypeError("Node ChatGptSubscription does not accept a browser WASM module");
|
|
13
|
+
}
|
|
14
|
+
installHostBridge();
|
|
15
|
+
WasmChatGptSubscription ||= require("../pkg-node/nanocodex.js").ChatGptSubscription;
|
|
16
|
+
return openSubscription(options, (config) => WasmChatGptSubscription.open(config));
|
|
17
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatGptSubscriptionHandle,
|
|
3
|
+
MppSession,
|
|
4
|
+
} from "../types.mjs";
|
|
5
|
+
import type { Options as ManagedClientOptions } from "../managed/Agent.mjs";
|
|
6
|
+
|
|
7
|
+
declare const responsesTransport: unique symbol;
|
|
8
|
+
declare const managedTransport: unique symbol;
|
|
9
|
+
|
|
10
|
+
export type ResponsesTransport = Readonly<{
|
|
11
|
+
[responsesTransport]: true;
|
|
12
|
+
}>;
|
|
13
|
+
export type ManagedTransport = Readonly<{ [managedTransport]: true }>;
|
|
14
|
+
export type Transport = ResponsesTransport | ManagedTransport;
|
|
15
|
+
|
|
16
|
+
type EndpointOptions = Readonly<{
|
|
17
|
+
/** HTTPS `/v1` base used for Node's pre-output SSE fallback. */
|
|
18
|
+
apiBaseUrl?: string | undefined;
|
|
19
|
+
/** Preferred Responses WebSocket endpoint. */
|
|
20
|
+
websocketUrl?: string | undefined;
|
|
21
|
+
/** Whether the Node host should probe the WebSocket with a non-generating request. */
|
|
22
|
+
websocketWarmup?: boolean | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export function openAi(options: EndpointOptions & Readonly<{
|
|
26
|
+
apiKey: string;
|
|
27
|
+
}>): ResponsesTransport;
|
|
28
|
+
|
|
29
|
+
export function chatGpt(options: EndpointOptions & Readonly<{
|
|
30
|
+
subscription: ChatGptSubscriptionHandle;
|
|
31
|
+
}>): ResponsesTransport;
|
|
32
|
+
|
|
33
|
+
export function mpp(options: EndpointOptions & Readonly<{
|
|
34
|
+
session: MppSession;
|
|
35
|
+
}>): ResponsesTransport;
|
|
36
|
+
|
|
37
|
+
export type ManagedIdentity =
|
|
38
|
+
| Readonly<{ create: true; id?: never }>
|
|
39
|
+
| Readonly<{ id: string; create?: never }>;
|
|
40
|
+
|
|
41
|
+
/** Account-authenticated durable Agent transport with explicit create/open identity. */
|
|
42
|
+
export function managed(options: ManagedClientOptions & Readonly<{
|
|
43
|
+
agent: ManagedIdentity;
|
|
44
|
+
}>): ManagedTransport;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createResponsesTransport,
|
|
3
|
+
nonEmpty,
|
|
4
|
+
} from "../runtime/responses-transport.mjs";
|
|
5
|
+
import { createManagedTransport } from "../runtime/managed-transport.mjs";
|
|
6
|
+
|
|
7
|
+
export function openAi(options) {
|
|
8
|
+
const apiKey = nonEmpty(options?.apiKey, "OpenAI API key");
|
|
9
|
+
return createResponsesTransport({
|
|
10
|
+
apiKey,
|
|
11
|
+
...endpoints(options),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function chatGpt(options) {
|
|
16
|
+
if (!options?.subscription || typeof options.subscription !== "object") {
|
|
17
|
+
throw new TypeError("ChatGPT transport requires a subscription handle");
|
|
18
|
+
}
|
|
19
|
+
return createResponsesTransport({
|
|
20
|
+
subscription: options.subscription,
|
|
21
|
+
...endpoints(options),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function mpp(options) {
|
|
26
|
+
if (!options?.session || typeof options.session.ws !== "function") {
|
|
27
|
+
throw new TypeError("MPP transport requires a session with ws(endpoint)");
|
|
28
|
+
}
|
|
29
|
+
return createResponsesTransport({
|
|
30
|
+
mpp: options.session,
|
|
31
|
+
...endpoints(options),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Account-authenticated durable Agent transport with explicit create/open identity. */
|
|
36
|
+
export function managed(options) {
|
|
37
|
+
return createManagedTransport(options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function endpoints(options = {}) {
|
|
41
|
+
return {
|
|
42
|
+
apiBaseUrl: options.apiBaseUrl,
|
|
43
|
+
websocketUrl: options.websocketUrl,
|
|
44
|
+
websocketWarmup: options.websocketWarmup,
|
|
45
|
+
};
|
|
46
|
+
}
|