All files / src/configuration types.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45          234x     234x                           234x                                            
/**
 * Configuration model of a caller: the account's durable settings and the overrides of
 * the current MCP session. Both only narrow what the operator's configuration allows.
 */
 
import { z } from 'zod';
 
/** A project or group the caller works in. */
export const WorkingScopeSchema = z
  .object({
    type: z.enum(['project', 'group']),
    path: z.string().min(1),
    /** Group scopes: whether projects of subgroups belong to the scope. */
    includeSubgroups: z.boolean(),
  })
  .strict();
export type WorkingScope = z.infer<typeof WorkingScopeSchema>;
 
/**
 * Settings of one account, kept across restarts and shared by the account's sessions.
 * Absent fields take the operator's configuration.
 */
export const AccountSettingsSchema = z
  .object({
    /** Built-in or local preset applied to every session of the account. */
    preset: z.string().min(1).optional(),
    /** Only read tools, on top of whatever the operator and the preset allow. */
    readOnly: z.boolean().optional(),
    /** Tool groups (feature keys such as `wiki`, `pipelines`) the account switched off. */
    disabledToolGroups: z.array(z.string().min(1)).optional(),
    /** Default working scope of new sessions. */
    scope: WorkingScopeSchema.optional(),
  })
  .strict();
export type AccountSettings = z.infer<typeof AccountSettingsSchema>;
 
/** Stored settings of an account with the version of the last write. */
export interface AccountSettingsRecord {
  accountKey: string;
  settings: AccountSettings;
  /** Starts at 1 and grows with every write; compare-and-set writes name it. */
  version: number;
  updatedAt: number;
}