@naturali/sdk 0.67.0 → 0.69.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
@@ -1659,6 +1659,282 @@ var Conversations = class {
1659
1659
  });
1660
1660
  }
1661
1661
  };
1662
+ var Evaluations = class {
1663
+ /**
1664
+ * List datasets
1665
+ *
1666
+ * Returns the datasets defined in a project
1667
+ */
1668
+ static listDatasets(options) {
1669
+ return (options.client ?? client).get({
1670
+ url: "/v1/projects/{project_id}/datasets",
1671
+ ...options
1672
+ });
1673
+ }
1674
+ /**
1675
+ * Create a dataset
1676
+ *
1677
+ * Creates a project-scoped dataset — a named collection of test cases an eval runs an agent against. Names are unique per project.
1678
+ *
1679
+ * 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.
1680
+ */
1681
+ static createDataset(options) {
1682
+ return (options.client ?? client).post({
1683
+ url: "/v1/projects/{project_id}/datasets",
1684
+ ...options,
1685
+ headers: {
1686
+ "Content-Type": "application/json",
1687
+ ...options.headers
1688
+ }
1689
+ });
1690
+ }
1691
+ /**
1692
+ * Delete a dataset
1693
+ *
1694
+ * 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.
1695
+ */
1696
+ static deleteDataset(options) {
1697
+ return (options.client ?? client).delete({
1698
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1699
+ ...options
1700
+ });
1701
+ }
1702
+ /**
1703
+ * Get a dataset
1704
+ *
1705
+ * Returns a specific dataset
1706
+ */
1707
+ static getDataset(options) {
1708
+ return (options.client ?? client).get({
1709
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1710
+ ...options
1711
+ });
1712
+ }
1713
+ /**
1714
+ * Update a dataset
1715
+ *
1716
+ * Updates a dataset's name and/or description
1717
+ */
1718
+ static updateDataset(options) {
1719
+ return (options.client ?? client).put({
1720
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}",
1721
+ ...options,
1722
+ headers: {
1723
+ "Content-Type": "application/json",
1724
+ ...options.headers
1725
+ }
1726
+ });
1727
+ }
1728
+ /**
1729
+ * List dataset items
1730
+ *
1731
+ * Returns the test cases in a dataset, oldest first
1732
+ */
1733
+ static listDatasetItems(options) {
1734
+ return (options.client ?? client).get({
1735
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items",
1736
+ ...options
1737
+ });
1738
+ }
1739
+ /**
1740
+ * Add a dataset item
1741
+ *
1742
+ * Adds one test case. `input` is replayed verbatim as the generation's messages, so it must be a non-empty array of `{ role, content }`.
1743
+ */
1744
+ static createDatasetItem(options) {
1745
+ return (options.client ?? client).post({
1746
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items",
1747
+ ...options,
1748
+ headers: {
1749
+ "Content-Type": "application/json",
1750
+ ...options.headers
1751
+ }
1752
+ });
1753
+ }
1754
+ /**
1755
+ * Curate a dataset item from a generation
1756
+ *
1757
+ * 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.
1758
+ *
1759
+ * 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.
1760
+ *
1761
+ * 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.
1762
+ *
1763
+ * 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.
1764
+ */
1765
+ static createDatasetItemFromGeneration(options) {
1766
+ return (options.client ?? client).post({
1767
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/from-generation",
1768
+ ...options,
1769
+ headers: {
1770
+ "Content-Type": "application/json",
1771
+ ...options.headers
1772
+ }
1773
+ });
1774
+ }
1775
+ /**
1776
+ * Delete a dataset item
1777
+ *
1778
+ * Deletes a test case. Results of runs that already scored it stay readable; their `dataset_item_id` becomes null.
1779
+ */
1780
+ static deleteDatasetItem(options) {
1781
+ return (options.client ?? client).delete({
1782
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/{item_id}",
1783
+ ...options
1784
+ });
1785
+ }
1786
+ /**
1787
+ * Update a dataset item
1788
+ *
1789
+ * Updates a test case. Runs that already scored it are unaffected — each result carries its own frozen copy of the input and expected output.
1790
+ */
1791
+ static updateDatasetItem(options) {
1792
+ return (options.client ?? client).put({
1793
+ url: "/v1/projects/{project_id}/datasets/{dataset_id}/items/{item_id}",
1794
+ ...options,
1795
+ headers: {
1796
+ "Content-Type": "application/json",
1797
+ ...options.headers
1798
+ }
1799
+ });
1800
+ }
1801
+ /**
1802
+ * List evals
1803
+ *
1804
+ * Returns the evals defined in a project
1805
+ */
1806
+ static listEvals(options) {
1807
+ return (options.client ?? client).get({
1808
+ url: "/v1/projects/{project_id}/evals",
1809
+ ...options
1810
+ });
1811
+ }
1812
+ /**
1813
+ * Create an eval
1814
+ *
1815
+ * 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.
1816
+ *
1817
+ * 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.
1818
+ */
1819
+ static createEval(options) {
1820
+ return (options.client ?? client).post({
1821
+ url: "/v1/projects/{project_id}/evals",
1822
+ ...options,
1823
+ headers: {
1824
+ "Content-Type": "application/json",
1825
+ ...options.headers
1826
+ }
1827
+ });
1828
+ }
1829
+ /**
1830
+ * Delete an eval
1831
+ *
1832
+ * Deletes an eval, its runs, and their results
1833
+ */
1834
+ static deleteEval(options) {
1835
+ return (options.client ?? client).delete({
1836
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1837
+ ...options
1838
+ });
1839
+ }
1840
+ /**
1841
+ * Get an eval
1842
+ *
1843
+ * Returns a specific eval
1844
+ */
1845
+ static getEval(options) {
1846
+ return (options.client ?? client).get({
1847
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1848
+ ...options
1849
+ });
1850
+ }
1851
+ /**
1852
+ * Update an eval
1853
+ *
1854
+ * 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.
1855
+ */
1856
+ static updateEval(options) {
1857
+ return (options.client ?? client).put({
1858
+ url: "/v1/projects/{project_id}/evals/{eval_id}",
1859
+ ...options,
1860
+ headers: {
1861
+ "Content-Type": "application/json",
1862
+ ...options.headers
1863
+ }
1864
+ });
1865
+ }
1866
+ /**
1867
+ * List eval runs
1868
+ *
1869
+ * Returns an eval's runs, newest first
1870
+ */
1871
+ static listEvalRuns(options) {
1872
+ return (options.client ?? client).get({
1873
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs",
1874
+ ...options
1875
+ });
1876
+ }
1877
+ /**
1878
+ * Start an eval run
1879
+ *
1880
+ * Runs the eval against its dataset, creating one real agent generation per item and scoring the outputs.
1881
+ *
1882
+ * `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.
1883
+ *
1884
+ * `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.
1885
+ *
1886
+ * 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.
1887
+ *
1888
+ * 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.
1889
+ */
1890
+ static startEvalRun(options) {
1891
+ return (options.client ?? client).post({
1892
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs",
1893
+ ...options,
1894
+ headers: {
1895
+ "Content-Type": "application/json",
1896
+ ...options.headers
1897
+ }
1898
+ });
1899
+ }
1900
+ /**
1901
+ * Get an eval run
1902
+ *
1903
+ * Returns a run's status, counts, and aggregate scores
1904
+ */
1905
+ static getEvalRun(options) {
1906
+ return (options.client ?? client).get({
1907
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}",
1908
+ ...options
1909
+ });
1910
+ }
1911
+ /**
1912
+ * List eval run results
1913
+ *
1914
+ * Returns the per-item results of a run, oldest first
1915
+ */
1916
+ static listEvalResults(options) {
1917
+ return (options.client ?? client).get({
1918
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}/results",
1919
+ ...options
1920
+ });
1921
+ }
1922
+ /**
1923
+ * Cancel an eval run
1924
+ *
1925
+ * Cancels a queued or running run: its outstanding item tasks are dropped so it stops consuming provider budget, and the run settles as `canceled`.
1926
+ *
1927
+ * 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.
1928
+ *
1929
+ * A run that has already finished is rejected with 400.
1930
+ */
1931
+ static cancelEvalRun(options) {
1932
+ return (options.client ?? client).post({
1933
+ url: "/v1/projects/{project_id}/evals/{eval_id}/runs/{eval_run_id}/cancel",
1934
+ ...options
1935
+ });
1936
+ }
1937
+ };
1662
1938
  var Generations = class {
1663
1939
  /**
1664
1940
  * List generations
@@ -1800,6 +2076,45 @@ var ModelRoutes = class {
1800
2076
  });
1801
2077
  }
1802
2078
  };
2079
+ var Models = class {
2080
+ /**
2081
+ * List models
2082
+ *
2083
+ * Lists catalog models, sorted by id. Filter by vendor, provider, input/output modality, status, or `managed` — the last being the axis that decides whether a model is usable without bringing your own provider credentials, so `?managed=true&status=available` is the set a project can enable today.
2084
+ *
2085
+ */
2086
+ static listModels(options) {
2087
+ return (options?.client ?? client).get({
2088
+ url: "/v1/models",
2089
+ ...options
2090
+ });
2091
+ }
2092
+ /**
2093
+ * Get a model
2094
+ */
2095
+ static getModel(options) {
2096
+ return (options.client ?? client).get({
2097
+ url: "/v1/models/{model_id}",
2098
+ ...options
2099
+ });
2100
+ }
2101
+ /**
2102
+ * Enable a naturali-managed model
2103
+ *
2104
+ * Provisions a managed provider running this model in the project. The provider needs no credentials of yours — it runs on naturali's own model access — and is priced from the catalog the moment it is created, so its usage is metered from the first generation. The created resource is an ordinary provider: read, update and delete it through [`GET /v1/projects/{project_id}/ai-providers/{ai_provider_id}`](/docs/api/ai-providers/get-ai-provider) like any other. Requires the `admin` role in the project. Only models with `managed: true` can be enabled; anything else is a 400.
2105
+ *
2106
+ */
2107
+ static enableManagedModel(options) {
2108
+ return (options.client ?? client).post({
2109
+ url: "/v1/projects/{project_id}/models/{model_id}/providers",
2110
+ ...options,
2111
+ headers: {
2112
+ "Content-Type": "application/json",
2113
+ ...options.headers
2114
+ }
2115
+ });
2116
+ }
2117
+ };
1803
2118
  var Projects = class {
1804
2119
  /**
1805
2120
  * List projects
@@ -2236,6 +2551,58 @@ var Tools = class {
2236
2551
  });
2237
2552
  }
2238
2553
  };
2554
+ var Traces = class {
2555
+ /**
2556
+ * List traces
2557
+ *
2558
+ * Returns a paginated list of execution traces for the project.
2559
+ */
2560
+ static listTraces(options) {
2561
+ return (options.client ?? client).get({
2562
+ url: "/v1/projects/{project_id}/traces",
2563
+ ...options
2564
+ });
2565
+ }
2566
+ /**
2567
+ * Get a trace
2568
+ *
2569
+ * Returns a single trace by ID.
2570
+ */
2571
+ static getTrace(options) {
2572
+ return (options.client ?? client).get({
2573
+ url: "/v1/projects/{project_id}/traces/{trace_id}",
2574
+ ...options
2575
+ });
2576
+ }
2577
+ /**
2578
+ * Get trace tree
2579
+ *
2580
+ * 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.
2581
+ *
2582
+ */
2583
+ static getTraceTree(options) {
2584
+ return (options.client ?? client).get({
2585
+ url: "/v1/projects/{project_id}/traces/{trace_id}/tree",
2586
+ ...options
2587
+ });
2588
+ }
2589
+ /**
2590
+ * Purge trace content
2591
+ *
2592
+ * 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.
2593
+ *
2594
+ * 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.
2595
+ *
2596
+ * Idempotent — purging an already-purged trace succeeds and leaves the original `content_redacted_at` in place.
2597
+ *
2598
+ */
2599
+ static purgeTraceContent(options) {
2600
+ return (options.client ?? client).delete({
2601
+ url: "/v1/projects/{project_id}/traces/{trace_id}/content",
2602
+ ...options
2603
+ });
2604
+ }
2605
+ };
2239
2606
  var Users = class {
2240
2607
  /**
2241
2608
  * Get the current user
@@ -2441,12 +2808,15 @@ var NaturaliClient = class {
2441
2808
  channels;
2442
2809
  auth;
2443
2810
  conversations;
2811
+ evaluations;
2444
2812
  generations;
2445
2813
  modelRoutes;
2814
+ models;
2446
2815
  projects;
2447
2816
  secrets;
2448
2817
  sessions;
2449
2818
  tools;
2819
+ traces;
2450
2820
  users;
2451
2821
  webhooks;
2452
2822
  /** The underlying HTTP client, for interceptors or one-off requests. */
@@ -2468,12 +2838,15 @@ var NaturaliClient = class {
2468
2838
  this.channels = bindResource(Channels, this.http);
2469
2839
  this.auth = bindResource(Auth, this.http);
2470
2840
  this.conversations = bindResource(Conversations, this.http);
2841
+ this.evaluations = bindResource(Evaluations, this.http);
2471
2842
  this.generations = bindResource(Generations, this.http);
2472
2843
  this.modelRoutes = bindResource(ModelRoutes, this.http);
2844
+ this.models = bindResource(Models, this.http);
2473
2845
  this.projects = bindResource(Projects, this.http);
2474
2846
  this.secrets = bindResource(Secrets, this.http);
2475
2847
  this.sessions = bindResource(Sessions, this.http);
2476
2848
  this.tools = bindResource(Tools, this.http);
2849
+ this.traces = bindResource(Traces, this.http);
2477
2850
  this.users = bindResource(Users, this.http);
2478
2851
  this.webhooks = bindResource(Webhooks, this.http);
2479
2852
  }
@@ -2488,13 +2861,16 @@ exports.Assistant = Assistant;
2488
2861
  exports.Auth = Auth;
2489
2862
  exports.Channels = Channels;
2490
2863
  exports.Conversations = Conversations;
2864
+ exports.Evaluations = Evaluations;
2491
2865
  exports.Generations = Generations;
2492
2866
  exports.ModelRoutes = ModelRoutes;
2867
+ exports.Models = Models;
2493
2868
  exports.NaturaliClient = NaturaliClient;
2494
2869
  exports.Projects = Projects;
2495
2870
  exports.Secrets = Secrets;
2496
2871
  exports.Sessions = Sessions;
2497
2872
  exports.Tools = Tools;
2873
+ exports.Traces = Traces;
2498
2874
  exports.Users = Users;
2499
2875
  exports.Webhooks = Webhooks;
2500
2876
  exports.createClient = createClient;