@pmate/cli 0.14.0 → 0.15.0

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
@@ -12612,8 +12612,8 @@ __export(index_exports, {
12612
12612
  parseCommandArgs: () => parseCommandArgs
12613
12613
  });
12614
12614
  module.exports = __toCommonJS(index_exports);
12615
- var import_node_fs14 = require("fs");
12616
- var import_node_path19 = __toESM(require("path"));
12615
+ var import_node_fs15 = require("fs");
12616
+ var import_node_path20 = __toESM(require("path"));
12617
12617
  var import_chalk3 = __toESM(require("chalk"));
12618
12618
 
12619
12619
  // src/cli.ts
@@ -17890,9 +17890,9 @@ ${indent}\`\`\``;
17890
17890
  static richTextToPlain(richText) {
17891
17891
  return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
17892
17892
  }
17893
- static async requestJson(path20, init) {
17893
+ static async requestJson(path21, init) {
17894
17894
  const token = this.getToken();
17895
- const response = await fetch(`${this.baseUrl}${path20}`, {
17895
+ const response = await fetch(`${this.baseUrl}${path21}`, {
17896
17896
  method: init.method,
17897
17897
  headers: {
17898
17898
  Authorization: `Bearer ${token}`,
@@ -18940,9 +18940,406 @@ var AgentCommandHandler = class {
18940
18940
  }
18941
18941
  };
18942
18942
 
18943
- // src/commands/AppCommandHandler.ts
18943
+ // src/commands/StoreCommandHandler.ts
18944
18944
  var import_node_fs13 = require("fs");
18945
18945
  var import_node_path18 = __toESM(require("path"));
18946
+
18947
+ // src/storeClient.ts
18948
+ var STORE_LOG_VERSION = 1;
18949
+ var LOG_KIND_TABLE = 1e4;
18950
+ var LOG_KIND_MAPPING = 6003;
18951
+ function createHash3() {
18952
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
18953
+ }
18954
+ function createDescriptor(input) {
18955
+ for (const [label, value] of Object.entries({
18956
+ chain: input.chain,
18957
+ namespace: input.ns,
18958
+ kind: input.kind,
18959
+ name: input.name
18960
+ })) {
18961
+ if (!value || value.includes("/")) {
18962
+ throw new Error(`Invalid ${label} "${value}". ${label} must be non-empty and cannot contain "/".`);
18963
+ }
18964
+ }
18965
+ return { ...input };
18966
+ }
18967
+ function descriptorToTopic(descriptor) {
18968
+ const normalized = createDescriptor(descriptor);
18969
+ return `@${normalized.ns}/${normalized.name}`;
18970
+ }
18971
+ function descriptorPathSegments(descriptor) {
18972
+ const normalized = createDescriptor(descriptor);
18973
+ return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
18974
+ }
18975
+ function buildPathUrl(baseUrl, pathSegments, query) {
18976
+ const path21 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
18977
+ const url = new URL(path21, baseUrl);
18978
+ if (query) {
18979
+ for (const [key, value] of Object.entries(query)) {
18980
+ url.searchParams.set(key, String(value));
18981
+ }
18982
+ }
18983
+ return url.toString();
18984
+ }
18985
+ async function requestJson(url, init, fallbackMessage) {
18986
+ const response = await fetch(url, init);
18987
+ const payload = await response.json();
18988
+ if (!response.ok || !payload?.success) {
18989
+ throw new Error(payload?.message || `${fallbackMessage}: ${response.status}`);
18990
+ }
18991
+ return payload;
18992
+ }
18993
+ var IndexerClient = class {
18994
+ constructor(baseUrl) {
18995
+ this.baseUrl = baseUrl;
18996
+ }
18997
+ async requestByPath(pathSegments, options = {}) {
18998
+ const method = options.method ?? "GET";
18999
+ const url = buildPathUrl(this.baseUrl, pathSegments, method === "GET" ? options.query : void 0);
19000
+ const payload = await requestJson(
19001
+ url,
19002
+ {
19003
+ method,
19004
+ headers: {
19005
+ Accept: "application/json",
19006
+ ...method === "POST" ? { "Content-Type": "application/json" } : {}
19007
+ },
19008
+ ...method === "POST" ? { body: JSON.stringify(options.query ?? {}) } : {}
19009
+ },
19010
+ "Indexer request failed"
19011
+ );
19012
+ return payload.data;
19013
+ }
19014
+ };
19015
+ var BlockLogAppender = class {
19016
+ constructor(chainId, baseUrl) {
19017
+ this.chainId = chainId;
19018
+ this.baseUrl = baseUrl;
19019
+ }
19020
+ async append(logs) {
19021
+ if (!logs.length) return;
19022
+ const url = `${this.baseUrl.replace(/\/+$/, "")}/chains/${encodeURIComponent(this.chainId)}/logs`;
19023
+ await fetch(url, {
19024
+ method: "POST",
19025
+ headers: {
19026
+ "Content-Type": "application/json",
19027
+ ...process.env.TSDB_BEARER_TOKEN ? { authorization: `Bearer ${process.env.TSDB_BEARER_TOKEN}` } : {}
19028
+ },
19029
+ body: JSON.stringify({ logs })
19030
+ }).then(async (response) => {
19031
+ if (!response.ok) {
19032
+ throw new Error(`TSDB request failed: ${response.status} ${response.statusText}`);
19033
+ }
19034
+ });
19035
+ }
19036
+ };
19037
+ var Namespace = class {
19038
+ constructor(options) {
19039
+ this.options = options;
19040
+ this.appender = new BlockLogAppender(options.chain, options.baseUrl.replace(/\/+$/, ""));
19041
+ this.indexerClient = new IndexerClient(options.indexerBaseUrl.replace(/\/+$/, ""));
19042
+ }
19043
+ table(name) {
19044
+ const descriptor = createDescriptor({
19045
+ chain: this.options.chain,
19046
+ ns: this.options.ns,
19047
+ kind: "table",
19048
+ name
19049
+ });
19050
+ return {
19051
+ list: async (pageNo = 0) => {
19052
+ const data = await this.indexerClient.requestByPath(
19053
+ [...descriptorPathSegments(descriptor), "page"],
19054
+ { query: { page_id: pageNo } }
19055
+ );
19056
+ if (!data) return [];
19057
+ if (Array.isArray(data)) return data;
19058
+ return Array.isArray(data.data) ? data.data : [];
19059
+ },
19060
+ getById: async (id) => {
19061
+ const data = await this.indexerClient.requestByPath(
19062
+ [...descriptorPathSegments(descriptor), "get_by_id"],
19063
+ { query: { id } }
19064
+ );
19065
+ return data ?? void 0;
19066
+ },
19067
+ exists: async (id) => {
19068
+ const data = await this.indexerClient.requestByPath(
19069
+ [...descriptorPathSegments(descriptor), "exists"],
19070
+ { query: { id } }
19071
+ );
19072
+ return Boolean(data);
19073
+ },
19074
+ appendRow: async (data) => {
19075
+ const log = {
19076
+ hash: createHash3(),
19077
+ t: Date.now(),
19078
+ kind: LOG_KIND_TABLE,
19079
+ topic: descriptorToTopic(descriptor),
19080
+ v: STORE_LOG_VERSION,
19081
+ data: { type: "create", after: data }
19082
+ };
19083
+ await this.appender.append([log]);
19084
+ },
19085
+ updateRow: async (data) => {
19086
+ const { id, ...value } = data;
19087
+ const log = {
19088
+ hash: createHash3(),
19089
+ t: Date.now(),
19090
+ kind: LOG_KIND_TABLE,
19091
+ topic: descriptorToTopic(descriptor),
19092
+ v: STORE_LOG_VERSION,
19093
+ data: { type: "update", id, value }
19094
+ };
19095
+ await this.appender.append([log]);
19096
+ },
19097
+ deleteRow: async (id) => {
19098
+ const log = {
19099
+ hash: createHash3(),
19100
+ t: Date.now(),
19101
+ kind: LOG_KIND_TABLE,
19102
+ topic: descriptorToTopic(descriptor),
19103
+ v: STORE_LOG_VERSION,
19104
+ data: { type: "delete", id }
19105
+ };
19106
+ await this.appender.append([log]);
19107
+ }
19108
+ };
19109
+ }
19110
+ kv(name) {
19111
+ const descriptor = createDescriptor({
19112
+ chain: this.options.chain,
19113
+ ns: this.options.ns,
19114
+ kind: "kv",
19115
+ name
19116
+ });
19117
+ return {
19118
+ list: async (pageNo = 0) => {
19119
+ const data = await this.indexerClient.requestByPath([...descriptorPathSegments(descriptor), "page"], {
19120
+ query: { page_id: pageNo }
19121
+ });
19122
+ if (!data) return [];
19123
+ if (Array.isArray(data)) return data;
19124
+ return Array.isArray(data.data) ? data.data : [];
19125
+ },
19126
+ get: async (key) => {
19127
+ const data = await this.indexerClient.requestByPath(
19128
+ [...descriptorPathSegments(descriptor), "get"],
19129
+ { query: { key } }
19130
+ );
19131
+ return data ?? void 0;
19132
+ },
19133
+ exists: async (key) => {
19134
+ const data = await this.indexerClient.requestByPath(
19135
+ [...descriptorPathSegments(descriptor), "exists"],
19136
+ { query: { key } }
19137
+ );
19138
+ return Boolean(data);
19139
+ },
19140
+ set: async (key, value) => {
19141
+ const log = {
19142
+ hash: createHash3(),
19143
+ t: Date.now(),
19144
+ kind: LOG_KIND_MAPPING,
19145
+ topic: descriptorToTopic(descriptor),
19146
+ v: STORE_LOG_VERSION,
19147
+ data: { key, value }
19148
+ };
19149
+ await this.appender.append([log]);
19150
+ },
19151
+ delete: async (key) => {
19152
+ const log = {
19153
+ hash: createHash3(),
19154
+ t: Date.now(),
19155
+ kind: LOG_KIND_MAPPING,
19156
+ topic: descriptorToTopic(descriptor),
19157
+ v: STORE_LOG_VERSION,
19158
+ data: { key, value: null }
19159
+ };
19160
+ await this.appender.append([log]);
19161
+ }
19162
+ };
19163
+ }
19164
+ };
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;
19192
+ }
19193
+ case "exists": {
19194
+ const exists = await table.exists(args.id);
19195
+ this.renderValue(exists, args.json);
19196
+ return;
19197
+ }
19198
+ case "delete": {
19199
+ await table.deleteRow(args.id);
19200
+ ui.success(`Deleted row ${args.name}/${args.id}`);
19201
+ return;
19202
+ }
19203
+ case "create": {
19204
+ const payload = this.readJsonFile(args.filePath);
19205
+ await table.appendRow(payload);
19206
+ ui.success(`Created row in ${args.name}`, { filePath: args.filePath });
19207
+ return;
19208
+ }
19209
+ case "update": {
19210
+ const payload = this.readJsonFile(args.filePath);
19211
+ await table.updateRow(payload);
19212
+ ui.success(`Updated row in ${args.name}`, { filePath: args.filePath });
19213
+ return;
19214
+ }
19215
+ }
19216
+ }
19217
+ const kv = namespace.kv(args.name);
19218
+ switch (args.action) {
19219
+ case "list": {
19220
+ const rows = await kv.list(args.page);
19221
+ this.renderJsonOrSummary(
19222
+ rows,
19223
+ args.json,
19224
+ "No kv entries found.",
19225
+ (row) => row.key
19226
+ );
19227
+ return;
19228
+ }
19229
+ case "get": {
19230
+ const value = await kv.get(args.key);
19231
+ this.renderValue(value, args.json);
19232
+ return;
19233
+ }
19234
+ case "exists": {
19235
+ const exists = await kv.exists(args.key);
19236
+ this.renderValue(exists, args.json);
19237
+ return;
19238
+ }
19239
+ case "delete": {
19240
+ await kv.delete(args.key);
19241
+ ui.success(`Deleted key ${args.name}/${args.key}`);
19242
+ return;
19243
+ }
19244
+ case "set": {
19245
+ const value = args.filePath ? this.readJsonFile(args.filePath) : JSON.parse(args.value);
19246
+ await kv.set(args.key, value);
19247
+ ui.success(`Set key ${args.name}/${args.key}`);
19248
+ return;
19249
+ }
19250
+ }
19251
+ }
19252
+ createNamespace(args) {
19253
+ return new Namespace({
19254
+ chain: args.chain,
19255
+ ns: args.namespace,
19256
+ baseUrl: this.resolveBaseUrl(args.baseUrl),
19257
+ indexerBaseUrl: this.resolveIndexerBaseUrl(args.indexerBaseUrl)
19258
+ });
19259
+ }
19260
+ resolveBaseUrl(baseUrl) {
19261
+ const resolved = baseUrl || process.env.PMATE_STORE_BASE_URL || process.env.BLOCKCHAIN_BASE_URL;
19262
+ if (!resolved) {
19263
+ throw new Error(
19264
+ "Missing store base URL. Provide --base-url or set PMATE_STORE_BASE_URL / BLOCKCHAIN_BASE_URL."
19265
+ );
19266
+ }
19267
+ return resolved.replace(/\/+$/, "");
19268
+ }
19269
+ resolveIndexerBaseUrl(indexerBaseUrl) {
19270
+ return (indexerBaseUrl || process.env.PMATE_STORE_INDEXER_BASE_URL || process.env.INDEXER_BASE_URL || "https://indexer.pmate.chat").replace(/\/+$/, "");
19271
+ }
19272
+ async listNamespaces(args) {
19273
+ const baseUrl = this.resolveIndexerBaseUrl(args.indexerBaseUrl);
19274
+ const url = new URL(`/chains/${encodeURIComponent(args.chain)}/namespaces`, `${baseUrl}/`);
19275
+ const response = await fetch(url.toString(), {
19276
+ headers: { Accept: "application/json" }
19277
+ });
19278
+ const payload = await response.json();
19279
+ if (!response.ok || !payload?.success) {
19280
+ throw new Error(payload?.message || `Namespace list request failed with status ${response.status}`);
19281
+ }
19282
+ return payload.data ?? [];
19283
+ }
19284
+ readJsonFile(filePath) {
19285
+ const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
19286
+ if (!(0, import_node_fs13.existsSync)(absolutePath)) {
19287
+ throw new Error(`JSON file not found: ${absolutePath}`);
19288
+ }
19289
+ const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
19290
+ try {
19291
+ return JSON.parse(raw);
19292
+ } catch (error) {
19293
+ const message = error instanceof Error ? error.message : String(error);
19294
+ throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
19295
+ }
19296
+ }
19297
+ renderNamespaceList(items, asJson) {
19298
+ if (asJson) {
19299
+ ui.plain(JSON.stringify(items, null, 2));
19300
+ return;
19301
+ }
19302
+ if (items.length === 0) {
19303
+ ui.warn("No namespaces found.");
19304
+ return;
19305
+ }
19306
+ for (const item of items) {
19307
+ ui.info(`${item.chain}/${item.namespace}`);
19308
+ }
19309
+ }
19310
+ renderJsonOrSummary(items, asJson, emptyText, label) {
19311
+ if (asJson) {
19312
+ ui.plain(JSON.stringify(items, null, 2));
19313
+ return;
19314
+ }
19315
+ if (items.length === 0) {
19316
+ ui.warn(emptyText);
19317
+ return;
19318
+ }
19319
+ for (const item of items) {
19320
+ ui.info(label(item), item);
19321
+ }
19322
+ }
19323
+ renderValue(value, asJson) {
19324
+ if (asJson) {
19325
+ ui.plain(JSON.stringify(value ?? null, null, 2));
19326
+ return;
19327
+ }
19328
+ if (typeof value === "boolean") {
19329
+ ui.plain(String(value));
19330
+ return;
19331
+ }
19332
+ if (value == null) {
19333
+ ui.warn("Not found.");
19334
+ return;
19335
+ }
19336
+ ui.plain(JSON.stringify(value, null, 2));
19337
+ }
19338
+ };
19339
+
19340
+ // src/commands/AppCommandHandler.ts
19341
+ var import_node_fs14 = require("fs");
19342
+ var import_node_path19 = __toESM(require("path"));
18946
19343
  init_sessionStore();
18947
19344
  var AppCommandHandler = class {
18948
19345
  async handle(args) {
@@ -19017,11 +19414,11 @@ var AppCommandHandler = class {
19017
19414
  }).token;
19018
19415
  }
19019
19416
  readJsonFile(filePath) {
19020
- const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
19021
- if (!(0, import_node_fs13.existsSync)(absolutePath)) {
19417
+ const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
19418
+ if (!(0, import_node_fs14.existsSync)(absolutePath)) {
19022
19419
  throw new Error(`JSON file not found: ${absolutePath}`);
19023
19420
  }
19024
- const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
19421
+ const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
19025
19422
  try {
19026
19423
  return JSON.parse(raw);
19027
19424
  } catch (error) {
@@ -19189,7 +19586,7 @@ function parseAgentArgs(tokens) {
19189
19586
  }
19190
19587
  let baseUrl;
19191
19588
  let json = false;
19192
- const takeSharedOptions = () => {
19589
+ const takeSharedOptions2 = () => {
19193
19590
  while (rest.length > 0) {
19194
19591
  const token = rest[0];
19195
19592
  if (token === "--base-url") {
@@ -19206,7 +19603,7 @@ function parseAgentArgs(tokens) {
19206
19603
  }
19207
19604
  };
19208
19605
  if (action === "namespaces") {
19209
- takeSharedOptions();
19606
+ takeSharedOptions2();
19210
19607
  if (rest.length > 0) {
19211
19608
  throw new Error(`Unknown agent namespaces option: ${rest[0]}`);
19212
19609
  }
@@ -19248,7 +19645,7 @@ function parseAgentArgs(tokens) {
19248
19645
  `Usage: agent ${action} [<namespace>] <name> [--base-url <url>] [--json]`
19249
19646
  );
19250
19647
  }
19251
- takeSharedOptions();
19648
+ takeSharedOptions2();
19252
19649
  if (rest.length > 0) {
19253
19650
  throw new Error(`Unknown agent ${action} option: ${rest[0]}`);
19254
19651
  }
@@ -19329,6 +19726,213 @@ function requireValue(tokens, optionName) {
19329
19726
  return value;
19330
19727
  }
19331
19728
 
19729
+ // src/storeCommandParser.ts
19730
+ var DEFAULT_CHAIN = "pmate";
19731
+ var DEFAULT_NAMESPACE2 = "pmate";
19732
+ function parseStoreArgs(tokens) {
19733
+ const rest = [...tokens];
19734
+ const scope = rest.shift();
19735
+ if (!scope) {
19736
+ throw new Error("Missing store scope. Use: store namespace|table|kv");
19737
+ }
19738
+ const action = rest.shift();
19739
+ if (!action) {
19740
+ throw new Error(`Missing store ${scope} action.`);
19741
+ }
19742
+ const shared = {
19743
+ chain: DEFAULT_CHAIN,
19744
+ namespace: DEFAULT_NAMESPACE2,
19745
+ baseUrl: void 0,
19746
+ indexerBaseUrl: void 0,
19747
+ json: false
19748
+ };
19749
+ if (scope === "namespace") {
19750
+ if (action !== "list") {
19751
+ throw new Error(`Unknown store namespace action: ${action}`);
19752
+ }
19753
+ takeSharedOptions(rest, shared);
19754
+ if (rest.length > 0) {
19755
+ throw new Error(`Unknown store namespace option: ${rest[0]}`);
19756
+ }
19757
+ return {
19758
+ type: "store" /* Store */,
19759
+ scope,
19760
+ action,
19761
+ ...shared
19762
+ };
19763
+ }
19764
+ if (scope === "table") {
19765
+ return parseTableArgs(action, rest, shared);
19766
+ }
19767
+ if (scope === "kv") {
19768
+ return parseKvArgs(action, rest, shared);
19769
+ }
19770
+ throw new Error(`Unknown store scope: ${scope}`);
19771
+ }
19772
+ function parseTableArgs(action, rest, shared) {
19773
+ const name = rest.shift();
19774
+ if (!name || name.startsWith("-")) {
19775
+ throw new Error(`Missing table name. Usage: store table ${action} <name> ...`);
19776
+ }
19777
+ if (action === "list") {
19778
+ let page = 0;
19779
+ while (rest.length > 0) {
19780
+ const token = rest.shift();
19781
+ switch (token) {
19782
+ case "--page":
19783
+ page = parsePage(requireValue2(rest, token));
19784
+ break;
19785
+ default:
19786
+ pushSharedOption(token, rest, shared);
19787
+ }
19788
+ }
19789
+ return { type: "store" /* Store */, scope: "table", action, name, page, ...shared };
19790
+ }
19791
+ if (action === "get" || action === "exists" || action === "delete") {
19792
+ let id;
19793
+ while (rest.length > 0) {
19794
+ const token = rest.shift();
19795
+ switch (token) {
19796
+ case "--id":
19797
+ id = requireValue2(rest, token);
19798
+ break;
19799
+ default:
19800
+ pushSharedOption(token, rest, shared);
19801
+ }
19802
+ }
19803
+ if (!id) {
19804
+ throw new Error(`Missing required option --id for store table ${action}`);
19805
+ }
19806
+ return { type: "store" /* Store */, scope: "table", action, name, id, ...shared };
19807
+ }
19808
+ if (action === "create" || action === "update") {
19809
+ let filePath;
19810
+ while (rest.length > 0) {
19811
+ const token = rest.shift();
19812
+ switch (token) {
19813
+ case "--file":
19814
+ filePath = requireValue2(rest, token);
19815
+ break;
19816
+ default:
19817
+ pushSharedOption(token, rest, shared);
19818
+ }
19819
+ }
19820
+ if (!filePath) {
19821
+ throw new Error(`Missing required option --file for store table ${action}`);
19822
+ }
19823
+ return { type: "store" /* Store */, scope: "table", action, name, filePath, ...shared };
19824
+ }
19825
+ throw new Error(`Unknown store table action: ${action}`);
19826
+ }
19827
+ function parseKvArgs(action, rest, shared) {
19828
+ const name = rest.shift();
19829
+ if (!name || name.startsWith("-")) {
19830
+ throw new Error(`Missing kv name. Usage: store kv ${action} <name> ...`);
19831
+ }
19832
+ if (action === "list") {
19833
+ let page = 0;
19834
+ while (rest.length > 0) {
19835
+ const token = rest.shift();
19836
+ switch (token) {
19837
+ case "--page":
19838
+ page = parsePage(requireValue2(rest, token));
19839
+ break;
19840
+ default:
19841
+ pushSharedOption(token, rest, shared);
19842
+ }
19843
+ }
19844
+ return { type: "store" /* Store */, scope: "kv", action, name, page, ...shared };
19845
+ }
19846
+ if (action === "get" || action === "exists" || action === "delete") {
19847
+ let key;
19848
+ while (rest.length > 0) {
19849
+ const token = rest.shift();
19850
+ switch (token) {
19851
+ case "--key":
19852
+ key = requireValue2(rest, token);
19853
+ break;
19854
+ default:
19855
+ pushSharedOption(token, rest, shared);
19856
+ }
19857
+ }
19858
+ if (!key) {
19859
+ throw new Error(`Missing required option --key for store kv ${action}`);
19860
+ }
19861
+ return { type: "store" /* Store */, scope: "kv", action, name, key, ...shared };
19862
+ }
19863
+ if (action === "set") {
19864
+ let key;
19865
+ let value;
19866
+ let filePath;
19867
+ while (rest.length > 0) {
19868
+ const token = rest.shift();
19869
+ switch (token) {
19870
+ case "--key":
19871
+ key = requireValue2(rest, token);
19872
+ break;
19873
+ case "--value":
19874
+ value = requireValue2(rest, token);
19875
+ break;
19876
+ case "--file":
19877
+ filePath = requireValue2(rest, token);
19878
+ break;
19879
+ default:
19880
+ pushSharedOption(token, rest, shared);
19881
+ }
19882
+ }
19883
+ if (!key) {
19884
+ throw new Error("Missing required option --key for store kv set");
19885
+ }
19886
+ if (!value && !filePath || value && filePath) {
19887
+ throw new Error("Provide exactly one of --value or --file for store kv set");
19888
+ }
19889
+ return { type: "store" /* Store */, scope: "kv", action, name, key, value, filePath, ...shared };
19890
+ }
19891
+ throw new Error(`Unknown store kv action: ${action}`);
19892
+ }
19893
+ function takeSharedOptions(rest, shared) {
19894
+ while (rest.length > 0) {
19895
+ const token = rest.shift();
19896
+ pushSharedOption(token, rest, shared);
19897
+ }
19898
+ }
19899
+ function pushSharedOption(token, rest, shared) {
19900
+ switch (token) {
19901
+ case "--chain":
19902
+ shared.chain = requireValue2(rest, token);
19903
+ break;
19904
+ case "--ns":
19905
+ case "--namespace":
19906
+ shared.namespace = requireValue2(rest, token);
19907
+ break;
19908
+ case "--base-url":
19909
+ shared.baseUrl = requireValue2(rest, token);
19910
+ break;
19911
+ case "--indexer-base-url":
19912
+ shared.indexerBaseUrl = requireValue2(rest, token);
19913
+ break;
19914
+ case "--json":
19915
+ shared.json = true;
19916
+ break;
19917
+ default:
19918
+ throw new Error(`Unknown store option: ${token}`);
19919
+ }
19920
+ }
19921
+ function requireValue2(tokens, optionName) {
19922
+ const value = tokens.shift();
19923
+ if (!value || value.startsWith("-")) {
19924
+ throw new Error(`Missing value for ${optionName}`);
19925
+ }
19926
+ return value;
19927
+ }
19928
+ function parsePage(value) {
19929
+ const page = Number.parseInt(value, 10);
19930
+ if (!Number.isInteger(page) || page < 0) {
19931
+ throw new Error(`Invalid --page value: ${value}`);
19932
+ }
19933
+ return page;
19934
+ }
19935
+
19332
19936
  // src/appCommandParser.ts
19333
19937
  function parseAppArgs(tokens) {
19334
19938
  const rest = [...tokens];
@@ -19338,12 +19942,12 @@ function parseAppArgs(tokens) {
19338
19942
  }
19339
19943
  let baseUrl;
19340
19944
  let json = false;
19341
- const takeSharedOptions = () => {
19945
+ const takeSharedOptions2 = () => {
19342
19946
  while (rest.length > 0) {
19343
19947
  const token = rest[0];
19344
19948
  if (token === "--base-url") {
19345
19949
  rest.shift();
19346
- baseUrl = requireValue2(rest, token);
19950
+ baseUrl = requireValue3(rest, token);
19347
19951
  continue;
19348
19952
  }
19349
19953
  if (token === "--json") {
@@ -19355,7 +19959,7 @@ function parseAppArgs(tokens) {
19355
19959
  }
19356
19960
  };
19357
19961
  if (action === "list") {
19358
- takeSharedOptions();
19962
+ takeSharedOptions2();
19359
19963
  if (rest.length > 0) {
19360
19964
  throw new Error(`Unknown app list option: ${rest[0]}`);
19361
19965
  }
@@ -19368,7 +19972,7 @@ function parseAppArgs(tokens) {
19368
19972
  `Usage: app ${action} <id> [--base-url <url>] [--json]`
19369
19973
  );
19370
19974
  }
19371
- takeSharedOptions();
19975
+ takeSharedOptions2();
19372
19976
  if (rest.length > 0) {
19373
19977
  throw new Error(`Unknown app ${action} option: ${rest[0]}`);
19374
19978
  }
@@ -19380,10 +19984,10 @@ function parseAppArgs(tokens) {
19380
19984
  const token = rest.shift();
19381
19985
  switch (token) {
19382
19986
  case "--file":
19383
- filePath = requireValue2(rest, token);
19987
+ filePath = requireValue3(rest, token);
19384
19988
  break;
19385
19989
  case "--base-url":
19386
- baseUrl = requireValue2(rest, token);
19990
+ baseUrl = requireValue3(rest, token);
19387
19991
  break;
19388
19992
  case "--json":
19389
19993
  json = true;
@@ -19409,10 +20013,10 @@ function parseAppArgs(tokens) {
19409
20013
  const token = rest.shift();
19410
20014
  switch (token) {
19411
20015
  case "--file":
19412
- filePath = requireValue2(rest, token);
20016
+ filePath = requireValue3(rest, token);
19413
20017
  break;
19414
20018
  case "--base-url":
19415
- baseUrl = requireValue2(rest, token);
20019
+ baseUrl = requireValue3(rest, token);
19416
20020
  break;
19417
20021
  case "--json":
19418
20022
  json = true;
@@ -19428,7 +20032,7 @@ function parseAppArgs(tokens) {
19428
20032
  }
19429
20033
  throw new Error(`Unknown app action: ${action}`);
19430
20034
  }
19431
- function requireValue2(tokens, optionName) {
20035
+ function requireValue3(tokens, optionName) {
19432
20036
  const value = tokens.shift();
19433
20037
  if (!value || value.startsWith("-")) {
19434
20038
  throw new Error(`Missing value for ${optionName}`);
@@ -19438,7 +20042,7 @@ function requireValue2(tokens, optionName) {
19438
20042
 
19439
20043
  // src/index.ts
19440
20044
  var pkg = JSON.parse(
19441
- (0, import_node_fs14.readFileSync)(import_node_path19.default.resolve(__dirname, "..", "package.json"), "utf8")
20045
+ (0, import_node_fs15.readFileSync)(import_node_path20.default.resolve(__dirname, "..", "package.json"), "utf8")
19442
20046
  );
19443
20047
  var HELP_TEXT = [
19444
20048
  import_chalk3.default.bold(`pmate v${pkg.version}`),
@@ -19522,6 +20126,11 @@ var HELP_TEXT = [
19522
20126
  ` ${import_chalk3.default.gray(" update [<namespace>] <name> --file <path> [--base-url <url>] [--json]")}`,
19523
20127
  ` ${import_chalk3.default.gray(" delete [<namespace>] <name> [--base-url <url>] [--json]")}`,
19524
20128
  ` ${import_chalk3.default.gray(" default namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
20129
+ ` ${import_chalk3.default.cyan("store")} Manage @pmate/store namespaces, tables, and kv stores`,
20130
+ ` ${import_chalk3.default.gray(" namespace list [--chain <chain>] [--indexer-base-url <url>] [--json]")}`,
20131
+ ` ${import_chalk3.default.gray(" table list|get|exists|create|update|delete <name> [options]")}`,
20132
+ ` ${import_chalk3.default.gray(" kv list|get|exists|set|delete <name> [options]")}`,
20133
+ ` ${import_chalk3.default.gray(" defaults: chain=pmate namespace=pmate env base URLs from BLOCKCHAIN_BASE_URL / INDEXER_BASE_URL")}`,
19525
20134
  ` ${import_chalk3.default.cyan("app")} Manage app registry entries via apps-api`,
19526
20135
  ` ${import_chalk3.default.gray(" list [--base-url <url>] [--json]")}`,
19527
20136
  ` ${import_chalk3.default.gray(" get <id> [--base-url <url>] [--json]")}`,
@@ -19589,7 +20198,7 @@ function parseCommandArgs(args) {
19589
20198
  const token = rest.shift();
19590
20199
  switch (token) {
19591
20200
  case "--app":
19592
- app = requireValue3(rest, token);
20201
+ app = requireValue4(rest, token);
19593
20202
  break;
19594
20203
  default:
19595
20204
  throw new Error(`Unknown login option: ${token}`);
@@ -19654,6 +20263,9 @@ function parseCommandArgs(args) {
19654
20263
  if (args.rest[0] === "agent") {
19655
20264
  return parseAgentArgs(args.rest.slice(1));
19656
20265
  }
20266
+ if (args.rest[0] === "store") {
20267
+ return parseStoreArgs(args.rest.slice(1));
20268
+ }
19657
20269
  if (args.rest[0] === "app") {
19658
20270
  return parseAppArgs(args.rest.slice(1));
19659
20271
  }
@@ -19674,7 +20286,7 @@ function parseVercelArgs(tokens) {
19674
20286
  const token = rest.shift();
19675
20287
  switch (token) {
19676
20288
  case "--scope":
19677
- scope = requireValue3(rest, token);
20289
+ scope = requireValue4(rest, token);
19678
20290
  break;
19679
20291
  default:
19680
20292
  throw new Error(`Unknown vercel option: ${token}`);
@@ -19694,10 +20306,10 @@ function parseVercelArgs(tokens) {
19694
20306
  const token = rest.shift();
19695
20307
  switch (token) {
19696
20308
  case "--scope":
19697
- scope = requireValue3(rest, token);
20309
+ scope = requireValue4(rest, token);
19698
20310
  break;
19699
20311
  case "--project":
19700
- project = requireValue3(rest, token);
20312
+ project = requireValue4(rest, token);
19701
20313
  break;
19702
20314
  case "--last-week":
19703
20315
  lastWeek = true;
@@ -19728,16 +20340,16 @@ function parseAddDnsArgs(tokens) {
19728
20340
  const token = rest.shift();
19729
20341
  switch (token) {
19730
20342
  case "--type":
19731
- options.dnsType = requireValue3(rest, token);
20343
+ options.dnsType = requireValue4(rest, token);
19732
20344
  break;
19733
20345
  case "--value":
19734
- options.dnsValue = requireValue3(rest, token);
20346
+ options.dnsValue = requireValue4(rest, token);
19735
20347
  break;
19736
20348
  case "--rr":
19737
- options.dnsRr = requireValue3(rest, token);
20349
+ options.dnsRr = requireValue4(rest, token);
19738
20350
  break;
19739
20351
  case "--ttl": {
19740
- const ttlValue = requireValue3(rest, token);
20352
+ const ttlValue = requireValue4(rest, token);
19741
20353
  const ttl = Number.parseInt(ttlValue, 10);
19742
20354
  if (!Number.isFinite(ttl) || ttl <= 0) {
19743
20355
  throw new Error(`Invalid --ttl value: ${ttlValue}`);
@@ -19746,7 +20358,7 @@ function parseAddDnsArgs(tokens) {
19746
20358
  break;
19747
20359
  }
19748
20360
  case "--domain":
19749
- options.dnsDomain = requireValue3(rest, token);
20361
+ options.dnsDomain = requireValue4(rest, token);
19750
20362
  break;
19751
20363
  default:
19752
20364
  throw new Error(`Unknown add-dns option: ${token}`);
@@ -19777,7 +20389,7 @@ function parseBucketArgs(tokens) {
19777
20389
  options.bucketCreate = true;
19778
20390
  break;
19779
20391
  case "--name":
19780
- options.bucketName = requireValue3(rest, token);
20392
+ options.bucketName = requireValue4(rest, token);
19781
20393
  break;
19782
20394
  default:
19783
20395
  throw new Error(`Unknown bucket option: ${token}`);
@@ -19813,7 +20425,7 @@ function parseDeployArgs(tokens) {
19813
20425
  options.deployAction = "logs";
19814
20426
  break;
19815
20427
  case "--cwd":
19816
- options.deployCwd = requireValue3(rest, token);
20428
+ options.deployCwd = requireValue4(rest, token);
19817
20429
  break;
19818
20430
  default:
19819
20431
  throw new Error(`Unknown deploy option: ${token}`);
@@ -19838,13 +20450,13 @@ function parseLogArgs(tokens) {
19838
20450
  const token = rest.shift();
19839
20451
  switch (token) {
19840
20452
  case "--cwd":
19841
- options.logCwd = requireValue3(rest, token);
20453
+ options.logCwd = requireValue4(rest, token);
19842
20454
  break;
19843
20455
  case "--ns":
19844
- options.logNamespace = requireValue3(rest, token);
20456
+ options.logNamespace = requireValue4(rest, token);
19845
20457
  break;
19846
20458
  case "--page": {
19847
- const value = requireValue3(rest, token);
20459
+ const value = requireValue4(rest, token);
19848
20460
  const page = Number.parseInt(value, 10);
19849
20461
  if (!Number.isFinite(page) || page < 0) {
19850
20462
  throw new Error(`Invalid log page: ${value}`);
@@ -19856,7 +20468,7 @@ function parseLogArgs(tokens) {
19856
20468
  options.logHistory = true;
19857
20469
  break;
19858
20470
  case "--search":
19859
- options.logSearch = requireValue3(rest, token);
20471
+ options.logSearch = requireValue4(rest, token);
19860
20472
  break;
19861
20473
  default:
19862
20474
  throw new Error(`Unknown log option: ${token}`);
@@ -19879,7 +20491,7 @@ function parseInitArgs(tokens) {
19879
20491
  const token = rest.shift();
19880
20492
  switch (token) {
19881
20493
  case "--cwd":
19882
- options.initCwd = requireValue3(rest, token);
20494
+ options.initCwd = requireValue4(rest, token);
19883
20495
  break;
19884
20496
  default:
19885
20497
  throw new Error(`Unknown init option: ${token}`);
@@ -19902,7 +20514,7 @@ function parseDevArgs(tokens) {
19902
20514
  const token = rest.shift();
19903
20515
  switch (token) {
19904
20516
  case "--cwd":
19905
- options.devCwd = requireValue3(rest, token);
20517
+ options.devCwd = requireValue4(rest, token);
19906
20518
  break;
19907
20519
  default:
19908
20520
  throw new Error(`Unknown dev option: ${token}`);
@@ -19932,13 +20544,13 @@ function parseOssArgs(tokens) {
19932
20544
  const token = rest.shift();
19933
20545
  switch (token) {
19934
20546
  case "--bucket":
19935
- bucket = requireValue3(rest, token);
20547
+ bucket = requireValue4(rest, token);
19936
20548
  break;
19937
20549
  case "--file":
19938
- filePath = requireValue3(rest, token);
20550
+ filePath = requireValue4(rest, token);
19939
20551
  break;
19940
20552
  case "--key":
19941
- objectKey = requireValue3(rest, token);
20553
+ objectKey = requireValue4(rest, token);
19942
20554
  break;
19943
20555
  default:
19944
20556
  throw new Error(`Unknown oss option: ${token}`);
@@ -19971,7 +20583,7 @@ function parseEnvArgs(tokens) {
19971
20583
  throw new Error("Only one env action is allowed.");
19972
20584
  }
19973
20585
  action = "set";
19974
- key = requireValue3(rest, token);
20586
+ key = requireValue4(rest, token);
19975
20587
  break;
19976
20588
  case "--list":
19977
20589
  if (action) {
@@ -19984,17 +20596,17 @@ function parseEnvArgs(tokens) {
19984
20596
  throw new Error("Only one env action is allowed.");
19985
20597
  }
19986
20598
  action = "delete";
19987
- key = requireValue3(rest, token);
20599
+ key = requireValue4(rest, token);
19988
20600
  break;
19989
20601
  case "--value":
19990
- value = requireValue3(rest, token);
20602
+ value = requireValue4(rest, token);
19991
20603
  break;
19992
20604
  case "--verbose":
19993
20605
  case "-v":
19994
20606
  verbose = true;
19995
20607
  break;
19996
20608
  case "--cwd":
19997
- cwd = requireValue3(rest, token);
20609
+ cwd = requireValue4(rest, token);
19998
20610
  break;
19999
20611
  default:
20000
20612
  throw new Error(`Unknown env option: ${token}`);
@@ -20052,7 +20664,7 @@ function parseCommitArgs(tokens) {
20052
20664
  push = true;
20053
20665
  break;
20054
20666
  case "--cwd":
20055
- cwd = requireValue3(rest, token);
20667
+ cwd = requireValue4(rest, token);
20056
20668
  break;
20057
20669
  default:
20058
20670
  throw new Error(`Unknown commit option: ${token}`);
@@ -20068,10 +20680,10 @@ function parseSummaryArgs(tokens) {
20068
20680
  const token = rest.shift();
20069
20681
  switch (token) {
20070
20682
  case "--pr":
20071
- prRef = requireValue3(rest, token);
20683
+ prRef = requireValue4(rest, token);
20072
20684
  break;
20073
20685
  case "--cwd":
20074
- cwd = requireValue3(rest, token);
20686
+ cwd = requireValue4(rest, token);
20075
20687
  break;
20076
20688
  default:
20077
20689
  throw new Error(`Unknown summary option: ${token}`);
@@ -20140,10 +20752,10 @@ function parseLinearPrArgs(tokens) {
20140
20752
  const token = rest.shift();
20141
20753
  switch (token) {
20142
20754
  case "--account":
20143
- account = requireValue3(rest, token);
20755
+ account = requireValue4(rest, token);
20144
20756
  break;
20145
20757
  case "--cwd":
20146
- cwd = requireValue3(rest, token);
20758
+ cwd = requireValue4(rest, token);
20147
20759
  break;
20148
20760
  default:
20149
20761
  throw new Error(`Unknown linear option: ${token}`);
@@ -20172,35 +20784,35 @@ function parseLinearCreateArgs(tokens) {
20172
20784
  const token = rest.shift();
20173
20785
  switch (token) {
20174
20786
  case "--account":
20175
- account = requireValue3(rest, token);
20787
+ account = requireValue4(rest, token);
20176
20788
  break;
20177
20789
  case "--repl":
20178
20790
  useRepl = true;
20179
20791
  break;
20180
20792
  case "--title":
20181
- title = requireValue3(rest, token);
20793
+ title = requireValue4(rest, token);
20182
20794
  break;
20183
20795
  case "--desc":
20184
20796
  case "--description":
20185
- description = decodeEscapedNewlines(requireValue3(rest, token));
20797
+ description = decodeEscapedNewlines(requireValue4(rest, token));
20186
20798
  break;
20187
20799
  case "--team-id":
20188
- teamId = requireValue3(rest, token);
20800
+ teamId = requireValue4(rest, token);
20189
20801
  break;
20190
20802
  case "--team-key":
20191
- teamKey = requireValue3(rest, token);
20803
+ teamKey = requireValue4(rest, token);
20192
20804
  break;
20193
20805
  case "--priority":
20194
- priority = parseLinearPriority(requireValue3(rest, token));
20806
+ priority = parseLinearPriority(requireValue4(rest, token));
20195
20807
  break;
20196
20808
  case "--parent-id":
20197
- parentId = requireValue3(rest, token);
20809
+ parentId = requireValue4(rest, token);
20198
20810
  break;
20199
20811
  case "--state-id":
20200
- stateId = requireValue3(rest, token);
20812
+ stateId = requireValue4(rest, token);
20201
20813
  break;
20202
20814
  case "--cwd":
20203
- cwd = requireValue3(rest, token);
20815
+ cwd = requireValue4(rest, token);
20204
20816
  break;
20205
20817
  default:
20206
20818
  throw new Error(`Unknown linear option: ${token}`);
@@ -20235,10 +20847,10 @@ function parseLinearWhoamiArgs(tokens) {
20235
20847
  const token = rest.shift();
20236
20848
  switch (token) {
20237
20849
  case "--account":
20238
- account = requireValue3(rest, token);
20850
+ account = requireValue4(rest, token);
20239
20851
  break;
20240
20852
  case "--cwd":
20241
- cwd = requireValue3(rest, token);
20853
+ cwd = requireValue4(rest, token);
20242
20854
  break;
20243
20855
  default:
20244
20856
  throw new Error(`Unknown linear option: ${token}`);
@@ -20263,10 +20875,10 @@ function parseLinearViewArgs(tokens) {
20263
20875
  const token = rest.shift();
20264
20876
  switch (token) {
20265
20877
  case "--account":
20266
- account = requireValue3(rest, token);
20878
+ account = requireValue4(rest, token);
20267
20879
  break;
20268
20880
  case "--cwd":
20269
- cwd = requireValue3(rest, token);
20881
+ cwd = requireValue4(rest, token);
20270
20882
  break;
20271
20883
  default:
20272
20884
  throw new Error(`Unknown linear option: ${token}`);
@@ -20301,32 +20913,32 @@ function parseLinearUpdateArgs(tokens) {
20301
20913
  const token = rest.shift();
20302
20914
  switch (token) {
20303
20915
  case "--account":
20304
- account = requireValue3(rest, token);
20916
+ account = requireValue4(rest, token);
20305
20917
  break;
20306
20918
  case "--title":
20307
- title = requireValue3(rest, token);
20919
+ title = requireValue4(rest, token);
20308
20920
  break;
20309
20921
  case "--desc":
20310
20922
  case "--description":
20311
- description = decodeEscapedNewlines(requireValue3(rest, token));
20923
+ description = decodeEscapedNewlines(requireValue4(rest, token));
20312
20924
  break;
20313
20925
  case "--team-id":
20314
- teamId = requireValue3(rest, token);
20926
+ teamId = requireValue4(rest, token);
20315
20927
  break;
20316
20928
  case "--team-key":
20317
- teamKey = requireValue3(rest, token);
20929
+ teamKey = requireValue4(rest, token);
20318
20930
  break;
20319
20931
  case "--priority":
20320
- priority = parseLinearPriority(requireValue3(rest, token));
20932
+ priority = parseLinearPriority(requireValue4(rest, token));
20321
20933
  break;
20322
20934
  case "--parent-id":
20323
- parentId = requireValue3(rest, token);
20935
+ parentId = requireValue4(rest, token);
20324
20936
  break;
20325
20937
  case "--state-id":
20326
- stateId = requireValue3(rest, token);
20938
+ stateId = requireValue4(rest, token);
20327
20939
  break;
20328
20940
  case "--cwd":
20329
- cwd = requireValue3(rest, token);
20941
+ cwd = requireValue4(rest, token);
20330
20942
  break;
20331
20943
  default:
20332
20944
  throw new Error(`Unknown linear option: ${token}`);
@@ -20364,10 +20976,10 @@ function parseLinearSubIssuesArgs(tokens) {
20364
20976
  const token = rest.shift();
20365
20977
  switch (token) {
20366
20978
  case "--account":
20367
- account = requireValue3(rest, token);
20979
+ account = requireValue4(rest, token);
20368
20980
  break;
20369
20981
  case "--cwd":
20370
- cwd = requireValue3(rest, token);
20982
+ cwd = requireValue4(rest, token);
20371
20983
  break;
20372
20984
  default:
20373
20985
  throw new Error(`Unknown linear option: ${token}`);
@@ -20394,15 +21006,15 @@ function parseLinearCommentArgs(tokens) {
20394
21006
  const token = rest.shift();
20395
21007
  switch (token) {
20396
21008
  case "--account":
20397
- account = requireValue3(rest, token);
21009
+ account = requireValue4(rest, token);
20398
21010
  break;
20399
21011
  case "--body":
20400
21012
  case "--desc":
20401
21013
  case "--description":
20402
- body = decodeEscapedNewlines(requireValue3(rest, token));
21014
+ body = decodeEscapedNewlines(requireValue4(rest, token));
20403
21015
  break;
20404
21016
  case "--cwd":
20405
- cwd = requireValue3(rest, token);
21017
+ cwd = requireValue4(rest, token);
20406
21018
  break;
20407
21019
  default:
20408
21020
  throw new Error(`Unknown linear option: ${token}`);
@@ -20432,10 +21044,10 @@ function parseLinearCommentsArgs(tokens) {
20432
21044
  const token = rest.shift();
20433
21045
  switch (token) {
20434
21046
  case "--account":
20435
- account = requireValue3(rest, token);
21047
+ account = requireValue4(rest, token);
20436
21048
  break;
20437
21049
  case "--cwd":
20438
- cwd = requireValue3(rest, token);
21050
+ cwd = requireValue4(rest, token);
20439
21051
  break;
20440
21052
  default:
20441
21053
  throw new Error(`Unknown linear option: ${token}`);
@@ -20459,16 +21071,16 @@ function parseLinearCycleArgs(tokens) {
20459
21071
  const token = rest.shift();
20460
21072
  switch (token) {
20461
21073
  case "--account":
20462
- account = requireValue3(rest, token);
21074
+ account = requireValue4(rest, token);
20463
21075
  break;
20464
21076
  case "--team-id":
20465
- teamId = requireValue3(rest, token);
21077
+ teamId = requireValue4(rest, token);
20466
21078
  break;
20467
21079
  case "--team-key":
20468
- teamKey = requireValue3(rest, token);
21080
+ teamKey = requireValue4(rest, token);
20469
21081
  break;
20470
21082
  case "--cwd":
20471
- cwd = requireValue3(rest, token);
21083
+ cwd = requireValue4(rest, token);
20472
21084
  break;
20473
21085
  default:
20474
21086
  throw new Error(`Unknown linear option: ${token}`);
@@ -20491,10 +21103,10 @@ function parseLinearTeamsArgs(tokens) {
20491
21103
  const token = rest.shift();
20492
21104
  switch (token) {
20493
21105
  case "--account":
20494
- account = requireValue3(rest, token);
21106
+ account = requireValue4(rest, token);
20495
21107
  break;
20496
21108
  case "--cwd":
20497
- cwd = requireValue3(rest, token);
21109
+ cwd = requireValue4(rest, token);
20498
21110
  break;
20499
21111
  default:
20500
21112
  throw new Error(`Unknown linear option: ${token}`);
@@ -20521,16 +21133,16 @@ function parseLinearUserIssuesArgs(tokens) {
20521
21133
  const token = rest.shift();
20522
21134
  switch (token) {
20523
21135
  case "--account":
20524
- account = requireValue3(rest, token);
21136
+ account = requireValue4(rest, token);
20525
21137
  break;
20526
21138
  case "--cycle":
20527
- cycle = parseLinearCycle(requireValue3(rest, token));
21139
+ cycle = parseLinearCycle(requireValue4(rest, token));
20528
21140
  break;
20529
21141
  case "--status":
20530
- status = parseLinearStatus(requireValue3(rest, token));
21142
+ status = parseLinearStatus(requireValue4(rest, token));
20531
21143
  break;
20532
21144
  case "--cwd":
20533
- cwd = requireValue3(rest, token);
21145
+ cwd = requireValue4(rest, token);
20534
21146
  break;
20535
21147
  default:
20536
21148
  throw new Error(`Unknown linear option: ${token}`);
@@ -20564,28 +21176,28 @@ function parseLinearIssuesArgs(tokens) {
20564
21176
  const token = rest.shift();
20565
21177
  switch (token) {
20566
21178
  case "--account":
20567
- account = requireValue3(rest, token);
21179
+ account = requireValue4(rest, token);
20568
21180
  break;
20569
21181
  case "--team-id":
20570
- teamId = requireValue3(rest, token);
21182
+ teamId = requireValue4(rest, token);
20571
21183
  break;
20572
21184
  case "--team-key":
20573
- teamKey = requireValue3(rest, token);
21185
+ teamKey = requireValue4(rest, token);
20574
21186
  break;
20575
21187
  case "--user":
20576
- user = requireValue3(rest, token);
21188
+ user = requireValue4(rest, token);
20577
21189
  break;
20578
21190
  case "--cycle":
20579
- cycle = parseLinearCycle(requireValue3(rest, token));
21191
+ cycle = parseLinearCycle(requireValue4(rest, token));
20580
21192
  break;
20581
21193
  case "--status":
20582
- status = parseLinearStatus(requireValue3(rest, token));
21194
+ status = parseLinearStatus(requireValue4(rest, token));
20583
21195
  break;
20584
21196
  case "--query":
20585
- query = requireValue3(rest, token).trim();
21197
+ query = requireValue4(rest, token).trim();
20586
21198
  break;
20587
21199
  case "--limit": {
20588
- const value = Number.parseInt(requireValue3(rest, token), 10);
21200
+ const value = Number.parseInt(requireValue4(rest, token), 10);
20589
21201
  if (!Number.isInteger(value) || value < 1 || value > 250) {
20590
21202
  throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
20591
21203
  }
@@ -20593,7 +21205,7 @@ function parseLinearIssuesArgs(tokens) {
20593
21205
  break;
20594
21206
  }
20595
21207
  case "--cwd":
20596
- cwd = requireValue3(rest, token);
21208
+ cwd = requireValue4(rest, token);
20597
21209
  break;
20598
21210
  default:
20599
21211
  throw new Error(`Unknown linear option: ${token}`);
@@ -20634,10 +21246,10 @@ function parseLinearLegacyArgs(tokens) {
20634
21246
  useScreenshot = true;
20635
21247
  break;
20636
21248
  case "--account":
20637
- account = requireValue3(rest, token);
21249
+ account = requireValue4(rest, token);
20638
21250
  break;
20639
21251
  case "--cwd":
20640
- cwd = requireValue3(rest, token);
21252
+ cwd = requireValue4(rest, token);
20641
21253
  break;
20642
21254
  default:
20643
21255
  throw new Error(`Unknown linear option: ${token}`);
@@ -20731,19 +21343,19 @@ function parseNotionArgs(tokens) {
20731
21343
  const token = rest.shift();
20732
21344
  switch (token) {
20733
21345
  case "--parent":
20734
- parentPageId = requireValue3(rest, token);
21346
+ parentPageId = requireValue4(rest, token);
20735
21347
  break;
20736
21348
  case "--title":
20737
- title = requireValue3(rest, token);
21349
+ title = requireValue4(rest, token);
20738
21350
  break;
20739
21351
  case "--private":
20740
21352
  isPrivate = true;
20741
21353
  break;
20742
21354
  case "--content":
20743
- content2 = requireValue3(rest, token);
21355
+ content2 = requireValue4(rest, token);
20744
21356
  break;
20745
21357
  case "--file":
20746
- filePath2 = requireValue3(rest, token);
21358
+ filePath2 = requireValue4(rest, token);
20747
21359
  break;
20748
21360
  default:
20749
21361
  throw new Error(`Unknown notion option: ${token}`);
@@ -20787,10 +21399,10 @@ function parseNotionArgs(tokens) {
20787
21399
  const token = rest.shift();
20788
21400
  switch (token) {
20789
21401
  case "--content":
20790
- content = requireValue3(rest, token);
21402
+ content = requireValue4(rest, token);
20791
21403
  break;
20792
21404
  case "--file":
20793
- filePath = requireValue3(rest, token);
21405
+ filePath = requireValue4(rest, token);
20794
21406
  break;
20795
21407
  case "--append":
20796
21408
  append = true;
@@ -20835,11 +21447,11 @@ function parseRandomArgs(tokens) {
20835
21447
  mode = "easy";
20836
21448
  break;
20837
21449
  case "--length":
20838
- length = parsePositiveInt(requireValue3(rest, token), token);
21450
+ length = parsePositiveInt(requireValue4(rest, token), token);
20839
21451
  seenLength = true;
20840
21452
  break;
20841
21453
  case "--charset": {
20842
- const value = requireValue3(rest, token);
21454
+ const value = requireValue4(rest, token);
20843
21455
  if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
20844
21456
  throw new Error(
20845
21457
  `Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
@@ -20850,18 +21462,18 @@ function parseRandomArgs(tokens) {
20850
21462
  break;
20851
21463
  }
20852
21464
  case "--count":
20853
- count = parsePositiveInt(requireValue3(rest, token), token);
21465
+ count = parsePositiveInt(requireValue4(rest, token), token);
20854
21466
  break;
20855
21467
  case "--words":
20856
- words = parsePositiveInt(requireValue3(rest, token), token);
21468
+ words = parsePositiveInt(requireValue4(rest, token), token);
20857
21469
  seenWords = true;
20858
21470
  break;
20859
21471
  case "--digits":
20860
- digits = parseNonNegativeInt(requireValue3(rest, token), token);
21472
+ digits = parseNonNegativeInt(requireValue4(rest, token), token);
20861
21473
  seenDigits = true;
20862
21474
  break;
20863
21475
  case "--separator":
20864
- separator = requireValue3(rest, token);
21476
+ separator = requireValue4(rest, token);
20865
21477
  seenSeparator = true;
20866
21478
  break;
20867
21479
  default:
@@ -20904,7 +21516,7 @@ function parseCollectArgs(tokens) {
20904
21516
  const token = rest.shift();
20905
21517
  switch (token) {
20906
21518
  case "--endpoint":
20907
- options.endpoint = requireValue3(rest, token);
21519
+ options.endpoint = requireValue4(rest, token);
20908
21520
  break;
20909
21521
  case "--json":
20910
21522
  options.json = true;
@@ -20914,7 +21526,7 @@ function parseCollectArgs(tokens) {
20914
21526
  break;
20915
21527
  case "--thread":
20916
21528
  options.mode = "thread";
20917
- options.threadName = requireValue3(rest, token);
21529
+ options.threadName = requireValue4(rest, token);
20918
21530
  break;
20919
21531
  default:
20920
21532
  throw new Error(`Unknown collect option: ${token}`);
@@ -20925,7 +21537,7 @@ function parseCollectArgs(tokens) {
20925
21537
  }
20926
21538
  return { type: "collect" /* Collect */, ...options };
20927
21539
  }
20928
- function requireValue3(tokens, optionName) {
21540
+ function requireValue4(tokens, optionName) {
20929
21541
  const value = tokens.shift();
20930
21542
  if (!value) {
20931
21543
  throw new Error(`Missing value for ${optionName}`);
@@ -21066,6 +21678,11 @@ async function main() {
21066
21678
  await handler.handle(commandArgs);
21067
21679
  return;
21068
21680
  }
21681
+ case "store" /* Store */: {
21682
+ const handler = new StoreCommandHandler();
21683
+ await handler.handle(commandArgs);
21684
+ return;
21685
+ }
21069
21686
  case "app" /* App */: {
21070
21687
  const handler = new AppCommandHandler();
21071
21688
  await handler.handle(commandArgs);