Skip to content

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

2.0 KB
Raw Blame
// SPDX-License-Identifier: Apache-2.0
//
// #2572 — wrong-runtime guard for the server operability CLI.
// #2554 — stale DEFAULT_MODEL fix.

import { describe, expect, it } from 'bun:test';
import { assertServerRuntimeForCli } from '../../src/server/runtime/ServerService.js';
import { DEFAULT_SERVER_CLAUDE_MODEL } from '../../src/server/generation/providers/ClaudeObservationProvider.js';

describe('assertServerRuntimeForCli — wrong-runtime guard (#2572)', () => {
  it('passes for canonical server runtime with a database URL', () => {
    expect(() =>
      assertServerRuntimeForCli('keys', {
        CLAUDE_MEM_RUNTIME: 'server',
        CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
      }),
    ).not.toThrow();
  });

  it('passes for legacy server-beta runtime literal (Phase 1d back-compat)', () => {
    expect(() =>
      assertServerRuntimeForCli('keys', {
        CLAUDE_MEM_RUNTIME: 'server-beta',
        CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
      }),
    ).not.toThrow();
  });

  it('passes when runtime is unset but a database URL is present (bare server image)', () => {
    expect(() =>
      assertServerRuntimeForCli('jobs', {
        CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
      }),
    ).not.toThrow();
  });

  it('fails CLEARLY when run in a worker-only runtime context', () => {
    expect(() =>
      assertServerRuntimeForCli('keys', {
        CLAUDE_MEM_RUNTIME: 'worker',
        CLAUDE_MEM_SERVER_DATABASE_URL: 'postgres://localhost/db',
      }),
    ).toThrow(/server runtime command.*CLAUDE_MEM_RUNTIME=worker/s);
  });

  it('fails CLEARLY (actionable) when no database URL is configured', () => {
    expect(() =>
      assertServerRuntimeForCli('jobs', { CLAUDE_MEM_RUNTIME: 'server' }),
    ).toThrow(/CLAUDE_MEM_SERVER_DATABASE_URL is required/);
  });
});

describe('Claude provider default model (#2554)', () => {
  it('uses an undated model alias', () => {
    expect(DEFAULT_SERVER_CLAUDE_MODEL).not.toMatch(/\d{8}/);
  });
});