@peakflo/agent-harness 0.0.0-stage → 0.2.2-rc.1

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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/dist/adapters/acp-adapter.d.ts +177 -0
  4. package/dist/adapters/acp-adapter.js +1732 -0
  5. package/dist/adapters/claude-code-adapter.d.ts +171 -0
  6. package/dist/adapters/claude-code-adapter.js +1918 -0
  7. package/dist/adapters/codex-adapter.d.ts +67 -0
  8. package/dist/adapters/codex-adapter.js +681 -0
  9. package/dist/adapters/codex-app-server-adapter.d.ts +105 -0
  10. package/dist/adapters/codex-app-server-adapter.js +1309 -0
  11. package/dist/adapters/coding-agent-adapter.d.ts +289 -0
  12. package/dist/adapters/coding-agent-adapter.js +31 -0
  13. package/dist/adapters/index.d.ts +17 -0
  14. package/dist/adapters/index.js +35 -0
  15. package/dist/adapters/model-gateway.d.ts +84 -0
  16. package/dist/adapters/model-gateway.js +270 -0
  17. package/dist/adapters/opencode-adapter.d.ts +403 -0
  18. package/dist/adapters/opencode-adapter.js +2710 -0
  19. package/dist/adapters/opencode-config.d.ts +41 -0
  20. package/dist/adapters/opencode-config.js +147 -0
  21. package/dist/adapters/opencode-server-policy.d.ts +82 -0
  22. package/dist/adapters/opencode-server-policy.js +148 -0
  23. package/dist/adapters/pi-adapter.d.ts +168 -0
  24. package/dist/adapters/pi-adapter.js +1468 -0
  25. package/dist/capabilities.d.ts +58 -0
  26. package/dist/capabilities.js +161 -0
  27. package/dist/cli.d.ts +2 -0
  28. package/dist/cli.js +231 -0
  29. package/dist/contract.d.ts +273 -0
  30. package/dist/contract.js +357 -0
  31. package/dist/control-plane.d.ts +178 -0
  32. package/dist/control-plane.js +431 -0
  33. package/dist/credential-store.d.ts +110 -0
  34. package/dist/credential-store.js +181 -0
  35. package/dist/enrol/browser-enrol.d.ts +85 -0
  36. package/dist/enrol/browser-enrol.js +387 -0
  37. package/dist/github-command-guards.d.ts +20 -0
  38. package/dist/github-command-guards.js +330 -0
  39. package/dist/github-proxy-certificates.d.ts +25 -0
  40. package/dist/github-proxy-certificates.js +145 -0
  41. package/dist/github-proxy.d.ts +37 -0
  42. package/dist/github-proxy.js +476 -0
  43. package/dist/github-workspace.d.ts +55 -0
  44. package/dist/github-workspace.js +537 -0
  45. package/dist/harness.d.ts +333 -0
  46. package/dist/harness.js +1414 -0
  47. package/dist/health.d.ts +45 -0
  48. package/dist/health.js +116 -0
  49. package/dist/index.d.ts +53 -0
  50. package/dist/index.js +123 -0
  51. package/dist/model-probe.d.ts +96 -0
  52. package/dist/model-probe.js +195 -0
  53. package/dist/options.d.ts +15 -0
  54. package/dist/options.js +212 -0
  55. package/dist/ports-default.d.ts +212 -0
  56. package/dist/ports-default.js +333 -0
  57. package/dist/ports.d.ts +436 -0
  58. package/dist/ports.js +27 -0
  59. package/dist/runtime/attachments.d.ts +92 -0
  60. package/dist/runtime/attachments.js +377 -0
  61. package/dist/runtime/child-stream-guards.d.ts +45 -0
  62. package/dist/runtime/child-stream-guards.js +111 -0
  63. package/dist/runtime/conversation.d.ts +87 -0
  64. package/dist/runtime/conversation.js +156 -0
  65. package/dist/runtime/lease-renewal.d.ts +169 -0
  66. package/dist/runtime/lease-renewal.js +433 -0
  67. package/dist/runtime/mcp-auth-proxy.d.ts +82 -0
  68. package/dist/runtime/mcp-auth-proxy.js +300 -0
  69. package/dist/runtime/permission-mode.d.ts +116 -0
  70. package/dist/runtime/permission-mode.js +146 -0
  71. package/dist/runtime/projection.d.ts +71 -0
  72. package/dist/runtime/projection.js +211 -0
  73. package/dist/runtime/session-runner.d.ts +520 -0
  74. package/dist/runtime/session-runner.js +2122 -0
  75. package/dist/shared/reasoning-effort.d.ts +11 -0
  76. package/dist/shared/reasoning-effort.js +20 -0
  77. package/dist/store/conversation-store.d.ts +100 -0
  78. package/dist/store/conversation-store.js +305 -0
  79. package/dist/store/sqlite-store.d.ts +120 -0
  80. package/dist/store/sqlite-store.js +346 -0
  81. package/dist/types.d.ts +952 -0
  82. package/dist/types.js +55 -0
  83. package/dist/version.d.ts +32 -0
  84. package/dist/version.js +77 -0
  85. package/package.json +53 -4
package/dist/types.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * THE RUNNER WIRE CONTRACT — the single meeting point between the control
4
+ * plane (Track A, workflow-builder) and the harness (Track B, extracted from
5
+ * 20x).
6
+ *
7
+ * This file is the contract. `packages/agentSandbox/test/control-plane-stub.mjs`
8
+ * is the SAME contract in executable form. The two are kept in lockstep on
9
+ * purpose: prose drifts, a running stub does not.
10
+ *
11
+ * FOUR PROPERTIES THAT ARE NOT NEGOTIABLE
12
+ *
13
+ * 1. VERSIONED. Every request carries `protocolVersion`. A harness below the
14
+ * control plane's floor is refused, and the refusal is FINAL — the harness
15
+ * exits so the host is recycled onto a supported version. See
16
+ * `./contract.ts`.
17
+ *
18
+ * 2. OUTBOUND ONLY. Nothing here requires the harness to accept an inbound
19
+ * connection. Work is delivered by a bounded long-poll (`GET .../lease`),
20
+ * never by the control plane dialling in. That single property is what lets
21
+ * a customer VM behind NAT work with no tunnel and no listening port.
22
+ * Anything that needs to reach a running harness — abort, an answer to a
23
+ * question — travels back on the NEXT poll, which is why
24
+ * `RunnerHeartbeatResponse.sessionCommands` exists.
25
+ *
26
+ * 3. RUNTIME NEUTRAL. A Daytona sandbox, a customer VM and the 20x desktop are
27
+ * the same client. There is no route, field or token that only one of them
28
+ * can use. `POST /api/coding-agents/sessions/:id/ingest` in particular is
29
+ * identical for all three; that is the whole payoff of the extraction.
30
+ *
31
+ * 4. TOKENS TRAVEL IN THE ENVIRONMENT OR IN HEADERS, NEVER IN ARGV.
32
+ * `/proc/<pid>/cmdline` is world-readable; `/proc/<pid>/environ` is readable
33
+ * only by the process owner. Every credential below is either an
34
+ * `Authorization: Bearer` header or an environment variable handed to a
35
+ * child process. Do not "improve" this by adding a `--token` flag.
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ /* -------------------------------------------------------------------------- */
39
+ /* Phase 0 bootstrap shapes — REMOVED */
40
+ /* -------------------------------------------------------------------------- */
41
+ /*
42
+ * `RegisterRequest`, `RegisterResponse`, `HeartbeatRequest` and
43
+ * `HeartbeatResponse` described the Phase 0 routes
44
+ * `/api/coding-agents/harness/{register,heartbeat}`. Both routes and all four
45
+ * shapes are gone.
46
+ *
47
+ * They were never aliases of the runner protocol: they carried no
48
+ * `protocolVersion`, so that path could not be protocol-version gated, and it
49
+ * was the only registration route running in production. Deleting them removes
50
+ * the last route exempt from the versioning guarantee.
51
+ *
52
+ * The replacements are `RunnerRegisterRequest`/`RunnerRegisterResponse` and
53
+ * `RunnerHeartbeatRequest`/`RunnerHeartbeatResponse` above. `sandboxToken` and
54
+ * `sandboxId` became `runnerCredential` and `runnerId`.
55
+ */
@@ -0,0 +1,32 @@
1
+ /** The version of THIS package, as installed. */
2
+ export declare function getHarnessVersion(): string;
3
+ /**
4
+ * The version of the SANDBOX TOOLS layer (gh, @peculiar/x509, ...) currently
5
+ * installed, or null when nothing was ever synced — a self-hosted runner or
6
+ * desktop, or a sandbox that booted before this layer existed.
7
+ *
8
+ * Set by pf-bootstrap on the child environment it hands to the harness,
9
+ * `PF_INSTALLED_TOOLS_VERSION`, AFTER it resolved (fetched, reused, or fell
10
+ * back to) a tools install — never guessed by the harness itself, the same
11
+ * way `PF_HARNESS_DEGRADED` is reported rather than inferred.
12
+ */
13
+ export declare function getInstalledSandboxToolsVersion(): string | null;
14
+ /**
15
+ * The tools pin pf-bootstrap most recently TRIED to install and could not
16
+ * make stick this boot (a bad hash, a registry outage, a malformed pin —
17
+ * anything that made it fall back or keep the prior install instead). Set
18
+ * on the harness's own environment, alongside `PF_INSTALLED_TOOLS_VERSION`.
19
+ *
20
+ * Read by `observeSandboxToolsPin()` to avoid re-arming a drain for the
21
+ * EXACT SAME pin the current boot cycle already gave up on — without this,
22
+ * a standing bad pin in a control-plane secret spins every affected sandbox
23
+ * in an unbounded drain -> exit-75 -> reboot -> fallback -> still-mismatched
24
+ * loop that takes zero leases the entire time.
25
+ */
26
+ export declare function getAttemptedSandboxToolsVersion(): string | null;
27
+ /**
28
+ * The `pi` version baked into the snapshot, or null when the binary is
29
+ * absent. Reported at registration so the control plane can see the runtime
30
+ * matrix of its fleet without shelling into a sandbox.
31
+ */
32
+ export declare function getPiVersion(): string | null;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHarnessVersion = getHarnessVersion;
4
+ exports.getInstalledSandboxToolsVersion = getInstalledSandboxToolsVersion;
5
+ exports.getAttemptedSandboxToolsVersion = getAttemptedSandboxToolsVersion;
6
+ exports.getPiVersion = getPiVersion;
7
+ const node_child_process_1 = require("node:child_process");
8
+ const node_fs_1 = require("node:fs");
9
+ const node_path_1 = require("node:path");
10
+ let cachedHarnessVersion = null;
11
+ let cachedPiVersion;
12
+ /** The version of THIS package, as installed. */
13
+ function getHarnessVersion() {
14
+ if (cachedHarnessVersion) {
15
+ return cachedHarnessVersion;
16
+ }
17
+ try {
18
+ const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8'));
19
+ cachedHarnessVersion = pkg.version ?? '0.0.0';
20
+ }
21
+ catch {
22
+ cachedHarnessVersion = '0.0.0';
23
+ }
24
+ return cachedHarnessVersion;
25
+ }
26
+ /**
27
+ * The version of the SANDBOX TOOLS layer (gh, @peculiar/x509, ...) currently
28
+ * installed, or null when nothing was ever synced — a self-hosted runner or
29
+ * desktop, or a sandbox that booted before this layer existed.
30
+ *
31
+ * Set by pf-bootstrap on the child environment it hands to the harness,
32
+ * `PF_INSTALLED_TOOLS_VERSION`, AFTER it resolved (fetched, reused, or fell
33
+ * back to) a tools install — never guessed by the harness itself, the same
34
+ * way `PF_HARNESS_DEGRADED` is reported rather than inferred.
35
+ */
36
+ function getInstalledSandboxToolsVersion() {
37
+ const value = process.env.PF_INSTALLED_TOOLS_VERSION;
38
+ return typeof value === 'string' && value.length > 0 ? value : null;
39
+ }
40
+ /**
41
+ * The tools pin pf-bootstrap most recently TRIED to install and could not
42
+ * make stick this boot (a bad hash, a registry outage, a malformed pin —
43
+ * anything that made it fall back or keep the prior install instead). Set
44
+ * on the harness's own environment, alongside `PF_INSTALLED_TOOLS_VERSION`.
45
+ *
46
+ * Read by `observeSandboxToolsPin()` to avoid re-arming a drain for the
47
+ * EXACT SAME pin the current boot cycle already gave up on — without this,
48
+ * a standing bad pin in a control-plane secret spins every affected sandbox
49
+ * in an unbounded drain -> exit-75 -> reboot -> fallback -> still-mismatched
50
+ * loop that takes zero leases the entire time.
51
+ */
52
+ function getAttemptedSandboxToolsVersion() {
53
+ const value = process.env.PF_ATTEMPTED_TOOLS_VERSION;
54
+ return typeof value === 'string' && value.length > 0 ? value : null;
55
+ }
56
+ /**
57
+ * The `pi` version baked into the snapshot, or null when the binary is
58
+ * absent. Reported at registration so the control plane can see the runtime
59
+ * matrix of its fleet without shelling into a sandbox.
60
+ */
61
+ function getPiVersion() {
62
+ if (cachedPiVersion !== undefined) {
63
+ return cachedPiVersion;
64
+ }
65
+ try {
66
+ const out = (0, node_child_process_1.execFileSync)('pi', ['--version'], {
67
+ encoding: 'utf8',
68
+ timeout: 10_000,
69
+ stdio: ['ignore', 'pipe', 'ignore']
70
+ });
71
+ cachedPiVersion = out.trim() || null;
72
+ }
73
+ catch {
74
+ cachedPiVersion = null;
75
+ }
76
+ return cachedPiVersion;
77
+ }
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@peakflo/agent-harness",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.2-rc.1",
4
+ "description": "Headless Peakflo coding-agent harness. One codebase, three hosting modes: a Daytona cloud sandbox, a customer VM, and the 20x desktop.",
5
+ "license": "MIT",
6
+ "type": "commonjs",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "pf-agent-harness": "dist/cli.js"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "engines": {
18
+ "node": ">=22.19"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "registry": "https://registry.npmjs.org/"
23
+ },
24
+ "scripts": {
25
+ "build": "rm -rf dist && tsc -p tsconfig.json && node scripts/make-executable.mjs",
26
+ "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
27
+ "start": "tsx src/cli.ts start",
28
+ "clean": "rm -rf dist",
29
+ "test": "jest"
30
+ },
31
+ "devDependencies": {
32
+ "@anthropic-ai/claude-agent-sdk": "^0.3.195",
33
+ "@opencode-ai/sdk": "^1.15.13",
34
+ "@types/node": "^22.10.0",
35
+ "tsx": "^4.19.3",
36
+ "typescript": "^5.7.2",
37
+ "undici": "^7.21.0"
38
+ },
39
+ "dependencies": {
40
+ "@peculiar/x509": "^2.1.0",
41
+ "reflect-metadata": "^0.2.2"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/peakflo/workflow-builder.git",
46
+ "directory": "packages/agent-harness"
47
+ },
48
+ "homepage": "https://github.com/peakflo/workflow-builder/tree/main/packages/agent-harness",
49
+ "keywords": [
50
+ "peakflo",
51
+ "agent",
52
+ "runner",
53
+ "harness"
54
+ ]
55
+ }