@contractspec/example.ai-support-bot 3.7.5 → 3.7.7
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.log +3 -3
- package/AGENTS.md +39 -18
- package/CHANGELOG.md +11 -0
- package/README.md +63 -7
- package/dist/browser/index.js +2 -2
- package/dist/browser/setup.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node/index.js +2 -2
- package/dist/node/setup.js +2 -2
- package/dist/setup.js +2 -2
- package/package.json +9 -9
- package/setup.ts +4 -4
- package/src/ai-support-bot.feature.ts +13 -13
- package/src/docs/ai-support-bot.docblock.ts +21 -21
- package/src/example.ts +26 -26
- package/src/index.ts +1 -1
- package/src/setup.ts +36 -36
- package/tsconfig.json +7 -9
- package/tsdown.config.js +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -3,7 +3,7 @@ $ bun run prebuild && bun run build:bundle && bun run build:types
|
|
|
3
3
|
$ contractspec-bun-build prebuild
|
|
4
4
|
$ contractspec-bun-build transpile
|
|
5
5
|
[contractspec-bun-build] transpile target=bun root=src entries=6 noBundle=false
|
|
6
|
-
Bundled 6 modules in
|
|
6
|
+
Bundled 6 modules in 35ms
|
|
7
7
|
|
|
8
8
|
./ai-support-bot.feature.js 0.66 KB (entry point)
|
|
9
9
|
./index.js 4.38 KB (entry point)
|
|
@@ -13,7 +13,7 @@ Bundled 6 modules in 15ms
|
|
|
13
13
|
./setup.js 1.44 KB (entry point)
|
|
14
14
|
|
|
15
15
|
[contractspec-bun-build] transpile target=node root=src entries=6 noBundle=false
|
|
16
|
-
Bundled 6 modules in
|
|
16
|
+
Bundled 6 modules in 7ms
|
|
17
17
|
|
|
18
18
|
./ai-support-bot.feature.js 0.66 KB (entry point)
|
|
19
19
|
./index.js 4.36 KB (entry point)
|
|
@@ -23,7 +23,7 @@ Bundled 6 modules in 8ms
|
|
|
23
23
|
./setup.js 1.43 KB (entry point)
|
|
24
24
|
|
|
25
25
|
[contractspec-bun-build] transpile target=browser root=src entries=6 noBundle=false
|
|
26
|
-
Bundled 6 modules in
|
|
26
|
+
Bundled 6 modules in 22ms
|
|
27
27
|
|
|
28
28
|
./ai-support-bot.feature.js 0.66 KB (entry point)
|
|
29
29
|
./index.js 4.36 KB (entry point)
|
package/AGENTS.md
CHANGED
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
# AI Agent Guide
|
|
1
|
+
# AI Agent Guide — `@contractspec/example.ai-support-bot`
|
|
2
2
|
|
|
3
3
|
Scope: `packages/examples/ai-support-bot/*`
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
AI support bot example: classify and resolve a support ticket using @contractspec/lib.support-bot.
|
|
6
6
|
|
|
7
7
|
## Quick Context
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- Layer: `example`.
|
|
10
|
+
- Package visibility: published package.
|
|
11
|
+
- Primary consumers are example explorers, template authors, and documentation readers.
|
|
12
|
+
- Related packages: `@contractspec/lib.contracts-spec`, `@contractspec/lib.knowledge`, `@contractspec/lib.logger`, `@contractspec/lib.support-bot`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
11
13
|
|
|
12
|
-
##
|
|
14
|
+
## Architecture
|
|
13
15
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
16
|
+
- `src/ai-support-bot.feature.ts` defines a feature entrypoint.
|
|
17
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
18
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
19
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
20
|
+
- `src/setup.ts` is part of the package's public or composition surface.
|
|
18
21
|
|
|
19
|
-
## Public
|
|
22
|
+
## Public Surface
|
|
20
23
|
|
|
21
|
-
- `.`
|
|
22
|
-
- `./
|
|
23
|
-
- `./
|
|
24
|
-
- `./
|
|
24
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
25
|
+
- Export `./ai-support-bot.feature` resolves through `./src/ai-support-bot.feature.ts`.
|
|
26
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
27
|
+
- Export `./docs/ai-support-bot.docblock` resolves through `./src/docs/ai-support-bot.docblock.ts`.
|
|
28
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
29
|
+
- Export `./setup` resolves through `./src/setup.ts`.
|
|
30
|
+
|
|
31
|
+
## Guardrails
|
|
32
|
+
|
|
33
|
+
- Keep the example package demonstrative, buildable, and aligned with the exported feature surface.
|
|
34
|
+
- Do not add hidden production assumptions that are not actually implemented in the example.
|
|
35
|
+
- Changes here can affect downstream packages such as `@contractspec/lib.contracts-spec`, `@contractspec/lib.knowledge`, `@contractspec/lib.logger`, `@contractspec/lib.support-bot`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
36
|
+
- Changes here can affect downstream packages such as `@contractspec/lib.contracts-spec`, `@contractspec/lib.knowledge`, `@contractspec/lib.logger`, `@contractspec/lib.support-bot`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
25
37
|
|
|
26
38
|
## Local Commands
|
|
27
39
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
40
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
41
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
42
|
+
- `bun run test` — bun test --pass-with-no-tests
|
|
43
|
+
- `bun run lint` — bun lint:fix
|
|
44
|
+
- `bun run lint:check` — biome check .
|
|
45
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
46
|
+
- `bun run typecheck` — tsc --noEmit
|
|
47
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
48
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
49
|
+
- `bun run clean` — rimraf dist .turbo
|
|
50
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
51
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
52
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @contractspec/example.ai-support-bot
|
|
2
2
|
|
|
3
|
+
## 3.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: release manifest
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @contractspec/lib.contracts-spec@3.7.6
|
|
10
|
+
- @contractspec/lib.support-bot@3.7.6
|
|
11
|
+
- @contractspec/lib.knowledge@3.7.6
|
|
12
|
+
- @contractspec/lib.logger@3.7.6
|
|
13
|
+
|
|
3
14
|
## 3.7.5
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,12 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @contractspec/example.ai-support-bot
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**AI support bot example: classify and resolve a support ticket using @contractspec/lib.support-bot.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What This Demonstrates
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- Ticket classification pipeline with AI-driven resolution.
|
|
10
|
+
- Integration of support-bot lib with knowledge base.
|
|
11
|
+
- DocBlock documentation for in-app help.
|
|
12
|
+
- Setup and example entry points for quick cloning.
|
|
13
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
14
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
## Running Locally
|
|
17
|
+
|
|
18
|
+
From `packages/examples/ai-support-bot`:
|
|
19
|
+
- `bun run dev`
|
|
20
|
+
- `bun run build`
|
|
21
|
+
- `bun run test`
|
|
22
|
+
- `bun run typecheck`
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Use `@contractspec/example.ai-support-bot` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
- `src/ai-support-bot.feature.ts` defines a feature entrypoint.
|
|
31
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
32
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
33
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
34
|
+
- `src/setup.ts` is part of the package's public or composition surface.
|
|
35
|
+
|
|
36
|
+
## Public Entry Points
|
|
37
|
+
|
|
38
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
39
|
+
- Export `./ai-support-bot.feature` resolves through `./src/ai-support-bot.feature.ts`.
|
|
40
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
41
|
+
- Export `./docs/ai-support-bot.docblock` resolves through `./src/docs/ai-support-bot.docblock.ts`.
|
|
42
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
43
|
+
- Export `./setup` resolves through `./src/setup.ts`.
|
|
44
|
+
|
|
45
|
+
## Local Commands
|
|
46
|
+
|
|
47
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
48
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
49
|
+
- `bun run test` — bun test --pass-with-no-tests
|
|
50
|
+
- `bun run lint` — bun lint:fix
|
|
51
|
+
- `bun run lint:check` — biome check .
|
|
52
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
53
|
+
- `bun run typecheck` — tsc --noEmit
|
|
54
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
55
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
56
|
+
- `bun run clean` — rimraf dist .turbo
|
|
57
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
58
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
59
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
60
|
+
|
|
61
|
+
## Recent Updates
|
|
62
|
+
|
|
63
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
64
|
+
- Missing contract layers.
|
|
65
|
+
|
|
66
|
+
## Notes
|
|
67
|
+
|
|
68
|
+
- Works alongside `@contractspec/lib.contracts-spec`, `@contractspec/lib.knowledge`, `@contractspec/lib.logger`, `@contractspec/lib.support-bot`, `@contractspec/tool.bun`, ...
|
package/dist/browser/index.js
CHANGED
|
@@ -85,10 +85,10 @@ var example = defineExample({
|
|
|
85
85
|
var example_default = example;
|
|
86
86
|
|
|
87
87
|
// src/setup.ts
|
|
88
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
89
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
88
90
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
89
91
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
90
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
91
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
92
92
|
var logger = new Logger({
|
|
93
93
|
level: LogLevel.INFO,
|
|
94
94
|
environment: "production",
|
package/dist/browser/setup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/setup.ts
|
|
2
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
3
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
2
4
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
3
5
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
4
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
5
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
6
6
|
var logger = new Logger({
|
|
7
7
|
level: LogLevel.INFO,
|
|
8
8
|
environment: "production",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -86,10 +86,10 @@ var example = defineExample({
|
|
|
86
86
|
var example_default = example;
|
|
87
87
|
|
|
88
88
|
// src/setup.ts
|
|
89
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
90
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
89
91
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
90
92
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
91
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
92
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
93
93
|
var logger = new Logger({
|
|
94
94
|
level: LogLevel.INFO,
|
|
95
95
|
environment: "production",
|
package/dist/node/index.js
CHANGED
|
@@ -85,10 +85,10 @@ var example = defineExample({
|
|
|
85
85
|
var example_default = example;
|
|
86
86
|
|
|
87
87
|
// src/setup.ts
|
|
88
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
89
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
88
90
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
89
91
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
90
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
91
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
92
92
|
var logger = new Logger({
|
|
93
93
|
level: LogLevel.INFO,
|
|
94
94
|
environment: "production",
|
package/dist/node/setup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/setup.ts
|
|
2
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
3
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
2
4
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
3
5
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
4
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
5
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
6
6
|
var logger = new Logger({
|
|
7
7
|
level: LogLevel.INFO,
|
|
8
8
|
environment: "production",
|
package/dist/setup.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/setup.ts
|
|
3
|
+
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
4
|
+
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
3
5
|
import { TicketResolver } from "@contractspec/lib.support-bot/rag";
|
|
4
6
|
import { TicketClassifier } from "@contractspec/lib.support-bot/tickets";
|
|
5
|
-
import { AutoResponder } from "@contractspec/lib.support-bot/bot";
|
|
6
|
-
import { Logger, LogLevel } from "@contractspec/lib.logger";
|
|
7
7
|
var logger = new Logger({
|
|
8
8
|
level: LogLevel.INFO,
|
|
9
9
|
environment: "production",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.ai-support-bot",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.7",
|
|
4
4
|
"description": "AI support bot example: classify and resolve a support ticket using @contractspec/lib.support-bot.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -57,22 +57,22 @@
|
|
|
57
57
|
"dev": "contractspec-bun-build dev",
|
|
58
58
|
"clean": "rimraf dist .turbo",
|
|
59
59
|
"lint": "bun lint:fix",
|
|
60
|
-
"lint:fix": "
|
|
61
|
-
"lint:check": "
|
|
60
|
+
"lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
|
|
61
|
+
"lint:check": "biome check .",
|
|
62
62
|
"test": "bun test --pass-with-no-tests",
|
|
63
63
|
"prebuild": "contractspec-bun-build prebuild",
|
|
64
64
|
"typecheck": "tsc --noEmit"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@contractspec/lib.support-bot": "3.7.
|
|
68
|
-
"@contractspec/lib.knowledge": "3.7.
|
|
69
|
-
"@contractspec/lib.contracts-spec": "
|
|
70
|
-
"@contractspec/lib.logger": "3.7.
|
|
67
|
+
"@contractspec/lib.support-bot": "3.7.7",
|
|
68
|
+
"@contractspec/lib.knowledge": "3.7.7",
|
|
69
|
+
"@contractspec/lib.contracts-spec": "4.0.0",
|
|
70
|
+
"@contractspec/lib.logger": "3.7.6"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@contractspec/tool.typescript": "3.7.
|
|
73
|
+
"@contractspec/tool.typescript": "3.7.6",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
|
-
"@contractspec/tool.bun": "3.7.
|
|
75
|
+
"@contractspec/tool.bun": "3.7.6"
|
|
76
76
|
},
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public",
|
package/setup.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { runAiSupportBotExample } from './src/setup';
|
|
2
2
|
|
|
3
3
|
void runAiSupportBotExample().catch((error) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
8
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { defineFeature } from '@contractspec/lib.contracts-spec';
|
|
2
2
|
|
|
3
3
|
export const AiSupportBotFeature = defineFeature({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'ai-support-bot',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'AI Support Bot',
|
|
8
|
+
description:
|
|
9
|
+
'AI support ticket classification and resolution using grounded knowledge',
|
|
10
|
+
domain: 'support',
|
|
11
|
+
owners: ['@examples'],
|
|
12
|
+
tags: ['ai', 'support', 'knowledge', 'tickets'],
|
|
13
|
+
stability: 'experimental',
|
|
14
|
+
},
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
knowledge: [{ key: 'ai-support-bot.knowledge.articles', version: '1.0.0' }],
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
docs: ['docs.examples.ai-support-bot', 'docs.examples.ai-support-bot.usage'],
|
|
19
19
|
});
|
|
@@ -2,27 +2,27 @@ import type { DocBlock } from '@contractspec/lib.contracts-spec/docs';
|
|
|
2
2
|
import { registerDocBlocks } from '@contractspec/lib.contracts-spec/docs';
|
|
3
3
|
|
|
4
4
|
const blocks: DocBlock[] = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
26
|
];
|
|
27
27
|
|
|
28
28
|
registerDocBlocks(blocks);
|
package/src/example.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { defineExample } from '@contractspec/lib.contracts-spec';
|
|
2
2
|
|
|
3
3
|
const example = defineExample({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'ai-support-bot',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'AI Support Bot',
|
|
8
|
+
description:
|
|
9
|
+
'Classify and resolve a support ticket (with a drafted response) using the support-bot and knowledge libraries.',
|
|
10
|
+
kind: 'script',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['support', 'ai', 'tickets', 'knowledge'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.ai-support-bot',
|
|
18
|
+
usageDocId: 'docs.examples.ai-support-bot.usage',
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: '@contractspec/example.ai-support-bot',
|
|
22
|
+
docs: './docs',
|
|
23
|
+
},
|
|
24
|
+
surfaces: {
|
|
25
|
+
templates: true,
|
|
26
|
+
sandbox: { enabled: true, modes: ['markdown'] },
|
|
27
|
+
studio: { enabled: true, installable: true },
|
|
28
|
+
mcp: { enabled: true },
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export default example;
|
package/src/index.ts
CHANGED
package/src/setup.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
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
1
|
import type { KnowledgeAnswer } from '@contractspec/lib.knowledge/query/service';
|
|
5
|
-
import type { SupportTicket } from '@contractspec/lib.support-bot/types';
|
|
6
2
|
import { Logger, LogLevel } from '@contractspec/lib.logger';
|
|
7
3
|
import type { LoggerConfig } from '@contractspec/lib.logger/types';
|
|
4
|
+
import { AutoResponder } from '@contractspec/lib.support-bot/bot';
|
|
5
|
+
import { TicketResolver } from '@contractspec/lib.support-bot/rag';
|
|
6
|
+
import { TicketClassifier } from '@contractspec/lib.support-bot/tickets';
|
|
7
|
+
import type { SupportTicket } from '@contractspec/lib.support-bot/types';
|
|
8
8
|
|
|
9
9
|
const logger = new Logger({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
level: process.env.NODE_ENV === 'production' ? LogLevel.INFO : LogLevel.DEBUG,
|
|
11
|
+
environment:
|
|
12
|
+
(process.env.NODE_ENV as LoggerConfig['environment']) || 'development',
|
|
13
|
+
enableColors: process.env.NODE_ENV !== 'production',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export async function runAiSupportBotExample(): Promise<void> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const knowledge = {
|
|
18
|
+
async query(question: string): Promise<KnowledgeAnswer> {
|
|
19
|
+
return {
|
|
20
|
+
answer: `The payout will retrigger automatically. (${question.slice(0, 40)}…)`,
|
|
21
|
+
references: [],
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const resolver = new TicketResolver({ knowledge });
|
|
27
|
+
const classifier = new TicketClassifier();
|
|
28
|
+
const responder = new AutoResponder();
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const ticket: SupportTicket = {
|
|
31
|
+
id: 'TIC-42',
|
|
32
|
+
subject: 'Payout failed',
|
|
33
|
+
body: 'Hello, our supplier payout failed twice yesterday. Can you confirm status? It is urgent.',
|
|
34
|
+
channel: 'email',
|
|
35
|
+
customerName: 'Ivy',
|
|
36
|
+
metadata: { accountId: 'acct_789' },
|
|
37
|
+
};
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const classification = await classifier.classify(ticket);
|
|
40
|
+
const resolution = await resolver.resolve(ticket);
|
|
41
|
+
const draft = await responder.draft(ticket, resolution, classification);
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
logger.info('Support bot run completed', {
|
|
44
|
+
ticketId: ticket.id,
|
|
45
|
+
classification,
|
|
46
|
+
resolution,
|
|
47
|
+
emailDraft: { subject: draft.subject, body: draft.body },
|
|
48
|
+
});
|
|
49
49
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
"extends": "@contractspec/tool.typescript/react-library.json",
|
|
3
|
+
"include": ["src"],
|
|
4
|
+
"exclude": ["node_modules", "dist"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "dist"
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
package/tsdown.config.js
CHANGED