@happyvertical/smrt-support 0.51.31 → 0.51.33

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 (40) hide show
  1. package/README.md +10 -0
  2. package/dist/index.d.ts +17 -0
  3. package/dist/index.js +146 -15
  4. package/dist/index.js.map +1 -1
  5. package/dist/manifest.json +56 -5
  6. package/dist/migrations/moneyMinorUnits.d.ts +30 -1
  7. package/dist/models/service-time-entry.d.ts +2 -1
  8. package/dist/models/support-ai-run.d.ts +15 -3
  9. package/dist/models/support-ai-run.d.ts.map +1 -1
  10. package/dist/models/support-case-event.d.ts +11 -1
  11. package/dist/models/support-case.d.ts +21 -2
  12. package/dist/models/support-case.d.ts.map +1 -1
  13. package/dist/models/support-channel-binding.d.ts +11 -1
  14. package/dist/models/support-compensation-plan.d.ts +11 -0
  15. package/dist/models/support-interaction.d.ts +12 -1
  16. package/dist/models/support-plan.d.ts +19 -1
  17. package/dist/models/support-policy.d.ts +19 -0
  18. package/dist/models/support-policy.d.ts.map +1 -1
  19. package/dist/models/support-service-target.d.ts +15 -1
  20. package/dist/models/support-settlement.d.ts +20 -1
  21. package/dist/models/support-specialist.d.ts +15 -1
  22. package/dist/models/support-work-link.d.ts +13 -1
  23. package/dist/permissions.d.ts +12 -1
  24. package/dist/services/coverage-calendar.d.ts +22 -1
  25. package/dist/services/human-handoff-service.d.ts +18 -3
  26. package/dist/services/project-assistance-adapter.d.ts +2 -2
  27. package/dist/services/service-target-engine.d.ts +33 -6
  28. package/dist/services/service-time-entry-service.d.ts +15 -3
  29. package/dist/services/support-ai-workflow.d.ts +34 -6
  30. package/dist/services/support-ai-workflow.d.ts.map +1 -1
  31. package/dist/services/support-case-service.d.ts +15 -7
  32. package/dist/services/support-intake-service.d.ts +25 -4
  33. package/dist/services/support-plan-admin-service.d.ts +17 -4
  34. package/dist/services/support-routing-service.d.ts +19 -4
  35. package/dist/services/time-entry-approval-service.d.ts +33 -6
  36. package/dist/smrt-knowledge.json +53 -4
  37. package/dist/types.d.ts +1 -1
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js.map +1 -1
  40. package/package.json +11 -11
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-support",
5
- "packageVersion": "0.51.31",
5
+ "packageVersion": "0.51.33",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-support:ServiceTimeEntry": {
8
8
  "name": "servicetimeentry",
@@ -2059,6 +2059,20 @@
2059
2059
  "isStatic": false,
2060
2060
  "isPublic": true
2061
2061
  },
2062
+ "attemptTriageDecision": {
2063
+ "name": "attemptTriageDecision",
2064
+ "async": true,
2065
+ "parameters": [
2066
+ {
2067
+ "name": "request",
2068
+ "type": "DecisionRequest",
2069
+ "optional": false
2070
+ }
2071
+ ],
2072
+ "returnType": "Promise<DecisionResult | undefined>",
2073
+ "isStatic": false,
2074
+ "isPublic": true
2075
+ },
2062
2076
  "initialize": {
2063
2077
  "name": "initialize",
2064
2078
  "async": true,
@@ -5025,6 +5039,11 @@
5025
5039
  "required": false,
5026
5040
  "_meta": {}
5027
5041
  },
5042
+ "allowedCategories": {
5043
+ "type": "text",
5044
+ "required": false,
5045
+ "_meta": {}
5046
+ },
5028
5047
  "allowedTools": {
5029
5048
  "type": "text",
5030
5049
  "required": false,
@@ -5059,6 +5078,28 @@
5059
5078
  "isStatic": false,
5060
5079
  "isPublic": true
5061
5080
  },
5081
+ "getAllowedCategories": {
5082
+ "name": "getAllowedCategories",
5083
+ "async": false,
5084
+ "parameters": [],
5085
+ "returnType": "string[]",
5086
+ "isStatic": false,
5087
+ "isPublic": true
5088
+ },
5089
+ "setAllowedCategories": {
5090
+ "name": "setAllowedCategories",
5091
+ "async": false,
5092
+ "parameters": [
5093
+ {
5094
+ "name": "categories",
5095
+ "type": "string[]",
5096
+ "optional": false
5097
+ }
5098
+ ],
5099
+ "returnType": "void",
5100
+ "isStatic": false,
5101
+ "isPublic": true
5102
+ },
5062
5103
  "getAllowedTools": {
5063
5104
  "name": "getAllowedTools",
5064
5105
  "async": false,
@@ -5148,7 +5189,7 @@
5148
5189
  "collectionExportName": "SupportPolicyCollection",
5149
5190
  "schema": {
5150
5191
  "tableName": "support_policies",
5151
- "ddl": "CREATE TABLE IF NOT EXISTS \"support_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"plan_id\" UUID,\n \"project_id\" TEXT,\n \"enabled\" BOOLEAN,\n \"auto_acknowledge\" BOOLEAN,\n \"auto_classify\" BOOLEAN,\n \"auto_answer\" BOOLEAN,\n \"auto_troubleshoot\" BOOLEAN,\n \"auto_resolve\" BOOLEAN,\n \"auto_resolve_max_severity\" TEXT,\n \"confidence_threshold\" REAL DEFAULT 0.7,\n \"max_auto_attempts\" INTEGER DEFAULT 1,\n \"auto_send_email_replies\" BOOLEAN,\n \"sensitive_categories\" TEXT,\n \"allowed_tools\" TEXT,\n \"metadata\" TEXT\n);",
5192
+ "ddl": "CREATE TABLE IF NOT EXISTS \"support_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"plan_id\" UUID,\n \"project_id\" TEXT,\n \"enabled\" BOOLEAN,\n \"auto_acknowledge\" BOOLEAN,\n \"auto_classify\" BOOLEAN,\n \"auto_answer\" BOOLEAN,\n \"auto_troubleshoot\" BOOLEAN,\n \"auto_resolve\" BOOLEAN,\n \"auto_resolve_max_severity\" TEXT,\n \"confidence_threshold\" REAL DEFAULT 0.7,\n \"max_auto_attempts\" INTEGER DEFAULT 1,\n \"auto_send_email_replies\" BOOLEAN,\n \"sensitive_categories\" TEXT,\n \"allowed_categories\" TEXT,\n \"allowed_tools\" TEXT,\n \"metadata\" TEXT\n);",
5152
5193
  "columns": {
5153
5194
  "id": {
5154
5195
  "type": "UUID",
@@ -5261,6 +5302,11 @@
5261
5302
  "notNull": false,
5262
5303
  "unique": false
5263
5304
  },
5305
+ "allowed_categories": {
5306
+ "type": "TEXT",
5307
+ "notNull": false,
5308
+ "unique": false
5309
+ },
5264
5310
  "allowed_tools": {
5265
5311
  "type": "TEXT",
5266
5312
  "notNull": false,
@@ -5303,7 +5349,7 @@
5303
5349
  ]
5304
5350
  }
5305
5351
  ],
5306
- "version": "61b60e25"
5352
+ "version": "db53199e"
5307
5353
  },
5308
5354
  "importPath": "@happyvertical/smrt-support"
5309
5355
  },
@@ -5343,7 +5389,7 @@
5343
5389
  "collectionExportName": "SupportPolicyCollectionCollection",
5344
5390
  "schema": {
5345
5391
  "tableName": "support_policies",
5346
- "ddl": "CREATE TABLE IF NOT EXISTS \"support_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"plan_id\" UUID,\n \"project_id\" TEXT,\n \"enabled\" BOOLEAN,\n \"auto_acknowledge\" BOOLEAN,\n \"auto_classify\" BOOLEAN,\n \"auto_answer\" BOOLEAN,\n \"auto_troubleshoot\" BOOLEAN,\n \"auto_resolve\" BOOLEAN,\n \"auto_resolve_max_severity\" TEXT,\n \"confidence_threshold\" REAL DEFAULT 0.7,\n \"max_auto_attempts\" INTEGER DEFAULT 1,\n \"auto_send_email_replies\" BOOLEAN,\n \"sensitive_categories\" TEXT,\n \"allowed_tools\" TEXT,\n \"metadata\" TEXT\n);",
5392
+ "ddl": "CREATE TABLE IF NOT EXISTS \"support_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT DEFAULT '',\n \"plan_id\" UUID,\n \"project_id\" TEXT,\n \"enabled\" BOOLEAN,\n \"auto_acknowledge\" BOOLEAN,\n \"auto_classify\" BOOLEAN,\n \"auto_answer\" BOOLEAN,\n \"auto_troubleshoot\" BOOLEAN,\n \"auto_resolve\" BOOLEAN,\n \"auto_resolve_max_severity\" TEXT,\n \"confidence_threshold\" REAL DEFAULT 0.7,\n \"max_auto_attempts\" INTEGER DEFAULT 1,\n \"auto_send_email_replies\" BOOLEAN,\n \"sensitive_categories\" TEXT,\n \"allowed_categories\" TEXT,\n \"allowed_tools\" TEXT,\n \"metadata\" TEXT\n);",
5347
5393
  "columns": {
5348
5394
  "id": {
5349
5395
  "type": "UUID",
@@ -5456,6 +5502,11 @@
5456
5502
  "notNull": false,
5457
5503
  "unique": false
5458
5504
  },
5505
+ "allowed_categories": {
5506
+ "type": "TEXT",
5507
+ "notNull": false,
5508
+ "unique": false
5509
+ },
5459
5510
  "allowed_tools": {
5460
5511
  "type": "TEXT",
5461
5512
  "notNull": false,
@@ -5498,7 +5549,7 @@
5498
5549
  ]
5499
5550
  }
5500
5551
  ],
5501
- "version": "61b60e25"
5552
+ "version": "db53199e"
5502
5553
  },
5503
5554
  "importPath": "@happyvertical/smrt-support"
5504
5555
  },
@@ -1,4 +1,33 @@
1
- import { DatabaseInterface, MinorUnitsPreflightResult, MinorUnitsRescaleResult, MoneyColumnTarget } from '@happyvertical/smrt-core/migrations';
1
+ /**
2
+ * Support money columns: floating-point major units → integer minor units.
3
+ *
4
+ * Ships as an explicit, opt-in migration rather than a schema-differ upgrade
5
+ * because REAL→INTEGER is not information-preserving: an automatic
6
+ * `ALTER … TYPE integer` would truncate `19.99` to `19`. The values have to be
7
+ * rescaled by the currency's minor-unit factor during the type change (#2401).
8
+ *
9
+ * ```ts
10
+ * console.log((await preflightSupportMoneyMinorUnits(db)).summary);
11
+ * await migrateSupportMoneyToMinorUnits(db);
12
+ * ```
13
+ *
14
+ * **Rate columns are deliberately absent.** `SupportPlan.overageHourlyRate`,
15
+ * `SupportPlan.onCallHourlyRate` and `SupportCompensationPlan.hourlyRate` stay
16
+ * DECIMAL — a rate is inherently fractional — but their *unit* changes from
17
+ * major units per hour to **minor units per hour**, so existing rows must be
18
+ * multiplied by the same scale. That is a value change with no type change, and
19
+ * the column list below cannot express it; rescale them in the same deploy
20
+ * step, e.g. `UPDATE support_plans SET overage_hourly_rate = overage_hourly_rate * 100`.
21
+ *
22
+ * Frozen `rateSnapshot` JSON on already-settled charges is history and is left
23
+ * alone: it records what the rate was when the charge was priced, and the
24
+ * amount beside it is rescaled by this migration.
25
+ *
26
+ * On SQLite the values are rescaled but the declared type cannot change in
27
+ * place; those columns come back in `declaredTypeChangePending` and need the
28
+ * table-rebuild path (#2370).
29
+ */
30
+ import { type DatabaseInterface, type MinorUnitsPreflightResult, type MinorUnitsRescaleResult, type MoneyColumnTarget } from '@happyvertical/smrt-core/migrations';
2
31
  /** Marker recorded in `_smrt_backfills` once the rescale has run. */
3
32
  export declare const SUPPORT_MONEY_MINOR_UNITS_BACKFILL = "@happyvertical/smrt-support:money-minor-units:v1";
4
33
  /** Every support money column that held major units before #2401. */
@@ -1,5 +1,6 @@
1
+ /** Compatibility mapping for issue #1955. */
1
2
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
- import { ServiceParticipantKind, ServiceTimeEntrySource, ServiceTimeEntryStatus, ServiceTimeEntry as SharedServiceTimeEntry } from '@happyvertical/smrt-projects';
3
+ import { type ServiceParticipantKind, type ServiceTimeEntrySource, type ServiceTimeEntryStatus, ServiceTimeEntry as SharedServiceTimeEntry } from '@happyvertical/smrt-projects';
3
4
  /**
4
5
  * Source-compatible support subtype over the shared canonical table. The
5
6
  * fields are restated because package-isolated manifest scanning deliberately
@@ -1,5 +1,15 @@
1
+ /**
2
+ * SupportAiRun — the auditable record of one Automated Support Response phase
3
+ * (FR-28a): what the AI attempted (acknowledge / classify / answer /
4
+ * troubleshoot / resolve), with confidence, classification output, knowledge
5
+ * references, attempted tool calls, and outcome. This is the "prior automated
6
+ * work" a Human Handoff transfers losslessly (FR-28b).
7
+ *
8
+ * Append-only: generated surface is `list`/`get`; the workflow writes each
9
+ * run once and never rewrites history.
10
+ */
1
11
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportAiRunOutcome, SupportAiRunPhase } from '../types.js';
12
+ import { type SupportAiRunOutcome, type SupportAiRunPhase } from '../types.js';
3
13
  export declare class SupportAiRun extends SmrtObject {
4
14
  tenantId: string | null;
5
15
  caseId: string;
@@ -8,8 +18,10 @@ export declare class SupportAiRun extends SmrtObject {
8
18
  phase: SupportAiRunPhase;
9
19
  outcome: SupportAiRunOutcome;
10
20
  /**
11
- * Model-reported confidence in [0, 1] for answer/classify/resolve phases;
12
- * null when the phase has no confidence semantics (e.g. acknowledge).
21
+ * Model-reported answer/resolve confidence or the classification audit
22
+ * certainty in [0, 1]. Classification certainty is not calibrated answer
23
+ * confidence and never controls the answer policy threshold. Null when the
24
+ * phase has no confidence semantics (e.g. acknowledge).
13
25
  */
14
26
  confidence: number | null;
15
27
  /** Classification output JSON: severity, category, sentiment, sensitive. */
@@ -1 +1 @@
1
- {"version":3,"file":"support-ai-run.d.ts","sourceRoot":"","sources":["../../src/models/support-ai-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,cAAc,EACd,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAE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I,GAAG,IAAI,CAAQ;IAGhC,QAAQ,EAAE,MAAM,CAAQ;IAExB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI5C,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIvD,gBAAgB,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIlD,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI;IAI5D,YAAY,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI9C,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI;CAG1D;AAED,qBAAa,sBAAuB,SAAQ,cAAc,CAAC,YAAY,CAAC;IACtE,MAAM,CAAC,QAAQ,CAAC,UAAU,sBAAgB;IAE1C,4CAA4C;IACtC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAGvD;AAED,eAAe,YAAY,CAAC"}
@@ -1,5 +1,15 @@
1
+ /**
2
+ * SupportCaseEvent — append-only audit trail for a Support Case: creations,
3
+ * transitions, assignments, AI runs, handoffs, escalations, target state
4
+ * changes, work links, and reopens. Together with interactions this is the
5
+ * "complete Case context" a Human Handoff transfers (FR-28b) and the reopen
6
+ * history FR-29b preserves.
7
+ *
8
+ * Events are immutable: the generated surface is `list`/`get` only and the
9
+ * service never updates an event after writing it.
10
+ */
1
11
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportActorKind, SupportCaseEventType } from '../types.js';
12
+ import { type SupportActorKind, type SupportCaseEventType } from '../types.js';
3
13
  export declare class SupportCaseEvent extends SmrtObject {
4
14
  tenantId: string | null;
5
15
  caseId: string;
@@ -1,5 +1,16 @@
1
- import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportCaseStatus } from '../types.js';
1
+ /**
2
+ * SupportCase — the canonical, tenant-scoped record of a client support
3
+ * request (FR-28/FR-29): one Case per request across every channel, carrying
4
+ * priority, severity, plan snapshot, lifecycle state, assignment, resolution,
5
+ * and reopen history.
6
+ *
7
+ * Internal model — writes go through {@link SupportCaseService} (closed-facade
8
+ * idiom, mirroring `smrt-chat`'s `ChatService`). The generated CRUD surface is
9
+ * read-only (`list`/`get`); the save-time transition guard below additionally
10
+ * rejects illegal status flips done via raw field assignment.
11
+ */
12
+ import { type DecisionRequest, type DecisionResult, SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
13
+ import { type SupportCaseStatus } from '../types.js';
3
14
  /** Generate a short human-facing case number (unique enough per tenant). */
4
15
  export declare function generateCaseNumber(now?: Date): string;
5
16
  export declare class SupportCase extends SmrtObject {
@@ -84,6 +95,14 @@ export declare class SupportCase extends SmrtObject {
84
95
  updateMetadata(patch: Record<string, unknown>): void;
85
96
  getPlanSnapshot(): Record<string, unknown>;
86
97
  setPlanSnapshot(value: Record<string, unknown>): void;
98
+ /**
99
+ * Attempt typed support triage without changing the established tool route.
100
+ *
101
+ * A configured decision client is deliberately resolved only after the tool
102
+ * guard, matching the core routing rule. `undefined` means the caller must
103
+ * use its legacy generative behavior.
104
+ */
105
+ attemptTriageDecision(request: DecisionRequest): Promise<DecisionResult | undefined>;
87
106
  /**
88
107
  * Capture the status the row was loaded with so the save-time guard can
89
108
  * reject illegal flips made via raw field assignment.
@@ -1 +1 @@
1
- {"version":3,"file":"support-case.d.ts","sourceRoot":"","sources":["../../src/models/support-case.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAIL,cAAc,EACd,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAQrB,4EAA4E;AAC5E,wBAAgB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OAAO,GAAE;QACP,MAAM,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;QACjD,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,GACL,OAAO,CAAC,WAAW,EAAE,CAAC;CA2B1B;AAED,eAAe,WAAW,CAAC"}
@@ -1,5 +1,15 @@
1
+ /**
2
+ * SupportChannelBinding — marks a transport container (a chat room, an email
3
+ * account) as a Managed Support intake channel. Inbound activity on a bound
4
+ * container creates-or-joins Support Cases; unbound containers are never
5
+ * touched, so ordinary chat rooms and mailboxes stay out of the support
6
+ * system.
7
+ *
8
+ * Bindings are configuration (operator-managed), so unlike the case-side
9
+ * models they expose full generated CRUD.
10
+ */
1
11
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportBindingKind, SupportChannelKind } from '../types.js';
12
+ import { type SupportBindingKind, type SupportChannelKind } from '../types.js';
3
13
  export declare class SupportChannelBinding extends SmrtObject {
4
14
  tenantId: string | null;
5
15
  /** Operator-facing binding name (inherited `name` is the display label). */
@@ -1,3 +1,14 @@
1
+ /**
2
+ * SupportCompensationPlan — the provider-facing **Support Compensation Plan**
3
+ * (FR-32/FR-35): the effective-dated terms under which a Support Specialist
4
+ * earns for delivered support time. Deliberately separate from
5
+ * {@link SupportPlan} (client pricing) so margin stays measurable and client
6
+ * terms never leak provider terms.
7
+ *
8
+ * Resolution: the specialist-specific plan effective at the work instant
9
+ * wins; otherwise the tenant default (`specialistId` null) effective at that
10
+ * instant applies.
11
+ */
1
12
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
13
  export declare class SupportCompensationPlan extends SmrtObject {
3
14
  tenantId: string | null;
@@ -1,5 +1,16 @@
1
+ /**
2
+ * SupportInteraction — a channel-neutral transport record attached to a
3
+ * Support Case (FR-28/FR-29): one row per message/chat/email/voice exchange,
4
+ * preserving chronology and transport metadata. The channel row (a
5
+ * `ChatMessage`, an `Email`, …) stays in its own package; this row links it
6
+ * via a qualified `sourceType`/`sourceId` pair and a globally unique
7
+ * `sourceKey` so re-ingesting the same transport record is idempotent.
8
+ *
9
+ * Internal model — writes go through {@link SupportCaseService}. Generated
10
+ * surface is read-only.
11
+ */
1
12
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportActorKind, SupportChannelKind, SupportInteractionDirection } from '../types.js';
13
+ import { type SupportActorKind, type SupportChannelKind, type SupportInteractionDirection } from '../types.js';
3
14
  export declare class SupportInteraction extends SmrtObject {
4
15
  tenantId: string | null;
5
16
  caseId: string;
@@ -1,5 +1,23 @@
1
+ /**
2
+ * SupportPlan — the client-facing **Managed Support Plan** (FR-31): coverage
3
+ * hours and channels, severity definitions, acknowledgement / response /
4
+ * update / resolution Service Targets, pause rules, escalation policy, an
5
+ * availability fee, included support time, and metered overage pricing.
6
+ *
7
+ * Pure hourly support is a plan with zero availability fee and zero included
8
+ * minutes. A Service Target here is an operational objective — it becomes a
9
+ * contractual Service Level Agreement only in the governing agreement, which
10
+ * is out of this package's scope.
11
+ *
12
+ * Client pricing lives here; Support Specialist earnings live in the separate
13
+ * {@link SupportCompensationPlan} — the two are never merged (FR-32/FR-35).
14
+ *
15
+ * `subscriptionPlanKey` optionally binds the plan to a
16
+ * `@happyvertical/smrt-subscriptions` plan by its natural key for entitlement
17
+ * checks — a string reference, deliberately not a package dependency.
18
+ */
1
19
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { CoverageWindow, EscalationStep, ServiceTargetMinutes, SeverityDefinition, TimeApprovalPolicy } from '../types.js';
20
+ import { type CoverageWindow, type EscalationStep, type ServiceTargetMinutes, type SeverityDefinition, type TimeApprovalPolicy } from '../types.js';
3
21
  /** Default target minutes applied when a plan omits a severity's targets. */
4
22
  export declare const DEFAULT_TARGET_MINUTES: ServiceTargetMinutes;
5
23
  export declare class SupportPlan extends SmrtObject {
@@ -1,3 +1,14 @@
1
+ /**
2
+ * SupportPolicy — governs what the AI support workflow may do without a human
3
+ * (FR-28a/FR-28b): which phases run automatically, whether low-risk
4
+ * resolutions may complete autonomously, the confidence floor, sensitive
5
+ * categories, and the tool whitelist for troubleshooting.
6
+ *
7
+ * Resolution is most-specific-wins per case: `(planId, projectId)` exact →
8
+ * `planId` → `projectId` → tenant default (both null) → the package's
9
+ * conservative built-in defaults (see `DEFAULT_SUPPORT_POLICY`). Policies are
10
+ * operator configuration, so they expose full generated CRUD.
11
+ */
1
12
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
13
  /**
3
14
  * Conservative defaults applied when no SupportPolicy row matches: the AI
@@ -16,6 +27,7 @@ export declare const DEFAULT_SUPPORT_POLICY: {
16
27
  readonly maxAutoAttempts: 1;
17
28
  readonly autoSendEmailReplies: false;
18
29
  readonly sensitiveCategories: string[];
30
+ readonly allowedCategories: string[];
19
31
  readonly allowedTools: string[];
20
32
  };
21
33
  export declare class SupportPolicy extends SmrtObject {
@@ -56,11 +68,18 @@ export declare class SupportPolicy extends SmrtObject {
56
68
  * triggers a Human Handoff (FR-28b). JSON array of category keys.
57
69
  */
58
70
  sensitiveCategories: string;
71
+ /**
72
+ * Optional closed vocabulary for AI classification categories. Empty keeps
73
+ * the legacy free-vocabulary category generation path.
74
+ */
75
+ allowedCategories: string;
59
76
  /** Tool ids the troubleshooting phase may execute. JSON array, fail-closed. */
60
77
  allowedTools: string;
61
78
  metadata: string;
62
79
  getSensitiveCategories(): string[];
63
80
  setSensitiveCategories(categories: string[]): void;
81
+ getAllowedCategories(): string[];
82
+ setAllowedCategories(categories: string[]): void;
64
83
  getAllowedTools(): string[];
65
84
  setAllowedTools(tools: string[]): void;
66
85
  getMetadata(): Record<string, unknown>;
@@ -1 +1 @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Ae,aAAa,CAAC"}
@@ -1,5 +1,19 @@
1
+ /**
2
+ * Service Target clocks and escalations (FR-30/FR-31).
3
+ *
4
+ * - **SupportServiceTarget** — one acknowledgement/response/update/resolution
5
+ * clock on a case, derived from the applicable plan's targets, coverage
6
+ * calendar, and pause rules. `escalationJobId` holds the one-shot
7
+ * `_smrt_jobs` row scheduled at `dueAt` so satisfying the target can cancel
8
+ * the pending escalation.
9
+ * - **SupportEscalation** — the auditable record of one escalation firing
10
+ * (target breach, target risk, manual, or AI-triggered).
11
+ *
12
+ * Both are written by the target engine / case service only; generated
13
+ * surfaces are read-only.
14
+ */
1
15
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { ServiceTargetStatus, ServiceTargetType, SupportEscalationReason } from '../types.js';
16
+ import { type ServiceTargetStatus, type ServiceTargetType, type SupportEscalationReason } from '../types.js';
3
17
  /** Outcome of one {@link SupportServiceTarget.checkAndEscalate} delivery. */
4
18
  export interface CheckAndEscalateResult {
5
19
  outcome: 'breached' | 'escalated' | 'rescheduled' | 'noop' | 'missing';
@@ -1,5 +1,24 @@
1
+ /**
2
+ * Derived commercial snapshots for approved Service Time Entries
3
+ * (FR-32/FR-35, issue #1930). Two deliberately separate rows per entry:
4
+ *
5
+ * - **SupportCharge** — what the Client owes, derived from the Managed
6
+ * Support Plan (included-time consumption, then metered overage).
7
+ * - **SupportCompensation** — what the delivering Participant earns, derived
8
+ * from the Support Compensation Plan.
9
+ *
10
+ * Margin = charge − compensation, computed by readers; the two records are
11
+ * never merged so client pricing can't leak provider terms. Rows snapshot the
12
+ * rate terms at derivation time (`rateSnapshot`) — later plan edits never
13
+ * rewrite them; corrections void/supersede and re-derive from the correcting
14
+ * entry. Settlement (invoicing, ledger posting) is out of scope here and
15
+ * composes at the app/accounting boundary (#1925).
16
+ *
17
+ * Append-only surfaces: `list`/`get` generated routes only; writes go through
18
+ * `TimeEntryApprovalService`.
19
+ */
1
20
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportSettlementStatus } from '../types.js';
21
+ import { type SupportSettlementStatus } from '../types.js';
3
22
  export declare class SupportCharge extends SmrtObject {
4
23
  tenantId: string | null;
5
24
  timeEntryId: string;
@@ -1,5 +1,19 @@
1
+ /**
2
+ * Support Specialist models (FR-30): the specialist role record layered on a
3
+ * Profile (the `commerce Customer` role-record idiom), per-project
4
+ * qualifications, and availability/on-call windows.
5
+ *
6
+ * - **SupportSpecialist** — a Participant qualified to handle first-tier
7
+ * support; workload cap, languages, and timezone drive routing.
8
+ * - **SupportQualification** — recognition that a specialist is trained and
9
+ * approved for a specific app-defined project (effective-dated).
10
+ * - **SupportAvailability** — weekly working windows, on-call spans, and
11
+ * time-off exceptions used by routing and coverage checks.
12
+ *
13
+ * These are operator configuration surfaces, so they expose generated CRUD.
14
+ */
1
15
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportAvailabilityKind, SupportQualificationLevel, SupportSpecialistStatus } from '../types.js';
16
+ import { type SupportAvailabilityKind, type SupportQualificationLevel, type SupportSpecialistStatus } from '../types.js';
3
17
  export declare class SupportSpecialist extends SmrtObject {
4
18
  tenantId: string | null;
5
19
  /** The Participant (Person profile) this specialist role belongs to. */
@@ -1,5 +1,17 @@
1
+ /**
2
+ * SupportWorkLink — links a Support Case to separately tracked internal work
3
+ * (FR-29/FR-29a): a **Support Work Item** on the operational board, or a
4
+ * **Development Work Item** created through a Delivery Handoff.
5
+ *
6
+ * Boundary: Support owns the Case and this link; Delivery Operations owns the
7
+ * linked work's execution (agents, previews, merges, deployments). The
8
+ * `status` field here is a read-only echo the delivery side reports back —
9
+ * this package never drives the linked item's lifecycle. Targets are
10
+ * addressed by qualified type + id (e.g. `@happyvertical/smrt-projects:Issue`)
11
+ * so no runtime dependency on the owning package is needed.
12
+ */
1
13
  import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
2
- import { SupportWorkLinkKind } from '../types.js';
14
+ import { type SupportWorkLinkKind } from '../types.js';
3
15
  export declare class SupportWorkLink extends SmrtObject {
4
16
  tenantId: string | null;
5
17
  caseId: string;
@@ -1,4 +1,15 @@
1
- import { PermissionDefinition } from '@happyvertical/smrt-users';
1
+ /**
2
+ * Custom permission slugs contributed by `@happyvertical/smrt-support` to the
3
+ * runtime permission catalog (the `personas.activate-directive` pattern).
4
+ *
5
+ * The privileged operations are permission splits, not bespoke checks:
6
+ * - `support.reassign-case` — manual reassignment despite routing (FR-30).
7
+ * - `support.approve-time-entry` — accept a Service Time Entry and derive its
8
+ * commercial snapshots (FR-36) via the operator path.
9
+ * - `support.manage-plans` — administer Managed Support Plans and Support
10
+ * Compensation Plans.
11
+ */
12
+ import { type PermissionDefinition } from '@happyvertical/smrt-users';
2
13
  /** Authorizes manual case reassignment overriding automatic routing. */
3
14
  export declare const REASSIGN_CASE_PERMISSION = "support.reassign-case";
4
15
  /** Authorizes operator approval/rejection of Service Time Entries. */
@@ -1,4 +1,25 @@
1
- import { CoverageWindow } from '../types.js';
1
+ /**
2
+ * Coverage-calendar math for Service Target clocks (FR-30/FR-31): pure,
3
+ * deterministic business-time arithmetic over a Managed Support Plan's
4
+ * coverage windows, holidays, and IANA timezone.
5
+ *
6
+ * Semantics:
7
+ * - An empty `windows` array means 24×7 coverage; with no holidays either,
8
+ * covered time is plain wall-clock time (the fast path).
9
+ * - Holidays (`YYYY-MM-DD` in the calendar's timezone) exclude whole days
10
+ * from coverage, including under 24×7 coverage.
11
+ * - All functions take explicit instants — no `Date.now()` inside — so the
12
+ * engine and its tests stay deterministic.
13
+ *
14
+ * Timezone handling uses `Intl.DateTimeFormat#formatToParts` only (no date
15
+ * library): {@link zonedParts} projects a UTC instant onto the calendar
16
+ * timezone's wall clock, and an iterative inverse converts wall-clock day
17
+ * positions back to UTC instants. DST transition days therefore keep exact
18
+ * window boundaries; a window boundary falling inside a nonexistent
19
+ * spring-forward hour lands on the later real instant so clocks never gain
20
+ * time.
21
+ */
22
+ import type { CoverageWindow } from '../types.js';
2
23
  /** The coverage terms a Service Target clock runs against. */
3
24
  export interface CoverageCalendar {
4
25
  /** Weekly coverage windows; empty means 24×7 coverage. */
@@ -1,7 +1,22 @@
1
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
1
+ /**
2
+ * HumanHandoffService — the lossless Human Handoff (FR-28b, issue #1928).
3
+ * Whatever pulls the trigger (an explicit client request, low answer
4
+ * confidence, a sensitive classification, high severity, failed automation,
5
+ * a policy cap, or a manual escalation), the handoff transfers the FULL case
6
+ * context — current state, the merged interaction/event timeline, and every
7
+ * prior {@link SupportAiRun} — so the Client never repeats themselves and the
8
+ * Support Specialist starts with the complete history.
9
+ *
10
+ * A no-repeat guarantee keeps at most one handoff active per case
11
+ * (`metadata.activeHandoff`): repeat triggers while one is pending only
12
+ * append a deduped audit event. Routing is a seam — the #1929 routing
13
+ * service plugs in via `assignSpecialist`; without it the case is queued for
14
+ * manual pickup (`new` → `triaged`).
15
+ */
16
+ import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
17
  import { SupportAiRunCollection } from '../models/support-ai-run.js';
3
- import { SupportCase } from '../models/support-case.js';
4
- import { HumanHandoffTrigger } from '../types.js';
18
+ import type { SupportCase } from '../models/support-case.js';
19
+ import type { HumanHandoffTrigger } from '../types.js';
5
20
  import { SupportCaseService } from './support-case-service.js';
6
21
  /** One compact timeline entry inside a {@link HandoffContextPackage}. */
7
22
  export interface HandoffTimelineItem {
@@ -1,5 +1,5 @@
1
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
- import { AssistanceSupportPort } from '@happyvertical/smrt-projects';
1
+ import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
+ import type { AssistanceSupportPort } from '@happyvertical/smrt-projects';
3
3
  import { SupportCaseService } from './support-case-service.js';
4
4
  /** Concrete lossless bridge from smrt-projects Assistance Requests to Support. */
5
5
  export declare class ProjectAssistanceSupportAdapter implements AssistanceSupportPort {
@@ -1,10 +1,37 @@
1
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
1
+ /**
2
+ * ServiceTargetEngine — Service Target clocks with timed escalation
3
+ * (FR-30/FR-31).
4
+ *
5
+ * Owns the full clock lifecycle on a case:
6
+ * - **start** — one clock per configured target type from the case's plan
7
+ * terms (the frozen `planSnapshot` wins over the live plan; sensible
8
+ * defaults with no plan), `dueAt` computed in *covered* time through the
9
+ * plan's coverage calendar, plus a one-shot `_smrt_jobs` row
10
+ * (`SupportServiceTarget.checkAndEscalate`) scheduled at `dueAt`;
11
+ * - **satisfy** — outbound specialist/agent interactions satisfy the
12
+ * acknowledgement/response clocks and roll the recurring update clock to
13
+ * its next cycle; satisfied clocks cancel their escalation job;
14
+ * - **pause/resume** — case statuses listed in the plan's `pauseStatuses`
15
+ * freeze clocks (FR-29b: waiting periods pause clocks *only when the plan
16
+ * says so*); resume recomputes `dueAt` from the remaining covered minutes
17
+ * and enqueues a fresh job;
18
+ * - **resolve/reopen** — resolution satisfies the resolution clock and
19
+ * cancels the rest; reopening starts fresh clocks on a new cycle;
20
+ * - **breach** — an overdue clock is marked breached and escalated through
21
+ * the plan's escalation policy (notify or reassign via
22
+ * {@link SupportRoutingService}), with optional delayed follow-up steps.
23
+ *
24
+ * The engine is invoked by the application around
25
+ * {@link SupportCaseService} calls; it deliberately takes explicit `at`
26
+ * instants so behavior is deterministic and testable.
27
+ */
28
+ import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
2
29
  import { SmrtJobCollection } from '@happyvertical/smrt-jobs';
3
- import { SupportCase } from '../models/support-case.js';
4
- import { SupportInteraction } from '../models/support-interaction.js';
5
- import { SupportEscalationCollection, SupportServiceTarget, SupportServiceTargetCollection } from '../models/support-service-target.js';
6
- import { EscalationStep, ServiceTargetMinutes, SupportCaseStatus } from '../types.js';
7
- import { CoverageCalendar } from './coverage-calendar.js';
30
+ import type { SupportCase } from '../models/support-case.js';
31
+ import type { SupportInteraction } from '../models/support-interaction.js';
32
+ import { SupportEscalationCollection, type SupportServiceTarget, SupportServiceTargetCollection } from '../models/support-service-target.js';
33
+ import { type EscalationStep, type ServiceTargetMinutes, type SupportCaseStatus } from '../types.js';
34
+ import { type CoverageCalendar } from './coverage-calendar.js';
8
35
  import { SupportCaseService } from './support-case-service.js';
9
36
  /** Queue name for support escalation jobs. */
10
37
  export declare const SUPPORT_JOB_QUEUE = "support";