u-foo 3.1.7 → 4.0.1
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/OBSERVABILITY.md +65 -0
- package/README.md +238 -21
- package/README.zh-CN.md +165 -20
- package/SKILLS/ufoo/SKILL.md +40 -4
- package/SKILLS/ufoo-bus/SKILL.md +46 -3
- package/bin/uclaude.js +4 -0
- package/bin/ucodex.js +4 -0
- package/bin/ufoo.js +6 -4
- package/dist/tui/darwin-arm64/ufoo-tui +0 -0
- package/dist/tui/darwin-x64/ufoo-tui +0 -0
- package/dist/tui/linux-arm64/ufoo-tui +0 -0
- package/dist/tui/linux-x64/ufoo-tui +0 -0
- package/package.json +14 -7
- package/scripts/postinstall-skills.js +53 -0
- package/scripts/postinstall.js +11 -16
- package/scripts/smoke-native-messages.js +214 -0
- package/src/agents/activity/activityDetector.js +1 -1
- package/src/agents/activity/activityStateWriter.js +37 -38
- package/src/agents/capabilities/agentManagement/index.js +4 -0
- package/src/agents/capabilities/agentManagement/service.js +140 -0
- package/src/agents/capabilities/agentRouting/index.js +4 -0
- package/src/agents/capabilities/coding/index.js +32 -0
- package/src/agents/capabilities/coordination/index.js +37 -0
- package/src/agents/capabilities/globalRouting/index.js +5 -0
- package/src/agents/capabilities/groups/index.js +3 -0
- package/src/agents/capabilities/index.js +25 -0
- package/src/agents/capabilities/planning/index.js +123 -0
- package/src/agents/capabilities/planning/main.js +28 -0
- package/src/agents/capabilities/projectDiscovery/index.js +3 -0
- package/src/agents/capabilities/scheduling/index.js +3 -0
- package/src/agents/capabilities/sharedMemory/index.js +4 -0
- package/src/agents/capabilities/skills/index.js +12 -0
- package/src/agents/capabilities/taskExecution/index.js +3 -0
- package/src/agents/capabilities/taskReports/index.js +6 -0
- package/src/agents/controller/controllerToolExecutor.js +40 -22
- package/src/agents/controller/index.js +1 -6
- package/src/agents/internal/internalRunner.js +181 -76
- package/src/agents/launch/index.js +0 -1
- package/src/agents/launch/launcher.js +96 -14
- package/src/agents/launch/nativeCapabilities.js +40 -0
- package/src/agents/launch/nativeMessages.js +362 -0
- package/src/agents/launch/notifier.js +15 -20
- package/src/agents/launch/readyDetector.js +28 -14
- package/src/agents/profiles/coding.js +6 -0
- package/src/agents/profiles/globalRouter.js +2 -0
- package/src/agents/profiles/main.js +5 -0
- package/src/agents/prompts/cooperation.js +14 -0
- package/src/agents/prompts/defaultBootstrap.js +1 -1
- package/src/agents/prompts/groupBootstrap.js +32 -6
- package/src/agents/prompts/mainAgent.js +48 -0
- package/src/agents/prompts/native/system.js +4 -1
- package/src/agents/prompts/native/tasks.js +2 -2
- package/src/agents/prompts/native/ufoo.js +14 -3
- package/src/agents/prompts/promptProfiles.js +2 -0
- package/src/agents/prompts/reporting.js +16 -0
- package/src/agents/providers/claudeEventTranslator.js +9 -1
- package/src/agents/providers/claudeThreadProvider.js +47 -4
- package/src/agents/providers/clientIdentity.js +75 -0
- package/src/agents/providers/codexEventTranslator.js +68 -7
- package/src/agents/providers/codexThreadProvider.js +18 -8
- package/src/agents/providers/credentials/claude.js +10 -3
- package/src/agents/providers/credentials/index.js +2 -0
- package/src/agents/providers/directAuthStatus.js +1 -1
- package/src/agents/providers/index.js +1 -1
- package/src/agents/providers/modelSettings.js +34 -0
- package/src/agents/providers/modelsCatalog.js +379 -0
- package/src/agents/providers/nativeTransport.js +1146 -0
- package/src/agents/providers/runtimeConfig.js +188 -0
- package/src/agents/providers/thinkingLevels.js +106 -0
- package/src/agents/providers/transports/anthropicMessagesTransport.js +121 -0
- package/src/agents/providers/transports/index.js +10 -0
- package/src/agents/providers/transports/openaiChatTransport.js +117 -0
- package/src/agents/providers/transports/openaiResponsesTransport.js +120 -0
- package/src/agents/providers/transports/responsesProtocol.js +504 -0
- package/src/agents/providers/transports/systemBlocks.js +16 -0
- package/src/agents/providers/transports/transportContract.js +50 -0
- package/src/agents/providers/transports/visionBlocks.js +151 -0
- package/src/agents/providers/upstreamRuntime.js +135 -0
- package/src/agents/runtime/composeCapabilities.js +89 -0
- package/src/agents/runtime/context/checkpointStore.js +38 -0
- package/src/agents/runtime/context/commandStore.js +43 -0
- package/src/agents/runtime/context/compaction.js +151 -0
- package/src/agents/runtime/context/contextBudget.js +93 -0
- package/src/agents/runtime/context/contextWindow.js +119 -0
- package/src/agents/runtime/context/fileLock.js +36 -0
- package/src/agents/runtime/context/replayHistory.js +28 -0
- package/src/agents/runtime/context/runtimeStore.js +127 -0
- package/src/agents/runtime/context/sessionJournal.js +360 -0
- package/src/agents/runtime/context/sessionStore.js +57 -0
- package/src/agents/runtime/core/agentLoop.js +351 -0
- package/src/agents/runtime/core/executionBudget.js +36 -0
- package/src/agents/runtime/core/stableJson.js +29 -0
- package/src/agents/runtime/core/toolLoopGuard.js +55 -0
- package/src/agents/runtime/createAgentRuntime.js +259 -0
- package/src/agents/runtime/index.js +14 -0
- package/src/agents/runtime/prompts/responseLanguage.js +12 -0
- package/src/agents/runtime/protocol/faultHarness.js +90 -0
- package/src/agents/runtime/protocol/materialize.js +107 -0
- package/src/agents/runtime/protocol/runObservation.js +24 -0
- package/src/agents/runtime/protocol/toolCallLedger.js +221 -0
- package/src/agents/runtime/protocol/traceContext.js +9 -0
- package/src/agents/runtime/tasks/resourceLease.js +66 -0
- package/src/agents/runtime/tasks/scheduler.js +73 -0
- package/src/agents/runtime/tools/registry.js +57 -0
- package/src/app/chat/ChatController.js +29 -45
- package/src/app/chat/agentDirectory.js +9 -18
- package/src/app/chat/bootstrap.js +1 -2
- package/src/app/chat/commandExecutor.js +111 -313
- package/src/app/chat/commands.js +39 -45
- package/src/app/chat/daemonConnection.js +58 -5
- package/src/app/chat/daemonMessageRouter.js +61 -48
- package/src/app/chat/historyStore.js +12 -48
- package/src/app/chat/inputSubmitHandler.js +21 -35
- package/src/app/chat/internalAgentLogHistory.js +19 -60
- package/src/app/chat/launchRequestContext.js +42 -0
- package/src/app/chat/multiWindow/paneManager.js +91 -164
- package/src/app/chat/streamState.js +3 -7
- package/src/app/chat/transport.js +1 -1
- package/src/app/cli/busCoreCommands.js +9 -0
- package/src/app/cli/features/doctor.js +33 -0
- package/src/app/cli/features/init.js +5 -5
- package/src/app/cli/features/skills.js +16 -4
- package/src/app/cli/metricsCommands.js +68 -0
- package/src/app/cli/reportCoreCommands.js +37 -0
- package/src/app/cli/run.js +82 -42
- package/src/app/cli/traceCommands.js +36 -0
- package/src/code/agent.js +34 -17
- package/src/code/busConsumer.js +1 -3
- package/src/code/commands.js +1 -1
- package/src/code/context/artifacts.js +12 -11
- package/src/code/context/assembler.js +9 -9
- package/src/code/context/promptLayers.js +1 -13
- package/src/code/context/stableJson.js +2 -27
- package/src/code/context/stateCommit.js +2 -1
- package/src/code/contextWindow.js +2 -117
- package/src/code/conversation/sessionJournal.js +3 -349
- package/src/code/internalThread.js +107 -0
- package/src/code/launcher/ucode.js +1 -1
- package/src/code/launcher/ucodeBootstrap.js +1 -1
- package/src/code/modelCommand.js +11 -35
- package/src/code/nativeRunner.js +104 -2697
- package/src/code/protocol/faultHarness.js +2 -88
- package/src/code/protocol/materialize.js +2 -105
- package/src/code/protocol/toolCallLedger.js +5 -215
- package/src/code/providers/anthropicMessagesTransport.js +2 -118
- package/src/code/providers/modelsCatalog.js +1 -317
- package/src/code/providers/openaiChatTransport.js +2 -114
- package/src/code/providers/openaiResponsesTransport.js +2 -117
- package/src/code/providers/responsesProtocol.js +2 -497
- package/src/code/providers/transportContract.js +2 -48
- package/src/code/providers/visionBlocks.js +2 -149
- package/src/code/repl.js +2 -11
- package/src/code/sessionStore.js +27 -99
- package/src/code/taskDecomposer.js +18 -0
- package/src/code/thinkingLevels.js +1 -130
- package/src/code/toolBudget.js +1 -17
- package/src/code/toolLoopGuard.js +3 -49
- package/src/code/tools/artifactRead.js +1 -1
- package/src/code/tools/executor.js +373 -0
- package/src/code/tools/specs.js +312 -0
- package/src/config.js +95 -131
- package/src/coordination/bus/deliveryQueue.js +16 -2
- package/src/coordination/bus/index.js +14 -9
- package/src/coordination/bus/inject.js +15 -7
- package/src/coordination/bus/message.js +15 -1
- package/src/coordination/bus/nativeReceipts.js +100 -0
- package/src/coordination/bus/nickname.js +1 -1
- package/src/coordination/bus/queue.js +1 -3
- package/src/coordination/bus/subscriber.js +3 -2
- package/src/coordination/bus/utils.js +8 -4
- package/src/coordination/history/agentPerformance.js +279 -0
- package/src/coordination/history/agentSurface.js +142 -0
- package/src/coordination/history/agentTrace.js +249 -0
- package/src/coordination/memory/index.js +5 -21
- package/src/coordination/report/store.js +103 -83
- package/src/coordination/state/agentsStore.js +57 -3
- package/src/coordination/state/fileLock.js +2 -0
- package/src/coordination/state/workspaceAccess.js +36 -0
- package/src/orchestration/controller/index.js +1 -8
- package/src/orchestration/controller/launchRouting.js +1 -1
- package/src/orchestration/solo/commands.js +3 -1
- package/src/runtime/contracts/agentMode.js +26 -0
- package/src/runtime/contracts/eventContract.js +3 -0
- package/src/runtime/contracts/uiProtocol.js +20 -17
- package/src/runtime/daemon/agentHost.js +407 -0
- package/src/runtime/daemon/agentRecoveryGroups.js +70 -0
- package/src/runtime/daemon/busBridge.js +396 -0
- package/src/runtime/daemon/claudeChannel.js +159 -0
- package/src/runtime/daemon/controlPlaneService.js +28 -18
- package/src/runtime/daemon/cronOps.js +25 -17
- package/src/runtime/daemon/deliveryScheduler.js +32 -5
- package/src/runtime/daemon/globalDaemon.js +28 -1
- package/src/runtime/daemon/groupOrchestrator.js +21 -5
- package/src/runtime/daemon/groupStatus.js +20 -0
- package/src/runtime/daemon/index.js +120 -375
- package/src/runtime/daemon/ipcServer.js +32 -10
- package/src/runtime/daemon/mcpConfigure.js +113 -20
- package/src/runtime/daemon/mcpHttpServer.js +27 -5
- package/src/runtime/daemon/mcpServer.js +8 -5
- package/src/runtime/daemon/mcpStdioProxy.js +127 -10
- package/src/runtime/daemon/nicknameScope.js +1 -1
- package/src/runtime/daemon/ops.js +68 -40
- package/src/runtime/daemon/projectRuntimeGateway.js +2 -0
- package/src/runtime/daemon/promptRequest.js +92 -570
- package/src/runtime/daemon/providerSessions.js +67 -33
- package/src/runtime/daemon/reportControlBus.js +59 -25
- package/src/runtime/daemon/status.js +9 -6
- package/src/runtime/privacy/redactor.js +2 -2
- package/src/runtime/projects/identity.js +2 -1
- package/src/runtime/projects/registry.js +98 -38
- package/src/tools/controllerSchemas.js +28 -0
- package/src/tools/handlers/dispatchMessage.js +5 -2
- package/src/tools/handlers/listAgents.js +3 -1
- package/src/tools/handlers/readBusSummary.js +3 -1
- package/src/tools/handlers/readProjectRegistry.js +29 -2
- package/src/tools/handlers/routeAgent.js +35 -0
- package/src/tools/handlers/tier2.js +4 -2
- package/src/tools/index.js +1 -0
- package/src/tools/registry.js +6 -0
- package/src/tools/schemaFixtures.js +42 -5
- package/src/tools/tier0/readAgentMetrics.js +14 -0
- package/src/tools/tier0/readAgentTrace.js +12 -0
- package/src/tools/tier1/routeAgent.js +2 -2
- package/src/tools/tier2/runtimeCoordination.js +38 -0
- package/src/tools/types.js +2 -0
- package/src/ui/agentPresentation.js +109 -0
- package/src/ui/agentSettingsController.js +107 -0
- package/src/ui/agentSurface.js +270 -0
- package/src/ui/dashboardBridge.js +1 -1
- package/src/ui/format/banner.js +9 -15
- package/src/ui/format/index.js +14 -10
- package/src/ui/format/loopSummary.js +50 -0
- package/src/ui/format/markdownRenderer.js +3 -4
- package/src/ui/format/startupBanner.js +50 -0
- package/src/ui/multiPaneBusMirror.js +29 -3
- package/src/ui/rustChatHost.js +316 -599
- package/src/ui/rustMultiSession.js +288 -73
- package/src/ui/rustUcodeHost.js +21 -88
- package/src/ui/settingsBridge.js +34 -14
- package/src/ui/toolMergeBridge.js +0 -4
- package/src/ui/uiHostServer.js +5 -8
- package/src/agents/controller/loopObservability.js +0 -200
- package/src/agents/controller/loopRuntime.js +0 -472
- package/src/agents/controller/ufooAgent.js +0 -829
- package/src/agents/launch/ptyRunner.js +0 -1135
- package/src/agents/providers/upstreamTransport.js +0 -689
- package/src/app/chat/agentBar.js +0 -135
- package/src/app/chat/agentEnter.js +0 -70
- package/src/app/chat/agentSockets.js +0 -225
- package/src/app/chat/dashboardView.js +0 -405
- package/src/app/chat/multiWindow/index.js +0 -310
- package/src/app/chat/multiWindow/paneLayout.js +0 -84
- package/src/app/chat/multiWindow/renderer.js +0 -420
- package/src/app/chat/multiWindow/virtualTerminal.js +0 -327
- package/src/app/chat/multiWindow/vtFrame.js +0 -93
- package/src/app/chat/rawKeyMap.js +0 -42
- package/src/app/chat/settingsController.js +0 -111
- package/src/orchestration/controller/flags.js +0 -167
- package/src/orchestration/controller/gateRouter.js +0 -211
- package/src/orchestration/controller/routerFastPath.js +0 -22
- package/src/orchestration/controller/routerFinalize.js +0 -222
- package/src/orchestration/controller/shadowGuard.js +0 -280
- package/src/runtime/daemon/promptLoop.js +0 -136
- package/src/runtime/privacy/shadowDiff.js +0 -174
- package/src/ui/multiWindowHandoff.js +0 -232
- package/src/ui/ptyHandoff.js +0 -23
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Multi-window handoff after Rust TUI suspend (exit 75, reason=multi).
|
|
5
|
-
* Reuses createMultiWindowController (same VT/pane code as Ink).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { createMultiWindowController } = require("../app/chat/multiWindow");
|
|
9
|
-
const { resolveAgentEnterRequest, resolveInjectSockPathForAgent } = require("../app/chat/agentEnter");
|
|
10
|
-
const { restoreStdinAfterHandoff } = require("./ptyHandoff");
|
|
11
|
-
|
|
12
|
-
function agentIdsFromMeta(activeAgentMeta) {
|
|
13
|
-
if (activeAgentMeta instanceof Map) {
|
|
14
|
-
return Array.from(activeAgentMeta.keys()).map(String).filter(Boolean);
|
|
15
|
-
}
|
|
16
|
-
if (activeAgentMeta && typeof activeAgentMeta === "object") {
|
|
17
|
-
return Object.keys(activeAgentMeta);
|
|
18
|
-
}
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function labelForAgent(activeAgentMeta, agentId) {
|
|
23
|
-
const meta = activeAgentMeta instanceof Map
|
|
24
|
-
? activeAgentMeta.get(agentId)
|
|
25
|
-
: (activeAgentMeta && activeAgentMeta[agentId]);
|
|
26
|
-
if (!meta || typeof meta !== "object") return agentId;
|
|
27
|
-
return String(meta.display_nickname || meta.nickname || meta.scoped_nickname || agentId);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @returns {Promise<{ ok: boolean, error?: string }>}
|
|
32
|
-
*/
|
|
33
|
-
async function runMultiWindowHandoff({
|
|
34
|
-
projectRoot = process.cwd(),
|
|
35
|
-
activeAgentMeta = new Map(),
|
|
36
|
-
settings = {},
|
|
37
|
-
getChatLogLines = () => [],
|
|
38
|
-
getStatusText = () => "",
|
|
39
|
-
getDashboardLines = () => [],
|
|
40
|
-
onInternalSubmit = null,
|
|
41
|
-
stdin = process.stdin,
|
|
42
|
-
stdout = process.stdout,
|
|
43
|
-
} = {}) {
|
|
44
|
-
const agents = agentIdsFromMeta(activeAgentMeta);
|
|
45
|
-
if (agents.length === 0) {
|
|
46
|
-
return { ok: false, error: "No active agents for multi-window mode" };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let terminalFocused = false;
|
|
50
|
-
let done = false;
|
|
51
|
-
let resolveDone = null;
|
|
52
|
-
const finished = new Promise((resolve) => {
|
|
53
|
-
resolveDone = resolve;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const originalWrite = stdout.write.bind(stdout);
|
|
57
|
-
const controller = createMultiWindowController({
|
|
58
|
-
processStdout: {
|
|
59
|
-
write: originalWrite,
|
|
60
|
-
rows: stdout.rows,
|
|
61
|
-
columns: stdout.columns,
|
|
62
|
-
},
|
|
63
|
-
getRows: () => stdout.rows || 24,
|
|
64
|
-
getCols: () => stdout.columns || 80,
|
|
65
|
-
getInjectSockPath: (agentId) => resolveInjectSockPathForAgent(projectRoot, agentId),
|
|
66
|
-
getActiveAgents: () => agentIdsFromMeta(activeAgentMeta),
|
|
67
|
-
getAgentPaneOptions: (agentId) => {
|
|
68
|
-
const enterRequest = resolveAgentEnterRequest({
|
|
69
|
-
agentId,
|
|
70
|
-
projectRoot,
|
|
71
|
-
activeAgentMeta,
|
|
72
|
-
settings,
|
|
73
|
-
});
|
|
74
|
-
if (!enterRequest || !enterRequest.useBus) return { mode: "socket" };
|
|
75
|
-
let initialLines = [];
|
|
76
|
-
try {
|
|
77
|
-
const { loadInternalAgentLogHistory } = require("../app/chat/internalAgentLogHistory");
|
|
78
|
-
initialLines = loadInternalAgentLogHistory(projectRoot, agentId, {
|
|
79
|
-
maxEvents: 200,
|
|
80
|
-
maxLines: 200,
|
|
81
|
-
});
|
|
82
|
-
} catch {
|
|
83
|
-
initialLines = [];
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
mode: "internal",
|
|
87
|
-
initialLines: [
|
|
88
|
-
`ufoo internal agent · ${labelForAgent(activeAgentMeta, agentId)}`,
|
|
89
|
-
`agent: ${agentId}`,
|
|
90
|
-
"",
|
|
91
|
-
...initialLines,
|
|
92
|
-
],
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
getChatLogLines,
|
|
96
|
-
getStatusText,
|
|
97
|
-
getPromptPrefix: () => "› ",
|
|
98
|
-
getCurrentDraft: () => "",
|
|
99
|
-
getCursorPos: () => 0,
|
|
100
|
-
getCompletions: () => ({ items: [], index: -1, windowStart: 0, pageSize: 8 }),
|
|
101
|
-
getAgentLabel: (id) => labelForAgent(activeAgentMeta, id),
|
|
102
|
-
getInternalPaneInfo: (id) => {
|
|
103
|
-
const meta = activeAgentMeta instanceof Map
|
|
104
|
-
? activeAgentMeta.get(id)
|
|
105
|
-
: (activeAgentMeta && activeAgentMeta[id]);
|
|
106
|
-
return {
|
|
107
|
-
status: String((meta && meta.activity_state) || ""),
|
|
108
|
-
detail: String((meta && meta.activity_detail) || ""),
|
|
109
|
-
input: "",
|
|
110
|
-
cursor: 0,
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
getDashboardLines,
|
|
114
|
-
getTerminalFocused: () => terminalFocused,
|
|
115
|
-
freezeScreen: (frozen) => {
|
|
116
|
-
if (frozen) stdout.write = () => true;
|
|
117
|
-
else stdout.write = originalWrite;
|
|
118
|
-
},
|
|
119
|
-
restoreTerminal: () => {
|
|
120
|
-
const rows = stdout.rows || 24;
|
|
121
|
-
originalWrite(`\x1b[1;${rows}r`);
|
|
122
|
-
originalWrite("\x1b[2J\x1b[H");
|
|
123
|
-
},
|
|
124
|
-
onInternalSubmit: (agentId, message) => {
|
|
125
|
-
if (typeof onInternalSubmit === "function") {
|
|
126
|
-
onInternalSubmit(agentId, message);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
onExit: () => {
|
|
130
|
-
done = true;
|
|
131
|
-
if (typeof resolveDone === "function") resolveDone();
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (!controller.enter()) {
|
|
136
|
-
return { ok: false, error: "No active agents for multi-window mode" };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const wasRaw = typeof stdin.isRaw === "boolean" ? stdin.isRaw : false;
|
|
140
|
-
try {
|
|
141
|
-
if (typeof stdin.setRawMode === "function" && stdin.isTTY) {
|
|
142
|
-
stdin.setRawMode(true);
|
|
143
|
-
}
|
|
144
|
-
if (typeof stdin.resume === "function") stdin.resume();
|
|
145
|
-
} catch {
|
|
146
|
-
// ignore
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const onResize = () => {
|
|
150
|
-
try {
|
|
151
|
-
controller.handleResize();
|
|
152
|
-
} catch {
|
|
153
|
-
// ignore
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
if (stdout && typeof stdout.on === "function") {
|
|
157
|
-
stdout.on("resize", onResize);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const onData = (chunk) => {
|
|
161
|
-
if (done) return;
|
|
162
|
-
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk || ""), "utf8");
|
|
163
|
-
if (buf.length === 0) return;
|
|
164
|
-
|
|
165
|
-
// Ctrl+C → exit multi
|
|
166
|
-
if (buf.includes(0x03)) {
|
|
167
|
-
controller.exit();
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
// Ctrl+Q → exit multi
|
|
171
|
-
if (buf.includes(0x11)) {
|
|
172
|
-
controller.handleKey({ name: "q", ctrl: true, sequence: "" });
|
|
173
|
-
terminalFocused = false;
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
// Ctrl+W → cycle focus (chat chrome ↔ agent panes)
|
|
177
|
-
if (buf.includes(0x17)) {
|
|
178
|
-
const ids = controller.getAgentIds();
|
|
179
|
-
if (ids.length === 0) return;
|
|
180
|
-
if (!terminalFocused) {
|
|
181
|
-
controller.focusAgent(ids[0]);
|
|
182
|
-
terminalFocused = true;
|
|
183
|
-
} else {
|
|
184
|
-
const current = controller.getFocused();
|
|
185
|
-
const idx = current ? ids.indexOf(current) : -1;
|
|
186
|
-
if (idx >= 0 && idx < ids.length - 1) {
|
|
187
|
-
controller.focusAgent(ids[idx + 1]);
|
|
188
|
-
} else {
|
|
189
|
-
terminalFocused = false;
|
|
190
|
-
controller.focusAgent(ids[0]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
controller.renderAll();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (terminalFocused) {
|
|
198
|
-
controller.sendInput(buf.toString("utf8"));
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
stdin.on("data", onData);
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
await finished;
|
|
206
|
-
return { ok: true };
|
|
207
|
-
} finally {
|
|
208
|
-
stdin.removeListener("data", onData);
|
|
209
|
-
if (stdout && typeof stdout.off === "function") {
|
|
210
|
-
stdout.off("resize", onResize);
|
|
211
|
-
} else if (stdout && typeof stdout.removeListener === "function") {
|
|
212
|
-
stdout.removeListener("resize", onResize);
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
if (controller.isActive()) controller.exit();
|
|
216
|
-
} catch {
|
|
217
|
-
// ignore
|
|
218
|
-
}
|
|
219
|
-
try {
|
|
220
|
-
if (typeof stdin.setRawMode === "function" && stdin.isTTY) {
|
|
221
|
-
stdin.setRawMode(wasRaw);
|
|
222
|
-
}
|
|
223
|
-
} catch {
|
|
224
|
-
// ignore
|
|
225
|
-
}
|
|
226
|
-
restoreStdinAfterHandoff(stdin);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
module.exports = {
|
|
231
|
-
runMultiWindowHandoff,
|
|
232
|
-
};
|
package/src/ui/ptyHandoff.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Stdin restore helpers after any fullscreen handoff (e.g. legacy multi).
|
|
5
|
-
* Agent PTY mirror handoff has been removed — activate / side / multi only.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
function restoreStdinAfterHandoff(stdin = process.stdin) {
|
|
9
|
-
try {
|
|
10
|
-
if (stdin && typeof stdin.setRawMode === "function" && stdin.isTTY) {
|
|
11
|
-
stdin.setRawMode(false);
|
|
12
|
-
}
|
|
13
|
-
if (stdin && typeof stdin.resume === "function") {
|
|
14
|
-
stdin.resume();
|
|
15
|
-
}
|
|
16
|
-
} catch {
|
|
17
|
-
// ignore — next TUI will reconfigure
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
restoreStdinAfterHandoff,
|
|
23
|
-
};
|