@warlock.js/core 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -5
- package/README.md +47 -11
- package/esm/ai/src/agent/agent-input-builder.mjs +132 -0
- package/esm/ai/src/agent/agent-input-builder.mjs.map +1 -0
- package/esm/ai/src/agent/agent-log-event.mjs +101 -0
- package/esm/ai/src/agent/agent-log-event.mjs.map +1 -0
- package/esm/ai/src/agent/agent-stream.mjs +82 -0
- package/esm/ai/src/agent/agent-stream.mjs.map +1 -0
- package/esm/ai/src/agent/agent-to-stream-event.mjs +86 -0
- package/esm/ai/src/agent/agent-to-stream-event.mjs.map +1 -0
- package/esm/ai/src/agent/agent.mjs +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/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/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 +7 -0
- package/esm/connectors/cache-connector.mjs.map +1 -1
- package/esm/connectors/connectors-manager.d.mts +6 -2
- package/esm/connectors/connectors-manager.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.mjs +8 -2
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/index.d.mts +1 -0
- package/esm/connectors/index.mjs +1 -0
- 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 +28 -5
- 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 +2 -14
- package/esm/dev-server/development-server.mjs.map +1 -1
- package/esm/dev-server/file-event-handler.mjs +15 -3
- package/esm/dev-server/file-event-handler.mjs.map +1 -1
- package/esm/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/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 +4 -1
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs +2 -1
- package/esm/http/middleware/maintenance.middleware.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 +19 -2
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +1 -1
- package/esm/http/server.mjs.map +1 -1
- package/esm/index.d.mts +6 -2
- package/esm/index.mjs +5 -1
- package/esm/node_modules/langfuse/lib/index.mjs +1827 -0
- package/esm/node_modules/langfuse/lib/index.mjs.map +1 -0
- package/esm/node_modules/langfuse-core/lib/index.mjs +1770 -0
- package/esm/node_modules/langfuse-core/lib/index.mjs.map +1 -0
- package/esm/node_modules/mustache/mustache.mjs +587 -0
- package/esm/node_modules/mustache/mustache.mjs.map +1 -0
- package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs +180 -0
- package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs.map +1 -0
- package/esm/node_modules/openai/auth/workload-identity-auth.mjs +80 -0
- package/esm/node_modules/openai/auth/workload-identity-auth.mjs.map +1 -0
- package/esm/node_modules/openai/azure.mjs +82 -0
- package/esm/node_modules/openai/azure.mjs.map +1 -0
- package/esm/node_modules/openai/client.mjs +638 -0
- package/esm/node_modules/openai/client.mjs.map +1 -0
- package/esm/node_modules/openai/core/api-promise.mjs +75 -0
- package/esm/node_modules/openai/core/api-promise.mjs.map +1 -0
- package/esm/node_modules/openai/core/error.mjs +110 -0
- package/esm/node_modules/openai/core/error.mjs.map +1 -0
- package/esm/node_modules/openai/core/pagination.mjs +160 -0
- package/esm/node_modules/openai/core/pagination.mjs.map +1 -0
- package/esm/node_modules/openai/core/resource.mjs +10 -0
- package/esm/node_modules/openai/core/resource.mjs.map +1 -0
- package/esm/node_modules/openai/core/streaming.mjs +238 -0
- package/esm/node_modules/openai/core/streaming.mjs.map +1 -0
- package/esm/node_modules/openai/index.mjs +8 -0
- package/esm/node_modules/openai/internal/decoders/line.mjs +91 -0
- package/esm/node_modules/openai/internal/decoders/line.mjs.map +1 -0
- package/esm/node_modules/openai/internal/detect-platform.mjs +123 -0
- package/esm/node_modules/openai/internal/detect-platform.mjs.map +1 -0
- package/esm/node_modules/openai/internal/errors.mjs +26 -0
- package/esm/node_modules/openai/internal/errors.mjs.map +1 -0
- package/esm/node_modules/openai/internal/headers.mjs +65 -0
- package/esm/node_modules/openai/internal/headers.mjs.map +1 -0
- package/esm/node_modules/openai/internal/parse.mjs +41 -0
- package/esm/node_modules/openai/internal/parse.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/formats.mjs +12 -0
- package/esm/node_modules/openai/internal/qs/formats.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/stringify.mjs +179 -0
- package/esm/node_modules/openai/internal/qs/stringify.mjs.map +1 -0
- package/esm/node_modules/openai/internal/qs/utils.mjs +65 -0
- package/esm/node_modules/openai/internal/qs/utils.mjs.map +1 -0
- package/esm/node_modules/openai/internal/request-options.mjs +11 -0
- package/esm/node_modules/openai/internal/request-options.mjs.map +1 -0
- package/esm/node_modules/openai/internal/shims.mjs +77 -0
- package/esm/node_modules/openai/internal/shims.mjs.map +1 -0
- package/esm/node_modules/openai/internal/to-file.mjs +63 -0
- package/esm/node_modules/openai/internal/to-file.mjs.map +1 -0
- package/esm/node_modules/openai/internal/tslib.mjs +16 -0
- package/esm/node_modules/openai/internal/tslib.mjs.map +1 -0
- package/esm/node_modules/openai/internal/uploads.mjs +94 -0
- package/esm/node_modules/openai/internal/uploads.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/base64.mjs +22 -0
- package/esm/node_modules/openai/internal/utils/base64.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/bytes.mjs +26 -0
- package/esm/node_modules/openai/internal/utils/bytes.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/env.mjs +16 -0
- package/esm/node_modules/openai/internal/utils/env.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/log.mjs +58 -0
- package/esm/node_modules/openai/internal/utils/log.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/path.mjs +62 -0
- package/esm/node_modules/openai/internal/utils/path.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/query.mjs +10 -0
- package/esm/node_modules/openai/internal/utils/query.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/sleep.mjs +6 -0
- package/esm/node_modules/openai/internal/utils/sleep.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/uuid.mjs +18 -0
- package/esm/node_modules/openai/internal/utils/uuid.mjs.map +1 -0
- package/esm/node_modules/openai/internal/utils/values.mjs +41 -0
- package/esm/node_modules/openai/internal/utils/values.mjs.map +1 -0
- package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +247 -0
- package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/AssistantStream.mjs +472 -0
- package/esm/node_modules/openai/lib/AssistantStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs +26 -0
- package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionStream.mjs +423 -0
- package/esm/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +26 -0
- package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -0
- package/esm/node_modules/openai/lib/EventStream.mjs +163 -0
- package/esm/node_modules/openai/lib/EventStream.mjs.map +1 -0
- package/esm/node_modules/openai/lib/ResponsesParser.mjs +94 -0
- package/esm/node_modules/openai/lib/ResponsesParser.mjs.map +1 -0
- package/esm/node_modules/openai/lib/RunnableFunction.mjs +8 -0
- package/esm/node_modules/openai/lib/RunnableFunction.mjs.map +1 -0
- package/esm/node_modules/openai/lib/Util.mjs +19 -0
- package/esm/node_modules/openai/lib/Util.mjs.map +1 -0
- package/esm/node_modules/openai/lib/chatCompletionUtils.mjs +11 -0
- package/esm/node_modules/openai/lib/chatCompletionUtils.mjs.map +1 -0
- package/esm/node_modules/openai/lib/parser.mjs +88 -0
- package/esm/node_modules/openai/lib/parser.mjs.map +1 -0
- package/esm/node_modules/openai/lib/responses/ResponseStream.mjs +231 -0
- package/esm/node_modules/openai/lib/responses/ResponseStream.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/admin.mjs +15 -0
- package/esm/node_modules/openai/resources/admin/admin.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +81 -0
- package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs +31 -0
- package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/certificates.mjs +153 -0
- package/esm/node_modules/openai/resources/admin/organization/certificates.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs +42 -0
- package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs +106 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/invites.mjs +83 -0
- package/esm/node_modules/openai/resources/admin/organization/invites.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/organization.mjs +45 -0
- package/esm/node_modules/openai/resources/admin/organization/organization.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +72 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs +78 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +46 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +95 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +91 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +45 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +63 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs +137 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +51 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs +108 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +112 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +106 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +91 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs +118 -0
- package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/roles.mjs +96 -0
- package/esm/node_modules/openai/resources/admin/organization/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs +97 -0
- package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/usage.mjs +207 -0
- package/esm/node_modules/openai/resources/admin/organization/usage.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs +88 -0
- package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs.map +1 -0
- package/esm/node_modules/openai/resources/admin/organization/users/users.mjs +82 -0
- package/esm/node_modules/openai/resources/admin/organization/users/users.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/audio.mjs +21 -0
- package/esm/node_modules/openai/resources/audio/audio.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/speech.mjs +39 -0
- package/esm/node_modules/openai/resources/audio/speech.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/transcriptions.mjs +22 -0
- package/esm/node_modules/openai/resources/audio/transcriptions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/audio/translations.mjs +21 -0
- package/esm/node_modules/openai/resources/audio/translations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/batches.mjs +54 -0
- package/esm/node_modules/openai/resources/batches.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/assistants.mjs +78 -0
- package/esm/node_modules/openai/resources/beta/assistants.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/beta.mjs +24 -0
- package/esm/node_modules/openai/resources/beta/beta.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs +18 -0
- package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs +49 -0
- package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs +85 -0
- package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs +21 -0
- package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs +33 -0
- package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +33 -0
- package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/messages.mjs +83 -0
- package/esm/node_modules/openai/resources/beta/threads/messages.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs +183 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs +45 -0
- package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +1 -0
- package/esm/node_modules/openai/resources/beta/threads/threads.mjs +101 -0
- package/esm/node_modules/openai/resources/beta/threads/threads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/chat.mjs +15 -0
- package/esm/node_modules/openai/resources/chat/chat.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/completions/completions.mjs +123 -0
- package/esm/node_modules/openai/resources/chat/completions/completions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/completions/index.mjs +7 -0
- package/esm/node_modules/openai/resources/chat/completions/messages.mjs +35 -0
- package/esm/node_modules/openai/resources/chat/completions/messages.mjs.map +1 -0
- package/esm/node_modules/openai/resources/chat/index.mjs +5 -0
- package/esm/node_modules/openai/resources/completions.mjs +20 -0
- package/esm/node_modules/openai/resources/completions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/containers.mjs +57 -0
- package/esm/node_modules/openai/resources/containers/containers.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/files/content.mjs +23 -0
- package/esm/node_modules/openai/resources/containers/files/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/containers/files/files.mjs +63 -0
- package/esm/node_modules/openai/resources/containers/files/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/conversations/conversations.mjs +57 -0
- package/esm/node_modules/openai/resources/conversations/conversations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/conversations/items.mjs +57 -0
- package/esm/node_modules/openai/resources/conversations/items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/embeddings.mjs +48 -0
- package/esm/node_modules/openai/resources/embeddings.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/evals.mjs +73 -0
- package/esm/node_modules/openai/resources/evals/evals.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/runs/output-items.mjs +35 -0
- package/esm/node_modules/openai/resources/evals/runs/output-items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/evals/runs/runs.mjs +72 -0
- package/esm/node_modules/openai/resources/evals/runs/runs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/files.mjs +111 -0
- package/esm/node_modules/openai/resources/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +15 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +60 -0
- package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +15 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +102 -0
- package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +24 -0
- package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +34 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +148 -0
- package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +1 -0
- package/esm/node_modules/openai/resources/fine-tuning/methods.mjs +8 -0
- package/esm/node_modules/openai/resources/fine-tuning/methods.mjs.map +1 -0
- package/esm/node_modules/openai/resources/graders/grader-models.mjs +8 -0
- package/esm/node_modules/openai/resources/graders/grader-models.mjs.map +1 -0
- package/esm/node_modules/openai/resources/graders/graders.mjs +15 -0
- package/esm/node_modules/openai/resources/graders/graders.mjs.map +1 -0
- package/esm/node_modules/openai/resources/images.mjs +46 -0
- package/esm/node_modules/openai/resources/images.mjs.map +1 -0
- package/esm/node_modules/openai/resources/index.mjs +27 -0
- package/esm/node_modules/openai/resources/models.mjs +44 -0
- package/esm/node_modules/openai/resources/models.mjs.map +1 -0
- package/esm/node_modules/openai/resources/moderations.mjs +23 -0
- package/esm/node_modules/openai/resources/moderations.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/calls.mjs +79 -0
- package/esm/node_modules/openai/resources/realtime/calls.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/client-secrets.mjs +39 -0
- package/esm/node_modules/openai/resources/realtime/client-secrets.mjs.map +1 -0
- package/esm/node_modules/openai/resources/realtime/realtime.mjs +18 -0
- package/esm/node_modules/openai/resources/realtime/realtime.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/input-items.mjs +31 -0
- package/esm/node_modules/openai/resources/responses/input-items.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/input-tokens.mjs +27 -0
- package/esm/node_modules/openai/resources/responses/input-tokens.mjs.map +1 -0
- package/esm/node_modules/openai/resources/responses/responses.mjs +110 -0
- package/esm/node_modules/openai/resources/responses/responses.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/content.mjs +22 -0
- package/esm/node_modules/openai/resources/skills/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/skills.mjs +69 -0
- package/esm/node_modules/openai/resources/skills/skills.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/versions/content.mjs +23 -0
- package/esm/node_modules/openai/resources/skills/versions/content.mjs.map +1 -0
- package/esm/node_modules/openai/resources/skills/versions/versions.mjs +58 -0
- package/esm/node_modules/openai/resources/skills/versions/versions.mjs.map +1 -0
- package/esm/node_modules/openai/resources/uploads/parts.mjs +34 -0
- package/esm/node_modules/openai/resources/uploads/parts.mjs.map +1 -0
- package/esm/node_modules/openai/resources/uploads/uploads.mjs +84 -0
- package/esm/node_modules/openai/resources/uploads/uploads.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs +126 -0
- package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/files.mjs +147 -0
- package/esm/node_modules/openai/resources/vector-stores/files.mjs.map +1 -0
- package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs +87 -0
- package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs.map +1 -0
- package/esm/node_modules/openai/resources/videos.mjs +115 -0
- package/esm/node_modules/openai/resources/videos.mjs.map +1 -0
- package/esm/node_modules/openai/resources/webhooks/index.mjs +3 -0
- package/esm/node_modules/openai/resources/webhooks/webhooks.mjs +69 -0
- package/esm/node_modules/openai/resources/webhooks/webhooks.mjs.map +1 -0
- package/esm/node_modules/openai/resources/webhooks.mjs +4 -0
- package/esm/node_modules/openai/streaming.mjs +3 -0
- package/esm/node_modules/openai/version.mjs +6 -0
- package/esm/node_modules/openai/version.mjs.map +1 -0
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +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/npm-registry.d.mts +1 -1
- package/esm/utils/npm-registry.mjs +2 -2
- package/esm/utils/npm-registry.mjs.map +1 -1
- package/llms-full.txt +29 -1
- package/package.json +9 -9
- package/skills/add-connector/SKILL.md +6 -1
- package/skills/configure-app/SKILL.md +23 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "../internal/tslib.mjs";
|
|
2
|
+
import { APIUserAbortError, ContentFilterFinishReasonError, LengthFinishReasonError, OpenAIError } from "../core/error.mjs";
|
|
3
|
+
import { Stream } from "../core/streaming.mjs";
|
|
4
|
+
import { hasAutoParseableInput, isAutoParsableResponseFormat, isAutoParsableTool, isChatCompletionFunctionTool, maybeParseChatCompletion, shouldParseToolCall } from "./parser.mjs";
|
|
5
|
+
import { AbstractChatCompletionRunner } from "./AbstractChatCompletionRunner.mjs";
|
|
6
|
+
import { partialParse } from "../_vendor/partial-json-parser/parser.mjs";
|
|
7
|
+
import "../streaming.mjs";
|
|
8
|
+
|
|
9
|
+
//#region ../@warlock.js/node_modules/openai/lib/ChatCompletionStream.mjs
|
|
10
|
+
var _ChatCompletionStream_instances, _ChatCompletionStream_params, _ChatCompletionStream_choiceEventStates, _ChatCompletionStream_currentChatCompletionSnapshot, _ChatCompletionStream_beginRequest, _ChatCompletionStream_getChoiceEventState, _ChatCompletionStream_addChunk, _ChatCompletionStream_emitToolCallDoneEvent, _ChatCompletionStream_emitContentDoneEvents, _ChatCompletionStream_endRequest, _ChatCompletionStream_getAutoParseableResponseFormat, _ChatCompletionStream_accumulateChatCompletion;
|
|
11
|
+
var ChatCompletionStream = class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
super();
|
|
14
|
+
_ChatCompletionStream_instances.add(this);
|
|
15
|
+
_ChatCompletionStream_params.set(this, void 0);
|
|
16
|
+
_ChatCompletionStream_choiceEventStates.set(this, void 0);
|
|
17
|
+
_ChatCompletionStream_currentChatCompletionSnapshot.set(this, void 0);
|
|
18
|
+
__classPrivateFieldSet(this, _ChatCompletionStream_params, params, "f");
|
|
19
|
+
__classPrivateFieldSet(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
20
|
+
}
|
|
21
|
+
get currentChatCompletionSnapshot() {
|
|
22
|
+
return __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Intended for use on the frontend, consuming a stream produced with
|
|
26
|
+
* `.toReadableStream()` on the backend.
|
|
27
|
+
*
|
|
28
|
+
* Note that messages sent to the model do not appear in `.on('message')`
|
|
29
|
+
* in this context.
|
|
30
|
+
*/
|
|
31
|
+
static fromReadableStream(stream) {
|
|
32
|
+
const runner = new ChatCompletionStream(null);
|
|
33
|
+
runner._run(() => runner._fromReadableStream(stream));
|
|
34
|
+
return runner;
|
|
35
|
+
}
|
|
36
|
+
static createChatCompletion(client, params, options) {
|
|
37
|
+
const runner = new ChatCompletionStream(params);
|
|
38
|
+
runner._run(() => runner._runChatCompletion(client, {
|
|
39
|
+
...params,
|
|
40
|
+
stream: true
|
|
41
|
+
}, {
|
|
42
|
+
...options,
|
|
43
|
+
headers: {
|
|
44
|
+
...options?.headers,
|
|
45
|
+
"X-Stainless-Helper-Method": "stream"
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
return runner;
|
|
49
|
+
}
|
|
50
|
+
async _createChatCompletion(client, params, options) {
|
|
51
|
+
super._createChatCompletion;
|
|
52
|
+
const signal = options?.signal;
|
|
53
|
+
if (signal) {
|
|
54
|
+
if (signal.aborted) this.controller.abort();
|
|
55
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
56
|
+
}
|
|
57
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
58
|
+
const stream = await client.chat.completions.create({
|
|
59
|
+
...params,
|
|
60
|
+
stream: true
|
|
61
|
+
}, {
|
|
62
|
+
...options,
|
|
63
|
+
signal: this.controller.signal
|
|
64
|
+
});
|
|
65
|
+
this._connected();
|
|
66
|
+
for await (const chunk of stream) __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
67
|
+
if (stream.controller.signal?.aborted) throw new APIUserAbortError();
|
|
68
|
+
return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
69
|
+
}
|
|
70
|
+
async _fromReadableStream(readableStream, options) {
|
|
71
|
+
const signal = options?.signal;
|
|
72
|
+
if (signal) {
|
|
73
|
+
if (signal.aborted) this.controller.abort();
|
|
74
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
75
|
+
}
|
|
76
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
77
|
+
this._connected();
|
|
78
|
+
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
79
|
+
let chatId;
|
|
80
|
+
for await (const chunk of stream) {
|
|
81
|
+
if (chatId && chatId !== chunk.id) this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
82
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
83
|
+
chatId = chunk.id;
|
|
84
|
+
}
|
|
85
|
+
if (stream.controller.signal?.aborted) throw new APIUserAbortError();
|
|
86
|
+
return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
87
|
+
}
|
|
88
|
+
[(_ChatCompletionStream_params = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_choiceEventStates = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_currentChatCompletionSnapshot = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_instances = /* @__PURE__ */ new WeakSet(), _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {
|
|
89
|
+
if (this.ended) return;
|
|
90
|
+
__classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, void 0, "f");
|
|
91
|
+
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {
|
|
92
|
+
let state = __classPrivateFieldGet(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
93
|
+
if (state) return state;
|
|
94
|
+
state = {
|
|
95
|
+
content_done: false,
|
|
96
|
+
refusal_done: false,
|
|
97
|
+
logprobs_content_done: false,
|
|
98
|
+
logprobs_refusal_done: false,
|
|
99
|
+
done_tool_calls: /* @__PURE__ */ new Set(),
|
|
100
|
+
current_tool_call_index: null
|
|
101
|
+
};
|
|
102
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
103
|
+
return state;
|
|
104
|
+
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {
|
|
105
|
+
if (this.ended) return;
|
|
106
|
+
const completion = __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
107
|
+
this._emit("chunk", chunk, completion);
|
|
108
|
+
for (const choice of chunk.choices) {
|
|
109
|
+
const choiceSnapshot = completion.choices[choice.index];
|
|
110
|
+
if (choice.delta.content != null && choiceSnapshot.message?.role === "assistant" && choiceSnapshot.message?.content) {
|
|
111
|
+
this._emit("content", choice.delta.content, choiceSnapshot.message.content);
|
|
112
|
+
this._emit("content.delta", {
|
|
113
|
+
delta: choice.delta.content,
|
|
114
|
+
snapshot: choiceSnapshot.message.content,
|
|
115
|
+
parsed: choiceSnapshot.message.parsed
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (choice.delta.refusal != null && choiceSnapshot.message?.role === "assistant" && choiceSnapshot.message?.refusal) this._emit("refusal.delta", {
|
|
119
|
+
delta: choice.delta.refusal,
|
|
120
|
+
snapshot: choiceSnapshot.message.refusal
|
|
121
|
+
});
|
|
122
|
+
if (choice.logprobs?.content != null && choiceSnapshot.message?.role === "assistant") this._emit("logprobs.content.delta", {
|
|
123
|
+
content: choice.logprobs?.content,
|
|
124
|
+
snapshot: choiceSnapshot.logprobs?.content ?? []
|
|
125
|
+
});
|
|
126
|
+
if (choice.logprobs?.refusal != null && choiceSnapshot.message?.role === "assistant") this._emit("logprobs.refusal.delta", {
|
|
127
|
+
refusal: choice.logprobs?.refusal,
|
|
128
|
+
snapshot: choiceSnapshot.logprobs?.refusal ?? []
|
|
129
|
+
});
|
|
130
|
+
const state = __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
131
|
+
if (choiceSnapshot.finish_reason) {
|
|
132
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
133
|
+
if (state.current_tool_call_index != null) __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
134
|
+
}
|
|
135
|
+
for (const toolCall of choice.delta.tool_calls ?? []) {
|
|
136
|
+
if (state.current_tool_call_index !== toolCall.index) {
|
|
137
|
+
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
138
|
+
if (state.current_tool_call_index != null) __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
139
|
+
}
|
|
140
|
+
state.current_tool_call_index = toolCall.index;
|
|
141
|
+
}
|
|
142
|
+
for (const toolCallDelta of choice.delta.tool_calls ?? []) {
|
|
143
|
+
const toolCallSnapshot = choiceSnapshot.message.tool_calls?.[toolCallDelta.index];
|
|
144
|
+
if (!toolCallSnapshot?.type) continue;
|
|
145
|
+
if (toolCallSnapshot?.type === "function") this._emit("tool_calls.function.arguments.delta", {
|
|
146
|
+
name: toolCallSnapshot.function?.name,
|
|
147
|
+
index: toolCallDelta.index,
|
|
148
|
+
arguments: toolCallSnapshot.function.arguments,
|
|
149
|
+
parsed_arguments: toolCallSnapshot.function.parsed_arguments,
|
|
150
|
+
arguments_delta: toolCallDelta.function?.arguments ?? ""
|
|
151
|
+
});
|
|
152
|
+
else toolCallSnapshot?.type;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {
|
|
156
|
+
if (__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot).done_tool_calls.has(toolCallIndex)) return;
|
|
157
|
+
const toolCallSnapshot = choiceSnapshot.message.tool_calls?.[toolCallIndex];
|
|
158
|
+
if (!toolCallSnapshot) throw new Error("no tool call snapshot");
|
|
159
|
+
if (!toolCallSnapshot.type) throw new Error("tool call snapshot missing `type`");
|
|
160
|
+
if (toolCallSnapshot.type === "function") {
|
|
161
|
+
const inputTool = __classPrivateFieldGet(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => isChatCompletionFunctionTool(tool) && tool.function.name === toolCallSnapshot.function.name);
|
|
162
|
+
this._emit("tool_calls.function.arguments.done", {
|
|
163
|
+
name: toolCallSnapshot.function.name,
|
|
164
|
+
index: toolCallIndex,
|
|
165
|
+
arguments: toolCallSnapshot.function.arguments,
|
|
166
|
+
parsed_arguments: isAutoParsableTool(inputTool) ? inputTool.$parseRaw(toolCallSnapshot.function.arguments) : inputTool?.function.strict ? JSON.parse(toolCallSnapshot.function.arguments) : null
|
|
167
|
+
});
|
|
168
|
+
} else toolCallSnapshot.type;
|
|
169
|
+
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {
|
|
170
|
+
const state = __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
171
|
+
if (choiceSnapshot.message.content && !state.content_done) {
|
|
172
|
+
state.content_done = true;
|
|
173
|
+
const responseFormat = __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
|
|
174
|
+
this._emit("content.done", {
|
|
175
|
+
content: choiceSnapshot.message.content,
|
|
176
|
+
parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (choiceSnapshot.message.refusal && !state.refusal_done) {
|
|
180
|
+
state.refusal_done = true;
|
|
181
|
+
this._emit("refusal.done", { refusal: choiceSnapshot.message.refusal });
|
|
182
|
+
}
|
|
183
|
+
if (choiceSnapshot.logprobs?.content && !state.logprobs_content_done) {
|
|
184
|
+
state.logprobs_content_done = true;
|
|
185
|
+
this._emit("logprobs.content.done", { content: choiceSnapshot.logprobs.content });
|
|
186
|
+
}
|
|
187
|
+
if (choiceSnapshot.logprobs?.refusal && !state.logprobs_refusal_done) {
|
|
188
|
+
state.logprobs_refusal_done = true;
|
|
189
|
+
this._emit("logprobs.refusal.done", { refusal: choiceSnapshot.logprobs.refusal });
|
|
190
|
+
}
|
|
191
|
+
}, _ChatCompletionStream_endRequest = function _ChatCompletionStream_endRequest() {
|
|
192
|
+
if (this.ended) throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
193
|
+
const snapshot = __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
194
|
+
if (!snapshot) throw new OpenAIError(`request ended without sending any chunks`);
|
|
195
|
+
__classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, void 0, "f");
|
|
196
|
+
__classPrivateFieldSet(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
197
|
+
return finalizeChatCompletion(snapshot, __classPrivateFieldGet(this, _ChatCompletionStream_params, "f"));
|
|
198
|
+
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {
|
|
199
|
+
const responseFormat = __classPrivateFieldGet(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
200
|
+
if (isAutoParsableResponseFormat(responseFormat)) return responseFormat;
|
|
201
|
+
return null;
|
|
202
|
+
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {
|
|
203
|
+
var _a, _b, _c, _d;
|
|
204
|
+
let snapshot = __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
205
|
+
const { choices, ...rest } = chunk;
|
|
206
|
+
if (!snapshot) snapshot = __classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
|
|
207
|
+
...rest,
|
|
208
|
+
choices: []
|
|
209
|
+
}, "f");
|
|
210
|
+
else Object.assign(snapshot, rest);
|
|
211
|
+
for (const { delta, finish_reason, index, logprobs = null, ...other } of chunk.choices) {
|
|
212
|
+
let choice = snapshot.choices[index];
|
|
213
|
+
if (!choice) choice = snapshot.choices[index] = {
|
|
214
|
+
finish_reason,
|
|
215
|
+
index,
|
|
216
|
+
message: {},
|
|
217
|
+
logprobs,
|
|
218
|
+
...other
|
|
219
|
+
};
|
|
220
|
+
if (logprobs) if (!choice.logprobs) choice.logprobs = Object.assign({}, logprobs);
|
|
221
|
+
else {
|
|
222
|
+
const { content, refusal, ...rest } = logprobs;
|
|
223
|
+
Object.assign(choice.logprobs, rest);
|
|
224
|
+
if (content) {
|
|
225
|
+
(_a = choice.logprobs).content ?? (_a.content = []);
|
|
226
|
+
choice.logprobs.content.push(...content);
|
|
227
|
+
}
|
|
228
|
+
if (refusal) {
|
|
229
|
+
(_b = choice.logprobs).refusal ?? (_b.refusal = []);
|
|
230
|
+
choice.logprobs.refusal.push(...refusal);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (finish_reason) {
|
|
234
|
+
choice.finish_reason = finish_reason;
|
|
235
|
+
if (__classPrivateFieldGet(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet(this, _ChatCompletionStream_params, "f"))) {
|
|
236
|
+
if (finish_reason === "length") throw new LengthFinishReasonError();
|
|
237
|
+
if (finish_reason === "content_filter") throw new ContentFilterFinishReasonError();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
Object.assign(choice, other);
|
|
241
|
+
if (!delta) continue;
|
|
242
|
+
const { content, refusal, function_call, role, tool_calls, ...rest } = delta;
|
|
243
|
+
Object.assign(choice.message, rest);
|
|
244
|
+
if (refusal) choice.message.refusal = (choice.message.refusal || "") + refusal;
|
|
245
|
+
if (role) choice.message.role = role;
|
|
246
|
+
if (function_call) if (!choice.message.function_call) choice.message.function_call = function_call;
|
|
247
|
+
else {
|
|
248
|
+
if (function_call.name) choice.message.function_call.name = function_call.name;
|
|
249
|
+
if (function_call.arguments) {
|
|
250
|
+
(_c = choice.message.function_call).arguments ?? (_c.arguments = "");
|
|
251
|
+
choice.message.function_call.arguments += function_call.arguments;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (content) {
|
|
255
|
+
choice.message.content = (choice.message.content || "") + content;
|
|
256
|
+
if (!choice.message.refusal && __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) choice.message.parsed = partialParse(choice.message.content);
|
|
257
|
+
}
|
|
258
|
+
if (tool_calls) {
|
|
259
|
+
if (!choice.message.tool_calls) choice.message.tool_calls = [];
|
|
260
|
+
for (const { index, id, type, function: fn, ...rest } of tool_calls) {
|
|
261
|
+
const tool_call = (_d = choice.message.tool_calls)[index] ?? (_d[index] = {});
|
|
262
|
+
Object.assign(tool_call, rest);
|
|
263
|
+
if (id) tool_call.id = id;
|
|
264
|
+
if (type) tool_call.type = type;
|
|
265
|
+
if (fn) tool_call.function ?? (tool_call.function = {
|
|
266
|
+
name: fn.name ?? "",
|
|
267
|
+
arguments: ""
|
|
268
|
+
});
|
|
269
|
+
if (fn?.name) tool_call.function.name = fn.name;
|
|
270
|
+
if (fn?.arguments) {
|
|
271
|
+
tool_call.function.arguments += fn.arguments;
|
|
272
|
+
if (shouldParseToolCall(__classPrivateFieldGet(this, _ChatCompletionStream_params, "f"), tool_call)) tool_call.function.parsed_arguments = partialParse(tool_call.function.arguments);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return snapshot;
|
|
278
|
+
}, Symbol.asyncIterator)]() {
|
|
279
|
+
const pushQueue = [];
|
|
280
|
+
const readQueue = [];
|
|
281
|
+
let done = false;
|
|
282
|
+
this.on("chunk", (chunk) => {
|
|
283
|
+
const reader = readQueue.shift();
|
|
284
|
+
if (reader) reader.resolve(chunk);
|
|
285
|
+
else pushQueue.push(chunk);
|
|
286
|
+
});
|
|
287
|
+
this.on("end", () => {
|
|
288
|
+
done = true;
|
|
289
|
+
for (const reader of readQueue) reader.resolve(void 0);
|
|
290
|
+
readQueue.length = 0;
|
|
291
|
+
});
|
|
292
|
+
this.on("abort", (err) => {
|
|
293
|
+
done = true;
|
|
294
|
+
for (const reader of readQueue) reader.reject(err);
|
|
295
|
+
readQueue.length = 0;
|
|
296
|
+
});
|
|
297
|
+
this.on("error", (err) => {
|
|
298
|
+
done = true;
|
|
299
|
+
for (const reader of readQueue) reader.reject(err);
|
|
300
|
+
readQueue.length = 0;
|
|
301
|
+
});
|
|
302
|
+
return {
|
|
303
|
+
next: async () => {
|
|
304
|
+
if (!pushQueue.length) {
|
|
305
|
+
if (done) return {
|
|
306
|
+
value: void 0,
|
|
307
|
+
done: true
|
|
308
|
+
};
|
|
309
|
+
return new Promise((resolve, reject) => readQueue.push({
|
|
310
|
+
resolve,
|
|
311
|
+
reject
|
|
312
|
+
})).then((chunk) => chunk ? {
|
|
313
|
+
value: chunk,
|
|
314
|
+
done: false
|
|
315
|
+
} : {
|
|
316
|
+
value: void 0,
|
|
317
|
+
done: true
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
value: pushQueue.shift(),
|
|
322
|
+
done: false
|
|
323
|
+
};
|
|
324
|
+
},
|
|
325
|
+
return: async () => {
|
|
326
|
+
this.abort();
|
|
327
|
+
return {
|
|
328
|
+
value: void 0,
|
|
329
|
+
done: true
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
toReadableStream() {
|
|
335
|
+
return new Stream(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
function finalizeChatCompletion(snapshot, params) {
|
|
339
|
+
const { id, choices, created, model, system_fingerprint, ...rest } = snapshot;
|
|
340
|
+
return maybeParseChatCompletion({
|
|
341
|
+
...rest,
|
|
342
|
+
id,
|
|
343
|
+
choices: choices.map(({ message, finish_reason, index, logprobs, ...choiceRest }) => {
|
|
344
|
+
if (!finish_reason) throw new OpenAIError(`missing finish_reason for choice ${index}`);
|
|
345
|
+
const { content = null, function_call, tool_calls, ...messageRest } = message;
|
|
346
|
+
const role = message.role;
|
|
347
|
+
if (!role) throw new OpenAIError(`missing role for choice ${index}`);
|
|
348
|
+
if (function_call) {
|
|
349
|
+
const { arguments: args, name } = function_call;
|
|
350
|
+
if (args == null) throw new OpenAIError(`missing function_call.arguments for choice ${index}`);
|
|
351
|
+
if (!name) throw new OpenAIError(`missing function_call.name for choice ${index}`);
|
|
352
|
+
return {
|
|
353
|
+
...choiceRest,
|
|
354
|
+
message: {
|
|
355
|
+
content,
|
|
356
|
+
function_call: {
|
|
357
|
+
arguments: args,
|
|
358
|
+
name
|
|
359
|
+
},
|
|
360
|
+
role,
|
|
361
|
+
refusal: message.refusal ?? null
|
|
362
|
+
},
|
|
363
|
+
finish_reason,
|
|
364
|
+
index,
|
|
365
|
+
logprobs
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (tool_calls) return {
|
|
369
|
+
...choiceRest,
|
|
370
|
+
index,
|
|
371
|
+
finish_reason,
|
|
372
|
+
logprobs,
|
|
373
|
+
message: {
|
|
374
|
+
...messageRest,
|
|
375
|
+
role,
|
|
376
|
+
content,
|
|
377
|
+
refusal: message.refusal ?? null,
|
|
378
|
+
tool_calls: tool_calls.map((tool_call, i) => {
|
|
379
|
+
const { function: fn, type, id, ...toolRest } = tool_call;
|
|
380
|
+
const { arguments: args, name, ...fnRest } = fn || {};
|
|
381
|
+
if (id == null) throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].id\n${str(snapshot)}`);
|
|
382
|
+
if (type == null) throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].type\n${str(snapshot)}`);
|
|
383
|
+
if (name == null) throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].function.name\n${str(snapshot)}`);
|
|
384
|
+
if (args == null) throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].function.arguments\n${str(snapshot)}`);
|
|
385
|
+
return {
|
|
386
|
+
...toolRest,
|
|
387
|
+
id,
|
|
388
|
+
type,
|
|
389
|
+
function: {
|
|
390
|
+
...fnRest,
|
|
391
|
+
name,
|
|
392
|
+
arguments: args
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
})
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
...choiceRest,
|
|
400
|
+
message: {
|
|
401
|
+
...messageRest,
|
|
402
|
+
content,
|
|
403
|
+
role,
|
|
404
|
+
refusal: message.refusal ?? null
|
|
405
|
+
},
|
|
406
|
+
finish_reason,
|
|
407
|
+
index,
|
|
408
|
+
logprobs
|
|
409
|
+
};
|
|
410
|
+
}),
|
|
411
|
+
created,
|
|
412
|
+
model,
|
|
413
|
+
object: "chat.completion",
|
|
414
|
+
...system_fingerprint ? { system_fingerprint } : {}
|
|
415
|
+
}, params);
|
|
416
|
+
}
|
|
417
|
+
function str(x) {
|
|
418
|
+
return JSON.stringify(x);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
//#endregion
|
|
422
|
+
export { ChatCompletionStream };
|
|
423
|
+
//# sourceMappingURL=ChatCompletionStream.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatCompletionStream.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/node_modules/openai/lib/ChatCompletionStream.mjs"],"sourcesContent":["var _ChatCompletionStream_instances, _ChatCompletionStream_params, _ChatCompletionStream_choiceEventStates, _ChatCompletionStream_currentChatCompletionSnapshot, _ChatCompletionStream_beginRequest, _ChatCompletionStream_getChoiceEventState, _ChatCompletionStream_addChunk, _ChatCompletionStream_emitToolCallDoneEvent, _ChatCompletionStream_emitContentDoneEvents, _ChatCompletionStream_endRequest, _ChatCompletionStream_getAutoParseableResponseFormat, _ChatCompletionStream_accumulateChatCompletion;\nimport { __classPrivateFieldGet, __classPrivateFieldSet } from \"../internal/tslib.mjs\";\nimport { partialParse } from \"../_vendor/partial-json-parser/parser.mjs\";\nimport { APIUserAbortError, ContentFilterFinishReasonError, LengthFinishReasonError, OpenAIError, } from \"../error.mjs\";\nimport { hasAutoParseableInput, isAutoParsableResponseFormat, isAutoParsableTool, isChatCompletionFunctionTool, maybeParseChatCompletion, shouldParseToolCall, } from \"../lib/parser.mjs\";\nimport { Stream } from \"../streaming.mjs\";\nimport { AbstractChatCompletionRunner, } from \"./AbstractChatCompletionRunner.mjs\";\nexport class ChatCompletionStream extends AbstractChatCompletionRunner {\n constructor(params) {\n super();\n _ChatCompletionStream_instances.add(this);\n _ChatCompletionStream_params.set(this, void 0);\n _ChatCompletionStream_choiceEventStates.set(this, void 0);\n _ChatCompletionStream_currentChatCompletionSnapshot.set(this, void 0);\n __classPrivateFieldSet(this, _ChatCompletionStream_params, params, \"f\");\n __classPrivateFieldSet(this, _ChatCompletionStream_choiceEventStates, [], \"f\");\n }\n get currentChatCompletionSnapshot() {\n return __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, \"f\");\n }\n /**\n * Intended for use on the frontend, consuming a stream produced with\n * `.toReadableStream()` on the backend.\n *\n * Note that messages sent to the model do not appear in `.on('message')`\n * in this context.\n */\n static fromReadableStream(stream) {\n const runner = new ChatCompletionStream(null);\n runner._run(() => runner._fromReadableStream(stream));\n return runner;\n }\n static createChatCompletion(client, params, options) {\n const runner = new ChatCompletionStream(params);\n runner._run(() => runner._runChatCompletion(client, { ...params, stream: true }, { ...options, headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'stream' } }));\n return runner;\n }\n async _createChatCompletion(client, params, options) {\n super._createChatCompletion;\n const signal = options?.signal;\n if (signal) {\n if (signal.aborted)\n this.controller.abort();\n signal.addEventListener('abort', () => this.controller.abort());\n }\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_beginRequest).call(this);\n const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });\n this._connected();\n for await (const chunk of stream) {\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_addChunk).call(this, chunk);\n }\n if (stream.controller.signal?.aborted) {\n throw new APIUserAbortError();\n }\n return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_endRequest).call(this));\n }\n async _fromReadableStream(readableStream, options) {\n const signal = options?.signal;\n if (signal) {\n if (signal.aborted)\n this.controller.abort();\n signal.addEventListener('abort', () => this.controller.abort());\n }\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_beginRequest).call(this);\n this._connected();\n const stream = Stream.fromReadableStream(readableStream, this.controller);\n let chatId;\n for await (const chunk of stream) {\n if (chatId && chatId !== chunk.id) {\n // A new request has been made.\n this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_endRequest).call(this));\n }\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_addChunk).call(this, chunk);\n chatId = chunk.id;\n }\n if (stream.controller.signal?.aborted) {\n throw new APIUserAbortError();\n }\n return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_endRequest).call(this));\n }\n [(_ChatCompletionStream_params = new WeakMap(), _ChatCompletionStream_choiceEventStates = new WeakMap(), _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap(), _ChatCompletionStream_instances = new WeakSet(), _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {\n if (this.ended)\n return;\n __classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, \"f\");\n }, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {\n let state = __classPrivateFieldGet(this, _ChatCompletionStream_choiceEventStates, \"f\")[choice.index];\n if (state) {\n return state;\n }\n state = {\n content_done: false,\n refusal_done: false,\n logprobs_content_done: false,\n logprobs_refusal_done: false,\n done_tool_calls: new Set(),\n current_tool_call_index: null,\n };\n __classPrivateFieldGet(this, _ChatCompletionStream_choiceEventStates, \"f\")[choice.index] = state;\n return state;\n }, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {\n if (this.ended)\n return;\n const completion = __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);\n this._emit('chunk', chunk, completion);\n for (const choice of chunk.choices) {\n const choiceSnapshot = completion.choices[choice.index];\n if (choice.delta.content != null &&\n choiceSnapshot.message?.role === 'assistant' &&\n choiceSnapshot.message?.content) {\n this._emit('content', choice.delta.content, choiceSnapshot.message.content);\n this._emit('content.delta', {\n delta: choice.delta.content,\n snapshot: choiceSnapshot.message.content,\n parsed: choiceSnapshot.message.parsed,\n });\n }\n if (choice.delta.refusal != null &&\n choiceSnapshot.message?.role === 'assistant' &&\n choiceSnapshot.message?.refusal) {\n this._emit('refusal.delta', {\n delta: choice.delta.refusal,\n snapshot: choiceSnapshot.message.refusal,\n });\n }\n if (choice.logprobs?.content != null && choiceSnapshot.message?.role === 'assistant') {\n this._emit('logprobs.content.delta', {\n content: choice.logprobs?.content,\n snapshot: choiceSnapshot.logprobs?.content ?? [],\n });\n }\n if (choice.logprobs?.refusal != null && choiceSnapshot.message?.role === 'assistant') {\n this._emit('logprobs.refusal.delta', {\n refusal: choice.logprobs?.refusal,\n snapshot: choiceSnapshot.logprobs?.refusal ?? [],\n });\n }\n const state = __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);\n if (choiceSnapshot.finish_reason) {\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);\n if (state.current_tool_call_index != null) {\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);\n }\n }\n for (const toolCall of choice.delta.tool_calls ?? []) {\n if (state.current_tool_call_index !== toolCall.index) {\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);\n // new tool call started, the previous one is done\n if (state.current_tool_call_index != null) {\n __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);\n }\n }\n state.current_tool_call_index = toolCall.index;\n }\n for (const toolCallDelta of choice.delta.tool_calls ?? []) {\n const toolCallSnapshot = choiceSnapshot.message.tool_calls?.[toolCallDelta.index];\n if (!toolCallSnapshot?.type) {\n continue;\n }\n if (toolCallSnapshot?.type === 'function') {\n this._emit('tool_calls.function.arguments.delta', {\n name: toolCallSnapshot.function?.name,\n index: toolCallDelta.index,\n arguments: toolCallSnapshot.function.arguments,\n parsed_arguments: toolCallSnapshot.function.parsed_arguments,\n arguments_delta: toolCallDelta.function?.arguments ?? '',\n });\n }\n else {\n assertNever(toolCallSnapshot?.type);\n }\n }\n }\n }, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {\n const state = __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);\n if (state.done_tool_calls.has(toolCallIndex)) {\n // we've already fired the done event\n return;\n }\n const toolCallSnapshot = choiceSnapshot.message.tool_calls?.[toolCallIndex];\n if (!toolCallSnapshot) {\n throw new Error('no tool call snapshot');\n }\n if (!toolCallSnapshot.type) {\n throw new Error('tool call snapshot missing `type`');\n }\n if (toolCallSnapshot.type === 'function') {\n const inputTool = __classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\")?.tools?.find((tool) => isChatCompletionFunctionTool(tool) && tool.function.name === toolCallSnapshot.function.name); // TS doesn't narrow based on isChatCompletionTool\n this._emit('tool_calls.function.arguments.done', {\n name: toolCallSnapshot.function.name,\n index: toolCallIndex,\n arguments: toolCallSnapshot.function.arguments,\n parsed_arguments: isAutoParsableTool(inputTool) ? inputTool.$parseRaw(toolCallSnapshot.function.arguments)\n : inputTool?.function.strict ? JSON.parse(toolCallSnapshot.function.arguments)\n : null,\n });\n }\n else {\n assertNever(toolCallSnapshot.type);\n }\n }, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {\n const state = __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);\n if (choiceSnapshot.message.content && !state.content_done) {\n state.content_done = true;\n const responseFormat = __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);\n this._emit('content.done', {\n content: choiceSnapshot.message.content,\n parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null,\n });\n }\n if (choiceSnapshot.message.refusal && !state.refusal_done) {\n state.refusal_done = true;\n this._emit('refusal.done', { refusal: choiceSnapshot.message.refusal });\n }\n if (choiceSnapshot.logprobs?.content && !state.logprobs_content_done) {\n state.logprobs_content_done = true;\n this._emit('logprobs.content.done', { content: choiceSnapshot.logprobs.content });\n }\n if (choiceSnapshot.logprobs?.refusal && !state.logprobs_refusal_done) {\n state.logprobs_refusal_done = true;\n this._emit('logprobs.refusal.done', { refusal: choiceSnapshot.logprobs.refusal });\n }\n }, _ChatCompletionStream_endRequest = function _ChatCompletionStream_endRequest() {\n if (this.ended) {\n throw new OpenAIError(`stream has ended, this shouldn't happen`);\n }\n const snapshot = __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, \"f\");\n if (!snapshot) {\n throw new OpenAIError(`request ended without sending any chunks`);\n }\n __classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, \"f\");\n __classPrivateFieldSet(this, _ChatCompletionStream_choiceEventStates, [], \"f\");\n return finalizeChatCompletion(snapshot, __classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\"));\n }, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {\n const responseFormat = __classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\")?.response_format;\n if (isAutoParsableResponseFormat(responseFormat)) {\n return responseFormat;\n }\n return null;\n }, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {\n var _a, _b, _c, _d;\n let snapshot = __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, \"f\");\n const { choices, ...rest } = chunk;\n if (!snapshot) {\n snapshot = __classPrivateFieldSet(this, _ChatCompletionStream_currentChatCompletionSnapshot, {\n ...rest,\n choices: [],\n }, \"f\");\n }\n else {\n Object.assign(snapshot, rest);\n }\n for (const { delta, finish_reason, index, logprobs = null, ...other } of chunk.choices) {\n let choice = snapshot.choices[index];\n if (!choice) {\n choice = snapshot.choices[index] = { finish_reason, index, message: {}, logprobs, ...other };\n }\n if (logprobs) {\n if (!choice.logprobs) {\n choice.logprobs = Object.assign({}, logprobs);\n }\n else {\n const { content, refusal, ...rest } = logprobs;\n assertIsEmpty(rest);\n Object.assign(choice.logprobs, rest);\n if (content) {\n (_a = choice.logprobs).content ?? (_a.content = []);\n choice.logprobs.content.push(...content);\n }\n if (refusal) {\n (_b = choice.logprobs).refusal ?? (_b.refusal = []);\n choice.logprobs.refusal.push(...refusal);\n }\n }\n }\n if (finish_reason) {\n choice.finish_reason = finish_reason;\n if (__classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\") && hasAutoParseableInput(__classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\"))) {\n if (finish_reason === 'length') {\n throw new LengthFinishReasonError();\n }\n if (finish_reason === 'content_filter') {\n throw new ContentFilterFinishReasonError();\n }\n }\n }\n Object.assign(choice, other);\n if (!delta)\n continue; // Shouldn't happen; just in case.\n const { content, refusal, function_call, role, tool_calls, ...rest } = delta;\n assertIsEmpty(rest);\n Object.assign(choice.message, rest);\n if (refusal) {\n choice.message.refusal = (choice.message.refusal || '') + refusal;\n }\n if (role)\n choice.message.role = role;\n if (function_call) {\n if (!choice.message.function_call) {\n choice.message.function_call = function_call;\n }\n else {\n if (function_call.name)\n choice.message.function_call.name = function_call.name;\n if (function_call.arguments) {\n (_c = choice.message.function_call).arguments ?? (_c.arguments = '');\n choice.message.function_call.arguments += function_call.arguments;\n }\n }\n }\n if (content) {\n choice.message.content = (choice.message.content || '') + content;\n if (!choice.message.refusal && __classPrivateFieldGet(this, _ChatCompletionStream_instances, \"m\", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {\n choice.message.parsed = partialParse(choice.message.content);\n }\n }\n if (tool_calls) {\n if (!choice.message.tool_calls)\n choice.message.tool_calls = [];\n for (const { index, id, type, function: fn, ...rest } of tool_calls) {\n const tool_call = ((_d = choice.message.tool_calls)[index] ?? (_d[index] = {}));\n Object.assign(tool_call, rest);\n if (id)\n tool_call.id = id;\n if (type)\n tool_call.type = type;\n if (fn)\n tool_call.function ?? (tool_call.function = { name: fn.name ?? '', arguments: '' });\n if (fn?.name)\n tool_call.function.name = fn.name;\n if (fn?.arguments) {\n tool_call.function.arguments += fn.arguments;\n if (shouldParseToolCall(__classPrivateFieldGet(this, _ChatCompletionStream_params, \"f\"), tool_call)) {\n tool_call.function.parsed_arguments = partialParse(tool_call.function.arguments);\n }\n }\n }\n }\n }\n return snapshot;\n }, Symbol.asyncIterator)]() {\n const pushQueue = [];\n const readQueue = [];\n let done = false;\n this.on('chunk', (chunk) => {\n const reader = readQueue.shift();\n if (reader) {\n reader.resolve(chunk);\n }\n else {\n pushQueue.push(chunk);\n }\n });\n this.on('end', () => {\n done = true;\n for (const reader of readQueue) {\n reader.resolve(undefined);\n }\n readQueue.length = 0;\n });\n this.on('abort', (err) => {\n done = true;\n for (const reader of readQueue) {\n reader.reject(err);\n }\n readQueue.length = 0;\n });\n this.on('error', (err) => {\n done = true;\n for (const reader of readQueue) {\n reader.reject(err);\n }\n readQueue.length = 0;\n });\n return {\n next: async () => {\n if (!pushQueue.length) {\n if (done) {\n return { value: undefined, done: true };\n }\n return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk) => (chunk ? { value: chunk, done: false } : { value: undefined, done: true }));\n }\n const chunk = pushQueue.shift();\n return { value: chunk, done: false };\n },\n return: async () => {\n this.abort();\n return { value: undefined, done: true };\n },\n };\n }\n toReadableStream() {\n const stream = new Stream(this[Symbol.asyncIterator].bind(this), this.controller);\n return stream.toReadableStream();\n }\n}\nfunction finalizeChatCompletion(snapshot, params) {\n const { id, choices, created, model, system_fingerprint, ...rest } = snapshot;\n const completion = {\n ...rest,\n id,\n choices: choices.map(({ message, finish_reason, index, logprobs, ...choiceRest }) => {\n if (!finish_reason) {\n throw new OpenAIError(`missing finish_reason for choice ${index}`);\n }\n const { content = null, function_call, tool_calls, ...messageRest } = message;\n const role = message.role; // this is what we expect; in theory it could be different which would make our types a slight lie but would be fine.\n if (!role) {\n throw new OpenAIError(`missing role for choice ${index}`);\n }\n if (function_call) {\n const { arguments: args, name } = function_call;\n if (args == null) {\n throw new OpenAIError(`missing function_call.arguments for choice ${index}`);\n }\n if (!name) {\n throw new OpenAIError(`missing function_call.name for choice ${index}`);\n }\n return {\n ...choiceRest,\n message: {\n content,\n function_call: { arguments: args, name },\n role,\n refusal: message.refusal ?? null,\n },\n finish_reason,\n index,\n logprobs,\n };\n }\n if (tool_calls) {\n return {\n ...choiceRest,\n index,\n finish_reason,\n logprobs,\n message: {\n ...messageRest,\n role,\n content,\n refusal: message.refusal ?? null,\n tool_calls: tool_calls.map((tool_call, i) => {\n const { function: fn, type, id, ...toolRest } = tool_call;\n const { arguments: args, name, ...fnRest } = fn || {};\n if (id == null) {\n throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].id\\n${str(snapshot)}`);\n }\n if (type == null) {\n throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].type\\n${str(snapshot)}`);\n }\n if (name == null) {\n throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].function.name\\n${str(snapshot)}`);\n }\n if (args == null) {\n throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].function.arguments\\n${str(snapshot)}`);\n }\n return { ...toolRest, id, type, function: { ...fnRest, name, arguments: args } };\n }),\n },\n };\n }\n return {\n ...choiceRest,\n message: { ...messageRest, content, role, refusal: message.refusal ?? null },\n finish_reason,\n index,\n logprobs,\n };\n }),\n created,\n model,\n object: 'chat.completion',\n ...(system_fingerprint ? { system_fingerprint } : {}),\n };\n return maybeParseChatCompletion(completion, params);\n}\nfunction str(x) {\n return JSON.stringify(x);\n}\n/**\n * Ensures the given argument is an empty object, useful for\n * asserting that all known properties on an object have been\n * destructured.\n */\nfunction assertIsEmpty(obj) {\n return;\n}\nfunction assertNever(_x) { }\n//# sourceMappingURL=ChatCompletionStream.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;AAAA,IAAI,iCAAiC,8BAA8B,yCAAyC,qDAAqD,oCAAoC,2CAA2C,gCAAgC,6CAA6C,6CAA6C,kCAAkC,sDAAsD;AAOl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#region ../@warlock.js/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs
|
|
4
|
+
var ChatCompletionStreamingRunner = class ChatCompletionStreamingRunner extends ChatCompletionStream {
|
|
5
|
+
static fromReadableStream(stream) {
|
|
6
|
+
const runner = new ChatCompletionStreamingRunner(null);
|
|
7
|
+
runner._run(() => runner._fromReadableStream(stream));
|
|
8
|
+
return runner;
|
|
9
|
+
}
|
|
10
|
+
static runTools(client, params, options) {
|
|
11
|
+
const runner = new ChatCompletionStreamingRunner(params);
|
|
12
|
+
const opts = {
|
|
13
|
+
...options,
|
|
14
|
+
headers: {
|
|
15
|
+
...options?.headers,
|
|
16
|
+
"X-Stainless-Helper-Method": "runTools"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
runner._run(() => runner._runTools(client, params, opts));
|
|
20
|
+
return runner;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ChatCompletionStreamingRunner };
|
|
26
|
+
//# sourceMappingURL=ChatCompletionStreamingRunner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatCompletionStreamingRunner.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs"],"sourcesContent":["import { ChatCompletionStream } from \"./ChatCompletionStream.mjs\";\nexport class ChatCompletionStreamingRunner extends ChatCompletionStream {\n static fromReadableStream(stream) {\n const runner = new ChatCompletionStreamingRunner(null);\n runner._run(() => runner._fromReadableStream(stream));\n return runner;\n }\n static runTools(client, params, options) {\n const runner = new ChatCompletionStreamingRunner(\n // @ts-expect-error TODO these types are incompatible\n params);\n const opts = {\n ...options,\n headers: { ...options?.headers, 'X-Stainless-Helper-Method': 'runTools' },\n };\n runner._run(() => runner._runTools(client, params, opts));\n return runner;\n }\n}\n//# sourceMappingURL=ChatCompletionStreamingRunner.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;AACA,IAAa,gCAAb,MAAa,sCAAsC,qBAAqB;CACpE,OAAO,mBAAmB,QAAQ;EAC9B,MAAM,SAAS,IAAI,8BAA8B,IAAI;EACrD,OAAO,WAAW,OAAO,oBAAoB,MAAM,CAAC;EACpD,OAAO;CACX;CACA,OAAO,SAAS,QAAQ,QAAQ,SAAS;EACrC,MAAM,SAAS,IAAI,8BAEnB,MAAM;EACN,MAAM,OAAO;GACT,GAAG;GACH,SAAS;IAAE,GAAG,SAAS;IAAS,6BAA6B;GAAW;EAC5E;EACA,OAAO,WAAW,OAAO,UAAU,QAAQ,QAAQ,IAAI,CAAC;EACxD,OAAO;CACX;AACJ"}
|