Skip to content

Commit 2bae3cd

Browse files
authored
fix: initial form rendering (#1453)
* fix: initial form rendering Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> * fix: code clarity Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com> --------- Signed-off-by: Tomas Weiss <tomas.weiss2@gmail.com>
1 parent ec7bf7b commit 2bae3cd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

apps/agentstack-sdk-ts/src/client/a2a/extensions/handle-agent-card.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { oauthProviderExtension } from './services/oauth-provider';
1717
import { platformApiExtension } from './services/platform';
1818
import type { SecretDemands, SecretFulfillments } from './services/secrets';
1919
import { secretsExtension } from './services/secrets';
20-
import type { FormDemands, FormFulfillments } from './ui/form';
20+
import type { FormFulfillments } from './ui/form';
2121
import { formExtension } from './ui/form';
2222
import { oauthRequestExtension } from './ui/oauth';
2323
import type { SettingsDemands, SettingsFulfillments } from './ui/settings';
@@ -31,7 +31,7 @@ export interface Fulfillments {
3131
oauth: (demand: OAuthDemands) => Promise<OAuthFulfillments>;
3232
settings: (demand: SettingsDemands) => Promise<SettingsFulfillments>;
3333
secrets: (demand: SecretDemands) => Promise<SecretFulfillments>;
34-
form: (demand: FormDemands) => Promise<FormFulfillments | null>;
34+
form: () => Promise<FormFulfillments | null>;
3535
oauthRedirectUri: () => string | null;
3636
getContextToken: () => ContextToken;
3737
}
@@ -92,11 +92,9 @@ export const handleAgentCard = (agentCard: { capabilities: AgentCapabilities })
9292
fulfilledMetadata = fulfillSecretDemand(fulfilledMetadata, await fulfillments.secrets(secretDemands));
9393
}
9494

95-
if (formDemands) {
96-
const formFulfillment = await fulfillments.form(formDemands);
97-
if (formFulfillment) {
98-
fulfilledMetadata = fulfillFormDemand(fulfilledMetadata, formFulfillment);
99-
}
95+
const formFulfillment = await fulfillments.form();
96+
if (formFulfillment) {
97+
fulfilledMetadata = fulfillFormDemand(fulfilledMetadata, formFulfillment);
10098
}
10199

102100
const oauthRedirectUri = fulfillments.oauthRedirectUri();

apps/agentstack-sdk-ts/src/client/a2a/extensions/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ export function extractServiceExtensionDemands<U extends string, D, F>(extension
3232

3333
return function (agentExtensions: AgentExtension[]) {
3434
const foundExtension = agentExtensions.find((agentExtension) => agentExtension.uri === uri);
35-
const { success, data: parsed } = schema.safeParse(foundExtension?.params ?? {});
35+
if (!foundExtension?.params) {
36+
return null;
37+
}
38+
const { success, data: parsed, error } = schema.safeParse(foundExtension.params);
3639

3740
if (!success) {
41+
console.warn(error);
42+
3843
return null;
3944
}
4045

0 commit comments

Comments
 (0)