@voicethere/agent 0.35.3 → 0.36.0

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.
Files changed (45) hide show
  1. package/README.md +18 -14
  2. package/dist/agent.js +1 -39
  3. package/dist/build-bundle.d.ts.map +1 -1
  4. package/dist/build-bundle.js.map +1 -1
  5. package/dist/cli.js +2 -2
  6. package/dist/cli.js.map +1 -1
  7. package/dist/host/session-speak-controller.d.ts.map +1 -1
  8. package/dist/host/session-speak-controller.js +1 -0
  9. package/dist/host/session-speak-controller.js.map +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/llm/openai-provider.d.ts +7 -1
  15. package/dist/llm/openai-provider.d.ts.map +1 -1
  16. package/dist/llm/openai-provider.js +43 -37
  17. package/dist/llm/openai-provider.js.map +1 -1
  18. package/dist/protocol.d.ts +11 -5
  19. package/dist/protocol.d.ts.map +1 -1
  20. package/dist/protocol.js.map +1 -1
  21. package/dist/runner-forwarded-events.d.ts +7 -0
  22. package/dist/runner-forwarded-events.d.ts.map +1 -0
  23. package/dist/runner-forwarded-events.js +19 -0
  24. package/dist/runner-forwarded-events.js.map +1 -0
  25. package/dist/runtime.d.ts +9 -4
  26. package/dist/runtime.d.ts.map +1 -1
  27. package/dist/runtime.js.map +1 -1
  28. package/dist/templates/flow-agent/agent.js +29 -25
  29. package/dist/templates/llm-agent/agent.js +29 -25
  30. package/dist/templates/llm-board/agent.js +29 -25
  31. package/dist/templates/llm-docs-rag/agent.js +29 -25
  32. package/dist/templates/llm-language-switch/agent.js +29 -25
  33. package/dist/templates/llm-language-tutor/agent.js +30 -26
  34. package/dist/templates/llm-mcp-service/agent.js +29 -25
  35. package/dist/templates/llm-store-support/agent.js +30 -26
  36. package/dist/templates/llm-support-sticky-user/agent.js +29 -25
  37. package/dist/templates/voice-starter/agent.js +2 -52
  38. package/dist/verify/run-verify-start.d.ts.map +1 -1
  39. package/dist/verify/run-verify-start.js +1 -2
  40. package/dist/verify/run-verify-start.js.map +1 -1
  41. package/eject/llm/loop.ts +1 -1
  42. package/package.json +1 -1
  43. package/templates/llm-language-tutor/prompt.md +1 -1
  44. package/templates/llm-store-support/prompt.md +1 -1
  45. package/templates/voice-starter/agent.ts +6 -67
@@ -49240,6 +49240,34 @@ function parseArgs(raw) {
49240
49240
  return { _raw: raw };
49241
49241
  }
49242
49242
  }
49243
+ function buildChatCompletionParams(req, providerId) {
49244
+ const tools2 = req.tools.map((t) => ({
49245
+ type: "function",
49246
+ function: {
49247
+ name: t.name,
49248
+ description: t.description,
49249
+ parameters: t.inputSchema
49250
+ }
49251
+ }));
49252
+ const params = {
49253
+ ...req.vendorConfig ?? {},
49254
+ model: req.model,
49255
+ messages: toMessages(req.system, req.messages),
49256
+ stream: true,
49257
+ stream_options: { include_usage: true },
49258
+ ...tools2.length > 0 ? { tools: tools2 } : {},
49259
+ ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
49260
+ ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
49261
+ tool_choice: {
49262
+ type: "function",
49263
+ function: { name: req.toolChoice.name }
49264
+ }
49265
+ } : {},
49266
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
49267
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
49268
+ };
49269
+ return params;
49270
+ }
49243
49271
  function createOpenAiCompatibleProvider(config2) {
49244
49272
  const client = new OpenAI({
49245
49273
  apiKey: config2.apiKey,
@@ -49249,31 +49277,7 @@ function createOpenAiCompatibleProvider(config2) {
49249
49277
  return {
49250
49278
  id: config2.id,
49251
49279
  async *stream(req) {
49252
- const tools2 = req.tools.map((t) => ({
49253
- type: "function",
49254
- function: {
49255
- name: t.name,
49256
- description: t.description,
49257
- parameters: t.inputSchema
49258
- }
49259
- }));
49260
- const params = {
49261
- ...req.vendorConfig ?? {},
49262
- model: req.model,
49263
- messages: toMessages(req.system, req.messages),
49264
- stream: true,
49265
- stream_options: { include_usage: true },
49266
- ...tools2.length > 0 ? { tools: tools2 } : {},
49267
- ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
49268
- ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
49269
- tool_choice: {
49270
- type: "function",
49271
- function: { name: req.toolChoice.name }
49272
- }
49273
- } : {},
49274
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
49275
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
49276
- };
49280
+ const params = buildChatCompletionParams(req, config2.id);
49277
49281
  const stream = await client.chat.completions.create(params, {
49278
49282
  signal: req.signal
49279
49283
  });
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools2 = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools2.length > 0 ? { tools: tools2 } : {},
60611
+ ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools2 = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools2.length > 0 ? { tools: tools2 } : {},
60619
- ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools.length > 0 ? { tools } : {},
60611
+ ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools.length > 0 ? { tools } : {},
60619
- ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools2 = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools2.length > 0 ? { tools: tools2 } : {},
60611
+ ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools2 = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools2.length > 0 ? { tools: tools2 } : {},
60619
- ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60596,6 +60596,34 @@ function parseArgs(raw) {
60596
60596
  return { _raw: raw };
60597
60597
  }
60598
60598
  }
60599
+ function buildChatCompletionParams(req, providerId) {
60600
+ const tools = req.tools.map((t) => ({
60601
+ type: "function",
60602
+ function: {
60603
+ name: t.name,
60604
+ description: t.description,
60605
+ parameters: t.inputSchema
60606
+ }
60607
+ }));
60608
+ const params = {
60609
+ ...req.vendorConfig ?? {},
60610
+ model: req.model,
60611
+ messages: toMessages(req.system, req.messages),
60612
+ stream: true,
60613
+ stream_options: { include_usage: true },
60614
+ ...tools.length > 0 ? { tools } : {},
60615
+ ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60616
+ ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60617
+ tool_choice: {
60618
+ type: "function",
60619
+ function: { name: req.toolChoice.name }
60620
+ }
60621
+ } : {},
60622
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60623
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60624
+ };
60625
+ return params;
60626
+ }
60599
60627
  function createOpenAiCompatibleProvider(config2) {
60600
60628
  const client = new OpenAI({
60601
60629
  apiKey: config2.apiKey,
@@ -60605,31 +60633,7 @@ function createOpenAiCompatibleProvider(config2) {
60605
60633
  return {
60606
60634
  id: config2.id,
60607
60635
  async *stream(req) {
60608
- const tools = req.tools.map((t) => ({
60609
- type: "function",
60610
- function: {
60611
- name: t.name,
60612
- description: t.description,
60613
- parameters: t.inputSchema
60614
- }
60615
- }));
60616
- const params = {
60617
- ...req.vendorConfig ?? {},
60618
- model: req.model,
60619
- messages: toMessages(req.system, req.messages),
60620
- stream: true,
60621
- stream_options: { include_usage: true },
60622
- ...tools.length > 0 ? { tools } : {},
60623
- ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60624
- ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60625
- tool_choice: {
60626
- type: "function",
60627
- function: { name: req.toolChoice.name }
60628
- }
60629
- } : {},
60630
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60631
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60632
- };
60636
+ const params = buildChatCompletionParams(req, config2.id);
60633
60637
  const stream = await client.chat.completions.create(params, {
60634
60638
  signal: req.signal
60635
60639
  });
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools.length > 0 ? { tools } : {},
60611
+ ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools.length > 0 ? { tools } : {},
60619
- ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60758,7 +60762,7 @@ var voicethere_llm_default = {
60758
60762
  };
60759
60763
 
60760
60764
  // templates/llm-language-tutor/prompt.md
60761
- var prompt_default = "You are an English conversation tutor for learners at levels A2 to B2. People talk to you by voice, so everything you say is read aloud.\n\nSpeak English only, even if the learner switches to another language. Keep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters.\n\nCorrect at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.\n\nWhen the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and offer a different phrase to practice.\n\nBe patient and friendly. Let the learner finish their thought before you correct anything.\n";
60765
+ var prompt_default = "You are an English conversation tutor for learners at levels A2 to B2. People talk to you by voice, so everything you say is read aloud.\n\nSpeak English only, even if the learner switches to another language. Keep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters.\n\nCorrect at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.\n\nWhen the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and suggest one lesson topic to practice instead. Do not explain any phrase or idiom that the search did not return.\n\nBe patient and friendly. Let the learner finish their thought before you correct anything.\n";
60762
60766
 
60763
60767
  // templates/llm-language-tutor/knowledge/lessons.md
60764
60768
  var lessons_default = `# English practice lessons
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools2 = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools2.length > 0 ? { tools: tools2 } : {},
60611
+ ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools2 = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools2.length > 0 ? { tools: tools2 } : {},
60619
- ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools.length > 0 ? { tools } : {},
60611
+ ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools.length > 0 ? { tools } : {},
60619
- ...tools.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });
@@ -60769,7 +60773,7 @@ var voicethere_llm_default = {
60769
60773
  };
60770
60774
 
60771
60775
  // templates/llm-store-support/prompt.md
60772
- var prompt_default = 'You are the phone support assistant for Kestrel Outdoor, an online store for camping and hiking gear. Customers talk to you by voice, so everything you say is read aloud.\n\nKeep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters. Say prices as words, for example "one hundred and twenty-nine dollars".\n\nAnswer questions about shipping, returns, warranty, sizing, store hours, contact details and what the store sells from search_knowledge. Search before you answer such a question: do not give a guess or a filler sentence first. If the search has nothing, say you are not sure and offer to connect the customer with the support team at the address or number in the store information.\n\nFor any price, call get_product_price with the product name or id. If the customer asks what the store sells and you need exact names, call list_products. Never state a price that did not come from get_product_price, never estimate one and never work out a total from memory. If the tool says it does not know the product, say so and offer to look up a similar one.\n\nBe friendly and patient. Ask one question at a time.\n';
60776
+ var prompt_default = 'You are the phone support assistant for Kestrel Outdoor, an online store for camping and hiking gear. Customers talk to you by voice, so everything you say is read aloud.\n\nKeep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters. Say prices as words, for example "one hundred and twenty-nine dollars".\n\nAnswer questions about shipping, returns, warranty, sizing, store hours, contact details and what the store sells from search_knowledge. Search before you answer such a question: do not give a guess or a filler sentence first. If the search has nothing, say you are not sure and offer to connect the customer with the support team at the address or number in the store information.\n\nFor any price, call get_product_price with the product name or id. Say exactly the priceUsd that get_product_price returned, in words, and no other amount. If the customer asks what the store sells and you need exact names, call list_products. Never state a price that did not come from get_product_price, never estimate one and never work out a total from memory. If the tool says it does not know the product, say so and offer to look up a similar one.\n\nBe friendly and patient. Ask one question at a time.\n';
60773
60777
 
60774
60778
  // templates/llm-store-support/knowledge/shipping.md
60775
60779
  var shipping_default = "# Shipping at Kestrel Outdoor\n\n## Delivery times and carriers\n\nOrders placed before 2 pm on a business day leave our warehouse the same day. Standard shipping takes three to five business days within the continental United States. Express shipping takes one to two business days. Orders to Alaska, Hawaii and US territories take up to ten business days.\n\n## Shipping costs\n\nLarger orders ship standard for free. The free-shipping threshold and the flat rates for smaller orders and for express are shown at checkout.\n\n## Tracking and delivery problems\n\nEvery order gets a tracking link by email when it ships. If a package shows as delivered but did not arrive, wait one business day and check with neighbors, then contact support. We open a carrier claim and send a replacement once the claim is filed.\n\n## International orders\n\nWe ship to Canada. Duties and import taxes are charged by the carrier on delivery. We do not ship to other countries yet.\n";
@@ -60592,6 +60592,34 @@ function parseArgs(raw) {
60592
60592
  return { _raw: raw };
60593
60593
  }
60594
60594
  }
60595
+ function buildChatCompletionParams(req, providerId) {
60596
+ const tools2 = req.tools.map((t) => ({
60597
+ type: "function",
60598
+ function: {
60599
+ name: t.name,
60600
+ description: t.description,
60601
+ parameters: t.inputSchema
60602
+ }
60603
+ }));
60604
+ const params = {
60605
+ ...req.vendorConfig ?? {},
60606
+ model: req.model,
60607
+ messages: toMessages(req.system, req.messages),
60608
+ stream: true,
60609
+ stream_options: { include_usage: true },
60610
+ ...tools2.length > 0 ? { tools: tools2 } : {},
60611
+ ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60612
+ ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60613
+ tool_choice: {
60614
+ type: "function",
60615
+ function: { name: req.toolChoice.name }
60616
+ }
60617
+ } : {},
60618
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60619
+ ...req.maxOutputTokens !== void 0 ? providerId === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60620
+ };
60621
+ return params;
60622
+ }
60595
60623
  function createOpenAiCompatibleProvider(config2) {
60596
60624
  const client = new OpenAI({
60597
60625
  apiKey: config2.apiKey,
@@ -60601,31 +60629,7 @@ function createOpenAiCompatibleProvider(config2) {
60601
60629
  return {
60602
60630
  id: config2.id,
60603
60631
  async *stream(req) {
60604
- const tools2 = req.tools.map((t) => ({
60605
- type: "function",
60606
- function: {
60607
- name: t.name,
60608
- description: t.description,
60609
- parameters: t.inputSchema
60610
- }
60611
- }));
60612
- const params = {
60613
- ...req.vendorConfig ?? {},
60614
- model: req.model,
60615
- messages: toMessages(req.system, req.messages),
60616
- stream: true,
60617
- stream_options: { include_usage: true },
60618
- ...tools2.length > 0 ? { tools: tools2 } : {},
60619
- ...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
60620
- ...tools2.length > 0 && typeof req.toolChoice === "object" && req.toolChoice !== null ? {
60621
- tool_choice: {
60622
- type: "function",
60623
- function: { name: req.toolChoice.name }
60624
- }
60625
- } : {},
60626
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
60627
- ...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
60628
- };
60632
+ const params = buildChatCompletionParams(req, config2.id);
60629
60633
  const stream = await client.chat.completions.create(params, {
60630
60634
  signal: req.signal
60631
60635
  });