@securecoms/agent-runtime 0.9.3 → 0.9.5
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/bin.js +23 -3
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -3593,6 +3593,12 @@ function parseTurnAuthorization(value) {
|
|
|
3593
3593
|
tool_grants: Object.freeze(grants)
|
|
3594
3594
|
});
|
|
3595
3595
|
}
|
|
3596
|
+
var VOICE_GUIDANCE_MAX_CHARS = 1e3;
|
|
3597
|
+
function parseVoiceGuidance(frame) {
|
|
3598
|
+
if (frame.voice !== true || typeof frame.guidance !== "string") return void 0;
|
|
3599
|
+
const g = frame.guidance.trim().slice(0, VOICE_GUIDANCE_MAX_CHARS);
|
|
3600
|
+
return g || void 0;
|
|
3601
|
+
}
|
|
3596
3602
|
var SEEN_MAX = 5e3;
|
|
3597
3603
|
var PENDING_REPLY_MAX = 1e3;
|
|
3598
3604
|
var TERMINAL_REPLY_ERRORS = /* @__PURE__ */ new Set(["agent_paused", "send_forbidden"]);
|
|
@@ -3980,6 +3986,7 @@ var SecureComsDataPlane = class {
|
|
|
3980
3986
|
this.status.set({ httpBase, token }, channelId, "working");
|
|
3981
3987
|
}
|
|
3982
3988
|
const handlerStart = this.clock();
|
|
3989
|
+
const voiceGuidance = parseVoiceGuidance(frame);
|
|
3983
3990
|
const reply = await this.onMessage({
|
|
3984
3991
|
text,
|
|
3985
3992
|
senderId: String(frame.sender_id ?? ""),
|
|
@@ -3987,7 +3994,8 @@ var SecureComsDataPlane = class {
|
|
|
3987
3994
|
messageId,
|
|
3988
3995
|
authorization: parseTurnAuthorization(frame.authorization),
|
|
3989
3996
|
memory: parseTurnMemory(frame.memory),
|
|
3990
|
-
seq: arrival.seq
|
|
3997
|
+
seq: arrival.seq,
|
|
3998
|
+
...voiceGuidance ? { voiceGuidance } : {}
|
|
3991
3999
|
}, turnController.signal);
|
|
3992
4000
|
handlerMs = this.elapsed(handlerStart);
|
|
3993
4001
|
if (reply != null) {
|
|
@@ -4087,6 +4095,7 @@ async function runToolCalls(toolCalls, skills, context) {
|
|
|
4087
4095
|
}
|
|
4088
4096
|
|
|
4089
4097
|
// src/turn-loop.ts
|
|
4098
|
+
var VOICE_TURN_PREFIX = "This message was spoken on a live voice call and your reply will be read aloud: plain spoken sentences, no markdown, lists, links or code. Use your tools as usual when the question needs them. ";
|
|
4090
4099
|
var DEFAULT_SYSTEM_PROMPT = "You are a SecureComs agent working inside a private, end-to-end encrypted messaging enclave for one business; the people you talk to are its staff, partners and customers. Answer questions in the chat, and keep replies to the length the question needs.";
|
|
4091
4100
|
var DEFAULT_MAX_ITERATIONS = 5;
|
|
4092
4101
|
var DEFAULT_MAX_CONCURRENT_TURNS = 4;
|
|
@@ -4508,7 +4517,12 @@ function buildHandler(deps) {
|
|
|
4508
4517
|
const memory = memoryFor(m.channelId);
|
|
4509
4518
|
memory.replace(m.memory);
|
|
4510
4519
|
const promptStart = clock();
|
|
4511
|
-
const system = {
|
|
4520
|
+
const system = {
|
|
4521
|
+
role: "system",
|
|
4522
|
+
content: m.voiceGuidance ? `${deps.systemPromptFor()}
|
|
4523
|
+
|
|
4524
|
+
${VOICE_TURN_PREFIX}${m.voiceGuidance}` : deps.systemPromptFor()
|
|
4525
|
+
};
|
|
4512
4526
|
const recallStart = clock();
|
|
4513
4527
|
const recalledText = await memory.recall(text);
|
|
4514
4528
|
live();
|
|
@@ -4517,7 +4531,8 @@ ${recalledText}` } : null;
|
|
|
4517
4531
|
const history = memory.getHistory();
|
|
4518
4532
|
const user = { role: "user", content: text };
|
|
4519
4533
|
const toolsStart = clock();
|
|
4520
|
-
const
|
|
4534
|
+
const eligibleTools = deps.tools();
|
|
4535
|
+
const tools = eligibleTools.filter((tool) => toolIsOffered(m.authorization, tool.function.name));
|
|
4521
4536
|
const offeredNames = new Set(tools.map((tool) => tool.function.name));
|
|
4522
4537
|
const toolsBytes = tools.length > 0 ? jsonBytes(tools) + 1 : 0;
|
|
4523
4538
|
const budgetBytes = requestMaxBytes - REQUEST_ENVELOPE_RESERVE_BYTES - toolsBytes;
|
|
@@ -4607,6 +4622,11 @@ ${recalledText}` } : null;
|
|
|
4607
4622
|
history_dropped: historyStart,
|
|
4608
4623
|
recalled: keepRecalled,
|
|
4609
4624
|
tools_offered: tools.length,
|
|
4625
|
+
// Counts only: the tools this runtime loaded, and the grants the bridge
|
|
4626
|
+
// sent. tools_offered=0 with grants=0 points at the bridge decision;
|
|
4627
|
+
// with grants>0 it points at the runtime intersection.
|
|
4628
|
+
tools_eligible: eligibleTools.length,
|
|
4629
|
+
grants: m.authorization.tool_grants.length,
|
|
4610
4630
|
prompt_bytes: promptBytes()
|
|
4611
4631
|
});
|
|
4612
4632
|
let toolResultBytes = 0;
|