(input: Input, context: ToolUseContext)
| 73 | return PROMPT |
| 74 | }, |
| 75 | async call(input: Input, context: ToolUseContext) { |
| 76 | const session = getAuthRuntime().getCurrentSession() |
| 77 | if (session.principalSource === 'console_api_key') { |
| 78 | throw new Error( |
| 79 | 'Authenticated with a console API key, but scheduled remote agents require a managed Noumena account login. Run /login, choose the managed account option, and try again.', |
| 80 | ) |
| 81 | } |
| 82 | |
| 83 | const { accessToken, orgUUID } = await resolveManagedRemoteCapability() |
| 84 | |
| 85 | const base = buildNoumenaPlatformUrl('/v1/code/triggers') |
| 86 | const headers = { |
| 87 | Authorization: `Bearer ${accessToken}`, |
| 88 | 'Content-Type': 'application/json', |
| 89 | 'anthropic-version': '2023-06-01', |
| 90 | 'anthropic-beta': TRIGGERS_BETA, |
| 91 | 'x-organization-uuid': orgUUID, |
| 92 | } |
| 93 | |
| 94 | const { action, trigger_id, body } = input |
| 95 | let method: 'GET' | 'POST' |
| 96 | let url: string |
| 97 | let data: unknown |
| 98 | switch (action) { |
| 99 | case 'list': |
| 100 | method = 'GET' |
| 101 | url = base |
| 102 | break |
| 103 | case 'get': |
| 104 | if (!trigger_id) throw new Error('get requires trigger_id') |
| 105 | method = 'GET' |
| 106 | url = `${base}/${trigger_id}` |
| 107 | break |
| 108 | case 'create': |
| 109 | if (!body) throw new Error('create requires body') |
| 110 | method = 'POST' |
| 111 | url = base |
| 112 | data = body |
| 113 | break |
| 114 | case 'update': |
| 115 | if (!trigger_id) throw new Error('update requires trigger_id') |
| 116 | if (!body) throw new Error('update requires body') |
| 117 | method = 'POST' |
| 118 | url = `${base}/${trigger_id}` |
| 119 | data = body |
| 120 | break |
| 121 | case 'run': |
| 122 | if (!trigger_id) throw new Error('run requires trigger_id') |
| 123 | method = 'POST' |
| 124 | url = `${base}/${trigger_id}/run` |
| 125 | data = {} |
| 126 | break |
| 127 | } |
| 128 | |
| 129 | const res = await axios.request({ |
| 130 | method, |
| 131 | url, |
| 132 | headers, |
nothing calls this directly
no test coverage detected