oc-pilot 0.114.11 → 0.115.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.
@@ -0,0 +1,232 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import test from "node:test";
7
+ import { activeFlight, appendFlightEvent, bisectFlight, createCheckpoint, diffFlight, endFlight, execInFlight, exportFlight, flightStatus, listFlights, readFlightEvents, replayFlight, showFlight, startFlight, verifyFlightEvents, } from "./flight.js";
8
+ function git(args, cwd) {
9
+ const result = spawnSync("git", args, { cwd, encoding: "utf8" });
10
+ assert.equal(result.status, 0, result.stderr);
11
+ return result.stdout.trim();
12
+ }
13
+ function makeRepo() {
14
+ const dir = mkdtempSync(join(tmpdir(), "oc-pilot-flight-"));
15
+ git(["init", "-q"], dir);
16
+ git(["config", "user.email", "test@example.com"], dir);
17
+ git(["config", "user.name", "Test"], dir);
18
+ git(["config", "core.autocrlf", "false"], dir);
19
+ writeFileSync(join(dir, "a.txt"), "one\n", "utf8");
20
+ git(["add", "a.txt"], dir);
21
+ git(["commit", "-qm", "init"], dir);
22
+ return dir;
23
+ }
24
+ test("startFlight creates a hash-chained session and active status", () => {
25
+ const dir = makeRepo();
26
+ try {
27
+ const session = startFlight(dir, "test flight");
28
+ assert.equal(session.meta.name, "test flight");
29
+ assert.equal(session.events.length, 1);
30
+ assert.equal(session.events[0]?.kind, "session.start");
31
+ assert.equal(session.events[0]?.prev, "genesis");
32
+ assert.match(session.events[0]?.hash ?? "", /^sha256:[0-9a-f]{64}$/);
33
+ assert.equal(verifyFlightEvents(session.events).valid, true);
34
+ const active = activeFlight(dir);
35
+ assert.equal(active?.meta.id, session.meta.id);
36
+ const status = flightStatus(dir);
37
+ assert.equal(status.active, true);
38
+ assert.equal(status.session?.meta.id, session.meta.id);
39
+ assert.equal(status.checkpoints, 0);
40
+ const flights = listFlights(dir);
41
+ assert.equal(flights.length, 1);
42
+ assert.equal(flights[0]?.id, session.meta.id);
43
+ assert.equal(flights[0]?.ended, false);
44
+ }
45
+ finally {
46
+ rmSync(dir, { recursive: true, force: true });
47
+ }
48
+ });
49
+ test("verifyFlightEvents detects a modified event", () => {
50
+ const dir = makeRepo();
51
+ try {
52
+ const session = startFlight(dir, "tamper");
53
+ appendFlightEvent(session.dir, "gate.result", { gate: "tests", status: "pass" });
54
+ const events = readFlightEvents(session.dir);
55
+ assert.equal(verifyFlightEvents(events).valid, true);
56
+ const tampered = structuredClone(events);
57
+ const target = tampered[1];
58
+ assert.ok(target);
59
+ target.payload.status = "fail";
60
+ const result = verifyFlightEvents(tampered);
61
+ assert.equal(result.valid, false);
62
+ assert.ok(result.errors.some((error) => error.includes("хеш")));
63
+ const file = join(session.dir, "events.jsonl");
64
+ writeFileSync(file, `${tampered.map((event) => JSON.stringify(event)).join("\n")}\n`, "utf8");
65
+ const shown = showFlight(dir, session.meta.id);
66
+ assert.equal(shown.verification.valid, false);
67
+ }
68
+ finally {
69
+ rmSync(dir, { recursive: true, force: true });
70
+ }
71
+ });
72
+ test("createCheckpoint creates a dangling commit without moving HEAD", () => {
73
+ const dir = makeRepo();
74
+ try {
75
+ const before = git(["rev-parse", "HEAD"], dir);
76
+ const session = startFlight(dir, "checkpoint");
77
+ writeFileSync(join(dir, "a.txt"), "two\n", "utf8");
78
+ writeFileSync(join(dir, "b.txt"), "untracked\n", "utf8");
79
+ const checkpoint = createCheckpoint(dir, "after edit");
80
+ assert.match(checkpoint.commit, /^[0-9a-f]{40}$/);
81
+ assert.match(checkpoint.tree, /^[0-9a-f]{40}$/);
82
+ assert.equal(git(["rev-parse", "HEAD"], dir), before);
83
+ assert.equal(git(["cat-file", "-t", checkpoint.commit], dir), "commit");
84
+ assert.equal(git(["show", `${checkpoint.commit}:a.txt`], dir), "two");
85
+ assert.equal(git(["show", `${checkpoint.commit}:b.txt`], dir), "untracked");
86
+ const events = readFlightEvents(session.dir);
87
+ const saved = events.find((event) => event.kind === "file.checkpoint");
88
+ assert.equal(saved?.payload.label, "after edit");
89
+ assert.equal(saved?.payload.commit, checkpoint.commit);
90
+ assert.equal(verifyFlightEvents(events).valid, true);
91
+ }
92
+ finally {
93
+ rmSync(dir, { recursive: true, force: true });
94
+ }
95
+ });
96
+ test("endFlight appends session.end and clears the active pointer", () => {
97
+ const dir = makeRepo();
98
+ try {
99
+ const session = startFlight(dir, "finish");
100
+ const result = endFlight(dir);
101
+ assert.equal(result.meta.id, session.meta.id);
102
+ assert.equal(result.events.at(-1)?.kind, "session.end");
103
+ assert.equal(result.summary.checkpoints, 0);
104
+ assert.equal(activeFlight(dir), undefined);
105
+ assert.equal(flightStatus(dir).active, false);
106
+ assert.equal(listFlights(dir)[0]?.ended, true);
107
+ }
108
+ finally {
109
+ rmSync(dir, { recursive: true, force: true });
110
+ }
111
+ });
112
+ test("execInFlight records command output and exit code", () => {
113
+ const dir = makeRepo();
114
+ try {
115
+ const session = startFlight(dir, "exec");
116
+ const result = execInFlight(dir, [process.execPath, "-e", "console.log('flight-ok')"], {
117
+ quiet: true,
118
+ });
119
+ assert.equal(result.exitCode, 0);
120
+ assert.match(result.stdoutTail, /flight-ok/);
121
+ const events = readFlightEvents(session.dir);
122
+ assert.equal(events.filter((event) => event.kind === "command.start").length, 1);
123
+ assert.equal(events.filter((event) => event.kind === "command.end").length, 1);
124
+ assert.equal(verifyFlightEvents(events).valid, true);
125
+ const failed = execInFlight(dir, [process.execPath, "-e", "process.exit(3)"], { quiet: true });
126
+ assert.equal(failed.exitCode, 3);
127
+ }
128
+ finally {
129
+ rmSync(dir, { recursive: true, force: true });
130
+ }
131
+ });
132
+ test("startFlight refuses a second active flight", () => {
133
+ const dir = makeRepo();
134
+ try {
135
+ startFlight(dir, "first");
136
+ assert.throws(() => startFlight(dir, "second"), /Уже идёт полёт/);
137
+ endFlight(dir);
138
+ const second = startFlight(dir, "second");
139
+ assert.equal(second.meta.name, "second");
140
+ }
141
+ finally {
142
+ rmSync(dir, { recursive: true, force: true });
143
+ }
144
+ });
145
+ test("readFlightEvents rejects malformed JSONL", () => {
146
+ const dir = makeRepo();
147
+ try {
148
+ const session = startFlight(dir, "broken");
149
+ writeFileSync(join(session.dir, "events.jsonl"), "{not json}\n", "utf8");
150
+ assert.throws(() => readFlightEvents(session.dir), /Повреждён журнал/);
151
+ }
152
+ finally {
153
+ rmSync(dir, { recursive: true, force: true });
154
+ }
155
+ });
156
+ test("replayFlight materializes a checkpoint in a shadow worktree", () => {
157
+ const dir = makeRepo();
158
+ try {
159
+ startFlight(dir, "replay");
160
+ writeFileSync(join(dir, "b.txt"), "two\n", "utf8");
161
+ const checkpoint = createCheckpoint(dir, "after-b");
162
+ const result = replayFlight(dir, undefined, "after-b");
163
+ try {
164
+ assert.equal(result.label, "after-b");
165
+ assert.equal(result.commit, checkpoint.commit);
166
+ assert.equal(readFileSync(join(result.path, "b.txt"), "utf8"), "two\n");
167
+ assert.equal(git(["rev-parse", "HEAD"], result.path), checkpoint.commit);
168
+ }
169
+ finally {
170
+ git(["worktree", "remove", "--force", result.path], dir);
171
+ }
172
+ }
173
+ finally {
174
+ rmSync(dir, { recursive: true, force: true });
175
+ }
176
+ });
177
+ test("diffFlight compares the base commit with a checkpoint", () => {
178
+ const dir = makeRepo();
179
+ try {
180
+ startFlight(dir, "diff");
181
+ writeFileSync(join(dir, "b.txt"), "two\n", "utf8");
182
+ createCheckpoint(dir, "after-b");
183
+ const result = diffFlight(dir);
184
+ assert.equal(result.from.label, "base");
185
+ assert.equal(result.to.label, "after-b");
186
+ assert.match(result.stat, /b\.txt/);
187
+ assert.match(result.patch, /\+two/);
188
+ }
189
+ finally {
190
+ rmSync(dir, { recursive: true, force: true });
191
+ }
192
+ });
193
+ test("bisectFlight finds the first failing checkpoint", () => {
194
+ const dir = makeRepo();
195
+ try {
196
+ startFlight(dir, "bisect");
197
+ writeFileSync(join(dir, "a.txt"), "good\n", "utf8");
198
+ createCheckpoint(dir, "good");
199
+ writeFileSync(join(dir, "a.txt"), "bad\n", "utf8");
200
+ createCheckpoint(dir, "bad");
201
+ writeFileSync(join(dir, "a.txt"), "bad\n", "utf8");
202
+ createCheckpoint(dir, "worse");
203
+ const script = "const fs=require('fs');process.exit(fs.readFileSync('a.txt','utf8').includes('bad')?1:0)";
204
+ const result = bisectFlight(dir, undefined, [process.execPath, "-e", script], 60_000);
205
+ assert.equal(result.steps.length, 2);
206
+ assert.equal(result.firstBad?.label, "bad");
207
+ assert.equal(result.firstBad?.exitCode, 1);
208
+ }
209
+ finally {
210
+ rmSync(dir, { recursive: true, force: true });
211
+ }
212
+ });
213
+ test("exportFlight redacts secrets and includes a digest", () => {
214
+ const dir = makeRepo();
215
+ try {
216
+ startFlight(dir, "export");
217
+ writeFileSync(join(dir, "secret.txt"), "token=abcdefgh12345\n", "utf8");
218
+ createCheckpoint(dir, "with-secret");
219
+ const result = exportFlight(dir);
220
+ assert.equal(result.format, "oc-pilot-flight-export/v1");
221
+ assert.equal(result.meta.id, activeFlight(dir)?.meta.id);
222
+ assert.equal(result.checkpoints.length, 1);
223
+ assert.match(result.digest, /^sha256:[0-9a-f]{64}$/);
224
+ assert.equal(JSON.stringify(result).includes("abcdefgh12345"), false);
225
+ assert.match(JSON.stringify(result), /\[REDACTED\]/);
226
+ assert.equal(result.verification.valid, true);
227
+ }
228
+ finally {
229
+ rmSync(dir, { recursive: true, force: true });
230
+ }
231
+ });
232
+ //# sourceMappingURL=flight.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flight.test.js","sourceRoot":"","sources":["../../src/core/flight.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA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AAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC,CAAC"}
package/dist/mcp.js CHANGED
@@ -1475,6 +1475,158 @@ const TOOLS = [
1475
1475
  },
1476
1476
  },
1477
1477
  },
1478
+ {
1479
+ name: "flight_start",
1480
+ description: "Start a black-box flight recorder for the current agent session. Writes a hash-chained event log and checkpoints under .git/oc-pilot/flights. Needs --allow-write.",
1481
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1482
+ inputSchema: {
1483
+ type: "object",
1484
+ additionalProperties: false,
1485
+ required: ["name"],
1486
+ properties: {
1487
+ name: { type: "string", description: "Human-readable session name" },
1488
+ ...RESULT_PROPERTIES,
1489
+ },
1490
+ },
1491
+ },
1492
+ {
1493
+ name: "flight_exec",
1494
+ description: "Run a command inside the active flight, record its output and exit code, and append command.start/command.end events. Needs --allow-write.",
1495
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1496
+ inputSchema: {
1497
+ type: "object",
1498
+ additionalProperties: false,
1499
+ required: ["command"],
1500
+ properties: {
1501
+ command: { type: "array", description: "Command argv, e.g. [\"npm\",\"test\"]", items: { type: "string" } },
1502
+ timeout: { type: "integer", minimum: 100, maximum: 600000 },
1503
+ ...RESULT_PROPERTIES,
1504
+ },
1505
+ },
1506
+ },
1507
+ {
1508
+ name: "flight_checkpoint",
1509
+ description: "Create a dangling git commit checkpoint of the current worktree and append it to the active flight journal. Needs --allow-write.",
1510
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1511
+ inputSchema: {
1512
+ type: "object",
1513
+ additionalProperties: false,
1514
+ properties: {
1515
+ label: { type: "string", description: "Optional checkpoint label" },
1516
+ ...RESULT_PROPERTIES,
1517
+ },
1518
+ },
1519
+ },
1520
+ {
1521
+ name: "flight_status",
1522
+ description: "Read the active flight status: session id, name, event count and checkpoints.",
1523
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1524
+ inputSchema: {
1525
+ type: "object",
1526
+ additionalProperties: false,
1527
+ properties: {
1528
+ ...RESULT_PROPERTIES,
1529
+ },
1530
+ },
1531
+ },
1532
+ {
1533
+ name: "flight_show",
1534
+ description: "Read a flight journal and verify its hash chain. Defaults to the active flight.",
1535
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1536
+ inputSchema: {
1537
+ type: "object",
1538
+ additionalProperties: false,
1539
+ properties: {
1540
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1541
+ ...RESULT_PROPERTIES,
1542
+ },
1543
+ },
1544
+ },
1545
+ {
1546
+ name: "flight_verify",
1547
+ description: "Verify the hash chain of a flight journal without rendering the full journal.",
1548
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1549
+ inputSchema: {
1550
+ type: "object",
1551
+ additionalProperties: false,
1552
+ properties: {
1553
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1554
+ ...RESULT_PROPERTIES,
1555
+ },
1556
+ },
1557
+ },
1558
+ {
1559
+ name: "flight_end",
1560
+ description: "Close the active flight, append session.end and clear the current pointer. The journal remains on disk. Needs --allow-write.",
1561
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1562
+ inputSchema: {
1563
+ type: "object",
1564
+ additionalProperties: false,
1565
+ properties: {
1566
+ ...RESULT_PROPERTIES,
1567
+ },
1568
+ },
1569
+ },
1570
+ {
1571
+ name: "flight_replay",
1572
+ description: "Materialize a flight checkpoint as a detached git worktree without touching the main worktree. Needs --allow-write.",
1573
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1574
+ inputSchema: {
1575
+ type: "object",
1576
+ additionalProperties: false,
1577
+ properties: {
1578
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1579
+ to: { type: "string", description: "Checkpoint label or commit; defaults to the latest checkpoint" },
1580
+ path: { type: "string", description: "Target worktree path; defaults to a temp directory" },
1581
+ ...RESULT_PROPERTIES,
1582
+ },
1583
+ },
1584
+ },
1585
+ {
1586
+ name: "flight_bisect",
1587
+ description: "Run a command at each flight checkpoint in order and report the first failing step. Needs --allow-write.",
1588
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1589
+ inputSchema: {
1590
+ type: "object",
1591
+ additionalProperties: false,
1592
+ required: ["command"],
1593
+ properties: {
1594
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1595
+ command: { type: "array", description: "Command argv, e.g. [\"npm\",\"test\"]", items: { type: "string" } },
1596
+ timeout: { type: "integer", minimum: 100, maximum: 600000 },
1597
+ ...RESULT_PROPERTIES,
1598
+ },
1599
+ },
1600
+ },
1601
+ {
1602
+ name: "flight_diff",
1603
+ description: "Compare the flight base commit or two checkpoints and return git diff stat and patch.",
1604
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1605
+ inputSchema: {
1606
+ type: "object",
1607
+ additionalProperties: false,
1608
+ properties: {
1609
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1610
+ from: { type: "string", description: "Checkpoint label or commit; defaults to the base commit" },
1611
+ to: { type: "string", description: "Checkpoint label or commit; defaults to the latest checkpoint" },
1612
+ ...RESULT_PROPERTIES,
1613
+ },
1614
+ },
1615
+ },
1616
+ {
1617
+ name: "flight_export",
1618
+ description: "Export a redacted flight bundle with journal, checkpoint patches and a sha256 digest. Needs --allow-write when output is set.",
1619
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
1620
+ inputSchema: {
1621
+ type: "object",
1622
+ additionalProperties: false,
1623
+ properties: {
1624
+ id: { type: "string", description: "Flight session id; defaults to the active flight" },
1625
+ output: { type: "string", description: "Optional bundle file path" },
1626
+ ...RESULT_PROPERTIES,
1627
+ },
1628
+ },
1629
+ },
1478
1630
  {
1479
1631
  name: "beacon",
1480
1632
  description: "Create, verify and render a signed verification beacon for HEAD: commit, tree, tool version, agent, model, checks, commands and digest. Supports HMAC and ssh-keygen signatures; verify detects tampering and unattributed manifests. Actions: stamp, verify, render, clear. stamp/clear write and need --allow-write.",
@@ -4191,6 +4343,94 @@ async function callChronos(input, cwd) {
4191
4343
  args.push("--fail-on-hotspot");
4192
4344
  return toToolResult(await runCli(args, cwd));
4193
4345
  }
4346
+ async function callFlightStart(input, cwd) {
4347
+ const name = stringArg(input, "name", true);
4348
+ return toToolResult(await runCli(["flight", "start", "--json", "--name", name], cwd));
4349
+ }
4350
+ async function callFlightExec(input, cwd) {
4351
+ const command = stringArrayArg(input, "command", true);
4352
+ const args = ["flight", "exec", "--json"];
4353
+ const timeout = integerArg(input, "timeout");
4354
+ if (timeout !== undefined)
4355
+ args.push("--timeout", String(timeout));
4356
+ args.push("--", ...command);
4357
+ return toToolResult(await runCli(args, cwd));
4358
+ }
4359
+ async function callFlightCheckpoint(input, cwd) {
4360
+ const args = ["flight", "checkpoint", "--json"];
4361
+ const label = stringArg(input, "label");
4362
+ if (label)
4363
+ args.push("--label", label);
4364
+ return toToolResult(await runCli(args, cwd));
4365
+ }
4366
+ async function callFlightStatus(_input, cwd) {
4367
+ return toToolResult(await runCli(["flight", "status", "--json"], cwd));
4368
+ }
4369
+ async function callFlightShow(input, cwd) {
4370
+ const args = ["flight", "show", "--json"];
4371
+ const id = stringArg(input, "id");
4372
+ if (id)
4373
+ args.push("--id", id);
4374
+ return toToolResult(await runCli(args, cwd));
4375
+ }
4376
+ async function callFlightVerify(input, cwd) {
4377
+ const args = ["flight", "verify", "--json"];
4378
+ const id = stringArg(input, "id");
4379
+ if (id)
4380
+ args.push("--id", id);
4381
+ return toToolResult(await runCli(args, cwd));
4382
+ }
4383
+ async function callFlightEnd(_input, cwd) {
4384
+ return toToolResult(await runCli(["flight", "end", "--json"], cwd));
4385
+ }
4386
+ async function callFlightReplay(input, cwd) {
4387
+ const args = ["flight", "replay", "--json"];
4388
+ const id = stringArg(input, "id");
4389
+ if (id)
4390
+ args.push("--id", id);
4391
+ const to = stringArg(input, "to");
4392
+ if (to)
4393
+ args.push("--to", to);
4394
+ const path = stringArg(input, "path");
4395
+ if (path)
4396
+ args.push("--path", path);
4397
+ return toToolResult(await runCli(args, cwd));
4398
+ }
4399
+ async function callFlightBisect(input, cwd) {
4400
+ const command = stringArrayArg(input, "command", true);
4401
+ const args = ["flight", "bisect", "--json"];
4402
+ const id = stringArg(input, "id");
4403
+ if (id)
4404
+ args.push("--id", id);
4405
+ const timeout = integerArg(input, "timeout");
4406
+ if (timeout !== undefined)
4407
+ args.push("--timeout", String(timeout));
4408
+ args.push("--", ...command);
4409
+ return toToolResult(await runCli(args, cwd));
4410
+ }
4411
+ async function callFlightDiff(input, cwd) {
4412
+ const args = ["flight", "diff", "--json"];
4413
+ const id = stringArg(input, "id");
4414
+ if (id)
4415
+ args.push("--id", id);
4416
+ const from = stringArg(input, "from");
4417
+ if (from)
4418
+ args.push("--from", from);
4419
+ const to = stringArg(input, "to");
4420
+ if (to)
4421
+ args.push("--to", to);
4422
+ return toToolResult(await runCli(args, cwd));
4423
+ }
4424
+ async function callFlightExport(input, cwd) {
4425
+ const args = ["flight", "export", "--json"];
4426
+ const id = stringArg(input, "id");
4427
+ if (id)
4428
+ args.push("--id", id);
4429
+ const output = stringArg(input, "output");
4430
+ if (output)
4431
+ args.push("--output", output);
4432
+ return toToolResult(await runCli(args, cwd));
4433
+ }
4194
4434
  async function callBeacon(input, cwd) {
4195
4435
  const action = stringArg(input, "action", true);
4196
4436
  const args = ["beacon", action, "--json"];
@@ -4582,6 +4822,10 @@ async function dispatchTool(name, input, cwd, readOnly) {
4582
4822
  if (name === "scan_injection" && booleanArg(input, "fix")) {
4583
4823
  throw new ToolInputError("scan_injection fix writes files and is disabled in read-only mode; start the MCP server with --allow-write");
4584
4824
  }
4825
+ if (name.startsWith("flight_") &&
4826
+ ["flight_start", "flight_exec", "flight_checkpoint", "flight_end", "flight_replay", "flight_bisect", "flight_export"].includes(name)) {
4827
+ throw new ToolInputError("flight write actions are disabled in read-only mode; start the MCP server with --allow-write");
4828
+ }
4585
4829
  }
4586
4830
  switch (name) {
4587
4831
  case "review":
@@ -4710,6 +4954,28 @@ async function dispatchTool(name, input, cwd, readOnly) {
4710
4954
  return callCuckoo(input, cwd);
4711
4955
  case "chronos":
4712
4956
  return callChronos(input, cwd);
4957
+ case "flight_start":
4958
+ return callFlightStart(input, cwd);
4959
+ case "flight_exec":
4960
+ return callFlightExec(input, cwd);
4961
+ case "flight_checkpoint":
4962
+ return callFlightCheckpoint(input, cwd);
4963
+ case "flight_status":
4964
+ return callFlightStatus(input, cwd);
4965
+ case "flight_show":
4966
+ return callFlightShow(input, cwd);
4967
+ case "flight_verify":
4968
+ return callFlightVerify(input, cwd);
4969
+ case "flight_end":
4970
+ return callFlightEnd(input, cwd);
4971
+ case "flight_replay":
4972
+ return callFlightReplay(input, cwd);
4973
+ case "flight_bisect":
4974
+ return callFlightBisect(input, cwd);
4975
+ case "flight_diff":
4976
+ return callFlightDiff(input, cwd);
4977
+ case "flight_export":
4978
+ return callFlightExport(input, cwd);
4713
4979
  case "beacon":
4714
4980
  return callBeacon(input, cwd);
4715
4981
  case "quarantine":
@@ -4831,6 +5097,53 @@ function summarizeResult(value) {
4831
5097
  if (typeof value.score === "number" && typeof value.hotspot === "boolean" && value.totals && typeof value.totals === "object") {
4832
5098
  return `oc-pilot: chronos ${String(value.score)}, ${value.hotspot ? "hotspot" : "stable"}`;
4833
5099
  }
5100
+ if (typeof value.id === "string" && typeof value.label === "string" && typeof value.commit === "string" && typeof value.path === "string") {
5101
+ return `oc-pilot: flight replay ${value.id} ${value.label}`;
5102
+ }
5103
+ if (typeof value.id === "string" && Array.isArray(value.command) && Array.isArray(value.steps)) {
5104
+ const first = value.firstBad && typeof value.firstBad === "object"
5105
+ ? value.firstBad.label
5106
+ : undefined;
5107
+ return `oc-pilot: flight bisect ${String(value.steps.length)} step(s)${typeof first === "string" ? `, first bad ${first}` : ", all passed"}`;
5108
+ }
5109
+ if (typeof value.id === "string" && value.from && typeof value.from === "object" && value.to && typeof value.to === "object" && typeof value.stat === "string") {
5110
+ const from = value.from;
5111
+ const to = value.to;
5112
+ return `oc-pilot: flight diff ${typeof from.label === "string" ? from.label : "?"}..${typeof to.label === "string" ? to.label : "?"}`;
5113
+ }
5114
+ if (typeof value.format === "string" && value.format.startsWith("oc-pilot-flight-export/") && typeof value.digest === "string") {
5115
+ const checkpoints = Array.isArray(value.checkpoints) ? value.checkpoints.length : 0;
5116
+ return `oc-pilot: flight export ${String(checkpoints)} checkpoint(s), ${value.digest.slice(0, 15)}`;
5117
+ }
5118
+ if (typeof value.active === "boolean") {
5119
+ if (value.session && typeof value.session === "object") {
5120
+ const session = value.session;
5121
+ const id = typeof session.meta?.id === "string" ? session.meta.id : "unknown";
5122
+ return `oc-pilot: flight active ${id}`;
5123
+ }
5124
+ return "oc-pilot: flight inactive";
5125
+ }
5126
+ if (Array.isArray(value.flights)) {
5127
+ return `oc-pilot: flight ${String(value.flights.length)} session(s)`;
5128
+ }
5129
+ if (typeof value.label === "string" && typeof value.commit === "string" && typeof value.tree === "string") {
5130
+ return `oc-pilot: flight checkpoint ${value.label} ${value.commit.slice(0, 8)}`;
5131
+ }
5132
+ if (Array.isArray(value.command) && typeof value.exitCode === "number" && typeof value.timedOut === "boolean") {
5133
+ return `oc-pilot: flight exec exit ${String(value.exitCode)}${value.timedOut ? ", timeout" : ""}`;
5134
+ }
5135
+ if (typeof value.id === "string" && typeof value.valid === "boolean" && Array.isArray(value.errors)) {
5136
+ return `oc-pilot: flight ${value.id} ${value.valid ? "valid" : "tampered"}`;
5137
+ }
5138
+ if (value.meta && typeof value.meta === "object" && Array.isArray(value.events) && value.verification) {
5139
+ const meta = value.meta;
5140
+ const verification = value.verification;
5141
+ const id = typeof meta.id === "string" ? meta.id : "unknown";
5142
+ return `oc-pilot: flight ${id}, ${String(value.events.length)} event(s), ${verification.valid === true ? "valid" : "tampered"}`;
5143
+ }
5144
+ if (value.meta && typeof value.meta === "object" && value.summary && typeof value.summary === "object") {
5145
+ return "oc-pilot: flight ended";
5146
+ }
4834
5147
  if (typeof value.status === "string" && Array.isArray(value.capabilities) && typeof value.file === "string") {
4835
5148
  return `oc-pilot: cuckoo ${value.status}, ${String(value.capabilities.length)} capability(ies)`;
4836
5149
  }