ai-fly 0.3.0-alpha.1 → 0.3.0-alpha.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/dist/ai-fly.js CHANGED
@@ -9,7 +9,7 @@ const USAGE = `ai-fly — peer-to-peer HTTP/WebSocket bridge with AI-ready prese
9
9
 
10
10
  Daemon:
11
11
  ai-fly run the provider daemon (foreground; Ctrl+C stops)
12
- ai-fly daemon start [--detach] [--data <dir>] [--relay <url>]...
12
+ ai-fly daemon start [--detach] [--data <dir>] [--relay <url>]... [--proxy <url|env|none>]
13
13
  ai-fly daemon stop [--force] | info | restart [--detach] | log [--lines <n>]
14
14
  ai-fly serve alias of 'daemon start'
15
15
 
@@ -27,9 +27,9 @@ Provider:
27
27
  ai-fly presets [search] [--json] featured + models.dev long tail
28
28
 
29
29
  Consumer:
30
- ai-fly join <dweb1-token> [--data <dir>] admit this device (fabric layer)
31
- ai-fly import <aifly1-link> [--run] [--preview] bundle link: join + keyring
32
- ai-fly run [--data <dir>] [--strict-ports] run the local gateway
30
+ ai-fly join <dweb1-token> [--data <dir>] [--proxy …] admit this device (fabric layer)
31
+ ai-fly import <aifly1-link> [--run] [--preview] [--proxy …] bundle link: join + keyring
32
+ ai-fly run [--data <dir>] [--strict-ports] [--proxy …] run the local gateway
33
33
  ai-fly ports [--data <dir>] [<serviceId> --port <n>] view/override mapped ports
34
34
  ai-fly test [--data <dir>] [--service <name>] [--form …] [--content <text>]
35
35
  single AI request through the local gateway
@@ -60,8 +60,8 @@ async function dispatch(command, rest) {
60
60
  const lazy = (load) => {
61
61
  return (argv, ctx) => load().then((m) => m.run([...argv], ctx));
62
62
  };
63
- return match(command).with("serve", () => lazy(() => import("./serve-Dk8Id1ai.mjs"))(rest)).with("daemon", () => lazy(() => import("./daemon-Cw1uCKMA.mjs"))(rest)).with("presets", () => lazy(() => import("./presets-C73CAMZ6.mjs"))(rest)).with("secret", () => lazy(() => import("./secret-SA37VND5.mjs"))(rest)).with("settings", async () => (await import("./settings-DU0YqNDt.mjs")).runAsSettings(rest, {})).with("relay", async () => (await import("./settings-DU0YqNDt.mjs")).runAsRelay(rest, {})).with("test", () => lazy(() => import("./test-Bc0OKBAi.mjs"))(rest)).with("service", () => lazy(() => import("./service-B5uORhl3.mjs"))(rest)).with("group", () => lazy(() => import("./group-B96IKEDF.mjs"))(rest)).with("share", () => lazy(() => import("./share-D1eMLG2r.mjs"))(rest)).with("revoke", () => lazy(() => import("./revoke-uRcIM8BX.mjs"))(rest)).with("join", () => lazy(() => import("./join-BB0W6DDq.mjs"))(rest)).with("import", () => lazy(() => import("./import-DL3cw0Ec.mjs"))(rest)).with("run", () => lazy(() => import("./run-CcWiV8JC.mjs"))(rest)).with("ports", () => lazy(() => import("./ports-8QzyXRWz.mjs"))(rest)).with("forget", () => lazy(() => import("./forget-BM0J4Oji.mjs"))(rest)).with("key", () => {
64
- if (rest[0] === "add") return lazy(() => import("./key-uMhgWu1I.mjs"))(rest);
63
+ return match(command).with("serve", () => lazy(() => import("./serve-DSBlodTF.mjs"))(rest)).with("daemon", () => lazy(() => import("./daemon-DklsEniO.mjs"))(rest)).with("presets", () => lazy(() => import("./presets-C73CAMZ6.mjs"))(rest)).with("secret", () => lazy(() => import("./secret-SA37VND5.mjs"))(rest)).with("settings", async () => (await import("./settings-DU0YqNDt.mjs")).runAsSettings(rest, {})).with("relay", async () => (await import("./settings-DU0YqNDt.mjs")).runAsRelay(rest, {})).with("test", () => lazy(() => import("./test-Bc0OKBAi.mjs"))(rest)).with("service", () => lazy(() => import("./service-B5uORhl3.mjs"))(rest)).with("group", () => lazy(() => import("./group-B96IKEDF.mjs"))(rest)).with("share", () => lazy(() => import("./share-Cug0944N.mjs"))(rest)).with("revoke", () => lazy(() => import("./revoke-CkpvK33Q.mjs"))(rest)).with("join", () => lazy(() => import("./join-DsKUAibH.mjs"))(rest)).with("import", () => lazy(() => import("./import-tilxdbTH.mjs"))(rest)).with("run", () => lazy(() => import("./run-DbPXAm6h.mjs"))(rest)).with("ports", () => lazy(() => import("./ports-rRppuBgo.mjs"))(rest)).with("forget", () => lazy(() => import("./forget-B17zGwj4.mjs"))(rest)).with("key", () => {
64
+ if (rest[0] === "add") return lazy(() => import("./key-CNufbB__.mjs"))(rest);
65
65
  return lazy(() => import("./key-BiEp995L.mjs"))(rest);
66
66
  }).with("status", async () => {
67
67
  const [scope, ...tail] = rest;
@@ -69,8 +69,8 @@ async function dispatch(command, rest) {
69
69
  const wantConsumer = scope === "consumer" || scope !== "provider" && consumersRootExists();
70
70
  const argv = scope === "provider" || scope === "consumer" ? tail : rest;
71
71
  let code = 0;
72
- if (wantProvider) code = Math.max(code, await lazy(() => import("./status-Eu_4Bc1O.mjs"))(argv));
73
- if (wantConsumer) code = Math.max(code, await lazy(() => import("./status-C24okZuH.mjs"))(argv));
72
+ if (wantProvider) code = Math.max(code, await lazy(() => import("./status-SkNsxGnk.mjs"))(argv));
73
+ if (wantConsumer) code = Math.max(code, await lazy(() => import("./status-B-j454u2.mjs"))(argv));
74
74
  if (!wantProvider && !wantConsumer) process.stdout.write("nothing to report: no provider storage and no imported consumers\n");
75
75
  return code;
76
76
  }).otherwise(() => {
@@ -1,5 +1,5 @@
1
1
  import { n as resolveRelayUrls, t as loadConfig } from "./config-BlZnFqx7.mjs";
2
- import { t as loadSdk } from "./sdk-DCHLGZRg.mjs";
2
+ import { n as loadSdk, t as resolveHttpProxy } from "./proxy-D7VMUVEg.mjs";
3
3
  import { t as loadSettings } from "./settings-C1Hb4zwd.mjs";
4
4
  import { homedir } from "node:os";
5
5
  //#region src/cli/commands/consumer/common.ts
@@ -17,15 +17,18 @@ function ctxHomedir(ctx) {
17
17
  * provider 在那个 relay 上,不拨它就永远会不了面):逐次解析为
18
18
  * flag > ring/链接内嵌 relay(opts.relayUrls,调用侧按 ring 传入)> env > file。
19
19
  * @param linkRelayUrls aifly1. 链接内嵌 relay(import 的 join 阶段用;空 = 缺席)
20
+ * @param proxyFlag --proxy 旗标值(url | 'env' | 'none';缺省回落 AIFLY_PROXY env)
20
21
  */
21
- async function createSdkFabricFactory(relayFlag, ctx = {}, linkRelayUrls) {
22
+ async function createSdkFabricFactory(relayFlag, ctx = {}, linkRelayUrls, proxyFlag) {
22
23
  const sdk = await loadSdk();
24
+ const httpProxy = resolveHttpProxy(proxyFlag);
23
25
  let relaySettings = null;
24
26
  try {
25
27
  relaySettings = loadSettings(ctxHomedir(ctx)).relayUrls;
26
28
  } catch {}
27
29
  const toOpts = (opts) => {
28
30
  const fabricOpts = { dataDir: opts.dataDir };
31
+ if (httpProxy !== void 0) fabricOpts.httpProxy = httpProxy;
29
32
  const link = opts.relayUrls ?? linkRelayUrls;
30
33
  const urls = resolveRelayUrls({
31
34
  ...relayFlag !== void 0 ? { flag: relayFlag } : {},
@@ -97,14 +97,18 @@ const SPEC = {
97
97
  relay: { type: "multi" },
98
98
  alias: { type: "string" },
99
99
  "log-usage": { type: "boolean" },
100
+ proxy: { type: "string" },
100
101
  lines: { type: "string" }
101
102
  };
102
103
  const USAGE = `usage:
103
- ai-fly daemon start [--detach] [--data <dir>] [--relay <url>]...
104
+ ai-fly daemon start [--detach] [--data <dir>] [--relay <url>]... [--proxy <url|env|none>]
104
105
  ai-fly daemon stop [--force]
105
106
  ai-fly daemon info
106
- ai-fly daemon restart [--detach] [--data <dir>] [--relay <url>]...
107
- ai-fly daemon log [--lines <n>]`;
107
+ ai-fly daemon restart [--detach] [--data <dir>] [--relay <url>]... [--proxy <url|env|none>]
108
+ ai-fly daemon log [--lines <n>]
109
+
110
+ --proxy: relay 控制面 HTTP 代理(QUIC 数据面永不过代理);等价 env AIFLY_PROXY。
111
+ 'env' = 读进程环境变量(HTTP_PROXY/HTTPS_PROXY);'none' = 显式禁用。`;
108
112
  async function run(argv, ctx = {}) {
109
113
  const home = ctx.homedir ?? homedir();
110
114
  const sub = argv[0];
@@ -173,7 +177,7 @@ async function start(startArgv, home) {
173
177
  process.on("exit", () => {
174
178
  clearPid(home);
175
179
  });
176
- const { run: serveRun } = await import("./serve-Dk8Id1ai.mjs");
180
+ const { run: serveRun } = await import("./serve-DSBlodTF.mjs");
177
181
  return serveRun([...startArgv], { homedir: home });
178
182
  }
179
183
  /** 后台 pid(活性核验;陈旧 pidfile 就地清理返回 null)。 */
@@ -1,7 +1,7 @@
1
1
  import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { d as removeKeyring, n as consumersRoot } from "./store-BiTS2FTl.mjs";
4
- import { n as ctxHomedir, r as ctxOut } from "./common-Ds1lf39d.mjs";
4
+ import { n as ctxHomedir, r as ctxOut } from "./common-CgxCXeTt.mjs";
5
5
  import { homedir } from "node:os";
6
6
  //#region src/cli/commands/consumer/forget.ts
7
7
  async function run(argv, ctx = {}) {
@@ -1,7 +1,7 @@
1
1
  import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { n as consumersRoot, s as listKeyrings } from "./store-BiTS2FTl.mjs";
4
- import { a as ringsForRun, i as printListeners, n as ctxHomedir, o as waitForSignals, r as ctxOut, t as createSdkFabricFactory } from "./common-Ds1lf39d.mjs";
4
+ import { a as ringsForRun, i as printListeners, n as ctxHomedir, o as waitForSignals, r as ctxOut, t as createSdkFabricFactory } from "./common-CgxCXeTt.mjs";
5
5
  import { a as importLink, i as formatLinkPreview, n as decodeShareLink, r as formatKeyringSummary } from "./join-hyqiwEek.mjs";
6
6
  import { n as createFabricProviderTransport, t as startEngine } from "./runtime-D_nxUEjd.mjs";
7
7
  import { homedir } from "node:os";
@@ -15,7 +15,8 @@ async function run(argv, ctx = {}) {
15
15
  preview: { type: "boolean" },
16
16
  run: { type: "boolean" },
17
17
  "strict-ports": { type: "boolean" },
18
- relay: { type: "multi" }
18
+ relay: { type: "multi" },
19
+ proxy: { type: "string" }
19
20
  }, { homedir: ctx.homedir ?? homedir() });
20
21
  const link = positionals[0];
21
22
  if (link === void 0) throw new UsageError("error: import requires a share link argument\nusage: ai-fly import <aifly1-link> [--data <dir>] [--preview] [--run]");
@@ -31,7 +32,7 @@ async function run(argv, ctx = {}) {
31
32
  if (flagRelays !== void 0 && flagRelays.length > 0 && linkRelays.length > 0) {
32
33
  if (!(flagRelays.length === linkRelays.length && flagRelays.every((u) => linkRelays.includes(u)))) out("warning: --relay overrides the share link's relay entries; if the provider stays unreachable, drop the flag to use the link's entries");
33
34
  } else if (linkRelays.length > 0) out(`relay: using ${linkRelays.length} entry URL(s) from the share link (override with --relay)`);
34
- const factory = await createSdkFabricFactory(flagRelays, ctx, linkRelays);
35
+ const factory = await createSdkFabricFactory(flagRelays, ctx, linkRelays, options.proxy);
35
36
  const result = await importLink(link, {
36
37
  consumersRoot: root,
37
38
  fabric: factory
@@ -1,7 +1,7 @@
1
1
  import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { n as consumersRoot } from "./store-BiTS2FTl.mjs";
4
- import { n as ctxHomedir, r as ctxOut, t as createSdkFabricFactory } from "./common-Ds1lf39d.mjs";
4
+ import { n as ctxHomedir, r as ctxOut, t as createSdkFabricFactory } from "./common-CgxCXeTt.mjs";
5
5
  import { o as joinDevice } from "./join-hyqiwEek.mjs";
6
6
  import { homedir } from "node:os";
7
7
  //#region src/cli/commands/consumer/join.ts
@@ -11,13 +11,14 @@ async function run(argv, ctx = {}) {
11
11
  type: "string",
12
12
  tilde: true
13
13
  },
14
- relay: { type: "multi" }
14
+ relay: { type: "multi" },
15
+ proxy: { type: "string" }
15
16
  }, { homedir: ctx.homedir ?? homedir() });
16
17
  const token = positionals[0];
17
18
  if (token === void 0) throw new UsageError("error: join requires an invite token argument\nusage: ai-fly join <dweb1-token> [--data <dir>]");
18
19
  const out = ctxOut(ctx);
19
20
  const root = consumersRoot(options.data, ctxHomedir(ctx));
20
- const factory = await createSdkFabricFactory(options.relay, ctx);
21
+ const factory = await createSdkFabricFactory(options.relay, ctx, void 0, options.proxy);
21
22
  const result = await joinDevice(token, root, { fabric: factory });
22
23
  if (result.alreadyJoined) {
23
24
  out(`already joined to provider '${result.ring.alias}' (${result.ring.endpointId})`);
@@ -1,7 +1,7 @@
1
1
  import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { n as consumersRoot } from "./store-BiTS2FTl.mjs";
4
- import { n as ctxHomedir, r as ctxOut } from "./common-Ds1lf39d.mjs";
4
+ import { n as ctxHomedir, r as ctxOut } from "./common-CgxCXeTt.mjs";
5
5
  import { r as formatKeyringSummary, t as addKey } from "./join-hyqiwEek.mjs";
6
6
  import { homedir } from "node:os";
7
7
  //#region src/cli/commands/consumer/key.ts
@@ -1,7 +1,7 @@
1
1
  import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { n as consumersRoot, p as setPort, s as listKeyrings } from "./store-BiTS2FTl.mjs";
4
- import { n as ctxHomedir, r as ctxOut } from "./common-Ds1lf39d.mjs";
4
+ import { n as ctxHomedir, r as ctxOut } from "./common-CgxCXeTt.mjs";
5
5
  import { i as validatePortArg, n as desiredPortFor } from "./ports-pI59MtmI.mjs";
6
6
  import { homedir } from "node:os";
7
7
  //#region src/cli/commands/consumer/ports.ts
@@ -0,0 +1,21 @@
1
+ import { n as UsageError } from "./errors-BGtxPkM7.mjs";
2
+ //#region src/sdk.ts
3
+ async function loadSdk() {
4
+ const candidate = await import("@jixo/opendweb-client-sdk");
5
+ if (typeof candidate.Fabric === "function") return candidate;
6
+ const def = candidate.default;
7
+ if (def !== void 0 && typeof def.Fabric === "function") return def;
8
+ throw new Error("error: @jixo/opendweb-client-sdk export shape unexpected (no Fabric via named or default interop)");
9
+ }
10
+ //#endregion
11
+ //#region src/cli/proxy.ts
12
+ function resolveHttpProxy(flag, env = process.env.AIFLY_PROXY) {
13
+ const spec = flag ?? env;
14
+ if (spec === void 0 || spec === "") return void 0;
15
+ if (spec === "none") return "none";
16
+ if (spec === "env") return "from-env";
17
+ if (!/^https?:\/\//i.test(spec)) throw new UsageError(`error: --proxy expects an http(s):// URL, 'env' or 'none' (got '${spec}')`);
18
+ return { url: spec };
19
+ }
20
+ //#endregion
21
+ export { loadSdk as n, resolveHttpProxy as t };
@@ -1,7 +1,8 @@
1
1
  import { n as UsageError, r as reportCliError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
+ import { t as resolveHttpProxy } from "./proxy-D7VMUVEg.mjs";
3
4
  import { d as str, l as resolveDataDir, u as resolvedRelayUrls } from "./common-CqxqIg6D.mjs";
4
- import { t as openExistingFabric } from "./serve-DQ5ces99.mjs";
5
+ import { t as openExistingFabric } from "./serve-Be4zdKVj.mjs";
5
6
  import { homedir } from "node:os";
6
7
  //#region src/cli/commands/provider/revoke.ts
7
8
  const SPEC = {
@@ -20,7 +21,7 @@ async function run(argv, ctx = {}) {
20
21
  if (endpointId === void 0 || endpointId === "") throw new UsageError("error: revoke requires an <endpointId> argument");
21
22
  if (positionals.length > 1) throw new UsageError(`error: unexpected argument '${positionals[1]}'`);
22
23
  const dataDir = resolveDataDir(str(options.data), home);
23
- fabric = await openExistingFabric(dataDir, resolvedRelayUrls(options, home));
24
+ fabric = await openExistingFabric(dataDir, resolvedRelayUrls(options, home), resolveHttpProxy(void 0));
24
25
  await fabric.revoke(endpointId);
25
26
  process.stdout.write(`member revoked: ${endpointId}\n`);
26
27
  return 0;
@@ -1,7 +1,7 @@
1
1
  import { t as CliError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
3
  import { n as consumersRoot, s as listKeyrings } from "./store-BiTS2FTl.mjs";
4
- import { a as ringsForRun, i as printListeners, n as ctxHomedir, o as waitForSignals, r as ctxOut, t as createSdkFabricFactory } from "./common-Ds1lf39d.mjs";
4
+ import { a as ringsForRun, i as printListeners, n as ctxHomedir, o as waitForSignals, r as ctxOut, t as createSdkFabricFactory } from "./common-CgxCXeTt.mjs";
5
5
  import { n as createFabricProviderTransport, t as startEngine } from "./runtime-D_nxUEjd.mjs";
6
6
  import { homedir } from "node:os";
7
7
  //#region src/cli/commands/consumer/run.ts
@@ -12,7 +12,8 @@ async function run(argv, ctx = {}) {
12
12
  tilde: true
13
13
  },
14
14
  "strict-ports": { type: "boolean" },
15
- relay: { type: "multi" }
15
+ relay: { type: "multi" },
16
+ proxy: { type: "string" }
16
17
  }, { homedir: ctx.homedir ?? homedir() });
17
18
  const out = ctxOut(ctx);
18
19
  const root = consumersRoot(options.data, ctxHomedir(ctx));
@@ -20,7 +21,8 @@ async function run(argv, ctx = {}) {
20
21
  for (const w of warnings) out(`warning: ${w}`);
21
22
  const engineRings = ringsForRun(rings);
22
23
  if (engineRings.length === 0) throw new CliError("error: no imported providers - run 'ai-fly import <aifly1-link>' or 'ai-fly join <token>' first");
23
- const factory = await createSdkFabricFactory(options.relay, ctx);
24
+ const factory = await createSdkFabricFactory(options.relay, ctx, void 0, options.proxy);
25
+ out(`gateway starting - booting fabric for ${engineRings.length} provider ring(s) (unreachable relays can stall this ~30s; Ctrl+C to abort)...`);
24
26
  const engine = await startEngine({
25
27
  rings: engineRings,
26
28
  consumersRoot: root,
@@ -1,5 +1,5 @@
1
1
  import { c as RESP_META_HEADER_WHITELIST, i as FRAME_TYPE, s as REJECTED_CODE, t as ERROR_CODE } from "./frames-BDqvhB2Y.mjs";
2
- import { t as loadSdk } from "./sdk-DCHLGZRg.mjs";
2
+ import { n as loadSdk } from "./proxy-D7VMUVEg.mjs";
3
3
  import { i as ensurePrivateDir, r as atomicWriteFileSync, t as ProviderStore } from "./store-CrTUwskE.mjs";
4
4
  import { n as FabricWireAdapter, r as DEFAULT_BODY_CHUNK_BYTES, t as WireSession } from "./mux-CS1zhF4W.mjs";
5
5
  import { a as collectEnvVarNames, i as buildUpstreamRequest, n as RewriteError, r as SecretMissingError, s as buildServiceEntry, t as PathNotOfferedError } from "./rewrite-xZHWnyJk.mjs";
@@ -1097,12 +1097,13 @@ function concatBytes(parts) {
1097
1097
  function providerFabricDir(dataDir) {
1098
1098
  return join(dataDir, "fabric");
1099
1099
  }
1100
- function fabricOptions(dataDir, relayUrls) {
1100
+ function fabricOptions(dataDir, relayUrls, httpProxy) {
1101
1101
  const opts = { dataDir: providerFabricDir(dataDir) };
1102
1102
  if (relayUrls !== void 0 && relayUrls.length > 0) opts.relay = {
1103
1103
  mode: "custom",
1104
1104
  urls: [relayUrls[0], ...relayUrls.slice(1)]
1105
1105
  };
1106
+ if (httpProxy !== void 0) opts.httpProxy = httpProxy;
1106
1107
  return opts;
1107
1108
  }
1108
1109
  function dirHasEntries(path) {
@@ -1112,9 +1113,9 @@ function dirHasEntries(path) {
1112
1113
  * 打开(或首启创建 root)数据目录下的 Fabric。已存在 fabric 数据则 open 复入
1113
1114
  * (EndpointId/名册不变),否则 createRoot。
1114
1115
  */
1115
- async function openOrCreateFabric(dataDir, relayUrls) {
1116
+ async function openOrCreateFabric(dataDir, relayUrls, httpProxy) {
1116
1117
  const { Fabric } = await loadSdk();
1117
- const opts = fabricOptions(dataDir, relayUrls);
1118
+ const opts = fabricOptions(dataDir, relayUrls, httpProxy);
1118
1119
  if (dirHasEntries(providerFabricDir(dataDir))) try {
1119
1120
  return await Fabric.open(opts);
1120
1121
  } catch (err) {
@@ -1127,10 +1128,10 @@ async function openOrCreateFabric(dataDir, relayUrls) {
1127
1128
  }
1128
1129
  }
1129
1130
  /** 打开既有 fabric 身份(share/revoke/status 用;未初始化时抛错)。 */
1130
- async function openExistingFabric(dataDir, relayUrls) {
1131
+ async function openExistingFabric(dataDir, relayUrls, httpProxy) {
1131
1132
  if (!dirHasEntries(providerFabricDir(dataDir))) throw new Error(`error: no fabric identity under ${dataDir}; run 'ai-fly serve --data <dir>' first`);
1132
1133
  const { Fabric } = await loadSdk();
1133
- return Fabric.open(fabricOptions(dataDir, relayUrls));
1134
+ return Fabric.open(fabricOptions(dataDir, relayUrls, httpProxy));
1134
1135
  }
1135
1136
  /** 扫描空/未设置的 $env 变量(已声明但为空 -> WARNING 列表)。 */
1136
1137
  function findEmptyEnvRefs(services, env = process.env) {
@@ -1169,7 +1170,7 @@ async function startProviderDaemon(opts) {
1169
1170
  const limits = new LimitEnforcer({ dataDir: opts.dataDir });
1170
1171
  const secretsStore = SecretsStore.open(opts.dataDir);
1171
1172
  const secrets = opts.secrets ?? ((name) => secretsStore.resolve(name)?.headerValue);
1172
- const fabric = await openOrCreateFabric(opts.dataDir, opts.relayUrls);
1173
+ const fabric = await openOrCreateFabric(opts.dataDir, opts.relayUrls, opts.httpProxy);
1173
1174
  const engine = new ProviderEngine({
1174
1175
  fabric,
1175
1176
  store,
@@ -1,7 +1,8 @@
1
1
  import { n as UsageError, r as reportCliError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
+ import { t as resolveHttpProxy } from "./proxy-D7VMUVEg.mjs";
3
4
  import { d as str, l as resolveDataDir, u as resolvedRelayUrls } from "./common-CqxqIg6D.mjs";
4
- import { n as startProviderDaemon } from "./serve-DQ5ces99.mjs";
5
+ import { n as startProviderDaemon } from "./serve-Be4zdKVj.mjs";
5
6
  import { homedir } from "node:os";
6
7
  //#region src/cli/commands/provider/serve.ts
7
8
  const SPEC = {
@@ -11,7 +12,8 @@ const SPEC = {
11
12
  },
12
13
  relay: { type: "multi" },
13
14
  alias: { type: "string" },
14
- "log-usage": { type: "boolean" }
15
+ "log-usage": { type: "boolean" },
16
+ proxy: { type: "string" }
15
17
  };
16
18
  async function run(argv, ctx = {}) {
17
19
  try {
@@ -19,12 +21,22 @@ async function run(argv, ctx = {}) {
19
21
  const { options, positionals } = parseArgv(argv, SPEC, { homedir: home });
20
22
  if (positionals.length > 0) throw new UsageError(`error: unexpected argument '${positionals[0]}' (serve takes no positional arguments)`);
21
23
  const dataDir = resolveDataDir(str(options.data), home);
22
- const relayUrls = resolvedRelayUrls(options, home);
24
+ const relayUrls = resolvedRelayUrls(options, home) ?? [];
25
+ const httpProxy = resolveHttpProxy(str(options.proxy));
26
+ process.stdout.write([
27
+ "ai-fly daemon starting",
28
+ ` relay: ${relayUrls.length > 0 ? relayUrls.join(", ") : "n0 public relays (default)"}`,
29
+ ` data : ${dataDir}`,
30
+ ...httpProxy !== void 0 ? [` proxy: ${httpProxy === "from-env" ? "env" : httpProxy === "none" ? "none" : httpProxy.url}`] : [],
31
+ "booting fabric (unreachable relays can stall this ~30s; Ctrl+C to abort)...",
32
+ ""
33
+ ].join("\n"));
23
34
  const daemon = await startProviderDaemon({
24
35
  dataDir,
25
36
  relayUrls,
26
37
  alias: str(options.alias),
27
- logUsage: options["log-usage"] === true
38
+ logUsage: options["log-usage"] === true,
39
+ ...httpProxy !== void 0 ? { httpProxy } : {}
28
40
  });
29
41
  process.stdout.write(`${daemon.banner}\n`);
30
42
  let stopping = false;
@@ -1,9 +1,10 @@
1
1
  import { r as reportCliError, t as CliError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv, r as parseDurationMs, t as assertDurationRange } from "./args-CSxXW9eD.mjs";
3
3
  import { l as SERVICE_ENTRY_SCHEMA } from "./frames-BDqvhB2Y.mjs";
4
+ import { t as resolveHttpProxy } from "./proxy-D7VMUVEg.mjs";
4
5
  import { n as StoreError } from "./store-CrTUwskE.mjs";
5
6
  import { c as requireString, d as str, l as resolveDataDir, r as openStore, u as resolvedRelayUrls } from "./common-CqxqIg6D.mjs";
6
- import { t as openExistingFabric } from "./serve-DQ5ces99.mjs";
7
+ import { t as openExistingFabric } from "./serve-Be4zdKVj.mjs";
7
8
  import { s as buildServiceEntry } from "./rewrite-xZHWnyJk.mjs";
8
9
  import { homedir } from "node:os";
9
10
  import { z } from "zod";
@@ -88,7 +89,7 @@ async function run(argv, ctx = {}) {
88
89
  const store = openStore(dataDir);
89
90
  const resolvedRelay = resolvedRelayUrls(options, home);
90
91
  if (resolvedRelay === void 0) process.stdout.write("warning: no relay configured for this command (flag/env/config); the link will carry public default relays - if the provider daemon runs on a custom relay, pass a matching --relay\n");
91
- fabric = await openExistingFabric(dataDir, resolvedRelay);
92
+ fabric = await openExistingFabric(dataDir, resolvedRelay, resolveHttpProxy(void 0));
92
93
  const invite = await issueInvite(fabric, ttlMs, options["allow-relayless"] === true);
93
94
  const relayStatus = await fabric.relayStatus();
94
95
  const result = buildShareLink({
@@ -1,6 +1,6 @@
1
1
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
2
2
  import { n as consumersRoot, s as listKeyrings } from "./store-BiTS2FTl.mjs";
3
- import { a as ringsForRun, n as ctxHomedir, r as ctxOut, t as createSdkFabricFactory } from "./common-Ds1lf39d.mjs";
3
+ import { a as ringsForRun, n as ctxHomedir, r as ctxOut, t as createSdkFabricFactory } from "./common-CgxCXeTt.mjs";
4
4
  import { n as createFabricProviderTransport, t as startEngine } from "./runtime-D_nxUEjd.mjs";
5
5
  import { homedir } from "node:os";
6
6
  //#region src/cli/commands/consumer/status.ts
@@ -59,7 +59,8 @@ async function run(argv, ctx = {}) {
59
59
  tilde: true
60
60
  },
61
61
  verbose: { type: "boolean" },
62
- relay: { type: "multi" }
62
+ relay: { type: "multi" },
63
+ proxy: { type: "string" }
63
64
  }, { homedir: ctx.homedir ?? homedir() });
64
65
  const verbose = options.verbose === true || positionals.includes("-v");
65
66
  const out = ctxOut(ctx);
@@ -71,7 +72,7 @@ async function run(argv, ctx = {}) {
71
72
  for (const line of formatStatus([], verbose)) out(line);
72
73
  return 0;
73
74
  }
74
- const factory = await createSdkFabricFactory(options.relay, ctx);
75
+ const factory = await createSdkFabricFactory(options.relay, ctx, void 0, options.proxy);
75
76
  const engine = await startEngine({
76
77
  rings: engineRings,
77
78
  consumersRoot: root,
@@ -1,7 +1,8 @@
1
1
  import { r as reportCliError } from "./errors-BGtxPkM7.mjs";
2
2
  import { n as parseArgv } from "./args-CSxXW9eD.mjs";
3
+ import { t as resolveHttpProxy } from "./proxy-D7VMUVEg.mjs";
3
4
  import { d as str, l as resolveDataDir, r as openStore, u as resolvedRelayUrls } from "./common-CqxqIg6D.mjs";
4
- import { t as openExistingFabric } from "./serve-DQ5ces99.mjs";
5
+ import { t as openExistingFabric } from "./serve-Be4zdKVj.mjs";
5
6
  import { c as detailDisplayLines, o as buildServiceDetail } from "./rewrite-xZHWnyJk.mjs";
6
7
  import { homedir } from "node:os";
7
8
  //#region src/cli/commands/provider/status.ts
@@ -35,7 +36,7 @@ async function run(argv, ctx = {}) {
35
36
  for (const line of detailDisplayLines(buildServiceDetail(s))) lines.push(` ${line}`);
36
37
  }
37
38
  try {
38
- fabric = await openExistingFabric(dataDir, resolvedRelayUrls(options, home));
39
+ fabric = await openExistingFabric(dataDir, resolvedRelayUrls(options, home), resolveHttpProxy(void 0));
39
40
  const fabricIdHex = await fabric.fabricIdHex();
40
41
  const members = await fabric.members();
41
42
  const relay = await fabric.relayStatus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-fly",
3
- "version": "0.3.0-alpha.1",
3
+ "version": "0.3.0-alpha.2",
4
4
  "description": "ai-fly — peer-to-peer HTTP/WebSocket bridge with AI-ready presets, over OpenDWeb fabric",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -1,10 +0,0 @@
1
- //#region src/sdk.ts
2
- async function loadSdk() {
3
- const candidate = await import("@jixo/opendweb-client-sdk");
4
- if (typeof candidate.Fabric === "function") return candidate;
5
- const def = candidate.default;
6
- if (def !== void 0 && typeof def.Fabric === "function") return def;
7
- throw new Error("error: @jixo/opendweb-client-sdk export shape unexpected (no Fabric via named or default interop)");
8
- }
9
- //#endregion
10
- export { loadSdk as t };