@agents24/cli 0.3.28 → 0.3.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -12,11 +12,11 @@ import {
12
12
  replacePackageFiles,
13
13
  shouldPromptForDependency,
14
14
  validatePackage
15
- } from "./chunk-Z7P3CO2J.js";
15
+ } from "./chunk-FT7LOHJF.js";
16
16
 
17
17
  // src/cli.ts
18
18
  import { basename as basename2, dirname, join as join3, resolve as resolve3 } from "path";
19
- import { chmod as chmod2, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
19
+ import { chmod as chmod2, readFile as readFile5, writeFile as writeFile4 } from "fs/promises";
20
20
  import { createInterface as createInterface3 } from "readline/promises";
21
21
  import { createHash as createHash3 } from "crypto";
22
22
  import { spawn } from "child_process";
@@ -24,8 +24,8 @@ import { isCancel, password, select, text } from "@clack/prompts";
24
24
  import { parse as parseYaml3 } from "yaml";
25
25
 
26
26
  // src/cli-arguments.ts
27
- var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["json", "remote", "yes", "allow-incomplete", "no-write-env", "prune", "apply", "wait", "replace", "fix-dependencies"]);
28
- var LIFECYCLE_COMMANDS = /* @__PURE__ */ new Set(["prepare", "plan", "apply", "pull", "dev", "publish", "setup", "status", "link", "resources", "fork", "artifact"]);
27
+ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["json", "remote", "yes", "allow-incomplete", "no-write-env", "prune", "apply", "wait", "replace", "fix-dependencies", "batch"]);
28
+ var LIFECYCLE_COMMANDS = /* @__PURE__ */ new Set(["prepare", "plan", "apply", "pull", "dev", "publish", "setup", "status", "link", "resources", "fork", "artifact", "knowledge"]);
29
29
  function parseArguments(argv) {
30
30
  const lifecycle = LIFECYCLE_COMMANDS.has(argv[0]);
31
31
  if (!lifecycle && (argv[0] !== "package" || !argv[1])) {
@@ -141,15 +141,15 @@ function canonicalJson(value) {
141
141
  function isNotFoundResponse(error) {
142
142
  return Boolean(error && typeof error === "object" && "status" in error && Number(error.status) === 404);
143
143
  }
144
- function packageUpload(data, input) {
144
+ function packageUpload(data, input2) {
145
145
  return {
146
146
  data,
147
- filename: basename(input).endsWith(".zip") ? basename(input) : "resource.agents24.zip"
147
+ filename: basename(input2).endsWith(".zip") ? basename(input2) : "resource.agents24.zip"
148
148
  };
149
149
  }
150
- async function packageDirectory(input) {
150
+ async function packageDirectory(input2) {
151
151
  try {
152
- return (await stat(input)).isDirectory() ? resolve(input) : void 0;
152
+ return (await stat(input2)).isDirectory() ? resolve(input2) : void 0;
153
153
  } catch {
154
154
  return void 0;
155
155
  }
@@ -189,8 +189,8 @@ function parseEnv(textValue) {
189
189
  }
190
190
  return result;
191
191
  }
192
- async function requirements(input) {
193
- const files = await loadPackageFiles(input);
192
+ async function requirements(input2) {
193
+ const files = await loadPackageFiles(input2);
194
194
  const manifest = parseYaml(files.get("agents24.yaml") || "");
195
195
  const requires = manifest.requires && typeof manifest.requires === "object" ? manifest.requires : {};
196
196
  const secrets = requires.secrets && typeof requires.secrets === "object" ? requires.secrets : {};
@@ -201,10 +201,10 @@ async function requirements(input) {
201
201
  return { key: `$secrets.${key}`, env, generate: item.generate === true };
202
202
  });
203
203
  }
204
- async function preparePackage(input) {
205
- const directory = await packageDirectory(input);
204
+ async function preparePackage(input2) {
205
+ const directory = await packageDirectory(input2);
206
206
  if (!directory) throw new Error("prepare requires a Resource Package directory");
207
- const local = await validatePackage(input);
207
+ const local = await validatePackage(input2);
208
208
  if (!local.valid) throw Object.assign(new Error("Resource package is invalid"), { diagnostics: local.diagnostics });
209
209
  const target = join2(directory, ".env.local");
210
210
  let current = "";
@@ -217,7 +217,7 @@ async function preparePackage(input) {
217
217
  const generated = [];
218
218
  const preserved = [];
219
219
  let next = current;
220
- for (const requirement of await requirements(input)) {
220
+ for (const requirement of await requirements(input2)) {
221
221
  if (values2[requirement.env] || process.env[requirement.env]) {
222
222
  preserved.push(requirement.env);
223
223
  continue;
@@ -233,8 +233,8 @@ async function preparePackage(input) {
233
233
  await ensureIgnored(directory, [".env.local"]);
234
234
  return { ok: true, package: directory, env_file: target, generated, preserved };
235
235
  }
236
- async function secretValues(input) {
237
- const directory = await packageDirectory(input);
236
+ async function secretValues(input2) {
237
+ const directory = await packageDirectory(input2);
238
238
  let local = {};
239
239
  if (directory) {
240
240
  try {
@@ -244,7 +244,7 @@ async function secretValues(input) {
244
244
  }
245
245
  }
246
246
  const result = {};
247
- for (const requirement of await requirements(input)) {
247
+ for (const requirement of await requirements(input2)) {
248
248
  const value = String(process.env[requirement.env] || local[requirement.env] || "");
249
249
  if (value) result[requirement.key] = value;
250
250
  }
@@ -269,10 +269,10 @@ async function confirmPull(parsed, plan) {
269
269
  if (!/^y(?:es)?$/i.test(answer.trim())) throw new Error("Pull cancelled");
270
270
  }
271
271
  async function pullPackage(options) {
272
- const { parsed, input, client, installationId } = options;
272
+ const { parsed, input: input2, client, installationId } = options;
273
273
  const preview = await client.resourceInstallations.planPull(
274
274
  installationId,
275
- packageUpload(await packPackageSnapshot(input), input)
275
+ packageUpload(await packPackageSnapshot(input2), input2)
276
276
  );
277
277
  const plan = preview.plan && typeof preview.plan === "object" ? preview.plan : {};
278
278
  await confirmPull(parsed, plan);
@@ -280,7 +280,7 @@ async function pullPackage(options) {
280
280
  const payload = await client.resourceInstallations.downloadPull(installationId, pullId);
281
281
  if (payload.platform_snapshot_hash !== preview.platform_snapshot_hash || payload.package_hash !== preview.package_hash || !payload.files || typeof payload.files !== "object" || Array.isArray(payload.files)) throw new Error("Pulled package snapshot does not match its preview");
282
282
  let accepted = {};
283
- await replacePackageFiles(input, payload.files, async () => {
283
+ await replacePackageFiles(input2, payload.files, async () => {
284
284
  accepted = await client.resourceInstallations.acceptPull(
285
285
  installationId,
286
286
  pullId,
@@ -304,12 +304,12 @@ async function pullPackage(options) {
304
304
  }
305
305
 
306
306
  // src/cli-status.ts
307
- async function installedPackageStatus(input, client, status) {
307
+ async function installedPackageStatus(input2, client, status) {
308
308
  const callableBindings = Array.isArray(status.callable_bindings) ? status.callable_bindings : [];
309
309
  const publicationCurrent = status.publication_state === "current";
310
310
  const healthy = callableBindings.filter((item) => item.draft_status === "attached" && (!publicationCurrent || item.published_status === "attached")).length;
311
311
  const compiled = await client.resourcePackages.validatePackage(
312
- packageUpload(await packPackage(input), input)
312
+ packageUpload(await packPackage(input2), input2)
313
313
  );
314
314
  const localPackageHash = typeof compiled.package_hash === "string" ? compiled.package_hash : null;
315
315
  return {
@@ -353,7 +353,7 @@ async function promptImportMappings(client, preview, current, enabled) {
353
353
  kind: String(dependency.kind),
354
354
  query: String(dependency.source_name || ""),
355
355
  modelRequirements: dependency.model_requirements,
356
- requiredCapability: ["chat", "embedding", "speech_to_text", "rerank"].find((kind) => kind === dependency.required_capability)
356
+ requiredCapability: ["chat", "embedding", "speech_to_text", "rerank", "ocr"].find((kind) => kind === dependency.required_capability)
357
357
  });
358
358
  const candidates = Array.isArray(response.items) ? response.items : [];
359
359
  process.stdout.write(`${dependency.source_name || key}: ${candidates.map((item, index) => `${index + 1}) ${item.name}`).join(" ")}
@@ -403,10 +403,10 @@ import { resolve as resolve2 } from "path";
403
403
  import { parse as parseYaml2 } from "yaml";
404
404
  var DEFAULT_API_BASE_URL = "https://api.agents24.dev";
405
405
  var MANIFEST_POLL_INTERVAL_MS = 2e3;
406
- async function developmentArtifacts(input) {
407
- const directory = await packageDirectory(input);
406
+ async function developmentArtifacts(input2) {
407
+ const directory = await packageDirectory(input2);
408
408
  if (!directory) throw new Error("dev requires a Resource Package directory");
409
- const files = await loadPackageFiles(input);
409
+ const files = await loadPackageFiles(input2);
410
410
  const manifest = parseYaml2(files.get("agents24.yaml") || "");
411
411
  const resources = Array.isArray(manifest.resources) ? manifest.resources : [];
412
412
  const requires = manifest.requires && typeof manifest.requires === "object" ? manifest.requires : {};
@@ -576,6 +576,7 @@ async function openDevelopmentRelay(client, installationIdValue, artifact, local
576
576
 
577
577
  // src/cli-help.ts
578
578
  var commands = {
579
+ knowledge: { args: "records <upsert|fetch|list|query|update|delete> | namespaces <list|stats>", summary: "Access raw records in a connected Knowledge Store.", flags: "--store <id> --input <json-file|-> --batch --limit <1-100> --cursor <token>", example: "agents24 knowledge records fetch --store <id> --input request.json --json" },
579
580
  prepare: { args: "<directory>", summary: "Validate package identity and prepare local secrets.", flags: "", example: "agents24 prepare ./agents24" },
580
581
  plan: { args: "<directory|archive.zip>", summary: "Plan the complete operation without changing resources. Resolve blockers before apply.", flags: "--integration <publish-only|bff|client-deployment> --agent <stable-key> --prune", example: "agents24 plan ./agents24 --integration bff --agent assistant --json" },
581
582
  apply: { args: "<directory|archive.zip>", summary: "Plan and apply resource drafts. Existing primary Agent selections are fixed.", flags: "--integration <publish-only|bff|client-deployment> --agent <stable-key> --prune --yes", example: "agents24 apply ./agents24 --yes" },
@@ -584,7 +585,7 @@ var commands = {
584
585
  status: { args: "<directory>", summary: "Inspect installation, validation, and publication status.", flags: "", example: "agents24 status ./agents24 --json" },
585
586
  pull: { args: "<directory>", summary: "Review and pull portable platform changes into the local package.", flags: "--yes", example: "agents24 pull ./agents24" },
586
587
  link: { args: "<directory>", summary: "Link an external requirement by its stable key in an installation.", flags: "--resource <stable-key=resource-id> (repeatable)", example: "agents24 link ./agents24 --resource '$tools.search=<tool-id>'" },
587
- resources: { args: "", summary: "List candidate resources for external requirements.", flags: "--kind <kind> --query <text> --limit <number>", example: "agents24 resources --kind tool --query Search --json" },
588
+ resources: { args: "list", summary: "List candidate resources for external requirements.", flags: "--kind <kind> --query <text> --limit <number> --capability <chat|embedding|speech_to_text|rerank|ocr>", example: "agents24 resources list --kind tool --query Search --json" },
588
589
  dev: { args: "<directory>", summary: "Run the local Remote Artifact development relay.", flags: "--artifact <stable-key> --apply --yes", example: "agents24 dev ./agents24 --artifact workspace --apply" },
589
590
  artifact: { args: "<init|pull|status|diff|push|build|test> [directory]", summary: "Author and test Hosted Artifact source; execution stays on Agents24.", flags: "--language <python|javascript> --artifact <key> --id <existing-artifact-id> --into <directory> --bind <key>:<credential-id> --replace --fix-dependencies --export <name> --input <file|-> --config <json-file> --target <draft|published> --wait", example: "agents24 artifact pull --id <artifact-id> --into ./artifact" },
590
591
  fork: { args: "<source> <target>", summary: "Copy a package with a new installation identity.", flags: "--name <name>", example: "agents24 fork ./agents24 ./copy --name copy" },
@@ -704,8 +705,8 @@ function portableDraft(remote) {
704
705
  });
705
706
  return { draft: { ...raw, source_files: source }, bindings };
706
707
  }
707
- async function localArtifact(input, selected) {
708
- const root = path.resolve(input);
708
+ async function localArtifact(input2, selected) {
709
+ const root = path.resolve(input2);
709
710
  const files = await loadPackageFiles(root);
710
711
  const manifest = object(parse(files.get("agents24.yaml") || ""));
711
712
  const declarations = Array.isArray(manifest.resources) ? manifest.resources.map(object) : [];
@@ -798,9 +799,9 @@ async function resolvedId(client, local) {
798
799
  return (await stateFile(local.root))[local.key]?.artifact_id || await installationArtifact(client, local);
799
800
  }
800
801
  async function hostedArtifactCommand(parsed, client) {
801
- const [action, input = "."] = parsed.positionals;
802
+ const [action, input2 = "."] = parsed.positionals;
802
803
  if (action === "init") {
803
- const directory = path.resolve(input);
804
+ const directory = path.resolve(input2);
804
805
  const local2 = await writeNewPackage(directory, flag(parsed, "name") || path.basename(directory), void 0, flag(parsed, "language"));
805
806
  return { ok: true, directory, package_id: local2.manifest.package_id, artifact_key: local2.key };
806
807
  }
@@ -810,13 +811,13 @@ async function hostedArtifactCommand(parsed, client) {
810
811
  const artifact = await client.hostedArtifacts.get(id2);
811
812
  const draft = await remoteDraft(client, id2);
812
813
  const portable2 = portableDraft(draft);
813
- const root = path.resolve(flag(parsed, "into") || input);
814
+ const root = path.resolve(flag(parsed, "into") || input2);
814
815
  const local2 = await writeNewPackage(root, String(artifact.display_name || "Artifact"), portable2.draft);
815
816
  await bindPackage(client, local2, id2);
816
817
  await saveState(root, local2.key, { artifact_id: id2, draft_version: Number(draft.draft_version), draft_hash: String(draft.draft_hash), local_hash: hash(comparable(snapshot(local2, portable2.bindings))), credential_bindings: portable2.bindings });
817
818
  return { ok: true, directory: root, artifact_id: id2, artifact_key: local2.key, draft_version: draft.draft_version, credential_refs: draft.credential_refs };
818
819
  }
819
- let local = await localArtifact(input, flag(parsed, "artifact"));
820
+ let local = await localArtifact(input2, flag(parsed, "artifact"));
820
821
  const id = await resolvedId(client, local);
821
822
  if (!id && action !== "push") throw new Error("This Hosted Artifact is not linked; run agents24 artifact push first");
822
823
  if (action === "push") {
@@ -959,6 +960,49 @@ async function hostedArtifactCommand(parsed, client) {
959
960
  throw new Error("Usage: agents24 artifact <init|pull|status|diff|push|build|test>");
960
961
  }
961
962
 
963
+ // src/cli-knowledge.ts
964
+ import { readFile as readFile4 } from "fs/promises";
965
+ async function input(parsed) {
966
+ const path2 = flag(parsed, "input");
967
+ if (!path2) throw new Error("Record operations require --input <json-file|->");
968
+ let data = "";
969
+ if (path2 === "-") {
970
+ for await (const chunk of process.stdin) data += chunk.toString();
971
+ } else data = await readFile4(path2, "utf8");
972
+ const payload = JSON.parse(data);
973
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) throw new Error("Input must be a JSON object");
974
+ return payload;
975
+ }
976
+ async function knowledgeCommand(parsed) {
977
+ const [surface, operation] = parsed.positionals;
978
+ const storeId = flag(parsed, "store");
979
+ if (!storeId) throw new Error("Knowledge commands require --store <knowledge-store-id>");
980
+ const recordMethods = {
981
+ upsert: "upsertRecords",
982
+ fetch: "fetchRecords",
983
+ list: "listRecords",
984
+ query: "queryRecords",
985
+ update: "updateRecord",
986
+ delete: "deleteRecords"
987
+ };
988
+ const api = (await createRemoteClient()).knowledgeStores;
989
+ let result;
990
+ if (surface === "records" && Object.hasOwn(recordMethods, operation)) {
991
+ const request = await input(parsed);
992
+ const method = recordMethods[operation];
993
+ result = operation === "upsert" && flag(parsed, "batch") === "true" ? await api.upsertRecordsBatched(storeId, request) : await api[method](storeId, request);
994
+ } else if (surface === "namespaces" && operation === "list") {
995
+ const limit = Number(flag(parsed, "limit") ?? 100);
996
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw new Error("Limit must be between 1 and 100");
997
+ result = await api.listNamespaces(storeId, { limit, ...flag(parsed, "cursor") ? { cursor: flag(parsed, "cursor") } : {} });
998
+ } else if (surface === "namespaces" && operation === "stats") {
999
+ result = await api.namespaceStats(storeId, await input(parsed));
1000
+ } else throw new Error("Usage: agents24 knowledge records <upsert|fetch|list|query|update|delete> | knowledge namespaces <list|stats>");
1001
+ const failed = Array.isArray(result.failed_ids) && result.failed_ids.length > 0;
1002
+ const unknown = Array.isArray(result.unknown_ids) && result.unknown_ids.length > 0;
1003
+ return { ok: !failed && !unknown, ...result };
1004
+ }
1005
+
962
1006
  // src/cli.ts
963
1007
  var DEFAULT_API_BASE_URL2 = "https://api.agents24.dev";
964
1008
  var DEFAULT_LOCAL_CLIENT_ORIGINS = ["http://localhost:5173", "http://127.0.0.1:5173"];
@@ -999,12 +1043,12 @@ async function pollOperation(client, operation) {
999
1043
  throw new Error("Resource apply did not finish within 15 minutes");
1000
1044
  }
1001
1045
  async function packedValidatedPackage(parsed) {
1002
- const input = parsed.positionals[0];
1003
- if (!input) throw new Error(`${parsed.command} requires a package directory or ZIP`);
1004
- const local = await validatePackage(input);
1046
+ const input2 = parsed.positionals[0];
1047
+ if (!input2) throw new Error(`${parsed.command} requires a package directory or ZIP`);
1048
+ const local = await validatePackage(input2);
1005
1049
  if (!local.valid) throw Object.assign(new Error("Resource package is invalid"), { diagnostics: local.diagnostics });
1006
- const data = await packPackage(input);
1007
- return { data, filename: `${basename2(resolve3(input))}.agents24.zip` };
1050
+ const data = await packPackage(input2);
1051
+ return { data, filename: `${basename2(resolve3(input2))}.agents24.zip` };
1008
1052
  }
1009
1053
  function importKey(packageHash, map) {
1010
1054
  return `import-${createHash3("sha256").update(canonicalJson({ package_hash: packageHash, mappings: map })).digest("hex").slice(0, 40)}`;
@@ -1028,13 +1072,13 @@ async function apiKeyForLifecycle(parsed) {
1028
1072
  registerSensitiveValue(apiKey);
1029
1073
  return apiKey;
1030
1074
  }
1031
- async function loadPackageLifecycleEnvironment(input) {
1032
- if (!input) return;
1033
- const directory = await packageDirectory(input);
1075
+ async function loadPackageLifecycleEnvironment(input2) {
1076
+ if (!input2) return;
1077
+ const directory = await packageDirectory(input2);
1034
1078
  if (!directory) return;
1035
1079
  for (const path2 of [join3(dirname(directory), ".env.local"), join3(directory, ".env.local")]) {
1036
1080
  try {
1037
- const values2 = parseEnv(await readFile4(path2, "utf8"));
1081
+ const values2 = parseEnv(await readFile5(path2, "utf8"));
1038
1082
  for (const [name, value] of Object.entries(values2)) {
1039
1083
  if (!process.env[name]) process.env[name] = value;
1040
1084
  }
@@ -1070,7 +1114,7 @@ function clientAppBaseUrl(environment = process.env) {
1070
1114
  async function appInfoAt(directory, explicit) {
1071
1115
  const target = resolve3(directory);
1072
1116
  try {
1073
- const manifest = JSON.parse(await readFile4(join3(target, "package.json"), "utf8"));
1117
+ const manifest = JSON.parse(await readFile5(join3(target, "package.json"), "utf8"));
1074
1118
  const metadata = manifest.agents24 && typeof manifest.agents24 === "object" ? manifest.agents24 : {};
1075
1119
  const integration = String(metadata.integration || "");
1076
1120
  if (integration !== "client-deployment" && integration !== "bff") {
@@ -1139,7 +1183,7 @@ async function updateEnvFile(app, values2) {
1139
1183
  const target = join3(app.directory, ".env.local");
1140
1184
  let content = "";
1141
1185
  try {
1142
- content = await readFile4(target, "utf8");
1186
+ content = await readFile5(target, "utf8");
1143
1187
  } catch (error) {
1144
1188
  if (error.code !== "ENOENT") throw error;
1145
1189
  }
@@ -1176,8 +1220,8 @@ function bffApplicationValues(applied) {
1176
1220
  AGENTS24_AGENTS: { value: JSON.stringify([{ agentAlias }]), literal: true }
1177
1221
  };
1178
1222
  }
1179
- async function packageIdentity(input, requireValid = true) {
1180
- const result = await validatePackage(input);
1223
+ async function packageIdentity(input2, requireValid = true) {
1224
+ const result = await validatePackage(input2);
1181
1225
  const packageId = String(result.package.package_id || "");
1182
1226
  if (!/^pkg_[0-9a-f]{32}$/.test(packageId)) {
1183
1227
  throw new Error("Resource Package is missing a valid package_id; create an independent package with agents24 fork <source> <target>");
@@ -1185,8 +1229,8 @@ async function packageIdentity(input, requireValid = true) {
1185
1229
  if (requireValid && !result.valid) throw Object.assign(new Error("Resource package is invalid"), { diagnostics: result.diagnostics });
1186
1230
  return { packageId, packageName: String(result.package.name || "") };
1187
1231
  }
1188
- async function resolveInstallation(input, client, requireValid = true) {
1189
- const { packageId } = await packageIdentity(input, requireValid);
1232
+ async function resolveInstallation(input2, client, requireValid = true) {
1233
+ const { packageId } = await packageIdentity(input2, requireValid);
1190
1234
  return client.resourceInstallations.getByPackageId(packageId);
1191
1235
  }
1192
1236
  function blockedPlanMessage(plan) {
@@ -1200,9 +1244,9 @@ function blockedPlanMessage(plan) {
1200
1244
  });
1201
1245
  return `The Resource Package plan is blocked: ${details.join("; ")}`;
1202
1246
  }
1203
- async function ensureInstallation(input, client, data, plan) {
1204
- const identity = await packageIdentity(input);
1205
- const initial = plan || await client.resourceInstallations.plan(packageUpload(data, input));
1247
+ async function ensureInstallation(input2, client, data, plan) {
1248
+ const identity = await packageIdentity(input2);
1249
+ const initial = plan || await client.resourceInstallations.plan(packageUpload(data, input2));
1206
1250
  if (initial.installation_id) return String(initial.installation_id);
1207
1251
  const created = await client.resourceInstallations.create(
1208
1252
  { package_id: identity.packageId, package_name: String(initial.package_name), operation_id: String(initial.operation_id) },
@@ -1211,14 +1255,14 @@ async function ensureInstallation(input, client, data, plan) {
1211
1255
  return String(created.id);
1212
1256
  }
1213
1257
  async function applyDraft(parsed, options = {}) {
1214
- const input = parsed.positionals[0];
1215
- if (!input) throw new Error(`${parsed.command} requires a Resource Package directory or ZIP`);
1216
- await packageIdentity(input);
1258
+ const input2 = parsed.positionals[0];
1259
+ if (!input2) throw new Error(`${parsed.command} requires a Resource Package directory or ZIP`);
1260
+ await packageIdentity(input2);
1217
1261
  const apiKey = options.apiKey || await apiKeyForLifecycle(parsed);
1218
1262
  const client = options.client || await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1219
- const data = await packPackage(input);
1263
+ const data = await packPackage(input2);
1220
1264
  const planInput = {
1221
- ...packageUpload(data, input),
1265
+ ...packageUpload(data, input2),
1222
1266
  prune: flag(parsed, "prune") === "true",
1223
1267
  integrationMode: options.integrationMode || flag(parsed, "integration"),
1224
1268
  primaryResourceKey: flag(parsed, "agent")
@@ -1236,7 +1280,7 @@ async function applyDraft(parsed, options = {}) {
1236
1280
  const requirements2 = Array.isArray(plan.external_requirements) ? plan.external_requirements : [];
1237
1281
  const requiresLink = requirements2.some((item) => item.required === true && item.configured !== true && !["model", "secret"].includes(String(item.kind)));
1238
1282
  if (requiresLink) {
1239
- const installationId = await ensureInstallation(input, client, data, plan);
1283
+ const installationId = await ensureInstallation(input2, client, data, plan);
1240
1284
  if (await promptInstallationRequirementLinks(client, installationId, plan, true)) {
1241
1285
  plan = await client.resourceInstallations.plan(planInput);
1242
1286
  }
@@ -1244,7 +1288,7 @@ async function applyDraft(parsed, options = {}) {
1244
1288
  }
1245
1289
  if (plan.can_apply !== true) throw Object.assign(new Error(blockedPlanMessage(plan)), { plan });
1246
1290
  if (!options.skipConfirmation) await applyConfirmation(parsed, plan);
1247
- const secrets = await secretValues(input);
1291
+ const secrets = await secretValues(input2);
1248
1292
  let operation = await client.resourceInstallations.apply(String(plan.operation_id), {
1249
1293
  secrets
1250
1294
  }, { idempotencyKey: `apply-${String(plan.operation_id)}` });
@@ -1262,25 +1306,26 @@ async function applyDraft(parsed, options = {}) {
1262
1306
  const agentId = String(result.primary_agent_id || "");
1263
1307
  const resources = Array.isArray(result.resources) ? result.resources : [];
1264
1308
  const agent = resources.find((item) => String(item.id) === agentId) || { id: agentId, name: "Agent" };
1265
- return { client, apiKey, input, installationId: installationIdValue, plan, operation, result, agent };
1309
+ return { client, apiKey, input: input2, installationId: installationIdValue, plan, operation, result, agent };
1266
1310
  }
1267
1311
  async function publishDraft(parsed, applied) {
1268
- const input = applied?.input || parsed.positionals[0];
1269
- if (!input) throw new Error("publish requires a Resource Package directory or ZIP");
1270
- await packageIdentity(input);
1312
+ const input2 = applied?.input || parsed.positionals[0];
1313
+ if (!input2) throw new Error("publish requires a Resource Package directory or ZIP");
1314
+ await packageIdentity(input2);
1271
1315
  const apiKey = applied?.apiKey || await apiKeyForLifecycle(parsed);
1272
1316
  const client = applied?.client || await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1273
- const installed = applied ? void 0 : await resolveInstallation(input, client);
1317
+ const installed = applied ? void 0 : await resolveInstallation(input2, client);
1274
1318
  const id = applied?.installationId || String(installed?.id || "");
1275
1319
  if (!id) throw new Error("No installation exists for this package_id; run agents24 apply first");
1276
- const data = await packPackage(input);
1277
- const plan = applied?.plan || await client.resourceInstallations.plan(packageUpload(data, input));
1320
+ const data = await packPackage(input2);
1321
+ const plan = applied?.plan || await client.resourceInstallations.plan(packageUpload(data, input2));
1278
1322
  const publication = await client.resourceInstallations.publish(id, { package_hash: String(plan.package_hash) }, {
1279
1323
  idempotencyKey: `publish-${String(plan.package_hash).slice(0, 40)}`
1280
1324
  });
1281
1325
  return { publication, installationId: id };
1282
1326
  }
1283
1327
  async function execute(parsed) {
1328
+ if (parsed.command === "knowledge") return knowledgeCommand(parsed);
1284
1329
  if (parsed.command === "artifact") {
1285
1330
  if (parsed.positionals[0] === "init") return hostedArtifactCommand(parsed);
1286
1331
  const apiKey = await apiKeyForLifecycle({ ...parsed, positionals: parsed.positionals.slice(1) });
@@ -1294,20 +1339,20 @@ async function execute(parsed) {
1294
1339
  return { ok: true, directory: resolve3(target), package: result.name, package_id: result.packageId };
1295
1340
  }
1296
1341
  if (parsed.command === "prepare") {
1297
- const input = parsed.positionals[0];
1298
- if (!input) throw new Error("prepare requires a Resource Package directory");
1299
- await packageIdentity(input);
1300
- return preparePackage(input);
1342
+ const input2 = parsed.positionals[0];
1343
+ if (!input2) throw new Error("prepare requires a Resource Package directory");
1344
+ await packageIdentity(input2);
1345
+ return preparePackage(input2);
1301
1346
  }
1302
1347
  if (parsed.command === "plan") {
1303
- const input = parsed.positionals[0];
1304
- if (!input) throw new Error("plan requires a Resource Package directory or ZIP");
1305
- await packageIdentity(input);
1348
+ const input2 = parsed.positionals[0];
1349
+ if (!input2) throw new Error("plan requires a Resource Package directory or ZIP");
1350
+ await packageIdentity(input2);
1306
1351
  const apiKey = await apiKeyForLifecycle(parsed);
1307
1352
  const client = await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1308
- const data = await packPackage(input);
1353
+ const data = await packPackage(input2);
1309
1354
  const plan = await client.resourceInstallations.plan({
1310
- ...packageUpload(data, input),
1355
+ ...packageUpload(data, input2),
1311
1356
  prune: flag(parsed, "prune") === "true",
1312
1357
  integrationMode: flag(parsed, "integration"),
1313
1358
  primaryResourceKey: flag(parsed, "agent")
@@ -1315,22 +1360,22 @@ async function execute(parsed) {
1315
1360
  return { ok: plan.can_apply === true, plan };
1316
1361
  }
1317
1362
  if (parsed.command === "pull") {
1318
- const input = parsed.positionals[0];
1319
- if (!input) throw new Error("pull requires a Resource Package directory");
1363
+ const input2 = parsed.positionals[0];
1364
+ if (!input2) throw new Error("pull requires a Resource Package directory");
1320
1365
  const apiKey = await apiKeyForLifecycle(parsed);
1321
1366
  const client = await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1322
- const installation = await resolveInstallation(input, client, false);
1323
- return pullPackage({ parsed, input, client, installationId: String(installation.id || "") });
1367
+ const installation = await resolveInstallation(input2, client, false);
1368
+ return pullPackage({ parsed, input: input2, client, installationId: String(installation.id || "") });
1324
1369
  }
1325
1370
  if (parsed.command === "status") {
1326
- const input = parsed.positionals[0];
1327
- if (!input) throw new Error("status requires a Resource Package directory or ZIP");
1328
- const identity = await packageIdentity(input);
1371
+ const input2 = parsed.positionals[0];
1372
+ if (!input2) throw new Error("status requires a Resource Package directory or ZIP");
1373
+ const identity = await packageIdentity(input2);
1329
1374
  const apiKey = await apiKeyForLifecycle(parsed);
1330
1375
  const client = await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1331
1376
  let status;
1332
1377
  try {
1333
- status = await resolveInstallation(input, client);
1378
+ status = await resolveInstallation(input2, client);
1334
1379
  } catch (error) {
1335
1380
  if (!isNotFoundResponse(error)) throw error;
1336
1381
  return {
@@ -1340,30 +1385,31 @@ async function execute(parsed) {
1340
1385
  message: "This package has not been applied to this organization. Run agents24 apply <package-directory> to create its resources."
1341
1386
  };
1342
1387
  }
1343
- return installedPackageStatus(input, client, status);
1388
+ return installedPackageStatus(input2, client, status);
1344
1389
  }
1345
1390
  if (parsed.command === "resources") {
1346
1391
  if (parsed.positionals[0] !== "list") throw new Error("Usage: agents24 resources list --kind <kind>");
1347
1392
  const kind = flag(parsed, "kind");
1348
1393
  if (!kind) throw new Error("resources list requires --kind");
1349
1394
  const apiKey = await apiKeyForLifecycle(parsed);
1350
- const result = await (await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey })).resourceInstallations.resources({
1351
- kind,
1352
- query: flag(parsed, "query"),
1353
- limit: Number(flag(parsed, "limit") || 100)
1354
- });
1395
+ const client = await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1396
+ const capability = flag(parsed, "capability");
1397
+ const supported = ["chat", "embedding", "speech_to_text", "rerank", "ocr"];
1398
+ const requiredCapability = supported.find((value) => value === capability);
1399
+ if (capability && (kind !== "model" || !requiredCapability)) throw new Error("--capability requires kind model and a supported model capability");
1400
+ const result = requiredCapability ? await client.resourcePackages.candidates({ kind, query: flag(parsed, "query"), requiredCapability, limit: Number(flag(parsed, "limit") || 100) }) : await client.resourceInstallations.resources({ kind, query: flag(parsed, "query"), limit: Number(flag(parsed, "limit") || 100) });
1355
1401
  return { ok: true, ...result };
1356
1402
  }
1357
1403
  if (parsed.command === "link") {
1358
- const input = parsed.positionals[0];
1359
- if (!input) throw new Error("link requires a Resource Package directory or ZIP");
1404
+ const input2 = parsed.positionals[0];
1405
+ if (!input2) throw new Error("link requires a Resource Package directory or ZIP");
1360
1406
  const assignments = values(parsed, "resource");
1361
1407
  if (!assignments.length) throw new Error("link requires --resource <stable-key>=<uuid>");
1362
- await packageIdentity(input);
1408
+ await packageIdentity(input2);
1363
1409
  const apiKey = await apiKeyForLifecycle(parsed);
1364
1410
  const client = await createRemoteClient({ ...process.env, AGENTS24_API_KEY: apiKey });
1365
- const data = await packPackage(input);
1366
- const id = await ensureInstallation(input, client, data);
1411
+ const data = await packPackage(input2);
1412
+ const id = await ensureInstallation(input2, client, data);
1367
1413
  const linked = [];
1368
1414
  for (const assignment of assignments) {
1369
1415
  const separator = assignment.indexOf("=");
@@ -1442,11 +1488,11 @@ async function execute(parsed) {
1442
1488
  };
1443
1489
  }
1444
1490
  if (parsed.command === "dev") {
1445
- const input = parsed.positionals[0];
1446
- if (!input) throw new Error("dev requires a Resource Package directory");
1447
- await packageIdentity(input);
1448
- await preparePackage(input);
1449
- const declared = await developmentArtifacts(input);
1491
+ const input2 = parsed.positionals[0];
1492
+ if (!input2) throw new Error("dev requires a Resource Package directory");
1493
+ await packageIdentity(input2);
1494
+ await preparePackage(input2);
1495
+ const declared = await developmentArtifacts(input2);
1450
1496
  const selectedKey = flag(parsed, "artifact");
1451
1497
  const artifacts = selectedKey ? declared.filter((item) => item.key === selectedKey) : declared;
1452
1498
  if (!artifacts.length) throw new Error(selectedKey ? `Artifact ${selectedKey} has no development configuration` : "No self-hosted Artifact development configuration was found");
@@ -1456,17 +1502,17 @@ async function execute(parsed) {
1456
1502
  let id = applied?.installationId;
1457
1503
  if (!id) {
1458
1504
  try {
1459
- id = String((await resolveInstallation(input, client)).id || "");
1505
+ id = String((await resolveInstallation(input2, client)).id || "");
1460
1506
  } catch (error) {
1461
1507
  if (!isNotFoundResponse(error)) throw error;
1462
1508
  throw new Error("Apply the package before starting Artifact development");
1463
1509
  }
1464
1510
  }
1465
1511
  if (!id) throw new Error("Apply the package before starting Artifact development");
1466
- const configuredSecrets = await secretValues(input);
1512
+ const configuredSecrets = await secretValues(input2);
1467
1513
  if (Object.keys(configuredSecrets).length) await client.resourceInstallations.configureSecrets(id, { secrets: configuredSecrets });
1468
- const directory = await packageDirectory(input);
1469
- const localEnv = directory ? parseEnv(await readFile4(join3(directory, ".env.local"), "utf8")) : {};
1514
+ const directory = await packageDirectory(input2);
1515
+ const localEnv = directory ? parseEnv(await readFile5(join3(directory, ".env.local"), "utf8")) : {};
1470
1516
  const children = [];
1471
1517
  const relays = [];
1472
1518
  try {
@@ -1526,15 +1572,15 @@ async function execute(parsed) {
1526
1572
  return { ok: true, directory, package: packageName };
1527
1573
  }
1528
1574
  if (parsed.command === "validate") {
1529
- const input = parsed.positionals[0];
1530
- if (!input) throw new Error("validate requires a package directory or ZIP");
1531
- const local = await validatePackage(input);
1575
+ const input2 = parsed.positionals[0];
1576
+ if (!input2) throw new Error("validate requires a package directory or ZIP");
1577
+ const local = await validatePackage(input2);
1532
1578
  let remote;
1533
1579
  const hostedDependencyDiagnostics = [];
1534
1580
  if (flag(parsed, "remote") === "true" && local.valid) {
1535
1581
  const client = await createRemoteClient();
1536
- const data = await packPackage(input);
1537
- remote = await client.resourcePackages.validatePackage(packageUpload(data, input));
1582
+ const data = await packPackage(input2);
1583
+ remote = await client.resourcePackages.validatePackage(packageUpload(data, input2));
1538
1584
  const manifest = parseYaml3(String(local.files.get("agents24.yaml") || ""));
1539
1585
  for (const declaration of Array.isArray(manifest.resources) ? manifest.resources : []) {
1540
1586
  const artifactPath = String(declaration.path || "");
@@ -1553,10 +1599,10 @@ async function execute(parsed) {
1553
1599
  return { ok: local.valid && (!remote || remote.valid === true) && hostedDependencyDiagnostics.length === 0, local: { ...local, files: void 0 }, ...remote ? { remote } : {}, ...flag(parsed, "remote") === "true" ? { hosted_dependency_diagnostics: hostedDependencyDiagnostics } : {} };
1554
1600
  }
1555
1601
  if (parsed.command === "pack") {
1556
- const input = parsed.positionals[0];
1557
- if (!input) throw new Error("pack requires a package directory");
1558
- const data = await packPackage(input);
1559
- const output = resolve3(flag(parsed, "output") || `${basename2(resolve3(input))}.agents24.zip`);
1602
+ const input2 = parsed.positionals[0];
1603
+ if (!input2) throw new Error("pack requires a package directory");
1604
+ const data = await packPackage(input2);
1605
+ const output = resolve3(flag(parsed, "output") || `${basename2(resolve3(input2))}.agents24.zip`);
1560
1606
  await writeFile4(output, data);
1561
1607
  return { ok: true, output, bytes: data.byteLength };
1562
1608
  }