@agents24/node 0.5.25 → 0.5.26

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
@@ -1158,8 +1158,7 @@ var ResourceInstallationsNamespace = class {
1158
1158
  return this.http.requestJson(`/resource-installations/${encodeURIComponent(installationId)}/artifact-development-sessions`, {
1159
1159
  method: "POST",
1160
1160
  body: request,
1161
- options,
1162
- mutation: true
1161
+ options
1163
1162
  });
1164
1163
  }
1165
1164
  developmentSessionStatus(installationId, resourceKey) {
@@ -1532,8 +1531,99 @@ var IngestionJobsNamespace = class {
1532
1531
  mutation: true
1533
1532
  });
1534
1533
  }
1534
+ listSteps(jobId) {
1535
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/steps`);
1536
+ }
1537
+ getStepData(jobId, stepId, options) {
1538
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/steps/${encodeURIComponent(stepId)}/data`, {
1539
+ query: {
1540
+ type: options.type,
1541
+ page: options.page,
1542
+ limit: options.limit,
1543
+ reference_id: options.reference_id
1544
+ }
1545
+ });
1546
+ }
1547
+ getStepField(jobId, stepId, options) {
1548
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/steps/${encodeURIComponent(stepId)}/field`, {
1549
+ query: {
1550
+ type: options.type,
1551
+ path: options.path,
1552
+ offset: options.offset,
1553
+ limit: options.limit,
1554
+ reference_id: options.reference_id
1555
+ }
1556
+ });
1557
+ }
1558
+ downloadStepData(jobId, stepId, options) {
1559
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/steps/${encodeURIComponent(stepId)}/download`, {
1560
+ query: {
1561
+ type: options.type,
1562
+ reference_id: options.reference_id
1563
+ }
1564
+ });
1565
+ }
1566
+ getResult(jobId) {
1567
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/result`);
1568
+ }
1569
+ getProcessedContent(jobId, options) {
1570
+ return this.http.requestJson(`/admin/pipelines/jobs/${encodeURIComponent(jobId)}/processed-content`, {
1571
+ query: {
1572
+ reference: options.reference
1573
+ }
1574
+ });
1575
+ }
1535
1576
  };
1536
1577
 
1578
+ // src/knowledge-record-helpers.ts
1579
+ async function* recordPages(client, storeId, request) {
1580
+ let cursor = request.cursor;
1581
+ do {
1582
+ const page = await client.listRecords(storeId, { ...request, ...cursor ? { cursor } : {} });
1583
+ yield page;
1584
+ if (page.next_cursor && page.next_cursor === cursor) throw new Error("Record cursor did not advance");
1585
+ cursor = page.next_cursor;
1586
+ } while (cursor);
1587
+ }
1588
+ async function recordBatches(client, storeId, request, limits = {}) {
1589
+ const maxRecords = Math.min(limits.maxRecords ?? 100, 100);
1590
+ const maxBytes = Math.min(limits.maxBytes ?? 2 * 1024 * 1024, 2 * 1024 * 1024);
1591
+ if (!Number.isInteger(maxRecords) || maxRecords < 1 || !Number.isInteger(maxBytes) || maxBytes < 1) throw new Error("Invalid batching limits");
1592
+ if (!request.records.length) throw new Error("At least one record is required");
1593
+ if (new Set(request.records.map((record) => record.id)).size !== request.records.length) throw new Error("Duplicate record IDs");
1594
+ const batches = [];
1595
+ let records = [];
1596
+ const size = (items) => new TextEncoder().encode(JSON.stringify({ namespace: request.namespace, records: items })).byteLength;
1597
+ for (const record of request.records) {
1598
+ if (size([record]) > maxBytes) throw new Error("A record exceeds the request byte limit");
1599
+ if (records.length === maxRecords || size([...records, record]) > maxBytes) {
1600
+ batches.push({ namespace: request.namespace, records });
1601
+ records = [];
1602
+ }
1603
+ records.push(record);
1604
+ }
1605
+ if (records.length) batches.push({ namespace: request.namespace, records });
1606
+ const result = { acknowledged_ids: [], failed_ids: [], unknown_ids: [] };
1607
+ for (let index = 0; index < batches.length; index++) {
1608
+ const batch = batches[index];
1609
+ try {
1610
+ const receipt = await client.upsertRecords(storeId, batch);
1611
+ const ids = batch.records.map((record) => record.id);
1612
+ if (!receipt.acknowledged || !receipt.acknowledged_ids || receipt.acknowledged_ids.length !== ids.length || new Set(receipt.acknowledged_ids).size !== ids.length || ids.some((id) => !receipt.acknowledged_ids.includes(id))) {
1613
+ throw new Agents24SDKError("Incomplete record acknowledgement", { kind: "protocol" });
1614
+ }
1615
+ result.acknowledged_ids.push(...ids);
1616
+ } catch (error) {
1617
+ const rejected = error instanceof Agents24SDKError && error.kind === "http" && error.failure && (error.status ?? 500) < 500 && error.code !== "KNOWLEDGE_STORE_OPERATION_UNKNOWN";
1618
+ result[rejected ? "failed_ids" : "unknown_ids"].push(...batch.records.map((record) => record.id));
1619
+ result.failed_ids.push(...batches.slice(index + 1).flatMap((item) => item.records.map((record) => record.id)));
1620
+ if (error instanceof Agents24SDKError && error.failure) result.failure = error.failure;
1621
+ break;
1622
+ }
1623
+ }
1624
+ return result;
1625
+ }
1626
+
1537
1627
  // src/generated/knowledgeStores.ts
1538
1628
  var KnowledgeStoresNamespace = class {
1539
1629
  constructor(http) {
@@ -1610,6 +1700,62 @@ var KnowledgeStoresNamespace = class {
1610
1700
  mutation: true
1611
1701
  });
1612
1702
  }
1703
+ upsertRecords(storeId, request) {
1704
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/upsert`, {
1705
+ method: "POST",
1706
+ body: request
1707
+ });
1708
+ }
1709
+ fetchRecords(storeId, request) {
1710
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/fetch`, {
1711
+ method: "POST",
1712
+ body: request
1713
+ });
1714
+ }
1715
+ listRecords(storeId, request) {
1716
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/list`, {
1717
+ method: "POST",
1718
+ body: request
1719
+ });
1720
+ }
1721
+ queryRecords(storeId, request) {
1722
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/query`, {
1723
+ method: "POST",
1724
+ body: request
1725
+ });
1726
+ }
1727
+ updateRecord(storeId, request) {
1728
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/update`, {
1729
+ method: "POST",
1730
+ body: request
1731
+ });
1732
+ }
1733
+ deleteRecords(storeId, request) {
1734
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/records/delete`, {
1735
+ method: "POST",
1736
+ body: request
1737
+ });
1738
+ }
1739
+ listNamespaces(storeId, options = {}) {
1740
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/namespaces`, {
1741
+ query: {
1742
+ limit: options.limit ?? 100,
1743
+ cursor: options.cursor
1744
+ }
1745
+ });
1746
+ }
1747
+ namespaceStats(storeId, request) {
1748
+ return this.http.requestJson(`/admin/knowledge-stores/${encodeURIComponent(storeId)}/namespaces/stats`, {
1749
+ method: "POST",
1750
+ body: request
1751
+ });
1752
+ }
1753
+ listRecordPages(storeId, request) {
1754
+ return recordPages(this, storeId, request);
1755
+ }
1756
+ upsertRecordsBatched(storeId, request, limits = {}) {
1757
+ return recordBatches(this, storeId, request, limits);
1758
+ }
1613
1759
  };
1614
1760
 
1615
1761
  // src/generated/integration-namespaces.ts
@@ -1774,10 +1920,16 @@ var SDK_OPERATION_IDS = [
1774
1920
  "ingestionJobs.cancel",
1775
1921
  "ingestionJobs.complete_upload",
1776
1922
  "ingestionJobs.create_upload",
1923
+ "ingestionJobs.download_step_data",
1777
1924
  "ingestionJobs.get",
1925
+ "ingestionJobs.get_processed_content",
1926
+ "ingestionJobs.get_result",
1927
+ "ingestionJobs.get_step_data",
1928
+ "ingestionJobs.get_step_field",
1778
1929
  "ingestionJobs.get_upload",
1779
1930
  "ingestionJobs.list",
1780
1931
  "ingestionJobs.list_batches",
1932
+ "ingestionJobs.list_steps",
1781
1933
  "ingestionJobs.put_upload_part",
1782
1934
  "ingestionJobs.resume",
1783
1935
  "ingestionJobs.start",
@@ -1787,14 +1939,22 @@ var SDK_OPERATION_IDS = [
1787
1939
  "knowledgeStores.cancel_cleanup_job",
1788
1940
  "knowledgeStores.create",
1789
1941
  "knowledgeStores.delete_indexed_content",
1942
+ "knowledgeStores.delete_records",
1943
+ "knowledgeStores.fetch_records",
1790
1944
  "knowledgeStores.get",
1791
1945
  "knowledgeStores.get_cleanup_job",
1792
1946
  "knowledgeStores.get_indexed_content",
1793
1947
  "knowledgeStores.list",
1794
1948
  "knowledgeStores.list_indexed_content",
1949
+ "knowledgeStores.list_namespaces",
1950
+ "knowledgeStores.list_records",
1951
+ "knowledgeStores.namespace_stats",
1952
+ "knowledgeStores.query_records",
1795
1953
  "knowledgeStores.resume_cleanup_job",
1796
1954
  "knowledgeStores.stats",
1797
1955
  "knowledgeStores.update",
1956
+ "knowledgeStores.update_record",
1957
+ "knowledgeStores.upsert_records",
1798
1958
  "pipelines.get",
1799
1959
  "pipelines.get_input_schema",
1800
1960
  "pipelines.get_published_executable",