@tomflow/proflow-execution-browser-extension 0.1.13 → 0.1.14

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tomflow/proflow-execution-browser-extension
2
2
 
3
+ ## 0.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Retire the obsolete Carrier package and Browser standalone management CLI, make Platform setup/status preserve owner and dependency semantics, and enforce read-only status observation across the final Real-3 deployment closeout.
8
+
3
9
  ## 0.1.13
4
10
 
5
11
  ### Patch Changes
package/DOCS.md CHANGED
@@ -32,7 +32,7 @@ Execution 领域拥有的 Chrome MV3 Extension,负责 Task UI、审批提醒
32
32
 
33
33
  ## 使用方式
34
34
 
35
- 运行 `pnpm exec -- proflow-execution-browser-extension setup --workspace <workspace>`。ProFlow 会先准备 unpacked 目录、运行配置和本地 Bridge,并用真实 hello + heartbeat 尝试重验证已有扩展;已有扩展仍在线时不会再次打扰用户。只有未检测到在线扩展时,ProFlow 才把正确目录复制到剪贴板并打开 `chrome://extensions/`,提示用户完成安装操作:如果开发者模式尚未开启则先开启,然后点击“加载未打包的扩展程序”,在目录选择窗口中粘贴并确认目录。完成后无需回终端输入任何标识或状态;扩展身份、session、hello/heartbeat、Browser Executor 配置和 setup evidence 都由机器自动发现、生成并验证。历史 pairing evidence 不能单独代替本次 live revalidation。
35
+ 运行 `platform setup --workspace <workspace> --module execution-browser-extension`。ProFlow 会先准备 unpacked 目录、运行配置和本地 Bridge,并用真实 hello + heartbeat 尝试重验证已有扩展;已有扩展仍在线时不会再次打扰用户。只有未检测到在线扩展时,ProFlow 才把正确目录复制到剪贴板并打开 `chrome://extensions/`,提示用户完成安装操作:如果开发者模式尚未开启则先开启,然后点击“加载未打包的扩展程序”,在目录选择窗口中粘贴并确认目录。完成后无需回终端输入任何标识或状态;扩展身份、session、hello/heartbeat、Browser Executor 配置和 setup evidence 都由机器自动发现、生成并验证。历史 pairing evidence 不能单独代替本次 live revalidation。
36
36
 
37
37
  若 pairing 等待超时,ProFlow 保留已经准备好的扩展文件和机器配置,不写伪 READY evidence,并输出稳定错误代码 `PAIRING_TIMEOUT`。用户确认 Chrome 已完成加载后重新执行 `platform setup` 即可。Agent setup 随后通过 `custom-gpt-web-provisioning` 使用同一 Extension package 的部署期分支。
38
38
 
package/SETUP.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## STEP-EXECUTION-BROWSER-EXTENSION-01 — 加载扩展并自动配对
4
4
  Responsible: USER
5
- Interactive executable: `pnpm exec -- proflow-execution-browser-extension setup`
6
- Non-interactive executable: `pnpm exec -- proflow-execution-browser-extension setup`
5
+ Interactive executable: `platform setup --module execution-browser-extension`
6
+ Non-interactive executable: `platform setup --module execution-browser-extension`
7
7
  Required inputs: none
8
- Verify: `pnpm exec -- proflow-execution-browser-extension verify`
8
+ Verify: `platform status`
9
9
  Success condition: 本地 pairing listener 已收到真实 Extension hello + heartbeat,并持久化部署证据。
10
10
 
11
11
  运行命令后,ProFlow 会先准备 unpacked 目录和所有机器配置,并尝试用真实 hello + heartbeat 重验证已有扩展。若已有扩展仍在线,则无需任何人工操作,setup 直接继续;只有未检测到在线扩展时,ProFlow 才把正确目录复制到剪贴板、打开 `chrome://extensions/` 并提示用户完成安装操作:如果开发者模式尚未开启则先开启,然后点击“加载未打包的扩展程序”,在目录选择窗口中粘贴并确认刚刚复制的目录。完成后无需回终端输入任何内容;扩展身份确认、Bridge 配置、hello/heartbeat 验证和 READY 状态均由 ProFlow 自动完成。历史 `setup.json` / verification evidence 不能单独跳过本次 live revalidation。
@@ -14,8 +14,8 @@ Success condition: 本地 pairing listener 已收到真实 Extension hello + hea
14
14
 
15
15
  ## STEP-EXECUTION-BROWSER-EXTENSION-02 — 验证部署状态
16
16
  Responsible: AI
17
- Interactive executable: `pnpm exec -- proflow-execution-browser-extension verify`
18
- Non-interactive executable: `pnpm exec -- proflow-execution-browser-extension verify`
17
+ Interactive executable: `platform status`
18
+ Non-interactive executable: `platform status`
19
19
  Required inputs: none
20
- Verify: `pnpm exec -- proflow-execution-browser-extension verify`
20
+ Verify: `platform status`
21
21
  Success condition: `execution-browser-extension.setupStatus=READY`.
@@ -24,7 +24,7 @@ export declare const behaviorAdapter: {
24
24
  ok: true;
25
25
  status: "SUCCEEDED";
26
26
  moduleRef: "execution-browser-extension";
27
- moduleVersion: "0.1.13";
27
+ moduleVersion: "0.1.14";
28
28
  data: {
29
29
  loadDir: string;
30
30
  };
@@ -37,7 +37,7 @@ export declare const behaviorAdapter: {
37
37
  readonly ok: true;
38
38
  readonly status: "SUCCEEDED";
39
39
  readonly moduleRef: "execution-browser-extension";
40
- readonly moduleVersion: "0.1.13";
40
+ readonly moduleVersion: "0.1.14";
41
41
  };
42
42
  observedEffects: never[];
43
43
  }>;
@@ -47,10 +47,10 @@ export declare const behaviorAdapter: {
47
47
  ok: true;
48
48
  status: "SUCCEEDED";
49
49
  moduleRef: "execution-browser-extension";
50
- moduleVersion: "0.1.13";
50
+ moduleVersion: "0.1.14";
51
51
  data: {
52
52
  setupStatus: "ACTION_REQUIRED" | "READY";
53
- runtimeStatus: "RUNNING" | "STOPPED";
53
+ runtimeStatus: "NOT_APPLICABLE";
54
54
  issues?: {
55
55
  scope: "SETUP";
56
56
  code: string;
@@ -63,10 +63,19 @@ export declare const behaviorAdapter: {
63
63
  observedEffects: string[];
64
64
  }>;
65
65
  readonly setup: (context: ModuleCommandContext) => Promise<{
66
+ result: {
67
+ readonly contract: "deployment.result.v1";
68
+ readonly ok: true;
69
+ readonly status: "SUCCEEDED";
70
+ readonly moduleRef: "execution-browser-extension";
71
+ readonly moduleVersion: "0.1.14";
72
+ };
73
+ observedEffects: string[];
74
+ } | {
66
75
  result: {
67
76
  contract: "deployment.result.v1";
68
77
  moduleRef: "execution-browser-extension";
69
- moduleVersion: "0.1.13";
78
+ moduleVersion: "0.1.14";
70
79
  ok: false;
71
80
  status: "FAILED";
72
81
  error: {
@@ -81,69 +90,17 @@ export declare const behaviorAdapter: {
81
90
  readonly state: "BLOCKED";
82
91
  readonly responsible: "EXTERNAL";
83
92
  readonly execution: {
84
- readonly interactive: "pnpm exec -- proflow-execution-browser-extension setup";
85
- readonly nonInteractive: "pnpm exec -- proflow-execution-browser-extension setup";
93
+ readonly interactive: "platform setup --module execution-browser-extension";
94
+ readonly nonInteractive: "platform setup --module execution-browser-extension";
86
95
  };
87
96
  readonly requiredInputs: readonly [];
88
- readonly verify: "pnpm exec -- proflow-execution-browser-extension verify";
97
+ readonly verify: "platform status";
89
98
  readonly successCondition: "配置状态变为“已就绪”";
90
99
  readonly blockedReason: "真实 Extension heartbeat 未到达或本地 pairing 失败";
91
100
  }];
92
101
  };
93
102
  };
94
103
  observedEffects: never[];
95
- } | {
96
- result: {
97
- readonly contract: "deployment.result.v1";
98
- readonly ok: true;
99
- readonly status: "SUCCEEDED";
100
- readonly moduleRef: "execution-browser-extension";
101
- readonly moduleVersion: "0.1.13";
102
- };
103
- observedEffects: string[];
104
- } | {
105
- result: {
106
- contract: "deployment.result.v1";
107
- moduleRef: "execution-browser-extension";
108
- moduleVersion: "0.1.13";
109
- ok: false;
110
- status: "ACTION_REQUIRED";
111
- data: {
112
- readonly steps: readonly [{
113
- readonly id: "STEP-EXECUTION-BROWSER-EXTENSION-01";
114
- readonly title: "加载扩展并自动配对";
115
- readonly description: "准备 unpacked 目录和本地 Bridge,等待 Chrome Extension 的真实 hello + heartbeat。";
116
- readonly state: "TODO";
117
- readonly responsible: "USER";
118
- readonly execution: {
119
- readonly interactive: "pnpm exec -- proflow-execution-browser-extension setup";
120
- readonly nonInteractive: "pnpm exec -- proflow-execution-browser-extension setup";
121
- };
122
- readonly requiredInputs: readonly [];
123
- readonly verify: "pnpm exec -- proflow-execution-browser-extension verify";
124
- readonly successCondition: "Extension hello + heartbeat 已被本地 pairing listener 验证并持久化";
125
- readonly humanAction: "启用开发者模式并加载脚本准备的 unpacked 目录;其余身份发现与验证自动完成。";
126
- }, {
127
- readonly id: "STEP-EXECUTION-BROWSER-EXTENSION-02";
128
- readonly title: "验证扩展部署状态";
129
- readonly description: "读取 heartbeat 形成的持久化部署证据。";
130
- readonly state: "TODO";
131
- readonly responsible: "AI";
132
- readonly execution: {
133
- readonly interactive: "pnpm exec -- proflow-execution-browser-extension verify";
134
- readonly nonInteractive: "pnpm exec -- proflow-execution-browser-extension verify";
135
- };
136
- readonly requiredInputs: readonly [];
137
- readonly verify: "pnpm exec -- proflow-execution-browser-extension verify";
138
- readonly successCondition: "execution-browser-extension.setupStatus=READY";
139
- }];
140
- };
141
- actionRequired: {
142
- action: string;
143
- description: string;
144
- };
145
- };
146
- observedEffects: never[];
147
104
  }>;
148
105
  readonly docs: (_context: ModuleCommandContext) => Promise<{
149
106
  result: {
@@ -151,7 +108,7 @@ export declare const behaviorAdapter: {
151
108
  ok: true;
152
109
  status: "SUCCEEDED";
153
110
  moduleRef: "execution-browser-extension";
154
- moduleVersion: "0.1.13";
111
+ moduleVersion: "0.1.14";
155
112
  data: {
156
113
  docs: string;
157
114
  };
@@ -164,11 +121,11 @@ export declare const behaviorAdapter: {
164
121
  readonly ok: true;
165
122
  readonly status: "SUCCEEDED";
166
123
  readonly moduleRef: "execution-browser-extension";
167
- readonly moduleVersion: "0.1.13";
124
+ readonly moduleVersion: "0.1.14";
168
125
  } | {
169
126
  contract: "deployment.result.v1";
170
127
  moduleRef: "execution-browser-extension";
171
- moduleVersion: "0.1.13";
128
+ moduleVersion: "0.1.14";
172
129
  ok: false;
173
130
  status: "FAILED";
174
131
  error: {
@@ -185,7 +142,7 @@ export declare const behaviorAdapter: {
185
142
  readonly ok: true;
186
143
  readonly status: "SUCCEEDED";
187
144
  readonly moduleRef: "execution-browser-extension";
188
- readonly moduleVersion: "0.1.13";
145
+ readonly moduleVersion: "0.1.14";
189
146
  };
190
147
  observedEffects: never[];
191
148
  }>;
@@ -3,6 +3,7 @@ import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { basename, dirname, join, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { deterministicLoopbackPort, ensureModuleSecretFile, moduleWorkspaceStateDirectory, readModuleSharedFacts, writeModuleSharedFacts, } from "@tomflow/proflow-module-contract";
6
+ import { runInteractiveBrowserExtensionSetup } from "../src/install-workflow.js";
6
7
  import { createBrowserExtensionPairingServer } from "../src/pairing.js";
7
8
  import { descriptor } from "./descriptor.js";
8
9
  const base = {
@@ -12,39 +13,6 @@ const base = {
12
13
  moduleRef: descriptor.moduleRef,
13
14
  moduleVersion: descriptor.moduleVersion,
14
15
  };
15
- const setupPlan = {
16
- steps: [
17
- {
18
- id: "STEP-EXECUTION-BROWSER-EXTENSION-01",
19
- title: "加载扩展并自动配对",
20
- description: "准备 unpacked 目录和本地 Bridge,等待 Chrome Extension 的真实 hello + heartbeat。",
21
- state: "TODO",
22
- responsible: "USER",
23
- execution: {
24
- interactive: "pnpm exec -- proflow-execution-browser-extension setup",
25
- nonInteractive: "pnpm exec -- proflow-execution-browser-extension setup",
26
- },
27
- requiredInputs: [],
28
- verify: "pnpm exec -- proflow-execution-browser-extension verify",
29
- successCondition: "Extension hello + heartbeat 已被本地 pairing listener 验证并持久化",
30
- humanAction: "启用开发者模式并加载脚本准备的 unpacked 目录;其余身份发现与验证自动完成。",
31
- },
32
- {
33
- id: "STEP-EXECUTION-BROWSER-EXTENSION-02",
34
- title: "验证扩展部署状态",
35
- description: "读取 heartbeat 形成的持久化部署证据。",
36
- state: "TODO",
37
- responsible: "AI",
38
- execution: {
39
- interactive: "pnpm exec -- proflow-execution-browser-extension verify",
40
- nonInteractive: "pnpm exec -- proflow-execution-browser-extension verify",
41
- },
42
- requiredInputs: [],
43
- verify: "pnpm exec -- proflow-execution-browser-extension verify",
44
- successCondition: "execution-browser-extension.setupStatus=READY",
45
- },
46
- ],
47
- };
48
16
  const blockedSetupPlan = {
49
17
  steps: [
50
18
  {
@@ -53,11 +21,11 @@ const blockedSetupPlan = {
53
21
  state: "BLOCKED",
54
22
  responsible: "EXTERNAL",
55
23
  execution: {
56
- interactive: "pnpm exec -- proflow-execution-browser-extension setup",
57
- nonInteractive: "pnpm exec -- proflow-execution-browser-extension setup",
24
+ interactive: "platform setup --module execution-browser-extension",
25
+ nonInteractive: "platform setup --module execution-browser-extension",
58
26
  },
59
27
  requiredInputs: [],
60
- verify: "pnpm exec -- proflow-execution-browser-extension verify",
28
+ verify: "platform status",
61
29
  successCondition: "配置状态变为“已就绪”",
62
30
  blockedReason: "真实 Extension heartbeat 未到达或本地 pairing 失败",
63
31
  },
@@ -244,10 +212,6 @@ async function materializeExecutorConfig(context, setup, prepared) {
244
212
  browserExecutorConfigPath: executorConfigFile(context),
245
213
  });
246
214
  }
247
- async function materialize(context, setup) {
248
- const prepared = await materializeRuntimeConfig(context);
249
- await materializeExecutorConfig(context, setup, prepared);
250
- }
251
215
  async function persistPairedBrowserExtension(context, prepared, identity) {
252
216
  const setup = { extensionId: identity.extensionId };
253
217
  await writeFile(setupFile(context), `${JSON.stringify(setup, null, 2)}\n`, {
@@ -338,7 +302,7 @@ export const behaviorAdapter = {
338
302
  setupStatus: setupReady
339
303
  ? "READY"
340
304
  : "ACTION_REQUIRED",
341
- runtimeStatus: evidence ? "RUNNING" : "STOPPED",
305
+ runtimeStatus: "NOT_APPLICABLE",
342
306
  ...(setupReady
343
307
  ? {}
344
308
  : {
@@ -360,43 +324,38 @@ export const behaviorAdapter = {
360
324
  };
361
325
  },
362
326
  setup: async (context) => {
363
- await mkdir(stateDir(context), { recursive: true, mode: 0o700 });
364
- await installPackage(context);
365
- const setup = await readSetup(context);
366
- const evidence = await readEvidence(context, browserExtensionLoadDir(context.workspaceRoot));
367
- if (setup && evidence && setup.extensionId === evidence.extensionId) {
368
- try {
369
- await materialize(context, setup);
370
- }
371
- catch (error) {
372
- return {
373
- result: {
374
- ...failed("SETUP_FAILED", error instanceof Error
375
- ? error.message
376
- : "browser extension config materialization failed"),
377
- data: blockedSetupPlan,
378
- },
379
- observedEffects: [],
380
- };
381
- }
327
+ try {
328
+ const input = typeof context.input === "object" && context.input !== null
329
+ ? context.input
330
+ : undefined;
331
+ await runInteractiveBrowserExtensionSetup({
332
+ workspaceRoot: context.workspaceRoot,
333
+ ...(input?.timeoutMs === undefined
334
+ ? {}
335
+ : { timeoutMs: input.timeoutMs }),
336
+ ...(input?.desktop === undefined ? {} : { desktop: input.desktop }),
337
+ ...(input?.pair === undefined ? {} : { pair: input.pair }),
338
+ });
382
339
  return {
383
340
  result: base,
384
- observedEffects: ["Uses heartbeat-proven Chrome MV3 pairing evidence"],
341
+ observedEffects: [
342
+ "Materializes browser runtime configuration",
343
+ "Opens Chrome extension management",
344
+ "Persists heartbeat-proven Chrome MV3 pairing evidence",
345
+ ],
385
346
  };
386
347
  }
387
- return {
388
- result: {
389
- ...base,
390
- ok: false,
391
- status: "ACTION_REQUIRED",
392
- data: setupPlan,
393
- actionRequired: {
394
- action: "load-unpacked-extension",
395
- description: `Run pnpm exec -- proflow-execution-browser-extension setup --workspace ${context.workspaceRoot}; then enable Developer Mode and load ${browserExtensionLoadDir(context.workspaceRoot)}. The package CLI materializes bootstrap config, discovers the extension and verifies its heartbeat automatically.`,
348
+ catch (error) {
349
+ return {
350
+ result: {
351
+ ...failed("SETUP_FAILED", error instanceof Error
352
+ ? error.message
353
+ : "browser extension setup failed"),
354
+ data: blockedSetupPlan,
396
355
  },
397
- },
398
- observedEffects: [],
399
- };
356
+ observedEffects: [],
357
+ };
358
+ }
400
359
  },
401
360
  docs: async (_context) => ({
402
361
  result: {
@@ -3,7 +3,7 @@ export declare const descriptor: {
3
3
  readonly contractVersion: "1.0.0";
4
4
  readonly moduleRef: "execution-browser-extension";
5
5
  readonly packageName: "@tomflow/proflow-execution-browser-extension";
6
- readonly moduleVersion: "0.1.13";
6
+ readonly moduleVersion: "0.1.14";
7
7
  readonly kind: "browser-extension";
8
8
  readonly templateVersion: "1.0.0";
9
9
  readonly platformCompatibility: ">=1.0.0 <2.0.0";
@@ -3,7 +3,7 @@ export const descriptor = {
3
3
  contractVersion: "1.0.0",
4
4
  moduleRef: "execution-browser-extension",
5
5
  packageName: "@tomflow/proflow-execution-browser-extension",
6
- moduleVersion: "0.1.13",
6
+ moduleVersion: "0.1.14",
7
7
  kind: "browser-extension",
8
8
  templateVersion: "1.0.0",
9
9
  platformCompatibility: ">=1.0.0 <2.0.0",
@@ -1,5 +1,4 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { pairBrowserExtensionSetup } from "../deployment/adapter.js";
3
2
  export function browserExtensionInstallInstruction(loadDir) {
4
3
  return `\nChrome 浏览器扩展\n\nProFlow 已准备好扩展文件,并已复制安装目录:\n${loadDir}\n\n请在已经打开的 Chrome 扩展管理页完成以下安装操作:\n1. 如果“开发者模式”尚未开启,请开启\n2. 点击“加载未打包的扩展程序”\n3. 在目录选择窗口中粘贴并确认刚刚复制的目录\n\n完成后无需返回输入任何内容。ProFlow 会自动检测扩展并继续。\n`;
5
4
  }
@@ -52,7 +51,8 @@ function systemDesktop() {
52
51
  }
53
52
  export async function runInteractiveBrowserExtensionSetup(input) {
54
53
  const desktop = input.desktop ?? systemDesktop();
55
- const pair = input.pair ?? pairBrowserExtensionSetup;
54
+ const pair = input.pair ??
55
+ (await import("../deployment/adapter.js")).pairBrowserExtensionSetup;
56
56
  return pair({ workspaceRoot: input.workspaceRoot }, {
57
57
  timeoutMs: input.timeoutMs ?? 120_000,
58
58
  async onWaiting({ loadDir }) {
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "ProFlow Execution Browser",
4
- "version": "0.1.13",
4
+ "version": "0.1.14",
5
5
  "permissions": ["tabs", "storage", "sidePanel"],
6
6
  "host_permissions": ["https://chatgpt.com/*", "http://127.0.0.1/*"],
7
7
  "background": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/proflow-execution-browser-extension",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Execution-owned MV3 Browser executor, evidence provider and browser application surface.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -13,8 +13,7 @@
13
13
  "./deployment/descriptor": "./dist/deployment/descriptor.js",
14
14
  "./runtime-composition": "./dist/src/runtime-composition.js",
15
15
  "./custom-gpt-provisioning": "./dist/src/custom-gpt-provisioner.js",
16
- "./custom-gpt-role": "./dist/src/custom-gpt-role.js",
17
- "./configure": "./dist/src/configure.js"
16
+ "./custom-gpt-role": "./dist/src/custom-gpt-role.js"
18
17
  },
19
18
  "files": [
20
19
  "dist",
@@ -32,8 +31,8 @@
32
31
  "@tomflow/proflow-module-contract": "^0.1.13"
33
32
  },
34
33
  "devDependencies": {
35
- "@tomflow/proflow-deployment-conformance": "^0.1.11",
36
- "@tomflow/proflow-execution-runtime": "^0.1.14"
34
+ "@tomflow/proflow-deployment-conformance": "^0.1.12",
35
+ "@tomflow/proflow-execution-runtime": "^0.1.15"
37
36
  },
38
37
  "keywords": [
39
38
  "proflow",
@@ -45,9 +44,6 @@
45
44
  "descriptor": "./dist/deployment/descriptor.js",
46
45
  "manifest": "./proflow.module.json"
47
46
  },
48
- "bin": {
49
- "proflow-execution-browser-extension": "./dist/src/configure.js"
50
- },
51
47
  "scripts": {
52
48
  "test": "node --test tests/**/*.test.ts",
53
49
  "typecheck": "tsc --noEmit"
@@ -3,7 +3,7 @@
3
3
  "contractVersion": "1.0.0",
4
4
  "moduleRef": "execution-browser-extension",
5
5
  "packageName": "@tomflow/proflow-execution-browser-extension",
6
- "moduleVersion": "0.1.13",
6
+ "moduleVersion": "0.1.14",
7
7
  "kind": "browser-extension",
8
8
  "templateVersion": "1.0.0",
9
9
  "platformCompatibility": ">=1.0.0 <2.0.0",
@@ -1,3 +0,0 @@
1
- export declare function parseBrowserExtensionSetupArgs(args: readonly string[], cwd: string): {
2
- workspaceRoot: string;
3
- };
@@ -1,23 +0,0 @@
1
- import { resolve } from "node:path";
2
- export function parseBrowserExtensionSetupArgs(args, cwd) {
3
- if (args[0] !== "setup")
4
- throw new Error("SETUP_COMMAND_REQUIRED");
5
- let workspaceRoot = resolve(cwd);
6
- for (let index = 1; index < args.length; index += 1) {
7
- const value = args[index];
8
- if (value === "--workspace") {
9
- const workspace = args[index + 1];
10
- if (!workspace || workspace.startsWith("--")) {
11
- throw new Error("MISSING_WORKSPACE_VALUE");
12
- }
13
- workspaceRoot = resolve(workspace);
14
- index += 1;
15
- continue;
16
- }
17
- if (value?.startsWith("--")) {
18
- throw new Error(`UNSUPPORTED_SETUP_OPTION:${value}`);
19
- }
20
- throw new Error(`UNSUPPORTED_SETUP_STEP:${value}`);
21
- }
22
- return { workspaceRoot };
23
- }
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare function materializeBrowserExtensionConfig(workspaceRoot: string): Promise<{
3
- loadDir: string;
4
- }>;
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env node
2
- import { readFile } from "node:fs/promises";
3
- import { resolve } from "node:path";
4
- import { behaviorAdapter, materializeProductionConfig, } from "../deployment/adapter.js";
5
- import { parseBrowserExtensionSetupArgs } from "./configure-args.js";
6
- import { browserExtensionSetupFailureMessage, browserExtensionSetupSuccessMessage, runInteractiveBrowserExtensionSetup, } from "./install-workflow.js";
7
- function reportFatal(error) {
8
- process.stderr.write(browserExtensionSetupFailureMessage(error));
9
- process.exitCode = 1;
10
- }
11
- process.on("uncaughtException", reportFatal);
12
- process.on("unhandledRejection", reportFatal);
13
- function workspaceFromArgs(args) {
14
- if (args[0] !== "materialize-config") {
15
- throw new Error("Usage: proflow-execution-browser-extension materialize-config [--workspace /absolute/path]");
16
- }
17
- const workspaceIndex = args.indexOf("--workspace");
18
- if (workspaceIndex < 0)
19
- return process.cwd();
20
- const value = args[workspaceIndex + 1];
21
- if (!value || args.length !== 3) {
22
- throw new Error("Usage: proflow-execution-browser-extension materialize-config [--workspace /absolute/path]");
23
- }
24
- return resolve(value);
25
- }
26
- export async function materializeBrowserExtensionConfig(workspaceRoot) {
27
- const configPath = resolve(workspaceRoot, ".proflow", "config", "execution-browser-extension.json");
28
- const parsed = JSON.parse(await readFile(configPath, "utf8"));
29
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
30
- throw new Error("execution-browser-extension config must be a JSON object");
31
- }
32
- const config = Object.fromEntries(Object.entries(parsed).map(([key, value]) => {
33
- if (typeof value !== "string") {
34
- throw new Error(`browser extension config ${key} must be a string`);
35
- }
36
- return [key, value];
37
- }));
38
- return materializeProductionConfig({
39
- moduleRef: "execution-browser-extension",
40
- config,
41
- workspaceRoot,
42
- });
43
- }
44
- async function main() {
45
- const args = process.argv.slice(2);
46
- if (args.includes("--json"))
47
- throw new Error("不支持的选项 --json");
48
- const option = (name) => {
49
- const index = args.indexOf(name);
50
- return index >= 0 ? args[index + 1] : undefined;
51
- };
52
- const workspaceRoot = option("--workspace")
53
- ? resolve(option("--workspace"))
54
- : process.cwd();
55
- if (args[0] === "setup") {
56
- const setup = parseBrowserExtensionSetupArgs(args, process.cwd());
57
- await runInteractiveBrowserExtensionSetup({
58
- workspaceRoot: setup.workspaceRoot,
59
- timeoutMs: 120_000,
60
- });
61
- process.stdout.write(browserExtensionSetupSuccessMessage());
62
- return;
63
- }
64
- if (args[0] === "verify") {
65
- const result = await behaviorAdapter.status({ workspaceRoot });
66
- process.stdout.write(result.result.data.setupStatus === "READY"
67
- ? "验证通过。\n"
68
- : "验证未通过:扩展尚未就绪。\n");
69
- if (result.result.data.setupStatus !== "READY")
70
- process.exitCode = 1;
71
- return;
72
- }
73
- const legacyWorkspaceRoot = workspaceFromArgs(args);
74
- const result = await materializeBrowserExtensionConfig(legacyWorkspaceRoot);
75
- process.stdout.write(`浏览器扩展配置已生成:${result.loadDir}\n`);
76
- }
77
- if (import.meta.main)
78
- await main();