@qoniai/qoni 0.4.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 ADDED
@@ -0,0 +1,232 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@qoniai/qoni` are documented in this file.
4
+
5
+ This project follows semantic versioning. Before `1.0.0`, minor versions may
6
+ include SDK API changes, while patch versions are reserved for backward
7
+ compatible fixes.
8
+
9
+ ## Unreleased
10
+
11
+ ### Added
12
+
13
+ - `RunHandle.events()` and `wait()` accept `onWireEvent` and `onReconnect`
14
+ observability callbacks. The former receives every original SSE frame before
15
+ semantic filtering; the latter exposes resumable-stream retry details.
16
+ - The focused Do Anything live E2E gate records the complete Agent/tool trace,
17
+ Browser Harness script source and execution, screenshots, recording, final
18
+ result, reconnects, and report-ready latency/token/cost metrics under the
19
+ ignored local evidence directory.
20
+
21
+ ## 0.4.0 - 2026-08-18
22
+
23
+ ### Breaking
24
+
25
+ - Rename the package from its previous product name to `@qoniai/qoni`.
26
+ - Rename the primary constructor and all branded exports to `QoniAgentKit`,
27
+ `Qoni`, and the corresponding `Qoni*` types, constants, and error classes.
28
+ - Rename the product namespace to `client.qoni` and environment variables to
29
+ `QONI_*`. The current server wire contract remains unchanged: SDK gateway
30
+ routes stay under `/api/v3/eak/*`, delegation tokens retain
31
+ `eak_delegation_token` and `eak_tenant_id`, and backend `eak.*` error codes
32
+ pass through as-is.
33
+ - Rename the bundled integration skill to `qoni-sdk` and update repository,
34
+ package publishing, smoke-test, and runtime-discovery metadata.
35
+
36
+ ## 0.3.4 - 2026-06-18
37
+
38
+ ### Fixed
39
+
40
+ - `refine()` no longer accepts `prompt`. It mapped to `patch.intent`, but the
41
+ backend `RefinePatch` is `extra="forbid"` with no `intent` field, so
42
+ `refine({ prompt })` 422'd with `validation_error` (while `schedule` /
43
+ `targetUrls` / etc. worked). The monitor's natural-language intent drives
44
+ URL/schema/DSL generation and is deliberately not refinable — create a new
45
+ monitor to change it. Removed `prompt` from `MonitorRefinePatch`; README and
46
+ types updated to match.
47
+
48
+ ## 0.3.3 - 2026-06-18
49
+
50
+ ### Changed
51
+
52
+ - `MonitorHandle.update(input)` is replaced by intent-revealing methods that
53
+ match the backend's monitor FSM: `pause()`, `resume()`, and `refine(patch)`.
54
+ The old passthrough sent a body with no `action` discriminator, so the
55
+ backend always rejected it with `validation_error` — it never worked as
56
+ documented, so no functioning code relied on it. `refine()` takes a
57
+ camelCase `MonitorRefinePatch` and normalizes `schedule`
58
+ (`{ kind: "cron", expr }` / `{ kind: "interval", intervalSeconds }`).
59
+
60
+ ### Fixed
61
+
62
+ - `RunResult.terminalReason` is now populated from the terminal `done` event
63
+ when the run-detail envelope omits it (previously `undefined` even though
64
+ the stream delivered the reason).
65
+
66
+ ### Documentation
67
+
68
+ - Track example: document the `pending_clarification` → `active` lifecycle —
69
+ `runNow()` / `refine()` require `active`, so a freshly created monitor must
70
+ reach `active` first (the old `create()` → `runNow()` snippet raced it).
71
+ - Replace the wrong `update({ schedule: "0 9 * * *" })` with
72
+ `refine({ schedule: { kind: "cron", expr: "0 9 * * *" } })`.
73
+
74
+ ## 0.3.2 - 2026-06-18
75
+
76
+ ### Fixed
77
+
78
+ - `delegateToken` in silent mode now fails locally with `QoniValidationError`
79
+ when no `user` / `userId` is given, instead of letting an un-attributed
80
+ request reach the gateway and surface as a confusing signing error. The TS
81
+ overloads already enforced this; the guard covers plain-JS callers.
82
+
83
+ ### Documentation
84
+
85
+ README pass driven by an external review:
86
+
87
+ - Document all exported error classes (`QoniAuthError`, `QoniTokenExpiredError`,
88
+ `QoniUpstreamError`, `QoniDelegationRequiredError`, …), not just three; note
89
+ that the SDK does not auto-retry and `retryable` is yours to act on.
90
+ - Clarify that `client.timeoutMs` bounds individual requests, not the live
91
+ run stream — long runs stream fine; bound waiting with `wait({ timeoutMs })`.
92
+ - Spell out the `delegateToken` input shape (silent requires `user: { id }`;
93
+ interactive needs none).
94
+ - Point at the exported constants (`InteractionTypes`, `InteractionStatuses`,
95
+ `ActionKinds`, `QoniScopes`, `QoniProductScopes`) instead of bare literals.
96
+ - Document the `RunResult` / `Artifact` shapes returned by `wait()`.
97
+ - Note the dual ESM/CommonJS builds; remove stray Chinese from the English README.
98
+
99
+ ## 0.3.1 - 2026-06-18
100
+
101
+ Documentation-only release; no SDK code changes.
102
+
103
+ ### Fixed
104
+
105
+ - README delegation examples passed `user: { subject: userId }`, but `UserRef`
106
+ requires `id` and the SDK only reads `user.id` — as written the silent
107
+ delegation throws `eak.delegation.user_id_required`. Corrected to
108
+ `user: { id: userId }` in both README.md and README.zh-CN.md.
109
+ - Replaced non-runnable placeholder example prompts (an undefined "customer
110
+ website", a literal `…`, a fake `example.com/pricing`) with concrete,
111
+ live-verified prompts so copy-pasted examples actually execute.
112
+
113
+ ## 0.3.0 - 2026-06-18
114
+
115
+ Semantic-layer public surface per the frozen contract. **Breaking** — the
116
+ WebAgent product namespaces are reorganized around handles; the 1:1 wire
117
+ methods moved (no compatibility aliases).
118
+
119
+ ### Breaking
120
+
121
+ - `doAnything.run` / `webSearch.run` / `deepResearch.run` now return a
122
+ `RunHandle` (`id`, `sessionRef`, `status()`, `events()`, `wait()`,
123
+ `respond()`, idempotent `cancel()`) instead of a wire envelope.
124
+ `attach(runId, { token })` reconnects to an existing run (doAnything
125
+ additionally needs `session`). `doAnything.runAndWait` is replaced by
126
+ `run()` + `wait()`.
127
+ - `track.createMonitor/getMonitor/updateMonitor/deleteMonitor/runNow/events`
128
+ are replaced by `track.create` / `track.attach` returning a `MonitorHandle`
129
+ (`get()`, `update()`, `runNow()`, `events()`, `respond()`, `runs()`,
130
+ `run(runId)`, `delete()`). Monitor HITL answers (`respond`) and tick-run
131
+ read views (`runs` / `run`) are newly exposed.
132
+ - The 1:1 wire-level methods moved to `qoni.<product>.api.*` (e.g.
133
+ `qoni.doAnything.api.createSession`, `qoni.deepResearch.api.followUp`); their
134
+ shapes may evolve with the API and are no longer the documented mainline.
135
+ - Handle event streams yield semantic `RunEvent`s (`type` / `runId` / `at` /
136
+ `isTerminal` / camelCase `data` / `raw`), end automatically at the terminal
137
+ event, and decode screenshot data URIs to `event.image.bytes`. The
138
+ `capture: { screenshots, videoFrames }` switch replaces hand-built
139
+ `stream.events` subscriptions; core events are always subscribed.
140
+ - `delegateToken`: `agent` is optional (default `"sdk"`), `products` sugar
141
+ expands to per-product scope sets, and scope strings are validated locally —
142
+ malformed scopes throw `QoniValidationError` before any request.
143
+
144
+ ### Added
145
+
146
+ - `result.artifacts` on `wait()` results — deepResearch deliverables with lazy
147
+ `content()` byte downloads; empty for other products.
148
+ - Server permission errors now append the known scope set to the message.
149
+
150
+ ## 0.2.0 - 2026-06-10
151
+
152
+ Run-event handling now matches the live WebAgent backend, plus resilient
153
+ streaming. **Breaking** — see below.
154
+
155
+ ### Breaking
156
+
157
+ - `QoniEventTypes` now holds the real backend wire event names (`run.*`, e.g.
158
+ `RUN_COMPLETED = "run.completed"`, `RUN_ACTION_STARTED`, `RUN_INPUT_REQUEST`,
159
+ `RUN_BROWSER_LIVE_URL_CHANGED`), replacing the previous placeholder constants
160
+ (`DO_ANYTHING_FINAL = "final"`, `DO_ANYTHING_ACTION = "action"`, …) that never
161
+ matched a real run stream. Match `event.event` against the new constants;
162
+ `RUN_COMPLETED` is the terminal event.
163
+
164
+ ### Fixed
165
+
166
+ - `doAnything.events()` (and the other product `events()` iterators) now surface
167
+ the wire event type on `event.event`. Backend run frames carry no SSE `event:`
168
+ line — the type lives in the envelope's `type` field — so `event.event` was
169
+ previously always `undefined`. The envelope still rides on `event.data`
170
+ (`event.data.data` is the payload; `event.data.task_id` identifies the run).
171
+ - `doAnything.run()` returns a typed `DoAnythingRunResult` with canonical
172
+ snake_case `run_id` / `session_id` (no more `id` / `sessionId` guessing).
173
+
174
+ ### Added
175
+
176
+ - Automatic SSE reconnect: `events()` resumes a dropped stream from the last
177
+ event id (network / 5xx). Configure with the `sseMaxRetries` client option
178
+ (default 5, `0` disables). User aborts and terminal 4xx are never retried.
179
+ Each reconnect re-resolves the product token, so a long stream survives token
180
+ expiry — a `401` on reconnect is treated as retryable and recovered with a
181
+ fresh token instead of throwing.
182
+ - `doAnything.events({ onlyTopLevel: true })` drops internal sub-run events
183
+ (matched on `event.data.task_id`) and yields only the addressed run's events.
184
+ - `doAnything.runAndWait` gains an `onCostUpdate` hook (live `run.cost_update`),
185
+ filters to the top-level run, and settles from the `getRun` envelope so
186
+ `result.raw` always carries `total_cost_usd` / `step_count` / token counts
187
+ (the `run.completed` event payload omits them).
188
+ - `doAnything.runAndWait({ instruction, onAction, onScreenshot, onInputRequest,
189
+ timeoutMs, signal, ... })` — high-level helper that starts a run, drives its
190
+ event stream to a terminal state, and resolves a settled
191
+ `{ status, output, terminalReason, isTaskSuccessful, runId, sessionId }`.
192
+ Falls back to `getRun` if the stream closes without a terminal event.
193
+ - `qoni.resolveAnyBoundUser()` — returns a real user id from the credential-bound
194
+ GenAuth userpool, for demos / smoke tests that need a `userId` for silent
195
+ `delegateToken` without hardcoding one.
196
+ - Onboarding hints: errors for `eak.delegation.user_not_bound` and
197
+ `eak.genauth.userpool_binding_missing` now append a one-line, actionable hint
198
+ to the message (e.g. pointing at `resolveAnyBoundUser` / `currentUser`).
199
+ - `QoniError.code` is now typed as `QoniErrorCode` — a union of the known SDK /
200
+ backend codes plus `(string & {})` — so you get literal autocomplete and can
201
+ write an exhaustive `switch (err.code)` while still tolerating new backend
202
+ codes. Exported as `QoniErrorCode`.
203
+
204
+ ## 0.1.0 - 2026-06-02
205
+
206
+ Initial public release of `@qoniai/qoni`.
207
+
208
+ ### What ships
209
+
210
+ - Server-side `QoniAgentKit` constructor for Qoni Agent delegation and product
211
+ runtime calls.
212
+ - Runtime service discovery from the Qoni Console gateway through
213
+ `GET /api/v3/eak/runtime-config`.
214
+ - One-step `delegateToken` flow for binding a GenAuth user, Agent identity,
215
+ scope list, expiry, and audit metadata.
216
+ - Automatic product-token exchange before GUMem and WebAgent runtime requests,
217
+ so integrations can pass the delegation token returned by `delegateToken`.
218
+ - Capability namespaces for `qoni`, `genauth`, `gumem`, `webSearch`,
219
+ `doAnything`, and `track`.
220
+ - Typed SDK errors with request, trace, audit, retry, service, and HTTP status
221
+ metadata.
222
+ - Exported scope constants, scope bundles, and event constants for common Agent
223
+ workflows.
224
+ - English and Chinese README files, open-source repository metadata, examples,
225
+ and readiness checks.
226
+
227
+ ### Compatibility
228
+
229
+ - `Qoni` remains available as a short constructor alias.
230
+ - `delegateAgent` and `completeDelegateAgent` remain available as deprecated
231
+ aliases for older integrations, but new integrations should use
232
+ `delegateToken`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eazo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.