@polygraph/claude-plugin 0.4.51 → 0.4.52
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appendFileSync, mkdirSync, renameSync, statSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { basename, join } from 'node:path';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
|
|
6
6
|
const HOOK_LOG_MAX_BYTES = 5 * 1024 * 1024;
|
|
@@ -56,6 +56,17 @@ export function buildLinkAgentSessionArgs({
|
|
|
56
56
|
return args;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Node runtime for the JS-entry fallback. This shim also runs inside
|
|
61
|
+
* non-Node hosts (the opencode plugin executes it in-process, and opencode
|
|
62
|
+
* is a compiled Bun binary), where process.execPath is not a Node
|
|
63
|
+
* executable — fall back to PATH resolution there.
|
|
64
|
+
*/
|
|
65
|
+
function nodeRuntime() {
|
|
66
|
+
const base = basename(process.execPath).toLowerCase();
|
|
67
|
+
return base === 'node' || base === 'node.exe' ? process.execPath : 'node';
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
export function linkAgentSession(claim, spawn = spawnSync, env = process.env) {
|
|
60
71
|
if (isManagedChildEnvironment(env)) return false;
|
|
61
72
|
|
|
@@ -67,11 +78,22 @@ export function linkAgentSession(claim, spawn = spawnSync, env = process.env) {
|
|
|
67
78
|
delete commandEnv.POLYGRAPH_CAPTURE_TOKEN;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
const
|
|
81
|
+
const spawnOptions = {
|
|
71
82
|
encoding: 'utf8',
|
|
72
83
|
env: commandEnv,
|
|
73
84
|
stdio: ['ignore', 'ignore', 'pipe'],
|
|
74
|
-
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
let result = spawn(command, args, spawnOptions);
|
|
88
|
+
|
|
89
|
+
// POLYGRAPH_CLI may point at a plain JS entry that cannot be spawned
|
|
90
|
+
// directly: a dev build without the executable bit, or a platform that
|
|
91
|
+
// cannot exec scripts. A spawn that failed to LAUNCH ran nothing, so the
|
|
92
|
+
// retry under a Node runtime is side-effect free — and anything that
|
|
93
|
+
// spawns directly today keeps its exact behavior.
|
|
94
|
+
if (result?.error && /\.[cm]?js$/i.test(command)) {
|
|
95
|
+
result = spawn(nodeRuntime(), [command, ...args], spawnOptions);
|
|
96
|
+
}
|
|
75
97
|
|
|
76
98
|
if (result?.error) throw result.error;
|
|
77
99
|
if (result?.status !== 0) {
|
package/package.json
CHANGED
|
@@ -41,6 +41,11 @@ For each id, launch one background poller subagent whose entire job is to block
|
|
|
41
41
|
- **Claude Code** — a background `Task` with `subagent_type: "polygraph:polygraph-delegate-subagent"`, `run_in_background: true`, and description `Delegate to <repo>`. Fall back to the bare agent name only if the namespaced form is not found.
|
|
42
42
|
- **OpenCode** — invoke `@polygraph-delegate-subagent`.
|
|
43
43
|
- **Codex** — launch `agent_type: "polygraph-delegate-subagent"` via Codex's own `spawn_agent`, and collect it with `wait_agent`.
|
|
44
|
+
- **Cursor** — a background `Task` with `subagent_type: "polygraph-delegate-subagent"`, `run_in_background: true`, and description `Delegate to <repo>`. Collect it with `Await`.
|
|
45
|
+
|
|
46
|
+
A collect step that returns while the poller subagent is still running has not failed. It has only reached the end of its collection window. Collect the same background-task id again, as many times as it takes for the poller subagent to stop. A poller that runs for several minutes is ordinary, and it is never a reason to take the wait back into the main conversation.
|
|
47
|
+
|
|
48
|
+
The background-task id is the handle your own harness returned when you launched the poller. It is not the Polygraph delegation id (`frontend-1`), which addresses the child agent. Once the poller subagent has finished, do not collect it again: read the child instead, as described below. A child that stops for attention also ends the poller, so treat that as a finished poller and not as a collection window running out.
|
|
44
49
|
|
|
45
50
|
The poller has exactly one tool and cannot read logs. It exits with a few lines naming the repo, the id, and the final status. That message is a doorbell, not a report — it tells you the child is worth reading, and nothing about what the child did.
|
|
46
51
|
|