@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.cjs CHANGED
@@ -1344,7 +1344,11 @@ var Knowledge = class {
1344
1344
  /**
1345
1345
  * Create a document
1346
1346
  *
1347
- * 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.
1347
+ * 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.
1348
+ *
1349
+ * `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.
1350
+ *
1351
+ * 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.
1348
1352
  *
1349
1353
  */
1350
1354
  static createKnowledgeDocument(options) {
@@ -1389,6 +1393,86 @@ var Knowledge = class {
1389
1393
  ...options
1390
1394
  });
1391
1395
  }
1396
+ /**
1397
+ * List converters
1398
+ *
1399
+ * Lists the media converters registered in the project.
1400
+ */
1401
+ static listKnowledgeConverters(options) {
1402
+ return (options.client ?? client).get({
1403
+ url: "/v1/projects/{project_id}/knowledge/converters",
1404
+ ...options
1405
+ });
1406
+ }
1407
+ /**
1408
+ * Create a converter
1409
+ *
1410
+ * 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:
1411
+ *
1412
+ * - an **agent** (`agent_id`) — the file is handed to a
1413
+ * multimodal model with a fixed "extract all the text" instruction and
1414
+ * its answer becomes the document text. The shortest path for images
1415
+ * and scanned PDFs; nothing to map.
1416
+ *
1417
+ * - a **tool** (`tool_id`) — the file is passed to an
1418
+ * `http` tool as `{ content_type, filename, data_base64 }`, and
1419
+ * whatever string the tool returns becomes the document text. The path
1420
+ * for dedicated non-chat APIs (speech-to-text, a specialist OCR
1421
+ * engine); use the tool's `execute.body_mode: multipart` for
1422
+ * form-data endpoints and its `output_mapping` to reduce a JSON
1423
+ * response to the bare string.
1424
+ *
1425
+ *
1426
+ * Exactly one of `agent_id` / `tool_id`, and one converter per `content_type` in a project.
1427
+ *
1428
+ */
1429
+ static createKnowledgeConverter(options) {
1430
+ return (options.client ?? client).post({
1431
+ url: "/v1/projects/{project_id}/knowledge/converters",
1432
+ ...options,
1433
+ headers: {
1434
+ "Content-Type": "application/json",
1435
+ ...options.headers
1436
+ }
1437
+ });
1438
+ }
1439
+ /**
1440
+ * Delete a converter
1441
+ *
1442
+ * Removes the converter. Documents already ingested through it are untouched; new files of that media type stop being ingestable until another converter covers them.
1443
+ *
1444
+ */
1445
+ static deleteKnowledgeConverter(options) {
1446
+ return (options.client ?? client).delete({
1447
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1448
+ ...options
1449
+ });
1450
+ }
1451
+ /**
1452
+ * Get a converter
1453
+ */
1454
+ static getKnowledgeConverter(options) {
1455
+ return (options.client ?? client).get({
1456
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1457
+ ...options
1458
+ });
1459
+ }
1460
+ /**
1461
+ * Update a converter
1462
+ *
1463
+ * 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.
1464
+ *
1465
+ */
1466
+ static updateKnowledgeConverter(options) {
1467
+ return (options.client ?? client).patch({
1468
+ url: "/v1/projects/{project_id}/knowledge/converters/{converter_id}",
1469
+ ...options,
1470
+ headers: {
1471
+ "Content-Type": "application/json",
1472
+ ...options.headers
1473
+ }
1474
+ });
1475
+ }
1392
1476
  };
1393
1477
  var Models = class {
1394
1478
  /**
@@ -1833,6 +1917,126 @@ var Traces = class {
1833
1917
  });
1834
1918
  }
1835
1919
  };
1920
+ var Webhooks = class {
1921
+ /**
1922
+ * List webhooks
1923
+ *
1924
+ * The endpoints registered in the project, newest first.
1925
+ */
1926
+ static listWebhooks(options) {
1927
+ return (options.client ?? client).get({
1928
+ url: "/v1/projects/{project_id}/webhooks",
1929
+ ...options
1930
+ });
1931
+ }
1932
+ /**
1933
+ * Create a webhook
1934
+ *
1935
+ * Register an endpoint and subscribe it to one or more event types.
1936
+ * 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.
1937
+ * Returns `501` on a deployment with no credential-sealing key configured, since the secret could not then be stored safely.
1938
+ *
1939
+ */
1940
+ static createWebhook(options) {
1941
+ return (options.client ?? client).post({
1942
+ url: "/v1/projects/{project_id}/webhooks",
1943
+ ...options,
1944
+ headers: {
1945
+ "Content-Type": "application/json",
1946
+ ...options.headers
1947
+ }
1948
+ });
1949
+ }
1950
+ /**
1951
+ * Delete a webhook
1952
+ *
1953
+ * Removes the endpoint and its delivery records. To stop deliveries while keeping the audit trail, `PATCH` it to `active: false` instead.
1954
+ *
1955
+ */
1956
+ static deleteWebhook(options) {
1957
+ return (options.client ?? client).delete({
1958
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1959
+ ...options
1960
+ });
1961
+ }
1962
+ /**
1963
+ * Get a webhook
1964
+ */
1965
+ static getWebhook(options) {
1966
+ return (options.client ?? client).get({
1967
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1968
+ ...options
1969
+ });
1970
+ }
1971
+ /**
1972
+ * Update a webhook
1973
+ *
1974
+ * Change the destination, the subscription, the label, or whether deliveries are attempted at all. At least one field is required.
1975
+ * 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.
1976
+ *
1977
+ */
1978
+ static updateWebhook(options) {
1979
+ return (options.client ?? client).patch({
1980
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}",
1981
+ ...options,
1982
+ headers: {
1983
+ "Content-Type": "application/json",
1984
+ ...options.headers
1985
+ }
1986
+ });
1987
+ }
1988
+ /**
1989
+ * Rotate the signing secret
1990
+ *
1991
+ * 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`.
1992
+ * 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.
1993
+ *
1994
+ */
1995
+ static rotateWebhookSecret(options) {
1996
+ return (options.client ?? client).post({
1997
+ url: "/v1/projects/{project_id}/webhooks/{webhook_id}:rotate-secret",
1998
+ ...options
1999
+ });
2000
+ }
2001
+ /**
2002
+ * List webhook deliveries
2003
+ *
2004
+ * 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.
2005
+ * Deliveries are per (event, endpoint): an event matching two subscribed endpoints produces two rows, retried and observed independently.
2006
+ *
2007
+ */
2008
+ static listWebhookDeliveries(options) {
2009
+ return (options.client ?? client).get({
2010
+ url: "/v1/projects/{project_id}/webhook-deliveries",
2011
+ ...options
2012
+ });
2013
+ }
2014
+ /**
2015
+ * Get a webhook delivery
2016
+ *
2017
+ * One delivery, including the exact payload that was signed and sent.
2018
+ *
2019
+ */
2020
+ static getWebhookDelivery(options) {
2021
+ return (options.client ?? client).get({
2022
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}",
2023
+ ...options
2024
+ });
2025
+ }
2026
+ /**
2027
+ * Redeliver an event
2028
+ *
2029
+ * 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`.
2030
+ * 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.
2031
+ *
2032
+ */
2033
+ static redeliverWebhookDelivery(options) {
2034
+ return (options.client ?? client).post({
2035
+ url: "/v1/projects/{project_id}/webhook-deliveries/{delivery_id}:redeliver",
2036
+ ...options
2037
+ });
2038
+ }
2039
+ };
1836
2040
  //#endregion
1837
2041
  //#region src/naturaliClient.ts
1838
2042
  /**
@@ -1895,6 +2099,7 @@ var NaturaliClient = class {
1895
2099
  tasks;
1896
2100
  tools;
1897
2101
  traces;
2102
+ webhooks;
1898
2103
  /** The underlying HTTP client, for interceptors or one-off requests. */
1899
2104
  http;
1900
2105
  constructor({ token, headers } = {}) {
@@ -1920,6 +2125,7 @@ var NaturaliClient = class {
1920
2125
  this.tasks = bindResource(Tasks, this.http);
1921
2126
  this.tools = bindResource(Tools, this.http);
1922
2127
  this.traces = bindResource(Traces, this.http);
2128
+ this.webhooks = bindResource(Webhooks, this.http);
1923
2129
  }
1924
2130
  };
1925
2131
  //#endregion
@@ -1939,5 +2145,6 @@ exports.Sessions = Sessions;
1939
2145
  exports.Tasks = Tasks;
1940
2146
  exports.Tools = Tools;
1941
2147
  exports.Traces = Traces;
2148
+ exports.Webhooks = Webhooks;
1942
2149
  exports.createClient = createClient;
1943
2150
  exports.createConfig = createConfig;