capman 0.4.2 → 0.4.3

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 (47) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/CODEBASE.md +391 -0
  3. package/README.md +1 -1
  4. package/bin/capman.js +11 -724
  5. package/bin/lib/cmd-demo.js +180 -0
  6. package/bin/lib/cmd-explain.js +72 -0
  7. package/bin/lib/cmd-generate.js +280 -0
  8. package/bin/lib/cmd-help.js +26 -0
  9. package/bin/lib/cmd-init.js +19 -0
  10. package/bin/lib/cmd-inspect.js +33 -0
  11. package/bin/lib/cmd-run.js +71 -0
  12. package/bin/lib/cmd-validate.js +32 -0
  13. package/bin/lib/shared.js +70 -0
  14. package/dist/cjs/engine.d.ts +58 -1
  15. package/dist/cjs/engine.d.ts.map +1 -1
  16. package/dist/cjs/engine.js +307 -12
  17. package/dist/cjs/engine.js.map +1 -1
  18. package/dist/cjs/generator.d.ts.map +1 -1
  19. package/dist/cjs/generator.js +4 -0
  20. package/dist/cjs/generator.js.map +1 -1
  21. package/dist/cjs/index.d.ts +1 -1
  22. package/dist/cjs/index.d.ts.map +1 -1
  23. package/dist/cjs/index.js.map +1 -1
  24. package/dist/cjs/matcher.d.ts.map +1 -1
  25. package/dist/cjs/matcher.js +19 -25
  26. package/dist/cjs/matcher.js.map +1 -1
  27. package/dist/cjs/types.d.ts +27 -0
  28. package/dist/cjs/types.d.ts.map +1 -1
  29. package/dist/cjs/version.d.ts +1 -1
  30. package/dist/cjs/version.js +1 -1
  31. package/dist/esm/cache.d.ts +49 -0
  32. package/dist/esm/engine.d.ts +138 -0
  33. package/dist/esm/engine.js +307 -12
  34. package/dist/esm/generator.d.ts +7 -0
  35. package/dist/esm/generator.js +4 -0
  36. package/dist/esm/index.d.ts +47 -0
  37. package/dist/esm/learning.d.ts +55 -0
  38. package/dist/esm/logger.d.ts +21 -0
  39. package/dist/esm/matcher.d.ts +6 -0
  40. package/dist/esm/matcher.js +19 -25
  41. package/dist/esm/parser.d.ts +10 -0
  42. package/dist/esm/resolver.d.ts +21 -0
  43. package/dist/esm/schema.d.ts +740 -0
  44. package/dist/esm/types.d.ts +136 -0
  45. package/dist/esm/version.d.ts +1 -0
  46. package/dist/esm/version.js +1 -1
  47. package/package.json +5 -3
@@ -0,0 +1,136 @@
1
+ export type ResolverType = 'api' | 'nav' | 'hybrid';
2
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
3
+ export interface CapabilityParam {
4
+ name: string;
5
+ description: string;
6
+ required: boolean;
7
+ source: 'user_query' | 'session' | 'context' | 'static';
8
+ default?: string | number | boolean;
9
+ }
10
+ export interface ApiResolver {
11
+ type: 'api';
12
+ endpoints: Array<{
13
+ method: HttpMethod;
14
+ path: string;
15
+ params?: string[];
16
+ }>;
17
+ }
18
+ export interface NavResolver {
19
+ type: 'nav';
20
+ destination: string;
21
+ hint?: string;
22
+ }
23
+ export interface HybridResolver {
24
+ type: 'hybrid';
25
+ api: Omit<ApiResolver, 'type'>;
26
+ nav: Omit<NavResolver, 'type'>;
27
+ }
28
+ export type Resolver = ApiResolver | NavResolver | HybridResolver;
29
+ export interface PrivacyScope {
30
+ level: 'public' | 'user_owned' | 'admin';
31
+ note?: string;
32
+ }
33
+ export interface Capability {
34
+ id: string;
35
+ name: string;
36
+ description: string;
37
+ examples?: string[];
38
+ params: CapabilityParam[];
39
+ returns: string[];
40
+ resolver: Resolver;
41
+ privacy: PrivacyScope;
42
+ }
43
+ export interface Manifest {
44
+ version: string;
45
+ app: string;
46
+ generatedAt: string;
47
+ capabilities: Capability[];
48
+ }
49
+ export interface CapmanConfig {
50
+ app: string;
51
+ baseUrl?: string;
52
+ capabilities: Capability[];
53
+ }
54
+ export interface MatchResult {
55
+ capability: Capability | null;
56
+ confidence: number;
57
+ intent: 'navigation' | 'retrieval' | 'hybrid' | 'out_of_scope';
58
+ extractedParams: Record<string, string | null>;
59
+ reasoning: string;
60
+ /** All scored candidates — always present after match() */
61
+ candidates: MatchCandidate[];
62
+ }
63
+ export interface ApiCallResult {
64
+ method: string;
65
+ url: string;
66
+ params: Record<string, unknown>;
67
+ /** HTTP status code — only present when actually executed (not dry run) */
68
+ status?: number;
69
+ /** Parsed JSON response body — only present when actually executed */
70
+ data?: unknown;
71
+ }
72
+ export interface ResolveResult {
73
+ success: boolean;
74
+ resolverType: ResolverType | null;
75
+ apiCalls?: ApiCallResult[];
76
+ navTarget?: string;
77
+ /** Execution time in milliseconds */
78
+ durationMs?: number;
79
+ error?: string;
80
+ }
81
+ export interface ValidationResult {
82
+ valid: boolean;
83
+ errors: string[];
84
+ warnings: string[];
85
+ }
86
+ export interface MatchCandidate {
87
+ capabilityId: string;
88
+ score: number;
89
+ matched: boolean;
90
+ }
91
+ export interface TraceStep {
92
+ type: 'cache_check' | 'keyword_match' | 'llm_match' | 'privacy_check' | 'resolve';
93
+ status: 'hit' | 'miss' | 'pass' | 'fail' | 'skip';
94
+ durationMs: number;
95
+ detail?: string;
96
+ }
97
+ export interface ExecutionTrace {
98
+ query: string;
99
+ /** All capabilities scored — not just the winner */
100
+ candidates: MatchCandidate[];
101
+ /** Why the winning capability was selected */
102
+ reasoning: string[];
103
+ /** Step-by-step execution breakdown */
104
+ steps: TraceStep[];
105
+ /** Which matcher was used */
106
+ resolvedVia: 'cache' | 'keyword' | 'llm';
107
+ /** Total duration */
108
+ totalMs: number;
109
+ }
110
+ export interface ExplainCandidate {
111
+ capabilityId: string;
112
+ score: number;
113
+ matched: boolean;
114
+ /** Human-readable explanation of why this capability scored this way */
115
+ explanation: string;
116
+ }
117
+ export interface ExplainResult {
118
+ query: string;
119
+ matched: {
120
+ capability: Capability | null;
121
+ confidence: number;
122
+ intent: string;
123
+ reasoning: string[];
124
+ };
125
+ candidates: ExplainCandidate[];
126
+ wouldExecute: {
127
+ resolverType: ResolverType | null;
128
+ /** The action that would be taken — e.g. "GET https://api.com/orders/1234" */
129
+ action: string | null;
130
+ privacy: string | null;
131
+ /** Set if privacy enforcement would block execution */
132
+ blocked: string | null;
133
+ };
134
+ resolvedVia: 'keyword' | 'llm';
135
+ durationMs: number;
136
+ }
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.4.3";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/version.js — do not edit manually
2
- export const VERSION = '0.4.2';
2
+ export const VERSION = '0.4.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capman",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Capability Manifest Engine — let AI agents interact with your app without navigating the UI",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -8,7 +8,7 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": {
11
- "types": "./dist/cjs/index.d.ts",
11
+ "types": "./dist/esm/index.d.ts",
12
12
  "default": "./dist/esm/index.js"
13
13
  },
14
14
  "require": {
@@ -24,7 +24,9 @@
24
24
  "dist",
25
25
  "bin",
26
26
  "README.md",
27
- "CONTRIBUTING.md"
27
+ "CONTRIBUTING.md",
28
+ "CHANGELOG.md",
29
+ "CODEBASE.md"
28
30
  ],
29
31
  "scripts": {
30
32
  "prebuild": "node scripts/version.js",