@workglow/task-graph 0.2.5 → 0.2.7

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/bun.js CHANGED
@@ -284,7 +284,13 @@ var Entitlements = {
284
284
  MCP_STDIO: "mcp:stdio",
285
285
  STORAGE: "storage",
286
286
  STORAGE_READ: "storage:read",
287
- STORAGE_WRITE: "storage:write"
287
+ STORAGE_WRITE: "storage:write",
288
+ BROWSER_CONTROL: "browser",
289
+ BROWSER_CONTROL_LOCAL: "browser:local",
290
+ BROWSER_CONTROL_CLOUD: "browser:cloud",
291
+ BROWSER_CONTROL_NAVIGATE: "browser:navigate",
292
+ BROWSER_CONTROL_EVALUATE: "browser:evaluate",
293
+ BROWSER_CONTROL_CREDENTIAL: "browser:credential"
288
294
  };
289
295
  var EMPTY_ENTITLEMENTS = Object.freeze({
290
296
  entitlements: Object.freeze([])
@@ -1272,6 +1278,7 @@ class TaskRunner {
1272
1278
  abortController;
1273
1279
  outputCache;
1274
1280
  registry = globalServiceRegistry;
1281
+ resourceScope;
1275
1282
  inputStreams;
1276
1283
  timeoutTimer;
1277
1284
  pendingTimeoutError;
@@ -1385,7 +1392,8 @@ class TaskRunner {
1385
1392
  if (hasRunConfig(i)) {
1386
1393
  Object.assign(i.runConfig, {
1387
1394
  registry: this.registry,
1388
- signal: this.abortController?.signal
1395
+ signal: this.abortController?.signal,
1396
+ resourceScope: this.resourceScope
1389
1397
  });
1390
1398
  }
1391
1399
  if (this.task.constructor.hasDynamicEntitlements) {
@@ -1398,7 +1406,8 @@ class TaskRunner {
1398
1406
  signal: this.abortController.signal,
1399
1407
  updateProgress: this.handleProgress.bind(this),
1400
1408
  own: this.own,
1401
- registry: this.registry
1409
+ registry: this.registry,
1410
+ resourceScope: this.resourceScope
1402
1411
  });
1403
1412
  return await this.executeTaskReactive(input, result || {});
1404
1413
  }
@@ -1430,6 +1439,7 @@ class TaskRunner {
1430
1439
  updateProgress: this.handleProgress.bind(this),
1431
1440
  own: this.own,
1432
1441
  registry: this.registry,
1442
+ resourceScope: this.resourceScope,
1433
1443
  inputStreams: this.inputStreams
1434
1444
  });
1435
1445
  for await (const event of stream) {
@@ -1552,6 +1562,9 @@ class TaskRunner {
1552
1562
  if (config.registry) {
1553
1563
  this.registry = config.registry;
1554
1564
  }
1565
+ if (config.resourceScope) {
1566
+ this.resourceScope = config.resourceScope;
1567
+ }
1555
1568
  if (config.signal) {
1556
1569
  const onAbort = () => this.abortController.abort();
1557
1570
  config.signal.addEventListener("abort", onAbort, { once: true });
@@ -2541,8 +2554,8 @@ class TopologicalScheduler {
2541
2554
  yield this.sortedNodes[this.currentIndex++];
2542
2555
  }
2543
2556
  }
2544
- onTaskCompleted(taskId) {}
2545
- onTaskStreaming(taskId) {}
2557
+ onTaskCompleted(_taskId) {}
2558
+ onTaskStreaming(_taskId) {}
2546
2559
  reset() {
2547
2560
  this.sortedNodes = this.dag.topologicallySortedNodes();
2548
2561
  this.currentIndex = 0;
@@ -2686,6 +2699,7 @@ class TaskGraphRunner {
2686
2699
  outputCache;
2687
2700
  accumulateLeafOutputs = true;
2688
2701
  registry = globalServiceRegistry2;
2702
+ resourceScope;
2689
2703
  abortController;
2690
2704
  inProgressTasks = new Map;
2691
2705
  inProgressFunctions = new Map;
@@ -3015,7 +3029,8 @@ class TaskGraphRunner {
3015
3029
  const results = await task.runner.run(input, {
3016
3030
  outputCache: this.outputCache ?? false,
3017
3031
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3018
- registry: this.registry
3032
+ registry: this.registry,
3033
+ resourceScope: this.resourceScope
3019
3034
  });
3020
3035
  await this.pushOutputFromNodeToEdges(task, results);
3021
3036
  return {
@@ -3061,7 +3076,8 @@ class TaskGraphRunner {
3061
3076
  outputCache: this.outputCache ?? false,
3062
3077
  shouldAccumulate,
3063
3078
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3064
- registry: this.registry
3079
+ registry: this.registry,
3080
+ resourceScope: this.resourceScope
3065
3081
  });
3066
3082
  await this.pushOutputFromNodeToEdges(task, results);
3067
3083
  return {
@@ -3102,7 +3118,7 @@ class TaskGraphRunner {
3102
3118
  }
3103
3119
  });
3104
3120
  }
3105
- pushStreamToEdges(task, streamMode) {
3121
+ pushStreamToEdges(task, _streamMode) {
3106
3122
  const targetDataflows = this.graph.getTargetDataflows(task.id);
3107
3123
  if (targetDataflows.length === 0)
3108
3124
  return;
@@ -3165,6 +3181,9 @@ class TaskGraphRunner {
3165
3181
  } else if (this.registry === undefined) {
3166
3182
  this.registry = new ServiceRegistry2(globalServiceRegistry2.container.createChildContainer());
3167
3183
  }
3184
+ if (config?.resourceScope !== undefined) {
3185
+ this.resourceScope = config.resourceScope;
3186
+ }
3168
3187
  this.accumulateLeafOutputs = config?.accumulateLeafOutputs !== false;
3169
3188
  if (config?.outputCache !== undefined) {
3170
3189
  if (typeof config.outputCache === "boolean") {
@@ -3363,14 +3382,16 @@ class GraphAsTaskRunner extends TaskRunner {
3363
3382
  const results = await this.task.subGraph.run(input, {
3364
3383
  parentSignal: this.abortController?.signal,
3365
3384
  outputCache: this.outputCache,
3366
- registry: this.registry
3385
+ registry: this.registry,
3386
+ resourceScope: this.resourceScope
3367
3387
  });
3368
3388
  unsubscribe();
3369
3389
  return results;
3370
3390
  }
3371
3391
  async executeTaskChildrenReactive() {
3372
3392
  return this.task.subGraph.runReactive(this.task.runInputData, {
3373
- registry: this.registry
3393
+ registry: this.registry,
3394
+ resourceScope: this.resourceScope
3374
3395
  });
3375
3396
  }
3376
3397
  async handleDisable() {
@@ -3419,9 +3440,9 @@ class GraphAsTask extends Task {
3419
3440
  static compoundMerge = PROPERTY_ARRAY;
3420
3441
  static hasDynamicSchemas = true;
3421
3442
  static hasDynamicEntitlements = true;
3422
- constructor(config = {}) {
3443
+ constructor(config = {}, runConfig = {}) {
3423
3444
  const { subGraph, ...rest } = config;
3424
- super(rest);
3445
+ super(rest, runConfig);
3425
3446
  if (subGraph) {
3426
3447
  this.subGraph = subGraph;
3427
3448
  }
@@ -3809,7 +3830,8 @@ class TaskGraph {
3809
3830
  accumulateLeafOutputs: config?.accumulateLeafOutputs,
3810
3831
  registry: config?.registry,
3811
3832
  timeout: config?.timeout,
3812
- maxTasks: config?.maxTasks
3833
+ maxTasks: config?.maxTasks,
3834
+ resourceScope: config?.resourceScope
3813
3835
  });
3814
3836
  }
3815
3837
  runReactive(input = {}, config = {}) {
@@ -4132,7 +4154,7 @@ function parallel(args, mergeFn = PROPERTY_ARRAY, workflow = new Workflow) {
4132
4154
  const config = {
4133
4155
  compoundMerge: mergeFn
4134
4156
  };
4135
- const name = `\u2016${args.map((arg) => "\uD835\uDC53").join("\u2016")}\u2016`;
4157
+ const name = `\u2016${args.map((_arg) => "\uD835\uDC53").join("\u2016")}\u2016`;
4136
4158
 
4137
4159
  class ParallelTask extends GraphAsTask {
4138
4160
  static type = name;
@@ -4350,7 +4372,8 @@ class Workflow {
4350
4372
  const output = await this.graph.run(input, {
4351
4373
  parentSignal: this._abortController.signal,
4352
4374
  outputCache: this._outputCache,
4353
- registry: config?.registry ?? this._registry
4375
+ registry: config?.registry ?? this._registry,
4376
+ resourceScope: config?.resourceScope
4354
4377
  });
4355
4378
  const results = this.graph.mergeExecuteOutputsToRunOutput(output, PROPERTY_ARRAY);
4356
4379
  this.events.emit("complete");
@@ -5013,7 +5036,7 @@ function generateRegularTask(task, chainIndent, lines) {
5013
5036
  lines.push(`${chainIndent}.addTask(${args})`);
5014
5037
  }
5015
5038
  }
5016
- function generateLoopTask(task, loopInfo, incomingDataflows, taskOrder, indent, depth, lines) {
5039
+ function generateLoopTask(task, loopInfo, _incomingDataflows, _taskOrder, indent, depth, lines) {
5017
5040
  const chainIndent = indent.repeat(depth + 1);
5018
5041
  const config = extractLoopConfig(task);
5019
5042
  const loopColOffset = chainIndent.length + `.${loopInfo.method}(`.length;
@@ -5269,9 +5292,17 @@ var DESKTOP_GRANTS = [
5269
5292
  ...BROWSER_GRANTS,
5270
5293
  { id: Entitlements.FILESYSTEM },
5271
5294
  { id: Entitlements.CODE_EXECUTION },
5272
- { id: Entitlements.MCP_STDIO }
5295
+ { id: Entitlements.MCP_STDIO },
5296
+ { id: Entitlements.BROWSER_CONTROL },
5297
+ { id: Entitlements.BROWSER_CONTROL_LOCAL },
5298
+ { id: Entitlements.BROWSER_CONTROL_NAVIGATE },
5299
+ { id: Entitlements.BROWSER_CONTROL_EVALUATE },
5300
+ { id: Entitlements.BROWSER_CONTROL_CREDENTIAL }
5301
+ ];
5302
+ var SERVER_GRANTS = [
5303
+ ...DESKTOP_GRANTS,
5304
+ { id: Entitlements.BROWSER_CONTROL_CLOUD }
5273
5305
  ];
5274
- var SERVER_GRANTS = [...DESKTOP_GRANTS];
5275
5306
  var PROFILE_GRANTS = {
5276
5307
  browser: BROWSER_GRANTS,
5277
5308
  desktop: DESKTOP_GRANTS,
@@ -5713,7 +5744,8 @@ class IteratorTaskRunner extends GraphAsTaskRunner {
5713
5744
  const results = await graphClone.run(input, {
5714
5745
  parentSignal: this.abortController?.signal,
5715
5746
  outputCache: this.outputCache,
5716
- registry: this.registry
5747
+ registry: this.registry,
5748
+ resourceScope: this.resourceScope
5717
5749
  });
5718
5750
  if (results.length === 0) {
5719
5751
  return;
@@ -7572,4 +7604,4 @@ export {
7572
7604
  BROWSER_GRANTS
7573
7605
  };
7574
7606
 
7575
- //# debugId=68A264276606E85C64756E2164756E21
7607
+ //# debugId=3A413C401323694864756E2164756E21