@automagik/omni 2.260908.10 → 2.260908.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +55 -4
- package/dist/server/index.js +141 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41075,15 +41075,66 @@ function extractMessages(context, promptOverride) {
|
|
|
41075
41075
|
return { error: "message content not found in payload" };
|
|
41076
41076
|
return [messageContent];
|
|
41077
41077
|
}
|
|
41078
|
+
function buildChatlessMessages(context, promptOverride) {
|
|
41079
|
+
if (promptOverride !== undefined) {
|
|
41080
|
+
const rendered = substituteTemplate(promptOverride, context);
|
|
41081
|
+
if (!rendered)
|
|
41082
|
+
return { error: "promptOverride rendered to an empty string" };
|
|
41083
|
+
return [rendered];
|
|
41084
|
+
}
|
|
41085
|
+
if (context.event) {
|
|
41086
|
+
return [
|
|
41087
|
+
JSON.stringify({
|
|
41088
|
+
id: context.event.id,
|
|
41089
|
+
type: context.event.type,
|
|
41090
|
+
payload: context.payload,
|
|
41091
|
+
metadata: context.event.metadata,
|
|
41092
|
+
timestamp: context.event.timestamp
|
|
41093
|
+
})
|
|
41094
|
+
];
|
|
41095
|
+
}
|
|
41096
|
+
return [JSON.stringify(context.payload)];
|
|
41097
|
+
}
|
|
41098
|
+
function buildChatlessAgentCallContext(config2, context, agentId) {
|
|
41099
|
+
const messagesResult = buildChatlessMessages(context, config2.promptOverride);
|
|
41100
|
+
if ("error" in messagesResult)
|
|
41101
|
+
return messagesResult;
|
|
41102
|
+
const automationId = context.automation?.id ?? "manual";
|
|
41103
|
+
const scope = context.event?.metadata.correlationId ?? context.event?.id ?? generateId();
|
|
41104
|
+
const sessionKey = `automation:${automationId}:${scope}`;
|
|
41105
|
+
return {
|
|
41106
|
+
context: {
|
|
41107
|
+
chatless: true,
|
|
41108
|
+
instanceId: "",
|
|
41109
|
+
agentId,
|
|
41110
|
+
sessionKey,
|
|
41111
|
+
automationId,
|
|
41112
|
+
chatId: sessionKey,
|
|
41113
|
+
senderId: sessionKey,
|
|
41114
|
+
messages: messagesResult,
|
|
41115
|
+
event: context.event ? {
|
|
41116
|
+
id: context.event.id,
|
|
41117
|
+
type: context.event.type,
|
|
41118
|
+
correlationId: context.event.metadata.correlationId
|
|
41119
|
+
} : undefined
|
|
41120
|
+
}
|
|
41121
|
+
};
|
|
41122
|
+
}
|
|
41078
41123
|
function extractAgentCallContext(config2, context) {
|
|
41079
41124
|
const instanceId = config2.providerId ? substituteTemplate(config2.providerId, context) : context.payload.instanceId;
|
|
41080
|
-
if (!instanceId) {
|
|
41081
|
-
return { error: "instanceId is required (from payload or config.providerId template)" };
|
|
41082
|
-
}
|
|
41083
41125
|
const fromObj = context.payload.from;
|
|
41084
41126
|
const chatId = context.payload.chatId ?? fromObj?.id;
|
|
41085
41127
|
const senderId = fromObj?.id ?? context.payload.senderId ?? chatId;
|
|
41086
41128
|
const senderName = fromObj?.name ?? context.payload.senderName ?? context.payload.chatName;
|
|
41129
|
+
if (!instanceId || !chatId) {
|
|
41130
|
+
const chatlessAgentId = config2.agentId ? substituteTemplate(config2.agentId, context) : "";
|
|
41131
|
+
if (chatlessAgentId) {
|
|
41132
|
+
return buildChatlessAgentCallContext(config2, context, chatlessAgentId);
|
|
41133
|
+
}
|
|
41134
|
+
}
|
|
41135
|
+
if (!instanceId) {
|
|
41136
|
+
return { error: "instanceId is required (from payload or config.providerId template)" };
|
|
41137
|
+
}
|
|
41087
41138
|
if (!chatId)
|
|
41088
41139
|
return { error: "chatId not found in payload" };
|
|
41089
41140
|
if (!senderId)
|
|
@@ -136695,7 +136746,7 @@ import { fileURLToPath } from "url";
|
|
|
136695
136746
|
// package.json
|
|
136696
136747
|
var package_default = {
|
|
136697
136748
|
name: "@automagik/omni",
|
|
136698
|
-
version: "2.260908.
|
|
136749
|
+
version: "2.260908.11",
|
|
136699
136750
|
repository: {
|
|
136700
136751
|
type: "git",
|
|
136701
136752
|
url: "git+https://github.com/automagik-dev/omni.git",
|
package/dist/server/index.js
CHANGED
|
@@ -37979,15 +37979,66 @@ function extractMessages(context2, promptOverride) {
|
|
|
37979
37979
|
return { error: "message content not found in payload" };
|
|
37980
37980
|
return [messageContent];
|
|
37981
37981
|
}
|
|
37982
|
+
function buildChatlessMessages(context2, promptOverride) {
|
|
37983
|
+
if (promptOverride !== undefined) {
|
|
37984
|
+
const rendered = substituteTemplate(promptOverride, context2);
|
|
37985
|
+
if (!rendered)
|
|
37986
|
+
return { error: "promptOverride rendered to an empty string" };
|
|
37987
|
+
return [rendered];
|
|
37988
|
+
}
|
|
37989
|
+
if (context2.event) {
|
|
37990
|
+
return [
|
|
37991
|
+
JSON.stringify({
|
|
37992
|
+
id: context2.event.id,
|
|
37993
|
+
type: context2.event.type,
|
|
37994
|
+
payload: context2.payload,
|
|
37995
|
+
metadata: context2.event.metadata,
|
|
37996
|
+
timestamp: context2.event.timestamp
|
|
37997
|
+
})
|
|
37998
|
+
];
|
|
37999
|
+
}
|
|
38000
|
+
return [JSON.stringify(context2.payload)];
|
|
38001
|
+
}
|
|
38002
|
+
function buildChatlessAgentCallContext(config2, context2, agentId) {
|
|
38003
|
+
const messagesResult = buildChatlessMessages(context2, config2.promptOverride);
|
|
38004
|
+
if ("error" in messagesResult)
|
|
38005
|
+
return messagesResult;
|
|
38006
|
+
const automationId = context2.automation?.id ?? "manual";
|
|
38007
|
+
const scope = context2.event?.metadata.correlationId ?? context2.event?.id ?? generateId();
|
|
38008
|
+
const sessionKey = `automation:${automationId}:${scope}`;
|
|
38009
|
+
return {
|
|
38010
|
+
context: {
|
|
38011
|
+
chatless: true,
|
|
38012
|
+
instanceId: "",
|
|
38013
|
+
agentId,
|
|
38014
|
+
sessionKey,
|
|
38015
|
+
automationId,
|
|
38016
|
+
chatId: sessionKey,
|
|
38017
|
+
senderId: sessionKey,
|
|
38018
|
+
messages: messagesResult,
|
|
38019
|
+
event: context2.event ? {
|
|
38020
|
+
id: context2.event.id,
|
|
38021
|
+
type: context2.event.type,
|
|
38022
|
+
correlationId: context2.event.metadata.correlationId
|
|
38023
|
+
} : undefined
|
|
38024
|
+
}
|
|
38025
|
+
};
|
|
38026
|
+
}
|
|
37982
38027
|
function extractAgentCallContext(config2, context2) {
|
|
37983
38028
|
const instanceId = config2.providerId ? substituteTemplate(config2.providerId, context2) : context2.payload.instanceId;
|
|
37984
|
-
if (!instanceId) {
|
|
37985
|
-
return { error: "instanceId is required (from payload or config.providerId template)" };
|
|
37986
|
-
}
|
|
37987
38029
|
const fromObj = context2.payload.from;
|
|
37988
38030
|
const chatId = context2.payload.chatId ?? fromObj?.id;
|
|
37989
38031
|
const senderId = fromObj?.id ?? context2.payload.senderId ?? chatId;
|
|
37990
38032
|
const senderName = fromObj?.name ?? context2.payload.senderName ?? context2.payload.chatName;
|
|
38033
|
+
if (!instanceId || !chatId) {
|
|
38034
|
+
const chatlessAgentId = config2.agentId ? substituteTemplate(config2.agentId, context2) : "";
|
|
38035
|
+
if (chatlessAgentId) {
|
|
38036
|
+
return buildChatlessAgentCallContext(config2, context2, chatlessAgentId);
|
|
38037
|
+
}
|
|
38038
|
+
}
|
|
38039
|
+
if (!instanceId) {
|
|
38040
|
+
return { error: "instanceId is required (from payload or config.providerId template)" };
|
|
38041
|
+
}
|
|
37991
38042
|
if (!chatId)
|
|
37992
38043
|
return { error: "chatId not found in payload" };
|
|
37993
38044
|
if (!senderId)
|
|
@@ -251114,7 +251165,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251114
251165
|
var require_package7 = __commonJS((exports, module) => {
|
|
251115
251166
|
module.exports = {
|
|
251116
251167
|
name: "@omni/api",
|
|
251117
|
-
version: "2.260908.
|
|
251168
|
+
version: "2.260908.11",
|
|
251118
251169
|
private: true,
|
|
251119
251170
|
type: "module",
|
|
251120
251171
|
exports: {
|
|
@@ -350404,6 +350455,43 @@ class AgentRunnerService {
|
|
|
350404
350455
|
}
|
|
350405
350456
|
};
|
|
350406
350457
|
}
|
|
350458
|
+
async runChatless(context20) {
|
|
350459
|
+
const { client } = await this.getClient(context20.agentProviderId, context20.tenantId ?? null);
|
|
350460
|
+
const combinedMessage = context20.messages.join(`
|
|
350461
|
+
---
|
|
350462
|
+
`);
|
|
350463
|
+
log81.info("Running agent (chatless)", {
|
|
350464
|
+
agentProviderId: context20.agentProviderId,
|
|
350465
|
+
agentInternalId: context20.agentInternalId,
|
|
350466
|
+
agentType: context20.agentType ?? "agent",
|
|
350467
|
+
sessionKey: context20.sessionKey,
|
|
350468
|
+
messageCount: context20.messages.length
|
|
350469
|
+
});
|
|
350470
|
+
const response = await client.run({
|
|
350471
|
+
message: combinedMessage,
|
|
350472
|
+
agentId: context20.agentInternalId,
|
|
350473
|
+
agentType: context20.agentType ?? "agent",
|
|
350474
|
+
stream: false,
|
|
350475
|
+
sessionId: context20.sessionKey,
|
|
350476
|
+
userId: context20.sessionKey,
|
|
350477
|
+
timeoutMs: (context20.timeoutSeconds ?? 600) * 1000
|
|
350478
|
+
});
|
|
350479
|
+
const parts = [response.content.trim()].filter(Boolean);
|
|
350480
|
+
log81.info("Chatless agent run complete", {
|
|
350481
|
+
runId: response.runId,
|
|
350482
|
+
status: response.status,
|
|
350483
|
+
sessionId: response.sessionId
|
|
350484
|
+
});
|
|
350485
|
+
return {
|
|
350486
|
+
parts,
|
|
350487
|
+
metadata: {
|
|
350488
|
+
runId: response.runId,
|
|
350489
|
+
sessionId: response.sessionId,
|
|
350490
|
+
status: response.status,
|
|
350491
|
+
metrics: response.metrics
|
|
350492
|
+
}
|
|
350493
|
+
};
|
|
350494
|
+
}
|
|
350407
350495
|
async runOrStream(context20) {
|
|
350408
350496
|
if (!context20.instance.agentStreamMode) {
|
|
350409
350497
|
return this.run(context20);
|
|
@@ -388116,6 +388204,44 @@ var init_plugins2 = __esm(() => {
|
|
|
388116
388204
|
});
|
|
388117
388205
|
|
|
388118
388206
|
// ../api/src/plugins/automation-actions.ts
|
|
388207
|
+
async function runChatlessCallAgent(services, db3, ctx, cfg, trustedTenantId) {
|
|
388208
|
+
const agentFkId = ctx.agentId;
|
|
388209
|
+
if (!agentFkId)
|
|
388210
|
+
throw new Error("chatless call_agent requires config.agentId");
|
|
388211
|
+
const [agentRow] = await runTenantWorkDb(db3, trustedTenantId, () => scopedHandle(db3).select({
|
|
388212
|
+
name: agents.name,
|
|
388213
|
+
agentProviderId: agents.agentProviderId,
|
|
388214
|
+
agentType: agents.agentType,
|
|
388215
|
+
metadata: agents.metadata,
|
|
388216
|
+
configPath: agents.configPath,
|
|
388217
|
+
tenantId: agents.tenantId
|
|
388218
|
+
}).from(agents).where(eq(agents.id, agentFkId)).limit(1));
|
|
388219
|
+
if (!agentRow)
|
|
388220
|
+
throw new Error(`Agent not found: ${agentFkId}`);
|
|
388221
|
+
if (!agentRow.agentProviderId) {
|
|
388222
|
+
throw new Error(`Agent ${agentFkId} has no agent provider configured (required for chatless call_agent)`);
|
|
388223
|
+
}
|
|
388224
|
+
const providerAgentId = agentRow.metadata?.providerAgentId ?? agentRow.configPath ?? agentRow.name;
|
|
388225
|
+
const result = await services.agentRunner.runChatless({
|
|
388226
|
+
agentProviderId: agentRow.agentProviderId,
|
|
388227
|
+
agentInternalId: providerAgentId,
|
|
388228
|
+
agentType: cfg.agentType ?? AGENT_TYPE_MAP[agentRow.agentType] ?? "agent",
|
|
388229
|
+
tenantId: agentRow.tenantId ?? trustedTenantId ?? null,
|
|
388230
|
+
sessionKey: ctx.sessionKey ?? ctx.chatId,
|
|
388231
|
+
messages: ctx.messages,
|
|
388232
|
+
timeoutSeconds: cfg.timeoutMs ? Math.ceil(cfg.timeoutMs / 1000) : undefined
|
|
388233
|
+
});
|
|
388234
|
+
return {
|
|
388235
|
+
parts: result.parts,
|
|
388236
|
+
fullResponse: result.parts.join(`
|
|
388237
|
+
`),
|
|
388238
|
+
metadata: {
|
|
388239
|
+
runId: result.metadata.runId,
|
|
388240
|
+
sessionId: result.metadata.sessionId,
|
|
388241
|
+
status: result.metadata.status
|
|
388242
|
+
}
|
|
388243
|
+
};
|
|
388244
|
+
}
|
|
388119
388245
|
async function resolveCallAgentChatIds(services, db3, ctx, trustedTenantId) {
|
|
388120
388246
|
if (!UUID_RE3.test(ctx.chatId)) {
|
|
388121
388247
|
return { chatId: ctx.chatId, senderId: ctx.senderId };
|
|
@@ -388180,6 +388306,9 @@ function buildAutomationEngineDeps(services, db3, options = {}) {
|
|
|
388180
388306
|
await plugin12.sendMessage(instanceId, { to: recipient, content: { type: "text", text: content } });
|
|
388181
388307
|
},
|
|
388182
388308
|
callAgent: async (ctx, cfg, trustedTenantId = null) => {
|
|
388309
|
+
if (ctx.chatless) {
|
|
388310
|
+
return runChatlessCallAgent(services, db3, ctx, cfg, trustedTenantId);
|
|
388311
|
+
}
|
|
388183
388312
|
const instance4 = await runTenantWorkDb(db3, trustedTenantId, () => services.instances.getById(ctx.instanceId));
|
|
388184
388313
|
if (!instance4)
|
|
388185
388314
|
throw new Error(`Instance not found: ${ctx.instanceId}`);
|
|
@@ -388196,17 +388325,11 @@ function buildAutomationEngineDeps(services, db3, options = {}) {
|
|
|
388196
388325
|
}).from(agents).where(eq(agents.id, agentFkId)).limit(1));
|
|
388197
388326
|
if (!agentRow)
|
|
388198
388327
|
throw new Error(`Agent not found: ${agentFkId}`);
|
|
388199
|
-
const typeMap = {
|
|
388200
|
-
assistant: "agent",
|
|
388201
|
-
tool: "agent",
|
|
388202
|
-
workflow: "workflow",
|
|
388203
|
-
team: "team"
|
|
388204
|
-
};
|
|
388205
388328
|
const providerAgentId = agentRow.metadata?.providerAgentId ?? agentRow.configPath ?? agentRow.name;
|
|
388206
388329
|
const runInstance = {
|
|
388207
388330
|
...instance4,
|
|
388208
388331
|
agentProviderId: agentRow.agentProviderId ?? null,
|
|
388209
|
-
agentType: cfg.agentType ??
|
|
388332
|
+
agentType: cfg.agentType ?? AGENT_TYPE_MAP[agentRow.agentType] ?? "agent",
|
|
388210
388333
|
agentInternalId: providerAgentId,
|
|
388211
388334
|
agentSessionStrategy: cfg.sessionStrategy ?? instance4.agentSessionStrategy,
|
|
388212
388335
|
agentPrefixSenderName: cfg.prefixSenderName ?? instance4.agentPrefixSenderName,
|
|
@@ -388289,7 +388412,7 @@ function buildAutomationEngineDeps(services, db3, options = {}) {
|
|
|
388289
388412
|
}
|
|
388290
388413
|
};
|
|
388291
388414
|
}
|
|
388292
|
-
var log130, UUID_RE3;
|
|
388415
|
+
var log130, UUID_RE3, AGENT_TYPE_MAP;
|
|
388293
388416
|
var init_automation_actions = __esm(() => {
|
|
388294
388417
|
init_src();
|
|
388295
388418
|
init_src5();
|
|
@@ -388300,6 +388423,12 @@ var init_automation_actions = __esm(() => {
|
|
|
388300
388423
|
init_loader2();
|
|
388301
388424
|
log130 = createLogger("automation-actions");
|
|
388302
388425
|
UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
388426
|
+
AGENT_TYPE_MAP = {
|
|
388427
|
+
assistant: "agent",
|
|
388428
|
+
tool: "agent",
|
|
388429
|
+
workflow: "workflow",
|
|
388430
|
+
team: "team"
|
|
388431
|
+
};
|
|
388303
388432
|
});
|
|
388304
388433
|
|
|
388305
388434
|
// ../api/src/scheduler.ts
|