@ultrst-armada/floks 2.0.7 → 2.0.8

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,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/floks",
4
- "version": "2.0.7",
5
- "sourceCommit": "30e9828c9552718fefa773b3122ffd74b86f84d0",
4
+ "version": "2.0.8",
5
+ "sourceCommit": "ec86c737b0ee1e7487e5979c12400aae7d636c67",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "44079620802"
7
+ "workflowRunId": "44244673463"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/floks",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -101,8 +101,8 @@
101
101
  "verify:npm-trusted-publishing": "node scripts/verify-npm-trusted-publishing.mjs"
102
102
  },
103
103
  "dependencies": {
104
- "@dinilmusick/gutts": "^2.1.1",
105
- "@ultrst-armada/frnlts": "^0.5.24",
104
+ "@dinilmusick/gutts": "^2.2.2",
105
+ "@ultrst-armada/frnlts": "^0.5.26",
106
106
  "zod": "^3.24.1"
107
107
  },
108
108
  "peerDependencies": {
@@ -120,7 +120,7 @@
120
120
  "@types/node": "^22.0.0",
121
121
  "@types/react": "^19.0.0",
122
122
  "@types/react-dom": "^19.0.0",
123
- "@ultrst-armada/frnlts": "^0.5.24",
123
+ "@ultrst-armada/frnlts": "^0.5.26",
124
124
  "happy-dom": "^21.0.3",
125
125
  "lucide-react": "^1.55.0",
126
126
  "react": "^19.0.1",
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { AikoRuntimeLike, EmbeddedAikoRuntime } from './AikoModule.js';
3
+ export declare function AgentWorkspace({ runtime, keyManager, workspaceId, className }: {
4
+ runtime: EmbeddedAikoRuntime;
5
+ keyManager?: AikoRuntimeLike;
6
+ workspaceId: string;
7
+ className?: string;
8
+ }): React.JSX.Element;
@@ -32,9 +32,13 @@ export interface AikoKey {
32
32
  emailGroup?: string;
33
33
  expiresAt?: string | null;
34
34
  }
35
- export interface AikoRuntimeLike {
35
+ export interface EmbeddedAikoRuntime {
36
36
  listAgents(): Promise<AikoAgentDefinition[]>;
37
37
  executeAgent(agentId: string, input: string): Promise<unknown>;
38
+ listCapabilities?(): Promise<AikoCapability[]>;
39
+ createCustomAgent?(name: string, capabilityIds: string[], specId?: string): Promise<AikoAgentDefinition>;
40
+ }
41
+ export interface AikoRuntimeLike extends EmbeddedAikoRuntime {
38
42
  listKeys(): Promise<AikoKey[]>;
39
43
  getActiveKey(providerId: string): Promise<AikoKey | null>;
40
44
  rotateKey(providerId: string): Promise<AikoKey | null>;
@@ -48,8 +52,6 @@ export interface AikoRuntimeLike {
48
52
  synced: number;
49
53
  message?: string;
50
54
  }>;
51
- listCapabilities?(): Promise<AikoCapability[]>;
52
- createCustomAgent?(name: string, capabilityIds: string[], specId?: string): Promise<AikoAgentDefinition>;
53
55
  }
54
56
  export interface AikoModuleProps {
55
57
  runtime: AikoRuntimeLike;
@@ -60,3 +62,9 @@ export declare function AikoModule({ runtime, workspaceId, className }: AikoModu
60
62
  export declare namespace AikoModule {
61
63
  var displayName: string;
62
64
  }
65
+ /** Downstream applications receive agent operations only. Credentials stay in central Aiko. */
66
+ export declare function EmbeddedAikoModule(props: {
67
+ runtime: EmbeddedAikoRuntime;
68
+ workspaceId: string;
69
+ className?: string;
70
+ }): React.JSX.Element;
@@ -1,6 +1,8 @@
1
1
  import {
2
- AikoModule
3
- } from "../chunk-OHAFLB3O.js";
2
+ AikoModule,
3
+ EmbeddedAikoModule
4
+ } from "../chunk-OH7S4XFZ.js";
4
5
  export {
5
- AikoModule
6
+ AikoModule,
7
+ EmbeddedAikoModule
6
8
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SRGVIYC5.js";
4
4
 
5
5
  // src/fod/FodModule.tsx
6
- import { useEffect, useMemo, useState } from "react";
6
+ import { useEffect, useMemo, useRef, useState } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  function toGraphNodes(flow, nodeDefinitions) {
9
9
  const defs = new Map(nodeDefinitions.map((def) => [def.type, def]));
@@ -25,7 +25,11 @@ function toGraphNodes(flow, nodeDefinitions) {
25
25
  function toGraphEdges(flow) {
26
26
  return flow.edges.map((edge) => ({ id: edge.id, source: edge.source, sourceSocket: edge.sourceHandle ?? "result", target: edge.target, targetSocket: edge.targetHandle ?? "input" }));
27
27
  }
28
- function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
28
+ function FodModule(props) {
29
+ return /* @__PURE__ */ jsx(WorkspaceFlows, { ...props }, props.workspaceId);
30
+ }
31
+ function WorkspaceFlows({ runtime, nodeDefinitions, workspaceId, className }) {
32
+ const drafts = useRef(/* @__PURE__ */ new Map());
29
33
  const [flows, setFlows] = useState([]);
30
34
  const [activeId, setActiveId] = useState(null);
31
35
  const [flow, setFlow] = useState(null);
@@ -33,20 +37,34 @@ function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
33
37
  const [message, setMessage] = useState("");
34
38
  const [running, setRunning] = useState(false);
35
39
  const refresh = async () => {
36
- const next = await runtime.listFlows();
40
+ const saved = await runtime.listFlows();
41
+ const merged = new Map(saved.map((item) => [item.id, item]));
42
+ for (const [id, draft] of drafts.current) merged.set(id, draft);
43
+ const next = [...merged.values()];
37
44
  setFlows(next);
38
- if (!activeId && next[0]) setActiveId(next[0].id);
45
+ setActiveId((current) => current ?? next[0]?.id ?? null);
39
46
  };
40
47
  useEffect(() => {
41
- void refresh();
42
- }, [workspaceId]);
48
+ void refresh().catch((error) => setMessage(String(error)));
49
+ }, [runtime]);
43
50
  useEffect(() => {
44
- if (!activeId) {
45
- setFlow(null);
46
- return;
51
+ let current = true;
52
+ const draft = activeId ? drafts.current.get(activeId) : void 0;
53
+ setFlow(draft ?? null);
54
+ if (activeId && !draft) {
55
+ void runtime.getFlow(activeId).then((saved) => {
56
+ if (current) setFlow(saved);
57
+ }).catch((error) => {
58
+ if (current) setMessage(String(error));
59
+ });
47
60
  }
48
- void runtime.getFlow(activeId).then(setFlow);
49
- }, [activeId]);
61
+ return () => {
62
+ current = false;
63
+ };
64
+ }, [activeId, runtime]);
65
+ useEffect(() => {
66
+ if (flow && drafts.current.has(flow.id)) drafts.current.set(flow.id, flow);
67
+ }, [flow]);
50
68
  const graphNodes = useMemo(() => flow ? toGraphNodes(flow, nodeDefinitions) : [], [flow, nodeDefinitions]);
51
69
  const graphEdges = useMemo(() => flow ? toGraphEdges(flow) : [], [flow]);
52
70
  const updateNodes = (next) => {
@@ -61,7 +79,8 @@ function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
61
79
  };
62
80
  const createFlow = () => {
63
81
  const now = (/* @__PURE__ */ new Date()).toISOString();
64
- const next = { id: `flow-${Date.now()}`, name: "New Flow", version: 1, createdAt: now, updatedAt: now, nodes: [], edges: [], metadata: { workspaceId } };
82
+ const next = { id: `flow-${crypto.randomUUID()}`, name: "New Flow", version: 1, createdAt: now, updatedAt: now, nodes: [], edges: [], metadata: { workspaceId } };
83
+ drafts.current.set(next.id, next);
65
84
  setFlows((current) => [...current, next]);
66
85
  setActiveId(next.id);
67
86
  setFlow(next);
@@ -69,7 +88,8 @@ function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
69
88
  const save = async () => {
70
89
  if (!flow) return;
71
90
  const saved = await runtime.saveFlow(flow);
72
- setFlow(saved);
91
+ drafts.current.delete(flow.id);
92
+ setFlow((current) => current?.id === flow.id ? saved : current);
73
93
  await refresh();
74
94
  setMessage("Saved");
75
95
  };
@@ -91,11 +111,13 @@ function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
91
111
  };
92
112
  const run = async () => {
93
113
  if (!flow) return;
94
- await save();
95
114
  setRunning(true);
96
115
  try {
116
+ await save();
97
117
  const result = await runtime.executeFlow(flow.id);
98
118
  setMessage(result.success ? "Execution completed" : result.errors?.[0]?.message ?? "Execution failed");
119
+ } catch (error) {
120
+ setMessage(String(error));
99
121
  } finally {
100
122
  setRunning(false);
101
123
  }
@@ -117,7 +139,8 @@ function FodModule({ runtime, nodeDefinitions, workspaceId, className }) {
117
139
  flows.map((item) => /* @__PURE__ */ jsx("option", { value: item.id, children: item.name }, item.id))
118
140
  ] }),
119
141
  /* @__PURE__ */ jsx("button", { type: "button", onClick: createFlow, children: "New flow" }),
120
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void save(), disabled: !flow, children: "Save" }),
142
+ flow && /* @__PURE__ */ jsx("input", { "aria-label": "Workflow name", value: flow.name, onChange: (event) => setFlow({ ...flow, name: event.target.value }) }),
143
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void save().catch((error) => setMessage(String(error))), disabled: !flow?.name.trim(), children: "Save as App Workflow" }),
121
144
  /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void run(), disabled: !flow || running, children: running ? "Running\u2026" : "Run" }),
122
145
  /* @__PURE__ */ jsx("span", { children: message })
123
146
  ] }),
@@ -1,7 +1,7 @@
1
- // src/aiko/AikoModule.tsx
1
+ // src/aiko/AgentWorkspace.tsx
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- function AikoModule({ runtime, workspaceId, className }) {
4
+ function AgentWorkspace({ runtime, keyManager, workspaceId, className }) {
5
5
  const [agents, setAgents] = useState([]);
6
6
  const [capabilities, setCapabilities] = useState([]);
7
7
  const [keys, setKeys] = useState([]);
@@ -20,7 +20,7 @@ function AikoModule({ runtime, workspaceId, className }) {
20
20
  const refresh = async () => {
21
21
  const [nextAgents, nextKeys, nextCaps] = await Promise.all([
22
22
  runtime.listAgents(),
23
- runtime.listKeys(),
23
+ keyManager ? keyManager.listKeys() : Promise.resolve([]),
24
24
  runtime.listCapabilities ? runtime.listCapabilities() : Promise.resolve([])
25
25
  ]);
26
26
  setAgents(nextAgents);
@@ -29,8 +29,8 @@ function AikoModule({ runtime, workspaceId, className }) {
29
29
  if (!activeAgent && nextAgents[0]) setActiveAgent(nextAgents[0].id);
30
30
  };
31
31
  useEffect(() => {
32
- void refresh();
33
- }, [workspaceId]);
32
+ void refresh().catch((error) => setMessage(error instanceof Error ? error.message : String(error)));
33
+ }, [workspaceId, runtime]);
34
34
  const groups = useMemo(() => {
35
35
  const map = /* @__PURE__ */ new Map();
36
36
  for (const agent of agents) {
@@ -53,15 +53,16 @@ function AikoModule({ runtime, workspaceId, className }) {
53
53
  }
54
54
  };
55
55
  const addKey = async () => {
56
- if (!runtime.addKey || !provider || !label || !secret) return;
57
- await runtime.addKey({ providerId: provider, label, key: secret, emailGroup: group || void 0 });
56
+ if (!keyManager?.addKey || !provider || !label || !secret) return;
57
+ await keyManager.addKey({ providerId: provider, label, key: secret, emailGroup: group || void 0 });
58
58
  setSecret("");
59
59
  await refresh();
60
60
  };
61
61
  const sync = async () => {
62
+ if (!keyManager) return;
62
63
  setBusy(true);
63
64
  try {
64
- const response = await runtime.syncFromAikoEngine();
65
+ const response = await keyManager.syncFromAikoEngine();
65
66
  setMessage(response.message ?? "Synced " + response.synced + " keys");
66
67
  await refresh();
67
68
  } catch (error) {
@@ -90,7 +91,7 @@ function AikoModule({ runtime, workspaceId, className }) {
90
91
  return /* @__PURE__ */ jsxs("div", { className, "data-aiko-module": "true", style: { display: "grid", gridTemplateColumns: "280px 1fr", gridTemplateRows: "48px 1fr", height: "100%", minHeight: 500 }, children: [
91
92
  /* @__PURE__ */ jsxs("header", { style: { gridColumn: "1 / -1", display: "flex", alignItems: "center", gap: 8, padding: 8, borderBottom: "1px solid var(--skipo-border,#333)" }, children: [
92
93
  /* @__PURE__ */ jsx("strong", { children: "AIKO" }),
93
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void sync(), disabled: busy, children: "Fetch from Aiko Engine" }),
94
+ keyManager && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void sync(), disabled: busy, children: "Fetch from Aiko Engine" }),
94
95
  /* @__PURE__ */ jsx("span", { children: message })
95
96
  ] }),
96
97
  /* @__PURE__ */ jsxs("aside", { style: { overflow: "auto", padding: 10, borderRight: "1px solid var(--skipo-border,#333)" }, children: [
@@ -123,23 +124,25 @@ function AikoModule({ runtime, workspaceId, className }) {
123
124
  ] }, cap.id)) }),
124
125
  /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void createCustomAgent(), disabled: busy || !customName.trim() || customCapIds.length === 0, children: "Create Custom Agent" })
125
126
  ] }),
126
- /* @__PURE__ */ jsx("h4", { children: "API Keys" }),
127
- /* @__PURE__ */ jsxs("div", { children: [
128
- /* @__PURE__ */ jsx("input", { value: provider, onChange: (event) => setProvider(event.target.value), placeholder: "Provider" }),
129
- /* @__PURE__ */ jsx("input", { value: label, onChange: (event) => setLabel(event.target.value), placeholder: "Label" }),
130
- /* @__PURE__ */ jsx("input", { value: group, onChange: (event) => setGroup(event.target.value), placeholder: "Email group" }),
131
- /* @__PURE__ */ jsx("input", { value: secret, onChange: (event) => setSecret(event.target.value), placeholder: "API key", type: "password" }),
132
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void addKey(), children: "Add key" })
133
- ] }),
134
- keys.map((key) => /* @__PURE__ */ jsxs("div", { children: [
135
- key.providerId,
136
- ": ",
137
- key.label,
138
- " ",
139
- key.isActive ? "(active)" : "",
140
- " ",
141
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void runtime.rotateKey(key.providerId), children: "Rotate" })
142
- ] }, key.id))
127
+ keyManager && /* @__PURE__ */ jsxs("section", { children: [
128
+ /* @__PURE__ */ jsx("h4", { children: "API Keys" }),
129
+ /* @__PURE__ */ jsxs("div", { children: [
130
+ /* @__PURE__ */ jsx("input", { value: provider, onChange: (event) => setProvider(event.target.value), placeholder: "Provider" }),
131
+ /* @__PURE__ */ jsx("input", { value: label, onChange: (event) => setLabel(event.target.value), placeholder: "Label" }),
132
+ /* @__PURE__ */ jsx("input", { value: group, onChange: (event) => setGroup(event.target.value), placeholder: "Email group" }),
133
+ /* @__PURE__ */ jsx("input", { value: secret, onChange: (event) => setSecret(event.target.value), placeholder: "API key", type: "password" }),
134
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void addKey(), children: "Add key" })
135
+ ] }),
136
+ keys.map((key) => /* @__PURE__ */ jsxs("div", { children: [
137
+ key.providerId,
138
+ ": ",
139
+ key.label,
140
+ " ",
141
+ key.isActive ? "(active)" : "",
142
+ " ",
143
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void keyManager.rotateKey(key.providerId), children: "Rotate" })
144
+ ] }, key.id))
145
+ ] })
143
146
  ] }),
144
147
  /* @__PURE__ */ jsx("main", { style: { padding: 16, overflow: "auto" }, children: activeAgent ? /* @__PURE__ */ jsxs(Fragment, { children: [
145
148
  /* @__PURE__ */ jsx("h3", { children: agents.find((agent) => agent.id === activeAgent)?.name }),
@@ -150,8 +153,18 @@ function AikoModule({ runtime, workspaceId, className }) {
150
153
  ] }) : /* @__PURE__ */ jsx("p", { children: "No Aiko agent selected." }) })
151
154
  ] });
152
155
  }
156
+
157
+ // src/aiko/AikoModule.tsx
158
+ import { jsx as jsx2 } from "react/jsx-runtime";
159
+ function AikoModule({ runtime, workspaceId, className }) {
160
+ return /* @__PURE__ */ jsx2(AgentWorkspace, { runtime, keyManager: runtime, workspaceId, className }, workspaceId);
161
+ }
162
+ function EmbeddedAikoModule(props) {
163
+ return /* @__PURE__ */ jsx2(AgentWorkspace, { ...props }, props.workspaceId);
164
+ }
153
165
  AikoModule.displayName = "AikoModule";
154
166
 
155
167
  export {
156
- AikoModule
168
+ AikoModule,
169
+ EmbeddedAikoModule
157
170
  };
@@ -50,7 +50,7 @@ export interface FodModuleProps {
50
50
  workspaceId: string;
51
51
  className?: string;
52
52
  }
53
- export declare function FodModule({ runtime, nodeDefinitions, workspaceId, className }: FodModuleProps): React.JSX.Element;
53
+ export declare function FodModule(props: FodModuleProps): React.JSX.Element;
54
54
  export declare namespace FodModule {
55
55
  var displayName: string;
56
56
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  FodModule
3
- } from "../chunk-TKOMIUCU.js";
3
+ } from "../chunk-24JGPSGO.js";
4
4
  import "../chunk-SRGVIYC5.js";
5
5
  import "../chunk-ZSVXR3HU.js";
6
6
  export {
@@ -36,8 +36,9 @@ import {
36
36
  useTileMenu
37
37
  } from "./chunk-SA3JADUG.js";
38
38
  import {
39
- AikoModule
40
- } from "./chunk-OHAFLB3O.js";
39
+ AikoModule,
40
+ EmbeddedAikoModule
41
+ } from "./chunk-OH7S4XFZ.js";
41
42
  import {
42
43
  UiAuthoringBindingEditor,
43
44
  UiAuthoringInspector,
@@ -74,7 +75,7 @@ import {
74
75
  } from "./chunk-34YRDZPJ.js";
75
76
  import {
76
77
  FodModule
77
- } from "./chunk-TKOMIUCU.js";
78
+ } from "./chunk-24JGPSGO.js";
78
79
  import {
79
80
  CanvasContextMenu,
80
81
  CompatibleNodePicker,
@@ -729,6 +730,7 @@ export {
729
730
  DockBar,
730
731
  DockItem,
731
732
  EffectNode2D,
733
+ EmbeddedAikoModule,
732
734
  FodModule,
733
735
  FrnlEditableNodeGraph,
734
736
  GraphToolbar,
@@ -76,7 +76,7 @@
76
76
  },
77
77
  "dependencies": {
78
78
  "@floks/ui": "workspace:*",
79
- "@ultrst-armada/frnlts": "^0.5.24",
79
+ "@ultrst-armada/frnlts": "^0.5.26",
80
80
  "@floks/contracts": "workspace:*"
81
81
  },
82
82
  "peerDependencies": {
@@ -109,11 +109,11 @@
109
109
  },
110
110
  "dependencies": {
111
111
  "zod": "^3.24.1",
112
- "@ultrst-armada/frnlts": "^0.5.24",
112
+ "@ultrst-armada/frnlts": "^0.5.26",
113
113
  "zustand": "^5.0.3",
114
114
  "@xyflow/react": "^12.8.6",
115
115
  "d3-force": "^3.0.0",
116
- "@dinilmusick/gutts": "^2.1.1"
116
+ "@dinilmusick/gutts": "^2.2.2"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "lucide-react": ">=0.300.0",