@arbidocs/tui 0.4.31 → 0.4.33

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.js CHANGED
@@ -1820,6 +1820,70 @@ function parseLimit(arg) {
1820
1820
  const n = Number.parseInt(arg, 10);
1821
1821
  return Number.isFinite(n) && n > 0 ? n : void 0;
1822
1822
  }
1823
+ var workflowCommands = [
1824
+ {
1825
+ name: "automations",
1826
+ description: "List workspace automations",
1827
+ requires: "workspace",
1828
+ run: async (ctx) => {
1829
+ const { arbi } = ctx;
1830
+ const rows = await sdk.workflows.listWorkflows(arbi);
1831
+ return rows.length ? rows.map(
1832
+ (row) => `${row.external_id} ${row.name} ${row.active ? "Active" : "Paused"} ${row.action?.type ?? "Chat"} ${row.next_fire_at ?? "Run now / notification"}`
1833
+ ) : "No automations in this workspace.";
1834
+ }
1835
+ },
1836
+ {
1837
+ name: "automation",
1838
+ description: "Manage an automation: view | run | runs | pause | resume | delete <id>; create <JSON>; update <id> <JSON>",
1839
+ argHint: "subcommand id",
1840
+ minArgs: 2,
1841
+ requires: "workspace",
1842
+ run: async (ctx) => {
1843
+ const { arbi, args, wsContext, rawInput } = ctx;
1844
+ const [sub, id, ...rest] = args;
1845
+ switch (sub) {
1846
+ case "view":
1847
+ return JSON.stringify(await sdk.workflows.getWorkflow(arbi, id), null, 2);
1848
+ case "run": {
1849
+ const result = await sdk.workflows.runWorkflow(arbi, id);
1850
+ if (result.error) throw new Error(result.error);
1851
+ return `${result.started ? "Started" : "Submitted"} ${id}${result.execution_id ? ` \u2014 execution ${result.execution_id}` : ""}${result.conversation_ext_id ? ` \u2014 thread ${result.conversation_ext_id}` : ""}`;
1852
+ }
1853
+ case "runs": {
1854
+ const rows = await sdk.workflows.listWorkflowRuns(arbi, id);
1855
+ return rows.length ? rows.map((row) => JSON.stringify(row)) : "This automation has not run yet.";
1856
+ }
1857
+ case "pause":
1858
+ case "resume":
1859
+ await sdk.workflows.updateWorkflow(arbi, id, { active: sub === "resume" });
1860
+ return `${sub === "pause" ? "Paused" : "Resumed"} ${id}`;
1861
+ case "delete":
1862
+ await sdk.workflows.deleteWorkflow(arbi, id);
1863
+ return `Deleted ${id}; existing threads and results are preserved.`;
1864
+ case "create": {
1865
+ const body = JSON.parse(
1866
+ rawInput?.slice(rawInput.indexOf("{")) || [id, ...rest].join(" ")
1867
+ );
1868
+ body.workspace_ext_id ??= wsContext.workspaceId;
1869
+ const result = await sdk.workflows.createWorkflow(arbi, body);
1870
+ return `Created ${result.name} (${result.external_id})`;
1871
+ }
1872
+ case "update":
1873
+ await sdk.workflows.updateWorkflow(
1874
+ arbi,
1875
+ id,
1876
+ JSON.parse(
1877
+ rawInput?.slice(rawInput.indexOf("{")) || rest.join(" ")
1878
+ )
1879
+ );
1880
+ return `Updated ${id}`;
1881
+ default:
1882
+ return "Use /automation view|run|runs|pause|resume|delete <wfl-id>, create <JSON>, or update <wfl-id> <JSON>.";
1883
+ }
1884
+ }
1885
+ }
1886
+ ];
1823
1887
  init_tui_helpers();
1824
1888
  var skillCommands = [
1825
1889
  {
@@ -1963,6 +2027,7 @@ function registerAllCommands() {
1963
2027
  registerCommands(sourcesCommands);
1964
2028
  registerCommands(historyCommands);
1965
2029
  registerCommands(skillCommands);
2030
+ registerCommands(workflowCommands);
1966
2031
  }
1967
2032
  async function streamResponse(tui, response, docNames) {
1968
2033
  tui.chatLog.startAssistant();