@phren/cli 0.3.42 → 0.3.44
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/bridge/conductor-role.js +15 -3
- package/dist/bridge/dispatch-command.js +7 -0
- package/dist/bridge/gitboy-contract.d.ts +5 -0
- package/dist/bridge/gitboy-contract.js +2 -0
- package/dist/bridge/pair.js +1 -1
- package/dist/bridge/pane-status.d.ts +2 -0
- package/dist/bridge/pane-status.js +5 -1
- package/dist/bridge/project-git.d.ts +8 -0
- package/dist/bridge/project-git.js +39 -0
- package/dist/bridge/project-memory.d.ts +12 -0
- package/dist/bridge/project-memory.js +27 -3
- package/dist/bridge/schedule-format.d.ts +6 -4
- package/dist/bridge/schedule-format.js +14 -6
- package/dist/bridge/schedule-launch.d.ts +16 -6
- package/dist/bridge/schedule-launch.js +78 -32
- package/dist/bridge/schedule-problems.d.ts +13 -0
- package/dist/bridge/schedule-problems.js +39 -0
- package/dist/bridge/schedules.d.ts +7 -0
- package/dist/bridge/schedules.js +23 -3
- package/dist/bridge/scoped-gateway.js +3 -2
- package/dist/bridge/server-routes.js +17 -4
- package/dist/bridge/worker-close.d.ts +5 -0
- package/dist/bridge/worker-close.js +16 -0
- package/dist/bridge-hook.mjs +10144 -9933
- package/dist/cli/schedules.js +14 -1
- package/dist/cli-registry.js +2 -1
- package/dist/modules/registry.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { connect } from "node:net";
|
|
2
2
|
import { BridgeError } from "./protocol.js";
|
|
3
|
-
import { findingWriteSchema, isBranchName, isRepoPath, isSearchText, MAX_FILE_PATHS, MAX_FINDING_BODY, PROJECT_NAME, } from "./gitboy-contract.js";
|
|
3
|
+
import { findingWriteSchema, taskCompleteSchema, isBranchName, isRepoPath, isSearchText, MAX_FILE_PATHS, MAX_FINDING_BODY, PROJECT_NAME, } from "./gitboy-contract.js";
|
|
4
4
|
// A scoped SSH key reaches the Hook through this gateway instead of the full
|
|
5
5
|
// byte pipe. The key's forced command names the scope
|
|
6
6
|
// (`sh ~/.local/share/phren/bridge/dispatch-scoped gitboy-read`); the gateway
|
|
@@ -51,12 +51,13 @@ const RULES = {
|
|
|
51
51
|
} },
|
|
52
52
|
],
|
|
53
53
|
"gitboy-write": [
|
|
54
|
+
{ method: "POST", path: new RegExp(`^/v1/projects/${PROJECT}/tasks/complete$`), body: { max: 256, schema: taskCompleteSchema } },
|
|
54
55
|
{ method: "POST", path: new RegExp(`^/v1/projects/${PROJECT}/findings$`), body: { max: MAX_FINDING_BODY, schema: findingWriteSchema } },
|
|
55
56
|
],
|
|
56
57
|
};
|
|
57
58
|
const DESCRIBE = {
|
|
58
59
|
"gitboy-read": "GET /v1/projects/<project>/memory, /memory/files, /memory/search and /tasks",
|
|
59
|
-
"gitboy-write": "POST /v1/projects/<project>/findings",
|
|
60
|
+
"gitboy-write": "POST /v1/projects/<project>/findings and /tasks/complete",
|
|
60
61
|
};
|
|
61
62
|
export function isGatewayScope(value) {
|
|
62
63
|
return GATEWAY_SCOPES.includes(value);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { listMoves, readMove } from "./session-move.js";
|
|
2
2
|
import { getTaskRoute, getTaskDirectoryRoute, updateTaskRoute, createTaskRoute, saveTaskRoute, launchTaskRoute } from "./task-routes.js";
|
|
3
3
|
import { ownerInboxView } from "./owner-inbox-view.js";
|
|
4
|
-
import { closeFinishedWorker } from "./worker-close.js";
|
|
4
|
+
import { closeFinishedWorker, closeOwnPane } from "./worker-close.js";
|
|
5
5
|
import { reportWorker, readIntegrator, setIntegrator } from "./worker-reports.js";
|
|
6
6
|
import { sessionStalls } from "./stalls.js";
|
|
7
7
|
import { harnessInventoryWithin, launchCheckOff } from "./harnesses.js";
|
|
@@ -27,7 +27,8 @@ import { browseFiles } from "./files.js";
|
|
|
27
27
|
import { MAX_FILE_RANGE, rangeInteger, readFileRange } from "./file-range.js";
|
|
28
28
|
import { resolveFilePath } from "./file-resolve.js";
|
|
29
29
|
import { storeRoute } from "./memory-store.js";
|
|
30
|
-
import { memoryForFiles, memorySearch, PROJECT_MEMORY_ROUTE, projectMemory, saveFinding, tasksForBranch } from "./project-memory.js";
|
|
30
|
+
import { memoryForFiles, memorySearch, PROJECT_MEMORY_ROUTE, projectMemory, saveFinding, tasksForBranch, completeProjectTask } from "./project-memory.js";
|
|
31
|
+
import { PROJECT_GIT_ROUTE, projectGit } from "./project-git.js";
|
|
31
32
|
import { liveBackground, markBackground, paneRecord, recordTitle } from "./session-activity.js";
|
|
32
33
|
import { paneAccountField, paneChatState, panes, rpc, servers, snapshot, validateTarget, workspaceSnapshot } from "./herdr.js";
|
|
33
34
|
import { locateProject } from "./locate.js";
|
|
@@ -313,11 +314,11 @@ export function createRouteHandler(ctx) {
|
|
|
313
314
|
const memoryRoute = PROJECT_MEMORY_ROUTE.exec(url.pathname);
|
|
314
315
|
if (memoryRoute) {
|
|
315
316
|
const [, project, route] = memoryRoute;
|
|
316
|
-
if (request.method !== (route === "findings" ? "POST" : "GET"))
|
|
317
|
+
if (request.method !== (route === "findings" || route === "tasks/complete" ? "POST" : "GET"))
|
|
317
318
|
throw new BridgeError(405, "Unsupported request method.");
|
|
318
319
|
if (!modules.has("memory"))
|
|
319
320
|
throw new BridgeError(404, disabledHint("memory"));
|
|
320
|
-
if (route === "tasks" && !modules.has("tasks"))
|
|
321
|
+
if ((route === "tasks" || route === "tasks/complete") && !modules.has("tasks"))
|
|
321
322
|
throw new BridgeError(404, disabledHint("tasks"));
|
|
322
323
|
if (route === "memory")
|
|
323
324
|
result = projectMemory(modules.store, project);
|
|
@@ -327,9 +328,18 @@ export function createRouteHandler(ctx) {
|
|
|
327
328
|
result = memorySearch(modules.store, project, url.searchParams.get("q") ?? "", Number(url.searchParams.get("limit") ?? "5"));
|
|
328
329
|
else if (route === "tasks")
|
|
329
330
|
result = tasksForBranch(modules.store, project, url.searchParams.get("branch") ?? "");
|
|
331
|
+
else if (route === "tasks/complete")
|
|
332
|
+
result = completeProjectTask(modules.store, project, await body(request));
|
|
330
333
|
else
|
|
331
334
|
result = await saveFinding(modules.store, project, await body(request));
|
|
332
335
|
}
|
|
336
|
+
else if (PROJECT_GIT_ROUTE.test(url.pathname)) {
|
|
337
|
+
if (request.method !== "GET")
|
|
338
|
+
throw new BridgeError(405, "Unsupported request method.");
|
|
339
|
+
if (!modules.has("git"))
|
|
340
|
+
throw new BridgeError(404, disabledHint("git"));
|
|
341
|
+
result = await projectGit(modules.store, PROJECT_GIT_ROUTE.exec(url.pathname)[1], await journal.recent());
|
|
342
|
+
}
|
|
333
343
|
else if (url.pathname.startsWith("/v1/store/")) {
|
|
334
344
|
result = await storeRoute(modules.store, request.method ?? "", url, request.method === "POST" ? await body(request) : undefined);
|
|
335
345
|
}
|
|
@@ -785,6 +795,9 @@ export function createRouteHandler(ctx) {
|
|
|
785
795
|
else if (url.pathname === "/v1/dispatch/close") {
|
|
786
796
|
result = await closeFinishedWorker(data, ctx.handOffs);
|
|
787
797
|
}
|
|
798
|
+
else if (url.pathname === "/v1/dispatch/close-self") {
|
|
799
|
+
result = await closeOwnPane(data);
|
|
800
|
+
}
|
|
788
801
|
else if (url.pathname === "/v1/hand-off") {
|
|
789
802
|
result = await ctx.handOffs.enqueue(data);
|
|
790
803
|
}
|
|
@@ -7,4 +7,9 @@ export declare function markPaneClosed(server: string, pane: Json): Promise<void
|
|
|
7
7
|
/** Called on the worker's computer only after the sender read the done return.
|
|
8
8
|
* Recheck this exact ended turn and skip any new work, background work or inbox. */
|
|
9
9
|
export declare function closeFinishedWorker(input: unknown, queue?: HandOffQueue): Promise<Json>;
|
|
10
|
+
/** An agent closing the pane it runs in, once its work is committed and reported:
|
|
11
|
+
* the sanctioned form of `herdr pane close`, which an agent's auto mode refuses.
|
|
12
|
+
* Only the caller's own pane (named by its terminal variables) is ever closed, and
|
|
13
|
+
* after the reply, so the agent's `phren` call still returns. */
|
|
14
|
+
export declare function closeOwnPane(input: unknown, delayMs?: number): Promise<Json>;
|
|
10
15
|
export {};
|
|
@@ -6,6 +6,7 @@ import { atomicInPrivateDir, BridgeError, bridgeRoot, targetSchema, startingTarg
|
|
|
6
6
|
import { validateTarget, paneChatState } from "./herdr.js";
|
|
7
7
|
import { terminalProvider } from "./terminal.js";
|
|
8
8
|
import { paneTurn, workerStates, workerTurnKey } from "./dispatch-returns.js";
|
|
9
|
+
import { originPaneSchema } from "./dispatch.js";
|
|
9
10
|
const closedTargetSchema = z.union([targetSchema, startingTargetSchema]);
|
|
10
11
|
const file = (target) => path.join(bridgeRoot(), "closed-workers", `${createHash("sha256").update(JSON.stringify([target.server, target.workspace, target.tab, target.pane, target.source, "session" in target ? target.session : target.startingToken])).digest("hex")}.json`);
|
|
11
12
|
export async function markWorkerClosed(target, terminal) {
|
|
@@ -77,3 +78,18 @@ export async function closeFinishedWorker(input, queue) {
|
|
|
77
78
|
}
|
|
78
79
|
return { ok: true, closed: true };
|
|
79
80
|
}
|
|
81
|
+
/** An agent closing the pane it runs in, once its work is committed and reported:
|
|
82
|
+
* the sanctioned form of `herdr pane close`, which an agent's auto mode refuses.
|
|
83
|
+
* Only the caller's own pane (named by its terminal variables) is ever closed, and
|
|
84
|
+
* after the reply, so the agent's `phren` call still returns. */
|
|
85
|
+
export async function closeOwnPane(input, delayMs = 500) {
|
|
86
|
+
const data = z.object({ origin: originPaneSchema }).strict().parse(input);
|
|
87
|
+
const { snapshot, findPane } = await import("./herdr.js");
|
|
88
|
+
const pane = findPane(await snapshot(data.origin.server), data.origin);
|
|
89
|
+
if (!pane)
|
|
90
|
+
return { ok: true, closed: false, reason: "The pane is already gone." };
|
|
91
|
+
await markPaneClosed(data.origin.server, pane);
|
|
92
|
+
const timer = setTimeout(() => { void terminalProvider().closePane(data.origin.server, data.origin.pane).catch(() => undefined); }, delayMs);
|
|
93
|
+
timer.unref();
|
|
94
|
+
return { ok: true, closed: true, pane: data.origin.pane };
|
|
95
|
+
}
|