@ai-zen/agents-sdk 2.0.0-alpha.0 → 2.0.0-alpha.1
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 +73 -16
- package/README.md +397 -113
- package/README.zh.md +314 -112
- package/dist/agent-plugins/AssetTransportPlugin.d.ts +51 -0
- package/dist/agent-plugins/AssetTransportPlugin.js +145 -0
- package/dist/agent-plugins/AutoMigratePlugin.d.ts +35 -14
- package/dist/agent-plugins/AutoMigratePlugin.js +36 -36
- package/dist/agent-plugins/AutoRefreshToolsPlugin.d.ts +6 -6
- package/dist/agent-plugins/AutoRefreshToolsPlugin.js +2 -2
- package/dist/agent-plugins/ContextGuardPlugin.d.ts +20 -24
- package/dist/agent-plugins/ContextGuardPlugin.js +25 -24
- package/dist/agent-plugins/SubAgentGuardInstallerPlugin.d.ts +25 -35
- package/dist/agent-plugins/SubAgentGuardInstallerPlugin.js +26 -41
- package/dist/agent-plugins/UnknownToolHintPlugin.d.ts +14 -9
- package/dist/agent-plugins/UnknownToolHintPlugin.js +15 -13
- package/dist/config/ConfigManager.d.ts +13 -5
- package/dist/config/ConfigManager.js +58 -39
- package/dist/config/constants.d.ts +1 -1
- package/dist/config/constants.js +2 -2
- package/dist/config/factory-skills.js +2 -2
- package/dist/config/normalize.d.ts +93 -0
- package/dist/config/normalize.js +158 -0
- package/dist/crud/AgentRepository.d.ts +3 -1
- package/dist/crud/AgentRepository.js +4 -2
- package/dist/index.d.ts +19 -9
- package/dist/index.js +14 -7
- package/dist/runtime/AgentRuntime.d.ts +293 -0
- package/dist/runtime/AgentRuntime.js +457 -0
- package/dist/runtime/HandoffGuardPlugin.d.ts +82 -15
- package/dist/runtime/HandoffGuardPlugin.js +136 -17
- package/dist/runtime/HandoffService.d.ts +244 -119
- package/dist/runtime/HandoffService.js +373 -251
- package/dist/runtime/RuntimePeerSessions.d.ts +34 -0
- package/dist/runtime/RuntimePeerSessions.js +50 -0
- package/dist/runtime/Scopes.d.ts +123 -0
- package/dist/runtime/Scopes.js +169 -0
- package/dist/runtime/SdkAgent.d.ts +19 -8
- package/dist/runtime/SdkAgent.js +23 -6
- package/dist/runtime/completeOnce.d.ts +3 -3
- package/dist/runtime/completeOnce.js +3 -3
- package/dist/runtime/createAgent.d.ts +29 -7
- package/dist/runtime/createAgent.js +57 -12
- package/dist/runtime/createModel.d.ts +4 -4
- package/dist/runtime/createModel.js +6 -6
- package/dist/runtime/lastPromptTokens.d.ts +18 -0
- package/dist/runtime/lastPromptTokens.js +26 -0
- package/dist/runtime/resolveModel.d.ts +9 -9
- package/dist/runtime/resolveModel.js +8 -8
- package/dist/scope/Scope.d.ts +10 -9
- package/dist/scope/Scope.js +6 -6
- package/dist/scope/ScopePlugin.d.ts +2 -8
- package/dist/scope/disclosure.d.ts +1 -1
- package/dist/scope/disclosure.js +1 -1
- package/dist/scope/plugins/allInOne.d.ts +13 -1
- package/dist/scope/plugins/allInOne.js +9 -5
- package/dist/scope/plugins/builtin/AsyncExecTool.d.ts +12 -0
- package/dist/scope/plugins/builtin/AsyncExecTool.js +103 -0
- package/dist/scope/plugins/builtin/AsyncTimeoutTool.d.ts +10 -0
- package/dist/scope/plugins/builtin/AsyncTimeoutTool.js +90 -0
- package/dist/scope/plugins/builtin/BuiltinToolsScopePlugin.d.ts +1 -1
- package/dist/scope/plugins/builtin/BuiltinToolsScopePlugin.js +1 -1
- package/dist/scope/plugins/builtin/DownloadFileTool.js +1 -1
- package/dist/scope/plugins/builtin/ExecTool.js +10 -199
- package/dist/scope/plugins/builtin/FindTextTool.d.ts +1 -1
- package/dist/scope/plugins/builtin/FindTextTool.js +1 -1
- package/dist/scope/plugins/builtin/GenerateImageTool.d.ts +1 -4
- package/dist/scope/plugins/builtin/GenerateImageTool.js +2 -8
- package/dist/scope/plugins/builtin/InspectFileTool.js +1 -1
- package/dist/scope/plugins/builtin/SdkCallbackTool.d.ts +4 -4
- package/dist/scope/plugins/builtin/SdkCallbackTool.js +3 -3
- package/dist/scope/plugins/builtin/SleepTool.js +2 -3
- package/dist/scope/plugins/builtin/ViewImageTool.d.ts +2 -4
- package/dist/scope/plugins/builtin/ViewImageTool.js +4 -6
- package/dist/scope/plugins/builtin/WriteTool.d.ts +7 -0
- package/dist/scope/plugins/builtin/WriteTool.js +8 -1
- package/dist/scope/plugins/builtin/asyncTasks.d.ts +41 -0
- package/dist/scope/plugins/builtin/asyncTasks.js +97 -0
- package/dist/scope/plugins/builtin/commandOutput.d.ts +22 -0
- package/dist/scope/plugins/builtin/commandOutput.js +55 -0
- package/dist/scope/plugins/builtin/commandRun.d.ts +48 -0
- package/dist/scope/plugins/builtin/commandRun.js +169 -0
- package/dist/scope/plugins/builtin/discover.d.ts +1 -3
- package/dist/scope/plugins/builtin/discover.js +1 -3
- package/dist/scope/plugins/builtin/index.d.ts +5 -7
- package/dist/scope/plugins/builtin/index.js +7 -7
- package/dist/scope/plugins/builtin/outputGuard.d.ts +1 -5
- package/dist/scope/plugins/builtin/outputGuard.js +1 -5
- package/dist/scope/plugins/mcp/McpConnectionManager.d.ts +56 -11
- package/dist/scope/plugins/mcp/McpConnectionManager.js +169 -74
- package/dist/scope/plugins/mcp/McpScopePlugin.d.ts +17 -7
- package/dist/scope/plugins/mcp/McpScopePlugin.js +36 -12
- package/dist/scope/plugins/mcp/discover.d.ts +9 -2
- package/dist/scope/plugins/mcp/discover.js +12 -14
- package/dist/scope/plugins/mcp/mcpTaskNotice.d.ts +52 -0
- package/dist/scope/plugins/mcp/mcpTaskNotice.js +8 -0
- package/dist/scope/plugins/mcp/mcpTools.d.ts +20 -2
- package/dist/scope/plugins/mcp/mcpTools.js +220 -39
- package/dist/scope/plugins/peers/PeerSessionsScopePlugin.d.ts +4 -7
- package/dist/scope/plugins/peers/PeerSessionsScopePlugin.js +4 -7
- package/dist/scope/plugins/peers/peerSessionTools.d.ts +97 -46
- package/dist/scope/plugins/peers/peerSessionTools.js +147 -121
- package/dist/scope/plugins/skills/SkillsScopePlugin.d.ts +4 -0
- package/dist/scope/plugins/skills/SkillsScopePlugin.js +10 -4
- package/dist/scope/plugins/skills/discover.d.ts +15 -8
- package/dist/scope/plugins/skills/discover.js +15 -26
- package/dist/scope/plugins/skills/skillTools.d.ts +8 -7
- package/dist/scope/plugins/skills/skillTools.js +18 -14
- package/dist/scope/plugins/subagents/SubAgentsScopePlugin.d.ts +4 -0
- package/dist/scope/plugins/subagents/SubAgentsScopePlugin.js +4 -1
- package/dist/scope/plugins/subagents/discover.d.ts +7 -1
- package/dist/scope/plugins/subagents/discover.js +7 -3
- package/dist/scope/plugins/subagents/subAgentTools.d.ts +0 -1
- package/dist/scope/plugins/subagents/subAgentTools.js +11 -1
- package/dist/scope/plugins/usertools/UserToolsScopePlugin.d.ts +4 -0
- package/dist/scope/plugins/usertools/UserToolsScopePlugin.js +4 -1
- package/dist/scope/plugins/usertools/discover.d.ts +7 -8
- package/dist/scope/plugins/usertools/discover.js +17 -27
- package/dist/shared/EntityRepository.d.ts +22 -5
- package/dist/shared/EntityRepository.js +45 -29
- package/dist/shared/content-blocks.d.ts +9 -3
- package/dist/shared/content-blocks.js +12 -19
- package/dist/shared/errors.d.ts +5 -7
- package/dist/shared/errors.js +6 -8
- package/dist/shared/logger.d.ts +21 -10
- package/dist/shared/logger.js +9 -15
- package/dist/types/index.d.ts +36 -13
- package/package.json +2 -2
- package/dist/config/migrate.d.ts +0 -115
- package/dist/config/migrate.js +0 -200
- package/dist/scope/plugins/builtin/test-helpers.d.ts +0 -3
- package/dist/scope/plugins/builtin/test-helpers.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,22 +1,79 @@
|
|
|
1
|
-
## [2.0.0-alpha.
|
|
2
|
-
|
|
3
|
-
> Follows `@ai-zen/agents-core` 5.0.0-alpha.
|
|
4
|
-
>
|
|
5
|
-
>
|
|
1
|
+
## [2.0.0-alpha.1] - 2026-11-23
|
|
2
|
+
|
|
3
|
+
> Follows `@ai-zen/agents-core` `5.0.0-alpha.2`, and it is a major bump for the same reason the
|
|
4
|
+
> kernel's was one: this package used to be business logic sitting on `send()`. A handoff awaited
|
|
5
|
+
> the round it had started, a sub-agent awaited the agent it had built, auto-migration reacted to
|
|
6
|
+
> "this round ended". None of that survives — a resident session has no "deliver and wait" any
|
|
7
|
+
> more, because any other party can push it from idle to busy — so the same behaviour had to be
|
|
8
|
+
> rebuilt on facts instead of promises.
|
|
9
|
+
>
|
|
10
|
+
> Rebuilding it is what split the package in two. The **capability face** is what `1.1.0` already
|
|
11
|
+
> was: `Scope` with its five capability sources behind `allInOne()`, `PermissionEvaluator`, the
|
|
12
|
+
> configuration and definition repositories, model resolution, `createAgent` / `SdkAgent`, handoff.
|
|
13
|
+
> The **runtime** is what the package never had: the thing that keeps those agents alive and lets
|
|
14
|
+
> them talk to each other. The line between the two halves is the line the package is now measured
|
|
15
|
+
> by — the runtime is the only place that knows who is alive, who knows whom, and when to build and
|
|
16
|
+
> when to tear down, and it still imports no host.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **`AgentRuntime`** — one resident agent per session, with `wake(sessionId, materials)`
|
|
21
|
+
(idempotent; concurrent calls share one assembly), `post({ from, to, content })`,
|
|
22
|
+
`status(sessionId)`, `openPeer({ from, prompt, agentId?, modelId?, label? })`, `kill(sessionId)`,
|
|
23
|
+
`close()`, `observe(listener)` and the snapshots `get` / `sessionOf` / `aliveOn`. It waits for
|
|
24
|
+
nobody: a delivery is what wakes a session, and there is no "one run" object to settle. Its facts
|
|
25
|
+
are a discriminated union — `resident:appeared` / `resident:gone` of its own, `scope:appeared` /
|
|
26
|
+
`scope:refreshed` / `scope:gone` from the container registry, and every kernel event of every
|
|
27
|
+
agent unchanged in name and payload with the `sessionId` added.
|
|
28
|
+
- **`Scopes`** — containers live by directory: one per `cwd`, built on first use, shared by every
|
|
29
|
+
session working there, with `for(cwd)`, `dispose(cwd)`, `refreshAll()` and `disposeAll()`.
|
|
30
|
+
`dispose()` refuses while a session is still alive on that directory instead of cascading,
|
|
31
|
+
because a cascade would silently kill sessions that are in the middle of work. No idle timer, no
|
|
32
|
+
reference counting: "nobody is using it" is not a decidable state.
|
|
33
|
+
- **Four ports** the runtime borrows and never implements: `openScope(cwd, peers)`, `open(input)`
|
|
34
|
+
(write the session, choose the identity, hand back `WakeMaterials`), `nameOf(sessionId)` and
|
|
35
|
+
`log`. A session is an opaque `string` here; a cast that fakes an instance of something in this
|
|
36
|
+
package now means a port is missing.
|
|
37
|
+
- **Peer sessions** — three tools under `scope/plugins/peers/`: `create_session` answers
|
|
38
|
+
`{ sessionId, label }` at once, `read_session_status` answers working / idle, alive, name and an
|
|
39
|
+
excerpt of the last thing said, and `post_message` says only that the message was accepted. They
|
|
40
|
+
implement none of it themselves: `PeerSessionsScopePlugin` takes a `PeerSessionPort` (`create` /
|
|
41
|
+
`status` / `send`) and without a port it produces no tools at all. `RuntimePeerSessions` is that
|
|
42
|
+
port, which is why the three tools also work with no host around. A delegated one-shot agent has
|
|
43
|
+
none of the three: it has no identity to sign a message with and can open nothing that anybody
|
|
44
|
+
would own.
|
|
45
|
+
- **One level deep, structurally** — an agent that was itself opened as a peer is created with
|
|
46
|
+
`canOpenPeers: false`, so `create_session` is not among its tools at all and the model cannot even
|
|
47
|
+
try; `post_message` and `read_session_status` stay, because peers talk both ways. Refusals are
|
|
48
|
+
structured rather than sentences: `gone` / `dead` for a delivery, `depth_exceeded` /
|
|
49
|
+
`model_unresolved` for a creation.
|
|
50
|
+
- **`async_exec` / `async_timeout`** — two tools that return at once and report later. The result
|
|
51
|
+
is delivered back into the same session at low priority, so it never lands inside the batch that
|
|
52
|
+
is currently running, and whatever is still running is reaped when the agent stops. A one-shot
|
|
53
|
+
agent gets neither (`ASYNC_TASK_TOOL_NAMES` is stripped when the tools are chosen): its call
|
|
54
|
+
stack has returned by the time the result arrives.
|
|
55
|
+
- **MCP tasks** — `call_mcp_tool` hands back the task id at once and the server pushes status
|
|
56
|
+
notifications; a terminal status goes to `McpTaskNoticePort` (`sessionOf` / `deliver`), which the
|
|
57
|
+
caller implements, while `isTerminalTaskStatus` is the single test for "this task is over". The
|
|
58
|
+
result itself is fetched by task id with `get_mcp_task_result`; `cancel_mcp_task` cancels it.
|
|
59
|
+
- **`completeOnce`** — one non-streaming call with no tools and no history, the request shape both
|
|
60
|
+
the handoff summary and auto-naming need. **`lastPromptTokens`** is the read behind the context
|
|
61
|
+
guard: the last assistant message that carries usage, never a second copy of the count.
|
|
6
62
|
|
|
7
63
|
### Changed
|
|
8
64
|
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
65
|
+
- Every plugin was re-seated on the seams the new kernel offers, and each had to justify the seam
|
|
66
|
+
it picked. `ContextGuardPlugin` refuses by **returning a string** from `onInnerLoopStart` instead
|
|
67
|
+
of throwing: throwing tears the whole loop down, while refusing leaves no placeholder behind and
|
|
68
|
+
reports `denied`. `AutoMigratePlugin` moved to `onIdle`, because migration means "nothing is
|
|
69
|
+
moving any more", not "this round ended".
|
|
70
|
+
- `HandoffService` judges a handoff round by one fact — whether the write to that path happened
|
|
71
|
+
inside that batch — instead of waiting for the agent to go idle, and there is no timer either: a
|
|
72
|
+
model that replies "done" without calling the tool is answered by the batch closing. Cancellation
|
|
73
|
+
surfaces as `HandoffAbortedError` and is never retried with the other writer.
|
|
74
|
+
- Sub-agents are built with `lifetime: "one-shot"`, and every `role: user` message injected from a
|
|
75
|
+
template carries a `source` naming the injecting tool, so a delegated task's history is never
|
|
76
|
+
mistaken for something the user said.
|
|
20
77
|
|
|
21
78
|
## [1.1.0] - 2026-11-09
|
|
22
79
|
|