@aiwg/cli 2026.10.14 → 2026.10.16
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/agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
- package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +37 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +27 -25
- package/dist/src/artifacts/corpus-tools/expand-cli.js +90 -0
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +41 -0
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +56 -0
- package/dist/src/artifacts/corpus-tools/expand.js +124 -0
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +99 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +119 -0
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +45 -0
- package/dist/src/cli/handlers/doctor-help.js +8 -3
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +3 -2
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands.js +8 -0
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -586
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +19 -0
- package/dist/src/config/host-resource-report.mjs +80 -0
- package/dist/src/config/host-resource-runtime.d.mts +34 -0
- package/dist/src/config/host-resource-runtime.mjs +293 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-context.js +33 -4
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +9 -2
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +115 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +2 -2
- package/dist/src/gates/heldout.js +52 -0
- package/dist/src/gates/index.js +2 -1
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/models/worker-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/research/clients/arxiv.js +14 -34
- package/dist/src/research/clients/base.js +53 -26
- package/dist/src/research/clients/crossref.js +9 -1
- package/dist/src/research/clients/semantic-scholar.js +73 -44
- package/dist/src/research/identity.js +117 -0
- package/dist/src/research/index.js +1 -0
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +135 -0
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/rules/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -0
- package/dist/src/serve/mission-conductor.js +48 -4
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +19 -46
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +49 -114
- package/dist/src/smiths/context-pipeline/managed-hook.js +11 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/package.json +13 -2
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +12 -123
- package/tools/agents/providers/antigravity.mjs +1 -1
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +16 -0
- package/tools/agents/providers/grok-build.mjs +8 -5
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
- package/tools/agents/providers/hermes-startup.mjs +209 -0
- package/tools/agents/providers/hermes.mjs +9 -359
- package/tools/agents/providers/model-wrapper.mjs +5 -1
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/pi.mjs +4 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1346
- package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-presentation.mjs +13 -4
- package/tools/agents/providers/rule-projection.mjs +119 -0
- package/tools/agents/providers/rule-startup.mjs +70 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
- package/tools/agents/providers/warp.mjs +2 -2
- package/tools/agents/providers/windsurf.mjs +11 -57
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/plugin/plugin-links.mjs +3 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +3 -2
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tmux Manager - Session management for the daemon REPL
|
|
3
|
+
*
|
|
4
|
+
* Creates and manages tmux sessions with a 2-pane layout:
|
|
5
|
+
* - Top pane (70%): Interactive chat REPL
|
|
6
|
+
* - Bottom pane (30%): Status dashboard
|
|
7
|
+
*
|
|
8
|
+
* @implements @.aiwg/requirements/use-cases/UC-TMUX-001.md
|
|
9
|
+
* @tests @test/unit/daemon/tmux-manager.test.js
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { spawn } from 'node:child_process';
|
|
13
|
+
import { EventEmitter } from 'node:events';
|
|
14
|
+
import { importImpl } from '../_resolve-impl.mjs';
|
|
15
|
+
|
|
16
|
+
const { boundedExecFileSync } = await importImpl(import.meta.url, 'process/bounded-child-process.mjs');
|
|
17
|
+
|
|
18
|
+
export class TmuxManager extends EventEmitter {
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
super();
|
|
21
|
+
this.sessionName = options.sessionName || 'aiwg-daemon';
|
|
22
|
+
this.chatPaneRatio = options.chatPaneRatio || 70;
|
|
23
|
+
this.daemonScript = options.daemonScript || null;
|
|
24
|
+
this.statusRefreshMs = options.statusRefreshMs || 5000;
|
|
25
|
+
this.statusTimer = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Check if tmux is installed and available
|
|
30
|
+
*/
|
|
31
|
+
isTmuxAvailable() {
|
|
32
|
+
try {
|
|
33
|
+
boundedExecFileSync('tmux', ['-V'], 'quick', { stdio: 'pipe' });
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Check if session already exists
|
|
42
|
+
*/
|
|
43
|
+
sessionExists() {
|
|
44
|
+
try {
|
|
45
|
+
boundedExecFileSync('tmux', ['has-session', '-t', this.sessionName], 'quick', { stdio: 'pipe' });
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a new tmux session with 2-pane layout
|
|
54
|
+
* @param {object} options - Creation options
|
|
55
|
+
* tmux executes these trusted, operator-supplied commands through its shell.
|
|
56
|
+
* @param {string} options.chatCommand - Shell command for the chat pane
|
|
57
|
+
* @param {string} options.statusCommand - Shell command for the status pane
|
|
58
|
+
*/
|
|
59
|
+
createSession(options = {}) {
|
|
60
|
+
if (!this.isTmuxAvailable()) {
|
|
61
|
+
throw new Error('tmux is not installed. Install with: apt install tmux');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (this.sessionExists()) {
|
|
65
|
+
throw new Error(`Session "${this.sessionName}" already exists. Use attach() instead.`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const chatCommand = options.chatCommand || 'echo "Chat pane ready"';
|
|
69
|
+
const statusCommand = options.statusCommand || 'echo "Status pane ready"';
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
// Create session in detached mode with the chat command
|
|
73
|
+
boundedExecFileSync(
|
|
74
|
+
'tmux', ['new-session', '-d', '-s', this.sessionName, '-x', '200', '-y', '50', chatCommand],
|
|
75
|
+
'quick',
|
|
76
|
+
{ stdio: 'pipe' }
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Split horizontally for status pane (bottom)
|
|
80
|
+
const statusPercent = 100 - this.chatPaneRatio;
|
|
81
|
+
boundedExecFileSync(
|
|
82
|
+
'tmux', ['split-window', '-t', this.sessionName, '-v', '-p', String(statusPercent), statusCommand],
|
|
83
|
+
'quick',
|
|
84
|
+
{ stdio: 'pipe' }
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Select the top pane (chat) as active
|
|
88
|
+
boundedExecFileSync('tmux', ['select-pane', '-t', `${this.sessionName}:0.0`], 'quick', { stdio: 'pipe' });
|
|
89
|
+
|
|
90
|
+
this.emit('session:created', { sessionName: this.sessionName });
|
|
91
|
+
return true;
|
|
92
|
+
} catch (err) {
|
|
93
|
+
throw new Error(`Failed to create tmux session: ${err.message}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Attach to the existing session
|
|
99
|
+
* @param {boolean} readonly - Attach in read-only mode
|
|
100
|
+
*/
|
|
101
|
+
attach(readonly = false) {
|
|
102
|
+
if (!this.sessionExists()) {
|
|
103
|
+
throw new Error(`Session "${this.sessionName}" does not exist. Use createSession() first.`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Use spawn to attach interactively
|
|
107
|
+
const proc = spawn('tmux', ['attach-session', '-t', this.sessionName, ...(readonly ? ['-r'] : [])], {
|
|
108
|
+
stdio: 'inherit',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
proc.on('exit', (code) => {
|
|
113
|
+
if (code === 0) {
|
|
114
|
+
resolve();
|
|
115
|
+
} else {
|
|
116
|
+
reject(new Error(`tmux attach exited with code ${code}`));
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
proc.on('error', (err) => {
|
|
121
|
+
reject(new Error(`Failed to attach to tmux: ${err.message}`));
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Send text to a specific pane
|
|
128
|
+
* @param {number} pane - Pane index (0 = chat, 1 = status)
|
|
129
|
+
* @param {string} text - Text to send
|
|
130
|
+
* @param {boolean} enter - Whether to send Enter after text
|
|
131
|
+
*/
|
|
132
|
+
sendToPane(pane, text, enter = true) {
|
|
133
|
+
if (!this.sessionExists()) {
|
|
134
|
+
throw new Error(`Session "${this.sessionName}" does not exist`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const target = `${this.sessionName}:0.${pane}`;
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
boundedExecFileSync(
|
|
141
|
+
'tmux', ['send-keys', '-t', target, '-l', '--', text],
|
|
142
|
+
'quick',
|
|
143
|
+
{ stdio: 'pipe' }
|
|
144
|
+
);
|
|
145
|
+
if (enter) boundedExecFileSync('tmux', ['send-keys', '-t', target, 'Enter'], 'quick', { stdio: 'pipe' });
|
|
146
|
+
} catch (err) {
|
|
147
|
+
throw new Error(`Failed to send to pane ${pane}: ${err.message}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Update the status pane content
|
|
153
|
+
* @param {string} content - Status text to display
|
|
154
|
+
*/
|
|
155
|
+
updateStatusPane(content) {
|
|
156
|
+
if (!this.sessionExists()) return;
|
|
157
|
+
|
|
158
|
+
const target = `${this.sessionName}:0.1`;
|
|
159
|
+
try {
|
|
160
|
+
// Clear pane and write new content
|
|
161
|
+
boundedExecFileSync('tmux', ['send-keys', '-t', target, 'C-c'], 'quick', { stdio: 'pipe' });
|
|
162
|
+
boundedExecFileSync('tmux', ['send-keys', '-t', target, 'C-l'], 'quick', { stdio: 'pipe' });
|
|
163
|
+
|
|
164
|
+
// Write each line
|
|
165
|
+
const lines = content.split('\n');
|
|
166
|
+
for (const line of lines) {
|
|
167
|
+
boundedExecFileSync(
|
|
168
|
+
'tmux', ['send-keys', '-t', target, '-l', '--', line],
|
|
169
|
+
'quick',
|
|
170
|
+
{ stdio: 'pipe' }
|
|
171
|
+
);
|
|
172
|
+
boundedExecFileSync('tmux', ['send-keys', '-t', target, 'Enter'], 'quick', { stdio: 'pipe' });
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
// Status update failure is non-critical
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Start auto-refreshing the status pane
|
|
181
|
+
* @param {function} statusFn - Function that returns status text
|
|
182
|
+
*/
|
|
183
|
+
startStatusRefresh(statusFn) {
|
|
184
|
+
this.stopStatusRefresh();
|
|
185
|
+
|
|
186
|
+
this.statusTimer = setInterval(() => {
|
|
187
|
+
try {
|
|
188
|
+
const content = statusFn();
|
|
189
|
+
this.updateStatusPane(content);
|
|
190
|
+
} catch {
|
|
191
|
+
// Non-critical
|
|
192
|
+
}
|
|
193
|
+
}, this.statusRefreshMs);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Stop auto-refreshing the status pane
|
|
198
|
+
*/
|
|
199
|
+
stopStatusRefresh() {
|
|
200
|
+
if (this.statusTimer) {
|
|
201
|
+
clearInterval(this.statusTimer);
|
|
202
|
+
this.statusTimer = null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Kill the tmux session
|
|
208
|
+
*/
|
|
209
|
+
killSession() {
|
|
210
|
+
this.stopStatusRefresh();
|
|
211
|
+
|
|
212
|
+
if (!this.sessionExists()) return;
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
boundedExecFileSync('tmux', ['kill-session', '-t', this.sessionName], 'quick', { stdio: 'pipe' });
|
|
216
|
+
this.emit('session:killed', { sessionName: this.sessionName });
|
|
217
|
+
} catch (err) {
|
|
218
|
+
throw new Error(`Failed to kill session: ${err.message}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* List all tmux sessions
|
|
224
|
+
*/
|
|
225
|
+
listSessions() {
|
|
226
|
+
try {
|
|
227
|
+
const output = boundedExecFileSync('tmux', ['list-sessions', '-F', '#{session_name}:#{session_windows}:#{session_attached}'], 'quick', {
|
|
228
|
+
stdio: 'pipe',
|
|
229
|
+
encoding: 'utf8',
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
return output
|
|
233
|
+
.trim()
|
|
234
|
+
.split('\n')
|
|
235
|
+
.filter(Boolean)
|
|
236
|
+
.map((line) => {
|
|
237
|
+
const [name, windows, attached] = line.split(':');
|
|
238
|
+
return { name, windows: parseInt(windows, 10), attached: attached === '1' };
|
|
239
|
+
});
|
|
240
|
+
} catch {
|
|
241
|
+
return [];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Get pane info for the session
|
|
247
|
+
*/
|
|
248
|
+
getPaneInfo() {
|
|
249
|
+
if (!this.sessionExists()) return null;
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
const output = boundedExecFileSync(
|
|
253
|
+
'tmux', ['list-panes', '-t', this.sessionName, '-F', '#{pane_index}:#{pane_width}x#{pane_height}:#{pane_active}'],
|
|
254
|
+
'quick',
|
|
255
|
+
{ stdio: 'pipe', encoding: 'utf8' }
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
return output
|
|
259
|
+
.trim()
|
|
260
|
+
.split('\n')
|
|
261
|
+
.filter(Boolean)
|
|
262
|
+
.map((line) => {
|
|
263
|
+
const [index, size, active] = line.split(':');
|
|
264
|
+
const [width, height] = size.split('x');
|
|
265
|
+
return {
|
|
266
|
+
index: parseInt(index, 10),
|
|
267
|
+
width: parseInt(width, 10),
|
|
268
|
+
height: parseInt(height, 10),
|
|
269
|
+
active: active === '1',
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
} catch {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Generate a status dashboard string
|
|
280
|
+
* @param {object} supervisor - AgentSupervisor instance
|
|
281
|
+
* @param {object} replChat - REPLChat instance
|
|
282
|
+
*/
|
|
283
|
+
export function formatStatusDashboard(supervisor, replChat) {
|
|
284
|
+
const lines = [];
|
|
285
|
+
const now = new Date().toISOString().slice(11, 19);
|
|
286
|
+
|
|
287
|
+
lines.push(`╔════════════════════════════════════════╗`);
|
|
288
|
+
lines.push(`║ AIWG Daemon Status ${now} ║`);
|
|
289
|
+
lines.push(`╠════════════════════════════════════════╣`);
|
|
290
|
+
|
|
291
|
+
if (supervisor) {
|
|
292
|
+
const status = supervisor.getStatus();
|
|
293
|
+
lines.push(`║ Agents: ${status.running} running / ${status.queued} queued `);
|
|
294
|
+
lines.push(`║ Max concurrent: ${status.maxConcurrency} `);
|
|
295
|
+
|
|
296
|
+
if (status.tasks.running.length > 0) {
|
|
297
|
+
lines.push(`╠────────────────────────────────────────╣`);
|
|
298
|
+
lines.push(`║ Running Tasks: `);
|
|
299
|
+
for (const t of status.tasks.running) {
|
|
300
|
+
const prompt = t.prompt.slice(0, 35).padEnd(35);
|
|
301
|
+
lines.push(`║ ${t.id}: ${prompt}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (status.tasks.queued.length > 0) {
|
|
306
|
+
lines.push(`╠────────────────────────────────────────╣`);
|
|
307
|
+
lines.push(`║ Queued Tasks: `);
|
|
308
|
+
for (const t of status.tasks.queued) {
|
|
309
|
+
const prompt = t.prompt.slice(0, 35).padEnd(35);
|
|
310
|
+
lines.push(`║ ${t.id}: ${prompt}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (replChat) {
|
|
316
|
+
lines.push(`╠────────────────────────────────────────╣`);
|
|
317
|
+
lines.push(`║ Chat: ${replChat.isProcessing ? 'Processing...' : 'Ready'} Queue: ${replChat.queueSize} `);
|
|
318
|
+
lines.push(`║ History: ${replChat.getHistory().length} messages `);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
lines.push(`╚════════════════════════════════════════╝`);
|
|
322
|
+
|
|
323
|
+
return lines.join('\n');
|
|
324
|
+
}
|