@linnlabs/linnkit 0.45.0 → 0.47.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/cli.cjs +65 -243
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +65 -243
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +7 -6
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +7 -6
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/index.cjs +75 -253
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +75 -253
  13. package/dist/index.js.map +1 -1
  14. package/dist/ports/llm-call.d.cts +2 -16
  15. package/dist/ports/llm-call.d.ts +2 -16
  16. package/dist/quickstart.cjs +65 -243
  17. package/dist/quickstart.cjs.map +1 -1
  18. package/dist/quickstart.js +65 -243
  19. package/dist/quickstart.js.map +1 -1
  20. package/dist/runtime-kernel/graph-engine/executor.d.cts +0 -2
  21. package/dist/runtime-kernel/graph-engine/executor.d.ts +0 -2
  22. package/dist/runtime-kernel/graph-engine/types.d.cts +1 -4
  23. package/dist/runtime-kernel/graph-engine/types.d.ts +1 -4
  24. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.cts +1 -2
  25. package/dist/runtime-kernel/llm/definitions/llmFallbackObserver.d.ts +1 -2
  26. package/dist/runtime-kernel/llm/modelCatalog.d.cts +2 -3
  27. package/dist/runtime-kernel/llm/modelCatalog.d.ts +2 -3
  28. package/dist/runtime-kernel.cjs +75 -253
  29. package/dist/runtime-kernel.cjs.map +1 -1
  30. package/dist/runtime-kernel.js +75 -253
  31. package/dist/runtime-kernel.js.map +1 -1
  32. package/dist/testkit.cjs +83 -261
  33. package/dist/testkit.cjs.map +1 -1
  34. package/dist/testkit.js +83 -261
  35. package/dist/testkit.js.map +1 -1
  36. package/docs/integration/agent-registration-guide.md +1 -1
  37. package/docs/integration/context-engineering.md +5 -5
  38. package/docs/integration/llm-provider.md +1 -1
  39. package/docs/integration/tool-development-guide.md +4 -2
  40. 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 与压缩专用位置合同见 [`runtime-kernel/system-reminder/README.md`](../../src/runtime-kernel/system-reminder/README.md)。
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 与预处理器实现细节,读 [`src/context-manager/README.md`](../../src/context-manager/README.md)。
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
- - 代码层实现说明:[`src/context-manager/README.md`](../../src/context-manager/README.md)
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
- 模块维护者还必须阅读 [`runtime-kernel/system-reminder/README.md`](../../src/runtime-kernel/system-reminder/README.md)。那里规定 owner、文件职责、扩展方式与验证门禁;接入方不要绕过 Graph stage 手工拼接 Reminder。
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
- 完整边界与 798→799→800 示例见 [Graph Engine §2.2](../../src/runtime-kernel/graph-engine/README.md#22-步数预算与收尾)。
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) / [Provider catalog](../../../../docs/source-acquisition/provider-catalog.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) |
@@ -12,7 +12,7 @@
12
12
  `LlmCaller` 仍然属于 Linnkit 内核,它拥有:
13
13
 
14
14
  - 输入能力校验、每次 attempt 的图片物化与总调用预算;
15
- - 同模型重试、产品已批准的模型 fallback 和 Cloud quota 续跑策略;
15
+ - 同模型重试与 Host 策略批准的模型 fallback;
16
16
  - canonical stream 到 AgentEvent / RuntimeEvent 的唯一映射;
17
17
  - thought、answer、tool call、usage 和 continuation 的持久化语义。
18
18
 
@@ -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` 时提供自己的判断(例如按本 run 的模型和模型目录,或对外部调用方默认接收图片),工具据此决定是否创建 selection 和临时授权;不接收时返回完整的文字与结构化主结果,不要先登记资源再靠失败降级。ToolNode 对工具返回的 selection 一律交给 resolver。
414
+ **是否返回图片由 Host 决定,linnkit 不判断。** 工具调用可能来自模型,也可能来自没有模型的 Host 主动调用(CLI、外部 Agent、测试),只有 Host 知道这次结果交给谁、对方能不能看图。因此 linnkit 不在工具定义上声明图片要求,ToolNode 执行前不查模型、不做能力校验,也不向工具写入准入事实。Host 应在装配 `ToolExecutionContext` 时提供自己的判断(例如按本 run 的模型 `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
- - [`../../src/runtime-kernel/tools/README.md`](../../src/runtime-kernel/tools/README.md) — runtime-kernel Tool 合同与幂等 owner
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.45.0",
3
+ "version": "0.47.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",