nanocodex 0.1.1 → 0.3.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/types.d.mts CHANGED
@@ -19,11 +19,50 @@ export type AgentEvent = {
19
19
  export type AgentOptions = {
20
20
  instructions?: string | undefined;
21
21
  reasoningMode?: ReasoningMode | undefined;
22
+ fastMode?: boolean | undefined;
22
23
  sessionId?: string | undefined;
23
24
  thinking?: Thinking | undefined;
25
+ workspace?: string | undefined;
26
+ resume?: SessionSnapshot | undefined;
24
27
  };
25
28
 
26
- export type ForkOptions = { at?: Turn | undefined };
29
+ export type EstimatedUsdCost = Readonly<{
30
+ usd: string;
31
+ input_usd: string;
32
+ cached_input_usd: string;
33
+ cache_write_input_usd: string;
34
+ output_usd: string;
35
+ service_tier: "standard" | "priority";
36
+ }>;
37
+
38
+ export type CostStatus =
39
+ | "estimated_from_usage"
40
+ | "usage_not_reported"
41
+ | "other";
42
+
43
+ export type SessionSnapshot = Readonly<{
44
+ version: number;
45
+ model: string;
46
+ lineage_id: string;
47
+ prompt_cache_key: string;
48
+ workspace: string;
49
+ request_prefix?: readonly Record<string, unknown>[] | undefined;
50
+ canonical_context: Record<string, unknown>;
51
+ history: readonly Record<string, unknown>[];
52
+ }>;
53
+
54
+ export type TurnUsage = Readonly<{
55
+ input_tokens: number;
56
+ cached_input_tokens: number;
57
+ cache_write_input_tokens: number;
58
+ output_tokens: number;
59
+ reasoning_output_tokens: number;
60
+ total_tokens: number;
61
+ estimated_cost: EstimatedUsdCost | null;
62
+ cost_status: CostStatus;
63
+ }>;
64
+
65
+ export type ForkOptions = { at?: TurnResult | undefined };
27
66
  export type WatchEventsOptions = { includeAllSessions?: boolean | undefined };
28
67
 
29
68
  export type EventWatcher = Readonly<{
@@ -37,7 +76,11 @@ export type AgentActions = {
37
76
  watch(options?: WatchEventsOptions): EventWatcher;
38
77
  };
39
78
  session: {
79
+ compact(): Promise<void>;
40
80
  fork(options?: ForkOptions): Promise<DefaultAgent>;
81
+ setFastMode(enabled: boolean): Promise<void>;
82
+ setThinking(thinking: Thinking): Promise<void>;
83
+ shutdown(): Promise<void>;
41
84
  spawn(): Promise<DefaultAgent>;
42
85
  };
43
86
  turn: {
@@ -54,6 +97,7 @@ export type Agent<extended extends object = {}> = {
54
97
  extend<const extension extends object>(
55
98
  decorator: (agent: Agent<extended>) => extension,
56
99
  ): Agent<extended & extension>;
100
+ /** Releases this JavaScript/WASM handle without joining unfinished turns. */
57
101
  dispose(): void;
58
102
  } & extended;
59
103
 
@@ -61,12 +105,19 @@ export type DefaultAgent = Agent<AgentActions>;
61
105
 
62
106
  export type Turn<agent extends Agent<object> = Agent<object>> = Readonly<{
63
107
  readonly agent: agent;
64
- result(): Promise<string>;
108
+ result(): Promise<TurnResult>;
65
109
  steer(options: { input: PromptInput }): Promise<void>;
66
110
  cancel(): Promise<void>;
111
+ /** Releases this handle without cancelling its accepted turn. */
67
112
  dispose(): void;
68
113
  }>;
69
114
 
115
+ export type TurnResult = Readonly<{
116
+ finalMessage: string;
117
+ snapshot: SessionSnapshot;
118
+ usage: TurnUsage;
119
+ }>;
120
+
70
121
  export type ToolContext = {
71
122
  callId: string;
72
123
  parentCallId: string;
@@ -80,3 +131,17 @@ export type Tool = {
80
131
  };
81
132
 
82
133
  export type ToolMap = Record<string, Tool>;
134
+
135
+ /** A paid WebSocket session, such as an mppx Tempo session manager. */
136
+ export type MppSession = {
137
+ ws(endpoint: string | URL): Promise<MppWebSocket>;
138
+ close?(): unknown | Promise<unknown>;
139
+ };
140
+
141
+ export type MppWebSocket = {
142
+ readonly readyState: number;
143
+ readonly bufferedAmount?: number | undefined;
144
+ addEventListener(type: string, listener: (event: any) => void, options?: unknown): void;
145
+ send(message: string): void;
146
+ close(code?: number, reason?: string): void;
147
+ };
@@ -1,38 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { readFile, stat } from "node:fs/promises";
3
-
4
- const root = new URL("../", import.meta.url);
5
- const packageJson = JSON.parse(await readFile(new URL("package.json", root), "utf8"));
6
-
7
- assert.equal(packageJson.name, "nanocodex");
8
- assert.equal(packageJson.type, "module");
9
- assert.equal(packageJson.publishConfig?.access, "public");
10
- assert.equal(packageJson.exports?.["./browser"]?.import, "./browser/index.mjs");
11
- assert.equal(packageJson.exports?.["./node"]?.import, "./node/index.mjs");
12
-
13
- const requiredFiles = [
14
- "browser/index.mjs",
15
- "browser/index.d.mts",
16
- "node/index.mjs",
17
- "node/index.d.mts",
18
- "pkg-web/nanocodex.js",
19
- "pkg-web/nanocodex.d.ts",
20
- "pkg-web/nanocodex_bg.wasm",
21
- "pkg-node/nanocodex.js",
22
- "pkg-node/nanocodex.d.ts",
23
- "pkg-node/nanocodex_bg.wasm",
24
- ];
25
-
26
- for (const file of requiredFiles) {
27
- const metadata = await stat(new URL(file, root));
28
- assert(metadata.isFile(), `${file} must be a file`);
29
- assert(metadata.size > 0, `${file} must not be empty`);
30
- }
31
-
32
- for (const target of ["web", "node"]) {
33
- const wasm = await readFile(new URL(`pkg-${target}/nanocodex_bg.wasm`, root));
34
- assert(wasm.byteLength > 100_000, `pkg-${target} WASM is unexpectedly small`);
35
- assert.deepEqual([...wasm.subarray(0, 4)], [0x00, 0x61, 0x73, 0x6d]);
36
- }
37
-
38
- console.log(`nanocodex@${packageJson.version} package artifacts are complete`);