@looopy-ai/core 2.1.9 → 2.1.12

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.
Files changed (68) hide show
  1. package/dist/core/agent.d.ts +3 -21
  2. package/dist/core/agent.js +3 -5
  3. package/dist/core/index.d.ts +1 -2
  4. package/dist/core/index.js +0 -1
  5. package/dist/core/iteration.d.ts +3 -3
  6. package/dist/core/iteration.js +30 -34
  7. package/dist/core/loop.d.ts +3 -3
  8. package/dist/core/tools.d.ts +1 -1
  9. package/dist/core/tools.js +26 -19
  10. package/dist/events/utils.d.ts +19 -53
  11. package/dist/events/utils.js +0 -34
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/observability/spans/iteration.d.ts +1 -1
  15. package/dist/observability/spans/llm-call.d.ts +5 -5
  16. package/dist/observability/spans/llm-call.js +8 -4
  17. package/dist/observability/spans/tool.d.ts +3 -3
  18. package/dist/plugins/agent-academy.d.ts +9 -0
  19. package/dist/plugins/agent-academy.js +137 -0
  20. package/dist/plugins/index.d.ts +2 -0
  21. package/dist/plugins/index.js +2 -0
  22. package/dist/plugins/system-prompt.d.ts +3 -0
  23. package/dist/plugins/system-prompt.js +20 -0
  24. package/dist/providers/litellm-provider.d.ts +2 -2
  25. package/dist/providers/litellm-provider.js +1 -1
  26. package/dist/stores/artifacts/internal-event-artifact-store.d.ts +2 -2
  27. package/dist/stores/artifacts/internal-event-artifact-store.js +0 -6
  28. package/dist/stores/filesystem/filesystem-message-store.d.ts +5 -5
  29. package/dist/stores/messages/hybrid-message-store.d.ts +7 -7
  30. package/dist/stores/messages/interfaces.d.ts +8 -8
  31. package/dist/stores/messages/mem0-message-store.d.ts +5 -5
  32. package/dist/stores/messages/memory-message-store.d.ts +5 -5
  33. package/dist/tools/agent-tool-provider.d.ts +5 -5
  34. package/dist/tools/agent-tool-provider.js +14 -10
  35. package/dist/tools/artifact-tools.d.ts +2 -2
  36. package/dist/tools/artifact-tools.js +14 -14
  37. package/dist/tools/index.d.ts +0 -1
  38. package/dist/tools/index.js +0 -1
  39. package/dist/tools/local-tools.d.ts +4 -3
  40. package/dist/tools/local-tools.js +8 -8
  41. package/dist/tools/mcp-tool-provider.d.ts +5 -4
  42. package/dist/tools/mcp-tool-provider.js +7 -7
  43. package/dist/tools/tool-result-events.d.ts +3 -4
  44. package/dist/tools/tool-result-events.js +2 -8
  45. package/dist/types/a2a.d.ts +2 -2
  46. package/dist/types/agent.d.ts +15 -1
  47. package/dist/types/core.d.ts +56 -0
  48. package/dist/types/core.js +8 -0
  49. package/dist/types/event.d.ts +6 -5
  50. package/dist/types/index.d.ts +2 -0
  51. package/dist/types/index.js +2 -0
  52. package/dist/types/llm.d.ts +3 -3
  53. package/dist/types/message.d.ts +5 -5
  54. package/dist/types/prettify.d.ts +3 -0
  55. package/dist/types/state.d.ts +2 -2
  56. package/dist/types/tools.d.ts +3 -12
  57. package/dist/types/tools.js +2 -2
  58. package/dist/utils/prompt.d.ts +5 -8
  59. package/dist/utils/prompt.js +12 -10
  60. package/package.json +5 -3
  61. package/dist/core/types.d.ts +0 -31
  62. package/dist/skills/index.d.ts +0 -1
  63. package/dist/skills/index.js +0 -1
  64. package/dist/skills/registry.d.ts +0 -14
  65. package/dist/skills/registry.js +0 -61
  66. package/dist/tools/client-tool-provider.d.ts +0 -25
  67. package/dist/tools/client-tool-provider.js +0 -143
  68. /package/dist/{core/types.js → types/prettify.js} +0 -0
@@ -14,7 +14,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
14
14
  const scheduledStore = new ArtifactScheduler(artifactStore);
15
15
  return localTools([
16
16
  tool({
17
- name: 'create_file_artifact',
17
+ id: 'create_file_artifact',
18
18
  description: 'Create a new file artifact for streaming text or binary content. Use append_file_chunk to add content. Set override=true to replace existing artifact.',
19
19
  schema: z.object({
20
20
  artifactId: z
@@ -64,7 +64,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
64
64
  },
65
65
  }),
66
66
  tool({
67
- name: 'append_file_chunk',
67
+ id: 'append_file_chunk',
68
68
  description: 'Append a chunk of content to a file artifact. Call multiple times to stream content.',
69
69
  schema: z.object({
70
70
  artifactId: z.string().describe('The artifact ID to append to'),
@@ -93,7 +93,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
93
93
  },
94
94
  }),
95
95
  tool({
96
- name: 'get_file_content',
96
+ id: 'get_file_content',
97
97
  description: 'Get the complete content of a file artifact',
98
98
  schema: z.object({
99
99
  artifactId: z.string().describe('The artifact ID to retrieve'),
@@ -110,7 +110,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
110
110
  },
111
111
  }),
112
112
  tool({
113
- name: 'create_data_artifact',
113
+ id: 'create_data_artifact',
114
114
  description: 'Create a data artifact with structured JSON data. Set override=true to replace existing artifact.',
115
115
  schema: z.object({
116
116
  artifactId: z.string().describe('Unique identifier for the artifact'),
@@ -148,7 +148,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
148
148
  },
149
149
  }),
150
150
  tool({
151
- name: 'update_data_artifact',
151
+ id: 'update_data_artifact',
152
152
  description: 'Update the data content of an existing data artifact',
153
153
  schema: z.object({
154
154
  artifactId: z.string().describe('The artifact ID to update'),
@@ -168,7 +168,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
168
168
  },
169
169
  }),
170
170
  tool({
171
- name: 'get_data_content',
171
+ id: 'get_data_content',
172
172
  description: 'Get the content of a data artifact',
173
173
  schema: z.object({
174
174
  artifactId: z.string().describe('The artifact ID to retrieve'),
@@ -185,7 +185,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
185
185
  },
186
186
  }),
187
187
  tool({
188
- name: 'get_data_artifact',
188
+ id: 'get_data_artifact',
189
189
  description: 'Get the data content of a data artifact',
190
190
  schema: z.object({
191
191
  artifactId: z.string().describe('The artifact ID to retrieve'),
@@ -202,7 +202,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
202
202
  },
203
203
  }),
204
204
  tool({
205
- name: 'create_dataset_artifact',
205
+ id: 'create_dataset_artifact',
206
206
  description: 'Create a dataset artifact for tabular data with a schema. Set override=true to replace existing artifact.',
207
207
  schema: z.object({
208
208
  artifactId: z.string().describe('Unique identifier for the dataset'),
@@ -246,7 +246,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
246
246
  },
247
247
  }),
248
248
  tool({
249
- name: 'append_dataset_row',
249
+ id: 'append_dataset_row',
250
250
  description: 'Append a single row to a dataset artifact',
251
251
  schema: z.object({
252
252
  artifactId: z.string().describe('The dataset artifact ID'),
@@ -265,7 +265,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
265
265
  },
266
266
  }),
267
267
  tool({
268
- name: 'append_dataset_rows',
268
+ id: 'append_dataset_rows',
269
269
  description: 'Append multiple rows to a dataset artifact',
270
270
  schema: z.object({
271
271
  artifactId: z.string().describe('The dataset artifact ID'),
@@ -287,7 +287,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
287
287
  },
288
288
  }),
289
289
  tool({
290
- name: 'get_dataset_rows',
290
+ id: 'get_dataset_rows',
291
291
  description: 'Get all rows from a dataset artifact',
292
292
  schema: z.object({
293
293
  artifactId: z.string().describe('The dataset artifact ID'),
@@ -305,7 +305,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
305
305
  },
306
306
  }),
307
307
  tool({
308
- name: 'list_artifacts',
308
+ id: 'list_artifacts',
309
309
  description: 'List all artifacts in the current context, optionally filtered by task',
310
310
  schema: z.object({
311
311
  taskId: z.string().optional().describe('Filter artifacts by task ID'),
@@ -331,7 +331,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
331
331
  },
332
332
  }),
333
333
  tool({
334
- name: 'get_artifact',
334
+ id: 'get_artifact',
335
335
  description: 'Get metadata for a specific artifact by ID',
336
336
  schema: z.object({
337
337
  artifactId: z.string().describe('The artifact ID to retrieve'),
@@ -368,7 +368,7 @@ export function createArtifactTools(artifactStore, taskStateStore) {
368
368
  },
369
369
  }),
370
370
  tool({
371
- name: 'delete_artifact',
371
+ id: 'delete_artifact',
372
372
  description: 'Delete an artifact by ID',
373
373
  schema: z.object({
374
374
  artifactId: z.string().describe('The artifact ID to delete'),
@@ -1,6 +1,5 @@
1
1
  export * from './agent-tool-provider';
2
2
  export * from './artifact-tools';
3
- export * from './client-tool-provider';
4
3
  export * from './local-tools';
5
4
  export * from './mcp-tool-provider';
6
5
  export * from './tool-result-events';
@@ -1,6 +1,5 @@
1
1
  export * from './agent-tool-provider';
2
2
  export * from './artifact-tools';
3
- export * from './client-tool-provider';
4
3
  export * from './local-tools';
5
4
  export * from './mcp-tool-provider';
6
5
  export * from './tool-result-events';
@@ -1,15 +1,16 @@
1
1
  import { z } from 'zod';
2
2
  import type { ExecutionContext } from '../types/context';
3
- import type { ToolProvider, ToolResult } from '../types/tools';
3
+ import type { Plugin } from '../types/core';
4
+ import type { ToolResult } from '../types/tools';
4
5
  type InternalToolResult = Omit<ToolResult, 'toolCallId' | 'toolName'>;
5
6
  export type ToolHandler<TParams, AuthContext> = (params: TParams, context: ExecutionContext<AuthContext>) => Promise<InternalToolResult> | InternalToolResult;
6
7
  export interface LocalToolDefinition<TSchema extends z.ZodObject, AuthContext> {
7
- name: string;
8
+ id: string;
8
9
  description: string;
9
10
  icon?: string;
10
11
  schema: TSchema;
11
12
  handler: ToolHandler<z.infer<TSchema>, AuthContext>;
12
13
  }
13
14
  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
+ export declare function localTools<AuthContext>(tools: LocalToolDefinition<z.ZodObject, AuthContext>[]): Plugin<AuthContext>;
15
16
  export {};
@@ -15,15 +15,15 @@ const zodToJsonSchema = (schema) => {
15
15
  export function localTools(tools) {
16
16
  const toolMap = new Map();
17
17
  for (const tool of tools) {
18
- if (toolMap.has(tool.name)) {
19
- throw new Error(`Duplicate tool name: ${tool.name}`);
18
+ if (toolMap.has(tool.id)) {
19
+ throw new Error(`Duplicate tool name: ${tool.id}`);
20
20
  }
21
- toolMap.set(tool.name, tool);
21
+ toolMap.set(tool.id, tool);
22
22
  }
23
23
  return {
24
24
  name: 'local-tool-provider',
25
- getTools: async () => tools.map((t) => ({
26
- name: t.name,
25
+ listTools: async () => tools.map((t) => ({
26
+ id: t.id,
27
27
  description: t.description,
28
28
  icon: t.icon,
29
29
  parameters: zodToJsonSchema(t.schema),
@@ -34,13 +34,13 @@ export function localTools(tools) {
34
34
  return undefined;
35
35
  }
36
36
  return {
37
- name: toolDef.name,
37
+ id: toolDef.id,
38
38
  description: toolDef.description,
39
39
  icon: toolDef.icon,
40
40
  parameters: zodToJsonSchema(toolDef.schema),
41
41
  };
42
42
  },
43
- execute: (toolCall, context) => defer(async () => {
43
+ executeTool: (toolCall, context) => defer(async () => {
44
44
  const toolDef = toolMap.get(toolCall.function.name);
45
45
  if (!toolDef) {
46
46
  return {
@@ -82,6 +82,6 @@ export function localTools(tools) {
82
82
  error: err.message,
83
83
  };
84
84
  }
85
- }).pipe(mergeMap((result) => toolResultToEvents(context, toolCall, result)), catchError((error) => of(toolErrorEvent(context, toolCall, error instanceof Error ? error.message : String(error))))),
85
+ }).pipe(mergeMap((result) => toolResultToEvents(result)), catchError((error) => of(toolErrorEvent(toolCall, error instanceof Error ? error.message : String(error))))),
86
86
  };
87
87
  }
@@ -1,5 +1,6 @@
1
+ import type { Plugin } from '..';
1
2
  import type { ExecutionContext } from '../types/context';
2
- import type { ToolCall, ToolDefinition, ToolProvider } from '../types/tools';
3
+ import type { ToolCall, ToolDefinition } from '../types/tools';
3
4
  export interface MCPProviderConfig<AuthContext> {
4
5
  serverId: string;
5
6
  serverUrl: string;
@@ -7,7 +8,7 @@ export interface MCPProviderConfig<AuthContext> {
7
8
  getHeaders: (authContext?: AuthContext) => Record<string, string>;
8
9
  }
9
10
  export declare const mcp: <AuthContext>(config: MCPProviderConfig<AuthContext>) => McpToolProvider<AuthContext>;
10
- export declare class McpToolProvider<AuthContext> implements ToolProvider<AuthContext> {
11
+ export declare class McpToolProvider<AuthContext> implements Plugin<AuthContext> {
11
12
  name: string;
12
13
  readonly id: string;
13
14
  private readonly client;
@@ -17,7 +18,7 @@ export declare class McpToolProvider<AuthContext> implements ToolProvider<AuthCo
17
18
  private ongoingRequest;
18
19
  constructor(config: MCPProviderConfig<AuthContext>);
19
20
  getTool(toolName: string): Promise<ToolDefinition | undefined>;
20
- getTools(): Promise<ToolDefinition[]>;
21
- execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): import("rxjs").Observable<import("..").ContextAnyEvent | import("..").ContextEvent<import("..").ToolCompleteEvent>>;
21
+ listTools(): Promise<ToolDefinition[]>;
22
+ executeTool(toolCall: ToolCall, context: ExecutionContext<AuthContext>): import("rxjs").Observable<import("..").AnyEvent>;
22
23
  private convertMCPTool;
23
24
  }
@@ -21,10 +21,10 @@ export class McpToolProvider {
21
21
  });
22
22
  }
23
23
  async getTool(toolName) {
24
- const tools = await this.getTools();
25
- return tools.find((tool) => tool.name === toolName);
24
+ const tools = await this.listTools();
25
+ return tools.find((tool) => tool.id === toolName);
26
26
  }
27
- async getTools() {
27
+ async listTools() {
28
28
  if (this.toolCache.size > 0 && this.cacheExpiry && Date.now() < this.cacheExpiry) {
29
29
  return Array.from(this.toolCache.values());
30
30
  }
@@ -37,7 +37,7 @@ export class McpToolProvider {
37
37
  const toolDefs = tools.map(this.convertMCPTool);
38
38
  this.toolCache.clear();
39
39
  for (const tool of toolDefs) {
40
- this.toolCache.set(tool.name, tool);
40
+ this.toolCache.set(tool.id, tool);
41
41
  }
42
42
  this.cacheExpiry = Date.now() + this.cacheTTL;
43
43
  return toolDefs;
@@ -47,7 +47,7 @@ export class McpToolProvider {
47
47
  });
48
48
  return this.ongoingRequest;
49
49
  }
50
- execute(toolCall, context) {
50
+ executeTool(toolCall, context) {
51
51
  return defer(async () => {
52
52
  const { name, arguments: args } = toolCall.function;
53
53
  if (typeof args !== 'object' || args === null) {
@@ -80,11 +80,11 @@ export class McpToolProvider {
80
80
  result: null,
81
81
  };
82
82
  }
83
- }).pipe(mergeMap((result) => toolResultToEvents(context, toolCall, result)), catchError((error) => of(toolErrorEvent(context, toolCall, error instanceof Error ? error.message : String(error)))));
83
+ }).pipe(mergeMap((result) => toolResultToEvents(result)), catchError((error) => of(toolErrorEvent(toolCall, error instanceof Error ? error.message : String(error)))));
84
84
  }
85
85
  convertMCPTool = (mcpTool) => {
86
86
  return {
87
- name: mcpTool.name,
87
+ id: mcpTool.name,
88
88
  description: mcpTool.description,
89
89
  parameters: mcpTool.inputSchema,
90
90
  };
@@ -1,6 +1,5 @@
1
1
  import { type Observable } from 'rxjs';
2
- import type { ExecutionContext } from '../types/context';
3
- import type { ContextAnyEvent, ContextEvent, ToolCompleteEvent } from '../types/event';
2
+ import type { AnyEvent, ToolCompleteEvent } from '../types/event';
4
3
  import type { ToolCall, ToolResult } from '../types/tools';
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>;
4
+ export declare const toolErrorEvent: (toolCall: ToolCall, errorMessage: string) => ToolCompleteEvent;
5
+ export declare const toolResultToEvents: (result: ToolResult) => Observable<AnyEvent>;
@@ -1,8 +1,6 @@
1
1
  import { concat, EMPTY, from, of } from 'rxjs';
2
- export const toolErrorEvent = (context, toolCall, errorMessage) => ({
2
+ export const toolErrorEvent = (toolCall, errorMessage) => ({
3
3
  kind: 'tool-complete',
4
- contextId: context.contextId,
5
- taskId: context.taskId,
6
4
  toolCallId: toolCall.id,
7
5
  toolName: toolCall.function.name,
8
6
  success: false,
@@ -10,11 +8,9 @@ export const toolErrorEvent = (context, toolCall, errorMessage) => ({
10
8
  error: errorMessage,
11
9
  timestamp: new Date().toISOString(),
12
10
  });
13
- export const toolResultToEvents = (context, _toolCall, result) => {
11
+ export const toolResultToEvents = (result) => {
14
12
  const toolCompleteEvent = {
15
13
  kind: 'tool-complete',
16
- contextId: context.contextId,
17
- taskId: context.taskId,
18
14
  toolCallId: result.toolCallId,
19
15
  toolName: result.toolName,
20
16
  success: result.success,
@@ -24,8 +20,6 @@ export const toolResultToEvents = (context, _toolCall, result) => {
24
20
  };
25
21
  const messageEvents = result.messages?.map((message) => ({
26
22
  kind: 'internal:tool-message',
27
- contextId: context.contextId,
28
- taskId: context.taskId,
29
23
  message,
30
24
  timestamp: new Date().toISOString(),
31
25
  })) ?? [];
@@ -1,8 +1,8 @@
1
- import type { Message } from './message';
1
+ import type { LLMMessage } from './message';
2
2
  export type A2ATaskState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'rejected' | 'auth-required' | 'unknown';
3
3
  export interface A2ATaskStatus {
4
4
  state: A2ATaskState;
5
- message?: Message;
5
+ message?: LLMMessage;
6
6
  timestamp?: string;
7
7
  }
8
8
  export type A2APart = A2ATextPart | A2AFilePart | A2ADataPart;
@@ -1,6 +1,20 @@
1
+ import type { MessageStore } from '../stores/messages';
1
2
  import type { SerializedError } from '../utils/error';
3
+ import type { Plugin } from './core';
4
+ import type { LLMProvider } from './llm';
5
+ export interface AgentConfig<AuthContext> {
6
+ agentId: string;
7
+ contextId: string;
8
+ llmProvider: LLMProvider;
9
+ messageStore: MessageStore;
10
+ agentStore?: AgentStore;
11
+ autoCompact?: boolean;
12
+ maxMessages?: number;
13
+ plugins?: Plugin<AuthContext>[];
14
+ logger?: import('pino').Logger;
15
+ }
2
16
  export interface AgentState {
3
- status: 'created' | 'ready' | 'busy' | 'shutdown' | 'error';
17
+ status: 'created' | 'idle' | 'busy' | 'shutdown' | 'error';
4
18
  turnCount: number;
5
19
  lastActivity: Date;
6
20
  createdAt: Date;
@@ -0,0 +1,56 @@
1
+ import type pino from 'pino';
2
+ import type { Observable } from 'rxjs';
3
+ import type { LLMProvider } from '../types/llm';
4
+ import type { AnyEvent, ContextAnyEvent } from './event';
5
+ import type { ToolCall, ToolDefinition } from './tools';
6
+ export type AgentContext<AuthContext> = Readonly<{
7
+ agentId: string;
8
+ contextId: string;
9
+ parentContext: import('@opentelemetry/api').Context;
10
+ authContext?: AuthContext;
11
+ logger: pino.Logger;
12
+ plugins: readonly Plugin<AuthContext>[];
13
+ metadata?: Record<string, unknown>;
14
+ }>;
15
+ export type TurnContext<AuthContext> = AgentContext<AuthContext> & Readonly<{
16
+ taskId: string;
17
+ turnNumber: number;
18
+ }>;
19
+ export type LoopContext<AuthContext> = TurnContext<AuthContext>;
20
+ export type IterationContext<AuthContext> = TurnContext<AuthContext>;
21
+ export type LoopConfig = {
22
+ llmProvider: LLMProvider;
23
+ maxIterations: number;
24
+ stopOnToolError: boolean;
25
+ };
26
+ export type IterationConfig<AuthContext> = {
27
+ llmProvider: LLMProvider | ((context: LoopContext<AuthContext>, systemPromptMetadata: Record<string, unknown> | undefined) => LLMProvider);
28
+ iterationNumber: number;
29
+ };
30
+ export type Plugin<AuthContext> = BasePlugin & Partial<SystemPromptPlugin<AuthContext>> & Partial<ToolPlugin<AuthContext>>;
31
+ type BasePlugin = {
32
+ readonly name: string;
33
+ readonly version?: string;
34
+ };
35
+ export type SystemPromptPlugin<AuthContext> = {
36
+ generateSystemPrompts: (context: IterationContext<AuthContext>) => SystemPrompt[] | Promise<SystemPrompt[]>;
37
+ };
38
+ export declare const isSystemPromptPlugin: <AuthContext>(plugin: Plugin<AuthContext>) => plugin is BasePlugin & SystemPromptPlugin<AuthContext>;
39
+ export type ToolPlugin<AuthContext> = {
40
+ listTools: () => Promise<ToolDefinition[]>;
41
+ getTool: (toolId: string) => Promise<ToolDefinition | undefined>;
42
+ executeTool: (toolCall: ToolCall, context: IterationContext<AuthContext>) => Observable<ContextAnyEvent | AnyEvent>;
43
+ };
44
+ export declare const isToolPlugin: <AuthContext>(plugin: Plugin<AuthContext>) => plugin is BasePlugin & ToolPlugin<AuthContext>;
45
+ export type SystemPrompt = {
46
+ content: string;
47
+ position: 'before' | 'after';
48
+ positionSequence?: number;
49
+ metadata?: Record<string, unknown>;
50
+ source?: {
51
+ providerName: string;
52
+ promptName: string;
53
+ promptVersion?: number;
54
+ };
55
+ };
56
+ export {};
@@ -0,0 +1,8 @@
1
+ export const isSystemPromptPlugin = (plugin) => {
2
+ return typeof plugin.generateSystemPrompts === 'function';
3
+ };
4
+ export const isToolPlugin = (plugin) => {
5
+ return (typeof plugin.listTools === 'function' &&
6
+ typeof plugin.getTool === 'function' &&
7
+ typeof plugin.executeTool === 'function');
8
+ };
@@ -1,12 +1,12 @@
1
- import type { Message, SystemMessage } from './message';
1
+ import type { LLMMessage, SystemLLMMessage } from './message';
2
2
  import type { ToolCall } from './tools';
3
3
  export type TaskStatus = 'working' | 'waiting-input' | 'waiting-auth' | 'waiting-subtask' | 'completed' | 'failed' | 'canceled';
4
4
  export type ThoughtVerbosity = 'brief' | 'normal' | 'detailed';
5
5
  export type ThoughtType = 'analysis' | 'planning' | 'reasoning' | 'reflection' | 'thinking' | 'decision' | 'observation' | 'strategy';
6
- export type InputType = 'tool-execution' | 'confirmation' | 'clarification' | 'selection' | 'custom';
6
+ export type InputType = 'confirmation' | 'clarification' | 'selection' | 'data';
7
7
  export type AuthType = 'oauth2' | 'api-key' | 'password' | 'biometric' | 'custom';
8
8
  export type TaskInitiator = 'user' | 'agent';
9
- export type InputProvider = 'user' | 'agent';
9
+ export type InputProvider = 'user' | 'any';
10
10
  export interface JSONSchema {
11
11
  type?: string;
12
12
  properties?: Record<string, JSONSchema>;
@@ -269,7 +269,7 @@ export interface InternalLLMCallEvent {
269
269
  }
270
270
  export interface InternalToolMessageEvent {
271
271
  kind: 'internal:tool-message';
272
- message: SystemMessage;
272
+ message: SystemLLMMessage;
273
273
  timestamp: string;
274
274
  }
275
275
  export interface InternalCheckpointEvent {
@@ -307,13 +307,14 @@ export interface LLMUsageEvent {
307
307
  export type UsageEvent = LLMUsageEvent;
308
308
  export interface MessageEvent {
309
309
  kind: 'message';
310
- message: Message;
310
+ message: LLMMessage;
311
311
  timestamp: string;
312
312
  }
313
313
  export type AnyEvent = TaskLifecycleEvent | ContentStreamingEvent | ToolExecutionEvent | InputRequestEvent | AuthenticationEvent | ArtifactEvent | SubAgentEvent | ThoughtStreamEvent | InternalDebugEvent | UsageEvent | MessageEvent;
314
314
  export type ContextEvent<T> = T & {
315
315
  contextId: string;
316
316
  taskId: string;
317
+ path?: string[];
317
318
  };
318
319
  export type ChildTaskEvent<T> = T & {
319
320
  parentTaskId: string;
@@ -2,9 +2,11 @@ export * from './a2a';
2
2
  export * from './agent';
3
3
  export * from './artifact';
4
4
  export * from './context';
5
+ export * from './core';
5
6
  export * from './event';
6
7
  export * from './llm';
7
8
  export * from './message';
9
+ export * from './prettify';
8
10
  export * from './skills';
9
11
  export * from './state';
10
12
  export * from './tools';
@@ -2,9 +2,11 @@ export * from './a2a';
2
2
  export * from './agent';
3
3
  export * from './artifact';
4
4
  export * from './context';
5
+ export * from './core';
5
6
  export * from './event';
6
7
  export * from './llm';
7
8
  export * from './message';
9
+ export * from './prettify';
8
10
  export * from './skills';
9
11
  export * from './state';
10
12
  export * from './tools';
@@ -1,17 +1,17 @@
1
1
  import type { Observable } from 'rxjs';
2
2
  import type { AnyEvent } from './event';
3
- import type { Message } from './message';
3
+ import type { LLMMessage } from './message';
4
4
  import type { ToolCall, ToolDefinition } from './tools';
5
5
  export interface LLMProvider {
6
6
  call(request: {
7
- messages: Message[];
7
+ messages: LLMMessage[];
8
8
  tools?: ToolDefinition[];
9
9
  stream?: boolean;
10
10
  sessionId?: string;
11
11
  }): Observable<AnyEvent>;
12
12
  }
13
13
  export interface LLMResponse {
14
- message: Message;
14
+ message: LLMMessage;
15
15
  toolCalls?: ToolCall[];
16
16
  finished: boolean;
17
17
  finishReason?: 'stop' | 'length' | 'tool_calls' | 'content_filter';
@@ -1,24 +1,24 @@
1
1
  import type { ToolCall } from './tools';
2
- export type SystemMessage = {
2
+ export type SystemLLMMessage = {
3
3
  role: 'system';
4
4
  content: string;
5
5
  name?: string;
6
6
  };
7
- export type UserMessage = {
7
+ export type UserLLMMessage = {
8
8
  role: 'user';
9
9
  content: string;
10
10
  name?: string;
11
11
  };
12
- export type AssistantMessage = {
12
+ export type AssistantLLMMessage = {
13
13
  role: 'assistant';
14
14
  content: string;
15
15
  name?: string;
16
16
  toolCalls?: ToolCall[];
17
17
  };
18
- export type ToolMessage = {
18
+ export type ToolLLMMessage = {
19
19
  role: 'tool';
20
20
  content: string;
21
21
  name?: string;
22
22
  toolCallId: string;
23
23
  };
24
- export type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
24
+ export type LLMMessage = SystemLLMMessage | UserLLMMessage | AssistantLLMMessage | ToolLLMMessage;
@@ -0,0 +1,3 @@
1
+ export type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
@@ -1,12 +1,12 @@
1
1
  import type { LLMResponse } from './llm';
2
- import type { Message } from './message';
2
+ import type { LLMMessage } from './message';
3
3
  import type { ToolCall, ToolDefinition, ToolResult } from './tools';
4
4
  export interface PersistedLoopState {
5
5
  taskId: string;
6
6
  agentId: string;
7
7
  parentTaskId?: string;
8
8
  contextId: string;
9
- messages: Message[];
9
+ messages: LLMMessage[];
10
10
  systemPrompt: string;
11
11
  iteration: number;
12
12
  completed: boolean;
@@ -1,8 +1,5 @@
1
- import type { Observable } from 'rxjs';
2
1
  import { z } from 'zod';
3
- import type { ExecutionContext } from './context';
4
- import type { ContextAnyEvent } from './event';
5
- import type { SystemMessage } from './message';
2
+ import type { SystemLLMMessage } from './message';
6
3
  export interface ToolCall {
7
4
  id: string;
8
5
  type: 'function';
@@ -17,7 +14,7 @@ export interface ToolResult {
17
14
  success: boolean;
18
15
  result: unknown;
19
16
  error?: string;
20
- messages?: SystemMessage[];
17
+ messages?: SystemLLMMessage[];
21
18
  }
22
19
  export declare const JsonSchemaPropertySchema: z.ZodType<unknown>;
23
20
  export type JsonSchemaProperty = z.infer<typeof JsonSchemaPropertySchema>;
@@ -29,7 +26,7 @@ export declare const FunctionParametersSchema: z.ZodObject<{
29
26
  }, z.core.$strip>;
30
27
  export type FunctionParameters = z.infer<typeof FunctionParametersSchema>;
31
28
  export declare const ToolDefinitionSchema: z.ZodObject<{
32
- name: z.ZodString;
29
+ id: z.ZodString;
33
30
  description: z.ZodString;
34
31
  icon: z.ZodOptional<z.ZodString>;
35
32
  parameters: z.ZodObject<{
@@ -54,9 +51,3 @@ export declare const ToolCallSchema: z.ZodObject<{
54
51
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
55
52
  }, z.core.$strip>;
56
53
  }, z.core.$strip>;
57
- export type ToolProvider<AuthContext> = {
58
- get name(): string;
59
- getTool(toolName: string): Promise<ToolDefinition | undefined>;
60
- getTools(): Promise<ToolDefinition[]>;
61
- execute(toolCall: ToolCall, context: ExecutionContext<AuthContext>): Observable<ContextAnyEvent>;
62
- };
@@ -25,11 +25,11 @@ export const FunctionParametersSchema = z.object({
25
25
  additionalProperties: z.boolean().optional(),
26
26
  });
27
27
  export const ToolDefinitionSchema = z.object({
28
- name: z
28
+ id: z
29
29
  .string()
30
30
  .min(1)
31
31
  .max(64)
32
- .regex(/^[a-zA-Z0-9_-]+$/, 'Tool name must contain only alphanumeric characters, underscores, and hyphens'),
32
+ .regex(/^[a-zA-Z0-9_-]+$/, 'Tool ID must contain only alphanumeric characters, underscores, and hyphens'),
33
33
  description: z.string().min(1).max(1024),
34
34
  icon: z.string().optional(),
35
35
  parameters: FunctionParametersSchema,
@@ -1,9 +1,6 @@
1
- import type { LoopContext } from '../core/types';
2
- export type SystemPrompt = {
3
- prompt: string;
4
- name?: string;
5
- version?: number;
6
- metadata?: Record<string, unknown>;
1
+ import type { IterationContext, Plugin, SystemPrompt } from '../types/core';
2
+ export type SystemPrompts = {
3
+ before: readonly SystemPrompt[];
4
+ after: readonly SystemPrompt[];
7
5
  };
8
- export type SystemPromptProp<AuthContext> = string | SystemPrompt | ((loopContext: LoopContext<AuthContext>) => Promise<SystemPrompt> | SystemPrompt);
9
- export declare const getSystemPrompt: <AuthContext>(systemPrompt: SystemPromptProp<AuthContext> | undefined, loopContext: LoopContext<AuthContext>) => Promise<SystemPrompt | undefined>;
6
+ export declare const getSystemPrompts: <AuthContext>(plugins: readonly Plugin<AuthContext>[] | undefined, loopContext: IterationContext<AuthContext>) => Promise<SystemPrompts>;