@kissflow/lowcode-client-sdk 1.0.49 → 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.
@@ -560,3 +560,96 @@ declare type BoardFieldOptions = {
560
560
  tableId?: string;
561
561
  tableRowId?: string;
562
562
  };
563
+
564
+ // ============================================
565
+ // Custom Agent Types
566
+ // ============================================
567
+
568
+ declare type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
569
+
570
+ declare type AgentOutputDataType = "string" | "number" | "boolean";
571
+
572
+ declare type AgentInputField = {
573
+ Key: string;
574
+ Name: string;
575
+ DataType: AgentInputDataType;
576
+ Required: boolean;
577
+ Description?: string;
578
+ };
579
+
580
+ declare type AgentOutputField = {
581
+ Key: string;
582
+ Name: string;
583
+ DataType: AgentOutputDataType;
584
+ Description?: string;
585
+ };
586
+
587
+ /**
588
+ * A file for an `Attachment` input: exactly one of `Key` (a Kissflow attachment) or `Url` (https).
589
+ * A file from `openFilePicker` or `uploadFile` has lowercase keys: pass
590
+ * `{ Key: file.key, FileName: file.name, Size: file.size }`.
591
+ */
592
+ declare type AgentAttachmentValue =
593
+ | { Key: string; Url?: never; FileName: string; Size?: number; ContentType?: string }
594
+ | { Url: string; Key?: never; FileName: string; Size?: number; ContentType?: string };
595
+
596
+ declare type AgentInputValue = string | number | boolean | AgentAttachmentValue;
597
+
598
+ /** The Agent's published invocation contract. */
599
+ declare type AgentContract = {
600
+ AgentId: string;
601
+ Definition: {
602
+ Name: string;
603
+ Description?: string;
604
+ Icon?: Record<string, unknown>;
605
+ Inputs: AgentInputField[];
606
+ Outputs: AgentOutputField[];
607
+ MaxOutputItems: number;
608
+ };
609
+ Readiness: {
610
+ Ready: boolean;
611
+ Issues: Array<{ Code: string; Path: string; Message: string }>;
612
+ };
613
+ };
614
+
615
+ declare type AgentExecuteOptions = {
616
+ /** Values keyed by input `Key`, as declared in the contract. */
617
+ inputData: Record<string, AgentInputValue>;
618
+ };
619
+
620
+ /** More statuses may be added; treat any status other than `Completed` or `Failed` as still in progress. */
621
+ declare type AgentExecutionStatus = "Queued" | "NotStarted" | "Running" | "Completed" | "Failed" | (string & {});
622
+
623
+ /** What `execute` resolves with once the run is accepted, before it has finished. */
624
+ declare type AgentExecutionAccepted = {
625
+ ExecutionId: string;
626
+ Status: AgentExecutionStatus;
627
+ };
628
+
629
+ declare type AgentExecution = {
630
+ ExecutionId: string;
631
+ Status: AgentExecutionStatus;
632
+ Stage?: string;
633
+ /** Present on `Completed`: one row per item, keyed by output `Key`. */
634
+ Output?: { items: Array<Record<string, string | number | boolean>> };
635
+ /** Present on `Failed`. */
636
+ Error?: { Code: string; Retryable: boolean; Details?: unknown };
637
+ Warnings?: Array<Record<string, unknown>>;
638
+ CreatedAt?: string;
639
+ StartedAt?: string;
640
+ CompletedAt?: string;
641
+ };
642
+
643
+ /**
644
+ * How an Agent call fails: `error` is the message text and `errorCode` either the platform code
645
+ * (`KISSFLOW_ERROR_…`) or an `AGENT_…` code, including `AGENT_HOST_TIMEOUT`, `AGENT_REQUEST_NOT_SENT`,
646
+ * `AGENT_EXECUTE_OUTCOME_UNKNOWN` (a run may have started), `AGENT_EXECUTE_NOT_SENT` (no run started),
647
+ * `AGENT_HOST_UNSUPPORTED`, `AGENT_WATCH_INVALID_EVENT`, `AGENT_OBSERVATION_STOPPED`, and from the host
648
+ * `AGENT_READ_TIMEOUT` and `AGENT_OFFLINE`. The list may grow; fall back to `error` for an unknown code.
649
+ * There is no `message`: read `error` for the text.
650
+ */
651
+ declare type AgentError = {
652
+ isError: true;
653
+ error?: string;
654
+ errorCode?: string;
655
+ };
@@ -20,6 +20,11 @@
20
20
  "documentation": "Evaluates the provided data and returns back the matched output",
21
21
  "insertText": "let decisionTableInstance = kf.app.getDecisionTable(\"${1:flowId}\");\n let decisionOutput = await decisionTableInstance.evaluate({ conditionField1: \"value\", conditionField2: \"value\" });"
22
22
  },
23
+ {
24
+ "label": "run custom agent",
25
+ "documentation": "Runs a published Custom Agent of this app and handles its result when it finishes",
26
+ "insertText": "let agentInstance = kf.app.getAgent(\"${1:agentId}\");\n let { ExecutionId } = await agentInstance.execute({ inputData: { ${2:inputKey}: ${3:value} } });\n let stopWatching = agentInstance.onExecutionComplete(ExecutionId, (execution) => { let items = execution.Output?.items; }, (error) => console.warn(error.errorCode));"
27
+ },
23
28
  {
24
29
  "label": "get local variable",
25
30
  "documentation": "Get value of the local variable",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kissflow/lowcode-client-sdk",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "JavaScript SDK for developing over the Kissflow lowcode platform",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -44,6 +44,8 @@
44
44
  "customBuild": "node custom.build.mjs",
45
45
  "build": "pnpm run customBuild",
46
46
  "serve": "http-server -p 8080",
47
- "publish-canary": "pnpm publish --tag canary"
47
+ "publish-canary": "pnpm publish --tag canary",
48
+ "pretest": "pnpm run build",
49
+ "test": "node --test \"test/*.test.mjs\""
48
50
  }
49
51
  }