photon-grid-core 2.0.1 → 2.0.5

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 (236) hide show
  1. package/README.md +3 -3
  2. package/cell-selection/cell-selection-engine.d.ts +14 -0
  3. package/cell-selection/cell-selection-engine.d.ts.map +1 -1
  4. package/cell-selection/cell-selection-engine.js +63 -9
  5. package/cell-selection/cell-selection-engine.js.map +1 -1
  6. package/chart/range-chart-controller.d.ts +10 -0
  7. package/chart/range-chart-controller.d.ts.map +1 -1
  8. package/chart/range-chart-controller.js +22 -2
  9. package/chart/range-chart-controller.js.map +1 -1
  10. package/column-groups/column-group-drag-handler.d.ts.map +1 -1
  11. package/column-groups/column-group-drag-handler.js +64 -25
  12. package/column-groups/column-group-drag-handler.js.map +1 -1
  13. package/column-groups/column-group-header-builder.d.ts.map +1 -1
  14. package/column-groups/column-group-header-builder.js +7 -5
  15. package/column-groups/column-group-header-builder.js.map +1 -1
  16. package/column-groups/display-group-drag-handler.d.ts +7 -3
  17. package/column-groups/display-group-drag-handler.d.ts.map +1 -1
  18. package/column-groups/display-group-drag-handler.js +46 -7
  19. package/column-groups/display-group-drag-handler.js.map +1 -1
  20. package/column-groups/display-group-header-builder.d.ts +1 -1
  21. package/column-groups/display-group-header-builder.d.ts.map +1 -1
  22. package/column-groups/display-group-header-builder.js +9 -7
  23. package/column-groups/display-group-header-builder.js.map +1 -1
  24. package/core/column-model.d.ts +88 -5
  25. package/core/column-model.d.ts.map +1 -1
  26. package/core/column-model.js +215 -3
  27. package/core/column-model.js.map +1 -1
  28. package/core/grid-api.d.ts +34 -2
  29. package/core/grid-api.d.ts.map +1 -1
  30. package/core/grid-api.js +40 -0
  31. package/core/grid-api.js.map +1 -1
  32. package/core/grid-core.d.ts +7 -0
  33. package/core/grid-core.d.ts.map +1 -1
  34. package/core/grid-core.js +42 -12
  35. package/core/grid-core.js.map +1 -1
  36. package/core/grid-store.d.ts +5 -5
  37. package/core/grid-store.d.ts.map +1 -1
  38. package/core/pointer-utils.d.ts +59 -0
  39. package/core/pointer-utils.d.ts.map +1 -0
  40. package/core/pointer-utils.js +59 -0
  41. package/core/pointer-utils.js.map +1 -0
  42. package/drag-drop/drag-drop-engine.d.ts.map +1 -1
  43. package/drag-drop/drag-drop-engine.js +8 -8
  44. package/drag-drop/drag-drop-engine.js.map +1 -1
  45. package/engines/editing/cell-editor-engine.js +1 -1
  46. package/engines/editing/cell-editor-engine.js.map +1 -1
  47. package/engines/master-detail/master-detail-engine.d.ts +4 -3
  48. package/engines/master-detail/master-detail-engine.d.ts.map +1 -1
  49. package/engines/master-detail/master-detail-engine.js +14 -5
  50. package/engines/master-detail/master-detail-engine.js.map +1 -1
  51. package/engines/selection/row-selection-engine.d.ts +41 -0
  52. package/engines/selection/row-selection-engine.d.ts.map +1 -1
  53. package/engines/selection/row-selection-engine.js +103 -0
  54. package/engines/selection/row-selection-engine.js.map +1 -1
  55. package/index.d.ts +8 -4
  56. package/index.d.ts.map +1 -1
  57. package/index.js +4 -1
  58. package/index.js.map +1 -1
  59. package/package.json +1 -1
  60. package/photon-ai/index.d.ts +2 -0
  61. package/photon-ai/index.d.ts.map +1 -1
  62. package/photon-ai/index.js +2 -0
  63. package/photon-ai/index.js.map +1 -1
  64. package/photon-ai/photon-ai-panel.d.ts +40 -0
  65. package/photon-ai/photon-ai-panel.d.ts.map +1 -1
  66. package/photon-ai/photon-ai-panel.js +163 -8
  67. package/photon-ai/photon-ai-panel.js.map +1 -1
  68. package/photon-ai/photon-ai-service.d.ts +38 -1
  69. package/photon-ai/photon-ai-service.d.ts.map +1 -1
  70. package/photon-ai/photon-ai-service.js +72 -1
  71. package/photon-ai/photon-ai-service.js.map +1 -1
  72. package/photon-ai/provider/ai-provider.types.d.ts +174 -0
  73. package/photon-ai/provider/ai-provider.types.d.ts.map +1 -0
  74. package/photon-ai/provider/ai-provider.types.js +42 -0
  75. package/photon-ai/provider/ai-provider.types.js.map +1 -0
  76. package/photon-ai/provider/command-normalizer.d.ts +36 -0
  77. package/photon-ai/provider/command-normalizer.d.ts.map +1 -0
  78. package/photon-ai/provider/command-normalizer.js +120 -0
  79. package/photon-ai/provider/command-normalizer.js.map +1 -0
  80. package/photon-ai/provider/grid-context-builder.d.ts +37 -0
  81. package/photon-ai/provider/grid-context-builder.d.ts.map +1 -0
  82. package/photon-ai/provider/grid-context-builder.js +96 -0
  83. package/photon-ai/provider/grid-context-builder.js.map +1 -0
  84. package/photon-ai/provider/http-ai-provider.d.ts +42 -0
  85. package/photon-ai/provider/http-ai-provider.d.ts.map +1 -0
  86. package/photon-ai/provider/http-ai-provider.js +125 -0
  87. package/photon-ai/provider/http-ai-provider.js.map +1 -0
  88. package/photon-ai/provider/index.d.ts +30 -0
  89. package/photon-ai/provider/index.d.ts.map +1 -0
  90. package/photon-ai/provider/index.js +42 -0
  91. package/photon-ai/provider/index.js.map +1 -0
  92. package/photon-ai/provider/presets.d.ts +29 -0
  93. package/photon-ai/provider/presets.d.ts.map +1 -0
  94. package/photon-ai/provider/presets.js +110 -0
  95. package/photon-ai/provider/presets.js.map +1 -0
  96. package/photon-ai/provider/response-parsing.d.ts +22 -0
  97. package/photon-ai/provider/response-parsing.d.ts.map +1 -0
  98. package/photon-ai/provider/response-parsing.js +79 -0
  99. package/photon-ai/provider/response-parsing.js.map +1 -0
  100. package/photon-ai/provider/system-prompt.d.ts +26 -0
  101. package/photon-ai/provider/system-prompt.d.ts.map +1 -0
  102. package/photon-ai/provider/system-prompt.js +82 -0
  103. package/photon-ai/provider/system-prompt.js.map +1 -0
  104. package/photon-grid.min.js +697 -488
  105. package/renderer/body-renderer.d.ts.map +1 -1
  106. package/renderer/body-renderer.js +34 -9
  107. package/renderer/body-renderer.js.map +1 -1
  108. package/renderer/column-chooser.d.ts +82 -0
  109. package/renderer/column-chooser.d.ts.map +1 -0
  110. package/renderer/column-chooser.js +335 -0
  111. package/renderer/column-chooser.js.map +1 -0
  112. package/renderer/column-menu.d.ts.map +1 -1
  113. package/renderer/column-menu.js +32 -20
  114. package/renderer/column-menu.js.map +1 -1
  115. package/renderer/column-style-manager.d.ts +17 -0
  116. package/renderer/column-style-manager.d.ts.map +1 -1
  117. package/renderer/column-style-manager.js +28 -0
  118. package/renderer/column-style-manager.js.map +1 -1
  119. package/renderer/detail-row-renderer.d.ts.map +1 -1
  120. package/renderer/detail-row-renderer.js +9 -7
  121. package/renderer/detail-row-renderer.js.map +1 -1
  122. package/renderer/grid-renderer.d.ts +23 -1
  123. package/renderer/grid-renderer.d.ts.map +1 -1
  124. package/renderer/grid-renderer.js +66 -8
  125. package/renderer/grid-renderer.js.map +1 -1
  126. package/renderer/group-drop-zone.js +14 -14
  127. package/renderer/group-drop-zone.js.map +1 -1
  128. package/renderer/header-renderer.d.ts +70 -0
  129. package/renderer/header-renderer.d.ts.map +1 -1
  130. package/renderer/header-renderer.js +361 -52
  131. package/renderer/header-renderer.js.map +1 -1
  132. package/renderer/row-animator.d.ts +18 -1
  133. package/renderer/row-animator.d.ts.map +1 -1
  134. package/renderer/row-animator.js +96 -20
  135. package/renderer/row-animator.js.map +1 -1
  136. package/renderer/row-drag-renderer.js +6 -6
  137. package/renderer/row-drag-renderer.js.map +1 -1
  138. package/renderer/scroll-controller.d.ts +40 -0
  139. package/renderer/scroll-controller.d.ts.map +1 -1
  140. package/renderer/scroll-controller.js +215 -13
  141. package/renderer/scroll-controller.js.map +1 -1
  142. package/styles/base/cells.css.d.ts +1 -1
  143. package/styles/base/cells.css.d.ts.map +1 -1
  144. package/styles/base/cells.css.js +13 -13
  145. package/styles/base/column-chooser.css.d.ts +13 -0
  146. package/styles/base/column-chooser.css.d.ts.map +1 -0
  147. package/styles/base/column-chooser.css.js +241 -0
  148. package/styles/base/column-chooser.css.js.map +1 -0
  149. package/styles/base/column-context-menu.css.d.ts +1 -1
  150. package/styles/base/column-context-menu.css.d.ts.map +1 -1
  151. package/styles/base/column-context-menu.css.js +29 -5
  152. package/styles/base/column-context-menu.css.js.map +1 -1
  153. package/styles/base/column-group-header.css.d.ts +1 -1
  154. package/styles/base/column-group-header.css.d.ts.map +1 -1
  155. package/styles/base/column-group-header.css.js +1 -1
  156. package/styles/base/context-menu.css.d.ts +1 -1
  157. package/styles/base/context-menu.css.d.ts.map +1 -1
  158. package/styles/base/context-menu.css.js +8 -0
  159. package/styles/base/context-menu.css.js.map +1 -1
  160. package/styles/base/filter.css.d.ts +1 -1
  161. package/styles/base/filter.css.d.ts.map +1 -1
  162. package/styles/base/filter.css.js +7 -7
  163. package/styles/base/group-drop-zone.css.d.ts +1 -1
  164. package/styles/base/group-drop-zone.css.d.ts.map +1 -1
  165. package/styles/base/group-drop-zone.css.js +3 -3
  166. package/styles/base/header.css.d.ts +1 -1
  167. package/styles/base/header.css.d.ts.map +1 -1
  168. package/styles/base/header.css.js +23 -0
  169. package/styles/base/header.css.js.map +1 -1
  170. package/styles/base/photon-ai.css.d.ts +1 -1
  171. package/styles/base/photon-ai.css.d.ts.map +1 -1
  172. package/styles/base/photon-ai.css.js +65 -0
  173. package/styles/base/photon-ai.css.js.map +1 -1
  174. package/styles/base/row-drag.css.d.ts +1 -1
  175. package/styles/base/row-drag.css.d.ts.map +1 -1
  176. package/styles/base/row-drag.css.js +1 -1
  177. package/styles/base/rows.css.d.ts +1 -1
  178. package/styles/base/rows.css.d.ts.map +1 -1
  179. package/styles/base/rows.css.js +4 -16
  180. package/styles/base/rows.css.js.map +1 -1
  181. package/styles/base/scrollbars.css.d.ts +1 -1
  182. package/styles/base/scrollbars.css.d.ts.map +1 -1
  183. package/styles/base/scrollbars.css.js +56 -7
  184. package/styles/base/scrollbars.css.js.map +1 -1
  185. package/styles/base/sparkline.css.d.ts +1 -1
  186. package/styles/base/sparkline.css.d.ts.map +1 -1
  187. package/styles/base/sparkline.css.js +6 -0
  188. package/styles/base/sparkline.css.js.map +1 -1
  189. package/styles/base/tooltip.css.d.ts +1 -1
  190. package/styles/base/tooltip.css.d.ts.map +1 -1
  191. package/styles/base/tooltip.css.js +1 -1
  192. package/styles/base/touch.css.d.ts +23 -0
  193. package/styles/base/touch.css.d.ts.map +1 -0
  194. package/styles/base/touch.css.js +85 -0
  195. package/styles/base/touch.css.js.map +1 -0
  196. package/styles/base-styles.d.ts.map +1 -1
  197. package/styles/base-styles.js +9 -2
  198. package/styles/base-styles.js.map +1 -1
  199. package/styles/themes/theme-alpine.d.ts +9 -1
  200. package/styles/themes/theme-alpine.d.ts.map +1 -1
  201. package/styles/themes/theme-alpine.js +34 -43
  202. package/styles/themes/theme-alpine.js.map +1 -1
  203. package/styles/themes/theme-balham.d.ts +9 -1
  204. package/styles/themes/theme-balham.d.ts.map +1 -1
  205. package/styles/themes/theme-balham.js +33 -42
  206. package/styles/themes/theme-balham.js.map +1 -1
  207. package/styles/themes/theme-material.d.ts +9 -1
  208. package/styles/themes/theme-material.d.ts.map +1 -1
  209. package/styles/themes/theme-material.js +35 -43
  210. package/styles/themes/theme-material.js.map +1 -1
  211. package/styles/themes/theme-quartz.d.ts +14 -1
  212. package/styles/themes/theme-quartz.d.ts.map +1 -1
  213. package/styles/themes/theme-quartz.js +63 -43
  214. package/styles/themes/theme-quartz.js.map +1 -1
  215. package/theme/theme-manager.d.ts +55 -7
  216. package/theme/theme-manager.d.ts.map +1 -1
  217. package/theme/theme-manager.js +139 -35
  218. package/theme/theme-manager.js.map +1 -1
  219. package/types/column.types.d.ts +78 -0
  220. package/types/column.types.d.ts.map +1 -1
  221. package/types/column.types.js +26 -1
  222. package/types/column.types.js.map +1 -1
  223. package/types/grid.types.d.ts +92 -3
  224. package/types/grid.types.d.ts.map +1 -1
  225. package/types/photon-ai.types.d.ts +125 -5
  226. package/types/photon-ai.types.d.ts.map +1 -1
  227. package/types/photon-ai.types.js +18 -1
  228. package/types/photon-ai.types.js.map +1 -1
  229. package/types/theme.types.d.ts +19 -0
  230. package/types/theme.types.d.ts.map +1 -1
  231. package/types/theme.types.js +7 -1
  232. package/types/theme.types.js.map +1 -1
  233. package/styles/themes/theme-dark.d.ts +0 -2
  234. package/styles/themes/theme-dark.d.ts.map +0 -1
  235. package/styles/themes/theme-dark.js +0 -216
  236. package/styles/themes/theme-dark.js.map +0 -1
@@ -0,0 +1,174 @@
1
+ import type { ColumnDataType, ColumnPinPosition } from '../../types/column.types';
2
+ /**
3
+ * The runtime contracts shared by every Photon AI generative provider. These
4
+ * types are intentionally provider-agnostic: {@link PhotonAIService} builds a
5
+ * {@link PhotonAIProviderRequest}, hands it to whichever {@link PhotonAIProvider}
6
+ * is configured, and executes the returned {@link PhotonAIGeneration} through
7
+ * the same command pipeline used by the deterministic interpreter — so a new
8
+ * back-end (Gemini today, another model tomorrow) only ever implements
9
+ * {@link PhotonAIProvider.generate}, never touches the grid.
10
+ */
11
+ /**
12
+ * One column, distilled to exactly what a language model needs to choose a
13
+ * target and a valid value. Deliberately excludes render functions, widths,
14
+ * and other presentation-only fields — sending them would waste tokens and
15
+ * leak irrelevant internals into the prompt.
16
+ */
17
+ export interface PhotonAIColumnContext {
18
+ /** Stable machine id — the value the model must echo back in a command's `colId`/`colIds`. */
19
+ readonly colId: string;
20
+ /** Human-facing column title (what the user is most likely to type). */
21
+ readonly header: string;
22
+ /** Underlying data field key. */
23
+ readonly field: string;
24
+ /** Data type — tells the model which filter operators and value formats make sense. */
25
+ readonly type: ColumnDataType;
26
+ readonly sortable: boolean;
27
+ readonly filterable: boolean;
28
+ readonly groupable: boolean;
29
+ /** Current pin side, or `null` when unpinned. */
30
+ readonly pinned: ColumnPinPosition;
31
+ readonly visible: boolean;
32
+ /**
33
+ * Allowed values for `dropdown`/`enum`-style columns, so the model filters
34
+ * by a value that actually exists rather than guessing. Omitted for
35
+ * free-form columns.
36
+ */
37
+ readonly options?: readonly (string | number)[];
38
+ }
39
+ /**
40
+ * A single grid action the model is allowed to emit, mirrored 1:1 from the
41
+ * live intent registry so the catalog can never drift from what the grid can
42
+ * actually execute. `type` is the intent key the model must reproduce in a
43
+ * command; `description` is the human blurb registered with that intent.
44
+ */
45
+ export interface PhotonAICapability {
46
+ readonly type: string;
47
+ readonly description: string;
48
+ }
49
+ /** A concise, model-friendly snapshot of the grid's live state at prompt time. */
50
+ export interface PhotonAIGridState {
51
+ readonly totalRowCount: number;
52
+ readonly visibleRowCount: number;
53
+ readonly sort: readonly PhotonAISortState[];
54
+ readonly filters: readonly PhotonAIFilterState[];
55
+ readonly groupedColumns: readonly string[];
56
+ readonly selectedRowCount: number;
57
+ }
58
+ export interface PhotonAISortState {
59
+ readonly colId: string;
60
+ readonly order: 'asc' | 'desc';
61
+ }
62
+ export interface PhotonAIFilterState {
63
+ readonly colId: string;
64
+ /** Short human summary of the active condition, e.g. `greaterThan 5000`. */
65
+ readonly summary: string;
66
+ }
67
+ /**
68
+ * Everything about the grid the model receives alongside the user's command:
69
+ * what columns exist, what actions are possible, and what state the grid is
70
+ * currently in. Built fresh per request by {@link PhotonAIService} so the
71
+ * model always reasons over the grid's *current* shape.
72
+ */
73
+ export interface PhotonGridContext {
74
+ readonly columns: readonly PhotonAIColumnContext[];
75
+ readonly capabilities: readonly PhotonAICapability[];
76
+ readonly state: PhotonAIGridState;
77
+ }
78
+ /**
79
+ * One executable instruction returned by the model. Structurally identical to
80
+ * a {@link import('../photon-ai.types').PhotonCommand} — `type` is an intent
81
+ * key from the capability catalog and `params` carries that intent's inputs —
82
+ * so a generated action flows straight into the existing `CommandExecutor`
83
+ * after light normalization.
84
+ */
85
+ export interface PhotonAIAction {
86
+ readonly type: string;
87
+ readonly params: Readonly<Record<string, unknown>>;
88
+ }
89
+ /** The parsed, validated result of one provider call. */
90
+ export interface PhotonAIGeneration {
91
+ /** Zero or more grid actions to execute, in order. Empty for a pure conversational reply. */
92
+ readonly actions: readonly PhotonAIAction[];
93
+ /** Natural-language message to show the user (streamed into the panel). */
94
+ readonly reply: string;
95
+ }
96
+ /**
97
+ * The provider-neutral, transformer-facing view of one prompt. This is what a
98
+ * consumer's {@link import('../../types/photon-ai.types').PhotonAIProviderConfig.requestTransformer}
99
+ * receives — everything needed to build any provider's request body, with no
100
+ * transport concern (URL, headers, auth) leaking in.
101
+ */
102
+ export interface PhotonAIRequest {
103
+ /** The assembled system instruction (role + output contract + any extra guidance). */
104
+ readonly systemInstruction: string;
105
+ /** The raw user command typed into the panel. */
106
+ readonly userCommand: string;
107
+ /** Structured grid context (columns, capabilities, live state). */
108
+ readonly gridContext: PhotonGridContext;
109
+ /** Resolved model id for this request. */
110
+ readonly model: string;
111
+ /** Resolved sampling temperature for this request. */
112
+ readonly temperature: number;
113
+ }
114
+ /**
115
+ * The provider-neutral, transformer-facing result. A consumer's
116
+ * {@link import('../../types/photon-ai.types').PhotonAIProviderConfig.responseTransformer}
117
+ * must return this shape from whatever the provider's raw JSON looked like.
118
+ * Identical in structure to {@link PhotonAIGeneration}.
119
+ */
120
+ export type PhotonAIResponse = PhotonAIGeneration;
121
+ /**
122
+ * What a provider receives. The service assembles the {@link systemInstruction}
123
+ * (role + output contract) and the structured {@link gridContext}; the provider
124
+ * decides how to serialize them into its own wire format and how to call its
125
+ * endpoint.
126
+ */
127
+ export interface PhotonAIProviderRequest {
128
+ readonly systemInstruction: string;
129
+ readonly gridContext: PhotonGridContext;
130
+ readonly userCommand: string;
131
+ /** Optional cooperative cancellation (e.g. panel closed mid-flight). */
132
+ readonly signal?: AbortSignal;
133
+ }
134
+ /**
135
+ * The one method every generative back-end implements. Must resolve with a
136
+ * validated {@link PhotonAIResponse} or reject with a
137
+ * {@link PhotonAIProviderError} — never leak a raw transport error to the UI.
138
+ */
139
+ export interface PhotonAIProvider {
140
+ generate(request: PhotonAIProviderRequest): Promise<PhotonAIResponse>;
141
+ }
142
+ /** Categorized failure reason, so the panel can show an actionable message rather than a stack trace. */
143
+ export declare enum PhotonAIErrorKind {
144
+ /** The request never reached the provider (offline, DNS, CORS). */
145
+ Network = "network",
146
+ /** Provider returned a non-2xx status not covered by a more specific kind. */
147
+ Http = "http",
148
+ /** HTTP 429 / quota exhausted. */
149
+ RateLimit = "rate-limit",
150
+ /** HTTP 401/403 — missing, invalid, or unauthorized API key. */
151
+ Auth = "auth",
152
+ /** The model refused or its output was safety-blocked. */
153
+ Blocked = "blocked",
154
+ /** Response arrived but could not be parsed into a {@link PhotonAIGeneration}. */
155
+ InvalidResponse = "invalid-response",
156
+ /** The request exceeded {@link import('../../types/photon-ai.types').PhotonAIProviderConfig.requestTimeoutMs}. */
157
+ Timeout = "timeout"
158
+ }
159
+ /**
160
+ * The single error type providers throw. Carries a machine-readable
161
+ * {@link PhotonAIErrorKind} (for retry/telemetry decisions) plus a
162
+ * user-facing message the panel can display verbatim.
163
+ */
164
+ export declare class PhotonAIProviderError extends Error {
165
+ readonly kind: PhotonAIErrorKind;
166
+ /** Upstream HTTP status, when the failure originated from an HTTP response. */
167
+ readonly status?: number | undefined;
168
+ constructor(kind: PhotonAIErrorKind, message: string,
169
+ /** Upstream HTTP status, when the failure originated from an HTTP response. */
170
+ status?: number | undefined);
171
+ }
172
+ /** A short, friendly one-liner for each failure kind, used when a provider throws to the panel. */
173
+ export declare function describeProviderError(error: unknown): string;
174
+ //# sourceMappingURL=ai-provider.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-provider.types.d.ts","sourceRoot":"","sources":["../../../src/photon-ai/provider/ai-provider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElF;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAA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IAC9E,IAAI,SAAS;IACb,kCAAkC;IAClC,SAAS,eAAe;IACxB,gEAAgE;IAChE,IAAI,SAAS;IACb,0DAA0D;IAC1D,OAAO,YAAY;IACnB,kFAAkF;IAClF,eAAe,qBAAqB;IACpC,kHAAkH;IAClH,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,IAAI,EAAE,iBAAiB;IAEhC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;gBAHf,IAAI,EAAE,iBAAiB,EAChC,OAAO,EAAE,MAAM;IACf,+EAA+E;IACtE,MAAM,CAAC,EAAE,MAAM,YAAA;CAK3B;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI5D"}
@@ -0,0 +1,42 @@
1
+ /** Categorized failure reason, so the panel can show an actionable message rather than a stack trace. */
2
+ export var PhotonAIErrorKind;
3
+ (function (PhotonAIErrorKind) {
4
+ /** The request never reached the provider (offline, DNS, CORS). */
5
+ PhotonAIErrorKind["Network"] = "network";
6
+ /** Provider returned a non-2xx status not covered by a more specific kind. */
7
+ PhotonAIErrorKind["Http"] = "http";
8
+ /** HTTP 429 / quota exhausted. */
9
+ PhotonAIErrorKind["RateLimit"] = "rate-limit";
10
+ /** HTTP 401/403 — missing, invalid, or unauthorized API key. */
11
+ PhotonAIErrorKind["Auth"] = "auth";
12
+ /** The model refused or its output was safety-blocked. */
13
+ PhotonAIErrorKind["Blocked"] = "blocked";
14
+ /** Response arrived but could not be parsed into a {@link PhotonAIGeneration}. */
15
+ PhotonAIErrorKind["InvalidResponse"] = "invalid-response";
16
+ /** The request exceeded {@link import('../../types/photon-ai.types').PhotonAIProviderConfig.requestTimeoutMs}. */
17
+ PhotonAIErrorKind["Timeout"] = "timeout";
18
+ })(PhotonAIErrorKind || (PhotonAIErrorKind = {}));
19
+ /**
20
+ * The single error type providers throw. Carries a machine-readable
21
+ * {@link PhotonAIErrorKind} (for retry/telemetry decisions) plus a
22
+ * user-facing message the panel can display verbatim.
23
+ */
24
+ export class PhotonAIProviderError extends Error {
25
+ constructor(kind, message,
26
+ /** Upstream HTTP status, when the failure originated from an HTTP response. */
27
+ status) {
28
+ super(message);
29
+ this.kind = kind;
30
+ this.status = status;
31
+ this.name = 'PhotonAIProviderError';
32
+ }
33
+ }
34
+ /** A short, friendly one-liner for each failure kind, used when a provider throws to the panel. */
35
+ export function describeProviderError(error) {
36
+ if (error instanceof PhotonAIProviderError)
37
+ return error.message;
38
+ if (error instanceof Error)
39
+ return `Photon AI request failed: ${error.message}`;
40
+ return 'Photon AI request failed due to an unexpected error.';
41
+ }
42
+ //# sourceMappingURL=ai-provider.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-provider.types.js","sourceRoot":"","sources":["../../../src/photon-ai/provider/ai-provider.types.ts"],"names":[],"mappings":"AA2JA,yGAAyG;AACzG,MAAM,CAAN,IAAY,iBAeX;AAfD,WAAY,iBAAiB;IAC3B,mEAAmE;IACnE,wCAAmB,CAAA;IACnB,8EAA8E;IAC9E,kCAAa,CAAA;IACb,kCAAkC;IAClC,6CAAwB,CAAA;IACxB,gEAAgE;IAChE,kCAAa,CAAA;IACb,0DAA0D;IAC1D,wCAAmB,CAAA;IACnB,kFAAkF;IAClF,yDAAoC,CAAA;IACpC,kHAAkH;IAClH,wCAAmB,CAAA;AACrB,CAAC,EAfW,iBAAiB,KAAjB,iBAAiB,QAe5B;AAED;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YACW,IAAuB,EAChC,OAAe;IACf,+EAA+E;IACtE,MAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QALN,SAAI,GAAJ,IAAI,CAAmB;QAGvB,WAAM,GAAN,MAAM,CAAS;QAGxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,mGAAmG;AACnG,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,KAAK,YAAY,qBAAqB;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjE,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC;IAChF,OAAO,sDAAsD,CAAC;AAChE,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { GridApi } from '../../core/grid-api';
2
+ import type { PhotonCommand } from '../photon-ai.types';
3
+ import type { PhotonAIAction } from './ai-provider.types';
4
+ /**
5
+ * Bridges a model-generated {@link PhotonAIAction} to a fully-formed
6
+ * {@link PhotonCommand} the existing `CommandExecutor` can run unchanged.
7
+ *
8
+ * A language model reliably produces the *shape* of a command (an intent key
9
+ * plus the target column and value) but not the incidental details the
10
+ * deterministic builders add for free — the display `header`, `Date` objects
11
+ * for date filters, a default operator, numeric coercion. Rather than force
12
+ * the model to reproduce all of that (fragile, token-heavy), this normalizer
13
+ * backfills it deterministically from the live grid:
14
+ *
15
+ * - resolves `colId`/`colIds` against real columns (tolerating a header used
16
+ * in place of an id, since models occasionally do that),
17
+ * - backfills the `header` param used by every intent's result message,
18
+ * - coerces `applyFilter` values to the column's type (ISO string → `Date`,
19
+ * numeric string → `number`) and defaults a sensible operator.
20
+ *
21
+ * It is intentionally the *only* place provider output is reshaped, mirroring
22
+ * the role `CommandBuilder` plays for the deterministic pipeline.
23
+ */
24
+ export declare class CommandNormalizer {
25
+ private readonly api;
26
+ constructor(api: GridApi);
27
+ /** Reshapes one action into an executable command. Never throws — worst case, the executor reports an unknown/invalid command. */
28
+ normalize(action: PhotonAIAction): PhotonCommand;
29
+ /** Resolves and canonicalizes `colId`/`colIds`, then backfills the human `header` label. */
30
+ private normalizeColumnTargets;
31
+ /** Coerces `applyFilter`'s value(s) to the target column's data type and supplies a default operator. */
32
+ private normalizeFilterParams;
33
+ /** Matches by exact colId first, then case-insensitively by header — models sometimes echo the visible header. */
34
+ private resolveColumn;
35
+ }
36
+ //# sourceMappingURL=command-normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-normalizer.d.ts","sourceRoot":"","sources":["../../../src/photon-ai/provider/command-normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,OAAO;IAEzC,kIAAkI;IAClI,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa;IAYhD,4FAA4F;IAC5F,OAAO,CAAC,sBAAsB;IAsB9B,yGAAyG;IACzG,OAAO,CAAC,qBAAqB;IAiB7B,kHAAkH;IAClH,OAAO,CAAC,aAAa;CAMtB"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Bridges a model-generated {@link PhotonAIAction} to a fully-formed
3
+ * {@link PhotonCommand} the existing `CommandExecutor` can run unchanged.
4
+ *
5
+ * A language model reliably produces the *shape* of a command (an intent key
6
+ * plus the target column and value) but not the incidental details the
7
+ * deterministic builders add for free — the display `header`, `Date` objects
8
+ * for date filters, a default operator, numeric coercion. Rather than force
9
+ * the model to reproduce all of that (fragile, token-heavy), this normalizer
10
+ * backfills it deterministically from the live grid:
11
+ *
12
+ * - resolves `colId`/`colIds` against real columns (tolerating a header used
13
+ * in place of an id, since models occasionally do that),
14
+ * - backfills the `header` param used by every intent's result message,
15
+ * - coerces `applyFilter` values to the column's type (ISO string → `Date`,
16
+ * numeric string → `number`) and defaults a sensible operator.
17
+ *
18
+ * It is intentionally the *only* place provider output is reshaped, mirroring
19
+ * the role `CommandBuilder` plays for the deterministic pipeline.
20
+ */
21
+ export class CommandNormalizer {
22
+ constructor(api) {
23
+ this.api = api;
24
+ }
25
+ /** Reshapes one action into an executable command. Never throws — worst case, the executor reports an unknown/invalid command. */
26
+ normalize(action) {
27
+ const params = { ...action.params };
28
+ this.normalizeColumnTargets(params);
29
+ if (action.type === 'applyFilter') {
30
+ this.normalizeFilterParams(params);
31
+ }
32
+ return { type: action.type, params };
33
+ }
34
+ /** Resolves and canonicalizes `colId`/`colIds`, then backfills the human `header` label. */
35
+ normalizeColumnTargets(params) {
36
+ if (typeof params.colId === 'string') {
37
+ const column = this.resolveColumn(params.colId);
38
+ if (column) {
39
+ params.colId = column.colId;
40
+ if (typeof params.header !== 'string')
41
+ params.header = column.header;
42
+ }
43
+ }
44
+ if (Array.isArray(params.colIds)) {
45
+ const columns = params.colIds
46
+ .map((id) => (typeof id === 'string' ? this.resolveColumn(id) : undefined))
47
+ .filter((c) => !!c);
48
+ if (columns.length > 0) {
49
+ params.colIds = columns.map((c) => c.colId);
50
+ if (typeof params.header !== 'string') {
51
+ params.header = columns.map((c) => c.header).join('", "');
52
+ }
53
+ }
54
+ }
55
+ }
56
+ /** Coerces `applyFilter`'s value(s) to the target column's data type and supplies a default operator. */
57
+ normalizeFilterParams(params) {
58
+ const colId = typeof params.colId === 'string' ? params.colId : undefined;
59
+ const column = colId ? this.resolveColumn(colId) : undefined;
60
+ if (!column)
61
+ return;
62
+ params.colId = column.colId;
63
+ if (typeof params.operator !== 'string') {
64
+ params.operator = defaultOperatorFor(column.type);
65
+ }
66
+ params.value = coerceValue(params.value, column.type);
67
+ if (params.valueTo !== undefined) {
68
+ params.valueTo = coerceValue(params.valueTo, column.type);
69
+ }
70
+ }
71
+ /** Matches by exact colId first, then case-insensitively by header — models sometimes echo the visible header. */
72
+ resolveColumn(idOrHeader) {
73
+ const byId = this.api.getColumn(idOrHeader);
74
+ if (byId)
75
+ return byId;
76
+ const needle = idOrHeader.trim().toLowerCase();
77
+ return this.api.getAllColumns().find((c) => c.header.toLowerCase() === needle);
78
+ }
79
+ }
80
+ /** Default operator when the model omitted one — mirrors the deterministic filter builder. */
81
+ function defaultOperatorFor(type) {
82
+ if (type === 'number' || type === 'currency' || type === 'percentage')
83
+ return 'equals';
84
+ if (type === 'date' || type === 'time')
85
+ return 'equals';
86
+ if (type === 'boolean')
87
+ return 'equals';
88
+ if (type === 'dropdown')
89
+ return 'equals';
90
+ return 'contains';
91
+ }
92
+ /** Coerces a JSON-safe primitive from the model into the runtime type the grid's filter engine expects. */
93
+ function coerceValue(value, type) {
94
+ if (value === null || value === undefined)
95
+ return value;
96
+ if (type === 'date' || type === 'time') {
97
+ if (value instanceof Date)
98
+ return value;
99
+ const date = new Date(String(value));
100
+ return Number.isNaN(date.getTime()) ? value : date;
101
+ }
102
+ if (type === 'number' || type === 'currency' || type === 'percentage') {
103
+ if (typeof value === 'number')
104
+ return value;
105
+ const num = Number(String(value).replace(/,/g, '').trim());
106
+ return Number.isNaN(num) ? value : num;
107
+ }
108
+ if (type === 'boolean') {
109
+ if (typeof value === 'boolean')
110
+ return value;
111
+ const text = String(value).trim().toLowerCase();
112
+ if (['true', 'yes', 'active', 'enabled', 'on', '1'].includes(text))
113
+ return true;
114
+ if (['false', 'no', 'inactive', 'disabled', 'off', '0'].includes(text))
115
+ return false;
116
+ return value;
117
+ }
118
+ return value;
119
+ }
120
+ //# sourceMappingURL=command-normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-normalizer.js","sourceRoot":"","sources":["../../../src/photon-ai/provider/command-normalizer.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;IAAG,CAAC;IAE7C,kIAAkI;IAClI,SAAS,CAAC,MAAsB;QAC9B,MAAM,MAAM,GAA4B,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAE7D,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,MA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AAE,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAChD,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAChF,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QACrF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { GridApi } from '../../core/grid-api';
2
+ import type { PhotonAICommandRegistry } from '../photon-ai-registry';
3
+ import type { PhotonGridContext } from './ai-provider.types';
4
+ /**
5
+ * Distills the live grid into the compact {@link PhotonGridContext} a language
6
+ * model needs to interpret a command: which columns exist, which actions are
7
+ * possible, and what the grid currently looks like.
8
+ *
9
+ * Every piece is read from the *live* {@link GridApi} and
10
+ * {@link PhotonAICommandRegistry} at build time, so the model always reasons
11
+ * over the grid's current shape — including any custom intents a host app
12
+ * registered at runtime (they appear in {@link buildCapabilities} automatically
13
+ * because it reads the registry, never a hard-coded list). This is what keeps
14
+ * the generative back-end in lock-step with the deterministic one: both are
15
+ * driven by the same registry.
16
+ */
17
+ export declare class GridContextBuilder {
18
+ private readonly api;
19
+ private readonly registry;
20
+ constructor(api: GridApi, registry: PhotonAICommandRegistry);
21
+ /** Builds a fresh snapshot. Cheap enough to call once per prompt. */
22
+ build(): PhotonGridContext;
23
+ private buildColumns;
24
+ private toColumnContext;
25
+ /** Enumerated values a `dropdown`/`enum` column accepts, so the model filters by a real value. */
26
+ private columnOptions;
27
+ /**
28
+ * The catalog of actions the model may emit — one entry per registered
29
+ * intent. Sourced from the registry so it never drifts from what
30
+ * `CommandExecutor` can actually run.
31
+ */
32
+ private buildCapabilities;
33
+ private buildState;
34
+ private buildSortState;
35
+ private buildFilterState;
36
+ }
37
+ //# sourceMappingURL=grid-context-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-context-builder.d.ts","sourceRoot":"","sources":["../../../src/photon-ai/provider/grid-context-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAMV,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,uBAAuB;IAGpD,qEAAqE;IACrE,KAAK,IAAI,iBAAiB;IAQ1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAiBvB,kGAAkG;IAClG,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;CAMzB"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Distills the live grid into the compact {@link PhotonGridContext} a language
3
+ * model needs to interpret a command: which columns exist, which actions are
4
+ * possible, and what the grid currently looks like.
5
+ *
6
+ * Every piece is read from the *live* {@link GridApi} and
7
+ * {@link PhotonAICommandRegistry} at build time, so the model always reasons
8
+ * over the grid's current shape — including any custom intents a host app
9
+ * registered at runtime (they appear in {@link buildCapabilities} automatically
10
+ * because it reads the registry, never a hard-coded list). This is what keeps
11
+ * the generative back-end in lock-step with the deterministic one: both are
12
+ * driven by the same registry.
13
+ */
14
+ export class GridContextBuilder {
15
+ constructor(api, registry) {
16
+ this.api = api;
17
+ this.registry = registry;
18
+ }
19
+ /** Builds a fresh snapshot. Cheap enough to call once per prompt. */
20
+ build() {
21
+ return {
22
+ columns: this.buildColumns(),
23
+ capabilities: this.buildCapabilities(),
24
+ state: this.buildState(),
25
+ };
26
+ }
27
+ buildColumns() {
28
+ return this.api.getAllColumns().map((col) => this.toColumnContext(col));
29
+ }
30
+ toColumnContext(col) {
31
+ const options = this.columnOptions(col);
32
+ return {
33
+ colId: col.colId,
34
+ header: col.header,
35
+ field: col.field,
36
+ type: col.type,
37
+ // These flags default to enabled in the grid, so treat "unset" as `true`.
38
+ sortable: col.sortable !== false,
39
+ filterable: col.filterable !== false,
40
+ groupable: col.groupable !== false,
41
+ pinned: col.pinned ?? null,
42
+ visible: col.visible !== false,
43
+ ...(options ? { options } : {}),
44
+ };
45
+ }
46
+ /** Enumerated values a `dropdown`/`enum` column accepts, so the model filters by a real value. */
47
+ columnOptions(col) {
48
+ if (col.dropdownOptions?.length)
49
+ return col.dropdownOptions.map((o) => o.value);
50
+ if (col.enumOptions?.length)
51
+ return col.enumOptions;
52
+ return undefined;
53
+ }
54
+ /**
55
+ * The catalog of actions the model may emit — one entry per registered
56
+ * intent. Sourced from the registry so it never drifts from what
57
+ * `CommandExecutor` can actually run.
58
+ */
59
+ buildCapabilities() {
60
+ return this.registry
61
+ .getAll()
62
+ .map((intent) => ({ type: intent.key, description: intent.description ?? intent.key }));
63
+ }
64
+ buildState() {
65
+ return {
66
+ totalRowCount: this.api.getAllRows().filter((r) => r.type === 'data').length,
67
+ visibleRowCount: this.api.getVisibleRows().filter((r) => r.type === 'data').length,
68
+ sort: this.buildSortState(),
69
+ filters: this.buildFilterState(),
70
+ groupedColumns: [...(this.api.getGridState().groupedColumns ?? [])],
71
+ selectedRowCount: this.api.getSelectedCount(),
72
+ };
73
+ }
74
+ buildSortState() {
75
+ return this.api.getSortConfig().map((s) => ({ colId: s.colId, order: s.order }));
76
+ }
77
+ buildFilterState() {
78
+ return Object.values(this.api.getFilterModel()).map((filter) => ({
79
+ colId: filter.colId,
80
+ summary: summarizeFilter(filter),
81
+ }));
82
+ }
83
+ }
84
+ /** Compresses a column filter into a single human/model-readable phrase. */
85
+ function summarizeFilter(filter) {
86
+ if (filter.selectedIds?.length)
87
+ return `in [${filter.selectedIds.join(', ')}]`;
88
+ const condition = filter.conditions[0];
89
+ if (!condition)
90
+ return 'active';
91
+ if (condition.operator === 'blank' || condition.operator === 'notBlank')
92
+ return condition.operator;
93
+ const to = condition.valueTo !== undefined ? `..${String(condition.valueTo)}` : '';
94
+ return `${condition.operator} ${String(condition.value)}${to}`;
95
+ }
96
+ //# sourceMappingURL=grid-context-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-context-builder.js","sourceRoot":"","sources":["../../../src/photon-ai/provider/grid-context-builder.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,kBAAkB;IAC7B,YACmB,GAAY,EACZ,QAAiC;QADjC,QAAG,GAAH,GAAG,CAAS;QACZ,aAAQ,GAAR,QAAQ,CAAyB;IACjD,CAAC;IAEJ,qEAAqE;IACrE,KAAK;QACH,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE;YACtC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE;SACzB,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,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W,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC/E,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS;QAAE,OAAO,QAAQ,CAAC;IAChC,IAAI,SAAS,CAAC,QAAQ,KAAK,OAAO,IAAI,SAAS,CAAC,QAAQ,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,QAAQ,CAAC;IACnG,MAAM,EAAE,GAAG,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,OAAO,GAAG,SAAS,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { PhotonAIProviderConfig } from '../../types/photon-ai.types';
2
+ import { type PhotonAIProvider, type PhotonAIProviderRequest, type PhotonAIResponse } from './ai-provider.types';
3
+ /**
4
+ * The single, provider-agnostic {@link PhotonAIProvider}. It is driven entirely
5
+ * by a consumer-supplied {@link PhotonAIProviderConfig}: pick a hosted
6
+ * {@link PhotonAIProviderType} for out-of-the-box defaults (endpoint, model,
7
+ * auth, wire format), or override any field — up to and including the full
8
+ * request/response wire format via `requestTransformer`/`responseTransformer` —
9
+ * to talk to any JSON HTTP model endpoint.
10
+ *
11
+ * Uses the native `fetch` API only (no SDK), so it runs in every browser Photon
12
+ * Grid supports. The API key is read from config at request time and applied
13
+ * with the provider's auth scheme; it is never hard-coded, cached, or logged.
14
+ * Every failure mode — HTTP errors, rate limits, auth problems, safety blocks,
15
+ * timeouts, and malformed JSON — surfaces as a categorized
16
+ * {@link PhotonAIProviderError}.
17
+ */
18
+ export declare class HttpAIProvider implements PhotonAIProvider {
19
+ private readonly type;
20
+ private readonly preset;
21
+ private readonly apiKey;
22
+ private readonly apiUrl;
23
+ private readonly model;
24
+ private readonly headers;
25
+ private readonly temperature;
26
+ private readonly timeoutMs;
27
+ private readonly transformRequest;
28
+ private readonly transformResponse;
29
+ constructor(config: PhotonAIProviderConfig);
30
+ generate(request: PhotonAIProviderRequest): Promise<PhotonAIResponse>;
31
+ /** Resolves the final URL (auth-in-query for Gemini, plain otherwise). */
32
+ private buildUrl;
33
+ /** Merges Content-Type + provider auth headers + consumer headers (consumer wins). */
34
+ private buildHeaders;
35
+ /** POSTs the request as JSON, enforcing the configured timeout via `AbortController`. */
36
+ private fetchWithTimeout;
37
+ /** Validates the HTTP status, mapping known failure statuses (auth, rate-limit) to categorized errors, and returns the parsed JSON body. */
38
+ private parseHttpResponse;
39
+ /** Best-effort extraction of a provider error message from a non-2xx body (`{ error: { message } }` or `{ error: "..." }`). */
40
+ private readErrorMessage;
41
+ }
42
+ //# sourceMappingURL=http-ai-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-ai-provider.d.ts","sourceRoot":"","sources":["../../../src/photon-ai/provider/http-ai-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAG1E,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAK7B;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAwC;IACzE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0C;gBAEhE,MAAM,EAAE,sBAAsB;IA2BpC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkB3E,0EAA0E;IAC1E,OAAO,CAAC,QAAQ;IAKhB,sFAAsF;IACtF,OAAO,CAAC,YAAY;IAKpB,yFAAyF;YAC3E,gBAAgB;IA+B9B,4IAA4I;YAC9H,iBAAiB;IAoC/B,+HAA+H;YACjH,gBAAgB;CAS/B"}