@nxuss/lemma 1.18.0 → 1.18.2
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/dist/cjs/mcp/cognitiveMap.d.ts +27 -0
- package/dist/cjs/mcp/cognitiveMap.d.ts.map +1 -0
- package/dist/cjs/mcp/cognitiveMap.js +47 -0
- package/dist/cjs/mcp/cognitiveMap.js.map +1 -0
- package/dist/cjs/mcp/toolTypes.d.ts +39 -0
- package/dist/cjs/mcp/toolTypes.d.ts.map +1 -0
- package/dist/cjs/mcp/toolTypes.js +8 -0
- package/dist/cjs/mcp/toolTypes.js.map +1 -0
- package/dist/cjs/mcp/tools/analysis.d.ts +11 -0
- package/dist/cjs/mcp/tools/analysis.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/analysis.js +933 -0
- package/dist/cjs/mcp/tools/analysis.js.map +1 -0
- package/dist/cjs/mcp/tools/codenav.d.ts +9 -0
- package/dist/cjs/mcp/tools/codenav.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/codenav.js +524 -0
- package/dist/cjs/mcp/tools/codenav.js.map +1 -0
- package/dist/cjs/mcp/tools/context-tools.d.ts +20 -0
- package/dist/cjs/mcp/tools/context-tools.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/context-tools.js +543 -0
- package/dist/cjs/mcp/tools/context-tools.js.map +1 -0
- package/dist/cjs/mcp/tools/depgraph.d.ts +8 -0
- package/dist/cjs/mcp/tools/depgraph.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/depgraph.js +321 -0
- package/dist/cjs/mcp/tools/depgraph.js.map +1 -0
- package/dist/cjs/mcp/tools/dev-utils.d.ts +11 -0
- package/dist/cjs/mcp/tools/dev-utils.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/dev-utils.js +519 -0
- package/dist/cjs/mcp/tools/dev-utils.js.map +1 -0
- package/dist/cjs/mcp/tools/devtools.d.ts +9 -0
- package/dist/cjs/mcp/tools/devtools.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/devtools.js +445 -0
- package/dist/cjs/mcp/tools/devtools.js.map +1 -0
- package/dist/cjs/mcp/tools/memory.d.ts +10 -0
- package/dist/cjs/mcp/tools/memory.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/memory.js +539 -0
- package/dist/cjs/mcp/tools/memory.js.map +1 -0
- package/dist/cjs/mcp/tools/misc.d.ts +10 -0
- package/dist/cjs/mcp/tools/misc.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/misc.js +423 -0
- package/dist/cjs/mcp/tools/misc.js.map +1 -0
- package/dist/cjs/mcp/tools/refactor.d.ts +8 -0
- package/dist/cjs/mcp/tools/refactor.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/refactor.js +335 -0
- package/dist/cjs/mcp/tools/refactor.js.map +1 -0
- package/dist/cjs/mcp/tools/review.d.ts +10 -0
- package/dist/cjs/mcp/tools/review.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/review.js +283 -0
- package/dist/cjs/mcp/tools/review.js.map +1 -0
- package/dist/cjs/mcp/tools/squeeze-cache.d.ts +14 -0
- package/dist/cjs/mcp/tools/squeeze-cache.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/squeeze-cache.js +418 -0
- package/dist/cjs/mcp/tools/squeeze-cache.js.map +1 -0
- package/dist/cjs/mcp/tools/text-ops.d.ts +14 -0
- package/dist/cjs/mcp/tools/text-ops.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/text-ops.js +155 -0
- package/dist/cjs/mcp/tools/text-ops.js.map +1 -0
- package/dist/cjs/mcp/tools/workspace.d.ts +10 -0
- package/dist/cjs/mcp/tools/workspace.d.ts.map +1 -0
- package/dist/cjs/mcp/tools/workspace.js +675 -0
- package/dist/cjs/mcp/tools/workspace.js.map +1 -0
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +636 -6388
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/mcp/utils.d.ts +55 -2
- package/dist/cjs/mcp/utils.d.ts.map +1 -1
- package/dist/cjs/mcp/utils.js +194 -10
- package/dist/cjs/mcp/utils.js.map +1 -1
- package/dist/cjs/mcp/workspaceShared.d.ts +19 -0
- package/dist/cjs/mcp/workspaceShared.d.ts.map +1 -0
- package/dist/cjs/mcp/workspaceShared.js +101 -0
- package/dist/cjs/mcp/workspaceShared.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/utils/ExecAuditLog.d.ts +27 -0
- package/dist/cjs/utils/ExecAuditLog.d.ts.map +1 -0
- package/dist/cjs/utils/ExecAuditLog.js +53 -0
- package/dist/cjs/utils/ExecAuditLog.js.map +1 -0
- package/dist/esm/api/dashboardRoutes.d.ts +3 -3
- package/dist/esm/api/dashboardRoutes.js +1 -1
- package/dist/esm/api/server.d.ts +4 -4
- package/dist/esm/api/server.js +3 -3
- package/dist/esm/autopilot/AutopilotWatcher.js +3 -3
- package/dist/esm/autopilot/Notifier.d.ts +1 -1
- package/dist/esm/cli/lemma-proxy.js +15 -15
- package/dist/esm/cli/stack.d.ts +4 -4
- package/dist/esm/cli/stack.js +5 -5
- package/dist/esm/cloud/KeyManager.d.ts +1 -1
- package/dist/esm/cloud/KeyManager.js +1 -1
- package/dist/esm/cloud/TenantCache.d.ts +1 -1
- package/dist/esm/cloud/identity/ApiKey.d.ts +1 -1
- package/dist/esm/cloud/identity/TenantResolver.d.ts +1 -1
- package/dist/esm/cloud/identity/TenantResolver.js +1 -1
- package/dist/esm/cloud/identity/authenticateV2.d.ts +3 -3
- package/dist/esm/cloud/identity/authenticateV2.js +3 -3
- package/dist/esm/cloud/identity/identityStore.d.ts +2 -2
- package/dist/esm/cloud/identity/index.d.ts +6 -6
- package/dist/esm/cloud/identity/index.js +6 -6
- package/dist/esm/cloud/index.d.ts +3 -3
- package/dist/esm/cloud/index.js +3 -3
- package/dist/esm/cloud/metering/UsageLedger.d.ts +1 -1
- package/dist/esm/cloud/metering/index.d.ts +2 -2
- package/dist/esm/cloud/metering/index.js +2 -2
- package/dist/esm/cloud/scrub/StatelessScrubber.d.ts +1 -1
- package/dist/esm/cloud/scrub/index.d.ts +1 -1
- package/dist/esm/cloud/scrub/index.js +1 -1
- package/dist/esm/cloud/server.d.ts +3 -3
- package/dist/esm/cloud/server.js +5 -5
- package/dist/esm/cloud/store/FileBrainStore.d.ts +1 -1
- package/dist/esm/cloud/store/FileBrainStore.js +1 -1
- package/dist/esm/cloud/store/PostgresBrainStore.d.ts +1 -1
- package/dist/esm/cloud/store/PostgresBrainStore.js +2 -2
- package/dist/esm/cloud/store/index.d.ts +2 -2
- package/dist/esm/cloud/store/index.js +2 -2
- package/dist/esm/cloud/v2/app.d.ts +1 -1
- package/dist/esm/cloud/v2/app.js +3 -3
- package/dist/esm/cloud/v2/routes/index.d.ts +5 -5
- package/dist/esm/cloud/v2/routes/index.js +7 -7
- package/dist/esm/cloud/v2/routes/memories.d.ts +4 -4
- package/dist/esm/cloud/v2/routes/memories.js +2 -2
- package/dist/esm/cloud/v2/routes/recall.d.ts +1 -1
- package/dist/esm/cloud/v2/routes/recall.js +1 -1
- package/dist/esm/cloud/v2/routes/scrub.d.ts +2 -2
- package/dist/esm/cloud/v2/routes/scrub.js +2 -2
- package/dist/esm/cloud/v2/routes/usage.d.ts +1 -1
- package/dist/esm/cloud/v2/routes/verify.d.ts +1 -1
- package/dist/esm/cloud/v2/routes/verify.js +1 -1
- package/dist/esm/cloud/v2/server.js +4 -4
- package/dist/esm/config/index.d.ts +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/consensus/index.d.ts +2 -2
- package/dist/esm/consensus/index.js +2 -2
- package/dist/esm/contracts/api-v2.types.d.ts +1 -1
- package/dist/esm/contracts/index.d.ts +4 -4
- package/dist/esm/contracts/index.js +4 -4
- package/dist/esm/core/AgentRegistry.d.ts +1 -1
- package/dist/esm/core/AgentRegistry.js +1 -1
- package/dist/esm/core/DashboardBroadcaster.d.ts +3 -3
- package/dist/esm/core/DashboardBroadcaster.js +2 -2
- package/dist/esm/core/DashboardWebSocketServer.d.ts +1 -1
- package/dist/esm/core/DashboardWebSocketServer.js +1 -1
- package/dist/esm/core/GhostAlchemist.js +1 -1
- package/dist/esm/core/GhostListener.js +2 -2
- package/dist/esm/core/OrchestrationEngine.d.ts +3 -3
- package/dist/esm/core/OrchestrationEngine.js +2 -2
- package/dist/esm/core/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/core/SubconsciousEngine.js +2 -2
- package/dist/esm/core/WebSocketServer.d.ts +2 -2
- package/dist/esm/core/WebSocketServer.js +1 -1
- package/dist/esm/core/index.d.ts +6 -6
- package/dist/esm/core/index.js +6 -6
- package/dist/esm/core/router.d.ts +3 -3
- package/dist/esm/core/router.js +1 -1
- package/dist/esm/db/database.js +1 -1
- package/dist/esm/embed.d.ts +2 -2
- package/dist/esm/embed.js +2 -2
- package/dist/esm/examples/basic-usage.js +1 -1
- package/dist/esm/index.d.ts +14 -14
- package/dist/esm/index.js +14 -14
- package/dist/esm/infra/analyzers/DriftDetector.d.ts +1 -1
- package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/MonolithAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/index.d.ts +3 -3
- package/dist/esm/infra/analyzers/index.js +3 -3
- package/dist/esm/infra/cli.js +2 -2
- package/dist/esm/infra/config.d.ts +1 -1
- package/dist/esm/infra/index.d.ts +5 -5
- package/dist/esm/infra/index.js +5 -5
- package/dist/esm/infra/mcp-tools.js +5 -5
- package/dist/esm/infra/providers/InfraProvider.d.ts +1 -1
- package/dist/esm/infra/providers/JenkinsProvider.d.ts +2 -2
- package/dist/esm/infra/providers/OKDProvider.d.ts +2 -2
- package/dist/esm/infra/providers/TerraformProvider.d.ts +2 -2
- package/dist/esm/infra/providers/index.d.ts +5 -5
- package/dist/esm/infra/providers/index.js +3 -3
- package/dist/esm/mcp/cognitiveMap.d.ts +27 -0
- package/dist/esm/mcp/cognitiveMap.d.ts.map +1 -0
- package/dist/esm/mcp/cognitiveMap.js +40 -0
- package/dist/esm/mcp/cognitiveMap.js.map +1 -0
- package/dist/esm/mcp/index.js +5 -5
- package/dist/esm/mcp/prompts.js +1 -1
- package/dist/esm/mcp/resources.js +2 -2
- package/dist/esm/mcp/tasks.js +1 -1
- package/dist/esm/mcp/tool-profiles.js +1 -1
- package/dist/esm/mcp/toolTypes.d.ts +39 -0
- package/dist/esm/mcp/toolTypes.d.ts.map +1 -0
- package/dist/esm/mcp/toolTypes.js +7 -0
- package/dist/esm/mcp/toolTypes.js.map +1 -0
- package/dist/esm/mcp/tools/analysis.d.ts +11 -0
- package/dist/esm/mcp/tools/analysis.d.ts.map +1 -0
- package/dist/esm/mcp/tools/analysis.js +894 -0
- package/dist/esm/mcp/tools/analysis.js.map +1 -0
- package/dist/esm/mcp/tools/codenav.d.ts +9 -0
- package/dist/esm/mcp/tools/codenav.d.ts.map +1 -0
- package/dist/esm/mcp/tools/codenav.js +485 -0
- package/dist/esm/mcp/tools/codenav.js.map +1 -0
- package/dist/esm/mcp/tools/context-tools.d.ts +20 -0
- package/dist/esm/mcp/tools/context-tools.d.ts.map +1 -0
- package/dist/esm/mcp/tools/context-tools.js +503 -0
- package/dist/esm/mcp/tools/context-tools.js.map +1 -0
- package/dist/esm/mcp/tools/depgraph.d.ts +8 -0
- package/dist/esm/mcp/tools/depgraph.d.ts.map +1 -0
- package/dist/esm/mcp/tools/depgraph.js +315 -0
- package/dist/esm/mcp/tools/depgraph.js.map +1 -0
- package/dist/esm/mcp/tools/dev-utils.d.ts +11 -0
- package/dist/esm/mcp/tools/dev-utils.d.ts.map +1 -0
- package/dist/esm/mcp/tools/dev-utils.js +516 -0
- package/dist/esm/mcp/tools/dev-utils.js.map +1 -0
- package/dist/esm/mcp/tools/devtools.d.ts +9 -0
- package/dist/esm/mcp/tools/devtools.d.ts.map +1 -0
- package/dist/esm/mcp/tools/devtools.js +406 -0
- package/dist/esm/mcp/tools/devtools.js.map +1 -0
- package/dist/esm/mcp/tools/memory.d.ts +10 -0
- package/dist/esm/mcp/tools/memory.d.ts.map +1 -0
- package/dist/esm/mcp/tools/memory.js +533 -0
- package/dist/esm/mcp/tools/memory.js.map +1 -0
- package/dist/esm/mcp/tools/misc.d.ts +10 -0
- package/dist/esm/mcp/tools/misc.d.ts.map +1 -0
- package/dist/esm/mcp/tools/misc.js +417 -0
- package/dist/esm/mcp/tools/misc.js.map +1 -0
- package/dist/esm/mcp/tools/refactor.d.ts +8 -0
- package/dist/esm/mcp/tools/refactor.d.ts.map +1 -0
- package/dist/esm/mcp/tools/refactor.js +296 -0
- package/dist/esm/mcp/tools/refactor.js.map +1 -0
- package/dist/esm/mcp/tools/review.d.ts +10 -0
- package/dist/esm/mcp/tools/review.d.ts.map +1 -0
- package/dist/esm/mcp/tools/review.js +277 -0
- package/dist/esm/mcp/tools/review.js.map +1 -0
- package/dist/esm/mcp/tools/squeeze-cache.d.ts +14 -0
- package/dist/esm/mcp/tools/squeeze-cache.d.ts.map +1 -0
- package/dist/esm/mcp/tools/squeeze-cache.js +382 -0
- package/dist/esm/mcp/tools/squeeze-cache.js.map +1 -0
- package/dist/esm/mcp/tools/text-ops.d.ts +14 -0
- package/dist/esm/mcp/tools/text-ops.d.ts.map +1 -0
- package/dist/esm/mcp/tools/text-ops.js +152 -0
- package/dist/esm/mcp/tools/text-ops.js.map +1 -0
- package/dist/esm/mcp/tools/workspace.d.ts +10 -0
- package/dist/esm/mcp/tools/workspace.d.ts.map +1 -0
- package/dist/esm/mcp/tools/workspace.js +669 -0
- package/dist/esm/mcp/tools/workspace.js.map +1 -0
- package/dist/esm/mcp/tools.d.ts +1 -1
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +652 -6404
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/mcp/utils.d.ts +55 -2
- package/dist/esm/mcp/utils.d.ts.map +1 -1
- package/dist/esm/mcp/utils.js +189 -10
- package/dist/esm/mcp/utils.js.map +1 -1
- package/dist/esm/mcp/workspaceShared.d.ts +19 -0
- package/dist/esm/mcp/workspaceShared.d.ts.map +1 -0
- package/dist/esm/mcp/workspaceShared.js +93 -0
- package/dist/esm/mcp/workspaceShared.js.map +1 -0
- package/dist/esm/observability/IdeContextSync.d.ts +1 -1
- package/dist/esm/observability/IdeContextSync.js +5 -5
- package/dist/esm/package.json +3 -0
- package/dist/esm/pr-review/PRReviewEngine.d.ts +1 -1
- package/dist/esm/pr-review/PRReviewEngine.js +4 -4
- package/dist/esm/pr-review/ReviewStore.d.ts +1 -1
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitHubAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitHubAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitLabAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitLabAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitPlatformAdapter.d.ts +1 -1
- package/dist/esm/pr-review/adapters/index.d.ts +4 -4
- package/dist/esm/pr-review/adapters/index.js +3 -3
- package/dist/esm/pr-review/analyzers/QualityGrader.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/RegressionDetector.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/SecurityScanner.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/StaticAnalyzer.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/index.d.ts +8 -8
- package/dist/esm/pr-review/analyzers/index.js +4 -4
- package/dist/esm/pr-review/bridge/BrainBridge.d.ts +1 -1
- package/dist/esm/pr-review/bridge/BrainBridge.js +1 -1
- package/dist/esm/pr-review/bridge/index.d.ts +1 -1
- package/dist/esm/pr-review/bridge/index.js +1 -1
- package/dist/esm/pr-review/index.d.ts +4 -4
- package/dist/esm/pr-review/index.js +2 -2
- package/dist/esm/pr-review/reviewRunner.d.ts +2 -2
- package/dist/esm/pr-review/reviewRunner.js +6 -6
- package/dist/esm/pr-review/webhook/WebhookServer.js +1 -1
- package/dist/esm/pr-review/webhook/index.d.ts +1 -1
- package/dist/esm/pr-review/webhook/index.js +1 -1
- package/dist/esm/protocol/flows.d.ts +1 -1
- package/dist/esm/protocol/flows.js +1 -1
- package/dist/esm/protocol/index.d.ts +4 -4
- package/dist/esm/protocol/index.js +4 -4
- package/dist/esm/protocol/utils.d.ts +1 -1
- package/dist/esm/protocol/utils.js +2 -2
- package/dist/esm/protocol/validators.d.ts +1 -1
- package/dist/esm/protocol/validators.js +1 -1
- package/dist/esm/proxy/ContextInjector.d.ts +1 -1
- package/dist/esm/proxy/Gatekeeper.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.js +3 -3
- package/dist/esm/security/index.d.ts +4 -4
- package/dist/esm/security/index.js +4 -4
- package/dist/esm/speculative/SpeculativeCache.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.js +3 -3
- package/dist/esm/speculative/WorkerPool.d.ts +1 -1
- package/dist/esm/speculative/index.d.ts +4 -4
- package/dist/esm/speculative/index.js +4 -4
- package/dist/esm/subconscious/GitIngest.d.ts +1 -1
- package/dist/esm/subconscious/GitIngest.js +1 -1
- package/dist/esm/subconscious/SemanticCache.d.ts +2 -2
- package/dist/esm/subconscious/SemanticCache.js +2 -2
- package/dist/esm/subconscious/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/subconscious/SubconsciousEngine.js +3 -3
- package/dist/esm/subconscious/TheBrainV2.d.ts +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +2 -2
- package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts +1 -1
- package/dist/esm/subconscious/freshness/LocalFsResolver.js +1 -1
- package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.d.ts +1 -1
- package/dist/esm/subconscious/freshness/index.d.ts +2 -2
- package/dist/esm/subconscious/freshness/index.js +2 -2
- package/dist/esm/subconscious/index.d.ts +4 -4
- package/dist/esm/subconscious/index.js +4 -4
- package/dist/esm/utils/AffectedTests.js +1 -1
- package/dist/esm/utils/AutoContextBundle.d.ts +1 -1
- package/dist/esm/utils/AutoContextBundle.js +4 -4
- package/dist/esm/utils/BulkFileDigest.js +2 -2
- package/dist/esm/utils/ClipboardWatcher.js +2 -2
- package/dist/esm/utils/ContextCollapser.js +1 -1
- package/dist/esm/utils/ConversationCheckpoint.js +1 -1
- package/dist/esm/utils/ExecAuditLog.d.ts +27 -0
- package/dist/esm/utils/ExecAuditLog.d.ts.map +1 -0
- package/dist/esm/utils/ExecAuditLog.js +45 -0
- package/dist/esm/utils/ExecAuditLog.js.map +1 -0
- package/dist/esm/utils/ExecutiveReport.js +1 -1
- package/dist/esm/utils/OutputLedger.js +2 -2
- package/dist/esm/utils/ReadWorkspaceCache.js +1 -1
- package/dist/esm/utils/SpeculativeWarmer.d.ts +1 -1
- package/dist/esm/utils/SpeculativeWarmer.js +2 -2
- package/dist/esm/utils/StateHashCache.js +1 -1
- package/dist/esm/utils/StructuralSearch.d.ts +1 -1
- package/dist/esm/utils/SurgicalASTInsert.js +1 -1
- package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
- package/dist/esm/utils/TestAutofixInterceptor.js +1 -1
- package/dist/esm/utils/WorkspaceSearch.js +0 -0
- package/dist/esm/utils/logger.js +1 -1
- package/dist/esm/utils/reportSavings.js +1 -1
- package/package.json +3 -1
- package/sdks/crewai/dist/crewai/src/index.d.ts +131 -0
- package/sdks/crewai/dist/crewai/src/index.js +325 -0
- package/sdks/crewai/dist/crewai/src/memory.d.ts +36 -0
- package/sdks/crewai/dist/crewai/src/memory.js +61 -0
- package/sdks/crewai/dist/ts/src/client.d.ts +39 -0
- package/sdks/crewai/dist/ts/src/client.js +124 -0
- package/sdks/crewai/dist/ts/src/errors.d.ts +19 -0
- package/sdks/crewai/dist/ts/src/errors.js +18 -0
- package/sdks/crewai/dist/ts/src/evidence.d.ts +30 -0
- package/sdks/crewai/dist/ts/src/evidence.js +175 -0
- package/sdks/crewai/dist/ts/src/index.d.ts +4 -0
- package/sdks/crewai/dist/ts/src/index.js +27 -0
- package/sdks/crewai/dist/ts/src/types.d.ts +112 -0
- package/sdks/crewai/dist/ts/src/types.js +11 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LemmaClientOptions } from '../../ts/src/index';
|
|
2
|
+
import type { MemoryState, VerifiedResult } from '../../ts/src/types';
|
|
3
|
+
export interface LemmaMemoryToolConfig extends Omit<LemmaClientOptions, 'apiKey'> {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
rootDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LemmaMemoryRecallResult {
|
|
8
|
+
state: MemoryState;
|
|
9
|
+
staleFiles?: string[];
|
|
10
|
+
results: VerifiedResult[];
|
|
11
|
+
}
|
|
12
|
+
export type LemmaMemoryToolInput = {
|
|
13
|
+
action: 'remember';
|
|
14
|
+
text: string;
|
|
15
|
+
filePaths?: string[];
|
|
16
|
+
} | {
|
|
17
|
+
action: 'recall';
|
|
18
|
+
query: string;
|
|
19
|
+
filePaths?: string[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A CrewAI-style tool: `name`, `description`, and an async `func` an agent
|
|
23
|
+
* calls directly. `func` never collapses the result to a string — a
|
|
24
|
+
* `'recall'` call returns `{ state, staleFiles, results }`, so the crew can
|
|
25
|
+
* branch on `state === 'stale'` instead of parsing prose.
|
|
26
|
+
*/
|
|
27
|
+
export declare class LemmaMemoryTool {
|
|
28
|
+
readonly name = "lemma_memory";
|
|
29
|
+
readonly description: string;
|
|
30
|
+
private readonly client;
|
|
31
|
+
private readonly rootDir;
|
|
32
|
+
constructor(config: LemmaMemoryToolConfig);
|
|
33
|
+
func(input: LemmaMemoryToolInput): Promise<{
|
|
34
|
+
id: string;
|
|
35
|
+
} | LemmaMemoryRecallResult>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LemmaMemoryTool = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lemma memory tool for CrewAI (Lane H).
|
|
6
|
+
*
|
|
7
|
+
* Separate surface from `LemmaCrewConfig`/task-execution code in `index.ts`
|
|
8
|
+
* (that talks to the WebSocket orchestration router, an unrelated pre-existing
|
|
9
|
+
* product surface) — this wraps the `/v2` Verifiable Memory API on top of
|
|
10
|
+
* `@nxuss/lemma-sdk`. Shaped as a CrewAI-style tool: `name` + `description`
|
|
11
|
+
* + an async `func`, the calling convention CrewAI tools use so an agent can
|
|
12
|
+
* invoke it directly — and, per the plan, `func('recall', ...)` returns
|
|
13
|
+
* `state` as a first-class field, never hidden behind prose the agent has to
|
|
14
|
+
* re-interpret.
|
|
15
|
+
*/
|
|
16
|
+
const index_1 = require("../../ts/src/index");
|
|
17
|
+
const STATE_SEVERITY = {
|
|
18
|
+
contradicted: 3,
|
|
19
|
+
stale: 2,
|
|
20
|
+
unverified: 1,
|
|
21
|
+
fresh: 0,
|
|
22
|
+
};
|
|
23
|
+
function worstState(results) {
|
|
24
|
+
if (results.length === 0)
|
|
25
|
+
return 'unverified';
|
|
26
|
+
return results.reduce((worst, r) => (STATE_SEVERITY[r.state] > STATE_SEVERITY[worst] ? r.state : worst), 'fresh');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A CrewAI-style tool: `name`, `description`, and an async `func` an agent
|
|
30
|
+
* calls directly. `func` never collapses the result to a string — a
|
|
31
|
+
* `'recall'` call returns `{ state, staleFiles, results }`, so the crew can
|
|
32
|
+
* branch on `state === 'stale'` instead of parsing prose.
|
|
33
|
+
*/
|
|
34
|
+
class LemmaMemoryTool {
|
|
35
|
+
constructor(config) {
|
|
36
|
+
this.name = 'lemma_memory';
|
|
37
|
+
this.description = 'Store and recall verifiable memories about this codebase. Every recall returns a `state` ' +
|
|
38
|
+
'(fresh/stale/unverified/contradicted) proven against the current code — never a guess.';
|
|
39
|
+
const { rootDir, ...clientOptions } = config;
|
|
40
|
+
this.client = new index_1.LemmaClient(clientOptions);
|
|
41
|
+
this.rootDir = rootDir ?? process.cwd();
|
|
42
|
+
}
|
|
43
|
+
async func(input) {
|
|
44
|
+
if (input.action === 'remember') {
|
|
45
|
+
const evidence = (0, index_1.collectEvidence)({ rootDir: this.rootDir, files: input.filePaths ?? [] });
|
|
46
|
+
const res = await this.client.remember({
|
|
47
|
+
claims: [{ text: input.text, filePaths: input.filePaths }],
|
|
48
|
+
evidence,
|
|
49
|
+
});
|
|
50
|
+
return { id: res.id };
|
|
51
|
+
}
|
|
52
|
+
const evidence = (0, index_1.collectEvidence)({ rootDir: this.rootDir, files: input.filePaths ?? [] });
|
|
53
|
+
const res = await this.client.recall({ query: input.query, currentEvidence: evidence });
|
|
54
|
+
return {
|
|
55
|
+
state: worstState(res.results),
|
|
56
|
+
staleFiles: res.results.flatMap((r) => r.staleFiles ?? []),
|
|
57
|
+
results: res.results,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.LemmaMemoryTool = LemmaMemoryTool;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CreateMemoryRequest, CreateMemoryResponse, RecallRequest, RecallResponse, VerifyRequest, VerifyResponse, ForgetResponse, ScrubRequest, ScrubResponse, UsageResponse } from './types';
|
|
2
|
+
export interface LemmaClientOptions {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Defaults to the production /v2 base URL. Point at a local server in dev. */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Per-request timeout. Defaults to 10s. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
/** Retries for 429 (honoring Retry-After) and transient network/5xx failures. Defaults to 3. */
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
/** Injectable for tests; defaults to the global fetch. */
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
/** Injectable for tests; avoids real sleeps in the backoff test. */
|
|
13
|
+
sleep?: (ms: number) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare class LemmaClient {
|
|
16
|
+
private readonly apiKey;
|
|
17
|
+
private readonly baseUrl;
|
|
18
|
+
private readonly timeoutMs;
|
|
19
|
+
private readonly maxRetries;
|
|
20
|
+
private readonly fetchImpl;
|
|
21
|
+
private readonly sleep;
|
|
22
|
+
constructor(options: LemmaClientOptions);
|
|
23
|
+
/** Store a memory: claims + the evidence they're grounded in (see `collectEvidence`). */
|
|
24
|
+
remember(request: CreateMemoryRequest): Promise<CreateMemoryResponse>;
|
|
25
|
+
/** Search; every result comes back with a verified `state`, never a guess. */
|
|
26
|
+
recall(request: RecallRequest): Promise<RecallResponse>;
|
|
27
|
+
/** Batch-resolve freshness for known ids without a search round-trip. */
|
|
28
|
+
verify(request: VerifyRequest): Promise<VerifyResponse>;
|
|
29
|
+
/** Permanently forget a memory, scoped to your tenant. */
|
|
30
|
+
forget(id: string): Promise<ForgetResponse>;
|
|
31
|
+
/** Stateless secret-scrubbing pass over text or a serialized tool-call. */
|
|
32
|
+
scrub(request: ScrubRequest): Promise<ScrubResponse>;
|
|
33
|
+
/** Real, counted usage for your tenant — never an estimate. */
|
|
34
|
+
usage(): Promise<UsageResponse>;
|
|
35
|
+
/** Masked — never prints the raw key, including via `console.log`. */
|
|
36
|
+
toString(): string;
|
|
37
|
+
private request;
|
|
38
|
+
}
|
|
39
|
+
export default LemmaClient;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LemmaClient = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const DEFAULT_BASE_URL = 'https://api.lemma.dev/v2';
|
|
6
|
+
const DEFAULT_TIMEOUT_MS = 10000;
|
|
7
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
8
|
+
/** Cap for exponential backoff on transient (network/5xx) failures. */
|
|
9
|
+
const MAX_BACKOFF_MS = 8000;
|
|
10
|
+
function defaultSleep(ms) {
|
|
11
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
|
+
}
|
|
13
|
+
function isRetryableStatus(status) {
|
|
14
|
+
return status === 429 || status >= 500;
|
|
15
|
+
}
|
|
16
|
+
/** LemmaClient never logs or exposes the raw key past construction. */
|
|
17
|
+
function maskKey(key) {
|
|
18
|
+
if (key.length <= 12)
|
|
19
|
+
return '***';
|
|
20
|
+
return `${key.slice(0, 8)}...${key.slice(-4)}`;
|
|
21
|
+
}
|
|
22
|
+
class LemmaClient {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
if (!options.apiKey) {
|
|
25
|
+
throw new errors_1.LemmaSdkError({ code: 'invalid_request', message: 'apiKey is required' });
|
|
26
|
+
}
|
|
27
|
+
this.apiKey = options.apiKey;
|
|
28
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
29
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
30
|
+
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
31
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
32
|
+
this.sleep = options.sleep ?? defaultSleep;
|
|
33
|
+
}
|
|
34
|
+
/** Store a memory: claims + the evidence they're grounded in (see `collectEvidence`). */
|
|
35
|
+
async remember(request) {
|
|
36
|
+
return this.request('POST', '/memories', request);
|
|
37
|
+
}
|
|
38
|
+
/** Search; every result comes back with a verified `state`, never a guess. */
|
|
39
|
+
async recall(request) {
|
|
40
|
+
return this.request('POST', '/recall', request);
|
|
41
|
+
}
|
|
42
|
+
/** Batch-resolve freshness for known ids without a search round-trip. */
|
|
43
|
+
async verify(request) {
|
|
44
|
+
return this.request('POST', '/verify', request);
|
|
45
|
+
}
|
|
46
|
+
/** Permanently forget a memory, scoped to your tenant. */
|
|
47
|
+
async forget(id) {
|
|
48
|
+
return this.request('DELETE', `/memories/${encodeURIComponent(id)}`);
|
|
49
|
+
}
|
|
50
|
+
/** Stateless secret-scrubbing pass over text or a serialized tool-call. */
|
|
51
|
+
async scrub(request) {
|
|
52
|
+
return this.request('POST', '/scrub', request);
|
|
53
|
+
}
|
|
54
|
+
/** Real, counted usage for your tenant — never an estimate. */
|
|
55
|
+
async usage() {
|
|
56
|
+
return this.request('GET', '/usage');
|
|
57
|
+
}
|
|
58
|
+
/** Masked — never prints the raw key, including via `console.log`. */
|
|
59
|
+
toString() {
|
|
60
|
+
return `LemmaClient(baseUrl=${this.baseUrl}, apiKey=${maskKey(this.apiKey)})`;
|
|
61
|
+
}
|
|
62
|
+
/** Node's console.log/util.inspect path — masked for the same reason as toString(). */
|
|
63
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
64
|
+
return this.toString();
|
|
65
|
+
}
|
|
66
|
+
async request(method, path, body) {
|
|
67
|
+
let attempt = 0;
|
|
68
|
+
while (true) {
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
71
|
+
let res;
|
|
72
|
+
try {
|
|
73
|
+
res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
74
|
+
method,
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
},
|
|
79
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
80
|
+
signal: controller.signal,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
const isAbort = err instanceof Error && err.name === 'AbortError';
|
|
86
|
+
if (attempt < this.maxRetries) {
|
|
87
|
+
await this.sleep(backoffMs(attempt));
|
|
88
|
+
attempt++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
throw new errors_1.LemmaSdkError({
|
|
92
|
+
code: isAbort ? 'timeout' : 'network_error',
|
|
93
|
+
message: isAbort ? `request timed out after ${this.timeoutMs}ms` : `network error: ${err.message}`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
if (res.ok) {
|
|
98
|
+
return (await res.json());
|
|
99
|
+
}
|
|
100
|
+
const bodyJson = (await res.json().catch(() => null));
|
|
101
|
+
const apiError = bodyJson?.error;
|
|
102
|
+
if (isRetryableStatus(res.status) && attempt < this.maxRetries) {
|
|
103
|
+
const retryAfterHeader = res.headers.get('Retry-After');
|
|
104
|
+
const waitMs = retryAfterHeader ? Number(retryAfterHeader) * 1000 : backoffMs(attempt);
|
|
105
|
+
await this.sleep(Number.isFinite(waitMs) && waitMs > 0 ? waitMs : backoffMs(attempt));
|
|
106
|
+
attempt++;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
throw new errors_1.LemmaSdkError({
|
|
110
|
+
code: apiError?.code ?? 'internal',
|
|
111
|
+
message: apiError?.message ?? `request failed with status ${res.status}`,
|
|
112
|
+
status: res.status,
|
|
113
|
+
field: apiError?.field,
|
|
114
|
+
retryAfter: res.headers.get('Retry-After') ? Number(res.headers.get('Retry-After')) : undefined,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.LemmaClient = LemmaClient;
|
|
120
|
+
/** Exponential backoff (200ms, 400ms, 800ms, ...) capped at MAX_BACKOFF_MS. */
|
|
121
|
+
function backoffMs(attempt) {
|
|
122
|
+
return Math.min(200 * 2 ** attempt, MAX_BACKOFF_MS);
|
|
123
|
+
}
|
|
124
|
+
exports.default = LemmaClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LemmaErrorCode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Typed error thrown by every LemmaClient method. Carries the API's stable
|
|
4
|
+
* `code` so callers can branch on it instead of parsing `message`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class LemmaSdkError extends Error {
|
|
7
|
+
readonly code: LemmaErrorCode | 'network_error' | 'timeout';
|
|
8
|
+
readonly status?: number;
|
|
9
|
+
readonly field?: string;
|
|
10
|
+
/** Present on `rate_limited` — seconds the server asked the client to wait. */
|
|
11
|
+
readonly retryAfter?: number;
|
|
12
|
+
constructor(opts: {
|
|
13
|
+
code: LemmaErrorCode | 'network_error' | 'timeout';
|
|
14
|
+
message: string;
|
|
15
|
+
status?: number;
|
|
16
|
+
field?: string;
|
|
17
|
+
retryAfter?: number;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LemmaSdkError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Typed error thrown by every LemmaClient method. Carries the API's stable
|
|
6
|
+
* `code` so callers can branch on it instead of parsing `message`.
|
|
7
|
+
*/
|
|
8
|
+
class LemmaSdkError extends Error {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
super(opts.message);
|
|
11
|
+
this.name = 'LemmaSdkError';
|
|
12
|
+
this.code = opts.code;
|
|
13
|
+
this.status = opts.status;
|
|
14
|
+
this.field = opts.field;
|
|
15
|
+
this.retryAfter = opts.retryAfter;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.LemmaSdkError = LemmaSdkError;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Evidence } from './types';
|
|
2
|
+
/** sha256 of a whole file's utf8 content. `'MISSING'` if it can't be read. */
|
|
3
|
+
export declare function hashFile(rootDir: string, relPath: string): string;
|
|
4
|
+
/** Token-stream normalization: strips comments/whitespace, keeps semantics. */
|
|
5
|
+
export declare function normalizeForFreshness(source: string): string;
|
|
6
|
+
/** Raw + normalized sha256 pair for one symbol. `'MISSING'`/`'MISSING'` if unreadable or not found. */
|
|
7
|
+
export declare function hashSymbol(rootDir: string, relPath: string, symbolName: string): {
|
|
8
|
+
raw: string;
|
|
9
|
+
normalized: string;
|
|
10
|
+
};
|
|
11
|
+
export interface CollectEvidenceOptions {
|
|
12
|
+
/** Directory relative paths are resolved against. Defaults to `process.cwd()`. */
|
|
13
|
+
rootDir?: string;
|
|
14
|
+
/** Relative file paths to hash whole. */
|
|
15
|
+
files?: string[];
|
|
16
|
+
/** Symbols to hash (raw + normalized), one file per symbol. */
|
|
17
|
+
symbols?: Array<{
|
|
18
|
+
filePath: string;
|
|
19
|
+
symbolName: string;
|
|
20
|
+
}>;
|
|
21
|
+
branch?: string;
|
|
22
|
+
commit?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Builds an `Evidence` bundle the way a client is expected to: hash the files
|
|
26
|
+
* and symbols it's about to make claims about, right before sending them.
|
|
27
|
+
* Identical algorithm to the local MCP Brain's `LocalFsResolver` — see the
|
|
28
|
+
* module doc.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collectEvidence(options: CollectEvidenceOptions): Evidence;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.hashFile = hashFile;
|
|
40
|
+
exports.normalizeForFreshness = normalizeForFreshness;
|
|
41
|
+
exports.hashSymbol = hashSymbol;
|
|
42
|
+
exports.collectEvidence = collectEvidence;
|
|
43
|
+
/**
|
|
44
|
+
* Client-side evidence hashing.
|
|
45
|
+
*
|
|
46
|
+
* Ports the exact algorithm `LocalFsResolver` and `getSymbolSurgicalContext`
|
|
47
|
+
* use in the main repo (`src/subconscious/freshness/LocalFsResolver.ts`,
|
|
48
|
+
* `src/utils/SymbolSurgicalContext.ts`), so a memory stored via this SDK and
|
|
49
|
+
* one stored via the local MCP Brain hash identically. Kept honest by
|
|
50
|
+
* `tests/unit/lane-g-evidence.test.ts`, which imports both implementations on
|
|
51
|
+
* the same fixture file and asserts the hashes match byte for byte — this is
|
|
52
|
+
* not a claim taken on faith.
|
|
53
|
+
*
|
|
54
|
+
* A file that can't be read, or a symbol that can't be found, hashes to the
|
|
55
|
+
* literal string `'MISSING'` — same fail-loud convention as `LocalFsResolver`
|
|
56
|
+
* — rather than silently omitting the claim.
|
|
57
|
+
*/
|
|
58
|
+
const fs_1 = __importDefault(require("fs"));
|
|
59
|
+
const path_1 = __importDefault(require("path"));
|
|
60
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
61
|
+
const ts = __importStar(require("typescript"));
|
|
62
|
+
function sha256(content) {
|
|
63
|
+
return crypto_1.default.createHash('sha256').update(content, 'utf8').digest('hex');
|
|
64
|
+
}
|
|
65
|
+
function resolvePath(rootDir, relPath) {
|
|
66
|
+
return path_1.default.isAbsolute(relPath) ? relPath : path_1.default.resolve(rootDir, relPath);
|
|
67
|
+
}
|
|
68
|
+
/** sha256 of a whole file's utf8 content. `'MISSING'` if it can't be read. */
|
|
69
|
+
function hashFile(rootDir, relPath) {
|
|
70
|
+
const abs = resolvePath(rootDir, relPath);
|
|
71
|
+
try {
|
|
72
|
+
return sha256(fs_1.default.readFileSync(abs, 'utf8'));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return 'MISSING';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Same traversal `SymbolSurgicalContext.findSymbolNode` uses: a top-level
|
|
80
|
+
* function/class/interface/type-alias/enum declaration named `name`, or the
|
|
81
|
+
* variable statement declaring an identifier named `name`.
|
|
82
|
+
*/
|
|
83
|
+
function findSymbolNode(sourceFile, name) {
|
|
84
|
+
let targetNode = null;
|
|
85
|
+
function walk(node) {
|
|
86
|
+
if (targetNode)
|
|
87
|
+
return;
|
|
88
|
+
if (ts.isFunctionDeclaration(node) && node.name && node.name.text === name) {
|
|
89
|
+
targetNode = node;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (ts.isClassDeclaration(node) && node.name && node.name.text === name) {
|
|
93
|
+
targetNode = node;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (ts.isInterfaceDeclaration(node) && node.name && node.name.text === name) {
|
|
97
|
+
targetNode = node;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (ts.isTypeAliasDeclaration(node) && node.name && node.name.text === name) {
|
|
101
|
+
targetNode = node;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (ts.isEnumDeclaration(node) && node.name && node.name.text === name) {
|
|
105
|
+
targetNode = node;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (ts.isVariableStatement(node)) {
|
|
109
|
+
for (const decl of node.declarationList.declarations) {
|
|
110
|
+
if (ts.isIdentifier(decl.name) && decl.name.text === name) {
|
|
111
|
+
targetNode = node;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
ts.forEachChild(node, walk);
|
|
117
|
+
}
|
|
118
|
+
walk(sourceFile);
|
|
119
|
+
return targetNode;
|
|
120
|
+
}
|
|
121
|
+
/** Token-stream normalization: strips comments/whitespace, keeps semantics. */
|
|
122
|
+
function normalizeForFreshness(source) {
|
|
123
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, /* skipTrivia */ true, ts.LanguageVariant.Standard, source);
|
|
124
|
+
const tokens = [];
|
|
125
|
+
let kind = scanner.scan();
|
|
126
|
+
while (kind !== ts.SyntaxKind.EndOfFileToken) {
|
|
127
|
+
tokens.push(scanner.getTokenText());
|
|
128
|
+
kind = scanner.scan();
|
|
129
|
+
}
|
|
130
|
+
return tokens.join(' ');
|
|
131
|
+
}
|
|
132
|
+
/** Raw + normalized sha256 pair for one symbol. `'MISSING'`/`'MISSING'` if unreadable or not found. */
|
|
133
|
+
function hashSymbol(rootDir, relPath, symbolName) {
|
|
134
|
+
const abs = resolvePath(rootDir, relPath);
|
|
135
|
+
try {
|
|
136
|
+
const src = fs_1.default.readFileSync(abs, 'utf8');
|
|
137
|
+
const sf = ts.createSourceFile(abs, src, ts.ScriptTarget.Latest, true);
|
|
138
|
+
const node = findSymbolNode(sf, symbolName);
|
|
139
|
+
if (!node)
|
|
140
|
+
return { raw: 'MISSING', normalized: 'MISSING' };
|
|
141
|
+
const implementation = node.getText();
|
|
142
|
+
return { raw: sha256(implementation), normalized: sha256(normalizeForFreshness(implementation)) };
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return { raw: 'MISSING', normalized: 'MISSING' };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Builds an `Evidence` bundle the way a client is expected to: hash the files
|
|
150
|
+
* and symbols it's about to make claims about, right before sending them.
|
|
151
|
+
* Identical algorithm to the local MCP Brain's `LocalFsResolver` — see the
|
|
152
|
+
* module doc.
|
|
153
|
+
*/
|
|
154
|
+
function collectEvidence(options) {
|
|
155
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
156
|
+
const files = {};
|
|
157
|
+
const symbols = {};
|
|
158
|
+
const symbolsNormalized = {};
|
|
159
|
+
for (const relPath of options.files ?? []) {
|
|
160
|
+
files[relPath] = hashFile(rootDir, relPath);
|
|
161
|
+
}
|
|
162
|
+
for (const { filePath, symbolName } of options.symbols ?? []) {
|
|
163
|
+
const key = `${filePath}::${symbolName}`;
|
|
164
|
+
const { raw, normalized } = hashSymbol(rootDir, filePath, symbolName);
|
|
165
|
+
symbols[key] = raw;
|
|
166
|
+
symbolsNormalized[key] = normalized;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
files,
|
|
170
|
+
symbols,
|
|
171
|
+
symbolsNormalized,
|
|
172
|
+
...(options.branch ? { branch: options.branch } : {}),
|
|
173
|
+
...(options.commit ? { commit: options.commit } : {}),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.LemmaSdkError = exports.normalizeForFreshness = exports.hashSymbol = exports.hashFile = exports.collectEvidence = exports.LemmaClient = void 0;
|
|
18
|
+
var client_1 = require("./client");
|
|
19
|
+
Object.defineProperty(exports, "LemmaClient", { enumerable: true, get: function () { return client_1.LemmaClient; } });
|
|
20
|
+
var evidence_1 = require("./evidence");
|
|
21
|
+
Object.defineProperty(exports, "collectEvidence", { enumerable: true, get: function () { return evidence_1.collectEvidence; } });
|
|
22
|
+
Object.defineProperty(exports, "hashFile", { enumerable: true, get: function () { return evidence_1.hashFile; } });
|
|
23
|
+
Object.defineProperty(exports, "hashSymbol", { enumerable: true, get: function () { return evidence_1.hashSymbol; } });
|
|
24
|
+
Object.defineProperty(exports, "normalizeForFreshness", { enumerable: true, get: function () { return evidence_1.normalizeForFreshness; } });
|
|
25
|
+
var errors_1 = require("./errors");
|
|
26
|
+
Object.defineProperty(exports, "LemmaSdkError", { enumerable: true, get: function () { return errors_1.LemmaSdkError; } });
|
|
27
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the Lemma /v2 API.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `src/contracts/api-v2.types.ts` and `src/contracts/evidence.ts` in the
|
|
5
|
+
* main repo (the SDK is published standalone, so it can't import from `src/`
|
|
6
|
+
* directly — this file is the SDK's own copy of the same shapes). Kept in sync
|
|
7
|
+
* by `tests/unit/lane-g-evidence.test.ts`, which imports the real contract
|
|
8
|
+
* types from the main repo and structurally checks this file against them.
|
|
9
|
+
*/
|
|
10
|
+
/** Hash of a whole file: path (as the client refers to it) → sha256 hex. */
|
|
11
|
+
export type FileHashes = Record<string, string>;
|
|
12
|
+
/** Hash pair for one symbol: key is `<path>::<symbolName>`. */
|
|
13
|
+
export type SymbolHashes = Record<string, string>;
|
|
14
|
+
export interface Evidence {
|
|
15
|
+
files: FileHashes;
|
|
16
|
+
symbols: SymbolHashes;
|
|
17
|
+
/** Symbols hashed after stripping comments/whitespace (semantic diff). */
|
|
18
|
+
symbolsNormalized: SymbolHashes;
|
|
19
|
+
branch?: string;
|
|
20
|
+
commit?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Verifiability state of a memory or claim.
|
|
24
|
+
*
|
|
25
|
+
* fresh — every tracked path hashes identical to what was stored.
|
|
26
|
+
* stale — a tracked path hashed differently (staleFiles names which).
|
|
27
|
+
* unverified — the verifier cannot prove validity (no current evidence, or a
|
|
28
|
+
* tracked path was omitted). NEVER `fresh` by guess.
|
|
29
|
+
* contradicted — two stored claims about the same subject now diverge.
|
|
30
|
+
*/
|
|
31
|
+
export type MemoryState = 'fresh' | 'stale' | 'unverified' | 'contradicted';
|
|
32
|
+
export interface MemoryClaim {
|
|
33
|
+
id: string;
|
|
34
|
+
text: string;
|
|
35
|
+
fileHashes?: FileHashes;
|
|
36
|
+
symbolHashes?: SymbolHashes;
|
|
37
|
+
symbolNormalizedHashes?: SymbolHashes;
|
|
38
|
+
}
|
|
39
|
+
export interface VerifiedResult {
|
|
40
|
+
id: string;
|
|
41
|
+
state: MemoryState;
|
|
42
|
+
staleFiles?: string[];
|
|
43
|
+
cosmeticChanges?: string[];
|
|
44
|
+
memory?: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface CreateMemoryRequest {
|
|
47
|
+
claims: Array<{
|
|
48
|
+
text: string;
|
|
49
|
+
filePaths?: string[];
|
|
50
|
+
symbols?: Array<{
|
|
51
|
+
filePath: string;
|
|
52
|
+
symbolName: string;
|
|
53
|
+
}>;
|
|
54
|
+
}>;
|
|
55
|
+
evidence: Evidence;
|
|
56
|
+
derivedFrom?: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface CreateMemoryResponse {
|
|
59
|
+
id: string;
|
|
60
|
+
claims: MemoryClaim[];
|
|
61
|
+
}
|
|
62
|
+
export interface RecallRequest {
|
|
63
|
+
query: string;
|
|
64
|
+
currentEvidence?: Evidence;
|
|
65
|
+
limit?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface RecallResponse {
|
|
68
|
+
results: VerifiedResult[];
|
|
69
|
+
query: string;
|
|
70
|
+
}
|
|
71
|
+
export interface VerifyRequest {
|
|
72
|
+
ids: string[];
|
|
73
|
+
currentEvidence: Evidence;
|
|
74
|
+
}
|
|
75
|
+
export interface VerifyResponse {
|
|
76
|
+
results: VerifiedResult[];
|
|
77
|
+
}
|
|
78
|
+
export interface ForgetResponse {
|
|
79
|
+
forged: string[];
|
|
80
|
+
}
|
|
81
|
+
export interface ScrubFinding {
|
|
82
|
+
type: string;
|
|
83
|
+
offset: number;
|
|
84
|
+
length: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ScrubRequest {
|
|
87
|
+
text?: string;
|
|
88
|
+
toolCallJson?: string;
|
|
89
|
+
mode?: 'mask' | 'detect';
|
|
90
|
+
}
|
|
91
|
+
export interface ScrubResponse {
|
|
92
|
+
text?: string;
|
|
93
|
+
toolCallJson?: string;
|
|
94
|
+
findings: ScrubFinding[];
|
|
95
|
+
}
|
|
96
|
+
export interface UsageStat {
|
|
97
|
+
measurement: 'counted';
|
|
98
|
+
value: number;
|
|
99
|
+
}
|
|
100
|
+
export interface UsageResponse {
|
|
101
|
+
metrics: Record<string, UsageStat>;
|
|
102
|
+
excludedEvents: number;
|
|
103
|
+
}
|
|
104
|
+
export type LemmaErrorCode = 'unauthenticated' | 'invalid_request' | 'quota_exceeded' | 'not_found' | 'forbidden' | 'rate_limited' | 'not_implemented' | 'internal';
|
|
105
|
+
export interface LemmaApiErrorBody {
|
|
106
|
+
error: {
|
|
107
|
+
code: LemmaErrorCode;
|
|
108
|
+
status: number;
|
|
109
|
+
message: string;
|
|
110
|
+
field?: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wire types for the Lemma /v2 API.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `src/contracts/api-v2.types.ts` and `src/contracts/evidence.ts` in the
|
|
6
|
+
* main repo (the SDK is published standalone, so it can't import from `src/`
|
|
7
|
+
* directly — this file is the SDK's own copy of the same shapes). Kept in sync
|
|
8
|
+
* by `tests/unit/lane-g-evidence.test.ts`, which imports the real contract
|
|
9
|
+
* types from the main repo and structurally checks this file against them.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|