@automagik/omni 2.260529.2 → 2.260530.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/commands/listen.d.ts +1 -0
- package/dist/commands/listen.d.ts.map +1 -1
- package/dist/index.js +266 -35
- package/dist/sdk/client.d.ts +3 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/index.js +4 -1
- package/dist/server/index.js +7584 -6693
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Listen Command — Speech-to-text verb
|
|
3
3
|
*
|
|
4
4
|
* omni listen audio.ogg — print transcription to stdout
|
|
5
|
+
* omni listen audio.ogg --provider openai — force OpenAI STT (quality default)
|
|
5
6
|
* omni listen audio.ogg --provider gemini — force Gemini STT (handles >19.5MB)
|
|
6
7
|
* omni listen audio.ogg --provider groq — force Groq Whisper (fast, 19.5MB cap)
|
|
7
8
|
* omni listen audio.ogg --language pt — language hint
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listen.d.ts","sourceRoot":"","sources":["../../src/commands/listen.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"listen.d.ts","sourceRoot":"","sources":["../../src/commands/listen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8DpC,wBAAgB,mBAAmB,IAAI,OAAO,CAqI7C"}
|
package/dist/index.js
CHANGED
|
@@ -35857,6 +35857,82 @@ function buildProviderRequestContext(context) {
|
|
|
35857
35857
|
}
|
|
35858
35858
|
var OMNI_EXECUTION_CONTEXT_EXTENSION_URI = "https://omni.dev/extensions/execution-context/v1";
|
|
35859
35859
|
|
|
35860
|
+
// ../core/src/providers/trace-context.ts
|
|
35861
|
+
import { createHash as createHash3 } from "crypto";
|
|
35862
|
+
function isNonZeroHex(value) {
|
|
35863
|
+
return value.length > 0 && !/^0+$/.test(value);
|
|
35864
|
+
}
|
|
35865
|
+
function hashHex(value, length) {
|
|
35866
|
+
return createHash3("sha256").update(value).digest("hex").slice(0, length);
|
|
35867
|
+
}
|
|
35868
|
+
function normalizeTraceId(value) {
|
|
35869
|
+
const lower = value.toLowerCase();
|
|
35870
|
+
if (W3C_TRACE_ID.test(lower) && isNonZeroHex(lower)) {
|
|
35871
|
+
return lower;
|
|
35872
|
+
}
|
|
35873
|
+
return hashHex(lower, 32);
|
|
35874
|
+
}
|
|
35875
|
+
function normalizeSpanId(value) {
|
|
35876
|
+
const lower = value.toLowerCase();
|
|
35877
|
+
if (W3C_SPAN_ID.test(lower) && isNonZeroHex(lower)) {
|
|
35878
|
+
return lower;
|
|
35879
|
+
}
|
|
35880
|
+
return hashHex(lower, 16);
|
|
35881
|
+
}
|
|
35882
|
+
function createTraceContextFromTraceId(traceId, spanSeed = "provider") {
|
|
35883
|
+
if (!traceId)
|
|
35884
|
+
return;
|
|
35885
|
+
return {
|
|
35886
|
+
traceId: normalizeTraceId(traceId),
|
|
35887
|
+
spanId: normalizeSpanId(`${traceId}:${spanSeed}`),
|
|
35888
|
+
traceFlags: 1
|
|
35889
|
+
};
|
|
35890
|
+
}
|
|
35891
|
+
function formatTraceparent(ctx) {
|
|
35892
|
+
const traceFlags = (ctx.traceFlags ?? 1) & 255;
|
|
35893
|
+
const paddedFlagsHex = traceFlags.toString(16).padStart(2, "0");
|
|
35894
|
+
return `00-${normalizeTraceId(ctx.traceId)}-${normalizeSpanId(ctx.spanId)}-${paddedFlagsHex}`;
|
|
35895
|
+
}
|
|
35896
|
+
function buildTraceHeaders2(ctx, khal) {
|
|
35897
|
+
const traceHeaders = {};
|
|
35898
|
+
if (ctx) {
|
|
35899
|
+
traceHeaders.traceparent = formatTraceparent(ctx);
|
|
35900
|
+
traceHeaders["x-trace-id"] = normalizeTraceId(ctx.traceId);
|
|
35901
|
+
traceHeaders["x-span-id"] = normalizeSpanId(ctx.spanId);
|
|
35902
|
+
const tracestate = ctx.tracestate ?? ctx.traceState;
|
|
35903
|
+
if (tracestate) {
|
|
35904
|
+
traceHeaders.tracestate = tracestate;
|
|
35905
|
+
}
|
|
35906
|
+
if (ctx.parentSpanId) {
|
|
35907
|
+
traceHeaders["x-parent-span-id"] = normalizeSpanId(ctx.parentSpanId);
|
|
35908
|
+
}
|
|
35909
|
+
}
|
|
35910
|
+
if (khal?.khalSessionId) {
|
|
35911
|
+
traceHeaders["x-khal-session-id"] = khal.khalSessionId;
|
|
35912
|
+
}
|
|
35913
|
+
if (khal?.userId) {
|
|
35914
|
+
traceHeaders["x-khal-user-id"] = khal.userId;
|
|
35915
|
+
}
|
|
35916
|
+
if (khal?.messageId) {
|
|
35917
|
+
traceHeaders["x-khal-message-id"] = khal.messageId;
|
|
35918
|
+
}
|
|
35919
|
+
if (khal?.omni?.instanceId) {
|
|
35920
|
+
traceHeaders["x-omni-instance-id"] = khal.omni.instanceId;
|
|
35921
|
+
}
|
|
35922
|
+
if (khal?.omni?.chatId) {
|
|
35923
|
+
traceHeaders["x-omni-chat-id"] = khal.omni.chatId;
|
|
35924
|
+
}
|
|
35925
|
+
if (khal?.omni?.channel) {
|
|
35926
|
+
traceHeaders["x-omni-channel"] = khal.omni.channel;
|
|
35927
|
+
}
|
|
35928
|
+
return traceHeaders;
|
|
35929
|
+
}
|
|
35930
|
+
var W3C_TRACE_ID, W3C_SPAN_ID;
|
|
35931
|
+
var init_trace_context = __esm(() => {
|
|
35932
|
+
W3C_TRACE_ID = /^[0-9a-f]{32}$/i;
|
|
35933
|
+
W3C_SPAN_ID = /^[0-9a-f]{16}$/i;
|
|
35934
|
+
});
|
|
35935
|
+
|
|
35860
35936
|
// ../core/src/providers/agno-client.ts
|
|
35861
35937
|
class AgnoClient {
|
|
35862
35938
|
baseUrl;
|
|
@@ -35985,12 +36061,14 @@ class AgnoClient {
|
|
|
35985
36061
|
const formData = new FormData;
|
|
35986
36062
|
formData.append("message", request.message);
|
|
35987
36063
|
formData.append("stream", String(stream));
|
|
35988
|
-
|
|
35989
|
-
|
|
36064
|
+
const sessionId = request.khalSessionId ?? request.sessionId;
|
|
36065
|
+
if (sessionId) {
|
|
36066
|
+
formData.append("session_id", sessionId);
|
|
35990
36067
|
}
|
|
35991
36068
|
if (request.userId) {
|
|
35992
36069
|
formData.append("user_id", request.userId);
|
|
35993
36070
|
}
|
|
36071
|
+
this.appendStructuredMetadata(formData, request);
|
|
35994
36072
|
if (request.files?.length) {
|
|
35995
36073
|
for (const file of request.files) {
|
|
35996
36074
|
try {
|
|
@@ -36008,6 +36086,28 @@ class AgnoClient {
|
|
|
36008
36086
|
}
|
|
36009
36087
|
return formData;
|
|
36010
36088
|
}
|
|
36089
|
+
appendStructuredMetadata(formData, request) {
|
|
36090
|
+
const appendJson = (key, value) => {
|
|
36091
|
+
if (value !== undefined) {
|
|
36092
|
+
formData.append(key, JSON.stringify(value));
|
|
36093
|
+
}
|
|
36094
|
+
};
|
|
36095
|
+
if (request.khalSessionId) {
|
|
36096
|
+
formData.append("khal_session_id", request.khalSessionId);
|
|
36097
|
+
}
|
|
36098
|
+
if (request.messageId) {
|
|
36099
|
+
formData.append("message_id", request.messageId);
|
|
36100
|
+
}
|
|
36101
|
+
if (request.replyToMessageId) {
|
|
36102
|
+
formData.append("reply_to_message_id", request.replyToMessageId);
|
|
36103
|
+
}
|
|
36104
|
+
appendJson("platform", request.platform);
|
|
36105
|
+
appendJson("sender", request.sender);
|
|
36106
|
+
appendJson("chat", request.chat);
|
|
36107
|
+
appendJson("mcp_url_params", request.mcpUrlParams);
|
|
36108
|
+
appendJson("env", request.env);
|
|
36109
|
+
appendJson("omni", request.omni);
|
|
36110
|
+
}
|
|
36011
36111
|
async runAgent(agentId, request) {
|
|
36012
36112
|
return this.runEndpoint("agents", agentId, request);
|
|
36013
36113
|
}
|
|
@@ -36023,7 +36123,15 @@ class AgnoClient {
|
|
|
36023
36123
|
const timeoutMs = request.timeoutMs ?? this.defaultTimeoutMs;
|
|
36024
36124
|
const response = await this.fetchWithTimeout(url, {
|
|
36025
36125
|
method: "POST",
|
|
36026
|
-
headers:
|
|
36126
|
+
headers: {
|
|
36127
|
+
...this.getHeaders(),
|
|
36128
|
+
...buildTraceHeaders2(request.traceContext, {
|
|
36129
|
+
khalSessionId: request.khalSessionId ?? request.sessionId,
|
|
36130
|
+
userId: request.userId,
|
|
36131
|
+
messageId: request.omni?.messageId,
|
|
36132
|
+
omni: request.omni
|
|
36133
|
+
})
|
|
36134
|
+
},
|
|
36027
36135
|
body: formData
|
|
36028
36136
|
}, timeoutMs);
|
|
36029
36137
|
if (!response.ok) {
|
|
@@ -36057,7 +36165,15 @@ class AgnoClient {
|
|
|
36057
36165
|
const timeoutMs = request.timeoutMs ?? this.defaultTimeoutMs;
|
|
36058
36166
|
const response = await this.fetchWithTimeout(url, {
|
|
36059
36167
|
method: "POST",
|
|
36060
|
-
headers:
|
|
36168
|
+
headers: {
|
|
36169
|
+
...this.getHeaders(),
|
|
36170
|
+
...buildTraceHeaders2(request.traceContext, {
|
|
36171
|
+
khalSessionId: request.khalSessionId ?? request.sessionId,
|
|
36172
|
+
userId: request.userId,
|
|
36173
|
+
messageId: request.omni?.messageId,
|
|
36174
|
+
omni: request.omni
|
|
36175
|
+
})
|
|
36176
|
+
},
|
|
36061
36177
|
body: formData
|
|
36062
36178
|
}, timeoutMs);
|
|
36063
36179
|
if (!response.ok) {
|
|
@@ -36197,6 +36313,7 @@ function createAgnoClient(config2) {
|
|
|
36197
36313
|
}
|
|
36198
36314
|
var DEFAULT_TIMEOUT_MS = 60000;
|
|
36199
36315
|
var init_agno_client = __esm(() => {
|
|
36316
|
+
init_trace_context();
|
|
36200
36317
|
init_types6();
|
|
36201
36318
|
});
|
|
36202
36319
|
|
|
@@ -60251,12 +60368,7 @@ class AgnoAgentProvider {
|
|
|
60251
60368
|
}
|
|
60252
60369
|
async trigger(context) {
|
|
60253
60370
|
const startTime = Date.now();
|
|
60254
|
-
|
|
60255
|
-
if (context.content.text) {
|
|
60256
|
-
message2 = context.content.text;
|
|
60257
|
-
} else if (context.content.emoji) {
|
|
60258
|
-
message2 = `[Reaction: ${context.content.emoji} on message ${context.content.referencedMessageId ?? context.source.messageId}]`;
|
|
60259
|
-
}
|
|
60371
|
+
const message2 = this.buildMessage(context);
|
|
60260
60372
|
if (!message2) {
|
|
60261
60373
|
log8.debug("No content to send to agent", { traceId: context.traceId });
|
|
60262
60374
|
return {
|
|
@@ -60268,17 +60380,7 @@ class AgnoAgentProvider {
|
|
|
60268
60380
|
}
|
|
60269
60381
|
};
|
|
60270
60382
|
}
|
|
60271
|
-
|
|
60272
|
-
message2 = `[${context.sender.displayName}]: ${message2}`;
|
|
60273
|
-
}
|
|
60274
|
-
const request = {
|
|
60275
|
-
...buildProviderRequestContext(context),
|
|
60276
|
-
message: message2,
|
|
60277
|
-
agentId: this.config.agentId,
|
|
60278
|
-
agentType: this.config.agentType,
|
|
60279
|
-
stream: false,
|
|
60280
|
-
timeoutMs: this.config.timeoutMs ?? 60000
|
|
60281
|
-
};
|
|
60383
|
+
const request = this.buildRequest(context, message2, false);
|
|
60282
60384
|
log8.info("Triggering Agno agent", {
|
|
60283
60385
|
agentId: this.config.agentId,
|
|
60284
60386
|
agentType: this.config.agentType,
|
|
@@ -60310,13 +60412,79 @@ class AgnoAgentProvider {
|
|
|
60310
60412
|
}
|
|
60311
60413
|
};
|
|
60312
60414
|
}
|
|
60415
|
+
async* triggerStream(context) {
|
|
60416
|
+
const message2 = this.buildMessage(context);
|
|
60417
|
+
if (!message2) {
|
|
60418
|
+
log8.debug("No content to send to Agno agent (stream)", { traceId: context.traceId });
|
|
60419
|
+
return;
|
|
60420
|
+
}
|
|
60421
|
+
const request = this.buildRequest(context, message2, true);
|
|
60422
|
+
log8.info("Streaming Agno agent", {
|
|
60423
|
+
agentId: this.config.agentId,
|
|
60424
|
+
agentType: this.config.agentType,
|
|
60425
|
+
triggerType: context.type,
|
|
60426
|
+
traceId: context.traceId
|
|
60427
|
+
});
|
|
60428
|
+
try {
|
|
60429
|
+
for await (const chunk of this.client.stream(request)) {
|
|
60430
|
+
if (chunk.content) {
|
|
60431
|
+
yield { phase: "content", content: chunk.content };
|
|
60432
|
+
}
|
|
60433
|
+
if (chunk.isComplete) {
|
|
60434
|
+
yield { phase: "final", content: chunk.fullContent ?? chunk.content ?? "" };
|
|
60435
|
+
}
|
|
60436
|
+
}
|
|
60437
|
+
} catch (error2) {
|
|
60438
|
+
const message3 = error2 instanceof Error ? error2.message : String(error2);
|
|
60439
|
+
log8.error("Error in Agno agent stream", {
|
|
60440
|
+
agentId: this.config.agentId,
|
|
60441
|
+
traceId: context.traceId,
|
|
60442
|
+
error: message3
|
|
60443
|
+
});
|
|
60444
|
+
yield { phase: "error", error: message3 };
|
|
60445
|
+
}
|
|
60446
|
+
}
|
|
60313
60447
|
async checkHealth() {
|
|
60314
60448
|
return this.client.checkHealth();
|
|
60315
60449
|
}
|
|
60450
|
+
buildMessage(context) {
|
|
60451
|
+
let message2 = "";
|
|
60452
|
+
if (context.content.text) {
|
|
60453
|
+
message2 = context.content.text;
|
|
60454
|
+
} else if (context.content.emoji) {
|
|
60455
|
+
message2 = `[Reaction: ${context.content.emoji} on message ${context.content.referencedMessageId ?? context.source.messageId}]`;
|
|
60456
|
+
}
|
|
60457
|
+
if (message2 && this.config.prefixSenderName !== false && context.sender.displayName) {
|
|
60458
|
+
message2 = `[${context.sender.displayName}]: ${message2}`;
|
|
60459
|
+
}
|
|
60460
|
+
return message2;
|
|
60461
|
+
}
|
|
60462
|
+
buildRequest(context, message2, stream) {
|
|
60463
|
+
const traceContext = context.traceContext ?? createTraceContextFromTraceId(context.traceId, `${context.source.instanceId}:${context.source.chatId}:${context.source.messageId}:agno`);
|
|
60464
|
+
return {
|
|
60465
|
+
...buildProviderRequestContext(context),
|
|
60466
|
+
message: message2,
|
|
60467
|
+
agentId: this.config.agentId,
|
|
60468
|
+
agentType: this.config.agentType,
|
|
60469
|
+
stream,
|
|
60470
|
+
timeoutMs: this.config.timeoutMs ?? 60000,
|
|
60471
|
+
files: context.content.files,
|
|
60472
|
+
traceContext,
|
|
60473
|
+
khalSessionId: context.sessionId,
|
|
60474
|
+
omni: {
|
|
60475
|
+
instanceId: context.source.instanceId,
|
|
60476
|
+
chatId: context.source.chatId,
|
|
60477
|
+
messageId: context.source.messageId,
|
|
60478
|
+
channel: context.source.channelType
|
|
60479
|
+
},
|
|
60480
|
+
...context.source.chatId ? { mcpUrlParams: { chat_id: context.source.chatId } } : {}
|
|
60481
|
+
};
|
|
60482
|
+
}
|
|
60316
60483
|
}
|
|
60317
60484
|
var log8;
|
|
60318
60485
|
var init_agno_provider = __esm(() => {
|
|
60319
60486
|
init_logger();
|
|
60487
|
+
init_trace_context();
|
|
60320
60488
|
log8 = createLogger("provider:agno");
|
|
60321
60489
|
});
|
|
60322
60490
|
|
|
@@ -62523,6 +62691,7 @@ var init_a2a_provider = __esm(() => {
|
|
|
62523
62691
|
});
|
|
62524
62692
|
|
|
62525
62693
|
// ../core/src/providers/nats-genie-provider.ts
|
|
62694
|
+
import { createHash as createHash5 } from "crypto";
|
|
62526
62695
|
import { mkdir, writeFile } from "fs/promises";
|
|
62527
62696
|
import { homedir as homedir10 } from "os";
|
|
62528
62697
|
import { join as join16 } from "path";
|
|
@@ -62556,6 +62725,8 @@ class NatsGenieProvider {
|
|
|
62556
62725
|
};
|
|
62557
62726
|
}
|
|
62558
62727
|
const topic = `omni.message.${this.config.instanceId}.${context.source.chatId}`;
|
|
62728
|
+
const traceContext = this.resolveTraceContext(context);
|
|
62729
|
+
const propagationHeaders = this.buildPropagationHeaders(context, traceContext);
|
|
62559
62730
|
const payload = {
|
|
62560
62731
|
content: message2,
|
|
62561
62732
|
sender: context.sender.displayName ?? context.sender.platformUserId,
|
|
@@ -62565,22 +62736,28 @@ class NatsGenieProvider {
|
|
|
62565
62736
|
timestamp: new Date().toISOString(),
|
|
62566
62737
|
traceId: context.traceId,
|
|
62567
62738
|
messageId: context.source.messageId,
|
|
62739
|
+
contextMessages: context.contextMessages,
|
|
62568
62740
|
files: context.content.files,
|
|
62741
|
+
traceContext,
|
|
62742
|
+
metadata: this.buildSafePayloadMetadata(propagationHeaders),
|
|
62569
62743
|
env: buildOmniEnv(context),
|
|
62570
62744
|
executionContext: buildOmniExecutionContext(context)
|
|
62571
62745
|
};
|
|
62572
62746
|
try {
|
|
62573
62747
|
await this.ensureConnected();
|
|
62574
|
-
this.nc?.publish(topic, this.sc.encode(JSON.stringify(payload)));
|
|
62748
|
+
this.nc?.publish(topic, this.sc.encode(JSON.stringify(payload)), this.buildPublishOptions(propagationHeaders));
|
|
62575
62749
|
log17.info("Published to NATS", {
|
|
62576
|
-
|
|
62750
|
+
subject: "omni.message.<instance>.<chat_hash>",
|
|
62577
62751
|
agent: this.config.agentName,
|
|
62578
|
-
|
|
62752
|
+
instanceId: this.config.instanceId,
|
|
62753
|
+
chatHash: this.safeHash(context.source.chatId),
|
|
62579
62754
|
traceId: context.traceId
|
|
62580
62755
|
});
|
|
62581
62756
|
} catch (error2) {
|
|
62582
62757
|
log17.error("Failed to publish to NATS, writing to dead-letter queue", {
|
|
62583
|
-
|
|
62758
|
+
subject: "omni.message.<instance>.<chat_hash>",
|
|
62759
|
+
instanceId: this.config.instanceId,
|
|
62760
|
+
chatHash: this.safeHash(context.source.chatId),
|
|
62584
62761
|
error: error2 instanceof Error ? error2.message : String(error2),
|
|
62585
62762
|
traceId: context.traceId
|
|
62586
62763
|
});
|
|
@@ -62623,7 +62800,8 @@ class NatsGenieProvider {
|
|
|
62623
62800
|
}
|
|
62624
62801
|
} catch (error2) {
|
|
62625
62802
|
log17.error("Error processing reply", {
|
|
62626
|
-
subject:
|
|
62803
|
+
subject: "omni.reply.<instance>.<chat_hash>",
|
|
62804
|
+
subjectHash: this.safeHash(msg.subject),
|
|
62627
62805
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
62628
62806
|
});
|
|
62629
62807
|
}
|
|
@@ -62648,7 +62826,7 @@ class NatsGenieProvider {
|
|
|
62648
62826
|
if (!chatId) {
|
|
62649
62827
|
log17.warn("NATS session reset skipped: missing chatId", {
|
|
62650
62828
|
providerId: this.id,
|
|
62651
|
-
sessionKey
|
|
62829
|
+
sessionKeyHash: this.safeHash(sessionKey)
|
|
62652
62830
|
});
|
|
62653
62831
|
throw new Error("chatId is required to reset NATS Genie session");
|
|
62654
62832
|
}
|
|
@@ -62665,14 +62843,17 @@ class NatsGenieProvider {
|
|
|
62665
62843
|
await this.ensureConnected();
|
|
62666
62844
|
this.nc?.publish(topic, this.sc.encode(JSON.stringify(payload)));
|
|
62667
62845
|
log17.info("Published session reset to NATS", {
|
|
62668
|
-
|
|
62846
|
+
subject: "omni.session.reset.<instance>.<chat_hash>",
|
|
62669
62847
|
providerId: this.id,
|
|
62670
|
-
|
|
62671
|
-
|
|
62848
|
+
instanceId: resolvedInstanceId,
|
|
62849
|
+
sessionKeyHash: this.safeHash(sessionKey),
|
|
62850
|
+
chatHash: this.safeHash(chatId)
|
|
62672
62851
|
});
|
|
62673
62852
|
} catch (error2) {
|
|
62674
62853
|
log17.error("Failed to publish NATS session reset", {
|
|
62675
|
-
|
|
62854
|
+
subject: "omni.session.reset.<instance>.<chat_hash>",
|
|
62855
|
+
instanceId: resolvedInstanceId,
|
|
62856
|
+
chatHash: this.safeHash(chatId),
|
|
62676
62857
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
62677
62858
|
});
|
|
62678
62859
|
throw error2;
|
|
@@ -62702,6 +62883,48 @@ class NatsGenieProvider {
|
|
|
62702
62883
|
});
|
|
62703
62884
|
log17.info("Connected to NATS", { url: this.config.natsUrl });
|
|
62704
62885
|
}
|
|
62886
|
+
resolveTraceContext(context) {
|
|
62887
|
+
return context.traceContext ?? createTraceContextFromTraceId(context.traceId, `${context.source.instanceId}:${context.source.chatId}:${context.source.messageId}:nats-genie`);
|
|
62888
|
+
}
|
|
62889
|
+
buildPropagationHeaders(context, traceContext) {
|
|
62890
|
+
return buildTraceHeaders2(traceContext, {
|
|
62891
|
+
khalSessionId: context.sessionId,
|
|
62892
|
+
userId: context.sender.personId ?? context.sender.platformUserId,
|
|
62893
|
+
messageId: context.source.messageId,
|
|
62894
|
+
omni: {
|
|
62895
|
+
instanceId: context.source.instanceId,
|
|
62896
|
+
chatId: context.source.chatId,
|
|
62897
|
+
channel: context.source.channelType
|
|
62898
|
+
}
|
|
62899
|
+
});
|
|
62900
|
+
}
|
|
62901
|
+
buildPublishOptions(traceHeaders) {
|
|
62902
|
+
if (Object.keys(traceHeaders).length === 0)
|
|
62903
|
+
return;
|
|
62904
|
+
const natsHeaders2 = import_nats2.headers();
|
|
62905
|
+
for (const [key, value] of Object.entries(traceHeaders)) {
|
|
62906
|
+
natsHeaders2.set(key, value);
|
|
62907
|
+
}
|
|
62908
|
+
return { headers: natsHeaders2 };
|
|
62909
|
+
}
|
|
62910
|
+
buildSafePayloadMetadata(traceHeaders) {
|
|
62911
|
+
const metadata = {};
|
|
62912
|
+
for (const [key, value] of Object.entries(traceHeaders)) {
|
|
62913
|
+
if (key === "x-khal-user-id") {
|
|
62914
|
+
metadata["x-khal-user-hash"] = this.safeHash(value);
|
|
62915
|
+
continue;
|
|
62916
|
+
}
|
|
62917
|
+
if (key === "x-omni-chat-id") {
|
|
62918
|
+
metadata["x-omni-chat-hash"] = this.safeHash(value);
|
|
62919
|
+
continue;
|
|
62920
|
+
}
|
|
62921
|
+
metadata[key] = value;
|
|
62922
|
+
}
|
|
62923
|
+
return metadata;
|
|
62924
|
+
}
|
|
62925
|
+
safeHash(value) {
|
|
62926
|
+
return createHash5("sha256").update(value).digest("hex").slice(0, 12);
|
|
62927
|
+
}
|
|
62705
62928
|
buildMessage(context) {
|
|
62706
62929
|
let message2 = "";
|
|
62707
62930
|
if (context.content.text) {
|
|
@@ -62735,6 +62958,7 @@ class NatsGenieProvider {
|
|
|
62735
62958
|
var import_nats2, log17;
|
|
62736
62959
|
var init_nats_genie_provider = __esm(() => {
|
|
62737
62960
|
init_logger();
|
|
62961
|
+
init_trace_context();
|
|
62738
62962
|
import_nats2 = __toESM(require_mod4(), 1);
|
|
62739
62963
|
log17 = createLogger("provider:nats-genie");
|
|
62740
62964
|
});
|
|
@@ -124293,7 +124517,10 @@ function createOmniClient(config) {
|
|
|
124293
124517
|
provider: body.provider,
|
|
124294
124518
|
language: body.language,
|
|
124295
124519
|
timestamps: body.timestamps,
|
|
124296
|
-
model: body.model
|
|
124520
|
+
model: body.model,
|
|
124521
|
+
prompt: body.prompt,
|
|
124522
|
+
context: body.context,
|
|
124523
|
+
glossary: body.glossary
|
|
124297
124524
|
})
|
|
124298
124525
|
});
|
|
124299
124526
|
const json = await resp.json();
|
|
@@ -124723,7 +124950,7 @@ import { fileURLToPath } from "url";
|
|
|
124723
124950
|
// package.json
|
|
124724
124951
|
var package_default = {
|
|
124725
124952
|
name: "@automagik/omni",
|
|
124726
|
-
version: "2.
|
|
124953
|
+
version: "2.260530.1",
|
|
124727
124954
|
description: "LLM-optimized CLI for Omni",
|
|
124728
124955
|
type: "module",
|
|
124729
124956
|
bin: {
|
|
@@ -133456,7 +133683,7 @@ function guessAudioMimeType(filePath) {
|
|
|
133456
133683
|
}
|
|
133457
133684
|
}
|
|
133458
133685
|
function createListenCommand() {
|
|
133459
|
-
return new Command("listen").description("Transcribe an audio file to text and print (or send as reply)").argument("<file>", "Path to the audio file to transcribe").option("--provider <name>", "STT provider (gemini, groq). Default: server config.").option("--language <code>", "BCP-47 language hint (e.g. en, pt-BR)").option("--timestamps", "Include per-segment timestamps").option("--format <fmt>", `Output format: ${ALLOWED_FORMATS.join(", ")} (default: text)`).option("--model <name>", "Model override (provider-specific)").option("--reply [message-id]", "Send transcript as a quote-reply to the trigger or a specific message").option("--instance <id>", "Override instance (default: from context, only with --reply)").option("--chat <id>", "Override chat (default: from context, only with --reply)").action(async (file, options) => {
|
|
133686
|
+
return new Command("listen").description("Transcribe an audio file to text and print (or send as reply)").argument("<file>", "Path to the audio file to transcribe").option("--provider <name>", "STT provider (openai, gemini, groq). Default: server config.").option("--language <code>", "BCP-47 language hint (e.g. en, pt-BR)").option("--timestamps", "Include per-segment timestamps").option("--format <fmt>", `Output format: ${ALLOWED_FORMATS.join(", ")} (default: text)`).option("--model <name>", "Model override (provider-specific)").option("--prompt <text>", "Provider transcription prompt/instructions").option("--context <text>", "Domain context for acoustic disambiguation").option("--glossary <terms>", "Comma-separated likely names/acronyms/products").option("--reply [message-id]", "Send transcript as a quote-reply to the trigger or a specific message").option("--instance <id>", "Override instance (default: from context, only with --reply)").option("--chat <id>", "Override chat (default: from context, only with --reply)").action(async (file, options) => {
|
|
133460
133687
|
const client = getClient();
|
|
133461
133688
|
const format = parseFormat(options.format);
|
|
133462
133689
|
const wantTimestamps = options.timestamps === true;
|
|
@@ -133471,6 +133698,7 @@ function createListenCommand() {
|
|
|
133471
133698
|
return error(`File is empty: ${file}`);
|
|
133472
133699
|
}
|
|
133473
133700
|
const mimeType = guessAudioMimeType(file);
|
|
133701
|
+
const glossary = options.glossary ? options.glossary.split(",").map((term) => term.trim()).filter(Boolean) : undefined;
|
|
133474
133702
|
let result;
|
|
133475
133703
|
try {
|
|
133476
133704
|
result = await client.media.stt({
|
|
@@ -133479,7 +133707,10 @@ function createListenCommand() {
|
|
|
133479
133707
|
provider: options.provider,
|
|
133480
133708
|
language: options.language,
|
|
133481
133709
|
timestamps: wantTimestamps,
|
|
133482
|
-
model: options.model
|
|
133710
|
+
model: options.model,
|
|
133711
|
+
prompt: options.prompt,
|
|
133712
|
+
context: options.context,
|
|
133713
|
+
glossary
|
|
133483
133714
|
});
|
|
133484
133715
|
} catch (err2) {
|
|
133485
133716
|
const message2 = err2 instanceof Error ? err2.message : "Unknown error";
|
package/dist/sdk/client.d.ts
CHANGED
|
@@ -1901,6 +1901,9 @@ export declare function createOmniClient(config: OmniClientConfig): {
|
|
|
1901
1901
|
language?: string;
|
|
1902
1902
|
timestamps?: boolean;
|
|
1903
1903
|
model?: string;
|
|
1904
|
+
prompt?: string;
|
|
1905
|
+
context?: string;
|
|
1906
|
+
glossary?: string[];
|
|
1904
1907
|
}): Promise<{
|
|
1905
1908
|
provider: string;
|
|
1906
1909
|
text: string;
|