@naturali/sdk 0.40.1 → 0.42.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/dist/index.mjs CHANGED
@@ -1343,7 +1343,11 @@ var Knowledge = class {
1343
1343
  /**
1344
1344
  * Create a document
1345
1345
  *
1346
- * Add an inline-text document to the collection. The platform ingests the content (chunk + embed) and records the document's ingestion status. File upload (PDF/binary) is a deliberate follow-up.
1346
+ * Add a document to the collection, from **inline text** (`content`) or from an **uploaded file** (`file`, base64, plus `content_type` and `filename`) exactly one of the two.
1347
+ *
1348
+ * `application/pdf`, `text/plain` and `text/markdown` are extracted natively. Any other media type needs a converter (`POST /v1/projects/{project_id}/knowledge/converters`) registered for it in the project; without one the request is rejected with `unsupported_content_type` and no document is created.
1349
+ *
1350
+ * Ingestion (extract → chunk → embed) runs in the background: the document comes back `pending` and becomes `indexed` or `failed`, which is announced by the `knowledge.document_ingested` / `knowledge.ingest_failed` webhook events.
1347
1351
  *
1348
1352
  */
1349
1353
  static createKnowledgeDocument(options) {
@@ -1388,6 +1392,86 @@ var Knowledge = class {
1388
1392
  ...options
1389
1393
  });
1390
1394
  }
1395
+ /**
1396
+ * List converters
1397
+ *
1398
+ * Lists the media converters registered in the project.
1399
+ */
1400
+ static listKnowledgeConverters(options) {
1401
+ return (options.client ?? client).get({
1402
+ url: "/v1/projects/{project_id}/knowledge/converters",
1403
+ ...options
1404
+ });
1405
+ }
1406
+ /**
1407
+ * Create a converter
1408
+ *
1409
+ * Register a converter for a media type the platform cannot extract natively, so files of that type become ingestable documents like any other. A converter maps a `content_type` glob (`image*`, `audio/mpeg`, …) onto one of two workers:
1410
+ *
1411
+ * - an **agent** (`agent_id`) — the file is handed to a
1412
+ * multimodal model with a fixed "extract all the text" instruction and
1413
+ * its answer becomes the document text. The shortest path for images
1414
+ * and scanned PDFs; nothing to map.
1415
+ *
1416
+ * - a **tool** (`tool_id`) — the file is passed to an
1417
+ * `http` tool as `{ content_type, filename, data_base64 }`, and
1418
+ * whatever string the tool returns becomes the document text. The path
1419
+ * for dedicated non-chat APIs (speech-to-text, a specialist OCR
1420
+ * engine); use the tool's `execute.body_mode: multipart` for
1421
+ * form-data endpoints and its `output_mapping` to reduce a JSON
1422
+ * response to the bare string.
1423
+ *
1424
+ *
1425
+ * Exactly one of `agent_id` / `tool_id`, and one converter per `content_type` in a project.
1426
+ *
1427
+ */
1428
+ static createKnowledgeConverter(options) {
1429
+ return (options.client ?? client).post({
1430
+ url: "/v1/projects/{project_id}/knowledge/converters",
1431
+ ...options,
1432
+ headers: {
1433
+ "Content-Type": "application/json",
1434
+ ...options.headers
1435
+ }
1436
+ });
1437
+ }
1438
+ /**
1439
+ * Delete a converter
1440
+ *
1441
+ * Removes the converter. Documents already ingested through it are untouched; new files of that media type stop being ingestable until another converter covers them.
1442
+ *
1443
+ */
1444
+ static deleteKnowledgeConverter(options) {
1445
+ return (options.client ?? client).delete({
1446
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1447
+ ...options
1448
+ });
1449
+ }
1450
+ /**
1451
+ * Get a converter
1452
+ */
1453
+ static getKnowledgeConverter(options) {
1454
+ return (options.client ?? client).get({
1455
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1456
+ ...options
1457
+ });
1458
+ }
1459
+ /**
1460
+ * Update a converter
1461
+ *
1462
+ * Change the worker or the chunking defaults. At least one field is required; `agent_id` and `tool_id` stay mutually exclusive, so setting one clears the other.
1463
+ *
1464
+ */
1465
+ static updateKnowledgeConverter(options) {
1466
+ return (options.client ?? client).patch({
1467
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1468
+ ...options,
1469
+ headers: {
1470
+ "Content-Type": "application/json",
1471
+ ...options.headers
1472
+ }
1473
+ });
1474
+ }
1391
1475
  };
1392
1476
  var Models = class {
1393
1477
  /**
@@ -1832,6 +1916,126 @@ var Traces = class {
1832
1916
  });
1833
1917
  }
1834
1918
  };
1919
+ var Webhooks = class {
1920
+ /**
1921
+ * List webhooks
1922
+ *
1923
+ * The endpoints registered in the project, newest first.
1924
+ */
1925
+ static listWebhooks(options) {
1926
+ return (options.client ?? client).get({
1927
+ url: "/v1/projects/{project_id}/webhooks",
1928
+ ...options
1929
+ });
1930
+ }
1931
+ /**
1932
+ * Create a webhook
1933
+ *
1934
+ * Register an endpoint and subscribe it to one or more event types.
1935
+ * The response carries `secret` — the signing key, in plaintext. **This is the only time it is returned.** Store it where your receiver can read it; if you lose it, rotate rather than re-create, so the endpoint keeps its delivery history.
1936
+ * Returns `501` on a deployment with no credential-sealing key configured, since the secret could not then be stored safely.
1937
+ *
1938
+ */
1939
+ static createWebhook(options) {
1940
+ return (options.client ?? client).post({
1941
+ url: "/v1/projects/{project_id}/webhooks",
1942
+ ...options,
1943
+ headers: {
1944
+ "Content-Type": "application/json",
1945
+ ...options.headers
1946
+ }
1947
+ });
1948
+ }
1949
+ /**
1950
+ * Delete a webhook
1951
+ *
1952
+ * Removes the endpoint and its delivery records. To stop deliveries while keeping the audit trail, `PATCH` it to `active: false` instead.
1953
+ *
1954
+ */
1955
+ static deleteWebhook(options) {
1956
+ return (options.client ?? client).delete({
1957
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1958
+ ...options
1959
+ });
1960
+ }
1961
+ /**
1962
+ * Get a webhook
1963
+ */
1964
+ static getWebhook(options) {
1965
+ return (options.client ?? client).get({
1966
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1967
+ ...options
1968
+ });
1969
+ }
1970
+ /**
1971
+ * Update a webhook
1972
+ *
1973
+ * Change the destination, the subscription, the label, or whether deliveries are attempted at all. At least one field is required.
1974
+ * Setting `active: false` is the reversible half of `DELETE`: deliveries stop, the endpoint and its history stay. It is what to reach for while a receiver is being repaired.
1975
+ *
1976
+ */
1977
+ static updateWebhook(options) {
1978
+ return (options.client ?? client).patch({
1979
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1980
+ ...options,
1981
+ headers: {
1982
+ "Content-Type": "application/json",
1983
+ ...options.headers
1984
+ }
1985
+ });
1986
+ }
1987
+ /**
1988
+ * Rotate the signing secret
1989
+ *
1990
+ * Issues a new signing secret for the same endpoint and returns it — the second and last time a secret is ever returned. This is the `…:rotate-secret` action; the path segment is `{webhook_id}:rotate-secret`.
1991
+ * The change takes effect on the next delivery, including retries of deliveries already queued, so roll the new secret out to your receiver promptly. There is no overlap window in which both secrets verify.
1992
+ *
1993
+ */
1994
+ static rotateWebhookSecret(options) {
1995
+ return (options.client ?? client).post({
1996
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}:rotate-secret",
1997
+ ...options
1998
+ });
1999
+ }
2000
+ /**
2001
+ * List webhook deliveries
2002
+ *
2003
+ * Every delivery attempted in the project, newest first — what was sent, where, how many times, and what came back. Filter by endpoint, by lifecycle status, or by event type.
2004
+ * Deliveries are per (event, endpoint): an event matching two subscribed endpoints produces two rows, retried and observed independently.
2005
+ *
2006
+ */
2007
+ static listWebhookDeliveries(options) {
2008
+ return (options.client ?? client).get({
2009
+ url: "/v1/projects/{project_id}/webhook-deliveries",
2010
+ ...options
2011
+ });
2012
+ }
2013
+ /**
2014
+ * Get a webhook delivery
2015
+ *
2016
+ * One delivery, including the exact payload that was signed and sent.
2017
+ *
2018
+ */
2019
+ static getWebhookDelivery(options) {
2020
+ return (options.client ?? client).get({
2021
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}",
2022
+ ...options
2023
+ });
2024
+ }
2025
+ /**
2026
+ * Redeliver an event
2027
+ *
2028
+ * Queue the same event at the same endpoint again — the recovery path for a delivery that failed, or one your receiver dropped. This is the `…:redeliver` action; the path segment is `{delivery_id}:redeliver`.
2029
+ * A **new** delivery is created and returned; the original record is left untouched, because its attempt history is the evidence you redelivered on. The event's `id` is carried over unchanged, so a receiver deduping on the event sees the same event twice while one deduping on `X-Naturali-Delivery` sees a distinct delivery.
2030
+ *
2031
+ */
2032
+ static redeliverWebhookDelivery(options) {
2033
+ return (options.client ?? client).post({
2034
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}:redeliver",
2035
+ ...options
2036
+ });
2037
+ }
2038
+ };
1835
2039
  //#endregion
1836
2040
  //#region src/naturaliClient.ts
1837
2041
  /**
@@ -1894,6 +2098,7 @@ var NaturaliClient = class {
1894
2098
  tasks;
1895
2099
  tools;
1896
2100
  traces;
2101
+ webhooks;
1897
2102
  /** The underlying HTTP client, for interceptors or one-off requests. */
1898
2103
  http;
1899
2104
  constructor({ token, headers } = {}) {
@@ -1919,7 +2124,8 @@ var NaturaliClient = class {
1919
2124
  this.tasks = bindResource(Tasks, this.http);
1920
2125
  this.tools = bindResource(Tools, this.http);
1921
2126
  this.traces = bindResource(Traces, this.http);
2127
+ this.webhooks = bindResource(Webhooks, this.http);
1922
2128
  }
1923
2129
  };
1924
2130
  //#endregion
1925
- export { Agents, ApiKeys, Auth, Boards, Channels, Contacts, Generations, Knowledge, Models, NaturaliClient, Projects, Providers, Sessions, Tasks, Tools, Traces, createClient, createConfig };
2131
+ export { Agents, ApiKeys, Auth, Boards, Channels, Contacts, Generations, Knowledge, Models, NaturaliClient, Projects, Providers, Sessions, Tasks, Tools, Traces, Webhooks, createClient, createConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/sdk",
3
- "version": "0.40.1",
3
+ "version": "0.42.0",
4
4
  "description": "TypeScript SDK for the naturali.ai API, generated from its OpenAPI specs",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "tsx": "^4.23.1",
38
38
  "typescript": "~6.0.3",
39
39
  "vitest": "^4.1.10",
40
- "@naturali/api": "0.40.1"
40
+ "@naturali/api": "0.42.0"
41
41
  },
42
42
  "scripts": {
43
43
  "generate": "tsx scripts/generate.ts",