@leitwerk-dev/watcher-utils 0.1.9 → 0.2.1

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 (49) hide show
  1. package/dist/{chunk-XF2QQLPO.js → chunk-BO52GPAV.js} +22 -11
  2. package/dist/chunk-BO52GPAV.js.map +1 -0
  3. package/dist/{chunk-IU3L35PC.js → chunk-D57H46H7.js} +1 -1
  4. package/dist/chunk-D57H46H7.js.map +1 -0
  5. package/dist/{chunk-3KGAUQIG.js → chunk-EWA6E2ZM.js} +1 -1
  6. package/dist/chunk-EWA6E2ZM.js.map +1 -0
  7. package/dist/chunk-ZW3LXDBX.js +46 -0
  8. package/dist/chunk-ZW3LXDBX.js.map +1 -0
  9. package/dist/duration-parse.d.ts +2 -0
  10. package/dist/duration-parse.d.ts.map +1 -1
  11. package/dist/duration-parse.js +6 -15
  12. package/dist/duration-parse.js.map +1 -1
  13. package/dist/index.d.ts +3 -4
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +48 -5
  16. package/dist/index.js.map +1 -1
  17. package/dist/poll-loop.d.ts +30 -3
  18. package/dist/poll-loop.d.ts.map +1 -1
  19. package/dist/poll-loop.js +11 -58
  20. package/dist/poll-loop.js.map +1 -1
  21. package/dist/polling-coordinator.d.ts +38 -0
  22. package/dist/polling-coordinator.d.ts.map +1 -0
  23. package/dist/polling-coordinator.js +9 -0
  24. package/dist/polling-coordinator.js.map +1 -0
  25. package/dist/process-helpers.d.ts +15 -0
  26. package/dist/process-helpers.d.ts.map +1 -1
  27. package/dist/process-helpers.js +10 -32
  28. package/dist/process-helpers.js.map +1 -1
  29. package/dist/trigger-files.d.ts +7 -0
  30. package/dist/trigger-files.d.ts.map +1 -1
  31. package/dist/watcher-coordinator.d.ts +77 -2
  32. package/dist/watcher-coordinator.d.ts.map +1 -1
  33. package/dist/watcher-coordinator.js +142 -114
  34. package/dist/watcher-coordinator.js.map +1 -1
  35. package/package.json +5 -5
  36. package/src/duration-parse.ts +5 -1
  37. package/src/index.ts +2 -30
  38. package/src/poll-loop.ts +50 -12
  39. package/src/polling-coordinator.ts +83 -0
  40. package/src/process-helpers.ts +30 -3
  41. package/src/trigger-files.ts +15 -1
  42. package/src/watcher-coordinator.ts +99 -11
  43. package/dist/chunk-3KGAUQIG.js.map +0 -1
  44. package/dist/chunk-IU3L35PC.js.map +0 -1
  45. package/dist/chunk-XF2QQLPO.js.map +0 -1
  46. package/dist/chunk-XLVMFO6W.js +0 -160
  47. package/dist/chunk-XLVMFO6W.js.map +0 -1
  48. package/dist/trigger-files.js +0 -31
  49. package/dist/trigger-files.js.map +0 -1
@@ -1,160 +0,0 @@
1
- import {
2
- ensureWorkerForActiveAgent,
3
- hasProcessEvent,
4
- processNeedsWorker
5
- } from "./chunk-3KGAUQIG.js";
6
-
7
- // src/watcher-coordinator.ts
8
- import {
9
- recordWriteIfMissing
10
- } from "@leitwerk-dev/external-writes";
11
- function requireWatcherStartTurnId(launchPlan, targetLabel) {
12
- if (launchPlan.startTurnId) {
13
- return launchPlan.startTurnId;
14
- }
15
- throw new Error(
16
- `Watcher launcher '${launchPlan.launcherId}' did not declare a startTurnId for ${targetLabel}`
17
- );
18
- }
19
- async function continueWatcherAgentStartup(deps, opts) {
20
- const { process } = opts;
21
- if (!hasProcessEvent(deps.events, process.id, "agent_created")) {
22
- deps.events.create({
23
- instanceId: process.id,
24
- eventType: "agent_created",
25
- data: opts.createdEventData
26
- });
27
- }
28
- await opts.afterCreatedEvent?.(process);
29
- await opts.beforeStart?.(process);
30
- let currentProcess = deps.processes.getById(process.id) ?? process;
31
- if (currentProcess.lifecycleStatus === "discovered") {
32
- const startResult = await deps.commands.startProcess(currentProcess.id, opts.startTurnId);
33
- if (!startResult.ok) {
34
- currentProcess = startResult.process ?? currentProcess;
35
- throw new Error(startResult.message ?? "Failed to start process");
36
- }
37
- currentProcess = startResult.process ?? currentProcess;
38
- if (opts.broadcastCreated !== false) {
39
- deps.broadcaster.sendDurable(
40
- "process.created",
41
- {
42
- process: currentProcess,
43
- processId: currentProcess.processId,
44
- ...opts.createdBroadcastData
45
- },
46
- currentProcess.id
47
- );
48
- }
49
- }
50
- await ensureWorkerForActiveAgent(deps, currentProcess);
51
- return currentProcess.id;
52
- }
53
- async function runWatcherDiscoveryPass(opts) {
54
- for (const item of opts.items) {
55
- try {
56
- const existingAgent = opts.findExistingAgent(item);
57
- if (existingAgent) {
58
- if (existingAgent.lifecycleStatus === "discovered") {
59
- const resumeResult = await opts.resumeDiscoveredAgent(existingAgent, item);
60
- if (resumeResult === "skipped") {
61
- opts.result.skipped.push(opts.getResultLabel(item));
62
- }
63
- continue;
64
- }
65
- if (opts.ensureWorkerForExistingAgent) {
66
- const handled = await opts.ensureWorkerForExistingAgent(existingAgent, item);
67
- if (handled) {
68
- continue;
69
- }
70
- }
71
- opts.result.skipped.push(opts.getResultLabel(item));
72
- continue;
73
- }
74
- const createResult = await opts.createAgent(item);
75
- if (createResult?.outcome === "created") {
76
- opts.result.created.push(opts.getResultLabel(item));
77
- continue;
78
- }
79
- if (createResult?.outcome === "skipped") {
80
- opts.result.skipped.push(opts.getResultLabel(item));
81
- }
82
- } catch (error) {
83
- opts.result.errors.push(opts.formatError(item, error));
84
- }
85
- }
86
- }
87
- async function runWatcherAbortReconciliation(opts) {
88
- for (const process of opts.candidates) {
89
- try {
90
- const shouldAbort = await opts.shouldAbort(process);
91
- if (!shouldAbort) {
92
- continue;
93
- }
94
- const abortResult = await opts.commands.abortProcess(process.id);
95
- if (!abortResult.ok) {
96
- if (abortResult.code === "worker_reconcile_failed") {
97
- throw new Error(abortResult.message ?? "Failed to abort process");
98
- }
99
- continue;
100
- }
101
- const abortedAgent = abortResult.process ?? process;
102
- if (!hasProcessEvent(opts.events, abortedAgent.id, "aborted_label_removed")) {
103
- opts.events.create({
104
- instanceId: abortedAgent.id,
105
- eventType: "aborted_label_removed",
106
- data: opts.getAbortedEventData(abortedAgent)
107
- });
108
- }
109
- opts.result.aborted.push(opts.getResultLabel(process));
110
- } catch (error) {
111
- opts.result.errors.push(
112
- `${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`
113
- );
114
- }
115
- }
116
- }
117
- async function runWatcherCompletionReconciliation(opts) {
118
- for (const process of opts.candidates) {
119
- try {
120
- const reconciliation = await opts.reconcile(process);
121
- if (!reconciliation.changed) {
122
- continue;
123
- }
124
- if (reconciliation.writeIdentity) {
125
- recordWriteIfMissing(
126
- opts.externalWrites,
127
- process.id,
128
- reconciliation.writeIdentity,
129
- reconciliation.metadata
130
- );
131
- }
132
- opts.result.labelExchanged.push(opts.getResultLabel(process));
133
- } catch (error) {
134
- opts.result.errors.push(
135
- `${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`
136
- );
137
- }
138
- }
139
- }
140
- function shouldEnsureWorkerForExistingActiveAgent(deps, process) {
141
- return processNeedsWorker(process) && !deps.supervisor.getWorker(process.id);
142
- }
143
- function deferWatcherLaunchStart(launchPlan) {
144
- return launchPlan.startTurnId === null ? launchPlan : { ...launchPlan, startTurnId: null };
145
- }
146
- function launchFailureMessage(result) {
147
- return typeof result.body.error === "string" && result.body.error.trim().length > 0 ? result.body.error : `Process launch failed with status ${result.status}`;
148
- }
149
-
150
- export {
151
- requireWatcherStartTurnId,
152
- continueWatcherAgentStartup,
153
- runWatcherDiscoveryPass,
154
- runWatcherAbortReconciliation,
155
- runWatcherCompletionReconciliation,
156
- shouldEnsureWorkerForExistingActiveAgent,
157
- deferWatcherLaunchStart,
158
- launchFailureMessage
159
- };
160
- //# sourceMappingURL=chunk-XLVMFO6W.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/watcher-coordinator.ts"],"sourcesContent":["import type { ProcessInstance, TurnId } from \"@leitwerk-dev/domain\";\nimport {\n\ttype ExternalWriteLogRepoLike,\n\trecordWriteIfMissing,\n\ttype WriteIdentity,\n} from \"@leitwerk-dev/external-writes\";\nimport type { KnownDurableWsFrameType, WsPayloadByType } from \"@leitwerk-dev/protocol\";\nimport type { PollResult } from \"./poll-loop.js\";\nimport {\n\tensureWorkerForActiveAgent,\n\thasProcessEvent,\n\ttype ProcessEventRepoLike,\n\tprocessNeedsWorker,\n\ttype WorkerSupervisorLike,\n} from \"./process-helpers.js\";\n\nexport interface AgentRepoAccessorLike {\n\tgetById(id: string): ProcessInstance | null;\n}\n\nexport interface BroadcasterLike {\n\tsendDurable<T extends KnownDurableWsFrameType>(\n\t\ttype: T,\n\t\tpayload: WsPayloadByType[T],\n\t\tinstanceId?: string,\n\t): void;\n}\n\nexport interface WatcherCommandResult {\n\tok: boolean;\n\tcode?: string;\n\tmessage?: string;\n\tprocess?: ProcessInstance | null;\n}\n\nexport interface WatcherCommandServiceLike {\n\tstartProcess(instanceId: string, startTurnId: TurnId): Promise<WatcherCommandResult>;\n\tabortProcess(instanceId: string): Promise<WatcherCommandResult>;\n}\n\nexport interface WatcherStartupDeps {\n\tprocesses: AgentRepoAccessorLike;\n\tevents: ProcessEventRepoLike;\n\tbroadcaster: BroadcasterLike;\n\tcommands: WatcherCommandServiceLike;\n\tsupervisor: WorkerSupervisorLike;\n}\n\nexport interface ContinueWatcherAgentStartupOptions {\n\tprocess: ProcessInstance;\n\tstartTurnId: TurnId;\n\tcreatedEventData: Record<string, unknown>;\n\tcreatedBroadcastData: Record<string, unknown>;\n\t/** Defaults to true. Set false when the shared launch executor already emitted process.created. */\n\tbroadcastCreated?: boolean;\n\tafterCreatedEvent?: (process: ProcessInstance) => Promise<void> | void;\n\tbeforeStart?: (process: ProcessInstance) => Promise<void>;\n}\n\nexport function requireWatcherStartTurnId(\n\tlaunchPlan: { launcherId: string; startTurnId: TurnId | null },\n\ttargetLabel: string,\n): TurnId {\n\tif (launchPlan.startTurnId) {\n\t\treturn launchPlan.startTurnId;\n\t}\n\tthrow new Error(\n\t\t`Watcher launcher '${launchPlan.launcherId}' did not declare a startTurnId for ${targetLabel}`,\n\t);\n}\n\nexport async function continueWatcherAgentStartup(\n\tdeps: WatcherStartupDeps,\n\topts: ContinueWatcherAgentStartupOptions,\n): Promise<string> {\n\tconst { process } = opts;\n\n\tif (!hasProcessEvent(deps.events, process.id, \"agent_created\")) {\n\t\tdeps.events.create({\n\t\t\tinstanceId: process.id,\n\t\t\teventType: \"agent_created\",\n\t\t\tdata: opts.createdEventData,\n\t\t});\n\t}\n\n\tawait opts.afterCreatedEvent?.(process);\n\tawait opts.beforeStart?.(process);\n\n\tlet currentProcess = deps.processes.getById(process.id) ?? process;\n\tif (currentProcess.lifecycleStatus === \"discovered\") {\n\t\tconst startResult = await deps.commands.startProcess(currentProcess.id, opts.startTurnId);\n\t\tif (!startResult.ok) {\n\t\t\tcurrentProcess = startResult.process ?? currentProcess;\n\t\t\tthrow new Error(startResult.message ?? \"Failed to start process\");\n\t\t}\n\t\tcurrentProcess = startResult.process ?? currentProcess;\n\t\tif (opts.broadcastCreated !== false) {\n\t\t\tdeps.broadcaster.sendDurable(\n\t\t\t\t\"process.created\",\n\t\t\t\t{\n\t\t\t\t\tprocess: currentProcess,\n\t\t\t\t\tprocessId: currentProcess.processId,\n\t\t\t\t\t...opts.createdBroadcastData,\n\t\t\t\t},\n\t\t\t\tcurrentProcess.id,\n\t\t\t);\n\t\t}\n\t}\n\n\tawait ensureWorkerForActiveAgent(deps, currentProcess);\n\treturn currentProcess.id;\n}\n\nexport type DiscoveryResumeResult = \"handled\" | \"skipped\" | undefined;\n\nexport type DiscoveryCreateResult =\n\t| { outcome: \"created\"; instanceId: string }\n\t| { outcome: \"skipped\" }\n\t| { outcome: \"handled\" }\n\t| null\n\t| undefined;\n\nexport interface DiscoveryPassOptions<TItem> {\n\titems: readonly TItem[];\n\tresult: PollResult;\n\tfindExistingAgent(item: TItem): ProcessInstance | null;\n\tgetResultLabel(item: TItem): string;\n\tresumeDiscoveredAgent(process: ProcessInstance, item: TItem): Promise<DiscoveryResumeResult>;\n\tcreateAgent(item: TItem): Promise<DiscoveryCreateResult>;\n\tensureWorkerForExistingAgent?(process: ProcessInstance, item: TItem): Promise<boolean>;\n\tformatError(item: TItem, error: unknown): string;\n}\n\nexport async function runWatcherDiscoveryPass<TItem>(\n\topts: DiscoveryPassOptions<TItem>,\n): Promise<void> {\n\tfor (const item of opts.items) {\n\t\ttry {\n\t\t\tconst existingAgent = opts.findExistingAgent(item);\n\t\t\tif (existingAgent) {\n\t\t\t\tif (existingAgent.lifecycleStatus === \"discovered\") {\n\t\t\t\t\tconst resumeResult = await opts.resumeDiscoveredAgent(existingAgent, item);\n\t\t\t\t\tif (resumeResult === \"skipped\") {\n\t\t\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (opts.ensureWorkerForExistingAgent) {\n\t\t\t\t\tconst handled = await opts.ensureWorkerForExistingAgent(existingAgent, item);\n\t\t\t\t\tif (handled) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst createResult = await opts.createAgent(item);\n\t\t\tif (createResult?.outcome === \"created\") {\n\t\t\t\topts.result.created.push(opts.getResultLabel(item));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (createResult?.outcome === \"skipped\") {\n\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t}\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(opts.formatError(item, error));\n\t\t}\n\t}\n}\n\nexport interface AbortReconciliationOptions {\n\tcandidates: readonly ProcessInstance[];\n\tresult: PollResult;\n\tevents: ProcessEventRepoLike;\n\tcommands: WatcherCommandServiceLike;\n\tshouldAbort(process: ProcessInstance): Promise<boolean>;\n\tgetResultLabel(process: ProcessInstance): string;\n\tgetErrorLabel(process: ProcessInstance): string;\n\tgetAbortedEventData(process: ProcessInstance): Record<string, unknown>;\n}\n\nexport async function runWatcherAbortReconciliation(\n\topts: AbortReconciliationOptions,\n): Promise<void> {\n\tfor (const process of opts.candidates) {\n\t\ttry {\n\t\t\tconst shouldAbort = await opts.shouldAbort(process);\n\t\t\tif (!shouldAbort) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst abortResult = await opts.commands.abortProcess(process.id);\n\t\t\tif (!abortResult.ok) {\n\t\t\t\tif (abortResult.code === \"worker_reconcile_failed\") {\n\t\t\t\t\tthrow new Error(abortResult.message ?? \"Failed to abort process\");\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst abortedAgent = abortResult.process ?? process;\n\t\t\tif (!hasProcessEvent(opts.events, abortedAgent.id, \"aborted_label_removed\")) {\n\t\t\t\topts.events.create({\n\t\t\t\t\tinstanceId: abortedAgent.id,\n\t\t\t\t\teventType: \"aborted_label_removed\",\n\t\t\t\t\tdata: opts.getAbortedEventData(abortedAgent),\n\t\t\t\t});\n\t\t\t}\n\t\t\topts.result.aborted.push(opts.getResultLabel(process));\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(\n\t\t\t\t`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport interface CompletionReconciliationResult {\n\tchanged: boolean;\n\twriteIdentity?: WriteIdentity;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface CompletionReconciliationOptions {\n\tcandidates: readonly ProcessInstance[];\n\tresult: PollResult;\n\texternalWrites: ExternalWriteLogRepoLike;\n\treconcile(process: ProcessInstance): Promise<CompletionReconciliationResult>;\n\tgetResultLabel(process: ProcessInstance): string;\n\tgetErrorLabel(process: ProcessInstance): string;\n}\n\nexport async function runWatcherCompletionReconciliation(\n\topts: CompletionReconciliationOptions,\n): Promise<void> {\n\tfor (const process of opts.candidates) {\n\t\ttry {\n\t\t\tconst reconciliation = await opts.reconcile(process);\n\t\t\tif (!reconciliation.changed) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (reconciliation.writeIdentity) {\n\t\t\t\trecordWriteIfMissing(\n\t\t\t\t\topts.externalWrites,\n\t\t\t\t\tprocess.id,\n\t\t\t\t\treconciliation.writeIdentity,\n\t\t\t\t\treconciliation.metadata,\n\t\t\t\t);\n\t\t\t}\n\t\t\topts.result.labelExchanged.push(opts.getResultLabel(process));\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(\n\t\t\t\t`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function shouldEnsureWorkerForExistingActiveAgent(\n\tdeps: { supervisor: WorkerSupervisorLike },\n\tprocess: ProcessInstance,\n): boolean {\n\treturn processNeedsWorker(process) && !deps.supervisor.getWorker(process.id);\n}\n\nexport function deferWatcherLaunchStart<TLaunchPlan extends { startTurnId: unknown }>(\n\tlaunchPlan: TLaunchPlan,\n): TLaunchPlan {\n\treturn launchPlan.startTurnId === null ? launchPlan : { ...launchPlan, startTurnId: null };\n}\n\nexport function launchFailureMessage(result: {\n\tstatus: number;\n\tbody: Record<string, unknown>;\n}): string {\n\treturn typeof result.body.error === \"string\" && result.body.error.trim().length > 0\n\t\t? result.body.error\n\t\t: `Process launch failed with status ${result.status}`;\n}\n"],"mappings":";;;;;;;AACA;AAAA,EAEC;AAAA,OAEM;AAsDA,SAAS,0BACf,YACA,aACS;AACT,MAAI,WAAW,aAAa;AAC3B,WAAO,WAAW;AAAA,EACnB;AACA,QAAM,IAAI;AAAA,IACT,qBAAqB,WAAW,UAAU,uCAAuC,WAAW;AAAA,EAC7F;AACD;AAEA,eAAsB,4BACrB,MACA,MACkB;AAClB,QAAM,EAAE,QAAQ,IAAI;AAEpB,MAAI,CAAC,gBAAgB,KAAK,QAAQ,QAAQ,IAAI,eAAe,GAAG;AAC/D,SAAK,OAAO,OAAO;AAAA,MAClB,YAAY,QAAQ;AAAA,MACpB,WAAW;AAAA,MACX,MAAM,KAAK;AAAA,IACZ,CAAC;AAAA,EACF;A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UAAI,eAAe,eAAe;AACjC;AAAA,UACC,KAAK;AAAA,UACL,QAAQ;AAAA,UACR,eAAe;AAAA,UACf,eAAe;AAAA,QAChB;AAAA,MACD;AACA,WAAK,OAAO,eAAe,KAAK,KAAK,eAAe,OAAO,CAAC;AAAA,IAC7D,SAAS,OAAO;AACf,WAAK,OAAO,OAAO;AAAA,QAClB,GAAG,KAAK,cAAc,OAAO,CAAC,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MAC1F;AAAA,IACD;AAAA,EACD;AACD;AAEO,SAAS,yCACf,MACA,SACU;AACV,SAAO,mBAAmB,OAAO,KAAK,CAAC,KAAK,WAAW,UAAU,QAAQ,EAAE;AAC5E;AAEO,SAAS,wBACf,YACc;AACd,SAAO,WAAW,gBAAgB,OAAO,aAAa,EAAE,GAAG,YAAY,aAAa,KAAK;AAC1F;AAEO,SAAS,qBAAqB,QAG1B;AACV,SAAO,OAAO,OAAO,KAAK,UAAU,YAAY,OAAO,KAAK,MAAM,KAAK,EAAE,SAAS,IAC/E,OAAO,KAAK,QACZ,qCAAqC,OAAO,MAAM;AACtD;","names":[]}
@@ -1,31 +0,0 @@
1
- import { readFile, unlink } from "node:fs/promises";
2
- export function errorCode(error) {
3
- if (typeof error !== "object" || error === null || !("code" in error)) {
4
- return null;
5
- }
6
- const code = error.code;
7
- return typeof code === "string" ? code : null;
8
- }
9
- export async function readTriggerFile(filePath) {
10
- try {
11
- return { exists: true, content: await readFile(filePath, "utf8") };
12
- }
13
- catch (error) {
14
- if (errorCode(error) === "ENOENT") {
15
- return { exists: false };
16
- }
17
- throw error;
18
- }
19
- }
20
- export async function consumeTriggerFile(filePath) {
21
- try {
22
- await unlink(filePath);
23
- }
24
- catch (error) {
25
- if (errorCode(error) === "ENOENT") {
26
- return;
27
- }
28
- throw error;
29
- }
30
- }
31
- //# sourceMappingURL=trigger-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger-files.js","sourceRoot":"","sources":["../src/trigger-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,UAAU,SAAS,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;IAChD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB;IACrD,IAAI,CAAC;QACJ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IACxD,IAAI,CAAC;QACJ,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO;QACR,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}