@superblocksteam/vite-plugin-file-sync 2.0.51 → 2.0.52-next.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 (214) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +36 -7
  3. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  4. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +28 -3
  5. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -1
  6. package/dist/ai-service/agent/subagents/apis/generate-api-source.js +102 -8
  7. package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -1
  8. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +1 -1
  9. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +2 -2
  10. package/dist/ai-service/agent/subagents/apis/state.d.ts +10 -0
  11. package/dist/ai-service/agent/subagents/apis/state.d.ts.map +1 -1
  12. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +1 -1
  13. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -1
  14. package/dist/ai-service/agent/subagents/apis/system-prompt.js +294 -5
  15. package/dist/ai-service/agent/subagents/apis/system-prompt.js.map +1 -1
  16. package/dist/ai-service/agent/tools/apis/build-api.d.ts +2 -0
  17. package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -1
  18. package/dist/ai-service/agent/tools/apis/build-api.js +96 -13
  19. package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -1
  20. package/dist/ai-service/agent/tools/apis/finalize-api.d.ts.map +1 -1
  21. package/dist/ai-service/agent/tools/apis/finalize-api.js +13 -4
  22. package/dist/ai-service/agent/tools/apis/finalize-api.js.map +1 -1
  23. package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -1
  24. package/dist/ai-service/agent/tools/build-debug.js +64 -2
  25. package/dist/ai-service/agent/tools/build-debug.js.map +1 -1
  26. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  27. package/dist/ai-service/agent/tools/build-edit-file.js +12 -0
  28. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  29. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
  30. package/dist/ai-service/agent/tools/build-finalize.js +43 -0
  31. package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
  32. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  33. package/dist/ai-service/agent/tools/build-multi-edit-file.js +6 -0
  34. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  35. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  36. package/dist/ai-service/agent/tools/build-write-file.js +6 -0
  37. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  38. package/dist/ai-service/agent/tools/debug-cache.d.ts +42 -0
  39. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
  40. package/dist/ai-service/agent/tools/debug-cache.js +121 -14
  41. package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
  42. package/dist/ai-service/agent/tools/index.d.ts +1 -0
  43. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  44. package/dist/ai-service/agent/tools/index.js +1 -0
  45. package/dist/ai-service/agent/tools/index.js.map +1 -1
  46. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +9 -5
  47. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  48. package/dist/ai-service/agent/tools/integrations/execute-request.js +105 -7
  49. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  50. package/dist/ai-service/agent/tools/integrations/index.d.ts +1 -1
  51. package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -1
  52. package/dist/ai-service/agent/tools/integrations/index.js +1 -1
  53. package/dist/ai-service/agent/tools/integrations/index.js.map +1 -1
  54. package/dist/ai-service/agent/tools/integrations/metadata.d.ts +0 -4
  55. package/dist/ai-service/agent/tools/integrations/metadata.d.ts.map +1 -1
  56. package/dist/ai-service/agent/tools/integrations/metadata.js +0 -44
  57. package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -1
  58. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  59. package/dist/ai-service/agent/tools.js +45 -10
  60. package/dist/ai-service/agent/tools.js.map +1 -1
  61. package/dist/ai-service/agent/tools2/access-control.d.ts +1 -1
  62. package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
  63. package/dist/ai-service/agent/tools2/access-control.js +13 -5
  64. package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
  65. package/dist/ai-service/agent/tools2/entity-permissions.d.ts +180 -0
  66. package/dist/ai-service/agent/tools2/entity-permissions.d.ts.map +1 -0
  67. package/dist/ai-service/agent/tools2/entity-permissions.js +154 -0
  68. package/dist/ai-service/agent/tools2/entity-permissions.js.map +1 -0
  69. package/dist/ai-service/agent/tools2/example.d.ts.map +1 -1
  70. package/dist/ai-service/agent/tools2/example.js +25 -6
  71. package/dist/ai-service/agent/tools2/example.js.map +1 -1
  72. package/dist/ai-service/agent/tools2/index.d.ts +4 -2
  73. package/dist/ai-service/agent/tools2/index.d.ts.map +1 -1
  74. package/dist/ai-service/agent/tools2/index.js +2 -1
  75. package/dist/ai-service/agent/tools2/index.js.map +1 -1
  76. package/dist/ai-service/agent/tools2/registry.d.ts +47 -0
  77. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
  78. package/dist/ai-service/agent/tools2/registry.js +122 -19
  79. package/dist/ai-service/agent/tools2/registry.js.map +1 -1
  80. package/dist/ai-service/agent/tools2/test-utils.d.ts +7 -0
  81. package/dist/ai-service/agent/tools2/test-utils.d.ts.map +1 -0
  82. package/dist/ai-service/agent/tools2/test-utils.js +10 -0
  83. package/dist/ai-service/agent/tools2/test-utils.js.map +1 -0
  84. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -1
  85. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +17 -9
  86. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -1
  87. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +2 -1
  88. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  89. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +192 -27
  90. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  91. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts +18 -0
  92. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts.map +1 -0
  93. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js +837 -0
  94. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -0
  95. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +96 -0
  96. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -0
  97. package/dist/ai-service/agent/tools2/tools/grep-metadata.js +437 -0
  98. package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -0
  99. package/dist/ai-service/agent/tools2/types.d.ts +113 -6
  100. package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
  101. package/dist/ai-service/agent/tools2/types.js +15 -0
  102. package/dist/ai-service/agent/tools2/types.js.map +1 -1
  103. package/dist/ai-service/agent/tools2/utils.d.ts +9 -0
  104. package/dist/ai-service/agent/tools2/utils.d.ts.map +1 -0
  105. package/dist/ai-service/agent/tools2/utils.js +11 -0
  106. package/dist/ai-service/agent/tools2/utils.js.map +1 -0
  107. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  108. package/dist/ai-service/chat/chat-session-store.js +12 -0
  109. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  110. package/dist/ai-service/const.d.ts +0 -1
  111. package/dist/ai-service/const.d.ts.map +1 -1
  112. package/dist/ai-service/const.js +0 -1
  113. package/dist/ai-service/const.js.map +1 -1
  114. package/dist/ai-service/index.d.ts +11 -0
  115. package/dist/ai-service/index.d.ts.map +1 -1
  116. package/dist/ai-service/index.js +50 -3
  117. package/dist/ai-service/index.js.map +1 -1
  118. package/dist/ai-service/integrations/metadata-storage/index.d.ts +25 -0
  119. package/dist/ai-service/integrations/metadata-storage/index.d.ts.map +1 -0
  120. package/dist/ai-service/integrations/metadata-storage/index.js +2 -0
  121. package/dist/ai-service/integrations/metadata-storage/index.js.map +1 -0
  122. package/dist/ai-service/integrations/metadata-storage/local.d.ts +53 -0
  123. package/dist/ai-service/integrations/metadata-storage/local.d.ts.map +1 -0
  124. package/dist/ai-service/integrations/metadata-storage/local.js +315 -0
  125. package/dist/ai-service/integrations/metadata-storage/local.js.map +1 -0
  126. package/dist/ai-service/integrations/store.d.ts +17 -14
  127. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  128. package/dist/ai-service/integrations/store.js +124 -131
  129. package/dist/ai-service/integrations/store.js.map +1 -1
  130. package/dist/ai-service/llm/utils.js +1 -1
  131. package/dist/ai-service/llm/utils.js.map +1 -1
  132. package/dist/ai-service/llmobs/helpers.d.ts.map +1 -1
  133. package/dist/ai-service/llmobs/helpers.js +17 -23
  134. package/dist/ai-service/llmobs/helpers.js.map +1 -1
  135. package/dist/ai-service/llmobs/middleware/stream-text.d.ts.map +1 -1
  136. package/dist/ai-service/llmobs/middleware/stream-text.js +1 -0
  137. package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
  138. package/dist/ai-service/state-machine/clark-fsm.d.ts +5 -2
  139. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  140. package/dist/ai-service/state-machine/clark-fsm.js +2 -2
  141. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  142. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  143. package/dist/ai-service/state-machine/handlers/agent-planning.js +5 -2
  144. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  145. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  146. package/dist/ai-service/state-machine/handlers/llm-generating.js +16 -7
  147. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  148. package/dist/ai-service/state-machine/handlers/post-processing.d.ts.map +1 -1
  149. package/dist/ai-service/state-machine/handlers/post-processing.js +11 -2
  150. package/dist/ai-service/state-machine/handlers/post-processing.js.map +1 -1
  151. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  152. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +0 -1
  153. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  154. package/dist/ai-service/types.d.ts +1 -0
  155. package/dist/ai-service/types.d.ts.map +1 -1
  156. package/dist/ai-service/types.js.map +1 -1
  157. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  158. package/dist/file-sync-vite-plugin.js +12 -0
  159. package/dist/file-sync-vite-plugin.js.map +1 -1
  160. package/dist/file-system-helpers.d.ts.map +1 -1
  161. package/dist/file-system-helpers.js +1 -0
  162. package/dist/file-system-helpers.js.map +1 -1
  163. package/dist/socket-manager.d.ts.map +1 -1
  164. package/dist/socket-manager.js +6 -0
  165. package/dist/socket-manager.js.map +1 -1
  166. package/dist/sync-service/index.d.ts +8 -0
  167. package/dist/sync-service/index.d.ts.map +1 -1
  168. package/dist/sync-service/index.js +15 -0
  169. package/dist/sync-service/index.js.map +1 -1
  170. package/dist/util/open-api.d.ts +2 -46
  171. package/dist/util/open-api.d.ts.map +1 -1
  172. package/dist/util/open-api.js +1 -114
  173. package/dist/util/open-api.js.map +1 -1
  174. package/package.json +7 -7
  175. package/dist/ai-service/integrations/metadata/database.d.ts +0 -15
  176. package/dist/ai-service/integrations/metadata/database.d.ts.map +0 -1
  177. package/dist/ai-service/integrations/metadata/database.js +0 -121
  178. package/dist/ai-service/integrations/metadata/database.js.map +0 -1
  179. package/dist/ai-service/integrations/metadata/databricks.d.ts +0 -25
  180. package/dist/ai-service/integrations/metadata/databricks.d.ts.map +0 -1
  181. package/dist/ai-service/integrations/metadata/databricks.js +0 -174
  182. package/dist/ai-service/integrations/metadata/databricks.js.map +0 -1
  183. package/dist/ai-service/integrations/metadata/graphql-based.d.ts +0 -16
  184. package/dist/ai-service/integrations/metadata/graphql-based.d.ts.map +0 -1
  185. package/dist/ai-service/integrations/metadata/graphql-based.js +0 -383
  186. package/dist/ai-service/integrations/metadata/graphql-based.js.map +0 -1
  187. package/dist/ai-service/integrations/metadata/index.d.ts +0 -9
  188. package/dist/ai-service/integrations/metadata/index.d.ts.map +0 -1
  189. package/dist/ai-service/integrations/metadata/index.js +0 -7
  190. package/dist/ai-service/integrations/metadata/index.js.map +0 -1
  191. package/dist/ai-service/integrations/metadata/llm-utils.d.ts +0 -24
  192. package/dist/ai-service/integrations/metadata/llm-utils.d.ts.map +0 -1
  193. package/dist/ai-service/integrations/metadata/llm-utils.js +0 -45
  194. package/dist/ai-service/integrations/metadata/llm-utils.js.map +0 -1
  195. package/dist/ai-service/integrations/metadata/open-api.d.ts +0 -17
  196. package/dist/ai-service/integrations/metadata/open-api.d.ts.map +0 -1
  197. package/dist/ai-service/integrations/metadata/open-api.js +0 -62
  198. package/dist/ai-service/integrations/metadata/open-api.js.map +0 -1
  199. package/dist/ai-service/integrations/metadata/table-based.d.ts +0 -10
  200. package/dist/ai-service/integrations/metadata/table-based.d.ts.map +0 -1
  201. package/dist/ai-service/integrations/metadata/table-based.js +0 -27
  202. package/dist/ai-service/integrations/metadata/table-based.js.map +0 -1
  203. package/dist/ai-service/prompt-builder-service/builders/dbschema-intent.d.ts +0 -19
  204. package/dist/ai-service/prompt-builder-service/builders/dbschema-intent.d.ts.map +0 -1
  205. package/dist/ai-service/prompt-builder-service/builders/dbschema-intent.js +0 -145
  206. package/dist/ai-service/prompt-builder-service/builders/dbschema-intent.js.map +0 -1
  207. package/dist/ai-service/prompt-builder-service/builders/openapi-intent.d.ts +0 -19
  208. package/dist/ai-service/prompt-builder-service/builders/openapi-intent.d.ts.map +0 -1
  209. package/dist/ai-service/prompt-builder-service/builders/openapi-intent.js +0 -41
  210. package/dist/ai-service/prompt-builder-service/builders/openapi-intent.js.map +0 -1
  211. package/dist/ai-service/prompt-builder-service/index.d.ts +0 -3
  212. package/dist/ai-service/prompt-builder-service/index.d.ts.map +0 -1
  213. package/dist/ai-service/prompt-builder-service/index.js +0 -3
  214. package/dist/ai-service/prompt-builder-service/index.js.map +0 -1
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Entity permission management for access control.
3
+ *
4
+ * Provides a generalized system for tracking user approvals for accessing
5
+ * specific entities (e.g., integrations, files, APIs). This enables granular
6
+ * per-entity access control where users can approve access to specific
7
+ * resources rather than blanket permissions.
8
+ */
9
+ import type { Tool } from "./types.js";
10
+ /**
11
+ * Types of entities that can have permissions tracked.
12
+ *
13
+ * Extensible to support future entity types like files, APIs, etc.
14
+ */
15
+ export declare enum EntityType {
16
+ /** Integration/datasource entities */
17
+ INTEGRATION = "integration"
18
+ }
19
+ /**
20
+ * Permission key components for scoping.
21
+ * Array of strings that identify the scope (e.g., ["toolName"] or ["category", "readonly"]).
22
+ */
23
+ export type ToolPermissionKey = string[];
24
+ /**
25
+ * Formatted scope string for storage.
26
+ * Created by joining ToolPermissionKey components with a delimiter.
27
+ */
28
+ export type ToolPermissionScope = string;
29
+ /**
30
+ * Strategy for determining how permissions are scoped by tool.
31
+ *
32
+ * Different strategies enable different granularities:
33
+ * - Per-tool: Each tool requires separate approval
34
+ * - Per-category: All tools in a category share approvals
35
+ * - Per-access: Separate read/write permissions
36
+ */
37
+ export declare abstract class ToolPermissionKeyStrategy {
38
+ /**
39
+ * Generate permission key components for a tool.
40
+ *
41
+ * @param tool - Tool to generate key for
42
+ * @returns Array of key components
43
+ */
44
+ abstract getToolPermissionKey(tool: Tool): ToolPermissionKey;
45
+ /**
46
+ * Format permission key into storage scope string.
47
+ *
48
+ * Default implementation joins components with ':' delimiter.
49
+ *
50
+ * @param key - Permission key components
51
+ * @returns Formatted scope string
52
+ */
53
+ formatScope(key: ToolPermissionKey): ToolPermissionScope;
54
+ }
55
+ /**
56
+ * Default strategy: scope permissions per individual tool.
57
+ *
58
+ * Most granular approach - each tool requires separate approval
59
+ * for accessing entities. Provides maximum user control.
60
+ */
61
+ export declare class ToolNamePermissionKeyStrategy extends ToolPermissionKeyStrategy {
62
+ getToolPermissionKey(tool: Tool): ToolPermissionKey;
63
+ }
64
+ /**
65
+ * Store for tracking entity-level permissions.
66
+ *
67
+ * This interface abstracts the storage mechanism, allowing different
68
+ * implementations (session-based, persistent, etc.) to be swapped out
69
+ * without changing the access control logic.
70
+ *
71
+ * Permissions are scoped by tool permission scope strings, enabling
72
+ * granular control (e.g., per-tool, per-category, etc.).
73
+ */
74
+ export interface EntityPermissionStore {
75
+ /**
76
+ * Check if access to a specific entity has been approved for a scope.
77
+ *
78
+ * @param entityType - The type of entity to check
79
+ * @param entityId - The unique identifier of the entity
80
+ * @param scope - Permission scope (e.g., "toolName", "category:read")
81
+ * @returns True if the entity has been approved for this scope
82
+ */
83
+ isApproved(entityType: EntityType, entityId: string, scope: ToolPermissionScope): boolean;
84
+ /**
85
+ * Approve access to a specific entity for a scope.
86
+ *
87
+ * Once approved, future permission checks for this entity and scope will
88
+ * return true until explicitly revoked or the store is cleared.
89
+ *
90
+ * @param entityType - The type of entity to approve
91
+ * @param entityId - The unique identifier of the entity
92
+ * @param scope - Permission scope (e.g., "toolName", "category:read")
93
+ */
94
+ approve(entityType: EntityType, entityId: string, scope: ToolPermissionScope): void;
95
+ /**
96
+ * Revoke access to a specific entity for a scope.
97
+ *
98
+ * Removes the approval for this entity and scope, requiring re-approval
99
+ * for future access attempts.
100
+ *
101
+ * @param entityType - The type of entity to revoke
102
+ * @param entityId - The unique identifier of the entity
103
+ * @param scope - Permission scope (e.g., "toolName", "category:read")
104
+ */
105
+ revoke(entityType: EntityType, entityId: string, scope: ToolPermissionScope): void;
106
+ /**
107
+ * Clear all entity approvals.
108
+ *
109
+ * Removes all stored approvals across all entity types and scopes.
110
+ */
111
+ clear(): void;
112
+ /**
113
+ * Get all approved entity IDs for a specific entity type and optional scope.
114
+ *
115
+ * Useful for debugging, inspection, and UI display of approved entities.
116
+ *
117
+ * @param entityType - The type of entity to list approvals for
118
+ * @param scope - Optional permission scope. If provided, returns only approvals
119
+ * for that scope. If omitted, returns all approved entities
120
+ * across all scopes.
121
+ * @returns Array of approved entity IDs for the given type (and scope)
122
+ */
123
+ getApproved(entityType: EntityType, scope?: ToolPermissionScope): string[];
124
+ }
125
+ /**
126
+ * Session-scoped implementation of entity permission store.
127
+ *
128
+ * Stores approvals in memory for the duration of the session.
129
+ * Approvals are lost when the session ends or the store is cleared.
130
+ *
131
+ * Permissions are scoped, allowing different tools/categories to have
132
+ * independent approval states for the same entity.
133
+ *
134
+ * This implementation is suitable for session-based permission tracking
135
+ * and can be replaced with a persistent implementation if needed.
136
+ */
137
+ export declare class SessionEntityPermissionStore implements EntityPermissionStore {
138
+ private permissions;
139
+ constructor();
140
+ /**
141
+ * Check if access to a specific entity has been approved for a scope.
142
+ *
143
+ * @param entityType - The type of entity to check
144
+ * @param entityId - The unique identifier of the entity
145
+ * @param scope - Permission scope
146
+ * @returns True if the entity has been approved for this scope
147
+ */
148
+ isApproved(entityType: EntityType, entityId: string, scope: ToolPermissionScope): boolean;
149
+ /**
150
+ * Approve access to a specific entity for a scope.
151
+ *
152
+ * @param entityType - The type of entity to approve
153
+ * @param entityId - The unique identifier of the entity
154
+ * @param scope - Permission scope
155
+ */
156
+ approve(entityType: EntityType, entityId: string, scope: ToolPermissionScope): void;
157
+ /**
158
+ * Revoke access to a specific entity for a scope.
159
+ *
160
+ * @param entityType - The type of entity to revoke
161
+ * @param entityId - The unique identifier of the entity
162
+ * @param scope - Permission scope
163
+ */
164
+ revoke(entityType: EntityType, entityId: string, scope: ToolPermissionScope): void;
165
+ /**
166
+ * Clear all entity approvals across all scopes.
167
+ */
168
+ clear(): void;
169
+ /**
170
+ * Get all approved entity IDs for a specific entity type and optional scope.
171
+ *
172
+ * @param entityType - The type of entity to list approvals for
173
+ * @param scope - Optional permission scope. If provided, returns only approvals
174
+ * for that scope. If omitted, returns all approved entities
175
+ * across all scopes (deduplicated).
176
+ * @returns Array of approved entity IDs for the given type (and scope)
177
+ */
178
+ getApproved(entityType: EntityType, scope?: ToolPermissionScope): string[];
179
+ }
180
+ //# sourceMappingURL=entity-permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-permissions.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/entity-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;GAIG;AACH,oBAAY,UAAU;IACpB,sCAAsC;IACtC,WAAW,gBAAgB;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,EAAE,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC;;;;;;;GAOG;AACH,8BAAsB,yBAAyB;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB;IAE5D;;;;;;;OAOG;IACH,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,mBAAmB;CAGzD;AAED;;;;;GAKG;AACH,qBAAa,6BAA8B,SAAQ,yBAAyB;IAC1E,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB;CAGpD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,UAAU,CACR,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC;IAEX;;;;;;;;;OASG;IACH,OAAO,CACL,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAAC;IAER;;;;;;;;;OASG;IACH,MAAM,CACJ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAAC;IAER;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;;;;;;;;;OAUG;IACH,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAAC;CAC5E;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,4BAA6B,YAAW,qBAAqB;IACxE,OAAO,CAAC,WAAW,CAAyD;;IAM5E;;;;;;;OAOG;IACH,UAAU,CACR,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,OAAO;IASV;;;;;;OAMG;IACH,OAAO,CACL,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,IAAI;IAgBP;;;;;;OAMG;IACH,MAAM,CACJ,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,mBAAmB,GACzB,IAAI;IASP;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;OAQG;IACH,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,MAAM,EAAE;CAqB3E"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Entity permission management for access control.
3
+ *
4
+ * Provides a generalized system for tracking user approvals for accessing
5
+ * specific entities (e.g., integrations, files, APIs). This enables granular
6
+ * per-entity access control where users can approve access to specific
7
+ * resources rather than blanket permissions.
8
+ */
9
+ /**
10
+ * Types of entities that can have permissions tracked.
11
+ *
12
+ * Extensible to support future entity types like files, APIs, etc.
13
+ */
14
+ export var EntityType;
15
+ (function (EntityType) {
16
+ /** Integration/datasource entities */
17
+ EntityType["INTEGRATION"] = "integration";
18
+ })(EntityType || (EntityType = {}));
19
+ /**
20
+ * Strategy for determining how permissions are scoped by tool.
21
+ *
22
+ * Different strategies enable different granularities:
23
+ * - Per-tool: Each tool requires separate approval
24
+ * - Per-category: All tools in a category share approvals
25
+ * - Per-access: Separate read/write permissions
26
+ */
27
+ export class ToolPermissionKeyStrategy {
28
+ /**
29
+ * Format permission key into storage scope string.
30
+ *
31
+ * Default implementation joins components with ':' delimiter.
32
+ *
33
+ * @param key - Permission key components
34
+ * @returns Formatted scope string
35
+ */
36
+ formatScope(key) {
37
+ return key.join(":");
38
+ }
39
+ }
40
+ /**
41
+ * Default strategy: scope permissions per individual tool.
42
+ *
43
+ * Most granular approach - each tool requires separate approval
44
+ * for accessing entities. Provides maximum user control.
45
+ */
46
+ export class ToolNamePermissionKeyStrategy extends ToolPermissionKeyStrategy {
47
+ getToolPermissionKey(tool) {
48
+ return [tool.name];
49
+ }
50
+ }
51
+ /**
52
+ * Session-scoped implementation of entity permission store.
53
+ *
54
+ * Stores approvals in memory for the duration of the session.
55
+ * Approvals are lost when the session ends or the store is cleared.
56
+ *
57
+ * Permissions are scoped, allowing different tools/categories to have
58
+ * independent approval states for the same entity.
59
+ *
60
+ * This implementation is suitable for session-based permission tracking
61
+ * and can be replaced with a persistent implementation if needed.
62
+ */
63
+ export class SessionEntityPermissionStore {
64
+ permissions;
65
+ constructor() {
66
+ this.permissions = new Map();
67
+ }
68
+ /**
69
+ * Check if access to a specific entity has been approved for a scope.
70
+ *
71
+ * @param entityType - The type of entity to check
72
+ * @param entityId - The unique identifier of the entity
73
+ * @param scope - Permission scope
74
+ * @returns True if the entity has been approved for this scope
75
+ */
76
+ isApproved(entityType, entityId, scope) {
77
+ const scopedPermissions = this.permissions.get(entityType);
78
+ if (!scopedPermissions) {
79
+ return false;
80
+ }
81
+ const approved = scopedPermissions.get(scope);
82
+ return approved?.has(entityId) ?? false;
83
+ }
84
+ /**
85
+ * Approve access to a specific entity for a scope.
86
+ *
87
+ * @param entityType - The type of entity to approve
88
+ * @param entityId - The unique identifier of the entity
89
+ * @param scope - Permission scope
90
+ */
91
+ approve(entityType, entityId, scope) {
92
+ let scopedPermissions = this.permissions.get(entityType);
93
+ if (!scopedPermissions) {
94
+ scopedPermissions = new Map();
95
+ this.permissions.set(entityType, scopedPermissions);
96
+ }
97
+ let approved = scopedPermissions.get(scope);
98
+ if (!approved) {
99
+ approved = new Set();
100
+ scopedPermissions.set(scope, approved);
101
+ }
102
+ approved.add(entityId);
103
+ }
104
+ /**
105
+ * Revoke access to a specific entity for a scope.
106
+ *
107
+ * @param entityType - The type of entity to revoke
108
+ * @param entityId - The unique identifier of the entity
109
+ * @param scope - Permission scope
110
+ */
111
+ revoke(entityType, entityId, scope) {
112
+ const scopedPermissions = this.permissions.get(entityType);
113
+ if (!scopedPermissions) {
114
+ return;
115
+ }
116
+ const approved = scopedPermissions.get(scope);
117
+ approved?.delete(entityId);
118
+ }
119
+ /**
120
+ * Clear all entity approvals across all scopes.
121
+ */
122
+ clear() {
123
+ this.permissions.clear();
124
+ }
125
+ /**
126
+ * Get all approved entity IDs for a specific entity type and optional scope.
127
+ *
128
+ * @param entityType - The type of entity to list approvals for
129
+ * @param scope - Optional permission scope. If provided, returns only approvals
130
+ * for that scope. If omitted, returns all approved entities
131
+ * across all scopes (deduplicated).
132
+ * @returns Array of approved entity IDs for the given type (and scope)
133
+ */
134
+ getApproved(entityType, scope) {
135
+ const scopedPermissions = this.permissions.get(entityType);
136
+ if (!scopedPermissions) {
137
+ return [];
138
+ }
139
+ // If scope provided, return only that scope's entities
140
+ if (scope !== undefined) {
141
+ const approved = scopedPermissions.get(scope);
142
+ return approved ? Array.from(approved) : [];
143
+ }
144
+ // No scope provided - return all entities across all scopes (deduplicated)
145
+ const allEntities = new Set();
146
+ for (const approved of scopedPermissions.values()) {
147
+ for (const entityId of approved) {
148
+ allEntities.add(entityId);
149
+ }
150
+ }
151
+ return Array.from(allEntities);
152
+ }
153
+ }
154
+ //# sourceMappingURL=entity-permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-permissions.js","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/entity-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,sCAAsC;IACtC,yCAA2B,CAAA;AAC7B,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAcD;;;;;;;GAOG;AACH,MAAM,OAAgB,yBAAyB;IAS7C;;;;;;;OAOG;IACH,WAAW,CAAC,GAAsB;QAChC,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,yBAAyB;IAC1E,oBAAoB,CAAC,IAAU;QAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF;AAgFD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,4BAA4B;IAC/B,WAAW,CAAyD;IAE5E;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CACR,UAAsB,EACtB,QAAgB,EAChB,KAA0B;QAE1B,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CACL,UAAsB,EACtB,QAAgB,EAChB,KAA0B;QAE1B,IAAI,iBAAiB,GAAG,IAAI,CAAC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CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,CAAC;QAED,2EAA2E;QAC3E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QACtC,KAAK,MAAM,QAAQ,IAAI,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBAChC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/example.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,YAAY,EAMb,MAAM,YAAY,CAAC;AAkFpB,wBAAgB,oBAAoB,iBA+CnC;AAMD,wBAAsB,YAAY,kBAuCjC"}
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/example.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,YAAY,EAOb,MAAM,YAAY,CAAC;AAkFpB,wBAAgB,oBAAoB,iBAoEnC;AAMD,wBAAsB,YAAY,kBAuCjC"}
@@ -8,7 +8,7 @@
8
8
  * - Executing tools with permissions
9
9
  */
10
10
  import { z } from "zod";
11
- import { ToolRegistry, PermissionLevel, promptForTools, requireRole, createToolFactory, ToolCategory, } from "./index.js";
11
+ import { ToolRegistry, PermissionLevel, ToolPermissionResponse, promptForTools, requireRole, createToolFactory, ToolCategory, } from "./index.js";
12
12
  // ============================================================================
13
13
  // Example Tool: Add Event
14
14
  // ============================================================================
@@ -92,15 +92,34 @@ export function setupExampleRegistry() {
92
92
  // Or use a preset
93
93
  // registry.addAccessRule(...presets.production());
94
94
  // 3. Setup prompt handler
95
- registry.setPromptHandler(async (toolName, input, context) => {
95
+ registry.setPromptHandler(async (tool, input, context) => {
96
96
  console.log(`\n=== User Confirmation Required ===`);
97
- console.log(`Tool: ${toolName}`);
98
- console.log(`Input:`, input);
97
+ console.log(`Tool: ${tool.name}`);
98
+ // Use tool formatting methods if available
99
+ const actionName = tool.getActionName?.();
100
+ const formattedInput = tool.formatInput?.(input);
101
+ if (actionName) {
102
+ console.log(`Action: ${actionName.future}`);
103
+ }
104
+ if (formattedInput) {
105
+ if (formattedInput.targets.length > 0) {
106
+ console.log(`Targets: ${formattedInput.targets.join(", ")}`);
107
+ }
108
+ if (formattedInput.summary) {
109
+ console.log(`Summary: ${formattedInput.summary}`);
110
+ }
111
+ if (formattedInput.details) {
112
+ console.log(`Details:\n${formattedInput.details}`);
113
+ }
114
+ }
115
+ else {
116
+ console.log(`Input:`, input);
117
+ }
99
118
  console.log(`User: ${context.userId} (${context.userRole})`);
100
119
  console.log(`===================================\n`);
101
120
  // In real implementation, show dialog and wait for user response
102
- // For example: return await showConfirmDialog({ toolName, input });
103
- return true; // Mock: auto-approve for demo
121
+ // For example: return await showConfirmDialog({ tool, input });
122
+ return ToolPermissionResponse.ALLOW; // Mock: auto-approve for demo
104
123
  });
105
124
  // 4. Instantiate tools with dependencies
106
125
  const mockDeps = {
@@ -1 +1 @@
1
- {"version":3,"file":"example.js","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/example.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,MAAM,mBAAmB,GAAG,iBAAiB,CAC3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AAG,MAAM,QAAQ,CAAC,OAAO,CACpC,aAAa,EACb,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAC7B,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,CAC3C,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEhC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpD,+BAA+B;IAC/B,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,6BAA6B;AAC7B,kBAAkB"}
@@ -7,8 +7,10 @@
7
7
  * - User prompt handling
8
8
  * - Type-safe tool definitions
9
9
  */
10
- export type { Tool, ToolFactory, ToolExecutionResult, AccessControlContext, AccessControlRule, PromptHandler, } from "./types.js";
11
- export { PermissionLevel, ToolCategory, createToolFactory } from "./types.js";
10
+ export type { Tool, ToolFactory, ToolExecutionResult, AccessControlContext, AccessControlRule, PromptHandler, EntityReference, } from "./types.js";
11
+ export { PermissionLevel, ToolCategory, ToolPermissionResponse, createToolFactory, } from "./types.js";
12
+ export type { EntityPermissionStore } from "./entity-permissions.js";
13
+ export { EntityType, SessionEntityPermissionStore, } from "./entity-permissions.js";
12
14
  export { ToolRegistry } from "./registry.js";
13
15
  export { blockTools, promptForTools, requireRole, combineRules, forTools, forCategory, presets, } from "./access-control.js";
14
16
  import { ToolRegistry } from "./registry.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,IAAI,EACJ,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG9E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,eAAO,MAAM,eAAe,cAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,IAAI,EACJ,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,UAAU,EACV,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,eAAO,MAAM,eAAe,cAAqB,CAAC"}
@@ -7,7 +7,8 @@
7
7
  * - User prompt handling
8
8
  * - Type-safe tool definitions
9
9
  */
10
- export { PermissionLevel, ToolCategory, createToolFactory } from "./types.js";
10
+ export { PermissionLevel, ToolCategory, ToolPermissionResponse, createToolFactory, } from "./types.js";
11
+ export { EntityType, SessionEntityPermissionStore, } from "./entity-permissions.js";
11
12
  // Export registry
12
13
  export { ToolRegistry } from "./registry.js";
13
14
  // Export access control utilities
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9E,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,kCAAkC;AAClC,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,qBAAqB,CAAC;AAE7B,4CAA4C;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,UAAU,EACV,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAEjC,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,kCAAkC;AAClC,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,qBAAqB,CAAC;AAE7B,4CAA4C;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type Tool, type ToolFactory, type AccessControlContext, type AccessControlRule, type PromptHandler, type ToolExecutionResult, PermissionLevel, type ToolMiddleware } from "./types.js";
2
+ import type { EntityPermissionStore } from "./entity-permissions.js";
2
3
  import type { ToolCallOptions } from "ai";
3
4
  /**
4
5
  * Central registry for tools with access control.
@@ -15,6 +16,9 @@ export declare class ToolRegistry {
15
16
  private accessRules;
16
17
  private middleware;
17
18
  private promptHandler?;
19
+ private promptQueue;
20
+ private entityPermissionStore?;
21
+ private scopeStrategy;
18
22
  /**
19
23
  * Register a tool factory and optionally instantiate it immediately.
20
24
  *
@@ -121,6 +125,26 @@ export declare class ToolRegistry {
121
125
  * @param handler - Prompt handler function
122
126
  */
123
127
  setPromptHandler(handler: PromptHandler): void;
128
+ /**
129
+ * Set entity permission store for tracking per-entity approvals.
130
+ *
131
+ * When set, tools with `extractEntities` defined will automatically
132
+ * check if extracted entities have been approved before execution.
133
+ * If any entity is not approved, the user will be prompted.
134
+ *
135
+ * @param store - Entity permission store instance
136
+ */
137
+ setEntityPermissionStore(store: EntityPermissionStore): void;
138
+ /**
139
+ * Get permission scope for a tool.
140
+ *
141
+ * Computes the scope string using the configured strategy.
142
+ * This scope is used to isolate permissions between different tools/categories.
143
+ *
144
+ * @param tool - Tool to get scope for
145
+ * @returns Permission scope string
146
+ */
147
+ private getToolPermissionScope;
124
148
  /**
125
149
  * Check permission level for tool execution.
126
150
  *
@@ -143,6 +167,29 @@ export declare class ToolRegistry {
143
167
  * @returns Execution result with success status and data/error
144
168
  */
145
169
  execute<Input, Output>(toolName: string, input: Input, context?: AccessControlContext, options?: ToolCallOptions): Promise<ToolExecutionResult<Output>>;
170
+ /**
171
+ * Check if we need to prompt the user for a tool with PROMPT permission.
172
+ *
173
+ * For tools with entity extraction, returns false if all entities are already
174
+ * approved for this tool's scope (skipping the prompt). For tools without
175
+ * entity extraction, always returns true (standard prompting).
176
+ *
177
+ * @param tool - Tool to check
178
+ * @param input - Tool input to extract entities from
179
+ * @returns True if we should prompt user, false if we can skip
180
+ */
181
+ private shouldPromptForEntities;
182
+ /**
183
+ * Store entity approvals after successful user prompt.
184
+ *
185
+ * Extracts entities from tool input and marks them as approved for this
186
+ * tool's scope in the entity permission store. No-op if entity system
187
+ * is not configured.
188
+ *
189
+ * @param tool - Tool that was approved
190
+ * @param input - Tool input to extract entities from
191
+ */
192
+ private approveEntitiesAfterPrompt;
146
193
  /**
147
194
  * Wrap a tool to enforce access control on execute().
148
195
  *
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/ai-service/agent/tools2/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,eAAe,EAEf,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAE1C;;;;;;;;GAQG;AAEH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,aAAa,CAAC,CAAgB;IAEtC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAkBpD;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAW7B;;;;OAIG;IACH,SAAS,IAAI,MAAM,EAAE;IAIrB;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI;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