@automagik/omni 2.260910.10 → 2.260910.12
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/db/drizzle/0066_consumer_exclude_types.sql +16 -0
- package/db/drizzle/meta/_journal.json +7 -0
- package/dist/commands/automations.d.ts +7 -1
- package/dist/commands/automations.d.ts.map +1 -1
- package/dist/commands/events.d.ts +11 -1
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/index.js +114 -54
- package/dist/sdk/client.d.ts +16 -5
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +10 -1
- package/dist/sdk/types.generated.d.ts +171 -92
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +188 -45
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -76973,7 +76973,7 @@ var require_ClientVoiceManager = __commonJS((exports, module) => {
|
|
|
76973
76973
|
|
|
76974
76974
|
// ../../node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist/index.js
|
|
76975
76975
|
var require_dist9 = __commonJS((exports, module) => {
|
|
76976
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
76976
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist";
|
|
76977
76977
|
var __create2 = Object.create;
|
|
76978
76978
|
var __defProp2 = Object.defineProperty;
|
|
76979
76979
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -162253,7 +162253,7 @@ var require_indexes = __commonJS((exports, module) => {
|
|
|
162253
162253
|
|
|
162254
162254
|
// ../../node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream/index.js
|
|
162255
162255
|
var require_thread_stream = __commonJS((exports, module) => {
|
|
162256
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162256
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream";
|
|
162257
162257
|
var { version } = require_package5();
|
|
162258
162258
|
var { EventEmitter: EventEmitter3 } = __require("events");
|
|
162259
162259
|
var { Worker } = __require("worker_threads");
|
|
@@ -162674,7 +162674,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
162674
162674
|
|
|
162675
162675
|
// ../../node_modules/.bun/pino@9.14.0/node_modules/pino/lib/transport.js
|
|
162676
162676
|
var require_transport2 = __commonJS((exports, module) => {
|
|
162677
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162677
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
162678
162678
|
var { createRequire: createRequire2 } = __require("module");
|
|
162679
162679
|
var getCallers = require_caller();
|
|
162680
162680
|
var { join: join8, isAbsolute, sep: sep2 } = __require("path");
|
|
@@ -174442,6 +174442,7 @@ var init_schema2 = __esm(() => {
|
|
|
174442
174442
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
174443
174443
|
name: varchar("name", { length: 100 }).notNull(),
|
|
174444
174444
|
eventType: varchar("event_type", { length: 255 }).notNull(),
|
|
174445
|
+
excludeTypes: jsonb("exclude_types").$type(),
|
|
174445
174446
|
filters: jsonb("filters").$type(),
|
|
174446
174447
|
cursor: bigint2("cursor", { mode: "number" }).notNull().default(0),
|
|
174447
174448
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -244418,7 +244419,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
244418
244419
|
|
|
244419
244420
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js
|
|
244420
244421
|
var require_esmLoader = __commonJS((exports) => {
|
|
244421
|
-
var __filename = "/home/runner/work/omni/omni
|
|
244422
|
+
var __filename = "/home/runner/work/omni/omni/node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js";
|
|
244422
244423
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
244423
244424
|
var core3 = require_cjs6();
|
|
244424
244425
|
var importInTheMiddle = require_import_in_the_middle();
|
|
@@ -251644,7 +251645,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251644
251645
|
var require_package7 = __commonJS((exports, module) => {
|
|
251645
251646
|
module.exports = {
|
|
251646
251647
|
name: "@omni/api",
|
|
251647
|
-
version: "2.260910.
|
|
251648
|
+
version: "2.260910.12",
|
|
251648
251649
|
private: true,
|
|
251649
251650
|
type: "module",
|
|
251650
251651
|
exports: {
|
|
@@ -278746,7 +278747,7 @@ var require_src45 = __commonJS((exports) => {
|
|
|
278746
278747
|
|
|
278747
278748
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
278748
278749
|
var require_channelz = __commonJS((exports) => {
|
|
278749
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
278750
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
278750
278751
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
278751
278752
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
278752
278753
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -284149,7 +284150,7 @@ var require_duration = __commonJS((exports) => {
|
|
|
284149
284150
|
|
|
284150
284151
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/orca.js
|
|
284151
284152
|
var require_orca = __commonJS((exports) => {
|
|
284152
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
284153
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
284153
284154
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
284154
284155
|
exports.OrcaOobMetricsSubchannelWrapper = exports.GRPC_METRICS_HEADER = exports.ServerMetricRecorder = exports.PerRequestMetricRecorder = undefined;
|
|
284155
284156
|
exports.createOrcaClient = createOrcaClient;
|
|
@@ -313279,6 +313280,7 @@ var init_scopes = __esm(() => {
|
|
|
313279
313280
|
"POST /events/consumers/:name/ack": "events:write",
|
|
313280
313281
|
"GET /events": "events:read",
|
|
313281
313282
|
"GET /events/analytics": "events:read",
|
|
313283
|
+
"GET /events/types": "events:read",
|
|
313282
313284
|
"GET /events/timeline/:personId": "events:read",
|
|
313283
313285
|
"POST /events/search": "events:read",
|
|
313284
313286
|
"GET /events/:id": "events:read",
|
|
@@ -314144,6 +314146,7 @@ var init_route_ownership = __esm(() => {
|
|
|
314144
314146
|
"GET /api/v2/events/schemas",
|
|
314145
314147
|
"GET /api/v2/events/schemas/:eventType",
|
|
314146
314148
|
"GET /api/v2/events/timeline/:personId",
|
|
314149
|
+
"GET /api/v2/events/types",
|
|
314147
314150
|
"GET /api/v2/follow-up/agents/:id",
|
|
314148
314151
|
"GET /api/v2/follow-up/chats/:id",
|
|
314149
314152
|
"GET /api/v2/follow-up/instances/:id",
|
|
@@ -368514,17 +368517,38 @@ class AutomationService {
|
|
|
368514
368517
|
}
|
|
368515
368518
|
async test(id, event) {
|
|
368516
368519
|
const automation = await this.getById(id);
|
|
368517
|
-
|
|
368518
|
-
|
|
368519
|
-
}
|
|
368520
|
-
const matched =
|
|
368520
|
+
const triggerMatched = automation.triggerEventType === event.type;
|
|
368521
|
+
const conditionLogic = automation.conditionLogic ?? "and";
|
|
368522
|
+
const conditionResult = evaluateConditionsWithDetails(automation.triggerConditions, { ...event.metadata ?? {}, ...event.payload }, conditionLogic);
|
|
368523
|
+
const matched = triggerMatched && conditionResult.matched;
|
|
368524
|
+
const context20 = createTemplateContext(event.payload, {
|
|
368525
|
+
event: event.id ? {
|
|
368526
|
+
id: event.id,
|
|
368527
|
+
type: event.type,
|
|
368528
|
+
timestamp: event.timestamp ?? Date.now(),
|
|
368529
|
+
metadata: event.metadata ?? {}
|
|
368530
|
+
} : undefined,
|
|
368531
|
+
automation: { id: automation.id, managedByAgentId: automation.managedByAgentId }
|
|
368532
|
+
});
|
|
368521
368533
|
return {
|
|
368522
368534
|
matched,
|
|
368523
|
-
|
|
368535
|
+
triggerMatched,
|
|
368536
|
+
conditionsMatched: conditionResult.matched,
|
|
368537
|
+
conditionLogic,
|
|
368538
|
+
conditions: conditionResult.conditions.map((c) => ({
|
|
368539
|
+
field: c.field,
|
|
368540
|
+
operator: c.operator,
|
|
368541
|
+
expected: c.expectedValue,
|
|
368542
|
+
actual: c.actualValue,
|
|
368543
|
+
resolved: c.actualValue !== undefined,
|
|
368544
|
+
matched: c.matched
|
|
368545
|
+
})),
|
|
368524
368546
|
actions: automation.actions.map((a) => ({
|
|
368525
368547
|
type: a.type,
|
|
368526
|
-
wouldExecute: matched
|
|
368548
|
+
wouldExecute: matched,
|
|
368549
|
+
config: substituteTemplateObject(a.config ?? {}, context20)
|
|
368527
368550
|
})),
|
|
368551
|
+
eventId: event.id ?? null,
|
|
368528
368552
|
dryRun: true
|
|
368529
368553
|
};
|
|
368530
368554
|
}
|
|
@@ -368537,7 +368561,7 @@ class AutomationService {
|
|
|
368537
368561
|
results: []
|
|
368538
368562
|
};
|
|
368539
368563
|
}
|
|
368540
|
-
const correlationId = crypto.randomUUID();
|
|
368564
|
+
const correlationId = event.id ?? crypto.randomUUID();
|
|
368541
368565
|
const context20 = createTemplateContext(event.payload);
|
|
368542
368566
|
const actionDeps = {
|
|
368543
368567
|
eventBus: this.eventBus,
|
|
@@ -370491,6 +370515,23 @@ var init_dead_letters = __esm(() => {
|
|
|
370491
370515
|
function escapeLikePattern(value) {
|
|
370492
370516
|
return value.replace(/([\\%_])/g, "\\$1");
|
|
370493
370517
|
}
|
|
370518
|
+
function eventTypeGlobClause(globs) {
|
|
370519
|
+
const exact = globs.filter((t) => !t.endsWith("*"));
|
|
370520
|
+
const prefixes = globs.filter((t) => t.endsWith("*")).map((t) => t.slice(0, -1));
|
|
370521
|
+
const clauses = [
|
|
370522
|
+
...exact.length ? [inArray(omniEvents.eventType, exact)] : [],
|
|
370523
|
+
...prefixes.map((p2) => like(omniEvents.eventType, `${escapeLikePattern(p2)}%`))
|
|
370524
|
+
];
|
|
370525
|
+
return clauses.length === 1 ? clauses[0] : or2(...clauses);
|
|
370526
|
+
}
|
|
370527
|
+
function eventTypeFilterClause(include, exclude) {
|
|
370528
|
+
const inc = include?.length ? eventTypeGlobClause(include) : undefined;
|
|
370529
|
+
const exc = exclude?.length ? eventTypeGlobClause(exclude) : undefined;
|
|
370530
|
+
return and2(inc, exc ? not2(exc) : undefined);
|
|
370531
|
+
}
|
|
370532
|
+
function consumerTypeMatches(filter, eventType) {
|
|
370533
|
+
return filter.endsWith("*") ? eventType.startsWith(filter.slice(0, -1)) : filter === eventType;
|
|
370534
|
+
}
|
|
370494
370535
|
|
|
370495
370536
|
class EventService {
|
|
370496
370537
|
pool;
|
|
@@ -370507,6 +370548,7 @@ class EventService {
|
|
|
370507
370548
|
personId,
|
|
370508
370549
|
chatId,
|
|
370509
370550
|
eventType,
|
|
370551
|
+
excludeEventType,
|
|
370510
370552
|
contentType,
|
|
370511
370553
|
direction,
|
|
370512
370554
|
since,
|
|
@@ -370530,17 +370572,9 @@ class EventService {
|
|
|
370530
370572
|
if (chatId) {
|
|
370531
370573
|
conditions3.push(eq(omniEvents.chatUuid, chatId));
|
|
370532
370574
|
}
|
|
370533
|
-
|
|
370534
|
-
|
|
370535
|
-
|
|
370536
|
-
const typeClauses = [
|
|
370537
|
-
...exact.length ? [inArray(omniEvents.eventType, exact)] : [],
|
|
370538
|
-
...prefixes.map((p2) => like(omniEvents.eventType, `${escapeLikePattern(p2)}%`))
|
|
370539
|
-
];
|
|
370540
|
-
const combined = typeClauses.length === 1 ? typeClauses[0] : or2(...typeClauses);
|
|
370541
|
-
if (combined)
|
|
370542
|
-
conditions3.push(combined);
|
|
370543
|
-
}
|
|
370575
|
+
const typeClause = eventTypeFilterClause(eventType, excludeEventType);
|
|
370576
|
+
if (typeClause)
|
|
370577
|
+
conditions3.push(typeClause);
|
|
370544
370578
|
if (contentType?.length) {
|
|
370545
370579
|
conditions3.push(inArray(omniEvents.contentType, contentType));
|
|
370546
370580
|
}
|
|
@@ -370722,6 +370756,31 @@ class EventService {
|
|
|
370722
370756
|
timeline
|
|
370723
370757
|
};
|
|
370724
370758
|
}
|
|
370759
|
+
async getTypes(options = {}) {
|
|
370760
|
+
const autos = options.automations ?? [];
|
|
370761
|
+
const [observed, schemas2, consumers] = await Promise.all([
|
|
370762
|
+
this.db.select({
|
|
370763
|
+
eventType: omniEvents.eventType,
|
|
370764
|
+
count: sql`count(*)::int`,
|
|
370765
|
+
lastSeen: sql`max(${omniEvents.receivedAt})::text`
|
|
370766
|
+
}).from(omniEvents).where(options.since ? gte(omniEvents.receivedAt, options.since) : undefined).groupBy(omniEvents.eventType).orderBy(desc(sql`count(*)`)),
|
|
370767
|
+
this.db.select({ eventType: eventSchemas.eventType, version: eventSchemas.version, enabled: eventSchemas.enabled }).from(eventSchemas),
|
|
370768
|
+
this.db.select({ name: durableConsumers.name, eventType: durableConsumers.eventType }).from(durableConsumers)
|
|
370769
|
+
]);
|
|
370770
|
+
const schemaByType = new Map(schemas2.map((s) => [s.eventType, s]));
|
|
370771
|
+
return observed.map((row) => {
|
|
370772
|
+
const schema3 = schemaByType.get(row.eventType);
|
|
370773
|
+
return {
|
|
370774
|
+
eventType: row.eventType,
|
|
370775
|
+
count: row.count,
|
|
370776
|
+
lastSeen: new Date(row.lastSeen).toISOString(),
|
|
370777
|
+
schemaVersion: schema3?.version ?? null,
|
|
370778
|
+
schemaEnabled: schema3?.enabled ?? null,
|
|
370779
|
+
consumers: consumers.filter((c) => consumerTypeMatches(c.eventType, row.eventType)).map((c) => c.name),
|
|
370780
|
+
automations: autos.filter((a) => a.triggerEventType === row.eventType).map((a) => a.name)
|
|
370781
|
+
};
|
|
370782
|
+
});
|
|
370783
|
+
}
|
|
370725
370784
|
}
|
|
370726
370785
|
var TRACE_MAX_ANCESTORS = 50, TRACE_MAX_DEPTH = 10, TRACE_MAX_NODES = 200;
|
|
370727
370786
|
var init_events2 = __esm(() => {
|
|
@@ -370779,7 +370838,13 @@ class EventConsumerService {
|
|
|
370779
370838
|
async create(input) {
|
|
370780
370839
|
const head = await this.head();
|
|
370781
370840
|
const cursor = resolveInitialCursor(input.startFrom ?? "now", head);
|
|
370782
|
-
const [created] = await this.db.insert(durableConsumers).values({
|
|
370841
|
+
const [created] = await this.db.insert(durableConsumers).values({
|
|
370842
|
+
name: input.name,
|
|
370843
|
+
eventType: input.eventType,
|
|
370844
|
+
excludeTypes: input.excludeTypes?.length ? input.excludeTypes : null,
|
|
370845
|
+
filters: input.filters ?? null,
|
|
370846
|
+
cursor
|
|
370847
|
+
}).onConflictDoNothing({ target: durableConsumers.name }).returning();
|
|
370783
370848
|
if (!created) {
|
|
370784
370849
|
throw new ConflictError("DurableConsumer", `a consumer named '${input.name}' already exists`, {
|
|
370785
370850
|
name: input.name
|
|
@@ -370839,7 +370904,7 @@ class EventConsumerService {
|
|
|
370839
370904
|
return { ...updated, head, lag: computeLag(head, updated.cursor) };
|
|
370840
370905
|
}
|
|
370841
370906
|
async scanPage(consumer, limit2) {
|
|
370842
|
-
const typeClause = consumer.eventType
|
|
370907
|
+
const typeClause = eventTypeFilterClause([consumer.eventType], consumer.excludeTypes ?? undefined);
|
|
370843
370908
|
return this.db.select().from(omniEvents).where(and2(gt(omniEvents.journalSeq, consumer.cursor), typeClause)).orderBy(asc(omniEvents.journalSeq)).limit(limit2);
|
|
370844
370909
|
}
|
|
370845
370910
|
}
|
|
@@ -378977,6 +379042,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
378977
379042
|
registry4.register("CreateAutomationRequest", CreateAutomationSchema);
|
|
378978
379043
|
registry4.register("AutomationLog", AutomationLogSchema);
|
|
378979
379044
|
registry4.register("TestAutomationRequest", TestAutomationSchema);
|
|
379045
|
+
registry4.register("AutomationTestResult", AutomationTestResultSchema);
|
|
378980
379046
|
registry4.register("AutomationMetrics", AutomationMetricsSchema);
|
|
378981
379047
|
registry4.registerPath({
|
|
378982
379048
|
method: "get",
|
|
@@ -379094,24 +379160,16 @@ function registerAutomationSchemas(registry4) {
|
|
|
379094
379160
|
path: "/automations/{id}/test",
|
|
379095
379161
|
operationId: "testAutomation",
|
|
379096
379162
|
tags: ["Automations"],
|
|
379097
|
-
summary: "Test automation",
|
|
379098
|
-
description: "
|
|
379163
|
+
summary: "Test automation (dry run)",
|
|
379164
|
+
description: "Dry-run an automation against a hand-written event or a REAL journaled event (`eventId`, #1073): " + "trigger match, per-condition verdicts and rendered action templates. Executes nothing, writes no execution log.",
|
|
379099
379165
|
request: {
|
|
379100
379166
|
params: exports_external.object({ id: exports_external.string().uuid().openapi({ description: "Automation UUID" }) }),
|
|
379101
379167
|
body: { content: { "application/json": { schema: TestAutomationSchema } } }
|
|
379102
379168
|
},
|
|
379103
379169
|
responses: {
|
|
379104
379170
|
200: {
|
|
379105
|
-
description: "
|
|
379106
|
-
content: {
|
|
379107
|
-
"application/json": {
|
|
379108
|
-
schema: exports_external.object({
|
|
379109
|
-
matched: exports_external.boolean(),
|
|
379110
|
-
conditionResults: exports_external.array(exports_external.object({ condition: ConditionSchema, passed: exports_external.boolean() })).optional(),
|
|
379111
|
-
wouldExecute: exports_external.array(ActionSchema).optional()
|
|
379112
|
-
})
|
|
379113
|
-
}
|
|
379114
|
-
}
|
|
379171
|
+
description: "Dry-run result",
|
|
379172
|
+
content: { "application/json": { schema: AutomationTestResultSchema } }
|
|
379115
379173
|
},
|
|
379116
379174
|
404: { description: "Not found", content: { "application/json": { schema: ErrorSchema } } }
|
|
379117
379175
|
}
|
|
@@ -379122,7 +379180,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
379122
379180
|
operationId: "executeAutomation",
|
|
379123
379181
|
tags: ["Automations"],
|
|
379124
379182
|
summary: "Execute automation",
|
|
379125
|
-
description: "Execute automation with a provided event payload. Actually runs the actions (not a dry run).",
|
|
379183
|
+
description: "Execute automation with a provided event payload or a journaled event (`eventId`). Actually runs the actions (not a dry run).",
|
|
379126
379184
|
request: {
|
|
379127
379185
|
params: exports_external.object({ id: exports_external.string().uuid().openapi({ description: "Automation UUID" }) }),
|
|
379128
379186
|
body: { content: { "application/json": { schema: TestAutomationSchema } } }
|
|
@@ -379209,7 +379267,7 @@ function registerAutomationSchemas(registry4) {
|
|
|
379209
379267
|
}
|
|
379210
379268
|
});
|
|
379211
379269
|
}
|
|
379212
|
-
var ConditionSchema, WebhookActionSchema, SendMessageActionSchema, EmitEventActionSchema, LogActionSchema, CallAgentActionSchema, ActionSchema, DebounceSchema, AutomationSchema, CreateAutomationSchema, AutomationLogSchema, TestAutomationSchema, AutomationMetricsSchema;
|
|
379270
|
+
var ConditionSchema, WebhookActionSchema, SendMessageActionSchema, EmitEventActionSchema, LogActionSchema, CallAgentActionSchema, ActionSchema, DebounceSchema, AutomationSchema, CreateAutomationSchema, AutomationLogSchema, TestAutomationSchema, AutomationTestResultSchema, AutomationMetricsSchema;
|
|
379213
379271
|
var init_automations3 = __esm(() => {
|
|
379214
379272
|
init_zod_openapi();
|
|
379215
379273
|
init_common4();
|
|
@@ -379329,8 +379387,32 @@ var init_automations3 = __esm(() => {
|
|
|
379329
379387
|
event: exports_external.object({
|
|
379330
379388
|
type: exports_external.string().min(1).openapi({ description: "Event type" }),
|
|
379331
379389
|
payload: exports_external.record(exports_external.string(), exports_external.unknown()).openapi({ description: "Event payload" })
|
|
379390
|
+
}).optional().openapi({ description: "Hand-written event. Exactly one of event / eventId is required" }),
|
|
379391
|
+
eventId: exports_external.string().uuid().optional().openapi({
|
|
379392
|
+
description: "Id of a REAL journaled event (omni_events) to run against (#1073): its rawPayload is the payload, " + "its envelope metadata is merged for conditions. Exactly one of event / eventId is required"
|
|
379332
379393
|
})
|
|
379333
379394
|
});
|
|
379395
|
+
AutomationTestResultSchema = exports_external.object({
|
|
379396
|
+
matched: exports_external.boolean().openapi({ description: "triggerMatched AND conditionsMatched" }),
|
|
379397
|
+
triggerMatched: exports_external.boolean().openapi({ description: "Event type equals the automation trigger" }),
|
|
379398
|
+
conditionsMatched: exports_external.boolean().openapi({ description: "Condition set verdict under conditionLogic" }),
|
|
379399
|
+
conditionLogic: exports_external.enum(["and", "or"]),
|
|
379400
|
+
conditions: exports_external.array(exports_external.object({
|
|
379401
|
+
field: exports_external.string(),
|
|
379402
|
+
operator: exports_external.string(),
|
|
379403
|
+
expected: exports_external.unknown().optional(),
|
|
379404
|
+
actual: exports_external.unknown().optional(),
|
|
379405
|
+
resolved: exports_external.boolean().openapi({ description: "false = the dot path resolved to nothing in the payload" }),
|
|
379406
|
+
matched: exports_external.boolean()
|
|
379407
|
+
})).openapi({ description: "Per-condition verdicts" }),
|
|
379408
|
+
actions: exports_external.array(exports_external.object({
|
|
379409
|
+
type: exports_external.string(),
|
|
379410
|
+
wouldExecute: exports_external.boolean(),
|
|
379411
|
+
config: exports_external.record(exports_external.string(), exports_external.unknown()).openapi({ description: "Action config with templates rendered" })
|
|
379412
|
+
})).openapi({ description: "Rendered actions \u2014 never executed" }),
|
|
379413
|
+
eventId: exports_external.string().uuid().nullable(),
|
|
379414
|
+
dryRun: exports_external.literal(true)
|
|
379415
|
+
});
|
|
379334
379416
|
AutomationMetricsSchema = exports_external.object({
|
|
379335
379417
|
running: exports_external.boolean().openapi({ description: "Engine running" }),
|
|
379336
379418
|
instanceQueues: exports_external.array(exports_external.object({
|
|
@@ -379905,6 +379987,7 @@ var init_event_consumers2 = __esm(() => {
|
|
|
379905
379987
|
id: exports_external.string().uuid().openapi({ description: "Consumer UUID" }),
|
|
379906
379988
|
name: exports_external.string().openapi({ description: "Unique consumer name (the follow/ack handle)" }),
|
|
379907
379989
|
eventType: exports_external.string().openapi({ description: "Type filter: exact event type or trailing-* prefix glob" }),
|
|
379990
|
+
excludeTypes: exports_external.array(exports_external.string()).nullable().openapi({ description: "Type globs dropped from the stream (exclusion wins over eventType), or null" }),
|
|
379908
379991
|
filters: exports_external.array(ConsumerConditionSchema).nullable().openapi({ description: "Payload conditions (AND), or null" }),
|
|
379909
379992
|
cursor: exports_external.number().int().openapi({ description: "Last acked journal_seq; delivery resumes strictly after it" }),
|
|
379910
379993
|
head: exports_external.number().int().openapi({ description: "Highest journal_seq currently in the journal" }),
|
|
@@ -379915,6 +379998,7 @@ var init_event_consumers2 = __esm(() => {
|
|
|
379915
379998
|
CreateConsumerSchema = exports_external.object({
|
|
379916
379999
|
name: exports_external.string().min(1).max(100).regex(CONSUMER_NAME_PATTERN, "Consumer name must be lowercase tokens: a-z 0-9 . _ - (starting alphanumeric)").openapi({ description: "Unique consumer name (e.g. deploy-tracker)" }),
|
|
379917
380000
|
eventType: exports_external.string().min(1).max(255).openapi({ description: "Type filter: exact event type, or trailing-* prefix glob (e.g. custom.github.*)" }),
|
|
380001
|
+
excludeTypes: exports_external.array(exports_external.string().min(1).max(255)).max(20).optional().openapi({ description: "Type globs to drop (same syntax as eventType); exclusion wins over inclusion" }),
|
|
379918
380002
|
filters: exports_external.array(ConsumerConditionSchema).max(20).optional().openapi({ description: "Payload conditions (AND) \u2014 same matcher as events wait --filter" }),
|
|
379919
380003
|
startFrom: exports_external.enum(["now", "beginning"]).optional().openapi({ description: "Initial cursor: 'now' = journal head (default), 'beginning' = full replay" })
|
|
379920
380004
|
});
|
|
@@ -380231,6 +380315,7 @@ function registerEventSchemas(registry4) {
|
|
|
380231
380315
|
personId: exports_external.string().uuid().optional().openapi({ description: "Filter by person" }),
|
|
380232
380316
|
chatId: exports_external.string().uuid().optional().openapi({ description: "Filter by chat UUID" }),
|
|
380233
380317
|
eventType: exports_external.string().optional().openapi({ description: "Event types (comma-separated)" }),
|
|
380318
|
+
excludeEventType: exports_external.string().optional().openapi({ description: "Event type globs to drop (comma-separated); exclusion wins over eventType" }),
|
|
380234
380319
|
contentType: exports_external.string().optional().openapi({ description: "Content types (comma-separated)" }),
|
|
380235
380320
|
direction: exports_external.enum(["inbound", "outbound"]).optional().openapi({ description: "Direction" }),
|
|
380236
380321
|
since: exports_external.string().datetime().optional().openapi({ description: "Start date" }),
|
|
@@ -380274,6 +380359,32 @@ function registerEventSchemas(registry4) {
|
|
|
380274
380359
|
200: { description: "Analytics data", content: { "application/json": { schema: EventAnalyticsSchema } } }
|
|
380275
380360
|
}
|
|
380276
380361
|
});
|
|
380362
|
+
registry4.registerPath({
|
|
380363
|
+
method: "get",
|
|
380364
|
+
path: "/events/types",
|
|
380365
|
+
operationId: "listEventTypes",
|
|
380366
|
+
tags: ["Events"],
|
|
380367
|
+
summary: "List observed event types",
|
|
380368
|
+
description: "Inventory of event types observed in the journal: volume and last seen in the window, registered schema version, and subscribed durable consumers / enabled automations.",
|
|
380369
|
+
request: {
|
|
380370
|
+
query: exports_external.object({
|
|
380371
|
+
since: exports_external.string().datetime().optional().openapi({ description: "Only count events received at/after this time" })
|
|
380372
|
+
})
|
|
380373
|
+
},
|
|
380374
|
+
responses: {
|
|
380375
|
+
200: {
|
|
380376
|
+
description: "Event type inventory",
|
|
380377
|
+
content: {
|
|
380378
|
+
"application/json": {
|
|
380379
|
+
schema: exports_external.object({
|
|
380380
|
+
items: exports_external.array(EventTypeInventoryRowSchema),
|
|
380381
|
+
meta: exports_external.object({ since: exports_external.string().datetime().nullable() })
|
|
380382
|
+
})
|
|
380383
|
+
}
|
|
380384
|
+
}
|
|
380385
|
+
}
|
|
380386
|
+
}
|
|
380387
|
+
});
|
|
380277
380388
|
registry4.registerPath({
|
|
380278
380389
|
method: "get",
|
|
380279
380390
|
path: "/events/timeline/{personId}",
|
|
@@ -380387,7 +380498,7 @@ function registerEventSchemas(registry4) {
|
|
|
380387
380498
|
}
|
|
380388
380499
|
});
|
|
380389
380500
|
}
|
|
380390
|
-
var EventSchema, EventSummarySchema, EventAnalyticsSchema, EventTraceSchema, EventSearchSchema;
|
|
380501
|
+
var EventSchema, EventTypeInventoryRowSchema, EventSummarySchema, EventAnalyticsSchema, EventTraceSchema, EventSearchSchema;
|
|
380391
380502
|
var init_events3 = __esm(() => {
|
|
380392
380503
|
init_zod_openapi();
|
|
380393
380504
|
init_common4();
|
|
@@ -380408,6 +380519,15 @@ var init_events3 = __esm(() => {
|
|
|
380408
380519
|
processedAt: exports_external.string().datetime().nullable().openapi({ description: "When event was processed" }),
|
|
380409
380520
|
causationId: exports_external.string().uuid().nullable().openapi({ description: "Id of the immediate parent event (null for roots and pre-#957 rows)" })
|
|
380410
380521
|
});
|
|
380522
|
+
EventTypeInventoryRowSchema = exports_external.object({
|
|
380523
|
+
eventType: exports_external.string().openapi({ description: "Event type" }),
|
|
380524
|
+
count: exports_external.number().int().openapi({ description: "Events observed in the window" }),
|
|
380525
|
+
lastSeen: exports_external.string().datetime().openapi({ description: "Most recent receivedAt in the window" }),
|
|
380526
|
+
schemaVersion: exports_external.number().int().nullable().openapi({ description: "Registered schema version (null = unregistered)" }),
|
|
380527
|
+
schemaEnabled: exports_external.boolean().nullable().openapi({ description: "Whether the registered schema gate is enabled" }),
|
|
380528
|
+
consumers: exports_external.array(exports_external.string()).openapi({ description: "Durable consumer names subscribed to this type" }),
|
|
380529
|
+
automations: exports_external.array(exports_external.string()).openapi({ description: "Enabled automations triggered by this type" })
|
|
380530
|
+
}).openapi("EventTypeInventoryRow");
|
|
380411
380531
|
EventSummarySchema = exports_external.object({
|
|
380412
380532
|
id: exports_external.string().uuid().openapi({ description: "Event UUID" }),
|
|
380413
380533
|
eventType: exports_external.string().openapi({ description: "Event type" }),
|
|
@@ -384942,6 +385062,18 @@ var init_auth3 = __esm(() => {
|
|
|
384942
385062
|
});
|
|
384943
385063
|
|
|
384944
385064
|
// ../api/src/routes/v2/automations.ts
|
|
385065
|
+
async function resolveTestEvent(services, body) {
|
|
385066
|
+
if (body.event)
|
|
385067
|
+
return body.event;
|
|
385068
|
+
const row = await services.events.getById(body.eventId);
|
|
385069
|
+
return {
|
|
385070
|
+
id: row.id,
|
|
385071
|
+
type: row.eventType,
|
|
385072
|
+
payload: row.rawPayload ?? {},
|
|
385073
|
+
metadata: row.metadata ?? undefined,
|
|
385074
|
+
timestamp: row.receivedAt.getTime()
|
|
385075
|
+
};
|
|
385076
|
+
}
|
|
384945
385077
|
var automationsRoutes, conditionSchema, webhookActionSchema, sendMessageActionSchema, emitEventActionSchema, logActionSchema, callAgentActionSchema, actionSchema, debounceSchema, createAutomationSchema, updateAutomationSchema, listQuerySchema5, testAutomationSchema, logsQuerySchema;
|
|
384946
385078
|
var init_automations4 = __esm(() => {
|
|
384947
385079
|
init_dist6();
|
|
@@ -385046,7 +385178,10 @@ var init_automations4 = __esm(() => {
|
|
|
385046
385178
|
event: exports_external.object({
|
|
385047
385179
|
type: exports_external.string().min(1).describe("Event type"),
|
|
385048
385180
|
payload: exports_external.record(exports_external.string(), exports_external.unknown()).describe("Event payload")
|
|
385049
|
-
})
|
|
385181
|
+
}).optional(),
|
|
385182
|
+
eventId: exports_external.string().uuid().optional().describe("Id of a journaled omni_events row to run against")
|
|
385183
|
+
}).refine((b3) => (b3.event ? 1 : 0) + (b3.eventId ? 1 : 0) === 1, {
|
|
385184
|
+
message: 'Provide exactly one of "event" or "eventId"'
|
|
385050
385185
|
});
|
|
385051
385186
|
logsQuerySchema = exports_external.object({
|
|
385052
385187
|
limit: exports_external.coerce.number().int().min(1).max(100).default(50),
|
|
@@ -385120,15 +385255,15 @@ var init_automations4 = __esm(() => {
|
|
|
385120
385255
|
});
|
|
385121
385256
|
automationsRoutes.post("/:id/test", zValidator("json", testAutomationSchema), async (c) => {
|
|
385122
385257
|
const id = c.req.param("id");
|
|
385123
|
-
const { event } = c.req.valid("json");
|
|
385124
385258
|
const services = c.get("services");
|
|
385259
|
+
const event = await resolveTestEvent(services, c.req.valid("json"));
|
|
385125
385260
|
const result = await services.automations.test(id, event);
|
|
385126
385261
|
return c.json(result);
|
|
385127
385262
|
});
|
|
385128
385263
|
automationsRoutes.post("/:id/execute", zValidator("json", testAutomationSchema), async (c) => {
|
|
385129
385264
|
const id = c.req.param("id");
|
|
385130
|
-
const { event } = c.req.valid("json");
|
|
385131
385265
|
const services = c.get("services");
|
|
385266
|
+
const event = await resolveTestEvent(services, c.req.valid("json"));
|
|
385132
385267
|
const result = await services.automations.execute(id, event);
|
|
385133
385268
|
return c.json(result);
|
|
385134
385269
|
});
|
|
@@ -386753,6 +386888,7 @@ var init_events4 = __esm(() => {
|
|
|
386753
386888
|
personId: exports_external.string().uuid().optional(),
|
|
386754
386889
|
chatId: exports_external.string().uuid().optional(),
|
|
386755
386890
|
eventType: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386891
|
+
excludeEventType: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386756
386892
|
contentType: exports_external.string().optional().transform((v2) => v2?.split(",")),
|
|
386757
386893
|
direction: exports_external.enum(["inbound", "outbound"]).optional(),
|
|
386758
386894
|
since: optionalDateParam("since"),
|
|
@@ -386823,6 +386959,13 @@ var init_events4 = __esm(() => {
|
|
|
386823
386959
|
});
|
|
386824
386960
|
return c.json(analytics);
|
|
386825
386961
|
});
|
|
386962
|
+
eventsRoutes.get("/types", zValidator("query", exports_external.object({ since: optionalDateParam("since") })), async (c) => {
|
|
386963
|
+
const { since } = c.req.valid("query");
|
|
386964
|
+
const services = c.get("services");
|
|
386965
|
+
const automations3 = await services.automations.list({ enabled: true });
|
|
386966
|
+
const items = await services.events.getTypes({ since, automations: automations3 });
|
|
386967
|
+
return c.json({ items, meta: { since: since?.toISOString() ?? null } });
|
|
386968
|
+
});
|
|
386826
386969
|
eventsRoutes.get("/timeline/:personId", zValidator("query", timelineQuerySchema), async (c) => {
|
|
386827
386970
|
const personId = c.req.param("personId");
|
|
386828
386971
|
const query = c.req.valid("query");
|