@adminforth/agent 2.0.10 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +333 -10
  2. package/dist/application/ports.d.ts +66 -0
  3. package/dist/application/runTurnUseCase.d.ts +71 -0
  4. package/dist/application/runTurnUseCase.js +364 -0
  5. package/dist/custom/ChatFooter.vue +58 -30
  6. package/dist/custom/SteerDebugPanel.vue +45 -0
  7. package/dist/custom/SteerQueue.vue +54 -0
  8. package/dist/custom/composables/agentStore/constants.ts +1 -0
  9. package/dist/custom/composables/agentStore/useAgentSessions.ts +35 -16
  10. package/dist/custom/composables/agentStore/useAgentSteerQueue.ts +114 -0
  11. package/dist/custom/composables/useAgentStore.ts +46 -1
  12. package/dist/custom/conversation_area/MessageRenderer.vue +7 -1
  13. package/dist/custom/speech_recognition_frontend/AudioLines.vue +1 -1
  14. package/dist/custom/speech_recognition_frontend/MicrophoneButon.vue +3 -3
  15. package/dist/{agentEvents.d.ts → domain/agentEvents.d.ts} +5 -1
  16. package/dist/domain/steerBuffer.d.ts +33 -0
  17. package/dist/domain/steerBuffer.js +51 -0
  18. package/dist/{agent → domain}/systemPrompt.js +1 -1
  19. package/dist/{agent/turn → domain}/turnTypes.d.ts +41 -37
  20. package/dist/{agent/turn/VegaLiteStreamBuffer.d.ts → domain/vegaLiteStreamBuffer.d.ts} +1 -1
  21. package/dist/index.d.ts +4 -2
  22. package/dist/index.js +49 -35
  23. package/dist/{agent/runtime/AgentContext.d.ts → llm/agentContext.d.ts} +3 -3
  24. package/dist/{agent/simpleAgent.d.ts → llm/agentModels.d.ts} +18 -16
  25. package/dist/llm/agentModels.js +65 -0
  26. package/dist/{agent/runtime/AgentRuntime.d.ts → llm/agentRuntime.d.ts} +14 -2
  27. package/dist/{agent/runtime/AgentRuntime.js → llm/agentRuntime.js} +41 -6
  28. package/dist/llm/langGraphLlm.d.ts +25 -0
  29. package/dist/llm/langGraphLlm.js +54 -0
  30. package/dist/{agent/middleware/apiBasedTools.d.ts → llm/middleware/apiToolsMiddleware.d.ts} +1 -1
  31. package/dist/{agent/middleware/apiBasedTools.js → llm/middleware/apiToolsMiddleware.js} +8 -14
  32. package/dist/{agent → llm}/middleware/sequenceDebug.d.ts +1 -1
  33. package/dist/llm/middleware/steerMiddleware.d.ts +21 -0
  34. package/dist/llm/middleware/steerMiddleware.js +50 -0
  35. package/dist/{agent/models/AgentModelFactory.d.ts → llm/modelFactory.d.ts} +1 -1
  36. package/dist/{agent/models/AgentModelFactory.js → llm/modelFactory.js} +1 -1
  37. package/dist/llm/streamAdapter.d.ts +18 -0
  38. package/dist/llm/streamAdapter.js +117 -0
  39. package/dist/{sessionStore.d.ts → persistence/sessionStore.d.ts} +19 -2
  40. package/dist/{sessionStore.js → persistence/sessionStore.js} +53 -0
  41. package/dist/{agent/tools/AgentToolProvider.d.ts → tools/agentToolProvider.d.ts} +1 -1
  42. package/dist/{agent/tools/AgentToolProvider.js → tools/agentToolProvider.js} +1 -1
  43. package/dist/{apiBasedTools.js → tools/apiBasedTools.js} +0 -3
  44. package/dist/{agent/tools → tools}/apiTool.d.ts +1 -1
  45. package/dist/{agent/tools → tools}/fetchSkill.js +1 -1
  46. package/dist/{agent/tools → tools}/fetchToolSchema.d.ts +1 -1
  47. package/dist/{agent/tools → tools}/index.d.ts +1 -1
  48. package/dist/{agent/tools → tools}/navigateUser.d.ts +3 -3
  49. package/dist/{endpoints → transport/http}/context.d.ts +12 -4
  50. package/dist/transport/http/context.js +1 -0
  51. package/dist/{endpoints/core.js → transport/http/coreEndpoints.js} +23 -3
  52. package/dist/{endpoints/sessions.js → transport/http/sessionEndpoints.js} +36 -1
  53. package/dist/transport/sse/sseWriter.d.ts +29 -0
  54. package/dist/{surfaces/web-sse/createSseEventEmitter.js → transport/sse/sseWriter.js} +27 -0
  55. package/dist/{chatSurfaceService.d.ts → transport/surfaces/chatSurfaceService.d.ts} +3 -3
  56. package/dist/{chatSurfaceService.js → transport/surfaces/chatSurfaceService.js} +7 -5
  57. package/dist/{agent/speech/SpeechTurnService.d.ts → transport/surfaces/speechTurnService.d.ts} +1 -1
  58. package/dist/{agent/speech/SpeechTurnService.js → transport/surfaces/speechTurnService.js} +2 -2
  59. package/dist/types.d.ts +10 -4
  60. package/package.json +11 -2
  61. package/.woodpecker/buildRelease.sh +0 -13
  62. package/.woodpecker/buildSlackNotify.sh +0 -46
  63. package/.woodpecker/release.yml +0 -57
  64. package/agent/checkpointer.ts +0 -329
  65. package/agent/languageDetect.ts +0 -92
  66. package/agent/middleware/apiBasedTools.ts +0 -174
  67. package/agent/middleware/openAiResponsesContinuation.ts +0 -92
  68. package/agent/middleware/sequenceDebug.ts +0 -429
  69. package/agent/models/AgentModeResolver.ts +0 -9
  70. package/agent/models/AgentModelFactory.ts +0 -28
  71. package/agent/runtime/AgentContext.ts +0 -30
  72. package/agent/runtime/AgentRuntime.ts +0 -89
  73. package/agent/simpleAgent.ts +0 -199
  74. package/agent/skills/registry.ts +0 -162
  75. package/agent/speech/SpeechTurnService.ts +0 -179
  76. package/agent/systemPrompt.ts +0 -133
  77. package/agent/toolCallEvents.ts +0 -135
  78. package/agent/tools/AgentToolProvider.ts +0 -28
  79. package/agent/tools/apiTool.ts +0 -66
  80. package/agent/tools/fetchSkill.ts +0 -68
  81. package/agent/tools/fetchToolSchema.ts +0 -47
  82. package/agent/tools/getUserLocation.ts +0 -45
  83. package/agent/tools/index.ts +0 -31
  84. package/agent/tools/navigateUser.ts +0 -210
  85. package/agent/turn/TurnContextBuilder.ts +0 -36
  86. package/agent/turn/TurnLifecycleService.ts +0 -47
  87. package/agent/turn/TurnPersistenceService.ts +0 -33
  88. package/agent/turn/TurnPromptBuilder.ts +0 -51
  89. package/agent/turn/TurnStreamConsumer.ts +0 -69
  90. package/agent/turn/VegaLiteStreamBuffer.ts +0 -90
  91. package/agent/turn/turnTypes.ts +0 -100
  92. package/agentEvents.ts +0 -75
  93. package/agentTurnService.ts +0 -314
  94. package/apiBasedTools.ts +0 -712
  95. package/build.log +0 -67
  96. package/chatSurfaceService.ts +0 -319
  97. package/custom/ChatFooter.vue +0 -173
  98. package/custom/ChatHeader.vue +0 -78
  99. package/custom/ChatSurface.vue +0 -160
  100. package/custom/CustomAutoScrollContainer.vue +0 -164
  101. package/custom/SessionsHistory.vue +0 -88
  102. package/custom/chat.ts +0 -82
  103. package/custom/composables/agentAudio/utils.ts +0 -220
  104. package/custom/composables/agentStore/constants.ts +0 -19
  105. package/custom/composables/agentStore/pageContext.ts +0 -8
  106. package/custom/composables/agentStore/useAgentChat.ts +0 -241
  107. package/custom/composables/agentStore/useAgentPlaceholder.ts +0 -142
  108. package/custom/composables/agentStore/useAgentSessions.ts +0 -350
  109. package/custom/composables/useAgentAudio.ts +0 -272
  110. package/custom/composables/useAgentStore.ts +0 -510
  111. package/custom/composables/useAgentTransitions.ts +0 -58
  112. package/custom/conversation_area/ConversationArea.vue +0 -301
  113. package/custom/conversation_area/MessageRenderer.vue +0 -49
  114. package/custom/conversation_area/ProcessingTimeline.vue +0 -286
  115. package/custom/conversation_area/ReasoningRenderer.vue +0 -79
  116. package/custom/conversation_area/SystemMessageRenderer.vue +0 -28
  117. package/custom/conversation_area/TextRenderer.vue +0 -182
  118. package/custom/conversation_area/ThreeDotsAnimation.vue +0 -35
  119. package/custom/conversation_area/ToolApprovalRenderer.vue +0 -98
  120. package/custom/conversation_area/ToolRenderer.vue +0 -178
  121. package/custom/conversation_area/ToolsGroup.vue +0 -59
  122. package/custom/env.d.ts +0 -7
  123. package/custom/incremark_code_renderers/IncremarkShikiCodeBlock.vue +0 -393
  124. package/custom/incremark_code_renderers/incremarkCodeHighlight.ts +0 -285
  125. package/custom/incremark_code_renderers/incremarkRenderer.ts +0 -653
  126. package/custom/incremark_code_renderers/renderIncremarkMarkdown.ts +0 -118
  127. package/custom/package.json +0 -30
  128. package/custom/pnpm-lock.yaml +0 -2394
  129. package/custom/public/agentAudio/agent-processing.mp3 +0 -0
  130. package/custom/skills/analyze_data/SKILL.md +0 -25
  131. package/custom/skills/charts/SKILL.md +0 -193
  132. package/custom/skills/fetch_data/SKILL.md +0 -31
  133. package/custom/skills/mutate_data/SKILL.md +0 -121
  134. package/custom/speech_recognition_frontend/AudioLines.vue +0 -43
  135. package/custom/speech_recognition_frontend/MicrophoneButon.vue +0 -185
  136. package/custom/speech_recognition_frontend/types/voice-activity-detection.d.ts +0 -22
  137. package/custom/speech_recognition_frontend/voiceActivityDetection.ts +0 -62
  138. package/custom/tsconfig.json +0 -15
  139. package/custom/types.ts +0 -108
  140. package/custom/utils.ts +0 -38
  141. package/dist/agent/middleware/openAiResponsesContinuation.d.ts +0 -1
  142. package/dist/agent/middleware/openAiResponsesContinuation.js +0 -66
  143. package/dist/agent/models/AgentModeResolver.d.ts +0 -9
  144. package/dist/agent/models/AgentModeResolver.js +0 -9
  145. package/dist/agent/simpleAgent.js +0 -118
  146. package/dist/agent/turn/TurnContextBuilder.d.ts +0 -14
  147. package/dist/agent/turn/TurnContextBuilder.js +0 -31
  148. package/dist/agent/turn/TurnLifecycleService.d.ts +0 -24
  149. package/dist/agent/turn/TurnLifecycleService.js +0 -47
  150. package/dist/agent/turn/TurnPersistenceService.d.ts +0 -13
  151. package/dist/agent/turn/TurnPersistenceService.js +0 -35
  152. package/dist/agent/turn/TurnPromptBuilder.d.ts +0 -19
  153. package/dist/agent/turn/TurnPromptBuilder.js +0 -43
  154. package/dist/agent/turn/TurnStreamConsumer.d.ts +0 -11
  155. package/dist/agent/turn/TurnStreamConsumer.js +0 -84
  156. package/dist/agentTurnService.d.ts +0 -24
  157. package/dist/agentTurnService.js +0 -269
  158. package/dist/surfaces/web-sse/createSseEventEmitter.d.ts +0 -14
  159. package/endpoints/chatSurfaces.ts +0 -66
  160. package/endpoints/context.ts +0 -52
  161. package/endpoints/core.ts +0 -181
  162. package/endpoints/sessions.ts +0 -183
  163. package/errors.ts +0 -10
  164. package/index.ts +0 -192
  165. package/pnpm-workspace.yaml +0 -4
  166. package/sanitizeSpeechText.ts +0 -32
  167. package/sessionStore.ts +0 -105
  168. package/surfaces/web-sse/createSseEventEmitter.ts +0 -311
  169. package/tsconfig.json +0 -14
  170. package/types.ts +0 -127
  171. /package/dist/{agent/turn/turnTypes.js → application/ports.js} +0 -0
  172. /package/dist/{agentEvents.js → domain/agentEvents.js} +0 -0
  173. /package/dist/{agent → domain}/languageDetect.d.ts +0 -0
  174. /package/dist/{agent → domain}/languageDetect.js +0 -0
  175. /package/dist/{agent → domain}/systemPrompt.d.ts +0 -0
  176. /package/dist/{agent → domain}/toolCallEvents.d.ts +0 -0
  177. /package/dist/{agent → domain}/toolCallEvents.js +0 -0
  178. /package/dist/{endpoints/context.js → domain/turnTypes.js} +0 -0
  179. /package/dist/{agent/turn/VegaLiteStreamBuffer.js → domain/vegaLiteStreamBuffer.js} +0 -0
  180. /package/dist/{agent/runtime/AgentContext.js → llm/agentContext.js} +0 -0
  181. /package/dist/{agent → llm}/middleware/sequenceDebug.js +0 -0
  182. /package/dist/{agent/checkpointer.d.ts → persistence/checkpointStore.d.ts} +0 -0
  183. /package/dist/{agent/checkpointer.js → persistence/checkpointStore.js} +0 -0
  184. /package/dist/{errors.d.ts → shared/errors.d.ts} +0 -0
  185. /package/dist/{errors.js → shared/errors.js} +0 -0
  186. /package/dist/{sanitizeSpeechText.d.ts → shared/sanitizeSpeechText.d.ts} +0 -0
  187. /package/dist/{sanitizeSpeechText.js → shared/sanitizeSpeechText.js} +0 -0
  188. /package/dist/{apiBasedTools.d.ts → tools/apiBasedTools.d.ts} +0 -0
  189. /package/dist/{agent/tools → tools}/apiTool.js +0 -0
  190. /package/dist/{agent/tools → tools}/fetchSkill.d.ts +0 -0
  191. /package/dist/{agent/tools → tools}/fetchToolSchema.js +0 -0
  192. /package/dist/{agent/tools → tools}/getUserLocation.d.ts +0 -0
  193. /package/dist/{agent/tools → tools}/getUserLocation.js +0 -0
  194. /package/dist/{agent/tools → tools}/index.js +0 -0
  195. /package/dist/{agent/tools → tools}/navigateUser.js +0 -0
  196. /package/dist/{agent → tools}/skills/registry.d.ts +0 -0
  197. /package/dist/{agent → tools}/skills/registry.js +0 -0
  198. /package/dist/{endpoints/chatSurfaces.d.ts → transport/http/chatSurfaceEndpoints.d.ts} +0 -0
  199. /package/dist/{endpoints/chatSurfaces.js → transport/http/chatSurfaceEndpoints.js} +0 -0
  200. /package/dist/{endpoints/core.d.ts → transport/http/coreEndpoints.d.ts} +0 -0
  201. /package/dist/{endpoints/sessions.d.ts → transport/http/sessionEndpoints.d.ts} +0 -0
@@ -1,25 +0,0 @@
1
- name: analyze_data
2
- description: Universal skill to analyze AdminForth resource data, summarize trends, and compare distributions from fetched rows.
3
- ---
4
-
5
- # Involved tools
6
-
7
- Always call `get_resource` first if you need to inspect resource structure and column names.
8
-
9
- Then you need to select between two main tools for fetching data:
10
-
11
- - Load and call `aggregate` tool to fetch data for analytics. This is the main tool for fast server-side aggregations, including filtered data, grouped metrics, and date buckets such as day, week, or month. Always prioritize this way of fetching data for analytics, as it is optimized for performance and reduces the amount of data transferred and processed in-memory.
12
-
13
- - Load and call `get_resource_data` tool only when the requested analysis cannot be answered with `aggregate`. When using it, pass `columns` with only the fields required for the calculation so large result sets do not include unrelated row data.
14
-
15
- # Instructions
16
-
17
- When the user asks for analytics, reports, trends, comparisons, or distributions:
18
-
19
- - Fetch the requested data using `aggregate` whenever possible.
20
- - If it is not possible to get the required aggregates using `aggregate`, fetch the underlying rows with `get_resource_data`.
21
- - Prefer narrow requests: use filters, sorting, pagination, and date ranges whenever possible.
22
- - Prefer narrow row payloads: include `columns` when only one or a few fields are needed.
23
- - If the request is ambiguous, clarify the resource, metric, grouping, or date range before fetching data.
24
- - Return a short written summary with the key finding and most important numbers.
25
- - If the user asks for a chart, or if a chart would help and you decide to produce one, invoke the `charts` skill for chart formatting and Vega-Lite requirements.
@@ -1,193 +0,0 @@
1
- name: charts
2
- description: Create Vega-Lite chart specs for AdminForth analytics responses. Always use this skill when the user asks for a chart or when a chart would help illustrate the insights from an analytics query.
3
- ---
4
-
5
- # Instructions
6
-
7
- Use Vega-Lite syntax for charts.
8
-
9
- Return every chart as valid JSON inside a `vega-lite` fenced code block.
10
-
11
- Every chart spec should include:
12
-
13
- - `title.text`
14
- - `title.subtitle`
15
- - explicit axis titles when axes are used
16
- - tooltips for the key fields
17
-
18
- ### Line chart
19
-
20
- ```vega-lite
21
- {
22
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
23
- "title": {
24
- "text": "Orders by Day",
25
- "subtitle": "Daily order count for the selected date range"
26
- },
27
- "data": {
28
- "values": [
29
- { "date": "2026-04-01", "orders": 18 },
30
- { "date": "2026-04-02", "orders": 25 },
31
- { "date": "2026-04-03", "orders": 21 },
32
- { "date": "2026-04-04", "orders": 29 }
33
- ]
34
- },
35
- "mark": { "type": "line", "point": true },
36
- "encoding": {
37
- "x": { "field": "date", "type": "temporal", "title": "Date" },
38
- "y": { "field": "orders", "type": "quantitative", "title": "Orders" },
39
- "tooltip": [
40
- { "field": "date", "type": "temporal", "title": "Date" },
41
- { "field": "orders", "type": "quantitative", "title": "Orders" }
42
- ]
43
- }
44
- }
45
- ```
46
-
47
- ### Bar chart
48
-
49
- ```vega-lite
50
- {
51
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
52
- "title": {
53
- "text": "Revenue by Category",
54
- "subtitle": "Top categories in the current filtered dataset"
55
- },
56
- "data": {
57
- "values": [
58
- { "category": "Hardware", "revenue": 42000 },
59
- { "category": "Software", "revenue": 31500 },
60
- { "category": "Services", "revenue": 22750 }
61
- ]
62
- },
63
- "mark": "bar",
64
- "encoding": {
65
- "x": { "field": "category", "type": "nominal", "title": "Category", "sort": "-y" },
66
- "y": { "field": "revenue", "type": "quantitative", "title": "Revenue" },
67
- "tooltip": [
68
- { "field": "category", "type": "nominal", "title": "Category" },
69
- { "field": "revenue", "type": "quantitative", "title": "Revenue" }
70
- ]
71
- }
72
- }
73
- ```
74
-
75
- ### Area chart
76
-
77
- ```vega-lite
78
- {
79
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
80
- "title": {
81
- "text": "Monthly Signups",
82
- "subtitle": "New users accumulated across the last six months"
83
- },
84
- "data": {
85
- "values": [
86
- { "month": "2025-11-01", "signups": 120 },
87
- { "month": "2025-12-01", "signups": 155 },
88
- { "month": "2026-01-01", "signups": 168 },
89
- { "month": "2026-02-01", "signups": 190 },
90
- { "month": "2026-03-01", "signups": 214 },
91
- { "month": "2026-04-01", "signups": 238 }
92
- ]
93
- },
94
- "mark": { "type": "area", "line": true, "point": true },
95
- "encoding": {
96
- "x": { "field": "month", "type": "temporal", "title": "Month" },
97
- "y": { "field": "signups", "type": "quantitative", "title": "Signups" },
98
- "tooltip": [
99
- { "field": "month", "type": "temporal", "title": "Month" },
100
- { "field": "signups", "type": "quantitative", "title": "Signups" }
101
- ]
102
- }
103
- }
104
- ```
105
-
106
- ### Scatter plot
107
-
108
- ```vega-lite
109
- {
110
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
111
- "title": {
112
- "text": "Ad Spend vs Revenue",
113
- "subtitle": "Campaign-level correlation for the selected month"
114
- },
115
- "data": {
116
- "values": [
117
- { "campaign": "Search", "spend": 1200, "revenue": 5400 },
118
- { "campaign": "Social", "spend": 900, "revenue": 3100 },
119
- { "campaign": "Email", "spend": 350, "revenue": 2200 },
120
- { "campaign": "Affiliates", "spend": 700, "revenue": 3600 }
121
- ]
122
- },
123
- "mark": { "type": "point", "filled": true, "size": 120 },
124
- "encoding": {
125
- "x": { "field": "spend", "type": "quantitative", "title": "Ad Spend" },
126
- "y": { "field": "revenue", "type": "quantitative", "title": "Revenue" },
127
- "tooltip": [
128
- { "field": "campaign", "type": "nominal", "title": "Campaign" },
129
- { "field": "spend", "type": "quantitative", "title": "Ad Spend" },
130
- { "field": "revenue", "type": "quantitative", "title": "Revenue" }
131
- ]
132
- }
133
- }
134
- ```
135
-
136
- ### Pie chart
137
-
138
- ```vega-lite
139
- {
140
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
141
- "title": {
142
- "text": "Tickets by Status",
143
- "subtitle": "Share of tickets in each workflow state"
144
- },
145
- "data": {
146
- "values": [
147
- { "status": "Open", "count": 42 },
148
- { "status": "In Progress", "count": 27 },
149
- { "status": "Resolved", "count": 58 }
150
- ]
151
- },
152
- "mark": { "type": "arc", "innerRadius": 40 },
153
- "encoding": {
154
- "theta": { "field": "count", "type": "quantitative", "title": "Tickets" },
155
- "color": { "field": "status", "type": "nominal", "title": "Status" },
156
- "tooltip": [
157
- { "field": "status", "type": "nominal", "title": "Status" },
158
- { "field": "count", "type": "quantitative", "title": "Tickets" }
159
- ]
160
- }
161
- }
162
- ```
163
-
164
- ### Histogram
165
-
166
- ```vega-lite
167
- {
168
- "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
169
- "title": {
170
- "text": "Order Value Distribution",
171
- "subtitle": "Histogram of order totals in the filtered result set"
172
- },
173
- "data": {
174
- "values": [
175
- { "order_total": 24 },
176
- { "order_total": 31 },
177
- { "order_total": 39 },
178
- { "order_total": 42 },
179
- { "order_total": 63 },
180
- { "order_total": 78 },
181
- { "order_total": 95 }
182
- ]
183
- },
184
- "mark": "bar",
185
- "encoding": {
186
- "x": { "bin": true, "field": "order_total", "type": "quantitative", "title": "Order Total" },
187
- "y": { "aggregate": "count", "type": "quantitative", "title": "Count" },
188
- "tooltip": [
189
- { "aggregate": "count", "type": "quantitative", "title": "Count" }
190
- ]
191
- }
192
- }
193
- ```
@@ -1,31 +0,0 @@
1
- name: fetch_data
2
- description: Fetch one or more records. Use to find records entities. To use this skill you first need to call get_resource tool to know resource column names. This tool returns only atomic record(s) not capable with any aggregations.
3
- ---
4
-
5
- # Involved tools
6
-
7
- You can use tool `get_resource_data` it returns one or more records and is capable of using filters
8
-
9
- When you only need specific fields, pass `columns` with the exact resource column names you need. This keeps large result sets small. For record links or user-facing record choices, include the primary key and enough display fields, or omit `columns` when you need the full row context.
10
-
11
- # Instructions
12
-
13
- To find specific data record you should use filters. ILIKE filters are preferred when we are unsure the input is clear. Pass raw search text to LIKE and ILIKE filters; never wrap filter values in SQL wildcards such as `%`. You can combine filters with OR if you want to search multiple fields. If user queries one record you should try to fetch up to 5 records and if more then one returned return output them all to user and ask to select one. When you communicate about record with user, show its several most important fields.
14
-
15
- Every record summary must be based on one exact row returned by `get_resource_data`.
16
-
17
- Never combine model/title/name, `_label`, primary key, link, or any field values from different rows.
18
-
19
- Never combine fields from different resources in one candidate.
20
-
21
- If results come from multiple resources, present them as separate groups with the resource label or resourceId.
22
-
23
- If several rows look similar, do not guess which one is "the same" record. Show them separately and ask user to choose.
24
-
25
- For long texts show only several first words and add "..." at the end (only if user did not request this field specifically).
26
-
27
- Never show information about more than 10 records in one message. If a tool returns more than 10 relevant records, summarize the total count if known, show only the 10 most relevant records, and offer to narrow filters, sort differently, or continue with the next 10.
28
-
29
- Also when you communicate with user about record, add related link to this record. Build it as `{ADMIN_BASE_PATH}resource/{resourceId}/show/{primary key}`. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links should always be relative paths and must start with `ADMIN_BASE_PATH`. Do not add an extra slash after `ADMIN_BASE_PATH`.
30
-
31
- Before sending the link, verify that the `resourceId`, `{primary key}`, `_label`, and shown fields come from the same exact returned row.
@@ -1,121 +0,0 @@
1
- name: mutate_data
2
- description: Create/update/delete some record of resource or call actions on one or multiple records
3
- ---
4
-
5
- # Involved tools
6
-
7
- Use `create_record` for creating records.
8
-
9
- Use `update_record` for editing records.
10
-
11
- Use `delete_record` for deleting records.
12
-
13
- Use `start_custom_action` and `start_custom_bulk_action` for resource actions.
14
-
15
- # General rules
16
-
17
- - if there is a dedicated action for some routine (result of `get_resource` tool call, field actions), prefer this to manual updating of records, for example, if you want to approve some comment, prefer calling `approve` action instead of updating `approved` field of comment record (because in action there might be some additional logic like sending notification to user, updating some counters and so on)
18
-
19
- ## Mutation context
20
-
21
- Before performing any state mutation including action calls edit/delete please fetch record which is going to be edited/deleted and show user record in format field → value (show several most important fields which can help user to understand what exactly record he is going to edit or delete).
22
-
23
- Every mutation description must describe one exact fetched row. Never combine `_label`, primary key, link, or field values from different rows or different resources in one description.
24
-
25
- For field values with long texts show only several first words and add "..." at the end.
26
- Also please add related link to record with will be changed. Build it as `{ADMIN_BASE_PATH}resource/{resourceId}/show/{primary key}`. Use _label from `get_resource_data` as anchor text for link (use markdown link). Links should always be relative paths and must start with `ADMIN_BASE_PATH`. Do not add an extra slash after `ADMIN_BASE_PATH`.
27
-
28
- Before calling the mutation tool, verify that the `resourceId`, `{primary key}`, `_label`, and all shown fields come from the same exact fetched row.
29
-
30
- Never show information about more than 10 records in one message. If a mutation plan affects more than 10 records, show only the 10 most important examples plus the total count if known.
31
-
32
- When creating new record, show user all data which you gonna create.
33
-
34
- Do not ask user for textual confirmation. Dangerous tools are approved by the runtime approval UI.
35
-
36
- # Calling actions
37
-
38
- To call action on some record you can use `start_custom_action` tool, or `start_custom_bulk_action` if you need to perform action on several records at once.
39
-
40
- Before calling any of this action you should understand whether this action is allowed. User result of `get_resource` tool call and check `action.allowed` - if this attribute is true or is not exists, assume action is allowed. If this attribute is false, action is not allowed, you should warn user that this action is not allowed for him.
41
-
42
- ### Example
43
-
44
- If you want to block some user you can describe the action by saying:
45
-
46
- ```I am going to block user:
47
- * Username: john_doe
48
- * Email: john_doe@example.com
49
- * IP Country: USA
50
- * Currently blocked: No // show this field only if it exists in user record
51
-
52
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
53
- ```
54
-
55
- ## Updating
56
-
57
- You can use tool `update_record` tool it updates fields of record. To update `allowedActions.edit` should be set to true and
58
- `updated` column `showIn.edit` should be true at the same time. If one of this condition is not met, explain to user that is not allowed to edit
59
-
60
- In addition to instructions above show user the table of edits (old value/new value)
61
-
62
- ### Examples
63
-
64
- For example if you gonna modify user record, please share full user info (not only username but also email, ip country - anything which help adminto check that that is correct user). Message could look like this:
65
-
66
- ```
67
- I am going to update user:
68
- * Username: john_doe
69
- * Email: john_doe@example.com
70
- * IP Country: USA
71
- I am going to change email from john_doe@example.com to new_email@example.com
72
-
73
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
74
- ```
75
-
76
-
77
- ## Deleting
78
-
79
- To delete some record you can use `delete_record` tool. To delete record `allowedActions.delete` should be set to true.
80
-
81
- ### Example
82
-
83
- If you gonna delete user record, please share full user info (not only username but also email, ip country - anything which help adminto check that that is correct user). Message could look like this:
84
-
85
- ```I am going to delete user:
86
- * Username: john_doe
87
- * Email: john_doe@example.com
88
- * Signed up: 2024 Jan 1
89
- * IP Country: USA
90
-
91
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/123)
92
- ```
93
-
94
- ## Creating
95
-
96
- To create new record you can use tool `create_record`. To create record `allowedActions.create` should be set to true.
97
-
98
- When calling `create_record` tool pass only columns which have `showIn.create` set to true and `backendOnly` is not set to true.
99
-
100
- For decimal fields please use string values with dot as decimal separator.
101
-
102
- After creation of new record also show user a link to this record. If several records record were created, show links to all of them in list.
103
-
104
- If more than 10 records were created, show links or details for only 10 of them and summarize the remaining count.
105
-
106
- Omit any pictures or file paths, you are not capable of doing it. If they are not required all is good, if they are required, explain to user that you are not able to create record because of this reason.
107
-
108
- ### Working with dates
109
-
110
- When you create or update date or datetime fields, please use ISO format for this. For example, "2024-01-01" for date and "2024-01-01T12:00:00Z" for datetime. If user provides date in different format, try to parse it and convert to ISO format.
111
-
112
- ### Example
113
-
114
-
115
- ```
116
- I am going to create user:
117
- * Username: john_doe
118
- * Email: john_doe@example.com
119
-
120
- View [John Doe]({ADMIN_BASE_PATH}resource/users/show/421) # 421 is id of new created record
121
- ```
@@ -1,43 +0,0 @@
1
- <template>
2
- <div
3
- v-for="(height, index) in lineHeights"
4
- :key="index"
5
- class="bg-white w-[0.2rem] rounded-sm transition-all duration-100 ease-out"
6
- :style="{ height }"
7
- />
8
- <p v-if="isRecording" class="text-white ml-2">{{ $t('End') }}</p>
9
- </template>
10
-
11
- <script setup lang="ts">
12
- import { computed } from 'vue';
13
-
14
- const IDLE_LINE_HEIGHTS = [0.5, 1, 0.75, 0.5];
15
- const RECORDING_LINE_WEIGHTS = [0.45, 1, 0.75, 0.9, 0.55];
16
- const MIN_RECORDING_HEIGHT = 0.25;
17
- const MAX_RECORDING_DELTA = 0.9;
18
-
19
- const props = defineProps<{
20
- showAnimation: boolean;
21
- isRecording: boolean;
22
- amplitude: number;
23
- }>();
24
-
25
- const normalizedAmplitude = computed(() => {
26
- if (!props.isRecording || !props.showAnimation) {
27
- return 0;
28
- }
29
-
30
- return Math.min(Math.max(props.amplitude, 0), 1);
31
- });
32
-
33
- const lineHeights = computed(() => {
34
- if (!props.isRecording) {
35
- return IDLE_LINE_HEIGHTS.map((height) => `${height}rem`);
36
- }
37
-
38
- return RECORDING_LINE_WEIGHTS.map((weight) => {
39
- const height = MIN_RECORDING_HEIGHT + normalizedAmplitude.value * MAX_RECORDING_DELTA * weight;
40
- return `${height}rem`;
41
- });
42
- });
43
- </script>
@@ -1,185 +0,0 @@
1
- <template>
2
- <div
3
- v-show="!agentStore.isResponseInProgress || isAudioChatMode"
4
- class="absolute bottom-2 flex items-center justify-center z-10 gap-4"
5
- :class="[!agentStore.isAudioChatMode ? 'right-16': agentStore.isMobile ? 'right-1/2 translate-x-1/2' : 'right-1/2 translate-x-1/2']"
6
- >
7
- <button
8
- v-if="isAudioChatMode && microphoneButtonMode === 'generating'"
9
- class="bg-red-500 hover:bg-red-600 dark:bg-red-700 dark:hover:bg-red-800 h-9 flex items-center justify-center rounded-full gap-2 text-white px-4"
10
- @click="stopCurrentGeneration()"
11
- >
12
- <div class="w-3 h-3 bg-white rounded-full"/>
13
- {{ $t('Stop') }}
14
- </button>
15
- <button
16
- v-else
17
- class="h-9 bg-lightPrimary dark:bg-darkPrimary
18
- hover:opacity-90 rounded-full flex items-center justify-center
19
- transition-all duration-300 ease-in-out overflow-hidden"
20
- :class="[isAudioChatMode ? 'w-32 px-2': 'w-9']"
21
- @click="toggleChatMode"
22
- >
23
- <div class="w-5 h-5 flex items-center justify-center">
24
- <div v-if="microphoneButtonMode === 'listen' || microphoneButtonMode === 'off'" class="flex justify-evenly items-center gap-[0.1rem]">
25
- <AudioLines
26
- :showAnimation="showAudioWavesAnimation"
27
- :isRecording="microphoneButtonMode === 'listen'"
28
- :amplitude="audioAmplitude"
29
- />
30
- </div>
31
- <div v-else-if="microphoneButtonMode === 'generating'" class="flex items-center justify-center gap-2 text-white text-sm">
32
- <span class="w-3 h-3 bg-white rounded-sm" />
33
- {{ $t('End') }}
34
- </div>
35
- <Spinner v-else class="w-4 h-4 text-lightButtonsText dark:text-darkButtonsText fill-lightButtonsBackground dark:fill-darkPrimary" />
36
- </div>
37
- </button>
38
- </div>
39
- </template>
40
-
41
-
42
- <script setup lang="ts">
43
- import { computed, onMounted, onBeforeUnmount, ref, watch } from 'vue';
44
- import debounce from 'lodash.debounce';
45
- import { requestMicAndStartVAD, stopUserMedia, getRecord } from './voiceActivityDetection';
46
- import { Spinner } from '@/afcl'
47
- import { storeToRefs } from 'pinia';
48
- import { useAgentStore } from '../composables/useAgentStore';
49
- import { useAgentAudio } from '../composables/useAgentAudio';
50
- import AudioLines from './AudioLines.vue';
51
-
52
- const agentStore = useAgentStore();
53
- const agentAudio = useAgentAudio();
54
- const { sendAudioToServerAndHandleResponse } = agentAudio;
55
- const { stopGenerationAndAudio } = agentAudio;
56
- const { stopCurrentAudioPlayback } = agentAudio;
57
- const { agentAudioMode } = storeToRefs(agentAudio);
58
- const { unlockAudio } = agentAudio;
59
- const microphoneButtonMode = ref<'off' | 'listen' | 'transcribing' | 'generating'>('off');
60
- const showAudioWavesAnimation = ref(false);
61
- const audioAmplitude = ref(0);
62
- const hideAnimationDebounced = debounce(() => {
63
- showAudioWavesAnimation.value = false;
64
- }, 100);
65
- const sendUserRecordDebounced = debounce(() => {
66
- sendRecordForTranscription();
67
- }, 500);
68
-
69
- const isAudioChatMode = computed(() => agentStore.isAudioChatMode);
70
-
71
- onMounted(() => {
72
- agentStore.registerOnBeforeChatCloseCallback(async () => {
73
- if(agentStore.isAudioChatMode) {
74
- onStopRecording();
75
- resetAll();
76
- agentStore.setIsAudioChatMode(false);
77
- }
78
- });
79
- });
80
-
81
- watch(agentAudioMode, async (newVal) => {
82
- if(newVal === 'streaming') {
83
- stopCurrentAudioPlayback(true);
84
- microphoneButtonMode.value = 'generating';
85
- } else if (newVal === 'transcribing') {
86
- microphoneButtonMode.value = 'transcribing';
87
- } else if (newVal === 'fetchingAudio') {
88
- //Generation is done, waiting for audio to be ready
89
- } else if (newVal === 'playingAgentResponse') {
90
- // Audio is playing'
91
- } else if (newVal === 'readyToRespond') {
92
- if(isAudioChatMode.value) {
93
- microphoneButtonMode.value = 'listen';
94
- await unlockAudio();
95
- await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
96
- agentAudio.playBeep(1000);
97
- } else {
98
- microphoneButtonMode.value = 'off';
99
- }
100
- }
101
- })
102
-
103
- function stopCurrentGeneration() {
104
- stopGenerationAndAudio();
105
- agentAudio.playBeep(1000);
106
- }
107
-
108
- function toggleChatMode() {
109
- agentStore.setIsAudioChatMode(!isAudioChatMode.value);
110
- if (isAudioChatMode.value) {
111
- onStartRecording();
112
- } else {
113
- resetAll();
114
- onStopRecording();
115
- }
116
- }
117
-
118
- async function onStartRecording() {
119
- await unlockAudio();
120
- await requestMicAndStartVAD(saidSomething, stopRecording, onAnySound);
121
- microphoneButtonMode.value = 'listen';
122
- agentAudio.playBeep(1000);
123
- }
124
-
125
- function onStopRecording() {
126
- agentAudio.playBeep(600);
127
- stopUserMedia();
128
- audioAmplitude.value = 0;
129
- showAudioWavesAnimation.value = false;
130
- }
131
-
132
- function resetAll() {
133
- stopGenerationAndAudio();
134
- microphoneButtonMode.value = 'off';
135
- audioAmplitude.value = 0;
136
- showAudioWavesAnimation.value = false;
137
- hideAnimationDebounced.cancel();
138
- sendUserRecordDebounced.cancel();
139
- }
140
-
141
-
142
- function saidSomething() {
143
- showAudioWavesAnimation.value = true;
144
- hideAnimationDebounced();
145
- sendUserRecordDebounced();
146
- }
147
-
148
- function stopRecording() {
149
- hideAnimationDebounced.cancel();
150
- sendUserRecordDebounced.cancel();
151
- }
152
-
153
- function onAnySound(amplitude: number) {
154
- audioAmplitude.value = Math.min(Math.max(amplitude, 0), 1);
155
-
156
- if(amplitude < 0.01) {
157
- audioAmplitude.value = 0;
158
- showAudioWavesAnimation.value = false;
159
- return;
160
- }
161
- showAudioWavesAnimation.value = true;
162
- hideAnimationDebounced.cancel();
163
- }
164
-
165
- async function sendRecordForTranscription() {
166
- showAudioWavesAnimation.value = false;
167
- const recordBlob = await getRecord();
168
- if (recordBlob) {
169
- onStopRecording();
170
- await sendAudioToServerAndHandleResponse(recordBlob);
171
- } else {
172
- console.error('No audio recorded');
173
- }
174
- }
175
-
176
- onBeforeUnmount(() => {
177
- stopUserMedia();
178
- agentStore.setIsAudioChatMode(false);
179
- onStopRecording();
180
- hideAnimationDebounced.cancel();
181
- sendUserRecordDebounced.cancel();
182
- });
183
-
184
-
185
- </script>
@@ -1,22 +0,0 @@
1
- declare module 'voice-activity-detection' {
2
- type VADOptions = {
3
- fftSize: number,
4
- bufferLen: number,
5
- smoothingTimeConstant: number,
6
- minCaptureFreq: number, // in Hz
7
- maxCaptureFreq: number, // in Hz
8
- noiseCaptureDuration: number, // in ms
9
- minNoiseLevel: number, // from 0 to 1
10
- maxNoiseLevel: number, // from 0 to 1
11
- avgNoiseMultiplier: number, // from 0 to 1
12
- onVoiceStart?: () => void;
13
- onVoiceStop?: () => void;
14
- onUpdate?: (value: number) => void;
15
- };
16
-
17
- export default function vad(
18
- audioContext: AudioContext,
19
- stream: MediaStream,
20
- options: VADOptions,
21
- ): void;
22
- }