@pmate/cli 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +68 -5
- package/dist/index.js +1041 -413
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12659,16 +12659,23 @@ function readSessionToken() {
|
|
|
12659
12659
|
preferredApp: DEFAULT_APP_ID
|
|
12660
12660
|
}).token;
|
|
12661
12661
|
}
|
|
12662
|
-
function unwrapAgentResult(value) {
|
|
12662
|
+
function unwrapAgentResult(agentId, value) {
|
|
12663
12663
|
if (!value || typeof value !== "object") {
|
|
12664
|
+
if (value == null) {
|
|
12665
|
+
throw new Error(`Agent ${agentId} returned no result`);
|
|
12666
|
+
}
|
|
12664
12667
|
return value;
|
|
12665
12668
|
}
|
|
12666
12669
|
if ("content" in value && "type" in value) {
|
|
12667
|
-
|
|
12670
|
+
const content = value.content;
|
|
12671
|
+
if (content == null) {
|
|
12672
|
+
throw new Error(`Agent ${agentId} returned empty envelope content`);
|
|
12673
|
+
}
|
|
12674
|
+
return content;
|
|
12668
12675
|
}
|
|
12669
12676
|
return value;
|
|
12670
12677
|
}
|
|
12671
|
-
var import_agent_sdk, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_FROM, AgentLlmClient;
|
|
12678
|
+
var import_agent_sdk, DEFAULT_AGENT_API_BASE_URL, DEFAULT_AGENT_HUB_BASE_URL, DEFAULT_NAMESPACE, DEFAULT_FROM, DEFAULT_AGENT_PROMPT_TIMEOUT_MS, AgentLlmClient;
|
|
12672
12679
|
var init_AgentLlmClient = __esm({
|
|
12673
12680
|
"src/llm/AgentLlmClient.ts"() {
|
|
12674
12681
|
"use strict";
|
|
@@ -12678,6 +12685,7 @@ var init_AgentLlmClient = __esm({
|
|
|
12678
12685
|
DEFAULT_AGENT_HUB_BASE_URL = "https://hub.pmate.chat";
|
|
12679
12686
|
DEFAULT_NAMESPACE = "pmate-cli";
|
|
12680
12687
|
DEFAULT_FROM = "pmate-cli";
|
|
12688
|
+
DEFAULT_AGENT_PROMPT_TIMEOUT_MS = 12e4;
|
|
12681
12689
|
AgentLlmClient = class {
|
|
12682
12690
|
constructor(options) {
|
|
12683
12691
|
this.token = options?.token ?? readSessionToken();
|
|
@@ -12696,7 +12704,8 @@ var init_AgentLlmClient = __esm({
|
|
|
12696
12704
|
async call(agentId, payload, options) {
|
|
12697
12705
|
const client = new import_agent_sdk.AgentClient({
|
|
12698
12706
|
baseUrl: options?.hubBaseUrl ?? this.hubBaseUrl,
|
|
12699
|
-
agentService: this.agentService
|
|
12707
|
+
agentService: this.agentService,
|
|
12708
|
+
timeoutMs: DEFAULT_AGENT_PROMPT_TIMEOUT_MS
|
|
12700
12709
|
});
|
|
12701
12710
|
try {
|
|
12702
12711
|
await client.login(options?.from ?? this.from, {
|
|
@@ -12706,7 +12715,7 @@ var init_AgentLlmClient = __esm({
|
|
|
12706
12715
|
agentId,
|
|
12707
12716
|
payload
|
|
12708
12717
|
});
|
|
12709
|
-
return unwrapAgentResult(result);
|
|
12718
|
+
return unwrapAgentResult(agentId, result);
|
|
12710
12719
|
} finally {
|
|
12711
12720
|
client.close();
|
|
12712
12721
|
}
|
|
@@ -12721,8 +12730,8 @@ __export(index_exports, {
|
|
|
12721
12730
|
parseCommandArgs: () => parseCommandArgs
|
|
12722
12731
|
});
|
|
12723
12732
|
module.exports = __toCommonJS(index_exports);
|
|
12724
|
-
var
|
|
12725
|
-
var
|
|
12733
|
+
var import_node_fs18 = require("fs");
|
|
12734
|
+
var import_node_path23 = __toESM(require("path"));
|
|
12726
12735
|
var import_chalk4 = __toESM(require("chalk"));
|
|
12727
12736
|
|
|
12728
12737
|
// src/cli.ts
|
|
@@ -17621,9 +17630,9 @@ ${indent}\`\`\``;
|
|
|
17621
17630
|
static richTextToPlain(richText) {
|
|
17622
17631
|
return richText.map((item) => item.plain_text ?? item.text?.content ?? "").join("").trim();
|
|
17623
17632
|
}
|
|
17624
|
-
static async requestJson(
|
|
17633
|
+
static async requestJson(path24, init) {
|
|
17625
17634
|
const token = this.getToken();
|
|
17626
|
-
const response = await fetch(`${this.baseUrl}${
|
|
17635
|
+
const response = await fetch(`${this.baseUrl}${path24}`, {
|
|
17627
17636
|
method: init.method,
|
|
17628
17637
|
headers: {
|
|
17629
17638
|
Authorization: `Bearer ${token}`,
|
|
@@ -18660,15 +18669,72 @@ var QuizCommandHandler = class {
|
|
|
18660
18669
|
|
|
18661
18670
|
// src/commands/CollectCommandHandler.ts
|
|
18662
18671
|
var import_playwright = require("playwright");
|
|
18672
|
+
var import_node_crypto4 = require("crypto");
|
|
18673
|
+
var import_node_fs11 = require("fs");
|
|
18674
|
+
var import_node_os6 = __toESM(require("os"));
|
|
18675
|
+
var import_node_path16 = __toESM(require("path"));
|
|
18676
|
+
|
|
18677
|
+
// src/collectStore.ts
|
|
18663
18678
|
var import_node_crypto3 = require("crypto");
|
|
18664
18679
|
var import_node_fs10 = require("fs");
|
|
18665
18680
|
var import_node_os5 = __toESM(require("os"));
|
|
18666
18681
|
var import_node_path15 = __toESM(require("path"));
|
|
18682
|
+
function resolveCollectTarget(input) {
|
|
18683
|
+
const endpoint = input.endpoint ?? (input.source === "cc" ? "http://localhost:9223" : "http://localhost:9222");
|
|
18684
|
+
const sourceKey = input.source ?? `endpoint-${(0, import_node_crypto3.createHash)("sha1").update(endpoint).digest("hex").slice(0, 8)}`;
|
|
18685
|
+
const rootDir = import_node_path15.default.join(import_node_os5.default.homedir(), ".pmate", "collect", sourceKey);
|
|
18686
|
+
return { sourceKey, endpoint, rootDir };
|
|
18687
|
+
}
|
|
18688
|
+
function toThreadKey(name) {
|
|
18689
|
+
const normalized = name.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fff]+/g, "-").replace(/^-+|-+$/g, "");
|
|
18690
|
+
const base = normalized || "thread";
|
|
18691
|
+
const suffix = (0, import_node_crypto3.createHash)("sha1").update(name).digest("hex").slice(0, 8);
|
|
18692
|
+
return `${base}-${suffix}`;
|
|
18693
|
+
}
|
|
18694
|
+
async function readStoredThread(rootDir, threadKey) {
|
|
18695
|
+
const filePath = getThreadFilePath(rootDir, threadKey);
|
|
18696
|
+
try {
|
|
18697
|
+
const raw = await import_node_fs10.promises.readFile(filePath, "utf8");
|
|
18698
|
+
return JSON.parse(raw);
|
|
18699
|
+
} catch {
|
|
18700
|
+
return null;
|
|
18701
|
+
}
|
|
18702
|
+
}
|
|
18703
|
+
async function writeStoredThread(rootDir, thread) {
|
|
18704
|
+
const filePath = getThreadFilePath(rootDir, thread.threadKey);
|
|
18705
|
+
await import_node_fs10.promises.mkdir(import_node_path15.default.dirname(filePath), { recursive: true });
|
|
18706
|
+
await import_node_fs10.promises.writeFile(filePath, JSON.stringify(thread, null, 2) + "\n", "utf8");
|
|
18707
|
+
}
|
|
18708
|
+
async function writeStoredIndex(rootDir, index) {
|
|
18709
|
+
await import_node_fs10.promises.mkdir(rootDir, { recursive: true });
|
|
18710
|
+
const filePath = import_node_path15.default.join(rootDir, "index.json");
|
|
18711
|
+
await import_node_fs10.promises.writeFile(filePath, JSON.stringify(index, null, 2) + "\n", "utf8");
|
|
18712
|
+
}
|
|
18713
|
+
function mergeMessages(existing, incoming) {
|
|
18714
|
+
const seen = new Set(existing.map((message) => message.hash));
|
|
18715
|
+
const merged = [...existing];
|
|
18716
|
+
let added = 0;
|
|
18717
|
+
for (const message of incoming) {
|
|
18718
|
+
if (seen.has(message.hash)) {
|
|
18719
|
+
continue;
|
|
18720
|
+
}
|
|
18721
|
+
seen.add(message.hash);
|
|
18722
|
+
merged.push(message);
|
|
18723
|
+
added += 1;
|
|
18724
|
+
}
|
|
18725
|
+
return { messages: merged, added };
|
|
18726
|
+
}
|
|
18727
|
+
function getThreadFilePath(rootDir, threadKey) {
|
|
18728
|
+
return import_node_path15.default.join(rootDir, "threads", `${threadKey}.json`);
|
|
18729
|
+
}
|
|
18730
|
+
|
|
18731
|
+
// src/commands/CollectCommandHandler.ts
|
|
18667
18732
|
var CollectCommandHandler = class {
|
|
18668
18733
|
async handle(args) {
|
|
18669
18734
|
let browser = null;
|
|
18670
18735
|
try {
|
|
18671
|
-
|
|
18736
|
+
const target = resolveCollectTarget(args);
|
|
18737
|
+
browser = await import_playwright.chromium.connectOverCDP(target.endpoint);
|
|
18672
18738
|
const targetPage = await this.pickTargetPage(
|
|
18673
18739
|
browser.contexts().flatMap((context) => context.pages())
|
|
18674
18740
|
);
|
|
@@ -18677,36 +18743,20 @@ var CollectCommandHandler = class {
|
|
|
18677
18743
|
}
|
|
18678
18744
|
const { rows } = await this.locateThreadRows(targetPage);
|
|
18679
18745
|
const threads = await this.extractThreads(rows);
|
|
18680
|
-
if (
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
}
|
|
18692
|
-
await this.
|
|
18693
|
-
|
|
18694
|
-
const messages = await this.extractMessages(targetPage, matched.name);
|
|
18695
|
-
if (args.json) {
|
|
18696
|
-
ui.plain(
|
|
18697
|
-
JSON.stringify(
|
|
18698
|
-
{
|
|
18699
|
-
thread: matched,
|
|
18700
|
-
totalMessages: messages.length,
|
|
18701
|
-
messages
|
|
18702
|
-
},
|
|
18703
|
-
null,
|
|
18704
|
-
2
|
|
18705
|
-
)
|
|
18706
|
-
);
|
|
18707
|
-
return;
|
|
18708
|
-
}
|
|
18709
|
-
this.printThreadMessages(matched, messages);
|
|
18746
|
+
if (threads.length === 0) {
|
|
18747
|
+
throw new Error("No threads found in target page.");
|
|
18748
|
+
}
|
|
18749
|
+
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
18750
|
+
const results = [];
|
|
18751
|
+
for (const thread of threads) {
|
|
18752
|
+
await this.clickThreadRow(rows, thread);
|
|
18753
|
+
await targetPage.waitForTimeout(1200);
|
|
18754
|
+
const messages = await this.extractMessages(targetPage, thread.name);
|
|
18755
|
+
const result = await this.persistThread(target.rootDir, target, thread, messages, syncedAt);
|
|
18756
|
+
results.push(result);
|
|
18757
|
+
}
|
|
18758
|
+
await this.writeIndex(target.rootDir, target, results, syncedAt);
|
|
18759
|
+
this.printSyncSummary(target.sourceKey, target.rootDir, threads.length, results);
|
|
18710
18760
|
} catch (error) {
|
|
18711
18761
|
const message = error instanceof Error ? error.message : String(error);
|
|
18712
18762
|
throw new Error(`collect failed: ${message}`);
|
|
@@ -18714,6 +18764,67 @@ var CollectCommandHandler = class {
|
|
|
18714
18764
|
await browser?.close().catch(() => void 0);
|
|
18715
18765
|
}
|
|
18716
18766
|
}
|
|
18767
|
+
async persistThread(rootDir, target, thread, messages, syncedAt) {
|
|
18768
|
+
const threadKey = toThreadKey(thread.name);
|
|
18769
|
+
const existing = await readStoredThread(rootDir, threadKey);
|
|
18770
|
+
const incoming = messages.map((message) => ({
|
|
18771
|
+
hash: message.hash,
|
|
18772
|
+
time: message.time,
|
|
18773
|
+
sender: message.sender,
|
|
18774
|
+
content: message.content,
|
|
18775
|
+
links: [...message.links],
|
|
18776
|
+
images: [...message.images],
|
|
18777
|
+
collectedAt: syncedAt
|
|
18778
|
+
}));
|
|
18779
|
+
const merged = mergeMessages(existing?.messages ?? [], incoming);
|
|
18780
|
+
const stored = {
|
|
18781
|
+
source: target.sourceKey,
|
|
18782
|
+
endpoint: target.endpoint,
|
|
18783
|
+
threadKey,
|
|
18784
|
+
threadName: thread.name,
|
|
18785
|
+
preview: thread.preview,
|
|
18786
|
+
unread: thread.unread,
|
|
18787
|
+
lastMessageAt: thread.time,
|
|
18788
|
+
lastSyncedAt: syncedAt,
|
|
18789
|
+
messageCount: merged.messages.length,
|
|
18790
|
+
messages: merged.messages
|
|
18791
|
+
};
|
|
18792
|
+
await writeStoredThread(rootDir, stored);
|
|
18793
|
+
return {
|
|
18794
|
+
thread: stored,
|
|
18795
|
+
addedMessages: merged.added,
|
|
18796
|
+
updated: merged.added > 0 || !existing || existing.preview !== stored.preview || existing.unread !== stored.unread || existing.lastMessageAt !== stored.lastMessageAt
|
|
18797
|
+
};
|
|
18798
|
+
}
|
|
18799
|
+
async writeIndex(rootDir, target, results, syncedAt) {
|
|
18800
|
+
const threads = results.map(({ thread }) => ({
|
|
18801
|
+
threadKey: thread.threadKey,
|
|
18802
|
+
name: thread.threadName,
|
|
18803
|
+
unread: thread.unread,
|
|
18804
|
+
preview: thread.preview,
|
|
18805
|
+
lastMessageAt: thread.lastMessageAt,
|
|
18806
|
+
messageCount: thread.messageCount,
|
|
18807
|
+
lastSyncedAt: thread.lastSyncedAt
|
|
18808
|
+
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
18809
|
+
const messageCount = threads.reduce((sum, thread) => sum + thread.messageCount, 0);
|
|
18810
|
+
await writeStoredIndex(rootDir, {
|
|
18811
|
+
source: target.sourceKey,
|
|
18812
|
+
endpoint: target.endpoint,
|
|
18813
|
+
lastSyncedAt: syncedAt,
|
|
18814
|
+
threadCount: threads.length,
|
|
18815
|
+
messageCount,
|
|
18816
|
+
threads
|
|
18817
|
+
});
|
|
18818
|
+
}
|
|
18819
|
+
printSyncSummary(sourceKey, rootDir, scannedThreads, results) {
|
|
18820
|
+
const updatedThreads = results.filter((result) => result.updated).length;
|
|
18821
|
+
const newMessages = results.reduce((sum, result) => sum + result.addedMessages, 0);
|
|
18822
|
+
ui.plain(`Synced source: ${sourceKey}`);
|
|
18823
|
+
ui.plain(`Threads scanned: ${scannedThreads}`);
|
|
18824
|
+
ui.plain(`Threads updated: ${updatedThreads}`);
|
|
18825
|
+
ui.plain(`New messages: ${newMessages}`);
|
|
18826
|
+
ui.plain(`Saved under: ${rootDir}`);
|
|
18827
|
+
}
|
|
18717
18828
|
async pickTargetPage(pages) {
|
|
18718
18829
|
let best = null;
|
|
18719
18830
|
for (const page of pages) {
|
|
@@ -18730,7 +18841,7 @@ var CollectCommandHandler = class {
|
|
|
18730
18841
|
async locateThreadRows(page) {
|
|
18731
18842
|
const preferred = page.locator(".ReactVirtualized__Grid__innerScrollContainer").first();
|
|
18732
18843
|
const preferredCount = await preferred.locator(":scope > *").count().catch(() => 0);
|
|
18733
|
-
if (preferredCount >=
|
|
18844
|
+
if (preferredCount >= 1) {
|
|
18734
18845
|
return { rows: preferred.locator(":scope > *") };
|
|
18735
18846
|
}
|
|
18736
18847
|
const seeds = [
|
|
@@ -18750,7 +18861,7 @@ var CollectCommandHandler = class {
|
|
|
18750
18861
|
for (let i = 0; i < max; i += 1) {
|
|
18751
18862
|
const rows = containers.nth(i).locator(":scope > *");
|
|
18752
18863
|
const rowCount = await rows.count().catch(() => 0);
|
|
18753
|
-
if (rowCount <
|
|
18864
|
+
if (rowCount < 1 || rowCount > 500) {
|
|
18754
18865
|
continue;
|
|
18755
18866
|
}
|
|
18756
18867
|
const textCount = await containers.nth(i).locator("text=/./").count().catch(() => 0);
|
|
@@ -18784,21 +18895,7 @@ var CollectCommandHandler = class {
|
|
|
18784
18895
|
) ?? "";
|
|
18785
18896
|
result.push({ index: i, name, unread, preview, time });
|
|
18786
18897
|
}
|
|
18787
|
-
return result;
|
|
18788
|
-
}
|
|
18789
|
-
findThread(threads, name) {
|
|
18790
|
-
const target = normalizeText(name).toLowerCase();
|
|
18791
|
-
if (!target) {
|
|
18792
|
-
return null;
|
|
18793
|
-
}
|
|
18794
|
-
const exact = threads.find((thread) => thread.name.toLowerCase() === target);
|
|
18795
|
-
if (exact) {
|
|
18796
|
-
return exact;
|
|
18797
|
-
}
|
|
18798
|
-
const contains = threads.find(
|
|
18799
|
-
(thread) => thread.name.toLowerCase().includes(target) || target.includes(thread.name.toLowerCase())
|
|
18800
|
-
);
|
|
18801
|
-
return contains ?? null;
|
|
18898
|
+
return dedupeThreads(result);
|
|
18802
18899
|
}
|
|
18803
18900
|
async extractMessages(page, threadName) {
|
|
18804
18901
|
const container = await this.locateMessageContainer(page);
|
|
@@ -18841,17 +18938,14 @@ var CollectCommandHandler = class {
|
|
|
18841
18938
|
return messages;
|
|
18842
18939
|
}
|
|
18843
18940
|
async clickThreadRow(rows, matched) {
|
|
18844
|
-
const
|
|
18845
|
-
const
|
|
18846
|
-
if (
|
|
18847
|
-
const
|
|
18848
|
-
|
|
18941
|
+
const row = rows.nth(matched.index);
|
|
18942
|
+
const clicked = await this.tryClick(row);
|
|
18943
|
+
if (!clicked) {
|
|
18944
|
+
const exactInRows = rows.filter({ hasText: matched.name }).first();
|
|
18945
|
+
const exactCount = await exactInRows.count().catch(() => 0);
|
|
18946
|
+
if (exactCount > 0 && await this.tryClick(exactInRows)) {
|
|
18849
18947
|
return;
|
|
18850
18948
|
}
|
|
18851
|
-
}
|
|
18852
|
-
const fallback = rows.nth(matched.index);
|
|
18853
|
-
const clicked = await this.tryClick(fallback);
|
|
18854
|
-
if (!clicked) {
|
|
18855
18949
|
throw new Error(`Failed to select thread row: ${matched.name}`);
|
|
18856
18950
|
}
|
|
18857
18951
|
}
|
|
@@ -18990,31 +19084,20 @@ var CollectCommandHandler = class {
|
|
|
18990
19084
|
}
|
|
18991
19085
|
return candidates[0] ?? "";
|
|
18992
19086
|
}
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
18997
|
-
|
|
18998
|
-
}
|
|
18999
|
-
|
|
19000
|
-
|
|
19001
|
-
const unread = thread.unread > 0 ? thread.unread : messages.length;
|
|
19002
|
-
ui.plain(`## ${thread.name} (${unread})`);
|
|
19003
|
-
for (const message of messages) {
|
|
19004
|
-
ui.plain("-");
|
|
19005
|
-
ui.plain(` time: ${message.time ?? ""}`);
|
|
19006
|
-
ui.plain(` sender: ${message.sender ?? ""}`);
|
|
19007
|
-
ui.plain(` content: ${message.content}`);
|
|
19008
|
-
ui.plain(` hash: ${message.hash}`);
|
|
19009
|
-
ui.plain(
|
|
19010
|
-
` links: ${message.links.length > 0 ? message.links.join(", ") : ""}`
|
|
19011
|
-
);
|
|
19012
|
-
ui.plain(
|
|
19013
|
-
` images: ${message.images.length > 0 ? message.images.join(", ") : ""}`
|
|
19014
|
-
);
|
|
19087
|
+
};
|
|
19088
|
+
function dedupeThreads(threads) {
|
|
19089
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19090
|
+
const result = [];
|
|
19091
|
+
for (const thread of threads) {
|
|
19092
|
+
const key = `${thread.name}::${thread.preview}::${thread.time ?? ""}`;
|
|
19093
|
+
if (seen.has(key)) {
|
|
19094
|
+
continue;
|
|
19015
19095
|
}
|
|
19096
|
+
seen.add(key);
|
|
19097
|
+
result.push(thread);
|
|
19016
19098
|
}
|
|
19017
|
-
|
|
19099
|
+
return result;
|
|
19100
|
+
}
|
|
19018
19101
|
function normalizeText(value) {
|
|
19019
19102
|
return value.replace(/\s+/g, " ").replace(/\u200B/g, "").trim();
|
|
19020
19103
|
}
|
|
@@ -19027,22 +19110,46 @@ function computeMessageHash(threadName, message) {
|
|
|
19027
19110
|
message.links.map(normalizeText).join("|"),
|
|
19028
19111
|
message.images.map(normalizeText).join("|")
|
|
19029
19112
|
].join("||");
|
|
19030
|
-
return (0,
|
|
19113
|
+
return (0, import_node_crypto4.createHash)("sha1").update(base).digest("hex").slice(0, 16);
|
|
19114
|
+
}
|
|
19115
|
+
function parseMessageText(rawText) {
|
|
19116
|
+
const text = normalizeText(rawText);
|
|
19117
|
+
if (!text) {
|
|
19118
|
+
return { time: null, sender: null, content: "" };
|
|
19119
|
+
}
|
|
19120
|
+
const timeMatch = text.match(/^(\d{1,2}:\d{2}\s?(?:AM|PM)?)\s+(.*)$/i) ?? text.match(/^(\d{1,2}\/\d{1,2}|\d{4}\/\d{1,2}\/\d{1,2})\s+(.*)$/);
|
|
19121
|
+
if (!timeMatch) {
|
|
19122
|
+
return { time: null, sender: null, content: text };
|
|
19123
|
+
}
|
|
19124
|
+
const time = timeMatch[1];
|
|
19125
|
+
const rest = normalizeText(timeMatch[2] ?? "");
|
|
19126
|
+
if (!rest) {
|
|
19127
|
+
return { time, sender: null, content: "" };
|
|
19128
|
+
}
|
|
19129
|
+
const senderMatch = rest.match(/^([^:]{1,80}):\s*(.*)$/);
|
|
19130
|
+
if (!senderMatch) {
|
|
19131
|
+
return { time, sender: null, content: rest };
|
|
19132
|
+
}
|
|
19133
|
+
return {
|
|
19134
|
+
time,
|
|
19135
|
+
sender: normalizeText(senderMatch[1] ?? "") || null,
|
|
19136
|
+
content: normalizeText(senderMatch[2] ?? "")
|
|
19137
|
+
};
|
|
19031
19138
|
}
|
|
19032
19139
|
async function toDisplayableImagePath(src) {
|
|
19033
|
-
if (!
|
|
19140
|
+
if (!import_node_path16.default.isAbsolute(src)) {
|
|
19034
19141
|
return src;
|
|
19035
19142
|
}
|
|
19036
|
-
const ext =
|
|
19143
|
+
const ext = import_node_path16.default.extname(src);
|
|
19037
19144
|
if (ext) {
|
|
19038
19145
|
return src;
|
|
19039
19146
|
}
|
|
19040
19147
|
try {
|
|
19041
|
-
const stat = await
|
|
19148
|
+
const stat = await import_node_fs11.promises.stat(src);
|
|
19042
19149
|
if (!stat.isFile()) {
|
|
19043
19150
|
return src;
|
|
19044
19151
|
}
|
|
19045
|
-
const fh = await
|
|
19152
|
+
const fh = await import_node_fs11.promises.open(src, "r");
|
|
19046
19153
|
try {
|
|
19047
19154
|
const buf = Buffer.alloc(32);
|
|
19048
19155
|
const { bytesRead } = await fh.read(buf, 0, 32, 0);
|
|
@@ -19051,17 +19158,17 @@ async function toDisplayableImagePath(src) {
|
|
|
19051
19158
|
if (!guessedExt) {
|
|
19052
19159
|
return src;
|
|
19053
19160
|
}
|
|
19054
|
-
const cacheDir =
|
|
19055
|
-
|
|
19161
|
+
const cacheDir = import_node_path16.default.join(
|
|
19162
|
+
import_node_os6.default.homedir(),
|
|
19056
19163
|
".pmate",
|
|
19057
19164
|
"messages",
|
|
19058
19165
|
"images"
|
|
19059
19166
|
);
|
|
19060
|
-
await
|
|
19061
|
-
const base = (0,
|
|
19062
|
-
const displayPath =
|
|
19063
|
-
await
|
|
19064
|
-
await
|
|
19167
|
+
await import_node_fs11.promises.mkdir(cacheDir, { recursive: true });
|
|
19168
|
+
const base = (0, import_node_crypto4.createHash)("sha1").update(src).digest("hex");
|
|
19169
|
+
const displayPath = import_node_path16.default.join(cacheDir, `${base}.${guessedExt}`);
|
|
19170
|
+
await import_node_fs11.promises.rm(displayPath, { force: true }).catch(() => void 0);
|
|
19171
|
+
await import_node_fs11.promises.copyFile(src, displayPath);
|
|
19065
19172
|
return displayPath;
|
|
19066
19173
|
} finally {
|
|
19067
19174
|
await fh.close();
|
|
@@ -19085,40 +19192,10 @@ function guessImageExtension(header) {
|
|
|
19085
19192
|
}
|
|
19086
19193
|
return null;
|
|
19087
19194
|
}
|
|
19088
|
-
function parseMessageText(raw) {
|
|
19089
|
-
if (!raw) {
|
|
19090
|
-
return { time: null, sender: null, content: "" };
|
|
19091
|
-
}
|
|
19092
|
-
const timeMatches = raw.match(/\b\d{1,2}:\d{2}\s?(?:AM|PM)\b/gi) || [];
|
|
19093
|
-
const time = timeMatches.length > 0 ? timeMatches[timeMatches.length - 1] : null;
|
|
19094
|
-
let sender = null;
|
|
19095
|
-
const chefSender = raw.match(/^(Chef\s+[A-Za-z0-9_-]+)/);
|
|
19096
|
-
if (chefSender) {
|
|
19097
|
-
sender = chefSender[1];
|
|
19098
|
-
} else {
|
|
19099
|
-
const simpleSender = raw.match(/^([A-Za-z][A-Za-z0-9._-]{1,30})/);
|
|
19100
|
-
sender = simpleSender ? simpleSender[1] : null;
|
|
19101
|
-
}
|
|
19102
|
-
let content = raw;
|
|
19103
|
-
if (sender && content.startsWith(sender)) {
|
|
19104
|
-
content = content.slice(sender.length).trim();
|
|
19105
|
-
}
|
|
19106
|
-
if (time) {
|
|
19107
|
-
const timeIdx = content.lastIndexOf(time);
|
|
19108
|
-
if (timeIdx >= 0) {
|
|
19109
|
-
content = content.slice(0, timeIdx).trim();
|
|
19110
|
-
}
|
|
19111
|
-
}
|
|
19112
|
-
content = content.replace(
|
|
19113
|
-
/QuoteReply|Forward|Save to Note|Select|Pin|Add To-Do|Info|Translate>English中文/g,
|
|
19114
|
-
" "
|
|
19115
|
-
).replace(/Group Chat History|Chat History/g, " ").replace(/\s+/g, " ").trim();
|
|
19116
|
-
return { time, sender, content };
|
|
19117
|
-
}
|
|
19118
19195
|
|
|
19119
19196
|
// src/commands/AgentCommandHandler.ts
|
|
19120
|
-
var
|
|
19121
|
-
var
|
|
19197
|
+
var import_node_fs12 = require("fs");
|
|
19198
|
+
var import_node_path17 = __toESM(require("path"));
|
|
19122
19199
|
init_AgentLlmClient();
|
|
19123
19200
|
init_sessionStore();
|
|
19124
19201
|
|
|
@@ -19126,7 +19203,7 @@ init_sessionStore();
|
|
|
19126
19203
|
var STORE_LOG_VERSION = 1;
|
|
19127
19204
|
var LOG_KIND_TABLE = 1e4;
|
|
19128
19205
|
var LOG_KIND_MAPPING = 6003;
|
|
19129
|
-
function
|
|
19206
|
+
function createHash4() {
|
|
19130
19207
|
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
19131
19208
|
}
|
|
19132
19209
|
function createDescriptor(input) {
|
|
@@ -19151,8 +19228,8 @@ function descriptorPathSegments(descriptor) {
|
|
|
19151
19228
|
return ["chains", normalized.chain, "namespaces", normalized.ns, normalized.kind, normalized.name];
|
|
19152
19229
|
}
|
|
19153
19230
|
function buildPathUrl(baseUrl, pathSegments, query) {
|
|
19154
|
-
const
|
|
19155
|
-
const url = new URL(
|
|
19231
|
+
const path24 = `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
19232
|
+
const url = new URL(path24, baseUrl);
|
|
19156
19233
|
if (query) {
|
|
19157
19234
|
for (const [key, value] of Object.entries(query)) {
|
|
19158
19235
|
url.searchParams.set(key, String(value));
|
|
@@ -19265,7 +19342,7 @@ var Namespace = class {
|
|
|
19265
19342
|
},
|
|
19266
19343
|
appendRow: async (data) => {
|
|
19267
19344
|
const log = {
|
|
19268
|
-
hash:
|
|
19345
|
+
hash: createHash4(),
|
|
19269
19346
|
t: Date.now(),
|
|
19270
19347
|
kind: LOG_KIND_TABLE,
|
|
19271
19348
|
topic: descriptorToTopic(descriptor),
|
|
@@ -19277,7 +19354,7 @@ var Namespace = class {
|
|
|
19277
19354
|
updateRow: async (data) => {
|
|
19278
19355
|
const { id, ...value } = data;
|
|
19279
19356
|
const log = {
|
|
19280
|
-
hash:
|
|
19357
|
+
hash: createHash4(),
|
|
19281
19358
|
t: Date.now(),
|
|
19282
19359
|
kind: LOG_KIND_TABLE,
|
|
19283
19360
|
topic: descriptorToTopic(descriptor),
|
|
@@ -19288,7 +19365,7 @@ var Namespace = class {
|
|
|
19288
19365
|
},
|
|
19289
19366
|
deleteRow: async (id) => {
|
|
19290
19367
|
const log = {
|
|
19291
|
-
hash:
|
|
19368
|
+
hash: createHash4(),
|
|
19292
19369
|
t: Date.now(),
|
|
19293
19370
|
kind: LOG_KIND_TABLE,
|
|
19294
19371
|
topic: descriptorToTopic(descriptor),
|
|
@@ -19331,7 +19408,7 @@ var Namespace = class {
|
|
|
19331
19408
|
},
|
|
19332
19409
|
set: async (key, value) => {
|
|
19333
19410
|
const log = {
|
|
19334
|
-
hash:
|
|
19411
|
+
hash: createHash4(),
|
|
19335
19412
|
t: Date.now(),
|
|
19336
19413
|
kind: LOG_KIND_MAPPING,
|
|
19337
19414
|
topic: descriptorToTopic(descriptor),
|
|
@@ -19342,7 +19419,7 @@ var Namespace = class {
|
|
|
19342
19419
|
},
|
|
19343
19420
|
delete: async (key) => {
|
|
19344
19421
|
const log = {
|
|
19345
|
-
hash:
|
|
19422
|
+
hash: createHash4(),
|
|
19346
19423
|
t: Date.now(),
|
|
19347
19424
|
kind: LOG_KIND_MAPPING,
|
|
19348
19425
|
topic: descriptorToTopic(descriptor),
|
|
@@ -19535,6 +19612,24 @@ var AgentCommandHandler = class {
|
|
|
19535
19612
|
this.renderJson(record, args.json);
|
|
19536
19613
|
return;
|
|
19537
19614
|
}
|
|
19615
|
+
case "move": {
|
|
19616
|
+
const record = await this.request(
|
|
19617
|
+
baseUrl,
|
|
19618
|
+
token,
|
|
19619
|
+
"POST",
|
|
19620
|
+
`/agents/${encodeURIComponent(args.namespace)}/move`,
|
|
19621
|
+
{
|
|
19622
|
+
from: args.fromName,
|
|
19623
|
+
toNamespace: args.targetNamespace,
|
|
19624
|
+
...args.toName ? { to: args.toName } : {}
|
|
19625
|
+
}
|
|
19626
|
+
);
|
|
19627
|
+
ui.success(
|
|
19628
|
+
`Moved agent ${formatNamespacedDisplayId(args.namespace, args.fromName)} -> ${record.id}`
|
|
19629
|
+
);
|
|
19630
|
+
this.renderJson(record, args.json);
|
|
19631
|
+
return;
|
|
19632
|
+
}
|
|
19538
19633
|
}
|
|
19539
19634
|
}
|
|
19540
19635
|
resolveBaseUrl(baseUrl) {
|
|
@@ -19566,11 +19661,11 @@ var AgentCommandHandler = class {
|
|
|
19566
19661
|
}).token;
|
|
19567
19662
|
}
|
|
19568
19663
|
readJsonFile(filePath) {
|
|
19569
|
-
const absolutePath =
|
|
19570
|
-
if (!(0,
|
|
19664
|
+
const absolutePath = import_node_path17.default.resolve(process.cwd(), filePath);
|
|
19665
|
+
if (!(0, import_node_fs12.existsSync)(absolutePath)) {
|
|
19571
19666
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
19572
19667
|
}
|
|
19573
|
-
const raw = (0,
|
|
19668
|
+
const raw = (0, import_node_fs12.readFileSync)(absolutePath, "utf8");
|
|
19574
19669
|
try {
|
|
19575
19670
|
return JSON.parse(raw);
|
|
19576
19671
|
} catch (error) {
|
|
@@ -19581,7 +19676,7 @@ var AgentCommandHandler = class {
|
|
|
19581
19676
|
readJsonObjectFile(filePath) {
|
|
19582
19677
|
const parsed = this.readJsonFile(filePath);
|
|
19583
19678
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19584
|
-
const absolutePath =
|
|
19679
|
+
const absolutePath = import_node_path17.default.resolve(process.cwd(), filePath);
|
|
19585
19680
|
throw new Error(`Invalid JSON in ${absolutePath}: expected an object`);
|
|
19586
19681
|
}
|
|
19587
19682
|
return parsed;
|
|
@@ -19664,6 +19759,160 @@ var AgentCommandHandler = class {
|
|
|
19664
19759
|
}
|
|
19665
19760
|
};
|
|
19666
19761
|
|
|
19762
|
+
// src/commands/RunnerCommandHandler.ts
|
|
19763
|
+
var import_node_fs13 = require("fs");
|
|
19764
|
+
var import_node_path18 = __toESM(require("path"));
|
|
19765
|
+
init_sessionStore();
|
|
19766
|
+
init_namespacedRef();
|
|
19767
|
+
var RunnerCommandHandler = class {
|
|
19768
|
+
async handle(args) {
|
|
19769
|
+
const token = this.readToken();
|
|
19770
|
+
const baseUrl = this.resolveBaseUrl(args.baseUrl);
|
|
19771
|
+
switch (args.action) {
|
|
19772
|
+
case "list": {
|
|
19773
|
+
const items = (await this.request(
|
|
19774
|
+
baseUrl,
|
|
19775
|
+
token,
|
|
19776
|
+
"GET",
|
|
19777
|
+
args.namespace ? `/runners?namespace=${encodeURIComponent(args.namespace)}` : "/runners/all"
|
|
19778
|
+
)).items;
|
|
19779
|
+
this.renderList(items, args.json);
|
|
19780
|
+
return;
|
|
19781
|
+
}
|
|
19782
|
+
case "get":
|
|
19783
|
+
case "view": {
|
|
19784
|
+
const record = await this.request(
|
|
19785
|
+
baseUrl,
|
|
19786
|
+
token,
|
|
19787
|
+
"GET",
|
|
19788
|
+
`/runners/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
|
|
19789
|
+
);
|
|
19790
|
+
this.renderJson(record, true);
|
|
19791
|
+
return;
|
|
19792
|
+
}
|
|
19793
|
+
case "create": {
|
|
19794
|
+
await this.requireNamespace(args.namespace, baseUrl);
|
|
19795
|
+
const payload = this.readJsonFile(args.filePath);
|
|
19796
|
+
const record = await this.request(
|
|
19797
|
+
baseUrl,
|
|
19798
|
+
token,
|
|
19799
|
+
"POST",
|
|
19800
|
+
`/runners/${encodeURIComponent(args.namespace)}`,
|
|
19801
|
+
payload
|
|
19802
|
+
);
|
|
19803
|
+
ui.success(`Created runner ${record.id}`);
|
|
19804
|
+
this.renderJson(record, args.json);
|
|
19805
|
+
return;
|
|
19806
|
+
}
|
|
19807
|
+
case "update": {
|
|
19808
|
+
const payload = this.readJsonFile(args.filePath);
|
|
19809
|
+
const record = await this.request(
|
|
19810
|
+
baseUrl,
|
|
19811
|
+
token,
|
|
19812
|
+
"PUT",
|
|
19813
|
+
`/runners/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`,
|
|
19814
|
+
payload
|
|
19815
|
+
);
|
|
19816
|
+
ui.success(`Updated runner ${record.id}`);
|
|
19817
|
+
this.renderJson(record, args.json);
|
|
19818
|
+
return;
|
|
19819
|
+
}
|
|
19820
|
+
case "delete": {
|
|
19821
|
+
const record = await this.request(
|
|
19822
|
+
baseUrl,
|
|
19823
|
+
token,
|
|
19824
|
+
"DELETE",
|
|
19825
|
+
`/runners/${encodeURIComponent(args.namespace)}/${encodeURIComponent(args.name)}`
|
|
19826
|
+
);
|
|
19827
|
+
ui.success(`Disabled runner ${record.id}`);
|
|
19828
|
+
this.renderJson(record, args.json);
|
|
19829
|
+
return;
|
|
19830
|
+
}
|
|
19831
|
+
}
|
|
19832
|
+
}
|
|
19833
|
+
resolveBaseUrl(baseUrl) {
|
|
19834
|
+
return (baseUrl || process.env.PMATE_AGENT_API_BASE_URL || "https://agent-api.pmate.chat").replace(/\/+$/, "");
|
|
19835
|
+
}
|
|
19836
|
+
async requireNamespace(namespace, registryBaseUrl) {
|
|
19837
|
+
const registry = new NamespaceRegistry({
|
|
19838
|
+
chain: "pmate",
|
|
19839
|
+
registryBaseUrl: this.resolveNamespaceBaseUrl(registryBaseUrl)
|
|
19840
|
+
});
|
|
19841
|
+
const exists = await registry.exists(namespace);
|
|
19842
|
+
if (!exists) {
|
|
19843
|
+
throw new Error(`Namespace "${namespace}" is not registered. Run: pmate ns create ${namespace}`);
|
|
19844
|
+
}
|
|
19845
|
+
}
|
|
19846
|
+
resolveNamespaceBaseUrl(baseUrl) {
|
|
19847
|
+
const envBaseUrl = process.env.PMATE_NAMESPACE_API_BASE_URL || process.env.PMATE_APPS_API_BASE_URL;
|
|
19848
|
+
if (envBaseUrl) {
|
|
19849
|
+
return envBaseUrl.replace(/\/+$/, "");
|
|
19850
|
+
}
|
|
19851
|
+
return baseUrl.includes("agent-api") || baseUrl.includes("agent.local") ? baseUrl.replace("agent-api", "apps-api").replace("agent.local", "apps.local") : baseUrl;
|
|
19852
|
+
}
|
|
19853
|
+
readToken() {
|
|
19854
|
+
return readRequiredSession({
|
|
19855
|
+
preferredApp: DEFAULT_APP_ID
|
|
19856
|
+
}).token;
|
|
19857
|
+
}
|
|
19858
|
+
readJsonFile(filePath) {
|
|
19859
|
+
const absolutePath = import_node_path18.default.resolve(process.cwd(), filePath);
|
|
19860
|
+
if (!(0, import_node_fs13.existsSync)(absolutePath)) {
|
|
19861
|
+
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
19862
|
+
}
|
|
19863
|
+
const raw = (0, import_node_fs13.readFileSync)(absolutePath, "utf8");
|
|
19864
|
+
try {
|
|
19865
|
+
return JSON.parse(raw);
|
|
19866
|
+
} catch (error) {
|
|
19867
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19868
|
+
throw new Error(`Invalid JSON in ${absolutePath}: ${message}`);
|
|
19869
|
+
}
|
|
19870
|
+
}
|
|
19871
|
+
async request(baseUrl, token, method, pathname, body) {
|
|
19872
|
+
const response = await fetch(`${baseUrl}${pathname}`, {
|
|
19873
|
+
method,
|
|
19874
|
+
headers: {
|
|
19875
|
+
Authorization: `Bearer ${token}`,
|
|
19876
|
+
"Content-Type": "application/json"
|
|
19877
|
+
},
|
|
19878
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
19879
|
+
});
|
|
19880
|
+
let payload = null;
|
|
19881
|
+
try {
|
|
19882
|
+
payload = await response.json();
|
|
19883
|
+
} catch {
|
|
19884
|
+
payload = null;
|
|
19885
|
+
}
|
|
19886
|
+
if (!response.ok || !payload?.success) {
|
|
19887
|
+
throw new Error(payload?.message || `Request failed with status ${response.status}`);
|
|
19888
|
+
}
|
|
19889
|
+
return payload.data;
|
|
19890
|
+
}
|
|
19891
|
+
renderList(items, asJson) {
|
|
19892
|
+
if (asJson) {
|
|
19893
|
+
ui.plain(JSON.stringify(items, null, 2));
|
|
19894
|
+
return;
|
|
19895
|
+
}
|
|
19896
|
+
if (items.length === 0) {
|
|
19897
|
+
ui.warn("No runners found.");
|
|
19898
|
+
return;
|
|
19899
|
+
}
|
|
19900
|
+
for (const item of items) {
|
|
19901
|
+
ui.info(formatNamespacedDisplayId(item.namespace, item.name), {
|
|
19902
|
+
status: item.status,
|
|
19903
|
+
runtime: item.payload.runtime,
|
|
19904
|
+
listen: item.payload.listen
|
|
19905
|
+
});
|
|
19906
|
+
}
|
|
19907
|
+
}
|
|
19908
|
+
renderJson(value, asJson) {
|
|
19909
|
+
if (!asJson) {
|
|
19910
|
+
return;
|
|
19911
|
+
}
|
|
19912
|
+
ui.plain(JSON.stringify(value, null, 2));
|
|
19913
|
+
}
|
|
19914
|
+
};
|
|
19915
|
+
|
|
19667
19916
|
// src/commands/NsCommandHandler.ts
|
|
19668
19917
|
init_sessionStore();
|
|
19669
19918
|
var NsCommandHandler = class {
|
|
@@ -19730,8 +19979,8 @@ var NsCommandHandler = class {
|
|
|
19730
19979
|
};
|
|
19731
19980
|
|
|
19732
19981
|
// src/commands/StoreCommandHandler.ts
|
|
19733
|
-
var
|
|
19734
|
-
var
|
|
19982
|
+
var import_node_fs14 = require("fs");
|
|
19983
|
+
var import_node_path19 = __toESM(require("path"));
|
|
19735
19984
|
var StoreCommandHandler = class {
|
|
19736
19985
|
async handle(args) {
|
|
19737
19986
|
if (args.scope === "namespace") {
|
|
@@ -19873,11 +20122,11 @@ var StoreCommandHandler = class {
|
|
|
19873
20122
|
return payload.data ?? [];
|
|
19874
20123
|
}
|
|
19875
20124
|
readJsonFile(filePath) {
|
|
19876
|
-
const absolutePath =
|
|
19877
|
-
if (!(0,
|
|
20125
|
+
const absolutePath = import_node_path19.default.resolve(process.cwd(), filePath);
|
|
20126
|
+
if (!(0, import_node_fs14.existsSync)(absolutePath)) {
|
|
19878
20127
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
19879
20128
|
}
|
|
19880
|
-
const raw = (0,
|
|
20129
|
+
const raw = (0, import_node_fs14.readFileSync)(absolutePath, "utf8");
|
|
19881
20130
|
try {
|
|
19882
20131
|
return JSON.parse(raw);
|
|
19883
20132
|
} catch (error) {
|
|
@@ -19929,8 +20178,8 @@ var StoreCommandHandler = class {
|
|
|
19929
20178
|
};
|
|
19930
20179
|
|
|
19931
20180
|
// src/commands/AppCommandHandler.ts
|
|
19932
|
-
var
|
|
19933
|
-
var
|
|
20181
|
+
var import_node_fs15 = require("fs");
|
|
20182
|
+
var import_node_path20 = __toESM(require("path"));
|
|
19934
20183
|
init_sessionStore();
|
|
19935
20184
|
init_namespacedRef();
|
|
19936
20185
|
var AppCommandHandler = class {
|
|
@@ -20018,22 +20267,40 @@ var AppCommandHandler = class {
|
|
|
20018
20267
|
this.renderJson(record, args.json);
|
|
20019
20268
|
return;
|
|
20020
20269
|
}
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20270
|
+
case "move": {
|
|
20271
|
+
const record = await this.request(
|
|
20272
|
+
baseUrl,
|
|
20273
|
+
token,
|
|
20274
|
+
"POST",
|
|
20275
|
+
`/apps/${encodeURIComponent(args.namespace)}/move`,
|
|
20276
|
+
{
|
|
20277
|
+
fromId: args.fromId,
|
|
20278
|
+
toNamespace: args.targetNamespace,
|
|
20279
|
+
...args.toId ? { toId: args.toId } : {}
|
|
20280
|
+
}
|
|
20281
|
+
);
|
|
20282
|
+
ui.success(
|
|
20283
|
+
`Moved app ${formatNamespacedDisplayId(args.namespace, args.fromId)} -> ${formatNamespacedDisplayId(record.namespace, record.id)}`
|
|
20284
|
+
);
|
|
20285
|
+
this.renderJson(record, args.json);
|
|
20286
|
+
return;
|
|
20287
|
+
}
|
|
20288
|
+
}
|
|
20289
|
+
}
|
|
20290
|
+
resolveBaseUrl(baseUrl) {
|
|
20291
|
+
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
20292
|
+
}
|
|
20293
|
+
readToken() {
|
|
20294
|
+
return readRequiredSession({
|
|
20295
|
+
preferredApp: DEFAULT_APP_ID
|
|
20296
|
+
}).token;
|
|
20030
20297
|
}
|
|
20031
20298
|
readJsonFile(filePath) {
|
|
20032
|
-
const absolutePath =
|
|
20033
|
-
if (!(0,
|
|
20299
|
+
const absolutePath = import_node_path20.default.resolve(process.cwd(), filePath);
|
|
20300
|
+
if (!(0, import_node_fs15.existsSync)(absolutePath)) {
|
|
20034
20301
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
20035
20302
|
}
|
|
20036
|
-
const raw = (0,
|
|
20303
|
+
const raw = (0, import_node_fs15.readFileSync)(absolutePath, "utf8");
|
|
20037
20304
|
try {
|
|
20038
20305
|
return JSON.parse(raw);
|
|
20039
20306
|
} catch (error) {
|
|
@@ -20113,13 +20380,13 @@ function readNamespaceFromPayload(payload) {
|
|
|
20113
20380
|
}
|
|
20114
20381
|
|
|
20115
20382
|
// src/commands/ServiceCommandHandler.ts
|
|
20116
|
-
var
|
|
20117
|
-
var
|
|
20383
|
+
var import_node_fs17 = require("fs");
|
|
20384
|
+
var import_node_path22 = __toESM(require("path"));
|
|
20118
20385
|
|
|
20119
20386
|
// src/services/ServiceRuntimeRunner.ts
|
|
20120
|
-
var
|
|
20121
|
-
var
|
|
20122
|
-
var
|
|
20387
|
+
var import_node_fs16 = require("fs");
|
|
20388
|
+
var import_node_os7 = __toESM(require("os"));
|
|
20389
|
+
var import_node_path21 = __toESM(require("path"));
|
|
20123
20390
|
var import_node_child_process9 = require("child_process");
|
|
20124
20391
|
var import_node_readline = require("readline");
|
|
20125
20392
|
var import_chalk3 = __toESM(require("chalk"));
|
|
@@ -20232,14 +20499,14 @@ var ServiceRuntimeRunner = class {
|
|
|
20232
20499
|
}
|
|
20233
20500
|
resolveRepoRoot(service, cwd) {
|
|
20234
20501
|
if (cwd) {
|
|
20235
|
-
return
|
|
20502
|
+
return import_node_path21.default.resolve(process.cwd(), cwd);
|
|
20236
20503
|
}
|
|
20237
20504
|
const repository = this.getDeploy(service).repository?.trim();
|
|
20238
20505
|
if (repository) {
|
|
20239
20506
|
const repoName = repository.replace(/\/+$/, "").split("/").pop()?.replace(/\.git$/i, "");
|
|
20240
20507
|
if (repoName) {
|
|
20241
|
-
const candidate =
|
|
20242
|
-
if ((0,
|
|
20508
|
+
const candidate = import_node_path21.default.join(import_node_os7.default.homedir(), "dev", "pmate", repoName);
|
|
20509
|
+
if ((0, import_node_fs16.existsSync)(candidate)) {
|
|
20243
20510
|
return candidate;
|
|
20244
20511
|
}
|
|
20245
20512
|
}
|
|
@@ -20252,12 +20519,12 @@ var ServiceRuntimeRunner = class {
|
|
|
20252
20519
|
if (!dir) {
|
|
20253
20520
|
throw new Error(`Missing deploy.dir for ${service.id}`);
|
|
20254
20521
|
}
|
|
20255
|
-
return
|
|
20522
|
+
return import_node_path21.default.resolve(repoRoot, dir);
|
|
20256
20523
|
}
|
|
20257
20524
|
async deployVite(service, options) {
|
|
20258
20525
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
20259
|
-
const packageJsonPath =
|
|
20260
|
-
if (!(0,
|
|
20526
|
+
const packageJsonPath = import_node_path21.default.join(appDir, "package.json");
|
|
20527
|
+
if (!(0, import_node_fs16.existsSync)(packageJsonPath)) {
|
|
20261
20528
|
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
20262
20529
|
}
|
|
20263
20530
|
const pkg2 = this.loadPackageJson(packageJsonPath);
|
|
@@ -20266,8 +20533,8 @@ var ServiceRuntimeRunner = class {
|
|
|
20266
20533
|
throw new Error(`Missing package name in ${packageJsonPath}`);
|
|
20267
20534
|
}
|
|
20268
20535
|
await this.runCommand("pnpm", ["--filter", pkgName, "build"], this.resolveRepoRoot(service, options.cwd));
|
|
20269
|
-
const distDir =
|
|
20270
|
-
if (!(0,
|
|
20536
|
+
const distDir = import_node_path21.default.join(appDir, "dist");
|
|
20537
|
+
if (!(0, import_node_fs16.existsSync)(distDir)) {
|
|
20271
20538
|
throw new Error(`No dist directory found at ${distDir}`);
|
|
20272
20539
|
}
|
|
20273
20540
|
const bucketName = this.getDeploy(service).bucket?.trim();
|
|
@@ -20278,8 +20545,8 @@ var ServiceRuntimeRunner = class {
|
|
|
20278
20545
|
}
|
|
20279
20546
|
async deployStatic(service, options) {
|
|
20280
20547
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
20281
|
-
const srcDir =
|
|
20282
|
-
if (!(0,
|
|
20548
|
+
const srcDir = import_node_path21.default.join(appDir, "src");
|
|
20549
|
+
if (!(0, import_node_fs16.existsSync)(srcDir)) {
|
|
20283
20550
|
throw new Error(`No src directory found at ${srcDir}`);
|
|
20284
20551
|
}
|
|
20285
20552
|
const bucketName = this.getDeploy(service).bucket?.trim();
|
|
@@ -20397,7 +20664,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20397
20664
|
const serverAddress = await resolveServerAddress(server);
|
|
20398
20665
|
const templateName = serviceType === "ws" ? "nginx.ws.template" : "nginx.rest.template";
|
|
20399
20666
|
const templatePath = this.resolveTemplatePath(templateName);
|
|
20400
|
-
const template = (0,
|
|
20667
|
+
const template = (0, import_node_fs16.readFileSync)(templatePath, "utf8");
|
|
20401
20668
|
const host = `${subdomain}.${deploy.domain?.trim() || "pmate.chat"}`;
|
|
20402
20669
|
const rendered = template.replace(/\$\{\{PORT\}\}/g, String(port)).replace(/\$\{\{HOSTS\}\}/g, host).replace(/\$\{\{HOST\}\}/g, host);
|
|
20403
20670
|
const remotePath = `/etc/nginx/sites-enabled/${subdomain}.conf`;
|
|
@@ -20429,11 +20696,11 @@ var ServiceRuntimeRunner = class {
|
|
|
20429
20696
|
}
|
|
20430
20697
|
if (config.ensurePackageJson) {
|
|
20431
20698
|
const appDir = this.resolveLocalDir(service, options.cwd);
|
|
20432
|
-
const packageJsonPath =
|
|
20433
|
-
if (!(0,
|
|
20699
|
+
const packageJsonPath = import_node_path21.default.join(appDir, "package.json");
|
|
20700
|
+
if (!(0, import_node_fs16.existsSync)(packageJsonPath)) {
|
|
20434
20701
|
throw new Error(`Missing package.json at ${packageJsonPath}`);
|
|
20435
20702
|
}
|
|
20436
|
-
const pkgStat = (0,
|
|
20703
|
+
const pkgStat = (0, import_node_fs16.statSync)(packageJsonPath);
|
|
20437
20704
|
if (!pkgStat.isFile()) {
|
|
20438
20705
|
throw new Error(`package.json is not a file at ${packageJsonPath}`);
|
|
20439
20706
|
}
|
|
@@ -20856,9 +21123,9 @@ var ServiceRuntimeRunner = class {
|
|
|
20856
21123
|
return tokens;
|
|
20857
21124
|
}
|
|
20858
21125
|
readPathValue(source, pathExpr) {
|
|
20859
|
-
const
|
|
21126
|
+
const path24 = pathExpr.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
20860
21127
|
let cursor = source;
|
|
20861
|
-
for (const segment of
|
|
21128
|
+
for (const segment of path24) {
|
|
20862
21129
|
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
|
|
20863
21130
|
return void 0;
|
|
20864
21131
|
}
|
|
@@ -20901,12 +21168,12 @@ var ServiceRuntimeRunner = class {
|
|
|
20901
21168
|
}
|
|
20902
21169
|
resolveTemplatePath(templateName) {
|
|
20903
21170
|
const candidates = [
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
21171
|
+
import_node_path21.default.join(__dirname, "..", "templates", templateName),
|
|
21172
|
+
import_node_path21.default.join(__dirname, "..", "src", "templates", templateName),
|
|
21173
|
+
import_node_path21.default.join(__dirname, "templates", templateName)
|
|
20907
21174
|
];
|
|
20908
21175
|
for (const candidate of candidates) {
|
|
20909
|
-
if ((0,
|
|
21176
|
+
if ((0, import_node_fs16.existsSync)(candidate)) {
|
|
20910
21177
|
return candidate;
|
|
20911
21178
|
}
|
|
20912
21179
|
}
|
|
@@ -20938,7 +21205,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20938
21205
|
});
|
|
20939
21206
|
}
|
|
20940
21207
|
loadPackageJson(packageJsonPath) {
|
|
20941
|
-
const raw = (0,
|
|
21208
|
+
const raw = (0, import_node_fs16.readFileSync)(packageJsonPath, "utf8");
|
|
20942
21209
|
const parsed = JSON.parse(raw);
|
|
20943
21210
|
if (!parsed || typeof parsed !== "object") {
|
|
20944
21211
|
throw new Error(`Invalid package.json at ${packageJsonPath}`);
|
|
@@ -20947,7 +21214,7 @@ var ServiceRuntimeRunner = class {
|
|
|
20947
21214
|
}
|
|
20948
21215
|
writePackageJson(packageJsonPath, data) {
|
|
20949
21216
|
const serialized = JSON.stringify(data, null, 2);
|
|
20950
|
-
(0,
|
|
21217
|
+
(0, import_node_fs16.writeFileSync)(packageJsonPath, `${serialized}
|
|
20951
21218
|
`, "utf8");
|
|
20952
21219
|
}
|
|
20953
21220
|
runCommand(command, args, cwd) {
|
|
@@ -21172,6 +21439,23 @@ var ServiceCommandHandler = class {
|
|
|
21172
21439
|
this.renderJson(record, args.json);
|
|
21173
21440
|
return;
|
|
21174
21441
|
}
|
|
21442
|
+
case "move": {
|
|
21443
|
+
const record = await this.request(
|
|
21444
|
+
baseUrl,
|
|
21445
|
+
"POST",
|
|
21446
|
+
`/services/${encodeURIComponent(args.namespace)}/move`,
|
|
21447
|
+
{
|
|
21448
|
+
from: args.fromName,
|
|
21449
|
+
toNamespace: args.targetNamespace,
|
|
21450
|
+
...args.toName ? { to: args.toName } : {}
|
|
21451
|
+
}
|
|
21452
|
+
);
|
|
21453
|
+
ui.success(
|
|
21454
|
+
`Moved service ${formatNamespacedDisplayId(args.namespace, args.fromName)} -> ${record.id}`
|
|
21455
|
+
);
|
|
21456
|
+
this.renderJson(record, args.json);
|
|
21457
|
+
return;
|
|
21458
|
+
}
|
|
21175
21459
|
case "deploy": {
|
|
21176
21460
|
const record = await registry.getService(args.namespace, args.name);
|
|
21177
21461
|
await runtime.deploy(record, { cwd: args.cwd });
|
|
@@ -21198,11 +21482,11 @@ var ServiceCommandHandler = class {
|
|
|
21198
21482
|
return (baseUrl || process.env.PMATE_APPS_API_BASE_URL || "https://apps-api.pmate.chat").replace(/\/+$/, "");
|
|
21199
21483
|
}
|
|
21200
21484
|
readJsonFile(filePath) {
|
|
21201
|
-
const absolutePath =
|
|
21202
|
-
if (!(0,
|
|
21485
|
+
const absolutePath = import_node_path22.default.resolve(process.cwd(), filePath);
|
|
21486
|
+
if (!(0, import_node_fs17.existsSync)(absolutePath)) {
|
|
21203
21487
|
throw new Error(`JSON file not found: ${absolutePath}`);
|
|
21204
21488
|
}
|
|
21205
|
-
const raw = (0,
|
|
21489
|
+
const raw = (0, import_node_fs17.readFileSync)(absolutePath, "utf8");
|
|
21206
21490
|
try {
|
|
21207
21491
|
return JSON.parse(raw);
|
|
21208
21492
|
} catch (error) {
|
|
@@ -21913,6 +22197,54 @@ function parseAgentArgs(tokens) {
|
|
|
21913
22197
|
json
|
|
21914
22198
|
};
|
|
21915
22199
|
}
|
|
22200
|
+
if (action === "move") {
|
|
22201
|
+
let namespace;
|
|
22202
|
+
let from;
|
|
22203
|
+
let targetNamespace;
|
|
22204
|
+
let to;
|
|
22205
|
+
while (rest.length > 0) {
|
|
22206
|
+
const token = rest.shift();
|
|
22207
|
+
switch (token) {
|
|
22208
|
+
case "--ns":
|
|
22209
|
+
case "--namespace":
|
|
22210
|
+
namespace = requireValue(rest, token);
|
|
22211
|
+
break;
|
|
22212
|
+
case "--from":
|
|
22213
|
+
from = parseBareRenameId(requireValue(rest, token), "agent");
|
|
22214
|
+
break;
|
|
22215
|
+
case "--to-ns":
|
|
22216
|
+
case "--target-namespace":
|
|
22217
|
+
targetNamespace = requireValue(rest, token);
|
|
22218
|
+
break;
|
|
22219
|
+
case "--to":
|
|
22220
|
+
to = parseBareRenameId(requireValue(rest, token), "agent");
|
|
22221
|
+
break;
|
|
22222
|
+
case "--base-url":
|
|
22223
|
+
baseUrl = requireValue(rest, token);
|
|
22224
|
+
break;
|
|
22225
|
+
case "--json":
|
|
22226
|
+
json = true;
|
|
22227
|
+
break;
|
|
22228
|
+
default:
|
|
22229
|
+
throw new Error(`Unknown agent move option: ${token}`);
|
|
22230
|
+
}
|
|
22231
|
+
}
|
|
22232
|
+
if (!namespace || !from || !targetNamespace) {
|
|
22233
|
+
throw new Error(
|
|
22234
|
+
"Usage: agent move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]"
|
|
22235
|
+
);
|
|
22236
|
+
}
|
|
22237
|
+
return {
|
|
22238
|
+
type: "agent" /* Agent */,
|
|
22239
|
+
action,
|
|
22240
|
+
namespace,
|
|
22241
|
+
fromName: from,
|
|
22242
|
+
targetNamespace,
|
|
22243
|
+
toName: to,
|
|
22244
|
+
baseUrl,
|
|
22245
|
+
json
|
|
22246
|
+
};
|
|
22247
|
+
}
|
|
21916
22248
|
throw new Error(`Unknown agent action: ${action}`);
|
|
21917
22249
|
}
|
|
21918
22250
|
function requireValue(tokens, optionName) {
|
|
@@ -21943,6 +22275,180 @@ function parseJsonObject(value, optionName) {
|
|
|
21943
22275
|
return parsed;
|
|
21944
22276
|
}
|
|
21945
22277
|
|
|
22278
|
+
// src/runnerCommandParser.ts
|
|
22279
|
+
init_namespacedRef();
|
|
22280
|
+
var DEFAULT_RUNNER_NAMESPACE = "pmate";
|
|
22281
|
+
function parseRunnerArgs(tokens) {
|
|
22282
|
+
const rest = [...tokens];
|
|
22283
|
+
const rawAction = rest.shift();
|
|
22284
|
+
const action = rawAction === "view" ? "view" : rawAction;
|
|
22285
|
+
if (!action) {
|
|
22286
|
+
throw new Error("Missing runner action. Use: runner list|get|view|create|update|delete");
|
|
22287
|
+
}
|
|
22288
|
+
let baseUrl;
|
|
22289
|
+
let json = false;
|
|
22290
|
+
const takeSharedOptions4 = () => {
|
|
22291
|
+
while (rest.length > 0) {
|
|
22292
|
+
const token = rest[0];
|
|
22293
|
+
if (token === "--base-url") {
|
|
22294
|
+
rest.shift();
|
|
22295
|
+
baseUrl = requireValue2(rest, token);
|
|
22296
|
+
continue;
|
|
22297
|
+
}
|
|
22298
|
+
if (token === "--json") {
|
|
22299
|
+
rest.shift();
|
|
22300
|
+
json = true;
|
|
22301
|
+
continue;
|
|
22302
|
+
}
|
|
22303
|
+
break;
|
|
22304
|
+
}
|
|
22305
|
+
};
|
|
22306
|
+
if (action === "list") {
|
|
22307
|
+
let namespace;
|
|
22308
|
+
while (rest.length > 0) {
|
|
22309
|
+
const token = rest.shift();
|
|
22310
|
+
switch (token) {
|
|
22311
|
+
case "--ns":
|
|
22312
|
+
case "--namespace":
|
|
22313
|
+
namespace = requireValue2(rest, token);
|
|
22314
|
+
break;
|
|
22315
|
+
case "--base-url":
|
|
22316
|
+
baseUrl = requireValue2(rest, token);
|
|
22317
|
+
break;
|
|
22318
|
+
case "--json":
|
|
22319
|
+
json = true;
|
|
22320
|
+
break;
|
|
22321
|
+
default:
|
|
22322
|
+
throw new Error(`Unknown runner list option: ${token}`);
|
|
22323
|
+
}
|
|
22324
|
+
}
|
|
22325
|
+
return { type: "runner" /* Runner */, action, namespace, baseUrl, json };
|
|
22326
|
+
}
|
|
22327
|
+
if (action === "view") {
|
|
22328
|
+
const ref = rest.shift();
|
|
22329
|
+
if (!ref) {
|
|
22330
|
+
throw new Error("Usage: runner view <ns:objectId> [--base-url <url>]");
|
|
22331
|
+
}
|
|
22332
|
+
while (rest.length > 0) {
|
|
22333
|
+
const token = rest.shift();
|
|
22334
|
+
switch (token) {
|
|
22335
|
+
case "--base-url":
|
|
22336
|
+
baseUrl = requireValue2(rest, token);
|
|
22337
|
+
break;
|
|
22338
|
+
default:
|
|
22339
|
+
throw new Error(`Unknown runner view option: ${token}`);
|
|
22340
|
+
}
|
|
22341
|
+
}
|
|
22342
|
+
const parsed = parseNamespacedRef(ref, {
|
|
22343
|
+
entityLabel: "runner ref"
|
|
22344
|
+
});
|
|
22345
|
+
return {
|
|
22346
|
+
type: "runner" /* Runner */,
|
|
22347
|
+
action,
|
|
22348
|
+
namespace: parsed.namespace,
|
|
22349
|
+
name: parsed.objectId,
|
|
22350
|
+
baseUrl,
|
|
22351
|
+
json
|
|
22352
|
+
};
|
|
22353
|
+
}
|
|
22354
|
+
if (action === "get" || action === "delete") {
|
|
22355
|
+
const ref = rest.shift();
|
|
22356
|
+
if (!ref) {
|
|
22357
|
+
throw new Error(
|
|
22358
|
+
`Usage: runner ${action} <ns:objectId> [--base-url <url>] [--json]`
|
|
22359
|
+
);
|
|
22360
|
+
}
|
|
22361
|
+
const parsed = parseNamespacedRef(ref, {
|
|
22362
|
+
entityLabel: "runner ref"
|
|
22363
|
+
});
|
|
22364
|
+
takeSharedOptions4();
|
|
22365
|
+
if (rest.length > 0) {
|
|
22366
|
+
throw new Error(`Unknown runner ${action} option: ${rest[0]}`);
|
|
22367
|
+
}
|
|
22368
|
+
return {
|
|
22369
|
+
type: "runner" /* Runner */,
|
|
22370
|
+
action,
|
|
22371
|
+
namespace: parsed.namespace,
|
|
22372
|
+
name: parsed.objectId,
|
|
22373
|
+
baseUrl,
|
|
22374
|
+
json
|
|
22375
|
+
};
|
|
22376
|
+
}
|
|
22377
|
+
if (action === "create") {
|
|
22378
|
+
let namespace = DEFAULT_RUNNER_NAMESPACE;
|
|
22379
|
+
if (rest[0] && !rest[0].startsWith("-")) {
|
|
22380
|
+
namespace = rest.shift();
|
|
22381
|
+
}
|
|
22382
|
+
let filePath;
|
|
22383
|
+
while (rest.length > 0) {
|
|
22384
|
+
const token = rest.shift();
|
|
22385
|
+
switch (token) {
|
|
22386
|
+
case "--file":
|
|
22387
|
+
filePath = requireValue2(rest, token);
|
|
22388
|
+
break;
|
|
22389
|
+
case "--base-url":
|
|
22390
|
+
baseUrl = requireValue2(rest, token);
|
|
22391
|
+
break;
|
|
22392
|
+
case "--json":
|
|
22393
|
+
json = true;
|
|
22394
|
+
break;
|
|
22395
|
+
default:
|
|
22396
|
+
throw new Error(`Unknown runner create option: ${token}`);
|
|
22397
|
+
}
|
|
22398
|
+
}
|
|
22399
|
+
if (!filePath) {
|
|
22400
|
+
throw new Error("Missing required option --file for runner create");
|
|
22401
|
+
}
|
|
22402
|
+
return { type: "runner" /* Runner */, action, namespace, filePath, baseUrl, json };
|
|
22403
|
+
}
|
|
22404
|
+
if (action === "update") {
|
|
22405
|
+
const ref = rest.shift();
|
|
22406
|
+
if (!ref) {
|
|
22407
|
+
throw new Error(
|
|
22408
|
+
"Usage: runner update <ns:objectId> --file <path> [--base-url <url>] [--json]"
|
|
22409
|
+
);
|
|
22410
|
+
}
|
|
22411
|
+
const parsed = parseNamespacedRef(ref, { entityLabel: "runner ref" });
|
|
22412
|
+
let filePath;
|
|
22413
|
+
while (rest.length > 0) {
|
|
22414
|
+
const token = rest.shift();
|
|
22415
|
+
switch (token) {
|
|
22416
|
+
case "--file":
|
|
22417
|
+
filePath = requireValue2(rest, token);
|
|
22418
|
+
break;
|
|
22419
|
+
case "--base-url":
|
|
22420
|
+
baseUrl = requireValue2(rest, token);
|
|
22421
|
+
break;
|
|
22422
|
+
case "--json":
|
|
22423
|
+
json = true;
|
|
22424
|
+
break;
|
|
22425
|
+
default:
|
|
22426
|
+
throw new Error(`Unknown runner update option: ${token}`);
|
|
22427
|
+
}
|
|
22428
|
+
}
|
|
22429
|
+
if (!filePath) {
|
|
22430
|
+
throw new Error("Missing required option --file for runner update");
|
|
22431
|
+
}
|
|
22432
|
+
return {
|
|
22433
|
+
type: "runner" /* Runner */,
|
|
22434
|
+
action,
|
|
22435
|
+
namespace: parsed.namespace,
|
|
22436
|
+
name: parsed.objectId,
|
|
22437
|
+
filePath,
|
|
22438
|
+
baseUrl,
|
|
22439
|
+
json
|
|
22440
|
+
};
|
|
22441
|
+
}
|
|
22442
|
+
throw new Error(`Unknown runner action: ${action}`);
|
|
22443
|
+
}
|
|
22444
|
+
function requireValue2(tokens, optionName) {
|
|
22445
|
+
const value = tokens.shift();
|
|
22446
|
+
if (!value || value.startsWith("-")) {
|
|
22447
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
22448
|
+
}
|
|
22449
|
+
return value;
|
|
22450
|
+
}
|
|
22451
|
+
|
|
21946
22452
|
// src/nsCommandParser.ts
|
|
21947
22453
|
var DEFAULT_CHAIN = "pmate";
|
|
21948
22454
|
function parseNsArgs(tokens) {
|
|
@@ -21993,10 +22499,10 @@ function takeSharedOptions(rest, handlers) {
|
|
|
21993
22499
|
const token = rest.shift();
|
|
21994
22500
|
switch (token) {
|
|
21995
22501
|
case "--chain":
|
|
21996
|
-
handlers.onChain(
|
|
22502
|
+
handlers.onChain(requireValue3(rest, token));
|
|
21997
22503
|
break;
|
|
21998
22504
|
case "--base-url":
|
|
21999
|
-
handlers.onBaseUrl(
|
|
22505
|
+
handlers.onBaseUrl(requireValue3(rest, token));
|
|
22000
22506
|
break;
|
|
22001
22507
|
case "--json":
|
|
22002
22508
|
handlers.onJson();
|
|
@@ -22006,7 +22512,7 @@ function takeSharedOptions(rest, handlers) {
|
|
|
22006
22512
|
}
|
|
22007
22513
|
}
|
|
22008
22514
|
}
|
|
22009
|
-
function
|
|
22515
|
+
function requireValue3(tokens, optionName) {
|
|
22010
22516
|
const value = tokens.shift();
|
|
22011
22517
|
if (!value || value.startsWith("-")) {
|
|
22012
22518
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22068,7 +22574,7 @@ function parseTableArgs(action, rest, shared) {
|
|
|
22068
22574
|
const token = rest.shift();
|
|
22069
22575
|
switch (token) {
|
|
22070
22576
|
case "--page":
|
|
22071
|
-
page = parsePage(
|
|
22577
|
+
page = parsePage(requireValue4(rest, token));
|
|
22072
22578
|
break;
|
|
22073
22579
|
default:
|
|
22074
22580
|
pushSharedOption(token, rest, shared);
|
|
@@ -22082,7 +22588,7 @@ function parseTableArgs(action, rest, shared) {
|
|
|
22082
22588
|
const token = rest.shift();
|
|
22083
22589
|
switch (token) {
|
|
22084
22590
|
case "--id":
|
|
22085
|
-
id =
|
|
22591
|
+
id = requireValue4(rest, token);
|
|
22086
22592
|
break;
|
|
22087
22593
|
default:
|
|
22088
22594
|
pushSharedOption(token, rest, shared);
|
|
@@ -22099,7 +22605,7 @@ function parseTableArgs(action, rest, shared) {
|
|
|
22099
22605
|
const token = rest.shift();
|
|
22100
22606
|
switch (token) {
|
|
22101
22607
|
case "--file":
|
|
22102
|
-
filePath =
|
|
22608
|
+
filePath = requireValue4(rest, token);
|
|
22103
22609
|
break;
|
|
22104
22610
|
default:
|
|
22105
22611
|
pushSharedOption(token, rest, shared);
|
|
@@ -22123,7 +22629,7 @@ function parseKvArgs(action, rest, shared) {
|
|
|
22123
22629
|
const token = rest.shift();
|
|
22124
22630
|
switch (token) {
|
|
22125
22631
|
case "--page":
|
|
22126
|
-
page = parsePage(
|
|
22632
|
+
page = parsePage(requireValue4(rest, token));
|
|
22127
22633
|
break;
|
|
22128
22634
|
default:
|
|
22129
22635
|
pushSharedOption(token, rest, shared);
|
|
@@ -22137,7 +22643,7 @@ function parseKvArgs(action, rest, shared) {
|
|
|
22137
22643
|
const token = rest.shift();
|
|
22138
22644
|
switch (token) {
|
|
22139
22645
|
case "--key":
|
|
22140
|
-
key =
|
|
22646
|
+
key = requireValue4(rest, token);
|
|
22141
22647
|
break;
|
|
22142
22648
|
default:
|
|
22143
22649
|
pushSharedOption(token, rest, shared);
|
|
@@ -22156,13 +22662,13 @@ function parseKvArgs(action, rest, shared) {
|
|
|
22156
22662
|
const token = rest.shift();
|
|
22157
22663
|
switch (token) {
|
|
22158
22664
|
case "--key":
|
|
22159
|
-
key =
|
|
22665
|
+
key = requireValue4(rest, token);
|
|
22160
22666
|
break;
|
|
22161
22667
|
case "--value":
|
|
22162
|
-
value =
|
|
22668
|
+
value = requireValue4(rest, token);
|
|
22163
22669
|
break;
|
|
22164
22670
|
case "--file":
|
|
22165
|
-
filePath =
|
|
22671
|
+
filePath = requireValue4(rest, token);
|
|
22166
22672
|
break;
|
|
22167
22673
|
default:
|
|
22168
22674
|
pushSharedOption(token, rest, shared);
|
|
@@ -22187,17 +22693,17 @@ function takeSharedOptions2(rest, shared) {
|
|
|
22187
22693
|
function pushSharedOption(token, rest, shared) {
|
|
22188
22694
|
switch (token) {
|
|
22189
22695
|
case "--chain":
|
|
22190
|
-
shared.chain =
|
|
22696
|
+
shared.chain = requireValue4(rest, token);
|
|
22191
22697
|
break;
|
|
22192
22698
|
case "--ns":
|
|
22193
22699
|
case "--namespace":
|
|
22194
|
-
shared.namespace =
|
|
22700
|
+
shared.namespace = requireValue4(rest, token);
|
|
22195
22701
|
break;
|
|
22196
22702
|
case "--base-url":
|
|
22197
|
-
shared.baseUrl =
|
|
22703
|
+
shared.baseUrl = requireValue4(rest, token);
|
|
22198
22704
|
break;
|
|
22199
22705
|
case "--indexer-base-url":
|
|
22200
|
-
shared.indexerBaseUrl =
|
|
22706
|
+
shared.indexerBaseUrl = requireValue4(rest, token);
|
|
22201
22707
|
break;
|
|
22202
22708
|
case "--json":
|
|
22203
22709
|
shared.json = true;
|
|
@@ -22206,7 +22712,7 @@ function pushSharedOption(token, rest, shared) {
|
|
|
22206
22712
|
throw new Error(`Unknown store option: ${token}`);
|
|
22207
22713
|
}
|
|
22208
22714
|
}
|
|
22209
|
-
function
|
|
22715
|
+
function requireValue4(tokens, optionName) {
|
|
22210
22716
|
const value = tokens.shift();
|
|
22211
22717
|
if (!value || value.startsWith("-")) {
|
|
22212
22718
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22228,7 +22734,7 @@ function parseAppArgs(tokens) {
|
|
|
22228
22734
|
const rawAction = rest.shift();
|
|
22229
22735
|
const action = rawAction === "view" ? "view" : rawAction;
|
|
22230
22736
|
if (!action) {
|
|
22231
|
-
throw new Error("Missing app action. Use: app list|get|view|create|update|rename|delete");
|
|
22737
|
+
throw new Error("Missing app action. Use: app list|get|view|create|update|rename|move|delete");
|
|
22232
22738
|
}
|
|
22233
22739
|
let baseUrl;
|
|
22234
22740
|
let json = false;
|
|
@@ -22237,7 +22743,7 @@ function parseAppArgs(tokens) {
|
|
|
22237
22743
|
const token = rest[0];
|
|
22238
22744
|
if (token === "--base-url") {
|
|
22239
22745
|
rest.shift();
|
|
22240
|
-
baseUrl =
|
|
22746
|
+
baseUrl = requireValue5(rest, token);
|
|
22241
22747
|
continue;
|
|
22242
22748
|
}
|
|
22243
22749
|
if (token === "--json") {
|
|
@@ -22255,10 +22761,10 @@ function parseAppArgs(tokens) {
|
|
|
22255
22761
|
switch (token) {
|
|
22256
22762
|
case "--ns":
|
|
22257
22763
|
case "--namespace":
|
|
22258
|
-
namespace =
|
|
22764
|
+
namespace = requireValue5(rest, token);
|
|
22259
22765
|
break;
|
|
22260
22766
|
case "--base-url":
|
|
22261
|
-
baseUrl =
|
|
22767
|
+
baseUrl = requireValue5(rest, token);
|
|
22262
22768
|
break;
|
|
22263
22769
|
case "--json":
|
|
22264
22770
|
json = true;
|
|
@@ -22283,7 +22789,7 @@ function parseAppArgs(tokens) {
|
|
|
22283
22789
|
const token = rest.shift();
|
|
22284
22790
|
switch (token) {
|
|
22285
22791
|
case "--base-url":
|
|
22286
|
-
baseUrl =
|
|
22792
|
+
baseUrl = requireValue5(rest, token);
|
|
22287
22793
|
break;
|
|
22288
22794
|
default:
|
|
22289
22795
|
throw new Error(`Unknown app view option: ${token}`);
|
|
@@ -22313,10 +22819,10 @@ function parseAppArgs(tokens) {
|
|
|
22313
22819
|
const token = rest.shift();
|
|
22314
22820
|
switch (token) {
|
|
22315
22821
|
case "--file":
|
|
22316
|
-
filePath =
|
|
22822
|
+
filePath = requireValue5(rest, token);
|
|
22317
22823
|
break;
|
|
22318
22824
|
case "--base-url":
|
|
22319
|
-
baseUrl =
|
|
22825
|
+
baseUrl = requireValue5(rest, token);
|
|
22320
22826
|
break;
|
|
22321
22827
|
case "--json":
|
|
22322
22828
|
json = true;
|
|
@@ -22343,10 +22849,10 @@ function parseAppArgs(tokens) {
|
|
|
22343
22849
|
const token = rest.shift();
|
|
22344
22850
|
switch (token) {
|
|
22345
22851
|
case "--file":
|
|
22346
|
-
filePath =
|
|
22852
|
+
filePath = requireValue5(rest, token);
|
|
22347
22853
|
break;
|
|
22348
22854
|
case "--base-url":
|
|
22349
|
-
baseUrl =
|
|
22855
|
+
baseUrl = requireValue5(rest, token);
|
|
22350
22856
|
break;
|
|
22351
22857
|
case "--json":
|
|
22352
22858
|
json = true;
|
|
@@ -22369,16 +22875,16 @@ function parseAppArgs(tokens) {
|
|
|
22369
22875
|
switch (token) {
|
|
22370
22876
|
case "--ns":
|
|
22371
22877
|
case "--namespace":
|
|
22372
|
-
namespace =
|
|
22878
|
+
namespace = requireValue5(rest, token);
|
|
22373
22879
|
break;
|
|
22374
22880
|
case "--from":
|
|
22375
|
-
fromId = parseBareRenameId2(
|
|
22881
|
+
fromId = parseBareRenameId2(requireValue5(rest, token), "app");
|
|
22376
22882
|
break;
|
|
22377
22883
|
case "--to":
|
|
22378
|
-
toId = parseBareRenameId2(
|
|
22884
|
+
toId = parseBareRenameId2(requireValue5(rest, token), "app");
|
|
22379
22885
|
break;
|
|
22380
22886
|
case "--base-url":
|
|
22381
|
-
baseUrl =
|
|
22887
|
+
baseUrl = requireValue5(rest, token);
|
|
22382
22888
|
break;
|
|
22383
22889
|
case "--json":
|
|
22384
22890
|
json = true;
|
|
@@ -22394,9 +22900,48 @@ function parseAppArgs(tokens) {
|
|
|
22394
22900
|
}
|
|
22395
22901
|
return { type: "app" /* App */, action, namespace, fromId, toId, baseUrl, json };
|
|
22396
22902
|
}
|
|
22903
|
+
if (action === "move") {
|
|
22904
|
+
let namespace;
|
|
22905
|
+
let fromId;
|
|
22906
|
+
let targetNamespace;
|
|
22907
|
+
let toId;
|
|
22908
|
+
while (rest.length > 0) {
|
|
22909
|
+
const token = rest.shift();
|
|
22910
|
+
switch (token) {
|
|
22911
|
+
case "--ns":
|
|
22912
|
+
case "--namespace":
|
|
22913
|
+
namespace = requireValue5(rest, token);
|
|
22914
|
+
break;
|
|
22915
|
+
case "--from":
|
|
22916
|
+
fromId = parseBareRenameId2(requireValue5(rest, token), "app");
|
|
22917
|
+
break;
|
|
22918
|
+
case "--to-ns":
|
|
22919
|
+
case "--target-namespace":
|
|
22920
|
+
targetNamespace = requireValue5(rest, token);
|
|
22921
|
+
break;
|
|
22922
|
+
case "--to":
|
|
22923
|
+
toId = parseBareRenameId2(requireValue5(rest, token), "app");
|
|
22924
|
+
break;
|
|
22925
|
+
case "--base-url":
|
|
22926
|
+
baseUrl = requireValue5(rest, token);
|
|
22927
|
+
break;
|
|
22928
|
+
case "--json":
|
|
22929
|
+
json = true;
|
|
22930
|
+
break;
|
|
22931
|
+
default:
|
|
22932
|
+
throw new Error(`Unknown app move option: ${token}`);
|
|
22933
|
+
}
|
|
22934
|
+
}
|
|
22935
|
+
if (!namespace || !fromId || !targetNamespace) {
|
|
22936
|
+
throw new Error(
|
|
22937
|
+
"Usage: app move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]"
|
|
22938
|
+
);
|
|
22939
|
+
}
|
|
22940
|
+
return { type: "app" /* App */, action, namespace, fromId, targetNamespace, toId, baseUrl, json };
|
|
22941
|
+
}
|
|
22397
22942
|
throw new Error(`Unknown app action: ${action}`);
|
|
22398
22943
|
}
|
|
22399
|
-
function
|
|
22944
|
+
function requireValue5(tokens, optionName) {
|
|
22400
22945
|
const value = tokens.shift();
|
|
22401
22946
|
if (!value || value.startsWith("-")) {
|
|
22402
22947
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22430,16 +22975,16 @@ function parseServiceArgs(tokens) {
|
|
|
22430
22975
|
const token = rest.shift();
|
|
22431
22976
|
switch (token) {
|
|
22432
22977
|
case "--namespace":
|
|
22433
|
-
namespace =
|
|
22978
|
+
namespace = requireValue6(rest, token);
|
|
22434
22979
|
break;
|
|
22435
22980
|
case "--repo":
|
|
22436
|
-
repository =
|
|
22981
|
+
repository = requireValue6(rest, token);
|
|
22437
22982
|
break;
|
|
22438
22983
|
case "--server":
|
|
22439
|
-
server =
|
|
22984
|
+
server = requireValue6(rest, token);
|
|
22440
22985
|
break;
|
|
22441
22986
|
case "--base-url":
|
|
22442
|
-
baseUrl =
|
|
22987
|
+
baseUrl = requireValue6(rest, token);
|
|
22443
22988
|
break;
|
|
22444
22989
|
case "--json":
|
|
22445
22990
|
json = true;
|
|
@@ -22459,7 +23004,7 @@ function parseServiceArgs(tokens) {
|
|
|
22459
23004
|
const token = rest.shift();
|
|
22460
23005
|
switch (token) {
|
|
22461
23006
|
case "--base-url":
|
|
22462
|
-
baseUrl =
|
|
23007
|
+
baseUrl = requireValue6(rest, token);
|
|
22463
23008
|
break;
|
|
22464
23009
|
default:
|
|
22465
23010
|
throw new Error(`Unknown service view option: ${token}`);
|
|
@@ -22489,19 +23034,19 @@ function parseServiceArgs(tokens) {
|
|
|
22489
23034
|
const token = rest.shift();
|
|
22490
23035
|
switch (token) {
|
|
22491
23036
|
case "--base-url":
|
|
22492
|
-
baseUrl =
|
|
23037
|
+
baseUrl = requireValue6(rest, token);
|
|
22493
23038
|
break;
|
|
22494
23039
|
case "--cwd":
|
|
22495
|
-
cwd =
|
|
23040
|
+
cwd = requireValue6(rest, token);
|
|
22496
23041
|
break;
|
|
22497
23042
|
case "--page":
|
|
22498
|
-
page = Number.parseInt(
|
|
23043
|
+
page = Number.parseInt(requireValue6(rest, token), 10);
|
|
22499
23044
|
break;
|
|
22500
23045
|
case "--history":
|
|
22501
23046
|
history = true;
|
|
22502
23047
|
break;
|
|
22503
23048
|
case "--search":
|
|
22504
|
-
search =
|
|
23049
|
+
search = requireValue6(rest, token);
|
|
22505
23050
|
break;
|
|
22506
23051
|
case "--follow":
|
|
22507
23052
|
case "-f":
|
|
@@ -22531,10 +23076,10 @@ function parseServiceArgs(tokens) {
|
|
|
22531
23076
|
const token = rest.shift();
|
|
22532
23077
|
switch (token) {
|
|
22533
23078
|
case "--file":
|
|
22534
|
-
filePath =
|
|
23079
|
+
filePath = requireValue6(rest, token);
|
|
22535
23080
|
break;
|
|
22536
23081
|
case "--base-url":
|
|
22537
|
-
baseUrl =
|
|
23082
|
+
baseUrl = requireValue6(rest, token);
|
|
22538
23083
|
break;
|
|
22539
23084
|
case "--json":
|
|
22540
23085
|
json = true;
|
|
@@ -22563,10 +23108,10 @@ function parseServiceArgs(tokens) {
|
|
|
22563
23108
|
const token = rest.shift();
|
|
22564
23109
|
switch (token) {
|
|
22565
23110
|
case "--file":
|
|
22566
|
-
filePath =
|
|
23111
|
+
filePath = requireValue6(rest, token);
|
|
22567
23112
|
break;
|
|
22568
23113
|
case "--base-url":
|
|
22569
|
-
baseUrl =
|
|
23114
|
+
baseUrl = requireValue6(rest, token);
|
|
22570
23115
|
break;
|
|
22571
23116
|
case "--json":
|
|
22572
23117
|
json = true;
|
|
@@ -22589,16 +23134,16 @@ function parseServiceArgs(tokens) {
|
|
|
22589
23134
|
switch (token) {
|
|
22590
23135
|
case "--ns":
|
|
22591
23136
|
case "--namespace":
|
|
22592
|
-
namespace =
|
|
23137
|
+
namespace = requireValue6(rest, token);
|
|
22593
23138
|
break;
|
|
22594
23139
|
case "--from":
|
|
22595
|
-
from = parseBareRenameId3(
|
|
23140
|
+
from = parseBareRenameId3(requireValue6(rest, token), "service");
|
|
22596
23141
|
break;
|
|
22597
23142
|
case "--to":
|
|
22598
|
-
to = parseBareRenameId3(
|
|
23143
|
+
to = parseBareRenameId3(requireValue6(rest, token), "service");
|
|
22599
23144
|
break;
|
|
22600
23145
|
case "--base-url":
|
|
22601
|
-
baseUrl =
|
|
23146
|
+
baseUrl = requireValue6(rest, token);
|
|
22602
23147
|
break;
|
|
22603
23148
|
case "--json":
|
|
22604
23149
|
json = true;
|
|
@@ -22622,9 +23167,57 @@ function parseServiceArgs(tokens) {
|
|
|
22622
23167
|
json
|
|
22623
23168
|
};
|
|
22624
23169
|
}
|
|
23170
|
+
if (action === "move") {
|
|
23171
|
+
let namespace;
|
|
23172
|
+
let from;
|
|
23173
|
+
let targetNamespace;
|
|
23174
|
+
let to;
|
|
23175
|
+
while (rest.length > 0) {
|
|
23176
|
+
const token = rest.shift();
|
|
23177
|
+
switch (token) {
|
|
23178
|
+
case "--ns":
|
|
23179
|
+
case "--namespace":
|
|
23180
|
+
namespace = requireValue6(rest, token);
|
|
23181
|
+
break;
|
|
23182
|
+
case "--from":
|
|
23183
|
+
from = parseBareRenameId3(requireValue6(rest, token), "service");
|
|
23184
|
+
break;
|
|
23185
|
+
case "--to-ns":
|
|
23186
|
+
case "--target-namespace":
|
|
23187
|
+
targetNamespace = requireValue6(rest, token);
|
|
23188
|
+
break;
|
|
23189
|
+
case "--to":
|
|
23190
|
+
to = parseBareRenameId3(requireValue6(rest, token), "service");
|
|
23191
|
+
break;
|
|
23192
|
+
case "--base-url":
|
|
23193
|
+
baseUrl = requireValue6(rest, token);
|
|
23194
|
+
break;
|
|
23195
|
+
case "--json":
|
|
23196
|
+
json = true;
|
|
23197
|
+
break;
|
|
23198
|
+
default:
|
|
23199
|
+
throw new Error(`Unknown service move option: ${token}`);
|
|
23200
|
+
}
|
|
23201
|
+
}
|
|
23202
|
+
if (!namespace || !from || !targetNamespace) {
|
|
23203
|
+
throw new Error(
|
|
23204
|
+
"Usage: service move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]"
|
|
23205
|
+
);
|
|
23206
|
+
}
|
|
23207
|
+
return {
|
|
23208
|
+
type: "service" /* Service */,
|
|
23209
|
+
action,
|
|
23210
|
+
namespace,
|
|
23211
|
+
fromName: from,
|
|
23212
|
+
targetNamespace,
|
|
23213
|
+
toName: to,
|
|
23214
|
+
baseUrl,
|
|
23215
|
+
json
|
|
23216
|
+
};
|
|
23217
|
+
}
|
|
22625
23218
|
throw new Error(`Unknown service action: ${action}`);
|
|
22626
23219
|
}
|
|
22627
|
-
function
|
|
23220
|
+
function requireValue6(tokens, optionName) {
|
|
22628
23221
|
const value = tokens.shift();
|
|
22629
23222
|
if (!value || value.startsWith("-")) {
|
|
22630
23223
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22682,13 +23275,13 @@ function parseRoleArgs(tokens) {
|
|
|
22682
23275
|
const token = rest.shift();
|
|
22683
23276
|
switch (token) {
|
|
22684
23277
|
case "--display-name":
|
|
22685
|
-
displayName =
|
|
23278
|
+
displayName = requireValue7(rest, token);
|
|
22686
23279
|
break;
|
|
22687
23280
|
case "--description":
|
|
22688
|
-
description =
|
|
23281
|
+
description = requireValue7(rest, token);
|
|
22689
23282
|
break;
|
|
22690
23283
|
case "--base-url":
|
|
22691
|
-
baseUrl =
|
|
23284
|
+
baseUrl = requireValue7(rest, token);
|
|
22692
23285
|
break;
|
|
22693
23286
|
case "--json":
|
|
22694
23287
|
json = true;
|
|
@@ -22715,7 +23308,7 @@ function takeSharedOptions3(rest, handlers) {
|
|
|
22715
23308
|
const token = rest.shift();
|
|
22716
23309
|
switch (token) {
|
|
22717
23310
|
case "--base-url":
|
|
22718
|
-
handlers.onBaseUrl(
|
|
23311
|
+
handlers.onBaseUrl(requireValue7(rest, token));
|
|
22719
23312
|
break;
|
|
22720
23313
|
case "--json":
|
|
22721
23314
|
handlers.onJson();
|
|
@@ -22725,7 +23318,7 @@ function takeSharedOptions3(rest, handlers) {
|
|
|
22725
23318
|
}
|
|
22726
23319
|
}
|
|
22727
23320
|
}
|
|
22728
|
-
function
|
|
23321
|
+
function requireValue7(tokens, optionName) {
|
|
22729
23322
|
const value = tokens.shift();
|
|
22730
23323
|
if (!value || value.startsWith("-")) {
|
|
22731
23324
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22752,17 +23345,17 @@ function parseAccountArgs(tokens) {
|
|
|
22752
23345
|
case void 0:
|
|
22753
23346
|
break;
|
|
22754
23347
|
case "--account":
|
|
22755
|
-
account2 =
|
|
23348
|
+
account2 = requireValue8(rest, token);
|
|
22756
23349
|
break;
|
|
22757
23350
|
case "--mobile":
|
|
22758
|
-
mobile =
|
|
23351
|
+
mobile = requireValue8(rest, token);
|
|
22759
23352
|
break;
|
|
22760
23353
|
case "--nickname":
|
|
22761
23354
|
case "--nickName":
|
|
22762
|
-
nickName =
|
|
23355
|
+
nickName = requireValue8(rest, token);
|
|
22763
23356
|
break;
|
|
22764
23357
|
case "--base-url":
|
|
22765
|
-
baseUrl2 =
|
|
23358
|
+
baseUrl2 = requireValue8(rest, token);
|
|
22766
23359
|
break;
|
|
22767
23360
|
case "--json":
|
|
22768
23361
|
json2 = true;
|
|
@@ -22807,16 +23400,16 @@ function parseAccountArgs(tokens) {
|
|
|
22807
23400
|
const token = rest.shift();
|
|
22808
23401
|
switch (token) {
|
|
22809
23402
|
case "--account":
|
|
22810
|
-
account =
|
|
23403
|
+
account = requireValue8(rest, token);
|
|
22811
23404
|
break;
|
|
22812
23405
|
case "--namespace":
|
|
22813
|
-
namespace =
|
|
23406
|
+
namespace = requireValue8(rest, token);
|
|
22814
23407
|
break;
|
|
22815
23408
|
case "--role":
|
|
22816
|
-
role =
|
|
23409
|
+
role = requireValue8(rest, token);
|
|
22817
23410
|
break;
|
|
22818
23411
|
case "--base-url":
|
|
22819
|
-
baseUrl =
|
|
23412
|
+
baseUrl = requireValue8(rest, token);
|
|
22820
23413
|
break;
|
|
22821
23414
|
case "--json":
|
|
22822
23415
|
json = true;
|
|
@@ -22858,7 +23451,7 @@ function parseAccountArgs(tokens) {
|
|
|
22858
23451
|
}
|
|
22859
23452
|
throw new Error(`Unknown account role action: ${roleAction}`);
|
|
22860
23453
|
}
|
|
22861
|
-
function
|
|
23454
|
+
function requireValue8(tokens, optionName) {
|
|
22862
23455
|
const value = tokens.shift();
|
|
22863
23456
|
if (!value || value.startsWith("-")) {
|
|
22864
23457
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -22866,9 +23459,59 @@ function requireValue7(tokens, optionName) {
|
|
|
22866
23459
|
return value;
|
|
22867
23460
|
}
|
|
22868
23461
|
|
|
23462
|
+
// src/collectCommandParser.ts
|
|
23463
|
+
function parseCollectArgs(tokens) {
|
|
23464
|
+
const rest = [...tokens];
|
|
23465
|
+
const options = {
|
|
23466
|
+
action: "sync",
|
|
23467
|
+
source: void 0,
|
|
23468
|
+
endpoint: void 0
|
|
23469
|
+
};
|
|
23470
|
+
const action = rest.shift();
|
|
23471
|
+
if (action !== "sync") {
|
|
23472
|
+
throw new Error(
|
|
23473
|
+
"Usage: collect sync (--source <cc|yelling> | --endpoint <url>)"
|
|
23474
|
+
);
|
|
23475
|
+
}
|
|
23476
|
+
while (rest.length > 0) {
|
|
23477
|
+
const token = rest.shift();
|
|
23478
|
+
switch (token) {
|
|
23479
|
+
case "--source": {
|
|
23480
|
+
const value = requireValue9(rest, token);
|
|
23481
|
+
if (value !== "cc" && value !== "yelling") {
|
|
23482
|
+
throw new Error(`Unsupported collect source: ${value}`);
|
|
23483
|
+
}
|
|
23484
|
+
options.source = value;
|
|
23485
|
+
break;
|
|
23486
|
+
}
|
|
23487
|
+
case "--endpoint":
|
|
23488
|
+
options.endpoint = requireValue9(rest, token);
|
|
23489
|
+
break;
|
|
23490
|
+
default:
|
|
23491
|
+
throw new Error(`Unknown collect option: ${token}`);
|
|
23492
|
+
}
|
|
23493
|
+
}
|
|
23494
|
+
if (options.source && options.endpoint) {
|
|
23495
|
+
throw new Error("Use either --source or --endpoint, not both.");
|
|
23496
|
+
}
|
|
23497
|
+
if (!options.source && !options.endpoint) {
|
|
23498
|
+
throw new Error(
|
|
23499
|
+
"Usage: collect sync (--source <cc|yelling> | --endpoint <url>)"
|
|
23500
|
+
);
|
|
23501
|
+
}
|
|
23502
|
+
return { type: "collect" /* Collect */, ...options };
|
|
23503
|
+
}
|
|
23504
|
+
function requireValue9(tokens, optionName) {
|
|
23505
|
+
const value = tokens.shift();
|
|
23506
|
+
if (!value) {
|
|
23507
|
+
throw new Error(`Missing value for ${optionName}`);
|
|
23508
|
+
}
|
|
23509
|
+
return value;
|
|
23510
|
+
}
|
|
23511
|
+
|
|
22869
23512
|
// src/index.ts
|
|
22870
23513
|
var pkg = JSON.parse(
|
|
22871
|
-
(0,
|
|
23514
|
+
(0, import_node_fs18.readFileSync)(import_node_path23.default.resolve(__dirname, "..", "package.json"), "utf8")
|
|
22872
23515
|
);
|
|
22873
23516
|
var HELP_TEXT = [
|
|
22874
23517
|
import_chalk4.default.bold(`pmate v${pkg.version}`),
|
|
@@ -22947,8 +23590,7 @@ var HELP_TEXT = [
|
|
|
22947
23590
|
` ${import_chalk4.default.gray(" [--count <n>]")}`,
|
|
22948
23591
|
` ${import_chalk4.default.gray(" --easy [--words <n>] [--digits <n>] [--separator <s>] [--count <n>]")}`,
|
|
22949
23592
|
` ${import_chalk4.default.cyan("collect")} Collect threads/messages from Electron chat app via CDP`,
|
|
22950
|
-
` ${import_chalk4.default.gray(" --
|
|
22951
|
-
` ${import_chalk4.default.gray(" --thread <name> [--endpoint <url>] [--json]")}`,
|
|
23593
|
+
` ${import_chalk4.default.gray(" sync (--source <cc|yelling> | --endpoint <url>)")}`,
|
|
22952
23594
|
` ${import_chalk4.default.cyan("agent")} Manage agent registry entries and call agents for debugging`,
|
|
22953
23595
|
` ${import_chalk4.default.gray(" namespaces [--base-url <url>] [--json]")}`,
|
|
22954
23596
|
` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
@@ -22957,9 +23599,18 @@ var HELP_TEXT = [
|
|
|
22957
23599
|
` ${import_chalk4.default.gray(" create [<namespace>] --file <path> [--base-url <url>] [--json]")}`,
|
|
22958
23600
|
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22959
23601
|
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
23602
|
+
` ${import_chalk4.default.gray(" move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]")}`,
|
|
22960
23603
|
` ${import_chalk4.default.gray(" call <ns:objectId> [--payload <json>] [--file <path>] [--base-url <url>] [--hub-base-url <url>] [--from <id>] [--json]")}`,
|
|
22961
23604
|
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22962
23605
|
` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat; call uses pmate:cli session and default hub: https://hub.pmate.chat")}`,
|
|
23606
|
+
` ${import_chalk4.default.cyan("runner")} Manage runner registry entries via agent-api`,
|
|
23607
|
+
` ${import_chalk4.default.gray(" list [--namespace <ns>] [--base-url <url>] [--json]")}`,
|
|
23608
|
+
` ${import_chalk4.default.gray(" get <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
23609
|
+
` ${import_chalk4.default.gray(" view <ns:objectId> [--base-url <url>]")}`,
|
|
23610
|
+
` ${import_chalk4.default.gray(" create [<namespace>] --file <path> [--base-url <url>] [--json]")}`,
|
|
23611
|
+
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
23612
|
+
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
23613
|
+
` ${import_chalk4.default.gray(" list defaults to all namespaces; create defaults to namespace: pmate; default base URL: https://agent-api.pmate.chat")}`,
|
|
22963
23614
|
` ${import_chalk4.default.cyan("ns")} Manage registered namespaces`,
|
|
22964
23615
|
` ${import_chalk4.default.gray(" list [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
22965
23616
|
` ${import_chalk4.default.gray(" get <namespace> [--chain <chain>] [--base-url <url>] [--json]")}`,
|
|
@@ -22986,6 +23637,7 @@ var HELP_TEXT = [
|
|
|
22986
23637
|
` ${import_chalk4.default.gray(" create --file <path> [--base-url <url>] [--json]")}`,
|
|
22987
23638
|
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22988
23639
|
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
23640
|
+
` ${import_chalk4.default.gray(" move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]")}`,
|
|
22989
23641
|
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22990
23642
|
` ${import_chalk4.default.gray(" default base URL: https://apps-api.pmate.chat")}`,
|
|
22991
23643
|
` ${import_chalk4.default.cyan("service")} Manage service registry entries via apps-api`,
|
|
@@ -22995,6 +23647,7 @@ var HELP_TEXT = [
|
|
|
22995
23647
|
` ${import_chalk4.default.gray(" create --file <path> [--base-url <url>] [--json]")}`,
|
|
22996
23648
|
` ${import_chalk4.default.gray(" update <ns:objectId> --file <path> [--base-url <url>] [--json]")}`,
|
|
22997
23649
|
` ${import_chalk4.default.gray(" rename --from <id> --to <id> --ns <namespace> [--base-url <url>] [--json]")}`,
|
|
23650
|
+
` ${import_chalk4.default.gray(" move --from <id> --ns <namespace> --to-ns <namespace> [--to <id>] [--base-url <url>] [--json]")}`,
|
|
22998
23651
|
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
22999
23652
|
` ${import_chalk4.default.gray(" deploy <ns:objectId> [--cwd <dir>] [--base-url <url>]")}`,
|
|
23000
23653
|
` ${import_chalk4.default.gray(" init <ns:objectId> [--cwd <dir>] [--base-url <url>]")}`,
|
|
@@ -23060,7 +23713,7 @@ function parseCommandArgs(args) {
|
|
|
23060
23713
|
const token = rest.shift();
|
|
23061
23714
|
switch (token) {
|
|
23062
23715
|
case "--app":
|
|
23063
|
-
app =
|
|
23716
|
+
app = requireValue10(rest, token);
|
|
23064
23717
|
break;
|
|
23065
23718
|
default:
|
|
23066
23719
|
throw new Error(`Unknown login option: ${token}`);
|
|
@@ -23122,6 +23775,9 @@ function parseCommandArgs(args) {
|
|
|
23122
23775
|
if (args.rest[0] === "agent") {
|
|
23123
23776
|
return parseAgentArgs(args.rest.slice(1));
|
|
23124
23777
|
}
|
|
23778
|
+
if (args.rest[0] === "runner") {
|
|
23779
|
+
return parseRunnerArgs(args.rest.slice(1));
|
|
23780
|
+
}
|
|
23125
23781
|
if (args.rest[0] === "ns" || args.rest[0] === "namespace") {
|
|
23126
23782
|
return parseNsArgs(args.rest.slice(1));
|
|
23127
23783
|
}
|
|
@@ -23157,7 +23813,7 @@ function parseVercelArgs(tokens) {
|
|
|
23157
23813
|
const token = rest.shift();
|
|
23158
23814
|
switch (token) {
|
|
23159
23815
|
case "--scope":
|
|
23160
|
-
scope =
|
|
23816
|
+
scope = requireValue10(rest, token);
|
|
23161
23817
|
break;
|
|
23162
23818
|
default:
|
|
23163
23819
|
throw new Error(`Unknown vercel option: ${token}`);
|
|
@@ -23177,10 +23833,10 @@ function parseVercelArgs(tokens) {
|
|
|
23177
23833
|
const token = rest.shift();
|
|
23178
23834
|
switch (token) {
|
|
23179
23835
|
case "--scope":
|
|
23180
|
-
scope =
|
|
23836
|
+
scope = requireValue10(rest, token);
|
|
23181
23837
|
break;
|
|
23182
23838
|
case "--project":
|
|
23183
|
-
project =
|
|
23839
|
+
project = requireValue10(rest, token);
|
|
23184
23840
|
break;
|
|
23185
23841
|
case "--last-week":
|
|
23186
23842
|
lastWeek = true;
|
|
@@ -23211,16 +23867,16 @@ function parseAddDnsArgs(tokens) {
|
|
|
23211
23867
|
const token = rest.shift();
|
|
23212
23868
|
switch (token) {
|
|
23213
23869
|
case "--type":
|
|
23214
|
-
options.dnsType =
|
|
23870
|
+
options.dnsType = requireValue10(rest, token);
|
|
23215
23871
|
break;
|
|
23216
23872
|
case "--value":
|
|
23217
|
-
options.dnsValue =
|
|
23873
|
+
options.dnsValue = requireValue10(rest, token);
|
|
23218
23874
|
break;
|
|
23219
23875
|
case "--rr":
|
|
23220
|
-
options.dnsRr =
|
|
23876
|
+
options.dnsRr = requireValue10(rest, token);
|
|
23221
23877
|
break;
|
|
23222
23878
|
case "--ttl": {
|
|
23223
|
-
const ttlValue =
|
|
23879
|
+
const ttlValue = requireValue10(rest, token);
|
|
23224
23880
|
const ttl = Number.parseInt(ttlValue, 10);
|
|
23225
23881
|
if (!Number.isFinite(ttl) || ttl <= 0) {
|
|
23226
23882
|
throw new Error(`Invalid --ttl value: ${ttlValue}`);
|
|
@@ -23229,7 +23885,7 @@ function parseAddDnsArgs(tokens) {
|
|
|
23229
23885
|
break;
|
|
23230
23886
|
}
|
|
23231
23887
|
case "--domain":
|
|
23232
|
-
options.dnsDomain =
|
|
23888
|
+
options.dnsDomain = requireValue10(rest, token);
|
|
23233
23889
|
break;
|
|
23234
23890
|
default:
|
|
23235
23891
|
throw new Error(`Unknown add-dns option: ${token}`);
|
|
@@ -23262,13 +23918,13 @@ function parseBucketArgs(tokens) {
|
|
|
23262
23918
|
options.bucketCreate = true;
|
|
23263
23919
|
break;
|
|
23264
23920
|
case "--name":
|
|
23265
|
-
options.bucketName =
|
|
23921
|
+
options.bucketName = requireValue10(rest, token);
|
|
23266
23922
|
break;
|
|
23267
23923
|
case "--subdomain":
|
|
23268
|
-
options.bucketSubdomain =
|
|
23924
|
+
options.bucketSubdomain = requireValue10(rest, token);
|
|
23269
23925
|
break;
|
|
23270
23926
|
case "--domain":
|
|
23271
|
-
options.bucketDomain =
|
|
23927
|
+
options.bucketDomain = requireValue10(rest, token);
|
|
23272
23928
|
break;
|
|
23273
23929
|
default:
|
|
23274
23930
|
throw new Error(`Unknown bucket option: ${token}`);
|
|
@@ -23300,7 +23956,7 @@ function parseDevArgs(tokens) {
|
|
|
23300
23956
|
const token = rest.shift();
|
|
23301
23957
|
switch (token) {
|
|
23302
23958
|
case "--cwd":
|
|
23303
|
-
options.devCwd =
|
|
23959
|
+
options.devCwd = requireValue10(rest, token);
|
|
23304
23960
|
break;
|
|
23305
23961
|
default:
|
|
23306
23962
|
throw new Error(`Unknown dev option: ${token}`);
|
|
@@ -23320,7 +23976,7 @@ function parseDeleteArgs(tokens) {
|
|
|
23320
23976
|
const token = rest.shift();
|
|
23321
23977
|
switch (token) {
|
|
23322
23978
|
case "--cwd":
|
|
23323
|
-
deleteCwd =
|
|
23979
|
+
deleteCwd = requireValue10(rest, token);
|
|
23324
23980
|
break;
|
|
23325
23981
|
default:
|
|
23326
23982
|
throw new Error(`Unknown delete option: ${token}`);
|
|
@@ -23354,13 +24010,13 @@ function parseOssArgs(tokens) {
|
|
|
23354
24010
|
const token = rest.shift();
|
|
23355
24011
|
switch (token) {
|
|
23356
24012
|
case "--bucket":
|
|
23357
|
-
bucket =
|
|
24013
|
+
bucket = requireValue10(rest, token);
|
|
23358
24014
|
break;
|
|
23359
24015
|
case "--file":
|
|
23360
|
-
filePath =
|
|
24016
|
+
filePath = requireValue10(rest, token);
|
|
23361
24017
|
break;
|
|
23362
24018
|
case "--key":
|
|
23363
|
-
objectKey =
|
|
24019
|
+
objectKey = requireValue10(rest, token);
|
|
23364
24020
|
break;
|
|
23365
24021
|
default:
|
|
23366
24022
|
throw new Error(`Unknown oss option: ${token}`);
|
|
@@ -23393,7 +24049,7 @@ function parseEnvArgs(tokens) {
|
|
|
23393
24049
|
throw new Error("Only one env action is allowed.");
|
|
23394
24050
|
}
|
|
23395
24051
|
action = "set";
|
|
23396
|
-
key =
|
|
24052
|
+
key = requireValue10(rest, token);
|
|
23397
24053
|
break;
|
|
23398
24054
|
case "--list":
|
|
23399
24055
|
if (action) {
|
|
@@ -23406,17 +24062,17 @@ function parseEnvArgs(tokens) {
|
|
|
23406
24062
|
throw new Error("Only one env action is allowed.");
|
|
23407
24063
|
}
|
|
23408
24064
|
action = "delete";
|
|
23409
|
-
key =
|
|
24065
|
+
key = requireValue10(rest, token);
|
|
23410
24066
|
break;
|
|
23411
24067
|
case "--value":
|
|
23412
|
-
value =
|
|
24068
|
+
value = requireValue10(rest, token);
|
|
23413
24069
|
break;
|
|
23414
24070
|
case "--verbose":
|
|
23415
24071
|
case "-v":
|
|
23416
24072
|
verbose = true;
|
|
23417
24073
|
break;
|
|
23418
24074
|
case "--cwd":
|
|
23419
|
-
cwd =
|
|
24075
|
+
cwd = requireValue10(rest, token);
|
|
23420
24076
|
break;
|
|
23421
24077
|
default:
|
|
23422
24078
|
throw new Error(`Unknown env option: ${token}`);
|
|
@@ -23474,7 +24130,7 @@ function parseCommitArgs(tokens) {
|
|
|
23474
24130
|
push = true;
|
|
23475
24131
|
break;
|
|
23476
24132
|
case "--cwd":
|
|
23477
|
-
cwd =
|
|
24133
|
+
cwd = requireValue10(rest, token);
|
|
23478
24134
|
break;
|
|
23479
24135
|
default:
|
|
23480
24136
|
throw new Error(`Unknown commit option: ${token}`);
|
|
@@ -23490,10 +24146,10 @@ function parseSummaryArgs(tokens) {
|
|
|
23490
24146
|
const token = rest.shift();
|
|
23491
24147
|
switch (token) {
|
|
23492
24148
|
case "--pr":
|
|
23493
|
-
prRef =
|
|
24149
|
+
prRef = requireValue10(rest, token);
|
|
23494
24150
|
break;
|
|
23495
24151
|
case "--cwd":
|
|
23496
|
-
cwd =
|
|
24152
|
+
cwd = requireValue10(rest, token);
|
|
23497
24153
|
break;
|
|
23498
24154
|
default:
|
|
23499
24155
|
throw new Error(`Unknown summary option: ${token}`);
|
|
@@ -23518,13 +24174,13 @@ function parseQuizArgs(tokens) {
|
|
|
23518
24174
|
const token = rest.shift();
|
|
23519
24175
|
switch (token) {
|
|
23520
24176
|
case "--paper-id":
|
|
23521
|
-
paperId =
|
|
24177
|
+
paperId = requireValue10(rest, token);
|
|
23522
24178
|
break;
|
|
23523
24179
|
case "--base-url":
|
|
23524
|
-
apiBaseUrl =
|
|
24180
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23525
24181
|
break;
|
|
23526
24182
|
case "--link-base":
|
|
23527
|
-
linkBaseUrl =
|
|
24183
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23528
24184
|
break;
|
|
23529
24185
|
default:
|
|
23530
24186
|
throw new Error(`Unknown quiz create-draft option: ${token}`);
|
|
@@ -23550,16 +24206,16 @@ function parseQuizArgs(tokens) {
|
|
|
23550
24206
|
const token = rest.shift();
|
|
23551
24207
|
switch (token) {
|
|
23552
24208
|
case "--paper-id":
|
|
23553
|
-
paperId =
|
|
24209
|
+
paperId = requireValue10(rest, token);
|
|
23554
24210
|
break;
|
|
23555
24211
|
case "--file":
|
|
23556
|
-
filePath =
|
|
24212
|
+
filePath = requireValue10(rest, token);
|
|
23557
24213
|
break;
|
|
23558
24214
|
case "--base-url":
|
|
23559
|
-
apiBaseUrl =
|
|
24215
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23560
24216
|
break;
|
|
23561
24217
|
case "--link-base":
|
|
23562
|
-
linkBaseUrl =
|
|
24218
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23563
24219
|
break;
|
|
23564
24220
|
default:
|
|
23565
24221
|
throw new Error(`Unknown quiz update-meta option: ${token}`);
|
|
@@ -23589,16 +24245,16 @@ function parseQuizArgs(tokens) {
|
|
|
23589
24245
|
const token = rest.shift();
|
|
23590
24246
|
switch (token) {
|
|
23591
24247
|
case "--paper-id":
|
|
23592
|
-
paperId =
|
|
24248
|
+
paperId = requireValue10(rest, token);
|
|
23593
24249
|
break;
|
|
23594
24250
|
case "--file":
|
|
23595
|
-
filePath =
|
|
24251
|
+
filePath = requireValue10(rest, token);
|
|
23596
24252
|
break;
|
|
23597
24253
|
case "--base-url":
|
|
23598
|
-
apiBaseUrl =
|
|
24254
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23599
24255
|
break;
|
|
23600
24256
|
case "--link-base":
|
|
23601
|
-
linkBaseUrl =
|
|
24257
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23602
24258
|
break;
|
|
23603
24259
|
default:
|
|
23604
24260
|
throw new Error(`Unknown quiz append-step option: ${token}`);
|
|
@@ -23629,19 +24285,19 @@ function parseQuizArgs(tokens) {
|
|
|
23629
24285
|
const token = rest.shift();
|
|
23630
24286
|
switch (token) {
|
|
23631
24287
|
case "--paper-id":
|
|
23632
|
-
paperId =
|
|
24288
|
+
paperId = requireValue10(rest, token);
|
|
23633
24289
|
break;
|
|
23634
24290
|
case "--step-id":
|
|
23635
|
-
stepId =
|
|
24291
|
+
stepId = requireValue10(rest, token);
|
|
23636
24292
|
break;
|
|
23637
24293
|
case "--file":
|
|
23638
|
-
filePath =
|
|
24294
|
+
filePath = requireValue10(rest, token);
|
|
23639
24295
|
break;
|
|
23640
24296
|
case "--base-url":
|
|
23641
|
-
apiBaseUrl =
|
|
24297
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23642
24298
|
break;
|
|
23643
24299
|
case "--link-base":
|
|
23644
|
-
linkBaseUrl =
|
|
24300
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23645
24301
|
break;
|
|
23646
24302
|
default:
|
|
23647
24303
|
throw new Error(`Unknown quiz update-step option: ${token}`);
|
|
@@ -23675,16 +24331,16 @@ function parseQuizArgs(tokens) {
|
|
|
23675
24331
|
const token = rest.shift();
|
|
23676
24332
|
switch (token) {
|
|
23677
24333
|
case "--paper-id":
|
|
23678
|
-
paperId =
|
|
24334
|
+
paperId = requireValue10(rest, token);
|
|
23679
24335
|
break;
|
|
23680
24336
|
case "--step-ids":
|
|
23681
|
-
stepIdsRaw =
|
|
24337
|
+
stepIdsRaw = requireValue10(rest, token);
|
|
23682
24338
|
break;
|
|
23683
24339
|
case "--base-url":
|
|
23684
|
-
apiBaseUrl =
|
|
24340
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23685
24341
|
break;
|
|
23686
24342
|
case "--link-base":
|
|
23687
|
-
linkBaseUrl =
|
|
24343
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23688
24344
|
break;
|
|
23689
24345
|
default:
|
|
23690
24346
|
throw new Error(`Unknown quiz reorder option: ${token}`);
|
|
@@ -23717,13 +24373,13 @@ function parseQuizArgs(tokens) {
|
|
|
23717
24373
|
const token = rest.shift();
|
|
23718
24374
|
switch (token) {
|
|
23719
24375
|
case "--paper-id":
|
|
23720
|
-
paperId =
|
|
24376
|
+
paperId = requireValue10(rest, token);
|
|
23721
24377
|
break;
|
|
23722
24378
|
case "--base-url":
|
|
23723
|
-
apiBaseUrl =
|
|
24379
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23724
24380
|
break;
|
|
23725
24381
|
case "--link-base":
|
|
23726
|
-
linkBaseUrl =
|
|
24382
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23727
24383
|
break;
|
|
23728
24384
|
default:
|
|
23729
24385
|
throw new Error(`Unknown quiz activate option: ${token}`);
|
|
@@ -23748,13 +24404,13 @@ function parseQuizArgs(tokens) {
|
|
|
23748
24404
|
const token = rest.shift();
|
|
23749
24405
|
switch (token) {
|
|
23750
24406
|
case "--paper-id":
|
|
23751
|
-
paperId =
|
|
24407
|
+
paperId = requireValue10(rest, token);
|
|
23752
24408
|
break;
|
|
23753
24409
|
case "--base-url":
|
|
23754
|
-
apiBaseUrl =
|
|
24410
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23755
24411
|
break;
|
|
23756
24412
|
case "--link-base":
|
|
23757
|
-
linkBaseUrl =
|
|
24413
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23758
24414
|
break;
|
|
23759
24415
|
default:
|
|
23760
24416
|
throw new Error(`Unknown quiz view option: ${token}`);
|
|
@@ -23783,22 +24439,22 @@ function parseQuizArgs(tokens) {
|
|
|
23783
24439
|
const token = rest.shift();
|
|
23784
24440
|
switch (token) {
|
|
23785
24441
|
case "--paper-id":
|
|
23786
|
-
paperId =
|
|
24442
|
+
paperId = requireValue10(rest, token);
|
|
23787
24443
|
break;
|
|
23788
24444
|
case "--step-id":
|
|
23789
|
-
stepId =
|
|
24445
|
+
stepId = requireValue10(rest, token);
|
|
23790
24446
|
break;
|
|
23791
24447
|
case "--file":
|
|
23792
|
-
filePath =
|
|
24448
|
+
filePath = requireValue10(rest, token);
|
|
23793
24449
|
break;
|
|
23794
24450
|
case "--new-paper-id":
|
|
23795
|
-
newPaperId =
|
|
24451
|
+
newPaperId = requireValue10(rest, token);
|
|
23796
24452
|
break;
|
|
23797
24453
|
case "--base-url":
|
|
23798
|
-
apiBaseUrl =
|
|
24454
|
+
apiBaseUrl = requireValue10(rest, token);
|
|
23799
24455
|
break;
|
|
23800
24456
|
case "--link-base":
|
|
23801
|
-
linkBaseUrl =
|
|
24457
|
+
linkBaseUrl = requireValue10(rest, token);
|
|
23802
24458
|
break;
|
|
23803
24459
|
case "--activate":
|
|
23804
24460
|
activate = true;
|
|
@@ -23888,10 +24544,10 @@ function parseLinearPrArgs(tokens) {
|
|
|
23888
24544
|
const token = rest.shift();
|
|
23889
24545
|
switch (token) {
|
|
23890
24546
|
case "--account":
|
|
23891
|
-
account =
|
|
24547
|
+
account = requireValue10(rest, token);
|
|
23892
24548
|
break;
|
|
23893
24549
|
case "--cwd":
|
|
23894
|
-
cwd =
|
|
24550
|
+
cwd = requireValue10(rest, token);
|
|
23895
24551
|
break;
|
|
23896
24552
|
default:
|
|
23897
24553
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -23920,35 +24576,35 @@ function parseLinearCreateArgs(tokens) {
|
|
|
23920
24576
|
const token = rest.shift();
|
|
23921
24577
|
switch (token) {
|
|
23922
24578
|
case "--account":
|
|
23923
|
-
account =
|
|
24579
|
+
account = requireValue10(rest, token);
|
|
23924
24580
|
break;
|
|
23925
24581
|
case "--repl":
|
|
23926
24582
|
useRepl = true;
|
|
23927
24583
|
break;
|
|
23928
24584
|
case "--title":
|
|
23929
|
-
title =
|
|
24585
|
+
title = requireValue10(rest, token);
|
|
23930
24586
|
break;
|
|
23931
24587
|
case "--desc":
|
|
23932
24588
|
case "--description":
|
|
23933
|
-
description = decodeEscapedNewlines(
|
|
24589
|
+
description = decodeEscapedNewlines(requireValue10(rest, token));
|
|
23934
24590
|
break;
|
|
23935
24591
|
case "--team-id":
|
|
23936
|
-
teamId =
|
|
24592
|
+
teamId = requireValue10(rest, token);
|
|
23937
24593
|
break;
|
|
23938
24594
|
case "--team-key":
|
|
23939
|
-
teamKey =
|
|
24595
|
+
teamKey = requireValue10(rest, token);
|
|
23940
24596
|
break;
|
|
23941
24597
|
case "--priority":
|
|
23942
|
-
priority = parseLinearPriority(
|
|
24598
|
+
priority = parseLinearPriority(requireValue10(rest, token));
|
|
23943
24599
|
break;
|
|
23944
24600
|
case "--parent-id":
|
|
23945
|
-
parentId =
|
|
24601
|
+
parentId = requireValue10(rest, token);
|
|
23946
24602
|
break;
|
|
23947
24603
|
case "--state-id":
|
|
23948
|
-
stateId =
|
|
24604
|
+
stateId = requireValue10(rest, token);
|
|
23949
24605
|
break;
|
|
23950
24606
|
case "--cwd":
|
|
23951
|
-
cwd =
|
|
24607
|
+
cwd = requireValue10(rest, token);
|
|
23952
24608
|
break;
|
|
23953
24609
|
default:
|
|
23954
24610
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -23983,10 +24639,10 @@ function parseLinearWhoamiArgs(tokens) {
|
|
|
23983
24639
|
const token = rest.shift();
|
|
23984
24640
|
switch (token) {
|
|
23985
24641
|
case "--account":
|
|
23986
|
-
account =
|
|
24642
|
+
account = requireValue10(rest, token);
|
|
23987
24643
|
break;
|
|
23988
24644
|
case "--cwd":
|
|
23989
|
-
cwd =
|
|
24645
|
+
cwd = requireValue10(rest, token);
|
|
23990
24646
|
break;
|
|
23991
24647
|
default:
|
|
23992
24648
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24011,10 +24667,10 @@ function parseLinearViewArgs(tokens) {
|
|
|
24011
24667
|
const token = rest.shift();
|
|
24012
24668
|
switch (token) {
|
|
24013
24669
|
case "--account":
|
|
24014
|
-
account =
|
|
24670
|
+
account = requireValue10(rest, token);
|
|
24015
24671
|
break;
|
|
24016
24672
|
case "--cwd":
|
|
24017
|
-
cwd =
|
|
24673
|
+
cwd = requireValue10(rest, token);
|
|
24018
24674
|
break;
|
|
24019
24675
|
default:
|
|
24020
24676
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24049,32 +24705,32 @@ function parseLinearUpdateArgs(tokens) {
|
|
|
24049
24705
|
const token = rest.shift();
|
|
24050
24706
|
switch (token) {
|
|
24051
24707
|
case "--account":
|
|
24052
|
-
account =
|
|
24708
|
+
account = requireValue10(rest, token);
|
|
24053
24709
|
break;
|
|
24054
24710
|
case "--title":
|
|
24055
|
-
title =
|
|
24711
|
+
title = requireValue10(rest, token);
|
|
24056
24712
|
break;
|
|
24057
24713
|
case "--desc":
|
|
24058
24714
|
case "--description":
|
|
24059
|
-
description = decodeEscapedNewlines(
|
|
24715
|
+
description = decodeEscapedNewlines(requireValue10(rest, token));
|
|
24060
24716
|
break;
|
|
24061
24717
|
case "--team-id":
|
|
24062
|
-
teamId =
|
|
24718
|
+
teamId = requireValue10(rest, token);
|
|
24063
24719
|
break;
|
|
24064
24720
|
case "--team-key":
|
|
24065
|
-
teamKey =
|
|
24721
|
+
teamKey = requireValue10(rest, token);
|
|
24066
24722
|
break;
|
|
24067
24723
|
case "--priority":
|
|
24068
|
-
priority = parseLinearPriority(
|
|
24724
|
+
priority = parseLinearPriority(requireValue10(rest, token));
|
|
24069
24725
|
break;
|
|
24070
24726
|
case "--parent-id":
|
|
24071
|
-
parentId =
|
|
24727
|
+
parentId = requireValue10(rest, token);
|
|
24072
24728
|
break;
|
|
24073
24729
|
case "--state-id":
|
|
24074
|
-
stateId =
|
|
24730
|
+
stateId = requireValue10(rest, token);
|
|
24075
24731
|
break;
|
|
24076
24732
|
case "--cwd":
|
|
24077
|
-
cwd =
|
|
24733
|
+
cwd = requireValue10(rest, token);
|
|
24078
24734
|
break;
|
|
24079
24735
|
default:
|
|
24080
24736
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24112,10 +24768,10 @@ function parseLinearSubIssuesArgs(tokens) {
|
|
|
24112
24768
|
const token = rest.shift();
|
|
24113
24769
|
switch (token) {
|
|
24114
24770
|
case "--account":
|
|
24115
|
-
account =
|
|
24771
|
+
account = requireValue10(rest, token);
|
|
24116
24772
|
break;
|
|
24117
24773
|
case "--cwd":
|
|
24118
|
-
cwd =
|
|
24774
|
+
cwd = requireValue10(rest, token);
|
|
24119
24775
|
break;
|
|
24120
24776
|
default:
|
|
24121
24777
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24142,15 +24798,15 @@ function parseLinearCommentArgs(tokens) {
|
|
|
24142
24798
|
const token = rest.shift();
|
|
24143
24799
|
switch (token) {
|
|
24144
24800
|
case "--account":
|
|
24145
|
-
account =
|
|
24801
|
+
account = requireValue10(rest, token);
|
|
24146
24802
|
break;
|
|
24147
24803
|
case "--body":
|
|
24148
24804
|
case "--desc":
|
|
24149
24805
|
case "--description":
|
|
24150
|
-
body = decodeEscapedNewlines(
|
|
24806
|
+
body = decodeEscapedNewlines(requireValue10(rest, token));
|
|
24151
24807
|
break;
|
|
24152
24808
|
case "--cwd":
|
|
24153
|
-
cwd =
|
|
24809
|
+
cwd = requireValue10(rest, token);
|
|
24154
24810
|
break;
|
|
24155
24811
|
default:
|
|
24156
24812
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24180,10 +24836,10 @@ function parseLinearCommentsArgs(tokens) {
|
|
|
24180
24836
|
const token = rest.shift();
|
|
24181
24837
|
switch (token) {
|
|
24182
24838
|
case "--account":
|
|
24183
|
-
account =
|
|
24839
|
+
account = requireValue10(rest, token);
|
|
24184
24840
|
break;
|
|
24185
24841
|
case "--cwd":
|
|
24186
|
-
cwd =
|
|
24842
|
+
cwd = requireValue10(rest, token);
|
|
24187
24843
|
break;
|
|
24188
24844
|
default:
|
|
24189
24845
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24207,16 +24863,16 @@ function parseLinearCycleArgs(tokens) {
|
|
|
24207
24863
|
const token = rest.shift();
|
|
24208
24864
|
switch (token) {
|
|
24209
24865
|
case "--account":
|
|
24210
|
-
account =
|
|
24866
|
+
account = requireValue10(rest, token);
|
|
24211
24867
|
break;
|
|
24212
24868
|
case "--team-id":
|
|
24213
|
-
teamId =
|
|
24869
|
+
teamId = requireValue10(rest, token);
|
|
24214
24870
|
break;
|
|
24215
24871
|
case "--team-key":
|
|
24216
|
-
teamKey =
|
|
24872
|
+
teamKey = requireValue10(rest, token);
|
|
24217
24873
|
break;
|
|
24218
24874
|
case "--cwd":
|
|
24219
|
-
cwd =
|
|
24875
|
+
cwd = requireValue10(rest, token);
|
|
24220
24876
|
break;
|
|
24221
24877
|
default:
|
|
24222
24878
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24239,10 +24895,10 @@ function parseLinearTeamsArgs(tokens) {
|
|
|
24239
24895
|
const token = rest.shift();
|
|
24240
24896
|
switch (token) {
|
|
24241
24897
|
case "--account":
|
|
24242
|
-
account =
|
|
24898
|
+
account = requireValue10(rest, token);
|
|
24243
24899
|
break;
|
|
24244
24900
|
case "--cwd":
|
|
24245
|
-
cwd =
|
|
24901
|
+
cwd = requireValue10(rest, token);
|
|
24246
24902
|
break;
|
|
24247
24903
|
default:
|
|
24248
24904
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24269,16 +24925,16 @@ function parseLinearUserIssuesArgs(tokens) {
|
|
|
24269
24925
|
const token = rest.shift();
|
|
24270
24926
|
switch (token) {
|
|
24271
24927
|
case "--account":
|
|
24272
|
-
account =
|
|
24928
|
+
account = requireValue10(rest, token);
|
|
24273
24929
|
break;
|
|
24274
24930
|
case "--cycle":
|
|
24275
|
-
cycle = parseLinearCycle(
|
|
24931
|
+
cycle = parseLinearCycle(requireValue10(rest, token));
|
|
24276
24932
|
break;
|
|
24277
24933
|
case "--status":
|
|
24278
|
-
status = parseLinearStatus(
|
|
24934
|
+
status = parseLinearStatus(requireValue10(rest, token));
|
|
24279
24935
|
break;
|
|
24280
24936
|
case "--cwd":
|
|
24281
|
-
cwd =
|
|
24937
|
+
cwd = requireValue10(rest, token);
|
|
24282
24938
|
break;
|
|
24283
24939
|
default:
|
|
24284
24940
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24312,28 +24968,28 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
24312
24968
|
const token = rest.shift();
|
|
24313
24969
|
switch (token) {
|
|
24314
24970
|
case "--account":
|
|
24315
|
-
account =
|
|
24971
|
+
account = requireValue10(rest, token);
|
|
24316
24972
|
break;
|
|
24317
24973
|
case "--team-id":
|
|
24318
|
-
teamId =
|
|
24974
|
+
teamId = requireValue10(rest, token);
|
|
24319
24975
|
break;
|
|
24320
24976
|
case "--team-key":
|
|
24321
|
-
teamKey =
|
|
24977
|
+
teamKey = requireValue10(rest, token);
|
|
24322
24978
|
break;
|
|
24323
24979
|
case "--user":
|
|
24324
|
-
user =
|
|
24980
|
+
user = requireValue10(rest, token);
|
|
24325
24981
|
break;
|
|
24326
24982
|
case "--cycle":
|
|
24327
|
-
cycle = parseLinearCycle(
|
|
24983
|
+
cycle = parseLinearCycle(requireValue10(rest, token));
|
|
24328
24984
|
break;
|
|
24329
24985
|
case "--status":
|
|
24330
|
-
status = parseLinearStatus(
|
|
24986
|
+
status = parseLinearStatus(requireValue10(rest, token));
|
|
24331
24987
|
break;
|
|
24332
24988
|
case "--query":
|
|
24333
|
-
query =
|
|
24989
|
+
query = requireValue10(rest, token).trim();
|
|
24334
24990
|
break;
|
|
24335
24991
|
case "--limit": {
|
|
24336
|
-
const value = Number.parseInt(
|
|
24992
|
+
const value = Number.parseInt(requireValue10(rest, token), 10);
|
|
24337
24993
|
if (!Number.isInteger(value) || value < 1 || value > 250) {
|
|
24338
24994
|
throw new Error("Invalid --limit. Expected an integer between 1 and 250.");
|
|
24339
24995
|
}
|
|
@@ -24341,7 +24997,7 @@ function parseLinearIssuesArgs(tokens) {
|
|
|
24341
24997
|
break;
|
|
24342
24998
|
}
|
|
24343
24999
|
case "--cwd":
|
|
24344
|
-
cwd =
|
|
25000
|
+
cwd = requireValue10(rest, token);
|
|
24345
25001
|
break;
|
|
24346
25002
|
default:
|
|
24347
25003
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24382,10 +25038,10 @@ function parseLinearLegacyArgs(tokens) {
|
|
|
24382
25038
|
useScreenshot = true;
|
|
24383
25039
|
break;
|
|
24384
25040
|
case "--account":
|
|
24385
|
-
account =
|
|
25041
|
+
account = requireValue10(rest, token);
|
|
24386
25042
|
break;
|
|
24387
25043
|
case "--cwd":
|
|
24388
|
-
cwd =
|
|
25044
|
+
cwd = requireValue10(rest, token);
|
|
24389
25045
|
break;
|
|
24390
25046
|
default:
|
|
24391
25047
|
throw new Error(`Unknown linear option: ${token}`);
|
|
@@ -24479,19 +25135,19 @@ function parseNotionArgs(tokens) {
|
|
|
24479
25135
|
const token = rest.shift();
|
|
24480
25136
|
switch (token) {
|
|
24481
25137
|
case "--parent":
|
|
24482
|
-
parentPageId =
|
|
25138
|
+
parentPageId = requireValue10(rest, token);
|
|
24483
25139
|
break;
|
|
24484
25140
|
case "--title":
|
|
24485
|
-
title =
|
|
25141
|
+
title = requireValue10(rest, token);
|
|
24486
25142
|
break;
|
|
24487
25143
|
case "--private":
|
|
24488
25144
|
isPrivate = true;
|
|
24489
25145
|
break;
|
|
24490
25146
|
case "--content":
|
|
24491
|
-
content2 =
|
|
25147
|
+
content2 = requireValue10(rest, token);
|
|
24492
25148
|
break;
|
|
24493
25149
|
case "--file":
|
|
24494
|
-
filePath2 =
|
|
25150
|
+
filePath2 = requireValue10(rest, token);
|
|
24495
25151
|
break;
|
|
24496
25152
|
default:
|
|
24497
25153
|
throw new Error(`Unknown notion option: ${token}`);
|
|
@@ -24535,10 +25191,10 @@ function parseNotionArgs(tokens) {
|
|
|
24535
25191
|
const token = rest.shift();
|
|
24536
25192
|
switch (token) {
|
|
24537
25193
|
case "--content":
|
|
24538
|
-
content =
|
|
25194
|
+
content = requireValue10(rest, token);
|
|
24539
25195
|
break;
|
|
24540
25196
|
case "--file":
|
|
24541
|
-
filePath =
|
|
25197
|
+
filePath = requireValue10(rest, token);
|
|
24542
25198
|
break;
|
|
24543
25199
|
case "--append":
|
|
24544
25200
|
append = true;
|
|
@@ -24583,11 +25239,11 @@ function parseRandomArgs(tokens) {
|
|
|
24583
25239
|
mode = "easy";
|
|
24584
25240
|
break;
|
|
24585
25241
|
case "--length":
|
|
24586
|
-
length = parsePositiveInt(
|
|
25242
|
+
length = parsePositiveInt(requireValue10(rest, token), token);
|
|
24587
25243
|
seenLength = true;
|
|
24588
25244
|
break;
|
|
24589
25245
|
case "--charset": {
|
|
24590
|
-
const value =
|
|
25246
|
+
const value = requireValue10(rest, token);
|
|
24591
25247
|
if (!["base64url", "hex", "alnum", "ascii"].includes(value)) {
|
|
24592
25248
|
throw new Error(
|
|
24593
25249
|
`Invalid --charset value: ${value}. Use base64url|hex|alnum|ascii.`
|
|
@@ -24598,18 +25254,18 @@ function parseRandomArgs(tokens) {
|
|
|
24598
25254
|
break;
|
|
24599
25255
|
}
|
|
24600
25256
|
case "--count":
|
|
24601
|
-
count = parsePositiveInt(
|
|
25257
|
+
count = parsePositiveInt(requireValue10(rest, token), token);
|
|
24602
25258
|
break;
|
|
24603
25259
|
case "--words":
|
|
24604
|
-
words = parsePositiveInt(
|
|
25260
|
+
words = parsePositiveInt(requireValue10(rest, token), token);
|
|
24605
25261
|
seenWords = true;
|
|
24606
25262
|
break;
|
|
24607
25263
|
case "--digits":
|
|
24608
|
-
digits = parseNonNegativeInt(
|
|
25264
|
+
digits = parseNonNegativeInt(requireValue10(rest, token), token);
|
|
24609
25265
|
seenDigits = true;
|
|
24610
25266
|
break;
|
|
24611
25267
|
case "--separator":
|
|
24612
|
-
separator =
|
|
25268
|
+
separator = requireValue10(rest, token);
|
|
24613
25269
|
seenSeparator = true;
|
|
24614
25270
|
break;
|
|
24615
25271
|
default:
|
|
@@ -24640,40 +25296,7 @@ function parseRandomArgs(tokens) {
|
|
|
24640
25296
|
count
|
|
24641
25297
|
};
|
|
24642
25298
|
}
|
|
24643
|
-
function
|
|
24644
|
-
const rest = [...tokens];
|
|
24645
|
-
const options = {
|
|
24646
|
-
endpoint: "http://localhost:9222",
|
|
24647
|
-
json: false,
|
|
24648
|
-
mode: "list",
|
|
24649
|
-
threadName: void 0
|
|
24650
|
-
};
|
|
24651
|
-
while (rest.length > 0) {
|
|
24652
|
-
const token = rest.shift();
|
|
24653
|
-
switch (token) {
|
|
24654
|
-
case "--endpoint":
|
|
24655
|
-
options.endpoint = requireValue8(rest, token);
|
|
24656
|
-
break;
|
|
24657
|
-
case "--json":
|
|
24658
|
-
options.json = true;
|
|
24659
|
-
break;
|
|
24660
|
-
case "--list":
|
|
24661
|
-
options.mode = "list";
|
|
24662
|
-
break;
|
|
24663
|
-
case "--thread":
|
|
24664
|
-
options.mode = "thread";
|
|
24665
|
-
options.threadName = requireValue8(rest, token);
|
|
24666
|
-
break;
|
|
24667
|
-
default:
|
|
24668
|
-
throw new Error(`Unknown collect option: ${token}`);
|
|
24669
|
-
}
|
|
24670
|
-
}
|
|
24671
|
-
if (options.mode === "thread" && !options.threadName) {
|
|
24672
|
-
throw new Error("Missing thread name. Usage: collect --thread <name>.");
|
|
24673
|
-
}
|
|
24674
|
-
return { type: "collect" /* Collect */, ...options };
|
|
24675
|
-
}
|
|
24676
|
-
function requireValue8(tokens, optionName) {
|
|
25299
|
+
function requireValue10(tokens, optionName) {
|
|
24677
25300
|
const value = tokens.shift();
|
|
24678
25301
|
if (!value) {
|
|
24679
25302
|
throw new Error(`Missing value for ${optionName}`);
|
|
@@ -24809,6 +25432,11 @@ async function main() {
|
|
|
24809
25432
|
await handler.handle(commandArgs);
|
|
24810
25433
|
return;
|
|
24811
25434
|
}
|
|
25435
|
+
case "runner" /* Runner */: {
|
|
25436
|
+
const handler = new RunnerCommandHandler();
|
|
25437
|
+
await handler.handle(commandArgs);
|
|
25438
|
+
return;
|
|
25439
|
+
}
|
|
24812
25440
|
case "ns" /* Ns */: {
|
|
24813
25441
|
const handler = new NsCommandHandler();
|
|
24814
25442
|
await handler.handle(commandArgs);
|