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,271 @@
|
|
|
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
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { emit } from "../events/emit.js";
|
|
18
|
+
/** Inline harness normalizer (mirrors canonical-emit.normalizeHarness), kept
|
|
19
|
+
* local so the writer's only cross-module dep is the in-process emit(). */
|
|
20
|
+
function harnessOf(platform) {
|
|
21
|
+
if (platform === "cursor")
|
|
22
|
+
return "cursor";
|
|
23
|
+
if (platform === "codex")
|
|
24
|
+
return "codex";
|
|
25
|
+
return "claude-code";
|
|
26
|
+
}
|
|
27
|
+
/** Inverse of harnessOf: maps the canonical harness ("claude-code"/"cursor"/
|
|
28
|
+
* "codex") to the legacy underscore platform label stored on the heartbeat.
|
|
29
|
+
* Mirrors heartbeat-projector.harnessToPlatform so a healed heartbeat carries
|
|
30
|
+
* the same platform value projection would have written. */
|
|
31
|
+
function harnessToPlatform(harness) {
|
|
32
|
+
if (harness === "cursor")
|
|
33
|
+
return "cursor";
|
|
34
|
+
if (harness === "codex")
|
|
35
|
+
return "codex";
|
|
36
|
+
return "claude_code";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Emit a canonical `health.*` event for an actual self-heal write. This is the
|
|
40
|
+
* single source of truth for heal telemetry across BOTH the live auto-heal
|
|
41
|
+
* (the pre-tool-use hook → agent-coord heal-heartbeat) and the manual `harn agents
|
|
42
|
+
* heal` path. Write-only by construction (callers only invoke it after a real
|
|
43
|
+
* write), so an already-correct heal records nothing.
|
|
44
|
+
* Best-effort: never throws into the heal path.
|
|
45
|
+
*/
|
|
46
|
+
function emitHealthHeal(coordRoot, type, instanceId, hb, data) {
|
|
47
|
+
try {
|
|
48
|
+
emit(coordRoot, {
|
|
49
|
+
event_type: type,
|
|
50
|
+
instance_id: instanceId,
|
|
51
|
+
session_id: hb?.session_id ?? instanceId,
|
|
52
|
+
harness: harnessOf(hb?.platform),
|
|
53
|
+
source: "agent-coord",
|
|
54
|
+
data,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
/* telemetry only, never break a heal */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function heartbeatPath(coordRoot, instanceId) {
|
|
62
|
+
return join(coordRoot, ".harnery", "active", `${instanceId}.json`);
|
|
63
|
+
}
|
|
64
|
+
function nowIsoSeconds() {
|
|
65
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
66
|
+
}
|
|
67
|
+
function atomicWrite(path, content) {
|
|
68
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
69
|
+
const tmp = `${path}.tmp.${process.pid}`;
|
|
70
|
+
writeFileSync(tmp, content, "utf8");
|
|
71
|
+
renameSync(tmp, path);
|
|
72
|
+
}
|
|
73
|
+
export function readHeartbeat(coordRoot, instanceId) {
|
|
74
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
75
|
+
if (!existsSync(path))
|
|
76
|
+
return null;
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function mutate(coordRoot, instanceId, fn) {
|
|
85
|
+
const hb = readHeartbeat(coordRoot, instanceId);
|
|
86
|
+
if (!hb)
|
|
87
|
+
return null;
|
|
88
|
+
const next = fn(hb);
|
|
89
|
+
next.last_heartbeat = nowIsoSeconds();
|
|
90
|
+
atomicWrite(heartbeatPath(coordRoot, instanceId), JSON.stringify(next, null, 2));
|
|
91
|
+
return next;
|
|
92
|
+
}
|
|
93
|
+
export function setTask(coordRoot, instanceId, task) {
|
|
94
|
+
return mutate(coordRoot, instanceId, (hb) => {
|
|
95
|
+
const cleared = !task || task.length === 0;
|
|
96
|
+
return {
|
|
97
|
+
...hb,
|
|
98
|
+
task: cleared ? undefined : task,
|
|
99
|
+
task_updated_at: nowIsoSeconds(),
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function stampStatusCheck(coordRoot, instanceId) {
|
|
104
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
105
|
+
...hb,
|
|
106
|
+
last_status_at: nowIsoSeconds(),
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
export function setTurnSummary(coordRoot, instanceId, summary) {
|
|
110
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
111
|
+
...hb,
|
|
112
|
+
turn_summary: summary,
|
|
113
|
+
turn_summary_updated_at: nowIsoSeconds(),
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
export function releaseClaim(coordRoot, instanceId, path) {
|
|
117
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
118
|
+
...hb,
|
|
119
|
+
files_touched: (hb.files_touched ?? []).filter((p) => p !== path),
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Session-group-wide unclaim. Walks every heartbeat sharing `groupId`
|
|
124
|
+
* (parent's session_id == group_id;
|
|
125
|
+
* subagents inherit it) and removes the path from each one's files_touched.
|
|
126
|
+
* Idempotent: heartbeats that don't hold the path are untouched.
|
|
127
|
+
*
|
|
128
|
+
* This is the Option B fix for post-commit's pid-map attribution hole: a
|
|
129
|
+
* subagent-held claim that doesn't live on the parent's heartbeat still gets
|
|
130
|
+
* pruned because the walk covers the whole group.
|
|
131
|
+
*/
|
|
132
|
+
export function groupUnclaim(coordRoot, groupId, path) {
|
|
133
|
+
if (!groupId || !path)
|
|
134
|
+
return;
|
|
135
|
+
const activeDir = join(coordRoot, ".harnery", "active");
|
|
136
|
+
if (!existsSync(activeDir))
|
|
137
|
+
return;
|
|
138
|
+
for (const f of readdirSync(activeDir)) {
|
|
139
|
+
if (!f.endsWith(".json"))
|
|
140
|
+
continue;
|
|
141
|
+
const hbPath = join(activeDir, f);
|
|
142
|
+
let body;
|
|
143
|
+
try {
|
|
144
|
+
body = JSON.parse(readFileSync(hbPath, "utf8"));
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const peerSession = body.session_id ?? body.instance_id;
|
|
150
|
+
if (peerSession !== groupId)
|
|
151
|
+
continue;
|
|
152
|
+
const files = body.files_touched ?? [];
|
|
153
|
+
const next = files.filter((p) => p !== path);
|
|
154
|
+
if (next.length === files.length)
|
|
155
|
+
continue;
|
|
156
|
+
body.files_touched = next;
|
|
157
|
+
try {
|
|
158
|
+
const tmp = `${hbPath}.tmp.${process.pid}`;
|
|
159
|
+
writeFileSync(tmp, JSON.stringify(body, null, 2), "utf8");
|
|
160
|
+
renameSync(tmp, hbPath);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
/* silent */
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export function killHeartbeat(coordRoot, instanceId) {
|
|
168
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
169
|
+
if (!existsSync(path))
|
|
170
|
+
return false;
|
|
171
|
+
try {
|
|
172
|
+
unlinkSync(path);
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export function healPidmap(coordRoot, instanceId, pid) {
|
|
180
|
+
const dir = join(coordRoot, ".harnery", "pid-map");
|
|
181
|
+
mkdirSync(dir, { recursive: true });
|
|
182
|
+
const hb = readHeartbeat(coordRoot, instanceId);
|
|
183
|
+
const platform = hb?.platform ?? "claude_code";
|
|
184
|
+
const pmPath = join(dir, String(pid));
|
|
185
|
+
// Drift guard: only write + emit telemetry when the entry is missing or
|
|
186
|
+
// points at a different owner. Without this, a per-tool-call heal would
|
|
187
|
+
// flood health.pidmap_heal on every call.
|
|
188
|
+
let existingOwner = "";
|
|
189
|
+
try {
|
|
190
|
+
if (existsSync(pmPath))
|
|
191
|
+
existingOwner = readFileSync(pmPath, "utf8").split("\t")[0] ?? "";
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
/* treat as missing */
|
|
195
|
+
}
|
|
196
|
+
if (existingOwner === instanceId)
|
|
197
|
+
return;
|
|
198
|
+
atomicWrite(pmPath, `${instanceId}\t${platform}`);
|
|
199
|
+
emitHealthHeal(coordRoot, "health.pidmap_heal", instanceId, hb, {
|
|
200
|
+
reason: existingOwner ? "stale" : "missing",
|
|
201
|
+
pid,
|
|
202
|
+
kind: "pidmap",
|
|
203
|
+
...(existingOwner ? { prior: existingOwner.slice(0, 8) } : {}),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
export function healHeartbeat(coordRoot, instanceId, sessionId, model, harness) {
|
|
207
|
+
const path = heartbeatPath(coordRoot, instanceId);
|
|
208
|
+
if (existsSync(path)) {
|
|
209
|
+
// Already alive, return it.
|
|
210
|
+
return readHeartbeat(coordRoot, instanceId);
|
|
211
|
+
}
|
|
212
|
+
const now = nowIsoSeconds();
|
|
213
|
+
// Recover name + kind from .name-history if present (idempotent across
|
|
214
|
+
// sweeps: same instance_id always gets the same name).
|
|
215
|
+
let name = "";
|
|
216
|
+
let kind = "session";
|
|
217
|
+
let agentId = "";
|
|
218
|
+
try {
|
|
219
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
220
|
+
const { resolveName } = require("./names.ts");
|
|
221
|
+
const resolved = resolveName(coordRoot, instanceId, sessionId);
|
|
222
|
+
if (resolved) {
|
|
223
|
+
name = resolved.name;
|
|
224
|
+
kind = resolved.kind;
|
|
225
|
+
// subagent kind: agent_id == instance_id. Else (session/transient): no id stamp.
|
|
226
|
+
if (resolved.kind === "subagent")
|
|
227
|
+
agentId = instanceId;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
/* names module unavailable, fall back to empty */
|
|
232
|
+
}
|
|
233
|
+
const hb = {
|
|
234
|
+
schema_version: 1,
|
|
235
|
+
instance_id: instanceId,
|
|
236
|
+
session_id: sessionId ?? instanceId,
|
|
237
|
+
name,
|
|
238
|
+
kind,
|
|
239
|
+
agent_id: agentId,
|
|
240
|
+
model: model ?? "",
|
|
241
|
+
started_at: now,
|
|
242
|
+
last_heartbeat: now,
|
|
243
|
+
files_touched: [],
|
|
244
|
+
// Default to claude_code only when the caller can't tell us the harness
|
|
245
|
+
// (e.g. manual `harn agents heal`). The live tool.pre_use heal threads the
|
|
246
|
+
// detected harness so a pruned Cursor/Codex heartbeat is recreated with
|
|
247
|
+
// the correct platform instead of being mislabeled claude_code.
|
|
248
|
+
platform: harnessToPlatform(harness),
|
|
249
|
+
};
|
|
250
|
+
atomicWrite(path, JSON.stringify(hb, null, 2));
|
|
251
|
+
// Write-only telemetry: only the actual-recreate branch reaches here (the
|
|
252
|
+
// already-alive case returned above), so this records exactly the heals that
|
|
253
|
+
// happened.
|
|
254
|
+
emitHealthHeal(coordRoot, "health.heartbeat_heal", instanceId, hb, {
|
|
255
|
+
reason: "missing",
|
|
256
|
+
kind: "heartbeat",
|
|
257
|
+
});
|
|
258
|
+
return hb;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Stamp the heartbeat with the most-recent tool name + target. Written from
|
|
262
|
+
* the post-tool-use hook.
|
|
263
|
+
*/
|
|
264
|
+
export function stampToolActivity(coordRoot, instanceId, toolName, target) {
|
|
265
|
+
return mutate(coordRoot, instanceId, (hb) => ({
|
|
266
|
+
...hb,
|
|
267
|
+
last_tool: toolName,
|
|
268
|
+
last_tool_target: target,
|
|
269
|
+
last_tool_at: nowIsoSeconds(),
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hurricane-style name pool for the agent coordination layer. The name-pool
|
|
3
|
+
* assignment + resolution helpers.
|
|
4
|
+
*
|
|
5
|
+
* Layout invariant: 260 entries (10 per starting letter A..Z). Counter N
|
|
6
|
+
* picks COORD_NAMES[N % 260]; wraps to A at N=260.
|
|
7
|
+
*
|
|
8
|
+
* Durable persistence: `.harnery/.name-history` (JSONL, one row per assignment)
|
|
9
|
+
* + `.harnery/.name-counter` (current counter, atomic temp+rename).
|
|
10
|
+
*
|
|
11
|
+
* Recreation rule (mirrors v1):
|
|
12
|
+
* 1. Own instance_id in name-history → (original name, original kind)
|
|
13
|
+
* 2. session_id in name-history (owner != session) → (parent's name, "transient")
|
|
14
|
+
* 3. Else: new assignment, consume a counter slot.
|
|
15
|
+
*/
|
|
16
|
+
/** All 260 names. */
|
|
17
|
+
export declare const COORD_NAMES: readonly ["Anna", "Bob", "Carlos", "Dalia", "Erika", "Fred", "Gemma", "Hank", "Imelda", "Jerry", "Kirk", "Lee", "Milton", "Nate", "Oscar", "Patty", "Quentin", "Rafael", "Sara", "Tony", "Ulrik", "Valerie", "Whitney", "Xander", "Yara", "Zara", "Adelaide", "Bertha", "Carmen", "Dorian", "Edna", "Francine", "Greta", "Helene", "Ines", "Joyce", "Karen", "Lorenzo", "Mindy", "Nadine", "Odette", "Paulette", "Quinn", "Rebekah", "Sean", "Tammy", "Ursula", "Vinson", "Wallace", "Xanthe", "Yusuf", "Zoe", "Alex", "Beatrice", "Cyrus", "Delia", "Ernesto", "Florence", "Gordon", "Hester", "Isaias", "Jenna", "Klaus", "Larry", "Maxine", "Nicholas", "Otto", "Peter", "Quill", "Renee", "Stella", "Theresa", "Umberto", "Virgil", "Willow", "Xavier", "Yolanda", "Zane", "Anita", "Bruno", "Cora", "Damon", "Edith", "Felix", "Gloria", "Holly", "Iris", "Jasper", "Kaia", "Linda", "Marco", "Nora", "Olive", "Petra", "Querida", "Roman", "Sebastian", "Tobias", "Una", "Vera", "Walter", "Xena", "Yusra", "Zelda", "Aaron", "Bonnie", "Caleb", "Daphne", "Elias", "Fiona", "Galileo", "Hugo", "Ian", "Jude", "Knox", "Leo", "Maya", "Nash", "Owen", "Paxton", "Quetzal", "Rosa", "Sage", "Talia", "Uri", "Vincent", "Wesley", "Ximena", "Yvette", "Zephyr", "Astrid", "Beau", "Celeste", "Dexter", "Ezra", "Fitz", "Genevieve", "Hadley", "Imogen", "Joaquin", "Kira", "Lila", "Mason", "Nila", "Olga", "Pearl", "Quincy", "Royce", "Sterling", "Trent", "Ulysses", "Violet", "Wynne", "Xerxes", "Yael", "Zinnia", "Amelia", "Bianca", "Cody", "Dahlia", "Esme", "Fern", "Greer", "Harriet", "Ivan", "Juno", "Kendrick", "Luther", "Margot", "Nigel", "Orion", "Phillip", "Quenby", "Reagan", "Sienna", "Tessa", "Uma", "Vesper", "Watson", "Xiomara", "Yuri", "Zoltan", "Andre", "Boris", "Cassidy", "Davis", "Evander", "Forrest", "Gibson", "Henry", "Irene", "Justus", "Kasper", "Lainey", "Miles", "Naomi", "Ophelia", "Phoebe", "Quark", "Rylie", "Saul", "Truman", "Ulrich", "Voss", "Winifred", "Xuxa", "Yvonne", "Zia", "Aria", "Brenda", "Crispin", "Dolores", "Estelle", "Felicity", "Goldie", "Hazel", "Ira", "Jovi", "Kestrel", "Lyric", "Mavis", "Nico", "Otis", "Percy", "Querubin", "Rhett", "Scout", "Tatum", "Unity", "Vivian", "Wyatt", "Xan", "Yancy", "Zev", "Atticus", "Barnaby", "Calliope", "Drake", "Eustace", "Foster", "Granger", "Hollis", "Indira", "Jericho", "Kaleb", "Logan", "Magnus", "Noor", "Oakley", "Posy", "Quito", "Rosalind", "Sloane", "Theron", "Upton", "Vance", "Wendell", "Xola", "Yann", "Zora"];
|
|
18
|
+
export type NameKind = "session" | "subagent" | "transient";
|
|
19
|
+
/**
|
|
20
|
+
* Resolve (name, kind) for an existing owner without consuming a counter
|
|
21
|
+
* slot. Returns null if no history match found.
|
|
22
|
+
*
|
|
23
|
+
* 1. Own instance_id → original (name, kind)
|
|
24
|
+
* 2. session_id (owner != session) → (parent's name, "transient")
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveName(coordRoot: string, instanceId: string, sessionId?: string): {
|
|
27
|
+
name: string;
|
|
28
|
+
kind: NameKind;
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* Assign a name to <instanceId> with the given <kind>. Counter-consuming when
|
|
32
|
+
* the owner is new. Idempotent: returns existing name on resume.
|
|
33
|
+
*/
|
|
34
|
+
export declare function assignName(coordRoot: string, instanceId: string, kind: NameKind): string;
|
|
35
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../../../src/core/agents/state/names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,qBAAqB;AACrB,eAAO,MAAM,WAAW,y5EA+Qd,CAAC;AAMX,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AA6C5D;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,IAAI,CAkBzC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAqBxF"}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hurricane-style name pool for the agent coordination layer. The name-pool
|
|
3
|
+
* assignment + resolution helpers.
|
|
4
|
+
*
|
|
5
|
+
* Layout invariant: 260 entries (10 per starting letter A..Z). Counter N
|
|
6
|
+
* picks COORD_NAMES[N % 260]; wraps to A at N=260.
|
|
7
|
+
*
|
|
8
|
+
* Durable persistence: `.harnery/.name-history` (JSONL, one row per assignment)
|
|
9
|
+
* + `.harnery/.name-counter` (current counter, atomic temp+rename).
|
|
10
|
+
*
|
|
11
|
+
* Recreation rule (mirrors v1):
|
|
12
|
+
* 1. Own instance_id in name-history → (original name, original kind)
|
|
13
|
+
* 2. session_id in name-history (owner != session) → (parent's name, "transient")
|
|
14
|
+
* 3. Else: new assignment, consume a counter slot.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
/** All 260 names. */
|
|
19
|
+
export const COORD_NAMES = [
|
|
20
|
+
// Pass 1
|
|
21
|
+
"Anna",
|
|
22
|
+
"Bob",
|
|
23
|
+
"Carlos",
|
|
24
|
+
"Dalia",
|
|
25
|
+
"Erika",
|
|
26
|
+
"Fred",
|
|
27
|
+
"Gemma",
|
|
28
|
+
"Hank",
|
|
29
|
+
"Imelda",
|
|
30
|
+
"Jerry",
|
|
31
|
+
"Kirk",
|
|
32
|
+
"Lee",
|
|
33
|
+
"Milton",
|
|
34
|
+
"Nate",
|
|
35
|
+
"Oscar",
|
|
36
|
+
"Patty",
|
|
37
|
+
"Quentin",
|
|
38
|
+
"Rafael",
|
|
39
|
+
"Sara",
|
|
40
|
+
"Tony",
|
|
41
|
+
"Ulrik",
|
|
42
|
+
"Valerie",
|
|
43
|
+
"Whitney",
|
|
44
|
+
"Xander",
|
|
45
|
+
"Yara",
|
|
46
|
+
"Zara",
|
|
47
|
+
// Pass 2
|
|
48
|
+
"Adelaide",
|
|
49
|
+
"Bertha",
|
|
50
|
+
"Carmen",
|
|
51
|
+
"Dorian",
|
|
52
|
+
"Edna",
|
|
53
|
+
"Francine",
|
|
54
|
+
"Greta",
|
|
55
|
+
"Helene",
|
|
56
|
+
"Ines",
|
|
57
|
+
"Joyce",
|
|
58
|
+
"Karen",
|
|
59
|
+
"Lorenzo",
|
|
60
|
+
"Mindy",
|
|
61
|
+
"Nadine",
|
|
62
|
+
"Odette",
|
|
63
|
+
"Paulette",
|
|
64
|
+
"Quinn",
|
|
65
|
+
"Rebekah",
|
|
66
|
+
"Sean",
|
|
67
|
+
"Tammy",
|
|
68
|
+
"Ursula",
|
|
69
|
+
"Vinson",
|
|
70
|
+
"Wallace",
|
|
71
|
+
"Xanthe",
|
|
72
|
+
"Yusuf",
|
|
73
|
+
"Zoe",
|
|
74
|
+
// Pass 3
|
|
75
|
+
"Alex",
|
|
76
|
+
"Beatrice",
|
|
77
|
+
"Cyrus",
|
|
78
|
+
"Delia",
|
|
79
|
+
"Ernesto",
|
|
80
|
+
"Florence",
|
|
81
|
+
"Gordon",
|
|
82
|
+
"Hester",
|
|
83
|
+
"Isaias",
|
|
84
|
+
"Jenna",
|
|
85
|
+
"Klaus",
|
|
86
|
+
"Larry",
|
|
87
|
+
"Maxine",
|
|
88
|
+
"Nicholas",
|
|
89
|
+
"Otto",
|
|
90
|
+
"Peter",
|
|
91
|
+
"Quill",
|
|
92
|
+
"Renee",
|
|
93
|
+
"Stella",
|
|
94
|
+
"Theresa",
|
|
95
|
+
"Umberto",
|
|
96
|
+
"Virgil",
|
|
97
|
+
"Willow",
|
|
98
|
+
"Xavier",
|
|
99
|
+
"Yolanda",
|
|
100
|
+
"Zane",
|
|
101
|
+
// Pass 4
|
|
102
|
+
"Anita",
|
|
103
|
+
"Bruno",
|
|
104
|
+
"Cora",
|
|
105
|
+
"Damon",
|
|
106
|
+
"Edith",
|
|
107
|
+
"Felix",
|
|
108
|
+
"Gloria",
|
|
109
|
+
"Holly",
|
|
110
|
+
"Iris",
|
|
111
|
+
"Jasper",
|
|
112
|
+
"Kaia",
|
|
113
|
+
"Linda",
|
|
114
|
+
"Marco",
|
|
115
|
+
"Nora",
|
|
116
|
+
"Olive",
|
|
117
|
+
"Petra",
|
|
118
|
+
"Querida",
|
|
119
|
+
"Roman",
|
|
120
|
+
"Sebastian",
|
|
121
|
+
"Tobias",
|
|
122
|
+
"Una",
|
|
123
|
+
"Vera",
|
|
124
|
+
"Walter",
|
|
125
|
+
"Xena",
|
|
126
|
+
"Yusra",
|
|
127
|
+
"Zelda",
|
|
128
|
+
// Pass 5
|
|
129
|
+
"Aaron",
|
|
130
|
+
"Bonnie",
|
|
131
|
+
"Caleb",
|
|
132
|
+
"Daphne",
|
|
133
|
+
"Elias",
|
|
134
|
+
"Fiona",
|
|
135
|
+
"Galileo",
|
|
136
|
+
"Hugo",
|
|
137
|
+
"Ian",
|
|
138
|
+
"Jude",
|
|
139
|
+
"Knox",
|
|
140
|
+
"Leo",
|
|
141
|
+
"Maya",
|
|
142
|
+
"Nash",
|
|
143
|
+
"Owen",
|
|
144
|
+
"Paxton",
|
|
145
|
+
"Quetzal",
|
|
146
|
+
"Rosa",
|
|
147
|
+
"Sage",
|
|
148
|
+
"Talia",
|
|
149
|
+
"Uri",
|
|
150
|
+
"Vincent",
|
|
151
|
+
"Wesley",
|
|
152
|
+
"Ximena",
|
|
153
|
+
"Yvette",
|
|
154
|
+
"Zephyr",
|
|
155
|
+
// Pass 6
|
|
156
|
+
"Astrid",
|
|
157
|
+
"Beau",
|
|
158
|
+
"Celeste",
|
|
159
|
+
"Dexter",
|
|
160
|
+
"Ezra",
|
|
161
|
+
"Fitz",
|
|
162
|
+
"Genevieve",
|
|
163
|
+
"Hadley",
|
|
164
|
+
"Imogen",
|
|
165
|
+
"Joaquin",
|
|
166
|
+
"Kira",
|
|
167
|
+
"Lila",
|
|
168
|
+
"Mason",
|
|
169
|
+
"Nila",
|
|
170
|
+
"Olga",
|
|
171
|
+
"Pearl",
|
|
172
|
+
"Quincy",
|
|
173
|
+
"Royce",
|
|
174
|
+
"Sterling",
|
|
175
|
+
"Trent",
|
|
176
|
+
"Ulysses",
|
|
177
|
+
"Violet",
|
|
178
|
+
"Wynne",
|
|
179
|
+
"Xerxes",
|
|
180
|
+
"Yael",
|
|
181
|
+
"Zinnia",
|
|
182
|
+
// Pass 7
|
|
183
|
+
"Amelia",
|
|
184
|
+
"Bianca",
|
|
185
|
+
"Cody",
|
|
186
|
+
"Dahlia",
|
|
187
|
+
"Esme",
|
|
188
|
+
"Fern",
|
|
189
|
+
"Greer",
|
|
190
|
+
"Harriet",
|
|
191
|
+
"Ivan",
|
|
192
|
+
"Juno",
|
|
193
|
+
"Kendrick",
|
|
194
|
+
"Luther",
|
|
195
|
+
"Margot",
|
|
196
|
+
"Nigel",
|
|
197
|
+
"Orion",
|
|
198
|
+
"Phillip",
|
|
199
|
+
"Quenby",
|
|
200
|
+
"Reagan",
|
|
201
|
+
"Sienna",
|
|
202
|
+
"Tessa",
|
|
203
|
+
"Uma",
|
|
204
|
+
"Vesper",
|
|
205
|
+
"Watson",
|
|
206
|
+
"Xiomara",
|
|
207
|
+
"Yuri",
|
|
208
|
+
"Zoltan",
|
|
209
|
+
// Pass 8
|
|
210
|
+
"Andre",
|
|
211
|
+
"Boris",
|
|
212
|
+
"Cassidy",
|
|
213
|
+
"Davis",
|
|
214
|
+
"Evander",
|
|
215
|
+
"Forrest",
|
|
216
|
+
"Gibson",
|
|
217
|
+
"Henry",
|
|
218
|
+
"Irene",
|
|
219
|
+
"Justus",
|
|
220
|
+
"Kasper",
|
|
221
|
+
"Lainey",
|
|
222
|
+
"Miles",
|
|
223
|
+
"Naomi",
|
|
224
|
+
"Ophelia",
|
|
225
|
+
"Phoebe",
|
|
226
|
+
"Quark",
|
|
227
|
+
"Rylie",
|
|
228
|
+
"Saul",
|
|
229
|
+
"Truman",
|
|
230
|
+
"Ulrich",
|
|
231
|
+
"Voss",
|
|
232
|
+
"Winifred",
|
|
233
|
+
"Xuxa",
|
|
234
|
+
"Yvonne",
|
|
235
|
+
"Zia",
|
|
236
|
+
// Pass 9
|
|
237
|
+
"Aria",
|
|
238
|
+
"Brenda",
|
|
239
|
+
"Crispin",
|
|
240
|
+
"Dolores",
|
|
241
|
+
"Estelle",
|
|
242
|
+
"Felicity",
|
|
243
|
+
"Goldie",
|
|
244
|
+
"Hazel",
|
|
245
|
+
"Ira",
|
|
246
|
+
"Jovi",
|
|
247
|
+
"Kestrel",
|
|
248
|
+
"Lyric",
|
|
249
|
+
"Mavis",
|
|
250
|
+
"Nico",
|
|
251
|
+
"Otis",
|
|
252
|
+
"Percy",
|
|
253
|
+
"Querubin",
|
|
254
|
+
"Rhett",
|
|
255
|
+
"Scout",
|
|
256
|
+
"Tatum",
|
|
257
|
+
"Unity",
|
|
258
|
+
"Vivian",
|
|
259
|
+
"Wyatt",
|
|
260
|
+
"Xan",
|
|
261
|
+
"Yancy",
|
|
262
|
+
"Zev",
|
|
263
|
+
// Pass 10
|
|
264
|
+
"Atticus",
|
|
265
|
+
"Barnaby",
|
|
266
|
+
"Calliope",
|
|
267
|
+
"Drake",
|
|
268
|
+
"Eustace",
|
|
269
|
+
"Foster",
|
|
270
|
+
"Granger",
|
|
271
|
+
"Hollis",
|
|
272
|
+
"Indira",
|
|
273
|
+
"Jericho",
|
|
274
|
+
"Kaleb",
|
|
275
|
+
"Logan",
|
|
276
|
+
"Magnus",
|
|
277
|
+
"Noor",
|
|
278
|
+
"Oakley",
|
|
279
|
+
"Posy",
|
|
280
|
+
"Quito",
|
|
281
|
+
"Rosalind",
|
|
282
|
+
"Sloane",
|
|
283
|
+
"Theron",
|
|
284
|
+
"Upton",
|
|
285
|
+
"Vance",
|
|
286
|
+
"Wendell",
|
|
287
|
+
"Xola",
|
|
288
|
+
"Yann",
|
|
289
|
+
"Zora",
|
|
290
|
+
];
|
|
291
|
+
if (COORD_NAMES.length !== 260) {
|
|
292
|
+
throw new Error(`COORD_NAMES table corrupt: expected 260 entries, got ${COORD_NAMES.length}`);
|
|
293
|
+
}
|
|
294
|
+
function atomicWrite(path, content) {
|
|
295
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
296
|
+
const tmp = `${path}.tmp.${process.pid}`;
|
|
297
|
+
writeFileSync(tmp, content, "utf8");
|
|
298
|
+
renameSync(tmp, path);
|
|
299
|
+
}
|
|
300
|
+
function counterPath(coordRoot) {
|
|
301
|
+
return join(coordRoot, ".harnery", ".name-counter");
|
|
302
|
+
}
|
|
303
|
+
function historyPath(coordRoot) {
|
|
304
|
+
return join(coordRoot, ".harnery", ".name-history");
|
|
305
|
+
}
|
|
306
|
+
function readHistory(coordRoot) {
|
|
307
|
+
const p = historyPath(coordRoot);
|
|
308
|
+
if (!existsSync(p))
|
|
309
|
+
return [];
|
|
310
|
+
try {
|
|
311
|
+
return readFileSync(p, "utf8")
|
|
312
|
+
.split("\n")
|
|
313
|
+
.filter((line) => line.length > 0)
|
|
314
|
+
.map((line) => JSON.parse(line));
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function appendHistory(coordRoot, row) {
|
|
321
|
+
const p = historyPath(coordRoot);
|
|
322
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
323
|
+
const line = `${JSON.stringify(row)}\n`;
|
|
324
|
+
// Append is naturally atomic for lines <PIPE_BUF (4096 on Linux).
|
|
325
|
+
writeFileSync(p, line, { encoding: "utf8", flag: "a" });
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Resolve (name, kind) for an existing owner without consuming a counter
|
|
329
|
+
* slot. Returns null if no history match found.
|
|
330
|
+
*
|
|
331
|
+
* 1. Own instance_id → original (name, kind)
|
|
332
|
+
* 2. session_id (owner != session) → (parent's name, "transient")
|
|
333
|
+
*/
|
|
334
|
+
export function resolveName(coordRoot, instanceId, sessionId) {
|
|
335
|
+
const history = readHistory(coordRoot);
|
|
336
|
+
for (const row of history) {
|
|
337
|
+
if (row.instance_id === instanceId) {
|
|
338
|
+
return { name: row.name, kind: row.kind };
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (sessionId && sessionId !== instanceId) {
|
|
342
|
+
for (const row of history) {
|
|
343
|
+
if (row.instance_id === sessionId) {
|
|
344
|
+
return { name: row.name, kind: "transient" };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Assign a name to <instanceId> with the given <kind>. Counter-consuming when
|
|
352
|
+
* the owner is new. Idempotent: returns existing name on resume.
|
|
353
|
+
*/
|
|
354
|
+
export function assignName(coordRoot, instanceId, kind) {
|
|
355
|
+
// Check 1: existing history row → original name.
|
|
356
|
+
const existing = resolveName(coordRoot, instanceId);
|
|
357
|
+
if (existing)
|
|
358
|
+
return existing.name;
|
|
359
|
+
// New owner: consume a counter slot.
|
|
360
|
+
const cPath = counterPath(coordRoot);
|
|
361
|
+
let counter = 0;
|
|
362
|
+
if (existsSync(cPath)) {
|
|
363
|
+
const raw = readFileSync(cPath, "utf8").trim();
|
|
364
|
+
if (/^\d+$/.test(raw))
|
|
365
|
+
counter = Number.parseInt(raw, 10);
|
|
366
|
+
}
|
|
367
|
+
const name = COORD_NAMES[counter % 260];
|
|
368
|
+
atomicWrite(cPath, String(counter + 1));
|
|
369
|
+
appendHistory(coordRoot, {
|
|
370
|
+
instance_id: instanceId,
|
|
371
|
+
name,
|
|
372
|
+
kind,
|
|
373
|
+
ts: new Date().toISOString().replace(/\.\d{3}Z$/, "Z"),
|
|
374
|
+
});
|
|
375
|
+
return name;
|
|
376
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pid-map writer.
|
|
3
|
+
*
|
|
4
|
+
* Per-harness pid-map at `.harnery/pid-map/<pid>` containing
|
|
5
|
+
* `<instance_id>\t<platform>`. `harn agents whoami` walks ppid up 20 hops looking
|
|
6
|
+
* for a matching entry (preferring the harness, falling back to any platform).
|
|
7
|
+
*
|
|
8
|
+
* Atomic temp+rename. Idempotent: re-writing the same row is a no-op.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writePidmapRow(coordRoot: string, pid: number, instanceId: string, platform: string): void;
|
|
11
|
+
//# sourceMappingURL=pidmap.d.ts.map
|