@flowy-agent-store/sdk 0.1.0-beta.3 → 0.1.0-beta.4
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/README.md +47 -3
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -8,13 +8,57 @@ import { launchClient } from "@flowy-agent-store/sdk";
|
|
|
8
8
|
const session = await launchClient({
|
|
9
9
|
client: { name: "my-app", version: "0.1.0" },
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
// 获取:浏览 / 搜索目录(含每个条目的安装状态)
|
|
13
|
+
const items = await session.client.store.search("software");
|
|
14
|
+
|
|
15
|
+
// 安装:导入 + 注册,并等到组件真的可用(默认 waitForReady: true)
|
|
16
|
+
const outcome = await session.client.store.install(items[0]);
|
|
17
|
+
if (outcome.readyIssue === "authorization_required") {
|
|
18
|
+
await session.client.connectors.authStart(outcome.readyComponentId!);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 禁用 / 启用:连接器改 mcp_servers.enabled,专家/专家团改 Preset.enabled
|
|
22
|
+
await session.client.store.setEnabled(items[0], false);
|
|
23
|
+
|
|
24
|
+
// 卸载:真的释放运行时产物(技能目录 / Preset / MCP server 行),再清记录
|
|
25
|
+
const released = await session.client.store.uninstall(items[0]);
|
|
26
|
+
if (!released.ok) console.warn(released.components.filter((c) => !c.ok));
|
|
27
|
+
|
|
12
28
|
await session.close();
|
|
13
29
|
```
|
|
14
30
|
|
|
31
|
+
五个动词都在 SDK 里可用,但**都不在 `@flowy-agent-store/sdk` 这个包里**:本包只负责进程与传输,方法来自 `@flowy-agent-store/client`,其中 `store` 子客户端把 `install` / `uninstall` / `setEnabled` 编排成一条状态机(`search → install → … → uninstall`)。这样分层是刻意的——见 `docs/agent-store/12-sdk-packaging.md` §2 的职责划分。
|
|
32
|
+
|
|
33
|
+
几条使用上的事实(都是实测结论,不是约定):
|
|
34
|
+
|
|
35
|
+
- `store.install` 默认**等到可用**才 resolve。技能拷完即可用,连接器不然:它注册出来是 **disabled** 的(安装器的既定默认),所以就绪检查会先把它 enable,再跑一次探针——只轮询状态永远到不了 `connected`,因为状态派生自上一次探针。
|
|
36
|
+
- 就绪超时**不会丢掉安装结果**:返回成功的安装 + `ready: false` / `readyIssue: "ready_timeout"`。需要 OAuth 的连接器立刻返回 `authorization_required`,不把超时预算烧光。
|
|
37
|
+
- 没有「更新」动词。`store.checkUpdates()` 只报告哪些条目有新版,`store.updateHint(item)` 告诉你该怎么做——当前是 `"uninstall_reinstall"`:卸载后重装,安装路径会按版本漂移重新导入,取到市场当前版本。
|
|
38
|
+
- 卸载是**可重入**的:产物已不在算成功。部分失败时那些组件保持已安装、`ok: false` 且点名到组件,重试有意义。
|
|
39
|
+
- `store.setEnabled(item, false)` 对技能只翻一个目录层标记,返回 `code: "skill_disable_flag_only"`——技能语料没有启用状态,要让技能离开运行时只能 `uninstall`。这个 code 会原样透出,不会被吞。
|
|
40
|
+
|
|
15
41
|
规则(P0 实测结论):
|
|
16
42
|
|
|
17
43
|
- 子进程固定 `--host 127.0.0.1 --no-open`;非回环一律拒绝(`isLoopbackUrl`)。
|
|
44
|
+
- 工具面不用改宿主自己的 `~/.agent-store/config.toml`:`env.AGENT_STORE_TOOLS` 直接指定,值是 JSON(形状同 `[tools]` 表),**整份替换**文件里的策略,`{}` = 全开。它只在 Store 宿主生效(桌面 / Web 宿主不采纳 `[tools]`),且子进程启动时读一次。
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const session = await launchClient({
|
|
48
|
+
client: { name: "my-app", version: "0.1.0" },
|
|
49
|
+
env: {
|
|
50
|
+
// 只要基础能力:关掉桌面控制/浏览器与几个域
|
|
51
|
+
AGENT_STORE_TOOLS: JSON.stringify({
|
|
52
|
+
web: true,
|
|
53
|
+
computer: false,
|
|
54
|
+
browser: false,
|
|
55
|
+
domains: { cron: false, knowledge: false, media: false },
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
18
60
|
- 默认自带临时 `--data-dir` 并在 `close()` 删除;传自己的目录即表示独占——后端单实例锁会 fail-fast。
|
|
19
|
-
- 二进制定位:`bin` 参数 → `AGENT_STORE_BIN` → `PATH
|
|
20
|
-
- 就绪行 `protocol_version` 与 SDK
|
|
61
|
+
- 二进制定位:`bin` 参数 → `AGENT_STORE_BIN` → 平台 runtime 包的 `vendor/` → `PATH`;找不到直接报错(**不下载**,见 P2)。
|
|
62
|
+
- 就绪行 `protocol_version` 与 SDK 不一致时杀掉子进程并报错(含两端版本)。该值是**契约指纹**,不是版本号:任何 wire 变更都会 bump。
|
|
63
|
+
|
|
64
|
+
不在本包范围内(`07-typescript-sdk.md` §非目标):`config/*` 与 `skill/*` 写面。它们的**类型**在 `@flowy-agent-store/protocol`(wire 上存在的方法就有形状),但**没有** typed 方法——因为这些面跟着宿主自己的设置文件与技能目录走,是最易变的部分。这是可发现性边界,不是权限边界:`client.transport` 是公开的,服务端按磁盘归属判定可写性。要用就直连 `transport.request`,并自担变动。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowy-agent-store/sdk",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Node.js host for the Agent Store App Server: spawn the runtime binary and connect over loopback (docs/agent-store/12 P1-3)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@flowy-agent-store/client": "0.1.0-beta.
|
|
29
|
-
"@flowy-agent-store/protocol": "0.1.0-beta.
|
|
28
|
+
"@flowy-agent-store/client": "0.1.0-beta.4",
|
|
29
|
+
"@flowy-agent-store/protocol": "0.1.0-beta.4"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsdown",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"module": "./dist/index.mjs",
|
|
41
41
|
"types": "./dist/index.d.mts",
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@flowy-agent-store/runtime-win32-x64": "0.1.0-beta.
|
|
44
|
-
"@flowy-agent-store/runtime-linux-x64": "0.1.0-beta.
|
|
45
|
-
"@flowy-agent-store/runtime-linux-arm64": "0.1.0-beta.
|
|
46
|
-
"@flowy-agent-store/runtime-darwin-x64": "0.1.0-beta.
|
|
47
|
-
"@flowy-agent-store/runtime-darwin-arm64": "0.1.0-beta.
|
|
43
|
+
"@flowy-agent-store/runtime-win32-x64": "0.1.0-beta.4",
|
|
44
|
+
"@flowy-agent-store/runtime-linux-x64": "0.1.0-beta.4",
|
|
45
|
+
"@flowy-agent-store/runtime-linux-arm64": "0.1.0-beta.4",
|
|
46
|
+
"@flowy-agent-store/runtime-darwin-x64": "0.1.0-beta.4",
|
|
47
|
+
"@flowy-agent-store/runtime-darwin-arm64": "0.1.0-beta.4"
|
|
48
48
|
}
|
|
49
49
|
}
|