@looopy-ai/core 2.0.1 → 2.1.1
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/dist/core/agent.d.ts +4 -5
- package/dist/core/iteration.d.ts +1 -1
- package/dist/core/loop.d.ts +1 -1
- package/dist/core/tools.d.ts +1 -1
- package/dist/core/types.d.ts +5 -6
- package/dist/observability/spans/iteration.d.ts +1 -1
- package/dist/observability/spans/llm-call.d.ts +2 -2
- package/dist/observability/spans/tool.d.ts +1 -1
- package/dist/skills/registry.d.ts +1 -1
- package/dist/tools/agent-tool-provider.d.ts +7 -7
- package/dist/tools/agent-tool-provider.js +31 -23
- package/dist/tools/artifact-tools.d.ts +1 -1
- package/dist/tools/client-tool-provider.d.ts +5 -5
- package/dist/tools/local-tools.d.ts +5 -5
- package/dist/tools/mcp-client.d.ts +3 -4
- package/dist/tools/mcp-tool-provider.d.ts +6 -6
- package/dist/tools/tool-result-events.d.ts +2 -2
- package/dist/types/context.d.ts +1 -6
- package/dist/types/tools.d.ts +2 -2
- package/package.json +2 -2
package/dist/core/agent.d.ts
CHANGED
|
@@ -2,17 +2,16 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import type { SkillRegistry } from '../skills';
|
|
3
3
|
import type { MessageStore } from '../stores/messages/interfaces';
|
|
4
4
|
import type { AgentState, AgentStore } from '../types/agent';
|
|
5
|
-
import type { AuthContext } from '../types/context';
|
|
6
5
|
import type { ContextAnyEvent } from '../types/event';
|
|
7
6
|
import type { LLMProvider } from '../types/llm';
|
|
8
7
|
import type { Message } from '../types/message';
|
|
9
8
|
import type { ToolProvider } from '../types/tools';
|
|
10
9
|
import type { SystemPromptProp } from '../utils/prompt';
|
|
11
|
-
export interface AgentConfig {
|
|
10
|
+
export interface AgentConfig<AuthContext> {
|
|
12
11
|
agentId: string;
|
|
13
12
|
contextId: string;
|
|
14
13
|
llmProvider: LLMProvider;
|
|
15
|
-
toolProviders: ToolProvider[];
|
|
14
|
+
toolProviders: ToolProvider<AuthContext>[];
|
|
16
15
|
messageStore: MessageStore;
|
|
17
16
|
agentStore?: AgentStore;
|
|
18
17
|
autoCompact?: boolean;
|
|
@@ -25,13 +24,13 @@ export interface GetMessagesOptions {
|
|
|
25
24
|
maxMessages?: number;
|
|
26
25
|
maxTokens?: number;
|
|
27
26
|
}
|
|
28
|
-
export declare class Agent {
|
|
27
|
+
export declare class Agent<AuthContext> {
|
|
29
28
|
private readonly config;
|
|
30
29
|
private _state;
|
|
31
30
|
private logger;
|
|
32
31
|
private shuttingDown;
|
|
33
32
|
private shutdownComplete;
|
|
34
|
-
constructor(config: AgentConfig);
|
|
33
|
+
constructor(config: AgentConfig<AuthContext>);
|
|
35
34
|
get state(): Readonly<AgentState>;
|
|
36
35
|
get agentId(): string;
|
|
37
36
|
get contextId(): string;
|
package/dist/core/iteration.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { type Observable } from 'rxjs';
|
|
|
2
2
|
import type { ContextAnyEvent } from '../types/event';
|
|
3
3
|
import type { Message } from '../types/message';
|
|
4
4
|
import type { IterationConfig, LoopContext } from './types';
|
|
5
|
-
export declare const runIteration: (context: LoopContext
|
|
5
|
+
export declare const runIteration: <AuthContext>(context: LoopContext<AuthContext>, config: IterationConfig, history: Message[]) => Observable<ContextAnyEvent>;
|
package/dist/core/loop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ContextAnyEvent } from '../types/event';
|
|
2
2
|
import type { Message } from '../types/message';
|
|
3
3
|
import type { LoopConfig, TurnContext } from './types';
|
|
4
|
-
export declare const runLoop: (context: TurnContext
|
|
4
|
+
export declare const runLoop: <AuthContext>(context: TurnContext<AuthContext>, config: LoopConfig, history: Message[]) => import("rxjs").Observable<ContextAnyEvent>;
|
package/dist/core/tools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
2
|
import type { ContextAnyEvent, ContextEvent, ToolCallEvent } from '../types/event';
|
|
3
3
|
import type { IterationContext } from './types';
|
|
4
|
-
export declare const runToolCall: (context: IterationContext
|
|
4
|
+
export declare const runToolCall: <AuthContext>(context: IterationContext<AuthContext>, toolCall: ContextEvent<ToolCallEvent>) => Observable<ContextAnyEvent>;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import type pino from 'pino';
|
|
2
2
|
import type { SkillRegistry } from '../skills';
|
|
3
|
-
import type { AuthContext } from '../types/context';
|
|
4
3
|
import type { LLMProvider } from '../types/llm';
|
|
5
4
|
import type { ToolProvider } from '../types/tools';
|
|
6
5
|
import type { SystemPromptProp } from '../utils';
|
|
7
|
-
export type AgentContext = {
|
|
6
|
+
export type AgentContext<AuthContext> = {
|
|
8
7
|
agentId: string;
|
|
9
8
|
contextId: string;
|
|
10
9
|
parentContext: import('@opentelemetry/api').Context;
|
|
11
10
|
authContext?: AuthContext;
|
|
12
|
-
toolProviders: ToolProvider[];
|
|
11
|
+
toolProviders: ToolProvider<AuthContext>[];
|
|
13
12
|
logger: pino.Logger;
|
|
14
13
|
systemPrompt?: SystemPromptProp;
|
|
15
14
|
skillRegistry?: SkillRegistry;
|
|
16
15
|
metadata?: Record<string, unknown>;
|
|
17
16
|
};
|
|
18
|
-
export type TurnContext = AgentContext & {
|
|
17
|
+
export type TurnContext<AuthContext> = AgentContext<AuthContext> & {
|
|
19
18
|
taskId: string;
|
|
20
19
|
turnNumber: number;
|
|
21
20
|
};
|
|
22
|
-
export type LoopContext = TurnContext
|
|
23
|
-
export type IterationContext = TurnContext
|
|
21
|
+
export type LoopContext<AuthContext> = TurnContext<AuthContext>;
|
|
22
|
+
export type IterationContext<AuthContext> = TurnContext<AuthContext>;
|
|
24
23
|
export type LoopConfig = {
|
|
25
24
|
llmProvider: LLMProvider;
|
|
26
25
|
maxIterations: number;
|
|
@@ -7,7 +7,7 @@ export interface LoopIterationSpanParams {
|
|
|
7
7
|
iteration: number;
|
|
8
8
|
parentContext: import('@opentelemetry/api').Context;
|
|
9
9
|
}
|
|
10
|
-
export declare const startLoopIterationSpan: (context: LoopContext
|
|
10
|
+
export declare const startLoopIterationSpan: <AuthContext>(context: LoopContext<AuthContext>, iteration: number) => {
|
|
11
11
|
span: import("@opentelemetry/api").Span;
|
|
12
12
|
traceContext: import("@opentelemetry/api").Context;
|
|
13
13
|
tapFinish: import("rxjs").MonoTypeOperatorFunction<ContextAnyEvent>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ToolDefinition } from '../..';
|
|
2
1
|
import type { LoopContext } from '../../core/types';
|
|
3
2
|
import type { AnyEvent } from '../../types/event';
|
|
4
3
|
import type { Message } from '../../types/message';
|
|
4
|
+
import type { ToolDefinition } from '../../types/tools';
|
|
5
5
|
import type { SystemPrompt } from '../../utils/prompt';
|
|
6
6
|
export interface LLMCallSpanParams {
|
|
7
7
|
agentId: string;
|
|
@@ -9,7 +9,7 @@ export interface LLMCallSpanParams {
|
|
|
9
9
|
messages: Message[];
|
|
10
10
|
parentContext: import('@opentelemetry/api').Context;
|
|
11
11
|
}
|
|
12
|
-
export declare const startLLMCallSpan: (context: LoopContext
|
|
12
|
+
export declare const startLLMCallSpan: <AuthContext>(context: LoopContext<AuthContext>, systemPrompt: SystemPrompt | undefined, messages: Message[], tools: ToolDefinition[]) => {
|
|
13
13
|
span: import("@opentelemetry/api").Span;
|
|
14
14
|
traceContext: import("@opentelemetry/api").Context;
|
|
15
15
|
tapFinish: import("rxjs").MonoTypeOperatorFunction<AnyEvent>;
|
|
@@ -7,7 +7,7 @@ export interface ToolExecutionSpanParams {
|
|
|
7
7
|
toolCall: ToolCall;
|
|
8
8
|
parentContext?: import('@opentelemetry/api').Context;
|
|
9
9
|
}
|
|
10
|
-
export declare const startToolExecuteSpan: (context: IterationContext
|
|
10
|
+
export declare const startToolExecuteSpan: <AuthContext>(context: IterationContext<AuthContext>, toolStart: ToolCallEvent) => {
|
|
11
11
|
span: import("@opentelemetry/api").Span;
|
|
12
12
|
traceContext: import("@opentelemetry/api").Context;
|
|
13
13
|
tapFinish: import("rxjs").MonoTypeOperatorFunction<ContextAnyEvent>;
|
|
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import type { ContextAnyEvent, ExecutionContext } from '../types';
|
|
4
4
|
import type { ToolCall, ToolDefinition, ToolProvider } from '../types/tools';
|
|
5
|
-
export type HeaderFactory = (context: ExecutionContext
|
|
5
|
+
export type HeaderFactory<AuthContext> = (context: ExecutionContext<AuthContext>, card: AgentCard) => Promise<Record<string, string | undefined>>;
|
|
6
6
|
declare const cardSchema: z.ZodObject<{
|
|
7
7
|
name: z.ZodString;
|
|
8
8
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -19,18 +19,18 @@ declare const cardSchema: z.ZodObject<{
|
|
|
19
19
|
}, z.core.$strip>>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
type AgentCard = z.infer<typeof cardSchema>;
|
|
22
|
-
export declare class AgentToolProvider implements ToolProvider {
|
|
22
|
+
export declare class AgentToolProvider<AuthContext> implements ToolProvider<AuthContext> {
|
|
23
23
|
readonly card: AgentCard;
|
|
24
|
-
readonly getHeaders?: HeaderFactory | undefined;
|
|
25
|
-
static fromUrl: (cardUrl: string, getHeaders?: HeaderFactory) => Promise<AgentToolProvider
|
|
26
|
-
static from: (card: AgentCard, getHeaders?: HeaderFactory) => AgentToolProvider
|
|
24
|
+
readonly getHeaders?: HeaderFactory<AuthContext> | undefined;
|
|
25
|
+
static fromUrl: <AuthContext_1>(cardUrl: string, getHeaders?: HeaderFactory<AuthContext_1>) => Promise<AgentToolProvider<AuthContext_1>>;
|
|
26
|
+
static from: <AuthContext_1>(card: AgentCard, getHeaders?: HeaderFactory<AuthContext_1>) => AgentToolProvider<AuthContext_1>;
|
|
27
27
|
private readonly agentName;
|
|
28
28
|
readonly name: string;
|
|
29
29
|
private readonly tools;
|
|
30
30
|
private readonly logger;
|
|
31
|
-
constructor(card: AgentCard, getHeaders?: HeaderFactory | undefined);
|
|
31
|
+
constructor(card: AgentCard, getHeaders?: HeaderFactory<AuthContext> | undefined);
|
|
32
32
|
getTool(toolName: string): Promise<ToolDefinition | undefined>;
|
|
33
33
|
getTools(): Promise<ToolDefinition[]>;
|
|
34
|
-
execute(toolCall: ToolCall, context: ExecutionContext): Observable<ContextAnyEvent>;
|
|
34
|
+
execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): Observable<ContextAnyEvent>;
|
|
35
35
|
}
|
|
36
36
|
export {};
|
|
@@ -74,20 +74,24 @@ export class AgentToolProvider {
|
|
|
74
74
|
return Promise.resolve(this.tools);
|
|
75
75
|
}
|
|
76
76
|
execute(toolCall, context) {
|
|
77
|
-
this.logger.
|
|
77
|
+
const logger = this.logger.child({
|
|
78
|
+
taskId: context.taskId,
|
|
79
|
+
toolCallId: toolCall.id,
|
|
80
|
+
});
|
|
81
|
+
logger.debug({ toolCallId: toolCall.id }, 'Executing agent tool call');
|
|
78
82
|
return new Observable((subscriber) => {
|
|
79
83
|
const abortController = new AbortController();
|
|
80
84
|
const run = async () => {
|
|
81
85
|
const tool = await this.getTool(toolCall.function.name);
|
|
82
86
|
if (!tool) {
|
|
83
|
-
|
|
87
|
+
logger.error({ toolName: toolCall.function.name }, 'Tool not found');
|
|
84
88
|
subscriber.next(toolErrorEvent(context, toolCall, `Tool not found: ${toolCall.function.name}`));
|
|
85
89
|
subscriber.complete();
|
|
86
90
|
return;
|
|
87
91
|
}
|
|
88
92
|
const prompt = toolCall.function.arguments.prompt;
|
|
89
93
|
if (!prompt || typeof prompt !== 'string') {
|
|
90
|
-
|
|
94
|
+
logger.error('Invalid tool call arguments');
|
|
91
95
|
subscriber.next(toolErrorEvent(context, toolCall, 'Tool argument must include "prompt" and it must be a string'));
|
|
92
96
|
subscriber.complete();
|
|
93
97
|
return;
|
|
@@ -103,47 +107,51 @@ export class AgentToolProvider {
|
|
|
103
107
|
signal: abortController.signal,
|
|
104
108
|
});
|
|
105
109
|
if (!res.ok) {
|
|
106
|
-
|
|
110
|
+
logger.error({ status: res.status, statusText: res.statusText }, 'Agent call failed');
|
|
107
111
|
subscriber.next(toolErrorEvent(context, toolCall, `Agent endpoint responded with ${res.status} ${res.statusText}`));
|
|
108
112
|
subscriber.complete();
|
|
109
113
|
return;
|
|
110
114
|
}
|
|
111
115
|
const body = res.body;
|
|
112
116
|
if (!body) {
|
|
113
|
-
|
|
117
|
+
logger.error('Agent response has no body');
|
|
114
118
|
subscriber.next(toolErrorEvent(context, toolCall, 'Agent returned no response body'));
|
|
115
119
|
subscriber.complete();
|
|
116
120
|
return;
|
|
117
121
|
}
|
|
122
|
+
let content = '';
|
|
118
123
|
await consumeSSEStream(body, (e) => {
|
|
119
124
|
if (subscriber.closed)
|
|
120
125
|
return;
|
|
126
|
+
const data = JSON.parse(e.data);
|
|
121
127
|
subscriber.next({
|
|
122
128
|
kind: e.event,
|
|
123
129
|
parentTaskId: context.taskId,
|
|
124
|
-
...
|
|
130
|
+
...data,
|
|
125
131
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (!subscriber.closed) {
|
|
129
|
-
const toolCompleteEvent = {
|
|
130
|
-
kind: 'tool-complete',
|
|
131
|
-
contextId: context.contextId,
|
|
132
|
-
taskId: context.taskId,
|
|
133
|
-
toolCallId: toolCall.id,
|
|
134
|
-
toolName: toolCall.function.name,
|
|
135
|
-
success: true,
|
|
136
|
-
result: 'Complete',
|
|
137
|
-
timestamp: new Date().toISOString(),
|
|
138
|
-
};
|
|
139
|
-
subscriber.next(toolCompleteEvent);
|
|
140
|
-
subscriber.complete();
|
|
141
|
-
this.logger.debug('Tool execution complete');
|
|
132
|
+
if (e.event === 'task-complete') {
|
|
133
|
+
content = data.content;
|
|
142
134
|
}
|
|
135
|
+
logger.debug({ event: e.event }, 'Received SSE event');
|
|
143
136
|
});
|
|
137
|
+
if (!subscriber.closed) {
|
|
138
|
+
const toolCompleteEvent = {
|
|
139
|
+
kind: 'tool-complete',
|
|
140
|
+
contextId: context.contextId,
|
|
141
|
+
taskId: context.taskId,
|
|
142
|
+
toolCallId: toolCall.id,
|
|
143
|
+
toolName: toolCall.function.name,
|
|
144
|
+
success: true,
|
|
145
|
+
result: content || 'Complete',
|
|
146
|
+
timestamp: new Date().toISOString(),
|
|
147
|
+
};
|
|
148
|
+
subscriber.next(toolCompleteEvent);
|
|
149
|
+
subscriber.complete();
|
|
150
|
+
logger.debug('Tool execution complete');
|
|
151
|
+
}
|
|
144
152
|
};
|
|
145
153
|
run().catch((err) => {
|
|
146
|
-
|
|
154
|
+
logger.error({ err }, 'Tool execution error');
|
|
147
155
|
if (!subscriber.closed) {
|
|
148
156
|
subscriber.error(err);
|
|
149
157
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ArtifactStore } from '../types/artifact';
|
|
2
2
|
import type { TaskStateStore } from '../types/state';
|
|
3
3
|
import type { ToolProvider } from '../types/tools';
|
|
4
|
-
export declare function createArtifactTools(artifactStore: ArtifactStore, taskStateStore: TaskStateStore): ToolProvider
|
|
4
|
+
export declare function createArtifactTools<AuthContext>(artifactStore: ArtifactStore, taskStateStore: TaskStateStore): ToolProvider<AuthContext>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { ExecutionContext } from '../types/context';
|
|
2
2
|
import { type ToolCall, type ToolDefinition, type ToolProvider, type ToolResult } from '../types/tools';
|
|
3
|
-
export interface ClientToolConfig {
|
|
3
|
+
export interface ClientToolConfig<AuthContext> {
|
|
4
4
|
tools: unknown;
|
|
5
|
-
onInputRequired: (toolCall: ToolCall, context: ExecutionContext) => Promise<ToolResult>;
|
|
5
|
+
onInputRequired: (toolCall: ToolCall, context: ExecutionContext<AuthContext>) => Promise<ToolResult>;
|
|
6
6
|
}
|
|
7
|
-
export declare class ClientToolProvider implements ToolProvider {
|
|
7
|
+
export declare class ClientToolProvider<AuthContext> implements ToolProvider<AuthContext> {
|
|
8
8
|
name: string;
|
|
9
9
|
private readonly tools;
|
|
10
10
|
private readonly toolNames;
|
|
11
11
|
private readonly onInputRequired;
|
|
12
|
-
constructor(config: ClientToolConfig);
|
|
12
|
+
constructor(config: ClientToolConfig<AuthContext>);
|
|
13
13
|
getTools(): Promise<ToolDefinition[]>;
|
|
14
|
-
execute(toolCall: ToolCall, context: ExecutionContext): import("rxjs").Observable<import("..").ContextAnyEvent | import("..").ContextEvent<import("..").ToolCompleteEvent>>;
|
|
14
|
+
execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): import("rxjs").Observable<import("..").ContextAnyEvent | import("..").ContextEvent<import("..").ToolCompleteEvent>>;
|
|
15
15
|
getTool(name: string): Promise<ToolDefinition | undefined>;
|
|
16
16
|
validateToolArguments(toolCall: ToolCall): Promise<{
|
|
17
17
|
valid: boolean;
|
|
@@ -2,14 +2,14 @@ import { z } from 'zod';
|
|
|
2
2
|
import type { ExecutionContext } from '../types/context';
|
|
3
3
|
import type { ToolProvider, ToolResult } from '../types/tools';
|
|
4
4
|
type InternalToolResult = Omit<ToolResult, 'toolCallId' | 'toolName'>;
|
|
5
|
-
export type ToolHandler<TParams> = (params: TParams, context: ExecutionContext) => Promise<InternalToolResult> | InternalToolResult;
|
|
6
|
-
export interface LocalToolDefinition<TSchema extends z.ZodObject> {
|
|
5
|
+
export type ToolHandler<TParams, AuthContext> = (params: TParams, context: ExecutionContext<AuthContext>) => Promise<InternalToolResult> | InternalToolResult;
|
|
6
|
+
export interface LocalToolDefinition<TSchema extends z.ZodObject, AuthContext> {
|
|
7
7
|
name: string;
|
|
8
8
|
description: string;
|
|
9
9
|
icon?: string;
|
|
10
10
|
schema: TSchema;
|
|
11
|
-
handler: ToolHandler<z.infer<TSchema
|
|
11
|
+
handler: ToolHandler<z.infer<TSchema>, AuthContext>;
|
|
12
12
|
}
|
|
13
|
-
export declare function tool<TSchema extends z.ZodObject>(definition: LocalToolDefinition<TSchema>): LocalToolDefinition<TSchema>;
|
|
14
|
-
export declare function localTools(tools: LocalToolDefinition<z.ZodObject>[]): ToolProvider
|
|
13
|
+
export declare function tool<TSchema extends z.ZodObject, AuthContext>(definition: LocalToolDefinition<TSchema, AuthContext>): LocalToolDefinition<TSchema, AuthContext>;
|
|
14
|
+
export declare function localTools<AuthContext>(tools: LocalToolDefinition<z.ZodObject, AuthContext>[]): ToolProvider<AuthContext>;
|
|
15
15
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AuthContext } from '../types/context';
|
|
2
1
|
import type { FunctionParameters } from '../types/tools';
|
|
3
2
|
export interface MCPTool {
|
|
4
3
|
name: string;
|
|
@@ -10,16 +9,16 @@ export interface MCPToolResponse {
|
|
|
10
9
|
result: unknown;
|
|
11
10
|
executionTime: number;
|
|
12
11
|
}
|
|
13
|
-
export interface MCPClientConfig {
|
|
12
|
+
export interface MCPClientConfig<AuthContext> {
|
|
14
13
|
baseUrl: string;
|
|
15
14
|
getHeaders: (authContext?: AuthContext) => Record<string, string>;
|
|
16
15
|
timeout?: number;
|
|
17
16
|
}
|
|
18
|
-
export declare class MCPClient {
|
|
17
|
+
export declare class MCPClient<AuthContext> {
|
|
19
18
|
private readonly baseUrl;
|
|
20
19
|
private readonly timeout;
|
|
21
20
|
private readonly getHeaders;
|
|
22
|
-
constructor(config: MCPClientConfig);
|
|
21
|
+
constructor(config: MCPClientConfig<AuthContext>);
|
|
23
22
|
listTools(): Promise<MCPTool[]>;
|
|
24
23
|
callTool(params: {
|
|
25
24
|
name: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExecutionContext } from '../types/context';
|
|
2
2
|
import type { ToolCall, ToolDefinition, ToolProvider } from '../types/tools';
|
|
3
|
-
export interface MCPProviderConfig {
|
|
3
|
+
export interface MCPProviderConfig<AuthContext> {
|
|
4
4
|
serverId: string;
|
|
5
5
|
serverUrl: string;
|
|
6
6
|
timeout?: number;
|
|
7
7
|
getHeaders: (authContext?: AuthContext) => Record<string, string>;
|
|
8
8
|
}
|
|
9
|
-
export declare const mcp: (config: MCPProviderConfig) => McpToolProvider
|
|
10
|
-
export declare class McpToolProvider implements ToolProvider {
|
|
9
|
+
export declare const mcp: <AuthContext>(config: MCPProviderConfig<AuthContext>) => McpToolProvider<AuthContext>;
|
|
10
|
+
export declare class McpToolProvider<AuthContext> implements ToolProvider<AuthContext> {
|
|
11
11
|
name: string;
|
|
12
12
|
readonly id: string;
|
|
13
13
|
private readonly client;
|
|
@@ -15,9 +15,9 @@ export declare class McpToolProvider implements ToolProvider {
|
|
|
15
15
|
private cacheExpiry;
|
|
16
16
|
private readonly cacheTTL;
|
|
17
17
|
private ongoingRequest;
|
|
18
|
-
constructor(config: MCPProviderConfig);
|
|
18
|
+
constructor(config: MCPProviderConfig<AuthContext>);
|
|
19
19
|
getTool(toolName: string): Promise<ToolDefinition | undefined>;
|
|
20
20
|
getTools(): Promise<ToolDefinition[]>;
|
|
21
|
-
execute(toolCall: ToolCall, context: ExecutionContext): import("rxjs").Observable<import("..").ContextAnyEvent | import("..").ContextEvent<import("..").ToolCompleteEvent>>;
|
|
21
|
+
execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): import("rxjs").Observable<import("..").ContextAnyEvent | import("..").ContextEvent<import("..").ToolCompleteEvent>>;
|
|
22
22
|
private convertMCPTool;
|
|
23
23
|
}
|
|
@@ -2,5 +2,5 @@ import { type Observable } from 'rxjs';
|
|
|
2
2
|
import type { ExecutionContext } from '../types/context';
|
|
3
3
|
import type { ContextAnyEvent, ContextEvent, ToolCompleteEvent } from '../types/event';
|
|
4
4
|
import type { ToolCall, ToolResult } from '../types/tools';
|
|
5
|
-
export declare const toolErrorEvent: (context: ExecutionContext
|
|
6
|
-
export declare const toolResultToEvents: (context: ExecutionContext
|
|
5
|
+
export declare const toolErrorEvent: <AuthContext>(context: ExecutionContext<AuthContext>, toolCall: ToolCall, errorMessage: string) => ContextEvent<ToolCompleteEvent>;
|
|
6
|
+
export declare const toolResultToEvents: <AuthContext>(context: ExecutionContext<AuthContext>, _toolCall: ToolCall, result: ToolResult) => Observable<ContextAnyEvent>;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export interface AuthContext {
|
|
2
|
-
userId?: string;
|
|
3
|
-
credentials?: Record<string, unknown>;
|
|
4
|
-
scopes?: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface ExecutionContext {
|
|
1
|
+
export interface ExecutionContext<AuthContext> {
|
|
7
2
|
taskId: string;
|
|
8
3
|
contextId: string;
|
|
9
4
|
agentId: string;
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -54,9 +54,9 @@ export declare const ToolCallSchema: z.ZodObject<{
|
|
|
54
54
|
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
55
55
|
}, z.core.$strip>;
|
|
56
56
|
}, z.core.$strip>;
|
|
57
|
-
export type ToolProvider = {
|
|
57
|
+
export type ToolProvider<AuthContext> = {
|
|
58
58
|
get name(): string;
|
|
59
59
|
getTool(toolName: string): Promise<ToolDefinition | undefined>;
|
|
60
60
|
getTools(): Promise<ToolDefinition[]>;
|
|
61
|
-
execute(toolCall: ToolCall, context: ExecutionContext): Observable<ContextAnyEvent>;
|
|
61
|
+
execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): Observable<ContextAnyEvent>;
|
|
62
62
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@looopy-ai/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "RxJS-based AI agent framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@geee-be/sse-stream-parser": "^1.0.
|
|
30
|
+
"@geee-be/sse-stream-parser": "^1.0.2",
|
|
31
31
|
"@opentelemetry/api": "^1.9.0",
|
|
32
32
|
"@opentelemetry/exporter-metrics-otlp-http": "^0.207.0",
|
|
33
33
|
"@opentelemetry/exporter-trace-otlp-http": "^0.207.0",
|