Interfaces

Injection

Interface: Injection

Defined in: src/lib/injection-engine/types.ts:161

THE primitive. Five fields. Four trigger kinds. Three slot targets.

Every named flavor (Skill, Steering, Instruction, Context, RAG, Memory, Guardrail, …) is a sugar factory that produces one of these.

Example

// Direct construction (power user)
  const myInjection: Injection = {
    id: 'demo',
    flavor: 'instructions',
    trigger: { kind: 'rule', activeWhen: (ctx) => ctx.iteration > 1 },
    inject: { systemPrompt: 'Refine the previous answer.' },
  };

  // Sugar (recommended)
  const myInjection2 = defineInstruction({
    id: 'demo',
    activeWhen: (ctx) => ctx.iteration > 1,
    prompt: 'Refine the previous answer.',
  });

Properties

description?

readonly optional description?: string

Defined in: src/lib/injection-engine/types.ts:165

Human-readable description (Lens / docs / debug).


flavor

readonly flavor: ContextSource

Defined in: src/lib/injection-engine/types.ts:167

Observability tag. Drives Lens chip color + ContextRecorder source field.


id

readonly id: string

Defined in: src/lib/injection-engine/types.ts:163

Unique id. Used for observability + de-duplication + LLM-activation lookup.


inject

readonly inject: InjectionContent

Defined in: src/lib/injection-engine/types.ts:171

WHAT to contribute (one or more slots).


metadata?

readonly optional metadata?: Readonly<Record<string, unknown>>

Defined in: src/lib/injection-engine/types.ts:181

Optional flavor-specific metadata. Engine ignores keys it doesn't recognize; flavor factories use this for opt-in fields without widening the Injection contract.

Known keys:

  • surfaceMode (Skill) — 'auto' | 'system-prompt' | 'tool-only' | 'both'
  • refreshPolicy (Skill) — { afterTokens, via }

trigger

readonly trigger: InjectionTrigger

Defined in: src/lib/injection-engine/types.ts:169

WHEN to activate.

On this page