tide-commander 1.174.0 → 1.176.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/assets/{BossLogsModal-CsjhF9hQ.js → BossLogsModal-qzLlhqPZ.js} +1 -1
- package/dist/assets/{BossSpawnModal-DRgrZpYr.js → BossSpawnModal-Bo5btfZs.js} +1 -1
- package/dist/assets/{ControlsModal-zYwhMaaL.js → ControlsModal-CCP1SS-b.js} +1 -1
- package/dist/assets/{DockerLogsModal-D7bewBqJ.js → DockerLogsModal-d2Isd330.js} +1 -1
- package/dist/assets/{EmbeddedEditor-IxYwI5JV.js → EmbeddedEditor-C2whRCAd.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-CfOuUZnu.js → GmailOAuthSetup-BM4xBt67.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-Cw1tGSti.js → GoogleOAuthSetup-BMvbdHEK.js} +1 -1
- package/dist/assets/{IframeModal-Bi8MNGZY.js → IframeModal-Diz8yWFu.js} +1 -1
- package/dist/assets/{IntegrationsPanel-01iVXM-l.js → IntegrationsPanel-W_8l0DxS.js} +2 -2
- package/dist/assets/{LogViewerModal-BXhxgz7Z.js → LogViewerModal-DU64WFDr.js} +1 -1
- package/dist/assets/{MonitoringModal-Gf0AkCEl.js → MonitoringModal-BoG0Hr7X.js} +1 -1
- package/dist/assets/{PM2LogsModal-BfoL_mEK.js → PM2LogsModal-ZemBmh8q.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-Ctss__a9.js → RestoreArchivedAreaModal-CEkL1jB3.js} +1 -1
- package/dist/assets/{Scene2DCanvas-BuCW0Zaw.js → Scene2DCanvas-BpX0JWYQ.js} +1 -1
- package/dist/assets/{SceneManager-BFnKKU1I.js → SceneManager-CdCkKNKF.js} +2 -2
- package/dist/assets/{SkillsPanel-D7kJE7eT.js → SkillsPanel-CcJJoxVd.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-Hp7r3YK0.js → SlackMultiInstanceSetup-D0QFzYL8.js} +1 -1
- package/dist/assets/{SpawnModal-Dq9P-FdI.js → SpawnModal-C8EMz9dV.js} +1 -1
- package/dist/assets/{StatisticsModal-BQOkmrmY.js → StatisticsModal-DBWeBd6u.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-D2-IpRLn.js → SubordinateAssignmentModal-g2VK-d4p.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-BCZhLuoZ.js → TriggerManagerPanel-CybQfvUd.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BEjublaK.js → WorkflowEditorPanel-Doo1fthh.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-jjWEEISc.js → abnfDiagram-VRR7QNED-DIzWJ00e.js} +1 -1
- package/dist/assets/{arc-xqT5-bwQ.js → arc-DYnuDU5M.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-BXEbOurL.js → architectureDiagram-ZJ3FMSHR-DcQkZge3.js} +1 -1
- package/dist/assets/{area-logos-BH-HM2a-.js → area-logos-CvKL6axv.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-D-0HVLDv.js → blockDiagram-677ZJIJ3-P9qfYIyd.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-BK39PXfT.js → c4Diagram-LMCZKHZV-Brvvf8IR.js} +1 -1
- package/dist/assets/channel-BjM2BONO.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CuW4NYbO.js → chunk-2Q5K7J3B-huNYyvxh.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-eJLo7W-b.js → chunk-32BRIVSS-BPwUeNlq.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-E2Yaai0b.js → chunk-5VM5RSS4-ClvwfT9j.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-9uAbQnMb.js → chunk-EX3LRPZG-r7lw8w07.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-kKtXyMkv.js → chunk-JWPE2WC7-Cg-NNKhK.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-DPN5ReJ7.js → chunk-MOJQB5TN-D1jRsGiz.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-d3yFo4Hu.js → chunk-RYQCIY6F-DzLe8Mhn.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC--3A8oVa7.js → chunk-V7JOEXUC-CP3S5ECO.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-KpHuZy9_.js → chunk-VR4S4FIN-CJsUxduu.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-hpU30gZQ.js → chunk-XXDRQBXY-CG5BEMYm.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-Bo96wh-7.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-Bo96wh-7.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-DOhYmYxe.js → cose-bilkent-JH36ORCC-ByxdBNNQ.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-UDH0NYTi.js → cynefin-VYW2F7L2-DUAFhLA3.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-DnGUiXaD.js → cynefinDiagram-TSTJHNR4-B2Kk-MGz.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-BQ6C_GWY.js → dagre-VKFMJZFB-DFCRJf_G.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-CREz1035.js → diagram-FQU43EPY-wYMGeAdu.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-9Jr7GbsE.js → diagram-G47NLZAW-rgjw8pQP.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-DtN5x74X.js → diagram-NH7WQ7WH-BpZASdpx.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-UuOi8FAP.js → diagram-OA4YK3LP-CakEHPj1.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-CWiUGHfM.js → diagram-WEI45ONY-BgF2sKn7.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-3eMfQx1G.js → ebnfDiagram-CCIWWBDH-D0Kf9aJj.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-DYzSgp8n.js → erDiagram-Q63AITRT-sKvL1I4l.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-DBLDGx8O.js → flowDiagram-23GEKE2U-DgS4-v6l.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-Dv7Uyp2U.js → ganttDiagram-NO4QXBWP-DxkYU6kL.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-leeHrOrC.js → gitGraphDiagram-IHSO6WYX-BP9sXgF1.js} +1 -1
- package/dist/assets/{index-lHF2zw41.js → index-B5rQe41U.js} +1 -1
- package/dist/assets/index-BLo9z-jE.js +1 -0
- package/dist/assets/{index-CFiAyn9P.js → index-CcSdiUnJ.js} +3 -3
- package/dist/assets/index-Cf8OqaQe.js +1 -0
- package/dist/assets/{index-Bnk8mX62.js → index-Ct8OBbU_.js} +1 -1
- package/dist/assets/{index-fP8UTiVP.js → index-D1S-PYLr.js} +2 -2
- package/dist/assets/{index-DY2LUL1D.js → index-DCRtV-sQ.js} +1 -1
- package/dist/assets/{index-CtGcfchE.js → index-DSC1km47.js} +1 -1
- package/dist/assets/{index-Cpf2LUXa.js → index-MzszL_qp.js} +4 -4
- package/dist/assets/{infoDiagram-FWYZ7A6U-B23FL64X.js → infoDiagram-FWYZ7A6U-ODz77wW8.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-BPsjNXWV.js → ishikawaDiagram-FXEZZL3T-B-zkHET8.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-3jqJYemY.js → journeyDiagram-5HDEW3XC-3-0ZxNaY.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-rHfIfWqi.js → kanban-definition-HUTT4EX6-6TXFrj9B.js} +1 -1
- package/dist/assets/{linear-CvofFTBe.js → linear-D4INeZan.js} +1 -1
- package/dist/assets/main-BNsRZCIt.css +1 -0
- package/dist/assets/{main-ts-uUN3p.js → main-awRasOMk.js} +142 -139
- package/dist/assets/{mermaid.core-BuuQCwr7.js → mermaid.core-VfI8B8Nu.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-CdMbsouS.js → mindmap-definition-LN4V7U3C-BtnLuWah.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-Cl7drnf-.js → pegDiagram-2B236MQR-C7u_WQ8m.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-CrfvJw6b.js → pieDiagram-ENE6RG2P-FP2oK2aq.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-D6Z7VqX6.js → quadrantDiagram-ABIIQ3AL-C7R49DqX.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-DBhqTpwY.js → railroadDiagram-RFXS5EU6-8Y-09cJG.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-DjYygiNl.js → requirementDiagram-TGXJPOKE-CuLFvAIT.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-Cb8su5H6.js → sankeyDiagram-HTMAVEWB-C83wAget.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-DH326uFa.js → sequenceDiagram-DBY2YBRQ-2bX54qCB.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-BA-8zei3.js → sizeCapture-X5ZJPWSS-CwcxMidm.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-DM412fD5.js → stateDiagram-2N3HPSRC-BRLu0Nh3.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-HDFSwLIz.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-BouPQ02z.js → swimlanes-5IMT3BWC-0ZHVD_6W.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-DIR86oWK.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-CHbeQn6a.js → timeline-definition-FHXFAJF6-mZxmuno3.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-HSzYjTi7.js → vennDiagram-L72KCM5P-529a4wgg.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-DvrdmzxK.js → wardleyDiagram-EHGQE667-DsYcsK_D.js} +1 -1
- package/dist/assets/{web-BvtZvOK9.js → web-CUfujGZR.js} +1 -1
- package/dist/assets/{web-DT7q-yw_.js → web-CzSim3jK.js} +1 -1
- package/dist/assets/{web-DwD7eqxR.js → web-VJlfgT9G.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-DgSgkHvg.js → xychartDiagram-FW5EYKEG-DImLqIu4.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/de/terminal.json +2 -1
- package/dist/locales/en/terminal.json +3 -1
- package/dist/locales/es/terminal.json +3 -1
- package/dist/locales/fr/terminal.json +2 -1
- package/dist/locales/hi/terminal.json +2 -1
- package/dist/locales/it/terminal.json +2 -1
- package/dist/locales/ja/terminal.json +2 -1
- package/dist/locales/pt/terminal.json +2 -1
- package/dist/locales/ru/terminal.json +2 -1
- package/dist/locales/zh-CN/terminal.json +2 -1
- package/dist/src/packages/server/claude/backend.js +26 -2
- package/dist/src/packages/server/claude/interactive/interactive-backend-args.js +1 -1
- package/dist/src/packages/server/claude/interactive/interactive-jsonl-translator.js +20 -0
- package/dist/src/packages/server/claude/interactive/interactive-jsonl-watcher.js +9 -1
- package/dist/src/packages/server/claude/runner/process-lifecycle.js +3 -1
- package/dist/src/packages/server/claude/runner/restart-policy.js +65 -2
- package/dist/src/packages/server/claude/runner/stdout-pipeline.js +10 -1
- package/dist/src/packages/server/claude/runner/watchdog.js +29 -0
- package/dist/src/packages/server/claude/session-loader.js +641 -45
- package/dist/src/packages/server/claude/types.js +10 -1
- package/dist/src/packages/server/codex/app-server/app-server-event-adapter.js +27 -11
- package/dist/src/packages/server/grok/session-watcher.js +60 -0
- package/dist/src/packages/server/routes/agents.js +26 -0
- package/dist/src/packages/server/routes/sessions.js +9 -4
- package/dist/src/packages/server/routes/system.js +16 -0
- package/dist/src/packages/server/services/agent-service.js +10 -0
- package/dist/src/packages/server/services/codex-usage-service.js +141 -2
- package/dist/src/packages/server/services/runtime-service.js +22 -0
- package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +27 -0
- package/dist/src/packages/shared/model-fallback.js +203 -0
- package/dist/src/packages/shared/types.js +1 -0
- package/package.json +1 -1
- package/dist/assets/channel-BgBFpxsT.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-CXHgnAgF.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-CXHgnAgF.js +0 -1
- package/dist/assets/index-BrN1fSea.js +0 -1
- package/dist/assets/index-jlRDILHc.js +0 -1
- package/dist/assets/main-CZA5Uyu6.css +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-BZJwjeVk.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-BRQaNmpd.js +0 -8
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Silent model-fallback detection.
|
|
3
|
+
*
|
|
4
|
+
* Anthropic's API can serve a turn with a DIFFERENT model than the one the
|
|
5
|
+
* session was started with — a refusal fallback, a capacity/quota fallback, or
|
|
6
|
+
* a server-side mid-stream swap. Only the first of those lanes shows a dialog
|
|
7
|
+
* in the CLI; the other two produce no UI notification at all and do not honor
|
|
8
|
+
* the local opt-outs (`switchModelsOnFlag`, CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK).
|
|
9
|
+
*
|
|
10
|
+
* The one trace that always reaches us is the message stamp: when a swap
|
|
11
|
+
* happens the CLI rewrites `message.model` on the assistant message to the
|
|
12
|
+
* model that actually served it, while the session's `system/init` keeps
|
|
13
|
+
* reporting the model we asked for. Comparing those two catches all three
|
|
14
|
+
* lanes, which is what these helpers do.
|
|
15
|
+
*/
|
|
16
|
+
const TIERS = ['fable', 'opus', 'sonnet', 'haiku'];
|
|
17
|
+
/**
|
|
18
|
+
* Reduce any model spelling to a comparable id.
|
|
19
|
+
*
|
|
20
|
+
* Handles the Tide Commander `[1m]` suffix (a context-window label, not a
|
|
21
|
+
* different model), cloud-vendor prefixes (Bedrock `us.anthropic.…`, Vertex),
|
|
22
|
+
* dated snapshots (`-20260115`) and Bedrock revisions (`-v1:0`). Returns null
|
|
23
|
+
* for values that name no real model — `<synthetic>` is the CLI's placeholder
|
|
24
|
+
* for locally generated messages (rate-limit notices, cancellations).
|
|
25
|
+
*/
|
|
26
|
+
export function normalizeModelId(raw) {
|
|
27
|
+
if (!raw)
|
|
28
|
+
return null;
|
|
29
|
+
let id = raw.trim().toLowerCase();
|
|
30
|
+
if (!id || id === '<synthetic>' || id === 'synthetic')
|
|
31
|
+
return null;
|
|
32
|
+
id = id.replace(/\[1m\]$/, '');
|
|
33
|
+
id = id.replace(/^(?:bedrock|vertex|anthropic)\//, '');
|
|
34
|
+
id = id.replace(/^(?:us|eu|apac|global)\./, '');
|
|
35
|
+
id = id.replace(/^anthropic\./, '');
|
|
36
|
+
id = id.replace(/-v\d+:\d+$/, '');
|
|
37
|
+
id = id.replace(/[-@]\d{8}$/, '');
|
|
38
|
+
id = id.replace(/-latest$/, '');
|
|
39
|
+
return id || null;
|
|
40
|
+
}
|
|
41
|
+
/** Which family a model belongs to, regardless of version. */
|
|
42
|
+
export function modelTier(raw) {
|
|
43
|
+
const id = normalizeModelId(raw);
|
|
44
|
+
if (!id)
|
|
45
|
+
return null;
|
|
46
|
+
return TIERS.find((tier) => id === tier || id.includes(tier)) ?? null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* True when the id names only a family and lets the CLI pick the version
|
|
50
|
+
* (`opus`, `sonnet`, `haiku`, `default`). Those requests cannot be compared
|
|
51
|
+
* version-for-version — whatever version the CLI resolves is legitimate — so
|
|
52
|
+
* they are only checked at tier level.
|
|
53
|
+
*/
|
|
54
|
+
export function isModelAlias(raw) {
|
|
55
|
+
const id = normalizeModelId(raw);
|
|
56
|
+
if (!id)
|
|
57
|
+
return false;
|
|
58
|
+
return id === 'default' || TIERS.includes(id);
|
|
59
|
+
}
|
|
60
|
+
const TIER_LABELS = {
|
|
61
|
+
fable: 'Fable',
|
|
62
|
+
opus: 'Opus',
|
|
63
|
+
sonnet: 'Sonnet',
|
|
64
|
+
haiku: 'Haiku',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Compact human label for a model id: `claude-opus-4-8` → `Opus 4.8`.
|
|
68
|
+
* Falls back to the raw id when the shape is unfamiliar, so an unknown model
|
|
69
|
+
* still shows something truthful instead of a wrong guess.
|
|
70
|
+
*/
|
|
71
|
+
export function formatModelName(raw) {
|
|
72
|
+
const id = normalizeModelId(raw);
|
|
73
|
+
if (!id)
|
|
74
|
+
return raw?.trim() || 'unknown';
|
|
75
|
+
const tier = modelTier(id);
|
|
76
|
+
if (!tier)
|
|
77
|
+
return raw?.trim() || id;
|
|
78
|
+
// Version digits, in either modern (`claude-opus-4-8`) or legacy
|
|
79
|
+
// (`claude-3-5-sonnet`) ordering — both reduce to the same digit list.
|
|
80
|
+
const digits = id
|
|
81
|
+
.split('-')
|
|
82
|
+
.filter((part) => /^\d+$/.test(part));
|
|
83
|
+
const label = TIER_LABELS[tier];
|
|
84
|
+
if (digits.length === 0)
|
|
85
|
+
return label;
|
|
86
|
+
return `${label} ${digits.join('.')}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Compare the requested session model against the model that actually served a
|
|
90
|
+
* message. Returns null when there is nothing to report:
|
|
91
|
+
* - either side is unknown or `<synthetic>`,
|
|
92
|
+
* - the models match,
|
|
93
|
+
* - the request was a bare family alias and the served model is in that same
|
|
94
|
+
* family (the CLI resolving `opus` → `claude-opus-4-8` is not a fallback).
|
|
95
|
+
*/
|
|
96
|
+
export function detectModelFallback(requested, served) {
|
|
97
|
+
const from = normalizeModelId(requested);
|
|
98
|
+
const to = normalizeModelId(served);
|
|
99
|
+
if (!from || !to || from === to)
|
|
100
|
+
return null;
|
|
101
|
+
const fromTier = modelTier(from);
|
|
102
|
+
const toTier = modelTier(to);
|
|
103
|
+
// `opus` → `claude-opus-4-8` is the CLI resolving our own alias, not a swap.
|
|
104
|
+
if (isModelAlias(from) && fromTier && fromTier === toTier)
|
|
105
|
+
return null;
|
|
106
|
+
return {
|
|
107
|
+
from,
|
|
108
|
+
to,
|
|
109
|
+
fromLabel: formatModelName(from),
|
|
110
|
+
toLabel: formatModelName(to),
|
|
111
|
+
tierChanged: fromTier !== toTier,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Per-agent state machine over "which model answered this message".
|
|
116
|
+
*
|
|
117
|
+
* Reports the *edges* only — one transition when the API starts serving
|
|
118
|
+
* something else, one when the requested model comes back — so a fallback that
|
|
119
|
+
* spans twenty turns produces two lines, not forty.
|
|
120
|
+
*/
|
|
121
|
+
export class ModelFallbackTracker {
|
|
122
|
+
requested;
|
|
123
|
+
served;
|
|
124
|
+
/**
|
|
125
|
+
* @param requested model this session asked for, if already known
|
|
126
|
+
* @param served model observed serving it before this tracker existed
|
|
127
|
+
* (e.g. restored from a persisted agent record after a
|
|
128
|
+
* restart) so the "back to normal" edge isn't lost
|
|
129
|
+
*/
|
|
130
|
+
constructor(requested, served) {
|
|
131
|
+
this.requested = requested ?? null;
|
|
132
|
+
this.served = served ?? null;
|
|
133
|
+
}
|
|
134
|
+
get requestedModel() {
|
|
135
|
+
return this.requested;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Record which model this run asked for. Keeps the observed served model when
|
|
139
|
+
* the new value is just a different spelling of the same family (our alias
|
|
140
|
+
* `opus` and the CLI's resolution `claude-opus-4-8` trade places between the
|
|
141
|
+
* launch args and `system/init`) — otherwise a sustained fallback would
|
|
142
|
+
* re-announce itself at the top of every turn.
|
|
143
|
+
*/
|
|
144
|
+
setRequested(requested) {
|
|
145
|
+
const previous = this.requested;
|
|
146
|
+
if (previous === requested)
|
|
147
|
+
return;
|
|
148
|
+
// Same model, different spelling. Observed live: the launch args say
|
|
149
|
+
// `claude-haiku-4-5` while a resumed session's `system/init` reports the
|
|
150
|
+
// dated `claude-haiku-4-5-20251001`. Comparing raw strings there would drop
|
|
151
|
+
// the served model at the top of every resumed turn, which is exactly how a
|
|
152
|
+
// sustained fallback would end up re-announcing itself on every turn.
|
|
153
|
+
const previousId = normalizeModelId(previous);
|
|
154
|
+
if (previousId !== null && previousId === normalizeModelId(requested)) {
|
|
155
|
+
this.requested = requested;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const tier = modelTier(previous);
|
|
159
|
+
const aliasRefinement = previous !== null
|
|
160
|
+
&& tier !== null
|
|
161
|
+
&& tier === modelTier(requested)
|
|
162
|
+
&& (isModelAlias(previous) || isModelAlias(requested));
|
|
163
|
+
this.requested = requested;
|
|
164
|
+
// Learning the requested model for the first time invalidates nothing — in
|
|
165
|
+
// particular it must not drop a served model seeded from a persisted agent
|
|
166
|
+
// record, which is the whole point of that seed.
|
|
167
|
+
if (previous !== null && !aliasRefinement)
|
|
168
|
+
this.served = null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Feed the model that served a main-loop message. Returns a transition only
|
|
172
|
+
* when the situation actually changed, otherwise null.
|
|
173
|
+
*/
|
|
174
|
+
observe(servedModel) {
|
|
175
|
+
if (!this.requested)
|
|
176
|
+
return null;
|
|
177
|
+
const detection = detectModelFallback(this.requested, servedModel);
|
|
178
|
+
const servedNow = detection ? detection.to : null;
|
|
179
|
+
if (servedNow === this.served)
|
|
180
|
+
return null;
|
|
181
|
+
const wasFallenBack = this.served !== null;
|
|
182
|
+
this.served = servedNow;
|
|
183
|
+
if (detection) {
|
|
184
|
+
return {
|
|
185
|
+
restored: false,
|
|
186
|
+
requestedModel: detection.from,
|
|
187
|
+
servedModel: detection.to,
|
|
188
|
+
label: `${detection.fromLabel} → ${detection.toLabel}`,
|
|
189
|
+
detection,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (!wasFallenBack)
|
|
193
|
+
return null;
|
|
194
|
+
const requested = normalizeModelId(this.requested) || this.requested;
|
|
195
|
+
return {
|
|
196
|
+
restored: true,
|
|
197
|
+
requestedModel: requested,
|
|
198
|
+
servedModel: requested,
|
|
199
|
+
label: formatModelName(requested),
|
|
200
|
+
detection: null,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// - common-types.ts: Drawing, tools, skills, events, permissions, notifications, secrets, exec tasks
|
|
7
7
|
// - websocket-messages.ts: All WebSocket message interfaces and union types
|
|
8
8
|
export * from './agent-types.js';
|
|
9
|
+
export * from './model-fallback.js';
|
|
9
10
|
export * from './building-types.js';
|
|
10
11
|
export * from './database-types.js';
|
|
11
12
|
export * from './common-types.js';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,C as n}from"./mermaid.core-BuuQCwr7.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-V7JOEXUC--3A8oVa7.js";import{_ as i}from"./mermaid.core-BuuQCwr7.js";import"./chunk-5VM5RSS4-E2Yaai0b.js";import"./chunk-XXDRQBXY-hpU30gZQ.js";import"./chunk-VR4S4FIN-KpHuZy9_.js";import"./chunk-32BRIVSS-eJLo7W-b.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as a,c as s,a as e,C as t}from"./chunk-V7JOEXUC--3A8oVa7.js";import{_ as i}from"./mermaid.core-BuuQCwr7.js";import"./chunk-5VM5RSS4-E2Yaai0b.js";import"./chunk-XXDRQBXY-hpU30gZQ.js";import"./chunk-VR4S4FIN-KpHuZy9_.js";import"./chunk-32BRIVSS-eJLo7W-b.js";import"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as At,d as yt,x as Et,_ as xt,f as Ct,bH as Mt,bI as wt,a6 as Ft,r as d,w as St,S as pe,bJ as bt,bK as fe,s as Y,bL as Bt,j as f,I as ne,T as Ye,bM as vt,n as It,bN as _t,bO as Dt,bP as Ee,R as Be,m as Rt,bQ as nt,u as we,bR as Je}from"./main-ts-uUN3p.js";import{bS as Ls,bT as $s,bU as js,bV as Ns,bW as Ps}from"./main-ts-uUN3p.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function kt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":kt(t)}function q(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function Q(t){return t!=null}function ve(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ot(t){let e=null,n=null,r=null,i=1,c=null;if(q(t)||re(t))r=t,e=Ze(t),n=Ie(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=Ze(o),n=Ie(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function Ze(t){return re(t)?t:t.split(".")}function Ie(t){return re(t)?t.join("."):t}function Qt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(Q(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!Q(l))return;if(a===o.length-1&&(q(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,q(e)?e.split("."):e,0),r?n:n[0]}const Gt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ht={location:0,threshold:.6,distance:100},Ut={useExtendedSearch:!1,getFn:Qt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Gt,...Ht,...Ut};const Vt=/[^ ]+/g;function Yt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Vt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Yt(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,q(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();q(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!Q(e)||ve(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(Q(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(Q(h))if(q(h)&&!ve(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,C)=>{u.push({nestedArrIndex:C,value:E})})}r.$[c]=a}else if(q(o)&&!ve(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function Zt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,C=Math.max(0,Math.min(r,E));let g=c,p=C;const S=a>1||u,F=S?Array(E):[];let T;for(;(T=t.indexOf(e,p))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:C,distance:i,ignoreLocation:l});if(g=Math.min($,g),p=T+h,S){let N=0;for(;N<h;)F[T+N]=1,N+=1}}p=-1;let j=[],G=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,_=W;for(;N<_;)xe(e,{errors:$,currentLocation:C+_,expectedLocation:C,distance:i,ignoreLocation:l})<=g?N=_:W=_,_=Math.floor((W-N)/2+N);W=_;let ae=Math.max(1,C-_+1),H=o?E:Math.min(C+_,E)+h,b=Array(H+2);b[H+1]=(1<<$)-1;for(let R=H;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(F[X]=+!!O),b[R]=(b[R+1]<<1|1)&O,$&&(b[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),b[R]&oe&&(G=xe(e,{errors:$,currentLocation:X,expectedLocation:C,distance:i,ignoreLocation:l}),G<=g)){if(g=G,p=X,p<=C)break;ae=Math.max(1,2*C-p)}}if(xe(e,{errors:$+1,currentLocation:C,expectedLocation:C,distance:i,ignoreLocation:l})>g)break;j=b}const ie={isMatch:p>=0,score:Math.max(.001,G)};if(S){const $=Xt(F,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function qt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,p)=>{this.chunks.push({pattern:g,alphabet:qt(g),startIndex:p})},C=this.pattern.length;if(C>le){let g=0;const p=C%le,S=C-p;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(p){const F=C-le;E(this.pattern.substr(F),F)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],C=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:F,startIndex:T})=>{const{isMatch:j,score:G,indices:W}=Zt(e,S,F,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),C+=G,j&&W&&(E=[...E,...W])});let p={isMatch:g,score:g?C/this.chunks.length:1};return g&&i&&(p.indices=E),p}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return qe(e,this.multiRegex)}static isSingleMatch(e){return qe(e,this.singleRegex)}search(){}}function qe(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ts extends ce{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class ss extends ce{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ns extends ce{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class rs extends ce{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class is extends ce{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const _e=[es,ht,ss,ns,is,rs,ts,lt],et=_e.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=_e[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=_e[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let C=0,g=E.length;C<g;C+=1){const p=E[C],{isMatch:S,indices:F,score:T}=p.search(e);if(S){if(o+=1,u+=T,r){const j=p.constructor.type;us.has(j)?a=[...a,...F]:a.push(F)}}else{u=0,o=0,a.length=0;break}}if(o){let C={isMatch:!0,score:u/o};return r&&(C.indices=a),C}}return{isMatch:!1,score:1}}}const De=[];function hs(...t){De.push(...t)}function Re(t,e){for(let n=0,r=De.length;n<r;n+=1){let i=De[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},ke={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[ke.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[ke.PATH]:c[0],l=o?i[ke.PATTERN]:i[u];if(!q(l))throw new Error(Nt(u));const h={keyId:Ie(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ps(t,e){const n=t.matches;e.matches=[],Q(n)&&n.forEach(r=>{if(!Q(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ms(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ps),r&&i.push(ms),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class Z{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Q(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=q(e)?q(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!Q(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:C}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:C});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,C=a.children.length;E<C;E+=1){const g=a.children[E],p=r(g,u,l);if(p.length)h.push(...p);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(Q(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!Q(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!Q(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!Q(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}Z.version="7.1.0";Z.createIndex=at;Z.parseIndex=Jt;Z.config=y;Z.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(pe.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(pe.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(pe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function ws({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),C=Ct(),g=Mt(),p=wt(),S=Ft(),F=d.useRef(e);F.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const G=d.useRef(i);G.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[_,ae]=d.useState(st),[H,b]=d.useState(0),[M,R]=d.useState(Cs),[X,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(pe.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),b(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=_.trim();if(s.length<xs){O([]);return}let m=!1;const w=setTimeout(()=>{ys(s).then(x=>{m||O(x)}).catch(()=>{m||O([])})},250);return()=>{m=!0,clearTimeout(w)}},[t,_]);const Fe=d.useCallback(s=>{R(s),bt(pe.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const m=fe.indexOf($e.current),w=fe[(m+s+fe.length)%fe.length];Fe(w)},[Fe]);d.useEffect(()=>{b(0)},[M]);const Se=Y.getShortcuts(),ge=d.useMemo(()=>t?Bt():{},[t]),me=d.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,m=Se.find(x=>x.id==="spawn-agent"),w=Se.find(x=>x.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":m?Ye(m):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{F.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":w!=null&&w.key?Ye(w):"Tab",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{F.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{F.current(),G.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var x;F.current(),(x=N.current)==null||x.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const m=(g||[]).filter(V=>V.agentId===s.id).map(V=>V.filePath),w=[...new Set(m)],x=w.map(V=>V.split("/").pop()||V),B=[];s.lastAssignedTask&&B.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let D=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(D+=` ${s.taskLabel}`),x.length>0&&(D+=` ${x.join(" ")} ${w.join(" ")}`),B.length>0&&(D+=` ${B.join(" ")}`);const P=Date.now()-s.lastActivity;let U;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?U=s.lastAssignedTask.slice(0,150)+"...":U=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:U,timeAway:P,icon:f.jsx(It,{agent:s,size:20}),_searchText:D,_modifiedFiles:w,_userQueries:B,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{F.current(),vt(s.id),Y.selectAgent(s.id),Y.getState().viewMode!=="flat"&&Y.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var m;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((m=s.directories)==null?void 0:m.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{F.current(),Y.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const m of he)m._agentId&&s.set(m._agentId,m);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const m of h.values()){const w=Y.getAreaForAgent(m.id);if(!w||w.archived)continue;const x=s.get(w.id);x?x.push(m):s.set(w.id,[m])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const m of p)s.has(m.agentId)||s.set(m.agentId,m.timestamp);return s},[p]),be=d.useMemo(()=>{if(!t)return[];const s=_.trim().toLowerCase(),m=_t({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:B=>Pe.get(B)}),w=Array.from(E.values()).filter(B=>!B.archived).filter(B=>s?B.name.toLowerCase().includes(s):!0).sort((B,L)=>B.name.localeCompare(L.name,void 0,{sensitivity:"base"})),x=[];for(const B of w){const D=(Ne.get(B.id)||[]).slice().sort(m).map(P=>je.get(P.id)).filter(P=>!!P);!s&&D.length===0||x.push({areaId:B.id,areaName:B.name,areaColor:B.color,agents:D})}return x},[t,_,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(C.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var P,U,V,ue,ee;const m=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",w=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",x=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${x} • ${s.status}`;if(s.type==="database"&&((U=(P=s.database)==null?void 0:P.connections)!=null&&U.length)){const z=s.database.connections[0];B+=` • ${z.engine} @ ${z.host}`}else s.type==="tests"&&s.folderPath?B=`${x} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const L=((V=s.pm2Status)==null?void 0:V.ports)||[];let D=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(D+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(D+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)D+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:m}),f.jsx(ne,{name:w,size:16})]}),_searchText:D,action:()=>{var z;F.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?Y.openTestsBuilding(s.id):s.type==="http"?Y.openHttpBuilding(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,C]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],m=new Set,w=[];for(const x of s){if(m.has(x.filePath))continue;m.add(x.filePath);const B=x.filePath.split("/").pop()||x.filePath,L=x.action==="created"?"Created":x.action==="modified"?"Modified":x.action==="deleted"?"Deleted":"Read";if(w.push({id:`modified-${x.filePath}-${x.timestamp}`,type:"modified-file",title:B,subtitle:`${L} by ${x.agentName} • ${x.filePath}`,matchedText:x.filePath,icon:x.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):Dt(x.filePath),action:()=>{F.current();const D=Array.from(Y.getState().areas.values());for(const P of D)for(const U of P.directories||[])if(x.filePath.startsWith(U)){Y.setFileViewerPath(x.filePath),W.current(P.id);return}Y.selectAgent(x.agentId)}}),w.length>=50)break}return w},[t,g]),Oe=d.useMemo(()=>t?X.map(s=>{const m=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:m,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{F.current(),Y.openFileExplorer(s.path)}}}):[],[t,X]),ze=d.useMemo(()=>new Z(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Qe=d.useMemo(()=>new Z(me,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[me]),Ge=d.useMemo(()=>new Z(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new Z(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),He=d.useMemo(()=>new Z(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!_.trim()){const A=[];A.push(...ye);const v=[...he].sort((k,K)=>{const te=Ee(k._agentId,k._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...v),A.push(...me.slice(0,2)),A.push(...Ae.slice(0,2));const I={};return Es.forEach((k,K)=>{I[k]=K}),A.sort((k,K)=>(I[k.type]??999)-(I[K.type]??999)),A}const s=_.trim().toLowerCase(),m=ze.search(_).slice(0,8),w=Qe.search(_).slice(0,3),x=Ge.search(_).slice(0,2),B=We.search(_).slice(0,3),L=Oe.slice(0,8),D=He.search(_).filter(A=>{const v=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||v<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const v=A.title.toLowerCase();return v===s?6:v.startsWith(s)?5:v.split(/[^a-z0-9]+/i).includes(s)?4:v.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},V=(A,v)=>{const I=(1-Math.min(1,v??1))*4;return U(A)*100+(P[A.type]??0)*5+I},ue=new Map,ee=(A,v)=>{const I=ue.get(A.type),k={item:A,score:V(A,v)};I?I.push(k):ue.set(A.type,[k])};for(const A of m){const v={...A.item};if(v._modifiedFiles&&v._modifiedFiles.length>0){const I=v._modifiedFiles.filter(k=>{var se;const K=((se=k.split("/").pop())==null?void 0:se.toLowerCase())||"",te=k.toLowerCase();return K.includes(s)||te.includes(s)});I.length>0&&(v.matchedFiles=I)}if(v._userQueries&&v._userQueries.length>0){const I=v._userQueries.find(k=>k.toLowerCase().includes(s));if(I)if(I.length>200){const K=I.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(I.length,K+s.length+100);v.matchedQuery=(te>0?"...":"")+I.slice(te,se)+(se<I.length?"...":"")}else v.matchedQuery=I}ee(v,A.score)}for(const A of D)ee(A.item,A.score);for(const A of w)ee(A.item,A.score);for(const A of x)ee(A.item,A.score);for(const A of B)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,v]of ue)A==="agent"?v.sort((I,k)=>{const K=U(I.item),te=U(k.item);if(te!==K)return te-K;const se=Ee(I.item._agentId,I.item._lastActivity,ge),Ve=Ee(k.item._agentId,k.item._lastActivity,ge);return Ve!==se?Ve-se:k.score-I.score}):v.sort((I,k)=>k.score-I.score);const z=A=>A.reduce((v,I)=>Math.max(v,I.score),-1),Ue=[];return Array.from(ue.values()).sort((A,v)=>z(v)-z(A)).forEach(A=>{for(const v of A)Ue.push(v.item)}),Ue},[_,ze,Qe,Ge,We,He,me,he,Ae,ye,Oe,ge]),J=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return be.flatMap(s=>s.agents);case"all":default:return de}},[M,de,be]);d.useEffect(()=>{H>=J.length&&b(Math.max(0,J.length-1))},[J.length,H]);const pt=d.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const m=s.key.toLowerCase();b(m==="p"?w=>w>0?w-1:J.length-1:w=>w<J.length-1?w+1:0);return}switch(s.key){case"Escape":s.preventDefault(),F.current();break;case"ArrowUp":s.preventDefault(),b(m=>m>0?m-1:J.length-1);break;case"ArrowDown":s.preventDefault(),b(m=>m<J.length-1?m+1:0);break;case"Enter":s.preventDefault(),J[H]&&J[H].action();break}},[J,H]),mt=d.useCallback((s,m)=>{if(!m||!s)return s;const w=s.toLowerCase(),x=m.toLowerCase(),B=[];let L=0,D=w.indexOf(x),P=0;for(;D!==-1;)D>L&&B.push(s.slice(L,D)),B.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(D,D+m.length))),L=D+m.length,D=w.indexOf(x,L);return L<s.length&&B.push(s.slice(L)),B.length>0?Be.createElement(Be.Fragment,null,...B):s},[]);return{query:_,setQuery:ft,selectedIndex:H,setSelectedIndex:b,results:J,activeTab:M,setActiveTab:Fe,cycleTab:gt,areaSections:be,handleKeyDown:pt,highlightMatch:mt}}const Fs=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=we(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=we(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),bs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=we(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const p=()=>{h.current=!0};return g.addEventListener("mousemove",p),()=>{g.removeEventListener("mousemove",p)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},C=d.useMemo(()=>{const g=[];let p=null,S=[];return e.forEach((F,T)=>{F.type!==p&&(p!==null&&S.length>0&&g.push([p,S]),p=F.type,S=[]),S.push({result:F,index:T})}),p!==null&&S.length>0&&g.push([p,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const p=g.querySelector(".spotlight-item.selected");p&&p.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(p=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:p.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:p.areaName}),f.jsx("span",{className:"spotlight-area-count",children:p.agents.length})]}),p.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):p.agents.map(S=>{const F=g++;return f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id)})]},p.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:C.map(([g,p])=>f.jsxs("div",{children:[C.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),p.map(({result:S,index:F})=>f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id))]},g))})}),Bs=d.memo(function(){const{t:e}=we(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),vs=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),C=d.useRef(null),g=d.useRef(0),{query:p,setQuery:S,selectedIndex:F,setSelectedIndex:T,results:j,activeTab:G,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=ws({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const _=d.useRef(oe);_.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var b,M;(b=h.current)==null||b.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const b=window.visualViewport;if(!b||window.innerWidth>vs)return;const M=()=>{const R=E.current;R&&(R.style.height=`${b.height}px`,R.style.top=`${b.offsetTop}px`)};return M(),b.addEventListener("resize",M),b.addEventListener("scroll",M),()=>{b.removeEventListener("resize",M),b.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const b=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),_.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",b,{capture:!0}),()=>{window.removeEventListener("keydown",b,{capture:!0})}},[t,e]);const ae=d.useCallback(b=>{b.target===b.currentTarget&&e()},[e]),H=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(Fs,{ref:h,query:p,onQueryChange:S,onKeyDown:$,onResetSelection:H}),f.jsx(Ss,{activeTab:G,onSelect:W}),f.jsx(bs,{ref:C,results:j,selectedIndex:F,query:p,activeTab:G,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(Bs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,Bs as SpotlightFooter,Fs as SpotlightInput,Je as SpotlightItem,bs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,Dt as getFileIconFromPath,Ps as getTypeLabel,ws as useSpotlightSearch};
|