@warlock.js/core 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 +72 -5
- package/README.md +47 -11
- package/esm/ai/src/agent/agent-input-builder.mjs +132 -0
- package/esm/ai/src/agent/agent-input-builder.mjs.map +1 -0
- package/esm/ai/src/agent/agent-log-event.mjs +101 -0
- package/esm/ai/src/agent/agent-log-event.mjs.map +1 -0
- package/esm/ai/src/agent/agent-stream.mjs +82 -0
- package/esm/ai/src/agent/agent-stream.mjs.map +1 -0
- package/esm/ai/src/agent/agent-to-stream-event.mjs +86 -0
- package/esm/ai/src/agent/agent-to-stream-event.mjs.map +1 -0
- package/esm/ai/src/agent/agent.mjs +1276 -0
- package/esm/ai/src/agent/agent.mjs.map +1 -0
- package/esm/ai/src/agent/index.mjs +5 -0
- package/esm/ai/src/agent/json-stream-guard.mjs +400 -0
- package/esm/ai/src/agent/json-stream-guard.mjs.map +1 -0
- package/esm/ai/src/agent/signature.mjs +57 -0
- package/esm/ai/src/agent/signature.mjs.map +1 -0
- package/esm/ai/src/agent/snapshot.mjs +101 -0
- package/esm/ai/src/agent/snapshot.mjs.map +1 -0
- package/esm/ai/src/agent/spawn-sub-agent.mjs +68 -0
- package/esm/ai/src/agent/spawn-sub-agent.mjs.map +1 -0
- package/esm/ai/src/ai.mjs +191 -0
- package/esm/ai/src/ai.mjs.map +1 -0
- package/esm/ai/src/batch/batch.mjs +198 -0
- package/esm/ai/src/batch/batch.mjs.map +1 -0
- package/esm/ai/src/batch/index.mjs +3 -0
- package/esm/ai/src/batch/run-batch-item.mjs +100 -0
- package/esm/ai/src/batch/run-batch-item.mjs.map +1 -0
- package/esm/ai/src/batch/run-with-concurrency.mjs +39 -0
- package/esm/ai/src/batch/run-with-concurrency.mjs.map +1 -0
- package/esm/ai/src/checkpoint/memory.mjs +0 -0
- package/esm/ai/src/checkpoint/memory.mjs.map +1 -0
- package/esm/ai/src/checkpoint/pg.mjs +265 -0
- package/esm/ai/src/checkpoint/pg.mjs.map +1 -0
- package/esm/ai/src/checkpoint/redis.mjs +200 -0
- package/esm/ai/src/checkpoint/redis.mjs.map +1 -0
- package/esm/ai/src/config.mjs +59 -0
- package/esm/ai/src/config.mjs.map +1 -0
- package/esm/ai/src/contracts/end.type.mjs +47 -0
- package/esm/ai/src/contracts/end.type.mjs.map +1 -0
- package/esm/ai/src/errors/agent-cancelled-error.mjs +43 -0
- package/esm/ai/src/errors/agent-cancelled-error.mjs.map +1 -0
- package/esm/ai/src/errors/agent-drift-error.mjs +31 -0
- package/esm/ai/src/errors/agent-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/agent-execution-error.mjs +35 -0
- package/esm/ai/src/errors/agent-execution-error.mjs.map +1 -0
- package/esm/ai/src/errors/agent-max-trips-error.mjs +41 -0
- package/esm/ai/src/errors/agent-max-trips-error.mjs.map +1 -0
- package/esm/ai/src/errors/ai-error.mjs +68 -0
- package/esm/ai/src/errors/ai-error.mjs.map +1 -0
- package/esm/ai/src/errors/budget-exceeded-error.mjs +31 -0
- package/esm/ai/src/errors/budget-exceeded-error.mjs.map +1 -0
- package/esm/ai/src/errors/content-filter-error.mjs +28 -0
- package/esm/ai/src/errors/content-filter-error.mjs.map +1 -0
- package/esm/ai/src/errors/context-length-exceeded-error.mjs +31 -0
- package/esm/ai/src/errors/context-length-exceeded-error.mjs.map +1 -0
- package/esm/ai/src/errors/guardrail-violation-error.mjs +41 -0
- package/esm/ai/src/errors/guardrail-violation-error.mjs.map +1 -0
- package/esm/ai/src/errors/index.mjs +39 -0
- package/esm/ai/src/errors/invalid-request-error.mjs +31 -0
- package/esm/ai/src/errors/invalid-request-error.mjs.map +1 -0
- package/esm/ai/src/errors/max-iterations-error.mjs +32 -0
- package/esm/ai/src/errors/max-iterations-error.mjs.map +1 -0
- package/esm/ai/src/errors/max-steps-exceeded-error.mjs +21 -0
- package/esm/ai/src/errors/max-steps-exceeded-error.mjs.map +1 -0
- package/esm/ai/src/errors/orchestrator-cancelled-error.mjs +31 -0
- package/esm/ai/src/errors/orchestrator-cancelled-error.mjs.map +1 -0
- package/esm/ai/src/errors/orchestrator-config-error.mjs +30 -0
- package/esm/ai/src/errors/orchestrator-config-error.mjs.map +1 -0
- package/esm/ai/src/errors/orchestrator-drift-error.mjs +37 -0
- package/esm/ai/src/errors/orchestrator-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/orchestrator-failed-error.mjs +36 -0
- package/esm/ai/src/errors/orchestrator-failed-error.mjs.map +1 -0
- package/esm/ai/src/errors/outbound-policy-error.mjs +32 -0
- package/esm/ai/src/errors/outbound-policy-error.mjs.map +1 -0
- package/esm/ai/src/errors/planner-cancelled-error.mjs +29 -0
- package/esm/ai/src/errors/planner-cancelled-error.mjs.map +1 -0
- package/esm/ai/src/errors/planner-drift-error.mjs +33 -0
- package/esm/ai/src/errors/planner-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/planner-failed-error.mjs +37 -0
- package/esm/ai/src/errors/planner-failed-error.mjs.map +1 -0
- package/esm/ai/src/errors/planner-plan-invalid-error.mjs +25 -0
- package/esm/ai/src/errors/planner-plan-invalid-error.mjs.map +1 -0
- package/esm/ai/src/errors/provider-auth-error.mjs +26 -0
- package/esm/ai/src/errors/provider-auth-error.mjs.map +1 -0
- package/esm/ai/src/errors/provider-error.mjs +42 -0
- package/esm/ai/src/errors/provider-error.mjs.map +1 -0
- package/esm/ai/src/errors/provider-rate-limit-error.mjs +31 -0
- package/esm/ai/src/errors/provider-rate-limit-error.mjs.map +1 -0
- package/esm/ai/src/errors/provider-timeout-error.mjs +26 -0
- package/esm/ai/src/errors/provider-timeout-error.mjs.map +1 -0
- package/esm/ai/src/errors/quota-exceeded-error.mjs +40 -0
- package/esm/ai/src/errors/quota-exceeded-error.mjs.map +1 -0
- package/esm/ai/src/errors/routing-error.mjs +23 -0
- package/esm/ai/src/errors/routing-error.mjs.map +1 -0
- package/esm/ai/src/errors/schema-validation-error.mjs +37 -0
- package/esm/ai/src/errors/schema-validation-error.mjs.map +1 -0
- package/esm/ai/src/errors/step-failed-error.mjs +19 -0
- package/esm/ai/src/errors/step-failed-error.mjs.map +1 -0
- package/esm/ai/src/errors/supervisor-cancelled-error.mjs +29 -0
- package/esm/ai/src/errors/supervisor-cancelled-error.mjs.map +1 -0
- package/esm/ai/src/errors/supervisor-drift-error.mjs +30 -0
- package/esm/ai/src/errors/supervisor-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/supervisor-failed-error.mjs +43 -0
- package/esm/ai/src/errors/supervisor-failed-error.mjs.map +1 -0
- package/esm/ai/src/errors/supervisor-routing-error.mjs +39 -0
- package/esm/ai/src/errors/supervisor-routing-error.mjs.map +1 -0
- package/esm/ai/src/errors/tool-execution-error.mjs +32 -0
- package/esm/ai/src/errors/tool-execution-error.mjs.map +1 -0
- package/esm/ai/src/errors/workflow-cancelled-error.mjs +23 -0
- package/esm/ai/src/errors/workflow-cancelled-error.mjs.map +1 -0
- package/esm/ai/src/errors/workflow-drift-error.mjs +24 -0
- package/esm/ai/src/errors/workflow-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/workflow-error.mjs +18 -0
- package/esm/ai/src/errors/workflow-error.mjs.map +1 -0
- package/esm/ai/src/eval/dataset.mjs +112 -0
- package/esm/ai/src/eval/dataset.mjs.map +1 -0
- package/esm/ai/src/eval/eval-runner.mjs +135 -0
- package/esm/ai/src/eval/eval-runner.mjs.map +1 -0
- package/esm/ai/src/eval/index.mjs +48 -0
- package/esm/ai/src/eval/index.mjs.map +1 -0
- package/esm/ai/src/eval/judge-scorer.mjs +87 -0
- package/esm/ai/src/eval/judge-scorer.mjs.map +1 -0
- package/esm/ai/src/eval/regression.mjs +51 -0
- package/esm/ai/src/eval/regression.mjs.map +1 -0
- package/esm/ai/src/eval/report-json.mjs +33 -0
- package/esm/ai/src/eval/report-json.mjs.map +1 -0
- package/esm/ai/src/eval/report-junit.mjs +60 -0
- package/esm/ai/src/eval/report-junit.mjs.map +1 -0
- package/esm/ai/src/eval/scorers.mjs +101 -0
- package/esm/ai/src/eval/scorers.mjs.map +1 -0
- package/esm/ai/src/guard/detectors/index.mjs +6 -0
- package/esm/ai/src/guard/detectors/injection.mjs +254 -0
- package/esm/ai/src/guard/detectors/injection.mjs.map +1 -0
- package/esm/ai/src/guard/detectors/moderation.mjs +134 -0
- package/esm/ai/src/guard/detectors/moderation.mjs.map +1 -0
- package/esm/ai/src/guard/detectors/pii.mjs +199 -0
- package/esm/ai/src/guard/detectors/pii.mjs.map +1 -0
- package/esm/ai/src/guard/detectors/topic.mjs +99 -0
- package/esm/ai/src/guard/detectors/topic.mjs.map +1 -0
- package/esm/ai/src/guard/errors.mjs +18 -0
- package/esm/ai/src/guard/errors.mjs.map +1 -0
- package/esm/ai/src/guard/guard.mjs +209 -0
- package/esm/ai/src/guard/guard.mjs.map +1 -0
- package/esm/ai/src/guard/guardrail.mjs +22 -0
- package/esm/ai/src/guard/guardrail.mjs.map +1 -0
- package/esm/ai/src/human/errors.mjs +60 -0
- package/esm/ai/src/human/errors.mjs.map +1 -0
- package/esm/ai/src/human/human-approval.mjs +170 -0
- package/esm/ai/src/human/human-approval.mjs.map +1 -0
- package/esm/ai/src/human/policy.mjs +67 -0
- package/esm/ai/src/human/policy.mjs.map +1 -0
- package/esm/ai/src/human/register.mjs +37 -0
- package/esm/ai/src/human/register.mjs.map +1 -0
- package/esm/ai/src/human/resume-seed.mjs +53 -0
- package/esm/ai/src/human/resume-seed.mjs.map +1 -0
- package/esm/ai/src/human/resume.mjs +121 -0
- package/esm/ai/src/human/resume.mjs.map +1 -0
- package/esm/ai/src/human/stores/index.mjs +5 -0
- package/esm/ai/src/human/stores/memory.mjs +91 -0
- package/esm/ai/src/human/stores/memory.mjs.map +1 -0
- package/esm/ai/src/human/stores/pg.mjs +220 -0
- package/esm/ai/src/human/stores/pg.mjs.map +1 -0
- package/esm/ai/src/human/stores/redis.mjs +201 -0
- package/esm/ai/src/human/stores/redis.mjs.map +1 -0
- package/esm/ai/src/image/image-cost.mjs +55 -0
- package/esm/ai/src/image/image-cost.mjs.map +1 -0
- package/esm/ai/src/image/image.mjs +112 -0
- package/esm/ai/src/image/image.mjs.map +1 -0
- package/esm/ai/src/image/index.mjs +4 -0
- package/esm/ai/src/index.mjs +194 -0
- package/esm/ai/src/memory/derive-id.mjs +24 -0
- package/esm/ai/src/memory/derive-id.mjs.map +1 -0
- package/esm/ai/src/memory/episodic-memory.mjs +106 -0
- package/esm/ai/src/memory/episodic-memory.mjs.map +1 -0
- package/esm/ai/src/memory/memory.mjs +166 -0
- package/esm/ai/src/memory/memory.mjs.map +1 -0
- package/esm/ai/src/memory/procedural-memory.mjs +103 -0
- package/esm/ai/src/memory/procedural-memory.mjs.map +1 -0
- package/esm/ai/src/memory/semantic-memory.mjs +80 -0
- package/esm/ai/src/memory/semantic-memory.mjs.map +1 -0
- package/esm/ai/src/memory/working-memory.mjs +62 -0
- package/esm/ai/src/memory/working-memory.mjs.map +1 -0
- package/esm/ai/src/middleware/builtins/budget.mjs +219 -0
- package/esm/ai/src/middleware/builtins/budget.mjs.map +1 -0
- package/esm/ai/src/middleware/builtins/guardrail.mjs +76 -0
- package/esm/ai/src/middleware/builtins/guardrail.mjs.map +1 -0
- package/esm/ai/src/middleware/builtins/semantic-cache.mjs +149 -0
- package/esm/ai/src/middleware/builtins/semantic-cache.mjs.map +1 -0
- package/esm/ai/src/middleware/helpers/compose.mjs +52 -0
- package/esm/ai/src/middleware/helpers/compose.mjs.map +1 -0
- package/esm/ai/src/middleware/helpers/for-tool.mjs +80 -0
- package/esm/ai/src/middleware/helpers/for-tool.mjs.map +1 -0
- package/esm/ai/src/middleware/index.mjs +10 -0
- package/esm/ai/src/middleware/pipeline.mjs +100 -0
- package/esm/ai/src/middleware/pipeline.mjs.map +1 -0
- package/esm/ai/src/middleware/utils/extract-user-text.mjs +47 -0
- package/esm/ai/src/middleware/utils/extract-user-text.mjs.map +1 -0
- package/esm/ai/src/middleware/utils/namespaced-state.mjs +60 -0
- package/esm/ai/src/middleware/utils/namespaced-state.mjs.map +1 -0
- package/esm/ai/src/mock/index.mjs +4 -0
- package/esm/ai/src/mock/mock-agent.mjs +3 -0
- package/esm/ai/src/mock/mock-router.mjs +58 -0
- package/esm/ai/src/mock/mock-router.mjs.map +1 -0
- package/esm/ai/src/model/fallback-model.mjs +218 -0
- package/esm/ai/src/model/fallback-model.mjs.map +1 -0
- package/esm/ai/src/model/index.mjs +3 -0
- package/esm/ai/src/object-stream/index.mjs +4 -0
- package/esm/ai/src/object-stream/parse-partial-json.mjs +78 -0
- package/esm/ai/src/object-stream/parse-partial-json.mjs.map +1 -0
- package/esm/ai/src/object-stream/stream-object.mjs +97 -0
- package/esm/ai/src/object-stream/stream-object.mjs.map +1 -0
- package/esm/ai/src/observe/index.mjs +4 -0
- package/esm/ai/src/observe/observer-registry.mjs +35 -0
- package/esm/ai/src/observe/observer-registry.mjs.map +1 -0
- package/esm/ai/src/observe/resolve-observers.mjs +73 -0
- package/esm/ai/src/observe/resolve-observers.mjs.map +1 -0
- package/esm/ai/src/orchestrator/as-tool.mjs +98 -0
- package/esm/ai/src/orchestrator/as-tool.mjs.map +1 -0
- package/esm/ai/src/orchestrator/checkpoint.mjs +75 -0
- package/esm/ai/src/orchestrator/checkpoint.mjs.map +1 -0
- package/esm/ai/src/orchestrator/commands.mjs +34 -0
- package/esm/ai/src/orchestrator/commands.mjs.map +1 -0
- package/esm/ai/src/orchestrator/compaction.mjs +206 -0
- package/esm/ai/src/orchestrator/compaction.mjs.map +1 -0
- package/esm/ai/src/orchestrator/dispatch.mjs +171 -0
- package/esm/ai/src/orchestrator/dispatch.mjs.map +1 -0
- package/esm/ai/src/orchestrator/emitter.mjs +85 -0
- package/esm/ai/src/orchestrator/emitter.mjs.map +1 -0
- package/esm/ai/src/orchestrator/execution.mjs +395 -0
- package/esm/ai/src/orchestrator/execution.mjs.map +1 -0
- package/esm/ai/src/orchestrator/index.mjs +11 -0
- package/esm/ai/src/orchestrator/load.mjs +49 -0
- package/esm/ai/src/orchestrator/load.mjs.map +1 -0
- package/esm/ai/src/orchestrator/lock.mjs +75 -0
- package/esm/ai/src/orchestrator/lock.mjs.map +1 -0
- package/esm/ai/src/orchestrator/memory.mjs +141 -0
- package/esm/ai/src/orchestrator/memory.mjs.map +1 -0
- package/esm/ai/src/orchestrator/orchestrator-stream.mjs +98 -0
- package/esm/ai/src/orchestrator/orchestrator-stream.mjs.map +1 -0
- package/esm/ai/src/orchestrator/orchestrator.mjs +206 -0
- package/esm/ai/src/orchestrator/orchestrator.mjs.map +1 -0
- package/esm/ai/src/orchestrator/resume.mjs +74 -0
- package/esm/ai/src/orchestrator/resume.mjs.map +1 -0
- package/esm/ai/src/orchestrator/session-lock.mjs +83 -0
- package/esm/ai/src/orchestrator/session-lock.mjs.map +1 -0
- package/esm/ai/src/orchestrator/signature.mjs +120 -0
- package/esm/ai/src/orchestrator/signature.mjs.map +1 -0
- package/esm/ai/src/orchestrator/window.mjs +56 -0
- package/esm/ai/src/orchestrator/window.mjs.map +1 -0
- package/esm/ai/src/planner/dag-scheduler.mjs +97 -0
- package/esm/ai/src/planner/dag-scheduler.mjs.map +1 -0
- package/esm/ai/src/planner/index.mjs +6 -0
- package/esm/ai/src/planner/plan-prompt.mjs +31 -0
- package/esm/ai/src/planner/plan-prompt.mjs.map +1 -0
- package/esm/ai/src/planner/plan-schema.mjs +120 -0
- package/esm/ai/src/planner/plan-schema.mjs.map +1 -0
- package/esm/ai/src/planner/planner-run.mjs +769 -0
- package/esm/ai/src/planner/planner-run.mjs.map +1 -0
- package/esm/ai/src/planner/planner.mjs +144 -0
- package/esm/ai/src/planner/planner.mjs.map +1 -0
- package/esm/ai/src/planner/signature.mjs +27 -0
- package/esm/ai/src/planner/signature.mjs.map +1 -0
- package/esm/ai/src/planner/snapshot.mjs +95 -0
- package/esm/ai/src/planner/snapshot.mjs.map +1 -0
- package/esm/ai/src/prompt/errors.mjs +73 -0
- package/esm/ai/src/prompt/errors.mjs.map +1 -0
- package/esm/ai/src/prompt/index.mjs +4 -0
- package/esm/ai/src/prompt/prompt-langfuse-sync.mjs +104 -0
- package/esm/ai/src/prompt/prompt-langfuse-sync.mjs.map +1 -0
- package/esm/ai/src/prompt/prompt-validate.mjs +170 -0
- package/esm/ai/src/prompt/prompt-validate.mjs.map +1 -0
- package/esm/ai/src/prompt/prompt.mjs +218 -0
- package/esm/ai/src/prompt/prompt.mjs.map +1 -0
- package/esm/ai/src/prompts/index.mjs +3 -0
- package/esm/ai/src/prompts/prompts-manager.mjs +410 -0
- package/esm/ai/src/prompts/prompts-manager.mjs.map +1 -0
- package/esm/ai/src/prompts/prompts-validate.mjs +200 -0
- package/esm/ai/src/prompts/prompts-validate.mjs.map +1 -0
- package/esm/ai/src/rag/as-tool.mjs +48 -0
- package/esm/ai/src/rag/as-tool.mjs.map +1 -0
- package/esm/ai/src/rag/chunk/chunk.mjs +44 -0
- package/esm/ai/src/rag/chunk/chunk.mjs.map +1 -0
- package/esm/ai/src/rag/chunk/fixed.mjs +32 -0
- package/esm/ai/src/rag/chunk/fixed.mjs.map +1 -0
- package/esm/ai/src/rag/chunk/markdown.mjs +75 -0
- package/esm/ai/src/rag/chunk/markdown.mjs.map +1 -0
- package/esm/ai/src/rag/chunk/recursive.mjs +132 -0
- package/esm/ai/src/rag/chunk/recursive.mjs.map +1 -0
- package/esm/ai/src/rag/chunk/sentence.mjs +73 -0
- package/esm/ai/src/rag/chunk/sentence.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/bm25.mjs +51 -0
- package/esm/ai/src/rag/hybrid/bm25.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +29 -0
- package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/rrf.mjs +30 -0
- package/esm/ai/src/rag/hybrid/rrf.mjs.map +1 -0
- package/esm/ai/src/rag/index.mjs +18 -0
- package/esm/ai/src/rag/loaders/errors.mjs +25 -0
- package/esm/ai/src/rag/loaders/errors.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/index.mjs +7 -0
- package/esm/ai/src/rag/loaders/load-html.mjs +138 -0
- package/esm/ai/src/rag/loaders/load-html.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-pdf.mjs +150 -0
- package/esm/ai/src/rag/loaders/load-pdf.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-text.mjs +60 -0
- package/esm/ai/src/rag/loaders/load-text.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-web.mjs +89 -0
- package/esm/ai/src/rag/loaders/load-web.mjs.map +1 -0
- package/esm/ai/src/rag/rag.mjs +126 -0
- package/esm/ai/src/rag/rag.mjs.map +1 -0
- package/esm/ai/src/rag/rerank/keyword-reranker.mjs +58 -0
- package/esm/ai/src/rag/rerank/keyword-reranker.mjs.map +1 -0
- package/esm/ai/src/rag/rerank/llm-reranker.mjs +85 -0
- package/esm/ai/src/rag/rerank/llm-reranker.mjs.map +1 -0
- package/esm/ai/src/rag/retrieve.mjs +68 -0
- package/esm/ai/src/rag/retrieve.mjs.map +1 -0
- package/esm/ai/src/rag/store/cache-vector-store.mjs +48 -0
- package/esm/ai/src/rag/store/cache-vector-store.mjs.map +1 -0
- package/esm/ai/src/rag/store/pg-vector-store.mjs +328 -0
- package/esm/ai/src/rag/store/pg-vector-store.mjs.map +1 -0
- package/esm/ai/src/rag/transforms/multi-query.mjs +41 -0
- package/esm/ai/src/rag/transforms/multi-query.mjs.map +1 -0
- package/esm/ai/src/security/index.mjs +5 -0
- package/esm/ai/src/security/outbound-policy.mjs +187 -0
- package/esm/ai/src/security/outbound-policy.mjs.map +1 -0
- package/esm/ai/src/security/private-ip.mjs +48 -0
- package/esm/ai/src/security/private-ip.mjs.map +1 -0
- package/esm/ai/src/security/redact.mjs +60 -0
- package/esm/ai/src/security/redact.mjs.map +1 -0
- package/esm/ai/src/serve/serve.mjs +90 -0
- package/esm/ai/src/serve/serve.mjs.map +1 -0
- package/esm/ai/src/serve/sse.mjs +25 -0
- package/esm/ai/src/serve/sse.mjs.map +1 -0
- package/esm/ai/src/serve/stream-to-sse.mjs +37 -0
- package/esm/ai/src/serve/stream-to-sse.mjs.map +1 -0
- package/esm/ai/src/skills/catalog.mjs +140 -0
- package/esm/ai/src/skills/catalog.mjs.map +1 -0
- package/esm/ai/src/skills/index.mjs +11 -0
- package/esm/ai/src/skills/load-skill-tool.mjs +65 -0
- package/esm/ai/src/skills/load-skill-tool.mjs.map +1 -0
- package/esm/ai/src/skills/save-skill-tool.mjs +65 -0
- package/esm/ai/src/skills/save-skill-tool.mjs.map +1 -0
- package/esm/ai/src/skills/skills.mjs +109 -0
- package/esm/ai/src/skills/skills.mjs.map +1 -0
- package/esm/ai/src/skills/sources/directory-source.mjs +108 -0
- package/esm/ai/src/skills/sources/directory-source.mjs.map +1 -0
- package/esm/ai/src/skills/sources/index.mjs +27 -0
- package/esm/ai/src/skills/sources/index.mjs.map +1 -0
- package/esm/ai/src/skills/sources/parse-frontmatter.mjs +46 -0
- package/esm/ai/src/skills/sources/parse-frontmatter.mjs.map +1 -0
- package/esm/ai/src/skills/sources/store-source.mjs +15 -0
- package/esm/ai/src/skills/sources/store-source.mjs.map +1 -0
- package/esm/ai/src/skills/sources/url-source.mjs +117 -0
- package/esm/ai/src/skills/sources/url-source.mjs.map +1 -0
- package/esm/ai/src/snapshot/memory.mjs +81 -0
- package/esm/ai/src/snapshot/memory.mjs.map +1 -0
- package/esm/ai/src/snapshot/pg.mjs +146 -0
- package/esm/ai/src/snapshot/pg.mjs.map +1 -0
- package/esm/ai/src/snapshot/redis.mjs +101 -0
- package/esm/ai/src/snapshot/redis.mjs.map +1 -0
- package/esm/ai/src/speech/index.mjs +3 -0
- package/esm/ai/src/speech/speech.mjs +122 -0
- package/esm/ai/src/speech/speech.mjs.map +1 -0
- package/esm/ai/src/supervisor/as-tool.mjs +74 -0
- package/esm/ai/src/supervisor/as-tool.mjs.map +1 -0
- package/esm/ai/src/supervisor/cancellation.mjs +22 -0
- package/esm/ai/src/supervisor/cancellation.mjs.map +1 -0
- package/esm/ai/src/supervisor/decide.mjs +272 -0
- package/esm/ai/src/supervisor/decide.mjs.map +1 -0
- package/esm/ai/src/supervisor/emitter.mjs +47 -0
- package/esm/ai/src/supervisor/emitter.mjs.map +1 -0
- package/esm/ai/src/supervisor/entries.mjs +206 -0
- package/esm/ai/src/supervisor/entries.mjs.map +1 -0
- package/esm/ai/src/supervisor/execution.mjs +1921 -0
- package/esm/ai/src/supervisor/execution.mjs.map +1 -0
- package/esm/ai/src/supervisor/fan-out.mjs +65 -0
- package/esm/ai/src/supervisor/fan-out.mjs.map +1 -0
- package/esm/ai/src/supervisor/index.mjs +14 -0
- package/esm/ai/src/supervisor/router-factory.mjs +141 -0
- package/esm/ai/src/supervisor/router-factory.mjs.map +1 -0
- package/esm/ai/src/supervisor/router-prompt.mjs +52 -0
- package/esm/ai/src/supervisor/router-prompt.mjs.map +1 -0
- package/esm/ai/src/supervisor/signature.mjs +89 -0
- package/esm/ai/src/supervisor/signature.mjs.map +1 -0
- package/esm/ai/src/supervisor/snapshot.mjs +69 -0
- package/esm/ai/src/supervisor/snapshot.mjs.map +1 -0
- package/esm/ai/src/supervisor/supervisor-stream.mjs +89 -0
- package/esm/ai/src/supervisor/supervisor-stream.mjs.map +1 -0
- package/esm/ai/src/supervisor/supervisor.mjs +144 -0
- package/esm/ai/src/supervisor/supervisor.mjs.map +1 -0
- package/esm/ai/src/system-prompt/index.mjs +6 -0
- package/esm/ai/src/system-prompt/instruction.mjs +57 -0
- package/esm/ai/src/system-prompt/instruction.mjs.map +1 -0
- package/esm/ai/src/system-prompt/persona.mjs +57 -0
- package/esm/ai/src/system-prompt/persona.mjs.map +1 -0
- package/esm/ai/src/system-prompt/render-placeholders.mjs +58 -0
- package/esm/ai/src/system-prompt/render-placeholders.mjs.map +1 -0
- package/esm/ai/src/system-prompt/system-prompt.mjs +267 -0
- package/esm/ai/src/system-prompt/system-prompt.mjs.map +1 -0
- package/esm/ai/src/team/gates.mjs +48 -0
- package/esm/ai/src/team/gates.mjs.map +1 -0
- package/esm/ai/src/team/index.mjs +3 -0
- package/esm/ai/src/team/team.mjs +94 -0
- package/esm/ai/src/team/team.mjs.map +1 -0
- package/esm/ai/src/tool/executable-as-tool.mjs +81 -0
- package/esm/ai/src/tool/executable-as-tool.mjs.map +1 -0
- package/esm/ai/src/tool/index.mjs +4 -0
- package/esm/ai/src/tool/tool.mjs +185 -0
- package/esm/ai/src/tool/tool.mjs.map +1 -0
- package/esm/ai/src/transcribe/audio-input.mjs +84 -0
- package/esm/ai/src/transcribe/audio-input.mjs.map +1 -0
- package/esm/ai/src/transcribe/index.mjs +4 -0
- package/esm/ai/src/transcribe/transcribe.mjs +127 -0
- package/esm/ai/src/transcribe/transcribe.mjs.map +1 -0
- package/esm/ai/src/utils/compute-cost.mjs +112 -0
- package/esm/ai/src/utils/compute-cost.mjs.map +1 -0
- package/esm/ai/src/utils/extract-json-lenient.mjs +97 -0
- package/esm/ai/src/utils/extract-json-lenient.mjs.map +1 -0
- package/esm/ai/src/utils/extract-json-payload.mjs +39 -0
- package/esm/ai/src/utils/extract-json-payload.mjs.map +1 -0
- package/esm/ai/src/utils/generate-run-id.mjs +23 -0
- package/esm/ai/src/utils/generate-run-id.mjs.map +1 -0
- package/esm/ai/src/utils/index.mjs +12 -0
- package/esm/ai/src/utils/json-schema.mjs +89 -0
- package/esm/ai/src/utils/json-schema.mjs.map +1 -0
- package/esm/ai/src/utils/prepare-attachment-part.mjs +232 -0
- package/esm/ai/src/utils/prepare-attachment-part.mjs.map +1 -0
- package/esm/ai/src/utils/resolve-attachment.mjs +74 -0
- package/esm/ai/src/utils/resolve-attachment.mjs.map +1 -0
- package/esm/ai/src/utils/run-context.mjs +89 -0
- package/esm/ai/src/utils/run-context.mjs.map +1 -0
- package/esm/ai/src/utils/safe-json-parse.mjs +22 -0
- package/esm/ai/src/utils/safe-json-parse.mjs.map +1 -0
- package/esm/ai/src/utils/stamp-report-lineage.mjs +45 -0
- package/esm/ai/src/utils/stamp-report-lineage.mjs.map +1 -0
- package/esm/ai/src/vcr/cassette-io.mjs +57 -0
- package/esm/ai/src/vcr/cassette-io.mjs.map +1 -0
- package/esm/ai/src/vcr/errors.mjs +37 -0
- package/esm/ai/src/vcr/errors.mjs.map +1 -0
- package/esm/ai/src/vcr/hash-request.mjs +118 -0
- package/esm/ai/src/vcr/hash-request.mjs.map +1 -0
- package/esm/ai/src/vcr/index.mjs +5 -0
- package/esm/ai/src/vcr/vcr.mjs +248 -0
- package/esm/ai/src/vcr/vcr.mjs.map +1 -0
- package/esm/ai/src/workflow/as-tool.mjs +49 -0
- package/esm/ai/src/workflow/as-tool.mjs.map +1 -0
- package/esm/ai/src/workflow/cancellation.mjs +44 -0
- package/esm/ai/src/workflow/cancellation.mjs.map +1 -0
- package/esm/ai/src/workflow/emitter.mjs +40 -0
- package/esm/ai/src/workflow/emitter.mjs.map +1 -0
- package/esm/ai/src/workflow/engine.mjs +363 -0
- package/esm/ai/src/workflow/engine.mjs.map +1 -0
- package/esm/ai/src/workflow/index.mjs +5 -0
- package/esm/ai/src/workflow/retry.mjs +32 -0
- package/esm/ai/src/workflow/retry.mjs.map +1 -0
- package/esm/ai/src/workflow/router.mjs +56 -0
- package/esm/ai/src/workflow/router.mjs.map +1 -0
- package/esm/ai/src/workflow/run-scoped-emitter.mjs +32 -0
- package/esm/ai/src/workflow/run-scoped-emitter.mjs.map +1 -0
- package/esm/ai/src/workflow/signature.mjs +34 -0
- package/esm/ai/src/workflow/signature.mjs.map +1 -0
- package/esm/ai/src/workflow/snapshot.mjs +77 -0
- package/esm/ai/src/workflow/snapshot.mjs.map +1 -0
- package/esm/ai/src/workflow/state.mjs +37 -0
- package/esm/ai/src/workflow/state.mjs.map +1 -0
- package/esm/ai/src/workflow/step-runner.mjs +370 -0
- package/esm/ai/src/workflow/step-runner.mjs.map +1 -0
- package/esm/ai/src/workflow/step.mjs +37 -0
- package/esm/ai/src/workflow/step.mjs.map +1 -0
- package/esm/ai/src/workflow/workflow.mjs +122 -0
- package/esm/ai/src/workflow/workflow.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/cli/commands/dev-server.command.mjs +1 -1
- package/esm/cli/commands/dev-server.command.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/config.check.mjs +42 -0
- package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/connectors.check.mjs +28 -0
- package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/health.check.mjs +35 -0
- package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/index.mjs +25 -0
- package/esm/cli/commands/doctor/checks/index.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +90 -0
- package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +69 -0
- package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/routes.check.mjs +30 -0
- package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/doctor-command.action.mjs +28 -0
- package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -0
- package/esm/cli/commands/doctor/format-report.mjs +44 -0
- package/esm/cli/commands/doctor/format-report.mjs.map +1 -0
- package/esm/cli/commands/doctor/run-checks.mjs +50 -0
- package/esm/cli/commands/doctor/run-checks.mjs.map +1 -0
- package/esm/cli/commands/doctor.command.mjs +29 -0
- package/esm/cli/commands/doctor.command.mjs.map +1 -0
- package/esm/cli/commands/generate/templates/stubs.mjs +9 -12
- package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
- package/esm/cli/commands/routes/format-routes-table.mjs +129 -0
- package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -0
- package/esm/cli/commands/routes/route-row.mjs +92 -0
- package/esm/cli/commands/routes/route-row.mjs.map +1 -0
- package/esm/cli/commands/routes/routes-command.action.mjs +43 -0
- package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -0
- package/esm/cli/commands/routes.command.mjs +51 -0
- package/esm/cli/commands/routes.command.mjs.map +1 -0
- package/esm/cli/commands/seed.command.mjs +5 -0
- package/esm/cli/commands/seed.command.mjs.map +1 -1
- package/esm/cli/framework-cli-commands.mjs +4 -0
- package/esm/cli/framework-cli-commands.mjs.map +1 -1
- package/esm/config/config-getter.mjs +5 -5
- package/esm/config/config-getter.mjs.map +1 -1
- package/esm/config/config-loader.mjs +2 -2
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/connectors/access-connector.mjs +2 -2
- package/esm/connectors/access-connector.mjs.map +1 -1
- package/esm/connectors/ai-connector.d.mts +43 -0
- package/esm/connectors/ai-connector.d.mts.map +1 -0
- package/esm/connectors/ai-connector.mjs +56 -0
- package/esm/connectors/ai-connector.mjs.map +1 -0
- package/esm/connectors/cache-connector.d.mts +5 -0
- package/esm/connectors/cache-connector.d.mts.map +1 -1
- package/esm/connectors/cache-connector.mjs +9 -2
- package/esm/connectors/cache-connector.mjs.map +1 -1
- package/esm/connectors/connectors-manager.d.mts +6 -2
- package/esm/connectors/connectors-manager.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.mjs +8 -2
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/database-connector.mjs +2 -2
- package/esm/connectors/database-connector.mjs.map +1 -1
- package/esm/connectors/herald-connector.mjs +2 -2
- package/esm/connectors/herald-connector.mjs.map +1 -1
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +9 -7
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/index.d.mts +1 -0
- package/esm/connectors/index.mjs +1 -0
- package/esm/connectors/logger-connector.mjs +2 -2
- package/esm/connectors/logger-connector.mjs.map +1 -1
- package/esm/connectors/mail-connector.mjs +2 -2
- package/esm/connectors/mail-connector.mjs.map +1 -1
- package/esm/connectors/notifications-connector.mjs +2 -2
- package/esm/connectors/notifications-connector.mjs.map +1 -1
- package/esm/connectors/socket-connector.d.mts +16 -1
- package/esm/connectors/socket-connector.d.mts.map +1 -1
- package/esm/connectors/socket-connector.mjs +31 -8
- package/esm/connectors/socket-connector.mjs.map +1 -1
- package/esm/connectors/storage.connector.d.mts +7 -0
- package/esm/connectors/storage.connector.d.mts.map +1 -1
- package/esm/connectors/storage.connector.mjs +7 -0
- package/esm/connectors/storage.connector.mjs.map +1 -1
- package/esm/connectors/types.d.mts +3 -2
- package/esm/connectors/types.d.mts.map +1 -1
- package/esm/connectors/types.mjs +1 -0
- package/esm/connectors/types.mjs.map +1 -1
- package/esm/database/index.d.mts +2 -1
- package/esm/database/index.mjs +1 -0
- package/esm/database/seed-command-action.mjs +44 -4
- package/esm/database/seed-command-action.mjs.map +1 -1
- package/esm/database/seeds/seed-records-table-migration.mjs +36 -0
- package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -0
- package/esm/database/seeds/seeder.d.mts +22 -5
- package/esm/database/seeds/seeder.d.mts.map +1 -1
- package/esm/database/seeds/seeder.errors.d.mts +22 -0
- package/esm/database/seeds/seeder.errors.d.mts.map +1 -0
- package/esm/database/seeds/seeder.errors.mjs +29 -0
- package/esm/database/seeds/seeder.errors.mjs.map +1 -0
- package/esm/database/seeds/seeder.mjs.map +1 -1
- package/esm/database/seeds/seeders.manager.mjs +90 -11
- package/esm/database/seeds/seeders.manager.mjs.map +1 -1
- package/esm/database/seeds/types.d.mts +117 -1
- package/esm/database/seeds/types.d.mts.map +1 -1
- package/esm/database/seeds/utils.mjs +6 -1
- package/esm/database/seeds/utils.mjs.map +1 -1
- package/esm/dev-server/development-server.mjs +2 -14
- package/esm/dev-server/development-server.mjs.map +1 -1
- package/esm/dev-server/file-event-handler.mjs +15 -3
- package/esm/dev-server/file-event-handler.mjs.map +1 -1
- package/esm/dev-server/module-loader.d.mts +12 -0
- package/esm/dev-server/module-loader.d.mts.map +1 -1
- package/esm/dev-server/module-loader.mjs +30 -2
- package/esm/dev-server/module-loader.mjs.map +1 -1
- package/esm/generations/add-command.action.mjs +61 -12
- package/esm/generations/add-command.action.mjs.map +1 -1
- package/esm/generations/stubs.mjs +31 -1
- package/esm/generations/stubs.mjs.map +1 -1
- package/esm/http/config.mjs +2 -2
- package/esm/http/config.mjs.map +1 -1
- package/esm/http/createHttpApplication.mjs +2 -2
- package/esm/http/createHttpApplication.mjs.map +1 -1
- package/esm/http/health.d.mts +14 -0
- package/esm/http/health.d.mts.map +1 -1
- package/esm/http/health.mjs +16 -0
- package/esm/http/health.mjs.map +1 -1
- package/esm/http/middleware/cache-response-middleware.d.mts +1 -1
- package/esm/http/middleware/cache-response-middleware.d.mts.map +1 -1
- package/esm/http/middleware/cache-response-middleware.mjs +15 -6
- package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
- package/esm/http/middleware/concurrency-limit.middleware.mjs +2 -0
- package/esm/http/middleware/concurrency-limit.middleware.mjs.map +1 -1
- package/esm/http/middleware/idempotency.middleware.d.mts.map +1 -1
- package/esm/http/middleware/idempotency.middleware.mjs +9 -6
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +2 -2
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs +6 -5
- package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
- package/esm/http/plugins.mjs +9 -9
- package/esm/http/plugins.mjs.map +1 -1
- package/esm/http/request.d.mts +9 -2
- package/esm/http/request.d.mts.map +1 -1
- package/esm/http/request.mjs +15 -3
- package/esm/http/request.mjs.map +1 -1
- package/esm/http/response.d.mts +12 -0
- package/esm/http/response.d.mts.map +1 -1
- package/esm/http/response.mjs +24 -7
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +4 -4
- package/esm/http/server.mjs.map +1 -1
- package/esm/index.d.mts +9 -4
- package/esm/index.mjs +6 -1
- package/esm/node_modules/langfuse/lib/index.mjs +1827 -0
- package/esm/node_modules/langfuse/lib/index.mjs.map +1 -0
- package/esm/node_modules/langfuse-core/lib/index.mjs +1770 -0
- package/esm/node_modules/langfuse-core/lib/index.mjs.map +1 -0
- package/esm/node_modules/mustache/mustache.mjs +587 -0
- package/esm/node_modules/mustache/mustache.mjs.map +1 -0
- package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs +180 -0
- package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs.map +1 -0
- package/esm/node_modules/openai/auth/workload-identity-auth.mjs +80 -0
- package/esm/node_modules/openai/auth/workload-identity-auth.mjs.map +1 -0
- package/esm/node_modules/openai/azure.mjs +82 -0
- package/esm/node_modules/openai/azure.mjs.map +1 -0
- package/esm/node_modules/openai/client.mjs +638 -0
- package/esm/node_modules/openai/client.mjs.map +1 -0
- package/esm/node_modules/openai/core/api-promise.mjs +75 -0
- package/esm/node_modules/openai/core/api-promise.mjs.map +1 -0
- package/esm/node_modules/openai/core/error.mjs +110 -0
- package/esm/node_modules/openai/core/error.mjs.map +1 -0
- package/esm/node_modules/openai/core/pagination.mjs +160 -0
- package/esm/node_modules/openai/core/pagination.mjs.map +1 -0
- package/esm/node_modules/openai/core/resource.mjs +10 -0
- package/esm/node_modules/openai/core/resource.mjs.map +1 -0
- package/esm/node_modules/openai/core/streaming.mjs +238 -0
- package/esm/node_modules/openai/core/streaming.mjs.map +1 -0
- package/esm/node_modules/openai/index.mjs +8 -0
- package/esm/node_modules/openai/internal/decoders/line.mjs +91 -0
- package/esm/node_modules/openai/internal/decoders/line.mjs.map +1 -0
- package/esm/node_modules/openai/internal/detect-platform.mjs +123 -0
- package/esm/node_modules/openai/internal/detect-platform.mjs.map +1 -0
- package/esm/node_modules/openai/internal/errors.mjs +26 -0
- package/esm/node_modules/openai/internal/errors.mjs.map +1 -0
- package/esm/node_modules/openai/internal/headers.mjs +65 -0
- package/esm/node_modules/openai/internal/headers.mjs.map +1 -0
- package/esm/node_modules/openai/internal/parse.mjs +41 -0
- package/esm/node_modules/openai/internal/parse.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/formats.mjs +12 -0
- package/esm/node_modules/openai/internal/qs/formats.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/stringify.mjs +179 -0
- package/esm/node_modules/openai/internal/qs/stringify.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/utils.mjs +65 -0
- package/esm/node_modules/openai/internal/qs/utils.mjs.map +1 -0
- package/esm/node_modules/openai/internal/request-options.mjs +11 -0
- package/esm/node_modules/openai/internal/request-options.mjs.map +1 -0
- package/esm/node_modules/openai/internal/shims.mjs +77 -0
- package/esm/node_modules/openai/internal/shims.mjs.map +1 -0
- package/esm/node_modules/openai/internal/to-file.mjs +63 -0
- package/esm/node_modules/openai/internal/to-file.mjs.map +1 -0
- package/esm/node_modules/openai/internal/tslib.mjs +16 -0
- package/esm/node_modules/openai/internal/tslib.mjs.map +1 -0
- package/esm/node_modules/openai/internal/uploads.mjs +94 -0
- package/esm/node_modules/openai/internal/uploads.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/base64.mjs +22 -0
- package/esm/node_modules/openai/internal/utils/base64.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/bytes.mjs +26 -0
- package/esm/node_modules/openai/internal/utils/bytes.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/env.mjs +16 -0
- package/esm/node_modules/openai/internal/utils/env.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/log.mjs +58 -0
- package/esm/node_modules/openai/internal/utils/log.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/path.mjs +62 -0
- package/esm/node_modules/openai/internal/utils/path.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/query.mjs +10 -0
- package/esm/node_modules/openai/internal/utils/query.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/sleep.mjs +6 -0
- package/esm/node_modules/openai/internal/utils/sleep.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/uuid.mjs +18 -0
- package/esm/node_modules/openai/internal/utils/uuid.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/values.mjs +41 -0
- package/esm/node_modules/openai/internal/utils/values.mjs.map +1 -0
- package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +247 -0
- package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/AssistantStream.mjs +472 -0
- package/esm/node_modules/openai/lib/AssistantStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs +26 -0
- package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionStream.mjs +423 -0
- package/esm/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +26 -0
- package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/EventStream.mjs +163 -0
- package/esm/node_modules/openai/lib/EventStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ResponsesParser.mjs +94 -0
- package/esm/node_modules/openai/lib/ResponsesParser.mjs.map +1 -0
- package/esm/node_modules/openai/lib/RunnableFunction.mjs +8 -0
- package/esm/node_modules/openai/lib/RunnableFunction.mjs.map +1 -0
- package/esm/node_modules/openai/lib/Util.mjs +19 -0
- package/esm/node_modules/openai/lib/Util.mjs.map +1 -0
- package/esm/node_modules/openai/lib/chatCompletionUtils.mjs +11 -0
- package/esm/node_modules/openai/lib/chatCompletionUtils.mjs.map +1 -0
- package/esm/node_modules/openai/lib/parser.mjs +88 -0
- package/esm/node_modules/openai/lib/parser.mjs.map +1 -0
- package/esm/node_modules/openai/lib/responses/ResponseStream.mjs +231 -0
- package/esm/node_modules/openai/lib/responses/ResponseStream.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/admin.mjs +15 -0
- package/esm/node_modules/openai/resources/admin/admin.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +81 -0
- package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs +31 -0
- package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/certificates.mjs +153 -0
- package/esm/node_modules/openai/resources/admin/organization/certificates.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs +42 -0
- package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs +106 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/invites.mjs +83 -0
- package/esm/node_modules/openai/resources/admin/organization/invites.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/organization.mjs +45 -0
- package/esm/node_modules/openai/resources/admin/organization/organization.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +72 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs +78 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +46 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +95 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +91 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +45 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +63 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs +137 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +51 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs +108 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +112 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +106 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +91 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs +118 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/roles.mjs +96 -0
- package/esm/node_modules/openai/resources/admin/organization/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs +97 -0
- package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/usage.mjs +207 -0
- package/esm/node_modules/openai/resources/admin/organization/usage.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/users/users.mjs +82 -0
- package/esm/node_modules/openai/resources/admin/organization/users/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/audio.mjs +21 -0
- package/esm/node_modules/openai/resources/audio/audio.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/speech.mjs +39 -0
- package/esm/node_modules/openai/resources/audio/speech.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/transcriptions.mjs +22 -0
- package/esm/node_modules/openai/resources/audio/transcriptions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/translations.mjs +21 -0
- package/esm/node_modules/openai/resources/audio/translations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/batches.mjs +54 -0
- package/esm/node_modules/openai/resources/batches.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/assistants.mjs +78 -0
- package/esm/node_modules/openai/resources/beta/assistants.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/beta.mjs +24 -0
- package/esm/node_modules/openai/resources/beta/beta.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs +18 -0
- package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs +49 -0
- package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs +85 -0
- package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs +21 -0
- package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs +33 -0
- package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +33 -0
- package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/messages.mjs +83 -0
- package/esm/node_modules/openai/resources/beta/threads/messages.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs +183 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs +45 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/threads.mjs +101 -0
- package/esm/node_modules/openai/resources/beta/threads/threads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/chat.mjs +15 -0
- package/esm/node_modules/openai/resources/chat/chat.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/completions/completions.mjs +123 -0
- package/esm/node_modules/openai/resources/chat/completions/completions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/completions/index.mjs +7 -0
- package/esm/node_modules/openai/resources/chat/completions/messages.mjs +35 -0
- package/esm/node_modules/openai/resources/chat/completions/messages.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/index.mjs +5 -0
- package/esm/node_modules/openai/resources/completions.mjs +20 -0
- package/esm/node_modules/openai/resources/completions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/containers.mjs +57 -0
- package/esm/node_modules/openai/resources/containers/containers.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/files/content.mjs +23 -0
- package/esm/node_modules/openai/resources/containers/files/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/files/files.mjs +63 -0
- package/esm/node_modules/openai/resources/containers/files/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/conversations/conversations.mjs +57 -0
- package/esm/node_modules/openai/resources/conversations/conversations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/conversations/items.mjs +57 -0
- package/esm/node_modules/openai/resources/conversations/items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/embeddings.mjs +48 -0
- package/esm/node_modules/openai/resources/embeddings.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/evals.mjs +73 -0
- package/esm/node_modules/openai/resources/evals/evals.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/runs/output-items.mjs +35 -0
- package/esm/node_modules/openai/resources/evals/runs/output-items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/runs/runs.mjs +72 -0
- package/esm/node_modules/openai/resources/evals/runs/runs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/files.mjs +111 -0
- package/esm/node_modules/openai/resources/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +15 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +60 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +15 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +102 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +24 -0
- package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +34 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +148 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/methods.mjs +8 -0
- package/esm/node_modules/openai/resources/fine-tuning/methods.mjs.map +1 -0
- package/esm/node_modules/openai/resources/graders/grader-models.mjs +8 -0
- package/esm/node_modules/openai/resources/graders/grader-models.mjs.map +1 -0
- package/esm/node_modules/openai/resources/graders/graders.mjs +15 -0
- package/esm/node_modules/openai/resources/graders/graders.mjs.map +1 -0
- package/esm/node_modules/openai/resources/images.mjs +46 -0
- package/esm/node_modules/openai/resources/images.mjs.map +1 -0
- package/esm/node_modules/openai/resources/index.mjs +27 -0
- package/esm/node_modules/openai/resources/models.mjs +44 -0
- package/esm/node_modules/openai/resources/models.mjs.map +1 -0
- package/esm/node_modules/openai/resources/moderations.mjs +23 -0
- package/esm/node_modules/openai/resources/moderations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/calls.mjs +79 -0
- package/esm/node_modules/openai/resources/realtime/calls.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/client-secrets.mjs +39 -0
- package/esm/node_modules/openai/resources/realtime/client-secrets.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/realtime.mjs +18 -0
- package/esm/node_modules/openai/resources/realtime/realtime.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/input-items.mjs +31 -0
- package/esm/node_modules/openai/resources/responses/input-items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/input-tokens.mjs +27 -0
- package/esm/node_modules/openai/resources/responses/input-tokens.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/responses.mjs +110 -0
- package/esm/node_modules/openai/resources/responses/responses.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/content.mjs +22 -0
- package/esm/node_modules/openai/resources/skills/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/skills.mjs +69 -0
- package/esm/node_modules/openai/resources/skills/skills.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/versions/content.mjs +23 -0
- package/esm/node_modules/openai/resources/skills/versions/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/versions/versions.mjs +58 -0
- package/esm/node_modules/openai/resources/skills/versions/versions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/uploads/parts.mjs +34 -0
- package/esm/node_modules/openai/resources/uploads/parts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/uploads/uploads.mjs +84 -0
- package/esm/node_modules/openai/resources/uploads/uploads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs +126 -0
- package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/files.mjs +147 -0
- package/esm/node_modules/openai/resources/vector-stores/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs +87 -0
- package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs.map +1 -0
- package/esm/node_modules/openai/resources/videos.mjs +115 -0
- package/esm/node_modules/openai/resources/videos.mjs.map +1 -0
- package/esm/node_modules/openai/resources/webhooks/index.mjs +3 -0
- package/esm/node_modules/openai/resources/webhooks/webhooks.mjs +69 -0
- package/esm/node_modules/openai/resources/webhooks/webhooks.mjs.map +1 -0
- package/esm/node_modules/openai/resources/webhooks.mjs +4 -0
- package/esm/node_modules/openai/streaming.mjs +3 -0
- package/esm/node_modules/openai/version.mjs +6 -0
- package/esm/node_modules/openai/version.mjs.map +1 -0
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +37 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +71 -5
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/filter-applicator.mjs +17 -3
- package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
- package/esm/repositories/contracts/index.d.mts +1 -1
- package/esm/repositories/contracts/query-builder.contract.d.mts +87 -1
- package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
- package/esm/repositories/index.d.mts +1 -1
- package/esm/repositories/repository.manager.d.mts +110 -2
- package/esm/repositories/repository.manager.d.mts.map +1 -1
- package/esm/repositories/repository.manager.mjs +207 -25
- package/esm/repositories/repository.manager.mjs.map +1 -1
- package/esm/router/route-registry.mjs +19 -10
- package/esm/router/route-registry.mjs.map +1 -1
- package/esm/router/router.d.mts +9 -0
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +28 -5
- package/esm/router/router.mjs.map +1 -1
- package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
- package/esm/storage/drivers/cloud-driver.mjs +48 -12
- package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
- package/esm/storage/drivers/do-spaces-driver.mjs +1 -1
- package/esm/storage/drivers/do-spaces-driver.mjs.map +1 -1
- package/esm/storage/drivers/local-driver.d.mts +8 -0
- package/esm/storage/drivers/local-driver.d.mts.map +1 -1
- package/esm/storage/drivers/local-driver.mjs +19 -4
- package/esm/storage/drivers/local-driver.mjs.map +1 -1
- package/esm/storage/drivers/r2-driver.mjs +1 -1
- package/esm/storage/drivers/r2-driver.mjs.map +1 -1
- package/esm/storage/drivers/s3-driver.mjs +1 -1
- package/esm/storage/drivers/s3-driver.mjs.map +1 -1
- package/esm/storage/index.d.mts +4 -1
- package/esm/storage/index.mjs +3 -0
- package/esm/storage/scoped-storage.d.mts +8 -4
- package/esm/storage/scoped-storage.d.mts.map +1 -1
- package/esm/storage/scoped-storage.mjs +21 -6
- package/esm/storage/scoped-storage.mjs.map +1 -1
- package/esm/storage/storage.d.mts +12 -4
- package/esm/storage/storage.d.mts.map +1 -1
- package/esm/storage/storage.mjs +23 -9
- package/esm/storage/storage.mjs.map +1 -1
- package/esm/storage/types.d.mts +33 -5
- package/esm/storage/types.d.mts.map +1 -1
- package/esm/storage/utils/contain-path.d.mts +23 -0
- package/esm/storage/utils/contain-path.d.mts.map +1 -0
- package/esm/storage/utils/contain-path.mjs +35 -0
- package/esm/storage/utils/contain-path.mjs.map +1 -0
- package/esm/storage/utils/safe-fetch.d.mts +68 -0
- package/esm/storage/utils/safe-fetch.d.mts.map +1 -0
- package/esm/storage/utils/safe-fetch.mjs +205 -0
- package/esm/storage/utils/safe-fetch.mjs.map +1 -0
- package/esm/storage/utils/storage-error.d.mts +35 -0
- package/esm/storage/utils/storage-error.d.mts.map +1 -0
- package/esm/storage/utils/storage-error.mjs +17 -0
- package/esm/storage/utils/storage-error.mjs.map +1 -0
- package/esm/use-cases/use-case-pipeline.mjs +4 -1
- package/esm/use-cases/use-case-pipeline.mjs.map +1 -1
- package/esm/use-cases/use-case.mjs +12 -4
- package/esm/use-cases/use-case.mjs.map +1 -1
- package/esm/use-cases/use-cases-registry.d.mts +12 -4
- package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
- package/esm/use-cases/use-cases-registry.mjs +13 -3
- package/esm/use-cases/use-cases-registry.mjs.map +1 -1
- package/esm/utils/npm-registry.d.mts +1 -1
- package/esm/utils/npm-registry.mjs +2 -2
- package/esm/utils/npm-registry.mjs.map +1 -1
- package/esm/utils/paths.mjs +2 -2
- package/esm/utils/paths.mjs.map +1 -1
- package/esm/validation/validateAll.mjs +2 -2
- package/esm/validation/validateAll.mjs.map +1 -1
- package/llms-full.txt +456 -46
- package/llms.txt +4 -2
- package/package.json +9 -9
- package/skills/README.md +65 -0
- package/skills/add-connector/SKILL.md +6 -1
- package/skills/configure-app/SKILL.md +23 -0
- package/skills/health-checks/SKILL.md +13 -0
- package/skills/use-repository/SKILL.md +38 -1
- package/skills/warlock-doctor/SKILL.md +135 -0
- package/skills/warlock-routes/SKILL.md +91 -0
- package/skills/write-seeder/SKILL.md +143 -45
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { humanApproval } from "./human-approval.mjs";
|
|
2
|
+
import { resume } from "./resume.mjs";
|
|
3
|
+
import { memory } from "./stores/memory.mjs";
|
|
4
|
+
import { pg } from "./stores/pg.mjs";
|
|
5
|
+
import { redis } from "./stores/redis.mjs";
|
|
6
|
+
import "./stores/index.mjs";
|
|
7
|
+
|
|
8
|
+
//#region ../@warlock.js/ai/src/human/register.ts
|
|
9
|
+
/**
|
|
10
|
+
* The assembled `ai.human.*` namespace — the human-in-the-loop surface
|
|
11
|
+
* mounted onto the shared `ai` object in `../ai`.
|
|
12
|
+
*
|
|
13
|
+
* - `approval(options)` — the `tool.before` approval-gate middleware.
|
|
14
|
+
* - `resume(id, decision, options)` — out-of-process durable resume.
|
|
15
|
+
* - `interrupt.{memory,pg,redis}()` — the
|
|
16
|
+
* {@link import("./contracts").InterruptStore} factories (memory ships
|
|
17
|
+
* real; pg/redis lazily import their optional-peer driver).
|
|
18
|
+
*
|
|
19
|
+
* Declared as a standalone object so `../ai` can spread it onto the `ai`
|
|
20
|
+
* literal and pin the `Ai.human` member to this exact shape with no casts.
|
|
21
|
+
* Lives here (not inlined into `../ai`) to keep the human factories grouped
|
|
22
|
+
* with the rest of the human module and avoid `../ai` reaching into each
|
|
23
|
+
* store/middleware file directly.
|
|
24
|
+
*/
|
|
25
|
+
const human = {
|
|
26
|
+
approval: humanApproval,
|
|
27
|
+
resume,
|
|
28
|
+
interrupt: {
|
|
29
|
+
memory,
|
|
30
|
+
pg,
|
|
31
|
+
redis
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { human };
|
|
37
|
+
//# sourceMappingURL=register.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.mjs","names":["interruptMemory","interruptPg","interruptRedis"],"sources":["../../../../../../../../../@warlock.js/ai/src/human/register.ts"],"sourcesContent":["import { humanApproval } from \"./human-approval\";\nimport { resume } from \"./resume\";\nimport { interruptMemory, interruptPg, interruptRedis } from \"./stores\";\n\n/**\n * The assembled `ai.human.*` namespace — the human-in-the-loop surface\n * mounted onto the shared `ai` object in `../ai`.\n *\n * - `approval(options)` — the `tool.before` approval-gate middleware.\n * - `resume(id, decision, options)` — out-of-process durable resume.\n * - `interrupt.{memory,pg,redis}()` — the\n * {@link import(\"./contracts\").InterruptStore} factories (memory ships\n * real; pg/redis lazily import their optional-peer driver).\n *\n * Declared as a standalone object so `../ai` can spread it onto the `ai`\n * literal and pin the `Ai.human` member to this exact shape with no casts.\n * Lives here (not inlined into `../ai`) to keep the human factories grouped\n * with the rest of the human module and avoid `../ai` reaching into each\n * store/middleware file directly.\n */\nexport const human = {\n approval: humanApproval,\n resume,\n interrupt: {\n memory: interruptMemory,\n pg: interruptPg,\n redis: interruptRedis,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,QAAQ;CACnB,UAAU;CACV;CACA,WAAW;EACDA;EACJC;EACGC;CACT;AACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/human/resume-seed.ts
|
|
2
|
+
/**
|
|
3
|
+
* Process-local registry of decisions pre-seeded for a durable re-run.
|
|
4
|
+
*
|
|
5
|
+
* **Why it exists.** v1 durable resume re-runs the *same* agent turn with
|
|
6
|
+
* the human's decision already in hand (it does **not** rehydrate an
|
|
7
|
+
* in-flight supervisor — that is the deferred v2 lift). The agent's
|
|
8
|
+
* `ai.human.approval(...)` middleware is baked in at construction, so the
|
|
9
|
+
* re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`
|
|
10
|
+
* stashes the decision here keyed by the agent name; the approval
|
|
11
|
+
* middleware's handler consults the registry **before** calling the
|
|
12
|
+
* author's handler and, on a hit, replays the seeded decision exactly once
|
|
13
|
+
* — so the gated tool call this time resolves to the human's ruling instead
|
|
14
|
+
* of pausing again.
|
|
15
|
+
*
|
|
16
|
+
* Keyed by agent name (not interrupt id): the re-run produces a *fresh*
|
|
17
|
+
* interrupt id (the id embeds a random segment), so the seed must be
|
|
18
|
+
* matched to the run, not the prior id. The registry holds at most one
|
|
19
|
+
* seeded decision per agent and consumes it on first read, so a second
|
|
20
|
+
* gated call in the same re-run falls through to the author's handler.
|
|
21
|
+
*/
|
|
22
|
+
const seededDecisions = /* @__PURE__ */ new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Stash a decision to be replayed on the next gated tool call of `agentName`.
|
|
25
|
+
* Overwrites any prior seed for the same agent (a re-run carries exactly one
|
|
26
|
+
* pre-seeded decision).
|
|
27
|
+
*/
|
|
28
|
+
function seedDecision(agentName, decision) {
|
|
29
|
+
seededDecisions.set(agentName, decision);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Take (read **and** remove) the seeded decision for `agentName`, or
|
|
33
|
+
* `undefined` when none is staged. Consuming on read makes the seed
|
|
34
|
+
* one-shot: only the first gated call of a re-run replays it.
|
|
35
|
+
*/
|
|
36
|
+
function takeSeededDecision(agentName) {
|
|
37
|
+
const decision = seededDecisions.get(agentName);
|
|
38
|
+
if (decision === void 0) return;
|
|
39
|
+
seededDecisions.delete(agentName);
|
|
40
|
+
return decision;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Drop any staged seed for `agentName` without consuming it as a decision.
|
|
44
|
+
* Used to clean up after a re-run that errored before the seeded call fired,
|
|
45
|
+
* so a stale seed never leaks into an unrelated later run of the same agent.
|
|
46
|
+
*/
|
|
47
|
+
function clearSeededDecision(agentName) {
|
|
48
|
+
seededDecisions.delete(agentName);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { clearSeededDecision, seedDecision, takeSeededDecision };
|
|
53
|
+
//# sourceMappingURL=resume-seed.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume-seed.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/resume-seed.ts"],"sourcesContent":["import type { ApprovalDecision } from \"./contracts\";\n\n/**\n * Process-local registry of decisions pre-seeded for a durable re-run.\n *\n * **Why it exists.** v1 durable resume re-runs the *same* agent turn with\n * the human's decision already in hand (it does **not** rehydrate an\n * in-flight supervisor — that is the deferred v2 lift). The agent's\n * `ai.human.approval(...)` middleware is baked in at construction, so the\n * re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`\n * stashes the decision here keyed by the agent name; the approval\n * middleware's handler consults the registry **before** calling the\n * author's handler and, on a hit, replays the seeded decision exactly once\n * — so the gated tool call this time resolves to the human's ruling instead\n * of pausing again.\n *\n * Keyed by agent name (not interrupt id): the re-run produces a *fresh*\n * interrupt id (the id embeds a random segment), so the seed must be\n * matched to the run, not the prior id. The registry holds at most one\n * seeded decision per agent and consumes it on first read, so a second\n * gated call in the same re-run falls through to the author's handler.\n */\nconst seededDecisions = new Map<string, ApprovalDecision>();\n\n/**\n * Stash a decision to be replayed on the next gated tool call of `agentName`.\n * Overwrites any prior seed for the same agent (a re-run carries exactly one\n * pre-seeded decision).\n */\nexport function seedDecision(agentName: string, decision: ApprovalDecision): void {\n seededDecisions.set(agentName, decision);\n}\n\n/**\n * Take (read **and** remove) the seeded decision for `agentName`, or\n * `undefined` when none is staged. Consuming on read makes the seed\n * one-shot: only the first gated call of a re-run replays it.\n */\nexport function takeSeededDecision(agentName: string): ApprovalDecision | undefined {\n const decision = seededDecisions.get(agentName);\n\n if (decision === undefined) {\n return undefined;\n }\n\n seededDecisions.delete(agentName);\n\n return decision;\n}\n\n/**\n * Drop any staged seed for `agentName` without consuming it as a decision.\n * Used to clean up after a re-run that errored before the seeded call fired,\n * so a stale seed never leaks into an unrelated later run of the same agent.\n */\nexport function clearSeededDecision(agentName: string): void {\n seededDecisions.delete(agentName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kCAAkB,IAAI,IAA8B;;;;;;AAO1D,SAAgB,aAAa,WAAmB,UAAkC;CAChF,gBAAgB,IAAI,WAAW,QAAQ;AACzC;;;;;;AAOA,SAAgB,mBAAmB,WAAiD;CAClF,MAAM,WAAW,gBAAgB,IAAI,SAAS;CAE9C,IAAI,aAAa,QACf;CAGF,gBAAgB,OAAO,SAAS;CAEhC,OAAO;AACT;;;;;;AAOA,SAAgB,oBAAoB,WAAyB;CAC3D,gBAAgB,OAAO,SAAS;AAClC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { clearSeededDecision, seedDecision } from "./resume-seed.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/human/resume.ts
|
|
4
|
+
/**
|
|
5
|
+
* Validate that a decision is a well-formed {@link ApprovalDecision}.
|
|
6
|
+
*
|
|
7
|
+
* `ai.human.resume(...)` is a public, out-of-process entry point — a
|
|
8
|
+
* webhook can hand it anything. Guard the closed `type` union (and the
|
|
9
|
+
* per-variant required fields) before applying it, so a malformed payload
|
|
10
|
+
* fails loudly here rather than silently mis-driving the re-run.
|
|
11
|
+
*/
|
|
12
|
+
function assertDecision(decision) {
|
|
13
|
+
if (decision.type === "approve") return;
|
|
14
|
+
if (decision.type === "reject") {
|
|
15
|
+
if (typeof decision.reason !== "string") throw new TypeError("ai.human.resume: a 'reject' decision requires a string 'reason'.");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (decision.type === "edit") {
|
|
19
|
+
if (!("args" in decision)) throw new TypeError("ai.human.resume: an 'edit' decision requires replacement 'args'.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw new TypeError(`ai.human.resume: unknown decision type '${decision.type}'. Expected one of: approve, reject, edit.`);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Re-run the agent for a resumed interrupt with the decision pre-seeded.
|
|
26
|
+
*
|
|
27
|
+
* Stages the decision in the process-local seed registry (keyed by agent
|
|
28
|
+
* name), then re-executes the original prompt. The agent's
|
|
29
|
+
* `ai.human.approval(...)` middleware consumes the seed on the gated tool
|
|
30
|
+
* call — so this time it resolves to the human's ruling instead of pausing
|
|
31
|
+
* again. The seed is cleared in a `finally` so a re-run that errors before
|
|
32
|
+
* the gated call never leaks a stale seed into a later run.
|
|
33
|
+
*/
|
|
34
|
+
async function rerun(pending, decision, options) {
|
|
35
|
+
const { agent } = options;
|
|
36
|
+
if (!agent) return {
|
|
37
|
+
type: "applied",
|
|
38
|
+
interruptId: pending.interruptId,
|
|
39
|
+
decision
|
|
40
|
+
};
|
|
41
|
+
const input = options.input ?? pending.request.context.originalInput ?? "";
|
|
42
|
+
seedDecision(agent.name, decision);
|
|
43
|
+
try {
|
|
44
|
+
const result = await agent.execute(input, options.executeOptions);
|
|
45
|
+
return {
|
|
46
|
+
type: "applied",
|
|
47
|
+
interruptId: pending.interruptId,
|
|
48
|
+
decision,
|
|
49
|
+
result
|
|
50
|
+
};
|
|
51
|
+
} finally {
|
|
52
|
+
clearSeededDecision(agent.name);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Apply a human's decision to a persisted interrupt — the out-of-process
|
|
57
|
+
* resume entry point behind `ai.human.resume(interruptId, decision, options)`.
|
|
58
|
+
*
|
|
59
|
+
* **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the
|
|
60
|
+
* {@link PendingInterrupt} from `options.store`, validates the decision,
|
|
61
|
+
* deletes the pending record, and (when an `agent` is supplied) re-executes
|
|
62
|
+
* the original turn with the decision **pre-seeded**, so the gated tool call
|
|
63
|
+
* resolves to the ruling instead of pausing again. It does **not** rehydrate
|
|
64
|
+
* an in-flight supervisor — that is the deferred v2 lift.
|
|
65
|
+
*
|
|
66
|
+
* **Idempotent.** A second resume of an already-resolved (deleted) or
|
|
67
|
+
* never-raised interrupt is a no-op: it returns `{ type: "already-resolved" }`
|
|
68
|
+
* without re-applying the decision or re-running the turn — mirroring the
|
|
69
|
+
* orchestrator resume's drain idempotency. The record is deleted **before**
|
|
70
|
+
* the re-run, so even a re-run that itself raises a fresh interrupt cannot
|
|
71
|
+
* collide with the one being resolved.
|
|
72
|
+
*
|
|
73
|
+
* **Two shapes** (see {@link ResumeOptions}):
|
|
74
|
+
* - **apply-only** — omit `agent`: load, validate, delete, return
|
|
75
|
+
* `{ type: "applied", decision }` for a caller-owned re-drive.
|
|
76
|
+
* - **re-run** — pass `agent`: additionally re-execute the turn; the
|
|
77
|
+
* {@link import("@warlock.js/ai").AgentResult} rides `result.result`.
|
|
78
|
+
*
|
|
79
|
+
* @param interruptId - Id of the persisted interrupt to resolve.
|
|
80
|
+
* @param decision - The human's ruling (approve / reject / edit).
|
|
81
|
+
* @param options - The durable `store` (required) plus optional re-run
|
|
82
|
+
* `agent` / `input` / `executeOptions`.
|
|
83
|
+
* @returns A {@link ResumeResult} — `"applied"` or idempotent
|
|
84
|
+
* `"already-resolved"`.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Process B (webhook, hours later) — apply-only:
|
|
88
|
+
* const outcome = await ai.human.resume(interruptId, { type: "reject", reason: "Out of policy" }, {
|
|
89
|
+
* store,
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Re-run the turn with the decision pre-seeded:
|
|
94
|
+
* const outcome = await ai.human.resume(interruptId, { type: "edit", args: { amount: 5 } }, {
|
|
95
|
+
* store,
|
|
96
|
+
* agent: support,
|
|
97
|
+
* });
|
|
98
|
+
* if (outcome.type === "applied" && outcome.result) {
|
|
99
|
+
* console.log(outcome.result.text);
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async function resume(interruptId, decision, options) {
|
|
103
|
+
assertDecision(decision);
|
|
104
|
+
const { store } = options;
|
|
105
|
+
const pending = await store.load(interruptId);
|
|
106
|
+
if (pending === void 0 || pending.status !== "pending") return {
|
|
107
|
+
type: "already-resolved",
|
|
108
|
+
interruptId
|
|
109
|
+
};
|
|
110
|
+
await store.delete(interruptId);
|
|
111
|
+
if (!options.agent) return {
|
|
112
|
+
type: "applied",
|
|
113
|
+
interruptId,
|
|
114
|
+
decision
|
|
115
|
+
};
|
|
116
|
+
return rerun(pending, decision, options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { resume };
|
|
121
|
+
//# sourceMappingURL=resume.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/resume.ts"],"sourcesContent":["import type {\n ApprovalDecision,\n PendingInterrupt,\n ResumeOptions,\n ResumeResult,\n} from \"./contracts\";\nimport { clearSeededDecision, seedDecision } from \"./resume-seed\";\n\n/**\n * Validate that a decision is a well-formed {@link ApprovalDecision}.\n *\n * `ai.human.resume(...)` is a public, out-of-process entry point — a\n * webhook can hand it anything. Guard the closed `type` union (and the\n * per-variant required fields) before applying it, so a malformed payload\n * fails loudly here rather than silently mis-driving the re-run.\n */\nfunction assertDecision(decision: ApprovalDecision): void {\n if (decision.type === \"approve\") {\n return;\n }\n\n if (decision.type === \"reject\") {\n if (typeof decision.reason !== \"string\") {\n throw new TypeError(\n \"ai.human.resume: a 'reject' decision requires a string 'reason'.\",\n );\n }\n\n return;\n }\n\n if (decision.type === \"edit\") {\n if (!(\"args\" in decision)) {\n throw new TypeError(\n \"ai.human.resume: an 'edit' decision requires replacement 'args'.\",\n );\n }\n\n return;\n }\n\n throw new TypeError(\n `ai.human.resume: unknown decision type '${(decision as { type: string }).type}'. Expected one of: approve, reject, edit.`,\n );\n}\n\n/**\n * Re-run the agent for a resumed interrupt with the decision pre-seeded.\n *\n * Stages the decision in the process-local seed registry (keyed by agent\n * name), then re-executes the original prompt. The agent's\n * `ai.human.approval(...)` middleware consumes the seed on the gated tool\n * call — so this time it resolves to the human's ruling instead of pausing\n * again. The seed is cleared in a `finally` so a re-run that errors before\n * the gated call never leaks a stale seed into a later run.\n */\nasync function rerun<TOutput>(\n pending: PendingInterrupt,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n const { agent } = options;\n\n // `agent` is guaranteed by the caller (this is only reached on the\n // re-run path), but narrow for the type system.\n if (!agent) {\n return { type: \"applied\", interruptId: pending.interruptId, decision };\n }\n\n const input = options.input ?? pending.request.context.originalInput ?? \"\";\n\n seedDecision(agent.name, decision);\n\n try {\n const result = await agent.execute(input, options.executeOptions);\n\n return {\n type: \"applied\",\n interruptId: pending.interruptId,\n decision,\n result,\n };\n } finally {\n // If the seeded call never fired (the re-run errored early, or the\n // policy no longer gates the tool), drop the stale seed so it cannot\n // leak into an unrelated later run of the same agent.\n clearSeededDecision(agent.name);\n }\n}\n\n/**\n * Apply a human's decision to a persisted interrupt — the out-of-process\n * resume entry point behind `ai.human.resume(interruptId, decision, options)`.\n *\n * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the\n * {@link PendingInterrupt} from `options.store`, validates the decision,\n * deletes the pending record, and (when an `agent` is supplied) re-executes\n * the original turn with the decision **pre-seeded**, so the gated tool call\n * resolves to the ruling instead of pausing again. It does **not** rehydrate\n * an in-flight supervisor — that is the deferred v2 lift.\n *\n * **Idempotent.** A second resume of an already-resolved (deleted) or\n * never-raised interrupt is a no-op: it returns `{ type: \"already-resolved\" }`\n * without re-applying the decision or re-running the turn — mirroring the\n * orchestrator resume's drain idempotency. The record is deleted **before**\n * the re-run, so even a re-run that itself raises a fresh interrupt cannot\n * collide with the one being resolved.\n *\n * **Two shapes** (see {@link ResumeOptions}):\n * - **apply-only** — omit `agent`: load, validate, delete, return\n * `{ type: \"applied\", decision }` for a caller-owned re-drive.\n * - **re-run** — pass `agent`: additionally re-execute the turn; the\n * {@link import(\"@warlock.js/ai\").AgentResult} rides `result.result`.\n *\n * @param interruptId - Id of the persisted interrupt to resolve.\n * @param decision - The human's ruling (approve / reject / edit).\n * @param options - The durable `store` (required) plus optional re-run\n * `agent` / `input` / `executeOptions`.\n * @returns A {@link ResumeResult} — `\"applied\"` or idempotent\n * `\"already-resolved\"`.\n *\n * @example\n * // Process B (webhook, hours later) — apply-only:\n * const outcome = await ai.human.resume(interruptId, { type: \"reject\", reason: \"Out of policy\" }, {\n * store,\n * });\n *\n * @example\n * // Re-run the turn with the decision pre-seeded:\n * const outcome = await ai.human.resume(interruptId, { type: \"edit\", args: { amount: 5 } }, {\n * store,\n * agent: support,\n * });\n * if (outcome.type === \"applied\" && outcome.result) {\n * console.log(outcome.result.text);\n * }\n */\nexport async function resume<TOutput = unknown>(\n interruptId: string,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n assertDecision(decision);\n\n const { store } = options;\n const pending = await store.load(interruptId);\n\n // No live interrupt — already resolved + deleted, or never raised. Never\n // double-apply; never re-run. Idempotent no-op.\n if (pending === undefined || pending.status !== \"pending\") {\n return { type: \"already-resolved\", interruptId };\n }\n\n // Resolve + delete BEFORE the re-run so a re-run that itself raises a new\n // interrupt cannot collide with the one being resolved, and a concurrent\n // resume of the same id sees it gone.\n await store.delete(interruptId);\n\n if (!options.agent) {\n return { type: \"applied\", interruptId, decision };\n }\n\n return rerun(pending, decision, options);\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,eAAe,UAAkC;CACxD,IAAI,SAAS,SAAS,WACpB;CAGF,IAAI,SAAS,SAAS,UAAU;EAC9B,IAAI,OAAO,SAAS,WAAW,UAC7B,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,IAAI,SAAS,SAAS,QAAQ;EAC5B,IAAI,EAAE,UAAU,WACd,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,MAAM,IAAI,UACR,2CAA4C,SAA8B,KAAK,2CACjF;AACF;;;;;;;;;;;AAYA,eAAe,MACb,SACA,UACA,SACgC;CAChC,MAAM,EAAE,UAAU;CAIlB,IAAI,CAAC,OACH,OAAO;EAAE,MAAM;EAAW,aAAa,QAAQ;EAAa;CAAS;CAGvE,MAAM,QAAQ,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,iBAAiB;CAExE,aAAa,MAAM,MAAM,QAAQ;CAEjC,IAAI;EACF,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,QAAQ,cAAc;EAEhE,OAAO;GACL,MAAM;GACN,aAAa,QAAQ;GACrB;GACA;EACF;CACF,UAAU;EAIR,oBAAoB,MAAM,IAAI;CAChC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,eAAsB,OACpB,aACA,UACA,SACgC;CAChC,eAAe,QAAQ;CAEvB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,MAAM,MAAM,KAAK,WAAW;CAI5C,IAAI,YAAY,UAAa,QAAQ,WAAW,WAC9C,OAAO;EAAE,MAAM;EAAoB;CAAY;CAMjD,MAAM,MAAM,OAAO,WAAW;CAE9B,IAAI,CAAC,QAAQ,OACX,OAAO;EAAE,MAAM;EAAW;EAAa;CAAS;CAGlD,OAAO,MAAM,SAAS,UAAU,OAAO;AACzC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/human/stores/memory.ts
|
|
2
|
+
/**
|
|
3
|
+
* In-memory {@link InterruptStore} — pending interrupts held in a
|
|
4
|
+
* process-local `Map`, never persisted to disk.
|
|
5
|
+
*
|
|
6
|
+
* Owns: the `interruptId → {@link PendingInterrupt}` index and the
|
|
7
|
+
* last-writer-wins `save` / `load` / `delete` / `list` semantics the
|
|
8
|
+
* contract declares. Does NOT own: durability, cross-process sharing, or
|
|
9
|
+
* TTL eviction — it is the zero-config default for dev, tests, and
|
|
10
|
+
* single-process apps whose approval flow stays interactive (the run
|
|
11
|
+
* `await`s the decision in-process and never needs to survive a restart).
|
|
12
|
+
* Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when
|
|
13
|
+
* a reviewer rules out-of-process, hours later.
|
|
14
|
+
*
|
|
15
|
+
* Front it with the {@link memory} factory — callers never `new` it.
|
|
16
|
+
*/
|
|
17
|
+
var MemoryInterruptStore = class {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.interrupts = /* @__PURE__ */ new Map();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Persist a pending interrupt, keyed by its own `interruptId`.
|
|
23
|
+
* Overwrites any prior record for the same id — a call has exactly one
|
|
24
|
+
* live interrupt, so a re-save replaces rather than appends.
|
|
25
|
+
*/
|
|
26
|
+
async save(record) {
|
|
27
|
+
this.interrupts.set(record.interruptId, record);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Return the interrupt for an `interruptId`, or `undefined` when none is
|
|
31
|
+
* recorded (never raised, or already resolved + deleted).
|
|
32
|
+
*/
|
|
33
|
+
async load(interruptId) {
|
|
34
|
+
return this.interrupts.get(interruptId);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Drop the interrupt for an `interruptId`. Idempotent — deleting an
|
|
38
|
+
* absent id is a no-op.
|
|
39
|
+
*/
|
|
40
|
+
async delete(interruptId) {
|
|
41
|
+
this.interrupts.delete(interruptId);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* List the interrupt ids the store knows, optionally filtered by a
|
|
45
|
+
* prefix. Returns a fresh array each call so a caller can mutate it
|
|
46
|
+
* freely without touching the backing index.
|
|
47
|
+
*/
|
|
48
|
+
async list(prefix) {
|
|
49
|
+
const ids = [...this.interrupts.keys()];
|
|
50
|
+
if (prefix === void 0) return ids;
|
|
51
|
+
return ids.filter((id) => id.startsWith(prefix));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The memory store has no backing table — there is nothing to migrate.
|
|
55
|
+
* Returns an empty string so callers can treat `schema()` uniformly
|
|
56
|
+
* across drivers.
|
|
57
|
+
*/
|
|
58
|
+
schema() {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Create an in-memory {@link InterruptStore}. Zero-config — no client, no
|
|
64
|
+
* connection. Suitable for dev, tests, and single-process apps whose
|
|
65
|
+
* approval flow stays interactive and doesn't need resume across
|
|
66
|
+
* restarts.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* import { ai } from "@warlock.js/ai";
|
|
70
|
+
*
|
|
71
|
+
* const store = ai.human.interrupt.memory();
|
|
72
|
+
*
|
|
73
|
+
* const agent = ai.agent({
|
|
74
|
+
* model,
|
|
75
|
+
* tools: [deleteAccount],
|
|
76
|
+
* middleware: [
|
|
77
|
+
* ai.human.approval({
|
|
78
|
+
* policy: { type: "allowlist", tools: ["deleteAccount"] },
|
|
79
|
+
* store,
|
|
80
|
+
* handler,
|
|
81
|
+
* }),
|
|
82
|
+
* ],
|
|
83
|
+
* });
|
|
84
|
+
*/
|
|
85
|
+
function memory() {
|
|
86
|
+
return new MemoryInterruptStore();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { memory };
|
|
91
|
+
//# sourceMappingURL=memory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/ai/src/human/stores/memory.ts"],"sourcesContent":["import type {\n InterruptStore,\n PendingInterrupt,\n} from \"../contracts/interrupt-store.contract\";\n\n/**\n * In-memory {@link InterruptStore} — pending interrupts held in a\n * process-local `Map`, never persisted to disk.\n *\n * Owns: the `interruptId → {@link PendingInterrupt}` index and the\n * last-writer-wins `save` / `load` / `delete` / `list` semantics the\n * contract declares. Does NOT own: durability, cross-process sharing, or\n * TTL eviction — it is the zero-config default for dev, tests, and\n * single-process apps whose approval flow stays interactive (the run\n * `await`s the decision in-process and never needs to survive a restart).\n * Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when\n * a reviewer rules out-of-process, hours later.\n *\n * Front it with the {@link memory} factory — callers never `new` it.\n */\nclass MemoryInterruptStore implements InterruptStore {\n /** Pending interrupts keyed by their own `interruptId`. */\n private readonly interrupts = new Map<string, PendingInterrupt>();\n\n /**\n * Persist a pending interrupt, keyed by its own `interruptId`.\n * Overwrites any prior record for the same id — a call has exactly one\n * live interrupt, so a re-save replaces rather than appends.\n */\n public async save(record: PendingInterrupt): Promise<void> {\n this.interrupts.set(record.interruptId, record);\n }\n\n /**\n * Return the interrupt for an `interruptId`, or `undefined` when none is\n * recorded (never raised, or already resolved + deleted).\n */\n public async load(\n interruptId: string,\n ): Promise<PendingInterrupt | undefined> {\n return this.interrupts.get(interruptId);\n }\n\n /**\n * Drop the interrupt for an `interruptId`. Idempotent — deleting an\n * absent id is a no-op.\n */\n public async delete(interruptId: string): Promise<void> {\n this.interrupts.delete(interruptId);\n }\n\n /**\n * List the interrupt ids the store knows, optionally filtered by a\n * prefix. Returns a fresh array each call so a caller can mutate it\n * freely without touching the backing index.\n */\n public async list(prefix?: string): Promise<string[]> {\n const ids = [...this.interrupts.keys()];\n\n if (prefix === undefined) {\n return ids;\n }\n\n return ids.filter((id) => id.startsWith(prefix));\n }\n\n /**\n * The memory store has no backing table — there is nothing to migrate.\n * Returns an empty string so callers can treat `schema()` uniformly\n * across drivers.\n */\n public schema(): string {\n return \"\";\n }\n}\n\n/**\n * Create an in-memory {@link InterruptStore}. Zero-config — no client, no\n * connection. Suitable for dev, tests, and single-process apps whose\n * approval flow stays interactive and doesn't need resume across\n * restarts.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * const store = ai.human.interrupt.memory();\n *\n * const agent = ai.agent({\n * model,\n * tools: [deleteAccount],\n * middleware: [\n * ai.human.approval({\n * policy: { type: \"allowlist\", tools: [\"deleteAccount\"] },\n * store,\n * handler,\n * }),\n * ],\n * });\n */\nexport function memory(): InterruptStore {\n return new MemoryInterruptStore();\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAM,uBAAN,MAAqD;;oCAErB,IAAI,IAA8B;;;;;;;CAOhE,MAAa,KAAK,QAAyC;EACzD,KAAK,WAAW,IAAI,OAAO,aAAa,MAAM;CAChD;;;;;CAMA,MAAa,KACX,aACuC;EACvC,OAAO,KAAK,WAAW,IAAI,WAAW;CACxC;;;;;CAMA,MAAa,OAAO,aAAoC;EACtD,KAAK,WAAW,OAAO,WAAW;CACpC;;;;;;CAOA,MAAa,KAAK,QAAoC;EACpD,MAAM,MAAM,CAAC,GAAG,KAAK,WAAW,KAAK,CAAC;EAEtC,IAAI,WAAW,QACb,OAAO;EAGT,OAAO,IAAI,QAAQ,OAAO,GAAG,WAAW,MAAM,CAAC;CACjD;;;;;;CAOA,AAAO,SAAiB;EACtB,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAAyB;CACvC,OAAO,IAAI,qBAAqB;AAClC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
//#region ../@warlock.js/ai/src/human/stores/pg.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default backing table — provisions the store with no extra config when
|
|
4
|
+
* the dev runs {@link InterruptStore.schema} through their migration tool.
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_TABLE = "warlock_ai_human_interrupts";
|
|
7
|
+
/**
|
|
8
|
+
* Allowed characters in a Postgres identifier (table name). The table name
|
|
9
|
+
* is interpolated into DDL/DML, so anything outside this conservative
|
|
10
|
+
* ASCII subset is rejected — interpolating an arbitrary string would be a
|
|
11
|
+
* SQL-injection footgun (mirrors `@warlock.js/ai`'s pg stores).
|
|
12
|
+
*/
|
|
13
|
+
const SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
14
|
+
/**
|
|
15
|
+
* Module specifier for the optional `pg` driver. Held in a `string`
|
|
16
|
+
* variable so the dynamic `import()` is not statically resolved at
|
|
17
|
+
* compile time — `pg` is an optional peer that need not be installed for
|
|
18
|
+
* this package to type-check or for a memory-only consumer to run.
|
|
19
|
+
*/
|
|
20
|
+
const PG_MODULE = "pg";
|
|
21
|
+
/**
|
|
22
|
+
* Curated install string surfaced (at use time) when a `connectionString`
|
|
23
|
+
* is configured but the optional `pg` driver is absent. Never thrown at
|
|
24
|
+
* import — a memory-only consumer must be able to load this module.
|
|
25
|
+
*/
|
|
26
|
+
const PG_INSTALL_INSTRUCTIONS = `
|
|
27
|
+
The @warlock.js/ai Postgres interrupt store requires the pg package.
|
|
28
|
+
Install it with:
|
|
29
|
+
|
|
30
|
+
npm install pg
|
|
31
|
+
|
|
32
|
+
Or with your preferred package manager:
|
|
33
|
+
|
|
34
|
+
pnpm add pg
|
|
35
|
+
yarn add pg
|
|
36
|
+
`.trim();
|
|
37
|
+
/**
|
|
38
|
+
* Lazily import `pg` and return a `Pool` built from `connectionString`. A
|
|
39
|
+
* bare `catch` rethrows the curated install string — a missing optional
|
|
40
|
+
* peer surfaces as actionable guidance, never a raw resolution error.
|
|
41
|
+
*/
|
|
42
|
+
async function buildPgClient(connectionString) {
|
|
43
|
+
let sdk;
|
|
44
|
+
try {
|
|
45
|
+
sdk = await import(PG_MODULE);
|
|
46
|
+
} catch {
|
|
47
|
+
throw new Error(PG_INSTALL_INSTRUCTIONS);
|
|
48
|
+
}
|
|
49
|
+
return new sdk.Pool({ connectionString });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Coerce a Postgres timestamp/text column to an ISO string. `pg` returns
|
|
53
|
+
* `TIMESTAMPTZ` as a `Date`; normalize to the ISO wire shape the
|
|
54
|
+
* {@link PendingInterrupt} contract declares.
|
|
55
|
+
*/
|
|
56
|
+
function toIso(value) {
|
|
57
|
+
if (value instanceof Date) return value.toISOString();
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Map a raw DB row to a {@link PendingInterrupt}. Column names match the
|
|
62
|
+
* reference DDL 1:1; the `request` JSONB rides one column, so it is parsed
|
|
63
|
+
* defensively (node-postgres parses `JSONB` already, but some pool
|
|
64
|
+
* wrappers hand back the raw string).
|
|
65
|
+
*/
|
|
66
|
+
function rowToRecord(row) {
|
|
67
|
+
const request = typeof row.request === "string" ? JSON.parse(row.request) : row.request;
|
|
68
|
+
return {
|
|
69
|
+
interruptId: row.interrupt_id,
|
|
70
|
+
request,
|
|
71
|
+
status: row.status,
|
|
72
|
+
savedAt: toIso(row.saved_at)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Postgres-backed {@link InterruptStore} — one durable row per pending
|
|
77
|
+
* interrupt, keyed by `interrupt_id`.
|
|
78
|
+
*
|
|
79
|
+
* Owns: durable round-tripping of the {@link PendingInterrupt} envelope so
|
|
80
|
+
* a reviewer can rule out-of-process (a webhook approves hours later, in a
|
|
81
|
+
* different process), the reference DDL via {@link PgInterruptStore.schema},
|
|
82
|
+
* and prefix-filtered enumeration. Does NOT own: the connection lifecycle
|
|
83
|
+
* (a dev-supplied client is never closed; a store-built `Pool` from a
|
|
84
|
+
* `connectionString` is also left open for the process to reuse) or schema
|
|
85
|
+
* migration (the dev runs `schema()` through their own tool — never
|
|
86
|
+
* auto-migrated).
|
|
87
|
+
*
|
|
88
|
+
* Like the snapshot store, a call has exactly one live interrupt, so
|
|
89
|
+
* `save()` upserts on the `interrupt_id` primary key.
|
|
90
|
+
*
|
|
91
|
+
* Front it with the {@link pg} factory — callers never `new` it.
|
|
92
|
+
*/
|
|
93
|
+
var PgInterruptStore = class {
|
|
94
|
+
constructor(options) {
|
|
95
|
+
const table = options.table ?? DEFAULT_TABLE;
|
|
96
|
+
if (!SAFE_IDENTIFIER.test(table)) throw new TypeError(`ai.human.interrupt.pg: invalid table name '${table}'. Allowed: [A-Za-z_][A-Za-z0-9_]*.`);
|
|
97
|
+
this.table = table;
|
|
98
|
+
if (options.client) {
|
|
99
|
+
if (typeof options.client.query !== "function") throw new TypeError("ai.human.interrupt.pg requires a 'client' option implementing { query(text, params) } — pass a pg.Pool or pg.Client.");
|
|
100
|
+
this.clientPromise = Promise.resolve(options.client);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (options.connectionString) {
|
|
104
|
+
this.clientPromise = buildPgClient(options.connectionString);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
throw new TypeError("ai.human.interrupt.pg requires either a 'client' or a 'connectionString' option.");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolve the backing client, surfacing the lazy `pg` import's curated
|
|
111
|
+
* install string on the first call that needs it.
|
|
112
|
+
*/
|
|
113
|
+
client() {
|
|
114
|
+
return this.clientPromise;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Persist a pending interrupt, keyed by its own `interrupt_id`. Upserts
|
|
118
|
+
* — a call has exactly one live interrupt, so a second save for the same
|
|
119
|
+
* id overwrites the payload rather than appending.
|
|
120
|
+
*/
|
|
121
|
+
async save(record) {
|
|
122
|
+
await (await this.client()).query(`INSERT INTO ${this.table} (interrupt_id, request, status, saved_at)
|
|
123
|
+
VALUES ($1, $2::jsonb, $3, $4)
|
|
124
|
+
ON CONFLICT (interrupt_id) DO UPDATE
|
|
125
|
+
SET request = EXCLUDED.request,
|
|
126
|
+
status = EXCLUDED.status,
|
|
127
|
+
saved_at = EXCLUDED.saved_at`, [
|
|
128
|
+
record.interruptId,
|
|
129
|
+
JSON.stringify(record.request),
|
|
130
|
+
record.status,
|
|
131
|
+
record.savedAt
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Load the interrupt for an `interruptId`, or `undefined` when none is
|
|
136
|
+
* recorded.
|
|
137
|
+
*/
|
|
138
|
+
async load(interruptId) {
|
|
139
|
+
const { rows } = await (await this.client()).query(`SELECT interrupt_id, request, status, saved_at
|
|
140
|
+
FROM ${this.table}
|
|
141
|
+
WHERE interrupt_id = $1`, [interruptId]);
|
|
142
|
+
if (rows.length === 0) return;
|
|
143
|
+
return rowToRecord(rows[0]);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Drop the interrupt for an `interruptId`. Idempotent — deleting an
|
|
147
|
+
* absent id deletes zero rows.
|
|
148
|
+
*/
|
|
149
|
+
async delete(interruptId) {
|
|
150
|
+
await (await this.client()).query(`DELETE FROM ${this.table} WHERE interrupt_id = $1`, [interruptId]);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* List the interrupt ids known to the store, optionally filtered by a
|
|
154
|
+
* prefix. The `_` and `%` LIKE wildcards in the prefix are escaped so an
|
|
155
|
+
* opaque interruptId that happens to contain them is matched literally.
|
|
156
|
+
*/
|
|
157
|
+
async list(prefix) {
|
|
158
|
+
const client = await this.client();
|
|
159
|
+
if (prefix === void 0) {
|
|
160
|
+
const { rows } = await client.query(`SELECT interrupt_id FROM ${this.table}`);
|
|
161
|
+
return rows.map((row) => row.interrupt_id);
|
|
162
|
+
}
|
|
163
|
+
const escaped = prefix.replace(/\\/g, "\\\\").replace(/_/g, "\\_").replace(/%/g, "\\%");
|
|
164
|
+
const { rows } = await client.query(`SELECT interrupt_id FROM ${this.table}
|
|
165
|
+
WHERE interrupt_id LIKE $1 ESCAPE '\\'`, [`${escaped}%`]);
|
|
166
|
+
return rows.map((row) => row.interrupt_id);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Return the reference DDL for this store's backing table, interpolating
|
|
170
|
+
* the configured table name. The dev runs it through their migration
|
|
171
|
+
* tool — the framework never auto-migrates.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* await pool.query(store.schema());
|
|
175
|
+
*/
|
|
176
|
+
schema() {
|
|
177
|
+
return [
|
|
178
|
+
`CREATE TABLE IF NOT EXISTS ${this.table} (`,
|
|
179
|
+
` interrupt_id TEXT PRIMARY KEY,`,
|
|
180
|
+
` request JSONB NOT NULL,`,
|
|
181
|
+
` status TEXT NOT NULL,`,
|
|
182
|
+
` saved_at TIMESTAMPTZ NOT NULL DEFAULT now()`,
|
|
183
|
+
`);`,
|
|
184
|
+
`CREATE INDEX IF NOT EXISTS idx_${this.table}_saved_at`,
|
|
185
|
+
` ON ${this.table} (saved_at);`
|
|
186
|
+
].join("\n");
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Create a Postgres-backed {@link InterruptStore}. Either pass a live
|
|
191
|
+
* `pg.Pool` / `pg.Client` (`{ client }`) — `@warlock.js/ai` never
|
|
192
|
+
* imports `pg` in that case — or a `{ connectionString }` and let the
|
|
193
|
+
* store lazily `import("pg")` to build its own pool. When `pg` is not
|
|
194
|
+
* installed, the curated install string surfaces on first use, never at
|
|
195
|
+
* import. Run {@link InterruptStore.schema} through your migration tool
|
|
196
|
+
* once before use; the store never auto-migrates.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* import { Pool } from "pg";
|
|
200
|
+
* import { ai } from "@warlock.js/ai";
|
|
201
|
+
*
|
|
202
|
+
* const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
203
|
+
* const store = ai.human.interrupt.pg({ client: pool });
|
|
204
|
+
*
|
|
205
|
+
* // Once, via your migration tooling:
|
|
206
|
+
* // await pool.query(store.schema());
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // Let the store build its own pool from a connection string:
|
|
210
|
+
* const store = ai.human.interrupt.pg({
|
|
211
|
+
* connectionString: process.env.DATABASE_URL,
|
|
212
|
+
* });
|
|
213
|
+
*/
|
|
214
|
+
function pg(options) {
|
|
215
|
+
return new PgInterruptStore(options);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
//#endregion
|
|
219
|
+
export { pg };
|
|
220
|
+
//# sourceMappingURL=pg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/ai/src/human/stores/pg.ts"],"sourcesContent":["import type {\n InterruptStore,\n PendingInterrupt,\n PgClientLike,\n} from \"../contracts/interrupt-store.contract\";\n\n/**\n * Options for the Postgres {@link InterruptStore}.\n *\n * Two mutually-supportive ways to supply the connection:\n * - **`client`** — pass an already-built `pg.Pool` / `pg.Client` (anything\n * satisfying {@link PgClientLike}). The store only ever calls `query`\n * and never opens or closes it; a single pool can back both an\n * orchestrator's checkpoint/snapshot stores and this interrupt table.\n * - **`connectionString`** — let the store lazily `import(\"pg\")` and build\n * its own `Pool`. `@warlock.js/ai` takes **no** hard dependency on\n * `pg` (it is an optional peer); when it is absent the store throws a\n * curated install string at first use, never a raw module-resolution\n * stack trace at import.\n *\n * Exactly one of the two must be present.\n */\nexport interface PgInterruptOptions {\n /** An already-built `pg.Pool` / `pg.Client` — anything matching {@link PgClientLike}. */\n client?: PgClientLike;\n\n /** Connection string the store passes to a lazily-imported `pg.Pool`. */\n connectionString?: string;\n\n /**\n * Backing table name. Defaults to `warlock_ai_human_interrupts`. Must be\n * a safe SQL identifier — it is interpolated into DDL/DML.\n */\n table?: string;\n}\n\n/**\n * Default backing table — provisions the store with no extra config when\n * the dev runs {@link InterruptStore.schema} through their migration tool.\n */\nconst DEFAULT_TABLE = \"warlock_ai_human_interrupts\";\n\n/**\n * Allowed characters in a Postgres identifier (table name). The table name\n * is interpolated into DDL/DML, so anything outside this conservative\n * ASCII subset is rejected — interpolating an arbitrary string would be a\n * SQL-injection footgun (mirrors `@warlock.js/ai`'s pg stores).\n */\nconst SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * Module specifier for the optional `pg` driver. Held in a `string`\n * variable so the dynamic `import()` is not statically resolved at\n * compile time — `pg` is an optional peer that need not be installed for\n * this package to type-check or for a memory-only consumer to run.\n */\nconst PG_MODULE = \"pg\";\n\n/**\n * Curated install string surfaced (at use time) when a `connectionString`\n * is configured but the optional `pg` driver is absent. Never thrown at\n * import — a memory-only consumer must be able to load this module.\n */\nconst PG_INSTALL_INSTRUCTIONS = `\nThe @warlock.js/ai Postgres interrupt store requires the pg package.\nInstall it with:\n\n npm install pg\n\nOr with your preferred package manager:\n\n pnpm add pg\n yarn add pg\n`.trim();\n\n/**\n * Minimal structural view of a `pg.Pool` constructor — just enough of the\n * `pg` module surface for the store to build a client when handed a\n * `connectionString`. Declared locally (rather than `typeof import(\"pg\")`)\n * so this module type-checks even when `pg` is not installed.\n */\ninterface PgModuleLike {\n Pool: new (config: { connectionString: string }) => PgClientLike;\n}\n\n/**\n * Lazily import `pg` and return a `Pool` built from `connectionString`. A\n * bare `catch` rethrows the curated install string — a missing optional\n * peer surfaces as actionable guidance, never a raw resolution error.\n */\nasync function buildPgClient(connectionString: string): Promise<PgClientLike> {\n let sdk: PgModuleLike;\n\n try {\n sdk = (await import(PG_MODULE)) as unknown as PgModuleLike;\n } catch {\n throw new Error(PG_INSTALL_INSTRUCTIONS);\n }\n\n return new sdk.Pool({ connectionString });\n}\n\n/**\n * Coerce a Postgres timestamp/text column to an ISO string. `pg` returns\n * `TIMESTAMPTZ` as a `Date`; normalize to the ISO wire shape the\n * {@link PendingInterrupt} contract declares.\n */\nfunction toIso(value: unknown): string {\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n return value as string;\n}\n\n/**\n * Map a raw DB row to a {@link PendingInterrupt}. Column names match the\n * reference DDL 1:1; the `request` JSONB rides one column, so it is parsed\n * defensively (node-postgres parses `JSONB` already, but some pool\n * wrappers hand back the raw string).\n */\nfunction rowToRecord(row: Record<string, unknown>): PendingInterrupt {\n const request =\n typeof row.request === \"string\" ? JSON.parse(row.request) : row.request;\n\n return {\n interruptId: row.interrupt_id as string,\n request: request as PendingInterrupt[\"request\"],\n status: row.status as PendingInterrupt[\"status\"],\n savedAt: toIso(row.saved_at),\n };\n}\n\n/**\n * Postgres-backed {@link InterruptStore} — one durable row per pending\n * interrupt, keyed by `interrupt_id`.\n *\n * Owns: durable round-tripping of the {@link PendingInterrupt} envelope so\n * a reviewer can rule out-of-process (a webhook approves hours later, in a\n * different process), the reference DDL via {@link PgInterruptStore.schema},\n * and prefix-filtered enumeration. Does NOT own: the connection lifecycle\n * (a dev-supplied client is never closed; a store-built `Pool` from a\n * `connectionString` is also left open for the process to reuse) or schema\n * migration (the dev runs `schema()` through their own tool — never\n * auto-migrated).\n *\n * Like the snapshot store, a call has exactly one live interrupt, so\n * `save()` upserts on the `interrupt_id` primary key.\n *\n * Front it with the {@link pg} factory — callers never `new` it.\n */\nclass PgInterruptStore implements InterruptStore {\n /** Validated backing table name, safe to interpolate into SQL. */\n private readonly table: string;\n\n /**\n * A ready client, or a promise resolving to one the store builds lazily\n * from a `connectionString`. Resolved once and memoized so the optional\n * `pg` import happens at most once.\n */\n private clientPromise: Promise<PgClientLike>;\n\n public constructor(options: PgInterruptOptions) {\n const table = options.table ?? DEFAULT_TABLE;\n\n if (!SAFE_IDENTIFIER.test(table)) {\n throw new TypeError(\n `ai.human.interrupt.pg: invalid table name '${table}'. Allowed: [A-Za-z_][A-Za-z0-9_]*.`,\n );\n }\n\n this.table = table;\n\n if (options.client) {\n if (typeof options.client.query !== \"function\") {\n throw new TypeError(\n \"ai.human.interrupt.pg requires a 'client' option implementing { query(text, params) } — pass a pg.Pool or pg.Client.\",\n );\n }\n\n this.clientPromise = Promise.resolve(options.client);\n\n return;\n }\n\n if (options.connectionString) {\n // Defer the optional `pg` import to first use — a curated install\n // string surfaces from `buildPgClient`, not at construction.\n this.clientPromise = buildPgClient(options.connectionString);\n\n return;\n }\n\n throw new TypeError(\n \"ai.human.interrupt.pg requires either a 'client' or a 'connectionString' option.\",\n );\n }\n\n /**\n * Resolve the backing client, surfacing the lazy `pg` import's curated\n * install string on the first call that needs it.\n */\n private client(): Promise<PgClientLike> {\n return this.clientPromise;\n }\n\n /**\n * Persist a pending interrupt, keyed by its own `interrupt_id`. Upserts\n * — a call has exactly one live interrupt, so a second save for the same\n * id overwrites the payload rather than appending.\n */\n public async save(record: PendingInterrupt): Promise<void> {\n const client = await this.client();\n\n await client.query(\n `INSERT INTO ${this.table} (interrupt_id, request, status, saved_at)\n VALUES ($1, $2::jsonb, $3, $4)\n ON CONFLICT (interrupt_id) DO UPDATE\n SET request = EXCLUDED.request,\n status = EXCLUDED.status,\n saved_at = EXCLUDED.saved_at`,\n [\n record.interruptId,\n JSON.stringify(record.request),\n record.status,\n record.savedAt,\n ],\n );\n }\n\n /**\n * Load the interrupt for an `interruptId`, or `undefined` when none is\n * recorded.\n */\n public async load(\n interruptId: string,\n ): Promise<PendingInterrupt | undefined> {\n const client = await this.client();\n\n const { rows } = await client.query(\n `SELECT interrupt_id, request, status, saved_at\n FROM ${this.table}\n WHERE interrupt_id = $1`,\n [interruptId],\n );\n\n if (rows.length === 0) {\n return undefined;\n }\n\n return rowToRecord(rows[0] as Record<string, unknown>);\n }\n\n /**\n * Drop the interrupt for an `interruptId`. Idempotent — deleting an\n * absent id deletes zero rows.\n */\n public async delete(interruptId: string): Promise<void> {\n const client = await this.client();\n\n await client.query(\n `DELETE FROM ${this.table} WHERE interrupt_id = $1`,\n [interruptId],\n );\n }\n\n /**\n * List the interrupt ids known to the store, optionally filtered by a\n * prefix. The `_` and `%` LIKE wildcards in the prefix are escaped so an\n * opaque interruptId that happens to contain them is matched literally.\n */\n public async list(prefix?: string): Promise<string[]> {\n const client = await this.client();\n\n if (prefix === undefined) {\n const { rows } = await client.query(\n `SELECT interrupt_id FROM ${this.table}`,\n );\n\n return rows.map(\n (row) => (row as Record<string, unknown>).interrupt_id as string,\n );\n }\n\n const escaped = prefix\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/_/g, \"\\\\_\")\n .replace(/%/g, \"\\\\%\");\n\n const { rows } = await client.query(\n `SELECT interrupt_id FROM ${this.table}\n WHERE interrupt_id LIKE $1 ESCAPE '\\\\'`,\n [`${escaped}%`],\n );\n\n return rows.map(\n (row) => (row as Record<string, unknown>).interrupt_id as string,\n );\n }\n\n /**\n * Return the reference DDL for this store's backing table, interpolating\n * the configured table name. The dev runs it through their migration\n * tool — the framework never auto-migrates.\n *\n * @example\n * await pool.query(store.schema());\n */\n public schema(): string {\n return [\n `CREATE TABLE IF NOT EXISTS ${this.table} (`,\n ` interrupt_id TEXT PRIMARY KEY,`,\n ` request JSONB NOT NULL,`,\n ` status TEXT NOT NULL,`,\n ` saved_at TIMESTAMPTZ NOT NULL DEFAULT now()`,\n `);`,\n `CREATE INDEX IF NOT EXISTS idx_${this.table}_saved_at`,\n ` ON ${this.table} (saved_at);`,\n ].join(\"\\n\");\n }\n}\n\n/**\n * Create a Postgres-backed {@link InterruptStore}. Either pass a live\n * `pg.Pool` / `pg.Client` (`{ client }`) — `@warlock.js/ai` never\n * imports `pg` in that case — or a `{ connectionString }` and let the\n * store lazily `import(\"pg\")` to build its own pool. When `pg` is not\n * installed, the curated install string surfaces on first use, never at\n * import. Run {@link InterruptStore.schema} through your migration tool\n * once before use; the store never auto-migrates.\n *\n * @example\n * import { Pool } from \"pg\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * const pool = new Pool({ connectionString: process.env.DATABASE_URL });\n * const store = ai.human.interrupt.pg({ client: pool });\n *\n * // Once, via your migration tooling:\n * // await pool.query(store.schema());\n *\n * @example\n * // Let the store build its own pool from a connection string:\n * const store = ai.human.interrupt.pg({\n * connectionString: process.env.DATABASE_URL,\n * });\n */\nexport function pg(options: PgInterruptOptions): InterruptStore {\n return new PgInterruptStore(options);\n}\n"],"mappings":";;;;;AAwCA,MAAM,gBAAgB;;;;;;;AAQtB,MAAM,kBAAkB;;;;;;;AAQxB,MAAM,YAAY;;;;;;AAOlB,MAAM,0BAA0B;;;;;;;;;;EAU9B,KAAK;;;;;;AAiBP,eAAe,cAAc,kBAAiD;CAC5E,IAAI;CAEJ,IAAI;EACF,MAAO,MAAM,OAAO;CACtB,QAAQ;EACN,MAAM,IAAI,MAAM,uBAAuB;CACzC;CAEA,OAAO,IAAI,IAAI,KAAK,EAAE,iBAAiB,CAAC;AAC1C;;;;;;AAOA,SAAS,MAAM,OAAwB;CACrC,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;CAG3B,OAAO;AACT;;;;;;;AAQA,SAAS,YAAY,KAAgD;CACnE,MAAM,UACJ,OAAO,IAAI,YAAY,WAAW,KAAK,MAAM,IAAI,OAAO,IAAI,IAAI;CAElE,OAAO;EACL,aAAa,IAAI;EACR;EACT,QAAQ,IAAI;EACZ,SAAS,MAAM,IAAI,QAAQ;CAC7B;AACF;;;;;;;;;;;;;;;;;;;AAoBA,IAAM,mBAAN,MAAiD;CAW/C,AAAO,YAAY,SAA6B;EAC9C,MAAM,QAAQ,QAAQ,SAAS;EAE/B,IAAI,CAAC,gBAAgB,KAAK,KAAK,GAC7B,MAAM,IAAI,UACR,8CAA8C,MAAM,oCACtD;EAGF,KAAK,QAAQ;EAEb,IAAI,QAAQ,QAAQ;GAClB,IAAI,OAAO,QAAQ,OAAO,UAAU,YAClC,MAAM,IAAI,UACR,sHACF;GAGF,KAAK,gBAAgB,QAAQ,QAAQ,QAAQ,MAAM;GAEnD;EACF;EAEA,IAAI,QAAQ,kBAAkB;GAG5B,KAAK,gBAAgB,cAAc,QAAQ,gBAAgB;GAE3D;EACF;EAEA,MAAM,IAAI,UACR,kFACF;CACF;;;;;CAMA,AAAQ,SAAgC;EACtC,OAAO,KAAK;CACd;;;;;;CAOA,MAAa,KAAK,QAAyC;EAGzD,OAAM,MAFe,KAAK,OAAO,EAErB,CAAC,MACX,eAAe,KAAK,MAAM;;;;;4CAM1B;GACE,OAAO;GACP,KAAK,UAAU,OAAO,OAAO;GAC7B,OAAO;GACP,OAAO;EACT,CACF;CACF;;;;;CAMA,MAAa,KACX,aACuC;EAGvC,MAAM,EAAE,SAAS,OAAM,MAFF,KAAK,OAAO,EAEJ,CAAC,MAC5B;cACQ,KAAK,MAAM;iCAEnB,CAAC,WAAW,CACd;EAEA,IAAI,KAAK,WAAW,GAClB;EAGF,OAAO,YAAY,KAAK,EAA6B;CACvD;;;;;CAMA,MAAa,OAAO,aAAoC;EAGtD,OAAM,MAFe,KAAK,OAAO,EAErB,CAAC,MACX,eAAe,KAAK,MAAM,2BAC1B,CAAC,WAAW,CACd;CACF;;;;;;CAOA,MAAa,KAAK,QAAoC;EACpD,MAAM,SAAS,MAAM,KAAK,OAAO;EAEjC,IAAI,WAAW,QAAW;GACxB,MAAM,EAAE,SAAS,MAAM,OAAO,MAC5B,4BAA4B,KAAK,OACnC;GAEA,OAAO,KAAK,KACT,QAAS,IAAgC,YAC5C;EACF;EAEA,MAAM,UAAU,OACb,QAAQ,OAAO,MAAM,CAAC,CACtB,QAAQ,MAAM,KAAK,CAAC,CACpB,QAAQ,MAAM,KAAK;EAEtB,MAAM,EAAE,SAAS,MAAM,OAAO,MAC5B,4BAA4B,KAAK,MAAM;gDAEvC,CAAC,GAAG,QAAQ,EAAE,CAChB;EAEA,OAAO,KAAK,KACT,QAAS,IAAgC,YAC5C;CACF;;;;;;;;;CAUA,AAAO,SAAiB;EACtB,OAAO;GACL,8BAA8B,KAAK,MAAM;GACzC;GACA;GACA;GACA;GACA;GACA,kCAAkC,KAAK,MAAM;GAC7C,QAAQ,KAAK,MAAM;EACrB,CAAC,CAAC,KAAK,IAAI;CACb;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,GAAG,SAA6C;CAC9D,OAAO,IAAI,iBAAiB,OAAO;AACrC"}
|