capman 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/bin/lib/cmd-demo.js +2 -2
- package/dist/cjs/cache.d.ts +2 -0
- package/dist/cjs/cache.d.ts.map +1 -1
- package/dist/cjs/cache.js +31 -14
- package/dist/cjs/cache.js.map +1 -1
- package/dist/cjs/engine.d.ts +3 -1
- package/dist/cjs/engine.d.ts.map +1 -1
- package/dist/cjs/engine.js +74 -23
- package/dist/cjs/engine.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/learning.d.ts +0 -1
- package/dist/cjs/learning.d.ts.map +1 -1
- package/dist/cjs/learning.js +34 -17
- package/dist/cjs/learning.js.map +1 -1
- package/dist/cjs/matcher.d.ts +4 -1
- package/dist/cjs/matcher.d.ts.map +1 -1
- package/dist/cjs/matcher.js +31 -12
- package/dist/cjs/matcher.js.map +1 -1
- package/dist/cjs/parser.js +2 -2
- package/dist/cjs/parser.js.map +1 -1
- package/dist/cjs/resolver.js +24 -4
- package/dist/cjs/resolver.js.map +1 -1
- package/dist/cjs/schema.d.ts +14 -14
- package/dist/cjs/schema.d.ts.map +1 -1
- package/dist/cjs/schema.js +4 -2
- package/dist/cjs/schema.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/cache.d.ts +2 -0
- package/dist/esm/cache.js +31 -14
- package/dist/esm/engine.d.ts +3 -1
- package/dist/esm/engine.js +75 -24
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/learning.d.ts +0 -1
- package/dist/esm/learning.js +34 -17
- package/dist/esm/matcher.d.ts +4 -1
- package/dist/esm/matcher.js +29 -11
- package/dist/esm/parser.js +2 -2
- package/dist/esm/resolver.js +24 -4
- package/dist/esm/schema.d.ts +14 -14
- package/dist/esm/schema.js +4 -2
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
package/dist/cjs/schema.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
108
108
|
hint?: string | undefined;
|
|
109
109
|
}>;
|
|
110
110
|
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
type: "hybrid";
|
|
111
112
|
api: {
|
|
112
113
|
endpoints: {
|
|
113
114
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -119,8 +120,8 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
119
120
|
destination: string;
|
|
120
121
|
hint?: string | undefined;
|
|
121
122
|
};
|
|
122
|
-
type: "hybrid";
|
|
123
123
|
}, {
|
|
124
|
+
type: "hybrid";
|
|
124
125
|
api: {
|
|
125
126
|
endpoints: {
|
|
126
127
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -132,7 +133,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
132
133
|
destination: string;
|
|
133
134
|
hint?: string | undefined;
|
|
134
135
|
};
|
|
135
|
-
type: "hybrid";
|
|
136
136
|
}>]>;
|
|
137
137
|
privacy: z.ZodObject<{
|
|
138
138
|
level: z.ZodEnum<["public", "user_owned", "admin"]>;
|
|
@@ -168,6 +168,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
168
168
|
destination: string;
|
|
169
169
|
hint?: string | undefined;
|
|
170
170
|
} | {
|
|
171
|
+
type: "hybrid";
|
|
171
172
|
api: {
|
|
172
173
|
endpoints: {
|
|
173
174
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -179,7 +180,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
179
180
|
destination: string;
|
|
180
181
|
hint?: string | undefined;
|
|
181
182
|
};
|
|
182
|
-
type: "hybrid";
|
|
183
183
|
};
|
|
184
184
|
privacy: {
|
|
185
185
|
level: "public" | "user_owned" | "admin";
|
|
@@ -210,6 +210,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
210
210
|
destination: string;
|
|
211
211
|
hint?: string | undefined;
|
|
212
212
|
} | {
|
|
213
|
+
type: "hybrid";
|
|
213
214
|
api: {
|
|
214
215
|
endpoints: {
|
|
215
216
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -221,7 +222,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
221
222
|
destination: string;
|
|
222
223
|
hint?: string | undefined;
|
|
223
224
|
};
|
|
224
|
-
type: "hybrid";
|
|
225
225
|
};
|
|
226
226
|
privacy: {
|
|
227
227
|
level: "public" | "user_owned" | "admin";
|
|
@@ -252,6 +252,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
252
252
|
destination: string;
|
|
253
253
|
hint?: string | undefined;
|
|
254
254
|
} | {
|
|
255
|
+
type: "hybrid";
|
|
255
256
|
api: {
|
|
256
257
|
endpoints: {
|
|
257
258
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -263,7 +264,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
263
264
|
destination: string;
|
|
264
265
|
hint?: string | undefined;
|
|
265
266
|
};
|
|
266
|
-
type: "hybrid";
|
|
267
267
|
};
|
|
268
268
|
privacy: {
|
|
269
269
|
level: "public" | "user_owned" | "admin";
|
|
@@ -294,6 +294,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
294
294
|
destination: string;
|
|
295
295
|
hint?: string | undefined;
|
|
296
296
|
} | {
|
|
297
|
+
type: "hybrid";
|
|
297
298
|
api: {
|
|
298
299
|
endpoints: {
|
|
299
300
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -305,7 +306,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
305
306
|
destination: string;
|
|
306
307
|
hint?: string | undefined;
|
|
307
308
|
};
|
|
308
|
-
type: "hybrid";
|
|
309
309
|
};
|
|
310
310
|
privacy: {
|
|
311
311
|
level: "public" | "user_owned" | "admin";
|
|
@@ -339,6 +339,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
339
339
|
destination: string;
|
|
340
340
|
hint?: string | undefined;
|
|
341
341
|
} | {
|
|
342
|
+
type: "hybrid";
|
|
342
343
|
api: {
|
|
343
344
|
endpoints: {
|
|
344
345
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -350,7 +351,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
350
351
|
destination: string;
|
|
351
352
|
hint?: string | undefined;
|
|
352
353
|
};
|
|
353
|
-
type: "hybrid";
|
|
354
354
|
};
|
|
355
355
|
privacy: {
|
|
356
356
|
level: "public" | "user_owned" | "admin";
|
|
@@ -385,6 +385,7 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
385
385
|
destination: string;
|
|
386
386
|
hint?: string | undefined;
|
|
387
387
|
} | {
|
|
388
|
+
type: "hybrid";
|
|
388
389
|
api: {
|
|
389
390
|
endpoints: {
|
|
390
391
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -396,7 +397,6 @@ export declare const CapmanConfigSchema: z.ZodObject<{
|
|
|
396
397
|
destination: string;
|
|
397
398
|
hint?: string | undefined;
|
|
398
399
|
};
|
|
399
|
-
type: "hybrid";
|
|
400
400
|
};
|
|
401
401
|
privacy: {
|
|
402
402
|
level: "public" | "user_owned" | "admin";
|
|
@@ -516,6 +516,7 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
516
516
|
hint?: string | undefined;
|
|
517
517
|
}>;
|
|
518
518
|
}, "strip", z.ZodTypeAny, {
|
|
519
|
+
type: "hybrid";
|
|
519
520
|
api: {
|
|
520
521
|
endpoints: {
|
|
521
522
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -527,8 +528,8 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
527
528
|
destination: string;
|
|
528
529
|
hint?: string | undefined;
|
|
529
530
|
};
|
|
530
|
-
type: "hybrid";
|
|
531
531
|
}, {
|
|
532
|
+
type: "hybrid";
|
|
532
533
|
api: {
|
|
533
534
|
endpoints: {
|
|
534
535
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -540,7 +541,6 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
540
541
|
destination: string;
|
|
541
542
|
hint?: string | undefined;
|
|
542
543
|
};
|
|
543
|
-
type: "hybrid";
|
|
544
544
|
}>]>;
|
|
545
545
|
privacy: z.ZodObject<{
|
|
546
546
|
level: z.ZodEnum<["public", "user_owned", "admin"]>;
|
|
@@ -576,6 +576,7 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
576
576
|
destination: string;
|
|
577
577
|
hint?: string | undefined;
|
|
578
578
|
} | {
|
|
579
|
+
type: "hybrid";
|
|
579
580
|
api: {
|
|
580
581
|
endpoints: {
|
|
581
582
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -587,7 +588,6 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
587
588
|
destination: string;
|
|
588
589
|
hint?: string | undefined;
|
|
589
590
|
};
|
|
590
|
-
type: "hybrid";
|
|
591
591
|
};
|
|
592
592
|
privacy: {
|
|
593
593
|
level: "public" | "user_owned" | "admin";
|
|
@@ -618,6 +618,7 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
618
618
|
destination: string;
|
|
619
619
|
hint?: string | undefined;
|
|
620
620
|
} | {
|
|
621
|
+
type: "hybrid";
|
|
621
622
|
api: {
|
|
622
623
|
endpoints: {
|
|
623
624
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -629,7 +630,6 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
629
630
|
destination: string;
|
|
630
631
|
hint?: string | undefined;
|
|
631
632
|
};
|
|
632
|
-
type: "hybrid";
|
|
633
633
|
};
|
|
634
634
|
privacy: {
|
|
635
635
|
level: "public" | "user_owned" | "admin";
|
|
@@ -664,6 +664,7 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
664
664
|
destination: string;
|
|
665
665
|
hint?: string | undefined;
|
|
666
666
|
} | {
|
|
667
|
+
type: "hybrid";
|
|
667
668
|
api: {
|
|
668
669
|
endpoints: {
|
|
669
670
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -675,7 +676,6 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
675
676
|
destination: string;
|
|
676
677
|
hint?: string | undefined;
|
|
677
678
|
};
|
|
678
|
-
type: "hybrid";
|
|
679
679
|
};
|
|
680
680
|
privacy: {
|
|
681
681
|
level: "public" | "user_owned" | "admin";
|
|
@@ -711,6 +711,7 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
711
711
|
destination: string;
|
|
712
712
|
hint?: string | undefined;
|
|
713
713
|
} | {
|
|
714
|
+
type: "hybrid";
|
|
714
715
|
api: {
|
|
715
716
|
endpoints: {
|
|
716
717
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -722,7 +723,6 @@ export declare const ManifestSchema: z.ZodObject<{
|
|
|
722
723
|
destination: string;
|
|
723
724
|
hint?: string | undefined;
|
|
724
725
|
};
|
|
725
|
-
type: "hybrid";
|
|
726
726
|
};
|
|
727
727
|
privacy: {
|
|
728
728
|
level: "public" | "user_owned" | "admin";
|
package/dist/cjs/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO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,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,mBAAmB,CAQnE;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAQvE"}
|
package/dist/cjs/schema.js
CHANGED
|
@@ -55,8 +55,10 @@ const CapabilitySchema = zod_1.z.object({
|
|
|
55
55
|
id: zod_1.z.string().min(1, 'capability id is required')
|
|
56
56
|
.regex(/^[a-z0-9_]+$/, 'id must be snake_case (lowercase, numbers, underscores only)'),
|
|
57
57
|
name: zod_1.z.string().min(1, 'capability name is required'),
|
|
58
|
-
description: zod_1.z.string()
|
|
59
|
-
|
|
58
|
+
description: zod_1.z.string()
|
|
59
|
+
.min(10, 'description must be at least 10 characters for accurate matching')
|
|
60
|
+
.max(500, 'description must be 500 characters or fewer'),
|
|
61
|
+
examples: zod_1.z.array(zod_1.z.string().max(200, 'each example must be 200 characters or fewer')).optional(),
|
|
60
62
|
params: zod_1.z.array(CapabilityParamSchema),
|
|
61
63
|
returns: zod_1.z.array(zod_1.z.string()),
|
|
62
64
|
resolver: ResolverSchema,
|
package/dist/cjs/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":";;;AAsGA,wCAQC;AAED,4CAQC;AAxHD,6BAAuB;AAEvB,iFAAiF;AAEjF,MAAM,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAS,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;IACxD,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,+BAA+B,CAAC;IAC/D,QAAQ,EAAK,OAAC,CAAC,OAAO,EAAE;IACxB,MAAM,EAAO,OAAC,CAA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8C;IAC9C,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,uCAAuC;IACvC,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,6BAA6B;IAC7B,WAAW,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAA;IACxC,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB;AAID,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAS,MAAM,CAAA;IACpB,OAAO,EAAO,OAAO,CAAA;IACrB,wEAAwE;IACxE,WAAW,EAAG,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAO,MAAM,CAAA;IAClB,OAAO,EAAE;QACP,UAAU,EAAE,UAAU,GAAG,IAAI,CAAA;QAC7B,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAM,MAAM,CAAA;QAClB,SAAS,EAAG,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,UAAU,EAAI,gBAAgB,EAAE,CAAA;IAChC,YAAY,EAAE;QACZ,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;QACjC,8EAA8E;QAC9E,MAAM,EAAQ,MAAM,GAAG,IAAI,CAAA;QAC3B,OAAO,EAAO,MAAM,GAAG,IAAI,CAAA;QAC3B,uDAAuD;QACvD,OAAO,EAAO,MAAM,GAAG,IAAI,CAAA;KAC5B,CAAA;IACD,WAAW,EAAG,SAAS,GAAG,KAAK,CAAA;IAC/B,UAAU,EAAI,MAAM,CAAA;CACrB;AAID,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAA"}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.5.
|
|
1
|
+
export declare const VERSION = "0.5.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/cache.d.ts
CHANGED
|
@@ -47,5 +47,7 @@ export declare class ComboCache implements CacheStore {
|
|
|
47
47
|
get(key: string, ttlMs?: number): Promise<CacheEntry | null>;
|
|
48
48
|
set(key: string, result: MatchResult): Promise<void>;
|
|
49
49
|
clear(): Promise<void>;
|
|
50
|
+
/** Returns the file-side entry count, not total unique entries across both stores.
|
|
51
|
+
* Memory may have additional promoted entries not reflected here. */
|
|
50
52
|
size(): Promise<number>;
|
|
51
53
|
}
|
package/dist/esm/cache.js
CHANGED
|
@@ -68,7 +68,14 @@ export class FileCache {
|
|
|
68
68
|
this.store = new Map();
|
|
69
69
|
this.loaded = false;
|
|
70
70
|
this.saveQueue = Promise.resolve();
|
|
71
|
-
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
const resolved = path.resolve(cwd, filePath);
|
|
73
|
+
const allowedPrefix = cwd === '/' ? '/' : cwd + path.sep;
|
|
74
|
+
if (!resolved.startsWith(allowedPrefix)) {
|
|
75
|
+
throw new Error(`FileCache path "${filePath}" resolves outside the working directory.\n` +
|
|
76
|
+
`Resolved: ${resolved}\nAllowed: ${cwd}`);
|
|
77
|
+
}
|
|
78
|
+
this.filePath = resolved;
|
|
72
79
|
logger.info(`FileCache initialized — writing to: ${this.filePath}`);
|
|
73
80
|
}
|
|
74
81
|
async load() {
|
|
@@ -78,7 +85,14 @@ export class FileCache {
|
|
|
78
85
|
const raw = await fs.promises.readFile(this.filePath, 'utf-8');
|
|
79
86
|
const parsed = JSON.parse(raw);
|
|
80
87
|
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
81
|
-
|
|
88
|
+
// Normalize keys on load — prevents duplicate entries from older versions,
|
|
89
|
+
// manual edits, or any path that bypassed normalizeQuery() on write.
|
|
90
|
+
// e.g. "Show me articles" and "show me articles" collapse to the same key.
|
|
91
|
+
const normalized = new Map();
|
|
92
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
93
|
+
normalized.set(normalizeQuery(k), v);
|
|
94
|
+
}
|
|
95
|
+
this.store = normalized;
|
|
82
96
|
logger.debug(`File cache loaded: ${this.store.size} entries`);
|
|
83
97
|
}
|
|
84
98
|
else {
|
|
@@ -107,20 +121,21 @@ export class FileCache {
|
|
|
107
121
|
async get(key, ttlMs) {
|
|
108
122
|
await this.load();
|
|
109
123
|
const entry = this.store.get(key);
|
|
110
|
-
if (entry)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
await this.save();
|
|
114
|
-
logger.debug(`Cache entry expired (file): "${key}"`);
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
entry.hits++;
|
|
124
|
+
if (!entry)
|
|
125
|
+
return null;
|
|
126
|
+
if (ttlMs && Date.now() - new Date(entry.cachedAt).getTime() > ttlMs) {
|
|
118
127
|
this.store.delete(key);
|
|
119
|
-
this.
|
|
120
|
-
logger.debug(`Cache
|
|
121
|
-
|
|
128
|
+
await this.save(); // eviction must be persisted
|
|
129
|
+
logger.debug(`Cache entry expired (file): "${key}"`);
|
|
130
|
+
return null;
|
|
122
131
|
}
|
|
123
|
-
|
|
132
|
+
entry.hits++;
|
|
133
|
+
this.store.delete(key); // reinsert at end for LRU ordering
|
|
134
|
+
this.store.set(key, entry);
|
|
135
|
+
// hits counter is in-memory only — not saved on read
|
|
136
|
+
// saves only happen on set() and eviction to avoid full file rewrite per request
|
|
137
|
+
logger.debug(`Cache hit (file): "${key}"`);
|
|
138
|
+
return entry;
|
|
124
139
|
}
|
|
125
140
|
async set(key, result) {
|
|
126
141
|
await this.load();
|
|
@@ -178,6 +193,8 @@ export class ComboCache {
|
|
|
178
193
|
this.file.clear(),
|
|
179
194
|
]);
|
|
180
195
|
}
|
|
196
|
+
/** Returns the file-side entry count, not total unique entries across both stores.
|
|
197
|
+
* Memory may have additional promoted entries not reflected here. */
|
|
181
198
|
async size() {
|
|
182
199
|
return this.file.size();
|
|
183
200
|
}
|
package/dist/esm/engine.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { LLMMatcherOptions } from './matcher';
|
|
|
3
3
|
import type { ResolveOptions, AuthContext } from './resolver';
|
|
4
4
|
import type { CacheStore } from './cache';
|
|
5
5
|
import type { LearningStore } from './learning';
|
|
6
|
-
import type { MatchMode } from './
|
|
6
|
+
import type { MatchMode } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* Options for constructing a CapmanEngine instance.
|
|
9
9
|
*
|
|
@@ -93,6 +93,8 @@ export interface EngineResult {
|
|
|
93
93
|
trace: ExecutionTrace;
|
|
94
94
|
}
|
|
95
95
|
export declare class CapmanEngine {
|
|
96
|
+
/** Maximum allowed query length in characters. Queries exceeding this throw RangeError. */
|
|
97
|
+
static readonly MAX_QUERY_LENGTH = 1000;
|
|
96
98
|
private manifest;
|
|
97
99
|
private mode;
|
|
98
100
|
private llm?;
|
package/dist/esm/engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { match as _match, matchWithLLM as _matchWithLLM, resolverToIntent, extractParams, STOPWORDS } from './matcher';
|
|
1
|
+
import { match as _match, matchWithLLM as _matchWithLLM, resolverToIntent, extractParams, STOPWORDS, LLMParseError } from './matcher';
|
|
2
2
|
import { resolve as _resolve } from './resolver';
|
|
3
3
|
import { MemoryLearningStore } from './learning';
|
|
4
4
|
import { logger } from './logger';
|
|
@@ -24,7 +24,7 @@ export class CapmanEngine {
|
|
|
24
24
|
this.maxLLMCallsPerMinute = options.maxLLMCallsPerMinute ?? 60;
|
|
25
25
|
this.llmCooldownMs = options.llmCooldownMs ?? 0;
|
|
26
26
|
this.llmCircuitBreakerThreshold = options.llmCircuitBreakerThreshold ?? 3;
|
|
27
|
-
this.llmCircuitBreakerResetMs = options.llmCircuitBreakerResetMs ??
|
|
27
|
+
this.llmCircuitBreakerResetMs = options.llmCircuitBreakerResetMs ?? 60_000;
|
|
28
28
|
// Cache — default MemoryCache (no filesystem writes), or disabled with false
|
|
29
29
|
// Use FileCache or ComboCache explicitly for persistence across restarts
|
|
30
30
|
this.cache = options.cache === false
|
|
@@ -37,14 +37,14 @@ export class CapmanEngine {
|
|
|
37
37
|
: (options.learning ?? new MemoryLearningStore());
|
|
38
38
|
logger.info(`CapmanEngine initialized — mode: ${this.mode}, cache: ${this.cache ? 'enabled' : 'disabled'}, learning: ${this.learning ? 'enabled' : 'disabled'}`);
|
|
39
39
|
// ── Manifest version compatibility check ─────────────────────────────────
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
if (options.manifest.version) {
|
|
41
|
+
const [mMaj, mMin] = options.manifest.version.split('.').map(Number);
|
|
42
|
+
const [eMaj, eMin] = VERSION.split('.').map(Number);
|
|
43
|
+
if (mMaj !== eMaj || mMin !== eMin) {
|
|
44
|
+
console.warn(`[capman] Manifest version "${options.manifest.version}" was generated with a ` +
|
|
45
|
+
`different engine version than "${VERSION}". This is usually fine across patch versions. ` +
|
|
46
|
+
`If you experience unexpected matching issues, regenerate with: npx capman generate`);
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -59,6 +59,12 @@ export class CapmanEngine {
|
|
|
59
59
|
* console.log(result.resolvedVia) // 'keyword' | 'llm' | 'cache'
|
|
60
60
|
*/
|
|
61
61
|
async ask(query, overrides = {}) {
|
|
62
|
+
if (!query || typeof query !== 'string') {
|
|
63
|
+
throw new TypeError('query must be a non-empty string');
|
|
64
|
+
}
|
|
65
|
+
if (query.length > CapmanEngine.MAX_QUERY_LENGTH) {
|
|
66
|
+
throw new RangeError(`query exceeds maximum length of ${CapmanEngine.MAX_QUERY_LENGTH} characters`);
|
|
67
|
+
}
|
|
62
68
|
const start = Date.now();
|
|
63
69
|
const steps = [];
|
|
64
70
|
// ── Step 1: Check cache ──────────────────────────────────────────────────
|
|
@@ -69,7 +75,18 @@ export class CapmanEngine {
|
|
|
69
75
|
if (cached) {
|
|
70
76
|
steps.push({ type: 'cache_check', status: 'hit', durationMs: Date.now() - cacheStart, detail: 'Served from cache' });
|
|
71
77
|
logger.info(`Cache hit for: "${query}"`);
|
|
72
|
-
|
|
78
|
+
// Re-extract params from the current query — never re-use cached params.
|
|
79
|
+
// Cached params belong to the original query (potentially from a different user).
|
|
80
|
+
// e.g. User A: "show orders for john" → cached with { customer: 'john' }
|
|
81
|
+
// User B: "show orders for jane" → must get { customer: 'jane' }, not john's
|
|
82
|
+
const freshParams = cached.result.capability
|
|
83
|
+
? extractParams(query, cached.result.capability)
|
|
84
|
+
: {};
|
|
85
|
+
const matchWithFreshParams = {
|
|
86
|
+
...cached.result,
|
|
87
|
+
extractedParams: freshParams,
|
|
88
|
+
};
|
|
89
|
+
const resolution = await _resolve(matchWithFreshParams, freshParams, this.resolveOptions(overrides));
|
|
73
90
|
const trace = {
|
|
74
91
|
query,
|
|
75
92
|
candidates: cached.result.candidates,
|
|
@@ -79,13 +96,13 @@ export class CapmanEngine {
|
|
|
79
96
|
totalMs: Date.now() - start,
|
|
80
97
|
};
|
|
81
98
|
const result = {
|
|
82
|
-
match:
|
|
99
|
+
match: matchWithFreshParams,
|
|
83
100
|
resolution,
|
|
84
101
|
resolvedVia: 'cache',
|
|
85
102
|
durationMs: Date.now() - start,
|
|
86
103
|
trace,
|
|
87
104
|
};
|
|
88
|
-
await this.recordLearning(query,
|
|
105
|
+
await this.recordLearning(query, matchWithFreshParams, 'cache');
|
|
89
106
|
return result;
|
|
90
107
|
}
|
|
91
108
|
steps.push({ type: 'cache_check', status: 'miss', durationMs: Date.now() - cacheStart });
|
|
@@ -213,6 +230,12 @@ export class CapmanEngine {
|
|
|
213
230
|
* console.log(explanation.candidates)
|
|
214
231
|
*/
|
|
215
232
|
async explain(query) {
|
|
233
|
+
if (!query || typeof query !== 'string') {
|
|
234
|
+
throw new TypeError('query must be a non-empty string');
|
|
235
|
+
}
|
|
236
|
+
if (query.length > CapmanEngine.MAX_QUERY_LENGTH) {
|
|
237
|
+
throw new RangeError(`query exceeds maximum length of ${CapmanEngine.MAX_QUERY_LENGTH} characters`);
|
|
238
|
+
}
|
|
216
239
|
const start = Date.now();
|
|
217
240
|
// ── Match — shared with ask() via _runMatch() ─────────────────────────────
|
|
218
241
|
let { matchResult, resolvedVia: _resolvedVia } = await this._runMatch(query);
|
|
@@ -261,12 +284,17 @@ export class CapmanEngine {
|
|
|
261
284
|
}
|
|
262
285
|
reasoning.push(`Resolved via: ${resolvedVia}`);
|
|
263
286
|
if (matchResult.extractedParams && Object.keys(matchResult.extractedParams).length) {
|
|
264
|
-
const
|
|
287
|
+
const extracted = Object.entries(matchResult.extractedParams)
|
|
265
288
|
.filter(([, v]) => v !== null)
|
|
266
289
|
.map(([k, v]) => `${k}=${v}`)
|
|
267
290
|
.join(', ');
|
|
268
|
-
|
|
269
|
-
|
|
291
|
+
const session = matchResult.capability?.params
|
|
292
|
+
.filter(p => p.source === 'session')
|
|
293
|
+
.map(p => `${p.name}=[from auth]`)
|
|
294
|
+
.join(', ');
|
|
295
|
+
const parts = [extracted, session].filter(Boolean).join(', ');
|
|
296
|
+
if (parts)
|
|
297
|
+
reasoning.push(`Would extract params: ${parts}`);
|
|
270
298
|
}
|
|
271
299
|
// ── Build wouldExecute ───────────────────────────────────────────────────
|
|
272
300
|
const cap = matchResult.capability;
|
|
@@ -299,7 +327,7 @@ export class CapmanEngine {
|
|
|
299
327
|
let path = endpoint.path;
|
|
300
328
|
for (const [k, v] of Object.entries(params)) {
|
|
301
329
|
if (v)
|
|
302
|
-
path = path.
|
|
330
|
+
path = path.replaceAll(`{${k}}`, v);
|
|
303
331
|
}
|
|
304
332
|
const base = this.baseUrl ?? '';
|
|
305
333
|
action = `${endpoint.method} ${base}${path}`;
|
|
@@ -308,7 +336,7 @@ export class CapmanEngine {
|
|
|
308
336
|
let dest = cap.resolver.destination;
|
|
309
337
|
for (const [k, v] of Object.entries(params)) {
|
|
310
338
|
if (v)
|
|
311
|
-
dest = dest.
|
|
339
|
+
dest = dest.replaceAll(`{${k}}`, v);
|
|
312
340
|
}
|
|
313
341
|
action = `navigate → ${dest}`;
|
|
314
342
|
}
|
|
@@ -318,12 +346,12 @@ export class CapmanEngine {
|
|
|
318
346
|
let path = endpoint.path;
|
|
319
347
|
for (const [k, v] of Object.entries(params)) {
|
|
320
348
|
if (v)
|
|
321
|
-
path = path.
|
|
349
|
+
path = path.replaceAll(`{${k}}`, v);
|
|
322
350
|
}
|
|
323
351
|
let dest = hybrid.nav.destination;
|
|
324
352
|
for (const [k, v] of Object.entries(params)) {
|
|
325
353
|
if (v)
|
|
326
|
-
dest = dest.
|
|
354
|
+
dest = dest.replaceAll(`{${k}}`, v);
|
|
327
355
|
}
|
|
328
356
|
const base = this.baseUrl ?? '';
|
|
329
357
|
action = `${endpoint.method} ${base}${path} + navigate → ${dest}`;
|
|
@@ -372,13 +400,13 @@ export class CapmanEngine {
|
|
|
372
400
|
}
|
|
373
401
|
// ── Per-minute rate limit ────────────────────────────────────────────────
|
|
374
402
|
const windowElapsed = now - this.llmWindowStart;
|
|
375
|
-
if (windowElapsed >=
|
|
403
|
+
if (windowElapsed >= 60_000) {
|
|
376
404
|
this.llmCallsThisMinute = 0;
|
|
377
405
|
this.llmWindowStart = now;
|
|
378
406
|
}
|
|
379
407
|
if (this.llmCallsThisMinute >= this.maxLLMCallsPerMinute) {
|
|
380
408
|
// Recalculate elapsed after possible window reset above
|
|
381
|
-
const resetIn = Math.ceil((
|
|
409
|
+
const resetIn = Math.ceil((60_000 - (now - this.llmWindowStart)) / 1000);
|
|
382
410
|
return `rate limit reached (${this.maxLLMCallsPerMinute}/min) — resets in ${Math.max(0, resetIn)}s`;
|
|
383
411
|
}
|
|
384
412
|
// Reserve the slot atomically before the call happens
|
|
@@ -432,10 +460,21 @@ export class CapmanEngine {
|
|
|
432
460
|
matchResult = await _matchWithLLM(query, this.manifest, { llm: this.llm });
|
|
433
461
|
this.recordLLMSuccess();
|
|
434
462
|
resolvedVia = 'llm';
|
|
463
|
+
// Merge keyword scores into LLM candidates so boost has real signal for alternatives
|
|
464
|
+
const kwResult = _match(query, this.manifest);
|
|
465
|
+
matchResult = {
|
|
466
|
+
...matchResult,
|
|
467
|
+
candidates: matchResult.candidates.map(c => ({
|
|
468
|
+
...c,
|
|
469
|
+
score: c.matched
|
|
470
|
+
? c.score // keep LLM confidence for winner
|
|
471
|
+
: (kwResult.candidates.find(kc => kc.capabilityId === c.capabilityId)?.score ?? 0),
|
|
472
|
+
})),
|
|
473
|
+
};
|
|
435
474
|
steps?.push({ type: 'llm_match', status: 'pass', durationMs: Date.now() - t, detail: `confidence: ${matchResult.confidence}%` });
|
|
436
475
|
}
|
|
437
476
|
catch (err) {
|
|
438
|
-
const isParseError =
|
|
477
|
+
const isParseError = err instanceof LLMParseError;
|
|
439
478
|
if (!isParseError)
|
|
440
479
|
this.recordLLMFailure();
|
|
441
480
|
logger.warn(`LLM call failed — falling back to keyword: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -476,10 +515,20 @@ export class CapmanEngine {
|
|
|
476
515
|
matchResult = await _matchWithLLM(query, this.manifest, { llm: this.llm });
|
|
477
516
|
this.recordLLMSuccess();
|
|
478
517
|
resolvedVia = 'llm';
|
|
518
|
+
// keywordResult already computed above in balanced mode — merge scores
|
|
519
|
+
matchResult = {
|
|
520
|
+
...matchResult,
|
|
521
|
+
candidates: matchResult.candidates.map(c => ({
|
|
522
|
+
...c,
|
|
523
|
+
score: c.matched
|
|
524
|
+
? c.score
|
|
525
|
+
: (keywordResult.candidates.find(kc => kc.capabilityId === c.capabilityId)?.score ?? 0),
|
|
526
|
+
})),
|
|
527
|
+
};
|
|
479
528
|
steps?.push({ type: 'llm_match', status: 'pass', durationMs: Date.now() - t2, detail: `confidence: ${matchResult.confidence}%` });
|
|
480
529
|
}
|
|
481
530
|
catch (err) {
|
|
482
|
-
const isParseError =
|
|
531
|
+
const isParseError = err instanceof LLMParseError;
|
|
483
532
|
if (!isParseError)
|
|
484
533
|
this.recordLLMFailure();
|
|
485
534
|
logger.warn(`LLM call failed — falling back to keyword: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -594,3 +643,5 @@ export class CapmanEngine {
|
|
|
594
643
|
});
|
|
595
644
|
}
|
|
596
645
|
}
|
|
646
|
+
/** Maximum allowed query length in characters. Queries exceeding this throw RangeError. */
|
|
647
|
+
CapmanEngine.MAX_QUERY_LENGTH = 1000;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { LogLevel } from './logger';
|
|
|
3
3
|
export type { Capability, CapabilityParam, CapmanConfig, Manifest, MatchResult, ExecutionTrace, TraceStep, MatchCandidate, ResolveResult, ApiCallResult, ValidationResult, Resolver, ApiResolver, NavResolver, HybridResolver, PrivacyScope, ResolverType, HttpMethod, ExplainResult, ExplainCandidate, } from './types';
|
|
4
4
|
export { generate, loadConfig, writeManifest, readManifest, validate, generateStarterConfig, } from './generator';
|
|
5
5
|
export { match, matchWithLLM, extractParams, } from './matcher';
|
|
6
|
+
export { LLMParseError } from './matcher';
|
|
6
7
|
export type { LLMMatcherOptions } from './matcher';
|
|
7
8
|
export { resolve } from './resolver';
|
|
8
9
|
export type { ResolveOptions, AuthContext } from './resolver';
|
|
@@ -14,10 +15,10 @@ export { FileLearningStore, MemoryLearningStore } from './learning';
|
|
|
14
15
|
export type { LearningStore, LearningEntry, KeywordStats } from './learning';
|
|
15
16
|
export { parseOpenAPI } from './parser';
|
|
16
17
|
export type { ParseResult } from './parser';
|
|
17
|
-
import type { Manifest, MatchResult, ResolveResult } from './types';
|
|
18
|
+
import type { Manifest, MatchResult, ResolveResult, MatchMode } from './types';
|
|
18
19
|
import type { LLMMatcherOptions } from './matcher';
|
|
19
20
|
import type { ResolveOptions } from './resolver';
|
|
20
|
-
export type MatchMode
|
|
21
|
+
export type { MatchMode } from './types';
|
|
21
22
|
export interface AskOptions extends ResolveOptions {
|
|
22
23
|
llm?: LLMMatcherOptions['llm'];
|
|
23
24
|
/**
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { setLogLevel } from './logger';
|
|
2
2
|
export { generate, loadConfig, writeManifest, readManifest, validate, generateStarterConfig, } from './generator';
|
|
3
3
|
export { match, matchWithLLM, extractParams, } from './matcher';
|
|
4
|
+
export { LLMParseError } from './matcher';
|
|
4
5
|
export { resolve } from './resolver';
|
|
5
6
|
// ─── Engine (recommended API) ─────────────────────────────────────────────────
|
|
6
7
|
export { CapmanEngine } from './engine';
|