@kissflow/lowcode-client-sdk 1.0.44 → 1.0.50

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.
@@ -1,9 +1,14 @@
1
1
 
2
2
  declare class Form {
3
3
  type: string
4
+ instanceId: string
5
+ activityInstanceId: string
4
6
  toJSON(): any;
5
7
  getField(fieldId: string): any;
6
8
  updateField(args: object): any;
9
+ getValidationErrors(): any;
10
+ getFormConfiguration(): any;
11
+ getFieldState(): any;
7
12
  getTable(tableId: string): Table;
8
13
  }
9
14
  declare class Table {
@@ -87,6 +92,121 @@ declare class Client {
87
92
  * document.querySelector("#avatar").src = dataUrl;
88
93
  */
89
94
  getImageUrl(imageValue: Record<string, unknown>): any;
95
+ /**
96
+ * Open the platform's file picker, upload the selected file(s), and resolve
97
+ * with their metadata.
98
+ *
99
+ * Custom components (iframes) cannot access the platform's authenticated upload
100
+ * endpoints directly. This method opens the file picker in the parent window
101
+ * (which has the required session), runs the full select → upload flow, and
102
+ * resolves once all uploads settle with an array of the uploaded files'
103
+ * metadata (each including `key`, `name`, `size`, `photos`, etc. — the same
104
+ * shape consumed by `getImageUrl`).
105
+ *
106
+ * Always resolves with an array — a single-element array for single-file
107
+ * pickers (e.g. `maxCount: 1` for `Image`), one entry per uploaded file for
108
+ * multi-file pickers (e.g. `Attachment`). Resolves with `[]` if the user closes
109
+ * the picker without completing any upload.
110
+ *
111
+ * @param options - File picker configuration (e.g. `fileExtensions`, `maxSize`,
112
+ * `maxCount`, `imageProps`).
113
+ * @returns A promise that resolves with an array of uploaded file metadata
114
+ * objects (empty if the picker was closed without uploading anything).
115
+ *
116
+ * @example
117
+ * const files = await kf.client.openFilePicker({ fileExtensions: ["JPG", "PNG"] });
118
+ * if (files.length) onChange(files[0]); // single-file consumer (Image)
119
+ *
120
+ * @example
121
+ * const files = await kf.client.openFilePicker({ maxCount: 10 });
122
+ * if (files.length) onChange([...existing, ...files]); // multi-file consumer (Attachment)
123
+ */
124
+ openFilePicker(options: FilePickerOptions): any;
125
+ /**
126
+ * Open the platform's barcode/QR scanner and resolve with the decoded text.
127
+ *
128
+ * The scanner UI (camera stream + decoding) runs in the parent window, which
129
+ * owns the camera permission — the iframe itself never accesses the camera.
130
+ * Camera-permission prompts and denials are handled inside the scanner UI;
131
+ * they are not surfaced as errors here.
132
+ *
133
+ * Resolves with `null` if the user closes the scanner without a successful
134
+ * scan (including the scanner's own inactivity timeout).
135
+ *
136
+ * Note: currently supported in web custom app UIs; the mobile (PWA) custom
137
+ * UI does not host the scanner portal yet.
138
+ *
139
+ * @param options - Scanner configuration (e.g. `localFileScan` to allow
140
+ * decoding from an uploaded image instead of the camera).
141
+ * @returns A promise that resolves with the decoded string, or `null` if the
142
+ * scanner was closed without scanning.
143
+ *
144
+ * @example
145
+ * const code = await kf.client.openScanner({ localFileScan: true });
146
+ * if (code) onChange(code);
147
+ */
148
+ openScanner(options?: ScannerOptions): any;
149
+ /**
150
+ * Open the platform's native Geolocation map picker (search, current-location
151
+ * detection, marker drag, reverse-geocoding) in a modal over the custom
152
+ * form/component. Runs in the parent window, which owns the Google Maps API
153
+ * key — the iframe itself never needs one.
154
+ *
155
+ * Resolves with `null` if the user closes the picker without selecting a
156
+ * location.
157
+ *
158
+ * @param value - Optional current geolocation value to pre-select on the map.
159
+ * @returns A promise that resolves with the picked location object, or
160
+ * `null` if the picker was closed without a selection.
161
+ *
162
+ * @example
163
+ * const location = await kf.client.pickLocation();
164
+ * if (location) onChange(location);
165
+ */
166
+ pickLocation(value?: GeolocationValue): any;
167
+ /**
168
+ * Upload a File object to Kissflow's S3 storage and resolve with its metadata.
169
+ *
170
+ * Use this when you have a File/Blob already in memory (e.g. a canvas drawing
171
+ * converted to a PNG blob) and need to upload it without opening a file picker UI.
172
+ * The platform runs the upload in the parent window (which has the required session)
173
+ * and resolves with the uploaded file's `{ key, name, ... }` metadata — the same
174
+ * shape returned by `openFilePicker`.
175
+ *
176
+ * Resolves with `null` if the upload fails.
177
+ *
178
+ * @param file - The File or Blob to upload.
179
+ * @param fileName - Optional file name override (defaults to `file.name`).
180
+ * @returns A promise that resolves with the uploaded file metadata, or `null` on failure.
181
+ *
182
+ * @example
183
+ * const blob = await new Promise<Blob>(res => canvas.toBlob(res, 'image/png'));
184
+ * const file = new File([blob], 'signature.png', { type: 'image/png' });
185
+ * const result = await kf.client.uploadFile(file);
186
+ * if (result) onChange(result);
187
+ */
188
+ uploadFile(file: UploadableFile, fileName?: string): any;
189
+ /**
190
+ * Open the platform's file preview (lightbox) for one or more files.
191
+ *
192
+ * `files` always accepts an array — pass a single-element array for fields like
193
+ * `Image`, or the full list for multi-file fields like `Attachment`. The host's
194
+ * preview UI natively renders next/prev navigation across the array; the SDK
195
+ * just passes the file list through, no extra navigation surface is needed here.
196
+ *
197
+ * @param args - Preview configuration.
198
+ * @param args.files - Array of file metadata objects to preview.
199
+ * @param args.indexOfFile - Index of the file to open the preview on (default: 0).
200
+ * @returns A promise that resolves once the user closes the preview.
201
+ *
202
+ * @example
203
+ * await kf.client.openFilePreview({ files: [imageFieldValue] });
204
+ * await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });
205
+ */
206
+ openFilePreview(args: {
207
+ files: Record<string, unknown>[];
208
+ indexOfFile?: number;
209
+ }): any;
90
210
  }
91
211
  declare class Formatter {
92
212
  toDate(date: string): any;
@@ -117,16 +237,71 @@ declare class Page {
117
237
  _id: string
118
238
  popup: Popup
119
239
  type: string
240
+ _route: string
120
241
  getParameter(key: string): any;
121
242
  getAllParameters(): any;
122
243
  getVariable(key: string): any;
123
244
  setVariable(key: string | object, value?: any): any;
124
245
  openPopup(popupId: string, popupParams?: object): any;
125
246
  getComponent(componentId: string): Component;
247
+ /**
248
+ * Notify the Kissflow host that the custom UI navigated to `path`,
249
+ * so the parent browser URL mirrors the route. Used by the App UI framework.
250
+ */
251
+ setRoute(path: string): void;
252
+ /** Returns the initial deep-link route the page was opened with. */
253
+ getRoute(): string;
126
254
  }
127
255
  declare class DecisionTable {
128
256
  evaluate(payload?: object): any;
129
257
  }
258
+ declare class Agent {
259
+ /**
260
+ * Read the Agent's published contract: its inputs, outputs and readiness.
261
+ *
262
+ * @example
263
+ * const { Definition } = await kf.app.getAgent("AgXXXXXXXXXX").getContract();
264
+ */
265
+ getContract(): Promise<AgentContract>;
266
+ /**
267
+ * Start a run. Resolves once the run is accepted (`ExecutionId`, `Status`), not when it finishes;
268
+ * use {@link onExecutionComplete} or {@link getExecution} for the result.
269
+ *
270
+ * Never retried: if the call fails with `AGENT_EXECUTE_OUTCOME_UNKNOWN`, a run may still have
271
+ * started, and app code cannot list runs to find it: tell the user the request may still be in
272
+ * progress instead of starting another. `AGENT_EXECUTE_NOT_SENT` means it was not sent (for
273
+ * example, the user is offline).
274
+ *
275
+ * @example
276
+ * const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks", amount: 54000 } });
277
+ */
278
+ execute(options: AgentExecuteOptions): Promise<AgentExecutionAccepted>;
279
+ /**
280
+ * Read a run's current state, with its `Output` once `Completed` or its `Error` once `Failed`.
281
+ * Callers who are not the App's authors can read only their own runs.
282
+ */
283
+ getExecution(executionId: string): Promise<AgentExecution>;
284
+ /**
285
+ * Be told once when a run finishes. `onComplete` gets the run on `Completed` or `Failed` (read
286
+ * `Status`: a failed run is a result, not an error). `onWatchError` gets what stopped the
287
+ * observation instead: an unsupported host, an access or network failure, or the observation limit
288
+ * (`AGENT_OBSERVATION_STOPPED`, after about six minutes; the run may still finish, so read it later
289
+ * with {@link getExecution}). At most one of the two is called, at most once.
290
+ *
291
+ * Neither is called if the script that registered them stops first: form, field, gallery and
292
+ * table scripts stop after one minute, and they and page event scripts stop when the next script
293
+ * starts on the same form, component or page. In those scripts, keep the `ExecutionId` and read
294
+ * it later with {@link getExecution}.
295
+ *
296
+ * Returns a function that stops observing. It never cancels the run.
297
+ *
298
+ * @example
299
+ * const stop = agent.onExecutionComplete(ExecutionId, (run) => show(run), (err) => warn(err));
300
+ * // later, e.g. on unmount
301
+ * stop();
302
+ */
303
+ onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
304
+ }
130
305
  declare class Dataform {
131
306
  /**
132
307
  * Get all items from this dataform with optional filtering, sorting, and pagination
@@ -193,6 +368,30 @@ declare class Dataform {
193
368
  getFields(options?: {
194
369
  viewId?: string;
195
370
  }): Promise<any>;
371
+ /**
372
+ * Initialize a form with all necessary data (schema, item data, form store)
373
+ * This is the recommended way to create a custom form for dataform records
374
+ * It automatically handles fetching schema, item data, and initializing the form store
375
+ *
376
+ * @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
377
+ * @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
378
+ * @returns Promise with Form instance ready to use
379
+ *
380
+ * @example
381
+ * // Load existing record
382
+ * const dataform = kf.app.getDataform("EmpMaster");
383
+ * const form = await dataform.initForm("emp_123");
384
+ * const data = await form.toJSON();
385
+ *
386
+ * // Load existing record scoped to a view
387
+ * const form = await dataform.initForm("emp_123", "EmpMaster_View");
388
+ *
389
+ * // Create new record
390
+ * const form = await dataform.initForm();
391
+ * await form.updateField({ firstName: "John" });
392
+ */
393
+ initForm(instanceId?: string, viewId?: string): Promise<Form>;
394
+ getFieldOptions(options?: DataformFieldOptions): Promise<DataformQueryResponse>;
196
395
  }
197
396
  declare class Board {
198
397
  /**
@@ -271,6 +470,41 @@ declare class Board {
271
470
  getFields(options?: {
272
471
  viewId?: string;
273
472
  }): Promise<any>;
473
+ /**
474
+ * Initialize a form for a board item with all necessary setup
475
+ * Fetches schema, item data, creates and initializes the form store
476
+ *
477
+ * @param instanceId - Optional instance ID. If omitted, creates a new board item
478
+ * @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
479
+ * @returns Promise with Form instance ready to use
480
+ *
481
+ * @example
482
+ * // Create new board item
483
+ * const board = kf.app.getBoard("Inventory");
484
+ * const form = await board.initForm();
485
+ * await form.updateField({ Name: "New Item" });
486
+ *
487
+ * // Edit existing board item
488
+ * const form = await board.initForm("item_123");
489
+ * const data = await form.toJSON();
490
+ *
491
+ * // Edit existing board item scoped to a view
492
+ * const form = await board.initForm("item_123", "Inventory_View");
493
+ */
494
+ initForm(instanceId?: string, viewId?: string): Promise<Form>;
495
+ /**
496
+ * Get field options for dropdown/lookup fields
497
+ * @param options - Field options (instanceId, fieldId)
498
+ * @returns Promise containing the field options
499
+ *
500
+ * @example
501
+ * const board = kf.app.getBoard("Inventory");
502
+ * const options = await board.getFieldOptions({
503
+ * instanceId: "item_123",
504
+ * fieldId: "Category"
505
+ * });
506
+ */
507
+ getFieldOptions(options: BoardFieldOptions): Promise<any>;
274
508
  }
275
509
  declare class Process {
276
510
  /**
@@ -321,7 +555,7 @@ declare class Process {
321
555
  getAdminItems(options?: ProcessAdminOptions): Promise<ProcessQueryResponse>;
322
556
  /**
323
557
  * Get a single process instance by ID
324
- * @param options - instanceId (required)
558
+ * @param options - instanceId, activityInstanceId (both required)
325
559
  * @returns Promise containing the instance data
326
560
  */
327
561
  getItem(options: ProcessGetItemOptions): Promise<ProcessItem>;
@@ -359,6 +593,26 @@ declare class Process {
359
593
  * await process.deleteItem({ instanceId: "item_123" });
360
594
  */
361
595
  deleteItem(options: ProcessDeleteItemOptions): Promise<void>;
596
+ /**
597
+ * Get a single process instance as admin (requires admin access)
598
+ * @param options - instanceId (required)
599
+ * @returns Promise containing the instance data
600
+ *
601
+ * @example
602
+ * const process = kf.app.getProcess("LeaveRequest");
603
+ * const item = await process.getAdminItem({ instanceId: "item_123" });
604
+ */
605
+ getAdminItem(options: ProcessGetAdminItemOptions): Promise<ProcessItem>;
606
+ /**
607
+ * Update a process instance as admin (requires admin access)
608
+ * @param options - instanceId, data (required)
609
+ * @returns Promise containing the updated item
610
+ *
611
+ * @example
612
+ * const process = kf.app.getProcess("LeaveRequest");
613
+ * await process.updateAdminItem({ instanceId: "item_123", data: { LeaveType: "Sick" } });
614
+ */
615
+ updateAdminItem(options: ProcessUpdateAdminItemOptions): Promise<ProcessItem>;
362
616
  /**
363
617
  * Open the form UI for a process instance
364
618
  * @param item - Process item with _id and _activity_instance_id
@@ -457,6 +711,40 @@ declare class Process {
457
711
  getProgress(options: {
458
712
  instanceId: string;
459
713
  }): Promise<any>;
714
+ /**
715
+ * Initialize a form with all necessary data (schema, item data, form store)
716
+ * This is the recommended way to create a custom form for dataform records
717
+ * It automatically handles fetching schema, item data, and initializing the form store
718
+ *
719
+ * @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
720
+ * @returns Promise with Form instance ready to use
721
+ *
722
+ * @example
723
+ * // Load existing record
724
+ * const dataform = kf.app.getDataform("EmpMaster");
725
+ * const form = await dataform.initForm("emp_123");
726
+ * const data = await form.toJSON();
727
+ *
728
+ * // Create new record
729
+ * const form = await dataform.initForm();
730
+ * await form.updateField({ firstName: "John" });
731
+ */
732
+ initForm(instanceId?: string, activityInstanceId?: string): Promise<Form>;
733
+ getFieldOptions(options?: ProcessFieldOptions): Promise<ProcessQueryResponse>;
734
+ /**
735
+ * Trigger AI document parsing on an uploaded file for a Smart Attachment field.
736
+ * Matches native platform behavior: matching empty fields are auto-filled directly
737
+ * into the form store (respecting field permissions) — no separate apply step needed.
738
+ * Call `form.toJSON()` afterward to read the updated values.
739
+ *
740
+ * @example
741
+ * const form = await process.initForm();
742
+ * const files = await kf.client.openFilePicker({ fileExtensions: ["pdf"], maxCount: 1 });
743
+ * await form.updateField({ [fieldId]: files });
744
+ * await process.parseAttachment({ instanceId: form.instanceId, fieldId, file: files[0] });
745
+ * const updated = await form.toJSON(); // other fields now auto-filled
746
+ */
747
+ parseAttachment(options: ProcessParseAttachmentOptions): Promise<ProcessAttachmentParseResult>;
460
748
  }
461
749
  declare class Application {
462
750
  page: Page
@@ -465,9 +753,55 @@ declare class Application {
465
753
  setVariable(key: string | object, value?: any): any;
466
754
  openPage(pageId: string, pageParams?: object): any;
467
755
  getDecisionTable(flowId: string): DecisionTable;
756
+ /**
757
+ * Get a published Custom Agent of this app by its id. The handle sends no request until you call one
758
+ * of its methods; see {@link Agent}.
759
+ *
760
+ * @example
761
+ * const agent = kf.app.getAgent("AgXXXXXXXXXX");
762
+ * const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks" } });
763
+ */
764
+ getAgent(agentId: string): Agent;
468
765
  getDataform(flowId: string): Dataform;
469
766
  getBoard(flowId: string): Board;
470
767
  getProcess(flowId: string): Process;
768
+ /**
769
+ * List the app's roles and which of them the current user is a member of.
770
+ *
771
+ * Only available in a Development account - use this to build a role
772
+ * picker UI inside the component, then pass the chosen role to
773
+ * {@link switchRole}.
774
+ *
775
+ * @returns A promise that resolves with `{ roles, currentRoles }` - the
776
+ * full list of app roles and the subset the current user belongs to.
777
+ *
778
+ * @example
779
+ * const { roles, currentRoles } = await kf.app.getRoles();
780
+ */
781
+ getRoles(): Promise<{
782
+ roles: rolesObject[];
783
+ currentRoles: rolesObject[];
784
+ }>;
785
+ /**
786
+ * Switch the current user's active role in a Development account.
787
+ *
788
+ * This performs a real role change - it removes the user from their
789
+ * current role(s) and adds them to the target role. The platform's app
790
+ * shell (top nav, other widgets) picks up the new role on its own; no
791
+ * page reload happens. Only available in a Development account.
792
+ *
793
+ * @param args - Either `roleId` or `roleName` identifying the target role
794
+ * (use the values returned by {@link getRoles}).
795
+ * @returns A promise that resolves with the switched-to role.
796
+ *
797
+ * @example
798
+ * const { roles } = await kf.app.getRoles();
799
+ * await kf.app.switchRole({ roleId: roles[1]._id });
800
+ */
801
+ switchRole(args: {
802
+ roleId?: string;
803
+ roleName?: string;
804
+ }): Promise<rolesObject>;
471
805
  }
472
806
  declare class kf {
473
807
  static context: Component
@@ -556,6 +890,25 @@ declare type ProcessItem = {
556
890
  _activity_instance_id: string;
557
891
  };
558
892
 
893
+ // ============================================
894
+ // Form Field Value Types
895
+ // ============================================
896
+
897
+ // The value shape a Geolocation field is stored/read as across the platform
898
+ // (native forms and custom forms alike) — Latitude/Longitude are stringified
899
+ // on save, matching the native Geolocation field's saved representation.
900
+ declare type GeolocationValue = {
901
+ Address?: string;
902
+ Latitude: string;
903
+ Longitude: string;
904
+ City?: string;
905
+ State?: string;
906
+ Country?: string;
907
+ ZipCode?: string;
908
+ Area?: string;
909
+ PlaceId?: string;
910
+ };
911
+
559
912
  // ============================================
560
913
  // Process Types
561
914
  // ============================================
@@ -589,6 +942,7 @@ declare type ProcessQueryResponse = QueryResponse;
589
942
 
590
943
  declare type ProcessGetItemOptions = {
591
944
  instanceId: string;
945
+ activityInstanceId: string;
592
946
  };
593
947
 
594
948
  declare type ProcessCreateItemOptions = {
@@ -605,6 +959,15 @@ declare type ProcessDeleteItemOptions = {
605
959
  instanceId: string;
606
960
  };
607
961
 
962
+ declare type ProcessGetAdminItemOptions = {
963
+ instanceId: string;
964
+ };
965
+
966
+ declare type ProcessUpdateAdminItemOptions = {
967
+ instanceId: string;
968
+ data: object;
969
+ };
970
+
608
971
  declare type ProcessSubmitItemOptions = {
609
972
  instanceId: string;
610
973
  activityInstanceId: string;
@@ -655,6 +1018,36 @@ declare type ProcessDiscardItemOptions = {
655
1018
  instanceId: string;
656
1019
  };
657
1020
 
1021
+ declare type ProcessFieldOptions = {
1022
+ instanceId: string;
1023
+ activityInstanceId: string;
1024
+ fieldId: string;
1025
+ /** Skip the server-side model lookup by supplying the field's type directly. */
1026
+ fieldType?: string;
1027
+ tableId?: string;
1028
+ tableRowId?: string;
1029
+ };
1030
+
1031
+ declare type ProcessAttachmentFile = {
1032
+ id: string;
1033
+ name: string;
1034
+ key: string;
1035
+ size?: number;
1036
+ fileExtension?: string;
1037
+ };
1038
+
1039
+ declare type ProcessParseAttachmentOptions = {
1040
+ instanceId: string; // form.instanceId (process record id)
1041
+ activityInstanceId: string;
1042
+ fieldId: string;
1043
+ file: ProcessAttachmentFile;
1044
+ };
1045
+
1046
+ declare type ProcessAttachmentParseResult = {
1047
+ appliedFields: string[]; // field IDs auto-filled into the form store
1048
+ suggestedBy: string; // name of the parsed file
1049
+ };
1050
+
658
1051
  declare type FetchOptions = {
659
1052
  method?: string;
660
1053
  body?: string | object;
@@ -703,6 +1096,15 @@ declare type DataformSubmitItemOptions = {
703
1096
  viewId?: string;
704
1097
  };
705
1098
 
1099
+ declare type DataformFieldOptions = {
1100
+ instanceId: string;
1101
+ fieldId: string;
1102
+ /** Skip the server-side model lookup by supplying the field's type directly. */
1103
+ fieldType?: string;
1104
+ tableId?: string;
1105
+ tableRowId?: string;
1106
+ };
1107
+
706
1108
  // ============================================
707
1109
  // Board Types
708
1110
  // ============================================
@@ -739,3 +1141,105 @@ declare type BoardSubmitItemOptions = {
739
1141
  declare type BoardDiscardItemOptions = {
740
1142
  instanceId: string;
741
1143
  };
1144
+
1145
+ declare type BoardFieldOptions = {
1146
+ instanceId: string;
1147
+ fieldId: string;
1148
+ /** Skip the server-side model lookup by supplying the field's type directly. */
1149
+ fieldType?: string;
1150
+ tableId?: string;
1151
+ tableRowId?: string;
1152
+ };
1153
+
1154
+ // ============================================
1155
+ // Custom Agent Types
1156
+ // ============================================
1157
+
1158
+ declare type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
1159
+
1160
+ declare type AgentOutputDataType = "string" | "number" | "boolean";
1161
+
1162
+ declare type AgentInputField = {
1163
+ Key: string;
1164
+ Name: string;
1165
+ DataType: AgentInputDataType;
1166
+ Required: boolean;
1167
+ Description?: string;
1168
+ };
1169
+
1170
+ declare type AgentOutputField = {
1171
+ Key: string;
1172
+ Name: string;
1173
+ DataType: AgentOutputDataType;
1174
+ Description?: string;
1175
+ };
1176
+
1177
+ /**
1178
+ * A file for an `Attachment` input: exactly one of `Key` (a Kissflow attachment) or `Url` (https).
1179
+ * A file from `openFilePicker` or `uploadFile` has lowercase keys: pass
1180
+ * `{ Key: file.key, FileName: file.name, Size: file.size }`.
1181
+ */
1182
+ declare type AgentAttachmentValue =
1183
+ | { Key: string; Url?: never; FileName: string; Size?: number; ContentType?: string }
1184
+ | { Url: string; Key?: never; FileName: string; Size?: number; ContentType?: string };
1185
+
1186
+ declare type AgentInputValue = string | number | boolean | AgentAttachmentValue;
1187
+
1188
+ /** The Agent's published invocation contract. */
1189
+ declare type AgentContract = {
1190
+ AgentId: string;
1191
+ Definition: {
1192
+ Name: string;
1193
+ Description?: string;
1194
+ Icon?: Record<string, unknown>;
1195
+ Inputs: AgentInputField[];
1196
+ Outputs: AgentOutputField[];
1197
+ MaxOutputItems: number;
1198
+ };
1199
+ Readiness: {
1200
+ Ready: boolean;
1201
+ Issues: Array<{ Code: string; Path: string; Message: string }>;
1202
+ };
1203
+ };
1204
+
1205
+ declare type AgentExecuteOptions = {
1206
+ /** Values keyed by input `Key`, as declared in the contract. */
1207
+ inputData: Record<string, AgentInputValue>;
1208
+ };
1209
+
1210
+ /** More statuses may be added; treat any status other than `Completed` or `Failed` as still in progress. */
1211
+ declare type AgentExecutionStatus = "Queued" | "NotStarted" | "Running" | "Completed" | "Failed" | (string & {});
1212
+
1213
+ /** What `execute` resolves with once the run is accepted, before it has finished. */
1214
+ declare type AgentExecutionAccepted = {
1215
+ ExecutionId: string;
1216
+ Status: AgentExecutionStatus;
1217
+ };
1218
+
1219
+ declare type AgentExecution = {
1220
+ ExecutionId: string;
1221
+ Status: AgentExecutionStatus;
1222
+ Stage?: string;
1223
+ /** Present on `Completed`: one row per item, keyed by output `Key`. */
1224
+ Output?: { items: Array<Record<string, string | number | boolean>> };
1225
+ /** Present on `Failed`. */
1226
+ Error?: { Code: string; Retryable: boolean; Details?: unknown };
1227
+ Warnings?: Array<Record<string, unknown>>;
1228
+ CreatedAt?: string;
1229
+ StartedAt?: string;
1230
+ CompletedAt?: string;
1231
+ };
1232
+
1233
+ /**
1234
+ * How an Agent call fails: `error` is the message text and `errorCode` either the platform code
1235
+ * (`KISSFLOW_ERROR_…`) or an `AGENT_…` code, including `AGENT_HOST_TIMEOUT`, `AGENT_REQUEST_NOT_SENT`,
1236
+ * `AGENT_EXECUTE_OUTCOME_UNKNOWN` (a run may have started), `AGENT_EXECUTE_NOT_SENT` (no run started),
1237
+ * `AGENT_HOST_UNSUPPORTED`, `AGENT_WATCH_INVALID_EVENT`, `AGENT_OBSERVATION_STOPPED`, and from the host
1238
+ * `AGENT_READ_TIMEOUT` and `AGENT_OFFLINE`. The list may grow; fall back to `error` for an unknown code.
1239
+ * There is no `message`: read `error` for the text.
1240
+ */
1241
+ declare type AgentError = {
1242
+ isError: true;
1243
+ error?: string;
1244
+ errorCode?: string;
1245
+ };