@defai.digital/ax-cli 4.4.7 → 4.4.11
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/bin/ax-cli +1 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -9
- package/dist/index.js.map +1 -1
- package/dist/setup.d.ts +27 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +591 -0
- package/dist/setup.js.map +1 -0
- package/package.json +43 -135
- package/LICENSE +0 -22
- package/README.md +0 -420
- package/config-defaults/messages.yaml +0 -75
- package/config-defaults/models.yaml +0 -57
- package/config-defaults/prompts.yaml +0 -948
- package/config-defaults/settings.yaml +0 -157
- package/dist/agent/agent-executor.d.ts +0 -61
- package/dist/agent/agent-executor.js +0 -194
- package/dist/agent/agent-executor.js.map +0 -1
- package/dist/agent/agent-router.d.ts +0 -68
- package/dist/agent/agent-router.js +0 -242
- package/dist/agent/agent-router.js.map +0 -1
- package/dist/agent/context-manager.d.ts +0 -122
- package/dist/agent/context-manager.js +0 -406
- package/dist/agent/context-manager.js.map +0 -1
- package/dist/agent/core/index.d.ts +0 -8
- package/dist/agent/core/index.js +0 -9
- package/dist/agent/core/index.js.map +0 -1
- package/dist/agent/core/types.d.ts +0 -92
- package/dist/agent/core/types.js +0 -11
- package/dist/agent/core/types.js.map +0 -1
- package/dist/agent/dependency-resolver.d.ts +0 -90
- package/dist/agent/dependency-resolver.js +0 -366
- package/dist/agent/dependency-resolver.js.map +0 -1
- package/dist/agent/execution/index.d.ts +0 -9
- package/dist/agent/execution/index.js +0 -9
- package/dist/agent/execution/index.js.map +0 -1
- package/dist/agent/execution/tool-executor.d.ts +0 -93
- package/dist/agent/execution/tool-executor.js +0 -552
- package/dist/agent/execution/tool-executor.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/index.js +0 -145
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/llm-agent.d.ts +0 -368
- package/dist/agent/llm-agent.js +0 -1931
- package/dist/agent/llm-agent.js.map +0 -1
- package/dist/agent/loop-detector.d.ts +0 -72
- package/dist/agent/loop-detector.js +0 -335
- package/dist/agent/loop-detector.js.map +0 -1
- package/dist/agent/parallel-tools.d.ts +0 -69
- package/dist/agent/parallel-tools.js +0 -188
- package/dist/agent/parallel-tools.js.map +0 -1
- package/dist/agent/planning/index.d.ts +0 -9
- package/dist/agent/planning/index.js +0 -9
- package/dist/agent/planning/index.js.map +0 -1
- package/dist/agent/planning/plan-executor.d.ts +0 -79
- package/dist/agent/planning/plan-executor.js +0 -240
- package/dist/agent/planning/plan-executor.js.map +0 -1
- package/dist/agent/progress-tracker.d.ts +0 -94
- package/dist/agent/progress-tracker.js +0 -225
- package/dist/agent/progress-tracker.js.map +0 -1
- package/dist/agent/specialized/analysis-agent.d.ts +0 -11
- package/dist/agent/specialized/analysis-agent.js +0 -24
- package/dist/agent/specialized/analysis-agent.js.map +0 -1
- package/dist/agent/specialized/debug-agent.d.ts +0 -11
- package/dist/agent/specialized/debug-agent.js +0 -46
- package/dist/agent/specialized/debug-agent.js.map +0 -1
- package/dist/agent/specialized/documentation-agent.d.ts +0 -11
- package/dist/agent/specialized/documentation-agent.js +0 -24
- package/dist/agent/specialized/documentation-agent.js.map +0 -1
- package/dist/agent/specialized/index.d.ts +0 -11
- package/dist/agent/specialized/index.js +0 -12
- package/dist/agent/specialized/index.js.map +0 -1
- package/dist/agent/specialized/performance-agent.d.ts +0 -11
- package/dist/agent/specialized/performance-agent.js +0 -24
- package/dist/agent/specialized/performance-agent.js.map +0 -1
- package/dist/agent/specialized/refactoring-agent.d.ts +0 -11
- package/dist/agent/specialized/refactoring-agent.js +0 -24
- package/dist/agent/specialized/refactoring-agent.js.map +0 -1
- package/dist/agent/specialized/testing-agent.d.ts +0 -11
- package/dist/agent/specialized/testing-agent.js +0 -24
- package/dist/agent/specialized/testing-agent.js.map +0 -1
- package/dist/agent/status-reporter.d.ts +0 -114
- package/dist/agent/status-reporter.js +0 -335
- package/dist/agent/status-reporter.js.map +0 -1
- package/dist/agent/streaming/index.d.ts +0 -9
- package/dist/agent/streaming/index.js +0 -9
- package/dist/agent/streaming/index.js.map +0 -1
- package/dist/agent/streaming/stream-handler.d.ts +0 -62
- package/dist/agent/streaming/stream-handler.js +0 -217
- package/dist/agent/streaming/stream-handler.js.map +0 -1
- package/dist/agent/subagent-orchestrator.d.ts +0 -166
- package/dist/agent/subagent-orchestrator.js +0 -487
- package/dist/agent/subagent-orchestrator.js.map +0 -1
- package/dist/agent/subagent-types.d.ts +0 -261
- package/dist/agent/subagent-types.js +0 -257
- package/dist/agent/subagent-types.js.map +0 -1
- package/dist/agent/subagent.d.ts +0 -116
- package/dist/agent/subagent.js +0 -507
- package/dist/agent/subagent.js.map +0 -1
- package/dist/checkpoint/index.d.ts +0 -9
- package/dist/checkpoint/index.js +0 -11
- package/dist/checkpoint/index.js.map +0 -1
- package/dist/checkpoint/manager.d.ts +0 -101
- package/dist/checkpoint/manager.js +0 -407
- package/dist/checkpoint/manager.js.map +0 -1
- package/dist/checkpoint/storage.d.ts +0 -39
- package/dist/checkpoint/storage.js +0 -350
- package/dist/checkpoint/storage.js.map +0 -1
- package/dist/checkpoint/types.d.ts +0 -111
- package/dist/checkpoint/types.js +0 -17
- package/dist/checkpoint/types.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -7
- package/dist/commands/cache.js +0 -284
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/custom-commands.d.ts +0 -77
- package/dist/commands/custom-commands.js +0 -251
- package/dist/commands/custom-commands.js.map +0 -1
- package/dist/commands/design.d.ts +0 -18
- package/dist/commands/design.js +0 -511
- package/dist/commands/design.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -6
- package/dist/commands/doctor.js +0 -773
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/frontend.d.ts +0 -9
- package/dist/commands/frontend.js +0 -645
- package/dist/commands/frontend.js.map +0 -1
- package/dist/commands/init/wizard.d.ts +0 -55
- package/dist/commands/init/wizard.js +0 -189
- package/dist/commands/init/wizard.js.map +0 -1
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -195
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp-migrate.d.ts +0 -9
- package/dist/commands/mcp-migrate.js +0 -175
- package/dist/commands/mcp-migrate.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -2
- package/dist/commands/mcp.js +0 -1292
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -6
- package/dist/commands/memory.js +0 -555
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/models.d.ts +0 -5
- package/dist/commands/models.js +0 -213
- package/dist/commands/models.js.map +0 -1
- package/dist/commands/plan.d.ts +0 -43
- package/dist/commands/plan.js +0 -362
- package/dist/commands/plan.js.map +0 -1
- package/dist/commands/rewind.d.ts +0 -19
- package/dist/commands/rewind.js +0 -221
- package/dist/commands/rewind.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -14
- package/dist/commands/setup.js +0 -733
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -437
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/templates.d.ts +0 -5
- package/dist/commands/templates.js +0 -245
- package/dist/commands/templates.js.map +0 -1
- package/dist/commands/update.d.ts +0 -49
- package/dist/commands/update.js +0 -366
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/usage.d.ts +0 -8
- package/dist/commands/usage.js +0 -264
- package/dist/commands/usage.js.map +0 -1
- package/dist/commands/vscode.d.ts +0 -7
- package/dist/commands/vscode.js +0 -419
- package/dist/commands/vscode.js.map +0 -1
- package/dist/constants.d.ts +0 -236
- package/dist/constants.js +0 -288
- package/dist/constants.js.map +0 -1
- package/dist/design/figma-alias.d.ts +0 -170
- package/dist/design/figma-alias.js +0 -577
- package/dist/design/figma-alias.js.map +0 -1
- package/dist/design/figma-audit.d.ts +0 -40
- package/dist/design/figma-audit.js +0 -383
- package/dist/design/figma-audit.js.map +0 -1
- package/dist/design/figma-client.d.ts +0 -131
- package/dist/design/figma-client.js +0 -369
- package/dist/design/figma-client.js.map +0 -1
- package/dist/design/figma-map.d.ts +0 -29
- package/dist/design/figma-map.js +0 -346
- package/dist/design/figma-map.js.map +0 -1
- package/dist/design/figma-tokens.d.ts +0 -73
- package/dist/design/figma-tokens.js +0 -448
- package/dist/design/figma-tokens.js.map +0 -1
- package/dist/design/index.d.ts +0 -13
- package/dist/design/index.js +0 -20
- package/dist/design/index.js.map +0 -1
- package/dist/design/types.d.ts +0 -98
- package/dist/design/types.js +0 -9
- package/dist/design/types.js.map +0 -1
- package/dist/hooks/hook-runner.d.ts +0 -142
- package/dist/hooks/hook-runner.js +0 -436
- package/dist/hooks/hook-runner.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/index.js +0 -10
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/manager.d.ts +0 -84
- package/dist/hooks/manager.js +0 -348
- package/dist/hooks/manager.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -134
- package/dist/hooks/types.js +0 -9
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/ipc/index.d.ts +0 -9
- package/dist/ipc/index.js +0 -10
- package/dist/ipc/index.js.map +0 -1
- package/dist/ipc/vscode-client.d.ts +0 -200
- package/dist/ipc/vscode-client.js +0 -495
- package/dist/ipc/vscode-client.js.map +0 -1
- package/dist/llm/client.d.ts +0 -205
- package/dist/llm/client.js +0 -735
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/tools.d.ts +0 -102
- package/dist/llm/tools.js +0 -275
- package/dist/llm/tools.js.map +0 -1
- package/dist/llm/types.d.ts +0 -428
- package/dist/llm/types.js +0 -194
- package/dist/llm/types.js.map +0 -1
- package/dist/mcp/automatosx-auto-discovery.d.ts +0 -66
- package/dist/mcp/automatosx-auto-discovery.js +0 -169
- package/dist/mcp/automatosx-auto-discovery.js.map +0 -1
- package/dist/mcp/automatosx-loader.d.ts +0 -99
- package/dist/mcp/automatosx-loader.js +0 -250
- package/dist/mcp/automatosx-loader.js.map +0 -1
- package/dist/mcp/cancellation.d.ts +0 -182
- package/dist/mcp/cancellation.js +0 -275
- package/dist/mcp/cancellation.js.map +0 -1
- package/dist/mcp/client-v2.d.ts +0 -500
- package/dist/mcp/client-v2.js +0 -1433
- package/dist/mcp/client-v2.js.map +0 -1
- package/dist/mcp/client.d.ts +0 -170
- package/dist/mcp/client.js +0 -232
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/config-detector.d.ts +0 -90
- package/dist/mcp/config-detector.js +0 -250
- package/dist/mcp/config-detector.js.map +0 -1
- package/dist/mcp/config-migrator.d.ts +0 -68
- package/dist/mcp/config-migrator.js +0 -291
- package/dist/mcp/config-migrator.js.map +0 -1
- package/dist/mcp/config.d.ts +0 -24
- package/dist/mcp/config.js +0 -273
- package/dist/mcp/config.js.map +0 -1
- package/dist/mcp/constants.d.ts +0 -66
- package/dist/mcp/constants.js +0 -85
- package/dist/mcp/constants.js.map +0 -1
- package/dist/mcp/content-length-transport.d.ts +0 -106
- package/dist/mcp/content-length-transport.js +0 -413
- package/dist/mcp/content-length-transport.js.map +0 -1
- package/dist/mcp/debug.d.ts +0 -211
- package/dist/mcp/debug.js +0 -404
- package/dist/mcp/debug.js.map +0 -1
- package/dist/mcp/error-formatter.d.ts +0 -40
- package/dist/mcp/error-formatter.js +0 -207
- package/dist/mcp/error-formatter.js.map +0 -1
- package/dist/mcp/error-remediation.d.ts +0 -45
- package/dist/mcp/error-remediation.js +0 -291
- package/dist/mcp/error-remediation.js.map +0 -1
- package/dist/mcp/health.d.ts +0 -120
- package/dist/mcp/health.js +0 -267
- package/dist/mcp/health.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -56
- package/dist/mcp/index.js +0 -89
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/invariants.d.ts +0 -141
- package/dist/mcp/invariants.js +0 -243
- package/dist/mcp/invariants.js.map +0 -1
- package/dist/mcp/mutex-safe.d.ts +0 -151
- package/dist/mcp/mutex-safe.js +0 -260
- package/dist/mcp/mutex-safe.js.map +0 -1
- package/dist/mcp/progress.d.ts +0 -155
- package/dist/mcp/progress.js +0 -252
- package/dist/mcp/progress.js.map +0 -1
- package/dist/mcp/prompts.d.ts +0 -68
- package/dist/mcp/prompts.js +0 -129
- package/dist/mcp/prompts.js.map +0 -1
- package/dist/mcp/provider-mcp-loader.d.ts +0 -130
- package/dist/mcp/provider-mcp-loader.js +0 -292
- package/dist/mcp/provider-mcp-loader.js.map +0 -1
- package/dist/mcp/reconnection.d.ts +0 -101
- package/dist/mcp/reconnection.js +0 -253
- package/dist/mcp/reconnection.js.map +0 -1
- package/dist/mcp/registry.d.ts +0 -75
- package/dist/mcp/registry.js +0 -276
- package/dist/mcp/registry.js.map +0 -1
- package/dist/mcp/resources.d.ts +0 -58
- package/dist/mcp/resources.js +0 -144
- package/dist/mcp/resources.js.map +0 -1
- package/dist/mcp/schema-validator.d.ts +0 -82
- package/dist/mcp/schema-validator.js +0 -161
- package/dist/mcp/schema-validator.js.map +0 -1
- package/dist/mcp/ssrf-protection.d.ts +0 -86
- package/dist/mcp/ssrf-protection.js +0 -311
- package/dist/mcp/ssrf-protection.js.map +0 -1
- package/dist/mcp/subscriptions.d.ts +0 -168
- package/dist/mcp/subscriptions.js +0 -248
- package/dist/mcp/subscriptions.js.map +0 -1
- package/dist/mcp/templates.d.ts +0 -52
- package/dist/mcp/templates.js +0 -627
- package/dist/mcp/templates.js.map +0 -1
- package/dist/mcp/transports.d.ts +0 -80
- package/dist/mcp/transports.js +0 -237
- package/dist/mcp/transports.js.map +0 -1
- package/dist/mcp/type-safety.d.ts +0 -225
- package/dist/mcp/type-safety.js +0 -237
- package/dist/mcp/type-safety.js.map +0 -1
- package/dist/mcp/validation.d.ts +0 -29
- package/dist/mcp/validation.js +0 -339
- package/dist/mcp/validation.js.map +0 -1
- package/dist/mcp/zai-detector.d.ts +0 -63
- package/dist/mcp/zai-detector.js +0 -193
- package/dist/mcp/zai-detector.js.map +0 -1
- package/dist/mcp/zai-templates.d.ts +0 -90
- package/dist/mcp/zai-templates.js +0 -157
- package/dist/mcp/zai-templates.js.map +0 -1
- package/dist/memory/context-generator.d.ts +0 -84
- package/dist/memory/context-generator.js +0 -546
- package/dist/memory/context-generator.js.map +0 -1
- package/dist/memory/context-injector.d.ts +0 -97
- package/dist/memory/context-injector.js +0 -159
- package/dist/memory/context-injector.js.map +0 -1
- package/dist/memory/context-store.d.ts +0 -103
- package/dist/memory/context-store.js +0 -264
- package/dist/memory/context-store.js.map +0 -1
- package/dist/memory/index.d.ts +0 -43
- package/dist/memory/index.js +0 -49
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/provider-context-store.d.ts +0 -127
- package/dist/memory/provider-context-store.js +0 -385
- package/dist/memory/provider-context-store.js.map +0 -1
- package/dist/memory/schemas.d.ts +0 -118
- package/dist/memory/schemas.js +0 -106
- package/dist/memory/schemas.js.map +0 -1
- package/dist/memory/stats-collector.d.ts +0 -73
- package/dist/memory/stats-collector.js +0 -170
- package/dist/memory/stats-collector.js.map +0 -1
- package/dist/memory/types.d.ts +0 -177
- package/dist/memory/types.js +0 -73
- package/dist/memory/types.js.map +0 -1
- package/dist/permissions/index.d.ts +0 -6
- package/dist/permissions/index.js +0 -7
- package/dist/permissions/index.js.map +0 -1
- package/dist/permissions/permission-manager.d.ts +0 -149
- package/dist/permissions/permission-manager.js +0 -410
- package/dist/permissions/permission-manager.js.map +0 -1
- package/dist/planner/dependency-resolver.d.ts +0 -72
- package/dist/planner/dependency-resolver.js +0 -272
- package/dist/planner/dependency-resolver.js.map +0 -1
- package/dist/planner/index.d.ts +0 -12
- package/dist/planner/index.js +0 -28
- package/dist/planner/index.js.map +0 -1
- package/dist/planner/plan-generator.d.ts +0 -74
- package/dist/planner/plan-generator.js +0 -244
- package/dist/planner/plan-generator.js.map +0 -1
- package/dist/planner/plan-storage.d.ts +0 -113
- package/dist/planner/plan-storage.js +0 -398
- package/dist/planner/plan-storage.js.map +0 -1
- package/dist/planner/prompts/planning-prompt.d.ts +0 -62
- package/dist/planner/prompts/planning-prompt.js +0 -414
- package/dist/planner/prompts/planning-prompt.js.map +0 -1
- package/dist/planner/task-planner.d.ts +0 -139
- package/dist/planner/task-planner.js +0 -532
- package/dist/planner/task-planner.js.map +0 -1
- package/dist/planner/token-estimator.d.ts +0 -63
- package/dist/planner/token-estimator.js +0 -295
- package/dist/planner/token-estimator.js.map +0 -1
- package/dist/planner/types.d.ts +0 -425
- package/dist/planner/types.js +0 -213
- package/dist/planner/types.js.map +0 -1
- package/dist/provider/config.d.ts +0 -227
- package/dist/provider/config.js +0 -430
- package/dist/provider/config.js.map +0 -1
- package/dist/schemas/api-schemas.d.ts +0 -45
- package/dist/schemas/api-schemas.js +0 -129
- package/dist/schemas/api-schemas.js.map +0 -1
- package/dist/schemas/confirmation-schemas.d.ts +0 -39
- package/dist/schemas/confirmation-schemas.js +0 -48
- package/dist/schemas/confirmation-schemas.js.map +0 -1
- package/dist/schemas/index-unified.d.ts +0 -12
- package/dist/schemas/index-unified.js +0 -17
- package/dist/schemas/index-unified.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -83
- package/dist/schemas/index.js +0 -139
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/settings-schemas.d.ts +0 -186
- package/dist/schemas/settings-schemas.js +0 -324
- package/dist/schemas/settings-schemas.js.map +0 -1
- package/dist/schemas/tool-schemas.d.ts +0 -127
- package/dist/schemas/tool-schemas.js +0 -84
- package/dist/schemas/tool-schemas.js.map +0 -1
- package/dist/schemas/yaml-schemas.d.ts +0 -231
- package/dist/schemas/yaml-schemas.js +0 -199
- package/dist/schemas/yaml-schemas.js.map +0 -1
- package/dist/sdk/errors.d.ts +0 -100
- package/dist/sdk/errors.js +0 -138
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -901
- package/dist/sdk/index.js +0 -1272
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/progress-reporter.d.ts +0 -123
- package/dist/sdk/progress-reporter.js +0 -220
- package/dist/sdk/progress-reporter.js.map +0 -1
- package/dist/sdk/testing.d.ts +0 -427
- package/dist/sdk/testing.js +0 -725
- package/dist/sdk/testing.js.map +0 -1
- package/dist/sdk/tool-registry.d.ts +0 -194
- package/dist/sdk/tool-registry.js +0 -326
- package/dist/sdk/tool-registry.js.map +0 -1
- package/dist/sdk/types.d.ts +0 -53
- package/dist/sdk/types.js +0 -8
- package/dist/sdk/types.js.map +0 -1
- package/dist/sdk/unified-logger.d.ts +0 -173
- package/dist/sdk/unified-logger.js +0 -327
- package/dist/sdk/unified-logger.js.map +0 -1
- package/dist/sdk/version.d.ts +0 -163
- package/dist/sdk/version.js +0 -205
- package/dist/sdk/version.js.map +0 -1
- package/dist/tools/ask-user.d.ts +0 -126
- package/dist/tools/ask-user.js +0 -290
- package/dist/tools/ask-user.js.map +0 -1
- package/dist/tools/ax-agent.d.ts +0 -71
- package/dist/tools/ax-agent.js +0 -283
- package/dist/tools/ax-agent.js.map +0 -1
- package/dist/tools/bash-output.d.ts +0 -25
- package/dist/tools/bash-output.js +0 -146
- package/dist/tools/bash-output.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -67
- package/dist/tools/bash.js +0 -522
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/confirmation-tool.d.ts +0 -16
- package/dist/tools/confirmation-tool.js +0 -76
- package/dist/tools/confirmation-tool.js.map +0 -1
- package/dist/tools/definitions/ask-user.d.ts +0 -8
- package/dist/tools/definitions/ask-user.js +0 -168
- package/dist/tools/definitions/ask-user.js.map +0 -1
- package/dist/tools/definitions/ax-agent.d.ts +0 -8
- package/dist/tools/definitions/ax-agent.js +0 -276
- package/dist/tools/definitions/ax-agent.js.map +0 -1
- package/dist/tools/definitions/bash-output.d.ts +0 -7
- package/dist/tools/definitions/bash-output.js +0 -78
- package/dist/tools/definitions/bash-output.js.map +0 -1
- package/dist/tools/definitions/bash.d.ts +0 -8
- package/dist/tools/definitions/bash.js +0 -152
- package/dist/tools/definitions/bash.js.map +0 -1
- package/dist/tools/definitions/create-file.d.ts +0 -7
- package/dist/tools/definitions/create-file.js +0 -129
- package/dist/tools/definitions/create-file.js.map +0 -1
- package/dist/tools/definitions/design.d.ts +0 -12
- package/dist/tools/definitions/design.js +0 -368
- package/dist/tools/definitions/design.js.map +0 -1
- package/dist/tools/definitions/index.d.ts +0 -49
- package/dist/tools/definitions/index.js +0 -87
- package/dist/tools/definitions/index.js.map +0 -1
- package/dist/tools/definitions/multi-edit.d.ts +0 -7
- package/dist/tools/definitions/multi-edit.js +0 -123
- package/dist/tools/definitions/multi-edit.js.map +0 -1
- package/dist/tools/definitions/search.d.ts +0 -7
- package/dist/tools/definitions/search.js +0 -159
- package/dist/tools/definitions/search.js.map +0 -1
- package/dist/tools/definitions/str-replace-editor.d.ts +0 -7
- package/dist/tools/definitions/str-replace-editor.js +0 -145
- package/dist/tools/definitions/str-replace-editor.js.map +0 -1
- package/dist/tools/definitions/todo.d.ts +0 -8
- package/dist/tools/definitions/todo.js +0 -261
- package/dist/tools/definitions/todo.js.map +0 -1
- package/dist/tools/definitions/view-file.d.ts +0 -7
- package/dist/tools/definitions/view-file.js +0 -111
- package/dist/tools/definitions/view-file.js.map +0 -1
- package/dist/tools/design-tool.d.ts +0 -68
- package/dist/tools/design-tool.js +0 -299
- package/dist/tools/design-tool.js.map +0 -1
- package/dist/tools/format-generators.d.ts +0 -62
- package/dist/tools/format-generators.js +0 -291
- package/dist/tools/format-generators.js.map +0 -1
- package/dist/tools/index.d.ts +0 -8
- package/dist/tools/index.js +0 -11
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/priority-registry.d.ts +0 -124
- package/dist/tools/priority-registry.js +0 -401
- package/dist/tools/priority-registry.js.map +0 -1
- package/dist/tools/priority.d.ts +0 -158
- package/dist/tools/priority.js +0 -350
- package/dist/tools/priority.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -146
- package/dist/tools/registry.js +0 -171
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/search.d.ts +0 -85
- package/dist/tools/search.js +0 -430
- package/dist/tools/search.js.map +0 -1
- package/dist/tools/text-editor.d.ts +0 -87
- package/dist/tools/text-editor.js +0 -1369
- package/dist/tools/text-editor.js.map +0 -1
- package/dist/tools/todo-tool.d.ts +0 -20
- package/dist/tools/todo-tool.js +0 -186
- package/dist/tools/todo-tool.js.map +0 -1
- package/dist/tools/types.d.ts +0 -175
- package/dist/tools/types.js +0 -11
- package/dist/tools/types.js.map +0 -1
- package/dist/types/index.d.ts +0 -30
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/project-analysis.d.ts +0 -84
- package/dist/types/project-analysis.js +0 -5
- package/dist/types/project-analysis.js.map +0 -1
- package/dist/types/template.d.ts +0 -53
- package/dist/types/template.js +0 -5
- package/dist/types/template.js.map +0 -1
- package/dist/ui/app.d.ts +0 -7
- package/dist/ui/app.js +0 -102
- package/dist/ui/app.js.map +0 -1
- package/dist/ui/components/api-key-input.d.ts +0 -7
- package/dist/ui/components/api-key-input.js +0 -92
- package/dist/ui/components/api-key-input.js.map +0 -1
- package/dist/ui/components/chat-history.d.ts +0 -12
- package/dist/ui/components/chat-history.js +0 -391
- package/dist/ui/components/chat-history.js.map +0 -1
- package/dist/ui/components/chat-input.d.ts +0 -13
- package/dist/ui/components/chat-input.js +0 -179
- package/dist/ui/components/chat-input.js.map +0 -1
- package/dist/ui/components/chat-interface.d.ts +0 -11
- package/dist/ui/components/chat-interface.js +0 -830
- package/dist/ui/components/chat-interface.js.map +0 -1
- package/dist/ui/components/collapsible-tool-result.d.ts +0 -42
- package/dist/ui/components/collapsible-tool-result.js +0 -216
- package/dist/ui/components/collapsible-tool-result.js.map +0 -1
- package/dist/ui/components/command-suggestions.d.ts +0 -29
- package/dist/ui/components/command-suggestions.js +0 -88
- package/dist/ui/components/command-suggestions.js.map +0 -1
- package/dist/ui/components/confirmation-dialog.d.ts +0 -11
- package/dist/ui/components/confirmation-dialog.js +0 -100
- package/dist/ui/components/confirmation-dialog.js.map +0 -1
- package/dist/ui/components/context-breakdown.d.ts +0 -23
- package/dist/ui/components/context-breakdown.js +0 -124
- package/dist/ui/components/context-breakdown.js.map +0 -1
- package/dist/ui/components/diff-renderer.d.ts +0 -13
- package/dist/ui/components/diff-renderer.js +0 -192
- package/dist/ui/components/diff-renderer.js.map +0 -1
- package/dist/ui/components/index.d.ts +0 -18
- package/dist/ui/components/index.js +0 -20
- package/dist/ui/components/index.js.map +0 -1
- package/dist/ui/components/keyboard-help.d.ts +0 -17
- package/dist/ui/components/keyboard-help.js +0 -122
- package/dist/ui/components/keyboard-help.js.map +0 -1
- package/dist/ui/components/keyboard-hints.d.ts +0 -35
- package/dist/ui/components/keyboard-hints.js +0 -142
- package/dist/ui/components/keyboard-hints.js.map +0 -1
- package/dist/ui/components/loading-spinner.d.ts +0 -9
- package/dist/ui/components/loading-spinner.js +0 -120
- package/dist/ui/components/loading-spinner.js.map +0 -1
- package/dist/ui/components/mcp-dashboard.d.ts +0 -15
- package/dist/ui/components/mcp-dashboard.js +0 -520
- package/dist/ui/components/mcp-dashboard.js.map +0 -1
- package/dist/ui/components/mcp-status.d.ts +0 -5
- package/dist/ui/components/mcp-status.js +0 -58
- package/dist/ui/components/mcp-status.js.map +0 -1
- package/dist/ui/components/model-selection.d.ts +0 -12
- package/dist/ui/components/model-selection.js +0 -17
- package/dist/ui/components/model-selection.js.map +0 -1
- package/dist/ui/components/phase-progress.d.ts +0 -21
- package/dist/ui/components/phase-progress.js +0 -185
- package/dist/ui/components/phase-progress.js.map +0 -1
- package/dist/ui/components/question-dialog.d.ts +0 -17
- package/dist/ui/components/question-dialog.js +0 -181
- package/dist/ui/components/question-dialog.js.map +0 -1
- package/dist/ui/components/quick-actions.d.ts +0 -12
- package/dist/ui/components/quick-actions.js +0 -171
- package/dist/ui/components/quick-actions.js.map +0 -1
- package/dist/ui/components/reasoning-display.d.ts +0 -36
- package/dist/ui/components/reasoning-display.js +0 -46
- package/dist/ui/components/reasoning-display.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -47
- package/dist/ui/components/status-bar.js +0 -310
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/components/subagent-monitor.d.ts +0 -41
- package/dist/ui/components/subagent-monitor.js +0 -122
- package/dist/ui/components/subagent-monitor.js.map +0 -1
- package/dist/ui/components/toast-notification.d.ts +0 -197
- package/dist/ui/components/toast-notification.js +0 -190
- package/dist/ui/components/toast-notification.js.map +0 -1
- package/dist/ui/components/tool-group-display.d.ts +0 -19
- package/dist/ui/components/tool-group-display.js +0 -222
- package/dist/ui/components/tool-group-display.js.map +0 -1
- package/dist/ui/components/virtualized-chat-history.d.ts +0 -33
- package/dist/ui/components/virtualized-chat-history.js +0 -182
- package/dist/ui/components/virtualized-chat-history.js.map +0 -1
- package/dist/ui/components/welcome-panel.d.ts +0 -11
- package/dist/ui/components/welcome-panel.js +0 -225
- package/dist/ui/components/welcome-panel.js.map +0 -1
- package/dist/ui/hooks/use-chat-reducer.d.ts +0 -69
- package/dist/ui/hooks/use-chat-reducer.js +0 -118
- package/dist/ui/hooks/use-chat-reducer.js.map +0 -1
- package/dist/ui/hooks/use-enhanced-input.d.ts +0 -53
- package/dist/ui/hooks/use-enhanced-input.js +0 -1275
- package/dist/ui/hooks/use-enhanced-input.js.map +0 -1
- package/dist/ui/hooks/use-input-handler.d.ts +0 -79
- package/dist/ui/hooks/use-input-handler.js +0 -2251
- package/dist/ui/hooks/use-input-handler.js.map +0 -1
- package/dist/ui/hooks/use-input-history.d.ts +0 -9
- package/dist/ui/hooks/use-input-history.js +0 -168
- package/dist/ui/hooks/use-input-history.js.map +0 -1
- package/dist/ui/shared/max-sized-box.d.ts +0 -17
- package/dist/ui/shared/max-sized-box.js +0 -14
- package/dist/ui/shared/max-sized-box.js.map +0 -1
- package/dist/ui/themes/index.d.ts +0 -5
- package/dist/ui/themes/index.js +0 -5
- package/dist/ui/themes/index.js.map +0 -1
- package/dist/ui/themes/theme-registry.d.ts +0 -55
- package/dist/ui/themes/theme-registry.js +0 -202
- package/dist/ui/themes/theme-registry.js.map +0 -1
- package/dist/ui/utils/bracketed-paste-handler.d.ts +0 -97
- package/dist/ui/utils/bracketed-paste-handler.js +0 -322
- package/dist/ui/utils/bracketed-paste-handler.js.map +0 -1
- package/dist/ui/utils/change-summarizer.d.ts +0 -20
- package/dist/ui/utils/change-summarizer.js +0 -282
- package/dist/ui/utils/change-summarizer.js.map +0 -1
- package/dist/ui/utils/code-colorizer.d.ts +0 -9
- package/dist/ui/utils/code-colorizer.js +0 -13
- package/dist/ui/utils/code-colorizer.js.map +0 -1
- package/dist/ui/utils/colors.d.ts +0 -41
- package/dist/ui/utils/colors.js +0 -80
- package/dist/ui/utils/colors.js.map +0 -1
- package/dist/ui/utils/image-handler.d.ts +0 -29
- package/dist/ui/utils/image-handler.js +0 -129
- package/dist/ui/utils/image-handler.js.map +0 -1
- package/dist/ui/utils/markdown-renderer.d.ts +0 -4
- package/dist/ui/utils/markdown-renderer.js +0 -40
- package/dist/ui/utils/markdown-renderer.js.map +0 -1
- package/dist/ui/utils/semantic-action-detector.d.ts +0 -49
- package/dist/ui/utils/semantic-action-detector.js +0 -339
- package/dist/ui/utils/semantic-action-detector.js.map +0 -1
- package/dist/ui/utils/tool-grouper.d.ts +0 -94
- package/dist/ui/utils/tool-grouper.js +0 -618
- package/dist/ui/utils/tool-grouper.js.map +0 -1
- package/dist/utils/api-error.d.ts +0 -61
- package/dist/utils/api-error.js +0 -176
- package/dist/utils/api-error.js.map +0 -1
- package/dist/utils/audit-logger.d.ts +0 -206
- package/dist/utils/audit-logger.js +0 -286
- package/dist/utils/audit-logger.js.map +0 -1
- package/dist/utils/auto-accept-logger.d.ts +0 -175
- package/dist/utils/auto-accept-logger.js +0 -423
- package/dist/utils/auto-accept-logger.js.map +0 -1
- package/dist/utils/automatosx-detector.d.ts +0 -19
- package/dist/utils/automatosx-detector.js +0 -52
- package/dist/utils/automatosx-detector.js.map +0 -1
- package/dist/utils/background-task-manager.d.ts +0 -114
- package/dist/utils/background-task-manager.js +0 -470
- package/dist/utils/background-task-manager.js.map +0 -1
- package/dist/utils/cache.d.ts +0 -77
- package/dist/utils/cache.js +0 -180
- package/dist/utils/cache.js.map +0 -1
- package/dist/utils/command-security.d.ts +0 -85
- package/dist/utils/command-security.js +0 -210
- package/dist/utils/command-security.js.map +0 -1
- package/dist/utils/config-loader.d.ts +0 -190
- package/dist/utils/config-loader.js +0 -108
- package/dist/utils/config-loader.js.map +0 -1
- package/dist/utils/confirmation-service.d.ts +0 -51
- package/dist/utils/confirmation-service.js +0 -220
- package/dist/utils/confirmation-service.js.map +0 -1
- package/dist/utils/console-messenger.d.ts +0 -80
- package/dist/utils/console-messenger.js +0 -142
- package/dist/utils/console-messenger.js.map +0 -1
- package/dist/utils/custom-instructions.d.ts +0 -1
- package/dist/utils/custom-instructions.js +0 -24
- package/dist/utils/custom-instructions.js.map +0 -1
- package/dist/utils/encryption.d.ts +0 -86
- package/dist/utils/encryption.js +0 -236
- package/dist/utils/encryption.js.map +0 -1
- package/dist/utils/enhanced-error-messages.d.ts +0 -33
- package/dist/utils/enhanced-error-messages.js +0 -440
- package/dist/utils/enhanced-error-messages.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -65
- package/dist/utils/error-handler.js +0 -148
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/error-translator.d.ts +0 -25
- package/dist/utils/error-translator.js +0 -203
- package/dist/utils/error-translator.js.map +0 -1
- package/dist/utils/external-editor.d.ts +0 -47
- package/dist/utils/external-editor.js +0 -179
- package/dist/utils/external-editor.js.map +0 -1
- package/dist/utils/file-cache.d.ts +0 -148
- package/dist/utils/file-cache.js +0 -413
- package/dist/utils/file-cache.js.map +0 -1
- package/dist/utils/file-lock.d.ts +0 -141
- package/dist/utils/file-lock.js +0 -554
- package/dist/utils/file-lock.js.map +0 -1
- package/dist/utils/file-mentions.d.ts +0 -68
- package/dist/utils/file-mentions.js +0 -225
- package/dist/utils/file-mentions.js.map +0 -1
- package/dist/utils/history-manager.d.ts +0 -52
- package/dist/utils/history-manager.js +0 -211
- package/dist/utils/history-manager.js.map +0 -1
- package/dist/utils/history-migration.d.ts +0 -9
- package/dist/utils/history-migration.js +0 -37
- package/dist/utils/history-migration.js.map +0 -1
- package/dist/utils/image-processor.d.ts +0 -33
- package/dist/utils/image-processor.js +0 -124
- package/dist/utils/image-processor.js.map +0 -1
- package/dist/utils/index.d.ts +0 -92
- package/dist/utils/index.js +0 -111
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/init-previewer.d.ts +0 -56
- package/dist/utils/init-previewer.js +0 -239
- package/dist/utils/init-previewer.js.map +0 -1
- package/dist/utils/init-validator.d.ts +0 -65
- package/dist/utils/init-validator.js +0 -252
- package/dist/utils/init-validator.js.map +0 -1
- package/dist/utils/input-sanitizer.d.ts +0 -210
- package/dist/utils/input-sanitizer.js +0 -362
- package/dist/utils/input-sanitizer.js.map +0 -1
- package/dist/utils/instruction-generator.d.ts +0 -21
- package/dist/utils/instruction-generator.js +0 -233
- package/dist/utils/instruction-generator.js.map +0 -1
- package/dist/utils/json-utils.d.ts +0 -72
- package/dist/utils/json-utils.js +0 -226
- package/dist/utils/json-utils.js.map +0 -1
- package/dist/utils/llm-optimized-instruction-generator.d.ts +0 -36
- package/dist/utils/llm-optimized-instruction-generator.js +0 -365
- package/dist/utils/llm-optimized-instruction-generator.js.map +0 -1
- package/dist/utils/message-optimizer.d.ts +0 -100
- package/dist/utils/message-optimizer.js +0 -297
- package/dist/utils/message-optimizer.js.map +0 -1
- package/dist/utils/onboarding-manager.d.ts +0 -45
- package/dist/utils/onboarding-manager.js +0 -131
- package/dist/utils/onboarding-manager.js.map +0 -1
- package/dist/utils/parallel-analyzer.d.ts +0 -123
- package/dist/utils/parallel-analyzer.js +0 -241
- package/dist/utils/parallel-analyzer.js.map +0 -1
- package/dist/utils/paste-utils.d.ts +0 -99
- package/dist/utils/paste-utils.js +0 -295
- package/dist/utils/paste-utils.js.map +0 -1
- package/dist/utils/path-helpers.d.ts +0 -8
- package/dist/utils/path-helpers.js +0 -35
- package/dist/utils/path-helpers.js.map +0 -1
- package/dist/utils/path-security.d.ts +0 -92
- package/dist/utils/path-security.js +0 -300
- package/dist/utils/path-security.js.map +0 -1
- package/dist/utils/path-utils.d.ts +0 -83
- package/dist/utils/path-utils.js +0 -122
- package/dist/utils/path-utils.js.map +0 -1
- package/dist/utils/path-validator.d.ts +0 -66
- package/dist/utils/path-validator.js +0 -141
- package/dist/utils/path-validator.js.map +0 -1
- package/dist/utils/performance.d.ts +0 -74
- package/dist/utils/performance.js +0 -133
- package/dist/utils/performance.js.map +0 -1
- package/dist/utils/process-pool.d.ts +0 -109
- package/dist/utils/process-pool.js +0 -332
- package/dist/utils/process-pool.js.map +0 -1
- package/dist/utils/progress-tracker.d.ts +0 -51
- package/dist/utils/progress-tracker.js +0 -152
- package/dist/utils/progress-tracker.js.map +0 -1
- package/dist/utils/project-analyzer.d.ts +0 -49
- package/dist/utils/project-analyzer.js +0 -396
- package/dist/utils/project-analyzer.js.map +0 -1
- package/dist/utils/prompt-builder.d.ts +0 -14
- package/dist/utils/prompt-builder.js +0 -100
- package/dist/utils/prompt-builder.js.map +0 -1
- package/dist/utils/provider-context.d.ts +0 -243
- package/dist/utils/provider-context.js +0 -421
- package/dist/utils/provider-context.js.map +0 -1
- package/dist/utils/provider-file-cache.d.ts +0 -91
- package/dist/utils/provider-file-cache.js +0 -165
- package/dist/utils/provider-file-cache.js.map +0 -1
- package/dist/utils/provider-settings.d.ts +0 -181
- package/dist/utils/provider-settings.js +0 -450
- package/dist/utils/provider-settings.js.map +0 -1
- package/dist/utils/rate-limiter.d.ts +0 -222
- package/dist/utils/rate-limiter.js +0 -338
- package/dist/utils/rate-limiter.js.map +0 -1
- package/dist/utils/retry-helper.d.ts +0 -81
- package/dist/utils/retry-helper.js +0 -244
- package/dist/utils/retry-helper.js.map +0 -1
- package/dist/utils/safety-rules.d.ts +0 -64
- package/dist/utils/safety-rules.js +0 -225
- package/dist/utils/safety-rules.js.map +0 -1
- package/dist/utils/settings-manager.d.ts +0 -256
- package/dist/utils/settings-manager.js +0 -967
- package/dist/utils/settings-manager.js.map +0 -1
- package/dist/utils/setup-validator.d.ts +0 -47
- package/dist/utils/setup-validator.js +0 -304
- package/dist/utils/setup-validator.js.map +0 -1
- package/dist/utils/string-utils.d.ts +0 -19
- package/dist/utils/string-utils.js +0 -28
- package/dist/utils/string-utils.js.map +0 -1
- package/dist/utils/template-manager.d.ts +0 -62
- package/dist/utils/template-manager.js +0 -366
- package/dist/utils/template-manager.js.map +0 -1
- package/dist/utils/text-utils.d.ts +0 -82
- package/dist/utils/text-utils.js +0 -203
- package/dist/utils/text-utils.js.map +0 -1
- package/dist/utils/token-counter.d.ts +0 -76
- package/dist/utils/token-counter.js +0 -231
- package/dist/utils/token-counter.js.map +0 -1
- package/dist/utils/usage-tracker.d.ts +0 -78
- package/dist/utils/usage-tracker.js +0 -126
- package/dist/utils/usage-tracker.js.map +0 -1
- package/dist/utils/version.d.ts +0 -14
- package/dist/utils/version.js +0 -70
- package/dist/utils/version.js.map +0 -1
package/dist/sdk/testing.js
DELETED
|
@@ -1,725 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Testing utilities for AX CLI SDK
|
|
3
|
-
*
|
|
4
|
-
* This module provides mock implementations and test helpers to make
|
|
5
|
-
* it easy to test code that uses the AX CLI SDK.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
import { EventEmitter } from 'events';
|
|
10
|
-
/**
|
|
11
|
-
* Mock agent for testing
|
|
12
|
-
*
|
|
13
|
-
* Implements the same interface as LLMAgent but with predictable,
|
|
14
|
-
* controllable behavior for testing.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { MockAgent } from '@defai.digital/ax-cli/sdk/testing';
|
|
19
|
-
*
|
|
20
|
-
* test('my integration', async () => {
|
|
21
|
-
* const agent = new MockAgent({
|
|
22
|
-
* responses: ['First response', 'Second response']
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* const result = await agent.processUserMessage('Hello');
|
|
26
|
-
* expect(result[0].content).toBe('First response');
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export class MockAgent extends EventEmitter {
|
|
31
|
-
responses;
|
|
32
|
-
currentResponseIndex = 0;
|
|
33
|
-
history = [];
|
|
34
|
-
disposed = false;
|
|
35
|
-
/**
|
|
36
|
-
* Create a new mock agent
|
|
37
|
-
*
|
|
38
|
-
* @param options - Configuration for mock behavior
|
|
39
|
-
*/
|
|
40
|
-
constructor(options = {}) {
|
|
41
|
-
super();
|
|
42
|
-
// BUG FIX: Clone responses array to prevent external mutation
|
|
43
|
-
// Without this, the caller could modify the responses array after construction
|
|
44
|
-
// and unexpectedly change the mock's behavior during tests
|
|
45
|
-
this.responses = options.responses ? [...options.responses] : ['Mock response'];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Process a user message (mock implementation)
|
|
49
|
-
*
|
|
50
|
-
* Returns the next predefined response and adds it to history.
|
|
51
|
-
* Cycles through responses if called more times than responses available.
|
|
52
|
-
*
|
|
53
|
-
* @param message - User message (stored in history)
|
|
54
|
-
* @returns Mock chat history
|
|
55
|
-
*/
|
|
56
|
-
async processUserMessage(message) {
|
|
57
|
-
this.checkDisposed();
|
|
58
|
-
// Add user message to history
|
|
59
|
-
const userEntry = {
|
|
60
|
-
type: 'user',
|
|
61
|
-
content: message,
|
|
62
|
-
timestamp: new Date(),
|
|
63
|
-
};
|
|
64
|
-
this.history.push(userEntry);
|
|
65
|
-
// Get next response (cycle through)
|
|
66
|
-
// Guard against empty responses array to prevent modulo-by-zero
|
|
67
|
-
const response = this.responses.length > 0
|
|
68
|
-
? this.responses[this.currentResponseIndex % this.responses.length]
|
|
69
|
-
: 'No response configured';
|
|
70
|
-
this.currentResponseIndex++;
|
|
71
|
-
// Add assistant response to history
|
|
72
|
-
const assistantEntry = {
|
|
73
|
-
type: 'assistant',
|
|
74
|
-
content: response,
|
|
75
|
-
timestamp: new Date(),
|
|
76
|
-
};
|
|
77
|
-
this.history.push(assistantEntry);
|
|
78
|
-
// Emit stream event for compatibility
|
|
79
|
-
this.emit('stream', {
|
|
80
|
-
type: 'content',
|
|
81
|
-
content: response,
|
|
82
|
-
});
|
|
83
|
-
this.emit('stream', {
|
|
84
|
-
type: 'done',
|
|
85
|
-
});
|
|
86
|
-
// BUG FIX: Return deep copies to prevent external mutation of internal history
|
|
87
|
-
// Without this, callers could modify the returned entries and corrupt
|
|
88
|
-
// the mock agent's internal chat history
|
|
89
|
-
return this.history.map(entry => ({
|
|
90
|
-
...entry,
|
|
91
|
-
timestamp: new Date(entry.timestamp.getTime()),
|
|
92
|
-
}));
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Process user message with streaming (mock implementation)
|
|
96
|
-
*
|
|
97
|
-
* Yields mock stream chunks for the response.
|
|
98
|
-
*/
|
|
99
|
-
async *processUserMessageStream(message) {
|
|
100
|
-
this.checkDisposed();
|
|
101
|
-
// Add user message to history
|
|
102
|
-
const userEntry = {
|
|
103
|
-
type: 'user',
|
|
104
|
-
content: message,
|
|
105
|
-
timestamp: new Date(),
|
|
106
|
-
};
|
|
107
|
-
this.history.push(userEntry);
|
|
108
|
-
// Get next response
|
|
109
|
-
// Guard against empty responses array to prevent modulo-by-zero
|
|
110
|
-
const response = this.responses.length > 0
|
|
111
|
-
? this.responses[this.currentResponseIndex % this.responses.length]
|
|
112
|
-
: 'No response configured';
|
|
113
|
-
this.currentResponseIndex++;
|
|
114
|
-
// Stream the response character by character (for realistic testing)
|
|
115
|
-
const words = response.split(' ');
|
|
116
|
-
for (const word of words) {
|
|
117
|
-
yield {
|
|
118
|
-
type: 'content',
|
|
119
|
-
content: word + ' ',
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
// Add assistant response to history
|
|
123
|
-
const assistantEntry = {
|
|
124
|
-
type: 'assistant',
|
|
125
|
-
content: response,
|
|
126
|
-
timestamp: new Date(),
|
|
127
|
-
};
|
|
128
|
-
this.history.push(assistantEntry);
|
|
129
|
-
yield {
|
|
130
|
-
type: 'done',
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Get chat history (mock implementation)
|
|
135
|
-
*
|
|
136
|
-
* Returns deep copies of chat entries to prevent external mutation.
|
|
137
|
-
*/
|
|
138
|
-
getChatHistory() {
|
|
139
|
-
this.checkDisposed();
|
|
140
|
-
// BUG FIX: Return deep copies to prevent external mutation of internal history
|
|
141
|
-
// Without this, callers could modify the returned entries and corrupt
|
|
142
|
-
// the mock agent's internal chat history (e.g., change timestamps, content)
|
|
143
|
-
return this.history.map(entry => ({
|
|
144
|
-
...entry,
|
|
145
|
-
// Clone Date objects to prevent mutation
|
|
146
|
-
timestamp: new Date(entry.timestamp.getTime()),
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Execute bash command (mock implementation)
|
|
151
|
-
*
|
|
152
|
-
* Always returns success with predefined output.
|
|
153
|
-
*/
|
|
154
|
-
async executeBashCommand(command) {
|
|
155
|
-
this.checkDisposed();
|
|
156
|
-
return {
|
|
157
|
-
success: true,
|
|
158
|
-
output: `Mock output for command: ${command}`,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get current directory (mock implementation)
|
|
163
|
-
*/
|
|
164
|
-
getCurrentDirectory() {
|
|
165
|
-
this.checkDisposed();
|
|
166
|
-
return '/mock/directory';
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Create checkpoint (mock implementation)
|
|
170
|
-
*/
|
|
171
|
-
async createCheckpoint(_description) {
|
|
172
|
-
this.checkDisposed();
|
|
173
|
-
return `mock-checkpoint-${Date.now()}`;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Rewind conversation (mock implementation)
|
|
177
|
-
*/
|
|
178
|
-
async rewindConversation(_checkpointId) {
|
|
179
|
-
this.checkDisposed();
|
|
180
|
-
this.history = [];
|
|
181
|
-
return { success: true };
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Check if bash is executing (mock implementation)
|
|
185
|
-
*/
|
|
186
|
-
isBashExecuting() {
|
|
187
|
-
this.checkDisposed();
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Dispose of mock agent
|
|
192
|
-
* Note: Returns void to match LLMAgent.dispose() signature
|
|
193
|
-
*/
|
|
194
|
-
dispose() {
|
|
195
|
-
if (this.disposed)
|
|
196
|
-
return;
|
|
197
|
-
this.disposed = true;
|
|
198
|
-
this.removeAllListeners();
|
|
199
|
-
this.history = [];
|
|
200
|
-
this.responses = [];
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Reset mock agent state
|
|
204
|
-
*
|
|
205
|
-
* Clears history and resets response index.
|
|
206
|
-
* Useful for reusing the same mock across multiple tests.
|
|
207
|
-
*/
|
|
208
|
-
reset() {
|
|
209
|
-
this.checkDisposed();
|
|
210
|
-
this.history = [];
|
|
211
|
-
this.currentResponseIndex = 0;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Set new responses
|
|
215
|
-
*
|
|
216
|
-
* @param responses - New responses to use (must have at least one response)
|
|
217
|
-
* @throws Error if responses array is empty
|
|
218
|
-
*/
|
|
219
|
-
setResponses(responses) {
|
|
220
|
-
this.checkDisposed();
|
|
221
|
-
if (!responses || responses.length === 0) {
|
|
222
|
-
throw new Error('MockAgent.setResponses: responses array must not be empty');
|
|
223
|
-
}
|
|
224
|
-
// BUG FIX: Clone responses array to prevent external mutation
|
|
225
|
-
// Without this, the caller could modify the responses array after setting
|
|
226
|
-
// and unexpectedly change the mock's behavior during tests
|
|
227
|
-
this.responses = [...responses];
|
|
228
|
-
this.currentResponseIndex = 0;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Get number of messages processed
|
|
232
|
-
*/
|
|
233
|
-
getMessageCount() {
|
|
234
|
-
this.checkDisposed();
|
|
235
|
-
return this.history.filter(entry => entry.type === 'user').length;
|
|
236
|
-
}
|
|
237
|
-
checkDisposed() {
|
|
238
|
-
if (this.disposed) {
|
|
239
|
-
throw new Error('MockAgent has been disposed and cannot be used');
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Clean up resources and remove all event listeners.
|
|
244
|
-
*/
|
|
245
|
-
destroy() {
|
|
246
|
-
this.removeAllListeners();
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Create a mock agent with predefined responses
|
|
251
|
-
*
|
|
252
|
-
* Convenience function for creating mock agents.
|
|
253
|
-
*
|
|
254
|
-
* @param responses - Predefined responses (optional)
|
|
255
|
-
* @returns Mock agent instance
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```typescript
|
|
259
|
-
* import { createMockAgent } from '@defai.digital/ax-cli/sdk/testing';
|
|
260
|
-
*
|
|
261
|
-
* const agent = createMockAgent(['Hello!', 'How can I help?']);
|
|
262
|
-
* const result = await agent.processUserMessage('Hi');
|
|
263
|
-
* expect(result[0].content).toBe('Hello!');
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
export function createMockAgent(responses) {
|
|
267
|
-
return new MockAgent({ responses });
|
|
268
|
-
}
|
|
269
|
-
export class MockSettingsManager {
|
|
270
|
-
settings;
|
|
271
|
-
constructor(settings = {}) {
|
|
272
|
-
// BUG FIX: Clone settings to prevent external mutation
|
|
273
|
-
// Without this, the caller could modify the settings object after construction
|
|
274
|
-
// and unexpectedly change the mock's behavior during tests
|
|
275
|
-
this.settings = { ...settings };
|
|
276
|
-
}
|
|
277
|
-
loadUserSettings() {
|
|
278
|
-
// No-op for mock
|
|
279
|
-
}
|
|
280
|
-
loadProjectSettings() {
|
|
281
|
-
// No-op for mock
|
|
282
|
-
}
|
|
283
|
-
getApiKey() {
|
|
284
|
-
return this.settings.apiKey;
|
|
285
|
-
}
|
|
286
|
-
getBaseURL() {
|
|
287
|
-
return this.settings.baseURL;
|
|
288
|
-
}
|
|
289
|
-
getCurrentModel() {
|
|
290
|
-
return this.settings.model;
|
|
291
|
-
}
|
|
292
|
-
updateUserSetting(key, value) {
|
|
293
|
-
this.settings[key] = value;
|
|
294
|
-
}
|
|
295
|
-
saveUserSettings() {
|
|
296
|
-
// No-op for mock
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Create a mock settings manager
|
|
301
|
-
*
|
|
302
|
-
* @param settings - Settings to return
|
|
303
|
-
* @returns Mock settings manager
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* ```typescript
|
|
307
|
-
* import { createMockSettings } from '@defai.digital/ax-cli/sdk/testing';
|
|
308
|
-
*
|
|
309
|
-
* const settings = createMockSettings({
|
|
310
|
-
* apiKey: 'test-key',
|
|
311
|
-
* model: 'glm-4.6'
|
|
312
|
-
* });
|
|
313
|
-
* ```
|
|
314
|
-
*/
|
|
315
|
-
export function createMockSettings(settings) {
|
|
316
|
-
return new MockSettingsManager(settings);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Mock MCP Server for Testing
|
|
320
|
-
*
|
|
321
|
-
* Simplified MCP server that can be used in tests without needing
|
|
322
|
-
* real MCP server infrastructure.
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* ```typescript
|
|
326
|
-
* import { createMockMCPServer } from '@defai.digital/ax-cli/sdk/testing';
|
|
327
|
-
*
|
|
328
|
-
* const mockServer = createMockMCPServer({
|
|
329
|
-
* name: 'test-server',
|
|
330
|
-
* tools: [{
|
|
331
|
-
* name: 'test_tool',
|
|
332
|
-
* description: 'A test tool',
|
|
333
|
-
* inputSchema: {
|
|
334
|
-
* type: 'object',
|
|
335
|
-
* properties: { input: { type: 'string' } },
|
|
336
|
-
* required: ['input']
|
|
337
|
-
* },
|
|
338
|
-
* handler: async (args) => ({ result: `Processed: ${args.input}` })
|
|
339
|
-
* }]
|
|
340
|
-
* });
|
|
341
|
-
*
|
|
342
|
-
* await mockServer.connect();
|
|
343
|
-
* const tools = await mockServer.listTools();
|
|
344
|
-
* const result = await mockServer.callTool('test_tool', { input: 'test' });
|
|
345
|
-
* ```
|
|
346
|
-
*/
|
|
347
|
-
export class MockMCPServer {
|
|
348
|
-
options;
|
|
349
|
-
connected = false;
|
|
350
|
-
constructor(options) {
|
|
351
|
-
// BUG FIX: Deep clone options to prevent external mutation
|
|
352
|
-
// Without this, external code could modify the options after construction
|
|
353
|
-
// (e.g., modify tools array, change handlers) and unexpectedly affect
|
|
354
|
-
// the mock server's behavior during tests
|
|
355
|
-
this.options = {
|
|
356
|
-
name: options.name,
|
|
357
|
-
version: options.version,
|
|
358
|
-
// Clone arrays to prevent external mutation, but keep handler references
|
|
359
|
-
// (handlers are functions and cannot be cloned)
|
|
360
|
-
tools: options.tools ? options.tools.map(t => ({
|
|
361
|
-
name: t.name,
|
|
362
|
-
description: t.description,
|
|
363
|
-
inputSchema: JSON.parse(JSON.stringify(t.inputSchema)),
|
|
364
|
-
handler: t.handler,
|
|
365
|
-
})) : undefined,
|
|
366
|
-
resources: options.resources ? options.resources.map(r => ({
|
|
367
|
-
uri: r.uri,
|
|
368
|
-
name: r.name,
|
|
369
|
-
mimeType: r.mimeType,
|
|
370
|
-
handler: r.handler,
|
|
371
|
-
})) : undefined,
|
|
372
|
-
prompts: options.prompts ? options.prompts.map(p => ({
|
|
373
|
-
name: p.name,
|
|
374
|
-
description: p.description,
|
|
375
|
-
handler: p.handler,
|
|
376
|
-
})) : undefined,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Connect the mock server
|
|
381
|
-
*/
|
|
382
|
-
async connect() {
|
|
383
|
-
this.connected = true;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Disconnect the mock server
|
|
387
|
-
*/
|
|
388
|
-
async disconnect() {
|
|
389
|
-
this.connected = false;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* List available tools
|
|
393
|
-
*
|
|
394
|
-
* Returns deep copies of tool definitions to prevent external mutation.
|
|
395
|
-
*/
|
|
396
|
-
async listTools() {
|
|
397
|
-
if (!this.connected) {
|
|
398
|
-
throw new Error('Server not connected');
|
|
399
|
-
}
|
|
400
|
-
// BUG FIX: Deep clone inputSchema to prevent external mutation of internal state
|
|
401
|
-
// Without this, callers could modify the returned schema and corrupt
|
|
402
|
-
// the mock server's tool definitions
|
|
403
|
-
return (this.options.tools || []).map(tool => ({
|
|
404
|
-
name: tool.name,
|
|
405
|
-
description: tool.description,
|
|
406
|
-
inputSchema: JSON.parse(JSON.stringify(tool.inputSchema))
|
|
407
|
-
}));
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Call a tool on the mock server
|
|
411
|
-
*
|
|
412
|
-
* @param name - Tool name to call
|
|
413
|
-
* @param args - Arguments to pass to the tool
|
|
414
|
-
* @throws Error if server not connected, tool not found, or handler throws
|
|
415
|
-
*/
|
|
416
|
-
async callTool(name, args) {
|
|
417
|
-
if (!this.connected) {
|
|
418
|
-
throw new Error('Server not connected');
|
|
419
|
-
}
|
|
420
|
-
const tool = this.options.tools?.find(t => t.name === name);
|
|
421
|
-
if (!tool) {
|
|
422
|
-
throw new Error(`Tool not found: ${name}`);
|
|
423
|
-
}
|
|
424
|
-
try {
|
|
425
|
-
// BUG FIX: Clone args before passing to handler to prevent mutation
|
|
426
|
-
// Without this, the handler could modify the caller's args object
|
|
427
|
-
const clonedArgs = args !== null && args !== undefined
|
|
428
|
-
? JSON.parse(JSON.stringify(args))
|
|
429
|
-
: args;
|
|
430
|
-
return await tool.handler(clonedArgs);
|
|
431
|
-
}
|
|
432
|
-
catch (error) {
|
|
433
|
-
// Wrap handler errors with context
|
|
434
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
435
|
-
throw new Error(`Tool '${name}' execution failed: ${message}`);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* List available resources
|
|
440
|
-
*/
|
|
441
|
-
async listResources() {
|
|
442
|
-
if (!this.connected) {
|
|
443
|
-
throw new Error('Server not connected');
|
|
444
|
-
}
|
|
445
|
-
return (this.options.resources || []).map(resource => ({
|
|
446
|
-
uri: resource.uri,
|
|
447
|
-
name: resource.name,
|
|
448
|
-
mimeType: resource.mimeType
|
|
449
|
-
}));
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Read a resource from the mock server
|
|
453
|
-
*
|
|
454
|
-
* @param uri - Resource URI to read
|
|
455
|
-
* @throws Error if server not connected, resource not found, or handler throws
|
|
456
|
-
*/
|
|
457
|
-
async readResource(uri) {
|
|
458
|
-
if (!this.connected) {
|
|
459
|
-
throw new Error('Server not connected');
|
|
460
|
-
}
|
|
461
|
-
const resource = this.options.resources?.find(r => r.uri === uri);
|
|
462
|
-
if (!resource) {
|
|
463
|
-
throw new Error(`Resource not found: ${uri}`);
|
|
464
|
-
}
|
|
465
|
-
try {
|
|
466
|
-
return await resource.handler();
|
|
467
|
-
}
|
|
468
|
-
catch (error) {
|
|
469
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
470
|
-
throw new Error(`Resource '${uri}' read failed: ${message}`);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* List available prompts
|
|
475
|
-
*/
|
|
476
|
-
async listPrompts() {
|
|
477
|
-
if (!this.connected) {
|
|
478
|
-
throw new Error('Server not connected');
|
|
479
|
-
}
|
|
480
|
-
return (this.options.prompts || []).map(prompt => ({
|
|
481
|
-
name: prompt.name,
|
|
482
|
-
description: prompt.description
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Execute a prompt
|
|
487
|
-
*
|
|
488
|
-
* @param name - Prompt name to execute
|
|
489
|
-
* @param args - Optional arguments for the prompt
|
|
490
|
-
* @throws Error if server not connected, prompt not found, or handler throws
|
|
491
|
-
*/
|
|
492
|
-
async executePrompt(name, args) {
|
|
493
|
-
if (!this.connected) {
|
|
494
|
-
throw new Error('Server not connected');
|
|
495
|
-
}
|
|
496
|
-
const prompt = this.options.prompts?.find(p => p.name === name);
|
|
497
|
-
if (!prompt) {
|
|
498
|
-
throw new Error(`Prompt not found: ${name}`);
|
|
499
|
-
}
|
|
500
|
-
try {
|
|
501
|
-
// BUG FIX: Clone args before passing to handler to prevent mutation
|
|
502
|
-
// Without this, the handler could modify the caller's args object
|
|
503
|
-
const clonedArgs = args !== null && args !== undefined
|
|
504
|
-
? JSON.parse(JSON.stringify(args))
|
|
505
|
-
: args;
|
|
506
|
-
return await prompt.handler(clonedArgs);
|
|
507
|
-
}
|
|
508
|
-
catch (error) {
|
|
509
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
510
|
-
throw new Error(`Prompt '${name}' execution failed: ${message}`);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Check if server is connected
|
|
515
|
-
*/
|
|
516
|
-
isConnected() {
|
|
517
|
-
return this.connected;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Get server info
|
|
521
|
-
*/
|
|
522
|
-
getInfo() {
|
|
523
|
-
return {
|
|
524
|
-
name: this.options.name,
|
|
525
|
-
version: this.options.version || '1.0.0',
|
|
526
|
-
toolCount: this.options.tools?.length || 0,
|
|
527
|
-
resourceCount: this.options.resources?.length || 0,
|
|
528
|
-
promptCount: this.options.prompts?.length || 0
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Create a mock MCP server for testing
|
|
534
|
-
*
|
|
535
|
-
* @example
|
|
536
|
-
* ```typescript
|
|
537
|
-
* const mockServer = createMockMCPServer({
|
|
538
|
-
* name: 'test-server',
|
|
539
|
-
* tools: [{
|
|
540
|
-
* name: 'test_tool',
|
|
541
|
-
* description: 'A test tool',
|
|
542
|
-
* inputSchema: {
|
|
543
|
-
* type: 'object',
|
|
544
|
-
* properties: { input: { type: 'string' } },
|
|
545
|
-
* required: ['input']
|
|
546
|
-
* },
|
|
547
|
-
* handler: async (args) => ({ result: `Processed: ${args.input}` })
|
|
548
|
-
* }]
|
|
549
|
-
* });
|
|
550
|
-
*
|
|
551
|
-
* await mockServer.connect();
|
|
552
|
-
* const tools = await mockServer.listTools();
|
|
553
|
-
* const result = await mockServer.callTool('test_tool', { input: 'test' });
|
|
554
|
-
* ```
|
|
555
|
-
*/
|
|
556
|
-
export function createMockMCPServer(options) {
|
|
557
|
-
return new MockMCPServer(options);
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Wait for agent to complete processing
|
|
561
|
-
*
|
|
562
|
-
* Useful in tests when you need to wait for async operations to complete.
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```typescript
|
|
566
|
-
* const agent = await createAgent();
|
|
567
|
-
*
|
|
568
|
-
* agent.processUserMessage('Hello');
|
|
569
|
-
*
|
|
570
|
-
* // Wait for agent to finish
|
|
571
|
-
* await waitForAgent(agent, { timeout: 5000 });
|
|
572
|
-
*
|
|
573
|
-
* // Now agent is idle
|
|
574
|
-
* ```
|
|
575
|
-
*/
|
|
576
|
-
export async function waitForAgent(agent, options) {
|
|
577
|
-
return new Promise((resolve, reject) => {
|
|
578
|
-
const timeout = options?.timeout || 5000;
|
|
579
|
-
let resolved = false;
|
|
580
|
-
let completionTimer;
|
|
581
|
-
let streamListener;
|
|
582
|
-
let errorListener;
|
|
583
|
-
const cleanup = () => {
|
|
584
|
-
// BUG FIX: Always clean up both timers and event listeners to prevent memory leaks
|
|
585
|
-
if (completionTimer !== undefined) {
|
|
586
|
-
clearTimeout(completionTimer);
|
|
587
|
-
completionTimer = undefined;
|
|
588
|
-
}
|
|
589
|
-
// Remove stream listener if it was added
|
|
590
|
-
if (streamListener && agent && typeof agent.off === 'function') {
|
|
591
|
-
agent.off('stream', streamListener);
|
|
592
|
-
streamListener = undefined;
|
|
593
|
-
}
|
|
594
|
-
// BUG FIX: Remove error listener if it was added
|
|
595
|
-
if (errorListener && agent && typeof agent.off === 'function') {
|
|
596
|
-
agent.off('error', errorListener);
|
|
597
|
-
errorListener = undefined;
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
const timer = setTimeout(() => {
|
|
601
|
-
if (!resolved) {
|
|
602
|
-
resolved = true;
|
|
603
|
-
cleanup();
|
|
604
|
-
reject(new Error(`Agent did not complete within ${timeout}ms`));
|
|
605
|
-
}
|
|
606
|
-
}, timeout);
|
|
607
|
-
// Track if we've received any stream events
|
|
608
|
-
let hasReceivedStreamEvent = false;
|
|
609
|
-
// BUG FIX: Listen for 'done' stream event instead of arbitrary delay
|
|
610
|
-
// This properly waits for the agent to complete rather than using a fixed timeout
|
|
611
|
-
if (agent && typeof agent.on === 'function') {
|
|
612
|
-
streamListener = (chunk) => {
|
|
613
|
-
hasReceivedStreamEvent = true;
|
|
614
|
-
if (chunk && chunk.type === 'done' && !resolved) {
|
|
615
|
-
resolved = true;
|
|
616
|
-
clearTimeout(timer);
|
|
617
|
-
cleanup();
|
|
618
|
-
resolve();
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
agent.on('stream', streamListener);
|
|
622
|
-
// BUG FIX: Listen for error events so waitForAgent rejects with the actual error
|
|
623
|
-
// Without this, agent errors would be silently ignored and waitForAgent would
|
|
624
|
-
// either timeout or resolve via fallback, hiding the real failure
|
|
625
|
-
errorListener = (error) => {
|
|
626
|
-
if (!resolved) {
|
|
627
|
-
resolved = true;
|
|
628
|
-
clearTimeout(timer);
|
|
629
|
-
cleanup();
|
|
630
|
-
reject(error);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
agent.on('error', errorListener);
|
|
634
|
-
}
|
|
635
|
-
// BUG FIX: Fallback only applies when NO stream events received
|
|
636
|
-
// The previous 100ms fallback would race with real 'done' events, causing
|
|
637
|
-
// false positives where waitForAgent returns while agent is still processing.
|
|
638
|
-
// Now we only use fallback for agents that don't emit stream events at all.
|
|
639
|
-
completionTimer = setTimeout(() => {
|
|
640
|
-
if (!resolved && !hasReceivedStreamEvent) {
|
|
641
|
-
// No stream events received - agent doesn't use streaming
|
|
642
|
-
resolved = true;
|
|
643
|
-
clearTimeout(timer);
|
|
644
|
-
cleanup();
|
|
645
|
-
resolve();
|
|
646
|
-
}
|
|
647
|
-
// If we received stream events but no 'done', let the main timeout handle it
|
|
648
|
-
}, 100);
|
|
649
|
-
// Allow process to exit if these are the only timers
|
|
650
|
-
timer.unref?.();
|
|
651
|
-
completionTimer.unref?.();
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Create a mock tool result
|
|
656
|
-
*
|
|
657
|
-
* @param success - Whether the tool execution succeeded
|
|
658
|
-
* @param output - Output message (typically for success cases)
|
|
659
|
-
* @param error - Error message (typically for failure cases)
|
|
660
|
-
* @param data - Additional structured data from the tool
|
|
661
|
-
* @returns ToolResult matching the full interface
|
|
662
|
-
*
|
|
663
|
-
* @example
|
|
664
|
-
* ```typescript
|
|
665
|
-
* // Success result
|
|
666
|
-
* const result = createMockToolResult(true, 'File created');
|
|
667
|
-
*
|
|
668
|
-
* // Failure result
|
|
669
|
-
* const result = createMockToolResult(false, undefined, 'Permission denied');
|
|
670
|
-
*
|
|
671
|
-
* // With data
|
|
672
|
-
* const result = createMockToolResult(true, 'Found 5 files', undefined, { files: ['a.ts', 'b.ts'] });
|
|
673
|
-
* ```
|
|
674
|
-
*/
|
|
675
|
-
export function createMockToolResult(success, output, error, data) {
|
|
676
|
-
return {
|
|
677
|
-
success,
|
|
678
|
-
output,
|
|
679
|
-
error,
|
|
680
|
-
data
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Assert tool result is successful
|
|
685
|
-
*
|
|
686
|
-
* Note: This only asserts `success: true`. The `output` field may still be undefined
|
|
687
|
-
* even for successful tool results (some tools don't produce output).
|
|
688
|
-
*
|
|
689
|
-
* @example
|
|
690
|
-
* ```typescript
|
|
691
|
-
* const result = await tool.execute();
|
|
692
|
-
* assertToolSuccess(result);
|
|
693
|
-
* // result.success is now true
|
|
694
|
-
* // result.output may still be undefined
|
|
695
|
-
* if (result.output) {
|
|
696
|
-
* console.log(result.output);
|
|
697
|
-
* }
|
|
698
|
-
* ```
|
|
699
|
-
*/
|
|
700
|
-
export function assertToolSuccess(result) {
|
|
701
|
-
if (!result.success) {
|
|
702
|
-
throw new Error(`Tool execution failed: ${result.error || 'Unknown error'}`);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* Assert tool result is a failure
|
|
707
|
-
*
|
|
708
|
-
* Note: This only asserts `success: false`. The `error` field may still be undefined
|
|
709
|
-
* even for failed tool results (some tools don't provide error messages).
|
|
710
|
-
*
|
|
711
|
-
* @example
|
|
712
|
-
* ```typescript
|
|
713
|
-
* const result = await tool.execute();
|
|
714
|
-
* assertToolFailure(result);
|
|
715
|
-
* // result.success is now false
|
|
716
|
-
* // result.error may still be undefined
|
|
717
|
-
* console.log(result.error ?? 'Unknown error');
|
|
718
|
-
* ```
|
|
719
|
-
*/
|
|
720
|
-
export function assertToolFailure(result) {
|
|
721
|
-
if (result.success) {
|
|
722
|
-
throw new Error('Expected tool to fail, but it succeeded');
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
//# sourceMappingURL=testing.js.map
|