dp-worker 0.1.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/builtin-skills/sourcepool.md +228 -0
- package/builtin-skills/x.md +263 -0
- package/config.example.json +37 -0
- package/dist/agent/agent-types.d.ts +44 -0
- package/dist/agent/agent-types.js +23 -0
- package/dist/agent/agent-types.js.map +1 -0
- package/dist/agent/agent.d.ts +162 -0
- package/dist/agent/agent.js +670 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/browser-lock.d.ts +36 -0
- package/dist/agent/browser-lock.js +46 -0
- package/dist/agent/browser-lock.js.map +1 -0
- package/dist/agent/chat-engine.d.ts +87 -0
- package/dist/agent/chat-engine.js +588 -0
- package/dist/agent/chat-engine.js.map +1 -0
- package/dist/agent/chrome-watchdog.d.ts +74 -0
- package/dist/agent/chrome-watchdog.js +136 -0
- package/dist/agent/chrome-watchdog.js.map +1 -0
- package/dist/agent/context.d.ts +148 -0
- package/dist/agent/context.js +521 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/duration.d.ts +2 -0
- package/dist/agent/duration.js +15 -0
- package/dist/agent/duration.js.map +1 -0
- package/dist/agent/executors/attachment-executor.d.ts +19 -0
- package/dist/agent/executors/attachment-executor.js +136 -0
- package/dist/agent/executors/attachment-executor.js.map +1 -0
- package/dist/agent/executors/memory-executor.d.ts +2 -0
- package/dist/agent/executors/memory-executor.js +13 -0
- package/dist/agent/executors/memory-executor.js.map +1 -0
- package/dist/agent/executors/org-executor.d.ts +8 -0
- package/dist/agent/executors/org-executor.js +47 -0
- package/dist/agent/executors/org-executor.js.map +1 -0
- package/dist/agent/executors/scheduler-executor.d.ts +21 -0
- package/dist/agent/executors/scheduler-executor.js +75 -0
- package/dist/agent/executors/scheduler-executor.js.map +1 -0
- package/dist/agent/executors/skill-executor.d.ts +10 -0
- package/dist/agent/executors/skill-executor.js +178 -0
- package/dist/agent/executors/skill-executor.js.map +1 -0
- package/dist/agent/executors/store-executor.d.ts +2 -0
- package/dist/agent/executors/store-executor.js +42 -0
- package/dist/agent/executors/store-executor.js.map +1 -0
- package/dist/agent/executors/web-fetch-executor.d.ts +17 -0
- package/dist/agent/executors/web-fetch-executor.js +164 -0
- package/dist/agent/executors/web-fetch-executor.js.map +1 -0
- package/dist/agent/frontend-multiplexer.d.ts +38 -0
- package/dist/agent/frontend-multiplexer.js +67 -0
- package/dist/agent/frontend-multiplexer.js.map +1 -0
- package/dist/agent/image-generator.d.ts +35 -0
- package/dist/agent/image-generator.js +266 -0
- package/dist/agent/image-generator.js.map +1 -0
- package/dist/agent/image-postprocess.d.ts +25 -0
- package/dist/agent/image-postprocess.js +82 -0
- package/dist/agent/image-postprocess.js.map +1 -0
- package/dist/agent/memory.d.ts +55 -0
- package/dist/agent/memory.js +401 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/org-manager.d.ts +70 -0
- package/dist/agent/org-manager.js +280 -0
- package/dist/agent/org-manager.js.map +1 -0
- package/dist/agent/scheduler.d.ts +51 -0
- package/dist/agent/scheduler.js +302 -0
- package/dist/agent/scheduler.js.map +1 -0
- package/dist/agent/skill-generator.d.ts +116 -0
- package/dist/agent/skill-generator.js +704 -0
- package/dist/agent/skill-generator.js.map +1 -0
- package/dist/agent/storage-policy.d.ts +55 -0
- package/dist/agent/storage-policy.js +406 -0
- package/dist/agent/storage-policy.js.map +1 -0
- package/dist/agent/store.d.ts +58 -0
- package/dist/agent/store.js +309 -0
- package/dist/agent/store.js.map +1 -0
- package/dist/agent/task-runner.d.ts +34 -0
- package/dist/agent/task-runner.js +705 -0
- package/dist/agent/task-runner.js.map +1 -0
- package/dist/agent/tool-loop-detection.d.ts +60 -0
- package/dist/agent/tool-loop-detection.js +233 -0
- package/dist/agent/tool-loop-detection.js.map +1 -0
- package/dist/agent/tool-runner.d.ts +37 -0
- package/dist/agent/tool-runner.js +72 -0
- package/dist/agent/tool-runner.js.map +1 -0
- package/dist/browser/actions.d.ts +217 -0
- package/dist/browser/actions.js +3097 -0
- package/dist/browser/actions.js.map +1 -0
- package/dist/browser/builtin-page-cleanups.d.ts +19 -0
- package/dist/browser/builtin-page-cleanups.js +111 -0
- package/dist/browser/builtin-page-cleanups.js.map +1 -0
- package/dist/browser/chrome-process.d.ts +55 -0
- package/dist/browser/chrome-process.js +288 -0
- package/dist/browser/chrome-process.js.map +1 -0
- package/dist/browser/dispatch.d.ts +32 -0
- package/dist/browser/dispatch.js +582 -0
- package/dist/browser/dispatch.js.map +1 -0
- package/dist/browser/dom-helpers.d.ts +68 -0
- package/dist/browser/dom-helpers.js +477 -0
- package/dist/browser/dom-helpers.js.map +1 -0
- package/dist/browser/expect.d.ts +66 -0
- package/dist/browser/expect.js +314 -0
- package/dist/browser/expect.js.map +1 -0
- package/dist/browser/humanize.d.ts +56 -0
- package/dist/browser/humanize.js +216 -0
- package/dist/browser/humanize.js.map +1 -0
- package/dist/browser/locator-resolver.d.ts +88 -0
- package/dist/browser/locator-resolver.js +302 -0
- package/dist/browser/locator-resolver.js.map +1 -0
- package/dist/browser/manager.d.ts +95 -0
- package/dist/browser/manager.js +389 -0
- package/dist/browser/manager.js.map +1 -0
- package/dist/browser/script-runner.d.ts +117 -0
- package/dist/browser/script-runner.js +305 -0
- package/dist/browser/script-runner.js.map +1 -0
- package/dist/browser/selectors.d.ts +41 -0
- package/dist/browser/selectors.js +165 -0
- package/dist/browser/selectors.js.map +1 -0
- package/dist/browser/snapshot.d.ts +129 -0
- package/dist/browser/snapshot.js +504 -0
- package/dist/browser/snapshot.js.map +1 -0
- package/dist/browser/workspace-lock.d.ts +37 -0
- package/dist/browser/workspace-lock.js +286 -0
- package/dist/browser/workspace-lock.js.map +1 -0
- package/dist/center/center-client.d.ts +124 -0
- package/dist/center/center-client.js +316 -0
- package/dist/center/center-client.js.map +1 -0
- package/dist/center/center-frontend.d.ts +92 -0
- package/dist/center/center-frontend.js +459 -0
- package/dist/center/center-frontend.js.map +1 -0
- package/dist/center/session-sync.d.ts +85 -0
- package/dist/center/session-sync.js +345 -0
- package/dist/center/session-sync.js.map +1 -0
- package/dist/config/center-config.d.ts +60 -0
- package/dist/config/center-config.js +92 -0
- package/dist/config/center-config.js.map +1 -0
- package/dist/config/types.d.ts +93 -0
- package/dist/config/types.js +136 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +395 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/client.d.ts +24 -0
- package/dist/llm/client.js +696 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/message-optimizer.d.ts +50 -0
- package/dist/llm/message-optimizer.js +337 -0
- package/dist/llm/message-optimizer.js.map +1 -0
- package/dist/llm/tools.d.ts +37 -0
- package/dist/llm/tools.js +895 -0
- package/dist/llm/tools.js.map +1 -0
- package/dist/llm/types.d.ts +96 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/logging/logger.d.ts +17 -0
- package/dist/logging/logger.js +54 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/scripts/migrate-history-to-store.d.ts +2 -0
- package/dist/scripts/migrate-history-to-store.js +250 -0
- package/dist/scripts/migrate-history-to-store.js.map +1 -0
- package/dist/telegram/bot.d.ts +28 -0
- package/dist/telegram/bot.js +546 -0
- package/dist/telegram/bot.js.map +1 -0
- package/dist/tui/tui.d.ts +12 -0
- package/dist/tui/tui.js +177 -0
- package/dist/tui/tui.js.map +1 -0
- package/dist/utils/safe-slice.d.ts +25 -0
- package/dist/utils/safe-slice.js +43 -0
- package/dist/utils/safe-slice.js.map +1 -0
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts +26 -0
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/admin-broadcast.js +7 -0
- package/node_modules/dp-shared/dist/admin-broadcast.js.map +1 -0
- package/node_modules/dp-shared/dist/audit-contracts.d.ts +41 -0
- package/node_modules/dp-shared/dist/audit-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/audit-contracts.js +30 -0
- package/node_modules/dp-shared/dist/audit-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/configs-contracts.d.ts +187 -0
- package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/configs-contracts.js +165 -0
- package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/db-rows.d.ts +293 -0
- package/node_modules/dp-shared/dist/db-rows.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/db-rows.js +222 -0
- package/node_modules/dp-shared/dist/db-rows.js.map +1 -0
- package/node_modules/dp-shared/dist/deploy-contracts.d.ts +34 -0
- package/node_modules/dp-shared/dist/deploy-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/deploy-contracts.js +32 -0
- package/node_modules/dp-shared/dist/deploy-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/domain.d.ts +144 -0
- package/node_modules/dp-shared/dist/domain.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/domain.js +81 -0
- package/node_modules/dp-shared/dist/domain.js.map +1 -0
- package/node_modules/dp-shared/dist/identities.d.ts +35 -0
- package/node_modules/dp-shared/dist/identities.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/identities.js +27 -0
- package/node_modules/dp-shared/dist/identities.js.map +1 -0
- package/node_modules/dp-shared/dist/index.d.ts +24 -0
- package/node_modules/dp-shared/dist/index.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/index.js +24 -0
- package/node_modules/dp-shared/dist/index.js.map +1 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts +459 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/rest-contracts.js +318 -0
- package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts +210 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/task-history-contracts.js +99 -0
- package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +212 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.js +193 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/ws-protocol.d.ts +839 -0
- package/node_modules/dp-shared/dist/ws-protocol.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/ws-protocol.js +264 -0
- package/node_modules/dp-shared/dist/ws-protocol.js.map +1 -0
- package/node_modules/dp-shared/package.json +31 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +191 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/locales/index.cjs +17 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +32 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +135 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5138 -0
- package/node_modules/zod/src/v4/classic/checks.ts +32 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +70 -0
- package/node_modules/zod/src/v4/classic/errors.ts +82 -0
- package/node_modules/zod/src/v4/classic/external.ts +52 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +82 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1823 -0
- package/node_modules/zod/src/v4/core/checks.ts +1293 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +153 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +455 -0
- package/node_modules/zod/src/v4/core/index.ts +16 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
- package/node_modules/zod/src/v4/core/parse.ts +195 -0
- package/node_modules/zod/src/v4/core/regexes.ts +190 -0
- package/node_modules/zod/src/v4/core/registries.ts +105 -0
- package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
- package/node_modules/zod/src/v4/core/util.ts +983 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +115 -0
- package/node_modules/zod/src/v4/locales/az.ts +111 -0
- package/node_modules/zod/src/v4/locales/be.ts +176 -0
- package/node_modules/zod/src/v4/locales/bg.ts +128 -0
- package/node_modules/zod/src/v4/locales/ca.ts +116 -0
- package/node_modules/zod/src/v4/locales/cs.ts +118 -0
- package/node_modules/zod/src/v4/locales/da.ts +123 -0
- package/node_modules/zod/src/v4/locales/de.ts +116 -0
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +123 -0
- package/node_modules/zod/src/v4/locales/eo.ts +118 -0
- package/node_modules/zod/src/v4/locales/es.ts +141 -0
- package/node_modules/zod/src/v4/locales/fa.ts +126 -0
- package/node_modules/zod/src/v4/locales/fi.ts +121 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
- package/node_modules/zod/src/v4/locales/fr.ts +132 -0
- package/node_modules/zod/src/v4/locales/he.ts +246 -0
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/hu.ts +117 -0
- package/node_modules/zod/src/v4/locales/hy.ts +164 -0
- package/node_modules/zod/src/v4/locales/id.ts +115 -0
- package/node_modules/zod/src/v4/locales/index.ts +52 -0
- package/node_modules/zod/src/v4/locales/is.ts +119 -0
- package/node_modules/zod/src/v4/locales/it.ts +116 -0
- package/node_modules/zod/src/v4/locales/ja.ts +114 -0
- package/node_modules/zod/src/v4/locales/ka.ts +123 -0
- package/node_modules/zod/src/v4/locales/kh.ts +7 -0
- package/node_modules/zod/src/v4/locales/km.ts +119 -0
- package/node_modules/zod/src/v4/locales/ko.ts +121 -0
- package/node_modules/zod/src/v4/locales/lt.ts +239 -0
- package/node_modules/zod/src/v4/locales/mk.ts +118 -0
- package/node_modules/zod/src/v4/locales/ms.ts +115 -0
- package/node_modules/zod/src/v4/locales/nl.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +116 -0
- package/node_modules/zod/src/v4/locales/ota.ts +117 -0
- package/node_modules/zod/src/v4/locales/pl.ts +118 -0
- package/node_modules/zod/src/v4/locales/ps.ts +126 -0
- package/node_modules/zod/src/v4/locales/pt.ts +116 -0
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/ru.ts +176 -0
- package/node_modules/zod/src/v4/locales/sl.ts +118 -0
- package/node_modules/zod/src/v4/locales/sv.ts +119 -0
- package/node_modules/zod/src/v4/locales/ta.ts +118 -0
- package/node_modules/zod/src/v4/locales/th.ts +119 -0
- package/node_modules/zod/src/v4/locales/tr.ts +111 -0
- package/node_modules/zod/src/v4/locales/ua.ts +7 -0
- package/node_modules/zod/src/v4/locales/uk.ts +117 -0
- package/node_modules/zod/src/v4/locales/ur.ts +119 -0
- package/node_modules/zod/src/v4/locales/uz.ts +117 -0
- package/node_modules/zod/src/v4/locales/vi.ts +117 -0
- package/node_modules/zod/src/v4/locales/yo.ts +124 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
- package/node_modules/zod/src/v4/mini/external.ts +41 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +66 -0
- package/node_modules/zod/src/v4/mini/parse.ts +14 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
- package/node_modules/zod/src/v4-mini/index.ts +3 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +112 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3777 -0
- package/node_modules/zod/v3/types.d.cts +1034 -0
- package/node_modules/zod/v3/types.d.ts +1034 -0
- package/node_modules/zod/v3/types.js +3695 -0
- package/node_modules/zod/v4/classic/checks.cjs +33 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +61 -0
- package/node_modules/zod/v4/classic/compat.d.cts +50 -0
- package/node_modules/zod/v4/classic/compat.d.ts +50 -0
- package/node_modules/zod/v4/classic/compat.js +31 -0
- package/node_modules/zod/v4/classic/errors.cjs +74 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +48 -0
- package/node_modules/zod/v4/classic/external.cjs +73 -0
- package/node_modules/zod/v4/classic/external.d.cts +16 -0
- package/node_modules/zod/v4/classic/external.d.ts +16 -0
- package/node_modules/zod/v4/classic/external.js +20 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +41 -0
- package/node_modules/zod/v4/classic/parse.d.cts +31 -0
- package/node_modules/zod/v4/classic/parse.d.ts +31 -0
- package/node_modules/zod/v4/classic/parse.js +15 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
- package/node_modules/zod/v4/classic/schemas.js +1395 -0
- package/node_modules/zod/v4/core/api.cjs +1227 -0
- package/node_modules/zod/v4/core/api.d.cts +325 -0
- package/node_modules/zod/v4/core/api.d.ts +325 -0
- package/node_modules/zod/v4/core/api.js +1087 -0
- package/node_modules/zod/v4/core/checks.cjs +601 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +575 -0
- package/node_modules/zod/v4/core/core.cjs +85 -0
- package/node_modules/zod/v4/core/core.d.cts +70 -0
- package/node_modules/zod/v4/core/core.d.ts +70 -0
- package/node_modules/zod/v4/core/core.js +78 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +216 -0
- package/node_modules/zod/v4/core/errors.d.cts +221 -0
- package/node_modules/zod/v4/core/errors.d.ts +221 -0
- package/node_modules/zod/v4/core/errors.js +185 -0
- package/node_modules/zod/v4/core/index.cjs +47 -0
- package/node_modules/zod/v4/core/index.d.cts +16 -0
- package/node_modules/zod/v4/core/index.d.ts +16 -0
- package/node_modules/zod/v4/core/index.js +16 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +131 -0
- package/node_modules/zod/v4/core/parse.d.cts +49 -0
- package/node_modules/zod/v4/core/parse.d.ts +49 -0
- package/node_modules/zod/v4/core/parse.js +93 -0
- package/node_modules/zod/v4/core/regexes.cjs +172 -0
- package/node_modules/zod/v4/core/regexes.d.cts +85 -0
- package/node_modules/zod/v4/core/regexes.d.ts +85 -0
- package/node_modules/zod/v4/core/regexes.js +139 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +2270 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
- package/node_modules/zod/v4/core/schemas.js +2239 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.js +448 -0
- package/node_modules/zod/v4/core/util.cjs +734 -0
- package/node_modules/zod/v4/core/util.d.cts +200 -0
- package/node_modules/zod/v4/core/util.d.ts +200 -0
- package/node_modules/zod/v4/core/util.js +674 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +133 -0
- package/node_modules/zod/v4/locales/ar.d.cts +5 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +106 -0
- package/node_modules/zod/v4/locales/az.cjs +132 -0
- package/node_modules/zod/v4/locales/az.d.cts +5 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +105 -0
- package/node_modules/zod/v4/locales/be.cjs +183 -0
- package/node_modules/zod/v4/locales/be.d.cts +5 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +156 -0
- package/node_modules/zod/v4/locales/bg.cjs +147 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +120 -0
- package/node_modules/zod/v4/locales/ca.cjs +134 -0
- package/node_modules/zod/v4/locales/ca.d.cts +5 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +107 -0
- package/node_modules/zod/v4/locales/cs.cjs +138 -0
- package/node_modules/zod/v4/locales/cs.d.cts +5 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +111 -0
- package/node_modules/zod/v4/locales/da.cjs +142 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +115 -0
- package/node_modules/zod/v4/locales/de.cjs +135 -0
- package/node_modules/zod/v4/locales/de.d.cts +5 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +108 -0
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +140 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +4 -0
- package/node_modules/zod/v4/locales/en.js +113 -0
- package/node_modules/zod/v4/locales/eo.cjs +136 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +4 -0
- package/node_modules/zod/v4/locales/eo.js +109 -0
- package/node_modules/zod/v4/locales/es.cjs +159 -0
- package/node_modules/zod/v4/locales/es.d.cts +5 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +132 -0
- package/node_modules/zod/v4/locales/fa.cjs +141 -0
- package/node_modules/zod/v4/locales/fa.d.cts +5 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +114 -0
- package/node_modules/zod/v4/locales/fi.cjs +139 -0
- package/node_modules/zod/v4/locales/fi.d.cts +5 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +112 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +107 -0
- package/node_modules/zod/v4/locales/fr.cjs +152 -0
- package/node_modules/zod/v4/locales/fr.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +125 -0
- package/node_modules/zod/v4/locales/he.cjs +241 -0
- package/node_modules/zod/v4/locales/he.d.cts +5 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +214 -0
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/hu.cjs +135 -0
- package/node_modules/zod/v4/locales/hu.d.cts +5 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +108 -0
- package/node_modules/zod/v4/locales/hy.cjs +174 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +147 -0
- package/node_modules/zod/v4/locales/id.cjs +133 -0
- package/node_modules/zod/v4/locales/id.d.cts +5 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +106 -0
- package/node_modules/zod/v4/locales/index.cjs +111 -0
- package/node_modules/zod/v4/locales/index.d.cts +52 -0
- package/node_modules/zod/v4/locales/index.d.ts +52 -0
- package/node_modules/zod/v4/locales/index.js +52 -0
- package/node_modules/zod/v4/locales/is.cjs +136 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +109 -0
- package/node_modules/zod/v4/locales/it.cjs +135 -0
- package/node_modules/zod/v4/locales/it.d.cts +5 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +108 -0
- package/node_modules/zod/v4/locales/ja.cjs +134 -0
- package/node_modules/zod/v4/locales/ja.d.cts +5 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +107 -0
- package/node_modules/zod/v4/locales/ka.cjs +139 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +112 -0
- package/node_modules/zod/v4/locales/kh.cjs +12 -0
- package/node_modules/zod/v4/locales/kh.d.cts +5 -0
- package/node_modules/zod/v4/locales/kh.d.ts +5 -0
- package/node_modules/zod/v4/locales/kh.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +137 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +110 -0
- package/node_modules/zod/v4/locales/ko.cjs +138 -0
- package/node_modules/zod/v4/locales/ko.d.cts +5 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +111 -0
- package/node_modules/zod/v4/locales/lt.cjs +230 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +203 -0
- package/node_modules/zod/v4/locales/mk.cjs +136 -0
- package/node_modules/zod/v4/locales/mk.d.cts +5 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +109 -0
- package/node_modules/zod/v4/locales/ms.cjs +134 -0
- package/node_modules/zod/v4/locales/ms.d.cts +5 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +107 -0
- package/node_modules/zod/v4/locales/nl.cjs +137 -0
- package/node_modules/zod/v4/locales/nl.d.cts +5 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +110 -0
- package/node_modules/zod/v4/locales/no.cjs +135 -0
- package/node_modules/zod/v4/locales/no.d.cts +5 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +108 -0
- package/node_modules/zod/v4/locales/ota.cjs +136 -0
- package/node_modules/zod/v4/locales/ota.d.cts +5 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +109 -0
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +136 -0
- package/node_modules/zod/v4/locales/pl.d.cts +5 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +109 -0
- package/node_modules/zod/v4/locales/ps.cjs +141 -0
- package/node_modules/zod/v4/locales/ps.d.cts +5 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +114 -0
- package/node_modules/zod/v4/locales/pt.cjs +135 -0
- package/node_modules/zod/v4/locales/pt.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +108 -0
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/ru.cjs +183 -0
- package/node_modules/zod/v4/locales/ru.d.cts +5 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +156 -0
- package/node_modules/zod/v4/locales/sl.cjs +136 -0
- package/node_modules/zod/v4/locales/sl.d.cts +5 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +109 -0
- package/node_modules/zod/v4/locales/sv.cjs +137 -0
- package/node_modules/zod/v4/locales/sv.d.cts +5 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +110 -0
- package/node_modules/zod/v4/locales/ta.cjs +137 -0
- package/node_modules/zod/v4/locales/ta.d.cts +5 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +110 -0
- package/node_modules/zod/v4/locales/th.cjs +137 -0
- package/node_modules/zod/v4/locales/th.d.cts +5 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +110 -0
- package/node_modules/zod/v4/locales/tr.cjs +132 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +4 -0
- package/node_modules/zod/v4/locales/tr.js +105 -0
- package/node_modules/zod/v4/locales/ua.cjs +12 -0
- package/node_modules/zod/v4/locales/ua.d.cts +5 -0
- package/node_modules/zod/v4/locales/ua.d.ts +5 -0
- package/node_modules/zod/v4/locales/ua.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +135 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +108 -0
- package/node_modules/zod/v4/locales/ur.cjs +137 -0
- package/node_modules/zod/v4/locales/ur.d.cts +5 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +110 -0
- package/node_modules/zod/v4/locales/uz.cjs +137 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +110 -0
- package/node_modules/zod/v4/locales/vi.cjs +135 -0
- package/node_modules/zod/v4/locales/vi.d.cts +5 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +108 -0
- package/node_modules/zod/v4/locales/yo.cjs +134 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +107 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +109 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +107 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +52 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +22 -0
- package/node_modules/zod/v4/mini/external.cjs +63 -0
- package/node_modules/zod/v4/mini/external.d.cts +13 -0
- package/node_modules/zod/v4/mini/external.d.ts +13 -0
- package/node_modules/zod/v4/mini/external.js +14 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +64 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +34 -0
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +16 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
- package/node_modules/zod/v4/mini/schemas.js +961 -0
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +32 -0
- package/node_modules/zod/v4-mini/index.d.cts +3 -0
- package/node_modules/zod/v4-mini/index.d.ts +3 -0
- package/node_modules/zod/v4-mini/index.js +3 -0
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/package.json +69 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
export function createLlmClient(config) {
|
|
6
|
+
let client;
|
|
7
|
+
if (config.llm.protocol === "openai") {
|
|
8
|
+
client = new OpenAIClient(config);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
client = new ClaudeClient(config);
|
|
12
|
+
}
|
|
13
|
+
if (config.debug) {
|
|
14
|
+
return new DebugLlmClient(client, config.workspace);
|
|
15
|
+
}
|
|
16
|
+
return client;
|
|
17
|
+
}
|
|
18
|
+
// --- OpenAI Protocol ---
|
|
19
|
+
/**
|
|
20
|
+
* Hardcoded reasoning effort sent on every OpenAI chat.completions
|
|
21
|
+
* request. `medium` was chosen because (a) it matches the upstream
|
|
22
|
+
* default's observed latency, (b) explicitly setting a value pins
|
|
23
|
+
* sub2api's gpt-5.5 routing to a predictable upstream account pool
|
|
24
|
+
* (omitting the param landed requests in an unstable pool with
|
|
25
|
+
* occasional ~250s stalls), and (c) keeps every per-instance JSON
|
|
26
|
+
* config identical across Claude/OpenAI agents.
|
|
27
|
+
*
|
|
28
|
+
* Assumes the configured model accepts `reasoning_effort` — true for
|
|
29
|
+
* gpt-5.x. Plain gpt-4o etc. would 400; revisit if that ever ships.
|
|
30
|
+
*/
|
|
31
|
+
const OPENAI_REASONING_EFFORT = "none";
|
|
32
|
+
class OpenAIClient {
|
|
33
|
+
client;
|
|
34
|
+
model;
|
|
35
|
+
maxTokens;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
let baseURL = config.llm.baseUrl.replace(/\/+$/, "");
|
|
38
|
+
if (!baseURL.endsWith("/v1")) {
|
|
39
|
+
baseURL += "/v1";
|
|
40
|
+
}
|
|
41
|
+
this.client = new OpenAI({
|
|
42
|
+
apiKey: config.llm.apiKey,
|
|
43
|
+
baseURL,
|
|
44
|
+
});
|
|
45
|
+
this.model = config.llm.model;
|
|
46
|
+
this.maxTokens = config.llm.maxTokens;
|
|
47
|
+
}
|
|
48
|
+
async chat(messages, tools, systemPrompt, cacheHints, signal) {
|
|
49
|
+
const openaiMessages = this.convertMessages(messages, systemPrompt);
|
|
50
|
+
const openaiTools = tools?.map((t) => this.convertTool(t));
|
|
51
|
+
const params = {
|
|
52
|
+
model: this.model,
|
|
53
|
+
messages: openaiMessages,
|
|
54
|
+
};
|
|
55
|
+
if (this.maxTokens) {
|
|
56
|
+
params.max_tokens = this.maxTokens;
|
|
57
|
+
}
|
|
58
|
+
if (openaiTools && openaiTools.length > 0) {
|
|
59
|
+
params.tools = openaiTools;
|
|
60
|
+
}
|
|
61
|
+
if (cacheHints?.sessionId) {
|
|
62
|
+
// Official OpenAI param (drives their prompt cache routing) and also
|
|
63
|
+
// matches sub2api's priority-3 sticky-session signal.
|
|
64
|
+
params.prompt_cache_key = cacheHints.sessionId;
|
|
65
|
+
}
|
|
66
|
+
params.reasoning_effort = OPENAI_REASONING_EFFORT;
|
|
67
|
+
const response = await this.client.chat.completions.create(params, signal ? { signal } : undefined);
|
|
68
|
+
const choice = response.choices[0];
|
|
69
|
+
const content = choice.message.content || "";
|
|
70
|
+
const toolCalls = (choice.message.tool_calls || []).map((tc) => ({
|
|
71
|
+
id: tc.id,
|
|
72
|
+
name: tc.function.name,
|
|
73
|
+
arguments: JSON.parse(tc.function.arguments),
|
|
74
|
+
}));
|
|
75
|
+
let stopReason = "stop";
|
|
76
|
+
if (choice.finish_reason === "tool_calls") {
|
|
77
|
+
stopReason = "tool_use";
|
|
78
|
+
}
|
|
79
|
+
else if (choice.finish_reason === "length") {
|
|
80
|
+
stopReason = "length";
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
content,
|
|
84
|
+
toolCalls,
|
|
85
|
+
stopReason,
|
|
86
|
+
usage: extractOpenAIUsage(response.usage),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async *chatStream(messages, tools, systemPrompt, cacheHints, signal) {
|
|
90
|
+
const openaiMessages = this.convertMessages(messages, systemPrompt);
|
|
91
|
+
const openaiTools = tools?.map((t) => this.convertTool(t));
|
|
92
|
+
const params = {
|
|
93
|
+
model: this.model,
|
|
94
|
+
messages: openaiMessages,
|
|
95
|
+
stream: true,
|
|
96
|
+
};
|
|
97
|
+
if (this.maxTokens) {
|
|
98
|
+
params.max_tokens = this.maxTokens;
|
|
99
|
+
}
|
|
100
|
+
if (openaiTools && openaiTools.length > 0) {
|
|
101
|
+
params.tools = openaiTools;
|
|
102
|
+
}
|
|
103
|
+
if (cacheHints?.sessionId) {
|
|
104
|
+
params.prompt_cache_key = cacheHints.sessionId;
|
|
105
|
+
}
|
|
106
|
+
params.reasoning_effort = OPENAI_REASONING_EFFORT;
|
|
107
|
+
const stream = await this.client.chat.completions.create(params, signal ? { signal } : undefined);
|
|
108
|
+
// Track tool calls being assembled across chunks
|
|
109
|
+
const pendingToolCalls = new Map();
|
|
110
|
+
for await (const chunk of stream) {
|
|
111
|
+
const delta = chunk.choices?.[0]?.delta;
|
|
112
|
+
if (!delta)
|
|
113
|
+
continue;
|
|
114
|
+
// Text content
|
|
115
|
+
if (delta.content) {
|
|
116
|
+
yield { type: "text_delta", text: delta.content };
|
|
117
|
+
}
|
|
118
|
+
// Tool calls (streamed incrementally)
|
|
119
|
+
if (delta.tool_calls) {
|
|
120
|
+
for (const tc of delta.tool_calls) {
|
|
121
|
+
const idx = tc.index;
|
|
122
|
+
if (tc.id) {
|
|
123
|
+
// New tool call starting
|
|
124
|
+
pendingToolCalls.set(idx, {
|
|
125
|
+
id: tc.id,
|
|
126
|
+
name: tc.function?.name || "",
|
|
127
|
+
args: tc.function?.arguments || "",
|
|
128
|
+
});
|
|
129
|
+
yield {
|
|
130
|
+
type: "tool_call_start",
|
|
131
|
+
toolCall: { id: tc.id, name: tc.function?.name || "", arguments: {} },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// Continuing existing tool call
|
|
136
|
+
const pending = pendingToolCalls.get(idx);
|
|
137
|
+
if (pending) {
|
|
138
|
+
if (tc.function?.name)
|
|
139
|
+
pending.name += tc.function.name;
|
|
140
|
+
if (tc.function?.arguments)
|
|
141
|
+
pending.args += tc.function.arguments;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Check if stream is done
|
|
147
|
+
if (chunk.choices?.[0]?.finish_reason) {
|
|
148
|
+
// Emit completed tool calls
|
|
149
|
+
for (const [, pending] of pendingToolCalls) {
|
|
150
|
+
try {
|
|
151
|
+
yield {
|
|
152
|
+
type: "tool_call_end",
|
|
153
|
+
toolCall: {
|
|
154
|
+
id: pending.id,
|
|
155
|
+
name: pending.name,
|
|
156
|
+
arguments: JSON.parse(pending.args || "{}"),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
yield {
|
|
162
|
+
type: "tool_call_end",
|
|
163
|
+
toolCall: { id: pending.id, name: pending.name, arguments: {} },
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
yield { type: "done" };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
convertMessages(messages, systemPrompt) {
|
|
172
|
+
const result = [];
|
|
173
|
+
if (systemPrompt) {
|
|
174
|
+
result.push({ role: "system", content: systemPrompt });
|
|
175
|
+
}
|
|
176
|
+
for (const msg of messages) {
|
|
177
|
+
if (msg.role === "tool" && msg.toolCallId) {
|
|
178
|
+
result.push({
|
|
179
|
+
role: "tool",
|
|
180
|
+
tool_call_id: msg.toolCallId,
|
|
181
|
+
content: typeof msg.content === "string"
|
|
182
|
+
? msg.content
|
|
183
|
+
: JSON.stringify(msg.content),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else if (msg.role === "assistant" && msg.toolCalls?.length) {
|
|
187
|
+
result.push({
|
|
188
|
+
role: "assistant",
|
|
189
|
+
content: typeof msg.content === "string" ? msg.content || null : null,
|
|
190
|
+
tool_calls: msg.toolCalls.map((tc) => ({
|
|
191
|
+
id: tc.id,
|
|
192
|
+
type: "function",
|
|
193
|
+
function: {
|
|
194
|
+
name: tc.name,
|
|
195
|
+
arguments: JSON.stringify(tc.arguments),
|
|
196
|
+
},
|
|
197
|
+
})),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const content = this.convertContent(msg.content);
|
|
202
|
+
result.push({
|
|
203
|
+
role: msg.role === "system" ? "system" : msg.role,
|
|
204
|
+
content,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
convertContent(content) {
|
|
211
|
+
if (typeof content === "string")
|
|
212
|
+
return content;
|
|
213
|
+
return content.map((block) => {
|
|
214
|
+
if (block.type === "image" && block.imageData) {
|
|
215
|
+
return {
|
|
216
|
+
type: "image_url",
|
|
217
|
+
image_url: {
|
|
218
|
+
url: `data:${block.mediaType || "image/png"};base64,${block.imageData}`,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return { type: "text", text: block.text || "" };
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
convertTool(tool) {
|
|
226
|
+
return {
|
|
227
|
+
type: "function",
|
|
228
|
+
function: {
|
|
229
|
+
name: tool.name,
|
|
230
|
+
description: tool.description,
|
|
231
|
+
parameters: tool.parameters,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Pull token counters from an OpenAI chat.completions response.usage. The
|
|
238
|
+
* automatic prompt cache (no cache_control needed; kicks in past ~1024 tokens
|
|
239
|
+
* of stable prefix) reports cached input under `prompt_tokens_details.cached_tokens`
|
|
240
|
+
* — we surface that as cacheReadInputTokens so dipclaw's logs / monitoring
|
|
241
|
+
* code can treat the two providers uniformly.
|
|
242
|
+
*
|
|
243
|
+
* OpenAI has no separate "cache write" concept — the first request just pays
|
|
244
|
+
* full rate and a later identical-prefix request gets the cached read.
|
|
245
|
+
*/
|
|
246
|
+
export function extractOpenAIUsage(usage) {
|
|
247
|
+
if (!usage || typeof usage !== "object")
|
|
248
|
+
return undefined;
|
|
249
|
+
const u = usage;
|
|
250
|
+
if (typeof u.prompt_tokens !== "number")
|
|
251
|
+
return undefined;
|
|
252
|
+
return {
|
|
253
|
+
inputTokens: u.prompt_tokens,
|
|
254
|
+
outputTokens: u.completion_tokens ?? 0,
|
|
255
|
+
cacheReadInputTokens: u.prompt_tokens_details?.cached_tokens ?? 0,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
// --- Claude/Anthropic Protocol ---
|
|
259
|
+
/** Anthropic API requires max_tokens — default to 16384 if not configured */
|
|
260
|
+
const CLAUDE_DEFAULT_MAX_TOKENS = 16384;
|
|
261
|
+
class ClaudeClient {
|
|
262
|
+
client;
|
|
263
|
+
model;
|
|
264
|
+
maxTokens;
|
|
265
|
+
deviceId;
|
|
266
|
+
constructor(config) {
|
|
267
|
+
this.client = new Anthropic({
|
|
268
|
+
apiKey: config.llm.apiKey,
|
|
269
|
+
baseURL: config.llm.baseUrl,
|
|
270
|
+
});
|
|
271
|
+
this.model = config.llm.model;
|
|
272
|
+
this.maxTokens = config.llm.maxTokens ?? CLAUDE_DEFAULT_MAX_TOKENS;
|
|
273
|
+
// Stable per-instance device tag for sub2api's metadata.user_id; the
|
|
274
|
+
// sticky-session hash only keys off session_id but device_id is part
|
|
275
|
+
// of the format sub2api parses.
|
|
276
|
+
this.deviceId = `dipclaw-${config.name || "default"}`;
|
|
277
|
+
}
|
|
278
|
+
async chat(messages, tools, systemPrompt, cacheHints, signal) {
|
|
279
|
+
const anthropicMessages = this.convertMessages(messages);
|
|
280
|
+
if (cacheHints?.cacheMessages) {
|
|
281
|
+
applyMessagesCacheBreakpoint(anthropicMessages);
|
|
282
|
+
}
|
|
283
|
+
const anthropicTools = tools?.map((t) => this.convertTool(t));
|
|
284
|
+
if (cacheHints?.cacheTools && anthropicTools && anthropicTools.length > 0) {
|
|
285
|
+
applyToolsCacheBreakpoint(anthropicTools);
|
|
286
|
+
}
|
|
287
|
+
const params = {
|
|
288
|
+
model: this.model,
|
|
289
|
+
max_tokens: this.maxTokens,
|
|
290
|
+
messages: anthropicMessages,
|
|
291
|
+
};
|
|
292
|
+
const systemValue = buildSystemValue(systemPrompt, cacheHints);
|
|
293
|
+
if (systemValue !== undefined) {
|
|
294
|
+
params.system = systemValue;
|
|
295
|
+
}
|
|
296
|
+
if (anthropicTools && anthropicTools.length > 0) {
|
|
297
|
+
params.tools = anthropicTools;
|
|
298
|
+
}
|
|
299
|
+
const userIdTag = this.buildUserIdTag(cacheHints?.sessionId);
|
|
300
|
+
if (userIdTag) {
|
|
301
|
+
params.metadata = { user_id: userIdTag };
|
|
302
|
+
}
|
|
303
|
+
const response = await this.client.messages.create(params, signal ? { signal } : undefined);
|
|
304
|
+
let content = "";
|
|
305
|
+
const toolCalls = [];
|
|
306
|
+
for (const block of response.content) {
|
|
307
|
+
if (block.type === "text") {
|
|
308
|
+
content += block.text;
|
|
309
|
+
}
|
|
310
|
+
else if (block.type === "tool_use") {
|
|
311
|
+
toolCalls.push({
|
|
312
|
+
id: block.id,
|
|
313
|
+
name: block.name,
|
|
314
|
+
arguments: block.input,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
let stopReason = "stop";
|
|
319
|
+
if (response.stop_reason === "tool_use") {
|
|
320
|
+
stopReason = "tool_use";
|
|
321
|
+
}
|
|
322
|
+
else if (response.stop_reason === "max_tokens") {
|
|
323
|
+
stopReason = "length";
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
content,
|
|
327
|
+
toolCalls,
|
|
328
|
+
stopReason,
|
|
329
|
+
usage: extractClaudeUsage(response.usage),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
async *chatStream(messages, tools, systemPrompt, cacheHints, signal) {
|
|
333
|
+
const anthropicMessages = this.convertMessages(messages);
|
|
334
|
+
if (cacheHints?.cacheMessages) {
|
|
335
|
+
applyMessagesCacheBreakpoint(anthropicMessages);
|
|
336
|
+
}
|
|
337
|
+
const anthropicTools = tools?.map((t) => this.convertTool(t));
|
|
338
|
+
if (cacheHints?.cacheTools && anthropicTools && anthropicTools.length > 0) {
|
|
339
|
+
applyToolsCacheBreakpoint(anthropicTools);
|
|
340
|
+
}
|
|
341
|
+
const params = {
|
|
342
|
+
model: this.model,
|
|
343
|
+
max_tokens: this.maxTokens,
|
|
344
|
+
messages: anthropicMessages,
|
|
345
|
+
stream: true,
|
|
346
|
+
};
|
|
347
|
+
const systemValue = buildSystemValue(systemPrompt, cacheHints);
|
|
348
|
+
if (systemValue !== undefined) {
|
|
349
|
+
params.system = systemValue;
|
|
350
|
+
}
|
|
351
|
+
if (anthropicTools && anthropicTools.length > 0) {
|
|
352
|
+
params.tools = anthropicTools;
|
|
353
|
+
}
|
|
354
|
+
const userIdTag = this.buildUserIdTag(cacheHints?.sessionId);
|
|
355
|
+
if (userIdTag) {
|
|
356
|
+
params.metadata = { user_id: userIdTag };
|
|
357
|
+
}
|
|
358
|
+
const stream = this.client.messages.stream(params, signal ? { signal } : undefined);
|
|
359
|
+
let currentToolId = "";
|
|
360
|
+
let currentToolName = "";
|
|
361
|
+
let currentToolInput = "";
|
|
362
|
+
for await (const event of stream) {
|
|
363
|
+
if (event.type === "content_block_start") {
|
|
364
|
+
const block = event.content_block;
|
|
365
|
+
if (block?.type === "tool_use") {
|
|
366
|
+
currentToolId = block.id;
|
|
367
|
+
currentToolName = block.name;
|
|
368
|
+
currentToolInput = "";
|
|
369
|
+
yield {
|
|
370
|
+
type: "tool_call_start",
|
|
371
|
+
toolCall: { id: block.id, name: block.name, arguments: {} },
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else if (event.type === "content_block_delta") {
|
|
376
|
+
const delta = event.delta;
|
|
377
|
+
if (delta?.type === "text_delta") {
|
|
378
|
+
yield { type: "text_delta", text: delta.text };
|
|
379
|
+
}
|
|
380
|
+
else if (delta?.type === "input_json_delta") {
|
|
381
|
+
currentToolInput += delta.partial_json;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else if (event.type === "content_block_stop") {
|
|
385
|
+
if (currentToolId) {
|
|
386
|
+
try {
|
|
387
|
+
yield {
|
|
388
|
+
type: "tool_call_end",
|
|
389
|
+
toolCall: {
|
|
390
|
+
id: currentToolId,
|
|
391
|
+
name: currentToolName,
|
|
392
|
+
arguments: JSON.parse(currentToolInput || "{}"),
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
yield {
|
|
398
|
+
type: "tool_call_end",
|
|
399
|
+
toolCall: { id: currentToolId, name: currentToolName, arguments: {} },
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
currentToolId = "";
|
|
403
|
+
currentToolName = "";
|
|
404
|
+
currentToolInput = "";
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
else if (event.type === "message_stop") {
|
|
408
|
+
yield { type: "done" };
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
convertMessages(messages) {
|
|
413
|
+
const result = [];
|
|
414
|
+
for (let i = 0; i < messages.length; i++) {
|
|
415
|
+
const msg = messages[i];
|
|
416
|
+
if (msg.role === "system")
|
|
417
|
+
continue;
|
|
418
|
+
if (msg.role === "tool" && msg.toolCallId) {
|
|
419
|
+
// Collect all consecutive tool messages into a single user message
|
|
420
|
+
const toolResults = [];
|
|
421
|
+
while (i < messages.length && messages[i].role === "tool" && messages[i].toolCallId) {
|
|
422
|
+
const toolMsg = messages[i];
|
|
423
|
+
toolResults.push({
|
|
424
|
+
type: "tool_result",
|
|
425
|
+
tool_use_id: toolMsg.toolCallId,
|
|
426
|
+
content: typeof toolMsg.content === "string"
|
|
427
|
+
? toolMsg.content
|
|
428
|
+
: JSON.stringify(toolMsg.content),
|
|
429
|
+
});
|
|
430
|
+
i++;
|
|
431
|
+
}
|
|
432
|
+
i--; // adjust for the outer loop increment
|
|
433
|
+
result.push({
|
|
434
|
+
role: "user",
|
|
435
|
+
content: toolResults,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else if (msg.role === "assistant" && msg.toolCalls?.length) {
|
|
439
|
+
const contentBlocks = [];
|
|
440
|
+
if (typeof msg.content === "string" && msg.content) {
|
|
441
|
+
contentBlocks.push({ type: "text", text: msg.content });
|
|
442
|
+
}
|
|
443
|
+
for (const tc of msg.toolCalls) {
|
|
444
|
+
contentBlocks.push({
|
|
445
|
+
type: "tool_use",
|
|
446
|
+
id: tc.id,
|
|
447
|
+
name: tc.name,
|
|
448
|
+
input: tc.arguments,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
result.push({ role: "assistant", content: contentBlocks });
|
|
452
|
+
}
|
|
453
|
+
else if (msg.role === "user") {
|
|
454
|
+
const content = this.convertContent(msg.content);
|
|
455
|
+
result.push({ role: "user", content });
|
|
456
|
+
}
|
|
457
|
+
else if (msg.role === "assistant") {
|
|
458
|
+
result.push({
|
|
459
|
+
role: "assistant",
|
|
460
|
+
content: typeof msg.content === "string"
|
|
461
|
+
? msg.content
|
|
462
|
+
: msg.content.map((b) => ({
|
|
463
|
+
type: "text",
|
|
464
|
+
text: b.text || "",
|
|
465
|
+
})),
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
471
|
+
convertContent(content) {
|
|
472
|
+
if (typeof content === "string")
|
|
473
|
+
return content;
|
|
474
|
+
return content.map((block) => {
|
|
475
|
+
if (block.type === "image" && block.imageData) {
|
|
476
|
+
return {
|
|
477
|
+
type: "image",
|
|
478
|
+
source: {
|
|
479
|
+
type: "base64",
|
|
480
|
+
media_type: (block.mediaType || "image/png"),
|
|
481
|
+
data: block.imageData,
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return { type: "text", text: block.text || "" };
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
convertTool(tool) {
|
|
489
|
+
return {
|
|
490
|
+
name: tool.name,
|
|
491
|
+
description: tool.description,
|
|
492
|
+
input_schema: tool.parameters,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Render the `metadata.user_id` payload sub2api expects (Claude Code ≥
|
|
497
|
+
* 2.1.78 shape). sub2api's sticky-session router keys off the embedded
|
|
498
|
+
* `session_id`; `device_id` and `account_uuid` are part of the format
|
|
499
|
+
* but not used for routing. Returns null when no session id is supplied
|
|
500
|
+
* so we leave the field unset rather than emit a meaningless tag.
|
|
501
|
+
*/
|
|
502
|
+
buildUserIdTag(sessionId) {
|
|
503
|
+
if (!sessionId)
|
|
504
|
+
return null;
|
|
505
|
+
return JSON.stringify({
|
|
506
|
+
device_id: this.deviceId,
|
|
507
|
+
account_uuid: "00000000-0000-0000-0000-000000000000",
|
|
508
|
+
session_id: sessionId,
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
// --- Anthropic cache_control helpers ---
|
|
513
|
+
const EPHEMERAL_CACHE = { type: "ephemeral" };
|
|
514
|
+
/**
|
|
515
|
+
* Pull all four token counters out of an Anthropic response.usage object.
|
|
516
|
+
* The cache_creation/cache_read fields are only present when at least one
|
|
517
|
+
* cache_control breakpoint was used; default to 0 so downstream loggers
|
|
518
|
+
* don't have to handle undefined separately. Without this, our execution
|
|
519
|
+
* logs only see `input_tokens` (the uncached delta) and dramatically
|
|
520
|
+
* under-report real input volume on cached requests.
|
|
521
|
+
*/
|
|
522
|
+
export function extractClaudeUsage(usage) {
|
|
523
|
+
const u = usage;
|
|
524
|
+
return {
|
|
525
|
+
inputTokens: u.input_tokens,
|
|
526
|
+
outputTokens: u.output_tokens,
|
|
527
|
+
cacheCreationInputTokens: u.cache_creation_input_tokens ?? 0,
|
|
528
|
+
cacheReadInputTokens: u.cache_read_input_tokens ?? 0,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Build the `system` field for Anthropic.messages.create. Returns:
|
|
533
|
+
* - undefined when there is no system prompt to send
|
|
534
|
+
* - a plain string when no cache hint is given (cheapest path, current behavior)
|
|
535
|
+
* - a TextBlockParam[] with cache_control on the static head when the caller
|
|
536
|
+
* provided systemStaticChars (the typical path once prompt caching is on).
|
|
537
|
+
*
|
|
538
|
+
* Splitting the string at systemStaticChars keeps the existing single-string
|
|
539
|
+
* `systemPrompt` parameter on LlmClient — callers don't need to thread two
|
|
540
|
+
* separate strings down the stack to participate in caching.
|
|
541
|
+
*/
|
|
542
|
+
function buildSystemValue(systemPrompt, cacheHints) {
|
|
543
|
+
if (!systemPrompt)
|
|
544
|
+
return undefined;
|
|
545
|
+
const staticChars = cacheHints?.systemStaticChars;
|
|
546
|
+
if (typeof staticChars !== "number" ||
|
|
547
|
+
staticChars <= 0 ||
|
|
548
|
+
staticChars >= systemPrompt.length) {
|
|
549
|
+
// No useful split — fall back to single block. Still mark it cacheable
|
|
550
|
+
// when staticChars covers the entire prompt (the dynamic tail was empty).
|
|
551
|
+
if (typeof staticChars === "number" &&
|
|
552
|
+
staticChars > 0 &&
|
|
553
|
+
staticChars >= systemPrompt.length) {
|
|
554
|
+
return [
|
|
555
|
+
{
|
|
556
|
+
type: "text",
|
|
557
|
+
text: systemPrompt,
|
|
558
|
+
cache_control: EPHEMERAL_CACHE,
|
|
559
|
+
},
|
|
560
|
+
];
|
|
561
|
+
}
|
|
562
|
+
return systemPrompt;
|
|
563
|
+
}
|
|
564
|
+
const head = systemPrompt.slice(0, staticChars);
|
|
565
|
+
const tail = systemPrompt.slice(staticChars);
|
|
566
|
+
return [
|
|
567
|
+
{ type: "text", text: head, cache_control: EPHEMERAL_CACHE },
|
|
568
|
+
{ type: "text", text: tail },
|
|
569
|
+
];
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Add cache_control to the last tool in the list. Anthropic caches every tool
|
|
573
|
+
* up to the breakpoint, which is what we want for the full tools array.
|
|
574
|
+
*/
|
|
575
|
+
function applyToolsCacheBreakpoint(tools) {
|
|
576
|
+
if (tools.length === 0)
|
|
577
|
+
return;
|
|
578
|
+
const last = tools[tools.length - 1];
|
|
579
|
+
tools[tools.length - 1] = {
|
|
580
|
+
...last,
|
|
581
|
+
cache_control: EPHEMERAL_CACHE,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Add cache_control to the final content block of the final message. Anthropic
|
|
586
|
+
* uses this as a prefix breakpoint covering all prior messages plus the system
|
|
587
|
+
* and tools. Skips when the last block can't carry cache_control (e.g. when
|
|
588
|
+
* the message is unexpectedly an empty string).
|
|
589
|
+
*/
|
|
590
|
+
function applyMessagesCacheBreakpoint(messages) {
|
|
591
|
+
if (messages.length === 0)
|
|
592
|
+
return;
|
|
593
|
+
const last = messages[messages.length - 1];
|
|
594
|
+
const content = last.content;
|
|
595
|
+
if (Array.isArray(content)) {
|
|
596
|
+
if (content.length === 0)
|
|
597
|
+
return;
|
|
598
|
+
const blockIndex = content.length - 1;
|
|
599
|
+
const block = content[blockIndex];
|
|
600
|
+
// CacheControlEphemeral is accepted on every Anthropic block type we
|
|
601
|
+
// emit (text, tool_use, tool_result, image). Add it idempotently.
|
|
602
|
+
content[blockIndex] = {
|
|
603
|
+
...block,
|
|
604
|
+
cache_control: EPHEMERAL_CACHE,
|
|
605
|
+
};
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (typeof content === "string" && content.length > 0) {
|
|
609
|
+
// Promote string content to a single text block so we can attach
|
|
610
|
+
// cache_control without losing the original text.
|
|
611
|
+
messages[messages.length - 1] = {
|
|
612
|
+
...last,
|
|
613
|
+
content: [
|
|
614
|
+
{
|
|
615
|
+
type: "text",
|
|
616
|
+
text: content,
|
|
617
|
+
cache_control: EPHEMERAL_CACHE,
|
|
618
|
+
},
|
|
619
|
+
],
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
// --- Debug wrapper ---
|
|
624
|
+
class DebugLlmClient {
|
|
625
|
+
inner;
|
|
626
|
+
logFile;
|
|
627
|
+
seq = 0;
|
|
628
|
+
constructor(inner, workspace) {
|
|
629
|
+
this.inner = inner;
|
|
630
|
+
const logDir = path.join(workspace, "logs");
|
|
631
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
632
|
+
this.logFile = path.join(logDir, "llm-debug.jsonl");
|
|
633
|
+
console.log(`🐛 LLM debug log: ${this.logFile}`);
|
|
634
|
+
}
|
|
635
|
+
async chat(messages, tools, systemPrompt, cacheHints, signal) {
|
|
636
|
+
const id = ++this.seq;
|
|
637
|
+
this.write({
|
|
638
|
+
id,
|
|
639
|
+
type: "request",
|
|
640
|
+
ts: new Date().toISOString(),
|
|
641
|
+
systemPrompt,
|
|
642
|
+
messages,
|
|
643
|
+
tools,
|
|
644
|
+
cacheHints,
|
|
645
|
+
});
|
|
646
|
+
const start = Date.now();
|
|
647
|
+
const response = await this.inner.chat(messages, tools, systemPrompt, cacheHints, signal);
|
|
648
|
+
this.write({
|
|
649
|
+
id,
|
|
650
|
+
type: "response",
|
|
651
|
+
ts: new Date().toISOString(),
|
|
652
|
+
durationMs: Date.now() - start,
|
|
653
|
+
content: response.content,
|
|
654
|
+
toolCalls: response.toolCalls,
|
|
655
|
+
stopReason: response.stopReason,
|
|
656
|
+
usage: response.usage,
|
|
657
|
+
});
|
|
658
|
+
return response;
|
|
659
|
+
}
|
|
660
|
+
async *chatStream(messages, tools, systemPrompt, cacheHints, signal) {
|
|
661
|
+
const id = ++this.seq;
|
|
662
|
+
this.write({
|
|
663
|
+
id,
|
|
664
|
+
type: "stream_request",
|
|
665
|
+
ts: new Date().toISOString(),
|
|
666
|
+
systemPrompt,
|
|
667
|
+
messages,
|
|
668
|
+
tools,
|
|
669
|
+
cacheHints,
|
|
670
|
+
});
|
|
671
|
+
const start = Date.now();
|
|
672
|
+
let fullText = "";
|
|
673
|
+
const toolCalls = [];
|
|
674
|
+
for await (const event of this.inner.chatStream(messages, tools, systemPrompt, cacheHints, signal)) {
|
|
675
|
+
if (event.type === "text_delta" && event.text) {
|
|
676
|
+
fullText += event.text;
|
|
677
|
+
}
|
|
678
|
+
else if (event.type === "tool_call_end" && event.toolCall) {
|
|
679
|
+
toolCalls.push(event.toolCall);
|
|
680
|
+
}
|
|
681
|
+
yield event;
|
|
682
|
+
}
|
|
683
|
+
this.write({
|
|
684
|
+
id,
|
|
685
|
+
type: "stream_response",
|
|
686
|
+
ts: new Date().toISOString(),
|
|
687
|
+
durationMs: Date.now() - start,
|
|
688
|
+
content: fullText,
|
|
689
|
+
toolCalls,
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
write(entry) {
|
|
693
|
+
fs.appendFileSync(this.logFile, JSON.stringify(entry) + "\n", "utf-8");
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
//# sourceMappingURL=client.js.map
|