@tablation/crew 0.157.1 → 0.158.2
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/dist/cli.js +402 -85
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6769,6 +6769,15 @@ function agentLogRefusedItem(route2, role, status2, request2, nowIso = (/* @__PU
|
|
|
6769
6769
|
message: `${route2}: the tracker refused ${what} (${status2}) for the ${role} seat \u2014 runs and ticket spend are not being recorded; update crew if a newer version exists, otherwise report this`
|
|
6770
6770
|
};
|
|
6771
6771
|
}
|
|
6772
|
+
var listTruncatedKey = (route2, what) => `list_truncated:${route2}:${what}`;
|
|
6773
|
+
function listTruncatedItem(route2, what, limit, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6774
|
+
return {
|
|
6775
|
+
kind: "list_truncated",
|
|
6776
|
+
key: listTruncatedKey(route2, what),
|
|
6777
|
+
since: nowIso,
|
|
6778
|
+
message: `${route2}: the ${what} list came back full at ${limit} rows and may be missing more \u2014 decisions made from it can skip tickets; report this`
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6772
6781
|
var workspaceAuthKey = (role) => `workspace_auth:${role}`;
|
|
6773
6782
|
var workspaceAllowanceKey = (role) => `workspace_allowance:${role}`;
|
|
6774
6783
|
function workspaceAllowanceItem(route2, role, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
@@ -7148,7 +7157,7 @@ function visibleAttention(items, dockerFindingPresent) {
|
|
|
7148
7157
|
function attentionProblems(items, already) {
|
|
7149
7158
|
const seen = new Set(already.filter((p) => p.kind === "hook_missing").map((p) => `hook_missing:${p.route}/${p.repo}/${p.hook}`));
|
|
7150
7159
|
if (already.some((p) => p.kind === "docker_daemon_down")) seen.add(DOCKER_DAEMON_KEY);
|
|
7151
|
-
return items.filter((i) => !seen.has(i.key)).map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
|
|
7160
|
+
return items.filter((i) => !seen.has(i.key) && i.kind !== "seat_missing").map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
|
|
7152
7161
|
}
|
|
7153
7162
|
var NO_PROJECTS_REMEDY = "run `crew projects add NAME --prefix PREFIX` (or add a row to the Projects table)";
|
|
7154
7163
|
function noProjectsFinding(route2, projectCount) {
|
|
@@ -9229,7 +9238,7 @@ import { basename as basename7 } from "path";
|
|
|
9229
9238
|
|
|
9230
9239
|
// src/tracker.ts
|
|
9231
9240
|
import { hostname } from "os";
|
|
9232
|
-
import { TablationClient } from "@tablation/client";
|
|
9241
|
+
import { TablationApiError, TablationClient } from "@tablation/client";
|
|
9233
9242
|
|
|
9234
9243
|
// src/work-mode.ts
|
|
9235
9244
|
function projectWorkModes(rows, contract) {
|
|
@@ -9260,16 +9269,6 @@ function isAutomatic(t, wm) {
|
|
|
9260
9269
|
if (!wm || wm.modes.size === 0) return true;
|
|
9261
9270
|
return modeOf(t, wm) === "automatic";
|
|
9262
9271
|
}
|
|
9263
|
-
function skippedByMode(tickets, wm) {
|
|
9264
|
-
const out = { manual: 0, hybrid: 0 };
|
|
9265
|
-
if (!wm || wm.modes.size === 0) return out;
|
|
9266
|
-
const kept = new Set(withinWorkMode(tickets, wm));
|
|
9267
|
-
for (const t of tickets) {
|
|
9268
|
-
if (kept.has(t)) continue;
|
|
9269
|
-
out[modeOf(t, wm) === "manual" ? "manual" : "hybrid"]++;
|
|
9270
|
-
}
|
|
9271
|
-
return out;
|
|
9272
|
-
}
|
|
9273
9272
|
function withoutManualVerified(tickets, verifiedStatus, wm) {
|
|
9274
9273
|
if (!wm || wm.modes.size === 0) return tickets;
|
|
9275
9274
|
return tickets.filter((t) => t.status !== verifiedStatus || modeOf(t, wm) !== "manual");
|
|
@@ -9387,7 +9386,42 @@ function referenceKeys(t) {
|
|
|
9387
9386
|
}
|
|
9388
9387
|
var RESOLVED_STATUSES = new Set(DEFAULT_CONTRACT.statuses.resolved);
|
|
9389
9388
|
var encodeFilters = (f) => JSON.stringify(f);
|
|
9390
|
-
var
|
|
9389
|
+
var encodeSort = (s) => JSON.stringify(s);
|
|
9390
|
+
var LIST_PAGE_SIZE = 500;
|
|
9391
|
+
var LIST_MAX_PAGES = 200;
|
|
9392
|
+
var LIST_SORT = encodeSort([{ columnName: "id", direction: "asc" }]);
|
|
9393
|
+
function actionableStatuses(c) {
|
|
9394
|
+
const s = c.statuses;
|
|
9395
|
+
const named = [s.approved, s.parked, s.building, s.handoff, s.verifying, s.verified, s.needsHuman, ...s.reviewing ? [s.reviewing] : []];
|
|
9396
|
+
return [...new Set(named.filter((x) => c.statuses.open.includes(x)))];
|
|
9397
|
+
}
|
|
9398
|
+
function scopedTicketQueries(c, scope) {
|
|
9399
|
+
const status2 = c.columns.status;
|
|
9400
|
+
const project = c.columns.slice;
|
|
9401
|
+
const assignee = c.columns.assignee;
|
|
9402
|
+
const manual = [...scope.modes].filter(([, m]) => m === "manual").map(([id]) => id);
|
|
9403
|
+
const hybrid = [...scope.modes].filter(([, m]) => m === "hybrid").map(([id]) => id);
|
|
9404
|
+
const actionable = actionableStatuses(c);
|
|
9405
|
+
const pre = c.statuses.open.filter((x) => !actionable.includes(x));
|
|
9406
|
+
const automatic = [{ columnName: project, operator: "IS_NOT_NULL" }];
|
|
9407
|
+
if (manual.length + hybrid.length > 0) automatic.push({ columnName: project, operator: "NOT_IN", value: [...manual, ...hybrid] });
|
|
9408
|
+
const out = [[...automatic, { columnName: status2, operator: "IN", value: actionable }]];
|
|
9409
|
+
if (scope.triageSeat && pre.length > 0) {
|
|
9410
|
+
out.push([...automatic, { columnName: status2, operator: "IN", value: pre }, { columnName: assignee, operator: "EQ", value: scope.triageSeat }]);
|
|
9411
|
+
}
|
|
9412
|
+
if (hybrid.length > 0) {
|
|
9413
|
+
if (scope.agentAssignees.size > 0) {
|
|
9414
|
+
out.push([
|
|
9415
|
+
{ columnName: project, operator: "IN", value: hybrid },
|
|
9416
|
+
{ columnName: status2, operator: "IN", value: actionable },
|
|
9417
|
+
{ columnName: assignee, operator: "IN", value: [...scope.agentAssignees] }
|
|
9418
|
+
]);
|
|
9419
|
+
}
|
|
9420
|
+
out.push([{ columnName: project, operator: "IN", value: hybrid }, { columnName: status2, operator: "EQ", value: c.statuses.verified }]);
|
|
9421
|
+
}
|
|
9422
|
+
return out;
|
|
9423
|
+
}
|
|
9424
|
+
var Tracker = class _Tracker {
|
|
9391
9425
|
// NB: explicit fields, not TypeScript parameter properties — node's
|
|
9392
9426
|
// --experimental-strip-types cannot transform those, and the test runner
|
|
9393
9427
|
// uses it. The same rule applies everywhere in src/.
|
|
@@ -9433,25 +9467,83 @@ var Tracker = class {
|
|
|
9433
9467
|
});
|
|
9434
9468
|
}
|
|
9435
9469
|
/**
|
|
9436
|
-
* Every non-terminal ticket for this route's area,
|
|
9470
|
+
* Every non-terminal ticket for this route's area, paged to the end
|
|
9471
|
+
* (CREW-3453: one `limit: 500` request silently dropped everything past the
|
|
9472
|
+
* newest 500 once a bulk import filled the board with `new` tickets).
|
|
9437
9473
|
*
|
|
9438
9474
|
* The area filter is what keeps two routes on one tracker out of each
|
|
9439
9475
|
* other's queue: a ship working `synthesis` and `tablation-js` from the same
|
|
9440
9476
|
* Issues project must not have either seat pick up the other's tickets. A
|
|
9441
9477
|
* route with no area sees everything, which is right for a tracker
|
|
9442
9478
|
* nobody has sliced yet.
|
|
9479
|
+
*
|
|
9480
|
+
* With a `scope` (the poll's), only what a lane can act on is asked for; see
|
|
9481
|
+
* `TicketScope`. Without one, every open ticket comes back, which is what the
|
|
9482
|
+
* operator-facing views (`status`, `inbox`, `doctor`) want.
|
|
9443
9483
|
*/
|
|
9444
|
-
async openTickets() {
|
|
9484
|
+
async openTickets(scope) {
|
|
9445
9485
|
const c = this.contract;
|
|
9446
|
-
const
|
|
9447
|
-
{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }
|
|
9448
|
-
];
|
|
9486
|
+
const base = [];
|
|
9449
9487
|
const areaId = this.route.resolved?.areaId;
|
|
9450
|
-
if (areaId)
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9488
|
+
if (areaId) base.push({ columnName: c.columns.slice, operator: "EQ", value: areaId });
|
|
9489
|
+
const queries = scope && scope.modes.size > 0 ? scopedTicketQueries(c, scope) : [[{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }]];
|
|
9490
|
+
const seen = /* @__PURE__ */ new Map();
|
|
9491
|
+
for (const q2 of queries) {
|
|
9492
|
+
for (const t of await this.listAll(this.models.issues, "open tickets", encodeFilters([...base, ...q2]))) seen.set(t.id, t);
|
|
9493
|
+
}
|
|
9494
|
+
return [...seen.values()];
|
|
9495
|
+
}
|
|
9496
|
+
/**
|
|
9497
|
+
* How many open tickets match `extra` (a `crew status` number or the sweep
|
|
9498
|
+
* summary's skipped-by-mode count), from the count endpoint rather than
|
|
9499
|
+
* downloaded rows. `undefined` when the count cannot be read.
|
|
9500
|
+
*/
|
|
9501
|
+
async countOpenTickets(extra) {
|
|
9502
|
+
const c = this.contract;
|
|
9503
|
+
const conds = [{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }, ...extra];
|
|
9504
|
+
const areaId = this.route.resolved?.areaId;
|
|
9505
|
+
if (areaId) conds.push({ columnName: c.columns.slice, operator: "EQ", value: areaId });
|
|
9506
|
+
try {
|
|
9507
|
+
const res = await this.eventsFetch("GET", `/records/count?filters=${encodeURIComponent(encodeFilters(conds))}`);
|
|
9508
|
+
if (!res.ok) return void 0;
|
|
9509
|
+
const body = await res.json();
|
|
9510
|
+
return typeof body.count === "number" ? body.count : void 0;
|
|
9511
|
+
} catch {
|
|
9512
|
+
return void 0;
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
/**
|
|
9516
|
+
* Lists the tracker has handed back full and this process had no way to
|
|
9517
|
+
* read past, by what they were (CREW-3453). A decision made from a cut-off
|
|
9518
|
+
* list is wrong without saying so, so every reader that can be cut off calls
|
|
9519
|
+
* `noteTruncated`, and the poll turns what is here into an attention item.
|
|
9520
|
+
*/
|
|
9521
|
+
truncated = /* @__PURE__ */ new Map();
|
|
9522
|
+
/** The page backstop `listAll` stops at; a variable only so a test can reach it without a hundred thousand rows. */
|
|
9523
|
+
static maxPages = LIST_MAX_PAGES;
|
|
9524
|
+
/** Records that the list `what` hit `limit` rows and may be missing more. */
|
|
9525
|
+
noteTruncated(what, limit) {
|
|
9526
|
+
this.truncated.set(what, limit);
|
|
9527
|
+
}
|
|
9528
|
+
/**
|
|
9529
|
+
* Every row of `model` matching `filters`, paged until a short page. Sorted by
|
|
9530
|
+
* `id` so the offset windows neither skip nor repeat a row while the table
|
|
9531
|
+
* changes under the read.
|
|
9532
|
+
*/
|
|
9533
|
+
async listAll(model, what, filters) {
|
|
9534
|
+
const out = [];
|
|
9535
|
+
for (let page = 0; page < _Tracker.maxPages; page++) {
|
|
9536
|
+
const rows = await this.client.records.list(model, {
|
|
9537
|
+
...filters ? { filters } : {},
|
|
9538
|
+
limit: LIST_PAGE_SIZE,
|
|
9539
|
+
offset: page * LIST_PAGE_SIZE,
|
|
9540
|
+
sort: LIST_SORT
|
|
9541
|
+
});
|
|
9542
|
+
out.push(...rows);
|
|
9543
|
+
if (rows.length < LIST_PAGE_SIZE) return out;
|
|
9544
|
+
}
|
|
9545
|
+
this.noteTruncated(what, LIST_PAGE_SIZE * _Tracker.maxPages);
|
|
9546
|
+
return out;
|
|
9455
9547
|
}
|
|
9456
9548
|
/**
|
|
9457
9549
|
* Tickets at the hand-off status whose row changed at or after `since`,
|
|
@@ -9459,10 +9551,11 @@ var Tracker = class {
|
|
|
9459
9551
|
*/
|
|
9460
9552
|
async handedOffSince(since2, exceptId) {
|
|
9461
9553
|
const c = this.contract;
|
|
9462
|
-
const rows = await this.
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9554
|
+
const rows = await this.listAll(
|
|
9555
|
+
this.models.issues,
|
|
9556
|
+
"handed-off tickets",
|
|
9557
|
+
encodeFilters([{ columnName: c.columns.status, operator: "EQ", value: c.statuses.handoff }])
|
|
9558
|
+
);
|
|
9466
9559
|
const from = Date.parse(since2);
|
|
9467
9560
|
return rows.filter((t) => t.id !== exceptId && Date.parse(t.updated_at) >= from);
|
|
9468
9561
|
}
|
|
@@ -9508,28 +9601,58 @@ var Tracker = class {
|
|
|
9508
9601
|
* from the open set. Bounded to the ids actually referenced.
|
|
9509
9602
|
*/
|
|
9510
9603
|
async ticketsByIds(ids) {
|
|
9511
|
-
|
|
9512
|
-
return this.client.records.list(this.models.issues, {
|
|
9513
|
-
filters: encodeFilters([{ columnName: "id", operator: "IN", value: ids }]),
|
|
9514
|
-
limit: 500
|
|
9515
|
-
});
|
|
9604
|
+
return this.ticketsByIn("id", ids);
|
|
9516
9605
|
}
|
|
9517
9606
|
/** Tickets by `issue_id` (CREW-3323: resolving a run's key to its display tag). */
|
|
9518
9607
|
async ticketsByKeys(keys) {
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9608
|
+
return this.ticketsByIn(this.contract.columns.key, keys);
|
|
9609
|
+
}
|
|
9610
|
+
/** IN lists go in the URL, so each request carries at most 100 values; every request is paged. */
|
|
9611
|
+
async ticketsByIn(column, values) {
|
|
9612
|
+
const out = [];
|
|
9613
|
+
for (let i = 0; i < values.length; i += 100) {
|
|
9614
|
+
out.push(...await this.listAll(
|
|
9615
|
+
this.models.issues,
|
|
9616
|
+
"tickets by lookup",
|
|
9617
|
+
encodeFilters([{ columnName: column, operator: "IN", value: values.slice(i, i + 100) }])
|
|
9618
|
+
));
|
|
9619
|
+
}
|
|
9620
|
+
return out;
|
|
9524
9621
|
}
|
|
9525
9622
|
async ticket(id) {
|
|
9526
9623
|
return this.client.records.get(this.models.issues, id);
|
|
9527
9624
|
}
|
|
9625
|
+
/**
|
|
9626
|
+
* Every comment on the given tickets, paged (CREW-3453). The poll feeds hold
|
|
9627
|
+
* answers, the new-comment signal and the digest from this, so a fixed window
|
|
9628
|
+
* of the newest rows would drop an older ticket's answer once the board's
|
|
9629
|
+
* comments outgrow it. IN lists carry at most 100 ids per request.
|
|
9630
|
+
*/
|
|
9631
|
+
async commentsForTickets(ticketIds) {
|
|
9632
|
+
const out = [];
|
|
9633
|
+
for (let i = 0; i < ticketIds.length; i += 100) {
|
|
9634
|
+
out.push(...await this.listAll(
|
|
9635
|
+
this.models.comments,
|
|
9636
|
+
"comments",
|
|
9637
|
+
encodeFilters([{ columnName: this.contract.comments.parent, operator: "IN", value: ticketIds.slice(i, i + 100) }])
|
|
9638
|
+
));
|
|
9639
|
+
}
|
|
9640
|
+
return out;
|
|
9641
|
+
}
|
|
9528
9642
|
async comments(limit = 500) {
|
|
9529
9643
|
return this.client.records.list(this.models.comments, { limit });
|
|
9530
9644
|
}
|
|
9645
|
+
/** One Crew row, or null when the tracker answers 404 (CREW-3449). Any other failure throws. */
|
|
9646
|
+
async crewRow(id) {
|
|
9647
|
+
try {
|
|
9648
|
+
return await this.client.records.get(this.models.crew, id);
|
|
9649
|
+
} catch (e) {
|
|
9650
|
+
if (e instanceof TablationApiError && e.status === 404) return null;
|
|
9651
|
+
throw e;
|
|
9652
|
+
}
|
|
9653
|
+
}
|
|
9531
9654
|
async crewRows() {
|
|
9532
|
-
return this.
|
|
9655
|
+
return this.listAll(this.models.crew, "Crew rows");
|
|
9533
9656
|
}
|
|
9534
9657
|
/**
|
|
9535
9658
|
* One row of the `Repos` table, for whatever it can tell the crew that
|
|
@@ -9569,7 +9692,7 @@ var Tracker = class {
|
|
|
9569
9692
|
const model = this.route.resolved?.areaModelId;
|
|
9570
9693
|
if (!model) return /* @__PURE__ */ new Map();
|
|
9571
9694
|
try {
|
|
9572
|
-
const rows = await this.
|
|
9695
|
+
const rows = await this.listAll(model, "Projects");
|
|
9573
9696
|
return projectWorkModes(rows, this.contract);
|
|
9574
9697
|
} catch {
|
|
9575
9698
|
return /* @__PURE__ */ new Map();
|
|
@@ -9579,7 +9702,7 @@ var Tracker = class {
|
|
|
9579
9702
|
async projectRows() {
|
|
9580
9703
|
const model = this.route.resolved?.areaModelId;
|
|
9581
9704
|
if (!model) return [];
|
|
9582
|
-
return this.
|
|
9705
|
+
return this.listAll(model, "Projects");
|
|
9583
9706
|
}
|
|
9584
9707
|
/** Create a `Projects` (area) row (CREW-3359). Throws when the workspace has no Projects table. */
|
|
9585
9708
|
async createProjectRow(fields) {
|
|
@@ -9610,13 +9733,13 @@ var Tracker = class {
|
|
|
9610
9733
|
async repoRows() {
|
|
9611
9734
|
const model = this.route.resolved?.reposModelId;
|
|
9612
9735
|
if (!model) return [];
|
|
9613
|
-
return this.
|
|
9736
|
+
return this.listAll(model, "Repos");
|
|
9614
9737
|
}
|
|
9615
9738
|
/** Every `Repos` row with the columns the resolved file mirrors (CREW-2885). */
|
|
9616
9739
|
async repoRowsForMap() {
|
|
9617
9740
|
const model = this.route.resolved?.reposModelId;
|
|
9618
9741
|
if (!model) return [];
|
|
9619
|
-
return this.
|
|
9742
|
+
return this.listAll(model, "Repos");
|
|
9620
9743
|
}
|
|
9621
9744
|
/** Delete a `Repos` row (`crew sample-ticket --remove`). */
|
|
9622
9745
|
async deleteRepoRow(id) {
|
|
@@ -9626,10 +9749,11 @@ var Tracker = class {
|
|
|
9626
9749
|
}
|
|
9627
9750
|
/** Every ticket filed against one `Repos` row, any status. */
|
|
9628
9751
|
async ticketsForRepo(repoId) {
|
|
9629
|
-
return this.
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9752
|
+
return this.listAll(
|
|
9753
|
+
this.models.issues,
|
|
9754
|
+
"tickets of a repo",
|
|
9755
|
+
encodeFilters([{ columnName: this.contract.columns.repo, operator: "EQ", value: repoId }])
|
|
9756
|
+
);
|
|
9633
9757
|
}
|
|
9634
9758
|
/**
|
|
9635
9759
|
* The Ships rows of this workspace, if it has a Ships table.
|
|
@@ -9641,7 +9765,7 @@ var Tracker = class {
|
|
|
9641
9765
|
const model = this.route.resolved?.shipsModelId;
|
|
9642
9766
|
if (!model) return [];
|
|
9643
9767
|
try {
|
|
9644
|
-
return await this.
|
|
9768
|
+
return await this.listAll(model, "Ships");
|
|
9645
9769
|
} catch {
|
|
9646
9770
|
return [];
|
|
9647
9771
|
}
|
|
@@ -9831,7 +9955,7 @@ var Tracker = class {
|
|
|
9831
9955
|
const model = this.route.resolved?.epicsModelId;
|
|
9832
9956
|
if (!model) return [];
|
|
9833
9957
|
try {
|
|
9834
|
-
return await this.
|
|
9958
|
+
return await this.listAll(model, "Epics");
|
|
9835
9959
|
} catch {
|
|
9836
9960
|
return [];
|
|
9837
9961
|
}
|
|
@@ -12866,7 +12990,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
|
12866
12990
|
import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
|
|
12867
12991
|
import { join as join32 } from "path";
|
|
12868
12992
|
import { parse as parseYaml2 } from "yaml";
|
|
12869
|
-
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as
|
|
12993
|
+
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError3 } from "@tablation/client";
|
|
12870
12994
|
|
|
12871
12995
|
// src/prompt-additions.ts
|
|
12872
12996
|
var PROMPT_ADDITIONS_SEPARATOR = "---\n\nAdditional instructions from this workspace. Where they conflict with anything above, these take precedence.";
|
|
@@ -12898,7 +13022,7 @@ function readPersonaFile(path) {
|
|
|
12898
13022
|
// src/agents.ts
|
|
12899
13023
|
import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
|
|
12900
13024
|
import { join as join31 } from "path";
|
|
12901
|
-
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
13025
|
+
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
12902
13026
|
var PERSONA_NAME = {
|
|
12903
13027
|
dev: "Developer",
|
|
12904
13028
|
design: "Design",
|
|
@@ -13050,7 +13174,7 @@ async function fetchKeyRole(route2, userAgent) {
|
|
|
13050
13174
|
}
|
|
13051
13175
|
}
|
|
13052
13176
|
function isForbidden(e) {
|
|
13053
|
-
return e instanceof
|
|
13177
|
+
return e instanceof TablationApiError2 && e.status === 403;
|
|
13054
13178
|
}
|
|
13055
13179
|
function promptSourceFields(model, prompt) {
|
|
13056
13180
|
return model.fields?.some((f) => f.columnName === "prompt_baseline") ? { prompt_source: "crew", prompt_baseline: prompt } : {};
|
|
@@ -13062,7 +13186,7 @@ function needsBaselineBackfill(model, row) {
|
|
|
13062
13186
|
return hasPromptBaselineColumn(model) && row.prompt_customized !== true && (typeof row.prompt_baseline !== "string" || !row.prompt_source);
|
|
13063
13187
|
}
|
|
13064
13188
|
function isPromptGateRejection(e) {
|
|
13065
|
-
return e instanceof
|
|
13189
|
+
return e instanceof TablationApiError2 && e.status === 422;
|
|
13066
13190
|
}
|
|
13067
13191
|
var RELEASE_AGENT_NAME = "Release agent";
|
|
13068
13192
|
var RELEASE_AGENT_PROMPT = "Principal for the crew release phase (merge, deploy, release comments). It runs no model; this row only gives those tracker writes an agent identity.";
|
|
@@ -13080,7 +13204,7 @@ async function syncPersonas(route2, opts) {
|
|
|
13080
13204
|
try {
|
|
13081
13205
|
agentsModel = await client2.dataModels.get("agents", workspaceId);
|
|
13082
13206
|
} catch (e) {
|
|
13083
|
-
if (e instanceof
|
|
13207
|
+
if (e instanceof TablationApiError2 && e.status === 404) {
|
|
13084
13208
|
throw new AgentsSyncError(
|
|
13085
13209
|
`workspace ${workspaceId} has no Agents table yet \u2014 every workspace auto-provisions one (ISSUE-465); an older workspace may still need its one-time backfill`
|
|
13086
13210
|
);
|
|
@@ -13277,7 +13401,7 @@ async function getSeatRow(client2, crewModelId, seatId) {
|
|
|
13277
13401
|
try {
|
|
13278
13402
|
return await client2.records.get(crewModelId, seatId);
|
|
13279
13403
|
} catch (e) {
|
|
13280
|
-
if (e instanceof
|
|
13404
|
+
if (e instanceof TablationApiError2 && e.status === 404) return null;
|
|
13281
13405
|
throw e;
|
|
13282
13406
|
}
|
|
13283
13407
|
}
|
|
@@ -13457,7 +13581,7 @@ async function syncSkills(route2, opts) {
|
|
|
13457
13581
|
try {
|
|
13458
13582
|
skillsModel = await client2.dataModels.get("agent_skills", workspaceId);
|
|
13459
13583
|
} catch (e) {
|
|
13460
|
-
if (e instanceof
|
|
13584
|
+
if (e instanceof TablationApiError3 && e.status === 404) {
|
|
13461
13585
|
throw new SkillSyncError(
|
|
13462
13586
|
`workspace ${workspaceId} has no Agent Skills table yet \u2014 every workspace auto-provisions one; an older workspace may still need its one-time backfill`
|
|
13463
13587
|
);
|
|
@@ -13499,7 +13623,7 @@ async function syncSkills(route2, opts) {
|
|
|
13499
13623
|
const agentsModel = await client2.dataModels.get("agents", workspaceId);
|
|
13500
13624
|
agentRows = await client2.records.list(agentsModel.id, { limit: 200 });
|
|
13501
13625
|
} catch (e) {
|
|
13502
|
-
if (!(e instanceof
|
|
13626
|
+
if (!(e instanceof TablationApiError3)) throw e;
|
|
13503
13627
|
agentRows = [];
|
|
13504
13628
|
}
|
|
13505
13629
|
}
|
|
@@ -18327,7 +18451,7 @@ function realPoolMemberDeps(o) {
|
|
|
18327
18451
|
}
|
|
18328
18452
|
|
|
18329
18453
|
// src/crew-floor.ts
|
|
18330
|
-
import { TablationApiError as
|
|
18454
|
+
import { TablationApiError as TablationApiError4 } from "@tablation/client";
|
|
18331
18455
|
var CREW_OUTDATED_KEY = "crew_outdated";
|
|
18332
18456
|
function parseVersion(v) {
|
|
18333
18457
|
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
@@ -18387,7 +18511,7 @@ function openOutdated(state) {
|
|
|
18387
18511
|
return state.shipAttention().previous().find((i) => i.key === CREW_OUTDATED_KEY)?.message ?? null;
|
|
18388
18512
|
}
|
|
18389
18513
|
function isUpgradeRequired(err3) {
|
|
18390
|
-
return err3 instanceof
|
|
18514
|
+
return err3 instanceof TablationApiError4 && err3.status === 426;
|
|
18391
18515
|
}
|
|
18392
18516
|
async function raiseFromUpgradeRequired(o, err3) {
|
|
18393
18517
|
const have = sentVersion(o.ship) ?? "unknown";
|
|
@@ -19451,15 +19575,23 @@ async function decideCycle(o) {
|
|
|
19451
19575
|
return fallback;
|
|
19452
19576
|
}
|
|
19453
19577
|
};
|
|
19454
|
-
const [
|
|
19455
|
-
tracker.openTickets(),
|
|
19456
|
-
tracker.comments(200),
|
|
19578
|
+
const [crewRows, projectModes] = await Promise.all([
|
|
19457
19579
|
tracker.crewRows(),
|
|
19580
|
+
optional("project work modes", tracker.projectWorkModes(), /* @__PURE__ */ new Map())
|
|
19581
|
+
]);
|
|
19582
|
+
const scopeHolds = new Set(holdIds(buildRoster(configuredMembers(route2), crewRows)));
|
|
19583
|
+
const scope = {
|
|
19584
|
+
modes: projectModes,
|
|
19585
|
+
agentAssignees: agentAssigneeIds(crewRows, (id) => scopeHolds.has(id)),
|
|
19586
|
+
triageSeat: route2.resolved?.seats.triage
|
|
19587
|
+
};
|
|
19588
|
+
const [tickets, epicRows, ships, stalledEvents] = await Promise.all([
|
|
19589
|
+
tracker.openTickets(scope),
|
|
19458
19590
|
optional("epics", tracker.epicRows(), []),
|
|
19459
19591
|
optional("ships", tracker.shipRows(), []),
|
|
19460
|
-
optional("project work modes", tracker.projectWorkModes(), /* @__PURE__ */ new Map()),
|
|
19461
19592
|
tracker.events("stalled")
|
|
19462
19593
|
]);
|
|
19594
|
+
const comments = await tracker.commentsForTickets(tickets.map((t) => t.id));
|
|
19463
19595
|
const directionEvents = (await Promise.all([...DIRECTION_EVENT_TYPES, ...STATUS_EVENT_TYPES, "pushed"].map((t) => tracker.events(t)))).flat();
|
|
19464
19596
|
const statusChanges = await tracker.statusChanges();
|
|
19465
19597
|
emit.note(`${tickets.length} open ticket(s), ${comments.length} comment(s)`, {
|
|
@@ -19492,6 +19624,7 @@ async function decideCycle(o) {
|
|
|
19492
19624
|
}
|
|
19493
19625
|
const extra = await tracker.ticketsByIds(missingBlockerIds(tickets));
|
|
19494
19626
|
const info = blockerInfoMap(tickets, extra);
|
|
19627
|
+
await reportTruncated(tracker, route2.route, state, emit);
|
|
19495
19628
|
const blocked = computeBlockedIds(tickets, info);
|
|
19496
19629
|
const footprintEvents = await optional("footprint events", readFootprintEvents(tracker), { declared: /* @__PURE__ */ new Map(), pushed: /* @__PURE__ */ new Map() });
|
|
19497
19630
|
const footprintPlan = planFootprintsFor(route2, tickets, footprintEvents, new Set(blocked));
|
|
@@ -19508,7 +19641,7 @@ async function decideCycle(o) {
|
|
|
19508
19641
|
const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits);
|
|
19509
19642
|
const holdReleases = planHoldReleases(tickets, tracker.contract);
|
|
19510
19643
|
const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
|
|
19511
|
-
const skipped =
|
|
19644
|
+
const skipped = await skippedCounts(tracker, tickets, projectModes);
|
|
19512
19645
|
if (skipped.manual || skipped.hybrid) {
|
|
19513
19646
|
emit.note(`sweeps skipped ${skipped.manual} manual/project-less and ${skipped.hybrid} unassigned hybrid ticket(s)`, {
|
|
19514
19647
|
data: { sweepSkipped: skipped }
|
|
@@ -19762,6 +19895,33 @@ ${body}` : body;
|
|
|
19762
19895
|
function rosterFor(d, route2, role) {
|
|
19763
19896
|
return rosterMarkdown(d.roster, route2.resolved.seats[role] ?? null);
|
|
19764
19897
|
}
|
|
19898
|
+
async function skippedCounts(tracker, tickets, modes) {
|
|
19899
|
+
if (modes.size === 0) return { manual: 0, hybrid: 0 };
|
|
19900
|
+
const c = tracker.contract;
|
|
19901
|
+
const idsOf = (m) => [...modes].filter(([, v]) => v === m).map(([id]) => id);
|
|
19902
|
+
const manualIds = idsOf("manual");
|
|
19903
|
+
const hybridIds = idsOf("hybrid");
|
|
19904
|
+
const col = c.columns.slice;
|
|
19905
|
+
const [none, manual, hybrid] = await Promise.all([
|
|
19906
|
+
tracker.countOpenTickets([{ columnName: col, operator: "IS_NULL" }]),
|
|
19907
|
+
manualIds.length ? tracker.countOpenTickets([{ columnName: col, operator: "IN", value: manualIds }]) : Promise.resolve(0),
|
|
19908
|
+
hybridIds.length ? tracker.countOpenTickets([{ columnName: col, operator: "IN", value: hybridIds }]) : Promise.resolve(0)
|
|
19909
|
+
]);
|
|
19910
|
+
const hybridFetched = tickets.filter((t) => t.project_id && hybridIds.includes(t.project_id)).length;
|
|
19911
|
+
return { manual: (none ?? 0) + (manual ?? 0), hybrid: Math.max(0, (hybrid ?? 0) - hybridFetched) };
|
|
19912
|
+
}
|
|
19913
|
+
async function reportTruncated(tracker, route2, state, emit) {
|
|
19914
|
+
const prefix = listTruncatedKey(route2, "");
|
|
19915
|
+
const live2 = /* @__PURE__ */ new Set();
|
|
19916
|
+
for (const [what, limit] of tracker.truncated) {
|
|
19917
|
+
const item = listTruncatedItem(route2, what, limit);
|
|
19918
|
+
live2.add(item.key);
|
|
19919
|
+
await raiseShipAttention({ state, emit }, item);
|
|
19920
|
+
}
|
|
19921
|
+
for (const i of openShipAttention(state)) {
|
|
19922
|
+
if (i.kind === "list_truncated" && i.key.startsWith(prefix) && !live2.has(i.key)) clearShipAttention(state, i.key);
|
|
19923
|
+
}
|
|
19924
|
+
}
|
|
19765
19925
|
|
|
19766
19926
|
// src/claim.ts
|
|
19767
19927
|
import { StaleWriteError as StaleWriteError6 } from "@tablation/client";
|
|
@@ -23467,6 +23627,60 @@ function explainRefusal(readable, unreadable) {
|
|
|
23467
23627
|
return parts.join(", ");
|
|
23468
23628
|
}
|
|
23469
23629
|
|
|
23630
|
+
// src/seat-missing.ts
|
|
23631
|
+
import { TablationApiError as TablationApiError5 } from "@tablation/client";
|
|
23632
|
+
var SEAT_MISSING_REMEDY = "run `crew connect` to pick a seat";
|
|
23633
|
+
async function probeSeats(route2, read) {
|
|
23634
|
+
const r = route2.resolved;
|
|
23635
|
+
if (!r) return [];
|
|
23636
|
+
const wanted = [];
|
|
23637
|
+
for (const role of ROLE_NAMES) if (r.seats[role]) wanted.push({ role, seatId: r.seats[role] });
|
|
23638
|
+
if (r.releaseSeat) wanted.push({ role: "release", seatId: r.releaseSeat });
|
|
23639
|
+
const byId = /* @__PURE__ */ new Map();
|
|
23640
|
+
const probeOne = async (id) => {
|
|
23641
|
+
try {
|
|
23642
|
+
return { state: await read(id) === null ? "missing" : "present" };
|
|
23643
|
+
} catch (e) {
|
|
23644
|
+
if (e instanceof TablationApiError5 && e.status === 404) return { state: "missing" };
|
|
23645
|
+
return { state: "unknown", detail: e.message };
|
|
23646
|
+
}
|
|
23647
|
+
};
|
|
23648
|
+
for (const w of wanted) if (!byId.has(w.seatId)) byId.set(w.seatId, probeOne(w.seatId));
|
|
23649
|
+
return Promise.all(wanted.map(async (w) => ({ ...w, ...await byId.get(w.seatId) })));
|
|
23650
|
+
}
|
|
23651
|
+
var seatMissingKey = (route2, role) => `seat_missing:${route2}:${role}`;
|
|
23652
|
+
function seatMissingMessage(route2, role) {
|
|
23653
|
+
return `${route2}: the ${role} seat's Crew row no longer exists, so that role is skipped \u2014 ${SEAT_MISSING_REMEDY}. Clears automatically once the seat resolves`;
|
|
23654
|
+
}
|
|
23655
|
+
function seatMissingItem(route2, role, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
23656
|
+
return { kind: "seat_missing", key: seatMissingKey(route2, role), since: nowIso, message: seatMissingMessage(route2, role) };
|
|
23657
|
+
}
|
|
23658
|
+
async function reconcileSeatAttention(route2, probes, io) {
|
|
23659
|
+
const slug2 = routeSlug(route2.route);
|
|
23660
|
+
for (const p of probes) {
|
|
23661
|
+
if (p.state === "missing") await io.raise(seatMissingItem(slug2, p.role));
|
|
23662
|
+
else if (p.state === "present") io.clear(seatMissingKey(slug2, p.role));
|
|
23663
|
+
}
|
|
23664
|
+
}
|
|
23665
|
+
var missingRoles = (probes) => probes.filter((p) => p.state === "missing").map((p) => p.role);
|
|
23666
|
+
function mergeSeatAttention(open, route2, probes, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
23667
|
+
const slug2 = routeSlug(route2.route);
|
|
23668
|
+
const settled = new Map(probes.filter((p) => p.state !== "unknown").map((p) => [seatMissingKey(slug2, p.role), p.state]));
|
|
23669
|
+
const kept = open.filter((i) => i.kind !== "seat_missing" || !settled.has(i.key) || settled.get(i.key) === "missing");
|
|
23670
|
+
const have = new Set(kept.map((i) => i.key));
|
|
23671
|
+
const added = probes.filter((p) => p.state === "missing" && !have.has(seatMissingKey(slug2, p.role))).map((p) => seatMissingItem(slug2, p.role, nowIso));
|
|
23672
|
+
return [...kept, ...added];
|
|
23673
|
+
}
|
|
23674
|
+
function seatMissingProblems(route2, probes) {
|
|
23675
|
+
return probes.filter((p) => p.state === "missing").map((p) => ({
|
|
23676
|
+
severity: "blocker",
|
|
23677
|
+
kind: "seat_missing",
|
|
23678
|
+
route: route2.route,
|
|
23679
|
+
message: `route ${route2.route}: the ${p.role} seat's Crew row (${p.seatId}) no longer exists, so that role is skipped`,
|
|
23680
|
+
remedy: SEAT_MISSING_REMEDY
|
|
23681
|
+
}));
|
|
23682
|
+
}
|
|
23683
|
+
|
|
23470
23684
|
// src/ssh-keys.ts
|
|
23471
23685
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
23472
23686
|
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
@@ -24279,9 +24493,29 @@ async function runOnePassUnguarded(o) {
|
|
|
24279
24493
|
const { ctx } = await prepareRoutePass(o);
|
|
24280
24494
|
const decision = await (o.decide ?? decideCycle)(ctx);
|
|
24281
24495
|
await applyRouteDecision(o, ctx, decision);
|
|
24282
|
-
const
|
|
24496
|
+
const pending = await dropRolesWithMissingSeat(o, ctx, decision.selection.pending);
|
|
24497
|
+
const { started, skipped } = await fillSlots(o, [{ ctx, decision, roles: pending }]);
|
|
24283
24498
|
await publishShipAttention(o.state, o.route, o.ship);
|
|
24284
|
-
return { pending
|
|
24499
|
+
return { pending, started, skipped };
|
|
24500
|
+
}
|
|
24501
|
+
async function dropRolesWithMissingSeat(o, ctx, pending) {
|
|
24502
|
+
if (!o.route.resolved) return pending;
|
|
24503
|
+
try {
|
|
24504
|
+
const tracker = new Tracker(o.route, o.ship);
|
|
24505
|
+
const probes = await probeSeats(o.route, (id) => tracker.crewRow(id));
|
|
24506
|
+
await reconcileSeatAttention(o.route, probes, {
|
|
24507
|
+
raise: (item) => raiseShipAttention({ state: o.state, emit: ctx.emit, route: o.route, ship: o.ship }, item),
|
|
24508
|
+
clear: (key) => clearShipAttention(o.state, key)
|
|
24509
|
+
});
|
|
24510
|
+
const missing = new Set(missingRoles(probes));
|
|
24511
|
+
for (const role of missing) {
|
|
24512
|
+
ctx.emit.warn(`${role} skipped this cycle: its configured seat's Crew row no longer exists (${SEAT_MISSING_REMEDY})`, { step: "select", role: role === "release" ? void 0 : role });
|
|
24513
|
+
}
|
|
24514
|
+
return pending.filter((r) => !missing.has(r));
|
|
24515
|
+
} catch (e) {
|
|
24516
|
+
ctx.emit.warn(`could not check the configured seats: ${e.message}`, { step: "select" });
|
|
24517
|
+
return pending;
|
|
24518
|
+
}
|
|
24285
24519
|
}
|
|
24286
24520
|
async function prepareRoutePass(o) {
|
|
24287
24521
|
await hydrateApiKeys([o.route], o.getSessionStore);
|
|
@@ -26574,13 +26808,16 @@ async function discover(o) {
|
|
|
26574
26808
|
}
|
|
26575
26809
|
if (shipRowId) {
|
|
26576
26810
|
const releaseId = stored?.releaseSeat && scoped.some((r) => r.id === stored.releaseSeat) ? stored.releaseSeat : void 0;
|
|
26577
|
-
if (releaseId)
|
|
26578
|
-
|
|
26811
|
+
if (releaseId) {
|
|
26812
|
+
out.releaseSeat = releaseId;
|
|
26813
|
+
out.releaseSeatAction = "matched";
|
|
26814
|
+
} else {
|
|
26579
26815
|
const created = await post2(o, `/data-models/${out.models.crew}/records`, {
|
|
26580
26816
|
name: "Release agent",
|
|
26581
26817
|
ship_id: shipRowId
|
|
26582
26818
|
});
|
|
26583
26819
|
out.releaseSeat = created.id;
|
|
26820
|
+
out.releaseSeatAction = "created";
|
|
26584
26821
|
provisioning.push("created Crew row for the release seat");
|
|
26585
26822
|
}
|
|
26586
26823
|
}
|
|
@@ -26687,12 +26924,11 @@ async function createOperatorRow(o, found) {
|
|
|
26687
26924
|
}
|
|
26688
26925
|
}
|
|
26689
26926
|
function renderConnection(d, route2, dir, opts = {}) {
|
|
26690
|
-
const apiKeyFileLine = opts.keychainBacked
|
|
26691
|
-
const apiKeyVarLine = opts.keychainBacked
|
|
26692
|
-
apiKeyVar: ${opts.apiKeyVar}` :
|
|
26693
|
-
|
|
26694
|
-
|
|
26695
|
-
` : ' baseUrl: "REPLACE \u2014 the same baseUrl as your other routes"\n';
|
|
26927
|
+
const apiKeyFileLine = !opts.keychainBacked && opts.apiKeyFile ? ` apiKeyFile: "${opts.apiKeyFile}"` : "";
|
|
26928
|
+
const apiKeyVarLine = !opts.keychainBacked && opts.apiKeyFile && opts.apiKeyVar ? `
|
|
26929
|
+
apiKeyVar: ${opts.apiKeyVar}` : "";
|
|
26930
|
+
const baseUrlLine = opts.baseUrl && opts.baseUrl.replace(/\/+$/, "") !== DEFAULT_BASE_URL ? ` baseUrl: "${opts.baseUrl}"
|
|
26931
|
+
` : "";
|
|
26696
26932
|
const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, "")].filter(Boolean).join("\n");
|
|
26697
26933
|
return ` - route: ${route2}
|
|
26698
26934
|
enabled: false # set to true once \`crew doctor\` is green
|
|
@@ -26700,6 +26936,27 @@ ${opts.area ? ` area: "${opts.area}"
|
|
|
26700
26936
|
` : ""}${dir === null ? "" : ` dir: "${dir}"
|
|
26701
26937
|
`}${baseUrlLine}${opts.hostPassengers ? " hostPassengers: true\n" : ""}${keyLines ? keyLines + "\n" : ""}`;
|
|
26702
26938
|
}
|
|
26939
|
+
function renderExistingRouteReport(o) {
|
|
26940
|
+
const seatRows = new Map((o.found.seatRows ?? []).map((r) => [r.role, r]));
|
|
26941
|
+
const keyOf = (role) => o.keys?.find((k) => k.role === role)?.action;
|
|
26942
|
+
const lines2 = [];
|
|
26943
|
+
for (const role of ["dev", "design", "qa", "triage"]) {
|
|
26944
|
+
const row = seatRows.get(role);
|
|
26945
|
+
lines2.push(row ? { role, ...row.id ? { id: row.id } : {}, outcome: row.action, key: keyOf(role) } : o.found.seats[role] ? { role, id: o.found.seats[role], outcome: "matched", key: keyOf(role) } : { role, outcome: "unresolved" });
|
|
26946
|
+
}
|
|
26947
|
+
lines2.push(o.found.seats.pair ? { role: "pair", id: o.found.seats.pair, outcome: "matched" } : { role: "pair", outcome: "unresolved" });
|
|
26948
|
+
lines2.push(o.found.releaseSeat ? { role: "release", id: o.found.releaseSeat, outcome: o.found.releaseSeatAction ?? "matched" } : { role: "release", outcome: "unresolved" });
|
|
26949
|
+
const out = [
|
|
26950
|
+
`${o.configFile} already has the route "${o.route}"; it was not changed.`,
|
|
26951
|
+
o.resolvedPath ? `${o.dryRun ? "(dry run) would write" : "Resolved ids written to"} ${o.resolvedPath}` : "",
|
|
26952
|
+
"Seats:",
|
|
26953
|
+
...lines2.map((l) => ` ${l.role.padEnd(8)} ${l.id ? `Crew row ${l.id}` : "no Crew row"} \u2014 ${l.outcome}${l.key && l.key !== "none" ? `; key ${l.key}` : ""}`),
|
|
26954
|
+
"",
|
|
26955
|
+
`Next: crew doctor ${o.route}`
|
|
26956
|
+
].filter((l, i, a) => l !== "" || i === a.length - 2);
|
|
26957
|
+
return `${out.join("\n")}
|
|
26958
|
+
`;
|
|
26959
|
+
}
|
|
26703
26960
|
|
|
26704
26961
|
// src/cli.ts
|
|
26705
26962
|
import {
|
|
@@ -28283,7 +28540,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
28283
28540
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
28284
28541
|
import { join as join60 } from "path";
|
|
28285
28542
|
function builtVersion() {
|
|
28286
|
-
return true ? "0.
|
|
28543
|
+
return true ? "0.158.2" : null;
|
|
28287
28544
|
}
|
|
28288
28545
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
28289
28546
|
function newestMtime(path) {
|
|
@@ -34387,10 +34644,36 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34387
34644
|
emit.error(`crew connect: ${msg}`);
|
|
34388
34645
|
stopWithProblem(msg, "wizard");
|
|
34389
34646
|
}
|
|
34390
|
-
|
|
34647
|
+
const storeLabel = () => {
|
|
34648
|
+
const r = describeSecretStore();
|
|
34649
|
+
return r.kind === "file" && r.dir ? `the key store under ${r.dir}` : "the OS keychain";
|
|
34650
|
+
};
|
|
34651
|
+
const keyFromFlag = givenKeySource === "flag" && !mintedFromDevice && !!apiKey;
|
|
34652
|
+
if (keyFromFlag && !keychainBacked && store) {
|
|
34653
|
+
if (dryRun) {
|
|
34654
|
+
keychainBacked = true;
|
|
34655
|
+
routineLine(`(dry run) would store the key in ${storeLabel()} for ${hostFromUrl4(baseUrl)}/${found.workspaceSlug}`);
|
|
34656
|
+
} else {
|
|
34657
|
+
try {
|
|
34658
|
+
await store.set(hostFromUrl4(baseUrl), found.workspaceSlug, {
|
|
34659
|
+
apiKey,
|
|
34660
|
+
workspaceId: found.workspaceId,
|
|
34661
|
+
identityId: found.meId ?? "",
|
|
34662
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
34663
|
+
});
|
|
34664
|
+
keychainBacked = true;
|
|
34665
|
+
sessionAddress = found.workspaceSlug;
|
|
34666
|
+
rememberSession(cfg.ship.stateDir, hostFromUrl4(baseUrl), found.workspaceSlug);
|
|
34667
|
+
routineLine(`API key stored in ${storeLabel()} for ${hostFromUrl4(baseUrl)}/${found.workspaceSlug}.`);
|
|
34668
|
+
} catch (e) {
|
|
34669
|
+
emit.warn(withFix(`could not store the key in ${storeLabel()} \u2014 ${e.message} \u2014 falling back to a key file`, "`crew doctor`"));
|
|
34670
|
+
}
|
|
34671
|
+
}
|
|
34672
|
+
}
|
|
34673
|
+
if ((mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
|
|
34391
34674
|
apiKeyFile = apiKeyPathFor(cfg.ship.stateDir, route3);
|
|
34392
34675
|
if (dryRun) {
|
|
34393
|
-
process.stderr.write(`(dry run) would write the
|
|
34676
|
+
process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
|
|
34394
34677
|
`);
|
|
34395
34678
|
} else {
|
|
34396
34679
|
mkdirSync43(dirname38(apiKeyFile), { recursive: true });
|
|
@@ -34406,13 +34689,14 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34406
34689
|
const routeBlock = renderConnection(
|
|
34407
34690
|
found,
|
|
34408
34691
|
route3,
|
|
34409
|
-
routeDir ??
|
|
34692
|
+
routeDir ?? null,
|
|
34410
34693
|
{
|
|
34411
34694
|
area: value("area"),
|
|
34412
34695
|
apiKeyFile,
|
|
34413
34696
|
apiKeyVar: apiKeyFile ? apiKeyVar : void 0,
|
|
34414
34697
|
keychainBacked,
|
|
34415
|
-
|
|
34698
|
+
baseUrl,
|
|
34699
|
+
...writeFirstRun ? { hostPassengers: wizard.answers.hostPassengers } : {}
|
|
34416
34700
|
}
|
|
34417
34701
|
);
|
|
34418
34702
|
let wroteConfig = false;
|
|
@@ -34431,7 +34715,17 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34431
34715
|
connectEvents.emit("config", `${cfg.configFile} already exists; left alone`, { written: false, path: cfg.configFile, reason: "exists" });
|
|
34432
34716
|
}
|
|
34433
34717
|
}
|
|
34434
|
-
|
|
34718
|
+
const routeInConfig = cfg.routes.some((r) => r.route === route3);
|
|
34719
|
+
const existingReport = routeInConfig ? renderExistingRouteReport({
|
|
34720
|
+
route: route3,
|
|
34721
|
+
configFile: cfg.configFile,
|
|
34722
|
+
resolvedPath,
|
|
34723
|
+
dryRun,
|
|
34724
|
+
found,
|
|
34725
|
+
keys: mintOutcomes.map((m) => ({ role: m.role, action: m.action }))
|
|
34726
|
+
}) : "";
|
|
34727
|
+
if (routeInConfig) (connectEvents.json ? process.stderr : process.stdout).write(existingReport);
|
|
34728
|
+
else if (!wroteConfig) (connectEvents.json ? process.stderr : process.stdout).write(routeBlock);
|
|
34435
34729
|
if (!flag("no-mcp") && apiKey) {
|
|
34436
34730
|
const replace = value("mcp") === "replace";
|
|
34437
34731
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -34481,17 +34775,19 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34481
34775
|
}));
|
|
34482
34776
|
if (!operator) process.stderr.write(` Also set operator in ${resolvedPath} before arming it.
|
|
34483
34777
|
`);
|
|
34778
|
+
} else if (routeInConfig) {
|
|
34779
|
+
if (!operator) emit.warn(`no operator resolved: set it in ${resolvedPath} before arming this route`);
|
|
34484
34780
|
} else if (operator) {
|
|
34485
34781
|
process.stderr.write(
|
|
34486
34782
|
`
|
|
34487
|
-
Paste the block above under routes: in crew.yaml
|
|
34783
|
+
Paste the block above under routes: in crew.yaml, then: crew doctor ${route3}
|
|
34488
34784
|
`
|
|
34489
34785
|
);
|
|
34490
34786
|
} else {
|
|
34491
34787
|
process.stderr.write(
|
|
34492
34788
|
`
|
|
34493
|
-
Paste the block above under routes: in crew.yaml
|
|
34494
|
-
|
|
34789
|
+
Paste the block above under routes: in crew.yaml, set operator in
|
|
34790
|
+
${resolvedPath}, then: crew doctor ${route3}
|
|
34495
34791
|
`
|
|
34496
34792
|
);
|
|
34497
34793
|
}
|
|
@@ -36145,6 +36441,8 @@ ${where.join("\n")}`);
|
|
|
36145
36441
|
const repos = await resolvedRepos(route2);
|
|
36146
36442
|
const seatIds = route2.resolved?.seats ?? {};
|
|
36147
36443
|
const crewRows = Object.keys(seatIds).length ? await statusTracker.crewRows() : [];
|
|
36444
|
+
const seatProbes = await probeSeats(route2, (id) => statusTracker.crewRow(id));
|
|
36445
|
+
const seatProbeOf = (role) => seatProbes.find((p) => p.role === role);
|
|
36148
36446
|
const crewRowById = new Map(crewRows.map((c) => [c.id, c]));
|
|
36149
36447
|
const agentPersonas = route2.resolved?.agentPersonas ?? {};
|
|
36150
36448
|
const seats2 = ROLE_NAMES.filter((r) => r !== "pair").map((r) => {
|
|
@@ -36156,6 +36454,8 @@ ${where.join("\n")}`);
|
|
|
36156
36454
|
role: r,
|
|
36157
36455
|
label: ROLE_LABEL[r],
|
|
36158
36456
|
crewId: seatId ?? null,
|
|
36457
|
+
// Additive (CREW-3449): true only when the tracker answered 404 for this seat's Crew row.
|
|
36458
|
+
missing: seatProbeOf(r)?.state === "missing",
|
|
36159
36459
|
name: crewRow?.name ?? null,
|
|
36160
36460
|
personaName,
|
|
36161
36461
|
// Additive (CREW-2822): how many runs this seat has live right now.
|
|
@@ -36191,7 +36491,7 @@ ${where.join("\n")}`);
|
|
|
36191
36491
|
eventFile: eventFileFor(cfg.ship.stateDir),
|
|
36192
36492
|
// Additive (CREW-1373): open ship-level items, including the
|
|
36193
36493
|
// derived `release_stale`. `version` stays 1.
|
|
36194
|
-
attention: openShipAttention(state),
|
|
36494
|
+
attention: mergeSeatAttention(openShipAttention(state), route2, seatProbes),
|
|
36195
36495
|
// Additive (CREW-2495): this ship's Ships-row name and whether it has drifted from `name`.
|
|
36196
36496
|
rowName: nameSync.rowName ?? null,
|
|
36197
36497
|
nameDrift: nameSync.drift,
|
|
@@ -36275,7 +36575,7 @@ ${where.join("\n")}`);
|
|
|
36275
36575
|
`);
|
|
36276
36576
|
break;
|
|
36277
36577
|
}
|
|
36278
|
-
const shipAttention = openShipAttention(state);
|
|
36578
|
+
const shipAttention = mergeSeatAttention(openShipAttention(state), route2, await probeSeats(route2, (id) => statusTracker.crewRow(id)));
|
|
36279
36579
|
let heldReleases = [];
|
|
36280
36580
|
let waitViews = [];
|
|
36281
36581
|
let deferredReleases = [];
|
|
@@ -36509,6 +36809,9 @@ ${where.join("\n")}`);
|
|
|
36509
36809
|
if (jsonGit && !jsonGit.ok) {
|
|
36510
36810
|
problems.push({ severity: "blocker", kind: "git_unrunnable", message: `git failed to run: ${jsonGit.detail}`, remedy: "fix the git on the scheduler PATH (on macOS, install the Xcode command line tools), then re-run `crew doctor`" });
|
|
36511
36811
|
}
|
|
36812
|
+
if (!flag("offline") && route2.resolved) {
|
|
36813
|
+
problems.push(...seatMissingProblems(route2, await probeSeats(route2, (id) => new Tracker(route2, cfg.ship).crewRow(id))));
|
|
36814
|
+
}
|
|
36512
36815
|
problems.push(...attentionProblems(openShipAttention(state), problems));
|
|
36513
36816
|
if (problems.some((p) => p.severity === "blocker")) process.exitCode = 1;
|
|
36514
36817
|
process.stdout.write(`${JSON.stringify({ offline: flag("offline"), pushAuth, tools: toolRows, daemon: daemonLiveness, problems, passed }, null, 2)}
|
|
@@ -37027,7 +37330,21 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
|
|
|
37027
37330
|
}
|
|
37028
37331
|
}
|
|
37029
37332
|
}
|
|
37030
|
-
|
|
37333
|
+
if (!flag("offline")) {
|
|
37334
|
+
for (const r of cfg.routes) {
|
|
37335
|
+
if (!r.resolved) continue;
|
|
37336
|
+
try {
|
|
37337
|
+
const tracker2 = new Tracker(r, cfg.ship);
|
|
37338
|
+
for (const p of seatMissingProblems(r, await probeSeats(r, (id) => tracker2.crewRow(id)))) {
|
|
37339
|
+
R.line(`seat: BLOCKER ${p.message} \u2014 ${p.remedy}
|
|
37340
|
+
`);
|
|
37341
|
+
process.exitCode = 1;
|
|
37342
|
+
}
|
|
37343
|
+
} catch {
|
|
37344
|
+
}
|
|
37345
|
+
}
|
|
37346
|
+
}
|
|
37347
|
+
for (const i of visibleAttention(openShipAttention(state), Boolean(dockerFinding)).filter((x) => x.kind !== "seat_missing")) {
|
|
37031
37348
|
R.line(`attention: ${i.kind} \u2014 ${i.message} (since ${i.since})
|
|
37032
37349
|
`);
|
|
37033
37350
|
}
|
package/package.json
CHANGED