@cleocode/core 2026.6.12 → 2026.6.13
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/conduit/local-transport.d.ts +12 -0
- package/dist/conduit/local-transport.d.ts.map +1 -1
- package/dist/conduit/local-transport.js +53 -23
- package/dist/conduit/local-transport.js.map +1 -1
- package/dist/crypto/credentials.d.ts +37 -0
- package/dist/crypto/credentials.d.ts.map +1 -1
- package/dist/crypto/credentials.js +110 -0
- package/dist/crypto/credentials.js.map +1 -1
- package/dist/dispatch/contracts/derive-output-contract.d.ts +86 -0
- package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -0
- package/dist/dispatch/contracts/derive-output-contract.js +347 -0
- package/dist/dispatch/contracts/derive-output-contract.js.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts +77 -0
- package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -0
- package/dist/dispatch/contracts/ensures-schema.js +91 -0
- package/dist/dispatch/contracts/ensures-schema.js.map +1 -0
- package/dist/dispatch/contracts/output-contracts.d.ts +27 -5
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/output-contracts.js +29 -6
- package/dist/dispatch/contracts/output-contracts.js.map +1 -1
- package/dist/docs/export-document.js +2294 -1250
- package/dist/docs/export-document.js.map +3 -3
- package/dist/go/driver.d.ts +132 -7
- package/dist/go/driver.d.ts.map +1 -1
- package/dist/go/driver.js +135 -10
- package/dist/go/driver.js.map +1 -1
- package/dist/go/index.d.ts +1 -1
- package/dist/go/index.d.ts.map +1 -1
- package/dist/go/index.js +1 -1
- package/dist/go/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -10
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +11 -11
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/engine-ops.d.ts.map +1 -1
- package/dist/lifecycle/engine-ops.js +7 -4
- package/dist/lifecycle/engine-ops.js.map +1 -1
- package/dist/lifecycle/ivtr-loop.d.ts +108 -183
- package/dist/lifecycle/ivtr-loop.d.ts.map +1 -1
- package/dist/lifecycle/ivtr-loop.js +207 -522
- package/dist/lifecycle/ivtr-loop.js.map +1 -1
- package/dist/llm/auxiliary-fallback.js +1 -1
- package/dist/llm/auxiliary-fallback.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +14 -1
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +41 -12
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/concrete-session.d.ts.map +1 -1
- package/dist/llm/concrete-session.js +4 -0
- package/dist/llm/concrete-session.js.map +1 -1
- package/dist/llm/credentials.d.ts +35 -0
- package/dist/llm/credentials.d.ts.map +1 -1
- package/dist/llm/credentials.js +49 -0
- package/dist/llm/credentials.js.map +1 -1
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/pi/gondolin-loader.d.ts +241 -0
- package/dist/llm/pi/gondolin-loader.d.ts.map +1 -0
- package/dist/llm/pi/gondolin-loader.js +195 -0
- package/dist/llm/pi/gondolin-loader.js.map +1 -0
- package/dist/llm/pi/index.d.ts +28 -0
- package/dist/llm/pi/index.d.ts.map +1 -0
- package/dist/llm/pi/index.js +27 -0
- package/dist/llm/pi/index.js.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts +135 -0
- package/dist/llm/pi/pi-agent-adapter.d.ts.map +1 -0
- package/dist/llm/pi/pi-agent-adapter.js +329 -0
- package/dist/llm/pi/pi-agent-adapter.js.map +1 -0
- package/dist/llm/pi/pi-errors.d.ts +161 -0
- package/dist/llm/pi/pi-errors.d.ts.map +1 -0
- package/dist/llm/pi/pi-errors.js +296 -0
- package/dist/llm/pi/pi-errors.js.map +1 -0
- package/dist/llm/pi/pi-execution-env.d.ts +286 -0
- package/dist/llm/pi/pi-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-execution-env.js +406 -0
- package/dist/llm/pi/pi-execution-env.js.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts +227 -0
- package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -0
- package/dist/llm/pi/pi-gondolin-env.js +541 -0
- package/dist/llm/pi/pi-gondolin-env.js.map +1 -0
- package/dist/llm/pi/pi-session-storage.d.ts +154 -0
- package/dist/llm/pi/pi-session-storage.d.ts.map +1 -0
- package/dist/llm/pi/pi-session-storage.js +314 -0
- package/dist/llm/pi/pi-session-storage.js.map +1 -0
- package/dist/llm/pi/pi-stream-fn.d.ts +124 -0
- package/dist/llm/pi/pi-stream-fn.d.ts.map +1 -0
- package/dist/llm/pi/pi-stream-fn.js +504 -0
- package/dist/llm/pi/pi-stream-fn.js.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts +99 -0
- package/dist/llm/pi/pi-tool-bridge.d.ts.map +1 -0
- package/dist/llm/pi/pi-tool-bridge.js +117 -0
- package/dist/llm/pi/pi-tool-bridge.js.map +1 -0
- package/dist/llm/pi/pi-types.d.ts +56 -0
- package/dist/llm/pi/pi-types.d.ts.map +1 -0
- package/dist/llm/pi/pi-types.js +16 -0
- package/dist/llm/pi/pi-types.js.map +1 -0
- package/dist/llm/pi/resolve-execution-env.d.ts +194 -0
- package/dist/llm/pi/resolve-execution-env.d.ts.map +1 -0
- package/dist/llm/pi/resolve-execution-env.js +132 -0
- package/dist/llm/pi/resolve-execution-env.js.map +1 -0
- package/dist/llm/plugin-facade.js +2253 -1151
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/role-executor.d.ts.map +1 -1
- package/dist/llm/role-executor.js +8 -5
- package/dist/llm/role-executor.js.map +1 -1
- package/dist/llm/role-resolver.d.ts +46 -14
- package/dist/llm/role-resolver.d.ts.map +1 -1
- package/dist/llm/role-resolver.js +178 -20
- package/dist/llm/role-resolver.js.map +1 -1
- package/dist/llm/sealed-credential.d.ts +125 -0
- package/dist/llm/sealed-credential.d.ts.map +1 -0
- package/dist/llm/sealed-credential.js +133 -0
- package/dist/llm/sealed-credential.js.map +1 -0
- package/dist/llm/session-factory.d.ts.map +1 -1
- package/dist/llm/session-factory.js +6 -2
- package/dist/llm/session-factory.js.map +1 -1
- package/dist/llm/system-key.d.ts +67 -0
- package/dist/llm/system-key.d.ts.map +1 -0
- package/dist/llm/system-key.js +87 -0
- package/dist/llm/system-key.js.map +1 -0
- package/dist/llm/system-of-use-registry.d.ts +119 -0
- package/dist/llm/system-of-use-registry.d.ts.map +1 -0
- package/dist/llm/system-of-use-registry.js +200 -0
- package/dist/llm/system-of-use-registry.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +32 -10
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +70 -18
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +116 -11
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.js +21 -0
- package/dist/memory/claude-mem-migration.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +32 -25
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/llm-backend-resolver.js +23 -5
- package/dist/memory/llm-backend-resolver.js.map +1 -1
- package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
- package/dist/nexus/migrations/M-split-graph.js +60 -53
- package/dist/nexus/migrations/M-split-graph.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +20 -2
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/release/engine-ops.js +2 -2
- package/dist/release/engine-ops.js.map +1 -1
- package/dist/routing/capability-matrix.d.ts.map +1 -1
- package/dist/routing/capability-matrix.js +0 -57
- package/dist/routing/capability-matrix.js.map +1 -1
- package/dist/selfimprove/budget.d.ts +206 -0
- package/dist/selfimprove/budget.d.ts.map +1 -0
- package/dist/selfimprove/budget.js +203 -0
- package/dist/selfimprove/budget.js.map +1 -0
- package/dist/selfimprove/dhq-adapter.d.ts +105 -0
- package/dist/selfimprove/dhq-adapter.d.ts.map +1 -0
- package/dist/selfimprove/dhq-adapter.js +95 -0
- package/dist/selfimprove/dhq-adapter.js.map +1 -0
- package/dist/selfimprove/draft-pr.d.ts +129 -0
- package/dist/selfimprove/draft-pr.d.ts.map +1 -0
- package/dist/selfimprove/draft-pr.js +158 -0
- package/dist/selfimprove/draft-pr.js.map +1 -0
- package/dist/selfimprove/envelope-diff.d.ts +162 -0
- package/dist/selfimprove/envelope-diff.d.ts.map +1 -0
- package/dist/selfimprove/envelope-diff.js +321 -0
- package/dist/selfimprove/envelope-diff.js.map +1 -0
- package/dist/selfimprove/replay.d.ts +121 -0
- package/dist/selfimprove/replay.d.ts.map +1 -0
- package/dist/selfimprove/replay.js +109 -0
- package/dist/selfimprove/replay.js.map +1 -0
- package/dist/selfimprove/run-loop.d.ts +148 -0
- package/dist/selfimprove/run-loop.d.ts.map +1 -0
- package/dist/selfimprove/run-loop.js +240 -0
- package/dist/selfimprove/run-loop.js.map +1 -0
- package/dist/selfimprove/scenario.d.ts +145 -0
- package/dist/selfimprove/scenario.d.ts.map +1 -0
- package/dist/selfimprove/scenario.js +243 -0
- package/dist/selfimprove/scenario.js.map +1 -0
- package/dist/sentient/daemon-entry.js +5 -0
- package/dist/sentient/daemon-entry.js.map +1 -1
- package/dist/sentient/daemon.d.ts.map +1 -1
- package/dist/sentient/daemon.js +19 -0
- package/dist/sentient/daemon.js.map +1 -1
- package/dist/sentient/hygiene-scan.d.ts.map +1 -1
- package/dist/sentient/hygiene-scan.js +14 -6
- package/dist/sentient/hygiene-scan.js.map +1 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +13 -9
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/connection-session-handle.d.ts +161 -0
- package/dist/sessions/connection-session-handle.d.ts.map +1 -0
- package/dist/sessions/connection-session-handle.js +168 -0
- package/dist/sessions/connection-session-handle.js.map +1 -0
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +9 -0
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/sessions/index.d.ts +4 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +31 -1
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-id.d.ts +34 -0
- package/dist/sessions/session-id.d.ts.map +1 -1
- package/dist/sessions/session-id.js +37 -0
- package/dist/sessions/session-id.js.map +1 -1
- package/dist/sessions/session-manifest-mirror.d.ts +115 -0
- package/dist/sessions/session-manifest-mirror.d.ts.map +1 -0
- package/dist/sessions/session-manifest-mirror.js +250 -0
- package/dist/sessions/session-manifest-mirror.js.map +1 -0
- package/dist/sessions/session-switch.d.ts.map +1 -1
- package/dist/sessions/session-switch.js +5 -2
- package/dist/sessions/session-switch.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +2 -0
- package/dist/store/converters.js.map +1 -1
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +2 -0
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +87 -47
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/pi-session-store.d.ts +151 -0
- package/dist/store/pi-session-store.d.ts.map +1 -0
- package/dist/store/pi-session-store.js +166 -0
- package/dist/store/pi-session-store.js.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +1 -0
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +5 -0
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/cleo-global/accounts.d.ts +357 -0
- package/dist/store/schema/cleo-global/accounts.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/accounts.js +136 -0
- package/dist/store/schema/cleo-global/accounts.js.map +1 -0
- package/dist/store/schema/cleo-global/index.d.ts +2 -0
- package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/index.js +2 -0
- package/dist/store/schema/cleo-global/index.js.map +1 -1
- package/dist/store/schema/cleo-global/session-manifest.d.ts +217 -0
- package/dist/store/schema/cleo-global/session-manifest.d.ts.map +1 -0
- package/dist/store/schema/cleo-global/session-manifest.js +99 -0
- package/dist/store/schema/cleo-global/session-manifest.js.map +1 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts +16 -0
- package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
- package/dist/store/schema/cleo-project/tasks-core.js +14 -0
- package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
- package/dist/store/schema/tasks.d.ts +16 -0
- package/dist/store/schema/tasks.d.ts.map +1 -1
- package/dist/store/schema/tasks.js +10 -0
- package/dist/store/schema/tasks.js.map +1 -1
- package/dist/store/selfimprove-dhq-schema.d.ts +284 -0
- package/dist/store/selfimprove-dhq-schema.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-schema.js +128 -0
- package/dist/store/selfimprove-dhq-schema.js.map +1 -0
- package/dist/store/selfimprove-dhq-store.d.ts +175 -0
- package/dist/store/selfimprove-dhq-store.d.ts.map +1 -0
- package/dist/store/selfimprove-dhq-store.js +182 -0
- package/dist/store/selfimprove-dhq-store.js.map +1 -0
- package/dist/store/session-store.d.ts +52 -13
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +71 -13
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +7 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/umbrella-data-accessor.d.ts +1 -0
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +5 -0
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +32 -0
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/store/writer-lease-schema.d.ts +392 -0
- package/dist/store/writer-lease-schema.d.ts.map +1 -0
- package/dist/store/writer-lease-schema.js +142 -0
- package/dist/store/writer-lease-schema.js.map +1 -0
- package/dist/store/writer-lease.d.ts +368 -0
- package/dist/store/writer-lease.d.ts.map +1 -0
- package/dist/store/writer-lease.js +1002 -0
- package/dist/store/writer-lease.js.map +1 -0
- package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
- package/dist/tasks/backfill-child-projections.js +14 -9
- package/dist/tasks/backfill-child-projections.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +7 -10
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +14 -7
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +10 -4
- package/dist/telemetry/index.js.map +1 -1
- package/dist/tools/agent-registry.d.ts +250 -0
- package/dist/tools/agent-registry.d.ts.map +1 -0
- package/dist/tools/agent-registry.js +292 -0
- package/dist/tools/agent-registry.js.map +1 -0
- package/dist/tools/agent-tool-families.d.ts +107 -0
- package/dist/tools/agent-tool-families.d.ts.map +1 -0
- package/dist/tools/agent-tool-families.js +527 -0
- package/dist/tools/agent-tool-families.js.map +1 -0
- package/dist/tools/browser-driver.d.ts +183 -0
- package/dist/tools/browser-driver.d.ts.map +1 -0
- package/dist/tools/browser-driver.js +242 -0
- package/dist/tools/browser-driver.js.map +1 -0
- package/dist/tools/builtin-agent-tools.d.ts +36 -0
- package/dist/tools/builtin-agent-tools.d.ts.map +1 -0
- package/dist/tools/builtin-agent-tools.js +150 -0
- package/dist/tools/builtin-agent-tools.js.map +1 -0
- package/dist/tools/dispatch.d.ts +370 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +505 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/env-scrub.d.ts +93 -0
- package/dist/tools/env-scrub.d.ts.map +1 -0
- package/dist/tools/env-scrub.js +176 -0
- package/dist/tools/env-scrub.js.map +1 -0
- package/dist/tools/fs.d.ts +30 -0
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +55 -2
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/guard.d.ts +15 -0
- package/dist/tools/guard.d.ts.map +1 -1
- package/dist/tools/guard.js +49 -12
- package/dist/tools/guard.js.map +1 -1
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +37 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pty.d.ts +45 -0
- package/dist/tools/pty.d.ts.map +1 -0
- package/dist/tools/pty.js +166 -0
- package/dist/tools/pty.js.map +1 -0
- package/dist/tools/schema-gen.d.ts +57 -0
- package/dist/tools/schema-gen.d.ts.map +1 -0
- package/dist/tools/schema-gen.js +52 -0
- package/dist/tools/schema-gen.js.map +1 -0
- package/dist/tools/shell.d.ts +12 -0
- package/dist/tools/shell.d.ts.map +1 -1
- package/dist/tools/shell.js +14 -1
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/web-agent-tools.d.ts +72 -0
- package/dist/tools/web-agent-tools.d.ts.map +1 -0
- package/dist/tools/web-agent-tools.js +393 -0
- package/dist/tools/web-agent-tools.js.map +1 -0
- package/dist/tools/web-search-backends.d.ts +156 -0
- package/dist/tools/web-search-backends.d.ts.map +1 -0
- package/dist/tools/web-search-backends.js +290 -0
- package/dist/tools/web-search-backends.js.map +1 -0
- package/dist/validation/ops.d.ts +1 -15
- package/dist/validation/ops.d.ts.map +1 -1
- package/dist/validation/ops.js +0 -20
- package/dist/validation/ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-global/20260607010000_t11639-session-manifest/migration.sql +43 -0
- package/migrations/drizzle-cleo-global/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-global/20260608010000_t11709-accounts-credential-pool/migration.sql +72 -0
- package/migrations/drizzle-cleo-global/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/migrations/drizzle-cleo-project/20260607000000_t11891-writer-leases/migration.sql +55 -0
- package/migrations/drizzle-cleo-project/20260607010000_t11639-session-parent/migration.sql +22 -0
- package/migrations/drizzle-cleo-project/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
- package/migrations/drizzle-cleo-project/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
- package/package.json +15 -13
- package/dist/lifecycle/chain-composition.d.ts +0 -30
- package/dist/lifecycle/chain-composition.d.ts.map +0 -1
- package/dist/lifecycle/chain-composition.js +0 -152
- package/dist/lifecycle/chain-composition.js.map +0 -1
- package/dist/lifecycle/chain-store.d.ts +0 -70
- package/dist/lifecycle/chain-store.d.ts.map +0 -1
- package/dist/lifecycle/chain-store.js +0 -246
- package/dist/lifecycle/chain-store.js.map +0 -1
- package/dist/lifecycle/default-chain.d.ts +0 -39
- package/dist/lifecycle/default-chain.d.ts.map +0 -1
- package/dist/lifecycle/default-chain.js +0 -176
- package/dist/lifecycle/default-chain.js.map +0 -1
- package/dist/lifecycle/tessera-engine.d.ts +0 -48
- package/dist/lifecycle/tessera-engine.d.ts.map +0 -1
- package/dist/lifecycle/tessera-engine.js +0 -249
- package/dist/lifecycle/tessera-engine.js.map +0 -1
- package/dist/validation/chain-validation.d.ts +0 -43
- package/dist/validation/chain-validation.d.ts.map +0 -1
- package/dist/validation/chain-validation.js +0 -146
- package/dist/validation/chain-validation.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright browser driver — the OPTIONAL, lazily-loaded automation backend
|
|
3
|
+
* (T1742 · epic T11456 · SG-TOOLS).
|
|
4
|
+
*
|
|
5
|
+
* The `browser_*` tools' execution backend. Playwright is an OPTIONAL dependency
|
|
6
|
+
* (publish-surface discipline · D11136): it is NEVER a hard dependency of
|
|
7
|
+
* `@cleocode/core`. Like `node-pty` (see {@link ./pty.js}), it is deliberately
|
|
8
|
+
* NOT declared in `core`'s `dependencies` / `optionalDependencies` and is loaded
|
|
9
|
+
* ONLY via a dynamic `import()` whose specifier is held in a variable — so
|
|
10
|
+
* neither the bundler nor TS treats the missing package as a hard,
|
|
11
|
+
* statically-resolved dependency, the published `@cleocode/core` carries no
|
|
12
|
+
* Playwright weight, and `core` builds + tests pass with Playwright NOT installed.
|
|
13
|
+
* An environment that wants the browser tools opts in by installing `playwright`
|
|
14
|
+
* itself (`pnpm add playwright && pnpm exec playwright install chromium`).
|
|
15
|
+
*
|
|
16
|
+
* Import-time side-effect-free: NO top-level `playwright` import; the browser is
|
|
17
|
+
* launched lazily on the first navigation through a {@link BrowserSession}. When
|
|
18
|
+
* Playwright is absent, {@link isPlaywrightAvailable} resolves `false` and the
|
|
19
|
+
* browser tools' availability predicate hides them with an install hint —
|
|
20
|
+
* nothing throws at import.
|
|
21
|
+
*
|
|
22
|
+
* @epic T11456
|
|
23
|
+
* @task T1742
|
|
24
|
+
* @see ./pty.js — the analogous optional-native-dep (node-pty) lazy-load pattern
|
|
25
|
+
*/
|
|
26
|
+
import type { AccessibilityNode, BrowserNavigateInput, BrowserPageState } from '@cleocode/contracts/tools/web-tools';
|
|
27
|
+
/**
|
|
28
|
+
* The npm install hint surfaced to the model when a browser tool is unavailable
|
|
29
|
+
* because Playwright is not installed. Playwright is an OPTIONAL dep — the
|
|
30
|
+
* browser tools are registered regardless, but report unavailable until this
|
|
31
|
+
* runs (AC8).
|
|
32
|
+
*/
|
|
33
|
+
export declare const PLAYWRIGHT_INSTALL_HINT: string;
|
|
34
|
+
/** A keyboard handle (`page.keyboard`). */
|
|
35
|
+
interface PwKeyboard {
|
|
36
|
+
press(key: string): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** A located element handle (`page.locator(...)`). */
|
|
39
|
+
interface PwLocator {
|
|
40
|
+
click(options?: {
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
fill(value: string, options?: {
|
|
44
|
+
timeout?: number;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
focus(options?: {
|
|
47
|
+
timeout?: number;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/** The accessibility snapshot surface (`page.accessibility`). */
|
|
51
|
+
interface PwAccessibility {
|
|
52
|
+
snapshot(): Promise<AccessibilityNode | null>;
|
|
53
|
+
}
|
|
54
|
+
/** A Playwright `Page`. */
|
|
55
|
+
interface PwPage {
|
|
56
|
+
goto(url: string, options?: {
|
|
57
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
58
|
+
timeout?: number;
|
|
59
|
+
}): Promise<unknown>;
|
|
60
|
+
url(): string;
|
|
61
|
+
title(): Promise<string>;
|
|
62
|
+
locator(selector: string): PwLocator;
|
|
63
|
+
readonly keyboard: PwKeyboard;
|
|
64
|
+
readonly accessibility: PwAccessibility;
|
|
65
|
+
screenshot(options?: {
|
|
66
|
+
fullPage?: boolean;
|
|
67
|
+
}): Promise<Buffer | Uint8Array>;
|
|
68
|
+
evaluate<T>(fn: string): Promise<T>;
|
|
69
|
+
}
|
|
70
|
+
/** A Playwright `Browser`. */
|
|
71
|
+
interface PwBrowser {
|
|
72
|
+
newPage(): Promise<PwPage>;
|
|
73
|
+
close(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/** The `chromium` browser-type launcher. */
|
|
76
|
+
interface PwBrowserType {
|
|
77
|
+
launch(options?: {
|
|
78
|
+
headless?: boolean;
|
|
79
|
+
}): Promise<PwBrowser>;
|
|
80
|
+
}
|
|
81
|
+
/** The minimal shape of the `playwright` module we depend on. */
|
|
82
|
+
interface PlaywrightModule {
|
|
83
|
+
readonly chromium: PwBrowserType;
|
|
84
|
+
}
|
|
85
|
+
export declare function isPlaywrightAvailable(): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Reset the cached Playwright-availability probe.
|
|
88
|
+
*
|
|
89
|
+
* EXPORTED FOR TESTS ONLY — lets a unit test toggle the mocked availability of
|
|
90
|
+
* the optional dep between cases without a fresh module graph.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
export declare function __resetPlaywrightAvailabilityCache(): void;
|
|
95
|
+
/**
|
|
96
|
+
* The injectable factory the {@link BrowserSession} uses to obtain a Playwright
|
|
97
|
+
* module. Defaults to the real lazy {@link loadPlaywright}; unit tests inject a
|
|
98
|
+
* fake so NO real browser is ever launched (AC9).
|
|
99
|
+
*/
|
|
100
|
+
export type PlaywrightLoader = () => Promise<PlaywrightModule | null>;
|
|
101
|
+
/**
|
|
102
|
+
* A single browser session: lazily launches a headless Chromium on the first
|
|
103
|
+
* navigation, then reuses the same page for subsequent interactions. Holds no
|
|
104
|
+
* Playwright reference until {@link BrowserSession.navigate} is first called, so
|
|
105
|
+
* constructing one is free and import-time side-effect-free.
|
|
106
|
+
*
|
|
107
|
+
* The browser tools share ONE session per registry run (created by the browser
|
|
108
|
+
* tool family at registration). All Playwright access funnels through here so
|
|
109
|
+
* the lazy-load + teardown live in one place.
|
|
110
|
+
*/
|
|
111
|
+
export declare class BrowserSession {
|
|
112
|
+
#private;
|
|
113
|
+
/**
|
|
114
|
+
* @param load - Optional Playwright loader (defaults to the real lazy import).
|
|
115
|
+
* Tests pass a fake that returns a mock module — no real browser launches.
|
|
116
|
+
*/
|
|
117
|
+
constructor(load?: PlaywrightLoader);
|
|
118
|
+
/**
|
|
119
|
+
* Navigate to a URL (launching the browser on first call).
|
|
120
|
+
*
|
|
121
|
+
* @param input - {@link BrowserNavigateInput}.
|
|
122
|
+
* @returns The page state after navigation.
|
|
123
|
+
*/
|
|
124
|
+
navigate(input: BrowserNavigateInput): Promise<BrowserPageState>;
|
|
125
|
+
/**
|
|
126
|
+
* Click the element matching `selector`.
|
|
127
|
+
*
|
|
128
|
+
* @param selector - CSS / Playwright selector.
|
|
129
|
+
* @param timeoutMs - Per-action timeout.
|
|
130
|
+
* @returns The page state after the click.
|
|
131
|
+
*/
|
|
132
|
+
click(selector: string, timeoutMs?: number): Promise<BrowserPageState>;
|
|
133
|
+
/**
|
|
134
|
+
* Type `text` into the element matching `selector`.
|
|
135
|
+
*
|
|
136
|
+
* @param selector - CSS / Playwright selector.
|
|
137
|
+
* @param text - Text to enter (`fill` replaces the field's content).
|
|
138
|
+
* @param timeoutMs - Per-action timeout.
|
|
139
|
+
* @returns The page state after typing.
|
|
140
|
+
*/
|
|
141
|
+
type(selector: string, text: string, timeoutMs?: number): Promise<BrowserPageState>;
|
|
142
|
+
/**
|
|
143
|
+
* Press a key / chord, optionally focusing `selector` first.
|
|
144
|
+
*
|
|
145
|
+
* @param key - Playwright key syntax (e.g. `Enter`, `Control+A`).
|
|
146
|
+
* @param selector - Optional element to focus before pressing.
|
|
147
|
+
* @param timeoutMs - Per-action timeout (for the focus step).
|
|
148
|
+
* @returns The page state after the keypress.
|
|
149
|
+
*/
|
|
150
|
+
press(key: string, selector?: string, timeoutMs?: number): Promise<BrowserPageState>;
|
|
151
|
+
/**
|
|
152
|
+
* Capture the page's accessibility tree.
|
|
153
|
+
*
|
|
154
|
+
* @returns The page state plus the accessibility tree root (or `null`).
|
|
155
|
+
*/
|
|
156
|
+
snapshot(): Promise<BrowserPageState & {
|
|
157
|
+
tree: AccessibilityNode | null;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Scroll the page vertically by `amountPx` in `direction` and report the new
|
|
161
|
+
* scroll offset.
|
|
162
|
+
*
|
|
163
|
+
* @param direction - `up` or `down`.
|
|
164
|
+
* @param amountPx - Pixels to scroll (defaults to ~one viewport).
|
|
165
|
+
* @returns The page state plus the post-scroll `scrollY`.
|
|
166
|
+
*/
|
|
167
|
+
scroll(direction: 'up' | 'down', amountPx?: number): Promise<BrowserPageState & {
|
|
168
|
+
scrollY: number;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* Capture a screenshot of the current page as base64-encoded PNG bytes.
|
|
172
|
+
*
|
|
173
|
+
* @param fullPage - Capture the full scrollable page when `true`.
|
|
174
|
+
* @returns The page state plus the base64 PNG and the page state.
|
|
175
|
+
*/
|
|
176
|
+
screenshot(fullPage?: boolean): Promise<BrowserPageState & {
|
|
177
|
+
base64Png: string;
|
|
178
|
+
}>;
|
|
179
|
+
/** Close the browser and release the page (idempotent). */
|
|
180
|
+
close(): Promise<void>;
|
|
181
|
+
}
|
|
182
|
+
export {};
|
|
183
|
+
//# sourceMappingURL=browser-driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-driver.d.ts","sourceRoot":"","sources":["../../src/tools/browser-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,qCAAqC,CAAC;AAK7C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAE2C,CAAC;AAWhF,2CAA2C;AAC3C,UAAU,UAAU;IAClB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED,sDAAsD;AACtD,UAAU,SAAS;IACjB,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,O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;IAOrF,2DAA2D;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAW7B"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright browser driver — the OPTIONAL, lazily-loaded automation backend
|
|
3
|
+
* (T1742 · epic T11456 · SG-TOOLS).
|
|
4
|
+
*
|
|
5
|
+
* The `browser_*` tools' execution backend. Playwright is an OPTIONAL dependency
|
|
6
|
+
* (publish-surface discipline · D11136): it is NEVER a hard dependency of
|
|
7
|
+
* `@cleocode/core`. Like `node-pty` (see {@link ./pty.js}), it is deliberately
|
|
8
|
+
* NOT declared in `core`'s `dependencies` / `optionalDependencies` and is loaded
|
|
9
|
+
* ONLY via a dynamic `import()` whose specifier is held in a variable — so
|
|
10
|
+
* neither the bundler nor TS treats the missing package as a hard,
|
|
11
|
+
* statically-resolved dependency, the published `@cleocode/core` carries no
|
|
12
|
+
* Playwright weight, and `core` builds + tests pass with Playwright NOT installed.
|
|
13
|
+
* An environment that wants the browser tools opts in by installing `playwright`
|
|
14
|
+
* itself (`pnpm add playwright && pnpm exec playwright install chromium`).
|
|
15
|
+
*
|
|
16
|
+
* Import-time side-effect-free: NO top-level `playwright` import; the browser is
|
|
17
|
+
* launched lazily on the first navigation through a {@link BrowserSession}. When
|
|
18
|
+
* Playwright is absent, {@link isPlaywrightAvailable} resolves `false` and the
|
|
19
|
+
* browser tools' availability predicate hides them with an install hint —
|
|
20
|
+
* nothing throws at import.
|
|
21
|
+
*
|
|
22
|
+
* @epic T11456
|
|
23
|
+
* @task T1742
|
|
24
|
+
* @see ./pty.js — the analogous optional-native-dep (node-pty) lazy-load pattern
|
|
25
|
+
*/
|
|
26
|
+
import { getLogger } from '../logger.js';
|
|
27
|
+
const log = getLogger('tool-browser');
|
|
28
|
+
/**
|
|
29
|
+
* The npm install hint surfaced to the model when a browser tool is unavailable
|
|
30
|
+
* because Playwright is not installed. Playwright is an OPTIONAL dep — the
|
|
31
|
+
* browser tools are registered regardless, but report unavailable until this
|
|
32
|
+
* runs (AC8).
|
|
33
|
+
*/
|
|
34
|
+
export const PLAYWRIGHT_INSTALL_HINT = 'Browser tools require the optional "playwright" package. Install it with ' +
|
|
35
|
+
'`pnpm add playwright && pnpm exec playwright install chromium`, then retry.';
|
|
36
|
+
/**
|
|
37
|
+
* Attempt to lazily load `playwright`. Returns `null` when the optional dep is
|
|
38
|
+
* not installed or fails to load (any reason), so callers can report the browser
|
|
39
|
+
* tools as unavailable rather than crashing.
|
|
40
|
+
*
|
|
41
|
+
* The import specifier is held in a variable so bundlers / TS do not treat the
|
|
42
|
+
* missing optional dep as a hard, statically-resolved dependency (same technique
|
|
43
|
+
* as {@link ./pty.js}'s `node-pty` load).
|
|
44
|
+
*
|
|
45
|
+
* @returns The loaded module shape, or `null` when unavailable.
|
|
46
|
+
*/
|
|
47
|
+
async function loadPlaywright() {
|
|
48
|
+
const specifier = 'playwright';
|
|
49
|
+
try {
|
|
50
|
+
const mod = await import(specifier);
|
|
51
|
+
const candidate = mod.default ?? mod;
|
|
52
|
+
if (candidate !== null &&
|
|
53
|
+
typeof candidate === 'object' &&
|
|
54
|
+
typeof candidate.chromium === 'object') {
|
|
55
|
+
return candidate;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
log.debug({ err }, 'playwright not loadable — browser tools unavailable');
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether the optional `playwright` package can be loaded in this process.
|
|
66
|
+
*
|
|
67
|
+
* Used by the browser tools' {@link import('./agent-registry.js').AvailabilityCheck}
|
|
68
|
+
* (via the registry's `capabilities` flag) so they are hidden — with
|
|
69
|
+
* {@link PLAYWRIGHT_INSTALL_HINT} — when Playwright is absent (AC8). The result is
|
|
70
|
+
* cached after the first probe so availability checks stay cheap.
|
|
71
|
+
*
|
|
72
|
+
* @returns `true` when `playwright` is importable, else `false`.
|
|
73
|
+
*/
|
|
74
|
+
let cachedAvailable;
|
|
75
|
+
export async function isPlaywrightAvailable() {
|
|
76
|
+
if (cachedAvailable !== undefined)
|
|
77
|
+
return cachedAvailable;
|
|
78
|
+
cachedAvailable = (await loadPlaywright()) !== null;
|
|
79
|
+
return cachedAvailable;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Reset the cached Playwright-availability probe.
|
|
83
|
+
*
|
|
84
|
+
* EXPORTED FOR TESTS ONLY — lets a unit test toggle the mocked availability of
|
|
85
|
+
* the optional dep between cases without a fresh module graph.
|
|
86
|
+
*
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
export function __resetPlaywrightAvailabilityCache() {
|
|
90
|
+
cachedAvailable = undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A single browser session: lazily launches a headless Chromium on the first
|
|
94
|
+
* navigation, then reuses the same page for subsequent interactions. Holds no
|
|
95
|
+
* Playwright reference until {@link BrowserSession.navigate} is first called, so
|
|
96
|
+
* constructing one is free and import-time side-effect-free.
|
|
97
|
+
*
|
|
98
|
+
* The browser tools share ONE session per registry run (created by the browser
|
|
99
|
+
* tool family at registration). All Playwright access funnels through here so
|
|
100
|
+
* the lazy-load + teardown live in one place.
|
|
101
|
+
*/
|
|
102
|
+
export class BrowserSession {
|
|
103
|
+
#browser = null;
|
|
104
|
+
#page = null;
|
|
105
|
+
#load;
|
|
106
|
+
/**
|
|
107
|
+
* @param load - Optional Playwright loader (defaults to the real lazy import).
|
|
108
|
+
* Tests pass a fake that returns a mock module — no real browser launches.
|
|
109
|
+
*/
|
|
110
|
+
constructor(load = loadPlaywright) {
|
|
111
|
+
this.#load = load;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Ensure a page exists, launching the browser on first use. Throws a typed
|
|
115
|
+
* error when Playwright is unavailable so the tool executable can surface the
|
|
116
|
+
* install hint (the tool's `available()` predicate normally hides it first).
|
|
117
|
+
*
|
|
118
|
+
* @returns The active page.
|
|
119
|
+
*/
|
|
120
|
+
async #ensurePage() {
|
|
121
|
+
if (this.#page !== null)
|
|
122
|
+
return this.#page;
|
|
123
|
+
const pw = await this.#load();
|
|
124
|
+
if (pw === null) {
|
|
125
|
+
throw new Error(`E_BROWSER_UNAVAILABLE: ${PLAYWRIGHT_INSTALL_HINT}`);
|
|
126
|
+
}
|
|
127
|
+
this.#browser = await pw.chromium.launch({ headless: true });
|
|
128
|
+
this.#page = await this.#browser.newPage();
|
|
129
|
+
return this.#page;
|
|
130
|
+
}
|
|
131
|
+
/** The current page state (url + title). */
|
|
132
|
+
async #state(page) {
|
|
133
|
+
return { url: page.url(), title: await page.title() };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Navigate to a URL (launching the browser on first call).
|
|
137
|
+
*
|
|
138
|
+
* @param input - {@link BrowserNavigateInput}.
|
|
139
|
+
* @returns The page state after navigation.
|
|
140
|
+
*/
|
|
141
|
+
async navigate(input) {
|
|
142
|
+
const page = await this.#ensurePage();
|
|
143
|
+
await page.goto(input.url, {
|
|
144
|
+
waitUntil: input.waitUntil ?? 'load',
|
|
145
|
+
timeout: input.timeoutMs ?? 30000,
|
|
146
|
+
});
|
|
147
|
+
return this.#state(page);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Click the element matching `selector`.
|
|
151
|
+
*
|
|
152
|
+
* @param selector - CSS / Playwright selector.
|
|
153
|
+
* @param timeoutMs - Per-action timeout.
|
|
154
|
+
* @returns The page state after the click.
|
|
155
|
+
*/
|
|
156
|
+
async click(selector, timeoutMs = 15000) {
|
|
157
|
+
const page = await this.#ensurePage();
|
|
158
|
+
await page.locator(selector).click({ timeout: timeoutMs });
|
|
159
|
+
return this.#state(page);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Type `text` into the element matching `selector`.
|
|
163
|
+
*
|
|
164
|
+
* @param selector - CSS / Playwright selector.
|
|
165
|
+
* @param text - Text to enter (`fill` replaces the field's content).
|
|
166
|
+
* @param timeoutMs - Per-action timeout.
|
|
167
|
+
* @returns The page state after typing.
|
|
168
|
+
*/
|
|
169
|
+
async type(selector, text, timeoutMs = 15000) {
|
|
170
|
+
const page = await this.#ensurePage();
|
|
171
|
+
await page.locator(selector).fill(text, { timeout: timeoutMs });
|
|
172
|
+
return this.#state(page);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Press a key / chord, optionally focusing `selector` first.
|
|
176
|
+
*
|
|
177
|
+
* @param key - Playwright key syntax (e.g. `Enter`, `Control+A`).
|
|
178
|
+
* @param selector - Optional element to focus before pressing.
|
|
179
|
+
* @param timeoutMs - Per-action timeout (for the focus step).
|
|
180
|
+
* @returns The page state after the keypress.
|
|
181
|
+
*/
|
|
182
|
+
async press(key, selector, timeoutMs = 15000) {
|
|
183
|
+
const page = await this.#ensurePage();
|
|
184
|
+
if (selector !== undefined) {
|
|
185
|
+
await page.locator(selector).focus({ timeout: timeoutMs });
|
|
186
|
+
}
|
|
187
|
+
await page.keyboard.press(key);
|
|
188
|
+
return this.#state(page);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Capture the page's accessibility tree.
|
|
192
|
+
*
|
|
193
|
+
* @returns The page state plus the accessibility tree root (or `null`).
|
|
194
|
+
*/
|
|
195
|
+
async snapshot() {
|
|
196
|
+
const page = await this.#ensurePage();
|
|
197
|
+
const tree = await page.accessibility.snapshot();
|
|
198
|
+
return { ...(await this.#state(page)), tree };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Scroll the page vertically by `amountPx` in `direction` and report the new
|
|
202
|
+
* scroll offset.
|
|
203
|
+
*
|
|
204
|
+
* @param direction - `up` or `down`.
|
|
205
|
+
* @param amountPx - Pixels to scroll (defaults to ~one viewport).
|
|
206
|
+
* @returns The page state plus the post-scroll `scrollY`.
|
|
207
|
+
*/
|
|
208
|
+
async scroll(direction, amountPx = 800) {
|
|
209
|
+
const page = await this.#ensurePage();
|
|
210
|
+
const delta = direction === 'down' ? amountPx : -amountPx;
|
|
211
|
+
// `evaluate(string)` so this file never imports playwright's function-arg
|
|
212
|
+
// serialization types; the page runs the scroll + returns the new offset.
|
|
213
|
+
const scrollY = await page.evaluate(`(() => { window.scrollBy(0, ${delta}); return window.scrollY; })()`);
|
|
214
|
+
return { ...(await this.#state(page)), scrollY };
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Capture a screenshot of the current page as base64-encoded PNG bytes.
|
|
218
|
+
*
|
|
219
|
+
* @param fullPage - Capture the full scrollable page when `true`.
|
|
220
|
+
* @returns The page state plus the base64 PNG and the page state.
|
|
221
|
+
*/
|
|
222
|
+
async screenshot(fullPage = false) {
|
|
223
|
+
const page = await this.#ensurePage();
|
|
224
|
+
const buf = await page.screenshot({ fullPage });
|
|
225
|
+
const base64Png = Buffer.from(buf).toString('base64');
|
|
226
|
+
return { ...(await this.#state(page)), base64Png };
|
|
227
|
+
}
|
|
228
|
+
/** Close the browser and release the page (idempotent). */
|
|
229
|
+
async close() {
|
|
230
|
+
if (this.#browser !== null) {
|
|
231
|
+
try {
|
|
232
|
+
await this.#browser.close();
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
log.debug({ err }, 'browser close failed (ignored)');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
this.#browser = null;
|
|
239
|
+
this.#page = null;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=browser-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-driver.js","sourceRoot":"","sources":["../../src/tools/browser-driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,GAAG,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,G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ACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in agent tools (T1739 · epic T11456 · SG-TOOLS).
|
|
3
|
+
*
|
|
4
|
+
* Wires the existing CORE-SDK atomic primitives ({@link ./fs.js} +
|
|
5
|
+
* {@link ./shell.js}) into the agent-facing {@link ./agent-registry.js |
|
|
6
|
+
* AgentToolRegistry} as its FIRST registered tools, so the registry is never
|
|
7
|
+
* empty and the Pi adapter / ModelRunner can consume them immediately. Every
|
|
8
|
+
* built-in tool:
|
|
9
|
+
*
|
|
10
|
+
* - declares a Zod parameter schema (→ OpenAI-format schema via AC3);
|
|
11
|
+
* - declares its agent-facing {@link Toolset} group (AC4) and side-effect
|
|
12
|
+
* {@link ToolClass};
|
|
13
|
+
* - declares an {@link AvailabilityCheck} (AC5) — e.g. `run_git` is only
|
|
14
|
+
* available when a `git` binary is known to be on PATH;
|
|
15
|
+
* - performs ALL side effects through the injected {@link GuardedToolSurface}
|
|
16
|
+
* (NEVER raw `fs`/`shell`), so the deny-first guard chokepoint
|
|
17
|
+
* ({@link ./guard.js}) policy still applies — there is no bypass.
|
|
18
|
+
*
|
|
19
|
+
* The model-visible names are snake_case (OpenAI-function convention); the
|
|
20
|
+
* underlying primitive names live in `@cleocode/contracts/tools/atomic`.
|
|
21
|
+
*
|
|
22
|
+
* @task T1739
|
|
23
|
+
* @epic T11456
|
|
24
|
+
*/
|
|
25
|
+
import type { AgentToolRegistry } from './agent-registry.js';
|
|
26
|
+
/**
|
|
27
|
+
* Register the built-in atomic-primitive tools into `registry`.
|
|
28
|
+
*
|
|
29
|
+
* Invoked by {@link AgentToolRegistry.init} (unless `skipBuiltins`). Pure
|
|
30
|
+
* registration — no I/O, no scan; the tools' side effects happen later through
|
|
31
|
+
* the {@link GuardedToolSurface} their executables receive.
|
|
32
|
+
*
|
|
33
|
+
* @param registry - The registry to populate.
|
|
34
|
+
*/
|
|
35
|
+
export declare function registerBuiltinAgentTools(registry: AgentToolRegistry): void;
|
|
36
|
+
//# sourceMappingURL=builtin-agent-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-agent-tools.d.ts","sourceRoot":"","sources":["../../src/tools/builtin-agent-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAUhF;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAkH3E"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in agent tools (T1739 · epic T11456 · SG-TOOLS).
|
|
3
|
+
*
|
|
4
|
+
* Wires the existing CORE-SDK atomic primitives ({@link ./fs.js} +
|
|
5
|
+
* {@link ./shell.js}) into the agent-facing {@link ./agent-registry.js |
|
|
6
|
+
* AgentToolRegistry} as its FIRST registered tools, so the registry is never
|
|
7
|
+
* empty and the Pi adapter / ModelRunner can consume them immediately. Every
|
|
8
|
+
* built-in tool:
|
|
9
|
+
*
|
|
10
|
+
* - declares a Zod parameter schema (→ OpenAI-format schema via AC3);
|
|
11
|
+
* - declares its agent-facing {@link Toolset} group (AC4) and side-effect
|
|
12
|
+
* {@link ToolClass};
|
|
13
|
+
* - declares an {@link AvailabilityCheck} (AC5) — e.g. `run_git` is only
|
|
14
|
+
* available when a `git` binary is known to be on PATH;
|
|
15
|
+
* - performs ALL side effects through the injected {@link GuardedToolSurface}
|
|
16
|
+
* (NEVER raw `fs`/`shell`), so the deny-first guard chokepoint
|
|
17
|
+
* ({@link ./guard.js}) policy still applies — there is no bypass.
|
|
18
|
+
*
|
|
19
|
+
* The model-visible names are snake_case (OpenAI-function convention); the
|
|
20
|
+
* underlying primitive names live in `@cleocode/contracts/tools/atomic`.
|
|
21
|
+
*
|
|
22
|
+
* @task T1739
|
|
23
|
+
* @epic T11456
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
import { ALWAYS_AVAILABLE } from './agent-registry.js';
|
|
27
|
+
import { registerAgentToolFamilies } from './agent-tool-families.js';
|
|
28
|
+
import { registerWebAgentTools } from './web-agent-tools.js';
|
|
29
|
+
/** Available only when the named binary is known on PATH (AC5 example). */
|
|
30
|
+
function binaryAvailable(name) {
|
|
31
|
+
return (ctx) => ctx.availableBinaries === undefined || ctx.availableBinaries.includes(name);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register the built-in atomic-primitive tools into `registry`.
|
|
35
|
+
*
|
|
36
|
+
* Invoked by {@link AgentToolRegistry.init} (unless `skipBuiltins`). Pure
|
|
37
|
+
* registration — no I/O, no scan; the tools' side effects happen later through
|
|
38
|
+
* the {@link GuardedToolSurface} their executables receive.
|
|
39
|
+
*
|
|
40
|
+
* @param registry - The registry to populate.
|
|
41
|
+
*/
|
|
42
|
+
export function registerBuiltinAgentTools(registry) {
|
|
43
|
+
// --- file toolset (fs class) ---------------------------------------------
|
|
44
|
+
registry.register({
|
|
45
|
+
name: 'read_file',
|
|
46
|
+
class: 'fs',
|
|
47
|
+
description: 'Read a file as UTF-8 text.',
|
|
48
|
+
toolset: 'file',
|
|
49
|
+
stateless: true,
|
|
50
|
+
available: ALWAYS_AVAILABLE,
|
|
51
|
+
parameters: z.object({
|
|
52
|
+
path: z.string().describe('Absolute path to the file to read.'),
|
|
53
|
+
}),
|
|
54
|
+
execute: async (args, tools) => {
|
|
55
|
+
const path = String(args.path);
|
|
56
|
+
return tools.readFileText({ path });
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
registry.register({
|
|
60
|
+
name: 'write_file',
|
|
61
|
+
class: 'fs',
|
|
62
|
+
description: 'Atomically write a file (tmp-then-rename), creating parent dirs.',
|
|
63
|
+
toolset: 'file',
|
|
64
|
+
stateless: true,
|
|
65
|
+
available: ALWAYS_AVAILABLE,
|
|
66
|
+
parameters: z.object({
|
|
67
|
+
path: z.string().describe('Absolute path to write.'),
|
|
68
|
+
content: z.string().describe('File content to write.'),
|
|
69
|
+
}),
|
|
70
|
+
execute: async (args, tools) => {
|
|
71
|
+
const path = String(args.path);
|
|
72
|
+
const content = String(args.content);
|
|
73
|
+
return tools.writeFileAtomic({ path, content });
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
registry.register({
|
|
77
|
+
name: 'path_exists',
|
|
78
|
+
class: 'fs',
|
|
79
|
+
description: 'Test whether a path exists and what kind of entry it is.',
|
|
80
|
+
toolset: 'file',
|
|
81
|
+
stateless: true,
|
|
82
|
+
available: ALWAYS_AVAILABLE,
|
|
83
|
+
parameters: z.object({
|
|
84
|
+
path: z.string().describe('Absolute path to test.'),
|
|
85
|
+
}),
|
|
86
|
+
execute: async (args, tools) => {
|
|
87
|
+
const path = String(args.path);
|
|
88
|
+
return tools.pathExists({ path });
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
// --- terminal toolset (shell class) --------------------------------------
|
|
92
|
+
registry.register({
|
|
93
|
+
name: 'run_command',
|
|
94
|
+
class: 'shell',
|
|
95
|
+
description: 'Run a single executable (argv form, no shell) with cwd/timeout.',
|
|
96
|
+
toolset: 'terminal',
|
|
97
|
+
stateless: true,
|
|
98
|
+
available: ALWAYS_AVAILABLE,
|
|
99
|
+
parameters: z.object({
|
|
100
|
+
command: z.string().describe('Executable to run (NOT a shell string).'),
|
|
101
|
+
args: z.array(z.string()).optional().describe('Arguments for the command.'),
|
|
102
|
+
cwd: z.string().optional().describe('Working directory.'),
|
|
103
|
+
timeoutMs: z.number().int().positive().optional().describe('Hard timeout in ms.'),
|
|
104
|
+
}),
|
|
105
|
+
execute: async (args, tools) => {
|
|
106
|
+
const command = String(args.command);
|
|
107
|
+
const argv = Array.isArray(args.args) ? args.args.map(String) : undefined;
|
|
108
|
+
const cwd = args.cwd === undefined ? undefined : String(args.cwd);
|
|
109
|
+
const timeoutMs = typeof args.timeoutMs === 'number' ? args.timeoutMs : undefined;
|
|
110
|
+
return tools.executeShell({ command, args: argv, cwd, timeoutMs });
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
registry.register({
|
|
114
|
+
name: 'run_git',
|
|
115
|
+
class: 'shell',
|
|
116
|
+
description: 'Run a git subcommand and capture stdout/stderr/exit-code.',
|
|
117
|
+
toolset: 'terminal',
|
|
118
|
+
stateless: true,
|
|
119
|
+
available: binaryAvailable('git'),
|
|
120
|
+
parameters: z.object({
|
|
121
|
+
args: z.array(z.string()).describe("Git arguments, e.g. ['status', '--porcelain']."),
|
|
122
|
+
cwd: z.string().optional().describe('Repository working directory.'),
|
|
123
|
+
timeoutMs: z.number().int().positive().optional().describe('Hard timeout in ms.'),
|
|
124
|
+
}),
|
|
125
|
+
execute: async (args, tools) => {
|
|
126
|
+
const gitArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
127
|
+
const cwd = args.cwd === undefined ? undefined : String(args.cwd);
|
|
128
|
+
const timeoutMs = typeof args.timeoutMs === 'number' ? args.timeoutMs : undefined;
|
|
129
|
+
return tools.runGit({ args: gitArgs, cwd, timeoutMs });
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
// Note: the `media` (notebook) primitives are NOT yet implemented in
|
|
133
|
+
// `core/src/tools/*` (only their contracts exist in atomic.ts). That toolset is
|
|
134
|
+
// intentionally empty until a later stage ships its primitives; the registry
|
|
135
|
+
// already supports it (AC4) so registration is a one-liner then.
|
|
136
|
+
// The richer agent-facing tool families (T1741): terminal `run_shell` (PTY +
|
|
137
|
+
// spawn), paginated `read_file_paged`, atomic `write_file_atomic`, fuzzy
|
|
138
|
+
// `apply_patch`, ripgrep `search_files`, and the git family
|
|
139
|
+
// (status/diff/log/commit). All route through the same guarded surface.
|
|
140
|
+
registerAgentToolFamilies(registry);
|
|
141
|
+
// The web + browser family (T1742): `web` toolset — `web_search` (pluggable,
|
|
142
|
+
// keyless backends), `web_extract` (HTML→markdown), and the Playwright-driven
|
|
143
|
+
// `browser_*` tools. Playwright is an OPTIONAL, lazily-loaded dependency: the
|
|
144
|
+
// browser tools register but their availability predicate hides them (with an
|
|
145
|
+
// install hint) until a context advertises the playwright capability, so core
|
|
146
|
+
// builds + runs with playwright NOT installed. The web tools' network egress +
|
|
147
|
+
// the `browser_vision` AI call (via resolveLLMForSystem) use no raw bypass.
|
|
148
|
+
registerWebAgentTools(registry);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=builtin-agent-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-agent-tools.js","sourceRoot":"","sources":["../../src/tools/builtin-agent-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,2EAA2E;AAC3E,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,iBAAiB,KAAK,SAAS,IAAI,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAA2B;IACnE,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC;QAChB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,4BAA4B;QACzC,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,gBAAgB;QAC3B,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;SAChE,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