@getcatalystiq/agent-plane-ui 0.1.19 → 0.1.21

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.
@@ -0,0 +1,277 @@
1
+ 'use strict';
2
+
3
+ var chunkXXF4U7WL_cjs = require('./chunk-XXF4U7WL.cjs');
4
+ var react = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ var FILE_MAP = [
8
+ { path: "SOUL.md", field: "soul_md" },
9
+ { path: "IDENTITY.md", field: "identity_md" },
10
+ { path: "STYLE.md", field: "style_md" },
11
+ { path: "AGENTS.md", field: "agents_md" },
12
+ { path: "HEARTBEAT.md", field: "heartbeat_md" },
13
+ { path: "USER_TEMPLATE.md", field: "user_template_md" },
14
+ { path: "examples/good-outputs.md", field: "examples_good_md" },
15
+ { path: "examples/bad-outputs.md", field: "examples_bad_md" }
16
+ ];
17
+ function agentToFiles(agent) {
18
+ const files = [];
19
+ for (const { path, field } of FILE_MAP) {
20
+ const value = agent[field];
21
+ if (typeof value === "string" && value.length > 0) {
22
+ files.push({ path, content: value });
23
+ }
24
+ }
25
+ return files;
26
+ }
27
+ function filesToPayload(files) {
28
+ const payload = {};
29
+ for (const { path, field } of FILE_MAP) {
30
+ const file = files.find((f) => f.path === path);
31
+ payload[field] = file ? file.content : null;
32
+ }
33
+ return payload;
34
+ }
35
+ function AgentIdentityTab({
36
+ agent,
37
+ FileTreeEditor,
38
+ onSaved,
39
+ onGenerateSoul,
40
+ onImportSoul,
41
+ onExportSoul,
42
+ onPublishSoul
43
+ }) {
44
+ const client = chunkXXF4U7WL_cjs.useAgentPlaneClient();
45
+ const [saving, setSaving] = react.useState(false);
46
+ const [error, setError] = react.useState("");
47
+ const [generating, setGenerating] = react.useState(false);
48
+ const [publishing, setPublishing] = react.useState(false);
49
+ const [importOpen, setImportOpen] = react.useState(false);
50
+ const [savedVersion, setSavedVersion] = react.useState(0);
51
+ const [overrideFiles, setOverrideFiles] = react.useState(null);
52
+ const initialFiles = react.useMemo(() => agentToFiles(agent), [agent]);
53
+ const editorFiles = overrideFiles ?? initialFiles;
54
+ const handleSave = react.useCallback(
55
+ async (files) => {
56
+ setSaving(true);
57
+ setError("");
58
+ try {
59
+ const payload = filesToPayload(files);
60
+ await client.agents.update(agent.id, payload);
61
+ setOverrideFiles(null);
62
+ setSavedVersion((v) => v + 1);
63
+ onSaved?.();
64
+ } catch (err) {
65
+ setError(err instanceof Error ? err.message : "Failed to save");
66
+ throw err;
67
+ } finally {
68
+ setSaving(false);
69
+ }
70
+ },
71
+ [agent.id, client, onSaved]
72
+ );
73
+ function applyFilesFromResponse(responseFiles) {
74
+ const newFiles = [];
75
+ for (const { path, field } of FILE_MAP) {
76
+ const content = responseFiles[field] ?? responseFiles[path];
77
+ if (content) {
78
+ newFiles.push({ path, content });
79
+ }
80
+ }
81
+ if (newFiles.length > 0) {
82
+ setOverrideFiles(newFiles);
83
+ }
84
+ }
85
+ async function handleGenerate() {
86
+ if (!onGenerateSoul) return;
87
+ setGenerating(true);
88
+ setError("");
89
+ try {
90
+ const data = await onGenerateSoul();
91
+ applyFilesFromResponse(data.files);
92
+ } catch (err) {
93
+ setError(err instanceof Error ? err.message : "Failed to generate");
94
+ } finally {
95
+ setGenerating(false);
96
+ }
97
+ }
98
+ function handleImported(responseFiles) {
99
+ applyFilesFromResponse(responseFiles);
100
+ }
101
+ async function handleExport() {
102
+ if (!onExportSoul) return;
103
+ setError("");
104
+ try {
105
+ const data = await onExportSoul();
106
+ const blob = new Blob([JSON.stringify(data, null, 2)], {
107
+ type: "application/json"
108
+ });
109
+ const url = URL.createObjectURL(blob);
110
+ const a = document.createElement("a");
111
+ a.href = url;
112
+ a.download = `${data.name || "soulspec"}.json`;
113
+ a.click();
114
+ URL.revokeObjectURL(url);
115
+ } catch (err) {
116
+ setError(err instanceof Error ? err.message : "Failed to export");
117
+ }
118
+ }
119
+ async function handlePublish() {
120
+ if (!onPublishSoul) return;
121
+ const owner = prompt("Enter owner name for publishing:");
122
+ if (!owner?.trim()) return;
123
+ setPublishing(true);
124
+ setError("");
125
+ try {
126
+ await onPublishSoul(owner.trim());
127
+ } catch (err) {
128
+ setError(err instanceof Error ? err.message : "Failed to publish");
129
+ } finally {
130
+ setPublishing(false);
131
+ }
132
+ }
133
+ const warnings = [];
134
+ const hasSoul = editorFiles.some(
135
+ (f) => f.path === "SOUL.md" && f.content.trim().length > 0
136
+ );
137
+ const hasIdentity = editorFiles.some(
138
+ (f) => f.path === "IDENTITY.md" && f.content.trim().length > 0
139
+ );
140
+ if (!hasSoul) warnings.push("SOUL.md is empty -- this is the core identity file");
141
+ if (!hasIdentity)
142
+ warnings.push("IDENTITY.md is empty -- consider adding behavioral traits");
143
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
144
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
145
+ onGenerateSoul && /* @__PURE__ */ jsxRuntime.jsx(
146
+ chunkXXF4U7WL_cjs.Button,
147
+ {
148
+ variant: "outline",
149
+ size: "sm",
150
+ onClick: handleGenerate,
151
+ disabled: generating,
152
+ children: generating ? "Generating..." : "Generate Soul"
153
+ }
154
+ ),
155
+ onImportSoul && /* @__PURE__ */ jsxRuntime.jsx(
156
+ chunkXXF4U7WL_cjs.Button,
157
+ {
158
+ variant: "outline",
159
+ size: "sm",
160
+ onClick: () => setImportOpen(true),
161
+ children: "Import"
162
+ }
163
+ ),
164
+ onExportSoul && /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.Button, { variant: "outline", size: "sm", onClick: handleExport, children: "Export" }),
165
+ onPublishSoul && /* @__PURE__ */ jsxRuntime.jsx(
166
+ chunkXXF4U7WL_cjs.Button,
167
+ {
168
+ variant: "outline",
169
+ size: "sm",
170
+ onClick: handlePublish,
171
+ disabled: publishing,
172
+ children: publishing ? "Publishing..." : "Publish"
173
+ }
174
+ ),
175
+ overrideFiles && /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.Badge, { variant: "destructive", className: "text-xs", children: "Unsaved generated content" })
176
+ ] }),
177
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: error }),
178
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-muted-foreground/25 p-5", children: /* @__PURE__ */ jsxRuntime.jsx(
179
+ FileTreeEditor,
180
+ {
181
+ initialFiles: editorFiles,
182
+ onSave: handleSave,
183
+ title: "SoulSpec",
184
+ saveLabel: saving ? "Saving..." : "Save Identity",
185
+ addFolderLabel: "Folder",
186
+ newFileTemplate: {
187
+ filename: "CUSTOM.md",
188
+ content: "# Custom\n\nAdd custom identity content...\n"
189
+ },
190
+ savedVersion
191
+ }
192
+ ) }),
193
+ warnings.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border border-yellow-600 bg-yellow-50 dark:bg-yellow-950/40 p-3", children: [
194
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium text-yellow-800 dark:text-yellow-400 mb-1", children: "Validation Warnings" }),
195
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "text-xs text-yellow-700 dark:text-yellow-300 space-y-0.5", children: warnings.map((w) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
196
+ "- ",
197
+ w
198
+ ] }, w)) })
199
+ ] }),
200
+ onImportSoul && /* @__PURE__ */ jsxRuntime.jsx(
201
+ ImportSoulDialog,
202
+ {
203
+ open: importOpen,
204
+ onOpenChange: setImportOpen,
205
+ onImport: onImportSoul,
206
+ onImported: handleImported
207
+ }
208
+ )
209
+ ] });
210
+ }
211
+ function ImportSoulDialog({
212
+ open,
213
+ onOpenChange,
214
+ onImport,
215
+ onImported
216
+ }) {
217
+ const [ref, setRef] = react.useState("");
218
+ const [loading, setLoading] = react.useState(false);
219
+ const [error, setError] = react.useState("");
220
+ async function handleImport() {
221
+ if (!ref.trim()) return;
222
+ setLoading(true);
223
+ setError("");
224
+ try {
225
+ const data = await onImport(ref.trim());
226
+ onImported(data.files);
227
+ onOpenChange(false);
228
+ setRef("");
229
+ } catch (err) {
230
+ setError(err instanceof Error ? err.message : "Failed to import");
231
+ } finally {
232
+ setLoading(false);
233
+ }
234
+ }
235
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(chunkXXF4U7WL_cjs.DialogContent, { className: "max-w-md", children: [
236
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkXXF4U7WL_cjs.DialogHeader, { children: [
237
+ /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.DialogTitle, { children: "Import SoulSpec" }),
238
+ /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.DialogDescription, { children: "Import a SoulSpec from the ClawSouls registry." })
239
+ ] }),
240
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkXXF4U7WL_cjs.DialogBody, { children: [
241
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive mb-3", children: error }),
242
+ /* @__PURE__ */ jsxRuntime.jsx(chunkXXF4U7WL_cjs.FormField, { label: "Registry Reference", children: /* @__PURE__ */ jsxRuntime.jsx(
243
+ chunkXXF4U7WL_cjs.Input,
244
+ {
245
+ value: ref,
246
+ onChange: (e) => setRef(e.target.value),
247
+ placeholder: "owner/name (e.g. clawsouls/surgical-coder)",
248
+ onKeyDown: (e) => e.key === "Enter" && handleImport(),
249
+ autoFocus: true
250
+ }
251
+ ) })
252
+ ] }),
253
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkXXF4U7WL_cjs.DialogFooter, { children: [
254
+ /* @__PURE__ */ jsxRuntime.jsx(
255
+ chunkXXF4U7WL_cjs.Button,
256
+ {
257
+ variant: "outline",
258
+ size: "sm",
259
+ onClick: () => onOpenChange(false),
260
+ disabled: loading,
261
+ children: "Cancel"
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsxRuntime.jsx(
265
+ chunkXXF4U7WL_cjs.Button,
266
+ {
267
+ size: "sm",
268
+ onClick: handleImport,
269
+ disabled: loading || !ref.trim(),
270
+ children: loading ? "Importing..." : "Import"
271
+ }
272
+ )
273
+ ] })
274
+ ] }) });
275
+ }
276
+
277
+ exports.AgentIdentityTab = AgentIdentityTab;
@@ -0,0 +1,275 @@
1
+ import { useAgentPlaneClient, Button, Badge, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogBody, FormField, Input, DialogFooter } from './chunk-XFI227OB.js';
2
+ import { useState, useMemo, useCallback } from 'react';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+
5
+ var FILE_MAP = [
6
+ { path: "SOUL.md", field: "soul_md" },
7
+ { path: "IDENTITY.md", field: "identity_md" },
8
+ { path: "STYLE.md", field: "style_md" },
9
+ { path: "AGENTS.md", field: "agents_md" },
10
+ { path: "HEARTBEAT.md", field: "heartbeat_md" },
11
+ { path: "USER_TEMPLATE.md", field: "user_template_md" },
12
+ { path: "examples/good-outputs.md", field: "examples_good_md" },
13
+ { path: "examples/bad-outputs.md", field: "examples_bad_md" }
14
+ ];
15
+ function agentToFiles(agent) {
16
+ const files = [];
17
+ for (const { path, field } of FILE_MAP) {
18
+ const value = agent[field];
19
+ if (typeof value === "string" && value.length > 0) {
20
+ files.push({ path, content: value });
21
+ }
22
+ }
23
+ return files;
24
+ }
25
+ function filesToPayload(files) {
26
+ const payload = {};
27
+ for (const { path, field } of FILE_MAP) {
28
+ const file = files.find((f) => f.path === path);
29
+ payload[field] = file ? file.content : null;
30
+ }
31
+ return payload;
32
+ }
33
+ function AgentIdentityTab({
34
+ agent,
35
+ FileTreeEditor,
36
+ onSaved,
37
+ onGenerateSoul,
38
+ onImportSoul,
39
+ onExportSoul,
40
+ onPublishSoul
41
+ }) {
42
+ const client = useAgentPlaneClient();
43
+ const [saving, setSaving] = useState(false);
44
+ const [error, setError] = useState("");
45
+ const [generating, setGenerating] = useState(false);
46
+ const [publishing, setPublishing] = useState(false);
47
+ const [importOpen, setImportOpen] = useState(false);
48
+ const [savedVersion, setSavedVersion] = useState(0);
49
+ const [overrideFiles, setOverrideFiles] = useState(null);
50
+ const initialFiles = useMemo(() => agentToFiles(agent), [agent]);
51
+ const editorFiles = overrideFiles ?? initialFiles;
52
+ const handleSave = useCallback(
53
+ async (files) => {
54
+ setSaving(true);
55
+ setError("");
56
+ try {
57
+ const payload = filesToPayload(files);
58
+ await client.agents.update(agent.id, payload);
59
+ setOverrideFiles(null);
60
+ setSavedVersion((v) => v + 1);
61
+ onSaved?.();
62
+ } catch (err) {
63
+ setError(err instanceof Error ? err.message : "Failed to save");
64
+ throw err;
65
+ } finally {
66
+ setSaving(false);
67
+ }
68
+ },
69
+ [agent.id, client, onSaved]
70
+ );
71
+ function applyFilesFromResponse(responseFiles) {
72
+ const newFiles = [];
73
+ for (const { path, field } of FILE_MAP) {
74
+ const content = responseFiles[field] ?? responseFiles[path];
75
+ if (content) {
76
+ newFiles.push({ path, content });
77
+ }
78
+ }
79
+ if (newFiles.length > 0) {
80
+ setOverrideFiles(newFiles);
81
+ }
82
+ }
83
+ async function handleGenerate() {
84
+ if (!onGenerateSoul) return;
85
+ setGenerating(true);
86
+ setError("");
87
+ try {
88
+ const data = await onGenerateSoul();
89
+ applyFilesFromResponse(data.files);
90
+ } catch (err) {
91
+ setError(err instanceof Error ? err.message : "Failed to generate");
92
+ } finally {
93
+ setGenerating(false);
94
+ }
95
+ }
96
+ function handleImported(responseFiles) {
97
+ applyFilesFromResponse(responseFiles);
98
+ }
99
+ async function handleExport() {
100
+ if (!onExportSoul) return;
101
+ setError("");
102
+ try {
103
+ const data = await onExportSoul();
104
+ const blob = new Blob([JSON.stringify(data, null, 2)], {
105
+ type: "application/json"
106
+ });
107
+ const url = URL.createObjectURL(blob);
108
+ const a = document.createElement("a");
109
+ a.href = url;
110
+ a.download = `${data.name || "soulspec"}.json`;
111
+ a.click();
112
+ URL.revokeObjectURL(url);
113
+ } catch (err) {
114
+ setError(err instanceof Error ? err.message : "Failed to export");
115
+ }
116
+ }
117
+ async function handlePublish() {
118
+ if (!onPublishSoul) return;
119
+ const owner = prompt("Enter owner name for publishing:");
120
+ if (!owner?.trim()) return;
121
+ setPublishing(true);
122
+ setError("");
123
+ try {
124
+ await onPublishSoul(owner.trim());
125
+ } catch (err) {
126
+ setError(err instanceof Error ? err.message : "Failed to publish");
127
+ } finally {
128
+ setPublishing(false);
129
+ }
130
+ }
131
+ const warnings = [];
132
+ const hasSoul = editorFiles.some(
133
+ (f) => f.path === "SOUL.md" && f.content.trim().length > 0
134
+ );
135
+ const hasIdentity = editorFiles.some(
136
+ (f) => f.path === "IDENTITY.md" && f.content.trim().length > 0
137
+ );
138
+ if (!hasSoul) warnings.push("SOUL.md is empty -- this is the core identity file");
139
+ if (!hasIdentity)
140
+ warnings.push("IDENTITY.md is empty -- consider adding behavioral traits");
141
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
142
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
143
+ onGenerateSoul && /* @__PURE__ */ jsx(
144
+ Button,
145
+ {
146
+ variant: "outline",
147
+ size: "sm",
148
+ onClick: handleGenerate,
149
+ disabled: generating,
150
+ children: generating ? "Generating..." : "Generate Soul"
151
+ }
152
+ ),
153
+ onImportSoul && /* @__PURE__ */ jsx(
154
+ Button,
155
+ {
156
+ variant: "outline",
157
+ size: "sm",
158
+ onClick: () => setImportOpen(true),
159
+ children: "Import"
160
+ }
161
+ ),
162
+ onExportSoul && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: handleExport, children: "Export" }),
163
+ onPublishSoul && /* @__PURE__ */ jsx(
164
+ Button,
165
+ {
166
+ variant: "outline",
167
+ size: "sm",
168
+ onClick: handlePublish,
169
+ disabled: publishing,
170
+ children: publishing ? "Publishing..." : "Publish"
171
+ }
172
+ ),
173
+ overrideFiles && /* @__PURE__ */ jsx(Badge, { variant: "destructive", className: "text-xs", children: "Unsaved generated content" })
174
+ ] }),
175
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
176
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-muted-foreground/25 p-5", children: /* @__PURE__ */ jsx(
177
+ FileTreeEditor,
178
+ {
179
+ initialFiles: editorFiles,
180
+ onSave: handleSave,
181
+ title: "SoulSpec",
182
+ saveLabel: saving ? "Saving..." : "Save Identity",
183
+ addFolderLabel: "Folder",
184
+ newFileTemplate: {
185
+ filename: "CUSTOM.md",
186
+ content: "# Custom\n\nAdd custom identity content...\n"
187
+ },
188
+ savedVersion
189
+ }
190
+ ) }),
191
+ warnings.length > 0 && /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-yellow-600 bg-yellow-50 dark:bg-yellow-950/40 p-3", children: [
192
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-yellow-800 dark:text-yellow-400 mb-1", children: "Validation Warnings" }),
193
+ /* @__PURE__ */ jsx("ul", { className: "text-xs text-yellow-700 dark:text-yellow-300 space-y-0.5", children: warnings.map((w) => /* @__PURE__ */ jsxs("li", { children: [
194
+ "- ",
195
+ w
196
+ ] }, w)) })
197
+ ] }),
198
+ onImportSoul && /* @__PURE__ */ jsx(
199
+ ImportSoulDialog,
200
+ {
201
+ open: importOpen,
202
+ onOpenChange: setImportOpen,
203
+ onImport: onImportSoul,
204
+ onImported: handleImported
205
+ }
206
+ )
207
+ ] });
208
+ }
209
+ function ImportSoulDialog({
210
+ open,
211
+ onOpenChange,
212
+ onImport,
213
+ onImported
214
+ }) {
215
+ const [ref, setRef] = useState("");
216
+ const [loading, setLoading] = useState(false);
217
+ const [error, setError] = useState("");
218
+ async function handleImport() {
219
+ if (!ref.trim()) return;
220
+ setLoading(true);
221
+ setError("");
222
+ try {
223
+ const data = await onImport(ref.trim());
224
+ onImported(data.files);
225
+ onOpenChange(false);
226
+ setRef("");
227
+ } catch (err) {
228
+ setError(err instanceof Error ? err.message : "Failed to import");
229
+ } finally {
230
+ setLoading(false);
231
+ }
232
+ }
233
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md", children: [
234
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
235
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Import SoulSpec" }),
236
+ /* @__PURE__ */ jsx(DialogDescription, { children: "Import a SoulSpec from the ClawSouls registry." })
237
+ ] }),
238
+ /* @__PURE__ */ jsxs(DialogBody, { children: [
239
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive mb-3", children: error }),
240
+ /* @__PURE__ */ jsx(FormField, { label: "Registry Reference", children: /* @__PURE__ */ jsx(
241
+ Input,
242
+ {
243
+ value: ref,
244
+ onChange: (e) => setRef(e.target.value),
245
+ placeholder: "owner/name (e.g. clawsouls/surgical-coder)",
246
+ onKeyDown: (e) => e.key === "Enter" && handleImport(),
247
+ autoFocus: true
248
+ }
249
+ ) })
250
+ ] }),
251
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
252
+ /* @__PURE__ */ jsx(
253
+ Button,
254
+ {
255
+ variant: "outline",
256
+ size: "sm",
257
+ onClick: () => onOpenChange(false),
258
+ disabled: loading,
259
+ children: "Cancel"
260
+ }
261
+ ),
262
+ /* @__PURE__ */ jsx(
263
+ Button,
264
+ {
265
+ size: "sm",
266
+ onClick: handleImport,
267
+ disabled: loading || !ref.trim(),
268
+ children: loading ? "Importing..." : "Import"
269
+ }
270
+ )
271
+ ] })
272
+ ] }) });
273
+ }
274
+
275
+ export { AgentIdentityTab };