open-agent-sdk 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +284 -0
- package/README.zh.md +285 -0
- package/dist/agent/agent-definition.d.ts +107 -0
- package/dist/agent/agent-definition.d.ts.map +1 -0
- package/dist/agent/agent-definition.js +90 -0
- package/dist/agent/agent-definition.js.map +1 -0
- package/dist/agent/react-loop.d.ts +117 -0
- package/dist/agent/react-loop.d.ts.map +1 -0
- package/dist/agent/react-loop.js +674 -0
- package/dist/agent/react-loop.js.map +1 -0
- package/dist/agent/subagent-runner.d.ts +67 -0
- package/dist/agent/subagent-runner.d.ts.map +1 -0
- package/dist/agent/subagent-runner.js +168 -0
- package/dist/agent/subagent-runner.js.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/inputs.d.ts +56 -0
- package/dist/hooks/inputs.d.ts.map +1 -0
- package/dist/hooks/inputs.js +150 -0
- package/dist/hooks/inputs.js.map +1 -0
- package/dist/hooks/manager.d.ts +63 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +137 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +191 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +6 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +218 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +26 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +43 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/index.d.ts +11 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +13 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +50 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +170 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/server-registry.d.ts +48 -0
- package/dist/mcp/server-registry.d.ts.map +1 -0
- package/dist/mcp/server-registry.js +121 -0
- package/dist/mcp/server-registry.js.map +1 -0
- package/dist/mcp/tool-adapter.d.ts +42 -0
- package/dist/mcp/tool-adapter.d.ts.map +1 -0
- package/dist/mcp/tool-adapter.js +89 -0
- package/dist/mcp/tool-adapter.js.map +1 -0
- package/dist/mcp/types.d.ts +74 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +21 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/permissions/index.d.ts +3 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +4 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/permissions/manager.d.ts +40 -0
- package/dist/permissions/manager.d.ts.map +1 -0
- package/dist/permissions/manager.js +115 -0
- package/dist/permissions/manager.js.map +1 -0
- package/dist/permissions/types.d.ts +124 -0
- package/dist/permissions/types.d.ts.map +1 -0
- package/dist/permissions/types.js +25 -0
- package/dist/permissions/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +18 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +126 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +85 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +36 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/google.d.ts +12 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +123 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai.d.ts +12 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +110 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/session/factory.d.ts +156 -0
- package/dist/session/factory.d.ts.map +1 -0
- package/dist/session/factory.js +311 -0
- package/dist/session/factory.js.map +1 -0
- package/dist/session/index.d.ts +8 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +7 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/session.d.ts +144 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +319 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/storage.d.ts +105 -0
- package/dist/session/storage.d.ts.map +1 -0
- package/dist/session/storage.js +148 -0
- package/dist/session/storage.js.map +1 -0
- package/dist/tools/ask-user-question.d.ts +31 -0
- package/dist/tools/ask-user-question.d.ts.map +1 -0
- package/dist/tools/ask-user-question.js +66 -0
- package/dist/tools/ask-user-question.js.map +1 -0
- package/dist/tools/bash-output.d.ts +22 -0
- package/dist/tools/bash-output.d.ts.map +1 -0
- package/dist/tools/bash-output.js +43 -0
- package/dist/tools/bash-output.js.map +1 -0
- package/dist/tools/bash.d.ts +36 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +161 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +24 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +83 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +22 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +248 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +39 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +312 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/kill-bash.d.ts +19 -0
- package/dist/tools/kill-bash.d.ts.map +1 -0
- package/dist/tools/kill-bash.js +64 -0
- package/dist/tools/kill-bash.js.map +1 -0
- package/dist/tools/read.d.ts +26 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +87 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/registry.d.ts +32 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +91 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/task-create.d.ts +22 -0
- package/dist/tools/task-create.d.ts.map +1 -0
- package/dist/tools/task-create.js +42 -0
- package/dist/tools/task-create.js.map +1 -0
- package/dist/tools/task-get.d.ts +19 -0
- package/dist/tools/task-get.d.ts.map +1 -0
- package/dist/tools/task-get.js +38 -0
- package/dist/tools/task-get.js.map +1 -0
- package/dist/tools/task-list.d.ts +18 -0
- package/dist/tools/task-list.d.ts.map +1 -0
- package/dist/tools/task-list.js +27 -0
- package/dist/tools/task-list.js.map +1 -0
- package/dist/tools/task-storage.d.ts +6 -0
- package/dist/tools/task-storage.d.ts.map +1 -0
- package/dist/tools/task-storage.js +83 -0
- package/dist/tools/task-storage.js.map +1 -0
- package/dist/tools/task-update.d.ts +28 -0
- package/dist/tools/task-update.d.ts.map +1 -0
- package/dist/tools/task-update.js +118 -0
- package/dist/tools/task-update.js.map +1 -0
- package/dist/tools/task.d.ts +80 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +99 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +21 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +124 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +20 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +127 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write.d.ts +22 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +46 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types/messages.d.ts +138 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +88 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/task.d.ts +29 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +5 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/tools.d.ts +56 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +25 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +46 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/uuid.d.ts +3 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +5 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task tool - Launch a subagent to handle specific tasks
|
|
3
|
+
* Aligned with Claude Agent SDK
|
|
4
|
+
*/
|
|
5
|
+
import { runSubagent } from '../agent/subagent-runner';
|
|
6
|
+
import { logger } from '../utils/logger';
|
|
7
|
+
// JSON Schema for Task tool parameters
|
|
8
|
+
const parameters = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
description: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Short task description (3-5 words)',
|
|
14
|
+
},
|
|
15
|
+
prompt: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Full task prompt for the subagent',
|
|
18
|
+
},
|
|
19
|
+
subagent_type: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Agent type identifier (must match a key in agents config)',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['description', 'prompt', 'subagent_type'],
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Task tool implementation
|
|
28
|
+
*/
|
|
29
|
+
export class TaskTool {
|
|
30
|
+
name = 'Task';
|
|
31
|
+
description = 'Launch a specialized subagent to handle a specific task. ' +
|
|
32
|
+
'The subagent operates independently with its own tool set and configuration. ' +
|
|
33
|
+
'Use this to delegate complex tasks like code review, testing, or exploration.';
|
|
34
|
+
parameters = parameters;
|
|
35
|
+
config;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
}
|
|
39
|
+
handler = async (input, context) => {
|
|
40
|
+
logger.debug(`[TaskTool] Executing task: ${input.description}`);
|
|
41
|
+
logger.debug(`[TaskTool] Subagent type: ${input.subagent_type}`);
|
|
42
|
+
// Validate that the subagent_type exists in agents config
|
|
43
|
+
const agentDef = this.config.agents[input.subagent_type];
|
|
44
|
+
if (!agentDef) {
|
|
45
|
+
const availableTypes = Object.keys(this.config.agents).join(', ');
|
|
46
|
+
throw new Error(`Unknown subagent_type: "${input.subagent_type}". ` +
|
|
47
|
+
`Available types: ${availableTypes || 'none configured'}`);
|
|
48
|
+
}
|
|
49
|
+
// Create subagent context
|
|
50
|
+
const subagentContext = {
|
|
51
|
+
parentContext: context,
|
|
52
|
+
parentToolRegistry: this.config.toolRegistry,
|
|
53
|
+
hookManager: this.config.hookManager,
|
|
54
|
+
parentSessionId: this.config.sessionId,
|
|
55
|
+
parentConfig: {
|
|
56
|
+
model: this.config.model,
|
|
57
|
+
maxTurns: this.config.maxTurns,
|
|
58
|
+
permissionMode: this.config.permissionMode,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
// Execute the subagent
|
|
62
|
+
const result = await runSubagent(agentDef, input.prompt, input.subagent_type, subagentContext);
|
|
63
|
+
logger.debug(`[TaskTool] Task completed: ${input.description}`);
|
|
64
|
+
logger.debug(`[TaskTool] Duration: ${result.durationMs}ms${result.costUsd !== undefined ? `, Cost: $${result.costUsd}` : ''}`);
|
|
65
|
+
return {
|
|
66
|
+
result: result.result,
|
|
67
|
+
agent_id: result.agentId,
|
|
68
|
+
usage: {
|
|
69
|
+
input_tokens: result.usage.inputTokens,
|
|
70
|
+
output_tokens: result.usage.outputTokens,
|
|
71
|
+
},
|
|
72
|
+
...(result.costUsd !== undefined && { total_cost_usd: result.costUsd }),
|
|
73
|
+
duration_ms: result.durationMs,
|
|
74
|
+
...(result.error && { error: result.error }),
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a Task tool instance
|
|
80
|
+
*/
|
|
81
|
+
export function createTaskTool(config) {
|
|
82
|
+
return new TaskTool(config);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a Task tool with agent definitions from parent config
|
|
86
|
+
* This is a convenience factory for use in ReActLoop
|
|
87
|
+
*/
|
|
88
|
+
export function createTaskToolFromConfig(agents, sessionId, model, maxTurns, permissionMode, hookManager, toolRegistry) {
|
|
89
|
+
return new TaskTool({
|
|
90
|
+
agents,
|
|
91
|
+
sessionId,
|
|
92
|
+
model,
|
|
93
|
+
maxTurns,
|
|
94
|
+
permissionMode,
|
|
95
|
+
hookManager,
|
|
96
|
+
toolRegistry,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/tools/task.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAwDzC,uCAAuC;AACvC,MAAM,UAAU,GAAe;IAC7B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,oCAAoC;SAClD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mCAAmC;SACjD;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2DAA2D;SACzE;KACF;IACD,QAAQ,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,eAAe,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,QAAQ;IACnB,IAAI,GAAG,MAAM,CAAC;IACd,WAAW,GACT,2DAA2D;QAC3D,+EAA+E;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../types/tools.js';
|
|
2
|
+
export interface WebFetchInput {
|
|
3
|
+
url: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WebFetchOutput {
|
|
7
|
+
response?: string;
|
|
8
|
+
url: string;
|
|
9
|
+
final_url?: string;
|
|
10
|
+
status_code?: number;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class WebFetchTool implements Tool<WebFetchInput, WebFetchOutput> {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: JSONSchema;
|
|
17
|
+
handler: (input: WebFetchInput, context: ToolContext) => Promise<WebFetchOutput>;
|
|
18
|
+
private extractContent;
|
|
19
|
+
}
|
|
20
|
+
export declare const webFetchTool: WebFetchTool;
|
|
21
|
+
//# sourceMappingURL=web-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-fetch.d.ts","sourceRoot":"","sources":["../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIvE,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAiBD,qBAAa,YAAa,YAAW,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC;IACtE,IAAI,SAAc;IAClB,WAAW,SAA4F;IACvG,UAAU,aAAc;IAExB,OAAO,GACL,OAAO,aAAa,EACpB,SAAS,WAAW,KACnB,OAAO,CAAC,cAAc,CAAC,CA6ExB;IAEF,OAAO,CAAC,cAAc;CA6BvB;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Readability } from '@mozilla/readability';
|
|
2
|
+
import { JSDOM } from 'jsdom';
|
|
3
|
+
import TurndownService from 'turndown';
|
|
4
|
+
import { createUserMessage } from '../types/messages.js';
|
|
5
|
+
import { generateUUID } from '../utils/uuid.js';
|
|
6
|
+
const parameters = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
url: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'The URL to fetch (HTTP will be auto-upgraded to HTTPS)',
|
|
12
|
+
},
|
|
13
|
+
prompt: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'The prompt to process the fetched content with',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ['url', 'prompt'],
|
|
19
|
+
};
|
|
20
|
+
export class WebFetchTool {
|
|
21
|
+
name = 'WebFetch';
|
|
22
|
+
description = 'Fetch a webpage and analyze its content using an LLM. Returns the LLM analysis result.';
|
|
23
|
+
parameters = parameters;
|
|
24
|
+
handler = async (input, context) => {
|
|
25
|
+
// Validate URL
|
|
26
|
+
let url;
|
|
27
|
+
try {
|
|
28
|
+
url = new URL(input.url);
|
|
29
|
+
// Auto-upgrade HTTP to HTTPS
|
|
30
|
+
if (url.protocol === 'http:') {
|
|
31
|
+
url.protocol = 'https:';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return {
|
|
36
|
+
url: input.url,
|
|
37
|
+
error: 'Invalid URL provided',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Check for provider
|
|
41
|
+
if (!context.provider) {
|
|
42
|
+
return {
|
|
43
|
+
url: input.url,
|
|
44
|
+
error: 'No provider available for LLM analysis. WebFetch requires a provider to be configured.',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
// Fetch the webpage
|
|
49
|
+
const fetchOptions = {
|
|
50
|
+
signal: context.abortController?.signal,
|
|
51
|
+
headers: {
|
|
52
|
+
'User-Agent': 'Mozilla/5.0 (compatible; OpenAgentSDK/1.0)',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const response = await fetch(url.toString(), fetchOptions);
|
|
56
|
+
const finalUrl = response.url;
|
|
57
|
+
const statusCode = response.status;
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
return {
|
|
60
|
+
url: input.url,
|
|
61
|
+
final_url: finalUrl,
|
|
62
|
+
status_code: statusCode,
|
|
63
|
+
error: `HTTP error ${statusCode}: ${response.statusText}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const html = await response.text();
|
|
67
|
+
// Extract readable content
|
|
68
|
+
const markdown = this.extractContent(html, finalUrl);
|
|
69
|
+
// Analyze with LLM using the chat method
|
|
70
|
+
const analysisPrompt = `${input.prompt}\n\nContent from ${finalUrl}:\n\n${markdown}`;
|
|
71
|
+
const message = createUserMessage(analysisPrompt, 'webfetch-session', generateUUID(), null);
|
|
72
|
+
const chunks = [];
|
|
73
|
+
for await (const chunk of context.provider.chat([message], undefined, context.abortController?.signal)) {
|
|
74
|
+
if (chunk.type === 'content' && chunk.delta) {
|
|
75
|
+
chunks.push(chunk.delta);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const response_text = chunks.join('');
|
|
79
|
+
return {
|
|
80
|
+
response: response_text,
|
|
81
|
+
url: input.url,
|
|
82
|
+
final_url: finalUrl,
|
|
83
|
+
status_code: statusCode,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
url: input.url,
|
|
89
|
+
error: error instanceof Error ? error.message : 'Failed to fetch or analyze webpage',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
extractContent(html, url) {
|
|
94
|
+
try {
|
|
95
|
+
const dom = new JSDOM(html, { url });
|
|
96
|
+
const reader = new Readability(dom.window.document);
|
|
97
|
+
const article = reader.parse();
|
|
98
|
+
if (article && article.content) {
|
|
99
|
+
// Convert to markdown
|
|
100
|
+
const turndownService = new TurndownService({
|
|
101
|
+
headingStyle: 'atx',
|
|
102
|
+
codeBlockStyle: 'fenced',
|
|
103
|
+
});
|
|
104
|
+
return turndownService.turndown(article.content);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Fall through to raw HTML conversion
|
|
109
|
+
}
|
|
110
|
+
// Fallback: convert entire body to markdown
|
|
111
|
+
try {
|
|
112
|
+
const dom = new JSDOM(html);
|
|
113
|
+
const turndownService = new TurndownService();
|
|
114
|
+
const body = dom.window.document.body;
|
|
115
|
+
return body ? turndownService.turndown(body.innerHTML) : '';
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Final fallback: return plain text
|
|
119
|
+
return html.replace(/<[^>]*>/g, '');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export const webFetchTool = new WebFetchTool();
|
|
124
|
+
//# sourceMappingURL=web-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-fetch.js","sourceRoot":"","sources":["../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,eAAe,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAehD,MAAM,UAAU,GAAe;IAC7B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wDAAwD;SACtE;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WA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E,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Tool, ToolContext, JSONSchema } from '../types/tools.js';
|
|
2
|
+
export interface WebSearchInput {
|
|
3
|
+
query: string;
|
|
4
|
+
numResults?: number;
|
|
5
|
+
type?: 'auto' | 'fast' | 'deep';
|
|
6
|
+
livecrawl?: 'fallback' | 'preferred';
|
|
7
|
+
}
|
|
8
|
+
export interface WebSearchOutput {
|
|
9
|
+
content: string;
|
|
10
|
+
query: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class WebSearchTool implements Tool<WebSearchInput, WebSearchOutput> {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: JSONSchema;
|
|
17
|
+
handler: (input: WebSearchInput, context: ToolContext) => Promise<WebSearchOutput>;
|
|
18
|
+
}
|
|
19
|
+
export declare const webSearchTool: WebSearchTool;
|
|
20
|
+
//# sourceMappingURL=web-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoCD,qBAAa,aAAc,YAAW,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC;IACzE,IAAI,SAAe;IACnB,WAAW,SAAqG;IAChH,UAAU,aAAc;IAExB,OAAO,GACL,OAAO,cAAc,EACrB,SAAS,WAAW,KACnB,OAAO,CAAC,eAAe,CAAC,CAgGzB;CACH;AAED,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const API_CONFIG = {
|
|
2
|
+
BASE_URL: 'https://mcp.exa.ai',
|
|
3
|
+
ENDPOINTS: {
|
|
4
|
+
SEARCH: '/mcp',
|
|
5
|
+
},
|
|
6
|
+
DEFAULT_NUM_RESULTS: 8,
|
|
7
|
+
TIMEOUT_MS: 25000,
|
|
8
|
+
};
|
|
9
|
+
const parameters = {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
query: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'The search query',
|
|
15
|
+
},
|
|
16
|
+
numResults: {
|
|
17
|
+
type: 'number',
|
|
18
|
+
description: 'Number of search results to return (default: 8)',
|
|
19
|
+
},
|
|
20
|
+
type: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
enum: ['auto', 'fast', 'deep'],
|
|
23
|
+
description: "Search type - 'auto': balanced (default), 'fast': quick, 'deep': comprehensive",
|
|
24
|
+
},
|
|
25
|
+
livecrawl: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: ['fallback', 'preferred'],
|
|
28
|
+
description: "Live crawl mode - 'fallback': use as backup, 'preferred': prioritize (default: 'fallback')",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['query'],
|
|
32
|
+
};
|
|
33
|
+
export class WebSearchTool {
|
|
34
|
+
name = 'WebSearch';
|
|
35
|
+
description = 'Search the web for information. Returns formatted search results optimized for LLM consumption.';
|
|
36
|
+
parameters = parameters;
|
|
37
|
+
handler = async (input, context) => {
|
|
38
|
+
// Validate query
|
|
39
|
+
if (!input.query || input.query.trim().length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
content: '',
|
|
42
|
+
query: input.query || '',
|
|
43
|
+
error: 'Query is required',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const searchRequest = {
|
|
47
|
+
jsonrpc: '2.0',
|
|
48
|
+
id: 1,
|
|
49
|
+
method: 'tools/call',
|
|
50
|
+
params: {
|
|
51
|
+
name: 'web_search_exa',
|
|
52
|
+
arguments: {
|
|
53
|
+
query: input.query,
|
|
54
|
+
type: input.type || 'auto',
|
|
55
|
+
numResults: input.numResults || API_CONFIG.DEFAULT_NUM_RESULTS,
|
|
56
|
+
livecrawl: input.livecrawl || 'fallback',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const controller = new AbortController();
|
|
61
|
+
const timeoutId = setTimeout(() => controller.abort(), API_CONFIG.TIMEOUT_MS);
|
|
62
|
+
try {
|
|
63
|
+
const abortSignals = [controller.signal];
|
|
64
|
+
if (context.abortController?.signal) {
|
|
65
|
+
abortSignals.push(context.abortController.signal);
|
|
66
|
+
}
|
|
67
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.SEARCH}`, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
accept: 'application/json, text/event-stream',
|
|
71
|
+
'content-type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify(searchRequest),
|
|
74
|
+
signal: AbortSignal.any(abortSignals),
|
|
75
|
+
});
|
|
76
|
+
clearTimeout(timeoutId);
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const errorText = await response.text();
|
|
79
|
+
return {
|
|
80
|
+
content: '',
|
|
81
|
+
query: input.query,
|
|
82
|
+
error: `Search error (${response.status}): ${errorText}`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const responseText = await response.text();
|
|
86
|
+
// Parse SSE response
|
|
87
|
+
const lines = responseText.split('\n');
|
|
88
|
+
for (const line of lines) {
|
|
89
|
+
if (line.startsWith('data: ')) {
|
|
90
|
+
try {
|
|
91
|
+
const data = JSON.parse(line.substring(6));
|
|
92
|
+
if (data.result?.content?.length > 0) {
|
|
93
|
+
return {
|
|
94
|
+
content: data.result.content[0].text,
|
|
95
|
+
query: input.query,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// Skip invalid JSON lines
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
content: 'No search results found. Please try a different query.',
|
|
106
|
+
query: input.query,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
clearTimeout(timeoutId);
|
|
111
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
112
|
+
return {
|
|
113
|
+
content: '',
|
|
114
|
+
query: input.query,
|
|
115
|
+
error: 'Search request timed out after 25 seconds',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
content: '',
|
|
120
|
+
query: input.query,
|
|
121
|
+
error: error instanceof Error ? error.message : 'Search failed',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export const webSearchTool = new WebSearchTool();
|
|
127
|
+
//# sourceMappingURL=web-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,GAAG;IACjB,QAAQ,EAAE,oBAAoB;IAC9B,SAAS,EAAE;QACT,MAAM,EAAE,MAAM;KACf;IACD,mBAAmB,EAAE,CAAC;IACtB,UAAU,EAAE,KAAK;CACT,CAAC;AAEX,MAAM,UAAU,GAAe;IAC7B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,kBAAkB;SAChC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iDAAiD;SAC/D;Q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AI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC3C,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;4BACrC,OAAO;gCACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;gCACpC,KAAK,EAAE,KAAK,CAAC,KAAK;6BACnB,CAAC;wBACJ,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC;wBACP,0BAA0B;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,wDAAwD;gBACjE,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,SAAS,CAAC,CAAC;YAExB,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1D,OAAO;oBACL,OAAO,EAAE,EAAE;oBACX,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,KAAK,EAAE,2CAA2C;iBACnD,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;CACH;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write tool - Write content to files, creating parent directories as needed
|
|
3
|
+
*/
|
|
4
|
+
import type { Tool, ToolContext, JSONSchema } from '../types/tools';
|
|
5
|
+
export interface WriteInput {
|
|
6
|
+
file_path: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
export interface WriteOutput {
|
|
10
|
+
message: string;
|
|
11
|
+
file_path: string;
|
|
12
|
+
bytes_written: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class WriteTool implements Tool<WriteInput, WriteOutput> {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
parameters: JSONSchema;
|
|
19
|
+
handler: (input: WriteInput, context: ToolContext) => Promise<WriteOutput>;
|
|
20
|
+
}
|
|
21
|
+
export declare const writeTool: WriteTool;
|
|
22
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpE,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAiBD,qBAAa,SAAU,YAAW,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IAC7D,IAAI,SAAW;IACf,WAAW,SACuF;IAClG,UAAU,aAAc;IAExB,OAAO,GACL,OAAO,UAAU,EACjB,SAAS,WAAW,KACnB,OAAO,CAAC,WAAW,CAAC,CAqBrB;CACH;AAGD,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write tool - Write content to files, creating parent directories as needed
|
|
3
|
+
*/
|
|
4
|
+
import { writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
5
|
+
import { resolve, dirname } from 'path';
|
|
6
|
+
const parameters = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
file_path: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'Absolute path to the file to write',
|
|
12
|
+
},
|
|
13
|
+
content: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'Content to write to the file',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ['file_path', 'content'],
|
|
19
|
+
};
|
|
20
|
+
export class WriteTool {
|
|
21
|
+
name = 'Write';
|
|
22
|
+
description = 'Write content to a file. Creates parent directories automatically. Overwrites existing files.';
|
|
23
|
+
parameters = parameters;
|
|
24
|
+
handler = async (input, context) => {
|
|
25
|
+
const filePath = resolve(context.cwd, input.file_path);
|
|
26
|
+
const existed = existsSync(filePath);
|
|
27
|
+
// Create parent directories
|
|
28
|
+
const parentDir = dirname(filePath);
|
|
29
|
+
if (!existsSync(parentDir)) {
|
|
30
|
+
mkdirSync(parentDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
// Write file
|
|
33
|
+
const content = input.content;
|
|
34
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
35
|
+
return {
|
|
36
|
+
message: existed
|
|
37
|
+
? `File "${input.file_path}" overwritten successfully`
|
|
38
|
+
: `File "${input.file_path}" created successfully`,
|
|
39
|
+
file_path: input.file_path,
|
|
40
|
+
bytes_written: Buffer.byteLength(content, 'utf-8'),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Export singleton instance
|
|
45
|
+
export const writeTool = new WriteTool();
|
|
46
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC1D,OA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AAC;IACJ,CAAC,CAAC;CACH;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message types for Open Agent SDK
|
|
3
|
+
* Defines the communication protocol between user, agent, and tools
|
|
4
|
+
* Aligned with Claude Agent SDK V2 API
|
|
5
|
+
*/
|
|
6
|
+
import type { PermissionMode } from '../permissions/types';
|
|
7
|
+
/** UUID type for message identification */
|
|
8
|
+
export type UUID = string;
|
|
9
|
+
/** Base message interface */
|
|
10
|
+
export interface BaseMessage {
|
|
11
|
+
type: string;
|
|
12
|
+
uuid: UUID;
|
|
13
|
+
session_id: string;
|
|
14
|
+
}
|
|
15
|
+
/** Content block for assistant message */
|
|
16
|
+
export type AssistantContentBlock = {
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'tool_use';
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
input: unknown;
|
|
24
|
+
};
|
|
25
|
+
/** Nested message structure for user messages */
|
|
26
|
+
export interface UserMessageContent {
|
|
27
|
+
role: 'user';
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
/** Nested message structure for assistant messages */
|
|
31
|
+
export interface AssistantMessageContent {
|
|
32
|
+
role: 'assistant';
|
|
33
|
+
content: AssistantContentBlock[];
|
|
34
|
+
tool_calls?: ToolCall[];
|
|
35
|
+
}
|
|
36
|
+
/** User message - input from the user */
|
|
37
|
+
export interface SDKUserMessage extends BaseMessage {
|
|
38
|
+
type: 'user';
|
|
39
|
+
message: UserMessageContent;
|
|
40
|
+
parent_tool_use_id: string | null;
|
|
41
|
+
}
|
|
42
|
+
/** Tool call from assistant */
|
|
43
|
+
export interface ToolCall {
|
|
44
|
+
id: string;
|
|
45
|
+
type: 'function';
|
|
46
|
+
function: {
|
|
47
|
+
name: string;
|
|
48
|
+
arguments: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Assistant message - response from the LLM */
|
|
52
|
+
export interface SDKAssistantMessage extends BaseMessage {
|
|
53
|
+
type: 'assistant';
|
|
54
|
+
message: AssistantMessageContent;
|
|
55
|
+
parent_tool_use_id: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** Tool result message - output from tool execution */
|
|
58
|
+
export interface SDKToolResultMessage extends BaseMessage {
|
|
59
|
+
type: 'tool_result';
|
|
60
|
+
tool_use_id: string;
|
|
61
|
+
tool_name: string;
|
|
62
|
+
result: unknown;
|
|
63
|
+
is_error: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** API key source for the session */
|
|
66
|
+
export type ApiKeySource = 'env' | 'keychain' | 'custom';
|
|
67
|
+
/** MCP server info in system message */
|
|
68
|
+
export interface McpServerInfo {
|
|
69
|
+
name: string;
|
|
70
|
+
status: string;
|
|
71
|
+
}
|
|
72
|
+
/** System message - initialization metadata (aligned with Claude Agent SDK) */
|
|
73
|
+
export interface SDKSystemMessage extends BaseMessage {
|
|
74
|
+
type: 'system';
|
|
75
|
+
subtype: 'init';
|
|
76
|
+
uuid: UUID;
|
|
77
|
+
session_id: string;
|
|
78
|
+
model: string;
|
|
79
|
+
provider: string;
|
|
80
|
+
tools: string[];
|
|
81
|
+
cwd: string;
|
|
82
|
+
apiKeySource?: ApiKeySource;
|
|
83
|
+
mcp_servers?: McpServerInfo[];
|
|
84
|
+
permissionMode?: PermissionMode;
|
|
85
|
+
slash_commands?: string[];
|
|
86
|
+
output_style?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Compact boundary message - marks a conversation compaction point */
|
|
89
|
+
export interface SDKCompactBoundaryMessage extends BaseMessage {
|
|
90
|
+
type: 'system';
|
|
91
|
+
subtype: 'compact_boundary';
|
|
92
|
+
uuid: UUID;
|
|
93
|
+
session_id: string;
|
|
94
|
+
compact_metadata: {
|
|
95
|
+
trigger: 'manual' | 'auto';
|
|
96
|
+
pre_tokens: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Result message - final output of the agent */
|
|
100
|
+
export interface SDKResultMessage extends BaseMessage {
|
|
101
|
+
type: 'result';
|
|
102
|
+
subtype: 'success' | 'error_max_turns' | 'error_during_execution';
|
|
103
|
+
duration_ms: number;
|
|
104
|
+
duration_api_ms: number;
|
|
105
|
+
is_error: boolean;
|
|
106
|
+
num_turns: number;
|
|
107
|
+
result: string;
|
|
108
|
+
usage: {
|
|
109
|
+
input_tokens: number;
|
|
110
|
+
output_tokens: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Union type for all SDK messages */
|
|
114
|
+
export type SDKMessage = SDKUserMessage | SDKAssistantMessage | SDKToolResultMessage | SDKSystemMessage | SDKCompactBoundaryMessage | SDKResultMessage;
|
|
115
|
+
/** Helper function to create user message */
|
|
116
|
+
export declare function createUserMessage(content: string, sessionId: string, uuid: UUID, parentToolUseId?: string | null): SDKUserMessage;
|
|
117
|
+
/** Options for creating system message */
|
|
118
|
+
export interface CreateSystemMessageOptions {
|
|
119
|
+
apiKeySource?: ApiKeySource;
|
|
120
|
+
mcp_servers?: McpServerInfo[];
|
|
121
|
+
permissionMode?: PermissionMode;
|
|
122
|
+
slash_commands?: string[];
|
|
123
|
+
output_style?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Helper function to create system message (aligned with Claude Agent SDK) */
|
|
126
|
+
export declare function createSystemMessage(model: string, provider: string, tools: string[], cwd: string, sessionId: string, uuid: UUID, options?: CreateSystemMessageOptions): SDKSystemMessage;
|
|
127
|
+
/** Helper function to create assistant message */
|
|
128
|
+
export declare function createAssistantMessage(contentBlocks: AssistantContentBlock[], sessionId: string, uuid: UUID, parentToolUseId?: string | null, toolCalls?: ToolCall[]): SDKAssistantMessage;
|
|
129
|
+
/** Helper function to create tool result message */
|
|
130
|
+
export declare function createToolResultMessage(toolUseId: string, toolName: string, result: unknown, isError: boolean, sessionId: string, uuid: UUID): SDKToolResultMessage;
|
|
131
|
+
/** Helper function to create result message */
|
|
132
|
+
export declare function createResultMessage(subtype: 'success' | 'error_max_turns' | 'error_during_execution', result: string, durationMs: number, durationApiMs: number, numTurns: number, usage: {
|
|
133
|
+
input_tokens: number;
|
|
134
|
+
output_tokens: number;
|
|
135
|
+
}, sessionId: string, uuid: UUID): SDKResultMessage;
|
|
136
|
+
/** Helper function to create compact boundary message */
|
|
137
|
+
export declare function createCompactBoundaryMessage(sessionId: string, uuid: UUID, trigger: 'manual' | 'auto', preTokens: number): SDKCompactBoundaryMessage;
|
|
138
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/types/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,2CAA2C;AAC3C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,6BAA6B;AAC7B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnE,iDAAiD;AACjD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sDAAsD;AACtD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,UAAU,CAA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