@looopy-ai/core 2.1.6 → 2.1.8
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 +1 -0
- package/dist/core/agent.js +3 -2
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/iteration.js +1 -1
- package/dist/utils/prompt.d.ts +3 -2
- package/dist/utils/prompt.js +2 -2
- package/package.json +1 -1
package/dist/core/agent.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare class Agent<AuthContext> {
|
|
|
38
38
|
startTurn(userMessage: string | null, options?: {
|
|
39
39
|
authContext?: AuthContext;
|
|
40
40
|
taskId?: string;
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
41
42
|
}): Promise<Observable<ContextAnyEvent>>;
|
|
42
43
|
private executeInternal;
|
|
43
44
|
shutdown(): Promise<void>;
|
package/dist/core/agent.js
CHANGED
|
@@ -129,7 +129,7 @@ export class Agent {
|
|
|
129
129
|
this._state.status = 'busy';
|
|
130
130
|
this._state.lastActivity = new Date();
|
|
131
131
|
await this.persistState();
|
|
132
|
-
return this.executeInternal(userMessage, taskId, options?.authContext, rootSpan, rootContext, this.logger.child({ taskId, turnNumber })).pipe(tapFinish);
|
|
132
|
+
return this.executeInternal(userMessage, taskId, options?.authContext, options?.metadata, rootSpan, rootContext, this.logger.child({ taskId, turnNumber })).pipe(tapFinish);
|
|
133
133
|
}
|
|
134
134
|
catch (error) {
|
|
135
135
|
const err = error;
|
|
@@ -144,7 +144,7 @@ export class Agent {
|
|
|
144
144
|
}));
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
executeInternal(userMessage, taskId, authContext, turnSpan, turnContext, logger) {
|
|
147
|
+
executeInternal(userMessage, taskId, authContext, metadata, turnSpan, turnContext, logger) {
|
|
148
148
|
const turnNumber = this._state.turnCount + 1;
|
|
149
149
|
return concat(new Observable((observer) => {
|
|
150
150
|
const execute = async () => {
|
|
@@ -174,6 +174,7 @@ export class Agent {
|
|
|
174
174
|
skillRegistry: this.config.skillRegistry,
|
|
175
175
|
logger: this.config.logger.child({ taskId, turnNumber }),
|
|
176
176
|
turnNumber,
|
|
177
|
+
metadata,
|
|
177
178
|
}, {
|
|
178
179
|
llmProvider: this.config.llmProvider,
|
|
179
180
|
maxIterations: 5,
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
package/dist/core/iteration.js
CHANGED
|
@@ -9,7 +9,7 @@ export const runIteration = (context, config, history) => {
|
|
|
9
9
|
});
|
|
10
10
|
const { traceContext: iterationContext, tapFinish: finishIterationSpan } = startLoopIterationSpan({ ...context, logger }, config.iterationNumber);
|
|
11
11
|
const llmEvents$ = defer(async () => {
|
|
12
|
-
const systemPrompt = await getSystemPrompt(context.systemPrompt);
|
|
12
|
+
const systemPrompt = await getSystemPrompt(context.systemPrompt, context);
|
|
13
13
|
const messages = await prepareMessages(systemPrompt, context.skillRegistry, history);
|
|
14
14
|
const tools = await prepareTools(context.toolProviders);
|
|
15
15
|
logger.debug({
|
package/dist/utils/prompt.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { LoopContext } from '../core/types';
|
|
1
2
|
export type SystemPrompt = {
|
|
2
3
|
prompt: string;
|
|
3
4
|
name?: string;
|
|
4
5
|
version?: number;
|
|
5
6
|
};
|
|
6
|
-
export type SystemPromptProp = string | SystemPrompt | (() => Promise<SystemPrompt> | SystemPrompt);
|
|
7
|
-
export declare const getSystemPrompt: (systemPrompt
|
|
7
|
+
export type SystemPromptProp = string | SystemPrompt | (<AuthContext>(loopContext: LoopContext<AuthContext>) => Promise<SystemPrompt> | SystemPrompt);
|
|
8
|
+
export declare const getSystemPrompt: <AuthContext>(systemPrompt: SystemPromptProp | undefined, loopContext: LoopContext<AuthContext>) => Promise<SystemPrompt | undefined>;
|
package/dist/utils/prompt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const getSystemPrompt = async (systemPrompt) => {
|
|
1
|
+
export const getSystemPrompt = async (systemPrompt, loopContext) => {
|
|
2
2
|
if (!systemPrompt) {
|
|
3
3
|
return undefined;
|
|
4
4
|
}
|
|
@@ -6,7 +6,7 @@ export const getSystemPrompt = async (systemPrompt) => {
|
|
|
6
6
|
return { prompt: systemPrompt };
|
|
7
7
|
}
|
|
8
8
|
if (typeof systemPrompt === 'function') {
|
|
9
|
-
return await systemPrompt();
|
|
9
|
+
return await systemPrompt(loopContext);
|
|
10
10
|
}
|
|
11
11
|
return systemPrompt;
|
|
12
12
|
};
|