neoctl 0.2.29 → 0.2.31
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/README.md +40 -4
- package/dist/context/compaction.d.ts +20 -4
- package/dist/context/compaction.js +377 -186
- package/dist/context/compaction.js.map +1 -1
- package/dist/context/context-manager.d.ts +7 -1
- package/dist/context/context-manager.js +15 -11
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/prompts.js +2 -0
- package/dist/context/prompts.js.map +1 -1
- package/dist/context/smoke-context.js +266 -17
- package/dist/context/smoke-context.js.map +1 -1
- package/dist/core/assistant-output-filter.d.ts +1 -0
- package/dist/core/assistant-output-filter.js +54 -2
- package/dist/core/assistant-output-filter.js.map +1 -1
- package/dist/core/context-metrics.d.ts +1 -0
- package/dist/core/context-metrics.js +18 -12
- package/dist/core/context-metrics.js.map +1 -1
- package/dist/core/image-registry.d.ts +16 -3
- package/dist/core/image-registry.js +65 -30
- package/dist/core/image-registry.js.map +1 -1
- package/dist/core/image-storage.d.ts +15 -1
- package/dist/core/image-storage.js +140 -17
- package/dist/core/image-storage.js.map +1 -1
- package/dist/core/message-pipeline.js +18 -4
- package/dist/core/message-pipeline.js.map +1 -1
- package/dist/core/query-engine.d.ts +12 -2
- package/dist/core/query-engine.js +57 -8
- package/dist/core/query-engine.js.map +1 -1
- package/dist/core/query.d.ts +13 -2
- package/dist/core/query.js +56 -21
- package/dist/core/query.js.map +1 -1
- package/dist/core/smoke-core-loop.js +68 -3
- package/dist/core/smoke-core-loop.js.map +1 -1
- package/dist/core/smoke-image-integrity.d.ts +1 -0
- package/dist/core/smoke-image-integrity.js +67 -0
- package/dist/core/smoke-image-integrity.js.map +1 -0
- package/dist/core/state.d.ts +1 -1
- package/dist/core/state.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/model-metadata.json +4 -4
- package/dist/plugins/plugin-system.d.ts +61 -0
- package/dist/plugins/plugin-system.js +189 -0
- package/dist/plugins/plugin-system.js.map +1 -0
- package/dist/plugins/smoke-plugin-system.d.ts +1 -0
- package/dist/plugins/smoke-plugin-system.js +63 -0
- package/dist/plugins/smoke-plugin-system.js.map +1 -0
- package/dist/repl/index.js +8 -3
- package/dist/repl/index.js.map +1 -1
- package/dist/session/session-export.d.ts +2 -0
- package/dist/session/session-export.js +10 -0
- package/dist/session/session-export.js.map +1 -1
- package/dist/session/session-store.d.ts +41 -0
- package/dist/session/session-store.js +292 -59
- package/dist/session/session-store.js.map +1 -1
- package/dist/session/smoke-session.js +127 -7
- package/dist/session/smoke-session.js.map +1 -1
- package/dist/tools/builtins/exec-process-manager.d.ts +16 -2
- package/dist/tools/builtins/exec-process-manager.js +119 -25
- package/dist/tools/builtins/exec-process-manager.js.map +1 -1
- package/dist/tools/builtins/exec-tool.js +11 -2
- package/dist/tools/builtins/exec-tool.js.map +1 -1
- package/dist/tools/builtins/image-generation-tool.js +32 -42
- package/dist/tools/builtins/image-generation-tool.js.map +1 -1
- package/dist/tools/builtins/image-loader-tool.js +10 -4
- package/dist/tools/builtins/image-loader-tool.js.map +1 -1
- package/dist/tools/builtins/image-note-tool.js +8 -3
- package/dist/tools/builtins/image-note-tool.js.map +1 -1
- package/dist/tools/registry.d.ts +8 -1
- package/dist/tools/registry.js +37 -13
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/smoke-exec-process.js +88 -4
- package/dist/tools/smoke-exec-process.js.map +1 -1
- package/dist/tools/smoke-tool-system.js +24 -6
- package/dist/tools/smoke-tool-system.js.map +1 -1
- package/dist/types/events.d.ts +5 -1
- package/dist/types/messages.d.ts +13 -5
- package/dist/types/messages.js +4 -0
- package/dist/types/messages.js.map +1 -1
- package/dist/ui/display-message.d.ts +10 -2
- package/dist/ui/display-message.js +18 -9
- package/dist/ui/display-message.js.map +1 -1
- package/dist/web/index.d.ts +176 -11
- package/dist/web/index.js +986 -106
- package/dist/web/index.js.map +1 -1
- package/dist/web/runtime-context-protocol.d.ts +12 -1
- package/dist/web/runtime-context-protocol.js +16 -1
- package/dist/web/runtime-context-protocol.js.map +1 -1
- package/dist/web/smoke-runtime-context-protocol.js +3 -0
- package/dist/web/smoke-runtime-context-protocol.js.map +1 -1
- package/dist/web/smoke-web-history.d.ts +1 -0
- package/dist/web/smoke-web-history.js +121 -0
- package/dist/web/smoke-web-history.js.map +1 -0
- package/dist/web/smoke-web-terminal-tasks.d.ts +1 -0
- package/dist/web/smoke-web-terminal-tasks.js +90 -0
- package/dist/web/smoke-web-terminal-tasks.js.map +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -262,15 +262,17 @@ REPL 当前注册的内置工具:
|
|
|
262
262
|
|
|
263
263
|
### 命令执行
|
|
264
264
|
|
|
265
|
-
`exec_command` 根据平台和 `shell` 参数选择 PowerShell、cmd、bash 或 sh。命令启动后持续收集输出;首次等待期内结束则直接返回,仍在运行则返回 `session_id
|
|
265
|
+
`exec_command` 根据平台和 `shell` 参数选择 PowerShell、cmd、bash 或 sh。命令启动后持续收集输出;首次等待期内结束则直接返回,仍在运行则返回 `session_id`,进程不会依赖当前模型轮次存活。`timeout_ms` 约束命令进入后台前的前台阶段;一旦命令让出成为后台终端,超时计时器会被清除,任务将持续运行到自行退出、显式停止或宿主进程关闭。
|
|
266
266
|
|
|
267
267
|
- `workdir`:命令工作目录。
|
|
268
|
-
- `timeout_ms
|
|
268
|
+
- `timeout_ms`:命令进入后台前的前台阶段超时上限;后台任务不设自动超时。
|
|
269
269
|
- `yield_time_ms`:首次等待时间;到期后将仍在运行的命令交还为后台终端。
|
|
270
270
|
- `max_output_chars`:分别限制每次待读取的 stdout/stderr,超限时保留开头和结尾。
|
|
271
271
|
- `tty=true`:通过 PTY/ConPTY 运行需要真实终端语义的交互程序。
|
|
272
272
|
|
|
273
|
-
`
|
|
273
|
+
`stdout`、`stderr`、`output_chars` 和 `omitted_chars` 都是本次调用新消费的增量;调用方应追加保存,重复查询终态不会返回已经读取的输出。`duration_ms` 是进程实际运行时间,进入终态后保持不变。每个终态都通过 `termination_reason` 区分正常完成、非零退出、用户中断、用户终止、强制停止、超时、外部信号和启动错误。Windows TTY 优先返回终端进程 PID;底层无法提供时返回 PTY 宿主 PID,不返回 `0`。TTY 输出可能包含 ANSI/VT 控制序列,后端会原样保留供终端界面解释。
|
|
274
|
+
|
|
275
|
+
`write_stdin` 使用 `session_id` 续接后台终端:空字符用于等待并读取新增输出,非空字符原样写入终端,也可发送 interrupt、terminate 或 kill。不同终端可并行执行,同一终端的交互按调用顺序串行处理。并行工具批次采用聚合返回语义:单个调用的 `yield_time_ms` 只约束该调用自身,不约束整批结果的交付时间;需要观察精确状态时序时应串行调用 `exec_command` 与 `write_stdin`。
|
|
274
276
|
|
|
275
277
|
## 上下文与压缩
|
|
276
278
|
|
|
@@ -284,7 +286,7 @@ REPL 当前注册的内置工具:
|
|
|
284
286
|
压缩实现位于 `src/context/compaction.ts`:
|
|
285
287
|
|
|
286
288
|
- `DeterministicCompactor` 提供可预测的 snip、microcompact、summary fallback。
|
|
287
|
-
- 默认运行时使用 `
|
|
289
|
+
- 默认运行时使用 `ModelDrivenCompactor`:达到上下文窗口阈值时主动压缩,模型返回上下文超限错误时执行响应式压缩并重试;如需仅允许手动压缩,可显式注入 `ManualOnlyCompactor`。
|
|
288
290
|
- 当工具结果过大时,session 模式下 `FileToolResultMemory` 会把完整结果写入文件,仅把预览和路径留在上下文中。
|
|
289
291
|
|
|
290
292
|
## 会话持久化
|
|
@@ -404,6 +406,40 @@ const canUseTool = createSkillAwareCanUseTool(skills, parentCanUseTool);
|
|
|
404
406
|
|
|
405
407
|
建议:开放 `skill_create`/`skill_update` 给模型时保持 approval;对 remote/plugin skill 使用只读 root;生产环境使用 `createSkillAwareCanUseTool()` 或父级权限系统强制 `allowedTools`。
|
|
406
408
|
|
|
409
|
+
## 插件协议
|
|
410
|
+
|
|
411
|
+
Core 提供 `neo-plugin/v1` 目录资源协议和 `loadNeoPlugins()` 动态加载器。Core 只定义协议、校验并加载资源,不内置任何外部插件实现。
|
|
412
|
+
|
|
413
|
+
一个插件根目录可以包含多个直接子目录;每个插件目录必须包含 `neo-plugin.json`:
|
|
414
|
+
|
|
415
|
+
```json
|
|
416
|
+
{
|
|
417
|
+
"protocol": "neo-plugin/v1",
|
|
418
|
+
"id": "example",
|
|
419
|
+
"name": "Example",
|
|
420
|
+
"version": "1.0.0",
|
|
421
|
+
"entry": "index.mjs",
|
|
422
|
+
"defaultEnabled": true
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
入口模块导出 `createPlugin(context)` 或默认工厂函数,返回以下能力之一或多项:
|
|
427
|
+
|
|
428
|
+
- `tools`: 符合 Core `Tool` 协议的工具数组。
|
|
429
|
+
- `promptSections`: 符合 `PromptSection` 协议的系统提示词段。
|
|
430
|
+
- `route(req, res, url, helpers)`: 由嵌入后台托管的 HTTP 路由处理器。
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
import { loadNeoPlugins } from "neoctl";
|
|
434
|
+
|
|
435
|
+
const plugins = await loadNeoPlugins({
|
|
436
|
+
directories: "/absolute/path/to/plugins",
|
|
437
|
+
appDataDir: "/absolute/path/to/app-data",
|
|
438
|
+
});
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
加载器会校验清单版本、插件 id、入口边界、工具/提示词结构、插件 id 冲突和工具名冲突;不存在的插件根目录视为空目录。
|
|
442
|
+
|
|
407
443
|
## 作为库使用
|
|
408
444
|
|
|
409
445
|
包入口会导出核心 agent 编排运行时、模型网关、上下文管理、任务/子代理、工具系统、session 与 safety 边界:
|
|
@@ -9,20 +9,36 @@ export interface ContextBudgetOptions {
|
|
|
9
9
|
autoCompactTriggerRatio?: number;
|
|
10
10
|
microCompactTriggerRatio?: number;
|
|
11
11
|
snipCompactTriggerRatio?: number;
|
|
12
|
+
/** @deprecated Summary checkpoints preserve recent user messages by token budget instead. */
|
|
12
13
|
keepRecentMessages?: number;
|
|
13
14
|
keepRecentTokenBudget?: number;
|
|
14
15
|
keepRecentToolResults?: number;
|
|
16
|
+
/** Character budget for deterministic fallback, snip, and pure summaries. Model summaries use compactMaxOutputTokens. */
|
|
15
17
|
summaryMaxChars?: number;
|
|
18
|
+
/** @deprecated Checkpoint summaries serialize the complete pre-compaction window. */
|
|
19
|
+
compactInputMaxChars?: number;
|
|
16
20
|
compactModel?: string;
|
|
17
21
|
compactMaxOutputTokens?: number;
|
|
18
22
|
}
|
|
19
23
|
export type CompactionReason = "none" | "snip" | "microcompact" | "autocompact" | "reactive_compact" | "manualcompact" | "purecompact";
|
|
24
|
+
export interface CompactionReport {
|
|
25
|
+
reason: Exclude<CompactionReason, "none">;
|
|
26
|
+
summary: string;
|
|
27
|
+
continuationState: string;
|
|
28
|
+
sourceMessages: number;
|
|
29
|
+
preservedUserMessages: number;
|
|
30
|
+
newWindowMessages: number;
|
|
31
|
+
charsFreed: number;
|
|
32
|
+
modelDriven: boolean;
|
|
33
|
+
imageCount: number;
|
|
34
|
+
}
|
|
20
35
|
export interface CompactionResult {
|
|
21
36
|
messages: Message[];
|
|
22
37
|
summary?: string;
|
|
23
38
|
changed: boolean;
|
|
24
39
|
reason?: CompactionReason;
|
|
25
40
|
charsFreed?: number;
|
|
41
|
+
report?: CompactionReport;
|
|
26
42
|
/** @deprecated Use charsFreed instead. Alias kept for backward compatibility. */
|
|
27
43
|
tokensFreed?: number;
|
|
28
44
|
}
|
|
@@ -41,13 +57,12 @@ export declare class DeterministicCompactor implements Compactor {
|
|
|
41
57
|
}
|
|
42
58
|
export declare class ModelDrivenCompactor implements Compactor {
|
|
43
59
|
private readonly modelGateway;
|
|
44
|
-
private readonly fallback;
|
|
45
60
|
constructor(modelGateway: ModelGateway);
|
|
46
61
|
compact(messages: readonly Message[], options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
47
62
|
manualCompact(messages: readonly Message[], options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
48
63
|
pureCompact(messages: readonly Message[], options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
49
|
-
reactiveCompact(messages: readonly Message[],
|
|
50
|
-
private
|
|
64
|
+
reactiveCompact(messages: readonly Message[], _error: Error, options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
65
|
+
private createCheckpoint;
|
|
51
66
|
private summarizeWithModel;
|
|
52
67
|
}
|
|
53
68
|
export declare class NoopCompactor implements Compactor {
|
|
@@ -67,7 +82,8 @@ export declare class ManualOnlyCompactor implements Compactor {
|
|
|
67
82
|
pureCompact(messages: readonly Message[], options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
68
83
|
reactiveCompact(messages: readonly Message[], _error: Error, _options?: ContextBudgetOptions): Promise<CompactionResult>;
|
|
69
84
|
}
|
|
85
|
+
export declare function withCompactionReport(result: CompactionResult, sourceMessages: number): CompactionResult;
|
|
70
86
|
export declare function estimateMessagesChars(messages: readonly Message[]): number;
|
|
71
87
|
export declare function snipCompactIfNeeded(messages: readonly Message[], options?: ContextBudgetOptions): CompactionResult;
|
|
72
88
|
export declare function microCompactIfNeeded(messages: readonly Message[], options?: ContextBudgetOptions): CompactionResult;
|
|
73
|
-
export declare function autoCompactIfNeeded(messages: readonly Message[], options?: ContextBudgetOptions): CompactionResult;
|
|
89
|
+
export declare function autoCompactIfNeeded(messages: readonly Message[], options?: ContextBudgetOptions, sourceMessages?: readonly Message[]): CompactionResult;
|