@workglow/task-graph 0.2.2 → 0.2.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.
- package/dist/browser.js +87 -14
- package/dist/browser.js.map +7 -7
- package/dist/bun.js +87 -14
- package/dist/bun.js.map +7 -7
- package/dist/node.js +87 -14
- package/dist/node.js.map +7 -7
- package/dist/task/EntitlementProfiles.d.ts +7 -0
- package/dist/task/EntitlementProfiles.d.ts.map +1 -1
- package/dist/task/GraphAsTask.d.ts +16 -0
- package/dist/task/GraphAsTask.d.ts.map +1 -1
- package/dist/task/TaskEntitlements.d.ts +7 -4
- package/dist/task/TaskEntitlements.d.ts.map +1 -1
- package/dist/task/TaskRunner.d.ts +1 -1
- package/dist/task/TaskRunner.d.ts.map +1 -1
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/browser.js
CHANGED
|
@@ -294,16 +294,32 @@ function entitlementCovers(granted, required) {
|
|
|
294
294
|
function resourcePatternMatches(grantPattern, requiredResource) {
|
|
295
295
|
if (grantPattern === requiredResource)
|
|
296
296
|
return true;
|
|
297
|
-
|
|
298
|
-
if (starIdx === -1)
|
|
297
|
+
if (!grantPattern.includes("*"))
|
|
299
298
|
return false;
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
|
|
299
|
+
const parts = grantPattern.split("*");
|
|
300
|
+
const first = parts[0];
|
|
301
|
+
const last = parts[parts.length - 1];
|
|
302
|
+
if (!requiredResource.startsWith(first))
|
|
303
303
|
return false;
|
|
304
|
-
if (!requiredResource.endsWith(
|
|
304
|
+
if (!requiredResource.endsWith(last))
|
|
305
305
|
return false;
|
|
306
|
-
|
|
306
|
+
let fixedLength = 0;
|
|
307
|
+
for (const p of parts)
|
|
308
|
+
fixedLength += p.length;
|
|
309
|
+
if (requiredResource.length < fixedLength)
|
|
310
|
+
return false;
|
|
311
|
+
let searchStart = first.length;
|
|
312
|
+
const searchEnd = requiredResource.length - last.length;
|
|
313
|
+
for (let i = 1;i < parts.length - 1; i++) {
|
|
314
|
+
const part = parts[i];
|
|
315
|
+
if (part.length === 0)
|
|
316
|
+
continue;
|
|
317
|
+
const idx = requiredResource.indexOf(part, searchStart);
|
|
318
|
+
if (idx === -1 || idx + part.length > searchEnd)
|
|
319
|
+
return false;
|
|
320
|
+
searchStart = idx + part.length;
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
307
323
|
}
|
|
308
324
|
function grantCoversResources(grant, required) {
|
|
309
325
|
if (grant.resources === undefined)
|
|
@@ -1371,6 +1387,9 @@ class TaskRunner {
|
|
|
1371
1387
|
signal: this.abortController?.signal
|
|
1372
1388
|
});
|
|
1373
1389
|
}
|
|
1390
|
+
if (this.task.constructor.hasDynamicEntitlements) {
|
|
1391
|
+
this.task.emit("entitlementChange", this.task.entitlements());
|
|
1392
|
+
}
|
|
1374
1393
|
return i;
|
|
1375
1394
|
}
|
|
1376
1395
|
async executeTask(input) {
|
|
@@ -2837,11 +2856,6 @@ class TaskGraphRunner {
|
|
|
2837
2856
|
const dataflows = this.graph.getTargetDataflows(node.id);
|
|
2838
2857
|
for (const dataflow of dataflows) {
|
|
2839
2858
|
const compatibility = dataflow.semanticallyCompatible(this.graph, dataflow);
|
|
2840
|
-
getLogger3().debug("pushOutputFromNodeToEdges", {
|
|
2841
|
-
dataflowId: dataflow.id,
|
|
2842
|
-
compatibility,
|
|
2843
|
-
resultsKeys: Object.keys(results)
|
|
2844
|
-
});
|
|
2845
2859
|
if (compatibility === "static") {
|
|
2846
2860
|
dataflow.setPortData(results);
|
|
2847
2861
|
} else if (compatibility === "runtime") {
|
|
@@ -3556,6 +3570,64 @@ class GraphAsTask extends Task {
|
|
|
3556
3570
|
this.events.emit("regenerate");
|
|
3557
3571
|
this.emitEntitlementChange();
|
|
3558
3572
|
}
|
|
3573
|
+
_entitlementUnsub;
|
|
3574
|
+
_subscribeToSubGraphEntitlements(graph) {
|
|
3575
|
+
this._entitlementUnsub?.();
|
|
3576
|
+
this._entitlementUnsub = graph.subscribeToTaskEntitlements(() => {
|
|
3577
|
+
this.emitEntitlementChange();
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
_syncSubGraphEntitlementSubscription(graph = this._subGraph) {
|
|
3581
|
+
if ((this._events?.listenerCount("entitlementChange") ?? 0) === 0) {
|
|
3582
|
+
this._entitlementUnsub?.();
|
|
3583
|
+
this._entitlementUnsub = undefined;
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
if (!graph || this._entitlementUnsub) {
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3589
|
+
this._subscribeToSubGraphEntitlements(graph);
|
|
3590
|
+
}
|
|
3591
|
+
subscribe(name, fn) {
|
|
3592
|
+
const unsub = super.subscribe(name, fn);
|
|
3593
|
+
if (name !== "entitlementChange") {
|
|
3594
|
+
return unsub;
|
|
3595
|
+
}
|
|
3596
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3597
|
+
return () => {
|
|
3598
|
+
unsub();
|
|
3599
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
on(name, fn) {
|
|
3603
|
+
super.on(name, fn);
|
|
3604
|
+
if (name === "entitlementChange") {
|
|
3605
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
off(name, fn) {
|
|
3609
|
+
super.off(name, fn);
|
|
3610
|
+
if (name === "entitlementChange") {
|
|
3611
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
once(name, fn) {
|
|
3615
|
+
super.once(name, fn);
|
|
3616
|
+
if (name === "entitlementChange") {
|
|
3617
|
+
this._syncSubGraphEntitlementSubscription();
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
set subGraph(subGraph) {
|
|
3621
|
+
this._entitlementUnsub?.();
|
|
3622
|
+
this._entitlementUnsub = undefined;
|
|
3623
|
+
super.subGraph = subGraph;
|
|
3624
|
+
this._syncSubGraphEntitlementSubscription(subGraph);
|
|
3625
|
+
}
|
|
3626
|
+
get subGraph() {
|
|
3627
|
+
const graph = super.subGraph;
|
|
3628
|
+
this._syncSubGraphEntitlementSubscription(graph);
|
|
3629
|
+
return graph;
|
|
3630
|
+
}
|
|
3559
3631
|
toJSON(options) {
|
|
3560
3632
|
let json = super.toJSON(options);
|
|
3561
3633
|
const hasChildren = this.hasChildren();
|
|
@@ -5174,7 +5246,8 @@ function resetMethodNameCache() {
|
|
|
5174
5246
|
}
|
|
5175
5247
|
// src/task/EntitlementProfiles.ts
|
|
5176
5248
|
var BROWSER_GRANTS = [
|
|
5177
|
-
{ id: Entitlements.
|
|
5249
|
+
{ id: Entitlements.NETWORK_HTTP },
|
|
5250
|
+
{ id: Entitlements.NETWORK_WEBSOCKET },
|
|
5178
5251
|
{ id: Entitlements.AI },
|
|
5179
5252
|
{ id: Entitlements.MCP_TOOL_CALL },
|
|
5180
5253
|
{ id: Entitlements.MCP_RESOURCE_READ },
|
|
@@ -8126,4 +8199,4 @@ export {
|
|
|
8126
8199
|
BROWSER_GRANTS
|
|
8127
8200
|
};
|
|
8128
8201
|
|
|
8129
|
-
//# debugId=
|
|
8202
|
+
//# debugId=8A43A4F12CABDEAB64756E2164756E21
|