@zoowork-ai/sdk 0.12.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -3,6 +3,46 @@
3
3
  All notable changes to `@zoowork-ai/sdk` (formerly `@zooclaw-agents/sdk`). Dates are the
4
4
  day the behaviour was verified, not the day it was written.
5
5
 
6
+ ## 0.14.0 — 2026-10-29
7
+
8
+ - Live smoke and thinking tests now default to the platform default model (the catalog row whose
9
+ `default_for` includes `model`) instead of the first catalog row, which sorts alphabetically.
10
+ They fall back to the first eligible row when no default is marked. `--model` still overrides.
11
+ - Ship `dist/AGENTS.md`, a short guide for coding assistants working in a project that installs this
12
+ package. The public docs describe the newest release; the guide tells an assistant to check a
13
+ method against the installed `*.d.ts` and `CHANGELOG.md`, and to tell the user when the docs rely
14
+ on something the installed version lacks instead of upgrading or working around it silently. In
15
+ an eval of projects pinned to 0.10.2, such a guide took Codex from 0/9 to 8/9 on reporting the
16
+ gap and kept Claude Code at 9/9 (zoowork-sdk-skills#40).
17
+ - Add `getBalance()` for `GET /service/v1/balance`. It returns the Organization balance shared by
18
+ all Projects as a USD decimal string (`available_amount`), the same amount the Platform Billing
19
+ page shows. Any Platform key in the Organization can read it; Work service tokens receive
20
+ `service_api.not_found`.
21
+ - Require Node.js 22 or later (`engines.node` is now `>=22`). Node.js 20 reached end of life on
22
+ 2026-04-30 and was not patched by the 2026-10-21 Node.js security release. The SDK does not use
23
+ any Node.js 22-only API, so Node.js 20 may still run it, but that line is no longer tested or
24
+ supported. CI now tests Node.js 22, 24 and 26.
25
+
26
+ ## 0.13.0 — 2026-10-23
27
+
28
+ - Make the deprecated engine-only event lane visible in the types (#58). `listEvents`,
29
+ `listEventsPage`, `listAllEvents` and `streamEvents` now have a cursor overload and a
30
+ `@deprecated` overload for `after`, so editors strike through `{ after: ev.seq }`. That call
31
+ reads a lane whose numbering differs from the unified `seq` and which omits your inputs, so it
32
+ silently skips and renumbers events. Use `cursor`.
33
+ - `listAllEvents` accepts `cursor` and starts the unified walk after it. A walk that starts from
34
+ a cursor never falls back to the `after` lane. Passing both `cursor` and `after` throws a
35
+ `TypeError` before any request.
36
+ - Type-level change: an options object that sets both `cursor` and `after` no longer compiles,
37
+ matching the server, which rejects that combination with `400 invalid_request`. A variable
38
+ typed `{ after?: number; cursor?: string }` also no longer matches either overload; narrow it
39
+ to one lane. New exported types: `EventCursorPosition`, `LegacyEventPosition` (deprecated),
40
+ `ListEventsOptions`, `ListAllEventsOptions` and `StreamEventsOptions`.
41
+ - Document that `SessionEvent.seq` orders events but is not a resume position, and that
42
+ `SessionEvent.cursor` is set only on streamed events.
43
+ - `examples/capability-probe.ts` and `examples/surface-probe.ts` resume turns with `cursor`
44
+ instead of passing a unified `seq` as `after`.
45
+
6
46
  ## 0.12.0 — 2026-10-14
7
47
 
8
48
  - Add the Agent default thinking level (Managed API `model.thinking`, live in production from
package/README.md CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  TypeScript SDK for the [ZooWork Managed Agents](https://zoowork.ai/docs/) API. Developer Preview.
4
4
 
5
- Zero runtime dependencies — it uses the platform `fetch`, which you can override for edge runtimes and tests. ESM only, Node 20+.
5
+ Zero runtime dependencies — it uses the platform `fetch`, which you can override for edge runtimes and tests. ESM only. Requires Node.js 22 or later; use the latest security release of your Node.js line.
6
+
7
+ Coding assistants: the installed package includes `dist/AGENTS.md`, which explains how to check
8
+ the docs against the installed version.
6
9
 
7
10
  ```bash
8
11
  npm install @zoowork-ai/sdk
@@ -161,7 +164,7 @@ for await (const ev of zc.streamEvents(agent.agent_id, session.session_id)) {
161
164
  Three things worth knowing before you write that loop:
162
165
 
163
166
  - **The stream is session-scoped and does not close when a turn ends.** The server closes it after an idle period. Break on `isRunFinished(ev)` yourself, or you block until that timeout.
164
- - **Save the opaque cursor.** After consuming an event, retain `ev.cursor` and resume with `{ cursor }`. Do not derive it from `seq` or mix it with `after`: `after` selects the deprecated event lane, which omits user-input events. The SDK sends the cursor in the query; do not rely on a raw `Last-Event-ID` header passing through the public gateway.
167
+ - **Save the opaque cursor.** After consuming an event, retain `ev.cursor` and resume with `{ cursor }`. Do not derive it from `seq` or mix it with `after`: `after` selects the deprecated event lane, which numbers events differently and omits user-input events, so `after: ev.seq` silently skips events. Calls that pass `after` resolve to a `@deprecated` overload, which editors strike through. Listed events carry no cursor: continue a listing from the page's `nextCursor`, which `listAllEvents({ cursor })` also accepts. The SDK sends the cursor in the query; do not rely on a raw `Last-Event-ID` header passing through the public gateway.
165
168
  - **The default unified REST and SSE wire formats use snake_case.** Older event formats differ; the SDK normalizes both into `SessionEvent`, where you read `eventType`. Keep the cursor unchanged.
166
169
 
167
170
  For API sessions, `user.message` can carry `actor: { ref: 'customer-42' }`, including in
@@ -446,6 +449,7 @@ These helpers require an SDK release that includes them. Check the installed dec
446
449
 
447
450
  ```ts
448
451
  const usage = await zc.getUsage({ range: '7d', view: 'both' })
452
+ const balance = await zc.getBalance() // { object: 'balance', available_amount: '11.34', currency: 'usd' }
449
453
  const endpoint = await zc.createAgentWebhook(agentId, {
450
454
  url: 'https://receiver.example/webhook', event_types: ['run.finished'],
451
455
  }, 'register-hook-v1')
@@ -460,7 +464,9 @@ The workspace Files methods (`getWorkspaceFile`, `writeWorkspaceFile`,
460
464
  Send a file to an Agent with `uploadFile`, and retrieve results by asking the Agent to publish
461
465
  Artifacts and downloading those through the Artifact API. The database viewer is not a
462
466
  supported production workflow. The Agent can use `agent_db` and return query results in its
463
- reply. Method presence is not production availability. Usage stays within the current key scope. Page helpers retain `next_cursor` and `has_more`; replay cursors
467
+ reply. Method presence is not production availability. Usage stays within the current key scope.
468
+ `getBalance` returns the Organization balance shared by all Projects, in USD, to any Platform
469
+ key in the Organization. Page helpers retain `next_cursor` and `has_more`; replay cursors
464
470
  verbatim. `getApproval` and `getCustomToolCall` read terminal as well as pending actions.
465
471
 
466
472
  Agent webhook methods include get/update/delete, `rotateAgentWebhookSecret`, `testAgentWebhook`,
@@ -471,10 +477,15 @@ records to learn the result. SDK writes do not retry automatically.
471
477
  `createSession` accepts `runtime_mode: 'active'` to pin the current active configuration at
472
478
  creation. Omit it to resolve active configuration on later turns. `idle_compaction` preserves
473
479
  false, null and omission. MCP tool overrides accept `requireConfirmation?: boolean`.
474
- Production `updateAgent` currently rejects `expected_config_version` with
475
- `400 invalid_declared_key`. Omit it for ordinary last-write-wins updates; serialize competing
476
- writes in your application. A GET followed by PUT is not atomic. Ownership-only changes do not
477
- increment the configuration version. The separate `upgradeSystemPrompt` precondition remains supported.
480
+
481
+ Pass an optional positive `expected_config_version` in the `updateAgent` sections object to
482
+ check the current configuration version atomically with the update. Read it from
483
+ `agent.status?.config_version ?? agent.config_version`. A mismatch returns
484
+ `409 active_config_changed` without changing the configuration. Re-read and recompute the
485
+ intended change before retrying; the precondition itself is not stored in `declared`.
486
+ Omitting it keeps last-write-wins behavior. Ownership-only changes do not increment the
487
+ configuration version. The separate `upgradeSystemPrompt` method requires its version
488
+ precondition and uses `409 config_version_changed`.
478
489
 
479
490
  ## Current production behavior
480
491
 
package/dist/AGENTS.md ADDED
@@ -0,0 +1,18 @@
1
+ # @zoowork-ai/sdk: notes for coding assistants
2
+
3
+ This file ships inside the installed `@zoowork-ai/sdk` package. The installed version is in
4
+ `../package.json`.
5
+
6
+ The docs at https://zoowork.ai/docs describe the newest SDK release, which can be newer than the
7
+ copy installed in this project. Before you use a method, field, or option from the docs:
8
+
9
+ - Check that it exists in the `*.d.ts` files next to this one. They are the source of truth for
10
+ what the installed version supports.
11
+ - `../CHANGELOG.md` lists what each release up to the installed one added. Later releases are
12
+ listed at https://raw.githubusercontent.com/SerendipityOneInc/zoowork-sdk-typescript/main/CHANGELOG.md.
13
+ - If the docs rely on something the installed version lacks, tell the user which release adds it
14
+ and ask before upgrading. Do not upgrade the SDK without asking. If you work around the gap
15
+ instead, for example with a deprecated method or an untyped value, say so.
16
+
17
+ Server behavior (errors, event streams, schedules, limits) does not depend on the SDK version.
18
+ Follow the live docs for it: https://zoowork.ai/docs/llms.txt
package/dist/client.d.ts CHANGED
@@ -883,6 +883,43 @@ export interface SessionEventPage {
883
883
  hasMore?: boolean;
884
884
  nextCursor?: string | null;
885
885
  }
886
+ /**
887
+ * Where an event read starts: omit `cursor` for the beginning of the unified history, or pass a
888
+ * saved one to continue after it. `after` is not accepted here; it selects a separate,
889
+ * deprecated overload, so an editor flags any call that uses it.
890
+ */
891
+ export interface EventCursorPosition {
892
+ /** Opaque resume token: a page's `nextCursor`, or a streamed event's `cursor`. Do not build one from `seq`. */
893
+ cursor?: string;
894
+ after?: undefined;
895
+ }
896
+ /**
897
+ * @deprecated Engine-only lane position. Use {@link EventCursorPosition}.
898
+ *
899
+ * That lane numbers events differently from the unified history and omits your own inputs
900
+ * (`user.message`, …), so `after: event.seq` with a `seq` from the unified history silently
901
+ * skips events and returns them renumbered. Keep it only for numeric positions stored from that
902
+ * lane before cursors existed. The server rejects `after` and `cursor` together.
903
+ */
904
+ export interface LegacyEventPosition {
905
+ /** @deprecated Engine-only lane sequence, not a unified `SessionEvent.seq`. Use `cursor`. */
906
+ after?: number;
907
+ cursor?: undefined;
908
+ }
909
+ /** Filters for {@link ZooworkClient.listEvents} and {@link ZooworkClient.listEventsPage}. */
910
+ export interface ListEventsOptions {
911
+ types?: string[];
912
+ limit?: number;
913
+ }
914
+ /** Filters for {@link ZooworkClient.listAllEvents}. */
915
+ export interface ListAllEventsOptions {
916
+ types?: string[];
917
+ pageSize?: number;
918
+ }
919
+ /** Options for {@link ZooworkClient.streamEvents}. */
920
+ export interface StreamEventsOptions {
921
+ signal?: AbortSignal;
922
+ }
886
923
  /**
887
924
  * When a schedule fires: cron expression, everyMs interval in milliseconds (optional
888
925
  * anchorMs), or an ISO instant in at. The everyMs contract is source-reviewed; it was
@@ -1406,8 +1443,10 @@ export interface ZooworkClient extends DeveloperApi {
1406
1443
  listAgents(opts?: AgentListParams): AgentPagePromise;
1407
1444
  getAgent(agentId: string): Promise<AgentRecord>;
1408
1445
  /** PUT declared sections. Ownership-only changes do not bump config_version.
1409
- * Production currently rejects expected_config_version with 400 invalid_declared_key.
1410
- * Omit it for last-write-wins updates and serialize competing writes in the application. */
1446
+ * Pass optional expected_config_version as a positive integer in sections for an atomic
1447
+ * version precondition. A mismatch returns 409 active_config_changed without applying
1448
+ * the update; re-read and recompute the change before retrying. Omit it for last-write-wins
1449
+ * updates. The precondition is not stored in declared configuration. */
1411
1450
  updateAgent(agentId: string, sections: Record<string, unknown>): Promise<AgentRecord>;
1412
1451
  /**
1413
1452
  * Soft delete: the agent stops resolving on the API, but this is not a resource purge.
@@ -1727,53 +1766,55 @@ export interface ZooworkClient extends DeveloperApi {
1727
1766
  * (`user.message`, …) alongside engine events. `limit` defaults to 100 and is capped at 500;
1728
1767
  * the page's pagination fields are dropped, so use {@link ZooworkClient.listAllEvents}, or
1729
1768
  * {@link ZooworkClient.listEventsPage} to page by hand.
1730
- * Passing `after` selects the deprecated engine-only lane — old cursors only.
1731
1769
  */
1732
- listEvents(agentId: string, sessionId: string, opts?: {
1733
- after?: number;
1734
- cursor?: string;
1735
- types?: string[];
1736
- limit?: number;
1737
- }): Promise<SessionEvent[]>;
1770
+ listEvents(agentId: string, sessionId: string, opts?: ListEventsOptions & EventCursorPosition): Promise<SessionEvent[]>;
1771
+ /**
1772
+ * @deprecated `after` reads the engine-only lane, whose numbering differs from the unified
1773
+ * `seq` and which omits your inputs. Use `cursor`; see {@link LegacyEventPosition}.
1774
+ */
1775
+ listEvents(agentId: string, sessionId: string, opts: ListEventsOptions & LegacyEventPosition): Promise<SessionEvent[]>;
1738
1776
  /**
1739
1777
  * The page-returning primitive under `listEvents`: same options, plus the page's `hasMore`
1740
1778
  * and `nextCursor` (absent on servers without cursor pagination). Feed `nextCursor` back as
1741
- * `cursor` to page by hand.
1779
+ * `cursor` to page by hand. Listed events carry no per-event `cursor`; resume from
1780
+ * `nextCursor`, not from an event's `seq`.
1742
1781
  */
1743
- listEventsPage(agentId: string, sessionId: string, opts?: {
1744
- after?: number;
1745
- cursor?: string;
1746
- types?: string[];
1747
- limit?: number;
1748
- }): Promise<SessionEventPage>;
1782
+ listEventsPage(agentId: string, sessionId: string, opts?: ListEventsOptions & EventCursorPosition): Promise<SessionEventPage>;
1783
+ /**
1784
+ * @deprecated `after` reads the engine-only lane, whose numbering differs from the unified
1785
+ * `seq` and which omits your inputs. Use `cursor`; see {@link LegacyEventPosition}.
1786
+ */
1787
+ listEventsPage(agentId: string, sessionId: string, opts: ListEventsOptions & LegacyEventPosition): Promise<SessionEventPage>;
1749
1788
  /**
1750
1789
  * Every durable event: follows the server's `next_cursor` until `has_more` is false, and
1751
1790
  * falls back to walking `after` against servers without cursor pagination (that walk stops
1752
1791
  * when a page fails to advance, so a server that ignored `after` cannot spin it forever).
1753
1792
  *
1754
- * `pageSize` is the per-request `limit` (default and maximum 500). Events come back in
1755
- * ascending `seq`, deduplicated across page boundaries. Passing `after` forces the
1756
- * deprecated engine-only lane.
1793
+ * Pass `cursor` (a saved `nextCursor` or streamed event `cursor`) to start after that
1794
+ * position; a walk that starts from a cursor never falls back to `after`. `pageSize` is the
1795
+ * per-request `limit` (default and maximum 500). Events come back in ascending `seq`,
1796
+ * deduplicated across page boundaries.
1757
1797
  */
1758
- listAllEvents(agentId: string, sessionId: string, opts?: {
1759
- after?: number;
1760
- types?: string[];
1761
- pageSize?: number;
1762
- }): Promise<SessionEvent[]>;
1798
+ listAllEvents(agentId: string, sessionId: string, opts?: ListAllEventsOptions & EventCursorPosition): Promise<SessionEvent[]>;
1799
+ /**
1800
+ * @deprecated `after` forces the engine-only lane, whose numbering differs from the unified
1801
+ * `seq` and which omits your inputs. Use `cursor`; see {@link LegacyEventPosition}.
1802
+ */
1803
+ listAllEvents(agentId: string, sessionId: string, opts: ListAllEventsOptions & LegacyEventPosition): Promise<SessionEvent[]>;
1763
1804
  /**
1764
1805
  * Durable event stream with server-side resume.
1765
1806
  *
1766
1807
  * The stream is SESSION-scoped and unbounded: it does NOT close when a turn ends, and the
1767
1808
  * server closes it on idle. Detect turn end with `isRunFinished`, and resume by passing the
1768
- * last event's `cursor` (its `after` fallback selects the deprecated engine-only lane).
1769
- * `chat.delta` preview frames are skipped — they are snapshot-replace frames on a separate
1770
- * Redis-only lane, not durable events.
1809
+ * last event's `cursor`. `chat.delta` preview frames are skipped — they are snapshot-replace
1810
+ * frames on a separate Redis-only lane, not durable events.
1771
1811
  */
1772
- streamEvents(agentId: string, sessionId: string, opts?: {
1773
- after?: number;
1774
- cursor?: string;
1775
- signal?: AbortSignal;
1776
- }): AsyncGenerator<SessionEvent>;
1812
+ streamEvents(agentId: string, sessionId: string, opts?: StreamEventsOptions & EventCursorPosition): AsyncGenerator<SessionEvent>;
1813
+ /**
1814
+ * @deprecated `after` resumes the engine-only lane, whose numbering differs from the unified
1815
+ * `seq` and which omits your inputs. Use `cursor`; see {@link LegacyEventPosition}.
1816
+ */
1817
+ streamEvents(agentId: string, sessionId: string, opts: StreamEventsOptions & LegacyEventPosition): AsyncGenerator<SessionEvent>;
1777
1818
  /** Pending calls only. Any other status is rejected by the API. */
1778
1819
  listCustomToolCalls(agentId: string, opts?: {
1779
1820
  status?: 'pending';
package/dist/client.js CHANGED
@@ -337,6 +337,21 @@ export function createZooworkClient(cfg = {}) {
337
337
  throw error;
338
338
  }
339
339
  };
340
+ // Both public overloads share this implementation; the deprecated `after` one only differs in
341
+ // which lane the server reads.
342
+ const listEventsPage = async (agentId, sessionId, opts = {}) => {
343
+ const data = await json(`${sessions(agentId)}/${encodeURIComponent(sessionId)}/events${query({
344
+ after: opts.after,
345
+ cursor: opts.cursor,
346
+ types: opts.types?.join(','),
347
+ limit: opts.limit,
348
+ })}`);
349
+ return {
350
+ events: (data.events ?? []).map((e) => normalizeEvent(e)),
351
+ ...(data.has_more !== undefined ? { hasMore: data.has_more } : {}),
352
+ ...(data.next_cursor !== undefined ? { nextCursor: data.next_cursor } : {}),
353
+ };
354
+ };
340
355
  const client = {
341
356
  ...createDeveloperApi(json, bytes, artifactSelectors),
342
357
  listModels: async () => {
@@ -620,28 +635,19 @@ export function createZooworkClient(cfg = {}) {
620
635
  const data = await json(`${sessions(agentId)}/${encodeURIComponent(sessionId)}/events`, { method: 'POST', body: JSON.stringify({ events }) });
621
636
  return { events: data.events ?? [] };
622
637
  },
623
- listEvents: async (agentId, sessionId, opts = {}) => (await client.listEventsPage(agentId, sessionId, opts)).events,
624
- listEventsPage: async (agentId, sessionId, opts = {}) => {
625
- const data = await json(`${sessions(agentId)}/${encodeURIComponent(sessionId)}/events${query({
626
- after: opts.after,
627
- cursor: opts.cursor,
628
- types: opts.types?.join(','),
629
- limit: opts.limit,
630
- })}`);
631
- return {
632
- events: (data.events ?? []).map((e) => normalizeEvent(e)),
633
- ...(data.has_more !== undefined ? { hasMore: data.has_more } : {}),
634
- ...(data.next_cursor !== undefined ? { nextCursor: data.next_cursor } : {}),
635
- };
636
- },
638
+ listEvents: async (agentId, sessionId, opts = {}) => (await listEventsPage(agentId, sessionId, opts)).events,
639
+ listEventsPage,
637
640
  listAllEvents: async (agentId, sessionId, opts = {}) => {
641
+ if (opts.cursor !== undefined && opts.after !== undefined) {
642
+ throw new TypeError('listAllEvents: pass either cursor or after, not both');
643
+ }
638
644
  const pageSize = Math.min(Math.max(opts.pageSize ?? 500, 1), 500);
639
645
  const out = [];
640
646
  // Unified lane (default): follow the server's cursor until has_more is false.
641
647
  if (opts.after === undefined) {
642
- let pageCursor;
648
+ let pageCursor = opts.cursor;
643
649
  for (;;) {
644
- const page = await client.listEventsPage(agentId, sessionId, {
650
+ const page = await listEventsPage(agentId, sessionId, {
645
651
  ...(pageCursor !== undefined ? { cursor: pageCursor } : {}),
646
652
  ...(opts.types ? { types: opts.types } : {}),
647
653
  limit: pageSize,
@@ -667,7 +673,7 @@ export function createZooworkClient(cfg = {}) {
667
673
  }
668
674
  let cursor = opts.after ?? out.reduce((max, e) => (e.seq > max ? e.seq : max), 0);
669
675
  for (;;) {
670
- const page = await client.listEvents(agentId, sessionId, {
676
+ const { events: page } = await listEventsPage(agentId, sessionId, {
671
677
  after: cursor,
672
678
  ...(opts.types ? { types: opts.types } : {}),
673
679
  limit: pageSize,
@@ -68,6 +68,13 @@ export interface UsageResult extends ApiObject {
68
68
  groups?: ApiObject[];
69
69
  records?: ApiObject[];
70
70
  }
71
+ /** The Organization's shared balance, as shown on the Platform Billing page. */
72
+ export interface BalanceResult extends ApiObject {
73
+ object: 'balance';
74
+ /** Decimal USD string with two places, e.g. `"11.34"`, after current-period usage. */
75
+ available_amount: string;
76
+ currency: 'usd';
77
+ }
71
78
  export interface RunOutputArtifact extends ApiObject {
72
79
  artifact_id: string | null;
73
80
  name: string;
@@ -182,6 +189,8 @@ export interface DeveloperApi {
182
189
  offset?: number;
183
190
  }): Promise<AgentDatabaseRows>;
184
191
  getUsage(opts?: UsageOptions): Promise<UsageResult>;
192
+ /** Read the Organization balance shared by every Project. Requires a Platform key. */
193
+ getBalance(): Promise<BalanceResult>;
185
194
  getRunOutput(agentId: string, sessionId: string, runId: string, opts?: CursorOptions): Promise<RunOutput>;
186
195
  getApproval(agentId: string, approvalId: string): Promise<ApprovalRecord>;
187
196
  getCustomToolCall(agentId: string, callId: string): Promise<CustomToolCallRecord>;
@@ -21,6 +21,7 @@ export function createDeveloperApi(json, bytes, selectors) {
21
21
  getAgentDatabase: (id) => json(`${agent(id)}/database`),
22
22
  getAgentDatabaseRows: (id, table, opts = {}) => json(`${agent(id)}/database/tables/${segment(table)}/rows${query({ limit: opts.limit, offset: opts.offset })}`),
23
23
  getUsage: (opts = {}) => json(`/usage${query({ range: opts.range, timezone: opts.timezone, group_by: opts.groupBy, view: opts.view, session_id: opts.sessionId, api_key_id: opts.apiKeyId, root_session_id: opts.rootSessionId, attribution: opts.attribution, page: opts.page, per_page: opts.perPage, as_of: opts.asOf, snapshot: opts.snapshot, cursor: opts.cursor })}`),
24
+ getBalance: () => json('/balance'),
24
25
  getRunOutput: (id, sid, rid, opts = {}) => json(`${agent(id)}/sessions/${segment(sid)}/runs/${segment(rid)}/output${query({ cursor: opts.cursor, limit: opts.limit })}`),
25
26
  getApproval: (id, aid) => json(`${agent(id)}/approvals/${segment(aid)}`),
26
27
  getCustomToolCall: (id, cid) => json(`${agent(id)}/custom_tool_calls/${segment(cid)}`),
package/dist/events.d.ts CHANGED
@@ -24,7 +24,11 @@ export declare const PUBLIC_INPUT_EVENT_TYPES: readonly ["user.message", "user.i
24
24
  export type PublicInputEventType = (typeof PUBLIC_INPUT_EVENT_TYPES)[number];
25
25
  /** A durable session event, normalized across the REST and SSE shapes. */
26
26
  export interface SessionEvent {
27
- /** Durable per-session sequence: strictly increasing, not necessarily contiguous. */
27
+ /**
28
+ * Durable per-session sequence: strictly increasing, not necessarily contiguous. It orders
29
+ * events; it is not a resume position. The unified history and the deprecated engine-only
30
+ * lane number events differently, so never pass it as `after`. Resume with `cursor`.
31
+ */
28
32
  seq: number;
29
33
  eventType: SessionEventType | PublicInputEventType | string;
30
34
  payload: Record<string, unknown>;
@@ -35,7 +39,10 @@ export interface SessionEvent {
35
39
  id?: string;
36
40
  /** Input events only: `null` while queued, set once the agent has consumed it. */
37
41
  processedAt?: string | null;
38
- /** Resume token for `streamEvents({ cursor })`, present on streamed events. */
42
+ /**
43
+ * Opaque resume token, set only on events from `streamEvents`. Listed events do not carry
44
+ * one; resume a listing from its page's `nextCursor`.
45
+ */
39
46
  cursor?: string;
40
47
  }
41
48
  /** Accepts either wire shape (and an SSE `id:` line as the seq fallback). */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { createZooworkClient, DEFAULT_BASE_URL, ZooworkError, type ZooworkClient, type ZooworkConfig, type ZooworkAuth, type Ownership, type ModelInfo, type ThinkingLevel, type AgentResource, type AgentModelUpdate, type AgentUpdate, type AgentRecord, type AgentListParams, type AgentPage, type AgentPagePromise, type AgentStatus, type AgentSkill, type AgentChannel, type AgentChannelCapabilitySync, type AgentChannelCapabilities, type FeishuChannelProviderStatus, type FeishuDocumentsCapability, type ChannelPlatform, type AddChannelPlatform, type GuidedSetupPlatform, type AddChannelInput, type UpdateChannelInput, type ChannelSetupInput, type ChannelSetupSession, type ChannelPollResult, type FeishuSetupInput, type FeishuSetupSession, type FeishuPollResult, type McpContextConfig, type McpServerDeclaration, type McpToolPermission, type McpToolPermissionOverride, type CustomToolDeclaration, type CustomToolResultImageMimeType, type CustomToolResultContent, type CustomToolResultEvent, type SkillRecord, type SkillVersionRecord, type SessionRecord, type SessionListPageOptions, type SessionListPage, type SessionHistoryEntry, type SessionEvent, type SessionEventPage, type OutboundEvent, type PostEventReceipt, type ApprovalDecision, type ApprovalRecord, type CustomToolCallStatus, type CustomToolCallRecord, type ArtifactPage, type ArtifactRecord, type ArtifactStatus, type OutcomeConfig, type OutcomeEvaluator, type SystemPromptDeclaration, type SystemPromptInfo, type SystemPromptPreview, type SystemPromptPreviewInput, type SystemPromptUpgrade, type ScheduleSpec, type SchedulePayload, type ScheduleInput, type ScheduleUpdate, type ScheduleRecord, type ScheduleRun, type WakeResult, type ExecResult, type UploadFileResult, type EnvironmentConfig, type EnvironmentResource, type EnvironmentRecord, type EnvironmentVersionRecord, } from './client.js';
1
+ export { createZooworkClient, DEFAULT_BASE_URL, ZooworkError, type ZooworkClient, type ZooworkConfig, type ZooworkAuth, type Ownership, type ModelInfo, type ThinkingLevel, type AgentResource, type AgentModelUpdate, type AgentUpdate, type AgentRecord, type AgentListParams, type AgentPage, type AgentPagePromise, type AgentStatus, type AgentSkill, type AgentChannel, type AgentChannelCapabilitySync, type AgentChannelCapabilities, type FeishuChannelProviderStatus, type FeishuDocumentsCapability, type ChannelPlatform, type AddChannelPlatform, type GuidedSetupPlatform, type AddChannelInput, type UpdateChannelInput, type ChannelSetupInput, type ChannelSetupSession, type ChannelPollResult, type FeishuSetupInput, type FeishuSetupSession, type FeishuPollResult, type McpContextConfig, type McpServerDeclaration, type McpToolPermission, type McpToolPermissionOverride, type CustomToolDeclaration, type CustomToolResultImageMimeType, type CustomToolResultContent, type CustomToolResultEvent, type SkillRecord, type SkillVersionRecord, type SessionRecord, type SessionListPageOptions, type SessionListPage, type SessionHistoryEntry, type SessionEvent, type SessionEventPage, type EventCursorPosition, type ListEventsOptions, type ListAllEventsOptions, type StreamEventsOptions, type LegacyEventPosition, type OutboundEvent, type PostEventReceipt, type ApprovalDecision, type ApprovalRecord, type CustomToolCallStatus, type CustomToolCallRecord, type ArtifactPage, type ArtifactRecord, type ArtifactStatus, type OutcomeConfig, type OutcomeEvaluator, type SystemPromptDeclaration, type SystemPromptInfo, type SystemPromptPreview, type SystemPromptPreviewInput, type SystemPromptUpgrade, type ScheduleSpec, type SchedulePayload, type ScheduleInput, type ScheduleUpdate, type ScheduleRecord, type ScheduleRun, type WakeResult, type ExecResult, type UploadFileResult, type EnvironmentConfig, type EnvironmentResource, type EnvironmentRecord, type EnvironmentVersionRecord, } from './client.js';
2
2
  export { SESSION_EVENT_TYPES, type SessionEventType, PUBLIC_INPUT_EVENT_TYPES, type PublicInputEventType, normalizeEvent, isRunFinished, runOutcome, messageText, assistantText, thinkingText, customToolUse, type CustomToolUse, toolCall, type ToolCall, } from './events.js';
3
3
  export { parseSSE, type SSEMessage } from './sse.js';
4
4
  export { WEBHOOK_EVENT_TYPES, WEBHOOK_SCHEDULE_CONFIG_EVENT_TYPES, type WebhookEventType, isKnownWebhookEventType, knownWebhookEvent, verifyWebhookSignature, unwrapWebhook, signWebhook, ZooworkWebhookError, type WebhookErrorCode, WEBHOOK_ID_HEADER, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SECRET_ENV, WEBHOOK_TOLERANCE_SECONDS, WEBHOOK_DEFAULT_MAX_BODY_BYTES, type WebhookEvent, type WebhookEventFor, type KnownWebhookEvent, type WebhookEventData, type WebhookEventDataByType, type WebhookEventAttribution, type WebhookScheduleRunRef, type WebhookWaitingOnRef, type WebhookRunEventData, type WebhookRunStartedData, type WebhookRunFinishedData, type WebhookRunYieldedData, type WebhookApprovalEventData, type WebhookApprovalRequestedData, type WebhookApprovalResolvedData, type WebhookCustomToolEventData, type WebhookCustomToolRequestedData, type WebhookCustomToolResolvedData, type WebhookOutcomeEvaluatedData, type WebhookSessionCreatedData, type WebhookSessionArchivedData, type WebhookSessionDeletedData, type WebhookScheduleFireData, type WebhookScheduleDispatchedData, type WebhookScheduleDispatchFailedData, type WebhookScheduleSkippedData, type WebhookScheduleFinishedData, type WebhookScheduleConfigData, type WebhookTestData, type WebhookHeaders, type WebhookHeaderSource, type WebhookSignatureHeaders, type VerifyWebhookInput, type VerifiedWebhook, type SignWebhookInput, } from './webhooks.js';
5
- export type { ApiObject, CursorOptions, ActionListOptions, ApprovalPage, CustomToolCallPage, WorkspaceFileEntry, WorkspaceFile, AgentDatabase, AgentDatabaseRows, UsageOptions, UsageResult, RunOutputArtifact, RunOutputItem, RunOutput, AgentWebhookInput, AgentWebhookEndpoint, AgentWebhookPage, AgentWebhookCreated, AgentWebhookSecretRotation, WebhookDeliveryOptions, WebhookDeliveryPage, WebhookTestReceipt, WebhookRedeliveryReceipt, WebhookBatchRedeliveryReceipt, WebhookBatchRedeliveryInput, DeveloperApi, } from './developer-api.js';
5
+ export type { ApiObject, CursorOptions, ActionListOptions, ApprovalPage, CustomToolCallPage, WorkspaceFileEntry, WorkspaceFile, AgentDatabase, AgentDatabaseRows, UsageOptions, UsageResult, BalanceResult, RunOutputArtifact, RunOutputItem, RunOutput, AgentWebhookInput, AgentWebhookEndpoint, AgentWebhookPage, AgentWebhookCreated, AgentWebhookSecretRotation, WebhookDeliveryOptions, WebhookDeliveryPage, WebhookTestReceipt, WebhookRedeliveryReceipt, WebhookBatchRedeliveryReceipt, WebhookBatchRedeliveryInput, DeveloperApi, } from './developer-api.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoowork-ai/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "TypeScript SDK for the ZooWork Managed Agents API (Developer Preview)",
5
5
  "keywords": [
6
6
  "zoowork",
@@ -33,14 +33,14 @@
33
33
  "LICENSE"
34
34
  ],
35
35
  "engines": {
36
- "node": ">=20"
36
+ "node": ">=22"
37
37
  },
38
38
  "sideEffects": false,
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
42
  "scripts": {
43
- "build": "tsc -p tsconfig.build.json",
43
+ "build": "tsc -p tsconfig.build.json && node -e \"require('node:fs').copyFileSync('agent-guide/AGENTS.md', 'dist/AGENTS.md')\"",
44
44
  "typecheck": "tsc --noEmit",
45
45
  "test": "tsc --noEmit && vitest run",
46
46
  "test:watch": "vitest",