@pmate/cli 0.20.8 → 0.20.9

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19429,14 +19429,13 @@ var AgentCommandHandler = class {
19429
19429
  return;
19430
19430
  }
19431
19431
  case "list": {
19432
- const search = args.namespace ? `?namespace=${encodeURIComponent(args.namespace)}` : "";
19433
- const response = await this.request(
19432
+ const items = args.namespace ? (await this.request(
19434
19433
  baseUrl,
19435
19434
  token,
19436
19435
  "GET",
19437
- `/agents${search}`
19438
- );
19439
- this.renderList(response.items, args.json);
19436
+ `/agents?namespace=${encodeURIComponent(args.namespace)}`
19437
+ )).items : await this.listAgentsAcrossNamespaces(baseUrl, token);
19438
+ this.renderList(items, args.json);
19440
19439
  return;
19441
19440
  }
19442
19441
  case "get":
@@ -19568,6 +19567,35 @@ var AgentCommandHandler = class {
19568
19567
  }
19569
19568
  return payload.data;
19570
19569
  }
19570
+ async listAgentsAcrossNamespaces(baseUrl, token) {
19571
+ const namespacesResponse = await this.request(
19572
+ baseUrl,
19573
+ token,
19574
+ "GET",
19575
+ "/agents/namespaces"
19576
+ );
19577
+ const namespaces = namespacesResponse.items.map((item) => item.namespace?.trim()).filter((value) => Boolean(value));
19578
+ if (namespaces.length === 0) {
19579
+ return [];
19580
+ }
19581
+ const listResponses = await Promise.all(
19582
+ namespaces.map(async (namespace) => {
19583
+ const response = await this.request(
19584
+ baseUrl,
19585
+ token,
19586
+ "GET",
19587
+ `/agents?namespace=${encodeURIComponent(namespace)}`
19588
+ );
19589
+ return response.items;
19590
+ })
19591
+ );
19592
+ const merged = listResponses.flat();
19593
+ const deduped = /* @__PURE__ */ new Map();
19594
+ for (const item of merged) {
19595
+ deduped.set(item.id, item);
19596
+ }
19597
+ return Array.from(deduped.values());
19598
+ }
19571
19599
  renderList(items, asJson) {
19572
19600
  if (asJson) {
19573
19601
  ui.plain(JSON.stringify(items, null, 2));
@@ -22787,7 +22815,7 @@ var HELP_TEXT = [
22787
22815
  ` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
22788
22816
  ` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
22789
22817
  ` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
22790
- ` ${import_chalk4.default.gray(" default namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
22818
+ ` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
22791
22819
  ` ${import_chalk4.default.cyan("ns")} Manage registered namespaces`,
22792
22820
  ` ${import_chalk4.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
22793
22821
  ` ${import_chalk4.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.20.8",
3
+ "version": "0.20.9",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {