@tomflow/proflow-execution-browser-extension 0.1.2 → 0.1.3
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 +6 -0
- package/dist/deployment/adapter.d.ts +20 -5
- package/dist/deployment/adapter.js +177 -0
- package/dist/deployment/descriptor.d.ts +12 -7
- package/dist/deployment/descriptor.js +13 -7
- package/dist/extension/background.js +14498 -675
- package/dist/src/collaboration-carrier.js +7 -7
- package/extension/background.ts +56 -11
- package/manifest.json +1 -1
- package/package.json +3 -3
- package/proflow.module.json +13 -7
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { parseExecutionRecord, } from "@tomflow/proflow-execution-contracts";
|
|
3
|
-
function contentFingerprint(message) {
|
|
4
|
-
|
|
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
|
-
|
|
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));
|
package/extension/background.ts
CHANGED
|
@@ -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/
|
|
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
|
-
|
|
985
|
-
|
|
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
|
|
992
|
-
|
|
993
|
-
|
|
1036
|
+
void bootstrapManagedRuntimeConfig().then(async () => {
|
|
1037
|
+
await persistSnapshot();
|
|
1038
|
+
void runBridgeLoop();
|
|
1039
|
+
void runObserverRecovery();
|
|
1040
|
+
});
|
|
994
1041
|
});
|
|
995
|
-
void
|
|
996
|
-
void runBridgeLoop();
|
|
997
|
-
void runObserverRecovery();
|
|
1042
|
+
void startBackgroundRuntime();
|
package/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/proflow-execution-browser-extension",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Execution-owned MV3 Browser executor, evidence provider and browser application surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@tomflow/proflow-execution-contracts": "^0.1.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
+
"@tomflow/proflow-module-contract": "^0.1.1",
|
|
30
31
|
"@tomflow/proflow-deployment-conformance": "^0.1.2",
|
|
31
|
-
"@tomflow/proflow-execution-runtime": "^0.1.
|
|
32
|
-
"@tomflow/proflow-module-contract": "^0.1.1"
|
|
32
|
+
"@tomflow/proflow-execution-runtime": "^0.1.2"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"proflow",
|
package/proflow.module.json
CHANGED
|
@@ -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.
|
|
6
|
+
"moduleVersion": "0.1.3",
|
|
7
7
|
"kind": "browser-extension",
|
|
8
8
|
"templateVersion": "1.0.0",
|
|
9
9
|
"platformCompatibility": ">=1.0.0 <2.0.0",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"key": "bridge.token",
|
|
55
|
-
"type": "
|
|
55
|
+
"type": "path",
|
|
56
56
|
"required": true,
|
|
57
57
|
"sensitive": true,
|
|
58
|
-
"description": "Browser Reality Bridge extension token
|
|
58
|
+
"description": "File containing the Browser Reality Bridge extension token"
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"key": "taskApplication.endpoint",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"key": "taskApplication.token",
|
|
68
|
-
"type": "
|
|
68
|
+
"type": "path",
|
|
69
69
|
"required": true,
|
|
70
70
|
"sensitive": true,
|
|
71
|
-
"description": "Platform Host Task application token
|
|
71
|
+
"description": "File containing the Platform Host Task application token"
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
"key": "approvalApplication.endpoint",
|
|
@@ -78,10 +78,16 @@
|
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"key": "approvalApplication.token",
|
|
81
|
-
"type": "
|
|
81
|
+
"type": "path",
|
|
82
82
|
"required": true,
|
|
83
83
|
"sensitive": true,
|
|
84
|
-
"description": "Platform Host Approval application token
|
|
84
|
+
"description": "File containing the Platform Host Approval application token"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"key": "verificationEvidenceFile",
|
|
88
|
+
"type": "path",
|
|
89
|
+
"required": true,
|
|
90
|
+
"description": "JSON evidence file written after real Chrome loads the Deployment-managed MV3 extension and its Service Worker runs"
|
|
85
91
|
},
|
|
86
92
|
{
|
|
87
93
|
"key": "chromeRuntimeModuleRef",
|