@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/cli/index.js
CHANGED
|
@@ -2200,11 +2200,119 @@ var init_retired_storage_mode = __esm(() => {
|
|
|
2200
2200
|
];
|
|
2201
2201
|
});
|
|
2202
2202
|
|
|
2203
|
-
//
|
|
2204
|
-
import { Database } from "bun:sqlite";
|
|
2205
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2203
|
+
// ../../node_modules/.bun/@hasna+paths@0.1.0/node_modules/@hasna/paths/dist/index.js
|
|
2206
2204
|
import { homedir } from "os";
|
|
2207
2205
|
import { join } from "path";
|
|
2206
|
+
function assertApp(app) {
|
|
2207
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
2208
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
2209
|
+
}
|
|
2210
|
+
if (!APP_SLUG_RE.test(app)) {
|
|
2211
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
function envOf(options) {
|
|
2215
|
+
return options.env ?? process.env;
|
|
2216
|
+
}
|
|
2217
|
+
function envValue(options, kind) {
|
|
2218
|
+
const value = envOf(options)[KIND_ENV[kind]];
|
|
2219
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
2220
|
+
}
|
|
2221
|
+
function isMacOS(platform) {
|
|
2222
|
+
return platform === "darwin";
|
|
2223
|
+
}
|
|
2224
|
+
function baseDir(kind, options) {
|
|
2225
|
+
const override = envValue(options, kind);
|
|
2226
|
+
if (override)
|
|
2227
|
+
return override;
|
|
2228
|
+
const home = options.home ?? homedir();
|
|
2229
|
+
const platform = options.platform ?? process.platform;
|
|
2230
|
+
if (isMacOS(platform)) {
|
|
2231
|
+
switch (kind) {
|
|
2232
|
+
case "config":
|
|
2233
|
+
case "data":
|
|
2234
|
+
return join(home, "Library", "Application Support", "Hasna");
|
|
2235
|
+
case "cache":
|
|
2236
|
+
return join(home, "Library", "Caches", "Hasna");
|
|
2237
|
+
case "state":
|
|
2238
|
+
return join(home, "Library", "Logs", "Hasna");
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
switch (kind) {
|
|
2242
|
+
case "config":
|
|
2243
|
+
return join(home, ".config", "hasna");
|
|
2244
|
+
case "data":
|
|
2245
|
+
return join(home, ".local", "share", "hasna");
|
|
2246
|
+
case "state":
|
|
2247
|
+
return join(home, ".local", "state", "hasna");
|
|
2248
|
+
case "cache":
|
|
2249
|
+
return join(home, ".cache", "hasna");
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
function resolvePath(kind, options) {
|
|
2253
|
+
assertApp(options.app);
|
|
2254
|
+
const appSegment = options.internal === true ? join("internal", options.app) : options.app;
|
|
2255
|
+
return join(baseDir(kind, options), appSegment);
|
|
2256
|
+
}
|
|
2257
|
+
function dataDir(options) {
|
|
2258
|
+
return resolvePath("data", options);
|
|
2259
|
+
}
|
|
2260
|
+
var KIND_ENV, APP_SLUG_RE;
|
|
2261
|
+
var init_dist = __esm(() => {
|
|
2262
|
+
KIND_ENV = {
|
|
2263
|
+
config: "HASNA_CONFIG_HOME",
|
|
2264
|
+
data: "HASNA_DATA_HOME",
|
|
2265
|
+
state: "HASNA_STATE_HOME",
|
|
2266
|
+
cache: "HASNA_CACHE_HOME"
|
|
2267
|
+
};
|
|
2268
|
+
APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2269
|
+
});
|
|
2270
|
+
|
|
2271
|
+
// src/lib/paths.ts
|
|
2272
|
+
import { existsSync } from "fs";
|
|
2273
|
+
import { homedir as homedir2 } from "os";
|
|
2274
|
+
import { join as join2, resolve } from "path";
|
|
2275
|
+
function effectiveHome() {
|
|
2276
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir2() || "/tmp";
|
|
2277
|
+
}
|
|
2278
|
+
function legacyDataRoot() {
|
|
2279
|
+
return join2(effectiveHome(), ".hasna", "mementos");
|
|
2280
|
+
}
|
|
2281
|
+
function resolverDataRoot() {
|
|
2282
|
+
return dataDir({
|
|
2283
|
+
app: "mementos",
|
|
2284
|
+
home: process.env["HOME"] || process.env["USERPROFILE"] || undefined
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
function adoptResolverDataRoot(resolved, env = process.env) {
|
|
2288
|
+
const dataOverride = env.HASNA_DATA_HOME;
|
|
2289
|
+
if (typeof dataOverride === "string" && dataOverride.trim().length > 0)
|
|
2290
|
+
return true;
|
|
2291
|
+
return existsSync(join2(resolved, "mementos.db"));
|
|
2292
|
+
}
|
|
2293
|
+
function exactDataRoot() {
|
|
2294
|
+
for (const key of ["HASNA_MEMENTOS_HOME", "MEMENTOS_HOME"]) {
|
|
2295
|
+
const dir = process.env[key]?.trim();
|
|
2296
|
+
if (dir)
|
|
2297
|
+
return resolve(dir);
|
|
2298
|
+
}
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
function getDataRoot() {
|
|
2302
|
+
const exact = exactDataRoot();
|
|
2303
|
+
if (exact)
|
|
2304
|
+
return exact;
|
|
2305
|
+
const resolved = resolverDataRoot();
|
|
2306
|
+
return adoptResolverDataRoot(resolved) ? resolve(resolved) : resolve(legacyDataRoot());
|
|
2307
|
+
}
|
|
2308
|
+
var init_paths = __esm(() => {
|
|
2309
|
+
init_dist();
|
|
2310
|
+
});
|
|
2311
|
+
|
|
2312
|
+
// src/storage.ts
|
|
2313
|
+
import { Database } from "bun:sqlite";
|
|
2314
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2315
|
+
import { join as join3 } from "path";
|
|
2208
2316
|
import { fileURLToPath } from "url";
|
|
2209
2317
|
import { Worker } from "worker_threads";
|
|
2210
2318
|
import pg from "pg";
|
|
@@ -2454,7 +2562,7 @@ function readEnv(name) {
|
|
|
2454
2562
|
return value ? value : null;
|
|
2455
2563
|
}
|
|
2456
2564
|
function readConfigFile() {
|
|
2457
|
-
if (!
|
|
2565
|
+
if (!existsSync2(STORAGE_CONFIG_PATH)) {
|
|
2458
2566
|
return {};
|
|
2459
2567
|
}
|
|
2460
2568
|
try {
|
|
@@ -2463,6 +2571,9 @@ function readConfigFile() {
|
|
|
2463
2571
|
return {};
|
|
2464
2572
|
}
|
|
2465
2573
|
}
|
|
2574
|
+
function getConfigPath() {
|
|
2575
|
+
return STORAGE_CONFIG_PATH;
|
|
2576
|
+
}
|
|
2466
2577
|
function getStorageDatabaseEnv() {
|
|
2467
2578
|
for (const env of DATABASE_ENV_NAMES) {
|
|
2468
2579
|
if (readEnv(env.name))
|
|
@@ -2699,11 +2810,7 @@ function getStorageStatus() {
|
|
|
2699
2810
|
function getConfiguredConnectionString() {
|
|
2700
2811
|
return getStorageDatabaseUrl() ?? undefined;
|
|
2701
2812
|
}
|
|
2702
|
-
function
|
|
2703
|
-
assertNoLegacyStorageMode2();
|
|
2704
|
-
if (!isServerContext()) {
|
|
2705
|
-
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).");
|
|
2706
|
-
}
|
|
2813
|
+
function resolveConfiguredConnectionString(dbName) {
|
|
2707
2814
|
const envConnectionString = getConfiguredConnectionString();
|
|
2708
2815
|
if (envConnectionString) {
|
|
2709
2816
|
const validation = validatePostgresConnectionString(envConnectionString);
|
|
@@ -2722,7 +2829,7 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
2722
2829
|
missing.push("storage.rds.username");
|
|
2723
2830
|
}
|
|
2724
2831
|
if (missing.length > 0) {
|
|
2725
|
-
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure
|
|
2832
|
+
throw new Error(`Remote storage database is not configured. Missing ${missing.join(", ")}. Set HASNA_MEMENTOS_DATABASE_URL or configure ${STORAGE_CONFIG_PATH}.`);
|
|
2726
2833
|
}
|
|
2727
2834
|
const password = process.env[password_env];
|
|
2728
2835
|
if (!password) {
|
|
@@ -2731,6 +2838,17 @@ function getStorageConnectionString(dbName = "mementos") {
|
|
|
2731
2838
|
const sslParam = ssl ? "?sslmode=require" : "";
|
|
2732
2839
|
return `postgres://${username}:${encodeURIComponent(password)}@${host}:${port}/${dbName}${sslParam}`;
|
|
2733
2840
|
}
|
|
2841
|
+
function getStorageConnectionString(dbName = "mementos") {
|
|
2842
|
+
assertNoLegacyStorageMode2();
|
|
2843
|
+
if (!isServerContext()) {
|
|
2844
|
+
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).");
|
|
2845
|
+
}
|
|
2846
|
+
return resolveConfiguredConnectionString(dbName);
|
|
2847
|
+
}
|
|
2848
|
+
function getStorageConnectionStringForOperator(dbName = "mementos") {
|
|
2849
|
+
assertNoLegacyStorageMode2();
|
|
2850
|
+
return resolveConfiguredConnectionString(dbName);
|
|
2851
|
+
}
|
|
2734
2852
|
function isSyncExcludedTable(table) {
|
|
2735
2853
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((pattern) => pattern.test(table));
|
|
2736
2854
|
}
|
|
@@ -2889,6 +3007,7 @@ CREATE TABLE IF NOT EXISTS _sync_meta (
|
|
|
2889
3007
|
var init_storage = __esm(() => {
|
|
2890
3008
|
init_backend();
|
|
2891
3009
|
init_retired_storage_mode();
|
|
3010
|
+
init_paths();
|
|
2892
3011
|
PgSyncPool = class PgSyncPool {
|
|
2893
3012
|
worker;
|
|
2894
3013
|
status;
|
|
@@ -2906,12 +3025,12 @@ var init_storage = __esm(() => {
|
|
|
2906
3025
|
const ext = import.meta.url.endsWith(".ts") ? ".ts" : ".js";
|
|
2907
3026
|
const here = fileURLToPath(new URL(".", import.meta.url));
|
|
2908
3027
|
const candidates = [
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
3028
|
+
join3(here, `pg-sync-worker${ext}`),
|
|
3029
|
+
join3(here, "..", `pg-sync-worker${ext}`),
|
|
3030
|
+
join3(here, "..", "..", `pg-sync-worker${ext}`)
|
|
2912
3031
|
];
|
|
2913
3032
|
for (const candidate of candidates) {
|
|
2914
|
-
if (
|
|
3033
|
+
if (existsSync2(candidate))
|
|
2915
3034
|
return candidate;
|
|
2916
3035
|
}
|
|
2917
3036
|
return candidates[0];
|
|
@@ -2998,7 +3117,7 @@ var init_storage = __esm(() => {
|
|
|
2998
3117
|
MEMENTOS_STORAGE_FALLBACK_ENV = {
|
|
2999
3118
|
databaseUrl: "MEMENTOS_DATABASE_URL"
|
|
3000
3119
|
};
|
|
3001
|
-
LOCAL_DATA_DIR =
|
|
3120
|
+
LOCAL_DATA_DIR = getDataRoot();
|
|
3002
3121
|
DEFAULT_STORAGE_CONFIG = {
|
|
3003
3122
|
rds: {
|
|
3004
3123
|
host: "",
|
|
@@ -3013,8 +3132,8 @@ var init_storage = __esm(() => {
|
|
|
3013
3132
|
schedule_minutes: 0
|
|
3014
3133
|
}
|
|
3015
3134
|
};
|
|
3016
|
-
STORAGE_CONFIG_DIR =
|
|
3017
|
-
STORAGE_CONFIG_PATH =
|
|
3135
|
+
STORAGE_CONFIG_DIR = join3(LOCAL_DATA_DIR, "storage");
|
|
3136
|
+
STORAGE_CONFIG_PATH = join3(STORAGE_CONFIG_DIR, "config.json");
|
|
3018
3137
|
DATABASE_ENV_NAMES = [
|
|
3019
3138
|
{ name: MEMENTOS_STORAGE_ENV.databaseUrl, deprecated: false },
|
|
3020
3139
|
{ name: MEMENTOS_STORAGE_FALLBACK_ENV.databaseUrl, deprecated: false }
|
|
@@ -3039,7 +3158,7 @@ var init_storage = __esm(() => {
|
|
|
3039
3158
|
|
|
3040
3159
|
// src/db/api-mode.ts
|
|
3041
3160
|
import { tmpdir } from "os";
|
|
3042
|
-
import { join as
|
|
3161
|
+
import { join as join4 } from "path";
|
|
3043
3162
|
import { writeFileSync as writeFileSync2, unlinkSync } from "fs";
|
|
3044
3163
|
import { randomUUID } from "crypto";
|
|
3045
3164
|
function firstEnv2(keys) {
|
|
@@ -3164,7 +3283,7 @@ x-api-key: ${cfg.apiKey}
|
|
|
3164
3283
|
];
|
|
3165
3284
|
let bodyFile;
|
|
3166
3285
|
if (hasBody) {
|
|
3167
|
-
bodyFile =
|
|
3286
|
+
bodyFile = join4(tmpdir(), `mem-req-${process.pid}-${randomUUID()}.json`);
|
|
3168
3287
|
writeFileSync2(bodyFile, JSON.stringify(body), { mode: 384 });
|
|
3169
3288
|
args.push("--data-binary", `@${bodyFile}`);
|
|
3170
3289
|
}
|
|
@@ -4650,18 +4769,18 @@ __export(exports_database, {
|
|
|
4650
4769
|
escapeLikePrefix: () => escapeLikePrefix,
|
|
4651
4770
|
closeDatabase: () => closeDatabase
|
|
4652
4771
|
});
|
|
4653
|
-
import { existsSync as
|
|
4654
|
-
import { dirname, join as
|
|
4772
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, cpSync } from "fs";
|
|
4773
|
+
import { dirname, join as join5, resolve as resolve2 } from "path";
|
|
4655
4774
|
function isInMemoryDb(path) {
|
|
4656
4775
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
4657
4776
|
}
|
|
4658
4777
|
function findNearestMementosDb(startDir) {
|
|
4659
|
-
let dir =
|
|
4778
|
+
let dir = resolve2(startDir);
|
|
4660
4779
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
4661
|
-
const legacyHomeDb =
|
|
4780
|
+
const legacyHomeDb = resolve2(home, ".mementos", "mementos.db");
|
|
4662
4781
|
while (true) {
|
|
4663
|
-
const candidate =
|
|
4664
|
-
if (
|
|
4782
|
+
const candidate = join5(dir, ".mementos", "mementos.db");
|
|
4783
|
+
if (existsSync3(candidate) && resolve2(candidate) !== legacyHomeDb)
|
|
4665
4784
|
return candidate;
|
|
4666
4785
|
const parent = dirname(dir);
|
|
4667
4786
|
if (parent === dir)
|
|
@@ -4671,9 +4790,9 @@ function findNearestMementosDb(startDir) {
|
|
|
4671
4790
|
return null;
|
|
4672
4791
|
}
|
|
4673
4792
|
function findGitRoot(startDir) {
|
|
4674
|
-
let dir =
|
|
4793
|
+
let dir = resolve2(startDir);
|
|
4675
4794
|
while (true) {
|
|
4676
|
-
if (
|
|
4795
|
+
if (existsSync3(join5(dir, ".git")))
|
|
4677
4796
|
return dir;
|
|
4678
4797
|
const parent = dirname(dir);
|
|
4679
4798
|
if (parent === dir)
|
|
@@ -4684,10 +4803,10 @@ function findGitRoot(startDir) {
|
|
|
4684
4803
|
}
|
|
4685
4804
|
function migrateGlobalDir() {
|
|
4686
4805
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
4687
|
-
const newDir =
|
|
4688
|
-
const oldDir =
|
|
4689
|
-
if (!
|
|
4690
|
-
mkdirSync2(
|
|
4806
|
+
const newDir = getDataRoot();
|
|
4807
|
+
const oldDir = join5(home, ".mementos");
|
|
4808
|
+
if (!existsSync3(newDir) && existsSync3(oldDir)) {
|
|
4809
|
+
mkdirSync2(dirname(newDir), { recursive: true });
|
|
4691
4810
|
cpSync(oldDir, newDir, { recursive: true });
|
|
4692
4811
|
}
|
|
4693
4812
|
}
|
|
@@ -4704,18 +4823,17 @@ function getDbPath() {
|
|
|
4704
4823
|
if (process.env["MEMENTOS_DB_SCOPE"] === "project") {
|
|
4705
4824
|
const gitRoot = findGitRoot(cwd);
|
|
4706
4825
|
if (gitRoot) {
|
|
4707
|
-
return
|
|
4826
|
+
return join5(gitRoot, ".mementos", "mementos.db");
|
|
4708
4827
|
}
|
|
4709
4828
|
}
|
|
4710
4829
|
migrateGlobalDir();
|
|
4711
|
-
|
|
4712
|
-
return join3(home, ".hasna", "mementos", "mementos.db");
|
|
4830
|
+
return join5(getDataRoot(), "mementos.db");
|
|
4713
4831
|
}
|
|
4714
4832
|
function ensureDir(filePath) {
|
|
4715
4833
|
if (isInMemoryDb(filePath))
|
|
4716
4834
|
return;
|
|
4717
|
-
const dir = dirname(
|
|
4718
|
-
if (!
|
|
4835
|
+
const dir = dirname(resolve2(filePath));
|
|
4836
|
+
if (!existsSync3(dir)) {
|
|
4719
4837
|
mkdirSync2(dir, { recursive: true });
|
|
4720
4838
|
}
|
|
4721
4839
|
}
|
|
@@ -4853,6 +4971,7 @@ var init_database = __esm(() => {
|
|
|
4853
4971
|
init_storage();
|
|
4854
4972
|
init_api_mode();
|
|
4855
4973
|
init_migrations();
|
|
4974
|
+
init_paths();
|
|
4856
4975
|
ALLOWED_TABLES = new Set([
|
|
4857
4976
|
"memories",
|
|
4858
4977
|
"agents",
|
|
@@ -5019,6 +5138,30 @@ function redactSecrets(text) {
|
|
|
5019
5138
|
}
|
|
5020
5139
|
return result;
|
|
5021
5140
|
}
|
|
5141
|
+
function redactValueTree(value) {
|
|
5142
|
+
if (typeof value === "string")
|
|
5143
|
+
return redactSecrets(value);
|
|
5144
|
+
if (Array.isArray(value))
|
|
5145
|
+
return value.map(redactValueTree);
|
|
5146
|
+
if (value !== null && typeof value === "object") {
|
|
5147
|
+
const out = {};
|
|
5148
|
+
for (const [k, v] of Object.entries(value)) {
|
|
5149
|
+
out[k] = redactValueTree(v);
|
|
5150
|
+
}
|
|
5151
|
+
return out;
|
|
5152
|
+
}
|
|
5153
|
+
return value;
|
|
5154
|
+
}
|
|
5155
|
+
function redactMemoryForOutput(memory) {
|
|
5156
|
+
return {
|
|
5157
|
+
...memory,
|
|
5158
|
+
key: redactSecrets(memory.key),
|
|
5159
|
+
value: redactSecrets(memory.value),
|
|
5160
|
+
summary: memory.summary ? redactSecrets(memory.summary) : null,
|
|
5161
|
+
when_to_use: memory.when_to_use ? redactSecrets(memory.when_to_use) : null,
|
|
5162
|
+
metadata: redactValueTree(memory.metadata)
|
|
5163
|
+
};
|
|
5164
|
+
}
|
|
5022
5165
|
var REDACTED = "[REDACTED]", SECRET_PATTERNS;
|
|
5023
5166
|
var init_redact = __esm(() => {
|
|
5024
5167
|
SECRET_PATTERNS = [
|
|
@@ -5421,12 +5564,22 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
5421
5564
|
const effectiveMode = dedupeMode === "overwrite" ? "merge" : dedupeMode === "version-fork" ? "create" : dedupeMode;
|
|
5422
5565
|
if (effectiveMode === "error") {
|
|
5423
5566
|
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
5424
|
-
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
5567
|
+
WHERE key = ? AND scope = ? AND COALESCE(project_id, '') = ?
|
|
5425
5568
|
LIMIT 1`).get(input.key, input.scope || "private", input.project_id || "");
|
|
5426
5569
|
if (existing) {
|
|
5427
5570
|
throw new MemoryConflictError(input.key, existing);
|
|
5428
5571
|
}
|
|
5429
5572
|
}
|
|
5573
|
+
if (effectiveMode === "create") {
|
|
5574
|
+
const existing = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
5575
|
+
WHERE key = ? AND scope = ?
|
|
5576
|
+
AND COALESCE(agent_id, '') = ?
|
|
5577
|
+
AND COALESCE(project_id, '') = ?
|
|
5578
|
+
AND COALESCE(session_id, '') = ?`).get(input.key, input.scope || "private", input.agent_id || "", input.project_id || "", input.session_id || "");
|
|
5579
|
+
if (existing) {
|
|
5580
|
+
throw new MemoryConflictError(input.key, existing);
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5430
5583
|
if (effectiveMode === "merge") {
|
|
5431
5584
|
const existing = d.query(`SELECT id, version FROM memories
|
|
5432
5585
|
WHERE key = ? AND scope = ?
|
|
@@ -6078,6 +6231,17 @@ function updateMemory(id, input, db) {
|
|
|
6078
6231
|
if (existing.version !== input.version) {
|
|
6079
6232
|
throw new VersionConflictError(id, input.version, existing.version);
|
|
6080
6233
|
}
|
|
6234
|
+
if (input.scope !== undefined && input.scope !== existing.scope) {
|
|
6235
|
+
const conflict = d.query(`SELECT id, agent_id, updated_at FROM memories
|
|
6236
|
+
WHERE key = ? AND scope = ?
|
|
6237
|
+
AND COALESCE(agent_id, '') = ?
|
|
6238
|
+
AND COALESCE(project_id, '') = ?
|
|
6239
|
+
AND COALESCE(session_id, '') = ?
|
|
6240
|
+
AND id != ?`).get(existing.key, input.scope, existing.agent_id || "", existing.project_id || "", existing.session_id || "", memoryId);
|
|
6241
|
+
if (conflict) {
|
|
6242
|
+
throw new MemoryConflictError(existing.key, conflict);
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6081
6245
|
const sets = ["version = version + 1", "updated_at = ?"];
|
|
6082
6246
|
const params = [now()];
|
|
6083
6247
|
if (input.value !== undefined) {
|
|
@@ -6336,16 +6500,16 @@ var init_memories = __esm(() => {
|
|
|
6336
6500
|
});
|
|
6337
6501
|
|
|
6338
6502
|
// src/db/agents.ts
|
|
6339
|
-
import { homedir as
|
|
6340
|
-
import { join as
|
|
6341
|
-
import { existsSync as
|
|
6503
|
+
import { homedir as homedir4 } from "os";
|
|
6504
|
+
import { join as join7 } from "path";
|
|
6505
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
|
|
6342
6506
|
function resolveWritingAgentName() {
|
|
6343
6507
|
const envName = process.env["MEMENTOS_AGENT"]?.trim();
|
|
6344
6508
|
if (envName)
|
|
6345
6509
|
return envName;
|
|
6346
6510
|
try {
|
|
6347
|
-
const path =
|
|
6348
|
-
if (
|
|
6511
|
+
const path = join7(homedir4(), ".hasna", "conversations", "agent-id");
|
|
6512
|
+
if (existsSync5(path)) {
|
|
6349
6513
|
const fileAgent = readFileSync2(path, "utf8").trim();
|
|
6350
6514
|
if (fileAgent)
|
|
6351
6515
|
return fileAgent;
|
|
@@ -6556,13 +6720,13 @@ var init_agents = __esm(() => {
|
|
|
6556
6720
|
|
|
6557
6721
|
// src/lib/package-version.ts
|
|
6558
6722
|
import { readFileSync as readFileSync3 } from "fs";
|
|
6559
|
-
import { dirname as dirname2, join as
|
|
6723
|
+
import { dirname as dirname2, join as join8 } from "path";
|
|
6560
6724
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6561
6725
|
function getMementosPackageVersion() {
|
|
6562
6726
|
const here = dirname2(fileURLToPath2(import.meta.url));
|
|
6563
6727
|
for (const candidate of [
|
|
6564
|
-
|
|
6565
|
-
|
|
6728
|
+
join8(here, "..", "..", "package.json"),
|
|
6729
|
+
join8(here, "..", "package.json")
|
|
6566
6730
|
]) {
|
|
6567
6731
|
try {
|
|
6568
6732
|
const parsed = JSON.parse(readFileSync3(candidate, "utf8"));
|
|
@@ -7548,7 +7712,7 @@ __export(exports_helpers, {
|
|
|
7548
7712
|
getPackageVersion: () => getPackageVersion,
|
|
7549
7713
|
getOutputFormat: () => getOutputFormat,
|
|
7550
7714
|
getNestedValue: () => getNestedValue,
|
|
7551
|
-
getConfigPath: () =>
|
|
7715
|
+
getConfigPath: () => getConfigPath2,
|
|
7552
7716
|
formatWatchLine: () => formatWatchLine,
|
|
7553
7717
|
formatMemoryLine: () => formatMemoryLine,
|
|
7554
7718
|
formatMemoryDetail: () => formatMemoryDetail,
|
|
@@ -7569,11 +7733,11 @@ __export(exports_helpers, {
|
|
|
7569
7733
|
});
|
|
7570
7734
|
import chalk from "chalk";
|
|
7571
7735
|
import { readFileSync as readFileSync4 } from "fs";
|
|
7572
|
-
import { dirname as dirname3, join as
|
|
7736
|
+
import { dirname as dirname3, join as join9, resolve as resolve3 } from "path";
|
|
7573
7737
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
7574
7738
|
function getPackageVersion() {
|
|
7575
7739
|
try {
|
|
7576
|
-
const pkgPath =
|
|
7740
|
+
const pkgPath = join9(dirname3(fileURLToPath3(import.meta.url)), "..", "..", "package.json");
|
|
7577
7741
|
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
7578
7742
|
return pkg.version || "0.0.0";
|
|
7579
7743
|
} catch {
|
|
@@ -7853,7 +8017,7 @@ function resolveKeyOrId(keyOrId, opts, globalOpts) {
|
|
|
7853
8017
|
const projectPath = opts.project || globalOpts.project;
|
|
7854
8018
|
let projectId;
|
|
7855
8019
|
if (projectPath) {
|
|
7856
|
-
const project = getProject(
|
|
8020
|
+
const project = getProject(resolve3(projectPath));
|
|
7857
8021
|
if (project)
|
|
7858
8022
|
projectId = project.id;
|
|
7859
8023
|
}
|
|
@@ -8132,14 +8296,13 @@ function validateConfigKeyValue(key, value, DEFAULT_CONFIG) {
|
|
|
8132
8296
|
}
|
|
8133
8297
|
return null;
|
|
8134
8298
|
}
|
|
8135
|
-
function
|
|
8136
|
-
|
|
8137
|
-
return join7(homedir4(), ".hasna", "mementos", "config.json");
|
|
8299
|
+
function getConfigPath2() {
|
|
8300
|
+
return join9(getDataRoot(), "config.json");
|
|
8138
8301
|
}
|
|
8139
8302
|
function readFileConfig() {
|
|
8140
|
-
const { existsSync:
|
|
8141
|
-
const configPath =
|
|
8142
|
-
if (!
|
|
8303
|
+
const { existsSync: existsSync6 } = __require("fs");
|
|
8304
|
+
const configPath = getConfigPath2();
|
|
8305
|
+
if (!existsSync6(configPath))
|
|
8143
8306
|
return {};
|
|
8144
8307
|
try {
|
|
8145
8308
|
const data = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
@@ -8153,10 +8316,10 @@ function readFileConfig() {
|
|
|
8153
8316
|
}
|
|
8154
8317
|
}
|
|
8155
8318
|
function writeFileConfig(data) {
|
|
8156
|
-
const { existsSync:
|
|
8157
|
-
const configPath =
|
|
8319
|
+
const { existsSync: existsSync6, writeFileSync: writeFileSync3, mkdirSync: mkdirSync3 } = __require("fs");
|
|
8320
|
+
const configPath = getConfigPath2();
|
|
8158
8321
|
const dir = dirname3(configPath);
|
|
8159
|
-
if (!
|
|
8322
|
+
if (!existsSync6(dir))
|
|
8160
8323
|
mkdirSync3(dir, { recursive: true });
|
|
8161
8324
|
writeFileSync3(configPath, JSON.stringify(data, null, 2) + `
|
|
8162
8325
|
`, "utf-8");
|
|
@@ -8169,6 +8332,7 @@ var init_helpers = __esm(() => {
|
|
|
8169
8332
|
init_agents();
|
|
8170
8333
|
init_projects();
|
|
8171
8334
|
init_entities();
|
|
8335
|
+
init_paths();
|
|
8172
8336
|
scopeColor = {
|
|
8173
8337
|
global: chalk.cyan,
|
|
8174
8338
|
shared: chalk.yellow,
|
|
@@ -8787,7 +8951,9 @@ function scoreResults(rows, queryLower, graphBoostedIds) {
|
|
|
8787
8951
|
scored.sort((a, b) => {
|
|
8788
8952
|
if (b.score !== a.score)
|
|
8789
8953
|
return b.score - a.score;
|
|
8790
|
-
|
|
8954
|
+
if (b.memory.importance !== a.memory.importance)
|
|
8955
|
+
return b.memory.importance - a.memory.importance;
|
|
8956
|
+
return a.memory.id.localeCompare(b.memory.id);
|
|
8791
8957
|
});
|
|
8792
8958
|
return scored;
|
|
8793
8959
|
}
|
|
@@ -9952,6 +10118,7 @@ var init_auto_memory = __esm(() => {
|
|
|
9952
10118
|
// src/db/webhook_hooks.ts
|
|
9953
10119
|
var exports_webhook_hooks = {};
|
|
9954
10120
|
__export(exports_webhook_hooks, {
|
|
10121
|
+
validateWebhookHandlerUrl: () => validateWebhookHandlerUrl,
|
|
9955
10122
|
updateWebhookHook: () => updateWebhookHook,
|
|
9956
10123
|
recordWebhookInvocation: () => recordWebhookInvocation,
|
|
9957
10124
|
listWebhookHooks: () => listWebhookHooks,
|
|
@@ -9959,6 +10126,8 @@ __export(exports_webhook_hooks, {
|
|
|
9959
10126
|
deleteWebhookHook: () => deleteWebhookHook,
|
|
9960
10127
|
createWebhookHook: () => createWebhookHook
|
|
9961
10128
|
});
|
|
10129
|
+
import { isIP } from "net";
|
|
10130
|
+
import { lookup as dnsLookup } from "dns/promises";
|
|
9962
10131
|
function parseRow(row) {
|
|
9963
10132
|
return {
|
|
9964
10133
|
id: row["id"],
|
|
@@ -9975,7 +10144,153 @@ function parseRow(row) {
|
|
|
9975
10144
|
failureCount: row["failure_count"]
|
|
9976
10145
|
};
|
|
9977
10146
|
}
|
|
9978
|
-
function
|
|
10147
|
+
function isBlockedIpv4(parts) {
|
|
10148
|
+
const a = parts[0];
|
|
10149
|
+
const b = parts[1];
|
|
10150
|
+
if (a === 0)
|
|
10151
|
+
return true;
|
|
10152
|
+
if (a === 127)
|
|
10153
|
+
return true;
|
|
10154
|
+
if (a === 169 && b === 254)
|
|
10155
|
+
return true;
|
|
10156
|
+
if (a === 10)
|
|
10157
|
+
return true;
|
|
10158
|
+
if (a === 172 && b >= 16 && b <= 31)
|
|
10159
|
+
return true;
|
|
10160
|
+
if (a === 192 && b === 168)
|
|
10161
|
+
return true;
|
|
10162
|
+
return false;
|
|
10163
|
+
}
|
|
10164
|
+
function isBlockedIpv6(bytes) {
|
|
10165
|
+
const mapped = bytes.slice(0, 10).every((b) => b === 0) && bytes[10] === 255 && bytes[11] === 255;
|
|
10166
|
+
if (mapped)
|
|
10167
|
+
return isBlockedIpv4(bytes.slice(12, 16));
|
|
10168
|
+
if (bytes.every((b) => b === 0))
|
|
10169
|
+
return true;
|
|
10170
|
+
if (bytes.slice(0, 15).every((b) => b === 0) && bytes[15] === 1)
|
|
10171
|
+
return true;
|
|
10172
|
+
if ((bytes[0] & 254) === 252)
|
|
10173
|
+
return true;
|
|
10174
|
+
if (bytes[0] === 254 && (bytes[1] & 192) === 128)
|
|
10175
|
+
return true;
|
|
10176
|
+
return false;
|
|
10177
|
+
}
|
|
10178
|
+
function quadToGroups(quad) {
|
|
10179
|
+
const nums = quad.split(".").map((p) => Number(p));
|
|
10180
|
+
const [a, b, c, d] = nums;
|
|
10181
|
+
const valid = [a, b, c, d].every((n) => n !== undefined && Number.isInteger(n) && n >= 0 && n <= 255);
|
|
10182
|
+
if (!valid)
|
|
10183
|
+
return null;
|
|
10184
|
+
return [a << 8 | b, c << 8 | d];
|
|
10185
|
+
}
|
|
10186
|
+
function parseIpv6Bytes(host) {
|
|
10187
|
+
const groups = host.split("::");
|
|
10188
|
+
if (groups.length > 2)
|
|
10189
|
+
return null;
|
|
10190
|
+
const headRaw = groups[0] ?? "";
|
|
10191
|
+
const tailRaw = groups[1] ?? "";
|
|
10192
|
+
const head = headRaw === "" ? [] : headRaw.split(":");
|
|
10193
|
+
const tail = tailRaw === "" ? [] : tailRaw.split(":");
|
|
10194
|
+
const headNums = [];
|
|
10195
|
+
for (const g of head) {
|
|
10196
|
+
if (!/^[0-9a-f]{1,4}$/i.test(g))
|
|
10197
|
+
return null;
|
|
10198
|
+
headNums.push(parseInt(g, 16));
|
|
10199
|
+
}
|
|
10200
|
+
const tailNums = [];
|
|
10201
|
+
for (const g of tail) {
|
|
10202
|
+
if (/^\d+\.\d+\.\d+\.\d+$/.test(g)) {
|
|
10203
|
+
const quads = quadToGroups(g);
|
|
10204
|
+
if (!quads)
|
|
10205
|
+
return null;
|
|
10206
|
+
tailNums.push(...quads);
|
|
10207
|
+
} else if (/^[0-9a-f]{1,4}$/i.test(g)) {
|
|
10208
|
+
tailNums.push(parseInt(g, 16));
|
|
10209
|
+
} else {
|
|
10210
|
+
return null;
|
|
10211
|
+
}
|
|
10212
|
+
}
|
|
10213
|
+
const hasCompression = groups.length === 2;
|
|
10214
|
+
if (!hasCompression && headNums.length !== 8)
|
|
10215
|
+
return null;
|
|
10216
|
+
if (hasCompression && headNums.length + tailNums.length >= 8)
|
|
10217
|
+
return null;
|
|
10218
|
+
const zeros = 8 - headNums.length - tailNums.length;
|
|
10219
|
+
const all = [...headNums, ...new Array(zeros).fill(0), ...tailNums];
|
|
10220
|
+
const bytes = [];
|
|
10221
|
+
for (const n of all) {
|
|
10222
|
+
bytes.push(n >> 8 & 255, n & 255);
|
|
10223
|
+
}
|
|
10224
|
+
return bytes;
|
|
10225
|
+
}
|
|
10226
|
+
function defaultResolveHost(hostname2) {
|
|
10227
|
+
return dnsLookup(hostname2, { all: true, verbatim: true });
|
|
10228
|
+
}
|
|
10229
|
+
function assertResolvedAddressPublic(address, url) {
|
|
10230
|
+
const version = isIP(address);
|
|
10231
|
+
if (version === 4) {
|
|
10232
|
+
if (isBlockedIpv4(address.split(".").map((p) => Number(p)))) {
|
|
10233
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10234
|
+
}
|
|
10235
|
+
} else if (version === 6) {
|
|
10236
|
+
const bytes = parseIpv6Bytes(address);
|
|
10237
|
+
if (!bytes || isBlockedIpv6(bytes)) {
|
|
10238
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10239
|
+
}
|
|
10240
|
+
} else {
|
|
10241
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10242
|
+
}
|
|
10243
|
+
}
|
|
10244
|
+
async function validateWebhookHandlerUrl(url, opts) {
|
|
10245
|
+
const resolveHost = opts?.lookup ?? defaultResolveHost;
|
|
10246
|
+
let parsed;
|
|
10247
|
+
try {
|
|
10248
|
+
parsed = new URL(url);
|
|
10249
|
+
} catch {
|
|
10250
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 must be a valid http(s) URL`);
|
|
10251
|
+
}
|
|
10252
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
10253
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 only http and https are allowed`);
|
|
10254
|
+
}
|
|
10255
|
+
if (parsed.username || parsed.password) {
|
|
10256
|
+
throw new Error(`Invalid webhook handler URL "${url}" \u2014 embedded credentials are not allowed`);
|
|
10257
|
+
}
|
|
10258
|
+
const host = parsed.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
10259
|
+
if (host === "localhost" || host.endsWith(".localhost")) {
|
|
10260
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10261
|
+
}
|
|
10262
|
+
const version = isIP(host);
|
|
10263
|
+
if (version === 4 || version === 6) {
|
|
10264
|
+
if (version === 4) {
|
|
10265
|
+
if (isBlockedIpv4(host.split(".").map((p) => Number(p)))) {
|
|
10266
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10267
|
+
}
|
|
10268
|
+
} else {
|
|
10269
|
+
const bytes = parseIpv6Bytes(host);
|
|
10270
|
+
if (!bytes || isBlockedIpv6(bytes)) {
|
|
10271
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10272
|
+
}
|
|
10273
|
+
}
|
|
10274
|
+
return;
|
|
10275
|
+
}
|
|
10276
|
+
if (/^[0-9]+(\.[0-9]+)*$/.test(host) || /^0x[0-9a-f]+$/i.test(host) || host.includes("%")) {
|
|
10277
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10278
|
+
}
|
|
10279
|
+
let addrs;
|
|
10280
|
+
try {
|
|
10281
|
+
addrs = await resolveHost(host);
|
|
10282
|
+
} catch {
|
|
10283
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10284
|
+
}
|
|
10285
|
+
if (addrs.length === 0) {
|
|
10286
|
+
throw new Error(`${BLOCKED_TARGET_MESSAGE}: "${url}"`);
|
|
10287
|
+
}
|
|
10288
|
+
for (const { address } of addrs) {
|
|
10289
|
+
assertResolvedAddressPublic(address, url);
|
|
10290
|
+
}
|
|
10291
|
+
}
|
|
10292
|
+
async function createWebhookHook(input, db, opts) {
|
|
10293
|
+
await validateWebhookHandlerUrl(input.handlerUrl, opts);
|
|
9979
10294
|
if (!db && isApiMode()) {
|
|
9980
10295
|
const { data } = apiJson("POST", "/webhooks", {
|
|
9981
10296
|
type: input.type,
|
|
@@ -10093,6 +10408,7 @@ function recordWebhookInvocation(id, success, db) {
|
|
|
10093
10408
|
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1, failure_count = failure_count + 1 WHERE id = ?", [id]);
|
|
10094
10409
|
}
|
|
10095
10410
|
}
|
|
10411
|
+
var BLOCKED_TARGET_MESSAGE = "Invalid webhook handler URL \u2014 loopback, link-local, and private network targets are not allowed";
|
|
10096
10412
|
var init_webhook_hooks = __esm(() => {
|
|
10097
10413
|
init_database();
|
|
10098
10414
|
init_api_mode();
|
|
@@ -10711,6 +11027,7 @@ var init_contradiction = __esm(() => {
|
|
|
10711
11027
|
var exports_built_in_hooks = {};
|
|
10712
11028
|
__export(exports_built_in_hooks, {
|
|
10713
11029
|
reloadWebhooks: () => reloadWebhooks,
|
|
11030
|
+
makeWebhookHandler: () => makeWebhookHandler,
|
|
10714
11031
|
loadWebhooksFromDb: () => loadWebhooksFromDb
|
|
10715
11032
|
});
|
|
10716
11033
|
async function getAutoMemory() {
|
|
@@ -10720,13 +11037,19 @@ async function getAutoMemory() {
|
|
|
10720
11037
|
}
|
|
10721
11038
|
return _processConversationTurn;
|
|
10722
11039
|
}
|
|
10723
|
-
function loadWebhooksFromDb() {
|
|
11040
|
+
async function loadWebhooksFromDb() {
|
|
10724
11041
|
if (_webhooksLoaded)
|
|
10725
11042
|
return;
|
|
10726
11043
|
_webhooksLoaded = true;
|
|
10727
11044
|
try {
|
|
10728
11045
|
const webhooks = listWebhookHooks({ enabled: true });
|
|
10729
11046
|
for (const wh of webhooks) {
|
|
11047
|
+
try {
|
|
11048
|
+
await validateWebhookHandlerUrl(wh.handlerUrl);
|
|
11049
|
+
} catch (err) {
|
|
11050
|
+
console.error(`[hooks] Skipping webhook ${wh.id} (${wh.type}): ${err instanceof Error ? err.message : String(err)}`);
|
|
11051
|
+
continue;
|
|
11052
|
+
}
|
|
10730
11053
|
hookRegistry.register({
|
|
10731
11054
|
type: wh.type,
|
|
10732
11055
|
blocking: wh.blocking,
|
|
@@ -10744,9 +11067,10 @@ function loadWebhooksFromDb() {
|
|
|
10744
11067
|
console.error("[hooks] Failed to load webhooks from DB:", err);
|
|
10745
11068
|
}
|
|
10746
11069
|
}
|
|
10747
|
-
function makeWebhookHandler(webhookId, url) {
|
|
11070
|
+
function makeWebhookHandler(webhookId, url, opts) {
|
|
10748
11071
|
return async (context) => {
|
|
10749
11072
|
try {
|
|
11073
|
+
await validateWebhookHandlerUrl(url, opts);
|
|
10750
11074
|
const res = await fetch(url, {
|
|
10751
11075
|
method: "POST",
|
|
10752
11076
|
headers: { "Content-Type": "application/json" },
|
|
@@ -10759,9 +11083,9 @@ function makeWebhookHandler(webhookId, url) {
|
|
|
10759
11083
|
}
|
|
10760
11084
|
};
|
|
10761
11085
|
}
|
|
10762
|
-
function reloadWebhooks() {
|
|
11086
|
+
async function reloadWebhooks() {
|
|
10763
11087
|
_webhooksLoaded = false;
|
|
10764
|
-
loadWebhooksFromDb();
|
|
11088
|
+
await loadWebhooksFromDb();
|
|
10765
11089
|
}
|
|
10766
11090
|
var _processConversationTurn = null, _webhooksLoaded = false;
|
|
10767
11091
|
var init_built_in_hooks = __esm(() => {
|
|
@@ -12726,13 +13050,13 @@ __export(exports_session_registry, {
|
|
|
12726
13050
|
closeRegistry: () => closeRegistry,
|
|
12727
13051
|
cleanStaleSessions: () => cleanStaleSessions
|
|
12728
13052
|
});
|
|
12729
|
-
import { existsSync as
|
|
12730
|
-
import { dirname as dirname6, join as
|
|
13053
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5 } from "fs";
|
|
13054
|
+
import { dirname as dirname6, join as join15 } from "path";
|
|
12731
13055
|
function getDb() {
|
|
12732
13056
|
if (_db2)
|
|
12733
13057
|
return _db2;
|
|
12734
13058
|
const dir = dirname6(DB_PATH);
|
|
12735
|
-
if (!
|
|
13059
|
+
if (!existsSync10(dir))
|
|
12736
13060
|
mkdirSync5(dir, { recursive: true });
|
|
12737
13061
|
_db2 = new SqliteAdapter(DB_PATH);
|
|
12738
13062
|
_db2.run("PRAGMA journal_mode = WAL");
|
|
@@ -12907,7 +13231,7 @@ function closeRegistry() {
|
|
|
12907
13231
|
var DB_PATH, _db2 = null;
|
|
12908
13232
|
var init_session_registry = __esm(() => {
|
|
12909
13233
|
init_storage();
|
|
12910
|
-
DB_PATH =
|
|
13234
|
+
DB_PATH = join15(process.env["HOME"] || process.env["USERPROFILE"] || "~", ".open-sessions-registry.db");
|
|
12911
13235
|
});
|
|
12912
13236
|
|
|
12913
13237
|
// src/db/pg-migrations.ts
|
|
@@ -13702,7 +14026,7 @@ function getPgMigrationDiagnostics(connectionString) {
|
|
|
13702
14026
|
const issues = [];
|
|
13703
14027
|
if (!resolvedConnectionString) {
|
|
13704
14028
|
try {
|
|
13705
|
-
resolvedConnectionString =
|
|
14029
|
+
resolvedConnectionString = getStorageConnectionStringForOperator("mementos");
|
|
13706
14030
|
} catch (error) {
|
|
13707
14031
|
issues.push(error instanceof Error ? error.message : String(error));
|
|
13708
14032
|
}
|
|
@@ -17767,7 +18091,7 @@ var init_zod = __esm(() => {
|
|
|
17767
18091
|
init_external();
|
|
17768
18092
|
});
|
|
17769
18093
|
|
|
17770
|
-
// ../../node_modules/.bun/@ai-sdk+provider@3.0.
|
|
18094
|
+
// ../../node_modules/.bun/@ai-sdk+provider@3.0.15/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
17771
18095
|
function getErrorMessage(error) {
|
|
17772
18096
|
if (error == null) {
|
|
17773
18097
|
return "unknown error";
|
|
@@ -17799,7 +18123,7 @@ function isJSONObject(value) {
|
|
|
17799
18123
|
return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
17800
18124
|
}
|
|
17801
18125
|
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, InvalidArgumentError2, 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;
|
|
17802
|
-
var
|
|
18126
|
+
var init_dist2 = __esm(() => {
|
|
17803
18127
|
symbol = Symbol.for(marker);
|
|
17804
18128
|
AISDKError = class _AISDKError extends (_b = Error, _a = symbol, _b) {
|
|
17805
18129
|
constructor({
|
|
@@ -29432,7 +29756,7 @@ var init_v3 = __esm(() => {
|
|
|
29432
29756
|
init_external();
|
|
29433
29757
|
});
|
|
29434
29758
|
|
|
29435
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
29759
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/index.js
|
|
29436
29760
|
function noop(_arg) {}
|
|
29437
29761
|
function createParser(config2) {
|
|
29438
29762
|
if (typeof config2 == "function")
|
|
@@ -29519,7 +29843,7 @@ ${value2}`, dataLines++;
|
|
|
29519
29843
|
}
|
|
29520
29844
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
29521
29845
|
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
29522
|
-
|
|
29846
|
+
value2.includes("\x00") || (id = value2);
|
|
29523
29847
|
return;
|
|
29524
29848
|
}
|
|
29525
29849
|
if (firstCharCode === 58) {
|
|
@@ -29547,7 +29871,7 @@ ${value2}`, dataLines++;
|
|
|
29547
29871
|
${value}`, dataLines++;
|
|
29548
29872
|
break;
|
|
29549
29873
|
case "id":
|
|
29550
|
-
|
|
29874
|
+
value.includes("\x00") || (id = value);
|
|
29551
29875
|
break;
|
|
29552
29876
|
case "retry":
|
|
29553
29877
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
@@ -29584,7 +29908,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
|
|
|
29584
29908
|
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;
|
|
29585
29909
|
}
|
|
29586
29910
|
var ParseError, LF = 10, CR = 13, SPACE = 32;
|
|
29587
|
-
var
|
|
29911
|
+
var init_dist3 = __esm(() => {
|
|
29588
29912
|
ParseError = class ParseError extends Error {
|
|
29589
29913
|
constructor(message, options) {
|
|
29590
29914
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -29592,10 +29916,10 @@ var init_dist2 = __esm(() => {
|
|
|
29592
29916
|
};
|
|
29593
29917
|
});
|
|
29594
29918
|
|
|
29595
|
-
// ../../node_modules/.bun/eventsource-parser@3.1.
|
|
29919
|
+
// ../../node_modules/.bun/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
|
|
29596
29920
|
var EventSourceParserStream;
|
|
29597
29921
|
var init_stream = __esm(() => {
|
|
29598
|
-
|
|
29922
|
+
init_dist3();
|
|
29599
29923
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
29600
29924
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
29601
29925
|
let parser;
|
|
@@ -29621,7 +29945,7 @@ var init_stream = __esm(() => {
|
|
|
29621
29945
|
};
|
|
29622
29946
|
});
|
|
29623
29947
|
|
|
29624
|
-
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.
|
|
29948
|
+
// ../../node_modules/.bun/@ai-sdk+provider-utils@4.0.46+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
29625
29949
|
function combineHeaders(...headers) {
|
|
29626
29950
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
29627
29951
|
...combinedHeaders,
|
|
@@ -29962,11 +30286,10 @@ async function loadNodeModule(id) {
|
|
|
29962
30286
|
var _a22;
|
|
29963
30287
|
const processWithBuiltins = globalThis.process;
|
|
29964
30288
|
const builtinModule = (_a22 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a22.call(processWithBuiltins, id);
|
|
29965
|
-
|
|
29966
|
-
}
|
|
29967
|
-
|
|
29968
|
-
|
|
29969
|
-
return dynamicImport(id);
|
|
30289
|
+
if (builtinModule == null) {
|
|
30290
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
30291
|
+
}
|
|
30292
|
+
return builtinModule;
|
|
29970
30293
|
}
|
|
29971
30294
|
function getCurrentModulePath() {
|
|
29972
30295
|
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
@@ -30065,7 +30388,7 @@ async function readResponseWithSizeLimit({
|
|
|
30065
30388
|
} finally {
|
|
30066
30389
|
try {
|
|
30067
30390
|
await reader.cancel();
|
|
30068
|
-
} finally {
|
|
30391
|
+
} catch (e) {} finally {
|
|
30069
30392
|
reader.releaseLock();
|
|
30070
30393
|
}
|
|
30071
30394
|
}
|
|
@@ -31330,7 +31653,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
31330
31653
|
supportsDeferredResults
|
|
31331
31654
|
});
|
|
31332
31655
|
}
|
|
31333
|
-
async function
|
|
31656
|
+
async function resolve21(value) {
|
|
31334
31657
|
if (typeof value === "function") {
|
|
31335
31658
|
value = value();
|
|
31336
31659
|
}
|
|
@@ -31465,7 +31788,7 @@ var DelayedPromise = class {
|
|
|
31465
31788
|
isPending() {
|
|
31466
31789
|
return this.status.type === "pending";
|
|
31467
31790
|
}
|
|
31468
|
-
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault,
|
|
31791
|
+
}, btoa, atob2, name14 = "AI_DownloadError", marker15, symbol17, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS = 10, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator = ({
|
|
31469
31792
|
prefix,
|
|
31470
31793
|
size = 16,
|
|
31471
31794
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -31489,7 +31812,7 @@ var DelayedPromise = class {
|
|
|
31489
31812
|
});
|
|
31490
31813
|
}
|
|
31491
31814
|
return () => `${prefix}${separator}${generator()}`;
|
|
31492
|
-
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.
|
|
31815
|
+
}, generateId2, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.46", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
31493
31816
|
url: url2,
|
|
31494
31817
|
headers = {},
|
|
31495
31818
|
successfulResponseHandler,
|
|
@@ -32009,23 +32332,23 @@ var DelayedPromise = class {
|
|
|
32009
32332
|
});
|
|
32010
32333
|
}
|
|
32011
32334
|
};
|
|
32012
|
-
var
|
|
32013
|
-
|
|
32014
|
-
|
|
32015
|
-
|
|
32016
|
-
|
|
32017
|
-
|
|
32018
|
-
|
|
32019
|
-
|
|
32020
|
-
|
|
32335
|
+
var init_dist4 = __esm(() => {
|
|
32336
|
+
init_dist2();
|
|
32337
|
+
init_dist2();
|
|
32338
|
+
init_dist2();
|
|
32339
|
+
init_dist2();
|
|
32340
|
+
init_dist2();
|
|
32341
|
+
init_dist2();
|
|
32342
|
+
init_dist2();
|
|
32343
|
+
init_dist2();
|
|
32021
32344
|
init_v4();
|
|
32022
32345
|
init_v3();
|
|
32023
32346
|
init_v3();
|
|
32024
32347
|
init_v3();
|
|
32025
32348
|
init_stream();
|
|
32026
|
-
|
|
32027
|
-
|
|
32028
|
-
|
|
32349
|
+
init_dist2();
|
|
32350
|
+
init_dist2();
|
|
32351
|
+
init_dist2();
|
|
32029
32352
|
({ btoa, atob: atob2 } = globalThis);
|
|
32030
32353
|
marker15 = `vercel.ai.error.${name14}`;
|
|
32031
32354
|
symbol17 = Symbol.for(marker15);
|
|
@@ -32118,7 +32441,7 @@ var init_dist3 = __esm(() => {
|
|
|
32118
32441
|
textDecoder = new TextDecoder;
|
|
32119
32442
|
});
|
|
32120
32443
|
|
|
32121
|
-
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.
|
|
32444
|
+
// ../../node_modules/.bun/@ai-sdk+anthropic@3.0.111+27912429049419a2/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
32122
32445
|
var exports_dist = {};
|
|
32123
32446
|
__export(exports_dist, {
|
|
32124
32447
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep,
|
|
@@ -32576,7 +32899,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
32576
32899
|
cacheControlValidator,
|
|
32577
32900
|
toolNameMapping
|
|
32578
32901
|
}) {
|
|
32579
|
-
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
32902
|
+
var _a16, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
32580
32903
|
const betas = /* @__PURE__ */ new Set;
|
|
32581
32904
|
const blocks = groupIntoBlocks(prompt);
|
|
32582
32905
|
const validator = cacheControlValidator || new CacheControlValidator;
|
|
@@ -32964,6 +33287,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
32964
33287
|
break;
|
|
32965
33288
|
}
|
|
32966
33289
|
case "tool-call": {
|
|
33290
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
32967
33291
|
if (part.providerExecuted) {
|
|
32968
33292
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
32969
33293
|
const isMcpToolUse = ((_l = (_k = part.providerOptions) == null ? undefined : _k.anthropic) == null ? undefined : _l.type) === "mcp-tool-use";
|
|
@@ -32992,6 +33316,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
32992
33316
|
id: part.toolCallId,
|
|
32993
33317
|
name: subtoolName,
|
|
32994
33318
|
input,
|
|
33319
|
+
...caller && { caller },
|
|
32995
33320
|
cache_control: cacheControl
|
|
32996
33321
|
});
|
|
32997
33322
|
} else if (providerToolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && part.input.type === "programmatic-tool-call") {
|
|
@@ -33001,6 +33326,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33001
33326
|
id: part.toolCallId,
|
|
33002
33327
|
name: "code_execution",
|
|
33003
33328
|
input: inputWithoutType,
|
|
33329
|
+
...caller && { caller },
|
|
33004
33330
|
cache_control: cacheControl
|
|
33005
33331
|
});
|
|
33006
33332
|
} else {
|
|
@@ -33010,6 +33336,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33010
33336
|
id: part.toolCallId,
|
|
33011
33337
|
name: providerToolName,
|
|
33012
33338
|
input: part.input,
|
|
33339
|
+
...caller && { caller },
|
|
33013
33340
|
cache_control: cacheControl
|
|
33014
33341
|
});
|
|
33015
33342
|
} else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
@@ -33018,6 +33345,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33018
33345
|
id: part.toolCallId,
|
|
33019
33346
|
name: providerToolName,
|
|
33020
33347
|
input: part.input,
|
|
33348
|
+
...caller && { caller },
|
|
33021
33349
|
cache_control: cacheControl
|
|
33022
33350
|
});
|
|
33023
33351
|
} else if (providerToolName === "advisor") {
|
|
@@ -33026,6 +33354,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33026
33354
|
id: part.toolCallId,
|
|
33027
33355
|
name: "advisor",
|
|
33028
33356
|
input: {},
|
|
33357
|
+
...caller && { caller },
|
|
33029
33358
|
cache_control: cacheControl
|
|
33030
33359
|
});
|
|
33031
33360
|
} else {
|
|
@@ -33037,11 +33366,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33037
33366
|
}
|
|
33038
33367
|
break;
|
|
33039
33368
|
}
|
|
33040
|
-
const callerOptions = (_o = part.providerOptions) == null ? undefined : _o.anthropic;
|
|
33041
|
-
const caller = (callerOptions == null ? undefined : callerOptions.caller) ? (callerOptions.caller.type === "code_execution_20250825" || callerOptions.caller.type === "code_execution_20260120") && callerOptions.caller.toolId ? {
|
|
33042
|
-
type: callerOptions.caller.type,
|
|
33043
|
-
tool_id: callerOptions.caller.toolId
|
|
33044
|
-
} : callerOptions.caller.type === "direct" ? { type: "direct" } : undefined : undefined;
|
|
33045
33369
|
anthropicContent.push({
|
|
33046
33370
|
type: "tool_use",
|
|
33047
33371
|
id: part.toolCallId,
|
|
@@ -33054,6 +33378,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33054
33378
|
}
|
|
33055
33379
|
case "tool-result": {
|
|
33056
33380
|
const providerToolName = toolNameMapping.toProviderToolName(part.toolName);
|
|
33381
|
+
const caller = getAnthropicCaller(part.providerOptions);
|
|
33057
33382
|
if (mcpToolUseIds.has(part.toolCallId)) {
|
|
33058
33383
|
const output = part.output;
|
|
33059
33384
|
if (output.type !== "json" && output.type !== "error-json") {
|
|
@@ -33087,7 +33412,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33087
33412
|
tool_use_id: part.toolCallId,
|
|
33088
33413
|
content: {
|
|
33089
33414
|
type: "code_execution_tool_result_error",
|
|
33090
|
-
error_code: (
|
|
33415
|
+
error_code: (_o = errorInfo.errorCode) != null ? _o : "unknown"
|
|
33091
33416
|
},
|
|
33092
33417
|
cache_control: cacheControl
|
|
33093
33418
|
});
|
|
@@ -33098,7 +33423,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33098
33423
|
cache_control: cacheControl,
|
|
33099
33424
|
content: {
|
|
33100
33425
|
type: "bash_code_execution_tool_result_error",
|
|
33101
|
-
error_code: (
|
|
33426
|
+
error_code: (_p = errorInfo.errorCode) != null ? _p : "unknown"
|
|
33102
33427
|
}
|
|
33103
33428
|
});
|
|
33104
33429
|
}
|
|
@@ -33131,7 +33456,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33131
33456
|
stdout: codeExecutionOutput.stdout,
|
|
33132
33457
|
stderr: codeExecutionOutput.stderr,
|
|
33133
33458
|
return_code: codeExecutionOutput.return_code,
|
|
33134
|
-
content: (
|
|
33459
|
+
content: (_q = codeExecutionOutput.content) != null ? _q : []
|
|
33135
33460
|
},
|
|
33136
33461
|
cache_control: cacheControl
|
|
33137
33462
|
});
|
|
@@ -33149,7 +33474,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33149
33474
|
encrypted_stdout: codeExecutionOutput.encrypted_stdout,
|
|
33150
33475
|
stderr: codeExecutionOutput.stderr,
|
|
33151
33476
|
return_code: codeExecutionOutput.return_code,
|
|
33152
|
-
content: (
|
|
33477
|
+
content: (_r = codeExecutionOutput.content) != null ? _r : []
|
|
33153
33478
|
},
|
|
33154
33479
|
cache_control: cacheControl
|
|
33155
33480
|
});
|
|
@@ -33168,7 +33493,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33168
33493
|
stdout: codeExecutionOutput.stdout,
|
|
33169
33494
|
stderr: codeExecutionOutput.stderr,
|
|
33170
33495
|
return_code: codeExecutionOutput.return_code,
|
|
33171
|
-
content: (
|
|
33496
|
+
content: (_s = codeExecutionOutput.content) != null ? _s : []
|
|
33172
33497
|
},
|
|
33173
33498
|
cache_control: cacheControl
|
|
33174
33499
|
});
|
|
@@ -33204,8 +33529,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33204
33529
|
tool_use_id: part.toolCallId,
|
|
33205
33530
|
content: {
|
|
33206
33531
|
type: "web_fetch_tool_result_error",
|
|
33207
|
-
error_code: (
|
|
33532
|
+
error_code: (_t = (await extractErrorValue(output.value)).errorCode) != null ? _t : "unavailable"
|
|
33208
33533
|
},
|
|
33534
|
+
...caller && { caller },
|
|
33209
33535
|
cache_control: cacheControl
|
|
33210
33536
|
});
|
|
33211
33537
|
break;
|
|
@@ -33239,6 +33565,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33239
33565
|
}
|
|
33240
33566
|
}
|
|
33241
33567
|
},
|
|
33568
|
+
...caller && { caller },
|
|
33242
33569
|
cache_control: cacheControl
|
|
33243
33570
|
});
|
|
33244
33571
|
break;
|
|
@@ -33251,8 +33578,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33251
33578
|
tool_use_id: part.toolCallId,
|
|
33252
33579
|
content: {
|
|
33253
33580
|
type: "web_search_tool_result_error",
|
|
33254
|
-
error_code: (
|
|
33581
|
+
error_code: (_u = (await extractErrorValue(output.value)).errorCode) != null ? _u : "unavailable"
|
|
33255
33582
|
},
|
|
33583
|
+
...caller && { caller },
|
|
33256
33584
|
cache_control: cacheControl
|
|
33257
33585
|
});
|
|
33258
33586
|
break;
|
|
@@ -33278,6 +33606,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
33278
33606
|
encrypted_content: result.encryptedContent,
|
|
33279
33607
|
type: result.type
|
|
33280
33608
|
})),
|
|
33609
|
+
...caller && { caller },
|
|
33281
33610
|
cache_control: cacheControl
|
|
33282
33611
|
});
|
|
33283
33612
|
break;
|
|
@@ -33446,6 +33775,17 @@ function moveToolUseBlocksToEnd(content) {
|
|
|
33446
33775
|
flushSegment();
|
|
33447
33776
|
return result;
|
|
33448
33777
|
}
|
|
33778
|
+
function getAnthropicCaller(providerOptions) {
|
|
33779
|
+
var _a16;
|
|
33780
|
+
const caller = (_a16 = providerOptions == null ? undefined : providerOptions.anthropic) == null ? undefined : _a16.caller;
|
|
33781
|
+
if (((caller == null ? undefined : caller.type) === "code_execution_20250825" || (caller == null ? undefined : caller.type) === "code_execution_20260120") && caller.toolId) {
|
|
33782
|
+
return {
|
|
33783
|
+
type: caller.type,
|
|
33784
|
+
tool_id: caller.toolId
|
|
33785
|
+
};
|
|
33786
|
+
}
|
|
33787
|
+
return (caller == null ? undefined : caller.type) === "direct" ? { type: "direct" } : undefined;
|
|
33788
|
+
}
|
|
33449
33789
|
function mapAnthropicStopReason({
|
|
33450
33790
|
finishReason,
|
|
33451
33791
|
isJsonResponseFromTool
|
|
@@ -33622,6 +33962,16 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
33622
33962
|
}
|
|
33623
33963
|
};
|
|
33624
33964
|
}
|
|
33965
|
+
function getAnthropicCallerInfo(caller) {
|
|
33966
|
+
return caller == null ? undefined : {
|
|
33967
|
+
type: caller.type,
|
|
33968
|
+
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
33969
|
+
};
|
|
33970
|
+
}
|
|
33971
|
+
function getAnthropicCallerMetadata(caller) {
|
|
33972
|
+
const callerInfo = getAnthropicCallerInfo(caller);
|
|
33973
|
+
return callerInfo == null ? {} : { providerMetadata: { anthropic: { caller: callerInfo } } };
|
|
33974
|
+
}
|
|
33625
33975
|
function getModelCapabilities(modelId) {
|
|
33626
33976
|
if (modelId.includes("claude-opus-5")) {
|
|
33627
33977
|
return {
|
|
@@ -33850,7 +34200,7 @@ function forwardAnthropicContainerIdFromLastStep({
|
|
|
33850
34200
|
}
|
|
33851
34201
|
return;
|
|
33852
34202
|
}
|
|
33853
|
-
var VERSION2 = "3.0.
|
|
34203
|
+
var VERSION2 = "3.0.111", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicStopDetailsSchema, anthropicToolCallCallerSchema, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicSystemMessageProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
33854
34204
|
constructor() {
|
|
33855
34205
|
this.breakpointCount = 0;
|
|
33856
34206
|
this.warnings = [];
|
|
@@ -34358,11 +34708,11 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34358
34708
|
betas,
|
|
34359
34709
|
headers
|
|
34360
34710
|
}) {
|
|
34361
|
-
return combineHeaders(await
|
|
34711
|
+
return combineHeaders(await resolve21(this.config.headers), headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
|
|
34362
34712
|
}
|
|
34363
34713
|
async getBetasFromHeaders(requestHeaders) {
|
|
34364
34714
|
var _a16, _b16;
|
|
34365
|
-
const configHeaders = await
|
|
34715
|
+
const configHeaders = await resolve21(this.config.headers);
|
|
34366
34716
|
const configBetaHeader = (_a16 = configHeaders["anthropic-beta"]) != null ? _a16 : "";
|
|
34367
34717
|
const requestBetaHeader = (_b16 = requestHeaders == null ? undefined : requestHeaders["anthropic-beta"]) != null ? _b16 : "";
|
|
34368
34718
|
return new Set([
|
|
@@ -34509,23 +34859,12 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34509
34859
|
text: JSON.stringify(part.input)
|
|
34510
34860
|
});
|
|
34511
34861
|
} else {
|
|
34512
|
-
const caller = part.caller;
|
|
34513
|
-
const callerInfo = caller ? {
|
|
34514
|
-
type: caller.type,
|
|
34515
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
34516
|
-
} : undefined;
|
|
34517
34862
|
content.push({
|
|
34518
34863
|
type: "tool-call",
|
|
34519
34864
|
toolCallId: part.id,
|
|
34520
34865
|
toolName: part.name,
|
|
34521
34866
|
input: JSON.stringify(part.input),
|
|
34522
|
-
...
|
|
34523
|
-
providerMetadata: {
|
|
34524
|
-
anthropic: {
|
|
34525
|
-
caller: callerInfo
|
|
34526
|
-
}
|
|
34527
|
-
}
|
|
34528
|
-
}
|
|
34867
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34529
34868
|
});
|
|
34530
34869
|
}
|
|
34531
34870
|
break;
|
|
@@ -34539,7 +34878,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34539
34878
|
toolName: toolNameMapping.toCustomToolName("code_execution"),
|
|
34540
34879
|
input: JSON.stringify({ type: part.name, ...part.input }),
|
|
34541
34880
|
providerExecuted: true,
|
|
34542
|
-
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {}
|
|
34881
|
+
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
34882
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34543
34883
|
});
|
|
34544
34884
|
} else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
|
|
34545
34885
|
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;
|
|
@@ -34549,7 +34889,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34549
34889
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
34550
34890
|
input: JSON.stringify(inputToSerialize),
|
|
34551
34891
|
providerExecuted: true,
|
|
34552
|
-
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {}
|
|
34892
|
+
...markCodeExecutionDynamic && part.name === "code_execution" ? { dynamic: true } : {},
|
|
34893
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34553
34894
|
});
|
|
34554
34895
|
} else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
|
|
34555
34896
|
serverToolCalls[part.id] = part.name;
|
|
@@ -34558,7 +34899,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34558
34899
|
toolCallId: part.id,
|
|
34559
34900
|
toolName: toolNameMapping.toCustomToolName(part.name),
|
|
34560
34901
|
input: JSON.stringify(part.input),
|
|
34561
|
-
providerExecuted: true
|
|
34902
|
+
providerExecuted: true,
|
|
34903
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34562
34904
|
});
|
|
34563
34905
|
} else if (part.name === "advisor") {
|
|
34564
34906
|
content.push({
|
|
@@ -34566,7 +34908,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34566
34908
|
toolCallId: part.id,
|
|
34567
34909
|
toolName: toolNameMapping.toCustomToolName("advisor"),
|
|
34568
34910
|
input: JSON.stringify(part.input),
|
|
34569
|
-
providerExecuted: true
|
|
34911
|
+
providerExecuted: true,
|
|
34912
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34570
34913
|
});
|
|
34571
34914
|
}
|
|
34572
34915
|
break;
|
|
@@ -34625,7 +34968,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34625
34968
|
data: part.content.content.source.data
|
|
34626
34969
|
}
|
|
34627
34970
|
}
|
|
34628
|
-
}
|
|
34971
|
+
},
|
|
34972
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34629
34973
|
});
|
|
34630
34974
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
34631
34975
|
content.push({
|
|
@@ -34636,7 +34980,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34636
34980
|
result: {
|
|
34637
34981
|
type: "web_fetch_tool_result_error",
|
|
34638
34982
|
errorCode: part.content.error_code
|
|
34639
|
-
}
|
|
34983
|
+
},
|
|
34984
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34640
34985
|
});
|
|
34641
34986
|
}
|
|
34642
34987
|
break;
|
|
@@ -34656,7 +35001,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34656
35001
|
encryptedContent: result.encrypted_content,
|
|
34657
35002
|
type: result.type
|
|
34658
35003
|
};
|
|
34659
|
-
})
|
|
35004
|
+
}),
|
|
35005
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34660
35006
|
});
|
|
34661
35007
|
for (const result of part.content) {
|
|
34662
35008
|
content.push({
|
|
@@ -34681,7 +35027,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
34681
35027
|
result: {
|
|
34682
35028
|
type: "web_search_tool_result_error",
|
|
34683
35029
|
errorCode: part.content.error_code
|
|
34684
|
-
}
|
|
35030
|
+
},
|
|
35031
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
34685
35032
|
});
|
|
34686
35033
|
}
|
|
34687
35034
|
break;
|
|
@@ -35022,11 +35369,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35022
35369
|
id: String(value.index)
|
|
35023
35370
|
});
|
|
35024
35371
|
} else {
|
|
35025
|
-
const
|
|
35026
|
-
const callerInfo = caller ? {
|
|
35027
|
-
type: caller.type,
|
|
35028
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
35029
|
-
} : undefined;
|
|
35372
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
35030
35373
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
35031
35374
|
const initialInput = hasNonEmptyInput ? JSON.stringify(part.input) : "";
|
|
35032
35375
|
contentBlocks[value.index] = {
|
|
@@ -35046,6 +35389,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35046
35389
|
return;
|
|
35047
35390
|
}
|
|
35048
35391
|
case "server_tool_use": {
|
|
35392
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
35049
35393
|
if ([
|
|
35050
35394
|
"web_fetch",
|
|
35051
35395
|
"web_search",
|
|
@@ -35066,7 +35410,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35066
35410
|
...markCodeExecutionDynamic && providerToolName === "code_execution" ? { dynamic: true } : {},
|
|
35067
35411
|
firstDelta: finalInput.length === 0,
|
|
35068
35412
|
providerToolName,
|
|
35069
|
-
providerToolInputType
|
|
35413
|
+
providerToolInputType,
|
|
35414
|
+
...callerInfo && { caller: callerInfo }
|
|
35070
35415
|
};
|
|
35071
35416
|
controller.enqueue({
|
|
35072
35417
|
type: "tool-input-start",
|
|
@@ -35085,7 +35430,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35085
35430
|
input: "",
|
|
35086
35431
|
providerExecuted: true,
|
|
35087
35432
|
firstDelta: true,
|
|
35088
|
-
providerToolName: part.name
|
|
35433
|
+
providerToolName: part.name,
|
|
35434
|
+
...callerInfo && { caller: callerInfo }
|
|
35089
35435
|
};
|
|
35090
35436
|
controller.enqueue({
|
|
35091
35437
|
type: "tool-input-start",
|
|
@@ -35102,7 +35448,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35102
35448
|
input: "{}",
|
|
35103
35449
|
providerExecuted: true,
|
|
35104
35450
|
firstDelta: true,
|
|
35105
|
-
providerToolName: part.name
|
|
35451
|
+
providerToolName: part.name,
|
|
35452
|
+
...callerInfo && { caller: callerInfo }
|
|
35106
35453
|
};
|
|
35107
35454
|
controller.enqueue({
|
|
35108
35455
|
type: "tool-input-start",
|
|
@@ -35137,7 +35484,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35137
35484
|
data: part.content.content.source.data
|
|
35138
35485
|
}
|
|
35139
35486
|
}
|
|
35140
|
-
}
|
|
35487
|
+
},
|
|
35488
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
35141
35489
|
});
|
|
35142
35490
|
} else if (part.content.type === "web_fetch_tool_result_error") {
|
|
35143
35491
|
controller.enqueue({
|
|
@@ -35148,7 +35496,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35148
35496
|
result: {
|
|
35149
35497
|
type: "web_fetch_tool_result_error",
|
|
35150
35498
|
errorCode: part.content.error_code
|
|
35151
|
-
}
|
|
35499
|
+
},
|
|
35500
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
35152
35501
|
});
|
|
35153
35502
|
}
|
|
35154
35503
|
return;
|
|
@@ -35168,7 +35517,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35168
35517
|
encryptedContent: result.encrypted_content,
|
|
35169
35518
|
type: result.type
|
|
35170
35519
|
};
|
|
35171
|
-
})
|
|
35520
|
+
}),
|
|
35521
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
35172
35522
|
});
|
|
35173
35523
|
for (const result of part.content) {
|
|
35174
35524
|
controller.enqueue({
|
|
@@ -35193,7 +35543,8 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35193
35543
|
result: {
|
|
35194
35544
|
type: "web_search_tool_result_error",
|
|
35195
35545
|
errorCode: part.content.error_code
|
|
35196
|
-
}
|
|
35546
|
+
},
|
|
35547
|
+
...getAnthropicCallerMetadata(part.caller)
|
|
35197
35548
|
});
|
|
35198
35549
|
}
|
|
35199
35550
|
return;
|
|
@@ -35571,11 +35922,7 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35571
35922
|
for (let contentIndex = 0;contentIndex < value.message.content.length; contentIndex++) {
|
|
35572
35923
|
const part = value.message.content[contentIndex];
|
|
35573
35924
|
if (part.type === "tool_use") {
|
|
35574
|
-
const
|
|
35575
|
-
const callerInfo = caller ? {
|
|
35576
|
-
type: caller.type,
|
|
35577
|
-
toolId: "tool_id" in caller ? caller.tool_id : undefined
|
|
35578
|
-
} : undefined;
|
|
35925
|
+
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
35579
35926
|
controller.enqueue({
|
|
35580
35927
|
type: "tool-input-start",
|
|
35581
35928
|
id: part.id,
|
|
@@ -35735,59 +36082,59 @@ var VERSION2 = "3.0.107", anthropicErrorDataSchema, anthropicFailedResponseHandl
|
|
|
35735
36082
|
}, 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 = {}) => {
|
|
35736
36083
|
return factory11(args);
|
|
35737
36084
|
}, anthropicTools, ANTHROPIC_API_URL = "https://api.anthropic.com", ANTHROPIC_API_VERSIONED_URL, anthropic;
|
|
35738
|
-
var
|
|
35739
|
-
|
|
35740
|
-
|
|
35741
|
-
|
|
35742
|
-
|
|
35743
|
-
|
|
36085
|
+
var init_dist5 = __esm(() => {
|
|
36086
|
+
init_dist2();
|
|
36087
|
+
init_dist4();
|
|
36088
|
+
init_dist2();
|
|
36089
|
+
init_dist4();
|
|
36090
|
+
init_dist4();
|
|
35744
36091
|
init_v4();
|
|
35745
|
-
|
|
36092
|
+
init_dist4();
|
|
35746
36093
|
init_v4();
|
|
35747
36094
|
init_v4();
|
|
35748
|
-
|
|
35749
|
-
|
|
36095
|
+
init_dist2();
|
|
36096
|
+
init_dist4();
|
|
35750
36097
|
init_v4();
|
|
35751
|
-
|
|
36098
|
+
init_dist4();
|
|
35752
36099
|
init_v4();
|
|
35753
|
-
|
|
36100
|
+
init_dist4();
|
|
35754
36101
|
init_v4();
|
|
35755
|
-
|
|
36102
|
+
init_dist4();
|
|
35756
36103
|
init_v4();
|
|
35757
|
-
|
|
36104
|
+
init_dist4();
|
|
35758
36105
|
init_v4();
|
|
35759
|
-
|
|
36106
|
+
init_dist4();
|
|
35760
36107
|
init_v4();
|
|
35761
|
-
|
|
35762
|
-
|
|
35763
|
-
|
|
35764
|
-
|
|
36108
|
+
init_dist4();
|
|
36109
|
+
init_dist2();
|
|
36110
|
+
init_dist4();
|
|
36111
|
+
init_dist4();
|
|
35765
36112
|
init_v4();
|
|
35766
|
-
|
|
36113
|
+
init_dist4();
|
|
35767
36114
|
init_v4();
|
|
35768
|
-
|
|
36115
|
+
init_dist4();
|
|
35769
36116
|
init_v4();
|
|
35770
|
-
|
|
36117
|
+
init_dist4();
|
|
35771
36118
|
init_v4();
|
|
35772
|
-
|
|
36119
|
+
init_dist4();
|
|
35773
36120
|
init_v4();
|
|
35774
|
-
|
|
36121
|
+
init_dist4();
|
|
35775
36122
|
init_v4();
|
|
35776
|
-
|
|
36123
|
+
init_dist4();
|
|
35777
36124
|
init_v4();
|
|
35778
|
-
|
|
36125
|
+
init_dist4();
|
|
35779
36126
|
init_v4();
|
|
35780
|
-
|
|
36127
|
+
init_dist4();
|
|
35781
36128
|
init_v4();
|
|
35782
|
-
|
|
36129
|
+
init_dist4();
|
|
35783
36130
|
init_v4();
|
|
35784
|
-
|
|
36131
|
+
init_dist4();
|
|
35785
36132
|
init_v4();
|
|
35786
|
-
|
|
36133
|
+
init_dist4();
|
|
35787
36134
|
init_v4();
|
|
35788
|
-
|
|
36135
|
+
init_dist4();
|
|
35789
36136
|
init_v4();
|
|
35790
|
-
|
|
36137
|
+
init_dist4();
|
|
35791
36138
|
init_v4();
|
|
35792
36139
|
anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
35793
36140
|
type: exports_external2.literal("error"),
|
|
@@ -35806,6 +36153,19 @@ var init_dist4 = __esm(() => {
|
|
|
35806
36153
|
explanation: exports_external2.string().nullish(),
|
|
35807
36154
|
recommended_model: exports_external2.string().nullish()
|
|
35808
36155
|
});
|
|
36156
|
+
anthropicToolCallCallerSchema = exports_external2.union([
|
|
36157
|
+
exports_external2.object({
|
|
36158
|
+
type: exports_external2.literal("code_execution_20250825"),
|
|
36159
|
+
tool_id: exports_external2.string()
|
|
36160
|
+
}),
|
|
36161
|
+
exports_external2.object({
|
|
36162
|
+
type: exports_external2.literal("code_execution_20260120"),
|
|
36163
|
+
tool_id: exports_external2.string()
|
|
36164
|
+
}),
|
|
36165
|
+
exports_external2.object({
|
|
36166
|
+
type: exports_external2.literal("direct")
|
|
36167
|
+
})
|
|
36168
|
+
]);
|
|
35809
36169
|
anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_external2.object({
|
|
35810
36170
|
type: exports_external2.literal("message"),
|
|
35811
36171
|
id: exports_external2.string().nullish(),
|
|
@@ -35858,34 +36218,14 @@ var init_dist4 = __esm(() => {
|
|
|
35858
36218
|
id: exports_external2.string(),
|
|
35859
36219
|
name: exports_external2.string(),
|
|
35860
36220
|
input: exports_external2.unknown(),
|
|
35861
|
-
caller:
|
|
35862
|
-
exports_external2.object({
|
|
35863
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
35864
|
-
tool_id: exports_external2.string()
|
|
35865
|
-
}),
|
|
35866
|
-
exports_external2.object({
|
|
35867
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
35868
|
-
tool_id: exports_external2.string()
|
|
35869
|
-
}),
|
|
35870
|
-
exports_external2.object({
|
|
35871
|
-
type: exports_external2.literal("direct")
|
|
35872
|
-
})
|
|
35873
|
-
]).optional()
|
|
36221
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
35874
36222
|
}),
|
|
35875
36223
|
exports_external2.object({
|
|
35876
36224
|
type: exports_external2.literal("server_tool_use"),
|
|
35877
36225
|
id: exports_external2.string(),
|
|
35878
36226
|
name: exports_external2.string(),
|
|
35879
36227
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
35880
|
-
caller:
|
|
35881
|
-
exports_external2.object({
|
|
35882
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
35883
|
-
tool_id: exports_external2.string()
|
|
35884
|
-
}),
|
|
35885
|
-
exports_external2.object({
|
|
35886
|
-
type: exports_external2.literal("direct")
|
|
35887
|
-
})
|
|
35888
|
-
]).optional()
|
|
36228
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
35889
36229
|
}),
|
|
35890
36230
|
exports_external2.object({
|
|
35891
36231
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -35906,6 +36246,7 @@ var init_dist4 = __esm(() => {
|
|
|
35906
36246
|
exports_external2.object({
|
|
35907
36247
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
35908
36248
|
tool_use_id: exports_external2.string(),
|
|
36249
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
35909
36250
|
content: exports_external2.union([
|
|
35910
36251
|
exports_external2.object({
|
|
35911
36252
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -35938,6 +36279,7 @@ var init_dist4 = __esm(() => {
|
|
|
35938
36279
|
exports_external2.object({
|
|
35939
36280
|
type: exports_external2.literal("web_search_tool_result"),
|
|
35940
36281
|
tool_use_id: exports_external2.string(),
|
|
36282
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
35941
36283
|
content: exports_external2.union([
|
|
35942
36284
|
exports_external2.array(exports_external2.object({
|
|
35943
36285
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -36141,19 +36483,7 @@ var init_dist4 = __esm(() => {
|
|
|
36141
36483
|
id: exports_external2.string(),
|
|
36142
36484
|
name: exports_external2.string(),
|
|
36143
36485
|
input: exports_external2.unknown(),
|
|
36144
|
-
caller:
|
|
36145
|
-
exports_external2.object({
|
|
36146
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
36147
|
-
tool_id: exports_external2.string()
|
|
36148
|
-
}),
|
|
36149
|
-
exports_external2.object({
|
|
36150
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
36151
|
-
tool_id: exports_external2.string()
|
|
36152
|
-
}),
|
|
36153
|
-
exports_external2.object({
|
|
36154
|
-
type: exports_external2.literal("direct")
|
|
36155
|
-
})
|
|
36156
|
-
]).optional()
|
|
36486
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
36157
36487
|
})
|
|
36158
36488
|
])).nullish(),
|
|
36159
36489
|
stop_reason: exports_external2.string().nullish(),
|
|
@@ -36180,19 +36510,7 @@ var init_dist4 = __esm(() => {
|
|
|
36180
36510
|
id: exports_external2.string(),
|
|
36181
36511
|
name: exports_external2.string(),
|
|
36182
36512
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).optional(),
|
|
36183
|
-
caller:
|
|
36184
|
-
exports_external2.object({
|
|
36185
|
-
type: exports_external2.literal("code_execution_20250825"),
|
|
36186
|
-
tool_id: exports_external2.string()
|
|
36187
|
-
}),
|
|
36188
|
-
exports_external2.object({
|
|
36189
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
36190
|
-
tool_id: exports_external2.string()
|
|
36191
|
-
}),
|
|
36192
|
-
exports_external2.object({
|
|
36193
|
-
type: exports_external2.literal("direct")
|
|
36194
|
-
})
|
|
36195
|
-
]).optional()
|
|
36513
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
36196
36514
|
}),
|
|
36197
36515
|
exports_external2.object({
|
|
36198
36516
|
type: exports_external2.literal("redacted_thinking"),
|
|
@@ -36207,15 +36525,7 @@ var init_dist4 = __esm(() => {
|
|
|
36207
36525
|
id: exports_external2.string(),
|
|
36208
36526
|
name: exports_external2.string(),
|
|
36209
36527
|
input: exports_external2.record(exports_external2.string(), exports_external2.unknown()).nullish(),
|
|
36210
|
-
caller:
|
|
36211
|
-
exports_external2.object({
|
|
36212
|
-
type: exports_external2.literal("code_execution_20260120"),
|
|
36213
|
-
tool_id: exports_external2.string()
|
|
36214
|
-
}),
|
|
36215
|
-
exports_external2.object({
|
|
36216
|
-
type: exports_external2.literal("direct")
|
|
36217
|
-
})
|
|
36218
|
-
]).optional()
|
|
36528
|
+
caller: anthropicToolCallCallerSchema.optional()
|
|
36219
36529
|
}),
|
|
36220
36530
|
exports_external2.object({
|
|
36221
36531
|
type: exports_external2.literal("mcp_tool_use"),
|
|
@@ -36236,6 +36546,7 @@ var init_dist4 = __esm(() => {
|
|
|
36236
36546
|
exports_external2.object({
|
|
36237
36547
|
type: exports_external2.literal("web_fetch_tool_result"),
|
|
36238
36548
|
tool_use_id: exports_external2.string(),
|
|
36549
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
36239
36550
|
content: exports_external2.union([
|
|
36240
36551
|
exports_external2.object({
|
|
36241
36552
|
type: exports_external2.literal("web_fetch_result"),
|
|
@@ -36268,6 +36579,7 @@ var init_dist4 = __esm(() => {
|
|
|
36268
36579
|
exports_external2.object({
|
|
36269
36580
|
type: exports_external2.literal("web_search_tool_result"),
|
|
36270
36581
|
tool_use_id: exports_external2.string(),
|
|
36582
|
+
caller: anthropicToolCallCallerSchema.optional(),
|
|
36271
36583
|
content: exports_external2.union([
|
|
36272
36584
|
exports_external2.array(exports_external2.object({
|
|
36273
36585
|
type: exports_external2.literal("web_search_result"),
|
|
@@ -37307,7 +37619,7 @@ var init_dist4 = __esm(() => {
|
|
|
37307
37619
|
anthropic = createAnthropic();
|
|
37308
37620
|
});
|
|
37309
37621
|
|
|
37310
|
-
// ../../node_modules/.bun/@ai-sdk+openai@3.0.
|
|
37622
|
+
// ../../node_modules/.bun/@ai-sdk+openai@3.0.97+27912429049419a2/node_modules/@ai-sdk/openai/dist/index.mjs
|
|
37311
37623
|
var exports_dist2 = {};
|
|
37312
37624
|
__export(exports_dist2, {
|
|
37313
37625
|
openai: () => openai,
|
|
@@ -38244,12 +38556,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
38244
38556
|
if (store && id != null) {
|
|
38245
38557
|
input.push({ type: "item_reference", id });
|
|
38246
38558
|
}
|
|
38247
|
-
|
|
38559
|
+
if (store || !hasShellTool || resolvedToolName !== "shell") {
|
|
38560
|
+
break;
|
|
38561
|
+
}
|
|
38248
38562
|
}
|
|
38249
|
-
|
|
38563
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
38564
|
+
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
38250
38565
|
break;
|
|
38251
38566
|
}
|
|
38252
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? undefined : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
38253
38567
|
if (store && id != null && isProviderDefinedToolCall) {
|
|
38254
38568
|
input.push({ type: "item_reference", id });
|
|
38255
38569
|
break;
|
|
@@ -38470,7 +38784,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
38470
38784
|
continue;
|
|
38471
38785
|
}
|
|
38472
38786
|
processedApprovalIds.add(approvalResponse.approvalId);
|
|
38473
|
-
if (store) {
|
|
38787
|
+
if (store && !hasConversation && !hasPreviousResponseId) {
|
|
38474
38788
|
input.push({
|
|
38475
38789
|
type: "item_reference",
|
|
38476
38790
|
id: approvalResponse.approvalId
|
|
@@ -39434,7 +39748,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
39434
39748
|
});
|
|
39435
39749
|
baseArgs.service_tier = undefined;
|
|
39436
39750
|
}
|
|
39437
|
-
if (openaiOptions.serviceTier === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
39751
|
+
if ((openaiOptions.serviceTier === "priority" || openaiOptions.serviceTier === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
39438
39752
|
warnings.push({
|
|
39439
39753
|
type: "unsupported",
|
|
39440
39754
|
feature: "serviceTier",
|
|
@@ -40444,7 +40758,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
40444
40758
|
});
|
|
40445
40759
|
delete baseArgs.service_tier;
|
|
40446
40760
|
}
|
|
40447
|
-
if ((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" && !modelCapabilities.supportsPriorityProcessing) {
|
|
40761
|
+
if (((openaiOptions == null ? undefined : openaiOptions.serviceTier) === "priority" || (openaiOptions == null ? undefined : openaiOptions.serviceTier) === "fast") && !modelCapabilities.supportsPriorityProcessing) {
|
|
40448
40762
|
warnings.push({
|
|
40449
40763
|
type: "unsupported",
|
|
40450
40764
|
feature: "serviceTier",
|
|
@@ -42024,78 +42338,78 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
42024
42338
|
}
|
|
42025
42339
|
};
|
|
42026
42340
|
}
|
|
42027
|
-
}, VERSION3 = "3.0.
|
|
42028
|
-
var
|
|
42029
|
-
|
|
42030
|
-
|
|
42031
|
-
|
|
42341
|
+
}, VERSION3 = "3.0.97", openai;
|
|
42342
|
+
var init_dist6 = __esm(() => {
|
|
42343
|
+
init_dist4();
|
|
42344
|
+
init_dist2();
|
|
42345
|
+
init_dist4();
|
|
42032
42346
|
init_v4();
|
|
42033
|
-
|
|
42034
|
-
|
|
42035
|
-
|
|
42036
|
-
|
|
42037
|
-
|
|
42347
|
+
init_dist4();
|
|
42348
|
+
init_dist2();
|
|
42349
|
+
init_dist2();
|
|
42350
|
+
init_dist4();
|
|
42351
|
+
init_dist4();
|
|
42038
42352
|
init_v4();
|
|
42039
|
-
|
|
42353
|
+
init_dist4();
|
|
42040
42354
|
init_v4();
|
|
42041
|
-
|
|
42042
|
-
|
|
42043
|
-
|
|
42355
|
+
init_dist2();
|
|
42356
|
+
init_dist4();
|
|
42357
|
+
init_dist2();
|
|
42044
42358
|
init_v4();
|
|
42045
|
-
|
|
42046
|
-
|
|
42359
|
+
init_dist4();
|
|
42360
|
+
init_dist4();
|
|
42047
42361
|
init_v4();
|
|
42048
|
-
|
|
42049
|
-
|
|
42050
|
-
|
|
42362
|
+
init_dist2();
|
|
42363
|
+
init_dist4();
|
|
42364
|
+
init_dist4();
|
|
42051
42365
|
init_v4();
|
|
42052
|
-
|
|
42366
|
+
init_dist4();
|
|
42053
42367
|
init_v4();
|
|
42054
|
-
|
|
42055
|
-
|
|
42368
|
+
init_dist4();
|
|
42369
|
+
init_dist4();
|
|
42056
42370
|
init_v4();
|
|
42057
|
-
|
|
42371
|
+
init_dist4();
|
|
42058
42372
|
init_v4();
|
|
42059
|
-
|
|
42373
|
+
init_dist4();
|
|
42060
42374
|
init_v4();
|
|
42061
|
-
|
|
42375
|
+
init_dist4();
|
|
42062
42376
|
init_v4();
|
|
42063
|
-
|
|
42377
|
+
init_dist4();
|
|
42064
42378
|
init_v4();
|
|
42065
|
-
|
|
42379
|
+
init_dist4();
|
|
42066
42380
|
init_v4();
|
|
42067
|
-
|
|
42381
|
+
init_dist4();
|
|
42068
42382
|
init_v4();
|
|
42069
|
-
|
|
42383
|
+
init_dist4();
|
|
42070
42384
|
init_v4();
|
|
42071
|
-
|
|
42385
|
+
init_dist4();
|
|
42072
42386
|
init_v4();
|
|
42073
|
-
|
|
42387
|
+
init_dist4();
|
|
42074
42388
|
init_v4();
|
|
42075
|
-
|
|
42389
|
+
init_dist4();
|
|
42076
42390
|
init_v4();
|
|
42077
|
-
|
|
42391
|
+
init_dist4();
|
|
42078
42392
|
init_v4();
|
|
42079
|
-
|
|
42393
|
+
init_dist4();
|
|
42080
42394
|
init_v4();
|
|
42081
|
-
|
|
42082
|
-
|
|
42083
|
-
|
|
42084
|
-
|
|
42395
|
+
init_dist2();
|
|
42396
|
+
init_dist4();
|
|
42397
|
+
init_dist2();
|
|
42398
|
+
init_dist4();
|
|
42085
42399
|
init_v4();
|
|
42086
|
-
|
|
42400
|
+
init_dist4();
|
|
42087
42401
|
init_v4();
|
|
42088
|
-
|
|
42402
|
+
init_dist4();
|
|
42089
42403
|
init_v4();
|
|
42090
|
-
|
|
42091
|
-
|
|
42092
|
-
|
|
42093
|
-
|
|
42404
|
+
init_dist2();
|
|
42405
|
+
init_dist4();
|
|
42406
|
+
init_dist4();
|
|
42407
|
+
init_dist4();
|
|
42094
42408
|
init_v4();
|
|
42095
|
-
|
|
42096
|
-
|
|
42409
|
+
init_dist4();
|
|
42410
|
+
init_dist4();
|
|
42097
42411
|
init_v4();
|
|
42098
|
-
|
|
42412
|
+
init_dist4();
|
|
42099
42413
|
init_v4();
|
|
42100
42414
|
openaiErrorDataSchema = exports_external2.object({
|
|
42101
42415
|
error: exports_external2.object({
|
|
@@ -42231,7 +42545,7 @@ var init_dist5 = __esm(() => {
|
|
|
42231
42545
|
store: exports_external2.boolean().optional(),
|
|
42232
42546
|
metadata: exports_external2.record(exports_external2.string().max(64), exports_external2.string().max(512)).optional(),
|
|
42233
42547
|
prediction: exports_external2.record(exports_external2.string(), exports_external2.any()).optional(),
|
|
42234
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).optional(),
|
|
42548
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).optional(),
|
|
42235
42549
|
strictJsonSchema: exports_external2.boolean().optional(),
|
|
42236
42550
|
textVerbosity: exports_external2.enum(["low", "medium", "high"]).optional(),
|
|
42237
42551
|
promptCacheKey: exports_external2.string().optional(),
|
|
@@ -43643,7 +43957,7 @@ var init_dist5 = __esm(() => {
|
|
|
43643
43957
|
reasoningContext: exports_external2.enum(["auto", "current_turn", "all_turns"]).optional(),
|
|
43644
43958
|
reasoningSummary: exports_external2.string().nullish(),
|
|
43645
43959
|
safetyIdentifier: exports_external2.string().nullish(),
|
|
43646
|
-
serviceTier: exports_external2.enum(["auto", "flex", "priority", "default"]).nullish(),
|
|
43960
|
+
serviceTier: exports_external2.enum(["auto", "flex", "priority", "fast", "default"]).nullish(),
|
|
43647
43961
|
store: exports_external2.boolean().nullish(),
|
|
43648
43962
|
passThroughUnsupportedFiles: exports_external2.boolean().optional(),
|
|
43649
43963
|
strictJsonSchema: exports_external2.boolean().nullish(),
|
|
@@ -43752,7 +44066,7 @@ var init_dist5 = __esm(() => {
|
|
|
43752
44066
|
openai = createOpenAI();
|
|
43753
44067
|
});
|
|
43754
44068
|
|
|
43755
|
-
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.
|
|
44069
|
+
// ../../node_modules/.bun/@ai-sdk+openai-compatible@2.0.69+27912429049419a2/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
43756
44070
|
var exports_dist3 = {};
|
|
43757
44071
|
__export(exports_dist3, {
|
|
43758
44072
|
createOpenAICompatible: () => createOpenAICompatible,
|
|
@@ -43803,7 +44117,7 @@ function convertOpenAICompatibleChatUsage(usage) {
|
|
|
43803
44117
|
},
|
|
43804
44118
|
outputTokens: {
|
|
43805
44119
|
total: completionTokens,
|
|
43806
|
-
text: completionTokens - reasoningTokens,
|
|
44120
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
43807
44121
|
reasoning: reasoningTokens
|
|
43808
44122
|
},
|
|
43809
44123
|
raw: usage
|
|
@@ -45177,27 +45491,27 @@ var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, open
|
|
|
45177
45491
|
}
|
|
45178
45492
|
};
|
|
45179
45493
|
}
|
|
45180
|
-
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.
|
|
45181
|
-
var
|
|
45182
|
-
|
|
45183
|
-
|
|
45494
|
+
}, openaiCompatibleImageResponseSchema, VERSION4 = "2.0.69";
|
|
45495
|
+
var init_dist7 = __esm(() => {
|
|
45496
|
+
init_dist2();
|
|
45497
|
+
init_dist4();
|
|
45184
45498
|
init_v4();
|
|
45185
45499
|
init_v4();
|
|
45186
|
-
|
|
45187
|
-
|
|
45500
|
+
init_dist2();
|
|
45501
|
+
init_dist4();
|
|
45188
45502
|
init_v4();
|
|
45189
|
-
|
|
45190
|
-
|
|
45503
|
+
init_dist2();
|
|
45504
|
+
init_dist4();
|
|
45191
45505
|
init_v4();
|
|
45192
|
-
|
|
45506
|
+
init_dist2();
|
|
45193
45507
|
init_v4();
|
|
45194
|
-
|
|
45195
|
-
|
|
45508
|
+
init_dist2();
|
|
45509
|
+
init_dist4();
|
|
45196
45510
|
init_v4();
|
|
45197
45511
|
init_v4();
|
|
45198
|
-
|
|
45512
|
+
init_dist4();
|
|
45199
45513
|
init_v4();
|
|
45200
|
-
|
|
45514
|
+
init_dist4();
|
|
45201
45515
|
openaiCompatibleErrorDataSchema = exports_external2.object({
|
|
45202
45516
|
error: exports_external2.object({
|
|
45203
45517
|
message: exports_external2.string(),
|
|
@@ -45220,10 +45534,10 @@ var init_dist6 = __esm(() => {
|
|
|
45220
45534
|
prompt_tokens: exports_external2.number().nullish(),
|
|
45221
45535
|
completion_tokens: exports_external2.number().nullish(),
|
|
45222
45536
|
total_tokens: exports_external2.number().nullish(),
|
|
45223
|
-
prompt_tokens_details: exports_external2.
|
|
45537
|
+
prompt_tokens_details: exports_external2.looseObject({
|
|
45224
45538
|
cached_tokens: exports_external2.number().nullish()
|
|
45225
45539
|
}).nullish(),
|
|
45226
|
-
completion_tokens_details: exports_external2.
|
|
45540
|
+
completion_tokens_details: exports_external2.looseObject({
|
|
45227
45541
|
reasoning_tokens: exports_external2.number().nullish(),
|
|
45228
45542
|
accepted_prediction_tokens: exports_external2.number().nullish(),
|
|
45229
45543
|
rejected_prediction_tokens: exports_external2.number().nullish()
|
|
@@ -45290,7 +45604,7 @@ var init_dist6 = __esm(() => {
|
|
|
45290
45604
|
suffix: exports_external2.string().optional(),
|
|
45291
45605
|
user: exports_external2.string().optional()
|
|
45292
45606
|
});
|
|
45293
|
-
usageSchema = exports_external2.
|
|
45607
|
+
usageSchema = exports_external2.looseObject({
|
|
45294
45608
|
prompt_tokens: exports_external2.number(),
|
|
45295
45609
|
completion_tokens: exports_external2.number(),
|
|
45296
45610
|
total_tokens: exports_external2.number()
|
|
@@ -45419,19 +45733,19 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
45419
45733
|
getUserDataDir: () => getUserDataDir
|
|
45420
45734
|
});
|
|
45421
45735
|
module.exports = __toCommonJS2(token_io_exports);
|
|
45422
|
-
var
|
|
45736
|
+
var import_path3 = __toESM2(__require("path"));
|
|
45423
45737
|
var import_fs2 = __toESM2(__require("fs"));
|
|
45424
|
-
var
|
|
45738
|
+
var import_os4 = __toESM2(__require("os"));
|
|
45425
45739
|
var import_token_error = require_token_error();
|
|
45426
45740
|
function findRootDir() {
|
|
45427
45741
|
try {
|
|
45428
45742
|
let dir = process.cwd();
|
|
45429
|
-
while (dir !==
|
|
45430
|
-
const pkgPath =
|
|
45743
|
+
while (dir !== import_path3.default.dirname(dir)) {
|
|
45744
|
+
const pkgPath = import_path3.default.join(dir, ".vercel");
|
|
45431
45745
|
if (import_fs2.default.existsSync(pkgPath)) {
|
|
45432
45746
|
return dir;
|
|
45433
45747
|
}
|
|
45434
|
-
dir =
|
|
45748
|
+
dir = import_path3.default.dirname(dir);
|
|
45435
45749
|
}
|
|
45436
45750
|
} catch (e) {
|
|
45437
45751
|
throw new import_token_error.VercelOidcTokenError("Token refresh only supported in node server environments");
|
|
@@ -45442,11 +45756,11 @@ var require_token_io = __commonJS((exports, module) => {
|
|
|
45442
45756
|
if (process.env.XDG_DATA_HOME) {
|
|
45443
45757
|
return process.env.XDG_DATA_HOME;
|
|
45444
45758
|
}
|
|
45445
|
-
switch (
|
|
45759
|
+
switch (import_os4.default.platform()) {
|
|
45446
45760
|
case "darwin":
|
|
45447
|
-
return
|
|
45761
|
+
return import_path3.default.join(import_os4.default.homedir(), "Library/Application Support");
|
|
45448
45762
|
case "linux":
|
|
45449
|
-
return
|
|
45763
|
+
return import_path3.default.join(import_os4.default.homedir(), ".local/share");
|
|
45450
45764
|
case "win32":
|
|
45451
45765
|
if (process.env.LOCALAPPDATA) {
|
|
45452
45766
|
return process.env.LOCALAPPDATA;
|
|
@@ -45491,11 +45805,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
45491
45805
|
var path = __toESM2(__require("path"));
|
|
45492
45806
|
var import_token_util = require_token_util();
|
|
45493
45807
|
function getAuthConfigPath() {
|
|
45494
|
-
const
|
|
45495
|
-
if (!
|
|
45808
|
+
const dataDir2 = (0, import_token_util.getVercelDataDir)();
|
|
45809
|
+
if (!dataDir2) {
|
|
45496
45810
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
45497
45811
|
}
|
|
45498
|
-
return path.join(
|
|
45812
|
+
return path.join(dataDir2, "auth.json");
|
|
45499
45813
|
}
|
|
45500
45814
|
function readAuthConfig() {
|
|
45501
45815
|
try {
|
|
@@ -45556,10 +45870,10 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
45556
45870
|
refreshTokenRequest: () => refreshTokenRequest
|
|
45557
45871
|
});
|
|
45558
45872
|
module.exports = __toCommonJS2(oauth_exports);
|
|
45559
|
-
var
|
|
45873
|
+
var import_os4 = __require("os");
|
|
45560
45874
|
var VERCEL_ISSUER = "https://vercel.com";
|
|
45561
45875
|
var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
|
|
45562
|
-
var userAgent = `@vercel/oidc node-${process.version} ${(0,
|
|
45876
|
+
var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os4.platform)()} (${(0, import_os4.arch)()}) ${(0, import_os4.hostname)()}`;
|
|
45563
45877
|
var _tokenEndpoint = null;
|
|
45564
45878
|
async function getTokenEndpoint() {
|
|
45565
45879
|
if (_tokenEndpoint) {
|
|
@@ -45702,11 +46016,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
45702
46016
|
var import_auth_errors = require_auth_errors();
|
|
45703
46017
|
function getVercelDataDir() {
|
|
45704
46018
|
const vercelFolder = "com.vercel.cli";
|
|
45705
|
-
const
|
|
45706
|
-
if (!
|
|
46019
|
+
const dataDir2 = (0, import_token_io.getUserDataDir)();
|
|
46020
|
+
if (!dataDir2) {
|
|
45707
46021
|
return null;
|
|
45708
46022
|
}
|
|
45709
|
-
return path.join(
|
|
46023
|
+
return path.join(dataDir2, vercelFolder);
|
|
45710
46024
|
}
|
|
45711
46025
|
async function getVercelToken2(options) {
|
|
45712
46026
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -45981,7 +46295,7 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
45981
46295
|
var import_token_util = require_token_util();
|
|
45982
46296
|
});
|
|
45983
46297
|
|
|
45984
|
-
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.
|
|
46298
|
+
// ../../node_modules/.bun/@ai-sdk+gateway@3.0.175+27912429049419a2/node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
45985
46299
|
async function createGatewayErrorFromResponse({
|
|
45986
46300
|
response,
|
|
45987
46301
|
statusCode,
|
|
@@ -46388,11 +46702,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46388
46702
|
try {
|
|
46389
46703
|
const { value } = await getFromApi({
|
|
46390
46704
|
url: `${this.config.baseURL}/config`,
|
|
46391
|
-
headers: await
|
|
46705
|
+
headers: await resolve21(this.config.headers()),
|
|
46392
46706
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
46393
46707
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46394
46708
|
errorSchema: exports_external2.any(),
|
|
46395
|
-
errorToMessage: (data) =>
|
|
46709
|
+
errorToMessage: (data) => {
|
|
46710
|
+
var _a112;
|
|
46711
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46712
|
+
}
|
|
46396
46713
|
}),
|
|
46397
46714
|
fetch: this.config.fetch
|
|
46398
46715
|
});
|
|
@@ -46406,11 +46723,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46406
46723
|
const baseUrl = new URL(this.config.baseURL);
|
|
46407
46724
|
const { value } = await getFromApi({
|
|
46408
46725
|
url: `${baseUrl.origin}/v1/credits`,
|
|
46409
|
-
headers: await
|
|
46726
|
+
headers: await resolve21(this.config.headers()),
|
|
46410
46727
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
46411
46728
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46412
46729
|
errorSchema: exports_external2.any(),
|
|
46413
|
-
errorToMessage: (data) =>
|
|
46730
|
+
errorToMessage: (data) => {
|
|
46731
|
+
var _a112;
|
|
46732
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46733
|
+
}
|
|
46414
46734
|
}),
|
|
46415
46735
|
fetch: this.config.fetch
|
|
46416
46736
|
});
|
|
@@ -46452,11 +46772,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46452
46772
|
}
|
|
46453
46773
|
const { value } = await getFromApi({
|
|
46454
46774
|
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
46455
|
-
headers: await
|
|
46775
|
+
headers: await resolve21(this.config.headers()),
|
|
46456
46776
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
46457
46777
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46458
46778
|
errorSchema: exports_external2.any(),
|
|
46459
|
-
errorToMessage: (data) =>
|
|
46779
|
+
errorToMessage: (data) => {
|
|
46780
|
+
var _a112;
|
|
46781
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46782
|
+
}
|
|
46460
46783
|
}),
|
|
46461
46784
|
fetch: this.config.fetch
|
|
46462
46785
|
});
|
|
@@ -46474,11 +46797,14 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46474
46797
|
const baseUrl = new URL(this.config.baseURL);
|
|
46475
46798
|
const { value } = await getFromApi({
|
|
46476
46799
|
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
46477
|
-
headers: await
|
|
46800
|
+
headers: await resolve21(this.config.headers()),
|
|
46478
46801
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
46479
46802
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46480
46803
|
errorSchema: exports_external2.any(),
|
|
46481
|
-
errorToMessage: (data) =>
|
|
46804
|
+
errorToMessage: (data) => {
|
|
46805
|
+
var _a112;
|
|
46806
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46807
|
+
}
|
|
46482
46808
|
}),
|
|
46483
46809
|
fetch: this.config.fetch
|
|
46484
46810
|
});
|
|
@@ -46507,7 +46833,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46507
46833
|
async doGenerate(options) {
|
|
46508
46834
|
const { args, warnings } = await this.getArgs(options);
|
|
46509
46835
|
const { abortSignal } = options;
|
|
46510
|
-
const resolvedHeaders = await
|
|
46836
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46511
46837
|
try {
|
|
46512
46838
|
const {
|
|
46513
46839
|
responseHeaders,
|
|
@@ -46515,12 +46841,15 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46515
46841
|
rawValue: rawResponse
|
|
46516
46842
|
} = await postJsonToApi({
|
|
46517
46843
|
url: this.getUrl(),
|
|
46518
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await
|
|
46844
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve21(this.config.o11yHeaders)),
|
|
46519
46845
|
body: args,
|
|
46520
46846
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
46521
46847
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46522
46848
|
errorSchema: exports_external2.any(),
|
|
46523
|
-
errorToMessage: (data) =>
|
|
46849
|
+
errorToMessage: (data) => {
|
|
46850
|
+
var _a112;
|
|
46851
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46852
|
+
}
|
|
46524
46853
|
}),
|
|
46525
46854
|
...abortSignal && { abortSignal },
|
|
46526
46855
|
fetch: this.config.fetch
|
|
@@ -46538,16 +46867,19 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46538
46867
|
async doStream(options) {
|
|
46539
46868
|
const { args, warnings } = await this.getArgs(options);
|
|
46540
46869
|
const { abortSignal } = options;
|
|
46541
|
-
const resolvedHeaders = await
|
|
46870
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46542
46871
|
try {
|
|
46543
46872
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
46544
46873
|
url: this.getUrl(),
|
|
46545
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await
|
|
46874
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve21(this.config.o11yHeaders)),
|
|
46546
46875
|
body: args,
|
|
46547
46876
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
46548
46877
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46549
46878
|
errorSchema: exports_external2.any(),
|
|
46550
|
-
errorToMessage: (data) =>
|
|
46879
|
+
errorToMessage: (data) => {
|
|
46880
|
+
var _a112;
|
|
46881
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
46882
|
+
}
|
|
46551
46883
|
}),
|
|
46552
46884
|
...abortSignal && { abortSignal },
|
|
46553
46885
|
fetch: this.config.fetch
|
|
@@ -46627,7 +46959,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46627
46959
|
providerOptions
|
|
46628
46960
|
}) {
|
|
46629
46961
|
var _a112, _b112;
|
|
46630
|
-
const resolvedHeaders = await
|
|
46962
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46631
46963
|
try {
|
|
46632
46964
|
const {
|
|
46633
46965
|
responseHeaders,
|
|
@@ -46635,7 +46967,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46635
46967
|
rawValue
|
|
46636
46968
|
} = await postJsonToApi({
|
|
46637
46969
|
url: this.getUrl(),
|
|
46638
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
46970
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders)),
|
|
46639
46971
|
body: {
|
|
46640
46972
|
values,
|
|
46641
46973
|
...providerOptions ? { providerOptions } : {}
|
|
@@ -46643,7 +46975,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46643
46975
|
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
46644
46976
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46645
46977
|
errorSchema: exports_external2.any(),
|
|
46646
|
-
errorToMessage: (data) =>
|
|
46978
|
+
errorToMessage: (data) => {
|
|
46979
|
+
var _a122;
|
|
46980
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
46981
|
+
}
|
|
46647
46982
|
}),
|
|
46648
46983
|
...abortSignal && { abortSignal },
|
|
46649
46984
|
fetch: this.config.fetch
|
|
@@ -46691,7 +47026,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46691
47026
|
abortSignal
|
|
46692
47027
|
}) {
|
|
46693
47028
|
var _a112, _b112, _c;
|
|
46694
|
-
const resolvedHeaders = await
|
|
47029
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46695
47030
|
try {
|
|
46696
47031
|
const {
|
|
46697
47032
|
responseHeaders,
|
|
@@ -46699,7 +47034,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46699
47034
|
rawValue
|
|
46700
47035
|
} = await postJsonToApi({
|
|
46701
47036
|
url: this.getUrl(),
|
|
46702
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
47037
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders)),
|
|
46703
47038
|
body: {
|
|
46704
47039
|
prompt,
|
|
46705
47040
|
n,
|
|
@@ -46715,7 +47050,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46715
47050
|
successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
|
|
46716
47051
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46717
47052
|
errorSchema: exports_external2.any(),
|
|
46718
|
-
errorToMessage: (data) =>
|
|
47053
|
+
errorToMessage: (data) => {
|
|
47054
|
+
var _a122;
|
|
47055
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
47056
|
+
}
|
|
46719
47057
|
}),
|
|
46720
47058
|
...abortSignal && { abortSignal },
|
|
46721
47059
|
fetch: this.config.fetch
|
|
@@ -46776,11 +47114,11 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46776
47114
|
headers,
|
|
46777
47115
|
abortSignal
|
|
46778
47116
|
}) {
|
|
46779
|
-
const resolvedHeaders = await
|
|
47117
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46780
47118
|
try {
|
|
46781
47119
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
46782
47120
|
url: this.getUrl(),
|
|
46783
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
47121
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
46784
47122
|
body: {
|
|
46785
47123
|
prompt,
|
|
46786
47124
|
n,
|
|
@@ -46868,7 +47206,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46868
47206
|
},
|
|
46869
47207
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46870
47208
|
errorSchema: exports_external2.any(),
|
|
46871
|
-
errorToMessage: (data) =>
|
|
47209
|
+
errorToMessage: (data) => {
|
|
47210
|
+
var _a112;
|
|
47211
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
47212
|
+
}
|
|
46872
47213
|
}),
|
|
46873
47214
|
...abortSignal && { abortSignal },
|
|
46874
47215
|
fetch: this.config.fetch
|
|
@@ -46914,7 +47255,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46914
47255
|
providerOptions
|
|
46915
47256
|
}) {
|
|
46916
47257
|
var _a112;
|
|
46917
|
-
const resolvedHeaders = await
|
|
47258
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46918
47259
|
try {
|
|
46919
47260
|
const {
|
|
46920
47261
|
responseHeaders,
|
|
@@ -46922,7 +47263,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46922
47263
|
rawValue
|
|
46923
47264
|
} = await postJsonToApi({
|
|
46924
47265
|
url: this.getUrl(),
|
|
46925
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
47266
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders)),
|
|
46926
47267
|
body: {
|
|
46927
47268
|
documents,
|
|
46928
47269
|
query,
|
|
@@ -46932,7 +47273,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46932
47273
|
successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
|
|
46933
47274
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46934
47275
|
errorSchema: exports_external2.any(),
|
|
46935
|
-
errorToMessage: (data) =>
|
|
47276
|
+
errorToMessage: (data) => {
|
|
47277
|
+
var _a122;
|
|
47278
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
47279
|
+
}
|
|
46936
47280
|
}),
|
|
46937
47281
|
...abortSignal && { abortSignal },
|
|
46938
47282
|
fetch: this.config.fetch
|
|
@@ -46976,7 +47320,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46976
47320
|
headers,
|
|
46977
47321
|
abortSignal
|
|
46978
47322
|
}) {
|
|
46979
|
-
const resolvedHeaders = await
|
|
47323
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
46980
47324
|
try {
|
|
46981
47325
|
const {
|
|
46982
47326
|
responseHeaders,
|
|
@@ -46984,7 +47328,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46984
47328
|
rawValue
|
|
46985
47329
|
} = await postJsonToApi({
|
|
46986
47330
|
url: this.getUrl(),
|
|
46987
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
47331
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders)),
|
|
46988
47332
|
body: {
|
|
46989
47333
|
text,
|
|
46990
47334
|
...voice && { voice },
|
|
@@ -46997,7 +47341,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
46997
47341
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
46998
47342
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
46999
47343
|
errorSchema: exports_external2.any(),
|
|
47000
|
-
errorToMessage: (data) =>
|
|
47344
|
+
errorToMessage: (data) => {
|
|
47345
|
+
var _a112;
|
|
47346
|
+
return (_a112 = getErrorMessage2(data)) != null ? _a112 : "unknown error";
|
|
47347
|
+
}
|
|
47001
47348
|
}),
|
|
47002
47349
|
...abortSignal && { abortSignal },
|
|
47003
47350
|
fetch: this.config.fetch
|
|
@@ -47043,7 +47390,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
47043
47390
|
abortSignal
|
|
47044
47391
|
}) {
|
|
47045
47392
|
var _a112, _b112, _c;
|
|
47046
|
-
const resolvedHeaders = await
|
|
47393
|
+
const resolvedHeaders = await resolve21(this.config.headers());
|
|
47047
47394
|
try {
|
|
47048
47395
|
const {
|
|
47049
47396
|
responseHeaders,
|
|
@@ -47051,7 +47398,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
47051
47398
|
rawValue
|
|
47052
47399
|
} = await postJsonToApi({
|
|
47053
47400
|
url: this.getUrl(),
|
|
47054
|
-
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await
|
|
47401
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve21(this.config.o11yHeaders)),
|
|
47055
47402
|
body: {
|
|
47056
47403
|
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
47057
47404
|
mediaType,
|
|
@@ -47060,7 +47407,10 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
47060
47407
|
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
47061
47408
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
47062
47409
|
errorSchema: exports_external2.any(),
|
|
47063
|
-
errorToMessage: (data) =>
|
|
47410
|
+
errorToMessage: (data) => {
|
|
47411
|
+
var _a122;
|
|
47412
|
+
return (_a122 = getErrorMessage2(data)) != null ? _a122 : "unknown error";
|
|
47413
|
+
}
|
|
47064
47414
|
}),
|
|
47065
47415
|
...abortSignal && { abortSignal },
|
|
47066
47416
|
fetch: this.config.fetch
|
|
@@ -47092,45 +47442,45 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
47092
47442
|
"ai-model-id": this.modelId
|
|
47093
47443
|
};
|
|
47094
47444
|
}
|
|
47095
|
-
}, 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.
|
|
47096
|
-
var
|
|
47097
|
-
|
|
47098
|
-
|
|
47445
|
+
}, 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;
|
|
47446
|
+
var init_dist8 = __esm(() => {
|
|
47447
|
+
init_dist4();
|
|
47448
|
+
init_dist2();
|
|
47099
47449
|
init_v4();
|
|
47100
47450
|
init_v4();
|
|
47101
|
-
|
|
47451
|
+
init_dist4();
|
|
47102
47452
|
init_v4();
|
|
47103
|
-
|
|
47104
|
-
|
|
47105
|
-
|
|
47453
|
+
init_dist4();
|
|
47454
|
+
init_dist4();
|
|
47455
|
+
init_dist4();
|
|
47106
47456
|
init_v4();
|
|
47107
|
-
|
|
47108
|
-
|
|
47457
|
+
init_dist4();
|
|
47458
|
+
init_dist4();
|
|
47109
47459
|
init_v4();
|
|
47110
|
-
|
|
47460
|
+
init_dist4();
|
|
47111
47461
|
init_v4();
|
|
47112
|
-
|
|
47462
|
+
init_dist4();
|
|
47113
47463
|
init_v4();
|
|
47114
|
-
|
|
47464
|
+
init_dist4();
|
|
47115
47465
|
init_v4();
|
|
47116
|
-
|
|
47466
|
+
init_dist4();
|
|
47117
47467
|
init_v4();
|
|
47118
|
-
|
|
47468
|
+
init_dist4();
|
|
47119
47469
|
init_v4();
|
|
47120
|
-
|
|
47121
|
-
|
|
47470
|
+
init_dist2();
|
|
47471
|
+
init_dist4();
|
|
47122
47472
|
init_v4();
|
|
47123
|
-
|
|
47473
|
+
init_dist4();
|
|
47124
47474
|
init_v4();
|
|
47125
|
-
|
|
47475
|
+
init_dist4();
|
|
47126
47476
|
init_v4();
|
|
47127
|
-
|
|
47477
|
+
init_dist4();
|
|
47128
47478
|
init_v4();
|
|
47129
|
-
|
|
47479
|
+
init_dist4();
|
|
47130
47480
|
init_zod();
|
|
47131
|
-
|
|
47481
|
+
init_dist4();
|
|
47132
47482
|
init_zod();
|
|
47133
|
-
|
|
47483
|
+
init_dist4();
|
|
47134
47484
|
init_zod();
|
|
47135
47485
|
import_oidc = __toESM(require_dist(), 1);
|
|
47136
47486
|
import_oidc2 = __toESM(require_dist(), 1);
|
|
@@ -49408,7 +49758,7 @@ var require_src = __commonJS((exports) => {
|
|
|
49408
49758
|
};
|
|
49409
49759
|
});
|
|
49410
49760
|
|
|
49411
|
-
// ../../node_modules/.bun/ai@6.0.
|
|
49761
|
+
// ../../node_modules/.bun/ai@6.0.257+27912429049419a2/node_modules/ai/dist/index.mjs
|
|
49412
49762
|
var exports_dist4 = {};
|
|
49413
49763
|
__export(exports_dist4, {
|
|
49414
49764
|
zodSchema: () => zodSchema,
|
|
@@ -50693,7 +51043,8 @@ async function recordSpan({
|
|
|
50693
51043
|
tracer,
|
|
50694
51044
|
attributes,
|
|
50695
51045
|
fn,
|
|
50696
|
-
endWhenDone = true
|
|
51046
|
+
endWhenDone = true,
|
|
51047
|
+
endOnError = endWhenDone
|
|
50697
51048
|
}) {
|
|
50698
51049
|
return tracer.startActiveSpan(name222, { attributes: await attributes }, async (span) => {
|
|
50699
51050
|
const ctx = import_api3.context.active();
|
|
@@ -50707,7 +51058,9 @@ async function recordSpan({
|
|
|
50707
51058
|
try {
|
|
50708
51059
|
recordErrorOnSpan(span, error40);
|
|
50709
51060
|
} finally {
|
|
50710
|
-
|
|
51061
|
+
if (endOnError) {
|
|
51062
|
+
span.end();
|
|
51063
|
+
}
|
|
50711
51064
|
}
|
|
50712
51065
|
throw error40;
|
|
50713
51066
|
}
|
|
@@ -53177,6 +53530,7 @@ function processUIMessageStream({
|
|
|
53177
53530
|
case "reasoning-start": {
|
|
53178
53531
|
const reasoningPart = {
|
|
53179
53532
|
type: "reasoning",
|
|
53533
|
+
id: chunk.id,
|
|
53180
53534
|
text: "",
|
|
53181
53535
|
providerMetadata: chunk.providerMetadata,
|
|
53182
53536
|
state: "streaming"
|
|
@@ -53473,7 +53827,7 @@ function processUIMessageStream({
|
|
|
53473
53827
|
}
|
|
53474
53828
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
53475
53829
|
if (chunk.messageId != null || chunk.messageMetadata != null) {
|
|
53476
|
-
write();
|
|
53830
|
+
write({ updateStatus: false });
|
|
53477
53831
|
}
|
|
53478
53832
|
break;
|
|
53479
53833
|
}
|
|
@@ -53696,9 +54050,18 @@ function createAsyncIterableStream(source) {
|
|
|
53696
54050
|
}
|
|
53697
54051
|
async function consumeStream({
|
|
53698
54052
|
stream,
|
|
53699
|
-
onError
|
|
54053
|
+
onError,
|
|
54054
|
+
abortSignal
|
|
53700
54055
|
}) {
|
|
53701
54056
|
const reader = stream.getReader();
|
|
54057
|
+
const cancelOnAbort = () => {
|
|
54058
|
+
reader.cancel().catch(() => {});
|
|
54059
|
+
};
|
|
54060
|
+
if (abortSignal == null ? undefined : abortSignal.aborted) {
|
|
54061
|
+
cancelOnAbort();
|
|
54062
|
+
} else {
|
|
54063
|
+
abortSignal == null || abortSignal.addEventListener("abort", cancelOnAbort, { once: true });
|
|
54064
|
+
}
|
|
53702
54065
|
try {
|
|
53703
54066
|
while (true) {
|
|
53704
54067
|
const { done } = await reader.read();
|
|
@@ -53708,6 +54071,7 @@ async function consumeStream({
|
|
|
53708
54071
|
} catch (error40) {
|
|
53709
54072
|
onError == null || onError(error40);
|
|
53710
54073
|
} finally {
|
|
54074
|
+
abortSignal == null || abortSignal.removeEventListener("abort", cancelOnAbort);
|
|
53711
54075
|
reader.releaseLock();
|
|
53712
54076
|
}
|
|
53713
54077
|
}
|
|
@@ -54308,6 +54672,27 @@ function createUIMessageStream({
|
|
|
54308
54672
|
onError
|
|
54309
54673
|
});
|
|
54310
54674
|
}
|
|
54675
|
+
function createUIMessageSnapshot(message) {
|
|
54676
|
+
const textByPartIndex = /* @__PURE__ */ new Map;
|
|
54677
|
+
const messageWithoutText = {
|
|
54678
|
+
...message,
|
|
54679
|
+
parts: message.parts.map((part, index) => {
|
|
54680
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
54681
|
+
textByPartIndex.set(index, part.text);
|
|
54682
|
+
return { ...part, text: "" };
|
|
54683
|
+
}
|
|
54684
|
+
return part;
|
|
54685
|
+
})
|
|
54686
|
+
};
|
|
54687
|
+
const snapshot2 = structuredClone(messageWithoutText);
|
|
54688
|
+
for (const [index, text2] of textByPartIndex) {
|
|
54689
|
+
const part = snapshot2.parts[index];
|
|
54690
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
54691
|
+
part.text = text2;
|
|
54692
|
+
}
|
|
54693
|
+
}
|
|
54694
|
+
return snapshot2;
|
|
54695
|
+
}
|
|
54311
54696
|
function readUIMessageStream({
|
|
54312
54697
|
message,
|
|
54313
54698
|
stream,
|
|
@@ -54340,7 +54725,7 @@ function readUIMessageStream({
|
|
|
54340
54725
|
return job({
|
|
54341
54726
|
state,
|
|
54342
54727
|
write: () => {
|
|
54343
|
-
controller == null || controller.enqueue(
|
|
54728
|
+
controller == null || controller.enqueue(createUIMessageSnapshot(state.message));
|
|
54344
54729
|
}
|
|
54345
54730
|
});
|
|
54346
54731
|
},
|
|
@@ -57223,7 +57608,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
57223
57608
|
}, imageMediaTypeSignatures, audioMediaTypeSignatures, videoMediaTypeSignatures, DEFAULT_SNIFF_BYTES = 18, MAX_SIGNATURE_BYTES = 12, MAX_ID3_TAG_BYTES, ID3_SCAN_BYTES, stripID3 = (bytes) => {
|
|
57224
57609
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
57225
57610
|
return bytes.subarray(id3Size + 10);
|
|
57226
|
-
}, VERSION6 = "6.0.
|
|
57611
|
+
}, VERSION6 = "6.0.257", download = async ({
|
|
57227
57612
|
url: url2,
|
|
57228
57613
|
maxBytes,
|
|
57229
57614
|
abortSignal
|
|
@@ -57318,7 +57703,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
57318
57703
|
const schema = asSchema(inputSchema);
|
|
57319
57704
|
return {
|
|
57320
57705
|
name: "object",
|
|
57321
|
-
responseFormat:
|
|
57706
|
+
responseFormat: resolve21(schema.jsonSchema).then((jsonSchema2) => ({
|
|
57322
57707
|
type: "json",
|
|
57323
57708
|
schema: jsonSchema2,
|
|
57324
57709
|
...name222 != null && { name: name222 },
|
|
@@ -57379,7 +57764,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
57379
57764
|
const elementSchema = asSchema(inputElementSchema);
|
|
57380
57765
|
return {
|
|
57381
57766
|
name: "array",
|
|
57382
|
-
responseFormat:
|
|
57767
|
+
responseFormat: resolve21(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
57383
57768
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
57384
57769
|
return {
|
|
57385
57770
|
type: "json",
|
|
@@ -58422,6 +58807,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
58422
58807
|
}),
|
|
58423
58808
|
tracer,
|
|
58424
58809
|
endWhenDone: false,
|
|
58810
|
+
endOnError: true,
|
|
58425
58811
|
fn: async (doStreamSpan2) => ({
|
|
58426
58812
|
startTimestampMs: now22(),
|
|
58427
58813
|
doStreamSpan: doStreamSpan2,
|
|
@@ -59341,10 +59727,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
59341
59727
|
onStepFinish,
|
|
59342
59728
|
...options
|
|
59343
59729
|
}) {
|
|
59730
|
+
const preparedCall = await this.prepareCall(options);
|
|
59344
59731
|
return generateText({
|
|
59345
|
-
...
|
|
59732
|
+
...preparedCall,
|
|
59346
59733
|
abortSignal,
|
|
59347
|
-
timeout,
|
|
59734
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
59348
59735
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
59349
59736
|
});
|
|
59350
59737
|
}
|
|
@@ -59355,10 +59742,11 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
59355
59742
|
onStepFinish,
|
|
59356
59743
|
...options
|
|
59357
59744
|
}) {
|
|
59745
|
+
const preparedCall = await this.prepareCall(options);
|
|
59358
59746
|
return streamText({
|
|
59359
|
-
...
|
|
59747
|
+
...preparedCall,
|
|
59360
59748
|
abortSignal,
|
|
59361
|
-
timeout,
|
|
59749
|
+
timeout: timeout != null ? timeout : preparedCall.timeout,
|
|
59362
59750
|
experimental_transform,
|
|
59363
59751
|
onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
|
|
59364
59752
|
});
|
|
@@ -59715,6 +60103,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
59715
60103
|
}),
|
|
59716
60104
|
tracer,
|
|
59717
60105
|
endWhenDone: false,
|
|
60106
|
+
endOnError: true,
|
|
59718
60107
|
fn: async (rootSpan) => {
|
|
59719
60108
|
const standardizedPrompt = await standardizePrompt({
|
|
59720
60109
|
system,
|
|
@@ -59784,6 +60173,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
59784
60173
|
}),
|
|
59785
60174
|
tracer,
|
|
59786
60175
|
endWhenDone: false,
|
|
60176
|
+
endOnError: true,
|
|
59787
60177
|
fn: async (doStreamSpan2) => ({
|
|
59788
60178
|
startTimestampMs: now22(),
|
|
59789
60179
|
doStreamSpan: doStreamSpan2,
|
|
@@ -60370,9 +60760,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60370
60760
|
...options
|
|
60371
60761
|
}) {
|
|
60372
60762
|
var _a222, _b16, _c, _d, _e;
|
|
60373
|
-
const resolvedBody = await
|
|
60374
|
-
const resolvedHeaders = await
|
|
60375
|
-
const resolvedCredentials = await
|
|
60763
|
+
const resolvedBody = await resolve21(this.body);
|
|
60764
|
+
const resolvedHeaders = await resolve21(this.headers);
|
|
60765
|
+
const resolvedCredentials = await resolve21(this.credentials);
|
|
60376
60766
|
const baseHeaders = {
|
|
60377
60767
|
...normalizeHeaders(resolvedHeaders),
|
|
60378
60768
|
...normalizeHeaders(options.headers)
|
|
@@ -60420,9 +60810,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60420
60810
|
}
|
|
60421
60811
|
async reconnectToStream(options) {
|
|
60422
60812
|
var _a222, _b16, _c, _d, _e;
|
|
60423
|
-
const resolvedBody = await
|
|
60424
|
-
const resolvedHeaders = await
|
|
60425
|
-
const resolvedCredentials = await
|
|
60813
|
+
const resolvedBody = await resolve21(this.body);
|
|
60814
|
+
const resolvedHeaders = await resolve21(this.headers);
|
|
60815
|
+
const resolvedCredentials = await resolve21(this.credentials);
|
|
60426
60816
|
const baseHeaders = {
|
|
60427
60817
|
...normalizeHeaders(resolvedHeaders),
|
|
60428
60818
|
...normalizeHeaders(options.headers)
|
|
@@ -60442,7 +60832,8 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60442
60832
|
const response = await fetch2(api2, {
|
|
60443
60833
|
method: "GET",
|
|
60444
60834
|
headers,
|
|
60445
|
-
credentials
|
|
60835
|
+
credentials,
|
|
60836
|
+
signal: options.abortSignal
|
|
60446
60837
|
});
|
|
60447
60838
|
if (response.status === 204) {
|
|
60448
60839
|
return null;
|
|
@@ -60470,6 +60861,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60470
60861
|
sendAutomaticallyWhen
|
|
60471
60862
|
}) {
|
|
60472
60863
|
this.activeResponse = undefined;
|
|
60864
|
+
this.activeResumeRequest = undefined;
|
|
60473
60865
|
this.jobExecutor = new SerialJobExecutor;
|
|
60474
60866
|
this.sendMessage = async (message, options) => {
|
|
60475
60867
|
var _a222, _b16, _c, _d;
|
|
@@ -60611,12 +61003,9 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60611
61003
|
});
|
|
60612
61004
|
this.addToolResult = this.addToolOutput;
|
|
60613
61005
|
this.stop = async () => {
|
|
60614
|
-
var _a222;
|
|
60615
|
-
|
|
60616
|
-
|
|
60617
|
-
if ((_a222 = this.activeResponse) == null ? undefined : _a222.abortController) {
|
|
60618
|
-
this.activeResponse.abortController.abort();
|
|
60619
|
-
}
|
|
61006
|
+
var _a222, _b16;
|
|
61007
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
61008
|
+
(_b16 = this.activeResponse) == null || _b16.abortController.abort();
|
|
60620
61009
|
};
|
|
60621
61010
|
this.id = id;
|
|
60622
61011
|
this.transport = transport;
|
|
@@ -60672,25 +61061,59 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60672
61061
|
body,
|
|
60673
61062
|
messageId
|
|
60674
61063
|
}) {
|
|
60675
|
-
var _a222, _b16;
|
|
61064
|
+
var _a222, _b16, _c;
|
|
61065
|
+
const abortController = new AbortController;
|
|
61066
|
+
const activeResumeRequest = trigger === "resume-stream" ? { abortController } : undefined;
|
|
61067
|
+
if (activeResumeRequest) {
|
|
61068
|
+
(_a222 = this.activeResumeRequest) == null || _a222.abortController.abort();
|
|
61069
|
+
this.activeResumeRequest = activeResumeRequest;
|
|
61070
|
+
}
|
|
61071
|
+
const isCurrentRequest = () => activeResumeRequest == null || this.activeResumeRequest === activeResumeRequest;
|
|
61072
|
+
const clearActiveResumeRequest = () => {
|
|
61073
|
+
if (this.activeResumeRequest === activeResumeRequest) {
|
|
61074
|
+
this.activeResumeRequest = undefined;
|
|
61075
|
+
}
|
|
61076
|
+
};
|
|
60676
61077
|
let resumeStream;
|
|
60677
61078
|
if (trigger === "resume-stream") {
|
|
60678
61079
|
try {
|
|
60679
61080
|
const reconnect = await this.transport.reconnectToStream({
|
|
60680
61081
|
chatId: this.id,
|
|
61082
|
+
abortSignal: abortController.signal,
|
|
60681
61083
|
metadata,
|
|
60682
61084
|
headers,
|
|
60683
61085
|
body
|
|
60684
61086
|
});
|
|
61087
|
+
if (abortController.signal.aborted || !isCurrentRequest()) {
|
|
61088
|
+
await (reconnect == null ? undefined : reconnect.cancel().catch(() => {}));
|
|
61089
|
+
if (isCurrentRequest()) {
|
|
61090
|
+
this.setStatus({ status: "ready" });
|
|
61091
|
+
}
|
|
61092
|
+
clearActiveResumeRequest();
|
|
61093
|
+
return;
|
|
61094
|
+
}
|
|
60685
61095
|
if (reconnect == null) {
|
|
61096
|
+
this.setStatus({ status: "ready" });
|
|
61097
|
+
clearActiveResumeRequest();
|
|
60686
61098
|
return;
|
|
60687
61099
|
}
|
|
60688
61100
|
resumeStream = reconnect;
|
|
60689
61101
|
} catch (err) {
|
|
61102
|
+
if (abortController.signal.aborted || err.name === "AbortError") {
|
|
61103
|
+
if (isCurrentRequest()) {
|
|
61104
|
+
this.setStatus({ status: "ready" });
|
|
61105
|
+
}
|
|
61106
|
+
clearActiveResumeRequest();
|
|
61107
|
+
return;
|
|
61108
|
+
}
|
|
61109
|
+
if (!isCurrentRequest()) {
|
|
61110
|
+
return;
|
|
61111
|
+
}
|
|
60690
61112
|
if (this.onError && err instanceof Error) {
|
|
60691
61113
|
this.onError(err);
|
|
60692
61114
|
}
|
|
60693
61115
|
this.setStatus({ status: "error", error: err });
|
|
61116
|
+
clearActiveResumeRequest();
|
|
60694
61117
|
return;
|
|
60695
61118
|
}
|
|
60696
61119
|
}
|
|
@@ -60703,10 +61126,10 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60703
61126
|
try {
|
|
60704
61127
|
const response = {
|
|
60705
61128
|
state: createStreamingUIMessageState({
|
|
60706
|
-
lastMessage: trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
61129
|
+
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? undefined : this.state.snapshot(lastMessage),
|
|
60707
61130
|
messageId: this.generateId()
|
|
60708
61131
|
}),
|
|
60709
|
-
abortController
|
|
61132
|
+
abortController
|
|
60710
61133
|
};
|
|
60711
61134
|
activeResponse = response;
|
|
60712
61135
|
response.abortController.signal.addEventListener("abort", () => {
|
|
@@ -60728,19 +61151,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60728
61151
|
messageId
|
|
60729
61152
|
});
|
|
60730
61153
|
}
|
|
60731
|
-
const runUpdateMessageJob = (job) => this.jobExecutor.run(() =>
|
|
60732
|
-
|
|
60733
|
-
|
|
60734
|
-
var _a232;
|
|
60735
|
-
this.setStatus({ status: "streaming" });
|
|
60736
|
-
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
60737
|
-
if (replaceLastMessage) {
|
|
60738
|
-
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
60739
|
-
} else {
|
|
60740
|
-
this.state.pushMessage(response.state.message);
|
|
60741
|
-
}
|
|
61154
|
+
const runUpdateMessageJob = (job) => this.jobExecutor.run(() => {
|
|
61155
|
+
if (response.abortController.signal.aborted) {
|
|
61156
|
+
return Promise.resolve();
|
|
60742
61157
|
}
|
|
60743
|
-
|
|
61158
|
+
return job({
|
|
61159
|
+
state: response.state,
|
|
61160
|
+
write: ({ updateStatus = true } = {}) => {
|
|
61161
|
+
var _a232;
|
|
61162
|
+
if (response.abortController.signal.aborted) {
|
|
61163
|
+
return;
|
|
61164
|
+
}
|
|
61165
|
+
if (updateStatus) {
|
|
61166
|
+
this.setStatus({ status: "streaming" });
|
|
61167
|
+
}
|
|
61168
|
+
const replaceLastMessage = response.state.message.id === ((_a232 = this.lastMessage) == null ? undefined : _a232.id);
|
|
61169
|
+
if (replaceLastMessage) {
|
|
61170
|
+
this.state.replaceMessage(this.state.messages.length - 1, response.state.message);
|
|
61171
|
+
} else {
|
|
61172
|
+
this.state.pushMessage(response.state.message);
|
|
61173
|
+
}
|
|
61174
|
+
}
|
|
61175
|
+
});
|
|
61176
|
+
});
|
|
60744
61177
|
await consumeStream({
|
|
60745
61178
|
stream: processUIMessageStream({
|
|
60746
61179
|
stream,
|
|
@@ -60753,15 +61186,29 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60753
61186
|
throw error40;
|
|
60754
61187
|
}
|
|
60755
61188
|
}),
|
|
61189
|
+
abortSignal: response.abortController.signal,
|
|
60756
61190
|
onError: (error40) => {
|
|
60757
61191
|
throw error40;
|
|
60758
61192
|
}
|
|
60759
61193
|
});
|
|
60760
|
-
|
|
61194
|
+
if (isAbort) {
|
|
61195
|
+
if (isCurrentRequest()) {
|
|
61196
|
+
this.setStatus({ status: "ready" });
|
|
61197
|
+
}
|
|
61198
|
+
return null;
|
|
61199
|
+
}
|
|
61200
|
+
if (isCurrentRequest()) {
|
|
61201
|
+
this.setStatus({ status: "ready" });
|
|
61202
|
+
}
|
|
60761
61203
|
} catch (err) {
|
|
60762
61204
|
if (isAbort || err.name === "AbortError") {
|
|
60763
61205
|
isAbort = true;
|
|
60764
|
-
|
|
61206
|
+
if (isCurrentRequest()) {
|
|
61207
|
+
this.setStatus({ status: "ready" });
|
|
61208
|
+
}
|
|
61209
|
+
return null;
|
|
61210
|
+
}
|
|
61211
|
+
if (!isCurrentRequest()) {
|
|
60765
61212
|
return null;
|
|
60766
61213
|
}
|
|
60767
61214
|
isError = true;
|
|
@@ -60775,7 +61222,7 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60775
61222
|
} finally {
|
|
60776
61223
|
try {
|
|
60777
61224
|
if (activeResponse) {
|
|
60778
|
-
(
|
|
61225
|
+
(_b16 = this.onFinish) == null || _b16.call(this, {
|
|
60779
61226
|
message: activeResponse.state.message,
|
|
60780
61227
|
messages: this.state.messages,
|
|
60781
61228
|
isAbort,
|
|
@@ -60784,17 +61231,17 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60784
61231
|
finishReason: activeResponse.state.finishReason
|
|
60785
61232
|
});
|
|
60786
61233
|
}
|
|
60787
|
-
}
|
|
60788
|
-
|
|
60789
|
-
|
|
60790
|
-
|
|
60791
|
-
|
|
61234
|
+
} finally {
|
|
61235
|
+
if (this.activeResponse === activeResponse) {
|
|
61236
|
+
this.activeResponse = undefined;
|
|
61237
|
+
}
|
|
61238
|
+
clearActiveResumeRequest();
|
|
60792
61239
|
}
|
|
60793
61240
|
}
|
|
60794
61241
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
60795
61242
|
await this.makeRequest({
|
|
60796
61243
|
trigger: "submit-message",
|
|
60797
|
-
messageId: (
|
|
61244
|
+
messageId: (_c = this.lastMessage) == null ? undefined : _c.id,
|
|
60798
61245
|
metadata,
|
|
60799
61246
|
headers,
|
|
60800
61247
|
body
|
|
@@ -60833,96 +61280,96 @@ var import_api2, import_api3, __defProp2, __export2 = (target, all) => {
|
|
|
60833
61280
|
return null;
|
|
60834
61281
|
}
|
|
60835
61282
|
}, TextStreamChatTransport;
|
|
60836
|
-
var
|
|
60837
|
-
|
|
60838
|
-
|
|
60839
|
-
|
|
60840
|
-
|
|
60841
|
-
|
|
60842
|
-
|
|
60843
|
-
|
|
60844
|
-
|
|
60845
|
-
|
|
60846
|
-
|
|
60847
|
-
|
|
60848
|
-
|
|
60849
|
-
|
|
60850
|
-
|
|
60851
|
-
|
|
60852
|
-
|
|
60853
|
-
|
|
60854
|
-
|
|
60855
|
-
|
|
60856
|
-
|
|
60857
|
-
|
|
60858
|
-
|
|
60859
|
-
|
|
60860
|
-
|
|
60861
|
-
|
|
60862
|
-
|
|
60863
|
-
|
|
60864
|
-
|
|
60865
|
-
|
|
60866
|
-
|
|
60867
|
-
|
|
60868
|
-
|
|
60869
|
-
|
|
61283
|
+
var init_dist9 = __esm(() => {
|
|
61284
|
+
init_dist8();
|
|
61285
|
+
init_dist4();
|
|
61286
|
+
init_dist4();
|
|
61287
|
+
init_dist4();
|
|
61288
|
+
init_dist2();
|
|
61289
|
+
init_dist2();
|
|
61290
|
+
init_dist2();
|
|
61291
|
+
init_dist2();
|
|
61292
|
+
init_dist2();
|
|
61293
|
+
init_dist2();
|
|
61294
|
+
init_dist2();
|
|
61295
|
+
init_dist2();
|
|
61296
|
+
init_dist2();
|
|
61297
|
+
init_dist2();
|
|
61298
|
+
init_dist2();
|
|
61299
|
+
init_dist2();
|
|
61300
|
+
init_dist2();
|
|
61301
|
+
init_dist2();
|
|
61302
|
+
init_dist2();
|
|
61303
|
+
init_dist2();
|
|
61304
|
+
init_dist2();
|
|
61305
|
+
init_dist2();
|
|
61306
|
+
init_dist2();
|
|
61307
|
+
init_dist2();
|
|
61308
|
+
init_dist2();
|
|
61309
|
+
init_dist4();
|
|
61310
|
+
init_dist2();
|
|
61311
|
+
init_dist8();
|
|
61312
|
+
init_dist4();
|
|
61313
|
+
init_dist4();
|
|
61314
|
+
init_dist4();
|
|
61315
|
+
init_dist2();
|
|
61316
|
+
init_dist4();
|
|
60870
61317
|
init_v4();
|
|
60871
|
-
|
|
60872
|
-
|
|
60873
|
-
|
|
60874
|
-
|
|
61318
|
+
init_dist2();
|
|
61319
|
+
init_dist4();
|
|
61320
|
+
init_dist2();
|
|
61321
|
+
init_dist4();
|
|
60875
61322
|
init_v4();
|
|
60876
61323
|
init_v4();
|
|
60877
61324
|
init_v4();
|
|
60878
61325
|
init_v4();
|
|
60879
61326
|
init_v4();
|
|
60880
|
-
|
|
60881
|
-
|
|
60882
|
-
|
|
60883
|
-
|
|
60884
|
-
|
|
60885
|
-
|
|
60886
|
-
|
|
60887
|
-
|
|
60888
|
-
|
|
60889
|
-
|
|
60890
|
-
|
|
60891
|
-
|
|
60892
|
-
|
|
60893
|
-
|
|
60894
|
-
|
|
60895
|
-
|
|
61327
|
+
init_dist8();
|
|
61328
|
+
init_dist2();
|
|
61329
|
+
init_dist2();
|
|
61330
|
+
init_dist8();
|
|
61331
|
+
init_dist4();
|
|
61332
|
+
init_dist4();
|
|
61333
|
+
init_dist4();
|
|
61334
|
+
init_dist4();
|
|
61335
|
+
init_dist4();
|
|
61336
|
+
init_dist2();
|
|
61337
|
+
init_dist4();
|
|
61338
|
+
init_dist4();
|
|
61339
|
+
init_dist4();
|
|
61340
|
+
init_dist2();
|
|
61341
|
+
init_dist4();
|
|
61342
|
+
init_dist4();
|
|
60896
61343
|
init_v4();
|
|
60897
|
-
|
|
60898
|
-
|
|
60899
|
-
|
|
60900
|
-
|
|
60901
|
-
|
|
60902
|
-
|
|
61344
|
+
init_dist4();
|
|
61345
|
+
init_dist4();
|
|
61346
|
+
init_dist4();
|
|
61347
|
+
init_dist4();
|
|
61348
|
+
init_dist2();
|
|
61349
|
+
init_dist4();
|
|
60903
61350
|
init_v4();
|
|
60904
|
-
|
|
60905
|
-
|
|
60906
|
-
|
|
60907
|
-
|
|
60908
|
-
|
|
60909
|
-
|
|
60910
|
-
|
|
60911
|
-
|
|
60912
|
-
|
|
60913
|
-
|
|
60914
|
-
|
|
60915
|
-
|
|
60916
|
-
|
|
60917
|
-
|
|
60918
|
-
|
|
60919
|
-
|
|
60920
|
-
|
|
60921
|
-
|
|
60922
|
-
|
|
60923
|
-
|
|
60924
|
-
|
|
60925
|
-
|
|
61351
|
+
init_dist4();
|
|
61352
|
+
init_dist4();
|
|
61353
|
+
init_dist4();
|
|
61354
|
+
init_dist4();
|
|
61355
|
+
init_dist2();
|
|
61356
|
+
init_dist4();
|
|
61357
|
+
init_dist2();
|
|
61358
|
+
init_dist4();
|
|
61359
|
+
init_dist4();
|
|
61360
|
+
init_dist4();
|
|
61361
|
+
init_dist4();
|
|
61362
|
+
init_dist4();
|
|
61363
|
+
init_dist2();
|
|
61364
|
+
init_dist4();
|
|
61365
|
+
init_dist2();
|
|
61366
|
+
init_dist2();
|
|
61367
|
+
init_dist2();
|
|
61368
|
+
init_dist4();
|
|
61369
|
+
init_dist4();
|
|
61370
|
+
init_dist4();
|
|
61371
|
+
init_dist4();
|
|
61372
|
+
init_dist4();
|
|
60926
61373
|
import_api2 = __toESM(require_src(), 1);
|
|
60927
61374
|
import_api3 = __toESM(require_src(), 1);
|
|
60928
61375
|
__defProp2 = Object.defineProperty;
|
|
@@ -61981,6 +62428,7 @@ var init_dist8 = __esm(() => {
|
|
|
61981
62428
|
}),
|
|
61982
62429
|
exports_external2.object({
|
|
61983
62430
|
type: exports_external2.literal("reasoning"),
|
|
62431
|
+
id: exports_external2.string().optional(),
|
|
61984
62432
|
text: exports_external2.string(),
|
|
61985
62433
|
state: exports_external2.enum(["streaming", "done"]).optional(),
|
|
61986
62434
|
providerMetadata: providerMetadataSchema.optional()
|
|
@@ -62389,7 +62837,7 @@ var {
|
|
|
62389
62837
|
// src/cli/index.tsx
|
|
62390
62838
|
init_database();
|
|
62391
62839
|
import { readFileSync as readFileSync10 } from "fs";
|
|
62392
|
-
import { dirname as dirname8, join as
|
|
62840
|
+
import { dirname as dirname8, join as join19 } from "path";
|
|
62393
62841
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
62394
62842
|
|
|
62395
62843
|
// src/db/machines.ts
|
|
@@ -62501,9 +62949,9 @@ function resolveExitCode(err) {
|
|
|
62501
62949
|
|
|
62502
62950
|
// ../../node_modules/.bun/@hasna+events@0.1.6/node_modules/@hasna/events/dist/commander.js
|
|
62503
62951
|
import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
62504
|
-
import { existsSync as
|
|
62505
|
-
import { homedir as
|
|
62506
|
-
import { join as
|
|
62952
|
+
import { existsSync as existsSync4 } from "fs";
|
|
62953
|
+
import { homedir as homedir3 } from "os";
|
|
62954
|
+
import { join as join6 } from "path";
|
|
62507
62955
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
62508
62956
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
62509
62957
|
import { spawn } from "child_process";
|
|
@@ -62552,7 +63000,7 @@ function channelMatchesEvent(channel, event) {
|
|
|
62552
63000
|
var HASNA_EVENTS_DIR_ENV = "HASNA_EVENTS_DIR";
|
|
62553
63001
|
var HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME";
|
|
62554
63002
|
function getEventsDataDir(override) {
|
|
62555
|
-
return override || process.env[HASNA_EVENTS_DIR_ENV] || process.env[HASNA_EVENTS_HOME_ENV] ||
|
|
63003
|
+
return override || process.env[HASNA_EVENTS_DIR_ENV] || process.env[HASNA_EVENTS_HOME_ENV] || join6(homedir3(), ".hasna", "events");
|
|
62556
63004
|
}
|
|
62557
63005
|
|
|
62558
63006
|
class JsonEventsStore {
|
|
@@ -62560,11 +63008,11 @@ class JsonEventsStore {
|
|
|
62560
63008
|
channelsPath;
|
|
62561
63009
|
eventsPath;
|
|
62562
63010
|
deliveriesPath;
|
|
62563
|
-
constructor(
|
|
62564
|
-
this.dataDir =
|
|
62565
|
-
this.channelsPath =
|
|
62566
|
-
this.eventsPath =
|
|
62567
|
-
this.deliveriesPath =
|
|
63011
|
+
constructor(dataDir2 = getEventsDataDir()) {
|
|
63012
|
+
this.dataDir = dataDir2;
|
|
63013
|
+
this.channelsPath = join6(dataDir2, "channels.json");
|
|
63014
|
+
this.eventsPath = join6(dataDir2, "events.json");
|
|
63015
|
+
this.deliveriesPath = join6(dataDir2, "deliveries.json");
|
|
62568
63016
|
}
|
|
62569
63017
|
async init() {
|
|
62570
63018
|
await mkdir(this.dataDir, { recursive: true, mode: 448 });
|
|
@@ -62636,7 +63084,7 @@ class JsonEventsStore {
|
|
|
62636
63084
|
};
|
|
62637
63085
|
}
|
|
62638
63086
|
async ensureArrayFile(path) {
|
|
62639
|
-
if (!
|
|
63087
|
+
if (!existsSync4(path)) {
|
|
62640
63088
|
await writeFile(path, `[]
|
|
62641
63089
|
`, { encoding: "utf-8", mode: 384 });
|
|
62642
63090
|
}
|
|
@@ -62753,7 +63201,7 @@ async function dispatchCommand(event, channel) {
|
|
|
62753
63201
|
HASNA_EVENT_SCHEMA_VERSION: event.schemaVersion,
|
|
62754
63202
|
HASNA_EVENT_JSON: eventJson
|
|
62755
63203
|
};
|
|
62756
|
-
return new Promise((
|
|
63204
|
+
return new Promise((resolve3) => {
|
|
62757
63205
|
const child = spawn(channel.command.command, channel.command.args ?? [], {
|
|
62758
63206
|
cwd: channel.command.cwd,
|
|
62759
63207
|
env,
|
|
@@ -62771,7 +63219,7 @@ async function dispatchCommand(event, channel) {
|
|
|
62771
63219
|
});
|
|
62772
63220
|
child.on("error", (error) => {
|
|
62773
63221
|
clearTimeout(timeout);
|
|
62774
|
-
|
|
63222
|
+
resolve3({
|
|
62775
63223
|
attempt: 1,
|
|
62776
63224
|
status: "failed",
|
|
62777
63225
|
startedAt,
|
|
@@ -62784,7 +63232,7 @@ async function dispatchCommand(event, channel) {
|
|
|
62784
63232
|
child.on("close", (code, signal) => {
|
|
62785
63233
|
clearTimeout(timeout);
|
|
62786
63234
|
const success = code === 0;
|
|
62787
|
-
|
|
63235
|
+
resolve3({
|
|
62788
63236
|
attempt: 1,
|
|
62789
63237
|
status: success ? "success" : "failed",
|
|
62790
63238
|
startedAt,
|
|
@@ -63191,7 +63639,7 @@ init_database();
|
|
|
63191
63639
|
init_api_mode();
|
|
63192
63640
|
init_memories();
|
|
63193
63641
|
import chalk2 from "chalk";
|
|
63194
|
-
import { resolve as
|
|
63642
|
+
import { resolve as resolve4 } from "path";
|
|
63195
63643
|
|
|
63196
63644
|
// src/db/memory-project-link.ts
|
|
63197
63645
|
init_storage();
|
|
@@ -64414,7 +64862,7 @@ function registerCrudCommands(program2) {
|
|
|
64414
64862
|
session_id: globalOpts.session
|
|
64415
64863
|
};
|
|
64416
64864
|
if (globalOpts.project) {
|
|
64417
|
-
const projectPath =
|
|
64865
|
+
const projectPath = resolve4(globalOpts.project);
|
|
64418
64866
|
const project = getProject(projectPath);
|
|
64419
64867
|
if (!project) {
|
|
64420
64868
|
throw new Error(`Unknown project "${projectPath}": no registered project matches that path.
|
|
@@ -64729,7 +65177,7 @@ init_helpers();
|
|
|
64729
65177
|
init_projects();
|
|
64730
65178
|
init_helpers();
|
|
64731
65179
|
import chalk4 from "chalk";
|
|
64732
|
-
import { resolve as
|
|
65180
|
+
import { resolve as resolve5 } from "path";
|
|
64733
65181
|
function registerTailCommand(program2) {
|
|
64734
65182
|
const handleError = makeHandleError(program2);
|
|
64735
65183
|
program2.command("tail").description("Watch for new/updated memories in real-time (like tail -f)").option("--scope <scope>", "Scope filter: global, shared, private, working").option("-c, --category <cat>", "Category filter: preference, fact, knowledge, history, procedural, resource").option("--agent <name>", "Agent filter").option("--project <path>", "Project filter").option("--interval <ms>", "Poll interval in milliseconds (default: 2000)", parseInt).option("--notify", "Send macOS notifications for each change").action((opts) => {
|
|
@@ -64740,7 +65188,7 @@ function registerTailCommand(program2) {
|
|
|
64740
65188
|
const projectPath = opts.project || globalOpts.project;
|
|
64741
65189
|
let projectId;
|
|
64742
65190
|
if (projectPath) {
|
|
64743
|
-
const project = getProject(
|
|
65191
|
+
const project = getProject(resolve5(projectPath));
|
|
64744
65192
|
if (project)
|
|
64745
65193
|
projectId = project.id;
|
|
64746
65194
|
}
|
|
@@ -64843,7 +65291,7 @@ init_projects();
|
|
|
64843
65291
|
init_search();
|
|
64844
65292
|
init_helpers();
|
|
64845
65293
|
import chalk6 from "chalk";
|
|
64846
|
-
import { resolve as
|
|
65294
|
+
import { resolve as resolve6 } from "path";
|
|
64847
65295
|
function registerSearchCommand(program2) {
|
|
64848
65296
|
const handleError = makeHandleError(program2);
|
|
64849
65297
|
program2.command("search <query>").description("Full-text search across memories").option("--scope <scope>", "Scope filter").option("-c, --category <cat>", "Category filter").option("--tags <tags>", "Comma-separated tags filter").option("--project <path>", "Project filter (path or name)").option("--agent <name>", "Agent filter").option("--session <id>", "Session ID filter").option("--limit <n>", "Max results", parseInt).option("--offset <n>", "Offset for pagination", parseInt).option("--cursor <n>", "Cursor offset for the next page", parseInt).option("--format <fmt>", "Output format: compact (default), json, csv, yaml").option("--verbose", "Show match highlights and wider snippets").option("--history", "Show recent search queries instead of searching").option("--popular", "Show most popular search queries").action((query, opts) => {
|
|
@@ -64888,7 +65336,7 @@ function registerSearchCommand(program2) {
|
|
|
64888
65336
|
const projectPath = opts.project || globalOpts.project;
|
|
64889
65337
|
let projectId;
|
|
64890
65338
|
if (projectPath) {
|
|
64891
|
-
const project = getProject(
|
|
65339
|
+
const project = getProject(resolve6(projectPath));
|
|
64892
65340
|
if (project)
|
|
64893
65341
|
projectId = project.id;
|
|
64894
65342
|
}
|
|
@@ -65154,7 +65602,7 @@ init_memories();
|
|
|
65154
65602
|
init_search();
|
|
65155
65603
|
init_helpers();
|
|
65156
65604
|
import chalk11 from "chalk";
|
|
65157
|
-
import { resolve as
|
|
65605
|
+
import { resolve as resolve7 } from "path";
|
|
65158
65606
|
|
|
65159
65607
|
// src/cli/commands/memory-cmd-recall-exit.ts
|
|
65160
65608
|
var RECALL_EXIT_NOT_FOUND = 1;
|
|
@@ -65170,7 +65618,7 @@ function registerRecallCommand(program2) {
|
|
|
65170
65618
|
const projectPath = opts.project || globalOpts.project;
|
|
65171
65619
|
let projectId;
|
|
65172
65620
|
if (projectPath) {
|
|
65173
|
-
const project = getProject(
|
|
65621
|
+
const project = getProject(resolve7(projectPath));
|
|
65174
65622
|
if (project)
|
|
65175
65623
|
projectId = project.id;
|
|
65176
65624
|
}
|
|
@@ -65226,9 +65674,10 @@ function registerRecallCommand(program2) {
|
|
|
65226
65674
|
// src/cli/commands/memory-cmd-list.ts
|
|
65227
65675
|
init_projects();
|
|
65228
65676
|
init_memories();
|
|
65677
|
+
init_redact();
|
|
65229
65678
|
init_helpers();
|
|
65230
65679
|
import chalk12 from "chalk";
|
|
65231
|
-
import { resolve as
|
|
65680
|
+
import { resolve as resolve8 } from "path";
|
|
65232
65681
|
function registerListCommand(program2) {
|
|
65233
65682
|
const handleError = makeHandleError(program2);
|
|
65234
65683
|
program2.command("list").description("List memories with optional filters").option("--scope <scope>", "Scope filter").option("-c, --category <cat>", "Category filter").option("--tags <tags>", "Comma-separated tags filter").option("--importance-min <n>", "Minimum importance", parseInt).option("--pinned", "Show only pinned").option("--agent <name>", "Agent filter").option("--project <path>", "Project filter").option("--session <id>", "Session ID filter").option("--limit <n>", "Max results", parseInt).option("--offset <n>", "Offset for pagination", parseInt).option("--cursor <n>", "Cursor offset for the next page", parseInt).option("--status <status>", "Status filter: active, archived, expired").option("--format <fmt>", "Output format: compact (default), json, csv, yaml").option("--verbose", "Show wider memory snippets in human output").action((opts) => {
|
|
@@ -65243,7 +65692,7 @@ function registerListCommand(program2) {
|
|
|
65243
65692
|
const projectPath = opts.project || globalOpts.project;
|
|
65244
65693
|
let projectId;
|
|
65245
65694
|
if (projectPath) {
|
|
65246
|
-
const project = getProject(
|
|
65695
|
+
const project = getProject(resolve8(projectPath));
|
|
65247
65696
|
if (!project) {
|
|
65248
65697
|
throw new Error(`Project not found: ${projectPath}`);
|
|
65249
65698
|
}
|
|
@@ -65273,36 +65722,37 @@ function registerListCommand(program2) {
|
|
|
65273
65722
|
};
|
|
65274
65723
|
}, limit, offset);
|
|
65275
65724
|
const memories = hasMore && limit !== undefined ? collected.slice(0, limit) : collected;
|
|
65725
|
+
const sanitized = memories.map(redactMemoryForOutput);
|
|
65276
65726
|
if (fmt === "json") {
|
|
65277
|
-
outputJson(
|
|
65727
|
+
outputJson(sanitized);
|
|
65278
65728
|
return;
|
|
65279
65729
|
}
|
|
65280
65730
|
if (fmt === "csv") {
|
|
65281
65731
|
console.log("key,value,scope,category,importance,id");
|
|
65282
|
-
for (const m of
|
|
65732
|
+
for (const m of sanitized) {
|
|
65283
65733
|
const v = m.value.replace(/"/g, '""');
|
|
65284
65734
|
console.log(`"${m.key}","${v}",${m.scope},${m.category},${m.importance},${m.id.slice(0, 8)}`);
|
|
65285
65735
|
}
|
|
65286
65736
|
return;
|
|
65287
65737
|
}
|
|
65288
65738
|
if (fmt === "yaml") {
|
|
65289
|
-
outputYaml(
|
|
65739
|
+
outputYaml(sanitized);
|
|
65290
65740
|
return;
|
|
65291
65741
|
}
|
|
65292
|
-
if (
|
|
65742
|
+
if (sanitized.length === 0) {
|
|
65293
65743
|
console.log(chalk12.yellow("No memories found."));
|
|
65294
65744
|
return;
|
|
65295
65745
|
}
|
|
65296
|
-
console.log(chalk12.bold(`${
|
|
65297
|
-
for (const m of
|
|
65746
|
+
console.log(chalk12.bold(`${sanitized.length}${hasMore ? "+" : ""} memor${sanitized.length === 1 ? "y" : "ies"}:`));
|
|
65747
|
+
for (const m of sanitized) {
|
|
65298
65748
|
console.log(formatMemoryLine(m, {
|
|
65299
65749
|
valueLength: opts.verbose ? 120 : 64,
|
|
65300
65750
|
preferSummary: !opts.verbose
|
|
65301
65751
|
}));
|
|
65302
65752
|
}
|
|
65303
65753
|
printPageHint({
|
|
65304
|
-
shown:
|
|
65305
|
-
limit: limit ??
|
|
65754
|
+
shown: sanitized.length,
|
|
65755
|
+
limit: limit ?? sanitized.length,
|
|
65306
65756
|
offset,
|
|
65307
65757
|
hasMore,
|
|
65308
65758
|
command: "mementos list",
|
|
@@ -65556,7 +66006,7 @@ function registerStatsCommand(program2) {
|
|
|
65556
66006
|
|
|
65557
66007
|
// src/cli/commands/info-report.ts
|
|
65558
66008
|
import chalk14 from "chalk";
|
|
65559
|
-
import { resolve as
|
|
66009
|
+
import { resolve as resolve9 } from "path";
|
|
65560
66010
|
init_projects();
|
|
65561
66011
|
function registerReportCommand(program2) {
|
|
65562
66012
|
program2.command("report").description("Rich summary of memory activity and top memories").option("--days <n>", "Activity window in days (default: 7)", "7").option("--project <path>", "Filter by project path").option("--markdown", "Output as Markdown (for PRs, docs, etc.)").option("--json", "Output as JSON").action((opts) => {
|
|
@@ -65568,7 +66018,7 @@ function registerReportCommand(program2) {
|
|
|
65568
66018
|
const projectPath = opts.project || globalOpts.project;
|
|
65569
66019
|
let projectId;
|
|
65570
66020
|
if (projectPath) {
|
|
65571
|
-
const project = getProject(
|
|
66021
|
+
const project = getProject(resolve9(projectPath));
|
|
65572
66022
|
if (project)
|
|
65573
66023
|
projectId = project.id;
|
|
65574
66024
|
}
|
|
@@ -65640,7 +66090,7 @@ mementos report \u2014 last ${days} days
|
|
|
65640
66090
|
|
|
65641
66091
|
// src/cli/commands/info-stale.ts
|
|
65642
66092
|
import chalk15 from "chalk";
|
|
65643
|
-
import { resolve as
|
|
66093
|
+
import { resolve as resolve10 } from "path";
|
|
65644
66094
|
init_projects();
|
|
65645
66095
|
init_helpers();
|
|
65646
66096
|
function registerStaleCommand(program2) {
|
|
@@ -65656,7 +66106,7 @@ function registerStaleCommand(program2) {
|
|
|
65656
66106
|
const projectPath = opts.project || globalOpts.project;
|
|
65657
66107
|
let projectId;
|
|
65658
66108
|
if (projectPath) {
|
|
65659
|
-
const project = getProject(
|
|
66109
|
+
const project = getProject(resolve10(projectPath));
|
|
65660
66110
|
if (project)
|
|
65661
66111
|
projectId = project.id;
|
|
65662
66112
|
}
|
|
@@ -65777,7 +66227,7 @@ function registerHistoryCommand(program2) {
|
|
|
65777
66227
|
init_projects();
|
|
65778
66228
|
init_memories();
|
|
65779
66229
|
import chalk17 from "chalk";
|
|
65780
|
-
import { resolve as
|
|
66230
|
+
import { resolve as resolve11 } from "path";
|
|
65781
66231
|
|
|
65782
66232
|
// src/lib/machine-visibility.ts
|
|
65783
66233
|
function resolveVisibleMachineId(machineId, db) {
|
|
@@ -65821,7 +66271,7 @@ function registerContextCommand(program2) {
|
|
|
65821
66271
|
const visibleMachineId = resolveVisibleMachineId(opts.machine);
|
|
65822
66272
|
let projectId;
|
|
65823
66273
|
if (projectPath) {
|
|
65824
|
-
const project = getProject(
|
|
66274
|
+
const project = getProject(resolve11(projectPath));
|
|
65825
66275
|
if (project)
|
|
65826
66276
|
projectId = project.id;
|
|
65827
66277
|
}
|
|
@@ -65935,7 +66385,7 @@ function registerInfoCommands(program2) {
|
|
|
65935
66385
|
init_projects();
|
|
65936
66386
|
init_memories();
|
|
65937
66387
|
init_helpers();
|
|
65938
|
-
import { resolve as
|
|
66388
|
+
import { resolve as resolve12 } from "path";
|
|
65939
66389
|
function registerExportCommand(program2) {
|
|
65940
66390
|
const handleError = makeHandleError(program2);
|
|
65941
66391
|
program2.command("export").description("Export memories as JSON").option("--scope <scope>", "Scope filter").option("-c, --category <cat>", "Category filter").option("--agent <name>", "Agent filter").option("--project <path>", "Project filter").action((opts) => {
|
|
@@ -65945,7 +66395,7 @@ function registerExportCommand(program2) {
|
|
|
65945
66395
|
const projectPath = opts.project || globalOpts.project;
|
|
65946
66396
|
let projectId;
|
|
65947
66397
|
if (projectPath) {
|
|
65948
|
-
const project = getProject(
|
|
66398
|
+
const project = getProject(resolve12(projectPath));
|
|
65949
66399
|
if (project)
|
|
65950
66400
|
projectId = project.id;
|
|
65951
66401
|
}
|
|
@@ -65967,7 +66417,7 @@ function registerExportCommand(program2) {
|
|
|
65967
66417
|
init_memories();
|
|
65968
66418
|
init_helpers();
|
|
65969
66419
|
import chalk18 from "chalk";
|
|
65970
|
-
import { resolve as
|
|
66420
|
+
import { resolve as resolve13 } from "path";
|
|
65971
66421
|
import { readFileSync as readFileSync5 } from "fs";
|
|
65972
66422
|
function registerImportCommand(program2) {
|
|
65973
66423
|
const handleError = makeHandleError(program2);
|
|
@@ -65978,7 +66428,7 @@ function registerImportCommand(program2) {
|
|
|
65978
66428
|
if (file === "-" || !file && !process.stdin.isTTY) {
|
|
65979
66429
|
raw = await Bun.stdin.text();
|
|
65980
66430
|
} else if (file) {
|
|
65981
|
-
raw = readFileSync5(
|
|
66431
|
+
raw = readFileSync5(resolve13(file), "utf-8");
|
|
65982
66432
|
} else {
|
|
65983
66433
|
console.error(chalk18.red("No input: provide a file path, use '-' for stdin, or pipe data."));
|
|
65984
66434
|
process.exit(1);
|
|
@@ -66008,14 +66458,15 @@ function registerImportCommand(program2) {
|
|
|
66008
66458
|
import chalk19 from "chalk";
|
|
66009
66459
|
|
|
66010
66460
|
// src/lib/config.ts
|
|
66011
|
-
|
|
66012
|
-
import {
|
|
66013
|
-
import {
|
|
66461
|
+
init_paths();
|
|
66462
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3, readFileSync as readFileSync6, readdirSync, writeFileSync as writeFileSync3, unlinkSync as unlinkSync2, cpSync as cpSync2 } from "fs";
|
|
66463
|
+
import { homedir as homedir5 } from "os";
|
|
66464
|
+
import { basename, dirname as dirname4, join as join10, resolve as resolve14 } from "path";
|
|
66014
66465
|
function isInMemoryDb2(path) {
|
|
66015
66466
|
return path === ":memory:" || path.startsWith("file::memory:");
|
|
66016
66467
|
}
|
|
66017
66468
|
function homeDir() {
|
|
66018
|
-
return process.env["HOME"] || process.env["USERPROFILE"] ||
|
|
66469
|
+
return process.env["HOME"] || process.env["USERPROFILE"] || homedir5();
|
|
66019
66470
|
}
|
|
66020
66471
|
var DEFAULT_CONFIG = {
|
|
66021
66472
|
default_scope: "private",
|
|
@@ -66073,9 +66524,9 @@ function isValidCategory(value) {
|
|
|
66073
66524
|
return VALID_CATEGORIES2.includes(value);
|
|
66074
66525
|
}
|
|
66075
66526
|
function loadConfig() {
|
|
66076
|
-
const configPath =
|
|
66527
|
+
const configPath = join10(getDataRoot(), "config.json");
|
|
66077
66528
|
let fileConfig = {};
|
|
66078
|
-
if (
|
|
66529
|
+
if (existsSync6(configPath)) {
|
|
66079
66530
|
try {
|
|
66080
66531
|
const raw = readFileSync6(configPath, "utf-8");
|
|
66081
66532
|
fileConfig = JSON.parse(raw);
|
|
@@ -66101,10 +66552,10 @@ function loadConfig() {
|
|
|
66101
66552
|
}
|
|
66102
66553
|
function findFileWalkingUp(filename) {
|
|
66103
66554
|
let dir = process.cwd();
|
|
66104
|
-
const legacyHomeMementosDb =
|
|
66555
|
+
const legacyHomeMementosDb = resolve14(homeDir(), ".mementos", "mementos.db");
|
|
66105
66556
|
while (true) {
|
|
66106
|
-
const candidate =
|
|
66107
|
-
if (
|
|
66557
|
+
const candidate = join10(dir, filename);
|
|
66558
|
+
if (existsSync6(candidate) && resolve14(candidate) !== legacyHomeMementosDb) {
|
|
66108
66559
|
return candidate;
|
|
66109
66560
|
}
|
|
66110
66561
|
const parent = dirname4(dir);
|
|
@@ -66117,7 +66568,7 @@ function findFileWalkingUp(filename) {
|
|
|
66117
66568
|
function findGitRoot2() {
|
|
66118
66569
|
let dir = process.cwd();
|
|
66119
66570
|
while (true) {
|
|
66120
|
-
if (
|
|
66571
|
+
if (existsSync6(join10(dir, ".git"))) {
|
|
66121
66572
|
return dir;
|
|
66122
66573
|
}
|
|
66123
66574
|
const parent = dirname4(dir);
|
|
@@ -66128,14 +66579,14 @@ function findGitRoot2() {
|
|
|
66128
66579
|
}
|
|
66129
66580
|
}
|
|
66130
66581
|
function profilesDir() {
|
|
66131
|
-
return
|
|
66582
|
+
return join10(getDataRoot(), "profiles");
|
|
66132
66583
|
}
|
|
66133
66584
|
function globalConfigPath() {
|
|
66134
|
-
return
|
|
66585
|
+
return join10(getDataRoot(), "config.json");
|
|
66135
66586
|
}
|
|
66136
66587
|
function readGlobalConfig() {
|
|
66137
66588
|
const p = globalConfigPath();
|
|
66138
|
-
if (!
|
|
66589
|
+
if (!existsSync6(p))
|
|
66139
66590
|
return {};
|
|
66140
66591
|
try {
|
|
66141
66592
|
return JSON.parse(readFileSync6(p, "utf-8"));
|
|
@@ -66145,7 +66596,7 @@ function readGlobalConfig() {
|
|
|
66145
66596
|
}
|
|
66146
66597
|
function readGlobalConfigForWrite() {
|
|
66147
66598
|
const p = globalConfigPath();
|
|
66148
|
-
if (!
|
|
66599
|
+
if (!existsSync6(p))
|
|
66149
66600
|
return {};
|
|
66150
66601
|
try {
|
|
66151
66602
|
const data = JSON.parse(readFileSync6(p, "utf-8"));
|
|
@@ -66181,13 +66632,13 @@ function setActiveProfile(name) {
|
|
|
66181
66632
|
}
|
|
66182
66633
|
function listProfiles() {
|
|
66183
66634
|
const dir = profilesDir();
|
|
66184
|
-
if (!
|
|
66635
|
+
if (!existsSync6(dir))
|
|
66185
66636
|
return [];
|
|
66186
66637
|
return readdirSync(dir).filter((f) => f.endsWith(".db")).map((f) => basename(f, ".db")).sort();
|
|
66187
66638
|
}
|
|
66188
66639
|
function deleteProfile(name) {
|
|
66189
|
-
const dbPath =
|
|
66190
|
-
if (!
|
|
66640
|
+
const dbPath = join10(profilesDir(), `${name}.db`);
|
|
66641
|
+
if (!existsSync6(dbPath))
|
|
66191
66642
|
return false;
|
|
66192
66643
|
unlinkSync2(dbPath);
|
|
66193
66644
|
if (getActiveProfile() === name)
|
|
@@ -66196,10 +66647,10 @@ function deleteProfile(name) {
|
|
|
66196
66647
|
}
|
|
66197
66648
|
function getDbPath2() {
|
|
66198
66649
|
const _home = homeDir();
|
|
66199
|
-
const _newDir =
|
|
66200
|
-
const _oldDir =
|
|
66201
|
-
if (!
|
|
66202
|
-
mkdirSync3(
|
|
66650
|
+
const _newDir = getDataRoot();
|
|
66651
|
+
const _oldDir = join10(_home, ".mementos");
|
|
66652
|
+
if (!existsSync6(_newDir) && existsSync6(_oldDir)) {
|
|
66653
|
+
mkdirSync3(join10(_home, ".hasna"), { recursive: true });
|
|
66203
66654
|
cpSync2(_oldDir, _newDir, { recursive: true });
|
|
66204
66655
|
}
|
|
66205
66656
|
const envDbPath = process.env["HASNA_MEMENTOS_DB_PATH"] ?? process.env["MEMENTOS_DB_PATH"];
|
|
@@ -66207,13 +66658,13 @@ function getDbPath2() {
|
|
|
66207
66658
|
if (isInMemoryDb2(envDbPath)) {
|
|
66208
66659
|
return envDbPath;
|
|
66209
66660
|
}
|
|
66210
|
-
const resolved =
|
|
66661
|
+
const resolved = resolve14(envDbPath);
|
|
66211
66662
|
ensureDir2(dirname4(resolved));
|
|
66212
66663
|
return resolved;
|
|
66213
66664
|
}
|
|
66214
66665
|
const profile = getActiveProfile();
|
|
66215
66666
|
if (profile) {
|
|
66216
|
-
const profilePath =
|
|
66667
|
+
const profilePath = join10(profilesDir(), `${profile}.db`);
|
|
66217
66668
|
ensureDir2(dirname4(profilePath));
|
|
66218
66669
|
return profilePath;
|
|
66219
66670
|
}
|
|
@@ -66221,21 +66672,21 @@ function getDbPath2() {
|
|
|
66221
66672
|
if (dbScope === "project") {
|
|
66222
66673
|
const gitRoot = findGitRoot2();
|
|
66223
66674
|
if (gitRoot) {
|
|
66224
|
-
const dbPath =
|
|
66675
|
+
const dbPath = join10(gitRoot, ".mementos", "mementos.db");
|
|
66225
66676
|
ensureDir2(dirname4(dbPath));
|
|
66226
66677
|
return dbPath;
|
|
66227
66678
|
}
|
|
66228
66679
|
}
|
|
66229
|
-
const found = findFileWalkingUp(
|
|
66680
|
+
const found = findFileWalkingUp(join10(".mementos", "mementos.db"));
|
|
66230
66681
|
if (found) {
|
|
66231
66682
|
return found;
|
|
66232
66683
|
}
|
|
66233
|
-
const fallback =
|
|
66684
|
+
const fallback = join10(getDataRoot(), "mementos.db");
|
|
66234
66685
|
ensureDir2(dirname4(fallback));
|
|
66235
66686
|
return fallback;
|
|
66236
66687
|
}
|
|
66237
66688
|
function ensureDir2(dir) {
|
|
66238
|
-
if (!
|
|
66689
|
+
if (!existsSync6(dir)) {
|
|
66239
66690
|
mkdirSync3(dir, { recursive: true });
|
|
66240
66691
|
}
|
|
66241
66692
|
}
|
|
@@ -66350,19 +66801,19 @@ function registerCleanCommand(program2) {
|
|
|
66350
66801
|
|
|
66351
66802
|
// src/cli/commands/io-backup.ts
|
|
66352
66803
|
init_database();
|
|
66804
|
+
init_paths();
|
|
66353
66805
|
init_helpers();
|
|
66354
66806
|
import chalk20 from "chalk";
|
|
66355
|
-
import { resolve as
|
|
66356
|
-
import { existsSync as
|
|
66807
|
+
import { join as join11, resolve as resolve15, dirname as dirname5 } from "path";
|
|
66808
|
+
import { existsSync as existsSync7, statSync, copyFileSync, mkdirSync as mkdirSync4, readdirSync as readdirSync2 } from "fs";
|
|
66357
66809
|
function registerBackupCommand(program2) {
|
|
66358
66810
|
const handleError = makeHandleError(program2);
|
|
66359
|
-
program2.command("backup [path]").description("Backup the SQLite database to a file").option("--list", "List available backups in
|
|
66811
|
+
program2.command("backup [path]").description("Backup the SQLite database to a file").option("--list", "List available backups in the mementos backups dir").action((targetPath, opts) => {
|
|
66360
66812
|
try {
|
|
66361
66813
|
const globalOpts = program2.opts();
|
|
66362
|
-
const
|
|
66363
|
-
const backupsDir = resolve14(home, ".hasna", "mementos", "backups");
|
|
66814
|
+
const backupsDir = join11(getDataRoot(), "backups");
|
|
66364
66815
|
if (opts.list) {
|
|
66365
|
-
if (!
|
|
66816
|
+
if (!existsSync7(backupsDir)) {
|
|
66366
66817
|
if (globalOpts.json) {
|
|
66367
66818
|
outputJson({ backups: [] });
|
|
66368
66819
|
return;
|
|
@@ -66371,7 +66822,7 @@ function registerBackupCommand(program2) {
|
|
|
66371
66822
|
return;
|
|
66372
66823
|
}
|
|
66373
66824
|
const files = readdirSync2(backupsDir).filter((f) => f.endsWith(".db")).map((f) => {
|
|
66374
|
-
const filePath =
|
|
66825
|
+
const filePath = resolve15(backupsDir, f);
|
|
66375
66826
|
const st2 = statSync(filePath);
|
|
66376
66827
|
return { name: f, path: filePath, size: st2.size, mtime: st2.mtime };
|
|
66377
66828
|
}).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
@@ -66404,23 +66855,23 @@ function registerBackupCommand(program2) {
|
|
|
66404
66855
|
return;
|
|
66405
66856
|
}
|
|
66406
66857
|
const dbPath = getDbPath();
|
|
66407
|
-
if (!
|
|
66858
|
+
if (!existsSync7(dbPath)) {
|
|
66408
66859
|
console.error(chalk20.red(`Database not found at ${dbPath}`));
|
|
66409
66860
|
process.exit(1);
|
|
66410
66861
|
}
|
|
66411
66862
|
let dest;
|
|
66412
66863
|
if (targetPath) {
|
|
66413
|
-
dest =
|
|
66864
|
+
dest = resolve15(targetPath);
|
|
66414
66865
|
} else {
|
|
66415
|
-
if (!
|
|
66866
|
+
if (!existsSync7(backupsDir)) {
|
|
66416
66867
|
mkdirSync4(backupsDir, { recursive: true });
|
|
66417
66868
|
}
|
|
66418
66869
|
const now3 = new Date;
|
|
66419
66870
|
const ts = now3.toISOString().replace(/[-:T]/g, "").replace(/\..+/, "").slice(0, 15);
|
|
66420
|
-
dest =
|
|
66871
|
+
dest = resolve15(backupsDir, `mementos-${ts}.db`);
|
|
66421
66872
|
}
|
|
66422
66873
|
const destDir = dirname5(dest);
|
|
66423
|
-
if (!
|
|
66874
|
+
if (!existsSync7(destDir)) {
|
|
66424
66875
|
mkdirSync4(destDir, { recursive: true });
|
|
66425
66876
|
}
|
|
66426
66877
|
copyFileSync(dbPath, dest);
|
|
@@ -66442,10 +66893,11 @@ function registerBackupCommand(program2) {
|
|
|
66442
66893
|
init_database();
|
|
66443
66894
|
init_api_mode();
|
|
66444
66895
|
init_memories();
|
|
66896
|
+
init_paths();
|
|
66445
66897
|
init_helpers();
|
|
66446
66898
|
import chalk21 from "chalk";
|
|
66447
|
-
import { resolve as
|
|
66448
|
-
import { existsSync as
|
|
66899
|
+
import { join as join12, resolve as resolve16 } from "path";
|
|
66900
|
+
import { existsSync as existsSync8, statSync as statSync2, copyFileSync as copyFileSync2, readdirSync as readdirSync3 } from "fs";
|
|
66449
66901
|
function readMemoriesFromBackup(source) {
|
|
66450
66902
|
const { Database: Database3 } = __require("bun:sqlite");
|
|
66451
66903
|
const backupDb = new Database3(source, { readonly: true });
|
|
@@ -66458,19 +66910,18 @@ function readMemoriesFromBackup(source) {
|
|
|
66458
66910
|
}
|
|
66459
66911
|
function registerRestoreCommand(program2) {
|
|
66460
66912
|
const handleError = makeHandleError(program2);
|
|
66461
|
-
program2.command("restore [file]").description("Restore the database from a backup file").option("--latest", "Restore the most recent backup from
|
|
66913
|
+
program2.command("restore [file]").description("Restore the database from a backup file").option("--latest", "Restore the most recent backup from the mementos backups dir").option("--force", "Skip confirmation and perform the restore").action((filePath, opts) => {
|
|
66462
66914
|
try {
|
|
66463
66915
|
const globalOpts = program2.opts();
|
|
66464
|
-
const
|
|
66465
|
-
const backupsDir = resolve15(home, ".hasna", "mementos", "backups");
|
|
66916
|
+
const backupsDir = join12(getDataRoot(), "backups");
|
|
66466
66917
|
let source;
|
|
66467
66918
|
if (opts.latest) {
|
|
66468
|
-
if (!
|
|
66919
|
+
if (!existsSync8(backupsDir)) {
|
|
66469
66920
|
console.error(chalk21.red("No backups directory found."));
|
|
66470
66921
|
process.exit(1);
|
|
66471
66922
|
}
|
|
66472
66923
|
const files = readdirSync3(backupsDir).filter((f) => f.endsWith(".db")).map((f) => {
|
|
66473
|
-
const fp =
|
|
66924
|
+
const fp = resolve16(backupsDir, f);
|
|
66474
66925
|
const st = statSync2(fp);
|
|
66475
66926
|
return { path: fp, mtime: st.mtime };
|
|
66476
66927
|
}).sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
@@ -66480,12 +66931,12 @@ function registerRestoreCommand(program2) {
|
|
|
66480
66931
|
}
|
|
66481
66932
|
source = files[0].path;
|
|
66482
66933
|
} else if (filePath) {
|
|
66483
|
-
source =
|
|
66934
|
+
source = resolve16(filePath);
|
|
66484
66935
|
} else {
|
|
66485
66936
|
console.error(chalk21.red("Provide a backup file path or use --latest"));
|
|
66486
66937
|
process.exit(1);
|
|
66487
66938
|
}
|
|
66488
|
-
if (!
|
|
66939
|
+
if (!existsSync8(source)) {
|
|
66489
66940
|
console.error(chalk21.red(`Backup file not found: ${source}`));
|
|
66490
66941
|
process.exit(1);
|
|
66491
66942
|
}
|
|
@@ -66560,7 +67011,7 @@ function registerRestoreCommand(program2) {
|
|
|
66560
67011
|
}
|
|
66561
67012
|
const dbPath = getDbPath();
|
|
66562
67013
|
let currentCount = 0;
|
|
66563
|
-
if (
|
|
67014
|
+
if (existsSync8(dbPath)) {
|
|
66564
67015
|
try {
|
|
66565
67016
|
const db = getDatabase();
|
|
66566
67017
|
const row = db.query("SELECT COUNT(*) as count FROM memories").get();
|
|
@@ -66842,7 +67293,7 @@ function registerAgentCommands(program2) {
|
|
|
66842
67293
|
init_projects();
|
|
66843
67294
|
init_memories();
|
|
66844
67295
|
import chalk23 from "chalk";
|
|
66845
|
-
import { resolve as
|
|
67296
|
+
import { resolve as resolve17 } from "path";
|
|
66846
67297
|
init_helpers();
|
|
66847
67298
|
function registerProjectCommands(program2) {
|
|
66848
67299
|
const handleError = makeHandleError(program2);
|
|
@@ -66860,7 +67311,7 @@ function registerProjectCommands(program2) {
|
|
|
66860
67311
|
console.error(chalk23.red("--name and --path are required when adding a project"));
|
|
66861
67312
|
process.exit(1);
|
|
66862
67313
|
}
|
|
66863
|
-
const project = registerProject(name,
|
|
67314
|
+
const project = registerProject(name, resolve17(path), opts.description);
|
|
66864
67315
|
if (globalOpts.json) {
|
|
66865
67316
|
outputJson(project);
|
|
66866
67317
|
} else {
|
|
@@ -66876,7 +67327,7 @@ function registerProjectCommands(program2) {
|
|
|
66876
67327
|
if (opts.name !== undefined)
|
|
66877
67328
|
updates.name = opts.name;
|
|
66878
67329
|
if (opts.path !== undefined)
|
|
66879
|
-
updates.path =
|
|
67330
|
+
updates.path = resolve17(opts.path);
|
|
66880
67331
|
if (opts.description !== undefined) {
|
|
66881
67332
|
updates.description = opts.description;
|
|
66882
67333
|
}
|
|
@@ -67020,7 +67471,7 @@ function registerProjectCommands(program2) {
|
|
|
67020
67471
|
const visibleMachineId = resolveVisibleMachineId(opts.machine);
|
|
67021
67472
|
let projectId;
|
|
67022
67473
|
if (projectPath) {
|
|
67023
|
-
const project = getProject(
|
|
67474
|
+
const project = getProject(resolve17(projectPath));
|
|
67024
67475
|
if (project)
|
|
67025
67476
|
projectId = project.id;
|
|
67026
67477
|
}
|
|
@@ -67373,7 +67824,7 @@ init_relations();
|
|
|
67373
67824
|
init_entity_memories();
|
|
67374
67825
|
init_helpers();
|
|
67375
67826
|
import chalk24 from "chalk";
|
|
67376
|
-
import { resolve as
|
|
67827
|
+
import { resolve as resolve18 } from "path";
|
|
67377
67828
|
function registerEntityCommands(program2) {
|
|
67378
67829
|
const handleError = makeHandleError(program2);
|
|
67379
67830
|
const entityCmd = program2.command("entity").description("Knowledge graph entity commands");
|
|
@@ -67383,7 +67834,7 @@ function registerEntityCommands(program2) {
|
|
|
67383
67834
|
const projectPath = opts.project || globalOpts.project;
|
|
67384
67835
|
let projectId;
|
|
67385
67836
|
if (projectPath) {
|
|
67386
|
-
const project = getProject(
|
|
67837
|
+
const project = getProject(resolve18(projectPath));
|
|
67387
67838
|
if (project)
|
|
67388
67839
|
projectId = project.id;
|
|
67389
67840
|
}
|
|
@@ -67456,7 +67907,7 @@ ${chalk24.bold(`Linked memories (${visibleMemories.length}${memories.length > vi
|
|
|
67456
67907
|
const projectPath = opts.project || globalOpts.project;
|
|
67457
67908
|
let projectId;
|
|
67458
67909
|
if (projectPath) {
|
|
67459
|
-
const project = getProject(
|
|
67910
|
+
const project = getProject(resolve18(projectPath));
|
|
67460
67911
|
if (project)
|
|
67461
67912
|
projectId = project.id;
|
|
67462
67913
|
}
|
|
@@ -67814,11 +68265,11 @@ init_memories();
|
|
|
67814
68265
|
init_agents();
|
|
67815
68266
|
init_projects();
|
|
67816
68267
|
import chalk27 from "chalk";
|
|
67817
|
-
import { join as
|
|
67818
|
-
import { homedir as
|
|
68268
|
+
import { join as join13 } from "path";
|
|
68269
|
+
import { homedir as homedir6 } from "os";
|
|
67819
68270
|
import {
|
|
67820
68271
|
readFileSync as readFileSync7,
|
|
67821
|
-
existsSync as
|
|
68272
|
+
existsSync as existsSync9,
|
|
67822
68273
|
accessSync,
|
|
67823
68274
|
statSync as statSync3,
|
|
67824
68275
|
constants as fsConstants
|
|
@@ -67832,10 +68283,10 @@ async function runCommandWithTimeout(args, timeoutMs) {
|
|
|
67832
68283
|
let timedOut = false;
|
|
67833
68284
|
const exitCode = await Promise.race([
|
|
67834
68285
|
proc.exited,
|
|
67835
|
-
new Promise((
|
|
68286
|
+
new Promise((resolve19) => setTimeout(() => {
|
|
67836
68287
|
timedOut = true;
|
|
67837
68288
|
proc.kill();
|
|
67838
|
-
|
|
68289
|
+
resolve19(null);
|
|
67839
68290
|
}, timeoutMs))
|
|
67840
68291
|
]);
|
|
67841
68292
|
const [stdout, stderr] = await Promise.all([stdoutPromise, stderrPromise]);
|
|
@@ -67853,7 +68304,7 @@ function registerDoctorCommand(program2) {
|
|
|
67853
68304
|
checks.push({ name: "Version", status: "ok", detail: version });
|
|
67854
68305
|
const dbPath = getDbPath();
|
|
67855
68306
|
let db = null;
|
|
67856
|
-
if (dbPath !== ":memory:" &&
|
|
68307
|
+
if (dbPath !== ":memory:" && existsSync9(dbPath)) {
|
|
67857
68308
|
try {
|
|
67858
68309
|
accessSync(dbPath, fsConstants.R_OK | fsConstants.W_OK);
|
|
67859
68310
|
checks.push({ name: "Database file", status: "ok", detail: dbPath });
|
|
@@ -67872,7 +68323,7 @@ function registerDoctorCommand(program2) {
|
|
|
67872
68323
|
checks.push({ name: "Database connection", status: "fail", detail: e instanceof Error ? e.message : String(e) });
|
|
67873
68324
|
}
|
|
67874
68325
|
try {
|
|
67875
|
-
if (dbPath !== ":memory:" &&
|
|
68326
|
+
if (dbPath !== ":memory:" && existsSync9(dbPath)) {
|
|
67876
68327
|
const stats = statSync3(dbPath);
|
|
67877
68328
|
const sizeKb = (stats.size / 1024).toFixed(1);
|
|
67878
68329
|
const sizeMb = (stats.size / (1024 * 1024)).toFixed(2);
|
|
@@ -68005,8 +68456,8 @@ function registerDoctorCommand(program2) {
|
|
|
68005
68456
|
checks.push({ name: "MCP server", status: "warn", detail: "could not check (is claude CLI installed?)" });
|
|
68006
68457
|
}
|
|
68007
68458
|
try {
|
|
68008
|
-
const settingsFilePath =
|
|
68009
|
-
if (
|
|
68459
|
+
const settingsFilePath = join13(homedir6(), ".claude", "settings.json");
|
|
68460
|
+
if (existsSync9(settingsFilePath)) {
|
|
68010
68461
|
const settings = JSON.parse(readFileSync7(settingsFilePath, "utf-8"));
|
|
68011
68462
|
const hooksObj = settings["hooks"] || {};
|
|
68012
68463
|
const stopHooks = hooksObj["Stop"] || [];
|
|
@@ -68023,11 +68474,11 @@ function registerDoctorCommand(program2) {
|
|
|
68023
68474
|
checks.push({ name: "Stop hook", status: "warn", detail: "could not check stop hook" });
|
|
68024
68475
|
}
|
|
68025
68476
|
if (process.platform === "darwin") {
|
|
68026
|
-
const plistFilePath =
|
|
68477
|
+
const plistFilePath = join13(homedir6(), "Library", "LaunchAgents", "com.hasna.mementos.plist");
|
|
68027
68478
|
checks.push({
|
|
68028
68479
|
name: "Auto-start",
|
|
68029
|
-
status:
|
|
68030
|
-
detail:
|
|
68480
|
+
status: existsSync9(plistFilePath) ? "ok" : "warn",
|
|
68481
|
+
detail: existsSync9(plistFilePath) ? "configured (starts on login)" : "not configured \u2192 run: mementos init"
|
|
68031
68482
|
});
|
|
68032
68483
|
} else {
|
|
68033
68484
|
checks.push({ name: "Auto-start", status: "ok", detail: `n/a on ${process.platform}` });
|
|
@@ -68106,8 +68557,8 @@ async function runCloudDoctor(globalOpts, checks) {
|
|
|
68106
68557
|
checks.push({ name: "MCP server", status: "warn", detail: "could not check (is claude CLI installed?)" });
|
|
68107
68558
|
}
|
|
68108
68559
|
try {
|
|
68109
|
-
const settingsFilePath =
|
|
68110
|
-
if (
|
|
68560
|
+
const settingsFilePath = join13(homedir6(), ".claude", "settings.json");
|
|
68561
|
+
if (existsSync9(settingsFilePath)) {
|
|
68111
68562
|
const settings = JSON.parse(readFileSync7(settingsFilePath, "utf-8"));
|
|
68112
68563
|
const hooksObj = settings["hooks"] || {};
|
|
68113
68564
|
const stopHooks = hooksObj["Stop"] || [];
|
|
@@ -68124,11 +68575,11 @@ async function runCloudDoctor(globalOpts, checks) {
|
|
|
68124
68575
|
checks.push({ name: "Stop hook", status: "warn", detail: "could not check stop hook" });
|
|
68125
68576
|
}
|
|
68126
68577
|
if (process.platform === "darwin") {
|
|
68127
|
-
const plistFilePath =
|
|
68578
|
+
const plistFilePath = join13(homedir6(), "Library", "LaunchAgents", "com.hasna.mementos.plist");
|
|
68128
68579
|
checks.push({
|
|
68129
68580
|
name: "Auto-start",
|
|
68130
|
-
status:
|
|
68131
|
-
detail:
|
|
68581
|
+
status: existsSync9(plistFilePath) ? "ok" : "warn",
|
|
68582
|
+
detail: existsSync9(plistFilePath) ? "configured (starts on login)" : "not configured \u2192 run: mementos init"
|
|
68132
68583
|
});
|
|
68133
68584
|
} else {
|
|
68134
68585
|
checks.push({ name: "Auto-start", status: "ok", detail: `n/a on ${process.platform}` });
|
|
@@ -68183,7 +68634,7 @@ function registerConfigCommand(program2) {
|
|
|
68183
68634
|
return;
|
|
68184
68635
|
}
|
|
68185
68636
|
if (subcommand === "path") {
|
|
68186
|
-
const p =
|
|
68637
|
+
const p = getConfigPath2();
|
|
68187
68638
|
if (useJson) {
|
|
68188
68639
|
outputJson({ path: p });
|
|
68189
68640
|
} else {
|
|
@@ -68252,7 +68703,7 @@ function registerConfigCommand(program2) {
|
|
|
68252
68703
|
console.log(chalk28.green(`Reset ${key} to default (${JSON.stringify(defaultVal)})`));
|
|
68253
68704
|
}
|
|
68254
68705
|
} else {
|
|
68255
|
-
const configPath =
|
|
68706
|
+
const configPath = getConfigPath2();
|
|
68256
68707
|
const { unlinkSync: unlinkSync3, existsSync: _existsSync } = __require("fs");
|
|
68257
68708
|
if (_existsSync(configPath)) {
|
|
68258
68709
|
unlinkSync3(configPath);
|
|
@@ -68276,6 +68727,8 @@ function registerConfigCommand(program2) {
|
|
|
68276
68727
|
|
|
68277
68728
|
// src/cli/commands/system-profile.ts
|
|
68278
68729
|
import chalk29 from "chalk";
|
|
68730
|
+
import { join as join14 } from "path";
|
|
68731
|
+
init_paths();
|
|
68279
68732
|
init_helpers();
|
|
68280
68733
|
function registerProfileCommand(program2) {
|
|
68281
68734
|
const profileCmd = program2.command("profile").description("Manage named profile files and active-profile metadata");
|
|
@@ -68306,7 +68759,7 @@ function registerProfileCommand(program2) {
|
|
|
68306
68759
|
if (active) {
|
|
68307
68760
|
console.log(chalk29.green(`Active profile: ${active}`));
|
|
68308
68761
|
if (!process.env["MEMENTOS_PROFILE"]) {
|
|
68309
|
-
console.log(chalk29.dim(
|
|
68762
|
+
console.log(chalk29.dim(`(persisted in ${join14(getDataRoot(), "config.json")})`));
|
|
68310
68763
|
} else {
|
|
68311
68764
|
console.log(chalk29.dim("(from MEMENTOS_PROFILE env var)"));
|
|
68312
68765
|
}
|
|
@@ -68322,7 +68775,7 @@ function registerProfileCommand(program2) {
|
|
|
68322
68775
|
}
|
|
68323
68776
|
setActiveProfile(clean);
|
|
68324
68777
|
console.log(chalk29.green(`\u2713 Active-profile metadata set: ${clean}`));
|
|
68325
|
-
console.log(chalk29.dim(` Profile file:
|
|
68778
|
+
console.log(chalk29.dim(` Profile file: ${join14(getDataRoot(), "profiles", `${clean}.db`)}`));
|
|
68326
68779
|
console.log(chalk29.dim(" Run `mementos storage mode` to verify the live runtime database."));
|
|
68327
68780
|
});
|
|
68328
68781
|
profileCmd.command("unset").description("Clear the active-profile metadata").action(() => {
|
|
@@ -68343,8 +68796,8 @@ function registerProfileCommand(program2) {
|
|
|
68343
68796
|
process.exit(1);
|
|
68344
68797
|
}
|
|
68345
68798
|
process.stdout.write(chalk29.yellow(`Delete profile "${name}" and its DB? This cannot be undone. [y/N] `));
|
|
68346
|
-
const answer = await new Promise((
|
|
68347
|
-
process.stdin.once("data", (d) =>
|
|
68799
|
+
const answer = await new Promise((resolve19) => {
|
|
68800
|
+
process.stdin.once("data", (d) => resolve19(d.toString().trim().toLowerCase()));
|
|
68348
68801
|
});
|
|
68349
68802
|
if (answer !== "y" && answer !== "yes") {
|
|
68350
68803
|
console.log(chalk29.dim("Cancelled."));
|
|
@@ -68572,7 +69025,7 @@ By type:`));
|
|
|
68572
69025
|
webhooksCmd.command("create <type> <url>").description("Create a persistent webhook hook").option("--blocking", "Block the operation until the webhook responds").option("--priority <n>", "Hook priority (default 50)", "50").option("--agent <id>", "Scope to specific agent").option("--project <id>", "Scope to specific project").option("--description <text>", "Human-readable description").action(async (type, url, opts) => {
|
|
68573
69026
|
const { createWebhookHook: createWebhookHook2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
68574
69027
|
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
68575
|
-
const wh = createWebhookHook2({
|
|
69028
|
+
const wh = await createWebhookHook2({
|
|
68576
69029
|
type,
|
|
68577
69030
|
handlerUrl: url,
|
|
68578
69031
|
blocking: opts.blocking ?? false,
|
|
@@ -68581,7 +69034,7 @@ By type:`));
|
|
|
68581
69034
|
projectId: opts.project,
|
|
68582
69035
|
description: opts.description
|
|
68583
69036
|
});
|
|
68584
|
-
reloadWebhooks2();
|
|
69037
|
+
await reloadWebhooks2();
|
|
68585
69038
|
console.log(chalk31.green("\u2713 Webhook created"));
|
|
68586
69039
|
console.log(` ID: ${chalk31.cyan(wh.id)}`);
|
|
68587
69040
|
console.log(` Type: ${wh.type}`);
|
|
@@ -68602,7 +69055,7 @@ By type:`));
|
|
|
68602
69055
|
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
68603
69056
|
const updated = updateWebhookHook2(id, { enabled: true });
|
|
68604
69057
|
if (updated) {
|
|
68605
|
-
reloadWebhooks2();
|
|
69058
|
+
await reloadWebhooks2();
|
|
68606
69059
|
console.log(chalk31.green(`\u2713 Webhook ${id} enabled`));
|
|
68607
69060
|
} else {
|
|
68608
69061
|
console.error(chalk31.red(`Webhook not found: ${id}`));
|
|
@@ -68614,7 +69067,7 @@ By type:`));
|
|
|
68614
69067
|
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
68615
69068
|
const updated = updateWebhookHook2(id, { enabled: false });
|
|
68616
69069
|
if (updated) {
|
|
68617
|
-
reloadWebhooks2();
|
|
69070
|
+
await reloadWebhooks2();
|
|
68618
69071
|
console.log(chalk31.yellow(`\u2298 Webhook ${id} disabled`));
|
|
68619
69072
|
} else {
|
|
68620
69073
|
console.error(chalk31.red(`Webhook not found: ${id}`));
|
|
@@ -68865,7 +69318,7 @@ function registerToolsCommand(program2) {
|
|
|
68865
69318
|
// src/cli/commands/system-synthesized-profile.ts
|
|
68866
69319
|
init_helpers();
|
|
68867
69320
|
import chalk35 from "chalk";
|
|
68868
|
-
import { resolve as
|
|
69321
|
+
import { resolve as resolve19 } from "path";
|
|
68869
69322
|
function registerSynthesizedProfileCommand(program2) {
|
|
68870
69323
|
const handleError = makeHandleError(program2);
|
|
68871
69324
|
program2.command("synthesized-profile").description("Show or refresh the synthesized agent/project profile").option("--project-id <id>", "Project ID").option("--refresh", "Force refresh the profile (re-synthesize from memories)").action(async (opts) => {
|
|
@@ -68875,7 +69328,7 @@ function registerSynthesizedProfileCommand(program2) {
|
|
|
68875
69328
|
let projectId = opts.projectId;
|
|
68876
69329
|
if (!projectId && globalOpts.project) {
|
|
68877
69330
|
const { getProject: getProject2 } = (init_projects(), __toCommonJS(exports_projects));
|
|
68878
|
-
const project = getProject2(
|
|
69331
|
+
const project = getProject2(resolve19(globalOpts.project));
|
|
68879
69332
|
if (project)
|
|
68880
69333
|
projectId = project.id;
|
|
68881
69334
|
}
|
|
@@ -69060,7 +69513,7 @@ function registerMiscCommands(program2) {
|
|
|
69060
69513
|
connStr = opts.connectionString;
|
|
69061
69514
|
} else {
|
|
69062
69515
|
try {
|
|
69063
|
-
connStr =
|
|
69516
|
+
connStr = getStorageConnectionStringForOperator("mementos");
|
|
69064
69517
|
} catch {
|
|
69065
69518
|
const msg = "Remote storage database is not configured. Use --connection-string or set HASNA_MEMENTOS_DATABASE_URL.";
|
|
69066
69519
|
if (useJson) {
|
|
@@ -69235,7 +69688,7 @@ args = []
|
|
|
69235
69688
|
init_memories();
|
|
69236
69689
|
init_helpers();
|
|
69237
69690
|
import chalk39 from "chalk";
|
|
69238
|
-
import { resolve as
|
|
69691
|
+
import { resolve as resolve20 } from "path";
|
|
69239
69692
|
function registerWatchCommand(program2) {
|
|
69240
69693
|
const handleError = makeHandleError(program2);
|
|
69241
69694
|
program2.command("watch").description("Watch for new and changed memories in real-time").option("--scope <scope>", "Scope filter: global, shared, private, working").option("-c, --category <cat>", "Category filter: preference, fact, knowledge, history, procedural, resource").option("--agent <name>", "Agent filter").option("--project <path>", "Project filter").option("--interval <ms>", "Poll interval in milliseconds", parseInt).action((opts) => {
|
|
@@ -69246,7 +69699,7 @@ function registerWatchCommand(program2) {
|
|
|
69246
69699
|
let projectId;
|
|
69247
69700
|
if (projectPath) {
|
|
69248
69701
|
const { getProject: getProject2 } = (init_projects(), __toCommonJS(exports_projects));
|
|
69249
|
-
const project = getProject2(
|
|
69702
|
+
const project = getProject2(resolve20(projectPath));
|
|
69250
69703
|
if (project)
|
|
69251
69704
|
projectId = project.id;
|
|
69252
69705
|
}
|
|
@@ -69802,7 +70255,7 @@ function resolveCurrentMachineId(local, requested) {
|
|
|
69802
70255
|
function runStorageSync(direction, options = {}) {
|
|
69803
70256
|
const backend = getStorageBackend();
|
|
69804
70257
|
if (backend === "sqlite" && !options.remote) {
|
|
69805
|
-
throw new Error(
|
|
70258
|
+
throw new Error(`Remote storage is not configured. Set HASNA_MEMENTOS_DATABASE_URL or configure ${getConfigPath()}.`);
|
|
69806
70259
|
}
|
|
69807
70260
|
return withManagedAdapters(options, (local, remote, currentMachineId) => {
|
|
69808
70261
|
const tables = resolveTables(local, options.tables);
|
|
@@ -70066,7 +70519,7 @@ function installStorageSubcommands(storage, program2) {
|
|
|
70066
70519
|
}
|
|
70067
70520
|
return;
|
|
70068
70521
|
}
|
|
70069
|
-
const connectionString = opts.connectionString ||
|
|
70522
|
+
const connectionString = opts.connectionString || getStorageConnectionStringForOperator("mementos");
|
|
70070
70523
|
const result = await applyPgMigrations2(connectionString);
|
|
70071
70524
|
if (useJson) {
|
|
70072
70525
|
outputJson2(true, result);
|
|
@@ -70132,17 +70585,17 @@ import chalk41 from "chalk";
|
|
|
70132
70585
|
import {
|
|
70133
70586
|
readFileSync as readFileSync8,
|
|
70134
70587
|
writeFileSync as writeFileSync4,
|
|
70135
|
-
existsSync as
|
|
70588
|
+
existsSync as existsSync11,
|
|
70136
70589
|
copyFileSync as copyFileSync3,
|
|
70137
70590
|
mkdirSync as mkdirSync6
|
|
70138
70591
|
} from "fs";
|
|
70139
|
-
import { dirname as dirname7, join as
|
|
70140
|
-
import { homedir as
|
|
70592
|
+
import { dirname as dirname7, join as join16 } from "path";
|
|
70593
|
+
import { homedir as homedir7 } from "os";
|
|
70141
70594
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
70142
70595
|
function registerInitCommand(program2) {
|
|
70143
70596
|
program2.command("init").description("One-command setup: register MCP, install stop hook, configure auto-start").action(async () => {
|
|
70144
70597
|
const { platform: platform2 } = process;
|
|
70145
|
-
const home =
|
|
70598
|
+
const home = homedir7();
|
|
70146
70599
|
const isMac = platform2 === "darwin";
|
|
70147
70600
|
console.log("");
|
|
70148
70601
|
console.log(chalk41.bold(" mementos \u2014 setting up your memory layer"));
|
|
@@ -70197,15 +70650,15 @@ function registerInitCommand(program2) {
|
|
|
70197
70650
|
} else {
|
|
70198
70651
|
console.log(chalk41.green(" \u2713 MCP server registered with Claude Code"));
|
|
70199
70652
|
}
|
|
70200
|
-
const hooksDir =
|
|
70201
|
-
const hookDest =
|
|
70202
|
-
const settingsPath =
|
|
70653
|
+
const hooksDir = join16(home, ".claude", "hooks");
|
|
70654
|
+
const hookDest = join16(hooksDir, "mementos-stop-hook.ts");
|
|
70655
|
+
const settingsPath = join16(home, ".claude", "settings.json");
|
|
70203
70656
|
const hookCommand = `bun ${hookDest}`;
|
|
70204
70657
|
let hookAlreadyInstalled = false;
|
|
70205
70658
|
let hookError = null;
|
|
70206
70659
|
try {
|
|
70207
70660
|
let settings = {};
|
|
70208
|
-
if (
|
|
70661
|
+
if (existsSync11(settingsPath)) {
|
|
70209
70662
|
try {
|
|
70210
70663
|
settings = JSON.parse(readFileSync8(settingsPath, "utf-8"));
|
|
70211
70664
|
} catch {
|
|
@@ -70218,19 +70671,19 @@ function registerInitCommand(program2) {
|
|
|
70218
70671
|
if (alreadyHasMementos) {
|
|
70219
70672
|
hookAlreadyInstalled = true;
|
|
70220
70673
|
} else {
|
|
70221
|
-
if (!
|
|
70674
|
+
if (!existsSync11(hooksDir)) {
|
|
70222
70675
|
mkdirSync6(hooksDir, { recursive: true });
|
|
70223
70676
|
}
|
|
70224
|
-
if (!
|
|
70677
|
+
if (!existsSync11(hookDest)) {
|
|
70225
70678
|
const packageDir = dirname7(dirname7(fileURLToPath4(import.meta.url)));
|
|
70226
70679
|
const candidatePaths = [
|
|
70227
|
-
|
|
70228
|
-
|
|
70229
|
-
|
|
70680
|
+
join16(packageDir, "scripts", "hooks", "claude-stop-hook.ts"),
|
|
70681
|
+
join16(packageDir, "..", "scripts", "hooks", "claude-stop-hook.ts"),
|
|
70682
|
+
join16(home, ".bun", "install", "global", "node_modules", "@hasna", "mementos", "scripts", "hooks", "claude-stop-hook.ts")
|
|
70230
70683
|
];
|
|
70231
70684
|
let hookSourceFound = false;
|
|
70232
70685
|
for (const src of candidatePaths) {
|
|
70233
|
-
if (
|
|
70686
|
+
if (existsSync11(src)) {
|
|
70234
70687
|
copyFileSync3(src, hookDest);
|
|
70235
70688
|
hookSourceFound = true;
|
|
70236
70689
|
break;
|
|
@@ -70296,7 +70749,7 @@ main().catch(() => {});
|
|
|
70296
70749
|
if (!isMac) {
|
|
70297
70750
|
console.log(chalk41.dim(` \xB7 Auto-start skipped (not macOS \u2014 platform: ${platform2})`));
|
|
70298
70751
|
} else {
|
|
70299
|
-
const plistPath =
|
|
70752
|
+
const plistPath = join16(home, "Library", "LaunchAgents", "com.hasna.mementos.plist");
|
|
70300
70753
|
const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
70301
70754
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
70302
70755
|
<plist version="1.0">
|
|
@@ -70321,11 +70774,11 @@ main().catch(() => {});
|
|
|
70321
70774
|
</plist>
|
|
70322
70775
|
`;
|
|
70323
70776
|
try {
|
|
70324
|
-
if (
|
|
70777
|
+
if (existsSync11(plistPath)) {
|
|
70325
70778
|
autoStartAlreadyInstalled = true;
|
|
70326
70779
|
} else {
|
|
70327
|
-
const launchAgentsDir =
|
|
70328
|
-
if (!
|
|
70780
|
+
const launchAgentsDir = join16(home, "Library", "LaunchAgents");
|
|
70781
|
+
if (!existsSync11(launchAgentsDir)) {
|
|
70329
70782
|
mkdirSync6(launchAgentsDir, { recursive: true });
|
|
70330
70783
|
}
|
|
70331
70784
|
writeFileSync4(plistPath, plistContent, "utf-8");
|
|
@@ -70341,7 +70794,7 @@ main().catch(() => {});
|
|
|
70341
70794
|
console.log(chalk41.green(" \u2713 Auto-start configured (starts on login)"));
|
|
70342
70795
|
}
|
|
70343
70796
|
if (!autoStartAlreadyInstalled && !autoStartError) {
|
|
70344
|
-
const plistPath2 =
|
|
70797
|
+
const plistPath2 = join16(home, "Library", "LaunchAgents", "com.hasna.mementos.plist");
|
|
70345
70798
|
const loadResult = await run(["launchctl", "load", plistPath2]);
|
|
70346
70799
|
if (!loadResult.ok) {
|
|
70347
70800
|
console.log(chalk41.dim(` \xB7 launchctl load: ${loadResult.output || "already loaded"}`));
|
|
@@ -70376,7 +70829,7 @@ main().catch(() => {});
|
|
|
70376
70829
|
init_agents();
|
|
70377
70830
|
init_projects();
|
|
70378
70831
|
import chalk42 from "chalk";
|
|
70379
|
-
import { resolve as
|
|
70832
|
+
import { resolve as resolve22 } from "path";
|
|
70380
70833
|
|
|
70381
70834
|
// src/lib/consolidation.ts
|
|
70382
70835
|
init_database();
|
|
@@ -71219,7 +71672,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
71219
71672
|
const key = process.env["ANTHROPIC_API_KEY"];
|
|
71220
71673
|
if (!key)
|
|
71221
71674
|
return null;
|
|
71222
|
-
const mod = await Promise.resolve().then(() => (
|
|
71675
|
+
const mod = await Promise.resolve().then(() => (init_dist5(), exports_dist));
|
|
71223
71676
|
const anthropic2 = mod["anthropic"];
|
|
71224
71677
|
return anthropic2 ? anthropic2(model) : null;
|
|
71225
71678
|
}
|
|
@@ -71227,7 +71680,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
71227
71680
|
const key = process.env["OPENAI_API_KEY"];
|
|
71228
71681
|
if (!key)
|
|
71229
71682
|
return null;
|
|
71230
|
-
const mod = await Promise.resolve().then(() => (
|
|
71683
|
+
const mod = await Promise.resolve().then(() => (init_dist6(), exports_dist2));
|
|
71231
71684
|
const openai2 = mod["openai"];
|
|
71232
71685
|
return openai2 ? openai2(model) : null;
|
|
71233
71686
|
}
|
|
@@ -71236,7 +71689,7 @@ async function resolveAISDKModel(provider, model) {
|
|
|
71236
71689
|
if (!apiKey)
|
|
71237
71690
|
return null;
|
|
71238
71691
|
const baseURL = provider === "cerebras" ? "https://api.cerebras.ai/v1" : "https://api.x.ai/v1";
|
|
71239
|
-
const mod = await Promise.resolve().then(() => (
|
|
71692
|
+
const mod = await Promise.resolve().then(() => (init_dist7(), exports_dist3));
|
|
71240
71693
|
const createOpenAICompatible2 = mod["createOpenAICompatible"];
|
|
71241
71694
|
if (!createOpenAICompatible2)
|
|
71242
71695
|
return null;
|
|
@@ -71252,7 +71705,7 @@ function createAISDKReflectionCritic(options = {}) {
|
|
|
71252
71705
|
if (!resolvedModel)
|
|
71253
71706
|
return heuristicReflectionCritic(trajectory);
|
|
71254
71707
|
try {
|
|
71255
|
-
const ai = await Promise.resolve().then(() => (
|
|
71708
|
+
const ai = await Promise.resolve().then(() => (init_dist9(), exports_dist4));
|
|
71256
71709
|
const generateObject2 = ai["generateObject"];
|
|
71257
71710
|
if (!generateObject2)
|
|
71258
71711
|
return heuristicReflectionCritic(trajectory);
|
|
@@ -71364,7 +71817,7 @@ function resolveAgentId(nameOrId) {
|
|
|
71364
71817
|
function resolveProjectId(pathOrId) {
|
|
71365
71818
|
if (!pathOrId)
|
|
71366
71819
|
return;
|
|
71367
|
-
return getProject(
|
|
71820
|
+
return getProject(resolve22(pathOrId))?.id ?? getProject(pathOrId)?.id ?? pathOrId;
|
|
71368
71821
|
}
|
|
71369
71822
|
function registerConsolidationCommands(program2) {
|
|
71370
71823
|
program2.command("consolidate").description("Consolidate memories: dedup, promote, summarize, and soft-delete stale low-value entries").option("--dry-run", "Plan actions without mutating memories").option("--scope <scope>", "Scope to consolidate: global, shared, private").option("--project <idOrPath>", "Project ID, name, or path").option("--agent <nameOrId>", "Agent name or ID").option("--duplicate-threshold <n>", "Near-duplicate similarity threshold 0-1", parseNumber2).option("--stale-days <n>", "Minimum age for decay/forget candidates", parseNumber2).option("--decay-threshold <n>", "Maximum decay score for soft-delete candidates", parseNumber2).option("--limit <n>", "Maximum memories to analyze", parseNumber2).option("--format <fmt>", "Output format: compact, json").action(async (opts) => {
|
|
@@ -71455,13 +71908,12 @@ function lessonTagForCli(kind) {
|
|
|
71455
71908
|
|
|
71456
71909
|
// src/cli/brains.ts
|
|
71457
71910
|
import {
|
|
71458
|
-
existsSync as
|
|
71911
|
+
existsSync as existsSync13,
|
|
71459
71912
|
mkdirSync as mkdirSync8,
|
|
71460
71913
|
writeFileSync as writeFileSync6,
|
|
71461
71914
|
readdirSync as readdirSync4
|
|
71462
71915
|
} from "fs";
|
|
71463
|
-
import {
|
|
71464
|
-
import { join as join13 } from "path";
|
|
71916
|
+
import { join as join18 } from "path";
|
|
71465
71917
|
import chalk43 from "chalk";
|
|
71466
71918
|
|
|
71467
71919
|
// src/lib/gatherer.ts
|
|
@@ -71537,15 +71989,18 @@ var gatherTrainingData = async (options = {}) => {
|
|
|
71537
71989
|
};
|
|
71538
71990
|
};
|
|
71539
71991
|
|
|
71992
|
+
// src/cli/brains.ts
|
|
71993
|
+
init_paths();
|
|
71994
|
+
|
|
71540
71995
|
// src/lib/model-config.ts
|
|
71541
|
-
|
|
71542
|
-
import {
|
|
71543
|
-
import { join as
|
|
71996
|
+
init_paths();
|
|
71997
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
|
|
71998
|
+
import { join as join17 } from "path";
|
|
71544
71999
|
var DEFAULT_MODEL = "gpt-4o-mini";
|
|
71545
|
-
var CONFIG_DIR =
|
|
71546
|
-
var CONFIG_PATH =
|
|
72000
|
+
var CONFIG_DIR = getDataRoot();
|
|
72001
|
+
var CONFIG_PATH = join17(CONFIG_DIR, "config.json");
|
|
71547
72002
|
function readConfig() {
|
|
71548
|
-
if (!
|
|
72003
|
+
if (!existsSync12(CONFIG_PATH))
|
|
71549
72004
|
return {};
|
|
71550
72005
|
try {
|
|
71551
72006
|
const raw = readFileSync9(CONFIG_PATH, "utf-8");
|
|
@@ -71555,7 +72010,7 @@ function readConfig() {
|
|
|
71555
72010
|
}
|
|
71556
72011
|
}
|
|
71557
72012
|
function writeConfig(config2) {
|
|
71558
|
-
if (!
|
|
72013
|
+
if (!existsSync12(CONFIG_DIR)) {
|
|
71559
72014
|
mkdirSync7(CONFIG_DIR, { recursive: true });
|
|
71560
72015
|
}
|
|
71561
72016
|
writeFileSync5(CONFIG_PATH, JSON.stringify(config2, null, 2) + `
|
|
@@ -71589,7 +72044,7 @@ function printInfo(msg) {
|
|
|
71589
72044
|
function makeBrainsCommand() {
|
|
71590
72045
|
const brains = new Command("brains");
|
|
71591
72046
|
brains.description("Fine-tuned model training and management (via @hasna/brains)");
|
|
71592
|
-
brains.command("gather").description("Gather training data from memories and write to JSONL").option("--limit <n>", "Maximum number of examples to gather", parseInt).option("--since <date>", "Only include memories created since this date (ISO 8601)").option("--output <dir>", "Output directory (default:
|
|
72047
|
+
brains.command("gather").description("Gather training data from memories and write to JSONL").option("--limit <n>", "Maximum number of examples to gather", parseInt).option("--since <date>", "Only include memories created since this date (ISO 8601)").option("--output <dir>", "Output directory (default: the mementos training data dir)").option("--json", "Output result summary as JSON").action(async (opts) => {
|
|
71593
72048
|
try {
|
|
71594
72049
|
const since = opts.since ? new Date(opts.since) : undefined;
|
|
71595
72050
|
if (since && isNaN(since.getTime())) {
|
|
@@ -71603,12 +72058,12 @@ function makeBrainsCommand() {
|
|
|
71603
72058
|
limit: opts.limit,
|
|
71604
72059
|
since
|
|
71605
72060
|
});
|
|
71606
|
-
const outputDir = opts.output ??
|
|
71607
|
-
if (!
|
|
72061
|
+
const outputDir = opts.output ?? join18(getDataRoot(), "training");
|
|
72062
|
+
if (!existsSync13(outputDir)) {
|
|
71608
72063
|
mkdirSync8(outputDir, { recursive: true });
|
|
71609
72064
|
}
|
|
71610
72065
|
const timestamp2 = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
71611
|
-
const outputPath =
|
|
72066
|
+
const outputPath = join18(outputDir, `mementos-training-${timestamp2}.jsonl`);
|
|
71612
72067
|
const jsonl = result.examples.map((ex) => JSON.stringify(ex)).join(`
|
|
71613
72068
|
`);
|
|
71614
72069
|
writeFileSync6(outputPath, jsonl + `
|
|
@@ -71632,8 +72087,8 @@ function makeBrainsCommand() {
|
|
|
71632
72087
|
try {
|
|
71633
72088
|
let datasetPath = opts.dataset;
|
|
71634
72089
|
if (!datasetPath) {
|
|
71635
|
-
const trainingDir =
|
|
71636
|
-
if (!
|
|
72090
|
+
const trainingDir = join18(getDataRoot(), "training");
|
|
72091
|
+
if (!existsSync13(trainingDir)) {
|
|
71637
72092
|
printError("No training data found. Run `mementos brains gather` first.");
|
|
71638
72093
|
process.exit(1);
|
|
71639
72094
|
}
|
|
@@ -71643,9 +72098,9 @@ function makeBrainsCommand() {
|
|
|
71643
72098
|
printError("No JSONL training files found. Run `mementos brains gather` first.");
|
|
71644
72099
|
process.exit(1);
|
|
71645
72100
|
}
|
|
71646
|
-
datasetPath =
|
|
72101
|
+
datasetPath = join18(trainingDir, latestFile);
|
|
71647
72102
|
}
|
|
71648
|
-
if (!datasetPath || !
|
|
72103
|
+
if (!datasetPath || !existsSync13(datasetPath)) {
|
|
71649
72104
|
printError(`Dataset file not found: ${datasetPath ?? "(unresolved)"}`);
|
|
71650
72105
|
process.exit(1);
|
|
71651
72106
|
}
|
|
@@ -71771,7 +72226,7 @@ function registerAllCommands(program2) {
|
|
|
71771
72226
|
// src/cli/index.tsx
|
|
71772
72227
|
function getPackageVersion2() {
|
|
71773
72228
|
try {
|
|
71774
|
-
const pkgPath =
|
|
72229
|
+
const pkgPath = join19(dirname8(fileURLToPath5(import.meta.url)), "..", "..", "package.json");
|
|
71775
72230
|
const pkg = JSON.parse(readFileSync10(pkgPath, "utf-8"));
|
|
71776
72231
|
return pkg.version || "0.0.0";
|
|
71777
72232
|
} catch {
|