@artinet/sdk 0.6.0-preview.1 → 0.6.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/client/a2a-client.js +4 -4
- package/dist/browser/config/index.d.ts +1 -1
- package/dist/browser/config/index.js +1 -1
- package/dist/browser/create/agentcard-builder.d.ts +47 -0
- package/dist/browser/create/agentcard-builder.js +65 -0
- package/dist/browser/create/base.d.ts +4 -0
- package/dist/browser/create/base.js +1 -0
- package/dist/browser/create/describe.d.ts +8 -0
- package/dist/browser/create/describe.js +8 -0
- package/dist/browser/create/message-builder.d.ts +78 -0
- package/dist/browser/create/message-builder.js +108 -0
- package/dist/browser/create/part-builder.d.ts +60 -0
- package/dist/browser/create/part-builder.js +81 -0
- package/dist/browser/create/task-builder.d.ts +251 -0
- package/dist/browser/create/task-builder.js +379 -0
- package/dist/browser/transport/rpc/parser.d.ts +1 -1
- package/dist/browser/transport/rpc/parser.js +2 -1
- package/dist/browser/types/a2a/a2a.d.ts +7 -3
- package/dist/browser/types/a2a/index.d.ts +3 -1
- package/dist/browser/types/a2a/index.js +0 -1
- package/dist/browser/utils/common/constants.d.ts +0 -5
- package/dist/browser/utils/common/constants.js +0 -27
- package/dist/browser/utils/common/errors.d.ts +57 -1
- package/dist/browser/utils/common/errors.js +68 -15
- package/dist/client/a2a-client.js +4 -4
- package/dist/config/default.d.ts +1 -1
- package/dist/config/default.js +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/create/agent-builder.d.ts +77 -0
- package/dist/create/agent-builder.js +20 -0
- package/dist/create/agentcard-builder.d.ts +47 -0
- package/dist/create/agentcard-builder.js +66 -0
- package/dist/create/base.d.ts +4 -0
- package/dist/create/base.js +1 -0
- package/dist/create/create.d.ts +762 -0
- package/dist/create/create.js +556 -0
- package/dist/create/describe.d.ts +8 -0
- package/dist/create/describe.js +8 -0
- package/dist/create/index.d.ts +4 -0
- package/dist/create/index.js +4 -0
- package/dist/create/message-builder.d.ts +78 -0
- package/dist/create/message-builder.js +110 -0
- package/dist/create/part-builder.d.ts +60 -0
- package/dist/create/part-builder.js +84 -0
- package/dist/create/status-builder.d.ts +26 -0
- package/dist/create/status-builder.js +46 -0
- package/dist/create/task-builder.d.ts +251 -0
- package/dist/create/task-builder.js +384 -0
- package/dist/create/transform.d.ts +16 -0
- package/dist/create/transform.js +106 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/server/express/errors.js +4 -8
- package/dist/server/express/middeware.js +17 -38
- package/dist/server/express/server.d.ts +6 -1
- package/dist/server/express/server.js +30 -12
- package/dist/services/a2a/execute.d.ts +5 -0
- package/dist/services/a2a/execute.js +7 -0
- package/dist/services/a2a/factory/context.d.ts +1 -1
- package/dist/services/a2a/factory/context.js +2 -3
- package/dist/services/a2a/factory/handler.js +3 -3
- package/dist/services/a2a/factory/index.d.ts +0 -1
- package/dist/services/a2a/factory/index.js +0 -1
- package/dist/services/a2a/factory/service.d.ts +2 -2
- package/dist/services/a2a/factory/service.js +2 -2
- package/dist/services/a2a/factory/state-machine.d.ts +1 -1
- package/dist/services/a2a/factory/state-machine.js +30 -8
- package/dist/services/a2a/handlers/artifact.d.ts +2 -5
- package/dist/services/a2a/handlers/artifact.js +21 -32
- package/dist/services/a2a/handlers/cancel-task.js +7 -5
- package/dist/services/a2a/handlers/resubscribe-task.d.ts +10 -2
- package/dist/services/a2a/handlers/resubscribe-task.js +21 -18
- package/dist/services/a2a/handlers/send-message.js +6 -10
- package/dist/services/a2a/handlers/stream-message.d.ts +10 -2
- package/dist/services/a2a/handlers/stream-message.js +5 -1
- package/dist/services/a2a/handlers/update.js +11 -6
- package/dist/services/a2a/helpers/content.d.ts +5 -1
- package/dist/services/a2a/helpers/content.js +5 -1
- package/dist/services/a2a/helpers/index.d.ts +2 -2
- package/dist/services/a2a/helpers/index.js +2 -2
- package/dist/services/a2a/index.d.ts +1 -1
- package/dist/services/a2a/index.js +1 -1
- package/dist/services/a2a/managers.js +7 -1
- package/dist/services/a2a/service.d.ts +6 -2
- package/dist/services/a2a/service.js +52 -59
- package/dist/services/a2a/state-machine.d.ts +3 -3
- package/dist/services/a2a/state-machine.js +2 -0
- package/dist/transport/rpc/parser.d.ts +1 -1
- package/dist/transport/rpc/parser.js +2 -1
- package/dist/types/a2a/a2a.d.ts +7 -3
- package/dist/types/a2a/index.d.ts +3 -1
- package/dist/types/a2a/index.js +0 -1
- package/dist/utils/common/constants.d.ts +0 -5
- package/dist/utils/common/constants.js +0 -27
- package/dist/utils/common/errors.d.ts +57 -1
- package/dist/utils/common/errors.js +68 -15
- package/dist/utils/common/parse.d.ts +1 -1
- package/dist/utils/common/schema-validation.d.ts +1 -1
- package/package.json +7 -4
- package/dist/browser/services/a2a/helpers/message-builder.d.ts +0 -17
- package/dist/browser/services/a2a/helpers/message-builder.js +0 -66
- package/dist/browser/types/a2a/builder.d.ts +0 -43
- package/dist/browser/types/a2a/builder.js +0 -5
- package/dist/services/a2a/factory/builder.d.ts +0 -292
- package/dist/services/a2a/factory/builder.js +0 -370
- package/dist/services/a2a/helpers/agentcard-builder.d.ts +0 -11
- package/dist/services/a2a/helpers/agentcard-builder.js +0 -27
- package/dist/services/a2a/helpers/message-builder.d.ts +0 -17
- package/dist/services/a2a/helpers/message-builder.js +0 -66
- package/dist/types/a2a/builder.d.ts +0 -43
- package/dist/types/a2a/builder.js +0 -5
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { A2A } from "../../../types/index.js";
|
|
6
|
-
export declare class MessageBuilder {
|
|
7
|
-
message: A2A.Message;
|
|
8
|
-
constructor(message?: Partial<A2A.Message>);
|
|
9
|
-
valueOf(): A2A.Message;
|
|
10
|
-
}
|
|
11
|
-
export declare const MESSAGE: (message?: Partial<A2A.Message>) => A2A.Message;
|
|
12
|
-
export declare class MessageSendConfigurationBuilder {
|
|
13
|
-
configuration: A2A.MessageSendConfiguration;
|
|
14
|
-
constructor(configuration?: Partial<A2A.MessageSendConfiguration> | null);
|
|
15
|
-
valueOf(): A2A.MessageSendConfiguration;
|
|
16
|
-
}
|
|
17
|
-
export declare const createMessageSendParams: (messageSendParams: Partial<A2A.MessageSendParams> | string) => A2A.MessageSendParams;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { v4 as uuidv4 } from "uuid";
|
|
6
|
-
export class MessageBuilder {
|
|
7
|
-
constructor(message = {}) {
|
|
8
|
-
this.message = {
|
|
9
|
-
role: "user",
|
|
10
|
-
parts: [],
|
|
11
|
-
metadata: undefined,
|
|
12
|
-
extensions: undefined,
|
|
13
|
-
referenceTaskIds: undefined,
|
|
14
|
-
messageId: uuidv4(),
|
|
15
|
-
taskId: undefined,
|
|
16
|
-
contextId: undefined,
|
|
17
|
-
kind: "message",
|
|
18
|
-
};
|
|
19
|
-
this.message.role = message.role ?? this.message.role;
|
|
20
|
-
this.message.parts = message.parts ?? this.message.parts;
|
|
21
|
-
this.message.metadata = message.metadata ?? this.message.metadata;
|
|
22
|
-
this.message.extensions = message.extensions ?? this.message.extensions;
|
|
23
|
-
this.message.referenceTaskIds =
|
|
24
|
-
message.referenceTaskIds ?? this.message.referenceTaskIds;
|
|
25
|
-
this.message.messageId = message.messageId ?? this.message.messageId;
|
|
26
|
-
this.message.taskId = message.taskId ?? this.message.taskId;
|
|
27
|
-
this.message.contextId = message.contextId ?? this.message.contextId;
|
|
28
|
-
}
|
|
29
|
-
valueOf() {
|
|
30
|
-
return this.message;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export const MESSAGE = (message = {}) => new MessageBuilder(message).message;
|
|
34
|
-
export class MessageSendConfigurationBuilder {
|
|
35
|
-
constructor(configuration = {}) {
|
|
36
|
-
this.configuration = {
|
|
37
|
-
acceptedOutputModes: undefined,
|
|
38
|
-
historyLength: undefined,
|
|
39
|
-
pushNotificationConfig: undefined,
|
|
40
|
-
blocking: undefined,
|
|
41
|
-
};
|
|
42
|
-
this.configuration.acceptedOutputModes =
|
|
43
|
-
configuration?.acceptedOutputModes ??
|
|
44
|
-
this.configuration.acceptedOutputModes;
|
|
45
|
-
this.configuration.historyLength =
|
|
46
|
-
configuration?.historyLength ?? this.configuration.historyLength;
|
|
47
|
-
this.configuration.pushNotificationConfig =
|
|
48
|
-
configuration?.pushNotificationConfig ??
|
|
49
|
-
this.configuration.pushNotificationConfig;
|
|
50
|
-
this.configuration.blocking =
|
|
51
|
-
configuration?.blocking ?? this.configuration.blocking;
|
|
52
|
-
}
|
|
53
|
-
valueOf() {
|
|
54
|
-
return this.configuration;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export const createMessageSendParams = (messageSendParams) => {
|
|
58
|
-
const isString = typeof messageSendParams === "string";
|
|
59
|
-
return {
|
|
60
|
-
message: new MessageBuilder(isString
|
|
61
|
-
? { parts: [{ text: messageSendParams, kind: "text" }] }
|
|
62
|
-
: messageSendParams.message).valueOf(),
|
|
63
|
-
configuration: new MessageSendConfigurationBuilder(isString ? undefined : messageSendParams.configuration).valueOf(),
|
|
64
|
-
metadata: isString ? undefined : messageSendParams.metadata,
|
|
65
|
-
};
|
|
66
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { MessageSendParams, DataPart, FilePart, TextPart } from "@artinet/types/a2a";
|
|
6
|
-
import { Context } from "./a2a.js";
|
|
7
|
-
/**
|
|
8
|
-
* Restricting to command for now, but could be extended to other types of commands in the future.
|
|
9
|
-
* When we shift to CoreCommand, move this into core.
|
|
10
|
-
*/
|
|
11
|
-
export interface StepArgs {
|
|
12
|
-
message: MessageSendParams;
|
|
13
|
-
context: Context;
|
|
14
|
-
skip: () => Promise<void> | void;
|
|
15
|
-
}
|
|
16
|
-
export type BaseArgs = Record<string, unknown>;
|
|
17
|
-
export type EmptyArgs = Record<string, never>;
|
|
18
|
-
export type StepParams<TInboundArgs extends BaseArgs = EmptyArgs> = StepArgs & Partial<{
|
|
19
|
-
content: string;
|
|
20
|
-
args: TInboundArgs;
|
|
21
|
-
}>;
|
|
22
|
-
export type PartContent = DataPart["data"] | FilePart["file"] | TextPart["text"];
|
|
23
|
-
export type StepOutput<TPart extends PartContent> = {
|
|
24
|
-
parts: Array<TPart> | TPart;
|
|
25
|
-
};
|
|
26
|
-
export type StepOutputWithForwardArgs<TPart extends PartContent, TForwardArgs extends BaseArgs = EmptyArgs> = StepOutput<TPart> & {
|
|
27
|
-
args: TForwardArgs;
|
|
28
|
-
};
|
|
29
|
-
export type OutputType<TPart extends PartContent, TForwardArgs extends BaseArgs = EmptyArgs> = StepOutput<TPart> | StepOutputWithForwardArgs<TPart, TForwardArgs> | Array<TPart> | TPart;
|
|
30
|
-
export type Step<TPart extends PartContent = TextPart["text"], TInboundArgs extends BaseArgs = EmptyArgs, TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<TPart, TForwardArgs> = OutputType<TPart, TForwardArgs>> = (params: StepParams<TInboundArgs>) => Promise<TOutput> | TOutput;
|
|
31
|
-
export type StepWithKind<TPart extends PartContent = TextPart["text"], TInboundArgs extends BaseArgs = EmptyArgs, TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<TPart, TForwardArgs> = OutputType<TPart, TForwardArgs>, TKind extends "text" | "file" | "data" = "text"> = {
|
|
32
|
-
step: Step<TPart, TInboundArgs, TForwardArgs, TOutput>;
|
|
33
|
-
kind: TKind;
|
|
34
|
-
};
|
|
35
|
-
export type OutArgsOf<O> = O extends StepOutputWithForwardArgs<any, infer A> ? A : EmptyArgs;
|
|
36
|
-
export interface StepBuilder<TInboundArgs extends BaseArgs = EmptyArgs> {
|
|
37
|
-
/**
|
|
38
|
-
* Add a step to the builder.
|
|
39
|
-
* @param step - The step to add.
|
|
40
|
-
* @returns A new builder with the step added.
|
|
41
|
-
*/
|
|
42
|
-
addStep<TPart extends PartContent = TextPart["text"], TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<TPart, TForwardArgs> = OutputType<TPart, TForwardArgs>, TKind extends "text" | "file" | "data" = "text">(step: StepWithKind<TPart, TInboundArgs, TForwardArgs, TOutput, TKind>): StepBuilder<OutArgsOf<TOutput>>;
|
|
43
|
-
}
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2025 The Artinet Project
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @fileoverview A2A Agent Builder and Execution Engine Factory
|
|
7
|
-
*
|
|
8
|
-
* This module provides a fluent builder API for constructing A2A agents and
|
|
9
|
-
* execution engines. It enables declarative definition of multi-step agent
|
|
10
|
-
* workflows with type-safe step composition and automatic execution orchestration.
|
|
11
|
-
*
|
|
12
|
-
* @module A2ABuilder
|
|
13
|
-
* @version 0.6.0-preview
|
|
14
|
-
* @since 0.5.6
|
|
15
|
-
* @author The Artinet Project
|
|
16
|
-
*/
|
|
17
|
-
import { StepBuilder, Step, A2A, StepWithKind, OutputType, BaseArgs, EmptyArgs, OutArgsOf, PartContent } from "../../../types/index.js";
|
|
18
|
-
import { ServiceParams } from "./service.js";
|
|
19
|
-
/**
|
|
20
|
-
* Type alias for text-based workflow steps.
|
|
21
|
-
*
|
|
22
|
-
* This type represents a step that processes or generates text content
|
|
23
|
-
* within an agent workflow. Text steps are the most common type of step
|
|
24
|
-
* and are used for message processing, content generation, and text-based
|
|
25
|
-
* decision making.
|
|
26
|
-
*
|
|
27
|
-
* @template TCommand - The command type, defaults to MessageSendParams
|
|
28
|
-
* @template TPart - The text part type, defaults to A2A.TextPart["text"]
|
|
29
|
-
* @template TInboundArgs - Arguments received from previous step
|
|
30
|
-
* @template TForwardArgs - Arguments passed to next step
|
|
31
|
-
* @template TOutput - The output type of the step
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const greetingStep: textStep = async ({ command, context, content, args }) => {
|
|
36
|
-
* const userName = command.message.metadata?.userName || 'there';
|
|
37
|
-
* return `Hello, ${userName}! How can I help you today?`;
|
|
38
|
-
* };
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
* @since 0.5.6
|
|
43
|
-
*/
|
|
44
|
-
export type textStep<TInboundArgs extends BaseArgs = EmptyArgs, TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.TextPart["text"], TForwardArgs> = OutputType<A2A.TextPart["text"], TForwardArgs>> = Step<A2A.TextPart["text"], TInboundArgs, TForwardArgs, TOutput>;
|
|
45
|
-
/**
|
|
46
|
-
* Type alias for file-based workflow steps.
|
|
47
|
-
*
|
|
48
|
-
* This type represents a step that processes or generates file content
|
|
49
|
-
* within an agent workflow. File steps handle document processing,
|
|
50
|
-
* file generation, and file-based data operations.
|
|
51
|
-
*
|
|
52
|
-
* @template TCommand - The command type, defaults to MessageSendParams
|
|
53
|
-
* @template TPart - The file part type, defaults to A2A.FilePart["file"]
|
|
54
|
-
* @template TInboundArgs - Arguments received from previous step
|
|
55
|
-
* @template TForwardArgs - Arguments passed to next step
|
|
56
|
-
* @template TOutput - The output type of the step
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const documentStep: fileStep = async ({ command, context, args }) => {
|
|
61
|
-
* const content = generateDocument(command.message.content);
|
|
62
|
-
* return {
|
|
63
|
-
* name: 'report.pdf',
|
|
64
|
-
* mimeType: 'application/pdf',
|
|
65
|
-
* bytes: content
|
|
66
|
-
* };
|
|
67
|
-
* };
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
* @since 0.5.6
|
|
72
|
-
*/
|
|
73
|
-
export type fileStep<TInboundArgs extends BaseArgs = EmptyArgs, TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.FilePart["file"], TForwardArgs> = OutputType<A2A.FilePart["file"], TForwardArgs>> = Step<A2A.FilePart["file"], TInboundArgs, TForwardArgs, TOutput>;
|
|
74
|
-
/**
|
|
75
|
-
* Type alias for data-based workflow steps.
|
|
76
|
-
*
|
|
77
|
-
* This type represents a step that processes or generates structured data
|
|
78
|
-
* within an agent workflow. Data steps handle JSON processing, API responses,
|
|
79
|
-
* and structured data transformations.
|
|
80
|
-
*
|
|
81
|
-
* @template TCommand - The command type, defaults to MessageSendParams
|
|
82
|
-
* @template TPart - The data part type, defaults to A2A.DataPart["data"]
|
|
83
|
-
* @template TInboundArgs - Arguments received from previous step
|
|
84
|
-
* @template TForwardArgs - Arguments passed to next step
|
|
85
|
-
* @template TOutput - The output type of the step
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
* const analyzeStep: dataStep = async ({ command, context, args }) => {
|
|
90
|
-
* const analysis = await analyzeMessage(command.message.content);
|
|
91
|
-
* return {
|
|
92
|
-
* sentiment: analysis.sentiment,
|
|
93
|
-
* entities: analysis.entities,
|
|
94
|
-
* confidence: analysis.confidence
|
|
95
|
-
* };
|
|
96
|
-
* };
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @public
|
|
100
|
-
* @since 0.5.6
|
|
101
|
-
*/
|
|
102
|
-
export type dataStep<TInboundArgs extends BaseArgs = EmptyArgs, TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.DataPart["data"], TForwardArgs> = OutputType<A2A.DataPart["data"], TForwardArgs>> = Step<A2A.DataPart["data"], TInboundArgs, TForwardArgs, TOutput>;
|
|
103
|
-
/**
|
|
104
|
-
* Fluent builder for constructing A2A agent execution engines.
|
|
105
|
-
*
|
|
106
|
-
* The EngineBuilder provides a type-safe, fluent API for composing multi-step
|
|
107
|
-
* agent workflows. It supports method chaining to build complex agent behaviors
|
|
108
|
-
* from individual processing steps, with automatic type inference and validation.
|
|
109
|
-
*
|
|
110
|
-
* @template TCommand - The command type, defaults to MessageSendParams
|
|
111
|
-
* @template TInboundArgs - The arguments type received from previous steps
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* const agent = EngineBuilder.create()
|
|
116
|
-
* .text(async ({ command }) => {
|
|
117
|
-
* return `Processing: ${command.message.content}`;
|
|
118
|
-
* })
|
|
119
|
-
* .data(async ({ args }) => {
|
|
120
|
-
* return { processed: true, timestamp: Date.now() };
|
|
121
|
-
* })
|
|
122
|
-
* .text(async ({ args }) => {
|
|
123
|
-
* return `Completed at ${new Date(args[0].timestamp)}`;
|
|
124
|
-
* })
|
|
125
|
-
* .createAgent({ agentCard: myAgentCard });
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @public
|
|
129
|
-
* @since 0.5.6
|
|
130
|
-
*/
|
|
131
|
-
export declare class EngineBuilder<TInboundArgs extends BaseArgs = EmptyArgs> implements StepBuilder<TInboundArgs> {
|
|
132
|
-
private steps;
|
|
133
|
-
/**
|
|
134
|
-
* Protected constructor to enforce factory method usage.
|
|
135
|
-
*
|
|
136
|
-
* @param steps - Initial steps array
|
|
137
|
-
*/
|
|
138
|
-
protected constructor(steps?: Array<StepWithKind<any, any, any, any, any>>);
|
|
139
|
-
/**
|
|
140
|
-
* Creates a new EngineBuilder instance.
|
|
141
|
-
*
|
|
142
|
-
* @template TCommand - The command type for the builder
|
|
143
|
-
* @template TInboundArgs - The initial arguments type
|
|
144
|
-
* @returns A new EngineBuilder instance
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const builder = EngineBuilder.create<MyCommand, [string, number]>();
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
static create<TInboundArgs extends BaseArgs = EmptyArgs>(): EngineBuilder<TInboundArgs>;
|
|
152
|
-
addStep<TPart extends PartContent = A2A.TextPart["text"], TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<TPart, TForwardArgs> = OutputType<TPart, TForwardArgs>, TKind extends "text" | "file" | "data" = "text">(step: StepWithKind<TPart, TInboundArgs, TForwardArgs, TOutput, TKind>): EngineBuilder<OutArgsOf<TOutput>>;
|
|
153
|
-
/**
|
|
154
|
-
* Adds a text processing step to the workflow.
|
|
155
|
-
*
|
|
156
|
-
* @template TPart - The text part type
|
|
157
|
-
* @template TForwardArgs - Arguments to forward to next step
|
|
158
|
-
* @template TOutput - The output type of the step
|
|
159
|
-
* @param step - The text step implementation
|
|
160
|
-
* @returns New builder instance with updated type parameters
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* builder.text(async ({ command, args }) => {
|
|
165
|
-
* return `Hello, ${command.message.content}!`;
|
|
166
|
-
* });
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
|
-
text<TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.TextPart["text"], TForwardArgs> = OutputType<A2A.TextPart["text"], TForwardArgs>>(step: textStep<TInboundArgs, TForwardArgs, TOutput> | string): EngineBuilder<OutArgsOf<TOutput>>;
|
|
170
|
-
/**
|
|
171
|
-
* Adds a file processing step to the workflow.
|
|
172
|
-
*
|
|
173
|
-
* @template TPart - The file part type
|
|
174
|
-
* @template TForwardArgs - Arguments to forward to next step
|
|
175
|
-
* @template TOutput - The output type of the step
|
|
176
|
-
* @param step - The file step implementation
|
|
177
|
-
* @returns New builder instance with updated type parameters
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* builder.file(async ({ command, args }) => {
|
|
182
|
-
* return {
|
|
183
|
-
* name: 'output.txt',
|
|
184
|
-
* mimeType: 'text/plain',
|
|
185
|
-
* bytes: Buffer.from(command.message.content)
|
|
186
|
-
* };
|
|
187
|
-
* });
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
file<TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.FilePart["file"], TForwardArgs> = OutputType<A2A.FilePart["file"], TForwardArgs>>(step: fileStep<TInboundArgs, TForwardArgs, TOutput>): EngineBuilder<OutArgsOf<TOutput>>;
|
|
191
|
-
/**
|
|
192
|
-
* Adds a data processing step to the workflow.
|
|
193
|
-
*
|
|
194
|
-
* @template TPart - The data part type
|
|
195
|
-
* @template TForwardArgs - Arguments to forward to next step
|
|
196
|
-
* @template TOutput - The output type of the step
|
|
197
|
-
* @param step - The data step implementation
|
|
198
|
-
* @returns New builder instance with updated type parameters
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* builder.data(async ({ command, args }) => {
|
|
203
|
-
* return {
|
|
204
|
-
* analysis: analyzeText(command.message.content),
|
|
205
|
-
* timestamp: Date.now()
|
|
206
|
-
* };
|
|
207
|
-
* });
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
data<TForwardArgs extends BaseArgs = EmptyArgs, TOutput extends OutputType<A2A.DataPart["data"], TForwardArgs> = OutputType<A2A.DataPart["data"], TForwardArgs>>(step: dataStep<TInboundArgs, TForwardArgs, TOutput>): EngineBuilder<OutArgsOf<TOutput>>;
|
|
211
|
-
/**
|
|
212
|
-
* Creates a complete A2A agent using the built workflow.
|
|
213
|
-
*
|
|
214
|
-
* @param params - Agent factory parameters (excluding engine)
|
|
215
|
-
* @returns Configured A2A agent instance
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```typescript
|
|
219
|
-
* const agent = builder.createAgent({
|
|
220
|
-
* agentCard: {
|
|
221
|
-
* id: 'my-agent',
|
|
222
|
-
* name: 'Assistant Agent',
|
|
223
|
-
* capabilities: ['text-processing']
|
|
224
|
-
* }
|
|
225
|
-
* });
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
createAgent(params: Omit<ServiceParams, "engine">): import("../service.js").Service;
|
|
229
|
-
/**
|
|
230
|
-
* Creates an agent execution engine from the built workflow.
|
|
231
|
-
*
|
|
232
|
-
* @returns Agent execution engine function
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```typescript
|
|
236
|
-
* const engine = builder.createAgentEngine();
|
|
237
|
-
* // Use engine with service execution
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
createAgentEngine(): A2A.Engine;
|
|
241
|
-
/**
|
|
242
|
-
* Builds the step list for the workflow.
|
|
243
|
-
*
|
|
244
|
-
* @returns Array of workflow steps
|
|
245
|
-
* @throws Error if no steps have been added
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* const steps = builder.build();
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
build(): StepWithKind<any, any, any, any, any>[];
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Convenience factory function for creating an agent builder with default parameters.
|
|
256
|
-
*
|
|
257
|
-
* @returns New EngineBuilder instance with MessageSendParams command type
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* const agent = AgentBuilder()
|
|
262
|
-
* .text(async ({ command }) => `Hello ${command.message.content}!`)
|
|
263
|
-
* .createAgent({ agentCard: myCard });
|
|
264
|
-
* ```
|
|
265
|
-
*
|
|
266
|
-
* @public
|
|
267
|
-
* @since 0.5.6
|
|
268
|
-
*/
|
|
269
|
-
export declare const AgentBuilder: () => EngineBuilder<EmptyArgs>;
|
|
270
|
-
/**
|
|
271
|
-
* Creates an agent execution engine from a list of workflow steps.
|
|
272
|
-
*
|
|
273
|
-
* This function transforms a list of step definitions into an executable
|
|
274
|
-
* agent engine that processes commands through the defined workflow,
|
|
275
|
-
* yielding updates as each step completes.
|
|
276
|
-
*
|
|
277
|
-
* @param stepsList - Array of workflow steps to execute
|
|
278
|
-
* @returns Agent execution engine function
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* ```typescript
|
|
282
|
-
* const steps = [
|
|
283
|
-
* { kind: 'text', step: greetingStep },
|
|
284
|
-
* { kind: 'data', step: analysisStep }
|
|
285
|
-
* ];
|
|
286
|
-
* const engine = createAgentExecutor(steps);
|
|
287
|
-
* ```
|
|
288
|
-
*
|
|
289
|
-
* @public
|
|
290
|
-
* @since 0.5.6
|
|
291
|
-
*/
|
|
292
|
-
export declare function createAgentExecutor(stepsList: StepWithKind[]): A2A.Engine;
|