@naturali/sdk 0.67.0 → 0.68.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
@@ -1658,6 +1658,282 @@ var Conversations = class {
1658
1658
  });
1659
1659
  }
1660
1660
  };
1661
+ var Evaluations = class {
1662
+ /**
1663
+ * List datasets
1664
+ *
1665
+ * Returns the datasets defined in a project
1666
+ */
1667
+ static listDatasets(options) {
1668
+ return (options.client ?? client).get({
1669
+ url: "/v1/projects/{project_id}/datasets",
1670
+ ...options
1671
+ });
1672
+ }
1673
+ /**
1674
+ * Create a dataset
1675
+ *
1676
+ * Creates a project-scoped dataset — a named collection of test cases an eval runs an agent against. Names are unique per project.
1677
+ *
1678
+ * Datasets are operator-owned **fixtures**. The platform's content purge never deletes or mutates a dataset item, so erasing a generation cannot silently stop a test suite from being runnable.
1679
+ */
1680
+ static createDataset(options) {
1681
+ return (options.client ?? client).post({
1682
+ url: "/v1/projects/{project_id}/datasets",
1683
+ ...options,
1684
+ headers: {
1685
+ "Content-Type": "application/json",
1686
+ ...options.headers
1687
+ }
1688
+ });
1689
+ }
1690
+ /**
1691
+ * Delete a dataset
1692
+ *
1693
+ * Deletes a dataset, its items, and every eval bound to it. Results of runs that already scored those items keep their frozen copies of the input and expected output.
1694
+ */
1695
+ static deleteDataset(options) {
1696
+ return (options.client ?? client).delete({
1697
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1698
+ ...options
1699
+ });
1700
+ }
1701
+ /**
1702
+ * Get a dataset
1703
+ *
1704
+ * Returns a specific dataset
1705
+ */
1706
+ static getDataset(options) {
1707
+ return (options.client ?? client).get({
1708
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1709
+ ...options
1710
+ });
1711
+ }
1712
+ /**
1713
+ * Update a dataset
1714
+ *
1715
+ * Updates a dataset's name and/or description
1716
+ */
1717
+ static updateDataset(options) {
1718
+ return (options.client ?? client).put({
1719
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1720
+ ...options,
1721
+ headers: {
1722
+ "Content-Type": "application/json",
1723
+ ...options.headers
1724
+ }
1725
+ });
1726
+ }
1727
+ /**
1728
+ * List dataset items
1729
+ *
1730
+ * Returns the test cases in a dataset, oldest first
1731
+ */
1732
+ static listDatasetItems(options) {
1733
+ return (options.client ?? client).get({
1734
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items",
1735
+ ...options
1736
+ });
1737
+ }
1738
+ /**
1739
+ * Add a dataset item
1740
+ *
1741
+ * Adds one test case. `input` is replayed verbatim as the generation's messages, so it must be a non-empty array of `{ role, content }`.
1742
+ */
1743
+ static createDatasetItem(options) {
1744
+ return (options.client ?? client).post({
1745
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items",
1746
+ ...options,
1747
+ headers: {
1748
+ "Content-Type": "application/json",
1749
+ ...options.headers
1750
+ }
1751
+ });
1752
+ }
1753
+ /**
1754
+ * Curate a dataset item from a generation
1755
+ *
1756
+ * Promotes a real, completed generation into a test case: its input messages become the item's `input`, and its own answer becomes `expected_output` unless you supply one. Use it to build an evaluation set out of production traffic rather than hand-authoring fixtures.
1757
+ *
1758
+ * The item is a **copy**, not a view. It keeps working after the source generation's content is purged, and `source_generation_id` goes null if that generation is deleted — a purge can never quietly stop a suite from being runnable.
1759
+ *
1760
+ * Requires both `evaluations:CreateDataset` and `generations:GetGeneration`: the call copies content out of a generation, so a principal that may not read that generation may not curate it either.
1761
+ *
1762
+ * Only a **completed** generation can be promoted (`409 GENERATION_NOT_COMPLETED`), and only while its content is still available: an agent or project running with `trace_content_mode: none` never stored the input, and a purged or expired generation no longer has it (`409 GENERATION_CONTENT_UNAVAILABLE`). Generations that predate input recording answer the same way.
1763
+ */
1764
+ static createDatasetItemFromGeneration(options) {
1765
+ return (options.client ?? client).post({
1766
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/from-generation",
1767
+ ...options,
1768
+ headers: {
1769
+ "Content-Type": "application/json",
1770
+ ...options.headers
1771
+ }
1772
+ });
1773
+ }
1774
+ /**
1775
+ * Delete a dataset item
1776
+ *
1777
+ * Deletes a test case. Results of runs that already scored it stay readable; their `dataset_item_id` becomes null.
1778
+ */
1779
+ static deleteDatasetItem(options) {
1780
+ return (options.client ?? client).delete({
1781
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/{item_id}",
1782
+ ...options
1783
+ });
1784
+ }
1785
+ /**
1786
+ * Update a dataset item
1787
+ *
1788
+ * Updates a test case. Runs that already scored it are unaffected — each result carries its own frozen copy of the input and expected output.
1789
+ */
1790
+ static updateDatasetItem(options) {
1791
+ return (options.client ?? client).put({
1792
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/{item_id}",
1793
+ ...options,
1794
+ headers: {
1795
+ "Content-Type": "application/json",
1796
+ ...options.headers
1797
+ }
1798
+ });
1799
+ }
1800
+ /**
1801
+ * List evals
1802
+ *
1803
+ * Returns the evals defined in a project
1804
+ */
1805
+ static listEvals(options) {
1806
+ return (options.client ?? client).get({
1807
+ url: "/v1/projects/{project_id}/evals",
1808
+ ...options
1809
+ });
1810
+ }
1811
+ /**
1812
+ * Create an eval
1813
+ *
1814
+ * Binds an agent under test to a dataset and a list of scorers. The agent and the dataset must belong to the same project as the eval; a cross-project reference is rejected with 400.
1815
+ *
1816
+ * Scorer config is frozen here rather than read from the agent at run time, so two runs of the same eval are always judged by the same criteria and their comparison measures the agent instead of the config drifting underneath it. Each scorer `type` may appear at most once.
1817
+ */
1818
+ static createEval(options) {
1819
+ return (options.client ?? client).post({
1820
+ url: "/v1/projects/{project_id}/evals",
1821
+ ...options,
1822
+ headers: {
1823
+ "Content-Type": "application/json",
1824
+ ...options.headers
1825
+ }
1826
+ });
1827
+ }
1828
+ /**
1829
+ * Delete an eval
1830
+ *
1831
+ * Deletes an eval, its runs, and their results
1832
+ */
1833
+ static deleteEval(options) {
1834
+ return (options.client ?? client).delete({
1835
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1836
+ ...options
1837
+ });
1838
+ }
1839
+ /**
1840
+ * Get an eval
1841
+ *
1842
+ * Returns a specific eval
1843
+ */
1844
+ static getEval(options) {
1845
+ return (options.client ?? client).get({
1846
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1847
+ ...options
1848
+ });
1849
+ }
1850
+ /**
1851
+ * Update an eval
1852
+ *
1853
+ * Updates an eval. Changing `agent_id` re-validates the scorers against the new agent, since an `output_schema` scorer that was legal against the old one may not be.
1854
+ */
1855
+ static updateEval(options) {
1856
+ return (options.client ?? client).put({
1857
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1858
+ ...options,
1859
+ headers: {
1860
+ "Content-Type": "application/json",
1861
+ ...options.headers
1862
+ }
1863
+ });
1864
+ }
1865
+ /**
1866
+ * List eval runs
1867
+ *
1868
+ * Returns an eval's runs, newest first
1869
+ */
1870
+ static listEvalRuns(options) {
1871
+ return (options.client ?? client).get({
1872
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs",
1873
+ ...options
1874
+ });
1875
+ }
1876
+ /**
1877
+ * Start an eval run
1878
+ *
1879
+ * Runs the eval against its dataset, creating one real agent generation per item and scoring the outputs.
1880
+ *
1881
+ * `wait: true` executes the run synchronously and returns it terminal, with its scores. The dataset is capped at 25 items for a synchronous run; a larger one is rejected with 400 rather than partially scored.
1882
+ *
1883
+ * `wait: false` (the default) enqueues one task per item and returns immediately with `status: "queued"`. A worker executes the items and the run settles itself; poll `GET /evals/{eval_id}/runs/{eval_run_id}` for the terminal status. There is no item cap on a queued run.
1884
+ *
1885
+ * The whole run is pinned to **one** agent version, stamped on `agent_version`: pass one explicitly to evaluate a canary before promoting it, or omit it to use the active release's stable version (or the live draft when no release is in effect). Without the pin, release assignment would bucket each item independently and blend two configs into a single score.
1886
+ *
1887
+ * With `baseline_run_id`, the finished run's `aggregate_scores.baseline` carries per-scorer deltas against that run, computed over the items present and scorable in **both** runs, with the divergence counted. A delta over a shifted dataset is therefore never presented as a clean comparison.
1888
+ */
1889
+ static startEvalRun(options) {
1890
+ return (options.client ?? client).post({
1891
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs",
1892
+ ...options,
1893
+ headers: {
1894
+ "Content-Type": "application/json",
1895
+ ...options.headers
1896
+ }
1897
+ });
1898
+ }
1899
+ /**
1900
+ * Get an eval run
1901
+ *
1902
+ * Returns a run's status, counts, and aggregate scores
1903
+ */
1904
+ static getEvalRun(options) {
1905
+ return (options.client ?? client).get({
1906
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}",
1907
+ ...options
1908
+ });
1909
+ }
1910
+ /**
1911
+ * List eval run results
1912
+ *
1913
+ * Returns the per-item results of a run, oldest first
1914
+ */
1915
+ static listEvalResults(options) {
1916
+ return (options.client ?? client).get({
1917
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}/results",
1918
+ ...options
1919
+ });
1920
+ }
1921
+ /**
1922
+ * Cancel an eval run
1923
+ *
1924
+ * Cancels a queued or running run: its outstanding item tasks are dropped so it stops consuming provider budget, and the run settles as `canceled`.
1925
+ *
1926
+ * Results already written are kept — they are real measurements of generations that were really paid for — and `completed_count` / `errored_count` report what ran. `aggregate_scores` is deliberately left null: a partial roll-up in the same field a completed run uses would read as a whole-dataset verdict.
1927
+ *
1928
+ * A run that has already finished is rejected with 400.
1929
+ */
1930
+ static cancelEvalRun(options) {
1931
+ return (options.client ?? client).post({
1932
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}/cancel",
1933
+ ...options
1934
+ });
1935
+ }
1936
+ };
1661
1937
  var Generations = class {
1662
1938
  /**
1663
1939
  * List generations
@@ -2235,6 +2511,58 @@ var Tools = class {
2235
2511
  });
2236
2512
  }
2237
2513
  };
2514
+ var Traces = class {
2515
+ /**
2516
+ * List traces
2517
+ *
2518
+ * Returns a paginated list of execution traces for the project.
2519
+ */
2520
+ static listTraces(options) {
2521
+ return (options.client ?? client).get({
2522
+ url: "/v1/projects/{project_id}/traces",
2523
+ ...options
2524
+ });
2525
+ }
2526
+ /**
2527
+ * Get a trace
2528
+ *
2529
+ * Returns a single trace by ID.
2530
+ */
2531
+ static getTrace(options) {
2532
+ return (options.client ?? client).get({
2533
+ url: "/v1/projects/{project_id}/traces/{trace_id}",
2534
+ ...options
2535
+ });
2536
+ }
2537
+ /**
2538
+ * Get trace tree
2539
+ *
2540
+ * Returns the full execution tree rooted at the given trace (or its root if the given trace is a child). Each node represents one agent's execution session. The `children` array contains traces triggered by sub-agent tool calls from that trace.
2541
+ *
2542
+ */
2543
+ static getTraceTree(options) {
2544
+ return (options.client ?? client).get({
2545
+ url: "/v1/projects/{project_id}/traces/{trace_id}/tree",
2546
+ ...options
2547
+ });
2548
+ }
2549
+ /**
2550
+ * Purge trace content
2551
+ *
2552
+ * Deletes the trace's steps object from storage and clears its content columns (`file_id`, `error`), cascading to every descendant trace and to all of their generations. A descendant holds its own steps object covering the same run, so the cascade is what makes the erasure complete rather than merely partial.
2553
+ *
2554
+ * The rows survive as auditable skeletons with `content_redacted_at` set — ids, timestamps, step counts, and the generations' usage-attribution fields are preserved, because the billing and audit ledger must outlive a tenant's erasure of the content. A purged trace therefore reads back as a skeleton, not a 404: a 404 would prove nothing.
2555
+ *
2556
+ * Idempotent — purging an already-purged trace succeeds and leaves the original `content_redacted_at` in place.
2557
+ *
2558
+ */
2559
+ static purgeTraceContent(options) {
2560
+ return (options.client ?? client).delete({
2561
+ url: "/v1/projects/{project_id}/traces/{trace_id}/content",
2562
+ ...options
2563
+ });
2564
+ }
2565
+ };
2238
2566
  var Users = class {
2239
2567
  /**
2240
2568
  * Get the current user
@@ -2440,12 +2768,14 @@ var NaturaliClient = class {
2440
2768
  channels;
2441
2769
  auth;
2442
2770
  conversations;
2771
+ evaluations;
2443
2772
  generations;
2444
2773
  modelRoutes;
2445
2774
  projects;
2446
2775
  secrets;
2447
2776
  sessions;
2448
2777
  tools;
2778
+ traces;
2449
2779
  users;
2450
2780
  webhooks;
2451
2781
  /** The underlying HTTP client, for interceptors or one-off requests. */
@@ -2467,15 +2797,17 @@ var NaturaliClient = class {
2467
2797
  this.channels = bindResource(Channels, this.http);
2468
2798
  this.auth = bindResource(Auth, this.http);
2469
2799
  this.conversations = bindResource(Conversations, this.http);
2800
+ this.evaluations = bindResource(Evaluations, this.http);
2470
2801
  this.generations = bindResource(Generations, this.http);
2471
2802
  this.modelRoutes = bindResource(ModelRoutes, this.http);
2472
2803
  this.projects = bindResource(Projects, this.http);
2473
2804
  this.secrets = bindResource(Secrets, this.http);
2474
2805
  this.sessions = bindResource(Sessions, this.http);
2475
2806
  this.tools = bindResource(Tools, this.http);
2807
+ this.traces = bindResource(Traces, this.http);
2476
2808
  this.users = bindResource(Users, this.http);
2477
2809
  this.webhooks = bindResource(Webhooks, this.http);
2478
2810
  }
2479
2811
  };
2480
2812
  //#endregion
2481
- export { Actors, AgentVersions, Agents, AiProviders, ApiKeys, Assistant, Auth, Channels, Conversations, Generations, ModelRoutes, NaturaliClient, Projects, Secrets, Sessions, Tools, Users, Webhooks, createClient, createConfig };
2813
+ export { Actors, AgentVersions, Agents, AiProviders, ApiKeys, Assistant, Auth, Channels, Conversations, Evaluations, Generations, ModelRoutes, NaturaliClient, Projects, Secrets, Sessions, Tools, Traces, Users, Webhooks, createClient, createConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturali/sdk",
3
- "version": "0.67.0",
3
+ "version": "0.68.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.67.0"
40
+ "@naturali/api": "0.68.0"
41
41
  },
42
42
  "scripts": {
43
43
  "generate": "tsx scripts/generate.ts",