harnery 0.0.1 → 0.2.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/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 +494 -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 +32 -0
- package/dist/lib/readability/client.d.ts.map +1 -0
- package/dist/lib/readability/client.js +119 -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 +564 -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 +156 -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,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stale-sweep: prune dead heartbeats + orphaned pid-map + .last-peer-hash
|
|
3
|
+
* files.
|
|
4
|
+
*
|
|
5
|
+
* Fires at session.start to clean up crashed-peer detritus before the new
|
|
6
|
+
* session's UX layer reads peer state.
|
|
7
|
+
*
|
|
8
|
+
* Freshness threshold defaults to 600s; configurable via
|
|
9
|
+
* HARNERY_AGENT_COORD_FRESHNESS env var.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { existsSync, readdirSync, readFileSync, statSync, unlinkSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { coordEnv } from "../../../lib/env.ts";
|
|
15
|
+
import { emit } from "../events/emit.ts";
|
|
16
|
+
|
|
17
|
+
const DEFAULT_FRESHNESS_SECS = 600;
|
|
18
|
+
|
|
19
|
+
/** platform → harness, for the swept-event envelope (mirrors heartbeat-writer's harnessOf). */
|
|
20
|
+
function harnessFromPlatform(platform: unknown): "claude-code" | "cursor" | "codex" {
|
|
21
|
+
if (platform === "cursor") return "cursor";
|
|
22
|
+
if (platform === "codex") return "codex";
|
|
23
|
+
return "claude-code";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Emit a best-effort health.heartbeat_swept event. Telemetry only, never throws. */
|
|
27
|
+
function emitSwept(
|
|
28
|
+
coordRoot: string,
|
|
29
|
+
instanceId: string,
|
|
30
|
+
harness: "claude-code" | "cursor" | "codex",
|
|
31
|
+
sessionId: string,
|
|
32
|
+
reason: "stale" | "unparseable" | "missing_ts",
|
|
33
|
+
ageSecs?: number,
|
|
34
|
+
): void {
|
|
35
|
+
try {
|
|
36
|
+
emit(coordRoot, {
|
|
37
|
+
event_type: "health.heartbeat_swept",
|
|
38
|
+
instance_id: instanceId,
|
|
39
|
+
session_id: sessionId,
|
|
40
|
+
harness,
|
|
41
|
+
source: "agent-coord",
|
|
42
|
+
data: { reason, ...(ageSecs !== undefined ? { age_secs: ageSecs } : {}) },
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
44
|
+
} as Parameters<typeof emit>[1]);
|
|
45
|
+
} catch {
|
|
46
|
+
/* telemetry only, never break the sweep */
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** File mtime in epoch-seconds, or +Infinity if it can't be read (treat as fresh → don't reap). */
|
|
51
|
+
function mtimeSecs(path: string): number {
|
|
52
|
+
try {
|
|
53
|
+
return Math.floor(statSync(path).mtimeMs / 1000);
|
|
54
|
+
} catch {
|
|
55
|
+
return Number.POSITIVE_INFINITY;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function staleSweep(coordRoot: string): {
|
|
60
|
+
heartbeatsRemoved: string[];
|
|
61
|
+
pidmapsRemoved: number;
|
|
62
|
+
peerHashesRemoved: number;
|
|
63
|
+
} {
|
|
64
|
+
const heartbeatsRemoved: string[] = [];
|
|
65
|
+
let pidmapsRemoved = 0;
|
|
66
|
+
let peerHashesRemoved = 0;
|
|
67
|
+
|
|
68
|
+
const freshness = Number.parseInt(
|
|
69
|
+
coordEnv("AGENT_COORD_FRESHNESS") ?? String(DEFAULT_FRESHNESS_SECS),
|
|
70
|
+
10,
|
|
71
|
+
);
|
|
72
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
73
|
+
const cutoff =
|
|
74
|
+
nowSec - (Number.isFinite(freshness) && freshness > 0 ? freshness : DEFAULT_FRESHNESS_SECS);
|
|
75
|
+
|
|
76
|
+
// 1. Prune stale heartbeats from the canonical `.harnery/active/` dir.
|
|
77
|
+
//
|
|
78
|
+
// Two deletion regimes, deliberately asymmetric:
|
|
79
|
+
// • Valid JSON with an OLD last_heartbeat → the legitimate dead/idle-agent
|
|
80
|
+
// prune. Delete (this is the whole point of stale-sweep; idle agents get
|
|
81
|
+
// healed back on their next tool call).
|
|
82
|
+
// • Can't-trust-content (JSON.parse failed, or no/NaN last_heartbeat) →
|
|
83
|
+
// fall back to file MTIME as the liveness signal. Only delete if the file
|
|
84
|
+
// is also mtime-old. A fresh-mtime file failing to parse is almost always
|
|
85
|
+
// a transient (mid-write / partial read), and deleting it would nuke a
|
|
86
|
+
// LIVE agent's heartbeat, the worst possible outcome. So: never reap a
|
|
87
|
+
// fresh file on a content failure.
|
|
88
|
+
// Every deletion now emits health.heartbeat_swept so the lifecycle is
|
|
89
|
+
// auditable (sweeps used to be silent; see the swept-event schema doc).
|
|
90
|
+
const liveInstanceIds = new Set<string>();
|
|
91
|
+
const d = join(coordRoot, ".harnery", "active");
|
|
92
|
+
if (existsSync(d)) {
|
|
93
|
+
for (const f of readdirSync(d)) {
|
|
94
|
+
if (!f.endsWith(".json")) continue;
|
|
95
|
+
const path = join(d, f);
|
|
96
|
+
const idFromFile = f.replace(/\.json$/, "");
|
|
97
|
+
let parsed: {
|
|
98
|
+
instance_id?: string;
|
|
99
|
+
last_heartbeat?: string;
|
|
100
|
+
platform?: unknown;
|
|
101
|
+
session_id?: string;
|
|
102
|
+
} | null = null;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
105
|
+
} catch {
|
|
106
|
+
parsed = null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (parsed === null) {
|
|
110
|
+
// Unparseable: only reap if the file itself is mtime-old.
|
|
111
|
+
if (mtimeSecs(path) < cutoff) {
|
|
112
|
+
try {
|
|
113
|
+
unlinkSync(path);
|
|
114
|
+
heartbeatsRemoved.push(f);
|
|
115
|
+
emitSwept(coordRoot, idFromFile, "claude-code", idFromFile, "unparseable");
|
|
116
|
+
} catch {
|
|
117
|
+
/* swallow */
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const instanceId = parsed.instance_id ?? idFromFile;
|
|
124
|
+
const harness = harnessFromPlatform(parsed.platform);
|
|
125
|
+
const sessionId = parsed.session_id ?? instanceId;
|
|
126
|
+
const ts = parsed.last_heartbeat
|
|
127
|
+
? Math.floor(Date.parse(parsed.last_heartbeat) / 1000)
|
|
128
|
+
: Number.NaN;
|
|
129
|
+
|
|
130
|
+
if (!parsed.last_heartbeat || !Number.isFinite(ts)) {
|
|
131
|
+
// No / NaN last_heartbeat: can't trust content; gate on mtime.
|
|
132
|
+
if (mtimeSecs(path) < cutoff) {
|
|
133
|
+
unlinkSync(path);
|
|
134
|
+
heartbeatsRemoved.push(f);
|
|
135
|
+
emitSwept(coordRoot, instanceId, harness, sessionId, "missing_ts");
|
|
136
|
+
} else if (parsed.instance_id) {
|
|
137
|
+
liveInstanceIds.add(parsed.instance_id);
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (ts < cutoff) {
|
|
143
|
+
// Legitimate stale prune (valid timestamp, past the freshness cutoff).
|
|
144
|
+
unlinkSync(path);
|
|
145
|
+
heartbeatsRemoved.push(f);
|
|
146
|
+
emitSwept(coordRoot, instanceId, harness, sessionId, "stale", nowSec - ts);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (parsed.instance_id) liveInstanceIds.add(parsed.instance_id);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 2. Prune pid-map entries whose instance has no live heartbeat.
|
|
155
|
+
const pidmapDir = join(coordRoot, ".harnery", "pid-map");
|
|
156
|
+
if (existsSync(pidmapDir)) {
|
|
157
|
+
for (const f of readdirSync(pidmapDir)) {
|
|
158
|
+
const path = join(pidmapDir, f);
|
|
159
|
+
try {
|
|
160
|
+
const row = readFileSync(path, "utf8").trim();
|
|
161
|
+
const ownerId = row.split("\t")[0]?.trim() ?? "";
|
|
162
|
+
if (!ownerId || !liveInstanceIds.has(ownerId)) {
|
|
163
|
+
unlinkSync(path);
|
|
164
|
+
pidmapsRemoved += 1;
|
|
165
|
+
}
|
|
166
|
+
} catch {
|
|
167
|
+
/* swallow */
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 3. Prune .last-peer-hash files for dead owners.
|
|
173
|
+
const agentsDir = join(coordRoot, ".harnery");
|
|
174
|
+
if (existsSync(agentsDir)) {
|
|
175
|
+
for (const f of readdirSync(agentsDir)) {
|
|
176
|
+
if (!f.startsWith(".last-peer-hash.")) continue;
|
|
177
|
+
const owner = f.slice(".last-peer-hash.".length);
|
|
178
|
+
if (!liveInstanceIds.has(owner)) {
|
|
179
|
+
try {
|
|
180
|
+
unlinkSync(join(agentsDir, f));
|
|
181
|
+
peerHashesRemoved += 1;
|
|
182
|
+
} catch {
|
|
183
|
+
/* swallow */
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return { heartbeatsRemoved, pidmapsRemoved, peerHashesRemoved };
|
|
190
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `.harnery/config.jsonc` reader: the host-project config the coord/hook layer
|
|
3
|
+
* consults when it can't see the consumer CLI's own process.
|
|
4
|
+
*
|
|
5
|
+
* The single field this module owns today is `binName`: the host CLI's binary
|
|
6
|
+
* name (e.g. `myapp`), used in user-facing strings the agent reads and runs:
|
|
7
|
+
* council prompts, end-of-turn nudges, command help/errors. The coord binaries
|
|
8
|
+
* (`agent-hook`, `agent-coord`) and the web UI run as harnery itself, so they
|
|
9
|
+
* have no other way to learn the consumer's bin name; `harn init` stamps it here
|
|
10
|
+
* for them to read back. The `files` deny/override section is parsed separately
|
|
11
|
+
* by `web/lib/files.ts`.
|
|
12
|
+
*
|
|
13
|
+
* Dependency-free (no jsonc npm dep) so it runs on both Bun and Node, and so the
|
|
14
|
+
* ADR-009 vendored copies stay portable.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { readFileSync, statSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { coordEnv } from "../lib/env.ts";
|
|
20
|
+
import { findCoordRoot } from "./hooks/resolve/coord-root.ts";
|
|
21
|
+
|
|
22
|
+
/** The standalone CLI's bin name: the resolution floor when nothing else is set. */
|
|
23
|
+
export const DEFAULT_BIN_NAME = "harn";
|
|
24
|
+
|
|
25
|
+
interface HarneryConfig {
|
|
26
|
+
/** Host CLI bin name, stamped by `harn init` for a consumer (e.g. "bp"). */
|
|
27
|
+
binName?: string;
|
|
28
|
+
[k: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Strip `//` and `/* */` comments from JSONC, ignoring comment-like runs inside strings. */
|
|
32
|
+
export function stripJsonComments(input: string): string {
|
|
33
|
+
let out = "";
|
|
34
|
+
let i = 0;
|
|
35
|
+
let inString = false;
|
|
36
|
+
while (i < input.length) {
|
|
37
|
+
const ch = input[i];
|
|
38
|
+
if (inString) {
|
|
39
|
+
out += ch;
|
|
40
|
+
if (ch === "\\" && i + 1 < input.length) {
|
|
41
|
+
out += input[i + 1];
|
|
42
|
+
i += 2;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (ch === '"') inString = false;
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (ch === '"') {
|
|
50
|
+
inString = true;
|
|
51
|
+
out += ch;
|
|
52
|
+
i++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (ch === "/" && input[i + 1] === "/") {
|
|
56
|
+
while (i < input.length && input[i] !== "\n") i++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (ch === "/" && input[i + 1] === "*") {
|
|
60
|
+
i += 2;
|
|
61
|
+
while (i < input.length && !(input[i] === "*" && input[i + 1] === "/")) i++;
|
|
62
|
+
i += 2;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
out += ch;
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// mtime-keyed per-process cache: a stat is cheap, a parse on every render isn't.
|
|
72
|
+
let cache: { root: string; mtimeMs: number; cfg: HarneryConfig } | null = null;
|
|
73
|
+
|
|
74
|
+
function readConfig(root: string): HarneryConfig {
|
|
75
|
+
const p = join(root, ".harnery", "config.jsonc");
|
|
76
|
+
let mtimeMs = -1;
|
|
77
|
+
try {
|
|
78
|
+
mtimeMs = statSync(p).mtimeMs;
|
|
79
|
+
} catch {
|
|
80
|
+
/* missing → -1; cache still valid until the file appears */
|
|
81
|
+
}
|
|
82
|
+
if (cache && cache.root === root && cache.mtimeMs === mtimeMs) return cache.cfg;
|
|
83
|
+
let cfg: HarneryConfig = {};
|
|
84
|
+
try {
|
|
85
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync(p, "utf8"))) as HarneryConfig | null;
|
|
86
|
+
if (parsed && typeof parsed === "object") cfg = parsed;
|
|
87
|
+
} catch {
|
|
88
|
+
/* missing or unparseable → defaults (the files-section resolver fails loud; bin name is non-critical) */
|
|
89
|
+
}
|
|
90
|
+
cache = { root, mtimeMs, cfg };
|
|
91
|
+
return cfg;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the host CLI's bin name for user-facing strings. Precedence:
|
|
96
|
+
* 1. `HARNERY_BIN` env (explicit per-process override)
|
|
97
|
+
* 2. `.harnery/config.jsonc` `binName` (stamped by `harn init`)
|
|
98
|
+
* 3. `"harn"` (standalone default)
|
|
99
|
+
*
|
|
100
|
+
* `coordRoot` is resolved via `findCoordRoot()` when not passed.
|
|
101
|
+
*/
|
|
102
|
+
export function resolveBinName(coordRoot?: string | null): string {
|
|
103
|
+
const env = coordEnv("BIN");
|
|
104
|
+
if (env?.trim()) return env.trim();
|
|
105
|
+
const root = coordRoot ?? findCoordRoot();
|
|
106
|
+
if (root) {
|
|
107
|
+
const binName = readConfig(root).binName;
|
|
108
|
+
if (typeof binName === "string" && binName.trim()) return binName.trim();
|
|
109
|
+
}
|
|
110
|
+
return DEFAULT_BIN_NAME;
|
|
111
|
+
}
|