paean 0.10.3 → 0.10.5
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.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/context-tools.d.ts +32 -0
- package/dist/mcp/context-tools.d.ts.map +1 -0
- package/dist/mcp/context-tools.js +136 -0
- package/dist/mcp/context-tools.js.map +1 -0
- package/dist/mcp/{cron.d.ts → loop.d.ts} +30 -14
- package/dist/mcp/{cron.d.ts.map → loop.d.ts.map} +1 -1
- package/dist/mcp/{cron.js → loop.js} +85 -73
- package/dist/mcp/{cron.js.map → loop.js.map} +1 -1
- package/dist/mcp/system.js +1 -1
- package/dist/mcp/system.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +13 -6
- package/dist/mcp/tools.js.map +1 -1
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +10 -2
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/hooks/useAgentStream.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentStream.js +29 -5
- package/dist/ui/hooks/useAgentStream.js.map +1 -1
- package/dist/ui/hooks/useCommands.d.ts.map +1 -1
- package/dist/ui/hooks/useCommands.js +18 -1
- package/dist/ui/hooks/useCommands.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ export { getMcpTools, executeMcpTool } from './mcp/tools.js';
|
|
|
13
13
|
export { McpClient } from './mcp/client.js';
|
|
14
14
|
export { AgentService, agentService, startChat, sendMessage, renderMarkdown, type AgentStreamEvent, type AgentStreamCallbacks, type McpState, type McpToolResult, } from './agent/index.js';
|
|
15
15
|
export { getSystemTools, executeSystemTool, isCommandWhitelisted, getCommandWhitelist, } from './mcp/system.js';
|
|
16
|
-
export { getCronToolDefinitions, executeCronTool, CRON_TOOL_NAMES, getActiveCronCount, clearAllCronJobs, onCronPrompt,
|
|
16
|
+
export { getLoopToolDefinitions, executeLoopTool, LOOP_TOOL_NAMES, getActiveLoopCount, clearAllLoopJobs, onLoopPrompt, setAgentBusyChecker, type LoopJob, type LoopPromptEvent, getCronToolDefinitions, executeCronTool, CRON_TOOL_NAMES, getActiveCronCount, clearAllCronJobs, onCronPrompt, type CronJob, type CronPromptEvent, } from './mcp/loop.js';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGpF,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,aAAa,EACb,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,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,EACd,SAAS,EACT,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,aAAa,GACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,KAAK,OAAO,EACZ,KAAK,eAAe,EAEpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,KAAK,OAAO,EACZ,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,8 @@ export { McpClient } from './mcp/client.js';
|
|
|
22
22
|
export { AgentService, agentService, startChat, sendMessage, renderMarkdown, } from './agent/index.js';
|
|
23
23
|
// System/Shell Tools
|
|
24
24
|
export { getSystemTools, executeSystemTool, isCommandWhitelisted, getCommandWhitelist, } from './mcp/system.js';
|
|
25
|
-
//
|
|
26
|
-
export {
|
|
25
|
+
// Loop Tools (session-scoped, prompt-injection based recurring tasks)
|
|
26
|
+
export { getLoopToolDefinitions, executeLoopTool, LOOP_TOOL_NAMES, getActiveLoopCount, clearAllLoopJobs, onLoopPrompt, setAgentBusyChecker,
|
|
27
|
+
// Legacy aliases
|
|
28
|
+
getCronToolDefinitions, executeCronTool, CRON_TOOL_NAMES, getActiveCronCount, clearAllCronJobs, onCronPrompt, } from './mcp/loop.js';
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,aAAa;AACb,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,iBAAiB;AACjB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,aAAa,EACb,MAAM,GAGP,MAAM,eAAe,CAAC;AAEvB,WAAW;AACX,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,GAKb,MAAM,eAAe,CAAC;AAEvB,gBAAgB;AAChB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,GAEd,MAAM,mBAAmB,CAAC;AAE3B,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAE5B,aAAa;AACb,OAAO,EAAE,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE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AAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE7D,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,aAAa;AACb,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,cAAc,GAKf,MAAM,kBAAkB,CAAC;AAE1B,qBAAqB;AACrB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,sEAAsE;AACtE,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB;AAGnB,iBAAiB;AACjB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,GAGb,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Management MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Provides tools that let the agent programmatically manage its own
|
|
5
|
+
* conversation context — clearing or compacting it. This is essential for
|
|
6
|
+
* loop/scheduled tasks that need a clean context between iterations.
|
|
7
|
+
*
|
|
8
|
+
* Uses an EventEmitter pattern (same as loop.ts) so the tool execution
|
|
9
|
+
* can signal the React hook (useAgentStream) to reset conversationId.
|
|
10
|
+
*/
|
|
11
|
+
import { type Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
12
|
+
export interface ContextActionEvent {
|
|
13
|
+
action: 'clear' | 'compact';
|
|
14
|
+
/** Agent-provided summary of what was accomplished (used by compact) */
|
|
15
|
+
summary?: string;
|
|
16
|
+
/** Reason the agent is performing this action */
|
|
17
|
+
reason?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a callback that fires when the agent requests a context action.
|
|
21
|
+
* Returns an unsubscribe function.
|
|
22
|
+
*/
|
|
23
|
+
export declare function onContextAction(callback: (event: ContextActionEvent) => void): () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Consume the pending compact summary (if any). Returns the summary string
|
|
26
|
+
* and clears it so it's only used once.
|
|
27
|
+
*/
|
|
28
|
+
export declare function consumeCompactSummary(): string | null;
|
|
29
|
+
export declare function getContextToolDefinitions(): Tool[];
|
|
30
|
+
export declare const CONTEXT_TOOL_NAMES: Set<string>;
|
|
31
|
+
export declare function executeContextTool(toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
32
|
+
//# sourceMappingURL=context-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-tools.d.ts","sourceRoot":"","sources":["../../src/mcp/context-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAO/D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC5C,MAAM,IAAI,CAKZ;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAIrD;AAMD,wBAAgB,yBAAyB,IAAI,IAAI,EAAE,CAiDlD;AAED,eAAO,MAAM,kBAAkB,aAG7B,CAAC;AAMH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,CAmDlB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Management MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Provides tools that let the agent programmatically manage its own
|
|
5
|
+
* conversation context — clearing or compacting it. This is essential for
|
|
6
|
+
* loop/scheduled tasks that need a clean context between iterations.
|
|
7
|
+
*
|
|
8
|
+
* Uses an EventEmitter pattern (same as loop.ts) so the tool execution
|
|
9
|
+
* can signal the React hook (useAgentStream) to reset conversationId.
|
|
10
|
+
*/
|
|
11
|
+
import { EventEmitter } from 'events';
|
|
12
|
+
// ============================================
|
|
13
|
+
// Event Bus
|
|
14
|
+
// ============================================
|
|
15
|
+
const contextEmitter = new EventEmitter();
|
|
16
|
+
/**
|
|
17
|
+
* Register a callback that fires when the agent requests a context action.
|
|
18
|
+
* Returns an unsubscribe function.
|
|
19
|
+
*/
|
|
20
|
+
export function onContextAction(callback) {
|
|
21
|
+
contextEmitter.on('context-action', callback);
|
|
22
|
+
return () => {
|
|
23
|
+
contextEmitter.off('context-action', callback);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// ============================================
|
|
27
|
+
// Stored compact summary (carry-forward)
|
|
28
|
+
// ============================================
|
|
29
|
+
let pendingCompactSummary = null;
|
|
30
|
+
/**
|
|
31
|
+
* Consume the pending compact summary (if any). Returns the summary string
|
|
32
|
+
* and clears it so it's only used once.
|
|
33
|
+
*/
|
|
34
|
+
export function consumeCompactSummary() {
|
|
35
|
+
const summary = pendingCompactSummary;
|
|
36
|
+
pendingCompactSummary = null;
|
|
37
|
+
return summary;
|
|
38
|
+
}
|
|
39
|
+
// ============================================
|
|
40
|
+
// MCP Tool Definitions
|
|
41
|
+
// ============================================
|
|
42
|
+
export function getContextToolDefinitions() {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
name: 'paean_context_clear',
|
|
46
|
+
description: 'Clear the current conversation context entirely. ' +
|
|
47
|
+
'The next message will start a brand-new conversation with no history. ' +
|
|
48
|
+
'Use this after completing a loop task iteration to ensure clean context ' +
|
|
49
|
+
'for the next run, or when the conversation has become too large/noisy. ' +
|
|
50
|
+
'This is equivalent to the user typing /clear.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
reason: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Brief reason for clearing context (e.g. "loop iteration complete", "context too large")',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'paean_context_compact',
|
|
63
|
+
description: 'Compact the current conversation by summarizing it. ' +
|
|
64
|
+
'Provide a concise summary of key facts, decisions, and outcomes from the conversation so far. ' +
|
|
65
|
+
'The current conversation will be replaced with a fresh one that starts with your summary as context. ' +
|
|
66
|
+
'Use this instead of paean_context_clear when you need to preserve important context ' +
|
|
67
|
+
'while reducing token usage. Good for long-running sessions or between loop iterations ' +
|
|
68
|
+
'where some state must carry forward.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
summary: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Concise summary of the conversation so far — key facts, decisions, outcomes, ' +
|
|
75
|
+
'and any state that should carry forward into the next conversation turn.',
|
|
76
|
+
},
|
|
77
|
+
reason: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Brief reason for compacting (e.g. "preserve state between loop iterations")',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ['summary'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
export const CONTEXT_TOOL_NAMES = new Set([
|
|
88
|
+
'paean_context_clear',
|
|
89
|
+
'paean_context_compact',
|
|
90
|
+
]);
|
|
91
|
+
// ============================================
|
|
92
|
+
// MCP Tool Execution
|
|
93
|
+
// ============================================
|
|
94
|
+
export async function executeContextTool(toolName, args) {
|
|
95
|
+
switch (toolName) {
|
|
96
|
+
case 'paean_context_clear': {
|
|
97
|
+
const reason = args.reason || 'Agent requested context clear';
|
|
98
|
+
contextEmitter.emit('context-action', {
|
|
99
|
+
action: 'clear',
|
|
100
|
+
reason,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
message: 'Context will be cleared after this turn completes. ' +
|
|
105
|
+
'The next message will start a fresh conversation.',
|
|
106
|
+
reason,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
case 'paean_context_compact': {
|
|
110
|
+
const summary = args.summary;
|
|
111
|
+
const reason = args.reason || 'Agent requested context compaction';
|
|
112
|
+
if (!summary) {
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
error: 'summary is required for context compaction',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
pendingCompactSummary = summary;
|
|
119
|
+
contextEmitter.emit('context-action', {
|
|
120
|
+
action: 'compact',
|
|
121
|
+
summary,
|
|
122
|
+
reason,
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
message: 'Context will be compacted after this turn completes. ' +
|
|
127
|
+
'The next conversation will start with your summary as initial context.',
|
|
128
|
+
summaryLength: summary.length,
|
|
129
|
+
reason,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
default:
|
|
133
|
+
return { success: false, error: `Unknown context tool: ${toolName}` };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=context-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-tools.js","sourceRoot":"","sources":["../../src/mcp/context-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AActC,+CAA+C;AAC/C,YAAY;AACZ,+CAA+C;AAE/C,MAAM,cAAc,GAAG,IAAI,YAAY,EAAE,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,QAA6C;IAE7C,cAAc,CAAC,E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-1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session-Scoped
|
|
2
|
+
* Session-Scoped Loop Scheduler
|
|
3
3
|
*
|
|
4
4
|
* Pushes natural-language prompts into the main agent interaction on a
|
|
5
|
-
* schedule, as if the user had typed them. This gives
|
|
5
|
+
* schedule, as if the user had typed them. This gives loop jobs full
|
|
6
6
|
* agent capabilities (tool use, reasoning, multi-step tasks) instead of
|
|
7
7
|
* being limited to simple shell commands.
|
|
8
8
|
*
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* - Cron expressions (minute hour day month weekday)
|
|
20
20
|
*/
|
|
21
21
|
import { type Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
22
|
-
export interface
|
|
22
|
+
export interface LoopJob {
|
|
23
23
|
id: string;
|
|
24
24
|
schedule: string;
|
|
25
25
|
/** Natural-language prompt injected into the agent conversation */
|
|
@@ -36,32 +36,48 @@ export interface CronJob {
|
|
|
36
36
|
} | null;
|
|
37
37
|
status: 'active' | 'paused';
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface LoopPromptEvent {
|
|
40
40
|
jobId: string;
|
|
41
41
|
prompt: string;
|
|
42
42
|
cwd?: string;
|
|
43
43
|
schedule: string;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Register a callback that fires whenever a
|
|
46
|
+
* Register a callback that fires whenever a loop job wants to inject a
|
|
47
47
|
* prompt into the main agent conversation.
|
|
48
48
|
* Returns an unsubscribe function.
|
|
49
49
|
*/
|
|
50
|
-
export declare function
|
|
50
|
+
export declare function onLoopPrompt(callback: (event: LoopPromptEvent) => void): () => void;
|
|
51
51
|
/**
|
|
52
52
|
* Register a function that the scheduler calls before injecting a prompt.
|
|
53
53
|
* If it returns `true`, the prompt is skipped for that tick.
|
|
54
54
|
*/
|
|
55
55
|
export declare function setAgentBusyChecker(checker: () => boolean): void;
|
|
56
|
-
export declare function
|
|
57
|
-
export declare const
|
|
58
|
-
export declare function
|
|
56
|
+
export declare function getLoopToolDefinitions(): Tool[];
|
|
57
|
+
export declare const LOOP_TOOL_NAMES: Set<string>;
|
|
58
|
+
export declare function executeLoopTool(toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
59
59
|
/**
|
|
60
|
-
* Get all active
|
|
60
|
+
* Get all active loop jobs count (for status display)
|
|
61
61
|
*/
|
|
62
|
-
export declare function
|
|
62
|
+
export declare function getActiveLoopCount(): number;
|
|
63
63
|
/**
|
|
64
|
-
* Remove all
|
|
64
|
+
* Remove all loop jobs (for testing or session cleanup)
|
|
65
65
|
*/
|
|
66
|
-
export declare function
|
|
67
|
-
|
|
66
|
+
export declare function clearAllLoopJobs(): void;
|
|
67
|
+
/** @deprecated Use LoopJob instead */
|
|
68
|
+
export type CronJob = LoopJob;
|
|
69
|
+
/** @deprecated Use LoopPromptEvent instead */
|
|
70
|
+
export type CronPromptEvent = LoopPromptEvent;
|
|
71
|
+
/** @deprecated Use getLoopToolDefinitions instead */
|
|
72
|
+
export declare const getCronToolDefinitions: typeof getLoopToolDefinitions;
|
|
73
|
+
/** @deprecated Use executeLoopTool instead */
|
|
74
|
+
export declare const executeCronTool: typeof executeLoopTool;
|
|
75
|
+
/** @deprecated Use LOOP_TOOL_NAMES instead */
|
|
76
|
+
export declare const CRON_TOOL_NAMES: Set<string>;
|
|
77
|
+
/** @deprecated Use onLoopPrompt instead */
|
|
78
|
+
export declare const onCronPrompt: typeof onLoopPrompt;
|
|
79
|
+
/** @deprecated Use getActiveLoopCount instead */
|
|
80
|
+
export declare const getActiveCronCount: typeof getActiveLoopCount;
|
|
81
|
+
/** @deprecated Use clearAllLoopJobs instead */
|
|
82
|
+
export declare const clearAllCronJobs: typeof clearAllLoopJobs;
|
|
83
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/mcp/loop.ts"],"names":[],"m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