@warlock.js/ai 4.4.0 → 4.5.0
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 +52 -55
- package/cjs/index.cjs +221 -14147
- package/cjs/src-C02yzsLs.cjs +22991 -0
- package/cjs/src-C02yzsLs.cjs.map +1 -0
- package/cjs/src-DFibP2FQ.cjs +30 -0
- package/esm/agent/agent-config.type.d.mts +90 -1
- package/esm/agent/agent-config.type.d.mts.map +1 -1
- package/esm/agent/agent-input-builder.mjs +27 -6
- package/esm/agent/agent-input-builder.mjs.map +1 -1
- package/esm/agent/agent.d.mts +40 -1
- package/esm/agent/agent.d.mts.map +1 -1
- package/esm/agent/agent.mjs +203 -30
- package/esm/agent/agent.mjs.map +1 -1
- package/esm/agent/index.d.mts +2 -1
- package/esm/agent/index.mjs +1 -0
- package/esm/agent/judge-config.type.d.mts +33 -0
- package/esm/agent/judge-config.type.d.mts.map +1 -0
- package/esm/agent/judge-config.type.mjs +13 -0
- package/esm/agent/judge-config.type.mjs.map +1 -0
- package/esm/ai-openai/src/embedder.mjs +4 -0
- package/esm/ai-openai/src/index.mjs +4 -0
- package/esm/ai-openai/src/model.mjs +5 -0
- package/esm/ai-openai/src/sdk.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +4 -0
- package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
- package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
- package/esm/ai.d.mts +119 -53
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +43 -8
- package/esm/ai.mjs.map +1 -1
- package/esm/batch/batch.d.mts.map +1 -1
- package/esm/batch/batch.mjs +21 -1
- package/esm/batch/batch.mjs.map +1 -1
- package/esm/batch/batch.type.d.mts +11 -4
- package/esm/batch/batch.type.d.mts.map +1 -1
- package/esm/config.d.mts +39 -3
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +26 -2
- package/esm/config.mjs.map +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts +11 -3
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
- package/esm/contracts/agent/eval.type.d.mts +43 -2
- package/esm/contracts/agent/eval.type.d.mts.map +1 -1
- package/esm/contracts/attachment-policy.type.d.mts +51 -0
- package/esm/contracts/attachment-policy.type.d.mts.map +1 -0
- package/esm/contracts/attachment.type.d.mts +16 -7
- package/esm/contracts/attachment.type.d.mts.map +1 -1
- package/esm/contracts/content-part.type.d.mts +14 -5
- package/esm/contracts/content-part.type.d.mts.map +1 -1
- package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +6 -4
- package/esm/contracts/model.contract.d.mts +11 -8
- package/esm/contracts/model.contract.d.mts.map +1 -1
- package/esm/contracts/orchestrator/index.d.mts +1 -0
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +31 -2
- package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
- package/esm/contracts/orchestrator/session-lock.contract.d.mts +47 -0
- package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -0
- package/esm/contracts/planner/index.d.mts +1 -1
- package/esm/contracts/planner/planner-config.type.d.mts +31 -0
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts +48 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-result.type.d.mts +8 -0
- package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner.contract.d.mts +1 -1
- package/esm/contracts/result/agent-result.type.d.mts +6 -4
- package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.d.mts +21 -3
- package/esm/contracts/result/base-report.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.mjs.map +1 -1
- package/esm/contracts/result/execution-report.type.d.mts +53 -1
- package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
- package/esm/contracts/result/supervisor-result.type.d.mts +14 -2
- package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
- package/esm/contracts/result/workflow-result.type.d.mts +2 -1
- package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
- package/esm/contracts/supervisor/supervisor-config.type.d.mts +29 -0
- package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
- package/esm/contracts/system-prompt.contract.d.mts +103 -1
- package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
- package/esm/contracts/team/index.d.mts +1 -0
- package/esm/contracts/team/team-config.type.d.mts +127 -0
- package/esm/contracts/team/team-config.type.d.mts.map +1 -0
- package/esm/contracts/tool.contract.d.mts +4 -2
- package/esm/contracts/tool.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/step.contract.d.mts +30 -5
- package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
- package/esm/contracts/workflow/workflow.contract.d.mts +16 -0
- package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/index.d.mts +1 -0
- package/esm/errors/index.mjs +1 -0
- package/esm/errors/outbound-policy-error.d.mts +27 -0
- package/esm/errors/outbound-policy-error.d.mts.map +1 -0
- package/esm/errors/outbound-policy-error.mjs +32 -0
- package/esm/errors/outbound-policy-error.mjs.map +1 -0
- package/esm/eval/dataset.d.mts +28 -0
- package/esm/eval/dataset.d.mts.map +1 -0
- package/esm/eval/dataset.mjs +112 -0
- package/esm/eval/dataset.mjs.map +1 -0
- package/esm/eval/dataset.type.d.mts +53 -0
- package/esm/eval/dataset.type.d.mts.map +1 -0
- package/esm/eval/eval-runner.d.mts.map +1 -1
- package/esm/eval/eval-runner.mjs +16 -2
- package/esm/eval/eval-runner.mjs.map +1 -1
- package/esm/eval/index.d.mts +20 -1
- package/esm/eval/index.d.mts.map +1 -1
- package/esm/eval/index.mjs +20 -2
- package/esm/eval/index.mjs.map +1 -1
- package/esm/eval/regression.d.mts +30 -0
- package/esm/eval/regression.d.mts.map +1 -0
- package/esm/eval/regression.mjs +51 -0
- package/esm/eval/regression.mjs.map +1 -0
- package/esm/eval/report-json.d.mts +30 -0
- package/esm/eval/report-json.d.mts.map +1 -0
- package/esm/eval/report-json.mjs +33 -0
- package/esm/eval/report-json.mjs.map +1 -0
- package/esm/eval/report-junit.d.mts +22 -0
- package/esm/eval/report-junit.d.mts.map +1 -0
- package/esm/eval/report-junit.mjs +60 -0
- package/esm/eval/report-junit.mjs.map +1 -0
- package/esm/guard/contracts/guard-options.type.d.mts +165 -0
- package/esm/guard/contracts/guard-options.type.d.mts.map +1 -0
- package/esm/guard/contracts/guardrail.contract.d.mts +78 -0
- package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -0
- package/esm/guard/contracts/index.d.mts +4 -0
- package/esm/guard/contracts/openai-client.contract.d.mts +51 -0
- package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -0
- package/esm/guard/contracts/verdict.type.d.mts +76 -0
- package/esm/guard/contracts/verdict.type.d.mts.map +1 -0
- package/esm/guard/detectors/index.d.mts +4 -0
- package/esm/guard/detectors/index.mjs +6 -0
- package/esm/guard/detectors/injection.d.mts +34 -0
- package/esm/guard/detectors/injection.d.mts.map +1 -0
- package/esm/guard/detectors/injection.mjs +254 -0
- package/esm/guard/detectors/injection.mjs.map +1 -0
- package/esm/guard/detectors/moderation.d.mts +32 -0
- package/esm/guard/detectors/moderation.d.mts.map +1 -0
- package/esm/guard/detectors/moderation.mjs +134 -0
- package/esm/guard/detectors/moderation.mjs.map +1 -0
- package/esm/guard/detectors/pii.d.mts +41 -0
- package/esm/guard/detectors/pii.d.mts.map +1 -0
- package/esm/guard/detectors/pii.mjs +199 -0
- package/esm/guard/detectors/pii.mjs.map +1 -0
- package/esm/guard/detectors/topic.d.mts +29 -0
- package/esm/guard/detectors/topic.d.mts.map +1 -0
- package/esm/guard/detectors/topic.mjs +99 -0
- package/esm/guard/detectors/topic.mjs.map +1 -0
- package/esm/guard/errors.d.mts +12 -0
- package/esm/guard/errors.d.mts.map +1 -0
- package/esm/guard/errors.mjs +18 -0
- package/esm/guard/errors.mjs.map +1 -0
- package/esm/guard/guard.d.mts +67 -0
- package/esm/guard/guard.d.mts.map +1 -0
- package/esm/guard/guard.mjs +209 -0
- package/esm/guard/guard.mjs.map +1 -0
- package/esm/guard/guardrail.d.mts +39 -0
- package/esm/guard/guardrail.d.mts.map +1 -0
- package/esm/guard/guardrail.mjs +22 -0
- package/esm/guard/guardrail.mjs.map +1 -0
- package/esm/human/contracts/approval.type.d.mts +154 -0
- package/esm/human/contracts/approval.type.d.mts.map +1 -0
- package/esm/human/contracts/human-approval.type.d.mts +38 -0
- package/esm/human/contracts/human-approval.type.d.mts.map +1 -0
- package/esm/human/contracts/index.d.mts +4 -0
- package/esm/human/contracts/interrupt-store.contract.d.mts +112 -0
- package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -0
- package/esm/human/contracts/resume.type.d.mts +77 -0
- package/esm/human/contracts/resume.type.d.mts.map +1 -0
- package/esm/human/errors.d.mts +84 -0
- package/esm/human/errors.d.mts.map +1 -0
- package/esm/human/errors.mjs +60 -0
- package/esm/human/errors.mjs.map +1 -0
- package/esm/human/human-approval.d.mts +57 -0
- package/esm/human/human-approval.d.mts.map +1 -0
- package/esm/human/human-approval.mjs +170 -0
- package/esm/human/human-approval.mjs.map +1 -0
- package/esm/human/policy.d.mts +55 -0
- package/esm/human/policy.d.mts.map +1 -0
- package/esm/human/policy.mjs +67 -0
- package/esm/human/policy.mjs.map +1 -0
- package/esm/human/register.mjs +37 -0
- package/esm/human/register.mjs.map +1 -0
- package/esm/human/resume-seed.mjs +53 -0
- package/esm/human/resume-seed.mjs.map +1 -0
- package/esm/human/resume.d.mts +54 -0
- package/esm/human/resume.d.mts.map +1 -0
- package/esm/human/resume.mjs +121 -0
- package/esm/human/resume.mjs.map +1 -0
- package/esm/human/stores/index.mjs +5 -0
- package/esm/human/stores/memory.d.mts +30 -0
- package/esm/human/stores/memory.d.mts.map +1 -0
- package/esm/human/stores/memory.mjs +91 -0
- package/esm/human/stores/memory.mjs.map +1 -0
- package/esm/human/stores/pg.d.mts +59 -0
- package/esm/human/stores/pg.d.mts.map +1 -0
- package/esm/human/stores/pg.mjs +220 -0
- package/esm/human/stores/pg.mjs.map +1 -0
- package/esm/human/stores/redis.d.mts +56 -0
- package/esm/human/stores/redis.d.mts.map +1 -0
- package/esm/human/stores/redis.mjs +201 -0
- package/esm/human/stores/redis.mjs.map +1 -0
- package/esm/index.d.mts +113 -22
- package/esm/index.mjs +82 -11
- package/esm/middleware/builtins/budget.mjs +6 -2
- package/esm/middleware/builtins/budget.mjs.map +1 -1
- package/esm/middleware/utils/extract-user-text.d.mts +8 -1
- package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
- package/esm/middleware/utils/extract-user-text.mjs +8 -1
- package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
- package/esm/object-stream/index.d.mts +2 -0
- package/esm/object-stream/index.mjs +4 -0
- package/esm/object-stream/parse-partial-json.d.mts +22 -0
- package/esm/object-stream/parse-partial-json.d.mts.map +1 -0
- package/esm/object-stream/parse-partial-json.mjs +78 -0
- package/esm/object-stream/parse-partial-json.mjs.map +1 -0
- package/esm/object-stream/stream-object.d.mts +68 -0
- package/esm/object-stream/stream-object.d.mts.map +1 -0
- package/esm/object-stream/stream-object.mjs +104 -0
- package/esm/object-stream/stream-object.mjs.map +1 -0
- package/esm/observe/index.mjs +4 -0
- package/esm/observe/observer-registry.d.mts +30 -0
- package/esm/observe/observer-registry.d.mts.map +1 -0
- package/esm/observe/observer-registry.mjs +51 -0
- package/esm/observe/observer-registry.mjs.map +1 -0
- package/esm/observe/observer.contract.d.mts +40 -0
- package/esm/observe/observer.contract.d.mts.map +1 -0
- package/esm/observe/resolve-observers.d.mts +40 -0
- package/esm/observe/resolve-observers.d.mts.map +1 -0
- package/esm/observe/resolve-observers.mjs +73 -0
- package/esm/observe/resolve-observers.mjs.map +1 -0
- package/esm/orchestrator/execution.d.mts.map +1 -1
- package/esm/orchestrator/execution.mjs +5 -2
- package/esm/orchestrator/execution.mjs.map +1 -1
- package/esm/orchestrator/index.d.mts +1 -0
- package/esm/orchestrator/index.mjs +1 -0
- package/esm/orchestrator/orchestrator.d.mts.map +1 -1
- package/esm/orchestrator/orchestrator.mjs +39 -6
- package/esm/orchestrator/orchestrator.mjs.map +1 -1
- package/esm/orchestrator/session-lock.d.mts +25 -0
- package/esm/orchestrator/session-lock.d.mts.map +1 -0
- package/esm/orchestrator/session-lock.mjs +83 -0
- package/esm/orchestrator/session-lock.mjs.map +1 -0
- package/esm/planner/dag-scheduler.mjs +97 -0
- package/esm/planner/dag-scheduler.mjs.map +1 -0
- package/esm/planner/plan-prompt.d.mts +1 -1
- package/esm/planner/plan-prompt.d.mts.map +1 -1
- package/esm/planner/plan-prompt.mjs +2 -1
- package/esm/planner/plan-prompt.mjs.map +1 -1
- package/esm/planner/planner-run.d.mts.map +1 -1
- package/esm/planner/planner-run.mjs +300 -29
- package/esm/planner/planner-run.mjs.map +1 -1
- package/esm/planner/planner.mjs +1 -1
- package/esm/planner/planner.mjs.map +1 -1
- package/esm/prompt/errors.d.mts +57 -0
- package/esm/prompt/errors.d.mts.map +1 -0
- package/esm/prompt/errors.mjs +73 -0
- package/esm/prompt/errors.mjs.map +1 -0
- package/esm/prompt/index.d.mts +3 -0
- package/esm/prompt/index.mjs +4 -0
- package/esm/prompt/prompt-langfuse-sync.mjs +104 -0
- package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -0
- package/esm/prompt/prompt-langfuse-sync.type.d.mts +32 -0
- package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -0
- package/esm/prompt/prompt-validate.mjs +170 -0
- package/esm/prompt/prompt-validate.mjs.map +1 -0
- package/esm/prompt/prompt.d.mts +54 -0
- package/esm/prompt/prompt.d.mts.map +1 -0
- package/esm/prompt/prompt.mjs +218 -0
- package/esm/prompt/prompt.mjs.map +1 -0
- package/esm/prompt/prompt.type.d.mts +174 -0
- package/esm/prompt/prompt.type.d.mts.map +1 -0
- package/esm/prompts/index.d.mts +3 -0
- package/esm/prompts/index.mjs +3 -0
- package/esm/prompts/prompts-manager.contract.d.mts +154 -0
- package/esm/prompts/prompts-manager.contract.d.mts.map +1 -0
- package/esm/prompts/prompts-manager.d.mts +38 -0
- package/esm/prompts/prompts-manager.d.mts.map +1 -0
- package/esm/prompts/prompts-manager.mjs +410 -0
- package/esm/prompts/prompts-manager.mjs.map +1 -0
- package/esm/prompts/prompts-manager.type.d.mts +172 -0
- package/esm/prompts/prompts-manager.type.d.mts.map +1 -0
- package/esm/prompts/prompts-validate.mjs +200 -0
- package/esm/prompts/prompts-validate.mjs.map +1 -0
- package/esm/rag/as-tool.mjs +48 -0
- package/esm/rag/as-tool.mjs.map +1 -0
- package/esm/rag/chunk/chunk.d.mts +24 -0
- package/esm/rag/chunk/chunk.d.mts.map +1 -0
- package/esm/rag/chunk/chunk.mjs +44 -0
- package/esm/rag/chunk/chunk.mjs.map +1 -0
- package/esm/rag/chunk/fixed.mjs +32 -0
- package/esm/rag/chunk/fixed.mjs.map +1 -0
- package/esm/rag/chunk/markdown.mjs +75 -0
- package/esm/rag/chunk/markdown.mjs.map +1 -0
- package/esm/rag/chunk/recursive.mjs +132 -0
- package/esm/rag/chunk/recursive.mjs.map +1 -0
- package/esm/rag/chunk/sentence.mjs +73 -0
- package/esm/rag/chunk/sentence.mjs.map +1 -0
- package/esm/rag/contracts/chunk-options.type.d.mts +35 -0
- package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -0
- package/esm/rag/contracts/citation.type.d.mts +35 -0
- package/esm/rag/contracts/citation.type.d.mts.map +1 -0
- package/esm/rag/contracts/index.d.mts +4 -0
- package/esm/rag/contracts/rag-config.type.d.mts +68 -0
- package/esm/rag/contracts/rag-config.type.d.mts.map +1 -0
- package/esm/rag/contracts/rag-document.type.d.mts +21 -0
- package/esm/rag/contracts/rag-document.type.d.mts.map +1 -0
- package/esm/rag/hybrid/bm25.d.mts +23 -0
- package/esm/rag/hybrid/bm25.d.mts.map +1 -0
- package/esm/rag/hybrid/bm25.mjs +51 -0
- package/esm/rag/hybrid/bm25.mjs.map +1 -0
- package/esm/rag/hybrid/hybrid-rank.d.mts +33 -0
- package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -0
- package/esm/rag/hybrid/hybrid-rank.mjs +29 -0
- package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -0
- package/esm/rag/hybrid/rrf.d.mts +25 -0
- package/esm/rag/hybrid/rrf.d.mts.map +1 -0
- package/esm/rag/hybrid/rrf.mjs +30 -0
- package/esm/rag/hybrid/rrf.mjs.map +1 -0
- package/esm/rag/index.d.mts +15 -0
- package/esm/rag/index.mjs +11 -0
- package/esm/rag/rag.d.mts +38 -0
- package/esm/rag/rag.d.mts.map +1 -0
- package/esm/rag/rag.mjs +126 -0
- package/esm/rag/rag.mjs.map +1 -0
- package/esm/rag/rerank/keyword-reranker.d.mts +32 -0
- package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -0
- package/esm/rag/rerank/keyword-reranker.mjs +58 -0
- package/esm/rag/rerank/keyword-reranker.mjs.map +1 -0
- package/esm/rag/rerank/llm-reranker.d.mts +36 -0
- package/esm/rag/rerank/llm-reranker.d.mts.map +1 -0
- package/esm/rag/rerank/llm-reranker.mjs +85 -0
- package/esm/rag/rerank/llm-reranker.mjs.map +1 -0
- package/esm/rag/rerank/reranker.contract.d.mts +28 -0
- package/esm/rag/rerank/reranker.contract.d.mts.map +1 -0
- package/esm/rag/retrieve.mjs +68 -0
- package/esm/rag/retrieve.mjs.map +1 -0
- package/esm/rag/store/cache-vector-store.d.mts +27 -0
- package/esm/rag/store/cache-vector-store.d.mts.map +1 -0
- package/esm/rag/store/cache-vector-store.mjs +48 -0
- package/esm/rag/store/cache-vector-store.mjs.map +1 -0
- package/esm/rag/store/vector-store.contract.d.mts +38 -0
- package/esm/rag/store/vector-store.contract.d.mts.map +1 -0
- package/esm/rag/transforms/multi-query.d.mts +27 -0
- package/esm/rag/transforms/multi-query.d.mts.map +1 -0
- package/esm/rag/transforms/multi-query.mjs +41 -0
- package/esm/rag/transforms/multi-query.mjs.map +1 -0
- package/esm/security/index.mjs +5 -0
- package/esm/security/outbound-policy.d.mts +46 -0
- package/esm/security/outbound-policy.d.mts.map +1 -0
- package/esm/security/outbound-policy.mjs +187 -0
- package/esm/security/outbound-policy.mjs.map +1 -0
- package/esm/security/outbound-policy.type.d.mts +74 -0
- package/esm/security/outbound-policy.type.d.mts.map +1 -0
- package/esm/security/private-ip.d.mts +15 -0
- package/esm/security/private-ip.d.mts.map +1 -0
- package/esm/security/private-ip.mjs +48 -0
- package/esm/security/private-ip.mjs.map +1 -0
- package/esm/security/redact.d.mts +59 -0
- package/esm/security/redact.d.mts.map +1 -0
- package/esm/security/redact.mjs +122 -0
- package/esm/security/redact.mjs.map +1 -0
- package/esm/serve/serve.d.mts +50 -0
- package/esm/serve/serve.d.mts.map +1 -0
- package/esm/serve/serve.mjs +90 -0
- package/esm/serve/serve.mjs.map +1 -0
- package/esm/serve/sse.d.mts +20 -0
- package/esm/serve/sse.d.mts.map +1 -0
- package/esm/serve/sse.mjs +25 -0
- package/esm/serve/sse.mjs.map +1 -0
- package/esm/serve/stream-to-sse.d.mts +29 -0
- package/esm/serve/stream-to-sse.d.mts.map +1 -0
- package/esm/serve/stream-to-sse.mjs +37 -0
- package/esm/serve/stream-to-sse.mjs.map +1 -0
- package/esm/skills/catalog.d.mts +49 -0
- package/esm/skills/catalog.d.mts.map +1 -0
- package/esm/skills/catalog.mjs +140 -0
- package/esm/skills/catalog.mjs.map +1 -0
- package/esm/skills/contracts/skill-record.type.d.mts +37 -0
- package/esm/skills/contracts/skill-record.type.d.mts.map +1 -0
- package/esm/skills/contracts/skills-config.type.d.mts +108 -0
- package/esm/skills/contracts/skills-config.type.d.mts.map +1 -0
- package/esm/skills/contracts/skills-store.contract.d.mts +28 -0
- package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -0
- package/esm/skills/contracts/skills.contract.d.mts +43 -0
- package/esm/skills/contracts/skills.contract.d.mts.map +1 -0
- package/esm/skills/index.d.mts +16 -0
- package/esm/skills/index.mjs +14 -0
- package/esm/skills/load-skill-tool.d.mts +38 -0
- package/esm/skills/load-skill-tool.d.mts.map +1 -0
- package/esm/skills/load-skill-tool.mjs +65 -0
- package/esm/skills/load-skill-tool.mjs.map +1 -0
- package/esm/skills/review-gate.d.mts +33 -0
- package/esm/skills/review-gate.d.mts.map +1 -0
- package/esm/skills/review-gate.mjs +60 -0
- package/esm/skills/review-gate.mjs.map +1 -0
- package/esm/skills/save-skill-tool.d.mts +39 -0
- package/esm/skills/save-skill-tool.d.mts.map +1 -0
- package/esm/skills/save-skill-tool.mjs +65 -0
- package/esm/skills/save-skill-tool.mjs.map +1 -0
- package/esm/skills/skills.d.mts +33 -0
- package/esm/skills/skills.d.mts.map +1 -0
- package/esm/skills/skills.mjs +109 -0
- package/esm/skills/skills.mjs.map +1 -0
- package/esm/skills/sources/directory-source.d.mts +19 -0
- package/esm/skills/sources/directory-source.d.mts.map +1 -0
- package/esm/skills/sources/directory-source.mjs +108 -0
- package/esm/skills/sources/directory-source.mjs.map +1 -0
- package/esm/skills/sources/index.d.mts +18 -0
- package/esm/skills/sources/index.d.mts.map +1 -0
- package/esm/skills/sources/index.mjs +27 -0
- package/esm/skills/sources/index.mjs.map +1 -0
- package/esm/skills/sources/parse-frontmatter.d.mts +27 -0
- package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -0
- package/esm/skills/sources/parse-frontmatter.mjs +46 -0
- package/esm/skills/sources/parse-frontmatter.mjs.map +1 -0
- package/esm/skills/sources/store-source.d.mts +14 -0
- package/esm/skills/sources/store-source.d.mts.map +1 -0
- package/esm/skills/sources/store-source.mjs +15 -0
- package/esm/skills/sources/store-source.mjs.map +1 -0
- package/esm/skills/sources/url-source.d.mts +29 -0
- package/esm/skills/sources/url-source.d.mts.map +1 -0
- package/esm/skills/sources/url-source.mjs +117 -0
- package/esm/skills/sources/url-source.mjs.map +1 -0
- package/esm/skills/store/mock-skills-store.d.mts +57 -0
- package/esm/skills/store/mock-skills-store.d.mts.map +1 -0
- package/esm/skills/store/mock-skills-store.mjs +100 -0
- package/esm/skills/store/mock-skills-store.mjs.map +1 -0
- package/esm/skills/store/procedural-skill-store.d.mts +30 -0
- package/esm/skills/store/procedural-skill-store.d.mts.map +1 -0
- package/esm/skills/store/procedural-skill-store.mjs +125 -0
- package/esm/skills/store/procedural-skill-store.mjs.map +1 -0
- package/esm/supervisor/as-tool.mjs +2 -2
- package/esm/supervisor/as-tool.mjs.map +1 -1
- package/esm/supervisor/execution.d.mts.map +1 -1
- package/esm/supervisor/execution.mjs +31 -28
- package/esm/supervisor/execution.mjs.map +1 -1
- package/esm/supervisor/supervisor.d.mts.map +1 -1
- package/esm/supervisor/supervisor.mjs +8 -3
- package/esm/supervisor/supervisor.mjs.map +1 -1
- package/esm/system-prompt/index.d.mts +4 -0
- package/esm/system-prompt/system-prompt.d.mts +68 -4
- package/esm/system-prompt/system-prompt.d.mts.map +1 -1
- package/esm/system-prompt/system-prompt.mjs +89 -5
- package/esm/system-prompt/system-prompt.mjs.map +1 -1
- package/esm/team/gates.mjs +48 -0
- package/esm/team/gates.mjs.map +1 -0
- package/esm/team/index.d.mts +1 -0
- package/esm/team/index.mjs +3 -0
- package/esm/team/team.d.mts +42 -0
- package/esm/team/team.d.mts.map +1 -0
- package/esm/team/team.mjs +94 -0
- package/esm/team/team.mjs.map +1 -0
- package/esm/tool/executable-as-tool.d.mts.map +1 -1
- package/esm/tool/executable-as-tool.mjs +2 -2
- package/esm/tool/executable-as-tool.mjs.map +1 -1
- package/esm/tool/tool.d.mts.map +1 -1
- package/esm/tool/tool.mjs +2 -2
- package/esm/tool/tool.mjs.map +1 -1
- package/esm/utils/compute-cost.d.mts +17 -1
- package/esm/utils/compute-cost.d.mts.map +1 -1
- package/esm/utils/compute-cost.mjs +26 -1
- package/esm/utils/compute-cost.mjs.map +1 -1
- package/esm/utils/extract-json-lenient.d.mts +42 -0
- package/esm/utils/extract-json-lenient.d.mts.map +1 -0
- package/esm/utils/extract-json-lenient.mjs +97 -0
- package/esm/utils/extract-json-lenient.mjs.map +1 -0
- package/esm/utils/index.d.mts +4 -2
- package/esm/utils/index.mjs +3 -1
- package/esm/utils/json-schema.d.mts +1 -1
- package/esm/utils/prepare-attachment-part.d.mts +10 -1
- package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
- package/esm/utils/prepare-attachment-part.mjs +103 -11
- package/esm/utils/prepare-attachment-part.mjs.map +1 -1
- package/esm/utils/resolve-attachment.d.mts +4 -3
- package/esm/utils/resolve-attachment.d.mts.map +1 -1
- package/esm/utils/resolve-attachment.mjs +4 -3
- package/esm/utils/resolve-attachment.mjs.map +1 -1
- package/esm/utils/run-context.d.mts +94 -0
- package/esm/utils/run-context.d.mts.map +1 -0
- package/esm/utils/run-context.mjs +98 -0
- package/esm/utils/run-context.mjs.map +1 -0
- package/esm/vcr/cassette-io.mjs +57 -0
- package/esm/vcr/cassette-io.mjs.map +1 -0
- package/esm/vcr/errors.d.mts +42 -0
- package/esm/vcr/errors.d.mts.map +1 -0
- package/esm/vcr/errors.mjs +37 -0
- package/esm/vcr/errors.mjs.map +1 -0
- package/esm/vcr/hash-request.d.mts +28 -0
- package/esm/vcr/hash-request.d.mts.map +1 -0
- package/esm/vcr/hash-request.mjs +118 -0
- package/esm/vcr/hash-request.mjs.map +1 -0
- package/esm/vcr/index.d.mts +4 -0
- package/esm/vcr/index.mjs +5 -0
- package/esm/vcr/vcr.d.mts +32 -0
- package/esm/vcr/vcr.d.mts.map +1 -0
- package/esm/vcr/vcr.mjs +248 -0
- package/esm/vcr/vcr.mjs.map +1 -0
- package/esm/vcr/vcr.type.d.mts +118 -0
- package/esm/vcr/vcr.type.d.mts.map +1 -0
- package/esm/workflow/as-tool.mjs +2 -2
- package/esm/workflow/as-tool.mjs.map +1 -1
- package/esm/workflow/engine.mjs +1 -0
- package/esm/workflow/engine.mjs.map +1 -1
- package/esm/workflow/step-runner.mjs +19 -20
- package/esm/workflow/step-runner.mjs.map +1 -1
- package/esm/workflow/workflow.d.mts.map +1 -1
- package/esm/workflow/workflow.mjs +8 -3
- package/esm/workflow/workflow.mjs.map +1 -1
- package/llms-full.txt +1683 -68
- package/llms.txt +16 -4
- package/package.json +7 -3
- package/skills/README.md +40 -4
- package/skills/ai-dx-helpers/SKILL.md +2 -2
- package/skills/approve-tool-calls/SKILL.md +134 -0
- package/skills/attach-ai-middleware/SKILL.md +1 -1
- package/skills/detect-and-redact-pii/SKILL.md +104 -0
- package/skills/durable-resume/SKILL.md +128 -0
- package/skills/escalate-block-to-human/SKILL.md +85 -0
- package/skills/eval-datasets-and-ci/SKILL.md +117 -0
- package/skills/guard-input-output/SKILL.md +117 -0
- package/skills/manage-prompts/SKILL.md +186 -0
- package/skills/observe-ai-flows/SKILL.md +94 -0
- package/skills/record-replay-llm/SKILL.md +92 -0
- package/skills/run-ai-agent/SKILL.md +26 -1
- package/skills/run-ai-rag/SKILL.md +139 -0
- package/skills/run-ai-team/SKILL.md +107 -0
- package/skills/run-orchestrator/SKILL.md +2 -0
- package/skills/run-planner/SKILL.md +73 -8
- package/skills/run-supervisor/SKILL.md +20 -1
- package/skills/use-runtime-skills/SKILL.md +106 -0
- package/skills/write-system-prompt/SKILL.md +30 -1
- package/cjs/index.cjs.map +0 -1
- package/esm/contracts/result/index.d.mts +0 -15
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { ModelContract } from "../contracts/model.contract.mjs";
|
|
2
|
+
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
3
|
+
import { SystemPrompt } from "../system-prompt/system-prompt.mjs";
|
|
4
|
+
import { LangfuseClientLike } from "./prompt-langfuse-sync.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../@warlock.js/ai/src/prompt/prompt.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* One immutable version of a named prompt.
|
|
9
|
+
*
|
|
10
|
+
* **Role.** A single addressable snapshot of a prompt body, tagged with a
|
|
11
|
+
* free-form `version` label and (optionally) the placeholder keys it
|
|
12
|
+
* requires. Many versions accumulate under one {@link PromptEntry} so a
|
|
13
|
+
* registered prompt can evolve while older versions stay resolvable.
|
|
14
|
+
*
|
|
15
|
+
* The `template` uses the exact same `{{placeholder}}` syntax the shared
|
|
16
|
+
* `renderPlaceholders` helper supports — `{{key}}`, `{{a.b.c}}`,
|
|
17
|
+
* `{{key|default}}` — so a version's body renders identically to a
|
|
18
|
+
* `systemPrompt(string)` seed.
|
|
19
|
+
*/
|
|
20
|
+
type PromptVersion = {
|
|
21
|
+
/** Monotonic version label, e.g. `"1"`, `"2"`, `"2025-06-draft"`. Free-form string. */version: string; /** The prompt body — same `{{placeholder}}` syntax `renderPlaceholders` supports. */
|
|
22
|
+
template: string;
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder keys this version requires. When set, `.resolve()` throws a
|
|
25
|
+
* {@link PromptValidationError} if any are missing from the merged
|
|
26
|
+
* placeholders — closing the silent-passthrough gap `renderPlaceholders`
|
|
27
|
+
* leaves for an unsupplied `{{key}}`. Absent = no required-key validation.
|
|
28
|
+
*/
|
|
29
|
+
required?: string[]; /** Optional free-form metadata (author note, model hint, etc.). */
|
|
30
|
+
meta?: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A named prompt and its ordered version history.
|
|
34
|
+
*
|
|
35
|
+
* **Role.** The unit `register()` ingests and `versions()` returns. The
|
|
36
|
+
* `versions` array is ordered oldest-first; the **last** entry is the
|
|
37
|
+
* default resolved when no explicit `version` is requested.
|
|
38
|
+
*/
|
|
39
|
+
type PromptEntry = {
|
|
40
|
+
/** Unique name used for lookup, e.g. `"support-agent"`. */name: string; /** Ordered version history; the last entry is the default. */
|
|
41
|
+
versions: PromptVersion[];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Options for {@link PromptRegistryContract.resolve}.
|
|
45
|
+
*/
|
|
46
|
+
type PromptResolveOptions = {
|
|
47
|
+
/** Pick a specific version by its label. Default: the latest registered version. */version?: string; /** Values for the template's `{{placeholders}}`. */
|
|
48
|
+
placeholders?: Placeholders;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Outcome of {@link PromptRegistryContract.resolve} — the picked version, its
|
|
52
|
+
* rendered text, and a one-call bridge to a `SystemPrompt`.
|
|
53
|
+
*/
|
|
54
|
+
type ResolvedPrompt = {
|
|
55
|
+
/** The prompt name that was resolved. */name: string; /** The version label that was picked. */
|
|
56
|
+
version: string; /** The rendered string (placeholders substituted). */
|
|
57
|
+
text: string;
|
|
58
|
+
/**
|
|
59
|
+
* A `SystemPrompt` seeded with the rendered text — the exact same seed
|
|
60
|
+
* `systemPrompt(string)` produces (`new SystemPrompt([new Instruction(text)])`),
|
|
61
|
+
* so it is a drop-in for `ai.agent({ systemPrompt })`.
|
|
62
|
+
*/
|
|
63
|
+
toSystemPrompt(): SystemPrompt;
|
|
64
|
+
};
|
|
65
|
+
/** Severity of a single {@link PromptValidationReport} finding. */
|
|
66
|
+
type PromptValidationSeverity = "info" | "warn" | "error";
|
|
67
|
+
/** One finding in a {@link PromptValidationReport}. */
|
|
68
|
+
type PromptValidationNote = {
|
|
69
|
+
/** How serious this finding is — drives the most-severe-first ordering. */severity: PromptValidationSeverity; /** Human-readable description of the finding. */
|
|
70
|
+
message: string; /** Optional concrete rewrite/fix for this finding. */
|
|
71
|
+
suggestion?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Result of {@link PromptRegistryContract.validate} — an overall quality
|
|
75
|
+
* score plus individual findings, most severe first.
|
|
76
|
+
*/
|
|
77
|
+
type PromptValidationReport = {
|
|
78
|
+
/** Overall quality score, `0`–`1`, from the LLM-as-judge rubric + static lint. */score: number; /** Individual findings, most severe first. */
|
|
79
|
+
notes: PromptValidationNote[];
|
|
80
|
+
};
|
|
81
|
+
/** Options for {@link PromptRegistryContract.validate}. */
|
|
82
|
+
type PromptValidateOptions = {
|
|
83
|
+
/**
|
|
84
|
+
* Model that powers the LLM-as-judge pass. When omitted (and no registry
|
|
85
|
+
* default `judgeModel` is set), `validate()` returns the static-lint
|
|
86
|
+
* findings only — never throwing.
|
|
87
|
+
*/
|
|
88
|
+
model?: ModelContract;
|
|
89
|
+
/**
|
|
90
|
+
* Validate a registered prompt's specific version (only meaningful when the
|
|
91
|
+
* first argument is a registered name). Default: the latest version.
|
|
92
|
+
*/
|
|
93
|
+
version?: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Public surface of the prompt registry returned by `prompt(options?)`.
|
|
97
|
+
*
|
|
98
|
+
* **Role.** A named, versioned, typed catalog wrapping `systemPrompt` /
|
|
99
|
+
* `SystemPrompt.fromFile` with `{{placeholder}}` validation, a `validate()`
|
|
100
|
+
* quality check (static lint + LLM-as-judge), and an optional Langfuse sync.
|
|
101
|
+
*
|
|
102
|
+
* Mutating methods (`register` / `add`) return the same registry for chaining.
|
|
103
|
+
*/
|
|
104
|
+
type PromptRegistryContract = {
|
|
105
|
+
/**
|
|
106
|
+
* Register a whole entry (name + its version history). Returns the registry
|
|
107
|
+
* for chaining. A name registered twice merges the new versions onto the
|
|
108
|
+
* existing history (duplicate version labels throw a
|
|
109
|
+
* {@link PromptValidationError}).
|
|
110
|
+
*/
|
|
111
|
+
register(entry: PromptEntry): PromptRegistryContract;
|
|
112
|
+
/**
|
|
113
|
+
* Add a new version to an existing name (creating the name when absent).
|
|
114
|
+
* A duplicate `version` label throws a {@link PromptValidationError} —
|
|
115
|
+
* never a silent overwrite.
|
|
116
|
+
*/
|
|
117
|
+
add(name: string, version: PromptVersion): PromptRegistryContract; /** Whether a name is registered. */
|
|
118
|
+
has(name: string): boolean; /** Every registered prompt name. */
|
|
119
|
+
list(): string[];
|
|
120
|
+
/**
|
|
121
|
+
* Resolve + render. Throws {@link PromptNotFoundError} on an unknown name
|
|
122
|
+
* and {@link PromptValidationError} when the picked version's `required`
|
|
123
|
+
* keys are missing from the merged placeholders.
|
|
124
|
+
*/
|
|
125
|
+
resolve(name: string, options?: PromptResolveOptions): ResolvedPrompt; /** Versions registered for a name, latest last. Throws {@link PromptNotFoundError} on miss. */
|
|
126
|
+
versions(name: string): PromptVersion[];
|
|
127
|
+
/**
|
|
128
|
+
* Quality-check a prompt body (raw text) or a registered prompt (by name).
|
|
129
|
+
* Runs a cheap static lint (length, undeclared/unresolved `{{placeholders}}`,
|
|
130
|
+
* missing role line) PLUS, when a model is resolvable, an LLM-as-judge pass
|
|
131
|
+
* over a clarity / role / output-format / conflict rubric — reusing the eval
|
|
132
|
+
* `judge` scorer. With no judge model, returns the static-lint findings only
|
|
133
|
+
* and never throws.
|
|
134
|
+
*/
|
|
135
|
+
validate(textOrName: string, options?: PromptValidateOptions): Promise<PromptValidationReport>;
|
|
136
|
+
/**
|
|
137
|
+
* Synchronize named prompts with Langfuse-prompts. Lazily imports the
|
|
138
|
+
* optional `langfuse` peer; pulls named prompts into the catalog and/or
|
|
139
|
+
* pushes local versions per the configured `direction`. Throws a curated
|
|
140
|
+
* install error when `langfuse` is not installed.
|
|
141
|
+
*/
|
|
142
|
+
sync(): Promise<void>;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Optional Langfuse-prompts sync configuration (see {@link PromptRegistryOptions}).
|
|
146
|
+
*/
|
|
147
|
+
type PromptLangfuseSyncOptions = {
|
|
148
|
+
/** A pre-built Langfuse client. When supplied, the SDK is never imported. */client?: LangfuseClientLike; /** Langfuse public key — used to construct a client when `client` is omitted. */
|
|
149
|
+
publicKey?: string; /** Langfuse secret key — used to construct a client when `client` is omitted. */
|
|
150
|
+
secretKey?: string; /** Langfuse host base URL. Optional; defaults to the SDK's own default. */
|
|
151
|
+
baseUrl?: string; /** Sync direction. `"pull"` (default) pulls remote prompts; `"push"` pushes local; `"both"` does both. */
|
|
152
|
+
direction?: "pull" | "push" | "both";
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Options for the `prompt(options?)` factory.
|
|
156
|
+
*/
|
|
157
|
+
type PromptRegistryOptions = {
|
|
158
|
+
/** Seed entries at construction. */prompts?: PromptEntry[];
|
|
159
|
+
/**
|
|
160
|
+
* Default model for the `validate()` LLM-as-judge pass when a call does not
|
|
161
|
+
* pass its own `model`. Absent = `validate()` is static-lint-only unless a
|
|
162
|
+
* per-call model is supplied.
|
|
163
|
+
*/
|
|
164
|
+
judgeModel?: ModelContract;
|
|
165
|
+
/**
|
|
166
|
+
* Optional Langfuse-prompts sync. Lazily imports `langfuse`; pulls named
|
|
167
|
+
* prompts on `.sync()` and (optionally) pushes local versions. Absent =
|
|
168
|
+
* fully local, no network.
|
|
169
|
+
*/
|
|
170
|
+
langfuse?: PromptLangfuseSyncOptions;
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
export { PromptEntry, PromptLangfuseSyncOptions, PromptRegistryContract, PromptRegistryOptions, PromptResolveOptions, PromptValidateOptions, PromptValidationNote, PromptValidationReport, PromptValidationSeverity, PromptVersion, ResolvedPrompt };
|
|
174
|
+
//# sourceMappingURL=prompt.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/prompt/prompt.type.ts"],"mappings":";;;;;;;;AAkBA;;;;;;;;;;AAae;KAbH,aAAA;EAuBW,uFArBrB,OAAA,UAyBuB;EAvBvB,QAAA;EAuBA;;;AAAuB;AAMzB;;EAtBE,QAAA,aA0B2B;EAxB3B,IAAA,GAAO,MAAM;AAAA;;;AAwBc;AAO7B;;;;KArBY,WAAA;EAyBV,2DAvBA,IAAA,UA+BA;EA7BA,QAAA,EAAU,aAAa;AAAA;AA6BO;AAIhC;;AAJgC,KAvBpB,oBAAA;EA2BwB,oFAzBlC,OAAA,WA4BU;EA1BV,YAAA,GAAe,YAAY;AAAA;;;;;KAOjB,cAAA;EAyBA,yCAvBV,IAAA,UA8BU;EA5BV,OAAA;EAEA,IAAA;EA4BA;;;;AAE2B;EAxB3B,cAAA,IAAkB,YAAY;AAAA;;KAIpB,wBAAA;;KAGA,oBAAA;EAgCV,2EA9BA,QAAA,EAAU,wBAAwB,EA8B3B;EA5BP,OAAA,UAwCgC;EAtChC,UAAA;AAAA;;;;;KAOU,sBAAA;EAwDc,kFAtDxB,KAAA,UAkEW;EAhEX,KAAA,EAAO,oBAAoB;AAAA;;KAIjB,qBAAA;EA8BV;;;;;EAxBA,KAAA,GAAQ,aAAa;EA8BM;;;;EAzB3B,OAAA;AAAA;;;;;;;;;;KAYU,sBAAA;EAoCE;;;;;;EA7BZ,QAAA,CAAS,KAAA,EAAO,WAAA,GAAc,sBAAA;EAqCf;AAMjB;;;;EArCE,GAAA,CAAI,IAAA,UAAc,OAAA,EAAS,aAAA,GAAgB,sBAAA,EAuClC;EArCT,GAAA,CAAI,IAAA,oBAyCJ;EAvCA,IAAA;EA2CA;;AAAS;AAMX;;EA3CE,OAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,oBAAA,GAAuB,cAAA,EA6C7C;EA3CV,QAAA,CAAS,IAAA,WAAe,aAAA;EAuDb;;;;;;;;EA9CX,QAAA,CACE,UAAA,UACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,sBAAA;EA2CyB;AAAA;;;;;EApCpC,IAAA,IAAQ,OAAA;AAAA;;;;KAME,yBAAA;+EAEV,MAAA,GAAS,kBAAkB;EAE3B,SAAA;EAEA,SAAA;EAEA,OAAA;EAEA,SAAA;AAAA;;;;KAMU,qBAAA;sCAEV,OAAA,GAAU,WAAA;;;;;;EAMV,UAAA,GAAa,aAAA;;;;;;EAMb,QAAA,GAAW,yBAAA;AAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ExportedPrompt, ExportedPromptVersion, ExportedRegistry, PromptDiff, PromptDiffBlock, PromptJudgeCacheLike, PromptTemplateVersion, PromptValidateTarget, PromptValidationResult, PromptsManagerOptions, PromptsValidateOptions } from "./prompts-manager.type.mjs";
|
|
2
|
+
import { PromptsManagerContract, PromptsManagerEntry, PromptsManagerRegisterOptions } from "./prompts-manager.contract.mjs";
|
|
3
|
+
import { defaultPromptsManager, promptKey, prompts } from "./prompts-manager.mjs";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Placeholders } from "../contracts/placeholders.type.mjs";
|
|
2
|
+
import { ExportedRegistry, PromptDiff, PromptTemplateVersion, PromptValidateTarget, PromptValidationResult, PromptsValidateOptions } from "./prompts-manager.type.mjs";
|
|
3
|
+
import { SystemPromptBlockContract, SystemPromptContract, SystemPromptMeta } from "../contracts/system-prompt.contract.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../@warlock.js/ai/src/prompts/prompts-manager.contract.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* One registered prompt in the {@link PromptsManagerContract} — a named,
|
|
8
|
+
* versioned `SystemPromptContract` plus the bookkeeping the manager needs to
|
|
9
|
+
* resolve "latest" deterministically.
|
|
10
|
+
*
|
|
11
|
+
* **Role.** The unit `register()` produces and `list()` / `get()` return. The
|
|
12
|
+
* registry is keyed by `name@version`, so the same `name` can hold many
|
|
13
|
+
* versions side by side, each its own entry.
|
|
14
|
+
*/
|
|
15
|
+
interface PromptsManagerEntry {
|
|
16
|
+
/** Registry name (from the contract's `meta.name`). */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Version label. Defaults to the next integer when registration omits it. */
|
|
19
|
+
readonly version: string;
|
|
20
|
+
/**
|
|
21
|
+
* Monotonic insertion order, sourced from an internal counter (never
|
|
22
|
+
* `Date.now()`), so "latest" is the highest `addedAt` for a name —
|
|
23
|
+
* deterministic and stable across same-tick registrations.
|
|
24
|
+
*/
|
|
25
|
+
readonly addedAt: number;
|
|
26
|
+
/** The registered prompt builder. */
|
|
27
|
+
readonly contract: SystemPromptContract;
|
|
28
|
+
/** Optional free-form tags for grouping / filtering. */
|
|
29
|
+
readonly tags?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
/** Options for {@link PromptsManagerContract.register}. */
|
|
32
|
+
interface PromptsManagerRegisterOptions {
|
|
33
|
+
/** Optional tags stored alongside the entry. */
|
|
34
|
+
readonly tags?: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
* Explicit name override. When set, it (not `contract.meta().name`) is the
|
|
37
|
+
* registry name — used by `define()` / `import()` to register an anonymous
|
|
38
|
+
* contract under a name without triggering the `SystemPrompt` constructor's
|
|
39
|
+
* auto-registration into the process-wide default manager.
|
|
40
|
+
*/
|
|
41
|
+
readonly name?: string;
|
|
42
|
+
/** Explicit version override, paired with {@link name}. */
|
|
43
|
+
readonly version?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Public surface of the prompts manager returned by `prompts()` and exposed as
|
|
47
|
+
* `ai.prompts`.
|
|
48
|
+
*
|
|
49
|
+
* **Role.** A single registry of named, versioned `SystemPromptContract`
|
|
50
|
+
* builders keyed by `name@version`. It owns registration (deriving the version
|
|
51
|
+
* when omitted, rejecting non-idempotent duplicates), version resolution
|
|
52
|
+
* (latest by insertion order), and one-call `resolve()` to the final string.
|
|
53
|
+
*
|
|
54
|
+
* **Responsibility.**
|
|
55
|
+
* - Owns: the `name@version` registry, the monotonic `addedAt` counter, the
|
|
56
|
+
* duplicate / idempotency rule, and latest-version selection.
|
|
57
|
+
* - Does NOT own: how a prompt renders (delegated to the contract's
|
|
58
|
+
* `resolve()`), the `{{placeholder}}` syntax, or block composition.
|
|
59
|
+
*/
|
|
60
|
+
interface PromptsManagerContract {
|
|
61
|
+
/**
|
|
62
|
+
* Register a prompt builder. The contract must carry `meta.name`; the
|
|
63
|
+
* version defaults to the next integer for that name when `meta.version` is
|
|
64
|
+
* omitted. Throws `InvalidRequestError` on a duplicate `name@version` unless
|
|
65
|
+
* the registered content is byte-identical (idempotent re-registration).
|
|
66
|
+
* Returns the manager for chaining.
|
|
67
|
+
*/
|
|
68
|
+
register(contract: SystemPromptContract, options?: PromptsManagerRegisterOptions): PromptsManagerContract;
|
|
69
|
+
/**
|
|
70
|
+
* Build a new `SystemPromptContract` — a documented alias of `ai.systemPrompt`.
|
|
71
|
+
* Identical input forms: no argument → empty builder; a single string → one
|
|
72
|
+
* instruction-seeded prompt; an array of blocks → used verbatim. Pass a `meta`
|
|
73
|
+
* with a `name` to auto-register the result in the process-wide `ai.prompts`
|
|
74
|
+
* default manager (same semantics as `ai.systemPrompt(input, { name })`).
|
|
75
|
+
*
|
|
76
|
+
* Provided so prompt authoring and the prompt registry share one entry point:
|
|
77
|
+
* `ai.prompts.create(...)` reads identically to `ai.prompts.get(...)` /
|
|
78
|
+
* `ai.prompts.resolve(...)` right beside it.
|
|
79
|
+
*/
|
|
80
|
+
create(input?: string | ReadonlyArray<SystemPromptBlockContract>, meta?: SystemPromptMeta): SystemPromptContract;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve a registered builder. The optional second argument selects the
|
|
83
|
+
* version by its label, by a pinned tag (`get(name, "production")`), or via
|
|
84
|
+
* the inline `name@selector` form folded into the first argument
|
|
85
|
+
* (`get("agent@production")`, `get("agent@2")`). With no selector, returns
|
|
86
|
+
* the latest by insertion order. Throws `InvalidRequestError` on an unknown
|
|
87
|
+
* name, version, or tag.
|
|
88
|
+
*/
|
|
89
|
+
get(name: string, versionOrTag?: string): SystemPromptContract;
|
|
90
|
+
/** Whether any version of `name` is registered (optionally a specific version/tag). */
|
|
91
|
+
has(name: string, versionOrTag?: string): boolean;
|
|
92
|
+
/** Every registered name, in first-seen order. */
|
|
93
|
+
list(): string[];
|
|
94
|
+
/** Version labels registered for a name, oldest first. Empty when unknown. */
|
|
95
|
+
versions(name: string): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a registered prompt to its final string in one call — picks the
|
|
98
|
+
* version (latest when omitted; a version label, a pinned tag, or the inline
|
|
99
|
+
* `name@selector` form is accepted) and renders it against `placeholders`.
|
|
100
|
+
* Throws `InvalidRequestError` on an unknown name / version / tag.
|
|
101
|
+
*/
|
|
102
|
+
resolve(name: string, versionOrTag?: string, placeholders?: Placeholders): string;
|
|
103
|
+
/**
|
|
104
|
+
* Bulk-register many versions of one name in a single call. Each entry's
|
|
105
|
+
* `template` is a raw string (wrapped into one instruction block) or an
|
|
106
|
+
* explicit ordered block list (used verbatim). Versions register oldest-first
|
|
107
|
+
* in array order; the same duplicate / idempotency rule as `register` applies
|
|
108
|
+
* per `name@version`. Returns the manager for chaining.
|
|
109
|
+
*/
|
|
110
|
+
define(name: string, versions: readonly PromptTemplateVersion[]): PromptsManagerContract;
|
|
111
|
+
/**
|
|
112
|
+
* Pin a tag to a specific registered version of a name (e.g.
|
|
113
|
+
* `tag("agent", "production", "2")`). The tag then resolves through
|
|
114
|
+
* `get(name, tag)` / `resolve(name, tag)` / the `name@tag` inline form.
|
|
115
|
+
* Re-pinning an existing tag moves it. Throws `InvalidRequestError` when the
|
|
116
|
+
* name or version is unknown. Returns the manager for chaining.
|
|
117
|
+
*/
|
|
118
|
+
tag(name: string, tag: string, version: string): PromptsManagerContract;
|
|
119
|
+
/**
|
|
120
|
+
* Unified prompt validation. ALWAYS runs the deterministic check — every
|
|
121
|
+
* `{{key}}` placeholder with no inline default that is neither supplied
|
|
122
|
+
* (`options.placeholders`) nor declared (`options.declare` + the prompt's
|
|
123
|
+
* `meta.required`) is reported in `missing`, and `ok` is `true` iff `missing`
|
|
124
|
+
* is empty. When `options.judge` is a model, ALSO runs a Nova-safe
|
|
125
|
+
* LLM-as-judge quality pass — it never throws and degrades to an `issues`
|
|
126
|
+
* note (leaving `score` undefined) on failure, so it never flips `ok`.
|
|
127
|
+
*
|
|
128
|
+
* `target` is a registered name (or `name@selector`), a `SystemPromptContract`
|
|
129
|
+
* instance, or a raw prompt string.
|
|
130
|
+
*/
|
|
131
|
+
validate(target: PromptValidateTarget, options?: PromptsValidateOptions): Promise<PromptValidationResult>;
|
|
132
|
+
/**
|
|
133
|
+
* Block-level diff between two registered versions of a name. Blocks are
|
|
134
|
+
* matched positionally; the result lists added / removed / changed blocks and
|
|
135
|
+
* an `identical` flag. Throws `InvalidRequestError` on an unknown name or
|
|
136
|
+
* version.
|
|
137
|
+
*/
|
|
138
|
+
diff(name: string, from: string, to: string): PromptDiff;
|
|
139
|
+
/**
|
|
140
|
+
* Serialize the whole registry to a portable JSON snapshot — every name, its
|
|
141
|
+
* versions (flattened to `{ type, text }` blocks), pinned tags, and carried
|
|
142
|
+
* `description` / `required` metadata. Round-trips through `import`.
|
|
143
|
+
*/
|
|
144
|
+
export(): ExportedRegistry;
|
|
145
|
+
/**
|
|
146
|
+
* Rehydrate a registry from an `export()` snapshot. Each version re-registers
|
|
147
|
+
* under its `name@version` (subject to the same duplicate / idempotency rule)
|
|
148
|
+
* and pinned tags are restored. Returns the manager for chaining.
|
|
149
|
+
*/
|
|
150
|
+
import(snapshot: ExportedRegistry): PromptsManagerContract;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { PromptsManagerContract, PromptsManagerEntry, PromptsManagerRegisterOptions };
|
|
154
|
+
//# sourceMappingURL=prompts-manager.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts-manager.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/prompts/prompts-manager.contract.ts"],"mappings":";;;;;;;AAwBA;;;;;;;UAAiB,mBAAA;EAeI;EAAA,SAbV,IAAA;EAgBI;EAAA,SAbJ,OAAA;EAiBM;;;;;EAAA,SAVN,OAAA;EAuBA;EAAA,SApBA,QAAA,EAAU,oBAAoB;EAoBvB;EAAA,SAjBP,IAAA;AAAA;;UAIM,6BAAA;EAyCH;EAAA,SAvCH,IAAA;EAsDwB;;;;;;EAAA,SA9CxB,IAAA;EA2FN;EAAA,SAxFM,OAAA;AAAA;;;;;;;;;;;;;;;;UAkBM,sBAAA;EAyBI;;;;;;;EAjBnB,QAAA,CACE,QAAA,EAAU,oBAAA,EACV,OAAA,GAAU,6BAAA,GACT,sBAAA;EA0Be;;;;;;;;;;;EAblB,MAAA,CACE,KAAA,YAAiB,aAAA,CAAc,yBAAA,GAC/B,IAAA,GAAO,gBAAA,GACN,oBAAA;EA8BD;;;;;;;;EApBF,GAAA,CAAI,IAAA,UAAc,YAAA,YAAwB,oBAAA;EA0CX;EAvC/B,GAAA,CAAI,IAAA,UAAc,YAAA;EAqDlB;EAlDA,IAAA;EAmDE;EAhDF,QAAA,CAAS,IAAA;EAiDP;;;;;;EAzCF,OAAA,CACE,IAAA,UACA,YAAA,WACA,YAAA,GAAe,YAAA;EA+C6B;;;;;;;EArC9C,MAAA,CACE,IAAA,UACA,QAAA,WAAmB,qBAAA,KAClB,sBAAA;EAgDuD;;;;;;;EAvC1D,GAAA,CAAI,IAAA,UAAc,GAAA,UAAa,OAAA,WAAkB,sBAAA;;;;;;;;;;;;;EAcjD,QAAA,CACE,MAAA,EAAQ,oBAAA,EACR,OAAA,GAAU,sBAAA,GACT,OAAA,CAAQ,sBAAA;;;;;;;EAQX,IAAA,CAAK,IAAA,UAAc,IAAA,UAAc,EAAA,WAAa,UAAA;;;;;;EAO9C,MAAA,IAAU,gBAAA;;;;;;EAOV,MAAA,CAAO,QAAA,EAAU,gBAAA,GAAmB,sBAAA;AAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PromptsManagerOptions } from "./prompts-manager.type.mjs";
|
|
2
|
+
import { PromptsManagerContract } from "./prompts-manager.contract.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../@warlock.js/ai/src/prompts/prompts-manager.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build the `name@version` registry key. Centralized so the duplicate check,
|
|
7
|
+
* `get`, and `composedFrom` provenance all agree on one label shape.
|
|
8
|
+
*/
|
|
9
|
+
declare function promptKey(name: string, version: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new, isolated prompts manager.
|
|
12
|
+
*
|
|
13
|
+
* **Role.** Public factory for {@link PromptsManagerContract} — keeps
|
|
14
|
+
* user-facing code free of `new` and consistent with the other `ai.*`
|
|
15
|
+
* factories. Each call returns a fresh registry, so parallel test suites and
|
|
16
|
+
* multi-tenant apps never share mutable global prompt state.
|
|
17
|
+
*
|
|
18
|
+
* The process-wide instance that named `systemPrompt(...)` builders
|
|
19
|
+
* auto-register into is `ai.prompts` (see {@link defaultPromptsManager}).
|
|
20
|
+
*
|
|
21
|
+
* @param options - Optional wiring, notably a `judgeCache` that memoizes
|
|
22
|
+
* LLM-judge verdicts (absent ⇒ every judge pass runs live).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const registry = prompts();
|
|
26
|
+
* registry.register(systemPrompt("You are support.", { name: "support" }));
|
|
27
|
+
* registry.resolve("support"); // "You are support."
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Memoize judge verdicts across validations.
|
|
31
|
+
* const registry = prompts({ judgeCache: new MemoryCacheDriver() });
|
|
32
|
+
*/
|
|
33
|
+
declare function prompts(options?: PromptsManagerOptions): PromptsManagerContract;
|
|
34
|
+
/** Accessor for the process-wide default {@link PromptsManagerContract}. */
|
|
35
|
+
declare function defaultPromptsManager(): PromptsManagerContract;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { defaultPromptsManager, promptKey, prompts };
|
|
38
|
+
//# sourceMappingURL=prompts-manager.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts-manager.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/prompts/prompts-manager.ts"],"mappings":";;;;;;AAsCA;;iBAAgB,SAAA,CAAU,IAAA,UAAc,OAAe;;AAAA;AAqnBvD;;;;;;;;AAAgF;AAehF;;;;AAA+D;;;;;;;;iBAf/C,OAAA,CAAQ,OAAA,GAAU,qBAAA,GAAwB,sBAAsB;;iBAehE,qBAAA,IAAyB,sBAAsB"}
|