@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
100 lines • 3.47 kB
TypeScript
/**
* The slice of A2A 1.0 (HTTP+JSON binding) this surface speaks: the message shapes, the AIP-193 error
* envelope, and the request validation PACT §4.1 asks for. Hand-rolled rather than schema-validated —
* `zod` is an optional peer, and the rules are few and exact.
*/
export declare const A2A_CONTENT_TYPE = "application/a2a+json";
export type A2aRole = 'ROLE_USER' | 'ROLE_AGENT';
export interface A2aTextPart {
text: string;
metadata?: Record<string, unknown>;
}
/** A structured part (A2A `DataPart`): what an action did, for the personal agent to relay. */
export interface A2aDataPart {
data: unknown;
mediaType?: string;
metadata?: Record<string, unknown>;
}
export interface A2aMessage {
messageId: string;
contextId?: string;
taskId?: string;
role: A2aRole;
parts: (A2aTextPart | A2aDataPart)[];
metadata?: Record<string, unknown>;
}
export interface A2aTask {
id: string;
contextId: string;
status: {
state: 'TASK_STATE_AUTH_REQUIRED';
message: A2aMessage;
};
metadata?: Record<string, unknown>;
}
/** What `message:send` answers: a message (an ordinary turn) or a task (step-up). */
export type A2aSendResult = {
message: A2aMessage;
} | {
task: A2aTask;
};
/** The A2A error reasons PACT §6 uses, with their HTTP status and google.rpc status. */
declare const REASONS: {
readonly INVALID_PARAMS: {
readonly httpStatus: 400;
readonly status: 'INVALID_ARGUMENT';
};
readonly CONTENT_TYPE_NOT_SUPPORTED: {
readonly httpStatus: 400;
readonly status: 'INVALID_ARGUMENT';
};
readonly UNSUPPORTED_OPERATION: {
readonly httpStatus: 400;
readonly status: 'FAILED_PRECONDITION';
};
readonly PUSH_NOTIFICATION_NOT_SUPPORTED: {
readonly httpStatus: 400;
readonly status: 'FAILED_PRECONDITION';
};
readonly TASK_NOT_FOUND: {
readonly httpStatus: 404;
readonly status: 'NOT_FOUND';
};
readonly INTERNAL: {
readonly httpStatus: 500;
readonly status: 'INTERNAL';
};
};
export type A2aErrorReason = keyof typeof REASONS;
/** An A2A error — answered as the AIP-193 envelope, never as a bare status. */
export declare class A2aError extends Error {
readonly reason: A2aErrorReason;
constructor(reason: A2aErrorReason, message: string);
get httpStatus(): number;
toJSON(): {
error: {
code: 400 | 404 | 500;
status: "FAILED_PRECONDITION" | "INTERNAL" | "INVALID_ARGUMENT" | "NOT_FOUND";
message: string;
details: {
'@type': string;
reason: "CONTENT_TYPE_NOT_SUPPORTED" | "INTERNAL" | "INVALID_PARAMS" | "PUSH_NOTIFICATION_NOT_SUPPORTED" | "TASK_NOT_FOUND" | "UNSUPPORTED_OPERATION";
domain: string;
}[];
};
};
}
/** A validated `message:send` request: the user's text and the ids the turn is addressed by. */
export interface SendMessageInput {
messageId: string;
contextId?: string;
text: string;
}
/**
* Parse and validate a `SendMessageRequest` body (PACT §4.1). `configuration` and `metadata` are
* accepted and ignored. Order matters where the conformance suite pins it: a `taskId` is
* `TASK_NOT_FOUND` even on an otherwise valid message.
*/
export declare function parseSendMessage(raw: string): SendMessageInput;
export {};
//# sourceMappingURL=protocol.d.ts.map