@agentstorm/server 0.2.5

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,49 @@
1
+ /**
2
+ * The on-disk contract for a project Workflow. A Workflow is one directory
3
+ * named by its display name; executable graph, canvas metadata and Prompt
4
+ * files are never split across sibling roots.
5
+ *
6
+ * .agentstorm/workflows/<display name>/
7
+ * manifest.json
8
+ * workflow.json
9
+ * layout.json
10
+ * prompts/<agent id>.md
11
+ * assets/<...>
12
+ * .versions/<n>.json
13
+ */
14
+ export declare const WORKFLOW_PACKAGE_ROOT = ".agentstorm/workflows";
15
+ export interface WorkflowPackageManifest {
16
+ schemaVersion: 1;
17
+ name: string;
18
+ description: string;
19
+ version: number;
20
+ source?: {
21
+ kind: "blank" | "template" | "bundle";
22
+ templateId?: string;
23
+ templateVersion?: number;
24
+ };
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ }
28
+ export interface WorkflowPackagePaths {
29
+ root: string;
30
+ manifest: string;
31
+ workflow: string;
32
+ layout: string;
33
+ prompts: string;
34
+ assets: string;
35
+ versions: string;
36
+ }
37
+ export declare function assertWorkflowDisplayName(value: string): string;
38
+ export declare function workflowPackagePaths(workspaceRoot: string, displayName: string): WorkflowPackagePaths;
39
+ export declare function workflowPackageExists(workspaceRoot: string, displayName: string): boolean;
40
+ export declare function listWorkflowPackageNames(workspaceRoot: string): string[];
41
+ export declare function readJsonFile<T>(filePath: string): T;
42
+ export declare function writeJsonAtomic(filePath: string, value: unknown): void;
43
+ export declare function writeTextAtomic(filePath: string, value: string): void;
44
+ export declare function safePackageRelativePath(value: string): string | null;
45
+ export declare function assertInsidePackage(packageRoot: string, candidate: string): void;
46
+ export declare function recordWorkflowPackageVersion(paths: WorkflowPackagePaths, raw: string): number;
47
+ export declare function latestWorkflowPackageVersion(paths: WorkflowPackagePaths): number;
48
+ export declare function workflowPromptRelativePath(nodeId: string): string;
49
+ //# sourceMappingURL=workflow-package.d.ts.map
@@ -0,0 +1,113 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ /**
4
+ * The on-disk contract for a project Workflow. A Workflow is one directory
5
+ * named by its display name; executable graph, canvas metadata and Prompt
6
+ * files are never split across sibling roots.
7
+ *
8
+ * .agentstorm/workflows/<display name>/
9
+ * manifest.json
10
+ * workflow.json
11
+ * layout.json
12
+ * prompts/<agent id>.md
13
+ * assets/<...>
14
+ * .versions/<n>.json
15
+ */
16
+ export const WORKFLOW_PACKAGE_ROOT = ".agentstorm/workflows";
17
+ export function assertWorkflowDisplayName(value) {
18
+ const name = value.trim();
19
+ if (!name || name === "." || name === ".." || /[\\/\0]/.test(name)) {
20
+ throw new Error("Workflow 显示名称不能为空,且不能包含 /、\\ 或 NUL");
21
+ }
22
+ return name;
23
+ }
24
+ export function workflowPackagePaths(workspaceRoot, displayName) {
25
+ const name = assertWorkflowDisplayName(displayName);
26
+ const root = path.join(workspaceRoot, WORKFLOW_PACKAGE_ROOT, name);
27
+ return {
28
+ root,
29
+ manifest: path.join(root, "manifest.json"),
30
+ workflow: path.join(root, "workflow.json"),
31
+ layout: path.join(root, "layout.json"),
32
+ prompts: path.join(root, "prompts"),
33
+ assets: path.join(root, "assets"),
34
+ versions: path.join(root, ".versions"),
35
+ };
36
+ }
37
+ export function workflowPackageExists(workspaceRoot, displayName) {
38
+ const paths = workflowPackagePaths(workspaceRoot, displayName);
39
+ return fs.existsSync(paths.root) && fs.statSync(paths.root).isDirectory();
40
+ }
41
+ export function listWorkflowPackageNames(workspaceRoot) {
42
+ const root = path.join(workspaceRoot, WORKFLOW_PACKAGE_ROOT);
43
+ if (!fs.existsSync(root))
44
+ return [];
45
+ return fs.readdirSync(root, { withFileTypes: true })
46
+ .filter((entry) => entry.isDirectory() && entry.name !== "." && entry.name !== ".." && !entry.name.startsWith("."))
47
+ .map((entry) => entry.name)
48
+ .filter((name) => {
49
+ try {
50
+ return fs.existsSync(workflowPackagePaths(workspaceRoot, name).workflow);
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ });
56
+ }
57
+ export function readJsonFile(filePath) {
58
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
59
+ }
60
+ export function writeJsonAtomic(filePath, value) {
61
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
62
+ const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
63
+ fs.writeFileSync(tmp, `${JSON.stringify(value, null, 2)}\n`, "utf8");
64
+ fs.renameSync(tmp, filePath);
65
+ }
66
+ export function writeTextAtomic(filePath, value) {
67
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
68
+ const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
69
+ fs.writeFileSync(tmp, value, "utf8");
70
+ fs.renameSync(tmp, filePath);
71
+ }
72
+ export function safePackageRelativePath(value) {
73
+ const normalized = value.replaceAll("\\", "/");
74
+ if (!normalized || normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized))
75
+ return null;
76
+ const parts = normalized.split("/");
77
+ if (parts.some((part) => !part || part === "." || part === ".."))
78
+ return null;
79
+ return parts.join(path.sep);
80
+ }
81
+ export function assertInsidePackage(packageRoot, candidate) {
82
+ const root = path.resolve(packageRoot);
83
+ const target = path.resolve(candidate);
84
+ if (target !== root && !target.startsWith(`${root}${path.sep}`)) {
85
+ throw new Error("Workflow 资源路径超出 Workflow 包目录");
86
+ }
87
+ }
88
+ export function recordWorkflowPackageVersion(paths, raw) {
89
+ fs.mkdirSync(paths.versions, { recursive: true });
90
+ const versions = fs.readdirSync(paths.versions)
91
+ .map((file) => /^(\d+)\.json$/.exec(file)?.[1])
92
+ .filter(Boolean)
93
+ .map(Number);
94
+ const version = Math.max(0, ...versions) + 1;
95
+ writeTextAtomic(path.join(paths.versions, `${version}.json`), raw);
96
+ return version;
97
+ }
98
+ export function latestWorkflowPackageVersion(paths) {
99
+ if (!fs.existsSync(paths.versions))
100
+ return 0;
101
+ return fs.readdirSync(paths.versions)
102
+ .map((file) => /^(\d+)\.json$/.exec(file)?.[1])
103
+ .filter(Boolean)
104
+ .map(Number)
105
+ .filter((version) => Number.isSafeInteger(version) && version > 0)
106
+ .sort((a, b) => a - b)
107
+ .at(-1) ?? 0;
108
+ }
109
+ export function workflowPromptRelativePath(nodeId) {
110
+ const safe = nodeId.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
111
+ return path.join("prompts", `${safe || "agent"}.md`);
112
+ }
113
+ //# sourceMappingURL=workflow-package.js.map
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@agentstorm/server",
3
+ "version": "0.2.5",
4
+ "description": "AgentStorm resident Pipeline service",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/",
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "@agentstorm/agent-runtime": "0.2.5",
23
+ "@agentstorm/kernel": "0.2.5",
24
+ "@agentstorm/protocol": "0.2.5",
25
+ "express": "^4.21.0"
26
+ },
27
+ "license": "AGPL-3.0-or-later",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://git.woa.com/jetteyang/agentstorm.git"
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ }
35
+ }