lua-cli 3.23.2 → 3.24.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.
@@ -1046,6 +1046,22 @@ export declare interface ChatHistoryMessage {
1046
1046
  */
1047
1047
  export declare type ChatMessage = TextMessage | ImageMessage | FileMessage;
1048
1048
 
1049
+ /**
1050
+ * Options for creating a custom data entry.
1051
+ */
1052
+ declare interface CreateCustomDataOptions {
1053
+ /** Text used for semantic (vector) search indexing of this entry. */
1054
+ searchText?: string;
1055
+ /**
1056
+ * Declare `data` fields this agent queries with filters, so the platform
1057
+ * maintains agent-scoped database indexes for them. Entries are a single
1058
+ * field path (`'business_id'`) or a compound of up to 2 paths
1059
+ * (`['country', 'business_id']`). Idempotent — declare on every write; an
1060
+ * index whose declaration stops arriving is removed after ~14 days.
1061
+ */
1062
+ index?: Array<string | string[]>;
1063
+ }
1064
+
1049
1065
  /**
1050
1066
  * Response from creating custom data entry.
1051
1067
  * Includes optional similarity score for search results.
@@ -1096,7 +1112,8 @@ declare interface CustomDataAPI {
1096
1112
  * @param searchText - Optional text for vector search indexing
1097
1113
  * @returns Promise resolving to created entry (DataEntryInstance)
1098
1114
  */
1099
- create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
1115
+ collections(): Promise<CustomDataCollectionsResponse>;
1116
+ create(collectionName: string, data: Record<string, any>, optionsOrSearchText?: string | CreateCustomDataOptions): Promise<DataEntryInstance>;
1100
1117
  /**
1101
1118
  * Gets entries from a collection with filtering and pagination.
1102
1119
  * @param collectionName - Collection name
@@ -1121,7 +1138,7 @@ declare interface CustomDataAPI {
1121
1138
  * @param searchText - Optional text for vector search indexing
1122
1139
  * @returns Promise resolving to update response
1123
1140
  */
1124
- update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
1141
+ update(collectionName: string, entryId: string, data: Record<string, any>, optionsOrSearchText?: string | CreateCustomDataOptions): Promise<UpdateCustomDataResponse>;
1125
1142
  /** Atomically sets and removes top-level entry fields and optionally changes search text. */
1126
1143
  patch(collectionName: string, entryId: string, mutation: {
1127
1144
  set?: Record<string, any>;
@@ -1146,6 +1163,29 @@ declare interface CustomDataAPI {
1146
1163
  delete(collectionName: string, entryId: string): Promise<DeleteCustomDataResponse>;
1147
1164
  }
1148
1165
 
1166
+ /** One collection in the agent's Data namespace, from Data.collections(). */
1167
+ declare interface CustomDataCollectionInfo {
1168
+ name: string;
1169
+ entryCount: number;
1170
+ lastUpdatedAt: number;
1171
+ firstCreatedAt: number;
1172
+ /** Managed index declarations for this collection — present only when declared. */
1173
+ indexes?: CustomDataIndexStatus[];
1174
+ }
1175
+
1176
+ declare interface CustomDataCollectionsResponse {
1177
+ data: CustomDataCollectionInfo[];
1178
+ count: number;
1179
+ }
1180
+
1181
+ declare interface CustomDataEntry extends IdentifiedEntity, TimestampedEntity {
1182
+ id: string;
1183
+ data: Record<string, any>;
1184
+ createdAt: number;
1185
+ updatedAt: number;
1186
+ searchText?: string;
1187
+ }
1188
+
1149
1189
  /**
1150
1190
  * Custom data entry.
1151
1191
  * Represents a single entry in a custom data collection.
@@ -1155,12 +1195,15 @@ declare interface CustomDataAPI {
1155
1195
  * - Vector search via searchText
1156
1196
  * - Automatic timestamps
1157
1197
  */
1158
- declare interface CustomDataEntry extends IdentifiedEntity, TimestampedEntity {
1159
- id: string;
1160
- data: Record<string, any>;
1161
- createdAt: number;
1162
- updatedAt: number;
1163
- searchText?: string;
1198
+ /** Status of one managed index declaration, from the collections listing. */
1199
+ declare interface CustomDataIndexStatus {
1200
+ fields: string[];
1201
+ /** pending | building | ready | failed | rejected */
1202
+ status: string;
1203
+ /** Populated when status is failed/rejected — the reason, verbatim. */
1204
+ error?: string;
1205
+ lastDeclaredAt: number;
1206
+ lastUsedAt?: number;
1164
1207
  }
1165
1208
 
1166
1209
  /**
@@ -1168,18 +1211,59 @@ declare interface CustomDataEntry extends IdentifiedEntity, TimestampedEntity {
1168
1211
  * Store and retrieve custom data with vector search capabilities
1169
1212
  */
1170
1213
  export declare const Data: {
1214
+ /**
1215
+ * Lists this agent's data collections, including managed index status
1216
+ * (fields, pending/building/ready/failed/rejected, error reasons) for any
1217
+ * declared indexes — the fastest way to diagnose a declaration.
1218
+ *
1219
+ * @returns Promise resolving to `{ data: CustomDataCollectionInfo[], count }`
1220
+ */
1221
+ collections(): Promise<CustomDataCollectionsResponse>;
1171
1222
  /**
1172
1223
  * Creates a new entry in a custom data collection.
1173
1224
  *
1225
+ * Declaring indexes: if your agent FILTERS this collection (e.g.
1226
+ * `Data.get(c, { business_id: 123 })`), declare the filtered fields here so
1227
+ * the platform maintains an index for them:
1228
+ *
1229
+ * ```typescript
1230
+ * await Data.create('inference_cache', doc, { index: ['business_id'] });
1231
+ * // Compound index (fields queried together) — note the NESTED array:
1232
+ * await Data.create('inference_cache', doc, { index: [['country', 'business_id']] });
1233
+ * // ['country', 'business_id'] WITHOUT nesting = two separate single-field
1234
+ * // indexes, which will NOT serve a combined filter efficiently.
1235
+ * ```
1236
+ *
1237
+ * Index semantics — read before relying on them:
1238
+ * - Builds are ASYNCHRONOUS: allow minutes after first declaration before
1239
+ * expecting fast queries. Check status via `Data.collections()`.
1240
+ * - A compound index serves filters on its leftmost field(s) only:
1241
+ * `[['country','business_id']]` serves `{country}` and
1242
+ * `{country, business_id}`, but NOT `{business_id}` alone.
1243
+ * - Limits: 2 fields per index, 3 declarations per call, 5 indexes per
1244
+ * agent. Over-limit or invalid declarations are REJECTED (visible in
1245
+ * index status), never silently trimmed.
1246
+ * - Lifecycle: an index stays while your agent uses it (declaring writes OR
1247
+ * matching filtered reads keep it alive) and is removed ~14 days after
1248
+ * all usage stops. No cleanup code needed.
1249
+ *
1174
1250
  * @param collectionName - Name of the collection
1175
1251
  * @param data - Data to store
1176
- * @param searchText - Optional text for vector search indexing
1252
+ * @param optionsOrSearchText - Options object `{ searchText?, index? }`.
1253
+ * Passing a bare string (legacy) sets `searchText` only — easy to confuse
1254
+ * with an index declaration, so prefer the object form.
1177
1255
  * @returns Promise resolving to created entry
1178
1256
  */
1179
- create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
1257
+ create(collectionName: string, data: Record<string, any>, optionsOrSearchText?: string | CreateCustomDataOptions): Promise<DataEntryInstance>;
1180
1258
  /**
1181
1259
  * Retrieves entries from a collection with optional filtering and pagination.
1182
1260
  *
1261
+ * Filtering a LARGE collection? Declare the filtered fields where you store
1262
+ * data — `Data.create(c, doc, { index: ['your_field'] })` — or queries will
1263
+ * slow down as the collection grows and eventually fail with an error
1264
+ * message naming the unindexed field and the declaration to add. Filtered reads on a declared field keep its index
1265
+ * alive automatically.
1266
+ *
1183
1267
  * @param collectionName - Name of the collection
1184
1268
  * @param filter - Optional filter criteria
1185
1269
  * @param page - Page number (default: 1)
@@ -1204,7 +1288,7 @@ export declare const Data: {
1204
1288
  * @param searchText - Optional new search text for vector search indexing
1205
1289
  * @returns Promise resolving to update response
1206
1290
  */
1207
- update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
1291
+ update(collectionName: string, entryId: string, data: Record<string, any>, optionsOrSearchText?: string | CreateCustomDataOptions): Promise<UpdateCustomDataResponse>;
1208
1292
  /**
1209
1293
  * Performs vector search on a collection.
1210
1294
  *
@@ -4476,17 +4476,42 @@ var init_custom_data_api_service = __esm({
4476
4476
  this.agentId = agentId;
4477
4477
  }
4478
4478
  /**
4479
+ * Lists the agent's data collections with entry counts, timestamps, and —
4480
+ * when declared — managed index status (fields, pending/building/ready/
4481
+ * failed/rejected, error reason). The place to diagnose index declarations.
4482
+ * @returns Promise resolving to the collections listing
4483
+ */
4484
+ async collections() {
4485
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {
4486
+ Authorization: `Bearer ${this.apiKey}`
4487
+ });
4488
+ if (response.success && response.data) {
4489
+ return response.data;
4490
+ }
4491
+ throw new Error(response.error?.message || "Failed to list custom data collections");
4492
+ }
4493
+ /**
4479
4494
  * Creates a new custom data entry in a specified collection
4480
4495
  * @param collectionName - The name of the collection to create the entry in
4481
4496
  * @param data - The data object to store in the entry
4482
- * @param searchText - Optional text to be used for semantic search indexing
4497
+ * @param optionsOrSearchText - Either a searchText string (legacy form) or an
4498
+ * options object: `searchText` for semantic search indexing, and `index` to
4499
+ * declare data fields this agent filters on (e.g. `['business_id']` or
4500
+ * compounds like `[['country', 'business_id']]`). Declared fields get
4501
+ * agent-scoped database indexes maintained by the platform: created when
4502
+ * first declared, removed automatically ~14 days after the code stops
4503
+ * declaring them. Declaring on every write is the intended, idempotent use.
4483
4504
  * @returns Promise resolving to a DataEntryInstance representing the created entry
4484
4505
  * @throws Error if the entry creation fails or the API request is unsuccessful
4485
4506
  */
4486
- async create(collectionName, data, searchText) {
4507
+ async create(collectionName, data, optionsOrSearchText) {
4508
+ const options = typeof optionsOrSearchText === "string" ? {
4509
+ searchText: optionsOrSearchText
4510
+ } : optionsOrSearchText ?? {};
4487
4511
  const response = await this.httpPost(`/developer/agents/${this.agentId}/custom-data/${collectionName}`, {
4488
4512
  data,
4489
- searchText
4513
+ searchText: options.searchText,
4514
+ index: options.index
4490
4515
  }, {
4491
4516
  Authorization: `Bearer ${this.apiKey}`
4492
4517
  });
@@ -4539,14 +4564,19 @@ var init_custom_data_api_service = __esm({
4539
4564
  * @param collectionName - The name of the collection containing the entry
4540
4565
  * @param entryId - The unique identifier of the entry to update
4541
4566
  * @param data - The data object to update
4542
- * @param searchText - Optional text to be used for semantic search indexing
4567
+ * @param optionsOrSearchText - searchText string (legacy) or { searchText?, index? };
4568
+ * `index` refreshes this agent's index declarations (same semantics as create)
4543
4569
  * @returns Promise resolving to an UpdateCustomDataResponse with the updated entry details
4544
4570
  * @throws Error if the entry is not found or the update fails
4545
4571
  */
4546
- async update(collectionName, entryId, data, searchText) {
4572
+ async update(collectionName, entryId, data, optionsOrSearchText) {
4573
+ const options = typeof optionsOrSearchText === "string" ? {
4574
+ searchText: optionsOrSearchText
4575
+ } : optionsOrSearchText ?? {};
4547
4576
  const response = await this.httpPut(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
4548
4577
  data,
4549
- searchText
4578
+ searchText: options.searchText,
4579
+ index: options.index
4550
4580
  }, {
4551
4581
  Authorization: `Bearer ${this.apiKey}`
4552
4582
  });
@@ -6893,21 +6923,65 @@ var User = {
6893
6923
  }
6894
6924
  };
6895
6925
  var Data = {
6926
+ /**
6927
+ * Lists this agent's data collections, including managed index status
6928
+ * (fields, pending/building/ready/failed/rejected, error reasons) for any
6929
+ * declared indexes — the fastest way to diagnose a declaration.
6930
+ *
6931
+ * @returns Promise resolving to `{ data: CustomDataCollectionInfo[], count }`
6932
+ */
6933
+ async collections() {
6934
+ const instance = await getDataInstance();
6935
+ return instance.collections();
6936
+ },
6896
6937
  /**
6897
6938
  * Creates a new entry in a custom data collection.
6898
6939
  *
6940
+ * Declaring indexes: if your agent FILTERS this collection (e.g.
6941
+ * `Data.get(c, { business_id: 123 })`), declare the filtered fields here so
6942
+ * the platform maintains an index for them:
6943
+ *
6944
+ * ```typescript
6945
+ * await Data.create('inference_cache', doc, { index: ['business_id'] });
6946
+ * // Compound index (fields queried together) — note the NESTED array:
6947
+ * await Data.create('inference_cache', doc, { index: [['country', 'business_id']] });
6948
+ * // ['country', 'business_id'] WITHOUT nesting = two separate single-field
6949
+ * // indexes, which will NOT serve a combined filter efficiently.
6950
+ * ```
6951
+ *
6952
+ * Index semantics — read before relying on them:
6953
+ * - Builds are ASYNCHRONOUS: allow minutes after first declaration before
6954
+ * expecting fast queries. Check status via `Data.collections()`.
6955
+ * - A compound index serves filters on its leftmost field(s) only:
6956
+ * `[['country','business_id']]` serves `{country}` and
6957
+ * `{country, business_id}`, but NOT `{business_id}` alone.
6958
+ * - Limits: 2 fields per index, 3 declarations per call, 5 indexes per
6959
+ * agent. Over-limit or invalid declarations are REJECTED (visible in
6960
+ * index status), never silently trimmed.
6961
+ * - Lifecycle: an index stays while your agent uses it (declaring writes OR
6962
+ * matching filtered reads keep it alive) and is removed ~14 days after
6963
+ * all usage stops. No cleanup code needed.
6964
+ *
6899
6965
  * @param collectionName - Name of the collection
6900
6966
  * @param data - Data to store
6901
- * @param searchText - Optional text for vector search indexing
6967
+ * @param optionsOrSearchText - Options object `{ searchText?, index? }`.
6968
+ * Passing a bare string (legacy) sets `searchText` only — easy to confuse
6969
+ * with an index declaration, so prefer the object form.
6902
6970
  * @returns Promise resolving to created entry
6903
6971
  */
6904
- async create(collectionName, data, searchText) {
6972
+ async create(collectionName, data, optionsOrSearchText) {
6905
6973
  const instance = await getDataInstance();
6906
- return instance.create(collectionName, data, searchText);
6974
+ return instance.create(collectionName, data, optionsOrSearchText);
6907
6975
  },
6908
6976
  /**
6909
6977
  * Retrieves entries from a collection with optional filtering and pagination.
6910
6978
  *
6979
+ * Filtering a LARGE collection? Declare the filtered fields where you store
6980
+ * data — `Data.create(c, doc, { index: ['your_field'] })` — or queries will
6981
+ * slow down as the collection grows and eventually fail with an error
6982
+ * message naming the unindexed field and the declaration to add. Filtered reads on a declared field keep its index
6983
+ * alive automatically.
6984
+ *
6911
6985
  * @param collectionName - Name of the collection
6912
6986
  * @param filter - Optional filter criteria
6913
6987
  * @param page - Page number (default: 1)
@@ -6938,9 +7012,9 @@ var Data = {
6938
7012
  * @param searchText - Optional new search text for vector search indexing
6939
7013
  * @returns Promise resolving to update response
6940
7014
  */
6941
- async update(collectionName, entryId, data, searchText) {
7015
+ async update(collectionName, entryId, data, optionsOrSearchText) {
6942
7016
  const instance = await getDataInstance();
6943
- return instance.update(collectionName, entryId, data, searchText);
7017
+ return instance.update(collectionName, entryId, data, optionsOrSearchText);
6944
7018
  },
6945
7019
  /**
6946
7020
  * Performs vector search on a collection.