@warlock.js/ai 4.4.0 → 4.6.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 +63 -52
- package/cjs/index.cjs +240 -14147
- package/cjs/src-Bmajk4Qg.cjs +30 -0
- package/cjs/src-OZyDYHxm.cjs +25089 -0
- package/cjs/src-OZyDYHxm.cjs.map +1 -0
- package/esm/agent/agent-config.type.d.mts +119 -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 +328 -36
- 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/agent/signature.mjs +57 -0
- package/esm/agent/signature.mjs.map +1 -0
- package/esm/agent/snapshot.mjs +101 -0
- package/esm/agent/snapshot.mjs.map +1 -0
- package/esm/ai-openai/src/embedder.mjs +4 -0
- package/esm/ai-openai/src/image.mjs +5 -0
- package/esm/ai-openai/src/index.mjs +7 -0
- package/esm/ai-openai/src/model.mjs +5 -0
- package/esm/ai-openai/src/sdk.mjs +9 -0
- package/esm/ai-openai/src/speech.mjs +5 -0
- package/esm/ai-openai/src/transcription.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +5 -0
- package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -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 +164 -53
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +79 -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 +33 -5
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
- package/esm/contracts/agent/agent-snapshot.type.d.mts +90 -0
- package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/agent/agent.contract.d.mts +29 -1
- package/esm/contracts/agent/agent.contract.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/agent/index.d.mts +2 -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/image-model.contract.d.mts +156 -0
- package/esm/contracts/image-model.contract.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +13 -6
- 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 +3 -2
- package/esm/contracts/planner/planner-config.type.d.mts +61 -0
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts +60 -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-snapshot.type.d.mts +77 -0
- package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner.contract.d.mts +21 -1
- package/esm/contracts/planner/planner.contract.d.mts.map +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/sdk-adapter.contract.d.mts +37 -0
- package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -1
- package/esm/contracts/speech-model.contract.d.mts +97 -0
- package/esm/contracts/speech-model.contract.d.mts.map +1 -0
- 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/transcription-model.contract.d.mts +101 -0
- package/esm/contracts/transcription-model.contract.d.mts.map +1 -0
- 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/agent-drift-error.d.mts +32 -0
- package/esm/errors/agent-drift-error.d.mts.map +1 -0
- package/esm/errors/agent-drift-error.mjs +31 -0
- package/esm/errors/agent-drift-error.mjs.map +1 -0
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/index.d.mts +3 -0
- package/esm/errors/index.mjs +3 -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/errors/planner-drift-error.d.mts +34 -0
- package/esm/errors/planner-drift-error.d.mts.map +1 -0
- package/esm/errors/planner-drift-error.mjs +33 -0
- package/esm/errors/planner-drift-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/image/image-cost.d.mts +32 -0
- package/esm/image/image-cost.d.mts.map +1 -0
- package/esm/image/image-cost.mjs +55 -0
- package/esm/image/image-cost.mjs.map +1 -0
- package/esm/image/image.d.mts +92 -0
- package/esm/image/image.d.mts.map +1 -0
- package/esm/image/image.mjs +113 -0
- package/esm/image/image.mjs.map +1 -0
- package/esm/image/index.mjs +4 -0
- package/esm/index.d.mts +137 -24
- package/esm/index.mjs +101 -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/mock/index.d.mts +3 -0
- package/esm/mock/index.mjs +3 -0
- package/esm/mock/mock-config.type.d.mts +22 -0
- package/esm/mock/mock-config.type.d.mts.map +1 -1
- package/esm/mock/mock-image-model.d.mts +41 -0
- package/esm/mock/mock-image-model.d.mts.map +1 -0
- package/esm/mock/mock-image-model.mjs +52 -0
- package/esm/mock/mock-image-model.mjs.map +1 -0
- package/esm/mock/mock-sdk.d.mts +7 -1
- package/esm/mock/mock-sdk.d.mts.map +1 -1
- package/esm/mock/mock-sdk.mjs +27 -0
- package/esm/mock/mock-sdk.mjs.map +1 -1
- package/esm/mock/mock-speech-model.d.mts +31 -0
- package/esm/mock/mock-speech-model.d.mts.map +1 -0
- package/esm/mock/mock-speech-model.mjs +39 -0
- package/esm/mock/mock-speech-model.mjs.map +1 -0
- package/esm/mock/mock-transcription-model.d.mts +32 -0
- package/esm/mock/mock-transcription-model.d.mts.map +1 -0
- package/esm/mock/mock-transcription-model.mjs +36 -0
- package/esm/mock/mock-transcription-model.mjs.map +1 -0
- 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 +8 -0
- package/esm/planner/planner-run.d.mts.map +1 -1
- package/esm/planner/planner-run.mjs +457 -31
- package/esm/planner/planner-run.mjs.map +1 -1
- package/esm/planner/planner.d.mts.map +1 -1
- package/esm/planner/planner.mjs +26 -2
- package/esm/planner/planner.mjs.map +1 -1
- package/esm/planner/snapshot.mjs +95 -0
- package/esm/planner/snapshot.mjs.map +1 -0
- 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 +22 -0
- package/esm/rag/index.mjs +18 -0
- package/esm/rag/loaders/errors.d.mts +19 -0
- package/esm/rag/loaders/errors.d.mts.map +1 -0
- package/esm/rag/loaders/errors.mjs +25 -0
- package/esm/rag/loaders/errors.mjs.map +1 -0
- package/esm/rag/loaders/index.mjs +7 -0
- package/esm/rag/loaders/load-html.d.mts +26 -0
- package/esm/rag/loaders/load-html.d.mts.map +1 -0
- package/esm/rag/loaders/load-html.mjs +138 -0
- package/esm/rag/loaders/load-html.mjs.map +1 -0
- package/esm/rag/loaders/load-pdf.d.mts +38 -0
- package/esm/rag/loaders/load-pdf.d.mts.map +1 -0
- package/esm/rag/loaders/load-pdf.mjs +150 -0
- package/esm/rag/loaders/load-pdf.mjs.map +1 -0
- package/esm/rag/loaders/load-text.d.mts +47 -0
- package/esm/rag/loaders/load-text.d.mts.map +1 -0
- package/esm/rag/loaders/load-text.mjs +60 -0
- package/esm/rag/loaders/load-text.mjs.map +1 -0
- package/esm/rag/loaders/load-web.d.mts +42 -0
- package/esm/rag/loaders/load-web.d.mts.map +1 -0
- package/esm/rag/loaders/load-web.mjs +89 -0
- package/esm/rag/loaders/load-web.mjs.map +1 -0
- package/esm/rag/loaders/loader.type.d.mts +89 -0
- package/esm/rag/loaders/loader.type.d.mts.map +1 -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/pg-vector-store.d.mts +139 -0
- package/esm/rag/store/pg-vector-store.d.mts.map +1 -0
- package/esm/rag/store/pg-vector-store.mjs +328 -0
- package/esm/rag/store/pg-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/speech/index.mjs +3 -0
- package/esm/speech/speech.d.mts +65 -0
- package/esm/speech/speech.d.mts.map +1 -0
- package/esm/speech/speech.mjs +123 -0
- package/esm/speech/speech.mjs.map +1 -0
- package/esm/supervisor/as-tool.mjs +2 -2
- package/esm/supervisor/as-tool.mjs.map +1 -1
- package/esm/supervisor/entries.mjs +2 -2
- package/esm/supervisor/entries.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/transcribe/audio-input.d.mts +47 -0
- package/esm/transcribe/audio-input.d.mts.map +1 -0
- package/esm/transcribe/audio-input.mjs +84 -0
- package/esm/transcribe/audio-input.mjs.map +1 -0
- package/esm/transcribe/index.mjs +4 -0
- package/esm/transcribe/transcribe.d.mts +64 -0
- package/esm/transcribe/transcribe.d.mts.map +1 -0
- package/esm/transcribe/transcribe.mjs +128 -0
- package/esm/transcribe/transcribe.mjs.map +1 -0
- 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 +2572 -204
- package/llms.txt +21 -4
- package/package.json +7 -3
- package/skills/README.md +44 -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-agent-runs/SKILL.md +135 -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/generate-images/SKILL.md +138 -0
- package/skills/generate-speech/SKILL.md +139 -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/rag-loaders-and-stores/SKILL.md +164 -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/transcribe-audio/SKILL.md +157 -0
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.mjs","names":["createPromptsManager"],"sources":["../../../../../../../@warlock.js/ai/src/prompt/prompt.ts"],"sourcesContent":["import type { SystemPromptContract } from \"../contracts/system-prompt.contract\";\nimport {\n defaultPromptsManager,\n prompts as createPromptsManager,\n} from \"../prompts/prompts-manager\";\nimport type { PromptsManagerContract } from \"../prompts/prompts-manager.contract\";\nimport { Instruction } from \"../system-prompt/instruction\";\nimport { renderPlaceholders } from \"../system-prompt/render-placeholders\";\nimport { SystemPrompt } from \"../system-prompt/system-prompt\";\nimport { PromptNotFoundError, PromptValidationError } from \"./errors\";\nimport {\n syncLangfusePrompts,\n warmLangfuse,\n} from \"./prompt-langfuse-sync\";\nimport {\n buildValidationReport,\n judgePrompt,\n staticLint,\n} from \"./prompt-validate\";\nimport { agent } from \"../agent/agent\";\nimport type { AgentContract } from \"../contracts/agent/agent.contract\";\nimport type { ModelContract } from \"../contracts/model.contract\";\nimport type {\n PromptEntry,\n PromptRegistryContract,\n PromptRegistryOptions,\n PromptResolveOptions,\n PromptValidateOptions,\n PromptValidationReport,\n PromptVersion,\n ResolvedPrompt,\n} from \"./prompt.type\";\n\n/**\n * Build the one-shot judge agent the `validate()` LLM-as-judge pass runs.\n * Name-bearing (the eval `judge` scorer requires a usable agent) and seeded\n * with a strict-JSON instruction so its verdict parses even without an output\n * schema. Kept module-private so the registry's only model dependency is the\n * `agent()` factory.\n */\nfunction buildJudgeAgent(model: ModelContract): AgentContract<unknown> {\n return agent({\n name: \"prompt-quality-judge\",\n model,\n systemPrompt:\n \"You are a strict prompt-quality grader. Respond with JSON only: \" +\n '{ \"score\": <0..1>, \"passed\": <true|false>, \"reason\": \"<short explanation>\" }.',\n });\n}\n\n/**\n * Build the `SystemPromptContract` a single {@link PromptVersion} maps to: its\n * `template` becomes one instruction block, and its `required` keys ride along\n * as `meta.required` so the unified manager (and `validate`) can see them.\n *\n * Deliberately ANONYMOUS (no `meta.name`) so the `SystemPrompt` constructor\n * never auto-registers this version into the process-wide `ai.prompts` default\n * manager — each `prompt()` registry owns its OWN isolated\n * {@link PromptsManagerContract}, the single storage shape behind this facade.\n */\nfunction versionToContract(version: PromptVersion): SystemPromptContract {\n return new SystemPrompt([new Instruction(version.template)], {\n ...(version.required ? { required: version.required } : {}),\n });\n}\n\n/**\n * Legacy `PromptRegistryContract` — now a THIN FACADE over the unified\n * {@link PromptsManagerContract} (`ai.prompts`).\n *\n * **Role.** The store behind `ai.prompt(...)`. Historically it held a private\n * `Map<string, PromptVersion[]>`; it now delegates ALL storage to a private,\n * per-instance {@link PromptsManagerContract}, so there is exactly ONE storage\n * shape across the whole prompt surface: a `SystemPromptContract` keyed by\n * `name@version`. A version's raw `template` string maps to a single\n * instruction block and its `required` keys to `meta.required`.\n *\n * **Responsibility.**\n * - Owns: the legacy method surface (`register` / `add` / `versions` /\n * `resolve` / `validate` / `sync`) and the back-compat behaviors — duplicate\n * version rejection, required-key assertion on `resolve()`, the\n * `{ score, notes }` validation report shape, and the optional Langfuse sync.\n * - Does NOT own: the actual storage (delegated to the internal manager),\n * placeholder rendering (delegated to `renderPlaceholders`), or the unified\n * validation primitives (delegated to `prompt-validate`).\n *\n * Each `prompt(options)` call builds its own isolated manager — so parallel\n * test suites and multi-tenant apps never share mutable global prompt state,\n * exactly as before the unification.\n *\n * Users construct via the `prompt()` factory — `new PromptRegistry()` is not\n * the public API.\n */\nclass PromptRegistry implements PromptRegistryContract {\n /** The single backing store — one isolated unified manager per registry. */\n private readonly manager: PromptsManagerContract;\n\n /** Per-name version metadata mirror, kept so `versions()` returns the rich\n * {@link PromptVersion} shape (template + required + meta) the legacy API\n * promised — the manager itself only stores the flattened contract. */\n private readonly versionMeta = new Map<string, PromptVersion[]>();\n\n public constructor(private readonly options: PromptRegistryOptions = {}) {\n this.manager = createPromptsManager();\n\n for (const entry of options.prompts ?? []) {\n this.register(entry);\n }\n\n if (options.langfuse) {\n warmLangfuse(options.langfuse);\n }\n }\n\n /**\n * Register a whole entry. Merges onto an existing name's history; a\n * duplicate version label throws {@link PromptValidationError}.\n */\n public register(entry: PromptEntry): PromptRegistryContract {\n for (const version of entry.versions) {\n this.add(entry.name, version);\n }\n\n // An entry with an empty version list still creates the name so `has`\n // / `list` reflect it.\n if (!this.versionMeta.has(entry.name)) {\n this.versionMeta.set(entry.name, []);\n }\n\n return this;\n }\n\n /**\n * Add a new version to a name (creating it when absent). A duplicate\n * version label throws {@link PromptValidationError} — never a silent\n * overwrite.\n */\n public add(name: string, version: PromptVersion): PromptRegistryContract {\n const mirror = this.versionMeta.get(name) ?? [];\n\n if (mirror.some(existing => existing.version === version.version)) {\n throw new PromptValidationError(\n `Prompt \"${name}\" already has a version labeled \"${version.version}\".`,\n { context: { name, version: version.version } },\n );\n }\n\n this.manager.register(versionToContract(version), {\n name,\n version: version.version,\n });\n\n this.versionMeta.set(name, [...mirror, version]);\n\n return this;\n }\n\n /** Whether a name is registered. */\n public has(name: string): boolean {\n return this.versionMeta.has(name);\n }\n\n /** Every registered prompt name, in registration order. */\n public list(): string[] {\n return [...this.versionMeta.keys()];\n }\n\n /** Versions registered for a name, latest last. Throws on an unknown name. */\n public versions(name: string): PromptVersion[] {\n const mirror = this.versionMeta.get(name);\n\n if (!mirror) {\n throw new PromptNotFoundError(name);\n }\n\n return [...mirror];\n }\n\n /**\n * Resolve + render. Picks the requested or latest version, validates the\n * version's `required` keys against the merged placeholders, then renders by\n * delegating to the shared `renderPlaceholders` over the contract's text.\n */\n public resolve(name: string, options: PromptResolveOptions = {}): ResolvedPrompt {\n const picked = this.pickVersion(name, options.version);\n const placeholders = options.placeholders ?? {};\n\n this.assertRequired(name, picked, placeholders);\n\n // Render the RAW template (placeholders intact) against the merged values —\n // resolving the contract first would bake inline `{{key|default}}` defaults\n // in and shadow an explicitly-supplied value. The stored block text is the\n // single source of the un-rendered template.\n const contract = this.manager.get(name, picked.version);\n const template = contract.blocks[0]?.text ?? picked.template;\n const text = renderPlaceholders(template, placeholders);\n\n return {\n name,\n version: picked.version,\n text,\n toSystemPrompt: () => new SystemPrompt([new Instruction(text)]),\n };\n }\n\n /**\n * Quality-check a raw prompt body or a registered prompt (by name). Backed by\n * the unified deterministic validate primitives plus the LLM-as-judge pass,\n * but returns the legacy `{ score, notes }` report shape so existing callers\n * keep working.\n *\n * Always runs the static lint; runs the LLM-as-judge pass too when a model is\n * resolvable. Never throws when no judge model is available.\n */\n public async validate(\n textOrName: string,\n options: PromptValidateOptions = {},\n ): Promise<PromptValidationReport> {\n const text = this.resolveValidationText(textOrName, options.version);\n const staticNotes = staticLint(text);\n\n const model = options.model ?? this.options.judgeModel;\n\n if (!model) {\n return buildValidationReport(staticNotes);\n }\n\n const judgeResult = await judgePrompt(text, model, buildJudgeAgent);\n\n return buildValidationReport(staticNotes, judgeResult);\n }\n\n /**\n * Synchronize named prompts with Langfuse-prompts. No-op (resolves) when no\n * `langfuse` option was configured. The resolved (rendered) body + the\n * `name@version` label are what is pushed/pulled.\n */\n public async sync(): Promise<void> {\n if (!this.options.langfuse) {\n return;\n }\n\n await syncLangfusePrompts(\n this.options.langfuse,\n this.list(),\n this.snapshotEntries(),\n entry => this.register(entry),\n );\n }\n\n /**\n * Pick the requested (or latest) {@link PromptVersion} for a name from the\n * mirror, throwing {@link PromptNotFoundError} on an unknown name or version.\n */\n private pickVersion(name: string, version?: string): PromptVersion {\n const mirror = this.versionMeta.get(name);\n\n if (!mirror || mirror.length === 0) {\n throw new PromptNotFoundError(name);\n }\n\n const picked = version\n ? mirror.find(candidate => candidate.version === version)\n : mirror[mirror.length - 1];\n\n if (!picked) {\n throw new PromptNotFoundError(name, {\n context: { name, version },\n });\n }\n\n return picked;\n }\n\n /**\n * Resolve the text `validate()` should grade: a registered name yields its\n * picked version's raw `template`; anything else is treated as the raw body.\n */\n private resolveValidationText(textOrName: string, version?: string): string {\n const mirror = this.versionMeta.get(textOrName);\n\n if (!mirror || mirror.length === 0) {\n return textOrName;\n }\n\n const picked = version\n ? mirror.find(candidate => candidate.version === version)\n : mirror[mirror.length - 1];\n\n return picked ? picked.template : textOrName;\n }\n\n /**\n * Throw {@link PromptValidationError} listing every `required` key absent\n * from the merged placeholders. A no-op when the version declares none.\n */\n private assertRequired(\n name: string,\n version: PromptVersion,\n placeholders: Record<string, unknown>,\n ): void {\n if (!version.required || version.required.length === 0) {\n return;\n }\n\n const missing = version.required.filter(\n key => placeholders[key] === undefined || placeholders[key] === null || placeholders[key] === \"\",\n );\n\n if (missing.length > 0) {\n throw new PromptValidationError(\n `Prompt \"${name}\" version \"${version.version}\" is missing required placeholder${\n missing.length > 1 ? \"s\" : \"\"\n }: ${missing.join(\", \")}.`,\n { context: { name, version: version.version, missing } },\n );\n }\n }\n\n /** Snapshot the catalog as `PromptEntry[]` (for the Langfuse push path). */\n private snapshotEntries(): PromptEntry[] {\n return [...this.versionMeta.entries()].map(([name, versions]) => ({\n name,\n versions: [...versions],\n }));\n }\n}\n\n/**\n * Create a versioned, typed prompt registry — a thin facade over the unified\n * `ai.prompts` manager.\n *\n * **Role.** Public factory for {@link PromptRegistryContract}. Keeps\n * user-facing code free of `new` and consistent with `ai.memory`,\n * `ai.orchestrator`, `ai.batch` (all return instances). Each call returns a\n * fresh, isolated registry backed by its own unified manager, so parallel test\n * suites and multi-tenant apps never share mutable global prompt state.\n *\n * @param options - Seed entries, an optional default judge model, and an\n * optional Langfuse sync.\n *\n * @example\n * const prompts = prompt({\n * prompts: [\n * {\n * name: \"support-agent\",\n * versions: [\n * { version: \"1\", template: \"You are support for {{product}}. Reply in {{language|English}}.\" },\n * { version: \"2\", template: \"You are senior support for {{product}}.\", required: [\"product\"] },\n * ],\n * },\n * ],\n * });\n *\n * const resolved = prompts.resolve(\"support-agent\", { placeholders: { product: \"Warlock\" } });\n * const agent = ai.agent({ model, systemPrompt: resolved.toSystemPrompt() });\n * // resolved.version === \"2\"; a missing `product` would throw PromptValidationError.\n *\n * @example\n * // Resolve a globally-registered prompt by name from `ai.prompts`.\n * ai.systemPrompt(\"You are support.\", { name: \"support\" });\n * const sp = ai.prompt(\"support\"); // → the registered SystemPromptContract\n */\nfunction promptFactory(\n name: string,\n versionOrTag?: string,\n): SystemPromptContract;\nfunction promptFactory(options?: PromptRegistryOptions): PromptRegistryContract;\nfunction promptFactory(\n first?: string | PromptRegistryOptions,\n versionOrTag?: string,\n): SystemPromptContract | PromptRegistryContract {\n // String form: resolve a globally-registered prompt from the process-wide\n // `ai.prompts` manager (the single unified registry). This is the thin\n // facade's read path onto the shared store.\n if (typeof first === \"string\") {\n return defaultPromptsManager().get(first, versionOrTag);\n }\n\n // Options form: build an isolated registry backed by its own unified manager.\n return new PromptRegistry(first);\n}\n\n/**\n * Create a versioned prompt registry, OR resolve a globally-registered prompt\n * by name from `ai.prompts`.\n *\n * - `prompt(options?)` → a fresh, isolated {@link PromptRegistryContract}.\n * - `prompt(name, versionOrTag?)` → the `SystemPromptContract` registered under\n * `name` in the process-wide `ai.prompts` manager (latest version by default,\n * or a specific version / pinned tag).\n */\nexport const prompt: typeof promptFactory = promptFactory;\n"],"mappings":"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"}
|
|
@@ -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"}
|