python-snapshot-tool.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /** Deterministic tool and denial fixture for the packaged SDK snapshot. */
  2. export const name = 'python-snapshot-tool'
  3. export const inject = ['tools']
  4. /** @param {import('@deepseek-ai/cordis').Context} ctx - Scenario-owned tool registration. */
  5. export function apply(ctx) {
  6. ctx.on('tools/pre-execute', (exec, next) => {
  7. if (exec.name !== 'snapshot_double' || exec.arguments.value !== -1) return next()
  8. return {
  9. kind: 'deny',
  10. reason: 'Auto review rejected tool "snapshot_double"; its body was not executed',
  11. info: {
  12. name: 'AutoReviewDeniedError', code: 'AUTO_REVIEW_DENIED',
  13. reason: ' transport raw\r\nreason ',
  14. },
  15. }
  16. })
  17. ctx.tools.register({
  18. name: 'snapshot_double',
  19. description: 'Double a number for executable snapshot verification.',
  20. parameters: { type: 'object', properties: { value: { type: 'number' } }, required: ['value'], additionalProperties: false },
  21. output: {
  22. schema: { type: 'number' },
  23. render(_args, value) {
  24. return [{ type: 'text', text: String(value) }]
  25. }
  26. },
  27. async execute(args) {
  28. return args.value * 2
  29. }
  30. })
  31. }