@automagik/omni 2.260717.7 → 2.260718.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.
- package/dist/index.js +2 -1
- package/dist/server/index.js +1773 -626
- package/package.json +2 -1
package/dist/server/index.js
CHANGED
|
@@ -156056,6 +156056,1149 @@ var init_audio_converter = __esm(() => {
|
|
|
156056
156056
|
};
|
|
156057
156057
|
});
|
|
156058
156058
|
|
|
156059
|
+
// ../channel-a2a/src/task-store.ts
|
|
156060
|
+
function taskKey(instanceId, taskId) {
|
|
156061
|
+
return `${TASK_KEY_PREFIX}/${instanceId}/${taskId}`;
|
|
156062
|
+
}
|
|
156063
|
+
function isTerminal(state) {
|
|
156064
|
+
return state === "TASK_STATE_COMPLETED" || state === "TASK_STATE_FAILED" || state === "TASK_STATE_CANCELED" || state === "TASK_STATE_REJECTED" || state === "completed" || state === "failed" || state === "canceled";
|
|
156065
|
+
}
|
|
156066
|
+
|
|
156067
|
+
class A2ATaskStore {
|
|
156068
|
+
memory = new Map;
|
|
156069
|
+
storage;
|
|
156070
|
+
constructor(storage) {
|
|
156071
|
+
this.storage = storage;
|
|
156072
|
+
}
|
|
156073
|
+
setStorage(storage) {
|
|
156074
|
+
this.storage = storage;
|
|
156075
|
+
}
|
|
156076
|
+
async createTask(params) {
|
|
156077
|
+
const now = new Date().toISOString();
|
|
156078
|
+
const task = {
|
|
156079
|
+
id: params.taskId,
|
|
156080
|
+
contextId: params.contextId,
|
|
156081
|
+
status: {
|
|
156082
|
+
state: "TASK_STATE_WORKING",
|
|
156083
|
+
timestamp: now
|
|
156084
|
+
},
|
|
156085
|
+
history: [params.message],
|
|
156086
|
+
artifacts: [],
|
|
156087
|
+
createdAt: now,
|
|
156088
|
+
lastModified: now,
|
|
156089
|
+
metadata: {
|
|
156090
|
+
...params.metadata ?? {},
|
|
156091
|
+
instanceId: params.instanceId,
|
|
156092
|
+
createdAt: now,
|
|
156093
|
+
updatedAt: now
|
|
156094
|
+
}
|
|
156095
|
+
};
|
|
156096
|
+
await this.set(params.instanceId, params.taskId, task);
|
|
156097
|
+
return task;
|
|
156098
|
+
}
|
|
156099
|
+
async appendMessage(params) {
|
|
156100
|
+
const task = await this.get(params.instanceId, params.taskId);
|
|
156101
|
+
if (!task)
|
|
156102
|
+
return null;
|
|
156103
|
+
const now = new Date().toISOString();
|
|
156104
|
+
const updated = {
|
|
156105
|
+
...task,
|
|
156106
|
+
contextId: task.contextId ?? params.contextId,
|
|
156107
|
+
status: {
|
|
156108
|
+
state: "TASK_STATE_WORKING",
|
|
156109
|
+
timestamp: now,
|
|
156110
|
+
message: params.message
|
|
156111
|
+
},
|
|
156112
|
+
history: [...task.history ?? [], params.message],
|
|
156113
|
+
lastModified: now,
|
|
156114
|
+
metadata: {
|
|
156115
|
+
...task.metadata ?? {},
|
|
156116
|
+
...params.metadata ?? {},
|
|
156117
|
+
instanceId: params.instanceId,
|
|
156118
|
+
updatedAt: now
|
|
156119
|
+
}
|
|
156120
|
+
};
|
|
156121
|
+
await this.set(params.instanceId, params.taskId, updated);
|
|
156122
|
+
return updated;
|
|
156123
|
+
}
|
|
156124
|
+
async getTask(instanceId, taskId) {
|
|
156125
|
+
return this.get(instanceId, taskId);
|
|
156126
|
+
}
|
|
156127
|
+
async listTasks(instanceId, options = {}) {
|
|
156128
|
+
const pageSize = Math.min(Math.max(options.pageSize ?? 50, 1), 100);
|
|
156129
|
+
const keys = await this.keys(instanceId);
|
|
156130
|
+
const tasks = [];
|
|
156131
|
+
const allTasks = await Promise.all(keys.map((key) => {
|
|
156132
|
+
const taskId = key.split("/").pop();
|
|
156133
|
+
return taskId ? this.get(instanceId, taskId) : Promise.resolve(null);
|
|
156134
|
+
}));
|
|
156135
|
+
for (const task of allTasks) {
|
|
156136
|
+
if (!task)
|
|
156137
|
+
continue;
|
|
156138
|
+
if (!taskMatchesListOptions(task, options))
|
|
156139
|
+
continue;
|
|
156140
|
+
tasks.push(task);
|
|
156141
|
+
}
|
|
156142
|
+
tasks.sort((a, b2) => {
|
|
156143
|
+
const aTime = String(a.lastModified ?? a.metadata?.updatedAt ?? a.status.timestamp ?? "");
|
|
156144
|
+
const bTime = String(b2.lastModified ?? b2.metadata?.updatedAt ?? b2.status.timestamp ?? "");
|
|
156145
|
+
return bTime.localeCompare(aTime);
|
|
156146
|
+
});
|
|
156147
|
+
const offset = Number.parseInt(options.pageToken ?? "0", 10);
|
|
156148
|
+
const start = Number.isFinite(offset) && offset > 0 ? offset : 0;
|
|
156149
|
+
const page = tasks.slice(start, start + pageSize).map((task) => shapeListTask(task, options));
|
|
156150
|
+
const nextOffset = start + page.length;
|
|
156151
|
+
return {
|
|
156152
|
+
tasks: page,
|
|
156153
|
+
nextPageToken: nextOffset < tasks.length ? String(nextOffset) : "",
|
|
156154
|
+
pageSize,
|
|
156155
|
+
totalSize: tasks.length
|
|
156156
|
+
};
|
|
156157
|
+
}
|
|
156158
|
+
async appendArtifact(instanceId, taskId, text) {
|
|
156159
|
+
const task = await this.get(instanceId, taskId);
|
|
156160
|
+
if (!task || isTerminal(task.status.state))
|
|
156161
|
+
return task;
|
|
156162
|
+
const now = new Date().toISOString();
|
|
156163
|
+
const artifacts = task.artifacts ?? [];
|
|
156164
|
+
const artifact = {
|
|
156165
|
+
artifactId: `artifact-${artifacts.length + 1}`,
|
|
156166
|
+
parts: [textPart(text)]
|
|
156167
|
+
};
|
|
156168
|
+
const updated = {
|
|
156169
|
+
...task,
|
|
156170
|
+
status: { state: "TASK_STATE_WORKING", timestamp: now },
|
|
156171
|
+
artifacts: [...artifacts, artifact],
|
|
156172
|
+
lastModified: now,
|
|
156173
|
+
metadata: { ...task.metadata ?? {}, updatedAt: now }
|
|
156174
|
+
};
|
|
156175
|
+
await this.set(instanceId, taskId, updated);
|
|
156176
|
+
return updated;
|
|
156177
|
+
}
|
|
156178
|
+
async updateStatus(instanceId, taskId, state, message2) {
|
|
156179
|
+
const task = await this.get(instanceId, taskId);
|
|
156180
|
+
if (!task)
|
|
156181
|
+
return null;
|
|
156182
|
+
const now = new Date().toISOString();
|
|
156183
|
+
const history3 = message2 ? [...task.history ?? [], message2] : task.history;
|
|
156184
|
+
const updated = {
|
|
156185
|
+
...task,
|
|
156186
|
+
status: { state, timestamp: now, ...message2 ? { message: message2 } : {} },
|
|
156187
|
+
history: history3,
|
|
156188
|
+
lastModified: now,
|
|
156189
|
+
metadata: { ...task.metadata ?? {}, updatedAt: now }
|
|
156190
|
+
};
|
|
156191
|
+
await this.set(instanceId, taskId, updated);
|
|
156192
|
+
return updated;
|
|
156193
|
+
}
|
|
156194
|
+
async cancelTask(instanceId, taskId) {
|
|
156195
|
+
return this.updateStatus(instanceId, taskId, "TASK_STATE_CANCELED");
|
|
156196
|
+
}
|
|
156197
|
+
async get(instanceId, taskId) {
|
|
156198
|
+
const key = taskKey(instanceId, taskId);
|
|
156199
|
+
if (this.storage) {
|
|
156200
|
+
return this.storage.get(key);
|
|
156201
|
+
}
|
|
156202
|
+
return this.memory.get(key) ?? null;
|
|
156203
|
+
}
|
|
156204
|
+
async set(instanceId, taskId, task) {
|
|
156205
|
+
const key = taskKey(instanceId, taskId);
|
|
156206
|
+
if (this.storage) {
|
|
156207
|
+
await this.storage.set(key, task);
|
|
156208
|
+
return;
|
|
156209
|
+
}
|
|
156210
|
+
this.memory.set(key, task);
|
|
156211
|
+
}
|
|
156212
|
+
async keys(instanceId) {
|
|
156213
|
+
const pattern = `${TASK_KEY_PREFIX}/${instanceId}/*`;
|
|
156214
|
+
if (this.storage) {
|
|
156215
|
+
return this.storage.keys(pattern);
|
|
156216
|
+
}
|
|
156217
|
+
const prefix = `${TASK_KEY_PREFIX}/${instanceId}/`;
|
|
156218
|
+
return Array.from(this.memory.keys()).filter((key) => key.startsWith(prefix));
|
|
156219
|
+
}
|
|
156220
|
+
}
|
|
156221
|
+
function textPart(text) {
|
|
156222
|
+
return { text, mediaType: "text/plain" };
|
|
156223
|
+
}
|
|
156224
|
+
function taskIsTerminal(task) {
|
|
156225
|
+
return isTerminal(task.status.state);
|
|
156226
|
+
}
|
|
156227
|
+
function shapeListTask(task, options) {
|
|
156228
|
+
return {
|
|
156229
|
+
...task,
|
|
156230
|
+
artifacts: options.includeArtifacts ? task.artifacts : [],
|
|
156231
|
+
history: trimHistory(task.history, options.historyLength)
|
|
156232
|
+
};
|
|
156233
|
+
}
|
|
156234
|
+
function trimHistory(history3, historyLength) {
|
|
156235
|
+
if (historyLength === undefined)
|
|
156236
|
+
return history3;
|
|
156237
|
+
if (historyLength <= 0)
|
|
156238
|
+
return [];
|
|
156239
|
+
return history3?.slice(-historyLength) ?? [];
|
|
156240
|
+
}
|
|
156241
|
+
function taskMatchesListOptions(task, options) {
|
|
156242
|
+
if (options.callerKey && task.metadata?.callerKey !== options.callerKey)
|
|
156243
|
+
return false;
|
|
156244
|
+
if (options.contextId && task.contextId !== options.contextId)
|
|
156245
|
+
return false;
|
|
156246
|
+
if (options.status && task.status.state !== options.status)
|
|
156247
|
+
return false;
|
|
156248
|
+
if (options.statusTimestampAfter && String(task.status.timestamp ?? "") <= options.statusTimestampAfter)
|
|
156249
|
+
return false;
|
|
156250
|
+
return true;
|
|
156251
|
+
}
|
|
156252
|
+
var TASK_KEY_PREFIX = "a2a-tasks";
|
|
156253
|
+
|
|
156254
|
+
// ../channel-a2a/src/a2a-handler.ts
|
|
156255
|
+
function normalizeRole(role) {
|
|
156256
|
+
if (role === "agent")
|
|
156257
|
+
return "ROLE_AGENT";
|
|
156258
|
+
if (role === "user")
|
|
156259
|
+
return "ROLE_USER";
|
|
156260
|
+
return role;
|
|
156261
|
+
}
|
|
156262
|
+
function normalizePart(part) {
|
|
156263
|
+
if (typeof part.text === "string")
|
|
156264
|
+
return textPart(part.text);
|
|
156265
|
+
if (part.data !== undefined)
|
|
156266
|
+
return { data: part.data, mediaType: part.mediaType, metadata: part.metadata };
|
|
156267
|
+
if (typeof part.url === "string") {
|
|
156268
|
+
return { url: part.url, filename: part.filename, mediaType: part.mediaType, metadata: part.metadata };
|
|
156269
|
+
}
|
|
156270
|
+
if (typeof part.raw === "string") {
|
|
156271
|
+
return { raw: part.raw, filename: part.filename, mediaType: part.mediaType, metadata: part.metadata };
|
|
156272
|
+
}
|
|
156273
|
+
if (part.type === "text" && typeof part.text === "string")
|
|
156274
|
+
return textPart(part.text);
|
|
156275
|
+
if (part.type === "data")
|
|
156276
|
+
return { data: part.data, mediaType: part.mediaType, metadata: part.metadata };
|
|
156277
|
+
if (part.type === "file" && part.file?.uri) {
|
|
156278
|
+
return {
|
|
156279
|
+
url: part.file.uri,
|
|
156280
|
+
filename: part.file.name,
|
|
156281
|
+
mediaType: part.file.mimeType,
|
|
156282
|
+
metadata: part.metadata
|
|
156283
|
+
};
|
|
156284
|
+
}
|
|
156285
|
+
return { data: part, mediaType: "application/json" };
|
|
156286
|
+
}
|
|
156287
|
+
function normalizeMessage(message2) {
|
|
156288
|
+
return {
|
|
156289
|
+
role: normalizeRole(message2.role),
|
|
156290
|
+
parts: message2.parts.map(normalizePart),
|
|
156291
|
+
messageId: message2.messageId,
|
|
156292
|
+
taskId: message2.taskId,
|
|
156293
|
+
contextId: message2.contextId,
|
|
156294
|
+
extensions: message2.extensions,
|
|
156295
|
+
metadata: message2.metadata
|
|
156296
|
+
};
|
|
156297
|
+
}
|
|
156298
|
+
function extractText(message2) {
|
|
156299
|
+
return message2.parts.filter((p2) => typeof p2.text === "string").map((p2) => p2.text).join(`
|
|
156300
|
+
`);
|
|
156301
|
+
}
|
|
156302
|
+
function isRecord(value) {
|
|
156303
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156304
|
+
}
|
|
156305
|
+
function asOmniExecutionContext(value) {
|
|
156306
|
+
if (!isRecord(value))
|
|
156307
|
+
return;
|
|
156308
|
+
const identity = value.identity;
|
|
156309
|
+
const source = value.source;
|
|
156310
|
+
const session = value.session;
|
|
156311
|
+
const trace4 = value.trace;
|
|
156312
|
+
if (!isRecord(identity) || typeof identity.userId !== "string")
|
|
156313
|
+
return;
|
|
156314
|
+
if (!isRecord(source) || typeof source.instanceId !== "string")
|
|
156315
|
+
return;
|
|
156316
|
+
if (!isRecord(session) || typeof session.id !== "string")
|
|
156317
|
+
return;
|
|
156318
|
+
if (!isRecord(trace4) || typeof trace4.id !== "string")
|
|
156319
|
+
return;
|
|
156320
|
+
return value;
|
|
156321
|
+
}
|
|
156322
|
+
function extractOmniExecutionContext(message2, requestMetadata) {
|
|
156323
|
+
const messageContext = asOmniExecutionContext(message2.metadata?.omniExecutionContext);
|
|
156324
|
+
if (messageContext)
|
|
156325
|
+
return messageContext;
|
|
156326
|
+
const requestContext = asOmniExecutionContext(requestMetadata?.omniExecutionContext);
|
|
156327
|
+
if (requestContext)
|
|
156328
|
+
return requestContext;
|
|
156329
|
+
return;
|
|
156330
|
+
}
|
|
156331
|
+
function a2aEventFrom(contextId, executionContext) {
|
|
156332
|
+
return executionContext?.customer?.externalUserId ?? executionContext?.identity.platformUserId ?? executionContext?.identity.userId ?? `a2a:${contextId}`;
|
|
156333
|
+
}
|
|
156334
|
+
function hasOmniExecutionContextExtension(message2) {
|
|
156335
|
+
return message2.extensions?.includes(OMNI_EXECUTION_CONTEXT_EXTENSION_URI) ?? false;
|
|
156336
|
+
}
|
|
156337
|
+
function jsonRpc(id, result) {
|
|
156338
|
+
return { jsonrpc: "2.0", id, result };
|
|
156339
|
+
}
|
|
156340
|
+
function jsonRpcError(id, code, message2, data) {
|
|
156341
|
+
return { jsonrpc: "2.0", id, error: { code, message: message2, ...data ? { data } : {} } };
|
|
156342
|
+
}
|
|
156343
|
+
function a2aErrorReason(code) {
|
|
156344
|
+
switch (code) {
|
|
156345
|
+
case A2A_TASK_NOT_FOUND:
|
|
156346
|
+
return "TASK_NOT_FOUND";
|
|
156347
|
+
case A2A_TASK_NOT_CANCELABLE:
|
|
156348
|
+
return "TASK_NOT_CANCELABLE";
|
|
156349
|
+
case A2A_PUSH_NOTIFICATION_NOT_SUPPORTED:
|
|
156350
|
+
return "PUSH_NOTIFICATION_NOT_SUPPORTED";
|
|
156351
|
+
case A2A_UNSUPPORTED_OPERATION:
|
|
156352
|
+
return "UNSUPPORTED_OPERATION";
|
|
156353
|
+
case A2A_CONTENT_TYPE_NOT_SUPPORTED:
|
|
156354
|
+
return "CONTENT_TYPE_NOT_SUPPORTED";
|
|
156355
|
+
case A2A_VERSION_NOT_SUPPORTED:
|
|
156356
|
+
return "VERSION_NOT_SUPPORTED";
|
|
156357
|
+
case A2A_UNAUTHORIZED:
|
|
156358
|
+
return "UNAUTHORIZED";
|
|
156359
|
+
default:
|
|
156360
|
+
return;
|
|
156361
|
+
}
|
|
156362
|
+
}
|
|
156363
|
+
function a2aErrorInfo(code, metadata) {
|
|
156364
|
+
const reason = a2aErrorReason(code);
|
|
156365
|
+
if (!reason)
|
|
156366
|
+
return;
|
|
156367
|
+
return [
|
|
156368
|
+
{
|
|
156369
|
+
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
|
|
156370
|
+
reason,
|
|
156371
|
+
domain: A2A_ERROR_DOMAIN,
|
|
156372
|
+
...metadata && Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
156373
|
+
}
|
|
156374
|
+
];
|
|
156375
|
+
}
|
|
156376
|
+
function jsonRpcA2AError(id, code, message2, metadata) {
|
|
156377
|
+
return jsonRpcError(id, code, message2, a2aErrorInfo(code, metadata));
|
|
156378
|
+
}
|
|
156379
|
+
function jsonResponse(body, status = 200) {
|
|
156380
|
+
return new Response(JSON.stringify(body), {
|
|
156381
|
+
status,
|
|
156382
|
+
headers: { "Content-Type": "application/json" }
|
|
156383
|
+
});
|
|
156384
|
+
}
|
|
156385
|
+
function validateVersion(request, method) {
|
|
156386
|
+
const url = new URL(request.url);
|
|
156387
|
+
const requested = request.headers.get("A2A-Version") ?? url.searchParams.get("A2A-Version") ?? "";
|
|
156388
|
+
if (!requested)
|
|
156389
|
+
return null;
|
|
156390
|
+
const isLegacyMethod = LEGACY_METHODS.has(method);
|
|
156391
|
+
if (requested === "1.0" && !isLegacyMethod)
|
|
156392
|
+
return null;
|
|
156393
|
+
if (requested === "0.3" && isLegacyMethod)
|
|
156394
|
+
return null;
|
|
156395
|
+
return jsonRpcA2AError(null, A2A_VERSION_NOT_SUPPORTED, `A2A version '${requested}' is not supported by method '${method}'`, { version: requested, method });
|
|
156396
|
+
}
|
|
156397
|
+
function getTaskStore(ctx) {
|
|
156398
|
+
ctx.taskStore ??= new A2ATaskStore;
|
|
156399
|
+
return ctx.taskStore;
|
|
156400
|
+
}
|
|
156401
|
+
function getCallerKey(ctx) {
|
|
156402
|
+
return typeof ctx.callerKey === "string" ? ctx.callerKey.trim() : "";
|
|
156403
|
+
}
|
|
156404
|
+
function taskOwnedByCaller(task, callerKey) {
|
|
156405
|
+
return typeof task.metadata?.callerKey === "string" && task.metadata.callerKey === callerKey;
|
|
156406
|
+
}
|
|
156407
|
+
function canAccessTask(ctx, task) {
|
|
156408
|
+
const callerKey = getCallerKey(ctx);
|
|
156409
|
+
return callerKey.length > 0 && taskOwnedByCaller(task, callerKey);
|
|
156410
|
+
}
|
|
156411
|
+
function requireCallerKey(id, ctx) {
|
|
156412
|
+
const callerKey = getCallerKey(ctx);
|
|
156413
|
+
if (callerKey.length > 0)
|
|
156414
|
+
return callerKey;
|
|
156415
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_UNAUTHORIZED, "Authentication required"), 401);
|
|
156416
|
+
}
|
|
156417
|
+
function shouldReturnImmediately(sendParams) {
|
|
156418
|
+
if (sendParams.configuration?.returnImmediately !== undefined)
|
|
156419
|
+
return sendParams.configuration.returnImmediately;
|
|
156420
|
+
if (sendParams.configuration?.blocking !== undefined)
|
|
156421
|
+
return !sendParams.configuration.blocking;
|
|
156422
|
+
return false;
|
|
156423
|
+
}
|
|
156424
|
+
function parseSendWaitMs() {
|
|
156425
|
+
const configured = Number.parseInt(process.env.A2A_SEND_WAIT_MS ?? "", 10);
|
|
156426
|
+
return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_SEND_WAIT_MS;
|
|
156427
|
+
}
|
|
156428
|
+
function taskIsSettled(task) {
|
|
156429
|
+
return taskIsTerminal(task) || task.status.state === "TASK_STATE_INPUT_REQUIRED" || task.status.state === "TASK_STATE_AUTH_REQUIRED" || task.status.state === "input-required";
|
|
156430
|
+
}
|
|
156431
|
+
async function waitForSettledTask(taskStore, instanceId, taskId, initialTask) {
|
|
156432
|
+
const deadline = Date.now() + SEND_WAIT_MS;
|
|
156433
|
+
let current = initialTask;
|
|
156434
|
+
let pollIndex = 0;
|
|
156435
|
+
while (Date.now() < deadline) {
|
|
156436
|
+
const latest = await taskStore.getTask(instanceId, taskId);
|
|
156437
|
+
if (latest)
|
|
156438
|
+
current = latest;
|
|
156439
|
+
if (taskIsSettled(current))
|
|
156440
|
+
return current;
|
|
156441
|
+
const pollMs = SEND_WAIT_POLL_BACKOFF_MS[Math.min(pollIndex, SEND_WAIT_POLL_BACKOFF_MS.length - 1)] ?? 1000;
|
|
156442
|
+
pollIndex++;
|
|
156443
|
+
await sleep2(Math.min(pollMs, Math.max(0, deadline - Date.now())));
|
|
156444
|
+
}
|
|
156445
|
+
return await taskStore.getTask(instanceId, taskId) ?? current;
|
|
156446
|
+
}
|
|
156447
|
+
function sleep2(ms) {
|
|
156448
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
156449
|
+
}
|
|
156450
|
+
async function handleA2ARequest(request, ctx) {
|
|
156451
|
+
const t0 = Date.now();
|
|
156452
|
+
let rpcReq;
|
|
156453
|
+
try {
|
|
156454
|
+
rpcReq = await request.json();
|
|
156455
|
+
} catch {
|
|
156456
|
+
return jsonResponse(jsonRpcError(null, RPC_PARSE_ERROR, "Invalid JSON payload"), 400);
|
|
156457
|
+
}
|
|
156458
|
+
if (typeof rpcReq !== "object" || rpcReq === null) {
|
|
156459
|
+
return jsonResponse(jsonRpcError(null, RPC_INVALID_REQUEST, "Request payload validation error"), 400);
|
|
156460
|
+
}
|
|
156461
|
+
if (rpcReq.jsonrpc !== "2.0" || !rpcReq.method) {
|
|
156462
|
+
return jsonResponse(jsonRpcError(rpcReq.id ?? null, RPC_INVALID_REQUEST, "Request payload validation error"), 400);
|
|
156463
|
+
}
|
|
156464
|
+
const { id, method, params } = rpcReq;
|
|
156465
|
+
ctx.callerKey = request.headers.get("x-omni-api-key-id") ?? undefined;
|
|
156466
|
+
const versionError = validateVersion(request, method);
|
|
156467
|
+
if (versionError) {
|
|
156468
|
+
return jsonResponse({ ...versionError, id }, 400);
|
|
156469
|
+
}
|
|
156470
|
+
switch (method) {
|
|
156471
|
+
case "SendMessage":
|
|
156472
|
+
case "message/send":
|
|
156473
|
+
return handleMessageSend(id, params, ctx, t0);
|
|
156474
|
+
case "SendStreamingMessage":
|
|
156475
|
+
case "message/stream":
|
|
156476
|
+
return handleMessageStream(id, params, ctx, t0);
|
|
156477
|
+
case "GetTask":
|
|
156478
|
+
case "tasks/get":
|
|
156479
|
+
return handleGetTask(id, params, ctx);
|
|
156480
|
+
case "ListTasks":
|
|
156481
|
+
return handleListTasks(id, params, ctx);
|
|
156482
|
+
case "CancelTask":
|
|
156483
|
+
case "tasks/cancel":
|
|
156484
|
+
return handleCancelTask(id, params, ctx);
|
|
156485
|
+
case "SubscribeToTask":
|
|
156486
|
+
case "tasks/resubscribe":
|
|
156487
|
+
return handleSubscribeToTask(id, params, ctx);
|
|
156488
|
+
case "GetExtendedAgentCard":
|
|
156489
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_UNSUPPORTED_OPERATION, "GetExtendedAgentCard is exposed through /api/v2/a2a/agents/:agentId/card", {
|
|
156490
|
+
method
|
|
156491
|
+
}), 400);
|
|
156492
|
+
case "CreateTaskPushNotificationConfig":
|
|
156493
|
+
case "GetTaskPushNotificationConfig":
|
|
156494
|
+
case "ListTaskPushNotificationConfigs":
|
|
156495
|
+
case "DeleteTaskPushNotificationConfig":
|
|
156496
|
+
case "tasks/pushNotificationConfig/set":
|
|
156497
|
+
case "tasks/pushNotificationConfig/get":
|
|
156498
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_UNSUPPORTED_OPERATION, `Method '${method}' is not supported`, { method }), 400);
|
|
156499
|
+
default:
|
|
156500
|
+
return jsonResponse(jsonRpcError(id, RPC_METHOD_NOT_FOUND, `Method not found: ${method}`), 404);
|
|
156501
|
+
}
|
|
156502
|
+
}
|
|
156503
|
+
async function handleMessageSend(id, params, ctx, t0) {
|
|
156504
|
+
const parsed = parseSendParams(id, params);
|
|
156505
|
+
if (parsed instanceof Response)
|
|
156506
|
+
return parsed;
|
|
156507
|
+
const { sendParams, message: message2, text } = parsed;
|
|
156508
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156509
|
+
if (callerKey instanceof Response)
|
|
156510
|
+
return callerKey;
|
|
156511
|
+
if (sendParams.configuration?.pushNotificationConfig !== undefined) {
|
|
156512
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_PUSH_NOTIFICATION_NOT_SUPPORTED, "Push notifications are not supported"), 400);
|
|
156513
|
+
}
|
|
156514
|
+
const prepared = await prepareTaskForSend(id, ctx, sendParams, message2, callerKey);
|
|
156515
|
+
if (prepared instanceof Response)
|
|
156516
|
+
return prepared;
|
|
156517
|
+
const { taskStore, task, taskId, contextId, normalizedMessage } = prepared;
|
|
156518
|
+
const timings = ctx.plugin.inboundTimings(t0);
|
|
156519
|
+
try {
|
|
156520
|
+
const correlationId = await emitMessageReceived(normalizedMessage, text, taskId, contextId, ctx, timings, sendParams.metadata);
|
|
156521
|
+
if (timings)
|
|
156522
|
+
ctx.plugin.recordT2(correlationId, timings);
|
|
156523
|
+
} catch {
|
|
156524
|
+
await taskStore.updateStatus(ctx.instanceId, taskId, "TASK_STATE_FAILED");
|
|
156525
|
+
return jsonResponse(jsonRpcError(id, RPC_INTERNAL_ERROR, "Internal error"), 500);
|
|
156526
|
+
}
|
|
156527
|
+
const responseTask = shouldReturnImmediately(sendParams) ? task : await waitForSettledTask(taskStore, ctx.instanceId, taskId, task);
|
|
156528
|
+
return jsonResponse(jsonRpc(id, { task: trimHistory2(responseTask, sendParams.configuration?.historyLength) }));
|
|
156529
|
+
}
|
|
156530
|
+
async function handleMessageStream(id, params, ctx, t0) {
|
|
156531
|
+
const parsed = parseSendParams(id, params);
|
|
156532
|
+
if (parsed instanceof Response)
|
|
156533
|
+
return parsed;
|
|
156534
|
+
const { sendParams, message: message2, text } = parsed;
|
|
156535
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156536
|
+
if (callerKey instanceof Response)
|
|
156537
|
+
return callerKey;
|
|
156538
|
+
if (sendParams.configuration?.pushNotificationConfig !== undefined) {
|
|
156539
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_PUSH_NOTIFICATION_NOT_SUPPORTED, "Push notifications are not supported"), 400);
|
|
156540
|
+
}
|
|
156541
|
+
const prepared = await prepareTaskForSend(id, ctx, sendParams, message2, callerKey);
|
|
156542
|
+
if (prepared instanceof Response)
|
|
156543
|
+
return prepared;
|
|
156544
|
+
const { taskStore, task, taskId, contextId, normalizedMessage } = prepared;
|
|
156545
|
+
const sseStream = ctx.streamStore.createPendingStream(ctx.instanceId, taskId, id, contextId);
|
|
156546
|
+
ctx.streamStore.writeTask(ctx.instanceId, taskId, task);
|
|
156547
|
+
const timings = ctx.plugin.inboundTimings(t0);
|
|
156548
|
+
try {
|
|
156549
|
+
const correlationId = await emitMessageReceived(normalizedMessage, text, taskId, contextId, ctx, timings, sendParams.metadata);
|
|
156550
|
+
if (timings)
|
|
156551
|
+
ctx.plugin.recordT2(correlationId, timings);
|
|
156552
|
+
} catch {
|
|
156553
|
+
await taskStore.updateStatus(ctx.instanceId, taskId, "TASK_STATE_FAILED");
|
|
156554
|
+
ctx.streamStore.closeStream(ctx.instanceId, taskId, "TASK_STATE_FAILED");
|
|
156555
|
+
}
|
|
156556
|
+
return new Response(sseStream, {
|
|
156557
|
+
status: 200,
|
|
156558
|
+
headers: {
|
|
156559
|
+
"Content-Type": "text/event-stream",
|
|
156560
|
+
"Cache-Control": "no-cache, no-transform",
|
|
156561
|
+
Connection: "keep-alive",
|
|
156562
|
+
"X-Accel-Buffering": "no"
|
|
156563
|
+
}
|
|
156564
|
+
});
|
|
156565
|
+
}
|
|
156566
|
+
function parseSendParams(id, params) {
|
|
156567
|
+
const parseResult = MessageSendParamsSchema.safeParse(params);
|
|
156568
|
+
if (!parseResult.success) {
|
|
156569
|
+
return jsonResponse(jsonRpcError(id, RPC_INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`), 400);
|
|
156570
|
+
}
|
|
156571
|
+
const raw = parseResult.data;
|
|
156572
|
+
const message2 = normalizeMessage(raw.message);
|
|
156573
|
+
const text = extractText(message2);
|
|
156574
|
+
if (!text.trim()) {
|
|
156575
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_CONTENT_TYPE_NOT_SUPPORTED, "Only text parts are currently supported"), 400);
|
|
156576
|
+
}
|
|
156577
|
+
return { sendParams: { ...raw, message: message2 }, message: message2, text };
|
|
156578
|
+
}
|
|
156579
|
+
async function prepareTaskForSend(id, ctx, sendParams, message2, callerKey) {
|
|
156580
|
+
const taskId = sendParams.taskId ?? message2.taskId ?? generateCorrelationId("a2a");
|
|
156581
|
+
const requestedContextId = sendParams.contextId ?? message2.contextId ?? taskId;
|
|
156582
|
+
const taskStore = getTaskStore(ctx);
|
|
156583
|
+
const existingTask = await taskStore.getTask(ctx.instanceId, taskId);
|
|
156584
|
+
const contextId = existingTask?.contextId ?? requestedContextId;
|
|
156585
|
+
const normalizedMessage = {
|
|
156586
|
+
...message2,
|
|
156587
|
+
messageId: message2.messageId ?? generateCorrelationId("msg"),
|
|
156588
|
+
taskId,
|
|
156589
|
+
contextId
|
|
156590
|
+
};
|
|
156591
|
+
const metadata = { ...sendParams.metadata ?? {}, callerKey };
|
|
156592
|
+
if (existingTask) {
|
|
156593
|
+
if (!taskOwnedByCaller(existingTask, callerKey)) {
|
|
156594
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_TASK_NOT_FOUND, "Task not found", { taskId }), 404);
|
|
156595
|
+
}
|
|
156596
|
+
const task2 = await taskStore.appendMessage({
|
|
156597
|
+
instanceId: ctx.instanceId,
|
|
156598
|
+
taskId,
|
|
156599
|
+
contextId,
|
|
156600
|
+
message: normalizedMessage,
|
|
156601
|
+
metadata
|
|
156602
|
+
});
|
|
156603
|
+
if (!task2) {
|
|
156604
|
+
return jsonResponse(jsonRpcError(id, RPC_INTERNAL_ERROR, "Internal error"), 500);
|
|
156605
|
+
}
|
|
156606
|
+
return { taskStore, task: task2, taskId, contextId, normalizedMessage };
|
|
156607
|
+
}
|
|
156608
|
+
const task = await taskStore.createTask({
|
|
156609
|
+
instanceId: ctx.instanceId,
|
|
156610
|
+
taskId,
|
|
156611
|
+
contextId,
|
|
156612
|
+
message: normalizedMessage,
|
|
156613
|
+
metadata
|
|
156614
|
+
});
|
|
156615
|
+
return { taskStore, task, taskId, contextId, normalizedMessage };
|
|
156616
|
+
}
|
|
156617
|
+
async function handleGetTask(id, params, ctx) {
|
|
156618
|
+
const parseResult = GetTaskParamsSchema.safeParse(params);
|
|
156619
|
+
if (!parseResult.success) {
|
|
156620
|
+
return jsonResponse(jsonRpcError(id, RPC_INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`), 400);
|
|
156621
|
+
}
|
|
156622
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156623
|
+
if (callerKey instanceof Response)
|
|
156624
|
+
return callerKey;
|
|
156625
|
+
const task = await getTaskStore(ctx).getTask(ctx.instanceId, parseResult.data.id);
|
|
156626
|
+
if (!task || !canAccessTask(ctx, task)) {
|
|
156627
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_TASK_NOT_FOUND, "Task not found", { taskId: parseResult.data.id }), 404);
|
|
156628
|
+
}
|
|
156629
|
+
return jsonResponse(jsonRpc(id, { task: trimHistory2(task, parseResult.data.historyLength) }));
|
|
156630
|
+
}
|
|
156631
|
+
async function handleListTasks(id, params, ctx) {
|
|
156632
|
+
const parseResult = ListTasksParamsSchema.safeParse(params ?? {});
|
|
156633
|
+
if (!parseResult.success) {
|
|
156634
|
+
return jsonResponse(jsonRpcError(id, RPC_INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`), 400);
|
|
156635
|
+
}
|
|
156636
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156637
|
+
if (callerKey instanceof Response)
|
|
156638
|
+
return callerKey;
|
|
156639
|
+
const result = await getTaskStore(ctx).listTasks(ctx.instanceId, {
|
|
156640
|
+
...parseResult.data,
|
|
156641
|
+
callerKey
|
|
156642
|
+
});
|
|
156643
|
+
return jsonResponse(jsonRpc(id, result));
|
|
156644
|
+
}
|
|
156645
|
+
async function handleCancelTask(id, params, ctx) {
|
|
156646
|
+
const parseResult = CancelTaskParamsSchema.safeParse(params);
|
|
156647
|
+
if (!parseResult.success) {
|
|
156648
|
+
return jsonResponse(jsonRpcError(id, RPC_INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`), 400);
|
|
156649
|
+
}
|
|
156650
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156651
|
+
if (callerKey instanceof Response)
|
|
156652
|
+
return callerKey;
|
|
156653
|
+
const taskStore = getTaskStore(ctx);
|
|
156654
|
+
const task = await taskStore.getTask(ctx.instanceId, parseResult.data.id);
|
|
156655
|
+
if (!task || !canAccessTask(ctx, task)) {
|
|
156656
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_TASK_NOT_FOUND, "Task not found", { taskId: parseResult.data.id }), 404);
|
|
156657
|
+
}
|
|
156658
|
+
if (taskIsTerminal(task)) {
|
|
156659
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_TASK_NOT_CANCELABLE, "Task is already terminal", { taskId: parseResult.data.id }), 400);
|
|
156660
|
+
}
|
|
156661
|
+
const canceled = await taskStore.cancelTask(ctx.instanceId, parseResult.data.id);
|
|
156662
|
+
ctx.streamStore.closeStream(ctx.instanceId, parseResult.data.id, "TASK_STATE_CANCELED");
|
|
156663
|
+
return jsonResponse(jsonRpc(id, { task: canceled }));
|
|
156664
|
+
}
|
|
156665
|
+
async function handleSubscribeToTask(id, params, ctx) {
|
|
156666
|
+
const parseResult = SubscribeToTaskParamsSchema.safeParse(params);
|
|
156667
|
+
if (!parseResult.success) {
|
|
156668
|
+
return jsonResponse(jsonRpcError(id, RPC_INVALID_PARAMS, `Invalid params: ${parseResult.error.message}`), 400);
|
|
156669
|
+
}
|
|
156670
|
+
const callerKey = requireCallerKey(id, ctx);
|
|
156671
|
+
if (callerKey instanceof Response)
|
|
156672
|
+
return callerKey;
|
|
156673
|
+
const task = await getTaskStore(ctx).getTask(ctx.instanceId, parseResult.data.id);
|
|
156674
|
+
if (!task || !canAccessTask(ctx, task)) {
|
|
156675
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_TASK_NOT_FOUND, "Task not found", { taskId: parseResult.data.id }), 404);
|
|
156676
|
+
}
|
|
156677
|
+
if (taskIsTerminal(task)) {
|
|
156678
|
+
return jsonResponse(jsonRpcA2AError(id, A2A_UNSUPPORTED_OPERATION, "Cannot subscribe to a terminal task", {
|
|
156679
|
+
taskId: parseResult.data.id
|
|
156680
|
+
}), 400);
|
|
156681
|
+
}
|
|
156682
|
+
const sseStream = ctx.streamStore.createPendingStream(ctx.instanceId, task.id, id, task.contextId ?? task.id);
|
|
156683
|
+
ctx.streamStore.writeTask(ctx.instanceId, task.id, task);
|
|
156684
|
+
return new Response(sseStream, {
|
|
156685
|
+
status: 200,
|
|
156686
|
+
headers: {
|
|
156687
|
+
"Content-Type": "text/event-stream",
|
|
156688
|
+
"Cache-Control": "no-cache, no-transform",
|
|
156689
|
+
Connection: "keep-alive",
|
|
156690
|
+
"X-Accel-Buffering": "no"
|
|
156691
|
+
}
|
|
156692
|
+
});
|
|
156693
|
+
}
|
|
156694
|
+
function trimHistory2(task, historyLength) {
|
|
156695
|
+
if (historyLength === undefined)
|
|
156696
|
+
return task;
|
|
156697
|
+
if (historyLength <= 0)
|
|
156698
|
+
return { ...task, history: [] };
|
|
156699
|
+
return { ...task, history: task.history?.slice(-historyLength) ?? [] };
|
|
156700
|
+
}
|
|
156701
|
+
async function emitMessageReceived(message2, text, taskId, contextId, ctx, timings, requestMetadata) {
|
|
156702
|
+
const correlationId = generateCorrelationId("evt");
|
|
156703
|
+
const executionContext = extractOmniExecutionContext(message2, requestMetadata);
|
|
156704
|
+
const rawPayload = {
|
|
156705
|
+
a2aTaskId: taskId,
|
|
156706
|
+
a2aContextId: contextId,
|
|
156707
|
+
a2aMessage: message2
|
|
156708
|
+
};
|
|
156709
|
+
if (executionContext) {
|
|
156710
|
+
rawPayload.omniExecutionContext = executionContext;
|
|
156711
|
+
rawPayload.omniExecutionContextExtension = hasOmniExecutionContextExtension(message2);
|
|
156712
|
+
}
|
|
156713
|
+
const eventPayload = {
|
|
156714
|
+
externalId: message2.messageId ?? taskId,
|
|
156715
|
+
chatId: taskId,
|
|
156716
|
+
from: a2aEventFrom(contextId, executionContext),
|
|
156717
|
+
...executionContext?.identity.displayName ? { senderName: executionContext.identity.displayName } : {},
|
|
156718
|
+
...executionContext?.source.threadId ? { threadId: executionContext.source.threadId } : {},
|
|
156719
|
+
content: { type: "text", text },
|
|
156720
|
+
rawPayload
|
|
156721
|
+
};
|
|
156722
|
+
const eventMetadata = {
|
|
156723
|
+
correlationId,
|
|
156724
|
+
instanceId: ctx.instanceId,
|
|
156725
|
+
channelType: ctx.channelType,
|
|
156726
|
+
...executionContext?.trace.id ? { traceId: executionContext.trace.id } : {},
|
|
156727
|
+
source: "channel:a2a",
|
|
156728
|
+
...timings ? { timings } : {}
|
|
156729
|
+
};
|
|
156730
|
+
await ctx.eventBus.publish("message.received", eventPayload, eventMetadata);
|
|
156731
|
+
return correlationId;
|
|
156732
|
+
}
|
|
156733
|
+
var A2APartSchema, MessageSendParamsSchema, GetTaskParamsSchema, ListTasksParamsSchema, CancelTaskParamsSchema, SubscribeToTaskParamsSchema, RPC_PARSE_ERROR = -32700, RPC_INVALID_REQUEST = -32600, RPC_METHOD_NOT_FOUND = -32601, RPC_INVALID_PARAMS = -32602, RPC_INTERNAL_ERROR = -32603, A2A_TASK_NOT_FOUND = -32001, A2A_TASK_NOT_CANCELABLE = -32002, A2A_PUSH_NOTIFICATION_NOT_SUPPORTED = -32003, A2A_UNSUPPORTED_OPERATION = -32004, A2A_CONTENT_TYPE_NOT_SUPPORTED = -32005, A2A_VERSION_NOT_SUPPORTED = -32009, A2A_UNAUTHORIZED = -32010, A2A_ERROR_DOMAIN = "a2a-protocol.org", DEFAULT_SEND_WAIT_MS = 30000, SEND_WAIT_POLL_BACKOFF_MS, SEND_WAIT_MS, LEGACY_METHODS;
|
|
156734
|
+
var init_a2a_handler = __esm(() => {
|
|
156735
|
+
init_src();
|
|
156736
|
+
init_zod();
|
|
156737
|
+
A2APartSchema = exports_external.object({
|
|
156738
|
+
text: exports_external.string().optional(),
|
|
156739
|
+
data: exports_external.unknown().optional(),
|
|
156740
|
+
url: exports_external.string().optional(),
|
|
156741
|
+
raw: exports_external.string().optional(),
|
|
156742
|
+
mediaType: exports_external.string().optional(),
|
|
156743
|
+
filename: exports_external.string().optional(),
|
|
156744
|
+
metadata: exports_external.record(exports_external.unknown()).optional(),
|
|
156745
|
+
type: exports_external.string().optional(),
|
|
156746
|
+
file: exports_external.object({
|
|
156747
|
+
name: exports_external.string().optional(),
|
|
156748
|
+
mimeType: exports_external.string().optional(),
|
|
156749
|
+
uri: exports_external.string().optional()
|
|
156750
|
+
}).optional()
|
|
156751
|
+
}).passthrough();
|
|
156752
|
+
MessageSendParamsSchema = exports_external.object({
|
|
156753
|
+
tenant: exports_external.string().optional(),
|
|
156754
|
+
message: exports_external.object({
|
|
156755
|
+
role: exports_external.enum(["ROLE_USER", "ROLE_AGENT", "user", "agent"]),
|
|
156756
|
+
parts: exports_external.array(A2APartSchema).min(1),
|
|
156757
|
+
messageId: exports_external.string().optional(),
|
|
156758
|
+
taskId: exports_external.string().optional(),
|
|
156759
|
+
contextId: exports_external.string().optional(),
|
|
156760
|
+
extensions: exports_external.array(exports_external.string()).optional(),
|
|
156761
|
+
metadata: exports_external.record(exports_external.unknown()).optional()
|
|
156762
|
+
}),
|
|
156763
|
+
configuration: exports_external.object({
|
|
156764
|
+
acceptedOutputModes: exports_external.array(exports_external.string()).optional(),
|
|
156765
|
+
pushNotificationConfig: exports_external.unknown().optional(),
|
|
156766
|
+
historyLength: exports_external.number().int().optional(),
|
|
156767
|
+
returnImmediately: exports_external.boolean().optional(),
|
|
156768
|
+
blocking: exports_external.boolean().optional()
|
|
156769
|
+
}).optional(),
|
|
156770
|
+
taskId: exports_external.string().optional(),
|
|
156771
|
+
contextId: exports_external.string().optional(),
|
|
156772
|
+
metadata: exports_external.record(exports_external.unknown()).optional()
|
|
156773
|
+
});
|
|
156774
|
+
GetTaskParamsSchema = exports_external.object({
|
|
156775
|
+
tenant: exports_external.string().optional(),
|
|
156776
|
+
id: exports_external.string(),
|
|
156777
|
+
historyLength: exports_external.number().int().optional()
|
|
156778
|
+
});
|
|
156779
|
+
ListTasksParamsSchema = exports_external.object({
|
|
156780
|
+
tenant: exports_external.string().optional(),
|
|
156781
|
+
contextId: exports_external.string().optional(),
|
|
156782
|
+
status: exports_external.enum([
|
|
156783
|
+
"TASK_STATE_SUBMITTED",
|
|
156784
|
+
"TASK_STATE_WORKING",
|
|
156785
|
+
"TASK_STATE_COMPLETED",
|
|
156786
|
+
"TASK_STATE_FAILED",
|
|
156787
|
+
"TASK_STATE_CANCELED",
|
|
156788
|
+
"TASK_STATE_INPUT_REQUIRED",
|
|
156789
|
+
"TASK_STATE_REJECTED",
|
|
156790
|
+
"TASK_STATE_AUTH_REQUIRED"
|
|
156791
|
+
]).optional(),
|
|
156792
|
+
historyLength: exports_external.number().int().optional(),
|
|
156793
|
+
statusTimestampAfter: exports_external.string().optional(),
|
|
156794
|
+
includeArtifacts: exports_external.boolean().optional(),
|
|
156795
|
+
pageSize: exports_external.number().int().optional(),
|
|
156796
|
+
pageToken: exports_external.string().optional()
|
|
156797
|
+
});
|
|
156798
|
+
CancelTaskParamsSchema = exports_external.object({ tenant: exports_external.string().optional(), id: exports_external.string() });
|
|
156799
|
+
SubscribeToTaskParamsSchema = exports_external.object({ tenant: exports_external.string().optional(), id: exports_external.string() });
|
|
156800
|
+
SEND_WAIT_POLL_BACKOFF_MS = [100, 250, 500, 1000];
|
|
156801
|
+
SEND_WAIT_MS = parseSendWaitMs();
|
|
156802
|
+
LEGACY_METHODS = new Set([
|
|
156803
|
+
"message/send",
|
|
156804
|
+
"message/stream",
|
|
156805
|
+
"tasks/get",
|
|
156806
|
+
"tasks/cancel",
|
|
156807
|
+
"tasks/resubscribe",
|
|
156808
|
+
"tasks/pushNotificationConfig/set",
|
|
156809
|
+
"tasks/pushNotificationConfig/get"
|
|
156810
|
+
]);
|
|
156811
|
+
});
|
|
156812
|
+
|
|
156813
|
+
// ../channel-a2a/src/agent-card.ts
|
|
156814
|
+
function strOverride(val) {
|
|
156815
|
+
return typeof val === "string" ? val : undefined;
|
|
156816
|
+
}
|
|
156817
|
+
function objectOverride(val) {
|
|
156818
|
+
return val !== null && typeof val === "object" && !Array.isArray(val) ? val : undefined;
|
|
156819
|
+
}
|
|
156820
|
+
function stringArrayOverride(val) {
|
|
156821
|
+
return Array.isArray(val) && val.every((item) => typeof item === "string") ? val : undefined;
|
|
156822
|
+
}
|
|
156823
|
+
function buildDefaultSkills(capabilities3) {
|
|
156824
|
+
const skills = [
|
|
156825
|
+
{
|
|
156826
|
+
id: "messaging",
|
|
156827
|
+
name: "Messaging",
|
|
156828
|
+
description: "Process and respond to text messages",
|
|
156829
|
+
tags: ["messaging", "chat"],
|
|
156830
|
+
inputModes: ["text/plain"],
|
|
156831
|
+
outputModes: ["text/plain"]
|
|
156832
|
+
}
|
|
156833
|
+
];
|
|
156834
|
+
if (capabilities3.includes("image") || capabilities3.includes("vision")) {
|
|
156835
|
+
skills.push({
|
|
156836
|
+
id: "vision",
|
|
156837
|
+
name: "Vision",
|
|
156838
|
+
description: "Process and describe images",
|
|
156839
|
+
tags: ["vision", "image"],
|
|
156840
|
+
inputModes: ["text/plain", "image/png", "image/jpeg", "image/webp"],
|
|
156841
|
+
outputModes: ["text/plain"]
|
|
156842
|
+
});
|
|
156843
|
+
}
|
|
156844
|
+
if (capabilities3.includes("audio") || capabilities3.includes("transcription")) {
|
|
156845
|
+
skills.push({
|
|
156846
|
+
id: "audio",
|
|
156847
|
+
name: "Audio",
|
|
156848
|
+
description: "Transcribe and process audio",
|
|
156849
|
+
tags: ["audio", "transcription"],
|
|
156850
|
+
inputModes: ["audio/mpeg", "audio/ogg", "audio/wav"],
|
|
156851
|
+
outputModes: ["text/plain"]
|
|
156852
|
+
});
|
|
156853
|
+
}
|
|
156854
|
+
return skills;
|
|
156855
|
+
}
|
|
156856
|
+
function buildAgentCard(params) {
|
|
156857
|
+
const { instanceId, instanceName, agentName, capabilities: capabilities3, agentCardOverride, baseUrl } = params;
|
|
156858
|
+
const baseCard = normalizeBaseUrl(baseUrl);
|
|
156859
|
+
const agentUrl = `${baseCard}/a2a/${instanceId}`;
|
|
156860
|
+
const skills = buildDefaultSkills(capabilities3);
|
|
156861
|
+
const overrideSkills = Array.isArray(agentCardOverride?.skills) ? agentCardOverride.skills : undefined;
|
|
156862
|
+
const overrideInterfaces = Array.isArray(agentCardOverride?.supportedInterfaces) ? agentCardOverride.supportedInterfaces : undefined;
|
|
156863
|
+
const defaultInputModes = stringArrayOverride(agentCardOverride?.defaultInputModes) ?? ["text/plain"];
|
|
156864
|
+
const defaultOutputModes = stringArrayOverride(agentCardOverride?.defaultOutputModes) ?? ["text/plain"];
|
|
156865
|
+
const card = {
|
|
156866
|
+
name: strOverride(agentCardOverride?.name) ?? agentName ?? instanceName,
|
|
156867
|
+
description: strOverride(agentCardOverride?.description) ?? `Omni agent ${agentName} on instance ${instanceName}`,
|
|
156868
|
+
version: strOverride(agentCardOverride?.version) ?? "1.0.0",
|
|
156869
|
+
supportedInterfaces: overrideInterfaces ?? [
|
|
156870
|
+
{
|
|
156871
|
+
url: agentUrl,
|
|
156872
|
+
protocolBinding: "JSONRPC",
|
|
156873
|
+
protocolVersion: "1.0"
|
|
156874
|
+
}
|
|
156875
|
+
],
|
|
156876
|
+
capabilities: {
|
|
156877
|
+
streaming: true,
|
|
156878
|
+
pushNotifications: false,
|
|
156879
|
+
extendedAgentCard: false,
|
|
156880
|
+
...objectOverride(agentCardOverride?.capabilities) ?? {}
|
|
156881
|
+
},
|
|
156882
|
+
defaultInputModes,
|
|
156883
|
+
defaultOutputModes,
|
|
156884
|
+
skills: overrideSkills ?? skills,
|
|
156885
|
+
securitySchemes: {
|
|
156886
|
+
bearerAuth: {
|
|
156887
|
+
httpAuthSecurityScheme: {
|
|
156888
|
+
scheme: "Bearer",
|
|
156889
|
+
bearerFormat: "Omni API key",
|
|
156890
|
+
description: "Use an Omni API key as a bearer token."
|
|
156891
|
+
}
|
|
156892
|
+
},
|
|
156893
|
+
apiKeyHeader: {
|
|
156894
|
+
apiKeySecurityScheme: {
|
|
156895
|
+
location: "header",
|
|
156896
|
+
name: "x-api-key",
|
|
156897
|
+
description: "Legacy Omni API key header."
|
|
156898
|
+
}
|
|
156899
|
+
},
|
|
156900
|
+
...objectOverride(agentCardOverride?.securitySchemes) ?? {}
|
|
156901
|
+
},
|
|
156902
|
+
securityRequirements: [{ schemes: { bearerAuth: { list: [] } } }, { schemes: { apiKeyHeader: { list: [] } } }]
|
|
156903
|
+
};
|
|
156904
|
+
const providerOverride = objectOverride(agentCardOverride?.provider);
|
|
156905
|
+
if (providerOverride) {
|
|
156906
|
+
card.provider = providerOverride;
|
|
156907
|
+
}
|
|
156908
|
+
const iconUrl = strOverride(agentCardOverride?.iconUrl);
|
|
156909
|
+
if (iconUrl)
|
|
156910
|
+
card.iconUrl = iconUrl;
|
|
156911
|
+
const documentationUrl = strOverride(agentCardOverride?.documentationUrl);
|
|
156912
|
+
if (documentationUrl)
|
|
156913
|
+
card.documentationUrl = documentationUrl;
|
|
156914
|
+
return card;
|
|
156915
|
+
}
|
|
156916
|
+
function normalizeBaseUrl(baseUrl) {
|
|
156917
|
+
return baseUrl.replace(/\/+$/, "");
|
|
156918
|
+
}
|
|
156919
|
+
|
|
156920
|
+
// ../channel-a2a/src/stream-store.ts
|
|
156921
|
+
class A2AStreamStore {
|
|
156922
|
+
onClose;
|
|
156923
|
+
idleCloseMs;
|
|
156924
|
+
streams = new Map;
|
|
156925
|
+
encoder = new TextEncoder;
|
|
156926
|
+
constructor(onClose, idleCloseMs = IDLE_CLOSE_MS) {
|
|
156927
|
+
this.onClose = onClose;
|
|
156928
|
+
this.idleCloseMs = idleCloseMs;
|
|
156929
|
+
}
|
|
156930
|
+
streamKey(instanceId, taskId) {
|
|
156931
|
+
return `${instanceId}:${taskId}`;
|
|
156932
|
+
}
|
|
156933
|
+
createPendingStream(instanceId, taskId, rpcId = null, contextId = taskId) {
|
|
156934
|
+
if (this.streams.size >= MAX_STREAMS) {
|
|
156935
|
+
throw new Error("Stream store capacity exceeded");
|
|
156936
|
+
}
|
|
156937
|
+
let instanceCount = 0;
|
|
156938
|
+
for (const key2 of this.streams.keys()) {
|
|
156939
|
+
if (key2.startsWith(`${instanceId}:`)) {
|
|
156940
|
+
instanceCount++;
|
|
156941
|
+
}
|
|
156942
|
+
}
|
|
156943
|
+
if (instanceCount >= MAX_STREAMS_PER_INSTANCE) {
|
|
156944
|
+
throw new Error(`Stream limit exceeded for instance ${instanceId}`);
|
|
156945
|
+
}
|
|
156946
|
+
const key = this.streamKey(instanceId, taskId);
|
|
156947
|
+
const store = this;
|
|
156948
|
+
const existing = this.streams.get(key);
|
|
156949
|
+
if (existing) {
|
|
156950
|
+
if (existing.closeTimer !== undefined)
|
|
156951
|
+
clearTimeout(existing.closeTimer);
|
|
156952
|
+
existing.close();
|
|
156953
|
+
}
|
|
156954
|
+
let entryRef;
|
|
156955
|
+
const stream = new ReadableStream({
|
|
156956
|
+
start(controller) {
|
|
156957
|
+
const entry = {
|
|
156958
|
+
enqueue: (data) => {
|
|
156959
|
+
try {
|
|
156960
|
+
controller.enqueue(data);
|
|
156961
|
+
} catch {}
|
|
156962
|
+
},
|
|
156963
|
+
close: () => {
|
|
156964
|
+
try {
|
|
156965
|
+
controller.close();
|
|
156966
|
+
} catch {}
|
|
156967
|
+
if (store.streams.get(key) === entryRef) {
|
|
156968
|
+
store.streams.delete(key);
|
|
156969
|
+
}
|
|
156970
|
+
},
|
|
156971
|
+
contextId,
|
|
156972
|
+
partIndex: 0,
|
|
156973
|
+
rpcId
|
|
156974
|
+
};
|
|
156975
|
+
entryRef = entry;
|
|
156976
|
+
store.streams.set(key, entry);
|
|
156977
|
+
entry.closeTimer = setTimeout(() => {
|
|
156978
|
+
store.closeIdleStream(instanceId, taskId);
|
|
156979
|
+
}, store.idleCloseMs);
|
|
156980
|
+
},
|
|
156981
|
+
cancel() {
|
|
156982
|
+
if (store.streams.get(key) === entryRef) {
|
|
156983
|
+
if (entryRef.closeTimer !== undefined) {
|
|
156984
|
+
clearTimeout(entryRef.closeTimer);
|
|
156985
|
+
}
|
|
156986
|
+
store.streams.delete(key);
|
|
156987
|
+
}
|
|
156988
|
+
}
|
|
156989
|
+
});
|
|
156990
|
+
return stream;
|
|
156991
|
+
}
|
|
156992
|
+
writeTask(instanceId, taskId, task) {
|
|
156993
|
+
const key = this.streamKey(instanceId, taskId);
|
|
156994
|
+
const entry = this.streams.get(key);
|
|
156995
|
+
if (!entry)
|
|
156996
|
+
return;
|
|
156997
|
+
this.resetIdleTimer(instanceId, taskId, entry);
|
|
156998
|
+
this.writeStreamResponse(entry, { task });
|
|
156999
|
+
}
|
|
157000
|
+
writePart(instanceId, taskId, text) {
|
|
157001
|
+
const key = this.streamKey(instanceId, taskId);
|
|
157002
|
+
const entry = this.streams.get(key);
|
|
157003
|
+
if (!entry)
|
|
157004
|
+
return;
|
|
157005
|
+
this.resetIdleTimer(instanceId, taskId, entry);
|
|
157006
|
+
entry.partIndex++;
|
|
157007
|
+
const artifact = {
|
|
157008
|
+
artifactId: `artifact-${entry.partIndex}`,
|
|
157009
|
+
parts: [textPart(text)]
|
|
157010
|
+
};
|
|
157011
|
+
this.writeStreamResponse(entry, {
|
|
157012
|
+
taskArtifactUpdate: {
|
|
157013
|
+
taskId,
|
|
157014
|
+
contextId: entry.contextId,
|
|
157015
|
+
artifact,
|
|
157016
|
+
index: entry.partIndex - 1
|
|
157017
|
+
}
|
|
157018
|
+
});
|
|
157019
|
+
}
|
|
157020
|
+
closeStream(instanceId, taskId, state) {
|
|
157021
|
+
const key = this.streamKey(instanceId, taskId);
|
|
157022
|
+
const entry = this.streams.get(key);
|
|
157023
|
+
if (!entry)
|
|
157024
|
+
return;
|
|
157025
|
+
if (entry.closeTimer !== undefined) {
|
|
157026
|
+
clearTimeout(entry.closeTimer);
|
|
157027
|
+
}
|
|
157028
|
+
this.writeStreamResponse(entry, {
|
|
157029
|
+
taskStatusUpdate: {
|
|
157030
|
+
taskId,
|
|
157031
|
+
contextId: entry.contextId,
|
|
157032
|
+
status: { state, timestamp: new Date().toISOString() }
|
|
157033
|
+
}
|
|
157034
|
+
});
|
|
157035
|
+
this.onClose?.(instanceId, taskId, state);
|
|
157036
|
+
entry.close();
|
|
157037
|
+
}
|
|
157038
|
+
closeIdleStream(instanceId, taskId) {
|
|
157039
|
+
const key = this.streamKey(instanceId, taskId);
|
|
157040
|
+
const entry = this.streams.get(key);
|
|
157041
|
+
if (!entry)
|
|
157042
|
+
return;
|
|
157043
|
+
if (entry.closeTimer !== undefined) {
|
|
157044
|
+
clearTimeout(entry.closeTimer);
|
|
157045
|
+
}
|
|
157046
|
+
entry.close();
|
|
157047
|
+
}
|
|
157048
|
+
hasStream(instanceId, taskId) {
|
|
157049
|
+
return this.streams.has(this.streamKey(instanceId, taskId));
|
|
157050
|
+
}
|
|
157051
|
+
resetIdleTimer(instanceId, taskId, entry) {
|
|
157052
|
+
if (entry.closeTimer !== undefined) {
|
|
157053
|
+
clearTimeout(entry.closeTimer);
|
|
157054
|
+
}
|
|
157055
|
+
entry.closeTimer = setTimeout(() => {
|
|
157056
|
+
this.closeStream(instanceId, taskId, "TASK_STATE_FAILED");
|
|
157057
|
+
}, IDLE_CLOSE_MS);
|
|
157058
|
+
}
|
|
157059
|
+
writeStreamResponse(entry, result) {
|
|
157060
|
+
const sseData = `data: ${JSON.stringify({ jsonrpc: "2.0", id: entry.rpcId, result })}
|
|
157061
|
+
|
|
157062
|
+
`;
|
|
157063
|
+
entry.enqueue(this.encoder.encode(sseData));
|
|
157064
|
+
}
|
|
157065
|
+
}
|
|
157066
|
+
var IDLE_CLOSE_MS = 30000, MAX_STREAMS = 5000, MAX_STREAMS_PER_INSTANCE = 100;
|
|
157067
|
+
var init_stream_store = () => {};
|
|
157068
|
+
|
|
157069
|
+
// ../channel-a2a/src/plugin.ts
|
|
157070
|
+
var A2A_CAPABILITIES, A2AChannelPlugin;
|
|
157071
|
+
var init_plugin = __esm(() => {
|
|
157072
|
+
init_src2();
|
|
157073
|
+
init_a2a_handler();
|
|
157074
|
+
init_stream_store();
|
|
157075
|
+
A2A_CAPABILITIES = {
|
|
157076
|
+
...DEFAULT_CAPABILITIES,
|
|
157077
|
+
canSendText: true
|
|
157078
|
+
};
|
|
157079
|
+
A2AChannelPlugin = class A2AChannelPlugin extends BaseChannelPlugin {
|
|
157080
|
+
id = "a2a";
|
|
157081
|
+
name = "A2A Protocol Server";
|
|
157082
|
+
version = "0.1.0";
|
|
157083
|
+
capabilities = A2A_CAPABILITIES;
|
|
157084
|
+
taskStore = new A2ATaskStore;
|
|
157085
|
+
streamStore = new A2AStreamStore((instanceId, taskId, state) => {
|
|
157086
|
+
this.taskStore.updateStatus(instanceId, taskId, state).catch(() => {});
|
|
157087
|
+
});
|
|
157088
|
+
async onInitialize(context2) {
|
|
157089
|
+
this.taskStore.setStorage(context2.storage);
|
|
157090
|
+
}
|
|
157091
|
+
async connect(instanceId, config2) {
|
|
157092
|
+
await this.updateInstanceStatus(instanceId, config2, {
|
|
157093
|
+
state: "connected",
|
|
157094
|
+
since: new Date,
|
|
157095
|
+
message: "A2A channel ready"
|
|
157096
|
+
});
|
|
157097
|
+
await this.emitInstanceConnected(instanceId, {});
|
|
157098
|
+
}
|
|
157099
|
+
async disconnect(instanceId) {
|
|
157100
|
+
const entry = this.instances.get(instanceId);
|
|
157101
|
+
if (entry) {
|
|
157102
|
+
await this.updateInstanceStatus(instanceId, entry.config, {
|
|
157103
|
+
state: "disconnected",
|
|
157104
|
+
since: new Date
|
|
157105
|
+
});
|
|
157106
|
+
}
|
|
157107
|
+
await this.emitInstanceDisconnected(instanceId, "disconnect requested");
|
|
157108
|
+
}
|
|
157109
|
+
async sendMessage(instanceId, message2) {
|
|
157110
|
+
const taskId = message2.to;
|
|
157111
|
+
const text = message2.content.text ?? "";
|
|
157112
|
+
if (text) {
|
|
157113
|
+
await this.taskStore.appendArtifact(instanceId, taskId, text);
|
|
157114
|
+
if (this.streamStore.hasStream(instanceId, taskId)) {
|
|
157115
|
+
this.streamStore.writePart(instanceId, taskId, text);
|
|
157116
|
+
}
|
|
157117
|
+
}
|
|
157118
|
+
return { success: true, timestamp: Date.now() };
|
|
157119
|
+
}
|
|
157120
|
+
async sendTyping(instanceId, chatId, duration) {
|
|
157121
|
+
if (duration === 0) {
|
|
157122
|
+
await this.taskStore.updateStatus(instanceId, chatId, "TASK_STATE_COMPLETED");
|
|
157123
|
+
if (this.streamStore.hasStream(instanceId, chatId)) {
|
|
157124
|
+
this.streamStore.closeStream(instanceId, chatId, "TASK_STATE_COMPLETED");
|
|
157125
|
+
}
|
|
157126
|
+
}
|
|
157127
|
+
}
|
|
157128
|
+
inboundTimings(platformTimestamp) {
|
|
157129
|
+
return this.captureInboundTimings(platformTimestamp);
|
|
157130
|
+
}
|
|
157131
|
+
recordT2(correlationId, timings) {
|
|
157132
|
+
this.captureT2(correlationId, timings);
|
|
157133
|
+
}
|
|
157134
|
+
async handleWebhook(request) {
|
|
157135
|
+
const url = new URL(request.url);
|
|
157136
|
+
const pathname = url.pathname;
|
|
157137
|
+
if (pathname.endsWith("/.well-known/agent-card.json") || pathname === "/.well-known/agent-card.json" || pathname.endsWith("/.well-known/agent.json") || pathname === "/.well-known/agent.json") {
|
|
157138
|
+
return this.handleAgentCardRequest(url);
|
|
157139
|
+
}
|
|
157140
|
+
const a2aMatch = /\/a2a\/([^/]+)\/?$/.exec(pathname);
|
|
157141
|
+
if (a2aMatch?.[1] && request.method === "POST") {
|
|
157142
|
+
const instanceId = a2aMatch[1];
|
|
157143
|
+
return handleA2ARequest(request, {
|
|
157144
|
+
instanceId,
|
|
157145
|
+
eventBus: this.eventBus,
|
|
157146
|
+
streamStore: this.streamStore,
|
|
157147
|
+
taskStore: this.taskStore,
|
|
157148
|
+
channelType: "a2a",
|
|
157149
|
+
plugin: this
|
|
157150
|
+
});
|
|
157151
|
+
}
|
|
157152
|
+
return new Response("Not Found", { status: 404 });
|
|
157153
|
+
}
|
|
157154
|
+
handleAgentCardRequest(url) {
|
|
157155
|
+
const instanceId = url.searchParams.get("instanceId");
|
|
157156
|
+
if (!instanceId) {
|
|
157157
|
+
return new Response(JSON.stringify({ error: "instanceId query parameter required" }), {
|
|
157158
|
+
status: 400,
|
|
157159
|
+
headers: { "Content-Type": "application/json" }
|
|
157160
|
+
});
|
|
157161
|
+
}
|
|
157162
|
+
const baseUrl = `${url.protocol}//${url.host}`;
|
|
157163
|
+
const card = buildAgentCard({
|
|
157164
|
+
instanceId,
|
|
157165
|
+
instanceName: instanceId,
|
|
157166
|
+
agentName: "Omni Agent",
|
|
157167
|
+
capabilities: [],
|
|
157168
|
+
agentCardOverride: null,
|
|
157169
|
+
baseUrl,
|
|
157170
|
+
extended: false
|
|
157171
|
+
});
|
|
157172
|
+
return new Response(JSON.stringify(card), {
|
|
157173
|
+
status: 200,
|
|
157174
|
+
headers: { "Content-Type": "application/json" }
|
|
157175
|
+
});
|
|
157176
|
+
}
|
|
157177
|
+
};
|
|
157178
|
+
});
|
|
157179
|
+
|
|
157180
|
+
// ../channel-a2a/src/index.ts
|
|
157181
|
+
var exports_src2 = {};
|
|
157182
|
+
__export(exports_src2, {
|
|
157183
|
+
handleA2ARequest: () => handleA2ARequest,
|
|
157184
|
+
default: () => src_default6,
|
|
157185
|
+
buildAgentCard: () => buildAgentCard,
|
|
157186
|
+
A2ATaskStore: () => A2ATaskStore,
|
|
157187
|
+
A2AStreamStore: () => A2AStreamStore,
|
|
157188
|
+
A2AChannelPlugin: () => A2AChannelPlugin
|
|
157189
|
+
});
|
|
157190
|
+
var plugin7, src_default6;
|
|
157191
|
+
var init_src4 = __esm(() => {
|
|
157192
|
+
init_src2();
|
|
157193
|
+
init_plugin();
|
|
157194
|
+
init_plugin();
|
|
157195
|
+
init_stream_store();
|
|
157196
|
+
init_a2a_handler();
|
|
157197
|
+
plugin7 = new A2AChannelPlugin;
|
|
157198
|
+
channelRegistry.register(plugin7);
|
|
157199
|
+
src_default6 = plugin7;
|
|
157200
|
+
});
|
|
157201
|
+
|
|
156059
157202
|
// ../../node_modules/.bun/@sentry+core@10.52.0/node_modules/@sentry/core/build/esm/debug-build.js
|
|
156060
157203
|
var DEBUG_BUILD;
|
|
156061
157204
|
var init_debug_build = __esm(() => {
|
|
@@ -171126,7 +172269,7 @@ function shouldIgnoreSpansForIncomingRequest(request, {
|
|
|
171126
172269
|
ignoreStaticAssets,
|
|
171127
172270
|
ignoreIncomingRequests
|
|
171128
172271
|
}) {
|
|
171129
|
-
if (
|
|
172272
|
+
if (import_core54.isTracingSuppressed(import_api7.context.active())) {
|
|
171130
172273
|
return true;
|
|
171131
172274
|
}
|
|
171132
172275
|
const urlPath = request.url;
|
|
@@ -171178,7 +172321,7 @@ function getIncomingRequestAttributesOnResponse(request, response) {
|
|
|
171178
172321
|
[import_semantic_conventions.SEMATTRS_HTTP_STATUS_CODE]: statusCode,
|
|
171179
172322
|
"http.status_text": statusMessage?.toUpperCase()
|
|
171180
172323
|
};
|
|
171181
|
-
const rpcMetadata =
|
|
172324
|
+
const rpcMetadata = import_core54.getRPCMetadata(import_api7.context.active());
|
|
171182
172325
|
if (socket) {
|
|
171183
172326
|
const { localAddress, localPort, remoteAddress, remotePort } = socket;
|
|
171184
172327
|
newAttributes[import_semantic_conventions.SEMATTRS_NET_HOST_IP] = localAddress;
|
|
@@ -171188,7 +172331,7 @@ function getIncomingRequestAttributesOnResponse(request, response) {
|
|
|
171188
172331
|
}
|
|
171189
172332
|
newAttributes[import_semantic_conventions.SEMATTRS_HTTP_STATUS_CODE] = statusCode;
|
|
171190
172333
|
newAttributes["http.status_text"] = (statusMessage || "").toUpperCase();
|
|
171191
|
-
if (rpcMetadata?.type ===
|
|
172334
|
+
if (rpcMetadata?.type === import_core54.RPCType.HTTP && rpcMetadata.route !== undefined) {
|
|
171192
172335
|
const routeName = rpcMetadata.route;
|
|
171193
172336
|
newAttributes[import_semantic_conventions.ATTR_HTTP_ROUTE] = routeName;
|
|
171194
172337
|
}
|
|
@@ -171203,7 +172346,7 @@ function shouldFilterStatusCode(statusCode, dropForStatusCodes) {
|
|
|
171203
172346
|
return statusCode >= min && statusCode <= max;
|
|
171204
172347
|
});
|
|
171205
172348
|
}
|
|
171206
|
-
var import_api7,
|
|
172349
|
+
var import_api7, import_core54, import_semantic_conventions, INTEGRATION_NAME8 = "Http.ServerSpans", _httpServerSpansIntegration = (options = {}) => {
|
|
171207
172350
|
const ignoreStaticAssets = options.ignoreStaticAssets ?? true;
|
|
171208
172351
|
const ignoreIncomingRequests = options.ignoreIncomingRequests;
|
|
171209
172352
|
const ignoreStatusCodes = options.ignoreStatusCodes ?? [
|
|
@@ -171268,10 +172411,10 @@ var import_api7, import_core53, import_semantic_conventions, INTEGRATION_NAME8 =
|
|
|
171268
172411
|
applyCustomAttributesOnSpan?.(span, request, response);
|
|
171269
172412
|
onSpanCreated?.(span, request, response);
|
|
171270
172413
|
const rpcMetadata = {
|
|
171271
|
-
type:
|
|
172414
|
+
type: import_core54.RPCType.HTTP,
|
|
171272
172415
|
span
|
|
171273
172416
|
};
|
|
171274
|
-
return import_api7.context.with(
|
|
172417
|
+
return import_api7.context.with(import_core54.setRPCMetadata(import_api7.trace.setSpan(import_api7.context.active(), span), rpcMetadata), () => {
|
|
171275
172418
|
import_api7.context.bind(import_api7.context.active(), request);
|
|
171276
172419
|
import_api7.context.bind(import_api7.context.active(), response);
|
|
171277
172420
|
let isEnded = false;
|
|
@@ -171333,7 +172476,7 @@ var init_httpServerSpansIntegration = __esm(() => {
|
|
|
171333
172476
|
init_debug_build2();
|
|
171334
172477
|
init_httpServerIntegration();
|
|
171335
172478
|
import_api7 = __toESM(require_src(), 1);
|
|
171336
|
-
|
|
172479
|
+
import_core54 = __toESM(require_src6(), 1);
|
|
171337
172480
|
import_semantic_conventions = __toESM(require_src5(), 1);
|
|
171338
172481
|
httpServerSpansIntegration = _httpServerSpansIntegration;
|
|
171339
172482
|
});
|
|
@@ -173167,13 +174310,13 @@ import { subscribe as subscribe2 } from "diagnostics_channel";
|
|
|
173167
174310
|
import { errorMonitor as errorMonitor2 } from "events";
|
|
173168
174311
|
import * as http from "http";
|
|
173169
174312
|
import * as https from "https";
|
|
173170
|
-
var import_api8,
|
|
174313
|
+
var import_api8, import_core57, import_instrumentation, FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL, SentryHttpInstrumentation;
|
|
173171
174314
|
var init_SentryHttpInstrumentation = __esm(() => {
|
|
173172
174315
|
init_esm();
|
|
173173
174316
|
init_constants10();
|
|
173174
174317
|
init_nodeVersion();
|
|
173175
174318
|
import_api8 = __toESM(require_src(), 1);
|
|
173176
|
-
|
|
174319
|
+
import_core57 = __toESM(require_src6(), 1);
|
|
173177
174320
|
import_instrumentation = __toESM(require_src8(), 1);
|
|
173178
174321
|
FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL = NODE_VERSION.major === 22 && NODE_VERSION.minor >= 12 || NODE_VERSION.major === 23 && NODE_VERSION.minor >= 2 || NODE_VERSION.major >= 24;
|
|
173179
174322
|
SentryHttpInstrumentation = class SentryHttpInstrumentation extends import_instrumentation.InstrumentationBase {
|
|
@@ -173188,7 +174331,7 @@ var init_SentryHttpInstrumentation = __esm(() => {
|
|
|
173188
174331
|
...options,
|
|
173189
174332
|
spans: options.createSpansForOutgoingRequests && (options.spans ?? true),
|
|
173190
174333
|
ignoreOutgoingRequests(url, request) {
|
|
173191
|
-
return
|
|
174334
|
+
return import_core57.isTracingSuppressed(import_api8.context.active()) || !!options.ignoreOutgoingRequests?.(url, getRequestOptions(request));
|
|
173192
174335
|
},
|
|
173193
174336
|
outgoingRequestHook(span, request) {
|
|
173194
174337
|
options.outgoingRequestHook?.(span, request);
|
|
@@ -173408,13 +174551,13 @@ var init_outgoingFetchRequest = __esm(() => {
|
|
|
173408
174551
|
|
|
173409
174552
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+6488de8736d8e524/node_modules/@sentry/node-core/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js
|
|
173410
174553
|
import * as diagch from "diagnostics_channel";
|
|
173411
|
-
var import_api9,
|
|
174554
|
+
var import_api9, import_core60, import_instrumentation2, SentryNodeFetchInstrumentation;
|
|
173412
174555
|
var init_SentryNodeFetchInstrumentation = __esm(() => {
|
|
173413
174556
|
init_esm();
|
|
173414
174557
|
init_nodeVersion();
|
|
173415
174558
|
init_outgoingFetchRequest();
|
|
173416
174559
|
import_api9 = __toESM(require_src(), 1);
|
|
173417
|
-
|
|
174560
|
+
import_core60 = __toESM(require_src6(), 1);
|
|
173418
174561
|
import_instrumentation2 = __toESM(require_src8(), 1);
|
|
173419
174562
|
SentryNodeFetchInstrumentation = class SentryNodeFetchInstrumentation extends import_instrumentation2.InstrumentationBase {
|
|
173420
174563
|
constructor(config2 = {}) {
|
|
@@ -173485,7 +174628,7 @@ var init_SentryNodeFetchInstrumentation = __esm(() => {
|
|
|
173485
174628
|
});
|
|
173486
174629
|
}
|
|
173487
174630
|
_shouldIgnoreOutgoingRequest(request) {
|
|
173488
|
-
if (
|
|
174631
|
+
if (import_core60.isTracingSuppressed(import_api9.context.active())) {
|
|
173489
174632
|
return true;
|
|
173490
174633
|
}
|
|
173491
174634
|
const url = getAbsoluteUrl2(request.origin, request.path);
|
|
@@ -175845,7 +176988,7 @@ function makeTraceState({
|
|
|
175845
176988
|
sampled
|
|
175846
176989
|
}) {
|
|
175847
176990
|
const dscString = dsc ? dynamicSamplingContextToSentryBaggageHeader(dsc) : undefined;
|
|
175848
|
-
const traceStateBase = new
|
|
176991
|
+
const traceStateBase = new import_core63.TraceState;
|
|
175849
176992
|
const traceStateWithDsc = dscString ? traceStateBase.set(SENTRY_TRACE_STATE_DSC, dscString) : traceStateBase;
|
|
175850
176993
|
return sampled === false ? traceStateWithDsc.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, "1") : traceStateWithDsc;
|
|
175851
176994
|
}
|
|
@@ -175969,13 +177112,13 @@ function _startSpan(options, callback, autoEnd) {
|
|
|
175969
177112
|
return wrapper(() => {
|
|
175970
177113
|
const activeCtx = getContext(options.scope, options.forceTransaction);
|
|
175971
177114
|
const missingRequiredParent = options.onlyIfParent && !import_api10.trace.getSpan(activeCtx);
|
|
175972
|
-
const ctx = missingRequiredParent ?
|
|
177115
|
+
const ctx = missingRequiredParent ? import_core63.suppressTracing(activeCtx) : activeCtx;
|
|
175973
177116
|
if (missingRequiredParent) {
|
|
175974
177117
|
getClient()?.recordDroppedEvent("no_parent_span", "span");
|
|
175975
177118
|
}
|
|
175976
177119
|
const spanOptions = getSpanOptions(options);
|
|
175977
177120
|
if (!hasSpansEnabled()) {
|
|
175978
|
-
const suppressedCtx =
|
|
177121
|
+
const suppressedCtx = import_core63.isTracingSuppressed(ctx) ? ctx : import_core63.suppressTracing(ctx);
|
|
175979
177122
|
return import_api10.context.with(suppressedCtx, () => {
|
|
175980
177123
|
return tracer.startActiveSpan(name, spanOptions, suppressedCtx, (span) => {
|
|
175981
177124
|
patchSpanEnd(span);
|
|
@@ -176012,13 +177155,13 @@ function startInactiveSpan2(options) {
|
|
|
176012
177155
|
return wrapper(() => {
|
|
176013
177156
|
const activeCtx = getContext(options.scope, options.forceTransaction);
|
|
176014
177157
|
const missingRequiredParent = options.onlyIfParent && !import_api10.trace.getSpan(activeCtx);
|
|
176015
|
-
let ctx = missingRequiredParent ?
|
|
177158
|
+
let ctx = missingRequiredParent ? import_core63.suppressTracing(activeCtx) : activeCtx;
|
|
176016
177159
|
if (missingRequiredParent) {
|
|
176017
177160
|
getClient()?.recordDroppedEvent("no_parent_span", "span");
|
|
176018
177161
|
}
|
|
176019
177162
|
const spanOptions = getSpanOptions(options);
|
|
176020
177163
|
if (!hasSpansEnabled()) {
|
|
176021
|
-
ctx =
|
|
177164
|
+
ctx = import_core63.isTracingSuppressed(ctx) ? ctx : import_core63.suppressTracing(ctx);
|
|
176022
177165
|
}
|
|
176023
177166
|
const span = tracer.startSpan(name, spanOptions, ctx);
|
|
176024
177167
|
patchSpanEnd(span);
|
|
@@ -176127,7 +177270,7 @@ function getActiveSpanWrapper2(parentSpan) {
|
|
|
176127
177270
|
} : (callback) => callback();
|
|
176128
177271
|
}
|
|
176129
177272
|
function suppressTracing2(callback) {
|
|
176130
|
-
const ctx =
|
|
177273
|
+
const ctx = import_core63.suppressTracing(import_api10.context.active());
|
|
176131
177274
|
return import_api10.context.with(ctx, callback);
|
|
176132
177275
|
}
|
|
176133
177276
|
function setupEventContextTrace(client) {
|
|
@@ -176814,7 +177957,7 @@ function wrapSamplingDecision({
|
|
|
176814
177957
|
function getBaseTraceState(context8, spanAttributes) {
|
|
176815
177958
|
const parentSpan = import_api10.trace.getSpan(context8);
|
|
176816
177959
|
const parentContext = parentSpan?.spanContext();
|
|
176817
|
-
let traceState = parentContext?.traceState || new
|
|
177960
|
+
let traceState = parentContext?.traceState || new import_core63.TraceState;
|
|
176818
177961
|
const url = spanAttributes[import_semantic_conventions2.SEMATTRS_HTTP_URL] || spanAttributes[import_semantic_conventions2.ATTR_URL_FULL];
|
|
176819
177962
|
if (url && typeof url === "string") {
|
|
176820
177963
|
traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
|
|
@@ -176875,12 +178018,12 @@ function getSentryResource(serviceNameFallback) {
|
|
|
176875
178018
|
...otelResourceAttrs,
|
|
176876
178019
|
...otelServiceName ? { [import_semantic_conventions2.ATTR_SERVICE_NAME]: otelServiceName } : {},
|
|
176877
178020
|
[import_semantic_conventions2.ATTR_SERVICE_VERSION]: SDK_VERSION,
|
|
176878
|
-
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_LANGUAGE]:
|
|
176879
|
-
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_NAME]:
|
|
176880
|
-
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_VERSION]:
|
|
178021
|
+
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_LANGUAGE]: import_core63.SDK_INFO[import_semantic_conventions2.ATTR_TELEMETRY_SDK_LANGUAGE],
|
|
178022
|
+
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_NAME]: import_core63.SDK_INFO[import_semantic_conventions2.ATTR_TELEMETRY_SDK_NAME],
|
|
178023
|
+
[import_semantic_conventions2.ATTR_TELEMETRY_SDK_VERSION]: import_core63.SDK_INFO[import_semantic_conventions2.ATTR_TELEMETRY_SDK_VERSION]
|
|
176881
178024
|
});
|
|
176882
178025
|
}
|
|
176883
|
-
var api, import_api10, import_semantic_conventions2,
|
|
178026
|
+
var api, import_api10, import_semantic_conventions2, import_core63, import_sdk_trace_base, SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = "sentry.parentIsRemote", SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = "sentry.graphql.operation", SENTRY_TRACE_HEADER2 = "sentry-trace", SENTRY_BAGGAGE_HEADER2 = "baggage", SENTRY_TRACE_STATE_DSC = "sentry.dsc", SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING = "sentry.sampled_not_recording", SENTRY_TRACE_STATE_URL = "sentry.url", SENTRY_TRACE_STATE_SAMPLE_RAND = "sentry.sample_rand", SENTRY_TRACE_STATE_SAMPLE_RATE = "sentry.sample_rate", SENTRY_TRACE_STATE_CHILD_IGNORED = "sentry.ignored", SENTRY_TRACE_STATE_SEGMENT_IGNORED = "sentry.segment_ignored", SENTRY_SCOPES_CONTEXT_KEY, SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY, SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, SCOPE_CONTEXT_FIELD = "_scopeContext", setupElements, SentryPropagator, canonicalGrpcErrorCodesMap, isStatusErrorMessageValid = (message2) => {
|
|
176884
178027
|
return Object.values(canonicalGrpcErrorCodesMap).includes(message2);
|
|
176885
178028
|
}, MAX_SPAN_COUNT2 = 1000, DEFAULT_TIMEOUT = 300;
|
|
176886
178029
|
var init_resource_Bhpm2sLf = __esm(() => {
|
|
@@ -176889,21 +178032,21 @@ var init_resource_Bhpm2sLf = __esm(() => {
|
|
|
176889
178032
|
api = __toESM(require_src(), 1);
|
|
176890
178033
|
import_api10 = __toESM(require_src(), 1);
|
|
176891
178034
|
import_semantic_conventions2 = __toESM(require_src5(), 1);
|
|
176892
|
-
|
|
178035
|
+
import_core63 = __toESM(require_src6(), 1);
|
|
176893
178036
|
import_sdk_trace_base = __toESM(require_src10(), 1);
|
|
176894
178037
|
SENTRY_SCOPES_CONTEXT_KEY = import_api10.createContextKey("sentry_scopes");
|
|
176895
178038
|
SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = import_api10.createContextKey("sentry_fork_isolation_scope");
|
|
176896
178039
|
SENTRY_FORK_SET_SCOPE_CONTEXT_KEY = import_api10.createContextKey("sentry_fork_set_scope");
|
|
176897
178040
|
SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY = import_api10.createContextKey("sentry_fork_set_isolation_scope");
|
|
176898
178041
|
setupElements = new Set;
|
|
176899
|
-
SentryPropagator = class SentryPropagator extends
|
|
178042
|
+
SentryPropagator = class SentryPropagator extends import_core63.W3CBaggagePropagator {
|
|
176900
178043
|
constructor() {
|
|
176901
178044
|
super();
|
|
176902
178045
|
setIsSetup("SentryPropagator");
|
|
176903
178046
|
this._urlMatchesTargetsMap = new LRUMap(100);
|
|
176904
178047
|
}
|
|
176905
178048
|
inject(context8, carrier, setter) {
|
|
176906
|
-
if (
|
|
178049
|
+
if (import_core63.isTracingSuppressed(context8)) {
|
|
176907
178050
|
DEBUG_BUILD3 && debug32.log("[Tracing] Not injecting trace data for url because tracing is suppressed.");
|
|
176908
178051
|
return;
|
|
176909
178052
|
}
|
|
@@ -179752,12 +180895,12 @@ var init_http3 = __esm(() => {
|
|
|
179752
180895
|
// ../../node_modules/.bun/@sentry+node@10.52.0+1b9a589cee1ff949/node_modules/@sentry/node/build/esm/integrations/node-fetch/vendored/undici.js
|
|
179753
180896
|
import * as diagch2 from "diagnostics_channel";
|
|
179754
180897
|
import { URL as URL4 } from "url";
|
|
179755
|
-
var import_instrumentation5, import_api15,
|
|
180898
|
+
var import_instrumentation5, import_api15, import_core92, import_semantic_conventions3, PACKAGE_NAME = "@sentry/instrumentation-undici", UndiciInstrumentation;
|
|
179756
180899
|
var init_undici = __esm(() => {
|
|
179757
180900
|
init_esm();
|
|
179758
180901
|
import_instrumentation5 = __toESM(require_src8(), 1);
|
|
179759
180902
|
import_api15 = __toESM(require_src(), 1);
|
|
179760
|
-
|
|
180903
|
+
import_core92 = __toESM(require_src6(), 1);
|
|
179761
180904
|
import_semantic_conventions3 = __toESM(require_src5(), 1);
|
|
179762
180905
|
UndiciInstrumentation = class UndiciInstrumentation extends import_instrumentation5.InstrumentationBase {
|
|
179763
180906
|
__init() {
|
|
@@ -179856,7 +180999,7 @@ var init_undici = __esm(() => {
|
|
|
179856
180999
|
if (shouldIgnoreReq) {
|
|
179857
181000
|
return;
|
|
179858
181001
|
}
|
|
179859
|
-
const startTime =
|
|
181002
|
+
const startTime = import_core92.hrTime();
|
|
179860
181003
|
let requestUrl;
|
|
179861
181004
|
try {
|
|
179862
181005
|
requestUrl = new URL4(request2.path, request2.origin);
|
|
@@ -180029,7 +181172,7 @@ var init_undici = __esm(() => {
|
|
|
180029
181172
|
metricsAttributes[key] = attributes[key];
|
|
180030
181173
|
}
|
|
180031
181174
|
});
|
|
180032
|
-
const durationSeconds =
|
|
181175
|
+
const durationSeconds = import_core92.hrTimeToMilliseconds(import_core92.hrTimeDuration(startTime, import_core92.hrTime())) / 1000;
|
|
180033
181176
|
this._httpClientDurationHistogram.record(durationSeconds, metricsAttributes);
|
|
180034
181177
|
}
|
|
180035
181178
|
getRequestMethod(original) {
|
|
@@ -180574,7 +181717,7 @@ var init_debug_build3 = __esm(() => {
|
|
|
180574
181717
|
});
|
|
180575
181718
|
|
|
180576
181719
|
// ../../node_modules/.bun/@sentry+node@10.52.0+1b9a589cee1ff949/node_modules/@sentry/node/build/esm/integrations/tracing/express.js
|
|
180577
|
-
var import_instrumentation6, import_api16,
|
|
181720
|
+
var import_instrumentation6, import_api16, import_core95, INTEGRATION_NAME23 = "Express", SUPPORTED_VERSIONS, instrumentExpress, ExpressInstrumentation, _expressIntegration = (options) => {
|
|
180578
181721
|
return {
|
|
180579
181722
|
name: INTEGRATION_NAME23,
|
|
180580
181723
|
setupOnce() {
|
|
@@ -180588,7 +181731,7 @@ var init_express2 = __esm(() => {
|
|
|
180588
181731
|
init_debug_build3();
|
|
180589
181732
|
import_instrumentation6 = __toESM(require_src8(), 1);
|
|
180590
181733
|
import_api16 = __toESM(require_src(), 1);
|
|
180591
|
-
|
|
181734
|
+
import_core95 = __toESM(require_src6(), 1);
|
|
180592
181735
|
SUPPORTED_VERSIONS = [">=4.0.0 <6"];
|
|
180593
181736
|
instrumentExpress = generateInstrumentOnce(INTEGRATION_NAME23, (options) => new ExpressInstrumentation(options));
|
|
180594
181737
|
ExpressInstrumentation = class ExpressInstrumentation extends import_instrumentation6.InstrumentationBase {
|
|
@@ -180601,8 +181744,8 @@ var init_express2 = __esm(() => {
|
|
|
180601
181744
|
patchExpressModule(express, () => ({
|
|
180602
181745
|
...this.getConfig(),
|
|
180603
181746
|
onRouteResolved(route) {
|
|
180604
|
-
const rpcMetadata =
|
|
180605
|
-
if (route && rpcMetadata?.type ===
|
|
181747
|
+
const rpcMetadata = import_core95.getRPCMetadata(import_api16.context.active());
|
|
181748
|
+
if (route && rpcMetadata?.type === import_core95.RPCType.HTTP) {
|
|
180606
181749
|
rpcMetadata.route = route;
|
|
180607
181750
|
}
|
|
180608
181751
|
}
|
|
@@ -184498,13 +185641,13 @@ function addFastifyV3SpanAttributes(span) {
|
|
|
184498
185641
|
span.updateName(updatedName);
|
|
184499
185642
|
}
|
|
184500
185643
|
}
|
|
184501
|
-
var import_api18,
|
|
185644
|
+
var import_api18, import_core97, import_instrumentation7, import_semantic_conventions4, PACKAGE_VERSION = "0.1.0", PACKAGE_NAME2 = "@sentry/instrumentation-fastify-v3", ANONYMOUS_NAME = "anonymous", hooksNamesToWrap, FastifyInstrumentationV3;
|
|
184502
185645
|
var init_instrumentation = __esm(() => {
|
|
184503
185646
|
init_esm();
|
|
184504
185647
|
init_AttributeNames();
|
|
184505
185648
|
init_utils10();
|
|
184506
185649
|
import_api18 = __toESM(require_src(), 1);
|
|
184507
|
-
|
|
185650
|
+
import_core97 = __toESM(require_src6(), 1);
|
|
184508
185651
|
import_instrumentation7 = __toESM(require_src8(), 1);
|
|
184509
185652
|
import_semantic_conventions4 = __toESM(require_src5(), 1);
|
|
184510
185653
|
hooksNamesToWrap = new Set([
|
|
@@ -184537,9 +185680,9 @@ var init_instrumentation = __esm(() => {
|
|
|
184537
185680
|
}
|
|
184538
185681
|
instrumentation._wrap(reply, "send", instrumentation._patchSend());
|
|
184539
185682
|
const anyRequest = request2;
|
|
184540
|
-
const rpcMetadata =
|
|
185683
|
+
const rpcMetadata = import_core97.getRPCMetadata(import_api18.context.active());
|
|
184541
185684
|
const routeName = anyRequest.routeOptions ? anyRequest.routeOptions.url : request2.routerPath;
|
|
184542
|
-
if (routeName && rpcMetadata?.type ===
|
|
185685
|
+
if (routeName && rpcMetadata?.type === import_core97.RPCType.HTTP) {
|
|
184543
185686
|
rpcMetadata.route = routeName;
|
|
184544
185687
|
}
|
|
184545
185688
|
const method = request2.method || "GET";
|
|
@@ -184776,10 +185919,10 @@ var init_fastify = __esm(() => {
|
|
|
184776
185919
|
instrumentFastifyV3 = generateInstrumentOnce(`${INTEGRATION_NAME24}.v3`, () => new FastifyInstrumentationV3);
|
|
184777
185920
|
instrumentFastify = generateInstrumentOnce(`${INTEGRATION_NAME24}.v5`, () => {
|
|
184778
185921
|
const fastifyOtelInstrumentationInstance = new import_otel.FastifyOtelInstrumentation;
|
|
184779
|
-
const
|
|
185922
|
+
const plugin8 = fastifyOtelInstrumentationInstance.plugin();
|
|
184780
185923
|
diagnosticsChannel2.subscribe("fastify.initialization", (message2) => {
|
|
184781
185924
|
const fastifyInstance = message2.fastify;
|
|
184782
|
-
fastifyInstance?.register(
|
|
185925
|
+
fastifyInstance?.register(plugin8).after((err) => {
|
|
184783
185926
|
if (err) {
|
|
184784
185927
|
DEBUG_BUILD4 && debug32.error("Failed to setup Fastify instrumentation", err);
|
|
184785
185928
|
} else {
|
|
@@ -188703,7 +189846,7 @@ var init_redis_instrumentation = __esm(() => {
|
|
|
188703
189846
|
return new import_instrumentation10.InstrumentationNodeModuleDefinition(basePackageName, ["^1.0.0", ">=5.0.0 <5.12.0"], (moduleExports) => moduleExports, () => {}, [commanderModuleFile, multiCommanderModule, clientIndexModule]);
|
|
188704
189847
|
}
|
|
188705
189848
|
_getPatchExtendWithCommands(transformCommandArguments) {
|
|
188706
|
-
const
|
|
189849
|
+
const plugin8 = this;
|
|
188707
189850
|
return function extendWithCommandsPatchWrapper(original) {
|
|
188708
189851
|
return function extendWithCommandsPatch(config2) {
|
|
188709
189852
|
if (config2?.BaseClass?.name !== "RedisClient") {
|
|
@@ -188712,32 +189855,32 @@ var init_redis_instrumentation = __esm(() => {
|
|
|
188712
189855
|
const origExecutor = config2.executor;
|
|
188713
189856
|
config2.executor = function(command, args) {
|
|
188714
189857
|
const redisCommandArguments = transformCommandArguments(command, args).args;
|
|
188715
|
-
return
|
|
189858
|
+
return plugin8._traceClientCommand(origExecutor, this, arguments, redisCommandArguments);
|
|
188716
189859
|
};
|
|
188717
189860
|
return original.apply(this, arguments);
|
|
188718
189861
|
};
|
|
188719
189862
|
};
|
|
188720
189863
|
}
|
|
188721
189864
|
_getPatchMultiCommandsExec(isPipeline) {
|
|
188722
|
-
const
|
|
189865
|
+
const plugin8 = this;
|
|
188723
189866
|
return function execPatchWrapper(original) {
|
|
188724
189867
|
return function execPatch() {
|
|
188725
189868
|
const execRes = original.apply(this, arguments);
|
|
188726
189869
|
if (typeof execRes?.then !== "function") {
|
|
188727
|
-
|
|
189870
|
+
plugin8._diag.error("non-promise result when patching exec/execAsPipeline");
|
|
188728
189871
|
return execRes;
|
|
188729
189872
|
}
|
|
188730
189873
|
return execRes.then((redisRes) => {
|
|
188731
189874
|
const openSpans = this[OTEL_OPEN_SPANS];
|
|
188732
|
-
|
|
189875
|
+
plugin8._endSpansWithRedisReplies(openSpans, redisRes, isPipeline);
|
|
188733
189876
|
return redisRes;
|
|
188734
189877
|
}).catch((err) => {
|
|
188735
189878
|
const openSpans = this[OTEL_OPEN_SPANS];
|
|
188736
189879
|
if (!openSpans) {
|
|
188737
|
-
|
|
189880
|
+
plugin8._diag.error("cannot find open spans to end for multi/pipeline");
|
|
188738
189881
|
} else {
|
|
188739
189882
|
const replies = err.constructor.name === "MultiErrorReply" ? err.replies : new Array(openSpans.length).fill(err);
|
|
188740
|
-
|
|
189883
|
+
plugin8._endSpansWithRedisReplies(openSpans, replies, isPipeline);
|
|
188741
189884
|
}
|
|
188742
189885
|
return Promise.reject(err);
|
|
188743
189886
|
});
|
|
@@ -188745,10 +189888,10 @@ var init_redis_instrumentation = __esm(() => {
|
|
|
188745
189888
|
};
|
|
188746
189889
|
}
|
|
188747
189890
|
_getPatchMultiCommandsAddCommand() {
|
|
188748
|
-
const
|
|
189891
|
+
const plugin8 = this;
|
|
188749
189892
|
return function addCommandWrapper(original) {
|
|
188750
189893
|
return function addCommandPatch(args) {
|
|
188751
|
-
return
|
|
189894
|
+
return plugin8._traceClientCommand(original, this, arguments, args);
|
|
188752
189895
|
};
|
|
188753
189896
|
};
|
|
188754
189897
|
}
|
|
@@ -188762,21 +189905,21 @@ var init_redis_instrumentation = __esm(() => {
|
|
|
188762
189905
|
};
|
|
188763
189906
|
}
|
|
188764
189907
|
_getPatchRedisClientSendCommand() {
|
|
188765
|
-
const
|
|
189908
|
+
const plugin8 = this;
|
|
188766
189909
|
return function sendCommandWrapper(original) {
|
|
188767
189910
|
return function sendCommandPatch(args) {
|
|
188768
|
-
return
|
|
189911
|
+
return plugin8._traceClientCommand(original, this, arguments, args);
|
|
188769
189912
|
};
|
|
188770
189913
|
};
|
|
188771
189914
|
}
|
|
188772
189915
|
_getPatchedClientConnect() {
|
|
188773
|
-
const
|
|
189916
|
+
const plugin8 = this;
|
|
188774
189917
|
return function connectWrapper(original) {
|
|
188775
189918
|
return function patchedConnect() {
|
|
188776
189919
|
const options = this.options;
|
|
188777
|
-
const attributes = getClientAttributes(
|
|
189920
|
+
const attributes = getClientAttributes(plugin8._diag, options, plugin8._semconvStability);
|
|
188778
189921
|
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.db.otel.redis";
|
|
188779
|
-
const span =
|
|
189922
|
+
const span = plugin8.tracer.startSpan(`${RedisInstrumentationV4_V5.COMPONENT}-connect`, {
|
|
188780
189923
|
kind: import_api21.SpanKind.CLIENT,
|
|
188781
189924
|
attributes
|
|
188782
189925
|
});
|
|
@@ -189618,16 +190761,16 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189618
190761
|
return module2;
|
|
189619
190762
|
}
|
|
189620
190763
|
_getClientConnectPatch() {
|
|
189621
|
-
const
|
|
190764
|
+
const plugin8 = this;
|
|
189622
190765
|
return (original) => {
|
|
189623
190766
|
return function connect5(callback) {
|
|
189624
|
-
const config2 =
|
|
190767
|
+
const config2 = plugin8.getConfig();
|
|
189625
190768
|
if (utils.shouldSkipInstrumentation(config2) || config2.ignoreConnectSpans) {
|
|
189626
190769
|
return original.call(this, callback);
|
|
189627
190770
|
}
|
|
189628
|
-
const span =
|
|
190771
|
+
const span = plugin8.tracer.startSpan(SpanNames_1.SpanNames.CONNECT, {
|
|
189629
190772
|
kind: api_1.SpanKind.CLIENT,
|
|
189630
|
-
attributes: utils.getSemanticAttributesFromConnection(this,
|
|
190773
|
+
attributes: utils.getSemanticAttributesFromConnection(this, plugin8._semconvStability)
|
|
189631
190774
|
});
|
|
189632
190775
|
if (callback) {
|
|
189633
190776
|
const parentSpan = api_1.trace.getSpan(api_1.context.active());
|
|
@@ -189667,11 +190810,11 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189667
190810
|
this._operationDuration.record(durationSeconds, metricsAttributes);
|
|
189668
190811
|
}
|
|
189669
190812
|
_getClientQueryPatch() {
|
|
189670
|
-
const
|
|
190813
|
+
const plugin8 = this;
|
|
189671
190814
|
return (original) => {
|
|
189672
190815
|
this._diag.debug("Patching pg.Client.prototype.query");
|
|
189673
190816
|
return function query(...args) {
|
|
189674
|
-
if (utils.shouldSkipInstrumentation(
|
|
190817
|
+
if (utils.shouldSkipInstrumentation(plugin8.getConfig())) {
|
|
189675
190818
|
return original.apply(this, args);
|
|
189676
190819
|
}
|
|
189677
190820
|
const startTime = (0, core_1.hrTime)();
|
|
@@ -189697,10 +190840,10 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189697
190840
|
attributes[semantic_conventions_1.ATTR_DB_OPERATION_NAME] = utils.parseNormalizedOperationName(queryConfig?.text);
|
|
189698
190841
|
}
|
|
189699
190842
|
const recordDuration = () => {
|
|
189700
|
-
|
|
190843
|
+
plugin8.recordOperationDuration(attributes, startTime);
|
|
189701
190844
|
};
|
|
189702
|
-
const instrumentationConfig =
|
|
189703
|
-
const span = utils.handleConfigQuery.call(this,
|
|
190845
|
+
const instrumentationConfig = plugin8.getConfig();
|
|
190846
|
+
const span = utils.handleConfigQuery.call(this, plugin8.tracer, instrumentationConfig, plugin8._semconvStability, queryConfig);
|
|
189704
190847
|
if (instrumentationConfig.addSqlCommenterCommentToQueries) {
|
|
189705
190848
|
if (firstArgIsString) {
|
|
189706
190849
|
args[0] = (0, sql_common_1.addSqlCommenterComment)(span, arg0);
|
|
@@ -189719,7 +190862,7 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189719
190862
|
args[args.length - 1] = api_1.context.bind(api_1.context.active(), args[args.length - 1]);
|
|
189720
190863
|
}
|
|
189721
190864
|
} else if (typeof queryConfig?.callback === "function") {
|
|
189722
|
-
let callback = utils.patchCallback(
|
|
190865
|
+
let callback = utils.patchCallback(plugin8.getConfig(), span, queryConfig.callback, attributes, recordDuration);
|
|
189723
190866
|
if (parentSpan) {
|
|
189724
190867
|
callback = api_1.context.bind(api_1.context.active(), callback);
|
|
189725
190868
|
}
|
|
@@ -189741,7 +190884,7 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189741
190884
|
});
|
|
189742
190885
|
}, (err) => {
|
|
189743
190886
|
if (err) {
|
|
189744
|
-
|
|
190887
|
+
plugin8._diag.error("Error running query hook", err);
|
|
189745
190888
|
}
|
|
189746
190889
|
}, true);
|
|
189747
190890
|
}
|
|
@@ -189762,7 +190905,7 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189762
190905
|
if (result instanceof Promise) {
|
|
189763
190906
|
return result.then((result2) => {
|
|
189764
190907
|
return new Promise((resolve3) => {
|
|
189765
|
-
utils.handleExecutionResult(
|
|
190908
|
+
utils.handleExecutionResult(plugin8.getConfig(), span, result2);
|
|
189766
190909
|
recordDuration();
|
|
189767
190910
|
span.end();
|
|
189768
190911
|
resolve3(result2);
|
|
@@ -189805,20 +190948,20 @@ var require_instrumentation12 = __commonJS((exports) => {
|
|
|
189805
190948
|
pgPool[internal_types_1.EVENT_LISTENERS_SET] = true;
|
|
189806
190949
|
}
|
|
189807
190950
|
_getPoolConnectPatch() {
|
|
189808
|
-
const
|
|
190951
|
+
const plugin8 = this;
|
|
189809
190952
|
return (originalConnect) => {
|
|
189810
190953
|
return function connect5(callback) {
|
|
189811
|
-
const config2 =
|
|
190954
|
+
const config2 = plugin8.getConfig();
|
|
189812
190955
|
if (utils.shouldSkipInstrumentation(config2)) {
|
|
189813
190956
|
return originalConnect.call(this, callback);
|
|
189814
190957
|
}
|
|
189815
|
-
|
|
190958
|
+
plugin8._setPoolConnectEventListeners(this);
|
|
189816
190959
|
if (config2.ignoreConnectSpans) {
|
|
189817
190960
|
return originalConnect.call(this, callback);
|
|
189818
190961
|
}
|
|
189819
|
-
const span =
|
|
190962
|
+
const span = plugin8.tracer.startSpan(SpanNames_1.SpanNames.POOL_CONNECT, {
|
|
189820
190963
|
kind: api_1.SpanKind.CLIENT,
|
|
189821
|
-
attributes: utils.getSemanticAttributesFromPoolConnection(this.options,
|
|
190964
|
+
attributes: utils.getSemanticAttributesFromPoolConnection(this.options, plugin8._semconvStability)
|
|
189822
190965
|
});
|
|
189823
190966
|
if (callback) {
|
|
189824
190967
|
const parentSpan = api_1.trace.getSpan(api_1.context.active());
|
|
@@ -191918,11 +193061,11 @@ var require_utils21 = __commonJS((exports) => {
|
|
|
191918
193061
|
var internal_types_1 = require_internal_types5();
|
|
191919
193062
|
var AttributeNames_1 = require_AttributeNames4();
|
|
191920
193063
|
var instrumentation_1 = require_src8();
|
|
191921
|
-
function getPluginName(
|
|
191922
|
-
if (
|
|
191923
|
-
return
|
|
193064
|
+
function getPluginName(plugin8) {
|
|
193065
|
+
if (plugin8.name) {
|
|
193066
|
+
return plugin8.name;
|
|
191924
193067
|
} else {
|
|
191925
|
-
return
|
|
193068
|
+
return plugin8.pkg.name;
|
|
191926
193069
|
}
|
|
191927
193070
|
}
|
|
191928
193071
|
exports.getPluginName = getPluginName;
|
|
@@ -192053,12 +193196,12 @@ var require_instrumentation15 = __commonJS((exports) => {
|
|
|
192053
193196
|
return function register2(pluginInput, options) {
|
|
192054
193197
|
if (Array.isArray(pluginInput)) {
|
|
192055
193198
|
for (const pluginObj of pluginInput) {
|
|
192056
|
-
const
|
|
192057
|
-
instrumentation._wrapRegisterHandler(
|
|
193199
|
+
const plugin8 = (0, utils_1.getPluginFromInput)(pluginObj);
|
|
193200
|
+
instrumentation._wrapRegisterHandler(plugin8);
|
|
192058
193201
|
}
|
|
192059
193202
|
} else {
|
|
192060
|
-
const
|
|
192061
|
-
instrumentation._wrapRegisterHandler(
|
|
193203
|
+
const plugin8 = (0, utils_1.getPluginFromInput)(pluginInput);
|
|
193204
|
+
instrumentation._wrapRegisterHandler(plugin8);
|
|
192062
193205
|
}
|
|
192063
193206
|
return original.apply(this, [pluginInput, options]);
|
|
192064
193207
|
};
|
|
@@ -192106,10 +193249,10 @@ var require_instrumentation15 = __commonJS((exports) => {
|
|
|
192106
193249
|
return original.apply(this, [route]);
|
|
192107
193250
|
};
|
|
192108
193251
|
}
|
|
192109
|
-
_wrapRegisterHandler(
|
|
193252
|
+
_wrapRegisterHandler(plugin8) {
|
|
192110
193253
|
const instrumentation = this;
|
|
192111
|
-
const pluginName = (0, utils_1.getPluginName)(
|
|
192112
|
-
const oldRegister =
|
|
193254
|
+
const pluginName = (0, utils_1.getPluginName)(plugin8);
|
|
193255
|
+
const oldRegister = plugin8.register;
|
|
192113
193256
|
const self2 = this;
|
|
192114
193257
|
const newRegisterHandler = function(server, options) {
|
|
192115
193258
|
self2._wrap(server, "route", (original) => {
|
|
@@ -192120,7 +193263,7 @@ var require_instrumentation15 = __commonJS((exports) => {
|
|
|
192120
193263
|
});
|
|
192121
193264
|
return oldRegister.call(this, server, options);
|
|
192122
193265
|
};
|
|
192123
|
-
|
|
193266
|
+
plugin8.register = newRegisterHandler;
|
|
192124
193267
|
}
|
|
192125
193268
|
_wrapExtMethods(method, extPoint, pluginName) {
|
|
192126
193269
|
const instrumentation = this;
|
|
@@ -192564,13 +193707,13 @@ var require_instrumentation16 = __commonJS((exports) => {
|
|
|
192564
193707
|
});
|
|
192565
193708
|
}
|
|
192566
193709
|
_getKoaUsePatch(original) {
|
|
192567
|
-
const
|
|
193710
|
+
const plugin8 = this;
|
|
192568
193711
|
return function use(middlewareFunction) {
|
|
192569
193712
|
let patchedFunction;
|
|
192570
193713
|
if (middlewareFunction.router) {
|
|
192571
|
-
patchedFunction =
|
|
193714
|
+
patchedFunction = plugin8._patchRouterDispatch(middlewareFunction);
|
|
192572
193715
|
} else {
|
|
192573
|
-
patchedFunction =
|
|
193716
|
+
patchedFunction = plugin8._patchLayer(middlewareFunction, false);
|
|
192574
193717
|
}
|
|
192575
193718
|
return original.apply(this, [patchedFunction]);
|
|
192576
193719
|
};
|
|
@@ -208653,11 +209796,11 @@ var require_transport3 = __commonJS((exports) => {
|
|
|
208653
209796
|
function captureJsonRpcErrorResponse(errorResponse) {
|
|
208654
209797
|
try {
|
|
208655
209798
|
if (errorResponse && typeof errorResponse === "object" && "code" in errorResponse && "message" in errorResponse) {
|
|
208656
|
-
const
|
|
208657
|
-
const isServerError =
|
|
209799
|
+
const jsonRpcError2 = errorResponse;
|
|
209800
|
+
const isServerError = jsonRpcError2.code === -32603 || jsonRpcError2.code >= -32099 && jsonRpcError2.code <= -32000;
|
|
208658
209801
|
if (isServerError) {
|
|
208659
|
-
const error3 = new Error(
|
|
208660
|
-
error3.name = `JsonRpcError_${
|
|
209802
|
+
const error3 = new Error(jsonRpcError2.message);
|
|
209803
|
+
error3.name = `JsonRpcError_${jsonRpcError2.code}`;
|
|
208661
209804
|
errorCapture.captureError(error3, "protocol");
|
|
208662
209805
|
}
|
|
208663
209806
|
}
|
|
@@ -220834,10 +221977,10 @@ var require_fastify = __commonJS((exports) => {
|
|
|
220834
221977
|
}
|
|
220835
221978
|
var instrumentFastify2 = nodeCore.generateInstrumentOnce(`${INTEGRATION_NAME46}.v5`, () => {
|
|
220836
221979
|
const fastifyOtelInstrumentationInstance = new otel.FastifyOtelInstrumentation;
|
|
220837
|
-
const
|
|
221980
|
+
const plugin8 = fastifyOtelInstrumentationInstance.plugin();
|
|
220838
221981
|
diagnosticsChannel3.subscribe("fastify.initialization", (message2) => {
|
|
220839
221982
|
const fastifyInstance = message2.fastify;
|
|
220840
|
-
fastifyInstance?.register(
|
|
221983
|
+
fastifyInstance?.register(plugin8).after((err) => {
|
|
220841
221984
|
if (err) {
|
|
220842
221985
|
debugBuild.DEBUG_BUILD && core3.debug.error("Failed to setup Fastify instrumentation", err);
|
|
220843
221986
|
} else {
|
|
@@ -220880,7 +222023,7 @@ var require_fastify = __commonJS((exports) => {
|
|
|
220880
222023
|
if (options?.shouldHandleError) {
|
|
220881
222024
|
getFastifyIntegration2()?.setShouldHandleError(options.shouldHandleError);
|
|
220882
222025
|
}
|
|
220883
|
-
const
|
|
222026
|
+
const plugin8 = Object.assign(function(fastify2, _options, done) {
|
|
220884
222027
|
fastify2.addHook("onError", async (request2, reply, error3) => {
|
|
220885
222028
|
handleFastifyError2.call(handleFastifyError2, error3, request2, reply, "onError-hook");
|
|
220886
222029
|
});
|
|
@@ -220889,7 +222032,7 @@ var require_fastify = __commonJS((exports) => {
|
|
|
220889
222032
|
[Symbol.for("skip-override")]: true,
|
|
220890
222033
|
[Symbol.for("fastify.display-name")]: "sentry-fastify-error-handler"
|
|
220891
222034
|
});
|
|
220892
|
-
fastify.register(
|
|
222035
|
+
fastify.register(plugin8);
|
|
220893
222036
|
}
|
|
220894
222037
|
function addFastifySpanAttributes2(span) {
|
|
220895
222038
|
const spanJSON = core3.spanToJSON(span);
|
|
@@ -221857,7 +223000,7 @@ var require_redis_instrumentation = __commonJS((exports) => {
|
|
|
221857
223000
|
return new instrumentation.InstrumentationNodeModuleDefinition(basePackageName, ["^1.0.0", ">=5.0.0 <5.12.0"], (moduleExports) => moduleExports, () => {}, [commanderModuleFile, multiCommanderModule, clientIndexModule]);
|
|
221858
223001
|
}
|
|
221859
223002
|
_getPatchExtendWithCommands(transformCommandArguments) {
|
|
221860
|
-
const
|
|
223003
|
+
const plugin8 = this;
|
|
221861
223004
|
return function extendWithCommandsPatchWrapper(original) {
|
|
221862
223005
|
return function extendWithCommandsPatch(config4) {
|
|
221863
223006
|
if (config4?.BaseClass?.name !== "RedisClient") {
|
|
@@ -221866,32 +223009,32 @@ var require_redis_instrumentation = __commonJS((exports) => {
|
|
|
221866
223009
|
const origExecutor = config4.executor;
|
|
221867
223010
|
config4.executor = function(command, args) {
|
|
221868
223011
|
const redisCommandArguments = transformCommandArguments(command, args).args;
|
|
221869
|
-
return
|
|
223012
|
+
return plugin8._traceClientCommand(origExecutor, this, arguments, redisCommandArguments);
|
|
221870
223013
|
};
|
|
221871
223014
|
return original.apply(this, arguments);
|
|
221872
223015
|
};
|
|
221873
223016
|
};
|
|
221874
223017
|
}
|
|
221875
223018
|
_getPatchMultiCommandsExec(isPipeline) {
|
|
221876
|
-
const
|
|
223019
|
+
const plugin8 = this;
|
|
221877
223020
|
return function execPatchWrapper(original) {
|
|
221878
223021
|
return function execPatch() {
|
|
221879
223022
|
const execRes = original.apply(this, arguments);
|
|
221880
223023
|
if (typeof execRes?.then !== "function") {
|
|
221881
|
-
|
|
223024
|
+
plugin8._diag.error("non-promise result when patching exec/execAsPipeline");
|
|
221882
223025
|
return execRes;
|
|
221883
223026
|
}
|
|
221884
223027
|
return execRes.then((redisRes) => {
|
|
221885
223028
|
const openSpans = this[OTEL_OPEN_SPANS2];
|
|
221886
|
-
|
|
223029
|
+
plugin8._endSpansWithRedisReplies(openSpans, redisRes, isPipeline);
|
|
221887
223030
|
return redisRes;
|
|
221888
223031
|
}).catch((err) => {
|
|
221889
223032
|
const openSpans = this[OTEL_OPEN_SPANS2];
|
|
221890
223033
|
if (!openSpans) {
|
|
221891
|
-
|
|
223034
|
+
plugin8._diag.error("cannot find open spans to end for multi/pipeline");
|
|
221892
223035
|
} else {
|
|
221893
223036
|
const replies = err.constructor.name === "MultiErrorReply" ? err.replies : new Array(openSpans.length).fill(err);
|
|
221894
|
-
|
|
223037
|
+
plugin8._endSpansWithRedisReplies(openSpans, replies, isPipeline);
|
|
221895
223038
|
}
|
|
221896
223039
|
return Promise.reject(err);
|
|
221897
223040
|
});
|
|
@@ -221899,10 +223042,10 @@ var require_redis_instrumentation = __commonJS((exports) => {
|
|
|
221899
223042
|
};
|
|
221900
223043
|
}
|
|
221901
223044
|
_getPatchMultiCommandsAddCommand() {
|
|
221902
|
-
const
|
|
223045
|
+
const plugin8 = this;
|
|
221903
223046
|
return function addCommandWrapper(original) {
|
|
221904
223047
|
return function addCommandPatch(args) {
|
|
221905
|
-
return
|
|
223048
|
+
return plugin8._traceClientCommand(original, this, arguments, args);
|
|
221906
223049
|
};
|
|
221907
223050
|
};
|
|
221908
223051
|
}
|
|
@@ -221916,21 +223059,21 @@ var require_redis_instrumentation = __commonJS((exports) => {
|
|
|
221916
223059
|
};
|
|
221917
223060
|
}
|
|
221918
223061
|
_getPatchRedisClientSendCommand() {
|
|
221919
|
-
const
|
|
223062
|
+
const plugin8 = this;
|
|
221920
223063
|
return function sendCommandWrapper(original) {
|
|
221921
223064
|
return function sendCommandPatch(args) {
|
|
221922
|
-
return
|
|
223065
|
+
return plugin8._traceClientCommand(original, this, arguments, args);
|
|
221923
223066
|
};
|
|
221924
223067
|
};
|
|
221925
223068
|
}
|
|
221926
223069
|
_getPatchedClientConnect() {
|
|
221927
|
-
const
|
|
223070
|
+
const plugin8 = this;
|
|
221928
223071
|
return function connectWrapper(original) {
|
|
221929
223072
|
return function patchedConnect() {
|
|
221930
223073
|
const options = this.options;
|
|
221931
|
-
const attributes = getClientAttributes2(
|
|
223074
|
+
const attributes = getClientAttributes2(plugin8._diag, options, plugin8._semconvStability);
|
|
221932
223075
|
attributes[core3.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = "auto.db.otel.redis";
|
|
221933
|
-
const span =
|
|
223076
|
+
const span = plugin8.tracer.startSpan(`${RedisInstrumentationV4_V52.COMPONENT}-connect`, {
|
|
221934
223077
|
kind: api2.SpanKind.CLIENT,
|
|
221935
223078
|
attributes
|
|
221936
223079
|
});
|
|
@@ -225883,7 +227026,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
225883
227026
|
var require_package7 = __commonJS((exports, module) => {
|
|
225884
227027
|
module.exports = {
|
|
225885
227028
|
name: "@omni/api",
|
|
225886
|
-
version: "2.
|
|
227029
|
+
version: "2.260718.1",
|
|
225887
227030
|
type: "module",
|
|
225888
227031
|
exports: {
|
|
225889
227032
|
".": {
|
|
@@ -281422,8 +282565,8 @@ function osUsername() {
|
|
|
281422
282565
|
return process.env.USERNAME || process.env.USER || process.env.LOGNAME;
|
|
281423
282566
|
}
|
|
281424
282567
|
}
|
|
281425
|
-
var
|
|
281426
|
-
var
|
|
282568
|
+
var src_default7;
|
|
282569
|
+
var init_src5 = __esm(() => {
|
|
281427
282570
|
init_types14();
|
|
281428
282571
|
init_connection();
|
|
281429
282572
|
init_query2();
|
|
@@ -281448,7 +282591,7 @@ var init_src4 = __esm(() => {
|
|
|
281448
282591
|
serialize: (x) => x.toString()
|
|
281449
282592
|
}
|
|
281450
282593
|
});
|
|
281451
|
-
|
|
282594
|
+
src_default7 = Postgres;
|
|
281452
282595
|
});
|
|
281453
282596
|
|
|
281454
282597
|
// ../../node_modules/.bun/drizzle-orm@0.38.4+db1fc555b1037084/node_modules/drizzle-orm/postgres-js/session.js
|
|
@@ -281599,7 +282742,7 @@ function construct(client, config4 = {}) {
|
|
|
281599
282742
|
}
|
|
281600
282743
|
function drizzle(...params) {
|
|
281601
282744
|
if (typeof params[0] === "string") {
|
|
281602
|
-
const instance4 =
|
|
282745
|
+
const instance4 = src_default7(params[0]);
|
|
281603
282746
|
return construct(instance4, params[1]);
|
|
281604
282747
|
}
|
|
281605
282748
|
if (isConfig(params[0])) {
|
|
@@ -281608,17 +282751,17 @@ function drizzle(...params) {
|
|
|
281608
282751
|
return construct(client, drizzleConfig);
|
|
281609
282752
|
if (typeof connection2 === "object" && connection2.url !== undefined) {
|
|
281610
282753
|
const { url, ...config4 } = connection2;
|
|
281611
|
-
const instance22 =
|
|
282754
|
+
const instance22 = src_default7(url, config4);
|
|
281612
282755
|
return construct(instance22, drizzleConfig);
|
|
281613
282756
|
}
|
|
281614
|
-
const instance4 =
|
|
282757
|
+
const instance4 = src_default7(connection2);
|
|
281615
282758
|
return construct(instance4, drizzleConfig);
|
|
281616
282759
|
}
|
|
281617
282760
|
return construct(params[0], params[1]);
|
|
281618
282761
|
}
|
|
281619
282762
|
var PostgresJsDatabase;
|
|
281620
282763
|
var init_driver = __esm(() => {
|
|
281621
|
-
|
|
282764
|
+
init_src5();
|
|
281622
282765
|
init_entity();
|
|
281623
282766
|
init_logger3();
|
|
281624
282767
|
init_db();
|
|
@@ -281667,7 +282810,7 @@ function getDefaultDatabaseUrl() {
|
|
|
281667
282810
|
function createPostgresClient(config4) {
|
|
281668
282811
|
const url = config4?.url ?? getDefaultDatabaseUrl();
|
|
281669
282812
|
const ssl = resolveSslConfig(config4?.sslCaFile);
|
|
281670
|
-
const client =
|
|
282813
|
+
const client = src_default7(url, {
|
|
281671
282814
|
max: config4?.maxConnections ?? 10,
|
|
281672
282815
|
idle_timeout: config4?.idleTimeout ?? 20,
|
|
281673
282816
|
connect_timeout: config4?.connectTimeout ?? 10,
|
|
@@ -281690,7 +282833,7 @@ async function closeDb() {
|
|
|
281690
282833
|
var sqlClient = null, dbInstance = null;
|
|
281691
282834
|
var init_client5 = __esm(() => {
|
|
281692
282835
|
init_postgres_js();
|
|
281693
|
-
|
|
282836
|
+
init_src5();
|
|
281694
282837
|
init_schema2();
|
|
281695
282838
|
});
|
|
281696
282839
|
|
|
@@ -281827,7 +282970,7 @@ var init_verify_schema = __esm(() => {
|
|
|
281827
282970
|
});
|
|
281828
282971
|
|
|
281829
282972
|
// ../db/src/index.ts
|
|
281830
|
-
var
|
|
282973
|
+
var init_src6 = __esm(() => {
|
|
281831
282974
|
init_client5();
|
|
281832
282975
|
init_migrate();
|
|
281833
282976
|
init_verify_schema();
|
|
@@ -284709,7 +285852,7 @@ class ApiKeyService {
|
|
|
284709
285852
|
var log58, API_KEY_PREFIX = "omni_sk_", PRIMARY_KEY_NAME = "__primary__";
|
|
284710
285853
|
var init_api_keys = __esm(() => {
|
|
284711
285854
|
init_src();
|
|
284712
|
-
|
|
285855
|
+
init_src6();
|
|
284713
285856
|
init_drizzle_orm();
|
|
284714
285857
|
init_cache2();
|
|
284715
285858
|
log58 = createLogger("api-keys");
|
|
@@ -284926,7 +286069,7 @@ function loadPubkey(pubkeyB64Url) {
|
|
|
284926
286069
|
}
|
|
284927
286070
|
async function verifySignature3(opts) {
|
|
284928
286071
|
const { hostIdHeader, timestampHeader, signatureHeader, method, path: path2, body, now, findHost } = opts;
|
|
284929
|
-
if (
|
|
286072
|
+
if (hostIdHeader === undefined && timestampHeader === undefined && signatureHeader === undefined) {
|
|
284930
286073
|
return { status: "no-signature" };
|
|
284931
286074
|
}
|
|
284932
286075
|
if (!hostIdHeader || !timestampHeader || !signatureHeader) {
|
|
@@ -284987,7 +286130,7 @@ var init_genie_signature = __esm(() => {
|
|
|
284987
286130
|
const hostIdHeader = c.req.header(HEADER_HOST_ID);
|
|
284988
286131
|
const timestampHeader = c.req.header(HEADER_TIMESTAMP);
|
|
284989
286132
|
const signatureHeader = c.req.header(HEADER_SIGNATURE);
|
|
284990
|
-
if (
|
|
286133
|
+
if (hostIdHeader === undefined && timestampHeader === undefined && signatureHeader === undefined) {
|
|
284991
286134
|
return next();
|
|
284992
286135
|
}
|
|
284993
286136
|
const services = c.get("services");
|
|
@@ -286134,7 +287277,7 @@ class DeepSeekVisionProvider {
|
|
|
286134
287277
|
if (!response.ok) {
|
|
286135
287278
|
throw new Error(`DeepSeek vision error (${response.status}): ${body.error?.message ?? bodyText.slice(0, 300)}`);
|
|
286136
287279
|
}
|
|
286137
|
-
const text3 =
|
|
287280
|
+
const text3 = extractText2(body).trim();
|
|
286138
287281
|
if (!text3) {
|
|
286139
287282
|
throw new Error("DeepSeek returned empty vision response");
|
|
286140
287283
|
}
|
|
@@ -286152,7 +287295,7 @@ ${base2}`;
|
|
|
286152
287295
|
return base2;
|
|
286153
287296
|
}
|
|
286154
287297
|
}
|
|
286155
|
-
function
|
|
287298
|
+
function extractText2(body) {
|
|
286156
287299
|
return (body.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
|
|
286157
287300
|
`);
|
|
286158
287301
|
}
|
|
@@ -307248,7 +308391,7 @@ async function uploadBlobInternal(file, uploadUrl, apiClient, httpOptions) {
|
|
|
307248
308391
|
break;
|
|
307249
308392
|
}
|
|
307250
308393
|
retryCount++;
|
|
307251
|
-
await
|
|
308394
|
+
await sleep3(currentDelayMs);
|
|
307252
308395
|
currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
|
|
307253
308396
|
}
|
|
307254
308397
|
offset += chunkSize;
|
|
@@ -307265,7 +308408,7 @@ async function getBlobStat(file) {
|
|
|
307265
308408
|
const fileStat = { size: file.size, type: file.type };
|
|
307266
308409
|
return fileStat;
|
|
307267
308410
|
}
|
|
307268
|
-
function
|
|
308411
|
+
function sleep3(ms) {
|
|
307269
308412
|
return new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
|
|
307270
308413
|
}
|
|
307271
308414
|
|
|
@@ -307445,7 +308588,7 @@ class NodeUploader {
|
|
|
307445
308588
|
break;
|
|
307446
308589
|
}
|
|
307447
308590
|
retryCount++;
|
|
307448
|
-
await
|
|
308591
|
+
await sleep3(currentDelayMs);
|
|
307449
308592
|
currentDelayMs = currentDelayMs * DELAY_MULTIPLIER;
|
|
307450
308593
|
}
|
|
307451
308594
|
offset += bytesRead;
|
|
@@ -308630,8 +309773,8 @@ var init_node6 = __esm(() => {
|
|
|
308630
309773
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
308631
309774
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
308632
309775
|
}).then((httpResponse) => {
|
|
308633
|
-
return httpResponse.json().then((
|
|
308634
|
-
const response2 =
|
|
309776
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
309777
|
+
const response2 = jsonResponse2;
|
|
308635
309778
|
response2.sdkHttpResponse = {
|
|
308636
309779
|
headers: httpResponse.headers
|
|
308637
309780
|
};
|
|
@@ -308658,8 +309801,8 @@ var init_node6 = __esm(() => {
|
|
|
308658
309801
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
308659
309802
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
308660
309803
|
}).then((httpResponse) => {
|
|
308661
|
-
return httpResponse.json().then((
|
|
308662
|
-
const response2 =
|
|
309804
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
309805
|
+
const response2 = jsonResponse2;
|
|
308663
309806
|
response2.sdkHttpResponse = {
|
|
308664
309807
|
headers: httpResponse.headers
|
|
308665
309808
|
};
|
|
@@ -308693,8 +309836,8 @@ var init_node6 = __esm(() => {
|
|
|
308693
309836
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
308694
309837
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
308695
309838
|
}).then((httpResponse) => {
|
|
308696
|
-
return httpResponse.json().then((
|
|
308697
|
-
const response2 =
|
|
309839
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
309840
|
+
const response2 = jsonResponse2;
|
|
308698
309841
|
response2.sdkHttpResponse = {
|
|
308699
309842
|
headers: httpResponse.headers
|
|
308700
309843
|
};
|
|
@@ -308719,8 +309862,8 @@ var init_node6 = __esm(() => {
|
|
|
308719
309862
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
308720
309863
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
308721
309864
|
}).then((httpResponse) => {
|
|
308722
|
-
return httpResponse.json().then((
|
|
308723
|
-
const response2 =
|
|
309865
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
309866
|
+
const response2 = jsonResponse2;
|
|
308724
309867
|
response2.sdkHttpResponse = {
|
|
308725
309868
|
headers: httpResponse.headers
|
|
308726
309869
|
};
|
|
@@ -308851,8 +309994,8 @@ var init_node6 = __esm(() => {
|
|
|
308851
309994
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
308852
309995
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
308853
309996
|
}).then((httpResponse) => {
|
|
308854
|
-
return httpResponse.json().then((
|
|
308855
|
-
const response2 =
|
|
309997
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
309998
|
+
const response2 = jsonResponse2;
|
|
308856
309999
|
response2.sdkHttpResponse = {
|
|
308857
310000
|
headers: httpResponse.headers
|
|
308858
310001
|
};
|
|
@@ -308879,8 +310022,8 @@ var init_node6 = __esm(() => {
|
|
|
308879
310022
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
308880
310023
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
308881
310024
|
}).then((httpResponse) => {
|
|
308882
|
-
return httpResponse.json().then((
|
|
308883
|
-
const response2 =
|
|
310025
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310026
|
+
const response2 = jsonResponse2;
|
|
308884
310027
|
response2.sdkHttpResponse = {
|
|
308885
310028
|
headers: httpResponse.headers
|
|
308886
310029
|
};
|
|
@@ -308959,8 +310102,8 @@ var init_node6 = __esm(() => {
|
|
|
308959
310102
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
308960
310103
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
308961
310104
|
}).then((httpResponse) => {
|
|
308962
|
-
return httpResponse.json().then((
|
|
308963
|
-
const response2 =
|
|
310105
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310106
|
+
const response2 = jsonResponse2;
|
|
308964
310107
|
response2.sdkHttpResponse = {
|
|
308965
310108
|
headers: httpResponse.headers
|
|
308966
310109
|
};
|
|
@@ -308987,8 +310130,8 @@ var init_node6 = __esm(() => {
|
|
|
308987
310130
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
308988
310131
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
308989
310132
|
}).then((httpResponse) => {
|
|
308990
|
-
return httpResponse.json().then((
|
|
308991
|
-
const response2 =
|
|
310133
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310134
|
+
const response2 = jsonResponse2;
|
|
308992
310135
|
response2.sdkHttpResponse = {
|
|
308993
310136
|
headers: httpResponse.headers
|
|
308994
310137
|
};
|
|
@@ -309058,8 +310201,8 @@ var init_node6 = __esm(() => {
|
|
|
309058
310201
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309059
310202
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309060
310203
|
}).then((httpResponse) => {
|
|
309061
|
-
return httpResponse.json().then((
|
|
309062
|
-
const response2 =
|
|
310204
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310205
|
+
const response2 = jsonResponse2;
|
|
309063
310206
|
response2.sdkHttpResponse = {
|
|
309064
310207
|
headers: httpResponse.headers
|
|
309065
310208
|
};
|
|
@@ -309154,8 +310297,8 @@ var init_node6 = __esm(() => {
|
|
|
309154
310297
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309155
310298
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309156
310299
|
}).then((httpResponse) => {
|
|
309157
|
-
return httpResponse.json().then((
|
|
309158
|
-
const response2 =
|
|
310300
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310301
|
+
const response2 = jsonResponse2;
|
|
309159
310302
|
response2.sdkHttpResponse = {
|
|
309160
310303
|
headers: httpResponse.headers
|
|
309161
310304
|
};
|
|
@@ -309569,8 +310712,8 @@ var init_node6 = __esm(() => {
|
|
|
309569
310712
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309570
310713
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309571
310714
|
}).then((httpResponse) => {
|
|
309572
|
-
return httpResponse.json().then((
|
|
309573
|
-
const response2 =
|
|
310715
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310716
|
+
const response2 = jsonResponse2;
|
|
309574
310717
|
response2.sdkHttpResponse = {
|
|
309575
310718
|
headers: httpResponse.headers
|
|
309576
310719
|
};
|
|
@@ -309597,8 +310740,8 @@ var init_node6 = __esm(() => {
|
|
|
309597
310740
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
309598
310741
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
309599
310742
|
}).then((httpResponse) => {
|
|
309600
|
-
return httpResponse.json().then((
|
|
309601
|
-
const response2 =
|
|
310743
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310744
|
+
const response2 = jsonResponse2;
|
|
309602
310745
|
response2.sdkHttpResponse = {
|
|
309603
310746
|
headers: httpResponse.headers
|
|
309604
310747
|
};
|
|
@@ -309728,8 +310871,8 @@ var init_node6 = __esm(() => {
|
|
|
309728
310871
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309729
310872
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309730
310873
|
}).then((httpResponse) => {
|
|
309731
|
-
return httpResponse.json().then((
|
|
309732
|
-
const response2 =
|
|
310874
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310875
|
+
const response2 = jsonResponse2;
|
|
309733
310876
|
response2.sdkHttpResponse = {
|
|
309734
310877
|
headers: httpResponse.headers
|
|
309735
310878
|
};
|
|
@@ -309756,8 +310899,8 @@ var init_node6 = __esm(() => {
|
|
|
309756
310899
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
309757
310900
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
309758
310901
|
}).then((httpResponse) => {
|
|
309759
|
-
return httpResponse.json().then((
|
|
309760
|
-
const response2 =
|
|
310902
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310903
|
+
const response2 = jsonResponse2;
|
|
309761
310904
|
response2.sdkHttpResponse = {
|
|
309762
310905
|
headers: httpResponse.headers
|
|
309763
310906
|
};
|
|
@@ -309791,8 +310934,8 @@ var init_node6 = __esm(() => {
|
|
|
309791
310934
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309792
310935
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309793
310936
|
}).then((httpResponse) => {
|
|
309794
|
-
return httpResponse.json().then((
|
|
309795
|
-
const response2 =
|
|
310937
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310938
|
+
const response2 = jsonResponse2;
|
|
309796
310939
|
response2.sdkHttpResponse = {
|
|
309797
310940
|
headers: httpResponse.headers
|
|
309798
310941
|
};
|
|
@@ -309819,8 +310962,8 @@ var init_node6 = __esm(() => {
|
|
|
309819
310962
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
309820
310963
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
309821
310964
|
}).then((httpResponse) => {
|
|
309822
|
-
return httpResponse.json().then((
|
|
309823
|
-
const response2 =
|
|
310965
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
310966
|
+
const response2 = jsonResponse2;
|
|
309824
310967
|
response2.sdkHttpResponse = {
|
|
309825
310968
|
headers: httpResponse.headers
|
|
309826
310969
|
};
|
|
@@ -309854,8 +310997,8 @@ var init_node6 = __esm(() => {
|
|
|
309854
310997
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309855
310998
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309856
310999
|
}).then((httpResponse) => {
|
|
309857
|
-
return httpResponse.json().then((
|
|
309858
|
-
const response2 =
|
|
311000
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311001
|
+
const response2 = jsonResponse2;
|
|
309859
311002
|
response2.sdkHttpResponse = {
|
|
309860
311003
|
headers: httpResponse.headers
|
|
309861
311004
|
};
|
|
@@ -309891,8 +311034,8 @@ var init_node6 = __esm(() => {
|
|
|
309891
311034
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
309892
311035
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
309893
311036
|
}).then((httpResponse) => {
|
|
309894
|
-
return httpResponse.json().then((
|
|
309895
|
-
const response2 =
|
|
311037
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311038
|
+
const response2 = jsonResponse2;
|
|
309896
311039
|
response2.sdkHttpResponse = {
|
|
309897
311040
|
headers: httpResponse.headers
|
|
309898
311041
|
};
|
|
@@ -310037,8 +311180,8 @@ var init_node6 = __esm(() => {
|
|
|
310037
311180
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
310038
311181
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
310039
311182
|
}).then((httpResponse) => {
|
|
310040
|
-
return httpResponse.json().then((
|
|
310041
|
-
const response2 =
|
|
311183
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311184
|
+
const response2 = jsonResponse2;
|
|
310042
311185
|
response2.sdkHttpResponse = {
|
|
310043
311186
|
headers: httpResponse.headers
|
|
310044
311187
|
};
|
|
@@ -310065,8 +311208,8 @@ var init_node6 = __esm(() => {
|
|
|
310065
311208
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
310066
311209
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
310067
311210
|
}).then((httpResponse) => {
|
|
310068
|
-
return httpResponse.json().then((
|
|
310069
|
-
const response2 =
|
|
311211
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311212
|
+
const response2 = jsonResponse2;
|
|
310070
311213
|
response2.sdkHttpResponse = {
|
|
310071
311214
|
headers: httpResponse.headers
|
|
310072
311215
|
};
|
|
@@ -310147,8 +311290,8 @@ var init_node6 = __esm(() => {
|
|
|
310147
311290
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
310148
311291
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
310149
311292
|
}).then((httpResponse) => {
|
|
310150
|
-
return httpResponse.json().then((
|
|
310151
|
-
const response2 =
|
|
311293
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311294
|
+
const response2 = jsonResponse2;
|
|
310152
311295
|
response2.sdkHttpResponse = {
|
|
310153
311296
|
headers: httpResponse.headers
|
|
310154
311297
|
};
|
|
@@ -310175,8 +311318,8 @@ var init_node6 = __esm(() => {
|
|
|
310175
311318
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
310176
311319
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
310177
311320
|
}).then((httpResponse) => {
|
|
310178
|
-
return httpResponse.json().then((
|
|
310179
|
-
const response2 =
|
|
311321
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311322
|
+
const response2 = jsonResponse2;
|
|
310180
311323
|
response2.sdkHttpResponse = {
|
|
310181
311324
|
headers: httpResponse.headers
|
|
310182
311325
|
};
|
|
@@ -310210,8 +311353,8 @@ var init_node6 = __esm(() => {
|
|
|
310210
311353
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
310211
311354
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
310212
311355
|
}).then((httpResponse) => {
|
|
310213
|
-
return httpResponse.json().then((
|
|
310214
|
-
const response2 =
|
|
311356
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311357
|
+
const response2 = jsonResponse2;
|
|
310215
311358
|
response2.sdkHttpResponse = {
|
|
310216
311359
|
headers: httpResponse.headers
|
|
310217
311360
|
};
|
|
@@ -310238,8 +311381,8 @@ var init_node6 = __esm(() => {
|
|
|
310238
311381
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
310239
311382
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
310240
311383
|
}).then((httpResponse) => {
|
|
310241
|
-
return httpResponse.json().then((
|
|
310242
|
-
const response2 =
|
|
311384
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311385
|
+
const response2 = jsonResponse2;
|
|
310243
311386
|
response2.sdkHttpResponse = {
|
|
310244
311387
|
headers: httpResponse.headers
|
|
310245
311388
|
};
|
|
@@ -310273,8 +311416,8 @@ var init_node6 = __esm(() => {
|
|
|
310273
311416
|
httpOptions: (_a2 = params.config) === null || _a2 === undefined ? undefined : _a2.httpOptions,
|
|
310274
311417
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
310275
311418
|
}).then((httpResponse) => {
|
|
310276
|
-
return httpResponse.json().then((
|
|
310277
|
-
const response2 =
|
|
311419
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
311420
|
+
const response2 = jsonResponse2;
|
|
310278
311421
|
response2.sdkHttpResponse = {
|
|
310279
311422
|
headers: httpResponse.headers
|
|
310280
311423
|
};
|
|
@@ -311309,8 +312452,8 @@ var init_node6 = __esm(() => {
|
|
|
311309
312452
|
httpOptions: (_a3 = params.config) === null || _a3 === undefined ? undefined : _a3.httpOptions,
|
|
311310
312453
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
311311
312454
|
}).then((httpResponse) => {
|
|
311312
|
-
return httpResponse.json().then((
|
|
311313
|
-
const response2 =
|
|
312455
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312456
|
+
const response2 = jsonResponse2;
|
|
311314
312457
|
response2.sdkHttpResponse = {
|
|
311315
312458
|
headers: httpResponse.headers
|
|
311316
312459
|
};
|
|
@@ -311335,8 +312478,8 @@ var init_node6 = __esm(() => {
|
|
|
311335
312478
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
311336
312479
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
311337
312480
|
}).then((httpResponse) => {
|
|
311338
|
-
return httpResponse.json().then((
|
|
311339
|
-
const response2 =
|
|
312481
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312482
|
+
const response2 = jsonResponse2;
|
|
311340
312483
|
response2.sdkHttpResponse = {
|
|
311341
312484
|
headers: httpResponse.headers
|
|
311342
312485
|
};
|
|
@@ -311368,8 +312511,8 @@ var init_node6 = __esm(() => {
|
|
|
311368
312511
|
httpOptions: (_a3 = params.config) === null || _a3 === undefined ? undefined : _a3.httpOptions,
|
|
311369
312512
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
311370
312513
|
}).then((httpResponse) => {
|
|
311371
|
-
return httpResponse.json().then((
|
|
311372
|
-
const response2 =
|
|
312514
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312515
|
+
const response2 = jsonResponse2;
|
|
311373
312516
|
response2.sdkHttpResponse = {
|
|
311374
312517
|
headers: httpResponse.headers
|
|
311375
312518
|
};
|
|
@@ -311405,8 +312548,8 @@ var init_node6 = __esm(() => {
|
|
|
311405
312548
|
httpOptions: (_a3 = params.config) === null || _a3 === undefined ? undefined : _a3.httpOptions,
|
|
311406
312549
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
311407
312550
|
}).then((httpResponse) => {
|
|
311408
|
-
return httpResponse.json().then((
|
|
311409
|
-
const response2 =
|
|
312551
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312552
|
+
const response2 = jsonResponse2;
|
|
311410
312553
|
response2.sdkHttpResponse = {
|
|
311411
312554
|
headers: httpResponse.headers
|
|
311412
312555
|
};
|
|
@@ -311433,8 +312576,8 @@ var init_node6 = __esm(() => {
|
|
|
311433
312576
|
httpOptions: (_c = params.config) === null || _c === undefined ? undefined : _c.httpOptions,
|
|
311434
312577
|
abortSignal: (_d = params.config) === null || _d === undefined ? undefined : _d.abortSignal
|
|
311435
312578
|
}).then((httpResponse) => {
|
|
311436
|
-
return httpResponse.json().then((
|
|
311437
|
-
const response2 =
|
|
312579
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312580
|
+
const response2 = jsonResponse2;
|
|
311438
312581
|
response2.sdkHttpResponse = {
|
|
311439
312582
|
headers: httpResponse.headers
|
|
311440
312583
|
};
|
|
@@ -311468,8 +312611,8 @@ var init_node6 = __esm(() => {
|
|
|
311468
312611
|
httpOptions: (_a3 = params.config) === null || _a3 === undefined ? undefined : _a3.httpOptions,
|
|
311469
312612
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
311470
312613
|
}).then((httpResponse) => {
|
|
311471
|
-
return httpResponse.json().then((
|
|
311472
|
-
const response2 =
|
|
312614
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312615
|
+
const response2 = jsonResponse2;
|
|
311473
312616
|
response2.sdkHttpResponse = {
|
|
311474
312617
|
headers: httpResponse.headers
|
|
311475
312618
|
};
|
|
@@ -311505,8 +312648,8 @@ var init_node6 = __esm(() => {
|
|
|
311505
312648
|
httpOptions: (_a3 = params.config) === null || _a3 === undefined ? undefined : _a3.httpOptions,
|
|
311506
312649
|
abortSignal: (_b = params.config) === null || _b === undefined ? undefined : _b.abortSignal
|
|
311507
312650
|
}).then((httpResponse) => {
|
|
311508
|
-
return httpResponse.json().then((
|
|
311509
|
-
const response2 =
|
|
312651
|
+
return httpResponse.json().then((jsonResponse2) => {
|
|
312652
|
+
const response2 = jsonResponse2;
|
|
311510
312653
|
response2.sdkHttpResponse = {
|
|
311511
312654
|
headers: httpResponse.headers
|
|
311512
312655
|
};
|
|
@@ -313425,7 +314568,7 @@ class AccessService {
|
|
|
313425
314568
|
var DEFAULT_PAIRING_EXPIRY_MS, MAX_PENDING_PER_INSTANCE = 3, PAIRING_CODE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", PAIRING_CODE_LENGTH = 6, PairingRequestExpiredError, PairingRequestConsumedError;
|
|
313426
314569
|
var init_access = __esm(() => {
|
|
313427
314570
|
init_src();
|
|
313428
|
-
|
|
314571
|
+
init_src6();
|
|
313429
314572
|
init_drizzle_orm();
|
|
313430
314573
|
init_cache_keys();
|
|
313431
314574
|
DEFAULT_PAIRING_EXPIRY_MS = 60 * 60 * 1000;
|
|
@@ -313774,7 +314917,7 @@ var log76;
|
|
|
313774
314917
|
var init_agent_runner = __esm(() => {
|
|
313775
314918
|
init_src();
|
|
313776
314919
|
init_src();
|
|
313777
|
-
|
|
314920
|
+
init_src6();
|
|
313778
314921
|
init_drizzle_orm();
|
|
313779
314922
|
log76 = createLogger("agent-runner");
|
|
313780
314923
|
});
|
|
@@ -314186,7 +315329,7 @@ class AgentTaskService {
|
|
|
314186
315329
|
var log78;
|
|
314187
315330
|
var init_agent_tasks = __esm(() => {
|
|
314188
315331
|
init_src();
|
|
314189
|
-
|
|
315332
|
+
init_src6();
|
|
314190
315333
|
init_drizzle_orm();
|
|
314191
315334
|
log78 = createLogger("services:agent-tasks");
|
|
314192
315335
|
});
|
|
@@ -314257,7 +315400,7 @@ class AgentService {
|
|
|
314257
315400
|
}
|
|
314258
315401
|
var init_agents = __esm(() => {
|
|
314259
315402
|
init_src();
|
|
314260
|
-
|
|
315403
|
+
init_src6();
|
|
314261
315404
|
init_drizzle_orm();
|
|
314262
315405
|
});
|
|
314263
315406
|
|
|
@@ -314318,7 +315461,7 @@ class AuditService {
|
|
|
314318
315461
|
var log79;
|
|
314319
315462
|
var init_audit = __esm(() => {
|
|
314320
315463
|
init_src();
|
|
314321
|
-
|
|
315464
|
+
init_src6();
|
|
314322
315465
|
init_drizzle_orm();
|
|
314323
315466
|
log79 = createLogger("audit");
|
|
314324
315467
|
});
|
|
@@ -314527,7 +315670,7 @@ class AutomationService {
|
|
|
314527
315670
|
}
|
|
314528
315671
|
var init_automations2 = __esm(() => {
|
|
314529
315672
|
init_src();
|
|
314530
|
-
|
|
315673
|
+
init_src6();
|
|
314531
315674
|
init_drizzle_orm();
|
|
314532
315675
|
});
|
|
314533
315676
|
|
|
@@ -315876,7 +317019,7 @@ class APIClient {
|
|
|
315876
317019
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
315877
317020
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
315878
317021
|
}
|
|
315879
|
-
await
|
|
317022
|
+
await sleep4(timeoutMillis);
|
|
315880
317023
|
return this.makeRequest(options, retriesRemaining - 1);
|
|
315881
317024
|
}
|
|
315882
317025
|
calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
|
|
@@ -316056,7 +317199,7 @@ var __classPrivateFieldSet = function(receiver, state, value, kind2, f2) {
|
|
|
316056
317199
|
}
|
|
316057
317200
|
}, startsWithSchemeRegexp2, isAbsoluteURL2 = (url) => {
|
|
316058
317201
|
return startsWithSchemeRegexp2.test(url);
|
|
316059
|
-
},
|
|
317202
|
+
}, sleep4 = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms)), validatePositiveInteger2 = (name, n2) => {
|
|
316060
317203
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
316061
317204
|
throw new GroqError(`${name} must be an integer`);
|
|
316062
317205
|
}
|
|
@@ -316664,7 +317807,7 @@ function buildPrompt4(language, options, defaultPrompt, defaultGlossary) {
|
|
|
316664
317807
|
|
|
316665
317808
|
`).slice(0, 4000);
|
|
316666
317809
|
}
|
|
316667
|
-
function
|
|
317810
|
+
function extractText3(content) {
|
|
316668
317811
|
let raw2 = "";
|
|
316669
317812
|
if (typeof content === "string")
|
|
316670
317813
|
raw2 = content;
|
|
@@ -316894,7 +318037,7 @@ var init_audio2 = __esm(() => {
|
|
|
316894
318037
|
if (!response.ok)
|
|
316895
318038
|
throw new Error(`OpenAI audio chat error (${response.status}): ${await response.text()}`);
|
|
316896
318039
|
const data = await response.json();
|
|
316897
|
-
return
|
|
318040
|
+
return extractText3(data.choices?.[0]?.message?.content);
|
|
316898
318041
|
}, { timeoutMs: timeouts.audioTimeoutMs });
|
|
316899
318042
|
return this.createSuccessResult(text3, "openai", model, language);
|
|
316900
318043
|
} catch (error3) {
|
|
@@ -319224,7 +320367,7 @@ class APIClient2 {
|
|
|
319224
320367
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
319225
320368
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
319226
320369
|
}
|
|
319227
|
-
await
|
|
320370
|
+
await sleep5(timeoutMillis);
|
|
319228
320371
|
return this.makeRequest(options, retriesRemaining - 1);
|
|
319229
320372
|
}
|
|
319230
320373
|
calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
|
|
@@ -319431,7 +320574,7 @@ var __classPrivateFieldSet3 = function(receiver, state, value, kind3, f2) {
|
|
|
319431
320574
|
}
|
|
319432
320575
|
}, startsWithSchemeRegexp3, isAbsoluteURL3 = (url) => {
|
|
319433
320576
|
return startsWithSchemeRegexp3.test(url);
|
|
319434
|
-
},
|
|
320577
|
+
}, sleep5 = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms)), validatePositiveInteger3 = (name, n2) => {
|
|
319435
320578
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
319436
320579
|
throw new OpenAIError(`${name} must be an integer`);
|
|
319437
320580
|
}
|
|
@@ -322049,7 +323192,7 @@ var init_runs = __esm(() => {
|
|
|
322049
323192
|
}
|
|
322050
323193
|
}
|
|
322051
323194
|
}
|
|
322052
|
-
await
|
|
323195
|
+
await sleep5(sleepInterval);
|
|
322053
323196
|
break;
|
|
322054
323197
|
case "requires_action":
|
|
322055
323198
|
case "incomplete":
|
|
@@ -322452,7 +323595,7 @@ var init_files3 = __esm(() => {
|
|
|
322452
323595
|
const start = Date.now();
|
|
322453
323596
|
let file = await this.retrieve(id);
|
|
322454
323597
|
while (!file.status || !TERMINAL_STATES.has(file.status)) {
|
|
322455
|
-
await
|
|
323598
|
+
await sleep5(pollInterval);
|
|
322456
323599
|
file = await this.retrieve(id);
|
|
322457
323600
|
if (Date.now() - start > maxWait) {
|
|
322458
323601
|
throw new APIConnectionTimeoutError3({
|
|
@@ -323275,7 +324418,7 @@ var init_files4 = __esm(() => {
|
|
|
323275
324418
|
}
|
|
323276
324419
|
}
|
|
323277
324420
|
}
|
|
323278
|
-
await
|
|
324421
|
+
await sleep5(sleepInterval);
|
|
323279
324422
|
break;
|
|
323280
324423
|
case "failed":
|
|
323281
324424
|
case "completed":
|
|
@@ -323363,7 +324506,7 @@ var init_file_batches = __esm(() => {
|
|
|
323363
324506
|
}
|
|
323364
324507
|
}
|
|
323365
324508
|
}
|
|
323366
|
-
await
|
|
324509
|
+
await sleep5(sleepInterval);
|
|
323367
324510
|
break;
|
|
323368
324511
|
case "failed":
|
|
323369
324512
|
case "cancelled":
|
|
@@ -333712,7 +334855,7 @@ var init_service = __esm(() => {
|
|
|
333712
334855
|
});
|
|
333713
334856
|
|
|
333714
334857
|
// ../media-processing/src/index.ts
|
|
333715
|
-
var
|
|
334858
|
+
var init_src7 = __esm(() => {
|
|
333716
334859
|
init_service();
|
|
333717
334860
|
init_processors();
|
|
333718
334861
|
init_retry();
|
|
@@ -334085,7 +335228,7 @@ var log84, DEFAULT_MEDIA_PATH = "./data/media";
|
|
|
334085
335228
|
var init_media_storage = __esm(() => {
|
|
334086
335229
|
init_src2();
|
|
334087
335230
|
init_src();
|
|
334088
|
-
|
|
335231
|
+
init_src6();
|
|
334089
335232
|
init_drizzle_orm();
|
|
334090
335233
|
init_safe_media_fetch();
|
|
334091
335234
|
log84 = createLogger("services:media-storage");
|
|
@@ -334681,8 +335824,8 @@ class BatchJobService {
|
|
|
334681
335824
|
var log85, PROCESSABLE_CONTENT_TYPES;
|
|
334682
335825
|
var init_batch_jobs = __esm(() => {
|
|
334683
335826
|
init_src();
|
|
334684
|
-
init_src5();
|
|
334685
335827
|
init_src6();
|
|
335828
|
+
init_src7();
|
|
334686
335829
|
init_drizzle_orm();
|
|
334687
335830
|
init_batch_pricing();
|
|
334688
335831
|
init_media_storage();
|
|
@@ -335211,7 +336354,7 @@ class ChatService {
|
|
|
335211
336354
|
var log86, ATTENTION_LABEL = "follow-up", GROUP_CHAT_TYPES;
|
|
335212
336355
|
var init_chats = __esm(() => {
|
|
335213
336356
|
init_src();
|
|
335214
|
-
|
|
336357
|
+
init_src6();
|
|
335215
336358
|
init_drizzle_orm();
|
|
335216
336359
|
log86 = createLogger("chats");
|
|
335217
336360
|
GROUP_CHAT_TYPES = new Set(["group", "community"]);
|
|
@@ -335276,7 +336419,7 @@ class ConsumerOffsetService {
|
|
|
335276
336419
|
var log87;
|
|
335277
336420
|
var init_consumer_offsets = __esm(() => {
|
|
335278
336421
|
init_src();
|
|
335279
|
-
|
|
336422
|
+
init_src6();
|
|
335280
336423
|
init_drizzle_orm();
|
|
335281
336424
|
log87 = createLogger("consumer-offsets");
|
|
335282
336425
|
});
|
|
@@ -335336,7 +336479,7 @@ class ConversationService {
|
|
|
335336
336479
|
var log88;
|
|
335337
336480
|
var init_conversations = __esm(() => {
|
|
335338
336481
|
init_src();
|
|
335339
|
-
|
|
336482
|
+
init_src6();
|
|
335340
336483
|
init_drizzle_orm();
|
|
335341
336484
|
log88 = createLogger("services:conversations");
|
|
335342
336485
|
});
|
|
@@ -335560,7 +336703,7 @@ class DeadLetterService {
|
|
|
335560
336703
|
var log89;
|
|
335561
336704
|
var init_dead_letters = __esm(() => {
|
|
335562
336705
|
init_src();
|
|
335563
|
-
|
|
336706
|
+
init_src6();
|
|
335564
336707
|
init_drizzle_orm();
|
|
335565
336708
|
log89 = createLogger("dead-letters");
|
|
335566
336709
|
});
|
|
@@ -335817,7 +336960,7 @@ class EventOpsService {
|
|
|
335817
336960
|
var log90;
|
|
335818
336961
|
var init_event_ops = __esm(() => {
|
|
335819
336962
|
init_src();
|
|
335820
|
-
|
|
336963
|
+
init_src6();
|
|
335821
336964
|
init_drizzle_orm();
|
|
335822
336965
|
log90 = createLogger("event-ops");
|
|
335823
336966
|
});
|
|
@@ -335999,7 +337142,7 @@ class EventService {
|
|
|
335999
337142
|
}
|
|
336000
337143
|
var init_events2 = __esm(() => {
|
|
336001
337144
|
init_src();
|
|
336002
|
-
|
|
337145
|
+
init_src6();
|
|
336003
337146
|
init_drizzle_orm();
|
|
336004
337147
|
});
|
|
336005
337148
|
|
|
@@ -336272,7 +337415,7 @@ class FollowUpLifecycleService {
|
|
|
336272
337415
|
var log91, TERMINAL_DISARM_REASONS, TERMINAL_OVERRIDE_PROTECTED;
|
|
336273
337416
|
var init_follow_up_lifecycle = __esm(() => {
|
|
336274
337417
|
init_src();
|
|
336275
|
-
|
|
337418
|
+
init_src6();
|
|
336276
337419
|
init_drizzle_orm();
|
|
336277
337420
|
log91 = createLogger("follow-up-lifecycle");
|
|
336278
337421
|
TERMINAL_DISARM_REASONS = new Set([
|
|
@@ -336434,7 +337577,7 @@ class FollowUpSweeperService {
|
|
|
336434
337577
|
var log92, STALE_PAUSE_MAX_AGE_MS, STALE_PAUSE_MIN_AGE_MS = 60000, STALE_PAUSE_MAX_PER_TICK = 100;
|
|
336435
337578
|
var init_follow_up_sweeper = __esm(() => {
|
|
336436
337579
|
init_src();
|
|
336437
|
-
|
|
337580
|
+
init_src6();
|
|
336438
337581
|
init_drizzle_orm();
|
|
336439
337582
|
log92 = createLogger("follow-up-sweeper");
|
|
336440
337583
|
STALE_PAUSE_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -336496,7 +337639,7 @@ class GenieHostsService {
|
|
|
336496
337639
|
var log93;
|
|
336497
337640
|
var init_genie_hosts = __esm(() => {
|
|
336498
337641
|
init_src();
|
|
336499
|
-
|
|
337642
|
+
init_src6();
|
|
336500
337643
|
init_drizzle_orm();
|
|
336501
337644
|
log93 = createLogger("genie-hosts");
|
|
336502
337645
|
});
|
|
@@ -336633,7 +337776,7 @@ class InstanceService {
|
|
|
336633
337776
|
}
|
|
336634
337777
|
var init_instances = __esm(() => {
|
|
336635
337778
|
init_src();
|
|
336636
|
-
|
|
337779
|
+
init_src6();
|
|
336637
337780
|
init_drizzle_orm();
|
|
336638
337781
|
});
|
|
336639
337782
|
|
|
@@ -337051,7 +338194,7 @@ class MessageService {
|
|
|
337051
338194
|
var MEDIA_BADGES;
|
|
337052
338195
|
var init_messages3 = __esm(() => {
|
|
337053
338196
|
init_src();
|
|
337054
|
-
|
|
338197
|
+
init_src6();
|
|
337055
338198
|
init_drizzle_orm();
|
|
337056
338199
|
MEDIA_BADGES = {
|
|
337057
338200
|
image: "[Image]",
|
|
@@ -337215,7 +338358,7 @@ class PayloadStoreService {
|
|
|
337215
338358
|
var log94;
|
|
337216
338359
|
var init_payload_store2 = __esm(() => {
|
|
337217
338360
|
init_src();
|
|
337218
|
-
|
|
338361
|
+
init_src6();
|
|
337219
338362
|
init_drizzle_orm();
|
|
337220
338363
|
log94 = createLogger("payload-store");
|
|
337221
338364
|
});
|
|
@@ -337665,7 +338808,7 @@ class PersonService {
|
|
|
337665
338808
|
}
|
|
337666
338809
|
var init_persons = __esm(() => {
|
|
337667
338810
|
init_src();
|
|
337668
|
-
|
|
338811
|
+
init_src6();
|
|
337669
338812
|
init_drizzle_orm();
|
|
337670
338813
|
});
|
|
337671
338814
|
|
|
@@ -337687,7 +338830,7 @@ async function withIdempotency(db2, eventId, handler, fn) {
|
|
|
337687
338830
|
var log95;
|
|
337688
338831
|
var init_idempotency = __esm(() => {
|
|
337689
338832
|
init_src();
|
|
337690
|
-
|
|
338833
|
+
init_src6();
|
|
337691
338834
|
log95 = createLogger("idempotency");
|
|
337692
338835
|
});
|
|
337693
338836
|
|
|
@@ -338233,7 +339376,7 @@ function getPluginStorage(pluginId) {
|
|
|
338233
339376
|
var log97, globalDb = null, storageInstances;
|
|
338234
339377
|
var init_storage = __esm(() => {
|
|
338235
339378
|
init_src();
|
|
338236
|
-
|
|
339379
|
+
init_src6();
|
|
338237
339380
|
init_drizzle_orm();
|
|
338238
339381
|
log97 = createLogger("api:storage");
|
|
338239
339382
|
storageInstances = new Map;
|
|
@@ -338315,13 +339458,13 @@ async function loadChannelPlugins2(options) {
|
|
|
338315
339458
|
const preRegistered = channelRegistry2.getAll();
|
|
338316
339459
|
if (preRegistered.length > 0) {
|
|
338317
339460
|
logger6.info("Using pre-registered channel plugins", { count: preRegistered.length });
|
|
338318
|
-
for (const
|
|
339461
|
+
for (const plugin8 of preRegistered) {
|
|
338319
339462
|
try {
|
|
338320
|
-
const context20 = createPluginContext({ pluginId:
|
|
338321
|
-
await channelRegistry2.initialize(
|
|
338322
|
-
logger6.info(`Initialized channel: ${
|
|
339463
|
+
const context20 = createPluginContext({ pluginId: plugin8.id, eventBus, db: db2 });
|
|
339464
|
+
await channelRegistry2.initialize(plugin8.id, context20);
|
|
339465
|
+
logger6.info(`Initialized channel: ${plugin8.id}`, { name: plugin8.name, version: plugin8.version });
|
|
338323
339466
|
} catch (error3) {
|
|
338324
|
-
logger6.error(`Failed to initialize channel: ${
|
|
339467
|
+
logger6.error(`Failed to initialize channel: ${plugin8.id}`, { error: String(error3) });
|
|
338325
339468
|
}
|
|
338326
339469
|
}
|
|
338327
339470
|
return {
|
|
@@ -338345,17 +339488,17 @@ async function loadChannelPlugins2(options) {
|
|
|
338345
339488
|
for (const failure of discoveryResult.failed) {
|
|
338346
339489
|
logger6.error("Failed to load plugin", { path: failure.path, error: failure.error });
|
|
338347
339490
|
}
|
|
338348
|
-
for (const
|
|
339491
|
+
for (const plugin8 of discoveryResult.registered) {
|
|
338349
339492
|
try {
|
|
338350
339493
|
const context20 = createPluginContext({
|
|
338351
|
-
pluginId:
|
|
339494
|
+
pluginId: plugin8.id,
|
|
338352
339495
|
eventBus,
|
|
338353
339496
|
db: db2
|
|
338354
339497
|
});
|
|
338355
|
-
await channelRegistry2.initialize(
|
|
338356
|
-
logger6.info(`Initialized channel: ${
|
|
339498
|
+
await channelRegistry2.initialize(plugin8.id, context20);
|
|
339499
|
+
logger6.info(`Initialized channel: ${plugin8.id}`, { name: plugin8.name, version: plugin8.version });
|
|
338357
339500
|
} catch (error3) {
|
|
338358
|
-
logger6.error(`Failed to initialize channel: ${
|
|
339501
|
+
logger6.error(`Failed to initialize channel: ${plugin8.id}`, { error: String(error3) });
|
|
338359
339502
|
}
|
|
338360
339503
|
}
|
|
338361
339504
|
return {
|
|
@@ -338650,11 +339793,11 @@ async function processSenderIdentity(services, payload, metadata, channel5) {
|
|
|
338650
339793
|
}
|
|
338651
339794
|
async function fetchAndUpdateProfile(services, channel5, instanceId, userId, identityId) {
|
|
338652
339795
|
try {
|
|
338653
|
-
const
|
|
338654
|
-
if (!
|
|
339796
|
+
const plugin8 = await getPlugin(channel5);
|
|
339797
|
+
if (!plugin8 || !("fetchUserProfile" in plugin8))
|
|
338655
339798
|
return;
|
|
338656
|
-
const fetchProfile =
|
|
338657
|
-
const profile = await fetchProfile.call(
|
|
339799
|
+
const fetchProfile = plugin8.fetchUserProfile;
|
|
339800
|
+
const profile = await fetchProfile.call(plugin8, instanceId, userId);
|
|
338658
339801
|
if (profile.avatarUrl || profile.bio || profile.platformData) {
|
|
338659
339802
|
await services.persons.updateIdentityProfile(identityId, profile);
|
|
338660
339803
|
log100.debug("Updated identity with profile data", {
|
|
@@ -339191,7 +340334,7 @@ function createSessionStorage(db2, providerId = "default", maxSessionAgeMs = DEF
|
|
|
339191
340334
|
}
|
|
339192
340335
|
var DEFAULT_MAX_SESSION_AGE_MS;
|
|
339193
340336
|
var init_session_storage = __esm(() => {
|
|
339194
|
-
|
|
340337
|
+
init_src6();
|
|
339195
340338
|
init_drizzle_orm();
|
|
339196
340339
|
DEFAULT_MAX_SESSION_AGE_MS = 4 * 60 * 60 * 1000;
|
|
339197
340340
|
});
|
|
@@ -339316,11 +340459,11 @@ function activeProviderTraceContext() {
|
|
|
339316
340459
|
traceState: spanContext.traceState?.serialize()
|
|
339317
340460
|
};
|
|
339318
340461
|
}
|
|
339319
|
-
function createPluginAckProvider(
|
|
339320
|
-
if (!
|
|
340462
|
+
function createPluginAckProvider(plugin8) {
|
|
340463
|
+
if (!plugin8?.react || !plugin8?.unreact)
|
|
339321
340464
|
return null;
|
|
339322
|
-
const reactFn =
|
|
339323
|
-
const unreactFn =
|
|
340465
|
+
const reactFn = plugin8.react.bind(plugin8);
|
|
340466
|
+
const unreactFn = plugin8.unreact.bind(plugin8);
|
|
339324
340467
|
return {
|
|
339325
340468
|
ack: (instanceId, chatId, messageId, emoji) => reactFn(instanceId, chatId, messageId, emoji),
|
|
339326
340469
|
removeAck: (instanceId, chatId, messageId, emoji) => unreactFn(instanceId, chatId, messageId, emoji)
|
|
@@ -339451,23 +340594,23 @@ function determineChatType(chatId, channel5, rawPayload) {
|
|
|
339451
340594
|
}
|
|
339452
340595
|
async function sendTypingPresence(channel5, instanceId, chatId, state) {
|
|
339453
340596
|
try {
|
|
339454
|
-
const
|
|
339455
|
-
if (
|
|
340597
|
+
const plugin8 = await getPlugin(channel5);
|
|
340598
|
+
if (plugin8 && "sendTyping" in plugin8 && typeof plugin8.sendTyping === "function") {
|
|
339456
340599
|
const duration = state === "composing" ? 30000 : 0;
|
|
339457
|
-
await
|
|
340600
|
+
await plugin8.sendTyping(instanceId, chatId, duration);
|
|
339458
340601
|
}
|
|
339459
340602
|
} catch (error3) {
|
|
339460
340603
|
log101.debug("Failed to send typing presence", { error: String(error3) });
|
|
339461
340604
|
}
|
|
339462
340605
|
}
|
|
339463
340606
|
async function sendTextMessage5(channel5, instanceId, chatId, text3, messageFormatMode = "convert", replyTo, correlationId, senderAgentId) {
|
|
339464
|
-
const
|
|
339465
|
-
if (!
|
|
340607
|
+
const plugin8 = await getPlugin(channel5);
|
|
340608
|
+
if (!plugin8)
|
|
339466
340609
|
throw new Error(`Channel plugin not found: ${channel5}`);
|
|
339467
340610
|
const sanitized = sanitizeOutboundText(text3);
|
|
339468
340611
|
if (!sanitized)
|
|
339469
340612
|
return;
|
|
339470
|
-
await
|
|
340613
|
+
await plugin8.sendMessage(instanceId, {
|
|
339471
340614
|
to: chatId,
|
|
339472
340615
|
content: { type: "text", text: sanitized },
|
|
339473
340616
|
replyTo,
|
|
@@ -339492,12 +340635,12 @@ function resolveErrorHandoffMessage(env2 = process.env) {
|
|
|
339492
340635
|
return env2.OMNI_AGENT_ERROR_HANDOFF_MESSAGE?.trim() || DEFAULT_ERROR_HANDOFF_MESSAGE;
|
|
339493
340636
|
}
|
|
339494
340637
|
async function triggerErrorHandoff(services, db2, channel5, instance4, chatId, message2) {
|
|
339495
|
-
const
|
|
339496
|
-
if (
|
|
340638
|
+
const plugin8 = await getPlugin(channel5);
|
|
340639
|
+
if (plugin8?.capabilities?.canHandoff !== true)
|
|
339497
340640
|
return false;
|
|
339498
340641
|
let sendResult;
|
|
339499
340642
|
try {
|
|
339500
|
-
sendResult = await
|
|
340643
|
+
sendResult = await plugin8.sendMessage(instance4.id, {
|
|
339501
340644
|
to: chatId,
|
|
339502
340645
|
content: { type: "text", text: message2 },
|
|
339503
340646
|
metadata: { isHandoff: true, motivoHandoff: "agent_dispatch_error" }
|
|
@@ -339555,7 +340698,7 @@ async function handleDispatchFailure(services, db2, channel5, instance4, chatId,
|
|
|
339555
340698
|
return;
|
|
339556
340699
|
await sendErrorFeedback(channel5, instance4.id, chatId, error3, resolveDispatchErrorMessage(null)).catch(() => {});
|
|
339557
340700
|
}
|
|
339558
|
-
function
|
|
340701
|
+
function sleep6(ms) {
|
|
339559
340702
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
339560
340703
|
}
|
|
339561
340704
|
function extractErrorFields(error3) {
|
|
@@ -339576,7 +340719,7 @@ function isTransientDispatchError(error3) {
|
|
|
339576
340719
|
async function runWithTransientDispatchRetry(fn, context20, options = {}) {
|
|
339577
340720
|
const delays = options.delaysMs ?? TRANSIENT_DISPATCH_RETRY_DELAYS_MS;
|
|
339578
340721
|
const transient = options.isTransient ?? isTransientDispatchError;
|
|
339579
|
-
const sleeper = options.sleeper ??
|
|
340722
|
+
const sleeper = options.sleeper ?? sleep6;
|
|
339580
340723
|
const logger7 = options.logger ?? log101;
|
|
339581
340724
|
let lastError;
|
|
339582
340725
|
for (let attempt = 0;attempt <= delays.length; attempt++) {
|
|
@@ -339736,7 +340879,7 @@ async function waitForRecord(fn, maxMs = 5000, pollMs = 250) {
|
|
|
339736
340879
|
return result;
|
|
339737
340880
|
const deadline = Date.now() + maxMs;
|
|
339738
340881
|
while (Date.now() < deadline) {
|
|
339739
|
-
await
|
|
340882
|
+
await sleep6(pollMs);
|
|
339740
340883
|
result = await fn();
|
|
339741
340884
|
if (result)
|
|
339742
340885
|
return result;
|
|
@@ -339912,7 +341055,7 @@ async function sendResponseParts(channel5, instanceId, chatId, parts, splitConfi
|
|
|
339912
341055
|
const delay2 = calculateSplitDelay(splitConfig);
|
|
339913
341056
|
if (delay2 > 0) {
|
|
339914
341057
|
await sendTypingPresence(channel5, instanceId, chatId, "composing");
|
|
339915
|
-
await
|
|
341058
|
+
await sleep6(delay2);
|
|
339916
341059
|
}
|
|
339917
341060
|
}
|
|
339918
341061
|
}
|
|
@@ -339944,11 +341087,11 @@ async function collectProcessedMedia(services, instance4, messages4) {
|
|
|
339944
341087
|
function extractQuotedProviderAliases(rawPayload) {
|
|
339945
341088
|
if (!rawPayload)
|
|
339946
341089
|
return [];
|
|
339947
|
-
const messageObj =
|
|
339948
|
-
const replyContext =
|
|
339949
|
-
const rawMessage =
|
|
339950
|
-
const rawContext =
|
|
339951
|
-
const topContext =
|
|
341090
|
+
const messageObj = isRecord2(rawPayload.messageobj) ? rawPayload.messageobj : undefined;
|
|
341091
|
+
const replyContext = isRecord2(messageObj?.replyContext) ? messageObj.replyContext : undefined;
|
|
341092
|
+
const rawMessage = isRecord2(messageObj?.raw) ? messageObj.raw : undefined;
|
|
341093
|
+
const rawContext = isRecord2(rawMessage?.context) ? rawMessage.context : undefined;
|
|
341094
|
+
const topContext = isRecord2(rawPayload.context) ? rawPayload.context : undefined;
|
|
339952
341095
|
return uniqueNonEmpty([
|
|
339953
341096
|
replyContext?.internalId,
|
|
339954
341097
|
rawContext?.gsId,
|
|
@@ -339960,7 +341103,7 @@ function extractQuotedProviderAliases(rawPayload) {
|
|
|
339960
341103
|
function extractInboundPlatformDate(rawPayload) {
|
|
339961
341104
|
if (!rawPayload)
|
|
339962
341105
|
return;
|
|
339963
|
-
const messageObj =
|
|
341106
|
+
const messageObj = isRecord2(rawPayload.messageobj) ? rawPayload.messageobj : undefined;
|
|
339964
341107
|
const timestamp3 = messageObj?.timestamp;
|
|
339965
341108
|
if (typeof timestamp3 === "number" && Number.isFinite(timestamp3) && timestamp3 > 0) {
|
|
339966
341109
|
return new Date(timestamp3 * 1000);
|
|
@@ -340098,11 +341241,11 @@ async function resolvePersonId(services, channel5, instanceId, senderId, metadat
|
|
|
340098
341241
|
const identity = await services.persons.getIdentityByPlatformId(channel5, instanceId, senderId);
|
|
340099
341242
|
if (identity?.personId)
|
|
340100
341243
|
return identity.personId;
|
|
340101
|
-
await
|
|
341244
|
+
await sleep6(200);
|
|
340102
341245
|
}
|
|
340103
341246
|
return;
|
|
340104
341247
|
}
|
|
340105
|
-
function
|
|
341248
|
+
function isRecord2(value) {
|
|
340106
341249
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
340107
341250
|
}
|
|
340108
341251
|
function pickString(record, ...keys) {
|
|
@@ -340129,13 +341272,13 @@ function extractA2ACustomerContext(messages4, channel5) {
|
|
|
340129
341272
|
if (channel5 !== "a2a")
|
|
340130
341273
|
return;
|
|
340131
341274
|
const rawPayload = messages4[0]?.payload.rawPayload;
|
|
340132
|
-
if (!
|
|
341275
|
+
if (!isRecord2(rawPayload))
|
|
340133
341276
|
return;
|
|
340134
341277
|
const executionContext = rawPayload.omniExecutionContext;
|
|
340135
|
-
if (!
|
|
341278
|
+
if (!isRecord2(executionContext))
|
|
340136
341279
|
return;
|
|
340137
|
-
const customer =
|
|
340138
|
-
const identity =
|
|
341280
|
+
const customer = isRecord2(executionContext.customer) ? executionContext.customer : {};
|
|
341281
|
+
const identity = isRecord2(executionContext.identity) ? executionContext.identity : {};
|
|
340139
341282
|
return compactCustomerContext({
|
|
340140
341283
|
...customerContextFromRecord(customer),
|
|
340141
341284
|
externalUserId: pickString(customer, "externalUserId", "external_user_id") ?? pickString(identity, "platformUserId", "userId")
|
|
@@ -340146,7 +341289,7 @@ async function resolveCustomerContext(services, personId, externalContext) {
|
|
|
340146
341289
|
if (personId) {
|
|
340147
341290
|
try {
|
|
340148
341291
|
const person2 = await services.persons.getById(personId);
|
|
340149
|
-
if (person2 &&
|
|
341292
|
+
if (person2 && isRecord2(person2.metadata)) {
|
|
340150
341293
|
storedContext = customerContextFromRecord(person2.metadata);
|
|
340151
341294
|
}
|
|
340152
341295
|
} catch (error3) {
|
|
@@ -340218,11 +341361,11 @@ async function resolveStreamingCapabilities(services, instance4, channel5, chatI
|
|
|
340218
341361
|
});
|
|
340219
341362
|
return null;
|
|
340220
341363
|
}
|
|
340221
|
-
const
|
|
340222
|
-
if (!
|
|
341364
|
+
const plugin8 = await getPlugin(channel5);
|
|
341365
|
+
if (!plugin8?.capabilities?.canStreamResponse || !plugin8.createStreamSender) {
|
|
340223
341366
|
log101.debug("Stream guard: channel does not support streaming", {
|
|
340224
341367
|
channel: channel5,
|
|
340225
|
-
canStream:
|
|
341368
|
+
canStream: plugin8?.capabilities?.canStreamResponse,
|
|
340226
341369
|
chatId
|
|
340227
341370
|
});
|
|
340228
341371
|
return null;
|
|
@@ -340238,7 +341381,7 @@ async function resolveStreamingCapabilities(services, instance4, channel5, chatI
|
|
|
340238
341381
|
}
|
|
340239
341382
|
return {
|
|
340240
341383
|
provider,
|
|
340241
|
-
createSender:
|
|
341384
|
+
createSender: plugin8.createStreamSender.bind(plugin8)
|
|
340242
341385
|
};
|
|
340243
341386
|
}
|
|
340244
341387
|
async function consumeStream(generator, sender, instanceId, chatId, traceId) {
|
|
@@ -340964,14 +342107,14 @@ async function processHistoryMessage2(msg, mediaService, reactFn, unreactFn) {
|
|
|
340964
342107
|
return buildHistoryMediaResult(header, icon, contentType, processedContent, msg.content.caption, msg.content.text);
|
|
340965
342108
|
}
|
|
340966
342109
|
async function fetchAndProcessThreadHistory(services, instance4, channel5, chatId, threadId2) {
|
|
340967
|
-
const
|
|
340968
|
-
if (!
|
|
342110
|
+
const plugin8 = await getPlugin(channel5);
|
|
342111
|
+
if (!plugin8?.fetchHistory) {
|
|
340969
342112
|
log101.debug("Channel plugin does not support fetchHistory", { instanceId: instance4.id, channel: channel5 });
|
|
340970
342113
|
return [];
|
|
340971
342114
|
}
|
|
340972
342115
|
let historyResult;
|
|
340973
342116
|
try {
|
|
340974
|
-
historyResult = await
|
|
342117
|
+
historyResult = await plugin8.fetchHistory(instance4.id, {
|
|
340975
342118
|
channelId: chatId,
|
|
340976
342119
|
threadId: threadId2,
|
|
340977
342120
|
limit: 200
|
|
@@ -340995,8 +342138,8 @@ async function fetchAndProcessThreadHistory(services, instance4, channel5, chatI
|
|
|
340995
342138
|
mediaService = createMediaProcessingService({ groqApiKey, openaiApiKey, geminiApiKey });
|
|
340996
342139
|
}
|
|
340997
342140
|
} catch {}
|
|
340998
|
-
const boundReact =
|
|
340999
|
-
const boundUnreact =
|
|
342141
|
+
const boundReact = plugin8.react?.bind(plugin8);
|
|
342142
|
+
const boundUnreact = plugin8.unreact?.bind(plugin8);
|
|
341000
342143
|
const reactFn = boundReact ? (msgId, emoji) => boundReact(instance4.id, chatId, msgId, emoji) : null;
|
|
341001
342144
|
const unreactFn = boundUnreact ? (msgId, emoji) => boundUnreact(instance4.id, chatId, msgId, emoji) : null;
|
|
341002
342145
|
const CONCURRENCY = 5;
|
|
@@ -341142,10 +342285,10 @@ async function processAgentResponse(services, instance4, messages4, triggerType,
|
|
|
341142
342285
|
const senderId = firstMessage.payload.from ?? "";
|
|
341143
342286
|
const channel5 = firstMessage.metadata.channelType ?? instance4.channel;
|
|
341144
342287
|
const traceId = firstMessage.metadata.traceId ?? "";
|
|
341145
|
-
const
|
|
341146
|
-
const ackProvider = createPluginAckProvider(
|
|
342288
|
+
const plugin8 = await getPlugin(channel5) ?? null;
|
|
342289
|
+
const ackProvider = createPluginAckProvider(plugin8);
|
|
341147
342290
|
const messageId = firstMessage.payload.externalId ?? "";
|
|
341148
|
-
const ackHandle = startAck(
|
|
342291
|
+
const ackHandle = startAck(plugin8, ackProvider, instance4.id, chatId, messageId, channel5, buildAckConfig(instance4));
|
|
341149
342292
|
const personId = await resolvePersonId(services, channel5, instance4.id, senderId, firstMessage.metadata.personId);
|
|
341150
342293
|
if (!personId) {
|
|
341151
342294
|
log101.warn("Could not resolve person ID, skipping agent", { instanceId: instance4.id, chatId, senderId });
|
|
@@ -342350,8 +343493,8 @@ var import_api32, log101, agentDispatchLimiter, _natsGenieProviderCtor, QUOTED_M
|
|
|
342350
343493
|
var init_agent_dispatcher = __esm(() => {
|
|
342351
343494
|
init_src2();
|
|
342352
343495
|
init_src();
|
|
342353
|
-
init_src5();
|
|
342354
343496
|
init_src6();
|
|
343497
|
+
init_src7();
|
|
342355
343498
|
init_esm5();
|
|
342356
343499
|
init_drizzle_orm();
|
|
342357
343500
|
init_idempotency();
|
|
@@ -342364,7 +343507,7 @@ var init_agent_dispatcher = __esm(() => {
|
|
|
342364
343507
|
init_message_debouncer();
|
|
342365
343508
|
init_message_persistence();
|
|
342366
343509
|
init_session_storage();
|
|
342367
|
-
|
|
343510
|
+
init_src7();
|
|
342368
343511
|
import_api32 = __toESM(require_src(), 1);
|
|
342369
343512
|
log101 = createLogger("agent-dispatcher");
|
|
342370
343513
|
agentDispatchLimiter = new AgentDispatchLimiter(loadAgentDispatchLimiterConfig(process.env, log101), log101);
|
|
@@ -342501,7 +343644,7 @@ class ProviderService {
|
|
|
342501
343644
|
}
|
|
342502
343645
|
var init_providers2 = __esm(() => {
|
|
342503
343646
|
init_src();
|
|
342504
|
-
|
|
343647
|
+
init_src6();
|
|
342505
343648
|
init_drizzle_orm();
|
|
342506
343649
|
init_agent_dispatcher();
|
|
342507
343650
|
});
|
|
@@ -342605,7 +343748,7 @@ class RouteResolver {
|
|
|
342605
343748
|
var log102, UUID_RE2, NO_ROUTE;
|
|
342606
343749
|
var init_route_resolver = __esm(() => {
|
|
342607
343750
|
init_src();
|
|
342608
|
-
|
|
343751
|
+
init_src6();
|
|
342609
343752
|
init_drizzle_orm();
|
|
342610
343753
|
init_index_min();
|
|
342611
343754
|
log102 = createLogger("route-resolver");
|
|
@@ -342732,7 +343875,7 @@ class RouteService {
|
|
|
342732
343875
|
}
|
|
342733
343876
|
var init_routes = __esm(() => {
|
|
342734
343877
|
init_src();
|
|
342735
|
-
|
|
343878
|
+
init_src6();
|
|
342736
343879
|
init_drizzle_orm();
|
|
342737
343880
|
});
|
|
342738
343881
|
|
|
@@ -342908,7 +344051,7 @@ class SettingsService {
|
|
|
342908
344051
|
var log103, DEFAULT_SETTINGS;
|
|
342909
344052
|
var init_settings = __esm(() => {
|
|
342910
344053
|
init_src();
|
|
342911
|
-
|
|
344054
|
+
init_src6();
|
|
342912
344055
|
init_drizzle_orm();
|
|
342913
344056
|
log103 = createLogger("settings");
|
|
342914
344057
|
DEFAULT_SETTINGS = [
|
|
@@ -343365,7 +344508,7 @@ class SyncJobService {
|
|
|
343365
344508
|
}
|
|
343366
344509
|
var init_sync_jobs = __esm(() => {
|
|
343367
344510
|
init_src();
|
|
343368
|
-
|
|
344511
|
+
init_src6();
|
|
343369
344512
|
init_drizzle_orm();
|
|
343370
344513
|
});
|
|
343371
344514
|
|
|
@@ -343699,7 +344842,7 @@ class TurnService {
|
|
|
343699
344842
|
var log104;
|
|
343700
344843
|
var init_turns = __esm(() => {
|
|
343701
344844
|
init_src();
|
|
343702
|
-
|
|
344845
|
+
init_src6();
|
|
343703
344846
|
init_drizzle_orm();
|
|
343704
344847
|
log104 = createLogger("turns");
|
|
343705
344848
|
});
|
|
@@ -343811,7 +344954,7 @@ class WebhookService {
|
|
|
343811
344954
|
var init_webhooks = __esm(() => {
|
|
343812
344955
|
init_src();
|
|
343813
344956
|
init_src();
|
|
343814
|
-
|
|
344957
|
+
init_src6();
|
|
343815
344958
|
init_drizzle_orm();
|
|
343816
344959
|
});
|
|
343817
344960
|
|
|
@@ -344493,8 +345636,8 @@ var import__package2, VERSION6, startTime2, healthRoutes, getHealth = async (c)
|
|
|
344493
345636
|
}
|
|
344494
345637
|
let connected = 0;
|
|
344495
345638
|
if (channelRegistry2) {
|
|
344496
|
-
for (const
|
|
344497
|
-
connected +=
|
|
345639
|
+
for (const plugin8 of channelRegistry2.getAll()) {
|
|
345640
|
+
connected += plugin8.getConnectedInstances().length;
|
|
344498
345641
|
}
|
|
344499
345642
|
}
|
|
344500
345643
|
instanceStats = { total, active, connected, byChannel };
|
|
@@ -344518,7 +345661,7 @@ var import__package2, VERSION6, startTime2, healthRoutes, getHealth = async (c)
|
|
|
344518
345661
|
return c.json(response, status === "healthy" ? 200 : 503);
|
|
344519
345662
|
};
|
|
344520
345663
|
var init_health2 = __esm(() => {
|
|
344521
|
-
|
|
345664
|
+
init_src6();
|
|
344522
345665
|
init_drizzle_orm();
|
|
344523
345666
|
init_dist2();
|
|
344524
345667
|
import__package2 = __toESM(require_package7(), 1);
|
|
@@ -344543,8 +345686,8 @@ var init_health2 = __esm(() => {
|
|
|
344543
345686
|
} catch {}
|
|
344544
345687
|
let instancesConnected = 0;
|
|
344545
345688
|
if (channelRegistry2) {
|
|
344546
|
-
for (const
|
|
344547
|
-
instancesConnected +=
|
|
345689
|
+
for (const plugin8 of channelRegistry2.getAll()) {
|
|
345690
|
+
instancesConnected += plugin8.getConnectedInstances().length;
|
|
344548
345691
|
}
|
|
344549
345692
|
}
|
|
344550
345693
|
return c.json({
|
|
@@ -350253,7 +351396,7 @@ var init_dist6 = __esm(() => {
|
|
|
350253
351396
|
});
|
|
350254
351397
|
|
|
350255
351398
|
// ../api/src/services/a2a-discovery.ts
|
|
350256
|
-
function
|
|
351399
|
+
function isRecord3(value) {
|
|
350257
351400
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
350258
351401
|
}
|
|
350259
351402
|
function stringOverride(value) {
|
|
@@ -350262,10 +351405,10 @@ function stringOverride(value) {
|
|
|
350262
351405
|
function stringArray(value) {
|
|
350263
351406
|
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
|
|
350264
351407
|
}
|
|
350265
|
-
function
|
|
351408
|
+
function normalizeBaseUrl2(baseUrl) {
|
|
350266
351409
|
return baseUrl.replace(/\/+$/, "");
|
|
350267
351410
|
}
|
|
350268
|
-
function
|
|
351411
|
+
function buildDefaultSkills2(capabilities3) {
|
|
350269
351412
|
const skills = [
|
|
350270
351413
|
{
|
|
350271
351414
|
id: "messaging",
|
|
@@ -350300,9 +351443,9 @@ function buildDefaultSkills(capabilities3) {
|
|
|
350300
351443
|
}
|
|
350301
351444
|
function buildA2AAgentCard(params) {
|
|
350302
351445
|
const { baseUrl, agent: agent3, instance: instance4 } = params;
|
|
350303
|
-
const override =
|
|
351446
|
+
const override = isRecord3(agent3.agentCard) ? agent3.agentCard : {};
|
|
350304
351447
|
const capabilities3 = agent3.capabilities ?? [];
|
|
350305
|
-
const endpointUrl = `${
|
|
351448
|
+
const endpointUrl = `${normalizeBaseUrl2(baseUrl)}/a2a/${instance4.id}`;
|
|
350306
351449
|
const card = {
|
|
350307
351450
|
name: stringOverride(override.name) ?? agent3.name,
|
|
350308
351451
|
description: stringOverride(override.description) ?? `Omni agent ${agent3.name}`,
|
|
@@ -350318,7 +351461,7 @@ function buildA2AAgentCard(params) {
|
|
|
350318
351461
|
streaming: true,
|
|
350319
351462
|
pushNotifications: false,
|
|
350320
351463
|
extendedAgentCard: false,
|
|
350321
|
-
...
|
|
351464
|
+
...isRecord3(override.capabilities) ? override.capabilities : {}
|
|
350322
351465
|
},
|
|
350323
351466
|
extensions: Array.isArray(override.extensions) ? override.extensions : [
|
|
350324
351467
|
{
|
|
@@ -350330,7 +351473,7 @@ function buildA2AAgentCard(params) {
|
|
|
350330
351473
|
],
|
|
350331
351474
|
defaultInputModes: stringArray(override.defaultInputModes) ?? ["text/plain"],
|
|
350332
351475
|
defaultOutputModes: stringArray(override.defaultOutputModes) ?? ["text/plain"],
|
|
350333
|
-
skills: Array.isArray(override.skills) ? override.skills :
|
|
351476
|
+
skills: Array.isArray(override.skills) ? override.skills : buildDefaultSkills2(capabilities3),
|
|
350334
351477
|
securitySchemes: {
|
|
350335
351478
|
bearerAuth: {
|
|
350336
351479
|
httpAuthSecurityScheme: {
|
|
@@ -350346,14 +351489,14 @@ function buildA2AAgentCard(params) {
|
|
|
350346
351489
|
description: "Legacy Omni API key header."
|
|
350347
351490
|
}
|
|
350348
351491
|
},
|
|
350349
|
-
...
|
|
351492
|
+
...isRecord3(override.securitySchemes) ? override.securitySchemes : {}
|
|
350350
351493
|
},
|
|
350351
351494
|
securityRequirements: [{ schemes: { bearerAuth: { list: [] } } }, { schemes: { apiKeyHeader: { list: [] } } }]
|
|
350352
351495
|
};
|
|
350353
|
-
const providerOverride =
|
|
351496
|
+
const providerOverride = isRecord3(override.provider) ? override.provider : undefined;
|
|
350354
351497
|
if (providerOverride)
|
|
350355
351498
|
card.provider = providerOverride;
|
|
350356
|
-
const metadataOverride =
|
|
351499
|
+
const metadataOverride = isRecord3(override.metadata) ? override.metadata : undefined;
|
|
350357
351500
|
if (metadataOverride)
|
|
350358
351501
|
card.metadata = metadataOverride;
|
|
350359
351502
|
const iconUrl = stringOverride(override.iconUrl);
|
|
@@ -350394,7 +351537,7 @@ async function listA2ADiscoverableAgents(params) {
|
|
|
350394
351537
|
capabilities: agent3.capabilities,
|
|
350395
351538
|
configured: Boolean(instance4),
|
|
350396
351539
|
instanceId: instance4?.id ?? null,
|
|
350397
|
-
endpointUrl: instance4 ? `${
|
|
351540
|
+
endpointUrl: instance4 ? `${normalizeBaseUrl2(baseUrl)}/a2a/${instance4.id}` : null,
|
|
350398
351541
|
parameters: {
|
|
350399
351542
|
agentType: agent3.agentType,
|
|
350400
351543
|
providerId: agent3.agentProviderId,
|
|
@@ -351507,9 +352650,9 @@ function isTrashEmojiOnly2(text3) {
|
|
|
351507
352650
|
async function sendMessage(services, instanceId, chatId, text3) {
|
|
351508
352651
|
const instance4 = await services.instances.getById(instanceId);
|
|
351509
352652
|
const channel5 = instance4.channel;
|
|
351510
|
-
const
|
|
351511
|
-
if (
|
|
351512
|
-
await
|
|
352653
|
+
const plugin8 = await getPlugin(channel5);
|
|
352654
|
+
if (plugin8) {
|
|
352655
|
+
await plugin8.sendMessage(instanceId, {
|
|
351513
352656
|
to: chatId,
|
|
351514
352657
|
content: { type: "text", text: text3 }
|
|
351515
352658
|
});
|
|
@@ -351687,7 +352830,7 @@ async function setupSessionCleaner(eventBus, services, db2) {
|
|
|
351687
352830
|
var log107;
|
|
351688
352831
|
var init_session_cleaner = __esm(() => {
|
|
351689
352832
|
init_src();
|
|
351690
|
-
|
|
352833
|
+
init_src6();
|
|
351691
352834
|
init_drizzle_orm();
|
|
351692
352835
|
init_idempotency();
|
|
351693
352836
|
init_agent_dispatcher();
|
|
@@ -351745,8 +352888,8 @@ async function getPluginForInstance(services, channelRegistry2, instanceId, requ
|
|
|
351745
352888
|
recoverable: false
|
|
351746
352889
|
});
|
|
351747
352890
|
}
|
|
351748
|
-
const
|
|
351749
|
-
if (!
|
|
352891
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
352892
|
+
if (!plugin8) {
|
|
351750
352893
|
throw new OmniError({
|
|
351751
352894
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
351752
352895
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -351754,7 +352897,7 @@ async function getPluginForInstance(services, channelRegistry2, instanceId, requ
|
|
|
351754
352897
|
recoverable: false
|
|
351755
352898
|
});
|
|
351756
352899
|
}
|
|
351757
|
-
if (requiredCapability && !
|
|
352900
|
+
if (requiredCapability && !plugin8.capabilities[requiredCapability]) {
|
|
351758
352901
|
throw new OmniError({
|
|
351759
352902
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
351760
352903
|
message: `Channel ${instance4.channel} does not support read receipts`,
|
|
@@ -351762,7 +352905,7 @@ async function getPluginForInstance(services, channelRegistry2, instanceId, requ
|
|
|
351762
352905
|
recoverable: false
|
|
351763
352906
|
});
|
|
351764
352907
|
}
|
|
351765
|
-
return { instance: instance4, plugin:
|
|
352908
|
+
return { instance: instance4, plugin: plugin8 };
|
|
351766
352909
|
}
|
|
351767
352910
|
async function getLastMessageKey(services, chatId) {
|
|
351768
352911
|
try {
|
|
@@ -351787,11 +352930,11 @@ async function applyChatModifyOnChannel(services, channelRegistry2, instanceId,
|
|
|
351787
352930
|
if (!channelRegistry2)
|
|
351788
352931
|
return;
|
|
351789
352932
|
const instance4 = await services.instances.getById(instanceId);
|
|
351790
|
-
const
|
|
351791
|
-
if (!
|
|
352933
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
352934
|
+
if (!plugin8)
|
|
351792
352935
|
return;
|
|
351793
|
-
if ("chatModifyAction" in
|
|
351794
|
-
await
|
|
352936
|
+
if ("chatModifyAction" in plugin8 && typeof plugin8.chatModifyAction === "function") {
|
|
352937
|
+
await plugin8.chatModifyAction(instanceId, chatExternalId, action, value, lastMessageKey);
|
|
351795
352938
|
}
|
|
351796
352939
|
}
|
|
351797
352940
|
function resolveContactName2(chat2, contactNames) {
|
|
@@ -352163,12 +353306,12 @@ var init_chats2 = __esm(() => {
|
|
|
352163
353306
|
recoverable: false
|
|
352164
353307
|
});
|
|
352165
353308
|
}
|
|
352166
|
-
const { instance: instance4, plugin:
|
|
353309
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance(services, channelRegistry2, instanceId, "canReceiveReadReceipts");
|
|
352167
353310
|
const readReceiptMode = instance4.readReceipts ?? "on";
|
|
352168
|
-
if ("markChatAsRead" in
|
|
352169
|
-
await
|
|
352170
|
-
} else if ("markAsRead" in
|
|
352171
|
-
await
|
|
353311
|
+
if ("markChatAsRead" in plugin8 && typeof plugin8.markChatAsRead === "function") {
|
|
353312
|
+
await plugin8.markChatAsRead(instanceId, chat2.externalId, readReceiptMode);
|
|
353313
|
+
} else if ("markAsRead" in plugin8 && typeof plugin8.markAsRead === "function") {
|
|
353314
|
+
await plugin8.markAsRead(instanceId, chat2.externalId, ["all"], undefined, readReceiptMode);
|
|
352172
353315
|
} else {
|
|
352173
353316
|
throw new OmniError({
|
|
352174
353317
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
@@ -352223,8 +353366,8 @@ var init_chats2 = __esm(() => {
|
|
|
352223
353366
|
});
|
|
352224
353367
|
}
|
|
352225
353368
|
const instance4 = await services.instances.getById(instanceId);
|
|
352226
|
-
const
|
|
352227
|
-
if (!
|
|
353369
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
353370
|
+
if (!plugin8) {
|
|
352228
353371
|
throw new OmniError({
|
|
352229
353372
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
352230
353373
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -352232,7 +353375,7 @@ var init_chats2 = __esm(() => {
|
|
|
352232
353375
|
recoverable: false
|
|
352233
353376
|
});
|
|
352234
353377
|
}
|
|
352235
|
-
if (!("setDisappearing" in
|
|
353378
|
+
if (!("setDisappearing" in plugin8) || typeof plugin8.setDisappearing !== "function") {
|
|
352236
353379
|
throw new OmniError({
|
|
352237
353380
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
352238
353381
|
message: `Plugin ${instance4.channel} does not support disappearing messages`,
|
|
@@ -352241,7 +353384,7 @@ var init_chats2 = __esm(() => {
|
|
|
352241
353384
|
});
|
|
352242
353385
|
}
|
|
352243
353386
|
const durationSeconds = DISAPPEARING_DURATIONS[duration] ?? 0;
|
|
352244
|
-
await
|
|
353387
|
+
await plugin8.setDisappearing(instanceId, chat2.externalId, durationSeconds);
|
|
352245
353388
|
return c.json({
|
|
352246
353389
|
success: true,
|
|
352247
353390
|
data: {
|
|
@@ -352261,15 +353404,15 @@ var init_chats2 = __esm(() => {
|
|
|
352261
353404
|
const services = c.get("services");
|
|
352262
353405
|
const channelRegistry2 = c.get("channelRegistry");
|
|
352263
353406
|
checkInstanceAccess(c.get("apiKey"), instanceId);
|
|
352264
|
-
const { plugin:
|
|
352265
|
-
if (!("fetchContacts" in
|
|
353407
|
+
const { plugin: plugin8 } = await getPluginForInstance(services, channelRegistry2, instanceId);
|
|
353408
|
+
if (!("fetchContacts" in plugin8) || typeof plugin8.fetchContacts !== "function") {
|
|
352266
353409
|
throw new OmniError({
|
|
352267
353410
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
352268
353411
|
message: "Plugin does not support fetchContacts",
|
|
352269
353412
|
recoverable: false
|
|
352270
353413
|
});
|
|
352271
353414
|
}
|
|
352272
|
-
const pluginWithContacts =
|
|
353415
|
+
const pluginWithContacts = plugin8;
|
|
352273
353416
|
const { contacts } = await pluginWithContacts.fetchContacts(instanceId);
|
|
352274
353417
|
const contactNames = new Map;
|
|
352275
353418
|
for (const contact of contacts) {
|
|
@@ -353028,7 +354171,7 @@ var init_follow_up3 = __esm(() => {
|
|
|
353028
354171
|
var handoffsRoutes, listQuerySchema11;
|
|
353029
354172
|
var init_handoffs = __esm(() => {
|
|
353030
354173
|
init_dist6();
|
|
353031
|
-
|
|
354174
|
+
init_src6();
|
|
353032
354175
|
init_drizzle_orm();
|
|
353033
354176
|
init_dist2();
|
|
353034
354177
|
init_zod();
|
|
@@ -354314,7 +355457,7 @@ function mapMessageTypeToContentType(messageType) {
|
|
|
354314
355457
|
var log109, MAX_REPLAY_WINDOW_MS;
|
|
354315
355458
|
var init_agent_replay = __esm(() => {
|
|
354316
355459
|
init_src();
|
|
354317
|
-
|
|
355460
|
+
init_src6();
|
|
354318
355461
|
init_drizzle_orm();
|
|
354319
355462
|
log109 = createLogger("agent-replay");
|
|
354320
355463
|
MAX_REPLAY_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
@@ -354471,9 +355614,9 @@ function buildInstanceConnectionOptions(input) {
|
|
|
354471
355614
|
function getPluginFromRegistry(channelRegistry2, channel5) {
|
|
354472
355615
|
return channelRegistry2?.get(channel5);
|
|
354473
355616
|
}
|
|
354474
|
-
async function connectInstanceWithPlugin(
|
|
355617
|
+
async function connectInstanceWithPlugin(plugin8, instanceId, options) {
|
|
354475
355618
|
try {
|
|
354476
|
-
await
|
|
355619
|
+
await plugin8.connect(instanceId, {
|
|
354477
355620
|
instanceId,
|
|
354478
355621
|
credentials: {},
|
|
354479
355622
|
options
|
|
@@ -354484,12 +355627,12 @@ async function connectInstanceWithPlugin(plugin7, instanceId, options) {
|
|
|
354484
355627
|
}
|
|
354485
355628
|
}
|
|
354486
355629
|
async function triggerCreateConnection(channelRegistry2, channel5, instanceId, options) {
|
|
354487
|
-
const
|
|
354488
|
-
if (!
|
|
355630
|
+
const plugin8 = getPluginFromRegistry(channelRegistry2, channel5);
|
|
355631
|
+
if (!plugin8) {
|
|
354489
355632
|
log110.warn("No plugin found for channel", { channel: channel5 });
|
|
354490
355633
|
return;
|
|
354491
355634
|
}
|
|
354492
|
-
const errorMessage = await connectInstanceWithPlugin(
|
|
355635
|
+
const errorMessage = await connectInstanceWithPlugin(plugin8, instanceId, options);
|
|
354493
355636
|
if (errorMessage) {
|
|
354494
355637
|
log110.error("Failed to connect instance", { instanceId, error: errorMessage });
|
|
354495
355638
|
return;
|
|
@@ -354586,9 +355729,9 @@ function buildConnectConnectionOptions(instance4, body, forceNewQr) {
|
|
|
354586
355729
|
twilioValidateSignature: body.twilioValidateSignature ?? instance4.twilioValidateSignature
|
|
354587
355730
|
});
|
|
354588
355731
|
}
|
|
354589
|
-
function hydrateConnectionOptionsForInstance(
|
|
354590
|
-
if ("loadGuildConfigs" in
|
|
354591
|
-
|
|
355732
|
+
function hydrateConnectionOptionsForInstance(plugin8, instance4, options) {
|
|
355733
|
+
if ("loadGuildConfigs" in plugin8 && instance4.guildConfigOverrides) {
|
|
355734
|
+
plugin8.loadGuildConfigs(instance4.id, instance4.guildConfigOverrides);
|
|
354592
355735
|
}
|
|
354593
355736
|
if (instance4.discordPresence) {
|
|
354594
355737
|
options.presence = instance4.discordPresence;
|
|
@@ -354658,15 +355801,15 @@ async function resolveInstancePlugin(services, channelRegistry2, instanceId) {
|
|
|
354658
355801
|
if (!channelRegistry2) {
|
|
354659
355802
|
return { ok: false, status: 503, error: { code: "NO_REGISTRY", message: "Channel registry not available" } };
|
|
354660
355803
|
}
|
|
354661
|
-
const
|
|
354662
|
-
if (!
|
|
355804
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
355805
|
+
if (!plugin8) {
|
|
354663
355806
|
return {
|
|
354664
355807
|
ok: false,
|
|
354665
355808
|
status: 400,
|
|
354666
355809
|
error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` }
|
|
354667
355810
|
};
|
|
354668
355811
|
}
|
|
354669
|
-
return { ok: true, plugin:
|
|
355812
|
+
return { ok: true, plugin: plugin8 };
|
|
354670
355813
|
}
|
|
354671
355814
|
function participantUpdateResponse(result) {
|
|
354672
355815
|
return {
|
|
@@ -354869,12 +356012,12 @@ var init_instances3 = __esm(() => {
|
|
|
354869
356012
|
instancesRoutes.get("/supported-channels", async (c) => {
|
|
354870
356013
|
const channelRegistry2 = c.get("channelRegistry");
|
|
354871
356014
|
const loadedPlugins = channelRegistry2 ? channelRegistry2.getAll() : [];
|
|
354872
|
-
const loadedChannels = loadedPlugins.map((
|
|
354873
|
-
id:
|
|
354874
|
-
name:
|
|
354875
|
-
version:
|
|
356015
|
+
const loadedChannels = loadedPlugins.map((plugin8) => ({
|
|
356016
|
+
id: plugin8.id,
|
|
356017
|
+
name: plugin8.name,
|
|
356018
|
+
version: plugin8.version,
|
|
354876
356019
|
loaded: true,
|
|
354877
|
-
capabilities:
|
|
356020
|
+
capabilities: plugin8.capabilities
|
|
354878
356021
|
}));
|
|
354879
356022
|
const loadedIds = new Set(loadedPlugins.map((p2) => p2.id));
|
|
354880
356023
|
const staticChannels = [
|
|
@@ -354997,18 +356140,18 @@ var init_instances3 = __esm(() => {
|
|
|
354997
356140
|
const services = c.get("services");
|
|
354998
356141
|
const channelRegistry2 = c.get("channelRegistry");
|
|
354999
356142
|
const instance4 = await services.instances.getById(id);
|
|
355000
|
-
const
|
|
355001
|
-
if (
|
|
356143
|
+
const plugin8 = channelRegistry2?.get(instance4.channel);
|
|
356144
|
+
if (plugin8) {
|
|
355002
356145
|
try {
|
|
355003
|
-
await
|
|
356146
|
+
await plugin8.disconnect(id);
|
|
355004
356147
|
} catch (error3) {
|
|
355005
356148
|
log110.error("Failed to disconnect instance before delete", { instanceId: id, error: String(error3) });
|
|
355006
356149
|
}
|
|
355007
356150
|
}
|
|
355008
356151
|
await services.instances.delete(id);
|
|
355009
|
-
if (
|
|
356152
|
+
if (plugin8 && "logout" in plugin8 && typeof plugin8.logout === "function") {
|
|
355010
356153
|
try {
|
|
355011
|
-
await
|
|
356154
|
+
await plugin8.logout(id);
|
|
355012
356155
|
} catch (error3) {
|
|
355013
356156
|
log110.error("Failed to clear channel auth after delete", { instanceId: id, error: String(error3) });
|
|
355014
356157
|
}
|
|
@@ -355023,10 +356166,10 @@ var init_instances3 = __esm(() => {
|
|
|
355023
356166
|
let connectionState = "unknown";
|
|
355024
356167
|
let statusMessage;
|
|
355025
356168
|
if (channelRegistry2) {
|
|
355026
|
-
const
|
|
355027
|
-
if (
|
|
356169
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356170
|
+
if (plugin8) {
|
|
355028
356171
|
try {
|
|
355029
|
-
const status = await
|
|
356172
|
+
const status = await plugin8.getStatus(id);
|
|
355030
356173
|
connectionState = status.state;
|
|
355031
356174
|
statusMessage = status.message;
|
|
355032
356175
|
} catch {
|
|
@@ -355088,15 +356231,15 @@ var init_instances3 = __esm(() => {
|
|
|
355088
356231
|
if (!channelRegistry2) {
|
|
355089
356232
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355090
356233
|
}
|
|
355091
|
-
const
|
|
355092
|
-
if (!
|
|
356234
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356235
|
+
if (!plugin8) {
|
|
355093
356236
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355094
356237
|
}
|
|
355095
|
-
if (!("requestPairingCode" in
|
|
356238
|
+
if (!("requestPairingCode" in plugin8)) {
|
|
355096
356239
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "This plugin does not support pairing codes" } }, 400);
|
|
355097
356240
|
}
|
|
355098
356241
|
try {
|
|
355099
|
-
const code = await
|
|
356242
|
+
const code = await plugin8.requestPairingCode(id, phoneNumber);
|
|
355100
356243
|
const formattedCode = code.length === 8 ? `${code.slice(0, 4)}-${code.slice(4)}` : code;
|
|
355101
356244
|
return c.json({
|
|
355102
356245
|
data: {
|
|
@@ -355140,12 +356283,12 @@ var init_instances3 = __esm(() => {
|
|
|
355140
356283
|
if (!channelRegistry2) {
|
|
355141
356284
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355142
356285
|
}
|
|
355143
|
-
const
|
|
355144
|
-
if (!
|
|
356286
|
+
const plugin8 = getPluginFromRegistry(channelRegistry2, instance4.channel);
|
|
356287
|
+
if (!plugin8) {
|
|
355145
356288
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355146
356289
|
}
|
|
355147
|
-
hydrateConnectionOptionsForInstance(
|
|
355148
|
-
const errorMessage = await connectInstanceWithPlugin(
|
|
356290
|
+
hydrateConnectionOptionsForInstance(plugin8, instance4, connectionOptions);
|
|
356291
|
+
const errorMessage = await connectInstanceWithPlugin(plugin8, id, connectionOptions);
|
|
355149
356292
|
if (errorMessage) {
|
|
355150
356293
|
return c.json({
|
|
355151
356294
|
error: {
|
|
@@ -355169,10 +356312,10 @@ var init_instances3 = __esm(() => {
|
|
|
355169
356312
|
const channelRegistry2 = c.get("channelRegistry");
|
|
355170
356313
|
const instance4 = await services.instances.getById(id);
|
|
355171
356314
|
if (channelRegistry2) {
|
|
355172
|
-
const
|
|
355173
|
-
if (
|
|
356315
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356316
|
+
if (plugin8) {
|
|
355174
356317
|
try {
|
|
355175
|
-
await
|
|
356318
|
+
await plugin8.disconnect(id);
|
|
355176
356319
|
} catch (error3) {
|
|
355177
356320
|
log110.error("Failed to disconnect instance", { instanceId: id, error: String(error3) });
|
|
355178
356321
|
}
|
|
@@ -355190,12 +356333,12 @@ var init_instances3 = __esm(() => {
|
|
|
355190
356333
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355191
356334
|
}
|
|
355192
356335
|
const instance4 = await services.instances.getById(id);
|
|
355193
|
-
const
|
|
355194
|
-
if (!
|
|
356336
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356337
|
+
if (!plugin8) {
|
|
355195
356338
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355196
356339
|
}
|
|
355197
356340
|
try {
|
|
355198
|
-
await
|
|
356341
|
+
await plugin8.disconnect(id);
|
|
355199
356342
|
const restartOptions = { forceNewQr };
|
|
355200
356343
|
const restartToken = persistedTokenForChannel(instance4);
|
|
355201
356344
|
if (restartToken)
|
|
@@ -355226,7 +356369,7 @@ var init_instances3 = __esm(() => {
|
|
|
355226
356369
|
markOnlineOnConnect: instance4.markOnlineOnConnect
|
|
355227
356370
|
};
|
|
355228
356371
|
}
|
|
355229
|
-
await
|
|
356372
|
+
await plugin8.connect(id, { instanceId: id, credentials: {}, options: restartOptions });
|
|
355230
356373
|
} catch (error3) {
|
|
355231
356374
|
return c.json({
|
|
355232
356375
|
error: {
|
|
@@ -355249,16 +356392,16 @@ var init_instances3 = __esm(() => {
|
|
|
355249
356392
|
const channelRegistry2 = c.get("channelRegistry");
|
|
355250
356393
|
const instance4 = await services.instances.getById(id);
|
|
355251
356394
|
if (channelRegistry2) {
|
|
355252
|
-
const
|
|
355253
|
-
if (
|
|
356395
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356396
|
+
if (plugin8 && "logout" in plugin8 && typeof plugin8.logout === "function") {
|
|
355254
356397
|
try {
|
|
355255
|
-
await
|
|
356398
|
+
await plugin8.logout(id);
|
|
355256
356399
|
} catch (error3) {
|
|
355257
356400
|
log110.error("Failed to logout instance", { instanceId: id, error: String(error3) });
|
|
355258
356401
|
}
|
|
355259
|
-
} else if (
|
|
356402
|
+
} else if (plugin8) {
|
|
355260
356403
|
try {
|
|
355261
|
-
await
|
|
356404
|
+
await plugin8.disconnect(id);
|
|
355262
356405
|
} catch (error3) {
|
|
355263
356406
|
log110.error("Failed to disconnect instance during logout", { instanceId: id, error: String(error3) });
|
|
355264
356407
|
}
|
|
@@ -355285,15 +356428,15 @@ var init_instances3 = __esm(() => {
|
|
|
355285
356428
|
if (!channelRegistry2) {
|
|
355286
356429
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355287
356430
|
}
|
|
355288
|
-
const
|
|
355289
|
-
if (!
|
|
356431
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356432
|
+
if (!plugin8) {
|
|
355290
356433
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355291
356434
|
}
|
|
355292
|
-
if (!("getProfile" in
|
|
356435
|
+
if (!("getProfile" in plugin8) || typeof plugin8.getProfile !== "function") {
|
|
355293
356436
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support profile sync` } }, 400);
|
|
355294
356437
|
}
|
|
355295
356438
|
try {
|
|
355296
|
-
const profile = await
|
|
356439
|
+
const profile = await plugin8.getProfile(id);
|
|
355297
356440
|
const updated = await services.instances.update(id, {
|
|
355298
356441
|
profileName: profile.name,
|
|
355299
356442
|
profilePicUrl: profile.avatarUrl,
|
|
@@ -355324,12 +356467,12 @@ var init_instances3 = __esm(() => {
|
|
|
355324
356467
|
if (!channelRegistry2) {
|
|
355325
356468
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355326
356469
|
}
|
|
355327
|
-
const
|
|
355328
|
-
if (!
|
|
356470
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356471
|
+
if (!plugin8 || !("updateProfileName" in plugin8) || typeof plugin8.updateProfileName !== "function") {
|
|
355329
356472
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support profile name update" } }, 400);
|
|
355330
356473
|
}
|
|
355331
356474
|
try {
|
|
355332
|
-
await
|
|
356475
|
+
await plugin8.updateProfileName(id, name);
|
|
355333
356476
|
await services.instances.update(id, { profileName: name });
|
|
355334
356477
|
return c.json({ success: true, data: { instanceId: id, action: "profile_name_updated", name } });
|
|
355335
356478
|
} catch (error3) {
|
|
@@ -355347,11 +356490,11 @@ var init_instances3 = __esm(() => {
|
|
|
355347
356490
|
if (!channelRegistry2) {
|
|
355348
356491
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355349
356492
|
}
|
|
355350
|
-
const
|
|
355351
|
-
if (!
|
|
356493
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356494
|
+
if (!plugin8 || !("getProfile" in plugin8)) {
|
|
355352
356495
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Profile sync not supported" } }, 400);
|
|
355353
356496
|
}
|
|
355354
|
-
const profile = await
|
|
356497
|
+
const profile = await plugin8.getProfile(id);
|
|
355355
356498
|
const updated = await services.instances.update(id, {
|
|
355356
356499
|
profileName: profile.name,
|
|
355357
356500
|
profilePicUrl: profile.avatarUrl,
|
|
@@ -355463,17 +356606,17 @@ var init_instances3 = __esm(() => {
|
|
|
355463
356606
|
if (!channelRegistry2) {
|
|
355464
356607
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355465
356608
|
}
|
|
355466
|
-
const
|
|
355467
|
-
if (!
|
|
356609
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356610
|
+
if (!plugin8) {
|
|
355468
356611
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355469
356612
|
}
|
|
355470
|
-
if (!("fetchUserProfile" in
|
|
356613
|
+
if (!("fetchUserProfile" in plugin8) || typeof plugin8.fetchUserProfile !== "function") {
|
|
355471
356614
|
return c.json({
|
|
355472
356615
|
error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support user profile fetching` }
|
|
355473
356616
|
}, 400);
|
|
355474
356617
|
}
|
|
355475
356618
|
try {
|
|
355476
|
-
const profile = await
|
|
356619
|
+
const profile = await plugin8.fetchUserProfile(id, userId);
|
|
355477
356620
|
return c.json({
|
|
355478
356621
|
data: {
|
|
355479
356622
|
platformUserId: userId,
|
|
@@ -355505,11 +356648,11 @@ var init_instances3 = __esm(() => {
|
|
|
355505
356648
|
if (!channelRegistry2) {
|
|
355506
356649
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355507
356650
|
}
|
|
355508
|
-
const
|
|
355509
|
-
if (!
|
|
356651
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356652
|
+
if (!plugin8) {
|
|
355510
356653
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355511
356654
|
}
|
|
355512
|
-
if (!("fetchContacts" in
|
|
356655
|
+
if (!("fetchContacts" in plugin8) || typeof plugin8.fetchContacts !== "function") {
|
|
355513
356656
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support contacts fetching` } }, 400);
|
|
355514
356657
|
}
|
|
355515
356658
|
try {
|
|
@@ -355521,7 +356664,7 @@ var init_instances3 = __esm(() => {
|
|
|
355521
356664
|
fetchOptions.guildId = guildId;
|
|
355522
356665
|
fetchOptions.limit = limit2;
|
|
355523
356666
|
}
|
|
355524
|
-
const result = await
|
|
356667
|
+
const result = await plugin8.fetchContacts(id, fetchOptions);
|
|
355525
356668
|
if (result.contacts.length > 0) {
|
|
355526
356669
|
await enrichContactNames(result.contacts, services, id);
|
|
355527
356670
|
let filtered = result.contacts;
|
|
@@ -355587,15 +356730,15 @@ var init_instances3 = __esm(() => {
|
|
|
355587
356730
|
if (!channelRegistry2) {
|
|
355588
356731
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355589
356732
|
}
|
|
355590
|
-
const
|
|
355591
|
-
if (!
|
|
356733
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356734
|
+
if (!plugin8) {
|
|
355592
356735
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355593
356736
|
}
|
|
355594
|
-
if (!("fetchGroups" in
|
|
356737
|
+
if (!("fetchGroups" in plugin8) || typeof plugin8.fetchGroups !== "function") {
|
|
355595
356738
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support groups fetching` } }, 400);
|
|
355596
356739
|
}
|
|
355597
356740
|
try {
|
|
355598
|
-
const result = await
|
|
356741
|
+
const result = await plugin8.fetchGroups(id, {});
|
|
355599
356742
|
let filtered = result.groups;
|
|
355600
356743
|
if (search) {
|
|
355601
356744
|
const q = search.toLowerCase();
|
|
@@ -355634,15 +356777,15 @@ var init_instances3 = __esm(() => {
|
|
|
355634
356777
|
if (!channelRegistry2) {
|
|
355635
356778
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355636
356779
|
}
|
|
355637
|
-
const
|
|
355638
|
-
if (!
|
|
356780
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356781
|
+
if (!plugin8) {
|
|
355639
356782
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355640
356783
|
}
|
|
355641
|
-
if (!("fetchGroupMembers" in
|
|
356784
|
+
if (!("fetchGroupMembers" in plugin8) || typeof plugin8.fetchGroupMembers !== "function") {
|
|
355642
356785
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support group member listing` } }, 501);
|
|
355643
356786
|
}
|
|
355644
356787
|
try {
|
|
355645
|
-
const result = await
|
|
356788
|
+
const result = await plugin8.fetchGroupMembers(id, jid);
|
|
355646
356789
|
return c.json({ members: result.members });
|
|
355647
356790
|
} catch (error3) {
|
|
355648
356791
|
const message2 = `Failed to fetch group members: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355661,15 +356804,15 @@ var init_instances3 = __esm(() => {
|
|
|
355661
356804
|
if (!channelRegistry2) {
|
|
355662
356805
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355663
356806
|
}
|
|
355664
|
-
const
|
|
355665
|
-
if (!
|
|
356807
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356808
|
+
if (!plugin8) {
|
|
355666
356809
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355667
356810
|
}
|
|
355668
|
-
if (!("checkNumber" in
|
|
356811
|
+
if (!("checkNumber" in plugin8) || typeof plugin8.checkNumber !== "function") {
|
|
355669
356812
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support number checking` } }, 400);
|
|
355670
356813
|
}
|
|
355671
356814
|
try {
|
|
355672
|
-
const results = await
|
|
356815
|
+
const results = await plugin8.checkNumber(id, phones);
|
|
355673
356816
|
return c.json({ data: { results } });
|
|
355674
356817
|
} catch (error3) {
|
|
355675
356818
|
const message2 = `Failed to check numbers: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355688,15 +356831,15 @@ var init_instances3 = __esm(() => {
|
|
|
355688
356831
|
if (!channelRegistry2) {
|
|
355689
356832
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355690
356833
|
}
|
|
355691
|
-
const
|
|
355692
|
-
if (!
|
|
356834
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356835
|
+
if (!plugin8) {
|
|
355693
356836
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355694
356837
|
}
|
|
355695
|
-
if (!("updateBio" in
|
|
356838
|
+
if (!("updateBio" in plugin8) || typeof plugin8.updateBio !== "function") {
|
|
355696
356839
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support bio updates` } }, 400);
|
|
355697
356840
|
}
|
|
355698
356841
|
try {
|
|
355699
|
-
await
|
|
356842
|
+
await plugin8.updateBio(id, status);
|
|
355700
356843
|
return c.json({ success: true, data: { status } });
|
|
355701
356844
|
} catch (error3) {
|
|
355702
356845
|
const message2 = `Failed to update bio: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355715,15 +356858,15 @@ var init_instances3 = __esm(() => {
|
|
|
355715
356858
|
if (!channelRegistry2) {
|
|
355716
356859
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355717
356860
|
}
|
|
355718
|
-
const
|
|
355719
|
-
if (!
|
|
356861
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356862
|
+
if (!plugin8) {
|
|
355720
356863
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355721
356864
|
}
|
|
355722
|
-
if (!("blockContact" in
|
|
356865
|
+
if (!("blockContact" in plugin8) || typeof plugin8.blockContact !== "function") {
|
|
355723
356866
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support blocking` } }, 400);
|
|
355724
356867
|
}
|
|
355725
356868
|
try {
|
|
355726
|
-
await
|
|
356869
|
+
await plugin8.blockContact(id, contactId);
|
|
355727
356870
|
return c.json({ success: true, data: { contactId, action: "blocked" } });
|
|
355728
356871
|
} catch (error3) {
|
|
355729
356872
|
const message2 = `Failed to block contact: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355739,15 +356882,15 @@ var init_instances3 = __esm(() => {
|
|
|
355739
356882
|
if (!channelRegistry2) {
|
|
355740
356883
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355741
356884
|
}
|
|
355742
|
-
const
|
|
355743
|
-
if (!
|
|
356885
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356886
|
+
if (!plugin8) {
|
|
355744
356887
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355745
356888
|
}
|
|
355746
|
-
if (!("unblockContact" in
|
|
356889
|
+
if (!("unblockContact" in plugin8) || typeof plugin8.unblockContact !== "function") {
|
|
355747
356890
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support unblocking` } }, 400);
|
|
355748
356891
|
}
|
|
355749
356892
|
try {
|
|
355750
|
-
await
|
|
356893
|
+
await plugin8.unblockContact(id, contactId);
|
|
355751
356894
|
return c.json({ success: true, data: { contactId, action: "unblocked" } });
|
|
355752
356895
|
} catch (error3) {
|
|
355753
356896
|
const message2 = `Failed to unblock contact: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355762,15 +356905,15 @@ var init_instances3 = __esm(() => {
|
|
|
355762
356905
|
if (!channelRegistry2) {
|
|
355763
356906
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355764
356907
|
}
|
|
355765
|
-
const
|
|
355766
|
-
if (!
|
|
356908
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356909
|
+
if (!plugin8) {
|
|
355767
356910
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: `No plugin for channel: ${instance4.channel}` } }, 400);
|
|
355768
356911
|
}
|
|
355769
|
-
if (!("fetchBlocklist" in
|
|
356912
|
+
if (!("fetchBlocklist" in plugin8) || typeof plugin8.fetchBlocklist !== "function") {
|
|
355770
356913
|
return c.json({ error: { code: "NOT_SUPPORTED", message: `Plugin ${instance4.channel} does not support blocklist` } }, 400);
|
|
355771
356914
|
}
|
|
355772
356915
|
try {
|
|
355773
|
-
const blocklist = await
|
|
356916
|
+
const blocklist = await plugin8.fetchBlocklist(id);
|
|
355774
356917
|
return c.json({ data: { blocklist, count: blocklist.length } });
|
|
355775
356918
|
} catch (error3) {
|
|
355776
356919
|
const message2 = `Failed to fetch blocklist: ${error3 instanceof Error ? error3.message : "Unknown error"}`;
|
|
@@ -355786,13 +356929,13 @@ var init_instances3 = __esm(() => {
|
|
|
355786
356929
|
if (!channelRegistry2) {
|
|
355787
356930
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355788
356931
|
}
|
|
355789
|
-
const
|
|
355790
|
-
if (!
|
|
356932
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356933
|
+
if (!plugin8 || !("updateProfilePicture" in plugin8)) {
|
|
355791
356934
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support profile picture update" } }, 400);
|
|
355792
356935
|
}
|
|
355793
356936
|
try {
|
|
355794
356937
|
const imageBuffer = Buffer.from(base64, "base64");
|
|
355795
|
-
await
|
|
356938
|
+
await plugin8.updateProfilePicture(id, imageBuffer);
|
|
355796
356939
|
return c.json({ success: true, data: { instanceId: id, action: "profile_picture_updated" } });
|
|
355797
356940
|
} catch (error3) {
|
|
355798
356941
|
const message2 = error3 instanceof Error ? error3.message : "Unknown error";
|
|
@@ -355807,12 +356950,12 @@ var init_instances3 = __esm(() => {
|
|
|
355807
356950
|
if (!channelRegistry2) {
|
|
355808
356951
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355809
356952
|
}
|
|
355810
|
-
const
|
|
355811
|
-
if (!
|
|
356953
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
356954
|
+
if (!plugin8 || !("removeProfilePicture" in plugin8)) {
|
|
355812
356955
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support profile picture removal" } }, 400);
|
|
355813
356956
|
}
|
|
355814
356957
|
try {
|
|
355815
|
-
await
|
|
356958
|
+
await plugin8.removeProfilePicture(id);
|
|
355816
356959
|
return c.json({ success: true, data: { instanceId: id, action: "profile_picture_removed" } });
|
|
355817
356960
|
} catch (error3) {
|
|
355818
356961
|
const message2 = error3 instanceof Error ? error3.message : "Unknown error";
|
|
@@ -355855,11 +356998,11 @@ var init_instances3 = __esm(() => {
|
|
|
355855
356998
|
if (!channelRegistry2) {
|
|
355856
356999
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
355857
357000
|
}
|
|
355858
|
-
const
|
|
355859
|
-
if (!
|
|
357001
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357002
|
+
if (!plugin8 || !("groupCreate" in plugin8)) {
|
|
355860
357003
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group creation" } }, 400);
|
|
355861
357004
|
}
|
|
355862
|
-
const result = await
|
|
357005
|
+
const result = await plugin8.groupCreate(id, subject, participants);
|
|
355863
357006
|
return c.json({ data: result }, 201);
|
|
355864
357007
|
});
|
|
355865
357008
|
instancesRoutes.post("/:id/groups/:groupJid/participants", instanceAccess2, zValidator("json", groupParticipantsSchema), async (c) => {
|
|
@@ -356083,13 +357226,13 @@ var init_instances3 = __esm(() => {
|
|
|
356083
357226
|
if (!channelRegistry2) {
|
|
356084
357227
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356085
357228
|
}
|
|
356086
|
-
const
|
|
356087
|
-
if (!
|
|
357229
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357230
|
+
if (!plugin8) {
|
|
356088
357231
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin not available" } }, 400);
|
|
356089
357232
|
}
|
|
356090
|
-
if ("getGroupInviteCode" in
|
|
357233
|
+
if ("getGroupInviteCode" in plugin8) {
|
|
356091
357234
|
try {
|
|
356092
|
-
const code = await
|
|
357235
|
+
const code = await plugin8.getGroupInviteCode(id, chatId);
|
|
356093
357236
|
return c.json({
|
|
356094
357237
|
data: {
|
|
356095
357238
|
chatId,
|
|
@@ -356102,9 +357245,9 @@ var init_instances3 = __esm(() => {
|
|
|
356102
357245
|
return c.json({ error: { code: "INVITE_FAILED", message: message2 } }, 500);
|
|
356103
357246
|
}
|
|
356104
357247
|
}
|
|
356105
|
-
if ("exportChatInviteLink" in
|
|
357248
|
+
if ("exportChatInviteLink" in plugin8) {
|
|
356106
357249
|
try {
|
|
356107
|
-
const inviteLink = await
|
|
357250
|
+
const inviteLink = await plugin8.exportChatInviteLink(id, chatId);
|
|
356108
357251
|
return c.json({
|
|
356109
357252
|
data: {
|
|
356110
357253
|
chatId,
|
|
@@ -356127,12 +357270,12 @@ var init_instances3 = __esm(() => {
|
|
|
356127
357270
|
if (!channelRegistry2) {
|
|
356128
357271
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356129
357272
|
}
|
|
356130
|
-
const
|
|
356131
|
-
if (!
|
|
357273
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357274
|
+
if (!plugin8 || !("getGroupInviteCode" in plugin8)) {
|
|
356132
357275
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group invites" } }, 400);
|
|
356133
357276
|
}
|
|
356134
357277
|
try {
|
|
356135
|
-
const code = await
|
|
357278
|
+
const code = await plugin8.getGroupInviteCode(id, groupJid);
|
|
356136
357279
|
return c.json({
|
|
356137
357280
|
data: {
|
|
356138
357281
|
groupJid,
|
|
@@ -356154,12 +357297,12 @@ var init_instances3 = __esm(() => {
|
|
|
356154
357297
|
if (!channelRegistry2) {
|
|
356155
357298
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356156
357299
|
}
|
|
356157
|
-
const
|
|
356158
|
-
if (!
|
|
357300
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357301
|
+
if (!plugin8 || !("revokeGroupInvite" in plugin8)) {
|
|
356159
357302
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group invite revocation" } }, 400);
|
|
356160
357303
|
}
|
|
356161
357304
|
try {
|
|
356162
|
-
const newCode = await
|
|
357305
|
+
const newCode = await plugin8.revokeGroupInvite(id, groupJid);
|
|
356163
357306
|
return c.json({
|
|
356164
357307
|
data: {
|
|
356165
357308
|
groupJid,
|
|
@@ -356181,12 +357324,12 @@ var init_instances3 = __esm(() => {
|
|
|
356181
357324
|
if (!channelRegistry2) {
|
|
356182
357325
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356183
357326
|
}
|
|
356184
|
-
const
|
|
356185
|
-
if (!
|
|
357327
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357328
|
+
if (!plugin8 || !("joinGroup" in plugin8)) {
|
|
356186
357329
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support joining groups" } }, 400);
|
|
356187
357330
|
}
|
|
356188
357331
|
try {
|
|
356189
|
-
const groupJid = await
|
|
357332
|
+
const groupJid = await plugin8.joinGroup(id, code);
|
|
356190
357333
|
return c.json({ data: { groupJid, joined: true } });
|
|
356191
357334
|
} catch (error3) {
|
|
356192
357335
|
const message2 = error3 instanceof Error ? error3.message : "Unknown error";
|
|
@@ -356203,12 +357346,12 @@ var init_instances3 = __esm(() => {
|
|
|
356203
357346
|
if (!channelRegistry2) {
|
|
356204
357347
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356205
357348
|
}
|
|
356206
|
-
const
|
|
356207
|
-
if (!
|
|
357349
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357350
|
+
if (!plugin8 || !("updateGroupPicture" in plugin8)) {
|
|
356208
357351
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support group picture update" } }, 400);
|
|
356209
357352
|
}
|
|
356210
357353
|
const imageBuffer = Buffer.from(base64, "base64");
|
|
356211
|
-
await
|
|
357354
|
+
await plugin8.updateGroupPicture(id, groupJid, imageBuffer);
|
|
356212
357355
|
return c.json({ success: true, data: { instanceId: id, groupJid, action: "group_picture_updated" } });
|
|
356213
357356
|
});
|
|
356214
357357
|
instancesRoutes.get("/:id/privacy", instanceAccess2, async (c) => {
|
|
@@ -356219,12 +357362,12 @@ var init_instances3 = __esm(() => {
|
|
|
356219
357362
|
if (!channelRegistry2) {
|
|
356220
357363
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356221
357364
|
}
|
|
356222
|
-
const
|
|
356223
|
-
if (!
|
|
357365
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357366
|
+
if (!plugin8 || !("fetchPrivacySettings" in plugin8)) {
|
|
356224
357367
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support privacy settings" } }, 400);
|
|
356225
357368
|
}
|
|
356226
357369
|
try {
|
|
356227
|
-
const settings = await
|
|
357370
|
+
const settings = await plugin8.fetchPrivacySettings(id);
|
|
356228
357371
|
return c.json({ data: settings });
|
|
356229
357372
|
} catch (error3) {
|
|
356230
357373
|
const message2 = error3 instanceof Error ? error3.message : "Unknown error";
|
|
@@ -356243,12 +357386,12 @@ var init_instances3 = __esm(() => {
|
|
|
356243
357386
|
if (!channelRegistry2) {
|
|
356244
357387
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356245
357388
|
}
|
|
356246
|
-
const
|
|
356247
|
-
if (!
|
|
357389
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357390
|
+
if (!plugin8 || !("rejectCall" in plugin8)) {
|
|
356248
357391
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support call rejection" } }, 400);
|
|
356249
357392
|
}
|
|
356250
357393
|
try {
|
|
356251
|
-
await
|
|
357394
|
+
await plugin8.rejectCall(id, callId, callFrom);
|
|
356252
357395
|
return c.json({ success: true, data: { callId, callFrom, rejected: true } });
|
|
356253
357396
|
} catch (error3) {
|
|
356254
357397
|
const message2 = error3 instanceof Error ? error3.message : "Unknown error";
|
|
@@ -356477,9 +357620,9 @@ var init_instances3 = __esm(() => {
|
|
|
356477
357620
|
invalidateGuildCache(id, guildId);
|
|
356478
357621
|
const channelRegistry2 = c.get("channelRegistry");
|
|
356479
357622
|
if (channelRegistry2) {
|
|
356480
|
-
const
|
|
356481
|
-
if (
|
|
356482
|
-
|
|
357623
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357624
|
+
if (plugin8 && "setGuildConfig" in plugin8) {
|
|
357625
|
+
plugin8.setGuildConfig(id, guildId, newConfig);
|
|
356483
357626
|
}
|
|
356484
357627
|
}
|
|
356485
357628
|
log110.info("Guild config updated", {
|
|
@@ -356506,9 +357649,9 @@ var init_instances3 = __esm(() => {
|
|
|
356506
357649
|
invalidateGuildCache(id, guildId);
|
|
356507
357650
|
const channelRegistry2 = c.get("channelRegistry");
|
|
356508
357651
|
if (channelRegistry2) {
|
|
356509
|
-
const
|
|
356510
|
-
if (
|
|
356511
|
-
|
|
357652
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
357653
|
+
if (plugin8 && "removeGuildConfig" in plugin8) {
|
|
357654
|
+
plugin8.removeGuildConfig(id, guildId);
|
|
356512
357655
|
}
|
|
356513
357656
|
}
|
|
356514
357657
|
log110.info("Guild config deleted", {
|
|
@@ -356543,15 +357686,15 @@ var init_instances3 = __esm(() => {
|
|
|
356543
357686
|
if (!channelRegistry2) {
|
|
356544
357687
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
356545
357688
|
}
|
|
356546
|
-
const
|
|
356547
|
-
if (!
|
|
357689
|
+
const plugin8 = channelRegistry2.get("discord");
|
|
357690
|
+
if (!plugin8) {
|
|
356548
357691
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: "Discord plugin not loaded" } }, 400);
|
|
356549
357692
|
}
|
|
356550
|
-
if (!("setPresence" in
|
|
357693
|
+
if (!("setPresence" in plugin8) || typeof plugin8.setPresence !== "function") {
|
|
356551
357694
|
return c.json({ error: { code: "NOT_SUPPORTED", message: "Plugin does not support setPresence" } }, 400);
|
|
356552
357695
|
}
|
|
356553
357696
|
try {
|
|
356554
|
-
await
|
|
357697
|
+
await plugin8.setPresence(id, presenceData);
|
|
356555
357698
|
await services.instances.update(id, { discordPresence: presenceData });
|
|
356556
357699
|
return c.json({ success: true, data: { instanceId: id, presence: presenceData } });
|
|
356557
357700
|
} catch (error3) {
|
|
@@ -357899,8 +359042,8 @@ async function getPluginForInstance2(services, channelRegistry2, instanceId, req
|
|
|
357899
359042
|
recoverable: false
|
|
357900
359043
|
});
|
|
357901
359044
|
}
|
|
357902
|
-
const
|
|
357903
|
-
if (!
|
|
359045
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359046
|
+
if (!plugin8) {
|
|
357904
359047
|
throw new OmniError({
|
|
357905
359048
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
357906
359049
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -357908,7 +359051,7 @@ async function getPluginForInstance2(services, channelRegistry2, instanceId, req
|
|
|
357908
359051
|
recoverable: false
|
|
357909
359052
|
});
|
|
357910
359053
|
}
|
|
357911
|
-
if (requiredCapability && !
|
|
359054
|
+
if (requiredCapability && !plugin8.capabilities[requiredCapability]) {
|
|
357912
359055
|
const capabilityNames = {
|
|
357913
359056
|
canSendText: "sending text messages",
|
|
357914
359057
|
canSendMedia: "sending media",
|
|
@@ -357927,7 +359070,7 @@ async function getPluginForInstance2(services, channelRegistry2, instanceId, req
|
|
|
357927
359070
|
recoverable: false
|
|
357928
359071
|
});
|
|
357929
359072
|
}
|
|
357930
|
-
return { instance: instance4, plugin:
|
|
359073
|
+
return { instance: instance4, plugin: plugin8 };
|
|
357931
359074
|
}
|
|
357932
359075
|
async function getReplyContext(services, instanceId, chatExternalId, replyToId) {
|
|
357933
359076
|
const chat2 = await services.chats.findByExternalIdSmart(instanceId, chatExternalId);
|
|
@@ -358054,8 +359197,8 @@ async function computeCloseContactTerminalState(db2, chatUuid, outcome, auditRow
|
|
|
358054
359197
|
const closeUntil = cfg.cooldownMs !== null ? new Date(Date.now() + cfg.cooldownMs) : null;
|
|
358055
359198
|
return { terminal: false, escalated: false, closeUntil };
|
|
358056
359199
|
}
|
|
358057
|
-
function hasPresenceStatusSender(
|
|
358058
|
-
return typeof
|
|
359200
|
+
function hasPresenceStatusSender(plugin8) {
|
|
359201
|
+
return typeof plugin8 === "object" && plugin8 !== null && "sendPresenceStatus" in plugin8 && typeof plugin8.sendPresenceStatus === "function";
|
|
358059
359202
|
}
|
|
358060
359203
|
async function verifyMessageInstanceOwnership(services, message2, instanceId) {
|
|
358061
359204
|
if (!message2.chatId)
|
|
@@ -358083,7 +359226,7 @@ var init_messages5 = __esm(() => {
|
|
|
358083
359226
|
init_dist6();
|
|
358084
359227
|
init_src2();
|
|
358085
359228
|
init_src();
|
|
358086
|
-
|
|
359229
|
+
init_src6();
|
|
358087
359230
|
init_esm5();
|
|
358088
359231
|
init_drizzle_orm();
|
|
358089
359232
|
init_dist2();
|
|
@@ -358525,7 +359668,7 @@ var init_messages5 = __esm(() => {
|
|
|
358525
359668
|
if (correlationId && tracker.isTracking(correlationId)) {
|
|
358526
359669
|
tracker.recordCheckpoint(correlationId, "T7", JOURNEY_STAGES.T7);
|
|
358527
359670
|
}
|
|
358528
|
-
const { instance: instance4, plugin:
|
|
359671
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, c.get("channelRegistry"), instanceId, "canSendText");
|
|
358529
359672
|
const resolvedTo = await resolveRecipient(to, instance4.channel, services);
|
|
358530
359673
|
const replyContext = replyTo ? await getReplyContext(services, instanceId, resolvedTo, replyTo) : {};
|
|
358531
359674
|
const outgoingMessage = {
|
|
@@ -358538,7 +359681,7 @@ var init_messages5 = __esm(() => {
|
|
|
358538
359681
|
if (correlationId && tracker.isTracking(correlationId)) {
|
|
358539
359682
|
tracker.recordCheckpoint(correlationId, "T8", JOURNEY_STAGES.T8);
|
|
358540
359683
|
}
|
|
358541
|
-
const result = await
|
|
359684
|
+
const result = await plugin8.sendMessage(instanceId, outgoingMessage);
|
|
358542
359685
|
handleSendResult(result, { channelType: instance4.channel, instanceId, operation: "send message" });
|
|
358543
359686
|
if (sentryEnabled()) {
|
|
358544
359687
|
exports_public_api2.count("messages.sent", 1, { attributes: { channel_type: instance4.channel } });
|
|
@@ -358578,8 +359721,8 @@ var init_messages5 = __esm(() => {
|
|
|
358578
359721
|
recoverable: false
|
|
358579
359722
|
});
|
|
358580
359723
|
}
|
|
358581
|
-
const
|
|
358582
|
-
if (!
|
|
359724
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359725
|
+
if (!plugin8) {
|
|
358583
359726
|
throw new OmniError({
|
|
358584
359727
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358585
359728
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358587,7 +359730,7 @@ var init_messages5 = __esm(() => {
|
|
|
358587
359730
|
recoverable: false
|
|
358588
359731
|
});
|
|
358589
359732
|
}
|
|
358590
|
-
if (!
|
|
359733
|
+
if (!plugin8.capabilities.canSendMedia) {
|
|
358591
359734
|
throw new OmniError({
|
|
358592
359735
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
358593
359736
|
message: `Channel ${instance4.channel} does not support sending media`,
|
|
@@ -358612,7 +359755,7 @@ var init_messages5 = __esm(() => {
|
|
|
358612
359755
|
if (correlationId && tracker.isTracking(correlationId)) {
|
|
358613
359756
|
tracker.recordCheckpoint(correlationId, "T8", JOURNEY_STAGES.T8);
|
|
358614
359757
|
}
|
|
358615
|
-
const result = await
|
|
359758
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
358616
359759
|
if (!result.success) {
|
|
358617
359760
|
throw new OmniError({
|
|
358618
359761
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -358658,8 +359801,8 @@ var init_messages5 = __esm(() => {
|
|
|
358658
359801
|
recoverable: false
|
|
358659
359802
|
});
|
|
358660
359803
|
}
|
|
358661
|
-
const
|
|
358662
|
-
if (!
|
|
359804
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359805
|
+
if (!plugin8) {
|
|
358663
359806
|
throw new OmniError({
|
|
358664
359807
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358665
359808
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358667,7 +359810,7 @@ var init_messages5 = __esm(() => {
|
|
|
358667
359810
|
recoverable: false
|
|
358668
359811
|
});
|
|
358669
359812
|
}
|
|
358670
|
-
if (!
|
|
359813
|
+
if (!plugin8.capabilities.canSendReaction) {
|
|
358671
359814
|
throw new OmniError({
|
|
358672
359815
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
358673
359816
|
message: `Channel ${instance4.channel} does not support sending reactions`,
|
|
@@ -358686,7 +359829,7 @@ var init_messages5 = __esm(() => {
|
|
|
358686
359829
|
},
|
|
358687
359830
|
metadata: reactionMetadata
|
|
358688
359831
|
};
|
|
358689
|
-
const result = await
|
|
359832
|
+
const result = await plugin8.sendMessage(instanceId, outgoingMessage);
|
|
358690
359833
|
if (!result.success) {
|
|
358691
359834
|
throw new OmniError({
|
|
358692
359835
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -358724,8 +359867,8 @@ var init_messages5 = __esm(() => {
|
|
|
358724
359867
|
recoverable: false
|
|
358725
359868
|
});
|
|
358726
359869
|
}
|
|
358727
|
-
const
|
|
358728
|
-
if (!
|
|
359870
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359871
|
+
if (!plugin8) {
|
|
358729
359872
|
throw new OmniError({
|
|
358730
359873
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358731
359874
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358733,7 +359876,7 @@ var init_messages5 = __esm(() => {
|
|
|
358733
359876
|
recoverable: false
|
|
358734
359877
|
});
|
|
358735
359878
|
}
|
|
358736
|
-
if (!
|
|
359879
|
+
if (!plugin8.capabilities.canSendSticker) {
|
|
358737
359880
|
throw new OmniError({
|
|
358738
359881
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
358739
359882
|
message: `Channel ${instance4.channel} does not support sending stickers`,
|
|
@@ -358752,7 +359895,7 @@ var init_messages5 = __esm(() => {
|
|
|
358752
359895
|
base64: data.base64
|
|
358753
359896
|
}
|
|
358754
359897
|
};
|
|
358755
|
-
const result = await
|
|
359898
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
358756
359899
|
if (!result.success) {
|
|
358757
359900
|
throw new OmniError({
|
|
358758
359901
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -358788,8 +359931,8 @@ var init_messages5 = __esm(() => {
|
|
|
358788
359931
|
recoverable: false
|
|
358789
359932
|
});
|
|
358790
359933
|
}
|
|
358791
|
-
const
|
|
358792
|
-
if (!
|
|
359934
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359935
|
+
if (!plugin8) {
|
|
358793
359936
|
throw new OmniError({
|
|
358794
359937
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358795
359938
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358797,7 +359940,7 @@ var init_messages5 = __esm(() => {
|
|
|
358797
359940
|
recoverable: false
|
|
358798
359941
|
});
|
|
358799
359942
|
}
|
|
358800
|
-
if (!
|
|
359943
|
+
if (!plugin8.capabilities.canSendContact) {
|
|
358801
359944
|
throw new OmniError({
|
|
358802
359945
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
358803
359946
|
message: `Channel ${instance4.channel} does not support sending contacts`,
|
|
@@ -358813,7 +359956,7 @@ var init_messages5 = __esm(() => {
|
|
|
358813
359956
|
contact: data.contact
|
|
358814
359957
|
}
|
|
358815
359958
|
};
|
|
358816
|
-
const result = await
|
|
359959
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
358817
359960
|
if (!result.success) {
|
|
358818
359961
|
throw new OmniError({
|
|
358819
359962
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -358849,8 +359992,8 @@ var init_messages5 = __esm(() => {
|
|
|
358849
359992
|
recoverable: false
|
|
358850
359993
|
});
|
|
358851
359994
|
}
|
|
358852
|
-
const
|
|
358853
|
-
if (!
|
|
359995
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
359996
|
+
if (!plugin8) {
|
|
358854
359997
|
throw new OmniError({
|
|
358855
359998
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358856
359999
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358858,7 +360001,7 @@ var init_messages5 = __esm(() => {
|
|
|
358858
360001
|
recoverable: false
|
|
358859
360002
|
});
|
|
358860
360003
|
}
|
|
358861
|
-
if (!
|
|
360004
|
+
if (!plugin8.capabilities.canSendLocation) {
|
|
358862
360005
|
throw new OmniError({
|
|
358863
360006
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
358864
360007
|
message: `Channel ${instance4.channel} does not support sending locations`,
|
|
@@ -358879,7 +360022,7 @@ var init_messages5 = __esm(() => {
|
|
|
358879
360022
|
}
|
|
358880
360023
|
}
|
|
358881
360024
|
};
|
|
358882
|
-
const result = await
|
|
360025
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
358883
360026
|
if (!result.success) {
|
|
358884
360027
|
throw new OmniError({
|
|
358885
360028
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -358916,8 +360059,8 @@ var init_messages5 = __esm(() => {
|
|
|
358916
360059
|
recoverable: false
|
|
358917
360060
|
});
|
|
358918
360061
|
}
|
|
358919
|
-
const
|
|
358920
|
-
if (!
|
|
360062
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360063
|
+
if (!plugin8) {
|
|
358921
360064
|
throw new OmniError({
|
|
358922
360065
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
358923
360066
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -358926,7 +360069,7 @@ var init_messages5 = __esm(() => {
|
|
|
358926
360069
|
});
|
|
358927
360070
|
}
|
|
358928
360071
|
const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
|
|
358929
|
-
const hasNativeHandoff =
|
|
360072
|
+
const hasNativeHandoff = plugin8.capabilities?.canHandoff === true;
|
|
358930
360073
|
let channelSendResult = null;
|
|
358931
360074
|
if (hasNativeHandoff) {
|
|
358932
360075
|
const outgoingMessage = {
|
|
@@ -358939,7 +360082,7 @@ var init_messages5 = __esm(() => {
|
|
|
358939
360082
|
handoffFields: data.handoffFields
|
|
358940
360083
|
}
|
|
358941
360084
|
};
|
|
358942
|
-
channelSendResult = await
|
|
360085
|
+
channelSendResult = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
358943
360086
|
handleSendResult(channelSendResult, {
|
|
358944
360087
|
channelType: instance4.channel,
|
|
358945
360088
|
instanceId: data.instanceId,
|
|
@@ -358994,8 +360137,8 @@ var init_messages5 = __esm(() => {
|
|
|
358994
360137
|
recoverable: false
|
|
358995
360138
|
});
|
|
358996
360139
|
}
|
|
358997
|
-
const
|
|
358998
|
-
if (!
|
|
360140
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360141
|
+
if (!plugin8) {
|
|
358999
360142
|
throw new OmniError({
|
|
359000
360143
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359001
360144
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359004,7 +360147,7 @@ var init_messages5 = __esm(() => {
|
|
|
359004
360147
|
});
|
|
359005
360148
|
}
|
|
359006
360149
|
const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
|
|
359007
|
-
const hasNativeClose =
|
|
360150
|
+
const hasNativeClose = plugin8.capabilities?.canCloseContact === true;
|
|
359008
360151
|
const outcome = data.outcome;
|
|
359009
360152
|
let channelSendResult = null;
|
|
359010
360153
|
if (hasNativeClose) {
|
|
@@ -359018,7 +360161,7 @@ var init_messages5 = __esm(() => {
|
|
|
359018
360161
|
closeFields: data.closeFields
|
|
359019
360162
|
}
|
|
359020
360163
|
};
|
|
359021
|
-
channelSendResult = await
|
|
360164
|
+
channelSendResult = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
359022
360165
|
handleSendResult(channelSendResult, {
|
|
359023
360166
|
channelType: instance4.channel,
|
|
359024
360167
|
instanceId: data.instanceId,
|
|
@@ -359107,7 +360250,7 @@ var init_messages5 = __esm(() => {
|
|
|
359107
360250
|
const data = c.req.valid("json");
|
|
359108
360251
|
const services = c.get("services");
|
|
359109
360252
|
checkInstanceAccess2(c.get("apiKey"), data.instanceId);
|
|
359110
|
-
const { instance: instance4, plugin:
|
|
360253
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, c.get("channelRegistry"), data.instanceId, "canSendMedia");
|
|
359111
360254
|
const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
|
|
359112
360255
|
const ttsResult = await services.tts.synthesize(data.text, {
|
|
359113
360256
|
voiceId: data.voiceId || instance4.ttsVoiceId || undefined,
|
|
@@ -359115,10 +360258,10 @@ var init_messages5 = __esm(() => {
|
|
|
359115
360258
|
stability: data.stability,
|
|
359116
360259
|
similarityBoost: data.similarityBoost
|
|
359117
360260
|
});
|
|
359118
|
-
if ("sendTyping" in
|
|
360261
|
+
if ("sendTyping" in plugin8 && typeof plugin8.sendTyping === "function") {
|
|
359119
360262
|
const presenceDuration = data.presenceDelay ?? Math.min(ttsResult.durationMs, 15000);
|
|
359120
360263
|
try {
|
|
359121
|
-
await
|
|
360264
|
+
await plugin8.sendTyping(data.instanceId, resolvedTo, presenceDuration);
|
|
359122
360265
|
if (presenceDuration > 0) {
|
|
359123
360266
|
await new Promise((resolve4) => setTimeout(resolve4, presenceDuration));
|
|
359124
360267
|
}
|
|
@@ -359135,7 +360278,7 @@ var init_messages5 = __esm(() => {
|
|
|
359135
360278
|
ptt: true
|
|
359136
360279
|
}
|
|
359137
360280
|
};
|
|
359138
|
-
const result = await
|
|
360281
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
359139
360282
|
if (!result.success) {
|
|
359140
360283
|
throw new OmniError({
|
|
359141
360284
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -359181,8 +360324,8 @@ var init_messages5 = __esm(() => {
|
|
|
359181
360324
|
recoverable: false
|
|
359182
360325
|
});
|
|
359183
360326
|
}
|
|
359184
|
-
const
|
|
359185
|
-
if (!
|
|
360327
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360328
|
+
if (!plugin8) {
|
|
359186
360329
|
throw new OmniError({
|
|
359187
360330
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359188
360331
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359190,7 +360333,7 @@ var init_messages5 = __esm(() => {
|
|
|
359190
360333
|
recoverable: false
|
|
359191
360334
|
});
|
|
359192
360335
|
}
|
|
359193
|
-
if (!
|
|
360336
|
+
if (!plugin8.capabilities.canForwardMessage) {
|
|
359194
360337
|
throw new OmniError({
|
|
359195
360338
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359196
360339
|
message: `Channel ${instance4.channel} does not support forwarding messages`,
|
|
@@ -359239,7 +360382,7 @@ var init_messages5 = __esm(() => {
|
|
|
359239
360382
|
}
|
|
359240
360383
|
}
|
|
359241
360384
|
};
|
|
359242
|
-
const result = await
|
|
360385
|
+
const result = await plugin8.sendMessage(instanceId, outgoingMessage);
|
|
359243
360386
|
if (!result.success) {
|
|
359244
360387
|
throw new OmniError({
|
|
359245
360388
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -359274,10 +360417,10 @@ var init_messages5 = __esm(() => {
|
|
|
359274
360417
|
const { instanceId, to, type, duration, threadId: threadId2, status, loadingMessages } = c.req.valid("json");
|
|
359275
360418
|
const services = c.get("services");
|
|
359276
360419
|
checkInstanceAccess2(c.get("apiKey"), instanceId);
|
|
359277
|
-
const { instance: instance4, plugin:
|
|
360420
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, c.get("channelRegistry"), instanceId);
|
|
359278
360421
|
const resolvedTo = await resolveRecipient(to, instance4.channel, services);
|
|
359279
|
-
const canSendNativeTyping =
|
|
359280
|
-
const canSendThreadStatus = hasPresenceStatusSender(
|
|
360422
|
+
const canSendNativeTyping = plugin8.capabilities.canSendTyping === true;
|
|
360423
|
+
const canSendThreadStatus = hasPresenceStatusSender(plugin8);
|
|
359281
360424
|
if (!canSendNativeTyping && !canSendThreadStatus) {
|
|
359282
360425
|
throw new OmniError({
|
|
359283
360426
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
@@ -359287,12 +360430,12 @@ var init_messages5 = __esm(() => {
|
|
|
359287
360430
|
});
|
|
359288
360431
|
}
|
|
359289
360432
|
const effectiveDuration = type === "paused" ? 0 : duration ?? (canSendThreadStatus ? 0 : 5000);
|
|
359290
|
-
const presenceResult = canSendThreadStatus ? await
|
|
360433
|
+
const presenceResult = canSendThreadStatus ? await plugin8.sendPresenceStatus(instanceId, resolvedTo, type, effectiveDuration, {
|
|
359291
360434
|
threadId: threadId2,
|
|
359292
360435
|
status,
|
|
359293
360436
|
loadingMessages
|
|
359294
360437
|
}) : await (async () => {
|
|
359295
|
-
if (!("sendTyping" in
|
|
360438
|
+
if (!("sendTyping" in plugin8) || typeof plugin8.sendTyping !== "function") {
|
|
359296
360439
|
throw new OmniError({
|
|
359297
360440
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359298
360441
|
message: `Channel ${instance4.channel} plugin does not implement sendTyping`,
|
|
@@ -359300,7 +360443,7 @@ var init_messages5 = __esm(() => {
|
|
|
359300
360443
|
recoverable: false
|
|
359301
360444
|
});
|
|
359302
360445
|
}
|
|
359303
|
-
await
|
|
360446
|
+
await plugin8.sendTyping(instanceId, resolvedTo, effectiveDuration);
|
|
359304
360447
|
return { delivered: true, method: "typing_indicator" };
|
|
359305
360448
|
})();
|
|
359306
360449
|
return c.json({
|
|
@@ -359343,8 +360486,8 @@ var init_messages5 = __esm(() => {
|
|
|
359343
360486
|
recoverable: false
|
|
359344
360487
|
});
|
|
359345
360488
|
}
|
|
359346
|
-
const { instance: instance4, plugin:
|
|
359347
|
-
if (!("markAsRead" in
|
|
360489
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, channelRegistry2, instanceId, "canReceiveReadReceipts");
|
|
360490
|
+
if (!("markAsRead" in plugin8) || typeof plugin8.markAsRead !== "function") {
|
|
359348
360491
|
throw new OmniError({
|
|
359349
360492
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359350
360493
|
message: `Channel ${instance4.channel} plugin does not implement markAsRead`,
|
|
@@ -359354,7 +360497,7 @@ var init_messages5 = __esm(() => {
|
|
|
359354
360497
|
}
|
|
359355
360498
|
const messageData = [{ externalId: message2.externalId, rawPayload: message2.rawPayload ?? null }];
|
|
359356
360499
|
const readReceiptMode = instance4.readReceipts ?? "on";
|
|
359357
|
-
await
|
|
360500
|
+
await plugin8.markAsRead(instanceId, chat2.externalId, [message2.externalId], messageData, readReceiptMode);
|
|
359358
360501
|
return c.json({
|
|
359359
360502
|
success: true,
|
|
359360
360503
|
data: {
|
|
@@ -359369,8 +360512,8 @@ var init_messages5 = __esm(() => {
|
|
|
359369
360512
|
const services = c.get("services");
|
|
359370
360513
|
const channelRegistry2 = c.get("channelRegistry");
|
|
359371
360514
|
checkInstanceAccess2(c.get("apiKey"), instanceId);
|
|
359372
|
-
const { instance: instance4, plugin:
|
|
359373
|
-
if (!("markAsRead" in
|
|
360515
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, channelRegistry2, instanceId, "canReceiveReadReceipts");
|
|
360516
|
+
if (!("markAsRead" in plugin8) || typeof plugin8.markAsRead !== "function") {
|
|
359374
360517
|
throw new OmniError({
|
|
359375
360518
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359376
360519
|
message: `Channel ${instance4.channel} plugin does not implement markAsRead`,
|
|
@@ -359405,7 +360548,7 @@ var init_messages5 = __esm(() => {
|
|
|
359405
360548
|
messageData = msgs.map((m2) => ({ externalId: m2.externalId, rawPayload: m2.rawPayload ?? null }));
|
|
359406
360549
|
}
|
|
359407
360550
|
const readReceiptMode = instance4.readReceipts ?? "on";
|
|
359408
|
-
await
|
|
360551
|
+
await plugin8.markAsRead(instanceId, externalChatId, messageIds, messageData, readReceiptMode);
|
|
359409
360552
|
return c.json({
|
|
359410
360553
|
success: true,
|
|
359411
360554
|
data: {
|
|
@@ -359466,7 +360609,7 @@ var init_messages5 = __esm(() => {
|
|
|
359466
360609
|
const data = c.req.valid("json");
|
|
359467
360610
|
const services = c.get("services");
|
|
359468
360611
|
checkInstanceAccess2(c.get("apiKey"), data.instanceId);
|
|
359469
|
-
const { instance: instance4, plugin:
|
|
360612
|
+
const { instance: instance4, plugin: plugin8 } = await getPluginForInstance2(services, c.get("channelRegistry"), data.instanceId, "canSendPoll");
|
|
359470
360613
|
const resolvedTo = await resolveRecipient(data.to, instance4.channel, services);
|
|
359471
360614
|
const replyContext = data.replyTo ? await getReplyContext(services, data.instanceId, resolvedTo, data.replyTo) : {};
|
|
359472
360615
|
const outgoingMessage = {
|
|
@@ -359483,7 +360626,7 @@ var init_messages5 = __esm(() => {
|
|
|
359483
360626
|
},
|
|
359484
360627
|
replyTo: data.replyTo
|
|
359485
360628
|
};
|
|
359486
|
-
const result = await
|
|
360629
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
359487
360630
|
handleSendResult(result, { channelType: instance4.channel, instanceId: data.instanceId, operation: "send poll" });
|
|
359488
360631
|
return c.json({ data: { messageId: result.messageId, status: "sent", timestamp: result.timestamp } }, 201);
|
|
359489
360632
|
});
|
|
@@ -359500,8 +360643,8 @@ var init_messages5 = __esm(() => {
|
|
|
359500
360643
|
recoverable: false
|
|
359501
360644
|
});
|
|
359502
360645
|
}
|
|
359503
|
-
const
|
|
359504
|
-
if (!
|
|
360646
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360647
|
+
if (!plugin8) {
|
|
359505
360648
|
throw new OmniError({
|
|
359506
360649
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359507
360650
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359509,7 +360652,7 @@ var init_messages5 = __esm(() => {
|
|
|
359509
360652
|
recoverable: false
|
|
359510
360653
|
});
|
|
359511
360654
|
}
|
|
359512
|
-
if (!
|
|
360655
|
+
if (!plugin8.capabilities.canSendEmbed) {
|
|
359513
360656
|
throw new OmniError({
|
|
359514
360657
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359515
360658
|
message: `Channel ${instance4.channel} does not support sending embeds`,
|
|
@@ -359554,7 +360697,7 @@ var init_messages5 = __esm(() => {
|
|
|
359554
360697
|
},
|
|
359555
360698
|
replyTo: data.replyTo
|
|
359556
360699
|
};
|
|
359557
|
-
const result = await
|
|
360700
|
+
const result = await plugin8.sendMessage(data.instanceId, outgoingMessage);
|
|
359558
360701
|
if (!result.success) {
|
|
359559
360702
|
throw new OmniError({
|
|
359560
360703
|
code: ERROR_CODES.CHANNEL_SEND_FAILED,
|
|
@@ -359589,8 +360732,8 @@ var init_messages5 = __esm(() => {
|
|
|
359589
360732
|
recoverable: false
|
|
359590
360733
|
});
|
|
359591
360734
|
}
|
|
359592
|
-
const
|
|
359593
|
-
if (!
|
|
360735
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360736
|
+
if (!plugin8) {
|
|
359594
360737
|
throw new OmniError({
|
|
359595
360738
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359596
360739
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359598,7 +360741,7 @@ var init_messages5 = __esm(() => {
|
|
|
359598
360741
|
recoverable: false
|
|
359599
360742
|
});
|
|
359600
360743
|
}
|
|
359601
|
-
if (!
|
|
360744
|
+
if (!plugin8.capabilities.canEditMessage) {
|
|
359602
360745
|
throw new OmniError({
|
|
359603
360746
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359604
360747
|
message: `Channel ${instance4.channel} does not support editing messages`,
|
|
@@ -359606,7 +360749,7 @@ var init_messages5 = __esm(() => {
|
|
|
359606
360749
|
recoverable: false
|
|
359607
360750
|
});
|
|
359608
360751
|
}
|
|
359609
|
-
if (!("editMessage" in
|
|
360752
|
+
if (!("editMessage" in plugin8) || typeof plugin8.editMessage !== "function") {
|
|
359610
360753
|
throw new OmniError({
|
|
359611
360754
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359612
360755
|
message: `Channel ${instance4.channel} plugin does not implement editMessage`,
|
|
@@ -359616,7 +360759,7 @@ var init_messages5 = __esm(() => {
|
|
|
359616
360759
|
}
|
|
359617
360760
|
const resolvedMessageId = await resolveChannelMessageId(services, messageId, instanceId);
|
|
359618
360761
|
try {
|
|
359619
|
-
await
|
|
360762
|
+
await plugin8.editMessage(instanceId, channelId, resolvedMessageId, text3);
|
|
359620
360763
|
} catch (error3) {
|
|
359621
360764
|
if (error3 instanceof OmniError)
|
|
359622
360765
|
throw error3;
|
|
@@ -359645,8 +360788,8 @@ var init_messages5 = __esm(() => {
|
|
|
359645
360788
|
recoverable: false
|
|
359646
360789
|
});
|
|
359647
360790
|
}
|
|
359648
|
-
const
|
|
359649
|
-
if (!
|
|
360791
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360792
|
+
if (!plugin8) {
|
|
359650
360793
|
throw new OmniError({
|
|
359651
360794
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359652
360795
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359654,7 +360797,7 @@ var init_messages5 = __esm(() => {
|
|
|
359654
360797
|
recoverable: false
|
|
359655
360798
|
});
|
|
359656
360799
|
}
|
|
359657
|
-
if (!
|
|
360800
|
+
if (!plugin8.capabilities.canDeleteMessage) {
|
|
359658
360801
|
throw new OmniError({
|
|
359659
360802
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359660
360803
|
message: `Channel ${instance4.channel} does not support deleting messages`,
|
|
@@ -359662,7 +360805,7 @@ var init_messages5 = __esm(() => {
|
|
|
359662
360805
|
recoverable: false
|
|
359663
360806
|
});
|
|
359664
360807
|
}
|
|
359665
|
-
if (!("deleteMessage" in
|
|
360808
|
+
if (!("deleteMessage" in plugin8) || typeof plugin8.deleteMessage !== "function") {
|
|
359666
360809
|
throw new OmniError({
|
|
359667
360810
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359668
360811
|
message: `Channel ${instance4.channel} plugin does not implement deleteMessage`,
|
|
@@ -359671,7 +360814,7 @@ var init_messages5 = __esm(() => {
|
|
|
359671
360814
|
});
|
|
359672
360815
|
}
|
|
359673
360816
|
const resolvedMessageId = await resolveChannelMessageId(services, messageId, instanceId);
|
|
359674
|
-
await
|
|
360817
|
+
await plugin8.deleteMessage(instanceId, channelId, resolvedMessageId, fromMe);
|
|
359675
360818
|
return c.json({
|
|
359676
360819
|
success: true,
|
|
359677
360820
|
data: { messageId, externalId: resolvedMessageId, deleted: true }
|
|
@@ -359696,8 +360839,8 @@ var init_messages5 = __esm(() => {
|
|
|
359696
360839
|
recoverable: false
|
|
359697
360840
|
});
|
|
359698
360841
|
}
|
|
359699
|
-
const
|
|
359700
|
-
if (!
|
|
360842
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360843
|
+
if (!plugin8) {
|
|
359701
360844
|
throw new OmniError({
|
|
359702
360845
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359703
360846
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359705,7 +360848,7 @@ var init_messages5 = __esm(() => {
|
|
|
359705
360848
|
recoverable: false
|
|
359706
360849
|
});
|
|
359707
360850
|
}
|
|
359708
|
-
if (!("starMessage" in
|
|
360851
|
+
if (!("starMessage" in plugin8) || typeof plugin8.starMessage !== "function") {
|
|
359709
360852
|
throw new OmniError({
|
|
359710
360853
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359711
360854
|
message: `Channel ${instance4.channel} does not support starring messages`,
|
|
@@ -359713,7 +360856,7 @@ var init_messages5 = __esm(() => {
|
|
|
359713
360856
|
recoverable: false
|
|
359714
360857
|
});
|
|
359715
360858
|
}
|
|
359716
|
-
await
|
|
360859
|
+
await plugin8.starMessage(instanceId, channelId, messageId, true, fromMe);
|
|
359717
360860
|
return c.json({
|
|
359718
360861
|
success: true,
|
|
359719
360862
|
data: { messageId, starred: true }
|
|
@@ -359733,8 +360876,8 @@ var init_messages5 = __esm(() => {
|
|
|
359733
360876
|
recoverable: false
|
|
359734
360877
|
});
|
|
359735
360878
|
}
|
|
359736
|
-
const
|
|
359737
|
-
if (!
|
|
360879
|
+
const plugin8 = channelRegistry2.get(instance4.channel);
|
|
360880
|
+
if (!plugin8) {
|
|
359738
360881
|
throw new OmniError({
|
|
359739
360882
|
code: ERROR_CODES.CHANNEL_NOT_CONNECTED,
|
|
359740
360883
|
message: `No plugin found for channel: ${instance4.channel}`,
|
|
@@ -359742,7 +360885,7 @@ var init_messages5 = __esm(() => {
|
|
|
359742
360885
|
recoverable: false
|
|
359743
360886
|
});
|
|
359744
360887
|
}
|
|
359745
|
-
if (!("starMessage" in
|
|
360888
|
+
if (!("starMessage" in plugin8) || typeof plugin8.starMessage !== "function") {
|
|
359746
360889
|
throw new OmniError({
|
|
359747
360890
|
code: ERROR_CODES.CAPABILITY_NOT_SUPPORTED,
|
|
359748
360891
|
message: `Channel ${instance4.channel} does not support starring messages`,
|
|
@@ -359750,7 +360893,7 @@ var init_messages5 = __esm(() => {
|
|
|
359750
360893
|
recoverable: false
|
|
359751
360894
|
});
|
|
359752
360895
|
}
|
|
359753
|
-
await
|
|
360896
|
+
await plugin8.starMessage(instanceId, channelId, messageId, false, fromMe);
|
|
359754
360897
|
return c.json({
|
|
359755
360898
|
success: true,
|
|
359756
360899
|
data: { messageId, starred: false }
|
|
@@ -360614,9 +361757,9 @@ var init_turns2 = __esm(() => {
|
|
|
360614
361757
|
function findVoicePlugin(channelRegistry2) {
|
|
360615
361758
|
if (!channelRegistry2)
|
|
360616
361759
|
return null;
|
|
360617
|
-
for (const
|
|
360618
|
-
if (isVoiceCapable(
|
|
360619
|
-
return
|
|
361760
|
+
for (const plugin8 of channelRegistry2.getAll()) {
|
|
361761
|
+
if (isVoiceCapable(plugin8))
|
|
361762
|
+
return plugin8;
|
|
360620
361763
|
}
|
|
360621
361764
|
return null;
|
|
360622
361765
|
}
|
|
@@ -360640,12 +361783,12 @@ var init_voice2 = __esm(() => {
|
|
|
360640
361783
|
});
|
|
360641
361784
|
voiceRoutes.post("/join", zValidator("json", joinSchema), async (c) => {
|
|
360642
361785
|
const { instanceId, channelId, guildId } = c.req.valid("json");
|
|
360643
|
-
const
|
|
360644
|
-
if (!
|
|
361786
|
+
const plugin8 = findVoicePlugin(c.get("channelRegistry"));
|
|
361787
|
+
if (!plugin8) {
|
|
360645
361788
|
return c.json({ error: { code: "NOT_AVAILABLE", message: "No voice-capable channel plugin found" } }, 400);
|
|
360646
361789
|
}
|
|
360647
361790
|
try {
|
|
360648
|
-
const session3 = await
|
|
361791
|
+
const session3 = await plugin8.voiceJoin(channelId, { instanceId, guildId });
|
|
360649
361792
|
const eventBus = c.get("eventBus");
|
|
360650
361793
|
if (eventBus) {
|
|
360651
361794
|
eventBus.publish("voice.session_started", { sessionId: session3.id, channelId, instanceId, guildId }).catch(() => {});
|
|
@@ -360666,12 +361809,12 @@ var init_voice2 = __esm(() => {
|
|
|
360666
361809
|
});
|
|
360667
361810
|
voiceRoutes.post("/leave", zValidator("json", leaveSchema), async (c) => {
|
|
360668
361811
|
const { sessionId } = c.req.valid("json");
|
|
360669
|
-
const
|
|
360670
|
-
if (!
|
|
361812
|
+
const plugin8 = findVoicePlugin(c.get("channelRegistry"));
|
|
361813
|
+
if (!plugin8) {
|
|
360671
361814
|
return c.json({ error: { code: "NOT_AVAILABLE", message: "No voice-capable plugin" } }, 400);
|
|
360672
361815
|
}
|
|
360673
361816
|
try {
|
|
360674
|
-
await
|
|
361817
|
+
await plugin8.voiceLeave(sessionId);
|
|
360675
361818
|
const eventBus = c.get("eventBus");
|
|
360676
361819
|
if (eventBus) {
|
|
360677
361820
|
eventBus.publish("voice.session_ended", { sessionId, reason: "manual" }).catch(() => {});
|
|
@@ -360682,10 +361825,10 @@ var init_voice2 = __esm(() => {
|
|
|
360682
361825
|
}
|
|
360683
361826
|
});
|
|
360684
361827
|
voiceRoutes.get("/sessions", async (c) => {
|
|
360685
|
-
const
|
|
360686
|
-
if (!
|
|
361828
|
+
const plugin8 = findVoicePlugin(c.get("channelRegistry"));
|
|
361829
|
+
if (!plugin8)
|
|
360687
361830
|
return c.json({ items: [] });
|
|
360688
|
-
const sessions =
|
|
361831
|
+
const sessions = plugin8.voiceSessions().map((s) => ({
|
|
360689
361832
|
sessionId: s.id,
|
|
360690
361833
|
instanceId: s.instanceId,
|
|
360691
361834
|
channelId: s.channelId,
|
|
@@ -360697,11 +361840,11 @@ var init_voice2 = __esm(() => {
|
|
|
360697
361840
|
});
|
|
360698
361841
|
voiceRoutes.get("/sessions/:id", zValidator("param", sessionIdParamSchema), async (c) => {
|
|
360699
361842
|
const { id } = c.req.valid("param");
|
|
360700
|
-
const
|
|
360701
|
-
if (!
|
|
361843
|
+
const plugin8 = findVoicePlugin(c.get("channelRegistry"));
|
|
361844
|
+
if (!plugin8) {
|
|
360702
361845
|
return c.json({ error: { code: "NOT_AVAILABLE", message: "No voice-capable plugin" } }, 400);
|
|
360703
361846
|
}
|
|
360704
|
-
const session3 =
|
|
361847
|
+
const session3 = plugin8.voiceSession(id);
|
|
360705
361848
|
if (!session3) {
|
|
360706
361849
|
return c.json({ error: { code: "NOT_FOUND", message: `Voice session ${id} not found` } }, 404);
|
|
360707
361850
|
}
|
|
@@ -360978,8 +362121,8 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
360978
362121
|
return c.json(validationError.body, validationError.status);
|
|
360979
362122
|
}
|
|
360980
362123
|
const channelRegistry3 = c.get("channelRegistry");
|
|
360981
|
-
const
|
|
360982
|
-
if (!
|
|
362124
|
+
const plugin8 = channelRegistry3?.get("a2a");
|
|
362125
|
+
if (!plugin8?.handleWebhook) {
|
|
360983
362126
|
return c.json({ error: "A2A channel not available" }, 503);
|
|
360984
362127
|
}
|
|
360985
362128
|
const headers = new Headers(c.req.raw.headers);
|
|
@@ -360987,7 +362130,7 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
360987
362130
|
if (apiKey?.id) {
|
|
360988
362131
|
headers.set("x-omni-api-key-id", apiKey.id);
|
|
360989
362132
|
}
|
|
360990
|
-
return
|
|
362133
|
+
return plugin8.handleWebhook(new Request(c.req.raw, { headers }));
|
|
360991
362134
|
});
|
|
360992
362135
|
} else {
|
|
360993
362136
|
app.all("/a2a/*", (c) => c.json({ error: "A2A channel not enabled. Set A2A_ENABLED=true." }, 503));
|
|
@@ -361000,11 +362143,11 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
361000
362143
|
if (!channelRegistry3) {
|
|
361001
362144
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
361002
362145
|
}
|
|
361003
|
-
const
|
|
361004
|
-
if (!
|
|
362146
|
+
const plugin8 = channelRegistry3.get("telegram");
|
|
362147
|
+
if (!plugin8) {
|
|
361005
362148
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: "Telegram plugin not loaded" } }, 503);
|
|
361006
362149
|
}
|
|
361007
|
-
const telegramPlugin =
|
|
362150
|
+
const telegramPlugin = plugin8;
|
|
361008
362151
|
const webhookSecret = telegramPlugin.getWebhookSecret(id);
|
|
361009
362152
|
let authPassed = false;
|
|
361010
362153
|
await createWebhookAuthMiddleware({ webhookSecret })(c, async () => {
|
|
@@ -361030,22 +362173,22 @@ function createApp(db2, eventBus = null, channelRegistry2 = null) {
|
|
|
361030
362173
|
if (!channelRegistry3) {
|
|
361031
362174
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
361032
362175
|
}
|
|
361033
|
-
const
|
|
361034
|
-
if (!
|
|
362176
|
+
const plugin8 = channelRegistry3.get("gupshup");
|
|
362177
|
+
if (!plugin8?.handleWebhook) {
|
|
361035
362178
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: "Gupshup plugin not loaded" } }, 503);
|
|
361036
362179
|
}
|
|
361037
|
-
return
|
|
362180
|
+
return plugin8.handleWebhook(c.req.raw);
|
|
361038
362181
|
});
|
|
361039
362182
|
app.post("/api/v2/channels/twilio-whatsapp/:instanceId/webhook", async (c) => {
|
|
361040
362183
|
const channelRegistry3 = c.get("channelRegistry");
|
|
361041
362184
|
if (!channelRegistry3) {
|
|
361042
362185
|
return c.json({ error: { code: "NO_REGISTRY", message: "Channel registry not available" } }, 503);
|
|
361043
362186
|
}
|
|
361044
|
-
const
|
|
361045
|
-
if (!
|
|
362187
|
+
const plugin8 = channelRegistry3.get("twilio-whatsapp");
|
|
362188
|
+
if (!plugin8?.handleWebhook) {
|
|
361046
362189
|
return c.json({ error: { code: "PLUGIN_NOT_FOUND", message: "Twilio WhatsApp plugin not loaded" } }, 503);
|
|
361047
362190
|
}
|
|
361048
|
-
return
|
|
362191
|
+
return plugin8.handleWebhook(c.req.raw);
|
|
361049
362192
|
});
|
|
361050
362193
|
const protectedApp = new Hono2;
|
|
361051
362194
|
protectedApp.use("*", authMiddleware);
|
|
@@ -361304,7 +362447,7 @@ async function setupChatUnreadListener(eventBus, db2) {
|
|
|
361304
362447
|
var instanceLog, messageLog, lidLog, contactsLog, unreadLog;
|
|
361305
362448
|
var init_event_listeners = __esm(() => {
|
|
361306
362449
|
init_src();
|
|
361307
|
-
|
|
362450
|
+
init_src6();
|
|
361308
362451
|
init_esm5();
|
|
361309
362452
|
init_drizzle_orm();
|
|
361310
362453
|
init_sentry_scrub();
|
|
@@ -361579,7 +362722,7 @@ async function setupEventPersistence(eventBus, db2) {
|
|
|
361579
362722
|
var log113, CONSUMER_OPTIONS;
|
|
361580
362723
|
var init_event_persistence = __esm(() => {
|
|
361581
362724
|
init_src();
|
|
361582
|
-
|
|
362725
|
+
init_src6();
|
|
361583
362726
|
init_drizzle_orm();
|
|
361584
362727
|
log113 = createLogger("event-persistence");
|
|
361585
362728
|
CONSUMER_OPTIONS = {
|
|
@@ -361975,8 +363118,8 @@ async function setupMediaProcessor(eventBus, db2, services) {
|
|
|
361975
363118
|
var log114, PROCESSABLE_MEDIA_TYPES;
|
|
361976
363119
|
var init_media_processor = __esm(() => {
|
|
361977
363120
|
init_src();
|
|
361978
|
-
init_src5();
|
|
361979
363121
|
init_src6();
|
|
363122
|
+
init_src7();
|
|
361980
363123
|
init_drizzle_orm();
|
|
361981
363124
|
init_media_storage();
|
|
361982
363125
|
log114 = createLogger("media-processor");
|
|
@@ -362157,13 +363300,13 @@ function buildAnchorsForExplicitChatJids(jobId, chatJids, dbAnchors) {
|
|
|
362157
363300
|
}
|
|
362158
363301
|
return anchors;
|
|
362159
363302
|
}
|
|
362160
|
-
function hasKnownChatJids(
|
|
362161
|
-
return typeof
|
|
363303
|
+
function hasKnownChatJids(plugin8) {
|
|
363304
|
+
return typeof plugin8 === "object" && plugin8 !== null && "getKnownChatJids" in plugin8 && typeof plugin8.getKnownChatJids === "function";
|
|
362162
363305
|
}
|
|
362163
|
-
async function discoverAnchorsFromPlugin(jobId, instanceId,
|
|
363306
|
+
async function discoverAnchorsFromPlugin(jobId, instanceId, plugin8, dbAnchors, services) {
|
|
362164
363307
|
const anchoredJids = new Set(dbAnchors.map((a) => a.chatJid));
|
|
362165
363308
|
const dbExternalIds = await services.chats.getAllExternalIds(instanceId);
|
|
362166
|
-
const baileysJids = hasKnownChatJids(
|
|
363309
|
+
const baileysJids = hasKnownChatJids(plugin8) ? plugin8.getKnownChatJids(instanceId) : [];
|
|
362167
363310
|
const allJids = new Set([...dbExternalIds, ...baileysJids]);
|
|
362168
363311
|
const discovered = [];
|
|
362169
363312
|
for (const jid of allJids) {
|
|
@@ -362183,18 +363326,18 @@ async function discoverAnchorsFromPlugin(jobId, instanceId, plugin7, dbAnchors,
|
|
|
362183
363326
|
}
|
|
362184
363327
|
return discovered;
|
|
362185
363328
|
}
|
|
362186
|
-
async function resolveWhatsAppAnchors(jobId, instanceId, config4,
|
|
363329
|
+
async function resolveWhatsAppAnchors(jobId, instanceId, config4, plugin8, dbAnchors, services) {
|
|
362187
363330
|
if (config4.chatJids?.length) {
|
|
362188
363331
|
return buildAnchorsForExplicitChatJids(jobId, config4.chatJids, dbAnchors);
|
|
362189
363332
|
}
|
|
362190
|
-
return [...dbAnchors, ...await discoverAnchorsFromPlugin(jobId, instanceId,
|
|
363333
|
+
return [...dbAnchors, ...await discoverAnchorsFromPlugin(jobId, instanceId, plugin8, dbAnchors, services)];
|
|
362191
363334
|
}
|
|
362192
363335
|
async function processMessageSync(jobId, instanceId, channelType, config4, services, channelRegistry2) {
|
|
362193
|
-
const
|
|
362194
|
-
if (!
|
|
363336
|
+
const plugin8 = channelRegistry2.get(channelType);
|
|
363337
|
+
if (!plugin8) {
|
|
362195
363338
|
throw new Error(`No plugin found for channel type: ${channelType}`);
|
|
362196
363339
|
}
|
|
362197
|
-
if (!("fetchHistory" in
|
|
363340
|
+
if (!("fetchHistory" in plugin8) || typeof plugin8.fetchHistory !== "function") {
|
|
362198
363341
|
log115.warn("Plugin does not support fetchHistory", { channelType });
|
|
362199
363342
|
await services.syncJobs.complete(jobId);
|
|
362200
363343
|
return;
|
|
@@ -362213,11 +363356,11 @@ async function processMessageSync(jobId, instanceId, channelType, config4, servi
|
|
|
362213
363356
|
let anchors = [];
|
|
362214
363357
|
if (channelType === "whatsapp-baileys" && config4.chatJids?.length) {
|
|
362215
363358
|
const dbAnchors = await buildWhatsAppAnchors(instanceId, services);
|
|
362216
|
-
anchors = await resolveWhatsAppAnchors(jobId, instanceId, config4,
|
|
363359
|
+
anchors = await resolveWhatsAppAnchors(jobId, instanceId, config4, plugin8, dbAnchors, services);
|
|
362217
363360
|
log115.info("WhatsApp per-chat active sync", { jobId, anchorCount: anchors.length, chatJids: config4.chatJids });
|
|
362218
363361
|
} else if (channelType === "whatsapp-baileys") {
|
|
362219
363362
|
const dbAnchors = await buildWhatsAppAnchors(instanceId, services);
|
|
362220
|
-
const discoveredAnchors = await discoverAnchorsFromPlugin(jobId, instanceId,
|
|
363363
|
+
const discoveredAnchors = await discoverAnchorsFromPlugin(jobId, instanceId, plugin8, dbAnchors, services);
|
|
362221
363364
|
anchors = [...dbAnchors, ...discoveredAnchors];
|
|
362222
363365
|
if (anchors.length > 0) {
|
|
362223
363366
|
log115.info("WhatsApp default sync with DB+cache discovery", {
|
|
@@ -362284,7 +363427,7 @@ async function processMessageSync(jobId, instanceId, channelType, config4, servi
|
|
|
362284
363427
|
if (channelType === "discord" && config4.channelId) {
|
|
362285
363428
|
fetchOptions.channelId = config4.channelId;
|
|
362286
363429
|
}
|
|
362287
|
-
await
|
|
363430
|
+
await plugin8.fetchHistory(instanceId, fetchOptions);
|
|
362288
363431
|
await services.syncJobs.updateProgress(jobId, {
|
|
362289
363432
|
fetched,
|
|
362290
363433
|
stored,
|
|
@@ -362354,11 +363497,11 @@ async function updateDmChatName(services, instanceId, jid, name) {
|
|
|
362354
363497
|
} catch {}
|
|
362355
363498
|
}
|
|
362356
363499
|
async function processContactsSync(jobId, instanceId, channelType, config4, services, channelRegistry2) {
|
|
362357
|
-
const
|
|
362358
|
-
if (!
|
|
363500
|
+
const plugin8 = channelRegistry2.get(channelType);
|
|
363501
|
+
if (!plugin8) {
|
|
362359
363502
|
throw new Error(`No plugin found for channel type: ${channelType}`);
|
|
362360
363503
|
}
|
|
362361
|
-
if (!("fetchContacts" in
|
|
363504
|
+
if (!("fetchContacts" in plugin8) || typeof plugin8.fetchContacts !== "function") {
|
|
362362
363505
|
log115.warn("Plugin does not support fetchContacts", { channelType });
|
|
362363
363506
|
await services.syncJobs.complete(jobId);
|
|
362364
363507
|
return;
|
|
@@ -362415,7 +363558,7 @@ async function processContactsSync(jobId, instanceId, channelType, config4, serv
|
|
|
362415
363558
|
if (channelType === "discord" && config4.channelId) {
|
|
362416
363559
|
fetchOptions.guildId = config4.channelId;
|
|
362417
363560
|
}
|
|
362418
|
-
await
|
|
363561
|
+
await plugin8.fetchContacts(instanceId, fetchOptions);
|
|
362419
363562
|
await services.syncJobs.updateProgress(jobId, {
|
|
362420
363563
|
fetched,
|
|
362421
363564
|
stored,
|
|
@@ -362430,12 +363573,12 @@ async function processContactsSync(jobId, instanceId, channelType, config4, serv
|
|
|
362430
363573
|
});
|
|
362431
363574
|
}
|
|
362432
363575
|
async function processGroupsSync(jobId, instanceId, channelType, _config, services, channelRegistry2) {
|
|
362433
|
-
const
|
|
362434
|
-
if (!
|
|
363576
|
+
const plugin8 = channelRegistry2.get(channelType);
|
|
363577
|
+
if (!plugin8) {
|
|
362435
363578
|
throw new Error(`No plugin found for channel type: ${channelType}`);
|
|
362436
363579
|
}
|
|
362437
363580
|
const fetchMethod = channelType === "discord" ? "fetchGuilds" : "fetchGroups";
|
|
362438
|
-
if (!(fetchMethod in
|
|
363581
|
+
if (!(fetchMethod in plugin8) || typeof plugin8[fetchMethod] !== "function") {
|
|
362439
363582
|
log115.warn(`Plugin does not support ${fetchMethod}`, { channelType });
|
|
362440
363583
|
await services.syncJobs.complete(jobId);
|
|
362441
363584
|
return;
|
|
@@ -362545,8 +363688,8 @@ async function processGroupsSync(jobId, instanceId, channelType, _config, servic
|
|
|
362545
363688
|
}
|
|
362546
363689
|
}
|
|
362547
363690
|
};
|
|
362548
|
-
const fetchFn =
|
|
362549
|
-
await fetchFn.call(
|
|
363691
|
+
const fetchFn = plugin8[fetchMethod];
|
|
363692
|
+
await fetchFn.call(plugin8, instanceId, fetchOptions);
|
|
362550
363693
|
await services.syncJobs.updateProgress(jobId, {
|
|
362551
363694
|
fetched,
|
|
362552
363695
|
stored,
|
|
@@ -362676,7 +363819,7 @@ async function setupHistoryPushTracker(eventBus, services) {
|
|
|
362676
363819
|
var log115, RATE_LIMITS2, db2 = null, historyPushLog;
|
|
362677
363820
|
var init_sync_worker = __esm(() => {
|
|
362678
363821
|
init_src();
|
|
362679
|
-
|
|
363822
|
+
init_src6();
|
|
362680
363823
|
init_drizzle_orm();
|
|
362681
363824
|
log115 = createLogger("sync-worker");
|
|
362682
363825
|
RATE_LIMITS2 = {
|
|
@@ -362895,18 +364038,18 @@ function applyTwilioWhatsAppOptions(options, instance4) {
|
|
|
362895
364038
|
}
|
|
362896
364039
|
}
|
|
362897
364040
|
async function connectInstance(instance4, registry5) {
|
|
362898
|
-
const
|
|
362899
|
-
if (!
|
|
364041
|
+
const plugin8 = registry5.get(instance4.channel);
|
|
364042
|
+
if (!plugin8) {
|
|
362900
364043
|
throw new Error(`No plugin for channel: ${instance4.channel}`);
|
|
362901
364044
|
}
|
|
362902
|
-
if ("loadGuildConfigs" in
|
|
362903
|
-
|
|
364045
|
+
if ("loadGuildConfigs" in plugin8 && instance4.guildConfigOverrides) {
|
|
364046
|
+
plugin8.loadGuildConfigs(instance4.id, instance4.guildConfigOverrides);
|
|
362904
364047
|
}
|
|
362905
364048
|
const options = buildInstanceConnectOptions(instance4);
|
|
362906
364049
|
if (instance4.discordPresence) {
|
|
362907
364050
|
options.presence = instance4.discordPresence;
|
|
362908
364051
|
}
|
|
362909
|
-
await
|
|
364052
|
+
await plugin8.connect(instance4.id, {
|
|
362910
364053
|
instanceId: instance4.id,
|
|
362911
364054
|
credentials: {},
|
|
362912
364055
|
options
|
|
@@ -362994,11 +364137,11 @@ class InstanceMonitor {
|
|
|
362994
364137
|
}).from(instances).where(eq(instances.isActive, true));
|
|
362995
364138
|
}
|
|
362996
364139
|
async checkInstanceHealth(instance4) {
|
|
362997
|
-
const
|
|
362998
|
-
if (!
|
|
364140
|
+
const plugin8 = this.getPluginForInstance(instance4);
|
|
364141
|
+
if (!plugin8)
|
|
362999
364142
|
return;
|
|
363000
364143
|
try {
|
|
363001
|
-
const status = await
|
|
364144
|
+
const status = await plugin8.getStatus(instance4.id);
|
|
363002
364145
|
if (needsReconnect(status)) {
|
|
363003
364146
|
this.handleUnhealthyInstance(instance4, status.state, status.message);
|
|
363004
364147
|
}
|
|
@@ -363008,11 +364151,11 @@ class InstanceMonitor {
|
|
|
363008
364151
|
}
|
|
363009
364152
|
}
|
|
363010
364153
|
getPluginForInstance(instance4) {
|
|
363011
|
-
const
|
|
363012
|
-
if (!
|
|
364154
|
+
const plugin8 = this.registry.get(instance4.channel);
|
|
364155
|
+
if (!plugin8) {
|
|
363013
364156
|
logger7.warn("No plugin for instance", { instanceId: instance4.id, channel: instance4.channel });
|
|
363014
364157
|
}
|
|
363015
|
-
return
|
|
364158
|
+
return plugin8 ?? null;
|
|
363016
364159
|
}
|
|
363017
364160
|
handleUnhealthyInstance(instance4, state, message2) {
|
|
363018
364161
|
if (!wasAuthenticated(instance4)) {
|
|
@@ -363188,7 +364331,7 @@ async function processSingleBatch(batch, registry5, db3, results) {
|
|
|
363188
364331
|
}
|
|
363189
364332
|
var logger7, DEFAULT_CONFIG3, STALE_TRANSITION_MAX_AGE_MS;
|
|
363190
364333
|
var init_instance_monitor = __esm(() => {
|
|
363191
|
-
|
|
364334
|
+
init_src6();
|
|
363192
364335
|
init_drizzle_orm();
|
|
363193
364336
|
init_logger4();
|
|
363194
364337
|
logger7 = createLogger3({ module: "instance-monitor" });
|
|
@@ -363859,8 +365002,8 @@ var init_voice3 = __esm(() => {
|
|
|
363859
365002
|
});
|
|
363860
365003
|
|
|
363861
365004
|
// ../api/src/index.ts
|
|
363862
|
-
var
|
|
363863
|
-
__export(
|
|
365005
|
+
var exports_src3 = {};
|
|
365006
|
+
__export(exports_src3, {
|
|
363864
365007
|
voiceStreamRegistry: () => voiceStreamRegistry,
|
|
363865
365008
|
getInstanceMonitor: () => getInstanceMonitor,
|
|
363866
365009
|
getEventBus: () => getEventBus,
|
|
@@ -363904,10 +365047,10 @@ async function initializeChannelPlugins(db3, eventBus) {
|
|
|
363904
365047
|
pluginLog.info("Loading channel plugins");
|
|
363905
365048
|
const result = await loadChannelPlugins2({ eventBus, db: db3 });
|
|
363906
365049
|
globalChannelRegistry = result.registry;
|
|
363907
|
-
for (const
|
|
363908
|
-
if (isVoiceCapable(
|
|
363909
|
-
Object.assign(
|
|
363910
|
-
pluginLog.info("Voice stream registry wired to plugin", { pluginId:
|
|
365050
|
+
for (const plugin8 of result.registry.getAll()) {
|
|
365051
|
+
if (isVoiceCapable(plugin8) && "voiceStreamSink" in plugin8) {
|
|
365052
|
+
Object.assign(plugin8, { voiceStreamSink: voiceStreamRegistry });
|
|
365053
|
+
pluginLog.info("Voice stream registry wired to plugin", { pluginId: plugin8.id });
|
|
363911
365054
|
}
|
|
363912
365055
|
}
|
|
363913
365056
|
if (result.loaded > 0) {
|
|
@@ -364123,8 +365266,8 @@ async function setupEventBusServices(eventBus, services, db3) {
|
|
|
364123
365266
|
const instance4 = await services.instances.getById(instanceId);
|
|
364124
365267
|
if (!instance4)
|
|
364125
365268
|
throw new Error(`Instance not found: ${instanceId}`);
|
|
364126
|
-
const
|
|
364127
|
-
if (!
|
|
365269
|
+
const plugin8 = await getPlugin(instance4.channel);
|
|
365270
|
+
if (!plugin8)
|
|
364128
365271
|
throw new Error(`No plugin for channel: ${instance4.channel}`);
|
|
364129
365272
|
let recipient = to;
|
|
364130
365273
|
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(to)) {
|
|
@@ -364135,7 +365278,7 @@ async function setupEventBusServices(eventBus, services, db3) {
|
|
|
364135
365278
|
throw new Error(`Chat not found for UUID: ${to}`);
|
|
364136
365279
|
}
|
|
364137
365280
|
}
|
|
364138
|
-
await
|
|
365281
|
+
await plugin8.sendMessage(instanceId, { to: recipient, content: { type: "text", text: content } });
|
|
364139
365282
|
},
|
|
364140
365283
|
callAgent: async (ctx, cfg) => {
|
|
364141
365284
|
const instance4 = await services.instances.getById(ctx.instanceId);
|
|
@@ -364373,12 +365516,12 @@ async function main() {
|
|
|
364373
365516
|
setupShutdownHandlers(server, earlyShutdown);
|
|
364374
365517
|
}
|
|
364375
365518
|
var import__package3, log122, natsLog, pluginLog, shutdownLog, PORT, HOST, NATS_URL, voiceStreamRegistry, globalEventBus = null, globalChannelRegistry = null, globalInstanceMonitor = null, globalDispatcherCleanup = null, globalTurnMonitor = null, globalDbRef = null, UUID_RE3;
|
|
364376
|
-
var
|
|
365519
|
+
var init_src8 = __esm(() => {
|
|
364377
365520
|
init_instrument2();
|
|
364378
365521
|
init_tracing4();
|
|
364379
365522
|
init_src2();
|
|
364380
365523
|
init_src();
|
|
364381
|
-
|
|
365524
|
+
init_src6();
|
|
364382
365525
|
init_esm5();
|
|
364383
365526
|
init_drizzle_orm();
|
|
364384
365527
|
init_app();
|
|
@@ -489742,7 +490885,11 @@ var plugin6 = new WhatsAppPlugin;
|
|
|
489742
490885
|
var src_default5 = plugin6;
|
|
489743
490886
|
|
|
489744
490887
|
// src/bundled-server-entry.ts
|
|
489745
|
-
for (const
|
|
489746
|
-
channelRegistry.register(
|
|
490888
|
+
for (const plugin8 of [src_default4, src_default, src_default5, src_default3, src_default2]) {
|
|
490889
|
+
channelRegistry.register(plugin8);
|
|
490890
|
+
}
|
|
490891
|
+
if (process.env.A2A_ENABLED === "true") {
|
|
490892
|
+
const { default: a2aPlugin } = await Promise.resolve().then(() => (init_src4(), exports_src2));
|
|
490893
|
+
channelRegistry.register(a2aPlugin);
|
|
489747
490894
|
}
|
|
489748
|
-
await Promise.resolve().then(() => (
|
|
490895
|
+
await Promise.resolve().then(() => (init_src8(), exports_src3));
|