@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.
@@ -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>;
@@ -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,
@@ -1,3 +1,4 @@
1
1
  export { Agent, type AgentConfig, type GetMessagesOptions } from './agent';
2
2
  export { StateCleanupService } from './cleanup';
3
3
  export { createLogger, getLogger, type LoggerConfig, type LogLevel, setDefaultLogger, } from './logger';
4
+ export * from './types';
@@ -1,3 +1,4 @@
1
1
  export { Agent } from './agent';
2
2
  export { StateCleanupService } from './cleanup';
3
3
  export { createLogger, getLogger, setDefaultLogger, } from './logger';
4
+ export * from './types';
@@ -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({
@@ -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?: SystemPromptProp) => Promise<SystemPrompt | undefined>;
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>;
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looopy-ai/core",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "RxJS-based AI agent framework",
5
5
  "keywords": [
6
6
  "agent",