memory-journal-mcp 9.0.0 → 9.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/README.md +165 -124
- package/dist/audit/interceptor.d.ts.map +1 -1
- package/dist/auth/authorization-server-discovery.d.ts.map +1 -1
- package/dist/auth/middleware.d.ts +11 -22
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/scope-map.d.ts.map +1 -1
- package/dist/auth/scopes.d.ts.map +1 -1
- package/dist/auth/token-validator.d.ts.map +1 -1
- package/dist/auth/transport-agnostic.d.ts +4 -0
- package/dist/auth/transport-agnostic.d.ts.map +1 -1
- package/dist/auth/validation.d.ts +1 -0
- package/dist/auth/validation.d.ts.map +1 -1
- package/dist/{chunk-6RCZ4IYV.js → chunk-4FZCHFB5.js} +28 -5
- package/dist/{chunk-AIWHVEOW.js → chunk-D2FY6XS5.js} +99 -7
- package/dist/chunk-FZLB6NAV.js +746 -0
- package/dist/{chunk-NVXCRDCO.js → chunk-LE6ZWUPK.js} +216 -138
- package/dist/chunk-SGJU2DHU.js +2102 -0
- package/dist/{chunk-2UIMA6JF.js → chunk-T7SROBBV.js} +32375 -29351
- package/dist/{chunk-IYZWMAA4.js → chunk-Y6MMKR2Z.js} +957 -1333
- package/dist/cli/commands/admin.d.ts +1 -1
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/entry-payload.d.ts +38 -0
- package/dist/cli/commands/entry-payload.d.ts.map +1 -0
- package/dist/cli/commands/entry.d.ts +10 -0
- package/dist/cli/commands/entry.d.ts.map +1 -1
- package/dist/cli/commands/exec.d.ts.map +1 -1
- package/dist/cli/commands/io.d.ts +1 -0
- package/dist/cli/commands/io.d.ts.map +1 -1
- package/dist/cli/commands/visualize.d.ts.map +1 -1
- package/dist/cli/index.js +7 -10
- package/dist/cli/schemas.d.ts +14 -1
- package/dist/cli/schemas.d.ts.map +1 -1
- package/dist/cli/server-options-builder.d.ts.map +1 -1
- package/dist/cli.js +7 -10
- package/dist/codemode/api/journal-api.d.ts +5 -23
- package/dist/codemode/api/journal-api.d.ts.map +1 -1
- package/dist/codemode/api/key-normalizer.d.ts +8 -0
- package/dist/codemode/api/key-normalizer.d.ts.map +1 -0
- package/dist/codemode/api/param-normalizer.d.ts +2 -4
- package/dist/codemode/api/param-normalizer.d.ts.map +1 -1
- package/dist/codemode/api/project-registry-ops.d.ts +26 -0
- package/dist/codemode/api/project-registry-ops.d.ts.map +1 -0
- package/dist/codemode/api/sandbox-bindings.d.ts +25 -0
- package/dist/codemode/api/sandbox-bindings.d.ts.map +1 -0
- package/dist/codemode/api/types.d.ts.map +1 -1
- package/dist/codemode/api-constants.d.ts +3 -39
- package/dist/codemode/api-constants.d.ts.map +1 -1
- package/dist/codemode/constants/examples-and-params.d.ts +31 -0
- package/dist/codemode/constants/examples-and-params.d.ts.map +1 -0
- package/dist/codemode/constants/method-aliases.d.ts +8 -0
- package/dist/codemode/constants/method-aliases.d.ts.map +1 -0
- package/dist/codemode/normalizers/domain-tool-interceptions.d.ts +6 -0
- package/dist/codemode/normalizers/domain-tool-interceptions.d.ts.map +1 -0
- package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts +6 -0
- package/dist/codemode/normalizers/entry-and-search-interceptions.d.ts.map +1 -0
- package/dist/codemode/normalizers/generic-interceptions.d.ts +6 -0
- package/dist/codemode/normalizers/generic-interceptions.d.ts.map +1 -0
- package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts +6 -0
- package/dist/codemode/normalizers/github-and-backup-interceptions.d.ts.map +1 -0
- package/dist/codemode/normalizers/shared-utils.d.ts +31 -0
- package/dist/codemode/normalizers/shared-utils.d.ts.map +1 -0
- package/dist/codemode/param-normalizer.d.ts +5 -1
- package/dist/codemode/param-normalizer.d.ts.map +1 -1
- package/dist/codemode/proxy-helpers.d.ts +34 -0
- package/dist/codemode/proxy-helpers.d.ts.map +1 -0
- package/dist/codemode/proxy-namespaces.d.ts +30 -0
- package/dist/codemode/proxy-namespaces.d.ts.map +1 -0
- package/dist/codemode/security.d.ts +11 -0
- package/dist/codemode/security.d.ts.map +1 -1
- package/dist/codemode/type-generator.d.ts.map +1 -1
- package/dist/codemode/types.d.ts.map +1 -1
- package/dist/codemode/worker/mj-shim-domains.d.ts +15 -0
- package/dist/codemode/worker/mj-shim-domains.d.ts.map +1 -0
- package/dist/codemode/worker/mj-shim-proxy.d.ts +18 -0
- package/dist/codemode/worker/mj-shim-proxy.d.ts.map +1 -0
- package/dist/codemode/worker/namespace-shims.d.ts +32 -0
- package/dist/codemode/worker/namespace-shims.d.ts.map +1 -0
- package/dist/codemode/worker/node-shims.d.ts +65 -0
- package/dist/codemode/worker/node-shims.d.ts.map +1 -0
- package/dist/codemode/worker/prototype-hardening.d.ts +18 -0
- package/dist/codemode/worker/prototype-hardening.d.ts.map +1 -0
- package/dist/codemode/worker/result-compactor.d.ts +20 -0
- package/dist/codemode/worker/result-compactor.d.ts.map +1 -0
- package/dist/codemode/worker/sandbox-globals.d.ts +19 -0
- package/dist/codemode/worker/sandbox-globals.d.ts.map +1 -0
- package/dist/codemode/worker-api-proxy.d.ts +1 -6
- package/dist/codemode/worker-api-proxy.d.ts.map +1 -1
- package/dist/codemode/worker-result-proxy.d.ts.map +1 -1
- package/dist/codemode/worker-sandbox.d.ts.map +1 -1
- package/dist/constants/instructions/admin.d.ts +1 -1
- package/dist/constants/instructions/admin.d.ts.map +1 -1
- package/dist/constants/instructions/base.d.ts +2 -2
- package/dist/constants/instructions/base.d.ts.map +1 -1
- package/dist/constants/instructions/codemode.d.ts +1 -1
- package/dist/constants/instructions/codemode.d.ts.map +1 -1
- package/dist/constants/instructions/core.d.ts +1 -1
- package/dist/constants/instructions/core.d.ts.map +1 -1
- package/dist/constants/instructions/github.d.ts +1 -1
- package/dist/constants/instructions/github.d.ts.map +1 -1
- package/dist/constants/instructions/gotchas.d.ts +1 -1
- package/dist/constants/instructions/gotchas.d.ts.map +1 -1
- package/dist/constants/instructions/io.d.ts +1 -1
- package/dist/constants/instructions/io.d.ts.map +1 -1
- package/dist/constants/instructions/templates.d.ts +1 -1
- package/dist/constants/instructions/templates.d.ts.map +1 -1
- package/dist/constants/server-instructions.d.ts +2 -2
- package/dist/constants/server-instructions.d.ts.map +1 -1
- package/dist/database/core/interfaces.d.ts +6 -6
- package/dist/database/core/interfaces.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/adapter-delegates.d.ts +161 -0
- package/dist/database/sqlite-adapter/adapter-delegates.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/backup.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/database-adapter.d.ts +17 -147
- package/dist/database/sqlite-adapter/database-adapter.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/crud-read.d.ts +16 -0
- package/dist/database/sqlite-adapter/entries/crud-read.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/crud-write.d.ts +62 -0
- package/dist/database/sqlite-adapter/entries/crud-write.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/crud.d.ts +3 -92
- package/dist/database/sqlite-adapter/entries/crud.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/importance.d.ts +7 -0
- package/dist/database/sqlite-adapter/entries/importance.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/index.d.ts +9 -4
- package/dist/database/sqlite-adapter/entries/index.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/revisions.d.ts +16 -0
- package/dist/database/sqlite-adapter/entries/revisions.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts +37 -0
- package/dist/database/sqlite-adapter/entries/search/date-and-pagination.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts +31 -0
- package/dist/database/sqlite-adapter/entries/search/entity-lookups.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts +44 -0
- package/dist/database/sqlite-adapter/entries/search/fts-and-hybrid.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/entries/search/index.d.ts +1 -1
- package/dist/database/sqlite-adapter/entries/search/index.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/search/query.d.ts +3 -82
- package/dist/database/sqlite-adapter/entries/search/query.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/entries/statistics.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/insights/cross-project.d.ts +42 -0
- package/dist/database/sqlite-adapter/insights/cross-project.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts +17 -0
- package/dist/database/sqlite-adapter/insights/entry-digest-queries.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts +29 -0
- package/dist/database/sqlite-adapter/insights/team-collaboration.d.ts.map +1 -0
- package/dist/database/sqlite-adapter/insights-operations.d.ts +11 -50
- package/dist/database/sqlite-adapter/insights-operations.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/lifecycle-operations.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/members.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/native-connection.d.ts +5 -0
- package/dist/database/sqlite-adapter/native-connection.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/relationships.d.ts +1 -2
- package/dist/database/sqlite-adapter/relationships.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/tags.d.ts.map +1 -1
- package/dist/database/sqlite-adapter/vector-operations.d.ts.map +1 -1
- package/dist/filtering/tool-constants.d.ts +1 -1
- package/dist/{fts-T466O2JP.js → fts-YHUVPPYF.js} +2 -2
- package/dist/github/commit-references/enricher.d.ts.map +1 -1
- package/dist/github/github-integration/projects.d.ts.map +1 -1
- package/dist/handlers/prompts/adversarial-helpers.d.ts +75 -0
- package/dist/handlers/prompts/adversarial-helpers.d.ts.map +1 -0
- package/dist/handlers/prompts/adversarial.d.ts +3 -5
- package/dist/handlers/prompts/adversarial.d.ts.map +1 -1
- package/dist/handlers/prompts/cms-supervisor.d.ts +8 -0
- package/dist/handlers/prompts/cms-supervisor.d.ts.map +1 -0
- package/dist/handlers/prompts/index.d.ts.map +1 -1
- package/dist/handlers/prompts/optimizer.d.ts.map +1 -1
- package/dist/handlers/prompts/workflow.d.ts.map +1 -1
- package/dist/handlers/resources/core/briefing/context-section.d.ts.map +1 -1
- package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts +57 -0
- package/dist/handlers/resources/core/briefing/github-repo-and-kanban.d.ts.map +1 -0
- package/dist/handlers/resources/core/briefing/github-section.d.ts +23 -20
- package/dist/handlers/resources/core/briefing/github-section.d.ts.map +1 -1
- package/dist/handlers/resources/core/briefing/system-section.d.ts.map +1 -1
- package/dist/handlers/resources/core/briefing/user-message.d.ts.map +1 -1
- package/dist/handlers/resources/help.d.ts.map +1 -1
- package/dist/handlers/resources/index.d.ts.map +1 -1
- package/dist/handlers/resources/shared.d.ts +1 -0
- package/dist/handlers/resources/shared.d.ts.map +1 -1
- package/dist/handlers/resources/staleness.d.ts.map +1 -1
- package/dist/handlers/tools/admin/batch-tools.d.ts.map +1 -1
- package/dist/handlers/tools/admin/core-tools.d.ts.map +1 -1
- package/dist/handlers/tools/admin/index.d.ts.map +1 -1
- package/dist/handlers/tools/admin/lifecycle-tools.d.ts.map +1 -1
- package/dist/handlers/tools/admin/project-tools.d.ts +1 -1
- package/dist/handlers/tools/admin/project-tools.d.ts.map +1 -1
- package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts +609 -0
- package/dist/handlers/tools/admin/schemas/crud-batch-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts +136 -0
- package/dist/handlers/tools/admin/schemas/project-and-ops-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/admin/schemas.d.ts +2 -733
- package/dist/handlers/tools/admin/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/admin/update_configuration.d.ts +14 -0
- package/dist/handlers/tools/admin/update_configuration.d.ts.map +1 -1
- package/dist/handlers/tools/admin/vector-tools.d.ts.map +1 -1
- package/dist/handlers/tools/analytics.d.ts.map +1 -1
- package/dist/handlers/tools/arg-interceptions.d.ts +51 -0
- package/dist/handlers/tools/arg-interceptions.d.ts.map +1 -0
- package/dist/handlers/tools/codemode/code-healer.d.ts +11 -0
- package/dist/handlers/tools/codemode/code-healer.d.ts.map +1 -0
- package/dist/handlers/tools/codemode/handler.d.ts +4 -23
- package/dist/handlers/tools/codemode/handler.d.ts.map +1 -1
- package/dist/handlers/tools/codemode/json-entry-recovery.d.ts +13 -0
- package/dist/handlers/tools/codemode/json-entry-recovery.d.ts.map +1 -0
- package/dist/handlers/tools/codemode/payload-synthesizer.d.ts +17 -0
- package/dist/handlers/tools/codemode/payload-synthesizer.d.ts.map +1 -0
- package/dist/handlers/tools/codemode/secure-dispatcher.d.ts +25 -0
- package/dist/handlers/tools/codemode/secure-dispatcher.d.ts.map +1 -0
- package/dist/handlers/tools/codemode/sql-recovery.d.ts +14 -0
- package/dist/handlers/tools/codemode/sql-recovery.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts +21 -0
- package/dist/handlers/tools/core/dummy-healing/alias-catalog.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts +4 -0
- package/dist/handlers/tools/core/dummy-healing/entry-fallbacks.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts +19 -0
- package/dist/handlers/tools/core/dummy-healing/fs-fallbacks.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing/index.d.ts +7 -0
- package/dist/handlers/tools/core/dummy-healing/index.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts +12 -0
- package/dist/handlers/tools/core/dummy-healing/mcp-fallbacks.d.ts.map +1 -0
- package/dist/handlers/tools/core/dummy-healing.d.ts +1 -29
- package/dist/handlers/tools/core/dummy-healing.d.ts.map +1 -1
- package/dist/handlers/tools/core/index.d.ts +1 -1
- package/dist/handlers/tools/core/index.d.ts.map +1 -1
- package/dist/handlers/tools/core/schemas.d.ts +33 -9
- package/dist/handlers/tools/core/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/core/staleness-tools.d.ts +17 -0
- package/dist/handlers/tools/core/staleness-tools.d.ts.map +1 -1
- package/dist/handlers/tools/core/tools.d.ts.map +1 -1
- package/dist/handlers/tools/git.d.ts +5 -11
- package/dist/handlers/tools/git.d.ts.map +1 -1
- package/dist/handlers/tools/github/close-issue-tool.d.ts +6 -0
- package/dist/handlers/tools/github/close-issue-tool.d.ts.map +1 -0
- package/dist/handlers/tools/github/create-issue-tool.d.ts +6 -0
- package/dist/handlers/tools/github/create-issue-tool.d.ts.map +1 -0
- package/dist/handlers/tools/github/issue-tools.d.ts +3 -0
- package/dist/handlers/tools/github/issue-tools.d.ts.map +1 -1
- package/dist/handlers/tools/github/kanban-tools.d.ts.map +1 -1
- package/dist/handlers/tools/github/milestone-tools.d.ts.map +1 -1
- package/dist/handlers/tools/index.d.ts +2 -2
- package/dist/handlers/tools/index.d.ts.map +1 -1
- package/dist/handlers/tools/io/schemas.d.ts +5 -2
- package/dist/handlers/tools/io/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/relationships.d.ts.map +1 -1
- package/dist/handlers/tools/schemas/constants-and-primitives.d.ts +53 -0
- package/dist/handlers/tools/schemas/constants-and-primitives.d.ts.map +1 -0
- package/dist/handlers/tools/schemas/hallucination-healer.d.ts +8 -0
- package/dist/handlers/tools/schemas/hallucination-healer.d.ts.map +1 -0
- package/dist/handlers/tools/schemas/output-schemas.d.ts +247 -0
- package/dist/handlers/tools/schemas/output-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/schemas.d.ts +4 -306
- package/dist/handlers/tools/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/search/cross-team.d.ts +14 -0
- package/dist/handlers/tools/search/cross-team.d.ts.map +1 -1
- package/dist/handlers/tools/search/helpers.d.ts.map +1 -1
- package/dist/handlers/tools/search/hybrid.d.ts.map +1 -1
- package/dist/handlers/tools/search/misc-tools.d.ts.map +1 -1
- package/dist/handlers/tools/search/schemas.d.ts +6 -3
- package/dist/handlers/tools/search/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/search/search-entries.d.ts.map +1 -1
- package/dist/handlers/tools/search/semantic-search.d.ts.map +1 -1
- package/dist/handlers/tools/team/admin-tools/batch.d.ts.map +1 -1
- package/dist/handlers/tools/team/admin-tools/crud.d.ts.map +1 -1
- package/dist/handlers/tools/team/backup-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/core-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/helpers.d.ts.map +1 -1
- package/dist/handlers/tools/team/io-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/member-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/rbac.d.ts.map +1 -1
- package/dist/handlers/tools/team/relationship-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts +618 -0
- package/dist/handlers/tools/team/schemas/admin-batch-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts +464 -0
- package/dist/handlers/tools/team/schemas/analytics-vector-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts +525 -0
- package/dist/handlers/tools/team/schemas/core-search-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts +419 -0
- package/dist/handlers/tools/team/schemas/io-backup-schemas.d.ts.map +1 -0
- package/dist/handlers/tools/team/schemas.d.ts +5 -2002
- package/dist/handlers/tools/team/schemas.d.ts.map +1 -1
- package/dist/handlers/tools/team/search-tools.d.ts.map +1 -1
- package/dist/handlers/tools/team/vector-tools.d.ts.map +1 -1
- package/dist/index.js +6 -9
- package/dist/markdown/exporter.d.ts.map +1 -1
- package/dist/markdown/importer.d.ts.map +1 -1
- package/dist/observability/latency-tracker.d.ts.map +1 -1
- package/dist/observability/metrics-server.d.ts +1 -1
- package/dist/observability/metrics-server.d.ts.map +1 -1
- package/dist/observability/token-estimator.d.ts.map +1 -1
- package/dist/{security-utils-HNTROJAG.js → security-utils-P4P6A2DG.js} +1 -1
- package/dist/server/digest-reporter.d.ts +1 -0
- package/dist/server/digest-reporter.d.ts.map +1 -1
- package/dist/server/mcp-server/core.d.ts.map +1 -1
- package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts +6 -0
- package/dist/server/mcp-server/tool-registration/call-interceptor.d.ts.map +1 -0
- package/dist/server/mcp-server/tool-registration/index.d.ts +4 -0
- package/dist/server/mcp-server/tool-registration/index.d.ts.map +1 -0
- package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts +4 -0
- package/dist/server/mcp-server/tool-registration/list-interceptor.d.ts.map +1 -0
- package/dist/server/mcp-server/tool-registration/register-tools.d.ts +18 -0
- package/dist/server/mcp-server/tool-registration/register-tools.d.ts.map +1 -0
- package/dist/server/mcp-server/tool-registration.d.ts +1 -17
- package/dist/server/mcp-server/tool-registration.d.ts.map +1 -1
- package/dist/server/registration.d.ts +2 -0
- package/dist/server/registration.d.ts.map +1 -1
- package/dist/server/scheduler.d.ts +1 -0
- package/dist/server/scheduler.d.ts.map +1 -1
- package/dist/server/subscription-manager.d.ts +2 -0
- package/dist/server/subscription-manager.d.ts.map +1 -1
- package/dist/tools-BOQV7QD3.js +6 -0
- package/dist/transports/http/security.d.ts.map +1 -1
- package/dist/transports/http/server/http-transport.d.ts +25 -0
- package/dist/transports/http/server/http-transport.d.ts.map +1 -0
- package/dist/transports/http/server/index.d.ts +3 -30
- package/dist/transports/http/server/index.d.ts.map +1 -1
- package/dist/transports/http/server/legacy-sse.d.ts.map +1 -1
- package/dist/transports/http/server/protocol-handlers.d.ts +9 -0
- package/dist/transports/http/server/protocol-handlers.d.ts.map +1 -0
- package/dist/types/entities.d.ts +41 -1
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/config-manager.d.ts +2 -0
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/error-helpers.d.ts.map +1 -1
- package/dist/utils/issue-logger.d.ts.map +1 -1
- package/dist/utils/mcp-logger.d.ts +14 -2
- package/dist/utils/mcp-logger.d.ts.map +1 -1
- package/dist/utils/security-utils.d.ts.map +1 -1
- package/dist/utils/vector-index-helpers.d.ts +1 -1
- package/dist/utils/vector-index-helpers.d.ts.map +1 -1
- package/dist/utils/workspace-resolver.d.ts.map +1 -1
- package/dist/vector/vector-search-manager/manager.d.ts +2 -2
- package/dist/vector/vector-search-manager/manager.d.ts.map +1 -1
- package/dist/vector/vector-search-manager/rebuild.d.ts.map +1 -1
- package/dist/vendor/lib-agent-exec/interceptors/git-interceptor.d.ts.map +1 -1
- package/dist/vendor/lib-agent-exec/schema.d.ts +18 -18
- package/dist/vendor/lib-agent-exec/schema.d.ts.map +1 -1
- package/dist/vendor/lib-agent-exec/stream-manager.d.ts.map +1 -1
- package/dist/worker-script.js +2662 -2645
- package/package.json +3 -4
- package/skills/memory-journal-mcp/SKILL.md +8 -8
- package/dist/auth/context.d.ts +0 -7
- package/dist/auth/context.d.ts.map +0 -1
- package/dist/chunk-ELMJYRTT.js +0 -29
- package/dist/chunk-F6WSLZVN.js +0 -675
- package/dist/chunk-JVGY2GHK.js +0 -776
- package/dist/chunk-KWSBCSFM.js +0 -411
- package/dist/chunk-SP5D3XYY.js +0 -1550
- package/dist/chunk-XJMEPP36.js +0 -57
- package/dist/database/core/entry-columns.d.ts +0 -8
- package/dist/database/core/entry-columns.d.ts.map +0 -1
- package/dist/database/core/schema.d.ts +0 -69
- package/dist/database/core/schema.d.ts.map +0 -1
- package/dist/error-helpers-STR7IPUR.js +0 -2
- package/dist/git-runner-6OE7PVKA.js +0 -1
- package/dist/journal-api-UG43ZD7Y.js +0 -1289
- package/dist/tools-RBNFDWIE.js +0 -9
|
@@ -1,1289 +0,0 @@
|
|
|
1
|
-
import { sendProgress } from './chunk-ELMJYRTT.js';
|
|
2
|
-
import { METHOD_ALIASES, GROUP_EXAMPLES, KEEP_PREFIX_GROUPS, GROUP_PREFIX_MAP, POSITIONAL_PARAM_MAP } from './chunk-F6WSLZVN.js';
|
|
3
|
-
import { resolveProjectContext } from './chunk-AIWHVEOW.js';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import * as fs from 'fs';
|
|
6
|
-
import * as os from 'os';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
|
|
9
|
-
// src/codemode/api/types.ts
|
|
10
|
-
function parseProjectRegistry() {
|
|
11
|
-
if (!process.env["PROJECT_REGISTRY"]) return void 0;
|
|
12
|
-
const parsed = JSON.parse(process.env["PROJECT_REGISTRY"]);
|
|
13
|
-
const arr = Object.entries(parsed).map(([name, val]) => ({
|
|
14
|
-
name,
|
|
15
|
-
projectNumber: val.project_number,
|
|
16
|
-
...val
|
|
17
|
-
}));
|
|
18
|
-
return arr;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/codemode/api/param-normalizer.ts
|
|
22
|
-
var PARAM_ALIASES = {
|
|
23
|
-
text: "content",
|
|
24
|
-
body: "content",
|
|
25
|
-
note: "content",
|
|
26
|
-
title: "content",
|
|
27
|
-
entry: "entry_id",
|
|
28
|
-
q: "query",
|
|
29
|
-
issue: "issue_number",
|
|
30
|
-
pr: "pr_number",
|
|
31
|
-
pr_id: "pr_number",
|
|
32
|
-
project: "project_number",
|
|
33
|
-
project_id: "project_number",
|
|
34
|
-
project_name: "project_number",
|
|
35
|
-
projectName: "project_number",
|
|
36
|
-
proj: "project_number",
|
|
37
|
-
milestone_id: "milestone_number",
|
|
38
|
-
issue_id: "issue_number",
|
|
39
|
-
pull_request_id: "pr_number",
|
|
40
|
-
pull_number: "pr_number",
|
|
41
|
-
user: "target_user",
|
|
42
|
-
assignee: "target_user",
|
|
43
|
-
repo_name: "repo",
|
|
44
|
-
version: "expected_version",
|
|
45
|
-
search: "query",
|
|
46
|
-
term: "query",
|
|
47
|
-
keyword: "query",
|
|
48
|
-
source: "source_tag",
|
|
49
|
-
target: "target_tag",
|
|
50
|
-
from: "from_entry_id",
|
|
51
|
-
to: "to_entry_id",
|
|
52
|
-
kind: "entry_type",
|
|
53
|
-
format_type: "format",
|
|
54
|
-
webhook: "report_webhook_url",
|
|
55
|
-
// §1.3: Flag resolution comment aliases
|
|
56
|
-
comment: "resolution",
|
|
57
|
-
resolution_comment: "resolution",
|
|
58
|
-
// §1.3: Severity escalation alias (agents say "escalate severity")
|
|
59
|
-
severity: "flag_type",
|
|
60
|
-
// §1.5: Sort/order aliases
|
|
61
|
-
sort: "sort_by",
|
|
62
|
-
order_by: "sort_by",
|
|
63
|
-
order: "sort_by",
|
|
64
|
-
keep: "keep_count",
|
|
65
|
-
path: "source_dir",
|
|
66
|
-
// common fallback, handled contextually
|
|
67
|
-
// Aliases for missing MCP Code Mode mapping fields
|
|
68
|
-
impactScore: "impact_score",
|
|
69
|
-
trustScore: "trust_score",
|
|
70
|
-
validationStatus: "validation_status",
|
|
71
|
-
// Team identification hallucinations
|
|
72
|
-
team_id: "workspace_id",
|
|
73
|
-
team: "workspace_id"
|
|
74
|
-
};
|
|
75
|
-
var ENTRY_TYPE_ALIASES = {
|
|
76
|
-
"session-summary": "retrospective",
|
|
77
|
-
"session_summary": "retrospective",
|
|
78
|
-
"team-session-summary": "retrospective",
|
|
79
|
-
"team_session_summary": "retrospective",
|
|
80
|
-
"team session summary": "retrospective",
|
|
81
|
-
"summary": "retrospective",
|
|
82
|
-
"bug": "bug_fix",
|
|
83
|
-
"feature": "feature_implementation",
|
|
84
|
-
"note": "technical_note",
|
|
85
|
-
"technical-note": "technical_note",
|
|
86
|
-
"reflection": "personal_reflection",
|
|
87
|
-
"decision": "project_decision",
|
|
88
|
-
"review": "code_review",
|
|
89
|
-
"code": "technical_note",
|
|
90
|
-
"coding": "technical_note",
|
|
91
|
-
"progress": "development_note",
|
|
92
|
-
"status": "development_note",
|
|
93
|
-
"update": "development_note",
|
|
94
|
-
"test": "system_integration_test",
|
|
95
|
-
"testing": "system_integration_test",
|
|
96
|
-
"task": "technical_note"
|
|
97
|
-
};
|
|
98
|
-
var TAG_ALIASES = {
|
|
99
|
-
"session_summary": "session-summary",
|
|
100
|
-
"team_session_summary": "session-summary",
|
|
101
|
-
"team-session-summary": "session-summary",
|
|
102
|
-
"team session summary": "session-summary",
|
|
103
|
-
"commit_narrative": "commit-narrative",
|
|
104
|
-
"bug_fix": "bug-fix",
|
|
105
|
-
"feature_implementation": "feature"
|
|
106
|
-
};
|
|
107
|
-
function convertKeysToSnakeCase(obj, methodName) {
|
|
108
|
-
if ("entry" in obj && typeof obj["entry"] === "object" && obj["entry"] !== null && !Array.isArray(obj["entry"])) {
|
|
109
|
-
const nested = obj["entry"];
|
|
110
|
-
const cloned = { ...obj };
|
|
111
|
-
delete cloned["entry"];
|
|
112
|
-
for (const [k, v] of Object.entries(nested)) {
|
|
113
|
-
if (!(k in cloned) && v !== void 0) {
|
|
114
|
-
cloned[k] = v;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
obj = cloned;
|
|
118
|
-
}
|
|
119
|
-
const result = {};
|
|
120
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
121
|
-
let snakeKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
122
|
-
if (snakeKey === "id" && !("entry_id" in obj) && !("entryId" in obj)) {
|
|
123
|
-
snakeKey = "entry_id";
|
|
124
|
-
}
|
|
125
|
-
if (snakeKey === "type") {
|
|
126
|
-
if (methodName?.toLowerCase().includes("export")) {
|
|
127
|
-
snakeKey = "format";
|
|
128
|
-
} else if (!("entry_type" in obj) && !("flag_type" in obj) && !("entry_type" in result) && !("flag_type" in result)) {
|
|
129
|
-
snakeKey = "entry_type";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (snakeKey === "filename") {
|
|
133
|
-
if (!("source_dir" in obj) && !("source_dir" in result)) {
|
|
134
|
-
if ("project_number" in obj || "tags" in obj || "dry_run" in obj) {
|
|
135
|
-
snakeKey = "source_dir";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (snakeKey === "target_user") {
|
|
140
|
-
if (!("author" in obj) && !("author" in result)) {
|
|
141
|
-
if ("role" in obj || "role" in result) {
|
|
142
|
-
snakeKey = "author";
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const alias = PARAM_ALIASES[snakeKey];
|
|
147
|
-
let useAlias = alias !== void 0 && !(alias in obj) && !(alias in result);
|
|
148
|
-
if (useAlias && snakeKey === "entry") {
|
|
149
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
150
|
-
useAlias = false;
|
|
151
|
-
} else if (typeof value === "string" && (!/^\d+$/.test(value.trim()) || methodName !== void 0 && /create|add|log|insert/i.test(methodName))) {
|
|
152
|
-
useAlias = false;
|
|
153
|
-
snakeKey = "content";
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (useAlias && (snakeKey === "title" || snakeKey === "body")) {
|
|
157
|
-
if (methodName && (methodName.toLowerCase().includes("github") || methodName.toLowerCase().includes("issue") || methodName.toLowerCase().includes("milestone") || methodName.toLowerCase().includes("pr"))) {
|
|
158
|
-
useAlias = false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (useAlias && snakeKey === "keep") {
|
|
162
|
-
if (methodName && !methodName.toLowerCase().includes("backup")) {
|
|
163
|
-
useAlias = false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (useAlias && snakeKey === "mode") {
|
|
167
|
-
if (methodName && !methodName.toLowerCase().includes("config")) {
|
|
168
|
-
useAlias = false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (useAlias && snakeKey === "source") {
|
|
172
|
-
if (methodName?.toLowerCase().includes("import")) {
|
|
173
|
-
useAlias = false;
|
|
174
|
-
snakeKey = "source_format";
|
|
175
|
-
} else if (methodName && !methodName.toLowerCase().includes("link")) ;
|
|
176
|
-
}
|
|
177
|
-
if (useAlias && snakeKey === "path") {
|
|
178
|
-
if (methodName?.toLowerCase().includes("export")) {
|
|
179
|
-
useAlias = false;
|
|
180
|
-
snakeKey = "output_dir";
|
|
181
|
-
} else if (!methodName?.toLowerCase().includes("import")) {
|
|
182
|
-
useAlias = false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (useAlias && (snakeKey === "text" || snakeKey === "body" || snakeKey === "note" || snakeKey === "title")) {
|
|
186
|
-
if (methodName && !(methodName.toLowerCase().includes("create") || methodName.toLowerCase().includes("update") || methodName.toLowerCase().includes("entry") || methodName.toLowerCase().includes("github") || methodName.toLowerCase().includes("issue") || methodName.toLowerCase().includes("pr") || methodName.toLowerCase().includes("milestone"))) {
|
|
187
|
-
useAlias = false;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (useAlias && typeof alias === "string") {
|
|
191
|
-
snakeKey = alias;
|
|
192
|
-
}
|
|
193
|
-
if (snakeKey === "message" || snakeKey === "msg" || snakeKey === "name" || snakeKey === "heading" || snakeKey === "subject" || snakeKey === "description" || snakeKey === "content" || snakeKey === "comment") {
|
|
194
|
-
const isGithubTool = Boolean(methodName && (methodName.toLowerCase().includes("github") || methodName.toLowerCase().includes("issue") || methodName.toLowerCase().includes("pr") || methodName.toLowerCase().includes("milestone")));
|
|
195
|
-
if (isGithubTool) {
|
|
196
|
-
if (snakeKey === "name") {
|
|
197
|
-
if (!("title" in obj) && !("title" in result)) {
|
|
198
|
-
snakeKey = "title";
|
|
199
|
-
}
|
|
200
|
-
} else if (snakeKey === "description" && methodName?.toLowerCase().includes("milestone")) {
|
|
201
|
-
snakeKey = "description";
|
|
202
|
-
} else if (methodName?.toLowerCase().includes("close") && (snakeKey === "message" || snakeKey === "msg" || snakeKey === "content")) {
|
|
203
|
-
if (!("comment" in obj) && !("comment" in result)) {
|
|
204
|
-
snakeKey = "comment";
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
if (!("body" in obj) && !("body" in result) && snakeKey !== "comment") {
|
|
208
|
-
snakeKey = "body";
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
} else if (methodName && (methodName.includes("create") || methodName.includes("update") || methodName.includes("Entry")) && !methodName.toLowerCase().includes("link")) {
|
|
212
|
-
if (!("content" in obj) && !("content" in result)) {
|
|
213
|
-
snakeKey = "content";
|
|
214
|
-
} else if (snakeKey === "name" || snakeKey === "heading" || snakeKey === "subject") {
|
|
215
|
-
snakeKey = "title";
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (snakeKey === "role" && typeof value === "string" && value.toLowerCase() === "contributor") {
|
|
220
|
-
result[snakeKey] = "member";
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
if (snakeKey === "significance_type" && typeof value === "string") {
|
|
224
|
-
const valLower = value.toLowerCase();
|
|
225
|
-
const validTypes = /* @__PURE__ */ new Set(["milestone", "breakthrough", "decision", "architecture", "lesson_learned", "blocker_resolved", "release", "security"]);
|
|
226
|
-
if (!validTypes.has(valLower)) {
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if ((snakeKey.endsWith("_id") || snakeKey === "id" || snakeKey === "project_number") && typeof value === "string") {
|
|
231
|
-
const num = Number(value);
|
|
232
|
-
if (!Number.isNaN(num) && value.trim() !== "") {
|
|
233
|
-
result[snakeKey] = num;
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if ((snakeKey.endsWith("_ids") || snakeKey === "ids") && Array.isArray(value)) {
|
|
238
|
-
result[snakeKey] = value.map((v) => {
|
|
239
|
-
if (typeof v === "string") {
|
|
240
|
-
const num = Number(v);
|
|
241
|
-
if (!Number.isNaN(num) && v.trim() !== "") return num;
|
|
242
|
-
}
|
|
243
|
-
return v;
|
|
244
|
-
});
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (snakeKey === "entry_type" && typeof value === "string") {
|
|
248
|
-
const valLower = value.toLowerCase();
|
|
249
|
-
if (ENTRY_TYPE_ALIASES[valLower]) {
|
|
250
|
-
result[snakeKey] = ENTRY_TYPE_ALIASES[valLower];
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
result[snakeKey] = value;
|
|
255
|
-
}
|
|
256
|
-
if ("tag" in result && !("tags" in result)) {
|
|
257
|
-
const tagVal = result["tag"];
|
|
258
|
-
result["tags"] = Array.isArray(tagVal) ? tagVal : [tagVal];
|
|
259
|
-
delete result["tag"];
|
|
260
|
-
}
|
|
261
|
-
if ("tags" in result && Array.isArray(result["tags"])) {
|
|
262
|
-
result["tags"] = result["tags"].map((tag) => {
|
|
263
|
-
if (typeof tag === "string") {
|
|
264
|
-
const tagLower = tag.trim().toLowerCase();
|
|
265
|
-
return TAG_ALIASES[tagLower] || tag;
|
|
266
|
-
}
|
|
267
|
-
return tag;
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if ("relationships" in result && Array.isArray(result["relationships"])) {
|
|
271
|
-
result["relationships"] = result["relationships"].map((rel) => {
|
|
272
|
-
if (typeof rel === "object" && rel !== null) {
|
|
273
|
-
const r = rel;
|
|
274
|
-
const healedRel = { ...r };
|
|
275
|
-
if ("target_id" in r) {
|
|
276
|
-
healedRel["targetId"] = r["target_id"];
|
|
277
|
-
delete healedRel["target_id"];
|
|
278
|
-
}
|
|
279
|
-
if ("relation_type" in r) {
|
|
280
|
-
healedRel["relationType"] = r["relation_type"];
|
|
281
|
-
delete healedRel["relation_type"];
|
|
282
|
-
}
|
|
283
|
-
return healedRel;
|
|
284
|
-
}
|
|
285
|
-
return rel;
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if ("commits" in result && Array.isArray(result["commits"])) {
|
|
289
|
-
if (!("auto_context" in result) || typeof result["auto_context"] !== "string") {
|
|
290
|
-
result["auto_context"] = JSON.stringify({ commits: result["commits"] });
|
|
291
|
-
}
|
|
292
|
-
delete result["commits"];
|
|
293
|
-
}
|
|
294
|
-
if (typeof result["project_number"] === "number") {
|
|
295
|
-
const pn = result["project_number"];
|
|
296
|
-
["entries", "updates", "entry_ids"].forEach((key) => {
|
|
297
|
-
if (Array.isArray(result[key])) {
|
|
298
|
-
for (const item of result[key]) {
|
|
299
|
-
if (typeof item === "object" && item !== null && item.project_number === void 0) {
|
|
300
|
-
item.project_number = pn;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
if ("content" in result && typeof result["content"] === "string") {
|
|
307
|
-
const c = result["content"];
|
|
308
|
-
if (/#+\s+Accomplished/i.test(c) && /#+\s+Unfinished \/ Blocked/i.test(c)) {
|
|
309
|
-
if (!("entry_type" in result)) result["entry_type"] = "retrospective";
|
|
310
|
-
let tags = result["tags"];
|
|
311
|
-
if (!Array.isArray(tags)) {
|
|
312
|
-
tags = tags !== void 0 && tags !== null ? [tags] : [];
|
|
313
|
-
result["tags"] = tags;
|
|
314
|
-
}
|
|
315
|
-
if (!tags.includes("session-summary")) {
|
|
316
|
-
tags.push("session-summary");
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if ("tags" in result && Array.isArray(result["tags"]) && result["tags"].includes("session-summary") && "content" in result && typeof result["content"] === "string") {
|
|
321
|
-
const c = result["content"];
|
|
322
|
-
let healedContent = c;
|
|
323
|
-
const requiredHeaders = [
|
|
324
|
-
"## Accomplished",
|
|
325
|
-
"## Unfinished / Blocked",
|
|
326
|
-
"## Context for Next Session",
|
|
327
|
-
"## Commits"
|
|
328
|
-
];
|
|
329
|
-
let changed = false;
|
|
330
|
-
healedContent = healedContent.replace(/(?:^#+\s+Accomplished\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Accomplished\n- None.\n");
|
|
331
|
-
healedContent = healedContent.replace(/(?:^#+\s+Unfinished \/ Blocked\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Unfinished / Blocked\n- None.\n");
|
|
332
|
-
healedContent = healedContent.replace(/(?:^#+\s+Context for Next Session\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Context for Next Session\n- None.\n");
|
|
333
|
-
healedContent = healedContent.replace(/(?:^#+\s+Commits\s*\n-\s*(?:None\.?|)\s*){2,}/gim, "## Commits\n- None.\n");
|
|
334
|
-
const deduplicate = (str, headerRegexStr) => {
|
|
335
|
-
let count = 0;
|
|
336
|
-
return str.replace(new RegExp(headerRegexStr, "gim"), (match) => {
|
|
337
|
-
count++;
|
|
338
|
-
return count === 1 ? match : "";
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
healedContent = deduplicate(healedContent, "^#+\\s+Accomplished");
|
|
342
|
-
healedContent = deduplicate(healedContent, "^#+\\s+Unfinished \\/ Blocked");
|
|
343
|
-
healedContent = deduplicate(healedContent, "^#+\\s+Context for Next Session");
|
|
344
|
-
healedContent = deduplicate(healedContent, "^#+\\s+Commits");
|
|
345
|
-
for (const header of requiredHeaders) {
|
|
346
|
-
const cleanHeader = header.replace(/^#+\s+/, "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/ /g, "\\s*");
|
|
347
|
-
const regex = new RegExp(`#+\\s+${cleanHeader}`, "i");
|
|
348
|
-
if (!regex.test(healedContent)) {
|
|
349
|
-
healedContent += `
|
|
350
|
-
|
|
351
|
-
${header}
|
|
352
|
-
- None.`;
|
|
353
|
-
changed = true;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
if (changed || healedContent !== c) {
|
|
357
|
-
result["content"] = healedContent.trim();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if ("tags" in result && Array.isArray(result["tags"]) && result["tags"].includes("commit-narrative") && !("auto_context" in result) && "content" in result && typeof result["content"] === "string") {
|
|
361
|
-
const match = /commit\s+([a-f0-9]{7,40})/i.exec(result["content"]);
|
|
362
|
-
if (match?.[1]) {
|
|
363
|
-
result["auto_context"] = JSON.stringify({ commits: [match[1]] });
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if ("auto_context" in result) {
|
|
367
|
-
const ac = result["auto_context"];
|
|
368
|
-
if (typeof ac === "string") {
|
|
369
|
-
try {
|
|
370
|
-
const parsed = JSON.parse(ac.replace(/'/g, '"'));
|
|
371
|
-
let changed = false;
|
|
372
|
-
if ("commit_shas" in parsed) {
|
|
373
|
-
parsed["commits"] = parsed["commit_shas"];
|
|
374
|
-
delete parsed["commit_shas"];
|
|
375
|
-
changed = true;
|
|
376
|
-
}
|
|
377
|
-
if ("shas" in parsed) {
|
|
378
|
-
parsed["commits"] = parsed["shas"];
|
|
379
|
-
delete parsed["shas"];
|
|
380
|
-
changed = true;
|
|
381
|
-
}
|
|
382
|
-
if ("commit_sha" in parsed) {
|
|
383
|
-
parsed["commits"] = parsed["commit_sha"];
|
|
384
|
-
delete parsed["commit_sha"];
|
|
385
|
-
changed = true;
|
|
386
|
-
}
|
|
387
|
-
if ("commitShas" in parsed) {
|
|
388
|
-
parsed["commits"] = parsed["commitShas"];
|
|
389
|
-
delete parsed["commitShas"];
|
|
390
|
-
changed = true;
|
|
391
|
-
}
|
|
392
|
-
if ("commits" in parsed && typeof parsed["commits"] === "string") {
|
|
393
|
-
parsed["commits"] = [parsed["commits"]];
|
|
394
|
-
changed = true;
|
|
395
|
-
}
|
|
396
|
-
if (changed) {
|
|
397
|
-
result["auto_context"] = JSON.stringify(parsed);
|
|
398
|
-
}
|
|
399
|
-
} catch {
|
|
400
|
-
}
|
|
401
|
-
} else if (typeof ac === "object" && ac !== null) {
|
|
402
|
-
const acObj = ac;
|
|
403
|
-
if ("commit_shas" in acObj) {
|
|
404
|
-
acObj["commits"] = acObj["commit_shas"];
|
|
405
|
-
delete acObj["commit_shas"];
|
|
406
|
-
}
|
|
407
|
-
if ("shas" in acObj) {
|
|
408
|
-
acObj["commits"] = acObj["shas"];
|
|
409
|
-
delete acObj["shas"];
|
|
410
|
-
}
|
|
411
|
-
if ("commit_sha" in acObj) {
|
|
412
|
-
acObj["commits"] = acObj["commit_sha"];
|
|
413
|
-
delete acObj["commit_sha"];
|
|
414
|
-
}
|
|
415
|
-
if ("commitShas" in acObj) {
|
|
416
|
-
acObj["commits"] = acObj["commitShas"];
|
|
417
|
-
delete acObj["commitShas"];
|
|
418
|
-
}
|
|
419
|
-
if ("commits" in acObj && typeof acObj["commits"] === "string") {
|
|
420
|
-
acObj["commits"] = [acObj["commits"]];
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if ("filter" in result && typeof result["filter"] === "object" && result["filter"] !== null && !Array.isArray(result["filter"])) {
|
|
425
|
-
const filterObj = result["filter"];
|
|
426
|
-
for (const [k, v] of Object.entries(filterObj)) {
|
|
427
|
-
let snakeK = k.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
428
|
-
if (snakeK === "id" && !("entry_id" in filterObj) && !("entryId" in filterObj)) snakeK = "entry_id";
|
|
429
|
-
if (snakeK === "project" || snakeK === "project_id" || snakeK === "proj") snakeK = "project_number";
|
|
430
|
-
if (!(snakeK in result)) {
|
|
431
|
-
result[snakeK] = v;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
delete result["filter"];
|
|
435
|
-
}
|
|
436
|
-
return result;
|
|
437
|
-
}
|
|
438
|
-
function normalizeParams(methodName, args) {
|
|
439
|
-
if (args.length === 0) return void 0;
|
|
440
|
-
if (args.length === 1) {
|
|
441
|
-
const arg = args[0];
|
|
442
|
-
if (typeof arg === "object" && arg !== null && !Array.isArray(arg)) {
|
|
443
|
-
const obj = convertKeysToSnakeCase(arg, methodName);
|
|
444
|
-
if ((methodName === "createEntry" || methodName === "createEntryMinimal" || methodName === "teamCreateEntry") && !("content" in obj)) {
|
|
445
|
-
let content = "";
|
|
446
|
-
const validFields = /* @__PURE__ */ new Set([
|
|
447
|
-
"type",
|
|
448
|
-
"tags",
|
|
449
|
-
"entry_type",
|
|
450
|
-
"is_personal",
|
|
451
|
-
"share_with_team",
|
|
452
|
-
"significance_type",
|
|
453
|
-
"auto_context",
|
|
454
|
-
"project_number",
|
|
455
|
-
"project_owner",
|
|
456
|
-
"issue_number",
|
|
457
|
-
"issue_url",
|
|
458
|
-
"pr_number",
|
|
459
|
-
"pr_url",
|
|
460
|
-
"pr_status",
|
|
461
|
-
"workflow_run_id",
|
|
462
|
-
"workflow_name",
|
|
463
|
-
"workflow_status"
|
|
464
|
-
]);
|
|
465
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
466
|
-
if (validFields.has(key)) continue;
|
|
467
|
-
const strValue = typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);
|
|
468
|
-
content += `**${key}**
|
|
469
|
-
${strValue}
|
|
470
|
-
|
|
471
|
-
`;
|
|
472
|
-
}
|
|
473
|
-
const trimmed = content.trim();
|
|
474
|
-
if (trimmed) {
|
|
475
|
-
obj["content"] = trimmed;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return obj;
|
|
479
|
-
}
|
|
480
|
-
if (typeof arg === "string" || typeof arg === "number" || typeof arg === "boolean") {
|
|
481
|
-
const paramMapping2 = POSITIONAL_PARAM_MAP[methodName];
|
|
482
|
-
if (typeof paramMapping2 === "string") {
|
|
483
|
-
return { [paramMapping2]: arg };
|
|
484
|
-
}
|
|
485
|
-
if (Array.isArray(paramMapping2) && paramMapping2[0] !== void 0) {
|
|
486
|
-
return { [paramMapping2[0]]: arg };
|
|
487
|
-
}
|
|
488
|
-
if (typeof arg === "string") {
|
|
489
|
-
return { content: arg, query: arg };
|
|
490
|
-
}
|
|
491
|
-
return arg;
|
|
492
|
-
}
|
|
493
|
-
return arg;
|
|
494
|
-
}
|
|
495
|
-
const paramMapping = POSITIONAL_PARAM_MAP[methodName];
|
|
496
|
-
if (paramMapping === void 0) {
|
|
497
|
-
return args[0];
|
|
498
|
-
}
|
|
499
|
-
if (typeof paramMapping === "string") {
|
|
500
|
-
const result2 = { [paramMapping]: args[0] };
|
|
501
|
-
if (args.length > 1) {
|
|
502
|
-
const lastArg = args[args.length - 1];
|
|
503
|
-
if (typeof lastArg === "object" && lastArg !== null && !Array.isArray(lastArg)) {
|
|
504
|
-
Object.assign(result2, convertKeysToSnakeCase(lastArg, methodName));
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
return result2;
|
|
508
|
-
}
|
|
509
|
-
const result = {};
|
|
510
|
-
for (let i = 0; i < paramMapping.length && i < args.length; i++) {
|
|
511
|
-
const key = paramMapping[i];
|
|
512
|
-
if (key !== void 0) {
|
|
513
|
-
result[key] = args[i];
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
if (args.length > paramMapping.length) {
|
|
517
|
-
const lastArg = args[args.length - 1];
|
|
518
|
-
if (typeof lastArg === "object" && lastArg !== null && !Array.isArray(lastArg)) {
|
|
519
|
-
Object.assign(result, convertKeysToSnakeCase(lastArg, methodName));
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return result;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// src/codemode/api/group-factory.ts
|
|
526
|
-
function toolNameToMethodName(toolName, groupName) {
|
|
527
|
-
let name = toolName;
|
|
528
|
-
if (!KEEP_PREFIX_GROUPS.has(groupName)) {
|
|
529
|
-
const groupPrefix = GROUP_PREFIX_MAP[groupName] ?? "";
|
|
530
|
-
if (groupPrefix && name.startsWith(groupPrefix)) {
|
|
531
|
-
name = name.substring(groupPrefix.length);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
return name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
535
|
-
}
|
|
536
|
-
function createGroupApi(groupName, tools, dispatcher) {
|
|
537
|
-
const api = {};
|
|
538
|
-
for (const tool of tools) {
|
|
539
|
-
const methodName = toolNameToMethodName(tool.name, groupName);
|
|
540
|
-
api[methodName] = async (...args) => {
|
|
541
|
-
try {
|
|
542
|
-
const normalizedParams = normalizeParams(methodName, args) ?? {};
|
|
543
|
-
if (dispatcher) {
|
|
544
|
-
return await dispatcher(tool.name, normalizedParams);
|
|
545
|
-
}
|
|
546
|
-
return await Promise.resolve(tool.handler(normalizedParams));
|
|
547
|
-
} catch (error) {
|
|
548
|
-
return {
|
|
549
|
-
success: false,
|
|
550
|
-
error: error instanceof Error ? error.message : String(error),
|
|
551
|
-
code: typeof error["code"] === "string" ? error["code"] : error?.name
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
if (tool.name !== methodName) {
|
|
556
|
-
api[tool.name] = api[methodName];
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
const aliases = METHOD_ALIASES[groupName];
|
|
560
|
-
if (aliases) {
|
|
561
|
-
for (const [aliasName, canonicalName] of Object.entries(aliases)) {
|
|
562
|
-
if (api[canonicalName] !== void 0) {
|
|
563
|
-
api[aliasName] = api[canonicalName];
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
api["help"] = () => {
|
|
568
|
-
const methods = Object.keys(api).filter((k) => k !== "help").sort();
|
|
569
|
-
return Promise.resolve({
|
|
570
|
-
group: groupName,
|
|
571
|
-
methods,
|
|
572
|
-
examples: GROUP_EXAMPLES[groupName] ?? []
|
|
573
|
-
});
|
|
574
|
-
};
|
|
575
|
-
return api;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/codemode/type-generator.ts
|
|
579
|
-
function getZodTypeString(schema) {
|
|
580
|
-
if (schema instanceof z.ZodString) return "string";
|
|
581
|
-
if (schema instanceof z.ZodNumber) return "number";
|
|
582
|
-
if (schema instanceof z.ZodBoolean) return "boolean";
|
|
583
|
-
if (schema instanceof z.ZodArray) {
|
|
584
|
-
return `${getZodTypeString(schema.element)}[]`;
|
|
585
|
-
}
|
|
586
|
-
if (schema instanceof z.ZodOptional) {
|
|
587
|
-
return getZodTypeString(schema.unwrap());
|
|
588
|
-
}
|
|
589
|
-
if (schema instanceof z.ZodNullable) {
|
|
590
|
-
return `${getZodTypeString(schema.unwrap())} | null`;
|
|
591
|
-
}
|
|
592
|
-
if (schema instanceof z.ZodDefault) {
|
|
593
|
-
return getZodTypeString(schema.unwrap());
|
|
594
|
-
}
|
|
595
|
-
if (schema instanceof z.ZodUnion) {
|
|
596
|
-
return schema.options.map((o) => getZodTypeString(o)).join(" | ");
|
|
597
|
-
}
|
|
598
|
-
if (schema instanceof z.ZodEnum) {
|
|
599
|
-
return schema.options.map((o) => `'${String(o)}'`).join(" | ");
|
|
600
|
-
}
|
|
601
|
-
if (schema instanceof z.ZodObject) {
|
|
602
|
-
const shape = schema.shape;
|
|
603
|
-
const props = Object.entries(shape).map(([k, v]) => {
|
|
604
|
-
const isOptional = v instanceof z.ZodOptional || v instanceof z.ZodDefault || v instanceof z.ZodNullable;
|
|
605
|
-
return `${k}${isOptional ? "?" : ""}: ${getZodTypeString(v)}`;
|
|
606
|
-
});
|
|
607
|
-
return `{ ${props.join(", ")} }`;
|
|
608
|
-
}
|
|
609
|
-
return "unknown";
|
|
610
|
-
}
|
|
611
|
-
function isRecord(val) {
|
|
612
|
-
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
613
|
-
}
|
|
614
|
-
var JournalApi = class {
|
|
615
|
-
core;
|
|
616
|
-
search;
|
|
617
|
-
analytics;
|
|
618
|
-
relationships;
|
|
619
|
-
io;
|
|
620
|
-
admin;
|
|
621
|
-
github;
|
|
622
|
-
backup;
|
|
623
|
-
team;
|
|
624
|
-
git;
|
|
625
|
-
memory;
|
|
626
|
-
// Alias for core to handle cross-server hallucinations
|
|
627
|
-
toolsByGroup;
|
|
628
|
-
constructor(tools, dispatcher) {
|
|
629
|
-
this.toolsByGroup = /* @__PURE__ */ new Map();
|
|
630
|
-
for (const tool of tools) {
|
|
631
|
-
if (tool.group === "codemode") continue;
|
|
632
|
-
const existing = this.toolsByGroup.get(tool.group) ?? [];
|
|
633
|
-
existing.push(tool);
|
|
634
|
-
this.toolsByGroup.set(tool.group, existing);
|
|
635
|
-
}
|
|
636
|
-
this.core = createGroupApi("core", this.toolsByGroup.get("core") ?? [], dispatcher);
|
|
637
|
-
this.search = createGroupApi("search", this.toolsByGroup.get("search") ?? [], dispatcher);
|
|
638
|
-
this.analytics = createGroupApi(
|
|
639
|
-
"analytics",
|
|
640
|
-
this.toolsByGroup.get("analytics") ?? [],
|
|
641
|
-
dispatcher
|
|
642
|
-
);
|
|
643
|
-
this.relationships = createGroupApi(
|
|
644
|
-
"relationships",
|
|
645
|
-
this.toolsByGroup.get("relationships") ?? [],
|
|
646
|
-
dispatcher
|
|
647
|
-
);
|
|
648
|
-
this.io = createGroupApi("io", this.toolsByGroup.get("io") ?? [], dispatcher);
|
|
649
|
-
this.admin = createGroupApi("admin", this.toolsByGroup.get("admin") ?? [], dispatcher);
|
|
650
|
-
this.github = createGroupApi("github", this.toolsByGroup.get("github") ?? [], dispatcher);
|
|
651
|
-
this.backup = createGroupApi("backup", this.toolsByGroup.get("backup") ?? [], dispatcher);
|
|
652
|
-
this.team = createGroupApi("team", this.toolsByGroup.get("team") ?? [], dispatcher);
|
|
653
|
-
this.git = createGroupApi("git", this.toolsByGroup.get("git") ?? [], dispatcher);
|
|
654
|
-
this.memory = this.core;
|
|
655
|
-
const searchEntriesFn = this.search["searchEntries"];
|
|
656
|
-
if (searchEntriesFn) {
|
|
657
|
-
this.core["searchEntries"] = searchEntriesFn;
|
|
658
|
-
this.core["search"] = searchEntriesFn;
|
|
659
|
-
this.core["listEntries"] = searchEntriesFn;
|
|
660
|
-
this.core["readQuery"] = async (...args) => {
|
|
661
|
-
const res = await searchEntriesFn(...args);
|
|
662
|
-
if (isRecord(res) && "entries" in res) {
|
|
663
|
-
return { ...res, rows: res["entries"] };
|
|
664
|
-
}
|
|
665
|
-
return res;
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
const _createEntryFn = this.core["createEntry"];
|
|
669
|
-
if (_createEntryFn) {
|
|
670
|
-
const wrappedCreateEntryFn = async (...args) => {
|
|
671
|
-
const params = args[0];
|
|
672
|
-
if (isRecord(params)) {
|
|
673
|
-
if (typeof params["project_number"] === "string") {
|
|
674
|
-
const cleaned = params["project_number"].trim();
|
|
675
|
-
const num = Number(cleaned);
|
|
676
|
-
if (!Number.isNaN(num) && cleaned !== "") {
|
|
677
|
-
params["project_number"] = num;
|
|
678
|
-
} else {
|
|
679
|
-
if (params["workspace_id"] === void 0 || params["workspace_id"] === "default") {
|
|
680
|
-
params["workspace_id"] = cleaned;
|
|
681
|
-
}
|
|
682
|
-
delete params["project_number"];
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
if ((params["workspace_id"] === void 0 || params["workspace_id"] === "default") && (params["workspaceId"] === void 0 || params["workspaceId"] === "default")) {
|
|
686
|
-
const projNum = typeof params["project_number"] === "number" ? params["project_number"] : typeof params["projectNumber"] === "number" ? params["projectNumber"] : void 0;
|
|
687
|
-
const contentStr = typeof params["content"] === "string" ? params["content"] : void 0;
|
|
688
|
-
const tagsArr = Array.isArray(params["tags"]) ? params["tags"].filter((t) => typeof t === "string") : void 0;
|
|
689
|
-
const resolved = resolveProjectContext({
|
|
690
|
-
workspace_id: typeof params["workspace_id"] === "string" ? params["workspace_id"] : void 0,
|
|
691
|
-
project_number: projNum,
|
|
692
|
-
content: contentStr,
|
|
693
|
-
tags: tagsArr
|
|
694
|
-
});
|
|
695
|
-
if (resolved.workspaceId && resolved.workspaceId !== "default") {
|
|
696
|
-
params["workspace_id"] = resolved.workspaceId;
|
|
697
|
-
params["workspaceId"] = resolved.workspaceId;
|
|
698
|
-
}
|
|
699
|
-
if (params["project_number"] === void 0 && resolved.projectNumber !== void 0) {
|
|
700
|
-
params["project_number"] = resolved.projectNumber;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return await _createEntryFn(...args);
|
|
705
|
-
};
|
|
706
|
-
for (const key of Object.keys(this.core)) {
|
|
707
|
-
if (this.core[key] === _createEntryFn) {
|
|
708
|
-
this.core[key] = wrappedCreateEntryFn;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
this.core["upsert"] = wrappedCreateEntryFn;
|
|
712
|
-
if (this.admin["listProjects"]) this.core["listProjects"] = this.admin["listProjects"];
|
|
713
|
-
if (this.admin["getProject"]) this.core["getProject"] = this.admin["getProject"];
|
|
714
|
-
}
|
|
715
|
-
const deleteEntryFn = this.admin["deleteEntry"];
|
|
716
|
-
if (deleteEntryFn) this.core["deleteEntry"] = deleteEntryFn;
|
|
717
|
-
const updateEntryFn = this.admin["updateEntry"];
|
|
718
|
-
if (updateEntryFn) this.core["updateEntry"] = updateEntryFn;
|
|
719
|
-
const mergeTagsFn = this.admin["mergeTags"];
|
|
720
|
-
if (mergeTagsFn) this.core["mergeTags"] = mergeTagsFn;
|
|
721
|
-
const restoreEntryFn = this.admin["restoreEntry"];
|
|
722
|
-
if (restoreEntryFn) this.core["restoreEntry"] = restoreEntryFn;
|
|
723
|
-
const auditLogFn = this.admin["searchAuditLog"];
|
|
724
|
-
if (auditLogFn) this.core["searchAuditLog"] = auditLogFn;
|
|
725
|
-
const deletedFn = this.search["listDeletedEntries"];
|
|
726
|
-
if (deletedFn) this.core["listDeletedEntries"] = deletedFn;
|
|
727
|
-
const semanticFn = this.search["semanticSearch"];
|
|
728
|
-
const searchEntriesFallbackFn = this.search["searchEntries"];
|
|
729
|
-
if (semanticFn) {
|
|
730
|
-
const wrappedSemanticFn = async (...args) => {
|
|
731
|
-
const res = await semanticFn(...args);
|
|
732
|
-
if (isRecord(res) && "entries" in res) {
|
|
733
|
-
const entries = res["entries"];
|
|
734
|
-
if (Array.isArray(entries) && entries.length === 0 && searchEntriesFallbackFn) {
|
|
735
|
-
const params = args[0];
|
|
736
|
-
if (isRecord(params) && typeof params["query"] === "string") {
|
|
737
|
-
const fallback = await searchEntriesFallbackFn(...args);
|
|
738
|
-
if (isRecord(fallback) && "entries" in fallback) {
|
|
739
|
-
const fallbackEntries = fallback["entries"];
|
|
740
|
-
if (Array.isArray(fallbackEntries) && fallbackEntries.length > 0) {
|
|
741
|
-
return fallback;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return res;
|
|
748
|
-
};
|
|
749
|
-
this.search["semanticSearch"] = wrappedSemanticFn;
|
|
750
|
-
this.core["semanticSearch"] = wrappedSemanticFn;
|
|
751
|
-
}
|
|
752
|
-
const vectorStatsFn = this.search["getVectorIndexStats"];
|
|
753
|
-
if (vectorStatsFn) {
|
|
754
|
-
this.core["getVectorIndexStats"] = vectorStatsFn;
|
|
755
|
-
this.core["vectorStats"] = vectorStatsFn;
|
|
756
|
-
}
|
|
757
|
-
const rebuildVectorFn = this.admin["rebuildVectorIndex"];
|
|
758
|
-
if (rebuildVectorFn) this.core["rebuildVectorIndex"] = rebuildVectorFn;
|
|
759
|
-
const addToVectorFn = this.admin["addToVectorIndex"];
|
|
760
|
-
if (addToVectorFn) this.core["addToVectorIndex"] = addToVectorFn;
|
|
761
|
-
const exportFn = this.io["exportEntries"];
|
|
762
|
-
if (exportFn) this.core["exportEntries"] = exportFn;
|
|
763
|
-
const backupFn = this.backup["backupJournal"];
|
|
764
|
-
if (backupFn) this.core["backupJournal"] = backupFn;
|
|
765
|
-
const restoreFn = this.backup["restoreBackup"];
|
|
766
|
-
if (backupFn) this.admin["backup"] = backupFn;
|
|
767
|
-
if (restoreFn) this.admin["restoreBackup"] = restoreFn;
|
|
768
|
-
const getConfigFn = () => Promise.resolve({
|
|
769
|
-
PROJECT_REGISTRY: parseProjectRegistry(),
|
|
770
|
-
dbPath: "memory://internal"
|
|
771
|
-
});
|
|
772
|
-
this.admin["getConfig"] = getConfigFn;
|
|
773
|
-
this.core["getConfig"] = getConfigFn;
|
|
774
|
-
const statsFn = this.analytics["getStatistics"];
|
|
775
|
-
if (statsFn) {
|
|
776
|
-
this.core["count"] = statsFn;
|
|
777
|
-
this.core["listTables"] = statsFn;
|
|
778
|
-
this.core["describeTable"] = statsFn;
|
|
779
|
-
this.admin["analyze"] = statsFn;
|
|
780
|
-
this.core["serverInfo"] = statsFn;
|
|
781
|
-
this.core["serverHealth"] = statsFn;
|
|
782
|
-
this.core["health"] = statsFn;
|
|
783
|
-
this.core["status"] = statsFn;
|
|
784
|
-
this.admin["serverInfo"] = statsFn;
|
|
785
|
-
this.admin["serverHealth"] = statsFn;
|
|
786
|
-
this.admin["health"] = statsFn;
|
|
787
|
-
this.admin["status"] = statsFn;
|
|
788
|
-
}
|
|
789
|
-
const getByIdFn = this.core["getEntryById"];
|
|
790
|
-
if (getByIdFn) this.core["exists"] = getByIdFn;
|
|
791
|
-
this.admin["registerProject"] = async (...args) => {
|
|
792
|
-
const name = args[0];
|
|
793
|
-
const absolutePath = args[1];
|
|
794
|
-
const projectNumber = args[2];
|
|
795
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
796
|
-
let config = { projectRegistry: {} };
|
|
797
|
-
try {
|
|
798
|
-
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
799
|
-
} catch {
|
|
800
|
-
}
|
|
801
|
-
config["projectRegistry"] ??= {};
|
|
802
|
-
const registry = config["projectRegistry"];
|
|
803
|
-
registry[name] = { path: absolutePath };
|
|
804
|
-
if (typeof projectNumber === "number" && !Number.isNaN(projectNumber)) {
|
|
805
|
-
registry[name].project_number = projectNumber;
|
|
806
|
-
}
|
|
807
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
808
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), "utf-8");
|
|
809
|
-
process.env["PROJECT_REGISTRY"] = JSON.stringify(config["projectRegistry"]);
|
|
810
|
-
const createEntryFn = this.core["createEntry"];
|
|
811
|
-
if (!createEntryFn) {
|
|
812
|
-
return { success: true, message: `Project '${name}' registered, but createEntry tool is missing. DB init skipped.` };
|
|
813
|
-
}
|
|
814
|
-
try {
|
|
815
|
-
await createEntryFn({
|
|
816
|
-
entryType: "project_decision",
|
|
817
|
-
significanceType: "architecture",
|
|
818
|
-
content: `Initialized project ${name}`,
|
|
819
|
-
tags: ["project-initialization", "setup"],
|
|
820
|
-
projectNumber: projectNumber ?? 0,
|
|
821
|
-
trustScore: 1,
|
|
822
|
-
impactScore: 0.8,
|
|
823
|
-
autoContext: JSON.stringify({ action: "register_project", target: name })
|
|
824
|
-
});
|
|
825
|
-
} catch {
|
|
826
|
-
}
|
|
827
|
-
return { success: true, message: `Project '${name}' successfully registered.` };
|
|
828
|
-
};
|
|
829
|
-
this.admin["updateProject"] = (...args) => {
|
|
830
|
-
const name = args[0];
|
|
831
|
-
const newName = args[1];
|
|
832
|
-
const absolutePath = args[2];
|
|
833
|
-
const projectNumber = args[3];
|
|
834
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
835
|
-
let config = { projectRegistry: {} };
|
|
836
|
-
try {
|
|
837
|
-
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
838
|
-
} catch {
|
|
839
|
-
}
|
|
840
|
-
config["projectRegistry"] ??= {};
|
|
841
|
-
const registry = config["projectRegistry"];
|
|
842
|
-
if (!registry[name]) return Promise.resolve({ success: false, error: `\u{1F6E0}\uFE0F AUTONOMOUS HEALING: Project not found: '${name}'` });
|
|
843
|
-
const project = registry[name];
|
|
844
|
-
if (absolutePath) project.path = absolutePath;
|
|
845
|
-
if (typeof projectNumber === "number" && !Number.isNaN(projectNumber)) project.project_number = projectNumber;
|
|
846
|
-
const targetName = newName ?? name;
|
|
847
|
-
const rest = Object.fromEntries(Object.entries(registry).filter(([key]) => key !== name));
|
|
848
|
-
const newRegistry = { ...rest, [targetName]: project };
|
|
849
|
-
config["projectRegistry"] = newRegistry;
|
|
850
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
851
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), "utf-8");
|
|
852
|
-
process.env["PROJECT_REGISTRY"] = JSON.stringify(config["projectRegistry"]);
|
|
853
|
-
return Promise.resolve({ success: true, message: `Project '${targetName}' updated.` });
|
|
854
|
-
};
|
|
855
|
-
this.admin["deleteProject"] = (...args) => {
|
|
856
|
-
const name = args[0];
|
|
857
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
858
|
-
let config = { projectRegistry: {} };
|
|
859
|
-
try {
|
|
860
|
-
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
861
|
-
} catch {
|
|
862
|
-
}
|
|
863
|
-
config["projectRegistry"] ??= {};
|
|
864
|
-
const registry = config["projectRegistry"];
|
|
865
|
-
if (!registry[name]) return Promise.resolve({ success: false, error: `\u{1F6E0}\uFE0F AUTONOMOUS HEALING: Project not found: '${name}'` });
|
|
866
|
-
const rest = Object.fromEntries(Object.entries(registry).filter(([key]) => key !== name));
|
|
867
|
-
config["projectRegistry"] = rest;
|
|
868
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
869
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), "utf-8");
|
|
870
|
-
process.env["PROJECT_REGISTRY"] = JSON.stringify(config["projectRegistry"]);
|
|
871
|
-
return Promise.resolve({ success: true, message: `Project '${name}' deleted.` });
|
|
872
|
-
};
|
|
873
|
-
this.admin["listProjects"] = () => {
|
|
874
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
875
|
-
let config = { projectRegistry: {} };
|
|
876
|
-
try {
|
|
877
|
-
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
878
|
-
} catch {
|
|
879
|
-
}
|
|
880
|
-
return Promise.resolve({ success: true, projects: config["projectRegistry"] ?? {} });
|
|
881
|
-
};
|
|
882
|
-
this.admin["getProject"] = (...args) => {
|
|
883
|
-
const name = args[0];
|
|
884
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
885
|
-
let config = { projectRegistry: {} };
|
|
886
|
-
if (fs.existsSync(configPath)) {
|
|
887
|
-
try {
|
|
888
|
-
config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
889
|
-
} catch {
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
const registry = config["projectRegistry"];
|
|
893
|
-
if (!registry?.[name]) return Promise.resolve({ success: false, error: `\u{1F6E0}\uFE0F AUTONOMOUS HEALING: Project not found: '${name}'` });
|
|
894
|
-
return Promise.resolve({ success: true, project: { name, ...registry[name] ?? {} } });
|
|
895
|
-
};
|
|
896
|
-
const teamDeleteEntryFn = this.team["teamDeleteEntry"];
|
|
897
|
-
if (teamDeleteEntryFn) {
|
|
898
|
-
this.team["deleteEntry"] = teamDeleteEntryFn;
|
|
899
|
-
this.team["delete"] = teamDeleteEntryFn;
|
|
900
|
-
}
|
|
901
|
-
const teamUpdateEntryFn = this.team["teamUpdateEntry"];
|
|
902
|
-
if (teamUpdateEntryFn) {
|
|
903
|
-
this.team["updateEntry"] = teamUpdateEntryFn;
|
|
904
|
-
this.team["update"] = teamUpdateEntryFn;
|
|
905
|
-
}
|
|
906
|
-
const teamCreateEntryFn = this.team["teamCreateEntry"];
|
|
907
|
-
if (teamCreateEntryFn) {
|
|
908
|
-
this.team["createEntry"] = teamCreateEntryFn;
|
|
909
|
-
this.team["create"] = teamCreateEntryFn;
|
|
910
|
-
}
|
|
911
|
-
const listProjectsFn = async () => {
|
|
912
|
-
try {
|
|
913
|
-
const registry = parseProjectRegistry();
|
|
914
|
-
if (registry !== void 0 && registry.length > 0) return registry;
|
|
915
|
-
} catch {
|
|
916
|
-
}
|
|
917
|
-
try {
|
|
918
|
-
const configPath = process.env["MEMORY_JOURNAL_CONFIG"] ?? path.resolve(os.homedir(), ".gemini", "config", "memory-journal.config.json");
|
|
919
|
-
if (fs.existsSync(configPath)) {
|
|
920
|
-
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
921
|
-
const reg = config["projectRegistry"];
|
|
922
|
-
if (reg !== void 0 && reg !== null && typeof reg === "object") {
|
|
923
|
-
return Object.entries(reg).map(([name, val]) => ({
|
|
924
|
-
name,
|
|
925
|
-
projectNumber: val?.["project_number"] ?? val?.["id"],
|
|
926
|
-
project_number: val?.["project_number"] ?? val?.["id"],
|
|
927
|
-
...typeof val === "object" && val !== null ? val : {}
|
|
928
|
-
}));
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
} catch {
|
|
932
|
-
}
|
|
933
|
-
const statsFn2 = this.analytics["getStatistics"];
|
|
934
|
-
if (typeof statsFn2 === "function") {
|
|
935
|
-
try {
|
|
936
|
-
const stats = await statsFn2({ group_by: "month", project_breakdown: true });
|
|
937
|
-
if (isRecord(stats) && "projectBreakdown" in stats && Array.isArray(stats["projectBreakdown"])) {
|
|
938
|
-
return stats["projectBreakdown"];
|
|
939
|
-
}
|
|
940
|
-
} catch {
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
return [];
|
|
944
|
-
};
|
|
945
|
-
const getProjectFn = async (params) => {
|
|
946
|
-
try {
|
|
947
|
-
let searchVal;
|
|
948
|
-
if (typeof params === "number") searchVal = params;
|
|
949
|
-
else if (typeof params === "string") searchVal = params;
|
|
950
|
-
if (isRecord(params)) {
|
|
951
|
-
const obj = params;
|
|
952
|
-
if (typeof obj["project_number"] === "number") searchVal = obj["project_number"];
|
|
953
|
-
else if (typeof obj["projectNumber"] === "number")
|
|
954
|
-
searchVal = obj["projectNumber"];
|
|
955
|
-
else if (typeof obj["name"] === "string") searchVal = obj["name"];
|
|
956
|
-
else if (typeof obj["query"] === "string") searchVal = obj["query"];
|
|
957
|
-
}
|
|
958
|
-
if (searchVal !== void 0) {
|
|
959
|
-
const isNum = typeof searchVal === "number" || !Number.isNaN(Number(searchVal));
|
|
960
|
-
const numVal = isNum ? Number(searchVal) : void 0;
|
|
961
|
-
const strVal = String(searchVal).toLowerCase();
|
|
962
|
-
const projects = await listProjectsFn();
|
|
963
|
-
if (Array.isArray(projects)) {
|
|
964
|
-
const projArray = projects;
|
|
965
|
-
const found = projArray.find((p) => {
|
|
966
|
-
if (!isRecord(p)) return false;
|
|
967
|
-
const proj = p;
|
|
968
|
-
if (numVal !== void 0 && (proj["project_number"] === numVal || proj["projectNumber"] === numVal))
|
|
969
|
-
return true;
|
|
970
|
-
if (strVal !== void 0 && typeof proj["name"] === "string") {
|
|
971
|
-
const projName = proj["name"].toLowerCase();
|
|
972
|
-
if (projName === strVal || projName.includes(strVal)) return true;
|
|
973
|
-
}
|
|
974
|
-
return false;
|
|
975
|
-
});
|
|
976
|
-
if (found !== void 0) return found;
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
} catch {
|
|
980
|
-
}
|
|
981
|
-
throw new Error(`Project not found: ${JSON.stringify(params)}`);
|
|
982
|
-
};
|
|
983
|
-
this.core["listProjects"] = listProjectsFn;
|
|
984
|
-
this.core["searchProjects"] = listProjectsFn;
|
|
985
|
-
this.core["getProjects"] = listProjectsFn;
|
|
986
|
-
this.core["getProject"] = getProjectFn;
|
|
987
|
-
this.search["listProjects"] = listProjectsFn;
|
|
988
|
-
this.search["searchProjects"] = listProjectsFn;
|
|
989
|
-
this.search["getProjects"] = listProjectsFn;
|
|
990
|
-
this.search["getProject"] = getProjectFn;
|
|
991
|
-
this.admin["listProjects"] = listProjectsFn;
|
|
992
|
-
this.admin["getProjects"] = listProjectsFn;
|
|
993
|
-
this.admin["getProject"] = getProjectFn;
|
|
994
|
-
for (const [groupName, aliases] of Object.entries(METHOD_ALIASES)) {
|
|
995
|
-
const groupApi = this[groupName];
|
|
996
|
-
if (!groupApi) continue;
|
|
997
|
-
for (const [aliasName, canonicalMethod] of Object.entries(aliases)) {
|
|
998
|
-
if (typeof groupApi[canonicalMethod] === "function") {
|
|
999
|
-
groupApi[aliasName] ??= groupApi[canonicalMethod];
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Get all available groups
|
|
1006
|
-
*/
|
|
1007
|
-
getGroups() {
|
|
1008
|
-
return [...this.toolsByGroup.keys()].sort();
|
|
1009
|
-
}
|
|
1010
|
-
/**
|
|
1011
|
-
* Get method names for a group
|
|
1012
|
-
*/
|
|
1013
|
-
getGroupMethods(group) {
|
|
1014
|
-
const groupApi = this[group];
|
|
1015
|
-
if (!groupApi || typeof groupApi !== "object") return [];
|
|
1016
|
-
return Object.keys(groupApi).filter((k) => k !== "help").sort();
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Create the sandbox bindings object.
|
|
1020
|
-
* This is the object injected as `mj` in the sandbox.
|
|
1021
|
-
* Includes group namespaces + top-level aliases for common operations.
|
|
1022
|
-
*/
|
|
1023
|
-
createSandboxBindings(progressCtx) {
|
|
1024
|
-
const handleReadResource = (uri) => {
|
|
1025
|
-
if (typeof uri === "string") {
|
|
1026
|
-
if (uri.startsWith("memory://briefing") && typeof this.core["getBriefing"] === "function") {
|
|
1027
|
-
return this.core["getBriefing"]();
|
|
1028
|
-
}
|
|
1029
|
-
if ((uri.startsWith("memory://agent-id") || uri.startsWith("memory://config")) && typeof this.core["getConfig"] === "function") {
|
|
1030
|
-
return this.core["getConfig"]();
|
|
1031
|
-
}
|
|
1032
|
-
if (uri.startsWith("memory://recent") && typeof this.core["getRecentEntries"] === "function") {
|
|
1033
|
-
return this.core["getRecentEntries"]();
|
|
1034
|
-
}
|
|
1035
|
-
if (uri.startsWith("memory://statistics") && typeof this.analytics["getStatistics"] === "function") {
|
|
1036
|
-
return this.analytics["getStatistics"]();
|
|
1037
|
-
}
|
|
1038
|
-
if (uri.startsWith("memory://tags") && typeof this.core["listTags"] === "function") {
|
|
1039
|
-
return this.core["listTags"]();
|
|
1040
|
-
}
|
|
1041
|
-
if (uri.startsWith("memory://flags") && typeof this.team["teamListFlags"] === "function") {
|
|
1042
|
-
return this.team["teamListFlags"]({ status: "active" });
|
|
1043
|
-
}
|
|
1044
|
-
if (uri.startsWith("memory://insights") && typeof this.analytics["getCrossProjectInsights"] === "function") {
|
|
1045
|
-
return this.analytics["getCrossProjectInsights"]();
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
const suggestions = {
|
|
1049
|
-
"memory://recent": "mj.core.getRecentEntries()",
|
|
1050
|
-
"memory://statistics": "mj.analytics.getStatistics()",
|
|
1051
|
-
"memory://tags": "mj.core.listTags()",
|
|
1052
|
-
"memory://flags": 'mj.team.teamListFlags({ status: "active" })',
|
|
1053
|
-
"memory://significant": 'mj.search.searchEntries({ sort_by: "importance" })',
|
|
1054
|
-
"memory://insights": "mj.analytics.getCrossProjectInsights()"
|
|
1055
|
-
};
|
|
1056
|
-
let hint = "";
|
|
1057
|
-
if (typeof uri === "string") {
|
|
1058
|
-
const match = Object.entries(suggestions).find(([k]) => uri.startsWith(k));
|
|
1059
|
-
if (match !== void 0) {
|
|
1060
|
-
hint = ` Try: ${match[1]}`;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
return Promise.reject(new Error(
|
|
1064
|
-
`Code Mode cannot directly read MCP resources (e.g., memory://briefing) using readResource().${hint} Use the appropriate mj.* tools to query data, or read the resource via standard MCP client requests outside of Code Mode.`
|
|
1065
|
-
));
|
|
1066
|
-
};
|
|
1067
|
-
const schemaHelpFn = () => Promise.resolve({
|
|
1068
|
-
group: "schema",
|
|
1069
|
-
description: "Memory Journal Schema: Embedded SQLite database storing entries, tags, entry tags, relationships, and projects.",
|
|
1070
|
-
tables: ["entries", "tags", "entry_tags", "relationships", "projects"],
|
|
1071
|
-
entrySchema: {
|
|
1072
|
-
id: "number (auto-increment primary key)",
|
|
1073
|
-
title: "string (required, entry title)",
|
|
1074
|
-
content: "string (markdown body)",
|
|
1075
|
-
entry_type: "'journal' | 'retrospective' | 'decision' | 'note' | 'runbook'",
|
|
1076
|
-
tags: "string[] (optional array of tags)",
|
|
1077
|
-
project_number: "number (optional project number)",
|
|
1078
|
-
session_id: "string (optional session tracking id)",
|
|
1079
|
-
metadata: "Record<string, unknown> (optional JSON metadata)"
|
|
1080
|
-
},
|
|
1081
|
-
methods: ["help", "describe", "listTables", "describeTable", "getSchema"],
|
|
1082
|
-
usage: "Call mj.core.createEntry.schema() for parameter validation details, or mj.analytics.getStatistics() for database statistics."
|
|
1083
|
-
});
|
|
1084
|
-
const schemaCallable = Object.assign(
|
|
1085
|
-
async (...args) => {
|
|
1086
|
-
const stats = this.analytics["getStatistics"];
|
|
1087
|
-
if (typeof stats === "function") {
|
|
1088
|
-
return stats(...args);
|
|
1089
|
-
}
|
|
1090
|
-
return schemaHelpFn();
|
|
1091
|
-
},
|
|
1092
|
-
{
|
|
1093
|
-
help: schemaHelpFn,
|
|
1094
|
-
describe: schemaHelpFn,
|
|
1095
|
-
listTables: () => Promise.resolve({
|
|
1096
|
-
success: true,
|
|
1097
|
-
tables: ["entries", "tags", "entry_tags", "relationships", "projects"]
|
|
1098
|
-
}),
|
|
1099
|
-
describeTable: (tableName) => {
|
|
1100
|
-
const table = typeof tableName === "string" ? tableName.toLowerCase() : "entries";
|
|
1101
|
-
if (table === "entries" || table === "journal" || table === "memory") {
|
|
1102
|
-
return schemaHelpFn();
|
|
1103
|
-
}
|
|
1104
|
-
return Promise.resolve({
|
|
1105
|
-
table,
|
|
1106
|
-
description: `Table '${table}' in Memory Journal SQLite database.`
|
|
1107
|
-
});
|
|
1108
|
-
},
|
|
1109
|
-
getSchema: schemaHelpFn
|
|
1110
|
-
}
|
|
1111
|
-
);
|
|
1112
|
-
const bindings = {
|
|
1113
|
-
// Group namespaces
|
|
1114
|
-
core: this.core,
|
|
1115
|
-
search: this.search,
|
|
1116
|
-
analytics: this.analytics,
|
|
1117
|
-
relationships: this.relationships,
|
|
1118
|
-
io: this.io,
|
|
1119
|
-
// Backward-compat alias — agents using mj.export.* still work
|
|
1120
|
-
export: this.io,
|
|
1121
|
-
admin: this.admin,
|
|
1122
|
-
github: this.github,
|
|
1123
|
-
backup: this.backup,
|
|
1124
|
-
team: this.team,
|
|
1125
|
-
git: this.git,
|
|
1126
|
-
gitApi: this.git,
|
|
1127
|
-
memory: this.memory,
|
|
1128
|
-
schema: schemaCallable,
|
|
1129
|
-
getSchema: schemaCallable,
|
|
1130
|
-
get_schema: schemaCallable,
|
|
1131
|
-
// Top-level convenience aliases
|
|
1132
|
-
createEntry: this.core["createEntry"],
|
|
1133
|
-
getRecentEntries: this.core["getRecentEntries"],
|
|
1134
|
-
searchEntries: this.search["searchEntries"],
|
|
1135
|
-
getStatistics: this.analytics["getStatistics"],
|
|
1136
|
-
serverInfo: this.analytics["getStatistics"],
|
|
1137
|
-
serverHealth: this.analytics["getStatistics"],
|
|
1138
|
-
getServerInfo: this.analytics["getStatistics"],
|
|
1139
|
-
getServerHealth: this.analytics["getStatistics"],
|
|
1140
|
-
listProjects: this.core["listProjects"],
|
|
1141
|
-
searchProjects: this.core["listProjects"],
|
|
1142
|
-
getProjects: this.core["listProjects"],
|
|
1143
|
-
getProject: this.core["getProject"],
|
|
1144
|
-
getBriefing: this.core["getBriefing"],
|
|
1145
|
-
// Common hallucinated aliases mapped to correct endpoints to smooth out agent executions
|
|
1146
|
-
getConfig: this.core["getConfig"],
|
|
1147
|
-
addEntry: this.core["createEntry"],
|
|
1148
|
-
append: this.core["createEntry"],
|
|
1149
|
-
appendEntry: this.core["createEntry"],
|
|
1150
|
-
append_entry: this.core["createEntry"],
|
|
1151
|
-
logJournal: this.core["createEntry"],
|
|
1152
|
-
log_journal: this.core["createEntry"],
|
|
1153
|
-
logEntry: this.core["createEntry"],
|
|
1154
|
-
log_entry: this.core["createEntry"],
|
|
1155
|
-
insertJournal: this.core["createEntry"],
|
|
1156
|
-
insert_journal: this.core["createEntry"],
|
|
1157
|
-
insertEntry: this.core["createEntry"],
|
|
1158
|
-
insert_entry: this.core["createEntry"],
|
|
1159
|
-
addJournal: this.core["createEntry"],
|
|
1160
|
-
add_journal: this.core["createEntry"],
|
|
1161
|
-
saveJournalEntry: this.core["createEntry"],
|
|
1162
|
-
save_journal_entry: this.core["createEntry"],
|
|
1163
|
-
createJournalEntry: this.core["createEntry"],
|
|
1164
|
-
create_journal_entry: this.core["createEntry"],
|
|
1165
|
-
sqlite_journal_add_entry: this.core["createEntry"],
|
|
1166
|
-
entries: this.core,
|
|
1167
|
-
deleteEntry: this.admin["deleteEntry"],
|
|
1168
|
-
updateEntry: this.admin["updateEntry"],
|
|
1169
|
-
// Factory & Singleton shims
|
|
1170
|
-
getInstance: () => bindings,
|
|
1171
|
-
get_instance: () => bindings,
|
|
1172
|
-
createInstance: () => bindings,
|
|
1173
|
-
create_instance: () => bindings,
|
|
1174
|
-
getClient: () => bindings,
|
|
1175
|
-
get_client: () => bindings,
|
|
1176
|
-
createClient: () => bindings,
|
|
1177
|
-
create_client: () => bindings,
|
|
1178
|
-
initClient: () => bindings,
|
|
1179
|
-
init_client: () => bindings,
|
|
1180
|
-
getService: () => bindings,
|
|
1181
|
-
get_service: () => bindings,
|
|
1182
|
-
createService: () => bindings,
|
|
1183
|
-
create_service: () => bindings,
|
|
1184
|
-
getJournal: () => bindings,
|
|
1185
|
-
get_journal: () => bindings,
|
|
1186
|
-
createJournal: () => bindings,
|
|
1187
|
-
create_journal: () => bindings,
|
|
1188
|
-
loadJournal: () => bindings,
|
|
1189
|
-
load_journal: () => bindings,
|
|
1190
|
-
loadMemory: () => bindings,
|
|
1191
|
-
load_memory: () => bindings,
|
|
1192
|
-
load: () => bindings,
|
|
1193
|
-
init: () => bindings,
|
|
1194
|
-
initialize: () => bindings,
|
|
1195
|
-
connect: () => bindings,
|
|
1196
|
-
open: () => bindings,
|
|
1197
|
-
start: () => bindings,
|
|
1198
|
-
create: () => bindings,
|
|
1199
|
-
// Global Hallucinations
|
|
1200
|
-
readResource: handleReadResource,
|
|
1201
|
-
// Extended top-level convenience aliases for common hallucinations
|
|
1202
|
-
find: this.search["searchEntries"],
|
|
1203
|
-
listEntries: this.search["searchEntries"],
|
|
1204
|
-
recent: this.core["getRecentEntries"],
|
|
1205
|
-
listTags: this.core["listTags"],
|
|
1206
|
-
semanticSearch: this.search["semanticSearch"],
|
|
1207
|
-
linkEntries: this.relationships["linkEntries"],
|
|
1208
|
-
mergeTags: this.admin["mergeTags"],
|
|
1209
|
-
exportEntries: this.io["exportEntries"],
|
|
1210
|
-
// Bare global function aliases to catch LLM top-level function hallucinations
|
|
1211
|
-
memory_journal_search: this.search["searchEntries"],
|
|
1212
|
-
memory_journal_create: this.core["createEntry"],
|
|
1213
|
-
journal_create: this.core["createEntry"],
|
|
1214
|
-
journal_search: this.search["searchEntries"],
|
|
1215
|
-
create_entry: this.core["createEntry"],
|
|
1216
|
-
search_entries: this.search["searchEntries"],
|
|
1217
|
-
get_recent_entries: this.core["getRecentEntries"],
|
|
1218
|
-
get_entry_by_id: this.core["getEntryById"],
|
|
1219
|
-
update_entry: this.admin["updateEntry"],
|
|
1220
|
-
delete_entry: this.admin["deleteEntry"],
|
|
1221
|
-
read_resource: handleReadResource,
|
|
1222
|
-
memory_read_resource: handleReadResource,
|
|
1223
|
-
memoryReadResource: handleReadResource,
|
|
1224
|
-
// Anti-Hallucination: Agent shell execution interceptor
|
|
1225
|
-
Agent: {
|
|
1226
|
-
system: {
|
|
1227
|
-
exec: () => Promise.reject(new Error(
|
|
1228
|
-
`\u{1F6E0}\uFE0F AUTONOMOUS HEALING: Code Mode sandbox cannot execute shell commands via 'Agent.system.exec'. To execute terminal commands or scripts, call 'run_command' outside of Code Mode in the agent shell.`
|
|
1229
|
-
))
|
|
1230
|
-
},
|
|
1231
|
-
exec: () => Promise.reject(new Error(
|
|
1232
|
-
`\u{1F6E0}\uFE0F AUTONOMOUS HEALING: Code Mode sandbox cannot execute shell commands via 'Agent.exec'. To execute terminal commands or scripts, call 'run_command' outside of Code Mode in the agent shell.`
|
|
1233
|
-
))
|
|
1234
|
-
},
|
|
1235
|
-
// Anti-Hallucination: setWorkspace interceptor
|
|
1236
|
-
setWorkspace: () => {
|
|
1237
|
-
return Promise.reject(new Error(
|
|
1238
|
-
`Workspace changes should be done via parameters (e.g., passing \`workspace_id\` to tool functions), not through imperative state like setWorkspace().`
|
|
1239
|
-
));
|
|
1240
|
-
},
|
|
1241
|
-
// Top-level help
|
|
1242
|
-
help: () => {
|
|
1243
|
-
const groups = this.getGroups();
|
|
1244
|
-
let totalMethods = 0;
|
|
1245
|
-
for (const group of groups) {
|
|
1246
|
-
totalMethods += this.getGroupMethods(group).length;
|
|
1247
|
-
}
|
|
1248
|
-
return Promise.resolve({
|
|
1249
|
-
groups,
|
|
1250
|
-
totalMethods,
|
|
1251
|
-
usage: "Use mj.<group>.help() for group details. Example: mj.core.help()"
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
};
|
|
1255
|
-
bindings["reportProgress"] = async (progress, total, message) => {
|
|
1256
|
-
await sendProgress(progressCtx, progress, total, message);
|
|
1257
|
-
};
|
|
1258
|
-
return bindings;
|
|
1259
|
-
}
|
|
1260
|
-
/**
|
|
1261
|
-
* Create the sandbox schemas object.
|
|
1262
|
-
* Contains the TypeScript type string representation for each method.
|
|
1263
|
-
*/
|
|
1264
|
-
createSandboxSchemas() {
|
|
1265
|
-
const schemas = {};
|
|
1266
|
-
for (const [groupName, tools] of this.toolsByGroup.entries()) {
|
|
1267
|
-
const groupSchemas = {};
|
|
1268
|
-
for (const tool of tools) {
|
|
1269
|
-
const methodName = toolNameToMethodName(tool.name, groupName);
|
|
1270
|
-
groupSchemas[methodName] = getZodTypeString(tool.inputSchema);
|
|
1271
|
-
}
|
|
1272
|
-
const aliases = METHOD_ALIASES[groupName];
|
|
1273
|
-
if (aliases) {
|
|
1274
|
-
for (const [aliasName, canonicalName] of Object.entries(aliases)) {
|
|
1275
|
-
if (groupSchemas[canonicalName] !== void 0) {
|
|
1276
|
-
groupSchemas[aliasName] = groupSchemas[canonicalName];
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
schemas[groupName] = groupSchemas;
|
|
1281
|
-
}
|
|
1282
|
-
return schemas;
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
|
-
function createJournalApi(tools, dispatcher) {
|
|
1286
|
-
return new JournalApi(tools, dispatcher);
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
export { JournalApi, createJournalApi };
|