@linnlabs/linnkit 0.44.0 → 0.46.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/CHANGELOG.md +48 -0
- package/dist/cli.cjs +61 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +61 -8
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +2 -1
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +2 -1
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +62 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -8
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +61 -8
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +61 -8
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +3 -0
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +3 -0
- package/dist/runtime-kernel/graph-engine/types.d.cts +1 -3
- package/dist/runtime-kernel/graph-engine/types.d.ts +1 -3
- package/dist/runtime-kernel/tools/toolContextRuntime.d.cts +1 -1
- package/dist/runtime-kernel/tools/toolContextRuntime.d.ts +1 -1
- package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +10 -0
- package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +10 -0
- package/dist/runtime-kernel.cjs +62 -8
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +62 -8
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +62 -8
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +62 -8
- package/dist/testkit.js.map +1 -1
- package/docs/integration/agent-registration-guide.md +1 -1
- package/docs/integration/context-engineering.md +5 -5
- package/docs/integration/run-supervisor.md +1 -0
- package/docs/integration/tool-development-guide.md +4 -2
- package/package.json +2 -1
|
@@ -171,7 +171,7 @@ defineContextPolicy({
|
|
|
171
171
|
- `keepLatestToolGroups` 保护最近完整工具组;附件和不完整工具组也不进入可替换区段。
|
|
172
172
|
- `maxOutputTokens` 限制本次压缩输出;`maxCompactionsPerRun` 限制单次 run 真正到达 Provider 的压缩 attempt,失败调用也会消耗这项产品护栏。
|
|
173
173
|
- 压缩不增加 Agent 、工具或 Graph 节点,不重置步数预算,前端也无需新的配置与交互。
|
|
174
|
-
- System Reminder 的普通 tick 与压缩专用位置合同见 [
|
|
174
|
+
- System Reminder 的普通 tick 与压缩专用位置合同见 [Context Engineering §6](./context-engineering.md#6-system-reminder注册表--agentspec-已接线-有一项不开放)。
|
|
175
175
|
|
|
176
176
|
---
|
|
177
177
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
> 本文是一份**全机制速查表**:列出 linnkit 当前所有作用在"发给 LLM 的 messages"上的机制,**说人话**讲清楚它在做什么、什么时候触发、在哪里改它、当前可以配到什么粒度。
|
|
12
12
|
>
|
|
13
13
|
> 想看 fence 一等接入面的具体落地骨架,跳到 [`context-fences.md`](./context-fences.md)。
|
|
14
|
-
> 想看 context-manager 的代码层架构、三阶段 provider
|
|
14
|
+
> 想看 context-manager 的代码层架构、三阶段 provider 与预处理器实现,读 GitHub 上的 [`src/context-manager/`](https://github.com/linnlabs/linnkit/tree/main/src/context-manager) 源码与测试。
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -54,7 +54,7 @@ Tool definitions 会先从有效输入预算扣除,剩余的 `messageBudgetTok
|
|
|
54
54
|
- 定义 agent 与 `defineContextPolicy()`:[`agent-registration-guide.md §4`](./agent-registration-guide.md)
|
|
55
55
|
- 工具历史窗口:[`tool-history.md`](./tool-history.md)
|
|
56
56
|
- fence / must-keep 注入:[`context-fences.md`](./context-fences.md)
|
|
57
|
-
-
|
|
57
|
+
- 代码层实现:GitHub 上的 [`src/context-manager/`](https://github.com/linnlabs/linnkit/tree/main/src/context-manager) 源码与测试
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
@@ -360,7 +360,7 @@ System Reminder 是统一的 `<system-reminder>...</system-reminder>` 瞬态控
|
|
|
360
360
|
|
|
361
361
|
`R′` 不是从旧 Prompt 复制出来的文本。运行时会用相同的 `request`、`history`、`executorLocal` 和 reminder policy 重新执行一次注册规则;符合纯函数合同的规则应得到与 `R` 等价、通常逐字相同的内容,但它会被追加到**重建后**的最后一条 message。专用 `C` 不进入重建后的主调用。若原 phase 是强制收尾,phase 与 tool choice 也保持不变。随后整份 Prompt 必须重新计量并通过容量门禁。
|
|
362
362
|
|
|
363
|
-
|
|
363
|
+
模块维护者以 GitHub 上的 [`src/runtime-kernel/system-reminder/`](https://github.com/linnlabs/linnkit/tree/main/src/runtime-kernel/system-reminder) 源码与测试为准;接入方不要绕过 Graph stage 手工拼接 Reminder。
|
|
364
364
|
|
|
365
365
|
**触发方式**:framework 内置 4 条规则,按顺序判定:
|
|
366
366
|
|
|
@@ -372,7 +372,7 @@ System Reminder 是统一的 `<system-reminder>...</system-reminder>` 瞬态控
|
|
|
372
372
|
| `periodic_progress_reflection` | `stepCount` 是 30 的倍数 | 长程任务定期反思 |
|
|
373
373
|
|
|
374
374
|
`phase` 只在实际进入 LLM 节点时决定工具视图;步数策略不得覆盖 ToolNode 或删除已经接受的工具批次。
|
|
375
|
-
|
|
375
|
+
例:`maxSteps = 800` 时,`stepCount = 798` 进入 LLM 仍是 `running`(剩 2 步,还能完成一次 ToolNode → LLM 闭环);`stepCount = 799` 进入 LLM 改为 `force_final_answer`(只剩 1 步,禁用工具);`stepCount = 800` 时若停在已经接受的 ToolNode,这批工具照常执行,pending batch 不丢弃。
|
|
376
376
|
|
|
377
377
|
**配置开放状态**:
|
|
378
378
|
|
|
@@ -480,7 +480,7 @@ Host 仍必须让 `assistant_part_end.text` 与该 part 已发送的 `thought_de
|
|
|
480
480
|
| `context_injection` / `task_request` | 当前没有 per-fence 硬上限 | `FenceDescriptor.maxBudgetFraction` 目前只校验声明,尚未形成运行时裁决;当前只受最终总门禁约束 | [Context Fence](./context-fences.md) |
|
|
481
481
|
| `thought` / canonical reasoning | `thought` 不进入模型输入;reasoning 与其他 Assistant 输出共享 `outputLimitTokens` | 全量 reasoning 通过所属 `assistant_replay_parts` 回放并计入消息 token,直到正式压缩替换 | [Reasoning 所有权 §8](#reasoning-retention) |
|
|
482
482
|
| `final_answer` / `tool_code` / `task_completion` | 无独立 token 上限 | 当前一次模型生成共享 `outputLimitTokens`;历史消息按工作记忆预算取舍 | [Token 管理](./token-management.md) |
|
|
483
|
-
| `tool_calls` | 与 thought / text 共享本次生成的 `outputLimitTokens`,没有第二份独立上限 | 普通 route 会把上限发给 Provider;ChatGPT Codex 订阅 route 按其客户端合同省略 wire 上限,只保留本地预算预留。进入历史后与全部 sibling `tool_output` 整组同进同退 | [Tool History](./tool-history.md)
|
|
483
|
+
| `tool_calls` | 与 thought / text 共享本次生成的 `outputLimitTokens`,没有第二份独立上限 | 普通 route 会把上限发给 Provider;ChatGPT Codex 订阅 route 按其客户端合同省略 wire 上限,只保留本地预算预留。进入历史后与全部 sibling `tool_output` 整组同进同退 | [Tool History](./tool-history.md);Provider 的模型目录与上限由 host 提供 |
|
|
484
484
|
| `tool_output` | 默认在超过 20,000 字符或 1,200 行时落盘并替换为 preview | 这是执行期字符/行阈值,不是 token 上限;preview 仍受最终总门禁约束 | [Tools](./tools.md) |
|
|
485
485
|
| `user_input` / `tool_output` 的图片附件 | Linnkit 不固定数量、字节或分辨率上限 | Host 的 `LlmInputMaterializerPort` / route profile 负责 admission;图片 token 估算计入最终输入,附件随所属消息或完整工具组同进同退 | [图片输入](./llm-provider.md#5-图片输入) |
|
|
486
486
|
| `<system-reminder>` | 无独立 token 上限 | 普通 Reminder 拼入末条 content;压缩专用 Reminder 是独立末尾 wire 消息。两者都重新计量并接受同一总门禁 | [System Reminder §6](#system-reminder) |
|
|
@@ -54,6 +54,7 @@ const handle = await supervisor.registerRun({
|
|
|
54
54
|
- transport `EventBus.close()` 不等于 run 终态。`awaiting_user` 会保留 handle/slot;恢复时 `claimResume.activate()` 把同一 RunHandle 换绑到新的 transport EventBus,并轮换 execution controller,`observeRun()` 可跨 transport 连续观察。同步 run 在 completed/failed/cancelled 后释放;detached 取消还必须等 executor settlement。
|
|
55
55
|
- detached run 执行中如果 EventBus 提前 close,不会提前释放 active slot,避免后台 run 绕过并发限制;slot 会等 detached executor 终态 cleanup。
|
|
56
56
|
- `pause()` 先持久化暂停意图,再以 `RunPauseRequested` 中断当前 attempt;此时 `status=paused` 且 `pausedAt` 缺失,表示仍在收口。Host 保存断点、收口当前 execution 后调用 `markPaused()`,才允许 `resumePausedRun()` 激活。它不创建用户消息,也不提交任何审批。
|
|
57
|
+
- 收口不依赖工具配合:暂停或取消信号发出后,`ToolNode` 最多再等 `abortGraceMs`(默认 3 秒)。工具仍未结束就按 AbortError 处理,与工具自己响应停止走同一路径:暂停时当前调用留待继续前对账,取消时结算为已取消;迟到的结果丢弃,不进入历史。期限只从停止信号发出时计时,不限制工具正常运行时长。被放弃的工具若仍在后台运行,其副作用由 Host 的对账负责。
|
|
57
58
|
- 面向异步客户端的暂停使用 `pause(runId, reason, expectedExecutionId)`;execution 身份在控制锁内核对,排队期间已经发生的继续不能被旧暂停命令中断。
|
|
58
59
|
- `resumePausedRun({ runId, expectedUpdatedAt, executionId, eventBus })` 保留同一 run 并轮换 execution identity / signal。Host 必须先完成前一 execution 的收口,之后再启动 Graph `continueSession`。原本抛 NotImplementedError 的 `RunHandle.resume()` 已移除,避免把“改状态”误当成“调度 Graph”。`runTree/handleFailure` 仍未实现。
|
|
59
60
|
|
|
@@ -411,10 +411,12 @@ const result: StructuredToolResult<{ report: string }> = {
|
|
|
411
411
|
|
|
412
412
|
host 必须通过 `ToolModelInputResolverPort` 把 selection 解析为当前 conversation/project 有权引用的 durable 图片身份。任一 selection 的 scope 或完整性失败时,整个工具结果失败,不产生半组附件。
|
|
413
413
|
|
|
414
|
-
**是否返回图片由 Host 决定,linnkit 不判断。** 工具调用可能来自模型,也可能来自没有模型的 Host 主动调用(CLI、外部 Agent、测试),只有 Host 知道这次结果交给谁、对方能不能看图。因此 linnkit 不在工具定义上声明图片要求,ToolNode 执行前不查模型、不做能力校验,也不向工具写入准入事实。Host 应在装配 `ToolExecutionContext`
|
|
414
|
+
**是否返回图片由 Host 决定,linnkit 不判断。** 工具调用可能来自模型,也可能来自没有模型的 Host 主动调用(CLI、外部 Agent、测试),只有 Host 知道这次结果交给谁、对方能不能看图。因此 linnkit 不在工具定义上声明图片要求,ToolNode 执行前不查模型、不做能力校验,也不向工具写入准入事实。ToolNode 只在 `ToolExecutionContext.activeModelId` 写入工具结果接下来交给的模型:平时等于 `modelId`,云端额度兜底后 run 锁定到兜底模型,此时是兜底模型。Host 应在装配 `ToolExecutionContext` 时提供自己的判断(例如按 `activeModelId` 和模型目录,或对外部调用方默认接收图片;不要按 `modelId` 判断,兜底后它仍是原选定模型),工具据此决定是否创建 selection 和临时授权;不接收时返回完整的文字与结构化主结果,不要先登记资源再靠失败降级。ToolNode 对工具返回的 selection 一律交给 resolver。
|
|
415
415
|
|
|
416
416
|
真正发往模型时,LLM 调用前的 input preflight 仍按实际请求中的图片和当前 route 校验;Host 判断失误会在那里明确失败,而不是静默丢图。
|
|
417
417
|
|
|
418
|
+
preflight 只是最后一道检查,不能代替 Host 的判断:走到 preflight 时工具已经执行完,副作用已经发生,图片也已作为工具结果写进对话历史。此后只要 route 仍不支持图片,这个对话的每一次 LLM 调用都会在 preflight 失败。所以 Host 必须在工具执行前按实际要调用的模型决定是否返回图片。
|
|
419
|
+
|
|
418
420
|
幂等历史命中时,ToolNode 复用该输出当时已解析的正式附件,不重跑有副作用的工具。root 与 child runtime 应注入同一类窄 resolver,child 仍受自己的模型和附件继承策略约束。
|
|
419
421
|
|
|
420
422
|
---
|
|
@@ -515,4 +517,4 @@ const toolRuntime = new QuickstartMemoryToolRuntime([
|
|
|
515
517
|
- [`context-engineering.md`](./context-engineering.md) — 10 大分组 `contextPolicy` 总览,含 `toolOutput.observationGovernance`
|
|
516
518
|
- [`audit.md`](./audit.md) — tool retry / tool deny 等审计决策
|
|
517
519
|
- [`testing.md`](./testing.md) — testkit 提供的 26 条 strict invariants(含工具相关的 C10)
|
|
518
|
-
- [
|
|
520
|
+
- GitHub 上的 [`src/runtime-kernel/tools/`](https://github.com/linnlabs/linnkit/tree/main/src/runtime-kernel/tools) — runtime-kernel Tool 合同与幂等 owner 的源码与测试
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linnlabs/linnkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A fine-grained context engineering framework for Agent applications — control every token sent to the model, with clear run lifecycle, audit records, and testable protocol boundaries.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"prepublishOnly": "npm run build:clean && npm run build && npm run test:smoke && npm run test:smoke:dist",
|
|
83
83
|
"publish:npm": "npm publish",
|
|
84
84
|
"publish:dry-run": "npm pack --dry-run",
|
|
85
|
+
"check:docs": "node scripts/check-markdown-links.ts",
|
|
85
86
|
"typecheck": "tsc --noEmit -p tsconfig.src.json && tsc --noEmit -p tsconfig.json",
|
|
86
87
|
"test": "vitest run",
|
|
87
88
|
"test:smoke": "vitest run __tests__/package.shell.test.ts",
|