@botpress/runtime 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ var TranscriptItemSchema = z.object({
19
19
  payload: z.unknown().optional()
20
20
  });
21
21
  var TranscriptSchema = z.array(TranscriptItemSchema);
22
+
22
23
  // src/runtime/tracked-state-schema.ts
23
24
  import { z as z2 } from "@botpress/sdk";
24
25
  var TrackedStateSchema = z2.object({
@@ -28,6 +29,7 @@ var TrackedStateSchema = z2.object({
28
29
  z2.object({ type: z2.literal("file"), key: z2.string() })
29
30
  ])
30
31
  });
32
+
31
33
  // src/runtime/events.ts
32
34
  import { z as z3 } from "@botpress/sdk";
33
35
  var WorkflowCallbackEvent = {
@@ -71,16 +73,16 @@ var WorkflowDataRequestEvent = {
71
73
  request: z3.string(),
72
74
  message: z3.string(),
73
75
  schema: z3.any()
76
+ // JSON Schema
74
77
  })
75
78
  };
76
79
  export {
77
- WorkflowScheduleEvent,
78
- WorkflowDataRequestEvent,
79
- WorkflowContinueEvent,
80
- WorkflowCallbackEvent,
81
- TranscriptSchema,
80
+ SubworkflowFinished,
82
81
  TrackedStateSchema,
83
- SubworkflowFinished
82
+ TranscriptSchema,
83
+ WorkflowCallbackEvent,
84
+ WorkflowContinueEvent,
85
+ WorkflowDataRequestEvent,
86
+ WorkflowScheduleEvent
84
87
  };
85
-
86
- //# debugId=879B05C756C9EED664756E2164756E21
88
+ //# sourceMappingURL=definition.js.map
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/runtime/chat/transcript.ts", "../src/runtime/tracked-state-schema.ts", "../src/runtime/events.ts"],
4
- "sourcesContent": [
5
- "import { z } from \"@botpress/sdk\";\n\nexport type TranscriptAttachment = {\n type: \"image\";\n url: string;\n};\n\nexport type TranscriptAssistantMessage = {\n id: string;\n role: \"assistant\";\n name?: string;\n createdAt?: string;\n content: string;\n};\n\nexport type TranscriptUserMessage = {\n id: string;\n role: \"user\";\n createdAt?: string;\n name?: string;\n content: string;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptEventMessage = {\n id: string;\n role: \"event\";\n createdAt?: string;\n name: string;\n payload: unknown;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptSummaryMessage = {\n id: string;\n role: \"summary\";\n content: string;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptItem =\n | TranscriptAssistantMessage\n | TranscriptUserMessage\n | TranscriptEventMessage\n | TranscriptSummaryMessage;\n\nconst AttachmentSchema = z.object({\n type: z.literal(\"image\"),\n url: z.string(),\n});\n\n// There's a bug in the bridge, we can't use unions and discriminated unions.\n// The resulting type will be the lowest common denominator and attachments will be stripped\n// So instead we use a single schema that is flexible enough to handle all types of messages\nconst TranscriptItemSchema = z.object({\n id: z.string(),\n role: z.union([\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n z.literal(\"event\"),\n z.literal(\"summary\"),\n ]),\n name: z.string().optional(),\n createdAt: z.string().optional(),\n content: z.string().optional(),\n attachments: z.array(AttachmentSchema).optional(),\n payload: z.unknown().optional(),\n});\n\nexport const TranscriptSchema = z.array(TranscriptItemSchema);\n",
6
- "import { z } from \"@botpress/sdk\";\n\nexport const TrackedStateSchema = z.object({\n value: z.any(),\n location: z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"state\") }),\n z.object({ type: z.literal(\"file\"), key: z.string() }),\n ]),\n});\n",
7
- "import { z } from \"@botpress/sdk\";\n\ntype EventDefinition<T extends string = string> = {\n name: T;\n description?: string;\n schema: z.ZodSchema;\n};\n\nexport const WorkflowCallbackEvent = {\n name: \"workflowCallback\" as const,\n schema: z.object({\n workflow: z.string(),\n workflowId: z.string(),\n target: z.union([\n z.object({\n conversationId: z.string(),\n }),\n z.object({\n workflowId: z.string(),\n }),\n ]),\n status: z.enum([\"completed\", \"failed\", \"canceled\", \"timed_out\"]),\n output: z.any().optional(),\n error: z.string().optional(),\n }),\n} satisfies EventDefinition;\n\nexport const WorkflowScheduleEvent = {\n name: \"workflowSchedule\" as const,\n schema: z.object({\n workflow: z.string(),\n }),\n} satisfies EventDefinition;\n\nexport const WorkflowContinueEvent = {\n name: \"workflowContinue\" as const,\n schema: z.object({}),\n};\n\nexport const SubworkflowFinished = {\n name: \"subworkflowFinished\" as const,\n schema: z.object({}),\n};\n\nexport const WorkflowDataRequestEvent = {\n name: \"workflowDataRequest\" as const,\n schema: z.object({\n workflowId: z.string(),\n workflowName: z.string(),\n stepName: z.string(),\n request: z.string(),\n message: z.string(),\n schema: z.any(), // JSON Schema\n }),\n} satisfies EventDefinition;\n"
8
- ],
9
- "mappings": ";AAAA;AA8CA,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,KAAK,EAAE,OAAO;AAChB,CAAC;AAKD,IAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,IAAI,EAAE,OAAO;AAAA,EACb,MAAM,EAAE,MAAM;AAAA,IACZ,EAAE,QAAQ,WAAW;AAAA,IACrB,EAAE,QAAQ,MAAM;AAAA,IAChB,EAAE,QAAQ,OAAO;AAAA,IACjB,EAAE,QAAQ,SAAS;AAAA,EACrB,CAAC;AAAA,EACD,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,MAAM,gBAAgB,EAAE,SAAS;AAAA,EAChD,SAAS,EAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;AAEM,IAAM,mBAAmB,EAAE,MAAM,oBAAoB;;ACrE5D,cAAS;AAEF,IAAM,qBAAqB,GAAE,OAAO;AAAA,EACzC,OAAO,GAAE,IAAI;AAAA,EACb,UAAU,GAAE,mBAAmB,QAAQ;AAAA,IACrC,GAAE,OAAO,EAAE,MAAM,GAAE,QAAQ,OAAO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664756E2164756E21",
11
- "names": []
12
- }
4
+ "sourcesContent": ["import { z } from \"@botpress/sdk\";\n\nexport type TranscriptAttachment = {\n type: \"image\";\n url: string;\n};\n\nexport type TranscriptAssistantMessage = {\n id: string;\n role: \"assistant\";\n name?: string;\n createdAt?: string;\n content: string;\n};\n\nexport type TranscriptUserMessage = {\n id: string;\n role: \"user\";\n createdAt?: string;\n name?: string;\n content: string;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptEventMessage = {\n id: string;\n role: \"event\";\n createdAt?: string;\n name: string;\n payload: unknown;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptSummaryMessage = {\n id: string;\n role: \"summary\";\n content: string;\n attachments?: Array<TranscriptAttachment>;\n};\n\nexport type TranscriptItem =\n | TranscriptAssistantMessage\n | TranscriptUserMessage\n | TranscriptEventMessage\n | TranscriptSummaryMessage;\n\nconst AttachmentSchema = z.object({\n type: z.literal(\"image\"),\n url: z.string(),\n});\n\n// There's a bug in the bridge, we can't use unions and discriminated unions.\n// The resulting type will be the lowest common denominator and attachments will be stripped\n// So instead we use a single schema that is flexible enough to handle all types of messages\nconst TranscriptItemSchema = z.object({\n id: z.string(),\n role: z.union([\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n z.literal(\"event\"),\n z.literal(\"summary\"),\n ]),\n name: z.string().optional(),\n createdAt: z.string().optional(),\n content: z.string().optional(),\n attachments: z.array(AttachmentSchema).optional(),\n payload: z.unknown().optional(),\n});\n\nexport const TranscriptSchema = z.array(TranscriptItemSchema);\n", "import { z } from \"@botpress/sdk\";\n\nexport const TrackedStateSchema = z.object({\n value: z.any(),\n location: z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"state\") }),\n z.object({ type: z.literal(\"file\"), key: z.string() }),\n ]),\n});\n", "import { z } from \"@botpress/sdk\";\n\ntype EventDefinition<T extends string = string> = {\n name: T;\n description?: string;\n schema: z.ZodSchema;\n};\n\nexport const WorkflowCallbackEvent = {\n name: \"workflowCallback\" as const,\n schema: z.object({\n workflow: z.string(),\n workflowId: z.string(),\n target: z.union([\n z.object({\n conversationId: z.string(),\n }),\n z.object({\n workflowId: z.string(),\n }),\n ]),\n status: z.enum([\"completed\", \"failed\", \"canceled\", \"timed_out\"]),\n output: z.any().optional(),\n error: z.string().optional(),\n }),\n} satisfies EventDefinition;\n\nexport const WorkflowScheduleEvent = {\n name: \"workflowSchedule\" as const,\n schema: z.object({\n workflow: z.string(),\n }),\n} satisfies EventDefinition;\n\nexport const WorkflowContinueEvent = {\n name: \"workflowContinue\" as const,\n schema: z.object({}),\n};\n\nexport const SubworkflowFinished = {\n name: \"subworkflowFinished\" as const,\n schema: z.object({}),\n};\n\nexport const WorkflowDataRequestEvent = {\n name: \"workflowDataRequest\" as const,\n schema: z.object({\n workflowId: z.string(),\n workflowName: z.string(),\n stepName: z.string(),\n request: z.string(),\n message: z.string(),\n schema: z.any(), // JSON Schema\n }),\n} satisfies EventDefinition;\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS;AA8ClB,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,KAAK,EAAE,OAAO;AAChB,CAAC;AAKD,IAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,IAAI,EAAE,OAAO;AAAA,EACb,MAAM,EAAE,MAAM;AAAA,IACZ,EAAE,QAAQ,WAAW;AAAA,IACrB,EAAE,QAAQ,MAAM;AAAA,IAChB,EAAE,QAAQ,OAAO;AAAA,IACjB,EAAE,QAAQ,SAAS;AAAA,EACrB,CAAC;AAAA,EACD,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,aAAa,EAAE,MAAM,gBAAgB,EAAE,SAAS;AAAA,EAChD,SAAS,EAAE,QAAQ,EAAE,SAAS;AAChC,CAAC;AAEM,IAAM,mB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