@warlock.js/ai 4.8.0 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/cjs/index.cjs +24427 -242
- package/cjs/index.cjs.map +1 -0
- package/esm/ai.mjs +1 -0
- package/esm/ai.mjs.map +1 -1
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +5 -1
- package/esm/config.mjs.map +1 -1
- package/esm/index.d.mts +2 -1
- package/esm/index.mjs +3 -1
- package/esm/memory/index.mjs +3 -0
- package/esm/prompts/index.d.mts +2 -1
- package/esm/prompts/index.mjs +1 -0
- package/esm/prompts/prompts-validate.d.mts +44 -0
- package/esm/prompts/prompts-validate.d.mts.map +1 -0
- package/esm/prompts/prompts-validate.mjs +0 -0
- package/esm/security/redact.d.mts.map +1 -1
- package/esm/security/redact.mjs +7 -1
- package/esm/security/redact.mjs.map +1 -1
- package/esm/skills/catalog.mjs +1 -1
- package/esm/skills/store/procedural-skill-store.mjs +1 -0
- package/esm/skills/store/procedural-skill-store.mjs.map +1 -1
- package/package.json +5 -3
- package/cjs/src-DBn2_pbG.cjs +0 -30
- package/cjs/src-DTlN47aO.cjs +0 -25624
- package/cjs/src-DTlN47aO.cjs.map +0 -1
- package/esm/ai-openai/src/embedder.mjs +0 -4
- package/esm/ai-openai/src/image.mjs +0 -5
- package/esm/ai-openai/src/index.mjs +0 -7
- package/esm/ai-openai/src/model.mjs +0 -5
- package/esm/ai-openai/src/sdk.mjs +0 -9
- package/esm/ai-openai/src/speech.mjs +0 -5
- package/esm/ai-openai/src/transcription.mjs +0 -6
- package/esm/ai-openai/src/utils/index.mjs +0 -5
- package/esm/ai-openai/src/utils/to-openai-messages.mjs +0 -3
- package/esm/ai-openai/src/utils/to-openai-tools.mjs +0 -3
- package/esm/ai-openai/src/utils/wrap-openai-error.mjs +0 -4
package/esm/ai.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { forTool } from "./middleware/helpers/for-tool.mjs";
|
|
|
7
7
|
import { tool } from "./tool/tool.mjs";
|
|
8
8
|
import { skills } from "./skills/skills.mjs";
|
|
9
9
|
import { memory } from "./memory/memory.mjs";
|
|
10
|
+
import "./memory/index.mjs";
|
|
10
11
|
import "./skills/index.mjs";
|
|
11
12
|
import { agent } from "./agent/agent.mjs";
|
|
12
13
|
import { spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
|
package/esm/ai.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.mjs","names":["checkpointMemory","checkpointPg","checkpointRedis","snapshotMemory","snapshotPg","snapshotRedis","guardrailSuite"],"sources":["../../../../../../@warlock.js/ai/src/ai.ts"],"sourcesContent":["import { agent } from \"./agent/agent\";\nimport { batch } from \"./batch\";\nimport { streamObject } from \"./object-stream\";\nimport { serve } from \"./serve\";\nimport {\n checkpointMemory,\n checkpointPg,\n checkpointRedis,\n} from \"./checkpoint\";\nimport { setAIConfig } from \"./config\";\nimport { dataset, evalScorers } from \"./eval\";\nimport { humanApproval } from \"./human/human-approval\";\nimport { human } from \"./human/register\";\nimport { image } from \"./image\";\nimport { speech } from \"./speech\";\nimport {\n audioFromBuffer,\n audioFromFile,\n audioMediaTypeForFilename,\n transcribe,\n} from \"./transcribe\";\nimport { resume } from \"./human/resume\";\nimport {\n interruptMemory,\n interruptPg,\n interruptRedis,\n} from \"./human/stores\";\nimport { guardrail as guardrailSuite } from \"./guard/guardrail\";\nimport { budget, readBudgetFallbackSignal } from \"./middleware/builtins/budget\";\nimport { memory } from \"./memory\";\nimport { guardrail } from \"./middleware/builtins/guardrail\";\nimport { semanticCache } from \"./middleware/builtins/semantic-cache\";\nimport { composeMiddleware, forTool } from \"./middleware/helpers\";\nimport { mockRouter } from \"./mock\";\nimport { fallbackModel } from \"./model\";\nimport { orchestrator } from \"./orchestrator\";\nimport { planner } from \"./planner\";\nimport { defaultPromptsManager } from \"./prompts/prompts-manager\";\nimport {\n bm25Rank,\n cacheVectorStore,\n chunk,\n hybridRank,\n keywordReranker,\n llmReranker,\n loadHtml,\n loadPdf,\n loadText,\n loadWeb,\n multiQuery,\n pgVectorStore,\n rag,\n reciprocalRankFusion,\n vectorLiteral,\n} from \"./rag\";\nimport { spawnSubAgent } from \"./agent/spawn-sub-agent\";\nimport { skills } from \"./skills\";\nimport { prompt } from \"./prompt\";\nimport { vcr } from \"./vcr\";\nimport { snapshotMemory, snapshotPg, snapshotRedis } from \"./snapshot\";\nimport { fanOut, router } from \"./supervisor\";\nimport { supervisor } from \"./supervisor/supervisor\";\nimport { team } from \"./team/team\";\nimport { instruction } from \"./system-prompt/instruction\";\nimport { persona } from \"./system-prompt/persona\";\nimport { systemPrompt } from \"./system-prompt/system-prompt\";\nimport { tool } from \"./tool/tool\";\nimport { step } from \"./workflow/step\";\nimport { workflow } from \"./workflow/workflow\";\n\n/**\n * The shape of the top-level `ai` namespace. Declared as an `interface` (not an\n * inferred `const` type) so satellite packages can attach their verb via\n * `declare module \"@warlock.js/ai\" { interface Ai { … } }` — e.g. `ai.workspace`,\n * `ai.tools`, `ai.mcp`, `ai.human`. The runtime object below is asserted to this\n * type; a satellite assigns its member on import.\n */\nexport interface Ai {\n config: typeof setAIConfig;\n tool: typeof tool;\n agent: typeof agent;\n systemPrompt: typeof systemPrompt;\n persona: typeof persona;\n instruction: typeof instruction;\n workflow: typeof workflow;\n step: typeof step;\n supervisor: typeof supervisor;\n team: typeof team;\n orchestrator: typeof orchestrator;\n memory: typeof memory;\n skills: typeof skills;\n planner: typeof planner;\n rag: typeof rag & {\n keywordReranker: typeof keywordReranker;\n llmReranker: typeof llmReranker;\n chunk: typeof chunk;\n cacheVectorStore: typeof cacheVectorStore;\n pgVectorStore: typeof pgVectorStore;\n vectorLiteral: typeof vectorLiteral;\n loadText: typeof loadText;\n loadHtml: typeof loadHtml;\n loadWeb: typeof loadWeb;\n loadPdf: typeof loadPdf;\n bm25Rank: typeof bm25Rank;\n reciprocalRankFusion: typeof reciprocalRankFusion;\n hybridRank: typeof hybridRank;\n multiQuery: typeof multiQuery;\n };\n spawnSubAgent: typeof spawnSubAgent;\n router: typeof router;\n fanOut: typeof fanOut;\n batch: typeof batch;\n /** Structured-output streaming — partial-object snapshots + a strict final parse (A1). */\n streamObject: typeof streamObject;\n /** Serve an executable as an SSE HTTP endpoint — production serving primitive (A3). */\n serve: typeof serve;\n /**\n * Generate images from a text prompt — the image-output verb of the\n * output-modality track (Theme I). Wraps an `ImageModelContract` (from\n * `openai.image(...)` / `google.image(...)`) in the uniform\n * never-throws `{ data, error, usage, report }` envelope with cost-truth\n * and observability.\n */\n image: typeof image;\n /** Text-to-speech (TTS) — the audio-output verb of the modality track (Theme I). */\n speech: typeof speech;\n /** Speech-to-text (STT / transcription) — the audio-input verb of the modality track (Theme I). */\n transcribe: typeof transcribe;\n /** Read an audio file from disk → `AudioInput` for `ai.transcribe` (non-AI file plumbing). */\n audioFromFile: typeof audioFromFile;\n /** Package raw audio bytes → `AudioInput` for `ai.transcribe`. */\n audioFromBuffer: typeof audioFromBuffer;\n /** Resolve the audio media type from a filename's extension. */\n audioMediaTypeForFilename: typeof audioMediaTypeForFilename;\n fallbackModel: typeof fallbackModel;\n eval: typeof evalScorers;\n dataset: typeof dataset;\n prompt: typeof prompt;\n /**\n * Process-wide registry of named, versioned `systemPrompt(...)` builders,\n * keyed by `name@version`. A `systemPrompt(input, { name })` (or any\n * `.meta({ name })` rename) auto-registers here; `ai.prompts.get(name)` /\n * `.resolve(name)` reads them back, and `systemPrompt().merge(name)` folds a\n * registered prompt into a new one.\n */\n prompts: ReturnType<typeof defaultPromptsManager>;\n vcr: typeof vcr;\n mockRouter: typeof mockRouter;\n middleware: {\n budget: typeof budget;\n guardrail: typeof guardrail;\n semanticCache: typeof semanticCache;\n compose: typeof composeMiddleware;\n forTool: typeof forTool;\n readBudgetFallbackSignal: typeof readBudgetFallbackSignal;\n };\n checkpoint: {\n memory: typeof checkpointMemory;\n pg: typeof checkpointPg;\n redis: typeof checkpointRedis;\n };\n snapshot: {\n memory: typeof snapshotMemory;\n pg: typeof snapshotPg;\n redis: typeof snapshotRedis;\n };\n /**\n * Human-in-the-loop tool approval (interrupt / resume).\n *\n * - `human.approval(options)` — the `tool.before` approval-gate middleware.\n * - `human.resume(id, decision, options)` — out-of-process durable resume.\n * - `human.interrupt.{memory,pg,redis}()` — durable {@link InterruptStore}\n * factories (memory ships real; pg/redis are lazy optional peers).\n */\n human: {\n approval: typeof humanApproval;\n resume: typeof resume;\n interrupt: {\n memory: typeof interruptMemory;\n pg: typeof interruptPg;\n redis: typeof interruptRedis;\n };\n };\n /**\n * Content-intelligence guardrail. `ai.guardrail(options)` builds a composed\n * input / output / tool middleware; `ai.guardrail.{pii,topic,injection,moderation}`\n * are the built-in detector factories.\n */\n guardrail: typeof guardrailSuite;\n}\n\n/**\n * Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.\n *\n * Factories:\n * - `ai.tool(...)` — wrap an async function with a schema-validated input.\n * - `ai.agent(...)` — build an executable agent from model + tools + prompt.\n * - `ai.systemPrompt(...)` — compose a layered persona + instructions prompt.\n * - `ai.persona(text)` — reusable persona block (can be passed to `systemPrompt`).\n * - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).\n * - `ai.orchestrator(...)` — session-state manager wrapped around a supervisor (durable session, drift detection, resume, commands).\n * - `ai.memory(...)` — build an agent-memory store with WORKING (in-run scratch) and SEMANTIC (cache-driver `.similar()` recall) tiers.\n * - `ai.skills(...)` — build a runtime skills library (always-injected metadata catalog + on-demand loadSkill tool).\n * - `ai.planner(...)` — build an executable that generates an ordered plan over registered capabilities, then runs it step-by-step.\n * - `ai.spawnSubAgent(spec)` — thin wrapper that builds a fresh one-shot `agent()` with an optional per-task `budget` and runs the task once. A general primitive (not planner-specific).\n * - `ai.router(...)` — build a supervisor-compatible routing agent from named intents.\n * - `ai.fanOut(unit, count)` — spread one agent/workflow into N intent entries for voting / self-consistency.\n * - `ai.batch(executable, items, opts?)` — run any executable over a dataset with bounded concurrency + per-item retry.\n * - `ai.fallbackModel(models, opts?)` — wrap an ordered model list that fails over to the next on transient provider errors.\n * - `ai.eval.{exact,contains,predicate,judge}(...)` — built-in scorer factories for `agent.eval(...)`.\n * - `ai.mockRouter(decisions, opts?)` — deterministic supervisor `route` callback for tests.\n * - `ai.checkpoint.{memory,pg,redis}()` — durable orchestrator session checkpoint stores.\n * - `ai.snapshot.{memory,pg,redis}()` — supervisor-run snapshot stores for `iterate: true` resume.\n * - `ai.human.approval(...)` / `ai.human.resume(...)` / `ai.human.interrupt.{memory,pg,redis}()` — human-in-the-loop tool approval (interrupt / resume).\n * - `ai.guardrail(options)` + `ai.guardrail.{pii,topic,injection,moderation}(...)` — content-intelligence guardrails (moderation / PII / injection / topic).\n * - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.\n *\n * @example\n * const alex = ai.persona(\"You are Alex, a TypeScript expert.\");\n * const replyIn = ai.instruction(\"Respond in {{language|English}}.\");\n *\n * const prompt = ai.systemPrompt().persona(alex).instruction(replyIn);\n *\n * const myAgent = ai.agent({\n * model: ai.openai.model({ name: \"gpt-4o\" }),\n * systemPrompt: prompt,\n * tools: [myTool],\n * });\n *\n * const result = await myAgent.execute(\"What is the weather in Cairo?\", {\n * placeholders: { language: \"Arabic\" },\n * });\n */\nexport const ai = {\n config: setAIConfig,\n tool,\n agent,\n systemPrompt,\n persona,\n instruction,\n workflow,\n step,\n supervisor,\n team,\n orchestrator,\n memory,\n skills,\n planner,\n rag: Object.assign(rag, {\n keywordReranker,\n llmReranker,\n chunk,\n cacheVectorStore,\n pgVectorStore,\n vectorLiteral,\n loadText,\n loadHtml,\n loadWeb,\n loadPdf,\n bm25Rank,\n reciprocalRankFusion,\n hybridRank,\n multiQuery,\n }),\n spawnSubAgent,\n router,\n fanOut,\n batch,\n streamObject,\n serve,\n image,\n speech,\n transcribe,\n audioFromFile,\n audioFromBuffer,\n audioMediaTypeForFilename,\n fallbackModel,\n eval: evalScorers,\n dataset,\n prompt,\n prompts: defaultPromptsManager(),\n vcr,\n mockRouter,\n middleware: {\n budget,\n guardrail,\n semanticCache,\n compose: composeMiddleware,\n forTool,\n readBudgetFallbackSignal,\n },\n checkpoint: {\n memory: checkpointMemory,\n pg: checkpointPg,\n redis: checkpointRedis,\n },\n snapshot: {\n memory: snapshotMemory,\n pg: snapshotPg,\n redis: snapshotRedis,\n },\n human,\n guardrail: guardrailSuite,\n // Asserted (not `: Ai`) so a consumer build that augments `Ai` with a\n // satellite verb (e.g. `workspace`) doesn't flag this literal as missing it.\n} as Ai;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyOA,MAAa,KAAK;CAChB,QAAQ;CACR;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,KAAK,OAAO,OAAO,KAAK;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;CACA;CACA,SAAS,sBAAsB;CAC/B;CACA;CACA,YAAY;EACV;EACA;EACA;EACA,SAAS;EACT;EACA;CACF;CACA,YAAY;EACV,QAAQA;EACJC;EACGC;CACT;CACA,UAAU;EACR,QAAQC;EACR,IAAIC;EACJ,OAAOC;CACT;CACA;CACA,WAAWC;AAGb"}
|
|
1
|
+
{"version":3,"file":"ai.mjs","names":["checkpointMemory","checkpointPg","checkpointRedis","snapshotMemory","snapshotPg","snapshotRedis","guardrailSuite"],"sources":["../../../../../../@warlock.js/ai/src/ai.ts"],"sourcesContent":["import { agent } from \"./agent/agent\";\nimport { batch } from \"./batch\";\nimport { streamObject } from \"./object-stream\";\nimport { serve } from \"./serve\";\nimport {\n checkpointMemory,\n checkpointPg,\n checkpointRedis,\n} from \"./checkpoint\";\nimport { setAIConfig } from \"./config\";\nimport { dataset, evalScorers } from \"./eval\";\nimport { humanApproval } from \"./human/human-approval\";\nimport { human } from \"./human/register\";\nimport { image } from \"./image\";\nimport { speech } from \"./speech\";\nimport {\n audioFromBuffer,\n audioFromFile,\n audioMediaTypeForFilename,\n transcribe,\n} from \"./transcribe\";\nimport { resume } from \"./human/resume\";\nimport {\n interruptMemory,\n interruptPg,\n interruptRedis,\n} from \"./human/stores\";\nimport { guardrail as guardrailSuite } from \"./guard/guardrail\";\nimport { budget, readBudgetFallbackSignal } from \"./middleware/builtins/budget\";\nimport { memory } from \"./memory\";\nimport { guardrail } from \"./middleware/builtins/guardrail\";\nimport { semanticCache } from \"./middleware/builtins/semantic-cache\";\nimport { composeMiddleware, forTool } from \"./middleware/helpers\";\nimport { mockRouter } from \"./mock\";\nimport { fallbackModel } from \"./model\";\nimport { orchestrator } from \"./orchestrator\";\nimport { planner } from \"./planner\";\nimport { defaultPromptsManager } from \"./prompts/prompts-manager\";\nimport {\n bm25Rank,\n cacheVectorStore,\n chunk,\n hybridRank,\n keywordReranker,\n llmReranker,\n loadHtml,\n loadPdf,\n loadText,\n loadWeb,\n multiQuery,\n pgVectorStore,\n rag,\n reciprocalRankFusion,\n vectorLiteral,\n} from \"./rag\";\nimport { spawnSubAgent } from \"./agent/spawn-sub-agent\";\nimport { skills } from \"./skills\";\nimport { prompt } from \"./prompt\";\nimport { vcr } from \"./vcr\";\nimport { snapshotMemory, snapshotPg, snapshotRedis } from \"./snapshot\";\nimport { fanOut, router } from \"./supervisor\";\nimport { supervisor } from \"./supervisor/supervisor\";\nimport { team } from \"./team/team\";\nimport { instruction } from \"./system-prompt/instruction\";\nimport { persona } from \"./system-prompt/persona\";\nimport { systemPrompt } from \"./system-prompt/system-prompt\";\nimport { tool } from \"./tool/tool\";\nimport { step } from \"./workflow/step\";\nimport { workflow } from \"./workflow/workflow\";\n\n/**\n * The shape of the top-level `ai` namespace. Declared as an `interface` (not an\n * inferred `const` type) so satellite packages can attach their verb via\n * `declare module \"@warlock.js/ai\" { interface Ai { … } }` — e.g. `ai.workspace`,\n * `ai.tools`, `ai.mcp`, `ai.human`. The runtime object below is asserted to this\n * type; a satellite assigns its member on import.\n */\nexport interface Ai {\n config: typeof setAIConfig;\n tool: typeof tool;\n agent: typeof agent;\n systemPrompt: typeof systemPrompt;\n persona: typeof persona;\n instruction: typeof instruction;\n workflow: typeof workflow;\n step: typeof step;\n supervisor: typeof supervisor;\n team: typeof team;\n orchestrator: typeof orchestrator;\n memory: typeof memory;\n skills: typeof skills;\n planner: typeof planner;\n rag: typeof rag & {\n keywordReranker: typeof keywordReranker;\n llmReranker: typeof llmReranker;\n chunk: typeof chunk;\n cacheVectorStore: typeof cacheVectorStore;\n pgVectorStore: typeof pgVectorStore;\n vectorLiteral: typeof vectorLiteral;\n loadText: typeof loadText;\n loadHtml: typeof loadHtml;\n loadWeb: typeof loadWeb;\n loadPdf: typeof loadPdf;\n bm25Rank: typeof bm25Rank;\n reciprocalRankFusion: typeof reciprocalRankFusion;\n hybridRank: typeof hybridRank;\n multiQuery: typeof multiQuery;\n };\n spawnSubAgent: typeof spawnSubAgent;\n router: typeof router;\n fanOut: typeof fanOut;\n batch: typeof batch;\n /** Structured-output streaming — partial-object snapshots + a strict final parse (A1). */\n streamObject: typeof streamObject;\n /** Serve an executable as an SSE HTTP endpoint — production serving primitive (A3). */\n serve: typeof serve;\n /**\n * Generate images from a text prompt — the image-output verb of the\n * output-modality track (Theme I). Wraps an `ImageModelContract` (from\n * `openai.image(...)` / `google.image(...)`) in the uniform\n * never-throws `{ data, error, usage, report }` envelope with cost-truth\n * and observability.\n */\n image: typeof image;\n /** Text-to-speech (TTS) — the audio-output verb of the modality track (Theme I). */\n speech: typeof speech;\n /** Speech-to-text (STT / transcription) — the audio-input verb of the modality track (Theme I). */\n transcribe: typeof transcribe;\n /** Read an audio file from disk → `AudioInput` for `ai.transcribe` (non-AI file plumbing). */\n audioFromFile: typeof audioFromFile;\n /** Package raw audio bytes → `AudioInput` for `ai.transcribe`. */\n audioFromBuffer: typeof audioFromBuffer;\n /** Resolve the audio media type from a filename's extension. */\n audioMediaTypeForFilename: typeof audioMediaTypeForFilename;\n fallbackModel: typeof fallbackModel;\n eval: typeof evalScorers;\n dataset: typeof dataset;\n prompt: typeof prompt;\n /**\n * Process-wide registry of named, versioned `systemPrompt(...)` builders,\n * keyed by `name@version`. A `systemPrompt(input, { name })` (or any\n * `.meta({ name })` rename) auto-registers here; `ai.prompts.get(name)` /\n * `.resolve(name)` reads them back, and `systemPrompt().merge(name)` folds a\n * registered prompt into a new one.\n */\n prompts: ReturnType<typeof defaultPromptsManager>;\n vcr: typeof vcr;\n mockRouter: typeof mockRouter;\n middleware: {\n budget: typeof budget;\n guardrail: typeof guardrail;\n semanticCache: typeof semanticCache;\n compose: typeof composeMiddleware;\n forTool: typeof forTool;\n readBudgetFallbackSignal: typeof readBudgetFallbackSignal;\n };\n checkpoint: {\n memory: typeof checkpointMemory;\n pg: typeof checkpointPg;\n redis: typeof checkpointRedis;\n };\n snapshot: {\n memory: typeof snapshotMemory;\n pg: typeof snapshotPg;\n redis: typeof snapshotRedis;\n };\n /**\n * Human-in-the-loop tool approval (interrupt / resume).\n *\n * - `human.approval(options)` — the `tool.before` approval-gate middleware.\n * - `human.resume(id, decision, options)` — out-of-process durable resume.\n * - `human.interrupt.{memory,pg,redis}()` — durable {@link InterruptStore}\n * factories (memory ships real; pg/redis are lazy optional peers).\n */\n human: {\n approval: typeof humanApproval;\n resume: typeof resume;\n interrupt: {\n memory: typeof interruptMemory;\n pg: typeof interruptPg;\n redis: typeof interruptRedis;\n };\n };\n /**\n * Content-intelligence guardrail. `ai.guardrail(options)` builds a composed\n * input / output / tool middleware; `ai.guardrail.{pii,topic,injection,moderation}`\n * are the built-in detector factories.\n */\n guardrail: typeof guardrailSuite;\n}\n\n/**\n * Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.\n *\n * Factories:\n * - `ai.tool(...)` — wrap an async function with a schema-validated input.\n * - `ai.agent(...)` — build an executable agent from model + tools + prompt.\n * - `ai.systemPrompt(...)` — compose a layered persona + instructions prompt.\n * - `ai.persona(text)` — reusable persona block (can be passed to `systemPrompt`).\n * - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).\n * - `ai.orchestrator(...)` — session-state manager wrapped around a supervisor (durable session, drift detection, resume, commands).\n * - `ai.memory(...)` — build an agent-memory store with WORKING (in-run scratch) and SEMANTIC (cache-driver `.similar()` recall) tiers.\n * - `ai.skills(...)` — build a runtime skills library (always-injected metadata catalog + on-demand loadSkill tool).\n * - `ai.planner(...)` — build an executable that generates an ordered plan over registered capabilities, then runs it step-by-step.\n * - `ai.spawnSubAgent(spec)` — thin wrapper that builds a fresh one-shot `agent()` with an optional per-task `budget` and runs the task once. A general primitive (not planner-specific).\n * - `ai.router(...)` — build a supervisor-compatible routing agent from named intents.\n * - `ai.fanOut(unit, count)` — spread one agent/workflow into N intent entries for voting / self-consistency.\n * - `ai.batch(executable, items, opts?)` — run any executable over a dataset with bounded concurrency + per-item retry.\n * - `ai.fallbackModel(models, opts?)` — wrap an ordered model list that fails over to the next on transient provider errors.\n * - `ai.eval.{exact,contains,predicate,judge}(...)` — built-in scorer factories for `agent.eval(...)`.\n * - `ai.mockRouter(decisions, opts?)` — deterministic supervisor `route` callback for tests.\n * - `ai.checkpoint.{memory,pg,redis}()` — durable orchestrator session checkpoint stores.\n * - `ai.snapshot.{memory,pg,redis}()` — supervisor-run snapshot stores for `iterate: true` resume.\n * - `ai.human.approval(...)` / `ai.human.resume(...)` / `ai.human.interrupt.{memory,pg,redis}()` — human-in-the-loop tool approval (interrupt / resume).\n * - `ai.guardrail(options)` + `ai.guardrail.{pii,topic,injection,moderation}(...)` — content-intelligence guardrails (moderation / PII / injection / topic).\n * - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.\n *\n * @example\n * const alex = ai.persona(\"You are Alex, a TypeScript expert.\");\n * const replyIn = ai.instruction(\"Respond in {{language|English}}.\");\n *\n * const prompt = ai.systemPrompt().persona(alex).instruction(replyIn);\n *\n * const myAgent = ai.agent({\n * model: ai.openai.model({ name: \"gpt-4o\" }),\n * systemPrompt: prompt,\n * tools: [myTool],\n * });\n *\n * const result = await myAgent.execute(\"What is the weather in Cairo?\", {\n * placeholders: { language: \"Arabic\" },\n * });\n */\nexport const ai = {\n config: setAIConfig,\n tool,\n agent,\n systemPrompt,\n persona,\n instruction,\n workflow,\n step,\n supervisor,\n team,\n orchestrator,\n memory,\n skills,\n planner,\n rag: Object.assign(rag, {\n keywordReranker,\n llmReranker,\n chunk,\n cacheVectorStore,\n pgVectorStore,\n vectorLiteral,\n loadText,\n loadHtml,\n loadWeb,\n loadPdf,\n bm25Rank,\n reciprocalRankFusion,\n hybridRank,\n multiQuery,\n }),\n spawnSubAgent,\n router,\n fanOut,\n batch,\n streamObject,\n serve,\n image,\n speech,\n transcribe,\n audioFromFile,\n audioFromBuffer,\n audioMediaTypeForFilename,\n fallbackModel,\n eval: evalScorers,\n dataset,\n prompt,\n prompts: defaultPromptsManager(),\n vcr,\n mockRouter,\n middleware: {\n budget,\n guardrail,\n semanticCache,\n compose: composeMiddleware,\n forTool,\n readBudgetFallbackSignal,\n },\n checkpoint: {\n memory: checkpointMemory,\n pg: checkpointPg,\n redis: checkpointRedis,\n },\n snapshot: {\n memory: snapshotMemory,\n pg: snapshotPg,\n redis: snapshotRedis,\n },\n human,\n guardrail: guardrailSuite,\n // Asserted (not `: Ai`) so a consumer build that augments `Ai` with a\n // satellite verb (e.g. `workspace`) doesn't flag this literal as missing it.\n} as Ai;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyOA,MAAa,KAAK;CAChB,QAAQ;CACR;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,KAAK,OAAO,OAAO,KAAK;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;CACA;CACA,SAAS,sBAAsB;CAC/B;CACA;CACA,YAAY;EACV;EACA;EACA;EACA,SAAS;EACT;EACA;CACF;CACA,YAAY;EACV,QAAQA;EACJC;EACGC;CACT;CACA,UAAU;EACR,QAAQC;EACR,IAAIC;EACJ,OAAOC;CACT;CACA;CACA,WAAWC;AAGb"}
|
package/esm/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"mappings":";;;;;;;AA2CA;;;;;;;;;;;;;;;AAoDsC;AACrC;;;;AAKsC;AAoBvC;;;;AAAwD;AAmBxD;;;;;;;;;;UAjGiB,QAAA;EAiGwC;;AAAQ;AAuBjE;;;;AAAuC;AAYvC;;;;AAAkD;AAUlD;;;;AAAgE;AAUhE;;;;AAA4D;EAhI1D,YAAA,GAAe,WAAA;;;;;;;;;;;;;EAcf,sBAAA,GAAyB,eAAA;;;;;;;;;;;;;EAczB,oBAAA,GAAuB,aAAA;AAAA;;KAMpB,cAAA,IAAkB,MAAgB,EAAR,QAAQ;;;;;;;;;;;;;;;;;iBAoBvB,eAAA,CAAgB,QAAwB,EAAd,cAAc;;;;;;;;;;;;;;;;iBAmBxC,WAAA,CAAY,OAAA,EAAS,OAAA,CAAQ,QAAA,IAAY,QAAA;;;;;;iBAuBzC,WAAA,IAAe,QAAQ;;;;;;;;;iBAYvB,mBAAA,IAAuB,WAAW;;;;;;;iBAUlC,6BAAA,IAAiC,eAAe;;;;;;;iBAUhD,2BAAA,IAA+B,aAAa"}
|
package/esm/config.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { log } from "@warlock.js/logger";
|
|
2
|
+
|
|
1
3
|
//#region ../@warlock.js/ai/src/config.ts
|
|
2
4
|
const aiConfig = {};
|
|
3
5
|
const configListeners = [];
|
|
@@ -40,7 +42,9 @@ function setAIConfig(partial) {
|
|
|
40
42
|
const snapshot = { ...aiConfig };
|
|
41
43
|
for (const listener of configListeners) try {
|
|
42
44
|
listener(snapshot);
|
|
43
|
-
} catch {
|
|
45
|
+
} catch (error) {
|
|
46
|
+
log.error("ai", "configListener", error);
|
|
47
|
+
}
|
|
44
48
|
return snapshot;
|
|
45
49
|
}
|
|
46
50
|
/**
|
package/esm/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\nimport type { CheckpointStore } from \"./contracts/orchestrator/checkpoint-store.contract\";\nimport type { SnapshotStore } from \"./contracts/orchestrator/snapshot-store.contract\";\n\n/**\n * Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**\n * Lives here only for genuinely cross-cutting defaults that would\n * otherwise force users to wire the same value into every consumer.\n *\n * **What lives here.** A field earns a slot only when it satisfies\n * all three:\n * 1. Multiple unrelated consumers need the same value.\n * 2. The value is infrastructure (drivers, clients, pools), not\n * behavior (kill-switches, mode flags).\n * 3. Per-call override doesn't make sense for the use case.\n *\n * **What does NOT live here.** Logger config (use\n * `@warlock.js/logger` directly). Per-primitive feature flags\n * (live on the relevant config type). Anything that's really one\n * consumer's concern (lives on that consumer).\n *\n * Phase 3.2 deliberately removed the previous `configureAI()` bag\n * because it was growing unbounded. Treat new fields here with the\n * same suspicion.\n *\n * **Augmentable.** Declared as an `interface` (not a `type` alias) so\n * observability/tooling packages can attach their own opaque config slot\n * via declaration merging WITHOUT core importing them — keeping core\n * dependency-free. For example `@warlock.js/ai-panoptic` adds a\n * `panoptic?` field:\n *\n * ```ts\n * declare module \"@warlock.js/ai\" {\n * interface AIConfig {\n * panoptic?: PanopticConfig;\n * }\n * }\n * ```\n *\n * `setAIConfig` stores the whole object via `Object.assign`, so any\n * augmented field is preserved even though core never reads it.\n */\nexport interface AIConfig {\n /**\n * Default `@warlock.js/cache` driver for cache-backed consumers that\n * didn't supply their own `store` — currently the `semanticCache`\n * middleware's vector store. Declaring it once here removes the\n * repetition across middleware declarations.\n *\n * NOT the snapshot-persistence fallback anymore. Supervisor /\n * workflow / orchestrator resume snapshots resolve through\n * {@link AIConfig.defaultSnapshotStore} (a {@link SnapshotStore}),\n * never this driver.\n *\n * Per-declaration overrides (`semanticCache({ store })`) win when\n * supplied. Set this once at app boot, *after* you've constructed\n * your driver.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({\n * defaultStore: cache.driver(\"redis\", { client: redisClient }),\n * });\n */\n defaultStore?: CacheDriver<any, any>;\n\n /**\n * Default {@link CheckpointStore} for every orchestrator that didn't\n * supply its own `checkpointStore` (orchestrator.md §15.2). Holds\n * durable session state — `state`, `turn_index`, drift `signature`,\n * compaction locks. Per-orchestrator `checkpointStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultCheckpointStore: ai.checkpoint.memory() });\n */\n defaultCheckpointStore?: CheckpointStore;\n\n /**\n * Default {@link SnapshotStore} for every orchestrator that didn't\n * supply its own `snapshotStore` (orchestrator.md §15.2). Holds the\n * internal supervisor run state used to resume an interrupted\n * `iterate: true` turn. Per-orchestrator `snapshotStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultSnapshotStore: ai.snapshot.memory() });\n */\n defaultSnapshotStore?: SnapshotStore;\n};\n\nconst aiConfig: AIConfig = {};\n\n/** A listener notified after every `setAIConfig` merge. */\ntype ConfigListener = (config: AIConfig) => void;\n\nconst configListeners: ConfigListener[] = [];\n\n/**\n * Subscribe to config changes. The listener fires after every\n * {@link setAIConfig} merge with a fresh snapshot of the full config —\n * the seam observability/tooling packages use to react when their\n * augmented slot (e.g. `panoptic`) is set, WITHOUT core importing them.\n *\n * Mirrors the dependency-inversion of the `Observer` registry: core\n * exposes the structural hook; the tool subscribes on its side-effect\n * import. To also catch config that was applied *before* the subscription,\n * read {@link getAIConfig} once right after subscribing.\n *\n * @example\n * import { onConfigApplied, getAIConfig } from \"@warlock.js/ai\";\n * onConfigApplied((config) => applyPanopticConfig(config.panoptic));\n * applyPanopticConfig(getAIConfig().panoptic); // catch pre-set config\n */\nexport function onConfigApplied(listener: ConfigListener): void {\n configListeners.push(listener);\n}\n\n/**\n * Set or extend process-wide AI configuration. Merges over existing\n * values — fields not present in `partial` keep whatever was set\n * before (or stay unset). Call once at app boot, before constructing\n * any agent / supervisor / middleware that should pick up the\n * defaults.\n *\n * Returns the merged config so callers can verify what landed.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultStore: cache.driver(\"redis\", { client }) });\n */\nexport function setAIConfig(partial: Partial<AIConfig>): AIConfig {\n Object.assign(aiConfig, partial);\n const snapshot = { ...aiConfig };\n\n // Notify subscribers (e.g. panoptic) after the merge. Errors are\n // swallowed so a misbehaving listener never breaks config application,\n // mirroring the observer / onUsage swallow-on-throw discipline.\n for (const listener of configListeners) {\n try {\n listener(snapshot);\n } catch {\n
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\nimport { log } from \"@warlock.js/logger\";\nimport type { CheckpointStore } from \"./contracts/orchestrator/checkpoint-store.contract\";\nimport type { SnapshotStore } from \"./contracts/orchestrator/snapshot-store.contract\";\n\n/**\n * Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**\n * Lives here only for genuinely cross-cutting defaults that would\n * otherwise force users to wire the same value into every consumer.\n *\n * **What lives here.** A field earns a slot only when it satisfies\n * all three:\n * 1. Multiple unrelated consumers need the same value.\n * 2. The value is infrastructure (drivers, clients, pools), not\n * behavior (kill-switches, mode flags).\n * 3. Per-call override doesn't make sense for the use case.\n *\n * **What does NOT live here.** Logger config (use\n * `@warlock.js/logger` directly). Per-primitive feature flags\n * (live on the relevant config type). Anything that's really one\n * consumer's concern (lives on that consumer).\n *\n * Phase 3.2 deliberately removed the previous `configureAI()` bag\n * because it was growing unbounded. Treat new fields here with the\n * same suspicion.\n *\n * **Augmentable.** Declared as an `interface` (not a `type` alias) so\n * observability/tooling packages can attach their own opaque config slot\n * via declaration merging WITHOUT core importing them — keeping core\n * dependency-free. For example `@warlock.js/ai-panoptic` adds a\n * `panoptic?` field:\n *\n * ```ts\n * declare module \"@warlock.js/ai\" {\n * interface AIConfig {\n * panoptic?: PanopticConfig;\n * }\n * }\n * ```\n *\n * `setAIConfig` stores the whole object via `Object.assign`, so any\n * augmented field is preserved even though core never reads it.\n */\nexport interface AIConfig {\n /**\n * Default `@warlock.js/cache` driver for cache-backed consumers that\n * didn't supply their own `store` — currently the `semanticCache`\n * middleware's vector store. Declaring it once here removes the\n * repetition across middleware declarations.\n *\n * NOT the snapshot-persistence fallback anymore. Supervisor /\n * workflow / orchestrator resume snapshots resolve through\n * {@link AIConfig.defaultSnapshotStore} (a {@link SnapshotStore}),\n * never this driver.\n *\n * Per-declaration overrides (`semanticCache({ store })`) win when\n * supplied. Set this once at app boot, *after* you've constructed\n * your driver.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({\n * defaultStore: cache.driver(\"redis\", { client: redisClient }),\n * });\n */\n defaultStore?: CacheDriver<any, any>;\n\n /**\n * Default {@link CheckpointStore} for every orchestrator that didn't\n * supply its own `checkpointStore` (orchestrator.md §15.2). Holds\n * durable session state — `state`, `turn_index`, drift `signature`,\n * compaction locks. Per-orchestrator `checkpointStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultCheckpointStore: ai.checkpoint.memory() });\n */\n defaultCheckpointStore?: CheckpointStore;\n\n /**\n * Default {@link SnapshotStore} for every orchestrator that didn't\n * supply its own `snapshotStore` (orchestrator.md §15.2). Holds the\n * internal supervisor run state used to resume an interrupted\n * `iterate: true` turn. Per-orchestrator `snapshotStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultSnapshotStore: ai.snapshot.memory() });\n */\n defaultSnapshotStore?: SnapshotStore;\n};\n\nconst aiConfig: AIConfig = {};\n\n/** A listener notified after every `setAIConfig` merge. */\ntype ConfigListener = (config: AIConfig) => void;\n\nconst configListeners: ConfigListener[] = [];\n\n/**\n * Subscribe to config changes. The listener fires after every\n * {@link setAIConfig} merge with a fresh snapshot of the full config —\n * the seam observability/tooling packages use to react when their\n * augmented slot (e.g. `panoptic`) is set, WITHOUT core importing them.\n *\n * Mirrors the dependency-inversion of the `Observer` registry: core\n * exposes the structural hook; the tool subscribes on its side-effect\n * import. To also catch config that was applied *before* the subscription,\n * read {@link getAIConfig} once right after subscribing.\n *\n * @example\n * import { onConfigApplied, getAIConfig } from \"@warlock.js/ai\";\n * onConfigApplied((config) => applyPanopticConfig(config.panoptic));\n * applyPanopticConfig(getAIConfig().panoptic); // catch pre-set config\n */\nexport function onConfigApplied(listener: ConfigListener): void {\n configListeners.push(listener);\n}\n\n/**\n * Set or extend process-wide AI configuration. Merges over existing\n * values — fields not present in `partial` keep whatever was set\n * before (or stay unset). Call once at app boot, before constructing\n * any agent / supervisor / middleware that should pick up the\n * defaults.\n *\n * Returns the merged config so callers can verify what landed.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultStore: cache.driver(\"redis\", { client }) });\n */\nexport function setAIConfig(partial: Partial<AIConfig>): AIConfig {\n Object.assign(aiConfig, partial);\n const snapshot = { ...aiConfig };\n\n // Notify subscribers (e.g. panoptic) after the merge. Errors are\n // swallowed so a misbehaving listener never breaks config application,\n // mirroring the observer / onUsage swallow-on-throw discipline.\n for (const listener of configListeners) {\n try {\n listener(snapshot);\n } catch (error) {\n log.error(\"ai\", \"configListener\", error as Error);\n }\n }\n\n return snapshot;\n}\n\n/**\n * Read the current AI config snapshot. Returns a shallow copy so\n * callers can't accidentally mutate the source of truth. Used\n * internally by consumers to resolve their `defaultStore` fallback.\n */\nexport function getAIConfig(): AIConfig {\n return { ...aiConfig };\n}\n\n/**\n * Resolve the effective `@warlock.js/cache` driver for a cache-backed\n * consumer that didn't receive an explicit one. Returns the global\n * `defaultStore` if set, otherwise `undefined`. The semantic-cache\n * middleware treats `undefined` as fatal and throws. Snapshot\n * persistence no longer consults this — it resolves through\n * {@link resolveDefaultSnapshotStore}.\n */\nexport function resolveDefaultStore(): CacheDriver<any, any> | undefined {\n return aiConfig.defaultStore;\n}\n\n/**\n * Resolve the global default {@link CheckpointStore} for an\n * orchestrator that didn't receive an explicit `checkpointStore`.\n * Returns `undefined` when none is configured — the orchestrator\n * factory decides whether that's fatal.\n */\nexport function resolveDefaultCheckpointStore(): CheckpointStore | undefined {\n return aiConfig.defaultCheckpointStore;\n}\n\n/**\n * Resolve the global default {@link SnapshotStore} for an orchestrator\n * that didn't receive an explicit `snapshotStore`. Returns `undefined`\n * when none is configured — the orchestrator factory decides whether\n * that's fatal (it is, when `iterate: true`).\n */\nexport function resolveDefaultSnapshotStore(): SnapshotStore | undefined {\n return aiConfig.defaultSnapshotStore;\n}\n"],"mappings":";;;AAkGA,MAAM,WAAqB,CAAC;AAK5B,MAAM,kBAAoC,CAAC;;;;;;;;;;;;;;;;;AAkB3C,SAAgB,gBAAgB,UAAgC;CAC9D,gBAAgB,KAAK,QAAQ;AAC/B;;;;;;;;;;;;;;;;AAiBA,SAAgB,YAAY,SAAsC;CAChE,OAAO,OAAO,UAAU,OAAO;CAC/B,MAAM,WAAW,EAAE,GAAG,SAAS;CAK/B,KAAK,MAAM,YAAY,iBACrB,IAAI;EACF,SAAS,QAAQ;CACnB,SAAS,OAAO;EACd,IAAI,MAAM,MAAM,kBAAkB,KAAc;CAClD;CAGF,OAAO;AACT;;;;;;AAOA,SAAgB,cAAwB;CACtC,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;;;;AAUA,SAAgB,sBAAyD;CACvE,OAAO,SAAS;AAClB;;;;;;;AAQA,SAAgB,gCAA6D;CAC3E,OAAO,SAAS;AAClB;;;;;;;AAQA,SAAgB,8BAAyD;CACvE,OAAO,SAAS;AAClB"}
|
package/esm/index.d.mts
CHANGED
|
@@ -291,6 +291,7 @@ import { MiddlewareContextByLevel, MiddlewareLevel, runPipeline } from "./middle
|
|
|
291
291
|
import { extractUserText } from "./middleware/utils/extract-user-text.mjs";
|
|
292
292
|
import { NamespacedStateAccessor, namespacedState } from "./middleware/utils/namespaced-state.mjs";
|
|
293
293
|
import { getObservers, isObserveAll, registerObserver, setObserveAll } from "./observe/observer-registry.mjs";
|
|
294
|
+
import { JudgeOutcome, formatCriteria, judgePromptBody } from "./prompts/prompts-validate.mjs";
|
|
294
295
|
import { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy } from "./security/outbound-policy.mjs";
|
|
295
296
|
import { isPrivateOrReservedIp } from "./security/private-ip.mjs";
|
|
296
297
|
import { DEFAULT_SENSITIVE_KEYS, RedactOptions, RedactedError, SENSITIVE_HEADERS, redact, redactError, redactHeaders, scrubSecrets } from "./security/redact.mjs";
|
|
@@ -311,7 +312,7 @@ import { computeSignature as computeSignature$1 } from "./workflow/signature.mjs
|
|
|
311
312
|
import { MatcherVerdict, matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
312
313
|
import { AiMatchers } from "./testing/matchers.mjs";
|
|
313
314
|
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
314
|
-
export { AIConfig, AIError, type AIErrorCode, type AIErrorOptions, type AckCallback, type AckConfig, type AckEntry, type AckRunEntry, type AckSnapshot, type AgentBranchSnapshot, AgentCancelledError, type AgentCancelledErrorOptions, type AgentCompletedPayload, type AgentConfig, type AgentContract, AgentDriftError, type AgentDriftErrorOptions, type AgentErrorPayload, type AgentEventHandler, type AgentEventMap, type AgentExecuteOptions, AgentExecutionError, AgentMaxTripsError, type AgentMaxTripsErrorOptions, type AgentMiddleware, type AgentMiddlewareExecuteHooks, type AgentMiddlewareSupervisorHooks, type AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentResumeOptions, type AgentSnapshot, type AgentSnapshotStatus, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentToolEntry, type AgentTripCompletedPayload, type AgentTripStartedPayload, type Ai, type AiMatchers, type ApprovalDecision, type ApprovalDecisionType, type ApprovalHandler, ApprovalRejectedError, type ApprovalRejectedErrorOptions, type ApprovalRequest, type ApprovalRequestContext, Attachment, AttachmentPolicy, AttachmentSource, type AttemptEntry, AudioInput, type BaseReport, type BaseResult, type BatchItemHandler, type BatchItemResult, type BatchItemStatus, type BatchOptions, type BatchReport, type BatchResult, BinarySource, type BudgetContract, type BudgetContractDimension, type BudgetContractFallback, type BudgetContractViolation, type BudgetContractViolationMode, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetFallbackSignal, type BudgetOptions, type BudgetPricing, type BudgetUnit, type CapturedMessage, type Cassette, type CassetteEntry, type CheckpointRecord, type CheckpointStore, type Chunk, type ChunkOptions, type ChunkType, type Citation, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompactionResult, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, type DatasetContract, type DatasetEntry, type DatasetOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type EpisodicMemoryConfig, type ErrorCategory, type EvalCase, type EvalCaseResult, type EvalJudge, type EvalOptions, type EvalPredicate, type EvalReport, type EvalScore, type EvalScorer, type EvalScorerContext, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecutableTool, type ExecuteResult, type ExecutionReport, type ExecutionStatus, type ExportedPrompt, type ExportedPromptVersion, type ExportedRegistry, type ExtractJsonSchemaOptions, type FallbackAttempt, type FallbackModelContract, type FallbackModelOptions, type FallbackRetryPredicate, type FanOutOptions, type FanOutUnit, FinishReason, type FlagRecord, type FlowObserveOption, GeneratedAudio, GeneratedImage, type GuardOptions, type GuardrailAction, type GuardrailBlockEvent, type GuardrailCheck, type GuardrailCheckResult, type GuardrailDetector, type GuardrailDetectorContext, type GuardrailEscalation, type GuardrailFactory, type GuardrailMatch, type GuardrailOptions, type GuardrailPhase, type GuardrailVerdict, GuardrailViolationError, type GuardrailViolationErrorOptions, type HumanApprovalOptions, type HumanErrorCode, type ImageData, ImageGenerationOptions, ImageGenerationResponse, ImageModelConfig, ImageModelContract, ImageModelPricing, type ImageParams, type ImageReport, type ImageResult, ImageSource, type InjectionDetectorOptions, Instruction, InstructionContract, type IntentCallback, type IntentEntry, type IntentRunEntry, type IntentRunner, type IntentRunnerMap, type InterruptPolicy, type InterruptStore, InterruptSuspendedError, type InterruptSuspendedErrorOptions, InvalidRequestError, type IterationDecision, type IterationSnapshot, JUDGE_DEFAULT_REPAIR_ATTEMPTS, type JsonSchemaTarget, type JudgeAgentConfig, type JudgeConfig, type KeywordRerankerOptions, type LLMTrip, type LexicalDoc, type LineageStamp, type LlmRerankerOptions, type LoadHtmlOptions, type LoadPdfOptions, type LoadSkillInput, type LoadSkillResult, type LoadSkillToolDeps, type LoadTextOptions, type LoadWebOptions, type MatcherVerdict, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, type MemoryConfig, type MemoryContract, type MemoryItem, type MemoryTier, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareSupervisorContext, type MiddlewareSupervisorRef, type MiddlewareToolContext, type MiddlewareTripContext, type MockImageCall, MockImageModel, type MockImageResponse, MockModel, type MockModelResponse, type MockRouterDecision, type MockRouterExhaustion, type MockRouterOptions, MockSDK, type MockSDKConfig, MockSkillsStore, type MockSpeechCall, MockSpeechModel, type MockSpeechResponse, type MockTranscriptionCall, MockTranscriptionModel, type MockTranscriptionResponse, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type MultiQueryOptions, type NamespacedStateAccessor, type Next, type NextStepResult, OPENAI_INSTALL_INSTRUCTIONS, type ObjectStreamEvent, type Observer, type OpenAiClientLike, type OpenAiModerationCreateBody, type OpenAiModerationOptions, type OpenAiModerationResponse, type OpenAiModerationResult, type OrchestratorAsToolOptions, type OrchestratorAwaitingStatus, OrchestratorCancelledError, type OrchestratorCancelledErrorOptions, type OrchestratorCommandHandlers, type OrchestratorCommands, type OrchestratorConfig, OrchestratorConfigError, type OrchestratorContract, OrchestratorDriftError, type OrchestratorDriftErrorOptions, OrchestratorEmitter, type OrchestratorEvent, type OrchestratorEventHandler, type OrchestratorEventHandlers, type OrchestratorEventMap, type OrchestratorEventName, type OrchestratorExecuteOptions, OrchestratorExecution, type OrchestratorExecutionParams, OrchestratorFailedError, type OrchestratorMemoryConfig, type OrchestratorReport, type OrchestratorReportStatus, type OrchestratorReportType, type OrchestratorResult, type OrchestratorResumeOptions, type OrchestratorSessionScope, type OrchestratorStreamController, type OutboundPolicy, OutboundPolicyError, PDF_PARSE_INSTALL_INSTRUCTIONS, type ParsedFrontmatter, type PendingInterrupt, type PendingInterruptStatus, Persona, PersonaContract, type PgCheckpointOptions, type PgClientLike, type PgInterruptOptions, type PgSnapshotStoreOptions, type PgVectorStoreInstance, type PgVectorStoreOptions, type PiiCategory, type PiiDetectorOptions, Placeholders, PlannerCancelledError, type PlannerCancelledErrorOptions, type PlannerCapability, type PlannerConfig, type PlannerContract, PlannerDriftError, type PlannerDriftErrorOptions, type PlannerExecuteOptions, PlannerFailedError, type PlannerPlan, PlannerPlanInvalidError, type PlannerReport, type PlannerReportType, type PlannerResult, type PlannerResumeOptions, type PlannerRunArgs, type PlannerSnapshot, type PlannerSnapshotStatus, type PlannerStep, type PlannerStepDirective, type PlannerStepSnapshot, type PolicyContext, type PolicyVerdict, type ProceduralMemoryConfig, type PromptDiff, type PromptDiffBlock, type PromptEntry, type PromptJudgeCacheLike, type PromptLangfuseSyncOptions, PromptNotFoundError, PromptRefineOptions, PromptRefinementError, type PromptRefinementErrorOptions, type PromptRefinementFailureReason, type PromptRegistryContract, type PromptRegistryOptions, type PromptResolveOptions, type PromptTemplateVersion, type PromptValidateOptions, type PromptValidateTarget, PromptValidationError, type PromptValidationNote, type PromptValidationReport, type PromptValidationResult, type PromptValidationSeverity, type PromptVersion, type PromptsManagerContract, type PromptsManagerEntry, type PromptsManagerOptions, type PromptsManagerRegisterOptions, type PromptsValidateOptions, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, type Rag, type RagAsToolOptions, type RagConfig, type RagDocument, type RagLoaderMetadata, type RagLoaderOptions, type RagLoaderResult, type RagLoaderType, type RagReranker, type RankedItem, ReasoningEffort, type RecallOptions, type RecalledMemory, type RedactOptions, type RedactedError, type RedisCheckpointOptions, type RedisClientLike, type RedisInterruptOptions, type RedisSnapshotStoreOptions, RefinedPromptStoreLike, RefinedSystemPrompt, RefinedSystemPromptContract, RefinedSystemPromptOptions, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type ResolvedOrchestratorMemory, type ResolvedOutboundPolicy, type ResolvedPrompt, type ResumeOptions, type ResumeResult, type RetrieveOptions, type RetrieveResult, type RetrievedChunk, type RetryBackoff, type RetryConfig, type ReviewOutcome, type RouteContext, type RouterConfig, type RouterEntry, type RouterIntents, type RouterOutput, RoutingError, type RoutingErrorOptions, type RunFrame, SDKAdapterContract, SENSITIVE_HEADERS, SSE_DONE, type SaveSkillInput, type SaveSkillResult, type SaveSkillToolDeps, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SemanticMemoryConfig, type ServableExecutable, type ServeOptions, type SessionContextOverrides, type SessionContract, type SessionLock, type SessionSendResult, type SkillAnalyticsEvent, type SkillCatalogEntry, type SkillInjectMode, type SkillRecord, type SkillReviewGate, type SkillSource, type SkillsConfig, type SkillsContract, type SkillsStoreContract, type SnapshotStore, type SpawnSubAgentSpec, type SpeechData, SpeechGenerationResponse, SpeechModelConfig, SpeechModelContract, SpeechModelPricing, SpeechOptions, type SpeechParams, type SpeechReport, type SpeechResult, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, type StreamLike, type StreamObjectParams, StreamingToolGuardConfig, type SummarizeCallback, type SummarizeConfig, type SupervisorAgentCompletedPayload, type SupervisorAgentFailedPayload, type SupervisorAgentStartingPayload, type SupervisorAgentStreamingPayload, type SupervisorAsToolOptions, SupervisorCancelledError, type SupervisorCancelledErrorOptions, type SupervisorCancelledPayload, type SupervisorCompletedPayload, type SupervisorConfig, type SupervisorContract, SupervisorDriftError, type SupervisorDriftErrorOptions, SupervisorEmitter, type SupervisorErrorPayload, type SupervisorEvaluateVerdictPayload, type SupervisorEventHandler, type SupervisorEventHandlers, type SupervisorEventMap, type SupervisorExecuteOptions, SupervisorExecution, SupervisorFailedError, type SupervisorInput, type SupervisorIntentValue, type SupervisorIterationCompletedPayload, type SupervisorIterationStartingPayload, type SupervisorReport, type SupervisorResult, type SupervisorResumeOptions, type SupervisorRouterDecidedPayload, type SupervisorRouterDecidingPayload, SupervisorRoutingError, type SupervisorRoutingErrorOptions, type SupervisorSnapshot, type SupervisorSnapshotStatus, type SupervisorStartingPayload, type SupervisorStreamController, type SupervisorStreamEvent, type SupervisorTerminatedBy, type SyncGuardrailDetector, SystemPrompt, SystemPromptBlockContract, SystemPromptContract, SystemPromptMergeOptions, SystemPromptMergeSource, SystemPromptMeta, type TeamConfig, type TeamGate, type TeamGateFn, type TeamMemberValue, type TextInput, type ToolCall, ToolConfig, ToolContext, type ToolContract, type ToolEventMeta, ToolExecutionError, type ToolExecutionErrorOptions, type ToolInvokeResult, ToolMeta, ToolMode, type TopicFilterOptions, TranscribeOptions, type TranscribeParams, type TranscriptionData, TranscriptionModelConfig, TranscriptionModelContract, TranscriptionModelPricing, type TranscriptionReport, TranscriptionResponse, type TranscriptionResult, TranscriptionSegment, type TurnSnapshot, type Usage, type UsageEvent, VcrCassetteMissError, type VcrCassetteMissErrorOptions, type VcrMode, type VcrModel, type VcrOptions, type VectorStore, type WithoutIdentity, WorkflowCancelledError, type WorkflowCancelledErrorOptions, type WorkflowCancelledPayload, type WorkflowCompletedPayload, type WorkflowContext, type WorkflowDefinition, WorkflowDriftError, type WorkflowDriftErrorOptions, WorkflowError, type WorkflowErrorPayload, type WorkflowEventHandler, type WorkflowEventHandlers, type WorkflowEventMap, type WorkflowExecuteOptions, type WorkflowInstance, type WorkflowLoopWarningPayload, type WorkflowReport, type WorkflowResult, type WorkflowResumeOptions, type WorkflowRunOptions, type WorkflowSnapshot, type WorkflowStartingPayload, type WorkflowStepCompletedPayload, type WorkflowStepFailedPayload, type WorkflowStepRetryingPayload, type WorkflowStepSkippedPayload, type WorkflowStepStartingPayload, type WorkflowStepStreamingPayload, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, audioFromBuffer, audioFromFile, audioMediaTypeForFilename, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeImageCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, image, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, keywordReranker, llmReranker, loadHtml, loadPdf, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, loadText, loadWeb, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pgVectorStore, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, speech, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, transcribe, urlSource, vcr, vectorLiteral, withRunFrame, withoutRunFrame, workflow };
|
|
315
|
+
export { AIConfig, AIError, type AIErrorCode, type AIErrorOptions, type AckCallback, type AckConfig, type AckEntry, type AckRunEntry, type AckSnapshot, type AgentBranchSnapshot, AgentCancelledError, type AgentCancelledErrorOptions, type AgentCompletedPayload, type AgentConfig, type AgentContract, AgentDriftError, type AgentDriftErrorOptions, type AgentErrorPayload, type AgentEventHandler, type AgentEventMap, type AgentExecuteOptions, AgentExecutionError, AgentMaxTripsError, type AgentMaxTripsErrorOptions, type AgentMiddleware, type AgentMiddlewareExecuteHooks, type AgentMiddlewareSupervisorHooks, type AgentMiddlewareToolHooks, type AgentMiddlewareTripHooks, type AgentReport, type AgentResult, type AgentResumeOptions, type AgentSnapshot, type AgentSnapshotStatus, type AgentStartingPayload, type AgentStreamingPayload, type AgentToolCalledPayload, type AgentToolCallingFailedPayload, type AgentToolCallingPayload, type AgentToolEntry, type AgentTripCompletedPayload, type AgentTripStartedPayload, type Ai, type AiMatchers, type ApprovalDecision, type ApprovalDecisionType, type ApprovalHandler, ApprovalRejectedError, type ApprovalRejectedErrorOptions, type ApprovalRequest, type ApprovalRequestContext, Attachment, AttachmentPolicy, AttachmentSource, type AttemptEntry, AudioInput, type BaseReport, type BaseResult, type BatchItemHandler, type BatchItemResult, type BatchItemStatus, type BatchOptions, type BatchReport, type BatchResult, BinarySource, type BudgetContract, type BudgetContractDimension, type BudgetContractFallback, type BudgetContractViolation, type BudgetContractViolationMode, BudgetExceededError, type BudgetExceededErrorOptions, type BudgetFallbackSignal, type BudgetOptions, type BudgetPricing, type BudgetUnit, type CapturedMessage, type Cassette, type CassetteEntry, type CheckpointRecord, type CheckpointStore, type Chunk, type ChunkOptions, type ChunkType, type Citation, type ClassifierAgentEntry, type ClassifierCallback, type ClassifierConfig, type ClassifierContext, type ClassifierOutput, type ClassifierRefineContext, type ClassifierRefineResult, type ClassifierRunEntry, type ClassifierSnapshot, type CompactionResult, type CompleteEvent, ContentFilterError, type ContentFilterErrorOptions, ContentPart, ContextLengthExceededError, type ContextLengthExceededErrorOptions, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, type DatasetContract, type DatasetEntry, type DatasetOptions, type DecisionSource, type DispatchContext, type DispatchRawResult, END, EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage, EndSentinel, type EpisodicMemoryConfig, type ErrorCategory, type EvalCase, type EvalCaseResult, type EvalJudge, type EvalOptions, type EvalPredicate, type EvalReport, type EvalScore, type EvalScorer, type EvalScorerContext, type EvaluateBranchResult, type EvaluateContext, type EvaluateResult, type EventIdentity, ExecutableContract, type ExecutableTool, type ExecuteResult, type ExecutionReport, type ExecutionStatus, type ExportedPrompt, type ExportedPromptVersion, type ExportedRegistry, type ExtractJsonSchemaOptions, type FallbackAttempt, type FallbackModelContract, type FallbackModelOptions, type FallbackRetryPredicate, type FanOutOptions, type FanOutUnit, FinishReason, type FlagRecord, type FlowObserveOption, GeneratedAudio, GeneratedImage, type GuardOptions, type GuardrailAction, type GuardrailBlockEvent, type GuardrailCheck, type GuardrailCheckResult, type GuardrailDetector, type GuardrailDetectorContext, type GuardrailEscalation, type GuardrailFactory, type GuardrailMatch, type GuardrailOptions, type GuardrailPhase, type GuardrailVerdict, GuardrailViolationError, type GuardrailViolationErrorOptions, type HumanApprovalOptions, type HumanErrorCode, type ImageData, ImageGenerationOptions, ImageGenerationResponse, ImageModelConfig, ImageModelContract, ImageModelPricing, type ImageParams, type ImageReport, type ImageResult, ImageSource, type InjectionDetectorOptions, Instruction, InstructionContract, type IntentCallback, type IntentEntry, type IntentRunEntry, type IntentRunner, type IntentRunnerMap, type InterruptPolicy, type InterruptStore, InterruptSuspendedError, type InterruptSuspendedErrorOptions, InvalidRequestError, type IterationDecision, type IterationSnapshot, JUDGE_DEFAULT_REPAIR_ATTEMPTS, type JsonSchemaTarget, type JudgeAgentConfig, type JudgeConfig, type JudgeOutcome, type KeywordRerankerOptions, type LLMTrip, type LexicalDoc, type LineageStamp, type LlmRerankerOptions, type LoadHtmlOptions, type LoadPdfOptions, type LoadSkillInput, type LoadSkillResult, type LoadSkillToolDeps, type LoadTextOptions, type LoadWebOptions, type MatcherVerdict, MaxIterationsError, type MaxIterationsErrorOptions, MaxStepsExceededError, type MaxStepsExceededErrorOptions, type MemoryConfig, type MemoryContract, type MemoryItem, type MemoryTier, Message, type MiddlewareAgentRef, type MiddlewareContextByLevel, type MiddlewareExecuteContext, type MiddlewareLevel, type MiddlewareModelRef, type MiddlewareState, type MiddlewareSupervisorContext, type MiddlewareSupervisorRef, type MiddlewareToolContext, type MiddlewareTripContext, type MockImageCall, MockImageModel, type MockImageResponse, MockModel, type MockModelResponse, type MockRouterDecision, type MockRouterExhaustion, type MockRouterOptions, MockSDK, type MockSDKConfig, MockSkillsStore, type MockSpeechCall, MockSpeechModel, type MockSpeechResponse, type MockTranscriptionCall, MockTranscriptionModel, type MockTranscriptionResponse, ModelCallOptions, ModelCapabilities, ModelConfig, ModelContract, type ModelPricing, ModelResponse, ModelStreamChunk, ModelToolCallRequest, type MultiQueryOptions, type NamespacedStateAccessor, type Next, type NextStepResult, OPENAI_INSTALL_INSTRUCTIONS, type ObjectStreamEvent, type Observer, type OpenAiClientLike, type OpenAiModerationCreateBody, type OpenAiModerationOptions, type OpenAiModerationResponse, type OpenAiModerationResult, type OrchestratorAsToolOptions, type OrchestratorAwaitingStatus, OrchestratorCancelledError, type OrchestratorCancelledErrorOptions, type OrchestratorCommandHandlers, type OrchestratorCommands, type OrchestratorConfig, OrchestratorConfigError, type OrchestratorContract, OrchestratorDriftError, type OrchestratorDriftErrorOptions, OrchestratorEmitter, type OrchestratorEvent, type OrchestratorEventHandler, type OrchestratorEventHandlers, type OrchestratorEventMap, type OrchestratorEventName, type OrchestratorExecuteOptions, OrchestratorExecution, type OrchestratorExecutionParams, OrchestratorFailedError, type OrchestratorMemoryConfig, type OrchestratorReport, type OrchestratorReportStatus, type OrchestratorReportType, type OrchestratorResult, type OrchestratorResumeOptions, type OrchestratorSessionScope, type OrchestratorStreamController, type OutboundPolicy, OutboundPolicyError, PDF_PARSE_INSTALL_INSTRUCTIONS, type ParsedFrontmatter, type PendingInterrupt, type PendingInterruptStatus, Persona, PersonaContract, type PgCheckpointOptions, type PgClientLike, type PgInterruptOptions, type PgSnapshotStoreOptions, type PgVectorStoreInstance, type PgVectorStoreOptions, type PiiCategory, type PiiDetectorOptions, Placeholders, PlannerCancelledError, type PlannerCancelledErrorOptions, type PlannerCapability, type PlannerConfig, type PlannerContract, PlannerDriftError, type PlannerDriftErrorOptions, type PlannerExecuteOptions, PlannerFailedError, type PlannerPlan, PlannerPlanInvalidError, type PlannerReport, type PlannerReportType, type PlannerResult, type PlannerResumeOptions, type PlannerRunArgs, type PlannerSnapshot, type PlannerSnapshotStatus, type PlannerStep, type PlannerStepDirective, type PlannerStepSnapshot, type PolicyContext, type PolicyVerdict, type ProceduralMemoryConfig, type PromptDiff, type PromptDiffBlock, type PromptEntry, type PromptJudgeCacheLike, type PromptLangfuseSyncOptions, PromptNotFoundError, PromptRefineOptions, PromptRefinementError, type PromptRefinementErrorOptions, type PromptRefinementFailureReason, type PromptRegistryContract, type PromptRegistryOptions, type PromptResolveOptions, type PromptTemplateVersion, type PromptValidateOptions, type PromptValidateTarget, PromptValidationError, type PromptValidationNote, type PromptValidationReport, type PromptValidationResult, type PromptValidationSeverity, type PromptVersion, type PromptsManagerContract, type PromptsManagerEntry, type PromptsManagerOptions, type PromptsManagerRegisterOptions, type PromptsValidateOptions, ProviderAuthError, ProviderError, ProviderRateLimitError, type ProviderRateLimitErrorOptions, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, type Rag, type RagAsToolOptions, type RagConfig, type RagDocument, type RagLoaderMetadata, type RagLoaderOptions, type RagLoaderResult, type RagLoaderType, type RagReranker, type RankedItem, ReasoningEffort, type RecallOptions, type RecalledMemory, type RedactOptions, type RedactedError, type RedisCheckpointOptions, type RedisClientLike, type RedisInterruptOptions, type RedisSnapshotStoreOptions, RefinedPromptStoreLike, RefinedSystemPrompt, RefinedSystemPromptContract, RefinedSystemPromptOptions, type ReportStatus, type ReportType, ResolvedAttachment, type ResolvedIntentEntry, type ResolvedOrchestratorMemory, type ResolvedOutboundPolicy, type ResolvedPrompt, type ResumeOptions, type ResumeResult, type RetrieveOptions, type RetrieveResult, type RetrievedChunk, type RetryBackoff, type RetryConfig, type ReviewOutcome, type RouteContext, type RouterConfig, type RouterEntry, type RouterIntents, type RouterOutput, RoutingError, type RoutingErrorOptions, type RunFrame, SDKAdapterContract, SENSITIVE_HEADERS, SSE_DONE, type SaveSkillInput, type SaveSkillResult, type SaveSkillToolDeps, SchemaValidationError, type SchemaValidationErrorOptions, type SemanticCacheOptions, type SemanticMemoryConfig, type ServableExecutable, type ServeOptions, type SessionContextOverrides, type SessionContract, type SessionLock, type SessionSendResult, type SkillAnalyticsEvent, type SkillCatalogEntry, type SkillInjectMode, type SkillRecord, type SkillReviewGate, type SkillSource, type SkillsConfig, type SkillsContract, type SkillsStoreContract, type SnapshotStore, type SpawnSubAgentSpec, type SpeechData, SpeechGenerationResponse, SpeechModelConfig, SpeechModelContract, SpeechModelPricing, SpeechOptions, type SpeechParams, type SpeechReport, type SpeechResult, type StepAgentInput, type StepDefinition, StepFailedError, type StepFailedErrorOptions, type StepLocalEvents, type StepOutputSpec, type StepSnapshot, StorageFileShape, type StreamContract, type StreamController, type StreamEvent, type StreamEventBody, type StreamLike, type StreamObjectParams, StreamingToolGuardConfig, type SummarizeCallback, type SummarizeConfig, type SupervisorAgentCompletedPayload, type SupervisorAgentFailedPayload, type SupervisorAgentStartingPayload, type SupervisorAgentStreamingPayload, type SupervisorAsToolOptions, SupervisorCancelledError, type SupervisorCancelledErrorOptions, type SupervisorCancelledPayload, type SupervisorCompletedPayload, type SupervisorConfig, type SupervisorContract, SupervisorDriftError, type SupervisorDriftErrorOptions, SupervisorEmitter, type SupervisorErrorPayload, type SupervisorEvaluateVerdictPayload, type SupervisorEventHandler, type SupervisorEventHandlers, type SupervisorEventMap, type SupervisorExecuteOptions, SupervisorExecution, SupervisorFailedError, type SupervisorInput, type SupervisorIntentValue, type SupervisorIterationCompletedPayload, type SupervisorIterationStartingPayload, type SupervisorReport, type SupervisorResult, type SupervisorResumeOptions, type SupervisorRouterDecidedPayload, type SupervisorRouterDecidingPayload, SupervisorRoutingError, type SupervisorRoutingErrorOptions, type SupervisorSnapshot, type SupervisorSnapshotStatus, type SupervisorStartingPayload, type SupervisorStreamController, type SupervisorStreamEvent, type SupervisorTerminatedBy, type SyncGuardrailDetector, SystemPrompt, SystemPromptBlockContract, SystemPromptContract, SystemPromptMergeOptions, SystemPromptMergeSource, SystemPromptMeta, type TeamConfig, type TeamGate, type TeamGateFn, type TeamMemberValue, type TextInput, type ToolCall, ToolConfig, ToolContext, type ToolContract, type ToolEventMeta, ToolExecutionError, type ToolExecutionErrorOptions, type ToolInvokeResult, ToolMeta, ToolMode, type TopicFilterOptions, TranscribeOptions, type TranscribeParams, type TranscriptionData, TranscriptionModelConfig, TranscriptionModelContract, TranscriptionModelPricing, type TranscriptionReport, TranscriptionResponse, type TranscriptionResult, TranscriptionSegment, type TurnSnapshot, type Usage, type UsageEvent, VcrCassetteMissError, type VcrCassetteMissErrorOptions, type VcrMode, type VcrModel, type VcrOptions, type VectorStore, type WithoutIdentity, WorkflowCancelledError, type WorkflowCancelledErrorOptions, type WorkflowCancelledPayload, type WorkflowCompletedPayload, type WorkflowContext, type WorkflowDefinition, WorkflowDriftError, type WorkflowDriftErrorOptions, WorkflowError, type WorkflowErrorPayload, type WorkflowEventHandler, type WorkflowEventHandlers, type WorkflowEventMap, type WorkflowExecuteOptions, type WorkflowInstance, type WorkflowLoopWarningPayload, type WorkflowReport, type WorkflowResult, type WorkflowResumeOptions, type WorkflowRunOptions, type WorkflowSnapshot, type WorkflowStartingPayload, type WorkflowStepCompletedPayload, type WorkflowStepFailedPayload, type WorkflowStepRetryingPayload, type WorkflowStepSkippedPayload, type WorkflowStepStartingPayload, type WorkflowStepStreamingPayload, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, audioFromBuffer, audioFromFile, audioMediaTypeForFilename, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeImageCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, formatCriteria, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, image, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, judgePromptBody, keywordReranker, llmReranker, loadHtml, loadPdf, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, loadText, loadWeb, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pgVectorStore, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, speech, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, transcribe, urlSource, vcr, vectorLiteral, withRunFrame, withoutRunFrame, workflow };
|
|
315
316
|
import "./ai.mjs";
|
|
316
317
|
import "./config.mjs";
|
|
317
318
|
import "./testing/matchers.mjs";
|
package/esm/index.mjs
CHANGED
|
@@ -78,6 +78,7 @@ import { resolveSource } from "./skills/sources/index.mjs";
|
|
|
78
78
|
import { skills } from "./skills/skills.mjs";
|
|
79
79
|
import { MockSkillsStore } from "./skills/store/mock-skills-store.mjs";
|
|
80
80
|
import { memory as memory$2 } from "./memory/memory.mjs";
|
|
81
|
+
import "./memory/index.mjs";
|
|
81
82
|
import { proceduralSkillStore } from "./skills/store/procedural-skill-store.mjs";
|
|
82
83
|
import { runReviewGate } from "./skills/review-gate.mjs";
|
|
83
84
|
import "./skills/index.mjs";
|
|
@@ -168,6 +169,7 @@ import { Instruction, instruction } from "./system-prompt/instruction.mjs";
|
|
|
168
169
|
import { Persona, persona } from "./system-prompt/persona.mjs";
|
|
169
170
|
import { RefinedSystemPrompt } from "./system-prompt/refined-system-prompt.mjs";
|
|
170
171
|
import { SystemPrompt, systemPrompt } from "./system-prompt/system-prompt.mjs";
|
|
172
|
+
import { formatCriteria, judgePromptBody } from "./prompts/prompts-validate.mjs";
|
|
171
173
|
import { defaultPromptsManager, promptKey, prompts } from "./prompts/prompts-manager.mjs";
|
|
172
174
|
import { chunk } from "./rag/chunk/chunk.mjs";
|
|
173
175
|
import { cacheVectorStore } from "./rag/store/cache-vector-store.mjs";
|
|
@@ -214,4 +216,4 @@ import "./workflow/index.mjs";
|
|
|
214
216
|
import { matchConverge, matchOutputShape, matchPassStep, matchRouteTo } from "./testing/matcher-logic.mjs";
|
|
215
217
|
import { registerAiMatchers } from "./testing/register-lazy.mjs";
|
|
216
218
|
|
|
217
|
-
export { AIError, AgentCancelledError, AgentDriftError, AgentExecutionError, AgentMaxTripsError, ApprovalRejectedError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, END, GuardrailViolationError, Instruction, InterruptSuspendedError, InvalidRequestError, JUDGE_DEFAULT_REPAIR_ATTEMPTS, MaxIterationsError, MaxStepsExceededError, MockImageModel, MockModel, MockSDK, MockSkillsStore, MockSpeechModel, MockTranscriptionModel, OPENAI_INSTALL_INSTRUCTIONS, OrchestratorCancelledError, OrchestratorConfigError, OrchestratorDriftError, OrchestratorEmitter, OrchestratorExecution, OrchestratorFailedError, OutboundPolicyError, PDF_PARSE_INSTALL_INSTRUCTIONS, Persona, PlannerCancelledError, PlannerDriftError, PlannerFailedError, PlannerPlanInvalidError, PromptNotFoundError, PromptRefinementError, PromptValidationError, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RefinedSystemPrompt, RoutingError, SENSITIVE_HEADERS, SSE_DONE, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, VcrCassetteMissError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, audioFromBuffer, audioFromFile, audioMediaTypeForFilename, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeImageCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, image, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, keywordReranker, llmReranker, loadHtml, loadPdf, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, loadText, loadWeb, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pgVectorStore, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, speech, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, transcribe, urlSource, vcr, vectorLiteral, withRunFrame, withoutRunFrame, workflow };
|
|
219
|
+
export { AIError, AgentCancelledError, AgentDriftError, AgentExecutionError, AgentMaxTripsError, ApprovalRejectedError, BudgetExceededError, ContentFilterError, ContextLengthExceededError, DEFAULT_HASH_OPTIONS, DEFAULT_SENSITIVE_KEYS, END, GuardrailViolationError, Instruction, InterruptSuspendedError, InvalidRequestError, JUDGE_DEFAULT_REPAIR_ATTEMPTS, MaxIterationsError, MaxStepsExceededError, MockImageModel, MockModel, MockSDK, MockSkillsStore, MockSpeechModel, MockTranscriptionModel, OPENAI_INSTALL_INSTRUCTIONS, OrchestratorCancelledError, OrchestratorConfigError, OrchestratorDriftError, OrchestratorEmitter, OrchestratorExecution, OrchestratorFailedError, OutboundPolicyError, PDF_PARSE_INSTALL_INSTRUCTIONS, Persona, PlannerCancelledError, PlannerDriftError, PlannerFailedError, PlannerPlanInvalidError, PromptNotFoundError, PromptRefinementError, PromptValidationError, ProviderAuthError, ProviderError, ProviderRateLimitError, ProviderTimeoutError, QuotaExceededError, REPORT_SCHEMA_VERSION, RefinedSystemPrompt, RoutingError, SENSITIVE_HEADERS, SSE_DONE, SchemaValidationError, StepFailedError, SupervisorCancelledError, SupervisorDriftError, SupervisorEmitter, SupervisorExecution, SupervisorFailedError, SupervisorRoutingError, SystemPrompt, ToolExecutionError, VcrCassetteMissError, WorkflowCancelledError, WorkflowDriftError, WorkflowError, accumulateCost, agent, ai, approximateTokenCount, assertUrlAllowed, audioFromBuffer, audioFromFile, audioMediaTypeForFilename, batch, bm25Rank, budget, buildCatalog, buildPlanSystemPrompt, buildRouterContextMessage, cacheVectorStore, captureChildReport, memory as checkpointMemory, pg as checkpointPg, redis as checkpointRedis, chunk, collectStreamObject, composeMiddleware, computeCost, computeImageCost, computeOrchestratorSignature, computeSignature as computePlannerSignature, computeSignature$1 as computeSignature, computeSignature$2 as computeSupervisorSignature, contains, createAgentStream, createCommandDispatcher as createOrchestratorCommandDispatcher, createOrchestratorStream, createCancelledError as createSupervisorCancelledError, createSupervisorStream, currentRunFrame, dataset, defaultPromptsManager, diff, directorySource, encodeSSE, evalScorers, evaluatePolicy, exact, executableToTool, extractJsonLenient, extractJsonPayload, extractJsonSchema, extractUserText, fallbackModel, fanOut, fetchTextWithPolicy, forTool, formatCriteria, fromJSON, generateRunId, getAIConfig, getObservers, guard, guardedFetch, guardrail, hashRequest, humanApproval, hybridRank, image, inProcessSessionLock, injectMemories as injectOrchestratorMemories, injection, instruction, memory$1 as interruptMemory, pg$1 as interruptPg, redis$1 as interruptRedis, isExecutableTool, isObserveAll, isPrivateOrReservedIp, judge, judgePromptBody, keywordReranker, llmReranker, loadHtml, loadPdf, loadRecord, loadSkillTool, loadSnapshotForResume as loadSupervisorSnapshotForResume, loadText, loadWeb, matchConverge, matchOutputShape, matchPassStep, matchRouteTo, memory$2 as memory, mergeUsage, mockAgent, mockRouter, moderation, multiQuery, namespacedState, noopSessionLock, normalizeAgentTools, onConfigApplied, orchestrator, asTool as orchestratorAsTool, memoryQueryFromInput as orchestratorMemoryQueryFromInput, outcomeTextFromTurn as orchestratorOutcomeTextFromTurn, parseFrontmatter, parsePartialJson, parseTags, persistSupervisorSnapshot, persona, pgVectorStore, pii, planSchema, planner, predicate, prepareAttachmentPart, proceduralSkillStore, prompt, promptKey, prompts, rag, readBudgetFallbackSignal, readTextCapped, recallForTurn as recallOrchestratorMemory, reciprocalRankFusion, redact, redactError, redactHeaders, registerAiMatchers, registerObserver, rememberTurnOutcome as rememberOrchestratorTurnOutcome, renderCatalogPrompt, renderPlaceholders, resolveAttachment, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, resolveIntentEntries, resolveObservers, resolveOrchestratorMemory, resolveOutboundPolicy, resolveSource, resume, router, runEval, runResume as runOrchestratorResume, runTurn as runOrchestratorTurn, runPipeline, runReviewGate, safeJsonParse, saveSkillTool, scrubSecrets, semanticCache, semanticPreselect, serve, setAIConfig, setObserveAll, skills, memory$3 as snapshotMemory, pg$2 as snapshotPg, redis$2 as snapshotRedis, spawnSubAgent, speech, stampReportLineage, step, storeSource, streamObject, streamTurn as streamOrchestratorTurn, streamToSSE, supervisor, asTool$1 as supervisorAsTool, systemPrompt, team, toJSON, toJUnit, tool, topic, transcribe, urlSource, vcr, vectorLiteral, withRunFrame, withoutRunFrame, workflow };
|
package/esm/prompts/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ExportedPrompt, ExportedPromptVersion, ExportedRegistry, PromptDiff, PromptDiffBlock, PromptJudgeCacheLike, PromptTemplateVersion, PromptValidateTarget, PromptValidationResult, PromptsManagerOptions, PromptsValidateOptions } from "./prompts-manager.type.mjs";
|
|
2
2
|
import { PromptsManagerContract, PromptsManagerEntry, PromptsManagerRegisterOptions } from "./prompts-manager.contract.mjs";
|
|
3
|
-
import { defaultPromptsManager, promptKey, prompts } from "./prompts-manager.mjs";
|
|
3
|
+
import { defaultPromptsManager, promptKey, prompts } from "./prompts-manager.mjs";
|
|
4
|
+
import { JudgeOutcome, formatCriteria, judgePromptBody } from "./prompts-validate.mjs";
|
package/esm/prompts/index.mjs
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ModelContract } from "../contracts/model.contract.mjs";
|
|
2
|
+
//#region ../@warlock.js/ai/src/prompts/prompts-validate.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Turn caller-supplied `criteria` into the judge rubric that replaces the
|
|
5
|
+
* built-in {@link PROMPT_JUDGE_RUBRIC}. A single string is used verbatim;
|
|
6
|
+
* a list is joined into a numbered rule set the judge must check ALL of.
|
|
7
|
+
* Returns `undefined` for an empty/blank input, so the caller falls back
|
|
8
|
+
* to the default rubric.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* formatCriteria(["Addresses the user by {{name}}", "Under 200 words"]);
|
|
12
|
+
* // → "Grade the system prompt against ALL of these criteria …\n1. …\n2. …"
|
|
13
|
+
*/
|
|
14
|
+
declare function formatCriteria(criteria: string | readonly string[] | undefined): string | undefined;
|
|
15
|
+
/** Outcome of the optional LLM-as-judge pass over a resolved prompt body. */
|
|
16
|
+
type JudgeOutcome = {
|
|
17
|
+
/**
|
|
18
|
+
* The judge score in `[0, 1]`, or `undefined` when the judge degraded
|
|
19
|
+
* (errored, returned no parseable verdict, or threw) — never a misleading
|
|
20
|
+
* `0` masquerading as a real verdict.
|
|
21
|
+
*/
|
|
22
|
+
readonly score?: number; /** Human-readable issues raised by the judge (its reason, or a degrade note). */
|
|
23
|
+
readonly issues: string[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Run the optional LLM-as-judge pass over a resolved prompt body, REUSING the
|
|
27
|
+
* eval `judge` scorer (the same path `prompt().validate` uses) so there is no
|
|
28
|
+
* second judging implementation.
|
|
29
|
+
*
|
|
30
|
+
* **Nova-safe by contract.** The judge NEVER throws here: the eval scorer
|
|
31
|
+
* already degrades a broken judge to `score: 0` with a failure reason, and any
|
|
32
|
+
* exception that still escapes (model wiring, agent construction) is caught.
|
|
33
|
+
* Both degrade paths surface `score: undefined` plus an issue note — so a flaky
|
|
34
|
+
* judge can never fail an otherwise-valid prompt.
|
|
35
|
+
*
|
|
36
|
+
* @param text - The resolved prompt body under evaluation.
|
|
37
|
+
* @param model - The model that powers the judge agent.
|
|
38
|
+
* @param criteria - Optional caller rules that REPLACE the built-in rubric
|
|
39
|
+
* ({@link formatCriteria}). Omitted ⇒ the default prompt-quality rubric.
|
|
40
|
+
*/
|
|
41
|
+
declare function judgePromptBody(text: string, model: ModelContract, criteria?: string | readonly string[]): Promise<JudgeOutcome>;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { JudgeOutcome, formatCriteria, judgePromptBody };
|
|
44
|
+
//# sourceMappingURL=prompts-validate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts-validate.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/prompts/prompts-validate.ts"],"mappings":";;;;;;;;;AAiMuB;;;;iBAzDP,cAAA,CACd,QAAgD;;KAyBtC,YAAA;;;;;;WAMD,KAAA;WAEA,MAAM;AAAA;;;;;;;;;;;;;;;;;iBAmBK,eAAA,CACpB,IAAA,UACA,KAAA,EAAO,aAAA,EACP,QAAA,gCACC,OAAA,CAAQ,YAAA"}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/redact.ts"],"mappings":";;AAMA;;;;AAgBC;cAhBY,sBAAA;;cAmBA,iBAAA;AAAA,KASD,aAAA;EAFX,iFAIC,IAAA,aAFuB;EAIvB,WAAA,WAJuB;EAMvB,QAAA;AAAA;;;AAAQ;AAqBV;;;;;;;iBAAgB,MAAA,IAAU,KAAA,EAAO,CAAA,EAAG,OAAA,GAAS,aAAA,GAAqB,CAAA;;;;;;
|
|
1
|
+
{"version":3,"file":"redact.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/redact.ts"],"mappings":";;AAMA;;;;AAgBC;cAhBY,sBAAA;;cAmBA,iBAAA;AAAA,KASD,aAAA;EAFX,iFAIC,IAAA,aAFuB;EAIvB,WAAA,WAJuB;EAMvB,QAAA;AAAA;;;AAAQ;AAqBV;;;;;;;iBAAgB,MAAA,IAAU,KAAA,EAAO,CAAA,EAAG,OAAA,GAAS,aAAA,GAAqB,CAAA;;;;;;iBAkDlD,aAAA,CACd,OAAA,EAAS,OAAA,GAAU,MAAA,+BACnB,WAAA,YACC,MAAA;;AArDgE;AAkDnE;;;;iBAuCgB,YAAA,CAAa,IAAY;;;;;;;;KAe7B,aAAA;EACV,IAAA;EACA,OAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;AAAA;AAAA,iBAGc,WAAA,CACd,KAAA,WACA,OAAA;EAAW,YAAA;AAAA,IAA2B,aAAA,GACrC,aAAa"}
|
package/esm/security/redact.mjs
CHANGED
|
@@ -57,8 +57,14 @@ function redact(value, options = {}) {
|
|
|
57
57
|
if (depth >= maxDepth || seen.has(input)) return placeholder;
|
|
58
58
|
seen.add(input);
|
|
59
59
|
if (Array.isArray(input)) return input.map((item) => walk(item, depth + 1));
|
|
60
|
+
const source = input instanceof Error ? {
|
|
61
|
+
...input,
|
|
62
|
+
name: input.name,
|
|
63
|
+
message: input.message,
|
|
64
|
+
stack: input.stack
|
|
65
|
+
} : input;
|
|
60
66
|
const out = {};
|
|
61
|
-
for (const [key, val] of Object.entries(
|
|
67
|
+
for (const [key, val] of Object.entries(source)) out[key] = keyIsSensitive(key, fragments) ? placeholder : walk(val, depth + 1);
|
|
62
68
|
return out;
|
|
63
69
|
};
|
|
64
70
|
return walk(value, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/redact.ts"],"sourcesContent":["/**\n * Default set of sensitive key fragments (matched case-insensitively as\n * substrings of an object key). Covers the secrets that leak through\n * recorded requests, error causes, and trace payloads: auth headers, API\n * keys, cookies, tokens, passwords, and private keys.\n */\nexport const DEFAULT_SENSITIVE_KEYS: readonly string[] = [\n \"authorization\",\n \"x-api-key\",\n \"api-key\",\n \"apikey\",\n \"cookie\",\n \"set-cookie\",\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"access_token\",\n \"refresh_token\",\n \"client_secret\",\n \"private_key\",\n \"session\",\n];\n\n/** HTTP header names always stripped from a serialized error/cause. */\nexport const SENSITIVE_HEADERS: readonly string[] = [\n \"authorization\",\n \"x-api-key\",\n \"api-key\",\n \"cookie\",\n \"set-cookie\",\n \"proxy-authorization\",\n];\n\nexport type RedactOptions = {\n /** Extra key fragments to redact, merged with {@link DEFAULT_SENSITIVE_KEYS}. */\n keys?: string[];\n /** Replacement for a redacted value. Default `\"[redacted]\"`. */\n placeholder?: string;\n /** Maximum recursion depth before bailing out. Default `8`. */\n maxDepth?: number;\n};\n\nconst DEFAULT_PLACEHOLDER = \"[redacted]\";\nconst DEFAULT_MAX_DEPTH = 8;\n\nfunction keyIsSensitive(key: string, fragments: string[]): boolean {\n const lower = key.toLowerCase();\n return fragments.some(fragment => lower.includes(fragment));\n}\n\n/**\n * Deep-copy `value` with any property whose KEY matches a sensitive\n * fragment replaced by the placeholder. Arrays are walked element-wise;\n * circular references and over-deep trees collapse to the placeholder.\n * Primitives pass through untouched (redaction is key-driven, not\n * value-driven — it never guesses at a bare string being a secret).\n *\n * Shared by VCR cassettes (S2), Panoptic content capture, and the error /\n * cause serializer (S4) so there is ONE redaction policy, not three.\n */\nexport function redact<T>(value: T, options: RedactOptions = {}): T {\n const fragments = [...DEFAULT_SENSITIVE_KEYS, ...(options.keys ?? [])].map(k =>\n k.toLowerCase(),\n );\n const placeholder = options.placeholder ?? DEFAULT_PLACEHOLDER;\n const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;\n const seen = new WeakSet<object>();\n\n const walk = (input: unknown, depth: number): unknown => {\n if (input === null || typeof input !== \"object\") {\n return input;\n }\n if (depth >= maxDepth || seen.has(input)) {\n return placeholder;\n }\n seen.add(input as object);\n\n if (Array.isArray(input)) {\n return input.map(item => walk(item, depth + 1));\n }\n\n const out: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(
|
|
1
|
+
{"version":3,"file":"redact.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/redact.ts"],"sourcesContent":["/**\n * Default set of sensitive key fragments (matched case-insensitively as\n * substrings of an object key). Covers the secrets that leak through\n * recorded requests, error causes, and trace payloads: auth headers, API\n * keys, cookies, tokens, passwords, and private keys.\n */\nexport const DEFAULT_SENSITIVE_KEYS: readonly string[] = [\n \"authorization\",\n \"x-api-key\",\n \"api-key\",\n \"apikey\",\n \"cookie\",\n \"set-cookie\",\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"access_token\",\n \"refresh_token\",\n \"client_secret\",\n \"private_key\",\n \"session\",\n];\n\n/** HTTP header names always stripped from a serialized error/cause. */\nexport const SENSITIVE_HEADERS: readonly string[] = [\n \"authorization\",\n \"x-api-key\",\n \"api-key\",\n \"cookie\",\n \"set-cookie\",\n \"proxy-authorization\",\n];\n\nexport type RedactOptions = {\n /** Extra key fragments to redact, merged with {@link DEFAULT_SENSITIVE_KEYS}. */\n keys?: string[];\n /** Replacement for a redacted value. Default `\"[redacted]\"`. */\n placeholder?: string;\n /** Maximum recursion depth before bailing out. Default `8`. */\n maxDepth?: number;\n};\n\nconst DEFAULT_PLACEHOLDER = \"[redacted]\";\nconst DEFAULT_MAX_DEPTH = 8;\n\nfunction keyIsSensitive(key: string, fragments: string[]): boolean {\n const lower = key.toLowerCase();\n return fragments.some(fragment => lower.includes(fragment));\n}\n\n/**\n * Deep-copy `value` with any property whose KEY matches a sensitive\n * fragment replaced by the placeholder. Arrays are walked element-wise;\n * circular references and over-deep trees collapse to the placeholder.\n * Primitives pass through untouched (redaction is key-driven, not\n * value-driven — it never guesses at a bare string being a secret).\n *\n * Shared by VCR cassettes (S2), Panoptic content capture, and the error /\n * cause serializer (S4) so there is ONE redaction policy, not three.\n */\nexport function redact<T>(value: T, options: RedactOptions = {}): T {\n const fragments = [...DEFAULT_SENSITIVE_KEYS, ...(options.keys ?? [])].map(k =>\n k.toLowerCase(),\n );\n const placeholder = options.placeholder ?? DEFAULT_PLACEHOLDER;\n const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;\n const seen = new WeakSet<object>();\n\n const walk = (input: unknown, depth: number): unknown => {\n if (input === null || typeof input !== \"object\") {\n return input;\n }\n if (depth >= maxDepth || seen.has(input)) {\n return placeholder;\n }\n seen.add(input as object);\n\n if (Array.isArray(input)) {\n return input.map(item => walk(item, depth + 1));\n }\n\n // `name` / `message` / `stack` sit on Error's prototype chain (or as\n // non-enumerable own properties), so a plain `Object.entries()` walk\n // sees none of them — a raw Error `cause` would otherwise collapse to\n // `{}`. Project them explicitly; own enumerable extras (`code`,\n // `cause`, custom AIError fields) still merge in below and recurse\n // normally, so a chained `cause` that is itself an Error is unwrapped\n // the same way.\n const source: Record<string, unknown> =\n input instanceof Error\n ? { ...input, name: input.name, message: input.message, stack: input.stack }\n : (input as Record<string, unknown>);\n\n const out: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(source)) {\n out[key] = keyIsSensitive(key, fragments)\n ? placeholder\n : walk(val, depth + 1);\n }\n return out;\n };\n\n return walk(value, 0) as T;\n}\n\n/**\n * Strip sensitive HTTP headers from a `Headers` instance or a plain\n * header record, returning a redacted plain object. Header names are\n * matched case-insensitively against {@link SENSITIVE_HEADERS}.\n */\nexport function redactHeaders(\n headers: Headers | Record<string, unknown> | undefined,\n placeholder: string = DEFAULT_PLACEHOLDER,\n): Record<string, unknown> {\n if (!headers) return {};\n\n const entries: Array<[string, unknown]> =\n headers instanceof Headers\n ? [...headers.entries()]\n : Object.entries(headers);\n\n const out: Record<string, unknown> = {};\n for (const [key, val] of entries) {\n out[key] = SENSITIVE_HEADERS.includes(key.toLowerCase()) ? placeholder : val;\n }\n return out;\n}\n\n/**\n * Patterns for secrets that hide in FREE TEXT (error messages, stack\n * traces, log lines) where the key-based {@link redact} can't reach them.\n * Each entry replaces the secret with `[redacted]` while keeping\n * surrounding context.\n */\nconst SECRET_PATTERNS: ReadonlyArray<readonly [RegExp, string]> = [\n [/\\bBearer\\s+[A-Za-z0-9._~+/-]+=*/gi, \"Bearer [redacted]\"],\n [/\\b(authorization|x-api-key|api[_-]?key|cookie)(\"?\\s*[:=]\\s*\"?)[^\\s\",}]+/gi, \"$1$2[redacted]\"],\n [/\\bsk-[A-Za-z0-9]{16,}\\b/g, \"[redacted]\"], // OpenAI-style keys\n [/\\bxox[baprs]-[A-Za-z0-9-]{8,}\\b/g, \"[redacted]\"], // Slack tokens\n [/\\bgh[pousr]_[A-Za-z0-9]{20,}\\b/g, \"[redacted]\"], // GitHub tokens\n [/\\bAKIA[0-9A-Z]{16}\\b/g, \"[redacted]\"], // AWS access key ids\n];\n\n/**\n * Scrub secrets that appear in free-form text — error messages, stack\n * traces, exported log lines. Complements {@link redact} (which is key-\n * driven and can't see a token embedded in a string). Used by the trace /\n * error serializer (S4) before a message or stack is stored or exported.\n */\nexport function scrubSecrets(text: string): string {\n let out = text;\n for (const [pattern, replacement] of SECRET_PATTERNS) {\n out = out.replace(pattern, replacement);\n }\n return out;\n}\n\n/**\n * Serialized, secret-free view of an error. `stack` is omitted by default\n * (it can embed local paths, endpoints, and tokens); pass\n * `includeStack: true` only for a trusted local sink. The retained\n * `cause` is deep-redacted via {@link redact}, so a raw provider SDK error\n * carrying `Authorization` / `x-api-key` on `cause.headers` is sanitized.\n */\nexport type RedactedError = {\n name: string;\n message: string;\n code?: string;\n cause?: unknown;\n stack?: string;\n};\n\nexport function redactError(\n error: unknown,\n options: { includeStack?: boolean } & RedactOptions = {},\n): RedactedError {\n const { includeStack, ...redactOptions } = options;\n\n if (error === null || typeof error !== \"object\") {\n return { name: \"Error\", message: String(error) };\n }\n\n const err = error as {\n name?: unknown;\n message?: unknown;\n code?: unknown;\n cause?: unknown;\n stack?: unknown;\n };\n\n const result: RedactedError = {\n name: typeof err.name === \"string\" ? err.name : \"Error\",\n message: typeof err.message === \"string\" ? err.message : String(error),\n };\n\n if (typeof err.code === \"string\") {\n result.code = err.code;\n }\n if (err.cause !== undefined) {\n result.cause =\n err.cause !== null && typeof err.cause === \"object\"\n ? redact(err.cause, redactOptions)\n : err.cause;\n }\n if (includeStack && typeof err.stack === \"string\") {\n result.stack = err.stack;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,yBAA4C;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,oBAAuC;CAClD;CACA;CACA;CACA;CACA;CACA;AACF;AAWA,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB;AAE1B,SAAS,eAAe,KAAa,WAA8B;CACjE,MAAM,QAAQ,IAAI,YAAY;CAC9B,OAAO,UAAU,MAAK,aAAY,MAAM,SAAS,QAAQ,CAAC;AAC5D;;;;;;;;;;;AAYA,SAAgB,OAAU,OAAU,UAAyB,CAAC,GAAM;CAClE,MAAM,YAAY,CAAC,GAAG,wBAAwB,GAAI,QAAQ,QAAQ,CAAC,CAAE,CAAC,CAAC,KAAI,MACzE,EAAE,YAAY,CAChB;CACA,MAAM,cAAc,QAAQ,eAAe;CAC3C,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,uBAAO,IAAI,QAAgB;CAEjC,MAAM,QAAQ,OAAgB,UAA2B;EACvD,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;EAET,IAAI,SAAS,YAAY,KAAK,IAAI,KAAK,GACrC,OAAO;EAET,KAAK,IAAI,KAAe;EAExB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAI,SAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC;EAUhD,MAAM,SACJ,iBAAiB,QACb;GAAE,GAAG;GAAO,MAAM,MAAM;GAAM,SAAS,MAAM;GAAS,OAAO,MAAM;EAAM,IACxE;EAEP,MAAM,MAA+B,CAAC;EACtC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,MAAM,GAC5C,IAAI,OAAO,eAAe,KAAK,SAAS,IACpC,cACA,KAAK,KAAK,QAAQ,CAAC;EAEzB,OAAO;CACT;CAEA,OAAO,KAAK,OAAO,CAAC;AACtB;;;;;;AAOA,SAAgB,cACd,SACA,cAAsB,qBACG;CACzB,IAAI,CAAC,SAAS,OAAO,CAAC;CAEtB,MAAM,UACJ,mBAAmB,UACf,CAAC,GAAG,QAAQ,QAAQ,CAAC,IACrB,OAAO,QAAQ,OAAO;CAE5B,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,KAAK,QAAQ,SACvB,IAAI,OAAO,kBAAkB,SAAS,IAAI,YAAY,CAAC,IAAI,cAAc;CAE3E,OAAO;AACT;;;;;;;AAQA,MAAM,kBAA4D;CAChE,CAAC,qCAAqC,mBAAmB;CACzD,CAAC,6EAA6E,gBAAgB;CAC9F,CAAC,4BAA4B,YAAY;CACzC,CAAC,oCAAoC,YAAY;CACjD,CAAC,mCAAmC,YAAY;CAChD,CAAC,yBAAyB,YAAY;AACxC;;;;;;;AAQA,SAAgB,aAAa,MAAsB;CACjD,IAAI,MAAM;CACV,KAAK,MAAM,CAAC,SAAS,gBAAgB,iBACnC,MAAM,IAAI,QAAQ,SAAS,WAAW;CAExC,OAAO;AACT;AAiBA,SAAgB,YACd,OACA,UAAsD,CAAC,GACxC;CACf,MAAM,EAAE,cAAc,GAAG,kBAAkB;CAE3C,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;EAAE,MAAM;EAAS,SAAS,OAAO,KAAK;CAAE;CAGjD,MAAM,MAAM;CAQZ,MAAM,SAAwB;EAC5B,MAAM,OAAO,IAAI,SAAS,WAAW,IAAI,OAAO;EAChD,SAAS,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU,OAAO,KAAK;CACvE;CAEA,IAAI,OAAO,IAAI,SAAS,UACtB,OAAO,OAAO,IAAI;CAEpB,IAAI,IAAI,UAAU,QAChB,OAAO,QACL,IAAI,UAAU,QAAQ,OAAO,IAAI,UAAU,WACvC,OAAO,IAAI,OAAO,aAAa,IAC/B,IAAI;CAEZ,IAAI,gBAAgB,OAAO,IAAI,UAAU,UACvC,OAAO,QAAQ,IAAI;CAGrB,OAAO;AACT"}
|
package/esm/skills/catalog.mjs
CHANGED
|
@@ -31,7 +31,7 @@ function probeEmbedderPeer() {
|
|
|
31
31
|
if (loadingPromise) return loadingPromise;
|
|
32
32
|
loadingPromise = (async () => {
|
|
33
33
|
try {
|
|
34
|
-
await import("
|
|
34
|
+
await import("@warlock.js/ai-openai");
|
|
35
35
|
isEmbedderPeerInstalled = true;
|
|
36
36
|
} catch {
|
|
37
37
|
isEmbedderPeerInstalled = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedural-skill-store.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/store/procedural-skill-store.ts"],"sourcesContent":["import type { MemoryContract } from \"../../contracts/memory/memory.contract\";\nimport type { ProceduralMemoryConfig } from \"../../contracts/memory/memory-config.type\";\nimport { memory } from \"../../memory\";\nimport type {\n SkillCatalogEntry,\n SkillRecord,\n} from \"../contracts/skill-record.type\";\nimport type { SkillsStoreContract } from \"../contracts/skills-store.contract\";\n\n/**\n * Metadata a procedural memory carries to round-trip a skill. `recall()`\n * surfaces `metadata` verbatim, so the skill's identity (name, version,\n * provenance, description, tags) rides here while the procedure body lives\n * in the memory's `text`.\n */\ntype ProceduralSkillMeta = {\n /** Marks the record as a skill (vs. a plain procedure) so `list` can scope. */\n skill: true;\n /** Skill name — the catalog key (also the memory `id`). */\n name: string;\n /** Provenance flag round-tripped onto the SkillRecord. */\n type: \"candidate\" | \"promoted\";\n /** Catalog line. */\n description: string;\n /** Monotonic version — bumped on promote. */\n version: number;\n /** Optional scope tags. */\n tags?: string[];\n};\n\n/** A recalled skill entry — the procedure body plus its skill metadata. */\ntype ProceduralSkillEntry = { body: string; meta: ProceduralSkillMeta };\n\nconst RECALL_K = 1000;\n\n/**\n * {@link SkillsStoreContract} backed by the procedural memory tier\n * (`ai.memory({ procedural })`). **The unification** the design calls for:\n * \"promote a proven procedural memory to a named skill\" and \"save a\n * self-authored skill\" are the SAME machinery — one store, two entry\n * points. No fifth `MemoryTier` is added; the existing `\"procedural\"` tier\n * is reused verbatim.\n *\n * - `saveCandidate` ⇒ `memory.remember({ tier: \"procedural\", metadata: { type: \"candidate\" } })`.\n * - `promote` ⇒ re-remembers the same id with `type: \"promoted\"` and\n * `version + 1`, which the procedural tier reinforces (increments `uses`).\n * - `list` / `load` map `memory.recall(..., { tier: \"procedural\" })` ⇒\n * `RecalledMemory[]` ⇒ `SkillCatalogEntry[]` / `SkillRecord`, filtering\n * out inert candidates so they can never be catalogued or injected.\n *\n * @example\n * const store = proceduralSkillStore({ embedder, store: cacheDriver });\n * const lib = skills({ name: \"learned\", sources: [{ type: \"store\", store }], review: gate });\n */\nexport function proceduralSkillStore(\n config: ProceduralMemoryConfig & { name?: string; recallQuery?: string },\n): SkillsStoreContract {\n const store: MemoryContract = memory({\n name: config.name ?? \"skills.procedural\",\n working: false,\n defaultTier: \"procedural\",\n procedural: {\n embedder: config.embedder,\n store: config.store,\n namespace: config.namespace,\n reinforcementWeight: config.reinforcementWeight,\n },\n });\n\n // The procedural tier recalls by similarity to a query; for a full\n // catalog listing we recall against a broad seed with a large `k` and a\n // zero floor so every stored skill comes back.\n const recallQuery = config.recallQuery ?? \"skill procedure how-to\";\n\n const recallAll = async (): Promise<ProceduralSkillEntry[]> => {\n const hits = await store.recall(recallQuery, {\n tier: \"procedural\",\n k: RECALL_K,\n threshold: 0,\n });\n\n return hits\n .map((hit) => ({ body: hit.text, meta: hit.metadata as ProceduralSkillMeta | undefined }))\n .filter((entry): entry is ProceduralSkillEntry => Boolean(entry.meta?.skill));\n };\n\n return {\n async list(scope?: { tags?: string[] }): Promise<SkillCatalogEntry[]> {\n const all = await recallAll();\n const wanted = scope?.tags;\n\n return all\n .filter((entry) => entry.meta.type !== \"candidate\")\n .filter((entry) => intersects(entry.meta.tags, wanted))\n .map((entry) => toCatalogEntry(entry.meta));\n },\n async load(name: string, version?: number): Promise<SkillRecord | undefined> {\n const all = await recallAll();\n const match = all.find((entry) => entry.meta.name === name);\n\n if (!match || match.meta.type === \"candidate\") {\n return undefined;\n }\n\n if (version !== undefined && match.meta.version !== version) {\n return undefined;\n }\n\n return toRecord(match.body, match.meta);\n },\n async saveCandidate(record: Omit<SkillRecord, \"version\" | \"type\">): Promise<SkillRecord> {\n const meta: ProceduralSkillMeta = {\n skill: true,\n name: record.name,\n type: \"candidate\",\n description: record.description,\n version: 0,\n tags: record.tags,\n };\n\n await store.remember({\n id: record.name,\n text: record.body,\n tier: \"procedural\",\n metadata: meta,\n });\n\n return { ...record, version: 0, type: \"candidate\" };\n },\n async promote(name: string): Promise<SkillRecord> {\n const all = await recallAll();\n const match = all.find((entry) => entry.meta.name === name);\n\n if (!match) {\n throw new Error(`proceduralSkillStore.promote: no skill named \"${name}\" to promote`);\n }\n\n const meta: ProceduralSkillMeta = {\n ...match.meta,\n type: \"promoted\",\n version: match.meta.version + 1,\n };\n\n // Re-remembering the same id reinforces (uses++) AND flips the\n // metadata — the procedural tier's reinforcement IS the promotion.\n await store.remember({\n id: name,\n text: match.body,\n tier: \"procedural\",\n metadata: meta,\n });\n\n return toRecord(match.body, meta);\n },\n };\n}\n\nfunction toCatalogEntry(meta: ProceduralSkillMeta): SkillCatalogEntry {\n return {\n name: meta.name,\n description: meta.description,\n version: meta.version,\n tags: meta.tags,\n type: meta.type,\n };\n}\n\nfunction toRecord(body: string, meta: ProceduralSkillMeta): SkillRecord {\n return {\n name: meta.name,\n description: meta.description,\n version: meta.version,\n body,\n tags: meta.tags,\n type: meta.type,\n };\n}\n\nfunction intersects(recordTags: string[] | undefined, wanted: string[] | undefined): boolean {\n if (!wanted || wanted.length === 0) {\n return true;\n }\n\n if (!recordTags || recordTags.length === 0) {\n return false;\n }\n\n return recordTags.some((tag) => wanted.includes(tag));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"procedural-skill-store.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/store/procedural-skill-store.ts"],"sourcesContent":["import type { MemoryContract } from \"../../contracts/memory/memory.contract\";\nimport type { ProceduralMemoryConfig } from \"../../contracts/memory/memory-config.type\";\nimport { memory } from \"../../memory\";\nimport type {\n SkillCatalogEntry,\n SkillRecord,\n} from \"../contracts/skill-record.type\";\nimport type { SkillsStoreContract } from \"../contracts/skills-store.contract\";\n\n/**\n * Metadata a procedural memory carries to round-trip a skill. `recall()`\n * surfaces `metadata` verbatim, so the skill's identity (name, version,\n * provenance, description, tags) rides here while the procedure body lives\n * in the memory's `text`.\n */\ntype ProceduralSkillMeta = {\n /** Marks the record as a skill (vs. a plain procedure) so `list` can scope. */\n skill: true;\n /** Skill name — the catalog key (also the memory `id`). */\n name: string;\n /** Provenance flag round-tripped onto the SkillRecord. */\n type: \"candidate\" | \"promoted\";\n /** Catalog line. */\n description: string;\n /** Monotonic version — bumped on promote. */\n version: number;\n /** Optional scope tags. */\n tags?: string[];\n};\n\n/** A recalled skill entry — the procedure body plus its skill metadata. */\ntype ProceduralSkillEntry = { body: string; meta: ProceduralSkillMeta };\n\nconst RECALL_K = 1000;\n\n/**\n * {@link SkillsStoreContract} backed by the procedural memory tier\n * (`ai.memory({ procedural })`). **The unification** the design calls for:\n * \"promote a proven procedural memory to a named skill\" and \"save a\n * self-authored skill\" are the SAME machinery — one store, two entry\n * points. No fifth `MemoryTier` is added; the existing `\"procedural\"` tier\n * is reused verbatim.\n *\n * - `saveCandidate` ⇒ `memory.remember({ tier: \"procedural\", metadata: { type: \"candidate\" } })`.\n * - `promote` ⇒ re-remembers the same id with `type: \"promoted\"` and\n * `version + 1`, which the procedural tier reinforces (increments `uses`).\n * - `list` / `load` map `memory.recall(..., { tier: \"procedural\" })` ⇒\n * `RecalledMemory[]` ⇒ `SkillCatalogEntry[]` / `SkillRecord`, filtering\n * out inert candidates so they can never be catalogued or injected.\n *\n * @example\n * const store = proceduralSkillStore({ embedder, store: cacheDriver });\n * const lib = skills({ name: \"learned\", sources: [{ type: \"store\", store }], review: gate });\n */\nexport function proceduralSkillStore(\n config: ProceduralMemoryConfig & { name?: string; recallQuery?: string },\n): SkillsStoreContract {\n const store: MemoryContract = memory({\n name: config.name ?? \"skills.procedural\",\n working: false,\n defaultTier: \"procedural\",\n procedural: {\n embedder: config.embedder,\n store: config.store,\n namespace: config.namespace,\n reinforcementWeight: config.reinforcementWeight,\n },\n });\n\n // The procedural tier recalls by similarity to a query; for a full\n // catalog listing we recall against a broad seed with a large `k` and a\n // zero floor so every stored skill comes back.\n const recallQuery = config.recallQuery ?? \"skill procedure how-to\";\n\n const recallAll = async (): Promise<ProceduralSkillEntry[]> => {\n const hits = await store.recall(recallQuery, {\n tier: \"procedural\",\n k: RECALL_K,\n threshold: 0,\n });\n\n return hits\n .map((hit) => ({ body: hit.text, meta: hit.metadata as ProceduralSkillMeta | undefined }))\n .filter((entry): entry is ProceduralSkillEntry => Boolean(entry.meta?.skill));\n };\n\n return {\n async list(scope?: { tags?: string[] }): Promise<SkillCatalogEntry[]> {\n const all = await recallAll();\n const wanted = scope?.tags;\n\n return all\n .filter((entry) => entry.meta.type !== \"candidate\")\n .filter((entry) => intersects(entry.meta.tags, wanted))\n .map((entry) => toCatalogEntry(entry.meta));\n },\n async load(name: string, version?: number): Promise<SkillRecord | undefined> {\n const all = await recallAll();\n const match = all.find((entry) => entry.meta.name === name);\n\n if (!match || match.meta.type === \"candidate\") {\n return undefined;\n }\n\n if (version !== undefined && match.meta.version !== version) {\n return undefined;\n }\n\n return toRecord(match.body, match.meta);\n },\n async saveCandidate(record: Omit<SkillRecord, \"version\" | \"type\">): Promise<SkillRecord> {\n const meta: ProceduralSkillMeta = {\n skill: true,\n name: record.name,\n type: \"candidate\",\n description: record.description,\n version: 0,\n tags: record.tags,\n };\n\n await store.remember({\n id: record.name,\n text: record.body,\n tier: \"procedural\",\n metadata: meta,\n });\n\n return { ...record, version: 0, type: \"candidate\" };\n },\n async promote(name: string): Promise<SkillRecord> {\n const all = await recallAll();\n const match = all.find((entry) => entry.meta.name === name);\n\n if (!match) {\n throw new Error(`proceduralSkillStore.promote: no skill named \"${name}\" to promote`);\n }\n\n const meta: ProceduralSkillMeta = {\n ...match.meta,\n type: \"promoted\",\n version: match.meta.version + 1,\n };\n\n // Re-remembering the same id reinforces (uses++) AND flips the\n // metadata — the procedural tier's reinforcement IS the promotion.\n await store.remember({\n id: name,\n text: match.body,\n tier: \"procedural\",\n metadata: meta,\n });\n\n return toRecord(match.body, meta);\n },\n };\n}\n\nfunction toCatalogEntry(meta: ProceduralSkillMeta): SkillCatalogEntry {\n return {\n name: meta.name,\n description: meta.description,\n version: meta.version,\n tags: meta.tags,\n type: meta.type,\n };\n}\n\nfunction toRecord(body: string, meta: ProceduralSkillMeta): SkillRecord {\n return {\n name: meta.name,\n description: meta.description,\n version: meta.version,\n body,\n tags: meta.tags,\n type: meta.type,\n };\n}\n\nfunction intersects(recordTags: string[] | undefined, wanted: string[] | undefined): boolean {\n if (!wanted || wanted.length === 0) {\n return true;\n }\n\n if (!recordTags || recordTags.length === 0) {\n return false;\n }\n\n return recordTags.some((tag) => wanted.includes(tag));\n}\n"],"mappings":";;;;AAiCA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAqBjB,SAAgB,qBACd,QACqB;CACrB,MAAM,QAAwB,OAAO;EACnC,MAAM,OAAO,QAAQ;EACrB,SAAS;EACT,aAAa;EACb,YAAY;GACV,UAAU,OAAO;GACjB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,qBAAqB,OAAO;EAC9B;CACF,CAAC;CAKD,MAAM,cAAc,OAAO,eAAe;CAE1C,MAAM,YAAY,YAA6C;EAO7D,QAAO,MANY,MAAM,OAAO,aAAa;GAC3C,MAAM;GACN,GAAG;GACH,WAAW;EACb,CAAC,EAEU,CACR,KAAK,SAAS;GAAE,MAAM,IAAI;GAAM,MAAM,IAAI;EAA4C,EAAE,CAAC,CACzF,QAAQ,UAAyC,QAAQ,MAAM,MAAM,KAAK,CAAC;CAChF;CAEA,OAAO;EACL,MAAM,KAAK,OAA2D;GACpE,MAAM,MAAM,MAAM,UAAU;GAC5B,MAAM,SAAS,OAAO;GAEtB,OAAO,IACJ,QAAQ,UAAU,MAAM,KAAK,SAAS,WAAW,CAAC,CAClD,QAAQ,UAAU,WAAW,MAAM,KAAK,MAAM,MAAM,CAAC,CAAC,CACtD,KAAK,UAAU,eAAe,MAAM,IAAI,CAAC;EAC9C;EACA,MAAM,KAAK,MAAc,SAAoD;GAE3E,MAAM,SAAQ,MADI,UAAU,EACX,CAAC,MAAM,UAAU,MAAM,KAAK,SAAS,IAAI;GAE1D,IAAI,CAAC,SAAS,MAAM,KAAK,SAAS,aAChC;GAGF,IAAI,YAAY,UAAa,MAAM,KAAK,YAAY,SAClD;GAGF,OAAO,SAAS,MAAM,MAAM,MAAM,IAAI;EACxC;EACA,MAAM,cAAc,QAAqE;GACvF,MAAM,OAA4B;IAChC,OAAO;IACP,MAAM,OAAO;IACb,MAAM;IACN,aAAa,OAAO;IACpB,SAAS;IACT,MAAM,OAAO;GACf;GAEA,MAAM,MAAM,SAAS;IACnB,IAAI,OAAO;IACX,MAAM,OAAO;IACb,MAAM;IACN,UAAU;GACZ,CAAC;GAED,OAAO;IAAE,GAAG;IAAQ,SAAS;IAAG,MAAM;GAAY;EACpD;EACA,MAAM,QAAQ,MAAoC;GAEhD,MAAM,SAAQ,MADI,UAAU,EACX,CAAC,MAAM,UAAU,MAAM,KAAK,SAAS,IAAI;GAE1D,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,iDAAiD,KAAK,aAAa;GAGrF,MAAM,OAA4B;IAChC,GAAG,MAAM;IACT,MAAM;IACN,SAAS,MAAM,KAAK,UAAU;GAChC;GAIA,MAAM,MAAM,SAAS;IACnB,IAAI;IACJ,MAAM,MAAM;IACZ,MAAM;IACN,UAAU;GACZ,CAAC;GAED,OAAO,SAAS,MAAM,MAAM,IAAI;EAClC;CACF;AACF;AAEA,SAAS,eAAe,MAA8C;CACpE,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,SAAS,KAAK;EACd,MAAM,KAAK;EACX,MAAM,KAAK;CACb;AACF;AAEA,SAAS,SAAS,MAAc,MAAwC;CACtE,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,SAAS,KAAK;EACd;EACA,MAAM,KAAK;EACX,MAAM,KAAK;CACb;AACF;AAEA,SAAS,WAAW,YAAkC,QAAuC;CAC3F,IAAI,CAAC,UAAU,OAAO,WAAW,GAC/B,OAAO;CAGT,IAAI,CAAC,cAAc,WAAW,WAAW,GACvC,OAAO;CAGT,OAAO,WAAW,MAAM,QAAQ,OAAO,SAAS,GAAG,CAAC;AACtD"}
|
package/package.json
CHANGED
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
"@standard-schema/spec": "^1.0.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@warlock.js/
|
|
19
|
-
"@warlock.js/
|
|
18
|
+
"@warlock.js/ai-openai": "4.8.2",
|
|
19
|
+
"@warlock.js/cache": "4.8.2",
|
|
20
|
+
"@warlock.js/logger": "4.8.2",
|
|
20
21
|
"langfuse": "*",
|
|
21
22
|
"openai": "*",
|
|
23
|
+
"pdf-parse": "*",
|
|
22
24
|
"pg": "*",
|
|
23
25
|
"redis": "*"
|
|
24
26
|
},
|
|
25
|
-
"version": "4.8.
|
|
27
|
+
"version": "4.8.2",
|
|
26
28
|
"main": "./cjs/index.cjs",
|
|
27
29
|
"module": "./esm/index.mjs",
|
|
28
30
|
"types": "./esm/index.d.mts",
|
package/cjs/src-DBn2_pbG.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
require('./src-DTlN47aO.cjs');
|
|
29
|
-
let _warlock_js_logger = require("@warlock.js/logger");
|
|
30
|
-
require("openai");
|