harnery 0.0.1 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +84 -2
- package/bin/agent-coord +42 -0
- package/bin/agent-hook +44 -0
- package/bin/harn +40 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/commander.d.ts +128 -0
- package/dist/commander.d.ts.map +1 -0
- package/dist/commander.js +126 -0
- package/dist/commands/agents.d.ts +18 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +3946 -0
- package/dist/commands/backup.d.ts +22 -0
- package/dist/commands/backup.d.ts.map +1 -0
- package/dist/commands/backup.js +262 -0
- package/dist/commands/browse-ai.d.ts +4 -0
- package/dist/commands/browse-ai.d.ts.map +1 -0
- package/dist/commands/browse-ai.js +156 -0
- package/dist/commands/browse.d.ts +4 -0
- package/dist/commands/browse.d.ts.map +1 -0
- package/dist/commands/browse.js +590 -0
- package/dist/commands/callers.d.ts +4 -0
- package/dist/commands/callers.d.ts.map +1 -0
- package/dist/commands/callers.js +276 -0
- package/dist/commands/completion.d.ts +17 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +158 -0
- package/dist/commands/config-get.d.ts +4 -0
- package/dist/commands/config-get.d.ts.map +1 -0
- package/dist/commands/config-get.js +131 -0
- package/dist/commands/context.d.ts +11 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +185 -0
- package/dist/commands/cookies.d.ts +4 -0
- package/dist/commands/cookies.d.ts.map +1 -0
- package/dist/commands/cookies.js +140 -0
- package/dist/commands/docs.d.ts +4 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +137 -0
- package/dist/commands/doctor.d.ts +25 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +200 -0
- package/dist/commands/edit-batch.d.ts +18 -0
- package/dist/commands/edit-batch.d.ts.map +1 -0
- package/dist/commands/edit-batch.js +172 -0
- package/dist/commands/eml.d.ts +4 -0
- package/dist/commands/eml.d.ts.map +1 -0
- package/dist/commands/eml.js +428 -0
- package/dist/commands/env.d.ts +4 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +201 -0
- package/dist/commands/fetch.d.ts +4 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +99 -0
- package/dist/commands/file-history.d.ts +4 -0
- package/dist/commands/file-history.d.ts.map +1 -0
- package/dist/commands/file-history.js +152 -0
- package/dist/commands/grep.d.ts +4 -0
- package/dist/commands/grep.d.ts.map +1 -0
- package/dist/commands/grep.js +317 -0
- package/dist/commands/init.d.ts +82 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +288 -0
- package/dist/commands/outline.d.ts +4 -0
- package/dist/commands/outline.d.ts.map +1 -0
- package/dist/commands/outline.js +509 -0
- package/dist/commands/presence.d.ts +12 -0
- package/dist/commands/presence.d.ts.map +1 -0
- package/dist/commands/presence.js +123 -0
- package/dist/commands/read.d.ts +7 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +46 -0
- package/dist/commands/scratch.d.ts +4 -0
- package/dist/commands/scratch.d.ts.map +1 -0
- package/dist/commands/scratch.js +426 -0
- package/dist/commands/session.d.ts +4 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +162 -0
- package/dist/commands/sync.d.ts +24 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +275 -0
- package/dist/commands/toc.d.ts +5 -0
- package/dist/commands/toc.d.ts.map +1 -0
- package/dist/commands/toc.js +153 -0
- package/dist/commands/tokens.d.ts +4 -0
- package/dist/commands/tokens.d.ts.map +1 -0
- package/dist/commands/tokens.js +48 -0
- package/dist/commands/tunnel.d.ts +4 -0
- package/dist/commands/tunnel.d.ts.map +1 -0
- package/dist/commands/tunnel.js +513 -0
- package/dist/commands/uninstall.d.ts +22 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +126 -0
- package/dist/commands/web.d.ts +4 -0
- package/dist/commands/web.d.ts.map +1 -0
- package/dist/commands/web.js +165 -0
- package/dist/core/agents/canonical-emit.d.ts +27 -0
- package/dist/core/agents/canonical-emit.d.ts.map +1 -0
- package/dist/core/agents/canonical-emit.js +72 -0
- package/dist/core/agents/cli-emit.d.ts +27 -0
- package/dist/core/agents/cli-emit.d.ts.map +1 -0
- package/dist/core/agents/cli-emit.js +57 -0
- package/dist/core/agents/cli.d.ts +10 -0
- package/dist/core/agents/cli.d.ts.map +1 -0
- package/dist/core/agents/cli.js +757 -0
- package/dist/core/agents/codex-replay.d.ts +29 -0
- package/dist/core/agents/codex-replay.d.ts.map +1 -0
- package/dist/core/agents/codex-replay.js +138 -0
- package/dist/core/agents/coord-client.d.ts +98 -0
- package/dist/core/agents/coord-client.d.ts.map +1 -0
- package/dist/core/agents/coord-client.js +212 -0
- package/dist/core/agents/events/consume.d.ts +59 -0
- package/dist/core/agents/events/consume.d.ts.map +1 -0
- package/dist/core/agents/events/consume.js +147 -0
- package/dist/core/agents/events/emit.d.ts +42 -0
- package/dist/core/agents/events/emit.d.ts.map +1 -0
- package/dist/core/agents/events/emit.js +70 -0
- package/dist/core/agents/events/ulid.d.ts +11 -0
- package/dist/core/agents/events/ulid.d.ts.map +1 -0
- package/dist/core/agents/events/ulid.js +47 -0
- package/dist/core/agents/index.d.ts +14 -0
- package/dist/core/agents/index.d.ts.map +1 -0
- package/dist/core/agents/index.js +13 -0
- package/dist/core/agents/paths.d.ts +6 -0
- package/dist/core/agents/paths.d.ts.map +1 -0
- package/dist/core/agents/paths.js +17 -0
- package/dist/core/agents/render/prompt-context.d.ts +43 -0
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -0
- package/dist/core/agents/render/prompt-context.js +335 -0
- package/dist/core/agents/render/session-context.d.ts +39 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -0
- package/dist/core/agents/render/session-context.js +283 -0
- package/dist/core/agents/rules/claim-conflict.d.ts +35 -0
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -0
- package/dist/core/agents/rules/claim-conflict.js +244 -0
- package/dist/core/agents/rules/commit-conflict.d.ts +59 -0
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -0
- package/dist/core/agents/rules/commit-conflict.js +244 -0
- package/dist/core/agents/rules/stop-hook.d.ts +44 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -0
- package/dist/core/agents/rules/stop-hook.js +161 -0
- package/dist/core/agents/session-events.d.ts +41 -0
- package/dist/core/agents/session-events.d.ts.map +1 -0
- package/dist/core/agents/session-events.js +205 -0
- package/dist/core/agents/state/activity-log.d.ts +18 -0
- package/dist/core/agents/state/activity-log.d.ts.map +1 -0
- package/dist/core/agents/state/activity-log.js +34 -0
- package/dist/core/agents/state/council.d.ts +39 -0
- package/dist/core/agents/state/council.d.ts.map +1 -0
- package/dist/core/agents/state/council.js +216 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts +59 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-projector.js +436 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts +64 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-writer.js +271 -0
- package/dist/core/agents/state/names.d.ts +35 -0
- package/dist/core/agents/state/names.d.ts.map +1 -0
- package/dist/core/agents/state/names.js +376 -0
- package/dist/core/agents/state/pidmap.d.ts +11 -0
- package/dist/core/agents/state/pidmap.d.ts.map +1 -0
- package/dist/core/agents/state/pidmap.js +32 -0
- package/dist/core/agents/state/scratch.d.ts +27 -0
- package/dist/core/agents/state/scratch.d.ts.map +1 -0
- package/dist/core/agents/state/scratch.js +90 -0
- package/dist/core/agents/state/shell-mutation.d.ts +17 -0
- package/dist/core/agents/state/shell-mutation.d.ts.map +1 -0
- package/dist/core/agents/state/shell-mutation.js +41 -0
- package/dist/core/agents/state/stale-sweep.d.ts +16 -0
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -0
- package/dist/core/agents/state/stale-sweep.js +166 -0
- package/dist/core/config.d.ts +29 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +108 -0
- package/dist/core/hooks/cli.d.ts +21 -0
- package/dist/core/hooks/cli.d.ts.map +1 -0
- package/dist/core/hooks/cli.js +1123 -0
- package/dist/core/hooks/effects/image-capture.d.ts +43 -0
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -0
- package/dist/core/hooks/effects/image-capture.js +288 -0
- package/dist/core/hooks/effects/index.d.ts +64 -0
- package/dist/core/hooks/effects/index.d.ts.map +1 -0
- package/dist/core/hooks/effects/index.js +197 -0
- package/dist/core/hooks/events/emit.d.ts +31 -0
- package/dist/core/hooks/events/emit.d.ts.map +1 -0
- package/dist/core/hooks/events/emit.js +89 -0
- package/dist/core/hooks/events/schema.d.ts +235 -0
- package/dist/core/hooks/events/schema.d.ts.map +1 -0
- package/dist/core/hooks/events/schema.js +12 -0
- package/dist/core/hooks/events/ulid.d.ts +10 -0
- package/dist/core/hooks/events/ulid.d.ts.map +1 -0
- package/dist/core/hooks/events/ulid.js +47 -0
- package/dist/core/hooks/harness/detect.d.ts +9 -0
- package/dist/core/hooks/harness/detect.d.ts.map +1 -0
- package/dist/core/hooks/harness/detect.js +29 -0
- package/dist/core/hooks/harness/events.d.ts +45 -0
- package/dist/core/hooks/harness/events.d.ts.map +1 -0
- package/dist/core/hooks/harness/events.js +71 -0
- package/dist/core/hooks/harness/output.d.ts +46 -0
- package/dist/core/hooks/harness/output.d.ts.map +1 -0
- package/dist/core/hooks/harness/output.js +87 -0
- package/dist/core/hooks/harness/parse.d.ts +67 -0
- package/dist/core/hooks/harness/parse.d.ts.map +1 -0
- package/dist/core/hooks/harness/parse.js +132 -0
- package/dist/core/hooks/index.d.ts +8 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +7 -0
- package/dist/core/hooks/resolve/anchor.d.ts +37 -0
- package/dist/core/hooks/resolve/anchor.d.ts.map +1 -0
- package/dist/core/hooks/resolve/anchor.js +48 -0
- package/dist/core/hooks/resolve/coord-root.d.ts +6 -0
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -0
- package/dist/core/hooks/resolve/coord-root.js +27 -0
- package/dist/core/hooks/resolve/intent.d.ts +33 -0
- package/dist/core/hooks/resolve/intent.d.ts.map +1 -0
- package/dist/core/hooks/resolve/intent.js +79 -0
- package/dist/core/hooks/resolve/owner.d.ts +42 -0
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -0
- package/dist/core/hooks/resolve/owner.js +140 -0
- package/dist/core/hooks/resolve/transcript.d.ts +26 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -0
- package/dist/core/hooks/resolve/transcript.js +73 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/lib/agent-browser/client.d.ts +99 -0
- package/dist/lib/agent-browser/client.d.ts.map +1 -0
- package/dist/lib/agent-browser/client.js +177 -0
- package/dist/lib/agent-browser/index.d.ts +2 -0
- package/dist/lib/agent-browser/index.d.ts.map +1 -0
- package/dist/lib/agent-browser/index.js +1 -0
- package/dist/lib/browser/client.d.ts +193 -0
- package/dist/lib/browser/client.d.ts.map +1 -0
- package/dist/lib/browser/client.js +325 -0
- package/dist/lib/browser/dev-overlay.d.ts +23 -0
- package/dist/lib/browser/dev-overlay.d.ts.map +1 -0
- package/dist/lib/browser/dev-overlay.js +153 -0
- package/dist/lib/browser/index.d.ts +5 -0
- package/dist/lib/browser/index.d.ts.map +1 -0
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/browser/layout.d.ts +79 -0
- package/dist/lib/browser/layout.d.ts.map +1 -0
- package/dist/lib/browser/layout.js +220 -0
- package/dist/lib/browser/visibility.d.ts +86 -0
- package/dist/lib/browser/visibility.d.ts.map +1 -0
- package/dist/lib/browser/visibility.js +333 -0
- package/dist/lib/browser/visual-diff.d.ts +38 -0
- package/dist/lib/browser/visual-diff.d.ts.map +1 -0
- package/dist/lib/browser/visual-diff.js +107 -0
- package/dist/lib/completion/bash.d.ts +25 -0
- package/dist/lib/completion/bash.d.ts.map +1 -0
- package/dist/lib/completion/bash.js +284 -0
- package/dist/lib/completion/fish.d.ts +16 -0
- package/dist/lib/completion/fish.d.ts.map +1 -0
- package/dist/lib/completion/fish.js +118 -0
- package/dist/lib/completion/index.d.ts +5 -0
- package/dist/lib/completion/index.d.ts.map +1 -0
- package/dist/lib/completion/index.js +4 -0
- package/dist/lib/completion/walk.d.ts +68 -0
- package/dist/lib/completion/walk.d.ts.map +1 -0
- package/dist/lib/completion/walk.js +102 -0
- package/dist/lib/completion/zsh.d.ts +13 -0
- package/dist/lib/completion/zsh.d.ts.map +1 -0
- package/dist/lib/completion/zsh.js +249 -0
- package/dist/lib/context/index.d.ts +107 -0
- package/dist/lib/context/index.d.ts.map +1 -0
- package/dist/lib/context/index.js +275 -0
- package/dist/lib/cookies/client.d.ts +131 -0
- package/dist/lib/cookies/client.d.ts.map +1 -0
- package/dist/lib/cookies/client.js +239 -0
- package/dist/lib/cookies/index.d.ts +2 -0
- package/dist/lib/cookies/index.d.ts.map +1 -0
- package/dist/lib/cookies/index.js +1 -0
- package/dist/lib/council/index.d.ts +266 -0
- package/dist/lib/council/index.d.ts.map +1 -0
- package/dist/lib/council/index.js +674 -0
- package/dist/lib/docs-index.d.ts +28 -0
- package/dist/lib/docs-index.d.ts.map +1 -0
- package/dist/lib/docs-index.js +169 -0
- package/dist/lib/docs-lint.d.ts +26 -0
- package/dist/lib/docs-lint.d.ts.map +1 -0
- package/dist/lib/docs-lint.js +378 -0
- package/dist/lib/docs-sweep.d.ts +34 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -0
- package/dist/lib/docs-sweep.js +304 -0
- package/dist/lib/docs.d.ts +27 -0
- package/dist/lib/docs.d.ts.map +1 -0
- package/dist/lib/docs.js +142 -0
- package/dist/lib/env.d.ts +11 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +12 -0
- package/dist/lib/exec.d.ts +32 -0
- package/dist/lib/exec.d.ts.map +1 -0
- package/dist/lib/exec.js +54 -0
- package/dist/lib/format.d.ts +29 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +139 -0
- package/dist/lib/http/client.d.ts +56 -0
- package/dist/lib/http/client.d.ts.map +1 -0
- package/dist/lib/http/client.js +160 -0
- package/dist/lib/http/index.d.ts +2 -0
- package/dist/lib/http/index.d.ts.map +1 -0
- package/dist/lib/http/index.js +1 -0
- package/dist/lib/identities/index.d.ts +77 -0
- package/dist/lib/identities/index.d.ts.map +1 -0
- package/dist/lib/identities/index.js +190 -0
- package/dist/lib/machine.d.ts +19 -0
- package/dist/lib/machine.d.ts.map +1 -0
- package/dist/lib/machine.js +61 -0
- package/dist/lib/presence.d.ts +48 -0
- package/dist/lib/presence.d.ts.map +1 -0
- package/dist/lib/presence.js +123 -0
- package/dist/lib/readability/client.d.ts +39 -0
- package/dist/lib/readability/client.d.ts.map +1 -0
- package/dist/lib/readability/client.js +121 -0
- package/dist/lib/readability/index.d.ts +2 -0
- package/dist/lib/readability/index.d.ts.map +1 -0
- package/dist/lib/readability/index.js +1 -0
- package/dist/lib/scratch/index.d.ts +74 -0
- package/dist/lib/scratch/index.d.ts.map +1 -0
- package/dist/lib/scratch/index.js +393 -0
- package/dist/lib/tunnel/gate.d.ts +12 -0
- package/dist/lib/tunnel/gate.d.ts.map +1 -0
- package/dist/lib/tunnel/gate.js +101 -0
- package/dist/lib/tunnel/state.d.ts +34 -0
- package/dist/lib/tunnel/state.d.ts.map +1 -0
- package/dist/lib/tunnel/state.js +132 -0
- package/package.json +160 -8
- package/schemas/.gitkeep +0 -0
- package/schemas/config.schema.json +109 -0
- package/src/cli.ts +22 -0
- package/src/commander.ts +242 -0
- package/src/commands/.gitkeep +0 -0
- package/src/commands/agents.ts +4567 -0
- package/src/commands/backup.ts +305 -0
- package/src/commands/browse-ai.ts +198 -0
- package/src/commands/browse.ts +849 -0
- package/src/commands/callers.ts +363 -0
- package/src/commands/completion.ts +193 -0
- package/src/commands/config-get.ts +161 -0
- package/src/commands/context.ts +209 -0
- package/src/commands/cookies.ts +198 -0
- package/src/commands/docs.ts +174 -0
- package/src/commands/doctor.ts +231 -0
- package/src/commands/edit-batch.ts +233 -0
- package/src/commands/eml.ts +519 -0
- package/src/commands/env.ts +254 -0
- package/src/commands/fetch.ts +136 -0
- package/src/commands/file-history.ts +202 -0
- package/src/commands/grep.ts +371 -0
- package/src/commands/init.ts +335 -0
- package/src/commands/outline.ts +583 -0
- package/src/commands/presence.ts +152 -0
- package/src/commands/read.ts +64 -0
- package/src/commands/scratch.ts +445 -0
- package/src/commands/session.ts +187 -0
- package/src/commands/sync.ts +306 -0
- package/src/commands/toc.ts +218 -0
- package/src/commands/tokens.ts +79 -0
- package/src/commands/tunnel.ts +633 -0
- package/src/commands/uninstall.ts +144 -0
- package/src/commands/web.ts +193 -0
- package/src/core/agents/canonical-emit.ts +77 -0
- package/src/core/agents/cli-emit.ts +64 -0
- package/src/core/agents/cli.ts +838 -0
- package/src/core/agents/codex-replay.ts +163 -0
- package/src/core/agents/coord-client.ts +249 -0
- package/src/core/agents/events/consume.ts +196 -0
- package/src/core/agents/events/emit.ts +108 -0
- package/src/core/agents/events/ulid.ts +51 -0
- package/src/core/agents/index.ts +14 -0
- package/src/core/agents/paths.ts +16 -0
- package/src/core/agents/render/prompt-context.ts +401 -0
- package/src/core/agents/render/session-context.ts +341 -0
- package/src/core/agents/rules/claim-conflict.ts +282 -0
- package/src/core/agents/rules/commit-conflict.ts +303 -0
- package/src/core/agents/rules/stop-hook.ts +229 -0
- package/src/core/agents/session-events.ts +228 -0
- package/src/core/agents/state/activity-log.ts +33 -0
- package/src/core/agents/state/council.ts +265 -0
- package/src/core/agents/state/heartbeat-projector.ts +488 -0
- package/src/core/agents/state/heartbeat-writer.ts +333 -0
- package/src/core/agents/state/names.ts +399 -0
- package/src/core/agents/state/pidmap.ts +38 -0
- package/src/core/agents/state/scratch.ts +121 -0
- package/src/core/agents/state/shell-mutation.ts +44 -0
- package/src/core/agents/state/stale-sweep.ts +190 -0
- package/src/core/config.ts +111 -0
- package/src/core/hooks/cli.ts +1247 -0
- package/src/core/hooks/effects/image-capture.ts +330 -0
- package/src/core/hooks/effects/index.ts +210 -0
- package/src/core/hooks/events/emit.ts +120 -0
- package/src/core/hooks/events/schema.ts +430 -0
- package/src/core/hooks/events/ulid.ts +51 -0
- package/src/core/hooks/harness/detect.ts +30 -0
- package/src/core/hooks/harness/events.ts +102 -0
- package/src/core/hooks/harness/output.ts +100 -0
- package/src/core/hooks/harness/parse.ts +180 -0
- package/src/core/hooks/index.ts +16 -0
- package/src/core/hooks/resolve/anchor.ts +51 -0
- package/src/core/hooks/resolve/coord-root.ts +25 -0
- package/src/core/hooks/resolve/intent.ts +89 -0
- package/src/core/hooks/resolve/owner.ts +140 -0
- package/src/core/hooks/resolve/transcript.ts +72 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/index.ts +15 -0
- package/src/lib/agent-browser/client.ts +239 -0
- package/src/lib/agent-browser/index.ts +1 -0
- package/src/lib/browser/client.ts +449 -0
- package/src/lib/browser/dev-overlay.ts +207 -0
- package/src/lib/browser/index.ts +24 -0
- package/src/lib/browser/layout.ts +288 -0
- package/src/lib/browser/visibility.ts +419 -0
- package/src/lib/browser/visual-diff.ts +150 -0
- package/src/lib/completion/bash.ts +291 -0
- package/src/lib/completion/fish.ts +134 -0
- package/src/lib/completion/index.ts +10 -0
- package/src/lib/completion/walk.ts +184 -0
- package/src/lib/completion/zsh.ts +262 -0
- package/src/lib/context/index.ts +386 -0
- package/src/lib/cookies/client.ts +301 -0
- package/src/lib/cookies/index.ts +13 -0
- package/src/lib/council/index.ts +803 -0
- package/src/lib/docs-index.ts +216 -0
- package/src/lib/docs-lint.ts +413 -0
- package/src/lib/docs-sweep.ts +348 -0
- package/src/lib/docs.ts +199 -0
- package/src/lib/env.ts +12 -0
- package/src/lib/exec.ts +74 -0
- package/src/lib/format.ts +147 -0
- package/src/lib/http/client.ts +211 -0
- package/src/lib/http/index.ts +1 -0
- package/src/lib/identities/index.ts +210 -0
- package/src/lib/machine.ts +61 -0
- package/src/lib/presence.ts +154 -0
- package/src/lib/readability/client.ts +169 -0
- package/src/lib/readability/index.ts +5 -0
- package/src/lib/readability/turndown-plugin-gfm.d.ts +10 -0
- package/src/lib/scratch/index.ts +470 -0
- package/src/lib/tunnel/gate.ts +113 -0
- package/src/lib/tunnel/state.ts +167 -0
- package/src/web/.gitkeep +0 -0
- package/index.js +0 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TS implementation of the heartbeat-mutating actions. Replaces the previous
|
|
3
|
+
* flock-serialized bash writes with atomic temp+rename in Bun. Phase 6 of the
|
|
4
|
+
* agent-hooks/agent-coord refactor.
|
|
5
|
+
*
|
|
6
|
+
* Atomicity guarantee: every write goes via a `<path>.tmp.<pid>` sibling +
|
|
7
|
+
* `renameSync`. POSIX rename is atomic within a filesystem, so concurrent
|
|
8
|
+
* readers either see the pre-write file or the post-write file but never a
|
|
9
|
+
* half-written intermediate. Concurrent writers serialize via the rename
|
|
10
|
+
* (last write wins).
|
|
11
|
+
*
|
|
12
|
+
* Owner identity invariant: every action operates on `.harnery/active/<instance_id>.json`
|
|
13
|
+
* (the file IS the heartbeat). No mutations happen elsewhere.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
existsSync,
|
|
18
|
+
mkdirSync,
|
|
19
|
+
readdirSync,
|
|
20
|
+
readFileSync,
|
|
21
|
+
renameSync,
|
|
22
|
+
unlinkSync,
|
|
23
|
+
writeFileSync,
|
|
24
|
+
} from "node:fs";
|
|
25
|
+
import { dirname, join } from "node:path";
|
|
26
|
+
import { emit } from "../events/emit.ts";
|
|
27
|
+
|
|
28
|
+
/** Inline harness normalizer (mirrors canonical-emit.normalizeHarness), kept
|
|
29
|
+
* local so the writer's only cross-module dep is the in-process emit(). */
|
|
30
|
+
function harnessOf(platform: string | undefined): "claude-code" | "cursor" | "codex" {
|
|
31
|
+
if (platform === "cursor") return "cursor";
|
|
32
|
+
if (platform === "codex") return "codex";
|
|
33
|
+
return "claude-code";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Inverse of harnessOf: maps the canonical harness ("claude-code"/"cursor"/
|
|
37
|
+
* "codex") to the legacy underscore platform label stored on the heartbeat.
|
|
38
|
+
* Mirrors heartbeat-projector.harnessToPlatform so a healed heartbeat carries
|
|
39
|
+
* the same platform value projection would have written. */
|
|
40
|
+
function harnessToPlatform(harness: string | undefined): string {
|
|
41
|
+
if (harness === "cursor") return "cursor";
|
|
42
|
+
if (harness === "codex") return "codex";
|
|
43
|
+
return "claude_code";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Emit a canonical `health.*` event for an actual self-heal write. This is the
|
|
48
|
+
* single source of truth for heal telemetry across BOTH the live auto-heal
|
|
49
|
+
* (the pre-tool-use hook → agent-coord heal-heartbeat) and the manual `harn agents
|
|
50
|
+
* heal` path. Write-only by construction (callers only invoke it after a real
|
|
51
|
+
* write), so an already-correct heal records nothing.
|
|
52
|
+
* Best-effort: never throws into the heal path.
|
|
53
|
+
*/
|
|
54
|
+
function emitHealthHeal(
|
|
55
|
+
coordRoot: string,
|
|
56
|
+
type: "health.pidmap_heal" | "health.heartbeat_heal",
|
|
57
|
+
instanceId: string,
|
|
58
|
+
hb: Heartbeat | null,
|
|
59
|
+
data: Record<string, unknown>,
|
|
60
|
+
): void {
|
|
61
|
+
try {
|
|
62
|
+
emit(coordRoot, {
|
|
63
|
+
event_type: type,
|
|
64
|
+
instance_id: instanceId,
|
|
65
|
+
session_id: hb?.session_id ?? instanceId,
|
|
66
|
+
harness: harnessOf(hb?.platform),
|
|
67
|
+
source: "agent-coord",
|
|
68
|
+
data,
|
|
69
|
+
});
|
|
70
|
+
} catch {
|
|
71
|
+
/* telemetry only, never break a heal */
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface Heartbeat {
|
|
76
|
+
schema_version?: number;
|
|
77
|
+
instance_id: string;
|
|
78
|
+
name?: string;
|
|
79
|
+
kind?: string;
|
|
80
|
+
agent_id?: string;
|
|
81
|
+
session_id: string;
|
|
82
|
+
subagent_call_id?: string;
|
|
83
|
+
model?: string;
|
|
84
|
+
platform?: string;
|
|
85
|
+
started_at?: string;
|
|
86
|
+
last_heartbeat: string;
|
|
87
|
+
files_touched: string[];
|
|
88
|
+
task?: string;
|
|
89
|
+
task_updated_at?: string | null;
|
|
90
|
+
last_status_at?: string;
|
|
91
|
+
turn_summary?: string | null;
|
|
92
|
+
turn_summary_updated_at?: string | null;
|
|
93
|
+
last_tool?: string;
|
|
94
|
+
last_tool_target?: string;
|
|
95
|
+
last_tool_at?: string;
|
|
96
|
+
current_turn_id?: string;
|
|
97
|
+
parent_instance_id?: string;
|
|
98
|
+
[extra: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function heartbeatPath(coordRoot: string, instanceId: string): string {
|
|
102
|
+
return join(coordRoot, ".harnery", "active", `${instanceId}.json`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function nowIsoSeconds(): string {
|
|
106
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function atomicWrite(path: string, content: string): void {
|
|
110
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
111
|
+
const tmp = `${path}.tmp.${process.pid}`;
|
|
112
|
+
writeFileSync(tmp, content, "utf8");
|
|
113
|
+
renameSync(tmp, path);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function readHeartbeat(coordRoot: string, instanceId: string): Heartbeat | null {
|
|
117
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
118
|
+
if (!existsSync(path)) return null;
|
|
119
|
+
try {
|
|
120
|
+
return JSON.parse(readFileSync(path, "utf8")) as Heartbeat;
|
|
121
|
+
} catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function mutate(
|
|
127
|
+
coordRoot: string,
|
|
128
|
+
instanceId: string,
|
|
129
|
+
fn: (hb: Heartbeat) => Heartbeat,
|
|
130
|
+
): Heartbeat | null {
|
|
131
|
+
const hb = readHeartbeat(coordRoot, instanceId);
|
|
132
|
+
if (!hb) return null;
|
|
133
|
+
const next = fn(hb);
|
|
134
|
+
next.last_heartbeat = nowIsoSeconds();
|
|
135
|
+
atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(next, null, 2));
|
|
136
|
+
return next;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function setTask(coordRoot: string, instanceId: string, task: string): Heartbeat | null {
|
|
140
|
+
return mutate(coordRoot, instanceId, (hb) => {
|
|
141
|
+
const cleared = !task || task.length === 0;
|
|
142
|
+
return {
|
|
143
|
+
...hb,
|
|
144
|
+
task: cleared ? undefined : task,
|
|
145
|
+
task_updated_at: nowIsoSeconds(),
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function stampStatusCheck(coordRoot: string, instanceId: string): Heartbeat | null {
|
|
151
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
152
|
+
...hb,
|
|
153
|
+
last_status_at: nowIsoSeconds(),
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function setTurnSummary(
|
|
158
|
+
coordRoot: string,
|
|
159
|
+
instanceId: string,
|
|
160
|
+
summary: string,
|
|
161
|
+
): Heartbeat | null {
|
|
162
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
163
|
+
...hb,
|
|
164
|
+
turn_summary: summary,
|
|
165
|
+
turn_summary_updated_at: nowIsoSeconds(),
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function releaseClaim(
|
|
170
|
+
coordRoot: string,
|
|
171
|
+
instanceId: string,
|
|
172
|
+
path: string,
|
|
173
|
+
): Heartbeat | null {
|
|
174
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
175
|
+
...hb,
|
|
176
|
+
files_touched: (hb.files_touched ?? []).filter((p) => p !== path),
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Session-group-wide unclaim. Walks every heartbeat sharing `groupId`
|
|
182
|
+
* (parent's session_id == group_id;
|
|
183
|
+
* subagents inherit it) and removes the path from each one's files_touched.
|
|
184
|
+
* Idempotent: heartbeats that don't hold the path are untouched.
|
|
185
|
+
*
|
|
186
|
+
* This is the Option B fix for post-commit's pid-map attribution hole: a
|
|
187
|
+
* subagent-held claim that doesn't live on the parent's heartbeat still gets
|
|
188
|
+
* pruned because the walk covers the whole group.
|
|
189
|
+
*/
|
|
190
|
+
export function groupUnclaim(coordRoot: string, groupId: string, path: string): void {
|
|
191
|
+
if (!groupId || !path) return;
|
|
192
|
+
const activeDir = join(coordRoot, ".harnery", "active");
|
|
193
|
+
if (!existsSync(activeDir)) return;
|
|
194
|
+
for (const f of readdirSync(activeDir)) {
|
|
195
|
+
if (!f.endsWith(".json")) continue;
|
|
196
|
+
const hbPath = join(activeDir, f);
|
|
197
|
+
let body: Record<string, unknown>;
|
|
198
|
+
try {
|
|
199
|
+
body = JSON.parse(readFileSync(hbPath, "utf8")) as Record<string, unknown>;
|
|
200
|
+
} catch {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const peerSession =
|
|
204
|
+
(body.session_id as string | undefined) ?? (body.instance_id as string | undefined);
|
|
205
|
+
if (peerSession !== groupId) continue;
|
|
206
|
+
const files = (body.files_touched as string[] | undefined) ?? [];
|
|
207
|
+
const next = files.filter((p) => p !== path);
|
|
208
|
+
if (next.length === files.length) continue;
|
|
209
|
+
body.files_touched = next;
|
|
210
|
+
try {
|
|
211
|
+
const tmp = `${hbPath}.tmp.${process.pid}`;
|
|
212
|
+
writeFileSync(tmp, JSON.stringify(body, null, 2), "utf8");
|
|
213
|
+
renameSync(tmp, hbPath);
|
|
214
|
+
} catch {
|
|
215
|
+
/* silent */
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function killHeartbeat(coordRoot: string, instanceId: string): boolean {
|
|
221
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
222
|
+
if (!existsSync(path)) return false;
|
|
223
|
+
try {
|
|
224
|
+
unlinkSync(path);
|
|
225
|
+
return true;
|
|
226
|
+
} catch {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function healPidmap(coordRoot: string, instanceId: string, pid: number): void {
|
|
232
|
+
const dir = join(coordRoot, ".harnery", "pid-map");
|
|
233
|
+
mkdirSync(dir, { recursive: true });
|
|
234
|
+
const hb = readHeartbeat(coordRoot, instanceId);
|
|
235
|
+
const platform = hb?.platform ?? "claude_code";
|
|
236
|
+
const pmPath = join(dir, String(pid));
|
|
237
|
+
// Drift guard: only write + emit telemetry when the entry is missing or
|
|
238
|
+
// points at a different owner. Without this, a per-tool-call heal would
|
|
239
|
+
// flood health.pidmap_heal on every call.
|
|
240
|
+
let existingOwner = "";
|
|
241
|
+
try {
|
|
242
|
+
if (existsSync(pmPath)) existingOwner = readFileSync(pmPath, "utf8").split("\t")[0] ?? "";
|
|
243
|
+
} catch {
|
|
244
|
+
/* treat as missing */
|
|
245
|
+
}
|
|
246
|
+
if (existingOwner === instanceId) return;
|
|
247
|
+
atomicWrite(pmPath, `${instanceId}\t${platform}`);
|
|
248
|
+
emitHealthHeal(coordRoot, "health.pidmap_heal", instanceId, hb, {
|
|
249
|
+
reason: existingOwner ? "stale" : "missing",
|
|
250
|
+
pid,
|
|
251
|
+
kind: "pidmap",
|
|
252
|
+
...(existingOwner ? { prior: existingOwner.slice(0, 8) } : {}),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function healHeartbeat(
|
|
257
|
+
coordRoot: string,
|
|
258
|
+
instanceId: string,
|
|
259
|
+
sessionId?: string,
|
|
260
|
+
model?: string,
|
|
261
|
+
harness?: string,
|
|
262
|
+
): Heartbeat | null {
|
|
263
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
264
|
+
if (existsSync(path)) {
|
|
265
|
+
// Already alive, return it.
|
|
266
|
+
return readHeartbeat(coordRoot, instanceId);
|
|
267
|
+
}
|
|
268
|
+
const now = nowIsoSeconds();
|
|
269
|
+
|
|
270
|
+
// Recover name + kind from .name-history if present (idempotent across
|
|
271
|
+
// sweeps: same instance_id always gets the same name).
|
|
272
|
+
let name = "";
|
|
273
|
+
let kind = "session";
|
|
274
|
+
let agentId = "";
|
|
275
|
+
try {
|
|
276
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
277
|
+
const { resolveName } = require("./names.ts") as typeof import("./names.ts");
|
|
278
|
+
const resolved = resolveName(coordRoot, instanceId, sessionId);
|
|
279
|
+
if (resolved) {
|
|
280
|
+
name = resolved.name;
|
|
281
|
+
kind = resolved.kind;
|
|
282
|
+
// subagent kind: agent_id == instance_id. Else (session/transient): no id stamp.
|
|
283
|
+
if (resolved.kind === "subagent") agentId = instanceId;
|
|
284
|
+
}
|
|
285
|
+
} catch {
|
|
286
|
+
/* names module unavailable, fall back to empty */
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const hb: Heartbeat = {
|
|
290
|
+
schema_version: 1,
|
|
291
|
+
instance_id: instanceId,
|
|
292
|
+
session_id: sessionId ?? instanceId,
|
|
293
|
+
name,
|
|
294
|
+
kind,
|
|
295
|
+
agent_id: agentId,
|
|
296
|
+
model: model ?? "",
|
|
297
|
+
started_at: now,
|
|
298
|
+
last_heartbeat: now,
|
|
299
|
+
files_touched: [],
|
|
300
|
+
// Default to claude_code only when the caller can't tell us the harness
|
|
301
|
+
// (e.g. manual `harn agents heal`). The live tool.pre_use heal threads the
|
|
302
|
+
// detected harness so a pruned Cursor/Codex heartbeat is recreated with
|
|
303
|
+
// the correct platform instead of being mislabeled claude_code.
|
|
304
|
+
platform: harnessToPlatform(harness),
|
|
305
|
+
};
|
|
306
|
+
atomicWrite(path, JSON.stringify(hb, null, 2));
|
|
307
|
+
// Write-only telemetry: only the actual-recreate branch reaches here (the
|
|
308
|
+
// already-alive case returned above), so this records exactly the heals that
|
|
309
|
+
// happened.
|
|
310
|
+
emitHealthHeal(coordRoot, "health.heartbeat_heal", instanceId, hb, {
|
|
311
|
+
reason: "missing",
|
|
312
|
+
kind: "heartbeat",
|
|
313
|
+
});
|
|
314
|
+
return hb;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Stamp the heartbeat with the most-recent tool name + target. Written from
|
|
319
|
+
* the post-tool-use hook.
|
|
320
|
+
*/
|
|
321
|
+
export function stampToolActivity(
|
|
322
|
+
coordRoot: string,
|
|
323
|
+
instanceId: string,
|
|
324
|
+
toolName: string,
|
|
325
|
+
target: string,
|
|
326
|
+
): Heartbeat | null {
|
|
327
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
328
|
+
...hb,
|
|
329
|
+
last_tool: toolName,
|
|
330
|
+
last_tool_target: target,
|
|
331
|
+
last_tool_at: nowIsoSeconds(),
|
|
332
|
+
}));
|
|
333
|
+
}
|