@nexface/tools 0.1.15-alpha.1 → 0.1.15-alpha.2

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.
Files changed (83) hide show
  1. package/dist/browser/actions.js +34 -10
  2. package/dist/browser/controller.js +53 -74
  3. package/dist/browser/diagnostics.js +8 -3
  4. package/dist/browser/dom.js +12 -28
  5. package/dist/browser/feedback.js +6 -5
  6. package/dist/browser/focus.js +0 -1
  7. package/dist/browser/locator.js +3 -9
  8. package/dist/browser/prompt.generated.js +0 -1
  9. package/dist/browser/prompt.js +0 -1
  10. package/dist/browser/snapshot.js +10 -22
  11. package/dist/browser/toolset.js +42 -36
  12. package/dist/browser/types.d.ts +1 -1
  13. package/dist/browser/types.js +0 -1
  14. package/dist/browser/worker-runner.js +0 -1
  15. package/dist/definition.d.ts +1 -3
  16. package/dist/definition.js +2 -2
  17. package/dist/index.browser.js +0 -1
  18. package/dist/index.js +0 -1
  19. package/dist/internal-react.d.ts +1 -1
  20. package/dist/internal-react.js +3 -4
  21. package/dist/internal-types.js +0 -1
  22. package/dist/navigation.js +0 -1
  23. package/dist/operation-lock.js +36 -2
  24. package/dist/operation-runtime.js +41 -13
  25. package/dist/operation-surface.js +118 -41
  26. package/dist/operation-types.js +0 -1
  27. package/dist/operation-view.d.ts +1 -1
  28. package/dist/operation-view.js +120 -60
  29. package/dist/react.js +9 -14
  30. package/dist/registration.js +4 -3
  31. package/dist/runtime.d.ts +4 -2
  32. package/dist/runtime.js +112 -47
  33. package/dist/shared/definition.js +2 -3
  34. package/dist/shared/errors.d.ts +1 -1
  35. package/dist/shared/errors.js +0 -1
  36. package/dist/shared/page-protocol.js +0 -1
  37. package/dist/shared/page-tools.js +0 -1
  38. package/dist/shared/runtime-controller.d.ts +1 -0
  39. package/dist/shared/runtime-controller.js +0 -1
  40. package/dist/shared/runtime-execution.js +0 -1
  41. package/dist/shared/schema.js +45 -19
  42. package/dist/styles.css +879 -109
  43. package/dist/tool-search.d.ts +11 -0
  44. package/dist/tool-search.js +117 -0
  45. package/dist/types.js +0 -1
  46. package/dist/webmcp.js +39 -13
  47. package/package.json +6 -2
  48. package/dist/browser/actions.js.map +0 -1
  49. package/dist/browser/controller.js.map +0 -1
  50. package/dist/browser/diagnostics.js.map +0 -1
  51. package/dist/browser/dom.js.map +0 -1
  52. package/dist/browser/feedback.js.map +0 -1
  53. package/dist/browser/focus.js.map +0 -1
  54. package/dist/browser/locator.js.map +0 -1
  55. package/dist/browser/prompt.generated.js.map +0 -1
  56. package/dist/browser/prompt.js.map +0 -1
  57. package/dist/browser/snapshot.js.map +0 -1
  58. package/dist/browser/toolset.js.map +0 -1
  59. package/dist/browser/types.js.map +0 -1
  60. package/dist/browser/worker-runner.js.map +0 -1
  61. package/dist/definition.js.map +0 -1
  62. package/dist/index.browser.js.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/internal-react.js.map +0 -1
  65. package/dist/internal-types.js.map +0 -1
  66. package/dist/navigation.js.map +0 -1
  67. package/dist/operation-lock.js.map +0 -1
  68. package/dist/operation-runtime.js.map +0 -1
  69. package/dist/operation-surface.js.map +0 -1
  70. package/dist/operation-types.js.map +0 -1
  71. package/dist/operation-view.js.map +0 -1
  72. package/dist/react.js.map +0 -1
  73. package/dist/registration.js.map +0 -1
  74. package/dist/runtime.js.map +0 -1
  75. package/dist/shared/definition.js.map +0 -1
  76. package/dist/shared/errors.js.map +0 -1
  77. package/dist/shared/page-protocol.js.map +0 -1
  78. package/dist/shared/page-tools.js.map +0 -1
  79. package/dist/shared/runtime-controller.js.map +0 -1
  80. package/dist/shared/runtime-execution.js.map +0 -1
  81. package/dist/shared/schema.js.map +0 -1
  82. package/dist/types.js.map +0 -1
  83. package/dist/webmcp.js.map +0 -1
@@ -27,11 +27,7 @@ const DEFAULT_SNAPSHOT_LIMITS = {
27
27
  fullMaxVisitedNodes: 40_000,
28
28
  };
29
29
  function isIgnoredMutationNode(node) {
30
- const element = node instanceof Element
31
- ? node
32
- : node instanceof Text
33
- ? node.parentElement
34
- : null;
30
+ const element = node instanceof Element ? node : node instanceof Text ? node.parentElement : null;
35
31
  return Boolean(element?.closest("[data-nexface-ignore]"));
36
32
  }
37
33
  function isRelevantMutation(record) {
@@ -40,8 +36,7 @@ function isRelevantMutation(record) {
40
36
  if (record.type !== "childList")
41
37
  return true;
42
38
  const changedNodes = [...record.addedNodes, ...record.removedNodes];
43
- return (changedNodes.length === 0
44
- || changedNodes.some((node) => !isIgnoredMutationNode(node)));
39
+ return changedNodes.length === 0 || changedNodes.some((node) => !isIgnoredMutationNode(node));
45
40
  }
46
41
  let activeHistoryPatch;
47
42
  function subscribeHistoryChanges(subscriber) {
@@ -223,12 +218,12 @@ function validateInput(definition, input) {
223
218
  }
224
219
  }
225
220
  export function browserToolsAvailable() {
226
- return (typeof window !== "undefined"
227
- && typeof document !== "undefined"
228
- && typeof Worker !== "undefined"
229
- && typeof Blob !== "undefined"
230
- && typeof URL?.createObjectURL === "function"
231
- && typeof MutationObserver !== "undefined");
221
+ return (typeof window !== "undefined" &&
222
+ typeof document !== "undefined" &&
223
+ typeof Worker !== "undefined" &&
224
+ typeof Blob !== "undefined" &&
225
+ typeof URL?.createObjectURL === "function" &&
226
+ typeof MutationObserver !== "undefined");
232
227
  }
233
228
  export function createBrowserToolset(options = {}) {
234
229
  if (!browserToolsAvailable()) {
@@ -236,19 +231,14 @@ export function createBrowserToolset(options = {}) {
236
231
  }
237
232
  const limits = {
238
233
  ...DEFAULT_EXECUTION_LIMITS,
239
- maxDurationMs: options.limits?.maxDurationMs
240
- ?? DEFAULT_EXECUTION_LIMITS.maxDurationMs,
241
- maxResultChars: options.limits?.maxResultChars
242
- ?? DEFAULT_EXECUTION_LIMITS.maxResultChars,
243
- singleActionTimeoutMs: options.limits?.singleActionTimeoutMs
244
- ?? DEFAULT_EXECUTION_LIMITS.singleActionTimeoutMs,
234
+ maxDurationMs: options.limits?.maxDurationMs ?? DEFAULT_EXECUTION_LIMITS.maxDurationMs,
235
+ maxResultChars: options.limits?.maxResultChars ?? DEFAULT_EXECUTION_LIMITS.maxResultChars,
236
+ singleActionTimeoutMs: options.limits?.singleActionTimeoutMs ?? DEFAULT_EXECUTION_LIMITS.singleActionTimeoutMs,
245
237
  };
246
238
  const snapshotLimits = {
247
239
  ...DEFAULT_SNAPSHOT_LIMITS,
248
- viewportMaxChars: options.snapshotLimits?.viewportMaxChars
249
- ?? DEFAULT_SNAPSHOT_LIMITS.viewportMaxChars,
250
- fullMaxChars: options.snapshotLimits?.fullMaxChars
251
- ?? DEFAULT_SNAPSHOT_LIMITS.fullMaxChars,
240
+ viewportMaxChars: options.snapshotLimits?.viewportMaxChars ?? DEFAULT_SNAPSHOT_LIMITS.viewportMaxChars,
241
+ fullMaxChars: options.snapshotLimits?.fullMaxChars ?? DEFAULT_SNAPSHOT_LIMITS.fullMaxChars,
252
242
  };
253
243
  const feedback = new ActionFeedback();
254
244
  const controller = new PageController(limits, feedback);
@@ -285,7 +275,8 @@ export function createBrowserToolset(options = {}) {
285
275
  const scope = normalizedInput.scope;
286
276
  const deadline = performance.now() + limits.maxDurationMs;
287
277
  signal.throwIfAborted();
288
- return (await observe(scope, { deadline, signal }, pageDecision ? "actions" : "text")).snapshot;
278
+ return (await observe(scope, { deadline, signal }, pageDecision ? "actions" : "text"))
279
+ .snapshot;
289
280
  },
290
281
  };
291
282
  const executeObserved = async (signal, execute, cancel, mode = "code", onFeedback, assertActive) => {
@@ -316,7 +307,8 @@ export function createBrowserToolset(options = {}) {
316
307
  }
317
308
  result = await measurePagePhase("execution", () => execute(activeRegistry, workerBudget));
318
309
  signal.throwIfAborted();
319
- if (result.error && ["EXECUTION_TIMEOUT", "WORKER_ERROR", "EXECUTION_OUTCOME_UNKNOWN"].includes(result.error.code)) {
310
+ if (result.error &&
311
+ ["EXECUTION_TIMEOUT", "WORKER_ERROR", "EXECUTION_OUTCOME_UNKNOWN"].includes(result.error.code)) {
320
312
  result.error.code = "EXECUTION_OUTCOME_UNKNOWN";
321
313
  }
322
314
  if (!result.ok && result.completedActions.length === 0) {
@@ -325,9 +317,7 @@ export function createBrowserToolset(options = {}) {
325
317
  try {
326
318
  const settled = await measurePagePhase("settle", () => tracker.waitForSettle({ deadline, signal }));
327
319
  signal.throwIfAborted();
328
- if (settled.timedOut
329
- && settled.urlChanged
330
- && !settled.mutationObservedAfterUrlChange) {
320
+ if (settled.timedOut && settled.urlChanged && !settled.mutationObservedAfterUrlChange) {
331
321
  result.snapshotUnavailable = true;
332
322
  return expireRefs(result);
333
323
  }
@@ -382,7 +372,9 @@ export function createBrowserToolset(options = {}) {
382
372
  if (!bundle || bundle.snapshot.snapshotId !== input.snapshotId)
383
373
  return undefined;
384
374
  const selected = bundle.actions?.get(input.actionId);
385
- if (!selected || selected.command.method === "scrollBy" || selected.command.method === "waitForTimeout")
375
+ if (!selected ||
376
+ selected.command.method === "scrollBy" ||
377
+ selected.command.method === "waitForTimeout")
386
378
  return undefined;
387
379
  const target = selected.command.target;
388
380
  const element = target?.type === "ref" ? bundle.registry.refs.get(target.ref)?.element : undefined;
@@ -396,14 +388,21 @@ export function createBrowserToolset(options = {}) {
396
388
  const selected = bundle.actions.get(input.actionId);
397
389
  if (!selected)
398
390
  throw new AgentToolError("INVALID_INPUT", "Action is not a candidate of this observation.");
399
- if (selected.command.method === "fill" ? typeof input.text !== "string" || !input.text.trim() : input.text !== undefined) {
391
+ if (selected.command.method === "fill"
392
+ ? typeof input.text !== "string" || !input.text.trim()
393
+ : input.text !== undefined) {
400
394
  throw new AgentToolError("INVALID_INPUT", "Only fill actions require a non-empty text value.");
401
395
  }
402
396
  if (selected.command.method === "selectOption") {
403
397
  const target = selected.command.target;
404
398
  const element = target.type === "ref" ? bundle.registry.refs.get(target.ref)?.element : undefined;
405
- const options = element instanceof HTMLSelectElement ? [...element.options].filter((option) => option.value === selected.command.args[0]) : [];
406
- if (options.length !== 1 || options[0].disabled || options[0].closest("optgroup[disabled]") || options[0].label.slice(0, 500) !== selected.candidate.option) {
399
+ const options = element instanceof HTMLSelectElement
400
+ ? [...element.options].filter((option) => option.value === selected.command.args[0])
401
+ : [];
402
+ if (options.length !== 1 ||
403
+ options[0].disabled ||
404
+ options[0].closest("optgroup[disabled]") ||
405
+ options[0].label.slice(0, 500) !== selected.candidate.option) {
407
406
  throw new AgentToolError("INVALID_INPUT", "The observed option changed or is no longer available. Observe again.");
408
407
  }
409
408
  }
@@ -413,7 +412,9 @@ export function createBrowserToolset(options = {}) {
413
412
  let timer;
414
413
  try {
415
414
  const command = {
416
- ...selected.command, executionId, commandSeq: 1,
415
+ ...selected.command,
416
+ executionId,
417
+ commandSeq: 1,
417
418
  args: selected.command.method === "fill" ? [input.text] : selected.command.args,
418
419
  };
419
420
  const response = await Promise.race([
@@ -421,7 +422,8 @@ export function createBrowserToolset(options = {}) {
421
422
  if (selected.optionElement) {
422
423
  const target = selected.command.target;
423
424
  const element = target.type === "ref" ? registry.refs.get(target.ref)?.element : undefined;
424
- if (!selected.optionElement.isConnected || selected.optionElement.closest("select") !== element) {
425
+ if (!selected.optionElement.isConnected ||
426
+ selected.optionElement.closest("select") !== element) {
425
427
  throw new AgentToolError("INVALID_INPUT", "The observed option was replaced. Observe again.");
426
428
  }
427
429
  }
@@ -434,7 +436,12 @@ export function createBrowserToolset(options = {}) {
434
436
  }),
435
437
  ]);
436
438
  const receipt = controller.completeExecution(executionId);
437
- return { executionId, ...receipt, ok: response.ok, ...(response.error ? { error: response.error } : {}) };
439
+ return {
440
+ executionId,
441
+ ...receipt,
442
+ ok: response.ok,
443
+ ...(response.error ? { error: response.error } : {}),
444
+ };
438
445
  }
439
446
  finally {
440
447
  clearTimeout(timer);
@@ -449,4 +456,3 @@ export function createBrowserToolset(options = {}) {
449
456
  handlers: new Map(toolHandlers.map((tool) => [tool.definition.name, tool])),
450
457
  };
451
458
  }
452
- //# sourceMappingURL=toolset.js.map
@@ -1,6 +1,6 @@
1
1
  import type { ObservedAction } from "./actions.js";
2
2
  import type { PageSnapshot } from "../shared/page-protocol.js";
3
- export type { SnapshotScope, SnapshotFormat, SemanticState, PageActionCandidate, PageSnapshot } from "../shared/page-protocol.js";
3
+ export type { SnapshotScope, SnapshotFormat, SemanticState, PageActionCandidate, PageSnapshot, } from "../shared/page-protocol.js";
4
4
  export interface RefTarget {
5
5
  element: Element;
6
6
  identity: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -397,4 +397,3 @@ export class WorkerRunner {
397
397
  active.cancel();
398
398
  }
399
399
  }
400
- //# sourceMappingURL=worker-runner.js.map
@@ -8,7 +8,5 @@ export declare function isValidAgentContextName(name: string): boolean;
8
8
  export declare function defineAgentTool<TResult = unknown>(metadata: AgentToolMetadataInput): AgentToolDefinition<Record<string, never>, TResult>;
9
9
  export declare function defineAgentTool<TInput = never, TResult = unknown, const TSchema extends AgentToolInputSchema = AgentToolInputSchema>(metadata: AgentToolMetadataInput & {
10
10
  inputSchema: TSchema;
11
- }): AgentToolDefinition<[
12
- TInput
13
- ] extends [never] ? InferJsonSchema<TSchema> : TInput, TResult>;
11
+ }): AgentToolDefinition<[TInput] extends [never] ? InferJsonSchema<TSchema> : TInput, TResult>;
14
12
  export {};
@@ -6,7 +6,8 @@ const emptyInputSchema = Object.freeze({
6
6
  });
7
7
  const agentNamePattern = /^[A-Za-z0-9_-]{1,64}$/;
8
8
  const reservedContextNames = new Set([
9
- "nxf_applyAction", "nxf_delegatePageTask",
9
+ "nxf_applyAction",
10
+ "nxf_delegatePageTask",
10
11
  "nxf_callAppTool",
11
12
  "nxf_finish",
12
13
  "nxf_getSnapshot",
@@ -33,4 +34,3 @@ export function defineAgentTool(metadata) {
33
34
  inputSchema: metadata.inputSchema === undefined ? emptyInputSchema : metadata.inputSchema,
34
35
  });
35
36
  }
36
- //# sourceMappingURL=definition.js.map
@@ -1,4 +1,3 @@
1
1
  import "./styles.css";
2
2
  export * from "./index.js";
3
3
  export { registerAgentTool } from "./registration.js";
4
- //# sourceMappingURL=index.browser.js.map
package/dist/index.js CHANGED
@@ -4,4 +4,3 @@ export { AgentOperationSurface } from "./operation-surface.js";
4
4
  export { createToolRuntime, isToolRuntimeError, } from "./runtime.js";
5
5
  export { AgentContext, ToolsProvider, AgentUIAction, useAgentContext, useAgentNavigation, useAgentTool, } from "./react.js";
6
6
  export { registerAgentTool } from "./registration.js";
7
- //# sourceMappingURL=index.js.map
@@ -3,7 +3,7 @@ import { type ToolRuntime, type InternalToolRuntime } from "./runtime.js";
3
3
  export interface InternalToolRuntimeHostProps {
4
4
  children: ReactNode;
5
5
  }
6
- export declare function InternalToolRuntimeHost({ children, }: InternalToolRuntimeHostProps): ReactElement;
6
+ export declare function InternalToolRuntimeHost({ children }: InternalToolRuntimeHostProps): ReactElement;
7
7
  export declare function InternalToolRuntimeScope({ children, runtime, }: {
8
8
  children: ReactNode;
9
9
  runtime: ToolRuntime;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
- import { createContext, useContext, useMemo, } from "react";
2
+ import { createContext, useContext, useMemo } from "react";
3
3
  import { createToolRuntime, getInternalToolRuntime, } from "./runtime.js";
4
4
  const InternalToolRuntimeContext = createContext(null);
5
- export function InternalToolRuntimeHost({ children, }) {
5
+ export function InternalToolRuntimeHost({ children }) {
6
6
  const runtime = useMemo(() => createToolRuntime(), []);
7
- return (React.createElement(InternalToolRuntimeScope, { runtime: runtime }, children));
7
+ return React.createElement(InternalToolRuntimeScope, { runtime: runtime }, children);
8
8
  }
9
9
  export function InternalToolRuntimeScope({ children, runtime, }) {
10
10
  const internalRuntime = getInternalToolRuntime(runtime);
@@ -20,4 +20,3 @@ export function useInternalToolRuntime() {
20
20
  export function useOptionalInternalToolRuntime() {
21
21
  return useContext(InternalToolRuntimeContext);
22
22
  }
23
- //# sourceMappingURL=internal-react.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=internal-types.js.map
@@ -37,4 +37,3 @@ export function getAgentNavigationEntries(navigation) {
37
37
  }
38
38
  return entries;
39
39
  }
40
- //# sourceMappingURL=navigation.js.map
@@ -30,7 +30,42 @@ export function lockOperationSurface(surface, redirectFocus) {
30
30
  event.stopImmediatePropagation();
31
31
  };
32
32
  // Wheel and touch defaults are blocked here: React delegates them passively.
33
- const events = ["focus", "focusin", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "pointerdown", "pointerup", "pointermove", "pointerover", "pointerout", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "click", "dblclick", "auxclick", "contextmenu", "keydown", "keyup", "beforeinput", "paste", "cut", "drop", "dragstart", "touchstart", "touchmove", "touchend", "touchcancel", "wheel", "submit", "reset"];
33
+ const events = [
34
+ "focus",
35
+ "focusin",
36
+ "mouseenter",
37
+ "mouseleave",
38
+ "pointerenter",
39
+ "pointerleave",
40
+ "pointerdown",
41
+ "pointerup",
42
+ "pointermove",
43
+ "pointerover",
44
+ "pointerout",
45
+ "mousedown",
46
+ "mouseup",
47
+ "mousemove",
48
+ "mouseover",
49
+ "mouseout",
50
+ "click",
51
+ "dblclick",
52
+ "auxclick",
53
+ "contextmenu",
54
+ "keydown",
55
+ "keyup",
56
+ "beforeinput",
57
+ "paste",
58
+ "cut",
59
+ "drop",
60
+ "dragstart",
61
+ "touchstart",
62
+ "touchmove",
63
+ "touchend",
64
+ "touchcancel",
65
+ "wheel",
66
+ "submit",
67
+ "reset",
68
+ ];
34
69
  lockedSurfaces.add(surface);
35
70
  surface.setAttribute("aria-busy", "true");
36
71
  for (const name of events)
@@ -45,4 +80,3 @@ export function lockOperationSurface(surface, redirectFocus) {
45
80
  surface.setAttribute("aria-busy", previousBusy);
46
81
  };
47
82
  }
48
- //# sourceMappingURL=operation-lock.js.map
@@ -4,17 +4,24 @@ export class OperationTracker {
4
4
  #unscoped = 0;
5
5
  #executions = new Map();
6
6
  #listeners = new Set();
7
- #snapshot = Object.freeze({ operation: null, executions: Object.freeze([]) });
7
+ #snapshot = Object.freeze({
8
+ operation: null,
9
+ executions: Object.freeze([]),
10
+ });
8
11
  getSnapshot = () => this.#snapshot;
9
12
  subscribe = (listener) => {
10
13
  this.#listeners.add(listener);
11
- return () => { this.#listeners.delete(listener); };
14
+ return () => {
15
+ this.#listeners.delete(listener);
16
+ };
12
17
  };
13
18
  begin(options = {}) {
14
19
  options.signal?.throwIfAborted();
15
20
  const previous = this.#operation;
16
- const replacing = previous && previous.handle === options.replaceWaiting
17
- && previous.snapshot.status === "waiting" && previous.pending === 0;
21
+ const replacing = previous &&
22
+ previous.handle === options.replaceWaiting &&
23
+ previous.snapshot.status === "waiting" &&
24
+ previous.pending === 0;
18
25
  if (this.#unscoped || (previous && !replacing)) {
19
26
  throw new AgentToolError("OPERATION_BUSY", "The Runtime already has an operation or outstanding tool calls.");
20
27
  }
@@ -23,11 +30,22 @@ export class OperationTracker {
23
30
  previous.resolveEnd();
24
31
  }
25
32
  let resolveEnd;
26
- const endPromise = new Promise((resolve) => { resolveEnd = resolve; });
33
+ const endPromise = new Promise((resolve) => {
34
+ resolveEnd = resolve;
35
+ });
27
36
  const id = globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
28
37
  const operation = {
29
- snapshot: Object.freeze({ id, source: options.source ?? "host", status: "running", hasExecuted: false, canCancel: Boolean(options.onCancel), ...(options.taskProgress ? { taskProgress: Object.freeze(options.taskProgress) } : {}) }),
30
- handle: undefined, pending: 0, resolveEnd,
38
+ snapshot: Object.freeze({
39
+ id,
40
+ source: options.source ?? "host",
41
+ status: "running",
42
+ hasExecuted: false,
43
+ canCancel: Boolean(options.onCancel),
44
+ ...(options.taskProgress ? { taskProgress: Object.freeze(options.taskProgress) } : {}),
45
+ }),
46
+ handle: undefined,
47
+ pending: 0,
48
+ resolveEnd,
31
49
  ...(options.onCancel ? { onCancel: options.onCancel } : {}),
32
50
  removeAbort: () => options.signal?.removeEventListener("abort", onAbort),
33
51
  };
@@ -42,7 +60,11 @@ export class OperationTracker {
42
60
  if (this.#operation !== operation || operation.snapshot.status === "ending")
43
61
  return endPromise;
44
62
  operation.removeAbort();
45
- operation.snapshot = Object.freeze({ ...operation.snapshot, status: "ending", outcome: endOptions?.outcome ?? "completed" });
63
+ operation.snapshot = Object.freeze({
64
+ ...operation.snapshot,
65
+ status: "ending",
66
+ outcome: endOptions?.outcome ?? "completed",
67
+ });
46
68
  this.#publish();
47
69
  if (this.#finish(operation))
48
70
  this.#publish();
@@ -77,8 +99,11 @@ export class OperationTracker {
77
99
  }
78
100
  requestCancel(id) {
79
101
  const operation = this.#operation;
80
- if (!operation || operation.snapshot.id !== id || !operation.onCancel
81
- || operation.snapshot.status === "ending" || operation.snapshot.status === "cancelling")
102
+ if (!operation ||
103
+ operation.snapshot.id !== id ||
104
+ !operation.onCancel ||
105
+ operation.snapshot.status === "ending" ||
106
+ operation.snapshot.status === "cancelling")
82
107
  return;
83
108
  const previous = operation.snapshot.status;
84
109
  this.#update(operation, { status: "cancelling" });
@@ -123,7 +148,9 @@ export class OperationTracker {
123
148
  if (event.status === "running") {
124
149
  this.#executions.set(event.id, event);
125
150
  const operation = this.#operation;
126
- if (operation && event.operationId === operation.snapshot.id && !operation.snapshot.hasExecuted) {
151
+ if (operation &&
152
+ event.operationId === operation.snapshot.id &&
153
+ !operation.snapshot.hasExecuted) {
127
154
  operation.snapshot = Object.freeze({ ...operation.snapshot, hasExecuted: true });
128
155
  }
129
156
  }
@@ -132,7 +159,9 @@ export class OperationTracker {
132
159
  this.#publish();
133
160
  }
134
161
  #finish(operation) {
135
- if (operation.pending || operation.snapshot.status !== "ending" || this.#operation !== operation)
162
+ if (operation.pending ||
163
+ operation.snapshot.status !== "ending" ||
164
+ this.#operation !== operation)
136
165
  return false;
137
166
  this.#operation = undefined;
138
167
  operation.resolveEnd();
@@ -151,4 +180,3 @@ export class OperationTracker {
151
180
  listener();
152
181
  }
153
182
  }
154
- //# sourceMappingURL=operation-runtime.js.map