@warlock.js/core 4.3.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -6
- 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 +1157 -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/spawn-sub-agent.mjs +68 -0
- package/esm/ai/src/agent/spawn-sub-agent.mjs.map +1 -0
- package/esm/ai/src/ai.mjs +155 -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-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 +37 -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-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/index.mjs +174 -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 +614 -0
- package/esm/ai/src/planner/planner-run.mjs.map +1 -0
- package/esm/ai/src/planner/planner.mjs +120 -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/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/index.mjs +7 -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/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/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/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/index.mjs +4 -0
- package/esm/ai-openai/src/model.mjs +5 -0
- package/esm/ai-openai/src/sdk.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +4 -0
- package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
- package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
- package/esm/application/application.d.mts +126 -4
- package/esm/application/application.d.mts.map +1 -1
- package/esm/application/application.mjs +133 -0
- package/esm/application/application.mjs.map +1 -1
- package/esm/application/index.d.mts +1 -1
- 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/generate/templates/stubs.mjs +3 -4
- package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
- package/esm/cli/types.d.mts +2 -1
- package/esm/cli/types.d.mts.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 +12 -3
- 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 +8 -0
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +40 -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/dev-server/development-server.mjs +9 -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/loader/transpile-cache.mjs +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 +57 -0
- package/esm/http/health.d.mts.map +1 -0
- package/esm/http/health.mjs +75 -0
- package/esm/http/health.mjs.map +1 -0
- package/esm/http/index.d.mts +2 -1
- package/esm/http/index.mjs +2 -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 +16 -1
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +24 -4
- package/esm/http/server.mjs.map +1 -1
- package/esm/http/types.d.mts +45 -0
- package/esm/http/types.d.mts.map +1 -1
- package/esm/index.d.mts +10 -5
- package/esm/index.mjs +10 -5
- 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/production/production-builder.mjs +2 -2
- package/esm/production/production-builder.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +9 -0
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +32 -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/repository.manager.d.mts +11 -1
- package/esm/repositories/repository.manager.d.mts.map +1 -1
- package/esm/repositories/repository.manager.mjs +79 -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.map +1 -1
- package/esm/router/router.mjs +7 -4
- 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/environment.d.mts +6 -1
- package/esm/utils/environment.d.mts.map +1 -1
- package/esm/utils/environment.mjs.map +1 -1
- package/esm/utils/index.d.mts +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 +193 -3
- package/llms.txt +2 -1
- package/package.json +9 -9
- package/skills/add-connector/SKILL.md +6 -1
- package/skills/configure-app/SKILL.md +23 -0
- package/skills/health-checks/SKILL.md +98 -0
- package/skills/use-app-context/SKILL.md +62 -2
package/esm/utils/paths.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import baseConfig from "@mongez/config";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
//#region ../@warlock.js/core/src/utils/paths.ts
|
|
@@ -28,7 +28,7 @@ function storagePath(relativePath = "") {
|
|
|
28
28
|
* If no path is given, it will return the absolute path to the uploads folder
|
|
29
29
|
*/
|
|
30
30
|
function uploadsPath(relativePath = "") {
|
|
31
|
-
const configPath =
|
|
31
|
+
const configPath = baseConfig.get("uploads.root");
|
|
32
32
|
if (!configPath) return rootPath("storage", "uploads", relativePath);
|
|
33
33
|
return typeof configPath === "function" ? configPath(relativePath) : path.resolve(configPath, relativePath);
|
|
34
34
|
}
|
package/esm/utils/paths.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/utils/paths.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport path from \"path\";\r\n\r\n/**\r\n * Get root path or join the given paths to the root path\r\n */\r\nexport function rootPath(...paths: string[]) {\r\n return path.resolve(process.cwd(), ...paths);\r\n}\r\n\r\n/**\r\n * Get src directory path or join the given paths to the src directory path\r\n */\r\nexport function srcPath(...paths: string[]) {\r\n return rootPath(\"src\", ...paths);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the storage folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the storage folder\r\n */\r\nexport function storagePath(relativePath = \"\") {\r\n return rootPath(\"storage\", relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the uploads folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the uploads folder\r\n */\r\nexport function uploadsPath(relativePath = \"\") {\r\n const configPath = config.get(\"uploads.root\");\r\n if (!configPath) {\r\n return rootPath(\"storage\", \"uploads\", relativePath);\r\n }\r\n\r\n return typeof configPath === \"function\"\r\n ? configPath(relativePath)\r\n : path.resolve(configPath, relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the public folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the public folder\r\n */\r\nexport function publicPath(relativePath = \"\") {\r\n return rootPath(\"public\", relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the cache folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the cache folder\r\n */\r\nexport function cachePath(relativePath = \"\") {\r\n return rootPath(\"storage\", \"cache\", relativePath);\r\n}\r\n\r\n/**\r\n * App path\r\n */\r\nexport function appPath(relativePath = \"\") {\r\n return rootPath(\"src/app\", relativePath);\r\n}\r\n\r\n/**\r\n * Get logs directory path\r\n */\r\nexport function logsPath(relativePath = \"\") {\r\n return rootPath(\"storage/logs\", relativePath);\r\n}\r\n\r\n/**\r\n * Get a temp path\r\n */\r\nexport function tempPath(relativePath = \"\") {\r\n return rootPath(\"storage/tmp\", relativePath);\r\n}\r\n\r\n/**\r\n * Remove any invalid characters from the file path using regex\r\n * It should accept any language character, numbers, and the following characters: _ - .\r\n */\r\nconst invalidCharsRegex = /[<>:\"/\\\\|?*]/g; // Regex to match invalid characters\r\nexport function sanitizePath(filePath: string) {\r\n return filePath.replace(invalidCharsRegex, \"\"); // Replace invalid characters with an empty string\r\n}\r\n\r\n/**\r\n * Warlock path\r\n * PLEASE DO NOT add any files in this directory as it may be deleted\r\n */\r\nexport function warlockPath(...path: string[]) {\r\n return rootPath(\".warlock\", ...path);\r\n}\r\n\r\n/**\r\n * Get config directory path\r\n */\r\nexport function configPath(...path: string[]) {\r\n return rootPath(\"src/config\", ...path);\r\n}\r\n\r\nexport const paths = {\r\n root: rootPath,\r\n src: srcPath,\r\n storage: storagePath,\r\n logs: logsPath,\r\n uploads: uploadsPath,\r\n public: publicPath,\r\n cache: cachePath,\r\n app: appPath,\r\n temp: tempPath,\r\n warlock: warlockPath,\r\n config: configPath,\r\n sanitize: sanitizePath,\r\n};\r\n"],"mappings":";;;;;;;AAMA,SAAgB,SAAS,GAAG,OAAiB;CAC3C,OAAO,KAAK,QAAQ,QAAQ,IAAI,GAAG,GAAG,KAAK;AAC7C;;;;AAKA,SAAgB,QAAQ,GAAG,OAAiB;CAC1C,OAAO,SAAS,OAAO,GAAG,KAAK;AACjC;;;;;;AAOA,SAAgB,YAAY,eAAe,IAAI;CAC7C,OAAO,SAAS,WAAW,YAAY;AACzC;;;;;;AAOA,SAAgB,YAAY,eAAe,IAAI;CAC7C,MAAM,
|
|
1
|
+
{"version":3,"file":"paths.mjs","names":["config"],"sources":["../../../../../../../@warlock.js/core/src/utils/paths.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport path from \"path\";\r\n\r\n/**\r\n * Get root path or join the given paths to the root path\r\n */\r\nexport function rootPath(...paths: string[]) {\r\n return path.resolve(process.cwd(), ...paths);\r\n}\r\n\r\n/**\r\n * Get src directory path or join the given paths to the src directory path\r\n */\r\nexport function srcPath(...paths: string[]) {\r\n return rootPath(\"src\", ...paths);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the storage folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the storage folder\r\n */\r\nexport function storagePath(relativePath = \"\") {\r\n return rootPath(\"storage\", relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the uploads folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the uploads folder\r\n */\r\nexport function uploadsPath(relativePath = \"\") {\r\n const configPath = config.get(\"uploads.root\");\r\n if (!configPath) {\r\n return rootPath(\"storage\", \"uploads\", relativePath);\r\n }\r\n\r\n return typeof configPath === \"function\"\r\n ? configPath(relativePath)\r\n : path.resolve(configPath, relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the public folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the public folder\r\n */\r\nexport function publicPath(relativePath = \"\") {\r\n return rootPath(\"public\", relativePath);\r\n}\r\n\r\n/**\r\n * Get the absolute path to the cache folder to the given path\r\n *\r\n * If no path is given, it will return the absolute path to the cache folder\r\n */\r\nexport function cachePath(relativePath = \"\") {\r\n return rootPath(\"storage\", \"cache\", relativePath);\r\n}\r\n\r\n/**\r\n * App path\r\n */\r\nexport function appPath(relativePath = \"\") {\r\n return rootPath(\"src/app\", relativePath);\r\n}\r\n\r\n/**\r\n * Get logs directory path\r\n */\r\nexport function logsPath(relativePath = \"\") {\r\n return rootPath(\"storage/logs\", relativePath);\r\n}\r\n\r\n/**\r\n * Get a temp path\r\n */\r\nexport function tempPath(relativePath = \"\") {\r\n return rootPath(\"storage/tmp\", relativePath);\r\n}\r\n\r\n/**\r\n * Remove any invalid characters from the file path using regex\r\n * It should accept any language character, numbers, and the following characters: _ - .\r\n */\r\nconst invalidCharsRegex = /[<>:\"/\\\\|?*]/g; // Regex to match invalid characters\r\nexport function sanitizePath(filePath: string) {\r\n return filePath.replace(invalidCharsRegex, \"\"); // Replace invalid characters with an empty string\r\n}\r\n\r\n/**\r\n * Warlock path\r\n * PLEASE DO NOT add any files in this directory as it may be deleted\r\n */\r\nexport function warlockPath(...path: string[]) {\r\n return rootPath(\".warlock\", ...path);\r\n}\r\n\r\n/**\r\n * Get config directory path\r\n */\r\nexport function configPath(...path: string[]) {\r\n return rootPath(\"src/config\", ...path);\r\n}\r\n\r\nexport const paths = {\r\n root: rootPath,\r\n src: srcPath,\r\n storage: storagePath,\r\n logs: logsPath,\r\n uploads: uploadsPath,\r\n public: publicPath,\r\n cache: cachePath,\r\n app: appPath,\r\n temp: tempPath,\r\n warlock: warlockPath,\r\n config: configPath,\r\n sanitize: sanitizePath,\r\n};\r\n"],"mappings":";;;;;;;AAMA,SAAgB,SAAS,GAAG,OAAiB;CAC3C,OAAO,KAAK,QAAQ,QAAQ,IAAI,GAAG,GAAG,KAAK;AAC7C;;;;AAKA,SAAgB,QAAQ,GAAG,OAAiB;CAC1C,OAAO,SAAS,OAAO,GAAG,KAAK;AACjC;;;;;;AAOA,SAAgB,YAAY,eAAe,IAAI;CAC7C,OAAO,SAAS,WAAW,YAAY;AACzC;;;;;;AAOA,SAAgB,YAAY,eAAe,IAAI;CAC7C,MAAM,aAAaA,WAAO,IAAI,cAAc;CAC5C,IAAI,CAAC,YACH,OAAO,SAAS,WAAW,WAAW,YAAY;CAGpD,OAAO,OAAO,eAAe,aACzB,WAAW,YAAY,IACvB,KAAK,QAAQ,YAAY,YAAY;AAC3C;;;;;;AAOA,SAAgB,WAAW,eAAe,IAAI;CAC5C,OAAO,SAAS,UAAU,YAAY;AACxC;;;;;;AAOA,SAAgB,UAAU,eAAe,IAAI;CAC3C,OAAO,SAAS,WAAW,SAAS,YAAY;AAClD;;;;AAKA,SAAgB,QAAQ,eAAe,IAAI;CACzC,OAAO,SAAS,WAAW,YAAY;AACzC;;;;AAKA,SAAgB,SAAS,eAAe,IAAI;CAC1C,OAAO,SAAS,gBAAgB,YAAY;AAC9C;;;;AAKA,SAAgB,SAAS,eAAe,IAAI;CAC1C,OAAO,SAAS,eAAe,YAAY;AAC7C;;;;;AAMA,MAAM,oBAAoB;AAC1B,SAAgB,aAAa,UAAkB;CAC7C,OAAO,SAAS,QAAQ,mBAAmB,EAAE;AAC/C;;;;;AAMA,SAAgB,YAAY,GAAG,MAAgB;CAC7C,OAAO,SAAS,YAAY,GAAG,IAAI;AACrC;;;;AAKA,SAAgB,WAAW,GAAG,MAAgB;CAC5C,OAAO,SAAS,cAAc,GAAG,IAAI;AACvC;AAEA,MAAa,QAAQ;CACnB,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,SAAS;CACT,QAAQ;CACR,OAAO;CACP,KAAK;CACL,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;AACZ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v } from "@warlock.js/seal";
|
|
2
|
-
import
|
|
2
|
+
import baseConfig from "@mongez/config";
|
|
3
3
|
import { log } from "@warlock.js/logger";
|
|
4
4
|
import { merge } from "@mongez/reinforcements";
|
|
5
5
|
|
|
@@ -40,7 +40,7 @@ async function validateAll(validation, request, response) {
|
|
|
40
40
|
if (validation.validate) {
|
|
41
41
|
const result = await validation.validate(request, response);
|
|
42
42
|
if (result) {
|
|
43
|
-
if (!response.statusCode) response.setStatusCode(
|
|
43
|
+
if (!response.statusCode) response.setStatusCode(baseConfig.get("validation.responseStatus", 400));
|
|
44
44
|
log.info("validation", "failed", "Validation failed");
|
|
45
45
|
return result;
|
|
46
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateAll.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/validation/validateAll.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { merge } from \"@mongez/reinforcements\";\nimport { log } from \"@warlock.js/logger\";\nimport { v } from \"@warlock.js/seal\";\nimport type { Request, Response } from \"../http\";\nimport type { RequestHandlerValidation, Route } from \"../router\";\n\nfunction resolveDataToParse(validating: RequestHandlerValidation[\"validating\"], request: Request) {\n if (!validating || validating.length === 0) return request.allExceptParams();\n\n let data: any = {};\n\n for (const validatingType of validating) {\n if (validatingType === \"body\") {\n data = merge(data, request.body);\n }\n\n if (validatingType === \"query\") {\n data = merge(data, request.query);\n }\n\n if (validatingType === \"params\") {\n data = merge(data, request.params);\n }\n\n if (validatingType === \"headers\") {\n data = merge(data, request.headers);\n }\n }\n\n return data;\n}\n\n/**\n * Validate the request route\n */\nexport async function validateAll(\n validation: Route[\"handler\"][\"validation\"],\n request: Request,\n response: Response,\n) {\n if (!validation) return;\n\n log.info(\"validation\", \"started\", \"Start validating the request\");\n\n if (validation.schema) {\n log.info(\"validation\", \"schema\", \"Validating request schema\");\n try {\n const data = resolveDataToParse(validation.validating, request);\n const result = await v.validate(validation.schema, data);\n\n if (result.data && result.isValid) {\n request.setValidatedData(result.data);\n }\n\n if (!result.isValid) {\n log.warn(\"validation\", \"schema\", \"Schema Validation failed\");\n return response.failedSchema(result);\n }\n\n log.success(\"validation\", \"schema\", \"Schema Validation passed\");\n } catch (error) {\n log.warn(\"app.validation\", \"error\", error);\n throw error;\n }\n }\n\n if (validation.validate) {\n const result = await validation.validate(request, response);\n\n // if there is a result, it means it failed\n if (result) {\n // check if there is no response status code, then set it to config value or 400 as default\n if (!response.statusCode) {\n response.setStatusCode(config.get(\"validation.responseStatus\", 400));\n }\n\n log.info(\"validation\", \"failed\", \"Validation failed\");\n\n return result;\n }\n\n log.info(\"validation\", \"passed\", \"Validation passed\");\n }\n}\n"],"mappings":";;;;;;AAOA,SAAS,mBAAmB,YAAoD,SAAkB;CAChG,IAAI,CAAC,cAAc,WAAW,WAAW,GAAG,OAAO,QAAQ,gBAAgB;CAE3E,IAAI,OAAY,CAAC;CAEjB,KAAK,MAAM,kBAAkB,YAAY;EACvC,IAAI,mBAAmB,QACrB,OAAO,MAAM,MAAM,QAAQ,IAAI;EAGjC,IAAI,mBAAmB,SACrB,OAAO,MAAM,MAAM,QAAQ,KAAK;EAGlC,IAAI,mBAAmB,UACrB,OAAO,MAAM,MAAM,QAAQ,MAAM;EAGnC,IAAI,mBAAmB,WACrB,OAAO,MAAM,MAAM,QAAQ,OAAO;CAEtC;CAEA,OAAO;AACT;;;;AAKA,eAAsB,YACpB,YACA,SACA,UACA;CACA,IAAI,CAAC,YAAY;CAEjB,IAAI,KAAK,cAAc,WAAW,8BAA8B;CAEhE,IAAI,WAAW,QAAQ;EACrB,IAAI,KAAK,cAAc,UAAU,2BAA2B;EAC5D,IAAI;GACF,MAAM,OAAO,mBAAmB,WAAW,YAAY,OAAO;GAC9D,MAAM,SAAS,MAAM,EAAE,SAAS,WAAW,QAAQ,IAAI;GAEvD,IAAI,OAAO,QAAQ,OAAO,SACxB,QAAQ,iBAAiB,OAAO,IAAI;GAGtC,IAAI,CAAC,OAAO,SAAS;IACnB,IAAI,KAAK,cAAc,UAAU,0BAA0B;IAC3D,OAAO,SAAS,aAAa,MAAM;GACrC;GAEA,IAAI,QAAQ,cAAc,UAAU,0BAA0B;EAChE,SAAS,OAAO;GACd,IAAI,KAAK,kBAAkB,SAAS,KAAK;GACzC,MAAM;EACR;CACF;CAEA,IAAI,WAAW,UAAU;EACvB,MAAM,SAAS,MAAM,WAAW,SAAS,SAAS,QAAQ;EAG1D,IAAI,QAAQ;GAEV,IAAI,CAAC,SAAS,YACZ,SAAS,
|
|
1
|
+
{"version":3,"file":"validateAll.mjs","names":["config"],"sources":["../../../../../../../@warlock.js/core/src/validation/validateAll.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { merge } from \"@mongez/reinforcements\";\nimport { log } from \"@warlock.js/logger\";\nimport { v } from \"@warlock.js/seal\";\nimport type { Request, Response } from \"../http\";\nimport type { RequestHandlerValidation, Route } from \"../router\";\n\nfunction resolveDataToParse(validating: RequestHandlerValidation[\"validating\"], request: Request) {\n if (!validating || validating.length === 0) return request.allExceptParams();\n\n let data: any = {};\n\n for (const validatingType of validating) {\n if (validatingType === \"body\") {\n data = merge(data, request.body);\n }\n\n if (validatingType === \"query\") {\n data = merge(data, request.query);\n }\n\n if (validatingType === \"params\") {\n data = merge(data, request.params);\n }\n\n if (validatingType === \"headers\") {\n data = merge(data, request.headers);\n }\n }\n\n return data;\n}\n\n/**\n * Validate the request route\n */\nexport async function validateAll(\n validation: Route[\"handler\"][\"validation\"],\n request: Request,\n response: Response,\n) {\n if (!validation) return;\n\n log.info(\"validation\", \"started\", \"Start validating the request\");\n\n if (validation.schema) {\n log.info(\"validation\", \"schema\", \"Validating request schema\");\n try {\n const data = resolveDataToParse(validation.validating, request);\n const result = await v.validate(validation.schema, data);\n\n if (result.data && result.isValid) {\n request.setValidatedData(result.data);\n }\n\n if (!result.isValid) {\n log.warn(\"validation\", \"schema\", \"Schema Validation failed\");\n return response.failedSchema(result);\n }\n\n log.success(\"validation\", \"schema\", \"Schema Validation passed\");\n } catch (error) {\n log.warn(\"app.validation\", \"error\", error);\n throw error;\n }\n }\n\n if (validation.validate) {\n const result = await validation.validate(request, response);\n\n // if there is a result, it means it failed\n if (result) {\n // check if there is no response status code, then set it to config value or 400 as default\n if (!response.statusCode) {\n response.setStatusCode(config.get(\"validation.responseStatus\", 400));\n }\n\n log.info(\"validation\", \"failed\", \"Validation failed\");\n\n return result;\n }\n\n log.info(\"validation\", \"passed\", \"Validation passed\");\n }\n}\n"],"mappings":";;;;;;AAOA,SAAS,mBAAmB,YAAoD,SAAkB;CAChG,IAAI,CAAC,cAAc,WAAW,WAAW,GAAG,OAAO,QAAQ,gBAAgB;CAE3E,IAAI,OAAY,CAAC;CAEjB,KAAK,MAAM,kBAAkB,YAAY;EACvC,IAAI,mBAAmB,QACrB,OAAO,MAAM,MAAM,QAAQ,IAAI;EAGjC,IAAI,mBAAmB,SACrB,OAAO,MAAM,MAAM,QAAQ,KAAK;EAGlC,IAAI,mBAAmB,UACrB,OAAO,MAAM,MAAM,QAAQ,MAAM;EAGnC,IAAI,mBAAmB,WACrB,OAAO,MAAM,MAAM,QAAQ,OAAO;CAEtC;CAEA,OAAO;AACT;;;;AAKA,eAAsB,YACpB,YACA,SACA,UACA;CACA,IAAI,CAAC,YAAY;CAEjB,IAAI,KAAK,cAAc,WAAW,8BAA8B;CAEhE,IAAI,WAAW,QAAQ;EACrB,IAAI,KAAK,cAAc,UAAU,2BAA2B;EAC5D,IAAI;GACF,MAAM,OAAO,mBAAmB,WAAW,YAAY,OAAO;GAC9D,MAAM,SAAS,MAAM,EAAE,SAAS,WAAW,QAAQ,IAAI;GAEvD,IAAI,OAAO,QAAQ,OAAO,SACxB,QAAQ,iBAAiB,OAAO,IAAI;GAGtC,IAAI,CAAC,OAAO,SAAS;IACnB,IAAI,KAAK,cAAc,UAAU,0BAA0B;IAC3D,OAAO,SAAS,aAAa,MAAM;GACrC;GAEA,IAAI,QAAQ,cAAc,UAAU,0BAA0B;EAChE,SAAS,OAAO;GACd,IAAI,KAAK,kBAAkB,SAAS,KAAK;GACzC,MAAM;EACR;CACF;CAEA,IAAI,WAAW,UAAU;EACvB,MAAM,SAAS,MAAM,WAAW,SAAS,SAAS,QAAQ;EAG1D,IAAI,QAAQ;GAEV,IAAI,CAAC,SAAS,YACZ,SAAS,cAAcA,WAAO,IAAI,6BAA6B,GAAG,CAAC;GAGrE,IAAI,KAAK,cAAc,UAAU,mBAAmB;GAEpD,OAAO;EACT;EAEA,IAAI,KAAK,cAAc,UAAU,mBAAmB;CACtD;AACF"}
|
package/llms-full.txt
CHANGED
|
@@ -79,8 +79,13 @@ Lower number = earlier. The built-in ordering, from `ConnectorPriority` in `@war
|
|
|
79
79
|
| `http` | 5 | **Late**|
|
|
80
80
|
| `storage` | 6 | Early |
|
|
81
81
|
| `socket` | 7 | **Late**|
|
|
82
|
+
| `notifications`| 8 | Early |
|
|
83
|
+
| `access` | 9 | Early |
|
|
84
|
+
| `ai` | 10 | Early |
|
|
82
85
|
|
|
83
|
-
Pick a number that places your connector where it belongs. If your queue needs the database, set `priority > 2` (e.g. `
|
|
86
|
+
Pick a number that places your connector where it belongs. If your queue needs the database, set `priority > 2` (e.g. `11`). If you replace the cache, set `< 4` to win.
|
|
87
|
+
|
|
88
|
+
> **Built-in `AiConnector` (priority `ConnectorPriority.AI = 10`, Early).** A reference example of a config-driven, lazy-import connector: it reads the ejected `src/config/ai.ts` and applies it via `ai.config(...)`, lazy-importing `@warlock.js/ai` only when the config is present (so core carries no hard dependency). The config file (ejected by `warlock add ai`) holds an auto-managed `// >>> warlock:ai-packages` import block where the `ai-tools` / `ai-panoptic` / `ai-workspace` satellite features link their side-effect imports. See `src/connectors/ai-connector.ts`.
|
|
84
89
|
|
|
85
90
|
Negative priorities are fine for "start before everything" — the project's `src/connectors/custom-connector.ts` example uses `priority: -10`.
|
|
86
91
|
|
|
@@ -1085,6 +1090,29 @@ That's the contract. Filename → config key. No registration, no manifest, no s
|
|
|
1085
1090
|
|
|
1086
1091
|
Some subsystems need to do extra work when their config loads (e.g. set the active locale, register a driver). Those have a special handler attached internally — for the most part you don't see them. The takeaway: changing a config file at dev time fires the handler again automatically.
|
|
1087
1092
|
|
|
1093
|
+
## The `config/ai.ts` eject + auto-import block
|
|
1094
|
+
|
|
1095
|
+
`warlock add ai` ejects `src/config/ai.ts` — a declarative `Partial<AIConfig>` default export applied on boot by the `ai` connector (`ai.config(...)`), the same special-handler pattern as above. Two things make it unusual:
|
|
1096
|
+
|
|
1097
|
+
1. **An auto-managed import block at the top.** The ejected file opens with a marker pair:
|
|
1098
|
+
|
|
1099
|
+
```ts title="src/config/ai.ts"
|
|
1100
|
+
import type { AIConfig } from "@warlock.js/ai";
|
|
1101
|
+
|
|
1102
|
+
// >>> warlock:ai-packages (auto-managed) >>>
|
|
1103
|
+
// <<< warlock:ai-packages <<<
|
|
1104
|
+
|
|
1105
|
+
const ai: Partial<AIConfig> = {
|
|
1106
|
+
// defaultStore, panoptic, …
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
export default ai;
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
2. **Satellite features link side-effect imports into that block.** `warlock add ai-tools | ai-panoptic | ai-workspace` inserts e.g. `import "@warlock.js/ai-workspace";` right after the marker (idempotent — re-running is a no-op). Those side-effect imports register the satellites' surface on the `ai` object (`ai.tools` / `ai.mcp`, `ai.workspace`, panoptic's wiring) **before** the connector applies the config, so a single `ai.config(...)` call sees the full augmented surface. Keep the marker block and don't hand-reorder it.
|
|
1113
|
+
|
|
1114
|
+
The five provider features (`ai-openai`, `ai-google`, `ai-anthropic`, `ai-bedrock`, `ai-ollama`) only add their package — they don't touch `config/ai.ts`; you wire a provider's model in your agent code.
|
|
1115
|
+
|
|
1088
1116
|
## Multi-file or conditional config
|
|
1089
1117
|
|
|
1090
1118
|
A config file is just a TS module. Branch on `env(...)` if production should differ from development:
|
|
@@ -2292,6 +2320,108 @@ There is no `warlock add` feature for password hashing — `bcryptjs` is a plain
|
|
|
2292
2320
|
- [`warlock-conventions/SKILL.md`](../warlock-conventions/SKILL.md) — service layering, where the password boundary should sit.
|
|
2293
2321
|
|
|
2294
2322
|
|
|
2323
|
+
## health-checks `@warlock.js/core/health-checks/SKILL.md`
|
|
2324
|
+
|
|
2325
|
+
---
|
|
2326
|
+
name: health-checks
|
|
2327
|
+
description: 'Built-in liveness (`/health`) and readiness (`/ready`) endpoints plus graceful HTTP request draining for zero-downtime deploys — the `health` registry (`health.addCheck`/`removeCheck`), the `http.health.*` and `http.gracefulShutdown.*` config, and how readiness ties into `Application.isShuttingDown`. Triggers: `health`, `health.addCheck`, `health.removeCheck`, `HealthCheck`, `/health`, `/ready`, `http.health`, `http.gracefulShutdown`, `forceCloseConnections`, "liveness probe", "readiness probe", "graceful shutdown", "drain in-flight requests", "zero-downtime deploy", "kubernetes health check", "503 until ready"; typical import `import { health } from "@warlock.js/core"`. Skip: the `Application.onShutdown` / `onceBooted` lifecycle hooks — `@warlock.js/core/use-app-context/SKILL.md`; maintenance-mode 503s — `@warlock.js/core/use-middleware/SKILL.md`; connector lifecycle — `@warlock.js/core/add-connector/SKILL.md`; competing libs `@fastify/under-pressure`, `terminus`, hand-rolled `/health` controllers.'
|
|
2328
|
+
---
|
|
2329
|
+
|
|
2330
|
+
# Warlock — health checks & graceful shutdown
|
|
2331
|
+
|
|
2332
|
+
Two endpoints and a drain, so a load balancer never routes to an instance that isn't ready and a deploy never kills an in-flight request. All built in; no controller to hand-roll.
|
|
2333
|
+
|
|
2334
|
+
## The two endpoints
|
|
2335
|
+
|
|
2336
|
+
The HTTP connector registers them on the Fastify server during boot (before route scanning), so they exist by the time the server listens:
|
|
2337
|
+
|
|
2338
|
+
| Path | Probe | 200 when | 503 when |
|
|
2339
|
+
| --- | --- | --- | --- |
|
|
2340
|
+
| `/health` | liveness | the process is up | shutdown has begun |
|
|
2341
|
+
| `/ready` | readiness | booted **and** not shutting down **and** every check passes | before boot, during shutdown, or any failing check |
|
|
2342
|
+
|
|
2343
|
+
**Liveness** answers "should the orchestrator RESTART me?" — it ignores dependency checks (a failing DB doesn't mean restart the pod). **Readiness** answers "should the load balancer ROUTE to me?" — it gates on boot completion, shutdown state, and your registered checks.
|
|
2344
|
+
|
|
2345
|
+
```
|
|
2346
|
+
GET /health → 200 {"status":"ok"}
|
|
2347
|
+
GET /ready → 200 {"status":"ok","checks":{"db":true}}
|
|
2348
|
+
→ 503 {"status":"error","checks":{"db":false}}
|
|
2349
|
+
```
|
|
2350
|
+
|
|
2351
|
+
### Config
|
|
2352
|
+
|
|
2353
|
+
```ts title="src/config/http.ts"
|
|
2354
|
+
const httpConfigurations: HttpConfigurations = {
|
|
2355
|
+
health: {
|
|
2356
|
+
enabled: true, // default; set false to remove both endpoints
|
|
2357
|
+
path: "/health", // liveness path
|
|
2358
|
+
readinessPath: "/ready", // readiness path
|
|
2359
|
+
},
|
|
2360
|
+
};
|
|
2361
|
+
```
|
|
2362
|
+
|
|
2363
|
+
## Readiness checks
|
|
2364
|
+
|
|
2365
|
+
Readiness is `isBooted && !isShuttingDown` plus every registered check. Register a check from a connector, a `main.ts`, or anywhere:
|
|
2366
|
+
|
|
2367
|
+
```ts
|
|
2368
|
+
import { health } from "@warlock.js/core";
|
|
2369
|
+
|
|
2370
|
+
health.addCheck("db", async () => {
|
|
2371
|
+
return database.isConnected();
|
|
2372
|
+
});
|
|
2373
|
+
|
|
2374
|
+
health.removeCheck("db"); // unregister later if needed
|
|
2375
|
+
```
|
|
2376
|
+
|
|
2377
|
+
A check returns `boolean | Promise<boolean>`. **A thrown error counts as a failed check** (it's surfaced in the `checks` map + the 503, not logged — probes poll often, so a failure is a normal signal, not an error event). Keep checks cheap and fast; they run on every `/ready` poll.
|
|
2378
|
+
|
|
2379
|
+
## Graceful shutdown (request draining)
|
|
2380
|
+
|
|
2381
|
+
On SIGINT/SIGTERM the framework tears down in order: **app `onShutdown` hooks → connectors in reverse priority**. The HTTP connector's teardown drains instead of dropping:
|
|
2382
|
+
|
|
2383
|
+
1. `Application.isShuttingDown` flips `true` at the very start → `/ready` immediately returns 503, so the load balancer stops sending new traffic.
|
|
2384
|
+
2. Fastify stops accepting new requests (answers 503 while closing) and lets in-flight ones finish.
|
|
2385
|
+
3. Draining is bounded by a timeout so one stuck request can't hang the deploy — after it, the server force-closes and a warning is logged.
|
|
2386
|
+
|
|
2387
|
+
```ts title="src/config/http.ts"
|
|
2388
|
+
const httpConfigurations: HttpConfigurations = {
|
|
2389
|
+
gracefulShutdown: {
|
|
2390
|
+
timeout: 10_000, // ms to wait for in-flight drain (default 10s)
|
|
2391
|
+
forceCloseConnections: "idle", // close idle keep-alives, let active finish (default)
|
|
2392
|
+
},
|
|
2393
|
+
};
|
|
2394
|
+
```
|
|
2395
|
+
|
|
2396
|
+
`forceCloseConnections`: `"idle"` (default) closes idle keep-alive connections and lets active requests finish; `true` force-closes everything immediately; `false` waits for every connection.
|
|
2397
|
+
|
|
2398
|
+
## The zero-downtime deploy flow
|
|
2399
|
+
|
|
2400
|
+
```
|
|
2401
|
+
SIGTERM → isShuttingDown = true → /ready returns 503
|
|
2402
|
+
→ LB stops routing new requests to this instance
|
|
2403
|
+
→ in-flight requests drain (up to gracefulShutdown.timeout)
|
|
2404
|
+
→ app onShutdown hooks already ran (db/cache still up)
|
|
2405
|
+
→ connectors close in reverse → process exits
|
|
2406
|
+
```
|
|
2407
|
+
|
|
2408
|
+
For an even smoother handoff, give the load balancer time to observe the 503 before the server closes — e.g. an `onShutdown` hook with a short `sleep` matched to your LB's health-check interval.
|
|
2409
|
+
|
|
2410
|
+
## Gotchas
|
|
2411
|
+
|
|
2412
|
+
- **`/health` is registered straight on Fastify, not the app router.** It's infra, so it's immune to HMR and route scanning — but if your app also defines a `/health` route you'll have a collision. Rename via `http.health.path`.
|
|
2413
|
+
- **Readiness needs a finished boot.** Before `Application.isBooted` (e.g. while late-phase connectors are still starting) `/ready` is 503 by design — that's the point.
|
|
2414
|
+
- **A hanging `onShutdown` hook delays the drain.** App hooks run before connector teardown and are only bounded by your process manager's kill timeout; keep them fast. The HTTP drain itself is bounded by `gracefulShutdown.timeout`.
|
|
2415
|
+
- **The `maintenance` middleware is a different 503.** It allowlists `/health` by default so probes pass during maintenance — but maintenance mode is operator-toggled downtime, not readiness. See `@warlock.js/core/use-middleware/SKILL.md`.
|
|
2416
|
+
|
|
2417
|
+
## See also
|
|
2418
|
+
|
|
2419
|
+
- [`use-app-context/SKILL.md`](../use-app-context/SKILL.md) — `Application.onShutdown` / `onceBooted` / `isShuttingDown`, the lifecycle hooks the endpoints build on.
|
|
2420
|
+
- [`configure-app/SKILL.md`](../configure-app/SKILL.md) — the `src/config/http.ts` shape.
|
|
2421
|
+
- [`add-connector/SKILL.md`](../add-connector/SKILL.md) — connector boot/shutdown order, where draining slots in.
|
|
2422
|
+
- [`use-middleware/SKILL.md`](../use-middleware/SKILL.md) — maintenance mode and other built-in middleware.
|
|
2423
|
+
|
|
2424
|
+
|
|
2295
2425
|
## lower-stage3-decorators `@warlock.js/core/lower-stage3-decorators/SKILL.md`
|
|
2296
2426
|
|
|
2297
2427
|
---
|
|
@@ -5179,7 +5309,7 @@ The reverse direction — sending a stored file back via `response.sendFile(...)
|
|
|
5179
5309
|
|
|
5180
5310
|
---
|
|
5181
5311
|
name: use-app-context
|
|
5182
|
-
description: 'Read app-wide context — the `Application` static class (env, version, uptime, runtime strategy) plus the `app` runtime accessor (live Fastify, socket.io, router, database via the DI container). Triggers: `Application.isProduction`, `Application.environment`, `Application.runtimeStrategy`, `Application.uptime`, `Application.version`, `app.http`, `app.socket`, `app.database`, `app.router`; "branch on environment", "reach the live Fastify instance", "framework version in health endpoint", "dev vs production runtime check"; typical import `import { Application, app } from "@warlock.js/core"`. Skip: path helpers — `@warlock.js/core/resolve-path/SKILL.md`; connector start order — `@warlock.js/core/add-connector/SKILL.md`; competing patterns: bare `process.env.NODE_ENV`, ad-hoc Fastify imports.'
|
|
5312
|
+
description: 'Read app-wide context — the `Application` static class (env, version, uptime, runtime strategy, boot lifecycle) plus the `app` runtime accessor (live Fastify, socket.io, router, database via the DI container). Triggers: `Application.isProduction`, `Application.environment`, `Application.runtimeStrategy`, `Application.uptime`, `Application.version`, `Application.onceBooted`, `Application.whenBooted`, `Application.isBooted`, `Application.onShutdown`, `Application.isShuttingDown`, `app.http`, `app.socket`, `app.database`, `app.router`; "branch on environment", "reach the live Fastify instance", "framework version in health endpoint", "dev vs production runtime check", "run code once the app is fully booted", "after all connectors started", "app booted hook", "run cleanup before shutdown", "graceful shutdown hook"; typical import `import { Application, app } from "@warlock.js/core"`. Skip: path helpers — `@warlock.js/core/resolve-path/SKILL.md`; connector start order — `@warlock.js/core/add-connector/SKILL.md`; competing patterns: bare `process.env.NODE_ENV`, ad-hoc Fastify imports.'
|
|
5183
5313
|
---
|
|
5184
5314
|
|
|
5185
5315
|
# Warlock — use the application context
|
|
@@ -5254,6 +5384,64 @@ The dev-server CLI command sets it to `"development"`. The `build` command and `
|
|
|
5254
5384
|
|
|
5255
5385
|
Most app code shouldn't care about `runtimeStrategy` — branch on `environment` instead, which is the orthogonal "what world is this code talking to?" axis.
|
|
5256
5386
|
|
|
5387
|
+
## Lifecycle: boot & shutdown
|
|
5388
|
+
|
|
5389
|
+
`Application.onceBooted(callback)` runs a callback the moment the app is fully booted — every connector in **both** phases is active and all app files (locales, events, main, routes) are loaded. It's the only hook that fires *after* the late phase (http, socket) is up.
|
|
5390
|
+
|
|
5391
|
+
```ts
|
|
5392
|
+
import { Application } from "@warlock.js/core";
|
|
5393
|
+
|
|
5394
|
+
Application.onceBooted(({ environment, runtimeStrategy, bootDurationMs }) => {
|
|
5395
|
+
// http is listening, socket is bound, every model is registered
|
|
5396
|
+
});
|
|
5397
|
+
```
|
|
5398
|
+
|
|
5399
|
+
Why a dedicated hook instead of code at the bottom of `main.ts`? **App files load before the late phase.** `main.ts`, `events.ts`, `routes.ts`, and locales are all imported *between* the early and late connector phases — so when `main.ts` runs, http/socket are not listening yet. `onceBooted` defers your callback until the whole sequence finishes, which makes it the safe place to touch `app.http` / `app.socket` from `main.ts`-level code.
|
|
5400
|
+
|
|
5401
|
+
It's a **latch**, not a plain event listener: register before boot and it queues; register *after* boot and it fires on the next microtask. A late subscriber never silently misses the signal.
|
|
5402
|
+
|
|
5403
|
+
```ts
|
|
5404
|
+
Application.isBooted; // boolean — has boot finished?
|
|
5405
|
+
await Application.whenBooted(); // Promise<BootContext> — await instead of a callback
|
|
5406
|
+
```
|
|
5407
|
+
|
|
5408
|
+
`whenBooted()` is the promise form, resolving with the same `BootContext` (`{ environment, runtimeStrategy, bootDurationMs? }`). `bootDurationMs` is set by the dev server (which times boot) and omitted by the production entry.
|
|
5409
|
+
|
|
5410
|
+
The framework fires the latch for you — the dev server and the production bundle each call it once, right after the late phase. App code only ever *reads* it via `onceBooted` / `whenBooted` / `isBooted`; the internal `markBooted` is a framework entry point, not for application use.
|
|
5411
|
+
|
|
5412
|
+
### Run something once everything is listening
|
|
5413
|
+
|
|
5414
|
+
```ts title="src/app/main.ts"
|
|
5415
|
+
import { Application } from "@warlock.js/core";
|
|
5416
|
+
import { log } from "@warlock.js/logger";
|
|
5417
|
+
|
|
5418
|
+
Application.onceBooted(({ environment, bootDurationMs }) => {
|
|
5419
|
+
log.success("app", "booted", `ready in ${environment}`, { bootDurationMs });
|
|
5420
|
+
});
|
|
5421
|
+
```
|
|
5422
|
+
|
|
5423
|
+
This is the right home for "warm a cache", "register a recurring job", "ping a readiness endpoint", or "open an outbound connection that needs the http server already listening" — anything that must wait for a complete boot.
|
|
5424
|
+
|
|
5425
|
+
### Shutdown — clean up before the app goes down
|
|
5426
|
+
|
|
5427
|
+
`Application.onShutdown(callback)` is the mirror of `onceBooted`: it runs your teardown **once**, when the process is shutting down (SIGINT/SIGTERM, or the dev server stopping) — and crucially **before** the connectors (db, cache, http) are torn down, so your cleanup can still use them.
|
|
5428
|
+
|
|
5429
|
+
```ts title="src/app/main.ts"
|
|
5430
|
+
import { Application } from "@warlock.js/core";
|
|
5431
|
+
|
|
5432
|
+
Application.onceBooted(() => {
|
|
5433
|
+
const consumer = startQueueConsumer();
|
|
5434
|
+
|
|
5435
|
+
Application.onShutdown(async () => {
|
|
5436
|
+
await consumer.stop(); // db / cache / http are still up here
|
|
5437
|
+
});
|
|
5438
|
+
});
|
|
5439
|
+
```
|
|
5440
|
+
|
|
5441
|
+
Hooks run **LIFO** (reverse of registration — last opened, first closed), each is awaited, and a throwing hook is caught + logged so it can't block the rest. `Application.isShuttingDown` flips `true` the moment shutdown begins — the built-in `/ready` endpoint reads it to report not-ready so a load balancer drains the instance first. Like `onceBooted`, registering after shutdown has begun runs the callback immediately.
|
|
5442
|
+
|
|
5443
|
+
The framework triggers this for you (the connectors manager runs the hooks at the start of shutdown); app code only ever registers via `onShutdown`. For the HTTP-side story — `/health`, `/ready`, and graceful request draining — see `@warlock.js/core/health-checks/SKILL.md`.
|
|
5444
|
+
|
|
5257
5445
|
## Paths
|
|
5258
5446
|
|
|
5259
5447
|
For path helpers (`appPath`, `configPath`, `uploadsPath`, …) anchored at `process.cwd()`, the `paths.*` aggregate, and the `uploads.root` config override, see [`resolve-path/SKILL.md`](../resolve-path/SKILL.md).
|
|
@@ -5409,7 +5597,9 @@ cors: {
|
|
|
5409
5597
|
|
|
5410
5598
|
- **`version` is `null` until the first `await`.** The version loader is async (it reads `package.json`). On a cold start before any framework code has run `getWarlockVersion()`, `Application.version` returns `null`. The framework does load it during bootstrap, so anywhere downstream of bootstrap is fine — controllers, services, connectors after `start()`. CLI commands without `preload.bootstrap` may see `null`.
|
|
5411
5599
|
- **`Application` is static, not a DI registration.** Don't try to inject it. There's nothing to inject — it's a class with only static members.
|
|
5412
|
-
- **`app.*` accessors return `undefined` before their connector boots — they don't throw.** `app.socket` / `app.database` / `app.http` are populated by their respective connectors during boot; until then each getter returns `undefined` (a bare `container.get(...)`). Reading them earlier (eager module-load code, the top level of a `main.ts` for the late-phase `http`/`socket`, certain CLI commands without the right `preload.connectors`) hands you `undefined`, and chaining off it throws. Safe everywhere downstream of bootstrap.
|
|
5600
|
+
- **`app.*` accessors return `undefined` before their connector boots — they don't throw.** `app.socket` / `app.database` / `app.http` are populated by their respective connectors during boot; until then each getter returns `undefined` (a bare `container.get(...)`). Reading them earlier (eager module-load code, the top level of a `main.ts` for the late-phase `http`/`socket`, certain CLI commands without the right `preload.connectors`) hands you `undefined`, and chaining off it throws. Safe everywhere downstream of bootstrap — including inside `Application.onceBooted(...)`.
|
|
5601
|
+
- **`onceBooted` is a latch, not `events.on`.** A callback registered *after* boot completed still runs (next microtask) instead of silently missing the signal — so register it wherever it reads best, including module top-level in `main.ts`. A listener that throws is caught and logged; it can't break boot or the other listeners.
|
|
5602
|
+
- **`onShutdown` runs before connectors close, not after.** That ordering is deliberate so cleanup can still use db/cache/http — but it means a hook that hangs delays connector teardown (bounded only by your process manager's kill timeout). Keep teardown fast; for HTTP draining the framework already bounds it via `http.gracefulShutdown.timeout`.
|
|
5413
5603
|
|
|
5414
5604
|
## See also
|
|
5415
5605
|
|
package/llms.txt
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- [define-resource](@warlock.js/core/define-resource/SKILL.md): Map model fields to wire-shape via `defineResource()` or `Resource` subclasses. Output-only — never put business logic, hydration, or reconciliation in a resource. Triggers: `defineResource`, `Resource`, `RegisterResource`, `toJSON`, `"self"`, `"localized"`, `"uploadsUrl"`; "shape an API response", "nest related resources", "rename a field on output", "self-referential tree resource"; typical import `import { defineResource } from "@warlock.js/core"`. Skip: localized columns — `@warlock.js/core/use-localization/SKILL.md`; URL casting — `@warlock.js/core/build-url/SKILL.md`; controller side — `@warlock.js/core/create-controller/SKILL.md`; competing libs `@nestjs/swagger` `@ApiProperty`, `class-transformer`, hand-rolled DTO mappers.
|
|
17
17
|
- [encrypt-data](@warlock.js/core/encrypt-data/SKILL.md): Reversible AES-256-GCM `encrypt` / `decrypt` for secrets you need to read back; one-way HMAC-SHA256 `hmacHash` for deterministic fingerprints (lookup/dedup of encrypted columns). Keys come from `src/config/encryption.ts`. Triggers: `encrypt`, `decrypt`, `hmacHash`, `EncryptionConfigurations`, `APP_ENCRYPTION_KEY`, `APP_HMAC_KEY`; "store an API key reversibly", "fingerprint an encrypted column for lookup", "AES-256-GCM secret", "HMAC-SHA256 dedup key"; typical import `import { encrypt, decrypt, hmacHash } from "@warlock.js/core"`. Skip: password hashing — `@warlock.js/core/hash-password/SKILL.md`; config wiring — `@warlock.js/core/configure-app/SKILL.md`; competing libs Node `crypto` direct, `crypto-js`, `libsodium-wrappers`.
|
|
18
18
|
- [hash-password](@warlock.js/core/hash-password/SKILL.md): One-way bcrypt password hashing — `hashPassword` / `verifyPassword`, plus the declarative `useHashedPassword()` schema transformer that auto-hashes a model's password field on save. Salt rounds come from `src/config/encryption.ts`. Triggers: `hashPassword`, `verifyPassword`, `useHashedPassword`, `password.salt`, `bcryptjs`; "hash a user password", "verify login credentials", "auto-hash on save", "rotate a password"; typical import `import { hashPassword, verifyPassword } from "@warlock.js/core"`. Skip: reversible secrets — `@warlock.js/core/encrypt-data/SKILL.md`; the other transformers — `@warlock.js/core/use-model-transformers/SKILL.md`; config wiring — `@warlock.js/core/configure-app/SKILL.md`; competing libs `bcrypt` native, `argon2`, `scrypt`.
|
|
19
|
+
- [health-checks](@warlock.js/core/health-checks/SKILL.md): Built-in liveness (`/health`) and readiness (`/ready`) endpoints plus graceful HTTP request draining for zero-downtime deploys — the `health` registry (`health.addCheck`/`removeCheck`), the `http.health.*` and `http.gracefulShutdown.*` config, and how readiness ties into `Application.isShuttingDown`. Triggers: `health`, `health.addCheck`, `health.removeCheck`, `HealthCheck`, `/health`, `/ready`, `http.health`, `http.gracefulShutdown`, `forceCloseConnections`, "liveness probe", "readiness probe", "graceful shutdown", "drain in-flight requests", "zero-downtime deploy", "kubernetes health check", "503 until ready"; typical import `import { health } from "@warlock.js/core"`. Skip: the `Application.onShutdown` / `onceBooted` lifecycle hooks — `@warlock.js/core/use-app-context/SKILL.md`; maintenance-mode 503s — `@warlock.js/core/use-middleware/SKILL.md`; connector lifecycle — `@warlock.js/core/add-connector/SKILL.md`; competing libs `@fastify/under-pressure`, `terminus`, hand-rolled `/health` controllers.
|
|
19
20
|
- [lower-stage3-decorators](@warlock.js/core/lower-stage3-decorators/SKILL.md): Vite/Vitest plugin `lowerStage3Decorators()` that lowers TC39 Stage-3 (native) decorators with esbuild before oxc / the SSR rewrite mangles them — so `@RegisterModel`-decorated Cascade models load under Vitest 4 / Vite 8. Triggers: `lowerStage3Decorators`, "SyntaxError: Invalid or unexpected token" on a decorated class, "@(0, __vite_ssr_import__.X)()", "decorator crashes vitest", "models won't load in tests", "Vite 8 oxc decorators"; typical import `import { lowerStage3Decorators } from "@warlock.js/core"` in `vite.config.ts` / `vitest.config.ts`. Skip: writing the tests themselves — `@warlock.js/core/test-service/SKILL.md` / `@warlock.js/core/test-http/SKILL.md`; runtime migrations — `@warlock.js/cascade/write-migration/SKILL.md`.
|
|
20
21
|
- [process-image](@warlock.js/core/process-image/SKILL.md): Transform images with the `Image` class — resize, crop, rotate, format, quality, watermark, blur, etc. — using a deferred pipeline that runs only at `save()` / `toBuffer()` / `toBase64()` / `toDataUrl()` time. Requires sharp via `warlock add image`. Triggers: `Image`, `Image.fromFile`, `Image.fromBuffer`, `Image.fromUrl`, `.resize`, `.crop`, `.watermark`, `.toBuffer`, `.toDataUrl`, `.apply`; "resize an image", "generate a thumbnail", "watermark a product photo", "build an image pipeline"; typical import `import { Image } from "@warlock.js/core"`. Skip: multipart upload entry — `@warlock.js/core/upload-file/SKILL.md`; storage persistence — `@warlock.js/core/store-file/SKILL.md`; competing libs `sharp` direct, `jimp`, `imagemagick`, `gm`.
|
|
21
22
|
- [register-route](@warlock.js/core/register-route/SKILL.md): Register HTTP routes via @warlock.js/core's router — single routes, prefix groups, middleware-guarded blocks, and RESTful resource chains. Routes always live in `src/app/<module>/routes.ts`. Triggers: `router.get`, `router.post`, `router.prefix`, `router.group`, `router.route`, `guarded`; "add a route", "wire a controller to a URL", "group routes by prefix", "register a RESTful resource"; typical import `import { router } from "@warlock.js/core"`. Skip: handler shape — `@warlock.js/core/create-controller/SKILL.md`; CRUD chain details — `@warlock.js/core/build-restful/SKILL.md`; middleware authoring — `@warlock.js/core/write-middleware/SKILL.md`; competing libs `express`, `fastify`, `koa`, `@nestjs/common`.
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
- [test-service](@warlock.js/core/test-service/SKILL.md): Pure unit tests against services, repositories, models, and use-cases — `setupTest({ connectors })` bootstraps each Vitest worker with its own DB/cache connections so you can call your code directly. Triggers: `setupTest`, `src/test-setup.ts`, `tests.connectors`, `Application.setEnvironment`; "unit-test a service", "test a repository query", "vitest setupFiles", "skip connectors for pure-logic tests"; typical import `import { setupTest } from "@warlock.js/core"`. Skip: HTTP integration — `@warlock.js/core/test-http/SKILL.md`; warlock add test scaffold — `@warlock.js/core/write-cli-command/SKILL.md`; competing tooling: jest direct, `supertest`, `nock`.
|
|
30
31
|
- [update-packages](@warlock.js/core/update-packages/SKILL.md): Keep a project current with `warlock update` — bump every `@warlock.js/*` dependency in package.json to its latest published version (range operator preserved), then run the lockfile-detected package manager install. Also covers the `warlock dev` update notice and the `devServer.checkForUpdates` toggle. Triggers: `warlock update`, `--no-install`, `checkForUpdates`, `fetchLatestVersion`, `isNewerVersion`; "update warlock packages", "upgrade the framework", "is there a new warlock version", "update notice in the dev server", "bump @warlock.js/* to latest"; typical CLI `warlock update`. Skip: dev/build/start runtime — `@warlock.js/core/run-app/SKILL.md`; writing a custom command — `@warlock.js/core/write-cli-command/SKILL.md`; installing a NEW feature package (auth, mail, storage) — that is `warlock add`; releasing/publishing the framework — workspace release tooling, not this command.
|
|
31
32
|
- [upload-file](@warlock.js/core/upload-file/SKILL.md): Handle multipart file uploads — read via `request.file()` or `request.validated()`, validate with `v.file()`, save via `UploadedFile.save()` or the storage layer, transform images inline. Triggers: `UploadedFile`, `request.file`, `v.file`, `.save`, `.saveAs`, `.resize`, `.format`, `.quality`, `.image`, `.mimeType`, `.maxSize`; "accept a file upload", "validate file size and mime", "save to S3 or local disk", "resize an uploaded image on save"; typical import `import type { UploadedFile, RequestHandler } from "@warlock.js/core"`. Skip: storage drivers + presigned URLs — `@warlock.js/core/store-file/SKILL.md`; image-only transforms — `@warlock.js/core/process-image/SKILL.md`; schema rules — `@warlock.js/core/validate-input/SKILL.md`; competing libs `multer`, `formidable`, `busboy`.
|
|
32
|
-
- [use-app-context](@warlock.js/core/use-app-context/SKILL.md): Read app-wide context — the `Application` static class (env, version, uptime, runtime strategy) plus the `app` runtime accessor (live Fastify, socket.io, router, database via the DI container). Triggers: `Application.isProduction`, `Application.environment`, `Application.runtimeStrategy`, `Application.uptime`, `Application.version`, `app.http`, `app.socket`, `app.database`, `app.router`; "branch on environment", "reach the live Fastify instance", "framework version in health endpoint", "dev vs production runtime check"; typical import `import { Application, app } from "@warlock.js/core"`. Skip: path helpers — `@warlock.js/core/resolve-path/SKILL.md`; connector start order — `@warlock.js/core/add-connector/SKILL.md`; competing patterns: bare `process.env.NODE_ENV`, ad-hoc Fastify imports.
|
|
33
|
+
- [use-app-context](@warlock.js/core/use-app-context/SKILL.md): Read app-wide context — the `Application` static class (env, version, uptime, runtime strategy, boot lifecycle) plus the `app` runtime accessor (live Fastify, socket.io, router, database via the DI container). Triggers: `Application.isProduction`, `Application.environment`, `Application.runtimeStrategy`, `Application.uptime`, `Application.version`, `Application.onceBooted`, `Application.whenBooted`, `Application.isBooted`, `Application.onShutdown`, `Application.isShuttingDown`, `app.http`, `app.socket`, `app.database`, `app.router`; "branch on environment", "reach the live Fastify instance", "framework version in health endpoint", "dev vs production runtime check", "run code once the app is fully booted", "after all connectors started", "app booted hook", "run cleanup before shutdown", "graceful shutdown hook"; typical import `import { Application, app } from "@warlock.js/core"`. Skip: path helpers — `@warlock.js/core/resolve-path/SKILL.md`; connector start order — `@warlock.js/core/add-connector/SKILL.md`; competing patterns: bare `process.env.NODE_ENV`, ad-hoc Fastify imports.
|
|
33
34
|
- [use-localization](@warlock.js/core/use-localization/SKILL.md): Multi-locale translations via `groupedTranslations` (declare keys), `t()` / `request.t()` / `request.trans()` (look up), `request.getLocaleCode()` (detect locale from headers/query), `getLocalized` (pick the right value from a localized-array column). Triggers: `groupedTranslations`, `t`, `request.t`, `request.trans`, `request.transFrom`, `request.getLocaleCode`, `request.setLocaleCode`, `getLocalized`; "add a translation key", "resolve a localized error message", "detect request locale", "pick the right per-locale column value"; typical import `import { t, getLocalized } from "@warlock.js/core"`. Skip: resource output — `@warlock.js/core/define-resource/SKILL.md`; module scaffold — `@warlock.js/core/create-module/SKILL.md`; competing libs `i18next`, `react-intl`, raw `@mongez/localization`.
|
|
34
35
|
- [use-middleware](@warlock.js/core/use-middleware/SKILL.md): Attach built-in HTTP middleware to routes via the `middleware` namespace from `@warlock.js/core` — rateLimit, concurrencyLimit, maxBodySize, idempotency, maintenance, ipFilter, cache. Plus `X-Request-Id` correlation, wired automatically. Triggers: `middleware.rateLimit`, `middleware.concurrencyLimit`, `middleware.maxBodySize`, `middleware.idempotency`, `middleware.maintenance`, `middleware.ipFilter`, `middleware.cache`, `X-Request-Id`, `Idempotency-Key`; "add rate limiting", "dedupe writes by idempotency key", "cap concurrent requests", "block IPs", "cache a GET response"; typical import `import { middleware } from "@warlock.js/core"`. Skip: author custom middleware — `@warlock.js/core/write-middleware/SKILL.md`; cache singleton — `@warlock.js/cache/cache-basics/SKILL.md`; competing libs `@fastify/rate-limit` direct, `express-rate-limit`, `helmet`.
|
|
35
36
|
- [use-model-transformers](@warlock.js/core/use-model-transformers/SKILL.md): Three schema-side helpers — `useHashedPassword()` (bcrypt on save) attaches via `.addTransformer(...)`; `useComputedSlug(field?, scope?)` (auto-slug from another field) and `useComputedModel(callback)` (arbitrary computed-on-save value) attach via `v.computed(...)`. Triggers: `useHashedPassword`, `useComputedSlug`, `useComputedModel`, `.addTransformer`, `v.computed`, `ComputedCallback`; "auto-hash a password field", "auto-slug from title on save", "derive a value at write time", "declarative model transformers"; typical import `import { useHashedPassword, useComputedSlug } from "@warlock.js/core"`. Skip: bcrypt setup details — `@warlock.js/core/hash-password/SKILL.md`; repository writes — `@warlock.js/core/use-repository/SKILL.md`; output filtering — `@warlock.js/core/define-resource/SKILL.md`; competing patterns: manual `await hashPassword(input)` in services, ORM lifecycle hooks.
|
package/package.json
CHANGED
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@mongez/slug": "^1.0.7",
|
|
37
37
|
"@mongez/supportive-is": "^2.1.3",
|
|
38
38
|
"@mongez/time-wizard": "^1.0.6",
|
|
39
|
-
"@warlock.js/auth": "4.
|
|
40
|
-
"@warlock.js/cache": "4.
|
|
41
|
-
"@warlock.js/cascade": "4.
|
|
42
|
-
"@warlock.js/context": "4.
|
|
43
|
-
"@warlock.js/logger": "4.
|
|
44
|
-
"@warlock.js/seal": "4.
|
|
45
|
-
"@warlock.js/fs": "4.
|
|
39
|
+
"@warlock.js/auth": "4.5.0",
|
|
40
|
+
"@warlock.js/cache": "4.5.0",
|
|
41
|
+
"@warlock.js/cascade": "4.5.0",
|
|
42
|
+
"@warlock.js/context": "4.5.0",
|
|
43
|
+
"@warlock.js/logger": "4.5.0",
|
|
44
|
+
"@warlock.js/seal": "4.5.0",
|
|
45
|
+
"@warlock.js/fs": "4.5.0",
|
|
46
46
|
"chokidar": "^5.0.0",
|
|
47
47
|
"dayjs": "^1.11.19",
|
|
48
48
|
"es-module-lexer": "^2.0.0",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"react": "^19.2.3",
|
|
69
69
|
"react-dom": "^19.2.3",
|
|
70
70
|
"@react-email/render": "^2.0.5",
|
|
71
|
-
"@warlock.js/herald": "4.
|
|
71
|
+
"@warlock.js/herald": "4.5.0"
|
|
72
72
|
},
|
|
73
73
|
"bin": {
|
|
74
74
|
"warlock": "bin/warlock.js"
|
|
75
75
|
},
|
|
76
|
-
"version": "4.
|
|
76
|
+
"version": "4.5.0",
|
|
77
77
|
"type": "module",
|
|
78
78
|
"main": "./esm/index.mjs",
|
|
79
79
|
"module": "./esm/index.mjs",
|
|
@@ -71,8 +71,13 @@ Lower number = earlier. The built-in ordering, from `ConnectorPriority` in `@war
|
|
|
71
71
|
| `http` | 5 | **Late**|
|
|
72
72
|
| `storage` | 6 | Early |
|
|
73
73
|
| `socket` | 7 | **Late**|
|
|
74
|
+
| `notifications`| 8 | Early |
|
|
75
|
+
| `access` | 9 | Early |
|
|
76
|
+
| `ai` | 10 | Early |
|
|
74
77
|
|
|
75
|
-
Pick a number that places your connector where it belongs. If your queue needs the database, set `priority > 2` (e.g. `
|
|
78
|
+
Pick a number that places your connector where it belongs. If your queue needs the database, set `priority > 2` (e.g. `11`). If you replace the cache, set `< 4` to win.
|
|
79
|
+
|
|
80
|
+
> **Built-in `AiConnector` (priority `ConnectorPriority.AI = 10`, Early).** A reference example of a config-driven, lazy-import connector: it reads the ejected `src/config/ai.ts` and applies it via `ai.config(...)`, lazy-importing `@warlock.js/ai` only when the config is present (so core carries no hard dependency). The config file (ejected by `warlock add ai`) holds an auto-managed `// >>> warlock:ai-packages` import block where the `ai-tools` / `ai-panoptic` / `ai-workspace` satellite features link their side-effect imports. See `src/connectors/ai-connector.ts`.
|
|
76
81
|
|
|
77
82
|
Negative priorities are fine for "start before everything" — the project's `src/connectors/custom-connector.ts` example uses `priority: -10`.
|
|
78
83
|
|
|
@@ -133,6 +133,29 @@ That's the contract. Filename → config key. No registration, no manifest, no s
|
|
|
133
133
|
|
|
134
134
|
Some subsystems need to do extra work when their config loads (e.g. set the active locale, register a driver). Those have a special handler attached internally — for the most part you don't see them. The takeaway: changing a config file at dev time fires the handler again automatically.
|
|
135
135
|
|
|
136
|
+
## The `config/ai.ts` eject + auto-import block
|
|
137
|
+
|
|
138
|
+
`warlock add ai` ejects `src/config/ai.ts` — a declarative `Partial<AIConfig>` default export applied on boot by the `ai` connector (`ai.config(...)`), the same special-handler pattern as above. Two things make it unusual:
|
|
139
|
+
|
|
140
|
+
1. **An auto-managed import block at the top.** The ejected file opens with a marker pair:
|
|
141
|
+
|
|
142
|
+
```ts title="src/config/ai.ts"
|
|
143
|
+
import type { AIConfig } from "@warlock.js/ai";
|
|
144
|
+
|
|
145
|
+
// >>> warlock:ai-packages (auto-managed) >>>
|
|
146
|
+
// <<< warlock:ai-packages <<<
|
|
147
|
+
|
|
148
|
+
const ai: Partial<AIConfig> = {
|
|
149
|
+
// defaultStore, panoptic, …
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export default ai;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
2. **Satellite features link side-effect imports into that block.** `warlock add ai-tools | ai-panoptic | ai-workspace` inserts e.g. `import "@warlock.js/ai-workspace";` right after the marker (idempotent — re-running is a no-op). Those side-effect imports register the satellites' surface on the `ai` object (`ai.tools` / `ai.mcp`, `ai.workspace`, panoptic's wiring) **before** the connector applies the config, so a single `ai.config(...)` call sees the full augmented surface. Keep the marker block and don't hand-reorder it.
|
|
156
|
+
|
|
157
|
+
The five provider features (`ai-openai`, `ai-google`, `ai-anthropic`, `ai-bedrock`, `ai-ollama`) only add their package — they don't touch `config/ai.ts`; you wire a provider's model in your agent code.
|
|
158
|
+
|
|
136
159
|
## Multi-file or conditional config
|
|
137
160
|
|
|
138
161
|
A config file is just a TS module. Branch on `env(...)` if production should differ from development:
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: health-checks
|
|
3
|
+
description: 'Built-in liveness (`/health`) and readiness (`/ready`) endpoints plus graceful HTTP request draining for zero-downtime deploys — the `health` registry (`health.addCheck`/`removeCheck`), the `http.health.*` and `http.gracefulShutdown.*` config, and how readiness ties into `Application.isShuttingDown`. Triggers: `health`, `health.addCheck`, `health.removeCheck`, `HealthCheck`, `/health`, `/ready`, `http.health`, `http.gracefulShutdown`, `forceCloseConnections`, "liveness probe", "readiness probe", "graceful shutdown", "drain in-flight requests", "zero-downtime deploy", "kubernetes health check", "503 until ready"; typical import `import { health } from "@warlock.js/core"`. Skip: the `Application.onShutdown` / `onceBooted` lifecycle hooks — `@warlock.js/core/use-app-context/SKILL.md`; maintenance-mode 503s — `@warlock.js/core/use-middleware/SKILL.md`; connector lifecycle — `@warlock.js/core/add-connector/SKILL.md`; competing libs `@fastify/under-pressure`, `terminus`, hand-rolled `/health` controllers.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Warlock — health checks & graceful shutdown
|
|
7
|
+
|
|
8
|
+
Two endpoints and a drain, so a load balancer never routes to an instance that isn't ready and a deploy never kills an in-flight request. All built in; no controller to hand-roll.
|
|
9
|
+
|
|
10
|
+
## The two endpoints
|
|
11
|
+
|
|
12
|
+
The HTTP connector registers them on the Fastify server during boot (before route scanning), so they exist by the time the server listens:
|
|
13
|
+
|
|
14
|
+
| Path | Probe | 200 when | 503 when |
|
|
15
|
+
| --- | --- | --- | --- |
|
|
16
|
+
| `/health` | liveness | the process is up | shutdown has begun |
|
|
17
|
+
| `/ready` | readiness | booted **and** not shutting down **and** every check passes | before boot, during shutdown, or any failing check |
|
|
18
|
+
|
|
19
|
+
**Liveness** answers "should the orchestrator RESTART me?" — it ignores dependency checks (a failing DB doesn't mean restart the pod). **Readiness** answers "should the load balancer ROUTE to me?" — it gates on boot completion, shutdown state, and your registered checks.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
GET /health → 200 {"status":"ok"}
|
|
23
|
+
GET /ready → 200 {"status":"ok","checks":{"db":true}}
|
|
24
|
+
→ 503 {"status":"error","checks":{"db":false}}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Config
|
|
28
|
+
|
|
29
|
+
```ts title="src/config/http.ts"
|
|
30
|
+
const httpConfigurations: HttpConfigurations = {
|
|
31
|
+
health: {
|
|
32
|
+
enabled: true, // default; set false to remove both endpoints
|
|
33
|
+
path: "/health", // liveness path
|
|
34
|
+
readinessPath: "/ready", // readiness path
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Readiness checks
|
|
40
|
+
|
|
41
|
+
Readiness is `isBooted && !isShuttingDown` plus every registered check. Register a check from a connector, a `main.ts`, or anywhere:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { health } from "@warlock.js/core";
|
|
45
|
+
|
|
46
|
+
health.addCheck("db", async () => {
|
|
47
|
+
return database.isConnected();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
health.removeCheck("db"); // unregister later if needed
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A check returns `boolean | Promise<boolean>`. **A thrown error counts as a failed check** (it's surfaced in the `checks` map + the 503, not logged — probes poll often, so a failure is a normal signal, not an error event). Keep checks cheap and fast; they run on every `/ready` poll.
|
|
54
|
+
|
|
55
|
+
## Graceful shutdown (request draining)
|
|
56
|
+
|
|
57
|
+
On SIGINT/SIGTERM the framework tears down in order: **app `onShutdown` hooks → connectors in reverse priority**. The HTTP connector's teardown drains instead of dropping:
|
|
58
|
+
|
|
59
|
+
1. `Application.isShuttingDown` flips `true` at the very start → `/ready` immediately returns 503, so the load balancer stops sending new traffic.
|
|
60
|
+
2. Fastify stops accepting new requests (answers 503 while closing) and lets in-flight ones finish.
|
|
61
|
+
3. Draining is bounded by a timeout so one stuck request can't hang the deploy — after it, the server force-closes and a warning is logged.
|
|
62
|
+
|
|
63
|
+
```ts title="src/config/http.ts"
|
|
64
|
+
const httpConfigurations: HttpConfigurations = {
|
|
65
|
+
gracefulShutdown: {
|
|
66
|
+
timeout: 10_000, // ms to wait for in-flight drain (default 10s)
|
|
67
|
+
forceCloseConnections: "idle", // close idle keep-alives, let active finish (default)
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`forceCloseConnections`: `"idle"` (default) closes idle keep-alive connections and lets active requests finish; `true` force-closes everything immediately; `false` waits for every connection.
|
|
73
|
+
|
|
74
|
+
## The zero-downtime deploy flow
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
SIGTERM → isShuttingDown = true → /ready returns 503
|
|
78
|
+
→ LB stops routing new requests to this instance
|
|
79
|
+
→ in-flight requests drain (up to gracefulShutdown.timeout)
|
|
80
|
+
→ app onShutdown hooks already ran (db/cache still up)
|
|
81
|
+
→ connectors close in reverse → process exits
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For an even smoother handoff, give the load balancer time to observe the 503 before the server closes — e.g. an `onShutdown` hook with a short `sleep` matched to your LB's health-check interval.
|
|
85
|
+
|
|
86
|
+
## Gotchas
|
|
87
|
+
|
|
88
|
+
- **`/health` is registered straight on Fastify, not the app router.** It's infra, so it's immune to HMR and route scanning — but if your app also defines a `/health` route you'll have a collision. Rename via `http.health.path`.
|
|
89
|
+
- **Readiness needs a finished boot.** Before `Application.isBooted` (e.g. while late-phase connectors are still starting) `/ready` is 503 by design — that's the point.
|
|
90
|
+
- **A hanging `onShutdown` hook delays the drain.** App hooks run before connector teardown and are only bounded by your process manager's kill timeout; keep them fast. The HTTP drain itself is bounded by `gracefulShutdown.timeout`.
|
|
91
|
+
- **The `maintenance` middleware is a different 503.** It allowlists `/health` by default so probes pass during maintenance — but maintenance mode is operator-toggled downtime, not readiness. See `@warlock.js/core/use-middleware/SKILL.md`.
|
|
92
|
+
|
|
93
|
+
## See also
|
|
94
|
+
|
|
95
|
+
- [`use-app-context/SKILL.md`](../use-app-context/SKILL.md) — `Application.onShutdown` / `onceBooted` / `isShuttingDown`, the lifecycle hooks the endpoints build on.
|
|
96
|
+
- [`configure-app/SKILL.md`](../configure-app/SKILL.md) — the `src/config/http.ts` shape.
|
|
97
|
+
- [`add-connector/SKILL.md`](../add-connector/SKILL.md) — connector boot/shutdown order, where draining slots in.
|
|
98
|
+
- [`use-middleware/SKILL.md`](../use-middleware/SKILL.md) — maintenance mode and other built-in middleware.
|