@ddse/acm-examples 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/src/examples/entitlement/tasks.d.ts +44 -0
  2. package/dist/src/examples/entitlement/tasks.d.ts.map +1 -0
  3. package/dist/src/examples/entitlement/tasks.js +27 -0
  4. package/dist/src/examples/entitlement/tasks.js.map +1 -0
  5. package/dist/src/examples/entitlement/tools.d.ts +74 -0
  6. package/dist/src/examples/entitlement/tools.d.ts.map +1 -0
  7. package/dist/src/examples/entitlement/tools.js +63 -0
  8. package/dist/src/examples/entitlement/tools.js.map +1 -0
  9. package/dist/src/framework.d.ts +19 -0
  10. package/dist/src/framework.d.ts.map +1 -0
  11. package/dist/src/framework.js +42 -0
  12. package/dist/src/framework.js.map +1 -0
  13. package/dist/tests/entitlement.test.d.ts +2 -0
  14. package/dist/tests/entitlement.test.d.ts.map +1 -0
  15. package/dist/tests/entitlement.test.js +30 -0
  16. package/dist/tests/entitlement.test.js.map +1 -0
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/package.json +22 -9
  19. package/bin/acm-demo.ts +0 -495
  20. package/data/coaching/agents.json +0 -16
  21. package/data/coaching/transcripts.json +0 -37
  22. package/data/documents.json +0 -72
  23. package/data/entitlement/customers.json +0 -38
  24. package/data/entitlement/policies.json +0 -38
  25. package/data/incidents/incidents.json +0 -30
  26. package/data/incidents/routing_rules.json +0 -36
  27. package/data/invoices/invoices.json +0 -38
  28. package/data/invoices/purchase-orders.json +0 -38
  29. package/data/issues.json +0 -99
  30. package/data/knowledge/docs/kb-001.md +0 -7
  31. package/data/knowledge/docs/kb-002.md +0 -7
  32. package/data/knowledge/docs/kb-003.md +0 -9
  33. package/data/knowledge/index.json +0 -25
  34. package/data/orders.json +0 -106
  35. package/docs/examples-architecture.md +0 -144
  36. package/docs/successrun.md +0 -1022
  37. package/src/context/directives.ts +0 -366
  38. package/src/context/index.ts +0 -1
  39. package/src/data/coaching.ts +0 -50
  40. package/src/data/entitlement.ts +0 -60
  41. package/src/data/incidents.ts +0 -78
  42. package/src/data/invoices.ts +0 -103
  43. package/src/data/knowledge.ts +0 -77
  44. package/src/data/loader.ts +0 -80
  45. package/src/examples/scenarios.ts +0 -724
  46. package/src/goals/index.ts +0 -18
  47. package/src/policy.ts +0 -30
  48. package/src/registries.ts +0 -48
  49. package/src/renderer.ts +0 -82
  50. package/src/search/bm25.ts +0 -173
  51. package/src/search/index.ts +0 -2
  52. package/src/tasks/coaching.ts +0 -217
  53. package/src/tasks/entitlement.ts +0 -197
  54. package/src/tasks/incidents.ts +0 -277
  55. package/src/tasks/index.ts +0 -6
  56. package/src/tasks/invoices.ts +0 -269
  57. package/src/tasks/knowledge.ts +0 -169
  58. package/src/tasks/legacy.ts +0 -112
  59. package/src/tools/coaching/index.ts +0 -197
  60. package/src/tools/entitlement/index.ts +0 -199
  61. package/src/tools/incidents/index.ts +0 -185
  62. package/src/tools/index.ts +0 -192
  63. package/src/tools/invoices/index.ts +0 -165
  64. package/src/tools/knowledge/index.ts +0 -203
  65. package/tests/bm25.test.ts +0 -129
  66. package/tests/integration.test.ts +0 -163
  67. package/tests/plan-hydration.test.ts +0 -33
  68. package/tsconfig.json +0 -18
@@ -1,77 +0,0 @@
1
- import { loadJson, loadText } from './loader.js';
2
-
3
- export interface KnowledgeSnippetMeta {
4
- id: string;
5
- title: string;
6
- tags: string[];
7
- path: string;
8
- summary: string;
9
- }
10
-
11
- interface KnowledgeIndex {
12
- snippets: KnowledgeSnippetMeta[];
13
- }
14
-
15
- let cachedIndex: KnowledgeIndex | null = null;
16
-
17
- async function loadIndex(): Promise<KnowledgeIndex> {
18
- if (cachedIndex) {
19
- return cachedIndex;
20
- }
21
-
22
- cachedIndex = await loadJson<KnowledgeIndex>('data/knowledge/index.json');
23
- return cachedIndex;
24
- }
25
-
26
- export async function searchSnippets(query: string): Promise<KnowledgeSnippetMeta[]> {
27
- const index = await loadIndex();
28
- const lower = query.toLowerCase();
29
- return index.snippets
30
- .map(snippet => ({
31
- snippet,
32
- score: scoreSnippet(snippet, lower),
33
- }))
34
- .filter(entry => entry.score > 0)
35
- .sort((a, b) => b.score - a.score)
36
- .map(entry => entry.snippet);
37
- }
38
-
39
- function scoreSnippet(snippet: KnowledgeSnippetMeta, query: string): number {
40
- const haystack = `${snippet.title} ${snippet.tags.join(' ')} ${snippet.summary}`.toLowerCase();
41
- let score = 0;
42
- for (const term of query.split(/\s+/)) {
43
- if (!term) continue;
44
- if (haystack.includes(term)) {
45
- score += 2;
46
- }
47
- for (const tag of snippet.tags) {
48
- if (tag.toLowerCase() === term) {
49
- score += 3;
50
- }
51
- }
52
- }
53
- return score;
54
- }
55
-
56
- export async function loadSnippetContent(docId: string): Promise<string | undefined> {
57
- const index = await loadIndex();
58
- const snippet = index.snippets.find(item => item.id === docId);
59
- if (!snippet) {
60
- return undefined;
61
- }
62
-
63
- return loadText(pathForSnippet(snippet.path));
64
- }
65
-
66
- function pathForSnippet(relative: string): string {
67
- return pathNormalize(`data/knowledge/${relative}`);
68
- }
69
-
70
- function pathNormalize(relative: string): string {
71
- return relative.replace(/\\/g, '/');
72
- }
73
-
74
- export async function getSnippetMeta(docId: string): Promise<KnowledgeSnippetMeta | undefined> {
75
- const index = await loadIndex();
76
- return index.snippets.find(item => item.id === docId);
77
- }
@@ -1,80 +0,0 @@
1
- import { readFile } from 'fs/promises';
2
- import { fileURLToPath } from 'url';
3
- import * as path from 'path';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- const jsonCache = new Map<string, unknown>();
9
- const textCache = new Map<string, string>();
10
- const pathCache = new Map<string, string>();
11
-
12
- function candidatePaths(relativePath: string): string[] {
13
- return [
14
- path.resolve(process.cwd(), relativePath),
15
- path.resolve(__dirname, '..', '..', relativePath),
16
- path.resolve(__dirname, '..', '..', '..', relativePath),
17
- ];
18
- }
19
-
20
- async function readDataFile(relativePath: string): Promise<{ absolute: string; content: string }> {
21
- if (pathCache.has(relativePath)) {
22
- const absolute = pathCache.get(relativePath)!;
23
- const content = await readFile(absolute, 'utf-8');
24
- return { absolute, content };
25
- }
26
-
27
- const candidates = candidatePaths(relativePath);
28
- let lastError: unknown;
29
-
30
- for (const absolute of candidates) {
31
- try {
32
- const content = await readFile(absolute, 'utf-8');
33
- pathCache.set(relativePath, absolute);
34
- return { absolute, content };
35
- } catch (error) {
36
- lastError = error;
37
- }
38
- }
39
-
40
- throw lastError instanceof Error
41
- ? lastError
42
- : new Error(`Unable to read data file ${relativePath}`);
43
- }
44
-
45
- export async function loadJson<T>(relativePath: string): Promise<T> {
46
- if (pathCache.has(relativePath)) {
47
- const absolute = pathCache.get(relativePath)!;
48
- if (jsonCache.has(absolute)) {
49
- return jsonCache.get(absolute) as T;
50
- }
51
- }
52
-
53
- const { absolute, content } = await readDataFile(relativePath);
54
- if (jsonCache.has(absolute)) {
55
- return jsonCache.get(absolute) as T;
56
- }
57
-
58
- const parsed = JSON.parse(content) as T;
59
- jsonCache.set(absolute, parsed);
60
- return parsed;
61
- }
62
-
63
- export async function loadText(relativePath: string): Promise<string> {
64
- if (pathCache.has(relativePath)) {
65
- const absolute = pathCache.get(relativePath)!;
66
- if (textCache.has(absolute)) {
67
- return textCache.get(absolute)!;
68
- }
69
- }
70
-
71
- const { absolute, content } = await readDataFile(relativePath);
72
- textCache.set(absolute, content);
73
- return content;
74
- }
75
-
76
- export function clearDataCaches(): void {
77
- jsonCache.clear();
78
- textCache.clear();
79
- pathCache.clear();
80
- }