@hasna/mementos 0.14.86 → 0.14.88
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/bun.lock +3 -0
- package/dist/cli/__fixtures__/clean-fallback-stub-server.d.ts +2 -0
- package/dist/cli/__fixtures__/clean-fallback-stub-server.d.ts.map +1 -0
- package/dist/cli/__fixtures__/io-restore-stub-server.d.ts +2 -0
- package/dist/cli/__fixtures__/io-restore-stub-server.d.ts.map +1 -0
- package/dist/cli/brains.d.ts +3 -0
- package/dist/cli/brains.d.ts.map +1 -0
- package/dist/cli/commands/agent.d.ts +3 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/consolidation.d.ts +3 -0
- package/dist/cli/commands/consolidation.d.ts.map +1 -0
- package/dist/cli/commands/entity.d.ts +3 -0
- package/dist/cli/commands/entity.d.ts.map +1 -0
- package/dist/cli/commands/graph.d.ts +3 -0
- package/dist/cli/commands/graph.d.ts.map +1 -0
- package/dist/cli/commands/info-context.d.ts +3 -0
- package/dist/cli/commands/info-context.d.ts.map +1 -0
- package/dist/cli/commands/info-history.d.ts +3 -0
- package/dist/cli/commands/info-history.d.ts.map +1 -0
- package/dist/cli/commands/info-report.d.ts +3 -0
- package/dist/cli/commands/info-report.d.ts.map +1 -0
- package/dist/cli/commands/info-stale.d.ts +3 -0
- package/dist/cli/commands/info-stale.d.ts.map +1 -0
- package/dist/cli/commands/info-stats.d.ts +3 -0
- package/dist/cli/commands/info-stats.d.ts.map +1 -0
- package/dist/cli/commands/info.d.ts +12 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/io-backup.d.ts +3 -0
- package/dist/cli/commands/io-backup.d.ts.map +1 -0
- package/dist/cli/commands/io-clean.d.ts +3 -0
- package/dist/cli/commands/io-clean.d.ts.map +1 -0
- package/dist/cli/commands/io-export.d.ts +3 -0
- package/dist/cli/commands/io-export.d.ts.map +1 -0
- package/dist/cli/commands/io-import.d.ts +3 -0
- package/dist/cli/commands/io-import.d.ts.map +1 -0
- package/dist/cli/commands/io-restore.d.ts +3 -0
- package/dist/cli/commands/io-restore.d.ts.map +1 -0
- package/dist/cli/commands/io.d.ts +12 -0
- package/dist/cli/commands/io.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-bulk.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-bulk.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-chain.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-chain.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-crud.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-crud.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-diff.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-diff.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-list.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-list.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-recall-exit.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-recall-exit.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-recall.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-recall.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-remove.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-remove.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-search.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-search.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-tail.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-tail.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-util.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-util.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-view.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-view.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-watch.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-watch.d.ts.map +1 -0
- package/dist/cli/commands/memory-cmd-when-to-use.d.ts +3 -0
- package/dist/cli/commands/memory-cmd-when-to-use.d.ts.map +1 -0
- package/dist/cli/commands/memory.d.ts +3 -0
- package/dist/cli/commands/memory.d.ts.map +1 -0
- package/dist/cli/commands/project-panel.d.ts +3 -0
- package/dist/cli/commands/project-panel.d.ts.map +1 -0
- package/dist/cli/commands/project.d.ts +3 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/relation.d.ts +3 -0
- package/dist/cli/commands/relation.d.ts.map +1 -0
- package/dist/cli/commands/storage.d.ts +3 -0
- package/dist/cli/commands/storage.d.ts.map +1 -0
- package/dist/cli/commands/system-auto-memory.d.ts +3 -0
- package/dist/cli/commands/system-auto-memory.d.ts.map +1 -0
- package/dist/cli/commands/system-completions.d.ts +13 -0
- package/dist/cli/commands/system-completions.d.ts.map +1 -0
- package/dist/cli/commands/system-config.d.ts +3 -0
- package/dist/cli/commands/system-config.d.ts.map +1 -0
- package/dist/cli/commands/system-doctor.d.ts +3 -0
- package/dist/cli/commands/system-doctor.d.ts.map +1 -0
- package/dist/cli/commands/system-hooks.d.ts +3 -0
- package/dist/cli/commands/system-hooks.d.ts.map +1 -0
- package/dist/cli/commands/system-mcp.d.ts +3 -0
- package/dist/cli/commands/system-mcp.d.ts.map +1 -0
- package/dist/cli/commands/system-misc.d.ts +3 -0
- package/dist/cli/commands/system-misc.d.ts.map +1 -0
- package/dist/cli/commands/system-profile.d.ts +3 -0
- package/dist/cli/commands/system-profile.d.ts.map +1 -0
- package/dist/cli/commands/system-session.d.ts +3 -0
- package/dist/cli/commands/system-session.d.ts.map +1 -0
- package/dist/cli/commands/system-sessions.d.ts +3 -0
- package/dist/cli/commands/system-sessions.d.ts.map +1 -0
- package/dist/cli/commands/system-synthesis.d.ts +3 -0
- package/dist/cli/commands/system-synthesis.d.ts.map +1 -0
- package/dist/cli/commands/system-synthesized-profile.d.ts +3 -0
- package/dist/cli/commands/system-synthesized-profile.d.ts.map +1 -0
- package/dist/cli/commands/system-tools.d.ts +3 -0
- package/dist/cli/commands/system-tools.d.ts.map +1 -0
- package/dist/cli/commands/system-watch.d.ts +3 -0
- package/dist/cli/commands/system-watch.d.ts.map +1 -0
- package/dist/cli/commands/system.d.ts +3 -0
- package/dist/cli/commands/system.d.ts.map +1 -0
- package/dist/cli/exit-codes.d.ts +13 -0
- package/dist/cli/exit-codes.d.ts.map +1 -0
- package/dist/cli/global-options.d.ts +27 -0
- package/dist/cli/global-options.d.ts.map +1 -0
- package/dist/cli/helpers.d.ts +150 -0
- package/dist/cli/helpers.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1150 -695
- package/dist/cli/register-all.d.ts +17 -0
- package/dist/cli/register-all.d.ts.map +1 -0
- package/dist/cli/startup-side-effects.d.ts +9 -0
- package/dist/cli/startup-side-effects.d.ts.map +1 -0
- package/dist/db/__fixtures__/fail-closed-stub-server.d.ts +2 -0
- package/dist/db/__fixtures__/fail-closed-stub-server.d.ts.map +1 -0
- package/dist/db/__fixtures__/list-filter-capture-server.d.ts +2 -0
- package/dist/db/__fixtures__/list-filter-capture-server.d.ts.map +1 -0
- package/dist/db/__fixtures__/list-filter-client-runner.d.ts +2 -0
- package/dist/db/__fixtures__/list-filter-client-runner.d.ts.map +1 -0
- package/dist/db/acl.d.ts +34 -0
- package/dist/db/acl.d.ts.map +1 -0
- package/dist/db/agents.d.ts +35 -0
- package/dist/db/agents.d.ts.map +1 -0
- package/dist/db/analytics.d.ts +124 -0
- package/dist/db/analytics.d.ts.map +1 -0
- package/dist/db/api-mode.d.ts +127 -0
- package/dist/db/api-mode.d.ts.map +1 -0
- package/dist/db/audit.d.ts +53 -0
- package/dist/db/audit.d.ts.map +1 -0
- package/dist/db/database.d.ts +26 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/entities.d.ts +62 -0
- package/dist/db/entities.d.ts.map +1 -0
- package/dist/db/entity-memories.d.ts +34 -0
- package/dist/db/entity-memories.d.ts.map +1 -0
- package/dist/db/feedback.d.ts +9 -0
- package/dist/db/feedback.d.ts.map +1 -0
- package/dist/db/locks.d.ts +63 -0
- package/dist/db/locks.d.ts.map +1 -0
- package/dist/db/machines.d.ts +23 -0
- package/dist/db/machines.d.ts.map +1 -0
- package/dist/db/memories.d.ts +199 -0
- package/dist/db/memories.d.ts.map +1 -0
- package/dist/db/memory-links.d.ts +21 -0
- package/dist/db/memory-links.d.ts.map +1 -0
- package/dist/db/memory-project-link.d.ts +13 -0
- package/dist/db/memory-project-link.d.ts.map +1 -0
- package/dist/db/migrations.d.ts +3 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/pg-migrate.d.ts +27 -0
- package/dist/db/pg-migrate.d.ts.map +1 -0
- package/dist/db/pg-migrations.d.ts +2 -0
- package/dist/db/pg-migrations.d.ts.map +1 -0
- package/dist/db/projects.d.ts +27 -0
- package/dist/db/projects.d.ts.map +1 -0
- package/dist/db/ratings.d.ts +23 -0
- package/dist/db/ratings.d.ts.map +1 -0
- package/dist/db/relations.d.ts +49 -0
- package/dist/db/relations.d.ts.map +1 -0
- package/dist/db/session-jobs.d.ts +67 -0
- package/dist/db/session-jobs.d.ts.map +1 -0
- package/dist/db/store-backend.d.ts +42 -0
- package/dist/db/store-backend.d.ts.map +1 -0
- package/dist/db/subscriptions.d.ts +24 -0
- package/dist/db/subscriptions.d.ts.map +1 -0
- package/dist/db/synthesis.d.ts +101 -0
- package/dist/db/synthesis.d.ts.map +1 -0
- package/dist/db/tasks.d.ts +89 -0
- package/dist/db/tasks.d.ts.map +1 -0
- package/dist/db/tool-events.d.ts +27 -0
- package/dist/db/tool-events.d.ts.map +1 -0
- package/dist/db/webhook_hooks.d.ts +48 -0
- package/dist/db/webhook_hooks.d.ts.map +1 -0
- package/dist/diagnostics/historical-project-registration-receipt.d.ts +39 -0
- package/dist/diagnostics/historical-project-registration-receipt.d.ts.map +1 -0
- package/dist/diagnostics/historical-project-registration-receipt.js +116 -10
- package/dist/generated/storage-kit/backend.d.ts +20 -0
- package/dist/generated/storage-kit/backend.d.ts.map +1 -0
- package/dist/generated/storage-kit/health.d.ts +20 -0
- package/dist/generated/storage-kit/health.d.ts.map +1 -0
- package/dist/generated/storage-kit/index.d.ts +8 -0
- package/dist/generated/storage-kit/index.d.ts.map +1 -0
- package/dist/generated/storage-kit/migrations.d.ts +48 -0
- package/dist/generated/storage-kit/migrations.d.ts.map +1 -0
- package/dist/generated/storage-kit/own.d.ts +11 -0
- package/dist/generated/storage-kit/own.d.ts.map +1 -0
- package/dist/generated/storage-kit/pool.d.ts +35 -0
- package/dist/generated/storage-kit/pool.d.ts.map +1 -0
- package/dist/generated/storage-kit/query.d.ts +36 -0
- package/dist/generated/storage-kit/query.d.ts.map +1 -0
- package/dist/generated/storage-kit/tls.d.ts +53 -0
- package/dist/generated/storage-kit/tls.d.ts.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +806 -541
- package/dist/lib/activation-matcher.d.ts +17 -0
- package/dist/lib/activation-matcher.d.ts.map +1 -0
- package/dist/lib/asmr/categorizer.d.ts +31 -0
- package/dist/lib/asmr/categorizer.d.ts.map +1 -0
- package/dist/lib/asmr/context-agent.d.ts +4 -0
- package/dist/lib/asmr/context-agent.d.ts.map +1 -0
- package/dist/lib/asmr/ensemble.d.ts +23 -0
- package/dist/lib/asmr/ensemble.d.ts.map +1 -0
- package/dist/lib/asmr/fact-agent.d.ts +4 -0
- package/dist/lib/asmr/fact-agent.d.ts.map +1 -0
- package/dist/lib/asmr/index.d.ts +7 -0
- package/dist/lib/asmr/index.d.ts.map +1 -0
- package/dist/lib/asmr/orchestrator.d.ts +4 -0
- package/dist/lib/asmr/orchestrator.d.ts.map +1 -0
- package/dist/lib/asmr/recall.d.ts +3 -0
- package/dist/lib/asmr/recall.d.ts.map +1 -0
- package/dist/lib/asmr/temporal-agent.d.ts +4 -0
- package/dist/lib/asmr/temporal-agent.d.ts.map +1 -0
- package/dist/lib/asmr/types.d.ts +27 -0
- package/dist/lib/asmr/types.d.ts.map +1 -0
- package/dist/lib/auto-inject-orchestrator.d.ts +57 -0
- package/dist/lib/auto-inject-orchestrator.d.ts.map +1 -0
- package/dist/lib/auto-memory-queue.d.ts +48 -0
- package/dist/lib/auto-memory-queue.d.ts.map +1 -0
- package/dist/lib/auto-memory.d.ts +19 -0
- package/dist/lib/auto-memory.d.ts.map +1 -0
- package/dist/lib/bench.d.ts +20 -0
- package/dist/lib/bench.d.ts.map +1 -0
- package/dist/lib/built-in-hooks.d.ts +32 -0
- package/dist/lib/built-in-hooks.d.ts.map +1 -0
- package/dist/lib/channel-pusher.d.ts +39 -0
- package/dist/lib/channel-pusher.d.ts.map +1 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/connectors/files.d.ts +8 -0
- package/dist/lib/connectors/files.d.ts.map +1 -0
- package/dist/lib/connectors/github.d.ts +7 -0
- package/dist/lib/connectors/github.d.ts.map +1 -0
- package/dist/lib/connectors/index.d.ts +12 -0
- package/dist/lib/connectors/index.d.ts.map +1 -0
- package/dist/lib/connectors/notion.d.ts +7 -0
- package/dist/lib/connectors/notion.d.ts.map +1 -0
- package/dist/lib/connectors/types.d.ts +27 -0
- package/dist/lib/connectors/types.d.ts.map +1 -0
- package/dist/lib/consolidation.d.ts +52 -0
- package/dist/lib/consolidation.d.ts.map +1 -0
- package/dist/lib/context-extractor.d.ts +14 -0
- package/dist/lib/context-extractor.d.ts.map +1 -0
- package/dist/lib/context.d.ts +36 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/contradiction.d.ts +50 -0
- package/dist/lib/contradiction.d.ts.map +1 -0
- package/dist/lib/decay.d.ts +35 -0
- package/dist/lib/decay.d.ts.map +1 -0
- package/dist/lib/dedup.d.ts +33 -0
- package/dist/lib/dedup.d.ts.map +1 -0
- package/dist/lib/duration.d.ts +28 -0
- package/dist/lib/duration.d.ts.map +1 -0
- package/dist/lib/embeddings.d.ts +20 -0
- package/dist/lib/embeddings.d.ts.map +1 -0
- package/dist/lib/enum-validation.d.ts +20 -0
- package/dist/lib/enum-validation.d.ts.map +1 -0
- package/dist/lib/export-v1.d.ts +30 -0
- package/dist/lib/export-v1.d.ts.map +1 -0
- package/dist/lib/extractor.d.ts +9 -0
- package/dist/lib/extractor.d.ts.map +1 -0
- package/dist/lib/extractors/audio.d.ts +8 -0
- package/dist/lib/extractors/audio.d.ts.map +1 -0
- package/dist/lib/extractors/index.d.ts +12 -0
- package/dist/lib/extractors/index.d.ts.map +1 -0
- package/dist/lib/extractors/ocr.d.ts +7 -0
- package/dist/lib/extractors/ocr.d.ts.map +1 -0
- package/dist/lib/extractors/pdf.d.ts +7 -0
- package/dist/lib/extractors/pdf.d.ts.map +1 -0
- package/dist/lib/extractors/types.d.ts +12 -0
- package/dist/lib/extractors/types.d.ts.map +1 -0
- package/dist/lib/file-deps.d.ts +27 -0
- package/dist/lib/file-deps.d.ts.map +1 -0
- package/dist/lib/focus.d.ts +58 -0
- package/dist/lib/focus.d.ts.map +1 -0
- package/dist/lib/gatherer.d.ts +16 -0
- package/dist/lib/gatherer.d.ts.map +1 -0
- package/dist/lib/gdpr.d.ts +39 -0
- package/dist/lib/gdpr.d.ts.map +1 -0
- package/dist/lib/hooks.d.ts +50 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/importers/index.d.ts +38 -0
- package/dist/lib/importers/index.d.ts.map +1 -0
- package/dist/lib/injector.d.ts +89 -0
- package/dist/lib/injector.d.ts.map +1 -0
- package/dist/lib/machine-visibility.d.ts +6 -0
- package/dist/lib/machine-visibility.d.ts.map +1 -0
- package/dist/lib/matryoshka.d.ts +50 -0
- package/dist/lib/matryoshka.d.ts.map +1 -0
- package/dist/lib/memory-lock.d.ts +58 -0
- package/dist/lib/memory-lock.d.ts.map +1 -0
- package/dist/lib/model-config.d.ts +14 -0
- package/dist/lib/model-config.d.ts.map +1 -0
- package/dist/lib/open-sessions-connector.d.ts +60 -0
- package/dist/lib/open-sessions-connector.d.ts.map +1 -0
- package/dist/lib/package-version.d.ts +3 -0
- package/dist/lib/package-version.d.ts.map +1 -0
- package/dist/lib/paths.d.ts +51 -0
- package/dist/lib/paths.d.ts.map +1 -0
- package/dist/lib/poisoning.d.ts +19 -0
- package/dist/lib/poisoning.d.ts.map +1 -0
- package/dist/lib/poll.d.ts +17 -0
- package/dist/lib/poll.d.ts.map +1 -0
- package/dist/lib/procedural-extractor.d.ts +21 -0
- package/dist/lib/procedural-extractor.d.ts.map +1 -0
- package/dist/lib/profile-sync.d.ts +20 -0
- package/dist/lib/profile-sync.d.ts.map +1 -0
- package/dist/lib/profile-synthesizer.d.ts +20 -0
- package/dist/lib/profile-synthesizer.d.ts.map +1 -0
- package/dist/lib/project-detect.d.ts +18 -0
- package/dist/lib/project-detect.d.ts.map +1 -0
- package/dist/lib/project-panel.d.ts +7 -0
- package/dist/lib/project-panel.d.ts.map +1 -0
- package/dist/lib/providers/anthropic.d.ts +21 -0
- package/dist/lib/providers/anthropic.d.ts.map +1 -0
- package/dist/lib/providers/base.d.ts +96 -0
- package/dist/lib/providers/base.d.ts.map +1 -0
- package/dist/lib/providers/cerebras.d.ts +20 -0
- package/dist/lib/providers/cerebras.d.ts.map +1 -0
- package/dist/lib/providers/grok.d.ts +19 -0
- package/dist/lib/providers/grok.d.ts.map +1 -0
- package/dist/lib/providers/index.d.ts +7 -0
- package/dist/lib/providers/index.d.ts.map +1 -0
- package/dist/lib/providers/openai-compat.d.ts +18 -0
- package/dist/lib/providers/openai-compat.d.ts.map +1 -0
- package/dist/lib/providers/openai.d.ts +20 -0
- package/dist/lib/providers/openai.d.ts.map +1 -0
- package/dist/lib/providers/registry.d.ts +38 -0
- package/dist/lib/providers/registry.d.ts.map +1 -0
- package/dist/lib/quality.d.ts +16 -0
- package/dist/lib/quality.d.ts.map +1 -0
- package/dist/lib/redact.d.ts +26 -0
- package/dist/lib/redact.d.ts.map +1 -0
- package/dist/lib/reflection.d.ts +83 -0
- package/dist/lib/reflection.d.ts.map +1 -0
- package/dist/lib/retention.d.ts +17 -0
- package/dist/lib/retention.d.ts.map +1 -0
- package/dist/lib/retired-storage-mode.d.ts +11 -0
- package/dist/lib/retired-storage-mode.d.ts.map +1 -0
- package/dist/lib/search.d.ts +52 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/session-auto-resolve.d.ts +28 -0
- package/dist/lib/session-auto-resolve.d.ts.map +1 -0
- package/dist/lib/session-processor.d.ts +38 -0
- package/dist/lib/session-processor.d.ts.map +1 -0
- package/dist/lib/session-queue.d.ts +28 -0
- package/dist/lib/session-queue.d.ts.map +1 -0
- package/dist/lib/session-registry.d.ts +47 -0
- package/dist/lib/session-registry.d.ts.map +1 -0
- package/dist/lib/session-start-briefing.d.ts +10 -0
- package/dist/lib/session-start-briefing.d.ts.map +1 -0
- package/dist/lib/session-watcher.d.ts +30 -0
- package/dist/lib/session-watcher.d.ts.map +1 -0
- package/dist/lib/storage-sync.d.ts +45 -0
- package/dist/lib/storage-sync.d.ts.map +1 -0
- package/dist/lib/sync.d.ts +10 -0
- package/dist/lib/sync.d.ts.map +1 -0
- package/dist/lib/synthesis/corpus-builder.d.ts +30 -0
- package/dist/lib/synthesis/corpus-builder.d.ts.map +1 -0
- package/dist/lib/synthesis/executor.d.ts +14 -0
- package/dist/lib/synthesis/executor.d.ts.map +1 -0
- package/dist/lib/synthesis/index.d.ts +37 -0
- package/dist/lib/synthesis/index.d.ts.map +1 -0
- package/dist/lib/synthesis/llm-analyzer.d.ts +18 -0
- package/dist/lib/synthesis/llm-analyzer.d.ts.map +1 -0
- package/dist/lib/synthesis/metrics.d.ts +13 -0
- package/dist/lib/synthesis/metrics.d.ts.map +1 -0
- package/dist/lib/synthesis/scheduler.d.ts +18 -0
- package/dist/lib/synthesis/scheduler.d.ts.map +1 -0
- package/dist/lib/synthesis/validator.d.ts +19 -0
- package/dist/lib/synthesis/validator.d.ts.map +1 -0
- package/dist/lib/task-runner.d.ts +37 -0
- package/dist/lib/task-runner.d.ts.map +1 -0
- package/dist/lib/tool-lesson-extractor.d.ts +24 -0
- package/dist/lib/tool-lesson-extractor.d.ts.map +1 -0
- package/dist/lib/tool-memory-synthesizer.d.ts +28 -0
- package/dist/lib/tool-memory-synthesizer.d.ts.map +1 -0
- package/dist/lib/topic-clusterer.d.ts +21 -0
- package/dist/lib/topic-clusterer.d.ts.map +1 -0
- package/dist/lib/when-to-use-generator.d.ts +22 -0
- package/dist/lib/when-to-use-generator.d.ts.map +1 -0
- package/dist/mcp/http.d.ts +17 -0
- package/dist/mcp/http.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +978 -554
- package/dist/mcp/memory-broadcast.d.ts +12 -0
- package/dist/mcp/memory-broadcast.d.ts.map +1 -0
- package/dist/mcp/tools/agent-tools.d.ts +3 -0
- package/dist/mcp/tools/agent-tools.d.ts.map +1 -0
- package/dist/mcp/tools/auto-memory-tools.d.ts +5 -0
- package/dist/mcp/tools/auto-memory-tools.d.ts.map +1 -0
- package/dist/mcp/tools/bulk-tools.d.ts +3 -0
- package/dist/mcp/tools/bulk-tools.d.ts.map +1 -0
- package/dist/mcp/tools/consolidation-tools.d.ts +3 -0
- package/dist/mcp/tools/consolidation-tools.d.ts.map +1 -0
- package/dist/mcp/tools/focus-tools.d.ts +3 -0
- package/dist/mcp/tools/focus-tools.d.ts.map +1 -0
- package/dist/mcp/tools/graph-entity-tools.d.ts +3 -0
- package/dist/mcp/tools/graph-entity-tools.d.ts.map +1 -0
- package/dist/mcp/tools/graph-query-tools.d.ts +3 -0
- package/dist/mcp/tools/graph-query-tools.d.ts.map +1 -0
- package/dist/mcp/tools/graph-relation-tools.d.ts +3 -0
- package/dist/mcp/tools/graph-relation-tools.d.ts.map +1 -0
- package/dist/mcp/tools/graph-tools.d.ts +3 -0
- package/dist/mcp/tools/graph-tools.d.ts.map +1 -0
- package/dist/mcp/tools/graph-utils.d.ts +5 -0
- package/dist/mcp/tools/graph-utils.d.ts.map +1 -0
- package/dist/mcp/tools/hook-tools.d.ts +3 -0
- package/dist/mcp/tools/hook-tools.d.ts.map +1 -0
- package/dist/mcp/tools/lock-tools.d.ts +3 -0
- package/dist/mcp/tools/lock-tools.d.ts.map +1 -0
- package/dist/mcp/tools/memory-audit.d.ts +3 -0
- package/dist/mcp/tools/memory-audit.d.ts.map +1 -0
- package/dist/mcp/tools/memory-crud.d.ts +3 -0
- package/dist/mcp/tools/memory-crud.d.ts.map +1 -0
- package/dist/mcp/tools/memory-health.d.ts +3 -0
- package/dist/mcp/tools/memory-health.d.ts.map +1 -0
- package/dist/mcp/tools/memory-history.d.ts +3 -0
- package/dist/mcp/tools/memory-history.d.ts.map +1 -0
- package/dist/mcp/tools/memory-inject.d.ts +3 -0
- package/dist/mcp/tools/memory-inject.d.ts.map +1 -0
- package/dist/mcp/tools/memory-io.d.ts +3 -0
- package/dist/mcp/tools/memory-io.d.ts.map +1 -0
- package/dist/mcp/tools/memory-lifecycle.d.ts +3 -0
- package/dist/mcp/tools/memory-lifecycle.d.ts.map +1 -0
- package/dist/mcp/tools/memory-search.d.ts +3 -0
- package/dist/mcp/tools/memory-search.d.ts.map +1 -0
- package/dist/mcp/tools/memory-stats.d.ts +3 -0
- package/dist/mcp/tools/memory-stats.d.ts.map +1 -0
- package/dist/mcp/tools/memory-tools.d.ts +17 -0
- package/dist/mcp/tools/memory-tools.d.ts.map +1 -0
- package/dist/mcp/tools/memory-utils.d.ts +27 -0
- package/dist/mcp/tools/memory-utils.d.ts.map +1 -0
- package/dist/mcp/tools/memory-validation.d.ts +3 -0
- package/dist/mcp/tools/memory-validation.d.ts.map +1 -0
- package/dist/mcp/tools/project-tools.d.ts +3 -0
- package/dist/mcp/tools/project-tools.d.ts.map +1 -0
- package/dist/mcp/tools/session-tools.d.ts +3 -0
- package/dist/mcp/tools/session-tools.d.ts.map +1 -0
- package/dist/mcp/tools/storage-tools.d.ts +3 -0
- package/dist/mcp/tools/storage-tools.d.ts.map +1 -0
- package/dist/mcp/tools/synthesis-tools.d.ts +3 -0
- package/dist/mcp/tools/synthesis-tools.d.ts.map +1 -0
- package/dist/mcp/tools/system-tools-events.d.ts +3 -0
- package/dist/mcp/tools/system-tools-events.d.ts.map +1 -0
- package/dist/mcp/tools/system-tools-memory-admin.d.ts +3 -0
- package/dist/mcp/tools/system-tools-memory-admin.d.ts.map +1 -0
- package/dist/mcp/tools/system-tools-shared.d.ts +23 -0
- package/dist/mcp/tools/system-tools-shared.d.ts.map +1 -0
- package/dist/mcp/tools/system-tools.d.ts +3 -0
- package/dist/mcp/tools/system-tools.d.ts.map +1 -0
- package/dist/mcp/tools/tool-registry.d.ts +30 -0
- package/dist/mcp/tools/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tools/utility-tools.d.ts +3 -0
- package/dist/mcp/tools/utility-tools.d.ts.map +1 -0
- package/dist/memory-project-link/index.d.ts +2 -0
- package/dist/memory-project-link/index.d.ts.map +1 -0
- package/dist/memory-project-link/schema.d.ts +5 -0
- package/dist/memory-project-link/schema.d.ts.map +1 -0
- package/dist/pg-sync-worker.d.ts +2 -0
- package/dist/pg-sync-worker.d.ts.map +1 -0
- package/dist/project-registration/authority.d.ts +43 -0
- package/dist/project-registration/authority.d.ts.map +1 -0
- package/dist/project-registration/historical-receipt.d.ts +38 -0
- package/dist/project-registration/historical-receipt.d.ts.map +1 -0
- package/dist/project-registration/http.d.ts +32 -0
- package/dist/project-registration/http.d.ts.map +1 -0
- package/dist/project-registration/identity.d.ts +20 -0
- package/dist/project-registration/identity.d.ts.map +1 -0
- package/dist/project-registration/index.d.ts +11 -0
- package/dist/project-registration/index.d.ts.map +1 -0
- package/dist/project-registration/project-references.d.ts +71 -0
- package/dist/project-registration/project-references.d.ts.map +1 -0
- package/dist/project-registration/project-resources.d.ts +22 -0
- package/dist/project-registration/project-resources.d.ts.map +1 -0
- package/dist/project-registration/schema.d.ts +5 -0
- package/dist/project-registration/schema.d.ts.map +1 -0
- package/dist/project-registration/types.d.ts +319 -0
- package/dist/project-registration/types.d.ts.map +1 -0
- package/dist/project-registration.d.ts +2 -0
- package/dist/project-registration.d.ts.map +1 -0
- package/dist/project-registration.js +179 -42
- package/dist/sdk/index.d.ts +987 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/server/auth.d.ts +11 -0
- package/dist/server/auth.d.ts.map +1 -0
- package/dist/server/helpers.d.ts +53 -0
- package/dist/server/helpers.d.ts.map +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +1047 -569
- package/dist/server/openapi.d.ts +2 -0
- package/dist/server/openapi.d.ts.map +1 -0
- package/dist/server/router.d.ts +17 -0
- package/dist/server/router.d.ts.map +1 -0
- package/dist/server/routes/agents.d.ts +2 -0
- package/dist/server/routes/agents.d.ts.map +1 -0
- package/dist/server/routes/entities.d.ts +2 -0
- package/dist/server/routes/entities.d.ts.map +1 -0
- package/dist/server/routes/memories-bulk.d.ts +2 -0
- package/dist/server/routes/memories-bulk.d.ts.map +1 -0
- package/dist/server/routes/memories-crud.d.ts +2 -0
- package/dist/server/routes/memories-crud.d.ts.map +1 -0
- package/dist/server/routes/memories-io.d.ts +2 -0
- package/dist/server/routes/memories-io.d.ts.map +1 -0
- package/dist/server/routes/memories-misc.d.ts +2 -0
- package/dist/server/routes/memories-misc.d.ts.map +1 -0
- package/dist/server/routes/memories-search.d.ts +2 -0
- package/dist/server/routes/memories-search.d.ts.map +1 -0
- package/dist/server/routes/memories-stats.d.ts +2 -0
- package/dist/server/routes/memories-stats.d.ts.map +1 -0
- package/dist/server/routes/memories.d.ts +19 -0
- package/dist/server/routes/memories.d.ts.map +1 -0
- package/dist/server/routes/memory-project-link.d.ts +2 -0
- package/dist/server/routes/memory-project-link.d.ts.map +1 -0
- package/dist/server/routes/project-registration.d.ts +2 -0
- package/dist/server/routes/project-registration.d.ts.map +1 -0
- package/dist/server/routes/projects.d.ts +2 -0
- package/dist/server/routes/projects.d.ts.map +1 -0
- package/dist/server/routes/system-auto-memory.d.ts +2 -0
- package/dist/server/routes/system-auto-memory.d.ts.map +1 -0
- package/dist/server/routes/system-chain.d.ts +2 -0
- package/dist/server/routes/system-chain.d.ts.map +1 -0
- package/dist/server/routes/system-consolidation.d.ts +2 -0
- package/dist/server/routes/system-consolidation.d.ts.map +1 -0
- package/dist/server/routes/system-hooks.d.ts +2 -0
- package/dist/server/routes/system-hooks.d.ts.map +1 -0
- package/dist/server/routes/system-sessions.d.ts +2 -0
- package/dist/server/routes/system-sessions.d.ts.map +1 -0
- package/dist/server/routes/system-subscriptions.d.ts +2 -0
- package/dist/server/routes/system-subscriptions.d.ts.map +1 -0
- package/dist/server/routes/system-synthesis.d.ts +2 -0
- package/dist/server/routes/system-synthesis.d.ts.map +1 -0
- package/dist/server/routes/system-tools.d.ts +2 -0
- package/dist/server/routes/system-tools.d.ts.map +1 -0
- package/dist/server/routes/system.d.ts +2 -0
- package/dist/server/routes/system.d.ts.map +1 -0
- package/dist/server/routes/tasks.d.ts +2 -0
- package/dist/server/routes/tasks.d.ts.map +1 -0
- package/dist/storage.d.ts +298 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +134 -17
- package/dist/test-support/memories-page-stub-server.d.ts +2 -0
- package/dist/test-support/memories-page-stub-server.d.ts.map +1 -0
- package/dist/test-support/memories-page-stub.d.ts +28 -0
- package/dist/test-support/memories-page-stub.d.ts.map +1 -0
- package/dist/test-support/pg-sync-stub-worker.d.ts +2 -0
- package/dist/test-support/pg-sync-stub-worker.d.ts.map +1 -0
- package/dist/test-support/preload-local-store.d.ts +2 -0
- package/dist/test-support/preload-local-store.d.ts.map +1 -0
- package/dist/test-support/project-authority-identity.d.ts +8 -0
- package/dist/test-support/project-authority-identity.d.ts.map +1 -0
- package/dist/test-support/store-isolation.d.ts +108 -0
- package/dist/test-support/store-isolation.d.ts.map +1 -0
- package/dist/test-support/strip-ansi.d.ts +3 -0
- package/dist/test-support/strip-ansi.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +136 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +482 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +6 -4
- package/postinstall.mjs +34 -0
package/dist/mcp/index.js
CHANGED
|
@@ -246,11 +246,119 @@ var init_retired_storage_mode = __esm(() => {
|
|
|
246
246
|
];
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
//
|
|
250
|
-
import { Database } from "bun:sqlite";
|
|
251
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
249
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
252
250
|
import { homedir } from "os";
|
|
253
251
|
import { join } from "path";
|
|
252
|
+
function assertApp(app) {
|
|
253
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
254
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
255
|
+
}
|
|
256
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
257
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function envOf(options) {
|
|
261
|
+
return options.env ?? process.env;
|
|
262
|
+
}
|
|
263
|
+
function envValue(options, kind) {
|
|
264
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
265
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
266
|
+
}
|
|
267
|
+
function isMacOS(platform) {
|
|
268
|
+
return platform === "darwin";
|
|
269
|
+
}
|
|
270
|
+
function baseDir(kind, options) {
|
|
271
|
+
const override = envValue(options, kind);
|
|
272
|
+
if (override)
|
|
273
|
+
return override;
|
|
274
|
+
const home = options.home ?? homedir();
|
|
275
|
+
const platform = options.platform ?? process.platform;
|
|
276
|
+
if (isMacOS(platform)) {
|
|
277
|
+
switch (kind) {
|
|
278
|
+
case "config":
|
|
279
|
+
case "data":
|
|
280
|
+
return join(home, "Library", "Application Support", "Hasna");
|
|
281
|
+
case "cache":
|
|
282
|
+
return join(home, "Library", "Caches", "Hasna");
|
|
283
|
+
case "state":
|
|
284
|
+
return join(home, "Library", "Logs", "Hasna");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
switch (kind) {
|
|
288
|
+
case "config":
|
|
289
|
+
return join(home, ".config", "hasna");
|
|
290
|
+
case "data":
|
|
291
|
+
return join(home, ".local", "share", "hasna");
|
|
292
|
+
case "state":
|
|
293
|
+
return join(home, ".local", "state", "hasna");
|
|
294
|
+
case "cache":
|
|
295
|
+
return join(home, ".cache", "hasna");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function resolvePath(kind, options) {
|
|
299
|
+
assertApp(options.app);
|
|
300
|
+
const appSegment = options.internal === true ? join("internal", options.app) : options.app;
|
|
301
|
+
return join(baseDir(kind, options), appSegment);
|
|
302
|
+
}
|
|
303
|
+
function dataDir(options) {
|
|
304
|
+
return resolvePath("data", options);
|
|
305
|
+
}
|
|
306
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
307
|
+
var init_dist = __esm(() => {
|
|
308
|
+
KIND_ENV = {
|
|
309
|
+
config: "HASNA_CONFIG_HOME",
|
|
310
|
+
data: "HASNA_DATA_HOME",
|
|
311
|
+
state: "HASNA_STATE_HOME",
|
|
312
|
+
cache: "HASNA_CACHE_HOME"
|
|
313
|
+
};
|
|
314
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// src/lib/paths.ts
|
|
318
|
+
import { existsSync } from "fs";
|
|
319
|
+
import { homedir as homedir2 } from "os";
|
|
320
|
+
import { join as join2, resolve } from "path";
|
|
321
|
+
function effectiveHome() {
|
|
322
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
|
|
323
|
+
}
|
|
324
|
+
function legacyDataRoot() {
|
|
325
|
+
return join2(effectiveHome(), ".hasna", "mementos");
|
|
326
|
+
}
|
|
327
|
+
function resolverDataRoot() {
|
|
328
|
+
return dataDir({
|
|
329
|
+
app: "mementos",
|
|
330
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function adoptResolverDataRoot(resolved, env = process.env) {
|
|
334
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
335
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
336
|
+
return true;
|
|
337
|
+
return existsSync(join2(resolved, "mementos.db"));
|
|
338
|
+
}
|
|
339
|
+
function exactDataRoot() {
|
|
340
|
+
for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
|
|
341
|
+
const dir = process.env[key]?.trim();
|
|
342
|
+
if (dir)
|
|
343
|
+
return resolve(dir);
|
|
344
|
+
}
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
function getDataRoot() {
|
|
348
|
+
const exact = exactDataRoot();
|
|
349
|
+
if (exact)
|
|
350
|
+
return exact;
|
|
351
|
+
const resolved = resolverDataRoot();
|
|
352
|
+
return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
|
|
353
|
+
}
|
|
354
|
+
var init_paths = __esm(() => {
|
|
355
|
+
init_dist();
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// src/storage.ts
|
|
359
|
+
import { Database } from "bun:sqlite";
|
|
360
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
361
|
+
import { join as join3 } from "path";
|
|
254
362
|
import { fileURLToPath } from "url";
|
|
255
363
|
import { Worker } from "worker_threads";
|
|
256
364
|
import pg from "pg";
|
|
@@ -500,7 +608,7 @@ function readEnv(name) {
|
|
|
500
608
|
return value ? value : null;
|
|
501
609
|
}
|
|
502
610
|
function readConfigFile() {
|
|
503
|
-
if (!
|
|
611
|
+
if (!existsSync2(STORAGE_CONFIG_PATH)) {
|
|
504
612
|
return {};
|
|
505
613
|
}
|
|
506
614
|
try {
|
|
@@ -509,6 +617,9 @@ function readConfigFile() {
|
|
|
509
617
|
return {};
|
|
510
618
|
}
|
|
511
619
|
}
|
|
620
|
+
function getConfigPath() {
|
|
621
|
+
return STORAGE_CONFIG_PATH;
|
|
622
|
+
}
|
|
512
623
|
function getStorageDatabaseEnv() {
|
|
513
624
|
for (const env of DATABASE_ENV_NAMES) {
|
|
514
625
|
if (readEnv(env.name))
|
|
@@ -745,11 +856,7 @@ function getStorageStatus() {
|
|
|
745
856
|
function getConfiguredConnectionString() {
|
|
746
857
|
return getStorageDatabaseUrl() ?? undefined;
|
|
747
858
|
}
|
|
748
|
-
function
|
|
749
|
-
assertNoLegacyStorageMode2();
|
|
750
|
-
if (!isServerContext()) {
|
|
751
|
-
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the HTTP API: set HASNA_MEMENTOS_API_URL and " + "HASNA_MEMENTOS_API_KEY (and unset HASNA_MEMENTOS_DATABASE_URL).");
|
|
752
|
-
}
|
|
859
|
+
function resolveConfiguredConnectionString(dbName) {
|
|
753
860
|
const envConnectionString = getConfiguredConnectionString();
|
|
754
861
|
if (envConnectionString) {
|
|
755
862
|
const validation = validatePostgresConnectionString(envConnectionString);
|
|
@@ -768,7 +875,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
768
875
|
missing.push("storage.rds.username");
|
|
769
876
|
}
|
|
770
877
|
if (missing.length > 0) {
|
|
771
|
-
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure
|
|
878
|
+
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
|
|
772
879
|
}
|
|
773
880
|
const password = process.env[password_env];
|
|
774
881
|
if (!password) {
|
|
@@ -777,6 +884,17 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
777
884
|
const sslParam = ssl ? "?sslmode=require" : "";
|
|
778
885
|
return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
|
|
779
886
|
}
|
|
887
|
+
function getStorageConnectionString(dbName = "mementos") {
|
|
888
|
+
assertNoLegacyStorageMode2();
|
|
889
|
+
if (!isServerContext()) {
|
|
890
|
+
throw new Error("Refusing to construct an RDS Postgres DSN outside the mementos-serve server. " + "The raw database DSN is NEVER distributed to client machines. " + "Clients must use the HTTP API: set HASNA_MEMENTOS_API_URL and " + "HASNA_MEMENTOS_API_KEY (and unset HASNA_MEMENTOS_DATABASE_URL).");
|
|
891
|
+
}
|
|
892
|
+
return resolveConfiguredConnectionString(dbName);
|
|
893
|
+
}
|
|
894
|
+
function getStorageConnectionStringForOperator(dbName = "mementos") {
|
|
895
|
+
assertNoLegacyStorageMode2();
|
|
896
|
+
return resolveConfiguredConnectionString(dbName);
|
|
897
|
+
}
|
|
780
898
|
function isSyncExcludedTable(table) {
|
|
781
899
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((pattern) => pattern.test(table));
|
|
782
900
|
}
|
|
@@ -935,6 +1053,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
935
1053
|
var init_storage = __esm(() => {
|
|
936
1054
|
init_backend();
|
|
937
1055
|
init_retired_storage_mode();
|
|
1056
|
+
init_paths();
|
|
938
1057
|
PgSyncPool = class PgSyncPool {
|
|
939
1058
|
worker;
|
|
940
1059
|
status;
|
|
@@ -952,12 +1071,12 @@ var init_storage = __esm(() => {
|
|
|
952
1071
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
953
1072
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
954
1073
|
const candidates = [
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1074
|
+
join3(here, `pg-sync-worker${ext}`),
|
|
1075
|
+
join3(here, "..", `pg-sync-worker${ext}`),
|
|
1076
|
+
join3(here, "..", "..", `pg-sync-worker${ext}`)
|
|
958
1077
|
];
|
|
959
1078
|
for (const candidate of candidates) {
|
|
960
|
-
if (
|
|
1079
|
+
if (existsSync2(candidate))
|
|
961
1080
|
return candidate;
|
|
962
1081
|
}
|
|
963
1082
|
return candidates[0];
|
|
@@ -1044,7 +1163,7 @@ var init_storage = __esm(() => {
|
|
|
1044
1163
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
1045
1164
|
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
1046
1165
|
};
|
|
1047
|
-
LOCAL_DATA_DIR =
|
|
1166
|
+
LOCAL_DATA_DIR = getDataRoot();
|
|
1048
1167
|
DEFAULT_STORAGE_CONFIG = {
|
|
1049
1168
|
rds: {
|
|
1050
1169
|
host: "",
|
|
@@ -1059,8 +1178,8 @@ var init_storage = __esm(() => {
|
|
|
1059
1178
|
schedule_minutes: 0
|
|
1060
1179
|
}
|
|
1061
1180
|
};
|
|
1062
|
-
STORAGE_CONFIG_DIR =
|
|
1063
|
-
STORAGE_CONFIG_PATH =
|
|
1181
|
+
STORAGE_CONFIG_DIR = join3(LOCAL_DATA_DIR, "storage");
|
|
1182
|
+
STORAGE_CONFIG_PATH = join3(STORAGE_CONFIG_DIR, "config.json");
|
|
1064
1183
|
DATABASE_ENV_NAMES = [
|
|
1065
1184
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
1066
1185
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
@@ -1085,7 +1204,7 @@ var init_storage = __esm(() => {
|
|
|
1085
1204
|
|
|
1086
1205
|
// src/db/api-mode.ts
|
|
1087
1206
|
import { tmpdir } from "os";
|
|
1088
|
-
import { join as
|
|
1207
|
+
import { join as join4 } from "path";
|
|
1089
1208
|
import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
|
|
1090
1209
|
import { randomUUID } from "crypto";
|
|
1091
1210
|
function firstEnv2(keys) {
|
|
@@ -1195,7 +1314,7 @@ x-api-key: ${cfg.apiKey}
|
|
|
1195
1314
|
];
|
|
1196
1315
|
let bodyFile;
|
|
1197
1316
|
if (hasBody) {
|
|
1198
|
-
bodyFile =
|
|
1317
|
+
bodyFile = join4(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
|
|
1199
1318
|
writeFileSync2(bodyFile, JSON.stringify(body), { mode: 384 });
|
|
1200
1319
|
args.push("--data-binary", `@${bodyFile}`);
|
|
1201
1320
|
}
|
|
@@ -2680,18 +2799,18 @@ __export(exports_database, {
|
|
|
2680
2799
|
escapeLikePrefix: () => escapeLikePrefix,
|
|
2681
2800
|
closeDatabase: () => closeDatabase
|
|
2682
2801
|
});
|
|
2683
|
-
import { existsSync as
|
|
2684
|
-
import { dirname, join as
|
|
2802
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, cpSync } from "fs";
|
|
2803
|
+
import { dirname, join as join5, resolve as resolve2 } from "path";
|
|
2685
2804
|
function isInMemoryDb(path) {
|
|
2686
2805
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
2687
2806
|
}
|
|
2688
2807
|
function findNearestMementosDb(startDir) {
|
|
2689
|
-
let dir =
|
|
2808
|
+
let dir = resolve2(startDir);
|
|
2690
2809
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2691
|
-
const legacyHomeDb =
|
|
2810
|
+
const legacyHomeDb = resolve2(home, ".mementos", "mementos.db");
|
|
2692
2811
|
while (true) {
|
|
2693
|
-
const candidate =
|
|
2694
|
-
if (
|
|
2812
|
+
const candidate = join5(dir, ".mementos", "mementos.db");
|
|
2813
|
+
if (existsSync3(candidate) && resolve2(candidate) !== legacyHomeDb)
|
|
2695
2814
|
return candidate;
|
|
2696
2815
|
const parent = dirname(dir);
|
|
2697
2816
|
if (parent === dir)
|
|
@@ -2701,9 +2820,9 @@ function findNearestMementosDb(startDir) {
|
|
|
2701
2820
|
return null;
|
|
2702
2821
|
}
|
|
2703
2822
|
function findGitRoot(startDir) {
|
|
2704
|
-
let dir =
|
|
2823
|
+
let dir = resolve2(startDir);
|
|
2705
2824
|
while (true) {
|
|
2706
|
-
if (
|
|
2825
|
+
if (existsSync3(join5(dir, ".git")))
|
|
2707
2826
|
return dir;
|
|
2708
2827
|
const parent = dirname(dir);
|
|
2709
2828
|
if (parent === dir)
|
|
@@ -2714,10 +2833,10 @@ function findGitRoot(startDir) {
|
|
|
2714
2833
|
}
|
|
2715
2834
|
function migrateGlobalDir() {
|
|
2716
2835
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2717
|
-
const newDir =
|
|
2718
|
-
const oldDir =
|
|
2719
|
-
if (!
|
|
2720
|
-
mkdirSync2(
|
|
2836
|
+
const newDir = getDataRoot();
|
|
2837
|
+
const oldDir = join5(home, ".mementos");
|
|
2838
|
+
if (!existsSync3(newDir) && existsSync3(oldDir)) {
|
|
2839
|
+
mkdirSync2(dirname(newDir), { recursive: true });
|
|
2721
2840
|
cpSync(oldDir, newDir, { recursive: true });
|
|
2722
2841
|
}
|
|
2723
2842
|
}
|
|
@@ -2734,18 +2853,17 @@ function getDbPath() {
|
|
|
2734
2853
|
if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
|
|
2735
2854
|
const gitRoot = findGitRoot(cwd);
|
|
2736
2855
|
if (gitRoot) {
|
|
2737
|
-
return
|
|
2856
|
+
return join5(gitRoot, ".mementos", "mementos.db");
|
|
2738
2857
|
}
|
|
2739
2858
|
}
|
|
2740
2859
|
migrateGlobalDir();
|
|
2741
|
-
|
|
2742
|
-
return join3(home, ".hasna", "mementos", "mementos.db");
|
|
2860
|
+
return join5(getDataRoot(), "mementos.db");
|
|
2743
2861
|
}
|
|
2744
2862
|
function ensureDir(filePath) {
|
|
2745
2863
|
if (isInMemoryDb(filePath))
|
|
2746
2864
|
return;
|
|
2747
|
-
const dir = dirname(
|
|
2748
|
-
if (!
|
|
2865
|
+
const dir = dirname(resolve2(filePath));
|
|
2866
|
+
if (!existsSync3(dir)) {
|
|
2749
2867
|
mkdirSync2(dir, { recursive: true });
|
|
2750
2868
|
}
|
|
2751
2869
|
}
|
|
@@ -2883,6 +3001,7 @@ var init_database = __esm(() => {
|
|
|
2883
3001
|
init_storage();
|
|
2884
3002
|
init_api_mode();
|
|
2885
3003
|
init_migrations();
|
|
3004
|
+
init_paths();
|
|
2886
3005
|
ALLOWED_TABLES = new Set([
|
|
2887
3006
|
"memories",
|
|
2888
3007
|
"agents",
|
|
@@ -3406,12 +3525,22 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
3406
3525
|
const effectiveMode = dedupeMode === "overwrite" ? "merge" : dedupeMode === "version-fork" ? "create" : dedupeMode;
|
|
3407
3526
|
if (effectiveMode === "error") {
|
|
3408
3527
|
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
3409
|
-
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
3528
|
+
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
3410
3529
|
LIMIT 1`).get(input.key, input.scope || "private", input.project_id || "");
|
|
3411
3530
|
if (existing) {
|
|
3412
3531
|
throw new MemoryConflictError(input.key, existing);
|
|
3413
3532
|
}
|
|
3414
3533
|
}
|
|
3534
|
+
if (effectiveMode === "create") {
|
|
3535
|
+
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
3536
|
+
WHERE key = ? AND scope = ?
|
|
3537
|
+
AND COALESCE(agent_id, '') = ?
|
|
3538
|
+
AND COALESCE(project_id, '') = ?
|
|
3539
|
+
AND COALESCE(session_id, '') = ?`).get(input.key, input.scope || "private", input.agent_id || "", input.project_id || "", input.session_id || "");
|
|
3540
|
+
if (existing) {
|
|
3541
|
+
throw new MemoryConflictError(input.key, existing);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3415
3544
|
if (effectiveMode === "merge") {
|
|
3416
3545
|
const existing = d.query(`SELECT id, version FROM memories
|
|
3417
3546
|
WHERE key = ? AND scope = ?
|
|
@@ -4063,6 +4192,17 @@ function updateMemory(id, input, db) {
|
|
|
4063
4192
|
if (existing.version !== input.version) {
|
|
4064
4193
|
throw new VersionConflictError(id, input.version, existing.version);
|
|
4065
4194
|
}
|
|
4195
|
+
if (input.scope !== undefined && input.scope !== existing.scope) {
|
|
4196
|
+
const conflict = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
4197
|
+
WHERE key = ? AND scope = ?
|
|
4198
|
+
AND COALESCE(agent_id, '') = ?
|
|
4199
|
+
AND COALESCE(project_id, '') = ?
|
|
4200
|
+
AND COALESCE(session_id, '') = ?
|
|
4201
|
+
AND id != ?`).get(existing.key, input.scope, existing.agent_id || "", existing.project_id || "", existing.session_id || "", memoryId);
|
|
4202
|
+
if (conflict) {
|
|
4203
|
+
throw new MemoryConflictError(existing.key, conflict);
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4066
4206
|
const sets = ["version = version + 1", "updated_at = ?"];
|
|
4067
4207
|
const params = [now()];
|
|
4068
4208
|
if (input.value !== undefined) {
|
|
@@ -4412,6 +4552,8 @@ var init_machines = __esm(() => {
|
|
|
4412
4552
|
});
|
|
4413
4553
|
|
|
4414
4554
|
// src/db/webhook_hooks.ts
|
|
4555
|
+
import { isIP } from "net";
|
|
4556
|
+
import { lookup as dnsLookup } from "dns/promises";
|
|
4415
4557
|
function parseRow(row) {
|
|
4416
4558
|
return {
|
|
4417
4559
|
id: row["id"],
|
|
@@ -4428,7 +4570,153 @@ function parseRow(row) {
|
|
|
4428
4570
|
failureCount: row["failure_count"]
|
|
4429
4571
|
};
|
|
4430
4572
|
}
|
|
4431
|
-
function
|
|
4573
|
+
function isBlockedIpv4(parts) {
|
|
4574
|
+
const a = parts[0];
|
|
4575
|
+
const b = parts[1];
|
|
4576
|
+
if (a === 0)
|
|
4577
|
+
return true;
|
|
4578
|
+
if (a === 127)
|
|
4579
|
+
return true;
|
|
4580
|
+
if (a === 169 && b === 254)
|
|
4581
|
+
return true;
|
|
4582
|
+
if (a === 10)
|
|
4583
|
+
return true;
|
|
4584
|
+
if (a === 172 && b >= 16 && b <= 31)
|
|
4585
|
+
return true;
|
|
4586
|
+
if (a === 192 && b === 168)
|
|
4587
|
+
return true;
|
|
4588
|
+
return false;
|
|
4589
|
+
}
|
|
4590
|
+
function isBlockedIpv6(bytes) {
|
|
4591
|
+
const mapped = bytes.slice(0, 10).every((b) => b === 0) && bytes[10] === 255 && bytes[11] === 255;
|
|
4592
|
+
if (mapped)
|
|
4593
|
+
return isBlockedIpv4(bytes.slice(12, 16));
|
|
4594
|
+
if (bytes.every((b) => b === 0))
|
|
4595
|
+
return true;
|
|
4596
|
+
if (bytes.slice(0, 15).every((b) => b === 0) && bytes[15] === 1)
|
|
4597
|
+
return true;
|
|
4598
|
+
if ((bytes[0] & 254) === 252)
|
|
4599
|
+
return true;
|
|
4600
|
+
if (bytes[0] === 254 && (bytes[1] & 192) === 128)
|
|
4601
|
+
return true;
|
|
4602
|
+
return false;
|
|
4603
|
+
}
|
|
4604
|
+
function quadToGroups(quad) {
|
|
4605
|
+
const nums = quad.split(".").map((p) => Number(p));
|
|
4606
|
+
const [a, b, c, d] = nums;
|
|
4607
|
+
const valid = [a, b, c, d].every((n) => n !== undefined && Number.isInteger(n) && n >= 0 && n <= 255);
|
|
4608
|
+
if (!valid)
|
|
4609
|
+
return null;
|
|
4610
|
+
return [a << 8 | b, c << 8 | d];
|
|
4611
|
+
}
|
|
4612
|
+
function parseIpv6Bytes(host) {
|
|
4613
|
+
const groups = host.split("::");
|
|
4614
|
+
if (groups.length > 2)
|
|
4615
|
+
return null;
|
|
4616
|
+
const headRaw = groups[0] ?? "";
|
|
4617
|
+
const tailRaw = groups[1] ?? "";
|
|
4618
|
+
const head = headRaw === "" ? [] : headRaw.split(":");
|
|
4619
|
+
const tail = tailRaw === "" ? [] : tailRaw.split(":");
|
|
4620
|
+
const headNums = [];
|
|
4621
|
+
for (const g of head) {
|
|
4622
|
+
if (!/^[0-9a-f]{1,4}$/i.test(g))
|
|
4623
|
+
return null;
|
|
4624
|
+
headNums.push(parseInt(g, 16));
|
|
4625
|
+
}
|
|
4626
|
+
const tailNums = [];
|
|
4627
|
+
for (const g of tail) {
|
|
4628
|
+
if (/^\d+\.\d+\.\d+\.\d+$/.test(g)) {
|
|
4629
|
+
const quads = quadToGroups(g);
|
|
4630
|
+
if (!quads)
|
|
4631
|
+
return null;
|
|
4632
|
+
tailNums.push(...quads);
|
|
4633
|
+
} else if (/^[0-9a-f]{1,4}$/i.test(g)) {
|
|
4634
|
+
tailNums.push(parseInt(g, 16));
|
|
4635
|
+
} else {
|
|
4636
|
+
return null;
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
const hasCompression = groups.length === 2;
|
|
4640
|
+
if (!hasCompression && headNums.length !== 8)
|
|
4641
|
+
return null;
|
|
4642
|
+
if (hasCompression && headNums.length + tailNums.length >= 8)
|
|
4643
|
+
return null;
|
|
4644
|
+
const zeros = 8 - headNums.length - tailNums.length;
|
|
4645
|
+
const all = [...headNums, ...new Array(zeros).fill(0), ...tailNums];
|
|
4646
|
+
const bytes = [];
|
|
4647
|
+
for (const n of all) {
|
|
4648
|
+
bytes.push(n >> 8 & 255, n & 255);
|
|
4649
|
+
}
|
|
4650
|
+
return bytes;
|
|
4651
|
+
}
|
|
4652
|
+
function defaultResolveHost(hostname2) {
|
|
4653
|
+
return dnsLookup(hostname2, { all: true, verbatim: true });
|
|
4654
|
+
}
|
|
4655
|
+
function assertResolvedAddressPublic(address, url) {
|
|
4656
|
+
const version = isIP(address);
|
|
4657
|
+
if (version === 4) {
|
|
4658
|
+
if (isBlockedIpv4(address.split(".").map((p) => Number(p)))) {
|
|
4659
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4660
|
+
}
|
|
4661
|
+
} else if (version === 6) {
|
|
4662
|
+
const bytes = parseIpv6Bytes(address);
|
|
4663
|
+
if (!bytes || isBlockedIpv6(bytes)) {
|
|
4664
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4665
|
+
}
|
|
4666
|
+
} else {
|
|
4667
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
async function validateWebhookHandlerUrl(url, opts) {
|
|
4671
|
+
const resolveHost = opts?.lookup ?? defaultResolveHost;
|
|
4672
|
+
let parsed;
|
|
4673
|
+
try {
|
|
4674
|
+
parsed = new URL(url);
|
|
4675
|
+
} catch {
|
|
4676
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 must be a valid http(s) URL`);
|
|
4677
|
+
}
|
|
4678
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
4679
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 only http and https are allowed`);
|
|
4680
|
+
}
|
|
4681
|
+
if (parsed.username || parsed.password) {
|
|
4682
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 embedded credentials are not allowed`);
|
|
4683
|
+
}
|
|
4684
|
+
const host = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
4685
|
+
if (host === "localhost" || host.endsWith(".localhost")) {
|
|
4686
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4687
|
+
}
|
|
4688
|
+
const version = isIP(host);
|
|
4689
|
+
if (version === 4 || version === 6) {
|
|
4690
|
+
if (version === 4) {
|
|
4691
|
+
if (isBlockedIpv4(host.split(".").map((p) => Number(p)))) {
|
|
4692
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4693
|
+
}
|
|
4694
|
+
} else {
|
|
4695
|
+
const bytes = parseIpv6Bytes(host);
|
|
4696
|
+
if (!bytes || isBlockedIpv6(bytes)) {
|
|
4697
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
return;
|
|
4701
|
+
}
|
|
4702
|
+
if (/^[0-9]+(\.[0-9]+)*$/.test(host) || /^0x[0-9a-f]+$/i.test(host) || host.includes("%")) {
|
|
4703
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4704
|
+
}
|
|
4705
|
+
let addrs;
|
|
4706
|
+
try {
|
|
4707
|
+
addrs = await resolveHost(host);
|
|
4708
|
+
} catch {
|
|
4709
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4710
|
+
}
|
|
4711
|
+
if (addrs.length === 0) {
|
|
4712
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
4713
|
+
}
|
|
4714
|
+
for (const { address } of addrs) {
|
|
4715
|
+
assertResolvedAddressPublic(address, url);
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
async function createWebhookHook(input, db, opts) {
|
|
4719
|
+
await validateWebhookHandlerUrl(input.handlerUrl, opts);
|
|
4432
4720
|
if (!db && isApiMode()) {
|
|
4433
4721
|
const { data } = apiJson("POST", "/webhooks", {
|
|
4434
4722
|
type: input.type,
|
|
@@ -4546,6 +4834,7 @@ function recordWebhookInvocation(id, success, db) {
|
|
|
4546
4834
|
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1, failure_count = failure_count + 1 WHERE id = ?", [id]);
|
|
4547
4835
|
}
|
|
4548
4836
|
}
|
|
4837
|
+
var BLOCKED_TARGET_MESSAGE = "Invalid webhook handler URL \u2014 loopback, link-local, and private network targets are not allowed";
|
|
4549
4838
|
var init_webhook_hooks = __esm(() => {
|
|
4550
4839
|
init_database();
|
|
4551
4840
|
init_api_mode();
|
|
@@ -5398,7 +5687,9 @@ function scoreResults(rows, queryLower, graphBoostedIds) {
|
|
|
5398
5687
|
scored.sort((a, b) => {
|
|
5399
5688
|
if (b.score !== a.score)
|
|
5400
5689
|
return b.score - a.score;
|
|
5401
|
-
|
|
5690
|
+
if (b.memory.importance !== a.memory.importance)
|
|
5691
|
+
return b.memory.importance - a.memory.importance;
|
|
5692
|
+
return a.memory.id.localeCompare(b.memory.id);
|
|
5402
5693
|
});
|
|
5403
5694
|
return scored;
|
|
5404
5695
|
}
|
|
@@ -7251,6 +7542,7 @@ var init_contradiction = __esm(() => {
|
|
|
7251
7542
|
var exports_built_in_hooks = {};
|
|
7252
7543
|
__export(exports_built_in_hooks, {
|
|
7253
7544
|
reloadWebhooks: () => reloadWebhooks,
|
|
7545
|
+
makeWebhookHandler: () => makeWebhookHandler,
|
|
7254
7546
|
loadWebhooksFromDb: () => loadWebhooksFromDb
|
|
7255
7547
|
});
|
|
7256
7548
|
async function getAutoMemory() {
|
|
@@ -7260,13 +7552,19 @@ async function getAutoMemory() {
|
|
|
7260
7552
|
}
|
|
7261
7553
|
return _processConversationTurn;
|
|
7262
7554
|
}
|
|
7263
|
-
function loadWebhooksFromDb() {
|
|
7555
|
+
async function loadWebhooksFromDb() {
|
|
7264
7556
|
if (_webhooksLoaded)
|
|
7265
7557
|
return;
|
|
7266
7558
|
_webhooksLoaded = true;
|
|
7267
7559
|
try {
|
|
7268
7560
|
const webhooks = listWebhookHooks({ enabled: true });
|
|
7269
7561
|
for (const wh of webhooks) {
|
|
7562
|
+
try {
|
|
7563
|
+
await validateWebhookHandlerUrl(wh.handlerUrl);
|
|
7564
|
+
} catch (err) {
|
|
7565
|
+
console.error(`[hooks] Skipping webhook ${wh.id} (${wh.type}): ${err instanceof Error ? err.message : String(err)}`);
|
|
7566
|
+
continue;
|
|
7567
|
+
}
|
|
7270
7568
|
hookRegistry.register({
|
|
7271
7569
|
type: wh.type,
|
|
7272
7570
|
blocking: wh.blocking,
|
|
@@ -7284,9 +7582,10 @@ function loadWebhooksFromDb() {
|
|
|
7284
7582
|
console.error("[hooks] Failed to load webhooks from DB:", err);
|
|
7285
7583
|
}
|
|
7286
7584
|
}
|
|
7287
|
-
function makeWebhookHandler(webhookId, url) {
|
|
7585
|
+
function makeWebhookHandler(webhookId, url, opts) {
|
|
7288
7586
|
return async (context) => {
|
|
7289
7587
|
try {
|
|
7588
|
+
await validateWebhookHandlerUrl(url, opts);
|
|
7290
7589
|
const res = await fetch(url, {
|
|
7291
7590
|
method: "POST",
|
|
7292
7591
|
headers: { "Content-Type": "application/json" },
|
|
@@ -7299,9 +7598,9 @@ function makeWebhookHandler(webhookId, url) {
|
|
|
7299
7598
|
}
|
|
7300
7599
|
};
|
|
7301
7600
|
}
|
|
7302
|
-
function reloadWebhooks() {
|
|
7601
|
+
async function reloadWebhooks() {
|
|
7303
7602
|
_webhooksLoaded = false;
|
|
7304
|
-
loadWebhooksFromDb();
|
|
7603
|
+
await loadWebhooksFromDb();
|
|
7305
7604
|
}
|
|
7306
7605
|
var _processConversationTurn = null, _webhooksLoaded = false;
|
|
7307
7606
|
var init_built_in_hooks = __esm(() => {
|
|
@@ -11604,14 +11903,14 @@ var init_export_v1 = __esm(() => {
|
|
|
11604
11903
|
});
|
|
11605
11904
|
|
|
11606
11905
|
// src/lib/config.ts
|
|
11607
|
-
import { existsSync as
|
|
11608
|
-
import { homedir as
|
|
11609
|
-
import { basename as basename2, dirname as dirname4, join as
|
|
11906
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync3, readdirSync as readdirSync2, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
|
|
11907
|
+
import { homedir as homedir3 } from "os";
|
|
11908
|
+
import { basename as basename2, dirname as dirname4, join as join9, resolve as resolve4 } from "path";
|
|
11610
11909
|
function isInMemoryDb2(path) {
|
|
11611
11910
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
11612
11911
|
}
|
|
11613
11912
|
function homeDir() {
|
|
11614
|
-
return process.env["HOME"] || process.env["USERPROFILE"] ||
|
|
11913
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir3();
|
|
11615
11914
|
}
|
|
11616
11915
|
function deepMerge(target, source) {
|
|
11617
11916
|
const result = { ...target };
|
|
@@ -11633,9 +11932,9 @@ function isValidCategory(value) {
|
|
|
11633
11932
|
return VALID_CATEGORIES.includes(value);
|
|
11634
11933
|
}
|
|
11635
11934
|
function loadConfig() {
|
|
11636
|
-
const configPath =
|
|
11935
|
+
const configPath = join9(getDataRoot(), "config.json");
|
|
11637
11936
|
let fileConfig = {};
|
|
11638
|
-
if (
|
|
11937
|
+
if (existsSync7(configPath)) {
|
|
11639
11938
|
try {
|
|
11640
11939
|
const raw = readFileSync3(configPath, "utf-8");
|
|
11641
11940
|
fileConfig = JSON.parse(raw);
|
|
@@ -11661,10 +11960,10 @@ function loadConfig() {
|
|
|
11661
11960
|
}
|
|
11662
11961
|
function findFileWalkingUp(filename) {
|
|
11663
11962
|
let dir = process.cwd();
|
|
11664
|
-
const legacyHomeMementosDb =
|
|
11963
|
+
const legacyHomeMementosDb = resolve4(homeDir(), ".mementos", "mementos.db");
|
|
11665
11964
|
while (true) {
|
|
11666
|
-
const candidate =
|
|
11667
|
-
if (
|
|
11965
|
+
const candidate = join9(dir, filename);
|
|
11966
|
+
if (existsSync7(candidate) && resolve4(candidate) !== legacyHomeMementosDb) {
|
|
11668
11967
|
return candidate;
|
|
11669
11968
|
}
|
|
11670
11969
|
const parent = dirname4(dir);
|
|
@@ -11677,7 +11976,7 @@ function findFileWalkingUp(filename) {
|
|
|
11677
11976
|
function findGitRoot3() {
|
|
11678
11977
|
let dir = process.cwd();
|
|
11679
11978
|
while (true) {
|
|
11680
|
-
if (
|
|
11979
|
+
if (existsSync7(join9(dir, ".git"))) {
|
|
11681
11980
|
return dir;
|
|
11682
11981
|
}
|
|
11683
11982
|
const parent = dirname4(dir);
|
|
@@ -11688,14 +11987,14 @@ function findGitRoot3() {
|
|
|
11688
11987
|
}
|
|
11689
11988
|
}
|
|
11690
11989
|
function profilesDir() {
|
|
11691
|
-
return
|
|
11990
|
+
return join9(getDataRoot(), "profiles");
|
|
11692
11991
|
}
|
|
11693
11992
|
function globalConfigPath() {
|
|
11694
|
-
return
|
|
11993
|
+
return join9(getDataRoot(), "config.json");
|
|
11695
11994
|
}
|
|
11696
11995
|
function readGlobalConfig() {
|
|
11697
11996
|
const p = globalConfigPath();
|
|
11698
|
-
if (!
|
|
11997
|
+
if (!existsSync7(p))
|
|
11699
11998
|
return {};
|
|
11700
11999
|
try {
|
|
11701
12000
|
return JSON.parse(readFileSync3(p, "utf-8"));
|
|
@@ -11712,10 +12011,10 @@ function getActiveProfile() {
|
|
|
11712
12011
|
}
|
|
11713
12012
|
function getDbPath2() {
|
|
11714
12013
|
const _home = homeDir();
|
|
11715
|
-
const _newDir =
|
|
11716
|
-
const _oldDir =
|
|
11717
|
-
if (!
|
|
11718
|
-
mkdirSync4(
|
|
12014
|
+
const _newDir = getDataRoot();
|
|
12015
|
+
const _oldDir = join9(_home, ".mementos");
|
|
12016
|
+
if (!existsSync7(_newDir) && existsSync7(_oldDir)) {
|
|
12017
|
+
mkdirSync4(join9(_home, ".hasna"), { recursive: true });
|
|
11719
12018
|
cpSync2(_oldDir, _newDir, { recursive: true });
|
|
11720
12019
|
}
|
|
11721
12020
|
const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
|
|
@@ -11723,13 +12022,13 @@ function getDbPath2() {
|
|
|
11723
12022
|
if (isInMemoryDb2(envDbPath)) {
|
|
11724
12023
|
return envDbPath;
|
|
11725
12024
|
}
|
|
11726
|
-
const resolved =
|
|
12025
|
+
const resolved = resolve4(envDbPath);
|
|
11727
12026
|
ensureDir2(dirname4(resolved));
|
|
11728
12027
|
return resolved;
|
|
11729
12028
|
}
|
|
11730
12029
|
const profile = getActiveProfile();
|
|
11731
12030
|
if (profile) {
|
|
11732
|
-
const profilePath =
|
|
12031
|
+
const profilePath = join9(profilesDir(), `${profile}.db`);
|
|
11733
12032
|
ensureDir2(dirname4(profilePath));
|
|
11734
12033
|
return profilePath;
|
|
11735
12034
|
}
|
|
@@ -11737,26 +12036,27 @@ function getDbPath2() {
|
|
|
11737
12036
|
if (dbScope === "project") {
|
|
11738
12037
|
const gitRoot = findGitRoot3();
|
|
11739
12038
|
if (gitRoot) {
|
|
11740
|
-
const dbPath =
|
|
12039
|
+
const dbPath = join9(gitRoot, ".mementos", "mementos.db");
|
|
11741
12040
|
ensureDir2(dirname4(dbPath));
|
|
11742
12041
|
return dbPath;
|
|
11743
12042
|
}
|
|
11744
12043
|
}
|
|
11745
|
-
const found = findFileWalkingUp(
|
|
12044
|
+
const found = findFileWalkingUp(join9(".mementos", "mementos.db"));
|
|
11746
12045
|
if (found) {
|
|
11747
12046
|
return found;
|
|
11748
12047
|
}
|
|
11749
|
-
const fallback =
|
|
12048
|
+
const fallback = join9(getDataRoot(), "mementos.db");
|
|
11750
12049
|
ensureDir2(dirname4(fallback));
|
|
11751
12050
|
return fallback;
|
|
11752
12051
|
}
|
|
11753
12052
|
function ensureDir2(dir) {
|
|
11754
|
-
if (!
|
|
12053
|
+
if (!existsSync7(dir)) {
|
|
11755
12054
|
mkdirSync4(dir, { recursive: true });
|
|
11756
12055
|
}
|
|
11757
12056
|
}
|
|
11758
12057
|
var DEFAULT_CONFIG2, VALID_SCOPES, VALID_CATEGORIES;
|
|
11759
12058
|
var init_config = __esm(() => {
|
|
12059
|
+
init_paths();
|
|
11760
12060
|
DEFAULT_CONFIG2 = {
|
|
11761
12061
|
default_scope: "private",
|
|
11762
12062
|
default_category: "knowledge",
|
|
@@ -13706,7 +14006,7 @@ function getPgMigrationDiagnostics(connectionString) {
|
|
|
13706
14006
|
const issues = [];
|
|
13707
14007
|
if (!resolvedConnectionString) {
|
|
13708
14008
|
try {
|
|
13709
|
-
resolvedConnectionString =
|
|
14009
|
+
resolvedConnectionString = getStorageConnectionStringForOperator("mementos");
|
|
13710
14010
|
} catch (error) {
|
|
13711
14011
|
issues.push(error instanceof Error ? error.message : String(error));
|
|
13712
14012
|
}
|
|
@@ -13777,7 +14077,7 @@ var init_pg_migrate = __esm(() => {
|
|
|
13777
14077
|
init_pg_migrations();
|
|
13778
14078
|
});
|
|
13779
14079
|
|
|
13780
|
-
// ../../node_modules/.bun/@ai-sdk+provider@3.0.
|
|
14080
|
+
// ../../node_modules/.bun/@ai-sdk+provider@3.0.15/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
13781
14081
|
function getErrorMessage(error) {
|
|
13782
14082
|
if (error == null) {
|
|
13783
14083
|
return "unknown error";
|
|
@@ -13809,7 +14109,7 @@ function isJSONObject(value) {
|
|
|
13809
14109
|
return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
13810
14110
|
}
|
|
13811
14111
|
var marker = "vercel.ai.error", symbol, _a, _b, AISDKError, name = "AI_APICallError", marker2, symbol2, _a2, _b2, APICallError, name2 = "AI_EmptyResponseBodyError", marker3, symbol3, _a3, _b3, EmptyResponseBodyError, name3 = "AI_InvalidArgumentError", marker4, symbol4, _a4, _b4, InvalidArgumentError, name4 = "AI_InvalidPromptError", marker5, symbol5, _a5, _b5, InvalidPromptError, name5 = "AI_InvalidResponseDataError", marker6, symbol6, _a6, _b6, InvalidResponseDataError, name6 = "AI_JSONParseError", marker7, symbol7, _a7, _b7, JSONParseError, name7 = "AI_LoadAPIKeyError", marker8, symbol8, _a8, _b8, LoadAPIKeyError, name8 = "AI_LoadSettingError", marker9, symbol9, _a9, _b9, LoadSettingError, name9 = "AI_NoContentGeneratedError", marker10, symbol10, _a10, _b10, NoContentGeneratedError, name10 = "AI_NoSuchModelError", marker11, symbol11, _a11, _b11, NoSuchModelError, name11 = "AI_TooManyEmbeddingValuesForCallError", marker12, symbol12, _a12, _b12, TooManyEmbeddingValuesForCallError, name12 = "AI_TypeValidationError", marker13, symbol13, _a13, _b13, TypeValidationError, name13 = "AI_UnsupportedFunctionalityError", marker14, symbol14, _a14, _b14, UnsupportedFunctionalityError;
|
|
13812
|
-
var
|
|
14112
|
+
var init_dist2 = __esm(() => {
|
|
13813
14113
|
symbol = Symbol.for(marker);
|
|
13814
14114
|
AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
13815
14115
|
constructor({
|
|
@@ -25442,7 +25742,7 @@ var init_v3 = __esm(() => {
|
|
|
25442
25742
|
init_external();
|
|
25443
25743
|
});
|
|
25444
25744
|
|
|
25445
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
25745
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
|
|
25446
25746
|
function noop(_arg) {}
|
|
25447
25747
|
function createParser(config2) {
|
|
25448
25748
|
if (typeof config2 == "function")
|
|
@@ -25529,7 +25829,7 @@ ${value2}`, dataLines++;
|
|
|
25529
25829
|
}
|
|
25530
25830
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
25531
25831
|
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
25532
|
-
|
|
25832
|
+
value2.includes("\x00") || (id = value2);
|
|
25533
25833
|
return;
|
|
25534
25834
|
}
|
|
25535
25835
|
if (firstCharCode === 58) {
|
|
@@ -25557,7 +25857,7 @@ ${value2}`, dataLines++;
|
|
|
25557
25857
|
${value}`, dataLines++;
|
|
25558
25858
|
break;
|
|
25559
25859
|
case "id":
|
|
25560
|
-
|
|
25860
|
+
value.includes("\x00") || (id = value);
|
|
25561
25861
|
break;
|
|
25562
25862
|
case "retry":
|
|
25563
25863
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
@@ -25594,7 +25894,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
|
|
|
25594
25894
|
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
25595
25895
|
}
|
|
25596
25896
|
var ParseError, LF = 10, CR = 13, SPACE = 32;
|
|
25597
|
-
var
|
|
25897
|
+
var init_dist3 = __esm(() => {
|
|
25598
25898
|
ParseError = class ParseError extends Error {
|
|
25599
25899
|
constructor(message, options) {
|
|
25600
25900
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -25602,10 +25902,10 @@ var init_dist2 = __esm(() => {
|
|
|
25602
25902
|
};
|
|
25603
25903
|
});
|
|
25604
25904
|
|
|
25605
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
25905
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
|
|
25606
25906
|
var EventSourceParserStream;
|
|
25607
25907
|
var init_stream = __esm(() => {
|
|
25608
|
-
|
|
25908
|
+
init_dist3();
|
|
25609
25909
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
25610
25910
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
25611
25911
|
let parser;
|
|
@@ -25631,7 +25931,7 @@ var init_stream = __esm(() => {
|
|
|
25631
25931
|
};
|
|
25632
25932
|
});
|
|
25633
25933
|
|
|
25634
|
-
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.
|
|
25934
|
+
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.46+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
25635
25935
|
function combineHeaders(...headers) {
|
|
25636
25936
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
25637
25937
|
...combinedHeaders,
|
|
@@ -25972,11 +26272,10 @@ async function loadNodeModule(id) {
|
|
|
25972
26272
|
var _a22;
|
|
25973
26273
|
const processWithBuiltins = globalThis.process;
|
|
25974
26274
|
const builtinModule = (_a22 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a22.call(processWithBuiltins, id);
|
|
25975
|
-
|
|
25976
|
-
}
|
|
25977
|
-
|
|
25978
|
-
|
|
25979
|
-
return dynamicImport(id);
|
|
26275
|
+
if (builtinModule == null) {
|
|
26276
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
26277
|
+
}
|
|
26278
|
+
return builtinModule;
|
|
25980
26279
|
}
|
|
25981
26280
|
function getCurrentModulePath() {
|
|
25982
26281
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
@@ -26075,7 +26374,7 @@ async function readResponseWithSizeLimit({
|
|
|
26075
26374
|
} finally {
|
|
26076
26375
|
try {
|
|
26077
26376
|
await reader.cancel();
|
|
26078
|
-
} finally {
|
|
26377
|
+
} catch (e) {} finally {
|
|
26079
26378
|
reader.releaseLock();
|
|
26080
26379
|
}
|
|
26081
26380
|
}
|
|
@@ -27340,7 +27639,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
27340
27639
|
supportsDeferredResults
|
|
27341
27640
|
});
|
|
27342
27641
|
}
|
|
27343
|
-
async function
|
|
27642
|
+
async function resolve6(value) {
|
|
27344
27643
|
if (typeof value === "function") {
|
|
27345
27644
|
value = value();
|
|
27346
27645
|
}
|
|
@@ -27475,7 +27774,7 @@ var DelayedPromise = class {
|
|
|
27475
27774
|
isPending() {
|
|
27476
27775
|
return this.status.type === "pending";
|
|
27477
27776
|
}
|
|
27478
|
-
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault,
|
|
27777
|
+
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
27479
27778
|
prefix,
|
|
27480
27779
|
size = 16,
|
|
27481
27780
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -27499,7 +27798,7 @@ var DelayedPromise = class {
|
|
|
27499
27798
|
});
|
|
27500
27799
|
}
|
|
27501
27800
|
return () => `${prefix}${separator}${generator()}`;
|
|
27502
|
-
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
27801
|
+
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.46", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
27503
27802
|
url: url2,
|
|
27504
27803
|
headers = {},
|
|
27505
27804
|
successfulResponseHandler,
|
|
@@ -28019,23 +28318,23 @@ var DelayedPromise = class {
|
|
|
28019
28318
|
});
|
|
28020
28319
|
}
|
|
28021
28320
|
};
|
|
28022
|
-
var
|
|
28023
|
-
|
|
28024
|
-
|
|
28025
|
-
|
|
28026
|
-
|
|
28027
|
-
|
|
28028
|
-
|
|
28029
|
-
|
|
28030
|
-
|
|
28321
|
+
var init_dist4 = __esm(() => {
|
|
28322
|
+
init_dist2();
|
|
28323
|
+
init_dist2();
|
|
28324
|
+
init_dist2();
|
|
28325
|
+
init_dist2();
|
|
28326
|
+
init_dist2();
|
|
28327
|
+
init_dist2();
|
|
28328
|
+
init_dist2();
|
|
28329
|
+
init_dist2();
|
|
28031
28330
|
init_v4();
|
|
28032
28331
|
init_v3();
|
|
28033
28332
|
init_v3();
|
|
28034
28333
|
init_v3();
|
|
28035
28334
|
init_stream();
|
|
28036
|
-
|
|
28037
|
-
|
|
28038
|
-
|
|
28335
|
+
init_dist2();
|
|
28336
|
+
init_dist2();
|
|
28337
|
+
init_dist2();
|
|
28039
28338
|
({ btoa, atob: atob2 } = globalThis);
|
|
28040
28339
|
marker15 = `vercel.ai.error.${name14}`;
|
|
28041
28340
|
symbol17 = Symbol.for(marker15);
|
|
@@ -28128,7 +28427,7 @@ var init_dist3 = __esm(() => {
|
|
|
28128
28427
|
textDecoder = new TextDecoder;
|
|
28129
28428
|
});
|
|
28130
28429
|
|
|
28131
|
-
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.
|
|
28430
|
+
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.111+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
28132
28431
|
var exports_dist = {};
|
|
28133
28432
|
__export(exports_dist, {
|
|
28134
28433
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
|
|
@@ -28586,7 +28885,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
28586
28885
|
cacheControlValidator,
|
|
28587
28886
|
toolNameMapping
|
|
28588
28887
|
}) {
|
|
28589
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
28888
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
28590
28889
|
const betas = /* @__PURE__ */ new Set;
|
|
28591
28890
|
const blocks = groupIntoBlocks(prompt);
|
|
28592
28891
|
const validator = cacheControlValidator || new CacheControlValidator;
|
|
@@ -28974,6 +29273,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
28974
29273
|
break;
|
|
28975
29274
|
}
|
|
28976
29275
|
case "tool-call": {
|
|
29276
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
28977
29277
|
if (part.providerExecuted) {
|
|
28978
29278
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
28979
29279
|
const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? undefined : _k.anthropic) == null ? undefined : _l.type) === "mcp-tool-use";
|
|
@@ -29002,6 +29302,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29002
29302
|
id: part.toolCallId,
|
|
29003
29303
|
name: subtoolName,
|
|
29004
29304
|
input,
|
|
29305
|
+
...caller && { caller },
|
|
29005
29306
|
cache_control: cacheControl
|
|
29006
29307
|
});
|
|
29007
29308
|
} else if (providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && part.input.type === "programmatic-tool-call") {
|
|
@@ -29011,6 +29312,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29011
29312
|
id: part.toolCallId,
|
|
29012
29313
|
name: "code_execution",
|
|
29013
29314
|
input: inputWithoutType,
|
|
29315
|
+
...caller && { caller },
|
|
29014
29316
|
cache_control: cacheControl
|
|
29015
29317
|
});
|
|
29016
29318
|
} else {
|
|
@@ -29020,6 +29322,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29020
29322
|
id: part.toolCallId,
|
|
29021
29323
|
name: providerToolName,
|
|
29022
29324
|
input: part.input,
|
|
29325
|
+
...caller && { caller },
|
|
29023
29326
|
cache_control: cacheControl
|
|
29024
29327
|
});
|
|
29025
29328
|
} else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
@@ -29028,6 +29331,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29028
29331
|
id: part.toolCallId,
|
|
29029
29332
|
name: providerToolName,
|
|
29030
29333
|
input: part.input,
|
|
29334
|
+
...caller && { caller },
|
|
29031
29335
|
cache_control: cacheControl
|
|
29032
29336
|
});
|
|
29033
29337
|
} else if (providerToolName === "advisor") {
|
|
@@ -29036,6 +29340,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29036
29340
|
id: part.toolCallId,
|
|
29037
29341
|
name: "advisor",
|
|
29038
29342
|
input: {},
|
|
29343
|
+
...caller && { caller },
|
|
29039
29344
|
cache_control: cacheControl
|
|
29040
29345
|
});
|
|
29041
29346
|
} else {
|
|
@@ -29047,11 +29352,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29047
29352
|
}
|
|
29048
29353
|
break;
|
|
29049
29354
|
}
|
|
29050
|
-
const callerOptions = (_o = part.providerOptions) == null ? undefined : _o.anthropic;
|
|
29051
|
-
const caller = (callerOptions == null ? undefined : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
29052
|
-
type: callerOptions.caller.type,
|
|
29053
|
-
tool_id: callerOptions.caller.toolId
|
|
29054
|
-
} : callerOptions.caller.type === "direct" ? { type: "direct" } : undefined : undefined;
|
|
29055
29355
|
anthropicContent.push({
|
|
29056
29356
|
type: "tool_use",
|
|
29057
29357
|
id: part.toolCallId,
|
|
@@ -29064,6 +29364,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29064
29364
|
}
|
|
29065
29365
|
case "tool-result": {
|
|
29066
29366
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
29367
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
29067
29368
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
29068
29369
|
const output = part.output;
|
|
29069
29370
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -29097,7 +29398,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29097
29398
|
tool_use_id: part.toolCallId,
|
|
29098
29399
|
content: {
|
|
29099
29400
|
type: "code_execution_tool_result_error",
|
|
29100
|
-
error_code: (
|
|
29401
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
29101
29402
|
},
|
|
29102
29403
|
cache_control: cacheControl
|
|
29103
29404
|
});
|
|
@@ -29108,7 +29409,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29108
29409
|
cache_control: cacheControl,
|
|
29109
29410
|
content: {
|
|
29110
29411
|
type: "bash_code_execution_tool_result_error",
|
|
29111
|
-
error_code: (
|
|
29412
|
+
error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
|
|
29112
29413
|
}
|
|
29113
29414
|
});
|
|
29114
29415
|
}
|
|
@@ -29141,7 +29442,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29141
29442
|
stdout: codeExecutionOutput.stdout,
|
|
29142
29443
|
stderr: codeExecutionOutput.stderr,
|
|
29143
29444
|
return_code: codeExecutionOutput.return_code,
|
|
29144
|
-
content: (
|
|
29445
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
29145
29446
|
},
|
|
29146
29447
|
cache_control: cacheControl
|
|
29147
29448
|
});
|
|
@@ -29159,7 +29460,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29159
29460
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
29160
29461
|
stderr: codeExecutionOutput.stderr,
|
|
29161
29462
|
return_code: codeExecutionOutput.return_code,
|
|
29162
|
-
content: (
|
|
29463
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
29163
29464
|
},
|
|
29164
29465
|
cache_control: cacheControl
|
|
29165
29466
|
});
|
|
@@ -29178,7 +29479,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29178
29479
|
stdout: codeExecutionOutput.stdout,
|
|
29179
29480
|
stderr: codeExecutionOutput.stderr,
|
|
29180
29481
|
return_code: codeExecutionOutput.return_code,
|
|
29181
|
-
content: (
|
|
29482
|
+
content: (_s = codeExecutionOutput.content) != null ? _s : []
|
|
29182
29483
|
},
|
|
29183
29484
|
cache_control: cacheControl
|
|
29184
29485
|
});
|
|
@@ -29214,8 +29515,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29214
29515
|
tool_use_id: part.toolCallId,
|
|
29215
29516
|
content: {
|
|
29216
29517
|
type: "web_fetch_tool_result_error",
|
|
29217
|
-
error_code: (
|
|
29518
|
+
error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
|
|
29218
29519
|
},
|
|
29520
|
+
...caller && { caller },
|
|
29219
29521
|
cache_control: cacheControl
|
|
29220
29522
|
});
|
|
29221
29523
|
break;
|
|
@@ -29249,6 +29551,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29249
29551
|
}
|
|
29250
29552
|
}
|
|
29251
29553
|
},
|
|
29554
|
+
...caller && { caller },
|
|
29252
29555
|
cache_control: cacheControl
|
|
29253
29556
|
});
|
|
29254
29557
|
break;
|
|
@@ -29261,8 +29564,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29261
29564
|
tool_use_id: part.toolCallId,
|
|
29262
29565
|
content: {
|
|
29263
29566
|
type: "web_search_tool_result_error",
|
|
29264
|
-
error_code: (
|
|
29567
|
+
error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
|
|
29265
29568
|
},
|
|
29569
|
+
...caller && { caller },
|
|
29266
29570
|
cache_control: cacheControl
|
|
29267
29571
|
});
|
|
29268
29572
|
break;
|
|
@@ -29288,6 +29592,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
29288
29592
|
encrypted_content: result.encryptedContent,
|
|
29289
29593
|
type: result.type
|
|
29290
29594
|
})),
|
|
29595
|
+
...caller && { caller },
|
|
29291
29596
|
cache_control: cacheControl
|
|
29292
29597
|
});
|
|
29293
29598
|
break;
|
|
@@ -29456,6 +29761,17 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
29456
29761
|
flushSegment();
|
|
29457
29762
|
return result;
|
|
29458
29763
|
}
|
|
29764
|
+
function getAnthropicCaller(providerOptions) {
|
|
29765
|
+
var _a16;
|
|
29766
|
+
const caller = (_a16 = providerOptions == null ? undefined : providerOptions.anthropic) == null ? undefined : _a16.caller;
|
|
29767
|
+
if (((caller == null ? undefined : caller.type) === "code_execution_20250825" || (caller == null ? undefined : caller.type) === "code_execution_20260120") && caller.toolId) {
|
|
29768
|
+
return {
|
|
29769
|
+
type: caller.type,
|
|
29770
|
+
tool_id: caller.toolId
|
|
29771
|
+
};
|
|
29772
|
+
}
|
|
29773
|
+
return (caller == null ? undefined : caller.type) === "direct" ? { type: "direct" } : undefined;
|
|
29774
|
+
}
|
|
29459
29775
|
function mapAnthropicStopReason({
|
|
29460
29776
|
finishReason,
|
|
29461
29777
|
isJsonResponseFromTool
|
|
@@ -29632,6 +29948,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
29632
29948
|
}
|
|
29633
29949
|
};
|
|
29634
29950
|
}
|
|
29951
|
+
function getAnthropicCallerInfo(caller) {
|
|
29952
|
+
return caller == null ? undefined : {
|
|
29953
|
+
type: caller.type,
|
|
29954
|
+
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
29955
|
+
};
|
|
29956
|
+
}
|
|
29957
|
+
function getAnthropicCallerMetadata(caller) {
|
|
29958
|
+
const callerInfo = getAnthropicCallerInfo(caller);
|
|
29959
|
+
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
29960
|
+
}
|
|
29635
29961
|
function getModelCapabilities(modelId) {
|
|
29636
29962
|
if (modelId.includes("claude-opus-5")) {
|
|
29637
29963
|
return {
|
|
@@ -29860,7 +30186,7 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
29860
30186
|
}
|
|
29861
30187
|
return;
|
|
29862
30188
|
}
|
|
29863
|
-
var VERSION2 = "3.0.
|
|
30189
|
+
var VERSION2 = "3.0.111", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicToolCallCallerSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
29864
30190
|
constructor() {
|
|
29865
30191
|
this.breakpointCount = 0;
|
|
29866
30192
|
this.warnings = [];
|
|
@@ -30368,11 +30694,11 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30368
30694
|
betas,
|
|
30369
30695
|
headers
|
|
30370
30696
|
}) {
|
|
30371
|
-
return combineHeaders(await
|
|
30697
|
+
return combineHeaders(await resolve6(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
|
|
30372
30698
|
}
|
|
30373
30699
|
async getBetasFromHeaders(requestHeaders) {
|
|
30374
30700
|
var _a16, _b16;
|
|
30375
|
-
const configHeaders = await
|
|
30701
|
+
const configHeaders = await resolve6(this.config.headers);
|
|
30376
30702
|
const configBetaHeader = (_a16 = configHeaders["anthropic-beta"]) != null ? _a16 : "";
|
|
30377
30703
|
const requestBetaHeader = (_b16 = requestHeaders == null ? undefined : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
|
|
30378
30704
|
return new Set([
|
|
@@ -30519,23 +30845,12 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30519
30845
|
text: JSON.stringify(part.input)
|
|
30520
30846
|
});
|
|
30521
30847
|
} else {
|
|
30522
|
-
const caller = part.caller;
|
|
30523
|
-
const callerInfo = caller ? {
|
|
30524
|
-
type: caller.type,
|
|
30525
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
30526
|
-
} : undefined;
|
|
30527
30848
|
content.push({
|
|
30528
30849
|
type: "tool-call",
|
|
30529
30850
|
toolCallId: part.id,
|
|
30530
30851
|
toolName: part.name,
|
|
30531
30852
|
input: JSON.stringify(part.input),
|
|
30532
|
-
...
|
|
30533
|
-
providerMetadata: {
|
|
30534
|
-
anthropic: {
|
|
30535
|
-
caller: callerInfo
|
|
30536
|
-
}
|
|
30537
|
-
}
|
|
30538
|
-
}
|
|
30853
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30539
30854
|
});
|
|
30540
30855
|
}
|
|
30541
30856
|
break;
|
|
@@ -30549,7 +30864,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30549
30864
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
30550
30865
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
30551
30866
|
providerExecuted: true,
|
|
30552
|
-
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
30867
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
30868
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30553
30869
|
});
|
|
30554
30870
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
30555
30871
|
const inputToSerialize = part.name === "code_execution" && part.input != null && typeof part.input === "object" && "code" in part.input && !("type" in part.input) ? { type: "programmatic-tool-call", ...part.input } : part.input;
|
|
@@ -30559,7 +30875,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30559
30875
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
30560
30876
|
input: JSON.stringify(inputToSerialize),
|
|
30561
30877
|
providerExecuted: true,
|
|
30562
|
-
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
30878
|
+
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
|
|
30879
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30563
30880
|
});
|
|
30564
30881
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
30565
30882
|
serverToolCalls[part.id] = part.name;
|
|
@@ -30568,7 +30885,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30568
30885
|
toolCallId: part.id,
|
|
30569
30886
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
30570
30887
|
input: JSON.stringify(part.input),
|
|
30571
|
-
providerExecuted: true
|
|
30888
|
+
providerExecuted: true,
|
|
30889
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30572
30890
|
});
|
|
30573
30891
|
} else if (part.name === "advisor") {
|
|
30574
30892
|
content.push({
|
|
@@ -30576,7 +30894,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30576
30894
|
toolCallId: part.id,
|
|
30577
30895
|
toolName: toolNameMapping.toCustomToolName("advisor"),
|
|
30578
30896
|
input: JSON.stringify(part.input),
|
|
30579
|
-
providerExecuted: true
|
|
30897
|
+
providerExecuted: true,
|
|
30898
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30580
30899
|
});
|
|
30581
30900
|
}
|
|
30582
30901
|
break;
|
|
@@ -30635,7 +30954,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30635
30954
|
data: part.content.content.source.data
|
|
30636
30955
|
}
|
|
30637
30956
|
}
|
|
30638
|
-
}
|
|
30957
|
+
},
|
|
30958
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30639
30959
|
});
|
|
30640
30960
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
30641
30961
|
content.push({
|
|
@@ -30646,7 +30966,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30646
30966
|
result: {
|
|
30647
30967
|
type: "web_fetch_tool_result_error",
|
|
30648
30968
|
errorCode: part.content.error_code
|
|
30649
|
-
}
|
|
30969
|
+
},
|
|
30970
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30650
30971
|
});
|
|
30651
30972
|
}
|
|
30652
30973
|
break;
|
|
@@ -30666,7 +30987,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30666
30987
|
encryptedContent: result.encrypted_content,
|
|
30667
30988
|
type: result.type
|
|
30668
30989
|
};
|
|
30669
|
-
})
|
|
30990
|
+
}),
|
|
30991
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30670
30992
|
});
|
|
30671
30993
|
for (const result of part.content) {
|
|
30672
30994
|
content.push({
|
|
@@ -30691,7 +31013,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
30691
31013
|
result: {
|
|
30692
31014
|
type: "web_search_tool_result_error",
|
|
30693
31015
|
errorCode: part.content.error_code
|
|
30694
|
-
}
|
|
31016
|
+
},
|
|
31017
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
30695
31018
|
});
|
|
30696
31019
|
}
|
|
30697
31020
|
break;
|
|
@@ -31032,11 +31355,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31032
31355
|
id: String(value.index)
|
|
31033
31356
|
});
|
|
31034
31357
|
} else {
|
|
31035
|
-
const
|
|
31036
|
-
const callerInfo = caller ? {
|
|
31037
|
-
type: caller.type,
|
|
31038
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
31039
|
-
} : undefined;
|
|
31358
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31040
31359
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
31041
31360
|
const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
|
|
31042
31361
|
contentBlocks[value.index] = {
|
|
@@ -31056,6 +31375,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31056
31375
|
return;
|
|
31057
31376
|
}
|
|
31058
31377
|
case "server_tool_use": {
|
|
31378
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31059
31379
|
if ([
|
|
31060
31380
|
"web_fetch",
|
|
31061
31381
|
"web_search",
|
|
@@ -31076,7 +31396,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31076
31396
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
31077
31397
|
firstDelta: finalInput.length === 0,
|
|
31078
31398
|
providerToolName,
|
|
31079
|
-
providerToolInputType
|
|
31399
|
+
providerToolInputType,
|
|
31400
|
+
...callerInfo && { caller: callerInfo }
|
|
31080
31401
|
};
|
|
31081
31402
|
controller.enqueue({
|
|
31082
31403
|
type: "tool-input-start",
|
|
@@ -31095,7 +31416,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31095
31416
|
input: "",
|
|
31096
31417
|
providerExecuted: true,
|
|
31097
31418
|
firstDelta: true,
|
|
31098
|
-
providerToolName: part.name
|
|
31419
|
+
providerToolName: part.name,
|
|
31420
|
+
...callerInfo && { caller: callerInfo }
|
|
31099
31421
|
};
|
|
31100
31422
|
controller.enqueue({
|
|
31101
31423
|
type: "tool-input-start",
|
|
@@ -31112,7 +31434,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31112
31434
|
input: "{}",
|
|
31113
31435
|
providerExecuted: true,
|
|
31114
31436
|
firstDelta: true,
|
|
31115
|
-
providerToolName: part.name
|
|
31437
|
+
providerToolName: part.name,
|
|
31438
|
+
...callerInfo && { caller: callerInfo }
|
|
31116
31439
|
};
|
|
31117
31440
|
controller.enqueue({
|
|
31118
31441
|
type: "tool-input-start",
|
|
@@ -31147,7 +31470,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31147
31470
|
data: part.content.content.source.data
|
|
31148
31471
|
}
|
|
31149
31472
|
}
|
|
31150
|
-
}
|
|
31473
|
+
},
|
|
31474
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31151
31475
|
});
|
|
31152
31476
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
31153
31477
|
controller.enqueue({
|
|
@@ -31158,7 +31482,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31158
31482
|
result: {
|
|
31159
31483
|
type: "web_fetch_tool_result_error",
|
|
31160
31484
|
errorCode: part.content.error_code
|
|
31161
|
-
}
|
|
31485
|
+
},
|
|
31486
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31162
31487
|
});
|
|
31163
31488
|
}
|
|
31164
31489
|
return;
|
|
@@ -31178,7 +31503,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31178
31503
|
encryptedContent: result.encrypted_content,
|
|
31179
31504
|
type: result.type
|
|
31180
31505
|
};
|
|
31181
|
-
})
|
|
31506
|
+
}),
|
|
31507
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31182
31508
|
});
|
|
31183
31509
|
for (const result of part.content) {
|
|
31184
31510
|
controller.enqueue({
|
|
@@ -31203,7 +31529,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31203
31529
|
result: {
|
|
31204
31530
|
type: "web_search_tool_result_error",
|
|
31205
31531
|
errorCode: part.content.error_code
|
|
31206
|
-
}
|
|
31532
|
+
},
|
|
31533
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
31207
31534
|
});
|
|
31208
31535
|
}
|
|
31209
31536
|
return;
|
|
@@ -31581,11 +31908,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31581
31908
|
for (let contentIndex = 0;contentIndex < value.message.content.length; contentIndex++) {
|
|
31582
31909
|
const part = value.message.content[contentIndex];
|
|
31583
31910
|
if (part.type === "tool_use") {
|
|
31584
|
-
const
|
|
31585
|
-
const callerInfo = caller ? {
|
|
31586
|
-
type: caller.type,
|
|
31587
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
31588
|
-
} : undefined;
|
|
31911
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
31589
31912
|
controller.enqueue({
|
|
31590
31913
|
type: "tool-input-start",
|
|
31591
31914
|
id: part.id,
|
|
@@ -31745,59 +32068,59 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
31745
32068
|
}, bash_20241022InputSchema, bash_20241022, bash_20250124InputSchema, bash_20250124, computer_20241022InputSchema, computer_20241022, computer_20250124InputSchema, computer_20250124, computer_20251124InputSchema, computer_20251124, memory_20250818InputSchema, memory_20250818, textEditor_20241022InputSchema, textEditor_20241022, textEditor_20250124InputSchema, textEditor_20250124, textEditor_20250429InputSchema, textEditor_20250429, toolSearchBm25_20251119OutputSchema, toolSearchBm25_20251119InputSchema, factory11, toolSearchBm25_20251119 = (args = {}) => {
|
|
31746
32069
|
return factory11(args);
|
|
31747
32070
|
}, anthropicTools, ANTHROPIC_API_URL = "https://api.anthropic.com", ANTHROPIC_API_VERSIONED_URL, anthropic;
|
|
31748
|
-
var
|
|
31749
|
-
|
|
31750
|
-
|
|
31751
|
-
|
|
31752
|
-
|
|
31753
|
-
|
|
32071
|
+
var init_dist5 = __esm(() => {
|
|
32072
|
+
init_dist2();
|
|
32073
|
+
init_dist4();
|
|
32074
|
+
init_dist2();
|
|
32075
|
+
init_dist4();
|
|
32076
|
+
init_dist4();
|
|
31754
32077
|
init_v4();
|
|
31755
|
-
|
|
32078
|
+
init_dist4();
|
|
31756
32079
|
init_v4();
|
|
31757
32080
|
init_v4();
|
|
31758
|
-
|
|
31759
|
-
|
|
32081
|
+
init_dist2();
|
|
32082
|
+
init_dist4();
|
|
31760
32083
|
init_v4();
|
|
31761
|
-
|
|
32084
|
+
init_dist4();
|
|
31762
32085
|
init_v4();
|
|
31763
|
-
|
|
32086
|
+
init_dist4();
|
|
31764
32087
|
init_v4();
|
|
31765
|
-
|
|
32088
|
+
init_dist4();
|
|
31766
32089
|
init_v4();
|
|
31767
|
-
|
|
32090
|
+
init_dist4();
|
|
31768
32091
|
init_v4();
|
|
31769
|
-
|
|
32092
|
+
init_dist4();
|
|
31770
32093
|
init_v4();
|
|
31771
|
-
|
|
31772
|
-
|
|
31773
|
-
|
|
31774
|
-
|
|
32094
|
+
init_dist4();
|
|
32095
|
+
init_dist2();
|
|
32096
|
+
init_dist4();
|
|
32097
|
+
init_dist4();
|
|
31775
32098
|
init_v4();
|
|
31776
|
-
|
|
32099
|
+
init_dist4();
|
|
31777
32100
|
init_v4();
|
|
31778
|
-
|
|
32101
|
+
init_dist4();
|
|
31779
32102
|
init_v4();
|
|
31780
|
-
|
|
32103
|
+
init_dist4();
|
|
31781
32104
|
init_v4();
|
|
31782
|
-
|
|
32105
|
+
init_dist4();
|
|
31783
32106
|
init_v4();
|
|
31784
|
-
|
|
32107
|
+
init_dist4();
|
|
31785
32108
|
init_v4();
|
|
31786
|
-
|
|
32109
|
+
init_dist4();
|
|
31787
32110
|
init_v4();
|
|
31788
|
-
|
|
32111
|
+
init_dist4();
|
|
31789
32112
|
init_v4();
|
|
31790
|
-
|
|
32113
|
+
init_dist4();
|
|
31791
32114
|
init_v4();
|
|
31792
|
-
|
|
32115
|
+
init_dist4();
|
|
31793
32116
|
init_v4();
|
|
31794
|
-
|
|
32117
|
+
init_dist4();
|
|
31795
32118
|
init_v4();
|
|
31796
|
-
|
|
32119
|
+
init_dist4();
|
|
31797
32120
|
init_v4();
|
|
31798
|
-
|
|
32121
|
+
init_dist4();
|
|
31799
32122
|
init_v4();
|
|
31800
|
-
|
|
32123
|
+
init_dist4();
|
|
31801
32124
|
init_v4();
|
|
31802
32125
|
anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
31803
32126
|
type: exports_external2.literal("error"),
|
|
@@ -31816,6 +32139,19 @@ var init_dist4 = __esm(() => {
|
|
|
31816
32139
|
explanation: exports_external2.string().nullish(),
|
|
31817
32140
|
recommended_model: exports_external2.string().nullish()
|
|
31818
32141
|
});
|
|
32142
|
+
anthropicToolCallCallerSchema = exports_external2.union([
|
|
32143
|
+
exports_external2.object({
|
|
32144
|
+
type: exports_external2.literal("code_execution_20250825"),
|
|
32145
|
+
tool_id: exports_external2.string()
|
|
32146
|
+
}),
|
|
32147
|
+
exports_external2.object({
|
|
32148
|
+
type: exports_external2.literal("code_execution_20260120"),
|
|
32149
|
+
tool_id: exports_external2.string()
|
|
32150
|
+
}),
|
|
32151
|
+
exports_external2.object({
|
|
32152
|
+
type: exports_external2.literal("direct")
|
|
32153
|
+
})
|
|
32154
|
+
]);
|
|
31819
32155
|
anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
31820
32156
|
type: exports_external2.literal("message"),
|
|
31821
32157
|
id: exports_external2.string().nullish(),
|
|
@@ -31868,34 +32204,14 @@ var init_dist4 = __esm(() => {
|
|
|
31868
32204
|
id: exports_external2.string(),
|
|
31869
32205
|
name: exports_external2.string(),
|
|
31870
32206
|
input: exports_external2.unknown(),
|
|
31871
|
-
caller:
|
|
31872
|
-
exports_external2.object({
|
|
31873
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
31874
|
-
tool_id: exports_external2.string()
|
|
31875
|
-
}),
|
|
31876
|
-
exports_external2.object({
|
|
31877
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
31878
|
-
tool_id: exports_external2.string()
|
|
31879
|
-
}),
|
|
31880
|
-
exports_external2.object({
|
|
31881
|
-
type: exports_external2.literal("direct")
|
|
31882
|
-
})
|
|
31883
|
-
]).optional()
|
|
32207
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
31884
32208
|
}),
|
|
31885
32209
|
exports_external2.object({
|
|
31886
32210
|
type: exports_external2.literal("server_tool_use"),
|
|
31887
32211
|
id: exports_external2.string(),
|
|
31888
32212
|
name: exports_external2.string(),
|
|
31889
32213
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
31890
|
-
caller:
|
|
31891
|
-
exports_external2.object({
|
|
31892
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
31893
|
-
tool_id: exports_external2.string()
|
|
31894
|
-
}),
|
|
31895
|
-
exports_external2.object({
|
|
31896
|
-
type: exports_external2.literal("direct")
|
|
31897
|
-
})
|
|
31898
|
-
]).optional()
|
|
32214
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
31899
32215
|
}),
|
|
31900
32216
|
exports_external2.object({
|
|
31901
32217
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -31916,6 +32232,7 @@ var init_dist4 = __esm(() => {
|
|
|
31916
32232
|
exports_external2.object({
|
|
31917
32233
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
31918
32234
|
tool_use_id: exports_external2.string(),
|
|
32235
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
31919
32236
|
content: exports_external2.union([
|
|
31920
32237
|
exports_external2.object({
|
|
31921
32238
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -31948,6 +32265,7 @@ var init_dist4 = __esm(() => {
|
|
|
31948
32265
|
exports_external2.object({
|
|
31949
32266
|
type: exports_external2.literal("web_search_tool_result"),
|
|
31950
32267
|
tool_use_id: exports_external2.string(),
|
|
32268
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
31951
32269
|
content: exports_external2.union([
|
|
31952
32270
|
exports_external2.array(exports_external2.object({
|
|
31953
32271
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -32151,19 +32469,7 @@ var init_dist4 = __esm(() => {
|
|
|
32151
32469
|
id: exports_external2.string(),
|
|
32152
32470
|
name: exports_external2.string(),
|
|
32153
32471
|
input: exports_external2.unknown(),
|
|
32154
|
-
caller:
|
|
32155
|
-
exports_external2.object({
|
|
32156
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
32157
|
-
tool_id: exports_external2.string()
|
|
32158
|
-
}),
|
|
32159
|
-
exports_external2.object({
|
|
32160
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32161
|
-
tool_id: exports_external2.string()
|
|
32162
|
-
}),
|
|
32163
|
-
exports_external2.object({
|
|
32164
|
-
type: exports_external2.literal("direct")
|
|
32165
|
-
})
|
|
32166
|
-
]).optional()
|
|
32472
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32167
32473
|
})
|
|
32168
32474
|
])).nullish(),
|
|
32169
32475
|
stop_reason: exports_external2.string().nullish(),
|
|
@@ -32190,19 +32496,7 @@ var init_dist4 = __esm(() => {
|
|
|
32190
32496
|
id: exports_external2.string(),
|
|
32191
32497
|
name: exports_external2.string(),
|
|
32192
32498
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).optional(),
|
|
32193
|
-
caller:
|
|
32194
|
-
exports_external2.object({
|
|
32195
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
32196
|
-
tool_id: exports_external2.string()
|
|
32197
|
-
}),
|
|
32198
|
-
exports_external2.object({
|
|
32199
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32200
|
-
tool_id: exports_external2.string()
|
|
32201
|
-
}),
|
|
32202
|
-
exports_external2.object({
|
|
32203
|
-
type: exports_external2.literal("direct")
|
|
32204
|
-
})
|
|
32205
|
-
]).optional()
|
|
32499
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32206
32500
|
}),
|
|
32207
32501
|
exports_external2.object({
|
|
32208
32502
|
type: exports_external2.literal("redacted_thinking"),
|
|
@@ -32217,15 +32511,7 @@ var init_dist4 = __esm(() => {
|
|
|
32217
32511
|
id: exports_external2.string(),
|
|
32218
32512
|
name: exports_external2.string(),
|
|
32219
32513
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
32220
|
-
caller:
|
|
32221
|
-
exports_external2.object({
|
|
32222
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
32223
|
-
tool_id: exports_external2.string()
|
|
32224
|
-
}),
|
|
32225
|
-
exports_external2.object({
|
|
32226
|
-
type: exports_external2.literal("direct")
|
|
32227
|
-
})
|
|
32228
|
-
]).optional()
|
|
32514
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
32229
32515
|
}),
|
|
32230
32516
|
exports_external2.object({
|
|
32231
32517
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -32246,6 +32532,7 @@ var init_dist4 = __esm(() => {
|
|
|
32246
32532
|
exports_external2.object({
|
|
32247
32533
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
32248
32534
|
tool_use_id: exports_external2.string(),
|
|
32535
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32249
32536
|
content: exports_external2.union([
|
|
32250
32537
|
exports_external2.object({
|
|
32251
32538
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -32278,6 +32565,7 @@ var init_dist4 = __esm(() => {
|
|
|
32278
32565
|
exports_external2.object({
|
|
32279
32566
|
type: exports_external2.literal("web_search_tool_result"),
|
|
32280
32567
|
tool_use_id: exports_external2.string(),
|
|
32568
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
32281
32569
|
content: exports_external2.union([
|
|
32282
32570
|
exports_external2.array(exports_external2.object({
|
|
32283
32571
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -33317,7 +33605,7 @@ var init_dist4 = __esm(() => {
|
|
|
33317
33605
|
anthropic = createAnthropic();
|
|
33318
33606
|
});
|
|
33319
33607
|
|
|
33320
|
-
// ../../node_modules/.bun/@ai-sdk+openai@3.0.
|
|
33608
|
+
// ../../node_modules/.bun/@ai-sdk+openai@3.0.97+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
33321
33609
|
var exports_dist2 = {};
|
|
33322
33610
|
__export(exports_dist2, {
|
|
33323
33611
|
openai: () => openai,
|
|
@@ -34254,12 +34542,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
34254
34542
|
if (store && id != null) {
|
|
34255
34543
|
input.push({ type: "item_reference", id });
|
|
34256
34544
|
}
|
|
34257
|
-
|
|
34545
|
+
if (store || !hasShellTool || resolvedToolName !== "shell") {
|
|
34546
|
+
break;
|
|
34547
|
+
}
|
|
34258
34548
|
}
|
|
34259
|
-
|
|
34549
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
34550
|
+
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
34260
34551
|
break;
|
|
34261
34552
|
}
|
|
34262
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
34263
34553
|
if (store && id != null && isProviderDefinedToolCall) {
|
|
34264
34554
|
input.push({ type: "item_reference", id });
|
|
34265
34555
|
break;
|
|
@@ -34480,7 +34770,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
34480
34770
|
continue;
|
|
34481
34771
|
}
|
|
34482
34772
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
34483
|
-
if (store) {
|
|
34773
|
+
if (store && !hasConversation && !hasPreviousResponseId) {
|
|
34484
34774
|
input.push({
|
|
34485
34775
|
type: "item_reference",
|
|
34486
34776
|
id: approvalResponse.approvalId
|
|
@@ -35444,7 +35734,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
35444
35734
|
});
|
|
35445
35735
|
baseArgs.service_tier = undefined;
|
|
35446
35736
|
}
|
|
35447
|
-
if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
35737
|
+
if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
35448
35738
|
warnings.push({
|
|
35449
35739
|
type: "unsupported",
|
|
35450
35740
|
feature: "serviceTier",
|
|
@@ -36454,7 +36744,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
36454
36744
|
});
|
|
36455
36745
|
delete baseArgs.service_tier;
|
|
36456
36746
|
}
|
|
36457
|
-
if ((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
36747
|
+
if (((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? undefined : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
36458
36748
|
warnings.push({
|
|
36459
36749
|
type: "unsupported",
|
|
36460
36750
|
feature: "serviceTier",
|
|
@@ -38034,78 +38324,78 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
38034
38324
|
}
|
|
38035
38325
|
};
|
|
38036
38326
|
}
|
|
38037
|
-
}, VERSION3 = "3.0.
|
|
38038
|
-
var
|
|
38039
|
-
|
|
38040
|
-
|
|
38041
|
-
|
|
38327
|
+
}, VERSION3 = "3.0.97", openai;
|
|
38328
|
+
var init_dist6 = __esm(() => {
|
|
38329
|
+
init_dist4();
|
|
38330
|
+
init_dist2();
|
|
38331
|
+
init_dist4();
|
|
38042
38332
|
init_v4();
|
|
38043
|
-
|
|
38044
|
-
|
|
38045
|
-
|
|
38046
|
-
|
|
38047
|
-
|
|
38333
|
+
init_dist4();
|
|
38334
|
+
init_dist2();
|
|
38335
|
+
init_dist2();
|
|
38336
|
+
init_dist4();
|
|
38337
|
+
init_dist4();
|
|
38048
38338
|
init_v4();
|
|
38049
|
-
|
|
38339
|
+
init_dist4();
|
|
38050
38340
|
init_v4();
|
|
38051
|
-
|
|
38052
|
-
|
|
38053
|
-
|
|
38341
|
+
init_dist2();
|
|
38342
|
+
init_dist4();
|
|
38343
|
+
init_dist2();
|
|
38054
38344
|
init_v4();
|
|
38055
|
-
|
|
38056
|
-
|
|
38345
|
+
init_dist4();
|
|
38346
|
+
init_dist4();
|
|
38057
38347
|
init_v4();
|
|
38058
|
-
|
|
38059
|
-
|
|
38060
|
-
|
|
38348
|
+
init_dist2();
|
|
38349
|
+
init_dist4();
|
|
38350
|
+
init_dist4();
|
|
38061
38351
|
init_v4();
|
|
38062
|
-
|
|
38352
|
+
init_dist4();
|
|
38063
38353
|
init_v4();
|
|
38064
|
-
|
|
38065
|
-
|
|
38354
|
+
init_dist4();
|
|
38355
|
+
init_dist4();
|
|
38066
38356
|
init_v4();
|
|
38067
|
-
|
|
38357
|
+
init_dist4();
|
|
38068
38358
|
init_v4();
|
|
38069
|
-
|
|
38359
|
+
init_dist4();
|
|
38070
38360
|
init_v4();
|
|
38071
|
-
|
|
38361
|
+
init_dist4();
|
|
38072
38362
|
init_v4();
|
|
38073
|
-
|
|
38363
|
+
init_dist4();
|
|
38074
38364
|
init_v4();
|
|
38075
|
-
|
|
38365
|
+
init_dist4();
|
|
38076
38366
|
init_v4();
|
|
38077
|
-
|
|
38367
|
+
init_dist4();
|
|
38078
38368
|
init_v4();
|
|
38079
|
-
|
|
38369
|
+
init_dist4();
|
|
38080
38370
|
init_v4();
|
|
38081
|
-
|
|
38371
|
+
init_dist4();
|
|
38082
38372
|
init_v4();
|
|
38083
|
-
|
|
38373
|
+
init_dist4();
|
|
38084
38374
|
init_v4();
|
|
38085
|
-
|
|
38375
|
+
init_dist4();
|
|
38086
38376
|
init_v4();
|
|
38087
|
-
|
|
38377
|
+
init_dist4();
|
|
38088
38378
|
init_v4();
|
|
38089
|
-
|
|
38379
|
+
init_dist4();
|
|
38090
38380
|
init_v4();
|
|
38091
|
-
|
|
38092
|
-
|
|
38093
|
-
|
|
38094
|
-
|
|
38381
|
+
init_dist2();
|
|
38382
|
+
init_dist4();
|
|
38383
|
+
init_dist2();
|
|
38384
|
+
init_dist4();
|
|
38095
38385
|
init_v4();
|
|
38096
|
-
|
|
38386
|
+
init_dist4();
|
|
38097
38387
|
init_v4();
|
|
38098
|
-
|
|
38388
|
+
init_dist4();
|
|
38099
38389
|
init_v4();
|
|
38100
|
-
|
|
38101
|
-
|
|
38102
|
-
|
|
38103
|
-
|
|
38390
|
+
init_dist2();
|
|
38391
|
+
init_dist4();
|
|
38392
|
+
init_dist4();
|
|
38393
|
+
init_dist4();
|
|
38104
38394
|
init_v4();
|
|
38105
|
-
|
|
38106
|
-
|
|
38395
|
+
init_dist4();
|
|
38396
|
+
init_dist4();
|
|
38107
38397
|
init_v4();
|
|
38108
|
-
|
|
38398
|
+
init_dist4();
|
|
38109
38399
|
init_v4();
|
|
38110
38400
|
openaiErrorDataSchema = exports_external2.object({
|
|
38111
38401
|
error: exports_external2.object({
|
|
@@ -38241,7 +38531,7 @@ var init_dist5 = __esm(() => {
|
|
|
38241
38531
|
store: exports_external2.boolean().optional(),
|
|
38242
38532
|
metadata: exports_external2.record(exports_external2.string().max(64), exports_external2.string().max(512)).optional(),
|
|
38243
38533
|
prediction: exports_external2.record(exports_external2.string(), exports_external2.any()).optional(),
|
|
38244
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
38534
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
38245
38535
|
strictJsonSchema: exports_external2.boolean().optional(),
|
|
38246
38536
|
textVerbosity: exports_external2.enum(["low", "medium", "high"]).optional(),
|
|
38247
38537
|
promptCacheKey: exports_external2.string().optional(),
|
|
@@ -39653,7 +39943,7 @@ var init_dist5 = __esm(() => {
|
|
|
39653
39943
|
reasoningContext: exports_external2.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
39654
39944
|
reasoningSummary: exports_external2.string().nullish(),
|
|
39655
39945
|
safetyIdentifier: exports_external2.string().nullish(),
|
|
39656
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
39946
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
39657
39947
|
store: exports_external2.boolean().nullish(),
|
|
39658
39948
|
passThroughUnsupportedFiles: exports_external2.boolean().optional(),
|
|
39659
39949
|
strictJsonSchema: exports_external2.boolean().nullish(),
|
|
@@ -39762,7 +40052,7 @@ var init_dist5 = __esm(() => {
|
|
|
39762
40052
|
openai = createOpenAI();
|
|
39763
40053
|
});
|
|
39764
40054
|
|
|
39765
|
-
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.
|
|
40055
|
+
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.69+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
39766
40056
|
var exports_dist3 = {};
|
|
39767
40057
|
__export(exports_dist3, {
|
|
39768
40058
|
createOpenAICompatible: () => createOpenAICompatible,
|
|
@@ -39813,7 +40103,7 @@ function convertOpenAICompatibleChatUsage(usage) {
|
|
|
39813
40103
|
},
|
|
39814
40104
|
outputTokens: {
|
|
39815
40105
|
total: completionTokens,
|
|
39816
|
-
text: completionTokens - reasoningTokens,
|
|
40106
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
39817
40107
|
reasoning: reasoningTokens
|
|
39818
40108
|
},
|
|
39819
40109
|
raw: usage
|
|
@@ -41187,27 +41477,27 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
|
|
|
41187
41477
|
}
|
|
41188
41478
|
};
|
|
41189
41479
|
}
|
|
41190
|
-
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.
|
|
41191
|
-
var
|
|
41192
|
-
|
|
41193
|
-
|
|
41480
|
+
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.69";
|
|
41481
|
+
var init_dist7 = __esm(() => {
|
|
41482
|
+
init_dist2();
|
|
41483
|
+
init_dist4();
|
|
41194
41484
|
init_v4();
|
|
41195
41485
|
init_v4();
|
|
41196
|
-
|
|
41197
|
-
|
|
41486
|
+
init_dist2();
|
|
41487
|
+
init_dist4();
|
|
41198
41488
|
init_v4();
|
|
41199
|
-
|
|
41200
|
-
|
|
41489
|
+
init_dist2();
|
|
41490
|
+
init_dist4();
|
|
41201
41491
|
init_v4();
|
|
41202
|
-
|
|
41492
|
+
init_dist2();
|
|
41203
41493
|
init_v4();
|
|
41204
|
-
|
|
41205
|
-
|
|
41494
|
+
init_dist2();
|
|
41495
|
+
init_dist4();
|
|
41206
41496
|
init_v4();
|
|
41207
41497
|
init_v4();
|
|
41208
|
-
|
|
41498
|
+
init_dist4();
|
|
41209
41499
|
init_v4();
|
|
41210
|
-
|
|
41500
|
+
init_dist4();
|
|
41211
41501
|
openaiCompatibleErrorDataSchema = exports_external2.object({
|
|
41212
41502
|
error: exports_external2.object({
|
|
41213
41503
|
message: exports_external2.string(),
|
|
@@ -41230,10 +41520,10 @@ var init_dist6 = __esm(() => {
|
|
|
41230
41520
|
prompt_tokens: exports_external2.number().nullish(),
|
|
41231
41521
|
completion_tokens: exports_external2.number().nullish(),
|
|
41232
41522
|
total_tokens: exports_external2.number().nullish(),
|
|
41233
|
-
prompt_tokens_details: exports_external2.
|
|
41523
|
+
prompt_tokens_details: exports_external2.looseObject({
|
|
41234
41524
|
cached_tokens: exports_external2.number().nullish()
|
|
41235
41525
|
}).nullish(),
|
|
41236
|
-
completion_tokens_details: exports_external2.
|
|
41526
|
+
completion_tokens_details: exports_external2.looseObject({
|
|
41237
41527
|
reasoning_tokens: exports_external2.number().nullish(),
|
|
41238
41528
|
accepted_prediction_tokens: exports_external2.number().nullish(),
|
|
41239
41529
|
rejected_prediction_tokens: exports_external2.number().nullish()
|
|
@@ -41300,7 +41590,7 @@ var init_dist6 = __esm(() => {
|
|
|
41300
41590
|
suffix: exports_external2.string().optional(),
|
|
41301
41591
|
user: exports_external2.string().optional()
|
|
41302
41592
|
});
|
|
41303
|
-
usageSchema = exports_external2.
|
|
41593
|
+
usageSchema = exports_external2.looseObject({
|
|
41304
41594
|
prompt_tokens: exports_external2.number(),
|
|
41305
41595
|
completion_tokens: exports_external2.number(),
|
|
41306
41596
|
total_tokens: exports_external2.number()
|
|
@@ -41429,19 +41719,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41429
41719
|
getUserDataDir: () => getUserDataDir
|
|
41430
41720
|
});
|
|
41431
41721
|
module.exports = __toCommonJS2(token_io_exports);
|
|
41432
|
-
var
|
|
41722
|
+
var import_path3 = __toESM2(__require("path"));
|
|
41433
41723
|
var import_fs2 = __toESM2(__require("fs"));
|
|
41434
|
-
var
|
|
41724
|
+
var import_os3 = __toESM2(__require("os"));
|
|
41435
41725
|
var import_token_error = require_token_error();
|
|
41436
41726
|
function findRootDir() {
|
|
41437
41727
|
try {
|
|
41438
41728
|
let dir = process.cwd();
|
|
41439
|
-
while (dir !==
|
|
41440
|
-
const pkgPath =
|
|
41729
|
+
while (dir !== import_path3.default.dirname(dir)) {
|
|
41730
|
+
const pkgPath = import_path3.default.join(dir, ".vercel");
|
|
41441
41731
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
41442
41732
|
return dir;
|
|
41443
41733
|
}
|
|
41444
|
-
dir =
|
|
41734
|
+
dir = import_path3.default.dirname(dir);
|
|
41445
41735
|
}
|
|
41446
41736
|
} catch (e) {
|
|
41447
41737
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -41452,11 +41742,11 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
41452
41742
|
if (process.env.XDG_DATA_HOME) {
|
|
41453
41743
|
return process.env.XDG_DATA_HOME;
|
|
41454
41744
|
}
|
|
41455
|
-
switch (
|
|
41745
|
+
switch (import_os3.default.platform()) {
|
|
41456
41746
|
case "darwin":
|
|
41457
|
-
return
|
|
41747
|
+
return import_path3.default.join(import_os3.default.homedir(), "Library/Application Support");
|
|
41458
41748
|
case "linux":
|
|
41459
|
-
return
|
|
41749
|
+
return import_path3.default.join(import_os3.default.homedir(), ".local/share");
|
|
41460
41750
|
case "win32":
|
|
41461
41751
|
if (process.env.LOCALAPPDATA) {
|
|
41462
41752
|
return process.env.LOCALAPPDATA;
|
|
@@ -41501,11 +41791,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
41501
41791
|
var path = __toESM2(__require("path"));
|
|
41502
41792
|
var import_token_util = require_token_util();
|
|
41503
41793
|
function getAuthConfigPath() {
|
|
41504
|
-
const
|
|
41505
|
-
if (!
|
|
41794
|
+
const dataDir2 = (0, import_token_util.getVercelDataDir)();
|
|
41795
|
+
if (!dataDir2) {
|
|
41506
41796
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
41507
41797
|
}
|
|
41508
|
-
return path.join(
|
|
41798
|
+
return path.join(dataDir2, "auth.json");
|
|
41509
41799
|
}
|
|
41510
41800
|
function readAuthConfig() {
|
|
41511
41801
|
try {
|
|
@@ -41566,10 +41856,10 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
41566
41856
|
refreshTokenRequest: () => refreshTokenRequest
|
|
41567
41857
|
});
|
|
41568
41858
|
module.exports = __toCommonJS2(oauth_exports);
|
|
41569
|
-
var
|
|
41859
|
+
var import_os3 = __require("os");
|
|
41570
41860
|
var VERCEL_ISSUER = "https://vercel.com";
|
|
41571
41861
|
var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
|
|
41572
|
-
var userAgent = `@vercel/oidc node-${process.version} ${(0,
|
|
41862
|
+
var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os3.platform)()} (${(0, import_os3.arch)()}) ${(0, import_os3.hostname)()}`;
|
|
41573
41863
|
var _tokenEndpoint = null;
|
|
41574
41864
|
async function getTokenEndpoint() {
|
|
41575
41865
|
if (_tokenEndpoint) {
|
|
@@ -41712,11 +42002,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
41712
42002
|
var import_auth_errors = require_auth_errors();
|
|
41713
42003
|
function getVercelDataDir() {
|
|
41714
42004
|
const vercelFolder = "com.vercel.cli";
|
|
41715
|
-
const
|
|
41716
|
-
if (!
|
|
42005
|
+
const dataDir2 = (0, import_token_io.getUserDataDir)();
|
|
42006
|
+
if (!dataDir2) {
|
|
41717
42007
|
return null;
|
|
41718
42008
|
}
|
|
41719
|
-
return path.join(
|
|
42009
|
+
return path.join(dataDir2, vercelFolder);
|
|
41720
42010
|
}
|
|
41721
42011
|
async function getVercelToken2(options) {
|
|
41722
42012
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -41991,7 +42281,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
41991
42281
|
var import_token_util = require_token_util();
|
|
41992
42282
|
});
|
|
41993
42283
|
|
|
41994
|
-
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.
|
|
42284
|
+
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.175+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
41995
42285
|
async function createGatewayErrorFromResponse({
|
|
41996
42286
|
response,
|
|
41997
42287
|
statusCode,
|
|
@@ -42398,11 +42688,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42398
42688
|
try {
|
|
42399
42689
|
const { value } = await getFromApi({
|
|
42400
42690
|
url: `${this.config.baseURL}/config`,
|
|
42401
|
-
headers: await
|
|
42691
|
+
headers: await resolve6(this.config.headers()),
|
|
42402
42692
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
42403
42693
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42404
42694
|
errorSchema: exports_external2.any(),
|
|
42405
|
-
errorToMessage: (data) =>
|
|
42695
|
+
errorToMessage: (data) => {
|
|
42696
|
+
var _a112;
|
|
42697
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42698
|
+
}
|
|
42406
42699
|
}),
|
|
42407
42700
|
fetch: this.config.fetch
|
|
42408
42701
|
});
|
|
@@ -42416,11 +42709,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42416
42709
|
const baseUrl = new URL(this.config.baseURL);
|
|
42417
42710
|
const { value } = await getFromApi({
|
|
42418
42711
|
url: `${baseUrl.origin}/v1/credits`,
|
|
42419
|
-
headers: await
|
|
42712
|
+
headers: await resolve6(this.config.headers()),
|
|
42420
42713
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
42421
42714
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42422
42715
|
errorSchema: exports_external2.any(),
|
|
42423
|
-
errorToMessage: (data) =>
|
|
42716
|
+
errorToMessage: (data) => {
|
|
42717
|
+
var _a112;
|
|
42718
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42719
|
+
}
|
|
42424
42720
|
}),
|
|
42425
42721
|
fetch: this.config.fetch
|
|
42426
42722
|
});
|
|
@@ -42462,11 +42758,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42462
42758
|
}
|
|
42463
42759
|
const { value } = await getFromApi({
|
|
42464
42760
|
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
42465
|
-
headers: await
|
|
42761
|
+
headers: await resolve6(this.config.headers()),
|
|
42466
42762
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
42467
42763
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42468
42764
|
errorSchema: exports_external2.any(),
|
|
42469
|
-
errorToMessage: (data) =>
|
|
42765
|
+
errorToMessage: (data) => {
|
|
42766
|
+
var _a112;
|
|
42767
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42768
|
+
}
|
|
42470
42769
|
}),
|
|
42471
42770
|
fetch: this.config.fetch
|
|
42472
42771
|
});
|
|
@@ -42484,11 +42783,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42484
42783
|
const baseUrl = new URL(this.config.baseURL);
|
|
42485
42784
|
const { value } = await getFromApi({
|
|
42486
42785
|
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
42487
|
-
headers: await
|
|
42786
|
+
headers: await resolve6(this.config.headers()),
|
|
42488
42787
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
42489
42788
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42490
42789
|
errorSchema: exports_external2.any(),
|
|
42491
|
-
errorToMessage: (data) =>
|
|
42790
|
+
errorToMessage: (data) => {
|
|
42791
|
+
var _a112;
|
|
42792
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42793
|
+
}
|
|
42492
42794
|
}),
|
|
42493
42795
|
fetch: this.config.fetch
|
|
42494
42796
|
});
|
|
@@ -42517,7 +42819,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42517
42819
|
async doGenerate(options) {
|
|
42518
42820
|
const { args, warnings } = await this.getArgs(options);
|
|
42519
42821
|
const { abortSignal } = options;
|
|
42520
|
-
const resolvedHeaders = await
|
|
42822
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42521
42823
|
try {
|
|
42522
42824
|
const {
|
|
42523
42825
|
responseHeaders,
|
|
@@ -42525,12 +42827,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42525
42827
|
rawValue: rawResponse
|
|
42526
42828
|
} = await postJsonToApi({
|
|
42527
42829
|
url: this.getUrl(),
|
|
42528
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await
|
|
42830
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve6(this.config.o11yHeaders)),
|
|
42529
42831
|
body: args,
|
|
42530
42832
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
42531
42833
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42532
42834
|
errorSchema: exports_external2.any(),
|
|
42533
|
-
errorToMessage: (data) =>
|
|
42835
|
+
errorToMessage: (data) => {
|
|
42836
|
+
var _a112;
|
|
42837
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42838
|
+
}
|
|
42534
42839
|
}),
|
|
42535
42840
|
...abortSignal && { abortSignal },
|
|
42536
42841
|
fetch: this.config.fetch
|
|
@@ -42548,16 +42853,19 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42548
42853
|
async doStream(options) {
|
|
42549
42854
|
const { args, warnings } = await this.getArgs(options);
|
|
42550
42855
|
const { abortSignal } = options;
|
|
42551
|
-
const resolvedHeaders = await
|
|
42856
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42552
42857
|
try {
|
|
42553
42858
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
42554
42859
|
url: this.getUrl(),
|
|
42555
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await
|
|
42860
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve6(this.config.o11yHeaders)),
|
|
42556
42861
|
body: args,
|
|
42557
42862
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
42558
42863
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42559
42864
|
errorSchema: exports_external2.any(),
|
|
42560
|
-
errorToMessage: (data) =>
|
|
42865
|
+
errorToMessage: (data) => {
|
|
42866
|
+
var _a112;
|
|
42867
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
42868
|
+
}
|
|
42561
42869
|
}),
|
|
42562
42870
|
...abortSignal && { abortSignal },
|
|
42563
42871
|
fetch: this.config.fetch
|
|
@@ -42637,7 +42945,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42637
42945
|
providerOptions
|
|
42638
42946
|
}) {
|
|
42639
42947
|
var _a112, _b112;
|
|
42640
|
-
const resolvedHeaders = await
|
|
42948
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42641
42949
|
try {
|
|
42642
42950
|
const {
|
|
42643
42951
|
responseHeaders,
|
|
@@ -42645,7 +42953,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42645
42953
|
rawValue
|
|
42646
42954
|
} = await postJsonToApi({
|
|
42647
42955
|
url: this.getUrl(),
|
|
42648
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
42956
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42649
42957
|
body: {
|
|
42650
42958
|
values,
|
|
42651
42959
|
...providerOptions ? { providerOptions } : {}
|
|
@@ -42653,7 +42961,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42653
42961
|
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
42654
42962
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42655
42963
|
errorSchema: exports_external2.any(),
|
|
42656
|
-
errorToMessage: (data) =>
|
|
42964
|
+
errorToMessage: (data) => {
|
|
42965
|
+
var _a122;
|
|
42966
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
42967
|
+
}
|
|
42657
42968
|
}),
|
|
42658
42969
|
...abortSignal && { abortSignal },
|
|
42659
42970
|
fetch: this.config.fetch
|
|
@@ -42701,7 +43012,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42701
43012
|
abortSignal
|
|
42702
43013
|
}) {
|
|
42703
43014
|
var _a112, _b112, _c;
|
|
42704
|
-
const resolvedHeaders = await
|
|
43015
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42705
43016
|
try {
|
|
42706
43017
|
const {
|
|
42707
43018
|
responseHeaders,
|
|
@@ -42709,7 +43020,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42709
43020
|
rawValue
|
|
42710
43021
|
} = await postJsonToApi({
|
|
42711
43022
|
url: this.getUrl(),
|
|
42712
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43023
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42713
43024
|
body: {
|
|
42714
43025
|
prompt,
|
|
42715
43026
|
n,
|
|
@@ -42725,7 +43036,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42725
43036
|
successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
|
|
42726
43037
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42727
43038
|
errorSchema: exports_external2.any(),
|
|
42728
|
-
errorToMessage: (data) =>
|
|
43039
|
+
errorToMessage: (data) => {
|
|
43040
|
+
var _a122;
|
|
43041
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43042
|
+
}
|
|
42729
43043
|
}),
|
|
42730
43044
|
...abortSignal && { abortSignal },
|
|
42731
43045
|
fetch: this.config.fetch
|
|
@@ -42786,11 +43100,11 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42786
43100
|
headers,
|
|
42787
43101
|
abortSignal
|
|
42788
43102
|
}) {
|
|
42789
|
-
const resolvedHeaders = await
|
|
43103
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42790
43104
|
try {
|
|
42791
43105
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
42792
43106
|
url: this.getUrl(),
|
|
42793
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43107
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
42794
43108
|
body: {
|
|
42795
43109
|
prompt,
|
|
42796
43110
|
n,
|
|
@@ -42878,7 +43192,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42878
43192
|
},
|
|
42879
43193
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42880
43194
|
errorSchema: exports_external2.any(),
|
|
42881
|
-
errorToMessage: (data) =>
|
|
43195
|
+
errorToMessage: (data) => {
|
|
43196
|
+
var _a112;
|
|
43197
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
43198
|
+
}
|
|
42882
43199
|
}),
|
|
42883
43200
|
...abortSignal && { abortSignal },
|
|
42884
43201
|
fetch: this.config.fetch
|
|
@@ -42924,7 +43241,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42924
43241
|
providerOptions
|
|
42925
43242
|
}) {
|
|
42926
43243
|
var _a112;
|
|
42927
|
-
const resolvedHeaders = await
|
|
43244
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42928
43245
|
try {
|
|
42929
43246
|
const {
|
|
42930
43247
|
responseHeaders,
|
|
@@ -42932,7 +43249,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42932
43249
|
rawValue
|
|
42933
43250
|
} = await postJsonToApi({
|
|
42934
43251
|
url: this.getUrl(),
|
|
42935
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43252
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42936
43253
|
body: {
|
|
42937
43254
|
documents,
|
|
42938
43255
|
query,
|
|
@@ -42942,7 +43259,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42942
43259
|
successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
|
|
42943
43260
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
42944
43261
|
errorSchema: exports_external2.any(),
|
|
42945
|
-
errorToMessage: (data) =>
|
|
43262
|
+
errorToMessage: (data) => {
|
|
43263
|
+
var _a122;
|
|
43264
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43265
|
+
}
|
|
42946
43266
|
}),
|
|
42947
43267
|
...abortSignal && { abortSignal },
|
|
42948
43268
|
fetch: this.config.fetch
|
|
@@ -42986,7 +43306,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42986
43306
|
headers,
|
|
42987
43307
|
abortSignal
|
|
42988
43308
|
}) {
|
|
42989
|
-
const resolvedHeaders = await
|
|
43309
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
42990
43310
|
try {
|
|
42991
43311
|
const {
|
|
42992
43312
|
responseHeaders,
|
|
@@ -42994,7 +43314,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
42994
43314
|
rawValue
|
|
42995
43315
|
} = await postJsonToApi({
|
|
42996
43316
|
url: this.getUrl(),
|
|
42997
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43317
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
42998
43318
|
body: {
|
|
42999
43319
|
text: text2,
|
|
43000
43320
|
...voice && { voice },
|
|
@@ -43007,7 +43327,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43007
43327
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
43008
43328
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43009
43329
|
errorSchema: exports_external2.any(),
|
|
43010
|
-
errorToMessage: (data) =>
|
|
43330
|
+
errorToMessage: (data) => {
|
|
43331
|
+
var _a112;
|
|
43332
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
43333
|
+
}
|
|
43011
43334
|
}),
|
|
43012
43335
|
...abortSignal && { abortSignal },
|
|
43013
43336
|
fetch: this.config.fetch
|
|
@@ -43053,7 +43376,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43053
43376
|
abortSignal
|
|
43054
43377
|
}) {
|
|
43055
43378
|
var _a112, _b112, _c;
|
|
43056
|
-
const resolvedHeaders = await
|
|
43379
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
43057
43380
|
try {
|
|
43058
43381
|
const {
|
|
43059
43382
|
responseHeaders,
|
|
@@ -43061,7 +43384,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43061
43384
|
rawValue
|
|
43062
43385
|
} = await postJsonToApi({
|
|
43063
43386
|
url: this.getUrl(),
|
|
43064
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
43387
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve6(this.config.o11yHeaders)),
|
|
43065
43388
|
body: {
|
|
43066
43389
|
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
43067
43390
|
mediaType,
|
|
@@ -43070,7 +43393,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43070
43393
|
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
43071
43394
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
43072
43395
|
errorSchema: exports_external2.any(),
|
|
43073
|
-
errorToMessage: (data) =>
|
|
43396
|
+
errorToMessage: (data) => {
|
|
43397
|
+
var _a122;
|
|
43398
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
43399
|
+
}
|
|
43074
43400
|
}),
|
|
43075
43401
|
...abortSignal && { abortSignal },
|
|
43076
43402
|
fetch: this.config.fetch
|
|
@@ -43102,45 +43428,45 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
43102
43428
|
"ai-model-id": this.modelId
|
|
43103
43429
|
};
|
|
43104
43430
|
}
|
|
43105
|
-
}, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.
|
|
43106
|
-
var
|
|
43107
|
-
|
|
43108
|
-
|
|
43431
|
+
}, providerMetadataEntrySchema4, gatewayTranscriptionWarningSchema, gatewayTranscriptionResponseSchema, exaSearchInputSchema, exaSearchOutputSchema, exaSearchToolFactory, exaSearch = (config2 = {}) => exaSearchToolFactory(config2), parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION5 = "3.0.175", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
43432
|
+
var init_dist8 = __esm(() => {
|
|
43433
|
+
init_dist4();
|
|
43434
|
+
init_dist2();
|
|
43109
43435
|
init_v4();
|
|
43110
43436
|
init_v4();
|
|
43111
|
-
|
|
43437
|
+
init_dist4();
|
|
43112
43438
|
init_v4();
|
|
43113
|
-
|
|
43114
|
-
|
|
43115
|
-
|
|
43439
|
+
init_dist4();
|
|
43440
|
+
init_dist4();
|
|
43441
|
+
init_dist4();
|
|
43116
43442
|
init_v4();
|
|
43117
|
-
|
|
43118
|
-
|
|
43443
|
+
init_dist4();
|
|
43444
|
+
init_dist4();
|
|
43119
43445
|
init_v4();
|
|
43120
|
-
|
|
43446
|
+
init_dist4();
|
|
43121
43447
|
init_v4();
|
|
43122
|
-
|
|
43448
|
+
init_dist4();
|
|
43123
43449
|
init_v4();
|
|
43124
|
-
|
|
43450
|
+
init_dist4();
|
|
43125
43451
|
init_v4();
|
|
43126
|
-
|
|
43452
|
+
init_dist4();
|
|
43127
43453
|
init_v4();
|
|
43128
|
-
|
|
43454
|
+
init_dist4();
|
|
43129
43455
|
init_v4();
|
|
43130
|
-
|
|
43131
|
-
|
|
43456
|
+
init_dist2();
|
|
43457
|
+
init_dist4();
|
|
43132
43458
|
init_v4();
|
|
43133
|
-
|
|
43459
|
+
init_dist4();
|
|
43134
43460
|
init_v4();
|
|
43135
|
-
|
|
43461
|
+
init_dist4();
|
|
43136
43462
|
init_v4();
|
|
43137
|
-
|
|
43463
|
+
init_dist4();
|
|
43138
43464
|
init_v4();
|
|
43139
|
-
|
|
43465
|
+
init_dist4();
|
|
43140
43466
|
init_zod();
|
|
43141
|
-
|
|
43467
|
+
init_dist4();
|
|
43142
43468
|
init_zod();
|
|
43143
|
-
|
|
43469
|
+
init_dist4();
|
|
43144
43470
|
init_zod();
|
|
43145
43471
|
import_oidc = __toESM(require_dist(), 1);
|
|
43146
43472
|
import_oidc2 = __toESM(require_dist(), 1);
|
|
@@ -45418,7 +45744,7 @@ var require_src = __commonJS((exports) => {
|
|
|
45418
45744
|
};
|
|
45419
45745
|
});
|
|
45420
45746
|
|
|
45421
|
-
// ../../node_modules/.bun/ai@6.0.
|
|
45747
|
+
// ../../node_modules/.bun/ai@6.0.257+27912429049419a2/node_modules/ai/dist/index.mjs
|
|
45422
45748
|
var exports_dist4 = {};
|
|
45423
45749
|
__export(exports_dist4, {
|
|
45424
45750
|
zodSchema: () => zodSchema,
|
|
@@ -46703,7 +47029,8 @@ async function recordSpan({
|
|
|
46703
47029
|
tracer,
|
|
46704
47030
|
attributes,
|
|
46705
47031
|
fn,
|
|
46706
|
-
endWhenDone = true
|
|
47032
|
+
endWhenDone = true,
|
|
47033
|
+
endOnError = endWhenDone
|
|
46707
47034
|
}) {
|
|
46708
47035
|
return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
|
|
46709
47036
|
const ctx = import_api3.context.active();
|
|
@@ -46717,7 +47044,9 @@ async function recordSpan({
|
|
|
46717
47044
|
try {
|
|
46718
47045
|
recordErrorOnSpan(span, error40);
|
|
46719
47046
|
} finally {
|
|
46720
|
-
|
|
47047
|
+
if (endOnError) {
|
|
47048
|
+
span.end();
|
|
47049
|
+
}
|
|
46721
47050
|
}
|
|
46722
47051
|
throw error40;
|
|
46723
47052
|
}
|
|
@@ -49187,6 +49516,7 @@ function processUIMessageStream({
|
|
|
49187
49516
|
case "reasoning-start": {
|
|
49188
49517
|
const reasoningPart = {
|
|
49189
49518
|
type: "reasoning",
|
|
49519
|
+
id: chunk.id,
|
|
49190
49520
|
text: "",
|
|
49191
49521
|
providerMetadata: chunk.providerMetadata,
|
|
49192
49522
|
state: "streaming"
|
|
@@ -49483,7 +49813,7 @@ function processUIMessageStream({
|
|
|
49483
49813
|
}
|
|
49484
49814
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
49485
49815
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
49486
|
-
write();
|
|
49816
|
+
write({ updateStatus: false });
|
|
49487
49817
|
}
|
|
49488
49818
|
break;
|
|
49489
49819
|
}
|
|
@@ -49706,9 +50036,18 @@ function createAsyncIterableStream(source) {
|
|
|
49706
50036
|
}
|
|
49707
50037
|
async function consumeStream({
|
|
49708
50038
|
stream,
|
|
49709
|
-
onError
|
|
50039
|
+
onError,
|
|
50040
|
+
abortSignal
|
|
49710
50041
|
}) {
|
|
49711
50042
|
const reader = stream.getReader();
|
|
50043
|
+
const cancelOnAbort = () => {
|
|
50044
|
+
reader.cancel().catch(() => {});
|
|
50045
|
+
};
|
|
50046
|
+
if (abortSignal == null ? undefined : abortSignal.aborted) {
|
|
50047
|
+
cancelOnAbort();
|
|
50048
|
+
} else {
|
|
50049
|
+
abortSignal == null || abortSignal.addEventListener("abort", cancelOnAbort, { once: true });
|
|
50050
|
+
}
|
|
49712
50051
|
try {
|
|
49713
50052
|
while (true) {
|
|
49714
50053
|
const { done } = await reader.read();
|
|
@@ -49718,6 +50057,7 @@ async function consumeStream({
|
|
|
49718
50057
|
} catch (error40) {
|
|
49719
50058
|
onError == null || onError(error40);
|
|
49720
50059
|
} finally {
|
|
50060
|
+
abortSignal == null || abortSignal.removeEventListener("abort", cancelOnAbort);
|
|
49721
50061
|
reader.releaseLock();
|
|
49722
50062
|
}
|
|
49723
50063
|
}
|
|
@@ -50318,6 +50658,27 @@ function createUIMessageStream({
|
|
|
50318
50658
|
onError
|
|
50319
50659
|
});
|
|
50320
50660
|
}
|
|
50661
|
+
function createUIMessageSnapshot(message) {
|
|
50662
|
+
const textByPartIndex = /* @__PURE__ */ new Map;
|
|
50663
|
+
const messageWithoutText = {
|
|
50664
|
+
...message,
|
|
50665
|
+
parts: message.parts.map((part, index) => {
|
|
50666
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
50667
|
+
textByPartIndex.set(index, part.text);
|
|
50668
|
+
return { ...part, text: "" };
|
|
50669
|
+
}
|
|
50670
|
+
return part;
|
|
50671
|
+
})
|
|
50672
|
+
};
|
|
50673
|
+
const snapshot = structuredClone(messageWithoutText);
|
|
50674
|
+
for (const [index, text22] of textByPartIndex) {
|
|
50675
|
+
const part = snapshot.parts[index];
|
|
50676
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
50677
|
+
part.text = text22;
|
|
50678
|
+
}
|
|
50679
|
+
}
|
|
50680
|
+
return snapshot;
|
|
50681
|
+
}
|
|
50321
50682
|
function readUIMessageStream({
|
|
50322
50683
|
message,
|
|
50323
50684
|
stream,
|
|
@@ -50350,7 +50711,7 @@ function readUIMessageStream({
|
|
|
50350
50711
|
return job({
|
|
50351
50712
|
state,
|
|
50352
50713
|
write: () => {
|
|
50353
|
-
controller == null || controller.enqueue(
|
|
50714
|
+
controller == null || controller.enqueue(createUIMessageSnapshot(state.message));
|
|
50354
50715
|
}
|
|
50355
50716
|
});
|
|
50356
50717
|
},
|
|
@@ -53233,7 +53594,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53233
53594
|
}, imageMediaTypeSignatures, audioMediaTypeSignatures, videoMediaTypeSignatures, DEFAULT_SNIFF_BYTES = 18, MAX_SIGNATURE_BYTES = 12, MAX_ID3_TAG_BYTES, ID3_SCAN_BYTES, stripID3 = (bytes) => {
|
|
53234
53595
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
53235
53596
|
return bytes.subarray(id3Size + 10);
|
|
53236
|
-
}, VERSION6 = "6.0.
|
|
53597
|
+
}, VERSION6 = "6.0.257", download = async ({
|
|
53237
53598
|
url: url2,
|
|
53238
53599
|
maxBytes,
|
|
53239
53600
|
abortSignal
|
|
@@ -53328,7 +53689,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53328
53689
|
const schema = asSchema(inputSchema);
|
|
53329
53690
|
return {
|
|
53330
53691
|
name: "object",
|
|
53331
|
-
responseFormat:
|
|
53692
|
+
responseFormat: resolve6(schema.jsonSchema).then((jsonSchema2) => ({
|
|
53332
53693
|
type: "json",
|
|
53333
53694
|
schema: jsonSchema2,
|
|
53334
53695
|
...name222 != null && { name: name222 },
|
|
@@ -53389,7 +53750,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
53389
53750
|
const elementSchema = asSchema(inputElementSchema);
|
|
53390
53751
|
return {
|
|
53391
53752
|
name: "array",
|
|
53392
|
-
responseFormat:
|
|
53753
|
+
responseFormat: resolve6(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
53393
53754
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
53394
53755
|
return {
|
|
53395
53756
|
type: "json",
|
|
@@ -54432,6 +54793,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
54432
54793
|
}),
|
|
54433
54794
|
tracer,
|
|
54434
54795
|
endWhenDone: false,
|
|
54796
|
+
endOnError: true,
|
|
54435
54797
|
fn: async (doStreamSpan2) => ({
|
|
54436
54798
|
startTimestampMs: now22(),
|
|
54437
54799
|
doStreamSpan: doStreamSpan2,
|
|
@@ -55351,10 +55713,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55351
55713
|
onStepFinish,
|
|
55352
55714
|
...options
|
|
55353
55715
|
}) {
|
|
55716
|
+
const preparedCall = await this.prepareCall(options);
|
|
55354
55717
|
return generateText({
|
|
55355
|
-
...
|
|
55718
|
+
...preparedCall,
|
|
55356
55719
|
abortSignal,
|
|
55357
|
-
timeout,
|
|
55720
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
55358
55721
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
55359
55722
|
});
|
|
55360
55723
|
}
|
|
@@ -55365,10 +55728,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55365
55728
|
onStepFinish,
|
|
55366
55729
|
...options
|
|
55367
55730
|
}) {
|
|
55731
|
+
const preparedCall = await this.prepareCall(options);
|
|
55368
55732
|
return streamText({
|
|
55369
|
-
...
|
|
55733
|
+
...preparedCall,
|
|
55370
55734
|
abortSignal,
|
|
55371
|
-
timeout,
|
|
55735
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
55372
55736
|
experimental_transform,
|
|
55373
55737
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
55374
55738
|
});
|
|
@@ -55725,6 +56089,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55725
56089
|
}),
|
|
55726
56090
|
tracer,
|
|
55727
56091
|
endWhenDone: false,
|
|
56092
|
+
endOnError: true,
|
|
55728
56093
|
fn: async (rootSpan) => {
|
|
55729
56094
|
const standardizedPrompt = await standardizePrompt({
|
|
55730
56095
|
system,
|
|
@@ -55794,6 +56159,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
55794
56159
|
}),
|
|
55795
56160
|
tracer,
|
|
55796
56161
|
endWhenDone: false,
|
|
56162
|
+
endOnError: true,
|
|
55797
56163
|
fn: async (doStreamSpan2) => ({
|
|
55798
56164
|
startTimestampMs: now22(),
|
|
55799
56165
|
doStreamSpan: doStreamSpan2,
|
|
@@ -56380,9 +56746,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56380
56746
|
...options
|
|
56381
56747
|
}) {
|
|
56382
56748
|
var _a222, _b16, _c, _d, _e;
|
|
56383
|
-
const resolvedBody = await
|
|
56384
|
-
const resolvedHeaders = await
|
|
56385
|
-
const resolvedCredentials = await
|
|
56749
|
+
const resolvedBody = await resolve6(this.body);
|
|
56750
|
+
const resolvedHeaders = await resolve6(this.headers);
|
|
56751
|
+
const resolvedCredentials = await resolve6(this.credentials);
|
|
56386
56752
|
const baseHeaders = {
|
|
56387
56753
|
...normalizeHeaders(resolvedHeaders),
|
|
56388
56754
|
...normalizeHeaders(options.headers)
|
|
@@ -56430,9 +56796,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56430
56796
|
}
|
|
56431
56797
|
async reconnectToStream(options) {
|
|
56432
56798
|
var _a222, _b16, _c, _d, _e;
|
|
56433
|
-
const resolvedBody = await
|
|
56434
|
-
const resolvedHeaders = await
|
|
56435
|
-
const resolvedCredentials = await
|
|
56799
|
+
const resolvedBody = await resolve6(this.body);
|
|
56800
|
+
const resolvedHeaders = await resolve6(this.headers);
|
|
56801
|
+
const resolvedCredentials = await resolve6(this.credentials);
|
|
56436
56802
|
const baseHeaders = {
|
|
56437
56803
|
...normalizeHeaders(resolvedHeaders),
|
|
56438
56804
|
...normalizeHeaders(options.headers)
|
|
@@ -56452,7 +56818,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56452
56818
|
const response = await fetch2(api2, {
|
|
56453
56819
|
method: "GET",
|
|
56454
56820
|
headers,
|
|
56455
|
-
credentials
|
|
56821
|
+
credentials,
|
|
56822
|
+
signal: options.abortSignal
|
|
56456
56823
|
});
|
|
56457
56824
|
if (response.status === 204) {
|
|
56458
56825
|
return null;
|
|
@@ -56480,6 +56847,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56480
56847
|
sendAutomaticallyWhen
|
|
56481
56848
|
}) {
|
|
56482
56849
|
this.activeResponse = undefined;
|
|
56850
|
+
this.activeResumeRequest = undefined;
|
|
56483
56851
|
this.jobExecutor = new SerialJobExecutor;
|
|
56484
56852
|
this.sendMessage = async (message, options) => {
|
|
56485
56853
|
var _a222, _b16, _c, _d;
|
|
@@ -56621,12 +56989,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56621
56989
|
});
|
|
56622
56990
|
this.addToolResult = this.addToolOutput;
|
|
56623
56991
|
this.stop = async () => {
|
|
56624
|
-
var _a222;
|
|
56625
|
-
|
|
56626
|
-
|
|
56627
|
-
if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
|
|
56628
|
-
this.activeResponse.abortController.abort();
|
|
56629
|
-
}
|
|
56992
|
+
var _a222, _b16;
|
|
56993
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
56994
|
+
(_b16 = this.activeResponse) == null || _b16.abortController.abort();
|
|
56630
56995
|
};
|
|
56631
56996
|
this.id = id;
|
|
56632
56997
|
this.transport = transport;
|
|
@@ -56682,25 +57047,59 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56682
57047
|
body,
|
|
56683
57048
|
messageId
|
|
56684
57049
|
}) {
|
|
56685
|
-
var _a222, _b16;
|
|
57050
|
+
var _a222, _b16, _c;
|
|
57051
|
+
const abortController = new AbortController;
|
|
57052
|
+
const activeResumeRequest = trigger === "resume-stream" ? { abortController } : undefined;
|
|
57053
|
+
if (activeResumeRequest) {
|
|
57054
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
57055
|
+
this.activeResumeRequest = activeResumeRequest;
|
|
57056
|
+
}
|
|
57057
|
+
const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
|
|
57058
|
+
const clearActiveResumeRequest = () => {
|
|
57059
|
+
if (this.activeResumeRequest === activeResumeRequest) {
|
|
57060
|
+
this.activeResumeRequest = undefined;
|
|
57061
|
+
}
|
|
57062
|
+
};
|
|
56686
57063
|
let resumeStream;
|
|
56687
57064
|
if (trigger === "resume-stream") {
|
|
56688
57065
|
try {
|
|
56689
57066
|
const reconnect = await this.transport.reconnectToStream({
|
|
56690
57067
|
chatId: this.id,
|
|
57068
|
+
abortSignal: abortController.signal,
|
|
56691
57069
|
metadata,
|
|
56692
57070
|
headers,
|
|
56693
57071
|
body
|
|
56694
57072
|
});
|
|
57073
|
+
if (abortController.signal.aborted || !isCurrentRequest()) {
|
|
57074
|
+
await (reconnect == null ? undefined : reconnect.cancel().catch(() => {}));
|
|
57075
|
+
if (isCurrentRequest()) {
|
|
57076
|
+
this.setStatus({ status: "ready" });
|
|
57077
|
+
}
|
|
57078
|
+
clearActiveResumeRequest();
|
|
57079
|
+
return;
|
|
57080
|
+
}
|
|
56695
57081
|
if (reconnect == null) {
|
|
57082
|
+
this.setStatus({ status: "ready" });
|
|
57083
|
+
clearActiveResumeRequest();
|
|
56696
57084
|
return;
|
|
56697
57085
|
}
|
|
56698
57086
|
resumeStream = reconnect;
|
|
56699
57087
|
} catch (err) {
|
|
57088
|
+
if (abortController.signal.aborted || err.name === "AbortError") {
|
|
57089
|
+
if (isCurrentRequest()) {
|
|
57090
|
+
this.setStatus({ status: "ready" });
|
|
57091
|
+
}
|
|
57092
|
+
clearActiveResumeRequest();
|
|
57093
|
+
return;
|
|
57094
|
+
}
|
|
57095
|
+
if (!isCurrentRequest()) {
|
|
57096
|
+
return;
|
|
57097
|
+
}
|
|
56700
57098
|
if (this.onError && err instanceof Error) {
|
|
56701
57099
|
this.onError(err);
|
|
56702
57100
|
}
|
|
56703
57101
|
this.setStatus({ status: "error", error: err });
|
|
57102
|
+
clearActiveResumeRequest();
|
|
56704
57103
|
return;
|
|
56705
57104
|
}
|
|
56706
57105
|
}
|
|
@@ -56713,10 +57112,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56713
57112
|
try {
|
|
56714
57113
|
const response = {
|
|
56715
57114
|
state: createStreamingUIMessageState({
|
|
56716
|
-
lastMessage: trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
57115
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
56717
57116
|
messageId: this.generateId()
|
|
56718
57117
|
}),
|
|
56719
|
-
abortController
|
|
57118
|
+
abortController
|
|
56720
57119
|
};
|
|
56721
57120
|
activeResponse = response;
|
|
56722
57121
|
response.abortController.signal.addEventListener("abort", () => {
|
|
@@ -56738,19 +57137,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56738
57137
|
messageId
|
|
56739
57138
|
});
|
|
56740
57139
|
}
|
|
56741
|
-
const runUpdateMessageJob = (job) => this.jobExecutor.run(() =>
|
|
56742
|
-
|
|
56743
|
-
|
|
56744
|
-
var _a232;
|
|
56745
|
-
this.setStatus({ status: "streaming" });
|
|
56746
|
-
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
56747
|
-
if (replaceLastMessage) {
|
|
56748
|
-
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
56749
|
-
} else {
|
|
56750
|
-
this.state.pushMessage(response.state.message);
|
|
56751
|
-
}
|
|
57140
|
+
const runUpdateMessageJob = (job) => this.jobExecutor.run(() => {
|
|
57141
|
+
if (response.abortController.signal.aborted) {
|
|
57142
|
+
return Promise.resolve();
|
|
56752
57143
|
}
|
|
56753
|
-
|
|
57144
|
+
return job({
|
|
57145
|
+
state: response.state,
|
|
57146
|
+
write: ({ updateStatus = true } = {}) => {
|
|
57147
|
+
var _a232;
|
|
57148
|
+
if (response.abortController.signal.aborted) {
|
|
57149
|
+
return;
|
|
57150
|
+
}
|
|
57151
|
+
if (updateStatus) {
|
|
57152
|
+
this.setStatus({ status: "streaming" });
|
|
57153
|
+
}
|
|
57154
|
+
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
57155
|
+
if (replaceLastMessage) {
|
|
57156
|
+
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
57157
|
+
} else {
|
|
57158
|
+
this.state.pushMessage(response.state.message);
|
|
57159
|
+
}
|
|
57160
|
+
}
|
|
57161
|
+
});
|
|
57162
|
+
});
|
|
56754
57163
|
await consumeStream({
|
|
56755
57164
|
stream: processUIMessageStream({
|
|
56756
57165
|
stream,
|
|
@@ -56763,15 +57172,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56763
57172
|
throw error40;
|
|
56764
57173
|
}
|
|
56765
57174
|
}),
|
|
57175
|
+
abortSignal: response.abortController.signal,
|
|
56766
57176
|
onError: (error40) => {
|
|
56767
57177
|
throw error40;
|
|
56768
57178
|
}
|
|
56769
57179
|
});
|
|
56770
|
-
|
|
57180
|
+
if (isAbort) {
|
|
57181
|
+
if (isCurrentRequest()) {
|
|
57182
|
+
this.setStatus({ status: "ready" });
|
|
57183
|
+
}
|
|
57184
|
+
return null;
|
|
57185
|
+
}
|
|
57186
|
+
if (isCurrentRequest()) {
|
|
57187
|
+
this.setStatus({ status: "ready" });
|
|
57188
|
+
}
|
|
56771
57189
|
} catch (err) {
|
|
56772
57190
|
if (isAbort || err.name === "AbortError") {
|
|
56773
57191
|
isAbort = true;
|
|
56774
|
-
|
|
57192
|
+
if (isCurrentRequest()) {
|
|
57193
|
+
this.setStatus({ status: "ready" });
|
|
57194
|
+
}
|
|
57195
|
+
return null;
|
|
57196
|
+
}
|
|
57197
|
+
if (!isCurrentRequest()) {
|
|
56775
57198
|
return null;
|
|
56776
57199
|
}
|
|
56777
57200
|
isError = true;
|
|
@@ -56785,7 +57208,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56785
57208
|
} finally {
|
|
56786
57209
|
try {
|
|
56787
57210
|
if (activeResponse) {
|
|
56788
|
-
(
|
|
57211
|
+
(_b16 = this.onFinish) == null || _b16.call(this, {
|
|
56789
57212
|
message: activeResponse.state.message,
|
|
56790
57213
|
messages: this.state.messages,
|
|
56791
57214
|
isAbort,
|
|
@@ -56794,17 +57217,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56794
57217
|
finishReason: activeResponse.state.finishReason
|
|
56795
57218
|
});
|
|
56796
57219
|
}
|
|
56797
|
-
}
|
|
56798
|
-
|
|
56799
|
-
|
|
56800
|
-
|
|
56801
|
-
|
|
57220
|
+
} finally {
|
|
57221
|
+
if (this.activeResponse === activeResponse) {
|
|
57222
|
+
this.activeResponse = undefined;
|
|
57223
|
+
}
|
|
57224
|
+
clearActiveResumeRequest();
|
|
56802
57225
|
}
|
|
56803
57226
|
}
|
|
56804
57227
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
56805
57228
|
await this.makeRequest({
|
|
56806
57229
|
trigger: "submit-message",
|
|
56807
|
-
messageId: (
|
|
57230
|
+
messageId: (_c = this.lastMessage) == null ? undefined : _c.id,
|
|
56808
57231
|
metadata,
|
|
56809
57232
|
headers,
|
|
56810
57233
|
body
|
|
@@ -56843,96 +57266,96 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
56843
57266
|
return null;
|
|
56844
57267
|
}
|
|
56845
57268
|
}, TextStreamChatTransport;
|
|
56846
|
-
var
|
|
56847
|
-
|
|
56848
|
-
|
|
56849
|
-
|
|
56850
|
-
|
|
56851
|
-
|
|
56852
|
-
|
|
56853
|
-
|
|
56854
|
-
|
|
56855
|
-
|
|
56856
|
-
|
|
56857
|
-
|
|
56858
|
-
|
|
56859
|
-
|
|
56860
|
-
|
|
56861
|
-
|
|
56862
|
-
|
|
56863
|
-
|
|
56864
|
-
|
|
56865
|
-
|
|
56866
|
-
|
|
56867
|
-
|
|
56868
|
-
|
|
56869
|
-
|
|
56870
|
-
|
|
56871
|
-
|
|
56872
|
-
|
|
56873
|
-
|
|
56874
|
-
|
|
56875
|
-
|
|
56876
|
-
|
|
56877
|
-
|
|
56878
|
-
|
|
56879
|
-
|
|
57269
|
+
var init_dist9 = __esm(() => {
|
|
57270
|
+
init_dist8();
|
|
57271
|
+
init_dist4();
|
|
57272
|
+
init_dist4();
|
|
57273
|
+
init_dist4();
|
|
57274
|
+
init_dist2();
|
|
57275
|
+
init_dist2();
|
|
57276
|
+
init_dist2();
|
|
57277
|
+
init_dist2();
|
|
57278
|
+
init_dist2();
|
|
57279
|
+
init_dist2();
|
|
57280
|
+
init_dist2();
|
|
57281
|
+
init_dist2();
|
|
57282
|
+
init_dist2();
|
|
57283
|
+
init_dist2();
|
|
57284
|
+
init_dist2();
|
|
57285
|
+
init_dist2();
|
|
57286
|
+
init_dist2();
|
|
57287
|
+
init_dist2();
|
|
57288
|
+
init_dist2();
|
|
57289
|
+
init_dist2();
|
|
57290
|
+
init_dist2();
|
|
57291
|
+
init_dist2();
|
|
57292
|
+
init_dist2();
|
|
57293
|
+
init_dist2();
|
|
57294
|
+
init_dist2();
|
|
57295
|
+
init_dist4();
|
|
57296
|
+
init_dist2();
|
|
57297
|
+
init_dist8();
|
|
57298
|
+
init_dist4();
|
|
57299
|
+
init_dist4();
|
|
57300
|
+
init_dist4();
|
|
57301
|
+
init_dist2();
|
|
57302
|
+
init_dist4();
|
|
56880
57303
|
init_v4();
|
|
56881
|
-
|
|
56882
|
-
|
|
56883
|
-
|
|
56884
|
-
|
|
57304
|
+
init_dist2();
|
|
57305
|
+
init_dist4();
|
|
57306
|
+
init_dist2();
|
|
57307
|
+
init_dist4();
|
|
56885
57308
|
init_v4();
|
|
56886
57309
|
init_v4();
|
|
56887
57310
|
init_v4();
|
|
56888
57311
|
init_v4();
|
|
56889
57312
|
init_v4();
|
|
56890
|
-
|
|
56891
|
-
|
|
56892
|
-
|
|
56893
|
-
|
|
56894
|
-
|
|
56895
|
-
|
|
56896
|
-
|
|
56897
|
-
|
|
56898
|
-
|
|
56899
|
-
|
|
56900
|
-
|
|
56901
|
-
|
|
56902
|
-
|
|
56903
|
-
|
|
56904
|
-
|
|
56905
|
-
|
|
57313
|
+
init_dist8();
|
|
57314
|
+
init_dist2();
|
|
57315
|
+
init_dist2();
|
|
57316
|
+
init_dist8();
|
|
57317
|
+
init_dist4();
|
|
57318
|
+
init_dist4();
|
|
57319
|
+
init_dist4();
|
|
57320
|
+
init_dist4();
|
|
57321
|
+
init_dist4();
|
|
57322
|
+
init_dist2();
|
|
57323
|
+
init_dist4();
|
|
57324
|
+
init_dist4();
|
|
57325
|
+
init_dist4();
|
|
57326
|
+
init_dist2();
|
|
57327
|
+
init_dist4();
|
|
57328
|
+
init_dist4();
|
|
56906
57329
|
init_v4();
|
|
56907
|
-
|
|
56908
|
-
|
|
56909
|
-
|
|
56910
|
-
|
|
56911
|
-
|
|
56912
|
-
|
|
57330
|
+
init_dist4();
|
|
57331
|
+
init_dist4();
|
|
57332
|
+
init_dist4();
|
|
57333
|
+
init_dist4();
|
|
57334
|
+
init_dist2();
|
|
57335
|
+
init_dist4();
|
|
56913
57336
|
init_v4();
|
|
56914
|
-
|
|
56915
|
-
|
|
56916
|
-
|
|
56917
|
-
|
|
56918
|
-
|
|
56919
|
-
|
|
56920
|
-
|
|
56921
|
-
|
|
56922
|
-
|
|
56923
|
-
|
|
56924
|
-
|
|
56925
|
-
|
|
56926
|
-
|
|
56927
|
-
|
|
56928
|
-
|
|
56929
|
-
|
|
56930
|
-
|
|
56931
|
-
|
|
56932
|
-
|
|
56933
|
-
|
|
56934
|
-
|
|
56935
|
-
|
|
57337
|
+
init_dist4();
|
|
57338
|
+
init_dist4();
|
|
57339
|
+
init_dist4();
|
|
57340
|
+
init_dist4();
|
|
57341
|
+
init_dist2();
|
|
57342
|
+
init_dist4();
|
|
57343
|
+
init_dist2();
|
|
57344
|
+
init_dist4();
|
|
57345
|
+
init_dist4();
|
|
57346
|
+
init_dist4();
|
|
57347
|
+
init_dist4();
|
|
57348
|
+
init_dist4();
|
|
57349
|
+
init_dist2();
|
|
57350
|
+
init_dist4();
|
|
57351
|
+
init_dist2();
|
|
57352
|
+
init_dist2();
|
|
57353
|
+
init_dist2();
|
|
57354
|
+
init_dist4();
|
|
57355
|
+
init_dist4();
|
|
57356
|
+
init_dist4();
|
|
57357
|
+
init_dist4();
|
|
57358
|
+
init_dist4();
|
|
56936
57359
|
import_api2 = __toESM(require_src(), 1);
|
|
56937
57360
|
import_api3 = __toESM(require_src(), 1);
|
|
56938
57361
|
__defProp2 = Object.defineProperty;
|
|
@@ -57991,6 +58414,7 @@ var init_dist8 = __esm(() => {
|
|
|
57991
58414
|
}),
|
|
57992
58415
|
exports_external2.object({
|
|
57993
58416
|
type: exports_external2.literal("reasoning"),
|
|
58417
|
+
id: exports_external2.string().optional(),
|
|
57994
58418
|
text: exports_external2.string(),
|
|
57995
58419
|
state: exports_external2.enum(["streaming", "done"]).optional(),
|
|
57996
58420
|
providerMetadata: providerMetadataSchema.optional()
|
|
@@ -58757,12 +59181,12 @@ init_machines();
|
|
|
58757
59181
|
// src/lib/project-detect.ts
|
|
58758
59182
|
init_database();
|
|
58759
59183
|
init_api_mode();
|
|
58760
|
-
import { existsSync as
|
|
58761
|
-
import { basename, dirname as dirname2, join as
|
|
59184
|
+
import { existsSync as existsSync4 } from "fs";
|
|
59185
|
+
import { basename, dirname as dirname2, join as join6, resolve as resolve3 } from "path";
|
|
58762
59186
|
function findGitRoot2(startDir) {
|
|
58763
|
-
let dir =
|
|
59187
|
+
let dir = resolve3(startDir);
|
|
58764
59188
|
while (true) {
|
|
58765
|
-
if (
|
|
59189
|
+
if (existsSync4(join6(dir, ".git")))
|
|
58766
59190
|
return dir;
|
|
58767
59191
|
const parent = dirname2(dir);
|
|
58768
59192
|
if (parent === dir)
|
|
@@ -58782,7 +59206,7 @@ function detectProject(db) {
|
|
|
58782
59206
|
return null;
|
|
58783
59207
|
}
|
|
58784
59208
|
const repoName = basename(gitRoot);
|
|
58785
|
-
const absPath =
|
|
59209
|
+
const absPath = resolve3(gitRoot);
|
|
58786
59210
|
const d = db ?? (isApiMode() ? undefined : getDatabase());
|
|
58787
59211
|
const existing = getProject(absPath, d);
|
|
58788
59212
|
if (existing) {
|
|
@@ -58798,23 +59222,23 @@ function detectProject(db) {
|
|
|
58798
59222
|
init_built_in_hooks();
|
|
58799
59223
|
|
|
58800
59224
|
// src/lib/session-watcher.ts
|
|
58801
|
-
import { watch, existsSync as
|
|
58802
|
-
import { join as
|
|
59225
|
+
import { watch, existsSync as existsSync5, statSync, readFileSync as readFileSync2 } from "fs";
|
|
59226
|
+
import { join as join7 } from "path";
|
|
58803
59227
|
import { readdirSync } from "fs";
|
|
58804
59228
|
function encodeCwd(cwd) {
|
|
58805
59229
|
return cwd.replace(/\//g, "-");
|
|
58806
59230
|
}
|
|
58807
59231
|
function getProjectsDir() {
|
|
58808
59232
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
58809
|
-
return
|
|
59233
|
+
return join7(home, ".claude", "projects");
|
|
58810
59234
|
}
|
|
58811
59235
|
function findActiveSession(projectDir) {
|
|
58812
|
-
if (!
|
|
59236
|
+
if (!existsSync5(projectDir))
|
|
58813
59237
|
return null;
|
|
58814
59238
|
const files = readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).map((f) => ({
|
|
58815
59239
|
name: f,
|
|
58816
|
-
path:
|
|
58817
|
-
mtime: statSync(
|
|
59240
|
+
path: join7(projectDir, f),
|
|
59241
|
+
mtime: statSync(join7(projectDir, f)).mtimeMs
|
|
58818
59242
|
})).sort((a, b) => b.mtime - a.mtime);
|
|
58819
59243
|
return files[0]?.path || null;
|
|
58820
59244
|
}
|
|
@@ -58857,7 +59281,7 @@ function processNewLines(filePath, callback) {
|
|
|
58857
59281
|
}
|
|
58858
59282
|
function startSessionWatcher(cwd, callback) {
|
|
58859
59283
|
stopSessionWatcher();
|
|
58860
|
-
const projectDir =
|
|
59284
|
+
const projectDir = join7(getProjectsDir(), encodeCwd(cwd));
|
|
58861
59285
|
const sessionFile = findActiveSession(projectDir);
|
|
58862
59286
|
if (!sessionFile) {
|
|
58863
59287
|
return { sessionFile: null };
|
|
@@ -59091,15 +59515,15 @@ function getRecentlyPushedCount() {
|
|
|
59091
59515
|
|
|
59092
59516
|
// src/lib/session-registry.ts
|
|
59093
59517
|
init_storage();
|
|
59094
|
-
import { existsSync as
|
|
59095
|
-
import { dirname as dirname3, join as
|
|
59096
|
-
var DB_PATH =
|
|
59518
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3 } from "fs";
|
|
59519
|
+
import { dirname as dirname3, join as join8 } from "path";
|
|
59520
|
+
var DB_PATH = join8(process.env["HOME"] || process.env["USERPROFILE"] || "~", ".open-sessions-registry.db");
|
|
59097
59521
|
var _db2 = null;
|
|
59098
59522
|
function getDb() {
|
|
59099
59523
|
if (_db2)
|
|
59100
59524
|
return _db2;
|
|
59101
59525
|
const dir = dirname3(DB_PATH);
|
|
59102
|
-
if (!
|
|
59526
|
+
if (!existsSync6(dir))
|
|
59103
59527
|
mkdirSync3(dir, { recursive: true });
|
|
59104
59528
|
_db2 = new SqliteAdapter(DB_PATH);
|
|
59105
59529
|
_db2.run("PRAGMA journal_mode = WAL");
|
|
@@ -62514,8 +62938,8 @@ init_entities();
|
|
|
62514
62938
|
init_database();
|
|
62515
62939
|
init_entities();
|
|
62516
62940
|
init_relations();
|
|
62517
|
-
import { readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync2, existsSync as
|
|
62518
|
-
import { join as
|
|
62941
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync2, existsSync as existsSync8 } from "fs";
|
|
62942
|
+
import { join as join10, resolve as resolve5, relative, dirname as dirname5, extname, basename as basename3 } from "path";
|
|
62519
62943
|
var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".py", ".go", ".rs"];
|
|
62520
62944
|
var DEFAULT_EXCLUDES = ["node_modules", ".git", "dist", "build", ".next", "__pycache__", "target", "vendor"];
|
|
62521
62945
|
function parseImports(_filePath, content) {
|
|
@@ -62545,14 +62969,14 @@ function parseImports(_filePath, content) {
|
|
|
62545
62969
|
}
|
|
62546
62970
|
function resolveImport(fromFile, importPath, allFiles) {
|
|
62547
62971
|
const dir = dirname5(fromFile);
|
|
62548
|
-
const base =
|
|
62972
|
+
const base = resolve5(dir, importPath);
|
|
62549
62973
|
if (allFiles.has(base))
|
|
62550
62974
|
return base;
|
|
62551
62975
|
for (const ext of [".ts", ".tsx", ".js", ".jsx", ".mjs"]) {
|
|
62552
62976
|
const withExt = base + ext;
|
|
62553
62977
|
if (allFiles.has(withExt))
|
|
62554
62978
|
return withExt;
|
|
62555
|
-
const index =
|
|
62979
|
+
const index = join10(base, `index${ext}`);
|
|
62556
62980
|
if (allFiles.has(index))
|
|
62557
62981
|
return index;
|
|
62558
62982
|
}
|
|
@@ -62570,7 +62994,7 @@ function collectFiles(dir, extensions, excludes) {
|
|
|
62570
62994
|
for (const entry of entries) {
|
|
62571
62995
|
if (excludes.some((e) => entry === e || current.includes(`/${e}/`)))
|
|
62572
62996
|
continue;
|
|
62573
|
-
const full =
|
|
62997
|
+
const full = join10(current, entry);
|
|
62574
62998
|
let stat;
|
|
62575
62999
|
try {
|
|
62576
63000
|
stat = statSync2(full);
|
|
@@ -62584,7 +63008,7 @@ function collectFiles(dir, extensions, excludes) {
|
|
|
62584
63008
|
}
|
|
62585
63009
|
}
|
|
62586
63010
|
}
|
|
62587
|
-
walk(
|
|
63011
|
+
walk(resolve5(dir));
|
|
62588
63012
|
return files;
|
|
62589
63013
|
}
|
|
62590
63014
|
async function buildFileDependencyGraph(opts, db) {
|
|
@@ -62592,8 +63016,8 @@ async function buildFileDependencyGraph(opts, db) {
|
|
|
62592
63016
|
const result = { files_scanned: 0, entities_created: 0, entities_updated: 0, relations_created: 0, errors: [] };
|
|
62593
63017
|
const extensions = opts.extensions ?? DEFAULT_EXTENSIONS;
|
|
62594
63018
|
const excludes = opts.exclude_patterns ?? DEFAULT_EXCLUDES;
|
|
62595
|
-
const rootDir =
|
|
62596
|
-
if (!
|
|
63019
|
+
const rootDir = resolve5(opts.root_dir);
|
|
63020
|
+
if (!existsSync8(rootDir)) {
|
|
62597
63021
|
result.errors.push(`Directory not found: ${rootDir}`);
|
|
62598
63022
|
return result;
|
|
62599
63023
|
}
|
|
@@ -63455,7 +63879,7 @@ function resolveCurrentMachineId(local, requested) {
|
|
|
63455
63879
|
function runStorageSync(direction, options = {}) {
|
|
63456
63880
|
const backend = getStorageBackend();
|
|
63457
63881
|
if (backend === "sqlite" && !options.remote) {
|
|
63458
|
-
throw new Error(
|
|
63882
|
+
throw new Error(`Remote storage is not configured. Set HASNA_MEMENTOS_DATABASE_URL or configure ${getConfigPath()}.`);
|
|
63459
63883
|
}
|
|
63460
63884
|
return withManagedAdapters(options, (local, remote, currentMachineId) => {
|
|
63461
63885
|
const tables = resolveTables(local, options.tables);
|
|
@@ -64207,7 +64631,7 @@ ${lines.join(`
|
|
|
64207
64631
|
}, async (args) => {
|
|
64208
64632
|
try {
|
|
64209
64633
|
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
64210
|
-
const wh = createWebhookHook({
|
|
64634
|
+
const wh = await createWebhookHook({
|
|
64211
64635
|
type: args.type,
|
|
64212
64636
|
handlerUrl: args.handler_url,
|
|
64213
64637
|
priority: args.priority,
|
|
@@ -64216,7 +64640,7 @@ ${lines.join(`
|
|
|
64216
64640
|
projectId: args.project_id,
|
|
64217
64641
|
description: args.description
|
|
64218
64642
|
});
|
|
64219
|
-
reloadWebhooks2();
|
|
64643
|
+
await reloadWebhooks2();
|
|
64220
64644
|
return { content: [{ type: "text", text: JSON.stringify(wh, null, 2) }] };
|
|
64221
64645
|
} catch (e) {
|
|
64222
64646
|
return { content: [{ type: "text", text: formatError6(e) }], isError: true };
|
|
@@ -67052,7 +67476,7 @@ function registerSystemEventTools({ server, z, createMemory: createMemory2, save
|
|
|
67052
67476
|
if (connection_string) {
|
|
67053
67477
|
connStr = connection_string;
|
|
67054
67478
|
} else {
|
|
67055
|
-
connStr =
|
|
67479
|
+
connStr = getStorageConnectionStringForOperator("mementos");
|
|
67056
67480
|
}
|
|
67057
67481
|
const result = await applyPgMigrations2(connStr);
|
|
67058
67482
|
const lines = [];
|
|
@@ -68077,7 +68501,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68077
68501
|
const key = process.env["ANTHROPIC_API_KEY"];
|
|
68078
68502
|
if (!key)
|
|
68079
68503
|
return null;
|
|
68080
|
-
const mod = await Promise.resolve().then(() => (
|
|
68504
|
+
const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist));
|
|
68081
68505
|
const anthropic2 = mod["anthropic"];
|
|
68082
68506
|
return anthropic2 ? anthropic2(model) : null;
|
|
68083
68507
|
}
|
|
@@ -68085,7 +68509,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68085
68509
|
const key = process.env["OPENAI_API_KEY"];
|
|
68086
68510
|
if (!key)
|
|
68087
68511
|
return null;
|
|
68088
|
-
const mod = await Promise.resolve().then(() => (
|
|
68512
|
+
const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist2));
|
|
68089
68513
|
const openai2 = mod["openai"];
|
|
68090
68514
|
return openai2 ? openai2(model) : null;
|
|
68091
68515
|
}
|
|
@@ -68094,7 +68518,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
68094
68518
|
if (!apiKey)
|
|
68095
68519
|
return null;
|
|
68096
68520
|
const baseURL = provider === "cerebras" ? "https://api.cerebras.ai/v1" : "https://api.x.ai/v1";
|
|
68097
|
-
const mod = await Promise.resolve().then(() => (
|
|
68521
|
+
const mod = await Promise.resolve().then(() => (init_dist7(), exports_dist3));
|
|
68098
68522
|
const createOpenAICompatible2 = mod["createOpenAICompatible"];
|
|
68099
68523
|
if (!createOpenAICompatible2)
|
|
68100
68524
|
return null;
|
|
@@ -68110,7 +68534,7 @@ function createAISDKReflectionCritic(options = {}) {
|
|
|
68110
68534
|
if (!resolvedModel)
|
|
68111
68535
|
return heuristicReflectionCritic(trajectory);
|
|
68112
68536
|
try {
|
|
68113
|
-
const ai = await Promise.resolve().then(() => (
|
|
68537
|
+
const ai = await Promise.resolve().then(() => (init_dist9(), exports_dist4));
|
|
68114
68538
|
const generateObject2 = ai["generateObject"];
|
|
68115
68539
|
if (!generateObject2)
|
|
68116
68540
|
return heuristicReflectionCritic(trajectory);
|
|
@@ -68346,9 +68770,9 @@ async function startMcpHttpServer(buildServer, options) {
|
|
|
68346
68770
|
}
|
|
68347
68771
|
}
|
|
68348
68772
|
});
|
|
68349
|
-
await new Promise((
|
|
68773
|
+
await new Promise((resolve7, reject) => {
|
|
68350
68774
|
httpServer.once("error", reject);
|
|
68351
|
-
httpServer.listen(requestedPort, host, () =>
|
|
68775
|
+
httpServer.listen(requestedPort, host, () => resolve7());
|
|
68352
68776
|
});
|
|
68353
68777
|
const addr = httpServer.address();
|
|
68354
68778
|
const port = typeof addr === "object" && addr ? addr.port : requestedPort;
|
|
@@ -68356,8 +68780,8 @@ async function startMcpHttpServer(buildServer, options) {
|
|
|
68356
68780
|
return {
|
|
68357
68781
|
port,
|
|
68358
68782
|
host,
|
|
68359
|
-
close: () => new Promise((
|
|
68360
|
-
httpServer.close((err) => err ? reject(err) :
|
|
68783
|
+
close: () => new Promise((resolve7, reject) => {
|
|
68784
|
+
httpServer.close((err) => err ? reject(err) : resolve7());
|
|
68361
68785
|
})
|
|
68362
68786
|
};
|
|
68363
68787
|
}
|
|
@@ -68469,7 +68893,7 @@ async function prepareMcpRuntime() {
|
|
|
68469
68893
|
}
|
|
68470
68894
|
} catch {}
|
|
68471
68895
|
await ensureRestServerRunning();
|
|
68472
|
-
loadWebhooksFromDb();
|
|
68896
|
+
await loadWebhooksFromDb();
|
|
68473
68897
|
}
|
|
68474
68898
|
async function main() {
|
|
68475
68899
|
if (hasFlag("--help", "-h")) {
|