@pikku/core 0.12.63 → 0.12.64

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 (198) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/dist/dev/hot-reload.js +13 -55
  3. package/dist/dev/module-runner.d.ts +14 -0
  4. package/dist/dev/module-runner.js +59 -0
  5. package/dist/dev/reload-meta.d.ts +13 -0
  6. package/dist/dev/reload-meta.js +22 -0
  7. package/dist/errors/errors.d.ts +12 -0
  8. package/dist/errors/errors.js +19 -0
  9. package/dist/function/function-runner.d.ts +5 -5
  10. package/dist/function/function-runner.js +39 -111
  11. package/dist/function/functions.types.d.ts +17 -7
  12. package/dist/index.d.ts +5 -1
  13. package/dist/index.js +3 -1
  14. package/dist/middleware/auth-apikey.d.ts +1 -0
  15. package/dist/middleware/auth-bearer.d.ts +1 -0
  16. package/dist/middleware/auth-cookie.d.ts +1 -0
  17. package/dist/middleware/cors.d.ts +1 -0
  18. package/dist/middleware/index.d.ts +1 -1
  19. package/dist/middleware/index.js +1 -1
  20. package/dist/middleware/remote-auth.d.ts +1 -0
  21. package/dist/middleware/telemetry.d.ts +2 -0
  22. package/dist/middleware/timeout.d.ts +1 -0
  23. package/dist/permissions.d.ts +32 -25
  24. package/dist/permissions.js +104 -185
  25. package/dist/pikku-state.js +0 -2
  26. package/dist/scopes.d.ts +17 -0
  27. package/dist/scopes.js +59 -0
  28. package/dist/services/ai-embedding-service.d.ts +31 -0
  29. package/dist/services/ai-embedding-service.js +1 -0
  30. package/dist/services/credential-wire-service.d.ts +3 -1
  31. package/dist/services/credential-wire-service.js +10 -4
  32. package/dist/services/index.d.ts +4 -0
  33. package/dist/services/index.js +2 -0
  34. package/dist/services/meta-service.d.ts +15 -2
  35. package/dist/services/meta-service.js +51 -1
  36. package/dist/services/queue-webhook-service.d.ts +55 -0
  37. package/dist/services/queue-webhook-service.js +136 -0
  38. package/dist/services/scope-service.d.ts +67 -0
  39. package/dist/services/scope-service.js +1 -0
  40. package/dist/services/typed-secret-service.d.ts +8 -0
  41. package/dist/services/typed-secret-service.js +39 -4
  42. package/dist/services/webhook-service.d.ts +140 -0
  43. package/dist/services/webhook-service.js +44 -0
  44. package/dist/services/workflow-service.d.ts +7 -0
  45. package/dist/types/core.types.d.ts +34 -6
  46. package/dist/types/state.types.d.ts +20 -2
  47. package/dist/utils/hmac.d.ts +16 -0
  48. package/dist/utils/hmac.js +26 -0
  49. package/dist/utils/safe-fetch.d.ts +51 -0
  50. package/dist/utils/safe-fetch.js +192 -0
  51. package/dist/wirings/ai-agent/ai-agent-agui.d.ts +84 -0
  52. package/dist/wirings/ai-agent/ai-agent-agui.js +305 -0
  53. package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +41 -1
  54. package/dist/wirings/ai-agent/ai-agent-prepare.js +146 -6
  55. package/dist/wirings/ai-agent/ai-agent-runner.js +6 -1
  56. package/dist/wirings/ai-agent/ai-agent-stream.js +61 -10
  57. package/dist/wirings/ai-agent/ai-agent.types.d.ts +27 -1
  58. package/dist/wirings/ai-agent/index.d.ts +1 -0
  59. package/dist/wirings/ai-agent/index.js +1 -0
  60. package/dist/wirings/ai-agent/voice-input.d.ts +1 -0
  61. package/dist/wirings/ai-agent/voice-input.js +2 -38
  62. package/dist/wirings/ai-agent/voice-output.d.ts +1 -0
  63. package/dist/wirings/channel/channel-common.js +0 -1
  64. package/dist/wirings/channel/channel-handler.js +1 -4
  65. package/dist/wirings/channel/channel-middleware-runner.d.ts +12 -0
  66. package/dist/wirings/channel/channel-middleware-runner.js +34 -19
  67. package/dist/wirings/channel/channel.types.d.ts +2 -6
  68. package/dist/wirings/cli/cli-runner.js +0 -2
  69. package/dist/wirings/cli/cli.types.d.ts +1 -2
  70. package/dist/wirings/http/http-routes.js +0 -3
  71. package/dist/wirings/http/http-runner.d.ts +9 -29
  72. package/dist/wirings/http/http-runner.js +9 -34
  73. package/dist/wirings/http/http.types.d.ts +1 -9
  74. package/dist/wirings/mcp/mcp-runner.js +0 -2
  75. package/dist/wirings/mcp/mcp.types.d.ts +5 -11
  76. package/dist/wirings/oauth2/index.d.ts +0 -3
  77. package/dist/wirings/oauth2/index.js +1 -2
  78. package/dist/wirings/rpc/addon-runner.d.ts +28 -0
  79. package/dist/wirings/rpc/addon-runner.js +173 -0
  80. package/dist/wirings/rpc/index.d.ts +5 -1
  81. package/dist/wirings/rpc/index.js +3 -1
  82. package/dist/wirings/rpc/remote-addon-auth.d.ts +26 -0
  83. package/dist/wirings/rpc/remote-addon-auth.js +43 -0
  84. package/dist/wirings/rpc/rpc-runner.d.ts +19 -0
  85. package/dist/wirings/rpc/rpc-runner.js +109 -3
  86. package/dist/wirings/rpc/rpc-types.d.ts +15 -1
  87. package/dist/wirings/rpc/wire-addon.js +9 -0
  88. package/dist/wirings/rpc/wire-remote-addon.d.ts +47 -0
  89. package/dist/wirings/rpc/wire-remote-addon.js +19 -0
  90. package/dist/wirings/scope/index.d.ts +3 -0
  91. package/dist/wirings/scope/index.js +2 -0
  92. package/dist/wirings/scope/scope.types.d.ts +39 -0
  93. package/dist/wirings/scope/scope.types.js +1 -0
  94. package/dist/wirings/scope/validate-scope-definitions.d.ts +16 -0
  95. package/dist/wirings/scope/validate-scope-definitions.js +76 -0
  96. package/dist/wirings/scope/wire-scope.d.ts +33 -0
  97. package/dist/wirings/scope/wire-scope.js +32 -0
  98. package/dist/wirings/workflow/dsl/index.d.ts +1 -1
  99. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +53 -1
  100. package/dist/wirings/workflow/graph/graph-node.d.ts +2 -0
  101. package/dist/wirings/workflow/graph/graph-runner.js +3 -0
  102. package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +6 -0
  103. package/dist/wirings/workflow/graph/wire-workflow-graph.js +1 -0
  104. package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +5 -0
  105. package/dist/wirings/workflow/index.d.ts +2 -2
  106. package/dist/wirings/workflow/index.js +1 -1
  107. package/dist/wirings/workflow/pikku-workflow-service.d.ts +51 -1
  108. package/dist/wirings/workflow/pikku-workflow-service.js +171 -0
  109. package/dist/wirings/workflow/workflow.types.d.ts +1 -1
  110. package/package.json +5 -1
  111. package/run-tests.sh +1 -0
  112. package/src/dev/hot-reload.ts +13 -68
  113. package/src/dev/module-runner.test.ts +169 -0
  114. package/src/dev/module-runner.ts +103 -0
  115. package/src/dev/reload-meta.test.ts +31 -2
  116. package/src/dev/reload-meta.ts +26 -0
  117. package/src/errors/errors.ts +24 -0
  118. package/src/function/function-runner.test.ts +276 -142
  119. package/src/function/function-runner.ts +52 -145
  120. package/src/function/functions.types.ts +28 -38
  121. package/src/index.ts +8 -6
  122. package/src/middleware/index.ts +1 -5
  123. package/src/permissions.test.ts +153 -372
  124. package/src/permissions.ts +139 -259
  125. package/src/pikku-state.ts +0 -2
  126. package/src/scopes.test.ts +167 -0
  127. package/src/scopes.ts +69 -0
  128. package/src/services/ai-embedding-service.ts +31 -0
  129. package/src/services/credential-wire-service.ts +10 -4
  130. package/src/services/index.ts +20 -0
  131. package/src/services/meta-service.ts +68 -3
  132. package/src/services/queue-webhook-service.test.ts +408 -0
  133. package/src/services/queue-webhook-service.ts +182 -0
  134. package/src/services/scope-service.ts +75 -0
  135. package/src/services/typed-secret-service.test.ts +35 -0
  136. package/src/services/typed-secret-service.ts +39 -4
  137. package/src/services/webhook-service.ts +180 -0
  138. package/src/services/workflow-service.ts +7 -0
  139. package/src/types/core.types.ts +42 -14
  140. package/src/types/state.types.ts +23 -3
  141. package/src/utils/hmac.ts +27 -0
  142. package/src/utils/safe-fetch.test.ts +373 -0
  143. package/src/utils/safe-fetch.ts +213 -0
  144. package/src/wirings/ai-agent/ai-agent-agui.test.ts +1127 -0
  145. package/src/wirings/ai-agent/ai-agent-agui.ts +386 -0
  146. package/src/wirings/ai-agent/ai-agent-prepare.test.ts +308 -0
  147. package/src/wirings/ai-agent/ai-agent-prepare.ts +192 -8
  148. package/src/wirings/ai-agent/ai-agent-runner.test.ts +48 -1
  149. package/src/wirings/ai-agent/ai-agent-runner.ts +21 -0
  150. package/src/wirings/ai-agent/ai-agent-stream.test.ts +198 -10
  151. package/src/wirings/ai-agent/ai-agent-stream.ts +84 -10
  152. package/src/wirings/ai-agent/ai-agent.types.ts +28 -0
  153. package/src/wirings/ai-agent/index.ts +1 -0
  154. package/src/wirings/ai-agent/voice-input.ts +6 -35
  155. package/src/wirings/channel/channel-common.ts +0 -1
  156. package/src/wirings/channel/channel-handler.ts +1 -9
  157. package/src/wirings/channel/channel-middleware-runner.test.ts +28 -2
  158. package/src/wirings/channel/channel-middleware-runner.ts +39 -27
  159. package/src/wirings/channel/channel.types.ts +0 -6
  160. package/src/wirings/cli/cli-runner.ts +0 -2
  161. package/src/wirings/cli/cli.types.ts +0 -2
  162. package/src/wirings/http/http-routes.ts +0 -3
  163. package/src/wirings/http/http-runner.test.ts +1 -11
  164. package/src/wirings/http/http-runner.ts +16 -39
  165. package/src/wirings/http/http.types.ts +1 -10
  166. package/src/wirings/mcp/mcp-runner.ts +0 -2
  167. package/src/wirings/mcp/mcp.types.ts +3 -11
  168. package/src/wirings/oauth2/index.ts +0 -3
  169. package/src/wirings/rpc/addon-runner.ts +233 -0
  170. package/src/wirings/rpc/index.ts +17 -1
  171. package/src/wirings/rpc/remote-addon-auth.ts +69 -0
  172. package/src/wirings/rpc/rpc-runner.test.ts +319 -16
  173. package/src/wirings/rpc/rpc-runner.ts +155 -3
  174. package/src/wirings/rpc/rpc-types.ts +16 -5
  175. package/src/wirings/rpc/wire-addon.test.ts +6 -3
  176. package/src/wirings/rpc/wire-addon.ts +9 -0
  177. package/src/wirings/rpc/wire-remote-addon.ts +57 -0
  178. package/src/wirings/scope/index.ts +14 -0
  179. package/src/wirings/scope/scope.test.ts +135 -0
  180. package/src/wirings/scope/scope.types.ts +44 -0
  181. package/src/wirings/scope/validate-scope-definitions.ts +110 -0
  182. package/src/wirings/scope/wire-scope.ts +34 -0
  183. package/src/wirings/workflow/dsl/index.ts +4 -0
  184. package/src/wirings/workflow/dsl/workflow-dsl.types.ts +61 -0
  185. package/src/wirings/workflow/graph/graph-node.ts +2 -0
  186. package/src/wirings/workflow/graph/graph-runner.test.ts +58 -0
  187. package/src/wirings/workflow/graph/graph-runner.ts +3 -0
  188. package/src/wirings/workflow/graph/wire-workflow-graph.ts +7 -0
  189. package/src/wirings/workflow/graph/workflow-graph.types.ts +5 -0
  190. package/src/wirings/workflow/index.ts +5 -0
  191. package/src/wirings/workflow/pikku-workflow-service.test.ts +341 -0
  192. package/src/wirings/workflow/pikku-workflow-service.ts +236 -0
  193. package/src/wirings/workflow/workflow-step-session.test.ts +21 -5
  194. package/src/wirings/workflow/workflow.types.ts +4 -0
  195. package/tsconfig.tsbuildinfo +1 -1
  196. package/src/wirings/oauth2/oauth2-client.test.ts +0 -930
  197. package/src/wirings/oauth2/oauth2-client.ts +0 -331
  198. package/src/wirings/oauth2/oauth2-routes.ts +0 -234
@@ -0,0 +1,386 @@
1
+ import type { AIStreamChannel, AIStreamEvent } from './ai-agent.types.js'
2
+ import { randomUUID } from './ai-agent-utils.js'
3
+
4
+ type AGUIEvent =
5
+ | { type: 'TEXT_MESSAGE_START'; messageId: string }
6
+ | { type: 'TEXT_MESSAGE_CONTENT'; messageId: string; delta: string }
7
+ | { type: 'TEXT_MESSAGE_END'; messageId: string }
8
+ | { type: 'TOOL_CALL_START'; toolCallId: string; toolCallName: string }
9
+ | { type: 'TOOL_CALL_ARGS'; toolCallId: string; delta: string }
10
+ | { type: 'TOOL_CALL_END'; toolCallId: string; toolCallName: string }
11
+ | {
12
+ type: 'TOOL_CALL_RESULT'
13
+ messageId: string
14
+ toolCallId: string
15
+ role: 'tool'
16
+ content: string
17
+ }
18
+ | { type: 'THINKING_START' }
19
+ | { type: 'THINKING_TEXT_MESSAGE_START'; messageId: string }
20
+ | { type: 'THINKING_TEXT_MESSAGE_CONTENT'; messageId: string; delta: string }
21
+ | { type: 'THINKING_TEXT_MESSAGE_END'; messageId: string }
22
+ | { type: 'THINKING_END' }
23
+ | { type: 'RUN_STARTED'; threadId: string; runId: string }
24
+ | {
25
+ type: 'RUN_FINISHED'
26
+ threadId: string
27
+ runId: string
28
+ model?: string
29
+ usage?: {
30
+ promptTokens: number
31
+ completionTokens: number
32
+ totalTokens: number
33
+ }
34
+ }
35
+ | { type: 'RUN_ERROR'; message: string; code?: string }
36
+ | { type: 'STEP_STARTED'; stepName: string }
37
+ | { type: 'STEP_FINISHED'; stepName: string }
38
+ | { type: 'CUSTOM'; name: string; value: unknown }
39
+
40
+ export type { AGUIEvent }
41
+
42
+ export type AGUIChannelOptions = {
43
+ threadId?: string
44
+ runId?: string
45
+ /**
46
+ * Late-bound runId source, resolved when the run is opened (first event).
47
+ * Lets the stream path report the AIRunStateService runId on RUN_STARTED
48
+ * even though that id is only created after the channel is wrapped.
49
+ */
50
+ getRunId?: () => string | undefined
51
+ }
52
+
53
+ function resultToString(result: unknown): string {
54
+ if (typeof result === 'string') return result
55
+ try {
56
+ return JSON.stringify(result, (_key, val) =>
57
+ typeof val === 'bigint' ? val.toString() : val
58
+ )
59
+ } catch {
60
+ return String(result)
61
+ }
62
+ }
63
+
64
+ export function wrapChannelWithAGUI(
65
+ inner: AIStreamChannel,
66
+ options?: AGUIChannelOptions
67
+ ): AIStreamChannel {
68
+ const threadId = options?.threadId ?? randomUUID()
69
+ let runId: string | null = options?.runId ?? null
70
+
71
+ function resolveRunId(): string {
72
+ if (!runId) {
73
+ runId = options?.getRunId?.() ?? randomUUID()
74
+ }
75
+ return runId
76
+ }
77
+
78
+ let textMessageId: string | null = null
79
+ let thinkingMessageId: string | null = null
80
+ let openStepName: string | null = null
81
+ let stepSeq = 0
82
+ let runStartedSent = false
83
+ let terminal = false
84
+ let sawUsage = false
85
+ let usageModel: string | undefined
86
+ const usageTotals = { input: 0, output: 0 }
87
+
88
+ // The AG-UI client rejects any event arriving before RUN_STARTED, so the
89
+ // run is opened lazily with the first translated event.
90
+ function send(event: AGUIEvent): void {
91
+ if (!runStartedSent) {
92
+ runStartedSent = true
93
+ inner.send({
94
+ type: 'RUN_STARTED',
95
+ threadId,
96
+ runId: resolveRunId(),
97
+ } as unknown as AIStreamEvent)
98
+ }
99
+ inner.send(event as unknown as AIStreamEvent)
100
+ }
101
+
102
+ function endTextMessage(): void {
103
+ if (textMessageId) {
104
+ send({ type: 'TEXT_MESSAGE_END', messageId: textMessageId })
105
+ textMessageId = null
106
+ }
107
+ }
108
+
109
+ function endThinkingMessage(): void {
110
+ if (thinkingMessageId) {
111
+ send({ type: 'THINKING_TEXT_MESSAGE_END', messageId: thinkingMessageId })
112
+ send({ type: 'THINKING_END' })
113
+ thinkingMessageId = null
114
+ }
115
+ }
116
+
117
+ function endStep(): void {
118
+ if (openStepName) {
119
+ send({ type: 'STEP_FINISHED', stepName: openStepName })
120
+ openStepName = null
121
+ }
122
+ }
123
+
124
+ function ensureTextMessage(): string {
125
+ if (!textMessageId) {
126
+ textMessageId = randomUUID()
127
+ send({ type: 'TEXT_MESSAGE_START', messageId: textMessageId })
128
+ }
129
+ return textMessageId
130
+ }
131
+
132
+ function ensureThinkingMessage(): string {
133
+ if (!thinkingMessageId) {
134
+ thinkingMessageId = randomUUID()
135
+ send({ type: 'THINKING_START' })
136
+ send({
137
+ type: 'THINKING_TEXT_MESSAGE_START',
138
+ messageId: thinkingMessageId,
139
+ })
140
+ }
141
+ return thinkingMessageId
142
+ }
143
+
144
+ // The AG-UI client treats RUN_FINISHED as terminal and rejects everything
145
+ // after it, so it is emitted exactly once — on 'done' — with the usage
146
+ // accumulated across all steps (per-step 'usage' events must NOT finish
147
+ // the run: on multi-step tool runs later steps would arrive after
148
+ // RUN_FINISHED and the client would drop the whole stream).
149
+ function finishRun(): void {
150
+ endTextMessage()
151
+ endThinkingMessage()
152
+ endStep()
153
+ send({
154
+ type: 'RUN_FINISHED',
155
+ threadId,
156
+ runId: resolveRunId(),
157
+ ...(usageModel ? { model: usageModel } : {}),
158
+ ...(sawUsage
159
+ ? {
160
+ usage: {
161
+ promptTokens: usageTotals.input,
162
+ completionTokens: usageTotals.output,
163
+ totalTokens: usageTotals.input + usageTotals.output,
164
+ },
165
+ }
166
+ : {}),
167
+ })
168
+ terminal = true
169
+ }
170
+
171
+ return {
172
+ channelId: inner.channelId,
173
+ openingData: inner.openingData,
174
+ get state() {
175
+ return inner.state
176
+ },
177
+ setState: (s) => inner.setState(s),
178
+ getState: () => inner.getState(),
179
+ clearState: () => inner.clearState(),
180
+ sendBinary: (data) => inner.sendBinary(data),
181
+ close: () => inner.close(),
182
+
183
+ send: (event: AIStreamEvent) => {
184
+ if (terminal) return
185
+
186
+ switch (event.type) {
187
+ case 'text-delta': {
188
+ endThinkingMessage()
189
+ const id = ensureTextMessage()
190
+ send({
191
+ type: 'TEXT_MESSAGE_CONTENT',
192
+ messageId: id,
193
+ delta: event.text,
194
+ })
195
+ break
196
+ }
197
+
198
+ case 'reasoning-delta': {
199
+ endTextMessage()
200
+ const id = ensureThinkingMessage()
201
+ send({
202
+ type: 'THINKING_TEXT_MESSAGE_CONTENT',
203
+ messageId: id,
204
+ delta: event.text,
205
+ })
206
+ break
207
+ }
208
+
209
+ case 'tool-call': {
210
+ endTextMessage()
211
+ endThinkingMessage()
212
+ send({
213
+ type: 'TOOL_CALL_START',
214
+ toolCallId: event.toolCallId,
215
+ toolCallName: event.toolName,
216
+ })
217
+ send({
218
+ type: 'TOOL_CALL_ARGS',
219
+ toolCallId: event.toolCallId,
220
+ delta: resultToString(event.args) || '{}',
221
+ })
222
+ send({
223
+ type: 'TOOL_CALL_END',
224
+ toolCallId: event.toolCallId,
225
+ toolCallName: event.toolName,
226
+ })
227
+ break
228
+ }
229
+
230
+ case 'tool-result': {
231
+ send({
232
+ type: 'TOOL_CALL_RESULT',
233
+ messageId: randomUUID(),
234
+ toolCallId: event.toolCallId,
235
+ role: 'tool',
236
+ content: resultToString(event.result),
237
+ })
238
+ break
239
+ }
240
+
241
+ case 'usage': {
242
+ endTextMessage()
243
+ endThinkingMessage()
244
+ sawUsage = true
245
+ usageTotals.input += event.tokens.input
246
+ usageTotals.output += event.tokens.output
247
+ if (event.model) usageModel = event.model
248
+ break
249
+ }
250
+
251
+ case 'error': {
252
+ endTextMessage()
253
+ endThinkingMessage()
254
+ endStep()
255
+ send({ type: 'RUN_ERROR', message: event.message })
256
+ terminal = true
257
+ break
258
+ }
259
+
260
+ case 'done': {
261
+ finishRun()
262
+ break
263
+ }
264
+
265
+ // Step names must be unique among active steps on the client and
266
+ // sub-agents reuse step numbers on the shared channel, so each
267
+ // step-start closes the previous step and gets a sequential name.
268
+ case 'step-start': {
269
+ endTextMessage()
270
+ endThinkingMessage()
271
+ endStep()
272
+ stepSeq += 1
273
+ openStepName = `${event.agent ?? 'step'}#${stepSeq}`
274
+ send({ type: 'STEP_STARTED', stepName: openStepName })
275
+ break
276
+ }
277
+
278
+ case 'approval-request': {
279
+ endTextMessage()
280
+ endThinkingMessage()
281
+ send({
282
+ type: 'CUSTOM',
283
+ name: 'pikku:approval-request',
284
+ value: {
285
+ toolCallId: event.toolCallId,
286
+ toolName: event.toolName,
287
+ args: event.args,
288
+ reason: event.reason,
289
+ runId: event.runId,
290
+ agent: event.agent,
291
+ session: event.session,
292
+ },
293
+ })
294
+ break
295
+ }
296
+
297
+ case 'credential-request': {
298
+ endTextMessage()
299
+ endThinkingMessage()
300
+ send({
301
+ type: 'CUSTOM',
302
+ name: 'pikku:credential-request',
303
+ value: {
304
+ toolCallId: event.toolCallId,
305
+ toolName: event.toolName,
306
+ args: event.args,
307
+ credentialName: event.credentialName,
308
+ credentialType: event.credentialType,
309
+ connectUrl: event.connectUrl,
310
+ runId: event.runId,
311
+ agent: event.agent,
312
+ session: event.session,
313
+ },
314
+ })
315
+ break
316
+ }
317
+
318
+ case 'generative-ui': {
319
+ send({
320
+ type: 'CUSTOM',
321
+ name: 'pikku:generative-ui',
322
+ value: { spec: event.spec },
323
+ })
324
+ break
325
+ }
326
+
327
+ case 'data': {
328
+ send({
329
+ type: 'CUSTOM',
330
+ name: 'pikku:data',
331
+ value: { name: event.name, data: event.data },
332
+ })
333
+ break
334
+ }
335
+
336
+ case 'workflow-created': {
337
+ send({
338
+ type: 'CUSTOM',
339
+ name: 'pikku:workflow-created',
340
+ value: { workflowName: event.workflowName, graph: event.graph },
341
+ })
342
+ break
343
+ }
344
+
345
+ case 'agent-call': {
346
+ send({
347
+ type: 'CUSTOM',
348
+ name: 'pikku:agent-call',
349
+ value: {
350
+ agentName: event.agentName,
351
+ session: event.session,
352
+ input: event.input,
353
+ },
354
+ })
355
+ break
356
+ }
357
+
358
+ case 'agent-result': {
359
+ send({
360
+ type: 'CUSTOM',
361
+ name: 'pikku:agent-result',
362
+ value: {
363
+ agentName: event.agentName,
364
+ session: event.session,
365
+ result: event.result,
366
+ },
367
+ })
368
+ break
369
+ }
370
+
371
+ case 'suspended': {
372
+ send({
373
+ type: 'CUSTOM',
374
+ name: 'pikku:suspended',
375
+ value: { reason: event.reason, missingRpcs: event.missingRpcs },
376
+ })
377
+ break
378
+ }
379
+
380
+ case 'audio-delta':
381
+ case 'audio-done':
382
+ break
383
+ }
384
+ },
385
+ }
386
+ }