@lleverage-ai/agent-sdk 0.0.2 → 0.0.4
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/README.md +141 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +528 -41
- package/dist/agent.js.map +1 -1
- package/dist/hooks.d.ts +28 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +40 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware/apply.d.ts.map +1 -1
- package/dist/middleware/apply.js +8 -0
- package/dist/middleware/apply.js.map +1 -1
- package/dist/middleware/context.d.ts.map +1 -1
- package/dist/middleware/context.js +11 -0
- package/dist/middleware/context.js.map +1 -1
- package/dist/middleware/types.d.ts +8 -0
- package/dist/middleware/types.d.ts.map +1 -1
- package/dist/plugins/agent-teams/coordinator.d.ts +46 -0
- package/dist/plugins/agent-teams/coordinator.d.ts.map +1 -0
- package/dist/plugins/agent-teams/coordinator.js +255 -0
- package/dist/plugins/agent-teams/coordinator.js.map +1 -0
- package/dist/plugins/agent-teams/hooks.d.ts +29 -0
- package/dist/plugins/agent-teams/hooks.d.ts.map +1 -0
- package/dist/plugins/agent-teams/hooks.js +29 -0
- package/dist/plugins/agent-teams/hooks.js.map +1 -0
- package/dist/plugins/agent-teams/index.d.ts +59 -0
- package/dist/plugins/agent-teams/index.d.ts.map +1 -0
- package/dist/plugins/agent-teams/index.js +313 -0
- package/dist/plugins/agent-teams/index.js.map +1 -0
- package/dist/plugins/agent-teams/mermaid.d.ts +32 -0
- package/dist/plugins/agent-teams/mermaid.d.ts.map +1 -0
- package/dist/plugins/agent-teams/mermaid.js +66 -0
- package/dist/plugins/agent-teams/mermaid.js.map +1 -0
- package/dist/plugins/agent-teams/session-runner.d.ts +92 -0
- package/dist/plugins/agent-teams/session-runner.d.ts.map +1 -0
- package/dist/plugins/agent-teams/session-runner.js +166 -0
- package/dist/plugins/agent-teams/session-runner.js.map +1 -0
- package/dist/plugins/agent-teams/tools.d.ts +41 -0
- package/dist/plugins/agent-teams/tools.d.ts.map +1 -0
- package/dist/plugins/agent-teams/tools.js +289 -0
- package/dist/plugins/agent-teams/tools.js.map +1 -0
- package/dist/plugins/agent-teams/types.d.ts +164 -0
- package/dist/plugins/agent-teams/types.d.ts.map +1 -0
- package/dist/plugins/agent-teams/types.js +7 -0
- package/dist/plugins/agent-teams/types.js.map +1 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +1 -0
- package/dist/plugins.js.map +1 -1
- package/dist/presets/production.d.ts.map +1 -1
- package/dist/presets/production.js +7 -7
- package/dist/presets/production.js.map +1 -1
- package/dist/prompt-builder/components.d.ts +149 -0
- package/dist/prompt-builder/components.d.ts.map +1 -0
- package/dist/prompt-builder/components.js +252 -0
- package/dist/prompt-builder/components.js.map +1 -0
- package/dist/prompt-builder/index.d.ts +248 -0
- package/dist/prompt-builder/index.d.ts.map +1 -0
- package/dist/prompt-builder/index.js +165 -0
- package/dist/prompt-builder/index.js.map +1 -0
- package/dist/task-manager.d.ts +15 -0
- package/dist/task-manager.d.ts.map +1 -1
- package/dist/task-manager.js +36 -0
- package/dist/task-manager.js.map +1 -1
- package/dist/testing/mock-agent.d.ts.map +1 -1
- package/dist/testing/mock-agent.js +6 -0
- package/dist/testing/mock-agent.js.map +1 -1
- package/dist/testing/recorder.d.ts.map +1 -1
- package/dist/testing/recorder.js +6 -0
- package/dist/testing/recorder.js.map +1 -1
- package/dist/tools/task.d.ts.map +1 -1
- package/dist/tools/task.js +6 -2
- package/dist/tools/task.js.map +1 -1
- package/dist/types.d.ts +178 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Agent Teams plugin.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { LanguageModel } from "ai";
|
|
7
|
+
import type { Agent, AgentOptions, HookRegistration } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Mutable reference to an agent, used by tools that need access to an agent
|
|
10
|
+
* that hasn't been created yet at tool-definition time.
|
|
11
|
+
*
|
|
12
|
+
* @category Agent Teams
|
|
13
|
+
*/
|
|
14
|
+
export interface AgentRef {
|
|
15
|
+
current: Agent | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Status of a team task.
|
|
19
|
+
*
|
|
20
|
+
* @category Agent Teams
|
|
21
|
+
*/
|
|
22
|
+
export type TeamTaskStatus = "pending" | "in_progress" | "completed";
|
|
23
|
+
/**
|
|
24
|
+
* A shared task with dependencies for team coordination.
|
|
25
|
+
*
|
|
26
|
+
* @category Agent Teams
|
|
27
|
+
*/
|
|
28
|
+
export interface TeamTask {
|
|
29
|
+
/** Unique task identifier */
|
|
30
|
+
id: string;
|
|
31
|
+
/** Brief task title */
|
|
32
|
+
subject: string;
|
|
33
|
+
/** Detailed task description */
|
|
34
|
+
description: string;
|
|
35
|
+
/** Current task status */
|
|
36
|
+
status: TeamTaskStatus;
|
|
37
|
+
/** Teammate ID that claimed this task */
|
|
38
|
+
assignee?: string;
|
|
39
|
+
/** ID of the teammate/lead that created this task */
|
|
40
|
+
createdBy: string;
|
|
41
|
+
/** Task IDs that must complete before this task can start */
|
|
42
|
+
blockedBy: string[];
|
|
43
|
+
/** Task IDs that this task blocks (computed reverse dependency) */
|
|
44
|
+
blocks: string[];
|
|
45
|
+
/** Result or output after task completion */
|
|
46
|
+
result?: string;
|
|
47
|
+
/** ISO timestamp of task creation */
|
|
48
|
+
createdAt: string;
|
|
49
|
+
/** ISO timestamp of last update */
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A mailbox message between team members.
|
|
54
|
+
*
|
|
55
|
+
* @category Agent Teams
|
|
56
|
+
*/
|
|
57
|
+
export interface TeamMessage {
|
|
58
|
+
/** Unique message identifier */
|
|
59
|
+
id: string;
|
|
60
|
+
/** Sender teammate/lead ID */
|
|
61
|
+
from: string;
|
|
62
|
+
/** Recipient teammate ID (null for broadcast) */
|
|
63
|
+
to: string | null;
|
|
64
|
+
/** Message content */
|
|
65
|
+
content: string;
|
|
66
|
+
/** ISO timestamp */
|
|
67
|
+
timestamp: string;
|
|
68
|
+
/** Whether the recipient has read this message */
|
|
69
|
+
read: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Status of a teammate.
|
|
73
|
+
*
|
|
74
|
+
* @category Agent Teams
|
|
75
|
+
*/
|
|
76
|
+
export type TeammateStatus = "idle" | "working" | "stopped";
|
|
77
|
+
/**
|
|
78
|
+
* Information about an active teammate.
|
|
79
|
+
*
|
|
80
|
+
* @category Agent Teams
|
|
81
|
+
*/
|
|
82
|
+
export interface TeammateInfo {
|
|
83
|
+
/** Unique teammate identifier */
|
|
84
|
+
id: string;
|
|
85
|
+
/** Role name (e.g., "researcher", "coder") */
|
|
86
|
+
role: string;
|
|
87
|
+
/** Description of the teammate's capabilities */
|
|
88
|
+
description: string;
|
|
89
|
+
/** Current status */
|
|
90
|
+
status: TeammateStatus;
|
|
91
|
+
/** ID of the task currently being worked on */
|
|
92
|
+
currentTaskId?: string;
|
|
93
|
+
/** ISO timestamp when the teammate was spawned */
|
|
94
|
+
spawnedAt: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Abstract coordination interface for team management.
|
|
98
|
+
*
|
|
99
|
+
* Handles teammate registration, task management with dependencies,
|
|
100
|
+
* and inter-agent messaging.
|
|
101
|
+
*
|
|
102
|
+
* @category Agent Teams
|
|
103
|
+
*/
|
|
104
|
+
export interface TeamCoordinator {
|
|
105
|
+
registerTeammate(info: TeammateInfo): void;
|
|
106
|
+
removeTeammate(id: string): void;
|
|
107
|
+
getTeammate(id: string): TeammateInfo | undefined;
|
|
108
|
+
listTeammates(): TeammateInfo[];
|
|
109
|
+
updateTeammateStatus(id: string, status: TeammateStatus, taskId?: string): void;
|
|
110
|
+
createTask(task: Omit<TeamTask, "id" | "createdAt" | "updatedAt" | "blocks">): TeamTask;
|
|
111
|
+
getTask(id: string): TeamTask | undefined;
|
|
112
|
+
listTasks(filter?: {
|
|
113
|
+
status?: TeamTaskStatus;
|
|
114
|
+
assignee?: string;
|
|
115
|
+
}): TeamTask[];
|
|
116
|
+
claimTask(taskId: string, teammateId: string): boolean;
|
|
117
|
+
completeTask(taskId: string, result?: string): boolean;
|
|
118
|
+
updateTask(taskId: string, updates: Partial<Pick<TeamTask, "subject" | "description" | "status" | "blockedBy">>): boolean;
|
|
119
|
+
isTaskBlocked(taskId: string): boolean;
|
|
120
|
+
sendMessage(msg: Omit<TeamMessage, "id" | "timestamp" | "read">): TeamMessage;
|
|
121
|
+
getMessages(recipientId: string, unreadOnly?: boolean): TeamMessage[];
|
|
122
|
+
markRead(messageId: string): void;
|
|
123
|
+
waitForMessage(agentId: string, timeoutMs?: number): Promise<TeamMessage[] | null>;
|
|
124
|
+
dispose(): void;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Template for spawnable teammates.
|
|
128
|
+
*
|
|
129
|
+
* Defines the role, capabilities, and agent configuration for a teammate type.
|
|
130
|
+
*
|
|
131
|
+
* @category Agent Teams
|
|
132
|
+
*/
|
|
133
|
+
export interface TeammateDefinition {
|
|
134
|
+
/** Role name (e.g., "researcher", "coder") */
|
|
135
|
+
role: string;
|
|
136
|
+
/** Description of what this teammate does */
|
|
137
|
+
description: string;
|
|
138
|
+
/** Agent options for this teammate (systemPrompt, tools, plugins, etc.) */
|
|
139
|
+
agentOptions: Partial<AgentOptions>;
|
|
140
|
+
/** Model to use for this teammate */
|
|
141
|
+
model?: LanguageModel;
|
|
142
|
+
/** Maximum turns before the teammate stops */
|
|
143
|
+
maxTurns?: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Configuration options for the Agent Teams plugin.
|
|
147
|
+
*
|
|
148
|
+
* @category Agent Teams
|
|
149
|
+
*/
|
|
150
|
+
export interface AgentTeamsPluginOptions {
|
|
151
|
+
/** Teammate definitions (templates for spawnable teammates) */
|
|
152
|
+
teammates: TeammateDefinition[];
|
|
153
|
+
/** Custom coordinator implementation (defaults to InMemoryTeamCoordinator) */
|
|
154
|
+
coordinator?: TeamCoordinator;
|
|
155
|
+
/** Hooks to merge into the agent's hook registration */
|
|
156
|
+
hooks?: HookRegistration;
|
|
157
|
+
/** Maximum concurrent teammates (default: Infinity) */
|
|
158
|
+
maxConcurrentTeammates?: number;
|
|
159
|
+
/** Milliseconds to wait for messages before considering a teammate idle. @default 30000 */
|
|
160
|
+
idleTimeoutMs?: number;
|
|
161
|
+
/** Callback when a teammate session error occurs. If not provided, errors are logged to console. */
|
|
162
|
+
onError?: (teammateId: string, error: Error) => void;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent-teams/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAM5E;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC;CAC5B;AAMD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,WAAW,EAA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C;IAClC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,CAAC;IAGnF,OAAO,IAAI,IAAI,CAAC;CACjB;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oGAAoG;IACpG,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plugins/agent-teams/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/plugins.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,CAUhE"}
|
package/dist/plugins.js
CHANGED
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/presets/production.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGxC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/presets/production.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGxC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAC;AAoCzE;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;IAElD;;;OAGG;IACH,mBA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|
];
|
|
30
|
+
// Cast to Record for dynamic key assignment — all HookRegistration values are arrays
|
|
31
|
+
const t = target;
|
|
32
|
+
const s = source;
|
|
30
33
|
for (const event of hookEvents) {
|
|
31
|
-
const sourceCallbacks =
|
|
34
|
+
const sourceCallbacks = s[event];
|
|
32
35
|
if (sourceCallbacks) {
|
|
33
|
-
if (!
|
|
34
|
-
|
|
36
|
+
if (!t[event]) {
|
|
37
|
+
t[event] = sourceCallbacks;
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
|
-
|
|
38
|
-
...target[event],
|
|
39
|
-
...sourceCallbacks,
|
|
40
|
-
];
|
|
40
|
+
t[event] = [...t[event], ...sourceCallbacks];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production.js","sourceRoot":"","sources":["../../src/presets/production.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EACL,yBAAyB,GAG1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAG9B;;;GAGG;AACH,SAAS,UAAU,CAAC,MAAwB,EAAE,MAAiC;IAC7E,MAAM,UAAU,GAA+B;QAC7C,YAAY;QACZ,aAAa;QACb,oBAAoB;QACpB,aAAa;QACb,cAAc;QACd,qBAAqB;QACrB,cAAc;QACd,YAAY;QACZ,eAAe;QACf,cAAc;KACf,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"production.js","sourceRoot":"","sources":["../../src/presets/production.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,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AAM,EACJ,uBAAuB,GAAG,IAAI,EAC9B,wBAAwB,GAAG,IAAI,EAC/B,oBAAoB,GAAG,EAAE,EACzB,qBAAqB,GAAG,EAAE,EAC1B,gBAAgB,GAAG,IAAI,EACvB,GAAG,WAAW,EACf,GAAG,OAAO,CAAC;IAEZ,sCAAsC;IACtC,MAAM,qBAAqB,GAAG,uBAAuB;QACnD,CAAC,CAAC,CAAC,GAAG,8BAA8B,EAAE,GAAG,oBAAoB,CAAC;QAC9D,CAAC,CAAC,oBAAoB,CAAC;IAEzB,MAAM,sBAAsB,GAAG,wBAAwB;QACrD,CAAC,CAAC,CAAC,GAAG,+BAA+B,EAAE,GAAG,qBAAqB,CAAC;QAChE,CAAC,CAAC,qBAAqB,CAAC;IAE1B,kDAAkD;IAClD,OAAO,qBAAqB,CAAC;QAC3B,GAAG,WAAW;QACd,gBAAgB;QAChB,oBAAoB,EAAE,qBAAqB;QAC3C,qBAAqB,EAAE,sBAAsB;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default prompt components for common use cases.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { PromptComponent } from "./index.js";
|
|
7
|
+
import { PromptBuilder } from "./index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Default identity component providing a basic agent identity.
|
|
10
|
+
*
|
|
11
|
+
* Priority: 100 (highest)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const builder = new PromptBuilder().register(identityComponent);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @category Prompt Builder
|
|
19
|
+
*/
|
|
20
|
+
export declare const identityComponent: PromptComponent;
|
|
21
|
+
/**
|
|
22
|
+
* Lists available tools in the system prompt.
|
|
23
|
+
*
|
|
24
|
+
* Only included if tools are available.
|
|
25
|
+
* Priority: 70
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const builder = new PromptBuilder().register(toolsComponent);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @category Prompt Builder
|
|
33
|
+
*/
|
|
34
|
+
export declare const toolsComponent: PromptComponent;
|
|
35
|
+
/**
|
|
36
|
+
* Lists available skills in the system prompt.
|
|
37
|
+
*
|
|
38
|
+
* Only included if skills are available.
|
|
39
|
+
* Priority: 65
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const builder = new PromptBuilder().register(skillsComponent);
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @category Prompt Builder
|
|
47
|
+
*/
|
|
48
|
+
export declare const skillsComponent: PromptComponent;
|
|
49
|
+
/**
|
|
50
|
+
* Lists agent capabilities based on backend and configuration.
|
|
51
|
+
*
|
|
52
|
+
* Priority: 60
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const builder = new PromptBuilder().register(capabilitiesComponent);
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @category Prompt Builder
|
|
60
|
+
*/
|
|
61
|
+
export declare const capabilitiesComponent: PromptComponent;
|
|
62
|
+
/**
|
|
63
|
+
* Provides context about the current conversation.
|
|
64
|
+
*
|
|
65
|
+
* Only included if thread ID or messages are available.
|
|
66
|
+
* Priority: 50
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const builder = new PromptBuilder().register(contextComponent);
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @category Prompt Builder
|
|
74
|
+
*/
|
|
75
|
+
export declare const contextComponent: PromptComponent;
|
|
76
|
+
/**
|
|
77
|
+
* Lists loaded plugins.
|
|
78
|
+
*
|
|
79
|
+
* Only included if plugins are available.
|
|
80
|
+
* Priority: 68
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const builder = new PromptBuilder().register(pluginsComponent);
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @category Prompt Builder
|
|
88
|
+
*/
|
|
89
|
+
export declare const pluginsComponent: PromptComponent;
|
|
90
|
+
/**
|
|
91
|
+
* Provides information about permission mode.
|
|
92
|
+
*
|
|
93
|
+
* Only included if permission mode is set.
|
|
94
|
+
* Priority: 55
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const builder = new PromptBuilder().register(permissionModeComponent);
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @category Prompt Builder
|
|
102
|
+
*/
|
|
103
|
+
export declare const permissionModeComponent: PromptComponent;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a prompt builder with sensible defaults.
|
|
106
|
+
*
|
|
107
|
+
* Includes the following components by default:
|
|
108
|
+
* - `identity`: Basic agent identity
|
|
109
|
+
* - `tools-listing`: Available tools
|
|
110
|
+
* - `skills-listing`: Available skills
|
|
111
|
+
* - `plugins-listing`: Loaded plugins
|
|
112
|
+
* - `capabilities`: Backend capabilities
|
|
113
|
+
* - `permission-mode`: Permission mode info
|
|
114
|
+
* - `context`: Conversation context
|
|
115
|
+
*
|
|
116
|
+
* You can customize by cloning and modifying:
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Use defaults
|
|
121
|
+
* const agent = createAgent({
|
|
122
|
+
* model,
|
|
123
|
+
* // No systemPrompt = uses default builder automatically
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Customize defaults
|
|
130
|
+
* const builder = createDefaultPromptBuilder()
|
|
131
|
+
* .unregister('identity')
|
|
132
|
+
* .register({
|
|
133
|
+
* name: 'custom-identity',
|
|
134
|
+
* priority: 100,
|
|
135
|
+
* render: () => 'You are a specialized coding assistant.',
|
|
136
|
+
* });
|
|
137
|
+
*
|
|
138
|
+
* const agent = createAgent({
|
|
139
|
+
* model,
|
|
140
|
+
* promptBuilder: builder,
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @returns A PromptBuilder with default components registered
|
|
145
|
+
*
|
|
146
|
+
* @category Prompt Builder
|
|
147
|
+
*/
|
|
148
|
+
export declare function createDefaultPromptBuilder(): PromptBuilder;
|
|
149
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/prompt-builder/components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,EAAE,eAQ5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,eAQ7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,EAAE,eA6BnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAqB9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAQ9B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAsBrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,0BAA0B,IAAI,aAAa,CAU1D"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default prompt components for common use cases.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { PromptBuilder } from "./index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Default identity component providing a basic agent identity.
|
|
9
|
+
*
|
|
10
|
+
* Priority: 100 (highest)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const builder = new PromptBuilder().register(identityComponent);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @category Prompt Builder
|
|
18
|
+
*/
|
|
19
|
+
export const identityComponent = {
|
|
20
|
+
name: "identity",
|
|
21
|
+
priority: 100,
|
|
22
|
+
render: () => "You are a helpful AI assistant.",
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Lists available tools in the system prompt.
|
|
26
|
+
*
|
|
27
|
+
* Only included if tools are available.
|
|
28
|
+
* Priority: 70
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const builder = new PromptBuilder().register(toolsComponent);
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @category Prompt Builder
|
|
36
|
+
*/
|
|
37
|
+
export const toolsComponent = {
|
|
38
|
+
name: "tools-listing",
|
|
39
|
+
priority: 70,
|
|
40
|
+
condition: (ctx) => ctx.tools !== undefined && ctx.tools.length > 0,
|
|
41
|
+
render: (ctx) => {
|
|
42
|
+
const toolLines = ctx.tools.map((t) => `- **${t.name}**: ${t.description}`);
|
|
43
|
+
return `# Available Tools\n\nYou have access to the following tools:\n${toolLines.join("\n")}`;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Lists available skills in the system prompt.
|
|
48
|
+
*
|
|
49
|
+
* Only included if skills are available.
|
|
50
|
+
* Priority: 65
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const builder = new PromptBuilder().register(skillsComponent);
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Prompt Builder
|
|
58
|
+
*/
|
|
59
|
+
export const skillsComponent = {
|
|
60
|
+
name: "skills-listing",
|
|
61
|
+
priority: 65,
|
|
62
|
+
condition: (ctx) => ctx.skills !== undefined && ctx.skills.length > 0,
|
|
63
|
+
render: (ctx) => {
|
|
64
|
+
const skillLines = ctx.skills.map((s) => `- **${s.name}**: ${s.description}`);
|
|
65
|
+
return `# Available Skills\n\nYou can activate these skills on-demand:\n${skillLines.join("\n")}`;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Lists agent capabilities based on backend and configuration.
|
|
70
|
+
*
|
|
71
|
+
* Priority: 60
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const builder = new PromptBuilder().register(capabilitiesComponent);
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @category Prompt Builder
|
|
79
|
+
*/
|
|
80
|
+
export const capabilitiesComponent = {
|
|
81
|
+
name: "capabilities",
|
|
82
|
+
priority: 60,
|
|
83
|
+
render: (ctx) => {
|
|
84
|
+
const capabilities = [];
|
|
85
|
+
if (ctx.backend?.hasExecuteCapability) {
|
|
86
|
+
capabilities.push("- Execute shell commands (bash)");
|
|
87
|
+
}
|
|
88
|
+
if (ctx.backend?.type === "filesystem") {
|
|
89
|
+
capabilities.push("- Read and write files to the filesystem");
|
|
90
|
+
if (ctx.backend.rootDir) {
|
|
91
|
+
capabilities.push(`- Working directory: ${ctx.backend.rootDir}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (ctx.backend?.type === "state") {
|
|
95
|
+
capabilities.push("- In-memory file operations (sandboxed)");
|
|
96
|
+
}
|
|
97
|
+
if (ctx.state?.todos && ctx.state.todos.length > 0) {
|
|
98
|
+
capabilities.push(`- ${ctx.state.todos.length} active task(s) in the task list`);
|
|
99
|
+
}
|
|
100
|
+
if (capabilities.length === 0) {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
return `# Capabilities\n\n${capabilities.join("\n")}`;
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Provides context about the current conversation.
|
|
108
|
+
*
|
|
109
|
+
* Only included if thread ID or messages are available.
|
|
110
|
+
* Priority: 50
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const builder = new PromptBuilder().register(contextComponent);
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @category Prompt Builder
|
|
118
|
+
*/
|
|
119
|
+
export const contextComponent = {
|
|
120
|
+
name: "context",
|
|
121
|
+
priority: 50,
|
|
122
|
+
condition: (ctx) => !!ctx.threadId || !!(ctx.currentMessages && ctx.currentMessages.length > 0),
|
|
123
|
+
render: (ctx) => {
|
|
124
|
+
const parts = [];
|
|
125
|
+
if (ctx.threadId) {
|
|
126
|
+
parts.push(`- Thread ID: ${ctx.threadId}`);
|
|
127
|
+
}
|
|
128
|
+
if (ctx.currentMessages && ctx.currentMessages.length > 0) {
|
|
129
|
+
parts.push(`- Conversation history: ${ctx.currentMessages.length} message(s)`);
|
|
130
|
+
}
|
|
131
|
+
if (parts.length === 0) {
|
|
132
|
+
return "";
|
|
133
|
+
}
|
|
134
|
+
return `# Context\n\n${parts.join("\n")}`;
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Lists loaded plugins.
|
|
139
|
+
*
|
|
140
|
+
* Only included if plugins are available.
|
|
141
|
+
* Priority: 68
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* const builder = new PromptBuilder().register(pluginsComponent);
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @category Prompt Builder
|
|
149
|
+
*/
|
|
150
|
+
export const pluginsComponent = {
|
|
151
|
+
name: "plugins-listing",
|
|
152
|
+
priority: 68,
|
|
153
|
+
condition: (ctx) => ctx.plugins !== undefined && ctx.plugins.length > 0,
|
|
154
|
+
render: (ctx) => {
|
|
155
|
+
const pluginLines = ctx.plugins.map((p) => `- **${p.name}**: ${p.description}`);
|
|
156
|
+
return `# Loaded Plugins\n\n${pluginLines.join("\n")}`;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Provides information about permission mode.
|
|
161
|
+
*
|
|
162
|
+
* Only included if permission mode is set.
|
|
163
|
+
* Priority: 55
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const builder = new PromptBuilder().register(permissionModeComponent);
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @category Prompt Builder
|
|
171
|
+
*/
|
|
172
|
+
export const permissionModeComponent = {
|
|
173
|
+
name: "permission-mode",
|
|
174
|
+
priority: 55,
|
|
175
|
+
condition: (ctx) => !!ctx.permissionMode,
|
|
176
|
+
render: (ctx) => {
|
|
177
|
+
const mode = ctx.permissionMode;
|
|
178
|
+
let description = "";
|
|
179
|
+
if (mode === "default") {
|
|
180
|
+
description = "Default permission mode: tools may require approval based on safety rules.";
|
|
181
|
+
}
|
|
182
|
+
else if (mode === "acceptEdits") {
|
|
183
|
+
description = "File editing tools are auto-approved; other tools may require approval.";
|
|
184
|
+
}
|
|
185
|
+
else if (mode === "bypassPermissions") {
|
|
186
|
+
description = "All tools are auto-approved without permission checks.";
|
|
187
|
+
}
|
|
188
|
+
else if (mode === "plan") {
|
|
189
|
+
description = "Plan mode: tool use is planned but not executed.";
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
description = `Permission mode: ${String(mode)}`;
|
|
193
|
+
}
|
|
194
|
+
return `# Permission Mode\n\n${description}`;
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Creates a prompt builder with sensible defaults.
|
|
199
|
+
*
|
|
200
|
+
* Includes the following components by default:
|
|
201
|
+
* - `identity`: Basic agent identity
|
|
202
|
+
* - `tools-listing`: Available tools
|
|
203
|
+
* - `skills-listing`: Available skills
|
|
204
|
+
* - `plugins-listing`: Loaded plugins
|
|
205
|
+
* - `capabilities`: Backend capabilities
|
|
206
|
+
* - `permission-mode`: Permission mode info
|
|
207
|
+
* - `context`: Conversation context
|
|
208
|
+
*
|
|
209
|
+
* You can customize by cloning and modifying:
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // Use defaults
|
|
214
|
+
* const agent = createAgent({
|
|
215
|
+
* model,
|
|
216
|
+
* // No systemPrompt = uses default builder automatically
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* // Customize defaults
|
|
223
|
+
* const builder = createDefaultPromptBuilder()
|
|
224
|
+
* .unregister('identity')
|
|
225
|
+
* .register({
|
|
226
|
+
* name: 'custom-identity',
|
|
227
|
+
* priority: 100,
|
|
228
|
+
* render: () => 'You are a specialized coding assistant.',
|
|
229
|
+
* });
|
|
230
|
+
*
|
|
231
|
+
* const agent = createAgent({
|
|
232
|
+
* model,
|
|
233
|
+
* promptBuilder: builder,
|
|
234
|
+
* });
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* @returns A PromptBuilder with default components registered
|
|
238
|
+
*
|
|
239
|
+
* @category Prompt Builder
|
|
240
|
+
*/
|
|
241
|
+
export function createDefaultPromptBuilder() {
|
|
242
|
+
return new PromptBuilder().registerMany([
|
|
243
|
+
identityComponent,
|
|
244
|
+
toolsComponent,
|
|
245
|
+
skillsComponent,
|
|
246
|
+
pluginsComponent,
|
|
247
|
+
capabilitiesComponent,
|
|
248
|
+
permissionModeComponent,
|
|
249
|
+
contextComponent,
|
|
250
|
+
]);
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","s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