@1kbirds/chidori 3.3.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,27 +3,26 @@
3
3
  Zero-dependency TypeScript client for a running `chidori serve` instance.
4
4
  Uses the global `fetch` (Node 18+, browsers). Mirrors the Python SDK.
5
5
 
6
+ > **This package is not the runtime.** It's an optional HTTP client for driving
7
+ > the Chidori **runtime** — the `chidori` binary — from a TypeScript app. You
8
+ > don't need it to write or run agents (those are plain `.ts` files the runtime
9
+ > executes directly). Install the runtime separately, no Rust toolchain needed:
10
+ > `curl -fsSL https://raw.githubusercontent.com/ThousandBirdsInc/chidori/main/scripts/install.sh | sh`
11
+ > — see the [project README](https://github.com/ThousandBirdsInc/chidori#%EF%B8%8F-quick-start).
12
+
6
13
  ## Install
7
14
 
8
15
  The package is published to npm as
9
- [`@1kbirds/chidori`](https://www.npmjs.com/package/@1kbirds/chidori) (the
10
- unscoped `chidori` npm name belongs to an unrelated project). Installing it
11
- under the `chidori` alias keeps the historical import spelling working:
16
+ [`@1kbirds/chidori`](https://www.npmjs.com/package/@1kbirds/chidori). The
17
+ unscoped `chidori` npm name belongs to an unrelated project, so **always import
18
+ the scoped name** never `npm install chidori`:
12
19
 
13
20
  ```bash
14
- npm install chidori@npm:@1kbirds/chidori
21
+ npm install @1kbirds/chidori
15
22
  ```
16
23
 
17
24
  ```ts
18
- import { AgentClient, Checkpoint } from "chidori";
19
- ```
20
-
21
- Or install under the scoped name directly — the Chidori runtime accepts both
22
- `"chidori"` and `"@1kbirds/chidori"` as the SDK module specifier in agent
23
- files:
24
-
25
- ```bash
26
- npm install @1kbirds/chidori
25
+ import { AgentClient, Checkpoint } from "@1kbirds/chidori";
27
26
  ```
28
27
 
29
28
  To build from source instead:
@@ -34,16 +33,28 @@ npm install
34
33
  npm run build
35
34
  ```
36
35
 
37
- Agent and tool authoring types are also exported:
36
+ ### Authoring agents and tools
37
+
38
+ Agent and tool files run *inside* the Chidori runtime, not as a normal Node
39
+ program. They get their authoring types — and the `chidori`/`run` globals — from
40
+ the **virtual** module `chidori:agent`:
38
41
 
39
42
  ```ts
40
- import type { Chidori, ToolDefinition } from "chidori";
43
+ /// <reference types="@1kbirds/chidori/agent-env" />
44
+ import type { Chidori, ToolDefinition } from "chidori:agent";
41
45
  ```
42
46
 
47
+ There is no installable package behind `chidori:agent`; it is a URL-style scheme
48
+ (like `node:fs`) that the runtime strips and injects at execution time, so the
49
+ unrelated `chidori` npm package can never be pulled in by mistake. The
50
+ `/// <reference …>` line (or a `compilerOptions.types: ["@1kbirds/chidori/agent-env"]`
51
+ entry in `tsconfig.json`) gives editors and `tsc` the types while you author;
52
+ the runtime itself needs nothing installed.
53
+
43
54
  ## Usage
44
55
 
45
56
  ```ts
46
- import { AgentClient, Checkpoint, isSignalQueued } from "chidori";
57
+ import { AgentClient, Checkpoint, isSignalQueued } from "@1kbirds/chidori";
47
58
 
48
59
  const client = new AgentClient("http://localhost:8080");
49
60
 
@@ -115,3 +126,17 @@ journal/scaffold metadata rather than serialized VM bytes.
115
126
 
116
127
  Use `client.getSnapshotManifest(sessionId)` when a UI needs only snapshot
117
128
  metadata. The endpoint never returns the binary VM snapshot.
129
+
130
+ ## Tests
131
+
132
+ The SDK ships a dependency-free test suite (Node's built-in `node:test`
133
+ runner) that drives `AgentClient` against a stdlib `node:http` mock server,
134
+ covering run/replay/resume/signal, SSE stream parsing, checkpoint
135
+ serialization, and error handling:
136
+
137
+ ```bash
138
+ npm test # builds, then runs node --test test/*.test.mjs
139
+ ```
140
+
141
+ End-to-end coverage against a real `chidori serve` binary lives in the Python
142
+ SDK integration tests (`sdk/python/tests/`).
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Ambient types for the virtual `chidori:agent` module.
3
+ *
4
+ * Agent and tool files written for the Chidori runtime import their authoring
5
+ * types — and, in the global style, the `chidori`/`run` values — from
6
+ * `chidori:agent`:
7
+ *
8
+ * ```ts
9
+ * import type { Chidori, ToolDefinition } from "chidori:agent";
10
+ * // …or the global style:
11
+ * import { chidori, run } from "chidori:agent";
12
+ * ```
13
+ *
14
+ * There is no installable package behind that specifier. It is a virtual module
15
+ * the runtime injects, much like `node:fs` or `bun:test`: the runtime strips the
16
+ * import and supplies the real values when it executes the file, so nothing is
17
+ * resolved from npm. Crucially, the unrelated `chidori` package on npm can never
18
+ * be pulled in by mistake, because `chidori:agent` is not a registry name at all.
19
+ *
20
+ * This file exists only so editors and `tsc` can type agent files. Pull it into
21
+ * a project with a triple-slash reference at the top of an agent or tool file:
22
+ *
23
+ * ```ts
24
+ * /// <reference types="@1kbirds/chidori/agent-env" />
25
+ * import type { Chidori } from "chidori:agent";
26
+ * ```
27
+ *
28
+ * or once, project-wide, via tsconfig `compilerOptions.types`:
29
+ * `["@1kbirds/chidori/agent-env"]`.
30
+ *
31
+ * NOTE: this must stay a script file (no top-level `import`/`export`). A bare
32
+ * `declare module "chidori:agent"` is a *global* ambient declaration; adding a
33
+ * top-level `export` would turn it into a module augmentation and fail to
34
+ * resolve, since there is no real `chidori:agent` module to augment.
35
+ */
36
+ declare module "chidori:agent" {
37
+ export * from "@1kbirds/chidori/agent";
38
+ }
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/agent.d.ts CHANGED
@@ -463,7 +463,7 @@ export type ToolFunction<TArgs extends JsonObject = JsonObject, TResult extends
463
463
  * need for a `(input, chidori)` second parameter):
464
464
  *
465
465
  * ```ts
466
- * import { chidori, run } from "chidori";
466
+ * import { chidori, run } from "chidori:agent";
467
467
  * run(async (input: { topic: string }) => {
468
468
  * await chidori.log("starting", { topic: input.topic });
469
469
  * return { ok: true };
@@ -480,7 +480,7 @@ export declare const chidori: Chidori;
480
480
  * named `agent`" convention.
481
481
  *
482
482
  * ```ts
483
- * import { run } from "chidori";
483
+ * import { run } from "chidori:agent";
484
484
  * run(async (input) => ({ greeting: `hello ${input.name}` }));
485
485
  * ```
486
486
  */
package/dist/agent.js CHANGED
@@ -13,7 +13,7 @@
13
13
  * need for a `(input, chidori)` second parameter):
14
14
  *
15
15
  * ```ts
16
- * import { chidori, run } from "chidori";
16
+ * import { chidori, run } from "chidori:agent";
17
17
  * run(async (input: { topic: string }) => {
18
18
  * await chidori.log("starting", { topic: input.topic });
19
19
  * return { ok: true };
@@ -35,7 +35,7 @@ export const chidori = new Proxy({}, {
35
35
  * named `agent`" convention.
36
36
  *
37
37
  * ```ts
38
- * import { run } from "chidori";
38
+ * import { run } from "chidori:agent";
39
39
  * run(async (input) => ({ greeting: `hello ${input.name}` }));
40
40
  * ```
41
41
  */
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@1kbirds/chidori",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "TypeScript SDK for the Chidori agent framework — HTTP client plus agent authoring types.",
5
+ "keywords": ["ai", "agents", "typescript", "llm", "replay"],
5
6
  "publishConfig": { "access": "public" },
6
7
  "homepage": "https://github.com/ThousandBirdsInc/chidori",
7
8
  "repository": { "type": "git", "url": "https://github.com/ThousandBirdsInc/chidori.git" },
@@ -17,12 +18,18 @@
17
18
  "./agent": {
18
19
  "import": "./dist/agent.js",
19
20
  "types": "./dist/agent.d.ts"
21
+ },
22
+ "./agent-env": {
23
+ "import": "./dist/agent-env.js",
24
+ "types": "./dist/agent-env.d.ts"
20
25
  }
21
26
  },
22
27
  "files": ["dist", "src", "README.md"],
23
28
  "scripts": {
24
29
  "build": "tsc",
25
- "typecheck": "tsc --noEmit"
30
+ "typecheck": "tsc --noEmit",
31
+ "pretest": "tsc",
32
+ "test": "node --test test/*.test.mjs"
26
33
  },
27
34
  "devDependencies": {
28
35
  "typescript": "^5.4.0"
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Ambient types for the virtual `chidori:agent` module.
3
+ *
4
+ * Agent and tool files written for the Chidori runtime import their authoring
5
+ * types — and, in the global style, the `chidori`/`run` values — from
6
+ * `chidori:agent`:
7
+ *
8
+ * ```ts
9
+ * import type { Chidori, ToolDefinition } from "chidori:agent";
10
+ * // …or the global style:
11
+ * import { chidori, run } from "chidori:agent";
12
+ * ```
13
+ *
14
+ * There is no installable package behind that specifier. It is a virtual module
15
+ * the runtime injects, much like `node:fs` or `bun:test`: the runtime strips the
16
+ * import and supplies the real values when it executes the file, so nothing is
17
+ * resolved from npm. Crucially, the unrelated `chidori` package on npm can never
18
+ * be pulled in by mistake, because `chidori:agent` is not a registry name at all.
19
+ *
20
+ * This file exists only so editors and `tsc` can type agent files. Pull it into
21
+ * a project with a triple-slash reference at the top of an agent or tool file:
22
+ *
23
+ * ```ts
24
+ * /// <reference types="@1kbirds/chidori/agent-env" />
25
+ * import type { Chidori } from "chidori:agent";
26
+ * ```
27
+ *
28
+ * or once, project-wide, via tsconfig `compilerOptions.types`:
29
+ * `["@1kbirds/chidori/agent-env"]`.
30
+ *
31
+ * NOTE: this must stay a script file (no top-level `import`/`export`). A bare
32
+ * `declare module "chidori:agent"` is a *global* ambient declaration; adding a
33
+ * top-level `export` would turn it into a module augmentation and fail to
34
+ * resolve, since there is no real `chidori:agent` module to augment.
35
+ */
36
+ declare module "chidori:agent" {
37
+ // Re-export every authoring type plus the `chidori`/`run` value globals from
38
+ // the SDK's agent module. Ambient module declarations may only reference
39
+ // other modules by a non-relative (package) name, so we use the package's own
40
+ // public subpath. The package's build resolves it via the `paths` mapping in
41
+ // tsconfig.json; consumers resolve it from `node_modules`.
42
+ export * from "@1kbirds/chidori/agent";
43
+ }
package/src/agent.ts CHANGED
@@ -508,7 +508,7 @@ export type ToolFunction<TArgs extends JsonObject = JsonObject, TResult extends
508
508
  * need for a `(input, chidori)` second parameter):
509
509
  *
510
510
  * ```ts
511
- * import { chidori, run } from "chidori";
511
+ * import { chidori, run } from "chidori:agent";
512
512
  * run(async (input: { topic: string }) => {
513
513
  * await chidori.log("starting", { topic: input.topic });
514
514
  * return { ok: true };
@@ -533,7 +533,7 @@ export const chidori: Chidori = new Proxy({} as Chidori, {
533
533
  * named `agent`" convention.
534
534
  *
535
535
  * ```ts
536
- * import { run } from "chidori";
536
+ * import { run } from "chidori:agent";
537
537
  * run(async (input) => ({ greeting: `hello ${input.name}` }));
538
538
  * ```
539
539
  */