@tinyweb_dev/agent-framework-agent 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +116 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/attachments.d.ts +41 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/bus/bus.d.ts +46 -0
- package/dist/bus/bus.d.ts.map +1 -0
- package/dist/bus/index.d.ts +2 -0
- package/dist/bus/index.d.ts.map +1 -0
- package/dist/define-tool.d.ts +13 -0
- package/dist/define-tool.d.ts.map +1 -0
- package/dist/events.d.ts +136 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/http-handlers.cjs +253 -0
- package/dist/http-handlers.cjs.map +1 -0
- package/dist/http-handlers.d.ts +49 -0
- package/dist/http-handlers.d.ts.map +1 -0
- package/dist/http-handlers.js +251 -0
- package/dist/http-handlers.js.map +1 -0
- package/dist/index.cjs +2073 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2015 -0
- package/dist/index.js.map +1 -0
- package/dist/loop-guard.d.ts +42 -0
- package/dist/loop-guard.d.ts.map +1 -0
- package/dist/mcp/client.d.ts +25 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/index.cjs +66 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/{src/mcp/index.ts → dist/mcp/index.d.ts} +2 -1
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +63 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/permission.d.ts +26 -0
- package/dist/permission.d.ts.map +1 -0
- package/dist/plugin/apply.d.ts +12 -0
- package/dist/plugin/apply.d.ts.map +1 -0
- package/dist/plugin/index.cjs +63 -0
- package/dist/plugin/index.cjs.map +1 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +52 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/loader.d.ts +3 -0
- package/dist/plugin/loader.d.ts.map +1 -0
- package/dist/plugin/types.d.ts +98 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/prompt/index.d.ts +51 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/objective.d.ts +29 -0
- package/dist/prompt/objective.d.ts.map +1 -0
- package/dist/prompt/response-style.d.ts +19 -0
- package/dist/prompt/response-style.d.ts.map +1 -0
- package/dist/prompt/tool-use-guidelines.d.ts +22 -0
- package/dist/prompt/tool-use-guidelines.d.ts.map +1 -0
- package/dist/prompt/tool-use.d.ts +12 -0
- package/dist/prompt/tool-use.d.ts.map +1 -0
- package/dist/runtime.d.ts +7 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/session/adapter.d.ts +40 -0
- package/dist/session/adapter.d.ts.map +1 -0
- package/dist/session/compaction.d.ts +37 -0
- package/dist/session/compaction.d.ts.map +1 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/memory.cjs +130 -0
- package/dist/session/memory.cjs.map +1 -0
- package/dist/session/memory.d.ts +3 -0
- package/dist/session/memory.d.ts.map +1 -0
- package/dist/session/memory.js +128 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/overflow.d.ts +19 -0
- package/dist/session/overflow.d.ts.map +1 -0
- package/dist/session/postgres.cjs +245 -0
- package/dist/session/postgres.cjs.map +1 -0
- package/dist/session/postgres.d.ts +10 -0
- package/dist/session/postgres.d.ts.map +1 -0
- package/dist/session/postgres.js +243 -0
- package/dist/session/postgres.js.map +1 -0
- package/dist/session/processor.d.ts +52 -0
- package/dist/session/processor.d.ts.map +1 -0
- package/dist/session/replay.d.ts +4 -0
- package/dist/session/replay.d.ts.map +1 -0
- package/dist/session/schema.d.ts +104 -0
- package/dist/session/schema.d.ts.map +1 -0
- package/dist/session/sqlite.cjs +236 -0
- package/dist/session/sqlite.cjs.map +1 -0
- package/dist/session/sqlite.d.ts +3 -0
- package/dist/session/sqlite.d.ts.map +1 -0
- package/dist/session/sqlite.js +234 -0
- package/dist/session/sqlite.js.map +1 -0
- package/dist/session-api.cjs +56 -0
- package/dist/session-api.cjs.map +1 -0
- package/dist/session-api.d.ts +36 -0
- package/dist/session-api.d.ts.map +1 -0
- package/dist/session-api.js +54 -0
- package/dist/session-api.js.map +1 -0
- package/dist/skill/index.cjs +81 -0
- package/dist/skill/index.cjs.map +1 -0
- package/dist/skill/index.d.ts +10 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +78 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/sse-handler.d.ts +27 -0
- package/dist/sse-handler.d.ts.map +1 -0
- package/dist/transcript.d.ts +81 -0
- package/dist/transcript.d.ts.map +1 -0
- package/package.json +54 -19
- package/src/agent.ts +0 -470
- package/src/attachments.ts +0 -155
- package/src/bus/bus.ts +0 -89
- package/src/bus/index.ts +0 -1
- package/src/define-tool.ts +0 -41
- package/src/events.ts +0 -186
- package/src/http-handlers.ts +0 -251
- package/src/index.ts +0 -128
- package/src/loop-guard.ts +0 -99
- package/src/mcp/client.ts +0 -129
- package/src/permission.ts +0 -114
- package/src/plugin/apply.ts +0 -89
- package/src/plugin/index.ts +0 -3
- package/src/plugin/loader.ts +0 -42
- package/src/plugin/types.ts +0 -134
- package/src/prompt/index.ts +0 -90
- package/src/prompt/objective.ts +0 -104
- package/src/prompt/response-style.ts +0 -59
- package/src/prompt/tool-use-guidelines.ts +0 -57
- package/src/prompt/tool-use.ts +0 -27
- package/src/runtime.ts +0 -22
- package/src/session/adapter.ts +0 -46
- package/src/session/compaction.ts +0 -160
- package/src/session/index.ts +0 -18
- package/src/session/memory.ts +0 -169
- package/src/session/overflow.ts +0 -50
- package/src/session/postgres.ts +0 -355
- package/src/session/processor.ts +0 -865
- package/src/session/replay.ts +0 -151
- package/src/session/schema.ts +0 -156
- package/src/session/sqlite.ts +0 -309
- package/src/session-api.ts +0 -103
- package/src/skill/index.ts +0 -113
- package/src/sse-handler.ts +0 -67
- package/src/transcript.ts +0 -126
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ExecutableTools } from "@tinyweb_dev/agent-framework-llm";
|
|
2
|
+
/**
|
|
3
|
+
* Loop-guard configuration. The guard wraps each tool in an
|
|
4
|
+
* `ExecutableTools` record so that identical `(toolName, JSON.stringify(args))`
|
|
5
|
+
* invocations short-circuit with a `ToolFailure` instead of running the
|
|
6
|
+
* tool body. This stops a runaway model that keeps re-invoking the same
|
|
7
|
+
* tool with the same args within a single agent turn (see
|
|
8
|
+
* [`.manager/bugs/0002-next-chat-agent-tool-loop-and-missing-stop-button.md`](../../../.manager/bugs/0002-next-chat-agent-tool-loop-and-missing-stop-button.md)).
|
|
9
|
+
*
|
|
10
|
+
* Scope:
|
|
11
|
+
* • The seen-set is **per `applyLoopGuard()` invocation**. Because
|
|
12
|
+
* `buildTools` runs once per `defineAgent`, and the typical pattern
|
|
13
|
+
* is one `defineAgent` per chat turn (e.g.
|
|
14
|
+
* [`examples/next-chat/lib/agent.ts`](../../../examples/next-chat/lib/agent.ts)),
|
|
15
|
+
* the seen-set naturally resets each turn.
|
|
16
|
+
* • For long-lived agents that span multiple turns (e.g. an HTTP server
|
|
17
|
+
* building the agent once at boot), the guard is currently
|
|
18
|
+
* conservative — duplicate calls across turns will also be blocked.
|
|
19
|
+
* If that becomes a problem we can add a turn-scoped reset hook.
|
|
20
|
+
*
|
|
21
|
+
* Behaviour on trip:
|
|
22
|
+
* • Returns `ToolFailure` with a clear message instructing the LLM to
|
|
23
|
+
* stop calling the tool. The processor surfaces this as a regular
|
|
24
|
+
* `tool-error` event so the UI renders an inline error pill (no
|
|
25
|
+
* stream crash).
|
|
26
|
+
*/
|
|
27
|
+
export type LoopGuardConfig = {
|
|
28
|
+
readonly enabled: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Wrap every tool in `tools` with the loop guard. Returns the original
|
|
32
|
+
* record unchanged when `config.enabled === false`.
|
|
33
|
+
*
|
|
34
|
+
* Typical wiring (inside the agent package — see [`agent.ts`](agent.ts:1)):
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const guarded = applyLoopGuard(merged, { enabled: config.loopGuard !== false })
|
|
38
|
+
* return applyPermission(guarded, config.permission, config.askHandler)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const applyLoopGuard: (tools: ExecutableTools, config?: LoopGuardConfig) => ExecutableTools;
|
|
42
|
+
//# sourceMappingURL=loop-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-guard.d.ts","sourceRoot":"","sources":["../src/loop-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9G;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B,CAAA;AA4CD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,eAAe,EACtB,SAAQ,eAAgC,KACvC,eAUF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Tool } from "@tinyweb_dev/agent-framework-llm";
|
|
2
|
+
export type McpStdioConfig = {
|
|
3
|
+
readonly type: "stdio";
|
|
4
|
+
readonly command: string;
|
|
5
|
+
readonly args?: string[];
|
|
6
|
+
readonly env?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export type McpHttpConfig = {
|
|
9
|
+
readonly type: "http";
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly headers?: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export type McpServerConfig = McpStdioConfig | McpHttpConfig;
|
|
14
|
+
export type McpClient = {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly tools: Record<string, Tool.AnyExecutableTool>;
|
|
17
|
+
readonly disconnect: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export declare function connectMcp(name: string, config: McpServerConfig): Promise<McpClient>;
|
|
20
|
+
export type McpConfig = Record<string, McpServerConfig>;
|
|
21
|
+
export declare function connectAllMcp(configs: McpConfig): Promise<{
|
|
22
|
+
clients: McpClient[];
|
|
23
|
+
tools: Record<string, Tool.AnyExecutableTool>;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAe,MAAM,8BAA8B,CAAA;AAMhE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,aAAa,CAAA;AAM5D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACzC,CAAA;AAwDD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAsB1F;AAMD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAEvD,wBAAsB,aAAa,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;CAAE,CAAC,CAOxI"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
4
|
+
var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
|
|
5
|
+
var streamableHttp_js = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
|
|
6
|
+
var effect = require('effect');
|
|
7
|
+
var llm = require('@tinyweb_dev/agent-framework-llm');
|
|
8
|
+
|
|
9
|
+
// src/mcp/client.ts
|
|
10
|
+
function asJsonSchema(inputSchema) {
|
|
11
|
+
if (inputSchema && typeof inputSchema === "object" && !Array.isArray(inputSchema)) {
|
|
12
|
+
return inputSchema;
|
|
13
|
+
}
|
|
14
|
+
return { type: "object", properties: {} };
|
|
15
|
+
}
|
|
16
|
+
function buildTool(serverName, mcpTool, client) {
|
|
17
|
+
const toolName = `${serverName}__${mcpTool.name}`;
|
|
18
|
+
const jsonSchema = asJsonSchema(mcpTool.inputSchema);
|
|
19
|
+
return llm.Tool.make({
|
|
20
|
+
description: mcpTool.description ?? toolName,
|
|
21
|
+
// Dynamic mode — preserves MCP inputSchema on the wire for the LLM.
|
|
22
|
+
jsonSchema,
|
|
23
|
+
execute: (input) => effect.Effect.tryPromise({
|
|
24
|
+
try: async () => {
|
|
25
|
+
const args = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
26
|
+
const result = await client.callTool({ name: mcpTool.name, arguments: args });
|
|
27
|
+
const parts = result.content ?? [];
|
|
28
|
+
const text = parts.map((c) => c.text ?? "").join("\n");
|
|
29
|
+
if (result.isError) {
|
|
30
|
+
throw new Error(text || "MCP tool returned error");
|
|
31
|
+
}
|
|
32
|
+
return text;
|
|
33
|
+
},
|
|
34
|
+
catch: (err) => new llm.ToolFailure({ message: String(err) })
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function connectMcp(name, config) {
|
|
39
|
+
const client = new index_js.Client({ name: "tinyweb-agent", version: "0.0.1" });
|
|
40
|
+
const transport = config.type === "stdio" ? new stdio_js.StdioClientTransport({ command: config.command, args: config.args, env: config.env }) : new streamableHttp_js.StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: config.headers ?? {} } });
|
|
41
|
+
await client.connect(transport);
|
|
42
|
+
const listResult = await client.listTools();
|
|
43
|
+
const tools = {};
|
|
44
|
+
for (const mcpTool of listResult.tools) {
|
|
45
|
+
const namespaced = `${name}__${mcpTool.name}`;
|
|
46
|
+
tools[namespaced] = buildTool(name, mcpTool, client);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
name,
|
|
50
|
+
tools,
|
|
51
|
+
disconnect: () => client.close()
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function connectAllMcp(configs) {
|
|
55
|
+
const clients = await Promise.all(Object.entries(configs).map(([name, config]) => connectMcp(name, config)));
|
|
56
|
+
const tools = {};
|
|
57
|
+
for (const mcp of clients) {
|
|
58
|
+
Object.assign(tools, mcp.tools);
|
|
59
|
+
}
|
|
60
|
+
return { clients, tools };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.connectAllMcp = connectAllMcp;
|
|
64
|
+
exports.connectMcp = connectMcp;
|
|
65
|
+
//# sourceMappingURL=index.cjs.map
|
|
66
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
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,KAAA;AAAA,IACA,UAAA,EAAY,MAAM,MAAA,CAAO,KAAA;AAAM,GACjC;AACF;AAQA,eAAsB,cAAc,OAAA,EAAsG;AACxI,EAAA,MAAM,UAAU,MAAM,OAAA,CAAQ,IAAI,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,MAAM,MAAM,CAAA,KAAM,WAAW,IAAA,EAAM,MAAM,CAAC,CAAC,CAAA;AAC3G,EAAA,MAAM,QAAgD,EAAC;AACvD,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,GAAA,CAAI,KAAK,CAAA;AAAA,EAChC;AACA,EAAA,OAAO,EAAE,SAAS,KAAA,EAAM;AAC1B","file":"index.cjs","sourcesContent":["// Adapted from opencode@v1.14.48 packages/opencode/src/mcp/\n\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\"\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\"\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\"\nimport { Effect } from \"effect\"\nimport { Tool, ToolFailure } from \"@tinyweb_dev/agent-framework-llm\"\n\n// ---------------------------------------------------------------------------\n// Config types\n// ---------------------------------------------------------------------------\n\nexport type McpStdioConfig = {\n readonly type: \"stdio\"\n readonly command: string\n readonly args?: string[]\n readonly env?: Record<string, string>\n}\n\nexport type McpHttpConfig = {\n readonly type: \"http\"\n readonly url: string\n readonly headers?: Record<string, string>\n}\n\nexport type McpServerConfig = McpStdioConfig | McpHttpConfig\n\n// ---------------------------------------------------------------------------\n// McpClient — holds connected client + tools\n// ---------------------------------------------------------------------------\n\nexport type McpClient = {\n readonly name: string\n readonly tools: Record<string, Tool.AnyExecutableTool>\n readonly disconnect: () => Promise<void>\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * MCP tools ship a real JSON Schema (`inputSchema`). We must pass it through\n * `Tool.make({ jsonSchema })` so the LLM sees required fields (e.g. Perplexity\n * `messages[]` / `query`). Using a generic Record schema loses that shape and\n * the model invents empty `{}` args → server-side validation errors.\n */\nfunction asJsonSchema(inputSchema: unknown): Record<string, unknown> {\n if (inputSchema && typeof inputSchema === \"object\" && !Array.isArray(inputSchema)) {\n return inputSchema as Record<string, unknown>\n }\n return { type: \"object\", properties: {} }\n}\n\nfunction buildTool(\n serverName: string,\n mcpTool: { name: string; description?: string; inputSchema: unknown },\n client: Client,\n): Tool.AnyExecutableTool {\n const toolName = `${serverName}__${mcpTool.name}`\n const jsonSchema = asJsonSchema(mcpTool.inputSchema)\n\n return Tool.make({\n description: mcpTool.description ?? toolName,\n // Dynamic mode — preserves MCP inputSchema on the wire for the LLM.\n jsonSchema: jsonSchema as never,\n execute: (input) =>\n Effect.tryPromise({\n try: async () => {\n const args =\n input && typeof input === \"object\" && !Array.isArray(input)\n ? (input as Record<string, unknown>)\n : {}\n const result = await client.callTool({ name: mcpTool.name, arguments: args })\n // MCP callTool returns {content: [{type, text?}], isError?}\n const parts = (result.content as { type: string; text?: string }[] | undefined) ?? []\n const text = parts.map((c) => c.text ?? \"\").join(\"\\n\")\n if (result.isError) {\n throw new Error(text || \"MCP tool returned error\")\n }\n return text\n },\n catch: (err) => new ToolFailure({ message: String(err) }),\n }),\n }) as Tool.AnyExecutableTool\n}\n\n// ---------------------------------------------------------------------------\n// connectMcp\n// ---------------------------------------------------------------------------\n\nexport async function connectMcp(name: string, config: McpServerConfig): Promise<McpClient> {\n const client = new Client({ name: \"tinyweb-agent\", version: \"0.0.1\" })\n\n const transport =\n config.type === \"stdio\"\n ? new StdioClientTransport({ command: config.command, args: config.args, env: config.env })\n : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: config.headers ?? {} } })\n\n await client.connect(transport)\n\n const listResult = await client.listTools()\n const tools: Record<string, Tool.AnyExecutableTool> = {}\n for (const mcpTool of listResult.tools) {\n const namespaced = `${name}__${mcpTool.name}`\n tools[namespaced] = buildTool(name, mcpTool, client)\n }\n\n return {\n name,\n tools,\n disconnect: () => client.close(),\n }\n}\n\n// ---------------------------------------------------------------------------\n// connectAllMcp — connect multiple servers, merge tools\n// ---------------------------------------------------------------------------\n\nexport type McpConfig = Record<string, McpServerConfig>\n\nexport async function connectAllMcp(configs: McpConfig): Promise<{ clients: McpClient[]; tools: Record<string, Tool.AnyExecutableTool> }> {\n const clients = await Promise.all(Object.entries(configs).map(([name, config]) => connectMcp(name, config)))\n const tools: Record<string, Tool.AnyExecutableTool> = {}\n for (const mcp of clients) {\n Object.assign(tools, mcp.tools)\n }\n return { clients, tools }\n}\n"]}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { connectMcp, connectAllMcp, type McpServerConfig, type McpStdioConfig, type McpHttpConfig, type McpConfig, type McpClient } from "./client"
|
|
1
|
+
export { connectMcp, connectAllMcp, type McpServerConfig, type McpStdioConfig, type McpHttpConfig, type McpConfig, type McpClient } from "./client";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
4
|
+
import { Effect } from 'effect';
|
|
5
|
+
import { Tool, ToolFailure } from '@tinyweb_dev/agent-framework-llm';
|
|
6
|
+
|
|
7
|
+
// src/mcp/client.ts
|
|
8
|
+
function asJsonSchema(inputSchema) {
|
|
9
|
+
if (inputSchema && typeof inputSchema === "object" && !Array.isArray(inputSchema)) {
|
|
10
|
+
return inputSchema;
|
|
11
|
+
}
|
|
12
|
+
return { type: "object", properties: {} };
|
|
13
|
+
}
|
|
14
|
+
function buildTool(serverName, mcpTool, client) {
|
|
15
|
+
const toolName = `${serverName}__${mcpTool.name}`;
|
|
16
|
+
const jsonSchema = asJsonSchema(mcpTool.inputSchema);
|
|
17
|
+
return Tool.make({
|
|
18
|
+
description: mcpTool.description ?? toolName,
|
|
19
|
+
// Dynamic mode — preserves MCP inputSchema on the wire for the LLM.
|
|
20
|
+
jsonSchema,
|
|
21
|
+
execute: (input) => Effect.tryPromise({
|
|
22
|
+
try: async () => {
|
|
23
|
+
const args = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
24
|
+
const result = await client.callTool({ name: mcpTool.name, arguments: args });
|
|
25
|
+
const parts = result.content ?? [];
|
|
26
|
+
const text = parts.map((c) => c.text ?? "").join("\n");
|
|
27
|
+
if (result.isError) {
|
|
28
|
+
throw new Error(text || "MCP tool returned error");
|
|
29
|
+
}
|
|
30
|
+
return text;
|
|
31
|
+
},
|
|
32
|
+
catch: (err) => new ToolFailure({ message: String(err) })
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async function connectMcp(name, config) {
|
|
37
|
+
const client = new Client({ name: "tinyweb-agent", version: "0.0.1" });
|
|
38
|
+
const transport = config.type === "stdio" ? new StdioClientTransport({ command: config.command, args: config.args, env: config.env }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: config.headers ?? {} } });
|
|
39
|
+
await client.connect(transport);
|
|
40
|
+
const listResult = await client.listTools();
|
|
41
|
+
const tools = {};
|
|
42
|
+
for (const mcpTool of listResult.tools) {
|
|
43
|
+
const namespaced = `${name}__${mcpTool.name}`;
|
|
44
|
+
tools[namespaced] = buildTool(name, mcpTool, client);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
name,
|
|
48
|
+
tools,
|
|
49
|
+
disconnect: () => client.close()
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function connectAllMcp(configs) {
|
|
53
|
+
const clients = await Promise.all(Object.entries(configs).map(([name, config]) => connectMcp(name, config)));
|
|
54
|
+
const tools = {};
|
|
55
|
+
for (const mcp of clients) {
|
|
56
|
+
Object.assign(tools, mcp.tools);
|
|
57
|
+
}
|
|
58
|
+
return { clients, tools };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { connectAllMcp, connectMcp };
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/client.ts"],"names":[],"mappings":";;;;;;;AA+CA,SAAS,aAAa,WAAA,EAA+C;AACnE,EAAA,IAAI,WAAA,IAAe,OAAO,WAAA,KAAgB,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,WAAW,CAAA,EAAG;AACjF,IAAA,OAAO,WAAA;AAAA,EACT;AACA,EAAA,OAAO,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,EAAC,EAAE;AAC1C;AAEA,SAAS,SAAA,CACP,UAAA,EACA,OAAA,EACA,MAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAW,CAAA,EAAG,UAAU,CAAA,EAAA,EAAK,QAAQ,IAAI,CAAA,CAAA;AAC/C,EAAA,MAAM,UAAA,GAAa,YAAA,CAAa,OAAA,CAAQ,WAAW,CAAA;AAEnD,EAAA,OAAO,KAAK,IAAA,CAAK;AAAA,IACf,WAAA,EAAa,QAAQ,WAAA,IAAe,QAAA;AAAA;AAAA,IAEpC,UAAA;AAAA,IACA,OAAA,EAAS,CAAC,KAAA,KACR,MAAA,CAAO,UAAA,CAAW;AAAA,MAChB,KAAK,YAAY;AACf,QAAA,MAAM,IAAA,GACJ,KAAA,IAAS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AAQ,SAAS,CAAA;AAE9B,EAAA,MAAM,UAAA,GAAa,MAAM,MAAA,CAAO,SAAA,EAAU;AAC1C,EAAA,MAAM,QAAgD,EAAC;AACvD,EAAA,KAAA,MAAW,OAAA,IAAW,WAAW,KAAA,EAAO;AACtC,IAAA,MAAM,UAAA,GAAa,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,QAAQ,IAAI,CAAA,CAAA;AAC3C,IAAA,KAAA,CAAM,UAAU,CAAA,GAAI,SAAA,CAAU,IAAA,EAAM,SAAS,MAAM,CAAA;AAAA,EACrD;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA,EAAY,MAAM,MAAA,CAAO,KAAA;AAAM,GACjC;AACF;AAQA,eAAsB,cAAc,OAAA,EAAsG;AACxI,EAAA,MAAM,UAAU,MAAM,OAAA,CAAQ,IAAI,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,MAAM,MAAM,CAAA,KAAM,WAAW,IAAA,EAAM,MAAM,CAAC,CAAC,CAAA;AAC3G,EAAA,MAAM,QAAgD,EAAC;AACvD,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,MAAA,CAAO,MAAA,CAAO,KAAA,EAAO,GAAA,CAAI,KAAK,CAAA;AAAA,EAChC;AACA,EAAA,OAAO,EAAE,SAAS,KAAA,EAAM;AAC1B","file":"index.js","sourcesContent":["// Adapted from opencode@v1.14.48 packages/opencode/src/mcp/\n\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\"\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\"\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\"\nimport { Effect } from \"effect\"\nimport { Tool, ToolFailure } from \"@tinyweb_dev/agent-framework-llm\"\n\n// ---------------------------------------------------------------------------\n// Config types\n// ---------------------------------------------------------------------------\n\nexport type McpStdioConfig = {\n readonly type: \"stdio\"\n readonly command: string\n readonly args?: string[]\n readonly env?: Record<string, string>\n}\n\nexport type McpHttpConfig = {\n readonly type: \"http\"\n readonly url: string\n readonly headers?: Record<string, string>\n}\n\nexport type McpServerConfig = McpStdioConfig | McpHttpConfig\n\n// ---------------------------------------------------------------------------\n// McpClient — holds connected client + tools\n// ---------------------------------------------------------------------------\n\nexport type McpClient = {\n readonly name: string\n readonly tools: Record<string, Tool.AnyExecutableTool>\n readonly disconnect: () => Promise<void>\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * MCP tools ship a real JSON Schema (`inputSchema`). We must pass it through\n * `Tool.make({ jsonSchema })` so the LLM sees required fields (e.g. Perplexity\n * `messages[]` / `query`). Using a generic Record schema loses that shape and\n * the model invents empty `{}` args → server-side validation errors.\n */\nfunction asJsonSchema(inputSchema: unknown): Record<string, unknown> {\n if (inputSchema && typeof inputSchema === \"object\" && !Array.isArray(inputSchema)) {\n return inputSchema as Record<string, unknown>\n }\n return { type: \"object\", properties: {} }\n}\n\nfunction buildTool(\n serverName: string,\n mcpTool: { name: string; description?: string; inputSchema: unknown },\n client: Client,\n): Tool.AnyExecutableTool {\n const toolName = `${serverName}__${mcpTool.name}`\n const jsonSchema = asJsonSchema(mcpTool.inputSchema)\n\n return Tool.make({\n description: mcpTool.description ?? toolName,\n // Dynamic mode — preserves MCP inputSchema on the wire for the LLM.\n jsonSchema: jsonSchema as never,\n execute: (input) =>\n Effect.tryPromise({\n try: async () => {\n const args =\n input && typeof input === \"object\" && !Array.isArray(input)\n ? (input as Record<string, unknown>)\n : {}\n const result = await client.callTool({ name: mcpTool.name, arguments: args })\n // MCP callTool returns {content: [{type, text?}], isError?}\n const parts = (result.content as { type: string; text?: string }[] | undefined) ?? []\n const text = parts.map((c) => c.text ?? \"\").join(\"\\n\")\n if (result.isError) {\n throw new Error(text || \"MCP tool returned error\")\n }\n return text\n },\n catch: (err) => new ToolFailure({ message: String(err) }),\n }),\n }) as Tool.AnyExecutableTool\n}\n\n// ---------------------------------------------------------------------------\n// connectMcp\n// ---------------------------------------------------------------------------\n\nexport async function connectMcp(name: string, config: McpServerConfig): Promise<McpClient> {\n const client = new Client({ name: \"tinyweb-agent\", version: \"0.0.1\" })\n\n const transport =\n config.type === \"stdio\"\n ? new StdioClientTransport({ command: config.command, args: config.args, env: config.env })\n : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: config.headers ?? {} } })\n\n await client.connect(transport)\n\n const listResult = await client.listTools()\n const tools: Record<string, Tool.AnyExecutableTool> = {}\n for (const mcpTool of listResult.tools) {\n const namespaced = `${name}__${mcpTool.name}`\n tools[namespaced] = buildTool(name, mcpTool, client)\n }\n\n return {\n name,\n tools,\n disconnect: () => client.close(),\n }\n}\n\n// ---------------------------------------------------------------------------\n// connectAllMcp — connect multiple servers, merge tools\n// ---------------------------------------------------------------------------\n\nexport type McpConfig = Record<string, McpServerConfig>\n\nexport async function connectAllMcp(configs: McpConfig): Promise<{ clients: McpClient[]; tools: Record<string, Tool.AnyExecutableTool> }> {\n const clients = await Promise.all(Object.entries(configs).map(([name, config]) => connectMcp(name, config)))\n const tools: Record<string, Tool.AnyExecutableTool> = {}\n for (const mcp of clients) {\n Object.assign(tools, mcp.tools)\n }\n return { clients, tools }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ToolFailure, type ExecutableTools } from "@tinyweb_dev/agent-framework-llm";
|
|
2
|
+
export type PermissionRule = "allow" | "ask" | "deny";
|
|
3
|
+
export type PermissionConfig = PermissionRule | Readonly<Record<string, PermissionRule>>;
|
|
4
|
+
/**
|
|
5
|
+
* How `"ask"` rules are enforced:
|
|
6
|
+
* - `"handler"` (default, backward-compat) — call `askHandler` and block the
|
|
7
|
+
* tool stream until it resolves. Suitable for in-process UIs / CLIs.
|
|
8
|
+
* - `"interrupt"` — short-circuit the tool with a structured `ToolFailure`
|
|
9
|
+
* (`metadata.kind = "tool-interrupt"`). The agent loop stops, persists a
|
|
10
|
+
* `pending-approval` ToolPart, and the host later calls
|
|
11
|
+
* `agent.resolveApproval` + `agent.resume`. No hanging Promise; survives
|
|
12
|
+
* process restarts when the SessionStore is durable.
|
|
13
|
+
*/
|
|
14
|
+
export type PermissionAskMode = "handler" | "interrupt";
|
|
15
|
+
export type PermissionAskRequest = {
|
|
16
|
+
readonly toolName: string;
|
|
17
|
+
readonly input: unknown;
|
|
18
|
+
};
|
|
19
|
+
export type PermissionAskHandler = (request: PermissionAskRequest) => Promise<boolean>;
|
|
20
|
+
/** Metadata key written onto ToolFailure / ToolResultValue for interrupts. */
|
|
21
|
+
export declare const TOOL_INTERRUPT_KIND: "tool-interrupt";
|
|
22
|
+
export declare const isToolInterruptMetadata: (metadata: Record<string, unknown> | undefined | null) => boolean;
|
|
23
|
+
export declare const toolInterruptFailure: (toolName: string, input: unknown) => ToolFailure;
|
|
24
|
+
export declare const resolveRule: (config: PermissionConfig | undefined, toolName: string) => PermissionRule;
|
|
25
|
+
export declare const applyPermission: (tools: ExecutableTools, config: PermissionConfig | undefined, askHandler: PermissionAskHandler | undefined, askMode?: PermissionAskMode) => ExecutableTools;
|
|
26
|
+
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAA0B,KAAK,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9G,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAExF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,WAAW,CAAA;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAEtF,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAA;AAE5D,eAAO,MAAM,uBAAuB,GAClC,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,KACnD,OAAiD,CAAA;AAEpD,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,OAAO,OAAO,KAAG,WAQpE,CAAA;AAEJ,eAAO,MAAM,WAAW,GAAI,QAAQ,gBAAgB,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,cAIpF,CAAA;AAmDD,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,EACtB,QAAQ,gBAAgB,GAAG,SAAS,EACpC,YAAY,oBAAoB,GAAG,SAAS,EAC5C,UAAS,iBAA6B,KACrC,eAUF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LoadedPlugin } from "./types";
|
|
2
|
+
import type { ChatHeadersInput, ChatHeadersOutput, ChatMessageInput, ChatMessageOutput, ChatParamsInput, ChatParamsOutput, EventHookInput, PermissionAskHookInput, PermissionAskHookOutput, SystemTransformInput, SystemTransformOutput, ToolDefinitionInput, ToolDefinitionOutput, ToolExecuteAfterInput, ToolExecuteAfterOutput, ToolExecuteBeforeInput, ToolExecuteBeforeOutput } from "./types";
|
|
3
|
+
export declare const applyEvent: (plugins: ReadonlyArray<LoadedPlugin>, input: EventHookInput) => Promise<void>;
|
|
4
|
+
export declare const applyChatMessage: (plugins: ReadonlyArray<LoadedPlugin>, input: ChatMessageInput, output: ChatMessageOutput) => Promise<ChatMessageOutput>;
|
|
5
|
+
export declare const applyChatParams: (plugins: ReadonlyArray<LoadedPlugin>, input: ChatParamsInput, output: ChatParamsOutput) => Promise<ChatParamsOutput>;
|
|
6
|
+
export declare const applyChatHeaders: (plugins: ReadonlyArray<LoadedPlugin>, input: ChatHeadersInput, output: ChatHeadersOutput) => Promise<ChatHeadersOutput>;
|
|
7
|
+
export declare const applyToolBefore: (plugins: ReadonlyArray<LoadedPlugin>, input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput) => Promise<ToolExecuteBeforeOutput>;
|
|
8
|
+
export declare const applyToolAfter: (plugins: ReadonlyArray<LoadedPlugin>, input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput) => Promise<ToolExecuteAfterOutput>;
|
|
9
|
+
export declare const applyToolDefinition: (plugins: ReadonlyArray<LoadedPlugin>, input: ToolDefinitionInput, output: ToolDefinitionOutput) => Promise<ToolDefinitionOutput>;
|
|
10
|
+
export declare const applyPermissionHook: (plugins: ReadonlyArray<LoadedPlugin>, input: PermissionAskHookInput, output: PermissionAskHookOutput) => Promise<PermissionAskHookOutput>;
|
|
11
|
+
export declare const applySystemTransform: (plugins: ReadonlyArray<LoadedPlugin>, input: SystemTransformInput, output: SystemTransformOutput) => Promise<SystemTransformOutput>;
|
|
12
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/plugin/apply.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAehB,eAAO,MAAM,UAAU,GAAU,S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+$/g, "") || "plugin";
|
|
6
|
+
var importPlugin = async (path) => {
|
|
7
|
+
const mod = await import(path);
|
|
8
|
+
const plugin = mod.server ?? mod.default;
|
|
9
|
+
if (!isPlugin(plugin))
|
|
10
|
+
throw new Error(`Plugin at ${path} must export a 'server' or default function returning Hooks`);
|
|
11
|
+
return { id: mod.id ?? idFromPath(path), plugin };
|
|
12
|
+
};
|
|
13
|
+
var normalizeEntry = async (entry, index) => {
|
|
14
|
+
if (isPlugin(entry)) return { id: `inline-${index}`, plugin: entry };
|
|
15
|
+
if (typeof entry === "string") {
|
|
16
|
+
const loaded2 = await importPlugin(entry);
|
|
17
|
+
return { id: loaded2.id, plugin: loaded2.plugin };
|
|
18
|
+
}
|
|
19
|
+
const loaded = await importPlugin(entry[0]);
|
|
20
|
+
return { id: loaded.id, plugin: loaded.plugin, options: entry[1] };
|
|
21
|
+
};
|
|
22
|
+
var loadPlugins = async (entries, input) => {
|
|
23
|
+
const resolved = await Promise.all(entries.map((entry, i) => normalizeEntry(entry, i)));
|
|
24
|
+
const loaded = await Promise.all(
|
|
25
|
+
resolved.map(async (item) => ({ id: item.id, hooks: await item.plugin(input, item.options) }))
|
|
26
|
+
);
|
|
27
|
+
return loaded;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/plugin/apply.ts
|
|
31
|
+
var runHooks = async (plugins, key, input, output) => {
|
|
32
|
+
for (const p of plugins) {
|
|
33
|
+
const hook = p.hooks[key];
|
|
34
|
+
if (hook) await hook(input, output);
|
|
35
|
+
}
|
|
36
|
+
return output;
|
|
37
|
+
};
|
|
38
|
+
var applyEvent = async (plugins, input) => {
|
|
39
|
+
for (const p of plugins) {
|
|
40
|
+
if (p.hooks.event) await p.hooks.event(input);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var applyChatMessage = (plugins, input, output) => runHooks(plugins, "chat.message", input, output);
|
|
44
|
+
var applyChatParams = (plugins, input, output) => runHooks(plugins, "chat.params", input, output);
|
|
45
|
+
var applyChatHeaders = (plugins, input, output) => runHooks(plugins, "chat.headers", input, output);
|
|
46
|
+
var applyToolBefore = (plugins, input, output) => runHooks(plugins, "tool.execute.before", input, output);
|
|
47
|
+
var applyToolAfter = (plugins, input, output) => runHooks(plugins, "tool.execute.after", input, output);
|
|
48
|
+
var applyToolDefinition = (plugins, input, output) => runHooks(plugins, "tool.definition", input, output);
|
|
49
|
+
var applyPermissionHook = (plugins, input, output) => runHooks(plugins, "permission.ask", input, output);
|
|
50
|
+
var applySystemTransform = (plugins, input, output) => runHooks(plugins, "experimental.chat.system.transform", input, output);
|
|
51
|
+
|
|
52
|
+
exports.applyChatHeaders = applyChatHeaders;
|
|
53
|
+
exports.applyChatMessage = applyChatMessage;
|
|
54
|
+
exports.applyChatParams = applyChatParams;
|
|
55
|
+
exports.applyEvent = applyEvent;
|
|
56
|
+
exports.applyPermissionHook = applyPermissionHook;
|
|
57
|
+
exports.applySystemTransform = applySystemTransform;
|
|
58
|
+
exports.applyToolAfter = applyToolAfter;
|
|
59
|
+
exports.applyToolBefore = applyToolBefore;
|
|
60
|
+
exports.applyToolDefinition = applyToolDefinition;
|
|
61
|
+
exports.loadPlugins = loadPlugins;
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
63
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/loader.ts","../../src/plugin/apply.ts"],"names":["loaded"],"mappings":";;;AAUA,IAAM,QAAA,GAAW,CAAC,KAAA,KAAoC,OAAO,KAAA,KAAU,UAAA;AAEvE,IAAM,UAAA,GAAa,CAAC,IAAA,KAAiB,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA,IAAK,QAAA;AAElG,IAAM,YAAA,GAAe,OAAO,IAAA,KAA0D;AACpF,EAAA,MAAM,GAAA,GAAO,MAAM,OAAO,IAAA,CAAA;AAC1B,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EAAsB,KAAA,EAAO,MAAM;AAEnD,IAAM,mBAAA,GAAsB,CACjC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,iBAAA,EAAmB,KAAA,EAAO,MAAM;AAEhD,IAAM,mBAAA,GAAsB,CACjC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,gBAAA,EAAkB,KAAA,EAAO,MAAM;AAE/C,IAAM,oBAAA,GAAuB,CAClC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,oCAAA,EAAsC,KAAA,EAAO,MAAM","file":"index.cjs","sourcesContent":["// Adapted from opencode@v1.14.48 packages/opencode/src/plugin/index.ts\n\nimport type { LoadedPlugin, Plugin, PluginEntry, PluginInput, PluginOptions } from \"./types\"\n\ntype PluginModule = {\n readonly id?: string\n readonly server?: Plugin\n readonly default?: Plugin\n}\n\nconst isPlugin = (value: unknown): value is Plugin => typeof value === \"function\"\n\nconst idFromPath = (path: string) => path.replace(/[^a-z0-9]+/gi, \"-\").replace(/^-+|-+$/g, \"\") || \"plugin\"\n\nconst importPlugin = async (path: string): Promise<{ id: string; plugin: Plugin }> => {\n const mod = (await import(path)) as PluginModule\n const plugin = mod.server ?? mod.default\n if (!isPlugin(plugin))\n throw new Error(`Plugin at ${path} must export a 'server' or default function returning Hooks`)\n return { id: mod.id ?? idFromPath(path), plugin }\n}\n\nconst normalizeEntry = async (entry: PluginEntry, index: number): Promise<{ id: string; plugin: Plugin; options?: PluginOptions }> => {\n if (isPlugin(entry)) return { id: `inline-${index}`, plugin: entry }\n if (typeof entry === \"string\") {\n const loaded = await importPlugin(entry)\n return { id: loaded.id, plugin: loaded.plugin }\n }\n const loaded = await importPlugin(entry[0])\n return { id: loaded.id, plugin: loaded.plugin, options: entry[1] }\n}\n\nexport const loadPlugins = async (\n entries: ReadonlyArray<PluginEntry>,\n input: PluginInput,\n): Promise<LoadedPlugin[]> => {\n const resolved = await Promise.all(entries.map((entry, i) => normalizeEntry(entry, i)))\n const loaded = await Promise.all(\n resolved.map(async (item) => ({ id: item.id, hooks: await item.plugin(input, item.options) })),\n )\n return loaded\n}\n","// Adapted from opencode@v1.14.48 packages/opencode/src/plugin/index.ts (apply pattern)\n\nimport type { LoadedPlugin } from \"./types\"\nimport type {\n ChatHeadersInput,\n ChatHeadersOutput,\n ChatMessageInput,\n ChatMessageOutput,\n ChatParamsInput,\n ChatParamsOutput,\n EventHookInput,\n PermissionAskHookInput,\n PermissionAskHookOutput,\n SystemTransformInput,\n SystemTransformOutput,\n ToolDefinitionInput,\n ToolDefinitionOutput,\n ToolExecuteAfterInput,\n ToolExecuteAfterOutput,\n ToolExecuteBeforeInput,\n ToolExecuteBeforeOutput,\n} from \"./types\"\n\nconst runHooks = async <I, O>(\n plugins: ReadonlyArray<LoadedPlugin>,\n key: string,\n input: I,\n output: O,\n): Promise<O> => {\n for (const p of plugins) {\n const hook = (p.hooks as Record<string, ((i: I, o: O) => Promise<void>) | undefined>)[key]\n if (hook) await hook(input, output)\n }\n return output\n}\n\nexport const applyEvent = async (plugins: ReadonlyArray<LoadedPlugin>, input: EventHookInput): Promise<void> => {\n for (const p of plugins) {\n if (p.hooks.event) await p.hooks.event(input)\n }\n}\n\nexport const applyChatMessage = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatMessageInput,\n output: ChatMessageOutput,\n) => runHooks(plugins, \"chat.message\", input, output)\n\nexport const applyChatParams = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatParamsInput,\n output: ChatParamsOutput,\n) => runHooks(plugins, \"chat.params\", input, output)\n\nexport const applyChatHeaders = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatHeadersInput,\n output: ChatHeadersOutput,\n) => runHooks(plugins, \"chat.headers\", input, output)\n\nexport const applyToolBefore = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolExecuteBeforeInput,\n output: ToolExecuteBeforeOutput,\n) => runHooks(plugins, \"tool.execute.before\", input, output)\n\nexport const applyToolAfter = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolExecuteAfterInput,\n output: ToolExecuteAfterOutput,\n) => runHooks(plugins, \"tool.execute.after\", input, output)\n\nexport const applyToolDefinition = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolDefinitionInput,\n output: ToolDefinitionOutput,\n) => runHooks(plugins, \"tool.definition\", input, output)\n\nexport const applyPermissionHook = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: PermissionAskHookInput,\n output: PermissionAskHookOutput,\n) => runHooks(plugins, \"permission.ask\", input, output)\n\nexport const applySystemTransform = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: SystemTransformInput,\n output: SystemTransformOutput,\n) => runHooks(plugins, \"experimental.chat.system.transform\", input, output)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/plugin/loader.ts
|
|
2
|
+
var isPlugin = (value) => typeof value === "function";
|
|
3
|
+
var idFromPath = (path) => path.replace(/[^a-z0-9]+/gi, "-").replace(/^-+|-+$/g, "") || "plugin";
|
|
4
|
+
var importPlugin = async (path) => {
|
|
5
|
+
const mod = await import(path);
|
|
6
|
+
const plugin = mod.server ?? mod.default;
|
|
7
|
+
if (!isPlugin(plugin))
|
|
8
|
+
throw new Error(`Plugin at ${path} must export a 'server' or default function returning Hooks`);
|
|
9
|
+
return { id: mod.id ?? idFromPath(path), plugin };
|
|
10
|
+
};
|
|
11
|
+
var normalizeEntry = async (entry, index) => {
|
|
12
|
+
if (isPlugin(entry)) return { id: `inline-${index}`, plugin: entry };
|
|
13
|
+
if (typeof entry === "string") {
|
|
14
|
+
const loaded2 = await importPlugin(entry);
|
|
15
|
+
return { id: loaded2.id, plugin: loaded2.plugin };
|
|
16
|
+
}
|
|
17
|
+
const loaded = await importPlugin(entry[0]);
|
|
18
|
+
return { id: loaded.id, plugin: loaded.plugin, options: entry[1] };
|
|
19
|
+
};
|
|
20
|
+
var loadPlugins = async (entries, input) => {
|
|
21
|
+
const resolved = await Promise.all(entries.map((entry, i) => normalizeEntry(entry, i)));
|
|
22
|
+
const loaded = await Promise.all(
|
|
23
|
+
resolved.map(async (item) => ({ id: item.id, hooks: await item.plugin(input, item.options) }))
|
|
24
|
+
);
|
|
25
|
+
return loaded;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/plugin/apply.ts
|
|
29
|
+
var runHooks = async (plugins, key, input, output) => {
|
|
30
|
+
for (const p of plugins) {
|
|
31
|
+
const hook = p.hooks[key];
|
|
32
|
+
if (hook) await hook(input, output);
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
};
|
|
36
|
+
var applyEvent = async (plugins, input) => {
|
|
37
|
+
for (const p of plugins) {
|
|
38
|
+
if (p.hooks.event) await p.hooks.event(input);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var applyChatMessage = (plugins, input, output) => runHooks(plugins, "chat.message", input, output);
|
|
42
|
+
var applyChatParams = (plugins, input, output) => runHooks(plugins, "chat.params", input, output);
|
|
43
|
+
var applyChatHeaders = (plugins, input, output) => runHooks(plugins, "chat.headers", input, output);
|
|
44
|
+
var applyToolBefore = (plugins, input, output) => runHooks(plugins, "tool.execute.before", input, output);
|
|
45
|
+
var applyToolAfter = (plugins, input, output) => runHooks(plugins, "tool.execute.after", input, output);
|
|
46
|
+
var applyToolDefinition = (plugins, input, output) => runHooks(plugins, "tool.definition", input, output);
|
|
47
|
+
var applyPermissionHook = (plugins, input, output) => runHooks(plugins, "permission.ask", input, output);
|
|
48
|
+
var applySystemTransform = (plugins, input, output) => runHooks(plugins, "experimental.chat.system.transform", input, output);
|
|
49
|
+
|
|
50
|
+
export { applyChatHeaders, applyChatMessage, applyChatParams, applyEvent, applyPermissionHook, applySystemTransform, applyToolAfter, applyToolBefore, applyToolDefinition, loadPlugins };
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/loader.ts","../../src/plugin/apply.ts"],"names":["loaded"],"mappings":";AAUA,IAAM,QAAA,GAAW,CAAC,KAAA,KAAoC,OAAO,KAAA,KAAU,UAAA;AAEvE,IAAM,UAAA,GAAa,CAAC,IAAA,KAAiB,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA,IAAK,QAAA;AAElG,IAAM,YAAA,GAAe,OAAO,IAAA,KAA0D;AACpF,EAAA,MAAM,GAAA,GAAO,MAAM,OAAO,IAAA,CAAA;AAC1B,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,MAAA,IAAU,GAAA,CAAI,OAAA;AACjC,EAAA,IAAI,CAAC,SAAS,MAAM,CAAA;AAClB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,UAAA,EAAa,IAAI,CAAA,2DAAA,CAA6D,CAAA;AAChG,EAAA,OAAO,EAAE,EAAA,EAAI,GAAA,CAAI,MAAM,UAAA,CAAW,IAAI,GAAG,MAAA,EAAO;AAClD,CAAA;AAEA,IAAM,cAAA,GAAiB,OAAO,KAAA,EAAoB,KAAA,KAAoF;AACpI,EAAA,IAAI,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,EAAE,IAAI,CAAA,OAAA,EAAU,KAAK,CAAA,CAAA,EAAI,MAAA,EAAQ,KAAA,EAAM;AACnE,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAMA,OAAAA,GAAS,MAAM,YAAA,CAAa,KAAK,CAAA;AACvC,IAAA,OAAO,EAAE,EAAA,EAAIA,OAAAA,CAAO,EAAA,EAAI,MAAA,E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,EAC9C;AACF;AAEO,IAAM,gBAAA,GAAmB,CAC9B,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,cAAA,EAAgB,KAAA,EAAO,MAAM;AAE7C,IAAM,eAAA,GAAkB,CAC7B,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,aAAA,EAAe,KAAA,EAAO,MAAM;AAE5C,IAAM,gBAAA,GAAmB,CAC9B,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,cAAA,EAAgB,KAAA,EAAO,MAAM;AAE7C,IAAM,eAAA,GAAkB,CAC7B,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,qBAAA,EAAuB,KAAA,EAAO,MAAM;AAEpD,IAAM,cAAA,GAAiB,CAC5B,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,oBAAA,EAAsB,KAAA,EAAO,MAAM;AAEnD,IAAM,mBAAA,GAAsB,CACjC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,iBAAA,EAAmB,KAAA,EAAO,MAAM;AAEhD,IAAM,mBAAA,GAAsB,CACjC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,gBAAA,EAAkB,KAAA,EAAO,MAAM;AAE/C,IAAM,oBAAA,GAAuB,CAClC,OAAA,EACA,KAAA,EACA,WACG,QAAA,CAAS,OAAA,EAAS,oCAAA,EAAsC,KAAA,EAAO,MAAM","file":"index.js","sourcesContent":["// Adapted from opencode@v1.14.48 packages/opencode/src/plugin/index.ts\n\nimport type { LoadedPlugin, Plugin, PluginEntry, PluginInput, PluginOptions } from \"./types\"\n\ntype PluginModule = {\n readonly id?: string\n readonly server?: Plugin\n readonly default?: Plugin\n}\n\nconst isPlugin = (value: unknown): value is Plugin => typeof value === \"function\"\n\nconst idFromPath = (path: string) => path.replace(/[^a-z0-9]+/gi, \"-\").replace(/^-+|-+$/g, \"\") || \"plugin\"\n\nconst importPlugin = async (path: string): Promise<{ id: string; plugin: Plugin }> => {\n const mod = (await import(path)) as PluginModule\n const plugin = mod.server ?? mod.default\n if (!isPlugin(plugin))\n throw new Error(`Plugin at ${path} must export a 'server' or default function returning Hooks`)\n return { id: mod.id ?? idFromPath(path), plugin }\n}\n\nconst normalizeEntry = async (entry: PluginEntry, index: number): Promise<{ id: string; plugin: Plugin; options?: PluginOptions }> => {\n if (isPlugin(entry)) return { id: `inline-${index}`, plugin: entry }\n if (typeof entry === \"string\") {\n const loaded = await importPlugin(entry)\n return { id: loaded.id, plugin: loaded.plugin }\n }\n const loaded = await importPlugin(entry[0])\n return { id: loaded.id, plugin: loaded.plugin, options: entry[1] }\n}\n\nexport const loadPlugins = async (\n entries: ReadonlyArray<PluginEntry>,\n input: PluginInput,\n): Promise<LoadedPlugin[]> => {\n const resolved = await Promise.all(entries.map((entry, i) => normalizeEntry(entry, i)))\n const loaded = await Promise.all(\n resolved.map(async (item) => ({ id: item.id, hooks: await item.plugin(input, item.options) })),\n )\n return loaded\n}\n","// Adapted from opencode@v1.14.48 packages/opencode/src/plugin/index.ts (apply pattern)\n\nimport type { LoadedPlugin } from \"./types\"\nimport type {\n ChatHeadersInput,\n ChatHeadersOutput,\n ChatMessageInput,\n ChatMessageOutput,\n ChatParamsInput,\n ChatParamsOutput,\n EventHookInput,\n PermissionAskHookInput,\n PermissionAskHookOutput,\n SystemTransformInput,\n SystemTransformOutput,\n ToolDefinitionInput,\n ToolDefinitionOutput,\n ToolExecuteAfterInput,\n ToolExecuteAfterOutput,\n ToolExecuteBeforeInput,\n ToolExecuteBeforeOutput,\n} from \"./types\"\n\nconst runHooks = async <I, O>(\n plugins: ReadonlyArray<LoadedPlugin>,\n key: string,\n input: I,\n output: O,\n): Promise<O> => {\n for (const p of plugins) {\n const hook = (p.hooks as Record<string, ((i: I, o: O) => Promise<void>) | undefined>)[key]\n if (hook) await hook(input, output)\n }\n return output\n}\n\nexport const applyEvent = async (plugins: ReadonlyArray<LoadedPlugin>, input: EventHookInput): Promise<void> => {\n for (const p of plugins) {\n if (p.hooks.event) await p.hooks.event(input)\n }\n}\n\nexport const applyChatMessage = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatMessageInput,\n output: ChatMessageOutput,\n) => runHooks(plugins, \"chat.message\", input, output)\n\nexport const applyChatParams = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatParamsInput,\n output: ChatParamsOutput,\n) => runHooks(plugins, \"chat.params\", input, output)\n\nexport const applyChatHeaders = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ChatHeadersInput,\n output: ChatHeadersOutput,\n) => runHooks(plugins, \"chat.headers\", input, output)\n\nexport const applyToolBefore = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolExecuteBeforeInput,\n output: ToolExecuteBeforeOutput,\n) => runHooks(plugins, \"tool.execute.before\", input, output)\n\nexport const applyToolAfter = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolExecuteAfterInput,\n output: ToolExecuteAfterOutput,\n) => runHooks(plugins, \"tool.execute.after\", input, output)\n\nexport const applyToolDefinition = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: ToolDefinitionInput,\n output: ToolDefinitionOutput,\n) => runHooks(plugins, \"tool.definition\", input, output)\n\nexport const applyPermissionHook = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: PermissionAskHookInput,\n output: PermissionAskHookOutput,\n) => runHooks(plugins, \"permission.ask\", input, output)\n\nexport const applySystemTransform = (\n plugins: ReadonlyArray<LoadedPlugin>,\n input: SystemTransformInput,\n output: SystemTransformOutput,\n) => runHooks(plugins, \"experimental.chat.system.transform\", input, output)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugin/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAU,WAAW,EAAE,WAAW,EAAiB,MAAM,SAAS,CAAA;AA8B5F,eAAO,MAAM,WAAW,GACtB,SAAS,aAAa,CAAC,WAAW,CAAC,EACnC,OAAO,WAAW,KACjB,OAAO,CAAC,YAAY,EAAE,CAMxB,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ModelRef, ToolDefinition } from "@tinyweb_dev/agent-framework-llm";
|
|
2
|
+
import type { Message, UserMessage } from "../session/schema";
|
|
3
|
+
import type { BusEvent } from "../bus/bus";
|
|
4
|
+
export type PluginOptions = Readonly<Record<string, unknown>>;
|
|
5
|
+
export type PluginInput = {
|
|
6
|
+
readonly agentName: string;
|
|
7
|
+
readonly directory: string;
|
|
8
|
+
};
|
|
9
|
+
export type ChatParamsInput = {
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly agentName: string;
|
|
12
|
+
readonly model: ModelRef;
|
|
13
|
+
readonly message: UserMessage;
|
|
14
|
+
};
|
|
15
|
+
export type ChatParamsOutput = {
|
|
16
|
+
temperature?: number;
|
|
17
|
+
topP?: number;
|
|
18
|
+
topK?: number;
|
|
19
|
+
maxOutputTokens?: number;
|
|
20
|
+
options: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export type ChatHeadersInput = ChatParamsInput;
|
|
23
|
+
export type ChatHeadersOutput = {
|
|
24
|
+
headers: Record<string, string>;
|
|
25
|
+
};
|
|
26
|
+
export type ChatMessageInput = {
|
|
27
|
+
readonly sessionId: string;
|
|
28
|
+
readonly agentName: string;
|
|
29
|
+
readonly model: ModelRef;
|
|
30
|
+
readonly messageId: string;
|
|
31
|
+
};
|
|
32
|
+
export type ChatMessageOutput = {
|
|
33
|
+
message: UserMessage;
|
|
34
|
+
};
|
|
35
|
+
export type ToolExecuteBeforeInput = {
|
|
36
|
+
readonly tool: string;
|
|
37
|
+
readonly sessionId: string;
|
|
38
|
+
readonly callId: string;
|
|
39
|
+
};
|
|
40
|
+
export type ToolExecuteBeforeOutput = {
|
|
41
|
+
args: unknown;
|
|
42
|
+
};
|
|
43
|
+
export type ToolExecuteAfterInput = {
|
|
44
|
+
readonly tool: string;
|
|
45
|
+
readonly sessionId: string;
|
|
46
|
+
readonly callId: string;
|
|
47
|
+
readonly args: unknown;
|
|
48
|
+
};
|
|
49
|
+
export type ToolExecuteAfterOutput = {
|
|
50
|
+
output: unknown;
|
|
51
|
+
metadata: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
export type ToolDefinitionInput = {
|
|
54
|
+
readonly toolId: string;
|
|
55
|
+
};
|
|
56
|
+
export type ToolDefinitionOutput = {
|
|
57
|
+
description: string;
|
|
58
|
+
parameters: ToolDefinition["inputSchema"];
|
|
59
|
+
};
|
|
60
|
+
export type PermissionAskHookInput = {
|
|
61
|
+
readonly toolName: string;
|
|
62
|
+
readonly sessionId: string;
|
|
63
|
+
readonly callId: string;
|
|
64
|
+
readonly input: unknown;
|
|
65
|
+
};
|
|
66
|
+
export type PermissionAskHookOutput = {
|
|
67
|
+
status: "allow" | "ask" | "deny";
|
|
68
|
+
};
|
|
69
|
+
export type SystemTransformInput = {
|
|
70
|
+
readonly sessionId: string;
|
|
71
|
+
readonly agentName: string;
|
|
72
|
+
readonly model: ModelRef;
|
|
73
|
+
};
|
|
74
|
+
export type SystemTransformOutput = {
|
|
75
|
+
system: string[];
|
|
76
|
+
};
|
|
77
|
+
export type EventHookInput = {
|
|
78
|
+
readonly event: BusEvent;
|
|
79
|
+
};
|
|
80
|
+
export type Hooks = {
|
|
81
|
+
readonly event?: (input: EventHookInput) => Promise<void>;
|
|
82
|
+
readonly "chat.message"?: (input: ChatMessageInput, output: ChatMessageOutput) => Promise<void>;
|
|
83
|
+
readonly "chat.params"?: (input: ChatParamsInput, output: ChatParamsOutput) => Promise<void>;
|
|
84
|
+
readonly "chat.headers"?: (input: ChatHeadersInput, output: ChatHeadersOutput) => Promise<void>;
|
|
85
|
+
readonly "tool.execute.before"?: (input: ToolExecuteBeforeInput, output: ToolExecuteBeforeOutput) => Promise<void>;
|
|
86
|
+
readonly "tool.execute.after"?: (input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput) => Promise<void>;
|
|
87
|
+
readonly "tool.definition"?: (input: ToolDefinitionInput, output: ToolDefinitionOutput) => Promise<void>;
|
|
88
|
+
readonly "permission.ask"?: (input: PermissionAskHookInput, output: PermissionAskHookOutput) => Promise<void>;
|
|
89
|
+
readonly "experimental.chat.system.transform"?: (input: SystemTransformInput, output: SystemTransformOutput) => Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
export type Plugin = (input: PluginInput, options?: PluginOptions) => Promise<Hooks>;
|
|
92
|
+
export type PluginEntry = Plugin | string | readonly [string, PluginOptions];
|
|
93
|
+
export type LoadedPlugin = {
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly hooks: Hooks;
|
|
96
|
+
};
|
|
97
|
+
export type { Message };
|
|
98
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE7D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,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