@agents24/cli 0.1.0

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/cli.js ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ assertImportAllowed,
4
+ createRemoteClient,
5
+ initializePackage,
6
+ packPackage,
7
+ parseMappings,
8
+ validatePackage
9
+ } from "./chunk-I2XQSX32.js";
10
+
11
+ // src/cli.ts
12
+ import { basename, resolve } from "path";
13
+ import { writeFile } from "fs/promises";
14
+ import { createInterface } from "readline/promises";
15
+ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["json", "remote", "yes", "allow-incomplete"]);
16
+ function parse(argv) {
17
+ if (argv[0] !== "package" || !argv[1]) throw new Error("Usage: agents24 package <init|validate|pack|export|compile|preview|import>");
18
+ const flags = /* @__PURE__ */ new Map();
19
+ const positionals = [];
20
+ for (let index = 2; index < argv.length; index += 1) {
21
+ const current = argv[index];
22
+ if (!current.startsWith("--")) {
23
+ positionals.push(current);
24
+ continue;
25
+ }
26
+ const [rawName, inline] = current.slice(2).split("=", 2);
27
+ if (!rawName) throw new Error("Invalid option");
28
+ const value = inline ?? (BOOLEAN_FLAGS.has(rawName) ? "true" : argv[++index]);
29
+ if (value === void 0 || value.startsWith("--")) throw new Error(`--${rawName} requires a value`);
30
+ flags.set(rawName, [...flags.get(rawName) || [], value]);
31
+ }
32
+ return { command: argv[1], positionals, flags };
33
+ }
34
+ function flag(parsed, name) {
35
+ return parsed.flags.get(name)?.at(-1);
36
+ }
37
+ function values(parsed, name) {
38
+ return parsed.flags.get(name) || [];
39
+ }
40
+ function mappings(parsed) {
41
+ return parseMappings(values(parsed, "map"));
42
+ }
43
+ function upload(data, input) {
44
+ return { data, filename: basename(input).endsWith(".zip") ? basename(input) : "resource.agents24.zip" };
45
+ }
46
+ function safeResult(result) {
47
+ return result;
48
+ }
49
+ async function confirmation(parsed, preview) {
50
+ const resources = Array.isArray(preview.resources) ? preview.resources : [];
51
+ const yes = flag(parsed, "yes") === "true";
52
+ assertImportAllowed(preview, {
53
+ allowIncomplete: flag(parsed, "allow-incomplete") === "true",
54
+ yes,
55
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
56
+ });
57
+ if (yes) return;
58
+ const prompt = createInterface({ input: process.stdin, output: process.stdout });
59
+ const answer = await prompt.question(`Import ${resources.length} resource draft(s)? [y/N] `);
60
+ prompt.close();
61
+ if (!/^y(?:es)?$/i.test(answer.trim())) throw new Error("Import cancelled");
62
+ }
63
+ async function compiledPackage(parsed) {
64
+ const input = parsed.positionals[0];
65
+ if (!input) throw new Error(`${parsed.command} requires a package directory or ZIP`);
66
+ const local = await validatePackage(input);
67
+ if (!local.valid) throw Object.assign(new Error("Resource package is invalid"), { diagnostics: local.diagnostics });
68
+ const data = await packPackage(input);
69
+ const client = await createRemoteClient();
70
+ const result = await client.resourcePackages.compilePackage(upload(data, input));
71
+ return { data, result };
72
+ }
73
+ async function execute(parsed) {
74
+ if (parsed.command === "init") {
75
+ const directory = resolve(parsed.positionals[0] || ".");
76
+ const name = flag(parsed, "name") || basename(directory);
77
+ const packageName = await initializePackage(directory, name);
78
+ return { ok: true, directory, package: packageName };
79
+ }
80
+ if (parsed.command === "validate") {
81
+ const input = parsed.positionals[0];
82
+ if (!input) throw new Error("validate requires a package directory or ZIP");
83
+ const local = await validatePackage(input);
84
+ let remote;
85
+ if (flag(parsed, "remote") === "true" && local.valid) {
86
+ const data = await packPackage(input);
87
+ remote = await (await createRemoteClient()).resourcePackages.validatePackage(upload(data, input));
88
+ }
89
+ return { ok: local.valid && (!remote || remote.valid === true), local: { ...local, files: void 0 }, ...remote ? { remote } : {} };
90
+ }
91
+ if (parsed.command === "pack") {
92
+ const input = parsed.positionals[0];
93
+ if (!input) throw new Error("pack requires a package directory");
94
+ const data = await packPackage(input);
95
+ const output = resolve(flag(parsed, "output") || `${basename(resolve(input))}.agents24.zip`);
96
+ await writeFile(output, data);
97
+ return { ok: true, output, bytes: data.byteLength };
98
+ }
99
+ if (parsed.command === "export") {
100
+ const kind = flag(parsed, "kind");
101
+ const id = flag(parsed, "id");
102
+ if (!kind || !id) throw new Error("export requires --kind and --id");
103
+ const target = flag(parsed, "target") || "draft";
104
+ const request = {
105
+ root: { kind, id, target, ...flag(parsed, "version-id") ? { version_id: flag(parsed, "version-id") } : {} }
106
+ };
107
+ const archive = await (await createRemoteClient()).resourcePackages.exportPackage(request);
108
+ const output = resolve(flag(parsed, "output") || archive.filename);
109
+ await writeFile(output, archive.data);
110
+ return { ok: true, output, bytes: archive.data.byteLength };
111
+ }
112
+ if (parsed.command === "compile") {
113
+ const { result } = await compiledPackage(parsed);
114
+ const output = flag(parsed, "output");
115
+ if (output) await writeFile(resolve(output), `${JSON.stringify(result.bundle, null, 2)}
116
+ `);
117
+ return { ok: result.valid === true, ...output ? { output: resolve(output) } : {}, result: safeResult(result) };
118
+ }
119
+ if (parsed.command === "preview" || parsed.command === "import") {
120
+ const { result } = await compiledPackage(parsed);
121
+ if (result.valid !== true || !result.bundle || typeof result.bundle !== "object") throw new Error("Remote compilation did not produce a bundle");
122
+ const request = {
123
+ bundle: result.bundle,
124
+ mappings: mappings(parsed)
125
+ };
126
+ const client = await createRemoteClient();
127
+ const preview = await client.resourceBundles.importPreview(request);
128
+ if (parsed.command === "preview") return { ok: preview.can_import === true, preview };
129
+ if (preview.can_import !== true) return { ok: false, preview };
130
+ await confirmation(parsed, preview);
131
+ return { ok: true, preview, result: await client.resourceBundles.importBundle(request) };
132
+ }
133
+ throw new Error(`Unknown package command: ${parsed.command}`);
134
+ }
135
+ function diagnostics(error) {
136
+ if (!error || typeof error !== "object") return void 0;
137
+ const record = error;
138
+ if (Array.isArray(record.diagnostics)) return record.diagnostics;
139
+ if (!record.details || typeof record.details !== "object" || Array.isArray(record.details)) return void 0;
140
+ const detail = record.details.detail;
141
+ if (!detail || typeof detail !== "object" || Array.isArray(detail)) return void 0;
142
+ const value = detail.diagnostics;
143
+ return Array.isArray(value) ? value : void 0;
144
+ }
145
+ async function run(argv = process.argv.slice(2)) {
146
+ let parsed;
147
+ try {
148
+ parsed = parse(argv);
149
+ const result = await execute(parsed);
150
+ if (flag(parsed, "json") === "true") process.stdout.write(`${JSON.stringify(result)}
151
+ `);
152
+ else if (result.ok === false) process.stderr.write(`${JSON.stringify(result, null, 2)}
153
+ `);
154
+ else process.stdout.write(`${JSON.stringify(result, null, 2)}
155
+ `);
156
+ return result.ok === false ? 1 : 0;
157
+ } catch (error) {
158
+ const payload = {
159
+ ok: false,
160
+ error: error instanceof Error ? error.message : "Unexpected CLI failure",
161
+ ...diagnostics(error) ? { diagnostics: diagnostics(error) } : {}
162
+ };
163
+ const body = parsed && flag(parsed, "json") === "true" ? JSON.stringify(payload) : JSON.stringify(payload, null, 2);
164
+ process.stderr.write(`${body}
165
+ `);
166
+ return 1;
167
+ }
168
+ }
169
+ process.exitCode = await run();
170
+ export {
171
+ run
172
+ };
173
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { basename, resolve } from \"node:path\";\nimport { writeFile } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline/promises\";\n\nimport { initializePackage, packPackage, validatePackage, type Diagnostic } from \"./package-source.js\";\nimport { createRemoteClient } from \"./remote.js\";\nimport { assertImportAllowed, parseMappings } from \"./import-guards.js\";\n\ntype Parsed = {\n command: string;\n positionals: string[];\n flags: Map<string, string[]>;\n};\n\nconst BOOLEAN_FLAGS = new Set([\"json\", \"remote\", \"yes\", \"allow-incomplete\"]);\n\nfunction parse(argv: string[]): Parsed {\n if (argv[0] !== \"package\" || !argv[1]) throw new Error(\"Usage: agents24 package <init|validate|pack|export|compile|preview|import>\");\n const flags = new Map<string, string[]>();\n const positionals: string[] = [];\n for (let index = 2; index < argv.length; index += 1) {\n const current = argv[index];\n if (!current.startsWith(\"--\")) { positionals.push(current); continue; }\n const [rawName, inline] = current.slice(2).split(\"=\", 2);\n if (!rawName) throw new Error(\"Invalid option\");\n const value = inline ?? (BOOLEAN_FLAGS.has(rawName) ? \"true\" : argv[++index]);\n if (value === undefined || value.startsWith(\"--\")) throw new Error(`--${rawName} requires a value`);\n flags.set(rawName, [...(flags.get(rawName) || []), value]);\n }\n return { command: argv[1], positionals, flags };\n}\n\nfunction flag(parsed: Parsed, name: string): string | undefined {\n return parsed.flags.get(name)?.at(-1);\n}\n\nfunction values(parsed: Parsed, name: string): string[] {\n return parsed.flags.get(name) || [];\n}\n\nfunction mappings(parsed: Parsed): Record<string, string> {\n return parseMappings(values(parsed, \"map\"));\n}\n\nfunction upload(data: Uint8Array, input: string): { data: Uint8Array; filename: string } {\n return { data, filename: basename(input).endsWith(\".zip\") ? basename(input) : \"resource.agents24.zip\" };\n}\n\nfunction safeResult(result: Record<string, unknown>): Record<string, unknown> {\n return result;\n}\n\nasync function confirmation(parsed: Parsed, preview: Record<string, unknown>): Promise<void> {\n const resources = Array.isArray(preview.resources) ? preview.resources as Array<Record<string, unknown>> : [];\n const yes = flag(parsed, \"yes\") === \"true\";\n assertImportAllowed(preview, {\n allowIncomplete: flag(parsed, \"allow-incomplete\") === \"true\",\n yes,\n interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),\n });\n if (yes) return;\n const prompt = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await prompt.question(`Import ${resources.length} resource draft(s)? [y/N] `);\n prompt.close();\n if (!/^y(?:es)?$/i.test(answer.trim())) throw new Error(\"Import cancelled\");\n}\n\nasync function compiledPackage(parsed: Parsed): Promise<{ data: Uint8Array; result: Record<string, unknown> }> {\n const input = parsed.positionals[0];\n if (!input) throw new Error(`${parsed.command} requires a package directory or ZIP`);\n const local = await validatePackage(input);\n if (!local.valid) throw Object.assign(new Error(\"Resource package is invalid\"), { diagnostics: local.diagnostics });\n const data = await packPackage(input);\n const client = await createRemoteClient();\n const result = await client.resourcePackages.compilePackage(upload(data, input));\n return { data, result };\n}\n\nasync function execute(parsed: Parsed): Promise<Record<string, unknown>> {\n if (parsed.command === \"init\") {\n const directory = resolve(parsed.positionals[0] || \".\");\n const name = flag(parsed, \"name\") || basename(directory);\n const packageName = await initializePackage(directory, name);\n return { ok: true, directory, package: packageName };\n }\n if (parsed.command === \"validate\") {\n const input = parsed.positionals[0];\n if (!input) throw new Error(\"validate requires a package directory or ZIP\");\n const local = await validatePackage(input);\n let remote: Record<string, unknown> | undefined;\n if (flag(parsed, \"remote\") === \"true\" && local.valid) {\n const data = await packPackage(input);\n remote = await (await createRemoteClient()).resourcePackages.validatePackage(upload(data, input));\n }\n return { ok: local.valid && (!remote || remote.valid === true), local: { ...local, files: undefined }, ...(remote ? { remote } : {}) };\n }\n if (parsed.command === \"pack\") {\n const input = parsed.positionals[0];\n if (!input) throw new Error(\"pack requires a package directory\");\n const data = await packPackage(input);\n const output = resolve(flag(parsed, \"output\") || `${basename(resolve(input))}.agents24.zip`);\n await writeFile(output, data);\n return { ok: true, output, bytes: data.byteLength };\n }\n if (parsed.command === \"export\") {\n const kind = flag(parsed, \"kind\");\n const id = flag(parsed, \"id\");\n if (!kind || !id) throw new Error(\"export requires --kind and --id\");\n const target = flag(parsed, \"target\") || \"draft\";\n const request = {\n root: { kind, id, target, ...(flag(parsed, \"version-id\") ? { version_id: flag(parsed, \"version-id\") } : {}) },\n };\n const archive = await (await createRemoteClient()).resourcePackages.exportPackage(request);\n const output = resolve(flag(parsed, \"output\") || archive.filename);\n await writeFile(output, archive.data);\n return { ok: true, output, bytes: archive.data.byteLength };\n }\n if (parsed.command === \"compile\") {\n const { result } = await compiledPackage(parsed);\n const output = flag(parsed, \"output\");\n if (output) await writeFile(resolve(output), `${JSON.stringify(result.bundle, null, 2)}\\n`);\n return { ok: result.valid === true, ...(output ? { output: resolve(output) } : {}), result: safeResult(result) };\n }\n if (parsed.command === \"preview\" || parsed.command === \"import\") {\n const { result } = await compiledPackage(parsed);\n if (result.valid !== true || !result.bundle || typeof result.bundle !== \"object\") throw new Error(\"Remote compilation did not produce a bundle\");\n const request = {\n bundle: result.bundle as Record<string, unknown>,\n mappings: mappings(parsed),\n };\n const client = await createRemoteClient();\n const preview = await client.resourceBundles.importPreview(request);\n if (parsed.command === \"preview\") return { ok: preview.can_import === true, preview };\n if (preview.can_import !== true) return { ok: false, preview };\n await confirmation(parsed, preview);\n return { ok: true, preview, result: await client.resourceBundles.importBundle(request) };\n }\n throw new Error(`Unknown package command: ${parsed.command}`);\n}\n\nfunction diagnostics(error: unknown): Diagnostic[] | undefined {\n if (!error || typeof error !== \"object\") return undefined;\n const record = error as { diagnostics?: unknown; details?: unknown };\n if (Array.isArray(record.diagnostics)) return record.diagnostics as Diagnostic[];\n if (!record.details || typeof record.details !== \"object\" || Array.isArray(record.details)) return undefined;\n const detail = (record.details as Record<string, unknown>).detail;\n if (!detail || typeof detail !== \"object\" || Array.isArray(detail)) return undefined;\n const value = (detail as Record<string, unknown>).diagnostics;\n return Array.isArray(value) ? value as Diagnostic[] : undefined;\n}\n\nexport async function run(argv = process.argv.slice(2)): Promise<number> {\n let parsed: Parsed | undefined;\n try {\n parsed = parse(argv);\n const result = await execute(parsed);\n if (flag(parsed, \"json\") === \"true\") process.stdout.write(`${JSON.stringify(result)}\\n`);\n else if (result.ok === false) process.stderr.write(`${JSON.stringify(result, null, 2)}\\n`);\n else process.stdout.write(`${JSON.stringify(result, null, 2)}\\n`);\n return result.ok === false ? 1 : 0;\n } catch (error) {\n const payload = {\n ok: false,\n error: error instanceof Error ? error.message : \"Unexpected CLI failure\",\n ...(diagnostics(error) ? { diagnostics: diagnostics(error) } : {}),\n };\n const body = parsed && flag(parsed, \"json\") === \"true\" ? JSON.stringify(payload) : JSON.stringify(payload, null, 2);\n process.stderr.write(`${body}\\n`);\n return 1;\n }\n}\n\nprocess.exitCode = await run();\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,UAAU,eAAe;AAClC,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAYhC,IAAM,gBAAgB,o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AK,IAAI,EAAE,aAAa,YAAY,KAAK,EAAE,IAAI,CAAC;AAAA,IAClE;AACA,UAAM,OAAO,UAAU,KAAK,QAAQ,MAAM,MAAM,SAAS,KAAK,UAAU,OAAO,IAAI,KAAK,UAAU,SAAS,MAAM,CAAC;AAClH,YAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAChC,WAAO;AAAA,EACT;AACF;AAEA,QAAQ,WAAW,MAAM,IAAI;","names":[]}
@@ -0,0 +1,56 @@
1
+ declare function packFiles(files: Map<string, string>): Uint8Array;
2
+ declare function unpackFiles(value: Uint8Array): Map<string, string>;
3
+
4
+ type Diagnostic = {
5
+ severity: "error" | "warning";
6
+ code: string;
7
+ path: string;
8
+ message: string;
9
+ };
10
+ type ValidationResult = {
11
+ valid: boolean;
12
+ package: Record<string, unknown>;
13
+ resources: Array<Record<string, unknown>>;
14
+ requirements: string[];
15
+ diagnostics: Diagnostic[];
16
+ files: Map<string, string>;
17
+ };
18
+ declare function loadPackageFiles(input: string): Promise<Map<string, string>>;
19
+ declare function validateFiles(files: Map<string, string>): ValidationResult;
20
+ declare function validatePackage(input: string): Promise<ValidationResult>;
21
+ declare function packPackage(input: string): Promise<Uint8Array>;
22
+ declare function initializePackage(directory: string, packageName: string): Promise<string>;
23
+
24
+ declare function parseMappings(items: string[]): Record<string, string>;
25
+ declare function assertImportAllowed(preview: Record<string, unknown>, options: {
26
+ allowIncomplete: boolean;
27
+ yes: boolean;
28
+ interactive: boolean;
29
+ }): void;
30
+
31
+ type ResourcePackageUpload = {
32
+ data: Uint8Array;
33
+ filename?: string;
34
+ };
35
+ type ResourceBundleRequest = {
36
+ bundle: Record<string, unknown>;
37
+ selected_resource_keys?: string[];
38
+ mappings?: Record<string, string>;
39
+ };
40
+ type RemoteClient = {
41
+ resourcePackages: {
42
+ exportPackage(request: Record<string, unknown>): Promise<{
43
+ data: Uint8Array;
44
+ filename: string;
45
+ }>;
46
+ validatePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;
47
+ compilePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;
48
+ };
49
+ resourceBundles: {
50
+ importPreview(request: ResourceBundleRequest): Promise<Record<string, unknown>>;
51
+ importBundle(request: ResourceBundleRequest): Promise<Record<string, unknown>>;
52
+ };
53
+ };
54
+ declare function createRemoteClient(environment?: NodeJS.ProcessEnv): Promise<RemoteClient>;
55
+
56
+ export { type Diagnostic, type RemoteClient, type ValidationResult, assertImportAllowed, createRemoteClient, initializePackage, loadPackageFiles, packFiles, packPackage, parseMappings, unpackFiles, validateFiles, validatePackage };
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ assertImportAllowed,
4
+ createRemoteClient,
5
+ initializePackage,
6
+ loadPackageFiles,
7
+ packFiles,
8
+ packPackage,
9
+ parseMappings,
10
+ unpackFiles,
11
+ validateFiles,
12
+ validatePackage
13
+ } from "./chunk-I2XQSX32.js";
14
+ export {
15
+ assertImportAllowed,
16
+ createRemoteClient,
17
+ initializePackage,
18
+ loadPackageFiles,
19
+ packFiles,
20
+ packPackage,
21
+ parseMappings,
22
+ unpackFiles,
23
+ validateFiles,
24
+ validatePackage
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,134 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://docs.agents24.dev/schemas/resource-package/1.0/agent.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "schema",
8
+ "name",
9
+ "description",
10
+ "model"
11
+ ],
12
+ "properties": {
13
+ "schema": {
14
+ "const": "agents24.agent/v1"
15
+ },
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1
19
+ },
20
+ "description": {
21
+ "type": "string",
22
+ "minLength": 1
23
+ },
24
+ "model": {
25
+ "type": "string"
26
+ },
27
+ "instructions": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string"
31
+ }
32
+ },
33
+ "skills": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "string"
37
+ }
38
+ },
39
+ "tools": {
40
+ "type": "array",
41
+ "items": {
42
+ "type": "object",
43
+ "required": [
44
+ "kind",
45
+ "uses"
46
+ ],
47
+ "additionalProperties": false,
48
+ "properties": {
49
+ "kind": {
50
+ "enum": [
51
+ "agent",
52
+ "rag",
53
+ "tool",
54
+ "toolset",
55
+ "integration"
56
+ ]
57
+ },
58
+ "uses": {
59
+ "type": "string"
60
+ },
61
+ "load": {
62
+ "enum": [
63
+ "static",
64
+ "dynamic"
65
+ ]
66
+ }
67
+ }
68
+ }
69
+ },
70
+ "reasoning": {
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "properties": {
74
+ "effort": {
75
+ "enum": [
76
+ "low",
77
+ "medium",
78
+ "high"
79
+ ]
80
+ }
81
+ }
82
+ },
83
+ "execution": {
84
+ "type": "object",
85
+ "additionalProperties": false,
86
+ "properties": {
87
+ "tool_mode": {
88
+ "enum": [
89
+ "sequential",
90
+ "parallel_safe"
91
+ ]
92
+ },
93
+ "max_tool_iterations": {
94
+ "type": "integer",
95
+ "minimum": 1
96
+ },
97
+ "max_parallel_tools": {
98
+ "type": "integer",
99
+ "minimum": 1
100
+ }
101
+ }
102
+ },
103
+ "chat_history": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "enabled": {
108
+ "type": "boolean"
109
+ }
110
+ }
111
+ },
112
+ "structured_output": {
113
+ "type": "object",
114
+ "additionalProperties": false,
115
+ "properties": {
116
+ "format": {
117
+ "enum": [
118
+ "text",
119
+ "json"
120
+ ]
121
+ },
122
+ "schema": {
123
+ "type": "object"
124
+ }
125
+ }
126
+ },
127
+ "tags": {
128
+ "type": "array",
129
+ "items": {
130
+ "type": "string"
131
+ }
132
+ }
133
+ }
134
+ }
@@ -0,0 +1,154 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://docs.agents24.dev/schemas/resource-package/1.0/manifest.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "schema",
8
+ "name",
9
+ "entrypoint"
10
+ ],
11
+ "$defs": {
12
+ "requirement": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "description": {
17
+ "type": "string",
18
+ "maxLength": 2000
19
+ },
20
+ "required": {
21
+ "type": "boolean"
22
+ },
23
+ "match": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "name": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "maxLength": 256
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ },
37
+ "properties": {
38
+ "schema": {
39
+ "const": "agents24.package/v1"
40
+ },
41
+ "name": {
42
+ "type": "string",
43
+ "minLength": 1,
44
+ "maxLength": 128
45
+ },
46
+ "description": {
47
+ "type": "string",
48
+ "maxLength": 2000
49
+ },
50
+ "version": {
51
+ "type": "string"
52
+ },
53
+ "entrypoint": {
54
+ "type": "string",
55
+ "pattern": "^(workflows|rag|skills)/[a-z0-9][a-z0-9-]*\\.(yaml|md)$"
56
+ },
57
+ "requires": {
58
+ "type": "object",
59
+ "additionalProperties": false,
60
+ "properties": {
61
+ "workflows": {
62
+ "type": "object",
63
+ "propertyNames": {
64
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
65
+ },
66
+ "additionalProperties": {
67
+ "$ref": "#/$defs/requirement"
68
+ }
69
+ },
70
+ "rag": {
71
+ "type": "object",
72
+ "propertyNames": {
73
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
74
+ },
75
+ "additionalProperties": {
76
+ "$ref": "#/$defs/requirement"
77
+ }
78
+ },
79
+ "skills": {
80
+ "type": "object",
81
+ "propertyNames": {
82
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
83
+ },
84
+ "additionalProperties": {
85
+ "$ref": "#/$defs/requirement"
86
+ }
87
+ },
88
+ "models": {
89
+ "type": "object",
90
+ "propertyNames": {
91
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
92
+ },
93
+ "additionalProperties": {
94
+ "$ref": "#/$defs/requirement"
95
+ }
96
+ },
97
+ "stores": {
98
+ "type": "object",
99
+ "propertyNames": {
100
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
101
+ },
102
+ "additionalProperties": {
103
+ "$ref": "#/$defs/requirement"
104
+ }
105
+ },
106
+ "tools": {
107
+ "type": "object",
108
+ "propertyNames": {
109
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
110
+ },
111
+ "additionalProperties": {
112
+ "$ref": "#/$defs/requirement"
113
+ }
114
+ },
115
+ "toolsets": {
116
+ "type": "object",
117
+ "propertyNames": {
118
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
119
+ },
120
+ "additionalProperties": {
121
+ "$ref": "#/$defs/requirement"
122
+ }
123
+ },
124
+ "artifacts": {
125
+ "type": "object",
126
+ "propertyNames": {
127
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
128
+ },
129
+ "additionalProperties": {
130
+ "$ref": "#/$defs/requirement"
131
+ }
132
+ },
133
+ "integrations": {
134
+ "type": "object",
135
+ "propertyNames": {
136
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
137
+ },
138
+ "additionalProperties": {
139
+ "$ref": "#/$defs/requirement"
140
+ }
141
+ },
142
+ "secrets": {
143
+ "type": "object",
144
+ "propertyNames": {
145
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
146
+ },
147
+ "additionalProperties": {
148
+ "$ref": "#/$defs/requirement"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,96 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://docs.agents24.dev/schemas/resource-package/1.0/rag.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "schema",
8
+ "name",
9
+ "mode",
10
+ "steps"
11
+ ],
12
+ "properties": {
13
+ "schema": {
14
+ "const": "agents24.rag/v1"
15
+ },
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1
19
+ },
20
+ "description": {
21
+ "type": "string"
22
+ },
23
+ "tags": {
24
+ "type": "array",
25
+ "items": {
26
+ "type": "string"
27
+ }
28
+ },
29
+ "mode": {
30
+ "enum": [
31
+ "ingestion",
32
+ "retrieval"
33
+ ]
34
+ },
35
+ "inputs": {
36
+ "type": "object"
37
+ },
38
+ "outputs": {
39
+ "type": "object"
40
+ },
41
+ "steps": {
42
+ "type": "object",
43
+ "minProperties": 1,
44
+ "additionalProperties": {
45
+ "type": "object",
46
+ "required": [
47
+ "uses"
48
+ ],
49
+ "properties": {
50
+ "uses": {
51
+ "type": "string"
52
+ },
53
+ "with": {
54
+ "type": "object"
55
+ }
56
+ },
57
+ "additionalProperties": false
58
+ }
59
+ },
60
+ "flow": {
61
+ "type": "array",
62
+ "items": {
63
+ "type": "object",
64
+ "required": [
65
+ "from",
66
+ "to"
67
+ ],
68
+ "properties": {
69
+ "from": {
70
+ "type": "string"
71
+ },
72
+ "to": {
73
+ "type": "string"
74
+ }
75
+ },
76
+ "additionalProperties": false
77
+ }
78
+ },
79
+ "tool": {
80
+ "type": "object",
81
+ "required": [
82
+ "name",
83
+ "description"
84
+ ],
85
+ "properties": {
86
+ "name": {
87
+ "type": "string"
88
+ },
89
+ "description": {
90
+ "type": "string"
91
+ }
92
+ },
93
+ "additionalProperties": false
94
+ }
95
+ }
96
+ }