Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions apps/agentstack-sdk-ts/src/client/a2a/core/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import z from 'zod';

import { MessageRole } from './types';

export const textPartSchema = z.object({
kind: z.literal('text'),
text: z.string(),
metadata: z.record(z.string(), z.unknown()).nullish(),
});

export const fileWithBytesSchema = z.object({
bytes: z.string(),
mimeType: z.string().nullish(),
name: z.string().nullish(),
});

export const fileWithUriSchema = z.object({
uri: z.string(),
mimeType: z.string().nullish(),
name: z.string().nullish(),
});

export const filePartSchema = z.object({
kind: z.literal('file'),
file: z.union([fileWithBytesSchema, fileWithUriSchema]),
metadata: z.record(z.string(), z.unknown()).nullish(),
});

export const dataPartSchema = z.object({
kind: z.literal('data'),
data: z.record(z.string(), z.unknown()),
metadata: z.record(z.string(), z.unknown()).nullish(),
});

export const partSchema = z.union([textPartSchema, filePartSchema, dataPartSchema]);

export const artifactSchema = z.object({
artifactId: z.string(),
parts: z.array(partSchema),
description: z.string().nullish(),
extensions: z.array(z.string()).nullish(),
metadata: z.record(z.string(), z.unknown()).nullish(),
name: z.string().nullish(),
});

export const messageRoleSchema = z.enum(MessageRole);

export const messageSchema = z.object({
kind: z.literal('message'),
messageId: z.string(),
parts: z.array(partSchema),
role: messageRoleSchema,
contextId: z.string().nullish(),
extensions: z.array(z.string()).nullish(),
metadata: z.record(z.string(), z.unknown()).nullish(),
referenceTaskIds: z.array(z.string()).nullish(),
taskId: z.string().nullish(),
});
38 changes: 38 additions & 0 deletions apps/agentstack-sdk-ts/src/client/a2a/core/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type z from 'zod';

import type {
artifactSchema,
dataPartSchema,
filePartSchema,
fileWithBytesSchema,
fileWithUriSchema,
messageSchema,
partSchema,
textPartSchema,
} from './schemas';

export type TextPart = z.infer<typeof textPartSchema>;

export type FileWithBytes = z.infer<typeof fileWithBytesSchema>;

export type FileWithUri = z.infer<typeof fileWithUriSchema>;

export type FilePart = z.infer<typeof filePartSchema>;

export type DataPart = z.infer<typeof dataPartSchema>;

export type Part = z.infer<typeof partSchema>;

export type Artifact = z.infer<typeof artifactSchema>;

export enum MessageRole {
Agent = 'agent',
User = 'user',
}

export type Message = z.infer<typeof messageSchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import z from 'zod';

import type { A2AServiceExtension, A2AUiExtension } from '../../core/types';
import { oAuthDemandsSchema, oAuthFulfillmentsSchema, oAuthRequestSchema } from './schemas';
import type { OAuthDemands, OAuthFulfillments, OAuthRequest } from './types';

const URI = 'https://a2a-extensions.agentstack.beeai.dev/auth/oauth/v1';

export const oAuthExtension: A2AServiceExtension<typeof URI, OAuthDemands, OAuthFulfillments> = {
getUri: () => URI,
getDemandsSchema: () => oAuthDemandsSchema,
getFulfillmentsSchema: () => oAuthFulfillmentsSchema,
};

export const oAuthRequestExtension: A2AUiExtension<typeof URI, OAuthRequest> = {
getUri: () => URI,
getMessageMetadataSchema: () => z.object({ [URI]: oAuthRequestSchema }).partial(),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import z from 'zod';

export const oAuthDemandSchema = z.object({
redirect_uri: z.boolean(),
});

export const oAuthDemandsSchema = z.object({
oauth_demands: z.record(z.string(), oAuthDemandSchema),
});

export const oAuthFulfillmentSchema = z.object({
redirect_uri: z.string(),
});

export const oAuthFulfillmentsSchema = z.object({
oauth_fulfillments: z.record(z.string(), oAuthFulfillmentSchema),
});

export const oAuthRequestSchema = z.object({
authorization_endpoint_url: z.string(),
});

export const oAuthResponseSchema = z.object({
redirect_uri: z.string(),
});

export const oAuthMessageSchema = z.object({
data: oAuthResponseSchema,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type z from 'zod';

import type {
oAuthDemandSchema,
oAuthDemandsSchema,
oAuthFulfillmentSchema,
oAuthFulfillmentsSchema,
oAuthMessageSchema,
oAuthRequestSchema,
oAuthResponseSchema,
} from './schemas';

export type OAuthDemand = z.infer<typeof oAuthDemandSchema>;
export type OAuthDemands = z.infer<typeof oAuthDemandsSchema>;

export type OAuthFulfillment = z.infer<typeof oAuthFulfillmentSchema>;
export type OAuthFulfillments = z.infer<typeof oAuthFulfillmentsSchema>;

export type OAuthRequest = z.infer<typeof oAuthRequestSchema>;
export type OAuthResponse = z.infer<typeof oAuthResponseSchema>;

export type OAuthMessage = z.infer<typeof oAuthMessageSchema>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import z from 'zod';

import type { A2AServiceExtension, A2AUiExtension } from '../../core/types';
import { secretDemandsSchema, secretFulfillmentsSchema } from './schemas';
import type { SecretDemands, SecretFulfillments } from './types';

const URI = 'https://a2a-extensions.agentstack.beeai.dev/auth/secrets/v1';

export const secretsExtension: A2AServiceExtension<typeof URI, SecretDemands, SecretFulfillments> = {
getUri: () => URI,
getDemandsSchema: () => secretDemandsSchema,
getFulfillmentsSchema: () => secretFulfillmentsSchema,
};

export const secretsRequestExtension: A2AUiExtension<typeof URI, SecretDemands> = {
getUri: () => URI,
getMessageMetadataSchema: () => z.object({ [URI]: secretDemandsSchema }).partial(),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import z from 'zod';

export const secretDemandSchema = z.object({
name: z.string(),
description: z.string().nullish(),
});

export const secretDemandsSchema = z.object({
secret_demands: z.record(z.string(), secretDemandSchema),
});

export const secretFulfillmentSchema = z.object({
secret: z.string(),
});

export const secretFulfillmentsSchema = z.object({
secret_fulfillments: z.record(z.string(), secretFulfillmentSchema),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type z from 'zod';

import type {
secretDemandSchema,
secretDemandsSchema,
secretFulfillmentSchema,
secretFulfillmentsSchema,
} from './schemas';

export type SecretDemand = z.infer<typeof secretDemandSchema>;
export type SecretDemands = z.infer<typeof secretDemandsSchema>;

export type SecretFulfillment = z.infer<typeof secretFulfillmentSchema>;
export type SecretFulfillments = z.infer<typeof secretFulfillmentsSchema>;
Loading
Loading