@tomflow/proflow-execution-browser-extension 0.1.2 → 0.1.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.
@@ -1,15 +1,15 @@
1
- import { createHash } from "node:crypto";
2
1
  import { parseExecutionRecord, } from "@tomflow/proflow-execution-contracts";
3
- function contentFingerprint(message) {
4
- return `sha256:${createHash("sha256")
5
- .update(JSON.stringify({
2
+ async function contentFingerprint(message) {
3
+ const payload = new TextEncoder().encode(JSON.stringify({
6
4
  messageId: message.messageId,
7
5
  taskId: message.taskId,
8
6
  targetRoleRef: message.targetRoleRef,
9
7
  targetWorkerRef: message.targetWorkerRef,
10
8
  content: message.content,
11
- }))
12
- .digest("hex")}`;
9
+ }));
10
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", payload);
11
+ const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
12
+ return `sha256:${hex}`;
13
13
  }
14
14
  /**
15
15
  * Event-driven Collaboration Carrier application.
@@ -59,7 +59,7 @@ export function createCollaborationCarrierApplication(options) {
59
59
  roleRef: message.targetRoleRef,
60
60
  workerRef: message.targetWorkerRef,
61
61
  messageRef: message.messageId,
62
- contentFingerprint: contentFingerprint(message),
62
+ contentFingerprint: await contentFingerprint(message),
63
63
  },
64
64
  };
65
65
  const execution = parseExecutionRecord(await options.execution.execute(request));
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export declare function materializeBrowserExtensionConfig(workspaceRoot: string): Promise<{
3
+ loadDir: string;
4
+ }>;
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ import { materializeProductionConfig } from "../deployment/adapter.js";
5
+ function workspaceFromArgs(args) {
6
+ if (args[0] !== "materialize-config") {
7
+ throw new Error("Usage: proflow-execution-browser-extension materialize-config [--workspace /absolute/path]");
8
+ }
9
+ const workspaceIndex = args.indexOf("--workspace");
10
+ if (workspaceIndex < 0)
11
+ return process.cwd();
12
+ const value = args[workspaceIndex + 1];
13
+ if (!value || args.length !== 3) {
14
+ throw new Error("Usage: proflow-execution-browser-extension materialize-config [--workspace /absolute/path]");
15
+ }
16
+ return resolve(value);
17
+ }
18
+ export async function materializeBrowserExtensionConfig(workspaceRoot) {
19
+ const configPath = resolve(workspaceRoot, ".proflow", "config", "execution-browser-extension.json");
20
+ const parsed = JSON.parse(await readFile(configPath, "utf8"));
21
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
22
+ throw new Error("execution-browser-extension config must be a JSON object");
23
+ }
24
+ const config = Object.fromEntries(Object.entries(parsed).map(([key, value]) => {
25
+ if (typeof value !== "string") {
26
+ throw new Error(`browser extension config ${key} must be a string`);
27
+ }
28
+ return [key, value];
29
+ }));
30
+ return materializeProductionConfig({
31
+ moduleRef: "execution-browser-extension",
32
+ config,
33
+ workspaceRoot,
34
+ });
35
+ }
36
+ async function main() {
37
+ const workspaceRoot = workspaceFromArgs(process.argv.slice(2));
38
+ const result = await materializeBrowserExtensionConfig(workspaceRoot);
39
+ process.stdout.write(`${JSON.stringify({ status: "MATERIALIZED", ...result })}\n`);
40
+ }
41
+ if (import.meta.main)
42
+ await main();
@@ -1,15 +1,17 @@
1
+ import { createCollaborationCarrierApplication } from "../src/collaboration-carrier.js";
1
2
  import {
2
- createCollaborationCarrierApplication,
3
3
  createSystemObserver,
4
- createTaskObserver,
5
4
  type SystemObserverReasonFailure,
6
5
  type SystemObserverReasonRequest,
7
6
  type SystemObserverReasonResult,
8
7
  type SystemObserverView,
8
+ } from "../src/system-observer.js";
9
+ import {
10
+ createTaskObserver,
9
11
  type TaskDriveProjection,
10
12
  type TaskObserverDiagnosticAssessment,
11
13
  type TaskObserverDiagnosticFailure,
12
- } from "../src/index.js";
14
+ } from "../src/task-observer.js";
13
15
 
14
16
  type PageState = "IDLE" | "BUSY" | "BLOCKED" | "UNKNOWN";
15
17
  type ActivityKind =
@@ -69,6 +71,7 @@ type ChromeTab = { id?: number; windowId?: number; url?: string };
69
71
  type ChromeRuntime = {
70
72
  runtime: {
71
73
  id: string;
74
+ getURL(path: string): string;
72
75
  onMessage: {
73
76
  addListener(
74
77
  listener: (
@@ -153,6 +156,38 @@ function parseConfig(value: unknown): BridgeConfig | null {
153
156
  return { endpoint: endpoint.replace(/\/$/, ""), token };
154
157
  }
155
158
 
159
+ type ManagedRuntimeConfig = {
160
+ proflowRuntimeBridge?: unknown;
161
+ proflowTaskApplication?: unknown;
162
+ proflowApprovalApplication?: unknown;
163
+ };
164
+
165
+ async function bootstrapManagedRuntimeConfig(): Promise<void> {
166
+ let response: Response;
167
+ try {
168
+ response = await fetch(chrome.runtime.getURL("runtime-config.json"), {
169
+ cache: "no-store",
170
+ });
171
+ } catch {
172
+ return;
173
+ }
174
+ if (!response.ok) return;
175
+ const raw = (await response.json()) as unknown;
176
+ if (!isRecord(raw)) return;
177
+ const managed = raw as ManagedRuntimeConfig;
178
+ const bridge = parseConfig(managed.proflowRuntimeBridge);
179
+ const task = parseConfig(managed.proflowTaskApplication);
180
+ const approval = parseConfig(managed.proflowApprovalApplication);
181
+ if (!bridge || !task || !approval) {
182
+ throw new Error("MANAGED_RUNTIME_CONFIG_INVALID");
183
+ }
184
+ await chrome.storage.local.set({
185
+ proflowRuntimeBridge: bridge,
186
+ proflowTaskApplication: task,
187
+ proflowApprovalApplication: approval,
188
+ });
189
+ }
190
+
156
191
  async function bridgeConfig(): Promise<BridgeConfig | null> {
157
192
  const stored = await chrome.storage.local.get("proflowRuntimeBridge");
158
193
  return parseConfig(stored.proflowRuntimeBridge);
@@ -981,17 +1016,27 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
981
1016
  }
982
1017
  });
983
1018
 
984
- chrome.runtime.onInstalled.addListener(() => {
985
- void chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
1019
+ async function startBackgroundRuntime(): Promise<void> {
1020
+ await bootstrapManagedRuntimeConfig();
1021
+ await persistSnapshot();
986
1022
  void runBridgeLoop();
987
1023
  void runObserverRecovery();
1024
+ }
1025
+
1026
+ chrome.runtime.onInstalled.addListener(() => {
1027
+ void chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
1028
+ void bootstrapManagedRuntimeConfig().then(async () => {
1029
+ await persistSnapshot();
1030
+ void runBridgeLoop();
1031
+ void runObserverRecovery();
1032
+ });
988
1033
  });
989
1034
  chrome.runtime.onStartup.addListener(() => {
990
1035
  sessions.clear();
991
- void persistSnapshot();
992
- void runBridgeLoop();
993
- void runObserverRecovery();
1036
+ void bootstrapManagedRuntimeConfig().then(async () => {
1037
+ await persistSnapshot();
1038
+ void runBridgeLoop();
1039
+ void runObserverRecovery();
1040
+ });
994
1041
  });
995
- void persistSnapshot();
996
- void runBridgeLoop();
997
- void runObserverRecovery();
1042
+ void startBackgroundRuntime();
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.2",
4
+ "version": "0.1.4",
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.2",
3
+ "version": "0.1.4",
4
4
  "description": "Execution-owned MV3 Browser executor, evidence provider and browser application surface.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -11,7 +11,8 @@
11
11
  "./bridge": "./dist/src/bridge.js",
12
12
  "./deployment/adapter": "./dist/deployment/adapter.js",
13
13
  "./deployment/descriptor": "./dist/deployment/descriptor.js",
14
- "./runtime-composition": "./dist/src/runtime-composition.js"
14
+ "./runtime-composition": "./dist/src/runtime-composition.js",
15
+ "./configure": "./dist/src/configure.js"
15
16
  },
16
17
  "files": [
17
18
  "dist",
@@ -21,15 +22,15 @@
21
22
  "proflow.module.json",
22
23
  "conformance.json",
23
24
  "README.md",
24
- "self-install.mjs"
25
+ "CONFIGURATION.md"
25
26
  ],
26
27
  "dependencies": {
27
- "@tomflow/proflow-execution-contracts": "^0.1.2"
28
+ "@tomflow/proflow-module-contract": "^0.1.2",
29
+ "@tomflow/proflow-execution-contracts": "^0.1.3"
28
30
  },
29
31
  "devDependencies": {
30
- "@tomflow/proflow-deployment-conformance": "^0.1.2",
31
- "@tomflow/proflow-execution-runtime": "^0.1.1",
32
- "@tomflow/proflow-module-contract": "^0.1.1"
32
+ "@tomflow/proflow-deployment-conformance": "^0.1.3",
33
+ "@tomflow/proflow-execution-runtime": "^0.1.5"
33
34
  },
34
35
  "keywords": [
35
36
  "proflow",
@@ -38,20 +39,11 @@
38
39
  ],
39
40
  "proflow": {
40
41
  "module": true,
41
- "installClass": "core",
42
- "installRequires": [
43
- "@tomflow/proflow-agent-runtime",
44
- "@tomflow/proflow-chatgpt-carrier",
45
- "@tomflow/proflow-chrome-runtime",
46
- "@tomflow/proflow-execution-contracts",
47
- "@tomflow/proflow-execution-runtime",
48
- "@tomflow/proflow-task-orchestration"
49
- ],
50
42
  "descriptor": "./dist/deployment/descriptor.js",
51
43
  "manifest": "./proflow.module.json"
52
44
  },
53
45
  "bin": {
54
- "proflow-execution-browser-extension": "./self-install.mjs"
46
+ "proflow-execution-browser-extension": "./dist/src/configure.js"
55
47
  },
56
48
  "scripts": {
57
49
  "test": "node --test tests/**/*.test.ts",
@@ -3,11 +3,10 @@
3
3
  "contractVersion": "1.0.0",
4
4
  "moduleRef": "execution-browser-extension",
5
5
  "packageName": "@tomflow/proflow-execution-browser-extension",
6
- "moduleVersion": "0.1.2",
6
+ "moduleVersion": "0.1.4",
7
7
  "kind": "browser-extension",
8
8
  "templateVersion": "1.0.0",
9
9
  "platformCompatibility": ">=1.0.0 <2.0.0",
10
- "installClass": "core",
11
10
  "identity": {
12
11
  "domain": "execution",
13
12
  "summary": "Execution-owned MV3 Browser executor, evidence provider and browser application surface."
@@ -52,10 +51,10 @@
52
51
  },
53
52
  {
54
53
  "key": "bridge.token",
55
- "type": "secretRef",
54
+ "type": "path",
56
55
  "required": true,
57
56
  "sensitive": true,
58
- "description": "Browser Reality Bridge extension token reference"
57
+ "description": "File containing the Browser Reality Bridge extension token"
59
58
  },
60
59
  {
61
60
  "key": "taskApplication.endpoint",
@@ -65,10 +64,10 @@
65
64
  },
66
65
  {
67
66
  "key": "taskApplication.token",
68
- "type": "secretRef",
67
+ "type": "path",
69
68
  "required": true,
70
69
  "sensitive": true,
71
- "description": "Platform Host Task application token reference"
70
+ "description": "File containing the Platform Host Task application token"
72
71
  },
73
72
  {
74
73
  "key": "approvalApplication.endpoint",
@@ -78,10 +77,16 @@
78
77
  },
79
78
  {
80
79
  "key": "approvalApplication.token",
81
- "type": "secretRef",
80
+ "type": "path",
82
81
  "required": true,
83
82
  "sensitive": true,
84
- "description": "Platform Host Approval application token reference"
83
+ "description": "File containing the Platform Host Approval application token"
84
+ },
85
+ {
86
+ "key": "verificationEvidenceFile",
87
+ "type": "path",
88
+ "required": true,
89
+ "description": "JSON evidence file written after real Chrome loads the Deployment-managed MV3 extension and its Service Worker runs"
85
90
  },
86
91
  {
87
92
  "key": "chromeRuntimeModuleRef",
@@ -122,6 +127,11 @@
122
127
  "id": "overview",
123
128
  "path": "./README.md",
124
129
  "description": "Package-owned module overview"
130
+ },
131
+ {
132
+ "id": "configuration",
133
+ "path": "./CONFIGURATION.md",
134
+ "description": "Module configuration fields, sources and materialization instructions"
125
135
  }
126
136
  ]
127
137
  }
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # @tomflow/proflow-execution-browser-extension
2
-
3
- ## 0.1.2
4
-
5
- ### Patch Changes
6
-
7
- - Close the Real-1 global Platform control-plane contract across every published ProFlow package. Platform CLI now owns one durable global Workspace binding with canonical identity, cross-process operation locking, cwd/`--workspace` install targeting, cross-directory instance commands, whole-instance uninstall/rebind, and deterministic npm/yarn/pnpm Workspace package-manager selection. Every package-owned install entry, including newly generated Module Template packages, delegates to the Shell-global `platform` command and fails closed when that global CLI is unavailable; Deployment Conformance and the formal test plans mechanically enforce the same rule across all 24 packages.
8
-
9
- ## 0.1.1
10
-
11
- ### Patch Changes
12
-
13
- - Close Real-1 deployment graph and Fresh Workspace bootstrap gaps: remove Contract-library runtime-provider aliases, correct Execution/Model dependency direction, materialize logical/moduleRef providers through `installRequires`, enforce repository graph validation, and keep self-install executables stable without package-manager worktree mutation.
package/self-install.mjs DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
-
4
- const [command, ...rest] = process.argv.slice(2);
5
- const usage =
6
- "Usage: npx @tomflow/proflow-execution-browser-extension install\n";
7
- if (command === "--help" || command === "-h") {
8
- process.stdout.write(usage);
9
- process.exit(0);
10
- }
11
- if (command !== "install" || rest.length > 0) {
12
- process.stderr.write(usage);
13
- process.exit(2);
14
- }
15
- const executable = process.platform === "win32" ? "platform.cmd" : "platform";
16
- const result = spawnSync(
17
- executable,
18
- [
19
- "install",
20
- "@tomflow/proflow-execution-browser-extension",
21
- "--workspace",
22
- process.cwd(),
23
- ],
24
- { cwd: process.cwd(), env: process.env, stdio: "inherit" },
25
- );
26
- if (result.error) {
27
- if (result.error.code === "ENOENT") {
28
- process.stderr.write(
29
- "GLOBAL_PLATFORM_CLI_REQUIRED: install @tomflow/proflow-platform-cli globally before package-owned install\n",
30
- );
31
- process.exit(127);
32
- }
33
- throw result.error;
34
- }
35
- process.exit(result.status ?? 1);