routine_code_commit
Save code versions for Edge Routines to enable future modifications or releases within ESA services.
Instructions
Save a code version for future modifications or release within an Edge Routine (ER).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the routine, support lowercase English, numbers, and hyphens, must start with lowercase English, length cannot be less than 2 characters | |
| description | No | Description of the routine, no spaces | |
| code | Yes | Source Code of the routine, export default { async fetch(request) { return handleRequest(request); } } |
Implementation Reference
- src/tools/er/commit.ts:34-90 (handler)The main handler function that implements the routine_code_commit tool logic: retrieves upload info, uploads the code to OSS, and commits the staging code via API calls.export const routine_code_commit = async (request: CallToolRequest) => { const res = await api.getRoutineStagingCodeUploadInfo( request.params.arguments as GetRoutineStagingCodeUploadInfoRequest, ); if (!res) { return { content: [ { type: 'text', text: `Failed to get routine staging code upload info. ${JSON.stringify(res)}`, }, ], success: false, }; } else { const uploadRes = await uploadCodeToOSS( res, request?.params?.arguments?.code as string, ); if (uploadRes !== true) { return { content: [ { type: 'text', text: `Failed to upload code to OSS. ${uploadRes}`, }, ], success: false, }; } else { const commitRes = await api.commitRoutineStagingCode( request.params.arguments as CommitRoutineStagingCodeRequest, ); if (commitRes.statusCode !== 200) { return { content: [ { type: 'text', text: `Failed to commit routine staging code. ${JSON.stringify(commitRes)}`, }, ], success: false, }; } else { return { content: [ { type: 'text', text: JSON.stringify(commitRes), }, ], success: true, }; } } } };
- src/tools/er/commit.ts:9-33 (schema)The tool definition including name, description, and input schema for validating parameters: name, description (optional), code (required).export const ROUTINE_CODE_COMMIT_TOOL: Tool = { name: 'routine_code_commit', description: 'Save a code version for future modifications or release within an Edge Routine (ER).', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'The name of the routine, support lowercase English, numbers, and hyphens, must start with lowercase English, length cannot be less than 2 characters', }, description: { type: 'string', description: 'Description of the routine, no spaces', }, code: { type: 'string', description: 'Source Code of the routine, export default { async fetch(request) { return handleRequest(request); } }', }, }, required: ['name', 'code'], }, };
- src/tools/list-esa-function.ts:103-123 (registration)ROUTINE_CODE_COMMIT_TOOL is registered in the ESA_OPENAPI_ER_LIST array, which collects tools for ER operations.export const ESA_OPENAPI_ER_LIST = [ HTML_DEPLOY_TOOL, ROUTINE_CREATE_TOOL, ROUTINE_DELETE_TOOL, ROUTINE_LIST_TOOL, ROUTINE_GET_TOOL, ROUTINE_CODE_COMMIT_TOOL, ROUTINE_CODE_DEPLOY_TOOL, ROUTINE_ROUTE_LIST_TOOL, DEPLOYMENT_DELETE_TOOL, SITE_ACTIVE_LIST_TOOL, SITE_ROUTE_LIST_TOOL, ROUTE_CREATE_TOOL, ROUTE_DELETE_TOOL, ROUTE_UPDATE_TOOL, ROUTE_GET_TOOL, SITE_MATCH_TOOL, ER_RECORD_CREATE_TOOL, ER_RECORD_DELETE_TOOL, ER_RECORD_LIST_TOOL, ];
- src/tools/list-esa-function.ts:170-170 (registration)The routine_code_commit handler is registered in the esaHandlers object mapping tool names to their handler functions.routine_code_commit,