@contractspec/example.ai-support-bot 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ $ tsdown
2
+ ℹ tsdown v0.18.3 powered by rolldown v1.0.0-beta.57
3
+ ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/ai-support-bot/tsdown.config.js
4
+ ℹ entry: src/example.ts, src/index.ts, src/setup.ts, src/docs/ai-support-bot.docblock.ts, src/docs/index.ts
5
+ ℹ target: esnext
6
+ ℹ tsconfig: tsconfig.json
7
+ ℹ Build start
8
+ ℹ Cleaning 16 files
9
+ ℹ dist/setup.js 1.53 kB │ gzip: 0.75 kB
10
+ ℹ dist/docs/ai-support-bot.docblock.js 1.35 kB │ gzip: 0.66 kB
11
+ ℹ dist/example.js 0.81 kB │ gzip: 0.44 kB
12
+ ℹ dist/index.js 0.19 kB │ gzip: 0.12 kB
13
+ ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
14
+ ℹ dist/setup.js.map 2.70 kB │ gzip: 1.18 kB
15
+ ℹ dist/docs/ai-support-bot.docblock.js.map 1.84 kB │ gzip: 0.85 kB
16
+ ℹ dist/example.js.map 1.17 kB │ gzip: 0.60 kB
17
+ ℹ dist/example.d.ts.map 0.14 kB │ gzip: 0.13 kB
18
+ ℹ dist/setup.d.ts.map 0.13 kB │ gzip: 0.13 kB
19
+ ℹ dist/example.d.ts 1.05 kB │ gzip: 0.44 kB
20
+ ℹ dist/setup.d.ts 0.17 kB │ gzip: 0.14 kB
21
+ ℹ dist/index.d.ts 0.13 kB │ gzip: 0.09 kB
22
+ ℹ dist/docs/ai-support-bot.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
23
+ ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
24
+ ℹ 15 files, total: 11.29 kB
25
+ ✔ Build complete in 15638ms
@@ -0,0 +1,26 @@
1
+ $ bun build:types && bun build:bundle
2
+ $ tsc --noEmit
3
+ $ tsdown
4
+ ℹ tsdown v0.18.3 powered by rolldown v1.0.0-beta.57
5
+ ℹ config file: /home/runner/work/contractspec/contractspec/packages/examples/ai-support-bot/tsdown.config.js
6
+ ℹ entry: src/example.ts, src/index.ts, src/setup.ts, src/docs/ai-support-bot.docblock.ts, src/docs/index.ts
7
+ ℹ target: esnext
8
+ ℹ tsconfig: tsconfig.json
9
+ ℹ Build start
10
+ ℹ dist/setup.js 1.53 kB │ gzip: 0.75 kB
11
+ ℹ dist/docs/ai-support-bot.docblock.js 1.35 kB │ gzip: 0.66 kB
12
+ ℹ dist/example.js 0.81 kB │ gzip: 0.44 kB
13
+ ℹ dist/index.js 0.19 kB │ gzip: 0.12 kB
14
+ ℹ dist/docs/index.js 0.04 kB │ gzip: 0.06 kB
15
+ ℹ dist/setup.js.map 2.70 kB │ gzip: 1.18 kB
16
+ ℹ dist/docs/ai-support-bot.docblock.js.map 1.84 kB │ gzip: 0.85 kB
17
+ ℹ dist/example.js.map 1.17 kB │ gzip: 0.60 kB
18
+ ℹ dist/example.d.ts.map 0.14 kB │ gzip: 0.13 kB
19
+ ℹ dist/setup.d.ts.map 0.13 kB │ gzip: 0.13 kB
20
+ ℹ dist/example.d.ts 1.05 kB │ gzip: 0.44 kB
21
+ ℹ dist/setup.d.ts 0.17 kB │ gzip: 0.14 kB
22
+ ℹ dist/index.d.ts 0.13 kB │ gzip: 0.09 kB
23
+ ℹ dist/docs/ai-support-bot.docblock.d.ts 0.01 kB │ gzip: 0.03 kB
24
+ ℹ dist/docs/index.d.ts 0.01 kB │ gzip: 0.03 kB
25
+ ℹ 15 files, total: 11.29 kB
26
+ ✔ Build complete in 18164ms
package/CHANGELOG.md ADDED
@@ -0,0 +1,211 @@
1
+ # @contractspec/example.ai-support-bot
2
+
3
+ ## 1.44.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5f3a868: chore: isolate branding to contractspec.io
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5f3a868]
12
+ - @contractspec/lib.support-bot@1.44.0
13
+ - @contractspec/lib.contracts@1.44.0
14
+ - @contractspec/lib.knowledge@1.44.0
15
+ - @contractspec/lib.logger@1.44.0
16
+ - @contractspec/lib.schema@1.44.0
17
+
18
+ ## 1.43.4
19
+
20
+ ### Patch Changes
21
+
22
+ - 9216062: fix: cross-platform compatibility
23
+ - Updated dependencies [9216062]
24
+ - @contractspec/lib.support-bot@1.43.4
25
+ - @contractspec/lib.contracts@1.43.4
26
+ - @contractspec/lib.knowledge@1.43.4
27
+ - @contractspec/lib.logger@1.43.3
28
+ - @contractspec/lib.schema@1.43.3
29
+
30
+ ## 1.43.3
31
+
32
+ ### Patch Changes
33
+
34
+ - 24d9759: improve documentation
35
+ - Updated dependencies [24d9759]
36
+ - @contractspec/lib.support-bot@1.43.3
37
+ - @contractspec/lib.contracts@1.43.3
38
+ - @contractspec/lib.knowledge@1.43.3
39
+ - @contractspec/lib.logger@1.43.2
40
+ - @contractspec/lib.schema@1.43.2
41
+
42
+ ## 1.43.2
43
+
44
+ ### Patch Changes
45
+
46
+ - e147271: fix: improve stability
47
+ - Updated dependencies [e147271]
48
+ - @contractspec/lib.support-bot@1.43.2
49
+ - @contractspec/lib.contracts@1.43.2
50
+ - @contractspec/lib.knowledge@1.43.2
51
+ - @contractspec/lib.logger@1.43.1
52
+ - @contractspec/lib.schema@1.43.1
53
+
54
+ ## 1.43.1
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [f28fdad]
59
+ - @contractspec/lib.contracts@1.43.1
60
+ - @contractspec/lib.knowledge@1.43.1
61
+ - @contractspec/lib.support-bot@1.43.1
62
+
63
+ ## 1.43.0
64
+
65
+ ### Minor Changes
66
+
67
+ - 042d072: feat: schema declaration using json schema, including zod
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [042d072]
72
+ - @contractspec/lib.support-bot@1.43.0
73
+ - @contractspec/lib.contracts@1.43.0
74
+ - @contractspec/lib.knowledge@1.43.0
75
+ - @contractspec/lib.logger@1.43.0
76
+ - @contractspec/lib.schema@1.43.0
77
+
78
+ ## 1.42.10
79
+
80
+ ### Patch Changes
81
+
82
+ - 1e6a0f1: fix: mcp server
83
+ - Updated dependencies [1e6a0f1]
84
+ - @contractspec/lib.support-bot@1.42.10
85
+ - @contractspec/lib.contracts@1.42.10
86
+ - @contractspec/lib.knowledge@1.42.10
87
+ - @contractspec/lib.logger@1.42.10
88
+ - @contractspec/lib.schema@1.42.10
89
+
90
+ ## 1.42.9
91
+
92
+ ### Patch Changes
93
+
94
+ - 9281db7: fix ModelRegistry
95
+ - Updated dependencies [9281db7]
96
+ - @contractspec/lib.support-bot@1.42.9
97
+ - @contractspec/lib.contracts@1.42.9
98
+ - @contractspec/lib.knowledge@1.42.9
99
+ - @contractspec/lib.logger@1.42.9
100
+ - @contractspec/lib.schema@1.42.9
101
+
102
+ ## 1.42.8
103
+
104
+ ### Patch Changes
105
+
106
+ - e07b5ac: fix
107
+ - Updated dependencies [e07b5ac]
108
+ - @contractspec/lib.support-bot@1.42.8
109
+ - @contractspec/lib.contracts@1.42.8
110
+ - @contractspec/lib.knowledge@1.42.8
111
+ - @contractspec/lib.logger@1.42.8
112
+ - @contractspec/lib.schema@1.42.8
113
+
114
+ ## 1.42.7
115
+
116
+ ### Patch Changes
117
+
118
+ - e9b575d: fix release
119
+ - Updated dependencies [e9b575d]
120
+ - @contractspec/lib.support-bot@1.42.7
121
+ - @contractspec/lib.contracts@1.42.7
122
+ - @contractspec/lib.knowledge@1.42.7
123
+ - @contractspec/lib.logger@1.42.7
124
+ - @contractspec/lib.schema@1.42.7
125
+
126
+ ## 1.42.6
127
+
128
+ ### Patch Changes
129
+
130
+ - 1500242: fix tooling
131
+ - Updated dependencies [1500242]
132
+ - @contractspec/lib.support-bot@1.42.6
133
+ - @contractspec/lib.contracts@1.42.6
134
+ - @contractspec/lib.knowledge@1.42.6
135
+ - @contractspec/lib.logger@1.42.6
136
+ - @contractspec/lib.schema@1.42.6
137
+
138
+ ## 1.42.5
139
+
140
+ ### Patch Changes
141
+
142
+ - 1299719: fix vscode
143
+ - Updated dependencies [1299719]
144
+ - @contractspec/lib.support-bot@1.42.5
145
+ - @contractspec/lib.contracts@1.42.5
146
+ - @contractspec/lib.knowledge@1.42.5
147
+ - @contractspec/lib.logger@1.42.5
148
+ - @contractspec/lib.schema@1.42.5
149
+
150
+ ## 1.42.4
151
+
152
+ ### Patch Changes
153
+
154
+ - ac28b99: fix: generate from openapi
155
+ - Updated dependencies [ac28b99]
156
+ - @contractspec/lib.support-bot@1.42.4
157
+ - @contractspec/lib.contracts@1.42.4
158
+ - @contractspec/lib.knowledge@1.42.4
159
+ - @contractspec/lib.logger@1.42.4
160
+ - @contractspec/lib.schema@1.42.4
161
+
162
+ ## 1.42.3
163
+
164
+ ### Patch Changes
165
+
166
+ - 3f5d015: fix(tooling): cicd
167
+ - Updated dependencies [3f5d015]
168
+ - @contractspec/lib.contracts@1.42.3
169
+ - @contractspec/lib.knowledge@1.42.3
170
+ - @contractspec/lib.logger@1.42.3
171
+ - @contractspec/lib.schema@1.42.3
172
+ - @contractspec/lib.support-bot@1.42.3
173
+
174
+ ## 1.42.2
175
+
176
+ ### Patch Changes
177
+
178
+ - 1f9ac4c: fix
179
+ - Updated dependencies [1f9ac4c]
180
+ - @contractspec/lib.contracts@1.42.2
181
+ - @contractspec/lib.knowledge@1.42.2
182
+ - @contractspec/lib.logger@1.42.2
183
+ - @contractspec/lib.schema@1.42.2
184
+ - @contractspec/lib.support-bot@1.42.2
185
+
186
+ ## 1.42.1
187
+
188
+ ### Patch Changes
189
+
190
+ - f043995: Fix release
191
+ - Updated dependencies [f043995]
192
+ - @contractspec/lib.support-bot@1.42.1
193
+ - @contractspec/lib.contracts@1.42.1
194
+ - @contractspec/lib.knowledge@1.42.1
195
+ - @contractspec/lib.logger@1.42.1
196
+ - @contractspec/lib.schema@1.42.1
197
+
198
+ ## 1.42.0
199
+
200
+ ### Minor Changes
201
+
202
+ - 8eefd9c: initial release
203
+
204
+ ### Patch Changes
205
+
206
+ - Updated dependencies [8eefd9c]
207
+ - @contractspec/lib.contracts@1.42.0
208
+ - @contractspec/lib.knowledge@1.42.0
209
+ - @contractspec/lib.logger@1.42.0
210
+ - @contractspec/lib.schema@1.42.0
211
+ - @contractspec/lib.support-bot@1.42.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Chaman Ventures, SASU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # AI Support Bot Example
2
+
3
+ Website: https://contractspec.io/
4
+
5
+
6
+ Minimal wiring that shows how `@contractspec/lib.ai-agent` works together with `@contractspec/lib.support-bot`.
7
+
8
+ ## What it demonstrates
9
+
10
+ - Create a SupportBot spec with confidence-based escalation.
11
+ - Register ticket classification / resolver / auto-responder tools.
12
+ - Run a mock ticket through the `AgentRunner` and inspect the draft reply.
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,29 @@
1
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
2
+
3
+ //#region src/docs/ai-support-bot.docblock.ts
4
+ registerDocBlocks([{
5
+ id: "docs.examples.ai-support-bot",
6
+ title: "AI Support Bot (example)",
7
+ summary: "Ticket classification + knowledge-grounded resolution + response drafting.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/ai-support-bot",
11
+ tags: [
12
+ "support",
13
+ "ai",
14
+ "example"
15
+ ],
16
+ body: `## What this example shows\n- Classify a ticket into a support category.\n- Use a knowledge port to generate a grounded resolution.\n- Draft a response (email body) from the resolution.\n\n## Guardrails\n- Avoid logging raw ticket bodies/PII; prefer structured summaries.\n- Keep knowledge and ticket adapters explicit and testable.`
17
+ }, {
18
+ id: "docs.examples.ai-support-bot.usage",
19
+ title: "AI Support Bot — Usage",
20
+ summary: "How to run the example and swap the knowledge adapter.",
21
+ kind: "usage",
22
+ visibility: "public",
23
+ route: "/docs/examples/ai-support-bot/usage",
24
+ tags: ["support", "usage"],
25
+ body: `## Usage\n- Call \`runAiSupportBotExample()\`.\n- Replace the \`knowledge.query\` implementation with a real knowledge service.\n\n## Notes\n- Keep outputs structured.\n- Use policy gates before exposing drafted replies to end-users.`
26
+ }]);
27
+
28
+ //#endregion
29
+ //# sourceMappingURL=ai-support-bot.docblock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-support-bot.docblock.js","names":[],"sources":["../../src/docs/ai-support-bot.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst blocks: DocBlock[] = [\n {\n id: 'docs.examples.ai-support-bot',\n title: 'AI Support Bot (example)',\n summary:\n 'Ticket classification + knowledge-grounded resolution + response drafting.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/ai-support-bot',\n tags: ['support', 'ai', 'example'],\n body: `## What this example shows\\n- Classify a ticket into a support category.\\n- Use a knowledge port to generate a grounded resolution.\\n- Draft a response (email body) from the resolution.\\n\\n## Guardrails\\n- Avoid logging raw ticket bodies/PII; prefer structured summaries.\\n- Keep knowledge and ticket adapters explicit and testable.`,\n },\n {\n id: 'docs.examples.ai-support-bot.usage',\n title: 'AI Support Bot — Usage',\n summary: 'How to run the example and swap the knowledge adapter.',\n kind: 'usage',\n visibility: 'public',\n route: '/docs/examples/ai-support-bot/usage',\n tags: ['support', 'usage'],\n body: `## Usage\\n- Call \\`runAiSupportBotExample()\\`.\\n- Replace the \\`knowledge.query\\` implementation with a real knowledge service.\\n\\n## Notes\\n- Keep outputs structured.\\n- Use policy gates before exposing drafted replies to end-users.`,\n },\n];\n\nregisterDocBlocks(blocks);\n"],"mappings":";;;AA2BA,kBAxB2B,CACzB;CACE,IAAI;CACJ,OAAO;CACP,SACE;CACF,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAW;EAAM;EAAU;CAClC,MAAM;CACP,EACD;CACE,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM,CAAC,WAAW,QAAQ;CAC1B,MAAM;CACP,CACF,CAEwB"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ import "./ai-support-bot.docblock.js";
@@ -0,0 +1,34 @@
1
+ //#region src/example.d.ts
2
+ declare const example: {
3
+ readonly id: "ai-support-bot";
4
+ readonly title: "AI Support Bot";
5
+ readonly summary: "Classify and resolve a support ticket (with a drafted response) using the support-bot and knowledge libraries.";
6
+ readonly tags: readonly ["support", "ai", "tickets", "knowledge"];
7
+ readonly kind: "script";
8
+ readonly visibility: "public";
9
+ readonly docs: {
10
+ readonly rootDocId: "docs.examples.ai-support-bot";
11
+ readonly usageDocId: "docs.examples.ai-support-bot.usage";
12
+ };
13
+ readonly entrypoints: {
14
+ readonly packageName: "@contractspec/example.ai-support-bot";
15
+ readonly docs: "./docs";
16
+ };
17
+ readonly surfaces: {
18
+ readonly templates: true;
19
+ readonly sandbox: {
20
+ readonly enabled: true;
21
+ readonly modes: readonly ["markdown"];
22
+ };
23
+ readonly studio: {
24
+ readonly enabled: true;
25
+ readonly installable: true;
26
+ };
27
+ readonly mcp: {
28
+ readonly enabled: true;
29
+ };
30
+ };
31
+ };
32
+ //#endregion
33
+ export { example as default };
34
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"sourcesContent":[],"mappings":";cAAM;EAAA,SAAA,EAsBI,EAAA,gBAAA"}
@@ -0,0 +1,39 @@
1
+ //#region src/example.ts
2
+ const example = {
3
+ id: "ai-support-bot",
4
+ title: "AI Support Bot",
5
+ summary: "Classify and resolve a support ticket (with a drafted response) using the support-bot and knowledge libraries.",
6
+ tags: [
7
+ "support",
8
+ "ai",
9
+ "tickets",
10
+ "knowledge"
11
+ ],
12
+ kind: "script",
13
+ visibility: "public",
14
+ docs: {
15
+ rootDocId: "docs.examples.ai-support-bot",
16
+ usageDocId: "docs.examples.ai-support-bot.usage"
17
+ },
18
+ entrypoints: {
19
+ packageName: "@contractspec/example.ai-support-bot",
20
+ docs: "./docs"
21
+ },
22
+ surfaces: {
23
+ templates: true,
24
+ sandbox: {
25
+ enabled: true,
26
+ modes: ["markdown"]
27
+ },
28
+ studio: {
29
+ enabled: true,
30
+ installable: true
31
+ },
32
+ mcp: { enabled: true }
33
+ }
34
+ };
35
+ var example_default = example;
36
+
37
+ //#endregion
38
+ export { example_default as default };
39
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["const example = {\n id: 'ai-support-bot',\n title: 'AI Support Bot',\n summary:\n 'Classify and resolve a support ticket (with a drafted response) using the support-bot and knowledge libraries.',\n tags: ['support', 'ai', 'tickets', 'knowledge'],\n kind: 'script',\n visibility: 'public',\n docs: {\n rootDocId: 'docs.examples.ai-support-bot',\n usageDocId: 'docs.examples.ai-support-bot.usage',\n },\n entrypoints: {\n packageName: '@contractspec/example.ai-support-bot',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: { enabled: true, modes: ['markdown'] },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n} as const;\n\nexport default example;\n"],"mappings":";AAAA,MAAM,UAAU;CACd,IAAI;CACJ,OAAO;CACP,SACE;CACF,MAAM;EAAC;EAAW;EAAM;EAAW;EAAY;CAC/C,MAAM;CACN,YAAY;CACZ,MAAM;EACJ,WAAW;EACX,YAAY;EACb;CACD,aAAa;EACX,aAAa;EACb,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GAAE,SAAS;GAAM,OAAO,CAAC,WAAW;GAAE;EAC/C,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF;AAED,sBAAe"}
@@ -0,0 +1,3 @@
1
+ import example from "./example.js";
2
+ import { runAiSupportBotExample } from "./setup.js";
3
+ export { example, runAiSupportBotExample };
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import example_default from "./example.js";
2
+ import { runAiSupportBotExample } from "./setup.js";
3
+ import "./docs/index.js";
4
+
5
+ export { example_default as example, runAiSupportBotExample };
@@ -0,0 +1,5 @@
1
+ //#region src/setup.d.ts
2
+ declare function runAiSupportBotExample(): Promise<void>;
3
+ //#endregion
4
+ export { runAiSupportBotExample };
5
+ //# sourceMappingURL=setup.d.ts.map
@@ -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 ADDED
@@ -0,0 +1,45 @@
1
+ import { TicketResolver } from "@contractspec/lib.support-bot/rag";
2
+ import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
3
+ import { AutoResponder } from "@contractspec/lib.support-bot/bot";
4
+ import { LogLevel, Logger } from "@contractspec/lib.logger";
5
+
6
+ //#region src/setup.ts
7
+ const logger = new Logger({
8
+ level: process.env.NODE_ENV === "production" ? LogLevel.INFO : LogLevel.DEBUG,
9
+ environment: process.env.NODE_ENV || "development",
10
+ enableColors: process.env.NODE_ENV !== "production"
11
+ });
12
+ async function runAiSupportBotExample() {
13
+ const resolver = new TicketResolver({ knowledge: { async query(question) {
14
+ return {
15
+ answer: `The payout will retrigger automatically. (${question.slice(0, 40)}…)`,
16
+ references: []
17
+ };
18
+ } } });
19
+ const classifier = new TicketClassifier();
20
+ const responder = new AutoResponder();
21
+ const ticket = {
22
+ id: "TIC-42",
23
+ subject: "Payout failed",
24
+ body: "Hello, our supplier payout failed twice yesterday. Can you confirm status? It is urgent.",
25
+ channel: "email",
26
+ customerName: "Ivy",
27
+ metadata: { accountId: "acct_789" }
28
+ };
29
+ const classification = await classifier.classify(ticket);
30
+ const resolution = await resolver.resolve(ticket);
31
+ const draft = await responder.draft(ticket, resolution, classification);
32
+ logger.info("Support bot run completed", {
33
+ ticketId: ticket.id,
34
+ classification,
35
+ resolution,
36
+ emailDraft: {
37
+ subject: draft.subject,
38
+ body: draft.body
39
+ }
40
+ });
41
+ }
42
+
43
+ //#endregion
44
+ export { runAiSupportBotExample };
45
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","names":["ticket: SupportTicket"],"sources":["../src/setup.ts"],"sourcesContent":["import { TicketResolver } from '@contractspec/lib.support-bot/rag';\nimport { TicketClassifier } from '@contractspec/lib.support-bot/tickets';\nimport { AutoResponder } from '@contractspec/lib.support-bot/bot';\nimport type { KnowledgeAnswer } from '@contractspec/lib.knowledge/query/service';\nimport type { SupportTicket } from '@contractspec/lib.support-bot/types';\nimport { Logger, LogLevel } from '@contractspec/lib.logger';\nimport type { LoggerConfig } from '@contractspec/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/example.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './src/example';
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@contractspec/example.ai-support-bot",
3
+ "version": "1.44.0",
4
+ "description": "AI support bot example: classify and resolve a support ticket using @contractspec/lib.support-bot.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./docs": "./dist/docs/index.js",
11
+ "./docs/ai-support-bot.docblock": "./dist/docs/ai-support-bot.docblock.js",
12
+ "./example": "./dist/example.js",
13
+ "./setup": "./dist/setup.js",
14
+ "./*": "./*"
15
+ },
16
+ "scripts": {
17
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
18
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
19
+ "build": "bun build:types && bun build:bundle",
20
+ "build:bundle": "tsdown",
21
+ "build:types": "tsc --noEmit",
22
+ "dev": "bun build:bundle --watch",
23
+ "clean": "rimraf dist .turbo",
24
+ "lint": "bun lint:fix",
25
+ "lint:fix": "eslint src --fix",
26
+ "lint:check": "eslint src",
27
+ "test": "bun test"
28
+ },
29
+ "dependencies": {
30
+ "@contractspec/lib.support-bot": "1.44.0",
31
+ "@contractspec/lib.knowledge": "1.44.0",
32
+ "@contractspec/lib.schema": "1.44.0",
33
+ "@contractspec/lib.contracts": "1.44.0",
34
+ "@contractspec/lib.logger": "1.44.0"
35
+ },
36
+ "devDependencies": {
37
+ "@contractspec/tool.tsdown": "1.44.0",
38
+ "@contractspec/tool.typescript": "1.44.0",
39
+ "tsdown": "^0.18.3",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public",
44
+ "exports": {
45
+ ".": "./dist/index.js",
46
+ "./docs": "./dist/docs/index.js",
47
+ "./docs/ai-support-bot.docblock": "./dist/docs/ai-support-bot.docblock.js",
48
+ "./example": "./dist/example.js",
49
+ "./setup": "./dist/setup.js",
50
+ "./*": "./*"
51
+ },
52
+ "registry": "https://registry.npmjs.org/"
53
+ },
54
+ "module": "./dist/index.js",
55
+ "license": "MIT",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/lssm-tech/contractspec.git",
59
+ "directory": "packages/examples/ai-support-bot"
60
+ },
61
+ "homepage": "https://contractspec.io"
62
+ }
package/setup.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { runAiSupportBotExample } from './src/setup';
2
+
3
+ void runAiSupportBotExample().catch((error) => {
4
+ // Keep console usage limited to this demo entrypoint only.
5
+ // eslint-disable-next-line no-console
6
+ console.error(error);
7
+ process.exitCode = 1;
8
+ });
@@ -0,0 +1,28 @@
1
+ import type { DocBlock } from '@contractspec/lib.contracts/docs';
2
+ import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
3
+
4
+ const blocks: DocBlock[] = [
5
+ {
6
+ id: 'docs.examples.ai-support-bot',
7
+ title: 'AI Support Bot (example)',
8
+ summary:
9
+ 'Ticket classification + knowledge-grounded resolution + response drafting.',
10
+ kind: 'reference',
11
+ visibility: 'public',
12
+ route: '/docs/examples/ai-support-bot',
13
+ tags: ['support', 'ai', 'example'],
14
+ body: `## What this example shows\n- Classify a ticket into a support category.\n- Use a knowledge port to generate a grounded resolution.\n- Draft a response (email body) from the resolution.\n\n## Guardrails\n- Avoid logging raw ticket bodies/PII; prefer structured summaries.\n- Keep knowledge and ticket adapters explicit and testable.`,
15
+ },
16
+ {
17
+ id: 'docs.examples.ai-support-bot.usage',
18
+ title: 'AI Support Bot — Usage',
19
+ summary: 'How to run the example and swap the knowledge adapter.',
20
+ kind: 'usage',
21
+ visibility: 'public',
22
+ route: '/docs/examples/ai-support-bot/usage',
23
+ tags: ['support', 'usage'],
24
+ body: `## Usage\n- Call \`runAiSupportBotExample()\`.\n- Replace the \`knowledge.query\` implementation with a real knowledge service.\n\n## Notes\n- Keep outputs structured.\n- Use policy gates before exposing drafted replies to end-users.`,
25
+ },
26
+ ];
27
+
28
+ registerDocBlocks(blocks);
@@ -0,0 +1 @@
1
+ import './ai-support-bot.docblock';
package/src/example.ts ADDED
@@ -0,0 +1,25 @@
1
+ const example = {
2
+ id: 'ai-support-bot',
3
+ title: 'AI Support Bot',
4
+ summary:
5
+ 'Classify and resolve a support ticket (with a drafted response) using the support-bot and knowledge libraries.',
6
+ tags: ['support', 'ai', 'tickets', 'knowledge'],
7
+ kind: 'script',
8
+ visibility: 'public',
9
+ docs: {
10
+ rootDocId: 'docs.examples.ai-support-bot',
11
+ usageDocId: 'docs.examples.ai-support-bot.usage',
12
+ },
13
+ entrypoints: {
14
+ packageName: '@contractspec/example.ai-support-bot',
15
+ docs: './docs',
16
+ },
17
+ surfaces: {
18
+ templates: true,
19
+ sandbox: { enabled: true, modes: ['markdown'] },
20
+ studio: { enabled: true, installable: true },
21
+ mcp: { enabled: true },
22
+ },
23
+ } as const;
24
+
25
+ export default example;
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './setup';
2
+ export { default as example } from './example';
3
+ import './docs';