@looopy-ai/core 2.1.21 → 2.1.22
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.js +1 -0
- package/dist/core/iteration.js +11 -3
- package/dist/core/loop.d.ts +1 -1
- package/dist/core/loop.js +1 -0
- package/dist/stores/messages/memory-message-store.js +2 -2
- package/dist/tools/agent-tool-provider.d.ts +1 -0
- package/dist/tools/agent-tool-provider.js +1 -0
- package/dist/types/agent.d.ts +2 -1
- package/dist/types/core.d.ts +4 -1
- package/package.json +8 -8
package/dist/core/agent.js
CHANGED
package/dist/core/iteration.js
CHANGED
|
@@ -10,10 +10,18 @@ export const runIteration = (context, config, history) => {
|
|
|
10
10
|
});
|
|
11
11
|
const { traceContext: iterationContext, tapFinish: finishIterationSpan } = startLoopIterationSpan({ ...context, logger }, config.iterationNumber);
|
|
12
12
|
const llmEvents$ = defer(async () => {
|
|
13
|
-
const
|
|
13
|
+
const allowedPlugins = config.filterPlugins
|
|
14
|
+
? config.filterPlugins(context.plugins, context)
|
|
15
|
+
: context.plugins;
|
|
16
|
+
const systemPrompts = await getSystemPrompts(allowedPlugins, context);
|
|
14
17
|
const messages = await prepareMessages(systemPrompts, history);
|
|
15
|
-
const tools = await prepareTools(
|
|
16
|
-
logger.debug({
|
|
18
|
+
const tools = await prepareTools(allowedPlugins);
|
|
19
|
+
logger.debug({
|
|
20
|
+
systemPrompts,
|
|
21
|
+
messages: messages.length,
|
|
22
|
+
plugins: allowedPlugins.map((p) => p.name).join(', '),
|
|
23
|
+
tools: tools.map((t) => t.id).join(', '),
|
|
24
|
+
}, 'Prepared messages and tools for LLM call');
|
|
17
25
|
return { messages, tools, systemPrompts };
|
|
18
26
|
}).pipe(mergeMap(({ messages, tools, systemPrompts }) => {
|
|
19
27
|
const { tapFinish: finishLLMCallSpan } = startLLMCallSpan({ ...context, parentContext: iterationContext }, systemPrompts, messages, tools);
|
package/dist/core/loop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LoopConfig, LoopContext } from '../types/core';
|
|
2
2
|
import type { ContextAnyEvent } from '../types/event';
|
|
3
3
|
import type { LLMMessage } from '../types/message';
|
|
4
|
-
export declare const runLoop: <AuthContext>(context: LoopContext<AuthContext>, config: LoopConfig
|
|
4
|
+
export declare const runLoop: <AuthContext>(context: LoopContext<AuthContext>, config: LoopConfig<AuthContext>, history: LLMMessage[]) => import("rxjs").Observable<ContextAnyEvent>;
|
package/dist/core/loop.js
CHANGED
|
@@ -35,6 +35,7 @@ export const runLoop = (context, config, history) => {
|
|
|
35
35
|
}, (state) => runIteration({ ...context, parentContext: loopContext }, {
|
|
36
36
|
llmProvider: config.llmProvider,
|
|
37
37
|
iterationNumber: state.iteration,
|
|
38
|
+
filterPlugins: config.filterPlugins,
|
|
38
39
|
}, state.messages), (state, { events }) => ({
|
|
39
40
|
...state,
|
|
40
41
|
messages: [...state.messages, ...eventsToMessages(events)],
|
|
@@ -26,10 +26,10 @@ export class InMemoryMessageStore {
|
|
|
26
26
|
if (maxTokens) {
|
|
27
27
|
messages = trimToTokenBudget(messages, maxTokens);
|
|
28
28
|
}
|
|
29
|
-
return messages;
|
|
29
|
+
return messages.slice();
|
|
30
30
|
}
|
|
31
31
|
async getAll(contextId) {
|
|
32
|
-
return this.messages.get(contextId) || [];
|
|
32
|
+
return (this.messages.get(contextId) || []).slice();
|
|
33
33
|
}
|
|
34
34
|
async getCount(contextId) {
|
|
35
35
|
const messages = this.messages.get(contextId) || [];
|
|
@@ -16,6 +16,7 @@ export declare const cardSchema: z.ZodObject<{
|
|
|
16
16
|
token_endpoint: z.ZodString;
|
|
17
17
|
scopes: z.ZodArray<z.ZodString>;
|
|
18
18
|
}, z.core.$loose>>;
|
|
19
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
19
20
|
}, z.core.$strip>;
|
|
20
21
|
export type AgentCard = z.infer<typeof cardSchema>;
|
|
21
22
|
export declare class AgentToolProvider<AuthContext> implements ToolPlugin<AuthContext> {
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MessageStore } from '../stores/messages';
|
|
2
2
|
import type { SerializedError } from '../utils/error';
|
|
3
|
-
import type { Plugin } from './core';
|
|
3
|
+
import type { FilterPlugins, Plugin } from './core';
|
|
4
4
|
import type { LLMProvider } from './llm';
|
|
5
5
|
export interface AgentConfig<AuthContext> {
|
|
6
6
|
agentId: string;
|
|
7
7
|
contextId: string;
|
|
8
8
|
llmProvider: LLMProvider;
|
|
9
|
+
filterPlugins?: FilterPlugins<AuthContext>;
|
|
9
10
|
messageStore: MessageStore;
|
|
10
11
|
agentStore?: AgentStore;
|
|
11
12
|
autoCompact?: boolean;
|
package/dist/types/core.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Observable } from 'rxjs';
|
|
|
3
3
|
import type { LLMProvider } from '../types/llm';
|
|
4
4
|
import type { AnyEvent, ContextAnyEvent } from './event';
|
|
5
5
|
import type { ToolCall, ToolDefinition } from './tools';
|
|
6
|
+
export type FilterPlugins<AuthContext> = (availablePlugins: readonly Plugin<AuthContext>[], context: IterationContext<AuthContext>) => readonly Plugin<AuthContext>[];
|
|
6
7
|
export type AgentContext<AuthContext> = Readonly<{
|
|
7
8
|
agentId: string;
|
|
8
9
|
contextId: string;
|
|
@@ -18,12 +19,14 @@ export type TurnContext<AuthContext> = AgentContext<AuthContext> & Readonly<{
|
|
|
18
19
|
}>;
|
|
19
20
|
export type LoopContext<AuthContext> = TurnContext<AuthContext>;
|
|
20
21
|
export type IterationContext<AuthContext> = TurnContext<AuthContext>;
|
|
21
|
-
export type LoopConfig = {
|
|
22
|
+
export type LoopConfig<AuthContext> = {
|
|
23
|
+
filterPlugins: FilterPlugins<AuthContext> | undefined;
|
|
22
24
|
llmProvider: LLMProvider;
|
|
23
25
|
maxIterations: number;
|
|
24
26
|
stopOnToolError: boolean;
|
|
25
27
|
};
|
|
26
28
|
export type IterationConfig<AuthContext> = {
|
|
29
|
+
filterPlugins: FilterPlugins<AuthContext> | undefined;
|
|
27
30
|
llmProvider: LLMProvider | ((context: LoopContext<AuthContext>, systemPromptMetadata: Record<string, unknown> | undefined) => LLMProvider);
|
|
28
31
|
iterationNumber: number;
|
|
29
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@looopy-ai/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.22",
|
|
4
4
|
"description": "RxJS-based AI agent framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/looopy-ai/lib"
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"@opentelemetry/exporter-metrics-otlp-http": "^0.207.0",
|
|
35
35
|
"@opentelemetry/exporter-trace-otlp-http": "^0.207.0",
|
|
36
36
|
"@opentelemetry/instrumentation": "^0.207.0",
|
|
37
|
-
"@opentelemetry/resources": "^2.
|
|
38
|
-
"@opentelemetry/sdk-metrics": "^2.
|
|
39
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
40
|
-
"@opentelemetry/sdk-trace-node": "^2.
|
|
41
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
37
|
+
"@opentelemetry/resources": "^2.4.0",
|
|
38
|
+
"@opentelemetry/sdk-metrics": "^2.4.0",
|
|
39
|
+
"@opentelemetry/sdk-trace-base": "^2.4.0",
|
|
40
|
+
"@opentelemetry/sdk-trace-node": "^2.4.0",
|
|
41
|
+
"@opentelemetry/semantic-conventions": "^1.39.0",
|
|
42
42
|
"pino": "^9.14.0",
|
|
43
|
-
"pino-pretty": "^13.1.
|
|
43
|
+
"pino-pretty": "^13.1.3",
|
|
44
44
|
"rxjs": "^7.8.2",
|
|
45
|
-
"zod": "^4.
|
|
45
|
+
"zod": "^4.3.5"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|