@agents24/cli 0.1.0 → 0.1.1
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/README.md +13 -9
- package/compatibility.json +10 -10
- package/dist/{chunk-I2XQSX32.js → chunk-MNGBA3HP.js} +38 -23
- package/dist/chunk-MNGBA3HP.js.map +1 -0
- package/dist/cli.js +289 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +24 -2
- package/dist/index.js +5 -1
- package/generated/schemas/resource-package/1.0/agent.schema.json +12 -0
- package/generated/schemas/resource-package/1.0/manifest.schema.json +18 -4
- package/generated/schemas/resource-package/1.0/store.schema.json +16 -0
- package/generated/schemas/resource-package/1.0/workflow.schema.json +26 -3
- package/package.json +3 -2
- package/dist/chunk-I2XQSX32.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@agents24/cli`
|
|
2
2
|
|
|
3
|
-
Last Updated: 2026-
|
|
3
|
+
Last Updated: 2026-08-06
|
|
4
4
|
|
|
5
5
|
Command-line tooling for editable `agents24.resource_package` source packages.
|
|
6
6
|
|
|
@@ -14,20 +14,24 @@ agents24 package pack ./customer-service
|
|
|
14
14
|
|
|
15
15
|
`init`, `validate`, and `pack` work offline. Add `--remote` to `validate` for canonical platform graph/operator validation.
|
|
16
16
|
|
|
17
|
-
Remote commands use the canonical `@agents24/node` client
|
|
17
|
+
Remote commands use the canonical `@agents24/node` client. `AGENTS24_API_KEY` is required; `AGENTS24_BASE_URL` is an optional advanced override of `https://api.agents24.dev`.
|
|
18
18
|
|
|
19
|
-
- `AGENTS24_BASE_URL`
|
|
20
19
|
- `AGENTS24_API_KEY`
|
|
21
|
-
- `AGENTS24_ORGANIZATION_ID`
|
|
22
|
-
- `AGENTS24_PROJECT_ID`
|
|
23
20
|
|
|
24
21
|
```bash
|
|
25
22
|
agents24 package export --kind agent --id <id> --target draft
|
|
26
23
|
agents24 package compile customer-service.agents24.zip --output bundle.json
|
|
27
|
-
agents24 package preview customer-service.agents24.zip
|
|
28
|
-
agents24 package import customer-service.agents24.zip --
|
|
24
|
+
agents24 package preview customer-service.agents24.zip
|
|
25
|
+
agents24 package import customer-service.agents24.zip --yes
|
|
26
|
+
agents24 install customer-service.agents24.zip --yes
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
`
|
|
29
|
+
`install` is the canonical remote installation workflow; the `package` commands remain authoring tools. It validates, compiles, resolves canonical Model requirements without model-selection prompts, previews, and imports the complete package, then publishes one selected Agent through the canonical Agent publish API. A missing preferred Model uses the effective default when available; otherwise the Agent/Store is saved without a model and can be configured later. That API publishes required RAG pipelines, Instructions, and child Agents; the CLI does not expose a separate RAG publication route. If the package contains several Agents, use `--agent <resource-key|id|name>` or choose interactively. `--map` remains available as an advanced override for noncanonical external requirements.
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
From a generated app, `install` reads `package.json.agents24.integration` automatically; `--app <directory>` selects another generated app. Without one, choose or pass `--integration <client-deployment|bff|publish-only>`. Client deployment uses guided active-policy, origin, and anonymous-auth defaults, then writes `VITE_AGENTS24_DEPLOYMENT_ID`. An explicit non-production `AGENTS24_BASE_URL` is copied as public `VITE_AGENTS24_BASE_URL` so the generated browser app reaches the same local or staging API. BFF writes `AGENTS24_API_KEY` and `AGENTS24_AGENT_ID`. `.env.local` is updated by default without disturbing unrelated entries and is locked to user-only permissions; `--no-write-env` leaves configuration for later.
|
|
32
|
+
|
|
33
|
+
The API key comes only from `AGENTS24_API_KEY` or an interactive masked prompt; `--api-key` is rejected. Create a new key in **Settings → API Keys** to receive the default Agent-integration permissions for install, publish, and trusted-server execution. Existing keys are not widened when that preset changes, so replace an under-scoped key. On authorization failure, the CLI reports this corrective guidance rather than the API's generic denial message. Guided client deployment uses `roles.read` only to list active Resource Policy sets; it does not modify them.
|
|
34
|
+
|
|
35
|
+
Completion prints the Agent ID, an optional deployment ID, and the app's next command, but never the key. `--json` includes `phase`, `integration`, `agent_id`, optional `deployment_id`, and `env_written`, without secrets. Repeatable `--map`, `--policy-set`, `--origin`, `--auth-mode`, `--oidc-config`, `--allow-incomplete`, and `--yes` remain available. Stable idempotency makes import, publication, and deployment retries safe; post-import and environment-write failures retain the imported resources and identify the resumable phase.
|
|
36
|
+
|
|
37
|
+
The canonical source tree is `agents24.yaml`, `workflows/*.yaml`, `agents/*.md`, `rag/*.yaml`, `skills/*.md`, `stores/*.yaml`, and optional `files/*.md`. The manifest has a sorted complete resource inventory and no entrypoint. It uses relative local references, external `$namespace.slug` requirements, and `[[skill:<slug>]]` inline Instruction mentions. `pack` writes stable ZIP order and metadata. See the [resource movement guide](https://docs.agents24.dev/guides/move-resource-bundles) and [manifest schema](https://docs.agents24.dev/schemas/resource-package/1.0/manifest.schema.json).
|
package/compatibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"contractHash": "
|
|
2
|
+
"contractHash": "13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2",
|
|
3
3
|
"contractVersion": "0.2.0",
|
|
4
4
|
"corpus": "conformance/v1/corpus.json",
|
|
5
5
|
"generatedBy": "@agents24/sdk-contract",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"reactDom": ">=19 <20"
|
|
16
16
|
},
|
|
17
17
|
"@agents24/client": {
|
|
18
|
-
"contract": "
|
|
19
|
-
"runtime": "run-stream.
|
|
18
|
+
"contract": "13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2",
|
|
19
|
+
"runtime": "run-stream.v3"
|
|
20
20
|
},
|
|
21
21
|
"@agents24/node": {
|
|
22
|
-
"contract": "
|
|
22
|
+
"contract": "13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2",
|
|
23
23
|
"node": "^22.0.0 || ^24.0.0"
|
|
24
24
|
},
|
|
25
25
|
"@agents24/react": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"react": ">=19 <20"
|
|
28
28
|
},
|
|
29
29
|
"@talmudpedia/runtime-sdk": {
|
|
30
|
-
"contract": "
|
|
30
|
+
"contract": "13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2",
|
|
31
31
|
"protocolOwner": "@agents24/client"
|
|
32
32
|
},
|
|
33
33
|
"agents24": {
|
|
34
|
-
"contract": "
|
|
34
|
+
"contract": "13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2",
|
|
35
35
|
"python": ">=3.10"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"protocols": {
|
|
39
39
|
"runtime": {
|
|
40
40
|
"minimum": "2.0.0",
|
|
41
|
-
"wire": "run-stream.
|
|
41
|
+
"wire": "run-stream.v3"
|
|
42
42
|
},
|
|
43
43
|
"threadSummary": {
|
|
44
44
|
"minimum": "1.0.0",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"schemaVersion": "agents24.compatibility.v1",
|
|
49
49
|
"targetOperationCounts": {
|
|
50
|
-
"client":
|
|
51
|
-
"node":
|
|
52
|
-
"python":
|
|
50
|
+
"client": 22,
|
|
51
|
+
"node": 78,
|
|
52
|
+
"python": 69
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -181,7 +181,7 @@ var MANIFEST = "agents24.yaml";
|
|
|
181
181
|
var SYMBOL = /^\$(workflows|rag|skills|models|stores|tools|toolsets|artifacts|integrations|secrets)\.([a-z0-9]+(?:-[a-z0-9]+)*)$/;
|
|
182
182
|
var UUID = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/i;
|
|
183
183
|
var URL_PATTERN = /\b[A-Za-z][A-Za-z0-9+.-]*:\/\//;
|
|
184
|
-
var LOCAL = /^(workflows|agents|rag|skills|files)\/(?:[a-z0-9][a-z0-9-]*\/)*[a-z0-9][a-z0-9-]*\.(yaml|md)$/;
|
|
184
|
+
var LOCAL = /^(workflows|agents|rag|skills|stores|files)\/(?:[a-z0-9][a-z0-9-]*\/)*[a-z0-9][a-z0-9-]*\.(yaml|md)$/;
|
|
185
185
|
var SECRET_FIELDS = /* @__PURE__ */ new Set(["access_token", "api_key", "authorization", "bearer_token", "client_secret", "credential", "credentials", "fixed_account_connection_id", "oauth_client_id", "oauth_client_secret", "password", "private_key", "refresh_token", "secret_name", "secret_value", "static_bearer_token", "static_headers", "token", "url", "account_id", "organization_id", "project_id", "publication_state", "governance_policy"]);
|
|
186
186
|
function add(rows, severity, code, itemPath, message) {
|
|
187
187
|
rows.push({ severity, code, path: itemPath, message });
|
|
@@ -218,7 +218,7 @@ function schema(name) {
|
|
|
218
218
|
}
|
|
219
219
|
var AjvConstructor = Ajv2020;
|
|
220
220
|
var ajv = new AjvConstructor({ allErrors: true, strict: true, strictRequired: false });
|
|
221
|
-
var validators = Object.fromEntries(["manifest", "workflow", "agent", "rag", "skill"].map((name) => [name, ajv.compile(schema(name))]));
|
|
221
|
+
var validators = Object.fromEntries(["manifest", "workflow", "agent", "rag", "skill", "store"].map((name) => [name, ajv.compile(schema(name))]));
|
|
222
222
|
async function directoryFiles(root) {
|
|
223
223
|
const files = /* @__PURE__ */ new Map();
|
|
224
224
|
let total = 0;
|
|
@@ -284,6 +284,7 @@ function validateFiles(files) {
|
|
|
284
284
|
else if (/^agents\/[a-z0-9][a-z0-9-]*\.md$/.test(filePath)) kind = "agent";
|
|
285
285
|
else if (/^rag\/[a-z0-9][a-z0-9-]*\.yaml$/.test(filePath)) kind = "rag";
|
|
286
286
|
else if (/^skills\/[a-z0-9][a-z0-9-]*\.md$/.test(filePath)) kind = "skill";
|
|
287
|
+
else if (/^stores\/[a-z0-9][a-z0-9-]*\.yaml$/.test(filePath)) kind = "store";
|
|
287
288
|
else if (/^files\/.+\.md$/.test(filePath)) {
|
|
288
289
|
parsed.set(filePath, {});
|
|
289
290
|
continue;
|
|
@@ -292,18 +293,24 @@ function validateFiles(files) {
|
|
|
292
293
|
add(diagnostics, "error", "UNKNOWN_FILE", filePath, "File is not in a canonical package directory");
|
|
293
294
|
continue;
|
|
294
295
|
}
|
|
295
|
-
const value = kind === "workflow" || kind === "rag" ? parseYaml(text, filePath, diagnostics) : frontmatter(text, filePath, diagnostics);
|
|
296
|
+
const value = kind === "workflow" || kind === "rag" || kind === "store" ? parseYaml(text, filePath, diagnostics) : frontmatter(text, filePath, diagnostics);
|
|
296
297
|
validateSchema(kind, value, filePath, diagnostics);
|
|
297
298
|
if ((kind === "agent" || kind === "skill") && (UUID.test(markdownBody(text).trim()) || URL_PATTERN.test(markdownBody(text).trim()))) {
|
|
298
299
|
add(diagnostics, "error", "FORBIDDEN_VALUE", `${filePath}/body`, "Platform UUIDs and URLs are forbidden in source packages");
|
|
299
300
|
}
|
|
300
301
|
parsed.set(filePath, value);
|
|
301
|
-
if (kind !== "agent") resources.push({ path: filePath, kind: kind === "workflow" ? "agent" : kind === "rag" ? "rag_pipeline" : "instruction", name: value.name });
|
|
302
|
+
if (kind !== "agent") resources.push({ path: filePath, kind: kind === "workflow" ? "agent" : kind === "rag" ? "rag_pipeline" : kind === "store" ? "knowledge_store" : "instruction", name: value.name });
|
|
302
303
|
}
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
304
|
+
const declaredRows = Array.isArray(manifest.resources) ? manifest.resources.map(String) : [];
|
|
305
|
+
if (declaredRows.some((item, index) => item !== [...declaredRows].sort()[index])) add(diagnostics, "error", "RESOURCE_ORDER", MANIFEST, "resources must be sorted deterministically");
|
|
306
|
+
const declared = new Set(declaredRows);
|
|
307
|
+
const platformResources = new Set(resources.map((item) => String(item.path)));
|
|
308
|
+
declaredRows.forEach((filePath, index) => {
|
|
309
|
+
if (!platformResources.has(filePath)) add(diagnostics, "error", "RESOURCE_DECLARATION_INVALID", `${MANIFEST}/resources/${index}`, `Declared resource does not exist or is not a platform resource: ${filePath}`);
|
|
310
|
+
});
|
|
311
|
+
for (const filePath of platformResources) if (!declared.has(filePath)) add(diagnostics, "error", "RESOURCE_NOT_DECLARED", filePath, "Platform resource must be listed in agents24.yaml resources");
|
|
305
312
|
const reachable = /* @__PURE__ */ new Set();
|
|
306
|
-
const queue =
|
|
313
|
+
const queue = declaredRows.filter((filePath) => platformResources.has(filePath));
|
|
307
314
|
let referenceCount = 0;
|
|
308
315
|
while (queue.length) {
|
|
309
316
|
const source = queue.shift();
|
|
@@ -328,16 +335,19 @@ function validateFiles(files) {
|
|
|
328
335
|
const declarations = manifest.requires?.[symbol[1]];
|
|
329
336
|
if (!declarations || !(symbol[2] in declarations)) add(diagnostics, "error", "REQUIREMENT_UNDECLARED", source + itemPath, `${item} is not declared`);
|
|
330
337
|
}
|
|
331
|
-
if (!["uses", "skills", "instructions", "file"].includes(String(key))) return;
|
|
332
338
|
const target = resolve(source, item);
|
|
333
|
-
|
|
339
|
+
const platformTarget = Boolean(target && /^(workflows|rag|skills|stores)\//.test(target));
|
|
340
|
+
if (target && (platformTarget || ["uses", "skills", "instructions", "file"].includes(String(key)))) {
|
|
334
341
|
referenceCount += 1;
|
|
335
342
|
if (!parsed.has(target)) add(diagnostics, "error", "LOCAL_REFERENCE_MISSING", source + itemPath, `Missing local reference: ${target}`);
|
|
336
|
-
else
|
|
343
|
+
else {
|
|
344
|
+
if (platformTarget && !declared.has(target)) add(diagnostics, "error", "RESOURCE_NOT_DECLARED", source + itemPath, `Referenced platform resource is not declared: ${target}`);
|
|
345
|
+
queue.push(target);
|
|
346
|
+
}
|
|
337
347
|
}
|
|
338
348
|
});
|
|
339
349
|
}
|
|
340
|
-
for (const filePath of parsed.keys()) if (!reachable.has(filePath)) add(diagnostics, "error", "
|
|
350
|
+
for (const filePath of parsed.keys()) if (/^(agents|files)\//.test(filePath) && !reachable.has(filePath)) add(diagnostics, "error", "ORPHAN_AUXILIARY", filePath, "Auxiliary file is not referenced by a declared resource");
|
|
341
351
|
if (resources.length > 250) add(diagnostics, "error", "RESOURCE_LIMIT", MANIFEST, "Package exceeds 250 resources");
|
|
342
352
|
if (referenceCount > 5e3) add(diagnostics, "error", "REFERENCE_LIMIT", MANIFEST, "Package exceeds 5,000 references");
|
|
343
353
|
diagnostics.sort((left, right) => left.path.localeCompare(right.path) || left.code.localeCompare(right.code) || left.message.localeCompare(right.message));
|
|
@@ -358,8 +368,9 @@ async function initializePackage(directory, packageName) {
|
|
|
358
368
|
await mkdir(path.join(directory, "agents"), { recursive: true });
|
|
359
369
|
await mkdir(path.join(directory, "rag"), { recursive: true });
|
|
360
370
|
await mkdir(path.join(directory, "skills"), { recursive: true });
|
|
371
|
+
await mkdir(path.join(directory, "stores"), { recursive: true });
|
|
361
372
|
await mkdir(path.join(directory, "files"), { recursive: true });
|
|
362
|
-
const manifest = { schema: "agents24.package/v1", name: packageSlug, description: `${packageName} agent package`,
|
|
373
|
+
const manifest = { schema: "agents24.package/v1", name: packageSlug, description: `${packageName} agent package`, resources: ["workflows/main.yaml"], requires: { models: { primary: { required: true, capability: "chat" } } } };
|
|
363
374
|
const workflow = { schema: "agents24.workflow/v1", name: packageName, description: "", inputs: { text: "string" }, outputs: { response: "string" }, entry: "assistant", nodes: { assistant: { uses: "../agents/assistant.md" } }, flow: [{ from: "assistant.output", to: "output.response" }] };
|
|
364
375
|
const agent = `---
|
|
365
376
|
schema: agents24.agent/v1
|
|
@@ -383,22 +394,15 @@ function _yaml(value) {
|
|
|
383
394
|
|
|
384
395
|
// src/remote.ts
|
|
385
396
|
async function createRemoteClient(environment = process.env) {
|
|
386
|
-
const required = [
|
|
387
|
-
"AGENTS24_BASE_URL",
|
|
388
|
-
"AGENTS24_API_KEY",
|
|
389
|
-
"AGENTS24_ORGANIZATION_ID",
|
|
390
|
-
"AGENTS24_PROJECT_ID"
|
|
391
|
-
];
|
|
397
|
+
const required = ["AGENTS24_API_KEY"];
|
|
392
398
|
const missing = required.filter((name) => !String(environment[name] || "").trim());
|
|
393
399
|
if (missing.length) throw new Error(`Missing remote configuration: ${missing.join(", ")}`);
|
|
394
400
|
const canonicalNodePackage = "@agents24/node";
|
|
395
401
|
const module = await import(canonicalNodePackage);
|
|
396
402
|
if (!module.Agents24) throw new Error("@agents24/node does not export Agents24");
|
|
397
403
|
return new module.Agents24({
|
|
398
|
-
baseUrl: environment.AGENTS24_BASE_URL,
|
|
399
|
-
apiKey: environment.AGENTS24_API_KEY
|
|
400
|
-
organizationId: environment.AGENTS24_ORGANIZATION_ID,
|
|
401
|
-
projectId: environment.AGENTS24_PROJECT_ID
|
|
404
|
+
baseUrl: String(environment.AGENTS24_BASE_URL || "https://api.agents24.dev").trim(),
|
|
405
|
+
apiKey: environment.AGENTS24_API_KEY
|
|
402
406
|
});
|
|
403
407
|
}
|
|
404
408
|
|
|
@@ -412,6 +416,15 @@ function parseMappings(items) {
|
|
|
412
416
|
return [item.slice(0, separator), item.slice(separator + 1)];
|
|
413
417
|
}));
|
|
414
418
|
}
|
|
419
|
+
function shouldPromptForDependency(dependency) {
|
|
420
|
+
return dependency.kind !== "model";
|
|
421
|
+
}
|
|
422
|
+
function assertInstallPreviewReady(preview) {
|
|
423
|
+
if (preview.can_import === true) return;
|
|
424
|
+
const blockers = Array.isArray(preview.blockers) ? preview.blockers : [];
|
|
425
|
+
const message = String(blockers[0]?.message || "Package cannot be installed");
|
|
426
|
+
throw new Error(message);
|
|
427
|
+
}
|
|
415
428
|
function assertImportAllowed(preview, options) {
|
|
416
429
|
const resources = Array.isArray(preview.resources) ? preview.resources : [];
|
|
417
430
|
if (resources.some((item) => item.status === "incomplete") && !options.allowIncomplete) {
|
|
@@ -430,6 +443,8 @@ export {
|
|
|
430
443
|
initializePackage,
|
|
431
444
|
createRemoteClient,
|
|
432
445
|
parseMappings,
|
|
446
|
+
shouldPromptForDependency,
|
|
447
|
+
assertInstallPreviewReady,
|
|
433
448
|
assertImportAllowed
|
|
434
449
|
};
|
|
435
|
-
//# sourceMappingURL=chunk-
|
|
450
|
+
//# sourceMappingURL=chunk-MNGBA3HP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/archive.ts","../src/package-source.ts","../src/remote.ts","../src/import-guards.ts"],"sourcesContent":["import { inflateRawSync, deflateRawSync } from \"node:zlib\";\n\nconst MAX_COMPRESSED = 5 * 1024 * 1024;\nconst MAX_UNCOMPRESSED = 10 * 1024 * 1024;\nconst MAX_FILE = 2 * 1024 * 1024;\nconst MAX_FILES = 512;\nconst MAX_DEPTH = 12;\n\nconst CRC_TABLE = Array.from({ length: 256 }, (_, start) => {\n let value = start;\n for (let bit = 0; bit < 8; bit += 1) {\n value = (value & 1) ? 0xedb88320 ^ (value >>> 1) : value >>> 1;\n }\n return value >>> 0;\n});\n\nfunction crc32(value: Uint8Array): number {\n let crc = 0xffffffff;\n for (const byte of value) crc = CRC_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);\n return (crc ^ 0xffffffff) >>> 0;\n}\n\nfunction safePath(raw: string): string {\n if (!raw || raw.startsWith(\"/\") || raw.includes(\"\\\\\")) throw new Error(\"Archive contains an unsafe path\");\n const parts = raw.split(\"/\");\n if (parts.some((part) => !part || part === \".\" || part === \"..\")) throw new Error(\"Archive contains an unsafe path\");\n if (parts.length > MAX_DEPTH) throw new Error(`Archive path exceeds depth ${MAX_DEPTH}: ${raw}`);\n if (/\\.(?:zip|tar|tgz|gz)$/i.test(raw)) throw new Error(`Nested archives are unsupported: ${raw}`);\n if (!/\\.(?:yaml|md)$/.test(raw) || raw.endsWith(\".yml\")) throw new Error(`Unsupported package file: ${raw}`);\n return raw;\n}\n\nfunction writeUInt32(value: number): Buffer {\n const result = Buffer.allocUnsafe(4);\n result.writeUInt32LE(value >>> 0);\n return result;\n}\n\nfunction writeUInt16(value: number): Buffer {\n const result = Buffer.allocUnsafe(2);\n result.writeUInt16LE(value);\n return result;\n}\n\nexport function packFiles(files: Map<string, string>): Uint8Array {\n if (files.size > MAX_FILES) throw new Error(\"Package exceeds the 512-file limit\");\n const localParts: Buffer[] = [];\n const centralParts: Buffer[] = [];\n let offset = 0;\n let total = 0;\n const normalized = new Set<string>();\n\n for (const [rawPath, text] of [...files.entries()].sort(([left], [right]) => left.localeCompare(right))) {\n const path = safePath(rawPath);\n const folded = path.toLocaleLowerCase(\"en-US\");\n if (normalized.has(folded)) throw new Error(`Package contains duplicate path: ${path}`);\n normalized.add(folded);\n const name = Buffer.from(path, \"utf8\");\n const content = Buffer.from(text, \"utf8\");\n if (content.byteLength > MAX_FILE) throw new Error(`Package file exceeds the 2 MiB limit: ${path}`);\n total += content.byteLength;\n if (total > MAX_UNCOMPRESSED) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n const compressed = deflateRawSync(content, { level: 9 });\n const checksum = crc32(content);\n const local = Buffer.concat([\n writeUInt32(0x04034b50),\n writeUInt16(20),\n writeUInt16(0x0800),\n writeUInt16(8),\n writeUInt16(0),\n writeUInt16(0x0021),\n writeUInt32(checksum),\n writeUInt32(compressed.byteLength),\n writeUInt32(content.byteLength),\n writeUInt16(name.byteLength),\n writeUInt16(0),\n name,\n compressed,\n ]);\n localParts.push(local);\n centralParts.push(Buffer.concat([\n writeUInt32(0x02014b50),\n writeUInt16(0x0314),\n writeUInt16(20),\n writeUInt16(0x0800),\n writeUInt16(8),\n writeUInt16(0),\n writeUInt16(0x0021),\n writeUInt32(checksum),\n writeUInt32(compressed.byteLength),\n writeUInt32(content.byteLength),\n writeUInt16(name.byteLength),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt32(0o100644 << 16),\n writeUInt32(offset),\n name,\n ]));\n offset += local.byteLength;\n }\n\n const central = Buffer.concat(centralParts);\n const result = Buffer.concat([\n ...localParts,\n central,\n writeUInt32(0x06054b50),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(files.size),\n writeUInt16(files.size),\n writeUInt32(central.byteLength),\n writeUInt32(offset),\n writeUInt16(0),\n ]);\n if (result.byteLength > MAX_COMPRESSED) throw new Error(\"Package exceeds the 5 MiB compressed limit\");\n return result;\n}\n\nfunction endOfCentralDirectory(data: Buffer): number {\n const minimum = Math.max(0, data.byteLength - 65557);\n for (let index = data.byteLength - 22; index >= minimum; index -= 1) {\n if (data.readUInt32LE(index) === 0x06054b50) return index;\n }\n throw new Error(\"Package must be a valid ZIP archive\");\n}\n\nexport function unpackFiles(value: Uint8Array): Map<string, string> {\n const data = Buffer.from(value);\n if (data.byteLength > MAX_COMPRESSED) throw new Error(\"Package exceeds the 5 MiB compressed limit\");\n const end = endOfCentralDirectory(data);\n const count = data.readUInt16LE(end + 10);\n const centralOffset = data.readUInt32LE(end + 16);\n if (count > MAX_FILES) throw new Error(\"Package exceeds the 512-file limit\");\n const files = new Map<string, string>();\n const normalized = new Set<string>();\n let cursor = centralOffset;\n let total = 0;\n\n for (let index = 0; index < count; index += 1) {\n if (data.readUInt32LE(cursor) !== 0x02014b50) throw new Error(\"Package central directory is invalid\");\n const method = data.readUInt16LE(cursor + 10);\n const expectedCrc = data.readUInt32LE(cursor + 16);\n const compressedSize = data.readUInt32LE(cursor + 20);\n const uncompressedSize = data.readUInt32LE(cursor + 24);\n const nameLength = data.readUInt16LE(cursor + 28);\n const extraLength = data.readUInt16LE(cursor + 30);\n const commentLength = data.readUInt16LE(cursor + 32);\n const externalAttributes = data.readUInt32LE(cursor + 38);\n const localOffset = data.readUInt32LE(cursor + 42);\n const path = safePath(data.subarray(cursor + 46, cursor + 46 + nameLength).toString(\"utf8\"));\n if ((externalAttributes >>> 16 & 0o170000) === 0o120000) throw new Error(`Package symlinks are unsupported: ${path}`);\n const folded = path.toLocaleLowerCase(\"en-US\");\n if (normalized.has(folded)) throw new Error(`Package contains duplicate path: ${path}`);\n normalized.add(folded);\n if (uncompressedSize > MAX_FILE) throw new Error(`Package file exceeds the 2 MiB limit: ${path}`);\n total += uncompressedSize;\n if (total > MAX_UNCOMPRESSED) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n if (data.readUInt32LE(localOffset) !== 0x04034b50) throw new Error(\"Package local header is invalid\");\n const localNameLength = data.readUInt16LE(localOffset + 26);\n const localExtraLength = data.readUInt16LE(localOffset + 28);\n const contentOffset = localOffset + 30 + localNameLength + localExtraLength;\n const compressed = data.subarray(contentOffset, contentOffset + compressedSize);\n let content: Buffer | null = null;\n try {\n content = method === 8\n ? inflateRawSync(compressed, { maxOutputLength: Math.min(MAX_FILE, uncompressedSize) + 1 })\n : method === 0 ? compressed : null;\n } catch {\n throw new Error(`Package file is invalid or exceeds its declared size: ${path}`);\n }\n if (!content || content.byteLength !== uncompressedSize || crc32(content) !== expectedCrc) {\n throw new Error(`Package file is invalid: ${path}`);\n }\n if (content.includes(0)) throw new Error(`Binary package file is unsupported: ${path}`);\n files.set(path, new TextDecoder(\"utf-8\", { fatal: true }).decode(content));\n cursor += 46 + nameLength + extraLength + commentLength;\n }\n if (!files.has(\"agents24.yaml\")) throw new Error(\"Package requires agents24.yaml at the archive root\");\n return files;\n}\n","import { lstat, mkdir, readFile, readdir, stat, writeFile } from \"node:fs/promises\";\nimport { readFileSync as readSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport { parseDocument } from \"yaml\";\n\nimport { packFiles, unpackFiles } from \"./archive.js\";\n\nexport type Diagnostic = { severity: \"error\" | \"warning\"; code: string; path: string; message: string };\nexport type ValidationResult = {\n valid: boolean;\n package: Record<string, unknown>;\n resources: Array<Record<string, unknown>>;\n requirements: string[];\n diagnostics: Diagnostic[];\n files: Map<string, string>;\n};\n\nconst MANIFEST = \"agents24.yaml\";\nconst SYMBOL = /^\\$(workflows|rag|skills|models|stores|tools|toolsets|artifacts|integrations|secrets)\\.([a-z0-9]+(?:-[a-z0-9]+)*)$/;\nconst UUID = /\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/i;\nconst URL_PATTERN = /\\b[A-Za-z][A-Za-z0-9+.-]*:\\/\\//;\nconst LOCAL = /^(workflows|agents|rag|skills|stores|files)\\/(?:[a-z0-9][a-z0-9-]*\\/)*[a-z0-9][a-z0-9-]*\\.(yaml|md)$/;\nconst SECRET_FIELDS = new Set([\"access_token\",\"api_key\",\"authorization\",\"bearer_token\",\"client_secret\",\"credential\",\"credentials\",\"fixed_account_connection_id\",\"oauth_client_id\",\"oauth_client_secret\",\"password\",\"private_key\",\"refresh_token\",\"secret_name\",\"secret_value\",\"static_bearer_token\",\"static_headers\",\"token\",\"url\",\"account_id\",\"organization_id\",\"project_id\",\"publication_state\",\"governance_policy\"]);\n\nfunction add(rows: Diagnostic[], severity: Diagnostic[\"severity\"], code: string, itemPath: string, message: string): void {\n rows.push({ severity, code, path: itemPath, message });\n}\nfunction slug(value: string): string {\n return value.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 64) || \"agent\";\n}\nfunction parseYaml(text: string, itemPath: string, diagnostics: Diagnostic[]): Record<string, unknown> {\n const doc = parseDocument(text, { uniqueKeys: true });\n for (const error of doc.errors) add(diagnostics, \"error\", \"YAML_INVALID\", itemPath, error.message);\n if (doc.errors.length) return {};\n const value = doc.toJS({ maxAliasCount: 0 });\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n add(diagnostics, \"error\", \"YAML_INVALID\", itemPath, \"YAML source must contain a mapping\");\n return {};\n }\n return value as Record<string, unknown>;\n}\nfunction frontmatter(text: string, itemPath: string, diagnostics: Diagnostic[]): Record<string, unknown> {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/.exec(text);\n if (!match) {\n add(diagnostics, \"error\", \"FRONTMATTER_REQUIRED\", itemPath, \"Markdown source requires YAML frontmatter\");\n return {};\n }\n return parseYaml(match[1], itemPath, diagnostics);\n}\nfunction markdownBody(text: string): string {\n const match = /^---\\r?\\n[\\s\\S]*?\\r?\\n---(?:\\r?\\n|$)([\\s\\S]*)$/.exec(text);\n return match?.[1] || \"\";\n}\nfunction schema(name: string): Record<string, unknown> {\n const location = new URL(`../generated/schemas/resource-package/1.0/${name}.schema.json`, import.meta.url);\n return JSON.parse(readSync(fileURLToPath(location), \"utf8\")) as Record<string, unknown>;\n}\nconst AjvConstructor = Ajv2020 as unknown as new (options: Record<string, unknown>) => {\n compile(schema: Record<string, unknown>): ((value: unknown) => boolean) & { errors?: Array<{ instancePath?: string; message?: string }> };\n};\nconst ajv = new AjvConstructor({ allErrors: true, strict: true, strictRequired: false });\nconst validators = Object.fromEntries([\"manifest\",\"workflow\",\"agent\",\"rag\",\"skill\",\"store\"].map((name) => [name, ajv.compile(schema(name))]));\n\nasync function directoryFiles(root: string): Promise<Map<string, string>> {\n const files = new Map<string, string>();\n let total = 0;\n async function visit(directory: string): Promise<void> {\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const absolute = path.join(directory, entry.name);\n const relative = path.relative(root, absolute).split(path.sep).join(\"/\");\n const metadata = await lstat(absolute);\n if (metadata.isSymbolicLink()) throw new Error(`Package symlinks are unsupported: ${relative}`);\n if (metadata.isDirectory()) { await visit(absolute); continue; }\n if (!metadata.isFile()) continue;\n if (relative.split(\"/\").length > 12) throw new Error(`Package path exceeds depth 12: ${relative}`);\n if (!/\\.(?:yaml|md)$/.test(relative) || relative.endsWith(\".yml\")) throw new Error(`Unsupported package file: ${relative}`);\n if (metadata.size > 2 * 1024 * 1024) throw new Error(`Package file exceeds the 2 MiB limit: ${relative}`);\n total += metadata.size;\n if (total > 10 * 1024 * 1024) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n const body = await readFile(absolute);\n if (body.includes(0)) throw new Error(`Binary package file is unsupported: ${relative}`);\n files.set(relative, new TextDecoder(\"utf-8\", { fatal: true }).decode(body));\n if (files.size > 512) throw new Error(\"Package exceeds the 512-file limit\");\n }\n }\n await visit(root);\n return files;\n}\nexport async function loadPackageFiles(input: string): Promise<Map<string, string>> {\n return (await stat(input)).isDirectory() ? directoryFiles(input) : unpackFiles(await readFile(input));\n}\nfunction validateSchema(kind: keyof typeof validators, value: Record<string, unknown>, itemPath: string, diagnostics: Diagnostic[]): void {\n const validate = validators[kind];\n if (validate(value)) return;\n for (const error of validate.errors || []) add(diagnostics, \"error\", \"SCHEMA_INVALID\", itemPath + (error.instancePath || \"\"), error.message || \"Schema validation failed\");\n}\nfunction resolve(source: string, target: string): string | null {\n if (!target || target.startsWith(\"/\") || target.includes(\"\\\\\")) return null;\n const value = path.posix.normalize(path.posix.join(path.posix.dirname(source), target));\n return value === \"..\" || value.startsWith(\"../\") || !LOCAL.test(value) ? null : value;\n}\nfunction walk(value: unknown, visit: (value: unknown, itemPath: string, key?: string) => void, itemPath = \"\", key?: string): void {\n visit(value, itemPath, key);\n if (Array.isArray(value)) value.forEach((item, index) => walk(item, visit, `${itemPath}/${index}`, key));\n else if (value && typeof value === \"object\") for (const [key, item] of Object.entries(value as Record<string, unknown>)) {\n walk(item, visit, `${itemPath}/${key}`, key);\n }\n}\n\nexport function validateFiles(files: Map<string, string>): ValidationResult {\n const diagnostics: Diagnostic[] = [];\n const manifest = parseYaml(files.get(MANIFEST) || \"\", MANIFEST, diagnostics);\n validateSchema(\"manifest\", manifest, MANIFEST, diagnostics);\n walk(manifest, (item, itemPath, key) => {\n if (key && SECRET_FIELDS.has(key.toLowerCase())) add(diagnostics, \"error\", \"FORBIDDEN_FIELD\", MANIFEST + itemPath, \"Secret and platform identity fields are forbidden\");\n if (typeof item === \"string\" && (UUID.test(item) || URL_PATTERN.test(item))) add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", MANIFEST + itemPath, \"Platform UUIDs and URLs are forbidden in source packages\");\n });\n const parsed = new Map<string, Record<string, unknown>>();\n const resources: Array<Record<string, unknown>> = [];\n for (const [filePath, text] of [...files].sort(([left],[right]) => left.localeCompare(right))) {\n if (filePath === MANIFEST) continue;\n let kind: \"workflow\"|\"agent\"|\"rag\"|\"skill\"|\"store\"|null = null;\n if (/^workflows\\/[a-z0-9][a-z0-9-]*\\.yaml$/.test(filePath)) kind = \"workflow\";\n else if (/^agents\\/[a-z0-9][a-z0-9-]*\\.md$/.test(filePath)) kind = \"agent\";\n else if (/^rag\\/[a-z0-9][a-z0-9-]*\\.yaml$/.test(filePath)) kind = \"rag\";\n else if (/^skills\\/[a-z0-9][a-z0-9-]*\\.md$/.test(filePath)) kind = \"skill\";\n else if (/^stores\\/[a-z0-9][a-z0-9-]*\\.yaml$/.test(filePath)) kind = \"store\";\n else if (/^files\\/.+\\.md$/.test(filePath)) { parsed.set(filePath, {}); continue; }\n if (!kind) { add(diagnostics, \"error\", \"UNKNOWN_FILE\", filePath, \"File is not in a canonical package directory\"); continue; }\n const value = kind === \"workflow\" || kind === \"rag\" || kind === \"store\" ? parseYaml(text, filePath, diagnostics) : frontmatter(text, filePath, diagnostics);\n validateSchema(kind, value, filePath, diagnostics);\n if ((kind === \"agent\" || kind === \"skill\") && (UUID.test(markdownBody(text).trim()) || URL_PATTERN.test(markdownBody(text).trim()))) {\n add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", `${filePath}/body`, \"Platform UUIDs and URLs are forbidden in source packages\");\n }\n parsed.set(filePath, value);\n if (kind !== \"agent\") resources.push({ path: filePath, kind: kind === \"workflow\" ? \"agent\" : kind === \"rag\" ? \"rag_pipeline\" : kind === \"store\" ? \"knowledge_store\" : \"instruction\", name: value.name });\n }\n const declaredRows = Array.isArray(manifest.resources) ? manifest.resources.map(String) : [];\n if (declaredRows.some((item, index) => item !== [...declaredRows].sort()[index])) add(diagnostics, \"error\", \"RESOURCE_ORDER\", MANIFEST, \"resources must be sorted deterministically\");\n const declared = new Set(declaredRows);\n const platformResources = new Set(resources.map((item) => String(item.path)));\n declaredRows.forEach((filePath, index) => {\n if (!platformResources.has(filePath)) add(diagnostics, \"error\", \"RESOURCE_DECLARATION_INVALID\", `${MANIFEST}/resources/${index}`, `Declared resource does not exist or is not a platform resource: ${filePath}`);\n });\n for (const filePath of platformResources) if (!declared.has(filePath)) add(diagnostics, \"error\", \"RESOURCE_NOT_DECLARED\", filePath, \"Platform resource must be listed in agents24.yaml resources\");\n const reachable = new Set<string>();\n const queue = declaredRows.filter((filePath) => platformResources.has(filePath));\n let referenceCount = 0;\n while (queue.length) {\n const source = queue.shift() as string;\n if (reachable.has(source)) continue;\n reachable.add(source);\n const value = parsed.get(source) || {};\n if (source.startsWith(\"agents/\")) {\n for (const match of (files.get(source) || \"\").matchAll(/\\[\\[skill:([a-z0-9]+(?:-[a-z0-9]+)*)\\]\\]/g)) {\n referenceCount += 1;\n const target = `skills/${match[1]}.md`;\n if (!parsed.has(target)) add(diagnostics, \"error\", \"LOCAL_REFERENCE_MISSING\", `${source}/body`, `Missing local reference: ${target}`);\n else queue.push(target);\n }\n }\n walk(value, (item, itemPath, key) => {\n if (key && SECRET_FIELDS.has(key.toLowerCase())) add(diagnostics, \"error\", \"FORBIDDEN_FIELD\", source + itemPath, \"Secret and platform identity fields are forbidden\");\n if (typeof item !== \"string\") return;\n if (UUID.test(item) || URL_PATTERN.test(item)) add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", source + itemPath, \"Platform UUIDs and URLs are forbidden in source packages\");\n const symbol = SYMBOL.exec(item);\n if (symbol) {\n referenceCount += 1;\n const declarations = (manifest.requires as Record<string, Record<string, unknown>> | undefined)?.[symbol[1]];\n if (!declarations || !(symbol[2] in declarations)) add(diagnostics, \"error\", \"REQUIREMENT_UNDECLARED\", source + itemPath, `${item} is not declared`);\n }\n const target = resolve(source, item);\n const platformTarget = Boolean(target && /^(workflows|rag|skills|stores)\\//.test(target));\n if (target && (platformTarget || [\"uses\",\"skills\",\"instructions\",\"file\"].includes(String(key)))) {\n referenceCount += 1;\n if (!parsed.has(target)) add(diagnostics, \"error\", \"LOCAL_REFERENCE_MISSING\", source + itemPath, `Missing local reference: ${target}`);\n else {\n if (platformTarget && !declared.has(target)) add(diagnostics, \"error\", \"RESOURCE_NOT_DECLARED\", source + itemPath, `Referenced platform resource is not declared: ${target}`);\n queue.push(target);\n }\n }\n });\n }\n for (const filePath of parsed.keys()) if (/^(agents|files)\\//.test(filePath) && !reachable.has(filePath)) add(diagnostics, \"error\", \"ORPHAN_AUXILIARY\", filePath, \"Auxiliary file is not referenced by a declared resource\");\n if (resources.length > 250) add(diagnostics, \"error\", \"RESOURCE_LIMIT\", MANIFEST, \"Package exceeds 250 resources\");\n if (referenceCount > 5000) add(diagnostics, \"error\", \"REFERENCE_LIMIT\", MANIFEST, \"Package exceeds 5,000 references\");\n diagnostics.sort((left,right) => left.path.localeCompare(right.path) || left.code.localeCompare(right.code) || left.message.localeCompare(right.message));\n const requirements = [...new Set([...files.values()].flatMap((text) => [...text.matchAll(/\\$(?:workflows|rag|skills|models|stores|tools|toolsets|artifacts|integrations|secrets)\\.[a-z0-9-]+/g)].map((match) => match[0])))].sort();\n return { valid: !diagnostics.some((item) => item.severity === \"error\"), package: manifest, resources, requirements, diagnostics, files };\n}\nexport async function validatePackage(input: string): Promise<ValidationResult> {\n return validateFiles(await loadPackageFiles(input));\n}\nexport async function packPackage(input: string): Promise<Uint8Array> {\n const result = await validatePackage(input);\n if (!result.valid) throw Object.assign(new Error(\"Resource package is invalid\"), { diagnostics: result.diagnostics });\n return packFiles(result.files);\n}\nexport async function initializePackage(directory: string, packageName: string): Promise<string> {\n const packageSlug = slug(packageName);\n await mkdir(path.join(directory, \"workflows\"), { recursive: true });\n await mkdir(path.join(directory, \"agents\"), { recursive: true });\n await mkdir(path.join(directory, \"rag\"), { recursive: true });\n await mkdir(path.join(directory, \"skills\"), { recursive: true });\n await mkdir(path.join(directory, \"stores\"), { recursive: true });\n await mkdir(path.join(directory, \"files\"), { recursive: true });\n const manifest = { schema: \"agents24.package/v1\", name: packageSlug, description: `${packageName} agent package`, resources: [\"workflows/main.yaml\"], requires: { models: { primary: { required: true, capability: \"chat\" } } } };\n const workflow = { schema: \"agents24.workflow/v1\", name: packageName, description: \"\", inputs: { text: \"string\" }, outputs: { response: \"string\" }, entry: \"assistant\", nodes: { assistant: { uses: \"../agents/assistant.md\" } }, flow: [{ from: \"assistant.output\", to: \"output.response\" }] };\n const agent = `---\\nschema: agents24.agent/v1\\nname: Assistant\\ndescription: Primary assistant\\nmodel: $models.primary\\n---\\n\\nYou are a helpful assistant.\\n`;\n await writeFile(path.join(directory, MANIFEST), _yaml(manifest), { flag: \"wx\" });\n await writeFile(path.join(directory, \"workflows/main.yaml\"), _yaml(workflow), { flag: \"wx\" });\n await writeFile(path.join(directory, \"agents/assistant.md\"), agent, { flag: \"wx\" });\n return packageSlug;\n}\nfunction _yaml(value: unknown): string {\n const doc = parseDocument(\"{}\");\n doc.contents = doc.createNode(value) as typeof doc.contents;\n return String(doc);\n}\n","type ResourcePackageUpload = { data: Uint8Array; filename?: string };\ntype ResourceBundleRequest = {\n bundle: Record<string, unknown>;\n selected_resource_keys?: string[];\n mappings?: Record<string, string>;\n};\n\nexport type RemoteClient = {\n resourcePackages: {\n exportPackage(request: Record<string, unknown>): Promise<{ data: Uint8Array; filename: string }>;\n validatePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;\n compilePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;\n };\n resourceBundles: {\n importPreview(request: ResourceBundleRequest): Promise<Record<string, unknown>>;\n importBundle(request: ResourceBundleRequest, options?: { idempotencyKey?: string }): Promise<Record<string, unknown>>;\n candidates(options: { kind: string; query?: string; requiredCapability?: \"chat\" | \"embedding\" }): Promise<Record<string, unknown>>;\n };\n agents: { publish(id: string, options?: { idempotencyKey?: string }): Promise<Record<string, unknown>> };\n resourcePolicies: { list(): Promise<Array<Record<string, unknown>>> };\n clientDeployments: { create(request: Record<string, unknown>, options?: { idempotencyKey?: string }): Promise<Record<string, unknown>> };\n};\n\nexport async function createRemoteClient(environment: NodeJS.ProcessEnv = process.env): Promise<RemoteClient> {\n const required = [\"AGENTS24_API_KEY\"] as const;\n const missing = required.filter((name) => !String(environment[name] || \"\").trim());\n if (missing.length) throw new Error(`Missing remote configuration: ${missing.join(\", \")}`);\n\n const canonicalNodePackage = \"@agents24/node\";\n const module = await import(canonicalNodePackage) as { Agents24?: new (options: Record<string, unknown>) => unknown };\n if (!module.Agents24) throw new Error(\"@agents24/node does not export Agents24\");\n return new module.Agents24({\n baseUrl: String(environment.AGENTS24_BASE_URL || \"https://api.agents24.dev\").trim(),\n apiKey: environment.AGENTS24_API_KEY,\n }) as unknown as RemoteClient;\n}\n","export function parseMappings(items: string[]): Record<string, string> {\n return Object.fromEntries(items.map((item) => {\n const separator = item.indexOf(\"=\");\n if (separator <= 0 || separator === item.length - 1) {\n throw new Error(\"--map must use requirement-key=target-id\");\n }\n return [item.slice(0, separator), item.slice(separator + 1)];\n }));\n}\n\nexport function shouldPromptForDependency(dependency: Record<string, unknown>): boolean {\n return dependency.kind !== \"model\";\n}\n\nexport function assertInstallPreviewReady(preview: Record<string, unknown>): void {\n if (preview.can_import === true) return;\n const blockers = Array.isArray(preview.blockers) ? preview.blockers as Array<Record<string, unknown>> : [];\n const message = String(blockers[0]?.message || \"Package cannot be installed\");\n throw new Error(message);\n}\n\nexport function assertImportAllowed(\n preview: Record<string, unknown>,\n options: { allowIncomplete: boolean; yes: boolean; interactive: boolean },\n): void {\n const resources = Array.isArray(preview.resources) ? preview.resources as Array<Record<string, unknown>> : [];\n if (resources.some((item) => item.status === \"incomplete\") && !options.allowIncomplete) {\n throw new Error(\"Import would create incomplete drafts; pass --allow-incomplete to continue\");\n }\n if (!options.yes && !options.interactive) throw new Error(\"Non-interactive import requires --yes\");\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB,sBAAsB;AAE/C,IAAM,iBAAiB,IAAI,OAAO;AAClC,IAAM,mBAAmB,KAAK,OAAO;AACrC,IAAM,WAAW,IAAI,OAAO;AAC5B,IAAM,YAAY;AAClB,IAAM,YAAY;AAElB,IAAM,YAAY,MAAM,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC,GAAG,UAAU;AAC1D,MAAI,QAAQ;AACZ,WAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;AACnC,YA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CAAC,GAAG,WAAW,6BAA6B;AAC5E,QAAM,IAAI,MAAM,OAAO;AACzB;AAEO,SAAS,oBACd,SACA,SACM;AACN,QAAM,YAAY,MAAM,QAAQ,QAAQ,SAAS,IAAI,QAAQ,YAA8C,CAAC;AAC5G,MAAI,UAAU,KAAK,CAAC,SAAS,KAAK,WAAW,YAAY,KAAK,CAAC,QAAQ,iBAAiB;AACtF,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AACA,MAAI,CAAC,QAAQ,OAAO,CAAC,QAAQ,YAAa,OAAM,IAAI,MAAM,uCAAuC;AACnG;","names":["path","key"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
assertImportAllowed,
|
|
4
|
+
assertInstallPreviewReady,
|
|
4
5
|
createRemoteClient,
|
|
5
6
|
initializePackage,
|
|
6
7
|
packPackage,
|
|
7
8
|
parseMappings,
|
|
9
|
+
shouldPromptForDependency,
|
|
8
10
|
validatePackage
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MNGBA3HP.js";
|
|
10
12
|
|
|
11
13
|
// src/cli.ts
|
|
12
|
-
import { basename, resolve } from "path";
|
|
13
|
-
import { writeFile } from "fs/promises";
|
|
14
|
+
import { basename, join, resolve } from "path";
|
|
15
|
+
import { chmod, readFile, writeFile } from "fs/promises";
|
|
14
16
|
import { createInterface } from "readline/promises";
|
|
15
|
-
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
|
+
import { isCancel, password, select, text } from "@clack/prompts";
|
|
19
|
+
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["json", "remote", "yes", "allow-incomplete", "no-write-env"]);
|
|
20
|
+
var DEFAULT_API_BASE_URL = "https://api.agents24.dev";
|
|
21
|
+
var DEFAULT_LOCAL_CLIENT_ORIGINS = ["http://localhost:5173", "http://127.0.0.1:5173"];
|
|
16
22
|
function parse(argv) {
|
|
17
|
-
|
|
23
|
+
const standaloneInstall = argv[0] === "install";
|
|
24
|
+
if (!standaloneInstall && (argv[0] !== "package" || !argv[1])) throw new Error("Usage: agents24 install <directory-or-zip> | agents24 package <init|validate|pack|export|compile|preview|import>");
|
|
18
25
|
const flags = /* @__PURE__ */ new Map();
|
|
19
26
|
const positionals = [];
|
|
20
|
-
for (let index = 2; index < argv.length; index += 1) {
|
|
27
|
+
for (let index = standaloneInstall ? 1 : 2; index < argv.length; index += 1) {
|
|
21
28
|
const current = argv[index];
|
|
22
29
|
if (!current.startsWith("--")) {
|
|
23
30
|
positionals.push(current);
|
|
@@ -25,11 +32,14 @@ function parse(argv) {
|
|
|
25
32
|
}
|
|
26
33
|
const [rawName, inline] = current.slice(2).split("=", 2);
|
|
27
34
|
if (!rawName) throw new Error("Invalid option");
|
|
35
|
+
if (rawName === "api-key") {
|
|
36
|
+
throw new Error("--api-key is not supported; use AGENTS24_API_KEY or the masked prompt");
|
|
37
|
+
}
|
|
28
38
|
const value = inline ?? (BOOLEAN_FLAGS.has(rawName) ? "true" : argv[++index]);
|
|
29
39
|
if (value === void 0 || value.startsWith("--")) throw new Error(`--${rawName} requires a value`);
|
|
30
40
|
flags.set(rawName, [...flags.get(rawName) || [], value]);
|
|
31
41
|
}
|
|
32
|
-
return { command: argv[1], positionals, flags };
|
|
42
|
+
return { command: standaloneInstall ? "install" : argv[1], positionals, flags };
|
|
33
43
|
}
|
|
34
44
|
function flag(parsed, name) {
|
|
35
45
|
return parsed.flags.get(name)?.at(-1);
|
|
@@ -60,16 +70,194 @@ async function confirmation(parsed, preview) {
|
|
|
60
70
|
prompt.close();
|
|
61
71
|
if (!/^y(?:es)?$/i.test(answer.trim())) throw new Error("Import cancelled");
|
|
62
72
|
}
|
|
63
|
-
async function
|
|
73
|
+
async function promptMappings(parsed, client, preview, current) {
|
|
74
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY || flag(parsed, "yes") === "true") return current;
|
|
75
|
+
const dependencies = Array.isArray(preview.dependencies) ? preview.dependencies.filter((item) => Boolean(item && typeof item === "object" && item.status === "unresolved")) : [];
|
|
76
|
+
const unique = new Map(dependencies.map((item) => [String(item.requirement_key || item.id), item]));
|
|
77
|
+
if (!unique.size) return current;
|
|
78
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
79
|
+
try {
|
|
80
|
+
const next = { ...current };
|
|
81
|
+
for (const [key, dependency] of unique) {
|
|
82
|
+
if (!shouldPromptForDependency(dependency)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (dependency.kind === "secret") {
|
|
86
|
+
const answer2 = await prompt.question(`${dependency.source_name || key} secret ($secret:name, blank to omit): `);
|
|
87
|
+
if (answer2.trim()) next[key] = answer2.trim();
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const response = await client.resourceBundles.candidates({
|
|
91
|
+
kind: String(dependency.kind),
|
|
92
|
+
query: String(dependency.source_name || ""),
|
|
93
|
+
requiredCapability: dependency.required_capability === "embedding" ? "embedding" : dependency.required_capability === "chat" ? "chat" : void 0
|
|
94
|
+
});
|
|
95
|
+
const candidates = Array.isArray(response.items) ? response.items : [];
|
|
96
|
+
process.stdout.write(`${dependency.source_name || key}: ${candidates.map((item, index) => `${index + 1}) ${item.name}`).join(" ")}
|
|
97
|
+
`);
|
|
98
|
+
const answer = await prompt.question("Choose a candidate number (blank to omit): ");
|
|
99
|
+
const selected = candidates[Number(answer) - 1];
|
|
100
|
+
if (selected?.id) next[key] = String(selected.id);
|
|
101
|
+
}
|
|
102
|
+
return next;
|
|
103
|
+
} finally {
|
|
104
|
+
prompt.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function compiledPackage(parsed, client) {
|
|
64
108
|
const input = parsed.positionals[0];
|
|
65
109
|
if (!input) throw new Error(`${parsed.command} requires a package directory or ZIP`);
|
|
66
110
|
const local = await validatePackage(input);
|
|
67
111
|
if (!local.valid) throw Object.assign(new Error("Resource package is invalid"), { diagnostics: local.diagnostics });
|
|
68
112
|
const data = await packPackage(input);
|
|
69
|
-
const
|
|
70
|
-
const result = await
|
|
113
|
+
const remoteClient = client || await createRemoteClient();
|
|
114
|
+
const result = await remoteClient.resourcePackages.compilePackage(upload(data, input));
|
|
71
115
|
return { data, result };
|
|
72
116
|
}
|
|
117
|
+
function canonical(value) {
|
|
118
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
119
|
+
if (value && typeof value === "object") return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
|
|
120
|
+
return JSON.stringify(value);
|
|
121
|
+
}
|
|
122
|
+
function installKey(bundle, map) {
|
|
123
|
+
return `install-${createHash("sha256").update(canonical({ bundle, mappings: map })).digest("hex").slice(0, 40)}`;
|
|
124
|
+
}
|
|
125
|
+
function importedRows(imported) {
|
|
126
|
+
return Array.isArray(imported.resources) ? imported.resources.filter((item) => Boolean(item && typeof item === "object")) : [];
|
|
127
|
+
}
|
|
128
|
+
function interactive(parsed) {
|
|
129
|
+
return flag(parsed, "yes") !== "true" && Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
130
|
+
}
|
|
131
|
+
function cancelled(value) {
|
|
132
|
+
if (isCancel(value)) throw new Error("Installation cancelled");
|
|
133
|
+
}
|
|
134
|
+
async function apiKeyForInstall(parsed) {
|
|
135
|
+
let apiKey = String(process.env.AGENTS24_API_KEY || "").trim();
|
|
136
|
+
if (!apiKey && interactive(parsed)) {
|
|
137
|
+
const answer = await password({ message: "Agents24 API key", validate: (value) => String(value || "").trim() ? void 0 : "The API key is required." });
|
|
138
|
+
cancelled(answer);
|
|
139
|
+
apiKey = String(answer).trim();
|
|
140
|
+
}
|
|
141
|
+
if (!apiKey) throw new Error("AGENTS24_API_KEY is required for noninteractive installation");
|
|
142
|
+
if (/[\r\n\0]/.test(apiKey)) throw new Error("AGENTS24_API_KEY contains invalid control characters");
|
|
143
|
+
return apiKey;
|
|
144
|
+
}
|
|
145
|
+
function clientAppBaseUrl(environment = process.env) {
|
|
146
|
+
const baseUrl = String(environment.AGENTS24_BASE_URL || "").trim().replace(/\/+$/, "");
|
|
147
|
+
if (!baseUrl || baseUrl === DEFAULT_API_BASE_URL) return void 0;
|
|
148
|
+
let parsed;
|
|
149
|
+
try {
|
|
150
|
+
parsed = new URL(baseUrl);
|
|
151
|
+
} catch {
|
|
152
|
+
throw new Error("AGENTS24_BASE_URL must be a valid absolute HTTP(S) URL.");
|
|
153
|
+
}
|
|
154
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
155
|
+
throw new Error("AGENTS24_BASE_URL must be a valid absolute HTTP(S) URL.");
|
|
156
|
+
}
|
|
157
|
+
return baseUrl;
|
|
158
|
+
}
|
|
159
|
+
async function appInfoAt(directory, explicit) {
|
|
160
|
+
const target = resolve(directory);
|
|
161
|
+
try {
|
|
162
|
+
const manifest = JSON.parse(await readFile(join(target, "package.json"), "utf8"));
|
|
163
|
+
const metadata = manifest.agents24 && typeof manifest.agents24 === "object" ? manifest.agents24 : {};
|
|
164
|
+
const integration = String(metadata.integration || "");
|
|
165
|
+
if (integration !== "client-deployment" && integration !== "bff") {
|
|
166
|
+
if (explicit) throw new Error("--app must reference a generated Agents24 application");
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
return { directory: target, integration, packageManager: String(metadata.package_manager || "pnpm") };
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (explicit || error.code !== "ENOENT") throw error;
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function resolveApp(parsed) {
|
|
176
|
+
const requested = flag(parsed, "app");
|
|
177
|
+
return appInfoAt(requested || process.cwd(), Boolean(requested));
|
|
178
|
+
}
|
|
179
|
+
async function resolveInstallMode(parsed, app) {
|
|
180
|
+
const requested = flag(parsed, "integration");
|
|
181
|
+
if (requested && !["client-deployment", "bff", "publish-only"].includes(requested)) throw new Error("--integration must be client-deployment, bff, or publish-only");
|
|
182
|
+
if (requested && app && requested !== "publish-only" && requested !== app.integration) throw new Error("--integration does not match the generated application");
|
|
183
|
+
if (requested) return requested;
|
|
184
|
+
if (app) return app.integration;
|
|
185
|
+
if (!interactive(parsed)) throw new Error("--integration is required when no generated application is detected");
|
|
186
|
+
const answer = await select({ message: "How will this Agent be integrated?", options: [
|
|
187
|
+
{ value: "client-deployment", label: "Client deployment", hint: "Create a public deployment ID" },
|
|
188
|
+
{ value: "bff", label: "Server BFF", hint: "Use the API key only on the server" },
|
|
189
|
+
{ value: "publish-only", label: "Publish only", hint: "Configure an integration later" }
|
|
190
|
+
] });
|
|
191
|
+
cancelled(answer);
|
|
192
|
+
return answer;
|
|
193
|
+
}
|
|
194
|
+
async function selectInstalledAgent(parsed, imported) {
|
|
195
|
+
const agents = importedRows(imported).filter((row) => row.kind === "agent");
|
|
196
|
+
if (!agents.length) throw new Error("The installed package does not contain an Agent");
|
|
197
|
+
const requested = flag(parsed, "agent");
|
|
198
|
+
if (requested) {
|
|
199
|
+
const match = agents.find((row) => [row.id, row.resource_key, row.name].map(String).includes(requested));
|
|
200
|
+
if (!match) throw new Error(`--agent did not match an imported Agent: ${requested}`);
|
|
201
|
+
return match;
|
|
202
|
+
}
|
|
203
|
+
if (agents.length === 1) return agents[0];
|
|
204
|
+
if (!interactive(parsed)) throw new Error("--agent is required when the package contains multiple Agents");
|
|
205
|
+
const answer = await select({ message: "Which Agent should be published?", options: agents.map((row) => ({ value: String(row.id), label: String(row.name) })) });
|
|
206
|
+
cancelled(answer);
|
|
207
|
+
return agents.find((row) => String(row.id) === answer);
|
|
208
|
+
}
|
|
209
|
+
async function clientDeployment(parsed, client, agent, app) {
|
|
210
|
+
const policies = (await client.resourcePolicies.list()).filter((row) => row.is_active === true);
|
|
211
|
+
let policyId = flag(parsed, "policy-set");
|
|
212
|
+
if (policyId && !policies.some((row) => String(row.id) === policyId)) throw new Error("--policy-set must identify an active Resource Policy");
|
|
213
|
+
if (!policyId && policies.length === 1) policyId = String(policies[0].id);
|
|
214
|
+
if (!policyId && interactive(parsed) && policies.length > 1) {
|
|
215
|
+
const answer = await select({ message: "Resource Policy", options: policies.map((row) => ({ value: String(row.id), label: String(row.name) })) });
|
|
216
|
+
cancelled(answer);
|
|
217
|
+
policyId = answer;
|
|
218
|
+
}
|
|
219
|
+
if (!policyId) throw new Error("An active Resource Policy is required; pass --policy-set when more than one is active");
|
|
220
|
+
let origins = values(parsed, "origin");
|
|
221
|
+
if (!origins.length && app) origins = [...DEFAULT_LOCAL_CLIENT_ORIGINS];
|
|
222
|
+
if (!origins.length && interactive(parsed)) {
|
|
223
|
+
const answer = await text({ message: "Allowed browser origins", placeholder: "http://localhost:5173", validate: (value) => String(value || "").trim() ? void 0 : "At least one origin is required." });
|
|
224
|
+
cancelled(answer);
|
|
225
|
+
origins = String(answer).split(",").map((item) => item.trim()).filter(Boolean);
|
|
226
|
+
}
|
|
227
|
+
if (!origins.length) throw new Error("At least one --origin is required when no generated app is detected");
|
|
228
|
+
const authModes = values(parsed, "auth-mode").length ? values(parsed, "auth-mode") : ["anonymous"];
|
|
229
|
+
const oidcRaw = flag(parsed, "oidc-config");
|
|
230
|
+
if (authModes.includes("external_oidc") && !oidcRaw) throw new Error("--oidc-config is required for external_oidc");
|
|
231
|
+
const request = {
|
|
232
|
+
agent_id: String(agent.id),
|
|
233
|
+
resource_policy_set_id: policyId,
|
|
234
|
+
version_policy: { mode: "latest_published" },
|
|
235
|
+
name: `${String(agent.name)} client deployment`,
|
|
236
|
+
auth_modes: authModes,
|
|
237
|
+
allowed_origins: origins,
|
|
238
|
+
...oidcRaw ? { oidc: JSON.parse(oidcRaw) } : {}
|
|
239
|
+
};
|
|
240
|
+
return client.clientDeployments.create(request, { idempotencyKey: `deploy-${createHash("sha256").update(canonical(request)).digest("hex").slice(0, 40)}` });
|
|
241
|
+
}
|
|
242
|
+
async function updateEnvFile(app, values2) {
|
|
243
|
+
const target = join(app.directory, ".env.local");
|
|
244
|
+
let content = "";
|
|
245
|
+
try {
|
|
246
|
+
content = await readFile(target, "utf8");
|
|
247
|
+
} catch (error) {
|
|
248
|
+
if (error.code !== "ENOENT") throw error;
|
|
249
|
+
}
|
|
250
|
+
let next = content;
|
|
251
|
+
for (const [name, value] of Object.entries(values2)) {
|
|
252
|
+
const line = `${name}=${JSON.stringify(value)}`;
|
|
253
|
+
const pattern = new RegExp(`^${name}=.*$`, "m");
|
|
254
|
+
next = pattern.test(next) ? next.replace(pattern, line) : `${next}${next && !next.endsWith("\n") ? "\n" : ""}${line}
|
|
255
|
+
`;
|
|
256
|
+
}
|
|
257
|
+
await writeFile(target, next, { mode: 384 });
|
|
258
|
+
await chmod(target, 384);
|
|
259
|
+
return target;
|
|
260
|
+
}
|
|
73
261
|
async function execute(parsed) {
|
|
74
262
|
if (parsed.command === "init") {
|
|
75
263
|
const directory = resolve(parsed.positionals[0] || ".");
|
|
@@ -101,9 +289,13 @@ async function execute(parsed) {
|
|
|
101
289
|
const id = flag(parsed, "id");
|
|
102
290
|
if (!kind || !id) throw new Error("export requires --kind and --id");
|
|
103
291
|
const target = flag(parsed, "target") || "draft";
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
292
|
+
const selectors = [{ kind, id, target, ...flag(parsed, "version-id") ? { version_id: flag(parsed, "version-id") } : {} }];
|
|
293
|
+
for (const value of values(parsed, "selector")) {
|
|
294
|
+
const [itemKind, itemId, itemTarget = "draft", versionId] = value.split(":");
|
|
295
|
+
if (!itemKind || !itemId) throw new Error("--selector must be kind:id[:draft|version[:version-id]]");
|
|
296
|
+
selectors.push({ kind: itemKind, id: itemId, target: itemTarget, ...versionId ? { version_id: versionId } : {} });
|
|
297
|
+
}
|
|
298
|
+
const request = { selectors };
|
|
107
299
|
const archive = await (await createRemoteClient()).resourcePackages.exportPackage(request);
|
|
108
300
|
const output = resolve(flag(parsed, "output") || archive.filename);
|
|
109
301
|
await writeFile(output, archive.data);
|
|
@@ -116,19 +308,79 @@ async function execute(parsed) {
|
|
|
116
308
|
`);
|
|
117
309
|
return { ok: result.valid === true, ...output ? { output: resolve(output) } : {}, result: safeResult(result) };
|
|
118
310
|
}
|
|
119
|
-
if (parsed.command === "preview" || parsed.command === "import") {
|
|
120
|
-
const
|
|
311
|
+
if (parsed.command === "preview" || parsed.command === "import" || parsed.command === "install") {
|
|
312
|
+
const app = parsed.command === "install" ? await resolveApp(parsed) : void 0;
|
|
313
|
+
const integration = parsed.command === "install" ? await resolveInstallMode(parsed, app) : void 0;
|
|
314
|
+
const apiKey = parsed.command === "install" ? await apiKeyForInstall(parsed) : void 0;
|
|
315
|
+
const client = apiKey ? await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey }) : await createRemoteClient();
|
|
316
|
+
const { result } = await compiledPackage(parsed, client);
|
|
121
317
|
if (result.valid !== true || !result.bundle || typeof result.bundle !== "object") throw new Error("Remote compilation did not produce a bundle");
|
|
122
318
|
const request = {
|
|
123
319
|
bundle: result.bundle,
|
|
124
320
|
mappings: mappings(parsed)
|
|
125
321
|
};
|
|
126
|
-
|
|
127
|
-
|
|
322
|
+
let preview = await client.resourceBundles.importPreview(request);
|
|
323
|
+
request.mappings = await promptMappings(parsed, client, preview, request.mappings);
|
|
324
|
+
if (Object.keys(request.mappings).length) preview = await client.resourceBundles.importPreview(request);
|
|
128
325
|
if (parsed.command === "preview") return { ok: preview.can_import === true, preview };
|
|
326
|
+
if (parsed.command === "install") assertInstallPreviewReady(preview);
|
|
129
327
|
if (preview.can_import !== true) return { ok: false, preview };
|
|
130
328
|
await confirmation(parsed, preview);
|
|
131
|
-
|
|
329
|
+
const imported = await client.resourceBundles.importBundle(request, { idempotencyKey: installKey(request.bundle, request.mappings) });
|
|
330
|
+
if (parsed.command === "import") return { ok: true, phase: "imported", preview, result: imported };
|
|
331
|
+
const agent = await selectInstalledAgent(parsed, imported);
|
|
332
|
+
if (importedRows(imported).some((row) => row.status === "incomplete") && flag(parsed, "allow-incomplete") !== "true") {
|
|
333
|
+
throw Object.assign(new Error("Publication is blocked by incomplete imported dependencies"), { phase: "post_import", imported });
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
await client.agents.publish(String(agent.id), {
|
|
337
|
+
idempotencyKey: `publish-${createHash("sha256").update(`agent:${String(agent.id)}`).digest("hex").slice(0, 40)}`
|
|
338
|
+
});
|
|
339
|
+
} catch (error) {
|
|
340
|
+
throw Object.assign(error instanceof Error ? error : new Error("Agent publication failed"), {
|
|
341
|
+
phase: "publish",
|
|
342
|
+
imported
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
let deployment;
|
|
346
|
+
try {
|
|
347
|
+
if (integration === "client-deployment") deployment = await clientDeployment(parsed, client, agent, app);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
throw Object.assign(error instanceof Error ? error : new Error("Client deployment setup failed"), {
|
|
350
|
+
phase: "deployment",
|
|
351
|
+
imported
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
const deploymentId = deployment && typeof deployment.client_id === "string" ? deployment.client_id : void 0;
|
|
355
|
+
let envFile;
|
|
356
|
+
if (app && flag(parsed, "no-write-env") !== "true" && integration !== "publish-only") {
|
|
357
|
+
try {
|
|
358
|
+
const localClientBaseUrl = integration === "client-deployment" ? clientAppBaseUrl() : void 0;
|
|
359
|
+
envFile = await updateEnvFile(app, integration === "client-deployment" ? {
|
|
360
|
+
VITE_AGENTS24_DEPLOYMENT_ID: String(deploymentId),
|
|
361
|
+
...localClientBaseUrl ? { VITE_AGENTS24_BASE_URL: localClientBaseUrl } : {}
|
|
362
|
+
} : { AGENTS24_API_KEY: apiKey, AGENTS24_AGENT_ID: String(agent.id) });
|
|
363
|
+
} catch (error) {
|
|
364
|
+
throw Object.assign(error instanceof Error ? error : new Error("Could not configure the generated app"), {
|
|
365
|
+
phase: "env_write",
|
|
366
|
+
imported
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const packageManager = app?.packageManager || "pnpm";
|
|
371
|
+
const nextCommand = app && integration !== "publish-only" ? packageManager === "npm" ? "npm run dev" : packageManager === "bun" ? "bun run dev" : `${packageManager} dev` : void 0;
|
|
372
|
+
return {
|
|
373
|
+
ok: true,
|
|
374
|
+
phase: deployment ? "deployed" : "published",
|
|
375
|
+
integration,
|
|
376
|
+
agent_id: String(agent.id),
|
|
377
|
+
...deployment ? { deployment, deployment_id: deploymentId } : {},
|
|
378
|
+
env_written: Boolean(envFile),
|
|
379
|
+
...envFile ? { env_file: envFile } : {},
|
|
380
|
+
...nextCommand ? { next_command: nextCommand } : {},
|
|
381
|
+
preview,
|
|
382
|
+
result: imported
|
|
383
|
+
};
|
|
132
384
|
}
|
|
133
385
|
throw new Error(`Unknown package command: ${parsed.command}`);
|
|
134
386
|
}
|
|
@@ -142,6 +394,21 @@ function diagnostics(error) {
|
|
|
142
394
|
const value = detail.diagnostics;
|
|
143
395
|
return Array.isArray(value) ? value : void 0;
|
|
144
396
|
}
|
|
397
|
+
function errorMessage(error, parsed) {
|
|
398
|
+
if (parsed?.command === "install" && error && typeof error === "object" && "status" in error && error.status === 403) {
|
|
399
|
+
return "This API key cannot install Agents. Create a new Agent integration API key in Settings; existing keys cannot gain additional scopes.";
|
|
400
|
+
}
|
|
401
|
+
return error instanceof Error ? error.message : "Unexpected CLI failure";
|
|
402
|
+
}
|
|
403
|
+
function installSummary(result) {
|
|
404
|
+
const lines = ["Agent installed and published.", `Agent ID: ${String(result.agent_id)}`];
|
|
405
|
+
if (result.deployment_id) lines.push(`Deployment ID: ${String(result.deployment_id)}`);
|
|
406
|
+
if (result.env_written) lines.push(`Configured: ${String(result.env_file)}`);
|
|
407
|
+
else if (result.integration !== "publish-only") lines.push("Environment configuration was not written.");
|
|
408
|
+
if (result.next_command) lines.push(`Next: ${String(result.next_command)}`);
|
|
409
|
+
return `${lines.join("\n")}
|
|
410
|
+
`;
|
|
411
|
+
}
|
|
145
412
|
async function run(argv = process.argv.slice(2)) {
|
|
146
413
|
let parsed;
|
|
147
414
|
try {
|
|
@@ -151,13 +418,16 @@ async function run(argv = process.argv.slice(2)) {
|
|
|
151
418
|
`);
|
|
152
419
|
else if (result.ok === false) process.stderr.write(`${JSON.stringify(result, null, 2)}
|
|
153
420
|
`);
|
|
421
|
+
else if (parsed.command === "install") process.stdout.write(installSummary(result));
|
|
154
422
|
else process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
155
423
|
`);
|
|
156
424
|
return result.ok === false ? 1 : 0;
|
|
157
425
|
} catch (error) {
|
|
158
426
|
const payload = {
|
|
159
427
|
ok: false,
|
|
160
|
-
error: error
|
|
428
|
+
error: errorMessage(error, parsed),
|
|
429
|
+
...error && typeof error === "object" && "phase" in error ? { phase: error.phase } : {},
|
|
430
|
+
...error && typeof error === "object" && "imported" in error ? { import_result: error.imported } : {},
|
|
161
431
|
...diagnostics(error) ? { diagnostics: diagnostics(error) } : {}
|
|
162
432
|
};
|
|
163
433
|
const body = parsed && flag(parsed, "json") === "true" ? JSON.stringify(payload) : JSON.stringify(payload, null, 2);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +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,eAA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,MACJ,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MAChD,GAAI,YAAY,KAAK,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":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { basename, join, resolve } from \"node:path\";\nimport { chmod, readFile, writeFile } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline/promises\";\nimport { createHash } from \"node:crypto\";\nimport { isCancel, password, select, text } from \"@clack/prompts\";\n\nimport { initializePackage, packPackage, validatePackage, type Diagnostic } from \"./package-source.js\";\nimport { createRemoteClient } from \"./remote.js\";\nimport { assertImportAllowed, assertInstallPreviewReady, parseMappings, shouldPromptForDependency } 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\", \"no-write-env\"]);\nconst DEFAULT_API_BASE_URL = \"https://api.agents24.dev\";\nconst DEFAULT_LOCAL_CLIENT_ORIGINS = [\"http://localhost:5173\", \"http://127.0.0.1:5173\"];\n\nfunction parse(argv: string[]): Parsed {\n const standaloneInstall = argv[0] === \"install\";\n if (!standaloneInstall && (argv[0] !== \"package\" || !argv[1])) throw new Error(\"Usage: agents24 install <directory-or-zip> | agents24 package <init|validate|pack|export|compile|preview|import>\");\n const flags = new Map<string, string[]>();\n const positionals: string[] = [];\n for (let index = standaloneInstall ? 1 : 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 if (rawName === \"api-key\") {\n throw new Error(\"--api-key is not supported; use AGENTS24_API_KEY or the masked prompt\");\n }\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: standaloneInstall ? \"install\" : 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 promptMappings(parsed: Parsed, client: Awaited<ReturnType<typeof createRemoteClient>>, preview: Record<string, unknown>, current: Record<string, string>): Promise<Record<string, string>> {\n if (!process.stdin.isTTY || !process.stdout.isTTY || flag(parsed, \"yes\") === \"true\") return current;\n const dependencies = Array.isArray(preview.dependencies) ? preview.dependencies.filter((item): item is Record<string, unknown> => Boolean(item && typeof item === \"object\" && item.status === \"unresolved\")) : [];\n const unique = new Map(dependencies.map((item) => [String(item.requirement_key || item.id), item]));\n if (!unique.size) return current;\n const prompt = createInterface({ input: process.stdin, output: process.stdout });\n try {\n const next = { ...current };\n for (const [key, dependency] of unique) {\n if (!shouldPromptForDependency(dependency)) {\n continue;\n }\n if (dependency.kind === \"secret\") {\n const answer = await prompt.question(`${dependency.source_name || key} secret ($secret:name, blank to omit): `);\n if (answer.trim()) next[key] = answer.trim();\n continue;\n }\n const response = await client.resourceBundles.candidates({\n kind: String(dependency.kind), query: String(dependency.source_name || \"\"),\n requiredCapability: dependency.required_capability === \"embedding\" ? \"embedding\" : dependency.required_capability === \"chat\" ? \"chat\" : undefined,\n });\n const candidates = Array.isArray(response.items) ? response.items as Array<Record<string, unknown>> : [];\n process.stdout.write(`${dependency.source_name || key}: ${candidates.map((item, index) => `${index + 1}) ${item.name}`).join(\" \")}\\n`);\n const answer = await prompt.question(\"Choose a candidate number (blank to omit): \");\n const selected = candidates[Number(answer) - 1];\n if (selected?.id) next[key] = String(selected.id);\n }\n return next;\n } finally {\n prompt.close();\n }\n}\n\nasync function compiledPackage(parsed: Parsed, client?: Awaited<ReturnType<typeof createRemoteClient>>): 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 remoteClient = client || await createRemoteClient();\n const result = await remoteClient.resourcePackages.compilePackage(upload(data, input));\n return { data, result };\n}\n\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(\",\")}]`;\n if (value && typeof value === \"object\") return `{${Object.entries(value as Record<string, unknown>).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(\",\")}}`;\n return JSON.stringify(value);\n}\n\nfunction installKey(bundle: Record<string, unknown>, map: Record<string, string>): string {\n return `install-${createHash(\"sha256\").update(canonical({ bundle, mappings: map })).digest(\"hex\").slice(0, 40)}`;\n}\n\nfunction importedRows(imported: Record<string, unknown>): Array<Record<string, unknown>> {\n return Array.isArray(imported.resources) ? imported.resources.filter((item): item is Record<string, unknown> => Boolean(item && typeof item === \"object\")) : [];\n}\n\ntype InstallMode = \"client-deployment\" | \"bff\" | \"publish-only\";\ntype AppInfo = { directory: string; integration: Exclude<InstallMode, \"publish-only\">; packageManager: string };\n\nfunction interactive(parsed: Parsed): boolean {\n return flag(parsed, \"yes\") !== \"true\" && Boolean(process.stdin.isTTY && process.stdout.isTTY);\n}\n\nfunction cancelled<T>(value: T): asserts value is Exclude<T, symbol> {\n if (isCancel(value)) throw new Error(\"Installation cancelled\");\n}\n\nasync function apiKeyForInstall(parsed: Parsed): Promise<string> {\n let apiKey = String(process.env.AGENTS24_API_KEY || \"\").trim();\n if (!apiKey && interactive(parsed)) {\n const answer = await password({ message: \"Agents24 API key\", validate: (value) => String(value || \"\").trim() ? undefined : \"The API key is required.\" });\n cancelled(answer);\n apiKey = String(answer).trim();\n }\n if (!apiKey) throw new Error(\"AGENTS24_API_KEY is required for noninteractive installation\");\n if (/[\\r\\n\\0]/.test(apiKey)) throw new Error(\"AGENTS24_API_KEY contains invalid control characters\");\n return apiKey;\n}\n\nfunction clientAppBaseUrl(environment: NodeJS.ProcessEnv = process.env): string | undefined {\n const baseUrl = String(environment.AGENTS24_BASE_URL || \"\").trim().replace(/\\/+$/, \"\");\n if (!baseUrl || baseUrl === DEFAULT_API_BASE_URL) return undefined;\n let parsed: URL;\n try {\n parsed = new URL(baseUrl);\n } catch {\n throw new Error(\"AGENTS24_BASE_URL must be a valid absolute HTTP(S) URL.\");\n }\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new Error(\"AGENTS24_BASE_URL must be a valid absolute HTTP(S) URL.\");\n }\n return baseUrl;\n}\n\nasync function appInfoAt(directory: string, explicit: boolean): Promise<AppInfo | undefined> {\n const target = resolve(directory);\n try {\n const manifest = JSON.parse(await readFile(join(target, \"package.json\"), \"utf8\")) as Record<string, unknown>;\n const metadata = manifest.agents24 && typeof manifest.agents24 === \"object\" ? manifest.agents24 as Record<string, unknown> : {};\n const integration = String(metadata.integration || \"\");\n if (integration !== \"client-deployment\" && integration !== \"bff\") {\n if (explicit) throw new Error(\"--app must reference a generated Agents24 application\");\n return undefined;\n }\n return { directory: target, integration, packageManager: String(metadata.package_manager || \"pnpm\") };\n } catch (error) {\n if (explicit || (error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n return undefined;\n }\n}\n\nasync function resolveApp(parsed: Parsed): Promise<AppInfo | undefined> {\n const requested = flag(parsed, \"app\");\n return appInfoAt(requested || process.cwd(), Boolean(requested));\n}\n\nasync function resolveInstallMode(parsed: Parsed, app: AppInfo | undefined): Promise<InstallMode> {\n const requested = flag(parsed, \"integration\") as InstallMode | undefined;\n if (requested && ![\"client-deployment\", \"bff\", \"publish-only\"].includes(requested)) throw new Error(\"--integration must be client-deployment, bff, or publish-only\");\n if (requested && app && requested !== \"publish-only\" && requested !== app.integration) throw new Error(\"--integration does not match the generated application\");\n if (requested) return requested;\n if (app) return app.integration;\n if (!interactive(parsed)) throw new Error(\"--integration is required when no generated application is detected\");\n const answer = await select<InstallMode>({ message: \"How will this Agent be integrated?\", options: [\n { value: \"client-deployment\", label: \"Client deployment\", hint: \"Create a public deployment ID\" },\n { value: \"bff\", label: \"Server BFF\", hint: \"Use the API key only on the server\" },\n { value: \"publish-only\", label: \"Publish only\", hint: \"Configure an integration later\" },\n ] });\n cancelled(answer);\n return answer;\n}\n\nasync function selectInstalledAgent(parsed: Parsed, imported: Record<string, unknown>): Promise<Record<string, unknown>> {\n const agents = importedRows(imported).filter((row) => row.kind === \"agent\");\n if (!agents.length) throw new Error(\"The installed package does not contain an Agent\");\n const requested = flag(parsed, \"agent\");\n if (requested) {\n const match = agents.find((row) => [row.id, row.resource_key, row.name].map(String).includes(requested));\n if (!match) throw new Error(`--agent did not match an imported Agent: ${requested}`);\n return match;\n }\n if (agents.length === 1) return agents[0];\n if (!interactive(parsed)) throw new Error(\"--agent is required when the package contains multiple Agents\");\n const answer = await select<string>({ message: \"Which Agent should be published?\", options: agents.map((row) => ({ value: String(row.id), label: String(row.name) })) });\n cancelled(answer);\n return agents.find((row) => String(row.id) === answer)!;\n}\n\nasync function clientDeployment(parsed: Parsed, client: Awaited<ReturnType<typeof createRemoteClient>>, agent: Record<string, unknown>, app: AppInfo | undefined): Promise<Record<string, unknown>> {\n const policies = (await client.resourcePolicies.list()).filter((row) => row.is_active === true);\n let policyId = flag(parsed, \"policy-set\");\n if (policyId && !policies.some((row) => String(row.id) === policyId)) throw new Error(\"--policy-set must identify an active Resource Policy\");\n if (!policyId && policies.length === 1) policyId = String(policies[0].id);\n if (!policyId && interactive(parsed) && policies.length > 1) {\n const answer = await select<string>({ message: \"Resource Policy\", options: policies.map((row) => ({ value: String(row.id), label: String(row.name) })) });\n cancelled(answer);\n policyId = answer;\n }\n if (!policyId) throw new Error(\"An active Resource Policy is required; pass --policy-set when more than one is active\");\n let origins = values(parsed, \"origin\");\n if (!origins.length && app) origins = [...DEFAULT_LOCAL_CLIENT_ORIGINS];\n if (!origins.length && interactive(parsed)) {\n const answer = await text({ message: \"Allowed browser origins\", placeholder: \"http://localhost:5173\", validate: (value) => String(value || \"\").trim() ? undefined : \"At least one origin is required.\" });\n cancelled(answer);\n origins = String(answer).split(\",\").map((item) => item.trim()).filter(Boolean);\n }\n if (!origins.length) throw new Error(\"At least one --origin is required when no generated app is detected\");\n const authModes = values(parsed, \"auth-mode\").length ? values(parsed, \"auth-mode\") : [\"anonymous\"];\n const oidcRaw = flag(parsed, \"oidc-config\");\n if (authModes.includes(\"external_oidc\") && !oidcRaw) throw new Error(\"--oidc-config is required for external_oidc\");\n const request = {\n agent_id: String(agent.id), resource_policy_set_id: policyId,\n version_policy: { mode: \"latest_published\" }, name: `${String(agent.name)} client deployment`,\n auth_modes: authModes, allowed_origins: origins,\n ...(oidcRaw ? { oidc: JSON.parse(oidcRaw) as Record<string, unknown> } : {}),\n };\n return client.clientDeployments.create(request, { idempotencyKey: `deploy-${createHash(\"sha256\").update(canonical(request)).digest(\"hex\").slice(0, 40)}` });\n}\n\nasync function updateEnvFile(app: AppInfo, values: Record<string, string>): Promise<string> {\n const target = join(app.directory, \".env.local\");\n let content = \"\";\n try { content = await readFile(target, \"utf8\"); } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n let next = content;\n for (const [name, value] of Object.entries(values)) {\n const line = `${name}=${JSON.stringify(value)}`;\n const pattern = new RegExp(`^${name}=.*$`, \"m\");\n next = pattern.test(next) ? next.replace(pattern, line) : `${next}${next && !next.endsWith(\"\\n\") ? \"\\n\" : \"\"}${line}\\n`;\n }\n await writeFile(target, next, { mode: 0o600 });\n await chmod(target, 0o600);\n return target;\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 selectors = [{ kind, id, target, ...(flag(parsed, \"version-id\") ? { version_id: flag(parsed, \"version-id\") } : {}) }];\n for (const value of values(parsed, \"selector\")) {\n const [itemKind, itemId, itemTarget = \"draft\", versionId] = value.split(\":\");\n if (!itemKind || !itemId) throw new Error(\"--selector must be kind:id[:draft|version[:version-id]]\");\n selectors.push({ kind: itemKind, id: itemId, target: itemTarget, ...(versionId ? { version_id: versionId } : {}) });\n }\n const request = { selectors };\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\" || parsed.command === \"install\") {\n const app = parsed.command === \"install\" ? await resolveApp(parsed) : undefined;\n const integration = parsed.command === \"install\" ? await resolveInstallMode(parsed, app) : undefined;\n const apiKey = parsed.command === \"install\" ? await apiKeyForInstall(parsed) : undefined;\n const client = apiKey\n ? await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey })\n : await createRemoteClient();\n const { result } = await compiledPackage(parsed, client);\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 let preview = await client.resourceBundles.importPreview(request);\n request.mappings = await promptMappings(parsed, client, preview, request.mappings);\n if (Object.keys(request.mappings).length) preview = await client.resourceBundles.importPreview(request);\n if (parsed.command === \"preview\") return { ok: preview.can_import === true, preview };\n if (parsed.command === \"install\") assertInstallPreviewReady(preview);\n if (preview.can_import !== true) return { ok: false, preview };\n await confirmation(parsed, preview);\n const imported = await client.resourceBundles.importBundle(request, { idempotencyKey: installKey(request.bundle, request.mappings) });\n if (parsed.command === \"import\") return { ok: true, phase: \"imported\", preview, result: imported };\n const agent = await selectInstalledAgent(parsed, imported);\n if (importedRows(imported).some((row) => row.status === \"incomplete\") && flag(parsed, \"allow-incomplete\") !== \"true\") {\n throw Object.assign(new Error(\"Publication is blocked by incomplete imported dependencies\"), { phase: \"post_import\", imported });\n }\n try {\n await client.agents.publish(String(agent.id), {\n idempotencyKey: `publish-${createHash(\"sha256\").update(`agent:${String(agent.id)}`).digest(\"hex\").slice(0, 40)}`,\n });\n } catch (error) {\n throw Object.assign(error instanceof Error ? error : new Error(\"Agent publication failed\"), {\n phase: \"publish\",\n imported,\n });\n }\n let deployment: Record<string, unknown> | undefined;\n try {\n if (integration === \"client-deployment\") deployment = await clientDeployment(parsed, client, agent, app);\n } catch (error) {\n throw Object.assign(error instanceof Error ? error : new Error(\"Client deployment setup failed\"), {\n phase: \"deployment\",\n imported,\n });\n }\n const deploymentId = deployment && typeof deployment.client_id === \"string\" ? deployment.client_id : undefined;\n let envFile: string | undefined;\n if (app && flag(parsed, \"no-write-env\") !== \"true\" && integration !== \"publish-only\") {\n try {\n const localClientBaseUrl = integration === \"client-deployment\" ? clientAppBaseUrl() : undefined;\n envFile = await updateEnvFile(app, integration === \"client-deployment\"\n ? {\n VITE_AGENTS24_DEPLOYMENT_ID: String(deploymentId),\n ...(localClientBaseUrl ? { VITE_AGENTS24_BASE_URL: localClientBaseUrl } : {}),\n }\n : { AGENTS24_API_KEY: apiKey!, AGENTS24_AGENT_ID: String(agent.id) });\n } catch (error) {\n throw Object.assign(error instanceof Error ? error : new Error(\"Could not configure the generated app\"), {\n phase: \"env_write\",\n imported,\n });\n }\n }\n const packageManager = app?.packageManager || \"pnpm\";\n const nextCommand = app && integration !== \"publish-only\"\n ? packageManager === \"npm\" ? \"npm run dev\" : packageManager === \"bun\" ? \"bun run dev\" : `${packageManager} dev`\n : undefined;\n return {\n ok: true,\n phase: deployment ? \"deployed\" : \"published\",\n integration,\n agent_id: String(agent.id),\n ...(deployment ? { deployment, deployment_id: deploymentId } : {}),\n env_written: Boolean(envFile),\n ...(envFile ? { env_file: envFile } : {}),\n ...(nextCommand ? { next_command: nextCommand } : {}),\n preview,\n result: imported,\n };\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\nfunction errorMessage(error: unknown, parsed: Parsed | undefined): string {\n if (parsed?.command === \"install\" && error && typeof error === \"object\" && \"status\" in error && error.status === 403) {\n return \"This API key cannot install Agents. Create a new Agent integration API key in Settings; existing keys cannot gain additional scopes.\";\n }\n return error instanceof Error ? error.message : \"Unexpected CLI failure\";\n}\n\nfunction installSummary(result: Record<string, unknown>): string {\n const lines = [\"Agent installed and published.\", `Agent ID: ${String(result.agent_id)}`];\n if (result.deployment_id) lines.push(`Deployment ID: ${String(result.deployment_id)}`);\n if (result.env_written) lines.push(`Configured: ${String(result.env_file)}`);\n else if (result.integration !== \"publish-only\") lines.push(\"Environment configuration was not written.\");\n if (result.next_command) lines.push(`Next: ${String(result.next_command)}`);\n return `${lines.join(\"\\n\")}\\n`;\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 if (parsed.command === \"install\") process.stdout.write(installSummary(result));\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: errorMessage(error, parsed),\n ...(error && typeof error === \"object\" && \"phase\" in error ? { phase: (error as { phase: unknown }).phase } : {}),\n ...(error && typeof error === \"object\" && \"imported\" in error ? { import_result: (error as { imported: unknown }).imported } : {}),\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,MAAM,eAAe;AACxC,SAAS,OAAO,UAAU,iBAAiB;AAC3C,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,UAAU,UAAU,QAAQ,YAAY;AAYjD,IAAM,gBAAgB,oBAAI,IAAI,CAAC,QAAQ,UAAU,OAAO,oBAAoB,cAAc,CAAC;AAC3F,IAAM,uBAAuB;AAC7B,IAAM,+BAA+B,CAAC,yBAAyB,uBAAuB;AAEtF,SAAS,MAAM,MAAwB;AACrC,QAAM,oBAAoB,KAAK,CAAC,MAAM;AACtC,MAAI,CAAC,sBAAsB,KAAK,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,GAAI,OAAM,IAAI,MAAM,kHAAkH;AACjM,QAAM,QAAQ,oBAAI,IAAsB;AACxC,QAAM,cAAwB,CAAC;AAC/B,WAAS,QAAQ,oBAAoB,IAAI,GAAG,QAAQ,KAAK,QAAQ,SAA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;AAAA,aAChF,OAAO,YAAY,UAAW,SAAQ,OAAO,MAAM,eAAe,MAAM,CAAC;AAAA,QAC7E,SAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,CAAI;AAChE,WAAO,OAAO,OAAO,QAAQ,IAAI;AAAA,EACnC,SAAS,OAAO;AACd,UAAM,UAAU;AAAA,MACd,IAAI;AAAA,MACJ,OAAO,aAAa,OAAO,MAAM;AAAA,MACjC,GAAI,SAAS,OAAO,UAAU,YAAY,WAAW,QAAQ,EAAE,OAAQ,MAA6B,MAAM,IAAI,CAAC;AAAA,MAC/G,GAAI,SAAS,OAAO,UAAU,YAAY,cAAc,QAAQ,EAAE,eAAgB,MAAgC,SAAS,IAAI,CAAC;AAAA,MAChI,GAAI,YAAY,KAAK,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":["answer","values"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ declare function packPackage(input: string): Promise<Uint8Array>;
|
|
|
22
22
|
declare function initializePackage(directory: string, packageName: string): Promise<string>;
|
|
23
23
|
|
|
24
24
|
declare function parseMappings(items: string[]): Record<string, string>;
|
|
25
|
+
declare function shouldPromptForDependency(dependency: Record<string, unknown>): boolean;
|
|
26
|
+
declare function assertInstallPreviewReady(preview: Record<string, unknown>): void;
|
|
25
27
|
declare function assertImportAllowed(preview: Record<string, unknown>, options: {
|
|
26
28
|
allowIncomplete: boolean;
|
|
27
29
|
yes: boolean;
|
|
@@ -48,9 +50,29 @@ type RemoteClient = {
|
|
|
48
50
|
};
|
|
49
51
|
resourceBundles: {
|
|
50
52
|
importPreview(request: ResourceBundleRequest): Promise<Record<string, unknown>>;
|
|
51
|
-
importBundle(request: ResourceBundleRequest
|
|
53
|
+
importBundle(request: ResourceBundleRequest, options?: {
|
|
54
|
+
idempotencyKey?: string;
|
|
55
|
+
}): Promise<Record<string, unknown>>;
|
|
56
|
+
candidates(options: {
|
|
57
|
+
kind: string;
|
|
58
|
+
query?: string;
|
|
59
|
+
requiredCapability?: "chat" | "embedding";
|
|
60
|
+
}): Promise<Record<string, unknown>>;
|
|
61
|
+
};
|
|
62
|
+
agents: {
|
|
63
|
+
publish(id: string, options?: {
|
|
64
|
+
idempotencyKey?: string;
|
|
65
|
+
}): Promise<Record<string, unknown>>;
|
|
66
|
+
};
|
|
67
|
+
resourcePolicies: {
|
|
68
|
+
list(): Promise<Array<Record<string, unknown>>>;
|
|
69
|
+
};
|
|
70
|
+
clientDeployments: {
|
|
71
|
+
create(request: Record<string, unknown>, options?: {
|
|
72
|
+
idempotencyKey?: string;
|
|
73
|
+
}): Promise<Record<string, unknown>>;
|
|
52
74
|
};
|
|
53
75
|
};
|
|
54
76
|
declare function createRemoteClient(environment?: NodeJS.ProcessEnv): Promise<RemoteClient>;
|
|
55
77
|
|
|
56
|
-
export { type Diagnostic, type RemoteClient, type ValidationResult, assertImportAllowed, createRemoteClient, initializePackage, loadPackageFiles, packFiles, packPackage, parseMappings, unpackFiles, validateFiles, validatePackage };
|
|
78
|
+
export { type Diagnostic, type RemoteClient, type ValidationResult, assertImportAllowed, assertInstallPreviewReady, createRemoteClient, initializePackage, loadPackageFiles, packFiles, packPackage, parseMappings, shouldPromptForDependency, unpackFiles, validateFiles, validatePackage };
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
assertImportAllowed,
|
|
4
|
+
assertInstallPreviewReady,
|
|
4
5
|
createRemoteClient,
|
|
5
6
|
initializePackage,
|
|
6
7
|
loadPackageFiles,
|
|
7
8
|
packFiles,
|
|
8
9
|
packPackage,
|
|
9
10
|
parseMappings,
|
|
11
|
+
shouldPromptForDependency,
|
|
10
12
|
unpackFiles,
|
|
11
13
|
validateFiles,
|
|
12
14
|
validatePackage
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MNGBA3HP.js";
|
|
14
16
|
export {
|
|
15
17
|
assertImportAllowed,
|
|
18
|
+
assertInstallPreviewReady,
|
|
16
19
|
createRemoteClient,
|
|
17
20
|
initializePackage,
|
|
18
21
|
loadPackageFiles,
|
|
19
22
|
packFiles,
|
|
20
23
|
packPackage,
|
|
21
24
|
parseMappings,
|
|
25
|
+
shouldPromptForDependency,
|
|
22
26
|
unpackFiles,
|
|
23
27
|
validateFiles,
|
|
24
28
|
validatePackage
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
"model": {
|
|
25
25
|
"type": "string"
|
|
26
26
|
},
|
|
27
|
+
"model_selectable": {
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
30
|
+
"temperature": {
|
|
31
|
+
"type": "number",
|
|
32
|
+
"minimum": 0,
|
|
33
|
+
"maximum": 1
|
|
34
|
+
},
|
|
27
35
|
"instructions": {
|
|
28
36
|
"type": "array",
|
|
29
37
|
"items": {
|
|
@@ -97,6 +105,10 @@
|
|
|
97
105
|
"max_parallel_tools": {
|
|
98
106
|
"type": "integer",
|
|
99
107
|
"minimum": 1
|
|
108
|
+
},
|
|
109
|
+
"tool_timeout_s": {
|
|
110
|
+
"type": "number",
|
|
111
|
+
"exclusiveMinimum": 0
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
114
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"required": [
|
|
7
7
|
"schema",
|
|
8
8
|
"name",
|
|
9
|
-
"
|
|
9
|
+
"resources"
|
|
10
10
|
],
|
|
11
11
|
"$defs": {
|
|
12
12
|
"requirement": {
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"required": {
|
|
21
21
|
"type": "boolean"
|
|
22
22
|
},
|
|
23
|
+
"capability": {
|
|
24
|
+
"enum": ["chat", "embedding"]
|
|
25
|
+
},
|
|
23
26
|
"match": {
|
|
24
27
|
"type": "object",
|
|
25
28
|
"additionalProperties": false,
|
|
@@ -28,6 +31,11 @@
|
|
|
28
31
|
"type": "string",
|
|
29
32
|
"minLength": 1,
|
|
30
33
|
"maxLength": 256
|
|
34
|
+
},
|
|
35
|
+
"canonical_key": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"pattern": "^[a-z0-9][a-z0-9._:/-]*$",
|
|
38
|
+
"maxLength": 255
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
}
|
|
@@ -50,9 +58,15 @@
|
|
|
50
58
|
"version": {
|
|
51
59
|
"type": "string"
|
|
52
60
|
},
|
|
53
|
-
"
|
|
54
|
-
"type": "
|
|
55
|
-
"
|
|
61
|
+
"resources": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"minItems": 1,
|
|
64
|
+
"maxItems": 250,
|
|
65
|
+
"uniqueItems": true,
|
|
66
|
+
"items": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"pattern": "^(workflows/[a-z0-9][a-z0-9-]*\\.yaml|rag/[a-z0-9][a-z0-9-]*\\.yaml|skills/[a-z0-9][a-z0-9-]*\\.md|stores/[a-z0-9][a-z0-9-]*\\.yaml)$"
|
|
69
|
+
}
|
|
56
70
|
},
|
|
57
71
|
"requires": {
|
|
58
72
|
"type": "object",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://docs.agents24.dev/schemas/resource-package/1.0/store.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["schema", "name", "description", "embedding_model", "chunking", "retrieval_policy", "default_namespace"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"schema": { "const": "agents24.store/v1" },
|
|
9
|
+
"name": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
10
|
+
"description": { "type": "string", "maxLength": 2000 },
|
|
11
|
+
"embedding_model": { "type": "string", "pattern": "^\\$models\\.[a-z0-9]+(?:-[a-z0-9]+)*$" },
|
|
12
|
+
"chunking": { "type": "object" },
|
|
13
|
+
"retrieval_policy": { "enum": ["semantic_only", "hybrid", "keyword_only", "recency_boosted"] },
|
|
14
|
+
"default_namespace": { "type": "string", "minLength": 1, "maxLength": 128 }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
"outputs": {
|
|
36
36
|
"type": "object"
|
|
37
37
|
},
|
|
38
|
+
"output_schema": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"required": ["schema"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"name": {"type": "string"},
|
|
43
|
+
"mode": {"enum": ["simple", "advanced"]},
|
|
44
|
+
"schema": {"type": "object"}
|
|
45
|
+
},
|
|
46
|
+
"additionalProperties": false
|
|
47
|
+
},
|
|
38
48
|
"entry": {
|
|
39
49
|
"type": "string",
|
|
40
50
|
"minLength": 1
|
|
@@ -69,9 +79,16 @@
|
|
|
69
79
|
"inputs": {
|
|
70
80
|
"type": "array",
|
|
71
81
|
"items": {
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
"oneOf": [
|
|
83
|
+
{"type": "string"},
|
|
84
|
+
{
|
|
85
|
+
"type": "object",
|
|
86
|
+
"required": ["from"],
|
|
87
|
+
"properties": {"from": {"type": "string"}},
|
|
88
|
+
"additionalProperties": false
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
75
92
|
},
|
|
76
93
|
"with": {
|
|
77
94
|
"type": "object"
|
|
@@ -94,6 +111,12 @@
|
|
|
94
111
|
},
|
|
95
112
|
"to": {
|
|
96
113
|
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"type": {
|
|
116
|
+
"enum": ["control", "data"]
|
|
117
|
+
},
|
|
118
|
+
"condition": {
|
|
119
|
+
"type": "string"
|
|
97
120
|
}
|
|
98
121
|
},
|
|
99
122
|
"additionalProperties": false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agents24/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Git-friendly Agents24 resource package tooling.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"provenance": false
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@agents24/node": "0.2.
|
|
37
|
+
"@agents24/node": "0.2.1",
|
|
38
|
+
"@clack/prompts": "1.7.0",
|
|
38
39
|
"ajv": "^8.17.1",
|
|
39
40
|
"yaml": "^2.8.1"
|
|
40
41
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/archive.ts","../src/package-source.ts","../src/remote.ts","../src/import-guards.ts"],"sourcesContent":["import { inflateRawSync, deflateRawSync } from \"node:zlib\";\n\nconst MAX_COMPRESSED = 5 * 1024 * 1024;\nconst MAX_UNCOMPRESSED = 10 * 1024 * 1024;\nconst MAX_FILE = 2 * 1024 * 1024;\nconst MAX_FILES = 512;\nconst MAX_DEPTH = 12;\n\nconst CRC_TABLE = Array.from({ length: 256 }, (_, start) => {\n let value = start;\n for (let bit = 0; bit < 8; bit += 1) {\n value = (value & 1) ? 0xedb88320 ^ (value >>> 1) : value >>> 1;\n }\n return value >>> 0;\n});\n\nfunction crc32(value: Uint8Array): number {\n let crc = 0xffffffff;\n for (const byte of value) crc = CRC_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);\n return (crc ^ 0xffffffff) >>> 0;\n}\n\nfunction safePath(raw: string): string {\n if (!raw || raw.startsWith(\"/\") || raw.includes(\"\\\\\")) throw new Error(\"Archive contains an unsafe path\");\n const parts = raw.split(\"/\");\n if (parts.some((part) => !part || part === \".\" || part === \"..\")) throw new Error(\"Archive contains an unsafe path\");\n if (parts.length > MAX_DEPTH) throw new Error(`Archive path exceeds depth ${MAX_DEPTH}: ${raw}`);\n if (/\\.(?:zip|tar|tgz|gz)$/i.test(raw)) throw new Error(`Nested archives are unsupported: ${raw}`);\n if (!/\\.(?:yaml|md)$/.test(raw) || raw.endsWith(\".yml\")) throw new Error(`Unsupported package file: ${raw}`);\n return raw;\n}\n\nfunction writeUInt32(value: number): Buffer {\n const result = Buffer.allocUnsafe(4);\n result.writeUInt32LE(value >>> 0);\n return result;\n}\n\nfunction writeUInt16(value: number): Buffer {\n const result = Buffer.allocUnsafe(2);\n result.writeUInt16LE(value);\n return result;\n}\n\nexport function packFiles(files: Map<string, string>): Uint8Array {\n if (files.size > MAX_FILES) throw new Error(\"Package exceeds the 512-file limit\");\n const localParts: Buffer[] = [];\n const centralParts: Buffer[] = [];\n let offset = 0;\n let total = 0;\n const normalized = new Set<string>();\n\n for (const [rawPath, text] of [...files.entries()].sort(([left], [right]) => left.localeCompare(right))) {\n const path = safePath(rawPath);\n const folded = path.toLocaleLowerCase(\"en-US\");\n if (normalized.has(folded)) throw new Error(`Package contains duplicate path: ${path}`);\n normalized.add(folded);\n const name = Buffer.from(path, \"utf8\");\n const content = Buffer.from(text, \"utf8\");\n if (content.byteLength > MAX_FILE) throw new Error(`Package file exceeds the 2 MiB limit: ${path}`);\n total += content.byteLength;\n if (total > MAX_UNCOMPRESSED) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n const compressed = deflateRawSync(content, { level: 9 });\n const checksum = crc32(content);\n const local = Buffer.concat([\n writeUInt32(0x04034b50),\n writeUInt16(20),\n writeUInt16(0x0800),\n writeUInt16(8),\n writeUInt16(0),\n writeUInt16(0x0021),\n writeUInt32(checksum),\n writeUInt32(compressed.byteLength),\n writeUInt32(content.byteLength),\n writeUInt16(name.byteLength),\n writeUInt16(0),\n name,\n compressed,\n ]);\n localParts.push(local);\n centralParts.push(Buffer.concat([\n writeUInt32(0x02014b50),\n writeUInt16(0x0314),\n writeUInt16(20),\n writeUInt16(0x0800),\n writeUInt16(8),\n writeUInt16(0),\n writeUInt16(0x0021),\n writeUInt32(checksum),\n writeUInt32(compressed.byteLength),\n writeUInt32(content.byteLength),\n writeUInt16(name.byteLength),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt32(0o100644 << 16),\n writeUInt32(offset),\n name,\n ]));\n offset += local.byteLength;\n }\n\n const central = Buffer.concat(centralParts);\n const result = Buffer.concat([\n ...localParts,\n central,\n writeUInt32(0x06054b50),\n writeUInt16(0),\n writeUInt16(0),\n writeUInt16(files.size),\n writeUInt16(files.size),\n writeUInt32(central.byteLength),\n writeUInt32(offset),\n writeUInt16(0),\n ]);\n if (result.byteLength > MAX_COMPRESSED) throw new Error(\"Package exceeds the 5 MiB compressed limit\");\n return result;\n}\n\nfunction endOfCentralDirectory(data: Buffer): number {\n const minimum = Math.max(0, data.byteLength - 65557);\n for (let index = data.byteLength - 22; index >= minimum; index -= 1) {\n if (data.readUInt32LE(index) === 0x06054b50) return index;\n }\n throw new Error(\"Package must be a valid ZIP archive\");\n}\n\nexport function unpackFiles(value: Uint8Array): Map<string, string> {\n const data = Buffer.from(value);\n if (data.byteLength > MAX_COMPRESSED) throw new Error(\"Package exceeds the 5 MiB compressed limit\");\n const end = endOfCentralDirectory(data);\n const count = data.readUInt16LE(end + 10);\n const centralOffset = data.readUInt32LE(end + 16);\n if (count > MAX_FILES) throw new Error(\"Package exceeds the 512-file limit\");\n const files = new Map<string, string>();\n const normalized = new Set<string>();\n let cursor = centralOffset;\n let total = 0;\n\n for (let index = 0; index < count; index += 1) {\n if (data.readUInt32LE(cursor) !== 0x02014b50) throw new Error(\"Package central directory is invalid\");\n const method = data.readUInt16LE(cursor + 10);\n const expectedCrc = data.readUInt32LE(cursor + 16);\n const compressedSize = data.readUInt32LE(cursor + 20);\n const uncompressedSize = data.readUInt32LE(cursor + 24);\n const nameLength = data.readUInt16LE(cursor + 28);\n const extraLength = data.readUInt16LE(cursor + 30);\n const commentLength = data.readUInt16LE(cursor + 32);\n const externalAttributes = data.readUInt32LE(cursor + 38);\n const localOffset = data.readUInt32LE(cursor + 42);\n const path = safePath(data.subarray(cursor + 46, cursor + 46 + nameLength).toString(\"utf8\"));\n if ((externalAttributes >>> 16 & 0o170000) === 0o120000) throw new Error(`Package symlinks are unsupported: ${path}`);\n const folded = path.toLocaleLowerCase(\"en-US\");\n if (normalized.has(folded)) throw new Error(`Package contains duplicate path: ${path}`);\n normalized.add(folded);\n if (uncompressedSize > MAX_FILE) throw new Error(`Package file exceeds the 2 MiB limit: ${path}`);\n total += uncompressedSize;\n if (total > MAX_UNCOMPRESSED) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n if (data.readUInt32LE(localOffset) !== 0x04034b50) throw new Error(\"Package local header is invalid\");\n const localNameLength = data.readUInt16LE(localOffset + 26);\n const localExtraLength = data.readUInt16LE(localOffset + 28);\n const contentOffset = localOffset + 30 + localNameLength + localExtraLength;\n const compressed = data.subarray(contentOffset, contentOffset + compressedSize);\n let content: Buffer | null = null;\n try {\n content = method === 8\n ? inflateRawSync(compressed, { maxOutputLength: Math.min(MAX_FILE, uncompressedSize) + 1 })\n : method === 0 ? compressed : null;\n } catch {\n throw new Error(`Package file is invalid or exceeds its declared size: ${path}`);\n }\n if (!content || content.byteLength !== uncompressedSize || crc32(content) !== expectedCrc) {\n throw new Error(`Package file is invalid: ${path}`);\n }\n if (content.includes(0)) throw new Error(`Binary package file is unsupported: ${path}`);\n files.set(path, new TextDecoder(\"utf-8\", { fatal: true }).decode(content));\n cursor += 46 + nameLength + extraLength + commentLength;\n }\n if (!files.has(\"agents24.yaml\")) throw new Error(\"Package requires agents24.yaml at the archive root\");\n return files;\n}\n","import { lstat, mkdir, readFile, readdir, stat, writeFile } from \"node:fs/promises\";\nimport { readFileSync as readSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport Ajv2020 from \"ajv/dist/2020.js\";\nimport { parseDocument } from \"yaml\";\n\nimport { packFiles, unpackFiles } from \"./archive.js\";\n\nexport type Diagnostic = { severity: \"error\" | \"warning\"; code: string; path: string; message: string };\nexport type ValidationResult = {\n valid: boolean;\n package: Record<string, unknown>;\n resources: Array<Record<string, unknown>>;\n requirements: string[];\n diagnostics: Diagnostic[];\n files: Map<string, string>;\n};\n\nconst MANIFEST = \"agents24.yaml\";\nconst SYMBOL = /^\\$(workflows|rag|skills|models|stores|tools|toolsets|artifacts|integrations|secrets)\\.([a-z0-9]+(?:-[a-z0-9]+)*)$/;\nconst UUID = /\\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\b/i;\nconst URL_PATTERN = /\\b[A-Za-z][A-Za-z0-9+.-]*:\\/\\//;\nconst LOCAL = /^(workflows|agents|rag|skills|files)\\/(?:[a-z0-9][a-z0-9-]*\\/)*[a-z0-9][a-z0-9-]*\\.(yaml|md)$/;\nconst SECRET_FIELDS = new Set([\"access_token\",\"api_key\",\"authorization\",\"bearer_token\",\"client_secret\",\"credential\",\"credentials\",\"fixed_account_connection_id\",\"oauth_client_id\",\"oauth_client_secret\",\"password\",\"private_key\",\"refresh_token\",\"secret_name\",\"secret_value\",\"static_bearer_token\",\"static_headers\",\"token\",\"url\",\"account_id\",\"organization_id\",\"project_id\",\"publication_state\",\"governance_policy\"]);\n\nfunction add(rows: Diagnostic[], severity: Diagnostic[\"severity\"], code: string, itemPath: string, message: string): void {\n rows.push({ severity, code, path: itemPath, message });\n}\nfunction slug(value: string): string {\n return value.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 64) || \"agent\";\n}\nfunction parseYaml(text: string, itemPath: string, diagnostics: Diagnostic[]): Record<string, unknown> {\n const doc = parseDocument(text, { uniqueKeys: true });\n for (const error of doc.errors) add(diagnostics, \"error\", \"YAML_INVALID\", itemPath, error.message);\n if (doc.errors.length) return {};\n const value = doc.toJS({ maxAliasCount: 0 });\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n add(diagnostics, \"error\", \"YAML_INVALID\", itemPath, \"YAML source must contain a mapping\");\n return {};\n }\n return value as Record<string, unknown>;\n}\nfunction frontmatter(text: string, itemPath: string, diagnostics: Diagnostic[]): Record<string, unknown> {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/.exec(text);\n if (!match) {\n add(diagnostics, \"error\", \"FRONTMATTER_REQUIRED\", itemPath, \"Markdown source requires YAML frontmatter\");\n return {};\n }\n return parseYaml(match[1], itemPath, diagnostics);\n}\nfunction markdownBody(text: string): string {\n const match = /^---\\r?\\n[\\s\\S]*?\\r?\\n---(?:\\r?\\n|$)([\\s\\S]*)$/.exec(text);\n return match?.[1] || \"\";\n}\nfunction schema(name: string): Record<string, unknown> {\n const location = new URL(`../generated/schemas/resource-package/1.0/${name}.schema.json`, import.meta.url);\n return JSON.parse(readSync(fileURLToPath(location), \"utf8\")) as Record<string, unknown>;\n}\nconst AjvConstructor = Ajv2020 as unknown as new (options: Record<string, unknown>) => {\n compile(schema: Record<string, unknown>): ((value: unknown) => boolean) & { errors?: Array<{ instancePath?: string; message?: string }> };\n};\nconst ajv = new AjvConstructor({ allErrors: true, strict: true, strictRequired: false });\nconst validators = Object.fromEntries([\"manifest\",\"workflow\",\"agent\",\"rag\",\"skill\"].map((name) => [name, ajv.compile(schema(name))]));\n\nasync function directoryFiles(root: string): Promise<Map<string, string>> {\n const files = new Map<string, string>();\n let total = 0;\n async function visit(directory: string): Promise<void> {\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const absolute = path.join(directory, entry.name);\n const relative = path.relative(root, absolute).split(path.sep).join(\"/\");\n const metadata = await lstat(absolute);\n if (metadata.isSymbolicLink()) throw new Error(`Package symlinks are unsupported: ${relative}`);\n if (metadata.isDirectory()) { await visit(absolute); continue; }\n if (!metadata.isFile()) continue;\n if (relative.split(\"/\").length > 12) throw new Error(`Package path exceeds depth 12: ${relative}`);\n if (!/\\.(?:yaml|md)$/.test(relative) || relative.endsWith(\".yml\")) throw new Error(`Unsupported package file: ${relative}`);\n if (metadata.size > 2 * 1024 * 1024) throw new Error(`Package file exceeds the 2 MiB limit: ${relative}`);\n total += metadata.size;\n if (total > 10 * 1024 * 1024) throw new Error(\"Package exceeds the 10 MiB uncompressed limit\");\n const body = await readFile(absolute);\n if (body.includes(0)) throw new Error(`Binary package file is unsupported: ${relative}`);\n files.set(relative, new TextDecoder(\"utf-8\", { fatal: true }).decode(body));\n if (files.size > 512) throw new Error(\"Package exceeds the 512-file limit\");\n }\n }\n await visit(root);\n return files;\n}\nexport async function loadPackageFiles(input: string): Promise<Map<string, string>> {\n return (await stat(input)).isDirectory() ? directoryFiles(input) : unpackFiles(await readFile(input));\n}\nfunction validateSchema(kind: keyof typeof validators, value: Record<string, unknown>, itemPath: string, diagnostics: Diagnostic[]): void {\n const validate = validators[kind];\n if (validate(value)) return;\n for (const error of validate.errors || []) add(diagnostics, \"error\", \"SCHEMA_INVALID\", itemPath + (error.instancePath || \"\"), error.message || \"Schema validation failed\");\n}\nfunction resolve(source: string, target: string): string | null {\n if (!target || target.startsWith(\"/\") || target.includes(\"\\\\\")) return null;\n const value = path.posix.normalize(path.posix.join(path.posix.dirname(source), target));\n return value === \"..\" || value.startsWith(\"../\") || !LOCAL.test(value) ? null : value;\n}\nfunction walk(value: unknown, visit: (value: unknown, itemPath: string, key?: string) => void, itemPath = \"\", key?: string): void {\n visit(value, itemPath, key);\n if (Array.isArray(value)) value.forEach((item, index) => walk(item, visit, `${itemPath}/${index}`, key));\n else if (value && typeof value === \"object\") for (const [key, item] of Object.entries(value as Record<string, unknown>)) {\n walk(item, visit, `${itemPath}/${key}`, key);\n }\n}\n\nexport function validateFiles(files: Map<string, string>): ValidationResult {\n const diagnostics: Diagnostic[] = [];\n const manifest = parseYaml(files.get(MANIFEST) || \"\", MANIFEST, diagnostics);\n validateSchema(\"manifest\", manifest, MANIFEST, diagnostics);\n walk(manifest, (item, itemPath, key) => {\n if (key && SECRET_FIELDS.has(key.toLowerCase())) add(diagnostics, \"error\", \"FORBIDDEN_FIELD\", MANIFEST + itemPath, \"Secret and platform identity fields are forbidden\");\n if (typeof item === \"string\" && (UUID.test(item) || URL_PATTERN.test(item))) add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", MANIFEST + itemPath, \"Platform UUIDs and URLs are forbidden in source packages\");\n });\n const parsed = new Map<string, Record<string, unknown>>();\n const resources: Array<Record<string, unknown>> = [];\n for (const [filePath, text] of [...files].sort(([left],[right]) => left.localeCompare(right))) {\n if (filePath === MANIFEST) continue;\n let kind: \"workflow\"|\"agent\"|\"rag\"|\"skill\"|null = null;\n if (/^workflows\\/[a-z0-9][a-z0-9-]*\\.yaml$/.test(filePath)) kind = \"workflow\";\n else if (/^agents\\/[a-z0-9][a-z0-9-]*\\.md$/.test(filePath)) kind = \"agent\";\n else if (/^rag\\/[a-z0-9][a-z0-9-]*\\.yaml$/.test(filePath)) kind = \"rag\";\n else if (/^skills\\/[a-z0-9][a-z0-9-]*\\.md$/.test(filePath)) kind = \"skill\";\n else if (/^files\\/.+\\.md$/.test(filePath)) { parsed.set(filePath, {}); continue; }\n if (!kind) { add(diagnostics, \"error\", \"UNKNOWN_FILE\", filePath, \"File is not in a canonical package directory\"); continue; }\n const value = kind === \"workflow\" || kind === \"rag\" ? parseYaml(text, filePath, diagnostics) : frontmatter(text, filePath, diagnostics);\n validateSchema(kind, value, filePath, diagnostics);\n if ((kind === \"agent\" || kind === \"skill\") && (UUID.test(markdownBody(text).trim()) || URL_PATTERN.test(markdownBody(text).trim()))) {\n add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", `${filePath}/body`, \"Platform UUIDs and URLs are forbidden in source packages\");\n }\n parsed.set(filePath, value);\n if (kind !== \"agent\") resources.push({ path: filePath, kind: kind === \"workflow\" ? \"agent\" : kind === \"rag\" ? \"rag_pipeline\" : \"instruction\", name: value.name });\n }\n const entrypoint = String(manifest.entrypoint || \"\");\n if (!parsed.has(entrypoint) || entrypoint.startsWith(\"agents/\") || entrypoint.startsWith(\"files/\")) add(diagnostics, \"error\", \"ENTRYPOINT_INVALID\", MANIFEST, \"Entrypoint must reference a Workflow, RAG pipeline, or Skill\");\n const reachable = new Set<string>();\n const queue = entrypoint ? [entrypoint] : [];\n let referenceCount = 0;\n while (queue.length) {\n const source = queue.shift() as string;\n if (reachable.has(source)) continue;\n reachable.add(source);\n const value = parsed.get(source) || {};\n if (source.startsWith(\"agents/\")) {\n for (const match of (files.get(source) || \"\").matchAll(/\\[\\[skill:([a-z0-9]+(?:-[a-z0-9]+)*)\\]\\]/g)) {\n referenceCount += 1;\n const target = `skills/${match[1]}.md`;\n if (!parsed.has(target)) add(diagnostics, \"error\", \"LOCAL_REFERENCE_MISSING\", `${source}/body`, `Missing local reference: ${target}`);\n else queue.push(target);\n }\n }\n walk(value, (item, itemPath, key) => {\n if (key && SECRET_FIELDS.has(key.toLowerCase())) add(diagnostics, \"error\", \"FORBIDDEN_FIELD\", source + itemPath, \"Secret and platform identity fields are forbidden\");\n if (typeof item !== \"string\") return;\n if (UUID.test(item) || URL_PATTERN.test(item)) add(diagnostics, \"error\", \"FORBIDDEN_VALUE\", source + itemPath, \"Platform UUIDs and URLs are forbidden in source packages\");\n const symbol = SYMBOL.exec(item);\n if (symbol) {\n referenceCount += 1;\n const declarations = (manifest.requires as Record<string, Record<string, unknown>> | undefined)?.[symbol[1]];\n if (!declarations || !(symbol[2] in declarations)) add(diagnostics, \"error\", \"REQUIREMENT_UNDECLARED\", source + itemPath, `${item} is not declared`);\n }\n if (![\"uses\",\"skills\",\"instructions\",\"file\"].includes(String(key))) return;\n const target = resolve(source, item);\n if (target) {\n referenceCount += 1;\n if (!parsed.has(target)) add(diagnostics, \"error\", \"LOCAL_REFERENCE_MISSING\", source + itemPath, `Missing local reference: ${target}`);\n else queue.push(target);\n }\n });\n }\n for (const filePath of parsed.keys()) if (!reachable.has(filePath)) add(diagnostics, \"error\", \"UNREACHABLE_RESOURCE\", filePath, \"Local source is not reachable from the entrypoint\");\n if (resources.length > 250) add(diagnostics, \"error\", \"RESOURCE_LIMIT\", MANIFEST, \"Package exceeds 250 resources\");\n if (referenceCount > 5000) add(diagnostics, \"error\", \"REFERENCE_LIMIT\", MANIFEST, \"Package exceeds 5,000 references\");\n diagnostics.sort((left,right) => left.path.localeCompare(right.path) || left.code.localeCompare(right.code) || left.message.localeCompare(right.message));\n const requirements = [...new Set([...files.values()].flatMap((text) => [...text.matchAll(/\\$(?:workflows|rag|skills|models|stores|tools|toolsets|artifacts|integrations|secrets)\\.[a-z0-9-]+/g)].map((match) => match[0])))].sort();\n return { valid: !diagnostics.some((item) => item.severity === \"error\"), package: manifest, resources, requirements, diagnostics, files };\n}\nexport async function validatePackage(input: string): Promise<ValidationResult> {\n return validateFiles(await loadPackageFiles(input));\n}\nexport async function packPackage(input: string): Promise<Uint8Array> {\n const result = await validatePackage(input);\n if (!result.valid) throw Object.assign(new Error(\"Resource package is invalid\"), { diagnostics: result.diagnostics });\n return packFiles(result.files);\n}\nexport async function initializePackage(directory: string, packageName: string): Promise<string> {\n const packageSlug = slug(packageName);\n await mkdir(path.join(directory, \"workflows\"), { recursive: true });\n await mkdir(path.join(directory, \"agents\"), { recursive: true });\n await mkdir(path.join(directory, \"rag\"), { recursive: true });\n await mkdir(path.join(directory, \"skills\"), { recursive: true });\n await mkdir(path.join(directory, \"files\"), { recursive: true });\n const manifest = { schema: \"agents24.package/v1\", name: packageSlug, description: `${packageName} agent package`, entrypoint: \"workflows/main.yaml\", requires: { models: { primary: { required: true } } } };\n const workflow = { schema: \"agents24.workflow/v1\", name: packageName, description: \"\", inputs: { text: \"string\" }, outputs: { response: \"string\" }, entry: \"assistant\", nodes: { assistant: { uses: \"../agents/assistant.md\" } }, flow: [{ from: \"assistant.output\", to: \"output.response\" }] };\n const agent = `---\\nschema: agents24.agent/v1\\nname: Assistant\\ndescription: Primary assistant\\nmodel: $models.primary\\n---\\n\\nYou are a helpful assistant.\\n`;\n await writeFile(path.join(directory, MANIFEST), _yaml(manifest), { flag: \"wx\" });\n await writeFile(path.join(directory, \"workflows/main.yaml\"), _yaml(workflow), { flag: \"wx\" });\n await writeFile(path.join(directory, \"agents/assistant.md\"), agent, { flag: \"wx\" });\n return packageSlug;\n}\nfunction _yaml(value: unknown): string {\n const doc = parseDocument(\"{}\");\n doc.contents = doc.createNode(value) as typeof doc.contents;\n return String(doc);\n}\n","type ResourcePackageUpload = { data: Uint8Array; filename?: string };\ntype ResourceBundleRequest = {\n bundle: Record<string, unknown>;\n selected_resource_keys?: string[];\n mappings?: Record<string, string>;\n};\n\nexport type RemoteClient = {\n resourcePackages: {\n exportPackage(request: Record<string, unknown>): Promise<{ data: Uint8Array; filename: string }>;\n validatePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;\n compilePackage(upload: ResourcePackageUpload): Promise<Record<string, unknown>>;\n };\n resourceBundles: {\n importPreview(request: ResourceBundleRequest): Promise<Record<string, unknown>>;\n importBundle(request: ResourceBundleRequest): Promise<Record<string, unknown>>;\n };\n};\n\nexport async function createRemoteClient(environment: NodeJS.ProcessEnv = process.env): Promise<RemoteClient> {\n const required = [\n \"AGENTS24_BASE_URL\",\n \"AGENTS24_API_KEY\",\n \"AGENTS24_ORGANIZATION_ID\",\n \"AGENTS24_PROJECT_ID\",\n ] as const;\n const missing = required.filter((name) => !String(environment[name] || \"\").trim());\n if (missing.length) throw new Error(`Missing remote configuration: ${missing.join(\", \")}`);\n\n const canonicalNodePackage = \"@agents24/node\";\n const module = await import(canonicalNodePackage) as { Agents24?: new (options: Record<string, unknown>) => unknown };\n if (!module.Agents24) throw new Error(\"@agents24/node does not export Agents24\");\n return new module.Agents24({\n baseUrl: environment.AGENTS24_BASE_URL,\n apiKey: environment.AGENTS24_API_KEY,\n organizationId: environment.AGENTS24_ORGANIZATION_ID,\n projectId: environment.AGENTS24_PROJECT_ID,\n }) as unknown as RemoteClient;\n}\n","export function parseMappings(items: string[]): Record<string, string> {\n return Object.fromEntries(items.map((item) => {\n const separator = item.indexOf(\"=\");\n if (separator <= 0 || separator === item.length - 1) {\n throw new Error(\"--map must use requirement-key=target-id\");\n }\n return [item.slice(0, separator), item.slice(separator + 1)];\n }));\n}\n\nexport function assertImportAllowed(\n preview: Record<string, unknown>,\n options: { allowIncomplete: boolean; yes: boolean; interactive: boolean },\n): void {\n const resources = Array.isArray(preview.resources) ? preview.resources as Array<Record<string, unknown>> : [];\n if (resources.some((item) => item.status === \"incomplete\") && !options.allowIncomplete) {\n throw new Error(\"Import would create incomplete drafts; pass --allow-incomplete to continue\");\n }\n if (!options.yes && !options.interactive) throw new Error(\"Non-interactive import requires --yes\");\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB,sBAAsB;AAE/C,IAAM,iBAAiB,IAAI,OAAO;AAClC,IAAM,mBAAmB,KAAK,OAAO;AACrC,IAAM,WAAW,IAAI,OAAO;AAC5B,IAAM,YAAY;AAClB,IAAM,YAAY;AAElB,IAAM,YAAY,MAAM,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC,GAAG,UAAU;AAC1D,MAAI,QAAQ;AACZ,WAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;AACnC,YAAS,QAAQ,IAAK,aAAc,UAAU,IAAK,UAAU;AAAA,EAC/D;AACA,SAAO,UAAU;AACnB,CAAC;AAED,SAAS,MAAM,OAA2B;AACxC,MAAI,MAAM;AACV,aAAW,QAAQ,MAAO,OAAM,WAAW,MAAM,QAAQ,GAAI,IAAK,QAAQ;AAC1E,UAAQ,MAAM,gBAAgB;AAChC;AAEA,SAAS,SAAS,KAAqB;AACrC,MAAI,CAAC,OAAO,IAAI,WAAW,GAAG,KAAK,IAAI,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,iCAAiC;A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