Line

You are reading the unreleased docs (next). See latest (v0.9)

ui/server/src/blockSettingsStore

per-project settings for the mechanical blocks (the PLAN_FLOWS): turn a block off for this project, and the default engine (Mechanical | AI) and default local model where the block supports one.

Cockpit server, next. Source: ui/server/src/blockSettingsStore.mjs.

Classes#

BlockSettingsError#

Defined in: ui/server/src/blockSettingsStore.mjs:40

Extends#

  • Error

Constructors#

Constructor

new BlockSettingsError(message, opts?): BlockSettingsError

Defined in: ui/server/src/blockSettingsStore.mjs:42

Parameters
message

string

opts?
code?

string

path?

string

status?

number = 400

Returns

BlockSettingsError

Overrides

Error.constructor

Properties#

code

code: string

Defined in: ui/server/src/blockSettingsStore.mjs:46

name

name: string

Defined in: ui/server/src/blockSettingsStore.mjs:44

Inherited from

Error.name

path

path: string

Defined in: ui/server/src/blockSettingsStore.mjs:47

status

status: number

Defined in: ui/server/src/blockSettingsStore.mjs:45

Variables#

ENGINES#

const ENGINES: readonly string[]

Defined in: ui/server/src/blockSettingsStore.mjs:34


MAX_MODEL_CHARS#

const MAX_MODEL_CHARS: 100 = 100

Defined in: ui/server/src/blockSettingsStore.mjs:36


MODEL_RE#

const MODEL_RE: RegExp

Defined in: ui/server/src/blockSettingsStore.mjs:38

An Ollama model name: qwen2.5-coder:7b, library/llama3:8b. Starts with a letter or digit (never -), no spaces.


SETTING_FIELDS#

const SETTING_FIELDS: readonly string[]

Defined in: ui/server/src/blockSettingsStore.mjs:35


SETTINGS_VERSION#

const SETTINGS_VERSION: 1 = 1

Defined in: ui/server/src/blockSettingsStore.mjs:33

Functions#

applyPatch()#

applyPatch(blocks, checked): object

Defined in: ui/server/src/blockSettingsStore.mjs:114

Apply a checked patch to the stored blocks. A null field is removed; an entry left empty is removed.

Parameters#

blocks

any

checked

any

Returns#

object


blockSettingsFile()#

blockSettingsFile(projectRoot, __namedParameters?): any

Defined in: ui/server/src/blockSettingsStore.mjs:160

Absolute file holding one project's block settings: <stateDir>/block-settings/<projectKey>.json.

Parameters#

projectRoot

any

__namedParameters?
stateDir?

string = ...

Returns#

any


blockSupport()#

blockSupport(flowId): object

Defined in: ui/server/src/blockSettingsStore.mjs:55

What a block can do, from the contract block (block-flows.mjs), never from a per-screen copy.

Parameters#

flowId

any

Returns#

object

ai

ai: any

mechanical

mechanical: any

offered

offered: boolean


checkBlockPatch()#

checkBlockPatch(flowId, patch, at?): Record<string, any>

Defined in: ui/server/src/blockSettingsStore.mjs:71

Check one block's patch and reduce it to the fields that differ from the defaults. null means "back to the default".

Parameters#

flowId

string

patch

unknown

{ enabled?, engine?, provider?, model? }

at?

string = ...

Dotted path used in errors.

Returns#

Record<string, any>

The normalised patch: a field set to null is to be removed.

Throws#


checkPatch()#

checkPatch(patch): object

Defined in: ui/server/src/blockSettingsStore.mjs:106

Check a whole patch, { '<flowId>': { ... } }, before anything is saved.

Parameters#

patch

any

Returns#

object


effectiveSettings()#

effectiveSettings(flowId, blocks?): object

Defined in: ui/server/src/blockSettingsStore.mjs:148

The effective settings of one block: what a screen shows and a step is prefilled from.

Parameters#

flowId

any

blocks?

Returns#

object

enabled

enabled: boolean

engine

engine: string

model

model: any

provider

provider: string


openBlockSettingsStore()#

openBlockSettingsStore(projectRoot, options?): object

Defined in: ui/server/src/blockSettingsStore.mjs:173

Open the settings for one project. No in-memory cache: the file on disk IS the store, so a second Cockpit process (or a restarted one) reads back exactly what was saved.

Parameters#

projectRoot

string

options?

State directory and clock (test seams).

now?

() => string = ...

stateDir?

string = ...

Returns#

file

file: any

read

read: () => { record: { blocks: { }; rev: number; updatedAt: any; version: number; }; unreadable: string; } | { record: { blocks: { }; rev: any; updatedAt: any; version: number; }; unreadable: any; }

{ record, unreadable }: a file that cannot be read is reported (and enforcement fails closed), not thrown.

Returns

{ record: { blocks: { }; rev: number; updatedAt: any; version: number; }; unreadable: string; } | { record: { blocks: { }; rev: any; updatedAt: any; version: number; }; unreadable: any; }

disabledFlows()

disabledFlows(): object

The blocks turned off for this project, for the plan check. unreadable is set when the file cannot be trusted.

Returns

object

flows

flows: string[]

unreadable

unreadable: any

update()

update(__namedParameters?): object

Apply a patch: { rev, blocks: { '<flowId>': { enabled?, engine?, provider?, model? } } }. The whole patch is checked first; on any refusal nothing is written. A file that cannot be read has no rev to conflict with, so a save replaces it (that is how a person recovers from a damaged file).

Parameters
__namedParameters?
Returns

object

blocks

blocks: object

Index Signature

[k: string]: any

rev

rev: any

updatedAt

updatedAt: string

version

version: number = SETTINGS_VERSION

Throws