UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

485 lines • 35.6 kB
/* * agentfootprint — public barrel. * * Pattern: Facade (GoF) over the typed sublayers. * Role: Single entry point consumers import from. * Emits: N/A. * * A plain block comment, not TSDoc: nothing separates it from the first * export below, and TypeDoc would otherwise attach this text to the * re-exported footprintjs types as their documentation. */ // Adapter interfaces (ports) export * from './provider-contract/types.js'; // Injection keys + recorder authoring helpers — needed by anyone writing // a custom recorder that switches on injection events. export { INJECTION_KEYS, injectionKeyForSlot, isInjectionKey, // Renderer-facing: classifies a stage's importance (hero vs plumbing) so // visualisers (the lens, custom shells) can style the chart. Unlike the // slot/id helpers below, this IS consumer API — it exists to be consumed // by renderers. stageRole, // Renderer-facing: declares which stages are time-travel MILESTONES (scrub // stops) so the lens can build a stage-by-stage slider (iteration → llm-turn // → tool-call → decision) instead of stopping only on structural boundaries. // Consumer API — owned by the domain, consumed by renderers. milestoneFor, // Declared milestones (9.90.0): the charts put the SAME table on the stage as // footprintjs 9.21 tags — `milestone:<kind>` + `milestone-label:<label>` — // so a recording carries its own milestones and `milestoneFor` above is the // fallback for a bundle with no tags. One writer, one reader, no literal. MILESTONE_KINDS, MILESTONE_TAG_PREFIX, MILESTONE_LABEL_TAG_PREFIX, milestoneTag, milestoneTags, milestoneTagsFor, milestoneFromTags, // The reserved subflow namespace (9.49.0): the prefix the framework names its // own composition segments with, and the predicate downstream READERS use to // tell library plumbing from consumer structure — exported so a viewer or a // pattern miner imports the law instead of hardcoding 'sf-'. The refusal // itself (assertUnreservedSubflowSegment) stays internal: it belongs to the // declaration doors, not to consumers. RESERVED_SUBFLOW_PREFIX, isReservedSubflowSegment, } from './lib/conventions.js'; // The milestones ON the reader's cursor. `milestoneFor` above classifies ONE // stage id; this is that classifier mapped onto a finished run's commit log as // a footprintjs `TimeTravelStrategy`, so `timeTravel(snapshot, { strategy: // milestoneStopsStrategy })` scrubs iteration → llm-turn → tool-call → // decision instead of stopping on every stage. `milestoneOf(stop)` reads the // milestone back off a stop (footprintjs's `Stop` has no slot for a // consumer's own vocabulary). Fold: derived from the recorded log, never a // re-walk — see src/time-travel/README.md. export { milestoneOf, milestoneStops, milestoneStopsStrategy } from './time-travel/index.js'; // THE RECEIPT AT THE STOP (9.88.0). The wire a model receives is assembled from // committed pieces and is itself never committed — so `servedAt(snapshot, k)` // REBUILDS it from those pieces, and `receiptAt(snapshot, k)` reads the // hashes-and-references record the call left behind at the same stop. The law // they hold together is `receiptHash(runId, servedAt(k).system.text) === // receiptAt(k).system.hash`; whatever the log cannot rebuild is named in // `servedAt(k).gaps` rather than quietly missing. `epochAt` / `epochLocations` // are the one owner of where an iteration's pieces live in either chart shape. // `receiptAt` answers a `StoredReceipt` (9.94.1): the receipt AS STORED, by // the release that minted it — a container a later release added may be // absent, and a reader reads it as "cannot say", never as a throw. export { epochAt, epochLocations, keyedFold, messageDigestInput, toolDigestInput, receiptAt, receiptHash, servedAt, servedViews, transformHashOf, RECEIPT_BOUNDARY, TRANSFORM_HASH_PREFIX, SERVED_GAPS, UNGAPPED_FIELDS, } from './time-travel/index.js'; // `STAGE_IDS`, `SUBFLOW_IDS`, `isSlotSubflow`, `slotFromSubflowId`, // `isKnownStage`, `isKnownSubflow` are intentionally NOT exported — they // are the internal builder↔recorder coordination protocol, not consumer // API. Library code reaches them via the relative `./lib/conventions.js` // import; downstream code should never need them. export { COMPOSITION_KEYS, } from './recorders/core/types.js'; // Context-engineering + emit primitives. // // The observability recorder FACTORIES (ContextRecorder, streamRecorder, // agentRecorder, compositionRecorder, costRecorder, evalRecorder, // memoryRecorder, permissionRecorder, skillRecorder, toolsRecorder, // contextEvaluatedRecorder, boundaryRecorder, liveStateRecorder, the // RunStep* family, attachFlowchart/attachLogging/attachStatus, …) now live // ONLY under `agentfootprint/observe` — the dedicated observability subpath — // so the main barrel stays focused on the core agent API. export { contextEngineering, isEngineeredSource, isBaselineSource, ENGINEERED_SOURCES, BASELINE_SOURCES, } from './recorders/core/contextEngineering.js'; export { RunnerBase, makeRunId } from './core/RunnerBase.js'; // Pause/Resume primitives — consumer API for human-in-the-loop tools. // `PauseRequest` (the throwable signal class) stays internal; consumers // detect pauses via `isPauseRequest(err)` / `isPaused(outcome)`. // `askHuman` is the HITL-named alias for `pauseHere` — same behavior, // reads more naturally inside a tool that's asking a person to decide. export { pauseHere, askHuman, requestInput, isInputPause, isPauseRequest, isPaused, isCheckInPause, isAskPause, // 8.13.0 — a consent gate (a tool's `checkIn`, a middleware's `ask`) is // answered with a decision, never a value. `pauseDemandsDecision` is how a // consumer asks which kind of pause it is holding; `DecisionRequiredError` is // what `agent.resume()` raises when the answer is the wrong shape, instead of // the silent `by: 'unknown'` decline it filed before. pauseDemandsDecision, DecisionRequiredError, StaleDecisionError, // A decision for another request, for a call that changed after the ask, or // for a request already answered — refused by name, the tool never runs. ResumeDecisionError, // 8.18.0 — an askHuman/pauseHere pause resumed with NO value. The answer // becomes the tool's result, so "no answer" and "carry on" are two different // conversations and the caller picks; the library used to pick silently and // crash a turn later. PauseAnswerRequiredError, } from './core/pause.js'; export { InputRequestError } from './tools/inputRequest.js'; // Typed HITL (9.24.0) — the OPTIONAL component half of a human ask: WHICH // registered screen component collects the answer, with small `props` inline // and the big half as an artifact ref (`propsRef`) that rides the STORE, not // the checkpoint. Ids and props only, never markup — the registry lives in // the frontend (the no-eval law). Carried by `askHuman({ question, component })`, // a middleware `ask({ question, component })`, and a tool's // `checkInComponent`; surfaced to hosts on `PendingAsk.component`. The // decision returns through the SAME structured field it always did. // `readAskComponent` is the one reader of a pause payload's component (for // anyone building a host); `InvalidAskComponentError` is the raise-time // refusal — a dangling `propsRef` fails at its source, never on the screen. export { readAskComponent, assertAskComponent, InvalidAskComponentError, } from './tools/askComponent.js'; // The middleware family — a typed chain around every tool dispatch // (`.toolMiddleware()`) and around the message boundary // (`.messageMiddleware()`): the input before the model sees it, the output // before the caller receives it. // // Three verbs, and no fourth: `allow()` / `allow(value, why)`, `deny(reason)`, // `ask({ question })`. There is no way to return a RESULT — the union has no // arm for one — so whatever a chain decides, the answer the model finally // reads is the real tool's output or a refusal. A transform commits both the // original and the replacement, so a scrub is legible in the trace instead of // silently rewriting history. export { allow, ask, deny, MessageDeniedError, } from './core/agent/middleware/index.js'; // `.act({ input, beforeTool, afterTool, window, output })` — the five moments // of the loop in one block, and the canonical way to say what an agent does // about its own turn. Pure sugar over the five doors above and below; the keys // are locked at compile time against `LoopMoment`, so the bundle cannot fall // behind the loop. export { LOOP_MOMENTS, actKeyFor } from './lib/moments.js'; export { ACT_KEYS } from './core/agent/act.js'; // Check in with the receipts — evidence-carrying human consent. A tool // declares `checkIn` (see `defineTool`); when it trips the run pauses with a // `CheckInRequest` (the ask + evidence pack); a human answers with // `checkInApproved` / `checkInDeclined`; the `CheckInDecision` lands as a // typed record (`checkin.request` / `checkin.decision` events + `CheckInRecorder`). export { checkInApproved, checkInDeclined, isCheckInDecision, lexicalDriverScorer, standardEvidenceAssembler, minimalEvidenceAssembler, } from './core/checkin.js'; // A decision answers ONE request, once: every consent pause mints a request id // bound to the exact paused call, a decision names it, and a resume holds it // to it (`ResumeDecisionError`). The ledger is where answered requests are // spent — per agent by default, shared across agents via // `Agent.create({ decisionLedger })`. export { inMemoryDecisionLedger } from './core/consentRequest.js'; // The built-in check-in audit store — `agent.attach(new CheckInRecorder())`. export { CheckInRecorder, } from './recorders/core/CheckInRecorder.js'; // Commentary — bundled prose templates + engine for narrating a run. // Consumers ship their own JSON locale / brand voice via the same // shape; viewers (Lens, CLI tail, log file) consume this surface. export { defaultCommentaryTemplates, // Commentary engine helpers — advanced surface consumed by viewer // libraries (agentfootprint-lens) to render run narration. Not the // everyday API, but de-facto public: keep exported. extractAgentName, extractCommentaryVars, renderCommentary, selectCommentaryKey, } from './recorders/observability/commentary/commentaryTemplates.js'; // Status — chat-bubble surface (separate audience: the end user // chatting; renamed from "thinking" in 5.0.0 to disambiguate from the // MODEL's extended-thinking reasoning). State machine: // idle / streaming / tool / paused. Same contract shape as commentary // (`Record<string, string>` with `{{vars}}`, partial overrides // supported, missing keys ignored) but a different vocabulary — // first-person status, mid-call only. Per-tool keys (`tool.<toolName>`) // win over the generic `tool` key. // Primitives (core/) export { LLMCall, LLMCallBuilder, } from './core/LLMCall.js'; // Agent (ReAct) form of the merge-tree — Context root selector → two-stage // convergence: [sf-message-api (system-prompt+messages → messageAPI), sf-tools] // → Call-LLM → route → [tool-exec → loop] / final. tools + the loop are the // only additions over buildMessageApiChart. See buildAgentMessageApiChart. export { buildAgentMessageApiChart, } from './core/agent/buildAgentMessageApiChart.js'; // `Agent` and `AgentBuilder` come through the trace toolpack's host, which // plugs `.selfExplain()` into the builder's port at load — the registration // travels with the class, so a bundler that skips this barrel cannot drop it // (`trace-toolpack/selfExplainHost.ts` says why). export { Agent, AgentBuilder } from './trace-toolpack/selfExplainHost.js'; // `.window(strategy)` / `.compaction()` — keep the live context window inside // its budget without ever losing the record. A strategy edits the WINDOW; the // LEDGER keeps every removed turn byte-identical, and every strategy files its // own recorded step naming the runtimeStageIds whose messages left. // // Three ship, over one turn segmentation and one refusal engine: // summarizeOldest fold the oldest span into a summary (what `.compaction()` is) // slidingWindow keep the last N turns, drop older ones // tokenBudget counted-token trigger, drop instead of summarize // // A commit log lives as long as the process; a conversation lives longer. So // `.compaction({ retain })` carries the folded originals on the conversation // checkpoint too, and `foldedSpanFor(conversation, message)` is the door back // to them after a restart. export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, DROP_NOTICE_PREFIX, foldedMessages, foldedSpanFor, isCompactedSummary, isDropNotice, slidingWindow, summarizeOldest, tokenBudget, } from './core/agent/window/index.js'; // Which `role: 'user'` message a PERSON wrote (9.84.0), and the registry of // openings it is decided against. Seven messages in a window carry that role // without anybody having said them — a compaction frame, a drop notice, the two // in-loop corrections, the out-of-budget wrap-up instruction, the stepped-skill // nudge (the last two registered in 9.86.0), and a message an Injection // delivered. This is the one test that tells them apart; the window's refusal // engine and `saidByPerson(ctx)` on `agentfootprint/context` both call it, so // no reader can hold a different rule. Since G17 the registry also holds // the openings of the lines served on a REQUEST only — `LIBRARY_NOTE_OPENING` // (the time layer's late line, on every request under `.time()`, and the // figures dial's conclusion) and the staged-refs nudge — so a host finding // "this turn" in what the model was sent never anchors on the library's line. export { isLibraryAuthoredFrame, isSaidByPerson, LIBRARY_AUTHORED_PREFIXES, LIBRARY_NOTE_OPENING, } from './lib/saidByPerson.js'; // 9.11.0 — the opt-in tool-result ceiling (`AgentOptions.maxToolResultChars`). // The marker is what a consumer reads off `stream.tool_end.result` and off the // `role: 'tool'` message, so the shape AND the guard are public; the measuring // helper stays internal to dispatch. export { isTruncatedToolResult } from './core/agent/toolResultCap.js'; // The write-seam advisory (9.77.0) — `AgentOptions.noticeEmptyLookups`. The // CEILING is exported as a string because it is quoted verbatim into every // finding this check files: a consumer rendering findings can recognize the // bound instead of re-wording it, and the docs, the code and the tests all // read one owner. `LookupResultReading` is what the library could see of a // result — the vocabulary behind a `not-applicable` row. export { EMPTY_LOOKUP_CEILING } from './integrity/empty-lookup/check.js'; // The COLUMN-TYPE CONTRACT (9.78.0) — `Tool.resultColumns` + // `AgentOptions.checkColumnTypes`. The CEILING is exported for the same // reason `EMPTY_LOOKUP_CEILING` is: it is quoted verbatim into every finding, // so a consumer rendering findings recognizes the bound instead of re-wording // it, and the docs, the code and the tests read one owner. `RowsetReading` is // what the library could see of a result — the vocabulary behind a // `not-applicable` row. export { COLUMN_TYPE_CEILING, readRowset, } from './integrity/column-types/check.js'; // The declaration's own vocabulary, so an app assembling `Tool` objects by // hand (or typing a config) can name the words the library judges by. export { COLUMN_TYPES, assertResultColumns, } from './integrity/column-types/types.js'; // The claim seam's RECENCY advisory (9.83.0) — `AgentOptions. // noticePriorTurnEvidence` beside `.namesAndNumbersFromEvidence()`. The // CEILING is exported for the same reason the two above are: it is quoted // verbatim into every finding, so a consumer rendering findings recognizes // the bound instead of re-wording it, and the docs, the code and the tests // read one owner. `AnswerGroundingReading` is what the library could see of // an answer's grounding — the vocabulary behind an `unreachable` row. export { PRIOR_TURN_EVIDENCE_CEILING, } from './integrity/prior-turn-evidence/check.js'; export { OutputSchemaError, applyOutputSchema, } from './answer-validation/outputSchema.js'; // 9.101.0 — the findings ledger (`.findings()`): the row shapes // `agent.findings()` hands back and `AgentState.findingsLedger` / // `AgentRunCheckpoint.findingsLedger` carry, plus the reserved argument name // so a tool author can avoid it (a registry tool declaring it is refused at // build when the ledger is armed). The door itself is `AgentBuilder.findings`. export { RESERVED_ARGUMENT, } from './core/agent/findings/types.js'; // 9.105.0 — tool choice by classifier (`.toolChoice()`): the row shapes // `AgentState.toolChoices` carries (a pick before every model call, the // outcome after it), the reasons a narrowing was skipped, and the two // leaf constants — the question id a record reader looks for and the // framework's doors that are never narrowed away. The asker itself is // loaded lazily by the tools slot and is deliberately NOT a root export. export { ALWAYS_SERVED_TOOLS, TOOL_CHOICE_QUESTION, } from './core/agent/toolChoice/types.js'; // 8.18.0 — the input boundary every runner's `run()` goes through. A bare // string IS the message (`run('go')` ≡ `run({ message: 'go' })`); anything // that is not a message is refused by name before the run starts, instead of // becoming `content: undefined` inside the messages slot. export { InvalidRunInputError } from './core/runInput.js'; // 7.26 — the loop's side of the output contract. `OutputAttempt` is the row // shape `snapshot.sharedState.outputAttempts` carries; the frame prefix and // the tool name are exported so a reader (or a test) can recognise the two // things this feature puts into a conversation without matching on prose. export { SCHEMA_CHECK_FRAME_PREFIX, SCHEMA_TOOL_NAME, isSchemaCheckMessage, } from './core/agent/outputEnforcement.js'; // 9.35.0 — the evidence gate (`.namesAndNumbersFromEvidence()`). Every name // and number in the final answer must appear in a tool result the run really // read; one that does not was typed rather than read. It is a FABRICATION // detector, not a correctness judge — it cannot see a false claim built out of // real values — and it is deterministic on purpose: a guard that needed a // bigger model to police a smaller one would invert this library's thesis. // The frame prefix is exported so a reader (or a test) can recognise the // correction this feature puts into a conversation without matching on prose. export { EVIDENCE_CHECK_FRAME_PREFIX, } from './core/agent/evidence/index.js'; export { UnsupportedValuesError, } from './core/agent/evidence/errors.js'; export { canResume, ConversationMismatchError, RunCheckpointError, } from './core/runCheckpoint.js'; // 9.10.0 — the CLIENT half of a hosting session: one line in a page that mints // a session id, keeps it, and hands it back. Exported from the ROOT rather than // from `agentfootprint/hosting` on purpose — the rest of that door is Node // (`node:http`, `node:sqlite`) and a browser bundle must not have to reach // through it. The server half is `nodeHost({ sessionHeader | sessionCookie })`. export { browserSessionId, DEFAULT_SESSION_STORAGE_KEY, } from './hosting/browserSession.js'; // 9.6.0 — "the request did not fit" as a typed error the adapters translate // from every vendor's wording, carrying the numbers and the fixes. Exported // from the ROOT (not `/llm-providers`) because the thing you catch it with is // `agent.run()`, and because `canResume` classifies on it. export { ContextWindowExceededError, ERR_CONTEXT_WINDOW_EXCEEDED, isContextWindowExceeded, } from './provider-contract/contextWindow.js'; // The code-session port's refusals and its one path rule — exported from the // ROOT with the `CodeSession` port they belong to, so a caller catches the same // names whichever code runner is behind the port. export { CodeSandboxError, sandboxPath, } from './provider-contract/codeSandbox.js'; export { SessionExpiredError } from './provider-contract/sessionExpired.js'; // The conversation refusals (9.2.0) — `instanceof`-able so a caller can tell // "you are already running" from "somebody is still waiting on an answer" from // "there is nothing to follow up on". export { NoConversationError, PendingQuestionError, ResumeIdentityConflictError, ResumeRedactionError, RunInFlightError, } from './core/conversation.js'; // A composition member runs for the run that mounted it; one no run reached is // refused by name (`core/memberRun.ts`). export { MemberIdentityError, ParentRunRefusedError, ResumeRequestConflictError, } from './core/memberRun.js'; export { flowchartAsTool, } from './core/flowchartAsTool.js'; // runbookAsTool (9.76.0) — the STANDARD bridge from a footprintjs procedure // to an Agent tool: every answer is the mandatory honesty spine (coverage // with inner-tool ledgers folded upward, provenance first, rule name+version, // the recorded walk as a `recording/chart-walk` artifact ticket) plus an // optional verdict/rowset projection selected by `resultKind: 'verdict/*'`. // `flowchartAsTool` stays for compatibility (its `resultMapper` users stay // put); new procedures start here. export { absenceSignalOf, DECLINED_VERDICT, DEFAULT_MAX_ROWS, // The chart-recording ceiling (9.79.0) — `walk: { recording: true }` files // the inner chart's own `{ snapshot, events, structure }` beside the walk, // and a bundle over this many bytes is REFUSED (never truncated) with the // reason stated on `walk.recording_note`. DEFAULT_RECORDING_MAX_BYTES, DEFAULT_WALK_CAP, PANEL_RENDER_NOTE, probeDispatch, projectWalk, recordingDispatch, renderVerdictTable, runbookAsTool, RunbookAbsenceSignal, VERDICT_RENDER_NOTE, verdictRowsOf, } from './core/runbook/index.js'; export { artifactDetailTool } from './tools/artifactDetailTool.js'; export { ArtifactDetailError } from './artifacts/detailError.js'; export { defineTool, assertResultCeiling, assertResultClass, // The placed-result kind (9.70.0) — `Tool.resultKind` lets a tool declare // the artifact kind its PLACED result is minted under, so the ticket speaks // the vocabulary a `wants` argument names. Exported beside the other two // for consumers assembling `Tool` objects by hand. assertResultKind, // The composition declarations (9.76.0) — `composedOf` (drift-checked at // agent build, when the catalog is complete) and `gates` (whether the // procedure can raise an approval gate). Exported beside the others for // consumers assembling `Tool` objects by hand. assertComposedOf, assertGates, } from './tools/tools.js'; // Host-filled tool arguments: a field the HOST fills from the call's credential // or the caller's identity — removed from the model's schema, a model-sent // value refused by name, the credential scrubbed from what comes back. export { hostFilled, fromCredential, fromIdentity, HostFilledArgumentError, HostFilledValueMissingError, HOST_FILLED_PLACEHOLDER, } from './tools/hostFilled.js'; // The tool-name law (`lib/toolName.ts`): the strict check and the dev-mode // warning `defineTool` runs, for consumers assembling `Tool` objects by hand. export { assertValidToolName, warnIfInvalidToolName } from './lib/toolName.js'; // Typed tool effects (9.19.0) — the result envelope a tool may return to // steer the run with DATA instead of string conventions: propose a graph // transition, push a registered instruction, declare an outcome status. The // law: push mandatory procedure; pull optional knowledge; never let // arbitrary text promote itself into control authority. export { explainStatusOnlyNearMiss, readToolResultEnvelope, TOOL_RESULT_STATUSES, } from './semantics/toolEffects.js'; // The two coverage primitives — both invented in FIELD USE, on a live triage // agent, because the library had no answer for either. // // • `absent()` — an absence that names its own coverage. A tool that finds // nothing returns something, and from an empty array a model cannot tell // "I looked and there is nothing" from "I could not look". The confusion // is not symmetric: a nothing-found read as an outage costs an // investigation, an outage read as nothing-found declares a system // healthy that was never checked. // • `coverage()` — the ledger of what a clean result does NOT rule out: // checked, not checked, and can never be covered. The sibling of the // evidence gate — the gate catches invented VALUES, this catches unstated // LIMITS. // // Both are RECOGNIZED by the framework (status, events, evidence corpus), not // conventions: a shape the framework does not understand cannot stop a retry // loop or keep a value out of the evidence index. // // `absent({ what, among })` — a name looked up in a known list that resolves // to nothing is a named miss over the names the tool read: the mint composes // the names facet and an irremovable "names outside <source>" gap (for a // partial read, "not every name in <source> was read"). The names are read // only to check the count; none is served. export { ABSENCE_MARKER, ABSENCE_NOTE, absent, coverage, COVERAGE_BLOCK_HEADING, COVERAGE_MARKER, COVERAGE_NOTE, readAbsence, readCoverageLedger, readCoverageResult, // `Tool.search` — what one call searches, declared once; and the coverage // row the library composes from it and the arguments the call ran with. // Three names on purpose: an item, a gap or a role is reached through these // (`ComposedCoverage['checked'][number]`), so the public surface stays small. isComposedCoverage, } from './semantics/coverage/index.js'; // The one period shape (honesty layer 3, step 7b): what a result's READ // covered in time — the instants it asked for, what the store holds (or // 'unknown', said out loud) — declared on `absent()`, `coverage()` and // `describedResult()`; the ONE verdict rule over it; the wire spelling as data // (`canonical-notes.json` publishes it); and the ledger row the results layer // files per call — a member of `FindingsRow`, returned by `agent.findings()`. export { PERIOD_WIRE, periodVerdict, } from './semantics/coverage/period.js'; // The third outcome (honesty layer 3): what a `coverage()`'s read found still // RUNNING — its outcome not known yet, neither a success nor a failure — as // the TOOL declares it (`inProgress`; the library never reads a vendor's state // name). The wire spelling as data (`canonical-notes.json` publishes it), the // served clause, the limits block's section label, and the typed shapes. export { IN_PROGRESS_CLAUSE, IN_PROGRESS_SECTION_LABEL, IN_PROGRESS_WIRE, } from './semantics/coverage/inProgress.js'; // The semantic tool-result envelope (9.53.0) — typed series/facts/edges with // the caveats that make them honest (grain, provenance, coverage) as DATA, // so honesty is inherited, not re-authored per tool. A sibling recognizer // beside the effects envelope and the coverage primitives (its own // `af_semantics` marker); the three compose on one result. The MODEL reads // the compact rendering-free projection; the FULL envelope rides the typed // `tools.semantics_declared` event; a declared `coverage` flows through the // same channel `coverage()` uses. The gate half (`checkSemantics`, the // `agentfootprint-check-semantics` bin) ships through `/observe`. // `describedResult()` mints it from a camelCase declaration; the saved // snake_case wire format remains unchanged. export { composeNotCovered, COUNTER_AGGREGATION_WORDS, describedResult, explainSemantics, isCounterLookingAggregation, readSemantics, RESULT_CLASSES, SEMANTICS_MARKER, SEMANTICS_NOTE, semanticsForModel, } from './semantics/index.js'; // Tool sessions (9.7.0) — the identity a tool holds a session under, and the // end-signal that releases it. The KEY DERIVATION is exported because it is the // isolation boundary: one implementation, or two that disagree. export { toolSessionKey, hashSessionKey, ToolTeardownTimeoutError, // A handle this process lost — never confused with a server's expiry // (`SessionExpiredError`, above): nothing was sent, the remote fate unknown. LocalSessionHandleLostError, TOOL_TEARDOWN_TIMEOUT_MS, } from './tools/toolSessions.js'; export { codeRunnerTool, codeShape, codeRunsOf, toolSessionsOf, TOOL_SESSIONS, } from './core/codeRunnerTool.js'; export { toolContractCheckup, formatToolContractCheckup, } from './tools/toolContract.js'; // Artifacts (9.21.0) — the claim-check store: a tool checks a payload in and // hands the model a ~26-char claim ticket; the model routes tickets instead // of hauling data; a later tool redeems them under the run's own scope // (`ctx.artifacts`, shaped exactly like `ctx.credentials`). Wired via // `Agent.create({ ..., artifacts })`. On the MAIN barrel because the door is // an AgentOptions port and the tool capability lives on ToolExecutionContext // — both main-barrel citizens; the durable adapters load `node:fs` / // `node:sqlite` lazily at CONSTRUCTION (the sqliteSessions law), so a browser // bundle walking this barrel never sees them. export { ARTIFACT_REF_PREFIX, ArtifactIntegrityError, bindArtifacts, // Recordings-as-artifacts (9.26.0) — a completed run's // `{ snapshot, events, structure }` checked in under kind 'recording/run', // so the existing artifact wire ops serve the Lens with no new operation. RECORDING_ARTIFACT_KIND, RECORDING_MEDIA_TYPE, recordingPutInput, // The chart-walk kind (9.76.0) — a runbook's inner walk, one row per // execution step with the decide() evidence in the `condition` rows, // checked in under 'recording/chart-walk' beside 'recording/run'. CHART_WALK_ARTIFACT_KIND, chartWalkPutInput, UnserializableRecordingError, DEFAULT_IN_MEMORY_ARTIFACT_RETENTION, fileArtifacts, gcsArtifacts, inMemoryArtifacts, InvalidArtifactError, isArtifactRef, mintArtifactRef, s3Artifacts, sqliteArtifacts, unconfiguredArtifacts, UnknownParentRefError, UnreadableArtifactFileError, UnreadableArtifactStoreError, withDatasetArtifacts, stageDatasetArtifacts, describeTimeAxis, normaliseInstants, readTimeAxis, timeAxisIssues, TIME_AXIS_AGGREGATES, TIME_AXIS_UNITS, } from './artifacts/index.js'; // The library's careful English reader (step T6b) — a tokenizer over the v1 // phrases, "unreadable" for the rest: `.time({ reader: englishTimeReader() })`. export { englishTimeReader } from './time/readers/english.js'; export { defaultTimeAskMessages } from './locales/timeAsk.js'; export { answerFromElicitation, elicitationOf, } from './mcp/elicitation.js'; // Artifacts, the optional streaming leg (9.25.0) — `putStream`/`getStream` are // FEATURE-DETECTED members of the port, so a store that cannot move bytes // without holding them whole leaves them absent rather than faking one. The // guards narrow the type, so calling an absent member is a compile error. export { canGetArtifactStream, canPutArtifactStream, canStreamArtifacts, } from './artifacts/index.js'; // Artifacts, the CONFORMANCE battery — the laws a store must hold to claim the // port, written once against the port and run against every store, in-tree or // out. On the main barrel because that is where `ArtifactStore` itself ships: // somebody implementing the port imports the check from the same door as the // interface. Nothing in it imports a test framework — a case throws to fail — // so it runs under vitest, jest, `node:test` or a plain script. export { artifactStoreConformance, formatArtifactStoreReport, runArtifactStoreCase, runArtifactStoreConformance, } from './artifacts/index.js'; // Artifacts, the data legs (9.22.0) — refs the model ROUTES: `wants` (ref // arguments resolved at dispatch, the declare-and-push precedent applied to // data), the auto-attached `present` tool (hand a ref to the screen with a // description snapshot the transcript keeps), and the placement threshold // (`artifacts: { store, placement }` — oversized results become claim // tickets). All zero-cost without a store. export { assertToolWants, isPlacedToolResult, placedResultKind, PRESENT_TOOL_NAME, } from './artifacts/index.js'; // Slot subflow builders are intentionally NOT exported. They are // internal helpers used only by `Agent.buildChart()` and // `LLMCall.buildChart()` to construct each primitive's three-slot // context-engineering subflow tree. Consumers compose at the // primitive / composition level (Agent / LLMCall / Sequence / …) — they // never construct slot subflows directly. Power-users authoring a // custom Agent-like primitive should copy the pattern from // `src/core/Agent.ts` rather than depend on a private helper surface. // Compositions (core-flow/) export { Sequence, SequenceBuilder, } from './core-flow/Sequence.js'; export { Parallel, ParallelBuilder, } from './core-flow/Parallel.js'; export { Conditional, ConditionalBuilder, } from './core-flow/Conditional.js'; export { Loop, LoopBuilder, } from './core-flow/Loop.js'; export { workflow, Workflow, } from './core-flow/Workflow.js'; export { graph, Graph, } from './core-flow/Graph.js'; // Adapters — LLM providers // `mock(...)` is the lowercase factory equivalent to `new MockProvider(...)`. // `anthropic(...)` is the real Claude provider via `@anthropic-ai/sdk`. // Zero-peer-dep providers — safe to re-export from the main barrel // because bundlers walking these never touch optional peer-dep code. // // Vendor-SDK-backed providers (AnthropicProvider, OpenAIProvider, // BedrockProvider) live ONLY at `agentfootprint/providers`. That // subpath segregation means bundlers walking from `agentfootprint` main // never see the lazy peer-dep requires for `@anthropic-ai/sdk`, // `openai`, `@aws-sdk/client-bedrock-runtime`, etc. — automatic // tree-shaking, no bundler-side workarounds. // // import { AnthropicProvider } from 'agentfootprint'; // ❌ not exported // import { AnthropicProvider } from 'agentfootprint/providers'; // ✓ canonical export { providerFromEnv, } from './adapters/llm/createProvider.js'; // Streaming helpers — agent events → SSE for browser delivery. // Injection Engine — the unifying primitive of context engineering. // One Injection type, four sugar factories, one engine subflow. // Patterns — factory functions composing primitives + core-flow into // well-known agent patterns from the research literature. export * from './patterns/index.js'; // Memory subsystem — narrative beats, fact extraction, embedding-based // retrieval, and pipelines that compose them. Top-level barrel exports // the most-used factories; the full subsystem (including types that // would collide with adapter types like MemoryStore) is reachable via // the `agentfootprint/memory` subpath import. // RAG — retrieval-augmented generation as a context-engineering flavor. // Thin sugar over `defineMemory({ type: SEMANTIC, strategy: TOP_K })` // plus the `indexDocuments` helper for seeding the corpus at startup. export { defineRAG, DEFAULT_CORPUS_IDENTITY, indexDocuments, } from './rag/retriever/index.js'; // The retrieval seam (8.8.0) — what a retrieval considered, and the rule // that decided what it kept. `topK` is the rule every release before this // one applied without naming it. The record types are here because a // consumer reading `agentfootprint.memory.retrieved` needs them. export { topK, } from './memory/retrieval/index.js'; export { AnswerValidationError, checkClaimRequirements, } from './answer-validation/index.js'; //# sourceMappingURL=index.js.map