Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 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
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>;
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,32 @@

import z from 'zod';

const baseField = z.object({
export const baseFieldSchema = z.object({
id: z.string().nonempty(),
label: z.string().nonempty(),
required: z.boolean(),
col_span: z.int().min(1).max(4).nullish(),
});

const textField = baseField.extend({
export const textFieldSchema = baseFieldSchema.extend({
type: z.literal('text'),
placeholder: z.string().nullish(),
default_value: z.string().nullish(),
auto_resize: z.boolean().default(true).nullish(),
});

export const textFieldValue = z.object({
type: textField.shape.type,
value: z.string().nullish(),
});

const dateField = baseField.extend({
export const dateFieldSchema = baseFieldSchema.extend({
type: z.literal('date'),
placeholder: z.string().nullish(),
default_value: z.string().nullish(),
});

export const dateFieldValue = z.object({
type: dateField.shape.type,
value: z.string().nullish(),
});

const fileField = baseField.extend({
export const fileFieldSchema = baseFieldSchema.extend({
type: z.literal('file'),
accept: z.array(z.string()),
});

export const fileFieldValue = z.object({
type: fileField.shape.type,
value: z
.array(
z.object({
uri: z.string(),
name: z.string().nullish(),
mime_type: z.string().nullish(),
}),
)
.nullish(),
});

export const singleSelectField = baseField.extend({
export const singleSelectFieldSchema = baseFieldSchema.extend({
type: z.literal('singleselect'),
options: z
.array(
Expand All @@ -66,12 +43,7 @@ export const singleSelectField = baseField.extend({
default_value: z.string().nullish(),
});

export const singleSelectFieldValue = z.object({
type: singleSelectField.shape.type,
value: z.string().nullish(),
});

export const multiSelectField = baseField.extend({
export const multiSelectFieldSchema = baseFieldSchema.extend({
type: z.literal('multiselect'),
options: z
.array(
Expand All @@ -84,61 +56,78 @@ export const multiSelectField = baseField.extend({
default_value: z.array(z.string()).nullish(),
});

export const multiSelectFieldValue = z.object({
type: multiSelectField.shape.type,
value: z.array(z.string()).nullish(),
});

export const checkboxField = baseField.extend({
export const checkboxFieldSchema = baseFieldSchema.extend({
type: z.literal('checkbox'),
content: z.string(),
default_value: z.boolean(),
});

export const checkboxFieldValue = z.object({
type: checkboxField.shape.type,
export const formFieldSchema = z.discriminatedUnion('type', [
textFieldSchema,
dateFieldSchema,
fileFieldSchema,
singleSelectFieldSchema,
multiSelectFieldSchema,
checkboxFieldSchema,
]);

export const textFieldValueSchema = z.object({
type: textFieldSchema.shape.type,
value: z.string().nullish(),
});

export const dateFieldValueSchema = z.object({
type: dateFieldSchema.shape.type,
value: z.string().nullish(),
});

export const fileFieldValueSchema = z.object({
type: fileFieldSchema.shape.type,
value: z
.array(
z.object({
uri: z.string(),
name: z.string().nullish(),
mime_type: z.string().nullish(),
}),
)
.nullish(),
});

export const singleSelectFieldValueSchema = z.object({
type: singleSelectFieldSchema.shape.type,
value: z.string().nullish(),
});

export const multiSelectFieldValueSchema = z.object({
type: multiSelectFieldSchema.shape.type,
value: z.array(z.string()).nullish(),
});

export const checkboxFieldValueSchema = z.object({
type: checkboxFieldSchema.shape.type,
value: z.boolean().nullish(),
});

const fieldSchema = z.discriminatedUnion('type', [
textField,
dateField,
fileField,
singleSelectField,
multiSelectField,
checkboxField,
export const formFieldValueSchema = z.discriminatedUnion('type', [
textFieldValueSchema,
dateFieldValueSchema,
fileFieldValueSchema,
singleSelectFieldValueSchema,
multiSelectFieldValueSchema,
checkboxFieldValueSchema,
]);

export const formRenderSchema = z.object({
title: z.string().nullish(),
description: z.string().nullish(),
columns: z.int().min(1).max(4).nullish(),
submit_label: z.string().nullish(),
fields: z.array(fieldSchema).nonempty(),
fields: z.array(formFieldSchema).nonempty(),
});

export const formValuesSchema = z.record(z.string(), formFieldValueSchema);

export const formResponseSchema = z.object({
values: z.record(
z.string(),
z.discriminatedUnion('type', [
textFieldValue,
dateFieldValue,
fileFieldValue,
singleSelectFieldValue,
multiSelectFieldValue,
checkboxFieldValue,
]),
),
values: formValuesSchema,
});

export type FormRender = z.infer<typeof formRenderSchema>;

export type TextField = z.infer<typeof textField>;
export type DateField = z.infer<typeof dateField>;
export type FileField = z.infer<typeof fileField>;
export type SingleSelectField = z.infer<typeof singleSelectField>;
export type MultiSelectField = z.infer<typeof multiSelectField>;
export type CheckboxField = z.infer<typeof checkboxField>;

export type FormField = z.infer<typeof fieldSchema>;
export type FormResponseValue = z.infer<typeof formResponseSchema>['values'][string];
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type z from 'zod';

import type {
checkboxFieldSchema,
checkboxFieldValueSchema,
dateFieldSchema,
dateFieldValueSchema,
fileFieldSchema,
fileFieldValueSchema,
formFieldSchema,
formFieldValueSchema,
formRenderSchema,
formResponseSchema,
formValuesSchema,
multiSelectFieldSchema,
multiSelectFieldValueSchema,
singleSelectFieldSchema,
singleSelectFieldValueSchema,
textFieldSchema,
textFieldValueSchema,
} from './schemas';

export type TextField = z.infer<typeof textFieldSchema>;
export type DateField = z.infer<typeof dateFieldSchema>;
export type FileField = z.infer<typeof fileFieldSchema>;
export type SingleSelectField = z.infer<typeof singleSelectFieldSchema>;
export type MultiSelectField = z.infer<typeof multiSelectFieldSchema>;
export type CheckboxField = z.infer<typeof checkboxFieldSchema>;

export type FormField = z.infer<typeof formFieldSchema>;

export type TextFieldValue = z.infer<typeof textFieldValueSchema>;
export type DateFieldValue = z.infer<typeof dateFieldValueSchema>;
export type FileFieldValue = z.infer<typeof fileFieldValueSchema>;
export type SingleSelectFieldValue = z.infer<typeof singleSelectFieldValueSchema>;
export type MultiSelectFieldValue = z.infer<typeof multiSelectFieldValueSchema>;
export type CheckboxFieldValue = z.infer<typeof checkboxFieldValueSchema>;

export type FormFieldValue = z.infer<typeof formFieldValueSchema>;

export type FormRender = z.infer<typeof formRenderSchema>;
export type FormValues = z.infer<typeof formValuesSchema>;
export type FormResponse = z.infer<typeof formResponseSchema>;
Loading
Loading