import * as node_http from 'node:http'; import { IncomingMessage, ServerResponse } from 'node:http'; declare const STICKER_COLOR_NAMES: readonly ["slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"]; type StickerColorName = (typeof STICKER_COLOR_NAMES)[number]; declare const STICKER_FAMILIES: readonly ["padding", "margin", "border", "radius", "stack", "grid", "text", "color", "transform", "opacity"]; type StickerFamily = (typeof STICKER_FAMILIES)[number]; type StickerSubproperty = 'all' | 'x' | 'y' | 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' | 'vertical' | 'horizontal' | 'direction' | 'gap' | 'align' | 'justify' | 'rows' | 'columns' | 'size' | 'weight' | 'line-height' | 'letter-spacing' | 'text-align' | 'color' | 'translate' | 'scale' | 'rotate' | 'opacity' | 'mix-blend' | StickerColorName; type Provider = 'claude' | 'codex' | 'copilot' | 'omp'; /** Renderer-owned identity for a target that does not exist as a DOM node. */ type OpaqueTargetReference = { adapter: string; key: string; }; /** Local preview protocol. Peers never supply reducer actions or host authority. */ type PeerAction = { type: 'tokens'; family?: StickerFamily; subproperty?: StickerSubproperty; } | { type: 'inspect'; selector: string; target?: OpaqueTargetReference; properties?: string[]; plane?: 'own' | 'host'; } | { type: 'comment'; selector: string; target?: OpaqueTargetReference; text: string; } | { type: 'clear'; selector: string; kind: 'comment' | 'style' | 'all'; } | { type: 'style'; selector: string; property: string; value: string; } | { type: 'style'; selector: string; token: string; family?: StickerFamily; } | { type: 'attention'; selector: string | null; target?: OpaqueTargetReference; activity?: 'looking' | 'working'; } | { type: 'undo' | 'redo' | 'send' | 'rebase'; }; /** A capability for a person/agent. Keep out of URLs, logs, and peer snapshots. */ type ParticipantCredential = { participantId: string; token: string; }; /** Browser hosting is replaceable; this boundary owns only local agent enrollment. */ type ParticipantAgentView = { act(action: PeerAction): Promise; close(): Promise; }; type ParticipantAgentAdapter = (credential: ParticipantCredential) => Promise; type ImprintExplanationKind = 'intention' | 'principle' | 'pattern'; type ImprintExplanationState = 'emerging' | 'testing' | 'grounded' | 'challenged' | 'retired'; type ImprintScopeKind = 'project' | 'route' | 'component' | 'selector' | 'file'; type ImprintScope = { kind: ImprintScopeKind; values: string[]; }; /** A store-qualified address; abstraction level is intentionally not encoded. */ type ImprintExplanationRef = { storeId: string; explanationId: string; }; type ImprintEvidence = { id: string; kind: 'observation' | 'application' | 'confirmation' | 'correction' | 'exception' | 'rejection'; stance: 'supports' | 'challenges' | 'excepts'; summary: string; threadId: string; jobId: string; createdAt: string; }; type ImprintExplanation = { id: string; kind: ImprintExplanationKind; statement: string; rationale: string; scope: ImprintScope; state: ImprintExplanationState; createdAt: string; updatedAt: string; evidence: ImprintEvidence[]; supersededBy?: string; }; type ImprintConcrete = { id: string; modelPath: string; value: unknown; createdAt: string; updatedAt: string; }; type ImprintTopologyRelationType = 'expresses' | 'excepts'; /** * Historical relation names remain readable so append-only Imprint journals can * be replayed. New writers must use ImprintTopologyRelationType. */ type LegacyImprintRelationType = 'operationalizes' | 'refines' | 'supports' | 'contradicts' | 'instantiates' | 'supersedes'; type ImprintRelationType = ImprintTopologyRelationType | LegacyImprintRelationType; type ImprintRelation = { id: string; type: ImprintRelationType; /** The source explanation is always owned by this relation's store. */ fromId: string; /** Omitted for a target in this relation's owning store. */ toStoreId?: string; toId: string; rationale: string; createdAt: string; }; type QualifiedImprintRelation = Omit & { from: ImprintExplanationRef; to: ImprintExplanationRef; }; type ImprintGraph = { version: 1; projectId: string; createdAt: string; updatedAt: string; head: { sequence: number; hash: string | null; }; explanations: ImprintExplanation[]; concrete: ImprintConcrete[]; relations: ImprintRelation[]; }; type ImprintMutation = { op: 'add_explanation'; explanation: ImprintExplanation; } | { op: 'replace_explanation'; explanation: ImprintExplanation; } | { op: 'remove_explanation'; explanationId: string; } | { op: 'add_concrete'; concrete: ImprintConcrete; } | { op: 'remove_concrete'; concreteId: string; } | { op: 'add_evidence'; explanationId: string; evidence: ImprintEvidence; } | { op: 'revise_explanation'; explanationId: string; patch: Partial>; updatedAt: string; } | { op: 'add_relation'; relation: ImprintRelation; } | { op: 'remove_relation'; relationId: string; }; type ImprintTransaction = { version: 1; sequence: number; transactionId: string; projectId: string; committedAt: string; previousHash: string | null; hash: string; source: { kind: 'automatic' | 'grounding' | 'correction' | 'migration' | 'undo'; threadId: string; jobId: string; }; summary: string; mutations: ImprintMutation[]; inverseMutations: ImprintMutation[]; undoesTransactionId?: string; }; type ImprintSummaryKind = 'added' | 'strengthened' | 'refined' | 'challenged' | 'exception' | 'consolidated'; type ImprintThreadSummary = { transactionId: string; coalescedTransactionIds?: string[]; additionalObservationCount?: number; kind: ImprintSummaryKind; title: string; detail: string; changes: Array<{ explanationId: string; action: 'added' | 'revised' | 'supported' | 'challenged' | 'retired' | 'related'; statement: string; state: ImprintExplanationState; }>; grounding?: { explanationId: string; question: string; state: 'testing'; }; resolvedAction?: ImprintGroundingAction; }; type ImprintGroundingAction = 'yes' | 'this_time' | 'no'; type ImprintContext = { explanations: Array & { concrete: Array>; /** Internal canonical-memory address; omitted from model-facing prompts. */ memoryId?: string; storeId?: string; storeRoot?: string; readOnly?: boolean; }>; truncated: boolean; pendingGroundingExplanationIds?: string[]; correctionExplanationIds?: string[]; relations?: Array & { /** The store that owns the relation record. */ storeId?: string; readOnly?: boolean; /** Present for composed reads; local single-store callers retain fromId/toId. */ from?: ImprintExplanationRef; to?: ImprintExplanationRef; }>; /** Explicit target/reference language detected in the current request. */ retrievalIntent?: { target: string; reference: string; }; /** * Directly relevant rejected history. These are warnings, not active * explanations, and therefore cannot be cited as Imprint usage. */ historicalCaveats?: Array & { storeId?: string; storeRoot?: string; readOnly?: boolean; }>; unavailableStoreIds?: string[]; unavailableTopologyStoreIds?: string[]; }; type PopmeltOptions = { port?: number; projectRoot?: string; tempDir?: string; maxTurns?: number; maxBudgetUsd?: number; allowedTools?: string[]; claudePath?: string; copilotPath?: string; ompPath?: string; provider?: Provider; timeoutMs?: number; devOrigin?: string; /** Optional Chromium DevTools endpoint, e.g. http://127.0.0.1:9222. */ nativeCaptureUrl?: string; restartMode?: 'embedded' | 'detached'; /** Internal opt-in. Collaboration authority is independent of app revisions. */ participantSessions?: { /** Optional context metadata. Never used as a save, Send, or approval gate. */ sourceRevision?: () => Promise; agentAdapter?: ParticipantAgentAdapter; }; }; type PopmeltHandle = { port: number; projectId: string; storeId?: string; /** Trusted local launch/recovery only; never publish this capability in HTML. */ participantHost?: () => Promise; close: () => Promise; }; /** One disposable, local Chrome profile per agent. Never attaches to a user's browser. */ declare function managedParticipantBrowser(url: string): ParticipantAgentAdapter; /** Same-origin host continuity adapter. A private claim or existing host proof is * mandatory before issuing the HttpOnly recovery capability. Localhost is not proof. */ declare function createParticipantHostEntry(options: { projectRoot: string; projectId: string; origin: string; host: () => Promise; }): Promise<{ handler: (req: IncomingMessage, res: ServerResponse) => Promise; claimUrl: string; }>; /** Public, credential-free description stamped by the application's dev server. * The revision is context metadata (or `unversioned`), never sync/Send authority. */ type ParticipantBootstrapConfig = { version?: 1; url: string; projectId: string; revision: string; }; declare global { interface Window { __POPMELT_PARTICIPANTS__?: ParticipantBootstrapConfig; } } /** Dev-server boundary: identify the project and optional source context, and * keep host proof in a private local file, never in public bootstrap metadata. * The framework owns the bridge lifecycle. No source hashing is required. */ declare function createParticipantDevBootstrap(options: { projectRoot: string; origin: string; bridge: PopmeltHandle; sourceRevision?: () => Promise; }): Promise<{ hostEntry: (req: node_http.IncomingMessage, res: node_http.ServerResponse) => Promise; read(): Promise; }>; type ImprintManifest = { version: 1; topologyVersion?: 2; projectId: string; createdAt: string; updatedAt: string; head: { sequence: number; hash: string | null; }; }; type ImprintLoadResult = { graph: ImprintGraph; transactions: ImprintTransaction[]; recoveredTransactions: number; }; declare class ImprintStore { private readonly projectRoot; private readonly projectId; private readonly imprintDir; private readonly manifestPath; private readonly graphPath; private readonly journalDir; private writeChain; constructor(projectRoot: string, projectId: string); readHead(): Promise; private readManifest; private loadRaw; load(): Promise; migrateTopology(): Promise<{ migrated: boolean; relationMutations: number; }>; commit(input: { transactionId: string; committedAt: string; source: ImprintTransaction['source']; summary: string; mutations: ImprintMutation[]; undoesTransactionId?: string; }): Promise<{ graph: ImprintGraph; transaction: ImprintTransaction; }>; undo(transactionId: string, source: ImprintTransaction['source'], committedAt: string, undoTransactionId: string): Promise<{ graph: ImprintGraph; transaction: ImprintTransaction; }>; recover(): Promise; } type ProposedExplanationRef = Omit & { storeId?: string; }; type ProposedMutation = { op: 'add'; clientId?: string; kind: ImprintExplanationKind; statement: string; rationale: string; scope?: ImprintScope; rootReason?: string; } | { op: 'revise'; explanationId: string; statement?: string; rationale?: string; scope?: ImprintScope; reopenGrounding?: boolean; } | { op: 'evidence'; explanationId: string; stance: 'supports' | 'challenges' | 'excepts'; summary: string; } | { op: 'relation'; type: ImprintTopologyRelationType; from: ProposedExplanationRef; to: ProposedExplanationRef; rationale: string; } | { op: 'supersede'; explanationId: string; replacementId: string; reason: string; } | { op: 'bind_concrete'; explanationId: string; modelPath: string; rationale: string; } | { op: 'retire'; explanationId: string; reason: string; }; type ImprintNoopReason = 'application_only' | 'transient_state' | 'concrete_without_model_path' | 'duplicate' | 'insufficient_evidence' | 'task_specific_detail' | 'no_shared_understanding_change'; type ImprintMutationDraft = { decision: 'mutate'; summary: { kind: ImprintSummaryKind; title: string; detail: string; }; usedExplanationIds?: string[]; appliedExplanationIds: string[]; mutations: ProposedMutation[]; grounding?: { explanationId: string; question: string; }; }; type ImprintApplicationDraft = { decision: 'apply'; summary: { title: string; detail: string; }; usedExplanationIds?: string[]; appliedExplanationIds: string[]; grounding?: { explanationId: string; question: string; }; }; type ImprintRecognitionDraft = { decision: 'recognize'; explanationId: string; summary: { title: string; detail: string; }; }; type ImprintDraft = ImprintMutationDraft | ImprintApplicationDraft | ImprintRecognitionDraft | { decision: 'none'; reason: ImprintNoopReason; usedExplanationIds?: string[]; appliedExplanationIds?: string[]; duplicateOfExplanationId?: string; scopeComparison?: 'equivalent' | 'existing_broader'; }; type ImprintParseContext = { context?: ImprintContext; requestText?: string; applicationOccurred?: boolean; }; type ImprintCaptureInput = { threadId: string; jobId: string; occurredAt?: string; concreteModel?: Record | null; pendingGroundingExplanationIds?: string[]; applicationOccurred?: boolean; /** The only store this capture is authorized to mutate. */ storeId?: string; /** Surfaced mounted-store addresses available for qualified relation targets. */ context?: ImprintContext; }; declare function parseImprintDraft(responseText: string, parseContext?: ImprintParseContext): { draft?: ImprintDraft; visibleText: string; error?: string; }; declare function formatImprintPrompt(context: ImprintContext | undefined, options?: { requestText?: string; delivery?: 'bridge' | 'ambient'; }): string; declare class ImprintService { readonly store: ImprintStore; private readonly noopCounts; private readonly assessmentFailures; private contextualGraphCache?; constructor(projectRoot: string, projectId: string); recordNoop(reason: ImprintNoopReason): void; recordAssessmentFailure(state: 'missing' | 'invalid'): void; diagnostics(): { noopDecisions: Partial>; assessmentFailures: Partial>; }; private contextualGraph; explanationsByIds(ids: string[]): Promise; contextualize(input: { text?: string; subjectHints?: string[]; maxExplanations?: number; pendingGroundingExplanationIds?: string[]; correctionExplanationIds?: string[]; }): Promise; capture(draft: ImprintMutationDraft | ImprintApplicationDraft, input: ImprintCaptureInput): Promise; applyGroundingAction(input: { summary: ImprintThreadSummary; action: ImprintGroundingAction; threadId: string; jobId: string; occurredAt?: string; }): Promise<'applied' | 'pending_correction'>; } declare function imprintExplanationRef(storeId: string, explanationId: string): ImprintExplanationRef; declare function qualifyImprintRelation(storeId: string, relation: ImprintRelation): QualifiedImprintRelation; type StartPopmeltOptions = PopmeltOptions & { force?: boolean; detached?: boolean; /** Set false when another lifecycle owner, such as a Vite HTTP server, manages the lease. */ manageLease?: boolean; }; declare function startPopmelt(options?: StartPopmeltOptions): Promise; export { type ImprintConcrete, type ImprintContext, type ImprintEvidence, type ImprintExplanation, type ImprintExplanationKind, type ImprintExplanationRef, type ImprintExplanationState, type ImprintGraph, type ImprintGroundingAction, type ImprintMutation, type ImprintRelation, type ImprintRelationType, type ImprintScope, ImprintService, ImprintStore, type ImprintThreadSummary, type ImprintTransaction, type ParticipantAgentAdapter, type ParticipantAgentView, type PopmeltHandle, type PopmeltOptions, type QualifiedImprintRelation, type StartPopmeltOptions, createParticipantDevBootstrap, createParticipantHostEntry, formatImprintPrompt, imprintExplanationRef, managedParticipantBrowser, parseImprintDraft, qualifyImprintRelation, startPopmelt };