INNER CODE UNIT · TypeScript
agent37Platform
rowboatlabs/rowboat · apps/harbor/packages/server/src/connectors/agent37/index.ts:15
export function agent37Platform(base = AGENT37_API, instance: InstanceUrl = instanceUrl): ConnectorPlatform {
return {
async verify(secret, target) {
let instances;
try {
instances = await agent37Api(secret, base, instance).instances();
} catch (err) {
if (err instanceof Agent37Error && err.rejectsKey) throw new HarborError('invalid_request', `Agent37 did not accept this key: ${err.message}`);
throw new HarborError('invalid_request', `Agent37 could not check this key: ${(err as Error).message}`);
}
const found = instances.find((i) => i.id === target.instance);
if (!found) throw new HarborError('invalid_request', `This Agent37 key does not reach an instance ${target.instance ?? '(none named)'}`);
if (['failed', 'deleted', 'deleting'].includes(found.status)) throw new HarborError('invalid_request', `The Agent37 instance ${found.id} is ${found.status}`);
const runs = kindOfTemplate(found.template);
if (runs !== target.kind) {
throw new HarborError('invalid_request', `The Agent37 instance ${found.id} runs ${found.template || 'an unknown template'}, not ${target.kind}`);
}
},