@ramme-io/kernel 6.0.0 → 6.0.2

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 (51) hide show
  1. package/dist/AiGateway-DsVWU6ih.js +3619 -0
  2. package/dist/index.es.js +5075 -4786
  3. package/dist/kernel/src/apps/quantize.d.ts +50 -0
  4. package/dist/kernel/src/apps/quantize.d.ts.map +1 -0
  5. package/dist/kernel/src/apps/spriteGrid.d.ts +47 -0
  6. package/dist/kernel/src/apps/spriteGrid.d.ts.map +1 -0
  7. package/dist/kernel/src/auth/AuthContext.d.ts +1 -1
  8. package/dist/kernel/src/auth/AuthContext.d.ts.map +1 -1
  9. package/dist/kernel/src/components/ThemeStudio.d.ts.map +1 -1
  10. package/dist/kernel/src/components/settings/AiSettingsPanel.d.ts.map +1 -1
  11. package/dist/kernel/src/config/app.manifest.d.ts +1 -1
  12. package/dist/kernel/src/engine/runtime/ManifestContext.d.ts +94 -94
  13. package/dist/kernel/src/engine/runtime/useLiveBridge.d.ts +93 -93
  14. package/dist/kernel/src/hooks/useAIKeyOrchestrator.d.ts +2 -2
  15. package/dist/kernel/src/hooks/useDevice.d.ts +5 -5
  16. package/dist/kernel/src/hooks/useDevice.d.ts.map +1 -1
  17. package/dist/kernel/src/index.d.ts +3 -0
  18. package/dist/kernel/src/index.d.ts.map +1 -1
  19. package/dist/kernel/src/renderers/AppDocumentRenderer.d.ts +39 -0
  20. package/dist/kernel/src/renderers/AppDocumentRenderer.d.ts.map +1 -0
  21. package/dist/kernel/src/server.d.ts +2 -0
  22. package/dist/kernel/src/server.d.ts.map +1 -1
  23. package/dist/kernel/src/services/NeuralGateway.d.ts.map +1 -1
  24. package/dist/kernel/src/services/ai/ConfigResolver.d.ts.map +1 -1
  25. package/dist/kernel/src/services/ai/generateAppDocument.d.ts +61 -0
  26. package/dist/kernel/src/services/ai/generateAppDocument.d.ts.map +1 -0
  27. package/dist/kernel/src/services/ai/models.test.d.ts +2 -0
  28. package/dist/kernel/src/services/ai/models.test.d.ts.map +1 -0
  29. package/dist/kernel/src/services/ai/providers/AnthropicAdapter.d.ts +17 -2
  30. package/dist/kernel/src/services/ai/providers/AnthropicAdapter.d.ts.map +1 -1
  31. package/dist/kernel/src/services/ai/providers/DeepSeekAdapter.d.ts +2 -2
  32. package/dist/kernel/src/services/ai/providers/DeepSeekAdapter.d.ts.map +1 -1
  33. package/dist/kernel/src/services/ai/providers/GeminiAdapter.d.ts.map +1 -1
  34. package/dist/kernel/src/services/ai/providers/GrokAdapter.d.ts +2 -2
  35. package/dist/kernel/src/services/ai/providers/GrokAdapter.d.ts.map +1 -1
  36. package/dist/kernel/src/services/ai/providers/OllamaAdapter.d.ts +1 -1
  37. package/dist/kernel/src/services/ai/providers/OllamaAdapter.d.ts.map +1 -1
  38. package/dist/kernel/src/services/ai/providers/OpenAIAdapter.d.ts +1 -1
  39. package/dist/kernel/src/services/ai/providers/OpenAIAdapter.d.ts.map +1 -1
  40. package/dist/kernel/src/services/ai/providers/openAiCompatibleStreamChat.d.ts +1 -1
  41. package/dist/kernel/src/services/ai/providers/openAiCompatibleStreamChat.d.ts.map +1 -1
  42. package/dist/kernel/src/setupTests.d.ts +2 -0
  43. package/dist/kernel/src/setupTests.d.ts.map +1 -0
  44. package/dist/kernel/src/stores/useSettingsStore.d.ts +1 -1
  45. package/dist/kernel/src/stores/useSettingsStore.d.ts.map +1 -1
  46. package/dist/kernel/src/stores/useSettingsStore.test.d.ts +2 -0
  47. package/dist/kernel/src/stores/useSettingsStore.test.d.ts.map +1 -0
  48. package/dist/kernel/src/utils/validationUtils.d.ts +103 -103
  49. package/dist/server.es.js +105 -42
  50. package/package.json +12 -4
  51. package/dist/AiGateway-DLGiTtyR.js +0 -3001
package/dist/server.es.js CHANGED
@@ -1,18 +1,18 @@
1
- import { p as o, a as i, q as l } from "./AiGateway-DLGiTtyR.js";
2
- import { g as _, m as v, A as I, e as O, c as R, h as T, o as g, B as w, k as K, E as k, l as f, G as L, j as P, I as N, O as D, i as b, n as x, P as M, R as j, S as F, T as q, W as B, f as H, b as U } from "./AiGateway-DLGiTtyR.js";
3
- import { streamText as A, generateObject as y } from "ai";
4
- import { createGoogleGenerativeAI as c } from "@ai-sdk/google";
5
- function n(e) {
6
- const s = typeof process < "u" ? process.env.GOOGLE_GENERATIVE_AI_API_KEY : void 0, t = e || s;
7
- if (!t)
1
+ import { C as d, a as E, H as O, J as y, K as G, n as _, L as T } from "./AiGateway-DsVWU6ih.js";
2
+ import { k as J, w as b, A as k, i as x, g as L, o as M, z as Y, B as F, r as H, E as U, v as q, G as z, q as B, I as C, O as V, p as W, y as X, x as Q, R as Z, S as ee, T as te, W as ae, j as se, b as re } from "./AiGateway-DsVWU6ih.js";
3
+ import { streamText as w, generateObject as $ } from "ai";
4
+ import { createGoogleGenerativeAI as S } from "@ai-sdk/google";
5
+ function A(e) {
6
+ const a = typeof process < "u" ? process.env.GOOGLE_GENERATIVE_AI_API_KEY : void 0, s = e || a;
7
+ if (!s)
8
8
  throw new Error(
9
9
  `[NeuralGateway] No API key found.
10
10
  — Server: Set GOOGLE_GENERATIVE_AI_API_KEY in .env.local
11
11
  — Client: Pass apiKey via request body`
12
12
  );
13
- return t;
13
+ return s;
14
14
  }
15
- const E = {
15
+ const P = {
16
16
  /**
17
17
  * Generate a validated, typed object using the Vercel AI SDK.
18
18
  *
@@ -25,13 +25,13 @@ const E = {
25
25
  * @param opts.apiKey - Optional client-provided key
26
26
  */
27
27
  async generateSchema(e) {
28
- const s = n(e.apiKey), t = c({ apiKey: s }), a = e.role ? o[e.role] : null, r = e.model ?? (a == null ? void 0 : a.model) ?? l, m = e.temperature ?? (a == null ? void 0 : a.temperature) ?? 0.3;
29
- return (await y({
30
- model: t(r),
28
+ const a = A(e.apiKey), s = S({ apiKey: a }), t = e.role ? d[e.role] : null, r = e.model ?? (t == null ? void 0 : t.model) ?? O, o = e.temperature ?? (t == null ? void 0 : t.temperature) ?? 0.3;
29
+ return (await $({
30
+ model: s(r),
31
31
  schema: e.schema,
32
32
  prompt: e.prompt,
33
33
  ...e.system ? { system: e.system } : {},
34
- temperature: m
34
+ temperature: o
35
35
  })).object;
36
36
  },
37
37
  /**
@@ -47,38 +47,101 @@ const E = {
47
47
  * @returns A Response object — directly return this from your route handler.
48
48
  */
49
49
  streamChatResponse(e) {
50
- const s = n(e.apiKey), t = c({ apiKey: s }), a = e.role ? o[e.role] : null, r = e.model ?? (a == null ? void 0 : a.model) ?? i;
51
- return e.temperature ?? (a == null || a.temperature), A({
52
- model: t(r),
50
+ const a = A(e.apiKey), s = S({ apiKey: a }), t = e.role ? d[e.role] : null, r = e.model ?? (t == null ? void 0 : t.model) ?? E, o = e.temperature ?? (t == null ? void 0 : t.temperature) ?? 0.5;
51
+ return w({
52
+ model: s(r),
53
53
  messages: e.messages,
54
- system: e.system
54
+ system: e.system,
55
+ temperature: o
55
56
  }).toTextStreamResponse();
56
57
  }
57
58
  };
59
+ class g extends Error {
60
+ constructor(a, s, t) {
61
+ super(a), this.issues = s, this.attempts = t, this.name = "AppDocumentGenerationError";
62
+ }
63
+ }
64
+ const v = (e) => {
65
+ const a = e.match(/```(?:json)?\s*([\s\S]*?)```/), s = (a ? a[1] : e).trim(), t = s.indexOf("{"), r = s.lastIndexOf("}");
66
+ return t === -1 || r === -1 || r <= t ? s : s.slice(t, r + 1);
67
+ }, R = (e) => e.issues.map((a) => `${a.path.join(".") || "(root)"}: ${a.message}`), D = async ({
68
+ request: e,
69
+ current: a,
70
+ complete: s,
71
+ maxRepairs: t = 2
72
+ }) => {
73
+ const r = `Today is ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.`, o = a ? `${y}
74
+
75
+ ${r}
76
+
77
+ ${G}
78
+ ${JSON.stringify(a)}
79
+
80
+ Request: ${e}` : `${y}
81
+
82
+ ${r}
83
+
84
+ Request: ${e}`;
85
+ let n = o, c = [];
86
+ for (let l = 0; l <= t; l += 1) {
87
+ const h = await s(n);
88
+ let p;
89
+ try {
90
+ p = JSON.parse(v(h));
91
+ } catch {
92
+ c = ["the reply was not JSON"], n = `${o}
93
+
94
+ Your last reply was not valid JSON. Reply with the JSON object only.`;
95
+ continue;
96
+ }
97
+ const u = _(p), i = T.safeParse(u.value);
98
+ if (i.success && u.issues.length === 0)
99
+ return { document: i.data, repairs: l };
100
+ c = [
101
+ ...u.issues.map((m) => `${m.path.join(".") || "(root)"}: ${m.message}`),
102
+ ...i.success ? [] : R(i.error)
103
+ ], n = `${o}
104
+
105
+ Your last reply did not validate:
106
+ ${c.map((m) => `- ${m}`).join(`
107
+ `)}
108
+ Here it is:
109
+ ${JSON.stringify(p)}
110
+
111
+ Return the corrected JSON object only.`;
112
+ }
113
+ throw new g(
114
+ "The model could not produce a valid app document.",
115
+ c,
116
+ t + 1
117
+ );
118
+ };
58
119
  export {
59
- _ as AGENT_ROSTER,
60
- v as ActionSchema,
61
- I as AiConfigResolver,
62
- O as AiGateway,
63
- R as AiGatewayService,
64
- T as AnthropicAdapter,
65
- g as AppSpecificationSchema,
66
- w as BlockSchema,
67
- K as DeepSeekAdapter,
68
- k as EntitySchema,
69
- f as FieldSchema,
70
- L as GeminiAdapter,
71
- P as GrokAdapter,
72
- N as InMemoryRateLimiter,
73
- E as NeuralGateway,
74
- D as OllamaAdapter,
75
- b as OpenAIAdapter,
76
- x as PageSchema,
77
- M as PageSectionSchema,
78
- j as ResourceSchema,
79
- F as SignalSchema,
80
- q as TriggerSchema,
81
- B as WorkflowSchema,
82
- H as aiGateway,
83
- U as aiGatewayService
120
+ J as AGENT_ROSTER,
121
+ b as ActionSchema,
122
+ k as AiConfigResolver,
123
+ x as AiGateway,
124
+ L as AiGatewayService,
125
+ M as AnthropicAdapter,
126
+ g as AppDocumentGenerationError,
127
+ Y as AppSpecificationSchema,
128
+ F as BlockSchema,
129
+ H as DeepSeekAdapter,
130
+ U as EntitySchema,
131
+ q as FieldSchema,
132
+ z as GeminiAdapter,
133
+ B as GrokAdapter,
134
+ C as InMemoryRateLimiter,
135
+ P as NeuralGateway,
136
+ V as OllamaAdapter,
137
+ W as OpenAIAdapter,
138
+ X as PageSchema,
139
+ Q as PageSectionSchema,
140
+ Z as ResourceSchema,
141
+ ee as SignalSchema,
142
+ te as TriggerSchema,
143
+ ae as WorkflowSchema,
144
+ se as aiGateway,
145
+ re as aiGatewayService,
146
+ D as generateAppDocument
84
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramme-io/kernel",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@ai-sdk/google": ">=0.0.1",
31
- "@ramme-io/ui": ">=4.1.0",
31
+ "@ramme-io/ui": ">=4.1.1",
32
32
  "ai": ">=4.0.0",
33
33
  "react": ">=18.2.0",
34
34
  "react-dom": ">=18.2.0",
@@ -37,16 +37,22 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@ai-sdk/google": "^3.0.1",
40
+ "@testing-library/jest-dom": "^6.9.1",
41
+ "@testing-library/react": "^16.3.2",
42
+ "@types/node": "^20.14.10",
40
43
  "@types/react": "^18.3.3",
41
44
  "@types/react-dom": "^18.3.0",
45
+ "@vitejs/plugin-react": "^4.3.1",
42
46
  "ai": "^6.0.3",
47
+ "jsdom": "^29.0.0",
43
48
  "react": "^18.2.0",
44
49
  "react-dom": "^18.2.0",
45
50
  "react-router-dom": "^6.28.0",
46
51
  "vite": "^5.3.1",
47
52
  "vite-plugin-dts": "^3.9.1",
53
+ "vitest": "^2.1.9",
48
54
  "zod": "^3.23.8",
49
- "@ramme-io/ui": "4.1.0"
55
+ "@ramme-io/ui": "4.1.1"
50
56
  },
51
57
  "dependencies": {
52
58
  "@types/react-syntax-highlighter": "^15.5.13",
@@ -60,6 +66,8 @@
60
66
  "@ramme-io/shared": "3.1.2"
61
67
  },
62
68
  "scripts": {
63
- "build": "vite build"
69
+ "build": "vite build",
70
+ "test": "vitest run",
71
+ "typecheck": "tsc --noEmit -p tsconfig.json"
64
72
  }
65
73
  }