@automagik/omni 2.260915.17 → 2.260915.19
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Supervised pull connector config (issue #1186).
|
|
2
|
+
--
|
|
3
|
+
-- A webhook source with a poll config is polled by the API: its command runs
|
|
4
|
+
-- on an interval and each JSON stdout line is ingested as an event. The column
|
|
5
|
+
-- holds both the config and the scheduler state (next run, backoff, last run):
|
|
6
|
+
--
|
|
7
|
+
-- webhook_sources.poll_config jsonb, NULL = push-only source.
|
|
8
|
+
--
|
|
9
|
+
-- Hand-written following the 0043/0044/0052 precedent (additive, idempotent).
|
|
10
|
+
-- No explicit BEGIN/COMMIT — the boot migrator executes this file on a pooled
|
|
11
|
+
-- postgres-js connection, which rejects raw transaction control.
|
|
12
|
+
|
|
13
|
+
ALTER TABLE "webhook_sources"
|
|
14
|
+
ADD COLUMN IF NOT EXISTS "poll_config" jsonb;
|
|
@@ -512,6 +512,13 @@
|
|
|
512
512
|
"when": 1787200000000,
|
|
513
513
|
"tag": "0072_shared_durable_consumers",
|
|
514
514
|
"breakpoints": true
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"idx": 73,
|
|
518
|
+
"version": "7",
|
|
519
|
+
"when": 1787300000000,
|
|
520
|
+
"tag": "0073_webhook_poll_config",
|
|
521
|
+
"breakpoints": true
|
|
515
522
|
}
|
|
516
523
|
]
|
|
517
524
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automations.d.ts","sourceRoot":"","sources":["../../src/commands/automations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAc,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,KAAK,MAAM,GAAG,oBAAoB,CAAC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,MAAM,EAAE,GAAG,SAAS,CA4BlE;AAQD;;;GAGG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAkBlF;AAED,uFAAuF;AACvF,iBAAS,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,oBAAoB,CASrE;AAID;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAUrE;AAqBD,eAAO,MAAM,WAAW;;;;;;CAA2F,CAAC;AAMpH,wBAAgB,wBAAwB,IAAI,OAAO,CAuVlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/commands/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/commands/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/G,MAAM,WAAW,YAAY;IAC3B,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,0BAA0B,CAAC;IAC5C,sBAA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AM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,gGAAgG;IAChG,aAAa,EAAE,OAAO,CAAC;IACvB,+FAA+F;IAC/F,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE;gBADnB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EAAE,EAC5B,KAAK,EAAE,OAAO;CAIjB;AAID,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGpF;AAED,kHAAkH;AAClH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,EACxB,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,SAAS,GAAG,eAAe,GAAG,gBAAgB,CAAC,GACzF,MAAM,EAAE,CAcV;AAED,eAAO,MAAM,KAAK,yFAA0F,CAAC;AAE7G,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA4E/E;AAMD,wBAAgB,oBAAoB,IAAI,OAAO,CA4I9C"}
|
package/dist/index.js
CHANGED
|
@@ -25952,7 +25952,16 @@ var init_registry = __esm(() => {
|
|
|
25952
25952
|
stalledForSeconds: exports_external.number(),
|
|
25953
25953
|
recoveredBy: exports_external.enum(["event", "heartbeat", "rearmed"]),
|
|
25954
25954
|
recoveredAt: exports_external.number()
|
|
25955
|
-
}), { description: "A stalled connector signalled again (event, heartbeat, or re-declared cadence)" })
|
|
25955
|
+
}), { description: "A stalled connector signalled again (event, heartbeat, or re-declared cadence)" }),
|
|
25956
|
+
agentRunCompleted: createEventSchema("system.agent.run_completed", exports_external.object({
|
|
25957
|
+
automationId: exports_external.string().nullable(),
|
|
25958
|
+
executionId: exports_external.string().nullable(),
|
|
25959
|
+
runId: exports_external.string(),
|
|
25960
|
+
status: exports_external.string(),
|
|
25961
|
+
providerRunId: exports_external.string().optional(),
|
|
25962
|
+
response: exports_external.string().optional(),
|
|
25963
|
+
error: exports_external.string().optional()
|
|
25964
|
+
}), { description: "A fire-and-forget call_agent run settled (completed or failed)" })
|
|
25956
25965
|
};
|
|
25957
25966
|
CustomEventSchemas = {
|
|
25958
25967
|
chatUnreadUpdated: createEventSchema("custom.chat.unread-updated", exports_external.object({
|
|
@@ -41284,7 +41293,7 @@ function extractAgentCallContext(config2, context) {
|
|
|
41284
41293
|
}
|
|
41285
41294
|
};
|
|
41286
41295
|
}
|
|
41287
|
-
async function executeCallAgentAction(config2, context, deps, trustedTenantId) {
|
|
41296
|
+
async function executeCallAgentAction(config2, context, deps, trustedTenantId, provenance) {
|
|
41288
41297
|
if (!deps.callAgent) {
|
|
41289
41298
|
return { success: false, error: "callAgent dependency not provided" };
|
|
41290
41299
|
}
|
|
@@ -41299,6 +41308,9 @@ async function executeCallAgentAction(config2, context, deps, trustedTenantId) {
|
|
|
41299
41308
|
senderId: agentContext.senderId,
|
|
41300
41309
|
agentId: config2.agentId
|
|
41301
41310
|
});
|
|
41311
|
+
if (config2.waitForResponse === false) {
|
|
41312
|
+
return dispatchCallAgent(deps.callAgent(agentContext, config2, trustedTenantId), deps, provenance);
|
|
41313
|
+
}
|
|
41302
41314
|
try {
|
|
41303
41315
|
const result = await deps.callAgent(agentContext, config2, trustedTenantId);
|
|
41304
41316
|
logger2.info("Agent call completed", {
|
|
@@ -41321,6 +41333,22 @@ async function executeCallAgentAction(config2, context, deps, trustedTenantId) {
|
|
|
41321
41333
|
return { success: false, error: errorMessage };
|
|
41322
41334
|
}
|
|
41323
41335
|
}
|
|
41336
|
+
function dispatchCallAgent(run, deps, provenance) {
|
|
41337
|
+
const runId = generateId();
|
|
41338
|
+
const base = {
|
|
41339
|
+
automationId: provenance?.automationId ?? null,
|
|
41340
|
+
executionId: provenance?.parentEventId ?? null,
|
|
41341
|
+
runId
|
|
41342
|
+
};
|
|
41343
|
+
const publish = (payload) => deps.eventBus?.publishGeneric("system.agent.run_completed", { ...base, ...payload }).catch((error2) => logger2.error("Failed to publish system.agent.run_completed", { runId, error: String(error2) }));
|
|
41344
|
+
run.then((result) => publish({
|
|
41345
|
+
status: result.metadata.status,
|
|
41346
|
+
providerRunId: result.metadata.runId,
|
|
41347
|
+
response: result.fullResponse,
|
|
41348
|
+
error: result.metadata.status === "failed" ? "Agent call failed" : undefined
|
|
41349
|
+
}), (error2) => publish({ status: "failed", error: error2 instanceof Error ? error2.message : "Unknown error" }));
|
|
41350
|
+
return { success: true, result: { runId, accepted: true } };
|
|
41351
|
+
}
|
|
41324
41352
|
async function executeAction(action, context, deps, trustedTenantId, actionIndex = 0, provenance) {
|
|
41325
41353
|
const start = Date.now();
|
|
41326
41354
|
let result;
|
|
@@ -41338,7 +41366,7 @@ async function executeAction(action, context, deps, trustedTenantId, actionIndex
|
|
|
41338
41366
|
result = await executeLogAction(action.config, context, deps);
|
|
41339
41367
|
break;
|
|
41340
41368
|
case "call_agent":
|
|
41341
|
-
result = await executeCallAgentAction(action.config, context, deps, trustedTenantId);
|
|
41369
|
+
result = await executeCallAgentAction(action.config, context, deps, trustedTenantId, provenance);
|
|
41342
41370
|
break;
|
|
41343
41371
|
default:
|
|
41344
41372
|
result = { success: false, error: `Unknown action type: ${action.type}` };
|
|
@@ -83249,6 +83277,7 @@ var init_schema2 = __esm(() => {
|
|
|
83249
83277
|
idempotencyAcrossEventTypes: boolean2("idempotency_across_event_types").notNull().default(false),
|
|
83250
83278
|
eventTypeMapping: jsonb("event_type_mapping").$type(),
|
|
83251
83279
|
strictSchemas: boolean2("strict_schemas").notNull().default(false),
|
|
83280
|
+
pollConfig: jsonb("poll_config").$type(),
|
|
83252
83281
|
enabled: boolean2("enabled").notNull().default(true),
|
|
83253
83282
|
lastReceivedAt: timestamp("last_received_at", { withTimezone: true }),
|
|
83254
83283
|
totalReceived: integer("total_received").notNull().default(0),
|
|
@@ -137386,7 +137415,7 @@ import { fileURLToPath } from "url";
|
|
|
137386
137415
|
// package.json
|
|
137387
137416
|
var package_default = {
|
|
137388
137417
|
name: "@automagik/omni",
|
|
137389
|
-
version: "2.260915.
|
|
137418
|
+
version: "2.260915.19",
|
|
137390
137419
|
repository: {
|
|
137391
137420
|
type: "git",
|
|
137392
137421
|
url: "git+https://github.com/automagik-dev/omni.git",
|
|
@@ -139828,7 +139857,7 @@ function createAutomationsCommand() {
|
|
|
139828
139857
|
error(`Failed to get automation: ${message2}`);
|
|
139829
139858
|
}
|
|
139830
139859
|
});
|
|
139831
|
-
automations2.command("create").description("Create an automation").option("--file <path>", "Full definition as JSON (the `get` output works as-is); explicit flags override it").option("--name <name>", "Automation name").option("--trigger <event>", "Trigger event type (e.g., message.received)").option("--action <type>", "Action type (webhook, send_message, emit_event, log, call_agent); repeat for ordered multi-action", collectRepeated).option("--action-config <json>", "Action config as JSON; the i-th pairs with the i-th --action", collectRepeated).option("--condition <json>", "Trigger conditions as JSON array").option("--condition-logic <logic>", 'Condition logic: "and" (all must match) or "or" (any must match)').option("--description <desc>", "Automation description").option("--priority <n>", "Priority (higher = runs first)", (v4) => Number.parseInt(v4, 10)).option("--disabled", "Create in disabled state").option("--transactional-emissions", "Buffer the run's emit_event publishes and flush them in order only when every action succeeded; " + "a failed run publishes zero (#988). Defaults to off (immediate publishing)").option("--max-concurrency <n>", "Cap concurrent runs of THIS automation (own queue, up to 50 deliveries per trigger in flight); " + "1 = strict single-flight, which a read-before-write action needs (#1108). " + "Default: shares the per-instance queue, engine default 5", (v4) => Number.parseInt(v4, 10)).option("--concurrency-key <template>", 'Template over the event payload partitioning that queue, e.g. "{{payload.from.id}}" to serialize ' + "per chat instead of globally (#1108)").option("--agent-id <id>", "Agent ID (for the first call_agent action)").option("--provider-id <id>", "Provider ID (for the first call_agent action)").option("--response-as <var>", "Store agent response as variable (for the first call_agent action)").action(async (options) => {
|
|
139860
|
+
automations2.command("create").description("Create an automation").option("--file <path>", "Full definition as JSON (the `get` output works as-is); explicit flags override it").option("--name <name>", "Automation name").option("--trigger <event>", "Trigger event type (e.g., message.received)").option("--action <type>", "Action type (webhook, send_message, emit_event, log, call_agent); repeat for ordered multi-action", collectRepeated).option("--action-config <json>", "Action config as JSON; the i-th pairs with the i-th --action", collectRepeated).option("--condition <json>", "Trigger conditions as JSON array").option("--condition-logic <logic>", 'Condition logic: "and" (all must match) or "or" (any must match)').option("--description <desc>", "Automation description").option("--priority <n>", "Priority (higher = runs first)", (v4) => Number.parseInt(v4, 10)).option("--disabled", "Create in disabled state").option("--transactional-emissions", "Buffer the run's emit_event publishes and flush them in order only when every action succeeded; " + "a failed run publishes zero (#988). Defaults to off (immediate publishing)").option("--max-concurrency <n>", "Cap concurrent runs of THIS automation (own queue, up to 50 deliveries per trigger in flight); " + "1 = strict single-flight, which a read-before-write action needs (#1108). " + "Default: shares the per-instance queue, engine default 5", (v4) => Number.parseInt(v4, 10)).option("--concurrency-key <template>", 'Template over the event payload partitioning that queue, e.g. "{{payload.from.id}}" to serialize ' + "per chat instead of globally (#1108)").option("--agent-id <id>", "Agent ID (for the first call_agent action)").option("--provider-id <id>", "Provider ID (for the first call_agent action)").option("--response-as <var>", "Store agent response as variable (for the first call_agent action; not with waitForResponse:false)").action(async (options) => {
|
|
139832
139861
|
const client = getClient();
|
|
139833
139862
|
try {
|
|
139834
139863
|
const automation = await client.automations.create(buildCreateBody(options));
|
|
@@ -139844,7 +139873,7 @@ function createAutomationsCommand() {
|
|
|
139844
139873
|
error(`Failed to create automation: ${message2}`);
|
|
139845
139874
|
}
|
|
139846
139875
|
});
|
|
139847
|
-
automations2.command("update <id>").description("Update an automation in place (id and execution logs are kept)").option("--file <path>", "Full definition as JSON (the `get` output works as-is); explicit flags override it").option("--name <name>", "New name").option("--description <desc>", "New description").option("--trigger <event>", "New trigger event type").option("--condition <json>", "Replace trigger conditions (JSON array)").option("--condition-logic <logic>", 'Condition logic: "and" or "or"').option("--action <type>", "Replace the actions list; repeat for ordered multi-action", collectRepeated).option("--action-config <json>", "Action config as JSON; the i-th pairs with the i-th --action", collectRepeated).option("--priority <n>", "New priority", (v4) => Number.parseInt(v4, 10)).option("--transactional-emissions", "Buffer the run's emit_event publishes and flush them in order only when every action succeeded; " + "a failed run publishes zero (#988)").option("--no-transactional-emissions", "Return the automation to immediate mid-sequence publishing").option("--max-concurrency <n>", "Cap concurrent runs of THIS automation on its own queue; 1 = strict single-flight (#1108)", (v4) => Number.parseInt(v4, 10)).option("--concurrency-key <template>", 'Template over the event payload partitioning that queue, e.g. "{{payload.from.id}}" (#1108)').option("--agent-id <id>", "Agent ID (for the first call_agent action)").option("--provider-id <id>", "Provider ID (for the first call_agent action)").option("--response-as <var>", "Store agent response as variable (for the first call_agent action)").action(async (id, options) => {
|
|
139876
|
+
automations2.command("update <id>").description("Update an automation in place (id and execution logs are kept)").option("--file <path>", "Full definition as JSON (the `get` output works as-is); explicit flags override it").option("--name <name>", "New name").option("--description <desc>", "New description").option("--trigger <event>", "New trigger event type").option("--condition <json>", "Replace trigger conditions (JSON array)").option("--condition-logic <logic>", 'Condition logic: "and" or "or"').option("--action <type>", "Replace the actions list; repeat for ordered multi-action", collectRepeated).option("--action-config <json>", "Action config as JSON; the i-th pairs with the i-th --action", collectRepeated).option("--priority <n>", "New priority", (v4) => Number.parseInt(v4, 10)).option("--transactional-emissions", "Buffer the run's emit_event publishes and flush them in order only when every action succeeded; " + "a failed run publishes zero (#988)").option("--no-transactional-emissions", "Return the automation to immediate mid-sequence publishing").option("--max-concurrency <n>", "Cap concurrent runs of THIS automation on its own queue; 1 = strict single-flight (#1108)", (v4) => Number.parseInt(v4, 10)).option("--concurrency-key <template>", 'Template over the event payload partitioning that queue, e.g. "{{payload.from.id}}" (#1108)').option("--agent-id <id>", "Agent ID (for the first call_agent action)").option("--provider-id <id>", "Provider ID (for the first call_agent action)").option("--response-as <var>", "Store agent response as variable (for the first call_agent action; not with waitForResponse:false)").action(async (id, options) => {
|
|
139848
139877
|
const client = getClient();
|
|
139849
139878
|
try {
|
|
139850
139879
|
const body = buildDefinition(options);
|
|
@@ -151970,8 +151999,55 @@ function createSourcesCommand() {
|
|
|
151970
151999
|
error(`Failed to add source: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
151971
152000
|
}
|
|
151972
152001
|
});
|
|
152002
|
+
sources.command("add-poll <name>").description("Create a supervised pull connector: omni runs --command every --interval seconds and ingests each JSON stdout line (command must live inside the API host OMNI_POLL_COMMAND_DIR)").requiredOption("--command <path>", "Executable to run (no shell, no arguments)").requiredOption("--interval <seconds>", "Seconds between runs (min 10); failures back off exponentially").requiredOption("--emit-type <type>", "Event type for each stdout line (custom.*)").option("--dedup-key <template>", "Idempotency key template, e.g. '{payload.message_id}'").option("--expected-interval <seconds>", "Liveness window (default: 2x --interval)").option("--env <KEY=VALUE...>", "Environment variables for the command (repeatable)").option("--description <desc>", "Description").action(async (name, options3) => {
|
|
152003
|
+
const intervalSeconds = Number(options3.interval);
|
|
152004
|
+
const env2 = Object.fromEntries((options3.env ?? []).map((pair) => [pair.slice(0, pair.indexOf("=")), pair.slice(pair.indexOf("=") + 1)]));
|
|
152005
|
+
try {
|
|
152006
|
+
const result = await webhookSourcesApiRequest("", {
|
|
152007
|
+
method: "POST",
|
|
152008
|
+
body: JSON.stringify({
|
|
152009
|
+
name,
|
|
152010
|
+
description: options3.description ?? `Poll connector: ${options3.command}`,
|
|
152011
|
+
enabled: true,
|
|
152012
|
+
expectedIntervalSeconds: options3.expectedInterval ? Number(options3.expectedInterval) : intervalSeconds * 2,
|
|
152013
|
+
pollConfig: {
|
|
152014
|
+
command: options3.command,
|
|
152015
|
+
intervalSeconds,
|
|
152016
|
+
emitType: options3.emitType,
|
|
152017
|
+
...options3.dedupKey && { dedupKeyTemplate: options3.dedupKey },
|
|
152018
|
+
...options3.env && { env: env2 }
|
|
152019
|
+
}
|
|
152020
|
+
})
|
|
152021
|
+
});
|
|
152022
|
+
success(`Poll source created: ${result.data.id}`, { name, ...result.data });
|
|
152023
|
+
} catch (err2) {
|
|
152024
|
+
error(`Failed to add poll source: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
152025
|
+
}
|
|
152026
|
+
});
|
|
152027
|
+
sources.command("run-now <name>").description("Run a poll source command immediately and show the result").action(async (name) => {
|
|
152028
|
+
try {
|
|
152029
|
+
const id = await resolveWebhookId(name);
|
|
152030
|
+
const result = await webhookSourcesApiRequest(`/${id}/run-now`, {
|
|
152031
|
+
method: "POST"
|
|
152032
|
+
});
|
|
152033
|
+
data(result.data.pollConfig);
|
|
152034
|
+
} catch (err2) {
|
|
152035
|
+
error(`Failed to run poll source: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
152036
|
+
}
|
|
152037
|
+
});
|
|
151973
152038
|
return sources;
|
|
151974
152039
|
}
|
|
152040
|
+
async function webhookSourcesApiRequest(path, init = {}) {
|
|
152041
|
+
const config2 = loadConfig();
|
|
152042
|
+
const resp = await fetch(`${config2.apiUrl ?? "http://localhost:8882"}/api/v2/webhook-sources${path}`, {
|
|
152043
|
+
method: init.method ?? "GET",
|
|
152044
|
+
body: init.body,
|
|
152045
|
+
headers: { "content-type": "application/json", "x-api-key": config2.apiKey ?? "" }
|
|
152046
|
+
});
|
|
152047
|
+
if (!resp.ok)
|
|
152048
|
+
throw new Error(`API returned ${resp.status}: ${await resp.text()}`);
|
|
152049
|
+
return await resp.json();
|
|
152050
|
+
}
|
|
151975
152051
|
|
|
151976
152052
|
// src/commands/speak.ts
|
|
151977
152053
|
import { writeFile as writeFile2 } from "fs/promises";
|