@locusai/sdk 0.7.3 → 0.7.6
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/agent/document-fetcher.d.ts +23 -0
- package/dist/agent/document-fetcher.d.ts.map +1 -0
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/worker.d.ts +1 -1
- package/dist/agent/worker.d.ts.map +1 -1
- package/dist/agent/worker.js +424 -124
- package/dist/ai/claude-runner.d.ts +17 -0
- package/dist/ai/claude-runner.d.ts.map +1 -1
- package/dist/ai/codex-runner.d.ts +2 -0
- package/dist/ai/codex-runner.d.ts.map +1 -1
- package/dist/ai/runner.d.ts +7 -0
- package/dist/ai/runner.d.ts.map +1 -1
- package/dist/core/config.d.ts +10 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/exec/context-tracker.d.ts +183 -0
- package/dist/exec/context-tracker.d.ts.map +1 -0
- package/dist/exec/event-emitter.d.ts +117 -0
- package/dist/exec/event-emitter.d.ts.map +1 -0
- package/dist/exec/events.d.ts +171 -0
- package/dist/exec/events.d.ts.map +1 -0
- package/dist/exec/exec-session.d.ts +164 -0
- package/dist/exec/exec-session.d.ts.map +1 -0
- package/dist/exec/history-manager.d.ts +153 -0
- package/dist/exec/history-manager.d.ts.map +1 -0
- package/dist/exec/index.d.ts +7 -0
- package/dist/exec/index.d.ts.map +1 -0
- package/dist/exec/types.d.ts +130 -0
- package/dist/exec/types.d.ts.map +1 -0
- package/dist/index-node.d.ts +1 -0
- package/dist/index-node.d.ts.map +1 -1
- package/dist/index-node.js +1274 -139
- package/package.json +2 -2
- package/dist/agent/artifact-syncer.d.ts +0 -18
- package/dist/agent/artifact-syncer.d.ts.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { AiRunner } from "../ai/runner.js";
|
|
2
|
+
import { type Artifact, ContextTracker, type Task } from "./context-tracker.js";
|
|
3
|
+
import { ExecEventEmitter } from "./event-emitter.js";
|
|
4
|
+
import { ExecEventType } from "./events.js";
|
|
5
|
+
import { type ConversationMessage, type ConversationSession, HistoryManager } from "./history-manager.js";
|
|
6
|
+
import type { StreamChunk } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for ExecSession.
|
|
9
|
+
*/
|
|
10
|
+
export interface ExecSessionConfig {
|
|
11
|
+
/** The AI runner to use for execution */
|
|
12
|
+
aiRunner: AiRunner;
|
|
13
|
+
/** Project path for history storage */
|
|
14
|
+
projectPath: string;
|
|
15
|
+
/** Model name for session metadata */
|
|
16
|
+
model: string;
|
|
17
|
+
/** Provider name for session metadata */
|
|
18
|
+
provider: string;
|
|
19
|
+
/** Optional session ID to resume */
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
/** Maximum messages to include in context (default: 10) */
|
|
22
|
+
maxContextMessages?: number;
|
|
23
|
+
/** Enable debug mode for event logging */
|
|
24
|
+
debug?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result returned after execution completes.
|
|
28
|
+
*/
|
|
29
|
+
export interface ExecResult {
|
|
30
|
+
content: string;
|
|
31
|
+
toolsUsed: string[];
|
|
32
|
+
duration: number;
|
|
33
|
+
success: boolean;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Manages AI execution with conversation history persistence.
|
|
38
|
+
*
|
|
39
|
+
* ExecSession wraps an AI runner and automatically:
|
|
40
|
+
* - Maintains conversation history across prompts
|
|
41
|
+
* - Persists history to disk between sessions
|
|
42
|
+
* - Includes recent history in prompts for context
|
|
43
|
+
* - Emits events for progress tracking
|
|
44
|
+
* - Prunes old sessions to prevent unbounded growth
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const session = new ExecSession({
|
|
49
|
+
* aiRunner: myRunner,
|
|
50
|
+
* projectPath: '/path/to/project',
|
|
51
|
+
* model: 'claude-sonnet-4-5',
|
|
52
|
+
* provider: 'claude',
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* await session.initialize();
|
|
56
|
+
*
|
|
57
|
+
* // Stream execution with history
|
|
58
|
+
* for await (const chunk of session.executeStreaming('Write a function')) {
|
|
59
|
+
* console.log(chunk);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Save session for later resume
|
|
63
|
+
* session.save();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class ExecSession {
|
|
67
|
+
private aiRunner;
|
|
68
|
+
private history;
|
|
69
|
+
private currentSession;
|
|
70
|
+
private eventEmitter;
|
|
71
|
+
private contextTracker;
|
|
72
|
+
private maxContextMessages;
|
|
73
|
+
private model;
|
|
74
|
+
private provider;
|
|
75
|
+
private sessionId?;
|
|
76
|
+
/** Track tool start times for duration calculation */
|
|
77
|
+
private toolStartTimes;
|
|
78
|
+
constructor(config: ExecSessionConfig);
|
|
79
|
+
/**
|
|
80
|
+
* Initialize the session, loading existing session or creating new one.
|
|
81
|
+
*/
|
|
82
|
+
initialize(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Get the current session.
|
|
85
|
+
*/
|
|
86
|
+
getSession(): ConversationSession | null;
|
|
87
|
+
/**
|
|
88
|
+
* Get the session ID.
|
|
89
|
+
*/
|
|
90
|
+
getSessionId(): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Get the event emitter for subscribing to execution events.
|
|
93
|
+
*/
|
|
94
|
+
getEventEmitter(): ExecEventEmitter;
|
|
95
|
+
/**
|
|
96
|
+
* Get the history manager.
|
|
97
|
+
*/
|
|
98
|
+
getHistoryManager(): HistoryManager;
|
|
99
|
+
/**
|
|
100
|
+
* Get the context tracker for managing artifacts and tasks.
|
|
101
|
+
*/
|
|
102
|
+
getContextTracker(): ContextTracker;
|
|
103
|
+
/**
|
|
104
|
+
* Create and track an artifact in the session.
|
|
105
|
+
*/
|
|
106
|
+
createArtifact(params: Omit<Artifact, "id" | "createdAt" | "updatedAt">): Artifact;
|
|
107
|
+
/**
|
|
108
|
+
* Create and track a task in the session.
|
|
109
|
+
*/
|
|
110
|
+
createTask(params: Omit<Task, "id" | "createdAt" | "updatedAt">): Task;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve a natural language reference to an artifact.
|
|
113
|
+
*/
|
|
114
|
+
resolveArtifactReference(reference: string): Artifact | null;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve a natural language reference to a task.
|
|
117
|
+
*/
|
|
118
|
+
resolveTaskReference(reference: string): Task | null;
|
|
119
|
+
/**
|
|
120
|
+
* Get conversation messages from the current session.
|
|
121
|
+
*/
|
|
122
|
+
getMessages(): ConversationMessage[];
|
|
123
|
+
/**
|
|
124
|
+
* Add a message to the current session.
|
|
125
|
+
*/
|
|
126
|
+
addMessage(message: Omit<ConversationMessage, "timestamp">): void;
|
|
127
|
+
/**
|
|
128
|
+
* Execute a prompt with streaming output and history context.
|
|
129
|
+
*/
|
|
130
|
+
executeStreaming(userPrompt: string): AsyncGenerator<StreamChunk, void, unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* Execute a prompt without streaming (returns complete result).
|
|
133
|
+
*/
|
|
134
|
+
execute(userPrompt: string): Promise<ExecResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Build a prompt that includes conversation history and context for follow-ups.
|
|
137
|
+
*/
|
|
138
|
+
private buildPromptWithHistory;
|
|
139
|
+
/**
|
|
140
|
+
* Save the current session to disk.
|
|
141
|
+
*/
|
|
142
|
+
save(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Reset the session (clear messages but keep the same session ID).
|
|
145
|
+
*/
|
|
146
|
+
reset(): void;
|
|
147
|
+
/**
|
|
148
|
+
* Start a new session (discards current session if not saved).
|
|
149
|
+
*/
|
|
150
|
+
startNewSession(): void;
|
|
151
|
+
/**
|
|
152
|
+
* End the session and emit completion event.
|
|
153
|
+
*/
|
|
154
|
+
end(success?: boolean): void;
|
|
155
|
+
/**
|
|
156
|
+
* Subscribe to execution events.
|
|
157
|
+
*/
|
|
158
|
+
on<K extends ExecEventType>(eventType: K, listener: Parameters<ExecEventEmitter["on"]>[1]): this;
|
|
159
|
+
/**
|
|
160
|
+
* Unsubscribe from execution events.
|
|
161
|
+
*/
|
|
162
|
+
off<K extends ExecEventType>(eventType: K, listener: Parameters<ExecEventEmitter["off"]>[1]): this;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=exec-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-session.d.ts","sourceRoot":"","sources":["../../src/exec/exec-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,KAAK,QAAQ,EACb,cAAc,EAEd,KAAK,IAAI,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0CAA0C;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,U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G,IAAI;IAIpD;;OAEG;IACH,WAAW,IAAI,mBAAmB,EAAE;IAIpC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,GAAG,IAAI;IAWjE;;OAEG;IACI,gBAAgB,CACrB,UAAU,EAAE,MAAM,GACjB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IA4H7C;;OAEG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA8BtD;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoC9B;;OAEG;IACH,IAAI,IAAI,IAAI;IAiBZ;;OAEG;IACH,KAAK,IAAI,IAAI;IAUb;;OAEG;IACH,eAAe,IAAI,IAAI;IAavB;;OAEG;IACH,GAAG,CAAC,OAAO,UAAO,GAAG,IAAI;IAIzB;;OAEG;IACH,EAAE,CAAC,CAAC,SAAS,aAAa,EACxB,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI;IAKP;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,aAAa,EACzB,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/C,IAAI;CAIR"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single message in a conversation.
|
|
3
|
+
*/
|
|
4
|
+
export interface ConversationMessage {
|
|
5
|
+
role: "user" | "assistant";
|
|
6
|
+
content: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
metadata?: {
|
|
9
|
+
toolsUsed?: string[];
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents a complete conversation session.
|
|
15
|
+
*/
|
|
16
|
+
export interface ConversationSession {
|
|
17
|
+
id: string;
|
|
18
|
+
projectPath: string;
|
|
19
|
+
messages: ConversationMessage[];
|
|
20
|
+
createdAt: number;
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
metadata: {
|
|
23
|
+
model: string;
|
|
24
|
+
provider: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Filter options for searching/listing sessions.
|
|
29
|
+
*/
|
|
30
|
+
export interface SessionFilterOptions {
|
|
31
|
+
/** Filter by text content in messages */
|
|
32
|
+
query?: string;
|
|
33
|
+
/** Filter sessions created after this timestamp */
|
|
34
|
+
after?: number;
|
|
35
|
+
/** Filter sessions created before this timestamp */
|
|
36
|
+
before?: number;
|
|
37
|
+
/** Maximum number of sessions to return */
|
|
38
|
+
limit?: number;
|
|
39
|
+
/** Offset for pagination */
|
|
40
|
+
offset?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Configuration options for HistoryManager.
|
|
44
|
+
*/
|
|
45
|
+
export interface HistoryManagerOptions {
|
|
46
|
+
/** Maximum number of sessions to keep (default: 30) */
|
|
47
|
+
maxSessions?: number;
|
|
48
|
+
/** Custom history directory path */
|
|
49
|
+
historyDir?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Manages conversation history persistence for exec sessions.
|
|
53
|
+
*
|
|
54
|
+
* Stores sessions as JSON files in `.locus/sessions/` directory.
|
|
55
|
+
* Supports session save/load, listing, searching, and auto-pruning.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const history = new HistoryManager('/path/to/project');
|
|
60
|
+
*
|
|
61
|
+
* // Get or create current session
|
|
62
|
+
* const session = await history.getCurrentSession();
|
|
63
|
+
*
|
|
64
|
+
* // Add a message
|
|
65
|
+
* session.messages.push({
|
|
66
|
+
* role: 'user',
|
|
67
|
+
* content: 'Hello',
|
|
68
|
+
* timestamp: Date.now()
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* // Save the session
|
|
72
|
+
* await history.saveSession(session);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare class HistoryManager {
|
|
76
|
+
private historyDir;
|
|
77
|
+
private maxSessions;
|
|
78
|
+
constructor(projectPath: string, options?: HistoryManagerOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Ensure the history directory exists.
|
|
81
|
+
*/
|
|
82
|
+
private ensureHistoryDir;
|
|
83
|
+
/**
|
|
84
|
+
* Get the file path for a session.
|
|
85
|
+
*/
|
|
86
|
+
private getSessionPath;
|
|
87
|
+
/**
|
|
88
|
+
* Save a session to disk.
|
|
89
|
+
*/
|
|
90
|
+
saveSession(session: ConversationSession): void;
|
|
91
|
+
/**
|
|
92
|
+
* Load a session from disk by ID.
|
|
93
|
+
* @returns The session if found, null otherwise.
|
|
94
|
+
*/
|
|
95
|
+
loadSession(sessionId: string): ConversationSession | null;
|
|
96
|
+
/**
|
|
97
|
+
* Delete a session from disk.
|
|
98
|
+
* @returns true if the session was deleted, false if it didn't exist.
|
|
99
|
+
*/
|
|
100
|
+
deleteSession(sessionId: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* List all sessions, sorted by updatedAt (most recent first).
|
|
103
|
+
*/
|
|
104
|
+
listSessions(options?: SessionFilterOptions): ConversationSession[];
|
|
105
|
+
/**
|
|
106
|
+
* Apply filter options to a list of sessions.
|
|
107
|
+
*/
|
|
108
|
+
private filterSessions;
|
|
109
|
+
/**
|
|
110
|
+
* Search sessions by content query.
|
|
111
|
+
* Returns sessions that contain the query in any message.
|
|
112
|
+
*/
|
|
113
|
+
searchSessions(query: string, limit?: number): ConversationSession[];
|
|
114
|
+
/**
|
|
115
|
+
* Get or create the current (most recent) session.
|
|
116
|
+
* If no sessions exist, creates a new one.
|
|
117
|
+
*/
|
|
118
|
+
getCurrentSession(model?: string, provider?: string): ConversationSession;
|
|
119
|
+
/**
|
|
120
|
+
* Create a new session.
|
|
121
|
+
*/
|
|
122
|
+
createNewSession(model?: string, provider?: string): ConversationSession;
|
|
123
|
+
/**
|
|
124
|
+
* Prune old sessions to keep only the most recent ones.
|
|
125
|
+
* Deletes sessions beyond the maxSessions limit.
|
|
126
|
+
* @returns Number of sessions deleted.
|
|
127
|
+
*/
|
|
128
|
+
pruneSessions(): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get session count.
|
|
131
|
+
*/
|
|
132
|
+
getSessionCount(): number;
|
|
133
|
+
/**
|
|
134
|
+
* Check if a session exists.
|
|
135
|
+
*/
|
|
136
|
+
sessionExists(sessionId: string): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Find a session by partial ID match.
|
|
139
|
+
* Supports both short IDs (last part of session ID) and partial matches.
|
|
140
|
+
* @returns The matching session if found, null otherwise.
|
|
141
|
+
*/
|
|
142
|
+
findSessionByPartialId(partialId: string): ConversationSession | null;
|
|
143
|
+
/**
|
|
144
|
+
* Get the history directory path.
|
|
145
|
+
*/
|
|
146
|
+
getHistoryDir(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Clear all sessions from the history directory.
|
|
149
|
+
* @returns Number of sessions deleted.
|
|
150
|
+
*/
|
|
151
|
+
clearAllSessions(): number;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=history-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-manager.d.ts","sourceRoot":"","sources":["../../src/exec/history-manager.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,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AO,CAAC,cAAc;IAkCtB;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,mBAAmB,EAAE;IAIpE;;;OAGG;IACH,iBAAiB,CACf,KAAK,SAAsB,EAC3B,QAAQ,SAAW,GAClB,mBAAmB;IAUtB;;OAEG;IACH,gBAAgB,CACd,KAAK,SAAsB,EAC3B,QAAQ,SAAW,GAClB,mBAAmB;IAkBtB;;;;OAIG;IACH,aAAa,IAAI,MAAM;IAgBvB;;OAEG;IACH,eAAe,IAAI,MAAM;IAKzB;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIzC;;;;OAIG;IACH,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAcrE;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,gBAAgB,IAAI,MAAM;CAiB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exec/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream chunk types for real-time AI output streaming.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Text delta chunk - contains incremental text content
|
|
6
|
+
*/
|
|
7
|
+
export interface TextDeltaChunk {
|
|
8
|
+
type: "text_delta";
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Tool parameters for different tool types.
|
|
13
|
+
*/
|
|
14
|
+
export interface ReadToolParams {
|
|
15
|
+
file_path: string;
|
|
16
|
+
offset?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface WriteToolParams {
|
|
20
|
+
file_path: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
export interface EditToolParams {
|
|
24
|
+
file_path: string;
|
|
25
|
+
old_string: string;
|
|
26
|
+
new_string: string;
|
|
27
|
+
replace_all?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface BashToolParams {
|
|
30
|
+
command: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface GrepToolParams {
|
|
35
|
+
pattern: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
glob?: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
output_mode?: "content" | "files_with_matches" | "count";
|
|
40
|
+
}
|
|
41
|
+
export interface GlobToolParams {
|
|
42
|
+
pattern: string;
|
|
43
|
+
path?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface WebFetchToolParams {
|
|
46
|
+
url: string;
|
|
47
|
+
prompt: string;
|
|
48
|
+
}
|
|
49
|
+
export interface TaskToolParams {
|
|
50
|
+
description: string;
|
|
51
|
+
prompt: string;
|
|
52
|
+
subagent_type: string;
|
|
53
|
+
}
|
|
54
|
+
export type ToolParams = ReadToolParams | WriteToolParams | EditToolParams | BashToolParams | GrepToolParams | GlobToolParams | WebFetchToolParams | TaskToolParams | Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Tool use chunk - indicates an AI tool is being invoked
|
|
57
|
+
*/
|
|
58
|
+
export interface ToolUseChunk {
|
|
59
|
+
type: "tool_use";
|
|
60
|
+
tool: string;
|
|
61
|
+
id?: string;
|
|
62
|
+
parameters?: ToolParams;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Tool result data for different tool types.
|
|
66
|
+
*/
|
|
67
|
+
export interface GrepResultData {
|
|
68
|
+
matches?: number;
|
|
69
|
+
files?: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface GlobResultData {
|
|
72
|
+
files?: string[];
|
|
73
|
+
count?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface ReadResultData {
|
|
76
|
+
lines?: number;
|
|
77
|
+
size?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface BashResultData {
|
|
80
|
+
exitCode?: number;
|
|
81
|
+
output?: string;
|
|
82
|
+
}
|
|
83
|
+
export type ToolResultData = GrepResultData | GlobResultData | ReadResultData | BashResultData | Record<string, unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Tool result chunk - indicates a tool has completed
|
|
86
|
+
*/
|
|
87
|
+
export interface ToolResultChunk {
|
|
88
|
+
type: "tool_result";
|
|
89
|
+
tool: string;
|
|
90
|
+
id?: string;
|
|
91
|
+
success: boolean;
|
|
92
|
+
error?: string;
|
|
93
|
+
duration?: number;
|
|
94
|
+
data?: ToolResultData;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Thinking chunk - indicates the AI is processing/thinking
|
|
98
|
+
*/
|
|
99
|
+
export interface ThinkingChunk {
|
|
100
|
+
type: "thinking";
|
|
101
|
+
content?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Result chunk - final result when stream completes
|
|
105
|
+
*/
|
|
106
|
+
export interface ResultChunk {
|
|
107
|
+
type: "result";
|
|
108
|
+
content: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Error chunk - indicates an error occurred during streaming
|
|
112
|
+
*/
|
|
113
|
+
export interface ErrorChunk {
|
|
114
|
+
type: "error";
|
|
115
|
+
error: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Tool parameters chunk - emitted when tool parameters are fully parsed
|
|
119
|
+
*/
|
|
120
|
+
export interface ToolParametersChunk {
|
|
121
|
+
type: "tool_parameters";
|
|
122
|
+
tool: string;
|
|
123
|
+
id?: string;
|
|
124
|
+
parameters: ToolParams;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Union type of all possible stream chunks
|
|
128
|
+
*/
|
|
129
|
+
export type StreamChunk = TextDeltaChunk | ToolUseChunk | ToolResultChunk | ThinkingChunk | ResultChunk | ErrorChunk | ToolParametersChunk;
|
|
130
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exec/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,SAAS,GAAG,oBAAoB,GAAG,OAAO,CAAC;CAC1D;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB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;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,YAAY,GACZ,eAAe,GACf,aAAa,GACb,WAAW,GACX,UAAU,GACV,mBAAmB,CAAC"}
|
package/dist/index-node.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./agent/index.js";
|
|
|
10
10
|
export * from "./ai/index.js";
|
|
11
11
|
export * from "./core/index.js";
|
|
12
12
|
export { PromptBuilder } from "./core/prompt-builder.js";
|
|
13
|
+
export * from "./exec/index.js";
|
|
13
14
|
export * from "./index.js";
|
|
14
15
|
export { AgentOrchestrator, type OrchestratorConfig } from "./orchestrator.js";
|
|
15
16
|
export { c } from "./utils/colors.js";
|
package/dist/index-node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAE9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,cAAc,iBAAiB,CAAC;AAEhC,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC"}
|