crewx 0.9.0-rc.2 → 0.9.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/MarketPage-DDPL2d7x.js +36 -0
- package/dist/assets/{PromptTab-hdXDbbT6.js → PromptTab-UC3K4qx2.js} +3 -3
- package/dist/assets/{arc--CBVVcyH.js → arc-DdP3-fUR.js} +1 -1
- package/dist/assets/{architectureDiagram-UYN6MBPD-DUiYwqJn.js → architectureDiagram-UYN6MBPD-D16VON1i.js} +1 -1
- package/dist/assets/{blockDiagram-ZHA2E4KO-DV86vAgG.js → blockDiagram-ZHA2E4KO-qs1dIRkl.js} +4 -4
- package/dist/assets/{c4Diagram-6F5ED5ID-CvWE7Cx_.js → c4Diagram-6F5ED5ID-BeDy8akQ.js} +1 -1
- package/dist/assets/channel-DtrxBSkc.js +1 -0
- package/dist/assets/{chunk-5HRBRIJM-DAxM5Ul_.js → chunk-5HRBRIJM-BC1zIb11.js} +1 -1
- package/dist/assets/{chunk-7U56Z5CX-BuYaEj8L.js → chunk-7U56Z5CX-BuGil3QD.js} +1 -1
- package/dist/assets/{chunk-ASOPGD6M-2Kx0e45C.js → chunk-ASOPGD6M-DmKdDtBQ.js} +1 -1
- package/dist/assets/{chunk-KFBOBJHC-CR4QS6Rt.js → chunk-KFBOBJHC-D3BvHLPa.js} +1 -1
- package/dist/assets/{chunk-T2TOU4HS-CffcwNHx.js → chunk-T2TOU4HS-B5MoUp-N.js} +1 -1
- package/dist/assets/{chunk-TMUBEWPD-BGpYtekN.js → chunk-TMUBEWPD-AvWe_lsV.js} +1 -1
- package/dist/assets/classDiagram-LNE6IOMH-BMT5B_JB.js +1 -0
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-BMT5B_JB.js +1 -0
- package/dist/assets/{dagre-4EVJKHTY-yBWukkrE.js → dagre-4EVJKHTY-B6DewFyM.js} +1 -1
- package/dist/assets/{diagram-QW4FP2JN-CIr1PLq3.js → diagram-QW4FP2JN-BTsQ8JSd.js} +1 -1
- package/dist/assets/{erDiagram-6RL3IURR-xG7SygyU.js → erDiagram-6RL3IURR-BM5nvgVR.js} +1 -1
- package/dist/assets/{flowDiagram-7ASYPVHJ-CKalfOqp.js → flowDiagram-7ASYPVHJ-D1UCCuOG.js} +1 -1
- package/dist/assets/{ganttDiagram-NTVNEXSI-Bnx7zrX4.js → ganttDiagram-NTVNEXSI-CNIGs7Cn.js} +1 -1
- package/dist/assets/{gitGraph-YCYPL57B-TQlF0fiA.js → gitGraph-YCYPL57B-DSLjx1yQ.js} +1 -1
- package/dist/assets/{gitGraphDiagram-NRZ2UAAF-DxlaFkwO.js → gitGraphDiagram-NRZ2UAAF-B11zX1Fa.js} +1 -1
- package/dist/assets/{infoDiagram-A4XQUW5V-B1-arkqa.js → infoDiagram-A4XQUW5V-DkjvODYl.js} +1 -1
- package/dist/assets/{journeyDiagram-G5WM74LC-Cj439GUX.js → journeyDiagram-G5WM74LC-BkCQPMn6.js} +1 -1
- package/dist/assets/{kanban-definition-QRCXZQQD-BvrIwEIc.js → kanban-definition-QRCXZQQD-_OX7pNfJ.js} +1 -1
- package/dist/assets/{linear-BKYNK0ri.js → linear-BYjwVAR6.js} +1 -1
- package/dist/assets/main-CZdKLdUl.css +10 -0
- package/dist/assets/main-CkkZNCy-.js +1561 -0
- package/dist/assets/{mindmap-definition-GWI6TPTV-BExfJY0G.js → mindmap-definition-GWI6TPTV-BzYpSnv8.js} +1 -1
- package/dist/assets/ort-wasm-simd-threaded.asyncify-DMmc6YqF.wasm +0 -0
- package/dist/assets/{pieDiagram-YF2LJOPJ-RPWpvrC8.js → pieDiagram-YF2LJOPJ-CEFg6ao0.js} +1 -1
- package/dist/assets/{quadrantDiagram-OS5C2QUG-DmbBzk5Q.js → quadrantDiagram-OS5C2QUG-_5w2x3VV.js} +1 -1
- package/dist/assets/{requirementDiagram-MIRIMTAZ-DFQuFXq3.js → requirementDiagram-MIRIMTAZ-B_VQYReZ.js} +1 -1
- package/dist/assets/{sankeyDiagram-Y46BX6SQ-p_bw56lJ.js → sankeyDiagram-Y46BX6SQ-CgmOlLhh.js} +1 -1
- package/dist/assets/{sequenceDiagram-G6AWOVSC-DTbBkLeD.js → sequenceDiagram-G6AWOVSC-MGVt0Ai2.js} +1 -1
- package/dist/assets/{stateDiagram-MAYHULR4-DBvC6UcF.js → stateDiagram-MAYHULR4-DaZjgTu-.js} +1 -1
- package/dist/assets/stateDiagram-v2-4JROLMXI-DN1wGYkV.js +1 -0
- package/dist/assets/{timeline-definition-U7ZMHBDA-B6utvIg1.js → timeline-definition-U7ZMHBDA-CusetmK6.js} +1 -1
- package/dist/assets/transformers.web-BN8Ug43_.js +45 -0
- package/dist/assets/{xychartDiagram-6QU3TZC5-BHG0s1Ye.js → xychartDiagram-6QU3TZC5-CTndf-if.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/app.module.js +4 -0
- package/dist-server/bootstrap/codex-writable-roots.js +88 -0
- package/dist-server/bootstrap/crewx-server.js +10 -2
- package/dist-server/common/decorator/skip-request-log.decorator.js +8 -0
- package/dist-server/common/interceptor/http-logging.interceptor.js +17 -4
- package/dist-server/common/task-log/stdout-json-fallback.js +200 -0
- package/dist-server/domain/agent/agent.controller.js +14 -0
- package/dist-server/domain/agent/agent.service.js +246 -18
- package/dist-server/domain/agent/dto/create-agent.dto.js +12 -0
- package/dist-server/domain/agent/dto/remote-provider.dto.js +82 -0
- package/dist-server/domain/agent/dto/reorder-agents.dto.js +51 -0
- package/dist-server/domain/agent/dto/update-agent.dto.js +3 -1
- package/dist-server/domain/agent/provider.controller.js +12 -1
- package/dist-server/domain/doc/doc.controller.js +43 -9
- package/dist-server/domain/doc/doc.service.js +80 -6
- package/dist-server/domain/doc/image-constants.js +11 -1
- package/dist-server/domain/events/workspace-events.controller.js +2 -0
- package/dist-server/domain/message/dto/send-message.dto.js +49 -1
- package/dist-server/domain/message/message.controller.js +1 -1
- package/dist-server/domain/message/message.module.js +2 -1
- package/dist-server/domain/message/message.service.js +83 -13
- package/dist-server/domain/settings/settings.service.js +188 -1
- package/dist-server/domain/system/system.controller.js +41 -0
- package/dist-server/domain/system/system.module.js +19 -0
- package/dist-server/domain/task/task.constants.js +8 -1
- package/dist-server/domain/task/task.service.js +59 -67
- package/dist-server/domain/thread/dto/list-threads.dto.js +18 -0
- package/dist-server/domain/thread/overdrive.types.js +38 -0
- package/dist-server/domain/thread/thread.service.js +83 -70
- package/dist-server/domain/usage/usage.controller.js +18 -0
- package/dist-server/domain/usage/usage.module.js +1 -0
- package/dist-server/domain/usage/usage.service.js +246 -4
- package/dist-server/domain/usage-report/dto/usage-report.dto.js +2 -0
- package/dist-server/domain/usage-report/usage-report.controller.js +72 -0
- package/dist-server/domain/usage-report/usage-report.module.js +23 -0
- package/dist-server/domain/usage-report/usage-report.service.js +135 -0
- package/dist-server/domain/wi/wi.service.js +45 -3
- package/dist-server/main.js +1 -0
- package/dist-server/repository/repository.module.js +2 -0
- package/dist-server/repository/task.repository.js +56 -0
- package/dist-server/repository/thread.repository.js +13 -0
- package/dist-server/repository/usage-report.repository.js +27 -0
- package/package.json +9 -9
- package/packages/cli/dist/bootstrap/codex-writable-roots.d.ts +45 -0
- package/packages/cli/dist/bootstrap/codex-writable-roots.js +88 -0
- package/packages/cli/dist/bootstrap/crewx-cli.js +2 -0
- package/packages/cli/dist/commands/execute.js +10 -2
- package/packages/cli/dist/commands/parse-common-flags.d.ts +5 -1
- package/packages/cli/dist/commands/parse-common-flags.js +9 -2
- package/packages/cli/dist/commands/ps.js +51 -2
- package/packages/cli/dist/commands/query.js +10 -2
- package/packages/cli/dist/commands/restart.js +20 -6
- package/packages/cli/dist/commands/write-output.d.ts +3 -0
- package/packages/cli/dist/commands/write-output.js +24 -0
- package/packages/cli/dist/main.js +7 -0
- package/packages/cli/package.json +1 -1
- package/dist/assets/MarketPage-T1o_oIrw.js +0 -41
- package/dist/assets/channel-7q16D7P9.js +0 -1
- package/dist/assets/classDiagram-LNE6IOMH-C6qjk4uc.js +0 -1
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-C6qjk4uc.js +0 -1
- package/dist/assets/main-C5mwv79r.css +0 -10
- package/dist/assets/main-DmvFaz-d.js +0 -1486
- package/dist/assets/stateDiagram-v2-4JROLMXI-CCMApx_v.js +0 -1
|
@@ -27,6 +27,7 @@ const parse_common_flags_1 = require("./parse-common-flags");
|
|
|
27
27
|
const resolve_prompt_1 = require("./resolve-prompt");
|
|
28
28
|
const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
29
29
|
const inherited_trace_1 = require("../utils/inherited-trace");
|
|
30
|
+
const write_output_1 = require("./write-output");
|
|
30
31
|
/**
|
|
31
32
|
* Handle `crewx execute <agentRef> <message>` command.
|
|
32
33
|
*
|
|
@@ -34,7 +35,7 @@ const inherited_trace_1 = require("../utils/inherited-trace");
|
|
|
34
35
|
* --verbose: debug info written to stderr, response to stdout.
|
|
35
36
|
*/
|
|
36
37
|
async function handleExecute(args) {
|
|
37
|
-
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
38
|
+
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, overdrive, vars, out, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
38
39
|
const { agentRef: parsedAgentRef, message } = (0, parse_agent_message_1.parseAgentMessage)(rest);
|
|
39
40
|
// No @mention → default to @crewx agent (matches cli-bak behaviour)
|
|
40
41
|
const agentRef = parsedAgentRef || '@crewx';
|
|
@@ -62,9 +63,11 @@ async function handleExecute(args) {
|
|
|
62
63
|
console.error(' --verbose Debug output mode');
|
|
63
64
|
console.error(' --config/-c <path> Config file path');
|
|
64
65
|
console.error(' --output-format <fmt> Output format (json|text|stream-json)');
|
|
66
|
+
console.error(' --out/-o <path> Save result to file (stdout suppressed)');
|
|
65
67
|
console.error(' --effort <level> Model effort (high|medium|low)');
|
|
66
68
|
console.error(' -f/--prompt-file <path> Read task body from file');
|
|
67
69
|
console.error(' --var key=value Template variable (repeatable)');
|
|
70
|
+
console.error(' --overdrive Activate overdrive (boost) profile for this request');
|
|
68
71
|
process.exit(1);
|
|
69
72
|
}
|
|
70
73
|
const configPath = config ?? process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
@@ -83,6 +86,8 @@ async function handleExecute(args) {
|
|
|
83
86
|
process.stderr.write(`📄 Output-format: ${outputFormat}\n`);
|
|
84
87
|
if (effort)
|
|
85
88
|
process.stderr.write(`⚡ Effort: ${effort}\n`);
|
|
89
|
+
if (overdrive)
|
|
90
|
+
process.stderr.write(`🚀 Overdrive: ON\n`);
|
|
86
91
|
process.stderr.write('─'.repeat(60) + '\n');
|
|
87
92
|
}
|
|
88
93
|
let parsedMetadata = {};
|
|
@@ -99,6 +104,7 @@ async function handleExecute(args) {
|
|
|
99
104
|
const result = await crewx.execute(agentRef, finalMessage, {
|
|
100
105
|
provider,
|
|
101
106
|
effort: effort || undefined,
|
|
107
|
+
overdrive: overdrive || undefined,
|
|
102
108
|
threadId: thread,
|
|
103
109
|
metadata: Object.keys(parsedMetadata).length > 0 ? parsedMetadata : undefined,
|
|
104
110
|
vars: Object.keys(vars).length > 0 ? vars : undefined,
|
|
@@ -107,6 +113,7 @@ async function handleExecute(args) {
|
|
|
107
113
|
if (!result.ok) {
|
|
108
114
|
const errMsg = result.error?.message ?? 'Execute failed';
|
|
109
115
|
console.error(errMsg);
|
|
116
|
+
(0, write_output_1.appendError)(out, errMsg);
|
|
110
117
|
exitCode = 1;
|
|
111
118
|
}
|
|
112
119
|
else {
|
|
@@ -119,7 +126,7 @@ async function handleExecute(args) {
|
|
|
119
126
|
process.stderr.write('\n📄 Response:\n');
|
|
120
127
|
process.stderr.write('─'.repeat(40) + '\n');
|
|
121
128
|
}
|
|
122
|
-
|
|
129
|
+
(0, write_output_1.writeResult)(out, result.data);
|
|
123
130
|
if (verbose) {
|
|
124
131
|
process.stderr.write('\n✅ Execute completed successfully\n');
|
|
125
132
|
}
|
|
@@ -128,6 +135,7 @@ async function handleExecute(args) {
|
|
|
128
135
|
catch (err) {
|
|
129
136
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
130
137
|
console.error(`Error: ${errMsg}`);
|
|
138
|
+
(0, write_output_1.appendError)(out, `Error: ${errMsg}`);
|
|
131
139
|
exitCode = 1;
|
|
132
140
|
}
|
|
133
141
|
finally {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports both `--flag=value` and `--flag value` forms.
|
|
5
5
|
* Handles: --thread, --provider, --metadata, --verbose, --config/-c,
|
|
6
|
-
* --output-format, --effort, --prompt-file/-f.
|
|
6
|
+
* --output-format, --effort, --prompt-file/-f, --overdrive.
|
|
7
7
|
*
|
|
8
8
|
* Strict mode: unknown --xxx tokens after known flags are consumed throw an
|
|
9
9
|
* error instead of silently leaking into the message prompt.
|
|
@@ -26,6 +26,10 @@ export interface CommonFlags {
|
|
|
26
26
|
effort?: string;
|
|
27
27
|
/** Path to a file whose content is used as the prompt body (-f/--prompt-file). */
|
|
28
28
|
promptFile?: string;
|
|
29
|
+
/** Whether overdrive (boost) is active for this request. */
|
|
30
|
+
overdrive: boolean;
|
|
31
|
+
/** Output file path for saving result (--out/-o). */
|
|
32
|
+
out?: string;
|
|
29
33
|
/** Template variables from --var key=value flags. */
|
|
30
34
|
vars: Record<string, string>;
|
|
31
35
|
/** Remaining non-flag positional arguments. */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Supports both `--flag=value` and `--flag value` forms.
|
|
6
6
|
* Handles: --thread, --provider, --metadata, --verbose, --config/-c,
|
|
7
|
-
* --output-format, --effort, --prompt-file/-f.
|
|
7
|
+
* --output-format, --effort, --prompt-file/-f, --overdrive.
|
|
8
8
|
*
|
|
9
9
|
* Strict mode: unknown --xxx tokens after known flags are consumed throw an
|
|
10
10
|
* error instead of silently leaking into the message prompt.
|
|
@@ -68,7 +68,9 @@ function parseCommonFlags(args) {
|
|
|
68
68
|
const outputFormat = parseFlag(args, '--output-format');
|
|
69
69
|
const effort = parseFlag(args, '--effort');
|
|
70
70
|
const promptFile = parseFlag(args, '--prompt-file', '-f');
|
|
71
|
+
const out = parseFlag(args, '--out', '-o');
|
|
71
72
|
const verbose = hasFlag(args, '--verbose');
|
|
73
|
+
const overdrive = hasFlag(args, '--overdrive');
|
|
72
74
|
// Collect consumed positions for known flags
|
|
73
75
|
const consumed = new Set();
|
|
74
76
|
const flagPairs = [
|
|
@@ -79,6 +81,7 @@ function parseCommonFlags(args) {
|
|
|
79
81
|
{ names: ['--output-format'] },
|
|
80
82
|
{ names: ['--effort'] },
|
|
81
83
|
{ names: ['--prompt-file', '-f'] },
|
|
84
|
+
{ names: ['--out', '-o'] },
|
|
82
85
|
];
|
|
83
86
|
// Parse --var key=value flags (multiple allowed; last value wins on duplicate keys)
|
|
84
87
|
const vars = {};
|
|
@@ -88,6 +91,10 @@ function parseCommonFlags(args) {
|
|
|
88
91
|
consumed.add(i);
|
|
89
92
|
continue;
|
|
90
93
|
}
|
|
94
|
+
if (arg === '--overdrive') {
|
|
95
|
+
consumed.add(i);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
91
98
|
// --var=key=value or --var key=value
|
|
92
99
|
if (arg.startsWith('--var=') || arg === '--var') {
|
|
93
100
|
let kv;
|
|
@@ -148,7 +155,7 @@ function parseCommonFlags(args) {
|
|
|
148
155
|
}
|
|
149
156
|
rest.push(token);
|
|
150
157
|
}
|
|
151
|
-
return { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest };
|
|
158
|
+
return { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, overdrive, vars, out, rest };
|
|
152
159
|
}
|
|
153
160
|
/**
|
|
154
161
|
* Parse metadata JSON string from --metadata flag.
|
|
@@ -21,14 +21,54 @@ function formatElapsed(ms) {
|
|
|
21
21
|
const h = Math.floor(m / 60);
|
|
22
22
|
return `${h}h ${m % 60}m`;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Antigravity-family providers (coding_agent_command starting with 'agy',
|
|
26
|
+
* path-included forms like '/usr/local/bin/agy' also count) don't emit
|
|
27
|
+
* parseable logs, so they get a distinct 'n/a' instead of '—'.
|
|
28
|
+
*/
|
|
29
|
+
function isAgyCommand(codingAgentCommand) {
|
|
30
|
+
const cmd = (codingAgentCommand ?? '').trim();
|
|
31
|
+
if (!cmd)
|
|
32
|
+
return false;
|
|
33
|
+
const firstToken = cmd.split(/\s+/)[0] ?? '';
|
|
34
|
+
const base = firstToken.split('/').pop() ?? firstToken;
|
|
35
|
+
return base.startsWith('agy');
|
|
36
|
+
}
|
|
37
|
+
function getLastActive(task) {
|
|
38
|
+
try {
|
|
39
|
+
const entries = task.logs ? JSON.parse(task.logs) : [];
|
|
40
|
+
if (Array.isArray(entries) && entries.length > 0) {
|
|
41
|
+
const lastEntry = entries[entries.length - 1];
|
|
42
|
+
const ts = lastEntry?.timestamp;
|
|
43
|
+
const parsedMs = ts ? new Date(ts).getTime() : NaN;
|
|
44
|
+
if (ts && !Number.isNaN(parsedMs)) {
|
|
45
|
+
const diffMs = Math.max(0, Date.now() - parsedMs);
|
|
46
|
+
return {
|
|
47
|
+
display: `${formatElapsed(diffMs)} ago`,
|
|
48
|
+
isoTimestamp: ts,
|
|
49
|
+
logCapable: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// fall through to antigravity/dash fallback below
|
|
56
|
+
}
|
|
57
|
+
if (isAgyCommand(task.coding_agent_command)) {
|
|
58
|
+
return { display: 'n/a', isoTimestamp: null, logCapable: false };
|
|
59
|
+
}
|
|
60
|
+
return { display: '—', isoTimestamp: null, logCapable: true };
|
|
61
|
+
}
|
|
24
62
|
function taskToRow(task) {
|
|
25
63
|
const elapsed = formatElapsed(Date.now() - new Date(task.started_at).getTime());
|
|
64
|
+
const lastActive = getLastActive(task);
|
|
26
65
|
return [
|
|
27
66
|
task.id,
|
|
28
67
|
task.agent_id ?? '—',
|
|
29
68
|
task.pid !== null && task.pid !== undefined ? String(task.pid) : '—',
|
|
30
69
|
elapsed,
|
|
31
70
|
task.mode ?? '—',
|
|
71
|
+
lastActive.display,
|
|
32
72
|
];
|
|
33
73
|
}
|
|
34
74
|
function renderTable(headers, rows) {
|
|
@@ -43,16 +83,25 @@ function renderTable(headers, rows) {
|
|
|
43
83
|
}
|
|
44
84
|
async function handlePs(args) {
|
|
45
85
|
const repo = new repository_1.TaskRepository();
|
|
86
|
+
repo.reapRunningWorkflowTasks();
|
|
46
87
|
const tasks = repo.getRunningTasks();
|
|
47
88
|
if (tasks.length === 0) {
|
|
48
89
|
console.log('No running tasks.');
|
|
49
90
|
return;
|
|
50
91
|
}
|
|
51
92
|
if (args.includes('--json')) {
|
|
52
|
-
|
|
93
|
+
const withLastActive = tasks.map((task) => {
|
|
94
|
+
const lastActive = getLastActive(task);
|
|
95
|
+
return {
|
|
96
|
+
...task,
|
|
97
|
+
last_active_at: lastActive.isoTimestamp,
|
|
98
|
+
log_capable: lastActive.logCapable,
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
console.log(JSON.stringify(withLastActive, null, 2));
|
|
53
102
|
return;
|
|
54
103
|
}
|
|
55
|
-
const headers = ['TASK ID', 'AGENT', 'PID', 'ELAPSED', 'MODE'];
|
|
104
|
+
const headers = ['TASK ID', 'AGENT', 'PID', 'ELAPSED', 'MODE', 'LAST ACTIVE'];
|
|
56
105
|
const rows = tasks.map(taskToRow);
|
|
57
106
|
renderTable(headers, rows);
|
|
58
107
|
console.log(`\n ${tasks.length} running task(s)`);
|
|
@@ -27,6 +27,7 @@ const parse_common_flags_1 = require("./parse-common-flags");
|
|
|
27
27
|
const resolve_prompt_1 = require("./resolve-prompt");
|
|
28
28
|
const crewx_cli_1 = require("../bootstrap/crewx-cli");
|
|
29
29
|
const inherited_trace_1 = require("../utils/inherited-trace");
|
|
30
|
+
const write_output_1 = require("./write-output");
|
|
30
31
|
/**
|
|
31
32
|
* Handle `crewx query <agentRef> <message>` command.
|
|
32
33
|
*
|
|
@@ -34,7 +35,7 @@ const inherited_trace_1 = require("../utils/inherited-trace");
|
|
|
34
35
|
* --verbose: debug info written to stderr, response to stdout.
|
|
35
36
|
*/
|
|
36
37
|
async function handleQuery(args) {
|
|
37
|
-
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, vars, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
38
|
+
const { thread, provider, metadata, verbose, config, outputFormat, effort, promptFile, overdrive, vars, out, rest } = (0, parse_common_flags_1.parseCommonFlags)(args);
|
|
38
39
|
const { agentRef: parsedAgentRef, message } = (0, parse_agent_message_1.parseAgentMessage)(rest);
|
|
39
40
|
// No @mention → default to @crewx agent (matches cli-bak behaviour)
|
|
40
41
|
const agentRef = parsedAgentRef || '@crewx';
|
|
@@ -62,9 +63,11 @@ async function handleQuery(args) {
|
|
|
62
63
|
console.error(' --verbose Debug output mode');
|
|
63
64
|
console.error(' --config/-c <path> Config file path');
|
|
64
65
|
console.error(' --output-format <fmt> Output format (json|text|stream-json)');
|
|
66
|
+
console.error(' --out/-o <path> Save result to file (stdout suppressed)');
|
|
65
67
|
console.error(' --effort <level> Model effort (high|medium|low)');
|
|
66
68
|
console.error(' -f/--prompt-file <path> Read prompt body from file');
|
|
67
69
|
console.error(' --var key=value Template variable (repeatable)');
|
|
70
|
+
console.error(' --overdrive Activate overdrive (boost) profile for this request');
|
|
68
71
|
process.exit(1);
|
|
69
72
|
}
|
|
70
73
|
const configPath = config ?? process.env.CREWX_CONFIG ?? 'crewx.yaml';
|
|
@@ -83,6 +86,8 @@ async function handleQuery(args) {
|
|
|
83
86
|
process.stderr.write(`📄 Output-format: ${outputFormat}\n`);
|
|
84
87
|
if (effort)
|
|
85
88
|
process.stderr.write(`⚡ Effort: ${effort}\n`);
|
|
89
|
+
if (overdrive)
|
|
90
|
+
process.stderr.write(`🚀 Overdrive: ON\n`);
|
|
86
91
|
process.stderr.write('─'.repeat(60) + '\n');
|
|
87
92
|
}
|
|
88
93
|
let parsedMetadata = {};
|
|
@@ -99,6 +104,7 @@ async function handleQuery(args) {
|
|
|
99
104
|
const result = await crewx.query(agentRef, finalMessage, {
|
|
100
105
|
provider,
|
|
101
106
|
effort: effort || undefined,
|
|
107
|
+
overdrive: overdrive || undefined,
|
|
102
108
|
threadId: thread,
|
|
103
109
|
metadata: Object.keys(parsedMetadata).length > 0 ? parsedMetadata : undefined,
|
|
104
110
|
vars: Object.keys(vars).length > 0 ? vars : undefined,
|
|
@@ -107,6 +113,7 @@ async function handleQuery(args) {
|
|
|
107
113
|
if (!result.ok) {
|
|
108
114
|
const errMsg = result.error?.message ?? 'Query failed';
|
|
109
115
|
console.error(errMsg);
|
|
116
|
+
(0, write_output_1.appendError)(out, errMsg);
|
|
110
117
|
exitCode = 1;
|
|
111
118
|
}
|
|
112
119
|
else {
|
|
@@ -119,7 +126,7 @@ async function handleQuery(args) {
|
|
|
119
126
|
process.stderr.write('\n📄 Response:\n');
|
|
120
127
|
process.stderr.write('─'.repeat(40) + '\n');
|
|
121
128
|
}
|
|
122
|
-
|
|
129
|
+
(0, write_output_1.writeResult)(out, result.data);
|
|
123
130
|
if (verbose) {
|
|
124
131
|
process.stderr.write('\n✅ Query completed successfully\n');
|
|
125
132
|
}
|
|
@@ -128,6 +135,7 @@ async function handleQuery(args) {
|
|
|
128
135
|
catch (err) {
|
|
129
136
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
130
137
|
console.error(`Error: ${errMsg}`);
|
|
138
|
+
(0, write_output_1.appendError)(out, `Error: ${errMsg}`);
|
|
131
139
|
exitCode = 1;
|
|
132
140
|
}
|
|
133
141
|
finally {
|
|
@@ -43,18 +43,23 @@ function buildRetryPrefix(originalTaskId) {
|
|
|
43
43
|
* the string when present and non-empty, otherwise `undefined` so the
|
|
44
44
|
* agent's configured provider default is used.
|
|
45
45
|
*/
|
|
46
|
-
function
|
|
46
|
+
function parseTaskMetadata(metadata) {
|
|
47
47
|
if (!metadata)
|
|
48
|
-
return
|
|
48
|
+
return {};
|
|
49
49
|
try {
|
|
50
50
|
const parsed = JSON.parse(metadata);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
52
|
+
? parsed
|
|
53
|
+
: {};
|
|
53
54
|
}
|
|
54
55
|
catch {
|
|
55
|
-
return
|
|
56
|
+
return {};
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
function extractProvider(metadata) {
|
|
60
|
+
const provider = metadata.provider;
|
|
61
|
+
return typeof provider === 'string' && provider.length > 0 ? provider : undefined;
|
|
62
|
+
}
|
|
58
63
|
async function handleRestart(args) {
|
|
59
64
|
const verbose = args.includes('--verbose');
|
|
60
65
|
const taskId = args.find((a) => !a.startsWith('--'));
|
|
@@ -96,7 +101,10 @@ async function handleRestart(args) {
|
|
|
96
101
|
// provider: recovered from metadata.provider (SDK-persisted). Falls back to
|
|
97
102
|
// the agent's configured provider when absent. This preserves a
|
|
98
103
|
// `crewx x --provider ...` choice across restart.
|
|
99
|
-
const
|
|
104
|
+
const originalMetadata = parseTaskMetadata(original.metadata);
|
|
105
|
+
const provider = extractProvider(originalMetadata);
|
|
106
|
+
const originalWasOverdrive = originalMetadata.overdrive === true;
|
|
107
|
+
const originalOverdriveMode = originalMetadata.overdriveState === 'latch' ? 'latch' : 'count';
|
|
100
108
|
(0, sdk_1.setAuditVerbose)(verbose);
|
|
101
109
|
if (verbose) {
|
|
102
110
|
process.stderr.write(`🔁 Restart: ${taskId} → ${newTaskId}\n`);
|
|
@@ -111,10 +119,16 @@ async function handleRestart(args) {
|
|
|
111
119
|
threadId: original.thread_id ?? undefined,
|
|
112
120
|
model,
|
|
113
121
|
provider,
|
|
122
|
+
...(originalWasOverdrive ? { overdrive: { mode: originalOverdriveMode } } : {}),
|
|
114
123
|
metadata: {
|
|
115
124
|
restartedFromTaskId: taskId,
|
|
116
125
|
// Back-compat / search convenience: mirror the Web UI metadata key.
|
|
117
126
|
retriedFromTaskId: taskId,
|
|
127
|
+
...(originalWasOverdrive ? {
|
|
128
|
+
overdrive: true,
|
|
129
|
+
overdriveState: originalOverdriveMode,
|
|
130
|
+
overdriveMode: mode,
|
|
131
|
+
} : {}),
|
|
118
132
|
},
|
|
119
133
|
trace: (0, inherited_trace_1.readInheritedTrace)(),
|
|
120
134
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeResult = writeResult;
|
|
4
|
+
exports.appendError = appendError;
|
|
5
|
+
/**
|
|
6
|
+
* EPIPE-safe result output.
|
|
7
|
+
* - out specified: write success result to file (sync, no stream EPIPE)
|
|
8
|
+
* - out not specified: fall back to existing stdout (console.log)
|
|
9
|
+
*/
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
function writeResult(out, data) {
|
|
12
|
+
if (out) {
|
|
13
|
+
(0, fs_1.writeFileSync)(out, data, 'utf8');
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.log(data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** On failure: if out is specified, append to file (avoid empty file). stderr is kept by the caller. */
|
|
20
|
+
function appendError(out, message) {
|
|
21
|
+
if (out) {
|
|
22
|
+
(0, fs_1.appendFileSync)(out, message.endsWith('\n') ? message : message + '\n', 'utf8');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -46,8 +46,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
46
|
// ─── P0-1: Env Bootstrap ─────────────────────────────────────────────────────
|
|
47
47
|
// Must run before any other code that might use process.env.CREWX_CLI.
|
|
48
48
|
const env_defaults_1 = require("./utils/env-defaults");
|
|
49
|
+
const sdk_1 = require("@crewx/sdk");
|
|
49
50
|
process.env.CREWX_CLI ??= (0, env_defaults_1.resolveCrewxCli)();
|
|
50
51
|
process.env.CREWX_WORKSPACE ??= (0, env_defaults_1.resolveCrewxWorkspace)();
|
|
52
|
+
// ─── Pricing remote override (WI-20260701-002) ───────────────────────────────
|
|
53
|
+
// Best-effort, non-blocking: fetch remote model registry so new models get
|
|
54
|
+
// accurate pricing without a CLI republish. Falls back to bundled table on
|
|
55
|
+
// failure / offline. Browser entry does not call this automatically.
|
|
56
|
+
void (0, sdk_1.initPricingRemote)();
|
|
51
57
|
// ─── Command Imports ──────────────────────────────────────────────────────────
|
|
52
58
|
const query_1 = require("./commands/query");
|
|
53
59
|
const execute_1 = require("./commands/execute");
|
|
@@ -256,6 +262,7 @@ Query / Execute:
|
|
|
256
262
|
--verbose Debug output mode (default: raw response only)
|
|
257
263
|
--config/-c <path> Config file path (default: CREWX_CONFIG or crewx.yaml)
|
|
258
264
|
--output-format <fmt> Output format (json|text|stream-json)
|
|
265
|
+
--out/-o <path> Save result to file (stdout suppressed)
|
|
259
266
|
--effort <level> Model effort (high|medium|low)
|
|
260
267
|
-f/--prompt-file <path> Read task body from file (bypasses argv length limits)
|
|
261
268
|
--var key=value Template variable (repeatable). Accessible as {{key}} in agent prompt.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{aB as N,aC as Ue,aD as b,aE as j,aF as Pe,aG as g,aH as e,aI as ue,aJ as J,aK as de,aL as I,aM as ge,aN as pe,aO as Ve,aP as ye,aQ as X,aR as F,aS as Fe,aT as Be,aU as Oe,aV as He,aW as he,aX as Qe,aY as We}from"./main-DmvFaz-d.js";/**
|
|
2
|
-
* @license lucide-react v0.563.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const qe=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],fe=N("badge-check",qe);/**
|
|
7
|
-
* @license lucide-react v0.563.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ge=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],be=N("circle-arrow-up",Ge);/**
|
|
12
|
-
* @license lucide-react v0.563.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ke=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]],je=N("layout-template",Ke);/**
|
|
17
|
-
* @license lucide-react v0.563.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Je=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Ne=N("plug",Je);/**
|
|
22
|
-
* @license lucide-react v0.563.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Xe=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],ve=N("puzzle",Xe);/**
|
|
27
|
-
* @license lucide-react v0.563.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Ye=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],Ze=N("scale",Ye);/**
|
|
32
|
-
* @license lucide-react v0.563.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const et=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],tt=N("settings-2",et);/**
|
|
37
|
-
* @license lucide-react v0.563.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const at=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],we=N("workflow",at);function T(t){return t instanceof Error?t.message:String(t)}function st(t){return[...t].sort((a,r)=>a.isInstalled!==r.isInstalled?a.isInstalled?-1:1:(a.displayName||a.name).localeCompare(r.displayName||r.name))}const oe={trusted:2,verified:1,unverified:0};function rt(t,a){return oe[t]>=oe[a]?t:a}function nt(t=[],a=[]){return Array.from(new Set([...t,...a]))}function ce(t,a){var s;if(!t)return a;const r=rt(t.trustLevel,a.trustLevel);return{...t,...a,displayName:a.displayName||t.displayName||a.name,description:a.description||t.description,author:a.author||t.author,version:a.version||t.version,tags:nt(t.tags,a.tags),type:a.type||t.type,trustLevel:r,isVerified:r!=="unverified",isInstalled:t.isInstalled||a.isInstalled,registryId:a.registryId??t.registryId,registryName:a.registryName??t.registryName,installSource:a.installSource??t.installSource,hasUpdate:a.hasUpdate??t.hasUpdate,remoteVersion:a.remoteVersion??t.remoteVersion,isCustomized:a.isCustomized??t.isCustomized,authors:(s=a.authors)!=null&&s.length?a.authors:t.authors,updatedAt:a.updatedAt??t.updatedAt,stars:a.stars??t.stars,license:a.license??t.license,installCount:a.installCount??t.installCount}}function lt(t){return t.toLowerCase().replace(/[\s_]+/g,"-")}function V(t){const a=new Map;for(const s of t){const d=lt(s.name),l=a.get(d)??[];l.push(s),a.set(d,l)}const r=[];for(const[,s]of a){if(s.length===1){r.push(s[0]);continue}const d=s.find(l=>l.isInstalled);if(d){const l=s.find(c=>c.registryId&&c.registryId!=="_local"),o=l?ce(l,d):d;r.push(o)}else{const l=new Map;for(const o of s){const c=o.registryId??"_local",u=l.get(c);l.set(c,ce(u,o))}r.push(...l.values())}}return st(r)}function it(t){return t.find(a=>a.isDefault)??t.find(a=>a.trustLevel!=="unverified")??t[0]??null}function dt(t,a){return V([...t,...a])}function K(t,a){var r;return a&&t.some(s=>s.name===a)?a:((r=t[0])==null?void 0:r.name)??null}const ot=Ue((t,a)=>({initialized:!1,loading:!1,loadingOfficial:!1,loadingInstalled:!1,savingRegistry:!1,deletingRegistryId:null,mutatingItemName:null,error:null,registries:[],officialRegistryId:null,allItems:[],activeFilter:"all",searchQuery:"",selectedItemName:null,setActiveFilter:r=>t({activeFilter:r}),setSearchQuery:r=>t({searchQuery:r}),setSelectedItem:r=>t({selectedItemName:r}),initialize:async()=>{const r=a().selectedItemName;t({loading:!0,loadingOfficial:!0,loadingInstalled:!0,error:null});try{const[s,d,l]=await Promise.all([b.getMarketRegistries(),b.getMarketItems(),b.getInstalledMarkets()]),o=s.registries,c=it(o),u=d.items,m=V(l.items.filter(h=>!h.source||h.source==="local")),y=dt(u,m);t({initialized:!0,loading:!1,loadingOfficial:!1,loadingInstalled:!1,registries:o,officialRegistryId:(c==null?void 0:c.id)??null,allItems:y,selectedItemName:K(y,r)}),b.checkMarketUpdates().then(h=>{!h||Object.keys(h).length===0||t(p=>({allItems:p.allItems.map(M=>{const v=h[M.name];return v?{...M,hasUpdate:v.hasUpdate,remoteVersion:v.remoteVersion,isCustomized:v.isCustomized}:M})}))}).catch(()=>{})}catch(s){throw t({loading:!1,loadingOfficial:!1,loadingInstalled:!1,error:T(s)}),s}},refresh:async()=>{await a().initialize()},addRegistry:async(r,s)=>{const d=r.trim();if(!d){const l=new Error("Registry URL is required");throw t({error:l.message}),l}t({savingRegistry:!0,error:null});try{const l=(s==null?void 0:s.trim())||void 0;await b.addMarketRegistry(d,l),await a().initialize(),t({savingRegistry:!1})}catch(l){throw t({savingRegistry:!1,error:T(l)}),l}},deleteRegistry:async r=>{t({deletingRegistryId:r,error:null});try{await b.deleteMarketRegistry(r),await a().initialize(),t({deletingRegistryId:null})}catch(s){throw t({deletingRegistryId:null,error:T(s)}),s}},installItem:async(r,s)=>{t({mutatingItemName:s,error:null});try{await b.installMarketItem(r,s),t(d=>{const l=d.registries.find(c=>c.id===r),o=V(d.allItems.map(c=>c.name===s?{...c,isInstalled:!0,registryId:c.registryId??r,registryName:c.registryName??(l==null?void 0:l.name)}:c));return{allItems:o,mutatingItemName:null,selectedItemName:K(o,d.selectedItemName??s)}})}catch(d){throw t({mutatingItemName:null,error:T(d)}),d}},uninstallItem:async r=>{t({mutatingItemName:r,error:null});try{await b.uninstallMarketItem(r),t(s=>{const d=V(s.allItems.map(l=>l.name===r?{...l,isInstalled:!1}:l));return{allItems:d,mutatingItemName:null,selectedItemName:K(d,s.selectedItemName)}})}catch(s){throw t({mutatingItemName:null,error:T(s)}),s}},clearError:()=>t({error:null})}));function ke(t,a){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?"—":new Intl.DateTimeFormat(a,{year:"numeric",month:"short",day:"numeric"}).format(r)}function ct(t,a){if(!t)return null;const r=new Date(t);if(Number.isNaN(r.getTime()))return null;const s=r.getTime()-Date.now(),d=[{unit:"year",ms:1e3*60*60*24*365},{unit:"month",ms:1e3*60*60*24*30},{unit:"week",ms:1e3*60*60*24*7},{unit:"day",ms:1e3*60*60*24},{unit:"hour",ms:1e3*60*60},{unit:"minute",ms:1e3*60}],l=new Intl.RelativeTimeFormat(a,{numeric:"auto"});for(const o of d)if(Math.abs(s)>=o.ms||o.unit==="minute")return l.format(Math.round(s/o.ms),o.unit);return null}function me(t,a){return typeof t!="number"?"—":new Intl.NumberFormat(a,{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}).format(t)}function Y(t){switch(t==null?void 0:t.toLowerCase()){case"template":return"template";case"agent":return"agent";case"workflow":return"workflow";case"plugin":return"plugin";default:return"skill"}}function Ie({type:t}){const{t:a}=j(),r=Y(t),s={skill:"bg-violet-50 text-violet-700",template:"bg-amber-50 text-amber-700",agent:"bg-emerald-50 text-emerald-700",workflow:"bg-cyan-50 text-cyan-700",plugin:"bg-rose-50 text-rose-700"},d={skill:ve,template:je,agent:ge,workflow:we,plugin:Ne},l={skill:a("market.types.skill"),template:a("market.types.template"),agent:a("market.types.agent"),workflow:a("market.types.workflow"),plugin:a("market.types.plugin")},o=d[r];return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ${s[r]}`,children:[e.jsx(o,{size:12}),l[r]]})}const mt={trusted:{bg:"bg-green-50",text:"text-green-700",icon:pe,label:"market.badges.trusted"},verified:{bg:"bg-blue-50",text:"text-blue-700",icon:fe,label:"market.badges.verified"},unverified:{bg:"bg-gray-50",text:"text-gray-500",icon:F,label:"market.badges.unverified"}};function xt({level:t}){const{t:a}=j(),r=mt[t],s=r.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${r.bg} ${r.text}`,children:[e.jsx(s,{size:13}),a(r.label)]})}function Ce(t){if(t.trustLevel==="unverified"){if(t.type==="plugin")return{allowed:!1,reason:"market.trust.blockedPlugin"};if(t.type==="exec")return{allowed:!1,reason:"market.trust.blockedExec"}}return t.trustLevel==="verified"&&t.type==="plugin"?{allowed:!0,needsConfirm:!0}:{allowed:!0}}function ut({itemName:t,onConfirm:a,onCancel:r}){const{t:s}=j();return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-md overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:s("market.pluginDialog.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s("market.pluginDialog.description")})]}),e.jsxs("div",{className:"space-y-3 px-6 py-5",children:[e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 px-4 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:t}),e.jsx("p",{className:"mt-1 text-sm text-amber-800",children:s("market.pluginDialog.warning")})]}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{size:14,className:"shrink-0 text-amber-500"}),s("market.pluginDialog.perm1")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{size:14,className:"shrink-0 text-amber-500"}),s("market.pluginDialog.perm2")]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:r,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:s("market.actions.cancel")}),e.jsx("button",{type:"button",onClick:a,className:"rounded-lg bg-red-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-600",children:s("market.actions.install")})]})]})})}function gt({url:t,tokenEnv:a,error:r,submitting:s,onChangeUrl:d,onChangeTokenEnv:l,onClose:o,onSubmit:c}){const{t:u}=j(),m=y=>{y.preventDefault(),c()};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-xl overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"border-b border-gray-200 px-6 py-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:u("market.addRegistryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:u("market.addRegistryModal.description")})]}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"registry-url",className:"mb-2 block text-sm font-medium text-gray-700",children:u("market.addRegistryModal.urlLabel")}),e.jsx("input",{id:"registry-url",type:"url",value:t,onChange:y=>d(y.target.value),placeholder:u("market.addRegistryModal.urlPlaceholder"),className:"w-full rounded-lg border border-gray-300 px-4 py-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"registry-token-env",className:"mb-2 block text-sm font-medium text-gray-700",children:[u("market.addRegistryModal.tokenEnvLabel","Token Env Variable"),e.jsx("span",{className:"ml-1 text-xs font-normal text-gray-400",children:u("market.addRegistryModal.optional","(optional)")})]}),e.jsx("input",{id:"registry-token-env",type:"text",value:a,onChange:y=>l(y.target.value),placeholder:u("market.addRegistryModal.tokenEnvPlaceholder","e.g. GITHUB_TOKEN"),className:"w-full rounded-lg border border-gray-300 px-4 py-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:u("market.addRegistryModal.tokenEnvHint","Environment variable name for private GitHub PAT. The token value must be set in .env or shell profile.")})]}),e.jsx("div",{className:"rounded-xl border border-blue-200 bg-blue-50 px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-white text-blue-600",children:e.jsx(Qe,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-900",children:u("market.addRegistryModal.compatibilityTitle")}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-blue-800",children:u("market.addRegistryModal.compatibilityDescription")})]})]})}),r&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(J,{size:18,className:"mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm",children:r})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[e.jsx("button",{type:"button",onClick:o,disabled:s,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:u("market.actions.cancel")}),e.jsxs("button",{type:"submit",disabled:s,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[s?e.jsx(I,{size:16,className:"animate-spin"}):e.jsx(X,{size:16}),u("market.actions.addRegistry")]})]})]})]})})}function pt({registry:t,deleting:a,onDelete:r}){const{t:s,i18n:d}=j();return e.jsxs("article",{className:"flex flex-col gap-4 rounded-xl border border-gray-200 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl ${t.trustLevel!=="unverified"?"bg-blue-50 text-blue-600":"bg-gray-100 text-gray-500"}`,children:e.jsx(he,{size:20})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold text-gray-900",children:t.name}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${t.isDefault?"bg-amber-50 text-amber-700":"bg-gray-100 text-gray-600"}`,children:t.isDefault?s("market.registryCard.defaultBadge"):s("market.registryCard.customBadge")})]}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex break-all text-sm text-blue-600 hover:text-blue-700",children:[e.jsx("span",{children:t.url}),e.jsx(We,{size:14,className:"ml-1 mt-0.5 shrink-0"})]})]})]}),e.jsxs("button",{type:"button",onClick:()=>r(t.id),disabled:t.isDefault||a,className:`inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${t.isDefault?"cursor-not-allowed bg-gray-100 text-gray-400":"bg-red-50 text-red-600 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50"}`,children:[a?e.jsx(I,{size:15,className:"animate-spin"}):e.jsx(ye,{size:15}),t.isDefault?s("market.registryCard.lockedAction"):s("market.actions.deleteRegistry")]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:s("market.registryCard.skillCount")}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-gray-900",children:t.itemCount})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:s("market.registryCard.addedAt")}),e.jsx("p",{className:"mt-1 text-sm font-medium text-gray-900",children:ke(t.addedAt,d.language)})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:t.isDefault?s("market.registryCard.defaultHint"):s("market.registryCard.customHint")})]})}function yt({registries:t,loading:a,deletingRegistryId:r,onAdd:s,onClose:d,onDelete:l}){const{t:o}=j();return e.jsx("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:o("market.registryModal.title")}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:o("market.registryModal.description")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:[e.jsx(X,{size:16}),o("market.actions.addRegistry")]}),e.jsx("button",{type:"button",onClick:d,className:"rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:o("market.actions.close")})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:a?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(I,{size:22,className:"animate-spin text-gray-400"})}):t.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(he,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:o("market.empty.registryTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:o("market.empty.registryDescription")})]}):e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:t.map(c=>e.jsx(pt,{registry:c,deleting:r===c.id,onDelete:l},c.id))})})]})})}function xe({skill:t,selected:a,onSelect:r}){const{t:s,i18n:d}=j(),l=ct(t.updatedAt,d.language),o=Y(t.type),c={skill:ve,template:je,agent:ge,workflow:we,plugin:Ne},u={skill:t.isInstalled?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500",template:"bg-amber-100 text-amber-700",agent:"bg-emerald-100 text-emerald-700",workflow:"bg-cyan-100 text-cyan-700",plugin:"bg-rose-100 text-rose-700"},m=c[o];return e.jsx("button",{type:"button",onClick:()=>r(t.name),className:`w-full rounded-xl border p-3 text-left transition-colors ${a?"border-blue-200 bg-blue-50 shadow-sm":"border-transparent bg-white hover:border-gray-200 hover:bg-gray-50"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl ${u[o]}`,children:e.jsx(m,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-gray-900",children:t.displayName||t.name}),t.trustLevel==="trusted"&&e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0 text-green-600"}),t.trustLevel==="verified"&&e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-blue-500"}),e.jsx(Ie,{type:t.type})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-gray-500",children:t.description||s("market.card.noDescription")}),e.jsxs("p",{className:"mt-2 text-[11px] text-gray-400",children:[t.registryName||t.author||s("market.card.unknownAuthor"),l?` · ${s("market.list.updatedLabel",{time:l})}`:""]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[t.isInstalled&&e.jsx("span",{className:"rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700",children:s("market.badges.installed")}),t.hasUpdate&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-orange-50 px-2 py-0.5 text-[10px] font-medium text-orange-700",children:[e.jsx(be,{size:10}),s("market.badges.updateAvailable",{version:t.remoteVersion})]})]})]})})}function P({icon:t,label:a,value:r}){return e.jsxs("div",{className:"rounded-xl border border-gray-200 bg-gray-50 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[e.jsx("span",{className:"text-gray-400",children:t}),e.jsx("span",{children:a})]}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-gray-900",children:r})]})}function ht({skill:t,markdownBody:a,descriptionLoading:r,descriptionError:s,busy:d,canInstall:l,onInstall:o,onUninstall:c,onRefresh:u}){const{t:m,i18n:y}=j(),h=typeof(t==null?void 0:t.installCount)=="number";return t?e.jsxs("section",{className:"flex h-full min-h-[520px] flex-col rounded-2xl border border-gray-200 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-gray-200 pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-2xl font-semibold text-gray-900",children:t.displayName||t.name}),e.jsxs("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-600",children:["v",t.version]}),t.hasUpdate&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-orange-50 px-2.5 py-1 text-xs font-medium text-orange-700",children:[e.jsx(be,{size:12}),m("market.badges.updateAvailable",{version:t.remoteVersion})]}),e.jsx(Ie,{type:t.type}),e.jsx(xt,{level:t.trustLevel})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t.registryName||t.author||m("market.card.unknownAuthor")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.isInstalled?e.jsxs("button",{type:"button",onClick:()=>c(t.name),disabled:d,className:"inline-flex items-center gap-2 rounded-lg bg-red-50 px-4 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[d?e.jsx(I,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16}),m("market.actions.uninstall")]}):(()=>{const p=Ce(t);return p.allowed?e.jsxs("button",{type:"button",onClick:()=>o(t),disabled:d||!l,className:"inline-flex items-center gap-2 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[d?e.jsx(I,{size:16,className:"animate-spin"}):e.jsx(X,{size:16}),m("market.actions.install")]}):e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-400",children:[e.jsx(F,{size:16}),m(p.reason)]})})(),e.jsxs("button",{type:"button",onClick:u,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ue,{size:16}),m("market.actions.checkUpdates")]})]})]}),e.jsxs("div",{className:"space-y-6 py-6",children:[t.isCustomized&&t.hasUpdate&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3",children:[e.jsx(J,{size:16,className:"mt-0.5 shrink-0 text-amber-600"}),e.jsx("p",{className:"text-sm text-amber-800",children:m("market.badges.customizedWarning")})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:m("market.detail.description")}),e.jsxs("div",{className:"mt-2",children:[t.description&&e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:t.description}),r?e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(I,{size:16,className:"animate-spin"}),e.jsx("span",{children:m("market.detail.loadingBody")})]}):a!=null&&a.trim()?e.jsx("div",{className:t.description?"mt-3 border-t border-gray-100 pt-3":"",children:e.jsx(Fe,{content:a,className:"text-sm"})}):e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"mt-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:s}),!t.description&&e.jsx("p",{className:"whitespace-pre-wrap text-sm leading-6 text-gray-600",children:m("market.card.noDescription")})]})]})]}),t.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:m("market.detail.tags")}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.tags.map(p=>e.jsxs("span",{className:"rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-600",children:["#",p]},p))})]}),t.authors&&t.authors.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:m("market.detail.developers")}),e.jsx("div",{className:"mt-3 space-y-3",children:t.authors.map(p=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:p.avatarUrl,alt:`@${p.login}`,className:"h-8 w-8 rounded-full border border-gray-200 object-cover"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium text-gray-900",children:p.name||p.login}),e.jsxs("div",{className:"text-xs text-gray-500",children:["@",p.login]})]}),typeof p.contributions=="number"&&e.jsx("div",{className:"text-xs text-gray-400",children:m("market.detail.contributions",{count:p.contributions})})]},`${t.name}-${p.login}`))})]})]}),e.jsxs("div",{className:`mt-auto grid gap-3 border-t border-gray-200 pt-6 sm:grid-cols-2 ${h?"xl:grid-cols-4":"xl:grid-cols-3"}`,children:[e.jsx(P,{icon:e.jsx(Be,{size:14}),label:m("market.detail.stats.stars"),value:me(t.stars,y.language)}),h&&e.jsx(P,{icon:e.jsx(Oe,{size:14}),label:m("market.detail.stats.installs"),value:me(t.installCount,y.language)}),e.jsx(P,{icon:e.jsx(Ze,{size:14}),label:m("market.detail.stats.license"),value:t.license||m("market.detail.unavailable")}),e.jsx(P,{icon:e.jsx(He,{size:14}),label:m("market.detail.stats.updatedAt"),value:ke(t.updatedAt,y.language)})]})]}):e.jsx("div",{className:"flex h-full min-h-[520px] items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 shadow-sm",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(Ve,{size:20})}),e.jsx("h3",{className:"mt-4 text-base font-semibold text-gray-900",children:m("market.detail.emptyTitle")}),e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:m("market.detail.emptyDescription")})]})})}function bt(){const{t}=j(),{setPageHeader:a}=Pe(),[r,s]=g.useState(!1),[d,l]=g.useState(!1),[o,c]=g.useState(""),[u,m]=g.useState(""),[y,h]=g.useState(null),[p,L]=g.useState({}),[M,v]=g.useState(null),[ze,B]=g.useState(null),[E,O]=g.useState(null),{initialized:Z,loading:S,savingRegistry:Me,deletingRegistryId:Re,mutatingItemName:De,error:ee,registries:Te,officialRegistryId:R,allItems:C,activeFilter:z,searchQuery:H,selectedItemName:A,setActiveFilter:Le,setSearchQuery:Ee,setSelectedItem:$,initialize:te,refresh:_,addRegistry:ae,deleteRegistry:se,installItem:re,uninstallItem:ne,clearError:U}=ot();g.useEffect(()=>{Z||te().catch(()=>{})},[Z,te]);const le=g.useMemo(()=>C.filter(n=>n.isInstalled).length,[C]),w=g.useMemo(()=>{const n=H.trim().toLowerCase();return C.filter(x=>z==="installed"&&!x.isInstalled||z!=="all"&&z!=="installed"&&Y(x.type)!==z?!1:n?[x.displayName,x.name,x.description,x.author,x.registryName,...x.tags].filter(k=>!!k).some(k=>k.toLowerCase().includes(n)):!0)},[z,C,H]),i=g.useMemo(()=>w.find(n=>n.name===A)??w[0]??null,[w,A]),Q=i?p[i.name]:void 0;g.useEffect(()=>{const n=(i==null?void 0:i.name)??null;n!==A&&$(n)},[i,A,$]),g.useEffect(()=>{if(!i)return;if(Q!==void 0){B(null);return}let n=!1;const x=i.name;return v(x),B(null),(i.isInstalled?b.getInstalledMarketDetail(x).then(f=>f.body??""):(()=>{const f=i.registryId??R;return f?b.getRemoteMarketDetail(f,x).then(D=>D.body??""):Promise.resolve("")})()).then(f=>{n||L(D=>({...D,[x]:f}))}).catch(f=>{if(!n){if(!i.isInstalled){L(D=>({...D,[x]:""}));return}B(f instanceof Error?f.message:t("market.errors.detailLoad"))}}).finally(()=>{n||v(f=>f===x?null:f)}),()=>{n=!0}},[i==null?void 0:i.isInstalled,i==null?void 0:i.name,i==null?void 0:i.registryId,Q,R,t]);const W=g.useCallback(n=>{n&&L(x=>{if(!(n in x))return x;const k={...x};return delete k[n],k})},[]);g.useEffect(()=>{a({title:t("market.title"),subtitle:t("market.subtitle.summary",{total:C.length,installed:le}),actions:e.jsxs("button",{type:"button",onClick:()=>{U(),W((i==null?void 0:i.name)??null),_().catch(()=>{})},className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[e.jsx(ue,{size:16,className:S?"animate-spin":""}),t("market.actions.refresh")]})})},[C.length,U,S,_,W,i==null?void 0:i.name,a,t,le]);const q=g.useCallback(n=>{const x=n.registryId??R;x&&re(x,n.name).catch(()=>{})},[re,R]),Se=g.useCallback(n=>{const x=Ce(n);if(x.allowed){if(x.needsConfirm){O(n);return}q(n)}},[q]),Ae=g.useCallback(n=>{window.confirm(t("market.actions.confirmUninstall",{name:n}))&&ne(n).catch(()=>{})},[t,ne]),$e=g.useCallback(n=>{se(n).catch(()=>{})},[se]),_e=g.useCallback(async()=>{h(null);try{await ae(o,u||void 0),c(""),m(""),l(!1)}catch(n){h(n instanceof Error?n.message:t("market.errors.addRegistry"))}},[ae,o,u,t]),G=w.filter(n=>n.isInstalled),ie=w.filter(n=>!n.isInstalled);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[ee&&e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-700",children:[e.jsx(J,{size:18,className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t("market.errors.bannerTitle")}),e.jsx("p",{className:"mt-1 break-words text-sm",children:ee})]}),e.jsx("button",{type:"button",onClick:()=>{U(),_().catch(()=>{})},className:"shrink-0 rounded-md bg-red-100 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-200",children:t("market.actions.retry")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-gray-200 bg-white p-4 shadow-sm lg:flex-row lg:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(de,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search",value:H,onChange:n=>Ee(n.target.value),placeholder:t("market.searchPlaceholder"),className:"w-full rounded-xl border border-gray-300 py-2.5 pl-10 pr-4 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("button",{type:"button",onClick:()=>s(!0),className:"inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-gray-50 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100",children:[e.jsx(tt,{size:16}),t("market.actions.manageSources")]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["all","installed","skill","template","agent"].map(n=>e.jsx("button",{type:"button",onClick:()=>Le(n),className:`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${z===n?"border-blue-500 bg-blue-500 text-white":"border-gray-200 bg-white text-gray-600 hover:bg-gray-50"}`,children:t(`market.filters.${n}`)},n))}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[360px_minmax(0,1fr)]",children:[e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white shadow-sm",children:[e.jsxs("div",{className:"border-b border-gray-200 px-4 py-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-900",children:t("market.list.title")}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:t("market.list.count",{count:w.length})})]}),e.jsx("div",{className:"max-h-[640px] overflow-y-auto p-3",children:S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(I,{size:22,className:"animate-spin text-gray-400"})}):w.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 px-4 py-12 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 text-gray-400",children:e.jsx(de,{size:18})}),e.jsx("h3",{className:"mt-3 text-sm font-semibold text-gray-900",children:t("market.empty.filteredTitle")}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-gray-500",children:t("market.empty.filteredDescription")})]}):e.jsxs("div",{className:"space-y-3",children:[G.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"px-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.installedHeading")}),G.map(n=>e.jsx(xe,{skill:n,selected:(i==null?void 0:i.name)===n.name,onSelect:$},`${n.registryId??"_"}:${n.name}`))]}),ie.length>0&&e.jsxs("div",{className:"space-y-2",children:[G.length>0&&e.jsx("p",{className:"px-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:t("market.list.availableHeading")}),ie.map(n=>e.jsx(xe,{skill:n,selected:(i==null?void 0:i.name)===n.name,onSelect:$},`${n.registryId??"_"}:${n.name}`))]})]})})]}),e.jsx(ht,{skill:i,markdownBody:Q,descriptionLoading:i?M===i.name:!1,descriptionError:ze,busy:i?De===i.name:!1,canInstall:!!((i==null?void 0:i.registryId)??R),onInstall:Se,onUninstall:Ae,onRefresh:()=>{U(),W((i==null?void 0:i.name)??null),_().catch(()=>{})}})]})]}),r&&e.jsx(yt,{registries:Te,loading:S,deletingRegistryId:Re,onAdd:()=>{h(null),c(""),m(""),l(!0)},onClose:()=>s(!1),onDelete:$e}),d&&e.jsx(gt,{url:o,tokenEnv:u,error:y,submitting:Me,onChangeUrl:c,onChangeTokenEnv:m,onClose:()=>{h(null),l(!1)},onSubmit:_e}),E&&e.jsx(ut,{itemName:E.displayName||E.name,onConfirm:()=>{q(E),O(null)},onCancel:()=>O(null)})]})}export{bt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ah as o,ai as n}from"./main-DmvFaz-d.js";const t=(a,r)=>o.lang.round(n.parse(a)[r]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s,c as e,a as r,b as l}from"./chunk-T2TOU4HS-CffcwNHx.js";import{_ as t}from"./main-DmvFaz-d.js";import"./chunk-5HRBRIJM-DAxM5Ul_.js";var _={parser:l,db:r,renderer:e,styles:s,init:t(a=>{a.class||(a.class={}),a.class.arrowMarkerAbsolute=a.arrowMarkerAbsolute,r.clear()},"init")};export{_ as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s,c as e,a as r,b as l}from"./chunk-T2TOU4HS-CffcwNHx.js";import{_ as t}from"./main-DmvFaz-d.js";import"./chunk-5HRBRIJM-DAxM5Ul_.js";var _={parser:l,db:r,renderer:e,styles:s,init:t(a=>{a.class||(a.class={}),a.class.arrowMarkerAbsolute=a.arrowMarkerAbsolute,r.clear()},"init")};export{_ as diagram};
|