Feed panes in the multiplexer (vpane_* control commands, main-vertical layout, header row), src/orch (board, panel, formatter, transport, CAP adapter), Agent observer and cancel flag, supervision (idle warn/cancel, user close cancels, soft then hard stop), CAP answers collected through the spill path. Research archived under background-work-limits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
48 lines
2.0 KiB
C++
48 lines
2.0 KiB
C++
// Driver for tests/orch_mplex_e2e.py: opens N panels on the multiplexer named by TAI_PLEXER_* and
|
|
// streams scripted events through the real OrchBoard and OrchMplexTransport.
|
|
// orch_live N TOKENS HOLD_MS [fail] prints "id label" per panel, finishes them, flushes.
|
|
#include <chrono>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
#include "orch_board.h"
|
|
|
|
using namespace detz::orch;
|
|
|
|
int main(int argc, char** argv) {
|
|
int n = argc > 1 ? std::atoi(argv[1]) : 1;
|
|
int tokens = argc > 2 ? std::atoi(argv[2]) : 50;
|
|
int hold_ms = argc > 3 ? std::atoi(argv[3]) : 0;
|
|
bool fail_last = argc > 4;
|
|
OrchBoard& board = OrchBoard::instance();
|
|
std::vector<std::shared_ptr<OrchPanel>> panels;
|
|
for (int i = 0; i < n; ++i) {
|
|
auto p = board.open("agent #" + std::to_string(i + 1), "scripted task number " + std::to_string(i + 1));
|
|
std::printf("%d %s %s\n", p->remote_id(), p->label().c_str(), p->shown() ? "shown" : board.last_error().c_str());
|
|
panels.push_back(p);
|
|
}
|
|
std::fflush(stdout);
|
|
std::vector<std::thread> workers;
|
|
for (int i = 0; i < n; ++i) {
|
|
workers.emplace_back([&, i] {
|
|
auto& p = panels[static_cast<size_t>(i)];
|
|
p->emit(OrchEvent::tool_start("shell", "{\"command\":\"echo " + std::to_string(i) + "\"}"));
|
|
p->emit(OrchEvent::tool_end("shell", "line one\nline two\nline three\nline four", false, 12));
|
|
for (int t = 0; t < tokens; ++t) {
|
|
p->emit(OrchEvent::text_of("word" + std::to_string(i) + "_" + std::to_string(t) + " "));
|
|
p->emit(OrchEvent::usage_of(t * 10));
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
}
|
|
p->emit(OrchEvent::text_of("\nTHE END " + std::to_string(i) + "\n"));
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(hold_ms));
|
|
bool bad = fail_last && i == n - 1;
|
|
p->finish(bad ? OrchPanel::State::Failed : OrchPanel::State::Done, bad ? "scripted failure" : "all good");
|
|
});
|
|
}
|
|
for (auto& w : workers) w.join();
|
|
board.flush(3.0);
|
|
return 0;
|
|
}
|