typeclaw 0.49.0 → 0.51.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/types/agent/attention-escalation.d.ts +18 -0
- package/dist/types/agent/auth.d.ts +7 -0
- package/dist/types/agent/bash-sandbox-env.d.ts +15 -0
- package/dist/types/agent/bash-sandbox-proc.d.ts +8 -0
- package/dist/types/agent/bash-sandbox.d.ts +94 -0
- package/dist/types/agent/compaction.d.ts +8 -0
- package/dist/types/agent/git-nudge.d.ts +6 -0
- package/dist/types/agent/guard-types.d.ts +25 -0
- package/dist/types/agent/guards.d.ts +7 -0
- package/dist/types/agent/idle-compaction.d.ts +8 -0
- package/dist/types/agent/index.d.ts +151 -0
- package/dist/types/agent/live-subagents.d.ts +113 -0
- package/dist/types/agent/llm-replay-sanitizer.d.ts +11 -0
- package/dist/types/agent/loop-guard.d.ts +67 -0
- package/dist/types/agent/model-fallback.d.ts +29 -0
- package/dist/types/agent/model-overrides.d.ts +8 -0
- package/dist/types/agent/multimodal/index.d.ts +2 -0
- package/dist/types/agent/multimodal/look-at.d.ts +60 -0
- package/dist/types/agent/multimodal/looker.d.ts +61 -0
- package/dist/types/agent/multimodal/read-redirect.d.ts +6 -0
- package/dist/types/agent/network/response-body.d.ts +1 -0
- package/dist/types/agent/network/safe-http.d.ts +46 -0
- package/dist/types/agent/output-allowance.d.ts +4 -0
- package/dist/types/agent/plugin-tools.d.ts +58 -0
- package/dist/types/agent/proactive-next-step-nudge.d.ts +2 -0
- package/dist/types/agent/prompt-cache-key.d.ts +3 -0
- package/dist/types/agent/provider-error.d.ts +23 -0
- package/dist/types/agent/reload-tool.d.ts +10 -0
- package/dist/types/agent/restart/index.d.ts +31 -0
- package/dist/types/agent/restart-handoff/index.d.ts +32 -0
- package/dist/types/agent/restart-handoff/paths.d.ts +1 -0
- package/dist/types/agent/retry-same-ref.d.ts +41 -0
- package/dist/types/agent/reviewer-activity.d.ts +3 -0
- package/dist/types/agent/reviewer-bash-policy.d.ts +8 -0
- package/dist/types/agent/self.d.ts +1 -0
- package/dist/types/agent/session-meta.d.ts +28 -0
- package/dist/types/agent/session-origin.d.ts +65 -0
- package/dist/types/agent/subagent-cache-keepalive.d.ts +38 -0
- package/dist/types/agent/subagent-completion-reminder.d.ts +29 -0
- package/dist/types/agent/subagent-drain.d.ts +25 -0
- package/dist/types/agent/subagent-session.d.ts +3 -0
- package/dist/types/agent/subagents.d.ts +153 -0
- package/dist/types/agent/system-prompt-composition.d.ts +17 -0
- package/dist/types/agent/system-prompt.d.ts +7 -0
- package/dist/types/agent/throttle-circuit.d.ts +25 -0
- package/dist/types/agent/todo/continuation-policy.d.ts +54 -0
- package/dist/types/agent/todo/continuation-state.d.ts +11 -0
- package/dist/types/agent/todo/continuation-wiring.d.ts +32 -0
- package/dist/types/agent/todo/continuation.d.ts +21 -0
- package/dist/types/agent/todo/scope.d.ts +6 -0
- package/dist/types/agent/todo/store.d.ts +16 -0
- package/dist/types/agent/tool-error-remediation.d.ts +1 -0
- package/dist/types/agent/tool-file-safety.d.ts +78 -0
- package/dist/types/agent/tool-not-found-nudge.d.ts +9 -0
- package/dist/types/agent/tool-result-budget.d.ts +15 -0
- package/dist/types/agent/tools/channel-disengage.d.ts +18 -0
- package/dist/types/agent/tools/channel-edit.d.ts +19 -0
- package/dist/types/agent/tools/channel-fetch-attachment.d.ts +36 -0
- package/dist/types/agent/tools/channel-handoff.d.ts +13 -0
- package/dist/types/agent/tools/channel-history-render.d.ts +3 -0
- package/dist/types/agent/tools/channel-history.d.ts +25 -0
- package/dist/types/agent/tools/channel-log.d.ts +5 -0
- package/dist/types/agent/tools/channel-react.d.ts +23 -0
- package/dist/types/agent/tools/channel-read.d.ts +27 -0
- package/dist/types/agent/tools/channel-reply.d.ts +47 -0
- package/dist/types/agent/tools/channel-send.d.ts +42 -0
- package/dist/types/agent/tools/channel-session-search.d.ts +10 -0
- package/dist/types/agent/tools/curl-impersonate.d.ts +37 -0
- package/dist/types/agent/tools/ddg.d.ts +27 -0
- package/dist/types/agent/tools/grant-role.d.ts +25 -0
- package/dist/types/agent/tools/keyed-semaphore.d.ts +10 -0
- package/dist/types/agent/tools/post-github-review.d.ts +38 -0
- package/dist/types/agent/tools/restart.d.ts +25 -0
- package/dist/types/agent/tools/runtime-notice.d.ts +3 -0
- package/dist/types/agent/tools/search-retry.d.ts +16 -0
- package/dist/types/agent/tools/skip-response.d.ts +17 -0
- package/dist/types/agent/tools/spawn-subagent.d.ts +77 -0
- package/dist/types/agent/tools/stream-snapshot.d.ts +23 -0
- package/dist/types/agent/tools/subagent-access.d.ts +20 -0
- package/dist/types/agent/tools/subagent-cancel.d.ts +23 -0
- package/dist/types/agent/tools/subagent-output.d.ts +50 -0
- package/dist/types/agent/tools/todo/index.d.ts +14 -0
- package/dist/types/agent/tools/webfetch/adaptive-html.d.ts +29 -0
- package/dist/types/agent/tools/webfetch/fetch.d.ts +26 -0
- package/dist/types/agent/tools/webfetch/html-lexical.d.ts +27 -0
- package/dist/types/agent/tools/webfetch/index.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/inline-style-visibility.d.ts +3 -0
- package/dist/types/agent/tools/webfetch/strategies/grep.d.ts +11 -0
- package/dist/types/agent/tools/webfetch/strategies/jq.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/raw.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/strategies/readability.d.ts +16 -0
- package/dist/types/agent/tools/webfetch/strategies/selector.d.ts +4 -0
- package/dist/types/agent/tools/webfetch/strategies/snapshot.d.ts +1 -0
- package/dist/types/agent/tools/webfetch/tool.d.ts +15 -0
- package/dist/types/agent/tools/webfetch/types.d.ts +32 -0
- package/dist/types/agent/tools/websearch.d.ts +17 -0
- package/dist/types/agent/tools/wikipedia.d.ts +7 -0
- package/dist/types/agent/tools-without-local-file-operands.d.ts +1 -0
- package/dist/types/agent/turn-runner.d.ts +36 -0
- package/dist/types/agent-messenger/config-dir.d.ts +19 -0
- package/dist/types/browser/dockerfile.d.ts +2 -0
- package/dist/types/browser/registry.d.ts +49 -0
- package/dist/types/bundled-plugins/bun-hygiene/policy.d.ts +18 -0
- package/dist/types/bundled-plugins/github-cli-auth/git-askpass.d.ts +5 -0
- package/dist/types/bundled-plugins/guard/keys.d.ts +6 -0
- package/dist/types/bundled-plugins/guard/policies/managed-config.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-delete.d.ts +11 -0
- package/dist/types/bundled-plugins/guard/policies/memory-topics-write.d.ts +7 -0
- package/dist/types/bundled-plugins/guard/policies/non-workspace-write.d.ts +9 -0
- package/dist/types/bundled-plugins/guard/policies/skill-authoring.d.ts +20 -0
- package/dist/types/bundled-plugins/guard/policies/uncommitted-changes.d.ts +12 -0
- package/dist/types/bundled-plugins/guard/policy.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/secret-detector.d.ts +11 -0
- package/dist/types/bundled-plugins/memory/slug.d.ts +4 -0
- package/dist/types/bundled-plugins/security/permissions.d.ts +20 -0
- package/dist/types/bundled-plugins/security/policies/private-surface-read.d.ts +34 -0
- package/dist/types/bundled-plugins/security/policies/ssrf.d.ts +18 -0
- package/dist/types/bundled-plugins/security/policy.d.ts +4 -0
- package/dist/types/channels/adapter-namespace.d.ts +2 -0
- package/dist/types/channels/adapters/mention-hints.d.ts +12 -0
- package/dist/types/channels/adapters/webex-id-ref.d.ts +5 -0
- package/dist/types/channels/background-handoff.d.ts +56 -0
- package/dist/types/channels/background-obligations.d.ts +135 -0
- package/dist/types/channels/catch-up.d.ts +26 -0
- package/dist/types/channels/commands.d.ts +2 -0
- package/dist/types/channels/completion-claim.d.ts +20 -0
- package/dist/types/channels/continuation-willingness.d.ts +1 -0
- package/dist/types/channels/continuity-types.d.ts +75 -0
- package/dist/types/channels/describe-error.d.ts +1 -0
- package/dist/types/channels/engagement.d.ts +34 -0
- package/dist/types/channels/github-false-receipt.d.ts +20 -0
- package/dist/types/channels/github-repo.d.ts +2 -0
- package/dist/types/channels/github-rereview-guard.d.ts +24 -0
- package/dist/types/channels/github-review-check.d.ts +135 -0
- package/dist/types/channels/github-review-claim.d.ts +3 -0
- package/dist/types/channels/github-review-turn-ledger.d.ts +71 -0
- package/dist/types/channels/github-review-verdict-coordinator.d.ts +117 -0
- package/dist/types/channels/github-token-bridge.d.ts +20 -0
- package/dist/types/channels/github-verdict-activity.d.ts +12 -0
- package/dist/types/channels/inbound-journal.d.ts +272 -0
- package/dist/types/channels/last-alive.d.ts +3 -0
- package/dist/types/channels/membership-cache.d.ts +27 -0
- package/dist/types/channels/membership.d.ts +21 -0
- package/dist/types/channels/outbound-flood-filter.d.ts +7 -0
- package/dist/types/channels/participants.d.ts +4 -0
- package/dist/types/channels/persistence.d.ts +32 -0
- package/dist/types/channels/recovery-notice.d.ts +26 -0
- package/dist/types/channels/recovery-outbox.d.ts +58 -0
- package/dist/types/channels/router.d.ts +760 -0
- package/dist/types/channels/schema.d.ts +501 -0
- package/dist/types/channels/session-handoff.d.ts +58 -0
- package/dist/types/channels/session-search.d.ts +29 -0
- package/dist/types/channels/types.d.ts +414 -0
- package/dist/types/channels/waiting-reactions.d.ts +25 -0
- package/dist/types/cli/builtins.d.ts +2 -0
- package/dist/types/cli/command-meta.d.ts +9 -0
- package/dist/types/coding-agent/broker-body.d.ts +7 -0
- package/dist/types/coding-agent/broker.d.ts +22 -0
- package/dist/types/coding-agent/claude.d.ts +22 -0
- package/dist/types/coding-agent/codex.d.ts +19 -0
- package/dist/types/coding-agent/index.d.ts +71 -0
- package/dist/types/coding-agent/omo-state.d.ts +2 -0
- package/dist/types/coding-agent/omo-stream.d.ts +22 -0
- package/dist/types/coding-agent/omo.d.ts +133 -0
- package/dist/types/coding-agent/runner.d.ts +35 -0
- package/dist/types/coding-agent/tool.d.ts +27 -0
- package/dist/types/coding-agent/worktree.d.ts +22 -0
- package/dist/types/commands/index.d.ts +45 -0
- package/dist/types/config/config.d.ts +827 -0
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/config/model-overrides.d.ts +3 -0
- package/dist/types/config/providers.d.ts +1458 -0
- package/dist/types/config/reloadable.d.ts +9 -0
- package/dist/types/container/agent-operation-lock.d.ts +31 -0
- package/dist/types/container/build-cache.d.ts +39 -0
- package/dist/types/container/compose-project.d.ts +1 -0
- package/dist/types/container/controller.d.ts +25 -0
- package/dist/types/container/docker-app.d.ts +23 -0
- package/dist/types/container/exit-reason.d.ts +10 -0
- package/dist/types/container/index.d.ts +14 -0
- package/dist/types/container/log-archive.d.ts +68 -0
- package/dist/types/container/log-colors.d.ts +3 -0
- package/dist/types/container/log-timestamps.d.ts +9 -0
- package/dist/types/container/logs.d.ts +37 -0
- package/dist/types/container/memory-limit.d.ts +13 -0
- package/dist/types/container/memory-oversubscription.d.ts +20 -0
- package/dist/types/container/oom-events.d.ts +18 -0
- package/dist/types/container/port.d.ts +18 -0
- package/dist/types/container/require-running.d.ts +16 -0
- package/dist/types/container/restart.d.ts +32 -0
- package/dist/types/container/shared.d.ts +93 -0
- package/dist/types/container/shell.d.ts +35 -0
- package/dist/types/container/start.d.ts +145 -0
- package/dist/types/container/stats.d.ts +31 -0
- package/dist/types/container/status.d.ts +25 -0
- package/dist/types/container/stop.d.ts +24 -0
- package/dist/types/container/tool-oom-priority.d.ts +4 -0
- package/dist/types/container/verify-running.d.ts +49 -0
- package/dist/types/cron/consumer.d.ts +42 -0
- package/dist/types/cron/count-state.d.ts +24 -0
- package/dist/types/cron/index.d.ts +21 -0
- package/dist/types/cron/list.d.ts +33 -0
- package/dist/types/cron/reloadable.d.ts +11 -0
- package/dist/types/cron/scheduler.d.ts +51 -0
- package/dist/types/cron/schema.d.ts +108 -0
- package/dist/types/dependencies/bin-resolver.d.ts +28 -0
- package/dist/types/dependencies/bins.d.ts +22 -0
- package/dist/types/dependencies/index.d.ts +2 -0
- package/dist/types/eval/cell.d.ts +26 -0
- package/dist/types/eval/config.d.ts +19 -0
- package/dist/types/eval/dispatch.d.ts +7 -0
- package/dist/types/eval/kernel.d.ts +28 -0
- package/dist/types/eval/process.d.ts +23 -0
- package/dist/types/eval/protocol.d.ts +34 -0
- package/dist/types/eval/sandbox.d.ts +10 -0
- package/dist/types/eval/tool.d.ts +17 -0
- package/dist/types/eval/wire.d.ts +33 -0
- package/dist/types/git/bound-gc-config.d.ts +4 -0
- package/dist/types/git/hookless.d.ts +1 -0
- package/dist/types/git/reconcile-ignored.d.ts +13 -0
- package/dist/types/git/resolve-agent-git.d.ts +8 -0
- package/dist/types/git/resolve-identity.d.ts +10 -0
- package/dist/types/git/run.d.ts +24 -0
- package/dist/types/git/system-commit.d.ts +2 -0
- package/dist/types/hostd/client.d.ts +13 -0
- package/dist/types/hostd/models.d.ts +1 -0
- package/dist/types/hostd/paths.d.ts +17 -0
- package/dist/types/hostd/protocol.d.ts +93 -0
- package/dist/types/hostd/spawn.d.ts +17 -0
- package/dist/types/hostd/version.d.ts +18 -0
- package/dist/types/init/auto-upgrade.d.ts +41 -0
- package/dist/types/init/cli-version.d.ts +7 -0
- package/dist/types/init/dockerfile.d.ts +34 -0
- package/dist/types/init/ensure-deps.d.ts +17 -0
- package/dist/types/init/env-file.d.ts +3 -0
- package/dist/types/init/gitignore.d.ts +5 -0
- package/dist/types/init/local-source-stamp.d.ts +3 -0
- package/dist/types/init/packagejson.d.ts +7 -0
- package/dist/types/init/paths.d.ts +3 -0
- package/dist/types/init/reconcile-plugin-deps.d.ts +13 -0
- package/dist/types/init/run-bun-install.d.ts +16 -0
- package/dist/types/init/windows-dev-link.d.ts +8 -0
- package/dist/types/mcp/catalog.d.ts +7 -0
- package/dist/types/mcp/client.d.ts +58 -0
- package/dist/types/mcp/manager.d.ts +56 -0
- package/dist/types/mcp/tools.d.ts +23 -0
- package/dist/types/models/embedding-model.d.ts +20 -0
- package/dist/types/models/transformers-version.d.ts +1 -0
- package/dist/types/network/internal-destinations.d.ts +29 -0
- package/dist/types/operations/classify-tool-outcome.d.ts +35 -0
- package/dist/types/operations/incidents.d.ts +47 -0
- package/dist/types/operations/index.d.ts +3 -0
- package/dist/types/operations/remediations.d.ts +25 -0
- package/dist/types/path-safety/real-intended-path.d.ts +9 -0
- package/dist/types/permissions/builtins.d.ts +25 -0
- package/dist/types/permissions/grant.d.ts +19 -0
- package/dist/types/permissions/index.d.ts +6 -0
- package/dist/types/permissions/match-rule.d.ts +28 -0
- package/dist/types/permissions/permissions.d.ts +42 -0
- package/dist/types/permissions/resolve.d.ts +25 -0
- package/dist/types/permissions/schema.d.ts +14 -0
- package/dist/types/plugin/context.d.ts +20 -0
- package/dist/types/plugin/core-tool-names.d.ts +4 -0
- package/dist/types/plugin/define.d.ts +46 -0
- package/dist/types/plugin/hooks.d.ts +52 -0
- package/dist/types/plugin/index.d.ts +11 -0
- package/dist/types/plugin/load-skill.d.ts +14 -0
- package/dist/types/plugin/loader.d.ts +25 -0
- package/dist/types/plugin/manager.d.ts +42 -0
- package/dist/types/plugin/registry.d.ts +73 -0
- package/dist/types/plugin/skills.d.ts +11 -0
- package/dist/types/plugin/types.d.ts +336 -0
- package/dist/types/plugin/zod-introspect.d.ts +11 -0
- package/dist/types/reload/client.d.ts +11 -0
- package/dist/types/reload/docker-exec-client.d.ts +11 -0
- package/dist/types/reload/format.d.ts +2 -0
- package/dist/types/reload/index.d.ts +6 -0
- package/dist/types/reload/recover.d.ts +22 -0
- package/dist/types/reload/registry.d.ts +10 -0
- package/dist/types/reload/types.d.ts +25 -0
- package/dist/types/role-claim/client.d.ts +20 -0
- package/dist/types/role-claim/code.d.ts +4 -0
- package/dist/types/role-claim/controller.d.ts +59 -0
- package/dist/types/role-claim/index.d.ts +6 -0
- package/dist/types/role-claim/match-rule.d.ts +9 -0
- package/dist/types/role-claim/pending.d.ts +35 -0
- package/dist/types/role-claim/reload-after-claim.d.ts +16 -0
- package/dist/types/run/llm-fetch-observer.d.ts +50 -0
- package/dist/types/sandbox/availability.d.ts +21 -0
- package/dist/types/sandbox/build.d.ts +7 -0
- package/dist/types/sandbox/canonical-secrets.d.ts +8 -0
- package/dist/types/sandbox/coding-agent.d.ts +20 -0
- package/dist/types/sandbox/dependency-bins.d.ts +19 -0
- package/dist/types/sandbox/dev-source.d.ts +4 -0
- package/dist/types/sandbox/env-exposure.d.ts +3 -0
- package/dist/types/sandbox/errors.d.ts +20 -0
- package/dist/types/sandbox/hidden-paths.d.ts +11 -0
- package/dist/types/sandbox/index.d.ts +14 -0
- package/dist/types/sandbox/package-install.d.ts +1 -0
- package/dist/types/sandbox/policy.d.ts +71 -0
- package/dist/types/sandbox/privileged-runtime.d.ts +13 -0
- package/dist/types/sandbox/quote.d.ts +2 -0
- package/dist/types/sandbox/runtime-private.d.ts +1 -0
- package/dist/types/sandbox/session-tmp.d.ts +6 -0
- package/dist/types/sandbox/symlinks.d.ts +6 -0
- package/dist/types/sandbox/writable-zones.d.ts +15 -0
- package/dist/types/secrets/coding-agent-auth.d.ts +25 -0
- package/dist/types/secrets/defaults.d.ts +21 -0
- package/dist/types/secrets/export-github-cli-store.d.ts +22 -0
- package/dist/types/secrets/hydrate.d.ts +7 -0
- package/dist/types/secrets/index.d.ts +7 -0
- package/dist/types/secrets/provision-github-cli-store.d.ts +45 -0
- package/dist/types/secrets/refresh-provider-oauth.d.ts +22 -0
- package/dist/types/secrets/resolve.d.ts +14 -0
- package/dist/types/secrets/schema.d.ts +840 -0
- package/dist/types/secrets/storage.d.ts +56 -0
- package/dist/types/shared/host-locale.d.ts +1 -0
- package/dist/types/shared/index.d.ts +5 -0
- package/dist/types/shared/local-time.d.ts +4 -0
- package/dist/types/shared/platform.d.ts +2 -0
- package/dist/types/shared/protocol.d.ts +424 -0
- package/dist/types/shared/style-text.d.ts +3 -0
- package/dist/types/shared/wsl.d.ts +17 -0
- package/dist/types/stream/broker.d.ts +2 -0
- package/dist/types/stream/index.d.ts +2 -0
- package/dist/types/stream/types.d.ts +71 -0
- package/package.json +13 -6
- package/scripts/build-plugin-types.ts +105 -0
- package/scripts/check-plugin-sdk.ts +111 -0
- package/scripts/require-parallel.ts +5 -32
- package/src/agent/bash-sandbox-env.ts +104 -0
- package/src/agent/bash-sandbox-proc.ts +70 -0
- package/src/agent/bash-sandbox.ts +225 -0
- package/src/agent/compaction.ts +22 -10
- package/src/agent/guard-types.ts +3 -0
- package/src/agent/guards.ts +4 -0
- package/src/agent/idle-compaction.ts +178 -0
- package/src/agent/index.ts +139 -172
- package/src/agent/live-subagents.ts +19 -0
- package/src/agent/multimodal/look-at.ts +22 -9
- package/src/agent/output-allowance.ts +7 -0
- package/src/agent/plugin-tools.ts +39 -377
- package/src/agent/reviewer-bash-policy.ts +41 -1
- package/src/agent/session-origin.ts +28 -11
- package/src/agent/subagent-cache-keepalive.ts +198 -0
- package/src/agent/subagent-completion-reminder.ts +2 -2
- package/src/agent/subagent-session.ts +6 -0
- package/src/agent/subagents.ts +46 -8
- package/src/agent/system-prompt-composition.ts +141 -0
- package/src/agent/system-prompt.ts +5 -5
- package/src/agent/todo/scope.ts +1 -1
- package/src/agent/tool-file-safety.ts +6 -1
- package/src/agent/tools/channel-edit.ts +20 -10
- package/src/agent/tools/channel-fetch-attachment.ts +12 -5
- package/src/agent/tools/channel-handoff.ts +72 -0
- package/src/agent/tools/channel-read.ts +57 -10
- package/src/agent/tools/channel-reply.ts +33 -26
- package/src/agent/tools/channel-send.ts +21 -13
- package/src/agent/tools/channel-session-search.ts +35 -0
- package/src/agent/tools/curl-impersonate.ts +11 -4
- package/src/agent/tools/ddg.ts +84 -16
- package/src/agent/tools/spawn-subagent.ts +27 -11
- package/src/agent/tools/stream-snapshot.ts +15 -2
- package/src/agent/tools/subagent-access.ts +11 -4
- package/src/agent/tools-without-local-file-operands.ts +4 -0
- package/src/browser/bsk-shim.mjs +74 -0
- package/src/browser/dockerfile.ts +84 -0
- package/src/browser/egress.ts +104 -0
- package/src/browser/fill-secret.ts +307 -0
- package/src/browser/managed-browser.ts +205 -0
- package/src/browser/registry.ts +110 -0
- package/src/browser/relay.ts +231 -0
- package/src/browser/sandbox-entry.ts +167 -0
- package/src/bundled-plugins/agent-browser/index.ts +2 -0
- package/src/bundled-plugins/browser-agent/browser-agent.ts +89 -0
- package/src/bundled-plugins/browser-agent/index.ts +12 -0
- package/src/bundled-plugins/doc-render/index.ts +0 -10
- package/src/bundled-plugins/doc-render/render.ts +83 -111
- package/src/bundled-plugins/doc-render/skills/typeclaw-render-pdf/SKILL.md +152 -257
- package/src/bundled-plugins/explorer/explorer.ts +1 -1
- package/src/bundled-plugins/github-cli-auth/gh-command.ts +4 -0
- package/src/bundled-plugins/github-cli-auth/gh-review-detect.ts +40 -16
- package/src/bundled-plugins/github-cli-auth/git-auth-diagnostic.ts +95 -0
- package/src/bundled-plugins/github-cli-auth/graphql-auth-nudge.ts +12 -7
- package/src/bundled-plugins/github-cli-auth/index.ts +85 -60
- package/src/bundled-plugins/managed-browser/index.ts +179 -0
- package/src/bundled-plugins/managed-browser/skills/browser-use/browser-use/SKILL.md +27 -0
- package/src/bundled-plugins/managed-browser/skills/browserskill/browserskill/SKILL.md +28 -0
- package/src/bundled-plugins/managed-browser/skills/omowright/omowright/SKILL.md +40 -0
- package/src/bundled-plugins/memory/dreaming.ts +4 -1
- package/src/bundled-plugins/memory/load-memory.ts +2 -4
- package/src/bundled-plugins/memory/memory-logger.ts +74 -2
- package/src/bundled-plugins/memory/transcript-preload.ts +103 -0
- package/src/bundled-plugins/memory/vector/hybrid.ts +25 -14
- package/src/bundled-plugins/operator/operator.ts +1 -1
- package/src/bundled-plugins/qa/index.ts +11 -0
- package/src/bundled-plugins/qa/qa.ts +160 -0
- package/src/bundled-plugins/qa/skills/qa-cli.ts +50 -0
- package/src/bundled-plugins/qa/skills/qa-general.ts +30 -0
- package/src/bundled-plugins/qa/skills/qa-http.ts +39 -0
- package/src/bundled-plugins/qa/skills/qa-pr.ts +51 -0
- package/src/bundled-plugins/qa/skills/qa-web.ts +49 -0
- package/src/bundled-plugins/security/index.ts +53 -34
- package/src/bundled-plugins/security/policies/outbound-secret-scan.ts +1 -0
- package/src/bundled-plugins/security/policies/private-surface-read.ts +166 -201
- package/src/channels/adapter-namespace.ts +13 -0
- package/src/channels/adapters/discord-bot-reference.ts +5 -4
- package/src/channels/adapters/discord-bot.ts +98 -5
- package/src/channels/adapters/discord-classify.ts +8 -3
- package/src/channels/adapters/discord.ts +29 -0
- package/src/channels/adapters/github/index.ts +16 -0
- package/src/channels/adapters/github/last-alive.ts +4 -16
- package/src/channels/adapters/slack-attachment-download.ts +14 -3
- package/src/channels/adapters/slack-bot-author-resolver.ts +4 -3
- package/src/channels/adapters/slack-bot-channel-resolver.ts +9 -6
- package/src/channels/adapters/slack-bot-classify.ts +1 -0
- package/src/channels/adapters/slack-bot-slash-commands.ts +3 -1
- package/src/channels/adapters/slack-bot.ts +299 -67
- package/src/channels/adapters/slack-classify.ts +1 -0
- package/src/channels/catch-up.ts +137 -0
- package/src/channels/continuation-willingness.ts +2 -2
- package/src/channels/continuity-types.ts +1 -0
- package/src/channels/engagement.ts +17 -1
- package/src/channels/github-false-receipt.ts +3 -3
- package/src/channels/github-rereview-guard.ts +9 -5
- package/src/channels/github-review-check.ts +5 -1
- package/src/channels/github-review-verdict-coordinator.ts +68 -2
- package/src/channels/github-token-bridge.ts +24 -0
- package/src/channels/last-alive.ts +34 -0
- package/src/channels/manager.ts +8 -1
- package/src/channels/router.ts +515 -243
- package/src/channels/session-handoff.fixture.ts +144 -0
- package/src/channels/session-handoff.ts +175 -0
- package/src/channels/session-search.ts +71 -0
- package/src/channels/subagent-completion-bridge.ts +3 -2
- package/src/channels/types.ts +12 -2
- package/src/cli/channel.ts +2 -3
- package/src/cli/hostd.ts +3 -0
- package/src/cli/init.ts +2 -3
- package/src/cli/model.ts +132 -3
- package/src/coding-agent/index.ts +7 -1
- package/src/coding-agent/omo-stream.ts +40 -0
- package/src/coding-agent/runner.ts +30 -8
- package/src/config/config.ts +126 -22
- package/src/config/model-overrides.ts +59 -0
- package/src/config/models-mutation.ts +185 -2
- package/src/config/providers-mutation.ts +12 -4
- package/src/config/providers.ts +69 -4
- package/src/container/start.ts +132 -5
- package/src/doctor/checks.ts +33 -22
- package/src/doctor/index.ts +48 -12
- package/src/doctor/operational-incidents.ts +16 -1
- package/src/doctor/plugin-bridge.ts +14 -1
- package/src/doctor/stage.ts +14 -0
- package/src/doctor/types.ts +6 -0
- package/src/eval/cell.ts +93 -0
- package/src/eval/config.ts +32 -0
- package/src/eval/dispatch.ts +67 -0
- package/src/eval/entry.ts +261 -0
- package/src/eval/kernel.ts +154 -0
- package/src/eval/process.ts +113 -0
- package/src/eval/protocol.ts +26 -0
- package/src/eval/redeclare.ts +174 -0
- package/src/eval/sandbox.ts +114 -0
- package/src/eval/tool.ts +98 -0
- package/src/eval/wire.ts +93 -0
- package/src/hostd/daemon.ts +13 -1
- package/src/init/auto-upgrade.ts +7 -1
- package/src/init/dockerfile.ts +57 -12
- package/src/init/index.ts +4 -3
- package/src/init/local-source-stamp.ts +68 -0
- package/src/init/models-dev.ts +4 -0
- package/src/init/validate-api-key.ts +3 -0
- package/src/operations/classify-tool-outcome.ts +1 -1
- package/src/permissions/builtins.ts +7 -0
- package/src/permissions/permissions.ts +18 -9
- package/src/permissions/resolve.ts +7 -1
- package/src/plugin/context.ts +2 -0
- package/src/plugin/core-tool-names.ts +6 -1
- package/src/plugin/hooks.ts +137 -0
- package/src/plugin/index.ts +6 -0
- package/src/plugin/manager.ts +4 -0
- package/src/plugin/types.ts +60 -0
- package/src/run/bundled-plugins.ts +6 -0
- package/src/run/index.ts +24 -14
- package/src/run/llm-fetch-observer.ts +12 -15
- package/src/sandbox/canonical-secrets.ts +4 -0
- package/src/sandbox/dev-source.ts +26 -0
- package/src/sandbox/env-exposure.ts +20 -0
- package/src/sandbox/hidden-paths.ts +16 -2
- package/src/secrets/storage.ts +13 -0
- package/src/server/index.ts +46 -11
- package/src/skills/typeclaw-channel-github/SKILL.md +8 -8
- package/src/skills/typeclaw-config/SKILL.md +57 -5
- package/src/skills/typeclaw-config/references/dockerfile.md +2 -2
- package/src/skills/typeclaw-github-contributing/SKILL.md +1 -1
- package/src/skills/typeclaw-monorepo/SKILL.md +1 -1
- package/src/skills/typeclaw-permissions/SKILL.md +7 -7
- package/src/skills/typeclaw-troubleshooting/SKILL.md +12 -1
- package/typeclaw.schema.json +488 -5
- package/src/bundled-plugins/doc-render/templates/lib.typ +0 -339
- package/src/bundled-plugins/github-cli-auth/gh-store.ts +0 -733
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// Types a runtime-held value into the focused field of a managed-browser tab
|
|
2
|
+
// over CDP, so the model can enter a secret it never sees. The value only ever
|
|
3
|
+
// travels runtime -> Chrome; every outcome reports where it went, never what.
|
|
4
|
+
|
|
5
|
+
const COMMAND_TIMEOUT_MS = 10_000
|
|
6
|
+
const DEFAULT_NAVIGATION_TIMEOUT_MS = 15_000
|
|
7
|
+
|
|
8
|
+
export type FillSecretOptions = {
|
|
9
|
+
cdpUrl: string
|
|
10
|
+
value: string
|
|
11
|
+
url?: string
|
|
12
|
+
submit: boolean
|
|
13
|
+
navigationTimeoutMs?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type FillSecretOutcome =
|
|
17
|
+
| { status: 'filled'; url: string; field: string }
|
|
18
|
+
| { status: 'submitted'; url: string; field: string }
|
|
19
|
+
| { status: 'not-navigated'; url: string; field: string; cleared: boolean }
|
|
20
|
+
| { status: 'refused'; reason: string }
|
|
21
|
+
|
|
22
|
+
export async function fillSecretIntoFocusedField(options: FillSecretOptions): Promise<FillSecretOutcome> {
|
|
23
|
+
const cdp = await CdpConnection.open(options.cdpUrl)
|
|
24
|
+
try {
|
|
25
|
+
const target = await pickTarget(cdp, options.url)
|
|
26
|
+
if ('reason' in target) return { status: 'refused', reason: target.reason }
|
|
27
|
+
const { sessionId } = (await cdp.send('Target.attachToTarget', { targetId: target.targetId, flatten: true })) as {
|
|
28
|
+
sessionId: string
|
|
29
|
+
}
|
|
30
|
+
// Background tabs (omowright opens them) report no focus; emulate it so
|
|
31
|
+
// keyboard input reaches the focused element without stealing the window.
|
|
32
|
+
await cdp.send('Emulation.setFocusEmulationEnabled', { enabled: true }, sessionId)
|
|
33
|
+
const focused = await inspectFocus(cdp, sessionId)
|
|
34
|
+
if (focused.kind === 'none') {
|
|
35
|
+
return {
|
|
36
|
+
status: 'refused',
|
|
37
|
+
reason: `no editable field is focused on ${target.url}${focused.field === undefined ? '' : ` (focused: ${focused.field})`}; click or focus the field first`,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await pressCommand(cdp, sessionId, 'selectAll')
|
|
42
|
+
try {
|
|
43
|
+
await cdp.send('Input.insertText', { text: options.value }, sessionId)
|
|
44
|
+
if (!options.submit) return { status: 'filled', url: target.url, field: focused.field }
|
|
45
|
+
|
|
46
|
+
await cdp.send('Page.enable', {}, sessionId)
|
|
47
|
+
const navigated = cdp.waitForEvent(
|
|
48
|
+
'Page.frameNavigated',
|
|
49
|
+
sessionId,
|
|
50
|
+
(params) => (params as { frame?: { parentId?: string } }).frame?.parentId === undefined,
|
|
51
|
+
options.navigationTimeoutMs ?? DEFAULT_NAVIGATION_TIMEOUT_MS,
|
|
52
|
+
)
|
|
53
|
+
await submitField(cdp, sessionId, focused.objectId)
|
|
54
|
+
if (await navigated) return { status: 'submitted', url: target.url, field: focused.field }
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// The value may already be in the field; a failed step must not leave it there.
|
|
57
|
+
if (focused.objectId !== undefined) await clearField(cdp, sessionId, focused.objectId)
|
|
58
|
+
throw error
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// The page stayed put (wrong value, inline error, SPA): don't leave the
|
|
62
|
+
// secret sitting in the DOM for a later snapshot or script to read back.
|
|
63
|
+
const cleared = focused.objectId !== undefined && (await clearField(cdp, sessionId, focused.objectId))
|
|
64
|
+
return { status: 'not-navigated', url: target.url, field: focused.field, cleared }
|
|
65
|
+
} finally {
|
|
66
|
+
cdp.close()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type TargetInfo = { targetId: string; type: string; url: string }
|
|
71
|
+
|
|
72
|
+
async function pickTarget(
|
|
73
|
+
cdp: CdpConnection,
|
|
74
|
+
url: string | undefined,
|
|
75
|
+
): Promise<{ targetId: string; url: string } | { reason: string }> {
|
|
76
|
+
const { targetInfos } = (await cdp.send('Target.getTargets')) as { targetInfos: TargetInfo[] }
|
|
77
|
+
const pages = targetInfos.filter((t) => t.type === 'page' && !/^(devtools|chrome|chrome-extension):/.test(t.url))
|
|
78
|
+
const matches = url === undefined ? pages : pages.filter((t) => t.url === url || t.url.startsWith(url))
|
|
79
|
+
if (matches.length === 1) return matches[0]!
|
|
80
|
+
if (matches.length === 0) {
|
|
81
|
+
return { reason: url === undefined ? 'the shared browser has no open tab' : `no open tab matches ${url}` }
|
|
82
|
+
}
|
|
83
|
+
return { reason: `several tabs match; pass \`url\` to pick one of: ${matches.map((t) => t.url).join(', ')}` }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type FocusInfo = { kind: 'editable'; field: string; objectId?: string } | { kind: 'none'; field?: string }
|
|
87
|
+
|
|
88
|
+
// Walks shadow roots and same-origin iframes down to the real focused element.
|
|
89
|
+
// A cross-origin iframe (hosted card/key widgets) can't be inspected from the
|
|
90
|
+
// top frame, but keyboard input still lands in its focused field.
|
|
91
|
+
const FOCUS_EXPRESSION = `(() => {
|
|
92
|
+
const deepest = (el) => { while (el && el.shadowRoot && el.shadowRoot.activeElement) el = el.shadowRoot.activeElement; return el }
|
|
93
|
+
let el = deepest(document.activeElement)
|
|
94
|
+
while (el && el.tagName === 'IFRAME') {
|
|
95
|
+
let doc = null
|
|
96
|
+
try { doc = el.contentDocument } catch {}
|
|
97
|
+
if (!doc) return { kind: 'frame' }
|
|
98
|
+
el = deepest(doc.activeElement)
|
|
99
|
+
}
|
|
100
|
+
if (!el || el === el.ownerDocument.body || el === el.ownerDocument.documentElement) return { kind: 'none' }
|
|
101
|
+
const tag = el.tagName.toLowerCase()
|
|
102
|
+
if (el.isContentEditable) return { kind: 'editable', field: tag + '[contenteditable]', el }
|
|
103
|
+
const usable = !el.disabled && !el.readOnly
|
|
104
|
+
if (tag === 'textarea') return usable ? { kind: 'editable', field: 'textarea', el } : { kind: 'none', field: tag }
|
|
105
|
+
if (tag === 'input') {
|
|
106
|
+
const type = (el.getAttribute('type') || 'text').toLowerCase()
|
|
107
|
+
const textual = ['text', 'password', 'email', 'tel', 'url', 'search', 'number'].includes(type)
|
|
108
|
+
return textual && usable ? { kind: 'editable', field: 'input[type=' + type + ']', el } : { kind: 'none', field: 'input[type=' + type + ']' }
|
|
109
|
+
}
|
|
110
|
+
return { kind: 'none', field: tag }
|
|
111
|
+
})()`
|
|
112
|
+
|
|
113
|
+
async function inspectFocus(cdp: CdpConnection, sessionId: string): Promise<FocusInfo> {
|
|
114
|
+
const described = (await cdp.send(
|
|
115
|
+
'Runtime.evaluate',
|
|
116
|
+
{
|
|
117
|
+
expression: `(() => { const r = ${FOCUS_EXPRESSION}; return { kind: r.kind, field: r.field } })()`,
|
|
118
|
+
returnByValue: true,
|
|
119
|
+
},
|
|
120
|
+
sessionId,
|
|
121
|
+
)) as { result: { value?: { kind: string; field?: string } } }
|
|
122
|
+
const info = described.result.value
|
|
123
|
+
if (info?.kind === 'frame') return { kind: 'editable', field: 'cross-origin iframe' }
|
|
124
|
+
if (info?.kind !== 'editable' || info.field === undefined)
|
|
125
|
+
return { kind: 'none', ...(info?.field ? { field: info.field } : {}) }
|
|
126
|
+
// Hold a handle to the exact element so a later clear can't hit whatever
|
|
127
|
+
// happens to be focused after the page changes.
|
|
128
|
+
const handle = (await cdp.send('Runtime.evaluate', { expression: `(${FOCUS_EXPRESSION}).el` }, sessionId)) as {
|
|
129
|
+
result: { objectId?: string }
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
kind: 'editable',
|
|
133
|
+
field: info.field,
|
|
134
|
+
...(handle.result.objectId ? { objectId: handle.result.objectId } : {}),
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Frameworks such as React shadow `value` on the element itself to track the
|
|
139
|
+
// last value they saw; assigning through that shadow updates the tracker, so the
|
|
140
|
+
// input event looks like no change and the app's state keeps the secret. Writing
|
|
141
|
+
// through the prototype's native setter leaves the tracker stale, so the app sees
|
|
142
|
+
// the edit and its own state is emptied too.
|
|
143
|
+
export const CLEAR_FIELD_FUNCTION = `function () {
|
|
144
|
+
if (!this.isConnected) return true
|
|
145
|
+
if (this.isContentEditable) {
|
|
146
|
+
this.textContent = ''
|
|
147
|
+
this.dispatchEvent(new Event('input', { bubbles: true }))
|
|
148
|
+
return this.textContent === ''
|
|
149
|
+
}
|
|
150
|
+
let setter
|
|
151
|
+
for (let proto = Object.getPrototypeOf(this); proto && !setter; proto = Object.getPrototypeOf(proto)) {
|
|
152
|
+
setter = Object.getOwnPropertyDescriptor(proto, 'value')?.set
|
|
153
|
+
}
|
|
154
|
+
if (!setter) return false
|
|
155
|
+
setter.call(this, '')
|
|
156
|
+
this.dispatchEvent(new Event('input', { bubbles: true }))
|
|
157
|
+
return this.value === ''
|
|
158
|
+
}`
|
|
159
|
+
|
|
160
|
+
async function clearField(cdp: CdpConnection, sessionId: string, objectId: string): Promise<boolean> {
|
|
161
|
+
const result = (await cdp
|
|
162
|
+
.send(
|
|
163
|
+
'Runtime.callFunctionOn',
|
|
164
|
+
{
|
|
165
|
+
objectId,
|
|
166
|
+
functionDeclaration: CLEAR_FIELD_FUNCTION,
|
|
167
|
+
returnByValue: true,
|
|
168
|
+
},
|
|
169
|
+
sessionId,
|
|
170
|
+
)
|
|
171
|
+
.catch(() => ({ result: { value: false } }))) as { result: { value?: boolean } }
|
|
172
|
+
return result.result.value === true
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function pressCommand(cdp: CdpConnection, sessionId: string, command: string): Promise<void> {
|
|
176
|
+
await cdp.send('Input.dispatchKeyEvent', { type: 'rawKeyDown', commands: [command] }, sessionId)
|
|
177
|
+
await cdp.send('Input.dispatchKeyEvent', { type: 'keyUp' }, sessionId)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// A form without a submit button and with several fields ignores Enter (HTML
|
|
181
|
+
// implicit submission), so submit the owning form directly when there is one;
|
|
182
|
+
// script-driven logins with no form still get the Enter keystroke.
|
|
183
|
+
async function submitField(cdp: CdpConnection, sessionId: string, objectId: string | undefined): Promise<void> {
|
|
184
|
+
if (objectId !== undefined) {
|
|
185
|
+
const submitted = (await cdp.send(
|
|
186
|
+
'Runtime.callFunctionOn',
|
|
187
|
+
{
|
|
188
|
+
objectId,
|
|
189
|
+
functionDeclaration: `function () {
|
|
190
|
+
if (!this.form) return false
|
|
191
|
+
this.form.requestSubmit()
|
|
192
|
+
return true
|
|
193
|
+
}`,
|
|
194
|
+
returnByValue: true,
|
|
195
|
+
},
|
|
196
|
+
sessionId,
|
|
197
|
+
)) as { result: { value?: boolean } }
|
|
198
|
+
if (submitted.result.value === true) return
|
|
199
|
+
}
|
|
200
|
+
await pressEnter(cdp, sessionId)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function pressEnter(cdp: CdpConnection, sessionId: string): Promise<void> {
|
|
204
|
+
const key = { key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13, nativeVirtualKeyCode: 13 }
|
|
205
|
+
await cdp.send('Input.dispatchKeyEvent', { type: 'keyDown', text: '\r', ...key }, sessionId)
|
|
206
|
+
await cdp.send('Input.dispatchKeyEvent', { type: 'keyUp', ...key }, sessionId)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type Pending = {
|
|
210
|
+
resolve: (value: unknown) => void
|
|
211
|
+
reject: (error: Error) => void
|
|
212
|
+
timer: ReturnType<typeof setTimeout>
|
|
213
|
+
}
|
|
214
|
+
type EventListener = { method: string; sessionId: string; onEvent: (params: unknown) => void }
|
|
215
|
+
|
|
216
|
+
class CdpConnection {
|
|
217
|
+
private nextId = 1
|
|
218
|
+
private readonly pending = new Map<number, Pending>()
|
|
219
|
+
private readonly listeners = new Set<EventListener>()
|
|
220
|
+
|
|
221
|
+
private constructor(private readonly socket: WebSocket) {
|
|
222
|
+
socket.addEventListener('message', (event) => this.onMessage(String(event.data)))
|
|
223
|
+
socket.addEventListener('close', () => {
|
|
224
|
+
for (const p of this.pending.values()) {
|
|
225
|
+
clearTimeout(p.timer)
|
|
226
|
+
p.reject(new Error('browser connection closed'))
|
|
227
|
+
}
|
|
228
|
+
this.pending.clear()
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static open(url: string): Promise<CdpConnection> {
|
|
233
|
+
return new Promise((resolve, reject) => {
|
|
234
|
+
const socket = new WebSocket(url)
|
|
235
|
+
socket.addEventListener('open', () => resolve(new CdpConnection(socket)), { once: true })
|
|
236
|
+
socket.addEventListener('error', () => reject(new Error('could not connect to the shared browser')), {
|
|
237
|
+
once: true,
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
send(method: string, params: Record<string, unknown> = {}, sessionId?: string): Promise<unknown> {
|
|
243
|
+
const id = this.nextId++
|
|
244
|
+
return new Promise((resolve, reject) => {
|
|
245
|
+
const timer = setTimeout(() => {
|
|
246
|
+
this.pending.delete(id)
|
|
247
|
+
reject(new Error(`${method} timed out`))
|
|
248
|
+
}, COMMAND_TIMEOUT_MS)
|
|
249
|
+
this.pending.set(id, { resolve, reject, timer })
|
|
250
|
+
this.socket.send(JSON.stringify({ id, method, params, ...(sessionId === undefined ? {} : { sessionId }) }))
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Registered before the triggering command so a fast event can't slip past.
|
|
255
|
+
waitForEvent(
|
|
256
|
+
method: string,
|
|
257
|
+
sessionId: string,
|
|
258
|
+
predicate: (params: unknown) => boolean,
|
|
259
|
+
timeoutMs: number,
|
|
260
|
+
): Promise<boolean> {
|
|
261
|
+
return new Promise((resolve) => {
|
|
262
|
+
const listener: EventListener = {
|
|
263
|
+
method,
|
|
264
|
+
sessionId,
|
|
265
|
+
onEvent: (params) => {
|
|
266
|
+
if (!predicate(params)) return
|
|
267
|
+
finish(true)
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
const timer = setTimeout(() => finish(false), timeoutMs)
|
|
271
|
+
const finish = (value: boolean): void => {
|
|
272
|
+
clearTimeout(timer)
|
|
273
|
+
this.listeners.delete(listener)
|
|
274
|
+
resolve(value)
|
|
275
|
+
}
|
|
276
|
+
this.listeners.add(listener)
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
close(): void {
|
|
281
|
+
this.socket.close()
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private onMessage(raw: string): void {
|
|
285
|
+
const message = JSON.parse(raw) as {
|
|
286
|
+
id?: number
|
|
287
|
+
result?: unknown
|
|
288
|
+
error?: { message: string }
|
|
289
|
+
method?: string
|
|
290
|
+
params?: unknown
|
|
291
|
+
sessionId?: string
|
|
292
|
+
}
|
|
293
|
+
if (message.id !== undefined) {
|
|
294
|
+
const pending = this.pending.get(message.id)
|
|
295
|
+
if (pending === undefined) return
|
|
296
|
+
this.pending.delete(message.id)
|
|
297
|
+
clearTimeout(pending.timer)
|
|
298
|
+
if (message.error !== undefined) pending.reject(new Error(message.error.message))
|
|
299
|
+
else pending.resolve(message.result)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
for (const listener of this.listeners) {
|
|
303
|
+
if (listener.method === message.method && listener.sessionId === message.sessionId)
|
|
304
|
+
listener.onEvent(message.params)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { mkdir, realpath, rm } from 'node:fs/promises'
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
|
|
6
|
+
import { createAndOpenAnchoredDirectory } from '@/agent/tool-file-safety'
|
|
7
|
+
import { getProcBindSafetyVerdict, resolveProcSelfExe } from '@/sandbox/availability'
|
|
8
|
+
import { buildSandboxedCommand } from '@/sandbox/build'
|
|
9
|
+
import { BROWSER_PROFILE_RELATIVE_DIR } from '@/sandbox/canonical-secrets'
|
|
10
|
+
import { rejectHardlinkAliases } from '@/sandbox/hidden-paths'
|
|
11
|
+
import type { SandboxMount, SandboxProcStrategy } from '@/sandbox/policy'
|
|
12
|
+
import { shellQuote } from '@/sandbox/quote'
|
|
13
|
+
|
|
14
|
+
import { startSocksEgress } from './egress'
|
|
15
|
+
import { BSK_BIN, CHROME_LAUNCHER, type BrowserConfig, extensionDir } from './registry'
|
|
16
|
+
import { cdpWebSocketUrl, startCdpRelay, startTokenStreamRelay } from './relay'
|
|
17
|
+
import { devtoolsSocket, egressSocket, type SandboxEntryConfig } from './sandbox-entry'
|
|
18
|
+
|
|
19
|
+
// Runtime-private (container /tmp is not the model's /tmp: sandboxed bash binds
|
|
20
|
+
// a per-session directory over it), so the sockets stay out of bash. The profile
|
|
21
|
+
// lives in the agent folder so logins survive restarts; it is masked from every
|
|
22
|
+
// model tool as a runtime-owned secret dir.
|
|
23
|
+
const RUN_DIR = '/tmp/typeclaw-browser'
|
|
24
|
+
const READY_TIMEOUT_MS = 60_000
|
|
25
|
+
const READY_POLL_MS = 250
|
|
26
|
+
const RESTART_BACKOFF_MS = [1_000, 2_000, 5_000, 10_000, 30_000, 60_000] as const
|
|
27
|
+
const HEALTHY_RESET_MS = 5 * 60_000
|
|
28
|
+
|
|
29
|
+
export type ManagedBrowserLogger = { info: (m: string) => void; warn: (m: string) => void; error: (m: string) => void }
|
|
30
|
+
|
|
31
|
+
export type ManagedBrowser = {
|
|
32
|
+
cdpUrl: string
|
|
33
|
+
filesDir: string
|
|
34
|
+
// Loopback address of the token-gated BrowserSkill daemon relay.
|
|
35
|
+
bskRelay: string | undefined
|
|
36
|
+
token: string
|
|
37
|
+
stop: () => Promise<void>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Workspace-relative so roles that can see workspace/ (the same tier that holds
|
|
41
|
+
// `browser.shared` by default) can exchange uploads and downloads with Chrome.
|
|
42
|
+
export function browserFilesRoot(agentDir: string): string {
|
|
43
|
+
return join(agentDir, 'workspace', '.typeclaw-browser')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function startManagedBrowser(options: {
|
|
47
|
+
agentDir: string
|
|
48
|
+
browser: BrowserConfig
|
|
49
|
+
logger: ManagedBrowserLogger
|
|
50
|
+
}): Promise<ManagedBrowser> {
|
|
51
|
+
const { agentDir, browser, logger } = options
|
|
52
|
+
const filesDir = join(browserFilesRoot(agentDir), 'files')
|
|
53
|
+
// Runtime-private: the daemon socket has no auth of its own, so bash reaches
|
|
54
|
+
// it only through the token relay below, never by pointing BSK_HOME here.
|
|
55
|
+
const bskHome = browser.extensions.includes('browserskill') ? join(RUN_DIR, 'bsk') : undefined
|
|
56
|
+
await rm(RUN_DIR, { recursive: true, force: true })
|
|
57
|
+
await mkdir(join(RUN_DIR, 'home'), { recursive: true })
|
|
58
|
+
if (bskHome !== undefined) await mkdir(bskHome, { recursive: true, mode: 0o700 })
|
|
59
|
+
// Workspace is model-writable, so a component could be a planted symlink to
|
|
60
|
+
// the agent root. Open each component no-follow and bind the held descriptor,
|
|
61
|
+
// so Chrome gets exactly the directory validated here for the whole boot.
|
|
62
|
+
const exchange = await createAndOpenAnchoredDirectory(filesDir)
|
|
63
|
+
const profileDir = join(agentDir, BROWSER_PROFILE_RELATIVE_DIR)
|
|
64
|
+
const profile = await createAndOpenAnchoredDirectory(profileDir)
|
|
65
|
+
// Bash skips the bounded per-call alias scan for the profile (see
|
|
66
|
+
// isCanonicalSecretDir), so refuse a pre-existing alias here, before Chrome writes.
|
|
67
|
+
await rejectHardlinkAliases(profileDir).catch(async (error: unknown) => {
|
|
68
|
+
await profile.close()
|
|
69
|
+
throw error
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const egress = await startSocksEgress(egressSocket(RUN_DIR))
|
|
73
|
+
const entry: SandboxEntryConfig = {
|
|
74
|
+
chrome: CHROME_LAUNCHER,
|
|
75
|
+
runDir: RUN_DIR,
|
|
76
|
+
profileDir,
|
|
77
|
+
downloadsDir: filesDir,
|
|
78
|
+
extensionDirs: browser.extensions.map((id) => extensionDir(id)),
|
|
79
|
+
headless: process.env['DISPLAY'] === undefined,
|
|
80
|
+
...(bskHome === undefined ? {} : { bsk: { home: bskHome } }),
|
|
81
|
+
}
|
|
82
|
+
const launch = await buildLaunch(entry, filesDir, profileDir)
|
|
83
|
+
const token = randomBytes(32).toString('hex')
|
|
84
|
+
const relay = await startCdpRelay({ token, upstreamSocket: devtoolsSocket(RUN_DIR) })
|
|
85
|
+
const bskRelay =
|
|
86
|
+
bskHome === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: await startTokenStreamRelay({
|
|
89
|
+
token,
|
|
90
|
+
upstreamSocket: join(bskHome, 'run', 'daemon.sock'),
|
|
91
|
+
describe: () => Bun.file(join(bskHome, 'daemon.json')).text(),
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
let stopped = false
|
|
95
|
+
let child: ReturnType<typeof Bun.spawn> | undefined
|
|
96
|
+
const supervise = async (): Promise<void> => {
|
|
97
|
+
let attempt = 0
|
|
98
|
+
while (!stopped) {
|
|
99
|
+
const startedAt = Date.now()
|
|
100
|
+
child = Bun.spawn(launch.argv, { env: launch.env, stdio: ['ignore', 'ignore', 'pipe', exchange.fd, profile.fd] })
|
|
101
|
+
void waitUntilReady(devtoolsSocket(RUN_DIR)).then(
|
|
102
|
+
() => {
|
|
103
|
+
logger.info(`managed browser ready (engines: ${browser.engines.join(', ') || 'none'})`)
|
|
104
|
+
if (bskHome !== undefined) void reportBrowserSkill(bskHome, logger)
|
|
105
|
+
},
|
|
106
|
+
(error: unknown) => logger.warn(`managed browser not ready: ${String(error)}`),
|
|
107
|
+
)
|
|
108
|
+
const code = await child.exited
|
|
109
|
+
if (stopped) return
|
|
110
|
+
const stderr = await new Response(child.stderr as ReadableStream).text().catch(() => '')
|
|
111
|
+
if (Date.now() - startedAt > HEALTHY_RESET_MS) attempt = 0
|
|
112
|
+
const delay = RESTART_BACKOFF_MS[Math.min(attempt, RESTART_BACKOFF_MS.length - 1)]!
|
|
113
|
+
attempt += 1
|
|
114
|
+
logger.warn(
|
|
115
|
+
`managed browser exited with code ${code}; restarting in ${delay / 1000}s` +
|
|
116
|
+
(stderr.trim() === '' ? '' : `: ${stderr.trim().split('\n').slice(-3).join(' | ')}`),
|
|
117
|
+
)
|
|
118
|
+
await Bun.sleep(delay)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
void supervise()
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
cdpUrl: cdpWebSocketUrl(relay.port, token),
|
|
125
|
+
filesDir,
|
|
126
|
+
bskRelay: bskRelay === undefined ? undefined : `127.0.0.1:${bskRelay.port}`,
|
|
127
|
+
token,
|
|
128
|
+
stop: async () => {
|
|
129
|
+
stopped = true
|
|
130
|
+
child?.kill()
|
|
131
|
+
await Promise.allSettled([relay.close(), egress.close(), bskRelay?.close(), exchange.close(), profile.close()])
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function buildLaunch(
|
|
137
|
+
entry: SandboxEntryConfig,
|
|
138
|
+
filesDir: string,
|
|
139
|
+
profileDir: string,
|
|
140
|
+
): Promise<{ argv: string[]; env: Record<string, string> }> {
|
|
141
|
+
const entryFile = await realpath(join(import.meta.dir, 'sandbox-entry.ts'))
|
|
142
|
+
const mounts: SandboxMount[] = [
|
|
143
|
+
{ type: 'bind', source: RUN_DIR, dest: RUN_DIR },
|
|
144
|
+
// fd 3 is the anchored exchange directory passed in the spawn's stdio.
|
|
145
|
+
{ type: 'bind-fd', fd: 3, dest: filesDir },
|
|
146
|
+
{ type: 'bind-fd', fd: 4, dest: profileDir },
|
|
147
|
+
{ type: 'ro-bind', source: dirname(entryFile), dest: dirname(entryFile) },
|
|
148
|
+
]
|
|
149
|
+
if (existsSync('/tmp/.X11-unix')) mounts.push({ type: 'ro-bind', source: '/tmp/.X11-unix', dest: '/tmp/.X11-unix' })
|
|
150
|
+
const proc: SandboxProcStrategy = (await getProcBindSafetyVerdict()) === 'safe' ? 'proc-bind' : 'tmpfs'
|
|
151
|
+
const display = process.env['DISPLAY']
|
|
152
|
+
const { argv, spawnEnv } = buildSandboxedCommand(
|
|
153
|
+
`exec bun ${shellQuote(entryFile)} ${shellQuote(JSON.stringify(entry))}`,
|
|
154
|
+
{
|
|
155
|
+
network: 'none',
|
|
156
|
+
proc,
|
|
157
|
+
procSelfExe: resolveProcSelfExe(),
|
|
158
|
+
mounts,
|
|
159
|
+
cwd: RUN_DIR,
|
|
160
|
+
env: { set: { HOME: join(RUN_DIR, 'home'), ...(display === undefined ? {} : { DISPLAY: display }) } },
|
|
161
|
+
},
|
|
162
|
+
)
|
|
163
|
+
return { argv, env: spawnEnv }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function waitUntilReady(socket: string): Promise<void> {
|
|
167
|
+
const deadline = Date.now() + READY_TIMEOUT_MS
|
|
168
|
+
let lastError: unknown
|
|
169
|
+
while (Date.now() < deadline) {
|
|
170
|
+
try {
|
|
171
|
+
const response = await fetch('http://127.0.0.1/json/version', { unix: socket } as RequestInit)
|
|
172
|
+
if (response.ok) return
|
|
173
|
+
lastError = new Error(`DevTools answered ${response.status}`)
|
|
174
|
+
} catch (error) {
|
|
175
|
+
lastError = error
|
|
176
|
+
}
|
|
177
|
+
await Bun.sleep(READY_POLL_MS)
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`DevTools did not answer within ${READY_TIMEOUT_MS / 1000}s (${String(lastError)})`)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Operator-log only: a disconnected extension degrades one tool, so it never
|
|
183
|
+
// becomes a channel message.
|
|
184
|
+
async function reportBrowserSkill(bskHome: string, logger: ManagedBrowserLogger): Promise<void> {
|
|
185
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
186
|
+
const status = Bun.spawn([BSK_BIN, 'status', '--json'], {
|
|
187
|
+
env: { PATH: process.env['PATH'] ?? '/usr/local/bin:/usr/bin:/bin', BSK_HOME: bskHome, BSK_AUTO_START: '0' },
|
|
188
|
+
stdout: 'pipe',
|
|
189
|
+
stderr: 'ignore',
|
|
190
|
+
})
|
|
191
|
+
const out = await new Response(status.stdout).text()
|
|
192
|
+
await status.exited
|
|
193
|
+
try {
|
|
194
|
+
const parsed = JSON.parse(out) as { browsers?: unknown[] }
|
|
195
|
+
if ((parsed.browsers?.length ?? 0) > 0) {
|
|
196
|
+
logger.info('BrowserSkill extension connected')
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
} catch {
|
|
200
|
+
// daemon not answering yet; retry below
|
|
201
|
+
}
|
|
202
|
+
await Bun.sleep(1_000)
|
|
203
|
+
}
|
|
204
|
+
logger.warn('BrowserSkill extension did not connect to its daemon; bsk commands will fail until it does')
|
|
205
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Browser engines and extensions that `typeclaw.json#browser` can enable.
|
|
2
|
+
//
|
|
3
|
+
// An engine is a driver the model runs from bash (a CLI or a library). Every
|
|
4
|
+
// engine except the legacy agent-browser default attaches to the one
|
|
5
|
+
// TypeClaw-managed Chrome over CDP, so tabs and logins persist across bash
|
|
6
|
+
// calls and every engine sees the same extensions. An extension is loaded into
|
|
7
|
+
// that managed Chrome once, so every engine benefits from it.
|
|
8
|
+
|
|
9
|
+
export const BROWSER_ENGINE_IDS = ['agent-browser', 'omowright', 'browser-use'] as const
|
|
10
|
+
export type BrowserEngineId = (typeof BROWSER_ENGINE_IDS)[number]
|
|
11
|
+
|
|
12
|
+
export const BROWSER_EXTENSION_IDS = ['browserskill'] as const
|
|
13
|
+
export type BrowserExtensionId = (typeof BROWSER_EXTENSION_IDS)[number]
|
|
14
|
+
|
|
15
|
+
export type BrowserEngineInstall =
|
|
16
|
+
// Already in every image: agent-browser installs the Chrome every engine shares.
|
|
17
|
+
| { kind: 'image' }
|
|
18
|
+
| { kind: 'bun-global'; spec: string }
|
|
19
|
+
| { kind: 'uv-tool'; package: string; version: string; python: string }
|
|
20
|
+
|
|
21
|
+
export type BrowserEngineSpec = {
|
|
22
|
+
id: BrowserEngineId
|
|
23
|
+
install: BrowserEngineInstall
|
|
24
|
+
// Env for sandboxed bash when the managed browser is running, keyed off its
|
|
25
|
+
// CDP URL. Also carries phone-home opt-outs.
|
|
26
|
+
env: (cdpUrl: string) => Record<string, string>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type BrowserExtensionSpec = {
|
|
30
|
+
id: BrowserExtensionId
|
|
31
|
+
version: string
|
|
32
|
+
zip: { url: string; sha256: string }
|
|
33
|
+
cli: { name: string; urlByArch: Record<'amd64' | 'arm64', { url: string; sha256: string }> }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const BROWSER_ROOT = '/usr/local/lib/typeclaw-browser'
|
|
37
|
+
|
|
38
|
+
// Installed by the base image for agent-browser; the launcher adds --no-sandbox
|
|
39
|
+
// because Chrome's own sandbox cannot run inside bwrap.
|
|
40
|
+
export const CHROME_LAUNCHER = '/usr/local/lib/typeclaw-agent-browser/chrome'
|
|
41
|
+
|
|
42
|
+
export const BSK_BIN = `${BROWSER_ROOT}/bsk/bsk`
|
|
43
|
+
export const BSK_SHIM = `${BROWSER_ROOT}/bsk/shim.mjs`
|
|
44
|
+
// BrowserSkill's extension dials its daemon here, inside the browser sandbox.
|
|
45
|
+
export const BSK_DAEMON_PORT = 52800
|
|
46
|
+
|
|
47
|
+
export const OMOWRIGHT_MODULE = `${BROWSER_ROOT}/omowright/index.js`
|
|
48
|
+
|
|
49
|
+
const OMOWRIGHT_COMMIT = 'a3f0c2b54fc41804beca7eb6ab26ee54804742a9'
|
|
50
|
+
const BROWSER_USE_VERSION = '0.13.11'
|
|
51
|
+
const BSK_VERSION = '0.3.3'
|
|
52
|
+
const BSK_RELEASES = 'https://github.com/Tencent/BrowserSkill/releases/download'
|
|
53
|
+
|
|
54
|
+
export const BROWSER_ENGINES: Record<BrowserEngineId, BrowserEngineSpec> = {
|
|
55
|
+
'agent-browser': {
|
|
56
|
+
id: 'agent-browser',
|
|
57
|
+
install: { kind: 'image' },
|
|
58
|
+
env: (cdpUrl) => ({ AGENT_BROWSER_CDP: cdpUrl }),
|
|
59
|
+
},
|
|
60
|
+
omowright: {
|
|
61
|
+
id: 'omowright',
|
|
62
|
+
install: { kind: 'bun-global', spec: `github:code-yeongyu/omowright#${OMOWRIGHT_COMMIT}` },
|
|
63
|
+
env: (cdpUrl) => ({ OMOWRIGHT_CDP_URL: cdpUrl }),
|
|
64
|
+
},
|
|
65
|
+
'browser-use': {
|
|
66
|
+
id: 'browser-use',
|
|
67
|
+
install: { kind: 'uv-tool', package: 'browser-use', version: BROWSER_USE_VERSION, python: '3.12' },
|
|
68
|
+
env: (cdpUrl) => ({ BU_CDP_WS: cdpUrl, ANONYMIZED_TELEMETRY: 'false' }),
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const BROWSER_EXTENSIONS: Record<BrowserExtensionId, BrowserExtensionSpec> = {
|
|
73
|
+
browserskill: {
|
|
74
|
+
id: 'browserskill',
|
|
75
|
+
version: BSK_VERSION,
|
|
76
|
+
zip: {
|
|
77
|
+
url: `${BSK_RELEASES}/ext-v${BSK_VERSION}/browser-skill-extension-v${BSK_VERSION}-chrome.zip`,
|
|
78
|
+
sha256: '10ef76e68f352893fa22dd4cce2f1b96cb90ed957b815d656e13180d07d3c6ea',
|
|
79
|
+
},
|
|
80
|
+
cli: {
|
|
81
|
+
name: 'bsk',
|
|
82
|
+
urlByArch: {
|
|
83
|
+
amd64: {
|
|
84
|
+
url: `${BSK_RELEASES}/cli-v${BSK_VERSION}/bsk-v${BSK_VERSION}-x86_64-unknown-linux-musl.tar.gz`,
|
|
85
|
+
sha256: '141b73489bec99d768cf18042919f0e054c9f614e6ecdfd754028d2b606e9106',
|
|
86
|
+
},
|
|
87
|
+
arm64: {
|
|
88
|
+
url: `${BSK_RELEASES}/cli-v${BSK_VERSION}/bsk-v${BSK_VERSION}-aarch64-unknown-linux-musl.tar.gz`,
|
|
89
|
+
sha256: '747e4c416da46650c7d8127a47dd8f08e813e0f69366c4db1af226d0b63a575d',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type BrowserConfig = {
|
|
97
|
+
engines: readonly BrowserEngineId[]
|
|
98
|
+
extensions: readonly BrowserExtensionId[]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// The managed Chrome exists only for engines that attach over CDP or for
|
|
102
|
+
// extensions. The default `["agent-browser"]` keeps today's per-session
|
|
103
|
+
// agent-browser browser, so existing agents see no change.
|
|
104
|
+
export function needsManagedBrowser(config: BrowserConfig): boolean {
|
|
105
|
+
return config.extensions.length > 0 || config.engines.some((id) => id !== 'agent-browser')
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function extensionDir(id: BrowserExtensionId): string {
|
|
109
|
+
return `${BROWSER_ROOT}/extensions/${id}`
|
|
110
|
+
}
|