@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.cjs +334 -0
- package/dist/index.d.cts +1657 -33
- package/dist/index.d.mts +1657 -33
- package/dist/index.mjs +333 -1
- package/package.json +2 -2
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
|
|
@@ -2236,6 +2512,58 @@ var Tools = class {
|
|
|
2236
2512
|
});
|
|
2237
2513
|
}
|
|
2238
2514
|
};
|
|
2515
|
+
var Traces = class {
|
|
2516
|
+
/**
|
|
2517
|
+
* List traces
|
|
2518
|
+
*
|
|
2519
|
+
* Returns a paginated list of execution traces for the project.
|
|
2520
|
+
*/
|
|
2521
|
+
static listTraces(options) {
|
|
2522
|
+
return (options.client ?? client).get({
|
|
2523
|
+
url: "/v1/projects/{project_id}/traces",
|
|
2524
|
+
...options
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Get a trace
|
|
2529
|
+
*
|
|
2530
|
+
* Returns a single trace by ID.
|
|
2531
|
+
*/
|
|
2532
|
+
static getTrace(options) {
|
|
2533
|
+
return (options.client ?? client).get({
|
|
2534
|
+
url: "/v1/projects/{project_id}/traces/{trace_id}",
|
|
2535
|
+
...options
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
/**
|
|
2539
|
+
* Get trace tree
|
|
2540
|
+
*
|
|
2541
|
+
* 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.
|
|
2542
|
+
*
|
|
2543
|
+
*/
|
|
2544
|
+
static getTraceTree(options) {
|
|
2545
|
+
return (options.client ?? client).get({
|
|
2546
|
+
url: "/v1/projects/{project_id}/traces/{trace_id}/tree",
|
|
2547
|
+
...options
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Purge trace content
|
|
2552
|
+
*
|
|
2553
|
+
* 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.
|
|
2554
|
+
*
|
|
2555
|
+
* 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.
|
|
2556
|
+
*
|
|
2557
|
+
* Idempotent — purging an already-purged trace succeeds and leaves the original `content_redacted_at` in place.
|
|
2558
|
+
*
|
|
2559
|
+
*/
|
|
2560
|
+
static purgeTraceContent(options) {
|
|
2561
|
+
return (options.client ?? client).delete({
|
|
2562
|
+
url: "/v1/projects/{project_id}/traces/{trace_id}/content",
|
|
2563
|
+
...options
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2239
2567
|
var Users = class {
|
|
2240
2568
|
/**
|
|
2241
2569
|
* Get the current user
|
|
@@ -2441,12 +2769,14 @@ var NaturaliClient = class {
|
|
|
2441
2769
|
channels;
|
|
2442
2770
|
auth;
|
|
2443
2771
|
conversations;
|
|
2772
|
+
evaluations;
|
|
2444
2773
|
generations;
|
|
2445
2774
|
modelRoutes;
|
|
2446
2775
|
projects;
|
|
2447
2776
|
secrets;
|
|
2448
2777
|
sessions;
|
|
2449
2778
|
tools;
|
|
2779
|
+
traces;
|
|
2450
2780
|
users;
|
|
2451
2781
|
webhooks;
|
|
2452
2782
|
/** The underlying HTTP client, for interceptors or one-off requests. */
|
|
@@ -2468,12 +2798,14 @@ var NaturaliClient = class {
|
|
|
2468
2798
|
this.channels = bindResource(Channels, this.http);
|
|
2469
2799
|
this.auth = bindResource(Auth, this.http);
|
|
2470
2800
|
this.conversations = bindResource(Conversations, this.http);
|
|
2801
|
+
this.evaluations = bindResource(Evaluations, this.http);
|
|
2471
2802
|
this.generations = bindResource(Generations, this.http);
|
|
2472
2803
|
this.modelRoutes = bindResource(ModelRoutes, this.http);
|
|
2473
2804
|
this.projects = bindResource(Projects, this.http);
|
|
2474
2805
|
this.secrets = bindResource(Secrets, this.http);
|
|
2475
2806
|
this.sessions = bindResource(Sessions, this.http);
|
|
2476
2807
|
this.tools = bindResource(Tools, this.http);
|
|
2808
|
+
this.traces = bindResource(Traces, this.http);
|
|
2477
2809
|
this.users = bindResource(Users, this.http);
|
|
2478
2810
|
this.webhooks = bindResource(Webhooks, this.http);
|
|
2479
2811
|
}
|
|
@@ -2488,6 +2820,7 @@ exports.Assistant = Assistant;
|
|
|
2488
2820
|
exports.Auth = Auth;
|
|
2489
2821
|
exports.Channels = Channels;
|
|
2490
2822
|
exports.Conversations = Conversations;
|
|
2823
|
+
exports.Evaluations = Evaluations;
|
|
2491
2824
|
exports.Generations = Generations;
|
|
2492
2825
|
exports.ModelRoutes = ModelRoutes;
|
|
2493
2826
|
exports.NaturaliClient = NaturaliClient;
|
|
@@ -2495,6 +2828,7 @@ exports.Projects = Projects;
|
|
|
2495
2828
|
exports.Secrets = Secrets;
|
|
2496
2829
|
exports.Sessions = Sessions;
|
|
2497
2830
|
exports.Tools = Tools;
|
|
2831
|
+
exports.Traces = Traces;
|
|
2498
2832
|
exports.Users = Users;
|
|
2499
2833
|
exports.Webhooks = Webhooks;
|
|
2500
2834
|
exports.createClient = createClient;
|