@kya-os/cli 1.8.1 → 1.8.3
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/dist/commands/agent.d.ts +35 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +321 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/build.js +2 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkpoint-init.d.ts +1 -1
- package/dist/commands/checkpoint-init.d.ts.map +1 -1
- package/dist/commands/checkpoint-init.js +8 -41
- package/dist/commands/checkpoint-init.js.map +1 -1
- package/dist/commands/claim.js +2 -2
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/dco.d.ts +59 -0
- package/dist/commands/dco.d.ts.map +1 -1
- package/dist/commands/dco.js +280 -5
- package/dist/commands/dco.js.map +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +18 -24
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env.js +6 -6
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/identity.js +3 -3
- package/dist/commands/identity.js.map +1 -1
- package/dist/commands/init-stages.d.ts +141 -0
- package/dist/commands/init-stages.d.ts.map +1 -0
- package/dist/commands/init-stages.js +684 -0
- package/dist/commands/init-stages.js.map +1 -0
- package/dist/commands/init.d.ts +46 -16
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +229 -279
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/orchestrator.d.ts +18 -0
- package/dist/commands/orchestrator.d.ts.map +1 -0
- package/dist/commands/orchestrator.js +251 -0
- package/dist/commands/orchestrator.js.map +1 -0
- package/dist/commands/register.d.ts +1 -1
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +35 -7
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/review.d.ts +48 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +220 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/rotate.js +4 -4
- package/dist/commands/rotate.js.map +1 -1
- package/dist/commands/score.d.ts +15 -0
- package/dist/commands/score.d.ts.map +1 -0
- package/dist/commands/score.js +471 -0
- package/dist/commands/score.js.map +1 -0
- package/dist/commands/start.js +3 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/verify.js +6 -6
- package/dist/commands/verify.js.map +1 -1
- package/dist/dco.d.ts +4 -0
- package/dist/dco.d.ts.map +1 -0
- package/dist/dco.js +23 -0
- package/dist/dco.js.map +1 -0
- package/dist/index.js +52 -9
- package/dist/orchestrator/daemon.d.ts +137 -0
- package/dist/orchestrator/daemon.d.ts.map +1 -0
- package/dist/orchestrator/daemon.js +242 -0
- package/dist/orchestrator/daemon.js.map +1 -0
- package/dist/orchestrator/db/dispatches.d.ts +108 -0
- package/dist/orchestrator/db/dispatches.d.ts.map +1 -0
- package/dist/orchestrator/db/dispatches.js +122 -0
- package/dist/orchestrator/db/dispatches.js.map +1 -0
- package/dist/orchestrator/db/index.d.ts +50 -0
- package/dist/orchestrator/db/index.d.ts.map +1 -0
- package/dist/orchestrator/db/index.js +116 -0
- package/dist/orchestrator/db/index.js.map +1 -0
- package/dist/orchestrator/db/journal.d.ts +93 -0
- package/dist/orchestrator/db/journal.d.ts.map +1 -0
- package/dist/orchestrator/db/journal.js +91 -0
- package/dist/orchestrator/db/journal.js.map +1 -0
- package/dist/orchestrator/db/liveness.d.ts +97 -0
- package/dist/orchestrator/db/liveness.d.ts.map +1 -0
- package/dist/orchestrator/db/liveness.js +105 -0
- package/dist/orchestrator/db/liveness.js.map +1 -0
- package/dist/orchestrator/db/mission.d.ts +78 -0
- package/dist/orchestrator/db/mission.d.ts.map +1 -0
- package/dist/orchestrator/db/mission.js +99 -0
- package/dist/orchestrator/db/mission.js.map +1 -0
- package/dist/orchestrator/db/schema.d.ts +14 -0
- package/dist/orchestrator/db/schema.d.ts.map +1 -0
- package/dist/orchestrator/db/schema.js +169 -0
- package/dist/orchestrator/db/schema.js.map +1 -0
- package/dist/orchestrator/db/tickets.d.ts +147 -0
- package/dist/orchestrator/db/tickets.d.ts.map +1 -0
- package/dist/orchestrator/db/tickets.js +238 -0
- package/dist/orchestrator/db/tickets.js.map +1 -0
- package/dist/orchestrator/db/verdicts.d.ts +187 -0
- package/dist/orchestrator/db/verdicts.d.ts.map +1 -0
- package/dist/orchestrator/db/verdicts.js +197 -0
- package/dist/orchestrator/db/verdicts.js.map +1 -0
- package/dist/orchestrator/events.d.ts +69 -0
- package/dist/orchestrator/events.d.ts.map +1 -0
- package/dist/orchestrator/events.js +20 -0
- package/dist/orchestrator/events.js.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts +159 -0
- package/dist/orchestrator/github-credential-anchor-sender.d.ts.map +1 -0
- package/dist/orchestrator/github-credential-anchor-sender.js +313 -0
- package/dist/orchestrator/github-credential-anchor-sender.js.map +1 -0
- package/dist/orchestrator/hub-dispatch.d.ts +120 -0
- package/dist/orchestrator/hub-dispatch.d.ts.map +1 -0
- package/dist/orchestrator/hub-dispatch.js +257 -0
- package/dist/orchestrator/hub-dispatch.js.map +1 -0
- package/dist/orchestrator/hub-observer.d.ts +201 -0
- package/dist/orchestrator/hub-observer.d.ts.map +1 -0
- package/dist/orchestrator/hub-observer.js +474 -0
- package/dist/orchestrator/hub-observer.js.map +1 -0
- package/dist/orchestrator/journal-writer.d.ts +80 -0
- package/dist/orchestrator/journal-writer.d.ts.map +1 -0
- package/dist/orchestrator/journal-writer.js +113 -0
- package/dist/orchestrator/journal-writer.js.map +1 -0
- package/dist/orchestrator/mcp/server.d.ts +136 -0
- package/dist/orchestrator/mcp/server.d.ts.map +1 -0
- package/dist/orchestrator/mcp/server.js +582 -0
- package/dist/orchestrator/mcp/server.js.map +1 -0
- package/dist/orchestrator/mcp/stdio.d.ts +22 -0
- package/dist/orchestrator/mcp/stdio.d.ts.map +1 -0
- package/dist/orchestrator/mcp/stdio.js +51 -0
- package/dist/orchestrator/mcp/stdio.js.map +1 -0
- package/dist/orchestrator/review.d.ts +131 -0
- package/dist/orchestrator/review.d.ts.map +1 -0
- package/dist/orchestrator/review.js +322 -0
- package/dist/orchestrator/review.js.map +1 -0
- package/dist/tui/app.d.ts +33 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +71 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/components.d.ts +110 -0
- package/dist/tui/components.d.ts.map +1 -0
- package/dist/tui/components.js +118 -0
- package/dist/tui/components.js.map +1 -0
- package/dist/tui/index.d.ts +30 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +95 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/keymap.d.ts +33 -0
- package/dist/tui/keymap.d.ts.map +1 -0
- package/dist/tui/keymap.js +49 -0
- package/dist/tui/keymap.js.map +1 -0
- package/dist/tui/nav.d.ts +29 -0
- package/dist/tui/nav.d.ts.map +1 -0
- package/dist/tui/nav.js +39 -0
- package/dist/tui/nav.js.map +1 -0
- package/dist/tui/sanitize.d.ts +25 -0
- package/dist/tui/sanitize.d.ts.map +1 -0
- package/dist/tui/sanitize.js +36 -0
- package/dist/tui/sanitize.js.map +1 -0
- package/dist/tui/theme.d.ts +32 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +63 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/views/agents.d.ts +67 -0
- package/dist/tui/views/agents.d.ts.map +1 -0
- package/dist/tui/views/agents.js +231 -0
- package/dist/tui/views/agents.js.map +1 -0
- package/dist/tui/views/index.d.ts +93 -0
- package/dist/tui/views/index.d.ts.map +1 -0
- package/dist/tui/views/index.js +150 -0
- package/dist/tui/views/index.js.map +1 -0
- package/dist/tui/views/registry.d.ts +22 -0
- package/dist/tui/views/registry.d.ts.map +1 -0
- package/dist/tui/views/registry.js +110 -0
- package/dist/tui/views/registry.js.map +1 -0
- package/dist/utils/agent/backoff.d.ts +31 -0
- package/dist/utils/agent/backoff.d.ts.map +1 -0
- package/dist/utils/agent/backoff.js +51 -0
- package/dist/utils/agent/backoff.js.map +1 -0
- package/dist/utils/agent/markers.d.ts +87 -0
- package/dist/utils/agent/markers.d.ts.map +1 -0
- package/dist/utils/agent/markers.js +147 -0
- package/dist/utils/agent/markers.js.map +1 -0
- package/dist/utils/agent/review.d.ts +67 -0
- package/dist/utils/agent/review.d.ts.map +1 -0
- package/dist/utils/agent/review.js +305 -0
- package/dist/utils/agent/review.js.map +1 -0
- package/dist/utils/agent/spawn-agent.d.ts +117 -0
- package/dist/utils/agent/spawn-agent.d.ts.map +1 -0
- package/dist/utils/agent/spawn-agent.js +177 -0
- package/dist/utils/agent/spawn-agent.js.map +1 -0
- package/dist/utils/agent/task.d.ts +101 -0
- package/dist/utils/agent/task.d.ts.map +1 -0
- package/dist/utils/agent/task.js +357 -0
- package/dist/utils/agent/task.js.map +1 -0
- package/dist/utils/agent/verify.d.ts +47 -0
- package/dist/utils/agent/verify.d.ts.map +1 -0
- package/dist/utils/agent/verify.js +144 -0
- package/dist/utils/agent/verify.js.map +1 -0
- package/dist/utils/agent-detector.d.ts +48 -0
- package/dist/utils/agent-detector.d.ts.map +1 -0
- package/dist/utils/agent-detector.js +74 -0
- package/dist/utils/agent-detector.js.map +1 -0
- package/dist/utils/agent-profile-stage.d.ts +70 -0
- package/dist/utils/agent-profile-stage.d.ts.map +1 -0
- package/dist/utils/agent-profile-stage.js +153 -0
- package/dist/utils/agent-profile-stage.js.map +1 -0
- package/dist/utils/agent-profiles.d.ts +27 -0
- package/dist/utils/agent-profiles.d.ts.map +1 -0
- package/dist/utils/agent-profiles.js +61 -0
- package/dist/utils/agent-profiles.js.map +1 -0
- package/dist/utils/checkpoint-api.d.ts +1 -1
- package/dist/utils/checkpoint-api.js +1 -1
- package/dist/utils/checkpoint-env.d.ts +1 -1
- package/dist/utils/checkpoint-env.js +2 -2
- package/dist/utils/checkpoint-env.js.map +1 -1
- package/dist/utils/checkpoint-scaffold.d.ts +1 -1
- package/dist/utils/checkpoint-scaffold.js +1 -1
- package/dist/utils/cli-kit/browser.d.ts +24 -0
- package/dist/utils/cli-kit/browser.d.ts.map +1 -0
- package/dist/utils/cli-kit/browser.js +58 -0
- package/dist/utils/cli-kit/browser.js.map +1 -0
- package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
- package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
- package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
- package/dist/utils/cli-kit/claim-polling.js.map +1 -0
- package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
- package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
- package/dist/utils/cli-kit/diagnostics.js +11 -0
- package/dist/utils/cli-kit/diagnostics.js.map +1 -0
- package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
- package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
- package/dist/utils/cli-kit/fs-safe.js +20 -0
- package/dist/utils/cli-kit/fs-safe.js.map +1 -0
- package/dist/utils/cli-kit/index.d.ts +15 -0
- package/dist/utils/cli-kit/index.d.ts.map +1 -0
- package/dist/utils/cli-kit/index.js +10 -0
- package/dist/utils/cli-kit/index.js.map +1 -0
- package/dist/utils/cli-kit/json-file.d.ts +21 -0
- package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
- package/dist/utils/cli-kit/json-file.js +51 -0
- package/dist/utils/cli-kit/json-file.js.map +1 -0
- package/dist/utils/cli-kit/marker-block.d.ts +26 -0
- package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
- package/dist/utils/cli-kit/marker-block.js +61 -0
- package/dist/utils/cli-kit/marker-block.js.map +1 -0
- package/dist/utils/cli-kit/paths.d.ts +15 -0
- package/dist/utils/cli-kit/paths.d.ts.map +1 -0
- package/dist/utils/cli-kit/paths.js +21 -0
- package/dist/utils/cli-kit/paths.js.map +1 -0
- package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
- package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
- package/dist/utils/cli-kit/secure-storage.js +20 -0
- package/dist/utils/cli-kit/secure-storage.js.map +1 -0
- package/dist/utils/cli-kit/step-report.d.ts +16 -0
- package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
- package/dist/utils/cli-kit/step-report.js +36 -0
- package/dist/utils/cli-kit/step-report.js.map +1 -0
- package/dist/utils/dco/agent-metadata.d.ts +1 -1
- package/dist/utils/dco/agent-metadata.js +1 -1
- package/dist/utils/dco/agent-metadata.js.map +1 -1
- package/dist/utils/dco/claude-config.d.ts +18 -14
- package/dist/utils/dco/claude-config.d.ts.map +1 -1
- package/dist/utils/dco/claude-config.js +31 -97
- package/dist/utils/dco/claude-config.js.map +1 -1
- package/dist/utils/dco/dispatch.d.ts +134 -0
- package/dist/utils/dco/dispatch.d.ts.map +1 -0
- package/dist/utils/dco/dispatch.js +399 -0
- package/dist/utils/dco/dispatch.js.map +1 -0
- package/dist/utils/dco/fix.d.ts +122 -0
- package/dist/utils/dco/fix.d.ts.map +1 -0
- package/dist/utils/dco/fix.js +560 -0
- package/dist/utils/dco/fix.js.map +1 -0
- package/dist/utils/dco/git-config.d.ts.map +1 -1
- package/dist/utils/dco/git-config.js +5 -3
- package/dist/utils/dco/git-config.js.map +1 -1
- package/dist/utils/dco/github.d.ts +101 -0
- package/dist/utils/dco/github.d.ts.map +1 -1
- package/dist/utils/dco/github.js +133 -0
- package/dist/utils/dco/github.js.map +1 -1
- package/dist/utils/dco/paths.d.ts +1 -8
- package/dist/utils/dco/paths.d.ts.map +1 -1
- package/dist/utils/dco/paths.js +3 -12
- package/dist/utils/dco/paths.js.map +1 -1
- package/dist/utils/dco/render.d.ts +1 -1
- package/dist/utils/dco/render.d.ts.map +1 -1
- package/dist/utils/dco/render.js +4 -21
- package/dist/utils/dco/render.js.map +1 -1
- package/dist/utils/dco/resolve-agent.d.ts +54 -0
- package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
- package/dist/utils/dco/resolve-agent.js +164 -0
- package/dist/utils/dco/resolve-agent.js.map +1 -0
- package/dist/utils/dco/setup.d.ts +10 -7
- package/dist/utils/dco/setup.d.ts.map +1 -1
- package/dist/utils/dco/setup.js +264 -200
- package/dist/utils/dco/setup.js.map +1 -1
- package/dist/utils/dco/signing-key-writer.d.ts +40 -0
- package/dist/utils/dco/signing-key-writer.d.ts.map +1 -0
- package/dist/utils/dco/signing-key-writer.js +76 -0
- package/dist/utils/dco/signing-key-writer.js.map +1 -0
- package/dist/utils/dco/ssh-key.d.ts +50 -0
- package/dist/utils/dco/ssh-key.d.ts.map +1 -1
- package/dist/utils/dco/ssh-key.js +129 -8
- package/dist/utils/dco/ssh-key.js.map +1 -1
- package/dist/utils/dco/status.d.ts +1 -1
- package/dist/utils/dco/status.d.ts.map +1 -1
- package/dist/utils/dco/status.js +3 -3
- package/dist/utils/dco/status.js.map +1 -1
- package/dist/utils/dco/verify.d.ts +170 -0
- package/dist/utils/dco/verify.d.ts.map +1 -0
- package/dist/utils/dco/verify.js +550 -0
- package/dist/utils/dco/verify.js.map +1 -0
- package/dist/utils/dependency-installer.d.ts +37 -0
- package/dist/utils/dependency-installer.d.ts.map +1 -0
- package/dist/utils/dependency-installer.js +32 -0
- package/dist/utils/dependency-installer.js.map +1 -0
- package/dist/utils/github-credential-stage.d.ts +87 -0
- package/dist/utils/github-credential-stage.d.ts.map +1 -0
- package/dist/utils/github-credential-stage.js +168 -0
- package/dist/utils/github-credential-stage.js.map +1 -0
- package/dist/utils/github-credential.d.ts +160 -0
- package/dist/utils/github-credential.d.ts.map +1 -0
- package/dist/utils/github-credential.js +308 -0
- package/dist/utils/github-credential.js.map +1 -0
- package/dist/utils/gitignore.d.ts +17 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +40 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/hub-config.d.ts +21 -0
- package/dist/utils/hub-config.d.ts.map +1 -0
- package/dist/utils/hub-config.js +28 -0
- package/dist/utils/hub-config.js.map +1 -0
- package/dist/utils/identity-heal.d.ts +16 -0
- package/dist/utils/identity-heal.d.ts.map +1 -0
- package/dist/utils/identity-heal.js +37 -0
- package/dist/utils/identity-heal.js.map +1 -0
- package/dist/utils/init/pipeline.d.ts +74 -0
- package/dist/utils/init/pipeline.d.ts.map +1 -0
- package/dist/utils/init/pipeline.js +96 -0
- package/dist/utils/init/pipeline.js.map +1 -0
- package/dist/utils/poll.d.ts +15 -1
- package/dist/utils/poll.d.ts.map +1 -1
- package/dist/utils/poll.js +6 -3
- package/dist/utils/poll.js.map +1 -1
- package/dist/utils/register-agent-identity.d.ts +67 -0
- package/dist/utils/register-agent-identity.d.ts.map +1 -0
- package/dist/utils/register-agent-identity.js +34 -0
- package/dist/utils/register-agent-identity.js.map +1 -0
- package/dist/utils/review/did-web-key.d.ts +34 -0
- package/dist/utils/review/did-web-key.d.ts.map +1 -0
- package/dist/utils/review/did-web-key.js +104 -0
- package/dist/utils/review/did-web-key.js.map +1 -0
- package/dist/utils/review/load-registry.d.ts +33 -0
- package/dist/utils/review/load-registry.d.ts.map +1 -0
- package/dist/utils/review/load-registry.js +62 -0
- package/dist/utils/review/load-registry.js.map +1 -0
- package/dist/utils/review/verdict-verify.d.ts +43 -0
- package/dist/utils/review/verdict-verify.d.ts.map +1 -0
- package/dist/utils/review/verdict-verify.js +53 -0
- package/dist/utils/review/verdict-verify.js.map +1 -0
- package/dist/utils/review-registry-writer.d.ts +52 -0
- package/dist/utils/review-registry-writer.d.ts.map +1 -0
- package/dist/utils/review-registry-writer.js +79 -0
- package/dist/utils/review-registry-writer.js.map +1 -0
- package/dist/utils/should-install-dependency.d.ts +17 -0
- package/dist/utils/should-install-dependency.d.ts.map +1 -0
- package/dist/utils/should-install-dependency.js +25 -0
- package/dist/utils/should-install-dependency.js.map +1 -0
- package/dist/utils/tool-readiness.d.ts +57 -0
- package/dist/utils/tool-readiness.d.ts.map +1 -0
- package/dist/utils/tool-readiness.js +114 -0
- package/dist/utils/tool-readiness.js.map +1 -0
- package/dist/utils/which.d.ts +2 -0
- package/dist/utils/which.d.ts.map +1 -0
- package/dist/utils/which.js +22 -0
- package/dist/utils/which.js.map +1 -0
- package/dist/version.d.ts +15 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +1 -0
- package/package.json +19 -6
- package/dist/utils/claim-polling.d.ts +0 -21
- package/dist/utils/claim-polling.d.ts.map +0 -1
- package/dist/utils/claim-polling.js.map +0 -1
- package/dist/utils/dco/fs-safe.d.ts +0 -14
- package/dist/utils/dco/fs-safe.d.ts.map +0 -1
- package/dist/utils/dco/fs-safe.js +0 -20
- package/dist/utils/dco/fs-safe.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless AI-agent spawn wrapper, shared by `kya-os agent task` (the
|
|
3
|
+
* implementation pass) and `kya-os agent review` (the analysis pass).
|
|
4
|
+
*
|
|
5
|
+
* Provider-agnostic by design (2026-08-22 revision, epic decision 12: no
|
|
6
|
+
* kya-os surface hardcodes a model provider — an agent is a general actor
|
|
7
|
+
* on behalf of its user, Claude is the default adapter, never the
|
|
8
|
+
* architecture). `PROVIDER_PRESETS` carries `claude`'s exact behavior
|
|
9
|
+
* (headless `-p`, `--output-format json`, its own envelope + usage
|
|
10
|
+
* parsing); a caller can instead point at an arbitrary command via
|
|
11
|
+
* `agentCmd`, or (once review-loop P15 lands agent profiles) resolve a
|
|
12
|
+
* preset from the invoking agent's own profile. Mirrors review-loop P8's
|
|
13
|
+
* spawn pattern (injectable process spawn, honest token accounting,
|
|
14
|
+
* defensive JSON parsing that throws rather than guessing) without
|
|
15
|
+
* importing it: P8's implementation lives in `@kya-os/compute`, which
|
|
16
|
+
* `@kya-os/cli` must never import. The prompt is piped over stdin rather
|
|
17
|
+
* than passed as an argument value, so a large prompt (a full diff, or a
|
|
18
|
+
* task description plus repository context) never risks an OS
|
|
19
|
+
* argv-length limit the way an `execFile` argument would.
|
|
20
|
+
*
|
|
21
|
+
* The agent process never sees or holds signing key material: this module
|
|
22
|
+
* only runs it and returns its text output; every caller signs
|
|
23
|
+
* separately, in the command process, using the agent's key file directly
|
|
24
|
+
* (see `resolveSigningIdentity` / `ssh-key.ts`).
|
|
25
|
+
*/
|
|
26
|
+
export interface SpawnOutcome {
|
|
27
|
+
stdout: string;
|
|
28
|
+
stderr: string;
|
|
29
|
+
exitCode: number | null;
|
|
30
|
+
timedOut: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Injectable process spawn. Tests supply a fake implementation; production
|
|
34
|
+
* uses {@link defaultSpawnImpl}. Never invoked with a real agent binary in
|
|
35
|
+
* CI.
|
|
36
|
+
*/
|
|
37
|
+
export type SpawnImpl = (cmd: string, args: string[], options: {
|
|
38
|
+
cwd: string;
|
|
39
|
+
input: string;
|
|
40
|
+
timeoutMs: number;
|
|
41
|
+
}) => Promise<SpawnOutcome>;
|
|
42
|
+
export interface HeadlessAgentUsage {
|
|
43
|
+
inputTokens: number;
|
|
44
|
+
outputTokens: number;
|
|
45
|
+
}
|
|
46
|
+
export interface HeadlessAgentResult {
|
|
47
|
+
/** The agent's final text response — the actual content, not any CLI envelope. */
|
|
48
|
+
text: string;
|
|
49
|
+
usage: HeadlessAgentUsage;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* How to build the argument list for one spawn. `writeCapable` signals
|
|
53
|
+
* "this pass needs to create/edit files unattended" (no TTY to approve a
|
|
54
|
+
* permission prompt) — what a preset does with that is its own business:
|
|
55
|
+
* the `claude` preset adds `--dangerously-skip-permissions` plus a
|
|
56
|
+
* `--disallowedTools` denylist scoped to the git/gh subcommands this
|
|
57
|
+
* feature's own signing process is responsible for; a different preset
|
|
58
|
+
* might need nothing at all, or its own equivalent flag.
|
|
59
|
+
*/
|
|
60
|
+
export interface BuildArgsOptions {
|
|
61
|
+
model?: string;
|
|
62
|
+
extraArgs?: string[];
|
|
63
|
+
writeCapable?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ProviderPreset {
|
|
66
|
+
/** The executable to run. */
|
|
67
|
+
command: string;
|
|
68
|
+
buildArgs(options: BuildArgsOptions): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Parse this provider's raw process output into `{text, usage}`. Throws
|
|
71
|
+
* on malformed/failed output — never returns a partial/garbled result,
|
|
72
|
+
* since a caller signs and posts whatever this returns.
|
|
73
|
+
*/
|
|
74
|
+
parseOutput(outcome: SpawnOutcome): HeadlessAgentResult;
|
|
75
|
+
/** This preset's own default timeout, used when the caller doesn't override. */
|
|
76
|
+
defaultTimeoutMs: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Known provider presets, keyed by the name `--provider <preset>` accepts.
|
|
80
|
+
* Kept as a CLI-local table, not imported from `@kya-os/compute` (which has
|
|
81
|
+
* its own equivalent `PROVIDER_PRESETS` for the DIDComm reviewer runtime) —
|
|
82
|
+
* the CLI never imports compute. Add a preset here to support a new
|
|
83
|
+
* headless AI CLI without touching any caller.
|
|
84
|
+
*/
|
|
85
|
+
export declare const PROVIDER_PRESETS: Record<string, ProviderPreset>;
|
|
86
|
+
export interface RunHeadlessAgentOptions {
|
|
87
|
+
/** Working directory the agent process runs in (its tool calls operate here). */
|
|
88
|
+
cwd: string;
|
|
89
|
+
/** A preset name from {@link PROVIDER_PRESETS}. Default `"claude"`. Mutually exclusive with `agentCmd`; `agentCmd` wins if both are given. */
|
|
90
|
+
provider?: string;
|
|
91
|
+
/**
|
|
92
|
+
* A full command line to run instead of any preset, e.g. `"my-agent-cli --flag"`.
|
|
93
|
+
* Split on whitespace (no quoting support in this v1); `extraArgs` are appended.
|
|
94
|
+
* Its raw stdout is treated as the text result directly — see {@link parseGenericOutput}.
|
|
95
|
+
*/
|
|
96
|
+
agentCmd?: string;
|
|
97
|
+
model?: string;
|
|
98
|
+
/** Overrides the resolved preset's own default timeout. */
|
|
99
|
+
timeoutMs?: number;
|
|
100
|
+
/** "This pass needs unattended write access" — see {@link BuildArgsOptions}. */
|
|
101
|
+
writeCapable?: boolean;
|
|
102
|
+
extraArgs?: string[];
|
|
103
|
+
spawnImpl?: SpawnImpl;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Run a headless AI agent with `prompt` on stdin and return its text result
|
|
107
|
+
* plus honest token counts. Resolution order: `agentCmd` (an explicit raw
|
|
108
|
+
* command) overrides everything; else `provider` names a preset from
|
|
109
|
+
* {@link PROVIDER_PRESETS}; else the `claude` preset is the default. Throws
|
|
110
|
+
* — never silently produces a partial result — on an unknown provider
|
|
111
|
+
* name, a spawn error, a non-zero exit, a timeout, or (for a preset) output
|
|
112
|
+
* that doesn't match its expected envelope: a garbled or failed response
|
|
113
|
+
* must never be mistaken for a real one by a caller that then signs and
|
|
114
|
+
* posts it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function runHeadlessAgent(prompt: string, options: RunHeadlessAgentOptions): Promise<HeadlessAgentResult>;
|
|
117
|
+
//# sourceMappingURL=spawn-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-agent.d.ts","sourceRoot":"","sources":["../../../src/utils/agent/spawn-agent.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,C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;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,mBAAmB,CAAC,CA2C9B"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const defaultSpawnImpl = (cmd, args, { cwd, input, timeoutMs }) => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const child = spawn(cmd, args, { cwd, stdio: ["pipe", "pipe", "pipe"] });
|
|
6
|
+
let stdout = "";
|
|
7
|
+
let stderr = "";
|
|
8
|
+
let timedOut = false;
|
|
9
|
+
let settled = false;
|
|
10
|
+
const timer = setTimeout(() => {
|
|
11
|
+
timedOut = true;
|
|
12
|
+
child.kill("SIGTERM");
|
|
13
|
+
}, timeoutMs);
|
|
14
|
+
child.stdout?.on("data", (chunk) => {
|
|
15
|
+
stdout += chunk.toString("utf8");
|
|
16
|
+
});
|
|
17
|
+
child.stderr?.on("data", (chunk) => {
|
|
18
|
+
stderr += chunk.toString("utf8");
|
|
19
|
+
});
|
|
20
|
+
child.on("error", (error) => {
|
|
21
|
+
if (settled)
|
|
22
|
+
return;
|
|
23
|
+
settled = true;
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
reject(error);
|
|
26
|
+
});
|
|
27
|
+
child.on("close", (exitCode) => {
|
|
28
|
+
if (settled)
|
|
29
|
+
return;
|
|
30
|
+
settled = true;
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
resolve({ stdout, stderr, exitCode, timedOut });
|
|
33
|
+
});
|
|
34
|
+
child.stdin?.write(input);
|
|
35
|
+
child.stdin?.end();
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The subset of the Claude Code CLI's `--output-format json` envelope this
|
|
40
|
+
* preset actually depends on. Deliberately loose (`.passthrough()`): the
|
|
41
|
+
* real envelope carries many more fields (session id, cost, duration, ...)
|
|
42
|
+
* this has no use for, and pinning to an exact shape would break on every
|
|
43
|
+
* unrelated CLI field addition.
|
|
44
|
+
*/
|
|
45
|
+
const ClaudeCliEnvelopeSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
result: z.string(),
|
|
48
|
+
is_error: z.boolean().optional(),
|
|
49
|
+
usage: z
|
|
50
|
+
.object({
|
|
51
|
+
input_tokens: z.number().nonnegative().optional(),
|
|
52
|
+
output_tokens: z.number().nonnegative().optional(),
|
|
53
|
+
})
|
|
54
|
+
.passthrough()
|
|
55
|
+
.optional(),
|
|
56
|
+
})
|
|
57
|
+
.passthrough();
|
|
58
|
+
const CLAUDE_WRITE_CAPABLE_ARGS = [
|
|
59
|
+
"--dangerously-skip-permissions",
|
|
60
|
+
"--disallowedTools",
|
|
61
|
+
"Bash(git commit*) Bash(git push*) Bash(gh pr create*) Bash(gh pr review*)",
|
|
62
|
+
];
|
|
63
|
+
function parseClaudeOutput(outcome) {
|
|
64
|
+
let parsedJson;
|
|
65
|
+
try {
|
|
66
|
+
parsedJson = JSON.parse(outcome.stdout);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
throw new Error(`claude did not return valid JSON output (--output-format json): ${outcome.stdout.slice(0, 500)}`);
|
|
70
|
+
}
|
|
71
|
+
const envelope = ClaudeCliEnvelopeSchema.safeParse(parsedJson);
|
|
72
|
+
if (!envelope.success) {
|
|
73
|
+
throw new Error(`claude's JSON output did not match the expected envelope shape: ${envelope.error.message}`);
|
|
74
|
+
}
|
|
75
|
+
if (envelope.data.is_error) {
|
|
76
|
+
throw new Error(`claude reported a failed result: ${envelope.data.result}`);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
text: envelope.data.result,
|
|
80
|
+
usage: {
|
|
81
|
+
// Returning 0 when usage is genuinely absent is honest, not a
|
|
82
|
+
// fallback to hide behind: a caller that feeds this into a token
|
|
83
|
+
// budget must see 0, not a guessed nonzero value, when the CLI truly
|
|
84
|
+
// reported nothing.
|
|
85
|
+
inputTokens: envelope.data.usage?.input_tokens ?? 0,
|
|
86
|
+
outputTokens: envelope.data.usage?.output_tokens ?? 0,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const CLAUDE_PRESET = {
|
|
91
|
+
command: "claude",
|
|
92
|
+
buildArgs: ({ model, extraArgs, writeCapable }) => {
|
|
93
|
+
const args = ["-p", "--output-format", "json"];
|
|
94
|
+
if (writeCapable) {
|
|
95
|
+
args.push(...CLAUDE_WRITE_CAPABLE_ARGS);
|
|
96
|
+
}
|
|
97
|
+
args.push(...(extraArgs ?? []));
|
|
98
|
+
if (model) {
|
|
99
|
+
args.push("--model", model);
|
|
100
|
+
}
|
|
101
|
+
return args;
|
|
102
|
+
},
|
|
103
|
+
parseOutput: parseClaudeOutput,
|
|
104
|
+
defaultTimeoutMs: 300000,
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Known provider presets, keyed by the name `--provider <preset>` accepts.
|
|
108
|
+
* Kept as a CLI-local table, not imported from `@kya-os/compute` (which has
|
|
109
|
+
* its own equivalent `PROVIDER_PRESETS` for the DIDComm reviewer runtime) —
|
|
110
|
+
* the CLI never imports compute. Add a preset here to support a new
|
|
111
|
+
* headless AI CLI without touching any caller.
|
|
112
|
+
*/
|
|
113
|
+
export const PROVIDER_PRESETS = {
|
|
114
|
+
claude: CLAUDE_PRESET,
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A fully custom command line (`--agent-cmd`), bypassing the preset table
|
|
118
|
+
* entirely. There's no known envelope to unwrap for an arbitrary command,
|
|
119
|
+
* so its raw stdout IS the text result, verbatim; a caller that needs
|
|
120
|
+
* structured content (e.g. `agent review`'s findings JSON) parses that text
|
|
121
|
+
* itself, the same way it would parse a preset's already-unwrapped text.
|
|
122
|
+
* Token usage is honestly reported as unknown (0), never guessed.
|
|
123
|
+
*/
|
|
124
|
+
function parseGenericOutput(outcome) {
|
|
125
|
+
return { text: outcome.stdout, usage: { inputTokens: 0, outputTokens: 0 } };
|
|
126
|
+
}
|
|
127
|
+
const GENERIC_DEFAULT_TIMEOUT_MS = 300000;
|
|
128
|
+
/**
|
|
129
|
+
* Run a headless AI agent with `prompt` on stdin and return its text result
|
|
130
|
+
* plus honest token counts. Resolution order: `agentCmd` (an explicit raw
|
|
131
|
+
* command) overrides everything; else `provider` names a preset from
|
|
132
|
+
* {@link PROVIDER_PRESETS}; else the `claude` preset is the default. Throws
|
|
133
|
+
* — never silently produces a partial result — on an unknown provider
|
|
134
|
+
* name, a spawn error, a non-zero exit, a timeout, or (for a preset) output
|
|
135
|
+
* that doesn't match its expected envelope: a garbled or failed response
|
|
136
|
+
* must never be mistaken for a real one by a caller that then signs and
|
|
137
|
+
* posts it.
|
|
138
|
+
*/
|
|
139
|
+
export async function runHeadlessAgent(prompt, options) {
|
|
140
|
+
const spawnImpl = options.spawnImpl ?? defaultSpawnImpl;
|
|
141
|
+
let command;
|
|
142
|
+
let args;
|
|
143
|
+
let parseOutput;
|
|
144
|
+
let defaultTimeoutMs;
|
|
145
|
+
if (options.agentCmd) {
|
|
146
|
+
const parts = options.agentCmd.trim().split(/\s+/).filter(Boolean);
|
|
147
|
+
if (parts.length === 0) {
|
|
148
|
+
throw new Error("--agent-cmd was given but is empty after trimming");
|
|
149
|
+
}
|
|
150
|
+
command = parts[0];
|
|
151
|
+
args = [...parts.slice(1), ...(options.extraArgs ?? [])];
|
|
152
|
+
parseOutput = parseGenericOutput;
|
|
153
|
+
defaultTimeoutMs = GENERIC_DEFAULT_TIMEOUT_MS;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const presetName = options.provider ?? "claude";
|
|
157
|
+
const preset = PROVIDER_PRESETS[presetName];
|
|
158
|
+
if (!preset) {
|
|
159
|
+
throw new Error(`unknown provider preset "${presetName}"; known presets: ${Object.keys(PROVIDER_PRESETS).join(", ")}`);
|
|
160
|
+
}
|
|
161
|
+
command = preset.command;
|
|
162
|
+
args = preset.buildArgs({ model: options.model, extraArgs: options.extraArgs, writeCapable: options.writeCapable });
|
|
163
|
+
parseOutput = preset.parseOutput;
|
|
164
|
+
defaultTimeoutMs = preset.defaultTimeoutMs;
|
|
165
|
+
}
|
|
166
|
+
const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
|
|
167
|
+
const outcome = await spawnImpl(command, args, { cwd: options.cwd, input: prompt, timeoutMs });
|
|
168
|
+
if (outcome.timedOut) {
|
|
169
|
+
throw new Error(`${command} timed out after ${timeoutMs}ms`);
|
|
170
|
+
}
|
|
171
|
+
if (outcome.exitCode !== 0) {
|
|
172
|
+
const detail = outcome.stderr.trim() || outcome.stdout.trim() || "(no output)";
|
|
173
|
+
throw new Error(`${command} exited with code ${outcome.exitCode}: ${detail}`);
|
|
174
|
+
}
|
|
175
|
+
return parseOutput(outcome);
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=spawn-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-agent.js","sourceRoot":"","sources":["../../../src/utils/agent/spawn-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8CxB,MAAM,gBAAgB,GAAc,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IAC3E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB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CAAC,CAAC;QACpH,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACjC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,gBAAgB,CAAC;IACxD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAE/F,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,oBAAoB,SAAS,IAAI,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,aAAa,CAAC;QAC/E,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,qBAAqB,OAAO,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ensureColdStartRepo, type ResolveSigningIdentityResult } from "../dco/dispatch.js";
|
|
2
|
+
import { type AgentPublicKeyResolution } from "../dco/verify.js";
|
|
3
|
+
import { type DcoFixOptions, type DcoFixResult } from "../dco/fix.js";
|
|
4
|
+
import { type PullRequestReview, type PullRequestSummary } from "../dco/github.js";
|
|
5
|
+
import { type RunHeadlessAgentOptions } from "./spawn-agent.js";
|
|
6
|
+
export interface RunAgentTaskOptions {
|
|
7
|
+
agentSlug: string;
|
|
8
|
+
/** Target an existing repo (owner/name) instead of cold-starting a fresh scratch one. */
|
|
9
|
+
repo?: string;
|
|
10
|
+
/**
|
|
11
|
+
* PR base branch. When omitted, `gh pr create` is left to auto-detect the
|
|
12
|
+
* repo's own default branch, rather than forcing "main" — a cold-started
|
|
13
|
+
* scratch repo's default branch name follows the LOCAL git installation's
|
|
14
|
+
* `init.defaultBranch` config (often "master", not "main"), and hardcoding
|
|
15
|
+
* "main" made `gh pr create` fail outright ("Base ref must be a branch")
|
|
16
|
+
* on such a machine, confirmed live.
|
|
17
|
+
*/
|
|
18
|
+
base?: string;
|
|
19
|
+
/** Directory under which scratch/clone directories are created. Default `os.tmpdir()`. */
|
|
20
|
+
workDir?: string;
|
|
21
|
+
/** Provider selection (`--provider`/`--agent-cmd`) and other headless-agent options; see `spawn-agent.ts`. */
|
|
22
|
+
agentOptions?: Omit<RunHeadlessAgentOptions, "cwd" | "writeCapable">;
|
|
23
|
+
resolveIdentity?: (cwd: string, agentSlug: string | undefined) => Promise<ResolveSigningIdentityResult>;
|
|
24
|
+
ensureColdStart?: typeof ensureColdStartRepo;
|
|
25
|
+
}
|
|
26
|
+
export interface RunAgentTaskResult {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
failure?: string;
|
|
29
|
+
agent?: {
|
|
30
|
+
name: string;
|
|
31
|
+
slug: string;
|
|
32
|
+
};
|
|
33
|
+
did?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The fresh clone directory the agent worked in — left on disk (not cleaned
|
|
36
|
+
* up) so `--watch`'s fix rounds can reuse it via `runDcoFix`, which
|
|
37
|
+
* requires `cwd` to already be a clone with `origin` pointing at the PR's
|
|
38
|
+
* repo.
|
|
39
|
+
*/
|
|
40
|
+
cloneDir?: string;
|
|
41
|
+
branch?: string;
|
|
42
|
+
commitSha?: string;
|
|
43
|
+
signed?: boolean;
|
|
44
|
+
createdRemote?: string;
|
|
45
|
+
prUrl?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function runAgentTask(description: string, options: RunAgentTaskOptions): Promise<RunAgentTaskResult>;
|
|
48
|
+
export interface AgentTaskGithubClient {
|
|
49
|
+
getPullRequestSummary: (target: string, repo?: string) => Promise<PullRequestSummary>;
|
|
50
|
+
getPullRequestReviews: (target: string, repo?: string) => Promise<PullRequestReview[]>;
|
|
51
|
+
}
|
|
52
|
+
export type AgentTaskWatchStopReason = "approved" | "fix-rounds-exhausted" | "pr-closed" | "task-failed" | "fix-failed";
|
|
53
|
+
export interface AgentTaskWatchResult {
|
|
54
|
+
ok: boolean;
|
|
55
|
+
stopReason: AgentTaskWatchStopReason;
|
|
56
|
+
fixesUsed: number;
|
|
57
|
+
prUrl?: string;
|
|
58
|
+
failure?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface RunAgentTaskWatchOptions extends RunAgentTaskOptions {
|
|
61
|
+
fixRounds?: number;
|
|
62
|
+
pollSeconds?: number;
|
|
63
|
+
github?: AgentTaskGithubClient;
|
|
64
|
+
resolvePublicKey?: (did: string) => Promise<AgentPublicKeyResolution>;
|
|
65
|
+
runDcoFixImpl?: (cwd: string, options: DcoFixOptions) => Promise<DcoFixResult>;
|
|
66
|
+
sleepImpl?: (ms: number) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Invoked once, immediately after the initial `runAgentTask` call
|
|
69
|
+
* succeeds and BEFORE this function enters its (potentially long-running)
|
|
70
|
+
* poll loop. Without this, a caller has no way to learn the PR URL until
|
|
71
|
+
* the entire watch loop concludes — which could be many minutes later —
|
|
72
|
+
* even though a second process (the reviewer, in the two-party demo)
|
|
73
|
+
* needs that URL right away to start watching the same PR concurrently.
|
|
74
|
+
*/
|
|
75
|
+
onTaskOpened?: (result: RunAgentTaskResult) => void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Open the PR ({@link runAgentTask}) and then keep watching it: on every
|
|
79
|
+
* poll, look for a review whose `kya-os-verdict:v1` marker names the
|
|
80
|
+
* CURRENT head, is signed for THIS repo/PR (never a verdict genuinely
|
|
81
|
+
* signed for a different repo/PR that happens to share this head SHA,
|
|
82
|
+
* which a fork trivially can), and whose fenced
|
|
83
|
+
* `kya-os-signed-verdict` block verifies against the marker's reviewer DID.
|
|
84
|
+
* Anything else — no marker, a stale head, a context mismatch, an
|
|
85
|
+
* unresolvable reviewer, or a verdict that fails signature verification —
|
|
86
|
+
* is silently ignored: this loop acts only on cryptographically verified
|
|
87
|
+
* verdicts.
|
|
88
|
+
*
|
|
89
|
+
* **Trust boundary, by design, not oversight**: there is no reviewer
|
|
90
|
+
* allowlist here. ANY `did:web` identity that can produce a valid Ed25519
|
|
91
|
+
* signature is trusted — matching this feature's own design doc ("this
|
|
92
|
+
* agent acts only on cryptographic verdicts") and the two-party demo's
|
|
93
|
+
* threat model, which deliberately has no registry/quorum (that's the
|
|
94
|
+
* separate hub-backed production loop's job). On a cold-started (private
|
|
95
|
+
* by default) scratch repo this is low-exposure; pointing `--repo` at a
|
|
96
|
+
* PUBLIC repo means anyone who can comment or review on that PR can forge
|
|
97
|
+
* an approve/request-changes from their own self-hosted DID. Do not point
|
|
98
|
+
* `--repo` at a public repo you don't control the review surface of.
|
|
99
|
+
*/
|
|
100
|
+
export declare function runAgentTaskWatch(description: string, options: RunAgentTaskWatchOptions): Promise<AgentTaskWatchResult>;
|
|
101
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../../src/utils/agent/task.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EAKnB,KAAK,4BAA4B,EAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAwHlF,MAAM,WAAW,m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