@cossistant/types 0.1.0 → 0.1.2

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 (76) hide show
  1. package/analytics.d.ts +31 -0
  2. package/analytics.d.ts.map +1 -0
  3. package/analytics.js +41 -0
  4. package/analytics.js.map +1 -0
  5. package/api/ai-agent-capabilities.d.ts +16 -19
  6. package/api/ai-agent-capabilities.d.ts.map +1 -1
  7. package/api/ai-agent-capabilities.js +215 -286
  8. package/api/ai-agent-capabilities.js.map +1 -1
  9. package/api/ai-agent-defaults.d.ts +6 -0
  10. package/api/ai-agent-defaults.d.ts.map +1 -0
  11. package/api/ai-agent-defaults.js +33 -0
  12. package/api/ai-agent-defaults.js.map +1 -0
  13. package/api/ai-agent.d.ts +314 -207
  14. package/api/ai-agent.d.ts.map +1 -1
  15. package/api/ai-agent.js +175 -111
  16. package/api/ai-agent.js.map +1 -1
  17. package/api/conversation.d.ts +79 -56
  18. package/api/conversation.d.ts.map +1 -1
  19. package/api/conversation.js +7 -2
  20. package/api/conversation.js.map +1 -1
  21. package/api/feedback.d.ts +5 -0
  22. package/api/feedback.d.ts.map +1 -1
  23. package/api/feedback.js +2 -0
  24. package/api/feedback.js.map +1 -1
  25. package/api/index.d.ts +7 -6
  26. package/api/index.js +7 -6
  27. package/api/link-source.d.ts +4 -4
  28. package/api/link-source.d.ts.map +1 -1
  29. package/api/link-source.js +1 -1
  30. package/api/link-source.js.map +1 -1
  31. package/api/timeline-item.d.ts +79 -67
  32. package/api/timeline-item.d.ts.map +1 -1
  33. package/api/timeline-item.js +3 -1
  34. package/api/timeline-item.js.map +1 -1
  35. package/api/user.d.ts +1 -1
  36. package/api/user.d.ts.map +1 -1
  37. package/api/user.js +2 -2
  38. package/api/user.js.map +1 -1
  39. package/api/visitor.d.ts +225 -1
  40. package/api/visitor.d.ts.map +1 -1
  41. package/api/visitor.js +142 -1
  42. package/api/visitor.js.map +1 -1
  43. package/api/website.d.ts +16 -7
  44. package/api/website.d.ts.map +1 -1
  45. package/api/website.js +16 -2
  46. package/api/website.js.map +1 -1
  47. package/enums.d.ts +2 -0
  48. package/enums.d.ts.map +1 -1
  49. package/enums.js +3 -1
  50. package/enums.js.map +1 -1
  51. package/index.d.ts +10 -8
  52. package/index.d.ts.map +1 -1
  53. package/index.js +10 -8
  54. package/package.json +1 -1
  55. package/realtime-events.d.ts +106 -36
  56. package/realtime-events.d.ts.map +1 -1
  57. package/realtime-events.js +6 -2
  58. package/realtime-events.js.map +1 -1
  59. package/schemas.d.ts +13 -11
  60. package/schemas.d.ts.map +1 -1
  61. package/tool-timeline-policy.d.ts +19 -2
  62. package/tool-timeline-policy.d.ts.map +1 -1
  63. package/tool-timeline-policy.js +29 -6
  64. package/tool-timeline-policy.js.map +1 -1
  65. package/trpc/conversation-hard-limit.d.ts +30 -0
  66. package/trpc/conversation-hard-limit.d.ts.map +1 -0
  67. package/trpc/conversation-hard-limit.js +43 -0
  68. package/trpc/conversation-hard-limit.js.map +1 -0
  69. package/trpc/conversation.d.ts +84 -44
  70. package/trpc/conversation.d.ts.map +1 -1
  71. package/trpc/conversation.js +6 -0
  72. package/trpc/conversation.js.map +1 -1
  73. package/trpc/visitor.d.ts +73 -15
  74. package/trpc/visitor.d.ts.map +1 -1
  75. package/trpc/visitor.js +15 -8
  76. package/trpc/visitor.js.map +1 -1
package/analytics.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ //#region src/analytics.d.ts
2
+ /**
3
+ * Shared satisfaction index calculation.
4
+ *
5
+ * Pure functions with zero dependencies — reusable in API, workers, and frontend.
6
+ */
7
+ declare const SATISFACTION_WEIGHTS: {
8
+ readonly rating: 0.4;
9
+ readonly sentiment: 0.25;
10
+ readonly responseTime: 0.2;
11
+ readonly resolution: 0.15;
12
+ };
13
+ declare const DEFAULT_SATISFACTION_SCORE = 50;
14
+ /**
15
+ * Calculate response time score based on median response time.
16
+ * Faster responses = higher score.
17
+ */
18
+ declare function calculateResponseTimeScore(medianSeconds: number | null): number | null;
19
+ /**
20
+ * Calculate composite satisfaction index from multiple signals.
21
+ * Falls back to DEFAULT_SATISFACTION_SCORE when individual signals are missing.
22
+ */
23
+ declare function calculateSatisfactionIndex(scores: {
24
+ ratingScore: number | null;
25
+ sentimentScore: number | null;
26
+ responseTimeScore: number | null;
27
+ resolutionScore: number | null;
28
+ }): number;
29
+ //#endregion
30
+ export { DEFAULT_SATISFACTION_SCORE, SATISFACTION_WEIGHTS, calculateResponseTimeScore, calculateSatisfactionIndex };
31
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","names":[],"sources":["../src/analytics.ts"],"sourcesContent":[],"mappings":";;AAMA;AAOA;AAMA;AA6BA;cA1Ca;;;;;;cAOA,0BAAA;;;;;iBAMG,0BAAA;;;;;iBA6BA,0BAAA"}
package/analytics.js ADDED
@@ -0,0 +1,41 @@
1
+ //#region src/analytics.ts
2
+ /**
3
+ * Shared satisfaction index calculation.
4
+ *
5
+ * Pure functions with zero dependencies — reusable in API, workers, and frontend.
6
+ */
7
+ const SATISFACTION_WEIGHTS = {
8
+ rating: .4,
9
+ sentiment: .25,
10
+ responseTime: .2,
11
+ resolution: .15
12
+ };
13
+ const DEFAULT_SATISFACTION_SCORE = 50;
14
+ /**
15
+ * Calculate response time score based on median response time.
16
+ * Faster responses = higher score.
17
+ */
18
+ function calculateResponseTimeScore(medianSeconds) {
19
+ if (medianSeconds === null) return null;
20
+ if (medianSeconds <= 300) return 100;
21
+ if (medianSeconds <= 900) return 85;
22
+ if (medianSeconds <= 3600) return 70;
23
+ if (medianSeconds <= 14400) return 50;
24
+ if (medianSeconds <= 86400) return 30;
25
+ return 10;
26
+ }
27
+ /**
28
+ * Calculate composite satisfaction index from multiple signals.
29
+ * Falls back to DEFAULT_SATISFACTION_SCORE when individual signals are missing.
30
+ */
31
+ function calculateSatisfactionIndex(scores) {
32
+ const rating = scores.ratingScore ?? DEFAULT_SATISFACTION_SCORE;
33
+ const sentiment = scores.sentimentScore ?? DEFAULT_SATISFACTION_SCORE;
34
+ const responseTime = scores.responseTimeScore ?? DEFAULT_SATISFACTION_SCORE;
35
+ const resolution = scores.resolutionScore ?? DEFAULT_SATISFACTION_SCORE;
36
+ return SATISFACTION_WEIGHTS.rating * rating + SATISFACTION_WEIGHTS.sentiment * sentiment + SATISFACTION_WEIGHTS.responseTime * responseTime + SATISFACTION_WEIGHTS.resolution * resolution;
37
+ }
38
+
39
+ //#endregion
40
+ export { DEFAULT_SATISFACTION_SCORE, SATISFACTION_WEIGHTS, calculateResponseTimeScore, calculateSatisfactionIndex };
41
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","names":[],"sources":["../src/analytics.ts"],"sourcesContent":["/**\n * Shared satisfaction index calculation.\n *\n * Pure functions with zero dependencies — reusable in API, workers, and frontend.\n */\n\nexport const SATISFACTION_WEIGHTS = {\n\trating: 0.4,\n\tsentiment: 0.25,\n\tresponseTime: 0.2,\n\tresolution: 0.15,\n} as const;\n\nexport const DEFAULT_SATISFACTION_SCORE = 50;\n\n/**\n * Calculate response time score based on median response time.\n * Faster responses = higher score.\n */\nexport function calculateResponseTimeScore(\n\tmedianSeconds: number | null\n): number | null {\n\tif (medianSeconds === null) {\n\t\treturn null;\n\t}\n\n\tif (medianSeconds <= 300) {\n\t\treturn 100; // ≤5 min\n\t}\n\tif (medianSeconds <= 900) {\n\t\treturn 85; // ≤15 min\n\t}\n\tif (medianSeconds <= 3600) {\n\t\treturn 70; // ≤1 hour\n\t}\n\tif (medianSeconds <= 14_400) {\n\t\treturn 50; // ≤4 hours\n\t}\n\tif (medianSeconds <= 86_400) {\n\t\treturn 30; // ≤24 hours\n\t}\n\treturn 10; // >24 hours\n}\n\n/**\n * Calculate composite satisfaction index from multiple signals.\n * Falls back to DEFAULT_SATISFACTION_SCORE when individual signals are missing.\n */\nexport function calculateSatisfactionIndex(scores: {\n\tratingScore: number | null;\n\tsentimentScore: number | null;\n\tresponseTimeScore: number | null;\n\tresolutionScore: number | null;\n}): number {\n\tconst rating = scores.ratingScore ?? DEFAULT_SATISFACTION_SCORE;\n\tconst sentiment = scores.sentimentScore ?? DEFAULT_SATISFACTION_SCORE;\n\tconst responseTime = scores.responseTimeScore ?? DEFAULT_SATISFACTION_SCORE;\n\tconst resolution = scores.resolutionScore ?? DEFAULT_SATISFACTION_SCORE;\n\n\treturn (\n\t\tSATISFACTION_WEIGHTS.rating * rating +\n\t\tSATISFACTION_WEIGHTS.sentiment * sentiment +\n\t\tSATISFACTION_WEIGHTS.responseTime * responseTime +\n\t\tSATISFACTION_WEIGHTS.resolution * resolution\n\t);\n}\n"],"mappings":";;;;;;AAMA,MAAa,uBAAuB;CACnC,QAAQ;CACR,WAAW;CACX,cAAc;CACd,YAAY;CACZ;AAED,MAAa,6BAA6B;;;;;AAM1C,SAAgB,2BACf,eACgB;AAChB,KAAI,kBAAkB,KACrB,QAAO;AAGR,KAAI,iBAAiB,IACpB,QAAO;AAER,KAAI,iBAAiB,IACpB,QAAO;AAER,KAAI,iBAAiB,KACpB,QAAO;AAER,KAAI,iBAAiB,MACpB,QAAO;AAER,KAAI,iBAAiB,MACpB,QAAO;AAER,QAAO;;;;;;AAOR,SAAgB,2BAA2B,QAKhC;CACV,MAAM,SAAS,OAAO,eAAe;CACrC,MAAM,YAAY,OAAO,kBAAkB;CAC3C,MAAM,eAAe,OAAO,qBAAqB;CACjD,MAAM,aAAa,OAAO,mBAAmB;AAE7C,QACC,qBAAqB,SAAS,SAC9B,qBAAqB,YAAY,YACjC,qBAAqB,eAAe,eACpC,qBAAqB,aAAa"}
@@ -1,37 +1,34 @@
1
1
  //#region src/api/ai-agent-capabilities.d.ts
2
2
  declare const AI_AGENT_TOOL_CATEGORIES: readonly ["system", "messaging", "action", "context", "analysis"];
3
3
  type AiAgentToolCategory = (typeof AI_AGENT_TOOL_CATEGORIES)[number];
4
- declare const AI_AGENT_TOOL_IDS: readonly ["searchKnowledgeBase", "identifyVisitor", "updateConversationTitle", "updateSentiment", "setPriority", "sendMessage", "sendPrivateMessage", "respond", "escalate", "resolve", "markSpam", "skip"];
4
+ declare const AI_AGENT_TOOL_GROUPS: readonly ["behavior", "actions"];
5
+ type AiAgentToolGroup = (typeof AI_AGENT_TOOL_GROUPS)[number];
6
+ declare const AI_AGENT_TOOL_IDS: readonly ["searchKnowledgeBase", "identifyVisitor", "updateConversationTitle", "updateSentiment", "setPriority", "categorizeConversation", "sendMessage", "sendPrivateMessage", "respond", "escalate", "resolve", "markSpam", "skip"];
5
7
  type AiAgentToolId = (typeof AI_AGENT_TOOL_IDS)[number];
6
- declare const AI_AGENT_BEHAVIOR_SETTING_KEYS: readonly ["canResolve", "canMarkSpam", "canSetPriority", "canEscalate", "autoGenerateTitle", "autoAnalyzeSentiment"];
8
+ declare const AI_AGENT_BEHAVIOR_SETTING_KEYS: readonly ["canResolve", "canMarkSpam", "canSetPriority", "canEscalate", "autoCategorize", "autoGenerateTitle", "autoAnalyzeSentiment"];
7
9
  type AiAgentBehaviorSettingKey = (typeof AI_AGENT_BEHAVIOR_SETTING_KEYS)[number];
10
+ type AiAgentToolDefaultSkill = {
11
+ name: string;
12
+ label: string;
13
+ description: string;
14
+ content: string;
15
+ };
8
16
  type AiAgentToolCatalogEntry = {
9
17
  id: AiAgentToolId;
10
18
  label: string;
11
19
  description: string;
12
20
  category: AiAgentToolCategory;
21
+ group: AiAgentToolGroup;
22
+ order: number;
13
23
  isSystem: boolean;
14
24
  isRequired: boolean;
15
25
  isToggleable: boolean;
16
26
  behaviorSettingKey: AiAgentBehaviorSettingKey | null;
17
- defaultTemplateNames: string[];
27
+ defaultSkill: AiAgentToolDefaultSkill;
18
28
  };
19
29
  declare const AI_AGENT_TOOL_CATALOG: readonly AiAgentToolCatalogEntry[];
20
- type AiAgentDefaultSkillTemplateEntry = {
21
- name: string;
22
- label: string;
23
- description: string;
24
- content: string;
25
- suggestedToolIds: readonly AiAgentToolId[];
26
- };
27
- declare const AI_AGENT_DEFAULT_SKILL_TEMPLATES: readonly AiAgentDefaultSkillTemplateEntry[];
28
- type AiAgentDefaultSkillTemplate = (typeof AI_AGENT_DEFAULT_SKILL_TEMPLATES)[number];
29
- type AiAgentSystemSkillMetadataEntry = {
30
- name: "agent.md" | "security.md" | "behaviour.md" | "participation.md" | "grounding.md" | "capabilities.md";
31
- label: string;
32
- description: string;
33
- };
34
- declare const AI_AGENT_SYSTEM_SKILL_METADATA: readonly AiAgentSystemSkillMetadataEntry[];
30
+ declare const AI_AGENT_RESERVED_TOOL_SKILL_TEMPLATE_NAMES: readonly string[];
31
+ declare const AI_AGENT_DROPPED_SKILL_TEMPLATE_NAMES: readonly ["reply-or-stay-silent.md", "send-message-behavior.md", "deep-research.md", "grounded-answers.md", "visitor-identification.md", "escalation-playbook.md", "resolution-checklist.md", "spam-detection.md", "priority-triage.md", "sentiment-tracking.md", "title-hygiene.md", "handoff-notes.md", "tone-and-voice.md", "short-clear-replies.md", "wait.md"];
35
32
  //#endregion
36
- export { AI_AGENT_BEHAVIOR_SETTING_KEYS, AI_AGENT_DEFAULT_SKILL_TEMPLATES, AI_AGENT_SYSTEM_SKILL_METADATA, AI_AGENT_TOOL_CATALOG, AI_AGENT_TOOL_CATEGORIES, AI_AGENT_TOOL_IDS, AiAgentBehaviorSettingKey, AiAgentDefaultSkillTemplate, AiAgentSystemSkillMetadataEntry, AiAgentToolCatalogEntry, AiAgentToolCategory, AiAgentToolId };
33
+ export { AI_AGENT_BEHAVIOR_SETTING_KEYS, AI_AGENT_DROPPED_SKILL_TEMPLATE_NAMES, AI_AGENT_RESERVED_TOOL_SKILL_TEMPLATE_NAMES, AI_AGENT_TOOL_CATALOG, AI_AGENT_TOOL_CATEGORIES, AI_AGENT_TOOL_GROUPS, AI_AGENT_TOOL_IDS, AiAgentBehaviorSettingKey, AiAgentToolCatalogEntry, AiAgentToolCategory, AiAgentToolDefaultSkill, AiAgentToolGroup, AiAgentToolId };
37
34
  //# sourceMappingURL=ai-agent-capabilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-agent-capabilities.d.ts","names":[],"sources":["../../src/api/ai-agent-capabilities.ts"],"sourcesContent":[],"mappings":";cAKa;AAAA,KAQD,mBAAA,GAFF,CAAA,OAEgC,wBAFhC,CAAA,CAAA,MAAA,CAAA;AAEE,cAEC,iBAFkB,EAAW,SAAA,CAAA,qBAAwB,EAAA,iBAAA,EAAA,yBAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,aAAA,EAAA,oBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAErD,KAeD,aAAA,GAFF,CAAA,OAE0B,iBAF1B,CAAA,CAAA,MAAA,CAAA;AAEE,cAEC,8BAFwC,EAAA,SAAA,CAAA,YAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,aAAA,EAAA,mBAAA,EAAA,sBAAA,CAAA;AAExC,KASD,yBAAA,GAFF,CAAA,OAGD,8BAHC,CAAA,CAAA,MAAA,CAAA;AAEE,KAGA,uBAAA,GAHyB;EAGzB,EAAA,EACP,aADO;EACP,KAAA,EAAA,MAAA;EAGM,WAAA,EAAA,MAAA;EAIU,QAAA,EAJV,mBAIU;EAAyB,QAAA,EAAA,OAAA;EAIjC,UAAA,EAAA,OAAA;EAgXR,YAAA,EAAA,OAAA;EAQQ,kBAAA,EA5XQ,yBAoYjB,GARoD,IAAA;EAU5C,oBAAA,EAAA,MAAA,EAA2B;AAGvC,CAAA;AAYa,cAjZA,qBAqbX,EAAA,SArb2C,uBAiZS,EAAA;KAjCjD,gCAAA;;;;;6BAKuB;;cAGf,2CAA2C;KAU5C,2BAAA,WACH;KAEG,+BAAA;;;;;cAYC,yCAAyC"}
1
+ {"version":3,"file":"ai-agent-capabilities.d.ts","names":[],"sources":["../../src/api/ai-agent-capabilities.ts"],"sourcesContent":[],"mappings":";cAKa;AAAA,KAQD,mBAAA,GAFF,CAAA,OAEgC,wBAFhC,CAAA,CAAA,MAAA,CAAA;AAEE,cAEC,oBAF6B,EAAA,SAAA,CAAA,UAAA,EAAwB,SAAA,CAAA;AAErD,KACD,gBAAA,GADwD,CAAA,OAC7B,oBAD6B,CAAA,CAAA,MAAA,CAAA;AACxD,cAEC,iBAF0B,EAAA,SAAA,CAAA,qBAAoB,EAAA,iBAAA,EAAA,yBAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,wBAAA,EAAA,aAAA,EAAA,oBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAE9C,KAgBD,aAAA,GAFF,CAAA,OAE0B,iBAF1B,CAAA,CAAA,MAAA,CAAA;AAEE,cAEC,8BAFwC,EAAA,SAAA,CAAA,YAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,mBAAA,EAAA,sBAAA,CAAA;AAExC,KAUD,yBAAA,GAFF,CAAA,OAGD,8BAHC,CAAA,CAAA,MAAA,CAAA;AAEE,KAGA,uBAAA,GAHyB;EAGzB,IAAA,EAAA,MAAA;EAOA,KAAA,EAAA,MAAA;EACP,WAAA,EAAA,MAAA;EAGM,OAAA,EAAA,MAAA;CACH;AAKa,KAVT,uBAAA,GAUS;EACN,EAAA,EAVV,aAUU;EAAuB,KAAA,EAAA,MAAA;EAiTzB,WAAA,EAAA,MAAA;EAaA,QAAA,EArUF,mBAqUE;EAIA,KAAA,EAxUL,gBAwUK;;;;;sBAnUQ;gBACN;;cAiTF,gCAAgC;cAahC;cAIA"}