@agentbridgeai/core 0.1.0
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/LICENSE +21 -0
- package/dist/action-executor.d.ts +9 -0
- package/dist/action-executor.d.ts.map +1 -0
- package/dist/action-executor.js +50 -0
- package/dist/action-executor.js.map +1 -0
- package/dist/conversation.d.ts +10 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +29 -0
- package/dist/conversation.js.map +1 -0
- package/dist/engine.d.ts +23 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +109 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-registry.d.ts +23 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +64 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentBridge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolCall, ToolResult, Session } from './types.js';
|
|
2
|
+
import { PluginRegistry } from './plugin-registry.js';
|
|
3
|
+
export declare class ActionExecutor {
|
|
4
|
+
private registry;
|
|
5
|
+
constructor(registry: PluginRegistry);
|
|
6
|
+
execute(toolCall: ToolCall, session: Session, askUser: (question: string) => Promise<string>): Promise<ToolResult>;
|
|
7
|
+
executeAll(toolCalls: ToolCall[], session: Session, askUser: (question: string) => Promise<string>): Promise<ToolResult[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=action-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-executor.d.ts","sourceRoot":"","sources":["../src/action-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA+B,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc;IAEtC,OAAO,CACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAC7C,OAAO,CAAC,UAAU,CAAC;IA4ChB,UAAU,CACd,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAC7C,OAAO,CAAC,UAAU,EAAE,CAAC;CAKzB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class ActionExecutor {
|
|
2
|
+
registry;
|
|
3
|
+
constructor(registry) {
|
|
4
|
+
this.registry = registry;
|
|
5
|
+
}
|
|
6
|
+
async execute(toolCall, session, askUser) {
|
|
7
|
+
const action = this.registry.getAction(toolCall.pluginName, toolCall.actionName);
|
|
8
|
+
if (!action) {
|
|
9
|
+
return {
|
|
10
|
+
toolCallId: toolCall.id,
|
|
11
|
+
result: {
|
|
12
|
+
success: false,
|
|
13
|
+
message: `Unknown action: ${toolCall.pluginName}.${toolCall.actionName}`,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// Validate parameters against the action's zod schema
|
|
18
|
+
const parseResult = action.parameters.safeParse(toolCall.parameters);
|
|
19
|
+
if (!parseResult.success) {
|
|
20
|
+
return {
|
|
21
|
+
toolCallId: toolCall.id,
|
|
22
|
+
result: {
|
|
23
|
+
success: false,
|
|
24
|
+
message: `Invalid parameters: ${parseResult.error.issues.map(i => i.message).join(', ')}`,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const context = {
|
|
29
|
+
session,
|
|
30
|
+
ask: askUser,
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
const result = await action.execute(parseResult.data, context);
|
|
34
|
+
return { toolCallId: toolCall.id, result };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
toolCallId: toolCall.id,
|
|
39
|
+
result: {
|
|
40
|
+
success: false,
|
|
41
|
+
message: `Action failed: ${error.message}`,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async executeAll(toolCalls, session, askUser) {
|
|
47
|
+
return Promise.all(toolCalls.map(tc => this.execute(tc, session, askUser)));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=action-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-executor.js","sourceRoot":"","sources":["../src/action-executor.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAAG,CAAC;IAEhD,KAAK,CAAC,OAAO,CACX,QAAkB,EAClB,OAAgB,EAChB,OAA8C;QAE9C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,EAAE;gBACvB,MAAM,EAAE;oBACN,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,mBAAmB,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,EAAE;iBACzE;aACF,CAAC;QACJ,CAAC;QAED,sDAAsD;QACtD,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,EAAE;gBACvB,MAAM,EAAE;oBACN,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,uBAAuB,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;iBAC1F;aACF,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAkB;YAC7B,OAAO;YACP,GAAG,EAAE,OAAO;SACb,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,EAAE;gBACvB,MAAM,EAAE;oBACN,OAAO,EAAE,KAAK;oBACd,OAAO,EAAE,kBAAkB,KAAK,CAAC,OAAO,EAAE;iBAC3C;aACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CACd,SAAqB,EACrB,OAAgB,EAChB,OAA8C;QAE9C,OAAO,OAAO,CAAC,GAAG,CAChB,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CACxD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Session, Message } from './types.js';
|
|
2
|
+
export declare class ConversationManager {
|
|
3
|
+
private sessions;
|
|
4
|
+
create(): Session;
|
|
5
|
+
get(sessionId: string): Session | undefined;
|
|
6
|
+
addMessage(sessionId: string, message: Message): void;
|
|
7
|
+
getMessages(sessionId: string): Message[];
|
|
8
|
+
destroy(sessionId: string): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEnD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAmC;IAEnD,MAAM,IAAI,OAAO;IAUjB,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI3C,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAMrD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE;IAIzC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGjC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
export class ConversationManager {
|
|
3
|
+
sessions = new Map();
|
|
4
|
+
create() {
|
|
5
|
+
const session = {
|
|
6
|
+
id: randomUUID(),
|
|
7
|
+
messages: [],
|
|
8
|
+
metadata: {},
|
|
9
|
+
};
|
|
10
|
+
this.sessions.set(session.id, session);
|
|
11
|
+
return session;
|
|
12
|
+
}
|
|
13
|
+
get(sessionId) {
|
|
14
|
+
return this.sessions.get(sessionId);
|
|
15
|
+
}
|
|
16
|
+
addMessage(sessionId, message) {
|
|
17
|
+
const session = this.sessions.get(sessionId);
|
|
18
|
+
if (!session)
|
|
19
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
20
|
+
session.messages.push(message);
|
|
21
|
+
}
|
|
22
|
+
getMessages(sessionId) {
|
|
23
|
+
return this.sessions.get(sessionId)?.messages ?? [];
|
|
24
|
+
}
|
|
25
|
+
destroy(sessionId) {
|
|
26
|
+
this.sessions.delete(sessionId);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,MAAM,OAAO,mBAAmB;IACtB,QAAQ,GAAyB,IAAI,GAAG,EAAE,CAAC;IAEnD,MAAM;QACJ,MAAM,OAAO,GAAY;YACvB,EAAE,EAAE,UAAU,EAAE;YAChB,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,EAAE;SACb,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,SAAiB;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,UAAU,CAAC,SAAiB,EAAE,OAAgB;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,WAAW,CAAC,SAAiB;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,SAAiB;QACvB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;CACF"}
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentBridgeConfig, Plugin, ToolCall, ActionResult } from './types.js';
|
|
2
|
+
export declare class AgentBridgeEngine {
|
|
3
|
+
private registry;
|
|
4
|
+
private executor;
|
|
5
|
+
private conversations;
|
|
6
|
+
private llm;
|
|
7
|
+
private systemPrompt;
|
|
8
|
+
constructor(config: AgentBridgeConfig);
|
|
9
|
+
registerPlugin(plugin: Plugin): Promise<void>;
|
|
10
|
+
getPlugins(): Plugin[];
|
|
11
|
+
createSession(): string;
|
|
12
|
+
private buildSystemPrompt;
|
|
13
|
+
/**
|
|
14
|
+
* Process a user message and return the assistant's response.
|
|
15
|
+
* Handles the full loop: LLM call → tool execution → follow-up LLM call.
|
|
16
|
+
*/
|
|
17
|
+
chat(sessionId: string, userMessage: string, options?: {
|
|
18
|
+
askUser?: (question: string) => Promise<string>;
|
|
19
|
+
onToolCall?: (toolCall: ToolCall) => void;
|
|
20
|
+
onToolResult?: (actionName: string, result: ActionResult) => void;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EAGN,QAAQ,EACR,YAAY,EACb,MAAM,YAAY,CAAC;AAapB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,iBAAiB;IAc/B,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,UAAU,IAAI,MAAM,EAAE;IAItB,aAAa,IAAI,MAAM;IAUvB,OAAO,CAAC,iBAAiB;IAYzB;;;OAGG;IACG,IAAI,CACR,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAChD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;QAC1C,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;KACnE,GACA,OAAO,CAAC,MAAM,CAAC;CA8DnB"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PluginRegistry } from './plugin-registry.js';
|
|
2
|
+
import { ActionExecutor } from './action-executor.js';
|
|
3
|
+
import { ConversationManager } from './conversation.js';
|
|
4
|
+
const DEFAULT_SYSTEM_PROMPT = `You are AgentBridge, a helpful AI assistant that can interact with various apps and services on behalf of the user.
|
|
5
|
+
|
|
6
|
+
You have access to tools provided by installed plugins. Use them when the user asks you to perform actions.
|
|
7
|
+
|
|
8
|
+
When a tool call fails or parameters are missing, ask the user for the needed information.
|
|
9
|
+
|
|
10
|
+
Be concise and helpful. When you perform an action, report the result clearly.`;
|
|
11
|
+
export class AgentBridgeEngine {
|
|
12
|
+
registry;
|
|
13
|
+
executor;
|
|
14
|
+
conversations;
|
|
15
|
+
llm;
|
|
16
|
+
systemPrompt;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.registry = new PluginRegistry();
|
|
19
|
+
this.executor = new ActionExecutor(this.registry);
|
|
20
|
+
this.conversations = new ConversationManager();
|
|
21
|
+
this.llm = config.llmProvider;
|
|
22
|
+
this.systemPrompt = config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
23
|
+
if (config.plugins) {
|
|
24
|
+
for (const plugin of config.plugins) {
|
|
25
|
+
this.registerPlugin(plugin);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async registerPlugin(plugin) {
|
|
30
|
+
await this.registry.register(plugin);
|
|
31
|
+
}
|
|
32
|
+
getPlugins() {
|
|
33
|
+
return this.registry.getAllPlugins();
|
|
34
|
+
}
|
|
35
|
+
createSession() {
|
|
36
|
+
const session = this.conversations.create();
|
|
37
|
+
// Add system message
|
|
38
|
+
this.conversations.addMessage(session.id, {
|
|
39
|
+
role: 'system',
|
|
40
|
+
content: this.buildSystemPrompt(),
|
|
41
|
+
});
|
|
42
|
+
return session.id;
|
|
43
|
+
}
|
|
44
|
+
buildSystemPrompt() {
|
|
45
|
+
const plugins = this.registry.getAllPlugins();
|
|
46
|
+
const pluginList = plugins
|
|
47
|
+
.map(p => `- **${p.name}**: ${p.description}`)
|
|
48
|
+
.join('\n');
|
|
49
|
+
return `${this.systemPrompt}
|
|
50
|
+
|
|
51
|
+
## Available Plugins
|
|
52
|
+
${pluginList || 'No plugins installed.'}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Process a user message and return the assistant's response.
|
|
56
|
+
* Handles the full loop: LLM call → tool execution → follow-up LLM call.
|
|
57
|
+
*/
|
|
58
|
+
async chat(sessionId, userMessage, options) {
|
|
59
|
+
const session = this.conversations.get(sessionId);
|
|
60
|
+
if (!session)
|
|
61
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
62
|
+
// Add user message
|
|
63
|
+
this.conversations.addMessage(sessionId, {
|
|
64
|
+
role: 'user',
|
|
65
|
+
content: userMessage,
|
|
66
|
+
});
|
|
67
|
+
const tools = this.registry.toLLMTools();
|
|
68
|
+
const maxIterations = 10; // prevent infinite tool-calling loops
|
|
69
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
70
|
+
const messages = this.conversations.getMessages(sessionId);
|
|
71
|
+
const response = await this.llm.chat(messages, tools);
|
|
72
|
+
// If no tool calls, return the text response
|
|
73
|
+
if (!response.toolCalls || response.toolCalls.length === 0) {
|
|
74
|
+
const text = response.text ?? 'I have nothing to say.';
|
|
75
|
+
this.conversations.addMessage(sessionId, {
|
|
76
|
+
role: 'assistant',
|
|
77
|
+
content: text,
|
|
78
|
+
});
|
|
79
|
+
return text;
|
|
80
|
+
}
|
|
81
|
+
// Add assistant message with tool calls
|
|
82
|
+
this.conversations.addMessage(sessionId, {
|
|
83
|
+
role: 'assistant',
|
|
84
|
+
content: response.text ?? '',
|
|
85
|
+
toolCalls: response.toolCalls,
|
|
86
|
+
});
|
|
87
|
+
// Execute each tool call
|
|
88
|
+
const askUser = options?.askUser ?? (async () => '');
|
|
89
|
+
const toolResults = await this.executor.executeAll(response.toolCalls, session, askUser);
|
|
90
|
+
// Add tool results as messages
|
|
91
|
+
for (const tr of toolResults) {
|
|
92
|
+
const tc = response.toolCalls.find(t => t.id === tr.toolCallId);
|
|
93
|
+
if (options?.onToolCall && tc)
|
|
94
|
+
options.onToolCall(tc);
|
|
95
|
+
if (options?.onToolResult && tc) {
|
|
96
|
+
options.onToolResult(`${tc.pluginName}.${tc.actionName}`, tr.result);
|
|
97
|
+
}
|
|
98
|
+
this.conversations.addMessage(sessionId, {
|
|
99
|
+
role: 'tool',
|
|
100
|
+
content: JSON.stringify(tr.result),
|
|
101
|
+
toolCallId: tr.toolCallId,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Loop back so the LLM can process the tool results
|
|
105
|
+
}
|
|
106
|
+
return 'I got stuck in a loop. Please try again.';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,qBAAqB,GAAG;;;;;;+EAMiD,CAAC;AAEhF,MAAM,OAAO,iBAAiB;IACpB,QAAQ,CAAiB;IACzB,QAAQ,CAAiB;IACzB,aAAa,CAAsB;IACnC,GAAG,CAAc;IACjB,YAAY,CAAS;IAE7B,YAAY,MAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC/C,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AAO,GAAG,OAAO,EAAE,OAAO,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACrD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAChD,QAAQ,CAAC,SAAS,EAClB,OAAO,EACP,OAAO,CACR,CAAC;YAEF,+BAA+B;YAC/B,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;gBAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;gBAChE,IAAI,OAAO,EAAE,UAAU,IAAI,EAAE;oBAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBACtD,IAAI,OAAO,EAAE,YAAY,IAAI,EAAE,EAAE,CAAC;oBAChC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;gBACvE,CAAC;gBAED,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE;oBACvC,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC;oBAClC,UAAU,EAAE,EAAE,CAAC,UAAU;iBAC1B,CAAC,CAAC;YACL,CAAC;YAED,oDAAoD;QACtD,CAAC;QAED,OAAO,0CAA0C,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AgentBridgeEngine } from './engine.js';
|
|
2
|
+
export { PluginRegistry } from './plugin-registry.js';
|
|
3
|
+
export { ActionExecutor } from './action-executor.js';
|
|
4
|
+
export { ConversationManager } from './conversation.js';
|
|
5
|
+
export type { Plugin, Action, ActionResult, ActionContext, AuthConfig, AuthField, Session, Message, ToolCall, ToolResult, LLMProvider, LLMTool, LLMResponse, AgentBridgeConfig, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,EACR,UAAU,EACV,WAAW,EACX,OAAO,EACP,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Plugin, Action, LLMTool } from './types.js';
|
|
2
|
+
export declare class PluginRegistry {
|
|
3
|
+
private plugins;
|
|
4
|
+
register(plugin: Plugin): Promise<void>;
|
|
5
|
+
unregister(name: string): void;
|
|
6
|
+
getPlugin(name: string): Plugin | undefined;
|
|
7
|
+
getAction(pluginName: string, actionName: string): Action | undefined;
|
|
8
|
+
getAllPlugins(): Plugin[];
|
|
9
|
+
/**
|
|
10
|
+
* Convert all plugin actions into LLM tool definitions.
|
|
11
|
+
* Tool names are formatted as "pluginName__actionName" so the LLM
|
|
12
|
+
* can call them and we can route back to the right plugin.
|
|
13
|
+
*/
|
|
14
|
+
toLLMTools(): LLMTool[];
|
|
15
|
+
/**
|
|
16
|
+
* Parse a tool name like "weather__get_weather" back into plugin + action names
|
|
17
|
+
*/
|
|
18
|
+
static parseToolName(toolName: string): {
|
|
19
|
+
pluginName: string;
|
|
20
|
+
actionName: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=plugin-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAkC;IAE3C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAQ9B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKrE,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;OAIG;IACH,UAAU,IAAI,OAAO,EAAE;IAqBvB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAOnF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
2
|
+
export class PluginRegistry {
|
|
3
|
+
plugins = new Map();
|
|
4
|
+
async register(plugin) {
|
|
5
|
+
if (this.plugins.has(plugin.name)) {
|
|
6
|
+
throw new Error(`Plugin "${plugin.name}" is already registered`);
|
|
7
|
+
}
|
|
8
|
+
if (plugin.setup) {
|
|
9
|
+
await plugin.setup();
|
|
10
|
+
}
|
|
11
|
+
this.plugins.set(plugin.name, plugin);
|
|
12
|
+
}
|
|
13
|
+
unregister(name) {
|
|
14
|
+
const plugin = this.plugins.get(name);
|
|
15
|
+
if (plugin?.teardown) {
|
|
16
|
+
plugin.teardown();
|
|
17
|
+
}
|
|
18
|
+
this.plugins.delete(name);
|
|
19
|
+
}
|
|
20
|
+
getPlugin(name) {
|
|
21
|
+
return this.plugins.get(name);
|
|
22
|
+
}
|
|
23
|
+
getAction(pluginName, actionName) {
|
|
24
|
+
const plugin = this.plugins.get(pluginName);
|
|
25
|
+
return plugin?.actions.find(a => a.name === actionName);
|
|
26
|
+
}
|
|
27
|
+
getAllPlugins() {
|
|
28
|
+
return Array.from(this.plugins.values());
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Convert all plugin actions into LLM tool definitions.
|
|
32
|
+
* Tool names are formatted as "pluginName__actionName" so the LLM
|
|
33
|
+
* can call them and we can route back to the right plugin.
|
|
34
|
+
*/
|
|
35
|
+
toLLMTools() {
|
|
36
|
+
const tools = [];
|
|
37
|
+
for (const plugin of this.plugins.values()) {
|
|
38
|
+
for (const action of plugin.actions) {
|
|
39
|
+
const jsonSchema = zodToJsonSchema(action.parameters, {
|
|
40
|
+
target: 'openApi3',
|
|
41
|
+
});
|
|
42
|
+
// Remove the top-level $schema key that zodToJsonSchema adds
|
|
43
|
+
const { $schema, ...parameterSchema } = jsonSchema;
|
|
44
|
+
tools.push({
|
|
45
|
+
name: `${plugin.name}__${action.name}`,
|
|
46
|
+
description: `[${plugin.name}] ${action.description}`,
|
|
47
|
+
parameters: parameterSchema,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return tools;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse a tool name like "weather__get_weather" back into plugin + action names
|
|
55
|
+
*/
|
|
56
|
+
static parseToolName(toolName) {
|
|
57
|
+
const [pluginName, actionName] = toolName.split('__');
|
|
58
|
+
if (!pluginName || !actionName) {
|
|
59
|
+
throw new Error(`Invalid tool name format: "${toolName}". Expected "pluginName__actionName"`);
|
|
60
|
+
}
|
|
61
|
+
return { pluginName, actionName };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=plugin-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../src/plugin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,OAAO,cAAc;IACjB,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEjD,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,WAAW,MAAM,CAAC,IAAI,yBAAyB,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,SAAS,CAAC,IAAY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AAC,CAAC;QACtD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,sCAAsC,CAAC,CAAC;QAChG,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;IACpC,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface Plugin {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
version: string;
|
|
6
|
+
actions: Action[];
|
|
7
|
+
auth?: AuthConfig;
|
|
8
|
+
setup?: () => Promise<void>;
|
|
9
|
+
teardown?: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface Action {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: z.ZodType<any>;
|
|
15
|
+
execute: (params: any, context: ActionContext) => Promise<ActionResult>;
|
|
16
|
+
confirm?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ActionResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
data?: any;
|
|
21
|
+
message: string;
|
|
22
|
+
followUp?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ActionContext {
|
|
25
|
+
session: Session;
|
|
26
|
+
auth?: Record<string, string>;
|
|
27
|
+
ask: (question: string) => Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
export interface AuthConfig {
|
|
30
|
+
type: 'api_key' | 'oauth2' | 'custom';
|
|
31
|
+
fields: AuthField[];
|
|
32
|
+
}
|
|
33
|
+
export interface AuthField {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
required: boolean;
|
|
37
|
+
secret?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface Session {
|
|
40
|
+
id: string;
|
|
41
|
+
messages: Message[];
|
|
42
|
+
metadata: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
export interface Message {
|
|
45
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
46
|
+
content: string;
|
|
47
|
+
toolCallId?: string;
|
|
48
|
+
toolCalls?: ToolCall[];
|
|
49
|
+
}
|
|
50
|
+
export interface ToolCall {
|
|
51
|
+
id: string;
|
|
52
|
+
pluginName: string;
|
|
53
|
+
actionName: string;
|
|
54
|
+
parameters: Record<string, any>;
|
|
55
|
+
}
|
|
56
|
+
export interface ToolResult {
|
|
57
|
+
toolCallId: string;
|
|
58
|
+
result: ActionResult;
|
|
59
|
+
}
|
|
60
|
+
export interface LLMProvider {
|
|
61
|
+
name: string;
|
|
62
|
+
chat(messages: Message[], tools: LLMTool[]): Promise<LLMResponse>;
|
|
63
|
+
}
|
|
64
|
+
export interface LLMTool {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
parameters: Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
export interface LLMResponse {
|
|
70
|
+
text?: string;
|
|
71
|
+
toolCalls?: ToolCall[];
|
|
72
|
+
}
|
|
73
|
+
export interface AgentBridgeConfig {
|
|
74
|
+
llmProvider: LLMProvider;
|
|
75
|
+
plugins?: Plugin[];
|
|
76
|
+
systemPrompt?: string;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,OAAO,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MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;CACtB;AAID,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAID,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentbridgeai/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Engine, plugin registry, and conversation manager for AgentBridge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/ranausmanai/AgentBridge.git",
|
|
12
|
+
"directory": "packages/core"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://agentbridge.cc",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"ai",
|
|
23
|
+
"agents",
|
|
24
|
+
"api",
|
|
25
|
+
"llm",
|
|
26
|
+
"openapi",
|
|
27
|
+
"agentbridge"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"zod": "^3.23.0",
|
|
31
|
+
"zod-to-json-schema": "^3.23.0",
|
|
32
|
+
"conf": "^13.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.0.0",
|
|
36
|
+
"typescript": "^5.5.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"dev": "tsc --watch",
|
|
41
|
+
"clean": "rm -rf dist"
|
|
42
|
+
}
|
|
43
|
+
}
|