@roll-agent/core 0.11.0 → 0.13.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/bin/roll.js +18 -1
- package/dist/cli/chat/ink/app.d.ts +15 -0
- package/dist/cli/chat/ink/app.js +1 -0
- package/dist/cli/chat/ink/commands.d.ts +6 -0
- package/dist/cli/chat/ink/commands.js +1 -0
- package/dist/cli/chat/ink/confirm-select.d.ts +6 -0
- package/dist/cli/chat/ink/confirm-select.js +1 -0
- package/dist/cli/chat/ink/history-from-messages.d.ts +3 -0
- package/dist/cli/chat/ink/history-from-messages.js +1 -0
- package/dist/cli/chat/ink/history-item.d.ts +5 -0
- package/dist/cli/chat/ink/history-item.js +1 -0
- package/dist/cli/chat/ink/live-region.d.ts +5 -0
- package/dist/cli/chat/ink/live-region.js +1 -0
- package/dist/cli/chat/ink/markdown.d.ts +5 -0
- package/dist/cli/chat/ink/markdown.js +1 -0
- package/dist/cli/chat/ink/run-ink-repl.d.ts +13 -0
- package/dist/cli/chat/ink/run-ink-repl.js +1 -0
- package/dist/cli/chat/ink/slash-popup.d.ts +7 -0
- package/dist/cli/chat/ink/slash-popup.js +1 -0
- package/dist/cli/chat/ink/spinner.d.ts +2 -0
- package/dist/cli/chat/ink/spinner.js +1 -0
- package/dist/cli/chat/ink/state.d.ts +103 -0
- package/dist/cli/chat/ink/state.js +1 -0
- package/dist/cli/chat/ink/status-line.d.ts +16 -0
- package/dist/cli/chat/ink/status-line.js +1 -0
- package/dist/cli/chat/ink/text-prompt.d.ts +12 -0
- package/dist/cli/chat/ink/text-prompt.js +1 -0
- package/dist/cli/chat/ink/thinking-text.d.ts +10 -0
- package/dist/cli/chat/ink/thinking-text.js +1 -0
- package/dist/cli/chat/ink/thinking.d.ts +3 -0
- package/dist/cli/chat/ink/thinking.js +1 -0
- package/dist/cli/chat/ink/tool-label.d.ts +4 -0
- package/dist/cli/chat/ink/tool-label.js +1 -0
- package/dist/cli/chat/ink/use-session.d.ts +20 -0
- package/dist/cli/chat/ink/use-session.js +1 -0
- package/dist/cli/chat/title.d.ts +1 -0
- package/dist/cli/chat/title.js +1 -0
- package/dist/cli/commands/browser-stop.d.ts +4 -4
- package/dist/cli/commands/chat.d.ts +9 -0
- package/dist/cli/commands/chat.js +1 -1
- package/dist/cli/commands/config-guidance.d.ts +2 -2
- package/dist/cli/utils/chat-renderer.d.ts +7 -1
- package/dist/cli/utils/chat-renderer.js +1 -1
- package/dist/cli/utils/output.d.ts +1 -0
- package/dist/cli/utils/output.js +1 -1
- package/dist/cli/utils/package-manager.d.ts +5 -0
- package/dist/cli/utils/package-manager.js +1 -1
- package/dist/cli/utils/token-format.d.ts +23 -0
- package/dist/cli/utils/token-format.js +1 -0
- package/dist/cli/utils/tool-format.d.ts +1 -0
- package/dist/cli/utils/tool-format.js +1 -0
- package/dist/config/defaults.js +1 -1
- package/dist/config/key-codec.js +1 -1
- package/dist/config/schema.d.ts +164 -40
- package/dist/config/schema.js +1 -1
- package/dist/llm/engine.d.ts +1 -1
- package/dist/llm/providers.d.ts +9 -6
- package/dist/llm/providers.js +1 -1
- package/dist/mcp/client-manager.d.ts +4 -2
- package/dist/mcp/client-manager.js +1 -1
- package/dist/mcp/sampling-handler.d.ts +2 -2
- package/dist/router/llm-router.d.ts +2 -2
- package/dist/tool-runtime/argument-extractor.d.ts +2 -2
- package/dist/types/chat.d.ts +12 -0
- package/package.json +15 -10
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
import type { AgentTransport } from "../types/agent.ts";
|
|
4
4
|
export interface ConnectOptions {
|
|
5
5
|
/** 连接超时(毫秒),默认 30s */
|
|
6
6
|
readonly timeoutMs?: number;
|
|
7
7
|
/** 为子 Agent 提供的 LLM model(启用 Sampling 支持) */
|
|
8
|
-
readonly samplingModel?:
|
|
8
|
+
readonly samplingModel?: LanguageModelV4;
|
|
9
9
|
/** 注入到 stdio 子进程的环境变量(与 process.env 合并) */
|
|
10
10
|
readonly env?: Readonly<Record<string, string>>;
|
|
11
11
|
}
|
|
12
|
+
export declare function buildStdioChildEnv(env?: Readonly<Record<string, string>>): Record<string, string>;
|
|
13
|
+
export declare function shouldSuppressStdioChildStderrLine(line: string): boolean;
|
|
12
14
|
/**
|
|
13
15
|
* MCP Client Manager — 管理到子 Agent MCP Server 的连接。
|
|
14
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Client as
|
|
1
|
+
import{Client as n}from"@modelcontextprotocol/sdk/client/index.js";import{StdioClientTransport as t}from"@modelcontextprotocol/sdk/client/stdio.js";import{StreamableHTTPClientTransport as e}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{registerSamplingHandler as o}from"./sampling-handler.js";const s=3e4,i="--disable-warning=ExperimentalWarning";export function buildStdioChildEnv(n){const t=n?{...process.env,...n}:{};return{...t,NODE_OPTIONS:r(t.NODE_OPTIONS,i),ROLL_AGENT_LOG_LEVEL:t.ROLL_AGENT_LOG_LEVEL??"warn"}}function r(n,t){const e=n?.trim();if(!e)return t;const o=e.split(/\s+/);return o.includes("--no-warnings")||o.includes(t)?e:`${e} ${t}`}export function shouldSuppressStdioChildStderrLine(n){const t=n.trim();return t.includes("ExperimentalWarning:")||t.startsWith("(Use `node --trace-warnings")||/\[INFO\s*\]\s*\[[^\]]+\]\s*MCP Server running on stdio$/.test(t)}function c(n,e,o){const s=new t({command:n.command,args:[...n.args??[]],cwd:e,env:buildStdioChildEnv(o),stderr:"pipe"});return l(s),s}function l(n){const t=n.stderr;if(!t)return;let e="";const o=n=>{shouldSuppressStdioChildStderrLine(n)||process.stderr.write(`${n}\n`)};t.on("data",n=>{e+=n.toString();const t=e.split(/\r?\n/);e=t.pop()??"";for(const n of t)o(n)}),t.on("end",()=>{e.length>0&&(o(e),e="")})}export class McpClientManager{connections=new Map;async connect(t,i,r,l={}){const a=this.connections.get(t);if(a)return a.client;const d=l.timeoutMs??s,p=l.samplingModel?{sampling:{}}:{},m=new n({name:`roll-client-${t}`,version:"0.0.1"},{capabilities:p});l.samplingModel&&o(m,l.samplingModel);const u="streamable-http"===i.type?new e(new URL(i.endpoint)):c(i,r,l.env),h=m.connect(u);let g;const w=new Promise((n,e)=>{g=setTimeout(()=>e(new Error(`Connection to "${t}" timed out after ${d}ms`)),d)});try{await Promise.race([h,w])}catch(n){throw await m.close().catch(()=>{}),n}finally{clearTimeout(g)}return this.connections.set(t,{client:m,transportType:i.type}),m}async disconnect(n){const t=this.connections.get(n);t&&(await t.client.close(),this.connections.delete(n))}async disconnectAll(){const n=[...this.connections.keys()];await Promise.all(n.map(n=>this.disconnect(n)))}isConnected(n){return this.connections.has(n)}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
/**
|
|
4
4
|
* 在 MCP Client 上注册 Sampling Handler。
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { LanguageModelV3 } from "@ai-sdk/provider";
|
|
|
8
8
|
*
|
|
9
9
|
* @see https://spec.modelcontextprotocol.io/specification/client/sampling/
|
|
10
10
|
*/
|
|
11
|
-
export declare function registerSamplingHandler(client: Client, model:
|
|
11
|
+
export declare function registerSamplingHandler(client: Client, model: LanguageModelV4): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV4, SharedV4ProviderOptions } from "@ai-sdk/provider";
|
|
2
2
|
import type { RegisteredAgent } from "../types/agent.ts";
|
|
3
3
|
import type { RouteSelection } from "../types/router.ts";
|
|
4
4
|
/**
|
|
@@ -8,4 +8,4 @@ import type { RouteSelection } from "../types/router.ts";
|
|
|
8
8
|
* 1. 优先尝试 structured output
|
|
9
9
|
* 2. 仅当模型未遵循 schema 时,降级为纯文本 JSON fallback
|
|
10
10
|
*/
|
|
11
|
-
export declare function routeWithLLM(message: string, agents: ReadonlyArray<RegisteredAgent>, model:
|
|
11
|
+
export declare function routeWithLLM(message: string, agents: ReadonlyArray<RegisteredAgent>, model: LanguageModelV4, structuredOutputProviderOptions?: SharedV4ProviderOptions): Promise<RouteSelection>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LanguageModelV4, SharedV4ProviderOptions } from "@ai-sdk/provider";
|
|
2
2
|
import type { AgentTool } from "../types/agent.ts";
|
|
3
|
-
export declare function extractToolInput(message: string, tool: Pick<AgentTool, "name" | "description" | "inputSchema">, model:
|
|
3
|
+
export declare function extractToolInput(message: string, tool: Pick<AgentTool, "name" | "description" | "inputSchema">, model: LanguageModelV4, structuredOutputProviderOptions?: SharedV4ProviderOptions): Promise<Readonly<Record<string, unknown>>>;
|
package/dist/types/chat.d.ts
CHANGED
|
@@ -16,6 +16,14 @@ export interface ChatStepUsage {
|
|
|
16
16
|
readonly finishReason: string;
|
|
17
17
|
readonly usage?: ChatTokenUsage;
|
|
18
18
|
}
|
|
19
|
+
export interface ChatCompactionSummary {
|
|
20
|
+
readonly reason: "auto" | "manual";
|
|
21
|
+
readonly strategy: "summarize" | "truncate";
|
|
22
|
+
readonly removed: number;
|
|
23
|
+
readonly kept: number;
|
|
24
|
+
readonly truncatedTools?: number;
|
|
25
|
+
readonly beforeInputTokens?: number;
|
|
26
|
+
}
|
|
19
27
|
export interface ChatInputRequirement {
|
|
20
28
|
readonly name: string;
|
|
21
29
|
readonly description: string;
|
|
@@ -36,6 +44,10 @@ export interface ChatCompletedResult {
|
|
|
36
44
|
readonly steps: ReadonlyArray<ChatStepSummary>;
|
|
37
45
|
readonly stepUsages?: ReadonlyArray<ChatStepUsage>;
|
|
38
46
|
readonly totalUsage?: ChatTokenUsage;
|
|
47
|
+
readonly sessionUsage?: ChatTokenUsage;
|
|
48
|
+
readonly contextWindow?: number;
|
|
49
|
+
readonly contextInputTokens?: number;
|
|
50
|
+
readonly compactions?: ReadonlyArray<ChatCompactionSummary>;
|
|
39
51
|
}
|
|
40
52
|
export interface ChatNeedsInputResult {
|
|
41
53
|
readonly status: "needs_input";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roll-agent/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -58,28 +58,33 @@
|
|
|
58
58
|
"node": ">=22.6.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@ai-sdk/alibaba": "^
|
|
62
|
-
"@ai-sdk/anthropic": "^
|
|
63
|
-
"@ai-sdk/deepseek": "^
|
|
64
|
-
"@ai-sdk/openai": "^
|
|
65
|
-
"@ai-sdk/provider": "^
|
|
61
|
+
"@ai-sdk/alibaba": "^2.0.3",
|
|
62
|
+
"@ai-sdk/anthropic": "^4.0.4",
|
|
63
|
+
"@ai-sdk/deepseek": "^3.0.2",
|
|
64
|
+
"@ai-sdk/openai": "^4.0.4",
|
|
65
|
+
"@ai-sdk/provider": "^4.0.1",
|
|
66
66
|
"@clack/prompts": "1.4.0",
|
|
67
67
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
68
|
-
"ai": "^
|
|
68
|
+
"ai": "^7.0.9",
|
|
69
69
|
"chalk": "^5.4.0",
|
|
70
70
|
"citty": "^0.1.6",
|
|
71
71
|
"cli-table3": "^0.6.5",
|
|
72
72
|
"gray-matter": "^4.0.3",
|
|
73
|
+
"ink": "7.0.1",
|
|
74
|
+
"marked": "18.0.5",
|
|
73
75
|
"ora": "^8.1.0",
|
|
76
|
+
"react": "19.2.7",
|
|
74
77
|
"yaml": "^2.7.0",
|
|
75
78
|
"zod": "^3.25.76",
|
|
76
|
-
"@roll-agent/runtime": "0.
|
|
79
|
+
"@roll-agent/runtime": "0.3.0"
|
|
77
80
|
},
|
|
78
81
|
"devDependencies": {
|
|
79
|
-
"@types/node": "^22.0.0"
|
|
82
|
+
"@types/node": "^22.0.0",
|
|
83
|
+
"@types/react": "19.2.16",
|
|
84
|
+
"ink-testing-library": "4.0.0"
|
|
80
85
|
},
|
|
81
86
|
"scripts": {
|
|
82
|
-
"dev": "node --experimental-strip-types --experimental-sqlite src/cli/index.ts",
|
|
87
|
+
"dev": "node --disable-warning=ExperimentalWarning --experimental-strip-types --experimental-sqlite src/cli/index.ts",
|
|
83
88
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/obfuscate.mjs",
|
|
84
89
|
"typecheck": "tsc --noEmit",
|
|
85
90
|
"test": "node --experimental-strip-types --experimental-sqlite --test \"src/**/*.test.ts\"",
|