notte-sdk 1.9.0 → 1.9.2
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 +93 -0
- package/dist/index.d.mts +1143 -262
- package/dist/index.d.ts +1143 -262
- package/dist/index.js +814 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +788 -108
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +21 -0
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +21 -0
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +21 -0
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +21 -0
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -24,6 +24,40 @@ npm pack --dry-run
|
|
|
24
24
|
To update the generated client, run `npm run generate:staging`, review the diff,
|
|
25
25
|
and commit it. `npm run check:staging` checks for drift without editing your files.
|
|
26
26
|
|
|
27
|
+
### Generated resource methods
|
|
28
|
+
|
|
29
|
+
The SDK generates client-bound methods for `sessions`, `agents`, `functions`,
|
|
30
|
+
`vaults`, `personas`, and `profiles` from the checked-in OpenAPI-derived types
|
|
31
|
+
and operations. No per-call client or `throwOnError` is needed:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const client = new NotteClient();
|
|
35
|
+
await client.sessions.stop(sessionId);
|
|
36
|
+
const vault = await client.vaults.create({ name: 'default' });
|
|
37
|
+
const copy = await client.functions.fork(functionId);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Arguments are path IDs in URL order, then the request body (if any), query
|
|
41
|
+
parameters (if any), and optional `{ signal }` cancellation options. For example,
|
|
42
|
+
`client.sessions.stop(sessionId, { close_reason: 'manual' }, { signal })`.
|
|
43
|
+
Operations with required request headers require a final options object, for
|
|
44
|
+
example `client.sessions.createPayment(sessionId, body, undefined, { headers: { 'idempotency-key': key } })`.
|
|
45
|
+
Keep the same idempotency key when retrying the same payment request. The SDK
|
|
46
|
+
binds `x-notte-api-key` automatically; callers cannot override it through typed headers.
|
|
47
|
+
Methods return the API response body and throw the client's typed API errors.
|
|
48
|
+
The five existing `list()` methods still return arrays for compatibility;
|
|
49
|
+
the newly added `profiles.list()` returns the API pagination response.
|
|
50
|
+
|
|
51
|
+
These are API operations, not lifecycle helpers: they do not poll for completion,
|
|
52
|
+
decrypt credentials, or manage cleanup. Continue using `Session().use()`,
|
|
53
|
+
`Agent().run()`, `Function().run()`, and `Vault()` for those behaviors. Existing
|
|
54
|
+
standalone generated exports remain supported.
|
|
55
|
+
|
|
56
|
+
`npm run generate` refreshes this layer too. Use `npm run resources:generate`
|
|
57
|
+
to regenerate it offline, `npm run resources:check` to detect stale output, and
|
|
58
|
+
`npm run resources:test` for generator regressions. Method-name aliases live in
|
|
59
|
+
the generator; request shapes and routes come from generated OpenAPI types.
|
|
60
|
+
|
|
27
61
|
For the isolated live test, set `NOTTE_API_KEY` and
|
|
28
62
|
`NOTTE_API_URL=https://us-staging.notte.cc`, then run:
|
|
29
63
|
|
|
@@ -884,6 +918,14 @@ try {
|
|
|
884
918
|
|
|
885
919
|
### Timeouts and retries
|
|
886
920
|
|
|
921
|
+
CAPTCHA solving has a separate `captchaTimeoutSeconds` budget (default 180).
|
|
922
|
+
`session.execute()` polls pending solves using requests of at most 10 seconds,
|
|
923
|
+
then resumes an ordinary action only when the backend confirms it did not execute.
|
|
924
|
+
Actions that already ran are never replayed. Navigation, closure, provider failure,
|
|
925
|
+
and deadline expiry preserve the normal `raiseOnFailure` behavior. Ordinary HTTP
|
|
926
|
+
transport failures are not automatically retried. Deploy backend CAPTCHA polling
|
|
927
|
+
support before upgrading the SDK.
|
|
928
|
+
|
|
887
929
|
The client applies a per-request timeout (`timeoutMs`, default 60 000 ms; `0`
|
|
888
930
|
disables it) through response-body consumption and rejects with `NotteTimeoutError`
|
|
889
931
|
when it elapses. Explicit streams use the caller's signal for body cancellation;
|
|
@@ -1100,3 +1142,54 @@ For issues and questions:
|
|
|
1100
1142
|
- GitHub Issues: [Report issues](https://github.com/nottelabs/notte/issues)
|
|
1101
1143
|
- Documentation: [docs.notte.cc](https://docs.notte.cc)
|
|
1102
1144
|
- Python SDK: [notte-sdk](https://pypi.org/project/notte-sdk/)
|
|
1145
|
+
|
|
1146
|
+
## Managed authentication
|
|
1147
|
+
|
|
1148
|
+
Use existing connection IDs with a session. `start()` waits for authentication by
|
|
1149
|
+
default, and `.use()` always invokes its callback only after the session is ready:
|
|
1150
|
+
|
|
1151
|
+
```typescript
|
|
1152
|
+
const session = client.Session({ auth_ids: ["<connection-id>"], auth_retry: 2 });
|
|
1153
|
+
await session.use(async (ready) => {
|
|
1154
|
+
await ready.execute({ type: "goto", url: "https://example.com" });
|
|
1155
|
+
});
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
For a nonblocking start, wait explicitly before browser actions or CDP access:
|
|
1159
|
+
|
|
1160
|
+
```typescript
|
|
1161
|
+
const abortController = new AbortController();
|
|
1162
|
+
const session = client.Session({ auth_ids: ["<connection-id>"] });
|
|
1163
|
+
await session.start({ wait_for_authentication: false });
|
|
1164
|
+
try {
|
|
1165
|
+
await session.waitForAuth({ timeoutMs: 615_000, signal: abortController.signal });
|
|
1166
|
+
await session.execute({ type: "goto", url: "https://example.com" });
|
|
1167
|
+
} finally {
|
|
1168
|
+
await session.stop();
|
|
1169
|
+
}
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
Waiting polls session readiness through short requests. It never restarts the
|
|
1173
|
+
session or submits another login. `auth_retry` controls server-side login retries
|
|
1174
|
+
(0 to 2) and is omitted from requests without `auth_ids`. A failed or cancelled
|
|
1175
|
+
startup wait closes the created session. A standalone `waitForAuth()` leaves
|
|
1176
|
+
cleanup to the caller.
|
|
1177
|
+
|
|
1178
|
+
Connection operations are available through `client.managedAuth`:
|
|
1179
|
+
|
|
1180
|
+
```typescript
|
|
1181
|
+
const check = await client.managedAuth.checkConnection("<connection-id>");
|
|
1182
|
+
// checkConnection only verifies; refreshConnection can log in if needed.
|
|
1183
|
+
const operation = await client.managedAuth.refreshConnection("<connection-id>", {
|
|
1184
|
+
wait: false,
|
|
1185
|
+
auth_retry: 2,
|
|
1186
|
+
});
|
|
1187
|
+
const completed = await client.managedAuth.waitForAuth(operation);
|
|
1188
|
+
// To explicitly request a new login:
|
|
1189
|
+
await client.managedAuth.reauthenticateConnection("<connection-id>");
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
Refresh and reauthentication wait by default. Use `getOperation(operation.id)`
|
|
1193
|
+
for individual status reads. Cancelling an operation wait does not cancel the
|
|
1194
|
+
server operation. An HTTP 409 remains an ownership conflict and is not retried.
|
|
1195
|
+
These helpers require a backend with the managed-auth lifecycle endpoints.
|