@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,663 @@
|
|
|
1
|
+
export type Thinking = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
2
|
+
export type ReasoningMode = "standard" | "pro";
|
|
3
|
+
export type Model = "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-5.6-luna" | "gpt-6-astra";
|
|
4
|
+
|
|
5
|
+
export type PromptItem =
|
|
6
|
+
| { type: "text"; text: string }
|
|
7
|
+
| { type: "image"; image_url: string; detail?: "auto" | "low" | "high" | "original" | undefined }
|
|
8
|
+
| { type: "audio"; audio_url: string };
|
|
9
|
+
|
|
10
|
+
export type PromptInput = string | readonly PromptItem[];
|
|
11
|
+
|
|
12
|
+
/** Model-visible content accepted by an engine-owned history seed. */
|
|
13
|
+
export type HistoryContentItem =
|
|
14
|
+
| { type: "input_text"; text: string }
|
|
15
|
+
| { type: "input_image"; image_url: string; detail?: "auto" | "low" | "high" | "original" | undefined }
|
|
16
|
+
| { type: "input_audio"; audio_url: string }
|
|
17
|
+
| { type: "output_text"; text: string };
|
|
18
|
+
|
|
19
|
+
/** Function or custom-tool output accepted in a history seed. */
|
|
20
|
+
export type HistoryToolOutput = string | readonly (
|
|
21
|
+
| { type: "input_text"; text: string }
|
|
22
|
+
| { type: "input_image"; image_url: string; detail?: "auto" | "low" | "high" | "original" | undefined }
|
|
23
|
+
| { type: "input_audio"; audio_url: string }
|
|
24
|
+
| { type: "encrypted_content"; encrypted_content: string }
|
|
25
|
+
)[];
|
|
26
|
+
|
|
27
|
+
/** Supported typed Responses items for engine-owned history hydration. */
|
|
28
|
+
export type HistoryItem =
|
|
29
|
+
| Readonly<{
|
|
30
|
+
type: "message";
|
|
31
|
+
role: "developer" | "user" | "assistant";
|
|
32
|
+
content: readonly HistoryContentItem[];
|
|
33
|
+
id?: string | undefined;
|
|
34
|
+
status?: "in_progress" | "completed" | "incomplete" | "failed" | undefined;
|
|
35
|
+
phase?: "commentary" | "final_answer" | undefined;
|
|
36
|
+
}>
|
|
37
|
+
| Readonly<{
|
|
38
|
+
type: "function_call";
|
|
39
|
+
name: string;
|
|
40
|
+
arguments: string;
|
|
41
|
+
call_id: string;
|
|
42
|
+
id?: string | undefined;
|
|
43
|
+
}>
|
|
44
|
+
| Readonly<{
|
|
45
|
+
type: "function_call_output";
|
|
46
|
+
call_id: string;
|
|
47
|
+
output: HistoryToolOutput;
|
|
48
|
+
id?: string | undefined;
|
|
49
|
+
}>
|
|
50
|
+
| Readonly<{
|
|
51
|
+
type: "custom_tool_call";
|
|
52
|
+
call_id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
input: string;
|
|
55
|
+
id?: string | undefined;
|
|
56
|
+
}>
|
|
57
|
+
| Readonly<{
|
|
58
|
+
type: "custom_tool_call_output";
|
|
59
|
+
call_id: string;
|
|
60
|
+
name?: string | undefined;
|
|
61
|
+
output: HistoryToolOutput;
|
|
62
|
+
id?: string | undefined;
|
|
63
|
+
}>
|
|
64
|
+
| Readonly<{
|
|
65
|
+
type: "compaction";
|
|
66
|
+
encrypted_content: string;
|
|
67
|
+
id?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
/** Already selected conversation state that the engine will validate and own. */
|
|
71
|
+
export type HistorySeed = Readonly<{
|
|
72
|
+
history: readonly HistoryItem[];
|
|
73
|
+
continuitySummary?: string | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
|
|
76
|
+
export type AgentEvent = {
|
|
77
|
+
protocol_version: number;
|
|
78
|
+
request_id: string;
|
|
79
|
+
seq: number;
|
|
80
|
+
type: string;
|
|
81
|
+
payload: Record<string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type AgentOptions = {
|
|
85
|
+
/** Replaces the selected model's built-in instructions. */
|
|
86
|
+
instructions?: string | undefined;
|
|
87
|
+
/** Appends host instructions while retaining the selected model's prompt. */
|
|
88
|
+
additionalInstructions?: string | undefined;
|
|
89
|
+
/** Generates client-owned context summaries instead of provider compaction. */
|
|
90
|
+
companionCompactionInstruction?: string | undefined;
|
|
91
|
+
/** Selects the final private compaction instruction for each operation. */
|
|
92
|
+
resolveCompactionInstruction?: CompactionInstructionResolver | undefined;
|
|
93
|
+
/** Hydrates a validated active history; cannot be combined with resume. */
|
|
94
|
+
historySeed?: HistorySeed | undefined;
|
|
95
|
+
model?: Model | undefined;
|
|
96
|
+
reasoningMode?: ReasoningMode | undefined;
|
|
97
|
+
fastMode?: boolean | undefined;
|
|
98
|
+
sessionId?: string | undefined;
|
|
99
|
+
thinking?: Thinking | undefined;
|
|
100
|
+
workspace?: string | undefined;
|
|
101
|
+
resume?: SessionSnapshot | undefined;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type CompactionInstructionContext = Readonly<{
|
|
105
|
+
after_model_call_index: number;
|
|
106
|
+
phase: "pre_turn" | "mid_turn";
|
|
107
|
+
trigger: "manual" | "automatic";
|
|
108
|
+
active_context_tokens: number;
|
|
109
|
+
auto_compact_token_limit: number;
|
|
110
|
+
}>;
|
|
111
|
+
|
|
112
|
+
export type CompactionInstructionResolver = (
|
|
113
|
+
context: CompactionInstructionContext,
|
|
114
|
+
signal: AbortSignal,
|
|
115
|
+
) => string | PromiseLike<string>;
|
|
116
|
+
|
|
117
|
+
/** Model-visible facts for tools executing outside the embedding process. */
|
|
118
|
+
export type ExecutionEnvironment = Readonly<{
|
|
119
|
+
currentDate: string;
|
|
120
|
+
timezone: string;
|
|
121
|
+
projectInstructions?: string | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
|
|
124
|
+
/** Unsigned decimal revision. Strings preserve the complete Rust `u64` range. */
|
|
125
|
+
declare const durabilityRevisionBrand: unique symbol;
|
|
126
|
+
export type DurabilityRevision = string & {
|
|
127
|
+
readonly [durabilityRevisionBrand]: "NanocodexDurabilityRevision";
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** Unsigned decimal owner generation. Strings preserve the complete Rust `u64` range. */
|
|
131
|
+
declare const durabilityFenceBrand: unique symbol;
|
|
132
|
+
export type DurabilityFence = string & {
|
|
133
|
+
readonly [durabilityFenceBrand]: "NanocodexDurabilityFence";
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type DurabilityStoredState = Readonly<{
|
|
137
|
+
revision: DurabilityRevision;
|
|
138
|
+
payload: string | null;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
/** JSON-safe exact state archive used for an offline provider cutover. */
|
|
142
|
+
export type DurabilityPortableStateArchive = DurabilityStoredState & Readonly<{
|
|
143
|
+
format: "nanocodex-durability-state-v1";
|
|
144
|
+
stateId: string;
|
|
145
|
+
}>;
|
|
146
|
+
|
|
147
|
+
export type DurabilityExportCursor = string;
|
|
148
|
+
|
|
149
|
+
/** One deterministic page of the total-state replacement from `from` (exclusive) to `to` (inclusive). */
|
|
150
|
+
export type DurabilityPortableStatePage = Readonly<{
|
|
151
|
+
format: "nanocodex-durability-state-page-v1";
|
|
152
|
+
stateId: string;
|
|
153
|
+
from: DurabilityRevision;
|
|
154
|
+
/** SHA-256 over the UTF-8 JSON tuple `[from, fromPayload]`. */
|
|
155
|
+
fromDigest: string;
|
|
156
|
+
to: DurabilityRevision;
|
|
157
|
+
cursor: DurabilityExportCursor;
|
|
158
|
+
nextCursor: DurabilityExportCursor | null;
|
|
159
|
+
/** Total UTF-16 code units in the opaque state payload. */
|
|
160
|
+
payloadLength: number;
|
|
161
|
+
payload: string;
|
|
162
|
+
}>;
|
|
163
|
+
|
|
164
|
+
export type DurabilityExportPageRequest = Readonly<{
|
|
165
|
+
from: DurabilityRevision;
|
|
166
|
+
/** Digest of the exact state at `from`; omit only when `from` is revision zero. */
|
|
167
|
+
fromDigest?: string | undefined;
|
|
168
|
+
/** Omit on the first request to select the current source revision; repeat the returned `to`. */
|
|
169
|
+
to?: DurabilityRevision | undefined;
|
|
170
|
+
cursor?: DurabilityExportCursor | undefined;
|
|
171
|
+
/** UTF-16 code units per page. Defaults to 256 KiB and is capped at 1 MiB. */
|
|
172
|
+
limit?: number | undefined;
|
|
173
|
+
}>;
|
|
174
|
+
|
|
175
|
+
export type DurabilityAcquireRequest = Readonly<{
|
|
176
|
+
ownerId: string;
|
|
177
|
+
}>;
|
|
178
|
+
|
|
179
|
+
export type DurabilityAcquiredState = DurabilityStoredState & Readonly<{
|
|
180
|
+
ownerId: string;
|
|
181
|
+
fence: DurabilityFence;
|
|
182
|
+
}>;
|
|
183
|
+
|
|
184
|
+
export type DurabilityReplaceRequest = Readonly<{
|
|
185
|
+
ownerId: string;
|
|
186
|
+
fence: DurabilityFence;
|
|
187
|
+
expectedRevision: DurabilityRevision;
|
|
188
|
+
payload: string;
|
|
189
|
+
}>;
|
|
190
|
+
|
|
191
|
+
export type DurabilityReplaceResult =
|
|
192
|
+
| Readonly<{ status: "replaced"; revision: DurabilityRevision }>
|
|
193
|
+
| Readonly<{ status: "fenced" }>
|
|
194
|
+
| Readonly<{ status: "conflict"; actualRevision: DurabilityRevision }>
|
|
195
|
+
| Readonly<{ status: "not_committed"; message: string }>;
|
|
196
|
+
|
|
197
|
+
/** Host capability consumed by the Rust/WASM durability driver. */
|
|
198
|
+
export type DurabilityStore = Readonly<{
|
|
199
|
+
load(stateId: string): DurabilityStoredState | Promise<DurabilityStoredState>;
|
|
200
|
+
acquire(
|
|
201
|
+
stateId: string,
|
|
202
|
+
request: DurabilityAcquireRequest,
|
|
203
|
+
): DurabilityAcquiredState | Promise<DurabilityAcquiredState>;
|
|
204
|
+
replace(
|
|
205
|
+
stateId: string,
|
|
206
|
+
request: DurabilityReplaceRequest,
|
|
207
|
+
): DurabilityReplaceResult | Promise<DurabilityReplaceResult>;
|
|
208
|
+
}>;
|
|
209
|
+
|
|
210
|
+
/** Store that can atomically restore an exact revision into an empty destination. */
|
|
211
|
+
export type DurabilityPortableStore = DurabilityStore & Readonly<{
|
|
212
|
+
importState(
|
|
213
|
+
stateId: string,
|
|
214
|
+
state: DurabilityStoredState,
|
|
215
|
+
options?: Readonly<{
|
|
216
|
+
expectedRevision?: DurabilityRevision | undefined;
|
|
217
|
+
/** When supplied, compare the complete expected state atomically before importing. */
|
|
218
|
+
expectedPayload?: string | null | undefined;
|
|
219
|
+
}> | undefined,
|
|
220
|
+
): DurabilityStoredState | Promise<DurabilityStoredState>;
|
|
221
|
+
}>;
|
|
222
|
+
|
|
223
|
+
/** In-process store for hosts that carry its snapshot across durable steps. */
|
|
224
|
+
export type MemoryDurabilityStore = DurabilityPortableStore & Readonly<{
|
|
225
|
+
stateId: string;
|
|
226
|
+
snapshot(): DurabilityStoredState;
|
|
227
|
+
}>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* SQLite scalar accepted by the generic adapter. Revision and fence numbers
|
|
231
|
+
* must be nonnegative safe integers; return exact decimal TEXT for larger values.
|
|
232
|
+
*/
|
|
233
|
+
export type DurabilitySqliteValue = string | number | null;
|
|
234
|
+
export type DurabilitySqliteRow = Record<string, DurabilitySqliteValue>;
|
|
235
|
+
|
|
236
|
+
export type DurabilitySqliteQuery = <Row extends DurabilitySqliteRow>(
|
|
237
|
+
sql: string,
|
|
238
|
+
args: readonly DurabilitySqliteValue[],
|
|
239
|
+
) => readonly Row[] | Promise<readonly Row[]>;
|
|
240
|
+
|
|
241
|
+
export type DurabilitySqliteTransaction = <Result>(
|
|
242
|
+
callback: (query: DurabilitySqliteQuery) => Result | Promise<Result>,
|
|
243
|
+
) => Result | Promise<Result>;
|
|
244
|
+
|
|
245
|
+
export type SqliteDurabilityStoreOptions = Readonly<{
|
|
246
|
+
transaction: DurabilitySqliteTransaction;
|
|
247
|
+
}>;
|
|
248
|
+
|
|
249
|
+
/** Unsigned decimal revision for opaque ChatGPT subscription state. */
|
|
250
|
+
declare const subscriptionRevisionBrand: unique symbol;
|
|
251
|
+
export type SubscriptionRevision = string & {
|
|
252
|
+
readonly [subscriptionRevisionBrand]: "NanocodexSubscriptionRevision";
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export type SubscriptionStoredValue = Readonly<{
|
|
256
|
+
revision: SubscriptionRevision;
|
|
257
|
+
payload?: string | undefined;
|
|
258
|
+
}>;
|
|
259
|
+
|
|
260
|
+
export type SubscriptionCommitRequest = Readonly<{
|
|
261
|
+
expectedRevision: SubscriptionRevision;
|
|
262
|
+
/** Opaque Rust-owned credential state. Hosts must store it as a secret. */
|
|
263
|
+
payload: string;
|
|
264
|
+
}>;
|
|
265
|
+
|
|
266
|
+
export type SubscriptionCommitResult =
|
|
267
|
+
| Readonly<{ status: "committed"; revision: SubscriptionRevision }>
|
|
268
|
+
| Readonly<{ status: "conflict"; actualRevision: SubscriptionRevision }>;
|
|
269
|
+
|
|
270
|
+
/** Generic secret persistence consumed by the Rust ChatGPT lifecycle. */
|
|
271
|
+
export type ChatGptSubscriptionStore = Readonly<{
|
|
272
|
+
load(id: string): SubscriptionStoredValue | Promise<SubscriptionStoredValue>;
|
|
273
|
+
compareAndSwap(
|
|
274
|
+
id: string,
|
|
275
|
+
request: SubscriptionCommitRequest,
|
|
276
|
+
): SubscriptionCommitResult | Promise<SubscriptionCommitResult>;
|
|
277
|
+
}>;
|
|
278
|
+
|
|
279
|
+
export type MemoryChatGptSubscriptionStore = ChatGptSubscriptionStore & Readonly<{
|
|
280
|
+
id: string;
|
|
281
|
+
snapshot(): SubscriptionStoredValue;
|
|
282
|
+
}>;
|
|
283
|
+
|
|
284
|
+
export type ChatGptCredentialSeed = Readonly<{
|
|
285
|
+
accessToken: string;
|
|
286
|
+
refreshToken?: string | undefined;
|
|
287
|
+
accountId: string;
|
|
288
|
+
fedramp?: boolean | undefined;
|
|
289
|
+
}>;
|
|
290
|
+
|
|
291
|
+
export type ChatGptLoginStatus =
|
|
292
|
+
| Readonly<{ state: "signed_out" | "expired" }>
|
|
293
|
+
| Readonly<{
|
|
294
|
+
state: "pending";
|
|
295
|
+
verificationUrl: string;
|
|
296
|
+
userCode: string;
|
|
297
|
+
expiresAt: number;
|
|
298
|
+
pollAfterMs: number;
|
|
299
|
+
}>
|
|
300
|
+
| Readonly<{
|
|
301
|
+
state: "authenticated";
|
|
302
|
+
accountId: string;
|
|
303
|
+
expiresAt: number | null;
|
|
304
|
+
}>;
|
|
305
|
+
|
|
306
|
+
export type ChatGptCredential = Readonly<{
|
|
307
|
+
kind: "chatgpt";
|
|
308
|
+
/** Resolved bearer credential. Do not retain or log it. */
|
|
309
|
+
accessToken: string;
|
|
310
|
+
accountId: string;
|
|
311
|
+
fedramp: boolean;
|
|
312
|
+
revision: SubscriptionRevision;
|
|
313
|
+
}>;
|
|
314
|
+
|
|
315
|
+
export type ChatGptSubscriptionHandle = Readonly<{
|
|
316
|
+
id: string;
|
|
317
|
+
startLogin(): Promise<ChatGptLoginStatus>;
|
|
318
|
+
status(): Promise<ChatGptLoginStatus>;
|
|
319
|
+
credential(): Promise<ChatGptCredential>;
|
|
320
|
+
recover(rejectedRevision: SubscriptionRevision): Promise<ChatGptCredential>;
|
|
321
|
+
logout(): Promise<void>;
|
|
322
|
+
dispose(): void;
|
|
323
|
+
}>;
|
|
324
|
+
|
|
325
|
+
export type ChatGptSubscriptionOptions = Readonly<{
|
|
326
|
+
id: string;
|
|
327
|
+
store: ChatGptSubscriptionStore;
|
|
328
|
+
/** Generic bounded HTTP capability; defaults to global fetch. */
|
|
329
|
+
fetch?: typeof globalThis.fetch | undefined;
|
|
330
|
+
/**
|
|
331
|
+
* Trusted initial credentials, typically imported from Codex auth.json.
|
|
332
|
+
* A same-account seed repairs stored access-only credentials; refreshable durable state wins.
|
|
333
|
+
*/
|
|
334
|
+
seed?: ChatGptCredentialSeed | undefined;
|
|
335
|
+
/** Test-only local issuer override. */
|
|
336
|
+
issuer?: string | undefined;
|
|
337
|
+
/** Browser WASM module compiled from the same nanocodex package. */
|
|
338
|
+
module?: unknown;
|
|
339
|
+
}>;
|
|
340
|
+
|
|
341
|
+
export type EstimatedUsdCost = Readonly<{
|
|
342
|
+
usd: string;
|
|
343
|
+
input_usd: string;
|
|
344
|
+
cached_input_usd: string;
|
|
345
|
+
cache_write_input_usd: string;
|
|
346
|
+
output_usd: string;
|
|
347
|
+
service_tier: "standard" | "priority" | "fast";
|
|
348
|
+
}>;
|
|
349
|
+
|
|
350
|
+
export type CostStatus =
|
|
351
|
+
| "estimated_from_usage"
|
|
352
|
+
| "usage_not_reported"
|
|
353
|
+
| "other";
|
|
354
|
+
|
|
355
|
+
export type SessionSnapshot = Readonly<{
|
|
356
|
+
version: number;
|
|
357
|
+
model: string;
|
|
358
|
+
lineage_id: string;
|
|
359
|
+
prompt_cache_key: string;
|
|
360
|
+
workspace: string;
|
|
361
|
+
request_prefix?: readonly Record<string, unknown>[] | undefined;
|
|
362
|
+
canonical_context: Record<string, unknown>;
|
|
363
|
+
history: readonly Record<string, unknown>[];
|
|
364
|
+
}>;
|
|
365
|
+
|
|
366
|
+
export type TurnUsage = Readonly<{
|
|
367
|
+
input_tokens: number;
|
|
368
|
+
cached_input_tokens: number;
|
|
369
|
+
cache_write_input_tokens: number;
|
|
370
|
+
output_tokens: number;
|
|
371
|
+
reasoning_output_tokens: number;
|
|
372
|
+
total_tokens: number;
|
|
373
|
+
estimated_cost: EstimatedUsdCost | null;
|
|
374
|
+
cost_status: CostStatus;
|
|
375
|
+
}>;
|
|
376
|
+
|
|
377
|
+
export type ForkOptions = Readonly<{ at?: TurnResult | undefined }>;
|
|
378
|
+
export type WatchEventsOptions = { includeAllSessions?: boolean | undefined };
|
|
379
|
+
|
|
380
|
+
/** Read-only model context captured at the latest safe agent boundary. */
|
|
381
|
+
export type AgentSessionContext = Readonly<{
|
|
382
|
+
workspace: string;
|
|
383
|
+
history: readonly Record<string, unknown>[];
|
|
384
|
+
}>;
|
|
385
|
+
|
|
386
|
+
export type CompactionItemIdentity = Readonly<{
|
|
387
|
+
index: number;
|
|
388
|
+
kind: string;
|
|
389
|
+
id: string | null;
|
|
390
|
+
call_id: string | null;
|
|
391
|
+
}>;
|
|
392
|
+
|
|
393
|
+
export type CompactionOutcome = Readonly<{
|
|
394
|
+
revision: string;
|
|
395
|
+
trigger: "manual" | "automatic";
|
|
396
|
+
/** Generated private summary text; never an assistant display event. */
|
|
397
|
+
summary: string | null;
|
|
398
|
+
replaced_history: Readonly<{ start: number; end: number }>;
|
|
399
|
+
retained_tail: readonly CompactionItemIdentity[];
|
|
400
|
+
context: AgentSessionContext;
|
|
401
|
+
}>;
|
|
402
|
+
|
|
403
|
+
/** Payload for the ordered event emitted after a custom replacement installs. */
|
|
404
|
+
export type CompactionReplacedEventPayload = CompactionOutcome & Readonly<{
|
|
405
|
+
after_model_call_index: number;
|
|
406
|
+
phase: "pre_turn" | "mid_turn";
|
|
407
|
+
}>;
|
|
408
|
+
|
|
409
|
+
export type RealtimeTranscriptEntry = Readonly<{
|
|
410
|
+
role: "user" | "assistant";
|
|
411
|
+
text: string;
|
|
412
|
+
}>;
|
|
413
|
+
|
|
414
|
+
export type EventWatcher = Readonly<{
|
|
415
|
+
onEvent(listener: (event: AgentEvent) => void): () => void;
|
|
416
|
+
off(): void;
|
|
417
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<AgentEvent>;
|
|
418
|
+
}>;
|
|
419
|
+
|
|
420
|
+
export type AgentActions = {
|
|
421
|
+
events: {
|
|
422
|
+
watch(options?: WatchEventsOptions): EventWatcher;
|
|
423
|
+
};
|
|
424
|
+
session: {
|
|
425
|
+
appendDeveloperMessage(text: string): Promise<AgentSessionContext>;
|
|
426
|
+
/** Returns the exact custom replacement, or null for provider-default compaction. */
|
|
427
|
+
compact(): Promise<CompactionOutcome | null>;
|
|
428
|
+
context(): Promise<AgentSessionContext>;
|
|
429
|
+
/** Returns the latest committed, resumable engine-owned snapshot. */
|
|
430
|
+
snapshot(): Promise<SessionSnapshot>;
|
|
431
|
+
fork(options?: ForkOptions): Promise<DefaultAgent>;
|
|
432
|
+
setModel(model: Model): Promise<void>;
|
|
433
|
+
setFastMode(enabled: boolean): Promise<void>;
|
|
434
|
+
setThinking(thinking: Thinking): Promise<void>;
|
|
435
|
+
shutdown(): Promise<void>;
|
|
436
|
+
spawn(): Promise<DefaultAgent>;
|
|
437
|
+
realtime: {
|
|
438
|
+
start(): Promise<AgentSessionContext>;
|
|
439
|
+
end(): Promise<AgentSessionContext>;
|
|
440
|
+
delegation(
|
|
441
|
+
input: string,
|
|
442
|
+
transcript?: readonly RealtimeTranscriptEntry[],
|
|
443
|
+
): Promise<string>;
|
|
444
|
+
tailDelegation(
|
|
445
|
+
transcript: readonly RealtimeTranscriptEntry[],
|
|
446
|
+
): Promise<string | undefined>;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
turn: {
|
|
450
|
+
prompt(options: {
|
|
451
|
+
input: PromptInput;
|
|
452
|
+
id?: string | undefined;
|
|
453
|
+
/** Host-resolved evidence attached to this same model input. */
|
|
454
|
+
supplementaryContext?: string | undefined;
|
|
455
|
+
}): Turn;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
export type Agent<extended extends object = {}> = {
|
|
460
|
+
readonly agentId: string;
|
|
461
|
+
readonly key: string;
|
|
462
|
+
readonly name: string;
|
|
463
|
+
readonly sessionId: string;
|
|
464
|
+
readonly type: string;
|
|
465
|
+
readonly uid: string;
|
|
466
|
+
extend<const extension extends object>(
|
|
467
|
+
decorator: (agent: Agent<extended>) => extension,
|
|
468
|
+
): Agent<extended & extension>;
|
|
469
|
+
/** Releases this JavaScript/WASM handle without joining unfinished turns. */
|
|
470
|
+
dispose(): void;
|
|
471
|
+
} & extended;
|
|
472
|
+
|
|
473
|
+
export type DefaultAgent = Agent<AgentActions>;
|
|
474
|
+
|
|
475
|
+
/** Transport-independent Agent lifecycle shared by local and managed durable Agents. */
|
|
476
|
+
export type AgentLifecycle = {
|
|
477
|
+
readonly agentId: string;
|
|
478
|
+
readonly key: string;
|
|
479
|
+
readonly name: string;
|
|
480
|
+
readonly sessionId: string;
|
|
481
|
+
readonly type: string;
|
|
482
|
+
readonly uid: string;
|
|
483
|
+
dispose(): void;
|
|
484
|
+
events: {
|
|
485
|
+
watch(options?: WatchEventsOptions): EventWatcher;
|
|
486
|
+
};
|
|
487
|
+
session: {
|
|
488
|
+
/** Stops this client lifecycle. A managed shutdown never deletes the durable Agent. */
|
|
489
|
+
shutdown(): Promise<void>;
|
|
490
|
+
};
|
|
491
|
+
turn: {
|
|
492
|
+
prompt(options: {
|
|
493
|
+
input: PromptInput;
|
|
494
|
+
id?: string | undefined;
|
|
495
|
+
}): LifecycleTurn;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
export type LifecycleTurn = Readonly<{
|
|
500
|
+
readonly agent: Readonly<{
|
|
501
|
+
agentId: string;
|
|
502
|
+
key: string;
|
|
503
|
+
name: string;
|
|
504
|
+
sessionId: string;
|
|
505
|
+
type: string;
|
|
506
|
+
uid: string;
|
|
507
|
+
dispose(): void;
|
|
508
|
+
}>;
|
|
509
|
+
accepted(): Promise<string | undefined>;
|
|
510
|
+
result(): Promise<LifecycleTurnResult>;
|
|
511
|
+
steer(options: { input: PromptInput }): Promise<void>;
|
|
512
|
+
cancel(): Promise<void>;
|
|
513
|
+
dispose(): void;
|
|
514
|
+
}>;
|
|
515
|
+
|
|
516
|
+
export type LifecycleTurnResult = Readonly<{
|
|
517
|
+
finalMessage: string;
|
|
518
|
+
/** Managed Agents may return null when the service did not report usage. */
|
|
519
|
+
usage(): Promise<TurnUsage | null>;
|
|
520
|
+
dispose(): void;
|
|
521
|
+
}>;
|
|
522
|
+
|
|
523
|
+
export type Turn<agent extends Agent<object> = Agent<object>> = Readonly<{
|
|
524
|
+
readonly agent: agent;
|
|
525
|
+
/**
|
|
526
|
+
* Waits for execution-policy admission and returns its durable request ID.
|
|
527
|
+
* Rejections are Errors whose `code` is `cancelled`, `blocked`, `conflict`,
|
|
528
|
+
* `retryable`, `reopen_required`, `invalid_request`, or `failed`.
|
|
529
|
+
*/
|
|
530
|
+
accepted(): Promise<string | undefined>;
|
|
531
|
+
/**
|
|
532
|
+
* Waits for the terminal result. A `reopen_required` rejection means this
|
|
533
|
+
* Agent is stale and the same durable turn may be resumed only on a new Agent.
|
|
534
|
+
*/
|
|
535
|
+
result(): Promise<TurnResult>;
|
|
536
|
+
steer(options: { input: PromptInput }): Promise<void>;
|
|
537
|
+
cancel(): Promise<void>;
|
|
538
|
+
/** Releases this handle without cancelling its accepted turn. */
|
|
539
|
+
dispose(): void;
|
|
540
|
+
}>;
|
|
541
|
+
|
|
542
|
+
declare const turnResultBrand: unique symbol;
|
|
543
|
+
/** Opaque completed-turn identity. Materialize large values explicitly and release it when done. */
|
|
544
|
+
export type TurnResult = Readonly<{
|
|
545
|
+
readonly [turnResultBrand]: "NanocodexTurnResult";
|
|
546
|
+
finalMessage: string;
|
|
547
|
+
snapshot(): Promise<SessionSnapshot>;
|
|
548
|
+
usage(): Promise<TurnUsage>;
|
|
549
|
+
dispose(): void;
|
|
550
|
+
}>;
|
|
551
|
+
|
|
552
|
+
import type { NamedTool, ToolMap } from "../nanocodex-tools/dist/index.d.ts";
|
|
553
|
+
export type {
|
|
554
|
+
CustomToolFormat,
|
|
555
|
+
NamedTool,
|
|
556
|
+
SubagentToolContext,
|
|
557
|
+
Tool,
|
|
558
|
+
ToolContext,
|
|
559
|
+
ToolDefinition,
|
|
560
|
+
ToolJson,
|
|
561
|
+
ToolMap,
|
|
562
|
+
} from "../nanocodex-tools/dist/index.d.ts";
|
|
563
|
+
|
|
564
|
+
/** Static JavaScript tools, optionally composed with Rust-backed extensions. */
|
|
565
|
+
export type ToolConfiguration<Extension = never> =
|
|
566
|
+
| ToolMap
|
|
567
|
+
| readonly (NamedTool | Extension)[]
|
|
568
|
+
| import("./tools/Tools.mjs").Tools;
|
|
569
|
+
|
|
570
|
+
export type CodeEvaluatorEnvironment = {
|
|
571
|
+
tools: Readonly<Record<string, (input: unknown) => Promise<unknown>>>;
|
|
572
|
+
toolDefinitions: readonly Record<string, unknown>[];
|
|
573
|
+
text(value: unknown): void;
|
|
574
|
+
image(value: unknown, detail?: string): void;
|
|
575
|
+
generatedImage(value: unknown): void;
|
|
576
|
+
audio(value: unknown): void;
|
|
577
|
+
notify(value: unknown): void;
|
|
578
|
+
yield_control(): void;
|
|
579
|
+
setTimeout(callback: () => void, delayMs?: number): number;
|
|
580
|
+
clearTimeout(timerId?: number): void;
|
|
581
|
+
store(key: string, value: unknown): void;
|
|
582
|
+
load(key: string): unknown;
|
|
583
|
+
exit(): never;
|
|
584
|
+
require?: unknown;
|
|
585
|
+
console?: Console;
|
|
586
|
+
/** Aborts the exact active Code Mode cell and all nested tool calls. */
|
|
587
|
+
signal: AbortSignal;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
export type CodeEvaluator = (
|
|
591
|
+
source: string,
|
|
592
|
+
environment: CodeEvaluatorEnvironment,
|
|
593
|
+
) => void | Promise<void>;
|
|
594
|
+
|
|
595
|
+
export type McpPayment = {
|
|
596
|
+
/** MPPx client methods, such as `tempo.session({ account, getClient, channelStore })`. */
|
|
597
|
+
methods: readonly unknown[];
|
|
598
|
+
/** Optional MPP method context forwarded for each paid MCP tool call. */
|
|
599
|
+
context?: unknown;
|
|
600
|
+
/** Called before MPPx creates a payment credential. */
|
|
601
|
+
onPaymentRequired?: ((challenge: unknown) => boolean | Promise<boolean>) | undefined;
|
|
602
|
+
orderChallenges?: ((challenges: readonly unknown[]) => readonly unknown[] | Promise<readonly unknown[]>) | undefined;
|
|
603
|
+
paymentPreferences?: unknown;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
export type McpClient = {
|
|
607
|
+
listTools(params?: { cursor?: string | undefined }, options?: Record<string, unknown>): Promise<{
|
|
608
|
+
tools: readonly McpTool[];
|
|
609
|
+
nextCursor?: string | undefined;
|
|
610
|
+
}>;
|
|
611
|
+
callTool(
|
|
612
|
+
params: { name: string; arguments?: Record<string, unknown> | undefined },
|
|
613
|
+
resultSchema?: unknown,
|
|
614
|
+
options?: Record<string, unknown>,
|
|
615
|
+
): Promise<unknown>;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
export type McpTool = {
|
|
619
|
+
name: string;
|
|
620
|
+
title?: string | undefined;
|
|
621
|
+
description?: string | undefined;
|
|
622
|
+
inputSchema?: Record<string, unknown> | undefined;
|
|
623
|
+
annotations?: Readonly<Record<string, unknown>> & {
|
|
624
|
+
readOnlyHint?: boolean | undefined;
|
|
625
|
+
} | undefined;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
export type McpServer = {
|
|
629
|
+
/** Public Streamable HTTP MCP endpoint. Omit when supplying an initialized client. */
|
|
630
|
+
url?: string | URL | undefined;
|
|
631
|
+
/** Existing MCP SDK-compatible client; Nanocodex does not close caller-owned clients. */
|
|
632
|
+
client?: McpClient | undefined;
|
|
633
|
+
description?: string | undefined;
|
|
634
|
+
headers?: HeadersInit | undefined;
|
|
635
|
+
fetch?: typeof globalThis.fetch | undefined;
|
|
636
|
+
payment?: McpPayment | undefined;
|
|
637
|
+
enabledTools?: readonly string[] | undefined;
|
|
638
|
+
disabledTools?: readonly string[] | undefined;
|
|
639
|
+
/** Declares every remote tool on this server safe for concurrent nested calls. */
|
|
640
|
+
supportsParallelToolCalls?: boolean | undefined;
|
|
641
|
+
/** Declares specific remote tool names safe for concurrent nested calls. */
|
|
642
|
+
parallelTools?: readonly string[] | undefined;
|
|
643
|
+
/** Synchronously reports whether this server may currently be discovered or called. */
|
|
644
|
+
isAvailable?: (() => boolean) | undefined;
|
|
645
|
+
startupTimeoutMs?: number | undefined;
|
|
646
|
+
timeoutMs?: number | undefined;
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
export type McpServers = Record<string, string | URL | McpServer>;
|
|
650
|
+
|
|
651
|
+
/** A paid WebSocket session, such as an mppx Tempo session manager. */
|
|
652
|
+
export type MppSession = {
|
|
653
|
+
ws(endpoint: string | URL): Promise<MppWebSocket>;
|
|
654
|
+
close?(): unknown | Promise<unknown>;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
export type MppWebSocket = {
|
|
658
|
+
readonly readyState: number;
|
|
659
|
+
readonly bufferedAmount?: number | undefined;
|
|
660
|
+
addEventListener(type: string, listener: (event: any) => void, options?: unknown): void;
|
|
661
|
+
send(message: string): void;
|
|
662
|
+
close(code?: number, reason?: string): void;
|
|
663
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatGptSubscriptionHandle,
|
|
3
|
+
ChatGptSubscriptionOptions,
|
|
4
|
+
} from "../types.mjs";
|
|
5
|
+
|
|
6
|
+
/** Opens the Rust-owned ChatGPT lifecycle in a module Worker. */
|
|
7
|
+
export function open(
|
|
8
|
+
options: Omit<ChatGptSubscriptionOptions, "module"> & { module: WebAssembly.Module },
|
|
9
|
+
): Promise<ChatGptSubscriptionHandle>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import init, { ChatGptSubscription as WasmChatGptSubscription } from "../pkg-web/nanocodex.js";
|
|
2
|
+
|
|
3
|
+
import { installHostBridge } from "../internal.mjs";
|
|
4
|
+
import { openSubscription } from "../runtime/chatgpt-subscription.mjs";
|
|
5
|
+
|
|
6
|
+
let initialization;
|
|
7
|
+
|
|
8
|
+
/** Opens the Rust-owned ChatGPT lifecycle in a module Worker. */
|
|
9
|
+
export async function open(options) {
|
|
10
|
+
installHostBridge();
|
|
11
|
+
if (options?.module === undefined) {
|
|
12
|
+
throw new TypeError("Worker ChatGptSubscription requires a precompiled WASM module");
|
|
13
|
+
}
|
|
14
|
+
await initialize(options.module);
|
|
15
|
+
return openSubscription(
|
|
16
|
+
options,
|
|
17
|
+
(config) => WasmChatGptSubscription.open(config),
|
|
18
|
+
// A Cloudflare isolate can outlive an evicted Durable Object instance.
|
|
19
|
+
// Rebind its stable subscription ID to the reconstructed instance.
|
|
20
|
+
{ replaceHost: true },
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function initialize(module) {
|
|
25
|
+
return initialization ??= init({ module_or_path: module }).catch((error) => {
|
|
26
|
+
initialization = undefined;
|
|
27
|
+
throw error;
|
|
28
|
+
});
|
|
29
|
+
}
|