@hasna-internal/kai-tool-cordis 0.1.1-rc.2
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +104 -0
- package/README.zh.md +104 -0
- package/lib/index.js +7594 -0
- package/lib/invariant.js +23 -0
- package/lib/types/api-catalog.d.ts +96 -0
- package/lib/types/fiber-state.d.ts +28 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/inspect.d.ts +93 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/present.d.ts +91 -0
- package/lib/types/prompt.d.ts +3 -0
- package/lib/types/providers.d.ts +10 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/extensions/tool-cordis/README.md
|
|
5
|
+
README.md: 396a844014328da8cfad57fa7728793b91a9aff7
|
|
6
|
+
README.zh.md: 046f350a6314471c738691ce11249412161650e1
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @hasna-internal/kai-tool-cordis
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The self-referential Cordis toolset: five model-facing tools over the live runtime in the current DSH process. The registry, the vm sandbox, and the browser broadcast belong to [`@hasna-internal/kai-cordis-host-runner`](../cordis-host-runner/README.md) (`ctx.dynamic`), which this toolset injects — a composition with these tools but no runner never activates them. Design home — sandbox semantics, dynamic-package lifecycle and composition, standing decisions: [the toolset Agent Note](../../../.agents/notes/implemented/feature/2026-07-08-self-referential-cordis-toolset.md).
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
Two paired verbs, plus the read-only report.
|
|
10
|
+
|
|
11
|
+
- `cordis_inspect` — read-only report over the current process: services, all live plugin fibers, registered tools, this session's dynamic packages, the reflection-backed `api` / `events` references, and the compile-time `client` slot surface a browser half can contribute UI into. An exact `name` with `what: "api"`, `what: "events"`, or `what: "client"` narrows the report and adds the full contract.
|
|
12
|
+
- `cordis_define` — records a package (`name`, `purpose`, and a host half `code` and/or a browser half `client`) after syntax-checking both halves. Nothing runs; the user sees a card for it in the conversation with a start control. The minted `dyn-<n>` id rides the result value AND the durable presentation metadata, which is how that card addresses the run verbs on replay.
|
|
13
|
+
- `cordis_run` — evaluates the host half in the sandbox and delivers the browser half to every open web page. Running an already-running package re-delivers the live version instead of failing, which is how a reloaded page gets it back.
|
|
14
|
+
- `cordis_stop` — disposes the host half to quiescence and withdraws the browser half; the definition survives and can run again.
|
|
15
|
+
- `cordis_undefine` — stops the package if needed and forgets the definition; its card stays in the conversation as an unloaded record.
|
|
16
|
+
|
|
17
|
+
Exact model-facing schemas: [the generated tool catalog](../../../docs/tool-catalog.md).
|
|
18
|
+
|
|
19
|
+
Dynamic packages live only in the shared DSH process memory. They remain active across later turns and may affect other sessions in that process, but disappear after `cordis_stop`/`cordis_undefine`, toolset unload, or DSH restart. They create no Plugin file, install no package, change no `cordis.yml` or personal/project configuration, do not survive restart, and cannot be promoted automatically. To keep an experiment, ask the Agent to implement a normal local, project, or repository Plugin through the regular development workflow. Every verb is session-scoped: a package is visible and controllable only in the session that defined it.
|
|
20
|
+
|
|
21
|
+
## Trust stance
|
|
22
|
+
|
|
23
|
+
The sandbox isolates globals but is not a security boundary. Node globals are absent or redirect to Cordis services such as `ctx.fs`, `ctx.web`, and `ctx.bash`, and writes to `globalThis` stay local, but host-realm helpers make escape possible. Mounted plugins receive a façade without framework internals, yet its allowed services affect the live runtime. Dynamic tool schemas and annotations cross the realm through iterative JSON cloning and schema normalization, so valid deep declarations are memory-bounded rather than call-stack-bounded; records with JSON-invisible keys and subclassed or decorated schema arrays reject before normalization. Treat this toolset like bash access; see the [design and trust stance](../../../.agents/notes/implemented/feature/2026-07-08-self-referential-cordis-toolset.md).
|
|
24
|
+
|
|
25
|
+
## Config
|
|
26
|
+
|
|
27
|
+
None. The vm evaluation bound (`vmTimeoutMs`) and the browser acknowledgement window (`ackTimeoutMs`) belong to the runner service that owns the sandbox and the broadcast — see [`@hasna-internal/kai-cordis-host-runner`](../cordis-host-runner/README.md#config).
|
|
28
|
+
|
|
29
|
+
## The generated client slot catalog
|
|
30
|
+
|
|
31
|
+
`src/client-catalog.ts` describes the browser half's seats, generated by `scripts/gen-client-catalog.ts` (freshness-gated by `pnpm run verify-client-catalog` in `doc-sync`) from a lexical scan of every `SlotMap` declaration merge and every `slots.register` call site. It carries the one surface a browser half can act on — the slot keys, each register call's options, the props a component receives, who already occupies the seat, and which owner's mount makes the seat exist — as plain data: this package stays host-side and imports no client module, so the strings are the only thing that crosses. The generator fails loud rather than shipping an entry a model cannot act on: a slot with no registrant-facing prose, a non-literal `kind`/`scope`, owner props no export provides, a duplicate key, or a registration into an undeclared slot all break the gate. Owner props expand one level — the owner declaration with its own member documentation, and the names of the shapes its fields reference — and one slot's whole report is budget-capped, because narrowing to a single slot exists to spend less context, not more.
|
|
32
|
+
|
|
33
|
+
A slot's teaching text is its declaration's JSDoc, so improving what the model reads means editing the contract at its declaring package — not this catalog.
|
|
34
|
+
|
|
35
|
+
## Where the API report comes from
|
|
36
|
+
|
|
37
|
+
`cordis_inspect what:"api"` / `what:"events"` renders `src/api-catalog.ts`, the generated projection of the workspace's Cordis declarations: rendered method signatures, source JSDoc, harness events with their dispatch modes, and the type shapes those signatures reference, all produced by the same AST walk as `docs/subsystems`, so the data a model reads and the rendered docs cannot diverge. It is a compile-time fact about the REPOSITORY, so `pnpm run gen-cordis-api` regenerates it and `pnpm run verify-cordis-api` gates its freshness.
|
|
38
|
+
|
|
39
|
+
`src/inspect.ts` intersects that catalog with the LIVE service store: what is RUNNING comes from the store, what each service CAN DO comes from the catalog, and a live service the catalog does not cover is reported as reachable with no signatures rather than omitted. A package that needs the list in its own code copies it out of a report — the catalog is a compile-time fact about the repository, so a copied list and a freshly read one say the same thing for any one deployment.
|
|
40
|
+
|
|
41
|
+
Two model-facing judgements live in this package rather than in the artifacts, because reflection data is faithful to the code while a report has to be useful:
|
|
42
|
+
|
|
43
|
+
- **Only callable methods are shown.** Non-method members are state rather than a verb, and their rendered form carries initializers from the implementation body; symbol-keyed members are internal seams between plugins that a package façade deliberately cannot reach, so naming one would advertise a call that cannot be made.
|
|
44
|
+
- **Only keys a host half can reach are named to a model.** The reflection model covers every `ctx.<key>` a package declares, including launcher-supplied boot values (`agent`, `headlessIo`, …) and browser-half services (`connection`). `src/curation.ts` classifies each one's `reach` — `injectable`, `not-a-service`, or `other-face` — and only `injectable` keys reach a report: naming a key a package cannot reach advertises a call that cannot be made. The classification is carried as data on each catalog entry rather than applied while rendering, so the exclusion is testable on its own, and `verify-cordis-catalog` pins the classified set to exactly the keys the documentation projection does not render — a newly declared key stops the gate instead of quietly inviting a model to `inject` something that will never arrive. A classified key that nonetheless has a live provider is still reported as running and injectable: the service store is the authority on what exists.
|
|
45
|
+
|
|
46
|
+
The generated `INHERITED_CTX_API` closes the `api` report with the framework-inherited `ctx` surface (`ctx.on`, `ctx.effect`, `ctx.loader`, the timer helpers): those members are the Context itself rather than service keys, and the framework tier lives in pinned vendor packages outside every analyzed face, so the generator curates that one tier and renders it into both this catalog and `docs/cordis-api/inherited.md`. A live service the catalog does not describe is reported as running and still injectable rather than as absent. Broad `api` / `events` reports render summaries and signatures only; an exact `name` opts into the retained method/event JSDoc, and unknown or non-running service targets fail loud.
|
|
47
|
+
|
|
48
|
+
## Rendering
|
|
49
|
+
|
|
50
|
+
Every tool renders a `generic` card (`read` / `execute` / `delete`); `cordis_define` carries the submitted halves as `rawInput` and titles the card with the label and purpose. Presenters are pure functions of the args, and results keep the default text rendering. A Web client registers its own keyed `cordis_define` row (`@hasna-internal/kai-client-ui-cordis`) and reads the label, purpose, and minted id from the call arguments and the result metadata; the generic card is what a surface without that registration falls back to.
|
|
51
|
+
|
|
52
|
+
## Export shape
|
|
53
|
+
|
|
54
|
+
Namespace plugin: named exports `name` / `inject` / `apply`, no default export ([docs/postmortem/0001](../../../docs/postmortem/0001-acp-default-export-drops-inject.md)). It injects `tools` and `dynamicCordisRunner`.
|
|
55
|
+
|
|
56
|
+
## Model Experience
|
|
57
|
+
|
|
58
|
+
### Tool schemas
|
|
59
|
+
|
|
60
|
+
#### What the model sees
|
|
61
|
+
|
|
62
|
+
The conversation model sees the generated [`cordis_inspect`, `cordis_define`, `cordis_run`, `cordis_stop`, and `cordis_undefine` schemas](../../../docs/tool-catalog.md#deepseek-aidsh-tool-cordis) whenever this plugin is visible.
|
|
63
|
+
|
|
64
|
+
#### Token effect
|
|
65
|
+
|
|
66
|
+
Fixed schema cost on every request in that tool view.
|
|
67
|
+
|
|
68
|
+
#### KV Cache effect
|
|
69
|
+
|
|
70
|
+
Prefix-stable while this tool view is unchanged. Scoping or plugin lifecycle changes that hide these definitions may invalidate reuse from the first changed schema token.
|
|
71
|
+
|
|
72
|
+
### Tool-call history and results
|
|
73
|
+
|
|
74
|
+
#### What the model sees
|
|
75
|
+
|
|
76
|
+
Inspect joins selected sections exactly as `## <section>` then a newline and the data-dependent body, with one blank line between sections; `what: "temporary"` uses the `## Dynamic Packages` heading. Each row reports the id, label, purpose, which halves exist, run state and revision, provided and awaited services, registered host methods, and the last browser-half load report. The empty state explains that definitions live only in this process's memory. Broad API/event reports omit JSDoc; `name` with `what: "api"`, `what: "events"`, or `what: "client"` returns one exact target with its full contract. The `client` section lists one seat per line with its cardinality, scope, summary, and whether registering there replaces shipped UI, then the cross-cutting registrant rules; the per-seat register options, owner and framework props, and runnable example arrive only under an exact `name`. Define answers that the package is defined and NOT running yet with the id to run; run reports the revision, what the host half provides or waits for, and whether a page acknowledged the browser half; stop and undefine acknowledge in one line. Every refusal is a tool error carrying the runner's teaching text. The submitted program remains in assistant tool-call history.
|
|
77
|
+
|
|
78
|
+
#### Token effect
|
|
79
|
+
|
|
80
|
+
Inspect output and submitted package code are data-dependent and resent until compaction; lifecycle acknowledgements are small. The `client` section is bounded by the shipped slot count (two lines each) and its per-seat detail is opt-in, so the default report grows with the slot surface rather than with its documentation.
|
|
81
|
+
|
|
82
|
+
#### KV Cache effect
|
|
83
|
+
|
|
84
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
85
|
+
|
|
86
|
+
### Later requests after cordis_run
|
|
87
|
+
|
|
88
|
+
#### What the model sees
|
|
89
|
+
|
|
90
|
+
A running package may register tools, prompt contributions, or listeners that change later requests for the scopes it targets; `cordis_stop` and `cordis_undefine` remove those contributions after quiescence.
|
|
91
|
+
|
|
92
|
+
#### Token effect
|
|
93
|
+
|
|
94
|
+
Indirect token impact equals the running package's contributions and lasts only for its process-local lifetime.
|
|
95
|
+
|
|
96
|
+
#### KV Cache effect
|
|
97
|
+
|
|
98
|
+
Running or stopping a prompt or tool contribution changes later request prefixes and may invalidate reuse from the first changed contribution; an unchanged running set remains prefix-stable.
|
|
99
|
+
|
|
100
|
+
## Known Limitations and Deferred Work
|
|
101
|
+
|
|
102
|
+
- **The sandbox is containment for honest code, not a security boundary** — host-realm helpers on the sandbox global are reachable, so package code can reach Node; load this plugin as deliberately as you would grant a bash tool (see § Trust stance).
|
|
103
|
+
- **The `ctx` façade exposes no `effect()`** — package code cannot register a bespoke disposer; `on`/`provide`/`tools.register` are the supported cleanup paths.
|
|
104
|
+
- **The vm and acknowledgement bounds belong to the runner** — see its [Known Limitations](../cordis-host-runner/README.md#known-limitations-and-deferred-work); an async host-half body escapes `vmTimeoutMs`.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @hasna-internal/kai-tool-cordis
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
自引用 Cordis 工具集:五个面向模型的工具,操作当前 DSH 进程中的实时运行时。注册表、vm 沙箱与浏览器广播属于 [`@hasna-internal/kai-cordis-host-runner`](../cordis-host-runner/README.zh.md)(`ctx.dynamic`),本工具集注入它——只装这些工具而不装 runner 的组合永远不会激活它们。沙箱语义、动态包生命周期与组合及既定决策详见[工具集 Agent Note](../../../.agents/notes/implemented/feature/2026-07-08-self-referential-cordis-toolset.zh.md)。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
两组配对动词,外加只读报告。
|
|
10
|
+
|
|
11
|
+
- `cordis_inspect`:当前进程运行时的只读报告,包括服务、全部存活插件 fiber、已注册工具、本会话的动态包、反射支持的 `api`/`events` 参考,以及浏览器半可以向其贡献 UI 的编译期 `client` 槽面。精确的 `name` 配合 `what: "api"`、`what: "events"` 或 `what: "client"` 可缩窄报告,并附上完整约定。
|
|
12
|
+
- `cordis_define`:在语法预检两个半之后登记一个包(`name`、`purpose`,以及 host 半 `code` 和/或浏览器半 `client`)。此时不运行任何东西;用户会在会话里看到它的卡片和一个启动控件。铸出的 `dyn-<n>` 标识同时进入结果 value **与**持久的呈现元数据,卡片正是靠后者在 replay 中寻址运行动词。
|
|
13
|
+
- `cordis_run`:在沙箱中求值 host 半,并把浏览器半投递给每个打开的网页。对已在运行的包再次运行不会失败,而是重新投递当前版本——这正是被刷新过的页面把包取回来的方式。
|
|
14
|
+
- `cordis_stop`:把 host 半 dispose 到完全停稳,并从各页面撤回浏览器半;定义存续,可以再次运行。
|
|
15
|
+
- `cordis_undefine`:必要时先停止该包,再忘掉定义;它的卡片作为一条已卸载记录留在会话里。
|
|
16
|
+
|
|
17
|
+
面向模型的确切 schema 见[生成的工具目录](../../../docs/tool-catalog.zh.md)。
|
|
18
|
+
|
|
19
|
+
动态包只存在于共享 DSH 进程内存中。它可跨后续轮次保持活跃,也可能影响同一进程中的其他会话,但会在 `cordis_stop`/`cordis_undefine`、工具集卸载或 DSH 重启后消失。它不会创建插件文件、安装任何包、修改 `cordis.yml` 或个人/项目配置、跨重启存续,也不能自动转为正式插件。若要保留实验结果,应让 agent(智能体)通过常规开发流程实现普通的本地、项目或仓库插件。每个动词都以会话为界:一个包只在定义它的那个会话里可见、可控。
|
|
20
|
+
|
|
21
|
+
## 信任立场
|
|
22
|
+
|
|
23
|
+
该沙箱隔离全局变量,但不是安全边界。Node 全局变量不存在,或会重定向到 `ctx.fs`、`ctx.web`、`ctx.bash` 等 Cordis 服务;写入 `globalThis` 的内容保持局部,但 host realm helper 使逃逸成为可能。运行中的 host 半收到不含框架内部机制的 façade,但获准服务仍会影响存活运行时。动态工具 schema 与 annotation 通过迭代式 JSON 克隆和 schema 规范化跨越 realm,因此有效的深层声明受内存而非调用栈限制;含 JSON 不可见 key 的 record,以及子类化或装饰过的 schema array,会在规范化前被拒绝。应当像对待 bash 访问一样对待该工具集;参见[设计与信任立场](../../../.agents/notes/implemented/feature/2026-07-08-self-referential-cordis-toolset.zh.md)。
|
|
24
|
+
|
|
25
|
+
## 配置
|
|
26
|
+
|
|
27
|
+
无。vm 求值边界(`vmTimeoutMs`)与浏览器确认窗口(`ackTimeoutMs`)属于拥有沙箱与广播的 runner 服务——见 [`@hasna-internal/kai-cordis-host-runner`](../cordis-host-runner/README.zh.md#config)。
|
|
28
|
+
|
|
29
|
+
## 生成的 client 槽目录
|
|
30
|
+
|
|
31
|
+
`src/client-catalog.ts` 描述浏览器半的座位,由 `scripts/gen-client-catalog.ts` 生成(新鲜度门禁为 `doc-sync` 中的 `pnpm run verify-client-catalog`),数据来自对每一处 `SlotMap` 声明合并与每一个 `slots.register` 调用点的词法扫描。它承载浏览器半唯一能动的那个面——槽键、每个 register 调用的选项、组件会收到的 props、谁已经占着这个座位、以及哪个 owner 挂着这个座位才存在——并且只以纯数据承载:本包始终在 host 侧、不 import 任何 client 模块,跨越两平面的只有这些字符串。生成器宁可高声失败也不吐出一条模型无法照做的条目:槽缺少面向 registrant 的 JSDoc 正文、`kind`/`scope` 不是字面量、owner props 没有任何导出声明、键重复、或注册进了没人声明的槽,都会让门禁变红。owner props 只展开一层——owner 声明本身连它的成员文档,加上其字段所引用的那些形状的名字——而单个槽的整份报告有行数上限:收窄到一个槽的意义是少花上下文,不是多花。
|
|
32
|
+
|
|
33
|
+
一个槽的教学文案就是它声明处的 JSDoc,所以要改模型读到的内容,改的是声明它的那个包里的约定,而不是这份目录。
|
|
34
|
+
|
|
35
|
+
## API 报告从哪里来
|
|
36
|
+
|
|
37
|
+
`cordis_inspect what:"api"`/`what:"events"` 渲染的是 `src/api-catalog.ts`,即工作区 Cordis 声明的生成投影:渲染好的方法签名、源码 JSDoc、带分发模式的 harness 事件,以及这些签名引用到的类型形状——全部由与 `docs/subsystems` 同一次 AST 遍历产出,因此模型读到的数据与渲染出的文档不可能彼此偏离。它是关于**仓库**的编译期事实,所以用 `pnpm run gen-cordis-api` 重新生成、用 `pnpm run verify-cordis-api` 守它的新鲜度。
|
|
38
|
+
|
|
39
|
+
`src/inspect.ts` 把这份目录与**活的**服务存储取交集:**谁在跑**由存储回答,**每个服务能做什么**由目录回答;目录没覆盖到的活服务会被报成可达但没有签名,而不是被省略。包代码若要在自己源码里用这份清单,就从报告里抄出来——目录是关于仓库的编译期事实,所以对任一个部署而言,抄出来的清单与现读的清单说的是同一件事。
|
|
40
|
+
|
|
41
|
+
有两项面向模型的判断住在本包里,而不住在产物里,因为反射数据忠于代码,而报告必须有用:
|
|
42
|
+
|
|
43
|
+
- **只展示可调用的方法。** 非方法成员是状态而不是动词,而它们渲染出来的形式会带上实现体里的初始值;以 symbol 为键的成员是插件之间的内部 seam,包的 façade 刻意无法触达,所以点出其中任何一个,都等于宣传一次根本发不出的调用。
|
|
44
|
+
- **只有 host 半够得到的键,才会被点名给模型。** 反射模型覆盖包声明的每一个 `ctx.<key>`,其中包括 launcher 提供的 boot 值(`agent`、`headlessIo` 等)与浏览器半的服务(`connection`)。`src/curation.ts` 会为每一个这样的键归类它的 `reach`——`injectable`、`not-a-service` 或 `other-face`——而只有 `injectable` 的键能进报告:点名一个包够不到的键,就等于宣传一次根本发不出的调用。这份归类是作为每条目录条目上的数据携带的,而不是在渲染时才施加,因此这项排除可以单独测试;同时 `verify-cordis-catalog` 把被归类的集合钉成「文档投影不渲染的键」这个集合本身——新声明一个键会把门禁拦下来,而不是悄悄引诱模型去 `inject` 一个永远不会到来的东西。一个被归类、但确实有存活提供方的键,仍然会被报成在跑且可 inject:服务 store 才是「什么存在」的权威。
|
|
45
|
+
|
|
46
|
+
生成常量 `INHERITED_CTX_API` 为 `api` 报告收尾,列出框架继承来的 `ctx` 面(`ctx.on`、`ctx.effect`、`ctx.loader`、各 timer 辅助方法):这些成员本身就是 Context,不是某个服务键;而框架层住在 pinned vendor 包里,位于每一个被分析的契约面之外——所以生成器策展这**一层**,并把它同时渲染进本目录与 `docs/cordis-api/inherited.md`。一个活着、但目录并不描述的服务,会被报成“在跑、且仍可 inject”,而不是报成不存在。宽泛的 `api`/`events` 报告只渲染摘要与签名;精确 `name` 会选择保留的方法/事件 JSDoc,未知或未运行的服务目标会高声失败。
|
|
47
|
+
|
|
48
|
+
## 渲染
|
|
49
|
+
|
|
50
|
+
每个工具都渲染 `generic` 卡片(`read`/`execute`/`delete`);`cordis_define` 以 `rawInput` 携带提交的两个半,并用标签与用途作为卡片标题。presenter 是 args 的纯函数,结果保留默认文本渲染。Web 客户端注册自己的 keyed `cordis_define` 行(`@hasna-internal/kai-client-ui-cordis`),从调用参数与结果元数据里取标签、用途和铸出的标识;没有该注册的界面则退回到这张 generic 卡片。
|
|
51
|
+
|
|
52
|
+
## 导出形式
|
|
53
|
+
|
|
54
|
+
Namespace 插件:命名导出 `name`/`inject`/`apply`,无默认导出([docs/postmortem/0001](../../../docs/postmortem/0001-acp-default-export-drops-inject.zh.md))。它注入 `tools` 与 `dynamicCordisRunner`。
|
|
55
|
+
|
|
56
|
+
## 模型体验
|
|
57
|
+
|
|
58
|
+
### 工具 schema
|
|
59
|
+
|
|
60
|
+
#### 模型看到的内容
|
|
61
|
+
|
|
62
|
+
该插件可见时,会话模型会看到生成的 [`cordis_inspect`、`cordis_define`、`cordis_run`、`cordis_stop` 和 `cordis_undefine` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-cordis)。
|
|
63
|
+
|
|
64
|
+
#### Token 影响
|
|
65
|
+
|
|
66
|
+
该工具视图中的每次请求承担固定 schema 成本。
|
|
67
|
+
|
|
68
|
+
#### KV Cache 影响
|
|
69
|
+
|
|
70
|
+
只要该工具视图不变,前缀就保持稳定。隐藏这些定义的 scope 或插件生命周期变更,可能使从第一个变化的 schema token 起的复用失效。
|
|
71
|
+
|
|
72
|
+
### 工具调用历史与结果
|
|
73
|
+
|
|
74
|
+
#### 模型看到的内容
|
|
75
|
+
|
|
76
|
+
检查会精确地用 `## <section>` 加换行及取决于数据的正文来拼接选中区段,各区段之间留一个空行;`what: "temporary"` 使用 `## Dynamic Packages` 标题。每一行都会报告标识、标签、用途、存在哪些半、运行状态与版本号、提供和等待的服务、已注册的 host 方法,以及最后一次浏览器半装载上报;空状态说明定义只存在于本进程内存中。宽泛的 API/事件报告省略 JSDoc;`name` 配合 `what: "api"`、`what: "events"` 或 `what: "client"` 返回一个精确目标及其完整约定。`client` 区段每个座位一行,给出其基数、作用域、摘要,以及注册进去是否会替换出厂 UI,随后是跨座位通用的 registrant 纪律;每个座位的 register 选项、owner 与框架 props、可直接运行的示例,只在精确 `name` 时才吐出。define 回答该包已定义、尚未运行,并给出用于运行的标识;run 报告版本号、host 半提供或等待什么,以及是否有页面确认了浏览器半;stop 与 undefine 各以一行确认。每一次拒绝都是携带 runner 教学文案的工具错误。提交的程序保留在 assistant 工具调用历史中。
|
|
77
|
+
|
|
78
|
+
#### Token 影响
|
|
79
|
+
|
|
80
|
+
检查输出与提交的包代码取决于数据,并在压缩(compaction)前重复发送;生命周期确认文本很短。`client` 区段的体量由出厂槽数量决定(每座位两行),每座位细节按需索取,因此默认报告随槽面增长,而不是随其文档量增长。
|
|
81
|
+
|
|
82
|
+
#### KV Cache 影响
|
|
83
|
+
|
|
84
|
+
仅追加;新可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
|
|
85
|
+
|
|
86
|
+
### cordis_run 后的后续请求
|
|
87
|
+
|
|
88
|
+
#### 模型看到的内容
|
|
89
|
+
|
|
90
|
+
运行中的包可以注册工具、提示词贡献或监听器,改变其目标 scope 的后续请求;`cordis_stop` 与 `cordis_undefine` 会在完全停稳后移除这些贡献。
|
|
91
|
+
|
|
92
|
+
#### Token 影响
|
|
93
|
+
|
|
94
|
+
间接 token 影响等于运行中包的贡献,且只在其进程内生命周期内持续。
|
|
95
|
+
|
|
96
|
+
#### KV Cache 影响
|
|
97
|
+
|
|
98
|
+
运行或停止提示词/工具贡献会改变后续请求前缀,并可能使从第一个变化的贡献起的复用失效;运行集合不变时,前缀保持稳定。
|
|
99
|
+
|
|
100
|
+
## 已知限制与暂缓事项
|
|
101
|
+
|
|
102
|
+
- **沙箱只用于约束诚实代码,并非安全边界**:可以访问沙箱全局变量上的 host realm helper,因此包代码可以触达 Node;加载该插件时,应当像授予 bash 工具一样慎重(见 § 信任立场)。
|
|
103
|
+
- **`ctx` façade 不公开 `effect()`**:包代码无法注册定制 disposer;`on`/`provide`/`tools.register` 是受支持的清理路径。
|
|
104
|
+
- **vm 与确认窗口这两个边界属于 runner**:见它的[已知限制](../cordis-host-runner/README.zh.md#known-limitations-and-deferred-work);async 的 host 半主体可逃出 `vmTimeoutMs`。
|