harnery 0.42.0 → 0.44.0
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/README.md +3 -3
- package/dist/commander.d.ts +16 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +18 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +95 -52
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +38 -11
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +10 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +22 -7
- package/dist/commands/governor.js +22 -10
- package/dist/commands/inbox.d.ts +1 -1
- package/dist/commands/inbox.d.ts.map +1 -1
- package/dist/commands/inbox.js +55 -2
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +28 -4
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/commands/servers.js +16 -1
- package/dist/commands/supervisor.d.ts.map +1 -1
- package/dist/commands/supervisor.js +7 -2
- package/dist/commands/toc.d.ts +14 -0
- package/dist/commands/toc.d.ts.map +1 -1
- package/dist/commands/toc.js +7 -4
- package/dist/commands/tunnel.d.ts +65 -0
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +290 -101
- package/dist/commands/web-fetch.d.ts +3 -2
- package/dist/commands/web-fetch.d.ts.map +1 -1
- package/dist/commands/web-fetch.js +25 -19
- package/dist/commands/web.d.ts +7 -1
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +9 -3
- package/dist/commands/workflow.js +24 -30
- package/dist/core/agents/live-authority-v3.d.ts +1 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +11 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +4 -2
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/live-lifecycle-v3.js +28 -7
- package/dist/core/agents/mailbox.d.ts +9 -8
- package/dist/core/agents/mailbox.d.ts.map +1 -1
- package/dist/core/agents/mailbox.js +24 -17
- package/dist/core/agents/render/prompt-context.d.ts +2 -0
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +19 -17
- package/dist/core/agents/render/session-context.d.ts +2 -8
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +64 -43
- package/dist/core/agents/rules/stop-hook.js +3 -3
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +25 -14
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-writer.js +5 -0
- package/dist/core/agents/state/names.d.ts +43 -3
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +87 -3
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +5 -0
- package/dist/core/agents/state/proc-start.d.ts +19 -0
- package/dist/core/agents/state/proc-start.d.ts.map +1 -1
- package/dist/core/agents/state/proc-start.js +41 -0
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +180 -70
- package/dist/core/agents/state/unchanged-file.d.ts +44 -0
- package/dist/core/agents/state/unchanged-file.d.ts.map +1 -0
- package/dist/core/agents/state/unchanged-file.js +390 -0
- package/dist/core/context/index.d.ts +22 -10
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +381 -119
- package/dist/core/context/observation.d.ts +26 -0
- package/dist/core/context/observation.d.ts.map +1 -0
- package/dist/core/context/observation.js +11 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -1
- package/dist/core/diagnostics/bundle.js +25 -14
- package/dist/core/diagnostics/path-identity.d.ts +3 -0
- package/dist/core/diagnostics/path-identity.d.ts.map +1 -0
- package/dist/core/diagnostics/path-identity.js +12 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -1
- package/dist/core/diagnostics/sanitize.js +4 -3
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +29 -0
- package/dist/core/events/v3/generation-custody.d.ts +5 -0
- package/dist/core/events/v3/generation-custody.d.ts.map +1 -0
- package/dist/core/events/v3/generation-custody.js +50 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +7 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +77 -64
- package/dist/core/events/v3/support-storage/pack-reader.d.ts.map +1 -1
- package/dist/core/events/v3/support-storage/pack-reader.js +42 -16
- package/dist/core/governor/planning.d.ts.map +1 -1
- package/dist/core/governor/planning.js +14 -1
- package/dist/core/governor/service-read.d.ts +10 -2
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +105 -22
- package/dist/core/governor/service.d.ts +20 -2
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +72 -47
- package/dist/core/hooks/cli.js +120 -23
- package/dist/core/hooks/fork-lineage.d.ts +40 -0
- package/dist/core/hooks/fork-lineage.d.ts.map +1 -0
- package/dist/core/hooks/fork-lineage.js +62 -0
- package/dist/core/hooks/resolve/transcript.d.ts +16 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +84 -0
- package/dist/core/hooks/shell-rm.d.ts +2 -0
- package/dist/core/hooks/shell-rm.d.ts.map +1 -0
- package/dist/core/hooks/shell-rm.js +105 -0
- package/dist/core/hooks/shell-tokens.d.ts +12 -0
- package/dist/core/hooks/shell-tokens.d.ts.map +1 -0
- package/dist/core/hooks/shell-tokens.js +97 -0
- package/dist/core/hooks/shell-waiter.d.ts.map +1 -1
- package/dist/core/hooks/shell-waiter.js +3 -93
- package/dist/core/inbox/contract.d.ts +2 -1
- package/dist/core/inbox/contract.d.ts.map +1 -1
- package/dist/core/inbox/index.d.ts +2 -0
- package/dist/core/inbox/index.d.ts.map +1 -1
- package/dist/core/inbox/index.js +2 -0
- package/dist/core/inbox/peer-messages.d.ts +37 -0
- package/dist/core/inbox/peer-messages.d.ts.map +1 -0
- package/dist/core/inbox/peer-messages.js +72 -0
- package/dist/core/inbox/service.d.ts +8 -1
- package/dist/core/inbox/service.d.ts.map +1 -1
- package/dist/core/inbox/service.js +67 -21
- package/dist/core/inbox/targets.d.ts +22 -0
- package/dist/core/inbox/targets.d.ts.map +1 -0
- package/dist/core/inbox/targets.js +108 -0
- package/dist/core/inbox/watcher.js +7 -3
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +17 -2
- package/dist/core/resources/contract.d.ts +3 -0
- package/dist/core/resources/contract.d.ts.map +1 -1
- package/dist/core/resources/service-status.d.ts +14 -1
- package/dist/core/resources/service-status.d.ts.map +1 -1
- package/dist/core/resources/service-status.js +23 -13
- package/dist/core/resources/service.d.ts +9 -1
- package/dist/core/resources/service.d.ts.map +1 -1
- package/dist/core/resources/service.js +47 -27
- package/dist/core/resources/status.d.ts +2 -5
- package/dist/core/resources/status.d.ts.map +1 -1
- package/dist/core/resources/status.js +36 -7
- package/dist/core/semantic/contract.d.ts +5 -5
- package/dist/core/servers/index.d.ts +24 -13
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +132 -92
- package/dist/core/servers/tunnels.d.ts +3 -5
- package/dist/core/servers/tunnels.d.ts.map +1 -1
- package/dist/core/servers/tunnels.js +3 -9
- package/dist/core/storage/process-log.d.ts +12 -0
- package/dist/core/storage/process-log.d.ts.map +1 -1
- package/dist/core/storage/process-log.js +10 -2
- package/dist/core/supervisor/contract.d.ts +12 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -1
- package/dist/core/supervisor/explanations.d.ts.map +1 -1
- package/dist/core/supervisor/explanations.js +2 -1
- package/dist/core/supervisor/findings.d.ts.map +1 -1
- package/dist/core/supervisor/findings.js +54 -9
- package/dist/core/supervisor/service.d.ts +9 -1
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +59 -29
- package/dist/core/supervisor/services.d.ts.map +1 -1
- package/dist/core/supervisor/services.js +22 -1
- package/dist/core/supervisor/status.d.ts +17 -2
- package/dist/core/supervisor/status.d.ts.map +1 -1
- package/dist/core/supervisor/status.js +70 -12
- package/dist/core/supervisor/timeline.d.ts.map +1 -1
- package/dist/core/supervisor/timeline.js +2 -1
- package/dist/core/work/state.js +7 -7
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +105 -32
- package/dist/core/workflow/failure-evidence.d.ts +16 -0
- package/dist/core/workflow/failure-evidence.d.ts.map +1 -0
- package/dist/core/workflow/failure-evidence.js +114 -0
- package/dist/core/workflow/index.d.ts +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +1 -1
- package/dist/core/workflow/live-session-v3.d.ts +6 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +126 -5
- package/dist/core/workflow/proof.d.ts +5 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +115 -20
- package/dist/core/workflow/run-state.d.ts +3 -1
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +31 -27
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +19 -0
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +13 -0
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +19 -0
- package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
- package/dist/core/workflow/spawn-opencode.js +14 -0
- package/dist/core/workflow/types.d.ts +64 -17
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/index.d.ts +0 -1
- package/dist/core/workflow/workspaces/index.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/index.js +0 -1
- package/dist/core/workflow/workspaces/leases.d.ts +3 -1
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +30 -16
- package/dist/core/workflow/workspaces/local-git.d.ts +6 -2
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +270 -6
- package/dist/core/workflow/workspaces/ownership.d.ts +11 -0
- package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -0
- package/dist/core/workflow/workspaces/ownership.js +194 -0
- package/dist/core/workflow/workspaces/reclaim.d.ts +35 -0
- package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/reclaim.js +14 -0
- package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.js +21 -13
- package/dist/core/workflow/workspaces/state.d.ts +1 -0
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +21 -1
- package/dist/lib/browser/windows-chrome.d.ts +100 -12
- package/dist/lib/browser/windows-chrome.d.ts.map +1 -1
- package/dist/lib/browser/windows-chrome.js +262 -73
- package/dist/lib/docs-links.d.ts.map +1 -1
- package/dist/lib/docs-links.js +45 -2
- package/dist/lib/guarded-remove.d.ts +7 -0
- package/dist/lib/guarded-remove.d.ts.map +1 -1
- package/dist/lib/guarded-remove.js +106 -12
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +4 -0
- package/dist/lib/tunnel/allowlist.d.ts +44 -0
- package/dist/lib/tunnel/allowlist.d.ts.map +1 -0
- package/dist/lib/tunnel/allowlist.js +204 -0
- package/dist/lib/tunnel/current-address.d.ts +41 -0
- package/dist/lib/tunnel/current-address.d.ts.map +1 -0
- package/dist/lib/tunnel/current-address.js +123 -0
- package/dist/lib/tunnel/gate.js +13 -6
- package/dist/lib/tunnel/processes.d.ts +39 -0
- package/dist/lib/tunnel/processes.d.ts.map +1 -0
- package/dist/lib/tunnel/processes.js +121 -0
- package/dist/lib/tunnel/state.d.ts +28 -3
- package/dist/lib/tunnel/state.d.ts.map +1 -1
- package/dist/lib/tunnel/state.js +98 -27
- package/dist/lib/zip/index.d.ts +41 -0
- package/dist/lib/zip/index.d.ts.map +1 -0
- package/dist/lib/zip/index.js +398 -0
- package/package.json +8 -1
- package/src/commander.ts +32 -0
- package/src/commands/agents.ts +151 -74
- package/src/commands/browse.ts +50 -14
- package/src/commands/diagnostics.ts +10 -0
- package/src/commands/doctor.ts +26 -7
- package/src/commands/governor.ts +23 -10
- package/src/commands/inbox.ts +52 -2
- package/src/commands/rm.ts +43 -4
- package/src/commands/servers.ts +16 -4
- package/src/commands/supervisor.ts +7 -2
- package/src/commands/toc.ts +14 -6
- package/src/commands/tunnel.ts +394 -116
- package/src/commands/web-fetch.ts +30 -19
- package/src/commands/web.ts +9 -3
- package/src/commands/workflow.ts +30 -30
- package/src/core/agents/live-authority-v3.ts +17 -0
- package/src/core/agents/live-lifecycle-v3.ts +52 -14
- package/src/core/agents/mailbox.ts +26 -17
- package/src/core/agents/render/prompt-context.ts +35 -20
- package/src/core/agents/render/session-context.ts +92 -48
- package/src/core/agents/rules/stop-hook.ts +3 -3
- package/src/core/agents/state/heartbeat-writer.ts +29 -12
- package/src/core/agents/state/live-coordination-writer.ts +29 -0
- package/src/core/agents/state/names.ts +117 -6
- package/src/core/agents/state/pidmap.ts +13 -0
- package/src/core/agents/state/proc-start.ts +57 -0
- package/src/core/agents/state/stale-sweep.ts +247 -82
- package/src/core/agents/state/unchanged-file.ts +456 -0
- package/src/core/context/index.ts +446 -136
- package/src/core/context/observation.ts +29 -0
- package/src/core/diagnostics/bundle.ts +23 -18
- package/src/core/diagnostics/path-identity.ts +15 -0
- package/src/core/diagnostics/sanitize.ts +4 -3
- package/src/core/events/v3/authority-outbox.ts +56 -0
- package/src/core/events/v3/generation-custody.ts +59 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +15 -0
- package/src/core/events/v3/producers/recorder.ts +94 -68
- package/src/core/events/v3/support-storage/pack-reader.ts +45 -19
- package/src/core/governor/planning.ts +20 -8
- package/src/core/governor/service-read.ts +128 -20
- package/src/core/governor/service.ts +119 -42
- package/src/core/hooks/cli.ts +139 -22
- package/src/core/hooks/fork-lineage.ts +82 -0
- package/src/core/hooks/resolve/transcript.ts +88 -0
- package/src/core/hooks/shell-rm.ts +103 -0
- package/src/core/hooks/shell-tokens.ts +96 -0
- package/src/core/hooks/shell-waiter.ts +4 -91
- package/src/core/inbox/contract.ts +2 -1
- package/src/core/inbox/index.ts +2 -0
- package/src/core/inbox/peer-messages.ts +94 -0
- package/src/core/inbox/service.ts +88 -22
- package/src/core/inbox/targets.ts +148 -0
- package/src/core/inbox/watcher.ts +8 -9
- package/src/core/journal/index.ts +19 -2
- package/src/core/resources/contract.ts +4 -0
- package/src/core/resources/service-status.ts +35 -12
- package/src/core/resources/service.ts +71 -24
- package/src/core/resources/status.ts +57 -8
- package/src/core/servers/index.ts +177 -91
- package/src/core/servers/tunnels.ts +3 -11
- package/src/core/storage/process-log.ts +17 -2
- package/src/core/supervisor/contract.ts +13 -0
- package/src/core/supervisor/explanations.ts +4 -1
- package/src/core/supervisor/findings.ts +68 -10
- package/src/core/supervisor/service.ts +88 -26
- package/src/core/supervisor/services.ts +26 -8
- package/src/core/supervisor/status.ts +89 -12
- package/src/core/supervisor/timeline.ts +2 -1
- package/src/core/work/state.ts +7 -7
- package/src/core/workflow/engine.ts +131 -49
- package/src/core/workflow/failure-evidence.ts +141 -0
- package/src/core/workflow/index.ts +0 -1
- package/src/core/workflow/live-session-v3.ts +146 -5
- package/src/core/workflow/proof.ts +134 -26
- package/src/core/workflow/run-state.ts +31 -29
- package/src/core/workflow/spawn-claude.ts +18 -0
- package/src/core/workflow/spawn-codex.ts +13 -0
- package/src/core/workflow/spawn-cursor.ts +18 -0
- package/src/core/workflow/spawn-opencode.ts +14 -0
- package/src/core/workflow/types.ts +51 -17
- package/src/core/workflow/workspaces/index.ts +0 -1
- package/src/core/workflow/workspaces/leases.ts +48 -17
- package/src/core/workflow/workspaces/local-git.ts +315 -5
- package/src/core/workflow/workspaces/ownership.ts +232 -0
- package/src/core/workflow/workspaces/reclaim.ts +58 -0
- package/src/core/workflow/workspaces/recovery.ts +25 -13
- package/src/core/workflow/workspaces/state.ts +20 -0
- package/src/lib/browser/windows-chrome.ts +346 -86
- package/src/lib/docs-links.ts +49 -2
- package/src/lib/guarded-remove.ts +132 -14
- package/src/lib/identities/assume.ts +4 -0
- package/src/lib/tunnel/allowlist.ts +208 -0
- package/src/lib/tunnel/current-address.ts +158 -0
- package/src/lib/tunnel/gate.ts +16 -8
- package/src/lib/tunnel/processes.ts +149 -0
- package/src/lib/tunnel/state.ts +123 -27
- package/src/lib/zip/index.ts +483 -0
package/src/commands/inbox.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { EmitContext } from "../commander.ts";
|
|
3
3
|
import type { HarneryInboxService } from "../core/inbox/service.ts";
|
|
4
|
+
import { watchInbox } from "../core/inbox/watcher.ts";
|
|
4
5
|
|
|
5
6
|
export function registerInboxCommand(
|
|
6
7
|
program: Command,
|
|
7
8
|
emit: EmitContext,
|
|
8
9
|
service?: HarneryInboxService,
|
|
10
|
+
defaultRecipient?: () => string,
|
|
9
11
|
): void {
|
|
10
12
|
const inbox = program.command("inbox").description("Inspect private coordination inbox state");
|
|
11
13
|
inbox
|
|
12
|
-
.command("list
|
|
14
|
+
.command("list [recipient]")
|
|
13
15
|
.option("--json", "Emit stable JSON")
|
|
14
|
-
.action((recipient: string, options: { json?: boolean }) => {
|
|
16
|
+
.action((recipient: string | undefined, options: { json?: boolean }) => {
|
|
15
17
|
run(emit, () => {
|
|
18
|
+
recipient = requireRecipient(recipient, defaultRecipient);
|
|
16
19
|
const rows = requireInboxService(service)
|
|
17
20
|
.pending(recipient)
|
|
18
21
|
.map((record) => ({
|
|
@@ -22,6 +25,7 @@ export function registerInboxCommand(
|
|
|
22
25
|
created_at: record.created_at,
|
|
23
26
|
body_bytes: record.body_bytes,
|
|
24
27
|
body: record.body,
|
|
28
|
+
state: "pending",
|
|
25
29
|
}));
|
|
26
30
|
if (options.json) {
|
|
27
31
|
emit.config({ format: "json" });
|
|
@@ -41,6 +45,52 @@ export function registerInboxCommand(
|
|
|
41
45
|
} else emit.rows([status as unknown as Record<string, unknown>]);
|
|
42
46
|
});
|
|
43
47
|
});
|
|
48
|
+
inbox
|
|
49
|
+
.command("watch [recipient]")
|
|
50
|
+
.description("Surface pending messages for this instance; poll history until timeout")
|
|
51
|
+
.option("--timeout <seconds>", "Stop after this many seconds", "60")
|
|
52
|
+
.option("--json", "Emit one JSON record per surfaced message")
|
|
53
|
+
.action(async (recipient: string | undefined, options: { json?: boolean; timeout: string }) => {
|
|
54
|
+
let controller: AbortController | undefined;
|
|
55
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
56
|
+
try {
|
|
57
|
+
const instanceId = requireRecipient(recipient, defaultRecipient);
|
|
58
|
+
const inboxService = requireInboxService(service);
|
|
59
|
+
const seconds = Number(options.timeout);
|
|
60
|
+
if (!Number.isFinite(seconds) || seconds <= 0 || seconds > 3600)
|
|
61
|
+
throw new Error("--timeout must be greater than 0 and at most 3600 seconds");
|
|
62
|
+
controller = new AbortController();
|
|
63
|
+
timer = setTimeout(() => controller!.abort(), seconds * 1000);
|
|
64
|
+
if (options.json) emit.config({ format: "json" });
|
|
65
|
+
for await (const message of watchInbox(inboxService, instanceId, {
|
|
66
|
+
signal: controller.signal,
|
|
67
|
+
})) {
|
|
68
|
+
const row = { ...message, state: "surfaced" };
|
|
69
|
+
if (options.json) emit.data(row);
|
|
70
|
+
else emit.rows([row]);
|
|
71
|
+
// An output error leaves this ID pending for prompt recovery.
|
|
72
|
+
await new Promise<void>((resolve, reject) =>
|
|
73
|
+
process.stdout.write("", (error) => (error ? reject(error) : resolve())),
|
|
74
|
+
);
|
|
75
|
+
inboxService.acknowledgeSurface(instanceId, [message.message_id]);
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
emit.error({
|
|
79
|
+
code: "inbox_failed",
|
|
80
|
+
message: error instanceof Error ? error.message : String(error),
|
|
81
|
+
});
|
|
82
|
+
emit.setExitCode(1);
|
|
83
|
+
} finally {
|
|
84
|
+
if (timer) clearTimeout(timer);
|
|
85
|
+
controller?.abort();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function requireRecipient(recipient: string | undefined, fallback?: () => string): string {
|
|
91
|
+
const resolved = recipient ?? fallback?.();
|
|
92
|
+
if (!resolved) throw new Error("recipient instance is required outside an agent session");
|
|
93
|
+
return resolved;
|
|
44
94
|
}
|
|
45
95
|
|
|
46
96
|
function requireInboxService(service?: HarneryInboxService): HarneryInboxService {
|
package/src/commands/rm.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { existsSync, lstatSync, readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
4
|
import type { Command } from "commander";
|
|
5
5
|
import type { EmitContext, HarneryProgramContext } from "../commander.ts";
|
|
6
6
|
import { resolveCoordRoot } from "../core/agents/coord-client.ts";
|
|
7
|
+
import { artifactsRoot, parseArtifactManifest } from "../core/artifacts/index.ts";
|
|
7
8
|
import {
|
|
8
9
|
readCoordinationViewV3,
|
|
9
10
|
requireAuthoritySafeCoordinationViewV3,
|
|
@@ -25,6 +26,15 @@ export function registerRmCommand(
|
|
|
25
26
|
"Allowed directory; each target must be strictly inside it",
|
|
26
27
|
)
|
|
27
28
|
.option("-r, --recursive", "Permit directory removal after inspecting its complete contents")
|
|
29
|
+
.option(
|
|
30
|
+
"--clean-clone",
|
|
31
|
+
"Remove only clean standalone clones inside one owned artifact; refuse local-only commits and worktrees",
|
|
32
|
+
)
|
|
33
|
+
.option(
|
|
34
|
+
"--entry-limit <n>",
|
|
35
|
+
"Maximum inspected entries, 1-100000 (default 10000); larger limits require one current caller-owned managed artifact as --root",
|
|
36
|
+
(value: string) => Number(value),
|
|
37
|
+
)
|
|
28
38
|
.option(
|
|
29
39
|
"--allow-protected <path>",
|
|
30
40
|
"Remove this one protected path (Git metadata, credentials, Harnery state, keys) inside a target; repeat per path",
|
|
@@ -65,7 +75,34 @@ export function registerRmCommand(
|
|
|
65
75
|
const liveRoots = [coordRoot, gitTopLevel(process.cwd())].filter((dir): dir is string =>
|
|
66
76
|
Boolean(dir),
|
|
67
77
|
);
|
|
68
|
-
const
|
|
78
|
+
const assertOwnedArtifact = (root: string): void => {
|
|
79
|
+
if (!coordRoot || dirname(root) !== realpathSync(artifactsRoot(coordRoot)))
|
|
80
|
+
throw new Error("Copied state requires --root to name one owned managed artifact");
|
|
81
|
+
const view = requireAuthoritySafeCoordinationViewV3(readCoordinationViewV3(coordRoot));
|
|
82
|
+
const owner = resolveOwner({ payload: null, coordRoot });
|
|
83
|
+
const ownId = owner ? liveInstanceIdV3(owner.instance_id) : undefined;
|
|
84
|
+
if (!ownId || !view.instances[ownId]?.authority_eligible)
|
|
85
|
+
throw new Error("Copied state requires an authenticated current artifact owner");
|
|
86
|
+
const record = resolve(root, ".harnery-artifact.json");
|
|
87
|
+
const stat = lstatSync(record);
|
|
88
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
89
|
+
throw new Error("An owned artifact requires a regular manifest file");
|
|
90
|
+
const parsed = parseArtifactManifest(JSON.parse(readFileSync(record, "utf8")));
|
|
91
|
+
if (
|
|
92
|
+
!parsed.ok ||
|
|
93
|
+
parsed.manifest.released_at ||
|
|
94
|
+
!parsed.manifest.created_by?.instance_id ||
|
|
95
|
+
liveInstanceIdV3(parsed.manifest.created_by.instance_id) !== ownId
|
|
96
|
+
)
|
|
97
|
+
throw new Error(
|
|
98
|
+
"Copied state requires a valid unreleased artifact owned by the caller",
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
const report = guardedRemove(
|
|
102
|
+
paths,
|
|
103
|
+
{ ...options, liveRoots, assertOwnedArtifact },
|
|
104
|
+
checkClaims,
|
|
105
|
+
);
|
|
69
106
|
if (options.json) {
|
|
70
107
|
emit.config({ format: "json" });
|
|
71
108
|
emit.data(report);
|
|
@@ -76,7 +113,9 @@ export function registerRmCommand(
|
|
|
76
113
|
];
|
|
77
114
|
if (report.protected.length)
|
|
78
115
|
lines.push(
|
|
79
|
-
|
|
116
|
+
options.cleanClone
|
|
117
|
+
? "Verified clone metadata:"
|
|
118
|
+
: "Protected paths named with --allow-protected:",
|
|
80
119
|
...report.protected.map((path) => ` ${path}`),
|
|
81
120
|
);
|
|
82
121
|
if (report.links.length)
|
package/src/commands/servers.ts
CHANGED
|
@@ -120,6 +120,7 @@ export function registerServersCommand(
|
|
|
120
120
|
type: "unregistered",
|
|
121
121
|
label: stray.command,
|
|
122
122
|
pid: stray.pid,
|
|
123
|
+
...(stray.start_token ? { start_token: stray.start_token } : {}),
|
|
123
124
|
host: hostname(),
|
|
124
125
|
started_at: new Date().toISOString(),
|
|
125
126
|
registered_at: new Date().toISOString(),
|
|
@@ -207,10 +208,20 @@ export function registerServersCommand(
|
|
|
207
208
|
emit.config({ format: "json" });
|
|
208
209
|
emit.data({ applied: Boolean(options.yes), pruned: report.pruned, decisions, results });
|
|
209
210
|
} else {
|
|
210
|
-
const lines = decisions.map(
|
|
211
|
-
(
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
const lines = decisions.map((decision) => {
|
|
212
|
+
const result = results.find((item) => item.id === decision.id);
|
|
213
|
+
const action =
|
|
214
|
+
decision.action === "keep"
|
|
215
|
+
? "keep"
|
|
216
|
+
: !options.yes
|
|
217
|
+
? "would stop"
|
|
218
|
+
: result?.stopped
|
|
219
|
+
? "stopped"
|
|
220
|
+
: result?.method === "not-running"
|
|
221
|
+
? "already stopped"
|
|
222
|
+
: "could not stop";
|
|
223
|
+
return `${action} ${decision.id} ${result?.detail ?? decision.reason}`;
|
|
224
|
+
});
|
|
214
225
|
if (report.pruned.length)
|
|
215
226
|
lines.push(`Removed records of exited servers: ${report.pruned.join(", ")}`);
|
|
216
227
|
if (!decisions.length) lines.push("No registered servers.");
|
|
@@ -218,6 +229,7 @@ export function registerServersCommand(
|
|
|
218
229
|
lines.push("Preview only. Re-run with --yes to stop.");
|
|
219
230
|
emit.text(lines.join("\n"));
|
|
220
231
|
}
|
|
232
|
+
if (results.some((result) => result.method === "refused")) emit.setExitCode(1);
|
|
221
233
|
} catch (error) {
|
|
222
234
|
fail(error);
|
|
223
235
|
}
|
|
@@ -83,11 +83,16 @@ export function registerSupervisorCommand(
|
|
|
83
83
|
.action(async (options: { root?: string }) => {
|
|
84
84
|
try {
|
|
85
85
|
const root = resolve(options.root ?? coordRoot(context));
|
|
86
|
-
|
|
86
|
+
const requested = requestSupervisorStop(root);
|
|
87
|
+
let status = requested;
|
|
87
88
|
const deadline = Date.now() + 5_000;
|
|
88
89
|
while (status.running && Date.now() < deadline) {
|
|
89
90
|
await new Promise((done) => setTimeout(done, 50));
|
|
90
|
-
status =
|
|
91
|
+
status = {
|
|
92
|
+
...readSupervisorStatus(root),
|
|
93
|
+
signal_sent: requested.signal_sent,
|
|
94
|
+
signal_verdict: requested.signal_verdict,
|
|
95
|
+
};
|
|
91
96
|
}
|
|
92
97
|
emit.data(status);
|
|
93
98
|
} catch (error) {
|
package/src/commands/toc.ts
CHANGED
|
@@ -172,17 +172,25 @@ function renderToc(r: TocResult): string {
|
|
|
172
172
|
return lines.join("\n");
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
async function runSection(
|
|
175
|
+
export async function runSection(
|
|
176
|
+
file: string,
|
|
177
|
+
query: string,
|
|
178
|
+
opts: SectionOpts,
|
|
179
|
+
): Promise<SectionResult> {
|
|
176
180
|
if (!query.trim()) throw new Error("header query required");
|
|
177
181
|
const tocResult = await runToc(file, {});
|
|
178
182
|
const absPath = resolve(file);
|
|
179
183
|
const lines = readFileSync(absPath, "utf8").split("\n");
|
|
180
184
|
|
|
181
|
-
const
|
|
182
|
-
opts.caseSensitive
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
const same = (a: string, b: string) =>
|
|
186
|
+
opts.caseSensitive ? a === b : a.toLowerCase() === b.toLowerCase();
|
|
187
|
+
const contains = (a: string, b: string) =>
|
|
188
|
+
opts.caseSensitive ? a.includes(b) : a.toLowerCase().includes(b.toLowerCase());
|
|
189
|
+
// A header that equals the query wins over headers that merely contain it,
|
|
190
|
+
// so "Media" can still select "## Media" beside "## Media recipes".
|
|
191
|
+
const exact = tocResult.headers.filter((h) => same(h.text, query.trim()));
|
|
192
|
+
const matches =
|
|
193
|
+
exact.length > 0 ? exact : tocResult.headers.filter((h) => contains(h.text, query));
|
|
186
194
|
if (matches.length === 0) {
|
|
187
195
|
throw new Error(
|
|
188
196
|
`no header matching "${query}". Run \`${resolveBinName()} toc ${file}\` to list available headers.`,
|