agent-afk 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/_lib/skill-sink-channel.d.ts +3 -0
- package/dist/agent/_lib/trusted-skill-events.d.ts +7 -0
- package/dist/agent/_lib/trusted-skill-registry.d.ts +3 -0
- package/dist/agent/abort-graph.d.ts +20 -0
- package/dist/agent/afk-channel.d.ts +9 -0
- package/dist/agent/afk-ledger-channel.d.ts +23 -0
- package/dist/agent/afk-mode-gate.d.ts +3 -0
- package/dist/agent/auth/credential-resolver.d.ts +3 -0
- package/dist/agent/auth/keychain.d.ts +4 -0
- package/dist/agent/awareness/index.d.ts +6 -0
- package/dist/agent/awareness/presence.d.ts +25 -0
- package/dist/agent/awareness/runtime-snapshot.d.ts +13 -0
- package/dist/agent/awareness/runtime-source.d.ts +18 -0
- package/dist/agent/awareness/tool.d.ts +7 -0
- package/dist/agent/awareness/types.d.ts +60 -0
- package/dist/agent/awareness/workspace-source.d.ts +2 -0
- package/dist/agent/background-registry.d.ts +57 -0
- package/dist/agent/background-summarizer.d.ts +43 -0
- package/dist/agent/bg-job-log.d.ts +41 -0
- package/dist/agent/daemon/gates.d.ts +20 -0
- package/dist/agent/daemon/http-client.d.ts +6 -0
- package/dist/agent/daemon/idle-detector.d.ts +7 -0
- package/dist/agent/daemon/queue-store.d.ts +13 -0
- package/dist/agent/daemon/schedule-store.d.ts +20 -0
- package/dist/agent/daemon/scheduler.d.ts +64 -0
- package/dist/agent/daemon/triggers.d.ts +10 -0
- package/dist/agent/daemon.d.ts +29 -0
- package/dist/agent/dag-subagent.d.ts +28 -0
- package/dist/agent/dag.d.ts +26 -0
- package/dist/agent/default-hook-registry.d.ts +23 -0
- package/dist/agent/elicitation-router.d.ts +20 -0
- package/dist/agent/facets/derive.d.ts +7 -0
- package/dist/agent/facets/index.d.ts +3 -0
- package/dist/agent/facets/raw-input.d.ts +3 -0
- package/dist/agent/facets/schema.d.ts +139 -0
- package/dist/agent/facets/store.d.ts +9 -0
- package/dist/agent/gh.d.ts +41 -0
- package/dist/agent/hook-registry.d.ts +9 -0
- package/dist/agent/hooks/command-executor.d.ts +12 -0
- package/dist/agent/hooks/config-bridge.d.ts +7 -0
- package/dist/agent/hooks/config-loader.d.ts +44 -0
- package/dist/agent/hooks.d.ts +88 -0
- package/dist/agent/index.d.ts +31 -0
- package/dist/agent/marketplaces/install.d.ts +23 -0
- package/dist/agent/marketplaces/manifest.d.ts +21 -0
- package/dist/agent/marketplaces/remove.d.ts +11 -0
- package/dist/agent/marketplaces/resolve.d.ts +27 -0
- package/dist/agent/marketplaces/update.d.ts +38 -0
- package/dist/agent/mcp/client.d.ts +28 -0
- package/dist/agent/mcp/config-loader.d.ts +22 -0
- package/dist/agent/mcp/env.d.ts +6 -0
- package/dist/agent/mcp/index.d.ts +8 -0
- package/dist/agent/mcp/manager.d.ts +23 -0
- package/dist/agent/mcp/naming.d.ts +20 -0
- package/dist/agent/mcp/oauth.d.ts +33 -0
- package/dist/agent/mcp/transport.d.ts +16 -0
- package/dist/agent/mcp/types.d.ts +22 -0
- package/dist/agent/memory/index.d.ts +5 -0
- package/dist/agent/memory/memory-evidence.d.ts +9 -0
- package/dist/agent/memory/memory-hooks.d.ts +3 -0
- package/dist/agent/memory/memory-loader.d.ts +3 -0
- package/dist/agent/memory/memory-store.d.ts +36 -0
- package/dist/agent/memory/memory-tool-renderers.d.ts +3 -0
- package/dist/agent/memory/memory-tools.d.ts +8 -0
- package/dist/agent/memory/types.d.ts +70 -0
- package/dist/agent/model-capabilities.d.ts +1 -0
- package/dist/agent/model-limits.d.ts +5 -0
- package/dist/agent/output-extractor.d.ts +1 -0
- package/dist/agent/permission-policy.d.ts +2 -0
- package/dist/agent/permissions-store.d.ts +28 -0
- package/dist/agent/permissions.d.ts +28 -0
- package/dist/agent/plan-mode-exit-prompt.d.ts +1 -0
- package/dist/agent/plan-mode-gate.d.ts +3 -0
- package/dist/agent/plugins/git-test-helpers.d.ts +2 -0
- package/dist/agent/plugins/git.d.ts +21 -0
- package/dist/agent/plugins/index-store.d.ts +32 -0
- package/dist/agent/plugins/install.d.ts +23 -0
- package/dist/agent/plugins/inventory.d.ts +16 -0
- package/dist/agent/plugins/load-entrypoints.d.ts +7 -0
- package/dist/agent/plugins/plugin-manifest.d.ts +5 -0
- package/dist/agent/plugins/remove.d.ts +10 -0
- package/dist/agent/plugins/source.d.ts +23 -0
- package/dist/agent/plugins/tool-injector.d.ts +18 -0
- package/dist/agent/plugins/update.d.ts +33 -0
- package/dist/agent/plugins/versions.d.ts +1 -0
- package/dist/agent/plugins-scanner.d.ts +9 -0
- package/dist/agent/provider.d.ts +212 -0
- package/dist/agent/providers/anthropic-direct/afk-mode-addendum.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/auth.d.ts +16 -0
- package/dist/agent/providers/anthropic-direct/cache-policy.d.ts +7 -0
- package/dist/agent/providers/anthropic-direct/compact.d.ts +10 -0
- package/dist/agent/providers/anthropic-direct/index.d.ts +75 -0
- package/dist/agent/providers/anthropic-direct/loop.d.ts +8 -0
- package/dist/agent/providers/anthropic-direct/oneshot.d.ts +15 -0
- package/dist/agent/providers/anthropic-direct/plan-mode-addendum.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/query/abort-coordinator.d.ts +15 -0
- package/dist/agent/providers/anthropic-direct/query/auto-compact.d.ts +15 -0
- package/dist/agent/providers/anthropic-direct/query/compact-handler.d.ts +12 -0
- package/dist/agent/providers/anthropic-direct/query/repair-orphan-tool-uses.d.ts +2 -0
- package/dist/agent/providers/anthropic-direct/query/retry-layer.d.ts +30 -0
- package/dist/agent/providers/anthropic-direct/query/session-state.d.ts +23 -0
- package/dist/agent/providers/anthropic-direct/query.d.ts +73 -0
- package/dist/agent/providers/anthropic-direct/resolve-params.d.ts +8 -0
- package/dist/agent/providers/anthropic-direct/tool-dispatcher.d.ts +7 -0
- package/dist/agent/providers/anthropic-direct/translate.d.ts +3 -0
- package/dist/agent/providers/anthropic-direct/types.d.ts +122 -0
- package/dist/agent/providers/anthropic-direct/usage-limit.d.ts +21 -0
- package/dist/agent/providers/index.d.ts +16 -0
- package/dist/agent/providers/openai-compatible/auth.d.ts +32 -0
- package/dist/agent/providers/openai-compatible/index.d.ts +53 -0
- package/dist/agent/providers/openai-compatible/loop.d.ts +47 -0
- package/dist/agent/providers/openai-compatible/messages.d.ts +33 -0
- package/dist/agent/providers/openai-compatible/oneshot.d.ts +17 -0
- package/dist/agent/providers/openai-compatible/query.d.ts +79 -0
- package/dist/agent/providers/openai-compatible/responses-config.d.ts +14 -0
- package/dist/agent/providers/openai-compatible/responses-messages.d.ts +54 -0
- package/dist/agent/providers/openai-compatible/responses-translate.d.ts +30 -0
- package/dist/agent/providers/openai-compatible/translate.d.ts +53 -0
- package/dist/agent/providers/router/provider-router.d.ts +55 -0
- package/dist/agent/query.d.ts +11 -0
- package/dist/agent/risk-classifier.d.ts +6 -0
- package/dist/agent/routing-directive.d.ts +5 -0
- package/dist/agent/routing-telemetry.d.ts +36 -0
- package/dist/agent/session/agent-session.d.ts +95 -0
- package/dist/agent/session/closure-guidance.d.ts +3 -0
- package/dist/agent/session/closure-reason.d.ts +11 -0
- package/dist/agent/session/hooks-dispatch.d.ts +9 -0
- package/dist/agent/session/input-iterable.d.ts +10 -0
- package/dist/agent/session/model-resolution.d.ts +5 -0
- package/dist/agent/session/model-slots.d.ts +24 -0
- package/dist/agent/session/phase-reducer.d.ts +3 -0
- package/dist/agent/session/prompt-dump.d.ts +33 -0
- package/dist/agent/session/session-identity.d.ts +6 -0
- package/dist/agent/session/session-setup.d.ts +6 -0
- package/dist/agent/session/session-state.d.ts +20 -0
- package/dist/agent/session/slot-credentials.d.ts +8 -0
- package/dist/agent/session/stream-consumer.d.ts +22 -0
- package/dist/agent/session-ledger.d.ts +81 -0
- package/dist/agent/session-ref.d.ts +4 -0
- package/dist/agent/session.d.ts +1 -0
- package/dist/agent/shadow-verify-nudge.d.ts +2 -0
- package/dist/agent/shell-jobs/index.d.ts +2 -0
- package/dist/agent/shell-jobs/registry.d.ts +36 -0
- package/dist/agent/shell-jobs/streamer.d.ts +33 -0
- package/dist/agent/signal-block.d.ts +45 -0
- package/dist/agent/subagent/handle.d.ts +51 -0
- package/dist/agent/subagent/result.d.ts +51 -0
- package/dist/agent/subagent/wave.d.ts +11 -0
- package/dist/agent/subagent-hooks.d.ts +12 -0
- package/dist/agent/subagent.d.ts +66 -0
- package/dist/agent/timeout.d.ts +7 -0
- package/dist/agent/tool-category.d.ts +9 -0
- package/dist/agent/tools/child-credential.d.ts +6 -0
- package/dist/agent/tools/compose-executor.d.ts +29 -0
- package/dist/agent/tools/custom-tool.d.ts +7 -0
- package/dist/agent/tools/dispatcher.d.ts +75 -0
- package/dist/agent/tools/handlers/_cwd-utils.d.ts +9 -0
- package/dist/agent/tools/handlers/ask-question.d.ts +2 -0
- package/dist/agent/tools/handlers/bash.d.ts +3 -0
- package/dist/agent/tools/handlers/browser-act.d.ts +4 -0
- package/dist/agent/tools/handlers/browser-close.d.ts +4 -0
- package/dist/agent/tools/handlers/browser-observe.d.ts +4 -0
- package/dist/agent/tools/handlers/browser-open.d.ts +6 -0
- package/dist/agent/tools/handlers/browser-screenshot.d.ts +4 -0
- package/dist/agent/tools/handlers/config-ops.d.ts +3 -0
- package/dist/agent/tools/handlers/edit-file.d.ts +2 -0
- package/dist/agent/tools/handlers/exit-plan-mode.d.ts +5 -0
- package/dist/agent/tools/handlers/glob.d.ts +3 -0
- package/dist/agent/tools/handlers/grep.d.ts +3 -0
- package/dist/agent/tools/handlers/index.d.ts +21 -0
- package/dist/agent/tools/handlers/list-directory.d.ts +2 -0
- package/dist/agent/tools/handlers/playwright-hints.d.ts +5 -0
- package/dist/agent/tools/handlers/read-file.d.ts +2 -0
- package/dist/agent/tools/handlers/schedules.d.ts +7 -0
- package/dist/agent/tools/handlers/send-telegram.d.ts +6 -0
- package/dist/agent/tools/handlers/terminal-font-size.d.ts +15 -0
- package/dist/agent/tools/handlers/test-runner-detector.d.ts +8 -0
- package/dist/agent/tools/handlers/web-scrape.d.ts +11 -0
- package/dist/agent/tools/handlers/write-denylist.d.ts +4 -0
- package/dist/agent/tools/handlers/write-file.d.ts +2 -0
- package/dist/agent/tools/hooks/bash-restriction-hook.d.ts +8 -0
- package/dist/agent/tools/hooks/path-approval-hook.d.ts +14 -0
- package/dist/agent/tools/index.d.ts +7 -0
- package/dist/agent/tools/nesting.d.ts +29 -0
- package/dist/agent/tools/permissions.d.ts +10 -0
- package/dist/agent/tools/readonly-bash.d.ts +4 -0
- package/dist/agent/tools/render-registry.d.ts +3 -0
- package/dist/agent/tools/renderers/bash-renderer.d.ts +1 -0
- package/dist/agent/tools/schemas.d.ts +29 -0
- package/dist/agent/tools/skill-bridge.d.ts +21 -0
- package/dist/agent/tools/skill-depth-message.d.ts +2 -0
- package/dist/agent/tools/skill-executor.d.ts +45 -0
- package/dist/agent/tools/subagent-executor.d.ts +57 -0
- package/dist/agent/tools/system-prompt.d.ts +6 -0
- package/dist/agent/tools/types.d.ts +17 -0
- package/dist/agent/trace/emit.d.ts +12 -0
- package/dist/agent/trace/events.d.ts +1052 -0
- package/dist/agent/trace/factory.d.ts +10 -0
- package/dist/agent/trace/index.d.ts +4 -0
- package/dist/agent/trace/receipt.d.ts +92 -0
- package/dist/agent/trace/types.d.ts +307 -0
- package/dist/agent/trace/writer.d.ts +42 -0
- package/dist/agent/transcript-search/transcript-index.d.ts +21 -0
- package/dist/agent/trusted-skill-result.d.ts +9 -0
- package/dist/agent/types/config-types.d.ts +86 -0
- package/dist/agent/types/message-types.d.ts +77 -0
- package/dist/agent/types/model-types.d.ts +2 -0
- package/dist/agent/types/permission-types.d.ts +8 -0
- package/dist/agent/types/sdk-types.d.ts +282 -0
- package/dist/agent/types/session-types.d.ts +134 -0
- package/dist/agent/types.d.ts +6 -0
- package/dist/agent/usage.d.ts +2 -0
- package/dist/agent/worktree-sweep.d.ts +52 -0
- package/dist/agent/worktree.d.ts +56 -0
- package/dist/browser/config.d.ts +13 -0
- package/dist/browser/playwright/index.d.ts +21 -0
- package/dist/browser/playwright/launcher.d.ts +32 -0
- package/dist/browser/playwright/observe.d.ts +12 -0
- package/dist/browser/playwright/resolve-target.d.ts +10 -0
- package/dist/browser/provider.d.ts +15 -0
- package/dist/browser/registry.d.ts +7 -0
- package/dist/browser/sanitize.d.ts +22 -0
- package/dist/browser/types.d.ts +139 -0
- package/dist/browser/witness.d.ts +11 -0
- package/dist/changelog.d.ts +13 -0
- package/dist/cli/_lib/capture-mode.d.ts +8 -0
- package/dist/cli/_lib/commit-block.d.ts +4 -0
- package/dist/cli/_lib/commit-coordinator.d.ts +13 -0
- package/dist/cli/_lib/dedup-line-writer.d.ts +5 -0
- package/dist/cli/_lib/overlay-composer.d.ts +18 -0
- package/dist/cli/_lib/sanitize.d.ts +1 -0
- package/dist/cli/_lib/stream-renderer-contexts.d.ts +43 -0
- package/dist/cli/_lib/stream-renderer-lifecycle.d.ts +33 -0
- package/dist/cli/_lib/stream-renderer-orchestrator-emit.d.ts +10 -0
- package/dist/cli/_lib/stream-renderer-orchestrator.d.ts +30 -0
- package/dist/cli/_lib/stream-renderer-source.d.ts +27 -0
- package/dist/cli/_lib/stream-renderer-subagent-helpers.d.ts +6 -0
- package/dist/cli/_lib/stream-renderer-subagent.d.ts +22 -0
- package/dist/cli/_lib/stream-renderer.d.ts +68 -0
- package/dist/cli/_lib/testing/virtual-screen.d.ts +54 -0
- package/dist/cli/afk-mode-toggle.d.ts +2 -0
- package/dist/cli/auth-wizard.d.ts +4 -0
- package/dist/cli/background/types.d.ts +8 -0
- package/dist/cli/background-status-bar.d.ts +37 -0
- package/dist/cli/clipboard.d.ts +7 -0
- package/dist/cli/color-config.d.ts +1 -0
- package/dist/cli/commands/bg.d.ts +2 -0
- package/dist/cli/commands/browser.d.ts +11 -0
- package/dist/cli/commands/chat.d.ts +2 -0
- package/dist/cli/commands/completion.d.ts +2 -0
- package/dist/cli/commands/config-command.d.ts +2 -0
- package/dist/cli/commands/daemon.d.ts +14 -0
- package/dist/cli/commands/doctor-checks.d.ts +19 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/farm.d.ts +40 -0
- package/dist/cli/commands/improve.d.ts +2 -0
- package/dist/cli/commands/interactive/afk-push.d.ts +14 -0
- package/dist/cli/commands/interactive/at-file-inject.d.ts +17 -0
- package/dist/cli/commands/interactive/boot-prune.d.ts +8 -0
- package/dist/cli/commands/interactive/bootstrap.d.ts +30 -0
- package/dist/cli/commands/interactive/context-pane.d.ts +11 -0
- package/dist/cli/commands/interactive/footer-subsystems.d.ts +15 -0
- package/dist/cli/commands/interactive/loop-iteration.d.ts +7 -0
- package/dist/cli/commands/interactive/loop-stage.d.ts +34 -0
- package/dist/cli/commands/interactive/progress-banner.d.ts +5 -0
- package/dist/cli/commands/interactive/provider-factory.d.ts +2 -0
- package/dist/cli/commands/interactive/repl-loop-shared.d.ts +10 -0
- package/dist/cli/commands/interactive/repl-loop.d.ts +6 -0
- package/dist/cli/commands/interactive/repl-renderer.d.ts +16 -0
- package/dist/cli/commands/interactive/resume-swap.d.ts +23 -0
- package/dist/cli/commands/interactive/shared.d.ts +116 -0
- package/dist/cli/commands/interactive/shell-passthrough.d.ts +33 -0
- package/dist/cli/commands/interactive/surface-setup.d.ts +12 -0
- package/dist/cli/commands/interactive/terminal-state.d.ts +18 -0
- package/dist/cli/commands/interactive/thinking-lane.d.ts +18 -0
- package/dist/cli/commands/interactive/thinking-paragraph.d.ts +5 -0
- package/dist/cli/commands/interactive/tool-lane-format-args.d.ts +4 -0
- package/dist/cli/commands/interactive/tool-lane-format-diff.d.ts +4 -0
- package/dist/cli/commands/interactive/tool-lane-format-sanitize.d.ts +2 -0
- package/dist/cli/commands/interactive/tool-lane-format.d.ts +14 -0
- package/dist/cli/commands/interactive/tool-lane-render-agent.d.ts +7 -0
- package/dist/cli/commands/interactive/tool-lane-render-children.d.ts +4 -0
- package/dist/cli/commands/interactive/tool-lane-render-grouping-overflow.d.ts +15 -0
- package/dist/cli/commands/interactive/tool-lane-render-grouping.d.ts +23 -0
- package/dist/cli/commands/interactive/tool-lane-render.d.ts +45 -0
- package/dist/cli/commands/interactive/tool-lane.d.ts +31 -0
- package/dist/cli/commands/interactive/transcript.d.ts +9 -0
- package/dist/cli/commands/interactive/turn-handler.d.ts +16 -0
- package/dist/cli/commands/interactive/verdict-card.d.ts +3 -0
- package/dist/cli/commands/interactive/verdict-ledger.d.ts +19 -0
- package/dist/cli/commands/interactive/worktree-autoname.d.ts +42 -0
- package/dist/cli/commands/interactive/worktree.d.ts +33 -0
- package/dist/cli/commands/interactive.d.ts +11 -0
- package/dist/cli/commands/login-command.d.ts +5 -0
- package/dist/cli/commands/marketplace.d.ts +8 -0
- package/dist/cli/commands/migrate.d.ts +14 -0
- package/dist/cli/commands/plugin.d.ts +7 -0
- package/dist/cli/commands/provider.d.ts +9 -0
- package/dist/cli/commands/queue.d.ts +2 -0
- package/dist/cli/commands/schedule.d.ts +2 -0
- package/dist/cli/commands/service.d.ts +2 -0
- package/dist/cli/commands/shell-init.d.ts +6 -0
- package/dist/cli/commands/skill-router.d.ts +9 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/telegram.d.ts +2 -0
- package/dist/cli/commands/trace.d.ts +25 -0
- package/dist/cli/commands/transcript.d.ts +4 -0
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/worktree.d.ts +2 -0
- package/dist/cli/commit-mode.d.ts +25 -0
- package/dist/cli/config.d.ts +69 -0
- package/dist/cli/constants.d.ts +4 -0
- package/dist/cli/context-bar.d.ts +8 -0
- package/dist/cli/context-sampler.d.ts +43 -0
- package/dist/cli/context-sparkline.d.ts +1 -0
- package/dist/cli/cup-frame-renderer.d.ts +18 -0
- package/dist/cli/daemon-options.d.ts +11 -0
- package/dist/cli/debug-banner.d.ts +2 -0
- package/dist/cli/display.d.ts +19 -0
- package/dist/cli/elicitation-repl.d.ts +26 -0
- package/dist/cli/errors/classifier.d.ts +9 -0
- package/dist/cli/errors/index.d.ts +4 -0
- package/dist/cli/errors/presenter.d.ts +5 -0
- package/dist/cli/format-cwd.d.ts +5 -0
- package/dist/cli/format-utils.d.ts +4 -0
- package/dist/cli/formatter.d.ts +27 -0
- package/dist/cli/git-status-sampler.d.ts +43 -0
- package/dist/cli/hyperlink.d.ts +6 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/input/attachments.d.ts +10 -0
- package/dist/cli/input/autocomplete-state.d.ts +11 -0
- package/dist/cli/input/caret-blink.d.ts +21 -0
- package/dist/cli/input/clipboard-image.d.ts +2 -0
- package/dist/cli/input/dropdown.d.ts +4 -0
- package/dist/cli/input/echo.d.ts +12 -0
- package/dist/cli/input/emit-keypress.d.ts +1 -0
- package/dist/cli/input/history.d.ts +15 -0
- package/dist/cli/input/input-surface.d.ts +63 -0
- package/dist/cli/input/non-tty.d.ts +2 -0
- package/dist/cli/input/raw-mode.d.ts +4 -0
- package/dist/cli/input/reader.d.ts +2 -0
- package/dist/cli/input/selectors.d.ts +3 -0
- package/dist/cli/input/spinner.d.ts +19 -0
- package/dist/cli/input/stdin-claim.d.ts +7 -0
- package/dist/cli/input/suggest.d.ts +36 -0
- package/dist/cli/input/trigger.d.ts +5 -0
- package/dist/cli/input/types.d.ts +53 -0
- package/dist/cli/input-box.d.ts +5 -0
- package/dist/cli/input-core.d.ts +37 -0
- package/dist/cli/input-highlight.d.ts +4 -0
- package/dist/cli/keychain.d.ts +1 -0
- package/dist/cli/loading-tips.d.ts +14 -0
- package/dist/cli/markdown-stream-format.d.ts +30 -0
- package/dist/cli/markdown-stream.d.ts +39 -0
- package/dist/cli/mascot.d.ts +6 -0
- package/dist/cli/model-limits.d.ts +1 -0
- package/dist/cli/multi-line-reader.d.ts +16 -0
- package/dist/cli/palette.d.ts +29 -0
- package/dist/cli/permission-mode-cycle.d.ts +3 -0
- package/dist/cli/plan-mode-toggle.d.ts +2 -0
- package/dist/cli/render/box.d.ts +8 -0
- package/dist/cli/render/card.d.ts +8 -0
- package/dist/cli/render/divider.d.ts +1 -0
- package/dist/cli/render/error-box.d.ts +1 -0
- package/dist/cli/render/help-table.d.ts +9 -0
- package/dist/cli/render/index.d.ts +9 -0
- package/dist/cli/render/picker.d.ts +15 -0
- package/dist/cli/render/progress-bar.d.ts +1 -0
- package/dist/cli/render/status-panel.d.ts +7 -0
- package/dist/cli/render/text-input.d.ts +9 -0
- package/dist/cli/render/usage-limit-box.d.ts +7 -0
- package/dist/cli/render/utils.d.ts +2 -0
- package/dist/cli/render/welcome-banner.d.ts +10 -0
- package/dist/cli/render.d.ts +1 -0
- package/dist/cli/resume-command.d.ts +3 -0
- package/dist/cli/resume-session.d.ts +13 -0
- package/dist/cli/session-name.d.ts +1 -0
- package/dist/cli/session-store.d.ts +51 -0
- package/dist/cli/shared-helpers.d.ts +33 -0
- package/dist/cli/slash/_lib/command-tags.d.ts +9 -0
- package/dist/cli/slash/_lib/create-skill-renderer.d.ts +9 -0
- package/dist/cli/slash/_lib/flag-harvest.d.ts +9 -0
- package/dist/cli/slash/_lib/image-blocks.d.ts +3 -0
- package/dist/cli/slash/_lib/review-post.d.ts +30 -0
- package/dist/cli/slash/_lib/run-skill-dispatch-turn.d.ts +11 -0
- package/dist/cli/slash/_lib/skill-message-bridge.d.ts +4 -0
- package/dist/cli/slash/_lib/skill-sink-channel.d.ts +1 -0
- package/dist/cli/slash/_lib/user-payload.d.ts +3 -0
- package/dist/cli/slash/builtin-skills.d.ts +4 -0
- package/dist/cli/slash/commands/afk.d.ts +2 -0
- package/dist/cli/slash/commands/allow-dir.d.ts +14 -0
- package/dist/cli/slash/commands/bgsub.d.ts +11 -0
- package/dist/cli/slash/commands/changelog.d.ts +2 -0
- package/dist/cli/slash/commands/config-doctor.d.ts +2 -0
- package/dist/cli/slash/commands/core.d.ts +2 -0
- package/dist/cli/slash/commands/font-size.d.ts +4 -0
- package/dist/cli/slash/commands/fork.d.ts +4 -0
- package/dist/cli/slash/commands/info.d.ts +2 -0
- package/dist/cli/slash/commands/init.d.ts +2 -0
- package/dist/cli/slash/commands/keys.d.ts +2 -0
- package/dist/cli/slash/commands/name.d.ts +2 -0
- package/dist/cli/slash/commands/plan.d.ts +2 -0
- package/dist/cli/slash/commands/reauth.d.ts +2 -0
- package/dist/cli/slash/commands/resume.d.ts +2 -0
- package/dist/cli/slash/commands/save.d.ts +2 -0
- package/dist/cli/slash/commands/sh.d.ts +4 -0
- package/dist/cli/slash/commands/stats.d.ts +2 -0
- package/dist/cli/slash/commands/todo.d.ts +2 -0
- package/dist/cli/slash/commands/transcript.d.ts +2 -0
- package/dist/cli/slash/commands/worktree.d.ts +2 -0
- package/dist/cli/slash/index.d.ts +3 -0
- package/dist/cli/slash/marketplace-browse.d.ts +1 -0
- package/dist/cli/slash/plugin-agents.d.ts +5 -0
- package/dist/cli/slash/plugin-skills.d.ts +32 -0
- package/dist/cli/slash/preflight/artifact-dir.d.ts +3 -0
- package/dist/cli/slash/preflight/index.d.ts +6 -0
- package/dist/cli/slash/preflight/registry.d.ts +8 -0
- package/dist/cli/slash/preflight/review-pr.d.ts +34 -0
- package/dist/cli/slash/preflight/stitch-forward.d.ts +1 -0
- package/dist/cli/slash/preflight/types.d.ts +18 -0
- package/dist/cli/slash/registry-exports.d.ts +2 -0
- package/dist/cli/slash/registry.d.ts +23 -0
- package/dist/cli/slash/session-stats.d.ts +6 -0
- package/dist/cli/slash/types.d.ts +103 -0
- package/dist/cli/slash/writer.d.ts +6 -0
- package/dist/cli/status-line.d.ts +51 -0
- package/dist/cli/syntax-highlight.d.ts +1 -0
- package/dist/cli/syntax-theme.d.ts +2 -0
- package/dist/cli/terminal-compositor.autocomplete.d.ts +16 -0
- package/dist/cli/terminal-compositor.committed-band-commit.d.ts +24 -0
- package/dist/cli/terminal-compositor.committed-band-repin.d.ts +3 -0
- package/dist/cli/terminal-compositor.committed-band.d.ts +2 -0
- package/dist/cli/terminal-compositor.d.ts +118 -0
- package/dist/cli/terminal-compositor.frame-preserve.d.ts +3 -0
- package/dist/cli/terminal-compositor.frame.d.ts +33 -0
- package/dist/cli/terminal-compositor.input-dispatch.d.ts +42 -0
- package/dist/cli/terminal-compositor.input-mode.d.ts +26 -0
- package/dist/cli/terminal-compositor.lifecycle.d.ts +40 -0
- package/dist/cli/terminal-compositor.paste.d.ts +16 -0
- package/dist/cli/terminal-compositor.render.d.ts +17 -0
- package/dist/cli/terminal-compositor.reset.d.ts +36 -0
- package/dist/cli/terminal-compositor.types.d.ts +80 -0
- package/dist/cli/terminal-size.d.ts +9 -0
- package/dist/cli/terminal-spawn/detect.d.ts +3 -0
- package/dist/cli/terminal-spawn/index.d.ts +29 -0
- package/dist/cli/terminal-spawn/spawners.d.ts +18 -0
- package/dist/cli/todo-panel.d.ts +18 -0
- package/dist/cli/tool-category.d.ts +9 -0
- package/dist/cli/trusted-skill-badge.d.ts +19 -0
- package/dist/cli/trusted-skill-ledger.d.ts +16 -0
- package/dist/cli/trusted-skills-registered.d.ts +1 -0
- package/dist/cli/update-checker.d.ts +10 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/wrap.d.ts +4 -0
- package/dist/cli.mjs +410 -408
- package/dist/config/env.d.ts +136 -0
- package/dist/config/import-sources.d.ts +46 -0
- package/dist/config/mutate.d.ts +78 -0
- package/dist/config/settable-keys.d.ts +44 -0
- package/dist/improve/eval-gen/replay-fixture.d.ts +19 -0
- package/dist/improve/eval-gen/writer.d.ts +41 -0
- package/dist/improve/eval-run/contracts.d.ts +25 -0
- package/dist/improve/eval-run/replay.d.ts +25 -0
- package/dist/improve/eval-run/runner.d.ts +37 -0
- package/dist/improve/paths.d.ts +19 -0
- package/dist/improve/propose/template-engine.d.ts +7 -0
- package/dist/improve/propose/writer.d.ts +26 -0
- package/dist/improve/scan/card-writer.d.ts +38 -0
- package/dist/improve/scan/detectors/closure-anomaly.d.ts +8 -0
- package/dist/improve/scan/detectors/index.d.ts +20 -0
- package/dist/improve/scan/detectors/repeated-tool-use.d.ts +29 -0
- package/dist/improve/scan/detectors/subagent-block.d.ts +13 -0
- package/dist/improve/scan/detectors/tool-failure-density.d.ts +10 -0
- package/dist/improve/scan/reader.d.ts +38 -0
- package/dist/improve/schemas.d.ts +494 -0
- package/dist/improve/triage.d.ts +22 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +148 -146
- package/dist/paths.d.ts +57 -0
- package/dist/service/launchd/install.d.ts +35 -0
- package/dist/service/launchd/paths.d.ts +8 -0
- package/dist/service/launchd/plist.d.ts +15 -0
- package/dist/service/launchd/status.d.ts +15 -0
- package/dist/service/launchd.d.ts +4 -0
- package/dist/skills/_agents/contract.d.ts +5 -0
- package/dist/skills/_agents/git-investigator.d.ts +8 -0
- package/dist/skills/_agents/index.d.ts +4 -0
- package/dist/skills/_agents/research-agent.d.ts +7 -0
- package/dist/skills/_agents/to-definition.d.ts +7 -0
- package/dist/skills/_lib/confidence-gate.d.ts +10 -0
- package/dist/skills/_lib/emit-card.d.ts +3 -0
- package/dist/skills/_lib/prompt-loader.d.ts +1 -0
- package/dist/skills/all.d.ts +7 -0
- package/dist/skills/audit-fit/discover.d.ts +16 -0
- package/dist/skills/audit-fit/index.d.ts +100 -0
- package/dist/skills/diagnose/_phases/orchestrator.d.ts +4 -0
- package/dist/skills/diagnose/_phases/triage.d.ts +4 -0
- package/dist/skills/diagnose/_phases/types.d.ts +142 -0
- package/dist/skills/diagnose/_phases/verifier.d.ts +16 -0
- package/dist/skills/diagnose/index.d.ts +6 -0
- package/dist/skills/example-template/index.d.ts +1 -0
- package/dist/skills/get-started/index.d.ts +2 -0
- package/dist/skills/index.d.ts +28 -0
- package/dist/skills/mint/_phases/build.d.ts +7 -0
- package/dist/skills/mint/_phases/heal.d.ts +8 -0
- package/dist/skills/mint/_phases/parallelize-dispatch.d.ts +12 -0
- package/dist/skills/mint/_phases/plan.d.ts +2 -0
- package/dist/skills/mint/_phases/research.d.ts +2 -0
- package/dist/skills/mint/_phases/ship.d.ts +3 -0
- package/dist/skills/mint/_phases/spec.d.ts +2 -0
- package/dist/skills/mint/_phases/verify.d.ts +9 -0
- package/dist/skills/mint/index.d.ts +47 -0
- package/dist/skills/mint/state-store.d.ts +4 -0
- package/dist/skills/score/digest-keyboard.d.ts +2 -0
- package/dist/skills/score/digest.d.ts +10 -0
- package/dist/skills/score/farm-run-record.d.ts +20 -0
- package/dist/skills/score/index.d.ts +33 -0
- package/dist/skills/score/memory-write.d.ts +31 -0
- package/dist/skills/score/winner.d.ts +10 -0
- package/dist/skills/service-setup/index.d.ts +2 -0
- package/dist/skills/telegram-setup/index.d.ts +2 -0
- package/dist/skills/user-skills.d.ts +9 -0
- package/dist/telegram/allowlist.d.ts +4 -0
- package/dist/telegram/bot.d.ts +38 -0
- package/dist/telegram/construct-session.d.ts +11 -0
- package/dist/telegram/elicitation-callback-data.d.ts +11 -0
- package/dist/telegram/elicitation-handler.d.ts +6 -0
- package/dist/telegram/elicitation-telegram.d.ts +6 -0
- package/dist/telegram/error-utils.d.ts +5 -0
- package/dist/telegram/example.d.ts +1 -0
- package/dist/telegram/farm-callback-data.d.ts +9 -0
- package/dist/telegram/formatter.d.ts +24 -0
- package/dist/telegram/handlers/commands.d.ts +11 -0
- package/dist/telegram/handlers/farm-callbacks.d.ts +26 -0
- package/dist/telegram/handlers/help.d.ts +3 -0
- package/dist/telegram/handlers/message.d.ts +26 -0
- package/dist/telegram/handlers/registration.d.ts +5 -0
- package/dist/telegram/handlers/start.d.ts +2 -0
- package/dist/telegram/index.d.ts +8 -0
- package/dist/telegram/manager.d.ts +35 -0
- package/dist/telegram/mcp-session.d.ts +8 -0
- package/dist/telegram/notify-routing.d.ts +12 -0
- package/dist/telegram/push.d.ts +23 -0
- package/dist/telegram/session-manager.d.ts +42 -0
- package/dist/telegram/setup-wizard.d.ts +59 -0
- package/dist/telegram/stream-timeout-error.d.ts +3 -0
- package/dist/telegram/streaming.d.ts +10 -0
- package/dist/telegram/version-check.d.ts +19 -0
- package/dist/telegram/watch.d.ts +22 -0
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.mjs +178 -176
- package/dist/telemetry/schemas.d.ts +10 -0
- package/dist/utils/CircularBuffer.d.ts +13 -0
- package/dist/utils/cd-on-exit.d.ts +5 -0
- package/dist/utils/cleanupRegistry.d.ts +2 -0
- package/dist/utils/debug.d.ts +2 -0
- package/dist/utils/diff.d.ts +17 -0
- package/dist/utils/envFile.d.ts +5 -0
- package/dist/utils/envUtils.d.ts +2 -0
- package/dist/utils/error-classifiers.d.ts +2 -0
- package/dist/utils/errors.d.ts +38 -0
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/memoize.d.ts +9 -0
- package/dist/utils/prompt-secret.d.ts +1 -0
- package/dist/utils/terminal-sanitize.d.ts +2 -0
- package/dist/web/extract.d.ts +3 -0
- package/dist/web/index.d.ts +6 -0
- package/dist/web/scrape.d.ts +14 -0
- package/dist/web/search.d.ts +14 -0
- package/dist/web/types.d.ts +29 -0
- package/package.json +10 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ROUTING_DIRECTIVE = "[skill-routing: active]\n\nRoute recurring work through registered skills instead of rolling ad-hoc solutions:\n\n- Before non-trivial implementation (multi-file edits, new features, config/build changes \u2014 anything that writes) \u2192 `/ground-state` first. Do NOT substitute inline `git status`/`get_runtime_state` \u2014 the skill triangulates git + infra + prior-session memory in parallel, which the inline checks miss. If `/ground-state` dispatch fails (depth limit, unavailable), fall back to inline checks AND note the coverage gap.\n- Bugs, failing tests, or regressions \u2192 `/diagnose`\n- High-stakes sub-agent output that will drive edits or commits \u2192 `/shadow-verify` before acting\n- Refactor needing parallel waves \u2192 `/parallelize`\n- Parallel or dependent multi-task work \u2192 `compose` tool (DAG of subagent nodes)\n- Greenfield feature where a written spec would genuinely help (novel scope, multi-day work, or external stakeholders involved) \u2192 `/mint`\n\nDo NOT reach for `/mint` for: bug fixes (use `/diagnose`), refactors with known shape, single-feature edits, work already spec'd in chat, or anything where the spec/approve pause would feel like ceremony. Implement directly in those cases.\n\nCommon composed sequences \u2014 reach for these when the task shape matches:\n\n- Bug with failing test and non-trivial fix \u2192 `/diagnose` \u2192 `/shadow-verify` on the proposed fix\n- Refactor needing parallel waves \u2192 plan \u2192 `/parallelize` \u2192 build waves\n- Diagnose + fix in parallel \u2192 `compose` with two independent nodes\n- Research \u2192 implement \u2192 verify pipeline \u2192 `compose` with edges: research\u2192implement\u2192verify\n- Multiple independent investigations \u2192 `compose` with N nodes, no edges\n\nReach for context-isolated investigators when the task is exploratory:\n\n- Map an unfamiliar module before editing \u2192 `/gather` or `/research`\n- Re-derive a load-bearing claim independently \u2192 `/shadow-verify`\n- Audit a diff before merge \u2192 `/review`\n- Generate alternatives before committing to a plan \u2192 `/devils-advocate`\n\nOr dispatch a raw `agent` call when no skill matches but the work is parallelizable, verification-heavy, or would otherwise consume substantial inline context.\n\nSkip orchestration for: single-line edits, trivial Q&A, and direct tool calls the user explicitly requested. The goal is leverage, not ceremony. If a skill would add overhead without adding value, don't invoke it.\n\nDefault to acting autonomously. `ask_question` is a last resort, not a first move \u2014 every question blocks on the operator, who is often away from keyboard.\n\nBefore you ask, you MUST exhaust the tools you have: read the files, check git, search the codebase and docs, inspect runtime state. If any tool can get you the answer, use the tool \u2014 never ask the operator for something you can discover yourself. When a wrong guess would be cheap or reversible, make a reasonable assumption, proceed, and state the assumption instead of asking.\n\n**Answerability \u2014 a question only helps if a human will actually answer it:**\n\n`surface` (from `get_runtime_state`, view `\"self\"`) is a partial signal, not a guarantee:\n- `daemon`, or any session started by a scheduler, cron job, or another agent, has no human watching \u2014 never block on `ask_question` here.\n- `cli` is ambiguous: the interactive REPL and the Telegram bot can reach a human, but one-shot `chat` runs and sub-agent forks report the same `cli` and have no elicitation handler \u2014 there `ask_question` returns `{ action: 'decline' }` instantly.\n- Even when a handler exists, the operator is usually away, so a blocking question can stall until the turn aborts.\n\nSo treat `ask_question` as best-effort: a `decline` or `cancel` result means \"no answer is coming,\" not a failure to abort the task on. When you cannot be sure a human will answer, instead of asking:\n1. **Proceed on a stated assumption** \u2014 pick the most reasonable interpretation, act on it, and record the assumption in your Done/Blocked terminal state for async review.\n2. **Emit a Blocked artifact** \u2014 if no safe assumption exists and proceeding would be irreversible, end the turn with a **Blocked** terminal state naming exactly what the operator must supply before the next run.\n\nReserve `ask_question` for the narrow set of things no tool can resolve: a genuinely ambiguous requirement whose readings lead to materially different work, a decision with significant or irreversible consequences, or context that lives only in the operator's head (a preference, a secret, an external constraint):\n\n- Question types: `text` (open-ended), `confirm` (yes/no), `choice` (single pick from list), `multi_choice` (multi-pick), `number` (numeric with optional bounds). When `allow_custom: true`, the result may include `custom_value` instead of `value` \u2014 check `content.custom_value !== undefined` to detect a free-form answer.\n- Ask one focused question at a time. Do NOT ask multiple questions in a single call, and do NOT stack several ask_question calls across a turn \u2014 fold the genuine unknowns into the single most decision-relevant question.\n- Do NOT use when the user has already provided sufficient context \u2014 infer and proceed instead.\n- The result `action` will be `accept` (answered), `cancel` (user interrupted), `decline` (no handler), or `skip` (optional question skipped).\n- `allow_custom` (choice/multi_choice only): opt-in to a free-form entry affordance. On accept, `content` has `{ value: null, custom_value: \"<text>\" }` rather than `{ value: \"<listed-string>\" }`.\n- After a `cancel` or `decline`, stop and tell the user what information you need \u2014 do not loop and re-ask.";
|
|
2
|
+
export declare const END_OF_TURN_DIRECTIVE = "[end-of-turn protocol]\n\nEvery turn must end in one externally identifiable terminal state. AFK users need inspectable artifacts, not ceremony. Write each bullet as a single sentence.\n\n**Done**\n- What was done\n- Evidence that exists, named by a durable location (file path, commit SHA, trace path, test output, or memory key) \u2014 never transcript-only\n- What changed in the world\n- Anything still pending or deferred, with why\n- If files were written or edited but no `git commit` ran, say so explicitly \u2014 name the uncommitted paths and why (e.g. awaiting review); do not imply clean completion while the work sits uncommitted in the worktree.\n\n**Blocked**\n- What blocks\n- What must change to unblock\n- What has already been done\n\n**Asking**\n- One precise question\n- The assumption it resolves\n- What you will do once answered\n\n**Interrupted**\n- What you were doing\n- Where state was saved\n- What resumption requires\n\nNever end a turn mid-loop without one of these. The terminal-state heading must be the last block of the response, with no trailing prose after it.";
|
|
3
|
+
export type PromptSurface = 'repl' | 'telegram' | 'one-shot' | 'subagent';
|
|
4
|
+
export declare function pendingBriefContext(briefsDir?: string): string | undefined;
|
|
5
|
+
export declare function assembleSystemPrompt(base: string | undefined, autoRouting: boolean, surface?: PromptSurface, briefContext?: string): string | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TraceOrigin, TraceActor } from './session/session-identity.js';
|
|
2
|
+
export interface RoutingDecisionEntry {
|
|
3
|
+
event: string;
|
|
4
|
+
origin?: TraceOrigin | undefined;
|
|
5
|
+
actor?: TraceActor | undefined;
|
|
6
|
+
subagent_id?: string | undefined;
|
|
7
|
+
id_prefix?: string | undefined;
|
|
8
|
+
parent_session_id?: string | undefined;
|
|
9
|
+
parent_subagent_id?: string | undefined;
|
|
10
|
+
status?: string | undefined;
|
|
11
|
+
duration_ms?: number | undefined;
|
|
12
|
+
content_chars?: number | undefined;
|
|
13
|
+
error_message?: string | undefined;
|
|
14
|
+
schema_error?: string | undefined;
|
|
15
|
+
partial_output_chars?: number | undefined;
|
|
16
|
+
depth?: number | undefined;
|
|
17
|
+
reason?: string | undefined;
|
|
18
|
+
requested_name?: string | undefined;
|
|
19
|
+
model?: string | undefined;
|
|
20
|
+
mode?: string | undefined;
|
|
21
|
+
max_turns?: number | undefined;
|
|
22
|
+
node_count?: number | undefined;
|
|
23
|
+
edge_count?: number | undefined;
|
|
24
|
+
succeeded?: number | undefined;
|
|
25
|
+
failed?: number | undefined;
|
|
26
|
+
skipped?: number | undefined;
|
|
27
|
+
tool_call_count?: number | undefined;
|
|
28
|
+
thinking_present?: boolean | undefined;
|
|
29
|
+
tool_names?: string | undefined;
|
|
30
|
+
is_gate?: boolean | undefined;
|
|
31
|
+
tool?: string | undefined;
|
|
32
|
+
total_bytes?: number | undefined;
|
|
33
|
+
stream?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildRoutingDecisionRow(entry: RoutingDecisionEntry): Record<string, unknown>;
|
|
36
|
+
export declare function appendRoutingDecision(entry: RoutingDecisionEntry): Promise<void>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import type { HookRegistry } from '../hooks.js';
|
|
3
|
+
import type { ProviderCompactResult, ProviderQuery } from '../provider.js';
|
|
4
|
+
import { type ZodType } from 'zod';
|
|
5
|
+
import type { AccountInfo, AgentConfig, AgentInfo, AgentModelInput, IAgentSession, InputStreamRef, McpServerStatus, Message, ModelInfo, OutputEvent, PermissionMode, ResponseMetadata, RewindFilesResult, SDKControlGetContextUsageResponse, SendMessageOptions, SessionIdentity, SessionMetadata, SessionState, SlashCommand, StructuredMessageOptions } from '../types.js';
|
|
6
|
+
import type { ElicitationRequest } from '../types/sdk-types.js';
|
|
7
|
+
export declare class AgentSession implements IAgentSession {
|
|
8
|
+
private config;
|
|
9
|
+
private _pendingPlanExitSeed;
|
|
10
|
+
private currentState;
|
|
11
|
+
private providerQuery;
|
|
12
|
+
private providerIterator;
|
|
13
|
+
private conversationHistory;
|
|
14
|
+
private turnCount;
|
|
15
|
+
private lastResponseMetadata;
|
|
16
|
+
private initPromise;
|
|
17
|
+
private inputStream;
|
|
18
|
+
private readonly abortController;
|
|
19
|
+
private readonly _hookRegistry;
|
|
20
|
+
private sessionEndDispatched;
|
|
21
|
+
private stateManager;
|
|
22
|
+
private sessionRunningCostUsd;
|
|
23
|
+
private sessionRunningTokens;
|
|
24
|
+
private lastStopReason;
|
|
25
|
+
private maxTurnsHit;
|
|
26
|
+
private hookBlocked;
|
|
27
|
+
private sawProviderError;
|
|
28
|
+
private readonly sessionStartedAt;
|
|
29
|
+
private subagentCompletedCount;
|
|
30
|
+
private subagentRunningTokens;
|
|
31
|
+
private subagentRunningCostUsd;
|
|
32
|
+
private ledger;
|
|
33
|
+
private ledgerInitAttempted;
|
|
34
|
+
constructor(config: AgentConfig);
|
|
35
|
+
private initSdkLifecycle;
|
|
36
|
+
private pullInitialization;
|
|
37
|
+
private buildTransformDeps;
|
|
38
|
+
get state(): SessionState;
|
|
39
|
+
get sessionId(): string | undefined;
|
|
40
|
+
get cwd(): string | undefined;
|
|
41
|
+
get abortSignal(): AbortSignal;
|
|
42
|
+
get hookRegistry(): HookRegistry | undefined;
|
|
43
|
+
abort(reason: string): void;
|
|
44
|
+
sendMessage(content: string, options?: SendMessageOptions): Promise<Message>;
|
|
45
|
+
sendMessageStructured<T>(content: string, schema: ZodType<T>, options?: StructuredMessageOptions): Promise<T>;
|
|
46
|
+
sendMessageStream(content: string | ContentBlockParam[]): AsyncIterableIterator<OutputEvent>;
|
|
47
|
+
private sendMessageStreamInternal;
|
|
48
|
+
private ensureLedger;
|
|
49
|
+
private sealLedger;
|
|
50
|
+
recordLedgerElicitation(reqId: string, request: ElicitationRequest): void;
|
|
51
|
+
private summarizeContentBlocks;
|
|
52
|
+
interrupt(): Promise<void>;
|
|
53
|
+
reset(): Promise<void>;
|
|
54
|
+
private onAbort;
|
|
55
|
+
setModel(model?: AgentModelInput): Promise<void>;
|
|
56
|
+
setPermissionMode(mode: PermissionMode): Promise<void>;
|
|
57
|
+
takePendingPlanExitSeed(): Promise<string | undefined>;
|
|
58
|
+
setCwd(cwd: string): void;
|
|
59
|
+
reauth(): Promise<{
|
|
60
|
+
accountId: string;
|
|
61
|
+
swapped: boolean;
|
|
62
|
+
} | null>;
|
|
63
|
+
waitForInitialization(): Promise<SessionMetadata>;
|
|
64
|
+
getSessionIdentity(): SessionIdentity;
|
|
65
|
+
getSessionMetadata(): SessionMetadata;
|
|
66
|
+
getQuery(): ProviderQuery;
|
|
67
|
+
supportedCommands(): Promise<SlashCommand[]>;
|
|
68
|
+
supportedModels(): Promise<ModelInfo[]>;
|
|
69
|
+
supportedAgents(): Promise<AgentInfo[]>;
|
|
70
|
+
getContextUsage(): Promise<SDKControlGetContextUsageResponse>;
|
|
71
|
+
mcpServerStatus(): Promise<McpServerStatus[]>;
|
|
72
|
+
accountInfo(): Promise<AccountInfo>;
|
|
73
|
+
rewindFiles(userMessageId: string, options?: {
|
|
74
|
+
dryRun?: boolean;
|
|
75
|
+
}): Promise<RewindFilesResult>;
|
|
76
|
+
compact(): Promise<ProviderCompactResult>;
|
|
77
|
+
getLastResponseMetadata(): ResponseMetadata | null;
|
|
78
|
+
getOutputStream(): AsyncIterable<OutputEvent>;
|
|
79
|
+
getInputStreamRef(): Pick<InputStreamRef, 'pushUserMessage'>;
|
|
80
|
+
getHistory(): readonly Message[];
|
|
81
|
+
getTurnCount(): number;
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
private dispatchSessionEndOnce;
|
|
84
|
+
private emitClosure;
|
|
85
|
+
private deriveClosureReason;
|
|
86
|
+
private sealTraceWriter;
|
|
87
|
+
recordSubagentCompletion(usage?: {
|
|
88
|
+
inputTokens?: number;
|
|
89
|
+
outputTokens?: number;
|
|
90
|
+
cacheReadTokens?: number;
|
|
91
|
+
cacheCreationTokens?: number;
|
|
92
|
+
}, costUsd?: number): void;
|
|
93
|
+
private deriveSealStatus;
|
|
94
|
+
private assertCanSend;
|
|
95
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ClosureReason } from '../trace/index.js';
|
|
2
|
+
export declare function isTruncationStopReason(stopReason: string | undefined): boolean;
|
|
3
|
+
export interface ClosureReasonInputs {
|
|
4
|
+
dispatchReason: string;
|
|
5
|
+
maxTurnsHit: boolean;
|
|
6
|
+
hookBlocked: boolean;
|
|
7
|
+
abort: 'budget_exceeded' | 'timeout' | 'abort' | null;
|
|
8
|
+
lastStopReason: string | undefined;
|
|
9
|
+
sawProviderError: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function classifyClosureReason(i: ClosureReasonInputs): ClosureReason;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HookRegistry, SessionEndContext, SessionStartContext } from '../hooks.js';
|
|
2
|
+
import type { TraceWriter } from '../trace/index.js';
|
|
3
|
+
export interface SessionHookDispatchOptions {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
onError?: (err: Error) => void;
|
|
6
|
+
traceWriter?: TraceWriter;
|
|
7
|
+
}
|
|
8
|
+
export declare function dispatchSessionStart(registry: HookRegistry | undefined, context: SessionStartContext, options?: SessionHookDispatchOptions): Promise<void>;
|
|
9
|
+
export declare function dispatchSessionEnd(registry: HookRegistry | undefined, context: SessionEndContext, options?: SessionHookDispatchOptions): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
|
|
2
|
+
import type { ProviderUserTurn } from '../provider.js';
|
|
3
|
+
export declare class QueryInputStream {
|
|
4
|
+
private pendingResolve;
|
|
5
|
+
private bufferedMessages;
|
|
6
|
+
private getSessionId;
|
|
7
|
+
constructor(getSessionId: () => string | undefined);
|
|
8
|
+
pushUserMessage(content: string | ContentBlockParam[]): void;
|
|
9
|
+
createIterable(): AsyncIterable<ProviderUserTurn>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AgentModelInput, ClaudeModel } from '../types.js';
|
|
2
|
+
export declare const MODEL_MAP: Readonly<Record<ClaudeModel, string>>;
|
|
3
|
+
export declare function isValidModel(model: string): model is ClaudeModel;
|
|
4
|
+
export declare function getModelId(shortName: ClaudeModel): string;
|
|
5
|
+
export declare function resolveModelId(model: AgentModelInput | undefined): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SlotName = 'local' | 'small' | 'medium' | 'large';
|
|
2
|
+
export declare const SLOT_NAMES: readonly SlotName[];
|
|
3
|
+
export type SlotProvider = 'anthropic' | 'openai';
|
|
4
|
+
export interface ModelSlotBinding {
|
|
5
|
+
id: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
provider?: SlotProvider;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
}
|
|
11
|
+
export type ModelSlots = Record<SlotName, ModelSlotBinding>;
|
|
12
|
+
export declare const DEFAULT_SLOT_BINDINGS: ModelSlots;
|
|
13
|
+
export declare const AUTO_SENTINEL = "auto";
|
|
14
|
+
export declare const CLAUDE_FABLE_5_ID = "claude-fable-5";
|
|
15
|
+
export declare const DIRECT_MODEL_ALIASES: Readonly<Record<string, string>>;
|
|
16
|
+
export declare function setSlotBindings(bindings: ModelSlots | undefined): void;
|
|
17
|
+
export declare function resetSlotBindings(): void;
|
|
18
|
+
export declare function computeSlotBindings(fileOverrides?: Partial<Record<SlotName, ModelSlotBinding>>): ModelSlots;
|
|
19
|
+
export declare function getSlotBindings(override?: ModelSlots): ModelSlots;
|
|
20
|
+
export declare function slotForInput(input: string, bindings?: ModelSlots): SlotName | undefined;
|
|
21
|
+
export declare function resolveBinding(input: string | undefined, bindings?: ModelSlots): ModelSlotBinding;
|
|
22
|
+
export declare function resolveModelInput(input: string | undefined, bindings?: ModelSlots): string | undefined;
|
|
23
|
+
export declare function unconfiguredSlotError(input: string | undefined, bindings?: ModelSlots): string | undefined;
|
|
24
|
+
export declare function parseModelsConfig(raw: unknown): Partial<Record<SlotName, ModelSlotBinding>>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OutputEvent, SubagentProgressMeta } from '../types.js';
|
|
2
|
+
export type Phase = 'idle' | 'investigating' | 'editing' | 'testing' | 'building' | 'waiting_on_subagent' | 'risky_pending' | 'blocked_by_hook' | 'interrupted' | 'ready_for_review';
|
|
3
|
+
export declare function reducePhase(prev: Phase, event: OutputEvent, meta: SubagentProgressMeta | undefined, now: number, lastEventAt: number): Phase;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type PromptShape = 'string' | 'string[]' | 'preset' | 'undefined';
|
|
2
|
+
export interface SystemPromptProvenance {
|
|
3
|
+
source: string;
|
|
4
|
+
shape: PromptShape;
|
|
5
|
+
length?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Provenance {
|
|
8
|
+
systemPrompt?: SystemPromptProvenance;
|
|
9
|
+
model?: {
|
|
10
|
+
source: string;
|
|
11
|
+
};
|
|
12
|
+
apiKey?: {
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export type ResolutionKind = 'custom-string' | 'custom-string-array' | 'preset-claude-code' | 'undefined';
|
|
17
|
+
export interface Resolution {
|
|
18
|
+
kind: ResolutionKind;
|
|
19
|
+
note: string;
|
|
20
|
+
append?: {
|
|
21
|
+
length: number;
|
|
22
|
+
};
|
|
23
|
+
excludeDynamicSections?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface DumpPayload {
|
|
26
|
+
prompt: unknown;
|
|
27
|
+
options: unknown;
|
|
28
|
+
provenance: Provenance;
|
|
29
|
+
}
|
|
30
|
+
export declare const DUMP_FILE_BANNER = "# AFK PROMPT DUMP \u2014 May contain secrets. Inspect before sharing.\n";
|
|
31
|
+
export declare function redactInlineSecrets(text: string): string;
|
|
32
|
+
export declare function deriveResolution(systemPrompt: unknown): Resolution;
|
|
33
|
+
export declare function dumpIfEnabled(payload: DumpPayload): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Surface } from '../awareness/types.js';
|
|
2
|
+
export type TraceOrigin = 'cli' | 'telegram' | 'daemon' | 'unknown';
|
|
3
|
+
export type TraceActor = 'main' | 'subagent';
|
|
4
|
+
export declare function deriveOrigin(surface: Surface | undefined): TraceOrigin;
|
|
5
|
+
export declare function deriveActor(parentSessionId: string | null | undefined): TraceActor;
|
|
6
|
+
export declare function actorFromDepth(depth: number | undefined): TraceActor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentConfig, SessionIdentity, SessionMetadata } from '../types.js';
|
|
2
|
+
export declare function wireAbortSignal(external: AbortSignal | undefined, internal: AbortController, onAbort: () => void): void;
|
|
3
|
+
export declare function buildInitialState(config: AgentConfig, resolvedModel: string): {
|
|
4
|
+
sessionIdentity: SessionIdentity;
|
|
5
|
+
metadata: SessionMetadata;
|
|
6
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SessionIdentity, SessionMetadata } from '../types.js';
|
|
2
|
+
export declare class SessionStateManager {
|
|
3
|
+
private initializationPromise;
|
|
4
|
+
private resolveInitialization;
|
|
5
|
+
private rejectInitialization;
|
|
6
|
+
private initializationSettled;
|
|
7
|
+
private sessionMetadata;
|
|
8
|
+
private sessionIdentity;
|
|
9
|
+
constructor(sessionIdentity: SessionIdentity, initialMetadata: SessionMetadata);
|
|
10
|
+
waitForInitialization(): Promise<SessionMetadata>;
|
|
11
|
+
getSessionIdentity(): SessionIdentity;
|
|
12
|
+
getSessionMetadata(): SessionMetadata;
|
|
13
|
+
getSessionId(): string | undefined;
|
|
14
|
+
updateSessionIdentity(sessionId?: string): void;
|
|
15
|
+
setSessionMetadata(updater: (prev: SessionMetadata) => SessionMetadata): void;
|
|
16
|
+
resolveInitializationIfNeeded(): void;
|
|
17
|
+
resolveInitializationOnce(): void;
|
|
18
|
+
rejectInitializationOnce(error: Error): void;
|
|
19
|
+
isInitializationSettled(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ModelSlots } from './model-slots.js';
|
|
2
|
+
export interface SlotCredentialTarget {
|
|
3
|
+
model: string;
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
openaiBaseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function applySlotCredentials(config: SlotCredentialTarget, bindings?: ModelSlots): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProviderEvent, ProviderUsage } from '../provider.js';
|
|
2
|
+
import type { Message, OutputEvent, ResponseMetadata, SessionMetadata } from '../types.js';
|
|
3
|
+
import type { TraceWriter } from '../trace/index.js';
|
|
4
|
+
export type TransformDeps = {
|
|
5
|
+
conversationHistory: Message[];
|
|
6
|
+
getSessionMetadata: () => SessionMetadata;
|
|
7
|
+
setSessionMetadata: (updater: (prev: SessionMetadata) => SessionMetadata) => void;
|
|
8
|
+
updateSessionIdentity: (sessionId?: string) => void;
|
|
9
|
+
resolveInitialization: () => void;
|
|
10
|
+
setLastResponseMetadata: (metadata: ResponseMetadata) => void;
|
|
11
|
+
maxBudgetUsd?: number;
|
|
12
|
+
abortBudget?: (reason: string) => void;
|
|
13
|
+
_runningCostUsd?: number;
|
|
14
|
+
traceWriter?: TraceWriter;
|
|
15
|
+
};
|
|
16
|
+
export declare function parsePersistedOutput(content: string): {
|
|
17
|
+
sizeLabel: string;
|
|
18
|
+
sizeBytes: number;
|
|
19
|
+
absolutePath: string;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare function usageToMetadata(usage: ProviderUsage, sessionId: string | undefined): ResponseMetadata;
|
|
22
|
+
export declare function transformProviderEvent(event: ProviderEvent, deps: TransformDeps): OutputEvent | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { OutputEvent } from './types/session-types.js';
|
|
2
|
+
import type { ElicitationRequest, ElicitationResult } from './types/sdk-types.js';
|
|
3
|
+
export type LedgerRecord = {
|
|
4
|
+
v: 1;
|
|
5
|
+
ts: number;
|
|
6
|
+
} & LedgerPayload;
|
|
7
|
+
export type LedgerPayload = {
|
|
8
|
+
kind: 'meta';
|
|
9
|
+
sessionId: string;
|
|
10
|
+
model: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
surface?: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'user';
|
|
15
|
+
text: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'assistant';
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'tool';
|
|
21
|
+
toolName: string;
|
|
22
|
+
input: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'tool_error';
|
|
25
|
+
toolName?: string;
|
|
26
|
+
content: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'done';
|
|
29
|
+
costUsd?: number;
|
|
30
|
+
durationMs?: number;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'error';
|
|
33
|
+
message: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'paused';
|
|
36
|
+
resetsAt?: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'resumed';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'elicitation';
|
|
41
|
+
reqId: string;
|
|
42
|
+
request: ElicitationRequest;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'elicitation_response';
|
|
45
|
+
reqId: string;
|
|
46
|
+
result: ElicitationResult;
|
|
47
|
+
hmac: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'abort_request';
|
|
50
|
+
nonce: string;
|
|
51
|
+
hmac: string;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'closed';
|
|
54
|
+
reason?: string;
|
|
55
|
+
};
|
|
56
|
+
export declare function projectOutputEvent(event: OutputEvent): LedgerPayload | null;
|
|
57
|
+
export declare class SessionLedgerWriter {
|
|
58
|
+
private readonly sessionId;
|
|
59
|
+
private readonly ledgerPath;
|
|
60
|
+
private stream;
|
|
61
|
+
private errored;
|
|
62
|
+
private closed;
|
|
63
|
+
private streamReady;
|
|
64
|
+
private pendingLines;
|
|
65
|
+
private readyPromise;
|
|
66
|
+
private readyResolve;
|
|
67
|
+
constructor(sessionId: string);
|
|
68
|
+
get active(): boolean;
|
|
69
|
+
record(payload: LedgerPayload): void;
|
|
70
|
+
recordEvent(event: OutputEvent): void;
|
|
71
|
+
recordUser(text: string): void;
|
|
72
|
+
private _openStream;
|
|
73
|
+
private _writeLine;
|
|
74
|
+
close(reason?: string): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export declare function ledgerExists(sessionId: string): Promise<boolean>;
|
|
77
|
+
export declare function readLedger(sessionId: string): AsyncGenerator<LedgerRecord>;
|
|
78
|
+
export declare function tailLedger(sessionId: string, opts?: {
|
|
79
|
+
fromStart?: boolean;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
}): AsyncGenerator<LedgerRecord>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AgentSession } from './session/agent-session.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { startShell, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_BYTES, type StartShellOptions, type ShellHandle, type ShellResult, type ShellErrorReason, } from './streamer.js';
|
|
2
|
+
export { ShellJobRegistry, type ShellJob, type ShellJobStatus, type ShellJobRegistryEvents, type StartJobOptions, } from './registry.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type ShellHandle, type ShellResult, type StartShellOptions } from './streamer.js';
|
|
3
|
+
export type ShellJobStatus = 'running' | 'completed' | 'failed' | 'killed';
|
|
4
|
+
export interface ShellJob {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly command: string;
|
|
7
|
+
readonly pid: number | undefined;
|
|
8
|
+
readonly startedAt: number;
|
|
9
|
+
readonly mode: 'foreground' | 'background';
|
|
10
|
+
status: ShellJobStatus;
|
|
11
|
+
result?: ShellResult;
|
|
12
|
+
}
|
|
13
|
+
export interface ShellJobRegistryEvents {
|
|
14
|
+
complete: [job: ShellJob];
|
|
15
|
+
}
|
|
16
|
+
export type StartJobOptions = Omit<StartShellOptions, 'onChunk' | 'abort'> & {
|
|
17
|
+
onChunk?: StartShellOptions['onChunk'];
|
|
18
|
+
mode: 'foreground' | 'background';
|
|
19
|
+
};
|
|
20
|
+
export declare class ShellJobRegistry extends EventEmitter<ShellJobRegistryEvents> {
|
|
21
|
+
private readonly jobs;
|
|
22
|
+
private readonly handles;
|
|
23
|
+
private readonly aborts;
|
|
24
|
+
private counter;
|
|
25
|
+
start(opts: StartJobOptions): {
|
|
26
|
+
job: ShellJob;
|
|
27
|
+
handle: ShellHandle;
|
|
28
|
+
};
|
|
29
|
+
get(id: string): ShellJob | undefined;
|
|
30
|
+
list(): readonly ShellJob[];
|
|
31
|
+
running(): readonly ShellJob[];
|
|
32
|
+
kill(id: string): boolean;
|
|
33
|
+
killAll(): readonly ShellJob[];
|
|
34
|
+
runningCount(): number;
|
|
35
|
+
private pruneHistory;
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface AnsiStripper {
|
|
2
|
+
strip(text: string): string;
|
|
3
|
+
flush(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare function makeAnsiStripper(): AnsiStripper;
|
|
6
|
+
export declare function utf8SafeTruncate(buf: Buffer, maxBytes: number): Buffer;
|
|
7
|
+
export declare const DEFAULT_TIMEOUT_MS = 120000;
|
|
8
|
+
export declare const DEFAULT_MAX_BYTES = 100000;
|
|
9
|
+
export interface StartShellOptions {
|
|
10
|
+
command: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
abort: AbortSignal;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
onChunk?: (chunk: Buffer, stream: 'stdout' | 'stderr') => void;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export type ShellErrorReason = 'timeout' | 'abort' | 'overflow' | 'spawn-failed' | 'nonzero-exit' | 'signal-killed';
|
|
19
|
+
export interface ShellResult {
|
|
20
|
+
exitCode: number | null;
|
|
21
|
+
durationMs: number;
|
|
22
|
+
displayCaptured: string;
|
|
23
|
+
modelCaptured: string;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
errorReason?: ShellErrorReason;
|
|
26
|
+
errorMessage?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ShellHandle {
|
|
29
|
+
readonly pid: number | undefined;
|
|
30
|
+
readonly promise: Promise<ShellResult>;
|
|
31
|
+
kill(signal?: NodeJS.Signals): void;
|
|
32
|
+
}
|
|
33
|
+
export declare function startShell(opts: StartShellOptions): ShellHandle;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const StanceSchema: z.ZodEnum<{
|
|
3
|
+
supports: "supports";
|
|
4
|
+
opposes: "opposes";
|
|
5
|
+
uncertain: "uncertain";
|
|
6
|
+
blocks: "blocks";
|
|
7
|
+
}>;
|
|
8
|
+
export type Stance = z.infer<typeof StanceSchema>;
|
|
9
|
+
export declare const SignalSchema: z.ZodObject<{
|
|
10
|
+
issue: z.ZodString;
|
|
11
|
+
stance: z.ZodEnum<{
|
|
12
|
+
supports: "supports";
|
|
13
|
+
opposes: "opposes";
|
|
14
|
+
uncertain: "uncertain";
|
|
15
|
+
blocks: "blocks";
|
|
16
|
+
}>;
|
|
17
|
+
confidence: z.ZodNumber;
|
|
18
|
+
evidence: z.ZodArray<z.ZodString>;
|
|
19
|
+
claim: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type Signal = z.infer<typeof SignalSchema>;
|
|
22
|
+
export declare const SignalBlockSchema: z.ZodObject<{
|
|
23
|
+
signal: z.ZodObject<{
|
|
24
|
+
issue: z.ZodString;
|
|
25
|
+
stance: z.ZodEnum<{
|
|
26
|
+
supports: "supports";
|
|
27
|
+
opposes: "opposes";
|
|
28
|
+
uncertain: "uncertain";
|
|
29
|
+
blocks: "blocks";
|
|
30
|
+
}>;
|
|
31
|
+
confidence: z.ZodNumber;
|
|
32
|
+
evidence: z.ZodArray<z.ZodString>;
|
|
33
|
+
claim: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
}, z.core.$loose>;
|
|
36
|
+
export type SignalBlock = z.infer<typeof SignalBlockSchema>;
|
|
37
|
+
export type ParseSignalResult = {
|
|
38
|
+
ok: true;
|
|
39
|
+
signal: Signal;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
reason: 'absent' | 'malformed';
|
|
43
|
+
};
|
|
44
|
+
export declare function extractSignalBlock(content: string): unknown;
|
|
45
|
+
export declare function parseSignal(content: string): ParseSignalResult;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
import { AbortGraph } from '../abort-graph.js';
|
|
3
|
+
import type { HookRegistry } from '../hooks.js';
|
|
4
|
+
import type { IAgentSession, Message } from '../types.js';
|
|
5
|
+
import type { OutputEvent, SubagentProgressSink } from '../types/session-types.js';
|
|
6
|
+
import type { TraceWriter } from '../trace/index.js';
|
|
7
|
+
import { type SubagentResult, type SubagentStatus, type SubagentTrace } from './result.js';
|
|
8
|
+
export interface SubagentHandle<T = unknown> {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly status: SubagentStatus;
|
|
11
|
+
readonly session: IAgentSession;
|
|
12
|
+
run(prompt: string): Promise<Message>;
|
|
13
|
+
runToResult(prompt: string): Promise<SubagentResult<T>>;
|
|
14
|
+
runInBackground(prompt: string, onResult?: (result: SubagentResult<T>) => void, onProgress?: (event: OutputEvent) => void): void;
|
|
15
|
+
cancel(): Promise<void>;
|
|
16
|
+
teardown(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly session: IAgentSession;
|
|
21
|
+
private readonly controller;
|
|
22
|
+
private readonly abortGraph;
|
|
23
|
+
private readonly outputSchema;
|
|
24
|
+
private readonly timeoutMs;
|
|
25
|
+
private readonly hookRegistry;
|
|
26
|
+
private readonly onTerminal;
|
|
27
|
+
private readonly parentInputStreamRef?;
|
|
28
|
+
private readonly parentAbortSignal?;
|
|
29
|
+
private readonly agentType?;
|
|
30
|
+
private readonly traceWriter?;
|
|
31
|
+
private readonly onSubagentSucceeded?;
|
|
32
|
+
private currentStatus;
|
|
33
|
+
private inFlight;
|
|
34
|
+
private lastMessage;
|
|
35
|
+
private lastDurationMs;
|
|
36
|
+
private latestTerminalStatus;
|
|
37
|
+
private stopDispatched;
|
|
38
|
+
private readonly progressSink;
|
|
39
|
+
private parentId;
|
|
40
|
+
private currentTrace;
|
|
41
|
+
private lastStreamedContent;
|
|
42
|
+
constructor(id: string, session: IAgentSession, controller: AbortController, abortGraph: AbortGraph, outputSchema: ZodType<T> | undefined, timeoutMs: number, hookRegistry: HookRegistry | undefined, onTerminal: () => void, parentInputStreamRef?: ReturnType<IAgentSession["getInputStreamRef"]> | undefined, parentAbortSignal?: AbortSignal | undefined, agentType?: string | undefined, progressSink?: SubagentProgressSink, parentId?: string, traceWriter?: TraceWriter | undefined, onSubagentSucceeded?: ((usage: SubagentTrace["usage"], costUsd: number | undefined) => void) | undefined);
|
|
43
|
+
get status(): SubagentStatus;
|
|
44
|
+
run(prompt: string, sinkOverride?: SubagentProgressSink): Promise<Message>;
|
|
45
|
+
private streamToFinalMessage;
|
|
46
|
+
runToResult(prompt: string, sinkOverride?: SubagentProgressSink): Promise<SubagentResult<T>>;
|
|
47
|
+
runInBackground(prompt: string, onResult?: (result: SubagentResult<T>) => void, onProgress?: (event: OutputEvent) => void): void;
|
|
48
|
+
cancel(): Promise<void>;
|
|
49
|
+
teardown(): Promise<void>;
|
|
50
|
+
private dispatchStopAndRelease;
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ZodError, ZodType } from 'zod';
|
|
2
|
+
import type { Message } from '../types.js';
|
|
3
|
+
import { type Signal } from '../signal-block.js';
|
|
4
|
+
export type SubagentStatus = 'idle' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
5
|
+
export interface SubagentToolCall {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
inputBytes?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SubagentToolResult {
|
|
11
|
+
toolUseId: string;
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
truncated?: boolean;
|
|
14
|
+
sizeBytes?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface SubagentTrace {
|
|
17
|
+
toolCalls: SubagentToolCall[];
|
|
18
|
+
toolResults: SubagentToolResult[];
|
|
19
|
+
thinkingPresent: boolean;
|
|
20
|
+
turnCount: number;
|
|
21
|
+
usage?: {
|
|
22
|
+
inputTokens?: number;
|
|
23
|
+
outputTokens?: number;
|
|
24
|
+
cacheReadTokens?: number;
|
|
25
|
+
cacheCreationTokens?: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare function createEmptyTrace(): SubagentTrace;
|
|
29
|
+
export interface SubagentResult<T = unknown> {
|
|
30
|
+
id: string;
|
|
31
|
+
status: SubagentStatus;
|
|
32
|
+
message?: Message;
|
|
33
|
+
output?: T;
|
|
34
|
+
error?: Error;
|
|
35
|
+
schemaError?: ZodError;
|
|
36
|
+
partialOutput?: T | string;
|
|
37
|
+
completionPercent?: number;
|
|
38
|
+
trace?: SubagentTrace;
|
|
39
|
+
signal?: Signal;
|
|
40
|
+
}
|
|
41
|
+
export declare function buildResultFromMessage<T>(id: string, status: SubagentStatus, message: Message, outputSchema: ZodType<T> | undefined, trace?: SubagentTrace): SubagentResult<T>;
|
|
42
|
+
export declare function buildResultFromError<T>(id: string, status: SubagentStatus, err: unknown, trace?: SubagentTrace): SubagentResult<T>;
|
|
43
|
+
export declare function describeFailure(result: Pick<SubagentResult, 'status' | 'error'>): string;
|
|
44
|
+
export interface SubagentExecutionError extends Error {
|
|
45
|
+
partialOutput?: unknown;
|
|
46
|
+
subagentId?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function attachSubagentContext(err: Error, context: {
|
|
49
|
+
partialOutput?: unknown;
|
|
50
|
+
subagentId?: string;
|
|
51
|
+
}): SubagentExecutionError;
|