@supernal/interface 1.0.2 → 1.0.4

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 (144) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/cjs/src/background/location/LocationContext.js +159 -0
  4. package/dist/cjs/src/background/location/LocationContext.js.map +1 -0
  5. package/dist/cjs/src/background/navigation/ContentResolver.js +37 -0
  6. package/dist/cjs/src/background/navigation/ContentResolver.js.map +1 -0
  7. package/dist/cjs/src/background/navigation/NavigationGraph.js +125 -11
  8. package/dist/cjs/src/background/navigation/NavigationGraph.js.map +1 -1
  9. package/dist/cjs/src/background/registry/ToolRegistry.js +98 -0
  10. package/dist/cjs/src/background/registry/ToolRegistry.js.map +1 -1
  11. package/dist/cjs/src/browser.js.map +1 -1
  12. package/dist/cjs/src/decorators/Component.js +30 -19
  13. package/dist/cjs/src/decorators/Component.js.map +1 -1
  14. package/dist/cjs/src/decorators/LocationScope.js +65 -0
  15. package/dist/cjs/src/decorators/LocationScope.js.map +1 -0
  16. package/dist/cjs/src/decorators/Tool.js +14 -1
  17. package/dist/cjs/src/decorators/Tool.js.map +1 -1
  18. package/dist/cjs/src/decorators/ToolProvider.js +11 -0
  19. package/dist/cjs/src/decorators/ToolProvider.js.map +1 -1
  20. package/dist/cjs/src/decorators/index.js +20 -2
  21. package/dist/cjs/src/decorators/index.js.map +1 -1
  22. package/dist/cjs/src/index.js +14 -3
  23. package/dist/cjs/src/index.js.map +1 -1
  24. package/dist/cjs/src/mcp/index.js +16 -0
  25. package/dist/cjs/src/mcp/index.js.map +1 -0
  26. package/dist/cjs/src/mcp/server.js +281 -0
  27. package/dist/cjs/src/mcp/server.js.map +1 -0
  28. package/dist/cjs/src/mcp/transport.js +131 -0
  29. package/dist/cjs/src/mcp/transport.js.map +1 -0
  30. package/dist/cjs/src/mcp/types.js +23 -0
  31. package/dist/cjs/src/mcp/types.js.map +1 -0
  32. package/dist/cjs/src/mcp-cli.js +55 -0
  33. package/dist/cjs/src/mcp-cli.js.map +1 -0
  34. package/dist/cjs/src/mcp-server.js +17 -0
  35. package/dist/cjs/src/mcp-server.js.map +1 -0
  36. package/dist/cjs/src/react/useNavigationHandler.js +53 -12
  37. package/dist/cjs/src/react/useNavigationHandler.js.map +1 -1
  38. package/dist/cjs/src/react/usePersistedState.js +1 -1
  39. package/dist/cjs/src/react/usePersistedState.js.map +1 -1
  40. package/dist/cjs/src/state/StateSync.js +130 -0
  41. package/dist/cjs/src/state/StateSync.js.map +1 -0
  42. package/dist/cjs/src/storage/LocalStorageAdapter.js +1 -1
  43. package/dist/cjs/src/storage/LocalStorageAdapter.js.map +1 -1
  44. package/dist/cjs/src/storage/StateManager.js +2 -2
  45. package/dist/cjs/src/tools/SystemTools.js +1 -1
  46. package/dist/cjs/src/tools/SystemTools.js.map +1 -1
  47. package/dist/cjs/src/types/StateManagers.js +2 -2
  48. package/dist/cjs/src/types/StateManagers.js.map +1 -1
  49. package/dist/cjs/src/ui/react/chat/ChatBubble.js +3 -3
  50. package/dist/cjs/src/ui/react/chat/ChatBubble.js.map +1 -1
  51. package/dist/esm/src/background/location/LocationContext.d.ts +118 -0
  52. package/dist/esm/src/background/location/LocationContext.d.ts.map +1 -0
  53. package/dist/esm/src/background/location/LocationContext.js +155 -0
  54. package/dist/esm/src/background/location/LocationContext.js.map +1 -0
  55. package/dist/esm/src/background/navigation/ContentResolver.d.ts +139 -0
  56. package/dist/esm/src/background/navigation/ContentResolver.d.ts.map +1 -0
  57. package/dist/esm/src/background/navigation/ContentResolver.js +36 -0
  58. package/dist/esm/src/background/navigation/ContentResolver.js.map +1 -0
  59. package/dist/esm/src/background/navigation/INavigationGraph.d.ts +1 -0
  60. package/dist/esm/src/background/navigation/INavigationGraph.d.ts.map +1 -1
  61. package/dist/esm/src/background/navigation/NavigationGraph.d.ts +24 -0
  62. package/dist/esm/src/background/navigation/NavigationGraph.d.ts.map +1 -1
  63. package/dist/esm/src/background/navigation/NavigationGraph.js +125 -11
  64. package/dist/esm/src/background/navigation/NavigationGraph.js.map +1 -1
  65. package/dist/esm/src/background/registry/ToolRegistry.d.ts +48 -0
  66. package/dist/esm/src/background/registry/ToolRegistry.d.ts.map +1 -1
  67. package/dist/esm/src/background/registry/ToolRegistry.js +98 -0
  68. package/dist/esm/src/background/registry/ToolRegistry.js.map +1 -1
  69. package/dist/esm/src/browser.d.ts +1 -0
  70. package/dist/esm/src/browser.d.ts.map +1 -1
  71. package/dist/esm/src/browser.js.map +1 -1
  72. package/dist/esm/src/decorators/Component.d.ts.map +1 -1
  73. package/dist/esm/src/decorators/Component.js +30 -19
  74. package/dist/esm/src/decorators/Component.js.map +1 -1
  75. package/dist/esm/src/decorators/LocationScope.d.ts +49 -0
  76. package/dist/esm/src/decorators/LocationScope.d.ts.map +1 -0
  77. package/dist/esm/src/decorators/LocationScope.js +60 -0
  78. package/dist/esm/src/decorators/LocationScope.js.map +1 -0
  79. package/dist/esm/src/decorators/Tool.d.ts +3 -1
  80. package/dist/esm/src/decorators/Tool.d.ts.map +1 -1
  81. package/dist/esm/src/decorators/Tool.js +14 -1
  82. package/dist/esm/src/decorators/Tool.js.map +1 -1
  83. package/dist/esm/src/decorators/ToolProvider.d.ts +11 -0
  84. package/dist/esm/src/decorators/ToolProvider.d.ts.map +1 -1
  85. package/dist/esm/src/decorators/ToolProvider.js +10 -0
  86. package/dist/esm/src/decorators/ToolProvider.js.map +1 -1
  87. package/dist/esm/src/decorators/index.d.ts +19 -1
  88. package/dist/esm/src/decorators/index.d.ts.map +1 -1
  89. package/dist/esm/src/decorators/index.js +19 -1
  90. package/dist/esm/src/decorators/index.js.map +1 -1
  91. package/dist/esm/src/index.d.ts +5 -2
  92. package/dist/esm/src/index.d.ts.map +1 -1
  93. package/dist/esm/src/index.js +6 -2
  94. package/dist/esm/src/index.js.map +1 -1
  95. package/dist/esm/src/mcp/index.d.ts +10 -0
  96. package/dist/esm/src/mcp/index.d.ts.map +1 -0
  97. package/dist/esm/src/mcp/index.js +9 -0
  98. package/dist/esm/src/mcp/index.js.map +1 -0
  99. package/dist/esm/src/mcp/server.d.ts +84 -0
  100. package/dist/esm/src/mcp/server.d.ts.map +1 -0
  101. package/dist/esm/src/mcp/server.js +276 -0
  102. package/dist/esm/src/mcp/server.js.map +1 -0
  103. package/dist/esm/src/mcp/transport.d.ts +53 -0
  104. package/dist/esm/src/mcp/transport.d.ts.map +1 -0
  105. package/dist/esm/src/mcp/transport.js +126 -0
  106. package/dist/esm/src/mcp/transport.js.map +1 -0
  107. package/dist/esm/src/mcp/types.d.ts +175 -0
  108. package/dist/esm/src/mcp/types.d.ts.map +1 -0
  109. package/dist/esm/src/mcp/types.js +20 -0
  110. package/dist/esm/src/mcp/types.js.map +1 -0
  111. package/dist/esm/src/mcp-cli.d.ts +25 -0
  112. package/dist/esm/src/mcp-cli.d.ts.map +1 -0
  113. package/dist/esm/src/mcp-cli.js +53 -0
  114. package/dist/esm/src/mcp-cli.js.map +1 -0
  115. package/dist/esm/src/mcp-server.d.ts +10 -0
  116. package/dist/esm/src/mcp-server.d.ts.map +1 -0
  117. package/dist/esm/src/mcp-server.js +10 -0
  118. package/dist/esm/src/mcp-server.js.map +1 -0
  119. package/dist/esm/src/react/useNavigationHandler.d.ts +29 -11
  120. package/dist/esm/src/react/useNavigationHandler.d.ts.map +1 -1
  121. package/dist/esm/src/react/useNavigationHandler.js +53 -12
  122. package/dist/esm/src/react/useNavigationHandler.js.map +1 -1
  123. package/dist/esm/src/react/usePersistedState.js +1 -1
  124. package/dist/esm/src/react/usePersistedState.js.map +1 -1
  125. package/dist/esm/src/state/StateSync.d.ts +57 -0
  126. package/dist/esm/src/state/StateSync.d.ts.map +1 -0
  127. package/dist/esm/src/state/StateSync.js +123 -0
  128. package/dist/esm/src/state/StateSync.js.map +1 -0
  129. package/dist/esm/src/storage/LocalStorageAdapter.d.ts.map +1 -1
  130. package/dist/esm/src/storage/LocalStorageAdapter.js +1 -1
  131. package/dist/esm/src/storage/LocalStorageAdapter.js.map +1 -1
  132. package/dist/esm/src/storage/StateManager.d.ts +2 -2
  133. package/dist/esm/src/storage/StateManager.js +2 -2
  134. package/dist/esm/src/tools/SystemTools.js +1 -1
  135. package/dist/esm/src/tools/SystemTools.js.map +1 -1
  136. package/dist/esm/src/types/StateManagers.d.ts +2 -2
  137. package/dist/esm/src/types/StateManagers.d.ts.map +1 -1
  138. package/dist/esm/src/types/StateManagers.js +2 -2
  139. package/dist/esm/src/types/StateManagers.js.map +1 -1
  140. package/dist/esm/src/ui/react/chat/ChatBubble.d.ts +4 -0
  141. package/dist/esm/src/ui/react/chat/ChatBubble.d.ts.map +1 -1
  142. package/dist/esm/src/ui/react/chat/ChatBubble.js +3 -3
  143. package/dist/esm/src/ui/react/chat/ChatBubble.js.map +1 -1
  144. package/package.json +9 -17
@@ -0,0 +1,139 @@
1
+ /**
2
+ * ContentResolver - Interface for content-aware navigation
3
+ *
4
+ * Enables fuzzy navigation within a context by providing searchable content.
5
+ * When a user says "open blog contracts", the ContentResolver fetches blog posts,
6
+ * searches them, and returns the best match for navigation.
7
+ *
8
+ * Separation of Concerns:
9
+ * - NavigationGraph: Knows routes and contexts
10
+ * - ContentResolver: Knows how to search content within a context (pluggable)
11
+ * - FuzzyMatcher: Generic string matching (reused)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Register blog context with content resolver
16
+ * NavigationGraph.getInstance().registerContext({
17
+ * id: 'blog',
18
+ * name: 'Blog',
19
+ * metadata: {
20
+ * route: '/blog',
21
+ * contentResolver: {
22
+ * fetch: () => fetch('/api/blog-posts').then(r => r.json()),
23
+ * searchFields: (post) => [post.title, post.slug, ...post.tags],
24
+ * toRoute: (post) => `/blog/${post.slug}`,
25
+ * toDisplay: (post) => ({ title: post.title, description: post.excerpt }),
26
+ * }
27
+ * }
28
+ * });
29
+ *
30
+ * // Auto-generates tool that handles:
31
+ * // - "go to blog" → /blog
32
+ * // - "open blog contracts" → fuzzy search → /blog/matching-post
33
+ * ```
34
+ */
35
+ /**
36
+ * Content item display info for suggestions
37
+ */
38
+ export interface ContentDisplayInfo {
39
+ /** Title to show in suggestions */
40
+ title: string;
41
+ /** Optional description/excerpt */
42
+ description?: string;
43
+ }
44
+ /**
45
+ * ContentResolver interface for fuzzy navigation within a context
46
+ *
47
+ * @template T - Type of content items (e.g., BlogPost, Product, User)
48
+ */
49
+ export interface ContentResolver<T = any> {
50
+ /**
51
+ * Fetch searchable content
52
+ *
53
+ * This is called when a user searches within this context.
54
+ * Results may be cached by the implementation.
55
+ *
56
+ * @returns Promise resolving to array of content items
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * fetch: () => fetch('/api/blog-posts').then(r => r.json())
61
+ * fetch: async () => db.products.findMany()
62
+ * ```
63
+ */
64
+ fetch: () => Promise<T[]>;
65
+ /**
66
+ * Extract searchable fields from an item
67
+ *
68
+ * Returns strings that will be matched against the user's query.
69
+ * Order matters - first fields are weighted higher.
70
+ *
71
+ * @param item - Content item
72
+ * @returns Array of searchable strings
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * searchFields: (post) => [post.title, post.slug, ...post.tags]
77
+ * searchFields: (product) => [product.name, product.sku, product.brand]
78
+ * ```
79
+ */
80
+ searchFields: (item: T) => string[];
81
+ /**
82
+ * Convert matched item to a navigation route
83
+ *
84
+ * @param item - Matched content item
85
+ * @returns Route path to navigate to
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * toRoute: (post) => `/blog/${post.slug}`
90
+ * toRoute: (product) => `/products/${product.id}`
91
+ * ```
92
+ */
93
+ toRoute: (item: T) => string;
94
+ /**
95
+ * Optional: Custom display info for suggestions
96
+ *
97
+ * Used when showing "Did you mean..." suggestions.
98
+ * If not provided, route path is used as title.
99
+ *
100
+ * @param item - Content item
101
+ * @returns Display info for UI
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * toDisplay: (post) => ({ title: post.title, description: post.excerpt })
106
+ * toDisplay: (product) => ({ title: product.name, description: `$${product.price}` })
107
+ * ```
108
+ */
109
+ toDisplay?: (item: T) => ContentDisplayInfo;
110
+ }
111
+ /**
112
+ * Result of a content-aware navigation
113
+ */
114
+ export interface ContentNavigationResult<T = any> {
115
+ /** Whether navigation was successful */
116
+ success: boolean;
117
+ /** Human-readable message */
118
+ message: string;
119
+ /** The matched item (if any) */
120
+ item?: T;
121
+ /** Suggestions if no exact match found */
122
+ suggestions?: ContentDisplayInfo[];
123
+ }
124
+ /**
125
+ * Navigation context extended with optional content resolver
126
+ */
127
+ export interface NavigationContextMetadata {
128
+ /** Route path for this context */
129
+ route?: string;
130
+ /** Content resolver for fuzzy navigation */
131
+ contentResolver?: ContentResolver;
132
+ /** Whether this context was auto-created */
133
+ autoCreated?: boolean;
134
+ /** Context type (page, modal, etc.) */
135
+ type?: string;
136
+ /** Additional metadata */
137
+ [key: string]: any;
138
+ }
139
+ //# sourceMappingURL=ContentResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentResolver.d.ts","sourceRoot":"","sources":["../../../../../src/background/navigation/ContentResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACtC;;;;;;;;;;;;;OAaG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAE1B;;;;;;;;;;;;;;OAcG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAAE,CAAC;IAEpC;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAE7B;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,kBAAkB,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,GAAG;IAC9C,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,0CAA0C;IAC1C,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ContentResolver - Interface for content-aware navigation
3
+ *
4
+ * Enables fuzzy navigation within a context by providing searchable content.
5
+ * When a user says "open blog contracts", the ContentResolver fetches blog posts,
6
+ * searches them, and returns the best match for navigation.
7
+ *
8
+ * Separation of Concerns:
9
+ * - NavigationGraph: Knows routes and contexts
10
+ * - ContentResolver: Knows how to search content within a context (pluggable)
11
+ * - FuzzyMatcher: Generic string matching (reused)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Register blog context with content resolver
16
+ * NavigationGraph.getInstance().registerContext({
17
+ * id: 'blog',
18
+ * name: 'Blog',
19
+ * metadata: {
20
+ * route: '/blog',
21
+ * contentResolver: {
22
+ * fetch: () => fetch('/api/blog-posts').then(r => r.json()),
23
+ * searchFields: (post) => [post.title, post.slug, ...post.tags],
24
+ * toRoute: (post) => `/blog/${post.slug}`,
25
+ * toDisplay: (post) => ({ title: post.title, description: post.excerpt }),
26
+ * }
27
+ * }
28
+ * });
29
+ *
30
+ * // Auto-generates tool that handles:
31
+ * // - "go to blog" → /blog
32
+ * // - "open blog contracts" → fuzzy search → /blog/matching-post
33
+ * ```
34
+ */
35
+ export {};
36
+ //# sourceMappingURL=ContentResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentResolver.js","sourceRoot":"","sources":["../../../../../src/background/navigation/ContentResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
@@ -43,6 +43,7 @@ export interface INavigationGraph {
43
43
  getAllEdges?(): any[];
44
44
  registerToolInContext(toolId: string, contextId?: string, extra?: unknown): void;
45
45
  getToolContext?(toolId: string): string | null;
46
+ navigate?(path: string | RouteInfo): void;
46
47
  navigateToContext?(contextId: string): Promise<boolean>;
47
48
  trackComponent?(id: string, parent?: string): void;
48
49
  getTree?(): NavigationNode[];
@@ -1 +1 @@
1
- {"version":3,"file":"INavigationGraph.d.ts","sourceRoot":"","sources":["../../../../../src/background/navigation/INavigationGraph.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC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AAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACjF,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAG/C,iBAAiB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAGxD,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,OAAO,CAAC,IAAI,cAAc,EAAE,CAAC;IAC7B,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAGjD,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,cAAc,CAAC,IAAI,IAAI,CAAC;IAGxB,SAAS,CAAC,IAAI,MAAM,CAAC;IACrB,MAAM,CAAC,IAAI,GAAG,CAAC;CAChB"}
1
+ {"version":3,"file":"INavigationGraph.d.ts","sourceRoot":"","sources":["../../../../../src/background/navigation/INavigationGraph.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM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AAE,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACjF,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAG/C,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAGxD,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,OAAO,CAAC,IAAI,cAAc,EAAE,CAAC;IAC7B,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAGjD,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,cAAc,CAAC,IAAI,IAAI,CAAC;IAGxB,SAAS,CAAC,IAAI,MAAM,CAAC;IACrB,MAAM,CAAC,IAAI,GAAG,CAAC;CAChB"}
@@ -4,6 +4,9 @@
4
4
  * This is a stub implementation for the open source edition.
5
5
  * Full runtime navigation tracking available in @supernal/interface-enterprise.
6
6
  *
7
+ * Context tracking is unified with LocationContext - NavigationGraph delegates
8
+ * to LocationContext for the single source of truth about current location.
9
+ *
7
10
  * Visit https://supernal.ai/enterprise for more information.
8
11
  */
9
12
  import { INavigationGraph, NavigationNode, RouteInfo, ContextData } from './INavigationGraph';
@@ -17,7 +20,17 @@ export { NavigationNode, RouteInfo, ContextData } from './INavigationGraph';
17
20
  export declare class NavigationGraph implements INavigationGraph {
18
21
  private static instance;
19
22
  private warned;
23
+ private currentContext;
24
+ private contextTools;
25
+ private navigationHandler;
26
+ private contextListeners;
27
+ private locationUnsubscribe;
20
28
  private warnOnce;
29
+ /**
30
+ * Set up synchronization with LocationContext
31
+ * This ensures NavigationGraph stays in sync when LocationContext changes
32
+ */
33
+ private setupLocationSync;
21
34
  static getInstance(): NavigationGraph;
22
35
  trackComponent(id: string, parent?: string): void;
23
36
  getTree(): NavigationNode[];
@@ -29,8 +42,19 @@ export declare class NavigationGraph implements INavigationGraph {
29
42
  registerToolInContext(toolId: string, contextId?: string, extra?: unknown): void;
30
43
  getRouteByName(name: string): RouteInfo | undefined;
31
44
  setCurrentContext(contextId: string | RouteInfo): void;
45
+ /**
46
+ * Subscribe to context changes
47
+ * @param fn Callback invoked when context changes
48
+ * @returns Unsubscribe function
49
+ */
50
+ onContextChange(fn: (ctx: string) => void): () => void;
32
51
  setNavigationHandler(handler: (path: string | RouteInfo) => void | Promise<void>): void;
33
52
  getNavigationHandler(): ((pageName: string) => void | Promise<void>) | null;
53
+ /**
54
+ * Navigate to a path using the registered navigation handler
55
+ * This is the method tools should call to trigger navigation
56
+ */
57
+ navigate(path: string | RouteInfo): void;
34
58
  navigateToContext(contextId: string): Promise<boolean>;
35
59
  getRouteForContext(contextId: string): string | undefined;
36
60
  getAllRoutes(): Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationGraph.d.ts","sourceRoot":"","sources":["../../../../../src/background/navigation/NavigationGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG9F,QAAA,MAAM,oBAAoB,kCAAkC,CAAC;AAG7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,CAAC,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,CAAC;KAC3C;CACF;AAED,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5E,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;IACvD,OAAO,CAAC,MAAM,CAAS;IAEvB,OAA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cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAK7C,KAAK,IAAI,IAAI;IAIb,cAAc,IAAI,IAAI;IAItB,SAAS,IAAI,MAAM;IAKnB,MAAM,IAAI,GAAG;CAId"}
@@ -4,27 +4,68 @@
4
4
  * This is a stub implementation for the open source edition.
5
5
  * Full runtime navigation tracking available in @supernal/interface-enterprise.
6
6
  *
7
+ * Context tracking is unified with LocationContext - NavigationGraph delegates
8
+ * to LocationContext for the single source of truth about current location.
9
+ *
7
10
  * Visit https://supernal.ai/enterprise for more information.
8
11
  */
12
+ // Lazy getter for LocationContext to avoid circular dependency at module load
13
+ function getLocationContext() {
14
+ return require('../location/LocationContext').LocationContext;
15
+ }
9
16
  // Global singleton key to ensure cross-package singleton behavior
10
17
  const GLOBAL_SINGLETON_KEY = '__SUPERNAL_NAVIGATION_GRAPH__';
11
18
  export class NavigationGraph {
12
19
  constructor() {
13
20
  this.warned = false;
21
+ this.contextTools = new Map(); // toolId -> contextId
22
+ this.navigationHandler = null;
23
+ // Context change listeners
24
+ this.contextListeners = new Set();
25
+ this.locationUnsubscribe = null;
14
26
  }
15
27
  warnOnce() {
16
28
  if (!this.warned && typeof console !== 'undefined') {
17
- console.warn('⚠️ NavigationGraph is an enterprise feature. ' +
29
+ console.warn('⚠️ Advanced NavigationGraph features are enterprise-only. ' +
18
30
  'Full runtime tracking available at https://supernal.ai/enterprise');
19
31
  this.warned = true;
20
32
  }
21
33
  }
34
+ /**
35
+ * Set up synchronization with LocationContext
36
+ * This ensures NavigationGraph stays in sync when LocationContext changes
37
+ */
38
+ setupLocationSync() {
39
+ if (this.locationUnsubscribe)
40
+ return; // Already set up
41
+ try {
42
+ const LocationContext = getLocationContext();
43
+ this.locationUnsubscribe = LocationContext.onLocationChange((old, newLoc) => {
44
+ const ctx = newLoc.page || 'global';
45
+ this.currentContext = ctx; // Keep in sync
46
+ this.contextListeners.forEach(fn => {
47
+ try {
48
+ fn(ctx);
49
+ }
50
+ catch (e) {
51
+ console.error('[NavigationGraph] Context listener error:', e);
52
+ }
53
+ });
54
+ });
55
+ }
56
+ catch (e) {
57
+ // LocationContext may not be available in all environments
58
+ console.warn('[NavigationGraph] Could not set up LocationContext sync:', e);
59
+ }
60
+ }
22
61
  static getInstance() {
23
62
  // Check global singleton first (browser environment)
24
63
  // If enterprise version already created a singleton, use that!
25
64
  if (typeof window !== 'undefined') {
26
65
  if (!window[GLOBAL_SINGLETON_KEY]) {
27
- window[GLOBAL_SINGLETON_KEY] = new NavigationGraph();
66
+ const instance = new NavigationGraph();
67
+ window[GLOBAL_SINGLETON_KEY] = instance;
68
+ instance.setupLocationSync();
28
69
  console.log('🌍 [NavigationGraph] Created GLOBAL singleton instance (open-source stub)');
29
70
  }
30
71
  return window[GLOBAL_SINGLETON_KEY];
@@ -32,6 +73,7 @@ export class NavigationGraph {
32
73
  // Fallback to module-level singleton (Node.js/SSR environment)
33
74
  if (!this.instance) {
34
75
  this.instance = new NavigationGraph();
76
+ this.instance.setupLocationSync();
35
77
  }
36
78
  return this.instance;
37
79
  }
@@ -62,21 +104,82 @@ export class NavigationGraph {
62
104
  return { id, tools: [] };
63
105
  }
64
106
  registerToolInContext(toolId, contextId, extra) {
65
- this.warnOnce();
107
+ // Basic implementation: store tool-to-context mapping
108
+ if (contextId) {
109
+ this.contextTools.set(toolId, contextId);
110
+ }
66
111
  }
67
112
  getRouteByName(name) {
68
113
  this.warnOnce();
69
114
  return undefined;
70
115
  }
71
116
  setCurrentContext(contextId) {
72
- this.warnOnce();
117
+ // Extract context ID from string or RouteInfo
118
+ let id;
119
+ if (typeof contextId === 'string') {
120
+ id = contextId;
121
+ }
122
+ else if (contextId && typeof contextId === 'object' && 'path' in contextId && contextId.path) {
123
+ id = contextId.path;
124
+ }
125
+ else {
126
+ id = 'global';
127
+ }
128
+ // Update LocationContext (single source of truth)
129
+ try {
130
+ const LocationContext = getLocationContext();
131
+ LocationContext.setCurrent({
132
+ page: id,
133
+ route: id,
134
+ });
135
+ }
136
+ catch (e) {
137
+ // LocationContext may not be available in all environments
138
+ }
139
+ // Keep local state for backward compat (redundant but safe)
140
+ this.currentContext = id;
141
+ // Notify listeners
142
+ this.contextListeners.forEach(fn => {
143
+ try {
144
+ fn(id);
145
+ }
146
+ catch (e) {
147
+ console.error('[NavigationGraph] Context listener error:', e);
148
+ }
149
+ });
150
+ }
151
+ /**
152
+ * Subscribe to context changes
153
+ * @param fn Callback invoked when context changes
154
+ * @returns Unsubscribe function
155
+ */
156
+ onContextChange(fn) {
157
+ this.contextListeners.add(fn);
158
+ return () => this.contextListeners.delete(fn);
73
159
  }
74
160
  setNavigationHandler(handler) {
75
- this.warnOnce();
161
+ this.navigationHandler = handler;
76
162
  }
77
163
  getNavigationHandler() {
78
- this.warnOnce();
79
- return null;
164
+ return this.navigationHandler;
165
+ }
166
+ /**
167
+ * Navigate to a path using the registered navigation handler
168
+ * This is the method tools should call to trigger navigation
169
+ */
170
+ navigate(path) {
171
+ if (this.navigationHandler) {
172
+ const result = this.navigationHandler(path);
173
+ // Handle async handlers
174
+ if (result && typeof result.then === 'function') {
175
+ result.catch((error) => {
176
+ console.error('[NavigationGraph] Navigation failed:', error);
177
+ });
178
+ }
179
+ }
180
+ else {
181
+ console.warn('[NavigationGraph] No navigation handler registered. Call setNavigationHandler() first.');
182
+ }
80
183
  }
81
184
  async navigateToContext(contextId) {
82
185
  this.warnOnce();
@@ -91,8 +194,19 @@ export class NavigationGraph {
91
194
  return {};
92
195
  }
93
196
  getCurrentContext() {
94
- this.warnOnce();
95
- return 'global';
197
+ // Read from LocationContext as authoritative source
198
+ try {
199
+ const LocationContext = getLocationContext();
200
+ const location = LocationContext.getCurrent();
201
+ if (location?.page) {
202
+ return location.page;
203
+ }
204
+ }
205
+ catch (e) {
206
+ // LocationContext may not be available in all environments
207
+ }
208
+ // Fallback to local state or 'global' as default
209
+ return this.currentContext !== undefined ? this.currentContext : 'global';
96
210
  }
97
211
  getAllContexts() {
98
212
  this.warnOnce();
@@ -103,8 +217,8 @@ export class NavigationGraph {
103
217
  return [];
104
218
  }
105
219
  getToolContext(toolId) {
106
- this.warnOnce();
107
- return null;
220
+ // Return the context for a tool, or null if not registered (matches interface)
221
+ return this.contextTools.get(toolId) || null;
108
222
  }
109
223
  clear() {
110
224
  this.warnOnce();
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationGraph.js","sourceRoot":"","sources":["../../../../../src/background/navigation/NavigationGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAW7D,MAAM,OAAO,eAAe;IAA5B;QAEU,WAAM,GAAG,KAAK,CAAC;IAyIzB,CAAC;IAvIS,QAAQ;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACnD,OAAO,CAAC,IAAI,CACV,gDAAgD;gBAChD,mEAAmE,CACpE,CAAC;YACF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,qDAAqD;QACrD,+DAA+D;QAC/D,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBAClC,MAAM,CAAC,oBAAoB,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC;gBACrD,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;YAC3F,CAAC;YACD,OAAO,MAAM,CAAC,oBAAoB,CAAoB,CAAC;QACzD,CAAC;QAED,+DAA+D;QAC/D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,uCAAuC;IACvC,cAAc,CAAC,EAAU,EA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,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,YAAY;QACV,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,WAAW;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,cAAc,CAAC,MAAc;QAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;;AAzIc,wBAAQ,GAA2B,IAAI,AAA/B,CAAgC"}
1
+ {"version":3,"file":"NavigationGraph.js","sourceRoot":"","sources":["../../../../../src/background/navigation/NavigationGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,8EAA8E;AAC9E,SAAS,kBAAkB;IACzB,OAAO,OAAO,CAAC,6BAA6B,CAAC,CAAC,eAAe,CAAC;AAChE,CAAC;AAED,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAW7D,MAAM,OAAO,eAAe;IAA5B;QAEU,WAAM,GAAG,KAAK,CAAC;QAIf,iBAAY,GAAwB,IAAI,GAAG,EAA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CAAC;YACH,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;YAC7C,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,EAAE,CAAC;YAC9C,IAAI,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,2DAA2D;QAC7D,CAAC;QAED,iDAAiD;QACjD,OAAO,IAAI,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC5E,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,WAAW;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,cAAc,CAAC,MAAc;QAC3B,+EAA+E;QAC/E,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAC/C,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;;AAzPc,wBAAQ,GAA2B,IAAI,AAA/B,CAAgC"}
@@ -228,5 +228,53 @@ export declare class ToolRegistry {
228
228
  * }
229
229
  */
230
230
  static getToolsGroupedByComponentAndContainer(): Record<string, Record<string, ToolMetadata[]>>;
231
+ /**
232
+ * Get tools filtered by current location
233
+ *
234
+ * Uses LocationContext to filter tools based on their @LocationScope decorators.
235
+ * Returns only tools that are available at the current location.
236
+ *
237
+ * @param location - Optional location to check against (defaults to LocationContext.getCurrent())
238
+ * @returns Array of tools available at the specified location
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * // Get tools available at current location
243
+ * const tools = ToolRegistry.getToolsByLocation();
244
+ *
245
+ * // Get tools for specific location
246
+ * const blogTools = ToolRegistry.getToolsByLocation({
247
+ * page: '/blog',
248
+ * components: ['blog-editor']
249
+ * });
250
+ * ```
251
+ */
252
+ static getToolsByLocation(location?: import('../location/LocationContext').AppLocation | null): ToolMetadata[];
253
+ /**
254
+ * Get tools for a specific context ID
255
+ *
256
+ * Convenience method that wraps getToolsByLocation with a simple context string.
257
+ *
258
+ * @param contextId - Context ID (e.g., '/blog', '/examples')
259
+ * @returns Tools available in that context
260
+ */
261
+ static getToolsForContext(contextId: string): ToolMetadata[];
262
+ /**
263
+ * Get tools for the current context
264
+ *
265
+ * Reads current location from LocationContext and returns matching tools.
266
+ *
267
+ * @returns Tools available at current location
268
+ */
269
+ static getToolsForCurrentContext(): ToolMetadata[];
270
+ /**
271
+ * Get tools grouped by container, filtered by location
272
+ *
273
+ * Combines location filtering with container grouping.
274
+ *
275
+ * @param location - Optional location to filter by
276
+ * @returns Tools grouped by container, filtered by location
277
+ */
278
+ static getToolsGroupedByContainerForLocation(location?: import('../location/LocationContext').AppLocation | null): Record<string, ToolMetadata[]>;
231
279
  }
232
280
  //# sourceMappingURL=ToolRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToolRegistry.d.ts","sourceRoot":"","sources":["../../../../../src/background/registry/ToolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,GAAG,CAAC;IAChB,MAAM,CAAC,EAAE,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,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAQtH;;OAEG;IACH,MAAM,CAAC,qBAAqB,IAAI,MAAM;IA6BtC;;OAEG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAKpB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,0BAA0B,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;IAgBnE;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,sCAAsC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAqB/F;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,OAAO,6BAA6B,EAAE,WAAW,GAAG,IAAI,GAAG,YAAY,EAAE;IAuC9G;;;;;;;OAOG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE;IAI5D;;;;;;OAMG;IACH,MAAM,CAAC,yBAAyB,IAAI,YAAY,EAAE;IAKlD;;;;;;;OAOG;IACH,MAAM,CAAC,qCAAqC,CAC1C,QAAQ,CAAC,EAAE,OAAO,6BAA6B,EAAE,WAAW,GAAG,IAAI,GAClE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;CAgBlC"}
@@ -660,5 +660,103 @@ export class ToolRegistry {
660
660
  }
661
661
  return grouped;
662
662
  }
663
+ /**
664
+ * Get tools filtered by current location
665
+ *
666
+ * Uses LocationContext to filter tools based on their @LocationScope decorators.
667
+ * Returns only tools that are available at the current location.
668
+ *
669
+ * @param location - Optional location to check against (defaults to LocationContext.getCurrent())
670
+ * @returns Array of tools available at the specified location
671
+ *
672
+ * @example
673
+ * ```typescript
674
+ * // Get tools available at current location
675
+ * const tools = ToolRegistry.getToolsByLocation();
676
+ *
677
+ * // Get tools for specific location
678
+ * const blogTools = ToolRegistry.getToolsByLocation({
679
+ * page: '/blog',
680
+ * components: ['blog-editor']
681
+ * });
682
+ * ```
683
+ */
684
+ static getToolsByLocation(location) {
685
+ // Lazy import to avoid circular dependencies
686
+ const { LocationContext } = require('../location/LocationContext');
687
+ const currentLocation = location !== undefined ? location : LocationContext.getCurrent();
688
+ return Array.from(this.tools.values()).filter(tool => {
689
+ // Check 1: LocationScope decorator (rich matching)
690
+ if (tool.locationScope) {
691
+ return LocationContext.matchesScope(tool.locationScope, currentLocation);
692
+ }
693
+ // Check 2: containerId-based scoping (unified with LocationScope)
694
+ if (tool.containerId) {
695
+ // Global container tools are always available
696
+ if (tool.containerId === 'global')
697
+ return true;
698
+ // Only treat containerId as scoping if it looks like a route (starts with /)
699
+ // Non-route containerIds (like 'TestContainer') are for grouping only, not scoping
700
+ if (!tool.containerId.startsWith('/'))
701
+ return true;
702
+ // No location set = global context, only global tools available
703
+ if (!currentLocation)
704
+ return false;
705
+ // Match containerId against current page/route
706
+ const currentPage = currentLocation.page || currentLocation.route || '';
707
+ // Exact match or hierarchical match (e.g., containerId='/blog' matches page='/blog/post')
708
+ return currentPage === tool.containerId ||
709
+ currentPage.startsWith(tool.containerId + '/') ||
710
+ currentPage.startsWith('/' + tool.containerId) ||
711
+ currentPage === '/' + tool.containerId;
712
+ }
713
+ // No scope defined = available everywhere (global)
714
+ return true;
715
+ });
716
+ }
717
+ /**
718
+ * Get tools for a specific context ID
719
+ *
720
+ * Convenience method that wraps getToolsByLocation with a simple context string.
721
+ *
722
+ * @param contextId - Context ID (e.g., '/blog', '/examples')
723
+ * @returns Tools available in that context
724
+ */
725
+ static getToolsForContext(contextId) {
726
+ return this.getToolsByLocation({ page: contextId, route: contextId });
727
+ }
728
+ /**
729
+ * Get tools for the current context
730
+ *
731
+ * Reads current location from LocationContext and returns matching tools.
732
+ *
733
+ * @returns Tools available at current location
734
+ */
735
+ static getToolsForCurrentContext() {
736
+ const { LocationContext } = require('../location/LocationContext');
737
+ return this.getToolsByLocation(LocationContext.getCurrent());
738
+ }
739
+ /**
740
+ * Get tools grouped by container, filtered by location
741
+ *
742
+ * Combines location filtering with container grouping.
743
+ *
744
+ * @param location - Optional location to filter by
745
+ * @returns Tools grouped by container, filtered by location
746
+ */
747
+ static getToolsGroupedByContainerForLocation(location) {
748
+ const tools = this.getToolsByLocation(location);
749
+ const grouped = {
750
+ global: [],
751
+ };
752
+ for (const tool of tools) {
753
+ const container = tool.containerId || 'global';
754
+ if (!grouped[container]) {
755
+ grouped[container] = [];
756
+ }
757
+ grouped[container].push(tool);
758
+ }
759
+ return grouped;
760
+ }
663
761
  }
664
762
  //# sourceMappingURL=ToolRegistry.js.map