@pinecall/agents 0.9.20

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 (292) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +121 -0
  3. package/dist/agent/accepts.d.ts +31 -0
  4. package/dist/agent/accepts.d.ts.map +1 -0
  5. package/dist/agent/accepts.js +27 -0
  6. package/dist/agent/accepts.js.map +1 -0
  7. package/dist/agent/agent.d.ts +151 -0
  8. package/dist/agent/agent.d.ts.map +1 -0
  9. package/dist/agent/agent.js +240 -0
  10. package/dist/agent/agent.js.map +1 -0
  11. package/dist/agent/authors.d.ts +12 -0
  12. package/dist/agent/authors.d.ts.map +1 -0
  13. package/dist/agent/authors.js +26 -0
  14. package/dist/agent/authors.js.map +1 -0
  15. package/dist/agent/decorators.d.ts +16 -0
  16. package/dist/agent/decorators.d.ts.map +1 -0
  17. package/dist/agent/decorators.js +43 -0
  18. package/dist/agent/decorators.js.map +1 -0
  19. package/dist/agent/docstrings.d.ts +35 -0
  20. package/dist/agent/docstrings.d.ts.map +1 -0
  21. package/dist/agent/docstrings.js +301 -0
  22. package/dist/agent/docstrings.js.map +1 -0
  23. package/dist/agent/knowledge.d.ts +9 -0
  24. package/dist/agent/knowledge.d.ts.map +1 -0
  25. package/dist/agent/knowledge.js +3 -0
  26. package/dist/agent/knowledge.js.map +1 -0
  27. package/dist/agent/lifecycle.d.ts +29 -0
  28. package/dist/agent/lifecycle.d.ts.map +1 -0
  29. package/dist/agent/lifecycle.js +9 -0
  30. package/dist/agent/lifecycle.js.map +1 -0
  31. package/dist/agent/searching.d.ts +7 -0
  32. package/dist/agent/searching.d.ts.map +1 -0
  33. package/dist/agent/searching.js +35 -0
  34. package/dist/agent/searching.js.map +1 -0
  35. package/dist/agent/stages.d.ts +23 -0
  36. package/dist/agent/stages.d.ts.map +1 -0
  37. package/dist/agent/stages.js +29 -0
  38. package/dist/agent/stages.js.map +1 -0
  39. package/dist/agent/state.d.ts +36 -0
  40. package/dist/agent/state.d.ts.map +1 -0
  41. package/dist/agent/state.js +93 -0
  42. package/dist/agent/state.js.map +1 -0
  43. package/dist/agent/tools.d.ts +61 -0
  44. package/dist/agent/tools.d.ts.map +1 -0
  45. package/dist/agent/tools.js +145 -0
  46. package/dist/agent/tools.js.map +1 -0
  47. package/dist/agent/view.d.ts +29 -0
  48. package/dist/agent/view.d.ts.map +1 -0
  49. package/dist/agent/view.js +29 -0
  50. package/dist/agent/view.js.map +1 -0
  51. package/dist/agent/visibility.d.ts +32 -0
  52. package/dist/agent/visibility.d.ts.map +1 -0
  53. package/dist/agent/visibility.js +77 -0
  54. package/dist/agent/visibility.js.map +1 -0
  55. package/dist/call/call.d.ts +137 -0
  56. package/dist/call/call.d.ts.map +1 -0
  57. package/dist/call/call.js +228 -0
  58. package/dist/call/call.js.map +1 -0
  59. package/dist/call/history.d.ts +28 -0
  60. package/dist/call/history.d.ts.map +1 -0
  61. package/dist/call/history.js +32 -0
  62. package/dist/call/history.js.map +1 -0
  63. package/dist/call/room.d.ts +56 -0
  64. package/dist/call/room.d.ts.map +1 -0
  65. package/dist/call/room.js +66 -0
  66. package/dist/call/room.js.map +1 -0
  67. package/dist/client/agent.d.ts +93 -0
  68. package/dist/client/agent.d.ts.map +1 -0
  69. package/dist/client/agent.js +230 -0
  70. package/dist/client/agent.js.map +1 -0
  71. package/dist/client/calls.d.ts +87 -0
  72. package/dist/client/calls.d.ts.map +1 -0
  73. package/dist/client/calls.js +180 -0
  74. package/dist/client/calls.js.map +1 -0
  75. package/dist/client/client.d.ts +112 -0
  76. package/dist/client/client.d.ts.map +1 -0
  77. package/dist/client/client.js +284 -0
  78. package/dist/client/client.js.map +1 -0
  79. package/dist/client/connection.d.ts +52 -0
  80. package/dist/client/connection.d.ts.map +1 -0
  81. package/dist/client/connection.js +157 -0
  82. package/dist/client/connection.js.map +1 -0
  83. package/dist/client/endpoints.d.ts +9 -0
  84. package/dist/client/endpoints.d.ts.map +1 -0
  85. package/dist/client/endpoints.js +25 -0
  86. package/dist/client/endpoints.js.map +1 -0
  87. package/dist/client/frames.d.ts +29 -0
  88. package/dist/client/frames.d.ts.map +1 -0
  89. package/dist/client/frames.js +51 -0
  90. package/dist/client/frames.js.map +1 -0
  91. package/dist/client/index.d.ts +18 -0
  92. package/dist/client/index.d.ts.map +1 -0
  93. package/dist/client/index.js +13 -0
  94. package/dist/client/index.js.map +1 -0
  95. package/dist/client/listeners.d.ts +35 -0
  96. package/dist/client/listeners.d.ts.map +1 -0
  97. package/dist/client/listeners.js +60 -0
  98. package/dist/client/listeners.js.map +1 -0
  99. package/dist/client/lost.d.ts +4 -0
  100. package/dist/client/lost.d.ts.map +1 -0
  101. package/dist/client/lost.js +8 -0
  102. package/dist/client/lost.js.map +1 -0
  103. package/dist/client/observe.d.ts +50 -0
  104. package/dist/client/observe.d.ts.map +1 -0
  105. package/dist/client/observe.js +125 -0
  106. package/dist/client/observe.js.map +1 -0
  107. package/dist/client/signed.d.ts +14 -0
  108. package/dist/client/signed.d.ts.map +1 -0
  109. package/dist/client/signed.js +18 -0
  110. package/dist/client/signed.js.map +1 -0
  111. package/dist/client/testing/gateway.d.ts +58 -0
  112. package/dist/client/testing/gateway.d.ts.map +1 -0
  113. package/dist/client/testing/gateway.js +175 -0
  114. package/dist/client/testing/gateway.js.map +1 -0
  115. package/dist/client/testing/index.d.ts +4 -0
  116. package/dist/client/testing/index.d.ts.map +1 -0
  117. package/dist/client/testing/index.js +4 -0
  118. package/dist/client/testing/index.js.map +1 -0
  119. package/dist/client/testing/log.d.ts +24 -0
  120. package/dist/client/testing/log.d.ts.map +1 -0
  121. package/dist/client/testing/log.js +106 -0
  122. package/dist/client/testing/log.js.map +1 -0
  123. package/dist/client/testing/loopback.d.ts +3 -0
  124. package/dist/client/testing/loopback.d.ts.map +1 -0
  125. package/dist/client/testing/loopback.js +3 -0
  126. package/dist/client/testing/loopback.js.map +1 -0
  127. package/dist/index.d.ts +23 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +27 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/runtime/connect.d.ts +42 -0
  132. package/dist/runtime/connect.d.ts.map +1 -0
  133. package/dist/runtime/connect.js +234 -0
  134. package/dist/runtime/connect.js.map +1 -0
  135. package/dist/runtime/dispatch.d.ts +32 -0
  136. package/dist/runtime/dispatch.d.ts.map +1 -0
  137. package/dist/runtime/dispatch.js +46 -0
  138. package/dist/runtime/dispatch.js.map +1 -0
  139. package/dist/runtime/environment.d.ts +7 -0
  140. package/dist/runtime/environment.d.ts.map +1 -0
  141. package/dist/runtime/environment.js +30 -0
  142. package/dist/runtime/environment.js.map +1 -0
  143. package/dist/runtime/recall.d.ts +9 -0
  144. package/dist/runtime/recall.d.ts.map +1 -0
  145. package/dist/runtime/recall.js +13 -0
  146. package/dist/runtime/recall.js.map +1 -0
  147. package/dist/runtime/run-tool.d.ts +18 -0
  148. package/dist/runtime/run-tool.d.ts.map +1 -0
  149. package/dist/runtime/run-tool.js +70 -0
  150. package/dist/runtime/run-tool.js.map +1 -0
  151. package/dist/serve/index.d.ts +5 -0
  152. package/dist/serve/index.d.ts.map +1 -0
  153. package/dist/serve/index.js +50 -0
  154. package/dist/serve/index.js.map +1 -0
  155. package/dist/serve/io.d.ts +14 -0
  156. package/dist/serve/io.d.ts.map +1 -0
  157. package/dist/serve/io.js +6 -0
  158. package/dist/serve/io.js.map +1 -0
  159. package/dist/serve/leaving.d.ts +12 -0
  160. package/dist/serve/leaving.d.ts.map +1 -0
  161. package/dist/serve/leaving.js +61 -0
  162. package/dist/serve/leaving.js.map +1 -0
  163. package/dist/serve/lines.d.ts +7 -0
  164. package/dist/serve/lines.d.ts.map +1 -0
  165. package/dist/serve/lines.js +25 -0
  166. package/dist/serve/lines.js.map +1 -0
  167. package/dist/serve/load.d.ts +26 -0
  168. package/dist/serve/load.d.ts.map +1 -0
  169. package/dist/serve/load.js +61 -0
  170. package/dist/serve/load.js.map +1 -0
  171. package/dist/serve/machine.d.ts +4 -0
  172. package/dist/serve/machine.d.ts.map +1 -0
  173. package/dist/serve/machine.js +33 -0
  174. package/dist/serve/machine.js.map +1 -0
  175. package/dist/serve/prompt.d.ts +7 -0
  176. package/dist/serve/prompt.d.ts.map +1 -0
  177. package/dist/serve/prompt.js +51 -0
  178. package/dist/serve/prompt.js.map +1 -0
  179. package/dist/serve/start.d.ts +7 -0
  180. package/dist/serve/start.d.ts.map +1 -0
  181. package/dist/serve/start.js +95 -0
  182. package/dist/serve/start.js.map +1 -0
  183. package/dist/serve/viewing.d.ts +17 -0
  184. package/dist/serve/viewing.d.ts.map +1 -0
  185. package/dist/serve/viewing.js +42 -0
  186. package/dist/serve/viewing.js.map +1 -0
  187. package/dist/views/built-in-rules.d.ts +9 -0
  188. package/dist/views/built-in-rules.d.ts.map +1 -0
  189. package/dist/views/built-in-rules.js +28 -0
  190. package/dist/views/built-in-rules.js.map +1 -0
  191. package/dist/views/components.d.ts +17 -0
  192. package/dist/views/components.d.ts.map +1 -0
  193. package/dist/views/components.js +33 -0
  194. package/dist/views/components.js.map +1 -0
  195. package/dist/views/jsx-dev-runtime.d.ts +3 -0
  196. package/dist/views/jsx-dev-runtime.d.ts.map +1 -0
  197. package/dist/views/jsx-dev-runtime.js +4 -0
  198. package/dist/views/jsx-dev-runtime.js.map +1 -0
  199. package/dist/views/jsx-runtime.d.ts +46 -0
  200. package/dist/views/jsx-runtime.d.ts.map +1 -0
  201. package/dist/views/jsx-runtime.js +63 -0
  202. package/dist/views/jsx-runtime.js.map +1 -0
  203. package/dist/views/layout.d.ts +19 -0
  204. package/dist/views/layout.d.ts.map +1 -0
  205. package/dist/views/layout.js +58 -0
  206. package/dist/views/layout.js.map +1 -0
  207. package/dist/views/nodes.d.ts +48 -0
  208. package/dist/views/nodes.d.ts.map +1 -0
  209. package/dist/views/nodes.js +45 -0
  210. package/dist/views/nodes.js.map +1 -0
  211. package/dist/views/panels.d.ts +17 -0
  212. package/dist/views/panels.d.ts.map +1 -0
  213. package/dist/views/panels.js +62 -0
  214. package/dist/views/panels.js.map +1 -0
  215. package/dist/views/render.d.ts +11 -0
  216. package/dist/views/render.d.ts.map +1 -0
  217. package/dist/views/render.js +19 -0
  218. package/dist/views/render.js.map +1 -0
  219. package/dist/wire/agent-config.d.ts +213 -0
  220. package/dist/wire/agent-config.d.ts.map +1 -0
  221. package/dist/wire/agent-config.js +126 -0
  222. package/dist/wire/agent-config.js.map +1 -0
  223. package/dist/wire/codec.d.ts +43 -0
  224. package/dist/wire/codec.d.ts.map +1 -0
  225. package/dist/wire/codec.js +51 -0
  226. package/dist/wire/codec.js.map +1 -0
  227. package/dist/wire/commands.d.ts +443 -0
  228. package/dist/wire/commands.d.ts.map +1 -0
  229. package/dist/wire/commands.js +203 -0
  230. package/dist/wire/commands.js.map +1 -0
  231. package/dist/wire/defs.d.ts +373 -0
  232. package/dist/wire/defs.d.ts.map +1 -0
  233. package/dist/wire/defs.js +212 -0
  234. package/dist/wire/defs.js.map +1 -0
  235. package/dist/wire/envelope.d.ts +29 -0
  236. package/dist/wire/envelope.d.ts.map +1 -0
  237. package/dist/wire/envelope.js +27 -0
  238. package/dist/wire/envelope.js.map +1 -0
  239. package/dist/wire/events-call.d.ts +446 -0
  240. package/dist/wire/events-call.d.ts.map +1 -0
  241. package/dist/wire/events-call.js +196 -0
  242. package/dist/wire/events-call.js.map +1 -0
  243. package/dist/wire/events.d.ts +946 -0
  244. package/dist/wire/events.d.ts.map +1 -0
  245. package/dist/wire/events.js +309 -0
  246. package/dist/wire/events.js.map +1 -0
  247. package/dist/wire/index.d.ts +19 -0
  248. package/dist/wire/index.d.ts.map +1 -0
  249. package/dist/wire/index.js +19 -0
  250. package/dist/wire/index.js.map +1 -0
  251. package/dist/wire/metrics.d.ts +366 -0
  252. package/dist/wire/metrics.d.ts.map +1 -0
  253. package/dist/wire/metrics.js +269 -0
  254. package/dist/wire/metrics.js.map +1 -0
  255. package/dist/wire/reduce.d.ts +10 -0
  256. package/dist/wire/reduce.d.ts.map +1 -0
  257. package/dist/wire/reduce.js +367 -0
  258. package/dist/wire/reduce.js.map +1 -0
  259. package/dist/wire/registry.d.ts +1789 -0
  260. package/dist/wire/registry.d.ts.map +1 -0
  261. package/dist/wire/registry.js +118 -0
  262. package/dist/wire/registry.js.map +1 -0
  263. package/dist/wire/rest-data.d.ts +170 -0
  264. package/dist/wire/rest-data.d.ts.map +1 -0
  265. package/dist/wire/rest-data.js +78 -0
  266. package/dist/wire/rest-data.js.map +1 -0
  267. package/dist/wire/rest-hosting.d.ts +74 -0
  268. package/dist/wire/rest-hosting.d.ts.map +1 -0
  269. package/dist/wire/rest-hosting.js +38 -0
  270. package/dist/wire/rest-hosting.js.map +1 -0
  271. package/dist/wire/rest-retrieval.d.ts +214 -0
  272. package/dist/wire/rest-retrieval.d.ts.map +1 -0
  273. package/dist/wire/rest-retrieval.js +161 -0
  274. package/dist/wire/rest-retrieval.js.map +1 -0
  275. package/dist/wire/rest.d.ts +786 -0
  276. package/dist/wire/rest.d.ts.map +1 -0
  277. package/dist/wire/rest.js +238 -0
  278. package/dist/wire/rest.js.map +1 -0
  279. package/dist/wire/room.d.ts +106 -0
  280. package/dist/wire/room.d.ts.map +1 -0
  281. package/dist/wire/room.js +73 -0
  282. package/dist/wire/room.js.map +1 -0
  283. package/dist/wire/state.d.ts +915 -0
  284. package/dist/wire/state.d.ts.map +1 -0
  285. package/dist/wire/state.js +189 -0
  286. package/dist/wire/state.js.map +1 -0
  287. package/dist/wire/verbs.d.ts +73 -0
  288. package/dist/wire/verbs.d.ts.map +1 -0
  289. package/dist/wire/verbs.js +50 -0
  290. package/dist/wire/verbs.js.map +1 -0
  291. package/package.json +74 -0
  292. package/tsconfig.tenant.json +24 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/agent/state.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EA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SAAS,GAAc,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACzE,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACvB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;QACf,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,UAAU;QAClB,EAAE,EAAE,SAAS,CAAC,EAAE;KACjB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAKD,qEAAqE;AAErE,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,61 @@
1
+ /** The tool registry: declared tools, their wire specs, and which are visible in the current state. */
2
+ import { z } from "zod";
3
+ import { type ToolSpec } from "../wire/defs.js";
4
+ import { type ParamDoc } from "./docstrings.js";
5
+ import type { StageOf } from "./stages.js";
6
+ import { type Snapshot } from "./state.js";
7
+ export type { ToolSpec };
8
+ export type SideEffect = NonNullable<ToolSpec["side_effect"]>;
9
+ /** Options for `@tool({...})`. `T` is inferred from the decorated class, so `when` sees typed state. */
10
+ export interface ToolOptions<T = unknown> {
11
+ /** Show the tool only while this returns true for the current state. */
12
+ when?: (state: Snapshot<T>) => boolean;
13
+ /**
14
+ * Show the tool only in these stages, typed against the class's `stage` field. Combined with
15
+ * `when`, both must hold.
16
+ */
17
+ stage?: StageOf<T> | StageOf<T>[];
18
+ /** Confirmation read back after the tool runs; `{{result.x}}` is filled from its return value. Marks the tool irreversible. */
19
+ confirm?: string;
20
+ /** Number of rows of a list result shown to the model; the full result is kept. */
21
+ preview?: number;
22
+ /** Parameter names holding personal data, masked in the log. */
23
+ pii?: string[];
24
+ /** Timeout for the method, in seconds. */
25
+ timeout?: number;
26
+ /** Explicit parameter schema, overriding the one inferred from the signature. */
27
+ params?: z.ZodObject;
28
+ }
29
+ export type ErasedToolOptions = ToolOptions<any>;
30
+ /** A declared tool: its options, method, owning class and wire spec. */
31
+ export interface ToolDeclaration {
32
+ name: string;
33
+ options: ErasedToolOptions;
34
+ method: (...args: unknown[]) => unknown;
35
+ owner: Function;
36
+ spec: ToolSpec;
37
+ }
38
+ /** Thrown at declaration time for a tool or class the platform would refuse. */
39
+ export declare class DeclarationRefused extends Error {
40
+ constructor(message: string);
41
+ }
42
+ interface Declared {
43
+ name: string;
44
+ options: ErasedToolOptions;
45
+ method: (...args: unknown[]) => unknown;
46
+ }
47
+ /** Record one decorated method against the class that declared it. */
48
+ export declare function register(prototype: object, declared: Declared): void;
49
+ /** JSON Schema for a tool's parameters, from an explicit zod object or from the signature. */
50
+ export declare function parametersOf(params: ParamDoc[], explicit?: z.ZodObject): Record<string, unknown>;
51
+ /** Every tool the agent declares, own class first, then inherited. */
52
+ export declare function toolsOf(agent: object): ToolDeclaration[];
53
+ /** A declared tool by name. */
54
+ export declare function toolNamed(agent: object, name: string): ToolDeclaration | undefined;
55
+ /** Tools whose `when` holds for the current state. */
56
+ export declare function visibleToolsOf(agent: object): ToolDeclaration[];
57
+ /** Wire specs of the currently visible tools. */
58
+ export declare function visibleTools(agent: object): ToolSpec[];
59
+ /** The agent class's docstring. */
60
+ export declare function docOf(agent: object): string | undefined;
61
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/agent/tools.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAEvG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAkD,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAY,KAAK,QAAQ,EAAE,MA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ACzC;AAQD,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAUpE;AAWD,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWhG;AAwDD,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAuBxD;AAED,+BAA+B;AAC/B,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAElF;AAED,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAG/D;AAED,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEtD;AAED,mCAAmC;AAEnC,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvD"}
@@ -0,0 +1,145 @@
1
+ /** The tool registry: declared tools, their wire specs, and which are visible in the current state. */
2
+ import { z } from "zod";
3
+ import {} from "../wire/defs.js";
4
+ import { classDoc, docsVersion, methodDoc, methodParams } from "./docstrings.js";
5
+ import { snapshot } from "./state.js";
6
+ /** Thrown at declaration time for a tool or class the platform would refuse. */
7
+ export class DeclarationRefused extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "DeclarationRefused";
11
+ }
12
+ }
13
+ // Keyed by prototype; subclasses inherit by walking the chain at read time.
14
+ const registries = new WeakMap();
15
+ const specs = new WeakMap();
16
+ const A_NAME_A_MODEL_CAN_CALL = /^[A-Za-z][A-Za-z0-9_]*$/;
17
+ /** Record one decorated method against the class that declared it. */
18
+ export function register(prototype, declared) {
19
+ if (!A_NAME_A_MODEL_CAN_CALL.test(declared.name)) {
20
+ throw new DeclarationRefused(`a tool name is one word a model can call, not ${declared.name}`);
21
+ }
22
+ let registry = registries.get(prototype);
23
+ if (!registry) {
24
+ registry = new Map();
25
+ registries.set(prototype, registry);
26
+ }
27
+ registry.set(declared.name, declared);
28
+ }
29
+ // Fallback for bare type text when `param.schema` is absent; unknown shapes become open objects.
30
+ function schemaOf(type) {
31
+ const name = (type ?? "").split(" ").join("");
32
+ if (name.includes("=>"))
33
+ return { description: "callback" };
34
+ if (name.endsWith("[]"))
35
+ return { type: "array", items: schemaOf(name.slice(0, -2)) };
36
+ if (name === "string" || name === "number" || name === "boolean")
37
+ return { type: name };
38
+ return { type: "object", additionalProperties: true };
39
+ }
40
+ /** JSON Schema for a tool's parameters, from an explicit zod object or from the signature. */
41
+ export function parametersOf(params, explicit) {
42
+ if (explicit)
43
+ return z.toJSONSchema(explicit);
44
+ const properties = {};
45
+ const required = [];
46
+ for (const param of params) {
47
+ const schema = param.schema ?? schemaOf(param.type);
48
+ properties[param.name] = schema;
49
+ // The model cannot supply a callback, so it is never required.
50
+ if (!param.optional && schema["description"] !== "callback")
51
+ required.push(param.name);
52
+ }
53
+ return { type: "object", properties, required, additionalProperties: false };
54
+ }
55
+ /** Build the wire spec for one declared tool, refusing what the gateway would refuse. */
56
+ function specFor(ctor, declared) {
57
+ const description = methodDoc(ctor, declared.name);
58
+ if (!description) {
59
+ throw new DeclarationRefused(`tool ${declared.name}: without a docstring no model can choose it; ` +
60
+ `write a /** one line */ above the method`);
61
+ }
62
+ const options = declared.options;
63
+ const parameters = parametersOf(methodParams(ctor, declared.name), options.params);
64
+ const properties = (parameters["properties"] ?? {});
65
+ const unknownPii = (options.pii ?? []).filter((field) => !(field in properties));
66
+ if (unknownPii.length > 0) {
67
+ throw new DeclarationRefused(`tool ${declared.name}: pii names parameters the tool has; unknown: ${unknownPii.join(", ")}`);
68
+ }
69
+ // `confirm` makes a tool irreversible: the platform reads it back and waits for a yes.
70
+ const spec = {
71
+ name: declared.name,
72
+ description,
73
+ parameters,
74
+ side_effect: options.confirm ? "irreversible" : "read",
75
+ };
76
+ if (options.confirm !== undefined)
77
+ spec.confirm = options.confirm;
78
+ if (options.pii !== undefined)
79
+ spec.pii = [...options.pii];
80
+ if (options.timeout !== undefined)
81
+ spec.timeout_s = options.timeout;
82
+ return spec;
83
+ }
84
+ function cachedSpec(ctor, prototype, declared) {
85
+ let byName = specs.get(prototype);
86
+ if (!byName) {
87
+ byName = new Map();
88
+ specs.set(prototype, byName);
89
+ }
90
+ const known = byName.get(declared.name);
91
+ if (known && known.version === docsVersion())
92
+ return known.spec;
93
+ const spec = specFor(ctor, declared);
94
+ byName.set(declared.name, { spec, version: docsVersion() });
95
+ return spec;
96
+ }
97
+ // Without a `stage` field every staged tool would stay hidden. The compiler catches this in TS;
98
+ // this catches it for JavaScript classes, at mount.
99
+ function refuseAStageWithNoField(agent, ctor, name) {
100
+ if ("stage" in agent)
101
+ return;
102
+ throw new DeclarationRefused(`tool ${name}: stage names a value of this agent's own stage field, and ${ctor.name} ` +
103
+ `declares none; add \`stage: Stages<"…"> = "…"\` to the class, or ask when(state) instead`);
104
+ }
105
+ /** Every tool the agent declares, own class first, then inherited. */
106
+ export function toolsOf(agent) {
107
+ const ctor = agent.constructor;
108
+ const declarations = [];
109
+ const seen = new Set();
110
+ for (let prototype = Object.getPrototypeOf(agent); prototype && prototype !== Object.prototype; prototype = Object.getPrototypeOf(prototype)) {
111
+ for (const declared of registries.get(prototype)?.values() ?? []) {
112
+ if (seen.has(declared.name))
113
+ continue;
114
+ seen.add(declared.name);
115
+ if (declared.options.stage !== undefined)
116
+ refuseAStageWithNoField(agent, ctor, declared.name);
117
+ declarations.push({
118
+ name: declared.name,
119
+ options: declared.options,
120
+ method: declared.method,
121
+ owner: prototype.constructor,
122
+ spec: cachedSpec(ctor, prototype, declared),
123
+ });
124
+ }
125
+ }
126
+ return declarations;
127
+ }
128
+ /** A declared tool by name. */
129
+ export function toolNamed(agent, name) {
130
+ return toolsOf(agent).find((declared) => declared.name === name);
131
+ }
132
+ /** Tools whose `when` holds for the current state. */
133
+ export function visibleToolsOf(agent) {
134
+ const state = snapshot(agent);
135
+ return toolsOf(agent).filter((declared) => declared.options.when?.(state) ?? true);
136
+ }
137
+ /** Wire specs of the currently visible tools. */
138
+ export function visibleTools(agent) {
139
+ return visibleToolsOf(agent).map((declared) => declared.spec);
140
+ }
141
+ /** The agent class's docstring. */
142
+ export function docOf(agent) {
143
+ return classDoc(agent.constructor);
144
+ }
145
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/agent/tools.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAEvG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAyCrD,gFAAgF;AAChF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAQD,4EAA4E;AAC5E,MAAM,UAAU,GAAG,IAAI,OAAO,EAAiC,CAAC;AAChE,MAAM,KAAK,GAAG,IAAI,OAAO,EAA4D,CAAC;AAEtF,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D,sEAAsE;AACtE,MAAM,UAAU,QAAQ,CAAC,SAAiB,EAAE,QAAkB;IAC5D,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,kBAAkB,CAAC,iDAAiD,QAAQ,CAAC,IAAI,EAAE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M;gBACvB,KAAK,EAAG,SAAuC,CAAC,WAAW;gBAC3D,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC;aAC5C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,IAAY;IACnD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;AACrF,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,mCAAmC;AAEnC,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,QAAQ,CAAE,KAAmC,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /** `@view(Component)`: the console panel an agent draws beside a conversation. */
2
+ import type { Child } from "../views/jsx-runtime.js";
3
+ /**
4
+ * The conversation a panel is drawn for. It identifies a thread, not live call state: panels are
5
+ * shown for ended calls too, so a view fetches its data from the tenant's own systems.
6
+ */
7
+ export interface Who {
8
+ /** The agent whose thread is open. */
9
+ agent: string;
10
+ /** The other party: phone number, contact id, or web visitor id. */
11
+ contact: string;
12
+ /** The thread's most recent call id. */
13
+ call: string;
14
+ }
15
+ /** Draws a panel for one conversation with `@pinecall/agents/panels` tags. May be async. */
16
+ export type View = (who: Who) => Child | Promise<Child>;
17
+ /** A class's declared panel: its title and draw function. */
18
+ export interface DeclaredView {
19
+ name: string;
20
+ draw: View;
21
+ }
22
+ /**
23
+ * Declare the class's console panel. The title defaults to the function name spaced out
24
+ * (`CustomerCard` becomes "Customer Card"); pass `name` to set it.
25
+ */
26
+ export declare function view(draw: View, name?: string): (ctor: new (...args: never[]) => object) => void;
27
+ /** The class's declared panel, or undefined. */
28
+ export declare function viewOf(ctor: object): DeclaredView | undefined;
29
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/agent/view.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,4FAA4F;AAC5F,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAExD,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAKD;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,UACb,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,MAAM,KAAG,IAAI,CAOvE;AAED,gDAAgD;AAChD,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE7D"}
@@ -0,0 +1,29 @@
1
+ /** `@view(Component)`: the console panel an agent draws beside a conversation. */
2
+ import { DeclarationRefused } from "./tools.js";
3
+ // Stored outside the class: subclasses do not inherit it and nothing is added to the tenant's class.
4
+ const VIEWS = new WeakMap();
5
+ /**
6
+ * Declare the class's console panel. The title defaults to the function name spaced out
7
+ * (`CustomerCard` becomes "Customer Card"); pass `name` to set it.
8
+ */
9
+ export function view(draw, name) {
10
+ return function decorate(ctor) {
11
+ const standing = VIEWS.get(ctor);
12
+ if (standing !== undefined) {
13
+ throw new DeclarationRefused(`${ctor.name} declares two views (${standing.name} and ${name ?? nameOf(draw)}); a class draws one panel`);
14
+ }
15
+ VIEWS.set(ctor, { name: name ?? nameOf(draw), draw });
16
+ };
17
+ }
18
+ /** The class's declared panel, or undefined. */
19
+ export function viewOf(ctor) {
20
+ return VIEWS.get(ctor);
21
+ }
22
+ // `CustomerCard` -> `Customer Card`; acronyms are left intact.
23
+ function nameOf(draw) {
24
+ const written = draw.name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
25
+ if (written === "")
26
+ return "View";
27
+ return written.charAt(0).toUpperCase() + written.slice(1);
28
+ }
29
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/agent/view.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAwBhD,qGAAqG;AACrG,MAAM,KAAK,GAAG,IAAI,OAAO,EAAwB,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,IAAU,EAAE,IAAa;IAC5C,OAAO,SAAS,QAAQ,CAAC,IAAsC;QAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,kBAAkB,CAAC,GAAG,IAAI,CAAC,IAAI,wBAAwB,QAAQ,CAAC,IAAI,QAAQ,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1I,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,+DAA+D;AAE/D,SAAS,MAAM,CAAC,IAAU;IACxB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,32 @@
1
+ /** `@state`: declare which fields are state and who may see them. */
2
+ /** Who may see a state field (wire values from the protocol). */
3
+ export type Visibility = "public" | "tenant" | "pii";
4
+ /** Options for `@state({...})`. */
5
+ export interface StateOptions {
6
+ visibility?: Visibility;
7
+ /** Shorthand for `visibility: "pii"`. */
8
+ pii?: boolean;
9
+ }
10
+ /** One field's declaration as carried in `AgentConfig.state_fields`. */
11
+ export interface StateFieldSpec {
12
+ name: string;
13
+ visibility: Visibility;
14
+ }
15
+ /**
16
+ * Declare a field as state, optionally with its visibility: `@state`, `@state({ pii: true })`,
17
+ * `@state({ visibility: "public" })`. The default visibility is `tenant`.
18
+ */
19
+ export declare function state(prototype: object, name: string): void;
20
+ export declare function state(options?: StateOptions): (prototype: object, name: string) => void;
21
+ /**
22
+ * Field visibilities from `@state` decorators up the chain (parents first), then
23
+ * `static visibility`, which wins.
24
+ */
25
+ export declare function visibilityOf(ctor: Function): StateFieldSpec[];
26
+ /**
27
+ * The `@state` fields of a class, or null when it decorates none (then every own field is state).
28
+ * Once any field is decorated, undecorated fields are excluded from snapshots, prompt and
29
+ * `state.changed`. `static visibility` does not declare state.
30
+ */
31
+ export declare function declaredStateOf(ctor: Function): ReadonlySet<string> | null;
32
+ //# sourceMappingURL=visibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../src/agent/visibility.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAIrE,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;AAErD,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,yCAAyC;IACzC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACxB;AASD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;AAC7D,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAWzF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,EAAE,CAU7D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAU1E"}
@@ -0,0 +1,77 @@
1
+ /** `@state`: declare which fields are state and who may see them. */
2
+ import { DeclarationRefused } from "./tools.js";
3
+ // Keyed by prototype; subclasses inherit by walking the chain. `undefined` visibility means the
4
+ // field is state and the wire default applies.
5
+ const declared = new WeakMap();
6
+ // Cached: decorators all run at class definition, and the Proxy reads this on every assignment.
7
+ const merged = new WeakMap();
8
+ export function state(first, name) {
9
+ // Bare decorator `(prototype, name)` vs factory `(options?)`: told apart by the second argument.
10
+ if (typeof name === "string")
11
+ return declare(first, name, {});
12
+ const options = (first ?? {});
13
+ return (prototype, field) => declare(prototype, field, options);
14
+ }
15
+ /**
16
+ * Field visibilities from `@state` decorators up the chain (parents first), then
17
+ * `static visibility`, which wins.
18
+ */
19
+ export function visibilityOf(ctor) {
20
+ const fields = new Map();
21
+ for (const prototype of chainOf(ctor)) {
22
+ for (const [field, visibility] of declared.get(prototype) ?? [])
23
+ fields.set(field, visibility);
24
+ }
25
+ const map = ctor.visibility;
26
+ for (const [field, visibility] of Object.entries(map ?? {}))
27
+ fields.set(field, visibility);
28
+ return [...fields]
29
+ .filter((entry) => entry[1] !== undefined)
30
+ .map(([name, visibility]) => ({ name, visibility }));
31
+ }
32
+ /**
33
+ * The `@state` fields of a class, or null when it decorates none (then every own field is state).
34
+ * Once any field is decorated, undecorated fields are excluded from snapshots, prompt and
35
+ * `state.changed`. `static visibility` does not declare state.
36
+ */
37
+ export function declaredStateOf(ctor) {
38
+ const known = merged.get(ctor);
39
+ if (known !== undefined)
40
+ return known;
41
+ const fields = new Set();
42
+ for (const prototype of chainOf(ctor)) {
43
+ for (const field of (declared.get(prototype) ?? new Map()).keys())
44
+ fields.add(field);
45
+ }
46
+ const answer = fields.size === 0 ? null : fields;
47
+ merged.set(ctor, answer);
48
+ return answer;
49
+ }
50
+ // Parents first, so a subclass's declarations override.
51
+ function chainOf(ctor) {
52
+ const chain = [];
53
+ for (let prototype = ctor.prototype ?? null; prototype !== null && prototype !== Object.prototype; prototype = Object.getPrototypeOf(prototype)) {
54
+ chain.unshift(prototype);
55
+ }
56
+ return chain;
57
+ }
58
+ function declare(prototype, name, options) {
59
+ let own = declared.get(prototype);
60
+ if (own === undefined) {
61
+ own = new Map();
62
+ declared.set(prototype, own);
63
+ }
64
+ own.set(name, visibilityIn(options, prototype, name));
65
+ }
66
+ // Refuse `pii: true` combined with a different `visibility`.
67
+ function visibilityIn(options, prototype, name) {
68
+ if (options.pii === true && options.visibility !== undefined && options.visibility !== "pii") {
69
+ throw new DeclarationRefused(`@state({ pii: true, visibility: ${JSON.stringify(options.visibility)} }) on ` +
70
+ `${prototype.constructor.name}.${name}: ` +
71
+ `two different answers to one question; write one`);
72
+ }
73
+ if (options.pii === true)
74
+ return "pii";
75
+ return options.visibility;
76
+ }
77
+ //# sourceMappingURL=visibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visibility.js","sourceRoot":"","sources":["../../src/agent/visibility.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAkBhD,gGAAgG;AAChG,+CAA+C;AAC/C,MAAM,QAAQ,GAAG,IAAI,OAAO,EAA+C,CAAC;AAE5E,gGAAgG;AAChG,MAAM,MAAM,GAAG,IAAI,OAAO,EAAwC,CAAC;AAQnE,MAAM,UAAU,KAAK,CACnB,KAA6B,EAC7B,IAAa;IAEb,iGAAiG;IACjG,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,KAAe,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE,CAAiB,CAAC;IAC9C,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;IACzD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,EA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AkD,CACrD,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACvC,OAAO,OAAO,CAAC,UAAU,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,137 @@
1
+ /** `this.call`: the live call an agent instance serves — its room, turns and verbs. */
2
+ import { type Medium } from "../wire/defs.js";
3
+ import type { Call as HookCall } from "../agent/lifecycle.js";
4
+ import { History } from "./history.js";
5
+ import { ParticipantHandle, Room, type Commander } from "./room.js";
6
+ /** `cold`: the caller is sent on. `warm`: the far end is dialled into the call. */
7
+ export type TransferMode = "cold" | "warm";
8
+ /** The supervisor who took the line, as their token names them. */
9
+ export interface Supervisor {
10
+ id: string;
11
+ name?: string;
12
+ }
13
+ /** Result of `transfer()`. `ok: false` means the caller is still on the line. */
14
+ export interface Transferred {
15
+ to: string;
16
+ mode: TransferMode | null;
17
+ ok: boolean;
18
+ error?: string;
19
+ }
20
+ /** Result of `attention()`: who took the line, or why nobody did. */
21
+ export interface Attended {
22
+ ok: boolean;
23
+ by: Supervisor | null;
24
+ error?: string;
25
+ }
26
+ /** One search hit: its source path, heading and text. */
27
+ export interface Found {
28
+ path: string;
29
+ heading: string | null;
30
+ text: string;
31
+ }
32
+ /** Runs a search for this call through the gateway. */
33
+ export type Searching = (query: string, k?: number) => Promise<Found[]>;
34
+ /** Error for `search()` on a call with no gateway (an offline prompt, a test). */
35
+ export declare const NO_GATEWAY_TO_SEARCH = "this call cannot search: no gateway is serving it";
36
+ /** Line facts the call needs beyond what the room's entries carry. */
37
+ export interface CallLine extends HookCall {
38
+ today?: string;
39
+ claimed?: string | null;
40
+ }
41
+ /**
42
+ * One live call. State is reduced from log entries; every verb sends one wire command.
43
+ * There is no direct LiveKit access.
44
+ */
45
+ export declare class CallWorld implements HookCall {
46
+ #private;
47
+ private readonly out;
48
+ private readonly searching;
49
+ private readonly ackMs;
50
+ readonly id: string;
51
+ readonly contact: string;
52
+ readonly from?: string;
53
+ readonly channel?: string;
54
+ /** Spoken (`voice`) or written (`text`). A gateway that does not say gets it from the channel. */
55
+ readonly medium: Medium;
56
+ /** The day this call opened, `YYYY-MM-DD`. */
57
+ readonly today?: string;
58
+ /** The page code this call claimed, or null. */
59
+ claimed: string | null;
60
+ readonly room: Room;
61
+ readonly history: History;
62
+ /** The event being dispatched, so a write inside onEvent can name its cause. */
63
+ cause: {
64
+ name: string;
65
+ seq: number;
66
+ } | null;
67
+ constructor(line: CallLine, out: Commander, searching?: Searching | null, ackMs?: number);
68
+ /** Next sequence number for this call's events (independent of the wire's seq). */
69
+ numbered(): number;
70
+ /** A handle to one participant, e.g. `call.participant(id).mute()`. */
71
+ participant(identity: string): ParticipantHandle;
72
+ /** Send a payload to browsers in the room. The log records its size, not its content. */
73
+ send(topic: string, data: Record<string, unknown>, options?: {
74
+ to?: string;
75
+ }): void;
76
+ /** Speak this text verbatim. Resolves true once the turn lands, false on timeout. */
77
+ say(text: string, options?: {
78
+ allowInterruptions?: boolean;
79
+ }): Promise<boolean>;
80
+ /** Have the model speak, guided by instructions the caller never hears. Resolves like `say`. */
81
+ reply(instructions: string, options?: {
82
+ allowInterruptions?: boolean;
83
+ }): Promise<boolean>;
84
+ /**
85
+ * Search the knowledge bases attached to this agent. The gateway runs the search and logs the
86
+ * results. `k` defaults to each base's own setting.
87
+ */
88
+ search(query: string, options?: {
89
+ k?: number;
90
+ }): Promise<Found[]>;
91
+ /** Invite someone into the room. Same as `room.invite`. */
92
+ invite(to: string, options: {
93
+ kind: "sip" | "participant";
94
+ }): void;
95
+ /**
96
+ * Transfer the caller to a number. On a phone call the line is sent on (cold); in a browser the
97
+ * number is dialled into the call (warm) and the agent goes silent once it answers. `mode`
98
+ * forces one. `ok: false` means the caller is still with the agent.
99
+ */
100
+ transfer(to: string, options?: {
101
+ mode?: TransferMode;
102
+ }): Promise<Transferred>;
103
+ /**
104
+ * Ask for a supervisor. The caller waits (on hold, or unanswered in a thread) until someone takes
105
+ * the line or `waitS` passes. `reason` is shown to the supervisor. The calling tool runs the
106
+ * whole time, so give it a `timeout` longer than `waitS`.
107
+ */
108
+ attention(reason: string, options: {
109
+ waitS: number;
110
+ }): Promise<Attended>;
111
+ /** Put the caller on hold: they hear hold music and the agent neither speaks nor listens. */
112
+ hold(): void;
113
+ /** Take the caller off hold. */
114
+ unhold(): void;
115
+ /** Send DTMF tones: `0-9`, `*`, `#`, and `,` for a pause. */
116
+ dtmf(digits: string): void;
117
+ /**
118
+ * Bind this call to the code shown on the caller's page, so the page follows the call. Sets
119
+ * `claimed` on `call.claimed`; an unknown, expired or taken code is refused with `no_code`.
120
+ */
121
+ claim(code: string): void;
122
+ /** Record a callback request in the call log for your backend to dial. */
123
+ callback(number: string, options?: {
124
+ when?: string;
125
+ note?: string;
126
+ }): void;
127
+ /**
128
+ * The caller asked never to be called again: their number joins the org's do-not-call list, and
129
+ * no call of the org reaches it until a consent is recorded. Tell them it is done.
130
+ */
131
+ optOut(note?: string): void;
132
+ /** End the call. Say goodbye before calling this; nothing after it is heard. */
133
+ hangup(reason?: string): void;
134
+ /** Fold one log entry into the room and history. Unknown types are ignored. */
135
+ take(type: string, data: Record<string, unknown>, at: number): void;
136
+ }
137
+ //# sourceMappingURL=call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/call/call.ts"],"names":[],"mappings":"AAAA,uFAAuF;AAEvF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,SAAS,EAAwB,MAAM,WAAW,CAAC;AAiB1F,mFAAmF;AACnF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C,mEAAmE;AACnE,MAAM,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