@robota-sdk/agent-core 3.0.0-beta.9 → 3.0.0-beta.90
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/CHANGELOG.md +1083 -0
- package/LICENSE +661 -21
- package/README.md +261 -50
- package/dist/browser/bounded-output-BdWv9SX3.js +2 -0
- package/dist/browser/bounded-output-BdWv9SX3.js.map +1 -0
- package/dist/browser/command-executor-DIXaSMrr.js +2 -0
- package/dist/browser/command-executor-DIXaSMrr.js.map +1 -0
- package/dist/browser/http-executor-B4YgCJg7.js +2 -0
- package/dist/browser/http-executor-B4YgCJg7.js.map +1 -0
- package/dist/browser/index.d.ts +6834 -3348
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +14 -5
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/verdict-decoder-Dz_rjoIZ.js +2 -0
- package/dist/browser/verdict-decoder-Dz_rjoIZ.js.map +1 -0
- package/dist/node/bounded-output-BdWv9SX3.js +2 -0
- package/dist/node/bounded-output-BdWv9SX3.js.map +1 -0
- package/dist/node/command-executor-D_UBZHxh.js +2 -0
- package/dist/node/command-executor-D_UBZHxh.js.map +1 -0
- package/dist/node/command-executor-wBgBdWXr.cjs +1 -0
- package/dist/node/http-executor-ADn4locH.js +2 -0
- package/dist/node/http-executor-ADn4locH.js.map +1 -0
- package/dist/node/http-executor-CeAAZotH.cjs +1 -0
- package/dist/node/index-CagopdzH.d.cts +7393 -0
- package/dist/node/index-CagopdzH.d.cts.map +1 -0
- package/dist/node/index-CjyNzgQN.d.ts +7393 -0
- package/dist/node/index-CjyNzgQN.d.ts.map +1 -0
- package/dist/node/index.cjs +13 -5
- package/dist/node/index.d.cts +3 -4238
- package/dist/node/index.d.ts +3 -4238
- package/dist/node/index.js +14 -5
- package/dist/node/index.js.map +1 -0
- package/dist/node/node.cjs +1 -0
- package/dist/node/node.d.cts +247 -0
- package/dist/node/node.d.cts.map +1 -0
- package/dist/node/node.d.ts +247 -0
- package/dist/node/node.d.ts.map +1 -0
- package/dist/node/node.js +2 -0
- package/dist/node/node.js.map +1 -0
- package/dist/node/project-tool-schema-DrDjGKnH.cjs +1 -0
- package/dist/node/project-tool-schema-_UKfY7yO.js +2 -0
- package/dist/node/project-tool-schema-_UKfY7yO.js.map +1 -0
- package/dist/node/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/node/rolldown-runtime-DWNI8pZO.cjs +1 -0
- package/dist/node/testing/index.cjs +1 -0
- package/dist/node/testing/index.d.cts +96 -0
- package/dist/node/testing/index.d.cts.map +1 -0
- package/dist/node/testing/index.d.ts +96 -0
- package/dist/node/testing/index.d.ts.map +1 -0
- package/dist/node/testing/index.js +2 -0
- package/dist/node/testing/index.js.map +1 -0
- package/dist/node/types-Ge2XB-y-.d.cts +334 -0
- package/dist/node/types-Ge2XB-y-.d.cts.map +1 -0
- package/dist/node/types-Ge2XB-y-.d.ts +334 -0
- package/dist/node/types-Ge2XB-y-.d.ts.map +1 -0
- package/dist/node/verdict-decoder-DQqwwDE7.cjs +1 -0
- package/dist/node/verdict-decoder-Dz_rjoIZ.js +2 -0
- package/dist/node/verdict-decoder-Dz_rjoIZ.js.map +1 -0
- package/package.json +103 -33
- package/dist/abstracts/abstract-agent.d.ts +0 -56
- package/dist/abstracts/abstract-agent.d.ts.map +0 -1
- package/dist/abstracts/abstract-agent.js +0 -55
- package/dist/abstracts/abstract-agent.js.map +0 -1
- package/dist/abstracts/abstract-ai-provider.d.ts +0 -187
- package/dist/abstracts/abstract-ai-provider.d.ts.map +0 -1
- package/dist/abstracts/abstract-ai-provider.js +0 -252
- package/dist/abstracts/abstract-ai-provider.js.map +0 -1
- package/dist/abstracts/abstract-executor.d.ts +0 -110
- package/dist/abstracts/abstract-executor.d.ts.map +0 -1
- package/dist/abstracts/abstract-executor.js +0 -156
- package/dist/abstracts/abstract-executor.js.map +0 -1
- package/dist/abstracts/abstract-manager.d.ts +0 -42
- package/dist/abstracts/abstract-manager.d.ts.map +0 -1
- package/dist/abstracts/abstract-manager.js +0 -49
- package/dist/abstracts/abstract-manager.js.map +0 -1
- package/dist/abstracts/abstract-module.d.ts +0 -365
- package/dist/abstracts/abstract-module.d.ts.map +0 -1
- package/dist/abstracts/abstract-module.js +0 -474
- package/dist/abstracts/abstract-module.js.map +0 -1
- package/dist/abstracts/abstract-plugin.d.ts +0 -369
- package/dist/abstracts/abstract-plugin.d.ts.map +0 -1
- package/dist/abstracts/abstract-plugin.js +0 -258
- package/dist/abstracts/abstract-plugin.js.map +0 -1
- package/dist/abstracts/abstract-tool.d.ts +0 -175
- package/dist/abstracts/abstract-tool.d.ts.map +0 -1
- package/dist/abstracts/abstract-tool.js +0 -140
- package/dist/abstracts/abstract-tool.js.map +0 -1
- package/dist/abstracts/abstract-workflow-converter.d.ts +0 -136
- package/dist/abstracts/abstract-workflow-converter.d.ts.map +0 -1
- package/dist/abstracts/abstract-workflow-converter.js +0 -252
- package/dist/abstracts/abstract-workflow-converter.js.map +0 -1
- package/dist/abstracts/abstract-workflow-validator.d.ts +0 -203
- package/dist/abstracts/abstract-workflow-validator.d.ts.map +0 -1
- package/dist/abstracts/abstract-workflow-validator.js +0 -447
- package/dist/abstracts/abstract-workflow-validator.js.map +0 -1
- package/dist/abstracts/index.d.ts +0 -6
- package/dist/abstracts/index.d.ts.map +0 -1
- package/dist/abstracts/index.js +0 -9
- package/dist/abstracts/index.js.map +0 -1
- package/dist/agents/constants.d.ts +0 -23
- package/dist/agents/constants.d.ts.map +0 -1
- package/dist/agents/constants.js +0 -22
- package/dist/agents/constants.js.map +0 -1
- package/dist/agents/index.d.ts +0 -1
- package/dist/agents/index.d.ts.map +0 -1
- package/dist/agents/index.js +0 -4
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/robota.test.d.ts +0 -2
- package/dist/agents/robota.test.d.ts.map +0 -1
- package/dist/agents/robota.test.js +0 -416
- package/dist/agents/robota.test.js.map +0 -1
- package/dist/browser/builtin-templates.json +0 -107
- package/dist/core/robota.d.ts +0 -694
- package/dist/core/robota.d.ts.map +0 -1
- package/dist/core/robota.js +0 -1277
- package/dist/core/robota.js.map +0 -1
- package/dist/executors/local-executor.d.ts +0 -96
- package/dist/executors/local-executor.d.ts.map +0 -1
- package/dist/executors/local-executor.js +0 -197
- package/dist/executors/local-executor.js.map +0 -1
- package/dist/executors/local-executor.test.d.ts +0 -2
- package/dist/executors/local-executor.test.d.ts.map +0 -1
- package/dist/executors/local-executor.test.js +0 -192
- package/dist/executors/local-executor.test.js.map +0 -1
- package/dist/index.d.ts +0 -274
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -235
- package/dist/index.js.map +0 -1
- package/dist/interfaces/agent.d.ts +0 -198
- package/dist/interfaces/agent.d.ts.map +0 -1
- package/dist/interfaces/agent.js +0 -2
- package/dist/interfaces/agent.js.map +0 -1
- package/dist/interfaces/event-service.d.ts +0 -79
- package/dist/interfaces/event-service.d.ts.map +0 -1
- package/dist/interfaces/event-service.js +0 -2
- package/dist/interfaces/event-service.js.map +0 -1
- package/dist/interfaces/executor.d.ts +0 -128
- package/dist/interfaces/executor.d.ts.map +0 -1
- package/dist/interfaces/executor.js +0 -2
- package/dist/interfaces/executor.js.map +0 -1
- package/dist/interfaces/history-module.d.ts +0 -19
- package/dist/interfaces/history-module.d.ts.map +0 -1
- package/dist/interfaces/history-module.js +0 -2
- package/dist/interfaces/history-module.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -13
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -4
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/manager.d.ts +0 -142
- package/dist/interfaces/manager.d.ts.map +0 -1
- package/dist/interfaces/manager.js +0 -2
- package/dist/interfaces/manager.js.map +0 -1
- package/dist/interfaces/messages.d.ts +0 -75
- package/dist/interfaces/messages.d.ts.map +0 -1
- package/dist/interfaces/messages.js +0 -29
- package/dist/interfaces/messages.js.map +0 -1
- package/dist/interfaces/progress-reporting.d.ts +0 -86
- package/dist/interfaces/progress-reporting.d.ts.map +0 -1
- package/dist/interfaces/progress-reporting.js +0 -37
- package/dist/interfaces/progress-reporting.js.map +0 -1
- package/dist/interfaces/provider.d.ts +0 -217
- package/dist/interfaces/provider.d.ts.map +0 -1
- package/dist/interfaces/provider.js +0 -2
- package/dist/interfaces/provider.js.map +0 -1
- package/dist/interfaces/service.d.ts +0 -205
- package/dist/interfaces/service.d.ts.map +0 -1
- package/dist/interfaces/service.js +0 -6
- package/dist/interfaces/service.js.map +0 -1
- package/dist/interfaces/tool.d.ts +0 -248
- package/dist/interfaces/tool.d.ts.map +0 -1
- package/dist/interfaces/tool.js +0 -2
- package/dist/interfaces/tool.js.map +0 -1
- package/dist/interfaces/types.d.ts +0 -71
- package/dist/interfaces/types.d.ts.map +0 -1
- package/dist/interfaces/types.js +0 -33
- package/dist/interfaces/types.js.map +0 -1
- package/dist/interfaces/workflow-converter.d.ts +0 -193
- package/dist/interfaces/workflow-converter.d.ts.map +0 -1
- package/dist/interfaces/workflow-converter.js +0 -11
- package/dist/interfaces/workflow-converter.js.map +0 -1
- package/dist/interfaces/workflow-validator.d.ts +0 -209
- package/dist/interfaces/workflow-validator.d.ts.map +0 -1
- package/dist/interfaces/workflow-validator.js +0 -16
- package/dist/interfaces/workflow-validator.js.map +0 -1
- package/dist/managers/agent-factory.d.ts +0 -132
- package/dist/managers/agent-factory.d.ts.map +0 -1
- package/dist/managers/agent-factory.js +0 -284
- package/dist/managers/agent-factory.js.map +0 -1
- package/dist/managers/agent-factory.test.d.ts +0 -2
- package/dist/managers/agent-factory.test.d.ts.map +0 -1
- package/dist/managers/agent-factory.test.js +0 -249
- package/dist/managers/agent-factory.test.js.map +0 -1
- package/dist/managers/agent-templates.d.ts +0 -84
- package/dist/managers/agent-templates.d.ts.map +0 -1
- package/dist/managers/agent-templates.js +0 -159
- package/dist/managers/agent-templates.js.map +0 -1
- package/dist/managers/ai-provider-manager.d.ts +0 -80
- package/dist/managers/ai-provider-manager.d.ts.map +0 -1
- package/dist/managers/ai-provider-manager.js +0 -226
- package/dist/managers/ai-provider-manager.js.map +0 -1
- package/dist/managers/conversation-history-manager.d.ts +0 -455
- package/dist/managers/conversation-history-manager.d.ts.map +0 -1
- package/dist/managers/conversation-history-manager.js +0 -578
- package/dist/managers/conversation-history-manager.js.map +0 -1
- package/dist/managers/conversation-history-manager.test.d.ts +0 -2
- package/dist/managers/conversation-history-manager.test.d.ts.map +0 -1
- package/dist/managers/conversation-history-manager.test.js +0 -374
- package/dist/managers/conversation-history-manager.test.js.map +0 -1
- package/dist/managers/index.d.ts +0 -8
- package/dist/managers/index.d.ts.map +0 -1
- package/dist/managers/index.js +0 -8
- package/dist/managers/index.js.map +0 -1
- package/dist/managers/module-registry.d.ts +0 -161
- package/dist/managers/module-registry.d.ts.map +0 -1
- package/dist/managers/module-registry.js +0 -519
- package/dist/managers/module-registry.js.map +0 -1
- package/dist/managers/module-type-registry.d.ts +0 -113
- package/dist/managers/module-type-registry.d.ts.map +0 -1
- package/dist/managers/module-type-registry.js +0 -439
- package/dist/managers/module-type-registry.js.map +0 -1
- package/dist/managers/plugins.d.ts +0 -166
- package/dist/managers/plugins.d.ts.map +0 -1
- package/dist/managers/plugins.js +0 -339
- package/dist/managers/plugins.js.map +0 -1
- package/dist/managers/tool-manager.d.ts +0 -70
- package/dist/managers/tool-manager.d.ts.map +0 -1
- package/dist/managers/tool-manager.js +0 -138
- package/dist/managers/tool-manager.js.map +0 -1
- package/dist/managers/tool-manager.test.d.ts +0 -2
- package/dist/managers/tool-manager.test.d.ts.map +0 -1
- package/dist/managers/tool-manager.test.js +0 -186
- package/dist/managers/tool-manager.test.js.map +0 -1
- package/dist/node/builtin-templates.json +0 -107
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts +0 -67
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts.map +0 -1
- package/dist/plugins/conversation-history/conversation-history-plugin.js +0 -270
- package/dist/plugins/conversation-history/conversation-history-plugin.js.map +0 -1
- package/dist/plugins/conversation-history/index.d.ts +0 -3
- package/dist/plugins/conversation-history/index.d.ts.map +0 -1
- package/dist/plugins/conversation-history/index.js +0 -2
- package/dist/plugins/conversation-history/index.js.map +0 -1
- package/dist/plugins/conversation-history/storages/database-storage.d.ts +0 -19
- package/dist/plugins/conversation-history/storages/database-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/database-storage.js +0 -94
- package/dist/plugins/conversation-history/storages/database-storage.js.map +0 -1
- package/dist/plugins/conversation-history/storages/file-storage.d.ts +0 -15
- package/dist/plugins/conversation-history/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/file-storage.js +0 -94
- package/dist/plugins/conversation-history/storages/file-storage.js.map +0 -1
- package/dist/plugins/conversation-history/storages/index.d.ts +0 -4
- package/dist/plugins/conversation-history/storages/index.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/index.js +0 -4
- package/dist/plugins/conversation-history/storages/index.js.map +0 -1
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts +0 -15
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/memory-storage.js +0 -33
- package/dist/plugins/conversation-history/storages/memory-storage.js.map +0 -1
- package/dist/plugins/conversation-history/types.d.ts +0 -61
- package/dist/plugins/conversation-history/types.d.ts.map +0 -1
- package/dist/plugins/conversation-history/types.js +0 -2
- package/dist/plugins/conversation-history/types.js.map +0 -1
- package/dist/plugins/error-handling/context-adapter.d.ts +0 -30
- package/dist/plugins/error-handling/context-adapter.d.ts.map +0 -1
- package/dist/plugins/error-handling/context-adapter.js +0 -41
- package/dist/plugins/error-handling/context-adapter.js.map +0 -1
- package/dist/plugins/error-handling/error-handling-plugin.d.ts +0 -49
- package/dist/plugins/error-handling/error-handling-plugin.d.ts.map +0 -1
- package/dist/plugins/error-handling/error-handling-plugin.js +0 -229
- package/dist/plugins/error-handling/error-handling-plugin.js.map +0 -1
- package/dist/plugins/error-handling/index.d.ts +0 -10
- package/dist/plugins/error-handling/index.d.ts.map +0 -1
- package/dist/plugins/error-handling/index.js +0 -10
- package/dist/plugins/error-handling/index.js.map +0 -1
- package/dist/plugins/error-handling/types.d.ts +0 -73
- package/dist/plugins/error-handling/types.d.ts.map +0 -1
- package/dist/plugins/error-handling/types.js +0 -14
- package/dist/plugins/error-handling/types.js.map +0 -1
- package/dist/plugins/event-emitter/metrics.d.ts +0 -17
- package/dist/plugins/event-emitter/metrics.d.ts.map +0 -1
- package/dist/plugins/event-emitter/metrics.js +0 -17
- package/dist/plugins/event-emitter/metrics.js.map +0 -1
- package/dist/plugins/event-emitter/types.d.ts +0 -112
- package/dist/plugins/event-emitter/types.d.ts.map +0 -1
- package/dist/plugins/event-emitter/types.js +0 -65
- package/dist/plugins/event-emitter/types.js.map +0 -1
- package/dist/plugins/event-emitter-plugin.d.ts +0 -222
- package/dist/plugins/event-emitter-plugin.d.ts.map +0 -1
- package/dist/plugins/event-emitter-plugin.js +0 -432
- package/dist/plugins/event-emitter-plugin.js.map +0 -1
- package/dist/plugins/event-emitter-plugin.test.d.ts +0 -2
- package/dist/plugins/event-emitter-plugin.test.d.ts.map +0 -1
- package/dist/plugins/event-emitter-plugin.test.js +0 -94
- package/dist/plugins/event-emitter-plugin.test.js.map +0 -1
- package/dist/plugins/execution/execution-analytics-plugin.d.ts +0 -129
- package/dist/plugins/execution/execution-analytics-plugin.d.ts.map +0 -1
- package/dist/plugins/execution/execution-analytics-plugin.js +0 -517
- package/dist/plugins/execution/execution-analytics-plugin.js.map +0 -1
- package/dist/plugins/execution/index.d.ts +0 -3
- package/dist/plugins/execution/index.d.ts.map +0 -1
- package/dist/plugins/execution/index.js +0 -2
- package/dist/plugins/execution/index.js.map +0 -1
- package/dist/plugins/execution/types.d.ts +0 -90
- package/dist/plugins/execution/types.d.ts.map +0 -1
- package/dist/plugins/execution/types.js +0 -2
- package/dist/plugins/execution/types.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -11
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/limits/types.d.ts +0 -61
- package/dist/plugins/limits/types.d.ts.map +0 -1
- package/dist/plugins/limits/types.js +0 -2
- package/dist/plugins/limits/types.js.map +0 -1
- package/dist/plugins/limits-plugin.d.ts +0 -113
- package/dist/plugins/limits-plugin.d.ts.map +0 -1
- package/dist/plugins/limits-plugin.js +0 -380
- package/dist/plugins/limits-plugin.js.map +0 -1
- package/dist/plugins/logging/formatters.d.ts +0 -14
- package/dist/plugins/logging/formatters.d.ts.map +0 -1
- package/dist/plugins/logging/formatters.js +0 -24
- package/dist/plugins/logging/formatters.js.map +0 -1
- package/dist/plugins/logging/index.d.ts +0 -3
- package/dist/plugins/logging/index.d.ts.map +0 -1
- package/dist/plugins/logging/index.js +0 -2
- package/dist/plugins/logging/index.js.map +0 -1
- package/dist/plugins/logging/logging-plugin.d.ts +0 -91
- package/dist/plugins/logging/logging-plugin.d.ts.map +0 -1
- package/dist/plugins/logging/logging-plugin.js +0 -335
- package/dist/plugins/logging/logging-plugin.js.map +0 -1
- package/dist/plugins/logging/storages/console-storage.d.ts +0 -14
- package/dist/plugins/logging/storages/console-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/console-storage.js +0 -38
- package/dist/plugins/logging/storages/console-storage.js.map +0 -1
- package/dist/plugins/logging/storages/file-storage.d.ts +0 -14
- package/dist/plugins/logging/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/file-storage.js +0 -41
- package/dist/plugins/logging/storages/file-storage.js.map +0 -1
- package/dist/plugins/logging/storages/index.d.ts +0 -5
- package/dist/plugins/logging/storages/index.d.ts.map +0 -1
- package/dist/plugins/logging/storages/index.js +0 -5
- package/dist/plugins/logging/storages/index.js.map +0 -1
- package/dist/plugins/logging/storages/remote-storage.d.ts +0 -20
- package/dist/plugins/logging/storages/remote-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/remote-storage.js +0 -61
- package/dist/plugins/logging/storages/remote-storage.js.map +0 -1
- package/dist/plugins/logging/storages/silent-storage.d.ts +0 -10
- package/dist/plugins/logging/storages/silent-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/silent-storage.js +0 -15
- package/dist/plugins/logging/storages/silent-storage.js.map +0 -1
- package/dist/plugins/logging/types.d.ts +0 -84
- package/dist/plugins/logging/types.d.ts.map +0 -1
- package/dist/plugins/logging/types.js +0 -2
- package/dist/plugins/logging/types.js.map +0 -1
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts +0 -12
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts.map +0 -1
- package/dist/plugins/performance/collectors/system-metrics-collector.js +0 -65
- package/dist/plugins/performance/collectors/system-metrics-collector.js.map +0 -1
- package/dist/plugins/performance/index.d.ts +0 -5
- package/dist/plugins/performance/index.d.ts.map +0 -1
- package/dist/plugins/performance/index.js +0 -4
- package/dist/plugins/performance/index.js.map +0 -1
- package/dist/plugins/performance/performance-plugin.d.ts +0 -49
- package/dist/plugins/performance/performance-plugin.d.ts.map +0 -1
- package/dist/plugins/performance/performance-plugin.js +0 -293
- package/dist/plugins/performance/performance-plugin.js.map +0 -1
- package/dist/plugins/performance/storages/index.d.ts +0 -2
- package/dist/plugins/performance/storages/index.d.ts.map +0 -1
- package/dist/plugins/performance/storages/index.js +0 -4
- package/dist/plugins/performance/storages/index.js.map +0 -1
- package/dist/plugins/performance/storages/memory-storage.d.ts +0 -19
- package/dist/plugins/performance/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/performance/storages/memory-storage.js +0 -69
- package/dist/plugins/performance/storages/memory-storage.js.map +0 -1
- package/dist/plugins/performance/types.d.ts +0 -154
- package/dist/plugins/performance/types.d.ts.map +0 -1
- package/dist/plugins/performance/types.js +0 -2
- package/dist/plugins/performance/types.js.map +0 -1
- package/dist/plugins/usage/aggregate-usage-stats.d.ts +0 -12
- package/dist/plugins/usage/aggregate-usage-stats.d.ts.map +0 -1
- package/dist/plugins/usage/aggregate-usage-stats.js +0 -115
- package/dist/plugins/usage/aggregate-usage-stats.js.map +0 -1
- package/dist/plugins/usage/index.d.ts +0 -5
- package/dist/plugins/usage/index.d.ts.map +0 -1
- package/dist/plugins/usage/index.js +0 -4
- package/dist/plugins/usage/index.js.map +0 -1
- package/dist/plugins/usage/storages/file-storage.d.ts +0 -22
- package/dist/plugins/usage/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/file-storage.js +0 -111
- package/dist/plugins/usage/storages/file-storage.js.map +0 -1
- package/dist/plugins/usage/storages/index.d.ts +0 -5
- package/dist/plugins/usage/storages/index.d.ts.map +0 -1
- package/dist/plugins/usage/storages/index.js +0 -5
- package/dist/plugins/usage/storages/index.js.map +0 -1
- package/dist/plugins/usage/storages/memory-storage.d.ts +0 -22
- package/dist/plugins/usage/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/memory-storage.js +0 -42
- package/dist/plugins/usage/storages/memory-storage.js.map +0 -1
- package/dist/plugins/usage/storages/remote-storage.d.ts +0 -26
- package/dist/plugins/usage/storages/remote-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/remote-storage.js +0 -115
- package/dist/plugins/usage/storages/remote-storage.js.map +0 -1
- package/dist/plugins/usage/storages/silent-storage.d.ts +0 -19
- package/dist/plugins/usage/storages/silent-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/silent-storage.js +0 -26
- package/dist/plugins/usage/storages/silent-storage.js.map +0 -1
- package/dist/plugins/usage/types.d.ts +0 -127
- package/dist/plugins/usage/types.d.ts.map +0 -1
- package/dist/plugins/usage/types.js +0 -2
- package/dist/plugins/usage/types.js.map +0 -1
- package/dist/plugins/usage/usage-plugin.d.ts +0 -67
- package/dist/plugins/usage/usage-plugin.d.ts.map +0 -1
- package/dist/plugins/usage/usage-plugin.js +0 -309
- package/dist/plugins/usage/usage-plugin.js.map +0 -1
- package/dist/plugins/webhook/http-client.d.ts +0 -30
- package/dist/plugins/webhook/http-client.d.ts.map +0 -1
- package/dist/plugins/webhook/http-client.js +0 -110
- package/dist/plugins/webhook/http-client.js.map +0 -1
- package/dist/plugins/webhook/index.d.ts +0 -9
- package/dist/plugins/webhook/index.d.ts.map +0 -1
- package/dist/plugins/webhook/index.js +0 -9
- package/dist/plugins/webhook/index.js.map +0 -1
- package/dist/plugins/webhook/transformer.d.ts +0 -63
- package/dist/plugins/webhook/transformer.d.ts.map +0 -1
- package/dist/plugins/webhook/transformer.js +0 -157
- package/dist/plugins/webhook/transformer.js.map +0 -1
- package/dist/plugins/webhook/types.d.ts +0 -183
- package/dist/plugins/webhook/types.d.ts.map +0 -1
- package/dist/plugins/webhook/types.js +0 -2
- package/dist/plugins/webhook/types.js.map +0 -1
- package/dist/plugins/webhook/webhook-plugin.d.ts +0 -92
- package/dist/plugins/webhook/webhook-plugin.d.ts.map +0 -1
- package/dist/plugins/webhook/webhook-plugin.js +0 -328
- package/dist/plugins/webhook/webhook-plugin.js.map +0 -1
- package/dist/schemas/agent-template-schema.d.ts +0 -137
- package/dist/schemas/agent-template-schema.d.ts.map +0 -1
- package/dist/schemas/agent-template-schema.js +0 -87
- package/dist/schemas/agent-template-schema.js.map +0 -1
- package/dist/services/conversation-service/index.d.ts +0 -88
- package/dist/services/conversation-service/index.d.ts.map +0 -1
- package/dist/services/conversation-service/index.js +0 -441
- package/dist/services/conversation-service/index.js.map +0 -1
- package/dist/services/conversation-service/types.d.ts +0 -32
- package/dist/services/conversation-service/types.d.ts.map +0 -1
- package/dist/services/conversation-service/types.js +0 -8
- package/dist/services/conversation-service/types.js.map +0 -1
- package/dist/services/event-service.d.ts +0 -61
- package/dist/services/event-service.d.ts.map +0 -1
- package/dist/services/event-service.js +0 -110
- package/dist/services/event-service.js.map +0 -1
- package/dist/services/event-service.test.d.ts +0 -2
- package/dist/services/event-service.test.d.ts.map +0 -1
- package/dist/services/event-service.test.js +0 -86
- package/dist/services/event-service.test.js.map +0 -1
- package/dist/services/execution-service.d.ts +0 -151
- package/dist/services/execution-service.d.ts.map +0 -1
- package/dist/services/execution-service.js +0 -1262
- package/dist/services/execution-service.js.map +0 -1
- package/dist/services/execution-service.test.d.ts +0 -2
- package/dist/services/execution-service.test.d.ts.map +0 -1
- package/dist/services/execution-service.test.js +0 -338
- package/dist/services/execution-service.test.js.map +0 -1
- package/dist/services/history-module.d.ts +0 -15
- package/dist/services/history-module.d.ts.map +0 -1
- package/dist/services/history-module.js +0 -42
- package/dist/services/history-module.js.map +0 -1
- package/dist/services/in-memory-history-store.d.ts +0 -12
- package/dist/services/in-memory-history-store.d.ts.map +0 -1
- package/dist/services/in-memory-history-store.js +0 -41
- package/dist/services/in-memory-history-store.js.map +0 -1
- package/dist/services/index.d.ts +0 -7
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -13
- package/dist/services/index.js.map +0 -1
- package/dist/services/task-events.d.ts +0 -6
- package/dist/services/task-events.d.ts.map +0 -1
- package/dist/services/task-events.js +0 -6
- package/dist/services/task-events.js.map +0 -1
- package/dist/services/tool-execution-service.d.ts +0 -74
- package/dist/services/tool-execution-service.d.ts.map +0 -1
- package/dist/services/tool-execution-service.js +0 -189
- package/dist/services/tool-execution-service.js.map +0 -1
- package/dist/services/user-events.d.ts +0 -7
- package/dist/services/user-events.d.ts.map +0 -1
- package/dist/services/user-events.js +0 -6
- package/dist/services/user-events.js.map +0 -1
- package/dist/tools/implementations/function-tool/index.d.ts +0 -9
- package/dist/tools/implementations/function-tool/index.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/index.js +0 -13
- package/dist/tools/implementations/function-tool/index.js.map +0 -1
- package/dist/tools/implementations/function-tool/schema-converter.d.ts +0 -32
- package/dist/tools/implementations/function-tool/schema-converter.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/schema-converter.js +0 -164
- package/dist/tools/implementations/function-tool/schema-converter.js.map +0 -1
- package/dist/tools/implementations/function-tool/types.d.ts +0 -72
- package/dist/tools/implementations/function-tool/types.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/types.js +0 -14
- package/dist/tools/implementations/function-tool/types.js.map +0 -1
- package/dist/tools/implementations/function-tool.d.ts +0 -49
- package/dist/tools/implementations/function-tool.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool.js +0 -223
- package/dist/tools/implementations/function-tool.js.map +0 -1
- package/dist/tools/implementations/index.d.ts +0 -4
- package/dist/tools/implementations/index.d.ts.map +0 -1
- package/dist/tools/implementations/index.js +0 -5
- package/dist/tools/implementations/index.js.map +0 -1
- package/dist/tools/implementations/mcp-tool.d.ts +0 -72
- package/dist/tools/implementations/mcp-tool.d.ts.map +0 -1
- package/dist/tools/implementations/mcp-tool.js +0 -246
- package/dist/tools/implementations/mcp-tool.js.map +0 -1
- package/dist/tools/implementations/openapi-tool.d.ts +0 -56
- package/dist/tools/implementations/openapi-tool.d.ts.map +0 -1
- package/dist/tools/implementations/openapi-tool.js +0 -324
- package/dist/tools/implementations/openapi-tool.js.map +0 -1
- package/dist/tools/implementations/relay-mcp-tool.d.ts +0 -38
- package/dist/tools/implementations/relay-mcp-tool.d.ts.map +0 -1
- package/dist/tools/implementations/relay-mcp-tool.js +0 -46
- package/dist/tools/implementations/relay-mcp-tool.js.map +0 -1
- package/dist/tools/index.d.ts +0 -3
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -4
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/registry/index.d.ts +0 -2
- package/dist/tools/registry/index.d.ts.map +0 -1
- package/dist/tools/registry/index.js +0 -3
- package/dist/tools/registry/index.js.map +0 -1
- package/dist/tools/registry/tool-registry.d.ts +0 -54
- package/dist/tools/registry/tool-registry.d.ts.map +0 -1
- package/dist/tools/registry/tool-registry.js +0 -146
- package/dist/tools/registry/tool-registry.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -155
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -203
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/execution-proxy.d.ts +0 -75
- package/dist/utils/execution-proxy.d.ts.map +0 -1
- package/dist/utils/execution-proxy.js +0 -230
- package/dist/utils/execution-proxy.js.map +0 -1
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -7
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -74
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -143
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/message-converter.d.ts +0 -68
- package/dist/utils/message-converter.d.ts.map +0 -1
- package/dist/utils/message-converter.js +0 -87
- package/dist/utils/message-converter.js.map +0 -1
- package/dist/utils/periodic-task.d.ts +0 -14
- package/dist/utils/periodic-task.d.ts.map +0 -1
- package/dist/utils/periodic-task.js +0 -26
- package/dist/utils/periodic-task.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -40
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -162
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":["relative","relativePath","dnsLookup","resolve","pinnedFetch"],"sources":["../../src/utils/path-containment.ts","../../src/utils/owner-only-store.ts","../../src/utils/ip-address.ts","../../src/utils/egress-policy.ts"],"sourcesContent":["/**\n * SEC-006 — the SSOT for \"is this path inside that root?\" when the answer is a SECURITY decision.\n *\n * `path.resolve` and `path.normalize` are purely lexical: they collapse `.` and `..` textually but do\n * not consult the filesystem, so they cannot see a symlink. A link sitting INSIDE the root and\n * pointing outside it therefore satisfies a `startsWith(root + sep)` check while the syscall that\n * follows — `open`, `readFile`, `writeFile` — follows the link straight out of the boundary.\n *\n * Symlinks are ordinary committed git content and ordinary build-output artifacts, so this is not a\n * theoretical hole: it was exploitable in both the file-tool sandbox and the CLI's monitor asset\n * server. Both now decide containment here, because two containment checks that can disagree are\n * their own defect.\n *\n * Every security-boundary containment check in the repo routes through here — the `agent-*` family\n * and the `dag-*` family alike. The DAG side is not a cross-family exception: `dag-framework`\n * declares `@robota-sdk/agent-core` in its runtime dependencies.\n */\nimport { accessSync, constants, realpathSync, statSync } from 'node:fs';\nimport { basename, dirname, isAbsolute, join, resolve, sep } from 'node:path';\n\n/**\n * Validate an authority root more strictly than candidate-path canonicalization.\n *\n * Candidate write paths may have a missing tail, but an authority root must already exist and be a\n * traversable directory. Keeping the contracts separate prevents a typo in a root from degrading to\n * a lexical boundary that the caller did not actually select.\n */\nexport function resolveTrustedExecutionRoot(input: unknown): string {\n if (typeof input !== 'string') {\n throw new TypeError('executionRoot must be a string');\n }\n if (input.trim().length === 0) {\n throw new TypeError('executionRoot must be a non-empty string');\n }\n if (!isAbsolute(input)) {\n throw new TypeError('executionRoot must be an absolute path');\n }\n\n let canonicalRoot: string;\n try {\n canonicalRoot = realpathSync(input);\n } catch {\n throw new TypeError('executionRoot must name an existing accessible directory');\n }\n if (!statSync(canonicalRoot).isDirectory()) {\n throw new TypeError('executionRoot must name a directory');\n }\n try {\n accessSync(canonicalRoot, constants.R_OK | constants.X_OK);\n } catch {\n throw new TypeError('executionRoot directory must be readable and traversable');\n }\n return canonicalRoot;\n}\n\n/**\n * Resolve `p` to its canonical form, following symlinks, tolerating a path that does not exist yet.\n *\n * `realpathSync` throws on a missing path, but callers legitimately ask about files they are about to\n * CREATE (a write or an edit). So we walk up to the deepest ancestor that does exist, canonicalize\n * that, and re-attach the remaining segments — the re-attached tail cannot itself be a symlink,\n * because it does not exist.\n */\nexport function canonicalizePath(p: string): string {\n const tail: string[] = [];\n let current = resolve(p);\n for (;;) {\n try {\n return join(realpathSync(current), ...tail);\n } catch {\n const parent = dirname(current);\n // allow-fallback: nothing along the chain exists or is readable — fall back to the lexical\n // path, which `resolve()` has already fully normalized and which is therefore safe to compare.\n if (parent === current) return resolve(p);\n tail.unshift(basename(current));\n current = parent;\n }\n }\n}\n\n/**\n * Whether `candidate` is `root` itself or lies beneath it, decided on the CANONICAL form of both.\n *\n * Canonicalizing the root as well as the candidate matters: a root that is itself reached through a\n * symlink (macOS `/tmp` -> `/private/tmp`, or a workspace under a symlinked home) would otherwise\n * spuriously reject every path inside it.\n */\nexport function isPathInside(root: string, candidate: string): boolean {\n const canonicalRoot = canonicalizePath(root);\n const canonicalCandidate = canonicalizePath(candidate);\n return canonicalCandidate === canonicalRoot || canonicalCandidate.startsWith(canonicalRoot + sep);\n}\n","/**\n * SEC-020 (issue #2021) — creating a host directory or file that only its owner can read.\n *\n * A host application persists session records, logs, settings and device credentials under a directory\n * of its own choosing. They carry prompts, model output, tool results and, in the settings case,\n * provider credentials. On a shared workstation or a CI host, every other local account reads them\n * unless the mode says otherwise.\n *\n * WHERE that directory is belongs to the host, not here — this module knows only what has to be true\n * of whatever path it is handed, which is what lets it be tested without a filesystem layout.\n *\n * ## Why this is one module and not a constant each caller repeats\n *\n * `0o600` and `0o700` were already spelled out in five separate files before this existed, and the\n * repository had already learned — in `guarded-directory.ts`, for a pairing rendezvous — that the\n * constants are the easy half. The load-bearing part is that **`mkdirSync(path, { mode })` does not\n * set the mode of a directory that already exists.** `recursive: true` returns successfully and\n * silently adopts whatever mode is there. A directory left at 0777 by an earlier version, by a\n * shared CI checkout, or by another local user who pre-created it, becomes ours with no signal.\n *\n * Measured under umask 022 before this module existed: a session log directory pre-created at 0777\n * stayed 0777 through `mkdirSync(dir, { recursive: true, mode: 0o700 })`, and its 0600 records were\n * then removable and replaceable by any local account.\n *\n * The same holds for files. `writeFileSync(path, data, { mode })` applies the mode only when the\n * file is CREATED; an existing 0644 record keeps 0644 forever, so a store written by an older\n * version is never repaired by a newer one.\n *\n * So: create, then set the mode unconditionally, then VERIFY — and verification is what makes the\n * first two checkable rather than hopeful. It is also the only step that catches an owner we did not\n * expect, which `mkdir` and `chmod` between them cannot.\n *\n * ## Windows\n *\n * `chmodSync` on win32 toggles the read-only attribute and cannot express \"owner only\"; NTFS ACL\n * inheritance governs instead, and a user's profile directory is not readable by other unprivileged\n * accounts by default. The POSIX assertion is therefore not made there, and `ownerOnlyGuarantee()` reports which\n * guarantee is in force so a caller — and a test — can state the platform's actual claim rather than\n * assume the POSIX one everywhere. A store directory placed inside a world-writable parent on\n * Windows is NOT protected by this module, and that is recorded rather than papered over.\n */\n\nimport {\n chmodSync,\n mkdirSync,\n renameSync,\n rmSync,\n statSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs';\nimport { dirname, isAbsolute, join, relative as relativePath, sep } from 'node:path';\n\n/** Owner read/write. Nothing for group, nothing for other. */\nexport const OWNER_ONLY_FILE_MODE = 0o600;\n/** Owner read/write/traverse. The traverse bit is what keeps another account out of the directory. */\nexport const OWNER_ONLY_DIRECTORY_MODE = 0o700;\n\n/** The bits that must be clear for the guarantee to hold: every group and other permission. */\nconst FORBIDDEN_BITS = 0o077;\n\n/** Raised when a path cannot be made owner-only. Never swallowed into a weaker mode. */\nexport class OwnerOnlyModeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'OwnerOnlyModeError';\n }\n}\n\n/**\n * Which guarantee this platform can actually make.\n *\n * `posix-mode` — the mode bits are asserted after every create and every write.\n * `windows-acl` — inherited NTFS ACLs govern; the POSIX assertion is not made and not claimed.\n */\nexport function ownerOnlyGuarantee(\n platform: string = process.platform,\n): 'posix-mode' | 'windows-acl' {\n return platform === 'win32' ? 'windows-acl' : 'posix-mode';\n}\n\n/**\n * Seams for the failure paths, injected for the reason `guarded-directory.ts` states: a filesystem\n * that silently ignores `chmod` is a real condition — some network and FAT mounts do exactly that —\n * and it is the ONLY condition the verification step catches that create-then-chmod does not. Without\n * a seam that case is unreachable from a test, and a guard no test can reach is a guard nobody knows\n * is there. Measured: with these absent, deleting the verification entirely changed no test result.\n */\nexport interface IOwnerOnlyIo {\n readonly makeDirectory?: (target: string, mode: number) => void;\n readonly setMode?: (target: string, mode: number) => void;\n readonly readMode?: (target: string) => number;\n}\n\nexport interface IEnsureOwnerOnlyOptions extends IOwnerOnlyIo {\n /**\n * An ANCESTOR of `directory` that the caller also owns, tightened along with every segment between\n * them.\n *\n * Needed because `mkdirSync(path, { recursive: true, mode })` applies the mode only to the\n * directories it CREATES. A store root an older version already made sits at whatever mode it was\n * given and this call would leave it there — which is the module's own headline defect surviving\n * one level up, on the very path it exists to protect. Found in review of PR #2224.\n *\n * It is a parameter rather than a walk up to some inferred boundary because WHICH ancestors belong\n * to the caller is the caller's knowledge. This module must not guess that a parent is ours; it\n * would eventually chmod someone's home directory.\n */\n readonly withinRoot?: string;\n}\n\n/** Every directory from `root` down to `target`, outermost first. `root` must be an ancestor. */\nfunction segmentsFromRoot(root: string, target: string): string[] {\n const relative = relativePath(root, target);\n if (relative.startsWith('..') || isAbsolute(relative)) {\n throw new OwnerOnlyModeError(\n `withinRoot ${root} is not an ancestor of ${target}, so this call cannot own the path between them.`,\n );\n }\n const parts = relative.split(sep).filter((part) => part.length > 0);\n const chain: string[] = [root];\n let current = root;\n for (const part of parts) {\n current = join(current, part);\n chain.push(current);\n }\n return chain;\n}\n\nfunction assertOwnerOnly(target: string, kind: 'directory' | 'file', io: IOwnerOnlyIo = {}): void {\n if (ownerOnlyGuarantee() !== 'posix-mode') return;\n const mode = (io.readMode ?? ((path: string) => statSync(path).mode & 0o7777))(target);\n if ((mode & FORBIDDEN_BITS) !== 0) {\n throw new OwnerOnlyModeError(\n `${kind} ${target} is mode 0${mode.toString(8)} after being set owner-only; ` +\n 'group or other permissions survived, so its contents are readable by another account.',\n );\n }\n}\n\n/**\n * Ensure `directory` exists and only its owner can enter it.\n *\n * The `chmod` is unconditional because `mkdir` does not touch an existing directory's mode, and the\n * `stat` afterwards is what turns two hopeful calls into a checked one.\n */\nexport function ensureOwnerOnlyDirectory(\n directory: string,\n options: IEnsureOwnerOnlyOptions = {},\n): void {\n const makeDirectory =\n options.makeDirectory ??\n ((target: string, mode: number): void => {\n mkdirSync(target, { recursive: true, mode });\n });\n const setMode =\n options.setMode ?? ((target: string, mode: number): void => chmodSync(target, mode));\n makeDirectory(directory, OWNER_ONLY_DIRECTORY_MODE);\n // Every directory the caller declared it owns, not only the leaf. `mkdir` set the mode on what it\n // CREATED; a root an older version left at 0755 was created by nobody here and would keep it.\n const owned =\n options.withinRoot === undefined\n ? [directory]\n : segmentsFromRoot(options.withinRoot, directory);\n for (const target of owned) {\n if (ownerOnlyGuarantee() === 'posix-mode') setMode(target, OWNER_ONLY_DIRECTORY_MODE);\n assertOwnerOnly(target, 'directory', options);\n }\n}\n\n/**\n * Replace `filePath` atomically with content only its owner can read.\n *\n * The temp file carries the mode from the moment it is created — writing it at the umask's default\n * and tightening afterwards leaves a window in which the full content is world-readable on disk, and\n * `rename` preserves whatever mode the temp file had. The `chmod` after the write is for the case\n * where the temp path already existed at a wider mode.\n */\nexport function writeOwnerOnlyFile(filePath: string, content: string): void {\n ensureOwnerOnlyDirectory(dirname(filePath));\n const temporaryPath = `${filePath}.${process.pid}.tmp`;\n // A stale temp file is REMOVED rather than reused. It can only come from a process that died\n // mid-write, its contents are meaningless, and — the part that matters here — `writeFileSync` does\n // not apply `mode` to a file that already exists, so reusing one at 0666 would put the whole\n // record on disk world-readable before the rename.\n //\n // Removed with `force` rather than `if (exists) unlink`: checking and then acting on a path is a\n // race, and the race is exploitable here — another process can create the path between the two\n // calls, and the `wx` write below would then fail on a file this call believed it had cleared.\n // CodeQL flagged the check-then-act form on PR #2224 and it was right to.\n rmSync(temporaryPath, { force: true });\n // `wx` guarantees this call CREATES the file, which is the only condition under which `mode` is\n // applied. There is deliberately no `chmod` after it: tightening a file that was created wide\n // leaves a window in which the full record is readable, and a `chmod` here would make the mode\n // above redundant — so a mutation that removed it would change nothing and the window would be\n // untested. The assertion below is what proves the mode actually took.\n writeFileSync(temporaryPath, content, {\n encoding: 'utf8',\n mode: OWNER_ONLY_FILE_MODE,\n flag: 'wx',\n });\n try {\n assertOwnerOnly(temporaryPath, 'file');\n renameSync(temporaryPath, filePath);\n } catch (error) {\n try {\n unlinkSync(temporaryPath);\n } catch {\n // allow-fallback: the temp file may already be gone; the original error is the one to report.\n }\n throw error;\n }\n assertOwnerOnly(filePath, 'file');\n}\n\n/**\n * Tighten a file that already exists — the repair path for a record an older version left at 0644.\n *\n * A no-op on a path that does not exist, because \"there is nothing to tighten\" and \"we tightened it\"\n * are the same outcome for the caller, and throwing would make every writer branch on existence.\n */\nexport function tightenExistingFile(filePath: string): void {\n if (ownerOnlyGuarantee() !== 'posix-mode') return;\n let mode: number;\n try {\n mode = statSync(filePath).mode & 0o7777;\n } catch {\n return; // allow-fallback: nothing to tighten\n }\n if ((mode & FORBIDDEN_BITS) === 0) return;\n chmodSync(filePath, OWNER_ONLY_FILE_MODE);\n assertOwnerOnly(filePath, 'file');\n}\n","/**\n * Address classification for the egress boundary (#2026) — the \"is this address public unicast?\"\n * half of `egress-policy.ts`, split out so each module holds one job: that one owns the FETCH\n * (scheme, redirects, headers, deadline, byte cap), this one owns the ARITHMETIC of an address.\n *\n * The awkward part lives here on purpose. A literal destination reaches the policy already\n * normalized by `URL` (`2130706433`, `0x7f.1` and `[::ffff:7f00:1]` all collapse to one hostname),\n * but a RESOLVED one does not: `dns.lookup` renders an IPv4-mapped AAAA answer through `inet_ntop`,\n * which prints the dotted spelling `::ffff:127.0.0.1`. So the expansion below accepts BOTH\n * spellings rather than trusting any normalizer to have run — on the resolution path an attacker\n * controls the record. Every \"cannot parse\" answer is `undefined`/`true`, i.e. NOT public: an\n * address this module cannot read is never treated as reachable.\n *\n * Node-only (`node:net`): reached through `egress-policy.ts`, never the browser barrel.\n */\n\nimport { isIP } from 'node:net';\n\n/** What `isIP` answers: 4 for an IPv4 literal, 6 for an IPv6 one, 0 for text that is neither. */\nconst IP_VERSION_V4 = 4;\nconst IP_VERSION_V6 = 6;\n/** An IPv6 group is two octets wide, and is written in hex once a dotted quad is folded into one. */\nconst OCTET_BITS = 8;\nconst HEX_RADIX = 16;\n\n/** True when `ip` (v4 or v6 text) is not a public unicast address. */\nexport function isPrivateAddress(ip: string): boolean {\n const version = isIP(ip);\n if (version === IP_VERSION_V4) return isPrivateIpv4(ip.split('.').map(Number));\n if (version === IP_VERSION_V6) return isPrivateIpv6(ip);\n return true; // not an address at all: never treat it as public\n}\n\nfunction isPrivateIpv4(o: readonly number[]): boolean {\n const [a = 0, b = 0, c = 0] = o;\n return (\n a === 0 || // \"this\" network\n a === 10 ||\n a === 127 ||\n (a === 100 && b >= 64 && b <= 127) || // CGNAT\n (a === 169 && b === 254) || // link-local, incl. 169.254.169.254\n (a === 172 && b >= 16 && b <= 31) ||\n (a === 192 && b === 0 && c === 0) ||\n (a === 192 && b === 168) ||\n (a === 198 && (b === 18 || b === 19)) ||\n a >= 224 // multicast + reserved + broadcast\n );\n}\n\nfunction isPrivateIpv6(ip: string): boolean {\n const groups = expandIpv6(ip);\n if (groups === undefined) return true;\n const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, g4 = 0, g5 = 0, g6 = 0, g7 = 0] = groups;\n const isMapped = g0 === 0 && g1 === 0 && g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0xffff;\n const isNat64 = g0 === 0x64 && g1 === 0xff9b && g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0;\n if (isMapped || isNat64) {\n return isPrivateIpv4([g6 >> 8, g6 & 0xff, g7 >> 8, g7 & 0xff]);\n }\n // ::/96 in one rule: the unspecified address `::`, loopback `::1`, and the DEPRECATED\n // IPv4-compatible form (`::127.0.0.1`, which `URL` renders as `::7f00:1`) — which embeds an IPv4\n // address just as a mapped one does. None of that range is public unicast.\n if (g0 === 0 && g1 === 0 && g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0) return true;\n if ((g0 & 0xfe00) === 0xfc00) return true; // fc00::/7 unique local\n if ((g0 & 0xffc0) === 0xfe80) return true; // fe80::/10 link-local\n if ((g0 & 0xffc0) === 0xfec0) return true; // fec0::/10 site-local (deprecated, still routable)\n if ((g0 & 0xff00) === 0xff00) return true; // ff00::/8 multicast\n return false;\n}\n\n/**\n * Rewrite a trailing dotted-quad (`::ffff:127.0.0.1`) into the two hex groups it stands for, so the\n * rest of the expansion only ever sees colon groups. `undefined` when the tail is not a valid IPv4\n * address — a refusal, never a guess, because {@link isPrivateIpv6} reads `undefined` as private.\n *\n * This form is not exotic: `URL` normalizes a literal to `[::ffff:7f00:1]`, but `dns.lookup` renders\n * an IPv4-mapped AAAA answer through `inet_ntop`, which prints the dotted form — so it is exactly\n * what arrives on the RESOLUTION path, where an attacker controls the record.\n */\nfunction withoutDottedQuadTail(ip: string): string | undefined {\n const lastColon = ip.lastIndexOf(':');\n const tail = ip.slice(lastColon + 1);\n if (!tail.includes('.')) return ip;\n if (lastColon < 0 || isIP(tail) !== IP_VERSION_V4) return undefined;\n const [a = 0, b = 0, c = 0, d = 0] = tail.split('.').map(Number);\n const high = ((a << OCTET_BITS) | b).toString(HEX_RADIX);\n const low = ((c << OCTET_BITS) | d).toString(HEX_RADIX);\n return `${ip.slice(0, lastColon + 1)}${high}:${low}`;\n}\n\n/** Expand an IPv6 literal (as `URL` or a resolver renders it, brackets removed) into 8 16-bit groups. */\nfunction expandIpv6(ip: string): number[] | undefined {\n const zoneless = ip.split('%')[0] ?? ip;\n const withoutZone = withoutDottedQuadTail(zoneless);\n if (withoutZone === undefined) return undefined;\n const halves = withoutZone.split('::');\n if (halves.length > 2) return undefined;\n const parse = (part: string): number[] =>\n part.length === 0 ? [] : part.split(':').map((g) => Number.parseInt(g, 16));\n const head = parse(halves[0] ?? '');\n const tail = halves.length === 2 ? parse(halves[1] ?? '') : [];\n const missing = 8 - head.length - tail.length;\n if (missing < 0 || (halves.length === 1 && missing !== 0)) return undefined;\n const groups = [...head, ...new Array<number>(missing).fill(0), ...tail];\n return groups.some((g) => Number.isNaN(g) || g < 0 || g > 0xffff) ? undefined : groups;\n}\n","/**\n * The shared outbound-network (egress) boundary (#2026).\n *\n * Every built-in, provider helper and node runtime that fetches a caller- or model-supplied URL goes\n * through {@link fetchWithEgressPolicy}. It owns, in one place:\n *\n * - DESTINATION safety: only `http:`/`https:`; literal and RESOLVED addresses are refused when they are\n * loopback, private, link-local, multicast, unspecified or reserved — for IPv4, IPv6, and IPv4-mapped /\n * IPv4-compatible / NAT64-embedded forms — plus the well-known cloud metadata hostnames. `URL`\n * normalization is what collapses alternate encodings (`2130706433`, `0x7f.1`, `[::ffff:7f00:1]`)\n * into one hostname on the LITERAL path; the RESOLVED path has no such normalizer, and an embedded\n * IPv4 arrives from `dns.lookup` in the dotted spelling `inet_ntop` prints (`::ffff:127.0.0.1`), so\n * the classifier accepts both spellings rather than trusting `URL` to have canonicalised anything.\n * - REDIRECTS: followed manually, every hop re-validated, and caller-supplied plus credential-bearing\n * headers dropped on a cross-origin hop. A POST ({@link postWithEgressPolicy}) never follows one:\n * its body can carry a credential — an authorization code, a client secret, a refresh token — and\n * a redirect would hand it to a destination the caller never chose.\n * - RESOURCE policy: the caller's `AbortSignal` composed with an explicit deadline, and the response\n * byte cap enforced WHILE STREAMING (and from `Content-Length` first), never after a whole-body\n * allocation.\n * - ESCAPE HATCHES: `allowedHosts` (exact hostnames that may resolve privately) and\n * `allowPrivateAddresses` (an explicit enterprise opt-out), both declared by the composition root.\n *\n * The default Node transport connects only to the validated address set through a request-owned\n * dispatcher. The original URL/Host/TLS name is preserved. A trusted injected fetch owns its own\n * socket policy; it is never an automatic fallback when the default pinned transport fails.\n *\n * Node-only (`node:dns`, `node:net`): exported from `@robota-sdk/agent-core/node`, never the browser barrel.\n */\n\nimport { lookup as dnsLookup } from 'node:dns/promises';\nimport { isIP } from 'node:net';\n// Bun replaces the bare specifier with a shim that ignores dispatcher; this subpath loads the pinned package.\nimport { Agent, fetch as pinnedFetch } from 'undici/index.js';\n\nimport { isPrivateAddress } from './ip-address.js';\n\nexport type TEgressLookup = (hostname: string) => Promise<readonly string[]>;\n\nexport interface IEgressPolicy {\n /** Exact lowercase hostnames that may be reached even when they resolve to a private address. */\n readonly allowedHosts?: readonly string[];\n /** Explicit enterprise opt-out from private/loopback/metadata blocking. Default `false`. */\n readonly allowPrivateAddresses?: boolean;\n /** Redirect hops followed before refusing. Default 5. */\n readonly maxRedirects?: number;\n}\n\nexport interface IEgressFetchOptions {\n readonly headers?: Readonly<Record<string, string>>;\n readonly signal?: AbortSignal;\n /** Deadline for the WHOLE exchange, redirects and body included. Default 30 000 ms. */\n readonly timeoutMs?: number;\n /** Byte cap enforced on `Content-Length` and again while streaming. Default 5 000 000. */\n readonly maxResponseBytes?: number;\n}\n\nexport interface IEgressDeps {\n /** Trusted owner/test carrier: this override owns connect-time policy and socket lifetime. */\n readonly fetch?: typeof globalThis.fetch;\n readonly lookup?: TEgressLookup;\n}\n\nexport type TEgressRejectionReason =\n | 'unsupported_scheme'\n | 'private_destination'\n | 'metadata_host'\n | 'unresolvable'\n | 'redirect_limit'\n | 'redirect_without_location'\n | 'redirect_refused'\n | 'response_too_large';\n\nexport interface IEgressRejection {\n readonly reason: TEgressRejectionReason;\n readonly url: string;\n readonly message: string;\n}\n\nexport type TEgressFetchResult =\n | {\n ok: true;\n status: number;\n statusText: string;\n headers: Headers;\n body: Uint8Array;\n finalUrl: string;\n }\n | { ok: false; rejection: IEgressRejection };\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_RESPONSE_BYTES = 5_000_000;\nconst DEFAULT_MAX_REDIRECTS = 5;\nconst REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);\n\n/** The address classifier, re-exported so the egress boundary stays one import for callers. */\nexport { isPrivateAddress };\n\n/** Hostnames that are metadata services or loopback by convention, whatever they resolve to. */\nexport const BLOCKED_HOSTNAMES: ReadonlySet<string> = new Set([\n 'localhost',\n 'metadata',\n 'metadata.google.internal',\n 'metadata.goog',\n 'instance-data',\n 'instance-data.ec2.internal',\n]);\n\nconst defaultLookup: TEgressLookup = async (hostname) =>\n (await dnsLookup(hostname, { all: true, verbatim: true })).map((entry) => entry.address);\n\n/** Validate ONE destination URL against the policy. `undefined` means it may be reached. */\nexport async function rejectDestination(\n url: URL,\n policy: IEgressPolicy = {},\n lookup: TEgressLookup = defaultLookup,\n): Promise<IEgressRejection | undefined> {\n const href = url.href;\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return {\n reason: 'unsupported_scheme',\n url: href,\n message: `Only http(s) URLs may be fetched.`,\n };\n }\n if (policy.allowPrivateAddresses === true) return undefined;\n const hostname = url.hostname.replace(/^\\[|\\]$/g, '').toLowerCase();\n if (policy.allowedHosts?.includes(hostname)) return undefined;\n if (BLOCKED_HOSTNAMES.has(hostname) || hostname.endsWith('.localhost')) {\n return {\n reason: 'metadata_host',\n url: href,\n message: `Destination \"${hostname}\" is a loopback or cloud-metadata host and is not reachable from tools.`,\n };\n }\n const addresses = isIP(hostname) ? [hostname] : await resolve(hostname, lookup);\n if (addresses === undefined || addresses.length === 0) {\n return {\n reason: 'unresolvable',\n url: href,\n message: `Destination \"${hostname}\" did not resolve.`,\n };\n }\n const blocked = addresses.find(isPrivateAddress);\n if (blocked !== undefined) {\n return {\n reason: 'private_destination',\n url: href,\n message: `Destination \"${hostname}\" resolves to ${blocked}, a private, loopback or link-local address, and is not reachable from tools.`,\n };\n }\n return undefined;\n}\n\nasync function resolve(\n hostname: string,\n lookup: TEgressLookup,\n): Promise<readonly string[] | undefined> {\n try {\n return await lookup(hostname);\n } catch {\n // allow-fallback: an unresolvable host is a POLICY outcome (\"unresolvable\"), reported to the\n // caller as a rejection with its reason — not a hidden success.\n return undefined;\n }\n}\n\nexport interface IEgressExchange {\n readonly response: Response;\n close(): Promise<void>;\n}\n\n/** The bounded resolver can finish later, but an aborted exchange never dispatches its result. */\nasync function lookupUnderSignal(\n hostname: string,\n lookup: TEgressLookup,\n signal: AbortSignal,\n): Promise<readonly string[]> {\n signal.throwIfAborted();\n let aborted: (() => void) | undefined;\n try {\n return await Promise.race([\n lookup(hostname),\n new Promise<never>((_, reject) => {\n aborted = () => reject(signal.reason);\n signal.addEventListener('abort', aborted, { once: true });\n if (signal.aborted) aborted();\n }),\n ]);\n } finally {\n if (aborted) signal.removeEventListener('abort', aborted);\n }\n}\n\n/**\n * Open one manually redirected exchange without buffering its response. A streaming owner supplies\n * the lifetime/deadline signal and must close the exchange on completion, cancellation and failure.\n * No ambient dispatcher, second DNS resolution, URL rewrite or transport downgrade is selected.\n */\nexport async function openEgressExchange(\n url: URL,\n init: RequestInit,\n policy: IEgressPolicy,\n deps: IEgressDeps,\n signal: AbortSignal,\n): Promise<IEgressExchange | IEgressRejection> {\n const hostname = url.hostname.replace(/^\\[|\\]$/g, '').toLowerCase();\n let addresses: readonly string[] | undefined;\n const lookup: TEgressLookup = async (host) => {\n const resolved = await lookupUnderSignal(host, deps.lookup ?? defaultLookup, signal);\n if (resolved.length === 0 || resolved.some((address) => isIP(address) === 0))\n throw new Error('Invalid DNS answer');\n addresses = Object.freeze([...resolved]);\n return addresses;\n };\n const rejection = await rejectDestination(url, policy, lookup);\n signal.throwIfAborted();\n if (rejection) return rejection;\n if (deps.fetch) {\n const response = await deps.fetch(url.href, { ...init, signal, redirect: 'manual' });\n return {\n response,\n close: async () => {\n if (response.body && !response.body.locked)\n await response.body.cancel().catch(() => undefined);\n },\n };\n }\n // Explicit private/host allowlisting skips destination blocking, never the connection's one resolution.\n addresses ??= isIP(hostname) ? [hostname] : await resolve(hostname, lookup);\n signal.throwIfAborted();\n if (!addresses || addresses.length === 0)\n return {\n reason: 'unresolvable',\n url: url.href,\n message: 'Destination did not resolve to valid IP addresses.',\n };\n const pinned = addresses.map((address) => ({ address, family: isIP(address) }));\n const dispatcher = new Agent({\n connections: 1,\n pipelining: 0,\n connect: {\n lookup: (host, options, callback) => {\n if (host.toLowerCase() !== hostname || signal.aborted) {\n callback(new Error('Connection authority unavailable'), '', 4);\n return;\n }\n const family = typeof options === 'number' ? options : options.family;\n const candidates = pinned.filter((record) => !family || record.family === family);\n if (candidates.length === 0) {\n callback(new Error('No validated address family'), '', 4);\n return;\n }\n if (typeof options === 'object' && options.all) callback(null, candidates);\n else callback(null, candidates[0]!.address, candidates[0]!.family);\n },\n },\n });\n if (typeof dispatcher.dispatch !== 'function' || typeof dispatcher.destroy !== 'function')\n throw new Error('Pinned HTTP transport is unavailable in this runtime');\n try {\n const response = await pinnedFetch(url.href, { ...init, signal, redirect: 'manual', dispatcher } as Parameters<\n typeof pinnedFetch\n >[1]);\n // undici implements the standard Response/Headers/body contract used below; DOM/Node type names differ.\n return {\n response: response as unknown as Response,\n close: async () => {\n await dispatcher.destroy();\n },\n };\n } catch (error) {\n await dispatcher.destroy();\n throw error;\n }\n}\n\n/**\n * Fetch `url` under the egress policy. Policy outcomes are RETURNED (`ok: false`); transport errors\n * (DNS failure at connect, refused connection, TLS, abort) are THROWN, as `fetch` throws them, so the\n * caller's own error classification keeps working.\n */\nexport async function fetchWithEgressPolicy(\n url: string,\n options: IEgressFetchOptions = {},\n policy: IEgressPolicy = {},\n deps: IEgressDeps = {},\n): Promise<TEgressFetchResult> {\n const maxBytes = options.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES;\n const maxRedirects = policy.maxRedirects ?? DEFAULT_MAX_REDIRECTS;\n const deadline = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n const signal = options.signal ? AbortSignal.any([deadline, options.signal]) : deadline;\n\n let current = new URL(url);\n let headers: Record<string, string> = { ...(options.headers ?? {}) };\n for (let hop = 0; ; hop += 1) {\n const exchange = await openEgressExchange(\n current,\n { headers, signal, redirect: 'manual' },\n policy,\n deps,\n signal,\n );\n if (!('response' in exchange)) return { ok: false, rejection: exchange };\n try {\n const response = exchange.response;\n if (!REDIRECT_STATUSES.has(response.status)) {\n return await readUnderCap(response, current.href, maxBytes, signal);\n }\n\n const location = response.headers.get('location');\n if (location === null) {\n return {\n ok: false,\n rejection: {\n reason: 'redirect_without_location',\n url: current.href,\n message: `HTTP ${response.status} without a Location header.`,\n },\n };\n }\n if (hop >= maxRedirects) {\n return {\n ok: false,\n rejection: {\n reason: 'redirect_limit',\n url: current.href,\n message: `More than ${maxRedirects} redirects.`,\n },\n };\n }\n const next = new URL(location, current);\n if (next.origin !== current.origin) headers = stripSensitiveHeaders(headers);\n current = next;\n } finally {\n await exchange.close();\n }\n }\n}\n\nexport interface IEgressPostOptions extends IEgressFetchOptions {\n /** Sent as-is; a `URLSearchParams` or JSON string, never a stream, so it is never re-sent. */\n readonly body: string | URLSearchParams;\n}\n\n/**\n * POST `url` under the egress policy. The destination is validated as for a GET, but a redirect is\n * REFUSED (`redirect_refused`), never followed: the body is the caller's to send to this URL alone.\n */\nexport async function postWithEgressPolicy(\n url: string,\n options: IEgressPostOptions,\n policy: IEgressPolicy = {},\n deps: IEgressDeps = {},\n): Promise<TEgressFetchResult> {\n const maxBytes = options.maxResponseBytes ?? DEFAULT_MAX_RESPONSE_BYTES;\n const deadline = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n const signal = options.signal ? AbortSignal.any([deadline, options.signal]) : deadline;\n const target = new URL(url);\n const exchange = await openEgressExchange(\n target,\n {\n method: 'POST',\n headers: { ...(options.headers ?? {}) },\n body: options.body,\n signal,\n redirect: 'manual',\n },\n policy,\n deps,\n signal,\n );\n if (!('response' in exchange)) return { ok: false, rejection: exchange };\n try {\n const response = exchange.response;\n if (response.status >= 300 && response.status < 400) {\n await response.body?.cancel().catch(() => undefined);\n return {\n ok: false,\n rejection: {\n reason: 'redirect_refused',\n url: target.href,\n message: `HTTP ${response.status}: a POST is never redirected.`,\n },\n };\n }\n return await readUnderCap(response, target.href, maxBytes, signal);\n } finally {\n await exchange.close();\n }\n}\n\n/** On a cross-origin hop nothing the caller supplied travels on — only the identifying User-Agent. */\nfunction stripSensitiveHeaders(headers: Record<string, string>): Record<string, string> {\n const kept: Record<string, string> = {};\n for (const [name, value] of Object.entries(headers)) {\n if (name.toLowerCase() === 'user-agent') kept[name] = value;\n }\n return kept;\n}\n\nasync function readUnderCap(\n response: Response,\n finalUrl: string,\n maxBytes: number,\n signal: AbortSignal,\n): Promise<TEgressFetchResult> {\n const tooLarge = (seen: number): TEgressFetchResult => ({\n ok: false,\n rejection: {\n reason: 'response_too_large',\n url: finalUrl,\n message: `Response exceeds ${maxBytes} bytes (${seen} seen).`,\n },\n });\n const declared = Number(response.headers.get('content-length'));\n if (Number.isFinite(declared) && declared > maxBytes) {\n await response.body?.cancel();\n return tooLarge(declared);\n }\n const chunks: Uint8Array[] = [];\n let total = 0;\n if (!response.body && typeof response.arrayBuffer === 'function') {\n // A carrier with no readable stream (a body-less Response, or a non-streaming fetch\n // implementation) can only be read whole; the cap is then checked on what it handed over.\n const whole = new Uint8Array(await response.arrayBuffer());\n if (whole.byteLength > maxBytes) return tooLarge(whole.byteLength);\n chunks.push(whole);\n total = whole.byteLength;\n } else if (response.body) {\n const reader = response.body.getReader();\n for (;;) {\n signal.throwIfAborted();\n const { done, value } = await reader.read();\n if (done) break;\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n return tooLarge(total);\n }\n chunks.push(value);\n }\n }\n const body = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n body.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return {\n ok: true,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n body,\n finalUrl,\n };\n}\n"],"mappings":"6fA2BA,SAAgB,EAA4B,EAAwB,CAClE,GAAI,OAAO,GAAU,SACnB,MAAU,UAAU,gCAAgC,EAEtD,GAAI,EAAM,KAAK,CAAC,CAAC,SAAW,EAC1B,MAAU,UAAU,0CAA0C,EAEhE,GAAI,CAAC,EAAW,CAAK,EACnB,MAAU,UAAU,wCAAwC,EAG9D,IAAI,EACJ,GAAI,CACF,EAAgB,EAAa,CAAK,CACpC,MAAQ,CACN,MAAU,UAAU,0DAA0D,CAChF,CACA,GAAI,CAAC,EAAS,CAAa,CAAC,CAAC,YAAY,EACvC,MAAU,UAAU,qCAAqC,EAE3D,GAAI,CACF,EAAW,EAAe,EAAU,KAAO,EAAU,IAAI,CAC3D,MAAQ,CACN,MAAU,UAAU,0DAA0D,CAChF,CACA,OAA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MAAO,CACL,GAAI,GACJ,OAAQ,EAAS,OACjB,WAAY,EAAS,WACrB,QAAS,EAAS,QAClB,OACA,UACF,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={type:`null`};function t(e){return e.type===`null`||Array.isArray(e.anyOf)&&e.anyOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`)}function n(n){if(typeof n!=`object`||!n||Array.isArray(n))return n;let r=n;return t(r)?r:Array.isArray(r.anyOf)?{...r,anyOf:[...r.anyOf,e]}:{anyOf:[r,e]}}function r(e,t={}){return i(e,t,``)}function i(e,r,a){if(Array.isArray(e))return e.map((e,t)=>i(e,r,`${a}/${t}`));if(typeof e!=`object`||!e)return e;let o=e,s={...o},c=o.type===`object`,l=o.properties&&typeof o.properties==`object`?o.properties:void 0;if(l){let e=new Set(Array.isArray(o.required)?o.required.map(String):[]);s.properties=Object.fromEntries(Object.entries(l).map(([o,s])=>{let c=`${a}/properties/${o}`,l=i(s,r,c),u=e.has(o);if(r.requireAllProperties===!0&&!u&&r.onChange?.({path:c,kind:`required-added`}),!(r.requireAllProperties===!0&&r.optionalAsNullable===!0&&!u))return[o,l];let d=typeof l==`object`&&l&&!Array.isArray(l)?t(l):!1,f=n(l);return d||r.onChange?.({path:c,kind:`nullable-added`}),[o,f]})),r.requireAllProperties===!0&&(s.required=Object.keys(l))}return o.items&&typeof o.items==`object`&&(s.items=i(o.items,r,`${a}/items`)),Array.isArray(o.anyOf)&&(s.anyOf=o.anyOf.map((e,t)=>i(e,r,`${a}/anyOf/${t}`))),o.additionalProperties&&typeof o.additionalProperties==`object`?s.additionalProperties=i(o.additionalProperties,r,`${a}/additionalProperties`):c&&(o.additionalProperties!==!1&&r.onChange?.({path:a,kind:`closed-object`}),s.additionalProperties=!1),s}const a=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function s(e,t){return e>>>t|e<<32-t}function c(e){let t=new TextEncoder().encode(e),n=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(n);r.set(t),r[t.length]=128;let i=new DataView(r.buffer),c=BigInt(t.length)*8n;i.setUint32(n-8,Number(c>>32n&4294967295n)),i.setUint32(n-4,Number(c&4294967295n));let l=new Uint32Array(o),u=new Uint32Array(64);for(let e=0;e<n;e+=64){for(let t=0;t<16;t+=1)u[t]=i.getUint32(e+t*4);for(let e=16;e<64;e+=1){let t=u[e-15]??0,n=u[e-2]??0,r=s(t,7)^s(t,18)^t>>>3,i=s(n,17)^s(n,19)^n>>>10;u[e]=(u[e-16]??0)+r+(u[e-7]??0)+i>>>0}let t=l[0]??0,n=l[1]??0,r=l[2]??0,o=l[3]??0,c=l[4]??0,d=l[5]??0,f=l[6]??0,p=l[7]??0;for(let e=0;e<64;e+=1){let i=s(c,6)^s(c,11)^s(c,25),l=c&d^~c&f,m=p+i+l+(a[e]??0)+(u[e]??0)>>>0,h=(s(t,2)^s(t,13)^s(t,22))+(t&n^t&r^n&r)>>>0;p=f,f=d,d=c,c=o+m>>>0,o=r,r=n,n=t,t=m+h>>>0}l[0]=(l[0]??0)+t>>>0,l[1]=(l[1]??0)+n>>>0,l[2]=(l[2]??0)+r>>>0,l[3]=(l[3]??0)+o>>>0,l[4]=(l[4]??0)+c>>>0,l[5]=(l[5]??0)+d>>>0,l[6]=(l[6]??0)+f>>>0,l[7]=(l[7]??0)+p>>>0}return[...l].map(e=>e.toString(16).padStart(8,`0`)).join(``)}const l=2e3,u=Object.keys({type:!0,description:!0,enum:!0,items:!0,properties:!0,required:!0,anyOf:!0,additionalProperties:!0,minimum:!0,maximum:!0,pattern:!0,format:!0,default:!0}),d=new Set(u),f=new Set([`__proto__`,`constructor`,`prototype`]),p=new Set([`title`,`$schema`,`$comment`,`examples`,`default`]);function m(){return{anyOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`object`},{type:`array`},{type:`null`}]}}const h={closedObjects:!1,requireAllProperties:!1,optionalAsNullable:!1,unknownKeywords:`adopt`,unsupportedMembers:[],maxDepth:32,maxNodes:l},g={closedObjects:!0,requireAllProperties:!0,optionalAsNullable:!0,unknownKeywords:`strip`,unsupportedMembers:[],maxDepth:32,maxNodes:l};function _(e,t){return`${e}/${t}`}function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function y(e,t,n,r,i,a){if(!v(e))return;if(r.has(e))return{path:t,keyword:`cycle`,reason:`object graph revisits a node on its own ancestor chain (cycle)`};if(r.add(e),n>a.maxDepth)return{path:t,keyword:`maxDepth`,reason:`nesting depth exceeds maxDepth (${a.maxDepth})`};if(i.count+=1,i.count>a.maxNodes)return{path:t,keyword:`maxNodes`,reason:`node count exceeds maxNodes (${a.maxNodes})`};if(a.unknownKeywords===`reject`){for(let n of Object.keys(e))if(!d.has(n))return{path:t,keyword:n,reason:`unknown keyword '${n}' is outside the IParameterSchema member set`}}let o=typeof e.type==`string`,s=Array.isArray(e.anyOf);if(o&&s)return{path:t,keyword:`anyOf`,reason:`a node must declare exactly one of 'type' or 'anyOf', not both`};if(!o&&!s&&!Object.keys(e).some(e=>!d.has(e)))return{path:t,keyword:`type`,reason:`a node must declare exactly one of 'type' or 'anyOf'`};let c=e.properties;if(v(c)){for(let e of Object.keys(c))if(f.has(e))return{path:_(_(t,`properties`),e),keyword:e,reason:`property name '${e}' is a prototype key`};for(let e of Object.keys(c)){let o=y(c[e],_(_(t,`properties`),e),n+1,r,i,a);if(o)return o}}if(v(e.items)){let o=y(e.items,_(t,`items`),n+1,r,i,a);if(o)return o}if(Array.isArray(e.anyOf))for(let o=0;o<e.anyOf.length;o+=1){let s=y(e.anyOf[o],_(_(t,`anyOf`),String(o)),n+1,r,i,a);if(s)return s}r.delete(e)}function b(e,t,n,r){let i={...e};for(let e of n.unsupportedMembers){let n=e;n in i&&(delete i[n],r.push({path:t,kind:`member-stripped`,keyword:n}))}if(n.unknownKeywords===`strip`){let e=Object.keys(i).filter(e=>!d.has(e));for(let t of e)delete i[t];let n=typeof i.type==`string`,a=Array.isArray(i.anyOf);if(e.length>0&&!n&&!a){for(let n of e)r.push({path:t,kind:`keyword-replaced`,keyword:n});let n=m();for(let e of Object.keys(i))e===`description`?n.description=i.description:r.push({path:t,kind:`member-stripped`,keyword:e});return n}for(let n of e)r.push({path:t,kind:`keyword-stripped`,keyword:n})}let a=i.properties;return v(a)&&(i.properties=Object.fromEntries(Object.keys(a).map(e=>{let i=a[e];return[e,v(i)?b(i,_(_(t,`properties`),e),n,r):i]}))),v(i.items)&&(i.items=b(i.items,_(t,`items`),n,r)),Array.isArray(i.anyOf)&&(i.anyOf=i.anyOf.map((e,i)=>v(e)?b(e,_(_(t,`anyOf`),String(i)),n,r):e)),i}function x(e){if(Array.isArray(e))return e.map(x);if(v(e)){let t={};for(let n of Object.keys(e).sort())t[n]=x(e[n]);return t}return e}function S(e){return c(JSON.stringify(x(e)))}function C(e,t){let n=e.parameters;if(!v(n)||n.type!==`object`)return{outcome:`rejected`,tool:e,changes:[],rejection:{path:``,keyword:`type`,reason:`the parameters root must declare type: 'object' — no documented provider accepts another root`}};let i=y(n,``,0,new Set,{count:0},t);if(i)return{outcome:`rejected`,tool:e,changes:[],rejection:i};let a=[],o=b(n,``,t,a),s=t.closedObjects?r(o,{requireAllProperties:t.requireAllProperties,optionalAsNullable:t.optionalAsNullable,onChange:e=>a.push(e)}):o;if(a.length===0)return{outcome:`adopted`,tool:e,changes:[]};let c=a.filter(e=>(e.kind===`keyword-stripped`||e.kind===`keyword-replaced`||e.kind===`member-stripped`)&&!p.has(e.keyword??``)),l=c.length===0?e.description:`${e.description}\n\nSchema note: ${c.length} constraint(s) not shown to ${t.providerName}: ${c.map(e=>`${e.kind}@${e.path}`).join(`, `)}`;return{outcome:`adapted`,tool:{...e,parameters:s,description:l},changes:a}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return 32}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={type:`null`};function t(e){return e.type===`null`||Array.isArray(e.anyOf)&&e.anyOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`)}function n(n){if(typeof n!=`object`||!n||Array.isArray(n))return n;let r=n;return t(r)?r:Array.isArray(r.anyOf)?{...r,anyOf:[...r.anyOf,e]}:{anyOf:[r,e]}}function r(e,t={}){return i(e,t,``)}function i(e,r,a){if(Array.isArray(e))return e.map((e,t)=>i(e,r,`${a}/${t}`));if(typeof e!=`object`||!e)return e;let o=e,s={...o},c=o.type===`object`,l=o.properties&&typeof o.properties==`object`?o.properties:void 0;if(l){let e=new Set(Array.isArray(o.required)?o.required.map(String):[]);s.properties=Object.fromEntries(Object.entries(l).map(([o,s])=>{let c=`${a}/properties/${o}`,l=i(s,r,c),u=e.has(o);if(r.requireAllProperties===!0&&!u&&r.onChange?.({path:c,kind:`required-added`}),!(r.requireAllProperties===!0&&r.optionalAsNullable===!0&&!u))return[o,l];let d=typeof l==`object`&&l&&!Array.isArray(l)?t(l):!1,f=n(l);return d||r.onChange?.({path:c,kind:`nullable-added`}),[o,f]})),r.requireAllProperties===!0&&(s.required=Object.keys(l))}return o.items&&typeof o.items==`object`&&(s.items=i(o.items,r,`${a}/items`)),Array.isArray(o.anyOf)&&(s.anyOf=o.anyOf.map((e,t)=>i(e,r,`${a}/anyOf/${t}`))),o.additionalProperties&&typeof o.additionalProperties==`object`?s.additionalProperties=i(o.additionalProperties,r,`${a}/additionalProperties`):c&&(o.additionalProperties!==!1&&r.onChange?.({path:a,kind:`closed-object`}),s.additionalProperties=!1),s}const a=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function s(e,t){return e>>>t|e<<32-t}function c(e){let t=new TextEncoder().encode(e),n=Math.ceil((t.length+9)/64)*64,r=new Uint8Array(n);r.set(t),r[t.length]=128;let i=new DataView(r.buffer),c=BigInt(t.length)*8n;i.setUint32(n-8,Number(c>>32n&4294967295n)),i.setUint32(n-4,Number(c&4294967295n));let l=new Uint32Array(o),u=new Uint32Array(64);for(let e=0;e<n;e+=64){for(let t=0;t<16;t+=1)u[t]=i.getUint32(e+t*4);for(let e=16;e<64;e+=1){let t=u[e-15]??0,n=u[e-2]??0,r=s(t,7)^s(t,18)^t>>>3,i=s(n,17)^s(n,19)^n>>>10;u[e]=(u[e-16]??0)+r+(u[e-7]??0)+i>>>0}let t=l[0]??0,n=l[1]??0,r=l[2]??0,o=l[3]??0,c=l[4]??0,d=l[5]??0,f=l[6]??0,p=l[7]??0;for(let e=0;e<64;e+=1){let i=s(c,6)^s(c,11)^s(c,25),l=c&d^~c&f,m=p+i+l+(a[e]??0)+(u[e]??0)>>>0,h=(s(t,2)^s(t,13)^s(t,22))+(t&n^t&r^n&r)>>>0;p=f,f=d,d=c,c=o+m>>>0,o=r,r=n,n=t,t=m+h>>>0}l[0]=(l[0]??0)+t>>>0,l[1]=(l[1]??0)+n>>>0,l[2]=(l[2]??0)+r>>>0,l[3]=(l[3]??0)+o>>>0,l[4]=(l[4]??0)+c>>>0,l[5]=(l[5]??0)+d>>>0,l[6]=(l[6]??0)+f>>>0,l[7]=(l[7]??0)+p>>>0}return[...l].map(e=>e.toString(16).padStart(8,`0`)).join(``)}const l=32,u=2e3,d=Object.keys({type:!0,description:!0,enum:!0,items:!0,properties:!0,required:!0,anyOf:!0,additionalProperties:!0,minimum:!0,maximum:!0,pattern:!0,format:!0,default:!0}),f=new Set(d),p=new Set([`__proto__`,`constructor`,`prototype`]),m=new Set([`title`,`$schema`,`$comment`,`examples`,`default`]);function h(){return{anyOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`object`},{type:`array`},{type:`null`}]}}const g={closedObjects:!1,requireAllProperties:!1,optionalAsNullable:!1,unknownKeywords:`adopt`,unsupportedMembers:[],maxDepth:32,maxNodes:u},_={closedObjects:!0,requireAllProperties:!0,optionalAsNullable:!0,unknownKeywords:`strip`,unsupportedMembers:[],maxDepth:32,maxNodes:u};function v(e,t){return`${e}/${t}`}function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e,t,n,r,i,a){if(!y(e))return;if(r.has(e))return{path:t,keyword:`cycle`,reason:`object graph revisits a node on its own ancestor chain (cycle)`};if(r.add(e),n>a.maxDepth)return{path:t,keyword:`maxDepth`,reason:`nesting depth exceeds maxDepth (${a.maxDepth})`};if(i.count+=1,i.count>a.maxNodes)return{path:t,keyword:`maxNodes`,reason:`node count exceeds maxNodes (${a.maxNodes})`};if(a.unknownKeywords===`reject`){for(let n of Object.keys(e))if(!f.has(n))return{path:t,keyword:n,reason:`unknown keyword '${n}' is outside the IParameterSchema member set`}}let o=typeof e.type==`string`,s=Array.isArray(e.anyOf);if(o&&s)return{path:t,keyword:`anyOf`,reason:`a node must declare exactly one of 'type' or 'anyOf', not both`};if(!o&&!s&&!Object.keys(e).some(e=>!f.has(e)))return{path:t,keyword:`type`,reason:`a node must declare exactly one of 'type' or 'anyOf'`};let c=e.properties;if(y(c)){for(let e of Object.keys(c))if(p.has(e))return{path:v(v(t,`properties`),e),keyword:e,reason:`property name '${e}' is a prototype key`};for(let e of Object.keys(c)){let o=b(c[e],v(v(t,`properties`),e),n+1,r,i,a);if(o)return o}}if(y(e.items)){let o=b(e.items,v(t,`items`),n+1,r,i,a);if(o)return o}if(Array.isArray(e.anyOf))for(let o=0;o<e.anyOf.length;o+=1){let s=b(e.anyOf[o],v(v(t,`anyOf`),String(o)),n+1,r,i,a);if(s)return s}r.delete(e)}function x(e,t,n,r){let i={...e};for(let e of n.unsupportedMembers){let n=e;n in i&&(delete i[n],r.push({path:t,kind:`member-stripped`,keyword:n}))}if(n.unknownKeywords===`strip`){let e=Object.keys(i).filter(e=>!f.has(e));for(let t of e)delete i[t];let n=typeof i.type==`string`,a=Array.isArray(i.anyOf);if(e.length>0&&!n&&!a){for(let n of e)r.push({path:t,kind:`keyword-replaced`,keyword:n});let n=h();for(let e of Object.keys(i))e===`description`?n.description=i.description:r.push({path:t,kind:`member-stripped`,keyword:e});return n}for(let n of e)r.push({path:t,kind:`keyword-stripped`,keyword:n})}let a=i.properties;return y(a)&&(i.properties=Object.fromEntries(Object.keys(a).map(e=>{let i=a[e];return[e,y(i)?x(i,v(v(t,`properties`),e),n,r):i]}))),y(i.items)&&(i.items=x(i.items,v(t,`items`),n,r)),Array.isArray(i.anyOf)&&(i.anyOf=i.anyOf.map((e,i)=>y(e)?x(e,v(v(t,`anyOf`),String(i)),n,r):e)),i}function S(e){if(Array.isArray(e))return e.map(S);if(y(e)){let t={};for(let n of Object.keys(e).sort())t[n]=S(e[n]);return t}return e}function C(e){return c(JSON.stringify(S(e)))}function w(e,t){let n=e.parameters;if(!y(n)||n.type!==`object`)return{outcome:`rejected`,tool:e,changes:[],rejection:{path:``,keyword:`type`,reason:`the parameters root must declare type: 'object' — no documented provider accepts another root`}};let i=b(n,``,0,new Set,{count:0},t);if(i)return{outcome:`rejected`,tool:e,changes:[],rejection:i};let a=[],o=x(n,``,t,a),s=t.closedObjects?r(o,{requireAllProperties:t.requireAllProperties,optionalAsNullable:t.optionalAsNullable,onChange:e=>a.push(e)}):o;if(a.length===0)return{outcome:`adopted`,tool:e,changes:[]};let c=a.filter(e=>(e.kind===`keyword-stripped`||e.kind===`keyword-replaced`||e.kind===`member-stripped`)&&!m.has(e.keyword??``)),l=c.length===0?e.description:`${e.description}\n\nSchema note: ${c.length} constraint(s) not shown to ${t.providerName}: ${c.map(e=>`${e.kind}@${e.path}`).join(`, `)}`;return{outcome:`adapted`,tool:{...e,parameters:s,description:l},changes:a}}export{u as a,r as c,l as i,g as n,C as o,_ as r,w as s,d as t};
|
|
2
|
+
//# sourceMappingURL=project-tool-schema-_UKfY7yO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-tool-schema-_UKfY7yO.js","names":[],"sources":["../../src/schema/close-object-schemas.ts","../../src/schema/sha256.ts","../../src/schema/project-tool-schema.ts"],"sourcesContent":["/**\n * Closing the universal schema subset for providers that reject open-world objects. PROV-007.\n *\n * Two vendors demand a closed schema and neither accepts what this repository emits. Anthropic's\n * structured-output surface requires every `object` node to carry `additionalProperties: false`;\n * OpenAI's strict mode requires that AND that every object list all of its properties in `required`.\n * The universal subset guarantees neither — a Zod-derived node emits `additionalProperties: true`\n * for Zod's default `strip` and for `.passthrough()`, a hand-written one may omit the member, and\n * `required` lists only the genuinely-required fields.\n *\n * ONE recursion, not one per vendor. Anthropic had its own copy and OpenAI was about to get a third;\n * CORE-039 exists because a walk over this subset that misses a route — it missed `anyOf` — leaves\n * exactly the nodes it was written to fix untouched, and every copy has to be found and fixed\n * separately. The vendors differ in POLICY, so the policy is an argument.\n *\n * The consumer's original schema still governs core-side validation. This is an SDK-seam\n * transformation, applied on the way out.\n */\n\n/** One structural edit `closeObjectSchemas` made, at the JSON-pointer-like path it made it. */\nexport interface ISchemaClosureChange {\n readonly path: string;\n readonly kind: 'closed-object' | 'required-added' | 'nullable-added';\n}\n\n/** How far to close, which is where the two vendors differ. */\nexport interface ISchemaClosureOptions {\n /**\n * Also list every property of every object in `required` — OpenAI strict mode.\n *\n * This is LOSSY: it forces genuinely-optional fields into `required`. `optionalAsNullable` is how\n * that is compensated, and the two are meant to travel together.\n */\n requireAllProperties?: boolean;\n /**\n * Give a property that was optional a `null` branch once it is forced into `required`.\n *\n * The representation strict mode has no faithful mapping for, decided here rather than left to\n * each call site: a field the caller marked optional becomes required-but-nullable, which is the\n * compensation OpenAI documents. `anyOf: [T, { type: 'null' }]` is chosen because that is already\n * how this subset expresses a nullable value (CORE-039 emits it for Zod's `.nullable()`), so a\n * forced-optional field and a genuinely nullable one are indistinguishable on the wire — which is\n * the point. Anything else would invent a second nullability spelling for one vendor.\n */\n optionalAsNullable?: boolean;\n /**\n * MCP-005: told once per actual structural edit, so a caller (the tool-schema projector) can build\n * a diagnostic without re-deriving this recursion — one walk, not a second copy that could disagree\n * with this one about which route a nested object arrives by.\n */\n onChange?: (change: ISchemaClosureChange) => void;\n}\n\nconst NULL_BRANCH = { type: 'null' } as const;\n\n/** Whether this node already admits `null`, so the branch is not added twice. */\nfunction admitsNull(node: Record<string, unknown>): boolean {\n if (node.type === 'null') return true;\n return (\n Array.isArray(node.anyOf) &&\n node.anyOf.some(\n (branch) =>\n typeof branch === 'object' &&\n branch !== null &&\n (branch as Record<string, unknown>).type === 'null',\n )\n );\n}\n\n/** Wrap a property schema so it accepts `null` as well as its own shape. */\nfunction withNullBranch(value: unknown): unknown {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return value;\n }\n const node = value as Record<string, unknown>;\n if (admitsNull(node)) return node;\n if (Array.isArray(node.anyOf)) {\n return { ...node, anyOf: [...node.anyOf, NULL_BRANCH] };\n }\n return { anyOf: [node, NULL_BRANCH] };\n}\n\n/**\n * Close every object node in a schema, recursively.\n *\n * Walks `properties`, `items`, `anyOf` and a schema-valued `additionalProperties` — every route a\n * nested object can arrive by in this subset. A route left unwalked is a nested object silently left\n * open, which is the failure this function exists to prevent.\n */\nexport function closeObjectSchemas(node: unknown, options: ISchemaClosureOptions = {}): unknown {\n return closeObjectSchemasAt(node, options, '');\n}\n\nfunction closeObjectSchemasAt(\n node: unknown,\n options: ISchemaClosureOptions,\n path: string,\n): unknown {\n if (Array.isArray(node)) {\n return node.map((entry, index) => closeObjectSchemasAt(entry, options, `${path}/${index}`));\n }\n if (typeof node !== 'object' || node === null) {\n return node;\n }\n\n const record = node as Record<string, unknown>;\n const closed: Record<string, unknown> = { ...record };\n const isObjectNode = record.type === 'object';\n const properties =\n record.properties && typeof record.properties === 'object'\n ? (record.properties as Record<string, unknown>)\n : undefined;\n\n if (properties) {\n const required = new Set(\n Array.isArray(record.required) ? (record.required as unknown[]).map(String) : [],\n );\n closed.properties = Object.fromEntries(\n Object.entries(properties).map(([key, value]) => {\n const propertyPath = `${path}/properties/${key}`;\n const child = closeObjectSchemasAt(value, options, propertyPath);\n const wasRequired = required.has(key);\n if (options.requireAllProperties === true && !wasRequired) {\n options.onChange?.({ path: propertyPath, kind: 'required-added' });\n }\n // Only a property that was NOT already required is compensated. A genuinely required field\n // gaining a null branch would widen the contract rather than preserve it.\n const forcedIntoRequired =\n options.requireAllProperties === true &&\n options.optionalAsNullable === true &&\n !wasRequired;\n if (!forcedIntoRequired) {\n return [key, child];\n }\n const childAlreadyNullable =\n typeof child === 'object' && child !== null && !Array.isArray(child)\n ? admitsNull(child as Record<string, unknown>)\n : false;\n const wrapped = withNullBranch(child);\n if (!childAlreadyNullable) {\n options.onChange?.({ path: propertyPath, kind: 'nullable-added' });\n }\n return [key, wrapped];\n }),\n );\n if (options.requireAllProperties === true) {\n closed.required = Object.keys(properties);\n }\n }\n\n if (record.items && typeof record.items === 'object') {\n closed.items = closeObjectSchemasAt(record.items, options, `${path}/items`);\n }\n\n // CORE-039: a union node's branches are objects too. Without this the spread carries `anyOf`\n // through unrecursed, leaving every object inside a branch open — the exact thing this seam\n // exists to prevent, reached by the one route it did not walk.\n if (Array.isArray(record.anyOf)) {\n closed.anyOf = record.anyOf.map((branch, index) =>\n closeObjectSchemasAt(branch, options, `${path}/anyOf/${index}`),\n );\n }\n\n if (record.additionalProperties && typeof record.additionalProperties === 'object') {\n // Schema-valued `additionalProperties` (record types) passes through recursed; a vendor may\n // reject it, which surfaces as a provider error rather than being masked here.\n closed.additionalProperties = closeObjectSchemasAt(\n record.additionalProperties,\n options,\n `${path}/additionalProperties`,\n );\n } else if (isObjectNode) {\n // Deliberate overwrite, including of an explicit `true`. The converter emits\n // `additionalProperties: true` routinely — Zod's default `strip` means \"accept then drop\" — and\n // these vendors still require every object node closed. The consumer's original schema keeps\n // governing core-side validation, where the `true` is honoured.\n if (record.additionalProperties !== false) {\n options.onChange?.({ path, kind: 'closed-object' });\n }\n closed.additionalProperties = false;\n }\n\n return closed;\n}\n","/** Synchronous SHA-256 over UTF-8, shared by the Node and browser core bundles. */\nconst ROUND_CONSTANTS = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nconst INITIAL_HASH = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\nfunction rotateRight(value: number, bits: number): number {\n return (value >>> bits) | (value << (32 - bits));\n}\n\nexport function sha256Hex(input: string): string {\n const bytes = new TextEncoder().encode(input);\n const paddedLength = Math.ceil((bytes.length + 9) / 64) * 64;\n const padded = new Uint8Array(paddedLength);\n padded.set(bytes);\n padded[bytes.length] = 0x80;\n const view = new DataView(padded.buffer);\n const bitLength = BigInt(bytes.length) * 8n;\n view.setUint32(paddedLength - 8, Number((bitLength >> 32n) & 0xffff_ffffn));\n view.setUint32(paddedLength - 4, Number(bitLength & 0xffff_ffffn));\n\n const hash = new Uint32Array(INITIAL_HASH);\n const words = new Uint32Array(64);\n for (let offset = 0; offset < paddedLength; offset += 64) {\n for (let index = 0; index < 16; index += 1) {\n words[index] = view.getUint32(offset + index * 4);\n }\n for (let index = 16; index < 64; index += 1) {\n const left = words[index - 15] ?? 0;\n const right = words[index - 2] ?? 0;\n const small0 = rotateRight(left, 7) ^ rotateRight(left, 18) ^ (left >>> 3);\n const small1 = rotateRight(right, 17) ^ rotateRight(right, 19) ^ (right >>> 10);\n words[index] = ((words[index - 16] ?? 0) + small0 + (words[index - 7] ?? 0) + small1) >>> 0;\n }\n\n let a = hash[0] ?? 0;\n let b = hash[1] ?? 0;\n let c = hash[2] ?? 0;\n let d = hash[3] ?? 0;\n let e = hash[4] ?? 0;\n let f = hash[5] ?? 0;\n let g = hash[6] ?? 0;\n let h = hash[7] ?? 0;\n for (let index = 0; index < 64; index += 1) {\n const big1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);\n const choose = (e & f) ^ (~e & g);\n const temp1 = (h + big1 + choose + (ROUND_CONSTANTS[index] ?? 0) + (words[index] ?? 0)) >>> 0;\n const big0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);\n const majority = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (big0 + majority) >>> 0;\n h = g;\n g = f;\n f = e;\n e = (d + temp1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (temp1 + temp2) >>> 0;\n }\n hash[0] = ((hash[0] ?? 0) + a) >>> 0;\n hash[1] = ((hash[1] ?? 0) + b) >>> 0;\n hash[2] = ((hash[2] ?? 0) + c) >>> 0;\n hash[3] = ((hash[3] ?? 0) + d) >>> 0;\n hash[4] = ((hash[4] ?? 0) + e) >>> 0;\n hash[5] = ((hash[5] ?? 0) + f) >>> 0;\n hash[6] = ((hash[6] ?? 0) + g) >>> 0;\n hash[7] = ((hash[7] ?? 0) + h) >>> 0;\n }\n return [...hash].map((word) => word.toString(16).padStart(8, '0')).join('');\n}\n","/**\n * Project an MCP tool's schema into what one provider's wire format can actually carry — MCP-005.\n *\n * Four converters used to reshape `IToolSchema.parameters` independently and disagreed with each\n * other and with the provider APIs (Anthropic cast it straight through, the openai-compatible family\n * shallow-spread it, OpenAI closed objects only when `strictTools` was on, Gemini rebuilt it field by\n * field and silently dropped anything it did not copy). A schema a provider rejects failed the WHOLE\n * request, or was silently narrowed. `projectToolSchema` is the one shared, tested projector every\n * provider calls instead: pure, deterministic, never throws, never mutates its input. A tool that\n * cannot be projected is REJECTED with a structured diagnostic — never dropped silently, never sent\n * in another shape (No Fallback Policy).\n *\n * This is NOT a second validator. CORE-040 (`agent-mcp/src/third-party-schema.ts`) stays the one\n * narrowing step for untrusted third-party schemas down to `IParameterSchema`; this module only\n * projects an already-`IParameterSchema`-shaped tool down to what one provider's profile accepts.\n * The universal subset (CORE-039, `../interfaces/tool-schema.ts`) is the SSOT this module walks —\n * `PARAMETER_SCHEMA_KEYWORDS` is derived from it once, at the type level, so the two cannot drift.\n *\n * See `docs/SPEC.md` § \"Tool Schema Projection (MCP-005)\" for the full contract.\n */\n\nimport { closeObjectSchemas } from './close-object-schemas';\nimport { sha256Hex } from './sha256';\n\nimport type {\n IObjectParameterSchema,\n IParameterSchema,\n IToolSchema,\n} from '../interfaces/tool-schema';\n\n/**\n * Depth and node ceilings shared by every profile — a schema is unbounded complexity otherwise, and\n * MCP itself sets no ceiling (the incompatibility lives entirely at the provider boundary).\n */\nexport const TOOL_SCHEMA_PROJECTION_MAX_DEPTH = 32;\nexport const TOOL_SCHEMA_PROJECTION_MAX_NODES = 2000;\n\n/**\n * Every member `IParameterSchema` declares (CORE-039, `../interfaces/tool-schema.ts:48-63`), derived\n * ONCE at the type level rather than hand-typed a second time. `Required<IParameterSchema>` forces\n * this record literal to gain or lose a property whenever the interface does — a missing or\n * extraneous key here is a compile error, not a silent drift.\n */\ntype TParameterSchemaKeywordRecord = { [K in keyof Required<IParameterSchema>]: true };\nconst PARAMETER_SCHEMA_KEYWORD_RECORD: TParameterSchemaKeywordRecord = {\n type: true,\n description: true,\n enum: true,\n items: true,\n properties: true,\n required: true,\n anyOf: true,\n additionalProperties: true,\n minimum: true,\n maximum: true,\n pattern: true,\n format: true,\n default: true,\n};\n/** The `IParameterSchema` member set, as a lookup — the SSOT `unknownKeywords` judges every key against. */\nexport const PARAMETER_SCHEMA_KEYWORDS: readonly (keyof IParameterSchema)[] = Object.keys(\n PARAMETER_SCHEMA_KEYWORD_RECORD,\n) as (keyof IParameterSchema)[];\nconst PARAMETER_SCHEMA_KEYWORD_SET = new Set<string>(PARAMETER_SCHEMA_KEYWORDS);\n\n/** Property names that risk prototype pollution if ever assigned as an object key. Refused outright. */\nconst PROTOTYPE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Stripped/replaced keywords that constrain nothing (pure metadata) — removing one produces no\n * `Schema note`, unlike a validation keyword (`minLength`, `pattern`, `additionalProperties`, a\n * replaced `$ref`/`oneOf`/`allOf` node, …) whose removal actually narrows what the schema states.\n */\nconst ANNOTATION_ONLY_KEYWORDS = new Set(['title', '$schema', '$comment', 'examples', 'default']);\n\n/**\n * A node that accepts any JSON value, expressed IN the universal subset — the same shape CORE-040\n * substitutes for an inexpressible node (`agent-mcp/src/third-party-schema.ts`, `anyValueNode`).\n * Replacing (not deleting) a structurally-empty node keeps a declared property declared: an object\n * node with `properties` is CLOSED relative to that set, so deleting the key would turn it into an\n * \"unexpected additional property\" instead of a value whose shape merely could not be projected.\n */\nfunction anyValueNode(): IParameterSchema {\n return {\n anyOf: [\n { type: 'string' },\n { type: 'number' },\n { type: 'boolean' },\n { type: 'object' },\n { type: 'array' },\n { type: 'null' },\n ],\n };\n}\n\n/** How one provider's wire format constrains the universal subset it is handed. */\nexport interface IToolSchemaProjectionProfile {\n /** Named in the `Schema note` and the quarantine line. */\n readonly providerName: string;\n /** `additionalProperties: false` on every object node. */\n readonly closedObjects: boolean;\n /** Every property listed in `required` (lossy — pairs with `optionalAsNullable`). */\n readonly requireAllProperties: boolean;\n /** An optional property becomes `anyOf: [T, { type: 'null' }]` once forced into `required`. */\n readonly optionalAsNullable: boolean;\n /** Keywords outside the `IParameterSchema` member set: pass through, remove/replace, or refuse. */\n readonly unknownKeywords: 'adopt' | 'strip' | 'reject';\n /** Subset members this provider's wire type cannot carry — stripped AND recorded (Gemini: `additionalProperties`). */\n readonly unsupportedMembers: readonly (keyof IParameterSchema)[];\n /** Nesting depth over which a schema is rejected (unbounded complexity). */\n readonly maxDepth: number;\n /** Node count over which a schema is rejected. */\n readonly maxNodes: number;\n}\n\n/**\n * `PERMISSIVE`/`STRICT` without a `providerName` — the two profile SHAPES named providers spread\n * their own name onto (`{ ...PERMISSIVE_TOOL_SCHEMA_PROFILE, providerName: 'anthropic' }`).\n */\nexport type TToolSchemaProjectionProfileBase = Omit<IToolSchemaProjectionProfile, 'providerName'>;\n\n/**\n * Anthropic; OpenAI Chat Completions and Responses without `strictTools`; the openai-compatible\n * family (gemma, qwen incl. its Responses surface, deepseek). Standard JSON Schema passes through —\n * stripping it would be lossy for nothing.\n */\nexport const PERMISSIVE_TOOL_SCHEMA_PROFILE: TToolSchemaProjectionProfileBase = {\n closedObjects: false,\n requireAllProperties: false,\n optionalAsNullable: false,\n unknownKeywords: 'adopt',\n unsupportedMembers: [],\n maxDepth: TOOL_SCHEMA_PROJECTION_MAX_DEPTH,\n maxNodes: TOOL_SCHEMA_PROJECTION_MAX_NODES,\n};\n\n/**\n * OpenAI Responses and Chat Completions with `strictTools: true`. Replaces the converter's own\n * `closeObjectSchemas` call — one closure, in one place.\n */\nexport const STRICT_TOOL_SCHEMA_PROFILE: TToolSchemaProjectionProfileBase = {\n closedObjects: true,\n requireAllProperties: true,\n optionalAsNullable: true,\n unknownKeywords: 'strip',\n unsupportedMembers: [],\n maxDepth: TOOL_SCHEMA_PROJECTION_MAX_DEPTH,\n maxNodes: TOOL_SCHEMA_PROJECTION_MAX_NODES,\n};\n\nexport type TToolSchemaProjectionOutcome = 'adopted' | 'adapted' | 'rejected';\n\nexport interface IToolSchemaProjectionChange {\n readonly path: string;\n readonly kind:\n | 'closed-object'\n | 'required-added'\n | 'nullable-added'\n | 'keyword-stripped'\n | 'keyword-replaced'\n | 'member-stripped';\n readonly keyword?: string;\n}\n\nexport interface IToolSchemaProjection {\n readonly outcome: TToolSchemaProjectionOutcome;\n /** adopted: the input (same reference); adapted: the projected copy; rejected: the input. */\n readonly tool: IToolSchema;\n readonly changes: readonly IToolSchemaProjectionChange[];\n readonly rejection?: { readonly path: string; readonly keyword: string; readonly reason: string };\n}\n\ninterface IRejection {\n readonly path: string;\n readonly keyword: string;\n readonly reason: string;\n}\n\n/** JSON-pointer-like path join — `''` at the root, `/properties/foo/items` below it. */\nfunction childPath(path: string, segment: string): string {\n return `${path}/${segment}`;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * The refusal walk (§ Decision, \"Refusals\"). Depth and node count are counted over the WHOLE graph,\n * not just the branch that eventually fails, so two calls on the same schema agree regardless of\n * which branch a caller happens to look at (determinism).\n */\nfunction findRejection(\n node: unknown,\n path: string,\n depth: number,\n visited: Set<object>,\n counter: { count: number },\n profile: IToolSchemaProjectionProfile,\n): IRejection | undefined {\n if (!isPlainRecord(node)) {\n return undefined;\n }\n // `visited` is the ANCESTOR chain, not a whole-graph set: a node is added on entry and removed on\n // exit below, so only a node that appears inside its own subtree (a true cycle) is refused. A DAG —\n // the same sub-schema object reused by two sibling properties or branches, common in hand-built\n // in-process tools — is walked twice and accepted (pr-review-reviewer, MCP-005 Round A).\n if (visited.has(node)) {\n return {\n path,\n keyword: 'cycle',\n reason: 'object graph revisits a node on its own ancestor chain (cycle)',\n };\n }\n visited.add(node);\n\n if (depth > profile.maxDepth) {\n return {\n path,\n keyword: 'maxDepth',\n reason: `nesting depth exceeds maxDepth (${profile.maxDepth})`,\n };\n }\n counter.count += 1;\n if (counter.count > profile.maxNodes) {\n return {\n path,\n keyword: 'maxNodes',\n reason: `node count exceeds maxNodes (${profile.maxNodes})`,\n };\n }\n\n // `'reject'` treats ANY foreign keyword as fatal by itself, named ahead of the structural check\n // below so the reported reason names the actual offending keyword rather than the generic\n // type/anyOf shape it happens to also violate.\n if (profile.unknownKeywords === 'reject') {\n for (const key of Object.keys(node)) {\n if (!PARAMETER_SCHEMA_KEYWORD_SET.has(key)) {\n return {\n path,\n keyword: key,\n reason: `unknown keyword '${key}' is outside the IParameterSchema member set`,\n };\n }\n }\n }\n\n const hasType = typeof node.type === 'string';\n const hasAnyOf = Array.isArray(node.anyOf);\n if (hasType && hasAnyOf) {\n return {\n path,\n keyword: 'anyOf',\n reason: \"a node must declare exactly one of 'type' or 'anyOf', not both\",\n };\n }\n if (!hasType && !hasAnyOf) {\n // A node whose ONLY structural indicator is a foreign keyword ($ref/oneOf/allOf — ordinary JSON\n // Schema this repo does not model) is not universally refused when the profile has a way to carry\n // it: `'adopt'` passes it through untouched (Anthropic and OpenAI non-strict accept standard JSON\n // Schema), and `'strip'` deletes the keyword and, finding the node then empty, REPLACES it with\n // the accept-anything node rather than losing the declared property. `'reject'` never reaches\n // here for such a node — the scan above already refused it by keyword. A node with NO foreign\n // keyword at all — genuinely empty, or carrying only other subset members — has nothing to defer\n // to and stays universally refused under every policy.\n const hasForeignKey = Object.keys(node).some((key) => !PARAMETER_SCHEMA_KEYWORD_SET.has(key));\n if (!hasForeignKey) {\n return {\n path,\n keyword: 'type',\n reason: \"a node must declare exactly one of 'type' or 'anyOf'\",\n };\n }\n }\n\n const properties = node.properties;\n if (isPlainRecord(properties)) {\n for (const key of Object.keys(properties)) {\n if (PROTOTYPE_KEYS.has(key)) {\n return {\n path: childPath(childPath(path, 'properties'), key),\n keyword: key,\n reason: `property name '${key}' is a prototype key`,\n };\n }\n }\n for (const key of Object.keys(properties)) {\n const rejection = findRejection(\n properties[key],\n childPath(childPath(path, 'properties'), key),\n depth + 1,\n visited,\n counter,\n profile,\n );\n if (rejection) return rejection;\n }\n }\n\n if (isPlainRecord(node.items)) {\n const rejection = findRejection(\n node.items,\n childPath(path, 'items'),\n depth + 1,\n visited,\n counter,\n profile,\n );\n if (rejection) return rejection;\n }\n\n if (Array.isArray(node.anyOf)) {\n for (let index = 0; index < node.anyOf.length; index += 1) {\n const rejection = findRejection(\n node.anyOf[index],\n childPath(childPath(path, 'anyOf'), String(index)),\n depth + 1,\n visited,\n counter,\n profile,\n );\n if (rejection) return rejection;\n }\n }\n\n visited.delete(node);\n return undefined;\n}\n\n/**\n * The adaptation walk: `unsupportedMembers`, then `unknownKeywords`, at every node; recurses into\n * every route a nested node can arrive by (`properties`, `items`, `anyOf`) so a missed route cannot\n * leave the exact thing this walk exists to fix untouched (the CORE-039 lesson). Closure is NOT done\n * here — it delegates to `closeObjectSchemas` once, afterwards, over the whole result.\n */\nfunction adaptNode(\n node: Record<string, unknown>,\n path: string,\n profile: IToolSchemaProjectionProfile,\n changes: IToolSchemaProjectionChange[],\n): Record<string, unknown> {\n const current: Record<string, unknown> = { ...node };\n\n for (const member of profile.unsupportedMembers) {\n const key = member as string;\n if (key in current) {\n delete current[key];\n changes.push({ path, kind: 'member-stripped', keyword: key });\n }\n }\n\n if (profile.unknownKeywords === 'strip') {\n const foreign = Object.keys(current).filter((key) => !PARAMETER_SCHEMA_KEYWORD_SET.has(key));\n for (const key of foreign) delete current[key];\n const hasType = typeof current.type === 'string';\n const hasAnyOf = Array.isArray(current.anyOf);\n if (foreign.length > 0 && !hasType && !hasAnyOf) {\n // The node's structural indicator was a foreign keyword ($ref/oneOf/allOf): the node is REPLACED\n // by the accept-anything node, one `keyword-replaced` per foreign keyword. Legitimate members that\n // sat beside it are not lost silently: `description` travels onto the replacement (it constrains\n // nothing); every other survivor is recorded as `member-stripped` so the loss reaches the Schema\n // note (pr-review-reviewer, MCP-005 Round A — the `$ref` + local `description` idiom).\n for (const key of foreign) changes.push({ path, kind: 'keyword-replaced', keyword: key });\n const replacement = anyValueNode() as unknown as Record<string, unknown>;\n for (const key of Object.keys(current)) {\n if (key === 'description') {\n replacement.description = current.description;\n } else {\n changes.push({ path, kind: 'member-stripped', keyword: key });\n }\n }\n return replacement;\n }\n for (const key of foreign) changes.push({ path, kind: 'keyword-stripped', keyword: key });\n }\n\n const properties = current.properties;\n if (isPlainRecord(properties)) {\n // `Object.fromEntries` — not a manual `record[key] = value` loop — because `key` is an untrusted\n // property NAME. A prototype-key node is refused before this walk ever runs, but `fromEntries`\n // defines every entry as an own property regardless, so this route stays safe even if that\n // ordering ever changes.\n current.properties = Object.fromEntries(\n Object.keys(properties).map((key) => {\n const child = properties[key];\n return [\n key,\n isPlainRecord(child)\n ? adaptNode(child, childPath(childPath(path, 'properties'), key), profile, changes)\n : child,\n ];\n }),\n );\n }\n\n if (isPlainRecord(current.items)) {\n current.items = adaptNode(current.items, childPath(path, 'items'), profile, changes);\n }\n\n if (Array.isArray(current.anyOf)) {\n current.anyOf = current.anyOf.map((branch: unknown, index: number) =>\n isPlainRecord(branch)\n ? adaptNode(branch, childPath(childPath(path, 'anyOf'), String(index)), profile, changes)\n : branch,\n );\n }\n\n return current;\n}\n\n/** Canonical, key-sorted JSON — the same schema hashes the same regardless of authored key order. */\nfunction canonicalize(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(canonicalize);\n }\n if (isPlainRecord(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = canonicalize(value[key]);\n }\n return sorted;\n }\n return value;\n}\n\n/**\n * A stable hash of a tool's `parameters`, over canonical key-sorted JSON. Part of the `projectTools`\n * per-tool cache identity (`provider.name` + `model` + `tool.name` + this hash) — a re-registered\n * tool whose schema changed is judged and reported again, one whose schema did not is not re-reported\n * on every turn. The synchronous digest uses the same implementation in Node and browsers while\n * keeping agent-core free of runtime dependencies.\n */\nexport function hashToolSchema(parameters: IParameterSchema): string {\n return sha256Hex(JSON.stringify(canonicalize(parameters)));\n}\n\n/**\n * Project one tool's schema into what `profile` can carry. Pure, deterministic (same input → deep-\n * equal output), never throws, never mutates `tool` or `tool.parameters`.\n */\nexport function projectToolSchema(\n tool: IToolSchema,\n profile: IToolSchemaProjectionProfile,\n): IToolSchemaProjection {\n const root: unknown = tool.parameters;\n if (!isPlainRecord(root) || root.type !== 'object') {\n return {\n outcome: 'rejected',\n tool,\n changes: [],\n rejection: {\n path: '',\n keyword: 'type',\n reason:\n \"the parameters root must declare type: 'object' — no documented provider accepts another root\",\n },\n };\n }\n\n const rejection = findRejection(root, '', 0, new Set<object>(), { count: 0 }, profile);\n if (rejection) {\n return { outcome: 'rejected', tool, changes: [], rejection };\n }\n\n const changes: IToolSchemaProjectionChange[] = [];\n const keywordAdapted = adaptNode(root, '', profile, changes);\n\n const finalParameters = profile.closedObjects\n ? (closeObjectSchemas(keywordAdapted, {\n requireAllProperties: profile.requireAllProperties,\n optionalAsNullable: profile.optionalAsNullable,\n onChange: (change) => changes.push(change),\n }) as IObjectParameterSchema)\n : (keywordAdapted as unknown as IObjectParameterSchema);\n\n if (changes.length === 0) {\n return { outcome: 'adopted', tool, changes: [] };\n }\n\n const noteworthy = changes.filter(\n (change) =>\n (change.kind === 'keyword-stripped' ||\n change.kind === 'keyword-replaced' ||\n change.kind === 'member-stripped') &&\n !ANNOTATION_ONLY_KEYWORDS.has(change.keyword ?? ''),\n );\n\n const description =\n noteworthy.length === 0\n ? tool.description\n : `${tool.description}\\n\\nSchema note: ${noteworthy.length} constraint(s) not shown to ${profile.providerName}: ${noteworthy\n .map((change) => `${change.kind}@${change.path}`)\n .join(', ')}`;\n\n return {\n outcome: 'adapted',\n tool: { ...tool, parameters: finalParameters, description },\n changes,\n };\n}\n"],"mappings":"AAqDA,MAAM,EAAc,CAAE,KAAM,MAAO,EAGnC,SAAS,EAAW,EAAwC,CAE1D,OADI,EAAK,OAAS,QAEhB,MAAM,QAAQ,EAAK,KAAK,GACxB,EAAK,MAAM,KACR,GACC,OAAO,GAAW,YAClB,GACC,EAAmC,OAAS,MACjD,CAEJ,CAGA,SAAS,EAAe,EAAyB,CAC/C,GAAI,OAAO,GAAU,WAAY,GAAkB,MAAM,QAAQ,CAAK,EACpE,OAAO,EAET,IAAM,EAAO,EAKb,OAJI,EAAW,CAAI,EAAU,EACzB,MAAM,QAAQ,EAAK,KAAK,EACnB,CAAE,GAAG,EAAM,MAAO,CAAC,GAAG,EAAK,MAAO,CAAW,CAAE,EAEjD,CAAE,MAAO,CAAC,EAAM,CAAW,CAAE,CACtC,CASA,SAAgB,EAAmB,EAAe,EAAiC,CAAC,EA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aAAa,IAAI,EAC7G,IAAK,GAAW,GAAG,EAAO,KAAK,GAAG,EAAO,MAAM,CAAC,CAChD,KAAK,IAAI,IAElB,MAAO,CACL,QAAS,UACT,KAAM,CAAE,GAAG,EAAM,WAAY,EAAiB,aAAY,EAC1D,SACF,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../project-tool-schema-DrDjGKnH.cjs");let t=require("node:fs"),n=require("node:crypto");function r(e){let t=[],n=[],r=0;return{provider:{name:`scripted-test-provider`,version:`test`,async chat(i,a){t.push([...i]),n.push(a);let o=e[r];if(o===void 0)throw Error(`Scripted provider: script exhausted at call ${r+1} (script declares ${e.length} turn(s)) — extend the script instead of relying on improvised responses`);r+=1;let s=o.usage?{metadata:{inputTokens:o.usage.inputTokens,outputTokens:o.usage.outputTokens,totalTokens:o.usage.inputTokens+o.usage.outputTokens}}:{};return`text`in o?(o.text.length>0&&a?.onTextDelta?.(o.text),{id:`scripted-${r}`,role:`assistant`,content:o.text,state:`complete`,timestamp:new Date,...s}):{id:`scripted-${r}`,role:`assistant`,content:null,state:`complete`,timestamp:new Date,...s,toolCalls:o.toolCalls.map((e,t)=>({id:`scripted-call-${r}-${t}`,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.args)}}))}},async generateResponse(){return{content:`scripted provider does not implement raw responses`}},supportsTools(){return!0},validateConfig(){return!0}},requests:t,chatOptions:n}}function i(e,t){let n=e;for(let e of t)e&&(n=n.split(e).join(`\0SCRUBBED\0`));return n}function a(e,t){let n=e.filter(e=>e.role!==`system`).map(e=>{let n=`toolCalls`in e?e.toolCalls:void 0;return{role:e.role,content:typeof e.content==`string`?i(e.content,t):e.content??null,toolCalls:n?.map(e=>({name:e.function?.name??null,args:e.function?.arguments?i(e.function.arguments,t):null}))??null}});return JSON.stringify(n)}function o(e,t){return(0,n.createHash)(`sha256`).update(a(e,t)).digest(`hex`).slice(0,16)}function s(e,t){let n=e[e.length-1],r=typeof n?.content==`string`?i(n.content,t):``;return`${e.length} msg(s); last ${n?.role??`?`}: ${r.slice(0,80)}`}function c(e){return{generateResponse:e.generateResponse.bind(e),supportsTools:e.supportsTools.bind(e),validateConfig:e.validateConfig.bind(e)}}function l(e){let n=e.scrub??(e.recordCwd?[e.recordCwd]:[]),r=[],i=()=>{let n={version:1,provider:e.provider.name,...e.model===void 0?{}:{model:e.model},...e.recordCwd===void 0?{}:{recordCwd:e.recordCwd},interactions:r};(0,t.writeFileSync)(e.cassettePath,`${JSON.stringify(n,null,2)}\n`,`utf8`)};return{name:e.provider.name,version:e.provider.version,async chat(t,a){let c=await e.provider.chat(t,a);return r.push({requestHash:o(t,n),requestPreview:s(t,n),response:c}),i(),c},...c(e.provider)}}function u(e,t,n){let r=e;return t&&n&&t!==n&&(r=JSON.parse(JSON.stringify(r).split(n).join(t))),{...r,timestamp:new Date(r.timestamp)}}function d(e){let n=JSON.parse((0,t.readFileSync)(e.cassettePath,`utf8`)),r=e.scrub??(e.rewriteCwd?[e.rewriteCwd]:[]),i=0;return{name:`cassette-replay-provider`,version:`test`,async chat(t){let a=n.interactions[i];if(!a)throw Error(`Cassette exhausted at call ${i+1} (recorded ${n.interactions.length}) — re-record ${e.cassettePath}`);if(o(t,r)!==a.requestHash)throw Error(`Cassette stale at call ${i+1}: the request changed since recording.\n recorded: ${a.requestPreview}\n current : ${s(t,r)}\nRe-record ${e.cassettePath}.`);return i+=1,u(a.response,e.rewriteCwd,n.recordCwd)},async generateResponse(){return{content:`cassette replay does not implement raw responses`}},supportsTools(){return!0},validateConfig(){return!0}}}var f={name:`bulk_upsert`,description:`An array property whose items are an object schema.`,parameters:{type:`object`,properties:{records:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},value:{type:`number`}},required:[`id`]}}},required:[`records`]}},p={name:`deeply_nested_tool`,description:`A schema nested 40 levels deep - over every profile maxDepth (32).`,parameters:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`string`}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},m={name:`update_profile`,description:`Update a user profile; nickname is optional and already nullable on the wire.`,parameters:{type:`object`,properties:{userId:{type:`string`},nickname:{anyOf:[{type:`string`},{type:`null`}]}},required:[`userId`]}},h=[{name:`good_tool_one`,description:`A well-formed tool.`,parameters:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}},{name:`bad_tool`,description:`A tool whose root is a union rather than a single object.`,parameters:{anyOf:[{type:`object`,properties:{a:{type:`string`}},required:[`a`]},{type:`object`,properties:{b:{type:`number`}},required:[`b`]}]}},{name:`good_tool_two`,description:`Another well-formed tool.`,parameters:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}],g={name:`flexible_root`,description:`A tool whose root is a union rather than a single object — no documented provider accepts this.`,parameters:{anyOf:[{type:`object`,properties:{a:{type:`string`}},required:[`a`]},{type:`object`,properties:{b:{type:`number`}},required:[`b`]}]}},_={name:`search_records`,description:`Search records by query and return matching entries.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query.`},limit:{type:`integer`,minimum:1,maximum:100},tags:{type:`array`,items:{type:`string`}},address:{type:`object`,properties:{city:{type:`string`},zip:{type:`string`,pattern:`^[0-9]{5}$`}},required:[`city`]}},required:[`query`]}},v={name:`third_party_search`,description:`A third-party MCP tool's schema carrying keywords outside the IParameterSchema member set.`,parameters:{type:`object`,properties:{refOnly:{$ref:`#/$defs/Query`},oneOfOnly:{oneOf:[{type:`string`},{type:`number`}]},allOfOnly:{allOf:[{type:`object`,properties:{x:{type:`string`}}},{type:`object`,properties:{y:{type:`string`}}}]},annotated:{type:`string`,title:`Annotated field`,$schema:`https://json-schema.org/draft/2020-12/schema`,$comment:`internal note`,examples:[`abc`]},patternMap:{type:`object`,properties:{known:{type:`string`}},patternProperties:{"^x-":{type:`string`}}},withDefs:{type:`object`,properties:{known:{type:`string`}},$defs:{Query:{type:`string`}}},shortText:{type:`string`,minLength:3}},required:[`refOnly`]}};function y(){return{name:`malicious_property_name`,description:`A property named as a prototype key — reachable from a parsed third-party schema.`,parameters:{type:`object`,properties:{safe:{type:`string`},["__proto__"]:{type:`string`}},required:[`safe`]}}}function b(){let t={},n=e.a+500;for(let e=0;e<n;e+=1)t[`field_${e}`]={type:`string`};return{name:`oversized_tool`,description:`A schema with more nodes than any shipped profile's maxNodes ceiling.`,parameters:{type:`object`,properties:t,required:[]}}}function x(){return{subsetOnly:_,rootAnyOf:g,nestedAnyOfOptional:m,unknownKeywords:v,prototypeKey:y(),deepNesting:p,oversized:b(),arrayItemsObject:f,oneInvalidAmongMany:h}}exports.createRecordingProvider=l,exports.createReplayProvider=d,exports.createScriptedProvider=r,exports.loadToolSchemaProjectionFixtures=x;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Nc as IAIProvider, Pc as IChatOptions, Zc as IToolSchema, iu as TUniversalMessage } from "../index-CagopdzH.cjs";
|
|
2
|
+
//#region src/testing/scripted-provider.d.ts
|
|
3
|
+
/** ANALYTICS-001: optional token usage a scripted turn reports, so usage-based tests are possible. */
|
|
4
|
+
interface IScriptedTurnUsage {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
outputTokens: number;
|
|
7
|
+
}
|
|
8
|
+
/** One scripted assistant turn: plain text or tool invocations, optionally reporting token usage. */
|
|
9
|
+
type TScriptedTurn = {
|
|
10
|
+
text: string;
|
|
11
|
+
usage?: IScriptedTurnUsage;
|
|
12
|
+
} | {
|
|
13
|
+
toolCalls: ReadonlyArray<{
|
|
14
|
+
name: string;
|
|
15
|
+
args: Record<string, unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
usage?: IScriptedTurnUsage;
|
|
18
|
+
};
|
|
19
|
+
interface IScriptedProvider {
|
|
20
|
+
provider: IAIProvider;
|
|
21
|
+
/** Message arrays of every chat() call, in order, for request assertions. */
|
|
22
|
+
requests: TUniversalMessage[][];
|
|
23
|
+
/**
|
|
24
|
+
* The `IChatOptions` of every chat() call, in order.
|
|
25
|
+
*
|
|
26
|
+
* CORE-042: the two entry points must build the SAME options object, and nothing could assert
|
|
27
|
+
* that while the double discarded them.
|
|
28
|
+
*/
|
|
29
|
+
chatOptions: Array<IChatOptions | undefined>;
|
|
30
|
+
}
|
|
31
|
+
declare function createScriptedProvider(turns: readonly TScriptedTurn[]): IScriptedProvider;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/testing/cassette-provider.d.ts
|
|
34
|
+
/** One recorded request→response interaction. */
|
|
35
|
+
interface ICassetteInteraction {
|
|
36
|
+
requestHash: string;
|
|
37
|
+
requestPreview: string;
|
|
38
|
+
response: TUniversalMessage;
|
|
39
|
+
}
|
|
40
|
+
/** A recorded session: an ordered list of interactions plus metadata. */
|
|
41
|
+
interface ICassette {
|
|
42
|
+
version: 1;
|
|
43
|
+
provider: string;
|
|
44
|
+
model?: string;
|
|
45
|
+
/** Recorded workspace path, stored verbatim so replay can rewrite it into its own workspace. */
|
|
46
|
+
recordCwd?: string;
|
|
47
|
+
interactions: ICassetteInteraction[];
|
|
48
|
+
}
|
|
49
|
+
interface IRecordingProviderOptions {
|
|
50
|
+
provider: IAIProvider;
|
|
51
|
+
cassettePath: string;
|
|
52
|
+
/** Volatile substrings normalized out of the staleness hash (e.g. the workspace path). */
|
|
53
|
+
scrub?: readonly string[];
|
|
54
|
+
/** Recorded workspace path; replay rewrites it into the replay workspace. */
|
|
55
|
+
recordCwd?: string;
|
|
56
|
+
model?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Wrap a real provider, recording every interaction to the cassette file as it runs. */
|
|
59
|
+
declare function createRecordingProvider(options: IRecordingProviderOptions): IAIProvider;
|
|
60
|
+
interface IReplayProviderOptions {
|
|
61
|
+
cassettePath: string;
|
|
62
|
+
/** Volatile substrings normalized out of the staleness hash (must match the record-time scrub). */
|
|
63
|
+
scrub?: readonly string[];
|
|
64
|
+
/** Replay workspace path; the recorded workspace path in responses is rewritten to it. */
|
|
65
|
+
rewriteCwd?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Replay a recorded cassette deterministically, failing clearly on staleness or exhaustion. */
|
|
68
|
+
declare function createReplayProvider(options: IReplayProviderOptions): IAIProvider;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/testing/tool-schema-projection-fixtures.d.ts
|
|
71
|
+
/** The named tool-schema-projection fixture set (MCP-005). Treat every value as read-only. */
|
|
72
|
+
interface IToolSchemaProjectionFixtures {
|
|
73
|
+
/** Only members of the `IParameterSchema` subset — projects `adopted` under every profile. */
|
|
74
|
+
readonly subsetOnly: IToolSchema;
|
|
75
|
+
/** `parameters` is a root union, not `type: 'object'` — universal rejection. */
|
|
76
|
+
readonly rootAnyOf: IToolSchema;
|
|
77
|
+
/** A nested (non-root) optional `anyOf` that already admits `null` — legitimate union usage. */
|
|
78
|
+
readonly nestedAnyOfOptional: IToolSchema;
|
|
79
|
+
/** `$ref`/`oneOf`/`allOf`-only nodes, annotations, `patternProperties`, `$defs`, `minLength`. */
|
|
80
|
+
readonly unknownKeywords: IToolSchema;
|
|
81
|
+
/** A property named `__proto__` — refused before any spread. */
|
|
82
|
+
readonly prototypeKey: IToolSchema;
|
|
83
|
+
/** Nested 40 levels deep — over every shipped profile's `maxDepth` (32). */
|
|
84
|
+
readonly deepNesting: IToolSchema;
|
|
85
|
+
/** Over every shipped profile's `maxNodes` (2000). */
|
|
86
|
+
readonly oversized: IToolSchema;
|
|
87
|
+
/** An array property whose `items` is an object schema. */
|
|
88
|
+
readonly arrayItemsObject: IToolSchema;
|
|
89
|
+
/** Three tools; the middle one is a root-union rejection — per-tool quarantine, not a whole-request failure. */
|
|
90
|
+
readonly oneInvalidAmongMany: readonly IToolSchema[];
|
|
91
|
+
}
|
|
92
|
+
/** The shared MCP-005 fixture set. Returns the same underlying values on every call — do not mutate them. */
|
|
93
|
+
declare function loadToolSchemaProjectionFixtures(): IToolSchemaProjectionFixtures;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { type ICassette, type ICassetteInteraction, type IRecordingProviderOptions, type IReplayProviderOptions, type IScriptedProvider, type IToolSchemaProjectionFixtures, type TScriptedTurn, createRecordingProvider, createReplayProvider, createScriptedProvider, loadToolSchemaProjectionFixtures };
|
|
96
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/testing/scripted-provider.ts","../../../src/testing/cassette-provider.ts","../../../src/testing/tool-schema-projection-fixtures.ts"],"mappings":";;;UAoBiB;EACf;EACA;;;KAIU;EACN;EAAc,QAAQ;;EAEtB,WAAW;IAAgB;IAAc,MAAM;;EAC/C,QAAQ;;UAGG;EACf,UAAU;;EAEV,UAAU;;;;;;;EAOV,aAAa,MAAM;;iBAGL,uBAAuB,gBAAgB,kBAAkB;;;;UCjBxD;EACf;EACA;EACA,UAAU;;;UAIK;EACf;EACA;EACA;;EAEA;EACA,cAAc;;UA6DC;EACf,UAAU;EACV;;EAEA;;EAEA;EACA;;;iBAIc,wBAAwB,SAAS,4BAA4B;UAmD5D;EACf;;EAEA;;EAEA;;;iBAIc,qBAAqB,SAAS,yBAAyB;;;;UCtGtD;;WAEN,YAAY;;WAEZ,WAAW;;WAEX,qBAAqB;;WAErB,iBAAiB;;WAEjB,cAAc;;WAEd,aAAa;;WAEb,WAAW;;WAEX,kBAAkB;;WAElB,8BAA8B;;;iBAIzB,oCAAoC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Nc as IAIProvider, Pc as IChatOptions, Zc as IToolSchema, iu as TUniversalMessage } from "../index-CjyNzgQN.js";
|
|
2
|
+
//#region src/testing/scripted-provider.d.ts
|
|
3
|
+
/** ANALYTICS-001: optional token usage a scripted turn reports, so usage-based tests are possible. */
|
|
4
|
+
interface IScriptedTurnUsage {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
outputTokens: number;
|
|
7
|
+
}
|
|
8
|
+
/** One scripted assistant turn: plain text or tool invocations, optionally reporting token usage. */
|
|
9
|
+
type TScriptedTurn = {
|
|
10
|
+
text: string;
|
|
11
|
+
usage?: IScriptedTurnUsage;
|
|
12
|
+
} | {
|
|
13
|
+
toolCalls: ReadonlyArray<{
|
|
14
|
+
name: string;
|
|
15
|
+
args: Record<string, unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
usage?: IScriptedTurnUsage;
|
|
18
|
+
};
|
|
19
|
+
interface IScriptedProvider {
|
|
20
|
+
provider: IAIProvider;
|
|
21
|
+
/** Message arrays of every chat() call, in order, for request assertions. */
|
|
22
|
+
requests: TUniversalMessage[][];
|
|
23
|
+
/**
|
|
24
|
+
* The `IChatOptions` of every chat() call, in order.
|
|
25
|
+
*
|
|
26
|
+
* CORE-042: the two entry points must build the SAME options object, and nothing could assert
|
|
27
|
+
* that while the double discarded them.
|
|
28
|
+
*/
|
|
29
|
+
chatOptions: Array<IChatOptions | undefined>;
|
|
30
|
+
}
|
|
31
|
+
declare function createScriptedProvider(turns: readonly TScriptedTurn[]): IScriptedProvider;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/testing/cassette-provider.d.ts
|
|
34
|
+
/** One recorded request→response interaction. */
|
|
35
|
+
interface ICassetteInteraction {
|
|
36
|
+
requestHash: string;
|
|
37
|
+
requestPreview: string;
|
|
38
|
+
response: TUniversalMessage;
|
|
39
|
+
}
|
|
40
|
+
/** A recorded session: an ordered list of interactions plus metadata. */
|
|
41
|
+
interface ICassette {
|
|
42
|
+
version: 1;
|
|
43
|
+
provider: string;
|
|
44
|
+
model?: string;
|
|
45
|
+
/** Recorded workspace path, stored verbatim so replay can rewrite it into its own workspace. */
|
|
46
|
+
recordCwd?: string;
|
|
47
|
+
interactions: ICassetteInteraction[];
|
|
48
|
+
}
|
|
49
|
+
interface IRecordingProviderOptions {
|
|
50
|
+
provider: IAIProvider;
|
|
51
|
+
cassettePath: string;
|
|
52
|
+
/** Volatile substrings normalized out of the staleness hash (e.g. the workspace path). */
|
|
53
|
+
scrub?: readonly string[];
|
|
54
|
+
/** Recorded workspace path; replay rewrites it into the replay workspace. */
|
|
55
|
+
recordCwd?: string;
|
|
56
|
+
model?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Wrap a real provider, recording every interaction to the cassette file as it runs. */
|
|
59
|
+
declare function createRecordingProvider(options: IRecordingProviderOptions): IAIProvider;
|
|
60
|
+
interface IReplayProviderOptions {
|
|
61
|
+
cassettePath: string;
|
|
62
|
+
/** Volatile substrings normalized out of the staleness hash (must match the record-time scrub). */
|
|
63
|
+
scrub?: readonly string[];
|
|
64
|
+
/** Replay workspace path; the recorded workspace path in responses is rewritten to it. */
|
|
65
|
+
rewriteCwd?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Replay a recorded cassette deterministically, failing clearly on staleness or exhaustion. */
|
|
68
|
+
declare function createReplayProvider(options: IReplayProviderOptions): IAIProvider;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/testing/tool-schema-projection-fixtures.d.ts
|
|
71
|
+
/** The named tool-schema-projection fixture set (MCP-005). Treat every value as read-only. */
|
|
72
|
+
interface IToolSchemaProjectionFixtures {
|
|
73
|
+
/** Only members of the `IParameterSchema` subset — projects `adopted` under every profile. */
|
|
74
|
+
readonly subsetOnly: IToolSchema;
|
|
75
|
+
/** `parameters` is a root union, not `type: 'object'` — universal rejection. */
|
|
76
|
+
readonly rootAnyOf: IToolSchema;
|
|
77
|
+
/** A nested (non-root) optional `anyOf` that already admits `null` — legitimate union usage. */
|
|
78
|
+
readonly nestedAnyOfOptional: IToolSchema;
|
|
79
|
+
/** `$ref`/`oneOf`/`allOf`-only nodes, annotations, `patternProperties`, `$defs`, `minLength`. */
|
|
80
|
+
readonly unknownKeywords: IToolSchema;
|
|
81
|
+
/** A property named `__proto__` — refused before any spread. */
|
|
82
|
+
readonly prototypeKey: IToolSchema;
|
|
83
|
+
/** Nested 40 levels deep — over every shipped profile's `maxDepth` (32). */
|
|
84
|
+
readonly deepNesting: IToolSchema;
|
|
85
|
+
/** Over every shipped profile's `maxNodes` (2000). */
|
|
86
|
+
readonly oversized: IToolSchema;
|
|
87
|
+
/** An array property whose `items` is an object schema. */
|
|
88
|
+
readonly arrayItemsObject: IToolSchema;
|
|
89
|
+
/** Three tools; the middle one is a root-union rejection — per-tool quarantine, not a whole-request failure. */
|
|
90
|
+
readonly oneInvalidAmongMany: readonly IToolSchema[];
|
|
91
|
+
}
|
|
92
|
+
/** The shared MCP-005 fixture set. Returns the same underlying values on every call — do not mutate them. */
|
|
93
|
+
declare function loadToolSchemaProjectionFixtures(): IToolSchemaProjectionFixtures;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { type ICassette, type ICassetteInteraction, type IRecordingProviderOptions, type IReplayProviderOptions, type IScriptedProvider, type IToolSchemaProjectionFixtures, type TScriptedTurn, createRecordingProvider, createReplayProvider, createScriptedProvider, loadToolSchemaProjectionFixtures };
|
|
96
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/testing/scripted-provider.ts","../../../src/testing/cassette-provider.ts","../../../src/testing/tool-schema-projection-fixtures.ts"],"mappings":";;;UAoBiB;EACf;EACA;;;KAIU;EACN;EAAc,QAAQ;;EAEtB,WAAW;IAAgB;IAAc,MAAM;;EAC/C,QAAQ;;UAGG;EACf,UAAU;;EAEV,UAAU;;;;;;;EAOV,aAAa,MAAM;;iBAGL,uBAAuB,gBAAgB,kBAAkB;;;;UCjBxD;EACf;EACA;EACA,UAAU;;;UAIK;EACf;EACA;EACA;;EAEA;EACA,cAAc;;UA6DC;EACf,UAAU;EACV;;EAEA;;EAEA;EACA;;;iBAIc,wBAAwB,SAAS,4BAA4B;UAmD5D;EACf;;EAEA;;EAEA;;;iBAIc,qBAAqB,SAAS,yBAAyB;;;;UCtGtD;;WAEN,YAAY;;WAEZ,WAAW;;WAEX,qBAAqB;;WAErB,iBAAiB;;WAEjB,cAAc;;WAEd,aAAa;;WAEb,WAAW;;WAEX,kBAAkB;;WAElB,8BAA8B;;;iBAIzB,oCAAoC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"../project-tool-schema-_UKfY7yO.js";import{readFileSync as t,writeFileSync as n}from"node:fs";import{createHash as r}from"node:crypto";function i(e){let t=[],n=[],r=0;return{provider:{name:`scripted-test-provider`,version:`test`,async chat(i,a){t.push([...i]),n.push(a);let o=e[r];if(o===void 0)throw Error(`Scripted provider: script exhausted at call ${r+1} (script declares ${e.length} turn(s)) — extend the script instead of relying on improvised responses`);r+=1;let s=o.usage?{metadata:{inputTokens:o.usage.inputTokens,outputTokens:o.usage.outputTokens,totalTokens:o.usage.inputTokens+o.usage.outputTokens}}:{};return`text`in o?(o.text.length>0&&a?.onTextDelta?.(o.text),{id:`scripted-${r}`,role:`assistant`,content:o.text,state:`complete`,timestamp:new Date,...s}):{id:`scripted-${r}`,role:`assistant`,content:null,state:`complete`,timestamp:new Date,...s,toolCalls:o.toolCalls.map((e,t)=>({id:`scripted-call-${r}-${t}`,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.args)}}))}},async generateResponse(){return{content:`scripted provider does not implement raw responses`}},supportsTools(){return!0},validateConfig(){return!0}},requests:t,chatOptions:n}}function a(e,t){let n=e;for(let e of t)e&&(n=n.split(e).join(`\0SCRUBBED\0`));return n}function o(e,t){let n=e.filter(e=>e.role!==`system`).map(e=>{let n=`toolCalls`in e?e.toolCalls:void 0;return{role:e.role,content:typeof e.content==`string`?a(e.content,t):e.content??null,toolCalls:n?.map(e=>({name:e.function?.name??null,args:e.function?.arguments?a(e.function.arguments,t):null}))??null}});return JSON.stringify(n)}function s(e,t){return r(`sha256`).update(o(e,t)).digest(`hex`).slice(0,16)}function c(e,t){let n=e[e.length-1],r=typeof n?.content==`string`?a(n.content,t):``;return`${e.length} msg(s); last ${n?.role??`?`}: ${r.slice(0,80)}`}function l(e){return{generateResponse:e.generateResponse.bind(e),supportsTools:e.supportsTools.bind(e),validateConfig:e.validateConfig.bind(e)}}function u(e){let t=e.scrub??(e.recordCwd?[e.recordCwd]:[]),r=[],i=()=>{let t={version:1,provider:e.provider.name,...e.model===void 0?{}:{model:e.model},...e.recordCwd===void 0?{}:{recordCwd:e.recordCwd},interactions:r};n(e.cassettePath,`${JSON.stringify(t,null,2)}\n`,`utf8`)};return{name:e.provider.name,version:e.provider.version,async chat(n,a){let o=await e.provider.chat(n,a);return r.push({requestHash:s(n,t),requestPreview:c(n,t),response:o}),i(),o},...l(e.provider)}}function d(e,t,n){let r=e;return t&&n&&t!==n&&(r=JSON.parse(JSON.stringify(r).split(n).join(t))),{...r,timestamp:new Date(r.timestamp)}}function f(e){let n=JSON.parse(t(e.cassettePath,`utf8`)),r=e.scrub??(e.rewriteCwd?[e.rewriteCwd]:[]),i=0;return{name:`cassette-replay-provider`,version:`test`,async chat(t){let a=n.interactions[i];if(!a)throw Error(`Cassette exhausted at call ${i+1} (recorded ${n.interactions.length}) — re-record ${e.cassettePath}`);if(s(t,r)!==a.requestHash)throw Error(`Cassette stale at call ${i+1}: the request changed since recording.\n recorded: ${a.requestPreview}\n current : ${c(t,r)}\nRe-record ${e.cassettePath}.`);return i+=1,d(a.response,e.rewriteCwd,n.recordCwd)},async generateResponse(){return{content:`cassette replay does not implement raw responses`}},supportsTools(){return!0},validateConfig(){return!0}}}var p={name:`bulk_upsert`,description:`An array property whose items are an object schema.`,parameters:{type:`object`,properties:{records:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},value:{type:`number`}},required:[`id`]}}},required:[`records`]}},m={name:`deeply_nested_tool`,description:`A schema nested 40 levels deep - over every profile maxDepth (32).`,parameters:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`object`,properties:{child:{type:`string`}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},required:[`child`]}},h={name:`update_profile`,description:`Update a user profile; nickname is optional and already nullable on the wire.`,parameters:{type:`object`,properties:{userId:{type:`string`},nickname:{anyOf:[{type:`string`},{type:`null`}]}},required:[`userId`]}},g=[{name:`good_tool_one`,description:`A well-formed tool.`,parameters:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}},{name:`bad_tool`,description:`A tool whose root is a union rather than a single object.`,parameters:{anyOf:[{type:`object`,properties:{a:{type:`string`}},required:[`a`]},{type:`object`,properties:{b:{type:`number`}},required:[`b`]}]}},{name:`good_tool_two`,description:`Another well-formed tool.`,parameters:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}],_={name:`flexible_root`,description:`A tool whose root is a union rather than a single object — no documented provider accepts this.`,parameters:{anyOf:[{type:`object`,properties:{a:{type:`string`}},required:[`a`]},{type:`object`,properties:{b:{type:`number`}},required:[`b`]}]}},v={name:`search_records`,description:`Search records by query and return matching entries.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query.`},limit:{type:`integer`,minimum:1,maximum:100},tags:{type:`array`,items:{type:`string`}},address:{type:`object`,properties:{city:{type:`string`},zip:{type:`string`,pattern:`^[0-9]{5}$`}},required:[`city`]}},required:[`query`]}},y={name:`third_party_search`,description:`A third-party MCP tool's schema carrying keywords outside the IParameterSchema member set.`,parameters:{type:`object`,properties:{refOnly:{$ref:`#/$defs/Query`},oneOfOnly:{oneOf:[{type:`string`},{type:`number`}]},allOfOnly:{allOf:[{type:`object`,properties:{x:{type:`string`}}},{type:`object`,properties:{y:{type:`string`}}}]},annotated:{type:`string`,title:`Annotated field`,$schema:`https://json-schema.org/draft/2020-12/schema`,$comment:`internal note`,examples:[`abc`]},patternMap:{type:`object`,properties:{known:{type:`string`}},patternProperties:{"^x-":{type:`string`}}},withDefs:{type:`object`,properties:{known:{type:`string`}},$defs:{Query:{type:`string`}}},shortText:{type:`string`,minLength:3}},required:[`refOnly`]}};function b(){return{name:`malicious_property_name`,description:`A property named as a prototype key — reachable from a parsed third-party schema.`,parameters:{type:`object`,properties:{safe:{type:`string`},["__proto__"]:{type:`string`}},required:[`safe`]}}}function x(){let t={},n=e+500;for(let e=0;e<n;e+=1)t[`field_${e}`]={type:`string`};return{name:`oversized_tool`,description:`A schema with more nodes than any shipped profile's maxNodes ceiling.`,parameters:{type:`object`,properties:t,required:[]}}}function S(){return{subsetOnly:v,rootAnyOf:_,nestedAnyOfOptional:h,unknownKeywords:y,prototypeKey:b(),deepNesting:m,oversized:x(),arrayItemsObject:p,oneInvalidAmongMany:g}}export{u as createRecordingProvider,f as createReplayProvider,i as createScriptedProvider,S as loadToolSchemaProjectionFixtures};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["subsetOnlyFixture","rootAnyOfFixture","nestedAnyOfOptionalFixture","unknownKeywordsFixture","deepNestingFixture","arrayItemsObjectFixture","oneInvalidAmongManyFixture"],"sources":["../../../src/testing/scripted-provider.ts","../../../src/testing/cassette-provider.ts","../../../src/schema/__tests__/fixtures/tool-schema-projection/array-items-object.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/deep-nesting.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/nested-anyof-optional.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/one-invalid-among-many.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/root-anyof.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/subset-only.json","../../../src/schema/__tests__/fixtures/tool-schema-projection/unknown-keywords.json","../../../src/testing/tool-schema-projection-fixtures.ts"],"sourcesContent":["/**\n * Deterministic scripted provider for functional tests (TEST-003 SSOT).\n *\n * Replays a declared sequence of assistant turns through the REAL agent loop — tool execution,\n * permission gate, persistence, and output all run unmocked. It implements only the agent-core\n * `IAIProvider` contract, so it lives at the lowest layer that owns that abstraction; higher\n * layers (`agent-framework`, `agent-transport`) re-export it through their `./testing` subpaths.\n *\n * Test-only: exported via the `@robota-sdk/agent-core/testing` subpath and never imported by\n * runtime code.\n */\n\nimport type {\n IAIProvider,\n IChatOptions,\n IRawProviderResponse,\n TUniversalMessage,\n} from '../index.js';\n\n/** ANALYTICS-001: optional token usage a scripted turn reports, so usage-based tests are possible. */\nexport interface IScriptedTurnUsage {\n inputTokens: number;\n outputTokens: number;\n}\n\n/** One scripted assistant turn: plain text or tool invocations, optionally reporting token usage. */\nexport type TScriptedTurn =\n | { text: string; usage?: IScriptedTurnUsage }\n | {\n toolCalls: ReadonlyArray<{ name: string; args: Record<string, unknown> }>;\n usage?: IScriptedTurnUsage;\n };\n\nexport interface IScriptedProvider {\n provider: IAIProvider;\n /** Message arrays of every chat() call, in order, for request assertions. */\n requests: TUniversalMessage[][];\n /**\n * The `IChatOptions` of every chat() call, in order.\n *\n * CORE-042: the two entry points must build the SAME options object, and nothing could assert\n * that while the double discarded them.\n */\n chatOptions: Array<IChatOptions | undefined>;\n}\n\nexport function createScriptedProvider(turns: readonly TScriptedTurn[]): IScriptedProvider {\n const requests: TUniversalMessage[][] = [];\n const chatOptions: Array<IChatOptions | undefined> = [];\n let cursor = 0;\n\n const provider: IAIProvider = {\n name: 'scripted-test-provider',\n version: 'test',\n async chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage> {\n requests.push([...messages]);\n chatOptions.push(options);\n const turn = turns[cursor];\n if (turn === undefined) {\n throw new Error(\n `Scripted provider: script exhausted at call ${cursor + 1} (script declares ${turns.length} turn(s)) — extend the script instead of relying on improvised responses`,\n );\n }\n cursor += 1;\n // ANALYTICS-001: surface declared usage in metadata so the real usage pipeline records it.\n const usageMetadata = turn.usage\n ? {\n metadata: {\n inputTokens: turn.usage.inputTokens,\n outputTokens: turn.usage.outputTokens,\n totalTokens: turn.usage.inputTokens + turn.usage.outputTokens,\n },\n }\n : {};\n if ('text' in turn) {\n // CORE-042: `IChatOptions.onTextDelta` requires a provider to stream internally and call\n // this per chunk WHILE still returning the assembled message. This double returned the text\n // and emitted nothing, so an agent streaming through it produced no deltas -- the double,\n // not the product, was the reason a streaming test needed a second engine to observe. The\n // whole text goes out as one delta: a scripted turn has no chunk boundaries to honour, and\n // splitting it arbitrarily would invent a fragmentation behaviour no real provider promised.\n if (turn.text.length > 0) {\n options?.onTextDelta?.(turn.text);\n }\n return {\n id: `scripted-${cursor}`,\n role: 'assistant',\n content: turn.text,\n state: 'complete',\n timestamp: new Date(),\n ...usageMetadata,\n };\n }\n return {\n id: `scripted-${cursor}`,\n role: 'assistant',\n content: null,\n state: 'complete',\n timestamp: new Date(),\n ...usageMetadata,\n toolCalls: turn.toolCalls.map((call, index) => ({\n id: `scripted-call-${cursor}-${index}`,\n type: 'function' as const,\n function: { name: call.name, arguments: JSON.stringify(call.args) },\n })),\n };\n },\n async generateResponse(): Promise<IRawProviderResponse> {\n return { content: 'scripted provider does not implement raw responses' };\n },\n supportsTools(): boolean {\n return true;\n },\n validateConfig(): boolean {\n return true;\n },\n };\n\n return { provider, requests, chatOptions };\n}\n","/**\n * TEST-005: record-replay (cassette) provider.\n *\n * The scripted provider verifies the deterministic machinery but ignores the prompt and fakes the\n * model's tool-use. A cassette captures a REAL model's behaviour once (real prompts in, real\n * responses + tool-use out) and replays it deterministically — testing the actual prompts and the\n * model's real decisions in CI at zero per-run cost.\n *\n * - `createRecordingProvider({ provider, cassettePath, … })` wraps a real provider and writes each\n * interaction to the cassette. Used in a one-off record run (needs an API key).\n * - `createReplayProvider({ cassettePath, … })` replays the recorded responses in order, with\n * staleness detection: if the incoming request diverges from the recorded one (e.g. a prompt\n * changed), it fails with a clear \"re-record\" error instead of returning a wrong response.\n *\n * Volatile substrings (e.g. the per-run workspace path) are normalized via `scrub` before hashing\n * so an unchanged flow matches across runs; `rewriteCwd` rewrites the recorded workspace path in\n * replayed responses so recorded absolute tool-call paths land in the replay workspace.\n *\n * Test-only: exported via `@robota-sdk/agent-core/testing`; never imported by runtime code.\n */\n\nimport { createHash } from 'node:crypto';\nimport { readFileSync, writeFileSync } from 'node:fs';\n\nimport type { IAIProvider, IChatOptions, IToolCall, TUniversalMessage } from '../index.js';\n\nconst SCRUB_TOKEN = '\u0000SCRUBBED\u0000';\n\n/** One recorded request→response interaction. */\nexport interface ICassetteInteraction {\n requestHash: string;\n requestPreview: string;\n response: TUniversalMessage;\n}\n\n/** A recorded session: an ordered list of interactions plus metadata. */\nexport interface ICassette {\n version: 1;\n provider: string;\n model?: string;\n /** Recorded workspace path, stored verbatim so replay can rewrite it into its own workspace. */\n recordCwd?: string;\n interactions: ICassetteInteraction[];\n}\n\nfunction applyScrub(text: string, scrub: readonly string[]): string {\n let out = text;\n for (const value of scrub) {\n if (value) out = out.split(value).join(SCRUB_TOKEN);\n }\n return out;\n}\n\n/**\n * Normalized, volatile-free projection of a request used for the staleness hash.\n *\n * System messages are excluded: the system prompt embeds host/version-specific content (platform,\n * paths, tool inventory) that differs across machines, so hashing it would make a cassette\n * non-portable (a stale failure in CI for a run recorded on another host). The portable, meaningful\n * content — the user/goal prompts, the assistant tool calls, and the tool results — is retained, so\n * a change to the goal prompts still trips staleness.\n */\nfunction normalizeRequest(messages: TUniversalMessage[], scrub: readonly string[]): string {\n const projection = messages\n .filter((message) => message.role !== 'system')\n .map((message) => {\n const toolCalls =\n 'toolCalls' in message ? (message.toolCalls as IToolCall[] | undefined) : undefined;\n return {\n role: message.role,\n content:\n typeof message.content === 'string'\n ? applyScrub(message.content, scrub)\n : (message.content ?? null),\n toolCalls:\n toolCalls?.map((call) => ({\n name: call.function?.name ?? null,\n args: call.function?.arguments ? applyScrub(call.function.arguments, scrub) : null,\n })) ?? null,\n };\n });\n return JSON.stringify(projection);\n}\n\nfunction hashRequest(messages: TUniversalMessage[], scrub: readonly string[]): string {\n return createHash('sha256').update(normalizeRequest(messages, scrub)).digest('hex').slice(0, 16);\n}\n\nfunction previewRequest(messages: TUniversalMessage[], scrub: readonly string[]): string {\n const last = messages[messages.length - 1];\n const content = typeof last?.content === 'string' ? applyScrub(last.content, scrub) : '';\n return `${messages.length} msg(s); last ${last?.role ?? '?'}: ${content.slice(0, 80)}`;\n}\n\n/** Forward the non-`chat` surface of a wrapped provider unchanged. */\nfunction delegate(provider: IAIProvider): Omit<IAIProvider, 'chat' | 'name' | 'version'> {\n return {\n generateResponse: provider.generateResponse.bind(provider),\n supportsTools: provider.supportsTools.bind(provider),\n validateConfig: provider.validateConfig.bind(provider),\n };\n}\n\nexport interface IRecordingProviderOptions {\n provider: IAIProvider;\n cassettePath: string;\n /** Volatile substrings normalized out of the staleness hash (e.g. the workspace path). */\n scrub?: readonly string[];\n /** Recorded workspace path; replay rewrites it into the replay workspace. */\n recordCwd?: string;\n model?: string;\n}\n\n/** Wrap a real provider, recording every interaction to the cassette file as it runs. */\nexport function createRecordingProvider(options: IRecordingProviderOptions): IAIProvider {\n const scrub = options.scrub ?? (options.recordCwd ? [options.recordCwd] : []);\n const interactions: ICassetteInteraction[] = [];\n\n const flush = (): void => {\n const cassette: ICassette = {\n version: 1,\n provider: options.provider.name,\n ...(options.model !== undefined ? { model: options.model } : {}),\n ...(options.recordCwd !== undefined ? { recordCwd: options.recordCwd } : {}),\n interactions,\n };\n writeFileSync(options.cassettePath, `${JSON.stringify(cassette, null, 2)}\\n`, 'utf8');\n };\n\n return {\n name: options.provider.name,\n version: options.provider.version,\n async chat(\n messages: TUniversalMessage[],\n chatOptions?: IChatOptions,\n ): Promise<TUniversalMessage> {\n const response = await options.provider.chat(messages, chatOptions);\n // Store the raw response; the record workspace path is rewritten at replay time, not here.\n interactions.push({\n requestHash: hashRequest(messages, scrub),\n requestPreview: previewRequest(messages, scrub),\n response,\n });\n flush();\n return response;\n },\n ...delegate(options.provider),\n };\n}\n\nfunction reviveResponse(\n response: TUniversalMessage,\n rewriteCwd: string | undefined,\n recordCwd: string | undefined,\n): TUniversalMessage {\n let revived = response;\n if (rewriteCwd && recordCwd && rewriteCwd !== recordCwd) {\n revived = JSON.parse(\n JSON.stringify(revived).split(recordCwd).join(rewriteCwd),\n ) as TUniversalMessage;\n }\n // The timestamp round-trips through JSON as a string; the loop expects a Date.\n return { ...revived, timestamp: new Date(revived.timestamp as unknown as string) };\n}\n\nexport interface IReplayProviderOptions {\n cassettePath: string;\n /** Volatile substrings normalized out of the staleness hash (must match the record-time scrub). */\n scrub?: readonly string[];\n /** Replay workspace path; the recorded workspace path in responses is rewritten to it. */\n rewriteCwd?: string;\n}\n\n/** Replay a recorded cassette deterministically, failing clearly on staleness or exhaustion. */\nexport function createReplayProvider(options: IReplayProviderOptions): IAIProvider {\n const cassette = JSON.parse(readFileSync(options.cassettePath, 'utf8')) as ICassette;\n // Record-time hashing scrubbed the record workspace path → SCRUB_TOKEN; replay must scrub the\n // replay workspace path the same way so an unchanged flow matches across the two runs.\n const scrub = options.scrub ?? (options.rewriteCwd ? [options.rewriteCwd] : []);\n let cursor = 0;\n\n return {\n name: 'cassette-replay-provider',\n version: 'test',\n async chat(messages: TUniversalMessage[]): Promise<TUniversalMessage> {\n const interaction = cassette.interactions[cursor];\n if (!interaction) {\n throw new Error(\n `Cassette exhausted at call ${cursor + 1} (recorded ${cassette.interactions.length}) — re-record ${options.cassettePath}`,\n );\n }\n const incoming = hashRequest(messages, scrub);\n if (incoming !== interaction.requestHash) {\n throw new Error(\n `Cassette stale at call ${cursor + 1}: the request changed since recording.\\n` +\n ` recorded: ${interaction.requestPreview}\\n` +\n ` current : ${previewRequest(messages, scrub)}\\n` +\n `Re-record ${options.cassettePath}.`,\n );\n }\n cursor += 1;\n return reviveResponse(interaction.response, options.rewriteCwd, cassette.recordCwd);\n },\n async generateResponse() {\n return { content: 'cassette replay does not implement raw responses' };\n },\n supportsTools() {\n return true;\n },\n validateConfig() {\n return true;\n },\n };\n}\n","","","","","","","","/**\n * Shared tool-schema-projection fixtures (MCP-005) — one schema shape per named case, so agent-core's\n * own projector tests and every provider's conformance test (S2) exercise IDENTICAL inputs.\n *\n * Exported from the `./testing` subpath (TEST-003 precedent: `createScriptedProvider` lives the same\n * way) rather than from a `__tests__` directory: `scan-package-boundary-ownership` refuses a\n * cross-package import that reaches another package's private tree, and `__tests__` is exactly that.\n * A provider package's conformance test imports `loadToolSchemaProjectionFixtures` from\n * `@robota-sdk/agent-core/testing`.\n *\n * Most shapes are authored as JSON fixtures under\n * `../schema/__tests__/fixtures/tool-schema-projection/` and imported statically here — a bundler's\n * JSON loader inlines the parsed value into this module at build time, so the compiled `./testing`\n * entry carries the data with no external asset to copy. `prototypeKey` and `oversized` are the two\n * exceptions, built programmatically below (see each function's comment for why).\n */\nimport arrayItemsObjectFixture from '../schema/__tests__/fixtures/tool-schema-projection/array-items-object.json';\nimport deepNestingFixture from '../schema/__tests__/fixtures/tool-schema-projection/deep-nesting.json';\nimport nestedAnyOfOptionalFixture from '../schema/__tests__/fixtures/tool-schema-projection/nested-anyof-optional.json';\nimport oneInvalidAmongManyFixture from '../schema/__tests__/fixtures/tool-schema-projection/one-invalid-among-many.json';\nimport rootAnyOfFixture from '../schema/__tests__/fixtures/tool-schema-projection/root-anyof.json';\nimport subsetOnlyFixture from '../schema/__tests__/fixtures/tool-schema-projection/subset-only.json';\nimport unknownKeywordsFixture from '../schema/__tests__/fixtures/tool-schema-projection/unknown-keywords.json';\nimport { TOOL_SCHEMA_PROJECTION_MAX_NODES } from '../schema/project-tool-schema';\n\nimport type { IToolSchema } from '../interfaces/tool-schema';\n\n/**\n * A property literally named `__proto__`, exactly as a parsed third-party schema could carry it.\n *\n * NOT loaded via a static JSON import: a bundler's JSON loader inlines the parsed value as an object\n * LITERAL, and a literal property written `\"__proto__\": value` (quoted or not) triggers the\n * ECMAScript `[[SetPrototypeOf]]` special case (Annex B.3.1) instead of creating an own property —\n * the opposite of what `JSON.parse` does for the same text over the wire (verified empirically: a\n * fixture authored as `prototype-key.json` and statically imported lost the property entirely). A\n * COMPUTED key (`['__proto__']`) is the one object-literal spelling that is not special-cased, so\n * this one fixture is authored directly in TypeScript instead of as JSON.\n */\nfunction buildPrototypeKeyFixture(): IToolSchema {\n return {\n name: 'malicious_property_name',\n description:\n 'A property named as a prototype key — reachable from a parsed third-party schema.',\n parameters: {\n type: 'object',\n properties: {\n safe: { type: 'string' },\n ['__proto__']: { type: 'string' },\n },\n required: ['safe'],\n },\n };\n}\n\n/**\n * More leaf properties than any shipped profile's `maxNodes` ceiling — generated here rather than\n * stored as a multi-thousand-line JSON file nobody would review line by line.\n */\nfunction buildOversizedFixture(): IToolSchema {\n const properties: Record<string, { type: 'string' }> = {};\n const propertyCount = TOOL_SCHEMA_PROJECTION_MAX_NODES + 500;\n for (let index = 0; index < propertyCount; index += 1) {\n properties[`field_${index}`] = { type: 'string' };\n }\n return {\n name: 'oversized_tool',\n description: \"A schema with more nodes than any shipped profile's maxNodes ceiling.\",\n parameters: { type: 'object', properties, required: [] },\n };\n}\n\n/** The named tool-schema-projection fixture set (MCP-005). Treat every value as read-only. */\nexport interface IToolSchemaProjectionFixtures {\n /** Only members of the `IParameterSchema` subset — projects `adopted` under every profile. */\n readonly subsetOnly: IToolSchema;\n /** `parameters` is a root union, not `type: 'object'` — universal rejection. */\n readonly rootAnyOf: IToolSchema;\n /** A nested (non-root) optional `anyOf` that already admits `null` — legitimate union usage. */\n readonly nestedAnyOfOptional: IToolSchema;\n /** `$ref`/`oneOf`/`allOf`-only nodes, annotations, `patternProperties`, `$defs`, `minLength`. */\n readonly unknownKeywords: IToolSchema;\n /** A property named `__proto__` — refused before any spread. */\n readonly prototypeKey: IToolSchema;\n /** Nested 40 levels deep — over every shipped profile's `maxDepth` (32). */\n readonly deepNesting: IToolSchema;\n /** Over every shipped profile's `maxNodes` (2000). */\n readonly oversized: IToolSchema;\n /** An array property whose `items` is an object schema. */\n readonly arrayItemsObject: IToolSchema;\n /** Three tools; the middle one is a root-union rejection — per-tool quarantine, not a whole-request failure. */\n readonly oneInvalidAmongMany: readonly IToolSchema[];\n}\n\n/** The shared MCP-005 fixture set. Returns the same underlying values on every call — do not mutate them. */\nexport function loadToolSchemaProjectionFixtures(): IToolSchemaProjectionFixtures {\n return {\n subsetOnly: subsetOnlyFixture as unknown as IToolSchema,\n rootAnyOf: rootAnyOfFixture as unknown as IToolSchema,\n nestedAnyOfOptional: nestedAnyOfOptionalFixture as unknown as IToolSchema,\n unknownKeywords: unknownKeywordsFixture as unknown as IToolSchema,\n prototypeKey: buildPrototypeKeyFixture(),\n deepNesting: deepNestingFixture as unknown as IToolSchema,\n oversized: buildOversizedFixture(),\n arrayItemsObject: arrayItemsObjectFixture as unknown as IToolSchema,\n oneInvalidAmongMany: oneInvalidAmongManyFixture as unknown as IToolSchema[],\n };\n}\n"],"mappings":"0JA8CA,SAAgB,EAAuB,EAAoD,CACzF,IAAM,EAAkC,CAAC,EACnC,EAA+C,CAAC,EAClD,EAAS,EAqEb,MAAO,CAAE,SAAA,CAlEP,KAAM,yBACN,QAAS,OACT,MAAM,KAAK,EAA+B,EAAoD,CAC5F,EAAS,KAAK,CAAC,GAAG,CAAQ,CAAC,EAC3B,EAAY,KAAK,CAAO,EACxB,IAAM,EAAO,EAAM,GACnB,GAAI,IAAS,IAAA,GACX,MAAU,MACR,+CAA+C,EAAS,EAAE,oBAAoB,EAAM,OAAO,yEAC7F,EAEF,GAAU,EAEV,IAAM,EAAgB,EAAK,MACvB,CACE,SAAU,CACR,YAAa,EAAK,MAAM,YACxB,aAAc,EAAK,MAAM,aACzB,YAAa,EAAK,MAAM,YAAc,EAAK,MAAM,YACnD,CACF,EACA,CAAC,EAoBL,MAnBI,SAAU,GAOR,EAAK,KAAK,OAAS,GACrB,GAAS,cAAc,EAAK,IAAI,EAE3B,CACL,GAAI,YAAY,IAChB,KAAM,YACN,QAAS,EAAK,KACd,MAAO,WACP,UAAW,IAAI,KACf,GAAG,CACL,GAEK,CACL,GAAI,YAAY,IAChB,KAAM,YACN,QAAS,KACT,MAAO,WACP,UAAW,IAAI,KACf,GAAG,EACH,UAAW,EAAK,UAAU,KAAK,EAAM,KAAW,CAC9C,GAAI,iBAAiB,EAAO,GAAG,IAC/B,KAAM,WACN,SAAU,CAAE,KAAM,EAAK,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