@bastani/atomic 0.10.9 → 0.10.10-alpha.2
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/CHANGELOG.md +83 -0
- package/README.md +226 -163
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +27 -12
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
- package/dist/_shared/sdk-RRLVN7ER.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js +4 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
- package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
- package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
- package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +150 -62
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
- package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
- package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
- package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
- package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
- package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +87 -116
- package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
- package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
- package/dist/builtin/intercom/group.ts +7 -3
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/README.md +61 -27
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/README.md +74 -141
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/README.md +61 -88
- package/dist/builtin/web-access/index.bundle.mjs +387 -351
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +2 -2
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +2 -2
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/compaction/compactor.d.ts +20 -14
- package/dist/core/compaction/errors.d.ts +120 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/model-resolver.d.ts +2 -2
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.code.js +1 -1
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/api-types.d.ts +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/provider-types.d.ts +18 -6
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.js +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-config.d.ts +40 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-resolver-scope.d.ts +4 -4
- package/dist/core/model-runtime.d.ts +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/provider-composer-internal.d.ts +11 -2
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +2 -2
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.code.js +1 -1
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +2 -2
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +2 -2
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -7
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/theme/color-utils.d.ts +5 -5
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
- package/dist/modes/rpc/rpc-types.d.ts +29 -2
- package/dist/package-manager-cli.code.js +5 -5
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -2
- package/dist/startup-stages/9.js +2 -1
- package/dist/utils/native-module.d.ts +44 -0
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/background-tasks.md +238 -243
- package/docs/build.md +21 -15
- package/docs/changelog.mdx +1 -1
- package/docs/codemode.md +68 -51
- package/docs/compaction/reference.md +65 -26
- package/docs/compaction.md +118 -66
- package/docs/computer-use.md +179 -146
- package/docs/containerization.md +87 -33
- package/docs/custom-provider/api-reference.md +152 -13
- package/docs/custom-provider/oauth.md +45 -28
- package/docs/custom-provider/override.md +14 -7
- package/docs/custom-provider/registration.md +77 -67
- package/docs/custom-provider/streaming.md +42 -19
- package/docs/custom-provider.md +26 -62
- package/docs/development.md +81 -42
- package/docs/docs.json +54 -38
- package/docs/environment-variables.md +92 -64
- package/docs/extensions/api-reference.md +326 -735
- package/docs/extensions/authoring.md +186 -269
- package/docs/extensions/events.md +308 -375
- package/docs/extensions/examples.md +122 -74
- package/docs/extensions/ui.md +217 -197
- package/docs/extensions.md +189 -259
- package/docs/getting-started/authentication.md +27 -14
- package/docs/getting-started/first-session.md +25 -26
- package/docs/getting-started/installation.md +62 -84
- package/docs/getting-started/project-instructions.md +39 -14
- package/docs/guides/configuration.md +62 -20
- package/docs/guides/intercom.md +20 -12
- package/docs/guides/non-interactive.md +31 -16
- package/docs/guides/orchestration.md +17 -9
- package/docs/guides/resume-on-any-machine.md +63 -52
- package/docs/guides/subagents.md +26 -14
- package/docs/guides/team-setup.md +49 -27
- package/docs/guides.md +30 -23
- package/docs/herdr.md +22 -17
- package/docs/index.md +24 -17
- package/docs/intercom/operations.md +90 -66
- package/docs/intercom/reference.md +219 -192
- package/docs/intercom.md +111 -92
- package/docs/json.md +73 -71
- package/docs/keybindings.md +74 -48
- package/docs/libraries/agent-core.md +52 -9
- package/docs/libraries/ai.md +90 -63
- package/docs/libraries/codemode.md +31 -8
- package/docs/libraries/schema.md +12 -9
- package/docs/libraries/storage-libsql.md +92 -0
- package/docs/libraries/storage-postgres.md +119 -0
- package/docs/libraries/telemetry.md +42 -9
- package/docs/libraries/tui.md +74 -94
- package/docs/libraries.md +25 -8
- package/docs/llama-cpp.md +38 -33
- package/docs/mcp-servers.md +140 -88
- package/docs/models/reference.md +53 -36
- package/docs/models-configuration.md +19 -13
- package/docs/models.md +102 -87
- package/docs/orchestration/migrating-workflows.md +22 -20
- package/docs/orchestration/patterns.md +36 -21
- package/docs/orchestration.md +24 -21
- package/docs/packages/authoring.md +29 -18
- package/docs/packages/reference.md +77 -16
- package/docs/packages.md +34 -34
- package/docs/programmatic.md +28 -21
- package/docs/prompt-templates.md +65 -41
- package/docs/providers/reference.md +36 -20
- package/docs/providers.md +78 -76
- package/docs/quickstart.md +42 -54
- package/docs/reference/cli.md +256 -254
- package/docs/reference.md +30 -23
- package/docs/rpc/examples.md +121 -17
- package/docs/rpc/extension-ui.md +86 -63
- package/docs/rpc/protocol.md +817 -358
- package/docs/rpc.md +78 -152
- package/docs/sdk/reference.md +309 -73
- package/docs/sdk/storage.md +614 -0
- package/docs/sdk/structured-decisions.md +168 -65
- package/docs/sdk/web-server.md +80 -46
- package/docs/sdk.md +168 -215
- package/docs/security.md +117 -44
- package/docs/session-format.md +127 -76
- package/docs/sessions.md +155 -113
- package/docs/settings.md +293 -205
- package/docs/shell-aliases.md +15 -6
- package/docs/skills/authoring.md +17 -9
- package/docs/skills/reference.md +23 -21
- package/docs/skills.md +148 -97
- package/docs/storage.md +172 -260
- package/docs/subagents/authoring.md +148 -15
- package/docs/subagents/reference.md +105 -29
- package/docs/subagents.md +247 -250
- package/docs/terminal-setup.md +97 -69
- package/docs/termux.md +51 -85
- package/docs/themes/reference.md +51 -37
- package/docs/themes.md +52 -55
- package/docs/tmux.md +38 -21
- package/docs/tools.md +209 -147
- package/docs/tui/reference.md +64 -32
- package/docs/tui.md +38 -66
- package/docs/usage.md +94 -86
- package/docs/verification.md +25 -25
- package/docs/web-access.md +106 -54
- package/docs/windows.md +55 -57
- package/docs/worktree-snapshots.md +82 -74
- package/examples/sdk/11-sessions.ts +4 -4
- package/package.json +8 -8
- package/schemas/models.schema.json +58 -7
- package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
- package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
- package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
|
@@ -8,7 +8,7 @@ import * as __atomicHostImport2 from "@bastani/atomic-ai/compat";
|
|
|
8
8
|
if (!(name in namespace)) missing.push(`The requested module '${specifier}' does not provide an export named '${name}'`);
|
|
9
9
|
if (missing.length > 0) {
|
|
10
10
|
const application = typeof __atomicHostImport0.APP_NAME === "string" ? __atomicHostImport0.APP_NAME : "atomic";
|
|
11
|
-
if (__atomicHostImport0.VERSION !== "0.10.
|
|
11
|
+
if (__atomicHostImport0.VERSION !== "0.10.10-alpha.2") missing.unshift(application + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using the web-access extension.");
|
|
12
12
|
throw new Error(missing.join("\n"));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -4552,15 +4552,26 @@ var init_owner_state = __esm(() => {
|
|
|
4552
4552
|
import { readFile } from "node:fs/promises";
|
|
4553
4553
|
import { APP_NAME, getUserConfigPaths as getUserConfigPaths2 } from "@bastani/atomic";
|
|
4554
4554
|
function createAsyncOwnerState(load) {
|
|
4555
|
-
const state = createOwnerState(() => ({}));
|
|
4556
|
-
|
|
4555
|
+
const state = createOwnerState(() => ({ generation: 0 }));
|
|
4556
|
+
const get = () => {
|
|
4557
4557
|
const holder = state();
|
|
4558
|
-
holder.promise
|
|
4559
|
-
holder.promise
|
|
4558
|
+
if (holder.promise)
|
|
4559
|
+
return holder.promise;
|
|
4560
|
+
const generation = holder.generation;
|
|
4561
|
+
const pending = load().catch((err) => {
|
|
4562
|
+
if (holder.generation === generation)
|
|
4563
|
+
holder.promise = undefined;
|
|
4560
4564
|
throw err;
|
|
4561
4565
|
});
|
|
4562
|
-
|
|
4566
|
+
holder.promise = pending;
|
|
4567
|
+
return pending;
|
|
4568
|
+
};
|
|
4569
|
+
get.reset = () => {
|
|
4570
|
+
const holder = state();
|
|
4571
|
+
holder.generation += 1;
|
|
4572
|
+
holder.promise = undefined;
|
|
4563
4573
|
};
|
|
4574
|
+
return get;
|
|
4564
4575
|
}
|
|
4565
4576
|
async function readWebSearchConfigFile() {
|
|
4566
4577
|
const primaryPath = await findReadableConfigPath();
|
|
@@ -5683,6 +5694,304 @@ var init_perplexity = __esm(() => {
|
|
|
5683
5694
|
});
|
|
5684
5695
|
});
|
|
5685
5696
|
|
|
5697
|
+
// dist/builtin/web-access/gemini-search.ts
|
|
5698
|
+
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2 } from "@bastani/atomic";
|
|
5699
|
+
function resetSearchConfig() {
|
|
5700
|
+
getSearchConfig.reset();
|
|
5701
|
+
}
|
|
5702
|
+
function normalizeSearchModel(value) {
|
|
5703
|
+
if (typeof value !== "string")
|
|
5704
|
+
return;
|
|
5705
|
+
const normalized = value.trim();
|
|
5706
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
5707
|
+
}
|
|
5708
|
+
function normalizeSearchProvider(value) {
|
|
5709
|
+
const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
5710
|
+
return normalized === "auto" || normalized === "perplexity" || normalized === "gemini" || normalized === "exa" ? normalized : "auto";
|
|
5711
|
+
}
|
|
5712
|
+
function providerSetupHint() {
|
|
5713
|
+
return `To configure a search provider, either:
|
|
5714
|
+
` + ` 1. Set EXA_API_KEY, PERPLEXITY_API_KEY, or GEMINI_API_KEY in the environment
|
|
5715
|
+
` + ` 2. Add exaApiKey, perplexityApiKey, or geminiApiKey to ~/${CONFIG_DIR_NAME2}/web-search.json
|
|
5716
|
+
` + " 3. Sign into gemini.google.com in a supported Chromium-based browser and allow browser cookies " + `(allowBrowserCookies: true in ~/${CONFIG_DIR_NAME2}/web-search.json)
|
|
5717
|
+
` + `Without a key, Exa's keyless fallback needs network access to mcp.exa.ai.
|
|
5718
|
+
` + "/curator only toggles the interactive review browser; it does not add a search provider. " + "Run /curator off if the curator keeps failing to open.";
|
|
5719
|
+
}
|
|
5720
|
+
function errorMessage(err) {
|
|
5721
|
+
return err instanceof Error ? err.message : String(err);
|
|
5722
|
+
}
|
|
5723
|
+
function isAbortError(err) {
|
|
5724
|
+
return errorMessage(err).toLowerCase().includes("abort");
|
|
5725
|
+
}
|
|
5726
|
+
async function searchWithGemini(query, options, strictErrors) {
|
|
5727
|
+
const errors = [];
|
|
5728
|
+
try {
|
|
5729
|
+
const apiResult = await searchWithGeminiApi(query, options);
|
|
5730
|
+
if (apiResult)
|
|
5731
|
+
return apiResult;
|
|
5732
|
+
} catch (err) {
|
|
5733
|
+
if (isAbortError(err))
|
|
5734
|
+
throw err;
|
|
5735
|
+
errors.push(`Gemini API: ${errorMessage(err)}`);
|
|
5736
|
+
}
|
|
5737
|
+
try {
|
|
5738
|
+
const webResult = await searchWithGeminiWeb(query, options);
|
|
5739
|
+
if (webResult)
|
|
5740
|
+
return webResult;
|
|
5741
|
+
} catch (err) {
|
|
5742
|
+
if (isAbortError(err))
|
|
5743
|
+
throw err;
|
|
5744
|
+
errors.push(`Gemini Web: ${errorMessage(err)}`);
|
|
5745
|
+
}
|
|
5746
|
+
if (strictErrors && errors.length > 0) {
|
|
5747
|
+
throw new Error(`Gemini search failed:
|
|
5748
|
+
- ${errors.join(`
|
|
5749
|
+
- `)}`);
|
|
5750
|
+
}
|
|
5751
|
+
return null;
|
|
5752
|
+
}
|
|
5753
|
+
async function search(query, options = {}) {
|
|
5754
|
+
const config = await getSearchConfig();
|
|
5755
|
+
const provider = options.provider ?? config.searchProvider;
|
|
5756
|
+
if (provider === "perplexity") {
|
|
5757
|
+
const result = await searchWithPerplexity(query, options);
|
|
5758
|
+
return { ...result, provider: "perplexity" };
|
|
5759
|
+
}
|
|
5760
|
+
if (provider === "gemini") {
|
|
5761
|
+
const result = await searchWithGemini(query, options, true);
|
|
5762
|
+
if (result)
|
|
5763
|
+
return { ...result, provider: "gemini" };
|
|
5764
|
+
throw new Error(`Gemini search unavailable. Either:
|
|
5765
|
+
` + ` 1. Set GEMINI_API_KEY in the environment or "geminiApiKey" in ~/${CONFIG_DIR_NAME2}/web-search.json
|
|
5766
|
+
` + ` 2. Sign into gemini.google.com in a supported Chromium-based browser and enable "allowBrowserCookies": true in ~/${CONFIG_DIR_NAME2}/web-search.json (or ${ALLOW_BROWSER_COOKIES_ENV}=1)`);
|
|
5767
|
+
}
|
|
5768
|
+
if (provider === "exa") {
|
|
5769
|
+
const exaApiKeyConfigured = await hasExaApiKey();
|
|
5770
|
+
try {
|
|
5771
|
+
const result = await searchWithExa(query, options);
|
|
5772
|
+
if (result && "exhausted" in result) {
|
|
5773
|
+
throw new Error(`Exa monthly free tier exhausted (1,000 requests). Resets next month.
|
|
5774
|
+
` + " Use provider: 'perplexity' or 'gemini', or upgrade at exa.ai/pricing");
|
|
5775
|
+
}
|
|
5776
|
+
if (result && "answer" in result)
|
|
5777
|
+
return { ...result, provider: "exa" };
|
|
5778
|
+
if (exaApiKeyConfigured) {
|
|
5779
|
+
throw new Error("Exa search returned no results.");
|
|
5780
|
+
}
|
|
5781
|
+
} catch (err) {
|
|
5782
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
5783
|
+
if (message.toLowerCase().includes("abort"))
|
|
5784
|
+
throw err;
|
|
5785
|
+
if (exaApiKeyConfigured)
|
|
5786
|
+
throw err;
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5789
|
+
const fallbackErrors = [];
|
|
5790
|
+
if (provider !== "exa" && await isExaAvailable()) {
|
|
5791
|
+
try {
|
|
5792
|
+
const result = await searchWithExa(query, options);
|
|
5793
|
+
if (result && "answer" in result)
|
|
5794
|
+
return { ...result, provider: "exa" };
|
|
5795
|
+
} catch (err) {
|
|
5796
|
+
if (isAbortError(err))
|
|
5797
|
+
throw err;
|
|
5798
|
+
fallbackErrors.push(`Exa: ${errorMessage(err)}`);
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
if (await isPerplexityAvailable()) {
|
|
5802
|
+
try {
|
|
5803
|
+
const result = await searchWithPerplexity(query, options);
|
|
5804
|
+
return { ...result, provider: "perplexity" };
|
|
5805
|
+
} catch (err) {
|
|
5806
|
+
if (isAbortError(err))
|
|
5807
|
+
throw err;
|
|
5808
|
+
fallbackErrors.push(`Perplexity: ${errorMessage(err)}`);
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
try {
|
|
5812
|
+
const geminiResult = await searchWithGemini(query, options, false);
|
|
5813
|
+
if (geminiResult)
|
|
5814
|
+
return { ...geminiResult, provider: "gemini" };
|
|
5815
|
+
} catch (err) {
|
|
5816
|
+
if (isAbortError(err))
|
|
5817
|
+
throw err;
|
|
5818
|
+
fallbackErrors.push(`Gemini: ${errorMessage(err)}`);
|
|
5819
|
+
}
|
|
5820
|
+
if (fallbackErrors.length > 0) {
|
|
5821
|
+
throw new Error(`Auto provider search failed:
|
|
5822
|
+
- ${fallbackErrors.join(`
|
|
5823
|
+
- `)}
|
|
5824
|
+
${providerSetupHint()}`);
|
|
5825
|
+
}
|
|
5826
|
+
throw new Error(`No search provider available.
|
|
5827
|
+
${providerSetupHint()}`);
|
|
5828
|
+
}
|
|
5829
|
+
async function searchWithGeminiApi(query, options = {}) {
|
|
5830
|
+
const apiKey = await getApiKey2();
|
|
5831
|
+
if (!apiKey)
|
|
5832
|
+
return null;
|
|
5833
|
+
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
5834
|
+
try {
|
|
5835
|
+
const model = (await getSearchConfig()).searchModel ?? DEFAULT_MODEL;
|
|
5836
|
+
const body = {
|
|
5837
|
+
contents: [{ parts: [{ text: query }] }],
|
|
5838
|
+
tools: [{ google_search: {} }]
|
|
5839
|
+
};
|
|
5840
|
+
const res = await fetch(`${API_BASE}/models/${model}:generateContent?key=${apiKey}`, {
|
|
5841
|
+
method: "POST",
|
|
5842
|
+
headers: { "Content-Type": "application/json" },
|
|
5843
|
+
body: JSON.stringify(body),
|
|
5844
|
+
signal: AbortSignal.any([
|
|
5845
|
+
AbortSignal.timeout(60000),
|
|
5846
|
+
...options.signal ? [options.signal] : []
|
|
5847
|
+
])
|
|
5848
|
+
});
|
|
5849
|
+
if (!res.ok) {
|
|
5850
|
+
const errorText = await res.text();
|
|
5851
|
+
throw new Error(`Gemini API error ${res.status}: ${errorText.slice(0, 300)}`);
|
|
5852
|
+
}
|
|
5853
|
+
const data = await res.json();
|
|
5854
|
+
activityMonitor.logComplete(activityId, res.status);
|
|
5855
|
+
const answer = data.candidates?.[0]?.content?.parts?.map((p) => p.text).filter(Boolean).join(`
|
|
5856
|
+
`) ?? "";
|
|
5857
|
+
const metadata = data.candidates?.[0]?.groundingMetadata;
|
|
5858
|
+
const results = await resolveGroundingChunks(metadata?.groundingChunks, options.signal);
|
|
5859
|
+
if (!answer && results.length === 0)
|
|
5860
|
+
return null;
|
|
5861
|
+
return { answer, results };
|
|
5862
|
+
} catch (err) {
|
|
5863
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
5864
|
+
if (message.toLowerCase().includes("abort")) {
|
|
5865
|
+
activityMonitor.logComplete(activityId, 0);
|
|
5866
|
+
} else {
|
|
5867
|
+
activityMonitor.logError(activityId, message);
|
|
5868
|
+
}
|
|
5869
|
+
throw err;
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
async function searchWithGeminiWeb(query, options = {}) {
|
|
5873
|
+
const cookies = await isGeminiWebAvailable();
|
|
5874
|
+
if (!cookies)
|
|
5875
|
+
return null;
|
|
5876
|
+
const prompt = buildSearchPrompt(query, options);
|
|
5877
|
+
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
5878
|
+
try {
|
|
5879
|
+
const text = await queryWithCookies(prompt, cookies, {
|
|
5880
|
+
model: "gemini-3-flash-preview",
|
|
5881
|
+
signal: options.signal,
|
|
5882
|
+
timeoutMs: 60000
|
|
5883
|
+
});
|
|
5884
|
+
activityMonitor.logComplete(activityId, 200);
|
|
5885
|
+
const results = extractSourceUrls(text);
|
|
5886
|
+
return { answer: text, results };
|
|
5887
|
+
} catch (err) {
|
|
5888
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
5889
|
+
if (message.toLowerCase().includes("abort")) {
|
|
5890
|
+
activityMonitor.logComplete(activityId, 0);
|
|
5891
|
+
} else {
|
|
5892
|
+
activityMonitor.logError(activityId, message);
|
|
5893
|
+
}
|
|
5894
|
+
throw err;
|
|
5895
|
+
}
|
|
5896
|
+
}
|
|
5897
|
+
function buildSearchPrompt(query, options) {
|
|
5898
|
+
let prompt = `Search the web and answer the following question. Include source URLs for your claims.
|
|
5899
|
+
Format your response as:
|
|
5900
|
+
1. A direct answer to the question
|
|
5901
|
+
2. Cited sources as markdown links
|
|
5902
|
+
|
|
5903
|
+
Question: ${query}`;
|
|
5904
|
+
if (options.recencyFilter) {
|
|
5905
|
+
const labels = {
|
|
5906
|
+
day: "past 24 hours",
|
|
5907
|
+
week: "past week",
|
|
5908
|
+
month: "past month",
|
|
5909
|
+
year: "past year"
|
|
5910
|
+
};
|
|
5911
|
+
prompt += `
|
|
5912
|
+
|
|
5913
|
+
Only include results from the ${labels[options.recencyFilter]}.`;
|
|
5914
|
+
}
|
|
5915
|
+
if (options.domainFilter?.length) {
|
|
5916
|
+
const includes = options.domainFilter.filter((d) => !d.startsWith("-"));
|
|
5917
|
+
const excludes = options.domainFilter.filter((d) => d.startsWith("-")).map((d) => d.slice(1));
|
|
5918
|
+
if (includes.length)
|
|
5919
|
+
prompt += `
|
|
5920
|
+
|
|
5921
|
+
Only cite sources from: ${includes.join(", ")}`;
|
|
5922
|
+
if (excludes.length)
|
|
5923
|
+
prompt += `
|
|
5924
|
+
|
|
5925
|
+
Do not cite sources from: ${excludes.join(", ")}`;
|
|
5926
|
+
}
|
|
5927
|
+
return prompt;
|
|
5928
|
+
}
|
|
5929
|
+
function extractSourceUrls(markdown) {
|
|
5930
|
+
const results = [];
|
|
5931
|
+
const seen = new Set;
|
|
5932
|
+
const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g;
|
|
5933
|
+
for (const match of markdown.matchAll(linkRegex)) {
|
|
5934
|
+
const url = match[2];
|
|
5935
|
+
if (seen.has(url))
|
|
5936
|
+
continue;
|
|
5937
|
+
seen.add(url);
|
|
5938
|
+
results.push({ title: match[1], url, snippet: "" });
|
|
5939
|
+
}
|
|
5940
|
+
return results;
|
|
5941
|
+
}
|
|
5942
|
+
async function resolveGroundingChunks(chunks, signal) {
|
|
5943
|
+
if (!chunks?.length)
|
|
5944
|
+
return [];
|
|
5945
|
+
const results = [];
|
|
5946
|
+
for (const chunk of chunks) {
|
|
5947
|
+
if (!chunk.web)
|
|
5948
|
+
continue;
|
|
5949
|
+
const title = chunk.web.title || "";
|
|
5950
|
+
let url = chunk.web.uri || "";
|
|
5951
|
+
if (url.includes("vertexaisearch.cloud.google.com/grounding-api-redirect")) {
|
|
5952
|
+
const resolved = await resolveRedirect(url, signal);
|
|
5953
|
+
if (resolved)
|
|
5954
|
+
url = resolved;
|
|
5955
|
+
}
|
|
5956
|
+
if (url)
|
|
5957
|
+
results.push({ title, url, snippet: "" });
|
|
5958
|
+
}
|
|
5959
|
+
return results;
|
|
5960
|
+
}
|
|
5961
|
+
async function resolveRedirect(proxyUrl, signal) {
|
|
5962
|
+
try {
|
|
5963
|
+
const res = await fetch(proxyUrl, {
|
|
5964
|
+
method: "HEAD",
|
|
5965
|
+
redirect: "manual",
|
|
5966
|
+
signal: AbortSignal.any([
|
|
5967
|
+
AbortSignal.timeout(5000),
|
|
5968
|
+
...signal ? [signal] : []
|
|
5969
|
+
])
|
|
5970
|
+
});
|
|
5971
|
+
return res.headers.get("location") || null;
|
|
5972
|
+
} catch {
|
|
5973
|
+
return null;
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
var getSearchConfig;
|
|
5977
|
+
var init_gemini_search = __esm(() => {
|
|
5978
|
+
init_activity();
|
|
5979
|
+
init_gemini_api();
|
|
5980
|
+
init_gemini_web();
|
|
5981
|
+
init_gemini_web_config();
|
|
5982
|
+
init_perplexity();
|
|
5983
|
+
init_exa();
|
|
5984
|
+
getSearchConfig = createAsyncOwnerState(async () => {
|
|
5985
|
+
const raw = await readWebSearchConfigFile();
|
|
5986
|
+
if (!raw)
|
|
5987
|
+
return { searchProvider: "auto" };
|
|
5988
|
+
return {
|
|
5989
|
+
searchProvider: normalizeSearchProvider(raw.provider ?? raw.searchProvider),
|
|
5990
|
+
searchModel: normalizeSearchModel(raw.searchModel)
|
|
5991
|
+
};
|
|
5992
|
+
});
|
|
5993
|
+
});
|
|
5994
|
+
|
|
5686
5995
|
// dist/builtin/web-access/web-search-workflow.ts
|
|
5687
5996
|
function resolveWorkflow(input, hasUI) {
|
|
5688
5997
|
if (!hasUI)
|
|
@@ -5694,10 +6003,10 @@ function resolveWorkflow(input, hasUI) {
|
|
|
5694
6003
|
}
|
|
5695
6004
|
|
|
5696
6005
|
// dist/builtin/web-access/web-search-config.ts
|
|
5697
|
-
import { CONFIG_DIR_NAME as
|
|
6006
|
+
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME3, getUserConfigPaths as getUserConfigPaths3 } from "@bastani/atomic";
|
|
5698
6007
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
5699
6008
|
import { homedir as homedir3 } from "node:os";
|
|
5700
|
-
import { join as join4 } from "node:path";
|
|
6009
|
+
import { dirname, join as join4 } from "node:path";
|
|
5701
6010
|
async function loadConfig5() {
|
|
5702
6011
|
return await readWebSearchConfigFile() ?? {};
|
|
5703
6012
|
}
|
|
@@ -5706,10 +6015,13 @@ function saveConfig(updates) {
|
|
|
5706
6015
|
const existing = await readWebSearchConfigFile();
|
|
5707
6016
|
const config = existing ? { ...existing } : {};
|
|
5708
6017
|
Object.assign(config, updates);
|
|
5709
|
-
|
|
5710
|
-
|
|
6018
|
+
if (updates.provider !== undefined) {
|
|
6019
|
+
delete config.searchProvider;
|
|
6020
|
+
}
|
|
6021
|
+
await mkdir2(dirname(WEB_SEARCH_CONFIG_PATH2), { recursive: true });
|
|
5711
6022
|
await writeFile2(WEB_SEARCH_CONFIG_PATH2, JSON.stringify(config, null, 2) + `
|
|
5712
6023
|
`);
|
|
6024
|
+
resetSearchConfig();
|
|
5713
6025
|
};
|
|
5714
6026
|
const next = saveConfigQueue.then(run, run);
|
|
5715
6027
|
saveConfigQueue = next.then(() => {
|
|
@@ -5816,7 +6128,8 @@ var init_web_search_config = __esm(() => {
|
|
|
5816
6128
|
init_gemini_web();
|
|
5817
6129
|
init_gemini_web_config();
|
|
5818
6130
|
init_perplexity();
|
|
5819
|
-
|
|
6131
|
+
init_gemini_search();
|
|
6132
|
+
WEB_SEARCH_CONFIG_PATH2 = getUserConfigPaths3("web-search.json")[0] ?? join4(homedir3(), CONFIG_DIR_NAME3, "web-search.json");
|
|
5820
6133
|
DEFAULT_SHORTCUTS = { curate: "ctrl+shift+s", activity: "ctrl+shift+w" };
|
|
5821
6134
|
saveConfigQueue = Promise.resolve();
|
|
5822
6135
|
});
|
|
@@ -85308,7 +85621,7 @@ var init_github_api = __esm(() => {
|
|
|
85308
85621
|
import { readFile as readFile5, rm as rm2, stat as stat2, readdir, open, realpath, lstat as lstat2, mkdir as mkdir4, writeFile as writeFile4 } from "node:fs/promises";
|
|
85309
85622
|
import { spawn } from "node:child_process";
|
|
85310
85623
|
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
85311
|
-
import { dirname, extname as extname2, isAbsolute, join as join6, relative, resolve as resolvePath, sep as pathSep } from "node:path";
|
|
85624
|
+
import { dirname as dirname2, extname as extname2, isAbsolute, join as join6, relative, resolve as resolvePath, sep as pathSep } from "node:path";
|
|
85312
85625
|
import {
|
|
85313
85626
|
assertPrivateDirectoryAsync,
|
|
85314
85627
|
containProcessTree,
|
|
@@ -85345,7 +85658,7 @@ async function pathExists2(path) {
|
|
|
85345
85658
|
async function isConfined(root, path) {
|
|
85346
85659
|
let existing = path;
|
|
85347
85660
|
while (!await pathExists2(existing))
|
|
85348
|
-
existing =
|
|
85661
|
+
existing = dirname2(existing);
|
|
85349
85662
|
if (!await pathExists(existing))
|
|
85350
85663
|
return false;
|
|
85351
85664
|
try {
|
|
@@ -85371,7 +85684,7 @@ async function prepareCloneDirectory(paths) {
|
|
|
85371
85684
|
const { root, directory } = paths;
|
|
85372
85685
|
try {
|
|
85373
85686
|
const privateRoot = chosenDefaultGitHubClonePath();
|
|
85374
|
-
if (privateRoot && (root === privateRoot ||
|
|
85687
|
+
if (privateRoot && (root === privateRoot || dirname2(root) === privateRoot)) {
|
|
85375
85688
|
await assertPrivateDirectoryAsync(privateRoot);
|
|
85376
85689
|
}
|
|
85377
85690
|
await mkdir4(root, { recursive: true });
|
|
@@ -86405,7 +86718,7 @@ var init_gemini_url_context = __esm(() => {
|
|
|
86405
86718
|
|
|
86406
86719
|
// dist/builtin/web-access/video-extract.ts
|
|
86407
86720
|
import { access as access5, readFile as readFile6, readdir as readdir2, stat as stat3 } from "node:fs/promises";
|
|
86408
|
-
import { resolve, extname as extname3, basename as basename3, join as join7, dirname as
|
|
86721
|
+
import { resolve, extname as extname3, basename as basename3, join as join7, dirname as dirname3, isAbsolute as isAbsolute2 } from "node:path";
|
|
86409
86722
|
import { fileURLToPath } from "node:url";
|
|
86410
86723
|
function shouldRethrow3(err) {
|
|
86411
86724
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -86467,7 +86780,7 @@ async function resolveFilePath(filePath) {
|
|
|
86467
86780
|
await access5(absolutePath);
|
|
86468
86781
|
return absolutePath;
|
|
86469
86782
|
} catch {}
|
|
86470
|
-
const dir =
|
|
86783
|
+
const dir = dirname3(absolutePath);
|
|
86471
86784
|
const base = basename3(absolutePath);
|
|
86472
86785
|
try {
|
|
86473
86786
|
const entries = await readdir2(dir);
|
|
@@ -86730,7 +87043,7 @@ var init_video_extract = __esm(() => {
|
|
|
86730
87043
|
});
|
|
86731
87044
|
|
|
86732
87045
|
// dist/builtin/web-access/extract-frames.ts
|
|
86733
|
-
function
|
|
87046
|
+
function errorMessage2(err) {
|
|
86734
87047
|
return err instanceof Error ? err.message : String(err);
|
|
86735
87048
|
}
|
|
86736
87049
|
function parseTimestamp(ts) {
|
|
@@ -86800,7 +87113,7 @@ async function safeVideoInfo(url) {
|
|
|
86800
87113
|
try {
|
|
86801
87114
|
return { info: await isVideoFile(url) };
|
|
86802
87115
|
} catch (err) {
|
|
86803
|
-
return { info: null, error:
|
|
87116
|
+
return { info: null, error: errorMessage2(err) };
|
|
86804
87117
|
}
|
|
86805
87118
|
}
|
|
86806
87119
|
async function extractRequestedFrames(url, options, signal) {
|
|
@@ -86932,7 +87245,7 @@ var init_extract_frames = __esm(() => {
|
|
|
86932
87245
|
|
|
86933
87246
|
// dist/builtin/web-access/extract.ts
|
|
86934
87247
|
import { isIPv4, isIPv6 } from "node:net";
|
|
86935
|
-
import { CONFIG_DIR_NAME as
|
|
87248
|
+
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME4 } from "@bastani/atomic";
|
|
86936
87249
|
async function readBodyWithinLimit(response, maxBytes) {
|
|
86937
87250
|
if (!response.body)
|
|
86938
87251
|
return new Uint8Array(0);
|
|
@@ -86993,14 +87306,14 @@ function isPrivateUrl(url) {
|
|
|
86993
87306
|
}
|
|
86994
87307
|
return !host.includes(".") || PRIVATE_HOST_SUFFIX.test(host);
|
|
86995
87308
|
}
|
|
86996
|
-
function
|
|
87309
|
+
function errorMessage3(err) {
|
|
86997
87310
|
return err instanceof Error ? err.message : String(err);
|
|
86998
87311
|
}
|
|
86999
87312
|
function isConfigParseError(err) {
|
|
87000
|
-
return
|
|
87313
|
+
return errorMessage3(err).startsWith("Failed to parse ");
|
|
87001
87314
|
}
|
|
87002
|
-
function
|
|
87003
|
-
return
|
|
87315
|
+
function isAbortError2(err) {
|
|
87316
|
+
return errorMessage3(err).toLowerCase().includes("abort");
|
|
87004
87317
|
}
|
|
87005
87318
|
function abortedResult(url) {
|
|
87006
87319
|
return { url, title: "", content: "", error: "Aborted" };
|
|
@@ -87009,7 +87322,7 @@ async function safeVideoInfo2(url) {
|
|
|
87009
87322
|
try {
|
|
87010
87323
|
return { info: await isVideoFile(url) };
|
|
87011
87324
|
} catch (err) {
|
|
87012
|
-
return { info: null, error:
|
|
87325
|
+
return { info: null, error: errorMessage3(err) };
|
|
87013
87326
|
}
|
|
87014
87327
|
}
|
|
87015
87328
|
async function extractWithJinaReader(url, signal) {
|
|
@@ -87063,7 +87376,16 @@ async function extractContent(url, signal, options) {
|
|
|
87063
87376
|
if (localVideo.error) {
|
|
87064
87377
|
return { url, title: "", content: "", error: localVideo.error };
|
|
87065
87378
|
}
|
|
87066
|
-
|
|
87379
|
+
const ytInfo = isYouTubeURL(url);
|
|
87380
|
+
let youtubeEnabled = false;
|
|
87381
|
+
if (ytInfo.isYouTube) {
|
|
87382
|
+
try {
|
|
87383
|
+
youtubeEnabled = await isYouTubeEnabled();
|
|
87384
|
+
} catch (err) {
|
|
87385
|
+
return { url, title: "", content: "", error: errorMessage3(err) };
|
|
87386
|
+
}
|
|
87387
|
+
}
|
|
87388
|
+
if (localVideo.info || ytInfo.isYouTube && youtubeEnabled) {
|
|
87067
87389
|
const frameResult = await extractRequestedFrames(url, options, signal);
|
|
87068
87390
|
if (frameResult)
|
|
87069
87391
|
return frameResult;
|
|
@@ -87073,13 +87395,18 @@ async function extractContent(url, signal, options) {
|
|
|
87073
87395
|
const result = await extractVideo(localVideo.info, signal, options);
|
|
87074
87396
|
if (signal?.aborted)
|
|
87075
87397
|
return abortedResult(url);
|
|
87076
|
-
return result ?? {
|
|
87077
|
-
|
|
87078
|
-
|
|
87398
|
+
return result ?? {
|
|
87399
|
+
url,
|
|
87400
|
+
title: "",
|
|
87401
|
+
content: "",
|
|
87402
|
+
error: `Video analysis requires Gemini access. Either:
|
|
87403
|
+
` + ` 1. Set GEMINI_API_KEY in the environment or "geminiApiKey" in ~/${CONFIG_DIR_NAME4}/web-search.json
|
|
87404
|
+
` + ` 2. Sign into gemini.google.com in Chrome and enable "allowBrowserCookies": true in ~/${CONFIG_DIR_NAME4}/web-search.json (or ${ALLOW_BROWSER_COOKIES_ENV}=1)`
|
|
87405
|
+
};
|
|
87079
87406
|
} catch (err) {
|
|
87080
|
-
if (
|
|
87407
|
+
if (isAbortError2(err))
|
|
87081
87408
|
return abortedResult(url);
|
|
87082
|
-
return { url, title: "", content: "", error:
|
|
87409
|
+
return { url, title: "", content: "", error: errorMessage3(err) };
|
|
87083
87410
|
}
|
|
87084
87411
|
}
|
|
87085
87412
|
let parsedUrl;
|
|
@@ -87098,20 +87425,13 @@ async function extractContent(url, signal, options) {
|
|
|
87098
87425
|
if (signal?.aborted)
|
|
87099
87426
|
return abortedResult(url);
|
|
87100
87427
|
} catch (err) {
|
|
87101
|
-
const message =
|
|
87102
|
-
if (
|
|
87428
|
+
const message = errorMessage3(err);
|
|
87429
|
+
if (isAbortError2(err))
|
|
87103
87430
|
return abortedResult(url);
|
|
87104
87431
|
if (isConfigParseError(err)) {
|
|
87105
87432
|
return { url, title: "", content: "", error: message };
|
|
87106
87433
|
}
|
|
87107
87434
|
}
|
|
87108
|
-
const ytInfo = isYouTubeURL(url);
|
|
87109
|
-
let youtubeEnabled = false;
|
|
87110
|
-
try {
|
|
87111
|
-
youtubeEnabled = await isYouTubeEnabled();
|
|
87112
|
-
} catch (err) {
|
|
87113
|
-
return { url, title: "", content: "", error: errorMessage2(err) };
|
|
87114
|
-
}
|
|
87115
87435
|
if (ytInfo.isYouTube && youtubeEnabled) {
|
|
87116
87436
|
try {
|
|
87117
87437
|
const ytResult = await extractYouTube(url, signal, options?.prompt, options?.model);
|
|
@@ -87120,8 +87440,8 @@ async function extractContent(url, signal, options) {
|
|
|
87120
87440
|
if (signal?.aborted)
|
|
87121
87441
|
return abortedResult(url);
|
|
87122
87442
|
} catch (err) {
|
|
87123
|
-
const message =
|
|
87124
|
-
if (
|
|
87443
|
+
const message = errorMessage3(err);
|
|
87444
|
+
if (isAbortError2(err))
|
|
87125
87445
|
return abortedResult(url);
|
|
87126
87446
|
if (isConfigParseError(err)) {
|
|
87127
87447
|
return { url, title: "", content: "", error: message };
|
|
@@ -87131,7 +87451,7 @@ async function extractContent(url, signal, options) {
|
|
|
87131
87451
|
url,
|
|
87132
87452
|
title: "",
|
|
87133
87453
|
content: "",
|
|
87134
|
-
error:
|
|
87454
|
+
error: `Could not extract YouTube video content. Set GEMINI_API_KEY in the environment or "geminiApiKey" in ~/${CONFIG_DIR_NAME4}/web-search.json, or sign into Google in Chrome and enable "allowBrowserCookies": true in ~/${CONFIG_DIR_NAME4}/web-search.json (or ${ALLOW_BROWSER_COOKIES_ENV}=1).`
|
|
87135
87455
|
};
|
|
87136
87456
|
}
|
|
87137
87457
|
if (signal?.aborted)
|
|
@@ -87155,10 +87475,10 @@ async function extractContent(url, signal, options) {
|
|
|
87155
87475
|
try {
|
|
87156
87476
|
geminiResult = await extractWithUrlContext(url, signal) ?? await extractWithGeminiWeb(url, signal);
|
|
87157
87477
|
} catch (err) {
|
|
87158
|
-
if (
|
|
87478
|
+
if (isAbortError2(err))
|
|
87159
87479
|
return abortedResult(url);
|
|
87160
87480
|
if (isConfigParseError(err)) {
|
|
87161
|
-
return { ...httpResult, error:
|
|
87481
|
+
return { ...httpResult, error: errorMessage3(err) };
|
|
87162
87482
|
}
|
|
87163
87483
|
}
|
|
87164
87484
|
if (geminiResult)
|
|
@@ -87169,8 +87489,8 @@ async function extractContent(url, signal, options) {
|
|
|
87169
87489
|
httpResult.error,
|
|
87170
87490
|
"",
|
|
87171
87491
|
"Fallback options:",
|
|
87172
|
-
` • Set GEMINI_API_KEY in ~/${
|
|
87173
|
-
|
|
87492
|
+
` • Set GEMINI_API_KEY in the environment or "geminiApiKey" in ~/${CONFIG_DIR_NAME4}/web-search.json`,
|
|
87493
|
+
` • Sign into gemini.google.com in Chrome and enable "allowBrowserCookies": true in ~/${CONFIG_DIR_NAME4}/web-search.json (or ${ALLOW_BROWSER_COOKIES_ENV}=1)`,
|
|
87174
87494
|
" • Use web_search to find content about this topic"
|
|
87175
87495
|
].join(`
|
|
87176
87496
|
`);
|
|
@@ -87470,6 +87790,7 @@ var init_extract = __esm(() => {
|
|
|
87470
87790
|
init_github_extract();
|
|
87471
87791
|
init_youtube_extract();
|
|
87472
87792
|
init_gemini_url_context();
|
|
87793
|
+
init_gemini_web_config();
|
|
87473
87794
|
init_video_extract();
|
|
87474
87795
|
init_extract_frames();
|
|
87475
87796
|
import_readability = __toESM(require_readability(), 1);
|
|
@@ -109259,301 +109580,6 @@ var init_curator_server = __esm(() => {
|
|
|
109259
109580
|
init_curator_server_helpers();
|
|
109260
109581
|
});
|
|
109261
109582
|
|
|
109262
|
-
// dist/builtin/web-access/gemini-search.ts
|
|
109263
|
-
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME4 } from "@bastani/atomic";
|
|
109264
|
-
function normalizeSearchModel(value) {
|
|
109265
|
-
if (typeof value !== "string")
|
|
109266
|
-
return;
|
|
109267
|
-
const normalized = value.trim();
|
|
109268
|
-
return normalized.length > 0 ? normalized : undefined;
|
|
109269
|
-
}
|
|
109270
|
-
function normalizeSearchProvider(value) {
|
|
109271
|
-
const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
109272
|
-
return normalized === "auto" || normalized === "perplexity" || normalized === "gemini" || normalized === "exa" ? normalized : "auto";
|
|
109273
|
-
}
|
|
109274
|
-
function providerSetupHint() {
|
|
109275
|
-
return `To configure a search provider, either:
|
|
109276
|
-
` + ` 1. Set EXA_API_KEY, PERPLEXITY_API_KEY, or GEMINI_API_KEY in the environment
|
|
109277
|
-
` + ` 2. Add exaApiKey, perplexityApiKey, or geminiApiKey to ~/${CONFIG_DIR_NAME4}/web-search.json
|
|
109278
|
-
` + " 3. Sign into gemini.google.com in a supported Chromium-based browser and allow browser cookies " + `(allowBrowserCookies: true in ~/${CONFIG_DIR_NAME4}/web-search.json)
|
|
109279
|
-
` + `Without a key, Exa's keyless fallback needs network access to mcp.exa.ai.
|
|
109280
|
-
` + "/curator only toggles the interactive review browser; it does not add a search provider. " + "Run /curator off if the curator keeps failing to open.";
|
|
109281
|
-
}
|
|
109282
|
-
function errorMessage3(err) {
|
|
109283
|
-
return err instanceof Error ? err.message : String(err);
|
|
109284
|
-
}
|
|
109285
|
-
function isAbortError2(err) {
|
|
109286
|
-
return errorMessage3(err).toLowerCase().includes("abort");
|
|
109287
|
-
}
|
|
109288
|
-
async function searchWithGemini(query, options, strictErrors) {
|
|
109289
|
-
const errors = [];
|
|
109290
|
-
try {
|
|
109291
|
-
const apiResult = await searchWithGeminiApi(query, options);
|
|
109292
|
-
if (apiResult)
|
|
109293
|
-
return apiResult;
|
|
109294
|
-
} catch (err) {
|
|
109295
|
-
if (isAbortError2(err))
|
|
109296
|
-
throw err;
|
|
109297
|
-
errors.push(`Gemini API: ${errorMessage3(err)}`);
|
|
109298
|
-
}
|
|
109299
|
-
try {
|
|
109300
|
-
const webResult = await searchWithGeminiWeb(query, options);
|
|
109301
|
-
if (webResult)
|
|
109302
|
-
return webResult;
|
|
109303
|
-
} catch (err) {
|
|
109304
|
-
if (isAbortError2(err))
|
|
109305
|
-
throw err;
|
|
109306
|
-
errors.push(`Gemini Web: ${errorMessage3(err)}`);
|
|
109307
|
-
}
|
|
109308
|
-
if (strictErrors && errors.length > 0) {
|
|
109309
|
-
throw new Error(`Gemini search failed:
|
|
109310
|
-
- ${errors.join(`
|
|
109311
|
-
- `)}`);
|
|
109312
|
-
}
|
|
109313
|
-
return null;
|
|
109314
|
-
}
|
|
109315
|
-
async function search(query, options = {}) {
|
|
109316
|
-
const config = await getSearchConfig();
|
|
109317
|
-
const provider = options.provider ?? config.searchProvider;
|
|
109318
|
-
if (provider === "perplexity") {
|
|
109319
|
-
const result = await searchWithPerplexity(query, options);
|
|
109320
|
-
return { ...result, provider: "perplexity" };
|
|
109321
|
-
}
|
|
109322
|
-
if (provider === "gemini") {
|
|
109323
|
-
const result = await searchWithGemini(query, options, true);
|
|
109324
|
-
if (result)
|
|
109325
|
-
return { ...result, provider: "gemini" };
|
|
109326
|
-
throw new Error(`Gemini search unavailable. Either:
|
|
109327
|
-
` + ` 1. Set GEMINI_API_KEY in ~/${CONFIG_DIR_NAME4}/web-search.json
|
|
109328
|
-
` + " 2. Sign into gemini.google.com in a supported Chromium-based browser");
|
|
109329
|
-
}
|
|
109330
|
-
if (provider === "exa") {
|
|
109331
|
-
const exaApiKeyConfigured = await hasExaApiKey();
|
|
109332
|
-
try {
|
|
109333
|
-
const result = await searchWithExa(query, options);
|
|
109334
|
-
if (result && "exhausted" in result) {
|
|
109335
|
-
throw new Error(`Exa monthly free tier exhausted (1,000 requests). Resets next month.
|
|
109336
|
-
` + " Use provider: 'perplexity' or 'gemini', or upgrade at exa.ai/pricing");
|
|
109337
|
-
}
|
|
109338
|
-
if (result && "answer" in result)
|
|
109339
|
-
return { ...result, provider: "exa" };
|
|
109340
|
-
if (exaApiKeyConfigured) {
|
|
109341
|
-
throw new Error("Exa search returned no results.");
|
|
109342
|
-
}
|
|
109343
|
-
} catch (err) {
|
|
109344
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
109345
|
-
if (message.toLowerCase().includes("abort"))
|
|
109346
|
-
throw err;
|
|
109347
|
-
if (exaApiKeyConfigured)
|
|
109348
|
-
throw err;
|
|
109349
|
-
}
|
|
109350
|
-
}
|
|
109351
|
-
const fallbackErrors = [];
|
|
109352
|
-
if (provider !== "exa" && await isExaAvailable()) {
|
|
109353
|
-
try {
|
|
109354
|
-
const result = await searchWithExa(query, options);
|
|
109355
|
-
if (result && "answer" in result)
|
|
109356
|
-
return { ...result, provider: "exa" };
|
|
109357
|
-
} catch (err) {
|
|
109358
|
-
if (isAbortError2(err))
|
|
109359
|
-
throw err;
|
|
109360
|
-
fallbackErrors.push(`Exa: ${errorMessage3(err)}`);
|
|
109361
|
-
}
|
|
109362
|
-
}
|
|
109363
|
-
if (await isPerplexityAvailable()) {
|
|
109364
|
-
try {
|
|
109365
|
-
const result = await searchWithPerplexity(query, options);
|
|
109366
|
-
return { ...result, provider: "perplexity" };
|
|
109367
|
-
} catch (err) {
|
|
109368
|
-
if (isAbortError2(err))
|
|
109369
|
-
throw err;
|
|
109370
|
-
fallbackErrors.push(`Perplexity: ${errorMessage3(err)}`);
|
|
109371
|
-
}
|
|
109372
|
-
}
|
|
109373
|
-
try {
|
|
109374
|
-
const geminiResult = await searchWithGemini(query, options, false);
|
|
109375
|
-
if (geminiResult)
|
|
109376
|
-
return { ...geminiResult, provider: "gemini" };
|
|
109377
|
-
} catch (err) {
|
|
109378
|
-
if (isAbortError2(err))
|
|
109379
|
-
throw err;
|
|
109380
|
-
fallbackErrors.push(`Gemini: ${errorMessage3(err)}`);
|
|
109381
|
-
}
|
|
109382
|
-
if (fallbackErrors.length > 0) {
|
|
109383
|
-
throw new Error(`Auto provider search failed:
|
|
109384
|
-
- ${fallbackErrors.join(`
|
|
109385
|
-
- `)}
|
|
109386
|
-
${providerSetupHint()}`);
|
|
109387
|
-
}
|
|
109388
|
-
throw new Error(`No search provider available.
|
|
109389
|
-
${providerSetupHint()}`);
|
|
109390
|
-
}
|
|
109391
|
-
async function searchWithGeminiApi(query, options = {}) {
|
|
109392
|
-
const apiKey = await getApiKey2();
|
|
109393
|
-
if (!apiKey)
|
|
109394
|
-
return null;
|
|
109395
|
-
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
109396
|
-
try {
|
|
109397
|
-
const model = (await getSearchConfig()).searchModel ?? DEFAULT_MODEL;
|
|
109398
|
-
const body = {
|
|
109399
|
-
contents: [{ parts: [{ text: query }] }],
|
|
109400
|
-
tools: [{ google_search: {} }]
|
|
109401
|
-
};
|
|
109402
|
-
const res = await fetch(`${API_BASE}/models/${model}:generateContent?key=${apiKey}`, {
|
|
109403
|
-
method: "POST",
|
|
109404
|
-
headers: { "Content-Type": "application/json" },
|
|
109405
|
-
body: JSON.stringify(body),
|
|
109406
|
-
signal: AbortSignal.any([
|
|
109407
|
-
AbortSignal.timeout(60000),
|
|
109408
|
-
...options.signal ? [options.signal] : []
|
|
109409
|
-
])
|
|
109410
|
-
});
|
|
109411
|
-
if (!res.ok) {
|
|
109412
|
-
const errorText = await res.text();
|
|
109413
|
-
throw new Error(`Gemini API error ${res.status}: ${errorText.slice(0, 300)}`);
|
|
109414
|
-
}
|
|
109415
|
-
const data = await res.json();
|
|
109416
|
-
activityMonitor.logComplete(activityId, res.status);
|
|
109417
|
-
const answer = data.candidates?.[0]?.content?.parts?.map((p) => p.text).filter(Boolean).join(`
|
|
109418
|
-
`) ?? "";
|
|
109419
|
-
const metadata = data.candidates?.[0]?.groundingMetadata;
|
|
109420
|
-
const results = await resolveGroundingChunks(metadata?.groundingChunks, options.signal);
|
|
109421
|
-
if (!answer && results.length === 0)
|
|
109422
|
-
return null;
|
|
109423
|
-
return { answer, results };
|
|
109424
|
-
} catch (err) {
|
|
109425
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
109426
|
-
if (message.toLowerCase().includes("abort")) {
|
|
109427
|
-
activityMonitor.logComplete(activityId, 0);
|
|
109428
|
-
} else {
|
|
109429
|
-
activityMonitor.logError(activityId, message);
|
|
109430
|
-
}
|
|
109431
|
-
throw err;
|
|
109432
|
-
}
|
|
109433
|
-
}
|
|
109434
|
-
async function searchWithGeminiWeb(query, options = {}) {
|
|
109435
|
-
const cookies = await isGeminiWebAvailable();
|
|
109436
|
-
if (!cookies)
|
|
109437
|
-
return null;
|
|
109438
|
-
const prompt = buildSearchPrompt(query, options);
|
|
109439
|
-
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
109440
|
-
try {
|
|
109441
|
-
const text = await queryWithCookies(prompt, cookies, {
|
|
109442
|
-
model: "gemini-3-flash-preview",
|
|
109443
|
-
signal: options.signal,
|
|
109444
|
-
timeoutMs: 60000
|
|
109445
|
-
});
|
|
109446
|
-
activityMonitor.logComplete(activityId, 200);
|
|
109447
|
-
const results = extractSourceUrls(text);
|
|
109448
|
-
return { answer: text, results };
|
|
109449
|
-
} catch (err) {
|
|
109450
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
109451
|
-
if (message.toLowerCase().includes("abort")) {
|
|
109452
|
-
activityMonitor.logComplete(activityId, 0);
|
|
109453
|
-
} else {
|
|
109454
|
-
activityMonitor.logError(activityId, message);
|
|
109455
|
-
}
|
|
109456
|
-
throw err;
|
|
109457
|
-
}
|
|
109458
|
-
}
|
|
109459
|
-
function buildSearchPrompt(query, options) {
|
|
109460
|
-
let prompt = `Search the web and answer the following question. Include source URLs for your claims.
|
|
109461
|
-
Format your response as:
|
|
109462
|
-
1. A direct answer to the question
|
|
109463
|
-
2. Cited sources as markdown links
|
|
109464
|
-
|
|
109465
|
-
Question: ${query}`;
|
|
109466
|
-
if (options.recencyFilter) {
|
|
109467
|
-
const labels = {
|
|
109468
|
-
day: "past 24 hours",
|
|
109469
|
-
week: "past week",
|
|
109470
|
-
month: "past month",
|
|
109471
|
-
year: "past year"
|
|
109472
|
-
};
|
|
109473
|
-
prompt += `
|
|
109474
|
-
|
|
109475
|
-
Only include results from the ${labels[options.recencyFilter]}.`;
|
|
109476
|
-
}
|
|
109477
|
-
if (options.domainFilter?.length) {
|
|
109478
|
-
const includes = options.domainFilter.filter((d) => !d.startsWith("-"));
|
|
109479
|
-
const excludes = options.domainFilter.filter((d) => d.startsWith("-")).map((d) => d.slice(1));
|
|
109480
|
-
if (includes.length)
|
|
109481
|
-
prompt += `
|
|
109482
|
-
|
|
109483
|
-
Only cite sources from: ${includes.join(", ")}`;
|
|
109484
|
-
if (excludes.length)
|
|
109485
|
-
prompt += `
|
|
109486
|
-
|
|
109487
|
-
Do not cite sources from: ${excludes.join(", ")}`;
|
|
109488
|
-
}
|
|
109489
|
-
return prompt;
|
|
109490
|
-
}
|
|
109491
|
-
function extractSourceUrls(markdown) {
|
|
109492
|
-
const results = [];
|
|
109493
|
-
const seen = new Set;
|
|
109494
|
-
const linkRegex = /\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g;
|
|
109495
|
-
for (const match of markdown.matchAll(linkRegex)) {
|
|
109496
|
-
const url = match[2];
|
|
109497
|
-
if (seen.has(url))
|
|
109498
|
-
continue;
|
|
109499
|
-
seen.add(url);
|
|
109500
|
-
results.push({ title: match[1], url, snippet: "" });
|
|
109501
|
-
}
|
|
109502
|
-
return results;
|
|
109503
|
-
}
|
|
109504
|
-
async function resolveGroundingChunks(chunks, signal) {
|
|
109505
|
-
if (!chunks?.length)
|
|
109506
|
-
return [];
|
|
109507
|
-
const results = [];
|
|
109508
|
-
for (const chunk of chunks) {
|
|
109509
|
-
if (!chunk.web)
|
|
109510
|
-
continue;
|
|
109511
|
-
const title = chunk.web.title || "";
|
|
109512
|
-
let url = chunk.web.uri || "";
|
|
109513
|
-
if (url.includes("vertexaisearch.cloud.google.com/grounding-api-redirect")) {
|
|
109514
|
-
const resolved = await resolveRedirect(url, signal);
|
|
109515
|
-
if (resolved)
|
|
109516
|
-
url = resolved;
|
|
109517
|
-
}
|
|
109518
|
-
if (url)
|
|
109519
|
-
results.push({ title, url, snippet: "" });
|
|
109520
|
-
}
|
|
109521
|
-
return results;
|
|
109522
|
-
}
|
|
109523
|
-
async function resolveRedirect(proxyUrl, signal) {
|
|
109524
|
-
try {
|
|
109525
|
-
const res = await fetch(proxyUrl, {
|
|
109526
|
-
method: "HEAD",
|
|
109527
|
-
redirect: "manual",
|
|
109528
|
-
signal: AbortSignal.any([
|
|
109529
|
-
AbortSignal.timeout(5000),
|
|
109530
|
-
...signal ? [signal] : []
|
|
109531
|
-
])
|
|
109532
|
-
});
|
|
109533
|
-
return res.headers.get("location") || null;
|
|
109534
|
-
} catch {
|
|
109535
|
-
return null;
|
|
109536
|
-
}
|
|
109537
|
-
}
|
|
109538
|
-
var getSearchConfig;
|
|
109539
|
-
var init_gemini_search = __esm(() => {
|
|
109540
|
-
init_activity();
|
|
109541
|
-
init_gemini_api();
|
|
109542
|
-
init_gemini_web();
|
|
109543
|
-
init_gemini_web_config();
|
|
109544
|
-
init_perplexity();
|
|
109545
|
-
init_exa();
|
|
109546
|
-
getSearchConfig = createAsyncOwnerState(async () => {
|
|
109547
|
-
const raw = await readWebSearchConfigFile();
|
|
109548
|
-
if (!raw)
|
|
109549
|
-
return { searchProvider: "auto" };
|
|
109550
|
-
return {
|
|
109551
|
-
searchProvider: normalizeSearchProvider(raw.searchProvider ?? raw.provider),
|
|
109552
|
-
searchModel: normalizeSearchModel(raw.searchModel)
|
|
109553
|
-
};
|
|
109554
|
-
});
|
|
109555
|
-
});
|
|
109556
|
-
|
|
109557
109583
|
// dist/builtin/web-access/web-search-formatting.ts
|
|
109558
109584
|
function stripThumbnails(results) {
|
|
109559
109585
|
return results.map(({ thumbnail, frames, ...rest }) => rest);
|
|
@@ -111168,7 +111194,7 @@ async function index_heavy_default(atomic) {
|
|
|
111168
111194
|
} else if (arg === "none" || arg === "summary-review") {
|
|
111169
111195
|
newWorkflow = arg;
|
|
111170
111196
|
} else {
|
|
111171
|
-
ctx.ui.notify(`Unknown option: ${arg}. Use on, off, or summary-review.`, "error");
|
|
111197
|
+
ctx.ui.notify(`Unknown option: ${arg}. Use on, off, none, or summary-review.`, "error");
|
|
111172
111198
|
return;
|
|
111173
111199
|
}
|
|
111174
111200
|
try {
|
|
@@ -111196,7 +111222,7 @@ async function index_heavy_default(atomic) {
|
|
|
111196
111222
|
content: [{ type: "text", text: `Gemini Web browser cookie access is disabled. Set allowBrowserCookies: true in ~/${CONFIG_DIR_NAME5}/web-search.json to enable it.` }],
|
|
111197
111223
|
display: true,
|
|
111198
111224
|
details: { available: false, cookieAccessAllowed: false }
|
|
111199
|
-
}, { triggerTurn:
|
|
111225
|
+
}, { triggerTurn: false, deliverAs: "followUp" });
|
|
111200
111226
|
return;
|
|
111201
111227
|
}
|
|
111202
111228
|
const cookies = await isGeminiWebAvailable();
|
|
@@ -111206,7 +111232,7 @@ async function index_heavy_default(atomic) {
|
|
|
111206
111232
|
content: [{ type: "text", text: "Gemini Web is unavailable. Sign into gemini.google.com in a supported Chromium-based browser." }],
|
|
111207
111233
|
display: true,
|
|
111208
111234
|
details: { available: false, cookieAccessAllowed: true }
|
|
111209
|
-
}, { triggerTurn:
|
|
111235
|
+
}, { triggerTurn: false, deliverAs: "followUp" });
|
|
111210
111236
|
return;
|
|
111211
111237
|
}
|
|
111212
111238
|
const email = await getActiveGoogleEmail(cookies);
|
|
@@ -111216,7 +111242,7 @@ async function index_heavy_default(atomic) {
|
|
|
111216
111242
|
content: [{ type: "text", text }],
|
|
111217
111243
|
display: true,
|
|
111218
111244
|
details: { available: true, email: email ?? null }
|
|
111219
|
-
}, { triggerTurn:
|
|
111245
|
+
}, { triggerTurn: false, deliverAs: "followUp" });
|
|
111220
111246
|
}
|
|
111221
111247
|
});
|
|
111222
111248
|
atomic.registerCommand("search", {
|
|
@@ -111312,9 +111338,10 @@ init_diagnostics();
|
|
|
111312
111338
|
init_dist2();
|
|
111313
111339
|
init_result_renderers();
|
|
111314
111340
|
init_message_renderers();
|
|
111315
|
-
import {
|
|
111316
|
-
|
|
111317
|
-
|
|
111341
|
+
import {
|
|
111342
|
+
getUserConfigPaths as getUserConfigPaths4
|
|
111343
|
+
} from "@bastani/atomic";
|
|
111344
|
+
import { readFileSync } from "node:fs";
|
|
111318
111345
|
import { Type as Type4 } from "@bastani/atomic-ai";
|
|
111319
111346
|
|
|
111320
111347
|
// dist/builtin/web-access/lifecycle-lease.ts
|
|
@@ -111437,11 +111464,19 @@ function renderHeavyToolResult(loadedHeavy, name, args) {
|
|
|
111437
111464
|
}
|
|
111438
111465
|
function getInitialShortcutConfig() {
|
|
111439
111466
|
const defaults = { curate: "ctrl+shift+s", activity: "ctrl+shift+w" };
|
|
111440
|
-
for (const configPath of
|
|
111467
|
+
for (const configPath of getUserConfigPaths4("web-search.json")) {
|
|
111468
|
+
let raw;
|
|
111441
111469
|
try {
|
|
111442
|
-
|
|
111470
|
+
raw = readFileSync(configPath, "utf8");
|
|
111471
|
+
} catch (error) {
|
|
111472
|
+
if (error.code === "ENOENT")
|
|
111443
111473
|
continue;
|
|
111444
|
-
|
|
111474
|
+
if (!reportOwnedWebDiagnostic())
|
|
111475
|
+
console.error(`[pi-web-access] Failed to inspect shortcuts in ${configPath}:`, error);
|
|
111476
|
+
return defaults;
|
|
111477
|
+
}
|
|
111478
|
+
try {
|
|
111479
|
+
const parsed = JSON.parse(raw);
|
|
111445
111480
|
return {
|
|
111446
111481
|
curate: parsed.shortcuts?.curate?.trim() || defaults.curate,
|
|
111447
111482
|
activity: parsed.shortcuts?.activity?.trim() || defaults.activity
|
|
@@ -111449,6 +111484,7 @@ function getInitialShortcutConfig() {
|
|
|
111449
111484
|
} catch (error) {
|
|
111450
111485
|
if (!reportOwnedWebDiagnostic())
|
|
111451
111486
|
console.error(`[pi-web-access] Failed to inspect shortcuts in ${configPath}:`, error);
|
|
111487
|
+
return defaults;
|
|
111452
111488
|
}
|
|
111453
111489
|
}
|
|
111454
111490
|
return defaults;
|