@pmate/cli 0.21.16 → 0.21.18

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/index.d.ts CHANGED
@@ -672,6 +672,7 @@ type AppCommandArgs = {
672
672
  type: Command.App;
673
673
  action: "list";
674
674
  namespace?: string;
675
+ all: boolean;
675
676
  baseUrl?: string;
676
677
  json: boolean;
677
678
  } | {
package/dist/index.js CHANGED
@@ -278,7 +278,7 @@ var init_sessionStore = __esm({
278
278
  import_node_os2 = __toESM(require("os"));
279
279
  import_node_path3 = __toESM(require("path"));
280
280
  init_namespacedRef();
281
- DEFAULT_APP_ID = "pmate:cli";
281
+ DEFAULT_APP_ID = "pmate:factory";
282
282
  SESSION_STORE_VERSION = 3;
283
283
  }
284
284
  });
@@ -17254,33 +17254,19 @@ var IOS_ICON_SPECS = [
17254
17254
  var pngToIco = require("png-to-ico").default;
17255
17255
  function normalizeAppIcon(icon, cwd) {
17256
17256
  if (typeof icon !== "string" || !icon.trim()) {
17257
- throw new Error("App icon must be a non-empty SVG string or .svg file path.");
17257
+ throw new Error("App icon must be a non-empty http(s) URL.");
17258
17258
  }
17259
17259
  const trimmed = icon.trim();
17260
17260
  if (looksLikeSvgMarkup(trimmed)) {
17261
- return trimmed;
17261
+ throw new Error("App icon cannot be inline SVG. Upload the SVG to OSS first and use its http(s) URL.");
17262
17262
  }
17263
17263
  if (trimmed.startsWith("data:")) {
17264
- return normalizeSvgDataUrl(trimmed);
17264
+ throw new Error("App icon cannot be a data URL. Upload the SVG to OSS first and use its http(s) URL.");
17265
17265
  }
17266
17266
  if (/^https?:\/\//i.test(trimmed)) {
17267
- throw new Error("App icon must be SVG source, not a remote URL.");
17268
- }
17269
- const absolutePath = import_node_path20.default.resolve(cwd, trimmed);
17270
- if (!(0, import_node_fs15.existsSync)(absolutePath)) {
17271
- if (trimmed.toLowerCase().endsWith(".svg")) {
17272
- throw new Error(`App icon SVG file not found: ${absolutePath}`);
17273
- }
17274
- throw new Error("App icon must be inline SVG, an SVG data URL, or a .svg file path.");
17275
- }
17276
- if (import_node_path20.default.extname(absolutePath).toLowerCase() !== ".svg") {
17277
- throw new Error(`App icon file must use the .svg extension: ${absolutePath}`);
17278
- }
17279
- const svg = (0, import_node_fs15.readFileSync)(absolutePath, "utf8").trim();
17280
- if (!looksLikeSvgMarkup(svg)) {
17281
- throw new Error(`App icon file is not valid SVG: ${absolutePath}`);
17267
+ return trimmed;
17282
17268
  }
17283
- return svg;
17269
+ throw new Error("App icon must be an http(s) URL. Upload SVG files to OSS first and use the public link.");
17284
17270
  }
17285
17271
  function prepareAppPayload(payload, cwd) {
17286
17272
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
@@ -17331,12 +17317,35 @@ function createAppIconExportPlans(input) {
17331
17317
  }
17332
17318
  ];
17333
17319
  }
17334
- async function exportAppIcon(svg, plans) {
17320
+ async function exportAppIcon(icon, plans) {
17321
+ const svg = await resolveAppIconSvg(icon);
17335
17322
  for (const plan of plans) {
17336
17323
  const bytes = await renderAppIcon(svg, plan.width, plan.height, plan.format);
17337
17324
  (0, import_node_fs15.writeFileSync)(plan.outputPath, bytes);
17338
17325
  }
17339
17326
  }
17327
+ async function resolveAppIconSvg(icon) {
17328
+ const trimmed = icon.trim();
17329
+ if (looksLikeSvgMarkup(trimmed)) {
17330
+ return trimmed;
17331
+ }
17332
+ if (!/^https?:\/\//i.test(trimmed)) {
17333
+ throw new Error("App icon export requires inline SVG or an http(s) SVG URL.");
17334
+ }
17335
+ const response = await fetch(trimmed);
17336
+ if (!response.ok) {
17337
+ throw new Error(`Failed to fetch app icon SVG: ${response.status} ${response.statusText}`.trim());
17338
+ }
17339
+ const contentType = response.headers.get("content-type")?.toLowerCase() || "";
17340
+ const svg = (await response.text()).trim();
17341
+ if (contentType && !contentType.includes("image/svg+xml") && !looksLikeSvgMarkup(svg)) {
17342
+ throw new Error(`App icon URL must return SVG content. Received: ${contentType}`);
17343
+ }
17344
+ if (!looksLikeSvgMarkup(svg)) {
17345
+ throw new Error("App icon URL does not contain valid SVG markup.");
17346
+ }
17347
+ return svg;
17348
+ }
17340
17349
  async function renderAppIcon(svg, width, height, format) {
17341
17350
  if (format === "svg") {
17342
17351
  return Buffer.from(svg);
@@ -17357,23 +17366,6 @@ async function renderAppIcon(svg, width, height, format) {
17357
17366
  function looksLikeSvgMarkup(value) {
17358
17367
  return /<svg[\s>]/i.test(value);
17359
17368
  }
17360
- function normalizeSvgDataUrl(value) {
17361
- const match = /^data:([^;,]+)?(?:;charset=[^;,]+)?(?:;(base64))?,(.*)$/i.exec(value);
17362
- if (!match) {
17363
- throw new Error("Invalid app icon data URL.");
17364
- }
17365
- const mimeType = (match[1] || "").toLowerCase();
17366
- if (mimeType !== "image/svg+xml") {
17367
- throw new Error(`App icon data URL must be image/svg+xml. Received: ${mimeType || "unknown"}`);
17368
- }
17369
- const payload = match[3] || "";
17370
- const decoded = match[2] ? Buffer.from(payload, "base64").toString("utf8") : decodeURIComponent(payload);
17371
- const svg = decoded.trim();
17372
- if (!looksLikeSvgMarkup(svg)) {
17373
- throw new Error("App icon data URL does not contain valid SVG markup.");
17374
- }
17375
- return svg;
17376
- }
17377
17369
 
17378
17370
  // src/commands/AppCommandHandler.ts
17379
17371
  init_namespacedRef();
@@ -17389,7 +17381,12 @@ var AppCommandHandler = class {
17389
17381
  "GET",
17390
17382
  "/apps"
17391
17383
  );
17392
- const items = args.namespace ? response.items.filter((item) => item.namespace === args.namespace) : response.items;
17384
+ const items = response.items.filter((item) => {
17385
+ if (!args.all && item.status !== "active") {
17386
+ return false;
17387
+ }
17388
+ return args.namespace ? item.namespace === args.namespace : true;
17389
+ });
17393
17390
  this.renderList(items, args.json);
17394
17391
  return;
17395
17392
  }
@@ -20566,6 +20563,7 @@ function parseAppArgs(tokens) {
20566
20563
  };
20567
20564
  if (action === "list") {
20568
20565
  let namespace;
20566
+ let all = false;
20569
20567
  while (rest.length > 0) {
20570
20568
  const token = rest.shift();
20571
20569
  switch (token) {
@@ -20573,6 +20571,9 @@ function parseAppArgs(tokens) {
20573
20571
  case "--namespace":
20574
20572
  namespace = requireValue5(rest, token);
20575
20573
  break;
20574
+ case "--all":
20575
+ all = true;
20576
+ break;
20576
20577
  case "--base-url":
20577
20578
  baseUrl = requireValue5(rest, token);
20578
20579
  break;
@@ -20583,7 +20584,7 @@ function parseAppArgs(tokens) {
20583
20584
  throw new Error(`Unknown app list option: ${token}`);
20584
20585
  }
20585
20586
  }
20586
- return { type: "app" /* App */, action, namespace, baseUrl, json };
20587
+ return { type: "app" /* App */, action, namespace, all, baseUrl, json };
20587
20588
  }
20588
20589
  if (action === "view") {
20589
20590
  const rawRef = rest.shift();
@@ -22246,7 +22247,7 @@ var HELP_TEXT = [
22246
22247
  ` ${import_chalk4.default.gray(" move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]")}`,
22247
22248
  ` ${import_chalk4.default.gray(" call <ns:objectId> [--payload <json>] [--file <path>] [--base-url <url>] [--hub-base-url <url>] [--from <id>] [--json]")}`,
22248
22249
  ` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
22249
- ` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat; call uses pmate:cli session and default hub: https://hub.pmate.chat")}`,
22250
+ ` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat; call uses pmate:factory session and default hub: https://hub.pmate.chat")}`,
22250
22251
  ` ${import_chalk4.default.cyan("runner")} Manage runner registry entries via agent-api`,
22251
22252
  ` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
22252
22253
  ` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
@@ -22295,7 +22296,7 @@ var HELP_TEXT = [
22295
22296
  ` ${import_chalk4.default.gray(" kv list|get|exists|set|delete <name> [options]")}`,
22296
22297
  ` ${import_chalk4.default.gray(" defaults: chain=pmate namespace=pmate env base URLs from BLOCKCHAIN_BASE_URL / INDEXER_BASE_URL")}`,
22297
22298
  ` ${import_chalk4.default.cyan("app")} Manage app registry entries via apps-api`,
22298
- ` ${import_chalk4.default.gray(" list [--ns <namespace>] [--base-url <url>] [--json]")}`,
22299
+ ` ${import_chalk4.default.gray(" list [--ns <namespace>] [--all] [--base-url <url>] [--json]")}`,
22299
22300
  ` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
22300
22301
  ` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
22301
22302
  ` ${import_chalk4.default.gray(" create --file <path> [--base-url <url>] [--json]")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.21.16",
3
+ "version": "0.21.18",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {