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,670 @@
|
|
|
1
|
+
import { createLlmClient } from "../llm/client.js";
|
|
2
|
+
import { BrowserManager } from "../browser/manager.js";
|
|
3
|
+
import { BrowserActions } from "../browser/actions.js";
|
|
4
|
+
import { TaskRunner } from "./task-runner.js";
|
|
5
|
+
import { Scheduler } from "./scheduler.js";
|
|
6
|
+
import { MemoryManager } from "./memory.js";
|
|
7
|
+
import { StoreManager } from "./store.js";
|
|
8
|
+
import { SkillGenerator } from "./skill-generator.js";
|
|
9
|
+
import { ImageGenerator } from "./image-generator.js";
|
|
10
|
+
import { BrowserLock } from "./browser-lock.js";
|
|
11
|
+
import { ChromeWatchdog } from "./chrome-watchdog.js";
|
|
12
|
+
import { formatDuration } from "./duration.js";
|
|
13
|
+
import { ChatEngine, summarizeChatInput } from "./chat-engine.js";
|
|
14
|
+
import { formatAddTask, formatRemoveTask, formatToggleTask, formatUpdateTask, } from "./executors/scheduler-executor.js";
|
|
15
|
+
import { TUI } from "../tui/tui.js";
|
|
16
|
+
import { TelegramBot } from "../telegram/bot.js";
|
|
17
|
+
import { OrgManager } from "./org-manager.js";
|
|
18
|
+
import { ExecutionLogger } from "../logging/logger.js";
|
|
19
|
+
import { applySessionBlob, shouldSkipSessionSwap, } from "../center/session-sync.js";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
const DEFAULT_SCHEDULED_TASK_TIMEOUT_MS = 30 * 60 * 1000;
|
|
22
|
+
const TAB_RESET_TIMEOUT_MS = 10 * 1000;
|
|
23
|
+
// Uniform 0-10 min jitter applied to every cron-triggered task before lock
|
|
24
|
+
// acquisition. Sleeps OUTSIDE the browser lock so other tasks / chat can use
|
|
25
|
+
// the browser during the wait. Manual `/run` (runTaskById) is unaffected.
|
|
26
|
+
const SCHEDULED_TASK_JITTER_MAX_MS = 10 * 60 * 1000;
|
|
27
|
+
const DEFAULT_CHROME_MAX_RUNTIME_MS = 24 * 60 * 60 * 1000;
|
|
28
|
+
const DEFAULT_CHROME_RESTART_CHECK_INTERVAL_MS = 10 * 60 * 1000;
|
|
29
|
+
const DEFAULT_CHROME_RESTART_MIN_LEAD_MS = 10 * 60 * 1000;
|
|
30
|
+
const DEFAULT_CHROME_IDLE_CLOSE_MS = 5 * 60 * 1000;
|
|
31
|
+
const DEFAULT_CHROME_IDLE_CLOSE_MIN_LEAD_MS = 2 * 60 * 1000;
|
|
32
|
+
const DEFAULT_CHROME_IDLE_CLOSE_CHECK_INTERVAL_MS = 60 * 1000;
|
|
33
|
+
class ScheduledTaskTimeoutError extends Error {
|
|
34
|
+
constructor(task, timeoutMs) {
|
|
35
|
+
super(`Scheduled task "${task.name}" timed out after ${formatDuration(timeoutMs)}`);
|
|
36
|
+
this.name = "ScheduledTaskTimeoutError";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export { NoChatContext } from "./agent-types.js";
|
|
40
|
+
import { FrontendMultiplexer } from "./frontend-multiplexer.js";
|
|
41
|
+
export class Agent {
|
|
42
|
+
config;
|
|
43
|
+
llmClient;
|
|
44
|
+
browser;
|
|
45
|
+
browserActions;
|
|
46
|
+
taskRunner;
|
|
47
|
+
scheduler;
|
|
48
|
+
memory;
|
|
49
|
+
store;
|
|
50
|
+
skillGenerator;
|
|
51
|
+
imageGenerator = null;
|
|
52
|
+
tui = null;
|
|
53
|
+
telegramBot = null;
|
|
54
|
+
orgManager = null;
|
|
55
|
+
chatEngine;
|
|
56
|
+
browserLock = new BrowserLock();
|
|
57
|
+
chromeWatchdog;
|
|
58
|
+
/** Per-session chat logger. Lazy-created on first chat turn, reset on clearChat. */
|
|
59
|
+
chatLogger = null;
|
|
60
|
+
attachmentSenders = new FrontendMultiplexer();
|
|
61
|
+
progressNotifiers = new FrontendMultiplexer();
|
|
62
|
+
constructor(config) {
|
|
63
|
+
this.config = config;
|
|
64
|
+
this.llmClient = createLlmClient(config);
|
|
65
|
+
this.browser = new BrowserManager(config);
|
|
66
|
+
this.browserActions = new BrowserActions(this.browser, config.browser.actionDelay, path.join(config.workspace, "attachments"));
|
|
67
|
+
this.memory = new MemoryManager(config.workspace);
|
|
68
|
+
this.store = new StoreManager(config.workspace);
|
|
69
|
+
this.taskRunner = new TaskRunner(config, this.llmClient, this.browser, this.memory, this.store);
|
|
70
|
+
this.scheduler = new Scheduler(config.workspace, config.scheduler?.timezone);
|
|
71
|
+
this.skillGenerator = new SkillGenerator(config.workspace, this.llmClient);
|
|
72
|
+
if (config.llm.imageGeneration) {
|
|
73
|
+
this.imageGenerator = new ImageGenerator(config.llm.imageGeneration, config.llm.baseUrl, config.workspace);
|
|
74
|
+
}
|
|
75
|
+
if (config.org) {
|
|
76
|
+
this.orgManager = new OrgManager(config);
|
|
77
|
+
}
|
|
78
|
+
// Give TaskRunner access to scheduler for auto-linking skills
|
|
79
|
+
this.taskRunner.setScheduler(this.scheduler);
|
|
80
|
+
this.chatEngine = new ChatEngine({
|
|
81
|
+
llmClient: this.llmClient,
|
|
82
|
+
browserActions: this.browserActions,
|
|
83
|
+
memory: this.memory,
|
|
84
|
+
store: this.store,
|
|
85
|
+
scheduler: this.scheduler,
|
|
86
|
+
skillGenerator: this.skillGenerator,
|
|
87
|
+
imageGenerator: this.imageGenerator,
|
|
88
|
+
orgManager: this.orgManager,
|
|
89
|
+
orgConfig: config.org,
|
|
90
|
+
llmProtocol: config.llm.protocol,
|
|
91
|
+
workspace: config.workspace,
|
|
92
|
+
agentName: config.name,
|
|
93
|
+
maxIterations: config.maxIterations,
|
|
94
|
+
getAttachmentSender: () => this.attachmentSenders.dispatcher(),
|
|
95
|
+
getProgressNotifier: () => this.progressNotifiers.dispatcher(),
|
|
96
|
+
});
|
|
97
|
+
this.chromeWatchdog = new ChromeWatchdog({
|
|
98
|
+
checkIntervalMs: this.config.scheduler?.chromeRestartCheckIntervalMs ??
|
|
99
|
+
DEFAULT_CHROME_RESTART_CHECK_INTERVAL_MS,
|
|
100
|
+
maxRuntimeMs: this.config.scheduler?.chromeMaxRuntimeMs ??
|
|
101
|
+
DEFAULT_CHROME_MAX_RUNTIME_MS,
|
|
102
|
+
minLeadMs: this.config.scheduler?.chromeRestartMinLeadMs ??
|
|
103
|
+
DEFAULT_CHROME_RESTART_MIN_LEAD_MS,
|
|
104
|
+
idleCloseMs: this.config.scheduler?.chromeIdleCloseMs ??
|
|
105
|
+
DEFAULT_CHROME_IDLE_CLOSE_MS,
|
|
106
|
+
idleCloseMinLeadMs: this.config.scheduler?.chromeIdleCloseMinLeadMs ??
|
|
107
|
+
DEFAULT_CHROME_IDLE_CLOSE_MIN_LEAD_MS,
|
|
108
|
+
idleCheckIntervalMs: this.config.scheduler?.chromeIdleCloseCheckIntervalMs ??
|
|
109
|
+
DEFAULT_CHROME_IDLE_CLOSE_CHECK_INTERVAL_MS,
|
|
110
|
+
}, {
|
|
111
|
+
lock: this.browserLock,
|
|
112
|
+
getUptimeMs: () => this.browser.getUptimeMs(),
|
|
113
|
+
getIdleMs: () => this.browser.getIdleMs(),
|
|
114
|
+
getNextRun: () => this.scheduler.getNextRun(),
|
|
115
|
+
restartBrowser: (reason) => this.restartBrowser(reason),
|
|
116
|
+
closeBrowser: (reason) => this.closeBrowserIdle(reason),
|
|
117
|
+
});
|
|
118
|
+
// Wire up scheduler to task runner (serialized via browser lock)
|
|
119
|
+
this.scheduler.setHandler(async (task) => {
|
|
120
|
+
// De-correlate cron fires so traffic looks less robotic. Done BEFORE
|
|
121
|
+
// acquiring the lock so concurrent tasks/chat are not blocked while a
|
|
122
|
+
// task is just sleeping.
|
|
123
|
+
const jitterMs = Math.floor(Math.random() * SCHEDULED_TASK_JITTER_MAX_MS);
|
|
124
|
+
console.log(`⏱️ Jitter for "${task.name}": ${(jitterMs / 1000).toFixed(1)}s before lock`);
|
|
125
|
+
await new Promise((r) => setTimeout(r, jitterMs));
|
|
126
|
+
const lock = this.acquireBrowserLock();
|
|
127
|
+
await lock.promise;
|
|
128
|
+
let result = null;
|
|
129
|
+
let failure = null;
|
|
130
|
+
let timedOut = false;
|
|
131
|
+
try {
|
|
132
|
+
try {
|
|
133
|
+
console.log(`🔒 Lock acquired for task: ${task.name}`);
|
|
134
|
+
// Drop the previous task's tabs so its renderer's accumulated
|
|
135
|
+
// JS heap / DOM / decoded images get released. The browser lock
|
|
136
|
+
// ensures no other operation is touching these pages right now.
|
|
137
|
+
await this.resetTabsOrRestart("before scheduled task");
|
|
138
|
+
const timeoutMs = this.config.scheduler?.taskTimeoutMs ??
|
|
139
|
+
DEFAULT_SCHEDULED_TASK_TIMEOUT_MS;
|
|
140
|
+
result = await this.runScheduledTaskWithWatchdog(task, timeoutMs, () => {
|
|
141
|
+
timedOut = true;
|
|
142
|
+
});
|
|
143
|
+
console.log(` Task result: ${result.slice(0, 200)}`);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
failure = err;
|
|
147
|
+
timedOut ||= err instanceof ScheduledTaskTimeoutError;
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
if (timedOut) {
|
|
151
|
+
await this.restartBrowser(`scheduled task timeout: ${task.name}`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
await this.resetTabsOrRestart("after scheduled task");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
159
|
+
console.error(` Browser recovery failed: ${msg}`);
|
|
160
|
+
failure ??= err;
|
|
161
|
+
}
|
|
162
|
+
if (failure) {
|
|
163
|
+
const msg = failure instanceof Error ? failure.message : String(failure);
|
|
164
|
+
console.error(` Task failed: ${msg}`);
|
|
165
|
+
if (this.telegramBot) {
|
|
166
|
+
await this.telegramBot.notify(`❌ Task "${task.name}" failed:\n${msg.slice(0, 3800)}`);
|
|
167
|
+
}
|
|
168
|
+
throw failure;
|
|
169
|
+
}
|
|
170
|
+
// Notify via Telegram if available
|
|
171
|
+
if (this.telegramBot && result) {
|
|
172
|
+
await this.telegramBot.notify(`✅ Task "${task.name}" completed:\n${result.slice(0, 3800)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
lock.release();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async start(opts = {}) {
|
|
181
|
+
// Claim workspace ownership up front so a conflicting dipclaw fails fast
|
|
182
|
+
// at startup rather than at the first browser action. Chrome itself is
|
|
183
|
+
// launched lazily by the first browser-touching call (getActivePage),
|
|
184
|
+
// and may be torn down + relaunched in-place by the idle-close watchdog
|
|
185
|
+
// while this workspace lock stays held.
|
|
186
|
+
await this.browser.prepareWorkspace();
|
|
187
|
+
// The local Scheduler is for stand-alone mode. In center mode the cron
|
|
188
|
+
// tick lives on the dp-center; `skipScheduler` suppresses the local
|
|
189
|
+
// scheduler so it doesn't double-fire any tasks the operator happened to
|
|
190
|
+
// leave in the local tasks.json. The class is otherwise untouched so
|
|
191
|
+
// local-mode operators keep their workflow.
|
|
192
|
+
if (!opts.skipScheduler) {
|
|
193
|
+
this.scheduler.start();
|
|
194
|
+
}
|
|
195
|
+
this.chromeWatchdog.start();
|
|
196
|
+
// Start Telegram bot if configured
|
|
197
|
+
if (this.config.telegram) {
|
|
198
|
+
this.telegramBot = new TelegramBot(this.config.telegram.botToken, this, this.config.telegram.allowedUsers);
|
|
199
|
+
try {
|
|
200
|
+
await this.telegramBot.start();
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
console.warn(`⚠️ Telegram bot failed to start; continuing without Telegram: ${err instanceof Error ? err.message : String(err)}`);
|
|
204
|
+
this.telegramBot.stop();
|
|
205
|
+
this.telegramBot = null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Start TUI only if enabled
|
|
209
|
+
if (this.config.tui) {
|
|
210
|
+
this.tui = new TUI(this);
|
|
211
|
+
this.tui.start();
|
|
212
|
+
}
|
|
213
|
+
if (this.orgManager) {
|
|
214
|
+
await this.orgManager.init();
|
|
215
|
+
// 如果当前角色是基础员工 (worker),则启动后台轮询,定期检查老板是否派发了新任务
|
|
216
|
+
if (this.config.org?.role === "worker") {
|
|
217
|
+
this.startOrgTaskPolling();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Run a center-dispatched prompt against this worker under the BrowserLock.
|
|
223
|
+
*
|
|
224
|
+
* The contract matches the M3 "single worker end-to-end" path in
|
|
225
|
+
* docs/architecture.md: center writes a task_run row + dispatches a
|
|
226
|
+
* `task_dispatch` message; the worker frontend (center-frontend.ts) calls
|
|
227
|
+
* this method and is responsible for emitting `task_event` messages
|
|
228
|
+
* (`dispatched_ack` immediately on receipt, `finished` when the
|
|
229
|
+
* promise here resolves with the outcome).
|
|
230
|
+
*
|
|
231
|
+
* Why this lives on Agent and not on center-frontend: BrowserLock is owned
|
|
232
|
+
* by Agent, and so is the per-turn logger wiring. Keeping the lock
|
|
233
|
+
* acquisition here means center-frontend stays a pure adapter.
|
|
234
|
+
*/
|
|
235
|
+
async enqueueTaskFromCenter(taskRunId, prompt, opts = {}) {
|
|
236
|
+
const lock = this.acquireBrowserLock();
|
|
237
|
+
await lock.promise;
|
|
238
|
+
try {
|
|
239
|
+
await this.resetTabsOrRestart(`before center task ${taskRunId}`);
|
|
240
|
+
const result = await this.taskRunner.runPrompt(prompt, `center-${taskRunId.slice(0, 8)}`);
|
|
241
|
+
return { status: "success", result };
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
const aborted = opts.signal?.aborted ||
|
|
245
|
+
(err instanceof Error && err.name === "AbortError");
|
|
246
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
247
|
+
return {
|
|
248
|
+
status: aborted ? "cancelled" : "failed",
|
|
249
|
+
error: message,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
// Try a best-effort tab cleanup so the next task starts fresh, but
|
|
254
|
+
// don't let cleanup failure mask the task outcome.
|
|
255
|
+
try {
|
|
256
|
+
await this.resetTabsOrRestart(`after center task ${taskRunId}`);
|
|
257
|
+
}
|
|
258
|
+
catch (err) {
|
|
259
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
260
|
+
console.error(` center task cleanup failed: ${msg}`);
|
|
261
|
+
}
|
|
262
|
+
lock.release();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Pull a center-published Chrome session zip onto this worker's local browser-data
|
|
267
|
+
* dir. Acquires the BrowserLock so the swap can't race a chat turn / task,
|
|
268
|
+
* then performs:
|
|
269
|
+
*
|
|
270
|
+
* 1. compare local meta vs blob hash + timestamps (skip-decision)
|
|
271
|
+
* 2. browser.close() — release the Chrome user-data lock
|
|
272
|
+
* 3. applySessionBlob — fetch zip + overwrite files
|
|
273
|
+
* 4. browser.launch() — bring Chrome back with the new profile
|
|
274
|
+
*
|
|
275
|
+
* `extractZipToDir` is stubbed until M7 lands the zip dep; callers in M7+
|
|
276
|
+
* will inject a real extractor or this throws.
|
|
277
|
+
*/
|
|
278
|
+
async swapSession(blob, deps) {
|
|
279
|
+
const lock = this.acquireBrowserLock();
|
|
280
|
+
await lock.promise;
|
|
281
|
+
try {
|
|
282
|
+
const skipReason = await shouldSkipSessionSwap(this.config.workspace, blob);
|
|
283
|
+
if (skipReason) {
|
|
284
|
+
console.log(`📦 Session swap skipped: ${skipReason}`);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
await this.browser.close();
|
|
288
|
+
await applySessionBlob(this.config.workspace, blob, deps);
|
|
289
|
+
await this.browser.launch();
|
|
290
|
+
console.log(`📦 Session swap applied (hash: ${blob.content_hash.slice(0, 12)}…)`);
|
|
291
|
+
}
|
|
292
|
+
finally {
|
|
293
|
+
lock.release();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Public read of BrowserLock state — true when a task or chat turn is
|
|
298
|
+
* currently using the browser (or queued ahead of us). Frontends
|
|
299
|
+
* (center-frontend, Telegram bot) use this to surface "worker busy, queued"
|
|
300
|
+
* to the user without taking the lock themselves.
|
|
301
|
+
*/
|
|
302
|
+
isBusy() {
|
|
303
|
+
return !this.browserLock.isIdle();
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* 启动员工的组织任务轮询机制。
|
|
307
|
+
* 此方法会在后台每隔 10 秒扫描一次该员工的“私有信箱”(inbox)。
|
|
308
|
+
* 如果发现有老板派发的新任务,将按顺序逐一执行。
|
|
309
|
+
*/
|
|
310
|
+
startOrgTaskPolling() {
|
|
311
|
+
const POLL_INTERVAL = 10000; // 10秒轮询一次
|
|
312
|
+
const poll = async () => {
|
|
313
|
+
if (!this.orgManager)
|
|
314
|
+
return;
|
|
315
|
+
try {
|
|
316
|
+
// 从信箱中取出所有状态为 "pending" 的任务
|
|
317
|
+
const tasks = this.orgManager.pollTasks();
|
|
318
|
+
for (const task of tasks) {
|
|
319
|
+
await this.handleOrgTask(task);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
console.error("Error polling org tasks:", err);
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
// 确保在上一次轮询及任务完全结束后,再设置下一次定时器,防止任务堆叠阻塞
|
|
327
|
+
setTimeout(poll, POLL_INTERVAL);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
setTimeout(poll, POLL_INTERVAL);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 处理单一的组织指派任务。
|
|
334
|
+
* 任务状态流转:pending -> running -> completed/failed
|
|
335
|
+
*/
|
|
336
|
+
async handleOrgTask(task) {
|
|
337
|
+
console.log(`Received task from ${task.assignedBy}: ${task.instruction}`);
|
|
338
|
+
// 先将任务状态标记为执行中,防止重复执行
|
|
339
|
+
this.orgManager?.updateTask(task.id, "running");
|
|
340
|
+
// 更新员工自身的状态为 busy,老板可以据此判断员工负荷
|
|
341
|
+
this.orgManager?.setStatus("busy");
|
|
342
|
+
try {
|
|
343
|
+
// 将老板的指令包装成一次内部的对话回合 (chat turn),交由 LLM 大脑处理
|
|
344
|
+
const result = await this.chat(`[Assignment from ${task.assignedBy}]: ${task.instruction}`);
|
|
345
|
+
// 任务成功完成,将结果写回任务文件,供老板查阅
|
|
346
|
+
this.orgManager?.updateTask(task.id, "completed", result);
|
|
347
|
+
if (this.telegramBot) {
|
|
348
|
+
await this.telegramBot.notify(`Finished task from ${task.assignedBy}:\n${task.instruction}\n\nResult: ${result.slice(0, 500)}...`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch (err) {
|
|
352
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
353
|
+
// 任务执行报错,记录错误信息并标记为 failed
|
|
354
|
+
this.orgManager?.updateTask(task.id, "failed", msg);
|
|
355
|
+
if (this.telegramBot) {
|
|
356
|
+
await this.telegramBot.notify(`Failed task from ${task.assignedBy}:\n${task.instruction}\n\nError: ${msg}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
// 任务结束(无论成功或失败),恢复员工状态为空闲
|
|
361
|
+
this.orgManager?.setStatus("idle");
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
async stop() {
|
|
365
|
+
// 1. Stop frontends first so no new chat turns / scheduled tasks enqueue.
|
|
366
|
+
this.chromeWatchdog.stop();
|
|
367
|
+
this.scheduler.stop();
|
|
368
|
+
this.telegramBot?.stop();
|
|
369
|
+
this.tui?.stop();
|
|
370
|
+
// 2. Wait for any in-flight chat turn / task to finish its finally block
|
|
371
|
+
// (which includes writing chat_turn_end). Only then do we emit
|
|
372
|
+
// chat_session_end, so log order stays well-formed on SIGINT/SIGTERM.
|
|
373
|
+
// If the in-flight operation is stuck the process can be force-killed
|
|
374
|
+
// with a second signal — standard Unix behavior.
|
|
375
|
+
const lock = this.acquireBrowserLock();
|
|
376
|
+
await lock.promise;
|
|
377
|
+
try {
|
|
378
|
+
if (this.chatLogger) {
|
|
379
|
+
this.chatLogger.log("chat_session_end", { reason: "shutdown" });
|
|
380
|
+
this.chatLogger = null;
|
|
381
|
+
}
|
|
382
|
+
this.orgManager?.stop();
|
|
383
|
+
await this.browser.close();
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
lock.release();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// --- Public API for TUI/Telegram ---
|
|
390
|
+
getName() {
|
|
391
|
+
return this.config.name;
|
|
392
|
+
}
|
|
393
|
+
getWorkspace() {
|
|
394
|
+
return this.config.workspace;
|
|
395
|
+
}
|
|
396
|
+
// --- Frontend hook registration ---
|
|
397
|
+
/**
|
|
398
|
+
* Register a frontend's delivery callbacks under a stable id (e.g.
|
|
399
|
+
* "telegram", "center"). Multiple frontends can be registered simultaneously;
|
|
400
|
+
* the Agent dispatches each tool call through every registered callback in
|
|
401
|
+
* insertion order, and the first one that doesn't throw NoChatContext
|
|
402
|
+
* handles it. Frontends should scope their callbacks to their own
|
|
403
|
+
* AsyncLocalStorage and throw NoChatContext when the store is empty, so
|
|
404
|
+
* the dispatcher can find the frontend whose chat handler is on the stack.
|
|
405
|
+
*/
|
|
406
|
+
registerFrontend(id, hooks) {
|
|
407
|
+
if (hooks.sender)
|
|
408
|
+
this.attachmentSenders.set(id, hooks.sender);
|
|
409
|
+
if (hooks.notifier)
|
|
410
|
+
this.progressNotifiers.set(id, hooks.notifier);
|
|
411
|
+
}
|
|
412
|
+
/** Drop both the sender and notifier registered under `id`, if any. */
|
|
413
|
+
unregisterFrontend(id) {
|
|
414
|
+
this.attachmentSenders.delete(id);
|
|
415
|
+
this.progressNotifiers.delete(id);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* @deprecated Use `registerFrontend("legacy", { sender })`.
|
|
419
|
+
*
|
|
420
|
+
* Single-slot legacy API. Pass `null` to clear the legacy slot only —
|
|
421
|
+
* does not touch other registered frontends.
|
|
422
|
+
*/
|
|
423
|
+
setAttachmentSender(sender) {
|
|
424
|
+
if (sender)
|
|
425
|
+
this.attachmentSenders.set("legacy", sender);
|
|
426
|
+
else
|
|
427
|
+
this.attachmentSenders.delete("legacy");
|
|
428
|
+
}
|
|
429
|
+
/** @deprecated Use `registerFrontend("legacy", { notifier })`. */
|
|
430
|
+
setProgressNotifier(notifier) {
|
|
431
|
+
if (notifier)
|
|
432
|
+
this.progressNotifiers.set("legacy", notifier);
|
|
433
|
+
else
|
|
434
|
+
this.progressNotifiers.delete("legacy");
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Clear chat history and start a new session.
|
|
438
|
+
*
|
|
439
|
+
* Queues on the browser lock so it runs AFTER any in-flight chat turn. This
|
|
440
|
+
* guarantees the turn's finally block writes `chat_turn_end` before we emit
|
|
441
|
+
* `chat_session_end`, and prevents the old turn from pushing messages into
|
|
442
|
+
* the cleared chatHistory.
|
|
443
|
+
*/
|
|
444
|
+
async clearChat() {
|
|
445
|
+
const lock = this.acquireBrowserLock();
|
|
446
|
+
await lock.promise;
|
|
447
|
+
try {
|
|
448
|
+
if (this.chatLogger) {
|
|
449
|
+
this.chatLogger.log("chat_session_end", { reason: "clearChat" });
|
|
450
|
+
this.chatLogger = null;
|
|
451
|
+
}
|
|
452
|
+
this.chatEngine.reset();
|
|
453
|
+
}
|
|
454
|
+
finally {
|
|
455
|
+
lock.release();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/** Lazily create a per-session chat logger. One jsonl per chat session. */
|
|
459
|
+
ensureChatLogger() {
|
|
460
|
+
if (!this.chatLogger) {
|
|
461
|
+
const logsDir = path.join(this.config.workspace, "logs");
|
|
462
|
+
this.chatLogger = new ExecutionLogger(logsDir, "chat");
|
|
463
|
+
this.chatLogger.log("chat_session_start", {
|
|
464
|
+
workspace: this.config.workspace,
|
|
465
|
+
model: this.config.llm?.model,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return this.chatLogger;
|
|
469
|
+
}
|
|
470
|
+
/** Chat with the agent (LLM-driven, with tool use) */
|
|
471
|
+
async chat(message) {
|
|
472
|
+
const lock = this.acquireBrowserLock();
|
|
473
|
+
await lock.promise;
|
|
474
|
+
const logger = this.ensureChatLogger();
|
|
475
|
+
this.browserActions.setLogger(logger);
|
|
476
|
+
const turnStartedAt = Date.now();
|
|
477
|
+
logger.log("chat_turn_start", {
|
|
478
|
+
mode: "sync",
|
|
479
|
+
userMessage: summarizeChatInput(message),
|
|
480
|
+
historyLen: this.chatEngine.getHistoryLength(),
|
|
481
|
+
});
|
|
482
|
+
try {
|
|
483
|
+
const result = await this.chatEngine.chat(message);
|
|
484
|
+
logger.log("chat_turn_end", {
|
|
485
|
+
mode: "sync",
|
|
486
|
+
durationMs: Date.now() - turnStartedAt,
|
|
487
|
+
resultPreview: result.slice(0, 500),
|
|
488
|
+
});
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
logger.log("chat_turn_end", {
|
|
493
|
+
mode: "sync",
|
|
494
|
+
durationMs: Date.now() - turnStartedAt,
|
|
495
|
+
error: err instanceof Error ? err.message : String(err),
|
|
496
|
+
}, false);
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
finally {
|
|
500
|
+
this.browserActions.clearLogger(logger);
|
|
501
|
+
lock.release();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/** Chat with streaming — yields text deltas, handles tool calls internally */
|
|
505
|
+
async *chatStream(message) {
|
|
506
|
+
const lock = this.acquireBrowserLock();
|
|
507
|
+
await lock.promise;
|
|
508
|
+
const logger = this.ensureChatLogger();
|
|
509
|
+
this.browserActions.setLogger(logger);
|
|
510
|
+
const turnStartedAt = Date.now();
|
|
511
|
+
logger.log("chat_turn_start", {
|
|
512
|
+
mode: "stream",
|
|
513
|
+
userMessage: summarizeChatInput(message),
|
|
514
|
+
historyLen: this.chatEngine.getHistoryLength(),
|
|
515
|
+
});
|
|
516
|
+
let collected = "";
|
|
517
|
+
let errored = null;
|
|
518
|
+
try {
|
|
519
|
+
for await (const delta of this.chatEngine.chatStream(message)) {
|
|
520
|
+
collected += delta;
|
|
521
|
+
yield delta;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
catch (err) {
|
|
525
|
+
errored = err instanceof Error ? err : new Error(String(err));
|
|
526
|
+
throw err;
|
|
527
|
+
}
|
|
528
|
+
finally {
|
|
529
|
+
logger.log("chat_turn_end", {
|
|
530
|
+
mode: "stream",
|
|
531
|
+
durationMs: Date.now() - turnStartedAt,
|
|
532
|
+
resultPreview: collected.slice(0, 500),
|
|
533
|
+
...(errored ? { error: errored.message } : {}),
|
|
534
|
+
}, !errored);
|
|
535
|
+
this.browserActions.clearLogger(logger);
|
|
536
|
+
lock.release();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
listTasks() {
|
|
540
|
+
return this.scheduler.formatTaskList();
|
|
541
|
+
}
|
|
542
|
+
addTask(name, cron, prompt, timezone) {
|
|
543
|
+
return formatAddTask(this.scheduler, name, cron, prompt, timezone);
|
|
544
|
+
}
|
|
545
|
+
removeTask(id) {
|
|
546
|
+
return formatRemoveTask(this.scheduler, id);
|
|
547
|
+
}
|
|
548
|
+
toggleTask(id, enabled) {
|
|
549
|
+
return formatToggleTask(this.scheduler, id, enabled);
|
|
550
|
+
}
|
|
551
|
+
updateTask(id, patch) {
|
|
552
|
+
return formatUpdateTask(this.scheduler, id, patch);
|
|
553
|
+
}
|
|
554
|
+
async runTaskById(id) {
|
|
555
|
+
const task = this.scheduler.getTask(id);
|
|
556
|
+
if (!task)
|
|
557
|
+
return `Task ${id} not found.`;
|
|
558
|
+
const lock = this.acquireBrowserLock();
|
|
559
|
+
await lock.promise;
|
|
560
|
+
try {
|
|
561
|
+
const result = await this.taskRunner.runTask(task);
|
|
562
|
+
this.scheduler.updateTaskStatus(id, "ok");
|
|
563
|
+
return result;
|
|
564
|
+
}
|
|
565
|
+
catch (err) {
|
|
566
|
+
this.scheduler.updateTaskStatus(id, "error");
|
|
567
|
+
return `Error: ${err instanceof Error ? err.message : String(err)}`;
|
|
568
|
+
}
|
|
569
|
+
finally {
|
|
570
|
+
lock.release();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
listSkills() {
|
|
574
|
+
return this.skillGenerator.listSkills();
|
|
575
|
+
}
|
|
576
|
+
async generateSkill(logFileName) {
|
|
577
|
+
const logsDir = path.join(this.config.workspace, "logs");
|
|
578
|
+
const logs = ExecutionLogger.listLogs(logsDir);
|
|
579
|
+
const match = logs.find((l) => l.includes(logFileName));
|
|
580
|
+
if (!match)
|
|
581
|
+
return `Log file not found: ${logFileName}`;
|
|
582
|
+
const logPath = path.join(logsDir, match);
|
|
583
|
+
return await this.skillGenerator.generate(logPath);
|
|
584
|
+
}
|
|
585
|
+
listMemories() {
|
|
586
|
+
return this.memory.list();
|
|
587
|
+
}
|
|
588
|
+
async runScheduledTaskWithWatchdog(task, timeoutMs, onTimeout) {
|
|
589
|
+
let timedOut = false;
|
|
590
|
+
let timer = null;
|
|
591
|
+
const controller = new AbortController();
|
|
592
|
+
const taskPromise = this.taskRunner.runTask(task, controller.signal);
|
|
593
|
+
taskPromise.catch((err) => {
|
|
594
|
+
if (!timedOut)
|
|
595
|
+
return;
|
|
596
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
597
|
+
console.error(` Timed-out task "${task.name}" later ended after Chrome restart: ${msg}`);
|
|
598
|
+
});
|
|
599
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
600
|
+
timer = setTimeout(() => {
|
|
601
|
+
timedOut = true;
|
|
602
|
+
onTimeout();
|
|
603
|
+
const err = new ScheduledTaskTimeoutError(task, timeoutMs);
|
|
604
|
+
controller.abort(err);
|
|
605
|
+
reject(err);
|
|
606
|
+
}, timeoutMs);
|
|
607
|
+
});
|
|
608
|
+
try {
|
|
609
|
+
return await Promise.race([taskPromise, timeoutPromise]);
|
|
610
|
+
}
|
|
611
|
+
finally {
|
|
612
|
+
if (timer)
|
|
613
|
+
clearTimeout(timer);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async resetTabsOrRestart(phase) {
|
|
617
|
+
try {
|
|
618
|
+
await withTimeout(this.browser.resetTabs(), TAB_RESET_TIMEOUT_MS, `resetTabs timed out during ${phase}`);
|
|
619
|
+
}
|
|
620
|
+
catch (err) {
|
|
621
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
622
|
+
console.error(` Tab cleanup failed during ${phase}: ${msg}`);
|
|
623
|
+
await this.restartBrowser(`tab cleanup failed during ${phase}`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
async restartBrowser(reason) {
|
|
627
|
+
console.warn(` Restarting Chrome profile (${reason})...`);
|
|
628
|
+
await this.browser.restart();
|
|
629
|
+
console.warn(" Chrome profile restarted.");
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Idle-close path: tear Chrome down but keep workspace ownership so the
|
|
633
|
+
* next browser action relaunches in-place. Caller (watchdog) holds the
|
|
634
|
+
* browser lock.
|
|
635
|
+
*/
|
|
636
|
+
async closeBrowserIdle(reason) {
|
|
637
|
+
console.log(` Closing idle Chrome (${reason})...`);
|
|
638
|
+
await this.browser.closeKeepLock();
|
|
639
|
+
console.log(" Chrome closed; will relaunch on next browser action.");
|
|
640
|
+
}
|
|
641
|
+
isBrowserLockIdle() {
|
|
642
|
+
return this.browserLock.isIdle();
|
|
643
|
+
}
|
|
644
|
+
tryAcquireBrowserLock() {
|
|
645
|
+
return this.browserLock.tryAcquire();
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Acquire a serialized lock for browser access.
|
|
649
|
+
* All operations that may use the browser (chat, scheduled tasks) must go through this
|
|
650
|
+
* to prevent concurrent browser manipulation.
|
|
651
|
+
*/
|
|
652
|
+
acquireBrowserLock() {
|
|
653
|
+
return this.browserLock.acquire();
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
657
|
+
return new Promise((resolve, reject) => {
|
|
658
|
+
const timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
659
|
+
promise
|
|
660
|
+
.then((value) => {
|
|
661
|
+
clearTimeout(timer);
|
|
662
|
+
resolve(value);
|
|
663
|
+
})
|
|
664
|
+
.catch((err) => {
|
|
665
|
+
clearTimeout(timer);
|
|
666
|
+
reject(err);
|
|
667
|
+
});
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
//# sourceMappingURL=agent.js.map
|