@tt-a1i/hive 2.1.10 → 2.1.12
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 +31 -0
- package/README.md +13 -11
- package/README.zh.md +9 -8
- package/dist/src/cli/hive-defaults.d.ts +1 -0
- package/dist/src/cli/hive-defaults.js +1 -0
- package/dist/src/cli/hive-mcp.d.ts +62 -0
- package/dist/src/cli/hive-mcp.js +254 -0
- package/dist/src/cli/hive.d.ts +2 -0
- package/dist/src/cli/hive.js +12 -2
- package/dist/src/cli/team.d.ts +8 -0
- package/dist/src/cli/team.js +100 -0
- package/dist/src/server/agent-runtime-contract.d.ts +1 -0
- package/dist/src/server/agent-runtime.js +4 -0
- package/dist/src/server/agent-startup-instructions.js +1 -1
- package/dist/src/server/command-preset-defaults.d.ts +1 -1
- package/dist/src/server/command-preset-defaults.js +10 -0
- package/dist/src/server/diagnostics-support-bundle.d.ts +1 -1
- package/dist/src/server/external-goal-auth.d.ts +1 -0
- package/dist/src/server/external-goal-auth.js +1 -0
- package/dist/src/server/external-goal-bridge.d.ts +103 -0
- package/dist/src/server/external-goal-bridge.js +299 -0
- package/dist/src/server/external-goal-store.d.ts +59 -0
- package/dist/src/server/external-goal-store.js +165 -0
- package/dist/src/server/hive-team-guidance.js +1 -0
- package/dist/src/server/post-start-input-writer.js +28 -7
- package/dist/src/server/route-types.d.ts +30 -0
- package/dist/src/server/routes-external-goals.d.ts +2 -0
- package/dist/src/server/routes-external-goals.js +184 -0
- package/dist/src/server/routes-runtime.js +6 -1
- package/dist/src/server/routes-team-goals.d.ts +2 -0
- package/dist/src/server/routes-team-goals.js +60 -0
- package/dist/src/server/routes.js +4 -0
- package/dist/src/server/runtime-store-contract.d.ts +11 -0
- package/dist/src/server/runtime-store-external-goals.d.ts +47 -0
- package/dist/src/server/runtime-store-external-goals.js +24 -0
- package/dist/src/server/runtime-store-helpers.d.ts +3 -0
- package/dist/src/server/runtime-store-helpers.js +11 -1
- package/dist/src/server/runtime-store.js +6 -0
- package/dist/src/server/sqlite-schema-v37.d.ts +2 -0
- package/dist/src/server/sqlite-schema-v37.js +38 -0
- package/dist/src/server/sqlite-schema-v38.d.ts +2 -0
- package/dist/src/server/sqlite-schema-v38.js +26 -0
- package/dist/src/server/sqlite-schema.d.ts +1 -1
- package/dist/src/server/sqlite-schema.js +46 -1
- package/dist/src/server/team-authz.d.ts +1 -1
- package/dist/src/server/team-authz.js +1 -0
- package/dist/src/server/ui-auth.d.ts +2 -0
- package/dist/src/server/ui-auth.js +7 -0
- package/dist/src/server/workflow-cli-policy.d.ts +1 -1
- package/dist/src/server/workflow-cli-policy.js +1 -0
- package/package.json +3 -3
- package/web/dist/assets/{AddWorkerDialog-Dc0slXtx.js → AddWorkerDialog-BA0p5Pcr.js} +2 -2
- package/web/dist/assets/{AddWorkspaceFlow-AyzSdx5w.js → AddWorkspaceFlow-YO-HxdrH.js} +1 -1
- package/web/dist/assets/{FirstRunWizard-DGB5zWhl.js → FirstRunWizard-C5iyX5QF.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-DAZ-crqq.js → MarketplaceDrawer-BIyJIDK4.js} +1 -1
- package/web/dist/assets/{TaskGraphDrawer-DYk-0uKD.js → TaskGraphDrawer-C0eOFQ8c.js} +1 -1
- package/web/dist/assets/{WhatsNewDialog-B5tu3MV2.js → WhatsNewDialog-Ci9pUKEP.js} +1 -1
- package/web/dist/assets/{WorkerModal-C73K7SUg.js → WorkerModal-DXHUZSN-.js} +1 -1
- package/web/dist/assets/WorkflowsDrawer-C5cS2jKY.js +1 -0
- package/web/dist/assets/{WorkspaceMemoryDrawer-CCz3HB4F.js → WorkspaceMemoryDrawer-BsAoM-lK.js} +1 -1
- package/web/dist/assets/{WorkspaceTaskDrawer-C7JzoRp8.js → WorkspaceTaskDrawer-rLaXBrNl.js} +1 -1
- package/web/dist/assets/index-CTJnf-r_.js +84 -0
- package/web/dist/assets/{search-Bx1xfpzr.js → search-CbyBNPSq.js} +1 -1
- package/web/dist/assets/{square-terminal-Dfr9QC1I.js → square-terminal-eIii6bbw.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/manifest.webmanifest +1 -1
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/WorkflowsDrawer-mrSAPqAh.js +0 -1
- package/web/dist/assets/index-CVQc8PLJ.js +0 -84
|
@@ -4,6 +4,7 @@ import type { AgentManager } from './agent-manager.js';
|
|
|
4
4
|
import type { AgentLaunchConfigInput, PersistedAgentRun } from './agent-run-store.js';
|
|
5
5
|
import type { LiveAgentRun } from './agent-runtime-types.js';
|
|
6
6
|
import type { DispatchRecord, ListDispatchesOptions } from './dispatch-ledger-store.js';
|
|
7
|
+
import type { ExternalGoalBridge, ExternalGoalCancelInput, ExternalGoalContinueInput, ExternalGoalReportInput, ExternalGoalStartInput, ExternalGoalWaitInput } from './external-goal-bridge.js';
|
|
7
8
|
import type { RecoveryMessage } from './message-log-store.js';
|
|
8
9
|
import type { PtyOutputBus } from './pty-output-bus.js';
|
|
9
10
|
import type { RemoteAuditStore } from './remote-audit-store.js';
|
|
@@ -50,6 +51,13 @@ export interface RuntimeStore {
|
|
|
50
51
|
listDispatches: (workspaceId: string, options?: ListDispatchesOptions) => DispatchRecord[];
|
|
51
52
|
listOpenDispatches: (workspaceId: string) => DispatchRecord[];
|
|
52
53
|
listRecentDispatches: (workspaceId: string, limit?: number) => DispatchRecord[];
|
|
54
|
+
listExternalGoalWorkspaces: ExternalGoalBridge['listWorkspaces'];
|
|
55
|
+
inspectExternalGoalWorkspace: ExternalGoalBridge['inspectWorkspace'];
|
|
56
|
+
startExternalGoal: (input: ExternalGoalStartInput) => ReturnType<ExternalGoalBridge['startGoal']>;
|
|
57
|
+
continueExternalGoal: (input: ExternalGoalContinueInput) => ReturnType<ExternalGoalBridge['continueGoal']>;
|
|
58
|
+
reportExternalGoal: (input: ExternalGoalReportInput) => ReturnType<ExternalGoalBridge['reportGoal']>;
|
|
59
|
+
waitExternalGoal: (input: ExternalGoalWaitInput) => ReturnType<ExternalGoalBridge['waitGoal']>;
|
|
60
|
+
cancelExternalGoal: (input: ExternalGoalCancelInput) => ReturnType<ExternalGoalBridge['cancelGoal']>;
|
|
53
61
|
listWorkers: (workspaceId: string) => TeamListItem[];
|
|
54
62
|
getLastPtyLineForAgent: (workspaceId: string, agentId: string) => string | null;
|
|
55
63
|
getWorkspaceSnapshot: (workspaceId: string) => WorkspaceRecord;
|
|
@@ -70,6 +78,7 @@ export interface RuntimeStore {
|
|
|
70
78
|
workspace_id: string;
|
|
71
79
|
}>>;
|
|
72
80
|
startWorkspaceWatch: (workspaceId: string) => Promise<void>;
|
|
81
|
+
findLiveRun: (runId: string) => LiveAgentRun | undefined;
|
|
73
82
|
getLiveRun: (runId: string) => LiveAgentRun;
|
|
74
83
|
waitForRunExit: (runId: string, timeoutMs: number) => Promise<boolean>;
|
|
75
84
|
getActiveRunByAgentId: (workspaceId: string, agentId: string) => LiveAgentRun | undefined;
|
|
@@ -102,9 +111,11 @@ export interface RuntimeStore {
|
|
|
102
111
|
settings: SettingsStore;
|
|
103
112
|
writeRunInput: (runId: string, input: Buffer | string) => void;
|
|
104
113
|
getUiToken: () => string;
|
|
114
|
+
getSupervisorToken: () => string;
|
|
105
115
|
stopAgentRun: (runId: string) => void;
|
|
106
116
|
validateAgentToken: (agentId: string, token: string | undefined) => boolean;
|
|
107
117
|
validateUiToken: (token: string | undefined) => boolean;
|
|
118
|
+
validateSupervisorToken: (token: string | undefined) => boolean;
|
|
108
119
|
authorizeRemoteTunnelRequest: (request: IncomingMessage) => boolean;
|
|
109
120
|
getRemoteTunnelSecret: () => string;
|
|
110
121
|
getRemoteAuditStore: () => RemoteAuditStore;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { RuntimeStoreServices } from './runtime-store-helpers.js';
|
|
2
|
+
export declare const createRuntimeStoreExternalGoalMethods: (services: RuntimeStoreServices) => {
|
|
3
|
+
cancelExternalGoal: (input: import("./external-goal-bridge.js").ExternalGoalCancelInput) => Promise<{
|
|
4
|
+
cursor: number;
|
|
5
|
+
event: import("./external-goal-store.js").ExternalGoalEvent;
|
|
6
|
+
session: import("./external-goal-store.js").ExternalGoalSession;
|
|
7
|
+
status: "open" | "cancelled" | "in_progress" | "blocked" | "done" | "failed";
|
|
8
|
+
}>;
|
|
9
|
+
continueExternalGoal: (input: import("./external-goal-bridge.js").ExternalGoalContinueInput) => Promise<{
|
|
10
|
+
cursor: number;
|
|
11
|
+
event: import("./external-goal-store.js").ExternalGoalEvent;
|
|
12
|
+
session: import("./external-goal-store.js").ExternalGoalSession;
|
|
13
|
+
status: "open" | "cancelled" | "in_progress" | "blocked" | "done" | "failed";
|
|
14
|
+
}>;
|
|
15
|
+
inspectExternalGoalWorkspace: (input: {
|
|
16
|
+
workspaceId: string;
|
|
17
|
+
}) => {
|
|
18
|
+
workspace: import("../shared/types.js").WorkspaceSummary;
|
|
19
|
+
orchestrator: {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
status: "idle" | "working" | "stopped";
|
|
23
|
+
active_run: boolean;
|
|
24
|
+
};
|
|
25
|
+
members: import("../shared/types.js").TeamListItemPayload[];
|
|
26
|
+
};
|
|
27
|
+
listExternalGoalWorkspaces: () => import("../shared/types.js").WorkspaceSummary[];
|
|
28
|
+
reportExternalGoal: (input: import("./external-goal-bridge.js").ExternalGoalReportInput) => {
|
|
29
|
+
cursor: number;
|
|
30
|
+
event: import("./external-goal-store.js").ExternalGoalEvent;
|
|
31
|
+
session: import("./external-goal-store.js").ExternalGoalSession;
|
|
32
|
+
status: "open" | "cancelled" | "in_progress" | "blocked" | "done" | "failed";
|
|
33
|
+
};
|
|
34
|
+
startExternalGoal: (input: import("./external-goal-bridge.js").ExternalGoalStartInput) => Promise<{
|
|
35
|
+
cursor: number;
|
|
36
|
+
events: import("./external-goal-store.js").ExternalGoalEvent[];
|
|
37
|
+
goalId: string;
|
|
38
|
+
session: import("./external-goal-store.js").ExternalGoalSession;
|
|
39
|
+
status: "open" | "cancelled" | "in_progress" | "blocked" | "done" | "failed";
|
|
40
|
+
}>;
|
|
41
|
+
waitExternalGoal: (input: import("./external-goal-bridge.js").ExternalGoalWaitInput) => Promise<{
|
|
42
|
+
cursor: number;
|
|
43
|
+
events: import("./external-goal-store.js").ExternalGoalEvent[];
|
|
44
|
+
goalId: string;
|
|
45
|
+
status: "open" | "cancelled" | "in_progress" | "blocked" | "done" | "failed";
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createExternalGoalBridge } from './external-goal-bridge.js';
|
|
2
|
+
import { getOrchestratorId } from './workspace-store-support.js';
|
|
3
|
+
export const createRuntimeStoreExternalGoalMethods = (services) => {
|
|
4
|
+
const bridge = createExternalGoalBridge({
|
|
5
|
+
deliverToOrchestrator: (workspaceId, text) => services.agentRuntime.deliverSystemMessageToAgent(workspaceId, getOrchestratorId(workspaceId), text, {
|
|
6
|
+
requireActiveRun: true,
|
|
7
|
+
}),
|
|
8
|
+
getActiveRunByAgentId: (workspaceId, agentId) => services.agentRuntime.getActiveRunByAgentId(workspaceId, agentId),
|
|
9
|
+
getAgent: (workspaceId, agentId) => services.workspaceStore.getAgent(workspaceId, agentId),
|
|
10
|
+
getWorkspaceSnapshot: (workspaceId) => services.workspaceStore.getWorkspaceSnapshot(workspaceId),
|
|
11
|
+
goalStore: services.externalGoalStore,
|
|
12
|
+
listWorkers: (workspaceId) => services.workspaceStore.listWorkers(workspaceId),
|
|
13
|
+
listWorkspaces: () => services.workspaceStore.listWorkspaces(),
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
cancelExternalGoal: bridge.cancelGoal,
|
|
17
|
+
continueExternalGoal: bridge.continueGoal,
|
|
18
|
+
inspectExternalGoalWorkspace: bridge.inspectWorkspace,
|
|
19
|
+
listExternalGoalWorkspaces: bridge.listWorkspaces,
|
|
20
|
+
reportExternalGoal: bridge.reportGoal,
|
|
21
|
+
startExternalGoal: bridge.startGoal,
|
|
22
|
+
waitExternalGoal: bridge.waitGoal,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -3,6 +3,7 @@ import { type AgentLaunchConfigInput, createAgentRunStore } from './agent-run-st
|
|
|
3
3
|
import { createAgentRuntime } from './agent-runtime.js';
|
|
4
4
|
import type { LiveAgentRun } from './agent-runtime-types.js';
|
|
5
5
|
import { createDispatchLedgerStore } from './dispatch-ledger-store.js';
|
|
6
|
+
import { createExternalGoalStore } from './external-goal-store.js';
|
|
6
7
|
import { createMessageLogStore } from './message-log-store.js';
|
|
7
8
|
import { createProtocolEventStats } from './protocol-event-stats.js';
|
|
8
9
|
import type { PtyOutputBus } from './pty-output-bus.js';
|
|
@@ -40,6 +41,7 @@ export interface RuntimeStoreServices {
|
|
|
40
41
|
agentRuntime: ReturnType<typeof createAgentRuntime>;
|
|
41
42
|
db: ReturnType<typeof openRuntimeDatabase>;
|
|
42
43
|
dispatchLedgerStore: ReturnType<typeof createDispatchLedgerStore>;
|
|
44
|
+
externalGoalStore: ReturnType<typeof createExternalGoalStore>;
|
|
43
45
|
isRuntimeClosing: () => boolean;
|
|
44
46
|
markRuntimeClosing: () => void;
|
|
45
47
|
messageLogStore: ReturnType<typeof createMessageLogStore>;
|
|
@@ -91,6 +93,7 @@ export declare const createRuntimeStoreLifecycle: ({ agentManager, services, }:
|
|
|
91
93
|
peekAgentLaunchConfig: (workspaceId: string, agentId: string) => AgentLaunchConfigInput | undefined;
|
|
92
94
|
deleteWorkspaceShell: (workspaceId: string) => void;
|
|
93
95
|
closeWorkspaceShell: (workspaceId: string, runId: string) => boolean;
|
|
96
|
+
findLiveRun: (runId: string) => LiveAgentRun | undefined;
|
|
94
97
|
getLiveRun: (runId: string) => LiveAgentRun;
|
|
95
98
|
waitForRunExit: (runId: string, timeoutMs: number) => Promise<boolean>;
|
|
96
99
|
getPtyOutputBus: () => PtyOutputBus;
|
|
@@ -5,6 +5,7 @@ import { createAgentRunStore } from './agent-run-store.js';
|
|
|
5
5
|
import { createAgentRuntime } from './agent-runtime.js';
|
|
6
6
|
import { createAgentSessionStore } from './agent-session-store.js';
|
|
7
7
|
import { createDispatchLedgerStore } from './dispatch-ledger-store.js';
|
|
8
|
+
import { createExternalGoalStore } from './external-goal-store.js';
|
|
8
9
|
import { readFeatureFlags } from './feature-flags.js';
|
|
9
10
|
import { createMessageLogStore } from './message-log-store.js';
|
|
10
11
|
import { seedOrchestratorLaunchConfig } from './orchestrator-launch.js';
|
|
@@ -80,6 +81,7 @@ export const createRuntimeStoreServices = (options = {}) => {
|
|
|
80
81
|
const uploadStorage = createWorkspaceUploadStorage(options.dataDir);
|
|
81
82
|
const messageLogStore = createMessageLogStore(db);
|
|
82
83
|
const dispatchLedgerStore = createDispatchLedgerStore(db);
|
|
84
|
+
const externalGoalStore = createExternalGoalStore(db);
|
|
83
85
|
const teamMemoryStore = createTeamMemoryStore(db);
|
|
84
86
|
const teamMemoryDreamStore = createTeamMemoryDreamStore(db);
|
|
85
87
|
const teamRecallStore = createTeamRecallStore(db);
|
|
@@ -305,6 +307,7 @@ export const createRuntimeStoreServices = (options = {}) => {
|
|
|
305
307
|
agentRuntime,
|
|
306
308
|
db,
|
|
307
309
|
dispatchLedgerStore,
|
|
310
|
+
externalGoalStore,
|
|
308
311
|
isRuntimeClosing: () => closing,
|
|
309
312
|
markRuntimeClosing: () => {
|
|
310
313
|
closing = true;
|
|
@@ -426,6 +429,7 @@ export const createRuntimeStoreLifecycle = ({ agentManager, services, }) => {
|
|
|
426
429
|
});
|
|
427
430
|
return Promise.all(starts);
|
|
428
431
|
};
|
|
432
|
+
const findLiveRun = (runId) => services.shellRuntime.getLiveRun(runId) ?? services.agentRuntime.findLiveRun(runId);
|
|
429
433
|
return {
|
|
430
434
|
close: async () => {
|
|
431
435
|
services.markRuntimeClosing();
|
|
@@ -457,7 +461,13 @@ export const createRuntimeStoreLifecycle = ({ agentManager, services, }) => {
|
|
|
457
461
|
services.shellRuntime.deleteWorkspace(workspaceId);
|
|
458
462
|
},
|
|
459
463
|
closeWorkspaceShell: (workspaceId, runId) => services.shellRuntime.closeRun(workspaceId, runId),
|
|
460
|
-
|
|
464
|
+
findLiveRun,
|
|
465
|
+
getLiveRun: (runId) => {
|
|
466
|
+
const run = findLiveRun(runId);
|
|
467
|
+
if (!run)
|
|
468
|
+
throw new Error(`Live run not found: ${runId}`);
|
|
469
|
+
return run;
|
|
470
|
+
},
|
|
461
471
|
waitForRunExit: (runId, timeoutMs) => services.agentRuntime.waitForRunExit(runId, timeoutMs),
|
|
462
472
|
getPtyOutputBus: () => {
|
|
463
473
|
if (!agentManager)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRuntimeStoreDreamMethods } from './runtime-store-dream.js';
|
|
2
|
+
import { createRuntimeStoreExternalGoalMethods } from './runtime-store-external-goals.js';
|
|
2
3
|
import { createRuntimeStoreLifecycle, createRuntimeStoreServices, logTasksFileWatchStartError, } from './runtime-store-helpers.js';
|
|
3
4
|
import { createRuntimeStoreMemoryMethods } from './runtime-store-memory.js';
|
|
4
5
|
import { createRuntimeStoreRemoteMethods } from './runtime-store-remote.js';
|
|
@@ -61,6 +62,7 @@ export const createRuntimeStore = (options = {}) => {
|
|
|
61
62
|
try {
|
|
62
63
|
runDataMutation(() => {
|
|
63
64
|
services.dispatchLedgerStore.deleteWorkspaceDispatches(workspaceId);
|
|
65
|
+
services.externalGoalStore.deleteWorkspaceGoals(workspaceId);
|
|
64
66
|
services.teamMemoryStore.deleteWorkspaceMemories(workspaceId);
|
|
65
67
|
services.teamMemoryDreamStore.deleteWorkspaceDreamRuns(workspaceId);
|
|
66
68
|
services.workspaceStore.deleteWorkspaceData(workspaceId);
|
|
@@ -92,6 +94,7 @@ export const createRuntimeStore = (options = {}) => {
|
|
|
92
94
|
listDispatches: services.dispatchLedgerStore.listWorkspaceDispatches,
|
|
93
95
|
listOpenDispatches: services.dispatchLedgerStore.listOpenWorkspaceDispatches,
|
|
94
96
|
listRecentDispatches: services.dispatchLedgerStore.listRecentWorkspaceDispatches,
|
|
97
|
+
...createRuntimeStoreExternalGoalMethods(services),
|
|
95
98
|
listWorkers: (workspaceId) => services.workspaceStore.listWorkers(workspaceId),
|
|
96
99
|
getLastPtyLineForAgent: (workspaceId, agentId) => services.workerOutputTracker?.getLastPtyLine(workspaceId, agentId) ?? null,
|
|
97
100
|
getWorkspaceSnapshot: (workspaceId) => services.workspaceStore.getWorkspaceSnapshot(workspaceId),
|
|
@@ -106,6 +109,7 @@ export const createRuntimeStore = (options = {}) => {
|
|
|
106
109
|
autostartConfiguredAgents: lifecycle.autostartConfiguredAgents,
|
|
107
110
|
startWorkspaceWatch: lifecycle.startWorkspaceWatch,
|
|
108
111
|
startWorkspaceShell: lifecycle.startWorkspaceShell,
|
|
112
|
+
findLiveRun: lifecycle.findLiveRun,
|
|
109
113
|
getLiveRun: lifecycle.getLiveRun,
|
|
110
114
|
waitForRunExit: lifecycle.waitForRunExit,
|
|
111
115
|
getActiveRunByAgentId: (workspaceId, agentId) => services.agentRuntime.getActiveRunByAgentId(workspaceId, agentId),
|
|
@@ -122,9 +126,11 @@ export const createRuntimeStore = (options = {}) => {
|
|
|
122
126
|
settings: services.settings,
|
|
123
127
|
writeRunInput: lifecycle.writeRunInput,
|
|
124
128
|
getUiToken: () => services.uiAuth.getToken(),
|
|
129
|
+
getSupervisorToken: () => services.uiAuth.getSupervisorToken(),
|
|
125
130
|
stopAgentRun: lifecycle.stopTerminalRun,
|
|
126
131
|
validateAgentToken: (agentId, token) => services.agentRuntime.validateAgentToken(agentId, token),
|
|
127
132
|
validateUiToken: (token) => services.uiAuth.validate(token),
|
|
133
|
+
validateSupervisorToken: (token) => services.uiAuth.validateSupervisorToken(token),
|
|
128
134
|
getRetentionSignals: () => services.protocolEventStats.getRetentionSignals(),
|
|
129
135
|
...createRuntimeStoreRemoteMethods(services),
|
|
130
136
|
getWorkflowDispatchAwaiter: () => services.workflowDispatchAwaiter,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const applySchemaVersion37 = (db) => {
|
|
2
|
+
db.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS external_goal_sessions (
|
|
4
|
+
id TEXT PRIMARY KEY,
|
|
5
|
+
workspace_id TEXT NOT NULL,
|
|
6
|
+
source TEXT NOT NULL,
|
|
7
|
+
status TEXT NOT NULL,
|
|
8
|
+
goal TEXT NOT NULL,
|
|
9
|
+
context_json TEXT NOT NULL,
|
|
10
|
+
title TEXT,
|
|
11
|
+
summary TEXT,
|
|
12
|
+
created_at INTEGER NOT NULL,
|
|
13
|
+
updated_at INTEGER NOT NULL,
|
|
14
|
+
closed_at INTEGER
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_sessions_workspace
|
|
18
|
+
ON external_goal_sessions (workspace_id, created_at);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS external_goal_events (
|
|
21
|
+
id TEXT PRIMARY KEY,
|
|
22
|
+
goal_id TEXT NOT NULL,
|
|
23
|
+
workspace_id TEXT NOT NULL,
|
|
24
|
+
sequence INTEGER NOT NULL,
|
|
25
|
+
kind TEXT NOT NULL,
|
|
26
|
+
status TEXT,
|
|
27
|
+
body TEXT NOT NULL,
|
|
28
|
+
artifacts_json TEXT NOT NULL,
|
|
29
|
+
created_at INTEGER NOT NULL,
|
|
30
|
+
UNIQUE(goal_id, sequence)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_events_goal
|
|
34
|
+
ON external_goal_events (goal_id, sequence);
|
|
35
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_events_workspace
|
|
36
|
+
ON external_goal_events (workspace_id, created_at);
|
|
37
|
+
`);
|
|
38
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getBuiltinCommandPreset } from './command-preset-defaults.js';
|
|
2
|
+
export const applySchemaVersion38 = (db) => {
|
|
3
|
+
const hasCommandPresets = db
|
|
4
|
+
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'command_presets'")
|
|
5
|
+
.get();
|
|
6
|
+
if (!hasCommandPresets)
|
|
7
|
+
return;
|
|
8
|
+
const preset = getBuiltinCommandPreset('pi');
|
|
9
|
+
if (!preset)
|
|
10
|
+
return;
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
db.prepare(`INSERT INTO command_presets (
|
|
13
|
+
id, display_name, command, args, env, resume_args_template, session_id_capture,
|
|
14
|
+
yolo_args_template, is_builtin, created_at, updated_at
|
|
15
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
|
16
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
17
|
+
display_name = excluded.display_name,
|
|
18
|
+
command = excluded.command,
|
|
19
|
+
args = excluded.args,
|
|
20
|
+
env = excluded.env,
|
|
21
|
+
resume_args_template = excluded.resume_args_template,
|
|
22
|
+
session_id_capture = excluded.session_id_capture,
|
|
23
|
+
yolo_args_template = excluded.yolo_args_template,
|
|
24
|
+
updated_at = excluded.updated_at
|
|
25
|
+
WHERE command_presets.is_builtin = 1`).run(preset.id, preset.displayName, preset.command, '[]', '{}', preset.resumeArgsTemplate, preset.sessionIdCapture ? JSON.stringify(preset.sessionIdCapture) : null, preset.yoloArgsTemplate ? JSON.stringify(preset.yoloArgsTemplate) : null, now, now);
|
|
26
|
+
};
|
|
@@ -29,7 +29,9 @@ import { applySchemaVersion33 } from './sqlite-schema-v33.js';
|
|
|
29
29
|
import { applySchemaVersion34 } from './sqlite-schema-v34.js';
|
|
30
30
|
import { applySchemaVersion35 } from './sqlite-schema-v35.js';
|
|
31
31
|
import { applySchemaVersion36 } from './sqlite-schema-v36.js';
|
|
32
|
-
|
|
32
|
+
import { applySchemaVersion37 } from './sqlite-schema-v37.js';
|
|
33
|
+
import { applySchemaVersion38 } from './sqlite-schema-v38.js';
|
|
34
|
+
export const CURRENT_SCHEMA_VERSION = 38;
|
|
33
35
|
// Idempotent column-add helper. SQLite doesn't have `ALTER TABLE … ADD COLUMN
|
|
34
36
|
// IF NOT EXISTS`, so PRAGMA-check first. Safe to call on every init; required
|
|
35
37
|
// for foreign-built DBs where the version-gated migration is skipped.
|
|
@@ -195,6 +197,41 @@ export const initializeRuntimeDatabase = (db) => {
|
|
|
195
197
|
|
|
196
198
|
CREATE INDEX IF NOT EXISTS idx_workspace_uploads_workspace_created
|
|
197
199
|
ON workspace_uploads (workspace_id, created_at DESC, id DESC);
|
|
200
|
+
|
|
201
|
+
CREATE TABLE IF NOT EXISTS external_goal_sessions (
|
|
202
|
+
id TEXT PRIMARY KEY,
|
|
203
|
+
workspace_id TEXT NOT NULL,
|
|
204
|
+
source TEXT NOT NULL,
|
|
205
|
+
status TEXT NOT NULL,
|
|
206
|
+
goal TEXT NOT NULL,
|
|
207
|
+
context_json TEXT NOT NULL,
|
|
208
|
+
title TEXT,
|
|
209
|
+
summary TEXT,
|
|
210
|
+
created_at INTEGER NOT NULL,
|
|
211
|
+
updated_at INTEGER NOT NULL,
|
|
212
|
+
closed_at INTEGER
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_sessions_workspace
|
|
216
|
+
ON external_goal_sessions (workspace_id, created_at);
|
|
217
|
+
|
|
218
|
+
CREATE TABLE IF NOT EXISTS external_goal_events (
|
|
219
|
+
id TEXT PRIMARY KEY,
|
|
220
|
+
goal_id TEXT NOT NULL,
|
|
221
|
+
workspace_id TEXT NOT NULL,
|
|
222
|
+
sequence INTEGER NOT NULL,
|
|
223
|
+
kind TEXT NOT NULL,
|
|
224
|
+
status TEXT,
|
|
225
|
+
body TEXT NOT NULL,
|
|
226
|
+
artifacts_json TEXT NOT NULL,
|
|
227
|
+
created_at INTEGER NOT NULL,
|
|
228
|
+
UNIQUE(goal_id, sequence)
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_events_goal
|
|
232
|
+
ON external_goal_events (goal_id, sequence);
|
|
233
|
+
CREATE INDEX IF NOT EXISTS idx_external_goal_events_workspace
|
|
234
|
+
ON external_goal_events (workspace_id, created_at);
|
|
198
235
|
`);
|
|
199
236
|
// Idempotent column additions — run on every init regardless of
|
|
200
237
|
// schema_version. The v19 migration adds these columns but is gated on
|
|
@@ -404,4 +441,12 @@ export const initializeRuntimeDatabase = (db) => {
|
|
|
404
441
|
if (!appliedVersions.has(36)) {
|
|
405
442
|
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(36, Date.now());
|
|
406
443
|
}
|
|
444
|
+
applySchemaVersion37(db);
|
|
445
|
+
if (!appliedVersions.has(37)) {
|
|
446
|
+
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(37, Date.now());
|
|
447
|
+
}
|
|
448
|
+
applySchemaVersion38(db);
|
|
449
|
+
if (!appliedVersions.has(38)) {
|
|
450
|
+
db.prepare('INSERT INTO schema_version (version, applied_at) VALUES (?, ?)').run(38, Date.now());
|
|
451
|
+
}
|
|
407
452
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentSummary } from '../shared/types.js';
|
|
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';
|
|
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
4
|
/**
|
|
5
5
|
* Dispatch-target gate: the sentinel is an observer, so handing it a dispatch
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
export interface UiAuth {
|
|
3
3
|
getToken: () => string;
|
|
4
|
+
getSupervisorToken: () => string;
|
|
4
5
|
validate: (token: string | undefined) => boolean;
|
|
6
|
+
validateSupervisorToken: (token: string | undefined) => boolean;
|
|
5
7
|
isTunnelRequest: (request: IncomingMessage) => boolean;
|
|
6
8
|
getTunnelSecret: () => string;
|
|
7
9
|
}
|
|
@@ -2,6 +2,7 @@ import { randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
|
|
|
2
2
|
import { HIVE_REMOTE_SECRET_HEADER } from './remote-loopback-auth.js';
|
|
3
3
|
export const createUiAuth = () => {
|
|
4
4
|
const token = randomUUID();
|
|
5
|
+
const supervisorToken = randomUUID();
|
|
5
6
|
// 32 bytes of CSPRNG entropy, fresh every boot. base64url so it travels as a
|
|
6
7
|
// clean header value. Held only in this closure.
|
|
7
8
|
const tunnelSecret = randomBytes(32).toString('base64url');
|
|
@@ -10,9 +11,15 @@ export const createUiAuth = () => {
|
|
|
10
11
|
getToken() {
|
|
11
12
|
return token;
|
|
12
13
|
},
|
|
14
|
+
getSupervisorToken() {
|
|
15
|
+
return supervisorToken;
|
|
16
|
+
},
|
|
13
17
|
validate(input) {
|
|
14
18
|
return input === token;
|
|
15
19
|
},
|
|
20
|
+
validateSupervisorToken(input) {
|
|
21
|
+
return input === supervisorToken;
|
|
22
|
+
},
|
|
16
23
|
isTunnelRequest(request) {
|
|
17
24
|
const raw = request.headers[HIVE_REMOTE_SECRET_HEADER];
|
|
18
25
|
const got = Array.isArray(raw) ? raw[0] : raw;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* Hive worker report loop should not become workflow agent targets merely by
|
|
19
19
|
* existing in settings.
|
|
20
20
|
*/
|
|
21
|
-
export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "agy"];
|
|
21
|
+
export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini", "hermes", "qwen", "pi", "agy"];
|
|
22
22
|
export type WorkflowCli = (typeof CANONICAL_WORKFLOW_CLIS)[number];
|
|
23
23
|
export declare const WORKFLOW_CLI_POLICY_KEY = "workflow.cli-policy";
|
|
24
24
|
export interface WorkflowCliPolicy {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tt-a1i/hive",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Run Claude Code, Codex, Gemini, OpenCode, Qwen, and other CLI agents as a visible local team in your browser.",
|
|
3
|
+
"version": "2.1.12",
|
|
4
|
+
"description": "Run Claude Code, Codex, Gemini, OpenCode, Qwen, Pi, and other CLI agents as a visible local team in your browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.30.3",
|
|
7
7
|
"license": "BUSL-1.1",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"clean": "node scripts/clean-build.mjs",
|
|
54
54
|
"dev": "pnpm dev:all",
|
|
55
55
|
"dev:all": "concurrently \"pnpm dev:runtime\" \"pnpm dev:web\"",
|
|
56
|
-
"dev:runtime": "tsx src/cli/hive.ts
|
|
56
|
+
"dev:runtime": "tsx src/cli/hive.ts",
|
|
57
57
|
"dev:web": "vite --config web/vite.config.ts",
|
|
58
58
|
"build": "pnpm clean && tsc -p tsconfig.build.json && node scripts/prepare-build-artifacts.mjs && pnpm build:web",
|
|
59
59
|
"build:web": "vite build --config web/vite.config.ts",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-
|
|
2
|
-
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-CVQc8PLJ.js";import{S as pe}from"./search-Bx1xfpzr.js";import{S as he}from"./square-terminal-Dfr9QC1I.js";const fe=[["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"}]],ge=z("bookmark-plus",fe);const be=[["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"}]],ve=z("dices",be);const ke=[["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"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"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(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(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:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?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(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,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===c;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:()=>{s(r.id),x(!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(L,{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:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(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(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!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(Y,{open:b!==null,onOpenChange:r=>{r||k(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;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.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(M,{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(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?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:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.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(ge,{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:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{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:l=>n(l.currentTarget.value),placeholder:x==="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&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),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]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=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(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"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(te,{commandPresetId:s,fallback:m,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:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.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(M,{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:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?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:x})]}),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:m=>t(m.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:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-DAZ-crqq.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"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(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"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)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("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(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("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(me,{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(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("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(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("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:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!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(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),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:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??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 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-BIyJIDK4.js","assets/index-CTJnf-r_.js","assets/index-DYIPzuPD.css","assets/search-CbyBNPSq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-CTJnf-r_.js";import{S as pe}from"./search-CbyBNPSq.js";import{S as he}from"./square-terminal-eIii6bbw.js";const fe=[["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"}]],ge=z("bookmark-plus",fe);const be=[["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"}]],ve=z("dices",be);const ke=[["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"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"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(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(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:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?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(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,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===c;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:()=>{s(r.id),x(!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(L,{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:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(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(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!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(Y,{open:b!==null,onOpenChange:r=>{r||k(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;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.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(M,{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(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?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:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.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(ge,{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:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{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:l=>n(l.currentTarget.value),placeholder:x==="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&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),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]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=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(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"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(te,{commandPresetId:s,fallback:m,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:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.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(M,{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:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?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:x})]}),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:m=>t(m.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:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-BIyJIDK4.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"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(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"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)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("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(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("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(me,{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(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("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(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("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:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!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(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),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:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??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 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|