@moxt-ai/cli 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/index.js +9 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,9 +226,8 @@ moxt workflow comment create -w <workspace-id> <workflow-file-id> <task-id> --co
|
|
|
226
226
|
moxt workflow comment list -w <workspace-id> <workflow-file-id> <task-id>
|
|
227
227
|
moxt workflow comment delete -w <workspace-id> <workflow-file-id> <task-id> <comment-id>
|
|
228
228
|
|
|
229
|
-
#
|
|
230
|
-
moxt workflow run
|
|
231
|
-
moxt workflow run abort -w <workspace-id> <workflow-file-id> <trigger-id>
|
|
229
|
+
# Abort workflow agent runs
|
|
230
|
+
moxt workflow run abort -w <workspace-id> <workflow-file-id> <pipeline-id>
|
|
232
231
|
```
|
|
233
232
|
|
|
234
233
|
Workflow, status, and task descriptions are read from local UTF-8 text files with `--desc-file`.
|
package/dist/index.js
CHANGED
|
@@ -153,7 +153,7 @@ function getApiKeyOrUndefined() {
|
|
|
153
153
|
|
|
154
154
|
// src/utils/http.ts
|
|
155
155
|
function getUserAgent() {
|
|
156
|
-
return `moxt-cli/${"0.
|
|
156
|
+
return `moxt-cli/${"0.6.0"} (${platform()}/${arch()}) node/${process.versions.node}`;
|
|
157
157
|
}
|
|
158
158
|
async function fetchApi(method, path2, body) {
|
|
159
159
|
const apiKey = getApiKey();
|
|
@@ -2097,39 +2097,18 @@ function registerCommentCommands(workflow) {
|
|
|
2097
2097
|
function registerRunCommands(workflow) {
|
|
2098
2098
|
const run = workflow.command("run").description("Workflow agent run operations");
|
|
2099
2099
|
addWorkspaceOption(
|
|
2100
|
-
run.command("
|
|
2101
|
-
).action(async (workflowFileId,
|
|
2102
|
-
const workflowPipelineTriggerIds = runOrExit4(
|
|
2103
|
-
() => triggerIds.map((triggerId) => parsePositiveInteger(triggerId, "workflowPipelineTriggerId"))
|
|
2104
|
-
);
|
|
2105
|
-
startSpinner("Fetching run statuses...");
|
|
2106
|
-
const response = await httpPost(
|
|
2107
|
-
`/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline/triggers/statuses`,
|
|
2108
|
-
{ workflowPipelineTriggerIds }
|
|
2109
|
-
);
|
|
2110
|
-
if (!response.ok) {
|
|
2111
|
-
stopSpinner(false, "Failed");
|
|
2112
|
-
failResponse(response);
|
|
2113
|
-
}
|
|
2114
|
-
stopSpinner(true, `Found ${response.data.length} run status item(s)`);
|
|
2115
|
-
for (const item of response.data) {
|
|
2116
|
-
print(`${colors.bold}${item.workflowPipelineTriggerId}${colors.reset} ${item.pipelineStatus}`);
|
|
2117
|
-
}
|
|
2118
|
-
});
|
|
2119
|
-
addWorkspaceOption(
|
|
2120
|
-
run.command("abort").description("Abort a workflow agent run").argument("<workflowFileId>").argument("<triggerId>")
|
|
2121
|
-
).action(async (workflowFileId, triggerId, options) => {
|
|
2122
|
-
const id = runOrExit4(() => parsePositiveInteger(triggerId, "workflowPipelineTriggerId"));
|
|
2100
|
+
run.command("abort").description("Abort a workflow agent run").argument("<workflowFileId>").argument("<pipelineId>")
|
|
2101
|
+
).action(async (workflowFileId, pipelineId, options) => {
|
|
2123
2102
|
startSpinner("Aborting run...");
|
|
2124
2103
|
const response = await httpPost(
|
|
2125
|
-
`/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline
|
|
2104
|
+
`/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline/${pipelineId}/abort`,
|
|
2126
2105
|
{}
|
|
2127
2106
|
);
|
|
2128
2107
|
if (!response.ok) {
|
|
2129
2108
|
stopSpinner(false, "Failed");
|
|
2130
2109
|
failResponse(response);
|
|
2131
2110
|
}
|
|
2132
|
-
stopSpinner(true, `Abort accepted: ${
|
|
2111
|
+
stopSpinner(true, `Abort accepted: ${pipelineId}`);
|
|
2133
2112
|
});
|
|
2134
2113
|
}
|
|
2135
2114
|
|
|
@@ -2156,7 +2135,7 @@ var FLUSH_TIMEOUT_MS = 3e3;
|
|
|
2156
2135
|
var MAX_BATCH_SIZE = 100;
|
|
2157
2136
|
function commonLabels() {
|
|
2158
2137
|
return {
|
|
2159
|
-
cli_version: "0.
|
|
2138
|
+
cli_version: "0.6.0",
|
|
2160
2139
|
node_version: process.versions.node,
|
|
2161
2140
|
os: platform2(),
|
|
2162
2141
|
arch: arch2(),
|
|
@@ -2202,7 +2181,7 @@ async function flush() {
|
|
|
2202
2181
|
}
|
|
2203
2182
|
const batch = buffer.splice(0, MAX_BATCH_SIZE);
|
|
2204
2183
|
const payload = {
|
|
2205
|
-
release_id: "0.
|
|
2184
|
+
release_id: "0.6.0",
|
|
2206
2185
|
client_type: "cli",
|
|
2207
2186
|
metric_data_list: batch.map((m) => ({
|
|
2208
2187
|
profile: "cli",
|
|
@@ -2343,9 +2322,9 @@ function installExitHandler() {
|
|
|
2343
2322
|
|
|
2344
2323
|
// src/index.ts
|
|
2345
2324
|
updateNotifier({
|
|
2346
|
-
pkg: { name: "@moxt-ai/cli", version: "0.
|
|
2325
|
+
pkg: { name: "@moxt-ai/cli", version: "0.6.0" }
|
|
2347
2326
|
}).notify();
|
|
2348
|
-
var program = createProgram("0.
|
|
2327
|
+
var program = createProgram("0.6.0");
|
|
2349
2328
|
instrumentProgram(program);
|
|
2350
2329
|
installExitHandler();
|
|
2351
2330
|
program.parseAsync(process.argv).then(async () => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/program.ts","../src/commands/file.ts","../src/commands/file-comment.ts","../src/utils/file-selector.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/spinner.ts","../src/utils/search-options.ts","../src/utils/run-or-exit.ts","../src/commands/memory.ts","../src/utils/miniapp-db.ts","../src/commands/miniapp.ts","../src/telemetry/config.ts","../src/telemetry/opt-out.ts","../src/commands/telemetry.ts","../src/commands/whoami.ts","../src/commands/workspace.ts","../src/commands/workflow.ts","../src/telemetry/client.ts","../src/telemetry/notice.ts","../src/telemetry/instrument.ts"],"sourcesContent":["import updateNotifier from 'update-notifier'\nimport { createProgram } from './program.js'\nimport { flush } from './telemetry/client.js'\nimport { installExitHandler, instrumentProgram } from './telemetry/instrument.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = createProgram(__CLI_VERSION__)\n\ninstrumentProgram(program)\ninstallExitHandler()\n\nprogram\n .parseAsync(process.argv)\n .then(async () => {\n await flush()\n })\n .catch(async (err: unknown) => {\n console.error('CLI Error:', err)\n await flush()\n process.exit(1)\n })\n","import { Command } from 'commander'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerMemoryCommand } from './commands/memory.js'\nimport { registerMiniappCommand } from './commands/miniapp.js'\nimport { registerTelemetryCommand } from './commands/telemetry.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\nimport { registerWorkflowCommand } from './commands/workflow.js'\n\nexport function createProgram(version: string): Command {\n const program = new Command()\n\n program\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(version)\n .action(() => {\n program.help()\n })\n\n registerWhoamiCommand(program)\n registerWorkspaceCommand(program)\n registerFileCommand(program)\n registerMemoryCommand(program)\n registerWorkflowCommand(program)\n registerMiniappCommand(program)\n registerTelemetryCommand(program)\n\n return program\n}\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport { registerFileCommentCommands } from './file-comment.js'\nimport {\n buildFileQueryString,\n isBinaryContent,\n resolveReadMode,\n resolveSpaceSelector,\n resolveWriteMode,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseSearchMode } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\ninterface FieldHighlight {\n text: string\n}\n\ninterface SemanticSnippet {\n content: string\n}\n\ninterface FileSearchItem {\n repoId: string\n fileId: string\n filePath: string\n rank: number\n contentHighlight?: FieldHighlight\n filePathHighlight?: FieldHighlight\n semanticSnippets: SemanticSnippet[]\n}\n\ninterface FileSearchResponse {\n items: FileSearchItem[]\n}\n\nfunction addSpaceOptions(cmd: Command): Command {\n return cmd\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n registerFileCommentCommands(file)\n\n addSpaceOptions(\n file.command('search')\n .description('Search files in accessible spaces')\n .argument('<query>', 'Search query')\n .option('-l, --limit <limit>', 'Maximum number of files to return', '30')\n .option('--mode <mode>', 'Keyword matching mode: any or all', 'any'),\n ).action(async (query: string, options: SpaceOptions & { limit?: string; mode?: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const limit = runOrExit(() => parseSearchLimit(options.limit, 30, 80))\n const mode = runOrExit(() => parseSearchMode(options.mode))\n\n startSpinner('Searching files...')\n const response = await httpPost<FileSearchResponse>(\n `/workspaces/${options.workspace}/files/search`,\n {\n query,\n limit,\n mode,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No files found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} file(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. ${item.filePath}${colors.reset}`)\n print(`${colors.dim}repo=${item.repoId} file=${item.fileId}${colors.reset}`)\n const snippet = item.contentHighlight?.text ?? item.semanticSnippets[0]?.content\n if (snippet) {\n print(snippet)\n }\n print('')\n }\n })\n\n addSpaceOptions(\n file.command('get-url')\n .description('Resolve the shareable browser URL for a file')\n .requiredOption('-p, --path <path>', 'File path'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Resolving URL...')\n const response = await httpGet<FileUrlResponse>(\n `/workspaces/${options.workspace}/files/url${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, response.data.path)\n print(`${colors.cyan}${response.data.url}${colors.reset}`)\n })\n\n addSpaceOptions(\n file.command('list')\n .description('List directory contents')\n .option('-p, --path <path>', 'Directory path', '/'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: Partial<SpaceOptions> & { path?: string; url?: string }) => {\n const mode = runOrExit(() => resolveReadMode(options))\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(mode.url)}`,\n )\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n response = await httpGet<FileReadResponse>(\n `/workspaces/${mode.workspace}/files/read${qs}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${displayPath} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'Remote file path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: Partial<SpaceOptions> & {\n path?: string\n url?: string\n localPath: string\n recursive?: boolean\n }) => {\n const mode = runOrExit(() => resolveWriteMode(options))\n\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n\n let response: { ok: boolean; status: number; data: FileWriteResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpPut<FileWriteResponse>('/files/write-by-url', {\n url: mode.url,\n content,\n })\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n response = await httpPut<FileWriteResponse>(\n `/workspaces/${mode.workspace}/files/write`,\n {\n path: mode.path,\n content,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n if (mode.kind === 'by-url') {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n }\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-r, --recursive', 'Create parent directories if needed'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n recursive?: boolean\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-p, --path <path>', 'File or directory path'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","import * as fs from 'node:fs'\nimport { TextDecoder } from 'node:util'\nimport { Command } from 'commander'\nimport {\n buildFileQueryString,\n ReadMode,\n resolveReadMode,\n resolveSpaceSelector,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpGet, httpPatch } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\n// The comment/thread ID column is a nanoid, and canonical file URLs embed a UUID fileId.\n// Mirror the server contract (server-ts openapi-file-comment.vo.ts / openapi-file-url.controller.ts)\n// so the CLI rejects malformed URLs locally instead of forwarding them to the API.\nconst FILE_ID_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\nconst URL_FORMAT_HINT =\n 'Error: invalid Moxt URL format. Expected https://moxt.ai/w/{workspaceId}/{fileId} ' +\n 'or https://moxt.ai/w/{workspaceId}/c/{agentId}[/{sessionId}]?file={fileId}'\n\ninterface FileCommentAuthor {\n humanId: number | null\n assistantId: number | null\n teammateId: number | null\n authorName: string | null\n authorAvatarUrl: string | null\n}\n\ninterface FileCommentItem extends FileCommentAuthor {\n id: string\n threadId: string\n content: string\n createdAt: string\n editedAt: string | null\n}\n\ninterface FileCommentThread {\n threadId: string\n items: FileCommentItem[]\n createdAt: string\n createdBy: FileCommentAuthor\n resolvedAt: string | null\n quotedText: string | null\n fileId: string\n}\n\ninterface ListFileCommentsResponse {\n items: FileCommentThread[]\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\ninterface FileCommentOptions extends Partial<SpaceOptions> {\n path?: string\n url?: string\n}\n\n/**\n * Error thrown when a file comment command's local option/content validation fails.\n * Handlers catch it via {@link runOrExit} and turn it into stderr + exit code 1.\n */\nclass FileCommentOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'FileCommentOptionsError'\n }\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof FileCommentOptionsError || err instanceof SpaceOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\n/**\n * Extract the workspace/file identifiers a comment API call needs from a canonical\n * Moxt file URL. Supports the workspace-mode shape `/w/{workspaceId}/{fileId}` and the\n * chat deeplink `/w/{workspaceId}/c/{agentId}[/{sessionId}]?file={fileId}`.\n */\nfunction parseMoxtFileUrl(url: string): { workspaceId: string; fileId: string } {\n let parsed: URL\n try {\n parsed = new URL(url)\n } catch {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n\n const segments = parsed.pathname.split('/').filter(Boolean)\n if (segments.length < 3 || segments[0] !== 'w') {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n const workspaceId = segments[1]\n\n let fileId: string | undefined\n if (segments[2] === 'c') {\n fileId = parsed.searchParams.get('file') ?? undefined\n } else if (segments.length === 3) {\n fileId = segments[2]\n }\n\n if (!fileId || !FILE_ID_UUID_RE.test(fileId)) {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n return { workspaceId, fileId }\n}\n\n/**\n * Resolve the target file for a comment command. URL mode reads the identifiers directly;\n * path mode calls the existing `file get-url` endpoint to obtain a stable URL, then parses it.\n */\nasync function resolveFileTarget(options: FileCommentOptions): Promise<{ workspaceId: string; fileId: string }> {\n const mode: ReadMode = runOrExit(() => resolveReadMode(options))\n if (mode.kind === 'by-url') {\n return runOrExit(() => parseMoxtFileUrl(mode.url))\n }\n\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n\n startSpinner('Resolving file...')\n const response = await httpGet<FileUrlResponse>(`/workspaces/${mode.workspace}/files/url${qs}`)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${mode.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n stopSpinner(true, response.data.path)\n return runOrExit(() => parseMoxtFileUrl(response.data.url))\n}\n\nfunction readCommentContentFile(path: string): string {\n if (!fs.existsSync(path)) {\n throw new FileCommentOptionsError(`Error: comment content file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new FileCommentOptionsError(`Error: comment content path is not a file: ${path}`)\n }\n const buffer = fs.readFileSync(path)\n if (buffer.includes(0)) {\n throw new FileCommentOptionsError('Error: comment content file must not contain NUL bytes.')\n }\n let content: string\n try {\n content = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer)\n } catch {\n throw new FileCommentOptionsError('Error: comment content file must contain valid UTF-8 text.')\n }\n // The file comment API only requires a non-empty body (server schema: z.string().min(1));\n // there is no server-side max length, so the CLI must not impose a client-only cap.\n if (content.length === 0) {\n throw new FileCommentOptionsError('Error: comment content file must not be empty.')\n }\n return content\n}\n\nfunction parseResolveState(state: string | undefined): boolean {\n if (state === 'resolved') return true\n if (state === 'open') return false\n throw new FileCommentOptionsError('Error: --state must be \"resolved\" or \"open\".')\n}\n\ntype DetailScalar = string | number | boolean | null\n\nfunction indentation(size: number): string {\n return ' '.repeat(size)\n}\n\n// Escape terminal control characters so untrusted comment content, author names, and\n// avatar URLs cannot inject ANSI/OSC sequences into the operator's terminal.\nfunction escapeTerminalControlCharacters(value: string): string {\n return value\n .replace(/\\r\\n/g, '\\n')\n .replace(/[\\u0000-\\u0008\\u000B-\\u001F\\u007F-\\u009F]/g, (character) =>\n `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n )\n}\n\nfunction formatDetailScalar(value: DetailScalar): string {\n if (value === null) return 'null'\n if (typeof value === 'string') {\n const escaped = escapeTerminalControlCharacters(value)\n if (escaped === '') return '\"\"'\n if (/\\n/.test(escaped)) return JSON.stringify(escaped)\n return escaped\n }\n return String(value)\n}\n\nfunction printDetailField(name: string, value: DetailScalar, indent = 0): void {\n print(`${indentation(indent)}${name}: ${formatDetailScalar(value)}`)\n}\n\nfunction printDetailTextField(name: string, value: string | null, indent = 0): void {\n if (value === null || value === '') {\n printDetailField(name, value, indent)\n return\n }\n const escaped = escapeTerminalControlCharacters(value)\n print(`${indentation(indent)}${name}:`)\n for (const line of escaped.split('\\n')) {\n print(`${indentation(indent + 2)}${line}`)\n }\n}\n\nfunction printAuthorFields(author: FileCommentAuthor, indent: number): void {\n printDetailField('humanId', author.humanId, indent)\n printDetailField('assistantId', author.assistantId, indent)\n printDetailField('teammateId', author.teammateId, indent)\n printDetailField('authorName', author.authorName, indent)\n printDetailField('authorAvatarUrl', author.authorAvatarUrl, indent)\n}\n\nfunction printCommentItem(item: FileCommentItem, indent = 0): void {\n print(`${indentation(indent)}${colors.bold}Comment${colors.reset}`)\n printDetailField('id', item.id, indent + 2)\n printDetailField('threadId', item.threadId, indent + 2)\n printAuthorFields(item, indent + 2)\n printDetailTextField('content', item.content, indent + 2)\n printDetailField('createdAt', item.createdAt, indent + 2)\n printDetailField('editedAt', item.editedAt, indent + 2)\n}\n\nfunction printThread(thread: FileCommentThread): void {\n print(`${colors.bold}Thread${colors.reset}`)\n printDetailField('threadId', thread.threadId, 2)\n printDetailField('fileId', thread.fileId, 2)\n printDetailTextField('quotedText', thread.quotedText, 2)\n printDetailField('resolvedAt', thread.resolvedAt, 2)\n print(`${indentation(2)}createdBy:`)\n printAuthorFields(thread.createdBy, 4)\n printDetailField('createdAt', thread.createdAt, 2)\n print(`${indentation(2)}comments:`)\n thread.items.forEach((item) => printCommentItem(item, 4))\n}\n\nfunction addFileSelectorOptions(cmd: Command): Command {\n return cmd\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n}\n\nexport function registerFileCommentCommands(file: Command): void {\n const comment = file.command('comment').description('File comment operations')\n\n addFileSelectorOptions(\n comment.command('list').description('List comment threads on a file'),\n ).action(async (options: FileCommentOptions) => {\n const target = await resolveFileTarget(options)\n\n startSpinner('Fetching comments...')\n const response = await httpGet<ListFileCommentsResponse>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comment-threads`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n if (response.data.items.length === 0) {\n stopSpinner(true, 'No comments found.')\n return\n }\n stopSpinner(true, `Found ${response.data.items.length} thread(s)`)\n response.data.items.forEach((thread, index) => {\n if (index > 0) print('')\n printThread(thread)\n })\n })\n\n addFileSelectorOptions(\n comment.command('update')\n .description('Update a comment you created')\n .argument('<commentId>')\n .requiredOption('--content-path <localPath>', 'Local UTF-8 text file for comment content'),\n ).action(async (commentId: string, options: FileCommentOptions & { contentPath: string }) => {\n // Validate the local content file before any network call so invalid input\n // never leaves the CLI (path-mode resolution below issues an HTTP request).\n const content = runOrExit(() => readCommentContentFile(options.contentPath))\n const target = await resolveFileTarget(options)\n\n startSpinner('Updating comment...')\n const response = await httpPatch<FileCommentItem>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comments/${commentId}`,\n { content },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n stopSpinner(true, 'Comment updated')\n printCommentItem(response.data)\n })\n\n addFileSelectorOptions(\n comment.command('resolve')\n .description('Resolve or reopen a comment thread')\n .argument('<threadId>')\n .requiredOption('--state <state>', 'Thread state: resolved or open'),\n ).action(async (threadId: string, options: FileCommentOptions & { state: string }) => {\n const resolved = runOrExit(() => parseResolveState(options.state))\n const target = await resolveFileTarget(options)\n\n startSpinner(resolved ? 'Resolving thread...' : 'Reopening thread...')\n const response = await httpPatch<unknown>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comment-threads/${threadId}/resolve`,\n { resolved },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n stopSpinner(true, resolved ? `Resolved: ${threadId}` : `Reopened: ${threadId}`)\n })\n}\n","/**\n * Pure logic for resolving file-command space selectors and building request URLs.\n *\n * These functions are extracted from commands/file.ts so they can be unit tested\n * without spawning the CLI or mocking process.exit. All error conditions are\n * surfaced as thrown Errors; action handlers are responsible for turning them\n * into user-facing output and exit codes.\n */\n\nexport interface SpaceOptions {\n workspace: string\n space?: string\n personal?: boolean\n teamSpaceId?: string\n teammateId?: string\n}\n\nexport interface SpaceParams {\n space?: string\n teamSpaceId?: string\n agentId?: number\n}\n\n/**\n * Error thrown when selector options violate a contract (mutually exclusive,\n * wrong format, etc). Action handlers catch this and print the message before\n * exiting with code 1.\n */\nexport class SpaceOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SpaceOptionsError'\n }\n}\n\n/**\n * Resolve mutually-exclusive space selector flags into normalized request params.\n *\n * Priority (only one must be set): --team-space-id > --teammate-id > --personal > -s <name>.\n * When none is set, returns empty params (server treats this as personal space).\n */\nexport function resolveSpaceSelector(options: SpaceOptions): SpaceParams {\n // Destructure first so TypeScript's control-flow analysis can narrow each\n // field through the subsequent non-null / non-empty checks without having\n // to re-read options.* at the point of use (which would lose narrowing).\n const { space, teamSpaceId, teammateId } = options\n const personalIsSet = options.personal === true\n\n // Count \"user-set\" selectors explicitly so the mutual-exclusion check\n // reflects intent (\"which flags did the user pass?\") rather than a\n // generic truthiness filter. This keeps the mutual-exclusion check\n // cleanly separated from the downstream format validation (e.g.\n // `parsed <= 0` for teammateId).\n const spaceIsSet = space != null && space !== ''\n const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== ''\n const teammateIdIsSet = teammateId != null && teammateId !== ''\n const selectorCount =\n (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0)\n if (selectorCount > 1) {\n throw new SpaceOptionsError(\n 'Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive.',\n )\n }\n\n // Dispatch via the underlying field checks (not `*IsSet`) so TypeScript\n // narrows each local to `string`, letting us return without `!`.\n if (teamSpaceId != null && teamSpaceId !== '') {\n return { teamSpaceId }\n }\n if (teammateId != null && teammateId !== '') {\n const parsed = Number.parseInt(teammateId, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {\n throw new SpaceOptionsError(\n `Error: --teammate-id must be a positive integer, got \"${teammateId}\".`,\n )\n }\n return { agentId: parsed }\n }\n if (personalIsSet) {\n return { space: 'personal' }\n }\n if (space != null && space !== '') {\n return { space }\n }\n return {}\n}\n\n/**\n * Build the `?path=...&space=...` query string for file endpoints.\n * Returns empty string when no params are set (caller should not append `?`).\n * Values are URL-encoded via URLSearchParams.\n *\n * An empty-string `path` is treated as \"not provided\" and omitted from the query;\n * callers should pass `undefined` rather than `\"\"` when no path is intended.\n */\nexport function buildFileQueryString(path: string | undefined, spaceParams: SpaceParams): string {\n const params = new URLSearchParams()\n if (path != null && path !== '') {\n params.set('path', path)\n }\n if (spaceParams.space) {\n params.set('space', spaceParams.space)\n }\n if (spaceParams.teamSpaceId) {\n params.set('teamSpaceId', spaceParams.teamSpaceId)\n }\n if (spaceParams.agentId != null) {\n params.set('agentId', String(spaceParams.agentId))\n }\n const qs = params.toString()\n return qs ? `?${qs}` : ''\n}\n\n/**\n * Detect if a Buffer contains binary content by sampling the first 8192 bytes.\n * Control characters other than tab (9), LF (10), and CR (13) are treated as binary.\n */\nexport function isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Validate `file read` command's top-level mutually-exclusive options (-u vs -w/-p).\n * Returns the resolved mode ('by-url' or 'by-path'). Throws SpaceOptionsError on conflict.\n *\n * Empty strings are treated as \"not provided\" (commander never passes empty strings\n * for optional flags, but callers outside the CLI context should pass undefined instead\n * of \"\" to avoid unexpected branch behaviour).\n */\nexport type ReadMode = { kind: 'by-url'; url: string } | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveReadMode(options: {\n url?: string\n workspace?: string\n path?: string\n}): ReadMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n // At this point both workspace and path are guaranteed non-empty by the guards\n // above. Use explicit checks so TypeScript narrows the types without needing `!`.\n if (!options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n return { kind: 'by-path', workspace: options.workspace, path: options.path }\n}\n\n/**\n * Validate `file put` command's top-level mutually-exclusive options (-u vs -w/-p).\n *\n * By-URL puts overwrite an existing file (the URL already identifies it), so\n * `--recursive` is meaningless in that mode and is rejected outright to keep the\n * user's intent unambiguous.\n */\nexport type WriteMode =\n | { kind: 'by-url'; url: string }\n | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveWriteMode(options: {\n url?: string\n workspace?: string\n path?: string\n recursive?: boolean\n}): WriteMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (options.url && options.recursive) {\n throw new SpaceOptionsError('Error: --recursive cannot be used with --url (the file must already exist)')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n return { kind: 'by-path', workspace: options.workspace!, path: options.path! }\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nexport interface RawApiResponse {\n ok: boolean\n status: number\n text: string\n contentType: string | null\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function fetchApi(method: string, path: string, body?: unknown): Promise<Response> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return response\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const response = await fetchApi(method, path, body)\n const contentType = response.headers.get('content-type')\n const data = contentType?.includes('application/json') ? ((await response.json()) as T) : ((await response.text()) as T)\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpPatch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PATCH', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body?: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n\nexport async function httpRaw(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, body?: unknown): Promise<RawApiResponse> {\n const response = await fetchApi(method, path, body)\n return {\n ok: response.ok,\n status: response.status,\n text: await response.text(),\n contentType: response.headers.get('content-type'),\n }\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n\nexport function getApiKeyOrUndefined(): string | undefined {\n return process.env.MOXT_API_KEY\n}\n","// ANSI colors\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n cyan: '\\x1b[36m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","export class SearchOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SearchOptionsError'\n }\n}\n\nexport function parseSearchLimit(raw: string | undefined, defaultValue: number, max: number): number {\n if (raw == null || raw === '') {\n return defaultValue\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --limit must be a positive integer, got \"${raw}\".`)\n }\n if (parsed > max) {\n throw new SearchOptionsError(`Error: --limit must be less than or equal to ${max}.`)\n }\n return parsed\n}\n\nexport function parseSearchMode(raw: string | undefined): 'all' | 'any' {\n if (raw == null || raw === '') {\n return 'any'\n }\n if (raw === 'all' || raw === 'any') {\n return raw\n }\n throw new SearchOptionsError(`Error: --mode must be \"any\" or \"all\", got \"${raw}\".`)\n}\n\nexport function parseTeammateId(raw: string | undefined): number | undefined {\n if (raw == null || raw === '') {\n return undefined\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --teammate-id must be a positive integer, got \"${raw}\".`)\n }\n return parsed\n}\n","import { SpaceOptionsError } from './file-selector.js'\nimport { printError } from './output.js'\nimport { SearchOptionsError } from './search-options.js'\n\n/**\n * Call a pure resolver that may throw a known CLI option error; on error,\n * print the message and exit(1). This keeps the user-facing contract\n * (stderr + exit code 1) consistent across subcommands while letting the\n * resolvers stay pure and unit-testable.\n */\nexport function runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n","import { Command } from 'commander'\nimport { httpPost } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseTeammateId } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface MemorySearchItem {\n rank: number\n pipelineId: string\n chunkId: string\n chunkIndex: number\n content: string\n contentTruncated: boolean\n}\n\ninterface MemorySearchResponse {\n items: MemorySearchItem[]\n}\n\nexport function registerMemoryCommand(program: Command): void {\n const memory = program.command('memory').description('Memory operations')\n\n memory.command('search')\n .description('Search archived agent memory')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('--teammate-id <teammateId>', 'Search a managed AI teammate memory')\n .option('-l, --limit <limit>', 'Maximum number of memory chunks to return', '5')\n .argument('<query>', 'Search query')\n .action(\n async (\n query: string,\n options: {\n workspace: string\n teammateId?: string\n limit?: string\n },\n ) => {\n const limit = runOrExit(() => parseSearchLimit(options.limit, 5, 10))\n const teammateId = runOrExit(() => parseTeammateId(options.teammateId))\n\n startSpinner('Searching memory...')\n const response = await httpPost<MemorySearchResponse>(\n `/workspaces/${options.workspace}/memory/search`,\n {\n query,\n limit,\n ...(teammateId !== undefined ? { agentId: teammateId } : {}),\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No memory found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} memory chunk(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. pipeline=${item.pipelineId} chunk=${item.chunkIndex}${colors.reset}`)\n print(`${colors.dim}chunkId=${item.chunkId}${item.contentTruncated ? ' truncated=true' : ''}${colors.reset}`)\n print(item.content)\n print('')\n }\n },\n )\n}\n","export class MiniappDbOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MiniappDbOptionsError'\n }\n}\n\nconst NON_FILTER_QUERY_PARAMS = new Set([\n 'select',\n 'order',\n 'limit',\n 'offset',\n 'range',\n 'range-unit',\n])\n\nconst ALLOWED_MINIAPP_DB_EMAIL_DOMAINS = ['@paraflow.com', '@moxt.ai', '@kanyun.com']\n\nexport function normalizePostgrestPath(path: string): string {\n const trimmed = path.trim()\n if (!trimmed) {\n throw new MiniappDbOptionsError('Error: PostgREST path is required.')\n }\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`\n}\n\nexport function buildMiniappDbDataPath(workspaceId: string, appId: string, postgrestPath: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/data${normalizePostgrestPath(postgrestPath)}`\n}\n\nexport function buildMiniappDbSchemaPath(workspaceId: string, appId: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/schema`\n}\n\nexport function parseJsonBody(raw: string): unknown {\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error)\n throw new MiniappDbOptionsError(`Error: --body must be valid JSON. ${detail}`)\n }\n\n if (parsed === null || (typeof parsed !== 'object' && !Array.isArray(parsed))) {\n throw new MiniappDbOptionsError('Error: --body must be a JSON object or array.')\n }\n return parsed\n}\n\nexport function hasPostgrestFilter(postgrestPath: string): boolean {\n const normalizedPath = normalizePostgrestPath(postgrestPath)\n const parsed = new URL(normalizedPath, 'https://postgrest.local')\n for (const [name] of parsed.searchParams.entries()) {\n if (!NON_FILTER_QUERY_PARAMS.has(name.toLowerCase())) {\n return true\n }\n }\n return false\n}\n\nexport function assertPostgrestFilter(postgrestPath: string, method: 'PATCH' | 'DELETE'): void {\n if (!hasPostgrestFilter(postgrestPath)) {\n throw new MiniappDbOptionsError(\n `Error: ${method.toLowerCase()} requires at least one PostgREST filter query parameter.`,\n )\n }\n}\n\nexport function formatRawResponse(text: string, pretty?: boolean): string {\n if (!pretty || !text) {\n return text\n }\n try {\n return JSON.stringify(JSON.parse(text), null, 2)\n } catch {\n return text\n }\n}\n\nexport function isAllowedMiniappDbUserEmail(email: string): boolean {\n const normalized = email.trim().toLowerCase()\n return ALLOWED_MINIAPP_DB_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain))\n}\n","import { Command } from 'commander'\nimport {\n assertPostgrestFilter,\n buildMiniappDbDataPath,\n buildMiniappDbSchemaPath,\n formatRawResponse,\n isAllowedMiniappDbUserEmail,\n MiniappDbOptionsError,\n parseJsonBody,\n} from '../utils/miniapp-db.js'\nimport { httpGet, httpRaw } from '../utils/http.js'\nimport { print, printError } from '../utils/output.js'\n\ninterface MiniappDbOptions {\n workspace: string\n appId: string\n pretty?: boolean\n body?: string\n yes?: boolean\n}\n\ninterface MiniappDbSchemaResponse {\n sql: string\n}\n\ninterface WhoamiResponse {\n email: string\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof MiniappDbOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\nfunction addMiniappDbTargetOptions(command: Command): Command {\n return command\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .requiredOption('--app-id <appId>', 'Miniapp app ID')\n}\n\nfunction handleRawResponse(response: Awaited<ReturnType<typeof httpRaw>>, pretty?: boolean): void {\n if (!response.ok) {\n printError(`Error [${response.status}]: ${response.text}`)\n process.exit(1)\n }\n print(formatRawResponse(response.text, pretty))\n}\n\nasync function ensureAllowedMiniappDbUser(): Promise<void> {\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n if (!isAllowedMiniappDbUserEmail(response.data.email)) {\n printError('Error: miniapp db commands are only available to @paraflow.com, @moxt.ai, or @kanyun.com users.')\n process.exit(1)\n }\n}\n\nasync function requestDataApi(\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE',\n postgrestPath: string,\n options: MiniappDbOptions,\n body?: unknown,\n): Promise<void> {\n await ensureAllowedMiniappDbUser()\n const path = buildMiniappDbDataPath(options.workspace, options.appId, postgrestPath)\n const response = await httpRaw(method, path, body)\n handleRawResponse(response, options.pretty)\n}\n\nexport function registerMiniappCommand(program: Command): void {\n const miniapp = program.command('miniapp', { hidden: true }).description('Miniapp operations')\n const db = miniapp.command('db').description('Miniapp database operations')\n\n addMiniappDbTargetOptions(\n db.command('schema').description('Print the miniapp database schema SQL'),\n ).action(async (options: MiniappDbOptions) => {\n await ensureAllowedMiniappDbUser()\n const response = await httpGet<MiniappDbSchemaResponse>(buildMiniappDbSchemaPath(options.workspace, options.appId))\n\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n print(response.data.sql)\n })\n\n addMiniappDbTargetOptions(\n db.command('get')\n .description('Read miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos?select=*')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n await requestDataApi('GET', postgrestPath, options)\n })\n\n addMiniappDbTargetOptions(\n db.command('post')\n .description('Create miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('POST', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('patch')\n .description('Update miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'PATCH'))\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('PATCH', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('delete')\n .description('Delete miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .option('--yes', 'Confirm the delete operation')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n if (options.yes !== true) {\n printError('Error: delete requires --yes.')\n process.exit(1)\n }\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'DELETE'))\n await requestDataApi('DELETE', postgrestPath, options)\n })\n}\n","import * as fs from 'node:fs'\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nexport interface TelemetryConfig {\n disabled?: boolean\n noticeShown?: boolean\n}\n\nfunction getConfigPath(): string {\n return path.join(os.homedir(), '.moxt', 'config.json')\n}\n\nexport function readTelemetryConfig(): TelemetryConfig {\n try {\n const raw = fs.readFileSync(getConfigPath(), 'utf8')\n const parsed = JSON.parse(raw) as { telemetry?: TelemetryConfig }\n return parsed.telemetry ?? {}\n } catch {\n return {}\n }\n}\n\nexport function writeTelemetryConfig(update: Partial<TelemetryConfig>): void {\n const configPath = getConfigPath()\n let existing: Record<string, unknown> = {}\n try {\n existing = JSON.parse(fs.readFileSync(configPath, 'utf8')) as Record<string, unknown>\n } catch {\n existing = {}\n }\n const currentTelemetry = (existing.telemetry as TelemetryConfig | undefined) ?? {}\n const next = { ...existing, telemetry: { ...currentTelemetry, ...update } }\n fs.mkdirSync(path.dirname(configPath), { recursive: true })\n fs.writeFileSync(configPath, JSON.stringify(next, null, 2))\n}\n","import { readTelemetryConfig } from './config.js'\n\nexport function isCiEnvironment(): boolean {\n return process.env.CI === 'true' || process.env.CI === '1'\n}\n\nexport function isTelemetryDisabled(): boolean {\n if (process.env.MOXT_TELEMETRY_DISABLED === '1' || process.env.MOXT_TELEMETRY_DISABLED === 'true') {\n return true\n }\n if (process.env.DO_NOT_TRACK === '1' || process.env.DO_NOT_TRACK === 'true') {\n return true\n }\n return readTelemetryConfig().disabled === true\n}\n","import { Command } from 'commander'\nimport { readTelemetryConfig, writeTelemetryConfig } from '../telemetry/config.js'\nimport { isTelemetryDisabled } from '../telemetry/opt-out.js'\nimport { print } from '../utils/output.js'\n\nexport function registerTelemetryCommand(program: Command): void {\n const telemetry = program.command('telemetry').description('Manage Moxt CLI telemetry')\n\n telemetry\n .command('status')\n .description('Show telemetry status')\n .action(() => {\n const cfg = readTelemetryConfig()\n const envOverride =\n process.env.MOXT_TELEMETRY_DISABLED === '1' ||\n process.env.MOXT_TELEMETRY_DISABLED === 'true' ||\n process.env.DO_NOT_TRACK === '1' ||\n process.env.DO_NOT_TRACK === 'true'\n\n const state = isTelemetryDisabled() ? 'disabled' : 'enabled'\n print(`telemetry: ${state}`)\n if (envOverride) {\n print('(disabled via environment variable)')\n } else if (cfg.disabled) {\n print('(disabled via config file)')\n }\n })\n\n telemetry\n .command('enable')\n .description('Enable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: false })\n print('telemetry: enabled')\n })\n\n telemetry\n .command('disable')\n .description('Disable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: true })\n print('telemetry: disabled')\n })\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpGet, httpDelete } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\ninterface MemberItem {\n userId: number\n email: string\n displayName: string | null\n role: string\n}\n\ninterface MembersResponse {\n members: MemberItem[]\n}\n\ninterface SpaceItem {\n type: 'personal' | 'team' | 'teammate'\n name: string\n teamSpaceId: string | null\n agentId: number | null\n}\n\n// Email regex (same as web/src/utils/email.ts)\nconst emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\nfunction isValidEmail(email: string): boolean {\n return emailRegex.test(email)\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n\n const members = program.command('members').description('Manage workspace members')\n\n members\n .command('list')\n .description('List all members in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching workspace members...')\n const response = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { members } = response.data\n if (members.length === 0) {\n stopSpinner(true, 'No members found.')\n return\n }\n\n stopSpinner(true, `Found ${members.length} member(s)`)\n\n for (const member of members) {\n const name = member.displayName || '-'\n print(`${colors.bold}${member.email}${colors.reset}\\t${name}\\t${member.role}`)\n }\n })\n\n members\n .command('remove')\n .description('Remove members from a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .argument('<emails>', 'Emails to remove (comma-separated)')\n .action(async (emailsArg: string, options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n const emails = emailsArg.split(',').map((e) => e.trim()).filter(Boolean)\n if (emails.length === 0) {\n printError('No valid emails provided')\n process.exit(1)\n }\n\n // Validate email format\n const invalidEmails = emails.filter((e) => !isValidEmail(e))\n if (invalidEmails.length > 0) {\n for (const email of invalidEmails) {\n printError(`Invalid email format: ${email}`)\n }\n process.exit(1)\n }\n\n // Fetch members to get userId by email\n startSpinner('Fetching workspace members...')\n const membersResponse = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!membersResponse.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Members fetched')\n\n const { members } = membersResponse.data\n const emailToMember = new Map(members.map((m) => [m.email.toLowerCase(), m]))\n\n // Remove each member\n for (const email of emails) {\n const member = emailToMember.get(email.toLowerCase())\n if (!member) {\n print(`${colors.red}✗${colors.reset} ${email} - not found in workspace`)\n continue\n }\n\n const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`)\n\n if (deleteResponse.ok) {\n print(`${colors.green}✓${colors.reset} ${email} - removed`)\n } else {\n print(`${colors.red}✗${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`)\n }\n }\n })\n\n const space = program.command('space').description('Manage spaces')\n\n space\n .command('list')\n .description('List accessible spaces in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching spaces...')\n const response = await httpGet<{ spaces: SpaceItem[] }>(`/workspaces/${workspaceId}/spaces`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch spaces')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { spaces } = response.data\n if (spaces.length === 0) {\n stopSpinner(true, 'No spaces found.')\n return\n }\n\n stopSpinner(true, `Found ${spaces.length} space(s)`)\n\n print(\n `${colors.bold}TYPE${colors.reset}\\t${colors.bold}TEAM_SPACE_ID${colors.reset}\\t${colors.bold}TEAMMATE_ID${colors.reset}\\t${colors.bold}NAME${colors.reset}`,\n )\n for (const s of spaces) {\n const teamSpaceId = s.teamSpaceId ?? ''\n const teammateId = s.agentId != null ? String(s.agentId) : ''\n print(`${s.type}\\t${teamSpaceId}\\t${teammateId}\\t${s.name}`)\n }\n })\n\n}\n","import * as fs from 'node:fs'\nimport { TextDecoder } from 'node:util'\nimport { Command } from 'commander'\nimport {\n isBinaryContent,\n resolveSpaceSelector,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPatch, httpPost } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { parseSearchLimit, SearchOptionsError } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\nconst MAX_DESC_LENGTH = 5000\nconst MAX_COMMENT_CONTENT_LENGTH = 5000\nconst MAX_COMMENT_CONTENT_BYTES = MAX_COMMENT_CONTENT_LENGTH * 4\n\ntype WorkflowStatusTypeValue = 1 | 2 | 3\ntype WorkflowTaskPriorityValue = 0 | 1 | 2 | 3\n\ninterface WorkflowItem {\n fileId: string\n ownerHumanId: number | null\n desc: string | null\n}\n\ninterface WorkflowListResponse {\n workflows: WorkflowItem[]\n}\n\ninterface WorkflowDetailResponse extends WorkflowItem {\n statusList: WorkflowStatusItem[]\n transitions: WorkflowTransitionItem[]\n}\n\ninterface WorkflowStatusItem {\n scopedId: number\n name: string\n desc: string | null\n type: WorkflowStatusTypeValue\n preferredAssignee: AssigneeInfo | null\n order: number\n}\n\ninterface WorkflowTransitionItem {\n statusFromScopedId: number\n statusToScopedId: number\n}\n\ninterface WorkflowTaskItem {\n scopedId: number\n workflowFileId: string\n ownerHumanId: number | null\n title: string\n desc: string | null\n statusScopedId: number\n priority: WorkflowTaskPriorityValue\n assignee: AssigneeInfo | null\n linkedFileIds: string[]\n subscribed: boolean\n runningAgentRuns: Array<{\n pipelineId: string\n executor: AssigneeInfo | null\n }>\n createdAt: string\n latestActAt: string\n}\n\ninterface WorkflowTaskListResponse {\n tasks: WorkflowTaskItem[]\n nextCursor: string | null\n}\n\ninterface WorkflowTaskCreateResponse {\n taskScopedId: number\n}\n\ninterface WorkflowPipelineStatusItem {\n workflowPipelineTriggerId: number\n pipelineStatus: string\n}\n\ninterface WorkflowCommentItem {\n id: number\n workflowFileId: string\n workflowTaskScopedId: number\n content: string\n createdBy: AssigneeInfo | null\n createdAt: string\n updatedAt: string\n}\n\ninterface WorkflowCommentListResponse {\n items: WorkflowCommentItem[]\n}\n\ntype AssigneeInfo =\n | { type: 'human'; humanId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'assistant'; aiAssistantId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'teammate'; aiTeammateId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'unknown'; humanId: number | null; aiAssistantId: number | null; aiTeammateId: number | null }\n\ninterface WorkflowSpaceOptions extends SpaceOptions {\n path: string\n descFile?: string\n ownerHumanId?: string\n}\n\ninterface AssigneeOptions {\n humanId?: string\n assistantId?: string\n teammateId?: string\n clear?: boolean\n}\n\ninterface PreferredAssigneeOptions {\n preferredHumanId?: string\n preferredAssistantId?: string\n preferredTeammateId?: string\n clearPreferredAssignee?: boolean\n}\n\nclass WorkflowOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'WorkflowOptionsError'\n }\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof WorkflowOptionsError || err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\nfunction addWorkspaceOption(command: Command): Command {\n return command.requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n}\n\nfunction addSpaceOptions(command: Command): Command {\n return addWorkspaceOption(command)\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nfunction addAssigneeOptions(command: Command): Command {\n return command\n .option('--human-id <humanId>', 'Human assignee ID')\n .option('--assistant-id <assistantId>', 'AI assistant assignee ID')\n .option('--teammate-id <teammateId>', 'AI teammate assignee ID')\n}\n\nfunction addPreferredAssigneeOptions(command: Command): Command {\n return command\n .option('--preferred-human-id <humanId>', 'Preferred human assignee ID')\n .option('--preferred-assistant-id <assistantId>', 'Preferred AI assistant assignee ID')\n .option('--preferred-teammate-id <teammateId>', 'Preferred AI teammate assignee ID')\n}\n\nfunction parsePositiveInteger(raw: string, label: string): number {\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new WorkflowOptionsError(`Error: ${label} must be a positive integer, got \"${raw}\".`)\n }\n return parsed\n}\n\nfunction parseOptionalPositiveInteger(raw: string | undefined, label: string): number | undefined {\n if (raw == null || raw === '') return undefined\n return parsePositiveInteger(raw, label)\n}\n\nfunction parseStatusType(raw: string | undefined): WorkflowStatusTypeValue | undefined {\n if (raw == null || raw === '') return undefined\n const parsed = Number.parseInt(raw, 10)\n if ((parsed === 1 || parsed === 2 || parsed === 3) && String(parsed) === raw) return parsed\n throw new WorkflowOptionsError('Error: --type must be one of 1 (todo), 2 (in-progress), or 3 (done).')\n}\n\nfunction parseRequiredStatusType(raw: string | undefined): WorkflowStatusTypeValue {\n const value = parseStatusType(raw)\n if (value === undefined) {\n throw new WorkflowOptionsError('Error: --type is required.')\n }\n return value\n}\n\nfunction parsePriority(raw: string | undefined): WorkflowTaskPriorityValue | undefined {\n if (raw == null || raw === '') return undefined\n if (raw === 'urgent') return 0\n if (raw === 'high') return 1\n if (raw === 'medium') return 2\n if (raw === 'low') return 3\n throw new WorkflowOptionsError('Error: --priority must be \"urgent\", \"high\", \"medium\", or \"low\".')\n}\n\nfunction parseRequiredPriority(raw: string | undefined): WorkflowTaskPriorityValue {\n return parsePriority(raw ?? 'medium') ?? 2\n}\n\nfunction parseWorkflowScope(raw: string | undefined): 'all' | 'owner_is_me' {\n if (raw == null || raw === '') return 'all'\n if (raw === 'all' || raw === 'owner_is_me') return raw\n throw new WorkflowOptionsError('Error: --scope must be \"all\" or \"owner_is_me\".')\n}\n\nfunction parseTaskScope(raw: string | undefined): 'all' | 'assigned_to_me' | 'subscribed_by_me' | 'owner_is_me' {\n if (raw == null || raw === '') return 'all'\n if (raw === 'all' || raw === 'assigned_to_me' || raw === 'subscribed_by_me' || raw === 'owner_is_me') {\n return raw\n }\n throw new WorkflowOptionsError(\n 'Error: --scope must be \"all\", \"assigned_to_me\", \"subscribed_by_me\", or \"owner_is_me\".',\n )\n}\n\nfunction parseFileIds(raw: string | undefined, label = '--file-ids'): string[] | undefined {\n if (raw == null || raw === '') return undefined\n const ids = raw.split(',').map((item) => item.trim()).filter(Boolean)\n if (ids.length === 0) {\n throw new WorkflowOptionsError(`Error: ${label} must include at least one file ID.`)\n }\n return ids\n}\n\nfunction readDescFile(path: string | undefined): string | undefined {\n if (path == null || path === '') return undefined\n if (!fs.existsSync(path)) {\n throw new WorkflowOptionsError(`Error: desc file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new WorkflowOptionsError(`Error: desc file is not a file: ${path}`)\n }\n const buffer = fs.readFileSync(path)\n if (isBinaryContent(buffer)) {\n throw new WorkflowOptionsError('Error: desc file must be UTF-8 text, not binary content.')\n }\n const content = buffer.toString('utf8')\n if (content.length > MAX_DESC_LENGTH) {\n throw new WorkflowOptionsError(`Error: desc file must be at most ${MAX_DESC_LENGTH} characters.`)\n }\n return content\n}\n\nfunction readCommentContentFile(path: string): string {\n if (!fs.existsSync(path)) {\n throw new WorkflowOptionsError(`Error: comment content file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new WorkflowOptionsError(`Error: comment content path is not a file: ${path}`)\n }\n if (stat.size > MAX_COMMENT_CONTENT_BYTES) {\n throw new WorkflowOptionsError(\n `Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`,\n )\n }\n const buffer = fs.readFileSync(path)\n if (buffer.includes(0)) {\n throw new WorkflowOptionsError('Error: comment content file must not contain NUL bytes.')\n }\n if (isBinaryContent(buffer)) {\n throw new WorkflowOptionsError('Error: comment content file must be UTF-8 text, not binary content.')\n }\n let content: string\n try {\n content = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer)\n } catch {\n throw new WorkflowOptionsError('Error: comment content file must contain valid UTF-8 text.')\n }\n if (content.length === 0) {\n throw new WorkflowOptionsError('Error: comment content file must not be empty.')\n }\n if (content.length > MAX_COMMENT_CONTENT_LENGTH) {\n throw new WorkflowOptionsError(\n `Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`,\n )\n }\n return content\n}\n\nfunction parseAssigneeBody(options: AssigneeOptions, allowClear: boolean): Record<string, number | null> {\n const hasClear = options.clear === true\n const humanId = parseOptionalPositiveInteger(options.humanId, '--human-id')\n const assistantId = parseOptionalPositiveInteger(options.assistantId, '--assistant-id')\n const teammateId = parseOptionalPositiveInteger(options.teammateId, '--teammate-id')\n const count =\n (humanId !== undefined ? 1 : 0) + (assistantId !== undefined ? 1 : 0) + (teammateId !== undefined ? 1 : 0)\n if (hasClear && !allowClear) {\n throw new WorkflowOptionsError('Error: --clear is not supported here.')\n }\n if (hasClear && count > 0) {\n throw new WorkflowOptionsError('Error: --clear cannot be used with assignee ID options.')\n }\n if (count > 1) {\n throw new WorkflowOptionsError('Error: assignee ID options are mutually exclusive.')\n }\n if (hasClear) return {}\n if (humanId !== undefined) return { assigneeHumanId: humanId }\n if (assistantId !== undefined) return { assigneeAiAssistantId: assistantId }\n if (teammateId !== undefined) return { assigneeAiTeammateId: teammateId }\n return {}\n}\n\nfunction parsePreferredAssigneeBody(options: PreferredAssigneeOptions): Record<string, number | null> {\n const hasClear = options.clearPreferredAssignee === true\n const humanId = parseOptionalPositiveInteger(options.preferredHumanId, '--preferred-human-id')\n const assistantId = parseOptionalPositiveInteger(options.preferredAssistantId, '--preferred-assistant-id')\n const teammateId = parseOptionalPositiveInteger(options.preferredTeammateId, '--preferred-teammate-id')\n const count =\n (humanId !== undefined ? 1 : 0) + (assistantId !== undefined ? 1 : 0) + (teammateId !== undefined ? 1 : 0)\n if (hasClear && count > 0) {\n throw new WorkflowOptionsError('Error: --clear-preferred-assignee cannot be used with preferred assignee ID options.')\n }\n if (count > 1) {\n throw new WorkflowOptionsError('Error: preferred assignee ID options are mutually exclusive.')\n }\n if (hasClear) return { preferredAssigneeHumanId: null }\n if (humanId !== undefined) return { preferredAssigneeHumanId: humanId }\n if (assistantId !== undefined) return { preferredAssigneeAiAssistantId: assistantId }\n if (teammateId !== undefined) return { preferredAssigneeAiTeammateId: teammateId }\n return {}\n}\n\nfunction assertNonEmptyBody(body: Record<string, unknown>): void {\n if (Object.keys(body).length === 0) {\n throw new WorkflowOptionsError('Error: at least one update option must be provided.')\n }\n}\n\nfunction buildQuery(params: Record<string, string | number | undefined>): string {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n query.set(key, String(value))\n }\n }\n const text = query.toString()\n return text ? `?${text}` : ''\n}\n\nfunction failResponse(response: { status: number; data: unknown }): never {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n}\n\nfunction priorityLabel(value: WorkflowTaskPriorityValue): string {\n switch (value) {\n case 0: return 'urgent'\n case 1: return 'high'\n case 2: return 'medium'\n case 3: return 'low'\n default: {\n const unsupportedValue: never = value\n throw new Error(`Unsupported workflow task priority: ${String(unsupportedValue)}`)\n }\n }\n}\n\nfunction statusTypeLabel(value: WorkflowStatusTypeValue): string {\n switch (value) {\n case 1: return 'todo'\n case 2: return 'in-progress'\n case 3: return 'done'\n default: {\n const unsupportedValue: never = value\n throw new Error(`Unsupported workflow status type: ${String(unsupportedValue)}`)\n }\n }\n}\n\nfunction formatAssignee(assignee: AssigneeInfo | null): string {\n if (!assignee) return '-'\n if (assignee.type === 'human') return assignee.displayName ?? `human:${assignee.humanId}`\n if (assignee.type === 'assistant') return assignee.displayName ?? `assistant:${assignee.aiAssistantId}`\n if (assignee.type === 'teammate') return assignee.displayName ?? `teammate:${assignee.aiTeammateId}`\n return 'unknown'\n}\n\nfunction printWorkflow(item: WorkflowItem): void {\n print(`${colors.bold}${item.fileId}${colors.reset}\\towner=${item.ownerHumanId ?? '-'}\\tdesc=${item.desc ?? '-'}`)\n}\n\ntype DetailScalar = string | number | boolean | null\n\nfunction indentation(size: number): string {\n return ' '.repeat(size)\n}\n\nfunction escapeTerminalControlCharacters(value: string): string {\n return value\n .replace(/\\r\\n/g, '\\n')\n .replace(/[\\u0000-\\u0008\\u000B-\\u001F\\u007F-\\u009F]/g, (character) =>\n `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n )\n}\n\nfunction formatDetailScalar(value: DetailScalar): string {\n if (value === null) return 'null'\n if (typeof value === 'string') {\n const escaped = escapeTerminalControlCharacters(value)\n if (escaped === '') return '\"\"'\n if (/\\n/.test(escaped)) return JSON.stringify(escaped)\n return escaped\n }\n return String(value)\n}\n\nfunction printDetailField(name: string, value: DetailScalar, indent = 0): void {\n print(`${indentation(indent)}${name}: ${formatDetailScalar(value)}`)\n}\n\nfunction printDetailTextField(name: string, value: string | null, indent = 0): void {\n if (value === null || value === '') {\n printDetailField(name, value, indent)\n return\n }\n\n const escaped = escapeTerminalControlCharacters(value)\n print(`${indentation(indent)}${name}:`)\n for (const line of escaped.split('\\n')) {\n print(`${indentation(indent + 2)}${line}`)\n }\n}\n\nfunction printAssigneeDetail(name: string, assignee: AssigneeInfo | null, indent = 0): void {\n if (assignee === null) {\n printDetailField(name, null, indent)\n return\n }\n\n print(`${indentation(indent)}${name}:`)\n printDetailField('type', assignee.type, indent + 2)\n switch (assignee.type) {\n case 'human':\n printDetailField('humanId', assignee.humanId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'assistant':\n printDetailField('aiAssistantId', assignee.aiAssistantId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'teammate':\n printDetailField('aiTeammateId', assignee.aiTeammateId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'unknown':\n printDetailField('humanId', assignee.humanId, indent + 2)\n printDetailField('aiAssistantId', assignee.aiAssistantId, indent + 2)\n printDetailField('aiTeammateId', assignee.aiTeammateId, indent + 2)\n }\n}\n\nfunction printStatusRemainingFields(item: WorkflowStatusItem, indent: number): void {\n printDetailField('name', item.name, indent)\n printDetailTextField('desc', item.desc, indent)\n printDetailField('type', `${item.type} (${statusTypeLabel(item.type)})`, indent)\n printAssigneeDetail('preferredAssignee', item.preferredAssignee, indent)\n printDetailField('order', item.order, indent)\n}\n\nfunction printStatusDetail(item: WorkflowStatusItem): void {\n print(`${colors.bold}Status${colors.reset}`)\n printDetailField('scopedId', item.scopedId)\n printStatusRemainingFields(item, 0)\n}\n\nfunction printWorkflowDetail(item: WorkflowDetailResponse): void {\n print(`${colors.bold}Workflow${colors.reset}`)\n printDetailField('fileId', item.fileId)\n printDetailField('ownerHumanId', item.ownerHumanId)\n printDetailTextField('desc', item.desc)\n\n if (item.statusList.length === 0) {\n print('statusList: []')\n } else {\n print('statusList:')\n for (const status of item.statusList) {\n print(` - scopedId: ${status.scopedId}`)\n printStatusRemainingFields(status, 4)\n }\n }\n\n if (item.transitions.length === 0) {\n print('transitions: []')\n } else {\n print('transitions:')\n for (const transition of item.transitions) {\n print(` - statusFromScopedId: ${transition.statusFromScopedId}`)\n printDetailField('statusToScopedId', transition.statusToScopedId, 4)\n }\n }\n}\n\nfunction printTaskSummary(item: WorkflowTaskItem): void {\n const runIds = item.runningAgentRuns.map((run) => run.pipelineId).join(',') || '-'\n print(\n `${colors.bold}#${item.scopedId}${colors.reset}\\t${item.title}\\tstatus=${item.statusScopedId}\\tpriority=${priorityLabel(item.priority)}\\tassignee=${formatAssignee(item.assignee)}\\truns=${runIds}`,\n )\n}\n\nfunction printTaskDetail(item: WorkflowTaskItem): void {\n print(`${colors.bold}Task${colors.reset}`)\n printDetailField('scopedId', item.scopedId)\n printDetailField('workflowFileId', item.workflowFileId)\n printDetailField('ownerHumanId', item.ownerHumanId)\n printDetailField('title', item.title)\n printDetailTextField('desc', item.desc)\n printDetailField('statusScopedId', item.statusScopedId)\n printDetailField('priority', `${item.priority} (${priorityLabel(item.priority)})`)\n printAssigneeDetail('assignee', item.assignee)\n\n if (item.linkedFileIds.length === 0) {\n print('linkedFileIds: []')\n } else {\n print('linkedFileIds:')\n for (const fileId of item.linkedFileIds) print(` - ${fileId}`)\n }\n\n printDetailField('subscribed', item.subscribed)\n if (item.runningAgentRuns.length === 0) {\n print('runningAgentRuns: []')\n } else {\n print('runningAgentRuns:')\n for (const run of item.runningAgentRuns) {\n print(` - pipelineId: ${run.pipelineId}`)\n printAssigneeDetail('executor', run.executor, 4)\n }\n }\n printDetailField('createdAt', item.createdAt)\n printDetailField('latestActAt', item.latestActAt)\n}\n\nfunction printCommentDetail(item: WorkflowCommentItem): void {\n print(`${colors.bold}Comment${colors.reset}`)\n printDetailField('id', item.id)\n printDetailField('workflowFileId', item.workflowFileId)\n printDetailField('workflowTaskScopedId', item.workflowTaskScopedId)\n printDetailTextField('content', item.content)\n printAssigneeDetail('createdBy', item.createdBy)\n printDetailField('createdAt', item.createdAt)\n printDetailField('updatedAt', item.updatedAt)\n}\n\nexport function registerWorkflowCommand(program: Command): void {\n const workflow = program.command('workflow').description('Workflow operations')\n\n addWorkspaceOption(\n workflow.command('list')\n .description('List accessible workflows')\n .option('--scope <scope>', 'Workflow scope: all or owner_is_me', 'all'),\n ).action(async (options: { workspace: string; scope?: string }) => {\n const scope = runOrExit(() => parseWorkflowScope(options.scope))\n\n startSpinner('Fetching workflows...')\n const response = await httpGet<WorkflowListResponse>(\n `/workspaces/${options.workspace}/workflows${buildQuery({ scope })}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.workflows.length === 0) {\n stopSpinner(true, 'No workflows found.')\n return\n }\n stopSpinner(true, `Found ${response.data.workflows.length} workflow(s)`)\n for (const item of response.data.workflows) printWorkflow(item)\n })\n\n addSpaceOptions(\n workflow.command('create')\n .description('Create a blank workflow')\n .requiredOption('-p, --path <path>', 'Target .workflow path')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for workflow description')\n .option('--owner-human-id <humanId>', 'Workflow owner human ID'),\n ).action(async (options: WorkflowSpaceOptions) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n path: options.path,\n ...resolveSpaceSelector(options),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n return next\n })\n\n startSpinner('Creating workflow...')\n const response = await httpPost<WorkflowItem>(`/workspaces/${options.workspace}/workflows`, body)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow created')\n printWorkflow(response.data)\n })\n\n addWorkspaceOption(workflow.command('get').description('Get a workflow').argument('<workflowFileId>')).action(\n async (workflowFileId: string, options: { workspace: string }) => {\n startSpinner('Fetching workflow...')\n const response = await httpGet<WorkflowDetailResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow fetched')\n printWorkflowDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n workflow.command('update')\n .description('Update workflow metadata')\n .argument('<workflowFileId>')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for workflow description')\n .option('--owner-human-id <humanId>', 'Workflow owner human ID'),\n ).action(async (workflowFileId: string, options: { workspace: string; descFile?: string; ownerHumanId?: string }) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {}\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n assertNonEmptyBody(next)\n return next\n })\n\n startSpinner('Updating workflow...')\n const response = await httpPatch<WorkflowItem>(`/workspaces/${options.workspace}/workflows/${workflowFileId}`, body)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow updated')\n printWorkflow(response.data)\n })\n\n addWorkspaceOption(\n workflow.command('delete')\n .description('Delete a workflow')\n .argument('<workflowFileId>')\n .option('--message <message>', 'Commit message'),\n ).action(async (workflowFileId: string, options: { workspace: string; message?: string }) => {\n startSpinner('Deleting workflow...')\n const response = await httpDelete<{ fileId: string }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}`,\n options.message ? { message: options.message } : {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.fileId}`)\n })\n\n addWorkspaceOption(workflow.command('duplicate').description('Duplicate a workflow').argument('<workflowFileId>')).action(\n async (workflowFileId: string, options: { workspace: string }) => {\n startSpinner('Duplicating workflow...')\n const response = await httpPost<WorkflowItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/duplicate`,\n {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow duplicated')\n printWorkflow(response.data)\n },\n )\n\n registerStatusCommands(workflow)\n registerTransitionCommands(workflow)\n registerTaskCommands(workflow)\n registerCommentCommands(workflow)\n registerRunCommands(workflow)\n}\n\nfunction registerStatusCommands(workflow: Command): void {\n const status = workflow.command('status').description('Workflow status operations')\n\n addPreferredAssigneeOptions(\n addWorkspaceOption(\n status.command('create')\n .description('Create a workflow status')\n .argument('<workflowFileId>')\n .requiredOption('--name <name>', 'Status name')\n .requiredOption('--type <type>', 'Status type value: 1=todo, 2=in-progress, 3=done')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for status description'),\n ),\n ).action(\n async (\n workflowFileId: string,\n options: { workspace: string; name: string; type?: string; descFile?: string } & PreferredAssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n name: options.name,\n type: parseRequiredStatusType(options.type),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n Object.assign(next, parsePreferredAssigneeBody(options))\n return next\n })\n startSpinner('Creating status...')\n const response = await httpPost<WorkflowStatusItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status created')\n printStatusDetail(response.data)\n },\n )\n\n addPreferredAssigneeOptions(\n addWorkspaceOption(\n status.command('update')\n .description('Update a workflow status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>')\n .option('--name <name>', 'Status name')\n .option('--type <type>', 'Status type value: 1=todo, 2=in-progress, 3=done')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for status description')\n .option('--clear-desc', 'Clear status description')\n .option('--clear-preferred-assignee', 'Clear preferred assignee'),\n ),\n ).action(\n async (\n workflowFileId: string,\n statusScopedId: string,\n options: {\n workspace: string\n name?: string\n type?: string\n descFile?: string\n clearDesc?: boolean\n } & PreferredAssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n if (options.descFile && options.clearDesc) {\n throw new WorkflowOptionsError('Error: --desc-file cannot be used with --clear-desc.')\n }\n const next: Record<string, unknown> = {}\n if (options.name) next.name = options.name\n const type = parseStatusType(options.type)\n if (type !== undefined) next.type = type\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n if (options.clearDesc) next.desc = null\n Object.assign(next, parsePreferredAssigneeBody(options))\n assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(statusScopedId, 'statusScopedId'))\n startSpinner('Updating status...')\n const response = await httpPatch<WorkflowStatusItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status updated')\n printStatusDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n status.command('move-after')\n .description('Move a workflow status after another status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>')\n .option('--after <statusScopedId>', 'Anchor status scoped ID')\n .option('--first', 'Move to first position'),\n ).action(\n async (\n workflowFileId: string,\n statusScopedId: string,\n options: { workspace: string; after?: string; first?: boolean },\n ) => {\n const { id, anchoredStatusScopedId } = runOrExit(() => {\n if (options.after && options.first) {\n throw new WorkflowOptionsError('Error: --after cannot be used with --first.')\n }\n if (!options.after && !options.first) {\n throw new WorkflowOptionsError('Error: either --after or --first is required.')\n }\n return {\n id: parsePositiveInteger(statusScopedId, 'statusScopedId'),\n anchoredStatusScopedId: options.first ? null : parsePositiveInteger(options.after!, '--after'),\n }\n })\n startSpinner('Moving status...')\n const response = await httpPost<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}/move-after`,\n { anchoredStatusScopedId },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status moved')\n },\n )\n\n addWorkspaceOption(\n status.command('delete')\n .description('Delete a workflow status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>'),\n ).action(async (workflowFileId: string, statusScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(statusScopedId, 'statusScopedId'))\n startSpinner('Deleting status...')\n const response = await httpDelete<{ scopedId: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.scopedId}`)\n })\n}\n\nfunction registerTransitionCommands(workflow: Command): void {\n const transition = workflow.command('transition').description('Workflow transition operations')\n\n for (const action of ['create', 'delete'] as const) {\n addWorkspaceOption(\n transition.command(action)\n .description(`${action === 'create' ? 'Create' : 'Delete'} a workflow transition`)\n .argument('<workflowFileId>')\n .requiredOption('--from <statusScopedId>', 'Source status scoped ID')\n .requiredOption('--to <statusScopedId>', 'Target status scoped ID'),\n ).action(async (workflowFileId: string, options: { workspace: string; from: string; to: string }) => {\n const body = runOrExit(() => ({\n statusFromScopedId: parsePositiveInteger(options.from, '--from'),\n statusToScopedId: parsePositiveInteger(options.to, '--to'),\n }))\n startSpinner(`${action === 'create' ? 'Creating' : 'Deleting'} transition...`)\n const response =\n action === 'create'\n ? await httpPost<WorkflowTransitionItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/transitions`,\n body,\n )\n : await httpDelete<WorkflowTransitionItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/transitions`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, action === 'create' ? 'Transition created' : 'Transition deleted')\n print(`${response.data.statusFromScopedId} -> ${response.data.statusToScopedId}`)\n })\n }\n}\n\nfunction registerTaskCommands(workflow: Command): void {\n const task = workflow.command('task').description('Workflow task operations')\n\n addWorkspaceOption(\n task.command('list')\n .description('List workflow tasks')\n .option('--workflow-file-id <workflowFileId>', 'Filter by workflow file ID')\n .option('--scope <scope>', 'Task scope', 'all')\n .option('-l, --limit <limit>', 'Maximum number of tasks to return', '20')\n .option('--cursor <cursor>', 'Pagination cursor'),\n ).action(\n async (options: { workspace: string; workflowFileId?: string; scope?: string; limit?: string; cursor?: string }) => {\n const query = runOrExit(() => buildQuery({\n scope: parseTaskScope(options.scope),\n limit: parseSearchLimit(options.limit, 20, 100),\n cursor: options.cursor,\n workflowFileId: options.workflowFileId,\n }))\n startSpinner('Fetching workflow tasks...')\n const response = await httpGet<WorkflowTaskListResponse>(`/workspaces/${options.workspace}/workflow-tasks-v2${query}`)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.tasks.length === 0) {\n stopSpinner(true, 'No workflow tasks found.')\n return\n }\n stopSpinner(true, `Found ${response.data.tasks.length} task(s)`)\n for (const item of response.data.tasks) printTaskSummary(item)\n if (response.data.nextCursor) print(`${colors.dim}nextCursor=${response.data.nextCursor}${colors.reset}`)\n },\n )\n\n addWorkspaceOption(\n task.command('get')\n .description('Get a workflow task')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Fetching task...')\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task fetched')\n printTaskDetail(response.data)\n })\n\n addAssigneeOptions(\n addWorkspaceOption(\n task.command('create')\n .description('Create a workflow task')\n .argument('<workflowFileId>')\n .requiredOption('--title <title>', 'Task title')\n .requiredOption('--status <statusScopedId>', 'Status scoped ID')\n .option('--priority <priority>', 'Priority: urgent, high, medium, or low', 'medium')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for task description')\n .option('--owner-human-id <humanId>', 'Task owner human ID')\n ),\n ).action(\n async (\n workflowFileId: string,\n options: {\n workspace: string\n title: string\n status: string\n priority?: string\n descFile?: string\n ownerHumanId?: string\n } & AssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n title: options.title,\n statusScopedId: parsePositiveInteger(options.status, '--status'),\n priority: parseRequiredPriority(options.priority),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n Object.assign(next, parseAssigneeBody(options, false))\n return next\n })\n startSpinner('Creating task...')\n const createResponse = await httpPost<WorkflowTaskCreateResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2`,\n body,\n )\n if (!createResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(createResponse)\n }\n const response = await getWorkflowTask(\n options.workspace,\n workflowFileId,\n createResponse.data.taskScopedId,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task created')\n printTaskDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n task.command('update')\n .description('Update workflow task metadata')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .option('--title <title>', 'Task title')\n .option('--priority <priority>', 'Priority: urgent, high, medium, or low')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for task description')\n .option('--clear-desc', 'Clear task description')\n .option('--owner-human-id <humanId>', 'Task owner human ID')\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: {\n workspace: string\n title?: string\n priority?: string\n descFile?: string\n clearDesc?: boolean\n ownerHumanId?: string\n },\n ) => {\n const body = runOrExit(() => {\n if (options.descFile && options.clearDesc) {\n throw new WorkflowOptionsError('Error: --desc-file cannot be used with --clear-desc.')\n }\n const next: Record<string, unknown> = {}\n if (options.title) next.title = options.title\n const priority = parsePriority(options.priority)\n if (priority !== undefined) next.priority = priority\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n if (options.clearDesc) next.desc = null\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Updating task...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/metadata`,\n body,\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task updated')\n printTaskDetail(response.data)\n },\n )\n\n for (const action of ['add-linked-files', 'remove-linked-files'] as const) {\n addWorkspaceOption(\n task.command(action)\n .description(`${action === 'add-linked-files' ? 'Add' : 'Remove'} linked files on a workflow task`)\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--file-ids <ids>', 'Comma-separated file IDs'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: { workspace: string; fileIds: string },\n ) => {\n const { id, fileIds } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n fileIds: parseFileIds(options.fileIds, '--file-ids')!,\n }))\n startSpinner(action === 'add-linked-files' ? 'Adding linked files...' : 'Removing linked files...')\n const path = `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/linked-files`\n const updateResponse =\n action === 'add-linked-files'\n ? await httpPost<void>(path, { fileIds })\n : await httpDelete<void>(path, { fileIds })\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, action === 'add-linked-files' ? 'Linked files added' : 'Linked files removed')\n printTaskDetail(response.data)\n },\n )\n }\n\n addWorkspaceOption(\n task.command('move')\n .description('Move a workflow task to another status')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--status <statusScopedId>', 'Target status scoped ID'),\n ).action(\n async (workflowFileId: string, taskScopedId: string, options: { workspace: string; status: string }) => {\n const { id, statusScopedId } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n statusScopedId: parsePositiveInteger(options.status, '--status'),\n }))\n startSpinner('Moving task...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/status`,\n { statusScopedId },\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task moved')\n printTaskDetail(response.data)\n },\n )\n\n addAssigneeOptions(\n addWorkspaceOption(\n task.command('assign')\n .description('Update workflow task assignee')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .option('--clear', 'Clear assignee'),\n ),\n ).action(\n async (workflowFileId: string, taskScopedId: string, options: { workspace: string } & AssigneeOptions) => {\n const body = runOrExit(() => {\n const next = parseAssigneeBody(options, true)\n if (Object.keys(next).length === 0 && options.clear !== true) assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Updating task assignee...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/assignee`,\n body,\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task assignee updated')\n printTaskDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n task.command('delete')\n .description('Delete a workflow task')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Deleting task...')\n const response = await httpDelete<{ scopedId: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.scopedId}`)\n })\n}\n\nfunction getWorkflowTask(workspaceId: string, workflowFileId: string, taskScopedId: number) {\n return httpGet<WorkflowTaskItem>(\n `/workspaces/${workspaceId}/workflows/${workflowFileId}/tasks-v2/${taskScopedId}`,\n )\n}\n\nfunction registerCommentCommands(workflow: Command): void {\n const comment = workflow.command('comment').description('Workflow task comment operations')\n\n addWorkspaceOption(\n comment.command('create')\n .description('Create a workflow task comment')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--content-path <localPath>', 'Local UTF-8 text file for comment content'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: { workspace: string; contentPath: string },\n ) => {\n const { id, content } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n content: readCommentContentFile(options.contentPath),\n }))\n startSpinner('Creating comment...')\n const response = await httpPost<WorkflowCommentItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}/comments`,\n { content },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Comment created')\n printCommentDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n comment.command('list')\n .description('List workflow task comments')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Fetching comments...')\n const response = await httpGet<WorkflowCommentListResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}/comments`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.items.length === 0) {\n stopSpinner(true, 'No comments found.')\n return\n }\n stopSpinner(true, `Found ${response.data.items.length} comment(s)`)\n response.data.items.forEach((item, index) => {\n if (index > 0) print('')\n printCommentDetail(item)\n })\n })\n\n addWorkspaceOption(\n comment.command('delete')\n .description('Delete a workflow task comment')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .argument('<commentId>'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n commentId: string,\n options: { workspace: string },\n ) => {\n const ids = runOrExit(() => ({\n task: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n comment: parsePositiveInteger(commentId, 'commentId'),\n }))\n startSpinner('Deleting comment...')\n const response = await httpDelete<{ id: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${ids.task}/comments/${ids.comment}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.id}`)\n },\n )\n}\n\nfunction registerRunCommands(workflow: Command): void {\n const run = workflow.command('run').description('Workflow agent run operations')\n\n addWorkspaceOption(\n run.command('status')\n .description('Get workflow agent run statuses')\n .argument('<workflowFileId>')\n .argument('<triggerIds...>'),\n ).action(async (workflowFileId: string, triggerIds: string[], options: { workspace: string }) => {\n const workflowPipelineTriggerIds = runOrExit(() =>\n triggerIds.map((triggerId) => parsePositiveInteger(triggerId, 'workflowPipelineTriggerId')),\n )\n startSpinner('Fetching run statuses...')\n const response = await httpPost<WorkflowPipelineStatusItem[]>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline/triggers/statuses`,\n { workflowPipelineTriggerIds },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Found ${response.data.length} run status item(s)`)\n for (const item of response.data) {\n print(`${colors.bold}${item.workflowPipelineTriggerId}${colors.reset}\\t${item.pipelineStatus}`)\n }\n })\n\n addWorkspaceOption(\n run.command('abort')\n .description('Abort a workflow agent run')\n .argument('<workflowFileId>')\n .argument('<triggerId>'),\n ).action(async (workflowFileId: string, triggerId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(triggerId, 'workflowPipelineTriggerId'))\n startSpinner('Aborting run...')\n const response = await httpPost<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline/trigger/${id}/abort`,\n {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Abort accepted: ${id}`)\n })\n}\n","import { arch, platform } from 'node:os'\nimport { getApiBaseUrl, getApiKeyOrUndefined } from '../utils/config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport type MetricType = 'counter' | 'gauge' | 'histogram'\n\nexport interface MetricRecord {\n metric_id: string\n metric_type: MetricType\n value: number\n extra_label_name_2_value?: Record<string, string>\n}\n\nconst buffer: MetricRecord[] = []\nconst FLUSH_TIMEOUT_MS = 3000\nconst MAX_BATCH_SIZE = 100\n\nfunction commonLabels(): Record<string, string> {\n return {\n cli_version: __CLI_VERSION__,\n node_version: process.versions.node,\n os: platform(),\n arch: arch(),\n is_ci: isCiEnvironment() ? 'true' : 'false',\n }\n}\n\nexport function record(metric: MetricRecord): void {\n if (isTelemetryDisabled()) {\n debugLog(`record: disabled, dropping ${metric.metric_id}`)\n return\n }\n if (!getApiKeyOrUndefined()) {\n debugLog(`record: no API key, dropping ${metric.metric_id}`)\n return\n }\n buffer.push({\n ...metric,\n extra_label_name_2_value: {\n ...commonLabels(),\n ...(metric.extra_label_name_2_value ?? {}),\n },\n })\n debugLog(`record: buffered ${metric.metric_id} (buffer=${buffer.length})`)\n}\n\nfunction isDebug(): boolean {\n return process.env.MOXT_TELEMETRY_DEBUG === '1' || process.env.MOXT_TELEMETRY_DEBUG === 'true'\n}\n\nfunction debugLog(msg: string, detail?: unknown): void {\n if (!isDebug()) return\n process.stderr.write(`[telemetry] ${msg}${detail !== undefined ? ` ${JSON.stringify(detail)}` : ''}\\n`)\n}\n\nexport async function flush(): Promise<void> {\n if (buffer.length === 0) {\n debugLog('flush: buffer empty, skipping')\n return\n }\n const apiKey = getApiKeyOrUndefined()\n if (!apiKey) {\n debugLog('flush: no API key, dropping buffer')\n buffer.length = 0\n return\n }\n\n const batch = buffer.splice(0, MAX_BATCH_SIZE)\n const payload = {\n release_id: __CLI_VERSION__,\n client_type: 'cli',\n metric_data_list: batch.map((m) => ({\n profile: 'cli',\n metric_id: m.metric_id,\n metric_type: m.metric_type,\n value: m.value,\n extra_label_name_2_value: m.extra_label_name_2_value,\n })),\n }\n\n const url = `${getApiBaseUrl()}/cli-metrics`\n debugLog(`flush: POST ${url} with ${batch.length} metrics`, payload)\n\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => {\n controller.abort()\n }, FLUSH_TIMEOUT_MS)\n try {\n const res = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(payload),\n signal: controller.signal,\n })\n debugLog(`flush: response status=${res.status}`)\n } finally {\n clearTimeout(timeout)\n }\n } catch (err) {\n debugLog('flush: failed', err instanceof Error ? err.message : String(err))\n // fire-and-forget — never surface telemetry failures to the user\n }\n}\n","import { readTelemetryConfig, writeTelemetryConfig } from './config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\nconst NOTICE = [\n '',\n 'Attention: Moxt CLI now collects anonymous telemetry regarding usage.',\n \"This information is used to shape Moxt CLI's roadmap and prioritize features.\",\n '',\n 'You may opt out by setting MOXT_TELEMETRY_DISABLED=1 in your env',\n 'or by running `moxt telemetry disable`.',\n 'Details: https://www.npmjs.com/package/@moxt-ai/cli#telemetry',\n '',\n]\n\nexport function maybeShowTelemetryNotice(): void {\n if (isTelemetryDisabled()) return\n if (isCiEnvironment()) return\n if (readTelemetryConfig().noticeShown) return\n\n for (const line of NOTICE) {\n process.stderr.write(`${line}\\n`)\n }\n\n try {\n writeTelemetryConfig({ noticeShown: true })\n } catch {\n // persistence failure is not user-visible — we'll just show the notice again next run\n }\n}\n","import type { Command } from 'commander'\nimport { flush, record } from './client.js'\nimport { maybeShowTelemetryNotice } from './notice.js'\n\ninterface RunningCommand {\n name: string\n subcommand?: string\n startedAt: number\n}\n\nlet current: RunningCommand | null = null\n\nfunction commandPath(cmd: Command): { command: string; subcommand?: string } {\n const names: string[] = []\n let node: Command | null = cmd\n while (node && node.parent) {\n names.unshift(node.name())\n node = node.parent\n }\n if (names.length === 0) return { command: 'unknown' }\n if (names.length === 1) return { command: names[0] }\n return { command: names[0], subcommand: names.slice(1).join(' ') }\n}\n\nexport function instrumentProgram(program: Command): void {\n program.hook('preAction', (_thisCommand, actionCommand) => {\n const { command, subcommand } = commandPath(actionCommand)\n if (command !== 'telemetry') {\n maybeShowTelemetryNotice()\n }\n current = { name: command, subcommand, startedAt: Date.now() }\n record({\n metric_id: 'client.cli.command_invocation.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command,\n ...(subcommand ? { subcommand } : {}),\n status: 'started',\n },\n })\n })\n\n program.hook('postAction', async () => {\n await reportOutcome('success')\n })\n}\n\nasync function reportOutcome(status: 'success' | 'error', errorCode?: string): Promise<void> {\n if (!current) return\n const { name, subcommand, startedAt } = current\n const durationSeconds = (Date.now() - startedAt) / 1000\n\n record({\n metric_id: 'client.cli.command_duration_seconds',\n metric_type: 'histogram',\n value: durationSeconds,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n status,\n },\n })\n\n if (status === 'error') {\n record({\n metric_id: 'client.cli.command_error.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n ...(errorCode ? { error_code: errorCode } : {}),\n },\n })\n }\n\n current = null\n await flush()\n}\n\n/**\n * Wire a final error/exit hook. Call before program.parseAsync so we can capture\n * failures routed through process.exit or unhandled rejections.\n *\n * Best-effort only: `reportOutcome` is fire-and-forget, and the subsequent\n * `process.exit(1)` terminates the process before `flush()` can complete — so\n * the error metric recorded here will typically be dropped. Reliable crash\n * reporting belongs to Sentry/APM, not this telemetry path.\n */\nexport function installExitHandler(): void {\n const handleError = (errorCode: string): void => {\n void reportOutcome('error', errorCode)\n }\n\n process.on('uncaughtException', () => {\n handleError('uncaught_exception')\n process.exit(1)\n })\n process.on('unhandledRejection', () => {\n handleError('unhandled_rejection')\n process.exit(1)\n })\n}\n"],"mappings":";;;AAAA,OAAO,oBAAoB;;;ACA3B,SAAS,eAAe;;;ACAxB,YAAYA,SAAQ;;;ACApB,YAAY,QAAQ;AACpB,SAAS,mBAAmB;;;AC2BrB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EACzC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAQO,SAAS,qBAAqB,SAAoC;AAIrE,QAAM,EAAE,OAAO,aAAa,WAAW,IAAI;AAC3C,QAAM,gBAAgB,QAAQ,aAAa;AAO3C,QAAM,aAAa,SAAS,QAAQ,UAAU;AAC9C,QAAM,mBAAmB,eAAe,QAAQ,gBAAgB;AAChE,QAAM,kBAAkB,cAAc,QAAQ,eAAe;A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AAG;AAC/B,QAAM,MAAM;AACZ,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["fs","path","buffer","path","path","buffer","runOrExit","program","runOrExit","path","buffer","program","runOrExit","path","runOrExit","path","program","fs","program","program","program","members","fs","TextDecoder","runOrExit","addSpaceOptions","path","buffer","readCommentContentFile","TextDecoder","indentation","escapeTerminalControlCharacters","formatDetailScalar","printDetailField","printDetailTextField","program","program","arch","platform","platform","arch","program"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/program.ts","../src/commands/file.ts","../src/commands/file-comment.ts","../src/utils/file-selector.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/spinner.ts","../src/utils/search-options.ts","../src/utils/run-or-exit.ts","../src/commands/memory.ts","../src/utils/miniapp-db.ts","../src/commands/miniapp.ts","../src/telemetry/config.ts","../src/telemetry/opt-out.ts","../src/commands/telemetry.ts","../src/commands/whoami.ts","../src/commands/workspace.ts","../src/commands/workflow.ts","../src/telemetry/client.ts","../src/telemetry/notice.ts","../src/telemetry/instrument.ts"],"sourcesContent":["import updateNotifier from 'update-notifier'\nimport { createProgram } from './program.js'\nimport { flush } from './telemetry/client.js'\nimport { installExitHandler, instrumentProgram } from './telemetry/instrument.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = createProgram(__CLI_VERSION__)\n\ninstrumentProgram(program)\ninstallExitHandler()\n\nprogram\n .parseAsync(process.argv)\n .then(async () => {\n await flush()\n })\n .catch(async (err: unknown) => {\n console.error('CLI Error:', err)\n await flush()\n process.exit(1)\n })\n","import { Command } from 'commander'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerMemoryCommand } from './commands/memory.js'\nimport { registerMiniappCommand } from './commands/miniapp.js'\nimport { registerTelemetryCommand } from './commands/telemetry.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\nimport { registerWorkflowCommand } from './commands/workflow.js'\n\nexport function createProgram(version: string): Command {\n const program = new Command()\n\n program\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(version)\n .action(() => {\n program.help()\n })\n\n registerWhoamiCommand(program)\n registerWorkspaceCommand(program)\n registerFileCommand(program)\n registerMemoryCommand(program)\n registerWorkflowCommand(program)\n registerMiniappCommand(program)\n registerTelemetryCommand(program)\n\n return program\n}\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport { registerFileCommentCommands } from './file-comment.js'\nimport {\n buildFileQueryString,\n isBinaryContent,\n resolveReadMode,\n resolveSpaceSelector,\n resolveWriteMode,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseSearchMode } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\ninterface FieldHighlight {\n text: string\n}\n\ninterface SemanticSnippet {\n content: string\n}\n\ninterface FileSearchItem {\n repoId: string\n fileId: string\n filePath: string\n rank: number\n contentHighlight?: FieldHighlight\n filePathHighlight?: FieldHighlight\n semanticSnippets: SemanticSnippet[]\n}\n\ninterface FileSearchResponse {\n items: FileSearchItem[]\n}\n\nfunction addSpaceOptions(cmd: Command): Command {\n return cmd\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n registerFileCommentCommands(file)\n\n addSpaceOptions(\n file.command('search')\n .description('Search files in accessible spaces')\n .argument('<query>', 'Search query')\n .option('-l, --limit <limit>', 'Maximum number of files to return', '30')\n .option('--mode <mode>', 'Keyword matching mode: any or all', 'any'),\n ).action(async (query: string, options: SpaceOptions & { limit?: string; mode?: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const limit = runOrExit(() => parseSearchLimit(options.limit, 30, 80))\n const mode = runOrExit(() => parseSearchMode(options.mode))\n\n startSpinner('Searching files...')\n const response = await httpPost<FileSearchResponse>(\n `/workspaces/${options.workspace}/files/search`,\n {\n query,\n limit,\n mode,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No files found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} file(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. ${item.filePath}${colors.reset}`)\n print(`${colors.dim}repo=${item.repoId} file=${item.fileId}${colors.reset}`)\n const snippet = item.contentHighlight?.text ?? item.semanticSnippets[0]?.content\n if (snippet) {\n print(snippet)\n }\n print('')\n }\n })\n\n addSpaceOptions(\n file.command('get-url')\n .description('Resolve the shareable browser URL for a file')\n .requiredOption('-p, --path <path>', 'File path'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Resolving URL...')\n const response = await httpGet<FileUrlResponse>(\n `/workspaces/${options.workspace}/files/url${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, response.data.path)\n print(`${colors.cyan}${response.data.url}${colors.reset}`)\n })\n\n addSpaceOptions(\n file.command('list')\n .description('List directory contents')\n .option('-p, --path <path>', 'Directory path', '/'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list${qs}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: Partial<SpaceOptions> & { path?: string; url?: string }) => {\n const mode = runOrExit(() => resolveReadMode(options))\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(mode.url)}`,\n )\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n response = await httpGet<FileReadResponse>(\n `/workspaces/${mode.workspace}/files/read${qs}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${displayPath} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'Remote file path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: Partial<SpaceOptions> & {\n path?: string\n url?: string\n localPath: string\n recursive?: boolean\n }) => {\n const mode = runOrExit(() => resolveWriteMode(options))\n\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n\n let response: { ok: boolean; status: number; data: FileWriteResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpPut<FileWriteResponse>('/files/write-by-url', {\n url: mode.url,\n content,\n })\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n response = await httpPut<FileWriteResponse>(\n `/workspaces/${mode.workspace}/files/write`,\n {\n path: mode.path,\n content,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n if (mode.kind === 'by-url') {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n }\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-r, --recursive', 'Create parent directories if needed'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n recursive?: boolean\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n addSpaceOptions(\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-p, --path <path>', 'File or directory path'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n ...spaceParams,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","import * as fs from 'node:fs'\nimport { TextDecoder } from 'node:util'\nimport { Command } from 'commander'\nimport {\n buildFileQueryString,\n ReadMode,\n resolveReadMode,\n resolveSpaceSelector,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpGet, httpPatch } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\n// The comment/thread ID column is a nanoid, and canonical file URLs embed a UUID fileId.\n// Mirror the server contract (server-ts openapi-file-comment.vo.ts / openapi-file-url.controller.ts)\n// so the CLI rejects malformed URLs locally instead of forwarding them to the API.\nconst FILE_ID_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\nconst URL_FORMAT_HINT =\n 'Error: invalid Moxt URL format. Expected https://moxt.ai/w/{workspaceId}/{fileId} ' +\n 'or https://moxt.ai/w/{workspaceId}/c/{agentId}[/{sessionId}]?file={fileId}'\n\ninterface FileCommentAuthor {\n humanId: number | null\n assistantId: number | null\n teammateId: number | null\n authorName: string | null\n authorAvatarUrl: string | null\n}\n\ninterface FileCommentItem extends FileCommentAuthor {\n id: string\n threadId: string\n content: string\n createdAt: string\n editedAt: string | null\n}\n\ninterface FileCommentThread {\n threadId: string\n items: FileCommentItem[]\n createdAt: string\n createdBy: FileCommentAuthor\n resolvedAt: string | null\n quotedText: string | null\n fileId: string\n}\n\ninterface ListFileCommentsResponse {\n items: FileCommentThread[]\n}\n\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\ninterface FileCommentOptions extends Partial<SpaceOptions> {\n path?: string\n url?: string\n}\n\n/**\n * Error thrown when a file comment command's local option/content validation fails.\n * Handlers catch it via {@link runOrExit} and turn it into stderr + exit code 1.\n */\nclass FileCommentOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'FileCommentOptionsError'\n }\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof FileCommentOptionsError || err instanceof SpaceOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\n/**\n * Extract the workspace/file identifiers a comment API call needs from a canonical\n * Moxt file URL. Supports the workspace-mode shape `/w/{workspaceId}/{fileId}` and the\n * chat deeplink `/w/{workspaceId}/c/{agentId}[/{sessionId}]?file={fileId}`.\n */\nfunction parseMoxtFileUrl(url: string): { workspaceId: string; fileId: string } {\n let parsed: URL\n try {\n parsed = new URL(url)\n } catch {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n\n const segments = parsed.pathname.split('/').filter(Boolean)\n if (segments.length < 3 || segments[0] !== 'w') {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n const workspaceId = segments[1]\n\n let fileId: string | undefined\n if (segments[2] === 'c') {\n fileId = parsed.searchParams.get('file') ?? undefined\n } else if (segments.length === 3) {\n fileId = segments[2]\n }\n\n if (!fileId || !FILE_ID_UUID_RE.test(fileId)) {\n throw new FileCommentOptionsError(URL_FORMAT_HINT)\n }\n return { workspaceId, fileId }\n}\n\n/**\n * Resolve the target file for a comment command. URL mode reads the identifiers directly;\n * path mode calls the existing `file get-url` endpoint to obtain a stable URL, then parses it.\n */\nasync function resolveFileTarget(options: FileCommentOptions): Promise<{ workspaceId: string; fileId: string }> {\n const mode: ReadMode = runOrExit(() => resolveReadMode(options))\n if (mode.kind === 'by-url') {\n return runOrExit(() => parseMoxtFileUrl(mode.url))\n }\n\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n\n startSpinner('Resolving file...')\n const response = await httpGet<FileUrlResponse>(`/workspaces/${mode.workspace}/files/url${qs}`)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${mode.path} does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n stopSpinner(true, response.data.path)\n return runOrExit(() => parseMoxtFileUrl(response.data.url))\n}\n\nfunction readCommentContentFile(path: string): string {\n if (!fs.existsSync(path)) {\n throw new FileCommentOptionsError(`Error: comment content file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new FileCommentOptionsError(`Error: comment content path is not a file: ${path}`)\n }\n const buffer = fs.readFileSync(path)\n if (buffer.includes(0)) {\n throw new FileCommentOptionsError('Error: comment content file must not contain NUL bytes.')\n }\n let content: string\n try {\n content = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer)\n } catch {\n throw new FileCommentOptionsError('Error: comment content file must contain valid UTF-8 text.')\n }\n // The file comment API only requires a non-empty body (server schema: z.string().min(1));\n // there is no server-side max length, so the CLI must not impose a client-only cap.\n if (content.length === 0) {\n throw new FileCommentOptionsError('Error: comment content file must not be empty.')\n }\n return content\n}\n\nfunction parseResolveState(state: string | undefined): boolean {\n if (state === 'resolved') return true\n if (state === 'open') return false\n throw new FileCommentOptionsError('Error: --state must be \"resolved\" or \"open\".')\n}\n\ntype DetailScalar = string | number | boolean | null\n\nfunction indentation(size: number): string {\n return ' '.repeat(size)\n}\n\n// Escape terminal control characters so untrusted comment content, author names, and\n// avatar URLs cannot inject ANSI/OSC sequences into the operator's terminal.\nfunction escapeTerminalControlCharacters(value: string): string {\n return value\n .replace(/\\r\\n/g, '\\n')\n .replace(/[\\u0000-\\u0008\\u000B-\\u001F\\u007F-\\u009F]/g, (character) =>\n `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n )\n}\n\nfunction formatDetailScalar(value: DetailScalar): string {\n if (value === null) return 'null'\n if (typeof value === 'string') {\n const escaped = escapeTerminalControlCharacters(value)\n if (escaped === '') return '\"\"'\n if (/\\n/.test(escaped)) return JSON.stringify(escaped)\n return escaped\n }\n return String(value)\n}\n\nfunction printDetailField(name: string, value: DetailScalar, indent = 0): void {\n print(`${indentation(indent)}${name}: ${formatDetailScalar(value)}`)\n}\n\nfunction printDetailTextField(name: string, value: string | null, indent = 0): void {\n if (value === null || value === '') {\n printDetailField(name, value, indent)\n return\n }\n const escaped = escapeTerminalControlCharacters(value)\n print(`${indentation(indent)}${name}:`)\n for (const line of escaped.split('\\n')) {\n print(`${indentation(indent + 2)}${line}`)\n }\n}\n\nfunction printAuthorFields(author: FileCommentAuthor, indent: number): void {\n printDetailField('humanId', author.humanId, indent)\n printDetailField('assistantId', author.assistantId, indent)\n printDetailField('teammateId', author.teammateId, indent)\n printDetailField('authorName', author.authorName, indent)\n printDetailField('authorAvatarUrl', author.authorAvatarUrl, indent)\n}\n\nfunction printCommentItem(item: FileCommentItem, indent = 0): void {\n print(`${indentation(indent)}${colors.bold}Comment${colors.reset}`)\n printDetailField('id', item.id, indent + 2)\n printDetailField('threadId', item.threadId, indent + 2)\n printAuthorFields(item, indent + 2)\n printDetailTextField('content', item.content, indent + 2)\n printDetailField('createdAt', item.createdAt, indent + 2)\n printDetailField('editedAt', item.editedAt, indent + 2)\n}\n\nfunction printThread(thread: FileCommentThread): void {\n print(`${colors.bold}Thread${colors.reset}`)\n printDetailField('threadId', thread.threadId, 2)\n printDetailField('fileId', thread.fileId, 2)\n printDetailTextField('quotedText', thread.quotedText, 2)\n printDetailField('resolvedAt', thread.resolvedAt, 2)\n print(`${indentation(2)}createdBy:`)\n printAuthorFields(thread.createdBy, 4)\n printDetailField('createdAt', thread.createdAt, 2)\n print(`${indentation(2)}comments:`)\n thread.items.forEach((item) => printCommentItem(item, 4))\n}\n\nfunction addFileSelectorOptions(cmd: Command): Command {\n return cmd\n .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n}\n\nexport function registerFileCommentCommands(file: Command): void {\n const comment = file.command('comment').description('File comment operations')\n\n addFileSelectorOptions(\n comment.command('list').description('List comment threads on a file'),\n ).action(async (options: FileCommentOptions) => {\n const target = await resolveFileTarget(options)\n\n startSpinner('Fetching comments...')\n const response = await httpGet<ListFileCommentsResponse>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comment-threads`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n if (response.data.items.length === 0) {\n stopSpinner(true, 'No comments found.')\n return\n }\n stopSpinner(true, `Found ${response.data.items.length} thread(s)`)\n response.data.items.forEach((thread, index) => {\n if (index > 0) print('')\n printThread(thread)\n })\n })\n\n addFileSelectorOptions(\n comment.command('update')\n .description('Update a comment you created')\n .argument('<commentId>')\n .requiredOption('--content-path <localPath>', 'Local UTF-8 text file for comment content'),\n ).action(async (commentId: string, options: FileCommentOptions & { contentPath: string }) => {\n // Validate the local content file before any network call so invalid input\n // never leaves the CLI (path-mode resolution below issues an HTTP request).\n const content = runOrExit(() => readCommentContentFile(options.contentPath))\n const target = await resolveFileTarget(options)\n\n startSpinner('Updating comment...')\n const response = await httpPatch<FileCommentItem>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comments/${commentId}`,\n { content },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n stopSpinner(true, 'Comment updated')\n printCommentItem(response.data)\n })\n\n addFileSelectorOptions(\n comment.command('resolve')\n .description('Resolve or reopen a comment thread')\n .argument('<threadId>')\n .requiredOption('--state <state>', 'Thread state: resolved or open'),\n ).action(async (threadId: string, options: FileCommentOptions & { state: string }) => {\n const resolved = runOrExit(() => parseResolveState(options.state))\n const target = await resolveFileTarget(options)\n\n startSpinner(resolved ? 'Resolving thread...' : 'Reopening thread...')\n const response = await httpPatch<unknown>(\n `/workspaces/${target.workspaceId}/files/${target.fileId}/comment-threads/${threadId}/resolve`,\n { resolved },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n stopSpinner(true, resolved ? `Resolved: ${threadId}` : `Reopened: ${threadId}`)\n })\n}\n","/**\n * Pure logic for resolving file-command space selectors and building request URLs.\n *\n * These functions are extracted from commands/file.ts so they can be unit tested\n * without spawning the CLI or mocking process.exit. All error conditions are\n * surfaced as thrown Errors; action handlers are responsible for turning them\n * into user-facing output and exit codes.\n */\n\nexport interface SpaceOptions {\n workspace: string\n space?: string\n personal?: boolean\n teamSpaceId?: string\n teammateId?: string\n}\n\nexport interface SpaceParams {\n space?: string\n teamSpaceId?: string\n agentId?: number\n}\n\n/**\n * Error thrown when selector options violate a contract (mutually exclusive,\n * wrong format, etc). Action handlers catch this and print the message before\n * exiting with code 1.\n */\nexport class SpaceOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SpaceOptionsError'\n }\n}\n\n/**\n * Resolve mutually-exclusive space selector flags into normalized request params.\n *\n * Priority (only one must be set): --team-space-id > --teammate-id > --personal > -s <name>.\n * When none is set, returns empty params (server treats this as personal space).\n */\nexport function resolveSpaceSelector(options: SpaceOptions): SpaceParams {\n // Destructure first so TypeScript's control-flow analysis can narrow each\n // field through the subsequent non-null / non-empty checks without having\n // to re-read options.* at the point of use (which would lose narrowing).\n const { space, teamSpaceId, teammateId } = options\n const personalIsSet = options.personal === true\n\n // Count \"user-set\" selectors explicitly so the mutual-exclusion check\n // reflects intent (\"which flags did the user pass?\") rather than a\n // generic truthiness filter. This keeps the mutual-exclusion check\n // cleanly separated from the downstream format validation (e.g.\n // `parsed <= 0` for teammateId).\n const spaceIsSet = space != null && space !== ''\n const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== ''\n const teammateIdIsSet = teammateId != null && teammateId !== ''\n const selectorCount =\n (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0)\n if (selectorCount > 1) {\n throw new SpaceOptionsError(\n 'Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive.',\n )\n }\n\n // Dispatch via the underlying field checks (not `*IsSet`) so TypeScript\n // narrows each local to `string`, letting us return without `!`.\n if (teamSpaceId != null && teamSpaceId !== '') {\n return { teamSpaceId }\n }\n if (teammateId != null && teammateId !== '') {\n const parsed = Number.parseInt(teammateId, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {\n throw new SpaceOptionsError(\n `Error: --teammate-id must be a positive integer, got \"${teammateId}\".`,\n )\n }\n return { agentId: parsed }\n }\n if (personalIsSet) {\n return { space: 'personal' }\n }\n if (space != null && space !== '') {\n return { space }\n }\n return {}\n}\n\n/**\n * Build the `?path=...&space=...` query string for file endpoints.\n * Returns empty string when no params are set (caller should not append `?`).\n * Values are URL-encoded via URLSearchParams.\n *\n * An empty-string `path` is treated as \"not provided\" and omitted from the query;\n * callers should pass `undefined` rather than `\"\"` when no path is intended.\n */\nexport function buildFileQueryString(path: string | undefined, spaceParams: SpaceParams): string {\n const params = new URLSearchParams()\n if (path != null && path !== '') {\n params.set('path', path)\n }\n if (spaceParams.space) {\n params.set('space', spaceParams.space)\n }\n if (spaceParams.teamSpaceId) {\n params.set('teamSpaceId', spaceParams.teamSpaceId)\n }\n if (spaceParams.agentId != null) {\n params.set('agentId', String(spaceParams.agentId))\n }\n const qs = params.toString()\n return qs ? `?${qs}` : ''\n}\n\n/**\n * Detect if a Buffer contains binary content by sampling the first 8192 bytes.\n * Control characters other than tab (9), LF (10), and CR (13) are treated as binary.\n */\nexport function isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Validate `file read` command's top-level mutually-exclusive options (-u vs -w/-p).\n * Returns the resolved mode ('by-url' or 'by-path'). Throws SpaceOptionsError on conflict.\n *\n * Empty strings are treated as \"not provided\" (commander never passes empty strings\n * for optional flags, but callers outside the CLI context should pass undefined instead\n * of \"\" to avoid unexpected branch behaviour).\n */\nexport type ReadMode = { kind: 'by-url'; url: string } | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveReadMode(options: {\n url?: string\n workspace?: string\n path?: string\n}): ReadMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n // At this point both workspace and path are guaranteed non-empty by the guards\n // above. Use explicit checks so TypeScript narrows the types without needing `!`.\n if (!options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n return { kind: 'by-path', workspace: options.workspace, path: options.path }\n}\n\n/**\n * Validate `file put` command's top-level mutually-exclusive options (-u vs -w/-p).\n *\n * By-URL puts overwrite an existing file (the URL already identifies it), so\n * `--recursive` is meaningless in that mode and is rejected outright to keep the\n * user's intent unambiguous.\n */\nexport type WriteMode =\n | { kind: 'by-url'; url: string }\n | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveWriteMode(options: {\n url?: string\n workspace?: string\n path?: string\n recursive?: boolean\n}): WriteMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (options.url && options.recursive) {\n throw new SpaceOptionsError('Error: --recursive cannot be used with --url (the file must already exist)')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n return { kind: 'by-path', workspace: options.workspace!, path: options.path! }\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nexport interface RawApiResponse {\n ok: boolean\n status: number\n text: string\n contentType: string | null\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function fetchApi(method: string, path: string, body?: unknown): Promise<Response> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return response\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const response = await fetchApi(method, path, body)\n const contentType = response.headers.get('content-type')\n const data = contentType?.includes('application/json') ? ((await response.json()) as T) : ((await response.text()) as T)\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpPatch<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PATCH', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body?: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n\nexport async function httpRaw(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, body?: unknown): Promise<RawApiResponse> {\n const response = await fetchApi(method, path, body)\n return {\n ok: response.ok,\n status: response.status,\n text: await response.text(),\n contentType: response.headers.get('content-type'),\n }\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n\nexport function getApiKeyOrUndefined(): string | undefined {\n return process.env.MOXT_API_KEY\n}\n","// ANSI colors\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n cyan: '\\x1b[36m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","export class SearchOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SearchOptionsError'\n }\n}\n\nexport function parseSearchLimit(raw: string | undefined, defaultValue: number, max: number): number {\n if (raw == null || raw === '') {\n return defaultValue\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --limit must be a positive integer, got \"${raw}\".`)\n }\n if (parsed > max) {\n throw new SearchOptionsError(`Error: --limit must be less than or equal to ${max}.`)\n }\n return parsed\n}\n\nexport function parseSearchMode(raw: string | undefined): 'all' | 'any' {\n if (raw == null || raw === '') {\n return 'any'\n }\n if (raw === 'all' || raw === 'any') {\n return raw\n }\n throw new SearchOptionsError(`Error: --mode must be \"any\" or \"all\", got \"${raw}\".`)\n}\n\nexport function parseTeammateId(raw: string | undefined): number | undefined {\n if (raw == null || raw === '') {\n return undefined\n }\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new SearchOptionsError(`Error: --teammate-id must be a positive integer, got \"${raw}\".`)\n }\n return parsed\n}\n","import { SpaceOptionsError } from './file-selector.js'\nimport { printError } from './output.js'\nimport { SearchOptionsError } from './search-options.js'\n\n/**\n * Call a pure resolver that may throw a known CLI option error; on error,\n * print the message and exit(1). This keeps the user-facing contract\n * (stderr + exit code 1) consistent across subcommands while letting the\n * resolvers stay pure and unit-testable.\n */\nexport function runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n","import { Command } from 'commander'\nimport { httpPost } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { runOrExit } from '../utils/run-or-exit.js'\nimport { parseSearchLimit, parseTeammateId } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface MemorySearchItem {\n rank: number\n pipelineId: string\n chunkId: string\n chunkIndex: number\n content: string\n contentTruncated: boolean\n}\n\ninterface MemorySearchResponse {\n items: MemorySearchItem[]\n}\n\nexport function registerMemoryCommand(program: Command): void {\n const memory = program.command('memory').description('Memory operations')\n\n memory.command('search')\n .description('Search archived agent memory')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('--teammate-id <teammateId>', 'Search a managed AI teammate memory')\n .option('-l, --limit <limit>', 'Maximum number of memory chunks to return', '5')\n .argument('<query>', 'Search query')\n .action(\n async (\n query: string,\n options: {\n workspace: string\n teammateId?: string\n limit?: string\n },\n ) => {\n const limit = runOrExit(() => parseSearchLimit(options.limit, 5, 10))\n const teammateId = runOrExit(() => parseTeammateId(options.teammateId))\n\n startSpinner('Searching memory...')\n const response = await httpPost<MemorySearchResponse>(\n `/workspaces/${options.workspace}/memory/search`,\n {\n query,\n limit,\n ...(teammateId !== undefined ? { agentId: teammateId } : {}),\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { items } = response.data\n if (items.length === 0) {\n stopSpinner(true, 'No memory found.')\n return\n }\n\n stopSpinner(true, `Found ${items.length} memory chunk(s)`)\n for (const item of items) {\n print(`${colors.bold}${item.rank}. pipeline=${item.pipelineId} chunk=${item.chunkIndex}${colors.reset}`)\n print(`${colors.dim}chunkId=${item.chunkId}${item.contentTruncated ? ' truncated=true' : ''}${colors.reset}`)\n print(item.content)\n print('')\n }\n },\n )\n}\n","export class MiniappDbOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'MiniappDbOptionsError'\n }\n}\n\nconst NON_FILTER_QUERY_PARAMS = new Set([\n 'select',\n 'order',\n 'limit',\n 'offset',\n 'range',\n 'range-unit',\n])\n\nconst ALLOWED_MINIAPP_DB_EMAIL_DOMAINS = ['@paraflow.com', '@moxt.ai', '@kanyun.com']\n\nexport function normalizePostgrestPath(path: string): string {\n const trimmed = path.trim()\n if (!trimmed) {\n throw new MiniappDbOptionsError('Error: PostgREST path is required.')\n }\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`\n}\n\nexport function buildMiniappDbDataPath(workspaceId: string, appId: string, postgrestPath: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/data${normalizePostgrestPath(postgrestPath)}`\n}\n\nexport function buildMiniappDbSchemaPath(workspaceId: string, appId: string): string {\n return `/workspaces/${encodeURIComponent(workspaceId)}/miniapps/${encodeURIComponent(appId)}/db/schema`\n}\n\nexport function parseJsonBody(raw: string): unknown {\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error)\n throw new MiniappDbOptionsError(`Error: --body must be valid JSON. ${detail}`)\n }\n\n if (parsed === null || (typeof parsed !== 'object' && !Array.isArray(parsed))) {\n throw new MiniappDbOptionsError('Error: --body must be a JSON object or array.')\n }\n return parsed\n}\n\nexport function hasPostgrestFilter(postgrestPath: string): boolean {\n const normalizedPath = normalizePostgrestPath(postgrestPath)\n const parsed = new URL(normalizedPath, 'https://postgrest.local')\n for (const [name] of parsed.searchParams.entries()) {\n if (!NON_FILTER_QUERY_PARAMS.has(name.toLowerCase())) {\n return true\n }\n }\n return false\n}\n\nexport function assertPostgrestFilter(postgrestPath: string, method: 'PATCH' | 'DELETE'): void {\n if (!hasPostgrestFilter(postgrestPath)) {\n throw new MiniappDbOptionsError(\n `Error: ${method.toLowerCase()} requires at least one PostgREST filter query parameter.`,\n )\n }\n}\n\nexport function formatRawResponse(text: string, pretty?: boolean): string {\n if (!pretty || !text) {\n return text\n }\n try {\n return JSON.stringify(JSON.parse(text), null, 2)\n } catch {\n return text\n }\n}\n\nexport function isAllowedMiniappDbUserEmail(email: string): boolean {\n const normalized = email.trim().toLowerCase()\n return ALLOWED_MINIAPP_DB_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain))\n}\n","import { Command } from 'commander'\nimport {\n assertPostgrestFilter,\n buildMiniappDbDataPath,\n buildMiniappDbSchemaPath,\n formatRawResponse,\n isAllowedMiniappDbUserEmail,\n MiniappDbOptionsError,\n parseJsonBody,\n} from '../utils/miniapp-db.js'\nimport { httpGet, httpRaw } from '../utils/http.js'\nimport { print, printError } from '../utils/output.js'\n\ninterface MiniappDbOptions {\n workspace: string\n appId: string\n pretty?: boolean\n body?: string\n yes?: boolean\n}\n\ninterface MiniappDbSchemaResponse {\n sql: string\n}\n\ninterface WhoamiResponse {\n email: string\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof MiniappDbOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\nfunction addMiniappDbTargetOptions(command: Command): Command {\n return command\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .requiredOption('--app-id <appId>', 'Miniapp app ID')\n}\n\nfunction handleRawResponse(response: Awaited<ReturnType<typeof httpRaw>>, pretty?: boolean): void {\n if (!response.ok) {\n printError(`Error [${response.status}]: ${response.text}`)\n process.exit(1)\n }\n print(formatRawResponse(response.text, pretty))\n}\n\nasync function ensureAllowedMiniappDbUser(): Promise<void> {\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n if (!isAllowedMiniappDbUserEmail(response.data.email)) {\n printError('Error: miniapp db commands are only available to @paraflow.com, @moxt.ai, or @kanyun.com users.')\n process.exit(1)\n }\n}\n\nasync function requestDataApi(\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE',\n postgrestPath: string,\n options: MiniappDbOptions,\n body?: unknown,\n): Promise<void> {\n await ensureAllowedMiniappDbUser()\n const path = buildMiniappDbDataPath(options.workspace, options.appId, postgrestPath)\n const response = await httpRaw(method, path, body)\n handleRawResponse(response, options.pretty)\n}\n\nexport function registerMiniappCommand(program: Command): void {\n const miniapp = program.command('miniapp', { hidden: true }).description('Miniapp operations')\n const db = miniapp.command('db').description('Miniapp database operations')\n\n addMiniappDbTargetOptions(\n db.command('schema').description('Print the miniapp database schema SQL'),\n ).action(async (options: MiniappDbOptions) => {\n await ensureAllowedMiniappDbUser()\n const response = await httpGet<MiniappDbSchemaResponse>(buildMiniappDbSchemaPath(options.workspace, options.appId))\n\n if (!response.ok) {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n print(response.data.sql)\n })\n\n addMiniappDbTargetOptions(\n db.command('get')\n .description('Read miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos?select=*')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n await requestDataApi('GET', postgrestPath, options)\n })\n\n addMiniappDbTargetOptions(\n db.command('post')\n .description('Create miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path, for example /todos')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('POST', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('patch')\n .description('Update miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .requiredOption('--body <json>', 'JSON object or array request body')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'PATCH'))\n const body = runOrExit(() => parseJsonBody(options.body ?? ''))\n await requestDataApi('PATCH', postgrestPath, options, body)\n })\n\n addMiniappDbTargetOptions(\n db.command('delete')\n .description('Delete miniapp data through PostgREST')\n .argument('<path>', 'PostgREST path with a filter, for example /todos?id=eq.1')\n .option('--yes', 'Confirm the delete operation')\n .option('--pretty', 'Pretty-print JSON responses'),\n ).action(async (postgrestPath: string, options: MiniappDbOptions) => {\n if (options.yes !== true) {\n printError('Error: delete requires --yes.')\n process.exit(1)\n }\n runOrExit(() => assertPostgrestFilter(postgrestPath, 'DELETE'))\n await requestDataApi('DELETE', postgrestPath, options)\n })\n}\n","import * as fs from 'node:fs'\nimport * as os from 'node:os'\nimport * as path from 'node:path'\n\nexport interface TelemetryConfig {\n disabled?: boolean\n noticeShown?: boolean\n}\n\nfunction getConfigPath(): string {\n return path.join(os.homedir(), '.moxt', 'config.json')\n}\n\nexport function readTelemetryConfig(): TelemetryConfig {\n try {\n const raw = fs.readFileSync(getConfigPath(), 'utf8')\n const parsed = JSON.parse(raw) as { telemetry?: TelemetryConfig }\n return parsed.telemetry ?? {}\n } catch {\n return {}\n }\n}\n\nexport function writeTelemetryConfig(update: Partial<TelemetryConfig>): void {\n const configPath = getConfigPath()\n let existing: Record<string, unknown> = {}\n try {\n existing = JSON.parse(fs.readFileSync(configPath, 'utf8')) as Record<string, unknown>\n } catch {\n existing = {}\n }\n const currentTelemetry = (existing.telemetry as TelemetryConfig | undefined) ?? {}\n const next = { ...existing, telemetry: { ...currentTelemetry, ...update } }\n fs.mkdirSync(path.dirname(configPath), { recursive: true })\n fs.writeFileSync(configPath, JSON.stringify(next, null, 2))\n}\n","import { readTelemetryConfig } from './config.js'\n\nexport function isCiEnvironment(): boolean {\n return process.env.CI === 'true' || process.env.CI === '1'\n}\n\nexport function isTelemetryDisabled(): boolean {\n if (process.env.MOXT_TELEMETRY_DISABLED === '1' || process.env.MOXT_TELEMETRY_DISABLED === 'true') {\n return true\n }\n if (process.env.DO_NOT_TRACK === '1' || process.env.DO_NOT_TRACK === 'true') {\n return true\n }\n return readTelemetryConfig().disabled === true\n}\n","import { Command } from 'commander'\nimport { readTelemetryConfig, writeTelemetryConfig } from '../telemetry/config.js'\nimport { isTelemetryDisabled } from '../telemetry/opt-out.js'\nimport { print } from '../utils/output.js'\n\nexport function registerTelemetryCommand(program: Command): void {\n const telemetry = program.command('telemetry').description('Manage Moxt CLI telemetry')\n\n telemetry\n .command('status')\n .description('Show telemetry status')\n .action(() => {\n const cfg = readTelemetryConfig()\n const envOverride =\n process.env.MOXT_TELEMETRY_DISABLED === '1' ||\n process.env.MOXT_TELEMETRY_DISABLED === 'true' ||\n process.env.DO_NOT_TRACK === '1' ||\n process.env.DO_NOT_TRACK === 'true'\n\n const state = isTelemetryDisabled() ? 'disabled' : 'enabled'\n print(`telemetry: ${state}`)\n if (envOverride) {\n print('(disabled via environment variable)')\n } else if (cfg.disabled) {\n print('(disabled via config file)')\n }\n })\n\n telemetry\n .command('enable')\n .description('Enable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: false })\n print('telemetry: enabled')\n })\n\n telemetry\n .command('disable')\n .description('Disable telemetry')\n .action(() => {\n writeTelemetryConfig({ disabled: true })\n print('telemetry: disabled')\n })\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpGet, httpDelete } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\ninterface MemberItem {\n userId: number\n email: string\n displayName: string | null\n role: string\n}\n\ninterface MembersResponse {\n members: MemberItem[]\n}\n\ninterface SpaceItem {\n type: 'personal' | 'team' | 'teammate'\n name: string\n teamSpaceId: string | null\n agentId: number | null\n}\n\n// Email regex (same as web/src/utils/email.ts)\nconst emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\nfunction isValidEmail(email: string): boolean {\n return emailRegex.test(email)\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n\n const members = program.command('members').description('Manage workspace members')\n\n members\n .command('list')\n .description('List all members in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching workspace members...')\n const response = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { members } = response.data\n if (members.length === 0) {\n stopSpinner(true, 'No members found.')\n return\n }\n\n stopSpinner(true, `Found ${members.length} member(s)`)\n\n for (const member of members) {\n const name = member.displayName || '-'\n print(`${colors.bold}${member.email}${colors.reset}\\t${name}\\t${member.role}`)\n }\n })\n\n members\n .command('remove')\n .description('Remove members from a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .argument('<emails>', 'Emails to remove (comma-separated)')\n .action(async (emailsArg: string, options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n const emails = emailsArg.split(',').map((e) => e.trim()).filter(Boolean)\n if (emails.length === 0) {\n printError('No valid emails provided')\n process.exit(1)\n }\n\n // Validate email format\n const invalidEmails = emails.filter((e) => !isValidEmail(e))\n if (invalidEmails.length > 0) {\n for (const email of invalidEmails) {\n printError(`Invalid email format: ${email}`)\n }\n process.exit(1)\n }\n\n // Fetch members to get userId by email\n startSpinner('Fetching workspace members...')\n const membersResponse = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!membersResponse.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Members fetched')\n\n const { members } = membersResponse.data\n const emailToMember = new Map(members.map((m) => [m.email.toLowerCase(), m]))\n\n // Remove each member\n for (const email of emails) {\n const member = emailToMember.get(email.toLowerCase())\n if (!member) {\n print(`${colors.red}✗${colors.reset} ${email} - not found in workspace`)\n continue\n }\n\n const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`)\n\n if (deleteResponse.ok) {\n print(`${colors.green}✓${colors.reset} ${email} - removed`)\n } else {\n print(`${colors.red}✗${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`)\n }\n }\n })\n\n const space = program.command('space').description('Manage spaces')\n\n space\n .command('list')\n .description('List accessible spaces in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching spaces...')\n const response = await httpGet<{ spaces: SpaceItem[] }>(`/workspaces/${workspaceId}/spaces`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch spaces')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { spaces } = response.data\n if (spaces.length === 0) {\n stopSpinner(true, 'No spaces found.')\n return\n }\n\n stopSpinner(true, `Found ${spaces.length} space(s)`)\n\n print(\n `${colors.bold}TYPE${colors.reset}\\t${colors.bold}TEAM_SPACE_ID${colors.reset}\\t${colors.bold}TEAMMATE_ID${colors.reset}\\t${colors.bold}NAME${colors.reset}`,\n )\n for (const s of spaces) {\n const teamSpaceId = s.teamSpaceId ?? ''\n const teammateId = s.agentId != null ? String(s.agentId) : ''\n print(`${s.type}\\t${teamSpaceId}\\t${teammateId}\\t${s.name}`)\n }\n })\n\n}\n","import * as fs from 'node:fs'\nimport { TextDecoder } from 'node:util'\nimport { Command } from 'commander'\nimport {\n isBinaryContent,\n resolveSpaceSelector,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\nimport { httpDelete, httpGet, httpPatch, httpPost } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { parseSearchLimit, SearchOptionsError } from '../utils/search-options.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\nconst MAX_DESC_LENGTH = 5000\nconst MAX_COMMENT_CONTENT_LENGTH = 5000\nconst MAX_COMMENT_CONTENT_BYTES = MAX_COMMENT_CONTENT_LENGTH * 4\n\ntype WorkflowStatusTypeValue = 1 | 2 | 3\ntype WorkflowTaskPriorityValue = 0 | 1 | 2 | 3\n\ninterface WorkflowItem {\n fileId: string\n ownerHumanId: number | null\n desc: string | null\n}\n\ninterface WorkflowListResponse {\n workflows: WorkflowItem[]\n}\n\ninterface WorkflowDetailResponse extends WorkflowItem {\n statusList: WorkflowStatusItem[]\n transitions: WorkflowTransitionItem[]\n}\n\ninterface WorkflowStatusItem {\n scopedId: number\n name: string\n desc: string | null\n type: WorkflowStatusTypeValue\n preferredAssignee: AssigneeInfo | null\n order: number\n}\n\ninterface WorkflowTransitionItem {\n statusFromScopedId: number\n statusToScopedId: number\n}\n\ninterface WorkflowTaskItem {\n scopedId: number\n workflowFileId: string\n ownerHumanId: number | null\n title: string\n desc: string | null\n statusScopedId: number\n priority: WorkflowTaskPriorityValue\n assignee: AssigneeInfo | null\n linkedFileIds: string[]\n subscribed: boolean\n runningAgentRuns: Array<{\n pipelineId: string\n executor: AssigneeInfo | null\n }>\n createdAt: string\n latestActAt: string\n}\n\ninterface WorkflowTaskListResponse {\n tasks: WorkflowTaskItem[]\n nextCursor: string | null\n}\n\ninterface WorkflowTaskCreateResponse {\n taskScopedId: number\n}\n\ninterface WorkflowCommentItem {\n id: number\n workflowFileId: string\n workflowTaskScopedId: number\n content: string\n createdBy: AssigneeInfo | null\n createdAt: string\n updatedAt: string\n}\n\ninterface WorkflowCommentListResponse {\n items: WorkflowCommentItem[]\n}\n\ntype AssigneeInfo =\n | { type: 'human'; humanId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'assistant'; aiAssistantId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'teammate'; aiTeammateId: number; displayName: string | null; avatarUrl: string | null }\n | { type: 'unknown'; humanId: number | null; aiAssistantId: number | null; aiTeammateId: number | null }\n\ninterface WorkflowSpaceOptions extends SpaceOptions {\n path: string\n descFile?: string\n ownerHumanId?: string\n}\n\ninterface AssigneeOptions {\n humanId?: string\n assistantId?: string\n teammateId?: string\n clear?: boolean\n}\n\ninterface PreferredAssigneeOptions {\n preferredHumanId?: string\n preferredAssistantId?: string\n preferredTeammateId?: string\n clearPreferredAssignee?: boolean\n}\n\nclass WorkflowOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'WorkflowOptionsError'\n }\n}\n\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof WorkflowOptionsError || err instanceof SpaceOptionsError || err instanceof SearchOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\n\nfunction addWorkspaceOption(command: Command): Command {\n return command.requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n}\n\nfunction addSpaceOptions(command: Command): Command {\n return addWorkspaceOption(command)\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nfunction addAssigneeOptions(command: Command): Command {\n return command\n .option('--human-id <humanId>', 'Human assignee ID')\n .option('--assistant-id <assistantId>', 'AI assistant assignee ID')\n .option('--teammate-id <teammateId>', 'AI teammate assignee ID')\n}\n\nfunction addPreferredAssigneeOptions(command: Command): Command {\n return command\n .option('--preferred-human-id <humanId>', 'Preferred human assignee ID')\n .option('--preferred-assistant-id <assistantId>', 'Preferred AI assistant assignee ID')\n .option('--preferred-teammate-id <teammateId>', 'Preferred AI teammate assignee ID')\n}\n\nfunction parsePositiveInteger(raw: string, label: string): number {\n const parsed = Number.parseInt(raw, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== raw) {\n throw new WorkflowOptionsError(`Error: ${label} must be a positive integer, got \"${raw}\".`)\n }\n return parsed\n}\n\nfunction parseOptionalPositiveInteger(raw: string | undefined, label: string): number | undefined {\n if (raw == null || raw === '') return undefined\n return parsePositiveInteger(raw, label)\n}\n\nfunction parseStatusType(raw: string | undefined): WorkflowStatusTypeValue | undefined {\n if (raw == null || raw === '') return undefined\n const parsed = Number.parseInt(raw, 10)\n if ((parsed === 1 || parsed === 2 || parsed === 3) && String(parsed) === raw) return parsed\n throw new WorkflowOptionsError('Error: --type must be one of 1 (todo), 2 (in-progress), or 3 (done).')\n}\n\nfunction parseRequiredStatusType(raw: string | undefined): WorkflowStatusTypeValue {\n const value = parseStatusType(raw)\n if (value === undefined) {\n throw new WorkflowOptionsError('Error: --type is required.')\n }\n return value\n}\n\nfunction parsePriority(raw: string | undefined): WorkflowTaskPriorityValue | undefined {\n if (raw == null || raw === '') return undefined\n if (raw === 'urgent') return 0\n if (raw === 'high') return 1\n if (raw === 'medium') return 2\n if (raw === 'low') return 3\n throw new WorkflowOptionsError('Error: --priority must be \"urgent\", \"high\", \"medium\", or \"low\".')\n}\n\nfunction parseRequiredPriority(raw: string | undefined): WorkflowTaskPriorityValue {\n return parsePriority(raw ?? 'medium') ?? 2\n}\n\nfunction parseWorkflowScope(raw: string | undefined): 'all' | 'owner_is_me' {\n if (raw == null || raw === '') return 'all'\n if (raw === 'all' || raw === 'owner_is_me') return raw\n throw new WorkflowOptionsError('Error: --scope must be \"all\" or \"owner_is_me\".')\n}\n\nfunction parseTaskScope(raw: string | undefined): 'all' | 'assigned_to_me' | 'subscribed_by_me' | 'owner_is_me' {\n if (raw == null || raw === '') return 'all'\n if (raw === 'all' || raw === 'assigned_to_me' || raw === 'subscribed_by_me' || raw === 'owner_is_me') {\n return raw\n }\n throw new WorkflowOptionsError(\n 'Error: --scope must be \"all\", \"assigned_to_me\", \"subscribed_by_me\", or \"owner_is_me\".',\n )\n}\n\nfunction parseFileIds(raw: string | undefined, label = '--file-ids'): string[] | undefined {\n if (raw == null || raw === '') return undefined\n const ids = raw.split(',').map((item) => item.trim()).filter(Boolean)\n if (ids.length === 0) {\n throw new WorkflowOptionsError(`Error: ${label} must include at least one file ID.`)\n }\n return ids\n}\n\nfunction readDescFile(path: string | undefined): string | undefined {\n if (path == null || path === '') return undefined\n if (!fs.existsSync(path)) {\n throw new WorkflowOptionsError(`Error: desc file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new WorkflowOptionsError(`Error: desc file is not a file: ${path}`)\n }\n const buffer = fs.readFileSync(path)\n if (isBinaryContent(buffer)) {\n throw new WorkflowOptionsError('Error: desc file must be UTF-8 text, not binary content.')\n }\n const content = buffer.toString('utf8')\n if (content.length > MAX_DESC_LENGTH) {\n throw new WorkflowOptionsError(`Error: desc file must be at most ${MAX_DESC_LENGTH} characters.`)\n }\n return content\n}\n\nfunction readCommentContentFile(path: string): string {\n if (!fs.existsSync(path)) {\n throw new WorkflowOptionsError(`Error: comment content file not found: ${path}`)\n }\n const stat = fs.statSync(path)\n if (!stat.isFile()) {\n throw new WorkflowOptionsError(`Error: comment content path is not a file: ${path}`)\n }\n if (stat.size > MAX_COMMENT_CONTENT_BYTES) {\n throw new WorkflowOptionsError(\n `Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`,\n )\n }\n const buffer = fs.readFileSync(path)\n if (buffer.includes(0)) {\n throw new WorkflowOptionsError('Error: comment content file must not contain NUL bytes.')\n }\n if (isBinaryContent(buffer)) {\n throw new WorkflowOptionsError('Error: comment content file must be UTF-8 text, not binary content.')\n }\n let content: string\n try {\n content = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer)\n } catch {\n throw new WorkflowOptionsError('Error: comment content file must contain valid UTF-8 text.')\n }\n if (content.length === 0) {\n throw new WorkflowOptionsError('Error: comment content file must not be empty.')\n }\n if (content.length > MAX_COMMENT_CONTENT_LENGTH) {\n throw new WorkflowOptionsError(\n `Error: comment content file must be at most ${MAX_COMMENT_CONTENT_LENGTH} characters.`,\n )\n }\n return content\n}\n\nfunction parseAssigneeBody(options: AssigneeOptions, allowClear: boolean): Record<string, number | null> {\n const hasClear = options.clear === true\n const humanId = parseOptionalPositiveInteger(options.humanId, '--human-id')\n const assistantId = parseOptionalPositiveInteger(options.assistantId, '--assistant-id')\n const teammateId = parseOptionalPositiveInteger(options.teammateId, '--teammate-id')\n const count =\n (humanId !== undefined ? 1 : 0) + (assistantId !== undefined ? 1 : 0) + (teammateId !== undefined ? 1 : 0)\n if (hasClear && !allowClear) {\n throw new WorkflowOptionsError('Error: --clear is not supported here.')\n }\n if (hasClear && count > 0) {\n throw new WorkflowOptionsError('Error: --clear cannot be used with assignee ID options.')\n }\n if (count > 1) {\n throw new WorkflowOptionsError('Error: assignee ID options are mutually exclusive.')\n }\n if (hasClear) return {}\n if (humanId !== undefined) return { assigneeHumanId: humanId }\n if (assistantId !== undefined) return { assigneeAiAssistantId: assistantId }\n if (teammateId !== undefined) return { assigneeAiTeammateId: teammateId }\n return {}\n}\n\nfunction parsePreferredAssigneeBody(options: PreferredAssigneeOptions): Record<string, number | null> {\n const hasClear = options.clearPreferredAssignee === true\n const humanId = parseOptionalPositiveInteger(options.preferredHumanId, '--preferred-human-id')\n const assistantId = parseOptionalPositiveInteger(options.preferredAssistantId, '--preferred-assistant-id')\n const teammateId = parseOptionalPositiveInteger(options.preferredTeammateId, '--preferred-teammate-id')\n const count =\n (humanId !== undefined ? 1 : 0) + (assistantId !== undefined ? 1 : 0) + (teammateId !== undefined ? 1 : 0)\n if (hasClear && count > 0) {\n throw new WorkflowOptionsError('Error: --clear-preferred-assignee cannot be used with preferred assignee ID options.')\n }\n if (count > 1) {\n throw new WorkflowOptionsError('Error: preferred assignee ID options are mutually exclusive.')\n }\n if (hasClear) return { preferredAssigneeHumanId: null }\n if (humanId !== undefined) return { preferredAssigneeHumanId: humanId }\n if (assistantId !== undefined) return { preferredAssigneeAiAssistantId: assistantId }\n if (teammateId !== undefined) return { preferredAssigneeAiTeammateId: teammateId }\n return {}\n}\n\nfunction assertNonEmptyBody(body: Record<string, unknown>): void {\n if (Object.keys(body).length === 0) {\n throw new WorkflowOptionsError('Error: at least one update option must be provided.')\n }\n}\n\nfunction buildQuery(params: Record<string, string | number | undefined>): string {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n query.set(key, String(value))\n }\n }\n const text = query.toString()\n return text ? `?${text}` : ''\n}\n\nfunction failResponse(response: { status: number; data: unknown }): never {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n}\n\nfunction priorityLabel(value: WorkflowTaskPriorityValue): string {\n switch (value) {\n case 0: return 'urgent'\n case 1: return 'high'\n case 2: return 'medium'\n case 3: return 'low'\n default: {\n const unsupportedValue: never = value\n throw new Error(`Unsupported workflow task priority: ${String(unsupportedValue)}`)\n }\n }\n}\n\nfunction statusTypeLabel(value: WorkflowStatusTypeValue): string {\n switch (value) {\n case 1: return 'todo'\n case 2: return 'in-progress'\n case 3: return 'done'\n default: {\n const unsupportedValue: never = value\n throw new Error(`Unsupported workflow status type: ${String(unsupportedValue)}`)\n }\n }\n}\n\nfunction formatAssignee(assignee: AssigneeInfo | null): string {\n if (!assignee) return '-'\n if (assignee.type === 'human') return assignee.displayName ?? `human:${assignee.humanId}`\n if (assignee.type === 'assistant') return assignee.displayName ?? `assistant:${assignee.aiAssistantId}`\n if (assignee.type === 'teammate') return assignee.displayName ?? `teammate:${assignee.aiTeammateId}`\n return 'unknown'\n}\n\nfunction printWorkflow(item: WorkflowItem): void {\n print(`${colors.bold}${item.fileId}${colors.reset}\\towner=${item.ownerHumanId ?? '-'}\\tdesc=${item.desc ?? '-'}`)\n}\n\ntype DetailScalar = string | number | boolean | null\n\nfunction indentation(size: number): string {\n return ' '.repeat(size)\n}\n\nfunction escapeTerminalControlCharacters(value: string): string {\n return value\n .replace(/\\r\\n/g, '\\n')\n .replace(/[\\u0000-\\u0008\\u000B-\\u001F\\u007F-\\u009F]/g, (character) =>\n `\\\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`,\n )\n}\n\nfunction formatDetailScalar(value: DetailScalar): string {\n if (value === null) return 'null'\n if (typeof value === 'string') {\n const escaped = escapeTerminalControlCharacters(value)\n if (escaped === '') return '\"\"'\n if (/\\n/.test(escaped)) return JSON.stringify(escaped)\n return escaped\n }\n return String(value)\n}\n\nfunction printDetailField(name: string, value: DetailScalar, indent = 0): void {\n print(`${indentation(indent)}${name}: ${formatDetailScalar(value)}`)\n}\n\nfunction printDetailTextField(name: string, value: string | null, indent = 0): void {\n if (value === null || value === '') {\n printDetailField(name, value, indent)\n return\n }\n\n const escaped = escapeTerminalControlCharacters(value)\n print(`${indentation(indent)}${name}:`)\n for (const line of escaped.split('\\n')) {\n print(`${indentation(indent + 2)}${line}`)\n }\n}\n\nfunction printAssigneeDetail(name: string, assignee: AssigneeInfo | null, indent = 0): void {\n if (assignee === null) {\n printDetailField(name, null, indent)\n return\n }\n\n print(`${indentation(indent)}${name}:`)\n printDetailField('type', assignee.type, indent + 2)\n switch (assignee.type) {\n case 'human':\n printDetailField('humanId', assignee.humanId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'assistant':\n printDetailField('aiAssistantId', assignee.aiAssistantId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'teammate':\n printDetailField('aiTeammateId', assignee.aiTeammateId, indent + 2)\n printDetailField('displayName', assignee.displayName, indent + 2)\n printDetailField('avatarUrl', assignee.avatarUrl, indent + 2)\n return\n case 'unknown':\n printDetailField('humanId', assignee.humanId, indent + 2)\n printDetailField('aiAssistantId', assignee.aiAssistantId, indent + 2)\n printDetailField('aiTeammateId', assignee.aiTeammateId, indent + 2)\n }\n}\n\nfunction printStatusRemainingFields(item: WorkflowStatusItem, indent: number): void {\n printDetailField('name', item.name, indent)\n printDetailTextField('desc', item.desc, indent)\n printDetailField('type', `${item.type} (${statusTypeLabel(item.type)})`, indent)\n printAssigneeDetail('preferredAssignee', item.preferredAssignee, indent)\n printDetailField('order', item.order, indent)\n}\n\nfunction printStatusDetail(item: WorkflowStatusItem): void {\n print(`${colors.bold}Status${colors.reset}`)\n printDetailField('scopedId', item.scopedId)\n printStatusRemainingFields(item, 0)\n}\n\nfunction printWorkflowDetail(item: WorkflowDetailResponse): void {\n print(`${colors.bold}Workflow${colors.reset}`)\n printDetailField('fileId', item.fileId)\n printDetailField('ownerHumanId', item.ownerHumanId)\n printDetailTextField('desc', item.desc)\n\n if (item.statusList.length === 0) {\n print('statusList: []')\n } else {\n print('statusList:')\n for (const status of item.statusList) {\n print(` - scopedId: ${status.scopedId}`)\n printStatusRemainingFields(status, 4)\n }\n }\n\n if (item.transitions.length === 0) {\n print('transitions: []')\n } else {\n print('transitions:')\n for (const transition of item.transitions) {\n print(` - statusFromScopedId: ${transition.statusFromScopedId}`)\n printDetailField('statusToScopedId', transition.statusToScopedId, 4)\n }\n }\n}\n\nfunction printTaskSummary(item: WorkflowTaskItem): void {\n const runIds = item.runningAgentRuns.map((run) => run.pipelineId).join(',') || '-'\n print(\n `${colors.bold}#${item.scopedId}${colors.reset}\\t${item.title}\\tstatus=${item.statusScopedId}\\tpriority=${priorityLabel(item.priority)}\\tassignee=${formatAssignee(item.assignee)}\\truns=${runIds}`,\n )\n}\n\nfunction printTaskDetail(item: WorkflowTaskItem): void {\n print(`${colors.bold}Task${colors.reset}`)\n printDetailField('scopedId', item.scopedId)\n printDetailField('workflowFileId', item.workflowFileId)\n printDetailField('ownerHumanId', item.ownerHumanId)\n printDetailField('title', item.title)\n printDetailTextField('desc', item.desc)\n printDetailField('statusScopedId', item.statusScopedId)\n printDetailField('priority', `${item.priority} (${priorityLabel(item.priority)})`)\n printAssigneeDetail('assignee', item.assignee)\n\n if (item.linkedFileIds.length === 0) {\n print('linkedFileIds: []')\n } else {\n print('linkedFileIds:')\n for (const fileId of item.linkedFileIds) print(` - ${fileId}`)\n }\n\n printDetailField('subscribed', item.subscribed)\n if (item.runningAgentRuns.length === 0) {\n print('runningAgentRuns: []')\n } else {\n print('runningAgentRuns:')\n for (const run of item.runningAgentRuns) {\n print(` - pipelineId: ${run.pipelineId}`)\n printAssigneeDetail('executor', run.executor, 4)\n }\n }\n printDetailField('createdAt', item.createdAt)\n printDetailField('latestActAt', item.latestActAt)\n}\n\nfunction printCommentDetail(item: WorkflowCommentItem): void {\n print(`${colors.bold}Comment${colors.reset}`)\n printDetailField('id', item.id)\n printDetailField('workflowFileId', item.workflowFileId)\n printDetailField('workflowTaskScopedId', item.workflowTaskScopedId)\n printDetailTextField('content', item.content)\n printAssigneeDetail('createdBy', item.createdBy)\n printDetailField('createdAt', item.createdAt)\n printDetailField('updatedAt', item.updatedAt)\n}\n\nexport function registerWorkflowCommand(program: Command): void {\n const workflow = program.command('workflow').description('Workflow operations')\n\n addWorkspaceOption(\n workflow.command('list')\n .description('List accessible workflows')\n .option('--scope <scope>', 'Workflow scope: all or owner_is_me', 'all'),\n ).action(async (options: { workspace: string; scope?: string }) => {\n const scope = runOrExit(() => parseWorkflowScope(options.scope))\n\n startSpinner('Fetching workflows...')\n const response = await httpGet<WorkflowListResponse>(\n `/workspaces/${options.workspace}/workflows${buildQuery({ scope })}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.workflows.length === 0) {\n stopSpinner(true, 'No workflows found.')\n return\n }\n stopSpinner(true, `Found ${response.data.workflows.length} workflow(s)`)\n for (const item of response.data.workflows) printWorkflow(item)\n })\n\n addSpaceOptions(\n workflow.command('create')\n .description('Create a blank workflow')\n .requiredOption('-p, --path <path>', 'Target .workflow path')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for workflow description')\n .option('--owner-human-id <humanId>', 'Workflow owner human ID'),\n ).action(async (options: WorkflowSpaceOptions) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n path: options.path,\n ...resolveSpaceSelector(options),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n return next\n })\n\n startSpinner('Creating workflow...')\n const response = await httpPost<WorkflowItem>(`/workspaces/${options.workspace}/workflows`, body)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow created')\n printWorkflow(response.data)\n })\n\n addWorkspaceOption(workflow.command('get').description('Get a workflow').argument('<workflowFileId>')).action(\n async (workflowFileId: string, options: { workspace: string }) => {\n startSpinner('Fetching workflow...')\n const response = await httpGet<WorkflowDetailResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow fetched')\n printWorkflowDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n workflow.command('update')\n .description('Update workflow metadata')\n .argument('<workflowFileId>')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for workflow description')\n .option('--owner-human-id <humanId>', 'Workflow owner human ID'),\n ).action(async (workflowFileId: string, options: { workspace: string; descFile?: string; ownerHumanId?: string }) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {}\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n assertNonEmptyBody(next)\n return next\n })\n\n startSpinner('Updating workflow...')\n const response = await httpPatch<WorkflowItem>(`/workspaces/${options.workspace}/workflows/${workflowFileId}`, body)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow updated')\n printWorkflow(response.data)\n })\n\n addWorkspaceOption(\n workflow.command('delete')\n .description('Delete a workflow')\n .argument('<workflowFileId>')\n .option('--message <message>', 'Commit message'),\n ).action(async (workflowFileId: string, options: { workspace: string; message?: string }) => {\n startSpinner('Deleting workflow...')\n const response = await httpDelete<{ fileId: string }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}`,\n options.message ? { message: options.message } : {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.fileId}`)\n })\n\n addWorkspaceOption(workflow.command('duplicate').description('Duplicate a workflow').argument('<workflowFileId>')).action(\n async (workflowFileId: string, options: { workspace: string }) => {\n startSpinner('Duplicating workflow...')\n const response = await httpPost<WorkflowItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/duplicate`,\n {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Workflow duplicated')\n printWorkflow(response.data)\n },\n )\n\n registerStatusCommands(workflow)\n registerTransitionCommands(workflow)\n registerTaskCommands(workflow)\n registerCommentCommands(workflow)\n registerRunCommands(workflow)\n}\n\nfunction registerStatusCommands(workflow: Command): void {\n const status = workflow.command('status').description('Workflow status operations')\n\n addPreferredAssigneeOptions(\n addWorkspaceOption(\n status.command('create')\n .description('Create a workflow status')\n .argument('<workflowFileId>')\n .requiredOption('--name <name>', 'Status name')\n .requiredOption('--type <type>', 'Status type value: 1=todo, 2=in-progress, 3=done')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for status description'),\n ),\n ).action(\n async (\n workflowFileId: string,\n options: { workspace: string; name: string; type?: string; descFile?: string } & PreferredAssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n name: options.name,\n type: parseRequiredStatusType(options.type),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n Object.assign(next, parsePreferredAssigneeBody(options))\n return next\n })\n startSpinner('Creating status...')\n const response = await httpPost<WorkflowStatusItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status created')\n printStatusDetail(response.data)\n },\n )\n\n addPreferredAssigneeOptions(\n addWorkspaceOption(\n status.command('update')\n .description('Update a workflow status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>')\n .option('--name <name>', 'Status name')\n .option('--type <type>', 'Status type value: 1=todo, 2=in-progress, 3=done')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for status description')\n .option('--clear-desc', 'Clear status description')\n .option('--clear-preferred-assignee', 'Clear preferred assignee'),\n ),\n ).action(\n async (\n workflowFileId: string,\n statusScopedId: string,\n options: {\n workspace: string\n name?: string\n type?: string\n descFile?: string\n clearDesc?: boolean\n } & PreferredAssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n if (options.descFile && options.clearDesc) {\n throw new WorkflowOptionsError('Error: --desc-file cannot be used with --clear-desc.')\n }\n const next: Record<string, unknown> = {}\n if (options.name) next.name = options.name\n const type = parseStatusType(options.type)\n if (type !== undefined) next.type = type\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n if (options.clearDesc) next.desc = null\n Object.assign(next, parsePreferredAssigneeBody(options))\n assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(statusScopedId, 'statusScopedId'))\n startSpinner('Updating status...')\n const response = await httpPatch<WorkflowStatusItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status updated')\n printStatusDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n status.command('move-after')\n .description('Move a workflow status after another status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>')\n .option('--after <statusScopedId>', 'Anchor status scoped ID')\n .option('--first', 'Move to first position'),\n ).action(\n async (\n workflowFileId: string,\n statusScopedId: string,\n options: { workspace: string; after?: string; first?: boolean },\n ) => {\n const { id, anchoredStatusScopedId } = runOrExit(() => {\n if (options.after && options.first) {\n throw new WorkflowOptionsError('Error: --after cannot be used with --first.')\n }\n if (!options.after && !options.first) {\n throw new WorkflowOptionsError('Error: either --after or --first is required.')\n }\n return {\n id: parsePositiveInteger(statusScopedId, 'statusScopedId'),\n anchoredStatusScopedId: options.first ? null : parsePositiveInteger(options.after!, '--after'),\n }\n })\n startSpinner('Moving status...')\n const response = await httpPost<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}/move-after`,\n { anchoredStatusScopedId },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Status moved')\n },\n )\n\n addWorkspaceOption(\n status.command('delete')\n .description('Delete a workflow status')\n .argument('<workflowFileId>')\n .argument('<statusScopedId>'),\n ).action(async (workflowFileId: string, statusScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(statusScopedId, 'statusScopedId'))\n startSpinner('Deleting status...')\n const response = await httpDelete<{ scopedId: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/statuses/${id}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.scopedId}`)\n })\n}\n\nfunction registerTransitionCommands(workflow: Command): void {\n const transition = workflow.command('transition').description('Workflow transition operations')\n\n for (const action of ['create', 'delete'] as const) {\n addWorkspaceOption(\n transition.command(action)\n .description(`${action === 'create' ? 'Create' : 'Delete'} a workflow transition`)\n .argument('<workflowFileId>')\n .requiredOption('--from <statusScopedId>', 'Source status scoped ID')\n .requiredOption('--to <statusScopedId>', 'Target status scoped ID'),\n ).action(async (workflowFileId: string, options: { workspace: string; from: string; to: string }) => {\n const body = runOrExit(() => ({\n statusFromScopedId: parsePositiveInteger(options.from, '--from'),\n statusToScopedId: parsePositiveInteger(options.to, '--to'),\n }))\n startSpinner(`${action === 'create' ? 'Creating' : 'Deleting'} transition...`)\n const response =\n action === 'create'\n ? await httpPost<WorkflowTransitionItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/transitions`,\n body,\n )\n : await httpDelete<WorkflowTransitionItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/transitions`,\n body,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, action === 'create' ? 'Transition created' : 'Transition deleted')\n print(`${response.data.statusFromScopedId} -> ${response.data.statusToScopedId}`)\n })\n }\n}\n\nfunction registerTaskCommands(workflow: Command): void {\n const task = workflow.command('task').description('Workflow task operations')\n\n addWorkspaceOption(\n task.command('list')\n .description('List workflow tasks')\n .option('--workflow-file-id <workflowFileId>', 'Filter by workflow file ID')\n .option('--scope <scope>', 'Task scope', 'all')\n .option('-l, --limit <limit>', 'Maximum number of tasks to return', '20')\n .option('--cursor <cursor>', 'Pagination cursor'),\n ).action(\n async (options: { workspace: string; workflowFileId?: string; scope?: string; limit?: string; cursor?: string }) => {\n const query = runOrExit(() => buildQuery({\n scope: parseTaskScope(options.scope),\n limit: parseSearchLimit(options.limit, 20, 100),\n cursor: options.cursor,\n workflowFileId: options.workflowFileId,\n }))\n startSpinner('Fetching workflow tasks...')\n const response = await httpGet<WorkflowTaskListResponse>(`/workspaces/${options.workspace}/workflow-tasks-v2${query}`)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.tasks.length === 0) {\n stopSpinner(true, 'No workflow tasks found.')\n return\n }\n stopSpinner(true, `Found ${response.data.tasks.length} task(s)`)\n for (const item of response.data.tasks) printTaskSummary(item)\n if (response.data.nextCursor) print(`${colors.dim}nextCursor=${response.data.nextCursor}${colors.reset}`)\n },\n )\n\n addWorkspaceOption(\n task.command('get')\n .description('Get a workflow task')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Fetching task...')\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task fetched')\n printTaskDetail(response.data)\n })\n\n addAssigneeOptions(\n addWorkspaceOption(\n task.command('create')\n .description('Create a workflow task')\n .argument('<workflowFileId>')\n .requiredOption('--title <title>', 'Task title')\n .requiredOption('--status <statusScopedId>', 'Status scoped ID')\n .option('--priority <priority>', 'Priority: urgent, high, medium, or low', 'medium')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for task description')\n .option('--owner-human-id <humanId>', 'Task owner human ID')\n ),\n ).action(\n async (\n workflowFileId: string,\n options: {\n workspace: string\n title: string\n status: string\n priority?: string\n descFile?: string\n ownerHumanId?: string\n } & AssigneeOptions,\n ) => {\n const body = runOrExit(() => {\n const next: Record<string, unknown> = {\n title: options.title,\n statusScopedId: parsePositiveInteger(options.status, '--status'),\n priority: parseRequiredPriority(options.priority),\n }\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n Object.assign(next, parseAssigneeBody(options, false))\n return next\n })\n startSpinner('Creating task...')\n const createResponse = await httpPost<WorkflowTaskCreateResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2`,\n body,\n )\n if (!createResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(createResponse)\n }\n const response = await getWorkflowTask(\n options.workspace,\n workflowFileId,\n createResponse.data.taskScopedId,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task created')\n printTaskDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n task.command('update')\n .description('Update workflow task metadata')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .option('--title <title>', 'Task title')\n .option('--priority <priority>', 'Priority: urgent, high, medium, or low')\n .option('--desc-file <localPath>', 'Local UTF-8 text file for task description')\n .option('--clear-desc', 'Clear task description')\n .option('--owner-human-id <humanId>', 'Task owner human ID')\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: {\n workspace: string\n title?: string\n priority?: string\n descFile?: string\n clearDesc?: boolean\n ownerHumanId?: string\n },\n ) => {\n const body = runOrExit(() => {\n if (options.descFile && options.clearDesc) {\n throw new WorkflowOptionsError('Error: --desc-file cannot be used with --clear-desc.')\n }\n const next: Record<string, unknown> = {}\n if (options.title) next.title = options.title\n const priority = parsePriority(options.priority)\n if (priority !== undefined) next.priority = priority\n const desc = readDescFile(options.descFile)\n if (desc !== undefined) next.desc = desc\n if (options.clearDesc) next.desc = null\n const ownerHumanId = parseOptionalPositiveInteger(options.ownerHumanId, '--owner-human-id')\n if (ownerHumanId !== undefined) next.ownerHumanId = ownerHumanId\n assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Updating task...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/metadata`,\n body,\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task updated')\n printTaskDetail(response.data)\n },\n )\n\n for (const action of ['add-linked-files', 'remove-linked-files'] as const) {\n addWorkspaceOption(\n task.command(action)\n .description(`${action === 'add-linked-files' ? 'Add' : 'Remove'} linked files on a workflow task`)\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--file-ids <ids>', 'Comma-separated file IDs'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: { workspace: string; fileIds: string },\n ) => {\n const { id, fileIds } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n fileIds: parseFileIds(options.fileIds, '--file-ids')!,\n }))\n startSpinner(action === 'add-linked-files' ? 'Adding linked files...' : 'Removing linked files...')\n const path = `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/linked-files`\n const updateResponse =\n action === 'add-linked-files'\n ? await httpPost<void>(path, { fileIds })\n : await httpDelete<void>(path, { fileIds })\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, action === 'add-linked-files' ? 'Linked files added' : 'Linked files removed')\n printTaskDetail(response.data)\n },\n )\n }\n\n addWorkspaceOption(\n task.command('move')\n .description('Move a workflow task to another status')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--status <statusScopedId>', 'Target status scoped ID'),\n ).action(\n async (workflowFileId: string, taskScopedId: string, options: { workspace: string; status: string }) => {\n const { id, statusScopedId } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n statusScopedId: parsePositiveInteger(options.status, '--status'),\n }))\n startSpinner('Moving task...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/status`,\n { statusScopedId },\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task moved')\n printTaskDetail(response.data)\n },\n )\n\n addAssigneeOptions(\n addWorkspaceOption(\n task.command('assign')\n .description('Update workflow task assignee')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .option('--clear', 'Clear assignee'),\n ),\n ).action(\n async (workflowFileId: string, taskScopedId: string, options: { workspace: string } & AssigneeOptions) => {\n const body = runOrExit(() => {\n const next = parseAssigneeBody(options, true)\n if (Object.keys(next).length === 0 && options.clear !== true) assertNonEmptyBody(next)\n return next\n })\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Updating task assignee...')\n const updateResponse = await httpPatch<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks-v2/${id}/assignee`,\n body,\n )\n if (!updateResponse.ok) {\n stopSpinner(false, 'Failed')\n failResponse(updateResponse)\n }\n const response = await getWorkflowTask(options.workspace, workflowFileId, id)\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Task assignee updated')\n printTaskDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n task.command('delete')\n .description('Delete a workflow task')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Deleting task...')\n const response = await httpDelete<{ scopedId: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.scopedId}`)\n })\n}\n\nfunction getWorkflowTask(workspaceId: string, workflowFileId: string, taskScopedId: number) {\n return httpGet<WorkflowTaskItem>(\n `/workspaces/${workspaceId}/workflows/${workflowFileId}/tasks-v2/${taskScopedId}`,\n )\n}\n\nfunction registerCommentCommands(workflow: Command): void {\n const comment = workflow.command('comment').description('Workflow task comment operations')\n\n addWorkspaceOption(\n comment.command('create')\n .description('Create a workflow task comment')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .requiredOption('--content-path <localPath>', 'Local UTF-8 text file for comment content'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n options: { workspace: string; contentPath: string },\n ) => {\n const { id, content } = runOrExit(() => ({\n id: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n content: readCommentContentFile(options.contentPath),\n }))\n startSpinner('Creating comment...')\n const response = await httpPost<WorkflowCommentItem>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}/comments`,\n { content },\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, 'Comment created')\n printCommentDetail(response.data)\n },\n )\n\n addWorkspaceOption(\n comment.command('list')\n .description('List workflow task comments')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>'),\n ).action(async (workflowFileId: string, taskScopedId: string, options: { workspace: string }) => {\n const id = runOrExit(() => parsePositiveInteger(taskScopedId, 'taskScopedId'))\n startSpinner('Fetching comments...')\n const response = await httpGet<WorkflowCommentListResponse>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${id}/comments`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n if (response.data.items.length === 0) {\n stopSpinner(true, 'No comments found.')\n return\n }\n stopSpinner(true, `Found ${response.data.items.length} comment(s)`)\n response.data.items.forEach((item, index) => {\n if (index > 0) print('')\n printCommentDetail(item)\n })\n })\n\n addWorkspaceOption(\n comment.command('delete')\n .description('Delete a workflow task comment')\n .argument('<workflowFileId>')\n .argument('<taskScopedId>')\n .argument('<commentId>'),\n ).action(\n async (\n workflowFileId: string,\n taskScopedId: string,\n commentId: string,\n options: { workspace: string },\n ) => {\n const ids = runOrExit(() => ({\n task: parsePositiveInteger(taskScopedId, 'taskScopedId'),\n comment: parsePositiveInteger(commentId, 'commentId'),\n }))\n startSpinner('Deleting comment...')\n const response = await httpDelete<{ id: number }>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/tasks/${ids.task}/comments/${ids.comment}`,\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Deleted: ${response.data.id}`)\n },\n )\n}\n\nfunction registerRunCommands(workflow: Command): void {\n const run = workflow.command('run').description('Workflow agent run operations')\n\n addWorkspaceOption(\n run.command('abort')\n .description('Abort a workflow agent run')\n .argument('<workflowFileId>')\n .argument('<pipelineId>'),\n ).action(async (workflowFileId: string, pipelineId: string, options: { workspace: string }) => {\n startSpinner('Aborting run...')\n const response = await httpPost<void>(\n `/workspaces/${options.workspace}/workflows/${workflowFileId}/pipeline/${pipelineId}/abort`,\n {},\n )\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n failResponse(response)\n }\n stopSpinner(true, `Abort accepted: ${pipelineId}`)\n })\n}\n","import { arch, platform } from 'node:os'\nimport { getApiBaseUrl, getApiKeyOrUndefined } from '../utils/config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport type MetricType = 'counter' | 'gauge' | 'histogram'\n\nexport interface MetricRecord {\n metric_id: string\n metric_type: MetricType\n value: number\n extra_label_name_2_value?: Record<string, string>\n}\n\nconst buffer: MetricRecord[] = []\nconst FLUSH_TIMEOUT_MS = 3000\nconst MAX_BATCH_SIZE = 100\n\nfunction commonLabels(): Record<string, string> {\n return {\n cli_version: __CLI_VERSION__,\n node_version: process.versions.node,\n os: platform(),\n arch: arch(),\n is_ci: isCiEnvironment() ? 'true' : 'false',\n }\n}\n\nexport function record(metric: MetricRecord): void {\n if (isTelemetryDisabled()) {\n debugLog(`record: disabled, dropping ${metric.metric_id}`)\n return\n }\n if (!getApiKeyOrUndefined()) {\n debugLog(`record: no API key, dropping ${metric.metric_id}`)\n return\n }\n buffer.push({\n ...metric,\n extra_label_name_2_value: {\n ...commonLabels(),\n ...(metric.extra_label_name_2_value ?? {}),\n },\n })\n debugLog(`record: buffered ${metric.metric_id} (buffer=${buffer.length})`)\n}\n\nfunction isDebug(): boolean {\n return process.env.MOXT_TELEMETRY_DEBUG === '1' || process.env.MOXT_TELEMETRY_DEBUG === 'true'\n}\n\nfunction debugLog(msg: string, detail?: unknown): void {\n if (!isDebug()) return\n process.stderr.write(`[telemetry] ${msg}${detail !== undefined ? ` ${JSON.stringify(detail)}` : ''}\\n`)\n}\n\nexport async function flush(): Promise<void> {\n if (buffer.length === 0) {\n debugLog('flush: buffer empty, skipping')\n return\n }\n const apiKey = getApiKeyOrUndefined()\n if (!apiKey) {\n debugLog('flush: no API key, dropping buffer')\n buffer.length = 0\n return\n }\n\n const batch = buffer.splice(0, MAX_BATCH_SIZE)\n const payload = {\n release_id: __CLI_VERSION__,\n client_type: 'cli',\n metric_data_list: batch.map((m) => ({\n profile: 'cli',\n metric_id: m.metric_id,\n metric_type: m.metric_type,\n value: m.value,\n extra_label_name_2_value: m.extra_label_name_2_value,\n })),\n }\n\n const url = `${getApiBaseUrl()}/cli-metrics`\n debugLog(`flush: POST ${url} with ${batch.length} metrics`, payload)\n\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => {\n controller.abort()\n }, FLUSH_TIMEOUT_MS)\n try {\n const res = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify(payload),\n signal: controller.signal,\n })\n debugLog(`flush: response status=${res.status}`)\n } finally {\n clearTimeout(timeout)\n }\n } catch (err) {\n debugLog('flush: failed', err instanceof Error ? err.message : String(err))\n // fire-and-forget — never surface telemetry failures to the user\n }\n}\n","import { readTelemetryConfig, writeTelemetryConfig } from './config.js'\nimport { isCiEnvironment, isTelemetryDisabled } from './opt-out.js'\n\nconst NOTICE = [\n '',\n 'Attention: Moxt CLI now collects anonymous telemetry regarding usage.',\n \"This information is used to shape Moxt CLI's roadmap and prioritize features.\",\n '',\n 'You may opt out by setting MOXT_TELEMETRY_DISABLED=1 in your env',\n 'or by running `moxt telemetry disable`.',\n 'Details: https://www.npmjs.com/package/@moxt-ai/cli#telemetry',\n '',\n]\n\nexport function maybeShowTelemetryNotice(): void {\n if (isTelemetryDisabled()) return\n if (isCiEnvironment()) return\n if (readTelemetryConfig().noticeShown) return\n\n for (const line of NOTICE) {\n process.stderr.write(`${line}\\n`)\n }\n\n try {\n writeTelemetryConfig({ noticeShown: true })\n } catch {\n // persistence failure is not user-visible — we'll just show the notice again next run\n }\n}\n","import type { Command } from 'commander'\nimport { flush, record } from './client.js'\nimport { maybeShowTelemetryNotice } from './notice.js'\n\ninterface RunningCommand {\n name: string\n subcommand?: string\n startedAt: number\n}\n\nlet current: RunningCommand | null = null\n\nfunction commandPath(cmd: Command): { command: string; subcommand?: string } {\n const names: string[] = []\n let node: Command | null = cmd\n while (node && node.parent) {\n names.unshift(node.name())\n node = node.parent\n }\n if (names.length === 0) return { command: 'unknown' }\n if (names.length === 1) return { command: names[0] }\n return { command: names[0], subcommand: names.slice(1).join(' ') }\n}\n\nexport function instrumentProgram(program: Command): void {\n program.hook('preAction', (_thisCommand, actionCommand) => {\n const { command, subcommand } = commandPath(actionCommand)\n if (command !== 'telemetry') {\n maybeShowTelemetryNotice()\n }\n current = { name: command, subcommand, startedAt: Date.now() }\n record({\n metric_id: 'client.cli.command_invocation.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command,\n ...(subcommand ? { subcommand } : {}),\n status: 'started',\n },\n })\n })\n\n program.hook('postAction', async () => {\n await reportOutcome('success')\n })\n}\n\nasync function reportOutcome(status: 'success' | 'error', errorCode?: string): Promise<void> {\n if (!current) return\n const { name, subcommand, startedAt } = current\n const durationSeconds = (Date.now() - startedAt) / 1000\n\n record({\n metric_id: 'client.cli.command_duration_seconds',\n metric_type: 'histogram',\n value: durationSeconds,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n status,\n },\n })\n\n if (status === 'error') {\n record({\n metric_id: 'client.cli.command_error.count',\n metric_type: 'counter',\n value: 1,\n extra_label_name_2_value: {\n command: name,\n ...(subcommand ? { subcommand } : {}),\n ...(errorCode ? { error_code: errorCode } : {}),\n },\n })\n }\n\n current = null\n await flush()\n}\n\n/**\n * Wire a final error/exit hook. Call before program.parseAsync so we can capture\n * failures routed through process.exit or unhandled rejections.\n *\n * Best-effort only: `reportOutcome` is fire-and-forget, and the subsequent\n * `process.exit(1)` terminates the process before `flush()` can complete — so\n * the error metric recorded here will typically be dropped. Reliable crash\n * reporting belongs to Sentry/APM, not this telemetry path.\n */\nexport function installExitHandler(): void {\n const handleError = (errorCode: string): void => {\n void reportOutcome('error', errorCode)\n }\n\n process.on('uncaughtException', () => {\n handleError('uncaught_exception')\n process.exit(1)\n })\n process.on('unhandledRejection', () => {\n handleError('unhandled_rejection')\n process.exit(1)\n })\n}\n"],"mappings":";;;AAAA,OAAO,oBAAoB;;;ACA3B,SAAS,eAAe;;;ACAxB,YAAYA,SAAQ;;;ACApB,YAAY,QAAQ;AACpB,SAAS,mBAAmB;;;AC2BrB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EACzC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAQO,SAAS,qBAAqB,SAAoC;AAIrE,QAAM,EAAE,OAAO,aAAa,WAAW,IAAI;AAC3C,QAAM,gBAAgB,QAAQ,aAAa;AAO3C,QAAM,aAAa,SAAS,QAAQ,UAAU;AAC9C,QAAM,mBAAmB,eAAe,QAAQ,gBAAgB;AAChE,QAAM,kBAAkB,cAAc,QAAQ,eAAe;AAC7D,QAAM,iBACD,aAAa,IAAI,MAAM,gBAAgB,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oBAAoB;AAChC,YAAQ,KAAK,CAAC;AAAA,EAClB,CAAC;AACD,UAAQ,GAAG,sBAAsB,MAAM;AACnC,gBAAY,qBAAqB;AACjC,YAAQ,KAAK,CAAC;AAAA,EAClB,CAAC;AACL;;;AtBhGA,eAAe;AAAA,EACX,KAAK,EAAE,MAAM,gBAAgB,SAAS,QAAgB;AAC1D,CAAC,EAAE,OAAO;AAEV,IAAM,UAAU,cAAc,OAAe;AAE7C,kBAAkB,OAAO;AACzB,mBAAmB;AAEnB,QACK,WAAW,QAAQ,IAAI,EACvB,KAAK,YAAY;AACd,QAAM,MAAM;AAChB,CAAC,EACA,MAAM,OAAO,QAAiB;AAC3B,UAAQ,MAAM,cAAc,GAAG;AAC/B,QAAM,MAAM;AACZ,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["fs","path","buffer","path","path","buffer","runOrExit","program","runOrExit","path","buffer","program","runOrExit","path","runOrExit","path","program","fs","program","program","program","members","fs","TextDecoder","runOrExit","addSpaceOptions","path","buffer","readCommentContentFile","TextDecoder","indentation","escapeTerminalControlCharacters","formatDetailScalar","printDetailField","printDetailTextField","program","program","arch","platform","platform","arch","program"]}
|