@lunnoa/client 1.2.0 → 1.3.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/README.md CHANGED
@@ -113,6 +113,8 @@ Most namespaces map to the Public API surface (`openapi.public.json`):
113
113
 
114
114
  `approvals` uses the authenticated **workspace** API (`/api/approvals/...`), not Public API v1. The inbox is filtered to requests where the current user is an eligible approver.
115
115
 
116
+ `scorecards` also uses the workspace API (`/api/scorecards/...`): `list`, `get`, and `recordValue(measureId, { value, period?, note? })` to push a measure value from your own system (API key needs `scorecard:record`).
117
+
116
118
  Errors are `LunnoaApiError` with `status`, `body`, and convenience flags (`isUnauthorized`, `isForbidden`, `isRateLimited`). Paginated lists have async iteration (`entities.iterate(...)`, `queueItems.iterate(...)`).
117
119
 
118
120
  ## Worked examples
package/dist/cli.js CHANGED
@@ -430,10 +430,7 @@ var AgentChatClient = class {
430
430
  raw: true,
431
431
  signal: options.signal,
432
432
  headers: { Accept: "text/event-stream" },
433
- body: {
434
- messages: [uiMessage],
435
- ...options.chatMode ? { chatMode: options.chatMode } : {}
436
- }
433
+ body: messageTaskBody(uiMessage, options)
437
434
  }
438
435
  );
439
436
  return new AgentChatStream(response, { signal: options.signal });
@@ -472,6 +469,14 @@ var AgentChatClient = class {
472
469
  );
473
470
  }
474
471
  };
472
+ function messageTaskBody(message, options = {}) {
473
+ return {
474
+ messages: [message],
475
+ ...options.chatMode ? { chatMode: options.chatMode } : {},
476
+ ...options.data ? { data: options.data } : {},
477
+ ...options.piiResolution ? { piiResolution: options.piiResolution } : {}
478
+ };
479
+ }
475
480
  function generateMessageId() {
476
481
  const cryptoObj = globalThis.crypto;
477
482
  if (cryptoObj?.randomUUID) {
@@ -1005,7 +1010,6 @@ var EntitiesResource = class {
1005
1010
  objectTypeSlug: options.objectTypeSlug,
1006
1011
  state: options.state,
1007
1012
  states: options.states?.join(","),
1008
- ownerId: options.ownerId,
1009
1013
  search: options.search,
1010
1014
  sortBy: options.sortBy,
1011
1015
  sortOrder: options.sortOrder,
@@ -1601,10 +1605,11 @@ var QueueItemsResource = class {
1601
1605
  listRetryable(queueId) {
1602
1606
  return this.http.get(`/api/queues/${queueId}/items/retry`);
1603
1607
  }
1604
- /** Returns items with the given status. */
1605
- listByStatus(queueId, status) {
1608
+ /** Returns a page of items with the given status. */
1609
+ listByStatus(queueId, status, options = {}) {
1606
1610
  return this.http.get(
1607
- `/api/queues/${queueId}/items/status/${status}`
1611
+ `/api/queues/${queueId}/items/status/${status}`,
1612
+ { query: { limit: options.limit, offset: options.offset } }
1608
1613
  );
1609
1614
  }
1610
1615
  /** Looks an item up by the external ID your system supplied. */
@@ -1613,11 +1618,22 @@ var QueueItemsResource = class {
1613
1618
  `/api/queues/${queueId}/items/external/${externalId}`
1614
1619
  );
1615
1620
  }
1616
- /** Searches items in the queue. */
1617
- search(queueId, query) {
1618
- return this.http.get(`/api/queues/${queueId}/items/search`, {
1619
- query: { q: query }
1620
- });
1621
+ /**
1622
+ * Searches items by external id, item data, and metadata.
1623
+ * Returns one page, same shape as `list`.
1624
+ */
1625
+ search(queueId, query, options = {}) {
1626
+ return this.http.get(
1627
+ `/api/queues/${queueId}/items/search`,
1628
+ {
1629
+ query: {
1630
+ limit: options.limit,
1631
+ offset: options.offset,
1632
+ expansion: serializeCsv(options.expansion),
1633
+ filterBy: serializeFilterBy({ search: query })
1634
+ }
1635
+ }
1636
+ );
1621
1637
  }
1622
1638
  /** Returns per-status and per-priority counts for the queue. */
1623
1639
  stats(queueId) {
@@ -1653,10 +1669,21 @@ var QueueItemsResource = class {
1653
1669
  addError(queueId, itemId, error) {
1654
1670
  return this.http.post(
1655
1671
  `/api/queues/${queueId}/items/${itemId}/error`,
1656
- { body: error }
1672
+ {
1673
+ body: {
1674
+ error: error.error,
1675
+ errorDetails: serializeErrorDetails(error.errorDetails)
1676
+ }
1677
+ }
1657
1678
  );
1658
1679
  }
1659
1680
  };
1681
+ function serializeErrorDetails(value) {
1682
+ if (value === void 0) {
1683
+ return void 0;
1684
+ }
1685
+ return typeof value === "string" ? value : JSON.stringify(value);
1686
+ }
1660
1687
 
1661
1688
  // src/resources/queues.ts
1662
1689
  var QueuesResource = class {
@@ -1783,6 +1810,32 @@ var RunsResource = class {
1783
1810
  }
1784
1811
  };
1785
1812
 
1813
+ // src/resources/scorecards.ts
1814
+ var ScorecardsResource = class {
1815
+ constructor(http) {
1816
+ this.http = http;
1817
+ }
1818
+ http;
1819
+ /** Lists scorecards in the workspace. */
1820
+ list() {
1821
+ return this.http.get("/api/scorecards");
1822
+ }
1823
+ /** Returns a scorecard with objectives, measures, latest values and status. */
1824
+ get(scorecardId) {
1825
+ return this.http.get(`/api/scorecards/${scorecardId}`);
1826
+ }
1827
+ /**
1828
+ * Records a measure value. A value for the same period replaces the current
1829
+ * one; the old value is kept as superseded history.
1830
+ */
1831
+ recordValue(measureId, data) {
1832
+ return this.http.post(
1833
+ `/api/scorecards/measures/${measureId}/values`,
1834
+ { body: data }
1835
+ );
1836
+ }
1837
+ };
1838
+
1786
1839
  // src/resources/tasks.ts
1787
1840
  var TasksResource = class {
1788
1841
  constructor(http) {
@@ -1833,12 +1886,7 @@ var TasksResource = class {
1833
1886
  } : message;
1834
1887
  return this.http.post(
1835
1888
  `/api/agents/${agentId}/tasks/${taskId}/message`,
1836
- {
1837
- body: {
1838
- messages: [uiMessage],
1839
- ...options.chatMode ? { chatMode: options.chatMode } : {}
1840
- }
1841
- }
1889
+ { body: messageTaskBody(uiMessage, options) }
1842
1890
  );
1843
1891
  }
1844
1892
  };
@@ -2021,6 +2069,7 @@ var LunnoaClient = class {
2021
2069
  queues;
2022
2070
  queueItems;
2023
2071
  variables;
2072
+ scorecards;
2024
2073
  connections;
2025
2074
  projects;
2026
2075
  workflowApps;
@@ -2043,6 +2092,7 @@ var LunnoaClient = class {
2043
2092
  this.queues = new QueuesResource(this.http);
2044
2093
  this.queueItems = new QueueItemsResource(this.http);
2045
2094
  this.variables = new VariablesResource(this.http);
2095
+ this.scorecards = new ScorecardsResource(this.http);
2046
2096
  this.connections = new ConnectionsResource(this.http);
2047
2097
  this.projects = new ProjectsResource(this.http);
2048
2098
  this.discovery = new DiscoveryResource(this.http);
@@ -2831,7 +2881,7 @@ function generateDeploymentModule(definitions) {
2831
2881
  *
2832
2882
  * Schema fingerprint: ${schemaFingerprint}
2833
2883
  */
2834
- import type { LunnoaClient, Entity, Execution, ExecuteWorkflowResult, PaginatedEntities, Task, AgentChatStream, WaitUntilFinishedOptions, ListEntitiesOptions, UIMessage } from '@lunnoa/client';
2884
+ import type { LunnoaClient, Entity, Execution, ExecuteWorkflowResult, PaginatedEntities, Task, AgentChatStream, WaitUntilFinishedOptions, ListEntitiesOptions, StreamMessageOptions, UIMessage } from '@lunnoa/client';
2835
2885
 
2836
2886
  /** Fingerprint of entity-type schemas at codegen time (slug:revision:allowUnknown). */
2837
2887
  export const DEPLOYMENT_SCHEMA_FINGERPRINT = ${JSON.stringify(schemaFingerprint)};
@@ -3019,7 +3069,7 @@ function typedEntityAccessor<A, S extends string>(
3019
3069
  })) as Typed;
3020
3070
  },
3021
3071
  /** Creates an entity of this type with compile-time checked attributes. */
3022
- async create(data: { name: string; attributes?: A; state?: S; ownerId?: string }): Promise<Typed> {
3072
+ async create(data: { name: string; attributes?: A; state?: S }): Promise<Typed> {
3023
3073
  return (await client.entities.create(
3024
3074
  { ...data, objectTypeId } as never,
3025
3075
  { expansion: ['attributes'] },
@@ -3028,7 +3078,7 @@ function typedEntityAccessor<A, S extends string>(
3028
3078
  /** Partially updates an entity of this type. */
3029
3079
  async update(
3030
3080
  entityId: string,
3031
- data: { name?: string; attributes?: Partial<A>; ownerId?: string },
3081
+ data: { name?: string; attributes?: Partial<A> },
3032
3082
  ): Promise<Typed> {
3033
3083
  return (await client.entities.update(entityId, data as never, {
3034
3084
  expansion: ['attributes'],
@@ -3074,13 +3124,17 @@ function typedAgentAccessor(client: LunnoaClient, agentId: string) {
3074
3124
  streamMessage(
3075
3125
  taskId: string,
3076
3126
  message: string | UIMessage,
3077
- options?: { chatMode?: 'builder' | 'preview'; signal?: AbortSignal },
3127
+ options?: StreamMessageOptions,
3078
3128
  ): Promise<AgentChatStream> {
3079
3129
  return client.agentChat.streamMessage(agentId, taskId, message, options);
3080
3130
  },
3081
3131
  /** Sends a message and waits for the full turn (non-streaming). */
3082
- message(taskId: string, message: string | UIMessage) {
3083
- return client.tasks.message(agentId, taskId, message);
3132
+ message(
3133
+ taskId: string,
3134
+ message: string | UIMessage,
3135
+ options?: Omit<StreamMessageOptions, 'signal'>,
3136
+ ) {
3137
+ return client.tasks.message(agentId, taskId, message, options);
3084
3138
  },
3085
3139
  };
3086
3140
  }
package/dist/index.cjs CHANGED
@@ -426,10 +426,7 @@ var AgentChatClient = class {
426
426
  raw: true,
427
427
  signal: options.signal,
428
428
  headers: { Accept: "text/event-stream" },
429
- body: {
430
- messages: [uiMessage],
431
- ...options.chatMode ? { chatMode: options.chatMode } : {}
432
- }
429
+ body: messageTaskBody(uiMessage, options)
433
430
  }
434
431
  );
435
432
  return new AgentChatStream(response, { signal: options.signal });
@@ -468,6 +465,14 @@ var AgentChatClient = class {
468
465
  );
469
466
  }
470
467
  };
468
+ function messageTaskBody(message, options = {}) {
469
+ return {
470
+ messages: [message],
471
+ ...options.chatMode ? { chatMode: options.chatMode } : {},
472
+ ...options.data ? { data: options.data } : {},
473
+ ...options.piiResolution ? { piiResolution: options.piiResolution } : {}
474
+ };
475
+ }
471
476
  function generateMessageId() {
472
477
  const cryptoObj = globalThis.crypto;
473
478
  if (cryptoObj?.randomUUID) {
@@ -1047,7 +1052,6 @@ var EntitiesResource = class {
1047
1052
  objectTypeSlug: options.objectTypeSlug,
1048
1053
  state: options.state,
1049
1054
  states: options.states?.join(","),
1050
- ownerId: options.ownerId,
1051
1055
  search: options.search,
1052
1056
  sortBy: options.sortBy,
1053
1057
  sortOrder: options.sortOrder,
@@ -1643,10 +1647,11 @@ var QueueItemsResource = class {
1643
1647
  listRetryable(queueId) {
1644
1648
  return this.http.get(`/api/queues/${queueId}/items/retry`);
1645
1649
  }
1646
- /** Returns items with the given status. */
1647
- listByStatus(queueId, status) {
1650
+ /** Returns a page of items with the given status. */
1651
+ listByStatus(queueId, status, options = {}) {
1648
1652
  return this.http.get(
1649
- `/api/queues/${queueId}/items/status/${status}`
1653
+ `/api/queues/${queueId}/items/status/${status}`,
1654
+ { query: { limit: options.limit, offset: options.offset } }
1650
1655
  );
1651
1656
  }
1652
1657
  /** Looks an item up by the external ID your system supplied. */
@@ -1655,11 +1660,22 @@ var QueueItemsResource = class {
1655
1660
  `/api/queues/${queueId}/items/external/${externalId}`
1656
1661
  );
1657
1662
  }
1658
- /** Searches items in the queue. */
1659
- search(queueId, query) {
1660
- return this.http.get(`/api/queues/${queueId}/items/search`, {
1661
- query: { q: query }
1662
- });
1663
+ /**
1664
+ * Searches items by external id, item data, and metadata.
1665
+ * Returns one page, same shape as `list`.
1666
+ */
1667
+ search(queueId, query, options = {}) {
1668
+ return this.http.get(
1669
+ `/api/queues/${queueId}/items/search`,
1670
+ {
1671
+ query: {
1672
+ limit: options.limit,
1673
+ offset: options.offset,
1674
+ expansion: serializeCsv(options.expansion),
1675
+ filterBy: serializeFilterBy({ search: query })
1676
+ }
1677
+ }
1678
+ );
1663
1679
  }
1664
1680
  /** Returns per-status and per-priority counts for the queue. */
1665
1681
  stats(queueId) {
@@ -1695,10 +1711,21 @@ var QueueItemsResource = class {
1695
1711
  addError(queueId, itemId, error) {
1696
1712
  return this.http.post(
1697
1713
  `/api/queues/${queueId}/items/${itemId}/error`,
1698
- { body: error }
1714
+ {
1715
+ body: {
1716
+ error: error.error,
1717
+ errorDetails: serializeErrorDetails(error.errorDetails)
1718
+ }
1719
+ }
1699
1720
  );
1700
1721
  }
1701
1722
  };
1723
+ function serializeErrorDetails(value) {
1724
+ if (value === void 0) {
1725
+ return void 0;
1726
+ }
1727
+ return typeof value === "string" ? value : JSON.stringify(value);
1728
+ }
1702
1729
 
1703
1730
  // src/resources/queues.ts
1704
1731
  var QueuesResource = class {
@@ -1825,6 +1852,32 @@ var RunsResource = class {
1825
1852
  }
1826
1853
  };
1827
1854
 
1855
+ // src/resources/scorecards.ts
1856
+ var ScorecardsResource = class {
1857
+ constructor(http) {
1858
+ this.http = http;
1859
+ }
1860
+ http;
1861
+ /** Lists scorecards in the workspace. */
1862
+ list() {
1863
+ return this.http.get("/api/scorecards");
1864
+ }
1865
+ /** Returns a scorecard with objectives, measures, latest values and status. */
1866
+ get(scorecardId) {
1867
+ return this.http.get(`/api/scorecards/${scorecardId}`);
1868
+ }
1869
+ /**
1870
+ * Records a measure value. A value for the same period replaces the current
1871
+ * one; the old value is kept as superseded history.
1872
+ */
1873
+ recordValue(measureId, data) {
1874
+ return this.http.post(
1875
+ `/api/scorecards/measures/${measureId}/values`,
1876
+ { body: data }
1877
+ );
1878
+ }
1879
+ };
1880
+
1828
1881
  // src/resources/tasks.ts
1829
1882
  var TasksResource = class {
1830
1883
  constructor(http) {
@@ -1875,12 +1928,7 @@ var TasksResource = class {
1875
1928
  } : message;
1876
1929
  return this.http.post(
1877
1930
  `/api/agents/${agentId}/tasks/${taskId}/message`,
1878
- {
1879
- body: {
1880
- messages: [uiMessage],
1881
- ...options.chatMode ? { chatMode: options.chatMode } : {}
1882
- }
1883
- }
1931
+ { body: messageTaskBody(uiMessage, options) }
1884
1932
  );
1885
1933
  }
1886
1934
  };
@@ -2063,6 +2111,7 @@ var LunnoaClient = class {
2063
2111
  queues;
2064
2112
  queueItems;
2065
2113
  variables;
2114
+ scorecards;
2066
2115
  connections;
2067
2116
  projects;
2068
2117
  workflowApps;
@@ -2085,6 +2134,7 @@ var LunnoaClient = class {
2085
2134
  this.queues = new QueuesResource(this.http);
2086
2135
  this.queueItems = new QueueItemsResource(this.http);
2087
2136
  this.variables = new VariablesResource(this.http);
2137
+ this.scorecards = new ScorecardsResource(this.http);
2088
2138
  this.connections = new ConnectionsResource(this.http);
2089
2139
  this.projects = new ProjectsResource(this.http);
2090
2140
  this.discovery = new DiscoveryResource(this.http);
@@ -2186,6 +2236,7 @@ exports.ProjectsResource = ProjectsResource;
2186
2236
  exports.QueueItemsResource = QueueItemsResource;
2187
2237
  exports.QueuesResource = QueuesResource;
2188
2238
  exports.RunsResource = RunsResource;
2239
+ exports.ScorecardsResource = ScorecardsResource;
2189
2240
  exports.SsoAuthResource = SsoAuthResource;
2190
2241
  exports.TasksResource = TasksResource;
2191
2242
  exports.VariablesResource = VariablesResource;