capman 0.4.4 → 0.5.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/CODEBASE.md +94 -156
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +23 -0
  5. package/bin/lib/cmd-generate.js +20 -3
  6. package/dist/cjs/cache.d.ts +2 -0
  7. package/dist/cjs/cache.d.ts.map +1 -1
  8. package/dist/cjs/cache.js +16 -3
  9. package/dist/cjs/cache.js.map +1 -1
  10. package/dist/cjs/engine.d.ts +36 -0
  11. package/dist/cjs/engine.d.ts.map +1 -1
  12. package/dist/cjs/engine.js +123 -9
  13. package/dist/cjs/engine.js.map +1 -1
  14. package/dist/cjs/index.d.ts +1 -1
  15. package/dist/cjs/index.d.ts.map +1 -1
  16. package/dist/cjs/index.js +2 -1
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/learning.d.ts +14 -1
  19. package/dist/cjs/learning.d.ts.map +1 -1
  20. package/dist/cjs/learning.js +92 -8
  21. package/dist/cjs/learning.js.map +1 -1
  22. package/dist/cjs/matcher.d.ts +14 -1
  23. package/dist/cjs/matcher.d.ts.map +1 -1
  24. package/dist/cjs/matcher.js +43 -19
  25. package/dist/cjs/matcher.js.map +1 -1
  26. package/dist/cjs/resolver.d.ts.map +1 -1
  27. package/dist/cjs/resolver.js +15 -4
  28. package/dist/cjs/resolver.js.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 +2 -0
  32. package/dist/esm/cache.js +16 -3
  33. package/dist/esm/engine.d.ts +36 -0
  34. package/dist/esm/engine.js +124 -10
  35. package/dist/esm/index.d.ts +1 -1
  36. package/dist/esm/index.js +1 -1
  37. package/dist/esm/learning.d.ts +14 -1
  38. package/dist/esm/learning.js +92 -8
  39. package/dist/esm/matcher.d.ts +14 -1
  40. package/dist/esm/matcher.js +39 -18
  41. package/dist/esm/resolver.js +15 -4
  42. package/dist/esm/version.d.ts +1 -1
  43. package/dist/esm/version.js +1 -1
  44. package/package.json +1 -1
@@ -1,4 +1,7 @@
1
1
  import { logger } from './logger';
2
+ function redactParams(params) {
3
+ return Object.fromEntries(Object.entries(params).map(([k, v]) => [k, v != null ? '[REDACTED]' : 'null']));
4
+ }
2
5
  function checkPrivacy(capability, auth) {
3
6
  const level = capability.privacy.level;
4
7
  if (level === 'public')
@@ -43,17 +46,17 @@ export async function resolve(matchResult, params = {}, options = {}) {
43
46
  // ── Session param injection ───────────────────────────────────────────────
44
47
  // Inject auth.userId into any params marked as source: 'session'
45
48
  const enrichedParams = { ...params };
46
- if (options.auth?.userId !== undefined) {
49
+ if (options.auth?.userId !== undefined && options.auth.userId !== '') {
47
50
  for (const param of capability.params) {
48
51
  if (param.source === 'session') {
49
52
  enrichedParams[param.name] = options.auth.userId;
50
- logger.debug(`Injected session param "${param.name}" = "${options.auth.userId}"`);
53
+ logger.debug(`Injected session param "${param.name}" (value redacted)`);
51
54
  }
52
55
  }
53
56
  }
54
57
  const resolver = capability.resolver;
55
58
  logger.info(`Resolving capability "${capability.id}" via ${resolver.type} resolver`);
56
- logger.debug(`Params: ${JSON.stringify(params)}`);
59
+ logger.debug(`Params: ${JSON.stringify(redactParams(params))}`);
57
60
  logger.debug(`Options: baseUrl=${options.baseUrl} dryRun=${options.dryRun}`);
58
61
  try {
59
62
  switch (resolver.type) {
@@ -169,12 +172,20 @@ async function resolveApi(resolver, params, options) {
169
172
  };
170
173
  }
171
174
  }
175
+ function validateNavParam(key, value) {
176
+ if (!/^[a-zA-Z0-9_\-]+$/.test(value)) {
177
+ throw new Error(`Nav param "${key}" contains invalid characters: "${value}". ` +
178
+ `Only alphanumeric, hyphens, and underscores are allowed.`);
179
+ }
180
+ }
172
181
  function resolveNav(resolver, params) {
173
182
  let destination = resolver.destination;
174
183
  for (const [key, value] of Object.entries(params)) {
175
184
  if (value === null || value === undefined)
176
185
  continue;
177
- destination = destination.replace(`{${key}}`, encodeURIComponent(String(value)));
186
+ const str = String(value);
187
+ validateNavParam(key, str);
188
+ destination = destination.replace(`{${key}}`, encodeURIComponent(str));
178
189
  }
179
190
  return { success: true, resolverType: 'nav', navTarget: destination };
180
191
  }
@@ -1 +1 @@
1
- export declare const VERSION = "0.4.4";
1
+ export declare const VERSION = "0.5.0";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/version.js — do not edit manually
2
- export const VERSION = '0.4.4';
2
+ export const VERSION = '0.5.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capman",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
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",