@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,7 @@
1
+ /** `serve prompt`: the prompt a state produces, and the stage and tools it shows, offline. */
2
+ import type { Io } from "./io.js";
3
+ /** Load the class, open it in the state the pairs name, and print its prompt. No gateway, no key. */
4
+ export declare function prompt(argv: string[], io: Io): Promise<number>;
5
+ /** `field=json` pairs as the state they name; a value that is not JSON is refused by its field. */
6
+ export declare function stateOf(pairs: string[]): Record<string, unknown>;
7
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/serve/prompt.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAO9F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAIlC,qGAAqG;AACrG,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBpE;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAahE"}
@@ -0,0 +1,51 @@
1
+ /** `serve prompt`: the prompt a state produces, and the stage and tools it shows, offline. */
2
+ import { parseArgs } from "node:util";
3
+ import { ChannelSchema, MediumSchema } from "../wire/defs.js";
4
+ import { showPrompt } from "../views/render.js";
5
+ import { CannotServe, instanceFor, loadServed } from "./load.js";
6
+ import { showMachine } from "./machine.js";
7
+ /** Load the class, open it in the state the pairs name, and print its prompt. No gateway, no key. */
8
+ export async function prompt(argv, io) {
9
+ const { values } = parseArgs({
10
+ args: argv,
11
+ options: {
12
+ file: { type: "string" },
13
+ slug: { type: "string" },
14
+ state: { type: "string", multiple: true },
15
+ channel: { type: "string", default: "phone" },
16
+ medium: { type: "string" },
17
+ "show-machine": { type: "boolean", default: false },
18
+ },
19
+ });
20
+ if (values.file === undefined || values.slug === undefined) {
21
+ throw new CannotServe("serve prompt takes the agent's --file and the --slug it is served as");
22
+ }
23
+ const channel = ChannelSchema.safeParse(values.channel);
24
+ const medium = MediumSchema.optional().safeParse(values.medium);
25
+ if (!channel.success || !medium.success) {
26
+ throw new CannotServe("--channel is phone, web or whatsapp, and --medium is voice or text");
27
+ }
28
+ const agent = instanceFor(await loadServed(values.file, values.slug), channel.data, medium.data);
29
+ agent.startIn(stateOf(values.state ?? []));
30
+ const machine = values["show-machine"] === true ? `\n\n${showMachine(agent)}` : "";
31
+ io.out.write(`${showPrompt(agent)}${machine}\n`);
32
+ return 0;
33
+ }
34
+ /** `field=json` pairs as the state they name; a value that is not JSON is refused by its field. */
35
+ export function stateOf(pairs) {
36
+ const state = {};
37
+ for (const pair of pairs) {
38
+ const at = pair.indexOf("=");
39
+ if (at <= 0)
40
+ throw new CannotServe(`--state ${pair}: a field, =, and its value as JSON`);
41
+ const field = pair.slice(0, at);
42
+ try {
43
+ state[field] = JSON.parse(pair.slice(at + 1));
44
+ }
45
+ catch {
46
+ throw new CannotServe(`--state ${field}: its value is not JSON`);
47
+ }
48
+ }
49
+ return state;
50
+ }
51
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/serve/prompt.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,qGAAqG;AACrG,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc,EAAE,EAAM;IACjD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC3B,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,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CAAC;AACX,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,OAAO,CAAC,KAAe;IACrC,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,IAAI,CAAC;YAAE,MAAM,IAAI,WAAW,CAAC,WAAW,IAAI,qCAAqC,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,WAAW,CAAC,WAAW,KAAK,yBAAyB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** `serve start`: hold the agents named, serve their calls, and leave by draining them. */
2
+ import type { Io } from "./io.js";
3
+ /** The console's other verbs are answered by the CLI's companion socket, never by the class. */
4
+ export declare const ONLY_THE_VIEW = "this process answers only view.render: the console's other verbs are the CLI's";
5
+ /** Hold every agent named until asked to leave; the exit code is 0 once they drained. */
6
+ export declare function start(argv: string[], io: Io): Promise<number>;
7
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/serve/start.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAU3F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAGlC,gGAAgG;AAChG,eAAO,MAAM,aAAa,mFAAmF,CAAC;AAY9G,yFAAyF;AACzF,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBnE"}
@@ -0,0 +1,95 @@
1
+ /** `serve start`: hold the agents named, serve their calls, and leave by draining them. */
2
+ import { parseArgs } from "node:util";
3
+ import { aLostSocket, DevRefused, Pinecall } from "../client/index.js";
4
+ import { mount } from "../runtime/connect.js";
5
+ import { drainLine, askedToLeave, drainedUnlessSignalledAgain } from "./leaving.js";
6
+ import { eventLine, personLine } from "./lines.js";
7
+ import { CannotServe, loadServed } from "./load.js";
8
+ import { viewingFrom } from "./viewing.js";
9
+ /** The console's other verbs are answered by the CLI's companion socket, never by the class. */
10
+ export const ONLY_THE_VIEW = "this process answers only view.render: the console's other verbs are the CLI's";
11
+ const NO_DOOR = "serve start reads PINECALL_URL and PINECALL_KEY from its environment, and one was not set";
12
+ const WORLDS = ["sandbox", "production"];
13
+ /** Hold every agent named until asked to leave; the exit code is 0 once they drained. */
14
+ export async function start(argv, io) {
15
+ const { values } = parseArgs({
16
+ args: argv,
17
+ options: {
18
+ file: { type: "string", multiple: true },
19
+ slug: { type: "string", multiple: true },
20
+ console: { type: "boolean", default: false },
21
+ events: { type: "boolean", default: false },
22
+ },
23
+ });
24
+ const served = paired(values.file ?? [], values.slug ?? []);
25
+ const pc = clientFrom(io.env);
26
+ for (const one of served)
27
+ await held(pc, one, values.console === true);
28
+ said(pc, io, values.events === true);
29
+ try {
30
+ await pc.connect();
31
+ if ((await askedToLeave(pc, io)) !== "stopped") {
32
+ const drained = await drainedUnlessSignalledAgain(pc, io);
33
+ if (drained !== undefined)
34
+ io.err.write(`${drainLine(drained)}\n`);
35
+ }
36
+ return 0;
37
+ }
38
+ finally {
39
+ pc.close();
40
+ }
41
+ }
42
+ /** Every `--file` with the `--slug` at its place. */
43
+ function paired(files, slugs) {
44
+ if (files.length === 0 || files.length !== slugs.length) {
45
+ throw new CannotServe("serve start takes one --slug for each --file, and at least one of each");
46
+ }
47
+ return files.map((file, at) => ({ file, slug: slugs[at] }));
48
+ }
49
+ function clientFrom(env) {
50
+ const url = env["PINECALL_URL"];
51
+ const apiKey = env["PINECALL_KEY"];
52
+ if (url === undefined || url === "" || apiKey === undefined || apiKey === "")
53
+ throw new CannotServe(NO_DOOR);
54
+ const world = env["PINECALL_ENV"];
55
+ if (world === undefined || world === "")
56
+ return new Pinecall({ url, apiKey });
57
+ if (!WORLDS.includes(world))
58
+ throw new CannotServe(`PINECALL_ENV is sandbox or production, not ${world}`);
59
+ return new Pinecall({ url, apiKey, env: world });
60
+ }
61
+ // A console's own process takes only the calls that name it; the class draws the panel.
62
+ async function held(pc, one, console) {
63
+ const loaded = await loadServed(one.file, one.slug);
64
+ const mounted = mount(loaded.ctor, { pc, source: loaded.source, file: loaded.file, slug: one.slug, takesUnclaimed: !console });
65
+ const viewing = viewingFrom(loaded.ctor, one.slug);
66
+ mounted.agent.onDev(async (verb, data) => {
67
+ if (verb !== "view.render")
68
+ throw new DevRefused(404, ONLY_THE_VIEW);
69
+ return { ...(await viewing.render(data)) };
70
+ });
71
+ return mounted;
72
+ }
73
+ // Listening starts before connect, so agent.registered is the first line. A lost gateway is one
74
+ // line per outage, on err so --events stays the wire alone.
75
+ function said(pc, io, events) {
76
+ pc.onEntries((entry) => {
77
+ const line = events ? eventLine(entry) : personLine(entry);
78
+ if (line !== null)
79
+ io.out.write(`${line}\n`);
80
+ });
81
+ let lost = false;
82
+ pc.onErrors((failed) => {
83
+ if (!aLostSocket(failed))
84
+ return void io.err.write(`${failed.stack ?? failed.message}\n`);
85
+ if (!lost)
86
+ io.err.write(`gateway ${failed.message} — reconnecting\n`);
87
+ lost = true;
88
+ });
89
+ pc.onConnected(() => {
90
+ if (lost)
91
+ io.err.write("gateway back\n");
92
+ lost = false;
93
+ });
94
+ }
95
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/serve/start.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAE3F,OA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,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gGAAgG;AAChG,4DAA4D;AAC5D,SAAS,IAAI,CAAC,EAAY,EAAE,EAAM,EAAE,MAAe;IACjD,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3D,IAAI,IAAI,KAAK,IAAI;YAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE;QACrB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;QAC1F,IAAI,CAAC,IAAI;YAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;QACvE,IAAI,GAAG,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;QAClB,IAAI,IAAI;YAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC1C,IAAI,GAAG,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Render the agent class's view as the console panel for one conversation. */
2
+ import { type ViewNode } from "../views/nodes.js";
3
+ /** Rendered panel: its title and node tree. */
4
+ export interface Drawn {
5
+ name: string;
6
+ nodes: ViewNode[];
7
+ }
8
+ /** This process's answer to `view.render`, for the class it serves. */
9
+ export interface Viewing {
10
+ render(asked: unknown): Promise<Drawn>;
11
+ }
12
+ /**
13
+ * Bind `view.render` to a class. The view may be async; its output is rendered to
14
+ * `@pinecall/agents/panels` nodes, so only data reaches the browser.
15
+ */
16
+ export declare function viewingFrom(ctor: object, slug: string): Viewing;
17
+ //# sourceMappingURL=viewing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewing.d.ts","sourceRoot":"","sources":["../../src/serve/viewing.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAK/E,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAKjE,+CAA+C;AAC/C,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,uEAAuE;AACvE,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAe/D"}
@@ -0,0 +1,42 @@
1
+ /** Render the agent class's view as the console panel for one conversation. */
2
+ import { DevRefused } from "../client/index.js";
3
+ import { viewOf } from "../agent/view.js";
4
+ import { renderToNodes } from "../views/nodes.js";
5
+ // The console falls back to its own contact panel on this 404.
6
+ const DRAWS_NONE = (agent) => `${agent} declares no view: nothing in this directory draws a panel`;
7
+ /**
8
+ * Bind `view.render` to a class. The view may be async; its output is rendered to
9
+ * `@pinecall/agents/panels` nodes, so only data reaches the browser.
10
+ */
11
+ export function viewingFrom(ctor, slug) {
12
+ return {
13
+ async render(asked) {
14
+ const said = aConversation(asked);
15
+ const who = { agent: slug, contact: said.contact, call: said.call };
16
+ const declared = viewOf(ctor);
17
+ if (declared === undefined)
18
+ throw new DevRefused(404, DRAWS_NONE(slug));
19
+ // Report a throwing view in the pane instead of breaking the conversation screen.
20
+ try {
21
+ return { name: declared.name, nodes: renderToNodes(await declared.draw(who)) };
22
+ }
23
+ catch (failed) {
24
+ throw new DevRefused(502, `${slug}'s view failed: ${failed instanceof Error ? failed.message : String(failed)}`);
25
+ }
26
+ },
27
+ };
28
+ }
29
+ function aConversation(asked) {
30
+ if (typeof asked !== "object" || asked === null || Array.isArray(asked)) {
31
+ throw new DevRefused(422, "a panel is asked for with a JSON object");
32
+ }
33
+ const said = asked;
34
+ return { contact: aName(said, "contact"), call: aName(said, "call") };
35
+ }
36
+ function aName(said, name) {
37
+ const value = said[name];
38
+ if (typeof value !== "string" || value === "")
39
+ throw new DevRefused(422, `${name} is a name, and it was missing`);
40
+ return value;
41
+ }
42
+ //# sourceMappingURL=viewing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewing.js","sourceRoot":"","sources":["../../src/serve/viewing.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAiB,MAAM,mBAAmB,CAAC;AAEjE,+DAA+D;AAC/D,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,GAAG,KAAK,4DAA4D,CAAC;AAanH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACpD,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,KAAc;YACzB,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;YAClC,MAAM,GAAG,GAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YACzE,MAAM,QAAQ,G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AAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** The framework's own words in the identity block: the rules, the protocols, and the channel's. */
2
+ import { type Medium } from "../wire/defs.js";
3
+ /** The rules every agent is given. */
4
+ export declare const RULES: string;
5
+ /** The protocols every agent is given. */
6
+ export declare const PROTOCOLS: string;
7
+ /** How to write on this channel and medium: WhatsApp's formatting, a website's Markdown, or speech. */
8
+ export declare function channelRulesFor(channel: string | undefined, medium: Medium): string;
9
+ //# sourceMappingURL=built-in-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in-rules.d.ts","sourceRoot":"","sources":["../../src/views/built-in-rules.ts"],"names":[],"mappings":"AAAA,oGAAoG;AAEpG,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAK9C,sCAAsC;AACtC,eAAO,MAAM,KAAK,QAIN,CAAC;AAEb,0CAA0C;AAC1C,eAAO,MAAM,SAAS,QAIV,CAAC;AAYb,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGnF"}
@@ -0,0 +1,28 @@
1
+ /** The framework's own words in the identity block: the rules, the protocols, and the channel's. */
2
+ import {} from "../wire/defs.js";
3
+ // English for every agent: a model follows English instructions and answers in any language.
4
+ // Constant within a call, so they stay in the cached prompt prefix.
5
+ /** The rules every agent is given. */
6
+ export const RULES = [
7
+ "- Invent nothing: if it did not come from a tool or from the knowledge, do not say it.",
8
+ "- One question per turn, and wait for the answer.",
9
+ "- Answer in the language the caller speaks.",
10
+ ].join("\n");
11
+ /** The protocols every agent is given. */
12
+ export const PROTOCOLS = [
13
+ "- To act, call a tool; saying you have done something does not do it.",
14
+ "- Before an irreversible action read back what you are about to do and wait for an explicit yes.",
15
+ "- If you cannot solve it, say so and offer to hand over to a person.",
16
+ ].join("\n");
17
+ const SPOKEN = "You are on a phone call. Everything you write is read aloud by a voice: short spoken sentences, " +
18
+ "no lists, no bold, no symbols, no links. Say an email or a web address the way a person says it out loud.";
19
+ const ON_A_WEBSITE = "You are in a written chat on a website. Markdown is fine: short paragraphs, a list when there " +
20
+ "are steps, bold for the one thing that matters.";
21
+ const ON_WHATSAPP = "You are on WhatsApp. Use its formatting: *bold*, _italic_, no headings, no tables, short messages.";
22
+ /** How to write on this channel and medium: WhatsApp's formatting, a website's Markdown, or speech. */
23
+ export function channelRulesFor(channel, medium) {
24
+ if (channel === "whatsapp")
25
+ return ON_WHATSAPP;
26
+ return channel === "web" && medium === "text" ? ON_A_WEBSITE : SPOKEN;
27
+ }
28
+ //# sourceMappingURL=built-in-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in-rules.js","sourceRoot":"","sources":["../../src/views/built-in-rules.ts"],"names":[],"mappings":"AAAA,oGAAoG;AAEpG,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAE9C,6FAA6F;AAC7F,oEAAoE;AAEpE,sCAAsC;AACtC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,wFAAwF;IACxF,mDAAmD;IACnD,6CAA6C;CAC9C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,0CAA0C;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,uEAAuE;IACvE,kGAAkG;IAClG,sEAAsE;CACvE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,MAAM,GACV,kGAAkG;IAClG,2GAA2G,CAAC;AAE9G,MAAM,YAAY,GAChB,gGAAgG;IAChG,iDAAiD,CAAC;AAEpD,MAAM,WAAW,GAAG,oGAAoG,CAAC;AAEzH,uGAAuG;AACvG,MAAM,UAAU,eAAe,CAAC,OAA2B,EAAE,MAAc;IACzE,IAAI,OAAO,KAAK,UAAU;QAAE,OAAO,WAAW,CAAC;IAC/C,OAAO,OAAO,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC;AACxE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Prompt components: rules, protocols, sections and examples, rendered to text. */
2
+ import { type Component } from "./jsx-runtime.js";
3
+ /** A single rule, rendered as a bullet line. */
4
+ export declare const Rule: Component;
5
+ /** A `<rules>` block, one child per line. */
6
+ export declare const Rules: Component;
7
+ /** A `<protocols>` block: behaviour that holds in every state. */
8
+ export declare const Protocols: Component;
9
+ /** A section with a `## title` heading and its children as paragraphs. */
10
+ export declare const Section: Component;
11
+ /** An `<example>` block, so the model reads it as an example rather than an instruction. */
12
+ export declare const Example: Component;
13
+ /** A paragraph; equivalent to the `<p>` tag. */
14
+ export declare const p: Component;
15
+ /** Wrap `body` in `<name>` tags, or return "" when it is empty. */
16
+ export declare function tagged(name: string, body: string): string;
17
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/views/components.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,OAAO,EAAkD,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAE9G,gDAAgD;AAChD,eAAO,MAAM,IAAI,EAAE,SAAkE,CAAC;AAGtF,6CAA6C;AAC7C,eAAO,MAAM,KAAK,EAAE,SAAoD,CAAC;AAEzE,kEAAkE;AAClE,eAAO,MAAM,SAAS,EAAE,SAAwD,CAAC;AAEjF,0EAA0E;AAC1E,eAAO,MAAM,OAAO,EAAE,SAKrB,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,OAAO,EAAE,SAAuE,CAAC;AAE9F,gDAAgD;AAChD,eAAO,MAAM,CAAC,EAAE,SAAoD,CAAC;AAGrE,mEAAmE;AAEnE,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,33 @@
1
+ /** Prompt components: rules, protocols, sections and examples, rendered to text. */
2
+ import { blocks, renderInline, renderToText } from "./jsx-runtime.js";
3
+ /** A single rule, rendered as a bullet line. */
4
+ export const Rule = (props) => `- ${renderInline(children(props)).trim()}`;
5
+ Rule.inline = true;
6
+ /** A `<rules>` block, one child per line. */
7
+ export const Rules = (props) => tagged("rules", lines(props));
8
+ /** A `<protocols>` block: behaviour that holds in every state. */
9
+ export const Protocols = (props) => tagged("protocols", lines(props));
10
+ /** A section with a `## title` heading and its children as paragraphs. */
11
+ export const Section = (props) => {
12
+ const body = renderToText(children(props));
13
+ const title = String(props["title"] ?? "").trim();
14
+ if (!title)
15
+ return body;
16
+ return body ? `## ${title}\n\n${body}` : `## ${title}`;
17
+ };
18
+ /** An `<example>` block, so the model reads it as an example rather than an instruction. */
19
+ export const Example = (props) => tagged("example", renderToText(children(props)));
20
+ /** A paragraph; equivalent to the `<p>` tag. */
21
+ export const p = (props) => renderInline(children(props));
22
+ p.inline = true;
23
+ /** Wrap `body` in `<name>` tags, or return "" when it is empty. */
24
+ export function tagged(name, body) {
25
+ return body ? `<${name}>\n${body}\n</${name}>` : "";
26
+ }
27
+ function children(props) {
28
+ return (props["children"] ?? null);
29
+ }
30
+ function lines(props) {
31
+ return blocks(children(props)).join("\n");
32
+ }
33
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/views/components.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAA0C,MAAM,kBAAkB,CAAC;AAE9G,gDAAgD;AAChD,MAAM,CAAC,MAAM,IAAI,GAAc,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACtF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAAc,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OA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AC;AAC9C,CAAC;AAED,SAAS,KAAK,CAAC,KAAY;IACzB,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The dev-mode JSX runtime entry: re-exports the production runtime. */
2
+ export * from "./jsx-runtime.js";
3
+ //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/views/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAIzE,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** The dev-mode JSX runtime entry: re-exports the production runtime. */
2
+ // A re-export so dev and prod builds render identical prompts.
3
+ export * from "./jsx-runtime.js";
4
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../../src/views/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,+DAA+D;AAE/D,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /** The JSX runtime: elements form a tree that renders to text, not DOM. */
2
+ /** Anything a component may return; arrays nest and falsy values render nothing. */
3
+ export type Child = Element | string | number | boolean | null | undefined | Child[];
4
+ export type Props = Record<string, unknown>;
5
+ /** A function component from props to renderable children. */
6
+ export interface Component {
7
+ (props: Props): Child;
8
+ /** Rendered on one line inside its parent instead of as its own paragraph. */
9
+ inline?: boolean;
10
+ }
11
+ /** A JSX element: a tag and its props (including `children`). */
12
+ export interface Element {
13
+ readonly kind: "element";
14
+ readonly type: string | Component | typeof Fragment;
15
+ readonly props: Props;
16
+ }
17
+ /** `<>…</>`: groups siblings without adding text. */
18
+ export declare const Fragment: unique symbol;
19
+ /** Element factory for the automatic JSX runtime; also exported as `jsxs` and `jsxDEV`. */
20
+ export declare function jsx(type: Element["type"], props: Props): Element;
21
+ export { jsx as jsxs, jsx as jsxDEV };
22
+ /** Render a child inline. Strings keep their spacing, so `{name} tiene cita` stays intact. */
23
+ export declare function renderInline(child: Child): string;
24
+ /**
25
+ * Render a child as text: siblings become paragraphs separated by a blank line, falsy values
26
+ * render nothing, and strings are trimmed.
27
+ */
28
+ export declare function renderToText(child: Child): string;
29
+ /** Render each child as a separate block, dropping empty ones. */
30
+ export declare function blocks(child: Child): string[];
31
+ /** JSX types TypeScript resolves through `jsxImportSource`. */
32
+ type TextElement = Element;
33
+ export declare namespace JSX {
34
+ type Element = TextElement;
35
+ /** An intrinsic tag or a function component; class components are not supported. */
36
+ type ElementType = string | ((props: never) => Child) | Component;
37
+ interface ElementChildrenAttribute {
38
+ children: object;
39
+ }
40
+ interface IntrinsicElements {
41
+ p: {
42
+ children?: Child;
43
+ };
44
+ }
45
+ }
46
+ //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/views/jsx-runtime.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,oFAAoF;AACpF,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;AAErF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C,8DAA8D;AAC9D,MAAM,WAAW,SAAS;IACxB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,iEAAiE;AACjE,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,QAAQ,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED,qDAAqD;AACrD,eAAO,MAAM,QAAQ,eAAwC,CAAC;AAE9D,2FAA2F;AAC3F,wBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAEhE;AAED,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC;AAWtC,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEjD;AAED,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAmB7C;AAED,+DAA+D;AAC/D,KAAK,WAAW,GAAG,OAAO,CAAC;AAE3B,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,KAAK,OAAO,GAAG,WAAW,CAAC;IAC3B,oFAAoF;IAEpF,KAAK,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,GAAG,SAAS,CAAC;IAClE,UAAU,wBAAwB;QAChC,QAAQ,EAAE,MAAM,CAAC;KAClB;IACD,UAAU,iBAAiB;QACzB,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;SAAE,CAAC;KACzB;CACF"}
@@ -0,0 +1,63 @@
1
+ /** The JSX runtime: elements form a tree that renders to text, not DOM. */
2
+ /** `<>…</>`: groups siblings without adding text. */
3
+ export const Fragment = Symbol.for("pinecall.views.fragment");
4
+ /** Element factory for the automatic JSX runtime; also exported as `jsxs` and `jsxDEV`. */
5
+ export function jsx(type, props) {
6
+ return { kind: "element", type, props: props ?? {} };
7
+ }
8
+ export { jsx as jsxs, jsx as jsxDEV };
9
+ function childrenOf(props) {
10
+ return (props["children"] ?? null);
11
+ }
12
+ // Collapse JSX source newlines and indentation into single spaces.
13
+ function paragraph(text) {
14
+ return text.replace(/\s*\n\s*/g, " ").replace(/[ \t]{2,}/g, " ").trim();
15
+ }
16
+ /** Render a child inline. Strings keep their spacing, so `{name} tiene cita` stays intact. */
17
+ export function renderInline(child) {
18
+ if (child === null || child === undefined || typeof child === "boolean")
19
+ return "";
20
+ if (typeof child === "string")
21
+ return child;
22
+ if (typeof child === "number")
23
+ return String(child);
24
+ if (Array.isArray(child))
25
+ return child.map(renderInline).join("");
26
+ const { type, props } = child;
27
+ if (typeof type === "function")
28
+ return renderInline(type(props));
29
+ return renderInline(childrenOf(props));
30
+ }
31
+ /**
32
+ * Render a child as text: siblings become paragraphs separated by a blank line, falsy values
33
+ * render nothing, and strings are trimmed.
34
+ */
35
+ export function renderToText(child) {
36
+ return blocks(child).join("\n\n");
37
+ }
38
+ /** Render each child as a separate block, dropping empty ones. */
39
+ export function blocks(child) {
40
+ if (child === null || child === undefined || typeof child === "boolean")
41
+ return [];
42
+ if (typeof child === "string")
43
+ return child.trim() ? [child.trim()] : [];
44
+ if (typeof child === "number")
45
+ return [String(child)];
46
+ if (Array.isArray(child))
47
+ return child.flatMap(blocks);
48
+ const { type, props } = child;
49
+ if (typeof type === "function") {
50
+ if (type.inline) {
51
+ const line = paragraph(renderInline(child));
52
+ return line ? [line] : [];
53
+ }
54
+ return blocks(type(props));
55
+ }
56
+ // `<p>` is the only intrinsic tag; other lowercase tags render just their children.
57
+ if (type === "p") {
58
+ const line = paragraph(renderInline(childrenOf(props)));
59
+ return line ? [line] : [];
60
+ }
61
+ return blocks(childrenOf(props));
62
+ }
63
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../../src/views/jsx-runtime.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAqB3E,qDAAqD;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CA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,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** Prompt layout: named blocks in send order, static, then history, then dynamic. */
2
+ import { type PromptBlockSpec } from "../wire/defs.js";
3
+ import { type Agent } from "../agent/agent.js";
4
+ /** A rendered prompt block: name, region and text. */
5
+ export interface Block extends PromptBlockSpec {
6
+ text: string;
7
+ }
8
+ /** The rendered prompt. Only `dynamic` blocks may differ between turns, to keep the cache prefix. */
9
+ export interface Blocks {
10
+ /** Blocks in send order; the history goes between the static and dynamic ones. */
11
+ blocks: Block[];
12
+ /** `collapse()` summaries, for the printed page; the runtime owns the actual history. */
13
+ history: string;
14
+ }
15
+ /** Prompt block names and regions, in send order. */
16
+ export declare const PROMPT_BLOCKS: readonly PromptBlockSpec[];
17
+ /** Render every prompt block in send order. */
18
+ export declare function layout(agent: Agent): Blocks;
19
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/views/layout.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAMrE,sDAAsD;AACtD,MAAM,WAAW,KAAM,SAAQ,eAAe;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qGAAqG;AACrG,MAAM,WAAW,MAAM;IACrB,kFAAkF;IAClF,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;CACjB;AAYD,qDAAqD;AACrD,eAAO,MAAM,aAAa,EAAE,SAAS,eAAe,EAAyD,CAAC;AAE9G,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAG3C"}
@@ -0,0 +1,58 @@
1
+ /** Prompt layout: named blocks in send order, static, then history, then dynamic. */
2
+ import {} from "../wire/defs.js";
3
+ import { changes, internalsOf } from "../agent/agent.js";
4
+ import { docOf, toolsOf } from "../agent/tools.js";
5
+ import { tagged } from "./components.js";
6
+ import { channelRulesFor, PROTOCOLS, RULES } from "./built-in-rules.js";
7
+ import { renderToText } from "./jsx-runtime.js";
8
+ // Static blocks are cached; the view is the only dynamic block and comes last, after the history,
9
+ // so per-turn guidance is what the model reads last.
10
+ const BLOCKS = [
11
+ { name: "identity", region: "static", text: identityBlock },
12
+ // Filled by the gateway from the agent's settings (`pinecall agent knowledge`); the app sends "".
13
+ { name: "knowledge", region: "static", text: () => "" },
14
+ { name: "tools", region: "static", text: toolsBlock },
15
+ { name: "view", region: "dynamic", text: viewBlock },
16
+ ];
17
+ /** Prompt block names and regions, in send order. */
18
+ export const PROMPT_BLOCKS = BLOCKS.map(({ name, region }) => ({ name, region }));
19
+ /** Render every prompt block in send order. */
20
+ export function layout(agent) {
21
+ const blocks = BLOCKS.map(({ name, region, text }) => ({ name, region, text: text(agent) }));
22
+ return { blocks, history: collapsedHistory(agent) };
23
+ }
24
+ /** Class docstring, built-in rules and protocols, and the channel's. Reads no state. */
25
+ function identityBlock(agent) {
26
+ return paragraphs([docOf(agent) ?? "", tagged("rules", RULES), tagged("protocols", PROTOCOLS), channelBlock(agent)]);
27
+ }
28
+ // Static because a call never changes its channel or medium. With no call (an offline prompt), a
29
+ // phone call's.
30
+ function channelBlock(agent) {
31
+ if (agent.channelRules === false)
32
+ return "";
33
+ const call = internalsOf(agent).call;
34
+ return tagged("channel", channelRulesFor(call?.channel, call?.medium ?? "voice"));
35
+ }
36
+ // Lists every declared tool, visible or not, so this block stays static. Schemas go on the wire.
37
+ function toolsBlock(agent) {
38
+ const docs = toolsOf(agent)
39
+ .map((declared) => `- ${declared.name}: ${declared.spec.description}`)
40
+ .join("\n");
41
+ return tagged("tools", docs);
42
+ }
43
+ // Only the tenant's `render()` output. Recalled facts and retrieved chunks reach the model as tool
44
+ // results, never here (runtime docs/security/prompt-injection.md).
45
+ function viewBlock(agent) {
46
+ return renderToText(agent.render());
47
+ }
48
+ /** Summaries left by `collapse()`; the runtime owns the actual turns. */
49
+ function collapsedHistory(agent) {
50
+ return changes(agent)
51
+ .filter((change) => change.field === "@summary")
52
+ .map((change) => String(change.next))
53
+ .join("\n\n");
54
+ }
55
+ function paragraphs(parts) {
56
+ return parts.filter((part) => part.trim()).join("\n\n");
57
+ }
58
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/views/layout.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF,OAAO,EAAwB,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAehD,kGAAkG;AAClG,qDAAqD;AACrD,MAAM,MAAM,GAAG;IACb,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE;IAC3D,kGAAkG;IAClG,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;IACvD,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,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