@pmate/cli 0.15.0 → 0.16.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/dist/index.js CHANGED
@@ -13827,12 +13827,107 @@ var StsCommandHandler = class {
13827
13827
  }
13828
13828
  };
13829
13829
 
13830
+ // src/staticSiteSetup.ts
13831
+ async function setupStaticSiteBucket(input) {
13832
+ const bucketName = input.bucketName.trim();
13833
+ const domainName = input.domainName.trim();
13834
+ const subdomain = input.subdomain?.trim();
13835
+ const dnsRr = subdomain || "@";
13836
+ const cdnDomain = subdomain ? `${subdomain}.${domainName}` : domainName;
13837
+ await AliyunService.ensureBucket(bucketName);
13838
+ await sleep(2e3);
13839
+ await AliyunService.ensureCdnDomain(cdnDomain, bucketName);
13840
+ await sleep(2e3);
13841
+ await AliyunService.enableOssPrivateBucketOrigin(cdnDomain);
13842
+ await sleep(2e3);
13843
+ ui.success(`Enabled OSS private bucket origin for ${cdnDomain}`);
13844
+ await AliyunService.setDefaultCacheRules(cdnDomain);
13845
+ await sleep(2e3);
13846
+ ui.success(`Set default cache rules for ${cdnDomain}`);
13847
+ const cname = await AliyunService.getCdnCname(cdnDomain);
13848
+ if (!cname) {
13849
+ throw new Error(`No CNAME found for ${cdnDomain}. Try again in a minute.`);
13850
+ }
13851
+ ui.info(`CNAME for ${cdnDomain}:`, cname);
13852
+ const existingCname = await AliyunService.getCnameRecordValue(domainName, dnsRr);
13853
+ if (existingCname) {
13854
+ if (existingCname !== cname) {
13855
+ throw new Error(
13856
+ `Existing CNAME record for ${cdnDomain} points to ${existingCname}, not ${cname}.`
13857
+ );
13858
+ }
13859
+ ui.success(`CNAME record already exists for ${cdnDomain}`);
13860
+ } else {
13861
+ await AliyunService.addRecord({
13862
+ domainName,
13863
+ rr: dnsRr,
13864
+ type: "CNAME",
13865
+ value: cname,
13866
+ ttl: 600
13867
+ });
13868
+ await sleep(2e3);
13869
+ ui.success(`Added CNAME record ${cdnDomain} -> ${cname}`);
13870
+ }
13871
+ if (!subdomain) {
13872
+ const wwwCname = await AliyunService.getCnameRecordValue(domainName, "www");
13873
+ if (wwwCname) {
13874
+ if (wwwCname !== domainName) {
13875
+ throw new Error(
13876
+ `Existing CNAME record for www.${domainName} points to ${wwwCname}, not ${domainName}.`
13877
+ );
13878
+ }
13879
+ ui.success(`CNAME record already exists for www.${domainName}`);
13880
+ } else {
13881
+ await AliyunService.addRecord({
13882
+ domainName,
13883
+ rr: "www",
13884
+ type: "CNAME",
13885
+ value: domainName,
13886
+ ttl: 600
13887
+ });
13888
+ await sleep(2e3);
13889
+ ui.success(`Added CNAME record www.${domainName} -> ${domainName}`);
13890
+ }
13891
+ }
13892
+ await AliyunService.enableHttpsCertificate(cdnDomain);
13893
+ await sleep(2e3);
13894
+ ui.success(`Enabled HTTPS certificate for ${cdnDomain}`);
13895
+ if (input.routeType === "ssg") {
13896
+ await AliyunService.enableSsgRewriteRule(cdnDomain);
13897
+ await sleep(2e3);
13898
+ ui.success(`Enabled SSG rewrite rule for ${cdnDomain}`);
13899
+ return;
13900
+ }
13901
+ await AliyunService.enableSpaRewriteRule(cdnDomain);
13902
+ await sleep(2e3);
13903
+ ui.success(`Enabled SPA rewrite rule for ${cdnDomain}`);
13904
+ }
13905
+ function sleep(ms) {
13906
+ return new Promise((resolve) => {
13907
+ setTimeout(resolve, ms);
13908
+ });
13909
+ }
13910
+
13830
13911
  // src/commands/BucketCommandHandler.ts
13831
13912
  var BucketCommandHandler = class {
13832
13913
  async handle(args) {
13833
13914
  const bucketName = args.bucketName.trim();
13834
- await AliyunService.createBucket(bucketName);
13835
- ui.success(`Bucket created: ${bucketName}`);
13915
+ const subdomain = args.bucketSubdomain?.trim();
13916
+ if (!subdomain) {
13917
+ await AliyunService.createBucket(bucketName);
13918
+ ui.success(`Bucket created: ${bucketName}`);
13919
+ return;
13920
+ }
13921
+ const domainName = args.bucketDomain?.trim();
13922
+ if (!domainName) {
13923
+ throw new Error("Missing domain name. Use --domain <name> when --subdomain is set.");
13924
+ }
13925
+ await setupStaticSiteBucket({
13926
+ bucketName,
13927
+ domainName,
13928
+ subdomain,
13929
+ routeType: "spa"
13930
+ });
13836
13931
  }
13837
13932
  };
13838
13933
 
@@ -14301,82 +14396,12 @@ var InitCommandHandler = class {
14301
14396
  if (!baseDomain) {
14302
14397
  throw new Error(`Missing domain in ${import_node_path8.default.join(cwd, ".pmate.yaml")}`);
14303
14398
  }
14304
- const subdomain = appConfig.subdomain?.trim();
14305
- const dnsRr = subdomain || "@";
14306
- const cdnDomain = subdomain ? `${subdomain}.${baseDomain}` : baseDomain;
14307
- await AliyunService.ensureBucket(bucketName);
14308
- await this.sleep(2e3);
14309
- await AliyunService.ensureCdnDomain(cdnDomain, bucketName);
14310
- await this.sleep(2e3);
14311
- await AliyunService.enableOssPrivateBucketOrigin(cdnDomain);
14312
- await this.sleep(2e3);
14313
- ui.success(`Enabled OSS private bucket origin for ${cdnDomain}`);
14314
- await AliyunService.setDefaultCacheRules(cdnDomain);
14315
- await this.sleep(2e3);
14316
- ui.success(`Set default cache rules for ${cdnDomain}`);
14317
- const cname = await AliyunService.getCdnCname(cdnDomain);
14318
- if (!cname) {
14319
- throw new Error(`No CNAME found for ${cdnDomain}. Try again in a minute.`);
14320
- }
14321
- ui.info(`CNAME for ${cdnDomain}:`, cname);
14322
- const existingCname = await AliyunService.getCnameRecordValue(
14323
- baseDomain,
14324
- dnsRr
14325
- );
14326
- if (existingCname) {
14327
- if (existingCname !== cname) {
14328
- throw new Error(
14329
- `Existing CNAME record for ${cdnDomain} points to ${existingCname}, not ${cname}.`
14330
- );
14331
- }
14332
- ui.success(`CNAME record already exists for ${cdnDomain}`);
14333
- } else {
14334
- await AliyunService.addRecord({
14335
- domainName: baseDomain,
14336
- rr: dnsRr,
14337
- type: "CNAME",
14338
- value: cname,
14339
- ttl: 600
14340
- });
14341
- await this.sleep(2e3);
14342
- ui.success(`Added CNAME record ${cdnDomain} -> ${cname}`);
14343
- }
14344
- if (!subdomain) {
14345
- const wwwCname = await AliyunService.getCnameRecordValue(
14346
- baseDomain,
14347
- "www"
14348
- );
14349
- if (wwwCname) {
14350
- if (wwwCname !== baseDomain) {
14351
- throw new Error(
14352
- `Existing CNAME record for www.${baseDomain} points to ${wwwCname}, not ${baseDomain}.`
14353
- );
14354
- }
14355
- ui.success(`CNAME record already exists for www.${baseDomain}`);
14356
- } else {
14357
- await AliyunService.addRecord({
14358
- domainName: baseDomain,
14359
- rr: "www",
14360
- type: "CNAME",
14361
- value: baseDomain,
14362
- ttl: 600
14363
- });
14364
- await this.sleep(2e3);
14365
- ui.success(`Added CNAME record www.${baseDomain} -> ${baseDomain}`);
14366
- }
14367
- }
14368
- await AliyunService.enableHttpsCertificate(cdnDomain);
14369
- await this.sleep(2e3);
14370
- ui.success(`Enabled HTTPS certificate for ${cdnDomain}`);
14371
- if (appConfig.type === "vite" && appConfig.routeType === "ssg") {
14372
- await AliyunService.enableSsgRewriteRule(cdnDomain);
14373
- await this.sleep(2e3);
14374
- ui.success(`Enabled SSG rewrite rule for ${cdnDomain}`);
14375
- } else {
14376
- await AliyunService.enableSpaRewriteRule(cdnDomain);
14377
- await this.sleep(2e3);
14378
- ui.success(`Enabled SPA rewrite rule for ${cdnDomain}`);
14379
- }
14399
+ await setupStaticSiteBucket({
14400
+ bucketName,
14401
+ domainName: baseDomain,
14402
+ subdomain: appConfig.subdomain,
14403
+ routeType: appConfig.type === "vite" && appConfig.routeType === "ssg" ? "ssg" : "spa"
14404
+ });
14380
14405
  }
14381
14406
  async initNode(appConfig, cwd) {
14382
14407
  console.log("Initializing node app...");
@@ -17194,7 +17219,7 @@ var LinearCommandHandler = class {
17194
17219
  for (let attempt = 0; attempt < 12; attempt++) {
17195
17220
  buffer = await this.captureClipboardImageAsPng();
17196
17221
  if (buffer.length > 0) break;
17197
- await sleep(150);
17222
+ await sleep2(150);
17198
17223
  }
17199
17224
  if (buffer.length === 0) {
17200
17225
  const info = await this.getClipboardDebugInfo();
@@ -17645,7 +17670,7 @@ function parseJson(raw) {
17645
17670
  return JSON.parse(match[0]);
17646
17671
  }
17647
17672
  }
17648
- function sleep(ms) {
17673
+ function sleep2(ms) {
17649
17674
  return new Promise((resolve) => setTimeout(resolve, ms));
17650
17675
  }
17651
17676
 
@@ -18782,167 +18807,6 @@ function parseMessageText(raw) {
18782
18807
  var import_node_fs12 = require("fs");
18783
18808
  var import_node_path17 = __toESM(require("path"));
18784
18809
  init_sessionStore();
18785
- var AgentCommandHandler = class {
18786
- async handle(args) {
18787
- const token = this.readToken();
18788
- const baseUrl = this.resolveBaseUrl(args.baseUrl);
18789
- switch (args.action) {
18790
- case "namespaces": {
18791
- const response = await this.request(
18792
- baseUrl,
18793
- token,
18794
- "GET",
18795
- "/agents/namespaces"
18796
- );
18797
- this.renderNamespaces(response.items, args.json);
18798
- return;
18799
- }
18800
- case "list": {
18801
- const response = await this.request(
18802
- baseUrl,
18803
- token,
18804
- "GET",
18805
- `/agents?namespace=${encodeURIComponent(args.namespace)}`
18806
- );
18807
- this.renderList(response.items, args.json);
18808
- return;
18809
- }
18810
- case "get": {
18811
- const record = await this.request(
18812
- baseUrl,
18813
- token,
18814
- "GET",
18815
- `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
18816
- );
18817
- this.renderJson(record, args.json ?? true);
18818
- return;
18819
- }
18820
- case "create": {
18821
- const payload = this.readJsonFile(args.filePath);
18822
- const record = await this.request(
18823
- baseUrl,
18824
- token,
18825
- "POST",
18826
- `/agents/${encodeURIComponent(args.namespace)}`,
18827
- payload
18828
- );
18829
- ui.success(`Created agent ${record.id}`);
18830
- this.renderJson(record, args.json);
18831
- return;
18832
- }
18833
- case "update": {
18834
- const payload = this.readJsonFile(args.filePath);
18835
- const record = await this.request(
18836
- baseUrl,
18837
- token,
18838
- "PUT",
18839
- `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`,
18840
- payload
18841
- );
18842
- ui.success(`Updated agent ${record.id}`);
18843
- this.renderJson(record, args.json);
18844
- return;
18845
- }
18846
- case "delete": {
18847
- const record = await this.request(
18848
- baseUrl,
18849
- token,
18850
- "DELETE",
18851
- `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
18852
- );
18853
- ui.success(`Disabled agent ${record.id}`);
18854
- this.renderJson(record, args.json);
18855
- return;
18856
- }
18857
- }
18858
- }
18859
- resolveBaseUrl(baseUrl) {
18860
- return (baseUrl || process.env.PMATE_AGENT_API_BASE_URL || "https://agent-api.pmate.chat").replace(
18861
- /\/+$/,
18862
- ""
18863
- );
18864
- }
18865
- readToken() {
18866
- return readRequiredSession({
18867
- preferredApp: DEFAULT_APP_ID
18868
- }).token;
18869
- }
18870
- readJsonFile(filePath) {
18871
- const absolutePath = import_node_path17.default.resolve(process.cwd(), filePath);
18872
- if (!(0, import_node_fs12.existsSync)(absolutePath)) {
18873
- throw new Error(`JSON file not found: ${absolutePath}`);
18874
- }
18875
- const raw = (0, import_node_fs12.readFileSync)(absolutePath, "utf8");
18876
- try {
18877
- return JSON.parse(raw);
18878
- } catch (error) {
18879
- const message = error instanceof Error ? error.message : String(error);
18880
- throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
18881
- }
18882
- }
18883
- async request(baseUrl, token, method, pathname, body) {
18884
- const response = await fetch(`${baseUrl}${pathname}`, {
18885
- method,
18886
- headers: {
18887
- Authorization: `Bearer ${token}`,
18888
- "Content-Type": "application/json"
18889
- },
18890
- ...body !== void 0 ? { body: JSON.stringify(body) } : {}
18891
- });
18892
- let payload = null;
18893
- try {
18894
- payload = await response.json();
18895
- } catch {
18896
- payload = null;
18897
- }
18898
- if (!response.ok || !payload?.success) {
18899
- throw new Error(payload?.message || `Request failed with status ${response.status}`);
18900
- }
18901
- return payload.data;
18902
- }
18903
- renderList(items, asJson) {
18904
- if (asJson) {
18905
- ui.plain(JSON.stringify(items, null, 2));
18906
- return;
18907
- }
18908
- if (items.length === 0) {
18909
- ui.warn("No agents found.");
18910
- return;
18911
- }
18912
- for (const item of items) {
18913
- ui.info(`${item.namespace}/${item.name}`, {
18914
- status: item.status,
18915
- version: item.version
18916
- });
18917
- }
18918
- }
18919
- renderJson(value, asJson) {
18920
- if (!asJson) {
18921
- return;
18922
- }
18923
- ui.plain(JSON.stringify(value, null, 2));
18924
- }
18925
- renderNamespaces(items, asJson) {
18926
- if (asJson) {
18927
- ui.plain(JSON.stringify(items, null, 2));
18928
- return;
18929
- }
18930
- if (items.length === 0) {
18931
- ui.warn("No namespaces found.");
18932
- return;
18933
- }
18934
- for (const item of items) {
18935
- ui.info(item.namespace, {
18936
- status: item.status,
18937
- updatedAt: item.updatedAt
18938
- });
18939
- }
18940
- }
18941
- };
18942
-
18943
- // src/commands/StoreCommandHandler.ts
18944
- var import_node_fs13 = require("fs");
18945
- var import_node_path18 = __toESM(require("path"));
18946
18810
 
18947
18811
  // src/storeClient.ts
18948
18812
  var STORE_LOG_VERSION = 1;
@@ -18990,6 +18854,13 @@ async function requestJson(url, init, fallbackMessage) {
18990
18854
  }
18991
18855
  return payload;
18992
18856
  }
18857
+ function normalizeNamespace(value) {
18858
+ const normalized = value.trim().toLowerCase();
18859
+ if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(normalized)) {
18860
+ throw new Error("Invalid namespace. Use lowercase letters, numbers, and dashes only.");
18861
+ }
18862
+ return normalized;
18863
+ }
18993
18864
  var IndexerClient = class {
18994
18865
  constructor(baseUrl) {
18995
18866
  this.baseUrl = baseUrl;
@@ -19162,33 +19033,348 @@ var Namespace = class {
19162
19033
  };
19163
19034
  }
19164
19035
  };
19165
-
19166
- // src/commands/StoreCommandHandler.ts
19167
- var StoreCommandHandler = class {
19168
- async handle(args) {
19169
- if (args.scope === "namespace") {
19170
- const items = await this.listNamespaces(args);
19171
- this.renderNamespaceList(items, args.json);
19172
- return;
19173
- }
19174
- const namespace = this.createNamespace(args);
19175
- if (args.scope === "table") {
19176
- const table = namespace.table(args.name);
19177
- switch (args.action) {
19178
- case "list": {
19179
- const rows = await table.list(args.page);
19180
- this.renderJsonOrSummary(
19181
- rows,
19182
- args.json,
19183
- "No rows found.",
19184
- (row) => row.id ?? "<missing-id>"
19185
- );
19186
- return;
19187
- }
19188
- case "get": {
19189
- const row = await table.getById(args.id);
19190
- this.renderValue(row, args.json);
19191
- return;
19036
+ var NamespaceRegistry = class {
19037
+ constructor(options) {
19038
+ this.options = options;
19039
+ }
19040
+ async list() {
19041
+ return this.request("GET", "/namespaces");
19042
+ }
19043
+ async get(namespace) {
19044
+ const normalized = normalizeNamespace(namespace);
19045
+ const response = await fetch(
19046
+ `${this.options.registryBaseUrl.replace(/\/+$/, "")}/namespaces/${encodeURIComponent(normalized)}`,
19047
+ {
19048
+ method: "GET",
19049
+ headers: {
19050
+ Accept: "application/json",
19051
+ ...this.options.headers
19052
+ }
19053
+ }
19054
+ );
19055
+ if (response.status === 404) {
19056
+ return void 0;
19057
+ }
19058
+ const payload = await response.json();
19059
+ if (!response.ok || !payload?.success) {
19060
+ throw new Error(payload?.message || `Namespace request failed: ${response.status}`);
19061
+ }
19062
+ return payload.data;
19063
+ }
19064
+ async exists(namespace) {
19065
+ return Boolean(await this.get(namespace));
19066
+ }
19067
+ async create(namespace) {
19068
+ return this.request("POST", "/namespaces", {
19069
+ namespace: normalizeNamespace(namespace)
19070
+ });
19071
+ }
19072
+ async require(namespace) {
19073
+ const record = await this.get(namespace);
19074
+ if (!record || record.status !== "active") {
19075
+ throw new Error(`Namespace "${normalizeNamespace(namespace)}" is not registered.`);
19076
+ }
19077
+ if (!this.options.blockchainBaseUrl || !this.options.indexerBaseUrl) {
19078
+ throw new Error("Namespace handle requires blockchain and indexer base URLs.");
19079
+ }
19080
+ return new Namespace({
19081
+ chain: this.options.chain,
19082
+ ns: record.namespace,
19083
+ baseUrl: this.options.blockchainBaseUrl,
19084
+ indexerBaseUrl: this.options.indexerBaseUrl
19085
+ });
19086
+ }
19087
+ async request(method, pathname, body) {
19088
+ const response = await fetch(`${this.options.registryBaseUrl.replace(/\/+$/, "")}${pathname}`, {
19089
+ method,
19090
+ headers: {
19091
+ Accept: "application/json",
19092
+ ...this.options.headers,
19093
+ ...method === "POST" ? { "Content-Type": "application/json" } : {}
19094
+ },
19095
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
19096
+ });
19097
+ const payload = await response.json();
19098
+ if (!response.ok || !payload?.success) {
19099
+ throw new Error(payload?.message || `Namespace request failed: ${response.status}`);
19100
+ }
19101
+ return payload.data;
19102
+ }
19103
+ };
19104
+
19105
+ // src/commands/AgentCommandHandler.ts
19106
+ var AgentCommandHandler = class {
19107
+ async handle(args) {
19108
+ const token = this.readToken();
19109
+ const baseUrl = this.resolveBaseUrl(args.baseUrl);
19110
+ switch (args.action) {
19111
+ case "namespaces": {
19112
+ const response = await this.request(
19113
+ baseUrl,
19114
+ token,
19115
+ "GET",
19116
+ "/agents/namespaces"
19117
+ );
19118
+ this.renderNamespaces(response.items, args.json);
19119
+ return;
19120
+ }
19121
+ case "list": {
19122
+ const response = await this.request(
19123
+ baseUrl,
19124
+ token,
19125
+ "GET",
19126
+ `/agents?namespace=${encodeURIComponent(args.namespace)}`
19127
+ );
19128
+ this.renderList(response.items, args.json);
19129
+ return;
19130
+ }
19131
+ case "get": {
19132
+ const record = await this.request(
19133
+ baseUrl,
19134
+ token,
19135
+ "GET",
19136
+ `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
19137
+ );
19138
+ this.renderJson(record, args.json ?? true);
19139
+ return;
19140
+ }
19141
+ case "create": {
19142
+ await this.requireNamespace(args.namespace, baseUrl);
19143
+ const payload = this.readJsonFile(args.filePath);
19144
+ const record = await this.request(
19145
+ baseUrl,
19146
+ token,
19147
+ "POST",
19148
+ `/agents/${encodeURIComponent(args.namespace)}`,
19149
+ payload
19150
+ );
19151
+ ui.success(`Created agent ${record.id}`);
19152
+ this.renderJson(record, args.json);
19153
+ return;
19154
+ }
19155
+ case "update": {
19156
+ const payload = this.readJsonFile(args.filePath);
19157
+ const record = await this.request(
19158
+ baseUrl,
19159
+ token,
19160
+ "PUT",
19161
+ `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`,
19162
+ payload
19163
+ );
19164
+ ui.success(`Updated agent ${record.id}`);
19165
+ this.renderJson(record, args.json);
19166
+ return;
19167
+ }
19168
+ case "delete": {
19169
+ const record = await this.request(
19170
+ baseUrl,
19171
+ token,
19172
+ "DELETE",
19173
+ `/agents/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
19174
+ );
19175
+ ui.success(`Disabled agent ${record.id}`);
19176
+ this.renderJson(record, args.json);
19177
+ return;
19178
+ }
19179
+ }
19180
+ }
19181
+ resolveBaseUrl(baseUrl) {
19182
+ return (baseUrl || process.env.PMATE_AGENT_API_BASE_URL || "https://agent-api.pmate.chat").replace(
19183
+ /\/+$/,
19184
+ ""
19185
+ );
19186
+ }
19187
+ async requireNamespace(namespace, registryBaseUrl) {
19188
+ const registry = new NamespaceRegistry({
19189
+ chain: "pmate",
19190
+ registryBaseUrl: this.resolveNamespaceBaseUrl(registryBaseUrl)
19191
+ });
19192
+ const exists = await registry.exists(namespace);
19193
+ if (!exists) {
19194
+ throw new Error(`Namespace "${namespace}" is not registered. Run: pmate ns create ${namespace}`);
19195
+ }
19196
+ }
19197
+ resolveNamespaceBaseUrl(baseUrl) {
19198
+ const envBaseUrl = process.env.PMATE_NAMESPACE_API_BASE_URL || process.env.PMATE_APPS_API_BASE_URL;
19199
+ if (envBaseUrl) {
19200
+ return envBaseUrl.replace(/\/+$/, "");
19201
+ }
19202
+ return baseUrl.includes("agent-api") || baseUrl.includes("agent.local") ? baseUrl.replace("agent-api", "apps-api").replace("agent.local", "apps.local") : baseUrl;
19203
+ }
19204
+ readToken() {
19205
+ return readRequiredSession({
19206
+ preferredApp: DEFAULT_APP_ID
19207
+ }).token;
19208
+ }
19209
+ readJsonFile(filePath) {
19210
+ const absolutePath = import_node_path17.default.resolve(process.cwd(), filePath);
19211
+ if (!(0, import_node_fs12.existsSync)(absolutePath)) {
19212
+ throw new Error(`JSON file not found: ${absolutePath}`);
19213
+ }
19214
+ const raw = (0, import_node_fs12.readFileSync)(absolutePath, "utf8");
19215
+ try {
19216
+ return JSON.parse(raw);
19217
+ } catch (error) {
19218
+ const message = error instanceof Error ? error.message : String(error);
19219
+ throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
19220
+ }
19221
+ }
19222
+ async request(baseUrl, token, method, pathname, body) {
19223
+ const response = await fetch(`${baseUrl}${pathname}`, {
19224
+ method,
19225
+ headers: {
19226
+ Authorization: `Bearer ${token}`,
19227
+ "Content-Type": "application/json"
19228
+ },
19229
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
19230
+ });
19231
+ let payload = null;
19232
+ try {
19233
+ payload = await response.json();
19234
+ } catch {
19235
+ payload = null;
19236
+ }
19237
+ if (!response.ok || !payload?.success) {
19238
+ throw new Error(payload?.message || `Request failed with status ${response.status}`);
19239
+ }
19240
+ return payload.data;
19241
+ }
19242
+ renderList(items, asJson) {
19243
+ if (asJson) {
19244
+ ui.plain(JSON.stringify(items, null, 2));
19245
+ return;
19246
+ }
19247
+ if (items.length === 0) {
19248
+ ui.warn("No agents found.");
19249
+ return;
19250
+ }
19251
+ for (const item of items) {
19252
+ ui.info(`${item.namespace}/${item.name}`, {
19253
+ status: item.status,
19254
+ version: item.version
19255
+ });
19256
+ }
19257
+ }
19258
+ renderJson(value, asJson) {
19259
+ if (!asJson) {
19260
+ return;
19261
+ }
19262
+ ui.plain(JSON.stringify(value, null, 2));
19263
+ }
19264
+ renderNamespaces(items, asJson) {
19265
+ if (asJson) {
19266
+ ui.plain(JSON.stringify(items, null, 2));
19267
+ return;
19268
+ }
19269
+ if (items.length === 0) {
19270
+ ui.warn("No namespaces found.");
19271
+ return;
19272
+ }
19273
+ for (const item of items) {
19274
+ ui.info(item.namespace, {
19275
+ status: item.status,
19276
+ updatedAt: item.updatedAt
19277
+ });
19278
+ }
19279
+ }
19280
+ };
19281
+
19282
+ // src/commands/NsCommandHandler.ts
19283
+ init_sessionStore();
19284
+ var NsCommandHandler = class {
19285
+ async handle(args) {
19286
+ switch (args.action) {
19287
+ case "list": {
19288
+ const registry = this.createRegistry(args);
19289
+ const items = await registry.list();
19290
+ this.render(items, args.json);
19291
+ return;
19292
+ }
19293
+ case "get": {
19294
+ const registry = this.createRegistry(args);
19295
+ const item = await registry.get(args.namespace);
19296
+ if (!item) {
19297
+ throw new Error(`Namespace "${args.namespace}" is not registered.`);
19298
+ }
19299
+ this.render(item, true);
19300
+ return;
19301
+ }
19302
+ case "create": {
19303
+ const registry = this.createRegistry(args, this.resolveAuthHeaders());
19304
+ const item = await registry.create(args.namespace);
19305
+ ui.success(`Created namespace ${item.namespace}`);
19306
+ this.render(item, args.json);
19307
+ return;
19308
+ }
19309
+ }
19310
+ }
19311
+ resolveBaseUrl(baseUrl) {
19312
+ return (baseUrl || process.env.PMATE_NAMESPACE_API_BASE_URL || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
19313
+ }
19314
+ resolveAuthHeaders() {
19315
+ return {
19316
+ Authorization: `Bearer ${readRequiredSession({ preferredApp: DEFAULT_APP_ID }).token}`
19317
+ };
19318
+ }
19319
+ createRegistry(args, headers) {
19320
+ return new NamespaceRegistry({
19321
+ chain: args.chain,
19322
+ registryBaseUrl: this.resolveBaseUrl(args.baseUrl),
19323
+ headers
19324
+ });
19325
+ }
19326
+ render(value, asJson) {
19327
+ if (asJson) {
19328
+ ui.plain(JSON.stringify(value, null, 2));
19329
+ return;
19330
+ }
19331
+ if (Array.isArray(value)) {
19332
+ if (value.length === 0) {
19333
+ ui.warn("No namespaces found.");
19334
+ return;
19335
+ }
19336
+ for (const item of value) {
19337
+ ui.info(`${item.chain ?? "pmate"}/${item.namespace}`, {
19338
+ status: item.status
19339
+ });
19340
+ }
19341
+ return;
19342
+ }
19343
+ ui.plain(JSON.stringify(value, null, 2));
19344
+ }
19345
+ };
19346
+
19347
+ // src/commands/StoreCommandHandler.ts
19348
+ var import_node_fs13 = require("fs");
19349
+ var import_node_path18 = __toESM(require("path"));
19350
+ var StoreCommandHandler = class {
19351
+ async handle(args) {
19352
+ if (args.scope === "namespace") {
19353
+ const items = await this.listNamespaces(args);
19354
+ this.renderNamespaceList(items, args.json);
19355
+ return;
19356
+ }
19357
+ if (this.requiresRegisteredNamespace(args)) {
19358
+ await this.requireNamespace(args);
19359
+ }
19360
+ const namespace = this.createNamespace(args);
19361
+ if (args.scope === "table") {
19362
+ const table = namespace.table(args.name);
19363
+ switch (args.action) {
19364
+ case "list": {
19365
+ const rows = await table.list(args.page);
19366
+ this.renderJsonOrSummary(
19367
+ rows,
19368
+ args.json,
19369
+ "No rows found.",
19370
+ (row) => row.id ?? "<missing-id>"
19371
+ );
19372
+ return;
19373
+ }
19374
+ case "get": {
19375
+ const row = await table.getById(args.id);
19376
+ this.renderValue(row, args.json);
19377
+ return;
19192
19378
  }
19193
19379
  case "exists": {
19194
19380
  const exists = await table.exists(args.id);
@@ -19269,6 +19455,25 @@ var StoreCommandHandler = class {
19269
19455
  resolveIndexerBaseUrl(indexerBaseUrl) {
19270
19456
  return (indexerBaseUrl || process.env.PMATE_STORE_INDEXER_BASE_URL || process.env.INDEXER_BASE_URL || "https://indexer.pmate.chat").replace(/\/+$/, "");
19271
19457
  }
19458
+ async requireNamespace(args) {
19459
+ const registry = new NamespaceRegistry({
19460
+ chain: args.chain,
19461
+ registryBaseUrl: this.resolveRegistryBaseUrl()
19462
+ });
19463
+ const exists = await registry.exists(args.namespace);
19464
+ if (!exists) {
19465
+ throw new Error(`Namespace "${args.namespace}" is not registered. Run: pmate ns create ${args.namespace}`);
19466
+ }
19467
+ }
19468
+ resolveRegistryBaseUrl() {
19469
+ return (process.env.PMATE_NAMESPACE_API_BASE_URL || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
19470
+ }
19471
+ requiresRegisteredNamespace(args) {
19472
+ if (args.scope === "table") {
19473
+ return args.action === "create" || args.action === "update" || args.action === "delete";
19474
+ }
19475
+ return args.action === "set" || args.action === "delete";
19476
+ }
19272
19477
  async listNamespaces(args) {
19273
19478
  const baseUrl = this.resolveIndexerBaseUrl(args.indexerBaseUrl);
19274
19479
  const url = new URL(`/chains/${encodeURIComponent(args.chain)}/namespaces`, `${baseUrl}/`);
@@ -19368,6 +19573,7 @@ var AppCommandHandler = class {
19368
19573
  }
19369
19574
  case "create": {
19370
19575
  const payload = this.readJsonFile(args.filePath);
19576
+ await this.requireNamespace(payload, baseUrl);
19371
19577
  const record = await this.request(
19372
19578
  baseUrl,
19373
19579
  token,
@@ -19446,6 +19652,17 @@ var AppCommandHandler = class {
19446
19652
  }
19447
19653
  return payload.data;
19448
19654
  }
19655
+ async requireNamespace(payload, baseUrl) {
19656
+ const namespace = readNamespaceFromPayload(payload);
19657
+ const registry = new NamespaceRegistry({
19658
+ chain: "pmate",
19659
+ registryBaseUrl: baseUrl
19660
+ });
19661
+ const exists = await registry.exists(namespace);
19662
+ if (!exists) {
19663
+ throw new Error(`Namespace "${namespace}" is not registered. Run: pmate ns create ${namespace}`);
19664
+ }
19665
+ }
19449
19666
  renderList(items, asJson) {
19450
19667
  if (asJson) {
19451
19668
  ui.plain(JSON.stringify(items, null, 2));
@@ -19469,6 +19686,16 @@ var AppCommandHandler = class {
19469
19686
  ui.plain(JSON.stringify(value, null, 2));
19470
19687
  }
19471
19688
  };
19689
+ function readNamespaceFromPayload(payload) {
19690
+ if (!payload || typeof payload !== "object") {
19691
+ throw new Error("App payload must be a JSON object.");
19692
+ }
19693
+ const namespace = payload.namespace;
19694
+ if (typeof namespace !== "string" || !namespace.trim()) {
19695
+ throw new Error("App payload.namespace is required.");
19696
+ }
19697
+ return namespace.trim().toLowerCase();
19698
+ }
19472
19699
 
19473
19700
  // src/commands/VercelCommandHandler.ts
19474
19701
  var import_node_child_process10 = require("child_process");
@@ -19586,7 +19813,7 @@ function parseAgentArgs(tokens) {
19586
19813
  }
19587
19814
  let baseUrl;
19588
19815
  let json = false;
19589
- const takeSharedOptions2 = () => {
19816
+ const takeSharedOptions3 = () => {
19590
19817
  while (rest.length > 0) {
19591
19818
  const token = rest[0];
19592
19819
  if (token === "--base-url") {
@@ -19603,7 +19830,7 @@ function parseAgentArgs(tokens) {
19603
19830
  }
19604
19831
  };
19605
19832
  if (action === "namespaces") {
19606
- takeSharedOptions2();
19833
+ takeSharedOptions3();
19607
19834
  if (rest.length > 0) {
19608
19835
  throw new Error(`Unknown agent namespaces option: ${rest[0]}`);
19609
19836
  }
@@ -19645,7 +19872,7 @@ function parseAgentArgs(tokens) {
19645
19872
  `Usage: agent ${action} [<namespace>] <name> [--base-url <url>] [--json]`
19646
19873
  );
19647
19874
  }
19648
- takeSharedOptions2();
19875
+ takeSharedOptions3();
19649
19876
  if (rest.length > 0) {
19650
19877
  throw new Error(`Unknown agent ${action} option: ${rest[0]}`);
19651
19878
  }
@@ -19726,8 +19953,79 @@ function requireValue(tokens, optionName) {
19726
19953
  return value;
19727
19954
  }
19728
19955
 
19729
- // src/storeCommandParser.ts
19956
+ // src/nsCommandParser.ts
19730
19957
  var DEFAULT_CHAIN = "pmate";
19958
+ function parseNsArgs(tokens) {
19959
+ const rest = [...tokens];
19960
+ const action = rest.shift();
19961
+ if (!action) {
19962
+ throw new Error("Missing ns action. Use: ns list|get|create");
19963
+ }
19964
+ let chain = DEFAULT_CHAIN;
19965
+ let baseUrl;
19966
+ let json = false;
19967
+ if (action === "list") {
19968
+ takeSharedOptions(rest, {
19969
+ onChain: (value) => {
19970
+ chain = value;
19971
+ },
19972
+ onBaseUrl: (value) => {
19973
+ baseUrl = value;
19974
+ },
19975
+ onJson: () => {
19976
+ json = true;
19977
+ }
19978
+ });
19979
+ return { type: "ns" /* Ns */, action, chain, baseUrl, json };
19980
+ }
19981
+ if (action === "get" || action === "create") {
19982
+ const namespace = rest.shift();
19983
+ if (!namespace || namespace.startsWith("-")) {
19984
+ throw new Error(`Usage: ns ${action} <namespace> [--chain <chain>] [--base-url <url>] [--json]`);
19985
+ }
19986
+ takeSharedOptions(rest, {
19987
+ onChain: (value) => {
19988
+ chain = value;
19989
+ },
19990
+ onBaseUrl: (value) => {
19991
+ baseUrl = value;
19992
+ },
19993
+ onJson: () => {
19994
+ json = true;
19995
+ }
19996
+ });
19997
+ return { type: "ns" /* Ns */, action, namespace, chain, baseUrl, json };
19998
+ }
19999
+ throw new Error(`Unknown ns action: ${action}`);
20000
+ }
20001
+ function takeSharedOptions(rest, handlers) {
20002
+ while (rest.length > 0) {
20003
+ const token = rest.shift();
20004
+ switch (token) {
20005
+ case "--chain":
20006
+ handlers.onChain(requireValue2(rest, token));
20007
+ break;
20008
+ case "--base-url":
20009
+ handlers.onBaseUrl(requireValue2(rest, token));
20010
+ break;
20011
+ case "--json":
20012
+ handlers.onJson();
20013
+ break;
20014
+ default:
20015
+ throw new Error(`Unknown ns option: ${token}`);
20016
+ }
20017
+ }
20018
+ }
20019
+ function requireValue2(tokens, optionName) {
20020
+ const value = tokens.shift();
20021
+ if (!value || value.startsWith("-")) {
20022
+ throw new Error(`Missing value for ${optionName}`);
20023
+ }
20024
+ return value;
20025
+ }
20026
+
20027
+ // src/storeCommandParser.ts
20028
+ var DEFAULT_CHAIN2 = "pmate";
19731
20029
  var DEFAULT_NAMESPACE2 = "pmate";
19732
20030
  function parseStoreArgs(tokens) {
19733
20031
  const rest = [...tokens];
@@ -19740,7 +20038,7 @@ function parseStoreArgs(tokens) {
19740
20038
  throw new Error(`Missing store ${scope} action.`);
19741
20039
  }
19742
20040
  const shared = {
19743
- chain: DEFAULT_CHAIN,
20041
+ chain: DEFAULT_CHAIN2,
19744
20042
  namespace: DEFAULT_NAMESPACE2,
19745
20043
  baseUrl: void 0,
19746
20044
  indexerBaseUrl: void 0,
@@ -19750,7 +20048,7 @@ function parseStoreArgs(tokens) {
19750
20048
  if (action !== "list") {
19751
20049
  throw new Error(`Unknown store namespace action: ${action}`);
19752
20050
  }
19753
- takeSharedOptions(rest, shared);
20051
+ takeSharedOptions2(rest, shared);
19754
20052
  if (rest.length > 0) {
19755
20053
  throw new Error(`Unknown store namespace option: ${rest[0]}`);
19756
20054
  }
@@ -19780,7 +20078,7 @@ function parseTableArgs(action, rest, shared) {
19780
20078
  const token = rest.shift();
19781
20079
  switch (token) {
19782
20080
  case "--page":
19783
- page = parsePage(requireValue2(rest, token));
20081
+ page = parsePage(requireValue3(rest, token));
19784
20082
  break;
19785
20083
  default:
19786
20084
  pushSharedOption(token, rest, shared);
@@ -19794,7 +20092,7 @@ function parseTableArgs(action, rest, shared) {
19794
20092
  const token = rest.shift();
19795
20093
  switch (token) {
19796
20094
  case "--id":
19797
- id = requireValue2(rest, token);
20095
+ id = requireValue3(rest, token);
19798
20096
  break;
19799
20097
  default:
19800
20098
  pushSharedOption(token, rest, shared);
@@ -19811,7 +20109,7 @@ function parseTableArgs(action, rest, shared) {
19811
20109
  const token = rest.shift();
19812
20110
  switch (token) {
19813
20111
  case "--file":
19814
- filePath = requireValue2(rest, token);
20112
+ filePath = requireValue3(rest, token);
19815
20113
  break;
19816
20114
  default:
19817
20115
  pushSharedOption(token, rest, shared);
@@ -19835,7 +20133,7 @@ function parseKvArgs(action, rest, shared) {
19835
20133
  const token = rest.shift();
19836
20134
  switch (token) {
19837
20135
  case "--page":
19838
- page = parsePage(requireValue2(rest, token));
20136
+ page = parsePage(requireValue3(rest, token));
19839
20137
  break;
19840
20138
  default:
19841
20139
  pushSharedOption(token, rest, shared);
@@ -19849,7 +20147,7 @@ function parseKvArgs(action, rest, shared) {
19849
20147
  const token = rest.shift();
19850
20148
  switch (token) {
19851
20149
  case "--key":
19852
- key = requireValue2(rest, token);
20150
+ key = requireValue3(rest, token);
19853
20151
  break;
19854
20152
  default:
19855
20153
  pushSharedOption(token, rest, shared);
@@ -19868,13 +20166,13 @@ function parseKvArgs(action, rest, shared) {
19868
20166
  const token = rest.shift();
19869
20167
  switch (token) {
19870
20168
  case "--key":
19871
- key = requireValue2(rest, token);
20169
+ key = requireValue3(rest, token);
19872
20170
  break;
19873
20171
  case "--value":
19874
- value = requireValue2(rest, token);
20172
+ value = requireValue3(rest, token);
19875
20173
  break;
19876
20174
  case "--file":
19877
- filePath = requireValue2(rest, token);
20175
+ filePath = requireValue3(rest, token);
19878
20176
  break;
19879
20177
  default:
19880
20178
  pushSharedOption(token, rest, shared);
@@ -19890,7 +20188,7 @@ function parseKvArgs(action, rest, shared) {
19890
20188
  }
19891
20189
  throw new Error(`Unknown store kv action: ${action}`);
19892
20190
  }
19893
- function takeSharedOptions(rest, shared) {
20191
+ function takeSharedOptions2(rest, shared) {
19894
20192
  while (rest.length > 0) {
19895
20193
  const token = rest.shift();
19896
20194
  pushSharedOption(token, rest, shared);
@@ -19899,17 +20197,17 @@ function takeSharedOptions(rest, shared) {
19899
20197
  function pushSharedOption(token, rest, shared) {
19900
20198
  switch (token) {
19901
20199
  case "--chain":
19902
- shared.chain = requireValue2(rest, token);
20200
+ shared.chain = requireValue3(rest, token);
19903
20201
  break;
19904
20202
  case "--ns":
19905
20203
  case "--namespace":
19906
- shared.namespace = requireValue2(rest, token);
20204
+ shared.namespace = requireValue3(rest, token);
19907
20205
  break;
19908
20206
  case "--base-url":
19909
- shared.baseUrl = requireValue2(rest, token);
20207
+ shared.baseUrl = requireValue3(rest, token);
19910
20208
  break;
19911
20209
  case "--indexer-base-url":
19912
- shared.indexerBaseUrl = requireValue2(rest, token);
20210
+ shared.indexerBaseUrl = requireValue3(rest, token);
19913
20211
  break;
19914
20212
  case "--json":
19915
20213
  shared.json = true;
@@ -19918,7 +20216,7 @@ function pushSharedOption(token, rest, shared) {
19918
20216
  throw new Error(`Unknown store option: ${token}`);
19919
20217
  }
19920
20218
  }
19921
- function requireValue2(tokens, optionName) {
20219
+ function requireValue3(tokens, optionName) {
19922
20220
  const value = tokens.shift();
19923
20221
  if (!value || value.startsWith("-")) {
19924
20222
  throw new Error(`Missing value for ${optionName}`);
@@ -19942,12 +20240,12 @@ function parseAppArgs(tokens) {
19942
20240
  }
19943
20241
  let baseUrl;
19944
20242
  let json = false;
19945
- const takeSharedOptions2 = () => {
20243
+ const takeSharedOptions3 = () => {
19946
20244
  while (rest.length > 0) {
19947
20245
  const token = rest[0];
19948
20246
  if (token === "--base-url") {
19949
20247
  rest.shift();
19950
- baseUrl = requireValue3(rest, token);
20248
+ baseUrl = requireValue4(rest, token);
19951
20249
  continue;
19952
20250
  }
19953
20251
  if (token === "--json") {
@@ -19959,7 +20257,7 @@ function parseAppArgs(tokens) {
19959
20257
  }
19960
20258
  };
19961
20259
  if (action === "list") {
19962
- takeSharedOptions2();
20260
+ takeSharedOptions3();
19963
20261
  if (rest.length > 0) {
19964
20262
  throw new Error(`Unknown app list option: ${rest[0]}`);
19965
20263
  }
@@ -19972,7 +20270,7 @@ function parseAppArgs(tokens) {
19972
20270
  `Usage: app ${action} <id> [--base-url <url>] [--json]`
19973
20271
  );
19974
20272
  }
19975
- takeSharedOptions2();
20273
+ takeSharedOptions3();
19976
20274
  if (rest.length > 0) {
19977
20275
  throw new Error(`Unknown app ${action} option: ${rest[0]}`);
19978
20276
  }
@@ -19984,10 +20282,10 @@ function parseAppArgs(tokens) {
19984
20282
  const token = rest.shift();
19985
20283
  switch (token) {
19986
20284
  case "--file":
19987
- filePath = requireValue3(rest, token);
20285
+ filePath = requireValue4(rest, token);
19988
20286
  break;
19989
20287
  case "--base-url":
19990
- baseUrl = requireValue3(rest, token);
20288
+ baseUrl = requireValue4(rest, token);
19991
20289
  break;
19992
20290
  case "--json":
19993
20291
  json = true;
@@ -20013,10 +20311,10 @@ function parseAppArgs(tokens) {
20013
20311
  const token = rest.shift();
20014
20312
  switch (token) {
20015
20313
  case "--file":
20016
- filePath = requireValue3(rest, token);
20314
+ filePath = requireValue4(rest, token);
20017
20315
  break;
20018
20316
  case "--base-url":
20019
- baseUrl = requireValue3(rest, token);
20317
+ baseUrl = requireValue4(rest, token);
20020
20318
  break;
20021
20319
  case "--json":
20022
20320
  json = true;
@@ -20032,7 +20330,7 @@ function parseAppArgs(tokens) {
20032
20330
  }
20033
20331
  throw new Error(`Unknown app action: ${action}`);
20034
20332
  }
20035
- function requireValue3(tokens, optionName) {
20333
+ function requireValue4(tokens, optionName) {
20036
20334
  const value = tokens.shift();
20037
20335
  if (!value || value.startsWith("-")) {
20038
20336
  throw new Error(`Missing value for ${optionName}`);
@@ -20063,7 +20361,7 @@ var HELP_TEXT = [
20063
20361
  ` ${import_chalk3.default.gray(" --type <t> --value <v> --rr <rr> [--ttl <n>] [--domain <name>]")}`,
20064
20362
  ` ${import_chalk3.default.cyan("sts")} Request an OSS STS token from the CI server`,
20065
20363
  ` ${import_chalk3.default.cyan("bucket")} Manage OSS buckets`,
20066
- ` ${import_chalk3.default.gray(" --create --name <bucket>")}`,
20364
+ ` ${import_chalk3.default.gray(" --create --name <bucket> [--subdomain <name> --domain <name>]")}`,
20067
20365
  ` ${import_chalk3.default.cyan("deploy")} Deploy or view logs for app dir from .pmate.yaml`,
20068
20366
  ` ${import_chalk3.default.gray(" <app-name> [deploy|logs] [--cwd <dir>]")}`,
20069
20367
  ` ${import_chalk3.default.cyan("log")} Query app logs from the log indexer API`,
@@ -20126,6 +20424,10 @@ var HELP_TEXT = [
20126
20424
  ` ${import_chalk3.default.gray(" update [<namespace>] <name> --file <path> [--base-url <url>] [--json]")}`,
20127
20425
  ` ${import_chalk3.default.gray(" delete [<namespace>] <name> [--base-url <url>] [--json]")}`,
20128
20426
  ` ${import_chalk3.default.gray(" default namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
20427
+ ` ${import_chalk3.default.cyan("ns")} Manage registered namespaces`,
20428
+ ` ${import_chalk3.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
20429
+ ` ${import_chalk3.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
20430
+ ` ${import_chalk3.default.gray(" create <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
20129
20431
  ` ${import_chalk3.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
20130
20432
  ` ${import_chalk3.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
20131
20433
  ` ${import_chalk3.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
@@ -20198,7 +20500,7 @@ function parseCommandArgs(args) {
20198
20500
  const token = rest.shift();
20199
20501
  switch (token) {
20200
20502
  case "--app":
20201
- app = requireValue4(rest, token);
20503
+ app = requireValue5(rest, token);
20202
20504
  break;
20203
20505
  default:
20204
20506
  throw new Error(`Unknown login option: ${token}`);
@@ -20263,6 +20565,9 @@ function parseCommandArgs(args) {
20263
20565
  if (args.rest[0] === "agent") {
20264
20566
  return parseAgentArgs(args.rest.slice(1));
20265
20567
  }
20568
+ if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
20569
+ return parseNsArgs(args.rest.slice(1));
20570
+ }
20266
20571
  if (args.rest[0] === "store") {
20267
20572
  return parseStoreArgs(args.rest.slice(1));
20268
20573
  }
@@ -20286,7 +20591,7 @@ function parseVercelArgs(tokens) {
20286
20591
  const token = rest.shift();
20287
20592
  switch (token) {
20288
20593
  case "--scope":
20289
- scope = requireValue4(rest, token);
20594
+ scope = requireValue5(rest, token);
20290
20595
  break;
20291
20596
  default:
20292
20597
  throw new Error(`Unknown vercel option: ${token}`);
@@ -20306,10 +20611,10 @@ function parseVercelArgs(tokens) {
20306
20611
  const token = rest.shift();
20307
20612
  switch (token) {
20308
20613
  case "--scope":
20309
- scope = requireValue4(rest, token);
20614
+ scope = requireValue5(rest, token);
20310
20615
  break;
20311
20616
  case "--project":
20312
- project = requireValue4(rest, token);
20617
+ project = requireValue5(rest, token);
20313
20618
  break;
20314
20619
  case "--last-week":
20315
20620
  lastWeek = true;
@@ -20340,16 +20645,16 @@ function parseAddDnsArgs(tokens) {
20340
20645
  const token = rest.shift();
20341
20646
  switch (token) {
20342
20647
  case "--type":
20343
- options.dnsType = requireValue4(rest, token);
20648
+ options.dnsType = requireValue5(rest, token);
20344
20649
  break;
20345
20650
  case "--value":
20346
- options.dnsValue = requireValue4(rest, token);
20651
+ options.dnsValue = requireValue5(rest, token);
20347
20652
  break;
20348
20653
  case "--rr":
20349
- options.dnsRr = requireValue4(rest, token);
20654
+ options.dnsRr = requireValue5(rest, token);
20350
20655
  break;
20351
20656
  case "--ttl": {
20352
- const ttlValue = requireValue4(rest, token);
20657
+ const ttlValue = requireValue5(rest, token);
20353
20658
  const ttl = Number.parseInt(ttlValue, 10);
20354
20659
  if (!Number.isFinite(ttl) || ttl <= 0) {
20355
20660
  throw new Error(`Invalid --ttl value: ${ttlValue}`);
@@ -20358,7 +20663,7 @@ function parseAddDnsArgs(tokens) {
20358
20663
  break;
20359
20664
  }
20360
20665
  case "--domain":
20361
- options.dnsDomain = requireValue4(rest, token);
20666
+ options.dnsDomain = requireValue5(rest, token);
20362
20667
  break;
20363
20668
  default:
20364
20669
  throw new Error(`Unknown add-dns option: ${token}`);
@@ -20379,7 +20684,9 @@ function parseAddDnsArgs(tokens) {
20379
20684
  function parseBucketArgs(tokens) {
20380
20685
  const options = {
20381
20686
  bucketCreate: false,
20382
- bucketName: ""
20687
+ bucketName: "",
20688
+ bucketSubdomain: void 0,
20689
+ bucketDomain: void 0
20383
20690
  };
20384
20691
  const rest = [...tokens];
20385
20692
  while (rest.length > 0) {
@@ -20389,7 +20696,13 @@ function parseBucketArgs(tokens) {
20389
20696
  options.bucketCreate = true;
20390
20697
  break;
20391
20698
  case "--name":
20392
- options.bucketName = requireValue4(rest, token);
20699
+ options.bucketName = requireValue5(rest, token);
20700
+ break;
20701
+ case "--subdomain":
20702
+ options.bucketSubdomain = requireValue5(rest, token);
20703
+ break;
20704
+ case "--domain":
20705
+ options.bucketDomain = requireValue5(rest, token);
20393
20706
  break;
20394
20707
  default:
20395
20708
  throw new Error(`Unknown bucket option: ${token}`);
@@ -20401,6 +20714,9 @@ function parseBucketArgs(tokens) {
20401
20714
  if (!options.bucketName.trim()) {
20402
20715
  throw new Error("Missing bucket name. Use --name <bucket>.");
20403
20716
  }
20717
+ if (options.bucketSubdomain && !options.bucketDomain?.trim()) {
20718
+ throw new Error("Missing domain name. Use --domain <name> when --subdomain is set.");
20719
+ }
20404
20720
  return { type: "bucket" /* Bucket */, ...options };
20405
20721
  }
20406
20722
  function parseDeployArgs(tokens) {
@@ -20425,7 +20741,7 @@ function parseDeployArgs(tokens) {
20425
20741
  options.deployAction = "logs";
20426
20742
  break;
20427
20743
  case "--cwd":
20428
- options.deployCwd = requireValue4(rest, token);
20744
+ options.deployCwd = requireValue5(rest, token);
20429
20745
  break;
20430
20746
  default:
20431
20747
  throw new Error(`Unknown deploy option: ${token}`);
@@ -20450,13 +20766,13 @@ function parseLogArgs(tokens) {
20450
20766
  const token = rest.shift();
20451
20767
  switch (token) {
20452
20768
  case "--cwd":
20453
- options.logCwd = requireValue4(rest, token);
20769
+ options.logCwd = requireValue5(rest, token);
20454
20770
  break;
20455
20771
  case "--ns":
20456
- options.logNamespace = requireValue4(rest, token);
20772
+ options.logNamespace = requireValue5(rest, token);
20457
20773
  break;
20458
20774
  case "--page": {
20459
- const value = requireValue4(rest, token);
20775
+ const value = requireValue5(rest, token);
20460
20776
  const page = Number.parseInt(value, 10);
20461
20777
  if (!Number.isFinite(page) || page < 0) {
20462
20778
  throw new Error(`Invalid log page: ${value}`);
@@ -20468,7 +20784,7 @@ function parseLogArgs(tokens) {
20468
20784
  options.logHistory = true;
20469
20785
  break;
20470
20786
  case "--search":
20471
- options.logSearch = requireValue4(rest, token);
20787
+ options.logSearch = requireValue5(rest, token);
20472
20788
  break;
20473
20789
  default:
20474
20790
  throw new Error(`Unknown log option: ${token}`);
@@ -20491,7 +20807,7 @@ function parseInitArgs(tokens) {
20491
20807
  const token = rest.shift();
20492
20808
  switch (token) {
20493
20809
  case "--cwd":
20494
- options.initCwd = requireValue4(rest, token);
20810
+ options.initCwd = requireValue5(rest, token);
20495
20811
  break;
20496
20812
  default:
20497
20813
  throw new Error(`Unknown init option: ${token}`);
@@ -20514,7 +20830,7 @@ function parseDevArgs(tokens) {
20514
20830
  const token = rest.shift();
20515
20831
  switch (token) {
20516
20832
  case "--cwd":
20517
- options.devCwd = requireValue4(rest, token);
20833
+ options.devCwd = requireValue5(rest, token);
20518
20834
  break;
20519
20835
  default:
20520
20836
  throw new Error(`Unknown dev option: ${token}`);
@@ -20544,13 +20860,13 @@ function parseOssArgs(tokens) {
20544
20860
  const token = rest.shift();
20545
20861
  switch (token) {
20546
20862
  case "--bucket":
20547
- bucket = requireValue4(rest, token);
20863
+ bucket = requireValue5(rest, token);
20548
20864
  break;
20549
20865
  case "--file":
20550
- filePath = requireValue4(rest, token);
20866
+ filePath = requireValue5(rest, token);
20551
20867
  break;
20552
20868
  case "--key":
20553
- objectKey = requireValue4(rest, token);
20869
+ objectKey = requireValue5(rest, token);
20554
20870
  break;
20555
20871
  default:
20556
20872
  throw new Error(`Unknown oss option: ${token}`);
@@ -20583,7 +20899,7 @@ function parseEnvArgs(tokens) {
20583
20899
  throw new Error("Only one env action is allowed.");
20584
20900
  }
20585
20901
  action = "set";
20586
- key = requireValue4(rest, token);
20902
+ key = requireValue5(rest, token);
20587
20903
  break;
20588
20904
  case "--list":
20589
20905
  if (action) {
@@ -20596,17 +20912,17 @@ function parseEnvArgs(tokens) {
20596
20912
  throw new Error("Only one env action is allowed.");
20597
20913
  }
20598
20914
  action = "delete";
20599
- key = requireValue4(rest, token);
20915
+ key = requireValue5(rest, token);
20600
20916
  break;
20601
20917
  case "--value":
20602
- value = requireValue4(rest, token);
20918
+ value = requireValue5(rest, token);
20603
20919
  break;
20604
20920
  case "--verbose":
20605
20921
  case "-v":
20606
20922
  verbose = true;
20607
20923
  break;
20608
20924
  case "--cwd":
20609
- cwd = requireValue4(rest, token);
20925
+ cwd = requireValue5(rest, token);
20610
20926
  break;
20611
20927
  default:
20612
20928
  throw new Error(`Unknown env option: ${token}`);
@@ -20664,7 +20980,7 @@ function parseCommitArgs(tokens) {
20664
20980
  push = true;
20665
20981
  break;
20666
20982
  case "--cwd":
20667
- cwd = requireValue4(rest, token);
20983
+ cwd = requireValue5(rest, token);
20668
20984
  break;
20669
20985
  default:
20670
20986
  throw new Error(`Unknown commit option: ${token}`);
@@ -20680,10 +20996,10 @@ function parseSummaryArgs(tokens) {
20680
20996
  const token = rest.shift();
20681
20997
  switch (token) {
20682
20998
  case "--pr":
20683
- prRef = requireValue4(rest, token);
20999
+ prRef = requireValue5(rest, token);
20684
21000
  break;
20685
21001
  case "--cwd":
20686
- cwd = requireValue4(rest, token);
21002
+ cwd = requireValue5(rest, token);
20687
21003
  break;
20688
21004
  default:
20689
21005
  throw new Error(`Unknown summary option: ${token}`);
@@ -20752,10 +21068,10 @@ function parseLinearPrArgs(tokens) {
20752
21068
  const token = rest.shift();
20753
21069
  switch (token) {
20754
21070
  case "--account":
20755
- account = requireValue4(rest, token);
21071
+ account = requireValue5(rest, token);
20756
21072
  break;
20757
21073
  case "--cwd":
20758
- cwd = requireValue4(rest, token);
21074
+ cwd = requireValue5(rest, token);
20759
21075
  break;
20760
21076
  default:
20761
21077
  throw new Error(`Unknown linear option: ${token}`);
@@ -20784,35 +21100,35 @@ function parseLinearCreateArgs(tokens) {
20784
21100
  const token = rest.shift();
20785
21101
  switch (token) {
20786
21102
  case "--account":
20787
- account = requireValue4(rest, token);
21103
+ account = requireValue5(rest, token);
20788
21104
  break;
20789
21105
  case "--repl":
20790
21106
  useRepl = true;
20791
21107
  break;
20792
21108
  case "--title":
20793
- title = requireValue4(rest, token);
21109
+ title = requireValue5(rest, token);
20794
21110
  break;
20795
21111
  case "--desc":
20796
21112
  case "--description":
20797
- description = decodeEscapedNewlines(requireValue4(rest, token));
21113
+ description = decodeEscapedNewlines(requireValue5(rest, token));
20798
21114
  break;
20799
21115
  case "--team-id":
20800
- teamId = requireValue4(rest, token);
21116
+ teamId = requireValue5(rest, token);
20801
21117
  break;
20802
21118
  case "--team-key":
20803
- teamKey = requireValue4(rest, token);
21119
+ teamKey = requireValue5(rest, token);
20804
21120
  break;
20805
21121
  case "--priority":
20806
- priority = parseLinearPriority(requireValue4(rest, token));
21122
+ priority = parseLinearPriority(requireValue5(rest, token));
20807
21123
  break;
20808
21124
  case "--parent-id":
20809
- parentId = requireValue4(rest, token);
21125
+ parentId = requireValue5(rest, token);
20810
21126
  break;
20811
21127
  case "--state-id":
20812
- stateId = requireValue4(rest, token);
21128
+ stateId = requireValue5(rest, token);
20813
21129
  break;
20814
21130
  case "--cwd":
20815
- cwd = requireValue4(rest, token);
21131
+ cwd = requireValue5(rest, token);
20816
21132
  break;
20817
21133
  default:
20818
21134
  throw new Error(`Unknown linear option: ${token}`);
@@ -20847,10 +21163,10 @@ function parseLinearWhoamiArgs(tokens) {
20847
21163
  const token = rest.shift();
20848
21164
  switch (token) {
20849
21165
  case "--account":
20850
- account = requireValue4(rest, token);
21166
+ account = requireValue5(rest, token);
20851
21167
  break;
20852
21168
  case "--cwd":
20853
- cwd = requireValue4(rest, token);
21169
+ cwd = requireValue5(rest, token);
20854
21170
  break;
20855
21171
  default:
20856
21172
  throw new Error(`Unknown linear option: ${token}`);
@@ -20875,10 +21191,10 @@ function parseLinearViewArgs(tokens) {
20875
21191
  const token = rest.shift();
20876
21192
  switch (token) {
20877
21193
  case "--account":
20878
- account = requireValue4(rest, token);
21194
+ account = requireValue5(rest, token);
20879
21195
  break;
20880
21196
  case "--cwd":
20881
- cwd = requireValue4(rest, token);
21197
+ cwd = requireValue5(rest, token);
20882
21198
  break;
20883
21199
  default:
20884
21200
  throw new Error(`Unknown linear option: ${token}`);
@@ -20913,32 +21229,32 @@ function parseLinearUpdateArgs(tokens) {
20913
21229
  const token = rest.shift();
20914
21230
  switch (token) {
20915
21231
  case "--account":
20916
- account = requireValue4(rest, token);
21232
+ account = requireValue5(rest, token);
20917
21233
  break;
20918
21234
  case "--title":
20919
- title = requireValue4(rest, token);
21235
+ title = requireValue5(rest, token);
20920
21236
  break;
20921
21237
  case "--desc":
20922
21238
  case "--description":
20923
- description = decodeEscapedNewlines(requireValue4(rest, token));
21239
+ description = decodeEscapedNewlines(requireValue5(rest, token));
20924
21240
  break;
20925
21241
  case "--team-id":
20926
- teamId = requireValue4(rest, token);
21242
+ teamId = requireValue5(rest, token);
20927
21243
  break;
20928
21244
  case "--team-key":
20929
- teamKey = requireValue4(rest, token);
21245
+ teamKey = requireValue5(rest, token);
20930
21246
  break;
20931
21247
  case "--priority":
20932
- priority = parseLinearPriority(requireValue4(rest, token));
21248
+ priority = parseLinearPriority(requireValue5(rest, token));
20933
21249
  break;
20934
21250
  case "--parent-id":
20935
- parentId = requireValue4(rest, token);
21251
+ parentId = requireValue5(rest, token);
20936
21252
  break;
20937
21253
  case "--state-id":
20938
- stateId = requireValue4(rest, token);
21254
+ stateId = requireValue5(rest, token);
20939
21255
  break;
20940
21256
  case "--cwd":
20941
- cwd = requireValue4(rest, token);
21257
+ cwd = requireValue5(rest, token);
20942
21258
  break;
20943
21259
  default:
20944
21260
  throw new Error(`Unknown linear option: ${token}`);
@@ -20976,10 +21292,10 @@ function parseLinearSubIssuesArgs(tokens) {
20976
21292
  const token = rest.shift();
20977
21293
  switch (token) {
20978
21294
  case "--account":
20979
- account = requireValue4(rest, token);
21295
+ account = requireValue5(rest, token);
20980
21296
  break;
20981
21297
  case "--cwd":
20982
- cwd = requireValue4(rest, token);
21298
+ cwd = requireValue5(rest, token);
20983
21299
  break;
20984
21300
  default:
20985
21301
  throw new Error(`Unknown linear option: ${token}`);
@@ -21006,15 +21322,15 @@ function parseLinearCommentArgs(tokens) {
21006
21322
  const token = rest.shift();
21007
21323
  switch (token) {
21008
21324
  case "--account":
21009
- account = requireValue4(rest, token);
21325
+ account = requireValue5(rest, token);
21010
21326
  break;
21011
21327
  case "--body":
21012
21328
  case "--desc":
21013
21329
  case "--description":
21014
- body = decodeEscapedNewlines(requireValue4(rest, token));
21330
+ body = decodeEscapedNewlines(requireValue5(rest, token));
21015
21331
  break;
21016
21332
  case "--cwd":
21017
- cwd = requireValue4(rest, token);
21333
+ cwd = requireValue5(rest, token);
21018
21334
  break;
21019
21335
  default:
21020
21336
  throw new Error(`Unknown linear option: ${token}`);
@@ -21044,10 +21360,10 @@ function parseLinearCommentsArgs(tokens) {
21044
21360
  const token = rest.shift();
21045
21361
  switch (token) {
21046
21362
  case "--account":
21047
- account = requireValue4(rest, token);
21363
+ account = requireValue5(rest, token);
21048
21364
  break;
21049
21365
  case "--cwd":
21050
- cwd = requireValue4(rest, token);
21366
+ cwd = requireValue5(rest, token);
21051
21367
  break;
21052
21368
  default:
21053
21369
  throw new Error(`Unknown linear option: ${token}`);
@@ -21071,16 +21387,16 @@ function parseLinearCycleArgs(tokens) {
21071
21387
  const token = rest.shift();
21072
21388
  switch (token) {
21073
21389
  case "--account":
21074
- account = requireValue4(rest, token);
21390
+ account = requireValue5(rest, token);
21075
21391
  break;
21076
21392
  case "--team-id":
21077
- teamId = requireValue4(rest, token);
21393
+ teamId = requireValue5(rest, token);
21078
21394
  break;
21079
21395
  case "--team-key":
21080
- teamKey = requireValue4(rest, token);
21396
+ teamKey = requireValue5(rest, token);
21081
21397
  break;
21082
21398
  case "--cwd":
21083
- cwd = requireValue4(rest, token);
21399
+ cwd = requireValue5(rest, token);
21084
21400
  break;
21085
21401
  default:
21086
21402
  throw new Error(`Unknown linear option: ${token}`);
@@ -21103,10 +21419,10 @@ function parseLinearTeamsArgs(tokens) {
21103
21419
  const token = rest.shift();
21104
21420
  switch (token) {
21105
21421
  case "--account":
21106
- account = requireValue4(rest, token);
21422
+ account = requireValue5(rest, token);
21107
21423
  break;
21108
21424
  case "--cwd":
21109
- cwd = requireValue4(rest, token);
21425
+ cwd = requireValue5(rest, token);
21110
21426
  break;
21111
21427
  default:
21112
21428
  throw new Error(`Unknown linear option: ${token}`);
@@ -21133,16 +21449,16 @@ function parseLinearUserIssuesArgs(tokens) {
21133
21449
  const token = rest.shift();
21134
21450
  switch (token) {
21135
21451
  case "--account":
21136
- account = requireValue4(rest, token);
21452
+ account = requireValue5(rest, token);
21137
21453
  break;
21138
21454
  case "--cycle":
21139
- cycle = parseLinearCycle(requireValue4(rest, token));
21455
+ cycle = parseLinearCycle(requireValue5(rest, token));
21140
21456
  break;
21141
21457
  case "--status":
21142
- status = parseLinearStatus(requireValue4(rest, token));
21458
+ status = parseLinearStatus(requireValue5(rest, token));
21143
21459
  break;
21144
21460
  case "--cwd":
21145
- cwd = requireValue4(rest, token);
21461
+ cwd = requireValue5(rest, token);
21146
21462
  break;
21147
21463
  default:
21148
21464
  throw new Error(`Unknown linear option: ${token}`);
@@ -21176,28 +21492,28 @@ function parseLinearIssuesArgs(tokens) {
21176
21492
  const token = rest.shift();
21177
21493
  switch (token) {
21178
21494
  case "--account":
21179
- account = requireValue4(rest, token);
21495
+ account = requireValue5(rest, token);
21180
21496
  break;
21181
21497
  case "--team-id":
21182
- teamId = requireValue4(rest, token);
21498
+ teamId = requireValue5(rest, token);
21183
21499
  break;
21184
21500
  case "--team-key":
21185
- teamKey = requireValue4(rest, token);
21501
+ teamKey = requireValue5(rest, token);
21186
21502
  break;
21187
21503
  case "--user":
21188
- user = requireValue4(rest, token);
21504
+ user = requireValue5(rest, token);
21189
21505
  break;
21190
21506
  case "--cycle":
21191
- cycle = parseLinearCycle(requireValue4(rest, token));
21507
+ cycle = parseLinearCycle(requireValue5(rest, token));
21192
21508
  break;
21193
21509
  case "--status":
21194
- status = parseLinearStatus(requireValue4(rest, token));
21510
+ status = parseLinearStatus(requireValue5(rest, token));
21195
21511
  break;
21196
21512
  case "--query":
21197
- query = requireValue4(rest, token).trim();
21513
+ query = requireValue5(rest, token).trim();
21198
21514
  break;
21199
21515
  case "--limit": {
21200
- const value = Number.parseInt(requireValue4(rest, token), 10);
21516
+ const value = Number.parseInt(requireValue5(rest, token), 10);
21201
21517
  if (!Number.isInteger(value) || value < 1 || value > 250) {
21202
21518
  throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
21203
21519
  }
@@ -21205,7 +21521,7 @@ function parseLinearIssuesArgs(tokens) {
21205
21521
  break;
21206
21522
  }
21207
21523
  case "--cwd":
21208
- cwd = requireValue4(rest, token);
21524
+ cwd = requireValue5(rest, token);
21209
21525
  break;
21210
21526
  default:
21211
21527
  throw new Error(`Unknown linear option: ${token}`);
@@ -21246,10 +21562,10 @@ function parseLinearLegacyArgs(tokens) {
21246
21562
  useScreenshot = true;
21247
21563
  break;
21248
21564
  case "--account":
21249
- account = requireValue4(rest, token);
21565
+ account = requireValue5(rest, token);
21250
21566
  break;
21251
21567
  case "--cwd":
21252
- cwd = requireValue4(rest, token);
21568
+ cwd = requireValue5(rest, token);
21253
21569
  break;
21254
21570
  default:
21255
21571
  throw new Error(`Unknown linear option: ${token}`);
@@ -21343,19 +21659,19 @@ function parseNotionArgs(tokens) {
21343
21659
  const token = rest.shift();
21344
21660
  switch (token) {
21345
21661
  case "--parent":
21346
- parentPageId = requireValue4(rest, token);
21662
+ parentPageId = requireValue5(rest, token);
21347
21663
  break;
21348
21664
  case "--title":
21349
- title = requireValue4(rest, token);
21665
+ title = requireValue5(rest, token);
21350
21666
  break;
21351
21667
  case "--private":
21352
21668
  isPrivate = true;
21353
21669
  break;
21354
21670
  case "--content":
21355
- content2 = requireValue4(rest, token);
21671
+ content2 = requireValue5(rest, token);
21356
21672
  break;
21357
21673
  case "--file":
21358
- filePath2 = requireValue4(rest, token);
21674
+ filePath2 = requireValue5(rest, token);
21359
21675
  break;
21360
21676
  default:
21361
21677
  throw new Error(`Unknown notion option: ${token}`);
@@ -21399,10 +21715,10 @@ function parseNotionArgs(tokens) {
21399
21715
  const token = rest.shift();
21400
21716
  switch (token) {
21401
21717
  case "--content":
21402
- content = requireValue4(rest, token);
21718
+ content = requireValue5(rest, token);
21403
21719
  break;
21404
21720
  case "--file":
21405
- filePath = requireValue4(rest, token);
21721
+ filePath = requireValue5(rest, token);
21406
21722
  break;
21407
21723
  case "--append":
21408
21724
  append = true;
@@ -21447,11 +21763,11 @@ function parseRandomArgs(tokens) {
21447
21763
  mode = "easy";
21448
21764
  break;
21449
21765
  case "--length":
21450
- length = parsePositiveInt(requireValue4(rest, token), token);
21766
+ length = parsePositiveInt(requireValue5(rest, token), token);
21451
21767
  seenLength = true;
21452
21768
  break;
21453
21769
  case "--charset": {
21454
- const value = requireValue4(rest, token);
21770
+ const value = requireValue5(rest, token);
21455
21771
  if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
21456
21772
  throw new Error(
21457
21773
  `Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
@@ -21462,18 +21778,18 @@ function parseRandomArgs(tokens) {
21462
21778
  break;
21463
21779
  }
21464
21780
  case "--count":
21465
- count = parsePositiveInt(requireValue4(rest, token), token);
21781
+ count = parsePositiveInt(requireValue5(rest, token), token);
21466
21782
  break;
21467
21783
  case "--words":
21468
- words = parsePositiveInt(requireValue4(rest, token), token);
21784
+ words = parsePositiveInt(requireValue5(rest, token), token);
21469
21785
  seenWords = true;
21470
21786
  break;
21471
21787
  case "--digits":
21472
- digits = parseNonNegativeInt(requireValue4(rest, token), token);
21788
+ digits = parseNonNegativeInt(requireValue5(rest, token), token);
21473
21789
  seenDigits = true;
21474
21790
  break;
21475
21791
  case "--separator":
21476
- separator = requireValue4(rest, token);
21792
+ separator = requireValue5(rest, token);
21477
21793
  seenSeparator = true;
21478
21794
  break;
21479
21795
  default:
@@ -21516,7 +21832,7 @@ function parseCollectArgs(tokens) {
21516
21832
  const token = rest.shift();
21517
21833
  switch (token) {
21518
21834
  case "--endpoint":
21519
- options.endpoint = requireValue4(rest, token);
21835
+ options.endpoint = requireValue5(rest, token);
21520
21836
  break;
21521
21837
  case "--json":
21522
21838
  options.json = true;
@@ -21526,7 +21842,7 @@ function parseCollectArgs(tokens) {
21526
21842
  break;
21527
21843
  case "--thread":
21528
21844
  options.mode = "thread";
21529
- options.threadName = requireValue4(rest, token);
21845
+ options.threadName = requireValue5(rest, token);
21530
21846
  break;
21531
21847
  default:
21532
21848
  throw new Error(`Unknown collect option: ${token}`);
@@ -21537,7 +21853,7 @@ function parseCollectArgs(tokens) {
21537
21853
  }
21538
21854
  return { type: "collect" /* Collect */, ...options };
21539
21855
  }
21540
- function requireValue4(tokens, optionName) {
21856
+ function requireValue5(tokens, optionName) {
21541
21857
  const value = tokens.shift();
21542
21858
  if (!value) {
21543
21859
  throw new Error(`Missing value for ${optionName}`);
@@ -21678,6 +21994,11 @@ async function main() {
21678
21994
  await handler.handle(commandArgs);
21679
21995
  return;
21680
21996
  }
21997
+ case "ns" /* Ns */: {
21998
+ const handler = new NsCommandHandler();
21999
+ await handler.handle(commandArgs);
22000
+ return;
22001
+ }
21681
22002
  case "store" /* Store */: {
21682
22003
  const handler = new StoreCommandHandler();
21683
22004
  await handler.handle(commandArgs);