@qcobro/common 1.24.1 → 1.28.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 (41) hide show
  1. package/dist/config.d.ts +2 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +12 -2
  4. package/dist/config.js.map +1 -1
  5. package/dist/schemas/agentEvaluations.d.ts +619 -0
  6. package/dist/schemas/agentEvaluations.d.ts.map +1 -0
  7. package/dist/schemas/agentEvaluations.js +124 -0
  8. package/dist/schemas/agentEvaluations.js.map +1 -0
  9. package/dist/schemas/index.d.ts +1 -0
  10. package/dist/schemas/index.d.ts.map +1 -1
  11. package/dist/schemas/index.js +1 -0
  12. package/dist/schemas/index.js.map +1 -1
  13. package/dist/schemas/workspaceSettings.d.ts +31 -1
  14. package/dist/schemas/workspaceSettings.d.ts.map +1 -1
  15. package/dist/schemas/workspaceSettings.js +30 -2
  16. package/dist/schemas/workspaceSettings.js.map +1 -1
  17. package/dist/types/agentEvaluations.d.ts +93 -0
  18. package/dist/types/agentEvaluations.d.ts.map +1 -0
  19. package/dist/types/agentEvaluations.js +2 -0
  20. package/dist/types/agentEvaluations.js.map +1 -0
  21. package/dist/types/index.d.ts +1 -0
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/index.js +1 -0
  24. package/dist/types/index.js.map +1 -1
  25. package/dist/types/voiceApplication.d.ts +65 -0
  26. package/dist/types/voiceApplication.d.ts.map +1 -1
  27. package/dist/types/workspaceSettings.d.ts +3 -1
  28. package/dist/types/workspaceSettings.d.ts.map +1 -1
  29. package/dist/utils/index.d.ts +1 -0
  30. package/dist/utils/index.d.ts.map +1 -1
  31. package/dist/utils/index.js +1 -0
  32. package/dist/utils/index.js.map +1 -1
  33. package/dist/utils/money.d.ts +23 -0
  34. package/dist/utils/money.d.ts.map +1 -0
  35. package/dist/utils/money.js +68 -0
  36. package/dist/utils/money.js.map +1 -0
  37. package/dist/utils/outreach.d.ts +2 -0
  38. package/dist/utils/outreach.d.ts.map +1 -1
  39. package/dist/utils/outreach.js +105 -28
  40. package/dist/utils/outreach.js.map +1 -1
  41. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ import { z } from "zod";
2
+ import { createAgentTemplateSchema } from "./agentTemplates.js";
3
+ import { contactOutcomeSchema } from "./contactLog.js";
4
+ /**
5
+ * The account context an eval scenario runs against — author-facing fields only
6
+ * (no id/portfolioId/timestamps). The apiserver fills those bookkeeping fields with
7
+ * synthetic values before calling {@link buildOutreachContext}, so eval scenarios reuse
8
+ * the exact same render/context-building logic as a real dispatch, not a re-implementation.
9
+ */
10
+ export const evalAccountSchema = z.object({
11
+ fullName: z.string().min(1),
12
+ principalAmount: z.number().default(0),
13
+ outstandingBalance: z.number().default(0),
14
+ daysPastDue: z.number().int().default(0),
15
+ termsAmount: z.number().default(0),
16
+ termsFrequency: z.string().optional(),
17
+ termsLength: z.number().int().default(0),
18
+ missedInstallments: z.number().int().default(0),
19
+ lastPaymentDate: z.string().datetime().optional(),
20
+ lastPaymentAmount: z.number().optional(),
21
+ preferredLanguage: z.string().optional(),
22
+ customerSegment: z.string().optional(),
23
+ bestTimeToCall: z.string().optional(),
24
+ currency: z.string().default("USD")
25
+ });
26
+ /** VOICE_AI's text-match assertion, mirroring Fonoster's `EXACT`/`SIMILAR` expectation. */
27
+ export const evalExpectedTextSchema = z.object({
28
+ type: z.enum(["EXACT", "SIMILAR"]),
29
+ response: z.string().min(1)
30
+ });
31
+ /** VOICE_AI's expected-tool-call assertion (e.g. `hangup`), mirroring Fonoster's report shape. */
32
+ export const evalExpectedToolSchema = z.object({
33
+ tool: z.string().min(1),
34
+ parameters: z.record(z.string(), z.unknown()).optional()
35
+ });
36
+ /**
37
+ * A single turn's optional expectation. `text`/`tools` are graded for `VOICE_AI` (relayed
38
+ * from Fonoster); `action`/`outcome` are graded for `EMAIL`/`WHATSAPP` (the behavioral analog
39
+ * of an expected tool call — see design.md). A turn with no `expected` still runs and streams
40
+ * a result, it just has nothing to grade — **except for VOICE_AI**: Fonoster's
41
+ * `evaluateIntelligence` requires `expected.text` on every conversation turn (confirmed
42
+ * against the live service, correcting an earlier assumption in design.md), so
43
+ * `resolveEvalTarget` rejects a VOICE_AI scenario with any turn missing it before ever
44
+ * calling Fonoster. This schema stays permissive (shared across all three channel types);
45
+ * the VOICE_AI-specific requirement is enforced at resolution time, not here.
46
+ */
47
+ export const evalExpectedSchema = z.object({
48
+ text: evalExpectedTextSchema.optional(),
49
+ tools: z.array(evalExpectedToolSchema).optional(),
50
+ action: z.enum(["reply", "ignore", "resolve", "escalate"]).optional(),
51
+ outcome: contactOutcomeSchema.optional()
52
+ });
53
+ export const evalTurnSchema = z.object({
54
+ input: z.string().min(1),
55
+ expected: evalExpectedSchema.optional()
56
+ });
57
+ export const evalScenarioSchema = z.object({
58
+ ref: z.string().min(1),
59
+ /** Free-text label forwarded as-is to Fonoster's required `scenarios[].description` for
60
+ * VOICE_AI (defaults to `ref` there when omitted); unused by EMAIL/WHATSAPP. */
61
+ description: z.string().optional(),
62
+ account: evalAccountSchema,
63
+ turns: z.array(evalTurnSchema).min(1)
64
+ });
65
+ // `createAgentTemplateSchema.options` is a tuple in the declaration order
66
+ // [VOICE_AI, VOICE_PRERECORDED, SMS, EMAIL, WHATSAPP] — destructured by position (not looked
67
+ // up by `.find()`) so TypeScript keeps each member's specific field types instead of widening
68
+ // to the full 5-way union. The runtime assertions below catch silent breakage if that
69
+ // declaration order ever changes.
70
+ const [voiceAiMember, voicePrerecordedMember, smsMember, emailMember, whatsAppMember] = createAgentTemplateSchema.options;
71
+ function assertMemberType(member, expected) {
72
+ if (member.shape.type.value !== expected) {
73
+ throw new Error(`createAgentTemplateSchema member order changed: expected "${expected}" here, got ` +
74
+ `"${member.shape.type.value}". Update the positional destructure in agentEvaluations.ts.`);
75
+ }
76
+ }
77
+ assertMemberType(voiceAiMember, "VOICE_AI");
78
+ assertMemberType(voicePrerecordedMember, "VOICE_PRERECORDED");
79
+ assertMemberType(smsMember, "SMS");
80
+ assertMemberType(emailMember, "EMAIL");
81
+ assertMemberType(whatsAppMember, "WHATSAPP");
82
+ const evalScenarios = { scenarios: z.array(evalScenarioSchema).min(1) };
83
+ /**
84
+ * An eval template: the same fields `createAgentTemplateSchema` validates for
85
+ * `agentTemplates.create`, plus a `scenarios` array — one document is both the agent
86
+ * definition and its tests (see design.md). Restricted to the three conversational
87
+ * channel types; `SMS`/`VOICE_PRERECORDED` have no scenarios to run (see
88
+ * `previewYamlAgentSchema` instead).
89
+ */
90
+ export const evalTemplateSchema = z.discriminatedUnion("type", [
91
+ voiceAiMember.extend(evalScenarios),
92
+ emailMember.extend(evalScenarios),
93
+ whatsAppMember.extend(evalScenarios)
94
+ ]);
95
+ /** Evaluate an existing template: caller supplies scenarios, since a stored `AgentTemplate`
96
+ * row carries no test fixtures of its own. */
97
+ export const evaluateExistingTargetSchema = z.object({
98
+ agentTemplateId: z.string().min(1),
99
+ scenarios: z.array(evalScenarioSchema).min(1)
100
+ });
101
+ /** Evaluate a not-yet-created agent: the YAML embeds both the agent fields and its scenarios. */
102
+ export const evaluateYamlTargetSchema = z.object({
103
+ yaml: z.string().min(1)
104
+ });
105
+ export const evaluateInputSchema = z.union([
106
+ evaluateExistingTargetSchema,
107
+ evaluateYamlTargetSchema
108
+ ]);
109
+ /** A static (no-conversation) agent definition for `agentTemplates.preview`'s YAML target —
110
+ * `createAgentTemplateSchema`'s `SMS`/`VOICE_PRERECORDED` fields, no `scenarios`. */
111
+ export const previewYamlAgentSchema = z.discriminatedUnion("type", [
112
+ smsMember,
113
+ voicePrerecordedMember
114
+ ]);
115
+ export const previewExistingTargetSchema = z.object({
116
+ agentTemplateId: z.string().min(1),
117
+ account: evalAccountSchema
118
+ });
119
+ export const previewYamlTargetSchema = z.object({
120
+ yaml: z.string().min(1),
121
+ account: evalAccountSchema
122
+ });
123
+ export const previewInputSchema = z.union([previewExistingTargetSchema, previewYamlTargetSchema]);
124
+ //# sourceMappingURL=ag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AAC,CAAC;IACvB,OAAO,EAAE,iBAAiB;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,2BAA2B,EAAE,uBAAuB,CAAC,CAAC,CAAC"}
@@ -8,6 +8,7 @@ export * from "./userSettings.js";
8
8
  export * from "./agentTemplates.js";
9
9
  export * from "./campaigns.js";
10
10
  export * from "./contactLog.js";
11
+ export * from "./agentEvaluations.js";
11
12
  export * from "./dispatch.js";
12
13
  export * from "./email.js";
13
14
  export * from "./whatsApp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -8,6 +8,7 @@ export * from "./userSettings.js";
8
8
  export * from "./agentTemplates.js";
9
9
  export * from "./campaigns.js";
10
10
  export * from "./contactLog.js";
11
+ export * from "./agentEvaluations.js";
11
12
  export * from "./dispatch.js";
12
13
  export * from "./email.js";
13
14
  export * from "./whatsApp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -5,6 +5,28 @@ export declare const currencySchema: z.ZodEnum<{
5
5
  DOP: "DOP";
6
6
  }>;
7
7
  export type Currency = z.infer<typeof currencySchema>;
8
+ /**
9
+ * Locales this deployment formats numbers for. Deliberately a closed set, not "any BCP-47
10
+ * tag": grouping and decimal separators differ per locale (`9,500` in es-DO, `9.500` in
11
+ * es-ES), and an unverified tag would silently reformat every amount an agent reads aloud.
12
+ * QCobro is launched in the Dominican Republic only, so the set has one member today; adding
13
+ * a market means adding it here.
14
+ */
15
+ export declare const supportedLocales: readonly ["es-DO"];
16
+ export declare const localeSchema: z.ZodEnum<{
17
+ "es-DO": "es-DO";
18
+ }>;
19
+ export type Locale = z.infer<typeof localeSchema>;
20
+ /** The locale a workspace gets when none was chosen. Mirrors the Prisma column default. */
21
+ export declare const DEFAULT_LOCALE: Locale;
22
+ /**
23
+ * Narrows a persisted locale to a supported one at the read boundary. The column is a plain
24
+ * `String`, so a row written outside the app (a manual migration, a restored dump) could hold
25
+ * a tag this deployment has never been checked against — that must not take down an inbound
26
+ * webhook mid-conversation, so reads fall back to the default. Writes stay strict:
27
+ * `workspaceSettingsSchema` rejects an unsupported tag outright.
28
+ */
29
+ export declare function parseLocale(value: unknown): Locale;
8
30
  /** The per-workspace settings record (stored in the app DB, keyed by workspaceRef). */
9
31
  export declare const workspaceSettingsSchema: z.ZodObject<{
10
32
  workspaceRef: z.ZodString;
@@ -13,9 +35,17 @@ export declare const workspaceSettingsSchema: z.ZodObject<{
13
35
  DOP: "DOP";
14
36
  }>;
15
37
  timezone: z.ZodString;
38
+ locale: z.ZodEnum<{
39
+ "es-DO": "es-DO";
40
+ }>;
16
41
  }, z.core.$strip>;
17
42
  export type WorkspaceSettings = z.infer<typeof workspaceSettingsSchema>;
18
- /** Operator-editable settings for the active workspace. */
43
+ /**
44
+ * Operator-editable settings for the active workspace. `locale` is deliberately absent: with
45
+ * a single supported locale there is nothing to choose, so it stays application-managed
46
+ * (persisted on the record, set from the column default). Adding a second market means adding
47
+ * it here and building the picker.
48
+ */
19
49
  export declare const updateWorkspaceSettingsSchema: z.ZodObject<{
20
50
  currency: z.ZodEnum<{
21
51
  USD: "USD";
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceSettings.d.ts","sourceRoot":"","sources":["../../src/schemas/workspaceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yEAAyE;AACzE,eAAO,MAAM,cAAc;;;EAAyB,CAAC;AACrD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,uFAAuF;AACvF,eAAO,MAAM,uBAAuB;;;;;;;iBAIlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,2DAA2D;AAC3D,eAAO,MAAM,6BAA6B;;;;;;iBAGxC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
1
+ {"version":3,"file":"workspaceSettings.d.ts","sourceRoot":"","sources":["../../src/schemas/workspaceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yEAAyE;AACzE,eAAO,MAAM,cAAc;;;EAAyB,CAAC;AACrD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,oBAAqB,CAAC;AACnD,eAAO,MAAM,YAAY;;EAA2B,CAAC;AACrD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,2FAA2F;AAC3F,eAAO,MAAM,cAAc,EAAE,MAAgB,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGlD;AAED,uFAAuF;AACvF,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAKlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;;;iBAGxC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
@@ -1,13 +1,41 @@
1
1
  import { z } from "zod";
2
2
  /** Supported display/billing currencies. A workspace has exactly one. */
3
3
  export const currencySchema = z.enum(["USD", "DOP"]);
4
+ /**
5
+ * Locales this deployment formats numbers for. Deliberately a closed set, not "any BCP-47
6
+ * tag": grouping and decimal separators differ per locale (`9,500` in es-DO, `9.500` in
7
+ * es-ES), and an unverified tag would silently reformat every amount an agent reads aloud.
8
+ * QCobro is launched in the Dominican Republic only, so the set has one member today; adding
9
+ * a market means adding it here.
10
+ */
11
+ export const supportedLocales = ["es-DO"];
12
+ export const localeSchema = z.enum(supportedLocales);
13
+ /** The locale a workspace gets when none was chosen. Mirrors the Prisma column default. */
14
+ export const DEFAULT_LOCALE = "es-DO";
15
+ /**
16
+ * Narrows a persisted locale to a supported one at the read boundary. The column is a plain
17
+ * `String`, so a row written outside the app (a manual migration, a restored dump) could hold
18
+ * a tag this deployment has never been checked against — that must not take down an inbound
19
+ * webhook mid-conversation, so reads fall back to the default. Writes stay strict:
20
+ * `workspaceSettingsSchema` rejects an unsupported tag outright.
21
+ */
22
+ export function parseLocale(value) {
23
+ const parsed = localeSchema.safeParse(value);
24
+ return parsed.success ? parsed.data : DEFAULT_LOCALE;
25
+ }
4
26
  /** The per-workspace settings record (stored in the app DB, keyed by workspaceRef). */
5
27
  export const workspaceSettingsSchema = z.object({
6
28
  workspaceRef: z.string().min(1),
7
29
  currency: currencySchema,
8
- timezone: z.string().min(1)
30
+ timezone: z.string().min(1),
31
+ locale: localeSchema
9
32
  });
10
- /** Operator-editable settings for the active workspace. */
33
+ /**
34
+ * Operator-editable settings for the active workspace. `locale` is deliberately absent: with
35
+ * a single supported locale there is nothing to choose, so it stays application-managed
36
+ * (persisted on the record, set from the column default). Adding a second market means adding
37
+ * it here and building the picker.
38
+ */
11
39
  export const updateWorkspaceSettingsSchema = z.object({
12
40
  currency: currencySchema,
13
41
  timezone: z.string().min(1)
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceSettings.js","sourceRoot":"","sources":["../../src/schemas/workspaceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAGrD,uFAAuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAC;AAGH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD,QAAQ,EAAE,cAAc;IACxB,QAAQ,EA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,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAC"}
@@ -0,0 +1,93 @@
1
+ import type { AgentType } from "../schemas/agentTemplates.js";
2
+ import type { EmailAutopilotAction } from "./email.js";
3
+ /**
4
+ * One turn's graded result, streamed as it happens. `passed` is present only when the
5
+ * turn's `expected` was set (see `evalExpectedSchema`) — a turn with no expectation still
6
+ * streams a result, it just has nothing to grade.
7
+ */
8
+ export interface EvalStepResult {
9
+ turnIndex: number;
10
+ input: string;
11
+ passed?: boolean;
12
+ errorMessage?: string;
13
+ /** VOICE_AI (relayed from Fonoster's `stepResult`). */
14
+ aiResponse?: string;
15
+ expectedResponse?: string;
16
+ evaluationType?: "EXACT" | "SIMILAR";
17
+ toolEvaluations?: {
18
+ expectedTool: string;
19
+ actualTool?: string;
20
+ passed: boolean;
21
+ }[];
22
+ /** EMAIL/WHATSAPP (the autopilot decision actually taken). */
23
+ action?: EmailAutopilotAction;
24
+ outcome?: string | null;
25
+ }
26
+ export interface EvalScenarioSummary {
27
+ ref: string;
28
+ overallPassed: boolean;
29
+ }
30
+ /** One event in the `agentEvaluations.evaluate` stream (see the `agent-evaluations` spec). */
31
+ export type EvalEvent = {
32
+ type: "turn";
33
+ scenarioRef: string;
34
+ result: EvalStepResult;
35
+ } | {
36
+ type: "scenarioSummary";
37
+ scenarioRef: string;
38
+ overallPassed: boolean;
39
+ } | {
40
+ type: "summary";
41
+ verdict: "pass" | "fail";
42
+ scenarios: EvalScenarioSummary[];
43
+ } | {
44
+ type: "error";
45
+ message: string;
46
+ };
47
+ /** The row shape `resolveEvalTarget` needs for an existing agent template — base fields
48
+ * plus every channel's child config (only one is ever non-null per row). */
49
+ export interface EvalAgentTemplateRow {
50
+ id: string;
51
+ type: AgentType;
52
+ voiceAiConfig: {
53
+ systemPrompt: string;
54
+ firstMessage: string | null;
55
+ language: string;
56
+ } | null;
57
+ voicePrerecordedConfig: {
58
+ script: string;
59
+ language: string;
60
+ } | null;
61
+ smsConfig: {
62
+ messageBody: string;
63
+ } | null;
64
+ emailConfig: {
65
+ systemPrompt: string;
66
+ messageBody: string;
67
+ maxReplies: number | null;
68
+ } | null;
69
+ whatsAppConfig: {
70
+ systemPrompt: string;
71
+ messageBody: string;
72
+ maxReplies: number | null;
73
+ } | null;
74
+ }
75
+ /** The narrow read port `resolveEvalTarget`/`resolvePreviewTarget` need from Prisma. */
76
+ export interface EvalAgentTemplateClient {
77
+ agentTemplate: {
78
+ findFirstOrThrow(args: {
79
+ where: {
80
+ id: string;
81
+ workspaceRef: string;
82
+ };
83
+ include: {
84
+ voiceAiConfig: true;
85
+ voicePrerecordedConfig: true;
86
+ smsConfig: true;
87
+ emailConfig: true;
88
+ whatsAppConfig: true;
89
+ };
90
+ }): Promise<EvalAgentTemplateRow>;
91
+ };
92
+ }
93
+ //# sourceMappingURL=agentEvaluations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentEvaluations.d.ts","sourceRoot":"","sources":["../../src/types/agentEvaluations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,eAAe,CAAC,EAAE;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,OAAO,CAAC;KACjB,EAAE,CAAC;IACJ,8DAA8D;IAC9D,MAAM,CAAC,EAAE,oBAAo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WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACjG;AAED,wFAAwF;AACxF,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE;QACb,gBAAgB,CAAC,IAAI,EAAE;YACrB,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,YAAY,EAAE,MAAM,CAAA;aAAE,CAAC;YAC5C,OAAO,EAAE;gBACP,aAAa,EAAE,IAAI,CAAC;gBACpB,sBAAsB,EAAE,IAAI,CAAC;gBAC7B,SAAS,EAAE,IAAI,CAAC;gBAChB,WAAW,EAAE,IAAI,CAAC;gBAClB,cAAc,EAAE,IAAI,CAAC;aACtB,CAAC;SACH,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;KACnC,CAAC;CACH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agentEvaluations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentEvaluations.js","sourceRoot":"","sources":["../../src/types/agentEvaluations.ts"],"names":[],"mappings":""}
@@ -4,6 +4,7 @@ export * from "./userSettings.js";
4
4
  export * from "./agentTemplates.js";
5
5
  export * from "./campaigns.js";
6
6
  export * from "./voiceApplication.js";
7
+ export * from "./agentEvaluations.js";
7
8
  export * from "./dispatch.js";
8
9
  export * from "./email.js";
9
10
  export * from "./whatsApp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -4,6 +4,7 @@ export * from "./userSettings.js";
4
4
  export * from "./agentTemplates.js";
5
5
  export * from "./campaigns.js";
6
6
  export * from "./voiceApplication.js";
7
+ export * from "./agentEvaluations.js";
7
8
  export * from "./dispatch.js";
8
9
  export * from "./email.js";
9
10
  export * from "./whatsApp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -17,6 +17,68 @@ export interface VoiceApplicationInput {
17
17
  /** Language code (e.g. `es`, `en`). */
18
18
  language: string;
19
19
  }
20
+ /** One scripted turn within a VOICE_AI eval scenario, translated into Fonoster's
21
+ * `conversation[].userInput`/`expected` shape by the client implementation. */
22
+ export interface VoiceApplicationEvalTurn {
23
+ input: string;
24
+ expected?: {
25
+ text?: {
26
+ type: "EXACT" | "SIMILAR";
27
+ response: string;
28
+ };
29
+ tools?: {
30
+ tool: string;
31
+ parameters?: Record<string, unknown>;
32
+ }[];
33
+ };
34
+ }
35
+ /** One scenario within a VOICE_AI eval run. `account` is the rendered outreach context
36
+ * (see `buildOutreachContext`); the client implementation maps it onto whatever ad-hoc
37
+ * metadata bag the provider expects (Fonoster's `telephonyContext.metadata`). */
38
+ export interface VoiceApplicationEvalScenario {
39
+ ref: string;
40
+ /** Forwarded to Fonoster's required `scenarios[].description`; defaults to `ref` when unset. */
41
+ description?: string;
42
+ account: Record<string, unknown>;
43
+ turns: VoiceApplicationEvalTurn[];
44
+ }
45
+ /** Input to evaluate a `VOICE_AI` agent's conversation logic. No application ref is
46
+ * required — evaluation is inherently ephemeral (see design.md). */
47
+ export interface VoiceApplicationEvalInput {
48
+ systemPrompt: string;
49
+ firstMessage?: string;
50
+ language: string;
51
+ scenarios: VoiceApplicationEvalScenario[];
52
+ }
53
+ /** Mirrors Fonoster's `EvaluateIntelligenceEvent` (`@fonoster/types`), so the apiserver
54
+ * relays it without inventing a parallel shape. */
55
+ export type VoiceApplicationEvalEvent = {
56
+ type: "stepResult";
57
+ scenarioRef: string;
58
+ stepResult: {
59
+ humanInput: string;
60
+ expectedResponse: string;
61
+ aiResponse: string;
62
+ evaluationType: "EXACT" | "SIMILAR";
63
+ passed: boolean;
64
+ errorMessage?: string;
65
+ toolEvaluations?: {
66
+ expectedTool: string;
67
+ actualTool: string;
68
+ passed: boolean;
69
+ expectedParameters?: Record<string, unknown>;
70
+ actualParameters?: Record<string, unknown>;
71
+ errorMessage?: string;
72
+ }[];
73
+ };
74
+ } | {
75
+ type: "scenarioSummary";
76
+ scenarioRef: string;
77
+ overallPassed: boolean;
78
+ } | {
79
+ type: "evalError";
80
+ message: string;
81
+ };
20
82
  export interface VoiceApplicationClient {
21
83
  /** Create the remote application; resolves with its provider ref. */
22
84
  createApplication(input: VoiceApplicationInput): Promise<{
@@ -28,5 +90,8 @@ export interface VoiceApplicationClient {
28
90
  }>;
29
91
  /** Delete the remote application by ref (best-effort cleanup). */
30
92
  deleteApplication(ref: string): Promise<void>;
93
+ /** Evaluate a `VOICE_AI` agent's conversation logic — existing or ephemeral, no
94
+ * application ref required. Streams Fonoster's per-turn/per-scenario events unchanged. */
95
+ evaluate(input: VoiceApplicationEvalInput): AsyncGenerator<VoiceApplicationEvalEvent>;
31
96
  }
32
97
  //# sourceMappingURL=voiceApplication.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"voiceApplication.d.ts","sourceRoot":"","sources":["../../src/types/voiceApplication.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB;mFAC+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,qEAAqE;IACrE,iBAAiB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC;QAAE,GAAG,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,EAAE,qBAAqB,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvF,kEAAkE;IAClE,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;8FAC0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,yBAAyB,GAAG,cAAc,CAAC,yBAAyB,CAAC,CAAC;CACvF"}
@@ -1,8 +1,10 @@
1
- import type { Currency } from "../schemas/workspaceSettings.js";
1
+ import type { Currency, Locale } from "../schemas/workspaceSettings.js";
2
2
  export interface WorkspaceSettingsRecord {
3
3
  workspaceRef: string;
4
4
  currency: Currency;
5
5
  timezone: string;
6
+ /** Governs how amounts are formatted in rendered outreach bodies. */
7
+ locale: Locale;
6
8
  createdAt: Date;
7
9
  updatedAt: Date;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceSettings.d.ts","sourceRoot":"","sources":["../../src/types/workspaceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE;QACjB,UAAU,CAAC,IAAI,EAAE;YAAE,KAAK,EAAE;gBAAE,YAAY,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;QAE/F,MAAM,CAAC,IAAI,EAAE;YACX,KAAK,EAAE;gBAAE,YAAY,EAAE,MAAM,CAAA;aAAE,CAAC;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACjC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;KACtC,CAAC;CACH"}
1
+ {"version":3,"file":"workspaceSettings.d.ts","sourceRoot":"","sources":["../../src/types/workspaceSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE;QACjB,UAAU,CAAC,IAAI,EAAE;YAAE,KAAK,EAAE;gBAAE,YAAY,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;QAE/F,MAAM,CAAC,IAAI,EAAE;YACX,KAAK,EAAE;gBAAE,YAAY,EAAE,MAAM,CAAA;aAAE,CAAC;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACjC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;KACtC,CAAC;CACH"}
@@ -1,6 +1,7 @@
1
1
  export { withErrorHandlingAndValidation } from "./withErrorHandlingAndValidation.js";
2
2
  export { renderTemplate, extractTemplateTokens, buildOutreachContext, buildAutopilotContextLines, pickRandomNumber, snakeToCamel, renderWhatsAppTemplate } from "./outreach.js";
3
3
  export { localParts, localDateString, isSameLocalDay, localWeekdayISO, localTimeHHMM, isWithinScheduleWindow, type ScheduleWindow } from "./time.js";
4
+ export { formatMoney, toNumber } from "./money.js";
4
5
  export { bucketOf, perTickCapacity, type PacingBucket } from "./pacing.js";
5
6
  export { normalizePhoneE164 } from "./normalizePhone.js";
6
7
  export { createValidatePhoneE164 } from "./validatePhone.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export { withErrorHandlingAndValidation } from "./withErrorHandlingAndValidation.js";
2
2
  export { renderTemplate, extractTemplateTokens, buildOutreachContext, buildAutopilotContextLines, pickRandomNumber, snakeToCamel, renderWhatsAppTemplate } from "./outreach.js";
3
3
  export { localParts, localDateString, isSameLocalDay, localWeekdayISO, localTimeHHMM, isWithinScheduleWindow } from "./time.js";
4
+ export { formatMoney, toNumber } from "./money.js";
4
5
  export { bucketOf, perTickCapacity } from "./pacing.js";
5
6
  export { normalizePhoneE164 } from "./normalizePhone.js";
6
7
  export { createValidatePhoneE164 } from "./validatePhone.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EAEvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EAEvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { Locale } from "../schemas/workspaceSettings.js";
2
+ /**
3
+ * Formats an amount for a workspace's locale, with grouping separators.
4
+ *
5
+ * This exists for how amounts are *heard*, not how they look: text-to-speech reads a bare
6
+ * `9500` wrong and `9,500` right, and the provider (ElevenLabs) offers no SSML `<say-as>`
7
+ * control, so the only lever is the text QCobro produces. Rendered outreach bodies are the
8
+ * caller.
9
+ *
10
+ * Fraction digits are two when the amount has a fractional part and none when it does not,
11
+ * so a round balance reads "nueve mil quinientos" rather than "…coma cero cero", and a
12
+ * fractional one reads "…con cincuenta" rather than "…coma cinco".
13
+ */
14
+ export declare function formatMoney(value: number, locale: Locale): string;
15
+ /**
16
+ * Parses a value that may be a number or a locale-formatted amount back to a number, so the
17
+ * template helpers keep working now that money-typed context fields render formatted. Returns
18
+ * `NaN` for anything unparseable — callers preserve their existing malformed-context
19
+ * behavior (`multiply` yields 0, comparisons yield false) rather than leaking `NaN` into
20
+ * customer-facing copy.
21
+ */
22
+ export declare function toNumber(value: unknown, locale: Locale): number;
23
+ //# sourceMappingURL=money.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../src/utils/money.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjE;AAuBD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAkB/D"}