@fonoster/autopilot 0.63.0 → 0.64.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/session/Agent.d.ts +12 -0
- package/dist/session/Agent.js +27 -3
- package/package.json +7 -7
package/dist/session/Agent.d.ts
CHANGED
|
@@ -176,6 +176,18 @@ export declare class Agent {
|
|
|
176
176
|
*/
|
|
177
177
|
private transferFailed;
|
|
178
178
|
private messages;
|
|
179
|
+
/**
|
|
180
|
+
* The agent's system prompt with the call's metadata (from `Calls.createCall`) appended as
|
|
181
|
+
* the 0.23 `[Additional Parameters (metadata)]` block. It stays in the first system message so
|
|
182
|
+
* the prompt prefix is the same on every request of the call (#1435).
|
|
183
|
+
*/
|
|
184
|
+
private systemPrompt;
|
|
185
|
+
/**
|
|
186
|
+
* The call's `metadata.firstMessage` replaces the agent's greeting, except in a session started
|
|
187
|
+
* by a handoff: every session on a call gets the call's metadata, and replaying the opening
|
|
188
|
+
* greeting partway through the call would be wrong (#1435).
|
|
189
|
+
*/
|
|
190
|
+
private firstMessage;
|
|
179
191
|
/** Knowledge for this turn, as a system message for the request only (never in history). */
|
|
180
192
|
private contextFor;
|
|
181
193
|
private toolSpecs;
|
package/dist/session/Agent.js
CHANGED
|
@@ -110,8 +110,9 @@ class Agent {
|
|
|
110
110
|
});
|
|
111
111
|
if (this.settings.initialDtmf)
|
|
112
112
|
await this.session.playDtmf(this.settings.initialDtmf);
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
const firstMessage = this.firstMessage();
|
|
114
|
+
if (firstMessage) {
|
|
115
|
+
const r = await this.session.say(firstMessage, this.speechOptions());
|
|
115
116
|
this.history.push({ role: "assistant", content: r.heardText });
|
|
116
117
|
}
|
|
117
118
|
this.send({ type: "SPOKEN", source: "greeting" });
|
|
@@ -484,11 +485,34 @@ class Agent {
|
|
|
484
485
|
// ---- internals --------------------------------------------------------------------
|
|
485
486
|
messages(context = []) {
|
|
486
487
|
return [
|
|
487
|
-
{ role: "system", content: this.
|
|
488
|
+
{ role: "system", content: this.systemPrompt() },
|
|
488
489
|
...context,
|
|
489
490
|
...this.history
|
|
490
491
|
];
|
|
491
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* The agent's system prompt with the call's metadata (from `Calls.createCall`) appended as
|
|
495
|
+
* the 0.23 `[Additional Parameters (metadata)]` block. It stays in the first system message so
|
|
496
|
+
* the prompt prefix is the same on every request of the call (#1435).
|
|
497
|
+
*/
|
|
498
|
+
systemPrompt() {
|
|
499
|
+
const lines = Object.entries(this.session.metadata ?? {}).map(([key, value]) => `- ${key}: ${typeof value === "string" ? value : JSON.stringify(value)}`);
|
|
500
|
+
return lines.length
|
|
501
|
+
? `${this.settings.systemPrompt}\n\n[Additional Parameters (metadata)]\n${lines.join("\n")}`
|
|
502
|
+
: this.settings.systemPrompt;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The call's `metadata.firstMessage` replaces the agent's greeting, except in a session started
|
|
506
|
+
* by a handoff: every session on a call gets the call's metadata, and replaying the opening
|
|
507
|
+
* greeting partway through the call would be wrong (#1435).
|
|
508
|
+
*/
|
|
509
|
+
firstMessage() {
|
|
510
|
+
const fromCall = this.session.metadata?.firstMessage;
|
|
511
|
+
const handedOff = (this.session.handoffPayload ?? null) !== null;
|
|
512
|
+
return !handedOff && typeof fromCall === "string" && fromCall
|
|
513
|
+
? fromCall
|
|
514
|
+
: this.settings.firstMessage;
|
|
515
|
+
}
|
|
492
516
|
/** Knowledge for this turn, as a system message for the request only (never in history). */
|
|
493
517
|
async contextFor(question, signal, searches) {
|
|
494
518
|
const knowledge = this.knowledge;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/autopilot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.1",
|
|
4
4
|
"description": "Voice AI for the Fonoster platform",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@aws-sdk/client-s3": "^3.958.0",
|
|
35
|
-
"@fonoster/common": "^0.
|
|
36
|
-
"@fonoster/community": "^0.
|
|
37
|
-
"@fonoster/logger": "^0.
|
|
38
|
-
"@fonoster/types": "^0.
|
|
39
|
-
"@fonoster/voice": "^0.
|
|
35
|
+
"@fonoster/common": "^0.64.0",
|
|
36
|
+
"@fonoster/community": "^0.64.0",
|
|
37
|
+
"@fonoster/logger": "^0.64.0",
|
|
38
|
+
"@fonoster/types": "^0.64.0",
|
|
39
|
+
"@fonoster/voice": "^0.64.1",
|
|
40
40
|
"@grpc/grpc-js": "~1.14.6",
|
|
41
41
|
"@langchain/anthropic": "^1.3.3",
|
|
42
42
|
"@langchain/community": "^1.1.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"xstate": "^5.17.3",
|
|
55
55
|
"zod": "^4.6.7"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "2456f75938793d6e27ae8e5652ebb7ab9b5ec3c9",
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"yaml": "^2.9.0"
|
|
60
60
|
}
|