@flowy-agent-store/sdk 0.1.0-beta.8 → 0.1.0-beta.9

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 CHANGED
@@ -65,9 +65,13 @@ result.danglingSkills; // 声明了但本机取不到的技能:{ id, err
65
65
  expert-pack.json # 线上 pack 逐字节
66
66
  persona.md # 仅 agent 形态(团没有自己的 persona)
67
67
  members/<id>/persona.md # 仅 team 形态,每个成员一个
68
- skills/<name>/… # 成员声明去重后的技能字节
68
+ skills/<name>/… # 团包级技能与成员声明合并去重后的技能字节
69
69
  ```
70
70
 
71
+ 团的技能有**两个来源**,`materializePack` 把两者合并后按 id 去重:顶层 `pack.skills`(该团**包级**声明、
72
+ 装机时已物化到托管技能根目录的技能)与 `team.members[].skills`(各成员 frontmatter 的 `skills:` 声明)。
73
+ 官方团大多**只在包级声明**技能(例如 `stock-partner-team`:包级 3 个、7 名成员零声明),所以两者都要算进来。
74
+
71
75
  错误语义:wire 导出失败(`agent_not_installed` / `agent_disabled` / `policy_denied` /
72
76
  `version_mismatch` / `response_too_large`…)**先于任何写盘**,不留半成品目录;`skill/files`
73
77
  失败进 `danglingSkills` 并继续;`skill/file` 在列文件成功后失败则**抛出**——那是宿主 I/O 错误,
package/dist/index.cjs CHANGED
@@ -210,11 +210,30 @@ const KILL_GRACE_MS = 2e3;
210
210
  function assertProtocolCompatible(runtimeVersion) {
211
211
  if (runtimeVersion !== _flowy_agent_store_protocol.APP_SERVER_PROTOCOL_VERSION) throw new Error(`protocol version mismatch: runtime speaks ${runtimeVersion}, SDK expects ${_flowy_agent_store_protocol.APP_SERVER_PROTOCOL_VERSION}`);
212
212
  }
213
+ /**
214
+ * The host-policy environment the typed options above expand to.
215
+ *
216
+ * The spawned host cannot be handed backend CLI flags: `apps/agent-store` parses
217
+ * its own argv (`--host` / `--port` / `--data-dir` / `--no-open`) and has no
218
+ * `--agent-store-config`, so a flag would make clap exit before the readiness
219
+ * line. The parent environment is therefore the only channel a launcher has —
220
+ * the same conclusion `NOMI_LOG_LEVEL` already documents for the log filter.
221
+ */
222
+ function hostPolicyEnv(options) {
223
+ const env = {};
224
+ if (options.marketDownload !== void 0) env["AGENT_STORE_MARKET_DOWNLOAD"] = options.marketDownload;
225
+ if (options.configPath !== void 0) env["AGENT_STORE_CONFIG"] = options.configPath;
226
+ return env;
227
+ }
213
228
  async function spawnAppServer(options = {}) {
214
229
  const bin = resolveAppServerBin(options.bin);
215
230
  const ownedDir = options.dataDir === void 0;
216
231
  const dataDir = ownedDir ? await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "agent-store-sdk-")) : options.dataDir;
217
232
  const port = options.port ?? 0;
233
+ const policyEnv = {
234
+ ...hostPolicyEnv(options),
235
+ ...options.env
236
+ };
218
237
  const { child, exited } = spawnRuntimeChild(bin, [
219
238
  "--host",
220
239
  "127.0.0.1",
@@ -224,7 +243,11 @@ async function spawnAppServer(options = {}) {
224
243
  dataDir,
225
244
  "--no-open",
226
245
  ...options.extraArgs ?? []
227
- ], options);
246
+ ], {
247
+ ...Object.keys(policyEnv).length > 0 ? { env: policyEnv } : {},
248
+ cwd: options.cwd,
249
+ onExit: options.onExit
250
+ });
228
251
  const stderrTail = [];
229
252
  child.stderr?.on("data", (chunk) => {
230
253
  for (const line of String(chunk).split(/\r?\n/)) {
package/dist/index.d.cts CHANGED
@@ -116,9 +116,38 @@ interface SpawnOptions {
116
116
  port?: number;
117
117
  /** Extra CLI args appended after the managed ones. */
118
118
  extraArgs?: string[];
119
+ /**
120
+ * What the spawned host does with its default marketplace sources at boot
121
+ * (doc `37` §3.1). Sent as `AGENT_STORE_MARKET_DOWNLOAD`.
122
+ *
123
+ * - `"lazy"` — register the declared sources and download nothing; the
124
+ * archives wait for an explicit `market/refresh` / `refreshMarketplace()`;
125
+ * - `"none"` — register nothing at all, so `store/list` starts empty;
126
+ * - `"eager"` — fetch every declared source during boot.
127
+ *
128
+ * Omitted = the host's own policy (`download_on_start` per source, default
129
+ * `true`, so a declared source *is* downloaded unless it says otherwise).
130
+ * This is a process-scoped override: nothing is written to the user's config.
131
+ */
132
+ marketDownload?: "eager" | "lazy" | "none";
133
+ /**
134
+ * Config file for this child only (doc `37` §3.1). Sent as
135
+ * `AGENT_STORE_CONFIG`.
136
+ *
137
+ * Without it the host reads the per-user `~/.agent-store/config.toml` — which
138
+ * a spawned, SDK-owned host should not have to share. The data directory is
139
+ * independent of this (`dataDir`, always explicit).
140
+ */
141
+ configPath?: string;
119
142
  /** How long to wait for the readiness line. Defaults to 120s (cold DB init). */
120
143
  readyTimeoutMs?: number;
121
- /** Extra environment variables, merged over the parent's `process.env`. */
144
+ /**
145
+ * Extra environment variables, merged over the parent's `process.env`.
146
+ *
147
+ * An entry here **wins over the typed options above** (`marketDownload`,
148
+ * `configPath`): the raw map is the caller's most specific statement, and
149
+ * nothing this factory derives should silently overwrite it.
150
+ */
122
151
  env?: Record<string, string | undefined>;
123
152
  /** Working directory for the child. Defaults to the parent's cwd. */
124
153
  cwd?: string;
package/dist/index.d.mts CHANGED
@@ -116,9 +116,38 @@ interface SpawnOptions {
116
116
  port?: number;
117
117
  /** Extra CLI args appended after the managed ones. */
118
118
  extraArgs?: string[];
119
+ /**
120
+ * What the spawned host does with its default marketplace sources at boot
121
+ * (doc `37` §3.1). Sent as `AGENT_STORE_MARKET_DOWNLOAD`.
122
+ *
123
+ * - `"lazy"` — register the declared sources and download nothing; the
124
+ * archives wait for an explicit `market/refresh` / `refreshMarketplace()`;
125
+ * - `"none"` — register nothing at all, so `store/list` starts empty;
126
+ * - `"eager"` — fetch every declared source during boot.
127
+ *
128
+ * Omitted = the host's own policy (`download_on_start` per source, default
129
+ * `true`, so a declared source *is* downloaded unless it says otherwise).
130
+ * This is a process-scoped override: nothing is written to the user's config.
131
+ */
132
+ marketDownload?: "eager" | "lazy" | "none";
133
+ /**
134
+ * Config file for this child only (doc `37` §3.1). Sent as
135
+ * `AGENT_STORE_CONFIG`.
136
+ *
137
+ * Without it the host reads the per-user `~/.agent-store/config.toml` — which
138
+ * a spawned, SDK-owned host should not have to share. The data directory is
139
+ * independent of this (`dataDir`, always explicit).
140
+ */
141
+ configPath?: string;
119
142
  /** How long to wait for the readiness line. Defaults to 120s (cold DB init). */
120
143
  readyTimeoutMs?: number;
121
- /** Extra environment variables, merged over the parent's `process.env`. */
144
+ /**
145
+ * Extra environment variables, merged over the parent's `process.env`.
146
+ *
147
+ * An entry here **wins over the typed options above** (`marketDownload`,
148
+ * `configPath`): the raw map is the caller's most specific statement, and
149
+ * nothing this factory derives should silently overwrite it.
150
+ */
122
151
  env?: Record<string, string | undefined>;
123
152
  /** Working directory for the child. Defaults to the parent's cwd. */
124
153
  cwd?: string;
package/dist/index.mjs CHANGED
@@ -209,11 +209,30 @@ const KILL_GRACE_MS = 2e3;
209
209
  function assertProtocolCompatible(runtimeVersion) {
210
210
  if (runtimeVersion !== APP_SERVER_PROTOCOL_VERSION) throw new Error(`protocol version mismatch: runtime speaks ${runtimeVersion}, SDK expects ${APP_SERVER_PROTOCOL_VERSION}`);
211
211
  }
212
+ /**
213
+ * The host-policy environment the typed options above expand to.
214
+ *
215
+ * The spawned host cannot be handed backend CLI flags: `apps/agent-store` parses
216
+ * its own argv (`--host` / `--port` / `--data-dir` / `--no-open`) and has no
217
+ * `--agent-store-config`, so a flag would make clap exit before the readiness
218
+ * line. The parent environment is therefore the only channel a launcher has —
219
+ * the same conclusion `NOMI_LOG_LEVEL` already documents for the log filter.
220
+ */
221
+ function hostPolicyEnv(options) {
222
+ const env = {};
223
+ if (options.marketDownload !== void 0) env["AGENT_STORE_MARKET_DOWNLOAD"] = options.marketDownload;
224
+ if (options.configPath !== void 0) env["AGENT_STORE_CONFIG"] = options.configPath;
225
+ return env;
226
+ }
212
227
  async function spawnAppServer(options = {}) {
213
228
  const bin = resolveAppServerBin(options.bin);
214
229
  const ownedDir = options.dataDir === void 0;
215
230
  const dataDir = ownedDir ? await mkdtemp(join(tmpdir(), "agent-store-sdk-")) : options.dataDir;
216
231
  const port = options.port ?? 0;
232
+ const policyEnv = {
233
+ ...hostPolicyEnv(options),
234
+ ...options.env
235
+ };
217
236
  const { child, exited } = spawnRuntimeChild(bin, [
218
237
  "--host",
219
238
  "127.0.0.1",
@@ -223,7 +242,11 @@ async function spawnAppServer(options = {}) {
223
242
  dataDir,
224
243
  "--no-open",
225
244
  ...options.extraArgs ?? []
226
- ], options);
245
+ ], {
246
+ ...Object.keys(policyEnv).length > 0 ? { env: policyEnv } : {},
247
+ cwd: options.cwd,
248
+ onExit: options.onExit
249
+ });
227
250
  const stderrTail = [];
228
251
  child.stderr?.on("data", (chunk) => {
229
252
  for (const line of String(chunk).split(/\r?\n/)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowy-agent-store/sdk",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0-beta.9",
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.8",
29
- "@flowy-agent-store/protocol": "0.1.0-beta.8"
28
+ "@flowy-agent-store/client": "0.1.0-beta.9",
29
+ "@flowy-agent-store/protocol": "0.1.0-beta.9"
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.8",
44
- "@flowy-agent-store/runtime-linux-x64": "0.1.0-beta.8",
45
- "@flowy-agent-store/runtime-linux-arm64": "0.1.0-beta.8",
46
- "@flowy-agent-store/runtime-darwin-x64": "0.1.0-beta.8",
47
- "@flowy-agent-store/runtime-darwin-arm64": "0.1.0-beta.8"
43
+ "@flowy-agent-store/runtime-win32-x64": "0.1.0-beta.9",
44
+ "@flowy-agent-store/runtime-linux-x64": "0.1.0-beta.9",
45
+ "@flowy-agent-store/runtime-linux-arm64": "0.1.0-beta.9",
46
+ "@flowy-agent-store/runtime-darwin-x64": "0.1.0-beta.9",
47
+ "@flowy-agent-store/runtime-darwin-arm64": "0.1.0-beta.9"
48
48
  }
49
49
  }