fix: enforce atomic agent registration contract

This commit is contained in:
ZacharyZhang-NY committed 2026-07-19 15:38:40 -04:00
1 parent 47d323c17b
commit f64d00673c
58 files changed
+2692 -1667

No files matched your search

+2
View File
@@ -28,6 +28,7 @@ import type {
ErrorResponse,
} from './types.js';
import { ElydoraError } from './errors.js';
import { assertIntegrationType } from './integration-types.js';
import {
jcsCanonicalise,
computePayloadHash,
@@ -148,6 +149,7 @@ export class ElydoraClient {
// -------------------------------------------------------------------------
async registerAgent(request: RegisterAgentRequest): Promise<RegisterAgentResponse> {
assertIntegrationType(request?.integration_type);
return this.request<RegisterAgentResponse>('POST', '/v1/agents/register', request);
}
+2
View File
@@ -1,5 +1,6 @@
export { ElydoraClient } from './client.js';
export { ElydoraError } from './errors.js';
export { INTEGRATION_TYPES } from './types.js';
export {
jcsCanonicalise,
@@ -24,6 +25,7 @@ export type {
KeyStatus,
ExportStatus,
RbacRole,
IntegrationType,
ErrorCode,
// Entities
+11
View File
@@ -0,0 +1,11 @@
import { INTEGRATION_TYPES, type IntegrationType } from './types.js';
export function assertIntegrationType(value: unknown): asserts value is IntegrationType {
const isSupported = typeof value === 'string'
&& INTEGRATION_TYPES.some((integrationType) => integrationType === value);
if (!isSupported) {
throw new TypeError(
`Invalid integration_type "${String(value)}". Expected one of: ${INTEGRATION_TYPES.join(', ')}`,
);
}
}
+24
View File
@@ -11,6 +11,28 @@ export type RbacRole =
| 'compliance_auditor'
| 'readonly_investigator'
| 'integration_engineer';
export const INTEGRATION_TYPES = [
'augment',
'claudecode',
'cline',
'codex',
'copilot',
'cursor',
'droid',
'gemini',
'grok',
'kimi',
'kirocli',
'kiroide',
'letta',
'opencode',
'qwen',
'enterprise',
'gui',
'sdk',
'other',
] as const;
export type IntegrationType = (typeof INTEGRATION_TYPES)[number];
export type ErrorCode =
| 'INVALID_SIGNATURE'
| 'UNKNOWN_AGENT'
@@ -36,6 +58,7 @@ export interface Agent {
readonly org_id: string;
readonly display_name: string;
readonly responsible_entity: string;
readonly integration_type: IntegrationType;
readonly status: AgentStatus;
readonly created_at: number;
readonly updated_at: number;
@@ -160,6 +183,7 @@ export interface EAR {
export interface RegisterAgentRequest {
readonly agent_id: string;
readonly integration_type: IntegrationType;
readonly display_name?: string;
readonly responsible_entity?: string;
readonly keys: ReadonlyArray<{