@hasna-internal/kai-subagent-in-process-driver 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 +116 -0
- package/README.zh.md +116 -0
- package/lib/index.js +251 -0
- package/lib/invariant.js +23 -0
- package/lib/types/index.d.ts +33 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/structured.d.ts +42 -0
- package/package.json +63 -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/subagent/subagent-in-process-driver/README.md
|
|
5
|
+
README.md: 47a5c09fc1c80c5dc3062be82e7355b874a627d3
|
|
6
|
+
README.zh.md: b96399795a0fbac05ef1795888aa93c620687f30
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @hasna-internal/kai-subagent-in-process-driver
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
This package is the shared run driver for the two in-process providers. Spawn passes no session seed; fork passes the parent's completed-turn prefix. Everything else—depth, child creation, optional child customization, result reading, cancellation, and disposal—has one implementation here.
|
|
6
|
+
|
|
7
|
+
## Start contract
|
|
8
|
+
|
|
9
|
+
`startInProcessRun(request, options): Promise<SubagentRun>` fulfills only after the child is published in `ctx.agents`. A rejected start has already quiesced the agent factory's unpublished creation transaction, so the caller never receives a half-created handle.
|
|
10
|
+
|
|
11
|
+
The driver follows this sequence:
|
|
12
|
+
|
|
13
|
+
1. Validate the parent depth and optional absolute `maxDepth`, then derive child depth as parent depth plus one and persist it in the child session header.
|
|
14
|
+
2. Call `parent.ctx.agents.create` directly, passing the required request signal into the factory's creation transaction.
|
|
15
|
+
3. During that transaction's unpublished setup window, install the requested persona, tool restriction, and structured-output runtime.
|
|
16
|
+
4. Publish the child, retain the returned `AgentHandle`, and drive one task with `child.followup(prompt)` followed by `child.whenIdle()`.
|
|
17
|
+
5. Read the child's own output — its last non-empty assistant message (an empty-content message that records usage is skipped), or its accumulated assistant text when no such message exists — and the final durable turn reason from the complete owned child run, excluding any fork seed.
|
|
18
|
+
|
|
19
|
+
The child gets the parent's working-directory/session lineage and inherits the parent provider, model, and output-token cap unless `request.agentOptions` overrides them. It gets a fresh flat registration scope: parent ownership does not import parent tool restrictions or establish an authority subset.
|
|
20
|
+
|
|
21
|
+
This result boundary is valid because the provider owns an isolated child lifecycle from publication through quiescence. Steering submitted during that lifecycle belongs to the child run; the provider does not pretend the initial follow-up alone owns its output.
|
|
22
|
+
|
|
23
|
+
The driver applies the seam's [delegated policy](../subagent/README.md#delegated-policy) through the shared child-agent helpers: it captures the parent's explicit sandbox override and the `'never'` approval pin before child creation and appends the source-tagged events during unpublished setup, after any fork history and before session publication. See the [delegation-policy decision](../../../.agents/notes/implemented/feature/2026-07-25-subagent-policy-inheritance.md).
|
|
24
|
+
|
|
25
|
+
## Cancellation and ownership
|
|
26
|
+
|
|
27
|
+
The required request signal covers both startup and the live run. Before publication, `AgentCreationTransaction` observes it, rolls back, and rejects. The factory detaches that creation-only listener before returning; the driver immediately checks the signal once more before installing a minimal live-run listener, closing the handoff race. After publication, abort cancels the child.
|
|
28
|
+
|
|
29
|
+
After fulfillment, the caller owns the run. Provider-plugin unload does not revoke it. `dispose()` removes the live abort listener, records cancellation, and delegates to the returned `AgentHandle.dispose()`, whose memoized quiescence transaction stops the loop, removes the agent and session, and unwinds scoped registrations. Cancellation owns every non-completed in-flight outcome and reports `aborted`; an already-completed turn remains completed.
|
|
30
|
+
|
|
31
|
+
## Spawn and fork inputs
|
|
32
|
+
|
|
33
|
+
`InProcessRunOptions` is `{ seed?: SessionEvent[] }`. Spawn omits it. Fork supplies a balanced completed-turn prefix and records its length so the result reader never mistakes a seeded parent message for child output.
|
|
34
|
+
|
|
35
|
+
Depth enforcement is internal to `startInProcessRun`: it reads the parent depth via `delegationDepthOf` (the persisted `SessionHeader.delegationDepth` is authoritative; runtime `AgentOptions.subagentDepth` may deepen but never lower it, so a resumed child keeps its budget), treats absence as top-level depth zero, rejects malformed stored values, and reports an attempted child depth above `maxDepth`. An unrepresentable depth above the safe-integer domain is a `RangeError`. The child depth is written to the child header, so it survives persistence and resume.
|
|
36
|
+
|
|
37
|
+
## Structured output
|
|
38
|
+
|
|
39
|
+
`attachStructuredRuntime(childCtx, schema)` installs the whole contract in the child's scope:
|
|
40
|
+
|
|
41
|
+
- A `structured_output` tool registered with the requested schema validates and stages the model's value.
|
|
42
|
+
- An order-190 system-prompt section tells the child that the tool call is the terminal answer.
|
|
43
|
+
- Both contributions are ordinary child-scoped registrations. An expert `system-prompt/assemble` listener may replace them and therefore owns preserving the structured-output protocol for that child.
|
|
44
|
+
- A `tools/result` observer commits a staged value only after that execution's authoritative final tool result succeeds, including the enclosing `run_code` result for Code Mode sub-dispatch.
|
|
45
|
+
- A monotonic tool guard blocks later calls after capture, and the structured-output execution's `concludeTurn()` marker ends the turn after the result commits.
|
|
46
|
+
|
|
47
|
+
A clean turn that never commits the required structured value reports `error`; the driver does not re-prompt. All registrations ride the child fiber and disappear with it.
|
|
48
|
+
|
|
49
|
+
## Model Experience
|
|
50
|
+
|
|
51
|
+
### Child-agent request
|
|
52
|
+
|
|
53
|
+
#### What the model sees
|
|
54
|
+
|
|
55
|
+
The shared driver sends the task verbatim as the child's user message and, when requested, shadows the persona and restricts global tool schemas, lookup, execution, and Code Mode SDK bindings in the unpublished child's fresh scope; parent restrictions are not inherited, and standalone tool-guidance sections remain. Spawn supplies no history; fork supplies its balanced seed.
|
|
56
|
+
|
|
57
|
+
#### Token effect
|
|
58
|
+
|
|
59
|
+
Child input is isolated from the parent and grows through the child's own steps. A persona changes repeated prompt text; filtering changes schema or generated SDK cost but not independently registered guidance.
|
|
60
|
+
|
|
61
|
+
#### KV Cache effect
|
|
62
|
+
|
|
63
|
+
Independent of the parent request cache. The child's later history is append-only, while persona, tool-filter, generated-SDK, provider, or model changes establish a different child prefix.
|
|
64
|
+
|
|
65
|
+
### Structured-output system prompt, schema, and results
|
|
66
|
+
|
|
67
|
+
#### What the model sees
|
|
68
|
+
|
|
69
|
+
A structured run adds the structured-output instruction below. It also adds a child-scoped `structured_output` definition with exact description `Report your final structured result. Call this exactly once, when your answer is complete; the arguments must match this tool's parameter schema exactly.` and the requested schema. This runtime-only definition is outside the generated shipped [tool package map](../../../docs/tool-catalog.md#tool-package-map). Its canonical acknowledgement is `{ recorded: true }`, rendered as `Structured output recorded.`; a later call becomes ``Error: structured output already recorded: the run is complete, so `<tool>` is not executed``.
|
|
70
|
+
|
|
71
|
+
##### Structured-output instruction
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
When you have your final answer, you MUST report it by calling the `structured_output` tool with arguments matching its parameter schema exactly. Do not finish with a plain text answer: only the tool call counts as your result.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Token effect
|
|
78
|
+
|
|
79
|
+
Fixed instruction and capability tokens are paid only by that child. Result text enters the child history, while the captured value alone becomes the parent result.
|
|
80
|
+
|
|
81
|
+
#### KV Cache effect
|
|
82
|
+
|
|
83
|
+
Prefix-stable inside the child while the structured-output instruction and schema are unchanged. Changing the schema or capability may invalidate the child's cache from that early segment; results append in child and parent histories.
|
|
84
|
+
|
|
85
|
+
### Parent start error, indirectly
|
|
86
|
+
|
|
87
|
+
#### What the model sees
|
|
88
|
+
|
|
89
|
+
Through `dsh-tool-subagent`, invalid depth state becomes exactly `Error: agent subagentDepth must be a non-negative safe integer`, `Error: subagent child depth exceeds the safe-integer range`, or `Error: subagent depth <attempted> exceeds maxDepth <max>`. A pre-publication cancellation passes its abort reason through the registry's `Error: <message>` wrapper.
|
|
90
|
+
|
|
91
|
+
#### Token effect
|
|
92
|
+
|
|
93
|
+
Zero tokens on a successful start; only the failed parent tool call retains this text.
|
|
94
|
+
|
|
95
|
+
#### KV Cache effect
|
|
96
|
+
|
|
97
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
98
|
+
|
|
99
|
+
### Parent result, indirectly
|
|
100
|
+
|
|
101
|
+
#### What the model sees
|
|
102
|
+
|
|
103
|
+
The driver extracts only the child's own last assistant output or captured structured value; seeded parent messages and intermediate child work do not become the result.
|
|
104
|
+
|
|
105
|
+
#### Token effect
|
|
106
|
+
|
|
107
|
+
The parent receives one data-dependent result through the consumer; all other child tokens stay in the child session.
|
|
108
|
+
|
|
109
|
+
#### KV Cache effect
|
|
110
|
+
|
|
111
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
112
|
+
|
|
113
|
+
## Known Limitations and Deferred Work
|
|
114
|
+
|
|
115
|
+
- **Runs expose no `sendMessage`/`resume`** — the optional runtime capabilities are absent on in-process runs.
|
|
116
|
+
- **Structured capture accepts the `defineTool` schema subset only** — unsupported JSON Schema constructs fail before the child is created; a provider needing a broader schema vocabulary requires a different runtime.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @hasna-internal/kai-subagent-in-process-driver
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
本包是两个进程内提供方共用的运行驱动器。spawn 不传入会话初始内容;fork 传入父 agent(智能体)已完成轮次的前缀。其余机制,包括深度、子 agent 创建、可选的子 agent 定制、结果读取、取消和 dispose(资源释放),都在此共用同一套实现。
|
|
6
|
+
|
|
7
|
+
## 启动约定
|
|
8
|
+
|
|
9
|
+
`startInProcessRun(request, options): Promise<SubagentRun>` 只在子 agent 发布到 `ctx.agents` 后才兑现。启动被拒绝时,agent 工厂的未发布创建事务已经完全停稳,因此调用方绝不会收到创建到一半的句柄。
|
|
10
|
+
|
|
11
|
+
驱动器按以下顺序运行:
|
|
12
|
+
|
|
13
|
+
1. 校验父 agent 深度和可选的绝对 `maxDepth`,然后把子 agent 深度推导为父 agent 深度加一,并将其持久化到子 agent 会话 header。
|
|
14
|
+
2. 直接调用 `parent.ctx.agents.create`,把必需的请求信号传入工厂的创建事务。
|
|
15
|
+
3. 在该事务未发布的设置窗口中,安装请求的 persona、工具限制和结构化输出运行时。
|
|
16
|
+
4. 发布子 agent,保留返回的 `AgentHandle`,并通过先调用 `child.followup(prompt)`、再调用 `child.whenIdle()` 来驱动一项任务。
|
|
17
|
+
5. 从完整的自有子运行中读取子 agent 自身的输出——最后一条非空 assistant 消息(记录 usage 的空内容消息会被跳过),若没有这类消息则取其累积的 assistant 文本——以及最终持久化的轮次原因,并排除任何 fork 初始内容。
|
|
18
|
+
|
|
19
|
+
子 agent 会获得父 agent 的工作目录/会话谱系;除非 `request.agentOptions` 覆盖,否则还会继承父 agent 的提供方、模型和输出 token 上限。它获得全新的扁平注册作用域:父级所有权不会导入父 agent 的工具限制,也不会建立权限子集。
|
|
20
|
+
|
|
21
|
+
该结果边界成立,是因为提供方拥有从发布到完全停稳的隔离子 agent 生命周期。在该生命周期内提交的 steering(中途引导)属于子运行;提供方不会声称输出只归初始 follow-up 所有。
|
|
22
|
+
|
|
23
|
+
驱动器通过共享的子 agent 辅助函数应用该 seam 的[委派策略](../subagent/README.zh.md#delegated-policy):它会在创建子 agent 前捕获父级的显式沙箱覆盖项与 `'never'` 审批钉定,并在未发布的设置阶段追加带来源标记的事件,使其位于所有 fork 历史之后、会话发布之前。参见[委派策略决策](../../../.agents/notes/implemented/feature/2026-07-25-subagent-policy-inheritance.zh.md)。
|
|
24
|
+
|
|
25
|
+
## 取消与所有权
|
|
26
|
+
|
|
27
|
+
必需的请求信号同时覆盖启动阶段和实时运行。发布前,`AgentCreationTransaction` 会观察该信号、回滚并拒绝。工厂返回前会移除仅用于创建阶段的监听器;驱动器随即再次检查信号,然后安装最小化的实时运行监听器,从而消除交接竞态。发布后,中止会取消子 agent。
|
|
28
|
+
|
|
29
|
+
兑现后,调用方拥有该运行。提供方插件卸载不会撤销它。`dispose()` 会移除实时中止监听器、记录取消,并委托给返回的 `AgentHandle.dispose()`;后者通过经记忆化的完全停稳事务停止循环、移除 agent 和会话,并撤销作用域内的注册。取消流程会接管所有尚未完成的进行中结果,并将其报告为 `aborted`;已经完成的轮次仍保持完成状态。
|
|
30
|
+
|
|
31
|
+
## spawn 与 fork 输入
|
|
32
|
+
|
|
33
|
+
`InProcessRunOptions` 的形态为 `{ seed?: SessionEvent[] }`。spawn 省略该值。fork 提供已配平的已完成轮次前缀,并记录其长度,确保结果读取器不会把作为初始内容的父 agent 消息误认为子 agent 输出。
|
|
34
|
+
|
|
35
|
+
深度强制在 `startInProcessRun` 内部完成:它通过 `delegationDepthOf` 读取父 agent 深度(持久化的 `SessionHeader.delegationDepth` 具有权威性;运行时 `AgentOptions.subagentDepth` 可以加深但绝不能降低该值,因此恢复后的子 agent 会保留预算),缺失值按顶层深度零处理,拒绝格式错误的存储值,并报告尝试的子 agent 深度超过 `maxDepth`。超过安全整数范围、无法表示的深度会触发 `RangeError`。子 agent 深度写入子 agent header,因此会在持久化和恢复后保留。
|
|
36
|
+
|
|
37
|
+
## 结构化输出
|
|
38
|
+
|
|
39
|
+
`attachStructuredRuntime(childCtx, schema)` 会在子 agent 作用域中安装完整约定:
|
|
40
|
+
|
|
41
|
+
- 使用请求 schema 注册的 `structured_output` 工具会校验并暂存模型值。
|
|
42
|
+
- 一个顺序为 190 的系统提示词段会告诉子 agent,该工具调用就是终态答案。
|
|
43
|
+
- 两项贡献都是普通的子 agent 作用域注册。专家级 `system-prompt/assemble` 监听器可以替换它们,因此负责为该子 agent 保留结构化输出协议。
|
|
44
|
+
- `tools/result` 观察器只会在该次执行的权威最终工具结果成功后提交暂存值;Code Mode 子分派外层的 `run_code` 结果也包括在内。
|
|
45
|
+
- 单调工具防护会在捕获值后阻止后续调用,结构化输出执行的 `concludeTurn()` 标记则在结果提交后结束轮次。
|
|
46
|
+
|
|
47
|
+
正常结束却始终未提交必需结构化值的轮次会报告 `error`;驱动器不会重新提示。所有注册都附着于子 agent fiber,并随其一同消失。
|
|
48
|
+
|
|
49
|
+
## 模型体验
|
|
50
|
+
|
|
51
|
+
### 子 agent 请求
|
|
52
|
+
|
|
53
|
+
#### 模型看到的内容
|
|
54
|
+
|
|
55
|
+
共享驱动器把任务逐字作为子 agent 的用户消息发送;若有请求,还会在未发布子 agent 的全新作用域中遮蔽 persona,并限制全局工具 schema、查找、执行和 Code Mode SDK 绑定。父 agent 的限制不会被继承,独立的工具指导段仍会保留。spawn 不提供历史;fork 提供平衡的初始内容。
|
|
56
|
+
|
|
57
|
+
#### Token 影响
|
|
58
|
+
|
|
59
|
+
子 agent 输入与父 agent 隔离,并通过子 agent 自身的步骤增长。persona 会改变重复提示词文本;过滤会改变 schema 或生成 SDK 的成本,但不影响独立注册的指导内容。
|
|
60
|
+
|
|
61
|
+
#### KV Cache 影响
|
|
62
|
+
|
|
63
|
+
与父 agent 请求缓存相互独立。子 agent 后续历史仅追加,而 persona、工具过滤、生成 SDK、提供方或模型变化会建立不同的子 agent 前缀。
|
|
64
|
+
|
|
65
|
+
### 结构化输出系统提示词、schema 与结果
|
|
66
|
+
|
|
67
|
+
#### 模型看到的内容
|
|
68
|
+
|
|
69
|
+
结构化运行会添加下方的结构化输出指令。它还会添加子 agent 作用域的 `structured_output` 定义,其精确描述为 `Report your final structured result. Call this exactly once, when your answer is complete; the arguments must match this tool's parameter schema exactly.`,参数使用请求的 schema。该仅运行时存在的定义不在已生成并随产品发布的[工具包索引](../../../docs/tool-catalog.zh.md#tool-package-map)中。其规范确认值是 `{ recorded: true }`,渲染为 `Structured output recorded.`;后续调用会变为 ``Error: structured output already recorded: the run is complete, so `<tool>` is not executed``。
|
|
70
|
+
|
|
71
|
+
##### 结构化输出指令
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
When you have your final answer, you MUST report it by calling the `structured_output` tool with arguments matching its parameter schema exactly. Do not finish with a plain text answer: only the tool call counts as your result.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Token 影响
|
|
78
|
+
|
|
79
|
+
固定指令和能力产生的 token 开销仅由该子 agent 承担。结果文本进入子 agent 历史,而只有捕获的值会成为父 agent 结果。
|
|
80
|
+
|
|
81
|
+
#### KV Cache 影响
|
|
82
|
+
|
|
83
|
+
只要结构化输出指令和 schema 不变,子 agent 内部的前缀就保持稳定。更改 schema 或能力可能从该早期片段开始使子 agent 缓存失效;结果会分别追加到子 agent 和父 agent 历史中。
|
|
84
|
+
|
|
85
|
+
### 父 agent 启动错误(间接)
|
|
86
|
+
|
|
87
|
+
#### 模型看到的内容
|
|
88
|
+
|
|
89
|
+
通过 `dsh-tool-subagent`,无效深度状态会精确变为 `Error: agent subagentDepth must be a non-negative safe integer`、`Error: subagent child depth exceeds the safe-integer range` 或 `Error: subagent depth <attempted> exceeds maxDepth <max>`。发布前取消的中止原因会通过注册表的 `Error: <message>` 包装传递。
|
|
90
|
+
|
|
91
|
+
#### Token 影响
|
|
92
|
+
|
|
93
|
+
启动成功时为零 token;只有失败的父 agent 工具调用会保留这段文本。
|
|
94
|
+
|
|
95
|
+
#### KV Cache 影响
|
|
96
|
+
|
|
97
|
+
仅追加;新增可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
|
|
98
|
+
|
|
99
|
+
### 父 agent 结果(间接)
|
|
100
|
+
|
|
101
|
+
#### 模型看到的内容
|
|
102
|
+
|
|
103
|
+
驱动器只提取子 agent 自身最后的 assistant 输出或捕获的结构化值;作为初始内容的父 agent 消息和子 agent 中间工作不会成为结果。
|
|
104
|
+
|
|
105
|
+
#### Token 影响
|
|
106
|
+
|
|
107
|
+
父 agent 通过消费方接收一个依赖数据的结果;其他所有子 agent token 都留在子 agent 会话中。
|
|
108
|
+
|
|
109
|
+
#### KV Cache 影响
|
|
110
|
+
|
|
111
|
+
仅追加;新增可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
|
|
112
|
+
|
|
113
|
+
## 已知限制与暂缓事项
|
|
114
|
+
|
|
115
|
+
- **运行不公开 `sendMessage`/`resume`**:进程内运行不具备这些可选运行时能力。
|
|
116
|
+
- **结构化捕获只接受 `defineTool` schema 子集**:不支持的 JSON Schema 构造会在子 agent 创建前失败;需要更广 schema 词汇的提供方必须采用不同的运行时。
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { foldConsumedWork } from "@hasna-internal/kai-agent";
|
|
3
|
+
import { SessionId } from "@hasna-internal/kai-session";
|
|
4
|
+
import { createUserMessage } from "@hasna-internal/kai-llm";
|
|
5
|
+
import { appendDelegatedPolicyOverrides, applyChildComposition, assertSubagentMaxDepth, captureDelegatedPolicyOverrides, childSessionMeta, finalAssistantOutput, resolveChildAgentOptions, resolveChildDepth } from "@hasna-internal/kai-subagent";
|
|
6
|
+
import { ToolArgsError, validateJsonSchemaValue } from "@hasna-internal/kai-tools";
|
|
7
|
+
//#region lib/types/structured.js
|
|
8
|
+
/**
|
|
9
|
+
* Child-scoped structured-output tool, prompt instruction, terminal guard, and authoritative
|
|
10
|
+
* result capture for in-process subagents. Each child registers its real schema on its own
|
|
11
|
+
* scope, so concurrent runs do not interact and disposal leaves no global residue. The prompt
|
|
12
|
+
* contribution is ordinary reconstructed request state.
|
|
13
|
+
*
|
|
14
|
+
* Capture commits only after the authoritative `tools/result` succeeds; Code Mode capture also
|
|
15
|
+
* waits for the enclosing `run_code` result. The terminal result marker and monotonic tool
|
|
16
|
+
* guard prevent later calls from reopening a completed structured run.
|
|
17
|
+
* @module @hasna-internal/kai-subagent-in-process-driver/structured
|
|
18
|
+
*/
|
|
19
|
+
/** The model-facing tool name a structured child must call to finish. */
|
|
20
|
+
const STRUCTURED_OUTPUT_TOOL = "structured_output";
|
|
21
|
+
/**
|
|
22
|
+
* The instruction registered as the child's trailing (order-190, the end of
|
|
23
|
+
* the tool-guidance band) scoped prompt section: the demand travels with the
|
|
24
|
+
* tool, as ordinary prompt state of exactly one agent.
|
|
25
|
+
*/
|
|
26
|
+
const STRUCTURED_OUTPUT_INSTRUCTION = `When you have your final answer, you MUST report it by calling the \`${STRUCTURED_OUTPUT_TOOL}\` tool with arguments matching its parameter schema exactly. Do not finish with a plain text answer: only the tool call counts as your result.`;
|
|
27
|
+
/**
|
|
28
|
+
* Attach the scoped capture tool, instruction, and enforcement to a child during
|
|
29
|
+
* its creation window. Child disposal removes every registration.
|
|
30
|
+
* @param childCtx - the child agent's scope context (`setup`'s argument).
|
|
31
|
+
* @param schema - the trusted, already-asserted schema subset to enforce (see
|
|
32
|
+
* `assertObjectJsonSchema` in dsh-tools).
|
|
33
|
+
* @returns the attachment handle (read `captured()` after the child settles).
|
|
34
|
+
*/
|
|
35
|
+
function attachStructuredRuntime(childCtx, schema) {
|
|
36
|
+
/**
|
|
37
|
+
* Validated values staged by the capture tool body, awaiting THEIR OWN
|
|
38
|
+
* authoritative `tools/result` notification. The execution object's identity
|
|
39
|
+
* uniquely identifies a trip through the pipeline: adapter call ids may
|
|
40
|
+
* repeat across steps, but another execution can never reach this WeakMap
|
|
41
|
+
* entry. This is distinct from the opaque `ToolExecutionToken` used to
|
|
42
|
+
* correlate nested transports. The final notification always deletes its own
|
|
43
|
+
* stage, whether the result succeeded or failed.
|
|
44
|
+
*/
|
|
45
|
+
const staged = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
/** Successful nested capture waiting for its enclosing transport to commit. */
|
|
47
|
+
let pending;
|
|
48
|
+
let captured;
|
|
49
|
+
const schemaEntry = {
|
|
50
|
+
name: STRUCTURED_OUTPUT_TOOL,
|
|
51
|
+
description: "Report your final structured result. Call this exactly once, when your answer is complete; the arguments must match this tool's parameter schema exactly.",
|
|
52
|
+
parameters: schema
|
|
53
|
+
};
|
|
54
|
+
childCtx.tools.register({
|
|
55
|
+
...schemaEntry,
|
|
56
|
+
output: {
|
|
57
|
+
schema: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: { recorded: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
const: true
|
|
62
|
+
} },
|
|
63
|
+
required: ["recorded"],
|
|
64
|
+
additionalProperties: false
|
|
65
|
+
},
|
|
66
|
+
render: () => [{
|
|
67
|
+
type: "text",
|
|
68
|
+
text: "Structured output recorded."
|
|
69
|
+
}]
|
|
70
|
+
},
|
|
71
|
+
execute(args, exec) {
|
|
72
|
+
const violations = validateJsonSchemaValue(schema, args);
|
|
73
|
+
if (violations.length > 0) throw new ToolArgsError(violations);
|
|
74
|
+
staged.set(exec, { value: args });
|
|
75
|
+
exec.concludeTurn();
|
|
76
|
+
return Promise.resolve({ recorded: true });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
childCtx.systemPrompt.section({
|
|
80
|
+
name: `tool:${STRUCTURED_OUTPUT_TOOL}`,
|
|
81
|
+
order: 190,
|
|
82
|
+
text: STRUCTURED_OUTPUT_INSTRUCTION
|
|
83
|
+
});
|
|
84
|
+
childCtx.tools.guard((exec) => captured === void 0 && pending === void 0 ? void 0 : `structured output already recorded: the run is complete, so \`${exec.name}\` is not executed`);
|
|
85
|
+
childCtx.on("tools/result", function(exec, result) {
|
|
86
|
+
if (exec.name === "structured_output") {
|
|
87
|
+
const entry = staged.get(exec);
|
|
88
|
+
if (entry === void 0) return;
|
|
89
|
+
staged.delete(exec);
|
|
90
|
+
if (result.isError) return;
|
|
91
|
+
if (exec.parent === void 0) {
|
|
92
|
+
/* v8 ignore else -- sequential agent-loop dispatch lets the guard block every later supported call */
|
|
93
|
+
if (captured === void 0) captured = { value: entry.value };
|
|
94
|
+
} else if (captured === void 0 && pending === void 0) pending = {
|
|
95
|
+
parent: exec.parent,
|
|
96
|
+
value: entry.value
|
|
97
|
+
};
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (pending?.parent !== exec.token) return;
|
|
101
|
+
const entry = pending;
|
|
102
|
+
pending = void 0;
|
|
103
|
+
if (result.isError) return;
|
|
104
|
+
/* v8 ignore else -- Code Mode serializes outer executions, so the guard blocks every later supported call */
|
|
105
|
+
if (captured === void 0) captured = { value: entry.value };
|
|
106
|
+
});
|
|
107
|
+
return { captured: () => captured };
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region lib/types/index.js
|
|
111
|
+
/**
|
|
112
|
+
* Shared driver for in-process ONE-SHOT subagent providers. The agent factory's
|
|
113
|
+
* creation transaction owns unpublished setup and rollback; after publication
|
|
114
|
+
* the returned AgentHandle is the one quiescent lifecycle owner held by the
|
|
115
|
+
* provider's caller.
|
|
116
|
+
*
|
|
117
|
+
* Continuable children never come through here: the continuation manager
|
|
118
|
+
* composes and drives them directly, so this driver owns exactly one turn with
|
|
119
|
+
* one result.
|
|
120
|
+
*
|
|
121
|
+
* @module @hasna-internal/kai-subagent-in-process-driver
|
|
122
|
+
*/
|
|
123
|
+
/** Map a session turn outcome to the subagent seam's terminal vocabulary. */
|
|
124
|
+
function toStopReason(reason) {
|
|
125
|
+
switch (reason?.kind) {
|
|
126
|
+
case "completed": return "completed";
|
|
127
|
+
case "max-tokens": return "max-tokens";
|
|
128
|
+
case "aborted": return "aborted";
|
|
129
|
+
case "blocked": return "refusal";
|
|
130
|
+
default: return "error";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Error used when cancellation wins before the child publication boundary. */
|
|
134
|
+
function prePublicationAbort() {
|
|
135
|
+
return /* @__PURE__ */ new Error("subagent request was aborted before child publication");
|
|
136
|
+
}
|
|
137
|
+
/** Append one one-shot descriptor inside the child's initial turn before its first request. */
|
|
138
|
+
function attachDescriptorAppend(childCtx, descriptor) {
|
|
139
|
+
let appended = false;
|
|
140
|
+
childCtx.on("agent/pre-step", async ({ agent }, next) => {
|
|
141
|
+
const decision = await next();
|
|
142
|
+
if (!appended && decision.kind === "enter") {
|
|
143
|
+
appended = true;
|
|
144
|
+
agent.session.append("subagent/descriptor", descriptor);
|
|
145
|
+
}
|
|
146
|
+
return decision;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Establish and drive one in-process one-shot child. Fulfillment means the agent
|
|
151
|
+
* is already published in the registry and transfers its turn, cancellation,
|
|
152
|
+
* and disposal work through the returned run. Rejection means the agent
|
|
153
|
+
* factory's unpublished creation transaction reached quiescence without
|
|
154
|
+
* publishing a child. Every start appends its resolved descriptor inside the
|
|
155
|
+
* child's initial turn.
|
|
156
|
+
* @param request - the trusted typed start request, including its required signal.
|
|
157
|
+
* @param options - the optional fork seed.
|
|
158
|
+
* @returns a published holder-owned run.
|
|
159
|
+
*/
|
|
160
|
+
async function startInProcessRun(request, options) {
|
|
161
|
+
assertSubagentMaxDepth(request.maxDepth);
|
|
162
|
+
if (request.signal.aborted) throw prePublicationAbort();
|
|
163
|
+
const parent = request.parent;
|
|
164
|
+
const childDepth = resolveChildDepth(parent, request.maxDepth);
|
|
165
|
+
const childId = SessionId(randomUUID());
|
|
166
|
+
const seed = options.seed;
|
|
167
|
+
const activationBoundary = seed?.length ?? 0;
|
|
168
|
+
const inherited = captureDelegatedPolicyOverrides(parent);
|
|
169
|
+
let structured;
|
|
170
|
+
const setup = (childCtx) => {
|
|
171
|
+
appendDelegatedPolicyOverrides(childCtx.agent.session, inherited);
|
|
172
|
+
applyChildComposition(childCtx, parent, {
|
|
173
|
+
persona: request.persona,
|
|
174
|
+
toolFilter: request.toolFilter
|
|
175
|
+
});
|
|
176
|
+
if (request.outputSchema !== void 0) structured = attachStructuredRuntime(childCtx, request.outputSchema);
|
|
177
|
+
attachDescriptorAppend(childCtx, request.descriptor);
|
|
178
|
+
};
|
|
179
|
+
return drivePublishedRun(await parent.ctx.agents.create({
|
|
180
|
+
sessionId: childId,
|
|
181
|
+
meta: childSessionMeta(parent, childDepth, activationBoundary),
|
|
182
|
+
...seed !== void 0 ? { seed } : {},
|
|
183
|
+
agentOptions: resolveChildAgentOptions(parent, request.agentOptions, childDepth),
|
|
184
|
+
signal: request.signal,
|
|
185
|
+
setup
|
|
186
|
+
}), request.signal, request.prompt, childId, activationBoundary, structured);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Wrap a published child in the single run lifecycle that owns signal handoff,
|
|
190
|
+
* one turn, result settlement, and quiescent disposal.
|
|
191
|
+
*/
|
|
192
|
+
function drivePublishedRun(handle, signal, prompt, childId, boundary, structured) {
|
|
193
|
+
const child = handle.agent;
|
|
194
|
+
const flags = { cancelled: false };
|
|
195
|
+
const onAbort = () => {
|
|
196
|
+
flags.cancelled = true;
|
|
197
|
+
child.cancel({ kind: "parent" });
|
|
198
|
+
};
|
|
199
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
200
|
+
if (signal.aborted) onAbort();
|
|
201
|
+
const result = (async () => {
|
|
202
|
+
try {
|
|
203
|
+
if (!flags.cancelled) {
|
|
204
|
+
child.followup(createUserMessage({
|
|
205
|
+
content: prompt,
|
|
206
|
+
source: { kind: "user" }
|
|
207
|
+
}));
|
|
208
|
+
await child.whenIdle();
|
|
209
|
+
}
|
|
210
|
+
return readResult(child, boundary, flags.cancelled, structured ? { captured: structured.captured() } : void 0);
|
|
211
|
+
} finally {
|
|
212
|
+
signal.removeEventListener("abort", onAbort);
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
215
|
+
return {
|
|
216
|
+
id: childId,
|
|
217
|
+
localAgent: child,
|
|
218
|
+
result,
|
|
219
|
+
async dispose() {
|
|
220
|
+
signal.removeEventListener("abort", onAbort);
|
|
221
|
+
flags.cancelled = true;
|
|
222
|
+
const disposal = (await Promise.allSettled([handle.dispose(), result]))[0];
|
|
223
|
+
if (disposal.status === "rejected") throw disposal.reason;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** Read one settled child's result from events after its activation boundary. */
|
|
228
|
+
function readResult(child, boundary, cancelled, structured) {
|
|
229
|
+
const own = child.session.events.slice(boundary);
|
|
230
|
+
const lastEnd = foldConsumedWork(own).end;
|
|
231
|
+
const output = finalAssistantOutput(own) ?? [];
|
|
232
|
+
const recorded = toStopReason(lastEnd?.data.reason);
|
|
233
|
+
const stopReason = cancelled && recorded !== "completed" ? "aborted" : recorded;
|
|
234
|
+
if (structured !== void 0) {
|
|
235
|
+
if (structured.captured !== void 0) return {
|
|
236
|
+
output,
|
|
237
|
+
structured: structured.captured.value,
|
|
238
|
+
stopReason
|
|
239
|
+
};
|
|
240
|
+
if (stopReason === "completed") return {
|
|
241
|
+
output,
|
|
242
|
+
stopReason: cancelled ? "aborted" : "error"
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
output,
|
|
247
|
+
stopReason
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { STRUCTURED_OUTPUT_INSTRUCTION, STRUCTURED_OUTPUT_TOOL, startInProcessRun };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@hasna-internal/kai-subagent-in-process-driver`.
|
|
4
|
+
* @module @hasna-internal/kai-subagent-in-process-driver/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@hasna-internal/kai-subagent-in-process-driver";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "subagent-in-process-driver-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: this package exposes no independent event sequence or mutable data relation
|
|
13
|
+
* beyond contracts enforced at its owning seam.
|
|
14
|
+
*/
|
|
15
|
+
const install = () => {};
|
|
16
|
+
/**
|
|
17
|
+
* Register this package's invariant companion.
|
|
18
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
+
*/
|
|
21
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
+
//#endregion
|
|
23
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared driver for in-process ONE-SHOT subagent providers. The agent factory's
|
|
3
|
+
* creation transaction owns unpublished setup and rollback; after publication
|
|
4
|
+
* the returned AgentHandle is the one quiescent lifecycle owner held by the
|
|
5
|
+
* provider's caller.
|
|
6
|
+
*
|
|
7
|
+
* Continuable children never come through here: the continuation manager
|
|
8
|
+
* composes and drives them directly, so this driver owns exactly one turn with
|
|
9
|
+
* one result.
|
|
10
|
+
*
|
|
11
|
+
* @module @hasna-internal/kai-subagent-in-process-driver
|
|
12
|
+
*/
|
|
13
|
+
import { type SessionEvent } from '@hasna-internal/kai-session';
|
|
14
|
+
import type { ResolvedSubagentStartRequest, SubagentRun } from '@hasna-internal/kai-subagent';
|
|
15
|
+
export { STRUCTURED_OUTPUT_TOOL, STRUCTURED_OUTPUT_INSTRUCTION, } from './structured.ts';
|
|
16
|
+
/** Extra inputs the spawn and fork providers supply to the shared driver. */
|
|
17
|
+
export interface InProcessRunOptions {
|
|
18
|
+
/** Completed-turn seed for fork, or undefined for a fresh spawn. */
|
|
19
|
+
readonly seed?: SessionEvent[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Establish and drive one in-process one-shot child. Fulfillment means the agent
|
|
23
|
+
* is already published in the registry and transfers its turn, cancellation,
|
|
24
|
+
* and disposal work through the returned run. Rejection means the agent
|
|
25
|
+
* factory's unpublished creation transaction reached quiescence without
|
|
26
|
+
* publishing a child. Every start appends its resolved descriptor inside the
|
|
27
|
+
* child's initial turn.
|
|
28
|
+
* @param request - the trusted typed start request, including its required signal.
|
|
29
|
+
* @param options - the optional fork seed.
|
|
30
|
+
* @returns a published holder-owned run.
|
|
31
|
+
*/
|
|
32
|
+
export declare function startInProcessRun(request: ResolvedSubagentStartRequest, options: InProcessRunOptions): Promise<SubagentRun>;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@hasna-internal/kai-subagent-in-process-driver`.
|
|
3
|
+
* @module @hasna-internal/kai-subagent-in-process-driver/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "subagent-in-process-driver-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Child-scoped structured-output tool, prompt instruction, terminal guard, and authoritative
|
|
3
|
+
* result capture for in-process subagents. Each child registers its real schema on its own
|
|
4
|
+
* scope, so concurrent runs do not interact and disposal leaves no global residue. The prompt
|
|
5
|
+
* contribution is ordinary reconstructed request state.
|
|
6
|
+
*
|
|
7
|
+
* Capture commits only after the authoritative `tools/result` succeeds; Code Mode capture also
|
|
8
|
+
* waits for the enclosing `run_code` result. The terminal result marker and monotonic tool
|
|
9
|
+
* guard prevent later calls from reopening a completed structured run.
|
|
10
|
+
* @module @hasna-internal/kai-subagent-in-process-driver/structured
|
|
11
|
+
*/
|
|
12
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
+
import { type ObjectJsonSchema } from '@hasna-internal/kai-tools';
|
|
14
|
+
/** The model-facing tool name a structured child must call to finish. */
|
|
15
|
+
export declare const STRUCTURED_OUTPUT_TOOL = "structured_output";
|
|
16
|
+
/**
|
|
17
|
+
* The instruction registered as the child's trailing (order-190, the end of
|
|
18
|
+
* the tool-guidance band) scoped prompt section: the demand travels with the
|
|
19
|
+
* tool, as ordinary prompt state of exactly one agent.
|
|
20
|
+
*/
|
|
21
|
+
export declare const STRUCTURED_OUTPUT_INSTRUCTION: string;
|
|
22
|
+
/** One structured run's live handle: read the captured value once the child settles. */
|
|
23
|
+
export interface StructuredAttachment {
|
|
24
|
+
/**
|
|
25
|
+
* The captured value, once the child called the tool with valid arguments
|
|
26
|
+
* and the authoritative final tool result accepted that call.
|
|
27
|
+
* @returns the committed value, or undefined while none was accepted.
|
|
28
|
+
*/
|
|
29
|
+
captured(): {
|
|
30
|
+
value: unknown;
|
|
31
|
+
} | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Attach the scoped capture tool, instruction, and enforcement to a child during
|
|
35
|
+
* its creation window. Child disposal removes every registration.
|
|
36
|
+
* @param childCtx - the child agent's scope context (`setup`'s argument).
|
|
37
|
+
* @param schema - the trusted, already-asserted schema subset to enforce (see
|
|
38
|
+
* `assertObjectJsonSchema` in dsh-tools).
|
|
39
|
+
* @returns the attachment handle (read `captured()` after the child settles).
|
|
40
|
+
*/
|
|
41
|
+
export declare function attachStructuredRuntime(childCtx: Context, schema: ObjectJsonSchema): StructuredAttachment;
|
|
42
|
+
//# sourceMappingURL=structured.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasna-internal/kai-subagent-in-process-driver",
|
|
3
|
+
"description": "Shared in-process subagent run driver: drives a child agent on ctx.agents (used by the spawn and fork backends)",
|
|
4
|
+
"version": "0.1.1-rc.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/subagent/subagent-in-process-driver"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@hasna-internal/kai-agent": "^0.1.1-rc.2",
|
|
36
|
+
"@hasna-internal/kai-invariants": "^0.1.1-rc.2",
|
|
37
|
+
"@hasna-internal/kai-llm": "^0.1.1-rc.2",
|
|
38
|
+
"@hasna-internal/kai-subagent": "^0.1.1-rc.2",
|
|
39
|
+
"@hasna-internal/kai-session": "^0.1.1-rc.2",
|
|
40
|
+
"@hasna-internal/kai-tools": "^0.1.1-rc.2",
|
|
41
|
+
"@hasna-internal/kai-system-prompt": "^0.1.1-rc.2",
|
|
42
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@deepseek-ai/cordis-plugin-include": "^1.0.6",
|
|
46
|
+
"@hasna-internal/kai-agent": "^0.1.1-rc.2",
|
|
47
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
|
|
48
|
+
"@hasna-internal/kai-agent-loop": "^0.1.1-rc.2",
|
|
49
|
+
"@hasna-internal/kai-fs-sandbox": "^0.1.1-rc.2",
|
|
50
|
+
"@hasna-internal/kai-agent-loop-testkit": "^0.1.1-rc.2",
|
|
51
|
+
"@hasna-internal/kai-agent-presets": "^0.1.1-rc.2",
|
|
52
|
+
"@hasna-internal/kai-sandbox-policy": "^0.1.1-rc.2",
|
|
53
|
+
"@hasna-internal/kai-invariants": "^0.1.1-rc.2",
|
|
54
|
+
"@hasna-internal/kai-llm": "^0.1.1-rc.2",
|
|
55
|
+
"@hasna-internal/kai-session": "^0.1.1-rc.2",
|
|
56
|
+
"@hasna-internal/kai-subagent": "^0.1.1-rc.2",
|
|
57
|
+
"@hasna-internal/kai-system-prompt": "^0.1.1-rc.2",
|
|
58
|
+
"@hasna-internal/kai-tool-fs": "^0.1.1-rc.2",
|
|
59
|
+
"@hasna-internal/kai-tools": "^0.1.1-rc.2",
|
|
60
|
+
"@hasna-internal/kai-user-approval": "^0.1.1-rc.2",
|
|
61
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
62
|
+
}
|
|
63
|
+
}
|