@signalwire/sdk 3.7.2 → 3.10.3

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 (67) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/README.md +1 -0
  3. package/dist/AgentBase.d.ts +107 -2
  4. package/dist/AgentBase.js +259 -13
  5. package/dist/AgentBase.js.map +1 -1
  6. package/dist/AiEvents.d.ts +70 -0
  7. package/dist/AiEvents.js +94 -0
  8. package/dist/AiEvents.js.map +1 -0
  9. package/dist/ContextBuilder.d.ts +215 -14
  10. package/dist/ContextBuilder.js +441 -14
  11. package/dist/ContextBuilder.js.map +1 -1
  12. package/dist/FunctionResult.d.ts +146 -1
  13. package/dist/FunctionResult.js +188 -2
  14. package/dist/FunctionResult.js.map +1 -1
  15. package/dist/PostPrompt.d.ts +19 -0
  16. package/dist/PostPrompt.js +43 -0
  17. package/dist/PostPrompt.js.map +1 -1
  18. package/dist/SWMLService.d.ts +97 -1
  19. package/dist/SWMLService.js +129 -2
  20. package/dist/SWMLService.js.map +1 -1
  21. package/dist/SemanticGate.d.ts +61 -1
  22. package/dist/SemanticGate.js +108 -15
  23. package/dist/SemanticGate.js.map +1 -1
  24. package/dist/SwaigFunction.d.ts +85 -9
  25. package/dist/SwaigFunction.js +214 -58
  26. package/dist/SwaigFunction.js.map +1 -1
  27. package/dist/ToolMiddleware.d.ts +82 -0
  28. package/dist/ToolMiddleware.js +131 -0
  29. package/dist/ToolMiddleware.js.map +1 -0
  30. package/dist/TypeInference.d.ts +1 -1
  31. package/dist/TypeInference.js.map +1 -1
  32. package/dist/cli/tsdocs/api-index.json +1 -1
  33. package/dist/cli/tsdocs/topics.js +24 -4
  34. package/dist/cli/tsdocs/topics.js.map +1 -1
  35. package/dist/index.d.ts +22 -8
  36. package/dist/index.js +15 -5
  37. package/dist/index.js.map +1 -1
  38. package/dist/llms.txt +1 -0
  39. package/dist/patterns/Proposal.d.ts +148 -0
  40. package/dist/patterns/Proposal.js +214 -0
  41. package/dist/patterns/Proposal.js.map +1 -0
  42. package/dist/patterns/RequestList.d.ts +138 -0
  43. package/dist/patterns/RequestList.js +171 -0
  44. package/dist/patterns/RequestList.js.map +1 -0
  45. package/dist/skills/SkillBase.d.ts +24 -1
  46. package/dist/skills/SkillBase.js +12 -1
  47. package/dist/skills/SkillBase.js.map +1 -1
  48. package/dist/speech/numbers.d.ts +66 -0
  49. package/dist/speech/numbers.js +281 -0
  50. package/dist/speech/numbers.js.map +1 -0
  51. package/dist/speech/spelling.d.ts +71 -0
  52. package/dist/speech/spelling.js +294 -0
  53. package/dist/speech/spelling.js.map +1 -0
  54. package/dist/testing/CallSimulator.d.ts +391 -0
  55. package/dist/testing/CallSimulator.js +966 -0
  56. package/dist/testing/CallSimulator.js.map +1 -0
  57. package/docs/agent-guide.md +2 -2
  58. package/docs/api-reference.md +279 -22
  59. package/docs/architecture.md +8 -4
  60. package/docs/cli-guide.md +2 -0
  61. package/docs/contexts-guide.md +75 -4
  62. package/docs/conversation_patterns.md +257 -0
  63. package/docs/mcp_integration.md +1 -1
  64. package/docs/pgi_agent_guide.md +5 -0
  65. package/docs/programmatically_governed_inference.md +2 -2
  66. package/docs/swaig-reference.md +98 -6
  67. package/package.json +1 -1
@@ -230,17 +230,34 @@ agent.defineTool({
230
230
  - \`gates: [new SemanticGate(...)]\` adds semantic gates: yes/no questions a
231
231
  decision model answers about the call before the platform runs the tool.
232
232
  A platform release without semantic gates runs the tool ungated.
233
+ - What the handler returns is the outcome the model reads. Throw
234
+ \`new ToolRefusal(toolResult, toolPrompt)\` to decline with an outcome you
235
+ know; any other error tells the model the outcome is unknown, not that it
236
+ failed. An object with neither a \`response\` nor an \`action\` reaches
237
+ the model as JSON.
238
+ - \`vouched: true\` runs a tool only when the model says its arguments came
239
+ from the caller; \`needsConversation: true\` sends the conversation with each
240
+ request, for \`callerTurns(rawData)\`.
241
+ - \`addToolMiddleware()\` runs code around every tool call; \`callNext()\`
242
+ returns a promise, so await it.
233
243
  - Answer within a few seconds: the caller hears nothing while a tool runs.
234
244
  SignalWire waits up to 120 seconds for a tool's webhook, and sends the
235
- request again after a timeout, a failed connection or a 5xx, so a slow tool
236
- can run more than once. Start long work without awaiting it, return at once, and
237
- send the result into the call with \`calling.aiMessage()\` on a
238
- \`RestClient\`.
245
+ request again after a timeout, a failed connection or a 5xx. The agent
246
+ answers such a retry with the first attempt's result while it keeps it (in
247
+ this process, for 10 minutes, up to 1,024 results), so the tool doesn't
248
+ run twice, but the caller still waits. With several replicas, a retry can
249
+ reach another one, so make tools that change things safe to run twice. Start long work without awaiting it,
250
+ return at once, and send the result into the call with
251
+ \`calling.aiMessage()\` on a \`RestClient\`.
239
252
  `,
240
253
  docs: [
241
254
  ['docs/swaig-reference.md', 'Every FunctionResult method and action'],
242
255
  ['docs/agent-guide.md', 'Defining tools, typed parameters, secure tools'],
243
256
  ['docs/pgi_agent_guide.md', 'What a tool may decide, and what code must enforce'],
257
+ [
258
+ 'docs/conversation_patterns.md',
259
+ "Confirming a change, the caller's own words, honest outcomes, testing a call flow",
260
+ ],
244
261
  ],
245
262
  examples: [
246
263
  'examples/swaig-features.ts',
@@ -259,6 +276,9 @@ agent.defineTool({
259
276
  'FunctionResult.setPostProcess',
260
277
  'SwaigRequest',
261
278
  'SemanticGate',
279
+ 'ToolRefusal',
280
+ 'Proposal',
281
+ 'CallSimulator',
262
282
  ],
263
283
  related: ['datamap', 'contexts', 'skills', 'security', 'pgi'],
264
284
  };
@@ -1 +1 @@
1
- {"version":3,"file":"topics.js","sourceRoot":"","sources":["../../../src/cli/tsdocs/topics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,MAAM,UAAU,GAAU;IACxB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,yCAAyC;IAChD,OAAO,EAAE,yDAAyD;IAClE,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCP;IACC,IAAI,EAAE;QACJ,CA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,EAAE,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC,8BAA8B,EAAE,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC,wBAAwB,EAAE,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,oCAAoC,EAAE,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAClC,CAAC,2BAA2B,EAAE,CAAC,SAAS,CAAC,CAAC;CAC3C,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,6EAA6E;QAC3E,oGAAoG;IACtG,yEAAyE;QACvE,oDAAoD;IACtD,qEAAqE;QACnE,0DAA0D;IAC5D,8EAA8E;QAC5E,+BAA+B;IACjC,+EAA+E;QAC7E,yDAAyD;IAC3D,oFAAoF;CACrF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -61,20 +61,22 @@
61
61
  * @module @signalwire/sdk
62
62
  */
63
63
  export { AgentBase } from './AgentBase.js';
64
- export type { RoutingCallback } from './AgentBase.js';
64
+ export type { RoutingCallback, AiEventHandler } from './AgentBase.js';
65
65
  export { AgentServer } from './AgentServer.js';
66
66
  export { SWMLService, SecurityConfig } from './SWMLService.js';
67
67
  export type { OnRequestCallback, SWMLServiceOptions } from './SWMLService.js';
68
68
  export { WebService } from './WebService.js';
69
69
  export type { WebServiceOptions } from './WebService.js';
70
70
  export type { HostAppRouter } from './web.js';
71
- export { FunctionResult } from './FunctionResult.js';
71
+ export { FunctionResult, ToolRefusal, toolErrorResult, settleResult, TOOL_ERROR_RESULT, TOOL_ERROR_PROMPT, TOOL_NO_RESULT, } from './FunctionResult.js';
72
72
  /** @deprecated Use {@link FunctionResult} instead. */
73
73
  export { FunctionResult as SwaigFunctionResult } from './FunctionResult.js';
74
74
  export type { PaymentPrompt, PaymentAction, PaymentParameter } from './FunctionResult.js';
75
- export { SwaigFunction } from './SwaigFunction.js';
76
- export { SemanticGate, gateDefinitions, applyGateFields, MAX_GATES, MAX_QUESTION_BYTES, MAX_CRITERIA_BYTES, MAX_ON_FAIL_BYTES, MAX_VISUAL_INPUT, RESERVED_FUNCTION_NAMES, } from './SemanticGate.js';
77
- export type { SemanticGateOptions, FillerPhrases } from './SemanticGate.js';
75
+ export { ResendDedupe, resolve, runChain } from './ToolMiddleware.js';
76
+ export type { ToolMiddleware, CallNext } from './ToolMiddleware.js';
77
+ export { SwaigFunction, VOUCHED_PARAMETER, VOUCHED_DESCRIPTION, VOUCHED_PROMPT, NATIVE_WEBHOOK_URL, } from './SwaigFunction.js';
78
+ export { SemanticGate, gateDefinitions, applyGateFields, MAX_GATES, MAX_QUESTION_BYTES, MAX_CRITERIA_BYTES, MAX_ON_FAIL_BYTES, MAX_VISUAL_INPUT, MAX_GATE_HISTORY, GATE_DIALOGUES, RESERVED_FUNCTION_NAMES, } from './SemanticGate.js';
79
+ export type { SemanticGateOptions, FillerPhrases, GateDialogue } from './SemanticGate.js';
78
80
  export type { SwaigHandler, SwaigFunctionOptions } from './SwaigFunction.js';
79
81
  export { ParameterSchema, paramSchema, RECORD_FORMATS, RECORD_DIRECTIONS, TAP_DIRECTIONS, TAP_CODECS, } from './ParameterSchema.js';
80
82
  export type { ParameterType, ParameterProperty, ParameterSchemaObject, RecordFormat, RecordDirection, TapDirection, TapCodec, } from './ParameterSchema.js';
@@ -89,8 +91,8 @@ import './SwmlVerbMethods.generated.js';
89
91
  export { SWMLVerbHandler, AIVerbHandler, VerbHandlerRegistry } from './SWMLHandler.js';
90
92
  export type { AIVerbBuildOptions } from './SWMLHandler.js';
91
93
  export { PromptManager } from './PromptManager.js';
92
- export { ContextBuilder, Context, Step, GatherInfo, GatherQuestion, createSimpleContext, HISTORY_MODES, } from './ContextBuilder.js';
93
- export type { HistoryMode } from './ContextBuilder.js';
94
+ export { ContextBuilder, Context, Step, GatherInfo, GatherQuestion, createSimpleContext, HISTORY_MODES, expectedAnswer, namedTools, MAX_EXPECTED_DIGITS, } from './ContextBuilder.js';
95
+ export type { HistoryMode, ExpectedAnswer } from './ContextBuilder.js';
94
96
  export { SessionManager } from './SessionManager.js';
95
97
  export type { DebugTokenResult } from './SessionManager.js';
96
98
  export { SslConfig } from './SslConfig.js';
@@ -208,5 +210,17 @@ export declare function registerSkill(skillClass: typeof _SkillBase): void;
208
210
  */
209
211
  export declare function addSkillDirectory(path: string): void;
210
212
  export { userVariables, declaredCapabilities, hasCapability } from './capabilities.js';
211
- export { DIALOGUE_ROLES, NormalizedPostPrompt, dialogueTurns, normalizePostPrompt, parsePostPromptData, stripJsonFence, } from './PostPrompt.js';
213
+ export { DIALOGUE_ROLES, NormalizedPostPrompt, dialogueTurns, callerTurns, normalizePostPrompt, parsePostPromptData, stripJsonFence, } from './PostPrompt.js';
212
214
  export type { DialogueTurn } from './PostPrompt.js';
215
+ export { SpeechLog, SPEECH_DETECT } from './AiEvents.js';
216
+ export type { SpeechFinal, SpeechWord } from './AiEvents.js';
217
+ export { numberWords, sayDigits, sayLastDigits, sayMoney } from './speech/numbers.js';
218
+ export type { SayDigitsOptions } from './speech/numbers.js';
219
+ export { readSpelled, spokenEmail, spellingVariants } from './speech/spelling.js';
220
+ export type { ReadSpelledOptions, SpellingVariantsOptions } from './speech/spelling.js';
221
+ export { Proposal, current, PROPOSAL_KEY } from './patterns/Proposal.js';
222
+ export type { ProposalOptions, ProposeOptions } from './patterns/Proposal.js';
223
+ export { RequestList } from './patterns/RequestList.js';
224
+ export type { NotedRequest, RequestListOptions } from './patterns/RequestList.js';
225
+ export { CallSimulator, SimulatedCall, RequestRecorder, ToolMentionError, } from './testing/CallSimulator.js';
226
+ export type { CallSimulatorOptions, GateCallback, RequestRecorderOptions, ToolStub, } from './testing/CallSimulator.js';
package/dist/index.js CHANGED
@@ -68,11 +68,12 @@ export { SWMLService, SecurityConfig } from './SWMLService.js';
68
68
  // Web Service (static file serving)
69
69
  export { WebService } from './WebService.js';
70
70
  // Tool results & functions
71
- export { FunctionResult } from './FunctionResult.js';
71
+ export { FunctionResult, ToolRefusal, toolErrorResult, settleResult, TOOL_ERROR_RESULT, TOOL_ERROR_PROMPT, TOOL_NO_RESULT, } from './FunctionResult.js';
72
72
  /** @deprecated Use {@link FunctionResult} instead. */
73
73
  export { FunctionResult as SwaigFunctionResult } from './FunctionResult.js';
74
- export { SwaigFunction } from './SwaigFunction.js';
75
- export { SemanticGate, gateDefinitions, applyGateFields, MAX_GATES, MAX_QUESTION_BYTES, MAX_CRITERIA_BYTES, MAX_ON_FAIL_BYTES, MAX_VISUAL_INPUT, RESERVED_FUNCTION_NAMES, } from './SemanticGate.js';
74
+ export { ResendDedupe, resolve, runChain } from './ToolMiddleware.js';
75
+ export { SwaigFunction, VOUCHED_PARAMETER, VOUCHED_DESCRIPTION, VOUCHED_PROMPT, NATIVE_WEBHOOK_URL, } from './SwaigFunction.js';
76
+ export { SemanticGate, gateDefinitions, applyGateFields, MAX_GATES, MAX_QUESTION_BYTES, MAX_CRITERIA_BYTES, MAX_ON_FAIL_BYTES, MAX_VISUAL_INPUT, MAX_GATE_HISTORY, GATE_DIALOGUES, RESERVED_FUNCTION_NAMES, } from './SemanticGate.js';
76
77
  // Typed SWAIG tool-parameter builder (Tier-2 flagship affordance for the
77
78
  // explicit-params path; byte-identical to the untyped `parameters` blob).
78
79
  export { ParameterSchema, paramSchema, RECORD_FORMATS, RECORD_DIRECTIONS, TAP_DIRECTIONS, TAP_CODECS, } from './ParameterSchema.js';
@@ -89,7 +90,7 @@ export { SWMLVerbHandler, AIVerbHandler, VerbHandlerRegistry } from './SWMLHandl
89
90
  // Prompt management
90
91
  export { PromptManager } from './PromptManager.js';
91
92
  // Contexts & Steps
92
- export { ContextBuilder, Context, Step, GatherInfo, GatherQuestion, createSimpleContext, HISTORY_MODES, } from './ContextBuilder.js';
93
+ export { ContextBuilder, Context, Step, GatherInfo, GatherQuestion, createSimpleContext, HISTORY_MODES, expectedAnswer, namedTools, MAX_EXPECTED_DIGITS, } from './ContextBuilder.js';
93
94
  // Security
94
95
  export { SessionManager } from './SessionManager.js';
95
96
  // SSL
@@ -227,5 +228,14 @@ export function addSkillDirectory(path) {
227
228
  }
228
229
  // Client capabilities and post-prompt normalization
229
230
  export { userVariables, declaredCapabilities, hasCapability } from './capabilities.js';
230
- export { DIALOGUE_ROLES, NormalizedPostPrompt, dialogueTurns, normalizePostPrompt, parsePostPromptData, stripJsonFence, } from './PostPrompt.js';
231
+ export { DIALOGUE_ROLES, NormalizedPostPrompt, dialogueTurns, callerTurns, normalizePostPrompt, parsePostPromptData, stripJsonFence, } from './PostPrompt.js';
232
+ export { SpeechLog, SPEECH_DETECT } from './AiEvents.js';
233
+ // Speech helpers: numbers as a voice says them, and what a caller spelled
234
+ export { numberWords, sayDigits, sayLastDigits, sayMoney } from './speech/numbers.js';
235
+ export { readSpelled, spokenEmail, spellingVariants } from './speech/spelling.js';
236
+ // Conversation patterns: a change the caller confirms, and requests to come back to
237
+ export { Proposal, current, PROPOSAL_KEY } from './patterns/Proposal.js';
238
+ export { RequestList } from './patterns/RequestList.js';
239
+ // Testing: a simulated call, and recorded tool requests to replay
240
+ export { CallSimulator, SimulatedCall, RequestRecorder, ToolMentionError, } from './testing/CallSimulator.js';
231
241
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,mCAAmC;AACnC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG/D,oCAAoC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,2BAA2B;AA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H,MAAM,UAAU,aAAa,CAAC,UAA6B;IACzD,cAAc,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,cAAc,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,oDAAoD;AACpD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGzD,0EAA0E;AAC1E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,oFAAoF;AACpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,kEAAkE;AAClE,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,4BAA4B,CAAC"}
package/dist/llms.txt CHANGED
@@ -15,6 +15,7 @@ Run `npx sw-tsdocs` for a map of the SDK, `npx sw-tsdocs <topic>` for an area, a
15
15
  - [docs/pgi_agent_guide.md](../docs/pgi_agent_guide.md): How to design agents that stay within their rules
16
16
  - [docs/llm_parameters.md](../docs/llm_parameters.md): Model parameters for the prompt and post-prompt
17
17
  - [docs/swaig-reference.md](../docs/swaig-reference.md): Every FunctionResult method and action
18
+ - [docs/conversation_patterns.md](../docs/conversation_patterns.md): Confirming a change, the caller's own words, honest outcomes, testing a call flow
18
19
  - [docs/datamap-guide.md](../docs/datamap-guide.md): The DataMap builder, templates, expressions and testing
19
20
  - [docs/contexts-guide.md](../docs/contexts-guide.md): Contexts, steps, navigation, gather mode and history
20
21
  - [docs/skills-guide.md](../docs/skills-guide.md): Using the built-in skills
@@ -0,0 +1,148 @@
1
+ /**
2
+ * A change the caller says yes to before a tool carries it out.
3
+ *
4
+ * This is the platform's confirm pattern. A function proposes the change: it
5
+ * reads it back and records it in `semantic_state`, in one action object, so
6
+ * the proposal's dialogue starts with the read-back on any platform release,
7
+ * including those that date a proposal from its own action object rather than
8
+ * the result's action list. The confirm tool's
9
+ * semantic gates, judged on that dialogue (`dialogue: 'proposal'`), check three
10
+ * things: that the caller's latest turn is an answer, that the answer is a yes,
11
+ * and that what they answered was a read-back of this change. The gates'
12
+ * questions are the platform's, as replayed against logged calls.
13
+ */
14
+ import { FunctionResult } from '../FunctionResult.js';
15
+ import { SemanticGate } from '../SemanticGate.js';
16
+ /** Where the proposal is recorded in `semantic_state`. */
17
+ export declare const PROPOSAL_KEY = "proposal";
18
+ /** Options for a {@link Proposal}. */
19
+ export interface ProposalOptions {
20
+ /**
21
+ * The tool the caller's no or change goes to, named in what the model is
22
+ * told when they don't say yes.
23
+ */
24
+ declineTool?: string;
25
+ /**
26
+ * Each gate's threshold. The platform's measured value is 0.8 for yes/no
27
+ * gates, about 0.6 with `unclear`. Default 0.8.
28
+ */
29
+ threshold?: number;
30
+ /** True to let the gates answer unclear as well (OpenAI), which asks the caller again. */
31
+ unclear?: boolean;
32
+ }
33
+ /** Options for {@link Proposal.propose}. */
34
+ export interface ProposeOptions {
35
+ /**
36
+ * The proposing call's request, so a proposal made again gets the next
37
+ * revision: the platform marks a new proposal only when `semantic_state`
38
+ * changes.
39
+ */
40
+ rawData?: Record<string, unknown> | null;
41
+ /** More of what the change is, kept in the state with it. */
42
+ details?: Record<string, unknown>;
43
+ /** A result to add to, in place of a new one. */
44
+ result?: FunctionResult;
45
+ }
46
+ /**
47
+ * A read-back the caller confirms before `confirmTool` runs.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { AgentBase, Proposal } from '@signalwire/sdk';
52
+ *
53
+ * const agent = new AgentBase({ name: 'shop' });
54
+ * const order = new Proposal('place_order', { declineTool: 'change_order' });
55
+ *
56
+ * agent.defineTool({
57
+ * name: 'review_order',
58
+ * description: 'Read the order back',
59
+ * parameters: {
60
+ * type: 'object',
61
+ * properties: { item: { type: 'string' }, time: { type: 'string' } },
62
+ * required: ['item', 'time'],
63
+ * },
64
+ * handler: (args, rawData) =>
65
+ * order.propose(`That's ${args.item} for pickup at ${args.time}. Is that right?`, {
66
+ * rawData,
67
+ * details: { item: args.item },
68
+ * }),
69
+ * });
70
+ * agent.defineTool({
71
+ * name: 'place_order',
72
+ * description: 'Place the order the caller said yes to',
73
+ * handler: () => order.complete('The order is placed.'),
74
+ * gates: order.confirmGates(),
75
+ * });
76
+ * ```
77
+ */
78
+ export declare class Proposal {
79
+ /** The tool that carries out the change. */
80
+ confirmTool: string;
81
+ /** The tool the caller's no or change goes to. */
82
+ declineTool?: string;
83
+ /** Each gate's threshold. */
84
+ threshold: number;
85
+ /** Whether the gates may answer unclear. */
86
+ unclear: boolean;
87
+ /**
88
+ * @param confirmTool - The tool that carries out the change.
89
+ * @param opts - `declineTool`, `threshold` and `unclear`.
90
+ */
91
+ constructor(confirmTool: string, opts?: ProposalOptions);
92
+ /**
93
+ * The result of the function that proposes the change.
94
+ *
95
+ * The agent says `readBack` word for word, and the proposal is recorded as
96
+ * `semantic_state` `{ proposal: readBack, revision: n, ...details }`, in the
97
+ * same action object, so the gates' proposal dialogue starts with the
98
+ * read-back. The model then waits for the caller's answer (`wait_for_user`).
99
+ *
100
+ * @param readBack - The words to read back, ending with the question, such as
101
+ * "That's a large tea for pickup at five. Is that right?". Name everything
102
+ * the change covers, the way the caller would say it.
103
+ * @param opts - `rawData`, `details` and `result`.
104
+ * @returns The result.
105
+ */
106
+ propose(readBack: string, opts?: ProposeOptions): FunctionResult;
107
+ /**
108
+ * Read the current proposal back again, as a new revision, so the gates'
109
+ * proposal dialogue starts over with it.
110
+ *
111
+ * @param rawData - The request of the call asking again, which carries the
112
+ * proposal in its `global_data`.
113
+ * @param result - A result to add to.
114
+ * @returns The result.
115
+ * @throws Error when the request carries no proposal.
116
+ */
117
+ askAgain(rawData: Record<string, unknown>, result?: FunctionResult): FunctionResult;
118
+ /**
119
+ * The confirm tool's gates: the caller answered, the answer is a yes, and it
120
+ * was a yes to a read-back of this change. Each is judged on the proposal's
121
+ * dialogue. When one fails, the model is told why, with the proposal quoted
122
+ * from `semantic_state` (the platform expands `${global_data...}` in a gate's
123
+ * output; one that doesn't sends it as written), and chaining is turned off
124
+ * for the call (`backToBackFunctions(false)`), so the model answers in words
125
+ * before it calls a tool again.
126
+ *
127
+ * @returns The gates, for the confirm tool's `gates`.
128
+ */
129
+ confirmGates(): SemanticGate[];
130
+ /**
131
+ * Record that the change was carried out, in place of the proposal.
132
+ *
133
+ * Write what was done rather than clearing the state with `{}`: a state that
134
+ * changes starts the next proposal dialogue there, and the model and the
135
+ * gates see what's settled.
136
+ *
137
+ * @param summary - What was done, such as "Order 4471 is placed".
138
+ * @param result - The confirm tool's result, to add to.
139
+ * @returns The result.
140
+ */
141
+ complete(summary: string, result?: FunctionResult): FunctionResult;
142
+ }
143
+ /**
144
+ * The proposal a request's `global_data.semantic_state` holds, or null.
145
+ * @param rawData - The SWAIG request.
146
+ * @returns The state, as the request carries it.
147
+ */
148
+ export declare function current(rawData: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
@@ -0,0 +1,214 @@
1
+ /**
2
+ * A change the caller says yes to before a tool carries it out.
3
+ *
4
+ * This is the platform's confirm pattern. A function proposes the change: it
5
+ * reads it back and records it in `semantic_state`, in one action object, so
6
+ * the proposal's dialogue starts with the read-back on any platform release,
7
+ * including those that date a proposal from its own action object rather than
8
+ * the result's action list. The confirm tool's
9
+ * semantic gates, judged on that dialogue (`dialogue: 'proposal'`), check three
10
+ * things: that the caller's latest turn is an answer, that the answer is a yes,
11
+ * and that what they answered was a read-back of this change. The gates'
12
+ * questions are the platform's, as replayed against logged calls.
13
+ */
14
+ import { FunctionResult } from '../FunctionResult.js';
15
+ import { SemanticGate } from '../SemanticGate.js';
16
+ /** Where the proposal is recorded in `semantic_state`. */
17
+ export const PROPOSAL_KEY = 'proposal';
18
+ /**
19
+ * A read-back the caller confirms before `confirmTool` runs.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { AgentBase, Proposal } from '@signalwire/sdk';
24
+ *
25
+ * const agent = new AgentBase({ name: 'shop' });
26
+ * const order = new Proposal('place_order', { declineTool: 'change_order' });
27
+ *
28
+ * agent.defineTool({
29
+ * name: 'review_order',
30
+ * description: 'Read the order back',
31
+ * parameters: {
32
+ * type: 'object',
33
+ * properties: { item: { type: 'string' }, time: { type: 'string' } },
34
+ * required: ['item', 'time'],
35
+ * },
36
+ * handler: (args, rawData) =>
37
+ * order.propose(`That's ${args.item} for pickup at ${args.time}. Is that right?`, {
38
+ * rawData,
39
+ * details: { item: args.item },
40
+ * }),
41
+ * });
42
+ * agent.defineTool({
43
+ * name: 'place_order',
44
+ * description: 'Place the order the caller said yes to',
45
+ * handler: () => order.complete('The order is placed.'),
46
+ * gates: order.confirmGates(),
47
+ * });
48
+ * ```
49
+ */
50
+ export class Proposal {
51
+ /** The tool that carries out the change. */
52
+ confirmTool;
53
+ /** The tool the caller's no or change goes to. */
54
+ declineTool;
55
+ /** Each gate's threshold. */
56
+ threshold;
57
+ /** Whether the gates may answer unclear. */
58
+ unclear;
59
+ /**
60
+ * @param confirmTool - The tool that carries out the change.
61
+ * @param opts - `declineTool`, `threshold` and `unclear`.
62
+ */
63
+ constructor(confirmTool, opts = {}) {
64
+ this.confirmTool = confirmTool;
65
+ this.declineTool = opts.declineTool;
66
+ this.threshold = opts.threshold ?? 0.8;
67
+ this.unclear = opts.unclear ?? false;
68
+ }
69
+ /**
70
+ * The result of the function that proposes the change.
71
+ *
72
+ * The agent says `readBack` word for word, and the proposal is recorded as
73
+ * `semantic_state` `{ proposal: readBack, revision: n, ...details }`, in the
74
+ * same action object, so the gates' proposal dialogue starts with the
75
+ * read-back. The model then waits for the caller's answer (`wait_for_user`).
76
+ *
77
+ * @param readBack - The words to read back, ending with the question, such as
78
+ * "That's a large tea for pickup at five. Is that right?". Name everything
79
+ * the change covers, the way the caller would say it.
80
+ * @param opts - `rawData`, `details` and `result`.
81
+ * @returns The result.
82
+ */
83
+ propose(readBack, opts = {}) {
84
+ const state = {
85
+ ...(opts.details ?? {}),
86
+ [PROPOSAL_KEY]: readBack,
87
+ revision: revisionOf(opts.rawData) + 1,
88
+ };
89
+ const result = opts.result ?? new FunctionResult();
90
+ result.setToolResponse(`Read back to the caller: ${readBack}`, `Wait for the caller's answer. Call ${this.confirmTool} only when ` +
91
+ 'they say yes to this read-back.' +
92
+ (this.declineTool ? ` If they say no or want a change, call ${this.declineTool}.` : ''));
93
+ // One object: its say runs before its set_global_data, so the read-back
94
+ // is the first turn of the proposal it records
95
+ result.addAction('say', readBack);
96
+ result.action[result.action.length - 1]['set_global_data'] = { semantic_state: state };
97
+ result.waitForUser({ enabled: true });
98
+ return result;
99
+ }
100
+ /**
101
+ * Read the current proposal back again, as a new revision, so the gates'
102
+ * proposal dialogue starts over with it.
103
+ *
104
+ * @param rawData - The request of the call asking again, which carries the
105
+ * proposal in its `global_data`.
106
+ * @param result - A result to add to.
107
+ * @returns The result.
108
+ * @throws Error when the request carries no proposal.
109
+ */
110
+ askAgain(rawData, result) {
111
+ const state = current(rawData);
112
+ if (state === null) {
113
+ throw new Error('there is no proposal in semantic_state to ask about again');
114
+ }
115
+ const details = Object.fromEntries(Object.entries(state).filter(([k]) => k !== PROPOSAL_KEY && k !== 'revision'));
116
+ return this.propose(String(state[PROPOSAL_KEY]), { rawData, details, result });
117
+ }
118
+ /**
119
+ * The confirm tool's gates: the caller answered, the answer is a yes, and it
120
+ * was a yes to a read-back of this change. Each is judged on the proposal's
121
+ * dialogue. When one fails, the model is told why, with the proposal quoted
122
+ * from `semantic_state` (the platform expands `${global_data...}` in a gate's
123
+ * output; one that doesn't sends it as written), and chaining is turned off
124
+ * for the call (`backToBackFunctions(false)`), so the model answers in words
125
+ * before it calls a tool again.
126
+ *
127
+ * @returns The gates, for the confirm tool's `gates`.
128
+ */
129
+ confirmGates() {
130
+ const tool = this.confirmTool;
131
+ const quoted = '${global_data.semantic_state.proposal}';
132
+ const decline = this.declineTool
133
+ ? `, or call ${this.declineTool} if they no longer want it`
134
+ : '';
135
+ const blocked = (why, then) => new FunctionResult(undefined, false, `${tool} was not run. ${why}`, then).backToBackFunctions(false);
136
+ const gate = { dialogue: 'proposal' };
137
+ if (this.unclear) {
138
+ gate.unclear = true;
139
+ gate.onUnclear = blocked("The caller's answer didn't settle it.", `Read the change back as it stands, "${quoted}", and ask for a plain yes or no.`);
140
+ }
141
+ return [
142
+ new SemanticGate("Is the caller's latest turn in `conversation` an answer, rather than " +
143
+ 'only a sound that shows they are listening, made while the agent was ' +
144
+ 'still talking? A caller turn began while the agent was still talking ' +
145
+ 'if it is marked `while_agent_talking`, or if the agent turn just ' +
146
+ 'before it is marked `interrupted`, which means the caller cut it off. ' +
147
+ 'Any other caller turn began after the agent had finished.', this.threshold, blocked('The caller was only showing they were listening.', 'Finish reading the change back and ask for a plain yes or no.'), {
148
+ ...gate,
149
+ id: 'answered',
150
+ trueMeans: 'Their latest turn answers, with a yes, a no, or more than a sound ' +
151
+ 'that shows they are listening, or it began after the agent had ' +
152
+ 'finished.',
153
+ falseMeans: 'Their latest turn is only a sound that shows they are listening, ' +
154
+ 'and it began while the agent was still talking.',
155
+ }),
156
+ new SemanticGate("Is the caller's latest answer in `conversation` to the agent's request " +
157
+ 'to confirm a yes to the change described in `semantic_state`? The ' +
158
+ 'read-back may be cut off by their answer: a yes once they have heard ' +
159
+ 'what the change is counts. A yes that comes with another request still ' +
160
+ 'counts as a yes to this change.', this.threshold, blocked('The caller has not said yes to this change.', `Read it back, "${quoted}", and ask for a plain yes or no${decline}.`), {
161
+ ...gate,
162
+ id: 'agreed',
163
+ trueMeans: 'Their latest answer says yes to this change, even with another ' +
164
+ 'request or a cut-off read-back.',
165
+ falseMeans: 'Their latest answer says no, hesitates, or only asks a question or ' +
166
+ 'for something else.',
167
+ }),
168
+ new SemanticGate("Did the agent read back the change in `semantic_state` before the caller's " +
169
+ 'latest answer in `conversation`?', this.threshold, blocked('What the caller answered was not a read-back of this change.', `Read the proposal back as it stands, "${quoted}", and only it, then ` +
170
+ `ask for a yes or no${decline}.`), {
171
+ ...gate,
172
+ id: 'read_back',
173
+ trueMeans: "The agent's read-back, even if cut off by the answer, described this change.",
174
+ falseMeans: 'The read-back described a different change, or none was given.',
175
+ }),
176
+ ];
177
+ }
178
+ /**
179
+ * Record that the change was carried out, in place of the proposal.
180
+ *
181
+ * Write what was done rather than clearing the state with `{}`: a state that
182
+ * changes starts the next proposal dialogue there, and the model and the
183
+ * gates see what's settled.
184
+ *
185
+ * @param summary - What was done, such as "Order 4471 is placed".
186
+ * @param result - The confirm tool's result, to add to.
187
+ * @returns The result.
188
+ */
189
+ complete(summary, result) {
190
+ return (result ?? new FunctionResult(undefined, false, summary)).setSemanticState({
191
+ done: summary,
192
+ });
193
+ }
194
+ }
195
+ /**
196
+ * The proposal a request's `global_data.semantic_state` holds, or null.
197
+ * @param rawData - The SWAIG request.
198
+ * @returns The state, as the request carries it.
199
+ */
200
+ export function current(rawData) {
201
+ if (!isRecord(rawData))
202
+ return null;
203
+ const globalData = rawData['global_data'];
204
+ const state = isRecord(globalData) ? globalData['semantic_state'] : undefined;
205
+ return isRecord(state) && PROPOSAL_KEY in state ? state : null;
206
+ }
207
+ function revisionOf(rawData) {
208
+ const revision = current(rawData)?.['revision'];
209
+ return typeof revision === 'number' && Number.isInteger(revision) ? revision : 0;
210
+ }
211
+ function isRecord(value) {
212
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
213
+ }
214
+ //# sourceMappingURL=Proposal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Proposal.js","sourceRoot":"","sources":["../../src/patterns/Proposal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAE5E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AAgCvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,OAAO,QAAQ;IACnB,4CAA4C;IAC5C,WAAW,CAAS;IACpB,kDAAkD;IAClD,WAAW,CAAU;IACrB,6BAA6B;IAC7B,SAAS,CAAS;IAClB,4CAA4C;IAC5C,OAAO,CAAU;IAEjB;;;OAGG;IACH,YAAY,WAAmB,EAAE,OAAwB,EAAE;QACzD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,QAAgB,EAAE,OAAuB,EAAE;QACjD,MAAM,KAAK,GAA4B;YACrC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;YACvB,CAAC,YAAY,CAAC,EAAE,QAAQ;YACxB,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;SACvC,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QACnD,MAAM,CAAC,eAAe,CACpB,4BAA4B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