@mappies/miniwat-agent 0.4.0 → 0.8.0

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/index.d.cts CHANGED
@@ -1,7 +1,42 @@
1
- import { Instruction, Model, Message, ModelOption, ResponseMessage } from '@mappies/miniwat-agent-core';
1
+ import { TokenUsage, Message, Instruction, Model, ModelEvent, ModelOption, ResponseMessage } from '@mappies/miniwat-agent-core';
2
2
  import { ToolDispatcher } from '@mappies/miniwat-mcp-core';
3
3
  import { Readable } from 'stream';
4
4
 
5
+ type TaskStatus = 'pending' | 'running' | 'completed' | 'failed';
6
+
7
+ declare class Task {
8
+ id?: number;
9
+ description?: string;
10
+ status?: TaskStatus;
11
+ executionLogs?: string[];
12
+ constructor(task: Partial<Task>);
13
+ }
14
+
15
+ declare class Plan {
16
+ id?: string;
17
+ userGoal?: string;
18
+ tasks?: Task[];
19
+ directAnswer?: {
20
+ content: string;
21
+ tokenUsage: TokenUsage;
22
+ };
23
+ createdAt?: string;
24
+ constructor(plan?: Partial<Plan>);
25
+ getInstruction(currentTask: Task): string;
26
+ getExecutionContext(currentTaskId: number): string;
27
+ getLastCompletedOutput(): string;
28
+ getNextPendingTask(): Task | undefined;
29
+ updateTaskStatus(taskId: number, status: TaskStatus): void;
30
+ appendLogToTask(taskId: number, log: string): void;
31
+ insertTask(afterStepId: number, description: string): void;
32
+ }
33
+
34
+ interface IPlanner {
35
+ createPlan(userGoal: string, conversationHistory?: Message[]): Promise<Plan>;
36
+ reflect(task: Task, executionOutput: string): Promise<boolean>;
37
+ replan(plan: Plan, failedTask: Task, failureOutput: string): Promise<void>;
38
+ }
39
+
5
40
  declare class AgentConfig {
6
41
  /**
7
42
  * Agent instruction
@@ -15,23 +50,68 @@ declare class AgentConfig {
15
50
  * Tool dispatcher for tools.
16
51
  */
17
52
  toolDispatcher?: ToolDispatcher;
53
+ /**
54
+ * Optional planner.
55
+ *
56
+ * When omitted, the agent executes prompts directly using the configured model.
57
+ * When provided, the planner determines whether to return a direct answer or
58
+ * execute a multi-step plan.
59
+ */
60
+ planner?: IPlanner;
61
+ /**
62
+ * Maximum number of tool calls allowed per model execution.
63
+ */
64
+ maxToolCalls?: number;
18
65
  constructor(data: AgentConfig);
19
66
  }
20
67
 
21
68
  declare class Session {
22
- readonly id: string;
69
+ id: string;
23
70
  name?: string;
24
- messages: Message[];
71
+ messages?: Message[];
72
+ createdTimestamp?: string;
25
73
  constructor(data?: Partial<Session>);
26
74
  }
27
75
 
76
+ interface AgentEvent extends ModelEvent {
77
+ onPlanUpdated?(plan: Plan): Promise<void>;
78
+ }
79
+
80
+ interface AgentOption extends Omit<ModelOption, "event"> {
81
+ event?: AgentEvent;
82
+ }
83
+
28
84
  declare class Agent {
29
85
  readonly instruction?: Instruction;
30
86
  readonly model: Model;
31
87
  readonly toolDispatcher?: ToolDispatcher;
88
+ readonly planner?: IPlanner;
89
+ readonly maxToolCalls?: number;
32
90
  constructor(config: AgentConfig);
33
- invoke(prompt: string, session: Session, option?: Omit<ModelOption, 'instruction'>): Promise<ResponseMessage>;
34
- stream(prompt: string, session: Session, option?: Omit<ModelOption, "instruction">): Promise<Readable>;
91
+ invoke(prompt: string, session: Session, option?: Omit<AgentOption, 'instruction'>): Promise<ResponseMessage>;
92
+ stream(prompt: string, session: Session, option?: Omit<AgentOption, "instruction">): Promise<Readable>;
93
+ private invokeDirect;
94
+ private invokeWithPlanner;
95
+ private streamDirect;
96
+ private streamWithPlanner;
97
+ private executePlan;
98
+ }
99
+
100
+ declare class DefaultPlanner {
101
+ private model;
102
+ constructor(model: Model);
103
+ private callLLM;
104
+ createPlan(userGoal: string, conversationHistory?: Message[]): Promise<Plan>;
105
+ /**
106
+ * PURE CRITIC INTERFACE
107
+ * Cross-references an execution string block against the target task expectations.
108
+ */
109
+ reflect(task: Task, executionOutput: string): Promise<boolean>;
110
+ /**
111
+ * CONTEXTUAL WORKFLOW PATCHING
112
+ * Invokes an LLM strategy session to formulate an actionable patch, injecting it into the state array.
113
+ */
114
+ replan(plan: Plan, failedTask: Task, failureOutput: string): Promise<void>;
35
115
  }
36
116
 
37
- export { Agent, AgentConfig, Session };
117
+ export { Agent, AgentConfig, DefaultPlanner, type IPlanner, Plan, Session, Task, type TaskStatus };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,42 @@
1
- import { Instruction, Model, Message, ModelOption, ResponseMessage } from '@mappies/miniwat-agent-core';
1
+ import { TokenUsage, Message, Instruction, Model, ModelEvent, ModelOption, ResponseMessage } from '@mappies/miniwat-agent-core';
2
2
  import { ToolDispatcher } from '@mappies/miniwat-mcp-core';
3
3
  import { Readable } from 'stream';
4
4
 
5
+ type TaskStatus = 'pending' | 'running' | 'completed' | 'failed';
6
+
7
+ declare class Task {
8
+ id?: number;
9
+ description?: string;
10
+ status?: TaskStatus;
11
+ executionLogs?: string[];
12
+ constructor(task: Partial<Task>);
13
+ }
14
+
15
+ declare class Plan {
16
+ id?: string;
17
+ userGoal?: string;
18
+ tasks?: Task[];
19
+ directAnswer?: {
20
+ content: string;
21
+ tokenUsage: TokenUsage;
22
+ };
23
+ createdAt?: string;
24
+ constructor(plan?: Partial<Plan>);
25
+ getInstruction(currentTask: Task): string;
26
+ getExecutionContext(currentTaskId: number): string;
27
+ getLastCompletedOutput(): string;
28
+ getNextPendingTask(): Task | undefined;
29
+ updateTaskStatus(taskId: number, status: TaskStatus): void;
30
+ appendLogToTask(taskId: number, log: string): void;
31
+ insertTask(afterStepId: number, description: string): void;
32
+ }
33
+
34
+ interface IPlanner {
35
+ createPlan(userGoal: string, conversationHistory?: Message[]): Promise<Plan>;
36
+ reflect(task: Task, executionOutput: string): Promise<boolean>;
37
+ replan(plan: Plan, failedTask: Task, failureOutput: string): Promise<void>;
38
+ }
39
+
5
40
  declare class AgentConfig {
6
41
  /**
7
42
  * Agent instruction
@@ -15,23 +50,68 @@ declare class AgentConfig {
15
50
  * Tool dispatcher for tools.
16
51
  */
17
52
  toolDispatcher?: ToolDispatcher;
53
+ /**
54
+ * Optional planner.
55
+ *
56
+ * When omitted, the agent executes prompts directly using the configured model.
57
+ * When provided, the planner determines whether to return a direct answer or
58
+ * execute a multi-step plan.
59
+ */
60
+ planner?: IPlanner;
61
+ /**
62
+ * Maximum number of tool calls allowed per model execution.
63
+ */
64
+ maxToolCalls?: number;
18
65
  constructor(data: AgentConfig);
19
66
  }
20
67
 
21
68
  declare class Session {
22
- readonly id: string;
69
+ id: string;
23
70
  name?: string;
24
- messages: Message[];
71
+ messages?: Message[];
72
+ createdTimestamp?: string;
25
73
  constructor(data?: Partial<Session>);
26
74
  }
27
75
 
76
+ interface AgentEvent extends ModelEvent {
77
+ onPlanUpdated?(plan: Plan): Promise<void>;
78
+ }
79
+
80
+ interface AgentOption extends Omit<ModelOption, "event"> {
81
+ event?: AgentEvent;
82
+ }
83
+
28
84
  declare class Agent {
29
85
  readonly instruction?: Instruction;
30
86
  readonly model: Model;
31
87
  readonly toolDispatcher?: ToolDispatcher;
88
+ readonly planner?: IPlanner;
89
+ readonly maxToolCalls?: number;
32
90
  constructor(config: AgentConfig);
33
- invoke(prompt: string, session: Session, option?: Omit<ModelOption, 'instruction'>): Promise<ResponseMessage>;
34
- stream(prompt: string, session: Session, option?: Omit<ModelOption, "instruction">): Promise<Readable>;
91
+ invoke(prompt: string, session: Session, option?: Omit<AgentOption, 'instruction'>): Promise<ResponseMessage>;
92
+ stream(prompt: string, session: Session, option?: Omit<AgentOption, "instruction">): Promise<Readable>;
93
+ private invokeDirect;
94
+ private invokeWithPlanner;
95
+ private streamDirect;
96
+ private streamWithPlanner;
97
+ private executePlan;
98
+ }
99
+
100
+ declare class DefaultPlanner {
101
+ private model;
102
+ constructor(model: Model);
103
+ private callLLM;
104
+ createPlan(userGoal: string, conversationHistory?: Message[]): Promise<Plan>;
105
+ /**
106
+ * PURE CRITIC INTERFACE
107
+ * Cross-references an execution string block against the target task expectations.
108
+ */
109
+ reflect(task: Task, executionOutput: string): Promise<boolean>;
110
+ /**
111
+ * CONTEXTUAL WORKFLOW PATCHING
112
+ * Invokes an LLM strategy session to formulate an actionable patch, injecting it into the state array.
113
+ */
114
+ replan(plan: Plan, failedTask: Task, failureOutput: string): Promise<void>;
35
115
  }
36
116
 
37
- export { Agent, AgentConfig, Session };
117
+ export { Agent, AgentConfig, DefaultPlanner, type IPlanner, Plan, Session, Task, type TaskStatus };