@nodii/dev 0.6.95 → 0.6.97
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/api.js +9 -1
- package/dist/cli.js +22 -1
- package/dist/core.js +1 -1
- package/dist/flags.js +1 -0
- package/dist/hooks.js +2 -2
- package/dist/lane-supervisor.js +7 -1
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -171,9 +171,17 @@ export function flagsToOperation(entry, positional, flags) {
|
|
|
171
171
|
return { params, body: schema ? body : undefined, consumed: pos };
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
// Dev requires an Idempotency-Key on these, and a retry of the same call must be the same call.
|
|
175
|
+
const NEEDS_IDEMPOTENCY_KEY = new Set(["answerInboxItem"]);
|
|
176
|
+
export const idempotencyKey = (...parts) => createHash("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 32);
|
|
177
|
+
|
|
178
|
+
export const operationHeaders = (entry, request, text) =>
|
|
179
|
+
NEEDS_IDEMPOTENCY_KEY.has(entry.operationId) ? { "Idempotency-Key": idempotencyKey(request.method, request.path, text) } : {};
|
|
180
|
+
|
|
174
181
|
export async function callOperation(entry, params, body) {
|
|
175
182
|
const request = buildOperationRequest(entry, params, body);
|
|
176
|
-
|
|
183
|
+
const text = body === undefined ? undefined : JSON.stringify(body);
|
|
184
|
+
return devRawRequest(request.method, request.path, text, "application/json", { headers: operationHeaders(entry, request, text) });
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
export const GROUPS = {
|
package/dist/cli.js
CHANGED
|
@@ -83,6 +83,8 @@ import {
|
|
|
83
83
|
GROUPS,
|
|
84
84
|
buildOperationRequest,
|
|
85
85
|
callOperation,
|
|
86
|
+
idempotencyKey,
|
|
87
|
+
operationHeaders,
|
|
86
88
|
findFirstClass,
|
|
87
89
|
flagsToOperation,
|
|
88
90
|
refusePersonOnly,
|
|
@@ -120,6 +122,7 @@ import {
|
|
|
120
122
|
import { superviseLane } from "./lane-supervisor.js";
|
|
121
123
|
import { awsCli, superviseRemoteRun } from "./remote.js";
|
|
122
124
|
|
|
125
|
+
const NOTICE_KINDS = ["lane_wait", "lane_escalation", "credential_expiry"];
|
|
123
126
|
const LANE_RUN_HOOKS = new Set(["nudge-pre", "nudge-stop", "lane-heartbeat", "session-start", "session-kind", "workflow-post"]);
|
|
124
127
|
|
|
125
128
|
const HELP = `nodii-dev ${VERSION}
|
|
@@ -142,6 +145,8 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
142
145
|
issues transition ISSUE --to STATUS [--reason TEXT] [--dev-check REF]
|
|
143
146
|
# blocked and wont_do need --reason; done needs --dev-check
|
|
144
147
|
inbox list|show
|
|
148
|
+
inbox ack <lane_wait|lane_escalation|credential_expiry> <id> [--note TEXT]
|
|
149
|
+
# acknowledge a notice; sending it again changes nothing
|
|
145
150
|
drift file | request file
|
|
146
151
|
drift accept <id> --decision DEC-nnnn [--reason TEXT] # staff or steward only (Dev refuses a lane)
|
|
147
152
|
drift resolve <id> --reason TEXT # the operator resolution; staff or steward only
|
|
@@ -809,7 +814,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
809
814
|
refusePersonOnly(entry.operationId);
|
|
810
815
|
const parsed = await readBody(f.body);
|
|
811
816
|
const request = buildOperationRequest(entry, parseParams(f.param), parsed?.value);
|
|
812
|
-
return emit(await devRawRequest(request.method, request.path, parsed?.text), json);
|
|
817
|
+
return emit(await devRawRequest(request.method, request.path, parsed?.text, "application/json", { headers: operationHeaders(entry, request, parsed?.text) }), json);
|
|
813
818
|
}
|
|
814
819
|
if (command === "login") return login(f, json);
|
|
815
820
|
if (command === "logout") {
|
|
@@ -1104,6 +1109,22 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1104
1109
|
),
|
|
1105
1110
|
json,
|
|
1106
1111
|
);
|
|
1112
|
+
// A notice only needs acknowledging. Answering a drift, request or question
|
|
1113
|
+
// decides it, so that stays the deliberate `api answerInboxItem`.
|
|
1114
|
+
if (action === "ack") {
|
|
1115
|
+
const [kind, id] = rest;
|
|
1116
|
+
if (!NOTICE_KINDS.includes(kind) || !id)
|
|
1117
|
+
throw new CliError("USAGE", `inbox ack needs <${NOTICE_KINDS.join("|")}> <id>`, 2);
|
|
1118
|
+
const path = `/api/v1/inbox/${encode(kind)}/${encode(id)}/answer`;
|
|
1119
|
+
const body = JSON.stringify({ bodyMd: f.note ? String(f.note) : "Acknowledged." });
|
|
1120
|
+
return emit(
|
|
1121
|
+
await devRawRequest("POST", path, body, "application/json", {
|
|
1122
|
+
headers: { "Idempotency-Key": idempotencyKey("inbox ack", kind, id) },
|
|
1123
|
+
}),
|
|
1124
|
+
json,
|
|
1125
|
+
`Acknowledged ${kind} ${id}.`,
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1107
1128
|
if (action === "show") {
|
|
1108
1129
|
const [kind, id] = rest;
|
|
1109
1130
|
if (!kind || !id)
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.97";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/flags.js
CHANGED
|
@@ -41,6 +41,7 @@ export const COMMAND_FLAGS = {
|
|
|
41
41
|
"lane waits": ["machine"],
|
|
42
42
|
"lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
|
|
43
43
|
"lane transfer": ["reason", "to-agent"],
|
|
44
|
+
"inbox ack": ["note"],
|
|
44
45
|
"lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push"],
|
|
45
46
|
"lane closeout": ["reason"],
|
|
46
47
|
"lane repo": ["repo", "branch", "worktree", "read-only", "reason"],
|
package/dist/hooks.js
CHANGED
|
@@ -258,7 +258,7 @@ export async function heartbeatCurrentLane(request = devRequest, { cwd = process
|
|
|
258
258
|
if (laneKey) {
|
|
259
259
|
const lane = (await request("GET", `/api/v1/lanes/${encodeURIComponent(laneKey)}`)).data;
|
|
260
260
|
if (lane.repositories?.some((repository) => repository.branch === branch)) {
|
|
261
|
-
await request("POST", `/api/v1/lanes/${encodeURIComponent(lane.id)}/heartbeat`, { via: "nodii-dev" });
|
|
261
|
+
await request("POST", `/api/v1/lanes/${encodeURIComponent(lane.id)}/heartbeat`, { via: "nodii-dev", source: "hook" });
|
|
262
262
|
return { heartbeated: true, key: lane.key };
|
|
263
263
|
}
|
|
264
264
|
}
|
|
@@ -266,7 +266,7 @@ export async function heartbeatCurrentLane(request = devRequest, { cwd = process
|
|
|
266
266
|
const lanes = (await request("GET", "/api/v1/lanes?limit=200")).data ?? [];
|
|
267
267
|
const lane = lanes.find((x) => x.branch === branch && !["on_dev", "stopped"].includes(x.status));
|
|
268
268
|
if (!lane) return { heartbeated: false, reason: "no lane for current branch" };
|
|
269
|
-
await request("POST", `/api/v1/lanes/${encodeURIComponent(lane.id)}/heartbeat`, { via: "nodii-dev" });
|
|
269
|
+
await request("POST", `/api/v1/lanes/${encodeURIComponent(lane.id)}/heartbeat`, { via: "nodii-dev", source: "hook" });
|
|
270
270
|
return { heartbeated: true, key: lane.key };
|
|
271
271
|
}
|
|
272
272
|
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -100,7 +100,13 @@ export const laneBlocked = (lane) => Boolean(laneBlockedReason(lane));
|
|
|
100
100
|
export function laneBlockedReason(lane) {
|
|
101
101
|
const step = (lane?.steps ?? []).find((candidate) => candidate.state === "blocked");
|
|
102
102
|
if (step) return `Lane step ${step.side}/${step.stepKey} is blocked.`;
|
|
103
|
-
|
|
103
|
+
// hub-283: the open waits first, then the latest heartbeat that says something.
|
|
104
|
+
// A noteless or hook heartbeat never clears a WAITING or BLOCKED.
|
|
105
|
+
const waits = (lane?.waits ?? []).map((wait) => wait.targetRef).filter(Boolean);
|
|
106
|
+
if (waits.length) return `Lane waits on ${waits.join(", ")}.`;
|
|
107
|
+
const heartbeat = (lane?.events ?? [])
|
|
108
|
+
.filter((event) => event.type === "heartbeat" && event.metadata?.source !== "hook" && String(event.metadata?.note ?? "").trim())
|
|
109
|
+
.at(-1);
|
|
104
110
|
const note = String(heartbeat?.metadata?.note ?? "");
|
|
105
111
|
return /^\s*blocked\b/i.test(note) || /^\s*WAITING\s*:/.test(note) ? `Lane heartbeat: ${note.slice(0, 500)}` : null;
|
|
106
112
|
}
|