@zoowork-ai/sdk 0.11.1 → 0.13.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 +33 -0
- package/README.md +33 -5
- package/dist/client.d.ts +118 -32
- package/dist/client.js +23 -17
- package/dist/events.d.ts +9 -2
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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.13.0 — 2026-10-23
|
|
7
|
+
|
|
8
|
+
- Make the deprecated engine-only event lane visible in the types (#58). `listEvents`,
|
|
9
|
+
`listEventsPage`, `listAllEvents` and `streamEvents` now have a cursor overload and a
|
|
10
|
+
`@deprecated` overload for `after`, so editors strike through `{ after: ev.seq }`. That call
|
|
11
|
+
reads a lane whose numbering differs from the unified `seq` and which omits your inputs, so it
|
|
12
|
+
silently skips and renumbers events. Use `cursor`.
|
|
13
|
+
- `listAllEvents` accepts `cursor` and starts the unified walk after it. A walk that starts from
|
|
14
|
+
a cursor never falls back to the `after` lane. Passing both `cursor` and `after` throws a
|
|
15
|
+
`TypeError` before any request.
|
|
16
|
+
- Type-level change: an options object that sets both `cursor` and `after` no longer compiles,
|
|
17
|
+
matching the server, which rejects that combination with `400 invalid_request`. A variable
|
|
18
|
+
typed `{ after?: number; cursor?: string }` also no longer matches either overload; narrow it
|
|
19
|
+
to one lane. New exported types: `EventCursorPosition`, `LegacyEventPosition` (deprecated),
|
|
20
|
+
`ListEventsOptions`, `ListAllEventsOptions` and `StreamEventsOptions`.
|
|
21
|
+
- Document that `SessionEvent.seq` orders events but is not a resume position, and that
|
|
22
|
+
`SessionEvent.cursor` is set only on streamed events.
|
|
23
|
+
- `examples/capability-probe.ts` and `examples/surface-probe.ts` resume turns with `cursor`
|
|
24
|
+
instead of passing a unified `seq` as `after`.
|
|
25
|
+
|
|
26
|
+
## 0.12.0 — 2026-10-14
|
|
27
|
+
|
|
28
|
+
- Add the Agent default thinking level (Managed API `model.thinking`, live in production from
|
|
29
|
+
Engine `v0.2.33-release`). New exported types `ThinkingLevel`
|
|
30
|
+
(`'off' | 'low' | 'medium' | 'high' | 'max'`), `AgentModelUpdate` and `AgentUpdate`.
|
|
31
|
+
`AgentResource.model.thinking` accepts a level or `null`. `null` in an update clears it, and
|
|
32
|
+
`{ model: { thinking: null } } satisfies AgentUpdate` type-checks without `primary`.
|
|
33
|
+
- `ModelInfo.thinking` types the new `GET /v1/models` field `{ default, levels }`, which lists the
|
|
34
|
+
levels a model honours as named. A level a model does not list resolves to the nearest one.
|
|
35
|
+
- `SchedulePayload.thinking` overrides the Agent's level for an `agentTurn` job. On update,
|
|
36
|
+
omitting it keeps the stored value and `null` clears it.
|
|
37
|
+
- Additive only. Existing calls and types compile unchanged.
|
|
38
|
+
|
|
6
39
|
## 0.11.1 — 2026-10-04
|
|
7
40
|
|
|
8
41
|
- `uploadFile` no longer runs `chown` on the uploaded file or on directories it creates. The
|
package/README.md
CHANGED
|
@@ -51,6 +51,29 @@ const session = await zc.createSession(agent.agent_id, {
|
|
|
51
51
|
before using a catalog row in a new Agent or config. A non-selectable choice returns
|
|
52
52
|
`409 model_not_selectable`; `expired_fallback_to` names the reviewed replacement when present.
|
|
53
53
|
|
|
54
|
+
To set a default thinking level, read the levels a model supports from `listModels()` and
|
|
55
|
+
choose one of them in `model.thinking` (`'off' | 'low' | 'medium' | 'high' | 'max'`). Omit it to
|
|
56
|
+
use the platform default; send `thinking: null` in an `updateAgent` call to clear it. A schedule's
|
|
57
|
+
`agentTurn` payload accepts the same `thinking` values; on `updateSchedule`, omitting it keeps the
|
|
58
|
+
stored value and `null` clears it.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// `models` and `primary` come from the listModels() example above.
|
|
62
|
+
const info = models.find((m) => m.model === primary)
|
|
63
|
+
const wanted: ThinkingLevel = 'high'
|
|
64
|
+
|
|
65
|
+
// Set the level only when the model supports it; otherwise leave `thinking` out and the
|
|
66
|
+
// Agent follows the platform default.
|
|
67
|
+
const model: AgentResource['model'] = { primary }
|
|
68
|
+
if (info?.thinking?.levels.includes(wanted)) model.thinking = wanted
|
|
69
|
+
|
|
70
|
+
const tuned = await zc.createAgent({ resource: { name: 'deep-research-agent', model } })
|
|
71
|
+
|
|
72
|
+
// Clear it later. `model.thinking` merges, so `primary` is not needed. `satisfies AgentUpdate`
|
|
73
|
+
// makes the compiler reject an unknown level (updateAgent itself accepts any object).
|
|
74
|
+
await zc.updateAgent(tuned.agent_id, { model: { thinking: null } } satisfies AgentUpdate)
|
|
75
|
+
```
|
|
76
|
+
|
|
54
77
|
Agent resources also accept `userTimezone`, a named IANA timezone used for prompt and message
|
|
55
78
|
time context, and `include_global_skills: false` to disable automatic global Skills while keeping
|
|
56
79
|
explicitly listed Skills. An explicit `skills: []` also opts out. Schedule timezones are configured
|
|
@@ -138,7 +161,7 @@ for await (const ev of zc.streamEvents(agent.agent_id, session.session_id)) {
|
|
|
138
161
|
Three things worth knowing before you write that loop:
|
|
139
162
|
|
|
140
163
|
- **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.
|
|
141
|
-
- **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.
|
|
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 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.
|
|
142
165
|
- **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.
|
|
143
166
|
|
|
144
167
|
For API sessions, `user.message` can carry `actor: { ref: 'customer-42' }`, including in
|
|
@@ -448,10 +471,15 @@ records to learn the result. SDK writes do not retry automatically.
|
|
|
448
471
|
`createSession` accepts `runtime_mode: 'active'` to pin the current active configuration at
|
|
449
472
|
creation. Omit it to resolve active configuration on later turns. `idle_compaction` preserves
|
|
450
473
|
false, null and omission. MCP tool overrides accept `requireConfirmation?: boolean`.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
474
|
+
|
|
475
|
+
Pass an optional positive `expected_config_version` in the `updateAgent` sections object to
|
|
476
|
+
check the current configuration version atomically with the update. Read it from
|
|
477
|
+
`agent.status?.config_version ?? agent.config_version`. A mismatch returns
|
|
478
|
+
`409 active_config_changed` without changing the configuration. Re-read and recompute the
|
|
479
|
+
intended change before retrying; the precondition itself is not stored in `declared`.
|
|
480
|
+
Omitting it keeps last-write-wins behavior. Ownership-only changes do not increment the
|
|
481
|
+
configuration version. The separate `upgradeSystemPrompt` method requires its version
|
|
482
|
+
precondition and uses `409 config_version_changed`.
|
|
455
483
|
|
|
456
484
|
## Current production behavior
|
|
457
485
|
|
package/dist/client.d.ts
CHANGED
|
@@ -118,6 +118,12 @@ export interface Ownership {
|
|
|
118
118
|
project_id?: string | null;
|
|
119
119
|
visibility?: 'private' | 'project';
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Thinking level, in ascending order of reasoning. A model resolves a level it does not list in
|
|
123
|
+
* `ModelInfo.thinking.levels` to the nearest listed one (ties go up), so `off` on a model that
|
|
124
|
+
* cannot stop thinking becomes its lowest level.
|
|
125
|
+
*/
|
|
126
|
+
export type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'max';
|
|
121
127
|
export interface ModelInfo {
|
|
122
128
|
model: string;
|
|
123
129
|
display_name?: string;
|
|
@@ -132,6 +138,15 @@ export interface ModelInfo {
|
|
|
132
138
|
selectable?: boolean;
|
|
133
139
|
retire_not_before?: string | null;
|
|
134
140
|
default_for?: string[];
|
|
141
|
+
/**
|
|
142
|
+
* Thinking levels that take effect as named on this model, ascending; any other
|
|
143
|
+
* {@link ThinkingLevel} resolves to the nearest listed one. `default` is what the platform
|
|
144
|
+
* applies when an Agent sets none. Optional so older servers that omit it still type-check.
|
|
145
|
+
*/
|
|
146
|
+
thinking?: {
|
|
147
|
+
default: ThinkingLevel;
|
|
148
|
+
levels: ThinkingLevel[];
|
|
149
|
+
};
|
|
135
150
|
[k: string]: unknown;
|
|
136
151
|
}
|
|
137
152
|
/** Approval behavior for one MCP server or one of its tools. */
|
|
@@ -281,6 +296,21 @@ export interface OutcomeConfig {
|
|
|
281
296
|
/** Defaults to `after_satisfied` at run time: an unsatisfied result stays unpublished. */
|
|
282
297
|
publish?: 'after_satisfied' | 'always' | 'never';
|
|
283
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Partial `model` section for {@link ZooworkClient.updateAgent}. `model.thinking` merges on its
|
|
301
|
+
* own, so `{ thinking: null }` alone clears the declared level; `primary` is not required.
|
|
302
|
+
*/
|
|
303
|
+
export type AgentModelUpdate = Partial<NonNullable<AgentResource['model']>>;
|
|
304
|
+
/**
|
|
305
|
+
* Opt-in typing for the `sections` argument of `updateAgent`. `updateAgent` itself still takes
|
|
306
|
+
* `Record<string, unknown>` so existing callers compile unchanged; write
|
|
307
|
+
* `const update = { model: { thinking: null } } satisfies AgentUpdate` (or annotate with this
|
|
308
|
+
* type) to have the compiler check `model` and reject an unknown thinking level.
|
|
309
|
+
*/
|
|
310
|
+
export type AgentUpdate = {
|
|
311
|
+
model?: AgentModelUpdate;
|
|
312
|
+
[section: string]: unknown;
|
|
313
|
+
};
|
|
284
314
|
export interface AgentResource {
|
|
285
315
|
name: string;
|
|
286
316
|
/** Named IANA timezone used in prompt context and message timestamps, e.g. `Asia/Shanghai`. */
|
|
@@ -290,11 +320,16 @@ export interface AgentResource {
|
|
|
290
320
|
* defaults can rotate; call `listModels()` and set `primary` explicitly for deterministic
|
|
291
321
|
* provisioning. `max_tokens` caps output tokens per model request; omit only that field to
|
|
292
322
|
* use the platform token limit.
|
|
323
|
+
*
|
|
324
|
+
* `thinking` is the Agent's default thinking level. Omit it to use the platform default for
|
|
325
|
+
* the model; send `null` in an update (PUT) to clear a previously declared value. Check
|
|
326
|
+
* `ModelInfo.thinking.levels` from `listModels()` for the levels a model accepts.
|
|
293
327
|
*/
|
|
294
328
|
model?: {
|
|
295
329
|
primary: string;
|
|
296
330
|
input?: string[];
|
|
297
331
|
max_tokens?: number;
|
|
332
|
+
thinking?: ThinkingLevel | null;
|
|
298
333
|
};
|
|
299
334
|
persona?: {
|
|
300
335
|
docs: {
|
|
@@ -848,6 +883,43 @@ export interface SessionEventPage {
|
|
|
848
883
|
hasMore?: boolean;
|
|
849
884
|
nextCursor?: string | null;
|
|
850
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
|
+
}
|
|
851
923
|
/**
|
|
852
924
|
* When a schedule fires: cron expression, everyMs interval in milliseconds (optional
|
|
853
925
|
* anchorMs), or an ISO instant in at. The everyMs contract is source-reviewed; it was
|
|
@@ -884,6 +956,16 @@ export interface SchedulePayload {
|
|
|
884
956
|
* 2026-08-14 (201, read back verbatim). See {@link OutcomeConfig}.
|
|
885
957
|
*/
|
|
886
958
|
outcome?: OutcomeConfig | null;
|
|
959
|
+
/**
|
|
960
|
+
* Thinking level for THIS job's turns, outranking the Agent's `model.thinking`. Only an
|
|
961
|
+
* `agentTurn` payload honours it. On an update it has three states: omit it (or send an empty or
|
|
962
|
+
* whitespace-only string) to keep the stored value, send `null` to clear it so the job follows
|
|
963
|
+
* the Agent again, or send a level to set it. The server trims and lowercases a new value and
|
|
964
|
+
* normalizes legacy spellings (`xhigh`, `minimal`, `adaptive` become `max`, `low`, `medium`);
|
|
965
|
+
* a stored value written back unchanged stays as is, so a job stored before this change may
|
|
966
|
+
* still read back a legacy spelling.
|
|
967
|
+
*/
|
|
968
|
+
thinking?: ThinkingLevel | null;
|
|
887
969
|
[k: string]: unknown;
|
|
888
970
|
}
|
|
889
971
|
export interface ScheduleInput {
|
|
@@ -1361,8 +1443,10 @@ export interface ZooworkClient extends DeveloperApi {
|
|
|
1361
1443
|
listAgents(opts?: AgentListParams): AgentPagePromise;
|
|
1362
1444
|
getAgent(agentId: string): Promise<AgentRecord>;
|
|
1363
1445
|
/** PUT declared sections. Ownership-only changes do not bump config_version.
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
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. */
|
|
1366
1450
|
updateAgent(agentId: string, sections: Record<string, unknown>): Promise<AgentRecord>;
|
|
1367
1451
|
/**
|
|
1368
1452
|
* Soft delete: the agent stops resolving on the API, but this is not a resource purge.
|
|
@@ -1682,53 +1766,55 @@ export interface ZooworkClient extends DeveloperApi {
|
|
|
1682
1766
|
* (`user.message`, …) alongside engine events. `limit` defaults to 100 and is capped at 500;
|
|
1683
1767
|
* the page's pagination fields are dropped, so use {@link ZooworkClient.listAllEvents}, or
|
|
1684
1768
|
* {@link ZooworkClient.listEventsPage} to page by hand.
|
|
1685
|
-
* Passing `after` selects the deprecated engine-only lane — old cursors only.
|
|
1686
1769
|
*/
|
|
1687
|
-
listEvents(agentId: string, sessionId: string, opts?:
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
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[]>;
|
|
1693
1776
|
/**
|
|
1694
1777
|
* The page-returning primitive under `listEvents`: same options, plus the page's `hasMore`
|
|
1695
1778
|
* and `nextCursor` (absent on servers without cursor pagination). Feed `nextCursor` back as
|
|
1696
|
-
* `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`.
|
|
1697
1781
|
*/
|
|
1698
|
-
listEventsPage(agentId: string, sessionId: string, opts?:
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
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>;
|
|
1704
1788
|
/**
|
|
1705
1789
|
* Every durable event: follows the server's `next_cursor` until `has_more` is false, and
|
|
1706
1790
|
* falls back to walking `after` against servers without cursor pagination (that walk stops
|
|
1707
1791
|
* when a page fails to advance, so a server that ignored `after` cannot spin it forever).
|
|
1708
1792
|
*
|
|
1709
|
-
* `
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
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.
|
|
1712
1797
|
*/
|
|
1713
|
-
listAllEvents(agentId: string, sessionId: string, opts?:
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
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[]>;
|
|
1718
1804
|
/**
|
|
1719
1805
|
* Durable event stream with server-side resume.
|
|
1720
1806
|
*
|
|
1721
1807
|
* The stream is SESSION-scoped and unbounded: it does NOT close when a turn ends, and the
|
|
1722
1808
|
* server closes it on idle. Detect turn end with `isRunFinished`, and resume by passing the
|
|
1723
|
-
* last event's `cursor
|
|
1724
|
-
*
|
|
1725
|
-
* 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.
|
|
1726
1811
|
*/
|
|
1727
|
-
streamEvents(agentId: string, sessionId: string, opts?:
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
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>;
|
|
1732
1818
|
/** Pending calls only. Any other status is rejected by the API. */
|
|
1733
1819
|
listCustomToolCalls(agentId: string, opts?: {
|
|
1734
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
|
|
624
|
-
listEventsPage
|
|
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
|
|
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
|
|
676
|
+
const { events: page } = await listEventsPage(agentId, sessionId, {
|
|
671
677
|
after: cursor,
|
|
672
678
|
...(opts.types ? { types: opts.types } : {}),
|
|
673
679
|
limit: pageSize,
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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,4 +1,4 @@
|
|
|
1
|
-
export { createZooworkClient, DEFAULT_BASE_URL, ZooworkError, type ZooworkClient, type ZooworkConfig, type ZooworkAuth, type Ownership, type ModelInfo, type AgentResource, 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';
|