feat(internal): add resolveConfig helper, use in supabase adapter

AM
5d ago
+184-3

Problem

The SupabaseMemoryAdapter hardcodes its defaults inline (options.tableName ?? "voltagent_memory", options.debug ?? false, and the logger name). There is no shared way to resolve default values against user options, so each adapter repeats the ?? pattern.

Change

  • @voltagent/internal: add resolveConfig(defaults, overrides) in src/config. It is exported through a new @voltagent/internal/config entry point. That entry point has its own package.json export and typesVersions entries, a tsup build target and a README mention.
    • The merge is shallow and returns a new object.
    • undefined and null overrides fall back to the default, the same as ??.
    • Falsy values (false, 0, "") are kept.
    • defaults is never mutated.
  • @voltagent/supabase: add SUPABASE_MEMORY_DEFAULTS in src/config.ts and use resolveConfig in the adapter constructor for tableName and debug. The default logger name now reads SUPABASE_MEMORY_DEFAULTS.loggerName. Behavior is unchanged: the defaults are still voltagent_memory, false and supabase-memory-v2.
  • Add a changeset: @voltagent/internal minor, @voltagent/supabase patch.

Tests

  • New packages/internal/src/config/config.spec.ts covers:
    • no overrides and null overrides
    • a defined override
    • undefined and null values
    • falsy values
    • no mutation of the defaults
    • a new object being returned
  • Extended packages/supabase/src/memory-adapter.spec.ts to cover:
    • the default and custom table name
    • the debug default and enabling it
    • the default logger being created with the expected name
    • no logger being created when one is provided

I did not run the tests or the build when writing this description.

Fixes #263

How this was validated

  • install: exit 0
  • build-supabase-deps: exit 0
  • lint: exit 0
  • publint-internal: exit 0
  • test-internal: exit 0
  • test-supabase: exit 0
  • internal-config-cjs: exit 0
  • internal-config-esm: exit 0

Validation run locally: 8/8 commands passed (install, build-supabase-deps, lint, publint-internal, test-internal, test-supabase, internal-config-cjs, internal-config-esm).

🤖 AI assistance disclosure: prepared with autonomous-oss-contributor; reviewed and approved by @Amsal1 before submission.

Summary by CodeRabbit

  • New Features
    • Added a reusable configuration resolver that applies provided values over defaults while preserving valid falsy values and leaving the original defaults unchanged.
    • Supabase memory adapters now use consistent defaults: the voltagent_memory table, debug logging off, and a default logger. You can still customize settings or provide your own logger.