@fieldwangai/agentflow 0.1.53 → 0.1.54
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/bin/lib/marketplace.mjs +24 -4
- package/bin/lib/ui-server.mjs +3 -3
- package/builtin/web-ui/dist/assets/index-DUDsW1dU.css +1 -0
- package/builtin/web-ui/dist/assets/{index-C2La4Klr.js → index-DVw2IOGE.js} +75 -75
- package/builtin/web-ui/dist/index.html +2 -2
- package/builtin/web-ui/dist/likee-context/usecase-ad-query.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-data-query.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-display.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-h5-prototype.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-prd.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-prototype.png +0 -0
- package/builtin/web-ui/dist/likee-context/usecase-sync.png +0 -0
- package/package.json +1 -1
- package/builtin/web-ui/dist/assets/index-DlZeY5p1.css +0 -1
package/bin/lib/marketplace.mjs
CHANGED
|
@@ -392,10 +392,11 @@ export function listMarketplacePackages(workspaceRoot, opts = {}) {
|
|
|
392
392
|
return { nodes, collections };
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
export function listMarketplaceFlowSnippets(workspaceRoot) {
|
|
395
|
+
export function listMarketplaceFlowSnippets(workspaceRoot, opts = {}) {
|
|
396
396
|
const root = workspacePackageRoot(workspaceRoot);
|
|
397
397
|
const snippetsRoot = path.join(root, "flow-snippets");
|
|
398
398
|
const snippets = [];
|
|
399
|
+
const requestedUserId = String(opts.userId || "").trim();
|
|
399
400
|
if (!fs.existsSync(snippetsRoot)) return { snippets };
|
|
400
401
|
for (const entry of fs.readdirSync(snippetsRoot, { withFileTypes: true })) {
|
|
401
402
|
if (!entry.isDirectory()) continue;
|
|
@@ -405,6 +406,8 @@ export function listMarketplaceFlowSnippets(workspaceRoot) {
|
|
|
405
406
|
const manifest = readYamlObject(path.join(dir, FLOW_SNIPPET_MANIFEST));
|
|
406
407
|
if (!manifest) continue;
|
|
407
408
|
const snippet = manifest.snippet && typeof manifest.snippet === "object" ? manifest.snippet : {};
|
|
409
|
+
const ownerUserId = String(manifest.ownerUserId || manifest.createdBy || "").trim();
|
|
410
|
+
if (requestedUserId && ownerUserId !== requestedUserId) continue;
|
|
408
411
|
snippets.push({
|
|
409
412
|
id: manifest.id || entry.name,
|
|
410
413
|
version: manifest.version || version,
|
|
@@ -415,6 +418,7 @@ export function listMarketplaceFlowSnippets(workspaceRoot) {
|
|
|
415
418
|
edgeCount: Number(manifest.edgeCount) || (Array.isArray(snippet.edges) ? snippet.edges.length : 0),
|
|
416
419
|
createdAt: manifest.createdAt || "",
|
|
417
420
|
updatedAt: manifest.updatedAt || "",
|
|
421
|
+
ownerUserId,
|
|
418
422
|
packageDir: dir,
|
|
419
423
|
snippet,
|
|
420
424
|
});
|
|
@@ -449,12 +453,19 @@ export function deleteMarketplaceNodePackage(workspaceRoot, id, version, opts =
|
|
|
449
453
|
return { ok: true, id, version, packageDir };
|
|
450
454
|
}
|
|
451
455
|
|
|
452
|
-
export function deleteMarketplaceFlowSnippetPackage(workspaceRoot, id, version) {
|
|
456
|
+
export function deleteMarketplaceFlowSnippetPackage(workspaceRoot, id, version, opts = {}) {
|
|
453
457
|
const packageDir = resolveWorkspaceFlowSnippetPackageDir(workspaceRoot, id, version);
|
|
454
458
|
if (!packageDir) return { ok: false, error: "Invalid flow snippet id or version" };
|
|
455
|
-
|
|
459
|
+
const manifestPath = path.join(packageDir, FLOW_SNIPPET_MANIFEST);
|
|
460
|
+
if (!fs.existsSync(manifestPath)) {
|
|
456
461
|
return { ok: false, error: `Flow snippet package not found: ${id}@${version}` };
|
|
457
462
|
}
|
|
463
|
+
const manifest = readYamlObject(manifestPath) || {};
|
|
464
|
+
const ownerUserId = String(manifest.ownerUserId || manifest.createdBy || "").trim();
|
|
465
|
+
const requestedUserId = String(opts.userId || "").trim();
|
|
466
|
+
if (!requestedUserId || ownerUserId !== requestedUserId) {
|
|
467
|
+
return { ok: false, error: "Flow snippet permission denied" };
|
|
468
|
+
}
|
|
458
469
|
fs.rmSync(packageDir, { recursive: true, force: true });
|
|
459
470
|
const versionRoot = path.dirname(packageDir);
|
|
460
471
|
try {
|
|
@@ -732,11 +743,13 @@ export function publishNodeFromInstance(workspaceRoot, payload = {}, options = {
|
|
|
732
743
|
};
|
|
733
744
|
}
|
|
734
745
|
|
|
735
|
-
export function publishFlowSnippet(workspaceRoot, payload = {}) {
|
|
746
|
+
export function publishFlowSnippet(workspaceRoot, payload = {}, opts = {}) {
|
|
736
747
|
const label = String(payload.displayName || payload.name || payload.id || "flow snippet").trim();
|
|
737
748
|
const id = safePackageId(payload.id || payload.packageId || label);
|
|
738
749
|
const version = normalizeVersion(payload.version || "1.0.0");
|
|
739
750
|
if (!id) return { ok: false, error: "Invalid snippet id" };
|
|
751
|
+
const ownerUserId = String(opts.userId || "").trim();
|
|
752
|
+
if (!ownerUserId) return { ok: false, error: "Authentication required" };
|
|
740
753
|
|
|
741
754
|
const rawSnippet = payload.snippet && typeof payload.snippet === "object" ? payload.snippet : {};
|
|
742
755
|
const instances = rawSnippet.instances && typeof rawSnippet.instances === "object" ? rawSnippet.instances : {};
|
|
@@ -748,6 +761,11 @@ export function publishFlowSnippet(workspaceRoot, payload = {}) {
|
|
|
748
761
|
const now = new Date().toISOString();
|
|
749
762
|
const dest = resolveWorkspaceFlowSnippetPackageDir(workspaceRoot, id, version);
|
|
750
763
|
if (!dest) return { ok: false, error: "Invalid snippet id or version" };
|
|
764
|
+
const existingManifest = readYamlObject(path.join(dest, FLOW_SNIPPET_MANIFEST));
|
|
765
|
+
if (existingManifest) {
|
|
766
|
+
const existingOwner = String(existingManifest.ownerUserId || existingManifest.createdBy || "").trim();
|
|
767
|
+
if (existingOwner !== ownerUserId) return { ok: false, error: "Flow snippet permission denied" };
|
|
768
|
+
}
|
|
751
769
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
752
770
|
fs.rmSync(dest, { recursive: true, force: true });
|
|
753
771
|
fs.mkdirSync(dest, { recursive: true });
|
|
@@ -759,6 +777,8 @@ export function publishFlowSnippet(workspaceRoot, payload = {}) {
|
|
|
759
777
|
displayName: label,
|
|
760
778
|
description: String(payload.description || "").trim(),
|
|
761
779
|
tags: Array.isArray(payload.tags) ? payload.tags.map((x) => String(x).trim()).filter(Boolean) : [],
|
|
780
|
+
ownerUserId,
|
|
781
|
+
createdBy: ownerUserId,
|
|
762
782
|
nodeCount,
|
|
763
783
|
edgeCount: edges.length,
|
|
764
784
|
createdAt: now,
|
package/bin/lib/ui-server.mjs
CHANGED
|
@@ -4842,7 +4842,7 @@ export function startUiServer({
|
|
|
4842
4842
|
|
|
4843
4843
|
if (req.method === "GET" && url.pathname === "/api/marketplace/flow-snippets") {
|
|
4844
4844
|
try {
|
|
4845
|
-
json(res, 200, listMarketplaceFlowSnippets(root));
|
|
4845
|
+
json(res, 200, listMarketplaceFlowSnippets(root, userCtx));
|
|
4846
4846
|
} catch (e) {
|
|
4847
4847
|
json(res, 500, { error: (e && e.message) || String(e) });
|
|
4848
4848
|
}
|
|
@@ -4873,7 +4873,7 @@ export function startUiServer({
|
|
|
4873
4873
|
return;
|
|
4874
4874
|
}
|
|
4875
4875
|
try {
|
|
4876
|
-
const result = deleteMarketplaceFlowSnippetPackage(root, id, version);
|
|
4876
|
+
const result = deleteMarketplaceFlowSnippetPackage(root, id, version, userCtx);
|
|
4877
4877
|
json(res, result.ok ? 200 : 400, result);
|
|
4878
4878
|
} catch (e) {
|
|
4879
4879
|
json(res, 500, { ok: false, error: (e && e.message) || String(e) });
|
|
@@ -4952,7 +4952,7 @@ export function startUiServer({
|
|
|
4952
4952
|
return;
|
|
4953
4953
|
}
|
|
4954
4954
|
try {
|
|
4955
|
-
const result = publishFlowSnippet(root, payload || {});
|
|
4955
|
+
const result = publishFlowSnippet(root, payload || {}, userCtx);
|
|
4956
4956
|
json(res, result.ok ? 200 : 400, result);
|
|
4957
4957
|
} catch (e) {
|
|
4958
4958
|
json(res, 500, { ok: false, error: (e && e.message) || String(e) });
|