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,82 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
const PNG_SIGNATURE = Buffer.from([
|
|
3
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
|
4
|
+
]);
|
|
5
|
+
/**
|
|
6
|
+
* Drop C2PA (`caBX`) chunks from a PNG byte stream. Every other chunk —
|
|
7
|
+
* IHDR, IDAT, IEND, ancillary metadata — is copied byte-for-byte, CRCs
|
|
8
|
+
* included, so pixel data is untouched. If the buffer is not a valid
|
|
9
|
+
* PNG or is malformed mid-stream, the input is returned unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export function stripC2paFromPng(data) {
|
|
12
|
+
if (data.length < 8 || !data.subarray(0, 8).equals(PNG_SIGNATURE)) {
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
const parts = [data.subarray(0, 8)];
|
|
16
|
+
let i = 8;
|
|
17
|
+
let sawIend = false;
|
|
18
|
+
while (i + 8 <= data.length) {
|
|
19
|
+
const length = data.readUInt32BE(i);
|
|
20
|
+
const chunkEnd = i + 12 + length; // 4 len + 4 type + N data + 4 CRC
|
|
21
|
+
if (chunkEnd > data.length) {
|
|
22
|
+
// Truncated chunk — bail out and hand back the original buffer
|
|
23
|
+
// rather than emit a corrupt PNG.
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
const type = data.subarray(i + 4, i + 8).toString("ascii");
|
|
27
|
+
if (type !== "caBX") {
|
|
28
|
+
parts.push(data.subarray(i, chunkEnd));
|
|
29
|
+
}
|
|
30
|
+
i = chunkEnd;
|
|
31
|
+
if (type === "IEND") {
|
|
32
|
+
sawIend = true;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!sawIend)
|
|
37
|
+
return data;
|
|
38
|
+
return Buffer.concat(parts);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decode the PNG and re-encode as JPEG quality 85. Lossy re-compression
|
|
42
|
+
* disturbs pixel-domain watermarks; the decode/encode round-trip also
|
|
43
|
+
* drops any non-pixel metadata that survived the chunk strip. Alpha is
|
|
44
|
+
* flattened to white since JPEG has no transparency.
|
|
45
|
+
*/
|
|
46
|
+
export async function pngToJpegQ85(pngBuffer) {
|
|
47
|
+
return sharp(pngBuffer)
|
|
48
|
+
.flatten({ background: { r: 255, g: 255, b: 255 } })
|
|
49
|
+
.jpeg({ quality: 85, mozjpeg: false })
|
|
50
|
+
.toBuffer();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* End-to-end post-process: strip C2PA, then JPEG-recompress. Returns the
|
|
54
|
+
* new bytes plus the file extension to use ("jpg" on success, "png" if
|
|
55
|
+
* we had to fall back). On strip success but encode failure, callers
|
|
56
|
+
* still benefit from the C2PA-free PNG.
|
|
57
|
+
*/
|
|
58
|
+
export async function sanitizeGeneratedImage(raw) {
|
|
59
|
+
let stripped;
|
|
60
|
+
try {
|
|
61
|
+
stripped = stripC2paFromPng(raw);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
return {
|
|
65
|
+
buffer: raw,
|
|
66
|
+
ext: "png",
|
|
67
|
+
note: `c2pa-strip failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const jpeg = await pngToJpegQ85(stripped);
|
|
72
|
+
return { buffer: jpeg, ext: "jpg" };
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
buffer: stripped,
|
|
77
|
+
ext: "png",
|
|
78
|
+
note: `jpeg-reencode failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=image-postprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-postprocess.js","sourceRoot":"","sources":["../../src/agent/image-postprocess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC;IAChC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CAC/C,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAA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,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;SACnD,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SACrC,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAW;IAEX,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,GAAG;YACX,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,sBAAsB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SAC/E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,yBAAyB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;SAClF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface MemoryIndexOptions {
|
|
2
|
+
maxEntries?: number;
|
|
3
|
+
maxBytes?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface RelevantMemoryOptions {
|
|
6
|
+
maxFiles?: number;
|
|
7
|
+
maxTotalBytes?: number;
|
|
8
|
+
perFileBytes?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a memory key into the on-disk file basename. Strips any trailing
|
|
12
|
+
* `.md` or `_md` suffixes the LLM may have included, then sanitizes
|
|
13
|
+
* characters. Without the strip, `key="foo.md"` produced `foo_md.md`, and on
|
|
14
|
+
* the next call `key="foo_md.md"` produced `foo_md_md.md` etc.
|
|
15
|
+
*/
|
|
16
|
+
export declare function keyToSafe(key: string): string;
|
|
17
|
+
export declare class MemoryManager {
|
|
18
|
+
private memoryDir;
|
|
19
|
+
private indexFile;
|
|
20
|
+
constructor(workspace: string);
|
|
21
|
+
/** Load the MEMORY.md index content */
|
|
22
|
+
loadIndex(): string;
|
|
23
|
+
/** Load a recent, byte-bounded MEMORY.md index for prompt injection. */
|
|
24
|
+
loadIndexCapped(opts?: MemoryIndexOptions): string;
|
|
25
|
+
/** Load memories relevant to a given context (task name, URL, etc.) */
|
|
26
|
+
loadRelevantMemories(keywords: string[], opts?: RelevantMemoryOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* Save a memory file and update the index. Scheduled tasks should NOT call
|
|
29
|
+
* this directly — task-runner rejects memory.save at the dispatch layer and
|
|
30
|
+
* funnels structured cross-run state to the store tool instead.
|
|
31
|
+
*/
|
|
32
|
+
save(key: string, title: string, content: string): string;
|
|
33
|
+
/** Read a specific memory file */
|
|
34
|
+
read(key: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* One-time cleanup: prior to the keyToSafe fix, an LLM passing key="foo.md"
|
|
37
|
+
* produced `foo_md.md`, then `foo_md_md.md` on next call, etc. Detect these
|
|
38
|
+
* `(_md)+\.md$` filenames, merge them with the canonical `foo.md` file
|
|
39
|
+
* (keeping the newest mtime), and prune dead lines from MEMORY.md.
|
|
40
|
+
*
|
|
41
|
+
* Idempotent: a clean directory makes this a no-op.
|
|
42
|
+
*/
|
|
43
|
+
private migrateMdSuffixDuplicates;
|
|
44
|
+
private nextArchivePath;
|
|
45
|
+
/** Read the `title:` line from a memory file's YAML frontmatter, if present. */
|
|
46
|
+
private readFrontmatterTitle;
|
|
47
|
+
/** Drop lines from MEMORY.md that point to files that no longer exist. */
|
|
48
|
+
private pruneIndexOfMissingFiles;
|
|
49
|
+
/** List all memory files */
|
|
50
|
+
list(): string;
|
|
51
|
+
private listMemoryFiles;
|
|
52
|
+
private parseIndex;
|
|
53
|
+
private renderIndex;
|
|
54
|
+
private updateIndex;
|
|
55
|
+
}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const MAX_MEMORY_CONTENT_BYTES = 8192;
|
|
4
|
+
const DEFAULT_INDEX_MAX_ENTRIES = 30;
|
|
5
|
+
const DEFAULT_INDEX_MAX_BYTES = 6144;
|
|
6
|
+
const DEFAULT_RELEVANT_MAX_FILES = 5;
|
|
7
|
+
const DEFAULT_RELEVANT_MAX_TOTAL_BYTES = 10 * 1024;
|
|
8
|
+
const DEFAULT_RELEVANT_PER_FILE_BYTES = 3 * 1024;
|
|
9
|
+
/**
|
|
10
|
+
* Normalize a memory key into the on-disk file basename. Strips any trailing
|
|
11
|
+
* `.md` or `_md` suffixes the LLM may have included, then sanitizes
|
|
12
|
+
* characters. Without the strip, `key="foo.md"` produced `foo_md.md`, and on
|
|
13
|
+
* the next call `key="foo_md.md"` produced `foo_md_md.md` etc.
|
|
14
|
+
*/
|
|
15
|
+
export function keyToSafe(key) {
|
|
16
|
+
let cleaned = key;
|
|
17
|
+
while (/(\.md|_md)$/i.test(cleaned)) {
|
|
18
|
+
cleaned = cleaned.replace(/(\.md|_md)$/i, "");
|
|
19
|
+
}
|
|
20
|
+
return cleaned.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
21
|
+
}
|
|
22
|
+
/** Keys that look like daily/per-run logs — rejected at save time. */
|
|
23
|
+
function isDateLikeKey(safeKey) {
|
|
24
|
+
return (/\d{8}/.test(safeKey) || // YYYYMMDD anywhere
|
|
25
|
+
/\d{4}-\d{2}-\d{2}/.test(safeKey) || // YYYY-MM-DD
|
|
26
|
+
/-\d{10,}$/.test(safeKey) // unix timestamp suffix (seconds or ms)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function byteLength(s) {
|
|
30
|
+
return Buffer.byteLength(s, "utf-8");
|
|
31
|
+
}
|
|
32
|
+
function truncateToBytes(s, maxBytes) {
|
|
33
|
+
if (maxBytes <= 0)
|
|
34
|
+
return "";
|
|
35
|
+
if (byteLength(s) <= maxBytes)
|
|
36
|
+
return s;
|
|
37
|
+
let out = "";
|
|
38
|
+
let used = 0;
|
|
39
|
+
for (const ch of s) {
|
|
40
|
+
const next = byteLength(ch);
|
|
41
|
+
if (used + next > maxBytes)
|
|
42
|
+
break;
|
|
43
|
+
out += ch;
|
|
44
|
+
used += next;
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
function appendNoteWithinBudget(body, note, maxBytes) {
|
|
49
|
+
const sep = body ? "\n\n" : "";
|
|
50
|
+
const full = `${body}${sep}${note}`;
|
|
51
|
+
if (byteLength(full) <= maxBytes)
|
|
52
|
+
return full;
|
|
53
|
+
const noteBytes = byteLength(note);
|
|
54
|
+
const sepBytes = body ? byteLength(sep) : 0;
|
|
55
|
+
const bodyBudget = maxBytes - noteBytes - sepBytes;
|
|
56
|
+
if (bodyBudget <= 0) {
|
|
57
|
+
return truncateToBytes(note, maxBytes);
|
|
58
|
+
}
|
|
59
|
+
return `${truncateToBytes(body, bodyBudget)}${sep}${note}`;
|
|
60
|
+
}
|
|
61
|
+
export class MemoryManager {
|
|
62
|
+
memoryDir;
|
|
63
|
+
indexFile;
|
|
64
|
+
constructor(workspace) {
|
|
65
|
+
this.memoryDir = path.join(workspace, "memory");
|
|
66
|
+
this.indexFile = path.join(this.memoryDir, "MEMORY.md");
|
|
67
|
+
fs.mkdirSync(this.memoryDir, { recursive: true });
|
|
68
|
+
this.migrateMdSuffixDuplicates();
|
|
69
|
+
}
|
|
70
|
+
/** Load the MEMORY.md index content */
|
|
71
|
+
loadIndex() {
|
|
72
|
+
if (!fs.existsSync(this.indexFile)) {
|
|
73
|
+
return "";
|
|
74
|
+
}
|
|
75
|
+
return fs.readFileSync(this.indexFile, "utf-8");
|
|
76
|
+
}
|
|
77
|
+
/** Load a recent, byte-bounded MEMORY.md index for prompt injection. */
|
|
78
|
+
loadIndexCapped(opts = {}) {
|
|
79
|
+
const maxEntries = opts.maxEntries ?? DEFAULT_INDEX_MAX_ENTRIES;
|
|
80
|
+
const maxBytes = opts.maxBytes ?? DEFAULT_INDEX_MAX_BYTES;
|
|
81
|
+
const index = this.loadIndex();
|
|
82
|
+
if (!index.trim() || maxBytes <= 0 || maxEntries <= 0) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
const { headerLines, entries } = this.parseIndex(index);
|
|
86
|
+
if (entries.length === 0) {
|
|
87
|
+
return truncateToBytes(index, maxBytes);
|
|
88
|
+
}
|
|
89
|
+
const sorted = [...entries].sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
90
|
+
let shown = sorted.slice(0, maxEntries);
|
|
91
|
+
let rendered = this.renderIndex(headerLines, shown, entries.length - shown.length);
|
|
92
|
+
while (shown.length > 0 && byteLength(rendered) > maxBytes) {
|
|
93
|
+
shown = shown.slice(0, -1);
|
|
94
|
+
rendered = this.renderIndex(headerLines, shown, entries.length - shown.length);
|
|
95
|
+
}
|
|
96
|
+
return truncateToBytes(rendered, maxBytes);
|
|
97
|
+
}
|
|
98
|
+
/** Load memories relevant to a given context (task name, URL, etc.) */
|
|
99
|
+
loadRelevantMemories(keywords, opts = {}) {
|
|
100
|
+
const maxFiles = opts.maxFiles ?? DEFAULT_RELEVANT_MAX_FILES;
|
|
101
|
+
const maxTotalBytes = opts.maxTotalBytes ?? DEFAULT_RELEVANT_MAX_TOTAL_BYTES;
|
|
102
|
+
const perFileBytes = opts.perFileBytes ?? DEFAULT_RELEVANT_PER_FILE_BYTES;
|
|
103
|
+
if (maxFiles <= 0 || maxTotalBytes <= 0 || perFileBytes <= 0) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
const normalizedKeywords = [
|
|
107
|
+
...new Set(keywords
|
|
108
|
+
.map((kw) => kw.toLowerCase().replace(/[^a-z0-9_-]/g, "").trim())
|
|
109
|
+
.filter((kw) => kw.length > 3)),
|
|
110
|
+
];
|
|
111
|
+
if (normalizedKeywords.length === 0)
|
|
112
|
+
return "";
|
|
113
|
+
const files = this.listMemoryFiles();
|
|
114
|
+
const matches = files
|
|
115
|
+
.map((file) => {
|
|
116
|
+
const name = path.basename(file, ".md").toLowerCase();
|
|
117
|
+
const score = normalizedKeywords.filter((kw) => name.includes(kw)).length;
|
|
118
|
+
if (score === 0)
|
|
119
|
+
return null;
|
|
120
|
+
const filePath = path.join(this.memoryDir, file);
|
|
121
|
+
const mtimeMs = fs.statSync(filePath).mtimeMs;
|
|
122
|
+
return { file, filePath, key: path.basename(file, ".md"), score, mtimeMs };
|
|
123
|
+
})
|
|
124
|
+
.filter((m) => m !== null)
|
|
125
|
+
.sort((a, b) => b.score - a.score || b.mtimeMs - a.mtimeMs);
|
|
126
|
+
const blocks = [];
|
|
127
|
+
for (const match of matches) {
|
|
128
|
+
if (blocks.length >= maxFiles)
|
|
129
|
+
break;
|
|
130
|
+
let content = fs.readFileSync(match.filePath, "utf-8");
|
|
131
|
+
if (byteLength(content) > perFileBytes) {
|
|
132
|
+
content =
|
|
133
|
+
truncateToBytes(content, perFileBytes) +
|
|
134
|
+
`\n\n... [truncated; call memory.read("${match.key}") for full]`;
|
|
135
|
+
}
|
|
136
|
+
const block = `## ${match.file}\n${content}`;
|
|
137
|
+
const candidate = blocks.length > 0
|
|
138
|
+
? `${blocks.join("\n\n")}\n\n${block}`
|
|
139
|
+
: block;
|
|
140
|
+
if (byteLength(candidate) > maxTotalBytes)
|
|
141
|
+
break;
|
|
142
|
+
blocks.push(block);
|
|
143
|
+
}
|
|
144
|
+
const moreMatches = matches.length - blocks.length;
|
|
145
|
+
const body = blocks.join("\n\n");
|
|
146
|
+
if (moreMatches <= 0)
|
|
147
|
+
return body;
|
|
148
|
+
const note = `... (${moreMatches} more matching memories not loaded; use memory.list to see all keys and memory.read("key") to fetch full content).`;
|
|
149
|
+
return appendNoteWithinBudget(body, note, maxTotalBytes);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Save a memory file and update the index. Scheduled tasks should NOT call
|
|
153
|
+
* this directly — task-runner rejects memory.save at the dispatch layer and
|
|
154
|
+
* funnels structured cross-run state to the store tool instead.
|
|
155
|
+
*/
|
|
156
|
+
save(key, title, content) {
|
|
157
|
+
const safeKey = keyToSafe(key);
|
|
158
|
+
if (!safeKey) {
|
|
159
|
+
return `Memory rejected: empty key after normalization.`;
|
|
160
|
+
}
|
|
161
|
+
if (isDateLikeKey(safeKey)) {
|
|
162
|
+
return `Memory rejected: key "${key}" looks date- or timestamp-based. Memory is for stable, reusable knowledge — not per-day logs. Use a stable key (e.g. "task1-rules", "x-login-flow") and overwrite it. For run-by-run results, rely on the execution logger instead of memory.`;
|
|
163
|
+
}
|
|
164
|
+
const contentBytes = byteLength(content);
|
|
165
|
+
if (contentBytes > MAX_MEMORY_CONTENT_BYTES) {
|
|
166
|
+
return `Memory rejected: content is ${contentBytes} bytes, cap is ${MAX_MEMORY_CONTENT_BYTES}. Summarize, split into multiple stable keys, or for growing lists keep only the most recent N items.`;
|
|
167
|
+
}
|
|
168
|
+
const filePath = path.join(this.memoryDir, `${safeKey}.md`);
|
|
169
|
+
const fileContent = `---
|
|
170
|
+
name: ${safeKey}
|
|
171
|
+
title: ${title}
|
|
172
|
+
updated: ${new Date().toISOString()}
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
${content}
|
|
176
|
+
`;
|
|
177
|
+
fs.writeFileSync(filePath, fileContent, "utf-8");
|
|
178
|
+
// Update index
|
|
179
|
+
this.updateIndex(safeKey, title);
|
|
180
|
+
return `Memory saved: ${safeKey}`;
|
|
181
|
+
}
|
|
182
|
+
/** Read a specific memory file */
|
|
183
|
+
read(key) {
|
|
184
|
+
const safeKey = keyToSafe(key);
|
|
185
|
+
const filePath = path.join(this.memoryDir, `${safeKey}.md`);
|
|
186
|
+
if (!fs.existsSync(filePath)) {
|
|
187
|
+
return `Memory '${key}' not found.`;
|
|
188
|
+
}
|
|
189
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* One-time cleanup: prior to the keyToSafe fix, an LLM passing key="foo.md"
|
|
193
|
+
* produced `foo_md.md`, then `foo_md_md.md` on next call, etc. Detect these
|
|
194
|
+
* `(_md)+\.md$` filenames, merge them with the canonical `foo.md` file
|
|
195
|
+
* (keeping the newest mtime), and prune dead lines from MEMORY.md.
|
|
196
|
+
*
|
|
197
|
+
* Idempotent: a clean directory makes this a no-op.
|
|
198
|
+
*/
|
|
199
|
+
migrateMdSuffixDuplicates() {
|
|
200
|
+
let files;
|
|
201
|
+
try {
|
|
202
|
+
files = fs.readdirSync(this.memoryDir);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// canonicalBase ("foo") -> list of {file, mtimeMs}
|
|
208
|
+
const groups = new Map();
|
|
209
|
+
for (const f of files) {
|
|
210
|
+
if (!f.endsWith(".md") || f === "MEMORY.md")
|
|
211
|
+
continue;
|
|
212
|
+
const base = f.slice(0, -3); // strip ".md"
|
|
213
|
+
const canonical = base.replace(/(_md)+$/i, "");
|
|
214
|
+
if (canonical === base)
|
|
215
|
+
continue; // not a suffix-bug victim, but the canonical sibling may exist
|
|
216
|
+
const stat = fs.statSync(path.join(this.memoryDir, f));
|
|
217
|
+
const list = groups.get(canonical) ?? [];
|
|
218
|
+
list.push({ file: f, mtimeMs: stat.mtimeMs });
|
|
219
|
+
groups.set(canonical, list);
|
|
220
|
+
}
|
|
221
|
+
// Add canonical sibling (if it exists) into each group so the merge picks
|
|
222
|
+
// the freshest file across "foo.md" + "foo_md.md" + "foo_md_md.md".
|
|
223
|
+
for (const [canonical, list] of groups) {
|
|
224
|
+
const canonicalFile = `${canonical}.md`;
|
|
225
|
+
const canonicalPath = path.join(this.memoryDir, canonicalFile);
|
|
226
|
+
if (fs.existsSync(canonicalPath)) {
|
|
227
|
+
const stat = fs.statSync(canonicalPath);
|
|
228
|
+
list.push({ file: canonicalFile, mtimeMs: stat.mtimeMs });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const archived = [];
|
|
232
|
+
const archiveDir = path.join(this.memoryDir, "_archive_md_duplicates");
|
|
233
|
+
fs.mkdirSync(archiveDir, { recursive: true });
|
|
234
|
+
for (const [canonical, list] of groups) {
|
|
235
|
+
list.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
236
|
+
const winner = list[0];
|
|
237
|
+
const canonicalFile = `${canonical}.md`;
|
|
238
|
+
const canonicalPath = path.join(this.memoryDir, canonicalFile);
|
|
239
|
+
if (winner.file !== canonicalFile) {
|
|
240
|
+
// The winner is an `_md` sibling that's about to overwrite canonical.
|
|
241
|
+
// If canonical exists and is part of the group (i.e. lost the mtime
|
|
242
|
+
// race), archive its current content first so we never silently
|
|
243
|
+
// destroy a file that simply lost the race.
|
|
244
|
+
const canonicalLost = list.some((e) => e.file === canonicalFile);
|
|
245
|
+
if (canonicalLost && fs.existsSync(canonicalPath)) {
|
|
246
|
+
try {
|
|
247
|
+
const destPath = this.nextArchivePath(archiveDir, canonicalFile);
|
|
248
|
+
fs.copyFileSync(canonicalPath, destPath);
|
|
249
|
+
archived.push(canonicalFile);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// best-effort
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
fs.copyFileSync(path.join(this.memoryDir, winner.file), canonicalPath);
|
|
256
|
+
}
|
|
257
|
+
for (const entry of list) {
|
|
258
|
+
if (entry.file === canonicalFile)
|
|
259
|
+
continue;
|
|
260
|
+
try {
|
|
261
|
+
const sourcePath = path.join(this.memoryDir, entry.file);
|
|
262
|
+
const destPath = this.nextArchivePath(archiveDir, entry.file);
|
|
263
|
+
fs.renameSync(sourcePath, destPath);
|
|
264
|
+
archived.push(entry.file);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// best-effort
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (archived.length > 0) {
|
|
272
|
+
// For each canonical file that now exists, ensure MEMORY.md has an
|
|
273
|
+
// up-to-date line pointing at it (using the survivor's frontmatter
|
|
274
|
+
// title), then drop any remaining lines pointing at deleted files.
|
|
275
|
+
for (const canonical of groups.keys()) {
|
|
276
|
+
const canonicalFile = `${canonical}.md`;
|
|
277
|
+
const canonicalPath = path.join(this.memoryDir, canonicalFile);
|
|
278
|
+
if (!fs.existsSync(canonicalPath))
|
|
279
|
+
continue;
|
|
280
|
+
const title = this.readFrontmatterTitle(canonicalPath) || canonical;
|
|
281
|
+
this.updateIndex(canonical, title);
|
|
282
|
+
}
|
|
283
|
+
this.pruneIndexOfMissingFiles();
|
|
284
|
+
console.log(`[memory] archived ${archived.length} duplicate file(s) caused by .md key bug to ${archiveDir}: ${archived.join(", ")}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
nextArchivePath(archiveDir, file) {
|
|
288
|
+
const parsed = path.parse(file);
|
|
289
|
+
let dest = path.join(archiveDir, file);
|
|
290
|
+
let i = 1;
|
|
291
|
+
while (fs.existsSync(dest)) {
|
|
292
|
+
dest = path.join(archiveDir, `${parsed.name}.${i}${parsed.ext}`);
|
|
293
|
+
i++;
|
|
294
|
+
}
|
|
295
|
+
return dest;
|
|
296
|
+
}
|
|
297
|
+
/** Read the `title:` line from a memory file's YAML frontmatter, if present. */
|
|
298
|
+
readFrontmatterTitle(filePath) {
|
|
299
|
+
try {
|
|
300
|
+
const head = fs.readFileSync(filePath, "utf-8").slice(0, 2048);
|
|
301
|
+
if (!head.startsWith("---"))
|
|
302
|
+
return null;
|
|
303
|
+
const end = head.indexOf("\n---", 3);
|
|
304
|
+
if (end < 0)
|
|
305
|
+
return null;
|
|
306
|
+
const block = head.slice(3, end);
|
|
307
|
+
const m = block.match(/^title:\s*(.+)$/m);
|
|
308
|
+
return m ? m[1].trim() : null;
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/** Drop lines from MEMORY.md that point to files that no longer exist. */
|
|
315
|
+
pruneIndexOfMissingFiles() {
|
|
316
|
+
if (!fs.existsSync(this.indexFile))
|
|
317
|
+
return;
|
|
318
|
+
const lines = fs.readFileSync(this.indexFile, "utf-8").split("\n");
|
|
319
|
+
const kept = [];
|
|
320
|
+
for (const line of lines) {
|
|
321
|
+
const m = line.match(/\]\(([^)]+\.md)\)/);
|
|
322
|
+
if (m) {
|
|
323
|
+
const target = path.join(this.memoryDir, m[1]);
|
|
324
|
+
if (!fs.existsSync(target))
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
kept.push(line);
|
|
328
|
+
}
|
|
329
|
+
fs.writeFileSync(this.indexFile, kept.join("\n"), "utf-8");
|
|
330
|
+
}
|
|
331
|
+
/** List all memory files */
|
|
332
|
+
list() {
|
|
333
|
+
return this.loadIndex() || "(no memories saved)";
|
|
334
|
+
}
|
|
335
|
+
listMemoryFiles() {
|
|
336
|
+
if (!fs.existsSync(this.memoryDir))
|
|
337
|
+
return [];
|
|
338
|
+
return fs
|
|
339
|
+
.readdirSync(this.memoryDir)
|
|
340
|
+
.filter((f) => f.endsWith(".md") && f !== "MEMORY.md");
|
|
341
|
+
}
|
|
342
|
+
parseIndex(index) {
|
|
343
|
+
const headerLines = [];
|
|
344
|
+
const entries = [];
|
|
345
|
+
let seenEntry = false;
|
|
346
|
+
for (const line of index.split("\n")) {
|
|
347
|
+
const m = line.match(/^- \[[^\]]*\]\(([^)]+\.md)\)\s*$/);
|
|
348
|
+
if (!m) {
|
|
349
|
+
if (!seenEntry)
|
|
350
|
+
headerLines.push(line);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
seenEntry = true;
|
|
354
|
+
const file = m[1];
|
|
355
|
+
const filePath = path.join(this.memoryDir, file);
|
|
356
|
+
const mtimeMs = fs.existsSync(filePath) ? fs.statSync(filePath).mtimeMs : 0;
|
|
357
|
+
entries.push({ line, file, mtimeMs });
|
|
358
|
+
}
|
|
359
|
+
return { headerLines, entries };
|
|
360
|
+
}
|
|
361
|
+
renderIndex(headerLines, entries, hiddenCount) {
|
|
362
|
+
const out = [...headerLines];
|
|
363
|
+
while (out.length > 0 && out[out.length - 1].trim() === "") {
|
|
364
|
+
out.pop();
|
|
365
|
+
}
|
|
366
|
+
if (entries.length > 0) {
|
|
367
|
+
if (out.length > 0)
|
|
368
|
+
out.push("");
|
|
369
|
+
out.push(...entries.map((entry) => entry.line));
|
|
370
|
+
}
|
|
371
|
+
if (hiddenCount > 0) {
|
|
372
|
+
out.push("", `... and ${hiddenCount} older memories not shown (use memory.list to see all keys and memory.read("key") to load any full memory).`);
|
|
373
|
+
}
|
|
374
|
+
return out.join("\n");
|
|
375
|
+
}
|
|
376
|
+
updateIndex(key, title) {
|
|
377
|
+
let index = this.loadIndex();
|
|
378
|
+
if (!index.trim()) {
|
|
379
|
+
index = "# Agent Memory\n\n";
|
|
380
|
+
}
|
|
381
|
+
const lines = index.split("\n");
|
|
382
|
+
const entryLine = `- [${title}](${key}.md)`;
|
|
383
|
+
// Check if entry already exists and update it
|
|
384
|
+
const existingIdx = lines.findIndex((l) => l.includes(`](${key}.md)`));
|
|
385
|
+
if (existingIdx >= 0) {
|
|
386
|
+
lines[existingIdx] = entryLine;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// Add after header
|
|
390
|
+
const headerEnd = lines.findIndex((l, i) => i > 0 && l.trim() === "");
|
|
391
|
+
if (headerEnd >= 0) {
|
|
392
|
+
lines.splice(headerEnd + 1, 0, entryLine);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
lines.push(entryLine);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
fs.writeFileSync(this.indexFile, lines.join("\n"), "utf-8");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/agent/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC,MAAM,gCAAgC,GAAG,EAAE,GAAG,IAAI,CAAC;AACnD,MAAM,+BAA+B,GAAG,CAAC,GAAG,IAAI,CAAC;AAajD;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,IAAI,OAAO,GAAG,GAAG,CAAC;IAClB,OAAO,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,sEAAsE;AACtE,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,CACL,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAc,oBAAoB;QACvD,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,aAAa;QAClD,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAW,wCAAwC;KAC7E,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,O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AAC;QACF,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,mBAAmB;YACnB,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAC/B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CACnC,CAAC;YACF,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;gBACnB,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DipclawConfig } from "../config/types.js";
|
|
2
|
+
export interface OrgTask {
|
|
3
|
+
id: string;
|
|
4
|
+
instruction: string;
|
|
5
|
+
assignedBy: string;
|
|
6
|
+
assignedAt: string;
|
|
7
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
8
|
+
result?: string;
|
|
9
|
+
targetDepartment?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentStatus {
|
|
12
|
+
name: string;
|
|
13
|
+
role: "boss" | "worker";
|
|
14
|
+
department: string;
|
|
15
|
+
lastSeen: string;
|
|
16
|
+
status: "idle" | "busy";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 组织管理器 (OrgManager)
|
|
20
|
+
* 负责处理跨 Agent 的通信、任务派发、状态汇报。
|
|
21
|
+
* 它采用“信箱模式”(Mailbox Pattern),通过在共享目录读写 JSON 文件实现解耦和高可靠的通信。
|
|
22
|
+
*/
|
|
23
|
+
export declare class OrgManager {
|
|
24
|
+
private config;
|
|
25
|
+
private heartbeatInterval;
|
|
26
|
+
constructor(config: DipclawConfig);
|
|
27
|
+
/** Get the primary department for this agent (used for registry/inbox) */
|
|
28
|
+
getPrimaryDepartment(): string;
|
|
29
|
+
/** Get all departments this agent can manage/view */
|
|
30
|
+
getManagedDepartments(): string[];
|
|
31
|
+
/**
|
|
32
|
+
* 初始化组织环境
|
|
33
|
+
* - 如果尚未注册,会在 registry 目录下创建该 Agent 的心跳文件。
|
|
34
|
+
* - 如果是员工,会为其建立专属的收件箱文件夹。
|
|
35
|
+
* - 启动定时器,定期更新自己的心跳状态(在线时间、忙闲状态),并清理过期历史任务。
|
|
36
|
+
*/
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* 定期清理和归档逻辑
|
|
40
|
+
* 1. 将收件箱里超过 24 小时的已完成/已失败任务转移到历史库 (history) 目录。
|
|
41
|
+
* 2. 将卡在 running 状态超过 24 小时的死锁任务强行标记为 failed(防止 Agent 崩溃导致的僵尸任务)。
|
|
42
|
+
* 3. 删除历史库中存放超过 7 天的文件,释放磁盘空间。
|
|
43
|
+
*/
|
|
44
|
+
private cleanup;
|
|
45
|
+
private updateStatus;
|
|
46
|
+
setStatus(status: "idle" | "busy"): void;
|
|
47
|
+
/**
|
|
48
|
+
* 获取团队名单 (仅老板常用)
|
|
49
|
+
* 老板会扫描自己所管辖的部门注册表,读取所有员工的心跳文件。
|
|
50
|
+
*/
|
|
51
|
+
listTeam(): AgentStatus[];
|
|
52
|
+
/**
|
|
53
|
+
* 指派任务 (核心方法)
|
|
54
|
+
* @param target 目标员工名称,可以带前缀如 "dept:推广部",或者填 "all" 广播全员。
|
|
55
|
+
* @param instruction 具体的操作指令文本。
|
|
56
|
+
* @returns 分发成功的任务 ID 列表。
|
|
57
|
+
*/
|
|
58
|
+
assignTask(target: string, instruction: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* 轮询查收新任务 (仅员工常用)
|
|
61
|
+
* 员工读取自己收件箱下的所有 JSON 文件,筛选出状态为 pending 的任务。
|
|
62
|
+
*/
|
|
63
|
+
pollTasks(): OrgTask[];
|
|
64
|
+
/**
|
|
65
|
+
* 更新任务状态与回传结果
|
|
66
|
+
* 员工在接单、完成、报错时,都会调用此方法覆盖修改收件箱里的同一个 JSON 文件。
|
|
67
|
+
*/
|
|
68
|
+
updateTask(taskId: string, status: OrgTask["status"], result?: string): void;
|
|
69
|
+
stop(): void;
|
|
70
|
+
}
|