@tomflow/proflow-execution-browser-extension 0.1.18 → 0.1.20

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.
@@ -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.18";
27
+ moduleVersion: "0.1.20";
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.18";
40
+ readonly moduleVersion: "0.1.20";
41
41
  };
42
42
  observedEffects: never[];
43
43
  }>;
@@ -47,7 +47,7 @@ export declare const behaviorAdapter: {
47
47
  ok: true;
48
48
  status: "SUCCEEDED";
49
49
  moduleRef: "execution-browser-extension";
50
- moduleVersion: "0.1.18";
50
+ moduleVersion: "0.1.20";
51
51
  data: {
52
52
  setupStatus: "ACTION_REQUIRED" | "READY";
53
53
  runtimeStatus: "NOT_APPLICABLE";
@@ -66,7 +66,7 @@ export declare const behaviorAdapter: {
66
66
  result: {
67
67
  contract: "deployment.result.v1";
68
68
  moduleRef: "execution-browser-extension";
69
- moduleVersion: "0.1.18";
69
+ moduleVersion: "0.1.20";
70
70
  ok: false;
71
71
  status: "ACTION_REQUIRED";
72
72
  data: {
@@ -98,14 +98,14 @@ export declare const behaviorAdapter: {
98
98
  readonly ok: true;
99
99
  readonly status: "SUCCEEDED";
100
100
  readonly moduleRef: "execution-browser-extension";
101
- readonly moduleVersion: "0.1.18";
101
+ readonly moduleVersion: "0.1.20";
102
102
  };
103
103
  observedEffects: string[];
104
104
  } | {
105
105
  result: {
106
106
  contract: "deployment.result.v1";
107
107
  moduleRef: "execution-browser-extension";
108
- moduleVersion: "0.1.18";
108
+ moduleVersion: "0.1.20";
109
109
  ok: false;
110
110
  status: "FAILED";
111
111
  error: {
@@ -138,7 +138,7 @@ export declare const behaviorAdapter: {
138
138
  ok: true;
139
139
  status: "SUCCEEDED";
140
140
  moduleRef: "execution-browser-extension";
141
- moduleVersion: "0.1.18";
141
+ moduleVersion: "0.1.20";
142
142
  data: {
143
143
  docs: string;
144
144
  };
@@ -151,11 +151,11 @@ export declare const behaviorAdapter: {
151
151
  readonly ok: true;
152
152
  readonly status: "SUCCEEDED";
153
153
  readonly moduleRef: "execution-browser-extension";
154
- readonly moduleVersion: "0.1.18";
154
+ readonly moduleVersion: "0.1.20";
155
155
  } | {
156
156
  contract: "deployment.result.v1";
157
157
  moduleRef: "execution-browser-extension";
158
- moduleVersion: "0.1.18";
158
+ moduleVersion: "0.1.20";
159
159
  ok: false;
160
160
  status: "FAILED";
161
161
  error: {
@@ -172,7 +172,7 @@ export declare const behaviorAdapter: {
172
172
  readonly ok: true;
173
173
  readonly status: "SUCCEEDED";
174
174
  readonly moduleRef: "execution-browser-extension";
175
- readonly moduleVersion: "0.1.18";
175
+ readonly moduleVersion: "0.1.20";
176
176
  };
177
177
  observedEffects: never[];
178
178
  }>;
@@ -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 { probeChromeExtensionState } from "../src/chrome-extension-state.js";
6
7
  import { openBrowserExtensionManager, runInteractiveBrowserExtensionSetup, } from "../src/install-workflow.js";
7
8
  import { createBrowserExtensionPairingServer } from "../src/pairing.js";
8
9
  import { descriptor } from "./descriptor.js";
@@ -132,11 +133,12 @@ async function persistDeveloperModeConfirmation(context) {
132
133
  await mkdir(stateDir(context), { recursive: true, mode: 0o700 });
133
134
  await writeFile(installFlowFile(context), `${JSON.stringify({ developerModeConfirmed: true })}\n`, { mode: 0o600 });
134
135
  }
135
- async function readEvidence(context, loadDir) {
136
+ async function readEvidenceCandidate(context, loadDir) {
136
137
  try {
137
138
  const raw = JSON.parse(await readFile(verificationFile(context), "utf8"));
138
139
  return raw.contract === "proflow.browser-extension-verification.v1" &&
139
- raw.moduleVersion === descriptor.moduleVersion &&
140
+ typeof raw.moduleVersion === "string" &&
141
+ raw.moduleVersion.length > 0 &&
140
142
  raw.loadDir === loadDir &&
141
143
  typeof raw.extensionId === "string" &&
142
144
  /^[a-z]{32}$/.test(raw.extensionId) &&
@@ -153,6 +155,12 @@ async function readEvidence(context, loadDir) {
153
155
  return undefined;
154
156
  }
155
157
  }
158
+ async function readEvidence(context, loadDir) {
159
+ const evidence = await readEvidenceCandidate(context, loadDir);
160
+ return evidence?.moduleVersion === descriptor.moduleVersion
161
+ ? evidence
162
+ : undefined;
163
+ }
156
164
  async function ownFacts(context) {
157
165
  await mkdir(stateDir(context), { recursive: true, mode: 0o700 });
158
166
  const loadDir = browserExtensionLoadDir(context.workspaceRoot);
@@ -247,15 +255,83 @@ async function persistPairedBrowserExtension(context, prepared, identity) {
247
255
  await writeFile(verificationFile(context), `${JSON.stringify(evidence, null, 2)}\n`, { mode: 0o600 });
248
256
  return identity;
249
257
  }
258
+ function connectionRefused(error) {
259
+ if (!(error instanceof TypeError))
260
+ return false;
261
+ const cause = Reflect.get(error, "cause");
262
+ return (typeof cause === "object" &&
263
+ cause !== null &&
264
+ Reflect.get(cause, "code") === "ECONNREFUSED");
265
+ }
266
+ async function probeRunningBridgeSession(prepared, extensionId, timeoutMs) {
267
+ try {
268
+ const response = await fetch(`${prepared.bridgeEndpoint}/v1/session/status`, {
269
+ headers: {
270
+ authorization: `Bearer ${await credential(prepared.bridgeTokenFile)}`,
271
+ origin: `chrome-extension://${extensionId}`,
272
+ },
273
+ signal: AbortSignal.timeout(Math.max(25, Math.min(500, timeoutMs))),
274
+ });
275
+ if (!response.ok)
276
+ throw new Error(`RUNNING_BRIDGE_STATUS_${response.status}`);
277
+ const body = (await response.json());
278
+ if (typeof body !== "object" || body === null || Array.isArray(body))
279
+ throw new Error("RUNNING_BRIDGE_STATUS_INVALID");
280
+ if (Reflect.get(body, "online") !== true)
281
+ return { kind: "PRESENT" };
282
+ const extensionInstanceId = Reflect.get(body, "extensionInstanceId");
283
+ if (typeof extensionInstanceId !== "string" ||
284
+ extensionInstanceId.length === 0)
285
+ throw new Error("RUNNING_BRIDGE_STATUS_INVALID");
286
+ return {
287
+ kind: "PRESENT",
288
+ identity: { extensionId, extensionInstanceId },
289
+ };
290
+ }
291
+ catch (error) {
292
+ if (connectionRefused(error))
293
+ return { kind: "ABSENT" };
294
+ throw error;
295
+ }
296
+ }
297
+ async function revalidateRunningBridge(prepared, extensionId, timeoutMs, onWaiting) {
298
+ const startedAt = Date.now();
299
+ const graceMs = Math.min(2_000, Math.max(25, Math.floor(timeoutMs / 4)));
300
+ let waitingShown = false;
301
+ while (true) {
302
+ const remainingMs = Math.max(1, timeoutMs - (Date.now() - startedAt));
303
+ const probe = await probeRunningBridgeSession(prepared, extensionId, remainingMs);
304
+ if (probe.kind === "ABSENT")
305
+ return undefined;
306
+ if (probe.identity)
307
+ return probe.identity;
308
+ const elapsedMs = Date.now() - startedAt;
309
+ if (!waitingShown && elapsedMs >= graceMs) {
310
+ waitingShown = true;
311
+ await onWaiting?.({
312
+ loadDir: prepared.loadDir,
313
+ endpoint: prepared.bridgeEndpoint,
314
+ });
315
+ }
316
+ if (elapsedMs >= timeoutMs)
317
+ throw new Error("PAIRING_TIMEOUT");
318
+ await new Promise((resolve) => setTimeout(resolve, Math.min(100, Math.max(10, timeoutMs - elapsedMs))));
319
+ }
320
+ }
250
321
  export async function pairBrowserExtensionSetup(context, options = {}) {
251
322
  await mkdir(stateDir(context), { recursive: true, mode: 0o700 });
252
323
  await installPackage(context);
253
324
  const existingSetup = await readSetup(context);
254
- const existingEvidence = await readEvidence(context, browserExtensionLoadDir(context.workspaceRoot));
325
+ const existingEvidence = await readEvidenceCandidate(context, browserExtensionLoadDir(context.workspaceRoot));
255
326
  const canRevalidateExisting = Boolean(existingSetup &&
256
327
  existingEvidence &&
257
328
  existingSetup.extensionId === existingEvidence.extensionId);
258
329
  const prepared = await materializeRuntimeConfig(context);
330
+ if (canRevalidateExisting && existingSetup) {
331
+ const runningIdentity = await revalidateRunningBridge(prepared, existingSetup.extensionId, options.timeoutMs ?? 120_000, options.onWaiting);
332
+ if (runningIdentity)
333
+ return persistPairedBrowserExtension(context, prepared, runningIdentity);
334
+ }
259
335
  const pairing = await createBrowserExtensionPairingServer({
260
336
  token: await credential(prepared.bridgeTokenFile),
261
337
  host: "127.0.0.1",
@@ -310,7 +386,16 @@ export const behaviorAdapter = {
310
386
  const loadDir = browserExtensionLoadDir(context.workspaceRoot);
311
387
  const setup = await readSetup(context);
312
388
  const evidence = await readEvidence(context, loadDir);
313
- const setupReady = Boolean(setup && evidence && setup.extensionId === evidence.extensionId);
389
+ const chromeState = setup && evidence && setup.extensionId === evidence.extensionId
390
+ ? await probeChromeExtensionState({
391
+ extensionId: evidence.extensionId,
392
+ loadDir,
393
+ })
394
+ : "MISSING";
395
+ const setupReady = Boolean(setup &&
396
+ evidence &&
397
+ setup.extensionId === evidence.extensionId &&
398
+ chromeState === "ENABLED");
314
399
  return {
315
400
  result: {
316
401
  ...base,
@@ -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.18";
6
+ readonly moduleVersion: "0.1.20";
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.18",
6
+ moduleVersion: "0.1.20",
7
7
  kind: "browser-extension",
8
8
  templateVersion: "1.0.0",
9
9
  platformCompatibility: ">=1.0.0 <2.0.0",
@@ -129,6 +129,15 @@ export async function createBrowserRealityBridgeServer(options) {
129
129
  send(response, 200, { accepted: true });
130
130
  return;
131
131
  }
132
+ if (request.method === "GET" && url.pathname === "/v1/session/status") {
133
+ const online = session !== undefined &&
134
+ now().getTime() - session.lastHeartbeatAt <= freshnessMs;
135
+ send(response, 200, {
136
+ online,
137
+ extensionInstanceId: session?.extensionInstanceId ?? null,
138
+ });
139
+ return;
140
+ }
132
141
  if (!session)
133
142
  throw new BrowserRealityBridgeError("BRIDGE_OFFLINE", "extension session has not completed hello");
134
143
  if (url.searchParams.get("extensionInstanceId") !==
@@ -0,0 +1,6 @@
1
+ export type ChromeExtensionState = "ENABLED" | "DISABLED" | "MISSING" | "UNKNOWN";
2
+ export declare function probeChromeExtensionState(input: {
3
+ extensionId: string;
4
+ loadDir: string;
5
+ userDataRoot?: string;
6
+ }): Promise<ChromeExtensionState>;
@@ -0,0 +1,66 @@
1
+ import { readdir, readFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join, resolve } from "node:path";
4
+ function defaultUserDataRoot() {
5
+ if (process.platform === "darwin")
6
+ return join(homedir(), "Library", "Application Support", "Google", "Chrome");
7
+ if (process.platform === "linux")
8
+ return join(homedir(), ".config", "google-chrome");
9
+ if (process.platform === "win32" && process.env.LOCALAPPDATA)
10
+ return join(process.env.LOCALAPPDATA, "Google", "Chrome", "User Data");
11
+ return undefined;
12
+ }
13
+ function entryState(entry, expectedLoadDir) {
14
+ if (typeof entry.path !== "string" || resolve(entry.path) !== expectedLoadDir)
15
+ return undefined;
16
+ const disabledByReason = Array.isArray(entry.disable_reasons) && entry.disable_reasons.length > 0;
17
+ const disabledByState = entry.state === 0;
18
+ return disabledByReason || disabledByState ? "DISABLED" : "ENABLED";
19
+ }
20
+ async function settingsFrom(path) {
21
+ const raw = JSON.parse(await readFile(path, "utf8"));
22
+ return raw.extensions?.settings ?? {};
23
+ }
24
+ async function preferredProfiles(root) {
25
+ let lastUsed;
26
+ try {
27
+ const localState = JSON.parse(await readFile(join(root, "Local State"), "utf8"));
28
+ if (typeof localState.profile?.last_used === "string")
29
+ lastUsed = localState.profile.last_used;
30
+ }
31
+ catch { }
32
+ const entries = await readdir(root, { withFileTypes: true });
33
+ const profiles = entries
34
+ .filter((entry) => entry.isDirectory() && /^(Default|Profile \d+)$/.test(entry.name))
35
+ .map((entry) => entry.name);
36
+ return lastUsed && profiles.includes(lastUsed)
37
+ ? [lastUsed, ...profiles.filter((name) => name !== lastUsed)]
38
+ : profiles;
39
+ }
40
+ export async function probeChromeExtensionState(input) {
41
+ const root = input.userDataRoot ?? defaultUserDataRoot();
42
+ if (!root)
43
+ return "UNKNOWN";
44
+ const expectedLoadDir = resolve(input.loadDir);
45
+ try {
46
+ const profiles = await preferredProfiles(root);
47
+ let sawMatchingDisabled = false;
48
+ for (const profile of profiles) {
49
+ for (const file of ["Secure Preferences", "Preferences"]) {
50
+ try {
51
+ const settings = await settingsFrom(join(root, profile, file));
52
+ const observed = entryState(settings[input.extensionId] ?? {}, expectedLoadDir);
53
+ if (observed === "ENABLED")
54
+ return "ENABLED";
55
+ if (observed === "DISABLED")
56
+ sawMatchingDisabled = true;
57
+ }
58
+ catch { }
59
+ }
60
+ }
61
+ return sawMatchingDisabled ? "DISABLED" : "MISSING";
62
+ }
63
+ catch {
64
+ return "UNKNOWN";
65
+ }
66
+ }
package/manifest.json CHANGED
@@ -1,28 +1,17 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "ProFlow Execution Browser",
4
- "version": "0.1.18",
5
- "permissions": [
6
- "tabs",
7
- "storage",
8
- "sidePanel"
9
- ],
10
- "host_permissions": [
11
- "https://chatgpt.com/*",
12
- "http://127.0.0.1/*"
13
- ],
4
+ "version": "0.1.20",
5
+ "permissions": ["tabs", "storage", "sidePanel"],
6
+ "host_permissions": ["https://chatgpt.com/*", "http://127.0.0.1/*"],
14
7
  "background": {
15
8
  "service_worker": "dist/extension/background.js",
16
9
  "type": "module"
17
10
  },
18
11
  "content_scripts": [
19
12
  {
20
- "matches": [
21
- "https://chatgpt.com/g/*"
22
- ],
23
- "js": [
24
- "dist/extension/content.js"
25
- ],
13
+ "matches": ["https://chatgpt.com/g/*"],
14
+ "js": ["dist/extension/content.js"],
26
15
  "run_at": "document_idle"
27
16
  },
28
17
  {
@@ -30,9 +19,7 @@
30
19
  "https://chatgpt.com/gpts/editor",
31
20
  "https://chatgpt.com/gpts/editor/*"
32
21
  ],
33
- "js": [
34
- "dist/extension/provisioning-content.js"
35
- ],
22
+ "js": ["dist/extension/provisioning-content.js"],
36
23
  "run_at": "document_idle"
37
24
  }
38
25
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomflow/proflow-execution-browser-extension",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Execution-owned MV3 Browser executor, evidence provider and browser application surface.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -31,8 +31,8 @@
31
31
  "@tomflow/proflow-module-contract": "^0.1.13"
32
32
  },
33
33
  "devDependencies": {
34
- "@tomflow/proflow-deployment-conformance": "^0.1.13",
35
- "@tomflow/proflow-execution-runtime": "^0.1.15"
34
+ "@tomflow/proflow-execution-runtime": "^0.1.15",
35
+ "@tomflow/proflow-deployment-conformance": "^0.1.13"
36
36
  },
37
37
  "keywords": [
38
38
  "proflow",
@@ -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.18",
6
+ "moduleVersion": "0.1.20",
7
7
  "kind": "browser-extension",
8
8
  "templateVersion": "1.0.0",
9
9
  "platformCompatibility": ">=1.0.0 <2.0.0",
package/CHANGELOG.md DELETED
@@ -1,79 +0,0 @@
1
- # @tomflow/proflow-execution-browser-extension
2
-
3
- ## 0.1.18
4
-
5
- ### Patch Changes
6
-
7
- - Close the final Deployment replay defects: make Dev Tunnel CLI version probing tolerate real service latency, keep Browser Extension setup idempotent across retries, and remember a non-sensitive Provider endpoint across temporary outages without fabricating readiness.
8
-
9
- ## 0.1.17
10
-
11
- ### Patch Changes
12
-
13
- - Repack the Deployment Closeout release from freshly rebuilt artifacts and enforce build + publishability before every canonical publish.
14
-
15
- ## 0.1.16
16
-
17
- ### Patch Changes
18
-
19
- - Harden Deployment Closeout: fail closed on partial installs and package-manager conflicts, normalize Git workspace isolation, make Dev Tunnel status fast and resumable without fabricating login failures, and align Browser Extension setup/conformance behavior.
20
-
21
- ## 0.1.15
22
-
23
- ### Patch Changes
24
-
25
- - Add professional setup orchestration, Provider FAST/THINK input, recoverable managed Dev Tunnel provisioning, Browser installation guidance, and precise status diagnostics.
26
-
27
- ## 0.1.14
28
-
29
- ### Patch Changes
30
-
31
- - 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.
32
-
33
- ## 0.1.13
34
-
35
- ### Patch Changes
36
-
37
- - Ship the Phase 3 browser, tunnel, model automation, platform readiness, and documentation closure as one verifiable platform snapshot.
38
-
39
- ## 0.1.12
40
-
41
- ### Patch Changes
42
-
43
- - Distinguish dependency blocking from verified failure, expose Module-owned status diagnostics, remove automatic docs paging, consolidate start checks, add contextual help, and clarify uninstall output.
44
-
45
- ## 0.1.11
46
-
47
- ### Patch Changes
48
-
49
- - Upgrade the ProFlow terminal experience, stream Registry and package-manager progress, publish structured Chinese Module documentation, and provide numbered package-owned Setup assistants.
50
-
51
- ## 0.1.10
52
-
53
- ### Patch Changes
54
-
55
- - Make every setup command directly runnable from a workspace and render setup failures without Node stack traces.
56
-
57
- ## 0.1.9
58
-
59
- ### Patch Changes
60
-
61
- - Improve terminal progress and localized status output, publish readable Chinese module docs, and add guided setup assistants for external resources.
62
-
63
- ## 0.1.8
64
-
65
- ### Patch Changes
66
-
67
- - Resolve DOCS.md from both source and built deployment adapters, prove all 24 built adapters return the published body, and announce package synchronization before the package manager blocks.
68
-
69
- ## 0.1.7
70
-
71
- ### Patch Changes
72
-
73
- - Replace JSON terminal protocols with typed CLI outcomes, add real-time Chinese progress and lifecycle summaries, publish DOCS content, standardize executable setup plans and package-owned setup commands, and preserve only user-owned pnpm policy during uninstall.
74
-
75
- ## 0.1.6
76
-
77
- ### Patch Changes
78
-
79
- - Align all Modules to the seven-command setup contract with executable package-owned setup guidance and full Platform setup aggregation.