(tool: ToolConfig)
| 715 | * Serialize an integration/tool schema for VFS components/integrations/{service}/{operation}.json |
| 716 | */ |
| 717 | export function serializeIntegrationSchema(tool: ToolConfig): string { |
| 718 | const hostedApiKeyParam = isHosted && tool.hosting ? tool.hosting.apiKeyParam : null |
| 719 | |
| 720 | return JSON.stringify( |
| 721 | { |
| 722 | // The full registry id is the agent-callable id (deferred tools are sent |
| 723 | // with this exact id; no stripping). Surface it verbatim so "copy the id |
| 724 | // field and load it" matches the callable tool and the block's tools.access. |
| 725 | id: tool.id, |
| 726 | name: tool.name, |
| 727 | description: getCopilotToolDescription(tool, { isHosted }), |
| 728 | version: tool.version, |
| 729 | oauth: tool.oauth |
| 730 | ? { required: tool.oauth.required, provider: tool.oauth.provider } |
| 731 | : undefined, |
| 732 | params: tool.params |
| 733 | ? { |
| 734 | ...Object.fromEntries( |
| 735 | Object.entries(tool.params) |
| 736 | .filter(([key, val]) => val != null && key !== hostedApiKeyParam) |
| 737 | .map(([key, val]) => [ |
| 738 | key, |
| 739 | { |
| 740 | type: val.type, |
| 741 | required: val.required, |
| 742 | description: val.description, |
| 743 | default: val.default, |
| 744 | }, |
| 745 | ]) |
| 746 | ), |
| 747 | ...(tool.oauth?.required && { |
| 748 | credentialId: { |
| 749 | type: 'string', |
| 750 | required: false, |
| 751 | description: |
| 752 | 'Credential ID to use for this OAuth tool call. For Copilot/Superagent execution, pass this explicitly. Get valid IDs from environment/credentials.json.', |
| 753 | }, |
| 754 | }), |
| 755 | } |
| 756 | : undefined, |
| 757 | outputs: tool.outputs |
| 758 | ? Object.fromEntries( |
| 759 | Object.entries(tool.outputs) |
| 760 | .filter(([, val]) => val != null) |
| 761 | .map(([key, val]) => [key, { type: val.type, description: val.description }]) |
| 762 | ) |
| 763 | : undefined, |
| 764 | }, |
| 765 | null, |
| 766 | 2 |
| 767 | ) |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * Serialize a trigger schema for VFS components/triggers/{provider}/{id}.json |
no test coverage detected