@tt-a1i/hive 2.1.15 → 2.1.17
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/CHANGELOG.md +29 -4
- package/dist/src/server/action-center-summary.d.ts +2 -2
- package/dist/src/server/agent-run-bootstrap.d.ts +3 -0
- package/dist/src/server/agent-run-bootstrap.js +1 -0
- package/dist/src/server/agent-run-exit-handler.js +2 -7
- package/dist/src/server/agent-run-start-context.d.ts +4 -4
- package/dist/src/server/agent-run-starter.js +12 -5
- package/dist/src/server/agent-startup-instructions.js +1 -7
- package/dist/src/server/agent-stdin-dispatcher.js +0 -1
- package/dist/src/server/diagnostics-support-bundle.d.ts +3 -3
- package/dist/src/server/hive-team-guidance.js +1 -24
- package/dist/src/server/resumed-session-cleanup.d.ts +15 -0
- package/dist/src/server/resumed-session-cleanup.js +26 -0
- package/dist/src/server/role-template-store.d.ts +1 -1
- package/dist/src/server/role-templates.d.ts +0 -2
- package/dist/src/server/role-templates.js +0 -24
- package/dist/src/server/routes-settings.js +6 -1
- package/dist/src/server/routes-workers.js +6 -0
- package/dist/src/server/runtime-store-helpers.d.ts +0 -2
- package/dist/src/server/runtime-store-helpers.js +0 -11
- package/dist/src/server/session-capture-codex.d.ts +1 -0
- package/dist/src/server/session-capture-codex.js +22 -2
- package/dist/src/server/session-capture.d.ts +1 -0
- package/dist/src/server/session-capture.js +5 -4
- package/dist/src/server/spawn-worker-defaults.d.ts +1 -1
- package/dist/src/server/spawn-worker-defaults.js +7 -2
- package/dist/src/server/sqlite-schema-v33.d.ts +1 -1
- package/dist/src/server/sqlite-schema-v33.js +2 -16
- package/dist/src/server/sqlite-schema-v35.js +1 -2
- package/dist/src/server/sqlite-schema-v40.d.ts +3 -0
- package/dist/src/server/sqlite-schema-v40.js +46 -0
- package/dist/src/server/sqlite-schema.d.ts +1 -1
- package/dist/src/server/sqlite-schema.js +6 -1
- package/dist/src/server/team-authz.d.ts +0 -8
- package/dist/src/server/team-authz.js +0 -21
- package/dist/src/server/team-operations.js +0 -2
- package/dist/src/server/workflow-agent-call-executor.d.ts +1 -1
- package/dist/src/server/workflow-agent-call-executor.js +2 -6
- package/dist/src/shared/random-worker-name.js +0 -26
- package/dist/src/shared/types.d.ts +3 -1
- package/dist/src/shared/types.js +2 -0
- package/package.json +1 -1
- package/web/dist/assets/AddWorkerDialog-BrvNv3RW.js +2 -0
- package/web/dist/assets/AddWorkspaceFlow-BxT9VxkV.js +1 -0
- package/web/dist/assets/{FirstRunWizard--NAbC5zC.js → FirstRunWizard-S7Pb_5iy.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-CJhft0Xd.js → MarketplaceDrawer-id-_KJdd.js} +8 -8
- package/web/dist/assets/{TaskGraphDrawer-BUCR4zPH.js → TaskGraphDrawer-Bc3ntINN.js} +1 -1
- package/web/dist/assets/{WhatsNewDialog-B05r5jd4.js → WhatsNewDialog-D-UzFajD.js} +1 -1
- package/web/dist/assets/WorkerModal-DxAQnNYF.js +1 -0
- package/web/dist/assets/{WorkflowsDrawer-pBezljLE.js → WorkflowsDrawer-_JG5sK9V.js} +1 -1
- package/web/dist/assets/WorkspaceMemoryDrawer-CmesL_Hn.js +1 -0
- package/web/dist/assets/{WorkspaceTaskDrawer-CDhs_vbw.js → WorkspaceTaskDrawer-DdAAFy8G.js} +1 -1
- package/web/dist/assets/{index-BTPjdp2B.js → index-CWxTzG6t.js} +20 -22
- package/web/dist/assets/index-DLjB6gMZ.css +1 -0
- package/web/dist/assets/{search-CWX42x_k.js → search-goAiPVWh.js} +1 -1
- package/web/dist/assets/{square-terminal-DoiN9oxG.js → square-terminal-BS_g8jLI.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/dist/src/server/sentinel-heartbeat.d.ts +0 -30
- package/dist/src/server/sentinel-heartbeat.js +0 -145
- package/web/dist/assets/AddWorkerDialog-Dfg4e74k.js +0 -2
- package/web/dist/assets/AddWorkspaceFlow-Bt5i_6p3.js +0 -1
- package/web/dist/assets/WorkerModal-CSM87uaz.js +0 -1
- package/web/dist/assets/WorkspaceMemoryDrawer-Akq36Iaz.js +0 -1
- package/web/dist/assets/index-Cs7E1UKt.css +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isWorkerRole } from '../shared/types.js';
|
|
3
|
+
import { BadRequestError } from './http-errors.js';
|
|
2
4
|
/**
|
|
3
5
|
* Role + name defaults for `team spawn` (routes-team /api/team/spawn).
|
|
4
6
|
*
|
|
@@ -15,7 +17,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
15
17
|
* orchestrator and broke send-by-role). The requested label survives in
|
|
16
18
|
* the worker name and in a generated role description.
|
|
17
19
|
*/
|
|
18
|
-
const
|
|
20
|
+
const REMOVED_ROLE_LABELS = new Set(['sentinel']);
|
|
19
21
|
/* The built-in pseudo-agents ('Orchestrator' / 'Workflow') are not workers,
|
|
20
22
|
so the store's duplicate-name check can't protect them. Don't let a bare
|
|
21
23
|
`team spawn orchestrator` mint a second roster entry that reads like the
|
|
@@ -27,7 +29,10 @@ const MAX_NAME_LENGTH = 64;
|
|
|
27
29
|
const MAX_LABEL_IN_FALLBACK = MAX_NAME_LENGTH - 37;
|
|
28
30
|
export const resolveSpawnWorkerDefaults = (input) => {
|
|
29
31
|
const label = input.requestedRole?.trim() || 'coder';
|
|
30
|
-
|
|
32
|
+
if (REMOVED_ROLE_LABELS.has(label.toLowerCase())) {
|
|
33
|
+
throw new BadRequestError("Role 'sentinel' was removed; use coder, reviewer, tester, or custom.");
|
|
34
|
+
}
|
|
35
|
+
const role = isWorkerRole(label) ? label : 'custom';
|
|
31
36
|
const language = input.language ?? 'en';
|
|
32
37
|
const description = role === 'custom' && label !== 'custom'
|
|
33
38
|
? language === 'zh'
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Database } from 'better-sqlite3';
|
|
2
|
-
/** v33:
|
|
2
|
+
/** v33 retired: Sentinel was removed as a built-in role in v40. */
|
|
3
3
|
export declare const applySchemaVersion33: (db: Database) => void;
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/** v33: built-in Sentinel role template — a read-only patrol observer that reports via `team status`. */
|
|
1
|
+
/** v33 retired: Sentinel was removed as a built-in role in v40. */
|
|
3
2
|
export const applySchemaVersion33 = (db) => {
|
|
4
|
-
|
|
5
|
-
// foreign-built DB where role_templates was never created — same
|
|
6
|
-
// sqlite_master guard v12 uses for the same table.
|
|
7
|
-
const hasRoleTemplates = db
|
|
8
|
-
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'role_templates'")
|
|
9
|
-
.get();
|
|
10
|
-
if (!hasRoleTemplates)
|
|
11
|
-
return;
|
|
12
|
-
const now = Date.now();
|
|
13
|
-
db.prepare(`INSERT INTO role_templates (
|
|
14
|
-
id, name, role_type, description, default_command, default_args, default_env,
|
|
15
|
-
is_builtin, created_at, updated_at
|
|
16
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
|
17
|
-
ON CONFLICT(id) DO NOTHING`).run('sentinel', 'Sentinel', 'sentinel', SENTINEL_ROLE_DESCRIPTION, 'claude', '[]', '{}', now, now);
|
|
3
|
+
db.prepare('SELECT 1').get();
|
|
18
4
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CODER_ROLE_DESCRIPTION, ORCHESTRATOR_ROLE_DESCRIPTION, REVIEWER_ROLE_DESCRIPTION,
|
|
1
|
+
import { CODER_ROLE_DESCRIPTION, ORCHESTRATOR_ROLE_DESCRIPTION, REVIEWER_ROLE_DESCRIPTION, TESTER_ROLE_DESCRIPTION, } from './role-templates.js';
|
|
2
2
|
const BUILTIN_ROLE_DESCRIPTIONS = [
|
|
3
3
|
['orchestrator', ORCHESTRATOR_ROLE_DESCRIPTION],
|
|
4
4
|
['coder', CODER_ROLE_DESCRIPTION],
|
|
5
5
|
['reviewer', REVIEWER_ROLE_DESCRIPTION],
|
|
6
6
|
['tester', TESTER_ROLE_DESCRIPTION],
|
|
7
|
-
['sentinel', SENTINEL_ROLE_DESCRIPTION],
|
|
8
7
|
];
|
|
9
8
|
/** v35: refresh built-in role contracts to be English-first bilingual prompts. */
|
|
10
9
|
export const applySchemaVersion35 = (db) => {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** v40: remove the retired Sentinel role/template and any stale Sentinel workers. */
|
|
2
|
+
export const applySchemaVersion40 = (db) => {
|
|
3
|
+
const hasRoleTemplates = db
|
|
4
|
+
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'role_templates'")
|
|
5
|
+
.get();
|
|
6
|
+
const deleteSentinelTemplate = hasRoleTemplates
|
|
7
|
+
? db.prepare("DELETE FROM role_templates WHERE id = 'sentinel' OR role_type = 'sentinel'")
|
|
8
|
+
: null;
|
|
9
|
+
const hasWorkers = db
|
|
10
|
+
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'workers'")
|
|
11
|
+
.get();
|
|
12
|
+
if (!hasWorkers) {
|
|
13
|
+
deleteSentinelTemplate?.run();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const rows = db.prepare("SELECT workspace_id, id FROM workers WHERE role = 'sentinel'").all();
|
|
17
|
+
const deleteMessages = db.prepare(`DELETE FROM messages
|
|
18
|
+
WHERE workspace_id = ?
|
|
19
|
+
AND (worker_id = ? OR from_agent_id = ? OR to_agent_id = ?)`);
|
|
20
|
+
const deleteReportOutbox = db.prepare(`DELETE FROM report_outbox
|
|
21
|
+
WHERE workspace_id = ?
|
|
22
|
+
AND (
|
|
23
|
+
target_agent_id = ?
|
|
24
|
+
OR dispatch_id IN (
|
|
25
|
+
SELECT id FROM dispatches
|
|
26
|
+
WHERE workspace_id = ? AND (from_agent_id = ? OR to_agent_id = ?)
|
|
27
|
+
)
|
|
28
|
+
)`);
|
|
29
|
+
const deleteDispatches = db.prepare('DELETE FROM dispatches WHERE workspace_id = ? AND (from_agent_id = ? OR to_agent_id = ?)');
|
|
30
|
+
const deleteLaunch = db.prepare('DELETE FROM agent_launch_configs WHERE workspace_id = ? AND agent_id = ?');
|
|
31
|
+
const deleteSessions = db.prepare('DELETE FROM agent_sessions WHERE workspace_id = ? AND agent_id = ?');
|
|
32
|
+
const deleteRuns = db.prepare('DELETE FROM agent_runs WHERE agent_id = ?');
|
|
33
|
+
const deleteWorker = db.prepare('DELETE FROM workers WHERE workspace_id = ? AND id = ?');
|
|
34
|
+
db.transaction(() => {
|
|
35
|
+
deleteSentinelTemplate?.run();
|
|
36
|
+
for (const row of rows) {
|
|
37
|
+
deleteMessages.run(row.workspace_id, row.id, row.id, row.id);
|
|
38
|
+
deleteReportOutbox.run(row.workspace_id, row.id, row.workspace_id, row.id, row.id);
|
|
39
|
+
deleteDispatches.run(row.workspace_id, row.id, row.id);
|
|
40
|
+
deleteLaunch.run(row.workspace_id, row.id);
|
|
41
|
+
deleteSessions.run(row.workspace_id, row.id);
|
|
42
|
+
deleteRuns.run(row.id);
|
|
43
|
+
deleteWorker.run(row.workspace_id, row.id);
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
};
|
|
@@ -32,7 +32,8 @@ import { applySchemaVersion36 } from './sqlite-schema-v36.js';
|
|
|
32
32
|
import { applySchemaVersion37 } from './sqlite-schema-v37.js';
|
|
33
33
|
import { applySchemaVersion38 } from './sqlite-schema-v38.js';
|
|
34
34
|
import { applySchemaVersion39 } from './sqlite-schema-v39.js';
|
|
35
|
-
|
|
35
|
+
import { applySchemaVersion40 } from './sqlite-schema-v40.js';
|
|
36
|
+
export const CURRENT_SCHEMA_VERSION = 40;
|
|
36
37
|
// Idempotent column-add helper. SQLite doesn't have `ALTER TABLE … ADD COLUMN
|
|
37
38
|
// IF NOT EXISTS`, so PRAGMA-check first. Safe to call on every init; required
|
|
38
39
|
// for foreign-built DBs where the version-gated migration is skipped.
|
|
@@ -456,4 +457,8 @@ export const initializeRuntimeDatabase = (db) => {
|
|
|
456
457
|
if (!appliedVersions.has(39)) {
|
|
457
458
|
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(39, Date.now());
|
|
458
459
|
}
|
|
460
|
+
applySchemaVersion40(db);
|
|
461
|
+
if (!appliedVersions.has(40)) {
|
|
462
|
+
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(40, Date.now());
|
|
463
|
+
}
|
|
459
464
|
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { AgentSummary } from '../shared/types.js';
|
|
2
2
|
export type TeamCommand = 'send' | 'list' | 'next' | 'report' | 'recall' | 'memory_add' | 'memory_apply' | 'memory_dream_show' | 'memory_forget' | 'memory_search' | 'memory_show' | 'status' | 'cancel' | 'help' | 'spawn' | 'dismiss' | 'workflow' | 'goal_report';
|
|
3
3
|
export declare const commandAllowedForRole: (role: AgentSummary["role"], command: TeamCommand) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Dispatch-target gate: the sentinel is an observer, so handing it a dispatch
|
|
6
|
-
* would strand the task forever (it cannot `team report` to close it).
|
|
7
|
-
*/
|
|
8
|
-
export declare const assertWorkerDispatchable: (worker: {
|
|
9
|
-
name: string;
|
|
10
|
-
role: string;
|
|
11
|
-
}) => void;
|
|
12
4
|
interface AuthenticateInput {
|
|
13
5
|
fromAgentId: string | undefined;
|
|
14
6
|
getAgent: (workspaceId: string, agentId: string) => AgentSummary;
|
|
@@ -27,34 +27,13 @@ const WORKER_COMMANDS = new Set([
|
|
|
27
27
|
'memory_show',
|
|
28
28
|
]);
|
|
29
29
|
const WORKER_ROLES = new Set(['coder', 'reviewer', 'tester', 'custom']);
|
|
30
|
-
// Observe-only: a sentinel reports findings via `team status` and may read team
|
|
31
|
-
// memory, but it can NEVER `team report` (it is never assigned dispatch work —
|
|
32
|
-
// see assertWorkerDispatchable) and never dispatches or spawns.
|
|
33
|
-
const SENTINEL_COMMANDS = new Set([
|
|
34
|
-
'status',
|
|
35
|
-
'help',
|
|
36
|
-
'recall',
|
|
37
|
-
'memory_search',
|
|
38
|
-
'memory_show',
|
|
39
|
-
]);
|
|
40
30
|
export const commandAllowedForRole = (role, command) => {
|
|
41
31
|
if (role === 'orchestrator')
|
|
42
32
|
return ORCHESTRATOR_COMMANDS.has(command);
|
|
43
|
-
if (role === 'sentinel')
|
|
44
|
-
return SENTINEL_COMMANDS.has(command);
|
|
45
33
|
if (WORKER_ROLES.has(role))
|
|
46
34
|
return WORKER_COMMANDS.has(command);
|
|
47
35
|
return false;
|
|
48
36
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Dispatch-target gate: the sentinel is an observer, so handing it a dispatch
|
|
51
|
-
* would strand the task forever (it cannot `team report` to close it).
|
|
52
|
-
*/
|
|
53
|
-
export const assertWorkerDispatchable = (worker) => {
|
|
54
|
-
if (worker.role === 'sentinel') {
|
|
55
|
-
throw new ForbiddenError(`@${worker.name} is a sentinel (observe-only); it does not take dispatches`);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
37
|
export const authenticateCliAgent = ({ fromAgentId, getAgent, token, validateToken, workspaceId, }) => {
|
|
59
38
|
if (!fromAgentId) {
|
|
60
39
|
throw new UnauthorizedError('Missing agent identity');
|
|
@@ -3,7 +3,6 @@ import { FEATURE_FLAGS_ALL_OFF } from './feature-flags.js';
|
|
|
3
3
|
import { escapeHiveEnvelopeText } from './hive-envelope-escape.js';
|
|
4
4
|
import { ConflictError } from './http-errors.js';
|
|
5
5
|
import { createReportMessage, createSendMessage, createStatusMessage, createUserInputMessage, } from './runtime-message-builders.js';
|
|
6
|
-
import { assertWorkerDispatchable } from './team-authz.js';
|
|
7
6
|
import { getWorkflowAgentId } from './workspace-store-support.js';
|
|
8
7
|
/* Roster snapshot embedded in the 409 the orchestrator sees when it
|
|
9
8
|
dispatches to a missing name. Format prioritizes the orchestrator's
|
|
@@ -291,7 +290,6 @@ export const createTeamOperations = ({ agentRuntime, createDispatch, deleteDispa
|
|
|
291
290
|
const fromAgentId = input.fromAgentId;
|
|
292
291
|
const sender = fromAgentId ? workspaceStore.getAgent(workspaceId, fromAgentId) : undefined;
|
|
293
292
|
const worker = workspaceStore.getWorker(workspaceId, workerId);
|
|
294
|
-
assertWorkerDispatchable(worker);
|
|
295
293
|
const message = createSendMessage(workspaceId, workerId, text, input.fromAgentId);
|
|
296
294
|
const messageHandle = insertMessage(message);
|
|
297
295
|
let dispatch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WorkerRole } from '../shared/types.js';
|
|
2
2
|
import type { AgentLaunchConfigInput } from './agent-run-store.js';
|
|
3
3
|
import { type WorkflowCliPolicy } from './workflow-cli-policy.js';
|
|
4
4
|
import type { WorkflowDispatchAwaiter } from './workflow-dispatch-awaiter.js';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { cpus } from 'node:os';
|
|
3
|
+
import { isWorkerRole } from '../shared/types.js';
|
|
3
4
|
import { resolveWorkflowCli } from './workflow-cli-policy.js';
|
|
4
5
|
import { buildSchemaInstruction, extractJsonBlock } from './workflow-output-schema.js';
|
|
5
6
|
const DEFAULT_MAX_AGENTS_PER_RUN = 1000;
|
|
6
7
|
const DEFAULT_MAX_CONCURRENT_AGENTS = Math.min(16, Math.max(2, cpus().length - 2));
|
|
7
|
-
const BUILT_IN_WORKER_ROLES = new Set(['coder', 'reviewer', 'tester', 'custom']);
|
|
8
|
-
const isBuiltInWorkerRole = (value) => BUILT_IN_WORKER_ROLES.has(value);
|
|
9
8
|
const buildModelArgs = (_cli, model) => {
|
|
10
9
|
if (!model?.trim())
|
|
11
10
|
return [];
|
|
@@ -74,15 +73,12 @@ export const createWorkflowAgentCallExecutor = ({ assertRunActive, awaiter, canc
|
|
|
74
73
|
let role;
|
|
75
74
|
let command;
|
|
76
75
|
let templateArgs = [];
|
|
77
|
-
if (typeof requestedType === 'string' && !
|
|
76
|
+
if (typeof requestedType === 'string' && !isWorkerRole(requestedType)) {
|
|
78
77
|
const template = roleTemplateResolver.findByName(requestedType);
|
|
79
78
|
if (!template) {
|
|
80
79
|
throw new Error(`Workflow agentType '${requestedType}' is not a built-in role (coder/reviewer/tester/custom) and no matching role template exists in this workspace. ` +
|
|
81
80
|
`Use a built-in role or an existing dispatchable role template.`);
|
|
82
81
|
}
|
|
83
|
-
if (template.roleType === 'sentinel') {
|
|
84
|
-
throw new Error(`Workflow agentType '${requestedType}' resolves to a sentinel role, but sentinels are read-only observers and cannot receive workflow dispatches. Use coder, reviewer, tester, custom, or a dispatchable role template.`);
|
|
85
|
-
}
|
|
86
82
|
role = template.roleType === 'orchestrator' ? 'custom' : template.roleType;
|
|
87
83
|
command = resolveWorkflowCli({
|
|
88
84
|
...(opts.cli !== undefined ? { requestedCli: opts.cli } : {}),
|
|
@@ -326,43 +326,17 @@ const ZH_OTHERS = [
|
|
|
326
326
|
];
|
|
327
327
|
const EN_CUSTOM = [...EN_CODER, ...EN_REVIEWER, ...EN_TESTER, ...EN_OTHERS];
|
|
328
328
|
const ZH_CUSTOM = [...ZH_CODER, ...ZH_REVIEWER, ...ZH_TESTER, ...ZH_OTHERS];
|
|
329
|
-
/* Sentinel = watchers of the sky and of the record: astronomers, historians,
|
|
330
|
-
and one mythological hundred-eyed guard. Observation without intervention. */
|
|
331
|
-
const EN_SENTINEL = [
|
|
332
|
-
'argus',
|
|
333
|
-
'cassandra',
|
|
334
|
-
'copernicus',
|
|
335
|
-
'halley',
|
|
336
|
-
'herodotus',
|
|
337
|
-
'hypatia',
|
|
338
|
-
'kepler',
|
|
339
|
-
'ptolemy',
|
|
340
|
-
'thucydides',
|
|
341
|
-
'tycho-brahe',
|
|
342
|
-
];
|
|
343
|
-
const ZH_SENTINEL = [
|
|
344
|
-
'班固',
|
|
345
|
-
'郭守敬',
|
|
346
|
-
'沈括',
|
|
347
|
-
'司马光',
|
|
348
|
-
'司马迁',
|
|
349
|
-
'一行',
|
|
350
|
-
'张衡',
|
|
351
|
-
'祖冲之',
|
|
352
|
-
];
|
|
353
329
|
const POOLS = {
|
|
354
330
|
en: {
|
|
355
331
|
coder: EN_CODER,
|
|
356
332
|
reviewer: EN_REVIEWER,
|
|
357
333
|
tester: EN_TESTER,
|
|
358
|
-
sentinel: EN_SENTINEL,
|
|
359
334
|
custom: EN_CUSTOM,
|
|
360
335
|
},
|
|
361
336
|
zh: {
|
|
362
337
|
coder: ZH_CODER,
|
|
363
338
|
reviewer: ZH_REVIEWER,
|
|
364
339
|
tester: ZH_TESTER,
|
|
365
|
-
sentinel: ZH_SENTINEL,
|
|
366
340
|
custom: ZH_CUSTOM,
|
|
367
341
|
},
|
|
368
342
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const agentStatuses: readonly ["idle", "working", "stopped"];
|
|
2
2
|
export type AgentStatus = (typeof agentStatuses)[number];
|
|
3
|
-
export
|
|
3
|
+
export declare const workerRoles: readonly ["coder", "reviewer", "tester", "custom"];
|
|
4
|
+
export type WorkerRole = (typeof workerRoles)[number];
|
|
5
|
+
export declare const isWorkerRole: (value: unknown) => value is WorkerRole;
|
|
4
6
|
/** How a worker came to exist: spawned by a workflow run or by the orchestrator
|
|
5
7
|
* (via `team spawn`). Absent/null for user-added workers. `ephemeral`
|
|
6
8
|
* controls lifecycle; `spawnedBy` controls ownership/routing behavior. */
|
package/dist/src/shared/types.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-id-_KJdd.js","assets/index-CWxTzG6t.js","assets/index-DLjB6gMZ.css","assets/search-goAiPVWh.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as M,j as e,u as y,r as c,C as L,x as P,t as R,H as ee,K as te,ad as ae,ae as re,e as se,i as ne,R as oe,P as le,O as ie,k as de,m as ce,Z as me,z as xe,X as ue,T as pe,af as he,ag as fe}from"./index-CWxTzG6t.js";import{S as ge}from"./search-goAiPVWh.js";import{S as be}from"./square-terminal-BS_g8jLI.js";const ve=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ke=M("bookmark-plus",ve);const je=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ye=M("dices",je);const Ne=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],Ce=M("store",Ne),we=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],B=t=>`role.${t}`,z=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),We=({active:t,spec:a,onSelect:s})=>{const{t:n}=y();return e.jsxs("button",{type:"button",onClick:s,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ae,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(B(a.value))}),t?e.jsx(P,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({onRoleChange:t,workerRole:a})=>{const{t:s}=y();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(z,{children:s("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:we.map(n=>e.jsx(We,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},ze=({customTemplates:t,disabledReason:a,onDeleteTemplate:s,onSelect:n,selectedTemplateId:l})=>{const{t:o}=y(),[f,m]=c.useState(!1),[x,u]=c.useState(""),[b,j]=c.useState(null),N=c.useRef(null),C=c.useMemo(()=>t.find(r=>r.id===l)??null,[t,l]),v=c.useMemo(()=>{const r=x.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,x]);return c.useEffect(()=>{if(!f)return;const r=g=>{g.key==="Escape"&&m(!1)},p=g=>{const i=N.current;i&&!i.contains(g.target)&&m(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(z,{children:o("addWorker.template")}),e.jsxs("div",{ref:N,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>m(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:C?C.name:o("addWorker.templatePickPlaceholder")}),e.jsx(L,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(ge,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:x,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===l;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),m(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(P,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:g=>{g.preventDefault(),g.stopPropagation(),!a&&j(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(R,{size:14,"aria-hidden":!0})})]},r.id)})}),l!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),m(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(ee,{open:b!==null,onOpenChange:r=>{r||j(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;j(null),s(r)}})]})},Me=({canSaveAsTemplate:t,modified:a,onChange:s,onReset:n,onSaveAsTemplate:l,roleDescription:o,templateBusy:f,workerRole:m,writeDisabledReason:x})=>{const{t:u,language:b}=y(),[j,N]=c.useState(!1),[C,v]=c.useState(!1),[r,p]=c.useState("");c.useEffect(()=>{(m==="custom"||a)&&N(!0)},[a,m]),c.useEffect(()=>{t||(v(!1),p(""))},[t]);const g=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:j,onToggle:i=>N(i.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(L,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(B(m))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:g}),t&&!C?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!x,title:x??void 0,onClick:i=>{i.preventDefault(),i.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ke,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:i=>{i.preventDefault(),i.stopPropagation(),n()},children:[e.jsx(te,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:i=>s(i.currentTarget.value),placeholder:m==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&C?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:i=>p(i.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!r.trim()||!!x,title:x??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(x)return;const i=r.trim();if(i)try{await l(i),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},q=({active:t,command:a,displayName:s,logoPresetId:n,notFound:l=!1,testId:o,onSelect:f})=>{const{t:m}=y(),x=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(re,{commandPresetId:n,fallback:x,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:s}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,l?` · ${m("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(P,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Le=({active:t,preset:a,onSelect:s})=>e.jsx(q,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:s}),Pe=({commandPresetId:t,commandPresets:a,onPresetChange:s})=>{const{t:n}=y();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(z,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(l=>e.jsx(Le,{active:t===l.id,preset:l,onSelect:()=>s(l.id)},l.id)),e.jsx(q,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>s("")})]})]})},Ae=({onChange:t,value:a})=>{const{t:s,language:n}=y(),[l,o]=c.useState(!1),f=a.trim(),m=n==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:x=>o(x.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(L,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:s("addWorker.startupCommand")}),f?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",s("addWorker.startupOverrides")]}):null]}),l?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:m})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:x=>t(x.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:s("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Ee=c.lazy(()=>fe(()=>import("./MarketplaceDrawer-id-_KJdd.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),Te=({avatar:t,commandPresets:a,commandPresetId:s,creating:n=!1,customTemplates:l,onApplyMarketplaceImport:o,onAvatarChange:f,onClose:m,onDeleteTemplate:x,onNameChange:u,onPresetChange:b,onRandomName:j,onRoleDescriptionChange:N,onRoleDescriptionReset:C,onRoleChange:v,onSaveAsTemplate:r,onStartupCommandChange:p,onSubmit:g,onTemplateChange:i,roleDescription:S,roleDescriptionDefault:D,selectedTemplateId:A,startupCommand:E,templateBusy:H,workerName:O,workerRole:W,writeDisabledReason:k})=>{const{t:d}=y(),_=se(),w=ne(),[K,$]=c.useState(!1),[V,Q]=c.useState(!1),X=c.useMemo(()=>new Set(l.map(h=>h.name)),[l]),Z=h=>{o(h),_.show({kind:"success",message:d("marketplace.imported",{name:h.name})})},G=h=>{h||m()},J=S!==D,T=a.find(h=>h.id===s),F=E.trim(),U=()=>k||(O.trim()?!s&&!F?d("addWorker.pickCliOrStartup"):T?.available===!1&&!F?d("addWorker.unavailable",{name:T.displayName}):S.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),Y=h=>{const I=U();if(I){h.preventDefault(),_.show({kind:"warning",message:I});return}g(h)};return e.jsxs(oe,{open:!0,onOpenChange:G,children:[e.jsxs(le,{children:[e.jsx(ie,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(de,{"data-testid":"add-worker-content","data-mobile":w||void 0,className:`${w?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...w?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:Y,"aria-label":d("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ce,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(me,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),w?e.jsx(xe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":d("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(ue,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(z,{children:d("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!w,value:O,onChange:h=>u(h.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(pe,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:j,"data-testid":"random-worker-name",children:[e.jsx(ye,{size:13,"aria-hidden":!0}),e.jsx("span",{children:d("addWorker.random")})]})})})]})]}),e.jsx(Se,{workerRole:W,onRoleChange:v}),e.jsxs("button",{type:"button",onClick:()=>{Q(!0),$(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(Ce,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:d("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(ze,{customTemplates:l,onDeleteTemplate:x,onSelect:i,selectedTemplateId:A,...k?{disabledReason:k}:{}}):null,e.jsx(Me,{canSaveAsTemplate:W==="custom"&&!A&&S.trim().length>0,modified:J,onChange:N,onReset:C,onSaveAsTemplate:r,roleDescription:S,templateBusy:H,workerRole:W,...k?{writeDisabledReason:k}:{}}),e.jsx(he,{avatar:t,commandPresetId:s||void 0,disabled:!!k,onChange:f,workerRole:W,showStatus:!0}),e.jsx(Pe,{commandPresetId:s,commandPresets:a,onPresetChange:b}),e.jsx(Ae,{value:E,onChange:p})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:m,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${w?"flex-1":""}`,"data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!k,title:k??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${w?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:d(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),V?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Ee,{open:K,onClose:()=>$(!1),onImport:Z,importedNames:X})}):null]})};export{Te as AddWorkerDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as A,u as R,r as c,j as e,C as B,x as oe,Y as pe,R as G,P as Y,O as K,k as X,m as J,Z as se,_ as Ne,q as Ce,b as F,$ as _e,a0 as Pe,i as Se,z as Ee,X as ze,a1 as ue,a2 as Re,a3 as $e,a4 as Me}from"./index-CWxTzG6t.js";const De=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ie=A("arrow-up",De);const Le=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],Ae=A("folder-search",Le);const Oe=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Q=A("folder",Oe);const Fe=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],me=A("git-branch",Fe);const Be=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],We=A("hard-drive",Be);const Te=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],ee=A("sliders-vertical",Te),xe=t=>{const s=t.trim();if(s.length<2)return s;const n=s[0],a=s[s.length-1];return(n==='"'||n==="'")&&n===a?s.slice(1,-1):s},qe={claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",opencode:"/cli-icons/opencode.svg",gemini:"/cli-icons/gemini.png",hermes:"/cli-icons/hermes.png",qwen:"/cli-icons/qwen.png",pi:"/cli-icons/pi.svg",agy:"/cli-icons/agy.png",cursor:"/cli-icons/cursor.ico",grok:"/cli-icons/grok.ico"},le=({id:t,className:s})=>{const[n,a]=c.useState(!1),r=qe[t];return r&&!n?e.jsx("img",{src:r,alt:"",onError:()=>a(!0),className:`${s} object-contain rounded-xs ${t==="opencode"?"bg-[#ebebeb] p-[1px]":""}`}):e.jsx(pe,{size:14,className:s})},he=({error:t,onChange:s,presets:n,value:a})=>{const{t:r}=R(),[m,i]=c.useState(!1),l=c.useRef(null),f=n.find(x=>x.id===a),o=a==="",d=f?[f.command,...f.args].join(" ").trim():r(o?"workspace.preset.genericPreview":"workspace.preset.loading"),p=f?.displayName??(o?r("workspace.preset.generic"):"Claude Code (CC)"),k=n.length===0&&!o;return c.useEffect(()=>{if(!m)return;const x=h=>{l.current?.contains(h.target)||i(!1)},u=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",u)}},[m]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:r("workspace.preset.label")}),e.jsxs("div",{ref:l,className:"cli-select group relative",children:[e.jsx(le,{id:a,className:"cli-select__leading w-3.5 h-3.5"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":m,"aria-disabled":k||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:k,onClick:()=>i(x=>!x),children:p}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),m&&n.length>0?e.jsxs("div",{role:"listbox","aria-label":r("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[n.map(x=>{const u=x.id===a,h=x.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":u,"data-testid":`workspace-command-preset-option-${x.id}`,className:"cli-select__option",onClick:()=>{s(x.id),i(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:u?1:0}}),e.jsx(le,{id:x.id,className:"w-3.5 h-3.5 text-ter shrink-0"}),e.jsxs("span",{children:[x.displayName,h?r("workspace.preset.notFoundSuffix"):""]})]},x.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":o,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{s(""),i(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:o?1:0}}),e.jsx(pe,{size:14,className:"text-ter shrink-0"}),e.jsx("span",{children:r("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:d,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:d})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},H=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),Z=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),Ve=({probe:t,pasteFallbackDefault:s=!1,commandPresetError:n,commandPresetId:a,commandPresets:r,onCancel:m,onCommandPresetChange:i,onCreate:l,onOpenServerBrowse:f,onTryDemo:o})=>{const{t:d}=R(),p=t?.path??"",k=t?.suggested_name??H(p),[x,u]=c.useState(k),[h,j]=c.useState(""),[y,S]=c.useState(s),[C,E]=c.useState(!1),[z,$]=c.useState("");c.useEffect(()=>{u(t?.suggested_name??H(t?.path??""))},[t?.path,t?.suggested_name]);const b=xe(h),_=H(b),g=y&&b.length>0?b:t?.path??"",P=z.trim(),N=r.find(v=>v.id===a),T=r.length===0&&!n,I=!a&&P.length===0,O=N?.available===!1&&P.length===0,q=I?d("workspace.preset.genericRequiresStartup"):O?d("workspace.preset.notInstalled",{name:N.displayName}):null,te=r.length>0&&r.every(v=>v.available===!1),V=x.trim().length>0&&g.length>0&&!T&&!I&&!O,U=()=>{V&&l({commandPresetId:a||null,name:x.trim(),path:g,...P?{startupCommand:P}:{}})};return c.useEffect(()=>{y&&b.length>0&&u(_)},[y,b,_]),e.jsx(G,{open:!0,onOpenChange:v=>!v&&m(),children:e.jsxs(Y,{children:[e.jsx(K,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(X,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Q,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:d("workspace.confirm.title")}),e.jsx(se,{className:"text-xs text-ter",children:d("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{children:d("workspace.field.path")}),e.jsx("input",{type:"hidden",value:t?.path??"","data-testid":"confirm-workspace-path",readOnly:!0}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate font-mono text-sm text-pri",title:t?.path??"",children:t?.path||d("workspace.field.pathEmptyPlaceholder")})}),t?.is_git_repository?e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 25%, transparent)"},"data-testid":"confirm-workspace-git-badge",children:[e.jsx(me,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"truncate max-w-[90px]",children:t.current_branch??d("workspace.git.detached")})]}):null]}),t?.ok&&!t?.is_git_repository&&e.jsx("span",{className:"text-xs text-ter pl-1",children:d("workspace.git.none")})]}),e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(Z,{children:d("workspace.field.name")}),e.jsx("input",{value:x,onChange:v=>u(v.target.value),placeholder:H(t?.path??"")||d("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(he,{error:n??q,onChange:i,presets:r,value:a}),O&&N?e.jsx(Ne,{presetId:N.id,presetName:N.displayName}):null,e.jsx("p",{className:"rounded-lg border p-3 text-xs text-sec",style:{background:"color-mix(in oklab, var(--status-yellow) 5%, transparent)",borderColor:"color-mix(in oklab, var(--status-yellow) 25%, transparent)"},"data-testid":"yolo-mode-notice",children:d("workspace.yolo.notice")}),te&&o?e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{background:"color-mix(in oklab, var(--accent) 6%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 30%, transparent)"},"data-testid":"cli-none-available",children:[e.jsx("span",{className:"text-xs text-sec",children:d("workspace.preset.noneAvailable")}),e.jsxs("button",{type:"button",onClick:o,className:"icon-btn w-full justify-center inline-flex items-center gap-2","data-testid":"cli-try-demo",children:[e.jsx(Ce,{size:13,"aria-hidden":!0}),d("workspace.preset.tryDemo")]})]}):null,e.jsxs("div",{className:"mt-2 rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-startup-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.startup")]}),C?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),C?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(Z,{children:d("workspace.field.startup")}),e.jsx("input",{type:"text",value:z,onChange:v=>$(v.target.value),placeholder:d("workspace.field.startupPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-[11px] text-ter normal-case tracking-normal leading-relaxed",children:d("workspace.startup.hint")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-paste-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.pastePath")]}),y?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),y?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(Z,{children:d("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:h,onChange:v=>j(v.target.value),placeholder:d("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-paste-path"})]}):null]}),e.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full rounded-lg border border-dashed px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 hover:text-pri transition-all cursor-pointer",style:{borderColor:"var(--border)"},"data-testid":"confirm-workspace-browse-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.browse")]}),e.jsx(F,{size:14,"aria-hidden":!0})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:m,className:"icon-btn",children:d("common.cancel")}),e.jsx("button",{type:"button",onClick:U,disabled:!V,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:d("workspace.confirm.create")})]})]})})]})})},L="hive://windows-drives",Ue=({entries:t,error:s,loading:n,onNavigate:a,onSelect:r,selected:m})=>{const{t:i}=R();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:n?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:i("common.loading")}):s?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:s}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:i("workspace.browse.empty")}):e.jsx("ul",{children:t.map(l=>{const f=m===l.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${l.name}`,onClick:()=>r(l.path),onDoubleClick:()=>a(l.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:f?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:l.is_git_repository?e.jsx(me,{size:14}):e.jsx(Q,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:l.name}),l.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:i("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${l.name}`,onClick:()=>a(l.path),"aria-label":i("workspace.browse.openAria",{name:l.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},l.path)})})})},He=({probe:t,suggestedName:s,onSuggestedNameChange:n})=>{const{t:a}=R(),r=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:a("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:a("workspace.git.short",{branch:t.current_branch??a("workspace.git.detached")})}):r?e.jsx("span",{className:"text-ter text-xs",children:a("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:a("workspace.field.name")}),e.jsx("input",{type:"text",value:s,onChange:m=>n(m.target.value),disabled:!r,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50 max-md:text-base",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},fe=t=>{const s=t.lastIndexOf("\\"),n=t.lastIndexOf("/");return s>=0&&s>n?"\\":n>=0?"/":/^[A-Za-z]:/u.test(t)?"\\":"/"},Ze=(t,s)=>{if(t===L)return s;const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),r=a[a.length-1];return r?`~ (${r})`:t},W=t=>t.replace(/[\\/]+$/u,"")||t,ce=t=>/^[A-Za-z]:($|[\\/])/u.test(t),ie=t=>/^\\\\[^\\/]+[\\/][^\\/]+/u.test(t),be=(t,s)=>ce(t)&&ce(s)||ie(t)&&ie(s),Ge=t=>{const s=/^(?:\\\\|\/\/)(?<server>[^\\/]+)[\\/](?<share>[^\\/]+)[\\/]*(?<rest>.*)$/u.exec(t);if(!s?.groups)return null;const{server:n,share:a,rest:r}=s.groups,m=`\\\\${n}\\${a}\\`;return{label:`\\\\${n}\\${a}`,rest:r,root:m}},Ye=(t,s)=>{const n=W(t),a=W(s);return be(n,a)?n.toLowerCase()===a.toLowerCase():n===a},Ke=(t,s)=>{const n=W(t),a=W(s);if(a==="/"||a==="\\")return n.startsWith(a);const r=be(n,a),m=r?n.toLowerCase():n,i=r?a.toLowerCase():a;if(m===i)return!0;if(!m.startsWith(i))return!1;const l=m[i.length];return l==="/"||l==="\\"},Xe=(t,s,n="This PC")=>{if(!s||!t)return[];const a=[{label:Ze(s,n),path:s}];if(Ye(t,s))return a;if(s===L){const o=Ge(t);if(o){a.push({label:o.label,path:o.root});const h=o.rest.split(/[\\/]/).filter(Boolean);let j=o.root.replace(/[\\/]+$/,"");for(const y of h)j=`${j}\\${y}`,a.push({label:y,path:j});return a}const d=/^(?<drive>[A-Za-z]:)[\\/]*(?<rest>.*)$/u.exec(t),p=d?.groups?.drive;if(!p)return a;const k=`${p}\\`;a.push({label:p,path:k});const x=(d.groups?.rest??"").split(/[\\/]/).filter(Boolean);let u=k.replace(/[\\/]+$/,"");for(const h of x)u=`${u}\\${h}`,a.push({label:h,path:u});return a}const r=W(s),m=Ke(t,r)?t.slice(r.length).replace(/^[\\/]+/,""):"";if(!m)return a;const i=fe(r),l=m.split(/[\\/]/).filter(Boolean);let f=r;for(const o of l)f=`${f}${i}${o}`,a.push({label:o,path:f});return a},de={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Je=t=>{const[s,n]=c.useState(de),[a,r]=c.useState(!1),[m,i]=c.useState(null),[l,f]=c.useState(null),o=c.useRef(0),d=c.useRef(0),p=c.useCallback(()=>{d.current++,i(null),f(null)},[]),k=c.useCallback(async u=>{const h=++o.current;r(!0);try{const j=await _e(u);if(o.current!==h)return;n(j),j.ok?i(j.current_path):p()}catch{}finally{o.current===h&&r(!1)}},[p]);c.useEffect(()=>{if(!t){o.current++,n(de),p();return}k("")},[p,t,k]),c.useEffect(()=>{if(!m){f(null);return}const u=++d.current;Pe(m).then(h=>{d.current===u&&f(h)}).catch(h=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",h)})},[m]);const x=c.useCallback(u=>{i(u)},[]);return{browse:s,loading:a,navigate:k,probe:l,selectEntry:x,selected:m}},Qe=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),ge=({commandPresetError:t,commandPresetId:s,commandPresets:n,onClose:a,onCommandPresetChange:r,onCreate:m,open:i,initialAdvanced:l=!1,manualHint:f})=>{const{t:o}=R(),d=Se(),{browse:p,loading:k,navigate:x,probe:u,selectEntry:h,selected:j}=Je(i),[y,S]=c.useState(""),[C,E]=c.useState(l),[z,$]=c.useState(""),[b,_]=c.useState(!1),[g,P]=c.useState(""),N=xe(z),T=Qe(N);if(c.useEffect(()=>{i||(S(""),E(l),$(""),_(!1),P(""))},[i,l]),c.useEffect(()=>{u?.suggested_name&&S(u.suggested_name)},[u?.suggested_name]),c.useEffect(()=>{C&&N.length>0&&S(T)},[C,T,N]),!i)return null;const I=o("workspace.browse.drivesRoot"),O=p.root_path===L?I:p.root_path,q=Xe(p.current_path,p.root_path,I),te=p.root_path===L&&p.current_path!==L,V=fe(p.current_path||p.root_path),U=n.find(w=>w.id===s),v=g.trim(),ke=n.length===0&&!t,ae=!s&&v.length===0,re=U?.available===!1&&v.length===0,ve=ae?o("workspace.preset.genericRequiresStartup"):re?o("workspace.preset.notInstalled",{name:U.displayName}):null,we=y.trim().length>0&&(u?.is_dir===!0||C&&N.length>0)&&!ke&&!ae&&!re,je=()=>{const w=C&&N.length>0?N:u?.path??"";w&&m({commandPresetId:s||null,name:y.trim(),path:w,...v?{startupCommand:v}:{}})};return e.jsx(G,{open:!0,onOpenChange:w=>!w&&a(),children:e.jsxs(Y,{children:[e.jsx(K,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center max-md:items-end max-md:p-0 p-4",children:e.jsxs(X,{"data-testid":"add-workspace-dialog","data-mobile":d||void 0,className:`${d?"dialog-slide-up":"dialog-scale-pop"} elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border max-md:w-full max-md:max-w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{height:d?"85dvh":"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Q,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:o("workspace.browse.title")}),e.jsx(se,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:p.root_path?o("workspace.browse.root",{path:O}):o("workspace.browse.rootLoading")})]}),e.jsx(Ee,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":o("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ze,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":o("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>p.parent_path?x(p.parent_path):null,disabled:!p.parent_path,"aria-label":o("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(Ie,{size:12,"aria-hidden":!0})," ",o("workspace.browse.up")]}),te?e.jsxs("button",{type:"button",onClick:()=>x(L),"aria-label":o("workspace.browse.drivesAria"),"data-testid":"fs-browse-drives",className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri",children:[e.jsx(We,{size:12,"aria-hidden":!0})," ",I]}):null,e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),q.map((w,ne)=>{const ye=ne===q.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[ne>0?e.jsx("span",{className:"text-ter",children:V}):null,ye?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:w.label}):e.jsx("button",{type:"button",onClick:()=>x(w.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:w.label})]},w.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 max-md:flex-col",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col max-md:min-h-[40%]",children:e.jsx(Ue,{entries:p.entries,error:p.ok?null:p.error,loading:k,onNavigate:x,onSelect:h,selected:j})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4 max-md:w-full max-md:border-l-0 max-md:border-t max-md:max-h-[45%] max-md:overflow-y-auto",style:{borderColor:"var(--border)"},children:[e.jsx(He,{onSuggestedNameChange:S,probe:u,suggestedName:y}),e.jsx(he,{error:t??ve,onChange:r,presets:n,value:s}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>_(w=>!w),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),o("workspace.advanced.startup")]}),b?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),b?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:o("workspace.field.startup")}),e.jsx("input",{type:"text",value:g,onChange:w=>P(w.target.value),placeholder:o("workspace.field.startupPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"text","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:o("workspace.startup.hintShort")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>E(w=>!w),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),o("workspace.advanced.pastePath")]}),C?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),C?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:o("workspace.field.absolutePath")}),f?e.jsx("span",{"data-testid":"fs-manual-hint",className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:f}):null,e.jsx("input",{type:"text",value:z,onChange:w=>$(w.target.value),placeholder:o("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"url","data-testid":"fs-manual-path"})]}):null]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:o("common.cancel")}),e.jsx("button",{type:"button",onClick:je,disabled:!we,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:o("workspace.confirm.create")})]})]})})]})})},M="claude",et=t=>t.some(s=>s.id===M&&s.available)?M:t.find(s=>s.available)?.id??t[0]?.id??M,tt=(t=typeof navigator>"u"?void 0:navigator)=>{if(!t)return!1;const s=[t.userAgentData?.platform,t.platform,t.userAgent].filter(n=>typeof n=="string"&&n.length>0).join(" ");return/\bWindows?\b|\bWin(?:32|64|CE)\b|Windows NT/i.test(s)},st=({trigger:t,onClose:s,onCreate:n,onTryDemo:a})=>{const{t:r}=R(),m=c.useRef(r);c.useEffect(()=>{m.current=r},[r]);const[i,l]=c.useState({kind:"idle"}),[f,o]=c.useState([]),[d,p]=c.useState(M),[k,x]=c.useState(null),u=c.useRef({error:null,id:M,presets:[]}),h=c.useRef(s);c.useEffect(()=>{h.current=s},[s]),c.useEffect(()=>{if(t===0)return;let b=!1;x(null);const _=ue().then(g=>{if(b)return;const P=g.some(N=>N.id===u.current.id&&N.available)?u.current.id:et(g);u.current={error:null,id:P,presets:g},o(g),p(P)}).catch(()=>{if(b)return;const g=m.current("workspace.preset.loadFailed");u.current={error:g,id:M,presets:[]},o([]),p(M),x(g)});return tt()?(l({kind:"browse"}),()=>{b=!0}):(l({kind:"picking"}),Re().then(async g=>{if(await _,!b){if(g.canceled){if(g.error){l({kind:"error",message:g.error});return}l({kind:"idle"}),h.current();return}if(!g.supported){l({kind:"confirm",probe:null,pasteDefault:!0});return}if(!g.probe?.ok||!g.probe.is_dir){l({kind:"error",message:g.error??m.current("workspace.error.outsideSandbox")});return}l({kind:"confirm",probe:g.probe,pasteDefault:!1})}}).catch(g=>{if(b)return;const P=g instanceof Error?g.message:m.current("workspace.error.pickerFailed");l({kind:"error",message:P})}),()=>{b=!0})},[t]);const j=()=>{l({kind:"idle"}),s()},y=a?()=>{l({kind:"idle"}),s(),a()}:void 0,S=b=>{Promise.resolve(n(b)).then(()=>l({kind:"idle"})).catch(_=>{const g=_ instanceof Error?_.message:r("workspace.error.createFailed");l({kind:"error",title:r("workspace.error.createTitle"),message:g})})},C=b=>{u.current={...u.current,id:b},p(b)},E=f.length>0||k?f:u.current.presets,z=d===""?"":E.length>0&&!E.some(b=>b.id===d&&b.available)?u.current.id:d,$=k??u.current.error;if(i.kind==="idle")return null;if(i.kind==="picking"){const b=()=>l({kind:"idle"});return e.jsx(G,{open:!0,onOpenChange:_=>!_&&b(),children:e.jsxs(Y,{children:[e.jsx(K,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(X,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(J,{className:"sr-only",children:r("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(Ae,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:r("workspace.picking.message")})]})]})]})})}return i.kind==="error"?e.jsx(G,{open:!0,onOpenChange:b=>!b&&j(),children:e.jsxs(Y,{children:[e.jsx(K,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(X,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},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",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx($e,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:i.title??r("workspace.error.pickerFailed")}),e.jsx(se,{className:"mt-1.5 break-words text-sm text-ter",children:i.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:j,className:"icon-btn",children:r("common.close")}),e.jsx("button",{type:"button",onClick:()=>l({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:r("workspace.error.pastePathInstead")})]})]})})]})}):i.kind==="browse"?e.jsx(ge,{commandPresetError:$,commandPresetId:z,commandPresets:E,onClose:j,onCommandPresetChange:C,onCreate:S,open:!0}):e.jsx(Ve,{commandPresetError:$,commandPresetId:z,commandPresets:E,pasteFallbackDefault:i.pasteDefault,probe:i.probe,onCancel:j,onCommandPresetChange:C,onCreate:S,onOpenServerBrowse:()=>l({kind:"browse"}),...y?{onTryDemo:y}:{}})},D="claude",at=t=>t.some(s=>s.id===D&&s.available)?D:t.find(s=>s.available)?.id??t[0]?.id??D,rt=t=>{const{t:s}=R(),n=c.useRef(s);c.useEffect(()=>{n.current=s},[s]);const[a,r]=c.useState([]),[m,i]=c.useState(D),[l,f]=c.useState(null),o=c.useRef(D);return c.useEffect(()=>{if(!t)return;let p=!1;return f(null),ue().then(k=>{if(p)return;const u=k.some(h=>h.id===o.current&&h.available)?o.current:at(k);o.current=u,r(k),i(u)}).catch(()=>{p||(o.current=D,r([]),i(D),f(n.current("workspace.preset.loadFailed")))}),()=>{p=!0}},[t]),{commandPresets:a,commandPresetId:m,commandPresetError:l,onCommandPresetChange:p=>{o.current=p,i(p)}}},nt=({trigger:t,onClose:s,onCreate:n})=>{const{t:a}=R(),[r,m]=c.useState(!1),i=c.useRef(0);c.useEffect(()=>{t>0&&t!==i.current&&m(!0)},[t]);const l=rt(r),f=()=>{i.current=t,m(!1),s()},o=d=>{Promise.resolve(n(d)).then(()=>{i.current=t,m(!1)})};return r?e.jsx(ge,{open:!0,initialAdvanced:!0,manualHint:a("workspace.add.manualHint"),commandPresetError:l.commandPresetError,commandPresetId:l.commandPresetId,commandPresets:l.commandPresets,onClose:f,onCommandPresetChange:l.onCommandPresetChange,onCreate:o}):null},lt=({trigger:t,onClose:s,onCreate:n,onTryDemo:a})=>{const{mode:r}=Me();return r==="mobile"?e.jsx(nt,{trigger:t,onClose:s,onCreate:n}):e.jsx(st,{trigger:t,onClose:s,onCreate:n,...a?{onTryDemo:a}:{}})};export{lt as AddWorkspaceFlow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as f,r as h,j as e,R as j,P as b,O as N,k as v,
|
|
1
|
+
import{u as f,r as h,j as e,R as j,P as b,O as N,k as v,Z as g,m as c}from"./index-CWxTzG6t.js";const y=({open:o,onClose:r,onAddWorkspace:d,onTryDemo:x})=>{const{t:s}=f(),[l,n]=h.useState(0),m=t=>{t||(n(0),r())},i=(t=!0)=>{n(0),r(t)},a=l===2;return e.jsx(j,{open:o,onOpenChange:m,children:e.jsxs(b,{children:[e.jsx(N,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(v,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:l+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[l===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx("img",{alt:"",className:"h-10 w-10 object-contain","data-testid":"first-run-logo",draggable:!1,src:"/logo.png"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),l>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),l===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:u,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:u}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),l===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{d(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{x(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:l+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&!a&&e.jsx("button",{type:"button",onClick:()=>n(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>n(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{y as FirstRunWizard};
|