@cluesmith/codev 2.0.0-rc.7 → 2.0.0-rc.71
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/bin/af.js +2 -2
- package/bin/consult.js +1 -1
- package/bin/porch.js +6 -35
- package/dashboard/dist/assets/index-C7FtNK6Y.css +32 -0
- package/dashboard/dist/assets/index-CDAINZKT.js +131 -0
- package/dashboard/dist/assets/index-CDAINZKT.js.map +1 -0
- package/dashboard/dist/index.html +14 -0
- package/dist/agent-farm/cli.d.ts.map +1 -1
- package/dist/agent-farm/cli.js +173 -118
- package/dist/agent-farm/cli.js.map +1 -1
- package/dist/agent-farm/commands/architect.d.ts +3 -3
- package/dist/agent-farm/commands/architect.d.ts.map +1 -1
- package/dist/agent-farm/commands/architect.js +20 -147
- package/dist/agent-farm/commands/architect.js.map +1 -1
- package/dist/agent-farm/commands/attach.d.ts +13 -0
- package/dist/agent-farm/commands/attach.d.ts.map +1 -0
- package/dist/agent-farm/commands/attach.js +144 -0
- package/dist/agent-farm/commands/attach.js.map +1 -0
- package/dist/agent-farm/commands/cleanup.d.ts.map +1 -1
- package/dist/agent-farm/commands/cleanup.js +35 -19
- package/dist/agent-farm/commands/cleanup.js.map +1 -1
- package/dist/agent-farm/commands/consult.d.ts +3 -4
- package/dist/agent-farm/commands/consult.d.ts.map +1 -1
- package/dist/agent-farm/commands/consult.js +27 -37
- package/dist/agent-farm/commands/consult.js.map +1 -1
- package/dist/agent-farm/commands/index.d.ts +2 -2
- package/dist/agent-farm/commands/index.d.ts.map +1 -1
- package/dist/agent-farm/commands/index.js +2 -2
- package/dist/agent-farm/commands/index.js.map +1 -1
- package/dist/agent-farm/commands/open.d.ts +4 -2
- package/dist/agent-farm/commands/open.d.ts.map +1 -1
- package/dist/agent-farm/commands/open.js +33 -83
- package/dist/agent-farm/commands/open.js.map +1 -1
- package/dist/agent-farm/commands/send.d.ts +1 -1
- package/dist/agent-farm/commands/send.d.ts.map +1 -1
- package/dist/agent-farm/commands/send.js +60 -79
- package/dist/agent-farm/commands/send.js.map +1 -1
- package/dist/agent-farm/commands/shell.d.ts +15 -0
- package/dist/agent-farm/commands/shell.d.ts.map +1 -0
- package/dist/agent-farm/commands/shell.js +50 -0
- package/dist/agent-farm/commands/shell.js.map +1 -0
- package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
- package/dist/agent-farm/commands/spawn.js +597 -281
- package/dist/agent-farm/commands/spawn.js.map +1 -1
- package/dist/agent-farm/commands/start.d.ts +10 -20
- package/dist/agent-farm/commands/start.d.ts.map +1 -1
- package/dist/agent-farm/commands/start.js +45 -491
- package/dist/agent-farm/commands/start.js.map +1 -1
- package/dist/agent-farm/commands/status.d.ts +2 -0
- package/dist/agent-farm/commands/status.d.ts.map +1 -1
- package/dist/agent-farm/commands/status.js +75 -24
- package/dist/agent-farm/commands/status.js.map +1 -1
- package/dist/agent-farm/commands/stop.d.ts +6 -0
- package/dist/agent-farm/commands/stop.d.ts.map +1 -1
- package/dist/agent-farm/commands/stop.js +49 -109
- package/dist/agent-farm/commands/stop.js.map +1 -1
- package/dist/agent-farm/commands/tower-cloud.d.ts +48 -0
- package/dist/agent-farm/commands/tower-cloud.d.ts.map +1 -0
- package/dist/agent-farm/commands/tower-cloud.js +329 -0
- package/dist/agent-farm/commands/tower-cloud.js.map +1 -0
- package/dist/agent-farm/commands/tower.d.ts +9 -0
- package/dist/agent-farm/commands/tower.d.ts.map +1 -1
- package/dist/agent-farm/commands/tower.js +59 -19
- package/dist/agent-farm/commands/tower.js.map +1 -1
- package/dist/agent-farm/db/index.d.ts +6 -2
- package/dist/agent-farm/db/index.d.ts.map +1 -1
- package/dist/agent-farm/db/index.js +246 -18
- package/dist/agent-farm/db/index.js.map +1 -1
- package/dist/agent-farm/db/migrate.d.ts +0 -4
- package/dist/agent-farm/db/migrate.d.ts.map +1 -1
- package/dist/agent-farm/db/migrate.js +6 -55
- package/dist/agent-farm/db/migrate.js.map +1 -1
- package/dist/agent-farm/db/schema.d.ts +3 -3
- package/dist/agent-farm/db/schema.d.ts.map +1 -1
- package/dist/agent-farm/db/schema.js +25 -19
- package/dist/agent-farm/db/schema.js.map +1 -1
- package/dist/agent-farm/db/types.d.ts +3 -13
- package/dist/agent-farm/db/types.d.ts.map +1 -1
- package/dist/agent-farm/db/types.js +3 -11
- package/dist/agent-farm/db/types.js.map +1 -1
- package/dist/agent-farm/hq-connector.d.ts +2 -6
- package/dist/agent-farm/hq-connector.d.ts.map +1 -1
- package/dist/agent-farm/hq-connector.js +2 -17
- package/dist/agent-farm/hq-connector.js.map +1 -1
- package/dist/agent-farm/lib/cloud-config.d.ts +59 -0
- package/dist/agent-farm/lib/cloud-config.d.ts.map +1 -0
- package/dist/agent-farm/lib/cloud-config.js +143 -0
- package/dist/agent-farm/lib/cloud-config.js.map +1 -0
- package/dist/agent-farm/lib/tower-client.d.ts +163 -0
- package/dist/agent-farm/lib/tower-client.d.ts.map +1 -0
- package/dist/agent-farm/lib/tower-client.js +233 -0
- package/dist/agent-farm/lib/tower-client.js.map +1 -0
- package/dist/agent-farm/lib/tunnel-client.d.ts +117 -0
- package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -0
- package/dist/agent-farm/lib/tunnel-client.js +504 -0
- package/dist/agent-farm/lib/tunnel-client.js.map +1 -0
- package/dist/agent-farm/servers/tower-server.js +2653 -185
- package/dist/agent-farm/servers/tower-server.js.map +1 -1
- package/dist/agent-farm/state.d.ts +6 -12
- package/dist/agent-farm/state.d.ts.map +1 -1
- package/dist/agent-farm/state.js +34 -49
- package/dist/agent-farm/state.js.map +1 -1
- package/dist/agent-farm/types.d.ts +49 -26
- package/dist/agent-farm/types.d.ts.map +1 -1
- package/dist/agent-farm/utils/config.d.ts +0 -5
- package/dist/agent-farm/utils/config.d.ts.map +1 -1
- package/dist/agent-farm/utils/config.js +12 -44
- package/dist/agent-farm/utils/config.js.map +1 -1
- package/dist/agent-farm/utils/deps.d.ts.map +1 -1
- package/dist/agent-farm/utils/deps.js +0 -32
- package/dist/agent-farm/utils/deps.js.map +1 -1
- package/dist/agent-farm/utils/file-tabs.d.ts +27 -0
- package/dist/agent-farm/utils/file-tabs.d.ts.map +1 -0
- package/dist/agent-farm/utils/file-tabs.js +46 -0
- package/dist/agent-farm/utils/file-tabs.js.map +1 -0
- package/dist/agent-farm/utils/gate-status.d.ts +16 -0
- package/dist/agent-farm/utils/gate-status.d.ts.map +1 -0
- package/dist/agent-farm/utils/gate-status.js +79 -0
- package/dist/agent-farm/utils/gate-status.js.map +1 -0
- package/dist/agent-farm/utils/gate-watcher.d.ts +38 -0
- package/dist/agent-farm/utils/gate-watcher.d.ts.map +1 -0
- package/dist/agent-farm/utils/gate-watcher.js +122 -0
- package/dist/agent-farm/utils/gate-watcher.js.map +1 -0
- package/dist/agent-farm/utils/index.d.ts +0 -1
- package/dist/agent-farm/utils/index.d.ts.map +1 -1
- package/dist/agent-farm/utils/index.js +0 -1
- package/dist/agent-farm/utils/index.js.map +1 -1
- package/dist/agent-farm/utils/notifications.d.ts +30 -0
- package/dist/agent-farm/utils/notifications.d.ts.map +1 -0
- package/dist/agent-farm/utils/notifications.js +121 -0
- package/dist/agent-farm/utils/notifications.js.map +1 -0
- package/dist/agent-farm/utils/server-utils.d.ts +5 -5
- package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
- package/dist/agent-farm/utils/server-utils.js +5 -16
- package/dist/agent-farm/utils/server-utils.js.map +1 -1
- package/dist/agent-farm/utils/session.d.ts +32 -0
- package/dist/agent-farm/utils/session.d.ts.map +1 -0
- package/dist/agent-farm/utils/session.js +57 -0
- package/dist/agent-farm/utils/session.js.map +1 -0
- package/dist/agent-farm/utils/shell.d.ts +9 -22
- package/dist/agent-farm/utils/shell.d.ts.map +1 -1
- package/dist/agent-farm/utils/shell.js +34 -34
- package/dist/agent-farm/utils/shell.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -54
- package/dist/cli.js.map +1 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +49 -4
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/consult/index.d.ts +13 -2
- package/dist/commands/consult/index.d.ts.map +1 -1
- package/dist/commands/consult/index.js +245 -29
- package/dist/commands/consult/index.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +96 -79
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +41 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/porch/build-counter.d.ts +5 -0
- package/dist/commands/porch/build-counter.d.ts.map +1 -0
- package/dist/commands/porch/build-counter.js +5 -0
- package/dist/commands/porch/build-counter.js.map +1 -0
- package/dist/commands/porch/checks.d.ts +17 -29
- package/dist/commands/porch/checks.d.ts.map +1 -1
- package/dist/commands/porch/checks.js +96 -144
- package/dist/commands/porch/checks.js.map +1 -1
- package/dist/commands/porch/index.d.ts +25 -43
- package/dist/commands/porch/index.d.ts.map +1 -1
- package/dist/commands/porch/index.js +463 -1116
- package/dist/commands/porch/index.js.map +1 -1
- package/dist/commands/porch/next.d.ts +22 -0
- package/dist/commands/porch/next.d.ts.map +1 -0
- package/dist/commands/porch/next.js +571 -0
- package/dist/commands/porch/next.js.map +1 -0
- package/dist/commands/porch/plan.d.ts +70 -0
- package/dist/commands/porch/plan.d.ts.map +1 -0
- package/dist/commands/porch/plan.js +190 -0
- package/dist/commands/porch/plan.js.map +1 -0
- package/dist/commands/porch/prompts.d.ts +19 -0
- package/dist/commands/porch/prompts.d.ts.map +1 -0
- package/dist/commands/porch/prompts.js +277 -0
- package/dist/commands/porch/prompts.js.map +1 -0
- package/dist/commands/porch/protocol.d.ts +59 -0
- package/dist/commands/porch/protocol.d.ts.map +1 -0
- package/dist/commands/porch/protocol.js +294 -0
- package/dist/commands/porch/protocol.js.map +1 -0
- package/dist/commands/porch/state.d.ts +36 -107
- package/dist/commands/porch/state.d.ts.map +1 -1
- package/dist/commands/porch/state.js +120 -699
- package/dist/commands/porch/state.js.map +1 -1
- package/dist/commands/porch/types.d.ts +99 -164
- package/dist/commands/porch/types.d.ts.map +1 -1
- package/dist/commands/porch/types.js +2 -1
- package/dist/commands/porch/types.js.map +1 -1
- package/dist/commands/porch/verdict.d.ts +31 -0
- package/dist/commands/porch/verdict.d.ts.map +1 -0
- package/dist/commands/porch/verdict.js +59 -0
- package/dist/commands/porch/verdict.js.map +1 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +31 -0
- package/dist/commands/update.js.map +1 -1
- package/dist/lib/scaffold.d.ts +37 -0
- package/dist/lib/scaffold.d.ts.map +1 -1
- package/dist/lib/scaffold.js +114 -0
- package/dist/lib/scaffold.js.map +1 -1
- package/dist/terminal/index.d.ts +8 -0
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +5 -0
- package/dist/terminal/index.js.map +1 -0
- package/dist/terminal/pty-manager.d.ts +69 -0
- package/dist/terminal/pty-manager.d.ts.map +1 -0
- package/dist/terminal/pty-manager.js +377 -0
- package/dist/terminal/pty-manager.js.map +1 -0
- package/dist/terminal/pty-session.d.ts +104 -0
- package/dist/terminal/pty-session.d.ts.map +1 -0
- package/dist/terminal/pty-session.js +327 -0
- package/dist/terminal/pty-session.js.map +1 -0
- package/dist/terminal/ring-buffer.d.ts +34 -0
- package/dist/terminal/ring-buffer.d.ts.map +1 -0
- package/dist/terminal/ring-buffer.js +94 -0
- package/dist/terminal/ring-buffer.js.map +1 -0
- package/dist/terminal/session-manager.d.ts +115 -0
- package/dist/terminal/session-manager.d.ts.map +1 -0
- package/dist/terminal/session-manager.js +582 -0
- package/dist/terminal/session-manager.js.map +1 -0
- package/dist/terminal/shepherd-client.d.ts +66 -0
- package/dist/terminal/shepherd-client.d.ts.map +1 -0
- package/dist/terminal/shepherd-client.js +234 -0
- package/dist/terminal/shepherd-client.js.map +1 -0
- package/dist/terminal/shepherd-main.d.ts +19 -0
- package/dist/terminal/shepherd-main.d.ts.map +1 -0
- package/dist/terminal/shepherd-main.js +153 -0
- package/dist/terminal/shepherd-main.js.map +1 -0
- package/dist/terminal/shepherd-process.d.ts +75 -0
- package/dist/terminal/shepherd-process.d.ts.map +1 -0
- package/dist/terminal/shepherd-process.js +279 -0
- package/dist/terminal/shepherd-process.js.map +1 -0
- package/dist/terminal/shepherd-protocol.d.ts +115 -0
- package/dist/terminal/shepherd-protocol.d.ts.map +1 -0
- package/dist/terminal/shepherd-protocol.js +214 -0
- package/dist/terminal/shepherd-protocol.js.map +1 -0
- package/dist/terminal/shepherd-replay-buffer.d.ts +38 -0
- package/dist/terminal/shepherd-replay-buffer.d.ts.map +1 -0
- package/dist/terminal/shepherd-replay-buffer.js +94 -0
- package/dist/terminal/shepherd-replay-buffer.js.map +1 -0
- package/dist/terminal/ws-protocol.d.ts +27 -0
- package/dist/terminal/ws-protocol.d.ts.map +1 -0
- package/dist/terminal/ws-protocol.js +44 -0
- package/dist/terminal/ws-protocol.js.map +1 -0
- package/package.json +19 -5
- package/skeleton/.claude/skills/af/SKILL.md +89 -0
- package/skeleton/.claude/skills/codev/SKILL.md +41 -0
- package/skeleton/.claude/skills/consult/SKILL.md +81 -0
- package/skeleton/.claude/skills/generate-image/SKILL.md +56 -0
- package/skeleton/DEPENDENCIES.md +4 -62
- package/skeleton/builders.md +1 -1
- package/skeleton/consult-types/impl-review.md +18 -9
- package/skeleton/consult-types/integration-review.md +1 -1
- package/skeleton/consult-types/plan-review.md +1 -1
- package/skeleton/consult-types/pr-ready.md +1 -1
- package/skeleton/consult-types/spec-review.md +1 -1
- package/skeleton/porch/prompts/defend.md +1 -1
- package/skeleton/porch/prompts/evaluate.md +2 -2
- package/skeleton/porch/prompts/implement.md +1 -1
- package/skeleton/porch/prompts/plan.md +1 -1
- package/skeleton/porch/prompts/review.md +4 -4
- package/skeleton/porch/prompts/specify.md +1 -1
- package/skeleton/porch/prompts/understand.md +2 -2
- package/skeleton/protocol-schema.json +282 -0
- package/skeleton/protocols/bugfix/builder-prompt.md +54 -0
- package/skeleton/protocols/bugfix/prompts/fix.md +77 -0
- package/skeleton/protocols/bugfix/prompts/investigate.md +77 -0
- package/skeleton/protocols/bugfix/prompts/pr.md +84 -0
- package/skeleton/protocols/bugfix/protocol.json +20 -33
- package/skeleton/protocols/experiment/builder-prompt.md +52 -0
- package/skeleton/protocols/experiment/protocol.json +101 -0
- package/skeleton/protocols/experiment/protocol.md +3 -3
- package/skeleton/protocols/experiment/templates/notes.md +1 -1
- package/skeleton/protocols/maintain/builder-prompt.md +46 -0
- package/skeleton/protocols/maintain/prompts/audit.md +111 -0
- package/skeleton/protocols/maintain/prompts/clean.md +91 -0
- package/skeleton/protocols/maintain/prompts/sync.md +113 -0
- package/skeleton/protocols/maintain/prompts/verify.md +110 -0
- package/skeleton/protocols/maintain/protocol.json +141 -0
- package/skeleton/protocols/maintain/protocol.md +17 -11
- package/skeleton/protocols/protocol-schema.json +54 -1
- package/skeleton/protocols/spir/builder-prompt.md +59 -0
- package/skeleton/protocols/spir/prompts/implement.md +208 -0
- package/skeleton/protocols/{spider → spir}/prompts/plan.md +6 -70
- package/skeleton/protocols/{spider → spir}/prompts/review.md +20 -39
- package/skeleton/protocols/{spider → spir}/prompts/specify.md +33 -61
- package/skeleton/protocols/spir/protocol.json +156 -0
- package/skeleton/protocols/{spider → spir}/protocol.md +35 -21
- package/skeleton/protocols/{spider → spir}/templates/plan.md +14 -0
- package/skeleton/protocols/spir/templates/review.md +89 -0
- package/skeleton/protocols/tick/builder-prompt.md +56 -0
- package/skeleton/protocols/tick/protocol.json +7 -2
- package/skeleton/protocols/tick/protocol.md +18 -18
- package/skeleton/protocols/tick/templates/review.md +1 -1
- package/skeleton/resources/commands/agent-farm.md +63 -46
- package/skeleton/resources/commands/codev.md +0 -2
- package/skeleton/resources/commands/overview.md +7 -17
- package/skeleton/resources/workflow-reference.md +4 -4
- package/skeleton/roles/architect.md +152 -315
- package/skeleton/roles/builder.md +110 -218
- package/skeleton/roles/consultant.md +6 -6
- package/skeleton/templates/AGENTS.md +2 -2
- package/skeleton/templates/CLAUDE.md +2 -2
- package/skeleton/templates/cheatsheet.md +7 -5
- package/skeleton/templates/projectlist.md +1 -1
- package/templates/dashboard/index.html +17 -43
- package/templates/dashboard/js/dialogs.js +7 -7
- package/templates/dashboard/js/files.js +2 -2
- package/templates/dashboard/js/main.js +4 -4
- package/templates/dashboard/js/projects.js +3 -3
- package/templates/dashboard/js/tabs.js +1 -1
- package/templates/dashboard/js/utils.js +22 -87
- package/templates/open.html +26 -0
- package/templates/tower.html +642 -36
- package/dist/agent-farm/commands/kickoff.d.ts +0 -20
- package/dist/agent-farm/commands/kickoff.d.ts.map +0 -1
- package/dist/agent-farm/commands/kickoff.js +0 -337
- package/dist/agent-farm/commands/kickoff.js.map +0 -1
- package/dist/agent-farm/commands/rename.d.ts +0 -13
- package/dist/agent-farm/commands/rename.d.ts.map +0 -1
- package/dist/agent-farm/commands/rename.js +0 -33
- package/dist/agent-farm/commands/rename.js.map +0 -1
- package/dist/agent-farm/commands/tutorial.d.ts +0 -10
- package/dist/agent-farm/commands/tutorial.d.ts.map +0 -1
- package/dist/agent-farm/commands/tutorial.js +0 -49
- package/dist/agent-farm/commands/tutorial.js.map +0 -1
- package/dist/agent-farm/commands/util.d.ts +0 -15
- package/dist/agent-farm/commands/util.d.ts.map +0 -1
- package/dist/agent-farm/commands/util.js +0 -108
- package/dist/agent-farm/commands/util.js.map +0 -1
- package/dist/agent-farm/servers/dashboard-server.d.ts +0 -7
- package/dist/agent-farm/servers/dashboard-server.d.ts.map +0 -1
- package/dist/agent-farm/servers/dashboard-server.js +0 -1872
- package/dist/agent-farm/servers/dashboard-server.js.map +0 -1
- package/dist/agent-farm/servers/open-server.d.ts +0 -7
- package/dist/agent-farm/servers/open-server.d.ts.map +0 -1
- package/dist/agent-farm/servers/open-server.js +0 -315
- package/dist/agent-farm/servers/open-server.js.map +0 -1
- package/dist/agent-farm/tutorial/index.d.ts +0 -8
- package/dist/agent-farm/tutorial/index.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/index.js +0 -8
- package/dist/agent-farm/tutorial/index.js.map +0 -1
- package/dist/agent-farm/tutorial/prompts.d.ts +0 -57
- package/dist/agent-farm/tutorial/prompts.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/prompts.js +0 -147
- package/dist/agent-farm/tutorial/prompts.js.map +0 -1
- package/dist/agent-farm/tutorial/runner.d.ts +0 -52
- package/dist/agent-farm/tutorial/runner.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/runner.js +0 -204
- package/dist/agent-farm/tutorial/runner.js.map +0 -1
- package/dist/agent-farm/tutorial/state.d.ts +0 -26
- package/dist/agent-farm/tutorial/state.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/state.js +0 -89
- package/dist/agent-farm/tutorial/state.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/first-spec.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/first-spec.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/first-spec.js +0 -136
- package/dist/agent-farm/tutorial/steps/first-spec.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/implementation.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/implementation.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/implementation.js +0 -76
- package/dist/agent-farm/tutorial/steps/implementation.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/index.d.ts +0 -10
- package/dist/agent-farm/tutorial/steps/index.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/index.js +0 -10
- package/dist/agent-farm/tutorial/steps/index.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/planning.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/planning.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/planning.js +0 -143
- package/dist/agent-farm/tutorial/steps/planning.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/review.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/review.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/review.js +0 -78
- package/dist/agent-farm/tutorial/steps/review.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/setup.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/setup.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/setup.js +0 -126
- package/dist/agent-farm/tutorial/steps/setup.js.map +0 -1
- package/dist/agent-farm/tutorial/steps/welcome.d.ts +0 -7
- package/dist/agent-farm/tutorial/steps/welcome.d.ts.map +0 -1
- package/dist/agent-farm/tutorial/steps/welcome.js +0 -50
- package/dist/agent-farm/tutorial/steps/welcome.js.map +0 -1
- package/dist/agent-farm/utils/orphan-handler.d.ts +0 -27
- package/dist/agent-farm/utils/orphan-handler.d.ts.map +0 -1
- package/dist/agent-farm/utils/orphan-handler.js +0 -149
- package/dist/agent-farm/utils/orphan-handler.js.map +0 -1
- package/dist/agent-farm/utils/port-registry.d.ts +0 -58
- package/dist/agent-farm/utils/port-registry.d.ts.map +0 -1
- package/dist/agent-farm/utils/port-registry.js +0 -166
- package/dist/agent-farm/utils/port-registry.js.map +0 -1
- package/dist/agent-farm/utils/terminal-ports.d.ts +0 -18
- package/dist/agent-farm/utils/terminal-ports.d.ts.map +0 -1
- package/dist/agent-farm/utils/terminal-ports.js +0 -35
- package/dist/agent-farm/utils/terminal-ports.js.map +0 -1
- package/dist/commands/pcheck/cache.d.ts +0 -48
- package/dist/commands/pcheck/cache.d.ts.map +0 -1
- package/dist/commands/pcheck/cache.js +0 -170
- package/dist/commands/pcheck/cache.js.map +0 -1
- package/dist/commands/pcheck/evaluator.d.ts +0 -15
- package/dist/commands/pcheck/evaluator.d.ts.map +0 -1
- package/dist/commands/pcheck/evaluator.js +0 -246
- package/dist/commands/pcheck/evaluator.js.map +0 -1
- package/dist/commands/pcheck/index.d.ts +0 -12
- package/dist/commands/pcheck/index.d.ts.map +0 -1
- package/dist/commands/pcheck/index.js +0 -249
- package/dist/commands/pcheck/index.js.map +0 -1
- package/dist/commands/pcheck/parser.d.ts +0 -39
- package/dist/commands/pcheck/parser.d.ts.map +0 -1
- package/dist/commands/pcheck/parser.js +0 -155
- package/dist/commands/pcheck/parser.js.map +0 -1
- package/dist/commands/pcheck/types.d.ts +0 -82
- package/dist/commands/pcheck/types.d.ts.map +0 -1
- package/dist/commands/pcheck/types.js +0 -5
- package/dist/commands/pcheck/types.js.map +0 -1
- package/dist/commands/porch/consultation.d.ts +0 -56
- package/dist/commands/porch/consultation.d.ts.map +0 -1
- package/dist/commands/porch/consultation.js +0 -330
- package/dist/commands/porch/consultation.js.map +0 -1
- package/dist/commands/porch/notifications.d.ts +0 -99
- package/dist/commands/porch/notifications.d.ts.map +0 -1
- package/dist/commands/porch/notifications.js +0 -223
- package/dist/commands/porch/notifications.js.map +0 -1
- package/dist/commands/porch/plan-parser.d.ts +0 -38
- package/dist/commands/porch/plan-parser.d.ts.map +0 -1
- package/dist/commands/porch/plan-parser.js +0 -166
- package/dist/commands/porch/plan-parser.js.map +0 -1
- package/dist/commands/porch/protocol-loader.d.ts +0 -46
- package/dist/commands/porch/protocol-loader.d.ts.map +0 -1
- package/dist/commands/porch/protocol-loader.js +0 -253
- package/dist/commands/porch/protocol-loader.js.map +0 -1
- package/dist/commands/porch/signal-parser.d.ts +0 -88
- package/dist/commands/porch/signal-parser.d.ts.map +0 -1
- package/dist/commands/porch/signal-parser.js +0 -148
- package/dist/commands/porch/signal-parser.js.map +0 -1
- package/dist/commands/tower.d.ts +0 -16
- package/dist/commands/tower.d.ts.map +0 -1
- package/dist/commands/tower.js +0 -21
- package/dist/commands/tower.js.map +0 -1
- package/skeleton/config.json +0 -7
- package/skeleton/porch/protocols/bugfix.json +0 -85
- package/skeleton/porch/protocols/spider.json +0 -135
- package/skeleton/porch/protocols/tick.json +0 -76
- package/skeleton/protocols/spider/prompts/defend.md +0 -215
- package/skeleton/protocols/spider/prompts/evaluate.md +0 -241
- package/skeleton/protocols/spider/prompts/implement.md +0 -149
- package/skeleton/protocols/spider/protocol.json +0 -210
- package/skeleton/protocols/spider/templates/review.md +0 -207
- package/templates/dashboard/css/activity.css +0 -151
- package/templates/dashboard/js/activity.js +0 -112
- /package/skeleton/protocols/{spider → spir}/templates/spec.md +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tower API Client (Spec 0090 Phase 3)
|
|
3
|
+
*
|
|
4
|
+
* Provides a client for CLI commands to interact with the tower daemon.
|
|
5
|
+
* Handles local-key authentication and common API operations.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
8
|
+
import { resolve } from 'node:path';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
import { randomBytes } from 'node:crypto';
|
|
11
|
+
// Tower configuration
|
|
12
|
+
const DEFAULT_TOWER_PORT = 4100;
|
|
13
|
+
const AGENT_FARM_DIR = resolve(homedir(), '.agent-farm');
|
|
14
|
+
const LOCAL_KEY_PATH = resolve(AGENT_FARM_DIR, 'local-key');
|
|
15
|
+
// Request timeout
|
|
16
|
+
const REQUEST_TIMEOUT_MS = 10000;
|
|
17
|
+
/**
|
|
18
|
+
* Get or create the local key for CLI authentication
|
|
19
|
+
*/
|
|
20
|
+
function getLocalKey() {
|
|
21
|
+
if (!existsSync(AGENT_FARM_DIR)) {
|
|
22
|
+
mkdirSync(AGENT_FARM_DIR, { recursive: true, mode: 0o700 });
|
|
23
|
+
}
|
|
24
|
+
if (!existsSync(LOCAL_KEY_PATH)) {
|
|
25
|
+
const key = randomBytes(32).toString('hex');
|
|
26
|
+
writeFileSync(LOCAL_KEY_PATH, key, { mode: 0o600 });
|
|
27
|
+
return key;
|
|
28
|
+
}
|
|
29
|
+
return readFileSync(LOCAL_KEY_PATH, 'utf-8').trim();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Encode a project path for use in tower API URLs
|
|
33
|
+
*/
|
|
34
|
+
export function encodeProjectPath(projectPath) {
|
|
35
|
+
return Buffer.from(projectPath).toString('base64url');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Decode a project path from tower API URL
|
|
39
|
+
*/
|
|
40
|
+
export function decodeProjectPath(encoded) {
|
|
41
|
+
return Buffer.from(encoded, 'base64url').toString('utf-8');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Tower API client class
|
|
45
|
+
*/
|
|
46
|
+
export class TowerClient {
|
|
47
|
+
baseUrl;
|
|
48
|
+
localKey;
|
|
49
|
+
constructor(port = DEFAULT_TOWER_PORT) {
|
|
50
|
+
this.baseUrl = `http://localhost:${port}`;
|
|
51
|
+
this.localKey = getLocalKey();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Make a request to the tower API
|
|
55
|
+
*/
|
|
56
|
+
async request(path, options = {}) {
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
59
|
+
...options,
|
|
60
|
+
headers: {
|
|
61
|
+
...options.headers,
|
|
62
|
+
'codev-web-key': this.localKey,
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
},
|
|
65
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const text = await response.text();
|
|
69
|
+
let error;
|
|
70
|
+
try {
|
|
71
|
+
const json = JSON.parse(text);
|
|
72
|
+
error = json.error || json.message || text;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
error = text;
|
|
76
|
+
}
|
|
77
|
+
return { ok: false, status: response.status, error };
|
|
78
|
+
}
|
|
79
|
+
if (response.status === 204) {
|
|
80
|
+
return { ok: true, status: 204 };
|
|
81
|
+
}
|
|
82
|
+
const data = (await response.json());
|
|
83
|
+
return { ok: true, status: response.status, data };
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
87
|
+
if (message.includes('ECONNREFUSED')) {
|
|
88
|
+
return { ok: false, status: 0, error: 'Tower not running' };
|
|
89
|
+
}
|
|
90
|
+
if (message.includes('timeout')) {
|
|
91
|
+
return { ok: false, status: 0, error: 'Request timeout' };
|
|
92
|
+
}
|
|
93
|
+
return { ok: false, status: 0, error: message };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if tower is running and healthy
|
|
98
|
+
*/
|
|
99
|
+
async isRunning() {
|
|
100
|
+
const result = await this.request('/health');
|
|
101
|
+
return result.ok && result.data?.status === 'healthy';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get tower health status
|
|
105
|
+
*/
|
|
106
|
+
async getHealth() {
|
|
107
|
+
const result = await this.request('/health');
|
|
108
|
+
return result.ok ? result.data : null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List all projects known to tower
|
|
112
|
+
*/
|
|
113
|
+
async listProjects() {
|
|
114
|
+
const result = await this.request('/api/projects');
|
|
115
|
+
return result.ok ? result.data.projects : [];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Activate a project (start its dashboard)
|
|
119
|
+
*/
|
|
120
|
+
async activateProject(projectPath) {
|
|
121
|
+
const encoded = encodeProjectPath(projectPath);
|
|
122
|
+
const result = await this.request(`/api/projects/${encoded}/activate`, { method: 'POST' });
|
|
123
|
+
if (!result.ok) {
|
|
124
|
+
return { ok: false, error: result.error };
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
ok: result.data?.success ?? true,
|
|
128
|
+
adopted: result.data?.adopted,
|
|
129
|
+
error: result.data?.error,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Deactivate a project (stop its dashboard)
|
|
134
|
+
*/
|
|
135
|
+
async deactivateProject(projectPath) {
|
|
136
|
+
const encoded = encodeProjectPath(projectPath);
|
|
137
|
+
const result = await this.request(`/api/projects/${encoded}/deactivate`, { method: 'POST' });
|
|
138
|
+
if (!result.ok) {
|
|
139
|
+
return { ok: false, error: result.error };
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
ok: result.data?.success ?? true,
|
|
143
|
+
stopped: result.data?.stopped,
|
|
144
|
+
error: result.data?.error,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get status of a specific project
|
|
149
|
+
*/
|
|
150
|
+
async getProjectStatus(projectPath) {
|
|
151
|
+
const encoded = encodeProjectPath(projectPath);
|
|
152
|
+
const result = await this.request(`/api/projects/${encoded}/status`);
|
|
153
|
+
return result.ok ? result.data : null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a terminal session
|
|
157
|
+
*/
|
|
158
|
+
async createTerminal(options) {
|
|
159
|
+
const result = await this.request('/api/terminals', {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
body: JSON.stringify(options),
|
|
162
|
+
});
|
|
163
|
+
return result.ok ? result.data : null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* List all terminal sessions
|
|
167
|
+
*/
|
|
168
|
+
async listTerminals() {
|
|
169
|
+
const result = await this.request('/api/terminals');
|
|
170
|
+
return result.ok ? result.data.terminals : [];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get terminal info
|
|
174
|
+
*/
|
|
175
|
+
async getTerminal(terminalId) {
|
|
176
|
+
const result = await this.request(`/api/terminals/${terminalId}`);
|
|
177
|
+
return result.ok ? result.data : null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Write data to a terminal session
|
|
181
|
+
*/
|
|
182
|
+
async writeTerminal(terminalId, data) {
|
|
183
|
+
const result = await this.request(`/api/terminals/${terminalId}/write`, {
|
|
184
|
+
method: 'POST',
|
|
185
|
+
body: JSON.stringify({ data }),
|
|
186
|
+
});
|
|
187
|
+
return result.ok;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Kill a terminal session
|
|
191
|
+
*/
|
|
192
|
+
async killTerminal(terminalId) {
|
|
193
|
+
const result = await this.request(`/api/terminals/${terminalId}`, { method: 'DELETE' });
|
|
194
|
+
return result.ok;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Resize a terminal
|
|
198
|
+
*/
|
|
199
|
+
async resizeTerminal(terminalId, cols, rows) {
|
|
200
|
+
const result = await this.request(`/api/terminals/${terminalId}/resize`, {
|
|
201
|
+
method: 'POST',
|
|
202
|
+
body: JSON.stringify({ cols, rows }),
|
|
203
|
+
});
|
|
204
|
+
return result.ok ? result.data : null;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get the tower dashboard URL for a project
|
|
208
|
+
*/
|
|
209
|
+
getProjectUrl(projectPath) {
|
|
210
|
+
const encoded = encodeProjectPath(projectPath);
|
|
211
|
+
return `${this.baseUrl}/project/${encoded}/`;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the WebSocket URL for a terminal
|
|
215
|
+
*/
|
|
216
|
+
getTerminalWsUrl(terminalId) {
|
|
217
|
+
return `ws://localhost:${new URL(this.baseUrl).port}/ws/terminal/${terminalId}`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Default tower client instance
|
|
222
|
+
*/
|
|
223
|
+
let defaultClient = null;
|
|
224
|
+
/**
|
|
225
|
+
* Get the default tower client
|
|
226
|
+
*/
|
|
227
|
+
export function getTowerClient(port) {
|
|
228
|
+
if (!defaultClient || (port && port !== DEFAULT_TOWER_PORT)) {
|
|
229
|
+
defaultClient = new TowerClient(port);
|
|
230
|
+
}
|
|
231
|
+
return defaultClient;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=tower-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tower-client.js","sourceRoot":"","sources":["../../../src/agent-farm/lib/tower-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OA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,CAAC,OAAO,CAAC,CAAC,IAAI,gBAAgB,UAAU,EAAE,CAAC;IAClF,CAAC;CACF;AAED;;GAEG;AACH,IAAI,aAAa,GAAuB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,kBAAkB,CAAC,EAAE,CAAC;QAC5D,aAAa,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP/2 Role-Reversal Tunnel Client (Spec 0097 Phase 3, TICK-001)
|
|
3
|
+
*
|
|
4
|
+
* Opens a WebSocket connection to codevos.ai/tunnel, authenticates
|
|
5
|
+
* with JSON messages, then runs an HTTP/2 *server* over the WebSocket
|
|
6
|
+
* stream. codevos.ai acts as the HTTP/2 *client*, sending requests
|
|
7
|
+
* through the tunnel. The tower proxies those requests to localhost.
|
|
8
|
+
*
|
|
9
|
+
* TICK-001: Transport changed from raw TCP/TLS to WebSocket.
|
|
10
|
+
* The H2 role-reversal is transport-agnostic — it works over any duplex stream.
|
|
11
|
+
*/
|
|
12
|
+
export interface TunnelClientOptions {
|
|
13
|
+
serverUrl: string;
|
|
14
|
+
apiKey: string;
|
|
15
|
+
towerId: string;
|
|
16
|
+
localPort: number;
|
|
17
|
+
/** @deprecated Use serverUrl protocol (ws:// vs wss://) instead */
|
|
18
|
+
tunnelPort?: number;
|
|
19
|
+
/** @deprecated No longer needed — WebSocket handles TLS via wss:// */
|
|
20
|
+
usePlainTcp?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type TunnelState = 'disconnected' | 'connecting' | 'connected' | 'auth_failed';
|
|
23
|
+
export interface TowerMetadata {
|
|
24
|
+
projects: Array<{
|
|
25
|
+
path: string;
|
|
26
|
+
name: string;
|
|
27
|
+
}>;
|
|
28
|
+
terminals: Array<{
|
|
29
|
+
id: string;
|
|
30
|
+
projectPath: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
type StateChangeCallback = (state: TunnelState, previousState: TunnelState) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Calculate reconnection backoff with exponential increase and jitter.
|
|
36
|
+
* Exported for unit testing.
|
|
37
|
+
*
|
|
38
|
+
* Formula: min(1000 * 2^attempt + random(0, 1000), 60000)
|
|
39
|
+
* After 10 consecutive failures: 300000ms (5 min)
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateBackoff(attempt: number, randomFn?: () => number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a request path should be blocked from tunnel proxying.
|
|
44
|
+
* Normalizes percent-encoding and collapses dot segments before checking,
|
|
45
|
+
* preventing bypass via encoded slashes (%2F), double dots, etc.
|
|
46
|
+
* Exported for unit testing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isBlockedPath(path: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Filter hop-by-hop headers from a headers object.
|
|
51
|
+
* Returns a new object with only end-to-end headers.
|
|
52
|
+
* Exported for unit testing.
|
|
53
|
+
*/
|
|
54
|
+
export declare function filterHopByHopHeaders(headers: Record<string, string | string[] | undefined>): Record<string, string | string[]>;
|
|
55
|
+
export declare class TunnelClient {
|
|
56
|
+
private options;
|
|
57
|
+
private state;
|
|
58
|
+
private connectedAt;
|
|
59
|
+
private stateListeners;
|
|
60
|
+
private ws;
|
|
61
|
+
private wsStream;
|
|
62
|
+
private h2Server;
|
|
63
|
+
private h2Session;
|
|
64
|
+
private reconnectTimer;
|
|
65
|
+
private consecutiveFailures;
|
|
66
|
+
private rateLimitCount;
|
|
67
|
+
private destroyed;
|
|
68
|
+
constructor(options: TunnelClientOptions);
|
|
69
|
+
getState(): TunnelState;
|
|
70
|
+
getUptime(): number | null;
|
|
71
|
+
onStateChange(callback: StateChangeCallback): void;
|
|
72
|
+
private setState;
|
|
73
|
+
/**
|
|
74
|
+
* Initiate tunnel connection. Non-blocking — connection happens asynchronously.
|
|
75
|
+
*/
|
|
76
|
+
connect(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Gracefully disconnect the tunnel.
|
|
79
|
+
*/
|
|
80
|
+
disconnect(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Reset the circuit breaker (e.g. after config change).
|
|
83
|
+
* Allows reconnection after auth_failed state.
|
|
84
|
+
*/
|
|
85
|
+
resetCircuitBreaker(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Send tower metadata to codevos.ai.
|
|
88
|
+
*
|
|
89
|
+
* Uses a dual mechanism:
|
|
90
|
+
* 1. Caches metadata for `GET /__tower/metadata` (served when codevos.ai H2 client polls)
|
|
91
|
+
* 2. When connected, proactively POSTs to `serverUrl/api/tower/metadata` via HTTPS
|
|
92
|
+
*
|
|
93
|
+
* Call before `connect()` to set initial metadata, or after to update it.
|
|
94
|
+
*/
|
|
95
|
+
sendMetadata(metadata: TowerMetadata): void;
|
|
96
|
+
/** Stored metadata for serving via GET /__tower/metadata */
|
|
97
|
+
private _pendingMetadata;
|
|
98
|
+
/**
|
|
99
|
+
* Push metadata to codevos.ai via outbound HTTPS POST.
|
|
100
|
+
* Best-effort — failures are silently ignored since codevos.ai
|
|
101
|
+
* can also poll via the H2 tunnel's GET /__tower/metadata handler.
|
|
102
|
+
*/
|
|
103
|
+
private pushMetadataViaHttp;
|
|
104
|
+
private clearReconnectTimer;
|
|
105
|
+
private scheduleReconnect;
|
|
106
|
+
private cleanup;
|
|
107
|
+
private doConnect;
|
|
108
|
+
private onWsOpen;
|
|
109
|
+
private handleAuthError;
|
|
110
|
+
private handleConnectionError;
|
|
111
|
+
private startH2Server;
|
|
112
|
+
private handleH2Stream;
|
|
113
|
+
private handleWebSocketConnect;
|
|
114
|
+
private proxyHttpRequest;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=tunnel-client.d.ts.map
|
|
@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