@lssm/example.ai-support-bot 0.0.0-canary-20251217080011 → 0.0.0-canary-20251219202229
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.
- package/.turbo/turbo-build$colon$bundle.log +109 -74
- package/.turbo/turbo-build.log +110 -18
- package/CHANGELOG.md +6 -6
- package/LICENSE +21 -0
- package/dist/docs/ai-support-bot.docblock.js +2 -1
- package/dist/docs/ai-support-bot.docblock.js.map +1 -0
- package/dist/example.d.ts +2 -1
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +2 -1
- package/dist/example.js.map +1 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/index.js +2 -6
- package/dist/libs/contracts/dist/docs/meta.docs.js +30 -0
- package/dist/libs/contracts/dist/docs/meta.docs.js.map +1 -0
- package/dist/libs/contracts/dist/docs/presentations.js +2 -1
- package/dist/libs/contracts/dist/docs/presentations.js.map +1 -0
- package/dist/libs/contracts/dist/docs/registry.js +2 -1
- package/dist/libs/contracts/dist/docs/registry.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +2 -1
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js.map +1 -0
- package/dist/libs/contracts/dist/docs/tech-contracts.docs.js +97 -0
- package/dist/libs/contracts/dist/docs/tech-contracts.docs.js.map +1 -0
- package/dist/libs/logger/dist/context.node.js +2 -1
- package/dist/libs/logger/dist/context.node.js.map +1 -0
- package/dist/libs/logger/dist/formatters.js +2 -1
- package/dist/libs/logger/dist/formatters.js.map +1 -0
- package/dist/libs/logger/dist/logger.node.js +2 -1
- package/dist/libs/logger/dist/logger.node.js.map +1 -0
- package/dist/libs/logger/dist/timer.js +2 -1
- package/dist/libs/logger/dist/timer.js.map +1 -0
- package/dist/libs/logger/dist/tracer.node.js +2 -1
- package/dist/libs/logger/dist/tracer.node.js.map +1 -0
- package/dist/libs/logger/dist/types.js +2 -1
- package/dist/libs/logger/dist/types.js.map +1 -0
- package/dist/libs/support-bot/dist/bot/auto-responder.js +2 -1
- package/dist/libs/support-bot/dist/bot/auto-responder.js.map +1 -0
- package/dist/libs/support-bot/dist/bot/tools.js +2 -1
- package/dist/libs/support-bot/dist/bot/tools.js.map +1 -0
- package/dist/libs/support-bot/dist/rag/ticket-resolver.js +2 -1
- package/dist/libs/support-bot/dist/rag/ticket-resolver.js.map +1 -0
- package/dist/libs/support-bot/dist/tickets/classifier.js +2 -1
- package/dist/libs/support-bot/dist/tickets/classifier.js.map +1 -0
- package/dist/setup.d.ts +2 -1
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +2 -1
- package/dist/setup.js.map +1 -0
- package/package.json +11 -10
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.node.js","names":["LogContext"],"sources":["../../../../../../libs/logger/dist/context.node.mjs"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\n//#region src/context.node.ts\n/**\n* Node.js implementation of LogContext using AsyncLocalStorage.\n*/\nvar LogContext = class LogContext {\n\tstatic instance;\n\tstorage;\n\tconstructor() {\n\t\tthis.storage = new AsyncLocalStorage();\n\t}\n\tstatic getInstance() {\n\t\tif (!LogContext.instance) LogContext.instance = new LogContext();\n\t\treturn LogContext.instance;\n\t}\n\t/**\n\t* Run a function with a new context\n\t*/\n\trun(context, fn) {\n\t\tconst contextData = {\n\t\t\tcontext: { ...context },\n\t\t\ttrace: this.getCurrentTrace()\n\t\t};\n\t\treturn this.storage.run(contextData, fn);\n\t}\n\t/**\n\t* Run a function with an extended context (merges with current)\n\t*/\n\textend(additionalContext, fn) {\n\t\tconst mergedContext = {\n\t\t\t...this.getContext(),\n\t\t\t...additionalContext\n\t\t};\n\t\treturn this.run(mergedContext, fn);\n\t}\n\t/**\n\t* Set context data for the current execution context\n\t*/\n\tset(key, value) {\n\t\tconst current = this.storage.getStore();\n\t\tif (current) current.context[key] = value;\n\t}\n\t/**\n\t* Get a specific context value\n\t*/\n\tget(key) {\n\t\treturn this.storage.getStore()?.context?.[key];\n\t}\n\t/**\n\t* Get all context data\n\t*/\n\tgetContext() {\n\t\treturn this.storage.getStore()?.context || {};\n\t}\n\t/**\n\t* Set trace context\n\t*/\n\tsetTrace(trace) {\n\t\tconst current = this.storage.getStore();\n\t\tif (current) current.trace = trace;\n\t}\n\t/**\n\t* Get current trace context\n\t*/\n\tgetCurrentTrace() {\n\t\treturn this.storage.getStore()?.trace;\n\t}\n\t/**\n\t* Generate a unique ID for requests/operations\n\t*/\n\tgenerateId() {\n\t\treturn crypto.randomUUID();\n\t}\n};\n\n//#endregion\nexport { LogContext };\n//# sourceMappingURL=context.node.mjs.map"],"mappings":";;;;;;AAMA,IAAI,aAAa,MAAMA,aAAW;CACjC,OAAO;CACP;CACA,cAAc;AACb,OAAK,UAAU,IAAI,mBAAmB;;CAEvC,OAAO,cAAc;AACpB,MAAI,CAACA,aAAW,SAAU,cAAW,WAAW,IAAIA,cAAY;AAChE,SAAOA,aAAW;;;;;CAKnB,IAAI,SAAS,IAAI;EAChB,MAAM,cAAc;GACnB,SAAS,EAAE,GAAG,SAAS;GACvB,OAAO,KAAK,iBAAiB;GAC7B;AACD,SAAO,KAAK,QAAQ,IAAI,aAAa,GAAG;;;;;CAKzC,OAAO,mBAAmB,IAAI;EAC7B,MAAM,gBAAgB;GACrB,GAAG,KAAK,YAAY;GACpB,GAAG;GACH;AACD,SAAO,KAAK,IAAI,eAAe,GAAG;;;;;CAKnC,IAAI,KAAK,OAAO;EACf,MAAM,UAAU,KAAK,QAAQ,UAAU;AACvC,MAAI,QAAS,SAAQ,QAAQ,OAAO;;;;;CAKrC,IAAI,KAAK;AACR,SAAO,KAAK,QAAQ,UAAU,EAAE,UAAU;;;;;CAK3C,aAAa;AACZ,SAAO,KAAK,QAAQ,UAAU,EAAE,WAAW,EAAE;;;;;CAK9C,SAAS,OAAO;EACf,MAAM,UAAU,KAAK,QAAQ,UAAU;AACvC,MAAI,QAAS,SAAQ,QAAQ;;;;;CAK9B,kBAAkB;AACjB,SAAO,KAAK,QAAQ,UAAU,EAAE;;;;;CAKjC,aAAa;AACZ,SAAO,OAAO,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","names":[],"sources":["../../../../../../libs/logger/dist/formatters.mjs"],"sourcesContent":["import { LogLevel } from \"./types.mjs\";\n\n//#region src/formatters.ts\nconst colors = {\n\treset: \"\\x1B[0m\",\n\tbright: \"\\x1B[1m\",\n\tdim: \"\\x1B[2m\",\n\tred: \"\\x1B[31m\",\n\tgreen: \"\\x1B[32m\",\n\tyellow: \"\\x1B[33m\",\n\tblue: \"\\x1B[34m\",\n\tmagenta: \"\\x1B[35m\",\n\tcyan: \"\\x1B[36m\",\n\twhite: \"\\x1B[37m\",\n\tgray: \"\\x1B[90m\",\n\tbgRed: \"\\x1B[41m\",\n\tbgYellow: \"\\x1B[43m\"\n};\nconst levelConfig = {\n\t[LogLevel.TRACE]: {\n\t\tcolor: colors.gray,\n\t\tsymbol: \"○\",\n\t\tname: \"TRACE\"\n\t},\n\t[LogLevel.DEBUG]: {\n\t\tcolor: colors.blue,\n\t\tsymbol: \"●\",\n\t\tname: \"DEBUG\"\n\t},\n\t[LogLevel.INFO]: {\n\t\tcolor: colors.green,\n\t\tsymbol: \"●\",\n\t\tname: \"INFO \"\n\t},\n\t[LogLevel.WARN]: {\n\t\tcolor: colors.yellow,\n\t\tsymbol: \"▲\",\n\t\tname: \"WARN \"\n\t},\n\t[LogLevel.ERROR]: {\n\t\tcolor: colors.red,\n\t\tsymbol: \"✖\",\n\t\tname: \"ERROR\"\n\t},\n\t[LogLevel.FATAL]: {\n\t\tcolor: colors.bgRed + colors.white,\n\t\tsymbol: \"💀\",\n\t\tname: \"FATAL\"\n\t}\n};\nvar DevFormatter = class {\n\tenableColors;\n\tconstructor(enableColors = true) {\n\t\tthis.enableColors = enableColors;\n\t}\n\tformat(entry) {\n\t\tconst parts = [];\n\t\tconst config = levelConfig[entry.level];\n\t\tconst timestamp = this.formatTimestamp(entry.timestamp);\n\t\tparts.push(this.colorize(timestamp, colors.gray));\n\t\tconst levelText = `${config.symbol} ${config.name}`;\n\t\tparts.push(this.colorize(levelText, config.color));\n\t\tif (entry.traceId) {\n\t\t\tconst traceInfo = this.formatTraceInfo(entry);\n\t\t\tparts.push(this.colorize(traceInfo, colors.cyan));\n\t\t}\n\t\tparts.push(this.colorize(entry.message, colors.white));\n\t\tif (entry.duration !== void 0) {\n\t\t\tconst durationText = `(${this.formatDuration(entry.duration)})`;\n\t\t\tparts.push(this.colorize(durationText, colors.magenta));\n\t\t}\n\t\tlet output = parts.join(\" \");\n\t\tif (entry.context && Object.keys(entry.context).length > 0) output += \"\\n\" + this.formatContext(entry.context);\n\t\tif (entry.metadata && Object.keys(entry.metadata).length > 0) output += \"\\n\" + this.formatMetadata(entry.metadata);\n\t\tif (entry.error) output += \"\\n\" + this.formatError(entry.error);\n\t\tif (entry.tags && entry.tags.length > 0) {\n\t\t\tconst tagsText = entry.tags.map((tag) => `#${tag}`).join(\" \");\n\t\t\toutput += \"\\n\" + this.colorize(`Tags: ${tagsText}`, colors.blue);\n\t\t}\n\t\treturn output;\n\t}\n\tformatTimestamp(timestamp) {\n\t\treturn timestamp.toISOString().substring(11, 23);\n\t}\n\tformatTraceInfo(entry) {\n\t\tconst parts = [`trace:${entry.traceId?.substring(0, 8) || \"unknown\"}`];\n\t\tif (entry.spanId && entry.spanId.length >= 8) parts.push(`span:${entry.spanId.substring(0, 8)}`);\n\t\tif (entry.parentId && entry.parentId.length >= 8) parts.push(`parent:${entry.parentId.substring(0, 8)}`);\n\t\treturn `[${parts.join(\"|\")}]`;\n\t}\n\tformatDuration(duration) {\n\t\tif (duration < 1) return `${(duration * 1e3).toFixed(0)}μs`;\n\t\telse if (duration < 1e3) return `${duration.toFixed(2)}ms`;\n\t\telse return `${(duration / 1e3).toFixed(2)}s`;\n\t}\n\tformatContext(context) {\n\t\tconst formatted = this.formatObject(context, 2);\n\t\treturn this.colorize(`Context: ${formatted}`, colors.cyan);\n\t}\n\tformatMetadata(metadata) {\n\t\tconst formatted = this.formatObject(metadata, 2);\n\t\treturn this.colorize(`Metadata: ${formatted}`, colors.blue);\n\t}\n\tformatError(error) {\n\t\tlet output = this.colorize(`Error: ${error.name}: ${error.message}`, colors.red);\n\t\tif (error.stack) {\n\t\t\tconst indentedStack = error.stack.split(\"\\n\").slice(1, 6).map((line) => ` ${line}`).join(\"\\n\");\n\t\t\toutput += \"\\n\" + this.colorize(indentedStack, colors.gray);\n\t\t}\n\t\treturn output;\n\t}\n\tformatObject(obj, indent = 0) {\n\t\tconst spaces = \" \".repeat(indent);\n\t\tconst entries = Object.entries(obj);\n\t\tif (entries.length === 0) return \"{}\";\n\t\tif (entries[0] && typeof entries[0][1] !== \"object\") return `{ ${entries[0][0]}: ${this.formatValue(entries[0][1])} }`;\n\t\treturn `{\\n${entries.map(([key, value]) => {\n\t\t\treturn `${spaces} ${key}: ${this.formatValue(value, indent + 2)}`;\n\t\t}).join(\"\\n\")}\\n${spaces}}`;\n\t}\n\tformatValue(value, indent = 0) {\n\t\tif (value === null) return \"null\";\n\t\tif (value === void 0) return \"undefined\";\n\t\tif (typeof value === \"string\") return `\"${value}\"`;\n\t\tif (typeof value === \"boolean\" || typeof value === \"number\") return String(value);\n\t\tif (value instanceof Date) return value.toISOString();\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length === 0) return \"[]\";\n\t\t\treturn `[${value.map((v) => this.formatValue(v)).join(\", \")}]`;\n\t\t}\n\t\tif (typeof value === \"object\") return this.formatObject(value, indent);\n\t\treturn String(value);\n\t}\n\tcolorize(text, color) {\n\t\tif (!this.enableColors) return text;\n\t\treturn `${color}${text}${colors.reset}`;\n\t}\n};\nvar ProductionFormatter = class {\n\tformat(entry) {\n\t\tconst logObject = {\n\t\t\ttimestamp: entry.timestamp,\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message\n\t\t};\n\t\tif (entry.traceId) logObject.traceId = entry.traceId;\n\t\tif (entry.spanId) logObject.spanId = entry.spanId;\n\t\tif (entry.parentId) logObject.parentId = entry.parentId;\n\t\tif (entry.duration !== void 0) logObject.duration = entry.duration;\n\t\tif (entry.context && Object.keys(entry.context).length > 0) logObject.context = entry.context;\n\t\tif (entry.metadata && Object.keys(entry.metadata).length > 0) logObject.metadata = entry.metadata;\n\t\tif (entry.error) logObject.error = {\n\t\t\tname: entry.error.name,\n\t\t\tmessage: entry.error.message,\n\t\t\tstack: entry.error.stack\n\t\t};\n\t\tif (entry.tags && entry.tags.length > 0) logObject.tags = entry.tags;\n\t\treturn JSON.stringify(logObject);\n\t}\n};\nvar CustomFormatter = class {\n\ttemplate;\n\tdateFormat;\n\tconstructor(template = \"{timestamp} [{level}] {message}\", dateFormat) {\n\t\tthis.template = template;\n\t\tthis.dateFormat = dateFormat || ((date) => date.toISOString());\n\t}\n\tformat(entry) {\n\t\tconst levelName = LogLevel[entry.level];\n\t\tconst timestamp = this.dateFormat(entry.timestamp);\n\t\tlet formatted = this.template.replace(\"{timestamp}\", timestamp).replace(\"{level}\", levelName).replace(\"{message}\", entry.message).replace(\"{traceId}\", entry.traceId || \"\").replace(\"{spanId}\", entry.spanId || \"\").replace(\"{duration}\", entry.duration?.toString() || \"\");\n\t\tif (entry.context) formatted = formatted.replace(\"{context}\", JSON.stringify(entry.context));\n\t\tif (entry.metadata) formatted = formatted.replace(\"{metadata}\", JSON.stringify(entry.metadata));\n\t\treturn formatted;\n\t}\n};\n\n//#endregion\nexport { CustomFormatter, DevFormatter, ProductionFormatter };\n//# sourceMappingURL=formatters.mjs.map"],"mappings":";;;AAGA,MAAM,SAAS;CACd,OAAO;CACP,QAAQ;CACR,KAAK;CACL,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACN,OAAO;CACP,UAAU;CACV;AACD,MAAM,cAAc;EAClB,SAAS,QAAQ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;AAC/B,SAAO,GAAG,QAAQ,OAAO,OAAO;;;AAGlC,IAAI,sBAAsB,MAAM;CAC/B,OAAO,OAAO;EACb,MAAM,YAAY;GACjB,WAAW,MAAM;GACjB,OAAO,MAAM;GACb,SAAS,MAAM;GACf;AACD,MAAI,MAAM,QAAS,WAAU,UAAU,MAAM;AAC7C,MAAI,MAAM,OAAQ,WAAU,SAAS,MAAM;AAC3C,MAAI,MAAM,SAAU,WAAU,WAAW,MAAM;AAC/C,MAAI,MAAM,aAAa,KAAK,EAAG,WAAU,WAAW,MAAM;AAC1D,MAAI,MAAM,WAAW,OAAO,KAAK,MAAM,QAAQ,CAAC,SAAS,EAAG,WAAU,UAAU,MAAM;AACtF,MAAI,MAAM,YAAY,OAAO,KAAK,MAAM,SAAS,CAAC,SAAS,EAAG,WAAU,WAAW,MAAM;AACzF,MAAI,MAAM,MAAO,WAAU,QAAQ;GAClC,MAAM,MAAM,MAAM;GAClB,SAAS,MAAM,MAAM;GACrB,OAAO,MAAM,MAAM;GACnB;AACD,MAAI,MAAM,QAAQ,MAAM,KAAK,SAAS,EAAG,WAAU,OAAO,MAAM;AAChE,SAAO,KAAK,UAAU,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.node.js","names":["Logger"],"sources":["../../../../../../libs/logger/dist/logger.node.mjs"],"sourcesContent":["import { LogContext } from \"./context.node.mjs\";\nimport { LogLevel } from \"./types.mjs\";\nimport { TimerManager } from \"./timer.mjs\";\nimport { Tracer } from \"./tracer.node.mjs\";\nimport { DevFormatter, ProductionFormatter } from \"./formatters.mjs\";\n\n//#region src/logger.node.ts\nvar Logger = class Logger {\n\tconfig;\n\tformatter;\n\tcontext;\n\ttracer;\n\ttimerManager;\n\tconstructor(config) {\n\t\tthis.config = {\n\t\t\tlevel: LogLevel.INFO,\n\t\t\tenvironment: process.env.NODE_ENV || \"development\",\n\t\t\tenableTracing: true,\n\t\t\tenableTiming: true,\n\t\t\tenableContext: true,\n\t\t\tenableColors: true,\n\t\t\tmaxContextDepth: 10,\n\t\t\ttimestampFormat: \"iso\",\n\t\t\t...config\n\t\t};\n\t\tthis.context = LogContext.getInstance();\n\t\tthis.tracer = new Tracer();\n\t\tthis.timerManager = new TimerManager();\n\t\tthis.formatter = this.config.environment === \"production\" ? new ProductionFormatter() : new DevFormatter(this.config.enableColors);\n\t}\n\ttraceLog(message, metadata) {\n\t\tthis.log(LogLevel.TRACE, message, metadata);\n\t}\n\tdebug(message, metadata) {\n\t\tthis.log(LogLevel.DEBUG, message, metadata);\n\t}\n\tinfo(message, metadata) {\n\t\tthis.log(LogLevel.INFO, message, metadata);\n\t}\n\twarn(message, metadata) {\n\t\tthis.log(LogLevel.WARN, message, metadata);\n\t}\n\terror(message, metadata, error) {\n\t\tthis.log(LogLevel.ERROR, message, metadata, error);\n\t}\n\tfatal(message, metadata, error) {\n\t\tthis.log(LogLevel.FATAL, message, metadata, error);\n\t}\n\twithContext(context, fn) {\n\t\treturn this.context.run(context, fn);\n\t}\n\textendContext(additionalContext, fn) {\n\t\treturn this.context.extend(additionalContext, fn);\n\t}\n\tsetContext(key, value) {\n\t\tthis.context.set(key, value);\n\t}\n\tgetContext() {\n\t\treturn this.context.getContext();\n\t}\n\ttrace = async (options, fn) => {\n\t\tif (!this.config.enableTracing) return await fn();\n\t\treturn this.tracer.trace(options, fn);\n\t};\n\tgetTraceId() {\n\t\treturn this.tracer.getCurrentTrace()?.traceId;\n\t}\n\tstartSpan(options) {\n\t\tif (!this.config.enableTracing) return null;\n\t\treturn this.tracer.startSpan(options);\n\t}\n\tfinishSpan(spanId) {\n\t\tif (!this.config.enableTracing) return;\n\t\treturn this.tracer.finishSpan(spanId);\n\t}\n\taddTraceMetadata(key, value) {\n\t\tif (this.config.enableTracing) this.tracer.addMetadata(key, value);\n\t}\n\taddTraceTags(...tags) {\n\t\tif (this.config.enableTracing) this.tracer.addTags(...tags);\n\t}\n\tstartTimer(id) {\n\t\tif (!this.config.enableTiming) return null;\n\t\treturn this.timerManager.start(id);\n\t}\n\tstopTimer(id) {\n\t\tif (!this.config.enableTiming) return;\n\t\treturn this.timerManager.stop(id);\n\t}\n\tgetTimer(id) {\n\t\treturn this.timerManager.get(id);\n\t}\n\tchild(context) {\n\t\tconst childLogger = new Logger(this.config);\n\t\tObject.entries(context).forEach(([key, value]) => {\n\t\t\tchildLogger.setContext(key, value);\n\t\t});\n\t\treturn childLogger;\n\t}\n\tsetLevel(level) {\n\t\tthis.config.level = level;\n\t}\n\tsetFormatter(formatter) {\n\t\tthis.formatter = formatter;\n\t}\n\tasync profile(operationName, fn, options) {\n\t\tconst timer = this.startTimer(`profile-${operationName}`);\n\t\tconst startTime = performance.now();\n\t\ttry {\n\t\t\tconst result = await this.tracer.trace({\n\t\t\t\toperationType: \"custom\",\n\t\t\t\toperationName: `profile:${operationName}`,\n\t\t\t\tautoTiming: true\n\t\t\t}, fn);\n\t\t\tconst duration = performance.now() - startTime;\n\t\t\ttimer?.stop();\n\t\t\tconst logLevel = options?.logLevel || LogLevel.DEBUG;\n\t\t\tthis.log(logLevel, `Profile: ${operationName} completed`, {\n\t\t\t\toperation: operationName,\n\t\t\t\tduration: `${duration.toFixed(2)}ms`,\n\t\t\t\tresult: options?.logResult ? result : \"[result hidden]\"\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tconst duration = performance.now() - startTime;\n\t\t\ttimer?.stop();\n\t\t\tthis.error(`Profile: ${operationName} failed`, {\n\t\t\t\toperation: operationName,\n\t\t\t\tduration: `${duration.toFixed(2)}ms`,\n\t\t\t\terror: error.message\n\t\t\t}, error);\n\t\t\tthrow error;\n\t\t}\n\t}\n\tlogRequest(method, url, statusCode, duration) {\n\t\tconst level = this.getHttpLogLevel(statusCode);\n\t\tconst message = `${method.toUpperCase()} ${url}${statusCode ? ` ${statusCode}` : \"\"}`;\n\t\tthis.log(level, message, {\n\t\t\tmethod,\n\t\t\turl,\n\t\t\tstatusCode,\n\t\t\tduration: duration ? `${duration.toFixed(2)}ms` : void 0,\n\t\t\ttype: \"http_request\"\n\t\t});\n\t}\n\tasync flush() {\n\t\tthis.timerManager.clear();\n\t}\n\tgetStats() {\n\t\treturn {\n\t\t\tactiveTimers: this.timerManager.getActive().length,\n\t\t\tactiveSpans: this.tracer.getActiveSpans().length,\n\t\t\tconfig: { ...this.config }\n\t\t};\n\t}\n\toutput(message, level) {\n\t\tif (level >= LogLevel.ERROR) console.error(message);\n\t\telse console.log(message);\n\t}\n\tlog(level, message, metadata, error) {\n\t\tif (level < this.config.level) return;\n\t\tconst currentTrace = this.config.enableTracing ? this.tracer.getCurrentTrace() : void 0;\n\t\tconst contextData = this.config.enableContext ? this.context.getContext() : void 0;\n\t\tconst entry = {\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t\ttimestamp: /* @__PURE__ */ new Date(),\n\t\t\ttraceId: currentTrace?.traceId,\n\t\t\tparentId: currentTrace?.parentId,\n\t\t\tspanId: currentTrace?.spanId,\n\t\t\tcontext: contextData,\n\t\t\tmetadata,\n\t\t\terror,\n\t\t\ttags: currentTrace?.tags\n\t\t};\n\t\tif (currentTrace?.metadata?.duration) entry.duration = currentTrace.metadata.duration;\n\t\tconst formatted = this.formatter.format(entry);\n\t\tthis.output(formatted, level);\n\t}\n\tgetHttpLogLevel(statusCode) {\n\t\tif (!statusCode) return LogLevel.INFO;\n\t\tif (statusCode >= 500) return LogLevel.ERROR;\n\t\tif (statusCode >= 400) return LogLevel.WARN;\n\t\treturn LogLevel.INFO;\n\t}\n};\n\n//#endregion\nexport { Logger };\n//# sourceMappingURL=logger.node.mjs.map"],"mappings":";;;;;;;AAOA,IAAI,SAAS,MAAMA,SAAO;CACzB;CACA;CACA;CACA;CACA;CACA,YAAY,QAAQ;AACnB,OAAK,SAAS;GACb,OAAO,SAAS;GAChB,aAAa,QAAQ,IAAI,YAAY;GACrC,eAAe;GACf,cAAc;GACd,eAAe;GACf,cAAc;GACd,iBAAiB;GACjB,iBAAiB;GACjB,GAA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;AAC3B,MAAI,CAAC,WAAY,QAAO,SAAS;AACjC,MAAI,cAAc,IAAK,QAAO,SAAS;AACvC,MAAI,cAAc,IAAK,QAAO,SAAS;AACvC,SAAO,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timer.js","names":[],"sources":["../../../../../../libs/logger/dist/timer.mjs"],"sourcesContent":["//#region src/timer.ts\nvar Timer = class {\n\tid;\n\tstartTime;\n\tlaps = [];\n\tstopped = false;\n\tstopTime;\n\tconstructor(id) {\n\t\tthis.id = id || crypto.randomUUID();\n\t\tthis.startTime = performance.now();\n\t}\n\t/**\n\t* Stop the timer and return elapsed time in milliseconds\n\t*/\n\tstop() {\n\t\tif (this.stopped) return this.getElapsed();\n\t\tthis.stopTime = performance.now();\n\t\tthis.stopped = true;\n\t\tconst elapsed = this.stopTime - this.startTime;\n\t\tthis.laps.push({\n\t\t\tlabel: \"stop\",\n\t\t\ttime: this.stopTime,\n\t\t\telapsed\n\t\t});\n\t\treturn elapsed;\n\t}\n\t/**\n\t* Record a lap time and return elapsed time since start\n\t*/\n\tlap(label) {\n\t\tif (this.stopped) return this.getElapsed();\n\t\tconst now = performance.now();\n\t\tconst elapsed = now - this.startTime;\n\t\tthis.laps.push({\n\t\t\tlabel: label || `lap-${this.laps.length + 1}`,\n\t\t\ttime: now,\n\t\t\telapsed\n\t\t});\n\t\treturn elapsed;\n\t}\n\t/**\n\t* Get elapsed time without stopping the timer\n\t*/\n\tgetElapsed() {\n\t\tif (this.stopped && this.stopTime) return this.stopTime - this.startTime;\n\t\treturn performance.now() - this.startTime;\n\t}\n\t/**\n\t* Get all recorded laps\n\t*/\n\tgetLaps() {\n\t\treturn [...this.laps];\n\t}\n\t/**\n\t* Get timer summary with total time and laps\n\t*/\n\tgetSummary() {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\ttotalTime: this.getElapsed(),\n\t\t\tisRunning: !this.stopped,\n\t\t\tlaps: this.getLaps()\n\t\t};\n\t}\n\t/**\n\t* Reset the timer (starts a new timing session)\n\t*/\n\treset() {\n\t\tthis.startTime = performance.now();\n\t\tthis.laps = [];\n\t\tthis.stopped = false;\n\t\tthis.stopTime = void 0;\n\t}\n};\n/**\n* Utility class for managing multiple timers\n*/\nvar TimerManager = class {\n\ttimers = /* @__PURE__ */ new Map();\n\t/**\n\t* Start a new timer\n\t*/\n\tstart(id) {\n\t\tconst timer = new Timer(id);\n\t\tthis.timers.set(timer.id, timer);\n\t\treturn timer;\n\t}\n\t/**\n\t* Get an existing timer\n\t*/\n\tget(id) {\n\t\treturn this.timers.get(id);\n\t}\n\t/**\n\t* Stop and remove a timer\n\t*/\n\tstop(id) {\n\t\tconst timer = this.timers.get(id);\n\t\tif (timer) {\n\t\t\tconst elapsed = timer.stop();\n\t\t\tthis.timers.delete(id);\n\t\t\treturn elapsed;\n\t\t}\n\t}\n\t/**\n\t* Get all active timers\n\t*/\n\tgetActive() {\n\t\treturn Array.from(this.timers.values()).filter((timer) => !timer.getSummary().isRunning === false);\n\t}\n\t/**\n\t* Clear all timers\n\t*/\n\tclear() {\n\t\tthis.timers.clear();\n\t}\n\t/**\n\t* Get summary of all timers\n\t*/\n\tgetSummary() {\n\t\treturn Array.from(this.timers.values()).map((timer) => timer.getSummary());\n\t}\n};\n/**\n* Decorator/wrapper function to time async operations\n*/\nasync function timed(operation, options) {\n\tconst timer = new Timer(options?.id);\n\ttry {\n\t\tconst result = await operation();\n\t\tconst elapsed = timer.stop();\n\t\toptions?.onComplete?.(elapsed);\n\t\treturn {\n\t\t\tresult,\n\t\t\telapsed,\n\t\t\ttimer\n\t\t};\n\t} catch (error) {\n\t\ttimer.stop();\n\t\tthrow error;\n\t}\n}\n/**\n* Decorator/wrapper function to time synchronous operations\n*/\nfunction timedSync(operation, options) {\n\tconst timer = new Timer(options?.id);\n\ttry {\n\t\tconst result = operation();\n\t\tconst elapsed = timer.stop();\n\t\toptions?.onComplete?.(elapsed);\n\t\treturn {\n\t\t\tresult,\n\t\t\telapsed,\n\t\t\ttimer\n\t\t};\n\t} catch (error) {\n\t\ttimer.stop();\n\t\tthrow error;\n\t}\n}\n\n//#endregion\nexport { Timer, TimerManager, timed, timedSync };\n//# sourceMappingURL=timer.mjs.map"],"mappings":";AACA,IAAI,QAAQ,MAAM;CACjB;CACA;CACA,OAAO,EAAE;CACT,UAAU;CACV;CACA,YAAY,IAAI;AACf,OAAK,KAAK,MAAM,OAAO,YAAY;AACnC,OAAK,YAAY,YAAY,KAAK;;;;;CAKnC,OAAO;AACN,MAAI,KAAK,QAAS,QAAO,KAAK,YAAY;AAC1C,OAAK,WAAW,YAAY,KAAK;AACjC,OAAK,UAAU;EACf,MAAM,UAAU,KAAK,WAAW,KAAK;AACrC,OAAK,KAAK,KAAK;GACd,OAAO;GACP,MAAM,KAAK;GACX;GACA,CAAC;AACF,SAAO;;;;;CAKR,IAAI,OAAO;AACV,MAAI,KAAK,QAAS,QAAO,KAAK,YAAY;EAC1C,MAAM,MAAM,YAAY,KAAK;EAC7B,MAAM,UAAU,MAAM,KAAK;AAC3B,OAAK,KAAK,KAAK;GACd,OAAO,SAAS,OAAO,KAAK,KAAK,SAAS;GAC1C,MAAM;GACN;GACA,CAAC;AACF,SAAO;;;;;CAKR,aAAa;AACZ,MAAI,KAAK,WAAW,KAAK,SAAU,QAAO,KAAK,WAAW,KAAK;AAC/D,SAAO,YAAY,KAAK,GAAG,KAAK;;;;;CAKjC,UAAU;AACT,SAAO,CAAC,GAAG,KAAK,KAAK;;;;;CAKtB,aAAa;AACZ,SAAO;GACN,IAAI,KAAK;GACT,WAAW,KAAK,YAAY;GAC5B,WAAW,CAAC,KAAK;GACjB,MAAM,KAAK,SAAS;GACpB;;;;;CAKF,QAAQ;AACP,OAAK,YAAY,YAAY,KAAK;AAClC,OAAK,OAAO,EAAE;AACd,OAAK,UAAU;AACf,OAAK,WAAW,KAAK;;;;;;AAMvB,IAAI,eAAe,MAAM;CACxB,yBAAyB,IAAI,KAAK;;;;CAIlC,MAAM,IAAI;EACT,MAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,OAAK,OAAO,IAAI,MAAM,IAAI,MAAM;AAChC,SAAO;;;;;CAKR,IAAI,IAAI;AACP,SAAO,KAAK,OAAO,IAAI,GAAG;;;;;CAK3B,KAAK,IAAI;EACR,MAAM,QAAQ,KAAK,OAAO,IAAI,GAAG;AACjC,MAAI,OAAO;GACV,MAAM,UAAU,MAAM,MAAM;AAC5B,QAAK,OAAO,OAAO,GAAG;AACtB,UAAO;;;;;;CAMT,YAAY;AACX,SAAO,MAAM,KAAK,KAAK,OAAO,QAAQ,CAAC,CAAC,QAAQ,UAAU,CAAC,MAAM,YAAY,CAAC,cAAc,MAAM;;;;;CAKnG,QAAQ;AACP,OAAK,OAAO,OAAO;;;;;CAKpB,aAAa;AACZ,SAAO,MAAM,KAAK,KAAK,OAAO,QAAQ,CAAC,CAAC,KAAK,UAAU,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracer.node.js","names":[],"sources":["../../../../../../libs/logger/dist/tracer.node.mjs"],"sourcesContent":["import { LogContext } from \"./context.node.mjs\";\nimport { Timer } from \"./timer.mjs\";\n\n//#region src/tracer.node.ts\nvar Tracer = class {\n\tcontext;\n\tactiveSpans = /* @__PURE__ */ new Map();\n\tconstructor() {\n\t\tthis.context = LogContext.getInstance();\n\t}\n\t/**\n\t* Start a new trace span\n\t*/\n\tstartSpan(options) {\n\t\tconst parentTrace = this.context.getCurrentTrace();\n\t\tconst span = {\n\t\t\ttraceId: parentTrace?.traceId || this.generateTraceId(),\n\t\t\tparentId: parentTrace?.spanId,\n\t\t\tspanId: this.generateSpanId(),\n\t\t\toperationType: options.operationType,\n\t\t\toperationName: options.operationName,\n\t\t\tstartTime: performance.now(),\n\t\t\tmetadata: { ...options.metadata },\n\t\t\ttags: [...options.tags || []]\n\t\t};\n\t\tthis.activeSpans.set(span.spanId, span);\n\t\tthis.context.setTrace(span);\n\t\treturn span;\n\t}\n\t/**\n\t* Finish a trace span\n\t*/\n\tfinishSpan(spanId) {\n\t\tconst span = this.activeSpans.get(spanId);\n\t\tif (!span) return;\n\t\tconst duration = performance.now() - span.startTime;\n\t\tthis.activeSpans.delete(spanId);\n\t\tif (this.context.getCurrentTrace()?.spanId === spanId && span.parentId) {\n\t\t\tconst parentSpan = this.findSpanById(span.parentId);\n\t\t\tif (parentSpan) this.context.setTrace(parentSpan);\n\t\t}\n\t\treturn duration;\n\t}\n\t/**\n\t* Execute a function within a trace span\n\t*/\n\tasync trace(options, fn) {\n\t\tconst span = this.startSpan(options);\n\t\tconst timer = options.autoTiming !== false ? new Timer(`trace-${span.spanId}`) : void 0;\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tconst duration = this.finishSpan(span.spanId);\n\t\t\tif (timer) timer.stop();\n\t\t\tif (duration !== void 0) span.metadata.duration = duration;\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tspan.metadata.error = {\n\t\t\t\tname: error.name || \"Unknown\",\n\t\t\t\tmessage: error.message || \"Unknown error\",\n\t\t\t\tstack: error.stack\n\t\t\t};\n\t\t\tconst duration = this.finishSpan(span.spanId);\n\t\t\tspan.metadata.duration = duration;\n\t\t\tif (timer) timer.stop();\n\t\t\tthrow error;\n\t\t}\n\t}\n\t/**\n\t* Add metadata to current span\n\t*/\n\taddMetadata(key, value) {\n\t\tconst currentTrace = this.context.getCurrentTrace();\n\t\tif (currentTrace) currentTrace.metadata[key] = value;\n\t}\n\t/**\n\t* Add tags to current span\n\t*/\n\taddTags(...tags) {\n\t\tconst currentTrace = this.context.getCurrentTrace();\n\t\tif (currentTrace) currentTrace.tags.push(...tags);\n\t}\n\t/**\n\t* Get current trace context\n\t*/\n\tgetCurrentTrace() {\n\t\treturn this.context.getCurrentTrace();\n\t}\n\t/**\n\t* Get all active spans\n\t*/\n\tgetActiveSpans() {\n\t\treturn Array.from(this.activeSpans.values());\n\t}\n\t/**\n\t* Find a span by ID\n\t*/\n\tfindSpanById(spanId) {\n\t\treturn this.activeSpans.get(spanId);\n\t}\n\t/**\n\t* Generate a unique trace ID\n\t*/\n\tgenerateTraceId() {\n\t\treturn crypto.randomUUID().replace(/-/g, \"\");\n\t}\n\t/**\n\t* Generate a unique span ID\n\t*/\n\tgenerateSpanId() {\n\t\treturn crypto.randomUUID().replace(/-/g, \"\").substring(0, 16);\n\t}\n};\n\n//#endregion\nexport { Tracer };\n//# sourceMappingURL=tracer.node.mjs.map"],"mappings":";;;;AAIA,IAAI,SAAS,MAAM;CAClB;CACA,8BAA8B,IAAI,KAAK;CACvC,cAAc;AACb,OAAK,UAAU,WAAW,aAAa;;;;;CAKxC,UAAU,SAAS;EAClB,MAAM,cAAc,KAAK,QAAQ,iBAAiB;EAClD,MAAM,OAAO;GACZ,SAAS,aAAa,WAAW,KAAK,iBAAiB;GACvD,UAAU,aAAa;GACvB,QAAQ,KAAK,gBAAgB;GAC7B,eAAe,QAAQ;GACvB,eAAe,QAAQ;GACvB,WAAW,YAAY,KAAK;GAC5B,UAAU,EAAE,GAAG,QAAQ,UAAU;GACjC,MAAM,CAAC,GAAG,QAAQ,QAAQ,EAAE,CAAC;GAC7B;AACD,OAAK,YAAY,IAAI,KAAK,QAAQ,KAAK;AACvC,OAAK,QAAQ,SAAS,KAAK;AAC3B,SAAO;;;;;CAKR,WAAW,QAAQ;EAClB,MAAM,OAAO,KAAK,YAAY,IAAI,OAAO;AACzC,MAAI,CAAC,KAAM;EACX,MAAM,WAAW,YAAY,KAAK,GAAG,KAAK;AAC1C,OAAK,YAAY,OAAO,OAAO;AAC/B,MAAI,KAAK,QAAQ,iBAAiB,EAAE,WAAW,UAAU,KAAK,UAAU;GACvE,MAAM,aAAa,KAAK,aAAa,KAAK,SAAS;AACnD,OAAI,WAAY,MAAK,QAAQ,SAAS,WAAW;;AAElD,SAAO;;;;;CAKR,MAAM,MAAM,SAAS,IAAI;EACxB,MAAM,OAAO,KAAK,UAAU,QAAQ;EACpC,MAAM,QAAQ,QAAQ,eAAe,QAAQ,IAAI,MAAM,SAAS,KAAK,SAAS,GAAG,KAAK;AACtF,MAAI;GACH,MAAM,SAAS,MAAM,IAAI;GACzB,MAAM,WAAW,KAAK,WAAW,KAAK,OAAO;AAC7C,OAAI,MAAO,OAAM,MAAM;AACvB,OAAI,aAAa,KAAK,EAAG,MAAK,SAAS,WAAW;AAClD,UAAO;WACC,OAAO;AACf,QAAK,SAAS,QAAQ;IACrB,MAAM,MAAM,QAAQ;IACpB,SAAS,MAAM,WAAW;IAC1B,OAAO,MAAM;IACb;GACD,MAAM,WAAW,KAAK,WAAW,KAAK,OAAO;AAC7C,QAAK,SAAS,WAAW;AACzB,OAAI,MAAO,OAAM,MAAM;AACvB,SAAM;;;;;;CAMR,YAAY,KAAK,OAAO;EACvB,MAAM,eAAe,KAAK,QAAQ,iBAAiB;AACnD,MAAI,aAAc,cAAa,SAAS,OAAO;;;;;CAKhD,QAAQ,GAAG,MAAM;EAChB,MAAM,eAAe,KAAK,QAAQ,iBAAiB;AACnD,MAAI,aAAc,cAAa,KAAK,KAAK,GAAG,KAAK;;;;;CAKlD,kBAAkB;AACjB,SAAO,KAAK,QAAQ,iBAAiB;;;;;CAKtC,iBAAiB;AAChB,SAAO,MAAM,KAAK,KAAK,YAAY,QAAQ,CAAC;;;;;CAK7C,aAAa,QAAQ;AACpB,SAAO,KAAK,YAAY,IAAI,OAAO;;;;;CAKpC,kBAAkB;AACjB,SAAO,OAAO,YAAY,CAAC,QAAQ,MAAM,GAAG;;;;;CAK7C,iBAAiB;AAChB,SAAO,OAAO,YAAY,CAAC,QAAQ,MAAM,GAAG,CAAC,UAAU,GAAG,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../libs/logger/dist/types.mjs"],"sourcesContent":["//#region src/types.ts\nlet LogLevel = /* @__PURE__ */ function(LogLevel$1) {\n\tLogLevel$1[LogLevel$1[\"TRACE\"] = 0] = \"TRACE\";\n\tLogLevel$1[LogLevel$1[\"DEBUG\"] = 1] = \"DEBUG\";\n\tLogLevel$1[LogLevel$1[\"INFO\"] = 2] = \"INFO\";\n\tLogLevel$1[LogLevel$1[\"WARN\"] = 3] = \"WARN\";\n\tLogLevel$1[LogLevel$1[\"ERROR\"] = 4] = \"ERROR\";\n\tLogLevel$1[LogLevel$1[\"FATAL\"] = 5] = \"FATAL\";\n\treturn LogLevel$1;\n}({});\n\n//#endregion\nexport { LogLevel };\n//# sourceMappingURL=types.mjs.map"],"mappings":";AACA,IAAI,WAA2B,yBAAS,YAAY;AACnD,YAAW,WAAW,WAAW,KAAK;AACtC,YAAW,WAAW,WAAW,KAAK;AACtC,YAAW,WAAW,UAAU,KAAK;AACrC,YAAW,WAAW,UAAU,KAAK;AACrC,YAAW,WAAW,WAAW,KAAK;AACtC,YAAW,WAAW,WAAW,KAAK;AACtC,QAAO;EACN,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-responder.js","names":[],"sources":["../../../../../../../libs/support-bot/dist/bot/auto-responder.js"],"sourcesContent":["//#region src/bot/auto-responder.ts\nvar AutoResponder = class {\n\tllm;\n\tmodel;\n\ttone;\n\tclosing;\n\tconstructor(options) {\n\t\tthis.llm = options?.llm;\n\t\tthis.model = options?.model;\n\t\tthis.tone = options?.tone ?? \"friendly\";\n\t\tthis.closing = options?.closing ?? (this.tone === \"friendly\" ? \"We remain available if you need anything else.\" : \"Please let us know if you require additional assistance.\");\n\t}\n\tasync draft(ticket, resolution, classification) {\n\t\tif (this.llm) return this.generateWithLLM(ticket, resolution, classification);\n\t\treturn this.generateTemplate(ticket, resolution, classification);\n\t}\n\tasync generateWithLLM(ticket, resolution, classification) {\n\t\tconst prompt = `You are a ${this.tone} support agent. Draft an email response.\nTicket Subject: ${ticket.subject}\nTicket Body: ${ticket.body}\nDetected Category: ${classification.category}\nDetected Priority: ${classification.priority}\nResolution:\n${resolution.answer}\nCitations: ${resolution.citations.map((c) => c.label).join(\", \")}`;\n\t\tconst body = (await this.llm.chat([{\n\t\t\trole: \"system\",\n\t\t\tcontent: [{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: \"Write empathetic, accurate support replies that cite sources when relevant.\"\n\t\t\t}]\n\t\t}, {\n\t\t\trole: \"user\",\n\t\t\tcontent: [{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: prompt\n\t\t\t}]\n\t\t}], { model: this.model })).message.content.map((part) => \"text\" in part ? part.text : \"\").join(\"\").trim();\n\t\treturn this.buildDraft(ticket, resolution, classification, body);\n\t}\n\tgenerateTemplate(ticket, resolution, classification) {\n\t\tconst body = `${ticket.customerName ? `Hi ${ticket.customerName},` : \"Hi there,\"}\n\nThanks for contacting us about \"${ticket.subject}\". ${this.renderCategoryIntro(classification)}\n\n${resolution.answer}\n\n${this.renderCitations(resolution)}\n${this.closing}\n\n— ContractSpec Support`;\n\t\treturn this.buildDraft(ticket, resolution, classification, body);\n\t}\n\tbuildDraft(ticket, resolution, classification, body) {\n\t\treturn {\n\t\t\tticketId: ticket.id,\n\t\t\tsubject: ticket.subject.startsWith(\"Re:\") ? ticket.subject : `Re: ${ticket.subject}`,\n\t\t\tbody,\n\t\t\tconfidence: Math.min(resolution.confidence, classification.confidence),\n\t\t\trequiresEscalation: resolution.actions.some((action) => action.type === \"escalate\") || Boolean(classification.escalationRequired),\n\t\t\tcitations: resolution.citations\n\t\t};\n\t}\n\trenderCategoryIntro(classification) {\n\t\tswitch (classification.category) {\n\t\t\tcase \"billing\": return \"I understand billing issues can be stressful, so let me clarify the situation.\";\n\t\t\tcase \"technical\": return \"I see you encountered a technical issue. Here is what happened and how to fix it.\";\n\t\t\tcase \"product\": return \"Thanks for sharing feedback about the product. Here are the next steps.\";\n\t\t\tcase \"account\": return \"Account access is critical, so let me walk you through the resolution.\";\n\t\t\tcase \"compliance\": return \"Compliance questions require precision. See the policy-aligned answer below.\";\n\t\t\tdefault: return \"Here is what we found after reviewing your request.\";\n\t\t}\n\t}\n\trenderCitations(resolution) {\n\t\tif (!resolution.citations.length) return \"\";\n\t\treturn `References:\\n${resolution.citations.map((citation, index) => {\n\t\t\treturn `- ${citation.label || `Source ${index + 1}`}${citation.url ? ` (${citation.url})` : \"\"}`;\n\t\t}).join(\"\\n\")}`;\n\t}\n};\n\n//#endregion\nexport { AutoResponder };\n//# sourceMappingURL=auto-responder.js.map"],"mappings":";AACA,IAAI,gBAAgB,MAAM;CACzB;CACA;CACA;CACA;CACA,YAAY,SAAS;AACpB,OAAK,MAAM,SAAS;AACpB,OAAK,QAAQ,SAAS;AACtB,OAAK,OAAO,SAAS,QAAQ;AAC7B,OAAK,UAAU,SAAS,YAAY,KAAK,SAAS,aAAa,mDAAmD;;CAEnH,MAAM,MAAM,QAAQ,YAAY,gBAAgB;AAC/C,MAAI,KAAK,IAAK,QAAO,KAAK,gBAAgB,QAAQ,YAAY,eAAe;AAC7E,SAAO,KAAK,iBAAiB,QAAQ,YAAY,eAAe;;CAEjE,MAAM,gBAAgB,QAAQ,YAAY,gBAAgB;EACzD,MAAM,SAAS,aAAa,KAAK,KAAK;kBACtB,OAAO,QAAQ;eAClB,OAAO,KAAK;qBACN,eAAe,SAAS;qBACxB,eAAe,SAAS;;EAE3C,WAAW,OAAO;aACP,WAAW,UAAU,KAAK,MAAM,EAAE,MAAM,CAAC,KAAK,KAAK;EAC9D,MAAM,QAAQ,MAAM,KAAK,IAAI,KAAK,CAAC;GAClC,MAAM;GACN,SAAS,CAAC;IACT,MAAM;IACN,MAAM;IACN,CAAC;GACF,EAAE;GACF,MAAM;GACN,SAAS,CAAC;IACT,MAAM;IACN,MAAM;IACN,CAAC;GACF,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC,EAAE,QAAQ,QAAQ,KAAK,SAAS,UAAU,OAAO,KAAK,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM;AAC1G,SAAO,KAAK,WAAW,QAAQ,YAAY,gBAAgB,KAAK;;CAEjE,iBAAiB,QAAQ,YAAY,gBAAgB;EACpD,MAAM,OAAO,GAAG,OAAO,eAAe,MAAM,OAAO,aAAa,KAAK,YAAY;;kCAEjD,OAAO,QAAQ,KAAK,KAAK,oBAAoB,eAAe,CAAC;;EAE7F,WAAW,OAAO;;EAElB,KAAK,gBAAgB,WAAW,CAAC;EACjC,KAAK,QAAQ;;;AAGb,SAAO,KAAK,WAAW,QAAQ,YAAY,gBAAgB,KAAK;;CAEjE,WAAW,QAAQ,YAAY,gBAAgB,MAAM;AACpD,SAAO;GACN,UAAU,OAAO;GACjB,SAAS,OAAO,QAAQ,WAAW,MAAM,GAAG,OAAO,UAAU,OAAO,OAAO;GAC3E;GACA,YAAY,KAAK,IAAI,WAAW,YAAY,eAAe,WAAW;GACtE,oBAAoB,WAAW,QAAQ,MAAM,WAAW,OAAO,SAAS,WAAW,IAAI,QAAQ,eAAe,mBAAmB;GACjI,WAAW,WAAW;GACtB;;CAEF,oBAAoB,gBAAgB;AACnC,UAAQ,eAAe,UAAvB;GACC,KAAK,UAAW,QAAO;GACvB,KAAK,YAAa,QAAO;GACzB,KAAK,UAAW,QAAO;GACvB,KAAK,UAAW,QAAO;GACvB,KAAK,aAAc,QAAO;GAC1B,QAAS,QAAO;;;CAGlB,gBAAgB,YAAY;AAC3B,MAAI,CAAC,WAAW,UAAU,OAAQ,QAAO;AACzC,SAAO,gBAAgB,WAAW,UAAU,KAAK,UAAU,UAAU;AACpE,UAAO,KAAK,SAAS,SAAS,UAAU,QAAQ,MAAM,SAAS,MAAM,KAAK,SAAS,IAAI,KAAK;IAC3F,CAAC,KAAK,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","names":[],"sources":["../../../../../../../libs/support-bot/dist/bot/tools.js"],"sourcesContent":["import * as z from \"zod\";\n\n//#region src/bot/tools.ts\nconst ticketSchema = z.object({\n\tid: z.string(),\n\tsubject: z.string(),\n\tbody: z.string(),\n\tchannel: z.enum([\n\t\t\"email\",\n\t\t\"chat\",\n\t\t\"phone\",\n\t\t\"portal\"\n\t]),\n\tcustomerName: z.string().optional(),\n\tcustomerEmail: z.string().optional(),\n\tmetadata: z.object().optional()\n});\nconst supportCitationSchema = z.object({\n\tlabel: z.string(),\n\turl: z.string().optional(),\n\tsnippet: z.string().optional(),\n\tscore: z.number().optional()\n});\nconst supportActionSchema = z.object({\n\ttype: z.enum([\n\t\t\"respond\",\n\t\t\"escalate\",\n\t\t\"refund\",\n\t\t\"manual\"\n\t]),\n\tlabel: z.string(),\n\tpayload: z.record(z.string(), z.string())\n});\nconst supportResolutionSchema = z.object({\n\tticketId: z.string(),\n\tanswer: z.string(),\n\tconfidence: z.number(),\n\tcitations: supportCitationSchema.array(),\n\tactions: supportActionSchema.array(),\n\tescalationReason: z.string().optional(),\n\tknowledgeUpdates: z.array(z.string()).optional()\n});\nconst ticketClassificationSchema = z.object({\n\tticketId: z.string(),\n\tcategory: z.enum([\n\t\t\"billing\",\n\t\t\"technical\",\n\t\t\"product\",\n\t\t\"account\",\n\t\t\"compliance\",\n\t\t\"other\"\n\t]),\n\tpriority: z.enum([\n\t\t\"urgent\",\n\t\t\"high\",\n\t\t\"medium\",\n\t\t\"low\"\n\t]),\n\tsentiment: z.enum([\n\t\t\"positive\",\n\t\t\"neutral\",\n\t\t\"negative\",\n\t\t\"frustrated\"\n\t]),\n\tintents: z.array(z.string()),\n\ttags: z.array(z.string()),\n\tconfidence: z.number(),\n\tescalationRequired: z.boolean().optional()\n});\nfunction ensureTicket(input) {\n\tif (!input || typeof input !== \"object\" || !(\"ticket\" in input)) throw new Error(\"Input must include ticket\");\n\tconst ticket = input.ticket;\n\tif (!ticket?.id) throw new Error(\"Ticket is missing id\");\n\treturn ticket;\n}\nfunction extractResolution(input) {\n\tif (!input || typeof input !== \"object\" || !(\"resolution\" in input)) return void 0;\n\treturn input.resolution;\n}\nfunction extractClassification(input) {\n\tif (!input || typeof input !== \"object\" || !(\"classification\" in input)) return void 0;\n\treturn input.classification;\n}\nfunction createSupportTools(options) {\n\treturn [\n\t\t{\n\t\t\ttitle: \"support_classify_ticket\",\n\t\t\tdescription: \"Classify a ticket for priority, sentiment, and category\",\n\t\t\tinputSchema: z.object({ ticket: ticketSchema }),\n\t\t\texecute: async (input) => {\n\t\t\t\tconst ticket = ensureTicket(input);\n\t\t\t\tconst classification = await options.classifier.classify(ticket);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: JSON.stringify(classification),\n\t\t\t\t\tmetadata: { ticketId: ticket.id }\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\ttitle: \"support_resolve_ticket\",\n\t\t\tdescription: \"Generate a knowledge-grounded resolution for a ticket\",\n\t\t\tinputSchema: z.object({ ticket: ticketSchema }),\n\t\t\texecute: async (input) => {\n\t\t\t\tconst ticket = ensureTicket(input);\n\t\t\t\tconst resolution = await options.resolver.resolve(ticket);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: JSON.stringify(resolution),\n\t\t\t\t\tmetadata: { ticketId: ticket.id }\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\ttitle: \"support_draft_response\",\n\t\t\tdescription: \"Draft a user-facing reply based on resolution + classification\",\n\t\t\tinputSchema: z.object({\n\t\t\t\tticket: ticketSchema,\n\t\t\t\tresolution: supportResolutionSchema,\n\t\t\t\tclassification: ticketClassificationSchema\n\t\t\t}),\n\t\t\texecute: async (input) => {\n\t\t\t\tconst ticket = ensureTicket(input);\n\t\t\t\tconst resolution = extractResolution(input);\n\t\t\t\tconst classification = extractClassification(input);\n\t\t\t\tif (!resolution || !classification) throw new Error(\"resolution and classification are required\");\n\t\t\t\tconst draft = await options.responder.draft(ticket, resolution, classification);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: JSON.stringify(draft),\n\t\t\t\t\tmetadata: { ticketId: ticket.id }\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t];\n}\n\n//#endregion\nexport { createSupportTools };\n//# sourceMappingURL=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AE,MAAM,EAAE,QAAQ,CAAC;CACzB,YAAY,EAAE,QAAQ;CACtB,oBAAoB,EAAE,SAAS,CAAC,UAAU;CAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket-resolver.js","names":[],"sources":["../../../../../../../libs/support-bot/dist/rag/ticket-resolver.js"],"sourcesContent":["//#region src/rag/ticket-resolver.ts\nvar TicketResolver = class {\n\tknowledge;\n\tminConfidence;\n\tprependPrompt;\n\tconstructor(options) {\n\t\tthis.knowledge = options.knowledge;\n\t\tthis.minConfidence = options.minConfidence ?? .65;\n\t\tthis.prependPrompt = options.prependPrompt;\n\t}\n\tasync resolve(ticket) {\n\t\tconst question = this.buildQuestion(ticket);\n\t\tconst answer = await this.knowledge.query(question);\n\t\treturn this.toResolution(ticket, answer);\n\t}\n\tbuildQuestion(ticket) {\n\t\tconst header = [`Subject: ${ticket.subject}`, `Channel: ${ticket.channel}`];\n\t\tif (ticket.customerName) header.push(`Customer: ${ticket.customerName}`);\n\t\treturn [\n\t\t\tthis.prependPrompt,\n\t\t\theader.join(\"\\n\"),\n\t\t\t\"---\",\n\t\t\tticket.body\n\t\t].filter(Boolean).join(\"\\n\");\n\t}\n\ttoResolution(ticket, answer) {\n\t\tconst citations = answer.references.map((ref) => {\n\t\t\treturn {\n\t\t\t\tlabel: typeof ref.payload?.title === \"string\" ? ref.payload.title : typeof ref.payload?.documentId === \"string\" ? ref.payload.documentId : ref.id,\n\t\t\t\turl: typeof ref.payload?.url === \"string\" ? ref.payload.url : void 0,\n\t\t\t\tsnippet: typeof ref.payload?.text === \"string\" ? ref.payload.text.slice(0, 280) : void 0,\n\t\t\t\tscore: ref.score\n\t\t\t};\n\t\t});\n\t\tconst confidence = this.deriveConfidence(answer);\n\t\tconst escalate = confidence < this.minConfidence || citations.length === 0;\n\t\treturn {\n\t\t\tticketId: ticket.id,\n\t\t\tanswer: answer.answer,\n\t\t\tconfidence,\n\t\t\tcitations,\n\t\t\tactions: [escalate ? {\n\t\t\t\ttype: \"escalate\",\n\t\t\t\tlabel: \"Escalate for human review\"\n\t\t\t} : {\n\t\t\t\ttype: \"respond\",\n\t\t\t\tlabel: \"Send automated response\"\n\t\t\t}],\n\t\t\tescalationReason: escalate ? \"Insufficient confidence or missing knowledge references\" : void 0,\n\t\t\tknowledgeUpdates: escalate ? [ticket.body.slice(0, 200)] : void 0\n\t\t};\n\t}\n\tderiveConfidence(answer) {\n\t\tif (!answer.references.length) return .3;\n\t\tconst topScore = answer.references[0]?.score ?? .4;\n\t\tconst normalized = Math.min(1, Math.max(0, topScore));\n\t\tconst tokenPenalty = answer.usage?.completionTokens ? Math.min(answer.usage.completionTokens / 1e3, .2) : 0;\n\t\treturn Number((normalized - tokenPenalty).toFixed(2));\n\t}\n};\n\n//#endregion\nexport { TicketResolver };\n//# sourceMappingURL=ticket-resolver.js.map"],"mappings":";AACA,IAAI,iBAAiB,MAAM;CAC1B;CACA;CACA;CACA,YAAY,SAAS;AACpB,OAAK,YAAY,QAAQ;AACzB,OAAK,gBAAgB,QAAQ,iBAAiB;AAC9C,OAAK,gBAAgB,QAAQ;;CAE9B,MAAM,QAAQ,QAAQ;EACrB,MAAM,WAAW,KAAK,cAAc,OAAO;EAC3C,MAAM,SAAS,MAAM,KAAK,UAAU,MAAM,SAAS;AACnD,SAAO,KAAK,aAAa,QAAQ,OAAO;;CAEzC,cAAc,QAAQ;EACrB,MAAM,SAAS,CAAC,YAAY,OAAO,WAAW,YAAY,OAAO,UAAU;AAC3E,MAAI,OAAO,aAAc,QAAO,KAAK,aAAa,OAAO,eAAe;AACxE,SAAO;GACN,KAAK;GACL,OAAO,KAAK,KAAK;GACjB;GACA,OAAO;GACP,CAAC,OAAO,QAAQ,CAAC,KAAK,KAAK;;CAE7B,aAAa,QAAQ,QAAQ;EAC5B,MAAM,YAAY,OAAO,WAAW,KAAK,QAAQ;AAChD,UAAO;IACN,OAAO,OAAO,IAAI,SAAS,UAAU,WAAW,IAAI,QAAQ,QAAQ,OAAO,IAAI,SAAS,eAAe,WAAW,IAAI,QAAQ,aAAa,IAAI;IAC/I,KAAK,OAAO,IAAI,SAAS,QAAQ,WAAW,IAAI,QAAQ,MAAM,KAAK;IACnE,SAAS,OAAO,IAAI,SAAS,SAAS,WAAW,IAAI,QAAQ,KAAK,MAAM,GAAG,IAAI,GAAG,KAAK;IACvF,OAAO,IAAI;IACX;IACA;EACF,MAAM,aAAa,KAAK,iBAAiB,OAAO;EAChD,MAAM,WAAW,aAAa,KAAK,iBAAiB,UAAU,WAAW;AACzE,SAAO;GACN,UAAU,OAAO;GACjB,QAAQ,OAAO;GACf;GACA;GACA,SAAS,CAAC,WAAW;IACpB,MAAM;IACN,OAAO;IACP,GAAG;IACH,MAAM;IACN,OAAO;IACP,CAAC;GACF,kBAAkB,WAAW,4DAA4D,KAAK;GAC9F,kBAAkB,WAAW,CAAC,OAAO,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK;GAChE;;CAEF,iBAAiB,QAAQ;AACxB,MAAI,CAAC,OAAO,WAAW,OAAQ,QAAO;EACtC,MAAM,WAAW,OAAO,WAAW,IAAI,SAAS;EAChD,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC;EACrD,MAAM,eAAe,OAAO,OAAO,mBAAmB,KAAK,IAAI,OAAO,MAAM,mBAAmB,KAAK,GAAG,GAAG;AAC1G,SAAO,QAAQ,aAAa,cAAc,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifier.js","names":[],"sources":["../../../../../../../libs/support-bot/dist/tickets/classifier.js"],"sourcesContent":["//#region src/tickets/classifier.ts\nconst CATEGORY_KEYWORDS = {\n\tbilling: [\n\t\t\"invoice\",\n\t\t\"payout\",\n\t\t\"refund\",\n\t\t\"charge\",\n\t\t\"billing\",\n\t\t\"payment\"\n\t],\n\ttechnical: [\n\t\t\"bug\",\n\t\t\"error\",\n\t\t\"crash\",\n\t\t\"issue\",\n\t\t\"failed\",\n\t\t\"timeout\"\n\t],\n\tproduct: [\n\t\t\"feature\",\n\t\t\"roadmap\",\n\t\t\"idea\",\n\t\t\"request\",\n\t\t\"feedback\"\n\t],\n\taccount: [\n\t\t\"login\",\n\t\t\"password\",\n\t\t\"2fa\",\n\t\t\"account\",\n\t\t\"profile\",\n\t\t\"email change\"\n\t],\n\tcompliance: [\n\t\t\"kyc\",\n\t\t\"aml\",\n\t\t\"compliance\",\n\t\t\"regulation\",\n\t\t\"gdpr\"\n\t],\n\tother: []\n};\nconst PRIORITY_HINTS = {\n\turgent: [\n\t\t\"urgent\",\n\t\t\"asap\",\n\t\t\"immediately\",\n\t\t\"today\",\n\t\t\"right away\"\n\t],\n\thigh: [\n\t\t\"high priority\",\n\t\t\"blocking\",\n\t\t\"major\",\n\t\t\"critical\"\n\t],\n\tmedium: [\"soon\", \"next few days\"],\n\tlow: [\n\t\t\"nice to have\",\n\t\t\"when possible\",\n\t\t\"later\"\n\t]\n};\nconst SENTIMENT_HINTS = {\n\tpositive: [\n\t\t\"love\",\n\t\t\"great\",\n\t\t\"awesome\",\n\t\t\"thank you\"\n\t],\n\tneutral: [\n\t\t\"question\",\n\t\t\"wonder\",\n\t\t\"curious\"\n\t],\n\tnegative: [\n\t\t\"unhappy\",\n\t\t\"bad\",\n\t\t\"terrible\",\n\t\t\"awful\",\n\t\t\"angry\"\n\t],\n\tfrustrated: [\n\t\t\"furious\",\n\t\t\"frustrated\",\n\t\t\"fed up\",\n\t\t\"ridiculous\"\n\t]\n};\nvar TicketClassifier = class {\n\tkeywords;\n\tllm;\n\tllmModel;\n\tconstructor(options) {\n\t\tthis.keywords = {\n\t\t\t...CATEGORY_KEYWORDS,\n\t\t\t...options?.keywords ?? {}\n\t\t};\n\t\tthis.llm = options?.llm;\n\t\tthis.llmModel = options?.llmModel;\n\t}\n\tasync classify(ticket) {\n\t\tconst heuristics = this.heuristicClassification(ticket);\n\t\tif (!this.llm) return heuristics;\n\t\ttry {\n\t\t\tconst content = (await this.llm.chat([{\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: \"Classify the support ticket.\"\n\t\t\t\t}]\n\t\t\t}, {\n\t\t\t\trole: \"user\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: JSON.stringify({\n\t\t\t\t\t\tsubject: ticket.subject,\n\t\t\t\t\t\tbody: ticket.body,\n\t\t\t\t\t\tchannel: ticket.channel\n\t\t\t\t\t})\n\t\t\t\t}]\n\t\t\t}], {\n\t\t\t\tresponseFormat: \"json\",\n\t\t\t\tmodel: this.llmModel\n\t\t\t})).message.content.find((part) => \"text\" in part);\n\t\t\tif (content && \"text\" in content) {\n\t\t\t\tconst parsed = JSON.parse(content.text);\n\t\t\t\treturn {\n\t\t\t\t\t...heuristics,\n\t\t\t\t\t...parsed,\n\t\t\t\t\tintents: parsed.intents ?? heuristics.intents,\n\t\t\t\t\ttags: parsed.tags ?? heuristics.tags\n\t\t\t\t};\n\t\t\t}\n\t\t} catch {}\n\t\treturn heuristics;\n\t}\n\theuristicClassification(ticket) {\n\t\tconst text = `${ticket.subject}\\n${ticket.body}`.toLowerCase();\n\t\tconst category = this.detectCategory(text);\n\t\tconst priority = this.detectPriority(text);\n\t\tconst sentiment = this.detectSentiment(text);\n\t\tconst intents = this.extractIntents(text);\n\t\tconst tags = intents.slice(0, 3);\n\t\tconst confidence = this.estimateConfidence(category, priority, sentiment);\n\t\treturn {\n\t\t\tticketId: ticket.id,\n\t\t\tcategory,\n\t\t\tpriority,\n\t\t\tsentiment,\n\t\t\tintents,\n\t\t\ttags,\n\t\t\tconfidence,\n\t\t\tescalationRequired: priority === \"urgent\" || category === \"compliance\"\n\t\t};\n\t}\n\tdetectCategory(text) {\n\t\tfor (const [category, keywords] of Object.entries(this.keywords)) if (keywords.some((keyword) => text.includes(keyword))) return category;\n\t\treturn \"other\";\n\t}\n\tdetectPriority(text) {\n\t\tfor (const priority of [\n\t\t\t\"urgent\",\n\t\t\t\"high\",\n\t\t\t\"medium\",\n\t\t\t\"low\"\n\t\t]) if (PRIORITY_HINTS[priority].some((word) => text.includes(word))) return priority;\n\t\treturn \"medium\";\n\t}\n\tdetectSentiment(text) {\n\t\tfor (const sentiment of [\n\t\t\t\"frustrated\",\n\t\t\t\"negative\",\n\t\t\t\"neutral\",\n\t\t\t\"positive\"\n\t\t]) if (SENTIMENT_HINTS[sentiment].some((word) => text.includes(word))) return sentiment;\n\t\treturn \"neutral\";\n\t}\n\textractIntents(text) {\n\t\tconst intents = [];\n\t\tif (text.includes(\"refund\") || text.includes(\"chargeback\")) intents.push(\"refund\");\n\t\tif (text.includes(\"payout\")) intents.push(\"payout\");\n\t\tif (text.includes(\"login\")) intents.push(\"login-help\");\n\t\tif (text.includes(\"feature\")) intents.push(\"feature-request\");\n\t\tif (text.includes(\"bug\") || text.includes(\"error\")) intents.push(\"bug-report\");\n\t\treturn intents.length ? intents : [\"general\"];\n\t}\n\testimateConfidence(category, priority, sentiment) {\n\t\tlet base = .6;\n\t\tif (category !== \"other\") base += .1;\n\t\tif (priority === \"urgent\" || priority === \"low\") base += .05;\n\t\tif (sentiment === \"frustrated\") base -= .05;\n\t\treturn Math.min(.95, Math.max(.4, Number(base.toFixed(2))));\n\t}\n};\n\n//#endregion\nexport { TicketClassifier };\n//# sourceMappingURL=classifier.js.map"],"mappings":";AACA,MAAM,oBAAoB;CACzB,SAAS;EACR;EACA;EACA;EACA;EACA;EACA;EACA;CACD,WAAW;EACV;EACA;EACA;EACA;EACA;EACA;EACA;CACD,SAAS;EACR;EACA;EACA;EACA;EACA;EACA;CACD,SAAS;EACR;EACA;EACA;EACA;EACA;EACA;EACA;CACD,YAAY;EACX;EACA;EACA;EACA;EACA;EACA;CACD,OAAO,EAAE;CACT;AACD,MAAM,iBAAiB;CACtB,QAAQ;EACP;EACA;EACA;EACA;EACA;EACA;CACD,MAAM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O;AACX,MAAI,aAAa,QAAS,SAAQ;AAClC,MAAI,aAAa,YAAY,aAAa,MAAO,SAAQ;AACzD,MAAI,cAAc,aAAc,SAAQ;AACxC,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC,CAAC,CAAC"}
|
package/dist/setup.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","names":[],"sources":["../src/setup.ts"],"sourcesContent":[],"mappings":";iBAesB,sBAAA,CAAA,GAA0B"}
|
package/dist/setup.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","names":["ticket: SupportTicket"],"sources":["../src/setup.ts"],"sourcesContent":["import { TicketResolver } from '@lssm/lib.support-bot/rag';\nimport { TicketClassifier } from '@lssm/lib.support-bot/tickets';\nimport { AutoResponder } from '@lssm/lib.support-bot/bot';\nimport type { KnowledgeAnswer } from '@lssm/lib.knowledge/query/service';\nimport type { SupportTicket } from '@lssm/lib.support-bot/types';\nimport { Logger, LogLevel } from '@lssm/lib.logger';\nimport type { LoggerConfig } from '@lssm/lib.logger/types';\n\nconst logger = new Logger({\n level: process.env.NODE_ENV === 'production' ? LogLevel.INFO : LogLevel.DEBUG,\n environment:\n (process.env.NODE_ENV as LoggerConfig['environment']) || 'development',\n enableColors: process.env.NODE_ENV !== 'production',\n});\n\nexport async function runAiSupportBotExample(): Promise<void> {\n const knowledge = {\n async query(question: string): Promise<KnowledgeAnswer> {\n return {\n answer: `The payout will retrigger automatically. (${question.slice(0, 40)}…)`,\n references: [],\n };\n },\n };\n\n const resolver = new TicketResolver({ knowledge });\n const classifier = new TicketClassifier();\n const responder = new AutoResponder();\n\n const ticket: SupportTicket = {\n id: 'TIC-42',\n subject: 'Payout failed',\n body: 'Hello, our supplier payout failed twice yesterday. Can you confirm status? It is urgent.',\n channel: 'email',\n customerName: 'Ivy',\n metadata: { accountId: 'acct_789' },\n };\n\n const classification = await classifier.classify(ticket);\n const resolution = await resolver.resolve(ticket);\n const draft = await responder.draft(ticket, resolution, classification);\n\n logger.info('Support bot run completed', {\n ticketId: ticket.id,\n classification,\n resolution,\n emailDraft: { subject: draft.subject, body: draft.body },\n });\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,SAAS,IAAI,OAAO;CACxB,OAAO,QAAQ,IAAI,aAAa,eAAe,SAAS,OAAO,SAAS;CACxE,aACG,QAAQ,IAAI,YAA4C;CAC3D,cAAc,QAAQ,IAAI,aAAa;CACxC,CAAC;AAEF,eAAsB,yBAAwC;CAU5D,MAAM,WAAW,IAAI,eAAe,EAAE,WATpB,EAChB,MAAM,MAAM,UAA4C;AACtD,SAAO;GACL,QAAQ,6CAA6C,SAAS,MAAM,GAAG,GAAG,CAAC;GAC3E,YAAY,EAAE;GACf;IAEJ,EAEgD,CAAC;CAClD,MAAM,aAAa,IAAI,kBAAkB;CACzC,MAAM,YAAY,IAAI,eAAe;CAErC,MAAMA,SAAwB;EAC5B,IAAI;EACJ,SAAS;EACT,MAAM;EACN,SAAS;EACT,cAAc;EACd,UAAU,EAAE,WAAW,YAAY;EACpC;CAED,MAAM,iBAAiB,MAAM,WAAW,SAAS,OAAO;CACxD,MAAM,aAAa,MAAM,SAAS,QAAQ,OAAO;CACjD,MAAM,QAAQ,MAAM,UAAU,MAAM,QAAQ,YAAY,eAAe;AAEvE,QAAO,KAAK,6BAA6B;EACvC,UAAU,OAAO;EACjB;EACA;EACA,YAAY;GAAE,SAAS,MAAM;GAAS,MAAM,MAAM;GAAM;EACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/example.ai-support-bot",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251219202229",
|
|
4
4
|
"description": "AI support bot example: classify and resolve a support ticket using @lssm/lib.support-bot.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"test": "bun test"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lssm/lib.support-bot": "0.0.0-canary-
|
|
31
|
-
"@lssm/lib.knowledge": "0.0.0-canary-
|
|
32
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
33
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
34
|
-
"@lssm/lib.logger": "0.0.0-canary-
|
|
30
|
+
"@lssm/lib.support-bot": "0.0.0-canary-20251219202229",
|
|
31
|
+
"@lssm/lib.knowledge": "0.0.0-canary-20251219202229",
|
|
32
|
+
"@lssm/lib.schema": "0.0.0-canary-20251219202229",
|
|
33
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251219202229",
|
|
34
|
+
"@lssm/lib.logger": "0.0.0-canary-20251219202229"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
38
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
39
|
-
"tsdown": "^0.
|
|
37
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251219202229",
|
|
38
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251219202229",
|
|
39
|
+
"tsdown": "^0.18.1",
|
|
40
40
|
"typescript": "^5.9.3"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
@@ -50,5 +50,6 @@
|
|
|
50
50
|
"./*": "./*"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"module": "./dist/index.js"
|
|
53
|
+
"module": "./dist/index.js",
|
|
54
|
+
"license": "MIT"
|
|
54
55
|
}
|