@baobox/sdk 0.1.0 → 0.1.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
@@ -1,8 +1,8 @@
1
1
  # @baobox/sdk
2
2
 
3
- TypeScript HTTP client for [Baobox](https://baobox.au) — an AI integration platform providing an agent runtime, eval engine, and observability trail.
3
+ TypeScript HTTP client for [BaoBox](https://baobox.ai) — an AI integration platform providing an agent runtime, eval engine, and observability trail.
4
4
 
5
- This package is a thin wrapper around Baobox's REST API. It has zero business logic — all intelligence lives server-side. Making it public removes friction for partners and third-party users while keeping the runtime closed.
5
+ This package is a thin wrapper around BaoBox's REST API. It has zero business logic — all intelligence lives server-side. Making it public removes friction for partners and third-party users while keeping the runtime closed.
6
6
 
7
7
  ## Installation
8
8
 
@@ -17,14 +17,14 @@ Requires Node.js 18+ (relies on native `fetch`).
17
17
  ## Quick start
18
18
 
19
19
  ```typescript
20
- import { BaoboxClient } from "@baobox/sdk";
20
+ import { BaoBoxClient } from "@baobox/sdk";
21
21
 
22
- const sb = new BaoboxClient({
23
- endpoint: "https://baobox-jv1.example.workers.dev",
22
+ const bb = new BaoBoxClient({
23
+ endpoint: "https://api.baobox.ai",
24
24
  apiKey: process.env.BAOBOX_API_KEY!,
25
25
  });
26
26
 
27
- const res = await sb.chat({
27
+ const res = await bb.chat({
28
28
  skillId: "sk_document_chaser",
29
29
  message: "Review cli_01 and take whatever action is needed.",
30
30
  sessionId: "ses_cli_01",
@@ -40,7 +40,7 @@ console.log(res.meta.trace); // [{ toolName, input, output, latencyMs },
40
40
  ### Chat
41
41
 
42
42
  ```typescript
43
- const res = await sb.chat({
43
+ const res = await bb.chat({
44
44
  skillId: "sk_chase",
45
45
  message: "...",
46
46
  sessionId: "ses_1", // optional
@@ -53,22 +53,22 @@ Returns `{ response, usage: { inputTokens, outputTokens }, sessionId, meta }` wh
53
53
  ### Sessions
54
54
 
55
55
  ```typescript
56
- const session = await sb.sessions.create({ skillId: "sk_chase" });
57
- const history = await sb.sessions.messages(session.id);
56
+ const session = await bb.sessions.create({ skillId: "sk_chase" });
57
+ const history = await bb.sessions.messages(session.id);
58
58
  ```
59
59
 
60
60
  ### Admin (requires admin token)
61
61
 
62
62
  ```typescript
63
- await sb.admin.skills.upsert({
63
+ await bb.admin.skills.upsert({
64
64
  id: "sk_chase",
65
65
  name: "Document Chaser",
66
66
  systemPrompt: "...",
67
- model: "MiniMax-M2.7",
67
+ model: "gpt-5",
68
68
  tools: ["lookup_client_docs", "send_client_email"],
69
69
  });
70
70
 
71
- await sb.admin.tools.upsert({
71
+ await bb.admin.tools.upsert({
72
72
  name: "lookup_client_docs",
73
73
  description: "...",
74
74
  inputSchema: { type: "object", properties: { /* ... */ } },
@@ -80,20 +80,20 @@ await sb.admin.tools.upsert({
80
80
  ### Events (trace)
81
81
 
82
82
  ```typescript
83
- const events = await sb.events.list({ sessionId: "ses_1", limit: 50 });
83
+ const events = await bb.events.list({ sessionId: "ses_1", limit: 50 });
84
84
  ```
85
85
 
86
86
  ## Error handling
87
87
 
88
- Every non-2xx response throws `BaoboxError`:
88
+ Every non-2xx response throws `BaoBoxError`:
89
89
 
90
90
  ```typescript
91
- import { BaoboxError } from "@baobox/sdk";
91
+ import { BaoBoxError } from "@baobox/sdk";
92
92
 
93
93
  try {
94
- await sb.chat({ skillId: "sk_missing", message: "..." });
94
+ await bb.chat({ skillId: "sk_missing", message: "..." });
95
95
  } catch (err) {
96
- if (err instanceof BaoboxError) {
96
+ if (err instanceof BaoBoxError) {
97
97
  console.error(err.status); // 404
98
98
  console.error(err.code); // "SKILL_NOT_FOUND"
99
99
  console.error(err.requestId); // server-side request id for log correlation
@@ -101,13 +101,13 @@ try {
101
101
  }
102
102
  ```
103
103
 
104
- Network failures surface as `BaoboxError` with `status: 0` and `code: "NETWORK"`; timeouts as `code: "TIMEOUT"`.
104
+ Network failures surface as `BaoBoxError` with `status: 0` and `code: "NETWORK"`; timeouts as `code: "TIMEOUT"`.
105
105
 
106
106
  ## Configuration
107
107
 
108
108
  ```typescript
109
- new BaoboxClient({
110
- endpoint: "...", // required — Baobox worker URL
109
+ new BaoBoxClient({
110
+ endpoint: "...", // required — BaoBox API base URL
111
111
  apiKey: "...", // required
112
112
  orgId: "firm_a", // optional, observability tag
113
113
  fetch: myFetch, // optional, injects custom fetch (tests / edge runtimes)
@@ -121,5 +121,5 @@ MIT. See [LICENSE](./LICENSE).
121
121
 
122
122
  ## Related
123
123
 
124
- - Tech Arch §4 full SDK design rationale (Baobox internal doc)
125
- - [Adoptive Co](https://adoptive.co) — consultancy using Baobox as a delivery tool
124
+ - [BaoBox](https://baobox.ai)product homepage
125
+ - [Adoptive Co](https://adoptive.co) — consultancy using BaoBox as a delivery tool
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare class BaoboxError extends Error {
1
+ export declare class BaoBoxError extends Error {
2
2
  readonly status: number;
3
3
  readonly code: string;
4
4
  readonly requestId: string | null;
package/dist/errors.js CHANGED
@@ -1,14 +1,14 @@
1
1
  // SDK-specific error class. Thrown for any non-2xx response; carries the
2
2
  // HTTP status, the server's error code + message when available, and the
3
- // Baobox request_id so callers can correlate with server logs.
4
- export class BaoboxError extends Error {
3
+ // BaoBox request_id so callers can correlate with server logs.
4
+ export class BaoBoxError extends Error {
5
5
  status;
6
6
  code;
7
7
  requestId;
8
8
  body;
9
9
  constructor(status, code, message, requestId, body) {
10
10
  super(message);
11
- this.name = "BaoboxError";
11
+ this.name = "BaoBoxError";
12
12
  this.status = status;
13
13
  this.code = code;
14
14
  this.requestId = requestId;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { ChatRequest, ChatResponse, Event, EventListRequest, Session, SessionMessage, Skill, BaoboxClientOptions, SkillUpsertRequest, Tool, ToolUpsertRequest } from "./types.js";
2
- export { BaoboxError } from "./errors.js";
1
+ import type { ChatRequest, ChatResponse, Event, EventListRequest, Session, SessionMessage, Skill, BaoBoxClientOptions, SkillUpsertRequest, Tool, ToolUpsertRequest } from "./types.js";
2
+ export { BaoBoxError } from "./errors.js";
3
3
  export type * from "./types.js";
4
- export declare class BaoboxClient {
4
+ export declare class BaoBoxClient {
5
5
  private readonly endpoint;
6
6
  private readonly apiKey;
7
7
  private readonly fetch;
@@ -23,7 +23,7 @@ export declare class BaoboxClient {
23
23
  readonly events: {
24
24
  list: (req: EventListRequest) => Promise<Event[]>;
25
25
  };
26
- constructor(opts: BaoboxClientOptions);
26
+ constructor(opts: BaoBoxClientOptions);
27
27
  chat(req: ChatRequest): Promise<ChatResponse>;
28
28
  private createSession;
29
29
  private listMessages;
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- // @baobox/sdk — thin HTTP client for the Baobox runtime.
1
+ // @baobox/sdk — thin HTTP client for the BaoBox runtime.
2
2
  // No business logic here — everything smart lives server-side. This file
3
3
  // is ~300 lines on purpose; if it grows past ~500, something that belongs
4
4
  // in the runtime has leaked out.
5
- import { BaoboxError } from "./errors.js";
6
- export { BaoboxError } from "./errors.js";
7
- export class BaoboxClient {
5
+ import { BaoBoxError } from "./errors.js";
6
+ export { BaoBoxError } from "./errors.js";
7
+ export class BaoBoxClient {
8
8
  endpoint;
9
9
  apiKey;
10
10
  fetch;
11
11
  timeoutMs;
12
12
  // `admin` and `events` are pseudo-namespaces — just method bundles so
13
- // call sites read as `sb.admin.skills.upsert(...)` rather than a flat
14
- // `sb.upsertSkill(...)`. Matches Tech Arch §4.2.
13
+ // call sites read as `bb.admin.skills.upsert(...)` rather than a flat
14
+ // `bb.upsertSkill(...)`. Matches Tech Arch §4.2.
15
15
  admin;
16
16
  sessions;
17
17
  events;
18
18
  constructor(opts) {
19
19
  if (!opts.endpoint)
20
- throw new Error("BaoboxClient: endpoint required");
20
+ throw new Error("BaoBoxClient: endpoint required");
21
21
  if (!opts.apiKey)
22
- throw new Error("BaoboxClient: apiKey required");
22
+ throw new Error("BaoBoxClient: apiKey required");
23
23
  this.endpoint = opts.endpoint.replace(/\/+$/, "");
24
24
  this.apiKey = opts.apiKey;
25
25
  this.fetch = opts.fetch ?? globalThis.fetch;
@@ -166,7 +166,7 @@ export class BaoboxClient {
166
166
  }
167
167
  catch (err) {
168
168
  const isAbort = err instanceof DOMException && err.name === "AbortError";
169
- throw new BaoboxError(0, isAbort ? "TIMEOUT" : "NETWORK", isAbort
169
+ throw new BaoBoxError(0, isAbort ? "TIMEOUT" : "NETWORK", isAbort
170
170
  ? `Request to ${path} timed out after ${this.timeoutMs}ms`
171
171
  : `Network error calling ${path}: ${String(err)}`, null, null);
172
172
  }
@@ -178,7 +178,7 @@ export class BaoboxClient {
178
178
  const parsed = text.length ? safeParseJson(text) : {};
179
179
  if (!res.ok) {
180
180
  const errObj = parsed.error;
181
- throw new BaoboxError(res.status, errObj?.code ?? "HTTP_ERROR", errObj?.message ?? res.statusText, errObj?.request_id ?? null, parsed);
181
+ throw new BaoBoxError(res.status, errObj?.code ?? "HTTP_ERROR", errObj?.message ?? res.statusText, errObj?.request_id ?? null, parsed);
182
182
  }
183
183
  const envelope = parsed;
184
184
  return {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type BaoboxClientOptions = {
2
- /** Full URL to the Baobox worker, e.g. "https://baobox-jv1.brightq.workers.dev" */
1
+ export type BaoBoxClientOptions = {
2
+ /** Full URL to the BaoBox worker, e.g. "https://baobox-jv1.brightq.workers.dev" */
3
3
  endpoint: string;
4
- /** API key issued by Baobox admin. Hashes to one `api_keys` row. */
4
+ /** API key issued by BaoBox admin. Hashes to one `api_keys` row. */
5
5
  apiKey: string;
6
6
  /** Optional tag for observability — not sent over the wire yet. */
7
7
  orgId?: string;
@@ -27,7 +27,7 @@ export type ChatResponse = {
27
27
  outputTokens: number;
28
28
  };
29
29
  sessionId?: string;
30
- /** Full Baobox metadata envelope: request_id, latency, tool trace. */
30
+ /** Full BaoBox metadata envelope: request_id, latency, tool trace. */
31
31
  meta: ResponseMeta;
32
32
  };
33
33
  export type ResponseMeta = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@baobox/sdk",
3
- "version": "0.1.0",
4
- "description": "TypeScript HTTP client for Baobox — agent runtime + eval + observability.",
3
+ "version": "0.1.1",
4
+ "description": "TypeScript HTTP client for BaoBox — agent runtime + eval + observability.",
5
5
  "license": "MIT",
6
6
  "author": "Bright Qi <bright@adoptive.co>",
7
7
  "repository": {