@linnlabs/linnkit 0.41.0 → 0.42.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 +25 -0
- package/dist/cli.cjs +5 -201
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +5 -201
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +0 -1
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +0 -1
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +6 -211
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -211
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +5 -201
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +5 -201
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +1 -3
- package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +1 -3
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.cts +1 -3
- package/dist/runtime-kernel/graph-engine/nodes/toolNode.d.ts +1 -3
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.cts +1 -2
- package/dist/runtime-kernel/testkit/defaultGraphExecutor.d.ts +1 -2
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.cts +1 -2
- package/dist/runtime-kernel/testkit/graphLoopHarness.d.ts +1 -2
- package/dist/runtime-kernel/tools/index.d.cts +1 -2
- package/dist/runtime-kernel/tools/index.d.ts +1 -2
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.cts +4 -3
- package/dist/runtime-kernel/tools/model-input/orchestration/resolveToolModelInput.d.ts +4 -3
- package/dist/runtime-kernel/tools/ports.d.cts +1 -28
- package/dist/runtime-kernel/tools/ports.d.ts +1 -28
- 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/toolContracts.d.cts +0 -6
- package/dist/runtime-kernel/tools/toolContracts.d.ts +0 -6
- package/dist/runtime-kernel/tools/toolExecutionContext.d.cts +0 -7
- package/dist/runtime-kernel/tools/toolExecutionContext.d.ts +0 -7
- package/dist/runtime-kernel.cjs +5 -206
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +1 -2
- package/dist/runtime-kernel.d.ts +1 -2
- package/dist/runtime-kernel.js +5 -206
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.cts +1 -1
- package/dist/testkit/agent-harness/scriptedInferenceHarness.d.ts +1 -1
- package/dist/testkit.cjs +5 -206
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +5 -206
- package/dist/testkit.js.map +1 -1
- package/docs/integration/tool-development-guide.md +7 -23
- package/docs/integration/tools.md +2 -5
- package/package.json +2 -2
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.cts +0 -17
- package/dist/runtime-kernel/tools/model-input/definitions/toolModelInputPolicy.d.ts +0 -17
|
@@ -408,29 +408,13 @@ const result: StructuredToolResult<{ report: string }> = {
|
|
|
408
408
|
|
|
409
409
|
工具不能直接返回 durable attachment,更不能返回本地路径、bytes、base64、hash 或 data URL。工具只在 `StructuredToolResult.modelInput.attachments` 中返回有序 asset selection;selection 只包含调用内 ID、稳定 asset URI 和可选展示标签。
|
|
410
410
|
|
|
411
|
-
host 必须通过 `ToolModelInputResolverPort` 把 selection 解析为当前 conversation/project 有权引用的 durable
|
|
411
|
+
host 必须通过 `ToolModelInputResolverPort` 把 selection 解析为当前 conversation/project 有权引用的 durable 图片身份。任一 selection 的 scope 或完整性失败时,整个工具结果失败,不产生半组附件。
|
|
412
412
|
|
|
413
|
-
|
|
413
|
+
**是否返回图片由 Host 决定,linnkit 不判断。** 工具调用可能来自模型,也可能来自没有模型的 Host 主动调用(CLI、外部 Agent、测试),只有 Host 知道这次结果交给谁、对方能不能看图。因此 linnkit 不在工具定义上声明图片要求,ToolNode 执行前不查模型、不做能力校验,也不向工具写入准入事实。Host 应在装配 `ToolExecutionContext` 时提供自己的判断(例如按本 run 的模型和模型目录,或对外部调用方默认接收图片),工具据此决定是否创建 selection 和临时授权;不接收时返回完整的文字与结构化主结果,不要先登记资源再靠失败降级。ToolNode 对工具返回的 selection 一律交给 resolver。
|
|
414
414
|
|
|
415
|
-
|
|
416
|
-
`tool_result_image`;反过来也一样。产品不得为了让动态图片工具继续运行而把工具结果改写成 user message。动态图片结果
|
|
417
|
-
若属于主操作的必要输入,缺少 `tool_result_image` 时返回结构化 placement error;若只是可选增强,则使用下述
|
|
418
|
-
`when_supported` 合同。
|
|
415
|
+
真正发往模型时,LLM 调用前的 input preflight 仍按实际请求中的图片和当前 route 校验;Host 判断失误会在那里明确失败,而不是静默丢图。
|
|
419
416
|
|
|
420
|
-
|
|
421
|
-
`modelInputDelivery='when_supported'`。这类工具对不兼容模型仍然可见并可执行;ToolNode 根据最近一次
|
|
422
|
-
成功 LLM attempt 的真实模型和 route 写入 `ToolExecutionContext.modelInputAdmission`。工具必须在
|
|
423
|
-
`admitted=true` 时才创建 selection 及其临时授权;`admitted=false` 时返回完整的文字与结构化主结果,
|
|
424
|
-
不得先登记资源再靠 resolver capability error 降级。未配置 validator、模型不具备聊天资格、selection
|
|
425
|
-
越权或内容损坏都不属于“模型不支持图片”的正常分支,仍须明确失败。
|
|
426
|
-
|
|
427
|
-
`when_supported` 的增强附件也不属于工具幂等主结果。历史成功输出若来自视觉模型,当前非视觉模型
|
|
428
|
-
命中缓存时只复用文字与结构化主结果,不能复用旧附件;当前视觉模型命中一条没有附件的历史结果时,
|
|
429
|
-
也不为它补跑有副作用的工具或额外生成附件。
|
|
430
|
-
|
|
431
|
-
动态工具的 `resolveModelInputRequirement(args)` 必须是只依赖规范化参数的确定性规则,不得执行 I/O。若 resolver 抛错,ToolNode 会把本次 call 作为 capability deny,生成稳定的 error `tool_output` 和 `tool.deny` 审计后继续消费同批 sibling calls;宿主异常原文不会回显给模型。resolver 不能用异常表达“本次不需要图片”,该场景应正常返回 `undefined`。
|
|
432
|
-
|
|
433
|
-
历史 cache hit 不能直接复用旧 durable ref。它应复用原始结构化输出,再按当前 workspace scope 重新解析 selection;selection 已失效时明确失败,不能重跑有副作用的工具,也不能退化成“文本成功、图片丢失”。root 与 child runtime 应注入同一类窄 resolver/validator,child 仍受自己的模型和附件继承策略约束。
|
|
417
|
+
幂等历史命中时,ToolNode 复用该输出当时已解析的正式附件,不重跑有副作用的工具。root 与 child runtime 应注入同一类窄 resolver,child 仍受自己的模型和附件继承策略约束。
|
|
434
418
|
|
|
435
419
|
---
|
|
436
420
|
|
|
@@ -492,7 +476,7 @@ const toolRuntime = new QuickstartMemoryToolRuntime([
|
|
|
492
476
|
| 工具配对一致性 | linnkit 协议层 | tool 配对不变量 C10 + `ToolReplayProtocolGuard` |
|
|
493
477
|
| 交互工具的 wait_user 路由 | linnkit 协议层 | `WaitUserNode` + `requires_user_interaction` 事件 |
|
|
494
478
|
| 工具图片 selection 与解析 | host 工具 + host resolver | `StructuredToolResult.modelInput` + `ToolModelInputResolverPort` |
|
|
495
|
-
|
|
|
479
|
+
| 是否返回工具图片 | host | Host 装配的 ToolContext 判断;linnkit 不规定 |
|
|
496
480
|
| `data` 字段名约定 / 前端 registry 注册 | host(工具作者 + 前端工程师)| linnkit 不规定 |
|
|
497
481
|
| 工具的业务实现(数据库 / 外部服务调用)| host | linnkit 不规定 |
|
|
498
482
|
|
|
@@ -514,8 +498,8 @@ const toolRuntime = new QuickstartMemoryToolRuntime([
|
|
|
514
498
|
- [ ] 实现 `getExecutionSummary(output)`,给 ToolHistoryCompressor 用
|
|
515
499
|
- [ ] 不在工具内部做超长截断 / 落盘——交给 `ObservationPreviewPort`
|
|
516
500
|
- [ ] 如果是交互工具:第一段返回 `result.control.requireUser = true`,复活路径只从 `tool_call.arguments` 重建
|
|
517
|
-
- [ ] 如果工具让模型读取图片:只返回稳定 asset selection,并验证 scope、cache replay
|
|
518
|
-
- [ ]
|
|
501
|
+
- [ ] 如果工具让模型读取图片:只返回稳定 asset selection,并验证 scope、cache replay 和附件顺序
|
|
502
|
+
- [ ] 是否返回图片按 Host 提供的判断决定,在创建受管副本/临时授权之前判断
|
|
519
503
|
- [ ] 单测用 `createToolContextFixture()` 直接测 `tool.run(args, fixtureContext)`
|
|
520
504
|
- [ ] 深层 admission 另有真实 `ToolNode + ToolRuntimeDefinition.validateArguments` 用例,证明错误参数不会发布 start 或进入 execute
|
|
521
505
|
- [ ] 在 host 的 `ToolRuntimePort` 实例化里注册
|
|
@@ -32,12 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
如果工具 Schema 依赖本次产品配置,Host 应在 `getToolSchemas(ToolSchemaBuildRequest)` 边界校验自己的扩展请求字段,再派生窄小的 Host 上下文交给具体工具。完整 query/history 不应暴露给所有 concrete/plugin tools。不要把用途模型 ID、产品模式或开放 metadata Map 加回 Linnkit;框架只拥有调用时机和通用 invocation。
|
|
34
34
|
|
|
35
|
-
工具需要把图片交给下一轮模型时,工具只返回 `StructuredToolResult.modelInput.attachments` selection;host 实现并注入 `ToolModelInputResolverPort
|
|
35
|
+
工具需要把图片交给下一轮模型时,工具只返回 `StructuredToolResult.modelInput.attachments` selection;host 实现并注入 `ToolModelInputResolverPort`,负责 scope 与完整性。linnkit 只拥有 selection 解析时机、工具配对和失败生命周期,不认识 asset 表、文件路径、具体 provider 或产品工具名。
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
`modelInputDelivery='when_supported'`:ToolNode 不会因当前模型缺少图片输入能力而隐藏或拒绝工具,
|
|
39
|
-
而会在执行期通过 `ToolExecutionContext.modelInputAdmission` 告知工具是否允许生产 selection。
|
|
40
|
-
这不是 catch 后丢附件;工具必须在创建临时授权或受管副本前读取准入事实。
|
|
37
|
+
调用方能否看图由 Host 判断,linnkit 不在工具定义上声明图片要求,也不在执行前查模型;没有模型的 Host 主动调用照常执行。完整规则见 [`tool-development-guide.md §7.4`](./tool-development-guide.md)。
|
|
41
38
|
|
|
42
39
|
## 4. 你不要做的
|
|
43
40
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linnlabs/linnkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.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",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"esbuild": "0.28.1"
|
|
113
113
|
},
|
|
114
114
|
"linnkit": {
|
|
115
|
-
"phase": "development (0.
|
|
115
|
+
"phase": "development (0.42.0 — Host-owned tool image delivery)",
|
|
116
116
|
"sourceOfTruth": "CHANGELOG.md",
|
|
117
117
|
"notes": [
|
|
118
118
|
"子入口 ./runtime-kernel/events 是 browser-safe slim seam:仅暴露 events governance 纯函数,禁止扩展任何 Node-only 依赖(如 node:async_hooks / crypto / fs)",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ModelInputRequirement } from '../../../llm/input-capabilities/definitions/modelInputCapability.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 工具结果模型输入的交付语义。
|
|
5
|
-
*
|
|
6
|
-
* `required` 表示附件是工具业务结果的一部分,当前模型不兼容时必须拒绝工具;
|
|
7
|
-
* `when_supported` 表示附件只是成功结果的增强反馈,不兼容时工具仍可返回文本结果。
|
|
8
|
-
*/
|
|
9
|
-
type ToolModelInputDelivery = 'required' | 'when_supported';
|
|
10
|
-
/** ToolNode 在真实 active model 上完成的本次调用准入事实。 */
|
|
11
|
-
interface ToolModelInputAdmission {
|
|
12
|
-
readonly requirement: ModelInputRequirement;
|
|
13
|
-
readonly delivery: ToolModelInputDelivery;
|
|
14
|
-
readonly admitted: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { ToolModelInputAdmission, ToolModelInputDelivery };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ModelInputRequirement } from '../../../llm/input-capabilities/definitions/modelInputCapability.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 工具结果模型输入的交付语义。
|
|
5
|
-
*
|
|
6
|
-
* `required` 表示附件是工具业务结果的一部分,当前模型不兼容时必须拒绝工具;
|
|
7
|
-
* `when_supported` 表示附件只是成功结果的增强反馈,不兼容时工具仍可返回文本结果。
|
|
8
|
-
*/
|
|
9
|
-
type ToolModelInputDelivery = 'required' | 'when_supported';
|
|
10
|
-
/** ToolNode 在真实 active model 上完成的本次调用准入事实。 */
|
|
11
|
-
interface ToolModelInputAdmission {
|
|
12
|
-
readonly requirement: ModelInputRequirement;
|
|
13
|
-
readonly delivery: ToolModelInputDelivery;
|
|
14
|
-
readonly admitted: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { ToolModelInputAdmission, ToolModelInputDelivery };
|