@hearsay-tools/squawk 0.18.0-dev.8215 → 0.18.0-dev.8218
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/ci-wait/controller.d.ts +7 -7
- package/dist/contract/index.js +2 -0
- package/dist/delegation/routes.d.ts +65 -65
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/models-routes.d.ts +13 -13
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/server.d.ts +1520 -1520
- package/dist/server/server.js +8 -9
- package/dist/server/server.js.map +1 -1
- package/package.json +4 -4
- package/scripts/profile-lint-compare.ts +101 -0
- package/scripts/profile-lint.ts +116 -14
- package/web/dist/assets/{accounts-section-3TFV3bKA.js → accounts-section-DpX5vTr7.js} +1 -1
- package/web/dist/assets/{activity-motion-DIEqBTn_.js → activity-motion-B7vHpK-u.js} +1 -1
- package/web/dist/assets/{activity-route-1e-zJAwF.js → activity-route-D84XrmQO.js} +1 -1
- package/web/dist/assets/{agent-config-section-BEhRUFXI.js → agent-config-section-Btyd_I6J.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-CPFpExY0.js → agent-defaults-section-D42khLKT.js} +1 -1
- package/web/dist/assets/{appearance-DmZqmV_h.js → appearance-BdWvRErI.js} +1 -1
- package/web/dist/assets/{automations-route-BQTvY9OZ.js → automations-route-CVK-f13I.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-CrCQrLkj.js → commit-diff-panel-DEgRHEFl.js} +1 -1
- package/web/dist/assets/{diff-CSURjwWN.js → diff-K_Xswloe.js} +2 -2
- package/web/dist/assets/{diff-view-C0EkYWIb.js → diff-view-DQOZSURG.js} +1 -1
- package/web/dist/assets/{file-preview-Dwpny4J1.js → file-preview-PwiOYFhV.js} +1 -1
- package/web/dist/assets/{git-toolbar-Cxylz9oM.js → git-toolbar-DfFwDI49.js} +1 -1
- package/web/dist/assets/{github-QMdDPo6m.js → github-DHOg6-co.js} +1 -1
- package/web/dist/assets/{global-activity-route-CbOpfU7Q.js → global-activity-route-Bx6y-b0h.js} +1 -1
- package/web/dist/assets/{index-Bra3Zx6_.js → index-Br3WCnOm.js} +6 -6
- package/web/dist/assets/{markdown-CVLWRUFa.js → markdown-POxkTBG0.js} +1 -1
- package/web/dist/assets/{notifications-section-y0N1nPKx.js → notifications-section-B-lcEfAs.js} +1 -1
- package/web/dist/assets/preview-pane-connected-DeAYL6ND.js +3 -0
- package/web/dist/assets/{projects-section-DwrBHp8U.js → projects-section-B1MB9FoT.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-B63ytixw.js → prompt-templates-section-C6NTpSpA.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-BaEqkFLb.js → remote-settings-notice-CrHduqnC.js} +1 -1
- package/web/dist/assets/repo-git-KGxu_ZKb.js +1 -0
- package/web/dist/assets/{report-reader-4K1U0nwt.js → report-reader-CnXmsiMI.js} +1 -1
- package/web/dist/assets/{reports-DzfdonA_.js → reports-CzsCz6ZC.js} +1 -1
- package/web/dist/assets/{run-header-BwxE9ges.js → run-header-BcuJbBox.js} +2 -2
- package/web/dist/assets/{settings-agent-picker-BsfSkgY9.js → settings-agent-picker-D9OiVDV3.js} +1 -1
- package/web/dist/assets/{settings-shell-DDTVjo7C.js → settings-shell-D9LDT4iY.js} +1 -1
- package/web/dist/assets/{skills-Cw_PL5-A.js → skills-Df3f4tt8.js} +1 -1
- package/web/dist/assets/{task-changes-DLzIXSTR.js → task-changes-B45GjG50.js} +1 -1
- package/web/dist/assets/{task-commits-amn0LePZ.js → task-commits-C6_f5ewJ.js} +1 -1
- package/web/dist/assets/{task-files-9b6zqJWa.js → task-files-YaD4DU-8.js} +1 -1
- package/web/dist/assets/{task-github-item-DJvWvk2q.js → task-github-item-D1QAOVjQ.js} +1 -1
- package/web/dist/assets/{task-thread-DA-IdbEA.js → task-thread-BoOE1dvx.js} +6 -6
- package/web/dist/assets/{thread-state-PGrlMiQA.js → thread-state-C3QKqNMn.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-CMiYRssU.js → use-hand-to-agent-state-DGAvwfdj.js} +1 -1
- package/web/dist/assets/{workflows-DowJdAnR.js → workflows-B2pwgXHF.js} +3 -3
- package/web/dist/assets/{workspace-tools-BPmJcyzi.js → workspace-tools-DfCerd4L.js} +1 -1
- package/web/dist/assets/{worktrees-section-Bn-NIqrK.js → worktrees-section-Dhlt22RI.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/assets/preview-pane-connected-DzLCKXRK.js +0 -3
- package/web/dist/assets/repo-git-CY6YcBMo.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hearsay-tools/squawk",
|
|
3
|
-
"version": "0.18.0-dev.
|
|
3
|
+
"version": "0.18.0-dev.8218",
|
|
4
4
|
"description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/parser": "^8.0.8",
|
|
70
70
|
"@babel/types": "^8.0.8",
|
|
71
|
-
"@open-mercato/cezar-api-client": "0.18.0-dev.
|
|
72
|
-
"@open-mercato/cezar-contract": "0.18.0-dev.
|
|
71
|
+
"@open-mercato/cezar-api-client": "0.18.0-dev.8218",
|
|
72
|
+
"@open-mercato/cezar-contract": "0.18.0-dev.8218",
|
|
73
73
|
"@types/node": "^24.19.1",
|
|
74
74
|
"@types/ws": "^8.18.1",
|
|
75
75
|
"esbuild": "^0.28.1",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "b5cf06971421f9f9ae437e1ddccf33a81f24d31a"
|
|
90
90
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The report of `profile-lint.ts --compare` (hearsay-tools/squawk#4238): pure functions over the
|
|
3
|
+
* rounds that the script measured, so a test can pin the format without running oxlint.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { isAbsolute, relative, sep } from 'node:path';
|
|
7
|
+
|
|
8
|
+
export interface CompareMeasure { user: number; sys: number }
|
|
9
|
+
|
|
10
|
+
/** One alternating round: base, then candidate, each with its user-CPU run and its `--debug timings` run. */
|
|
11
|
+
export interface CompareRound {
|
|
12
|
+
/** The 1-minute load before each user-CPU run of the round. */
|
|
13
|
+
loads: number[];
|
|
14
|
+
base: CompareMeasure;
|
|
15
|
+
candidate: CompareMeasure;
|
|
16
|
+
baseTimings: Record<string, number>;
|
|
17
|
+
candidateTimings: Record<string, number>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CompareInput { base: string; command: string; rounds: CompareRound[]; cores: number }
|
|
21
|
+
|
|
22
|
+
export function median(values: readonly number[]): number {
|
|
23
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
24
|
+
const middle = Math.floor(sorted.length / 2);
|
|
25
|
+
const upper = sorted[middle] ?? Number.NaN;
|
|
26
|
+
return sorted.length % 2 === 1 ? upper : ((sorted[middle - 1] ?? Number.NaN) + upper) / 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The `cez/*` rows of oxlint's `--debug timings` table: rule name to JS milliseconds. */
|
|
30
|
+
export function ruleTimings(output: string): Record<string, number> {
|
|
31
|
+
const timings: Record<string, number> = {};
|
|
32
|
+
for (const line of output.split('\n')) {
|
|
33
|
+
const [name, ms] = line.trim().split(/\s+/);
|
|
34
|
+
if (name?.startsWith('cez/') && Number.isFinite(Number(ms))) timings[name] = Number(ms);
|
|
35
|
+
}
|
|
36
|
+
return timings;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The file count of oxlint's `Finished in … on N files` line, or undefined when the line is missing. */
|
|
40
|
+
export function lintedFiles(output: string): number | undefined {
|
|
41
|
+
const match = /^Finished in .* on (\d+) files?\b/m.exec(output);
|
|
42
|
+
return match ? Number(match[1]) : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Lint paths relative to the repository root, so each side lints its own tree: an absolute path would
|
|
47
|
+
* make an extracted base tree lint the working tree's files. A path outside the root is refused.
|
|
48
|
+
*/
|
|
49
|
+
export function rootRelativePaths(paths: readonly string[], root: string): string[] {
|
|
50
|
+
return paths.map(path => {
|
|
51
|
+
if (!isAbsolute(path)) return path;
|
|
52
|
+
const inside = relative(root, path);
|
|
53
|
+
if (inside === '..' || inside.startsWith(`..${sep}`) || isAbsolute(inside)) throw new Error(`${path} is outside ${root}`);
|
|
54
|
+
return inside === '' ? '.' : inside;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const sum = (timings: Record<string, number>) => Object.values(timings).reduce((total, ms) => total + ms, 0);
|
|
59
|
+
const fixed = (value: number, digits = 2) => value.toFixed(digits);
|
|
60
|
+
const ratio = (candidate: number, base: number) => (base > 0 ? fixed(candidate / base) : 'n/a');
|
|
61
|
+
|
|
62
|
+
function sideRow(label: string, measures: CompareMeasure[], timings: Record<string, number>[]): { row: string; user: number; js: number } {
|
|
63
|
+
const users = measures.map(m => m.user);
|
|
64
|
+
const user = median(users);
|
|
65
|
+
const js = median(timings.map(sum));
|
|
66
|
+
const row = `| ${label} | ${fixed(user)} | ${fixed(Math.min(...users))}–${fixed(Math.max(...users))} | ${fixed(median(measures.map(m => m.sys)))} | ${fixed(js, 0)} |`;
|
|
67
|
+
return { row, user, js };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function ruleRows(rounds: readonly CompareRound[]): string[] {
|
|
71
|
+
const names = [...new Set(rounds.flatMap(r => [...Object.keys(r.baseTimings), ...Object.keys(r.candidateTimings)]))];
|
|
72
|
+
const rows = names.map(name => {
|
|
73
|
+
const base = median(rounds.map(r => r.baseTimings[name] ?? 0));
|
|
74
|
+
const candidate = median(rounds.map(r => r.candidateTimings[name] ?? 0));
|
|
75
|
+
return { name, base, candidate };
|
|
76
|
+
});
|
|
77
|
+
rows.sort((a, b) => b.candidate - a.candidate || a.name.localeCompare(b.name));
|
|
78
|
+
return rows.map(r => `| ${r.name} | ${fixed(r.base, 0)} | ${fixed(r.candidate, 0)} | ${r.candidate - r.base >= 0 ? '+' : ''}${fixed(r.candidate - r.base, 0)} |`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The Markdown report: per-side medians and ranges, the ratios, host load against the ceiling, and per-rule JS time. */
|
|
82
|
+
export function compareReport({ base, command, rounds, cores }: CompareInput): string {
|
|
83
|
+
const baseSide = sideRow('base', rounds.map(r => r.base), rounds.map(r => r.baseTimings));
|
|
84
|
+
const candidateSide = sideRow('candidate', rounds.map(r => r.candidate), rounds.map(r => r.candidateTimings));
|
|
85
|
+
const load = median(rounds.flatMap(r => r.loads));
|
|
86
|
+
const ceiling = cores / 2;
|
|
87
|
+
const lines = [
|
|
88
|
+
`Base: ${base}. Candidate: the working tree. Command: ${command}; ${rounds.length} alternating rounds; CPU in seconds, JS time in ms.`,
|
|
89
|
+
'',
|
|
90
|
+
'| Side | User median | User range | Sys median | `cez/*` JS ms median |',
|
|
91
|
+
'| --- | ---: | ---: | ---: | ---: |',
|
|
92
|
+
baseSide.row,
|
|
93
|
+
candidateSide.row,
|
|
94
|
+
'',
|
|
95
|
+
`Candidate/base: user CPU ${ratio(candidateSide.user, baseSide.user)}, \`cez/*\` JS time ${ratio(candidateSide.js, baseSide.js)}.`,
|
|
96
|
+
`Host: ${cores} cores; median 1-minute load ${fixed(load)}; user-CPU ceiling ${fixed(ceiling)} (half the cores).`,
|
|
97
|
+
];
|
|
98
|
+
if (load >= ceiling) lines.push('', '**Load above ceiling: user CPU is not evidence; report the `--debug timings` sums.**');
|
|
99
|
+
lines.push('', '| Rule | Base ms | Candidate ms | Delta |', '| --- | ---: | ---: | ---: |', ...ruleRows(rounds));
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
package/scripts/profile-lint.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { availableParallelism, loadavg as osLoadavg, tmpdir } from 'node:os';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
6
6
|
import { oxlintBin } from '../src/lint/run.ts';
|
|
@@ -10,12 +10,15 @@ import { PROCESS_OWNER_RULES } from '../src/lint/owner-process-rules.ts';
|
|
|
10
10
|
import { STATE_OWNER_RULES } from '../src/lint/owner-state-rules.ts';
|
|
11
11
|
import { READER_OWNER_RULES } from '../src/lint/owner-reader-rules.ts';
|
|
12
12
|
import { activeRunWriteRules } from '../src/lint/active-run-write.ts';
|
|
13
|
+
import { gitEnv, gitSync } from '../src/git-command.ts';
|
|
14
|
+
import { type CompareRound, compareReport, lintedFiles, rootRelativePaths, ruleTimings } from './profile-lint-compare.ts';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Measures what the `cez` oxlint plugin costs (hearsay-tools/squawk#3774). A developer tool, not a
|
|
16
18
|
* test: its numbers depend on the host and its load, so it prints `/proc/loadavg` beside each run.
|
|
17
19
|
*
|
|
18
20
|
* node packages/cezar/scripts/profile-lint.ts [--alone] [--families] [--runs N] [path...]
|
|
21
|
+
* node packages/cezar/scripts/profile-lint.ts --compare <ref|config> [--runs N] [path...]
|
|
19
22
|
*
|
|
20
23
|
* It runs `oxlint -c <config> <path...>` (default path `packages`) from the repository root with
|
|
21
24
|
* these configs, each written to a scratch directory:
|
|
@@ -28,32 +31,69 @@ import { activeRunWriteRules } from '../src/lint/active-run-write.ts';
|
|
|
28
31
|
* rule or family. Each run's user and system CPU come from the shell's `times` for its child.
|
|
29
32
|
* Last, it runs the full config once with `--debug timings` and lists oxlint's own JS time per rule
|
|
30
33
|
* (visitor and `create` time only; tree transfer, walking and garbage collection are not in it).
|
|
34
|
+
*
|
|
35
|
+
* `--compare` measures a base against the working tree in N alternating rounds (default 5); see
|
|
36
|
+
* `profile-lint-compare.ts` for the report. A base that names an existing file is an oxlint config,
|
|
37
|
+
* linted over the working tree. Any other base is a commit: its tree is extracted with `git archive`
|
|
38
|
+
* and linted with its own `.oxlintrc.json`, because the rules locate files relative to their own
|
|
39
|
+
* repository root. Both sides use the working tree's oxlint binary.
|
|
31
40
|
*/
|
|
32
41
|
|
|
33
42
|
interface Measure { label: string; user: number; sys: number; wall: number; load: string }
|
|
34
43
|
|
|
35
|
-
export interface ProfileOptions { paths: string[]; runs: number; alone: boolean; families: boolean }
|
|
44
|
+
export interface ProfileOptions { paths: string[]; runs: number; alone: boolean; families: boolean; compare?: string }
|
|
45
|
+
|
|
46
|
+
/** The value after `flag`, or undefined without the flag; a flag with no value throws. */
|
|
47
|
+
function flagValue(args: readonly string[], flag: string): string | undefined {
|
|
48
|
+
const index = args.indexOf(flag);
|
|
49
|
+
if (index < 0) return undefined;
|
|
50
|
+
const value = args[index + 1];
|
|
51
|
+
if (value === undefined || value.startsWith('--')) throw new Error(`${flag} needs a value`);
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `--runs N`: a positive integer, or the statistics describe no run at all. */
|
|
56
|
+
function roundCount(value: string): number {
|
|
57
|
+
const count = Number(value);
|
|
58
|
+
if (!/^\d+$/.test(value) || count < 1) throw new Error(`--runs needs a positive integer, not ${value}`);
|
|
59
|
+
return count;
|
|
60
|
+
}
|
|
36
61
|
|
|
37
|
-
/** The command line: flags, `--runs N`, and the paths to lint (default `packages`). */
|
|
62
|
+
/** The command line: flags, `--runs N`, `--compare <ref|config>`, and the paths to lint (default `packages`). */
|
|
38
63
|
export function profileArgs(args: readonly string[]): ProfileOptions {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
64
|
+
const runs = flagValue(args, '--runs');
|
|
65
|
+
const compare = flagValue(args, '--compare');
|
|
66
|
+
const values = new Set(['--runs', '--compare'].map(flag => args.indexOf(flag) + 1).filter(index => index > 0));
|
|
67
|
+
const paths = args.filter((arg, index) => !arg.startsWith('--') && !values.has(index));
|
|
41
68
|
return {
|
|
42
69
|
paths: paths.length > 0 ? paths : ['packages'],
|
|
43
|
-
runs:
|
|
70
|
+
runs: runs === undefined ? (compare === undefined ? 1 : 5) : roundCount(runs),
|
|
44
71
|
alone: args.includes('--alone'),
|
|
45
72
|
families: args.includes('--families'),
|
|
73
|
+
...(compare === undefined ? {} : { compare }),
|
|
46
74
|
};
|
|
47
75
|
}
|
|
48
76
|
|
|
49
|
-
|
|
77
|
+
// The test imports `profileArgs`; only a direct run reads the command line, inside its error handler.
|
|
78
|
+
let paths: string[] = [];
|
|
79
|
+
let runs = 1;
|
|
80
|
+
let alone = false;
|
|
81
|
+
let byFamily = false;
|
|
82
|
+
let compare: string | undefined;
|
|
83
|
+
|
|
84
|
+
function readCommandLine(): void {
|
|
85
|
+
const options = profileArgs(process.argv.slice(2));
|
|
86
|
+
paths = rootRelativePaths(options.paths, repoRoot);
|
|
87
|
+
({ runs, alone, families: byFamily, compare } = options);
|
|
88
|
+
}
|
|
50
89
|
|
|
51
90
|
const base = JSON.parse(readFileSync(join(repoRoot, '.oxlintrc.json'), 'utf8')) as { jsPlugins?: string[]; rules: Record<string, unknown> };
|
|
52
91
|
const pluginPath = resolve(repoRoot, base.jsPlugins?.[0] ?? 'packages/cezar/src/lint/plugin.ts');
|
|
53
92
|
const builtinRules = Object.fromEntries(Object.entries(base.rules).filter(([name]) => !name.startsWith('cez/')));
|
|
54
93
|
let scratch = '';
|
|
55
94
|
|
|
56
|
-
const loadavg = () => (
|
|
95
|
+
const loadavg = () => osLoadavg().map(value => value.toFixed(2)).join(' ');
|
|
96
|
+
const oneMinute = () => osLoadavg()[0] ?? Number.NaN;
|
|
57
97
|
const seconds = (text: string) => {
|
|
58
98
|
const match = /^(\d+)m([\d.]+)s$/.exec(text);
|
|
59
99
|
return match ? Number(match[1]) * 60 + Number(match[2]) : Number.NaN;
|
|
@@ -77,10 +117,10 @@ function noopPlugin(name: string, visitors: string[]): string {
|
|
|
77
117
|
}
|
|
78
118
|
|
|
79
119
|
/** One oxlint run; `times` in a POSIX shell reports the CPU its children used. */
|
|
80
|
-
function measure(label: string, config: string): Measure {
|
|
120
|
+
function measure(label: string, config: string, cwd = repoRoot): Measure {
|
|
81
121
|
const load = loadavg();
|
|
82
122
|
const started = performance.now();
|
|
83
|
-
const shell = spawnSync('/bin/sh', ['-c', '"$@" >/dev/null 2>&1; times', 'sh', process.execPath, oxlintBin(), '-c', config, ...paths], { cwd
|
|
123
|
+
const shell = spawnSync('/bin/sh', ['-c', '"$@" >/dev/null 2>&1; times', 'sh', process.execPath, oxlintBin(), '-c', config, ...paths], { cwd, encoding: 'utf8' });
|
|
84
124
|
const wall = (performance.now() - started) / 1000;
|
|
85
125
|
const [user = '', sys = ''] = (shell.stdout.trim().split('\n').at(-1) ?? '').split(/\s+/);
|
|
86
126
|
return { label, user: seconds(user), sys: seconds(sys), wall, load };
|
|
@@ -113,8 +153,7 @@ function main(): void {
|
|
|
113
153
|
console.log(`Command: oxlint -c <config> ${paths.join(' ')} (cwd ${repoRoot}); best of ${runs}; CPU in seconds.\n`);
|
|
114
154
|
console.log('| Config | User | Sys | Wall | Load (1/5/15 min) |\n| --- | ---: | ---: | ---: | --- |');
|
|
115
155
|
for (const m of results) console.log(row(m));
|
|
116
|
-
const
|
|
117
|
-
const lines = timings.split('\n').filter(line => line.startsWith('cez/'));
|
|
156
|
+
const lines = timingsOutput('.oxlintrc.json').split('\n').filter(line => line.startsWith('cez/'));
|
|
118
157
|
console.log(`\nOxlint's JS time per rule (\`--debug timings\`, load ${loadavg()}):\n\n| Rule | ms | Calls |\n| --- | ---: | ---: |`);
|
|
119
158
|
for (const line of lines) {
|
|
120
159
|
const [name, ms, , calls] = line.split(/\s+/);
|
|
@@ -122,10 +161,73 @@ function main(): void {
|
|
|
122
161
|
}
|
|
123
162
|
}
|
|
124
163
|
|
|
164
|
+
/** Oxlint's `--debug timings` output for one run; lint findings make it exit 1, which is not a failure here. */
|
|
165
|
+
function timingsOutput(config: string, cwd = repoRoot): string {
|
|
166
|
+
const run = spawnSync(process.execPath, [oxlintBin(), '-c', config, '-f', 'default', '--debug', 'timings', ...paths], { cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
167
|
+
if (run.status !== 0 && run.status !== 1) throw new Error(`oxlint --debug timings exited ${run.status}: ${run.stderr}`);
|
|
168
|
+
return run.stdout;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface Side { config: string; cwd: string }
|
|
172
|
+
|
|
173
|
+
/** The base side: an existing file is a config over the working tree; anything else is a commit's own tree. */
|
|
174
|
+
function baseSide(arg: string): { side: Side; describe: string } {
|
|
175
|
+
const file = resolve(arg);
|
|
176
|
+
if (existsSync(file)) return { side: { config: file, cwd: repoRoot }, describe: `config ${arg}` };
|
|
177
|
+
// The git helpers drop inherited `GIT_DIR`-style variables (a hook, `rebase --exec`), so git acts on `cwd`.
|
|
178
|
+
let sha: string;
|
|
179
|
+
try {
|
|
180
|
+
sha = gitSync(['rev-parse', '--verify', '--quiet', `${arg}^{commit}`], { cwd: repoRoot, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
181
|
+
} catch {
|
|
182
|
+
throw new Error(`--compare ${arg}: not a file and not a commit`);
|
|
183
|
+
}
|
|
184
|
+
const tree = join(scratch, 'base');
|
|
185
|
+
mkdirSync(tree);
|
|
186
|
+
execFileSync('/bin/sh', ['-c', 'git archive "$1" | tar -x -C "$2"', 'sh', sha, tree], { cwd: repoRoot, env: gitEnv() });
|
|
187
|
+
// Oxlint applies the `.gitignore` of an enclosing repository. A temp directory inside an ignored
|
|
188
|
+
// path (a task's TMPDIR) would hide every file, so the tree gets a repository boundary of its own.
|
|
189
|
+
gitSync(['init', '--quiet', tree]);
|
|
190
|
+
for (const dir of ['.', ...readdirSync(join(repoRoot, 'packages')).map(name => join('packages', name))]) {
|
|
191
|
+
const modules = join(repoRoot, dir, 'node_modules');
|
|
192
|
+
if (existsSync(modules) && existsSync(join(tree, dir)) && !existsSync(join(tree, dir, 'node_modules'))) symlinkSync(modules, join(tree, dir, 'node_modules'), 'dir');
|
|
193
|
+
}
|
|
194
|
+
return { side: { config: join(tree, '.oxlintrc.json'), cwd: tree }, describe: `commit ${arg} (${sha.slice(0, 9)})` };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** One side's per-rule JS time. A side that lints no files fails: a CPU time from that run measures nothing. */
|
|
198
|
+
function sideTimings(label: string, side: Side): Record<string, number> {
|
|
199
|
+
const output = timingsOutput(side.config, side.cwd);
|
|
200
|
+
if (!lintedFiles(output)) throw new Error(`${label}: oxlint linted no files for ${paths.join(' ')} in ${side.cwd}`);
|
|
201
|
+
return ruleTimings(output);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function compareMain(arg: string): void {
|
|
205
|
+
const { side: base, describe } = baseSide(arg);
|
|
206
|
+
const candidate: Side = { config: join(repoRoot, '.oxlintrc.json'), cwd: repoRoot };
|
|
207
|
+
const rounds: CompareRound[] = [];
|
|
208
|
+
for (let round = 1; round <= runs; round++) {
|
|
209
|
+
const loads = [oneMinute()];
|
|
210
|
+
const baseRun = measure('base', base.config, base.cwd);
|
|
211
|
+
loads.push(oneMinute());
|
|
212
|
+
const candidateRun = measure('candidate', candidate.config, candidate.cwd);
|
|
213
|
+
const baseTimings = sideTimings('base', base);
|
|
214
|
+
const candidateTimings = sideTimings('candidate', candidate);
|
|
215
|
+
rounds.push({ loads, base: baseRun, candidate: candidateRun, baseTimings, candidateTimings });
|
|
216
|
+
const [baseLoad = Number.NaN, candidateLoad = Number.NaN] = loads;
|
|
217
|
+
console.error(`round ${round}/${runs}: base ${baseRun.user.toFixed(2)} s user at load ${baseLoad.toFixed(2)}, candidate ${candidateRun.user.toFixed(2)} s user at load ${candidateLoad.toFixed(2)}`);
|
|
218
|
+
}
|
|
219
|
+
console.log(compareReport({ base: describe, command: `oxlint -c <config> ${paths.join(' ')}`, rounds, cores: availableParallelism() }));
|
|
220
|
+
}
|
|
221
|
+
|
|
125
222
|
if (import.meta.main) {
|
|
126
223
|
scratch = mkdtempSync(join(tmpdir(), 'cez-profile-lint-'));
|
|
127
224
|
try {
|
|
128
|
-
|
|
225
|
+
readCommandLine();
|
|
226
|
+
if (compare === undefined) main();
|
|
227
|
+
else compareMain(compare);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(`profile-lint: ${error instanceof Error ? error.message : String(error)}`);
|
|
230
|
+
process.exitCode = 2;
|
|
129
231
|
} finally {
|
|
130
232
|
rmSync(scratch, { recursive: true, force: true });
|
|
131
233
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ar as r,Jt as i,ci as a,f as o,hn as s,i as c}from"./project-scope-context-C0FJXpqD.js";import{$t as l,At as u,Et as d,Ft as f,It as p,J as m,M as h,Nt as g,Rt as _,Ut as v,X as y,g as ee,in as b,m as x,o as S,r as C,tt as w,zt as T}from"./queries-CK9ZDDfL.js";import{t as te}from"./useQuery-9BEU-yko.js";import{f as ne}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{y as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as k}from"./folder-browser-vE5IBaDD.js";import{t as A}from"./button-BQ2y4XRB.js";import{t as j}from"./badge-D9JrXe0o.js";import{a as M,i as N,o as P,r as F,s as I,t as L}from"./dialog-BVF6dIeS.js";import{t as R}from"./status-dot-DtAOFiIi.js";import{n as z}from"./agents-settings-path-7X6_cvUg.js";import{t as B}from"./centered-state-V15AR_qo.js";import{Bt as V,Gt as H,Ht as U,Kt as W,N as G,Ut as K,Vt as q,Wt as J,j as Y,qt as re}from"./index-Bra3Zx6_.js";import{n as X,r as ie,t as ae}from"./settings-agent-picker-BsfSkgY9.js";var oe=O(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Z=e(t(),1),Q=n(),se=`~/.claude-second`;function ce({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=v().data,[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(r??n[0]??`claude`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),y=ee(),b=p.trim();return(0,Q.jsx)(L,{open:e,onOpenChange:t,children:(0,Q.jsxs)(F,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(I,{children:`Add agent account`}),(0,Q.jsx)(N,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,Q.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:l,onChange:e=>u(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:d,placeholder:`Work`,onChange:e=>f(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:p,placeholder:_(i,l)?.accountFolderExample??se,onChange:e=>{m(e.target.value),c(null),y.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":h,onClick:()=>g(e=>!e),children:h?`Hide folders`:`Browse…`})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),h?(0,Q.jsx)(k,{path:a,selected:s,onSelect:e=>{c(e),m(e.path),y.reset()},onEnter:e=>{o(e),c(null),y.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,y.isError?(0,Q.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:y.error instanceof Error?y.error.message:`could not add that folder`}):null,(0,Q.jsxs)(M,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(A,{"data-slot":`add-account-confirm`,disabled:b===``||y.isPending,onClick:()=>{b===``||y.isPending||y.mutate({provider:l,configDir:b,...d.trim()?{label:d.trim()}:{}},{onSuccess:()=>{t(!1),f(``),m(``),c(null),g(!1),E(`Account added — use Connect to sign in`)}})},children:y.isPending?`Adding…`:`Add account`})]})]})})}async function le(e){return s(await o.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function ue(e,t){return s(await o.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var de={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function fe(e){let t=h().data?.capabilities?.settingsAdmin===!0,n=a(),r=[`runner-install`,e],i=te({queryKey:r,queryFn:()=>le(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),o=b({mutationFn:t=>ue(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),s=i.data;return{allowed:t,data:s,busy:o.isPending||!!s&&s.phase!==`idle`&&s.phase!==`failed`,error:o.error?.message??i.error?.message??s?.error,action:o,status:i}}function pe({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,Q.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function $({runner:e}){let t=fe(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,Q.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${de[r.phase]}`:``]}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,Q.jsx)(pe,{state:t}),r?.installedVersion?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var me={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function he(){let e=S(),t=v();if(e.isPending||t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,Q.jsx)(B,{icon:(0,Q.jsx)(oe,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,Q.jsx)(_e,{data:e.data,runners:t.data})}function ge(){let{hash:e}=ne();(0,Z.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function _e({data:e,runners:t}){let n=h(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=w();return ge(),(0,Q.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Install, update and sign in to each agent, and set what a project runs when it has not chosen.`}),e.editable?null:(0,Q.jsx)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:`Agent accounts are managed from the machine that owns the checkout — this cockpit runs in hosted mode.`}),(0,Q.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-4`,children:t.runners.map(r=>(0,Q.jsx)(ye,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>i(r.id),onRemove:o},r.id))}),(0,Q.jsx)(be,{runners:t}),r===null?null:(0,Q.jsx)(ce,{open:!0,onOpenChange:e=>!e&&i(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,Q.jsx)(V,{open:a!==null,onOpenChange:e=>!e&&o(null),children:(0,Q.jsxs)(K,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(W,{children:[(0,Q.jsxs)(re,{children:[`Remove “`,a?.label,`”?`]}),(0,Q.jsxs)(J,{children:[`This only forgets the account. Nothing in `,a?.configDir,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{children:`Cancel`}),(0,Q.jsx)(q,{"data-action":`accounts-remove-confirm`,disabled:s.isPending,onClick:()=>{let e=a;e&&s.mutate(e.id,{onSuccess:()=>{o(null),E(`Removed ${e.label}`)},onError:e=>E(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function ve({entry:e,check:t}){return t===void 0?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking…`}):t.available?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}),t.version?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,Q.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null]}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed`,e.installHint?(0,Q.jsxs)(Q.Fragment,{children:[` — `,(0,Q.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function ye({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.managedInstall===!0&&n,d=a.filter(e=>e.isDefault).length,f=`${z(l)}-title`;return(0,Q.jsxs)(`section`,{id:z(l),tabIndex:-1,"aria-labelledby":f,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col gap-4 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h3`,{id:f,className:`settings-account-provider-title`,children:e.displayName}),u?(0,Q.jsx)($,{runner:l}):null,(0,Q.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[u?null:(0,Q.jsx)(ve,{entry:e,check:t}),i?(0,Q.jsxs)(`span`,{className:`settings-account-count`,children:[a.length,` `,a.length===1?`account`:`accounts`,` (`,d,` discovered, `,a.length-d,` added)`]}):null]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`ul`,{children:a.map(e=>(0,Q.jsx)(Ce,{account:e,runners:r,onRemove:()=>c(e)},e.id))}),o?(0,Q.jsx)(`div`,{className:`settings-account-add-row`,children:(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`})}):(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11px] text-soft-foreground`,children:[e.displayName,` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]})]}):e.browserLogin?(0,Q.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Discovered account`}),(0,Q.jsx)(X,{provider:l,label:e.displayName})]}):null]})}function be({runners:e}){let[t,n]=(0,Z.useState)(null),r=a(),o=u(),s=m(),c=l(T(e)),d=b({mutationFn:e=>i(e),onSuccess:e=>r.setQueryData(g.config,e),onError:e=>E(e.message,{tone:`danger`})});if(o.data===void 0)return null;let p=ie([],e),h=o.data.agentDefaults.runner??`claude`,_=f(t??h,T(e))??t??h,v=o.data.agentDefaults.models??{};return(0,Q.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,Q.jsx)(ae,{rows:p,runner:h,accountFor:()=>null,providerStatus:s,disabled:d.isPending,onPick:e=>{e!==h&&d.mutate({agentDefaults:{runner:e}})}}),(0,Q.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,Q.jsx)(`span`,{children:`Default model for`}),(0,Q.jsx)(`select`,{"aria-label":`Model agent`,value:_,onChange:e=>n(e.target.value),children:e.runners.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),e.runners.filter(e=>e.id===_).map(t=>(0,Q.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,Q.jsx)(D,{className:`size-4 text-accent-icon shrink-0`}),(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:v[t.id]??``,disabled:d.isPending,onChange:e=>d.mutate({agentDefaults:{models:{[t.id]:e.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[G(t.id,e,c[t.id]?.data,[v[t.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),(0,Q.jsx)(xe,{runner:t.id,runners:e,catalog:c[t.id]})]})]},t.id))]})]})}function xe({runner:e,runners:t,catalog:n}){let r=Y(e,t,n);return r?(0,Q.jsx)(`option`,{disabled:!0,children:r}):null}function Se({account:e,runners:t,status:n}){let r=x();return(0,Q.jsxs)(Q.Fragment,{children:[n&&n.status!==`connected`&&_(t,e.provider)?.browserLogin?(0,Q.jsx)(X,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,n&&n.status!==`connected`&&_(t,e.provider)?.terminalLogin!==!1?(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:r.isPending,onClick:()=>r.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>E(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>E(e instanceof c&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function Ce({account:e,runners:t,onRemove:n}){let i=r(e),a=y(),o=C(i,e.status===void 0),s=e.status??o.data?.status,c=s?me[s.status]:void 0;return(0,Q.jsx)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:(0,Q.jsxs)(`div`,{className:`settings-account-card`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)(j,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`discovered`}):null]}),(0,Q.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11px] text-soft-foreground`,title:e.path,children:e.configDir}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(R,{tone:c?.tone??`neutral`,pulse:c===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:c?.label??`Checking…`}),!s||s.requiresAccountHome===!1?null:e.exists?e.looksValid?null:(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,p(t,e.provider),` config yet`]}):(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:`— folder not created yet; Connect will make it`})]}),s?.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s.hint}):null]})]}),(0,Q.jsxs)(`div`,{className:`settings-account-actions`,children:[(0,Q.jsx)(Se,{account:e,runners:t,status:s}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:a.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>a.mutate(i,{onError:e=>E(e.message,{tone:`danger`})}),children:`Check again`}),(0,Q.jsx)(we,{account:e,onRemove:n})]})]})})}function we({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.label),o=d();return(0,Q.jsx)(Q.Fragment,{children:e.isDefault?null:(0,Q.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>E(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{he as GlobalAgentsSection};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ar as r,Jt as i,ci as a,f as o,hn as s,i as c}from"./project-scope-context-C0FJXpqD.js";import{$t as l,At as u,Et as d,Ft as f,It as p,J as m,M as h,Nt as g,Rt as _,Ut as v,X as y,g as ee,in as b,m as x,o as S,r as C,tt as w,zt as T}from"./queries-CK9ZDDfL.js";import{t as te}from"./useQuery-9BEU-yko.js";import{f as ne}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{y as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as k}from"./folder-browser-vE5IBaDD.js";import{t as A}from"./button-BQ2y4XRB.js";import{t as j}from"./badge-D9JrXe0o.js";import{a as M,i as N,o as P,r as F,s as I,t as L}from"./dialog-BVF6dIeS.js";import{t as R}from"./status-dot-DtAOFiIi.js";import{n as z}from"./agents-settings-path-7X6_cvUg.js";import{t as B}from"./centered-state-V15AR_qo.js";import{Gt as V,Ht as H,Jt as U,Kt as W,N as G,Ut as K,Vt as q,Wt as J,j as Y,qt as re}from"./index-Br3WCnOm.js";import{n as X,r as ie,t as ae}from"./settings-agent-picker-D9OiVDV3.js";var oe=O(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Z=e(t(),1),Q=n(),se=`~/.claude-second`;function ce({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=v().data,[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(r??n[0]??`claude`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),y=ee(),b=p.trim();return(0,Q.jsx)(L,{open:e,onOpenChange:t,children:(0,Q.jsxs)(F,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(I,{children:`Add agent account`}),(0,Q.jsx)(N,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,Q.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:l,onChange:e=>u(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:d,placeholder:`Work`,onChange:e=>f(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:p,placeholder:_(i,l)?.accountFolderExample??se,onChange:e=>{m(e.target.value),c(null),y.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":h,onClick:()=>g(e=>!e),children:h?`Hide folders`:`Browse…`})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),h?(0,Q.jsx)(k,{path:a,selected:s,onSelect:e=>{c(e),m(e.path),y.reset()},onEnter:e=>{o(e),c(null),y.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,y.isError?(0,Q.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:y.error instanceof Error?y.error.message:`could not add that folder`}):null,(0,Q.jsxs)(M,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(A,{"data-slot":`add-account-confirm`,disabled:b===``||y.isPending,onClick:()=>{b===``||y.isPending||y.mutate({provider:l,configDir:b,...d.trim()?{label:d.trim()}:{}},{onSuccess:()=>{t(!1),f(``),m(``),c(null),g(!1),E(`Account added — use Connect to sign in`)}})},children:y.isPending?`Adding…`:`Add account`})]})]})})}async function le(e){return s(await o.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function ue(e,t){return s(await o.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var de={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function fe(e){let t=h().data?.capabilities?.settingsAdmin===!0,n=a(),r=[`runner-install`,e],i=te({queryKey:r,queryFn:()=>le(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),o=b({mutationFn:t=>ue(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),s=i.data;return{allowed:t,data:s,busy:o.isPending||!!s&&s.phase!==`idle`&&s.phase!==`failed`,error:o.error?.message??i.error?.message??s?.error,action:o,status:i}}function pe({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,Q.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function $({runner:e}){let t=fe(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,Q.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${de[r.phase]}`:``]}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,Q.jsx)(pe,{state:t}),r?.installedVersion?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var me={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function he(){let e=S(),t=v();if(e.isPending||t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,Q.jsx)(B,{icon:(0,Q.jsx)(oe,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,Q.jsx)(_e,{data:e.data,runners:t.data})}function ge(){let{hash:e}=ne();(0,Z.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function _e({data:e,runners:t}){let n=h(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=w();return ge(),(0,Q.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Install, update and sign in to each agent, and set what a project runs when it has not chosen.`}),e.editable?null:(0,Q.jsx)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:`Agent accounts are managed from the machine that owns the checkout — this cockpit runs in hosted mode.`}),(0,Q.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-4`,children:t.runners.map(r=>(0,Q.jsx)(ye,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>i(r.id),onRemove:o},r.id))}),(0,Q.jsx)(be,{runners:t}),r===null?null:(0,Q.jsx)(ce,{open:!0,onOpenChange:e=>!e&&i(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,Q.jsx)(q,{open:a!==null,onOpenChange:e=>!e&&o(null),children:(0,Q.jsxs)(J,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(re,{children:[(0,Q.jsxs)(U,{children:[`Remove “`,a?.label,`”?`]}),(0,Q.jsxs)(V,{children:[`This only forgets the account. Nothing in `,a?.configDir,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,Q.jsxs)(W,{children:[(0,Q.jsx)(K,{children:`Cancel`}),(0,Q.jsx)(H,{"data-action":`accounts-remove-confirm`,disabled:s.isPending,onClick:()=>{let e=a;e&&s.mutate(e.id,{onSuccess:()=>{o(null),E(`Removed ${e.label}`)},onError:e=>E(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function ve({entry:e,check:t}){return t===void 0?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking…`}):t.available?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}),t.version?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,Q.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null]}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed`,e.installHint?(0,Q.jsxs)(Q.Fragment,{children:[` — `,(0,Q.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function ye({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.managedInstall===!0&&n,d=a.filter(e=>e.isDefault).length,f=`${z(l)}-title`;return(0,Q.jsxs)(`section`,{id:z(l),tabIndex:-1,"aria-labelledby":f,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col gap-4 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h3`,{id:f,className:`settings-account-provider-title`,children:e.displayName}),u?(0,Q.jsx)($,{runner:l}):null,(0,Q.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[u?null:(0,Q.jsx)(ve,{entry:e,check:t}),i?(0,Q.jsxs)(`span`,{className:`settings-account-count`,children:[a.length,` `,a.length===1?`account`:`accounts`,` (`,d,` discovered, `,a.length-d,` added)`]}):null]}),i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`ul`,{children:a.map(e=>(0,Q.jsx)(Ce,{account:e,runners:r,onRemove:()=>c(e)},e.id))}),o?(0,Q.jsx)(`div`,{className:`settings-account-add-row`,children:(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`})}):(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11px] text-soft-foreground`,children:[e.displayName,` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]})]}):e.browserLogin?(0,Q.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Discovered account`}),(0,Q.jsx)(X,{provider:l,label:e.displayName})]}):null]})}function be({runners:e}){let[t,n]=(0,Z.useState)(null),r=a(),o=u(),s=m(),c=l(T(e)),d=b({mutationFn:e=>i(e),onSuccess:e=>r.setQueryData(g.config,e),onError:e=>E(e.message,{tone:`danger`})});if(o.data===void 0)return null;let p=ie([],e),h=o.data.agentDefaults.runner??`claude`,_=f(t??h,T(e))??t??h,v=o.data.agentDefaults.models??{};return(0,Q.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,Q.jsx)(ae,{rows:p,runner:h,accountFor:()=>null,providerStatus:s,disabled:d.isPending,onPick:e=>{e!==h&&d.mutate({agentDefaults:{runner:e}})}}),(0,Q.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,Q.jsx)(`span`,{children:`Default model for`}),(0,Q.jsx)(`select`,{"aria-label":`Model agent`,value:_,onChange:e=>n(e.target.value),children:e.runners.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),e.runners.filter(e=>e.id===_).map(t=>(0,Q.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,Q.jsx)(D,{className:`size-4 text-accent-icon shrink-0`}),(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:v[t.id]??``,disabled:d.isPending,onChange:e=>d.mutate({agentDefaults:{models:{[t.id]:e.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[G(t.id,e,c[t.id]?.data,[v[t.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),(0,Q.jsx)(xe,{runner:t.id,runners:e,catalog:c[t.id]})]})]},t.id))]})]})}function xe({runner:e,runners:t,catalog:n}){let r=Y(e,t,n);return r?(0,Q.jsx)(`option`,{disabled:!0,children:r}):null}function Se({account:e,runners:t,status:n}){let r=x();return(0,Q.jsxs)(Q.Fragment,{children:[n&&n.status!==`connected`&&_(t,e.provider)?.browserLogin?(0,Q.jsx)(X,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,n&&n.status!==`connected`&&_(t,e.provider)?.terminalLogin!==!1?(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:r.isPending,onClick:()=>r.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>E(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>E(e instanceof c&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function Ce({account:e,runners:t,onRemove:n}){let i=r(e),a=y(),o=C(i,e.status===void 0),s=e.status??o.data?.status,c=s?me[s.status]:void 0;return(0,Q.jsx)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:(0,Q.jsxs)(`div`,{className:`settings-account-card`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)(j,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`discovered`}):null]}),(0,Q.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11px] text-soft-foreground`,title:e.path,children:e.configDir}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(R,{tone:c?.tone??`neutral`,pulse:c===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:c?.label??`Checking…`}),!s||s.requiresAccountHome===!1?null:e.exists?e.looksValid?null:(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,p(t,e.provider),` config yet`]}):(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:`— folder not created yet; Connect will make it`})]}),s?.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s.hint}):null]})]}),(0,Q.jsxs)(`div`,{className:`settings-account-actions`,children:[(0,Q.jsx)(Se,{account:e,runners:t,status:s}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:a.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>a.mutate(i,{onError:e=>E(e.message,{tone:`danger`})}),children:`Check again`}),(0,Q.jsx)(we,{account:e,onRemove:n})]})]})})}function we({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.label),o=d();return(0,Q.jsx)(Q.Fragment,{children:e.isDefault?null:(0,Q.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>E(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{he as GlobalAgentsSection};
|