@gemies/sdk 1.1.0 → 2.0.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.
- package/CHANGELOG.md +12 -0
- package/README.md +0 -37
- package/package.json +1 -7
- package/src/components/canvas/ChartRenderer.tsx +3 -1
- package/src/components/thread/ToolResultCard.tsx +1 -1
- package/src/metro/chart-importers.json +0 -18
- package/src/metro/granular-charts.js +0 -3
- package/src/metro/index.cjs +0 -227
- package/src/metro/index.d.cts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @gemies/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
- **Lighter chat on web: the chart cards come from their own Bloom entries.** `ChartRenderer` and
|
|
6
|
+
`ToolResultCard` import `@oxy.so/bloom/chart-cards/bar-list` and `/line` instead of the
|
|
7
|
+
`chart-cards` root, which is every chart Bloom draws. Measured in the Gemies web export, the
|
|
8
|
+
first paint of `/` carries 50,210 B of chart code instead of 188,724 B. Both entries exist in
|
|
9
|
+
every Bloom the peer range admits (`>=17.41.0`), so nothing changes for a consumer.
|
|
10
|
+
- **Breaking: `@gemies/sdk/metro` is gone.** `withGemieGranularCharts` redirected those same two
|
|
11
|
+
imports at resolution time, for apps whose Bloom did not yet ship the chart entries; now the
|
|
12
|
+
SDK imports them itself, so a consumer that wrapped its Metro config with it removes the
|
|
13
|
+
wrapper and changes nothing else. No app used it.
|
|
14
|
+
|
|
3
15
|
## 1.1.0
|
|
4
16
|
|
|
5
17
|
- **New entry `@gemies/sdk/accounts`** (Gemies ADR 0035): `GemieAccounts`, the panel that links a
|
package/README.md
CHANGED
|
@@ -17,43 +17,6 @@ hooks are named `Gemie*` (`GemieChatContent`, `GemieChatSheet`, `GemieAvatar`, `
|
|
|
17
17
|
the default API is `https://api.gemies.ai` and the shared web origin is `https://gemies.ai`. The
|
|
18
18
|
mapping is in [`CHANGELOG.md`](./CHANGELOG.md) under 1.0.0.
|
|
19
19
|
|
|
20
|
-
## Optional granular chart imports for Metro
|
|
21
|
-
|
|
22
|
-
The standard SDK entries and Bloom peer range are unchanged. Apps that install a Bloom
|
|
23
|
-
version exposing `chart-cards/bar-list` and `chart-cards/line` can opt into a narrower
|
|
24
|
-
chart graph by wrapping their **finished** Metro configuration:
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
const { withGemieGranularCharts } = require('@gemies/sdk/metro');
|
|
28
|
-
|
|
29
|
-
module.exports = withGemieGranularCharts(existingMetroConfig);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
This Node-only entry wraps the previous resolver and redirects two verified chart imports
|
|
33
|
-
in this SDK copy. It delegates extra resolution probes to that resolver, so resolver
|
|
34
|
-
implementations with side effects will observe those calls. It checks that the original
|
|
35
|
-
barrel and both granular imports resolve to
|
|
36
|
-
the same physical Bloom copy for the original importer and the adapter. Both subpaths
|
|
37
|
-
must be explicit `exports` keys resolving under the active Metro conditions to files
|
|
38
|
-
inside that copy; arrays, patterns and redirects to other files are not supported.
|
|
39
|
-
The SDK importer hashes are rechecked on affected resolutions, including in watch mode.
|
|
40
|
-
Detection uses the registered paths and their real paths; new aliases introduced later
|
|
41
|
-
may be treated as unregistered, so restart Metro after changing SDK links.
|
|
42
|
-
Missing exports,
|
|
43
|
-
an altered SDK importer or incompatible metadata fail with an explicit build error; the
|
|
44
|
-
normal SDK does not require those exports when this option is not used. File hashes detect
|
|
45
|
-
changes requiring review; they do not authenticate packages.
|
|
46
|
-
|
|
47
|
-
Apply the wrapper once, after other Metro wrappers. Reapplying it directly throws;
|
|
48
|
-
register all copies together instead. Opaque wrappers or cloned configurations can
|
|
49
|
-
hide the marker; do not apply this helper again after composing them.
|
|
50
|
-
Multiple installed SDK copies are not discovered automatically. To opt in other copies,
|
|
51
|
-
pass `{ additionalSdkRoots: ['/absolute/path/to/sdk'] }`; each must ship matching opt-in
|
|
52
|
-
metadata. Unregistered copies retain their original imports and may still include the chart
|
|
53
|
-
barrel. This does not deduplicate React, Bloom or SDK providers, nor prove a bundle-size
|
|
54
|
-
reduction. Review importers, update the version and hashes in `chart-importers.json`, and
|
|
55
|
-
run the Metro tests when updating the SDK package or those files.
|
|
56
|
-
|
|
57
20
|
## Install
|
|
58
21
|
|
|
59
22
|
```sh
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemies/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
"./csp": "./src/csp.ts",
|
|
19
19
|
"./dictation": "./src/dictation.ts",
|
|
20
20
|
"./model": "./src/runtime/model.ts",
|
|
21
|
-
"./metro": {
|
|
22
|
-
"types": "./src/metro/index.d.cts",
|
|
23
|
-
"default": "./src/metro/index.cjs"
|
|
24
|
-
},
|
|
25
21
|
"./runtime": "./src/runtime/index.ts",
|
|
26
22
|
"./text": "./src/text.ts",
|
|
27
23
|
"./tools": "./src/tools.ts",
|
|
@@ -49,7 +45,6 @@
|
|
|
49
45
|
"scripts": {
|
|
50
46
|
"typecheck": "tsc --noEmit",
|
|
51
47
|
"test": "vitest run",
|
|
52
|
-
"test:metro": "node --test scripts/metro/opt-in.node.cjs",
|
|
53
48
|
"check:entries": "node scripts/check-entry-isolation.mjs",
|
|
54
49
|
"check:entry-types": "node scripts/check-entry-types.mjs"
|
|
55
50
|
},
|
|
@@ -97,7 +92,6 @@
|
|
|
97
92
|
},
|
|
98
93
|
"devDependencies": {
|
|
99
94
|
"@types/react-test-renderer": "^19.1.0",
|
|
100
|
-
"metro-resolver": "0.87.1",
|
|
101
95
|
"react-native-audio-api": "0.13.6",
|
|
102
96
|
"react-native-qrcode-svg": "^6.3.21",
|
|
103
97
|
"react-test-renderer": "19.3.0",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useLabels } from '../../lib/labels';
|
|
2
|
-
|
|
2
|
+
// The two cards by subpath: the `chart-cards` root is every chart Bloom draws (~190 KB on web).
|
|
3
|
+
import { BarListCard } from '@oxy.so/bloom/chart-cards/bar-list';
|
|
4
|
+
import { LineChartCard } from '@oxy.so/bloom/chart-cards/line';
|
|
3
5
|
import { formatNumber } from '@oxy.so/bloom/locale';
|
|
4
6
|
|
|
5
7
|
interface ChartData {
|
|
@@ -18,7 +18,7 @@ import { useGemieRuntime } from '../../runtime/config';
|
|
|
18
18
|
import { AiChatMessageLine } from '@oxy.so/bloom/ai-chat';
|
|
19
19
|
import { Badge } from '@oxy.so/bloom/badge';
|
|
20
20
|
import { Card, CardBody, CardHeader } from '@oxy.so/bloom/card';
|
|
21
|
-
import { LineChartCard } from '@oxy.so/bloom/chart-cards';
|
|
21
|
+
import { LineChartCard } from '@oxy.so/bloom/chart-cards/line';
|
|
22
22
|
import { IconCircle } from '@oxy.so/bloom/icon-circle';
|
|
23
23
|
import { RiArrowRightSLine } from '@oxy.so/bloom/icons/RiArrowRightSLine';
|
|
24
24
|
import { RiCalendarScheduleLine } from '@oxy.so/bloom/icons/RiCalendarScheduleLine';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"format": 1,
|
|
3
|
-
"sdkVersion": "1.1.0",
|
|
4
|
-
"adapter": {
|
|
5
|
-
"path": "src/metro/granular-charts.js",
|
|
6
|
-
"sha256": "252add5b6642f8637f9b044a76fd05aff52fc9751bcff3e3587a95444f9ec1c1"
|
|
7
|
-
},
|
|
8
|
-
"importers": [
|
|
9
|
-
{
|
|
10
|
-
"path": "src/components/thread/ToolResultCard.tsx",
|
|
11
|
-
"sha256": "887ee8e6e586248a172ab0234450498463f660a707c0a402c8ceba7b0cfc8932"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"path": "src/components/canvas/ChartRenderer.tsx",
|
|
15
|
-
"sha256": "14a6c3a6531a706f3b5c7b135034dfaaf6abe236acc53f98524bfcbb52d3d755"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
package/src/metro/index.cjs
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Optional Metro-only resolver for Alia's chart imports. The regular SDK entries
|
|
5
|
-
* and their Bloom peer remain unchanged. Each opted-in SDK copy carries the
|
|
6
|
-
* exact importers and adapter it supports; an unknown copy fails explicitly.
|
|
7
|
-
*/
|
|
8
|
-
const fs = require('node:fs');
|
|
9
|
-
const path = require('node:path');
|
|
10
|
-
const crypto = require('node:crypto');
|
|
11
|
-
|
|
12
|
-
const SDK_ROOT = path.resolve(__dirname, '../..');
|
|
13
|
-
const LEGACY = '@oxy.so/bloom/chart-cards';
|
|
14
|
-
const GRANULAR = [`${LEGACY}/bar-list`, `${LEGACY}/line`];
|
|
15
|
-
const PREFIX = '[Gemies granular charts]';
|
|
16
|
-
const WRAPPED = Symbol.for('@gemies/sdk/metro/granular-charts-resolver/v1');
|
|
17
|
-
|
|
18
|
-
function checkedFile(root, entry) {
|
|
19
|
-
if (!entry || typeof entry.path !== 'string' || !/^[a-f0-9]{64}$/.test(entry.sha256 ?? '')) {
|
|
20
|
-
throw new Error(`${PREFIX} invalid SDK manifest entry`);
|
|
21
|
-
}
|
|
22
|
-
let actual;
|
|
23
|
-
try {
|
|
24
|
-
actual = fs.realpathSync(path.resolve(root, entry.path));
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw new Error(`${PREFIX} missing SDK file ${entry.path}`, { cause: error });
|
|
27
|
-
}
|
|
28
|
-
if (!actual.startsWith(`${root}${path.sep}`))
|
|
29
|
-
throw new Error(`${PREFIX} SDK file escapes its package`);
|
|
30
|
-
const digest = crypto.createHash('sha256').update(fs.readFileSync(actual)).digest('hex');
|
|
31
|
-
if (digest !== entry.sha256) throw new Error(`${PREFIX} changed SDK file ${entry.path}`);
|
|
32
|
-
return actual;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function collectTargets(roots) {
|
|
36
|
-
const targets = new Map();
|
|
37
|
-
for (const input of roots) {
|
|
38
|
-
let root, pkg, metadata;
|
|
39
|
-
try {
|
|
40
|
-
root = fs.realpathSync(input);
|
|
41
|
-
pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
42
|
-
metadata = JSON.parse(
|
|
43
|
-
fs.readFileSync(path.join(root, 'src/metro/chart-importers.json'), 'utf8'),
|
|
44
|
-
);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
throw new Error(`${PREFIX} SDK copy lacks opt-in metadata`, { cause: error });
|
|
47
|
-
}
|
|
48
|
-
if (
|
|
49
|
-
pkg.name !== '@gemies/sdk' ||
|
|
50
|
-
metadata.format !== 1 ||
|
|
51
|
-
metadata.sdkVersion !== pkg.version ||
|
|
52
|
-
!Array.isArray(metadata.importers) ||
|
|
53
|
-
metadata.importers.length !== 2
|
|
54
|
-
) {
|
|
55
|
-
throw new Error(`${PREFIX} unsupported SDK copy or version`);
|
|
56
|
-
}
|
|
57
|
-
const adapter = checkedFile(root, metadata.adapter);
|
|
58
|
-
for (const importer of metadata.importers) {
|
|
59
|
-
const target = { root, adapter };
|
|
60
|
-
targets.set(checkedFile(root, importer), target);
|
|
61
|
-
targets.set(path.resolve(root, importer.path), target);
|
|
62
|
-
targets.set(path.resolve(input, importer.path), target);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return targets;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function sourceFile(resolution, name) {
|
|
69
|
-
if (resolution?.type !== 'sourceFile' || typeof resolution.filePath !== 'string') {
|
|
70
|
-
throw new Error(`${PREFIX} ${name} did not resolve to a source file`);
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
return fs.realpathSync(resolution.filePath);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
throw new Error(`${PREFIX} ${name} resolved to a missing file`, { cause: error });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function bloomRoot(file) {
|
|
80
|
-
let dir = path.dirname(file);
|
|
81
|
-
for (;;) {
|
|
82
|
-
const manifest = path.join(dir, 'package.json');
|
|
83
|
-
if (fs.existsSync(manifest)) {
|
|
84
|
-
let pkg;
|
|
85
|
-
try {
|
|
86
|
-
pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw new Error(`${PREFIX} invalid package manifest`, { cause: error });
|
|
89
|
-
}
|
|
90
|
-
if (pkg.name === '@oxy.so/bloom') return fs.realpathSync(dir);
|
|
91
|
-
}
|
|
92
|
-
const parent = path.dirname(dir);
|
|
93
|
-
if (parent === dir) throw new Error(`${PREFIX} resolved file is not inside Bloom`);
|
|
94
|
-
dir = parent;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Resolve only explicit, file-valued exports with Metro's active conditions. */
|
|
99
|
-
function exportedFile(root, entry, context, platform, subpath) {
|
|
100
|
-
const names = new Set([
|
|
101
|
-
'default',
|
|
102
|
-
context.isESMImport === true ? 'import' : 'require',
|
|
103
|
-
...(context.unstable_conditionNames ?? []),
|
|
104
|
-
...(context.unstable_conditionsByPlatform?.[platform] ?? []),
|
|
105
|
-
]);
|
|
106
|
-
let target = entry;
|
|
107
|
-
while (target && typeof target === 'object' && !Array.isArray(target)) {
|
|
108
|
-
const key = Object.keys(target).find((condition) => names.has(condition));
|
|
109
|
-
target = key === undefined ? null : target[key];
|
|
110
|
-
}
|
|
111
|
-
if (
|
|
112
|
-
typeof target !== 'string' ||
|
|
113
|
-
!target.startsWith('./') ||
|
|
114
|
-
target.includes('\\') ||
|
|
115
|
-
target.includes('*') ||
|
|
116
|
-
target.split('/').some((segment) => segment === '..' || segment === 'node_modules')
|
|
117
|
-
) {
|
|
118
|
-
throw new Error(`${PREFIX} ${subpath} has no supported export for ${platform}`);
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
const file = fs.realpathSync(path.resolve(root, target));
|
|
122
|
-
if (!file.startsWith(`${root}${path.sep}`) || !fs.statSync(file).isFile())
|
|
123
|
-
throw new Error('invalid target');
|
|
124
|
-
return file;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw new Error(`${PREFIX} ${subpath} export target is unavailable for ${platform}`, {
|
|
127
|
-
cause: error,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Wrap a finished Metro config. Only the two verified importers in each
|
|
134
|
-
* explicitly opted-in SDK copy are redirected. Register other installed copies
|
|
135
|
-
* through `additionalSdkRoots`; unregistered copies use their original path.
|
|
136
|
-
* The app must install Bloom with both granular chart subpaths.
|
|
137
|
-
*
|
|
138
|
-
* @param {object} config Metro config, after the app's other resolver wrappers.
|
|
139
|
-
* @param {{additionalSdkRoots?: string[]}} [options]
|
|
140
|
-
* @returns {object} The same config, with its previous resolver preserved.
|
|
141
|
-
*/
|
|
142
|
-
function withGemieGranularCharts(config, options = {}) {
|
|
143
|
-
if (!Array.isArray(options.additionalSdkRoots ?? []))
|
|
144
|
-
throw new Error(`${PREFIX} additionalSdkRoots must be an array`);
|
|
145
|
-
const previous = config.resolver?.resolveRequest;
|
|
146
|
-
if (config[WRAPPED] || previous?.[WRAPPED]) {
|
|
147
|
-
throw new Error(
|
|
148
|
-
`${PREFIX} already configured; register all SDK copies with additionalSdkRoots in one call`,
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
const targets = collectTargets([SDK_ROOT, ...(options.additionalSdkRoots ?? [])]);
|
|
152
|
-
config.resolver ??= {};
|
|
153
|
-
const delegate = (context, name, platform) =>
|
|
154
|
-
previous ? previous(context, name, platform) : context.resolveRequest(context, name, platform);
|
|
155
|
-
const wrapped = (context, name, platform) => {
|
|
156
|
-
if (name !== LEGACY) return delegate(context, name, platform);
|
|
157
|
-
const lexicalOrigin = path.resolve(context.originModulePath);
|
|
158
|
-
const lexicalTarget = targets.get(lexicalOrigin);
|
|
159
|
-
let origin;
|
|
160
|
-
try {
|
|
161
|
-
origin = fs.realpathSync(lexicalOrigin);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
if (lexicalTarget) throw new Error(`${PREFIX} SDK importer is missing`, { cause: error });
|
|
164
|
-
return delegate(context, name, platform);
|
|
165
|
-
}
|
|
166
|
-
const registered = lexicalTarget ?? targets.get(origin);
|
|
167
|
-
if (!registered) return delegate(context, name, platform);
|
|
168
|
-
const refreshed = collectTargets([registered.root]).get(origin);
|
|
169
|
-
if (!refreshed || refreshed.adapter !== registered.adapter) {
|
|
170
|
-
throw new Error(`${PREFIX} SDK targets changed; restart Metro`);
|
|
171
|
-
}
|
|
172
|
-
const adapter = refreshed.adapter;
|
|
173
|
-
|
|
174
|
-
let legacy;
|
|
175
|
-
try {
|
|
176
|
-
legacy = sourceFile(delegate(context, LEGACY, platform), LEGACY);
|
|
177
|
-
} catch (error) {
|
|
178
|
-
throw new Error(`${PREFIX} the original Bloom chart barrel is unavailable for ${platform}`, {
|
|
179
|
-
cause: error,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
const expectedBloom = bloomRoot(legacy);
|
|
183
|
-
const bloom = JSON.parse(fs.readFileSync(path.join(expectedBloom, 'package.json'), 'utf8'));
|
|
184
|
-
const adapterContext = { ...context, originModulePath: adapter };
|
|
185
|
-
for (const subpath of GRANULAR) {
|
|
186
|
-
const exported = `.${subpath.slice('@oxy.so/bloom'.length)}`;
|
|
187
|
-
if (!bloom.exports || !Object.hasOwn(bloom.exports, exported)) {
|
|
188
|
-
throw new Error(
|
|
189
|
-
`${PREFIX} ${subpath} is not exported by this Bloom; install a compatible Bloom`,
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
const publicTarget = exportedFile(
|
|
193
|
-
expectedBloom,
|
|
194
|
-
bloom.exports[exported],
|
|
195
|
-
context,
|
|
196
|
-
platform,
|
|
197
|
-
subpath,
|
|
198
|
-
);
|
|
199
|
-
let originalTarget, adapterTarget;
|
|
200
|
-
try {
|
|
201
|
-
originalTarget = sourceFile(delegate(context, subpath, platform), subpath);
|
|
202
|
-
adapterTarget = sourceFile(delegate(adapterContext, subpath, platform), subpath);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
throw new Error(
|
|
205
|
-
`${PREFIX} ${subpath} is unavailable for ${platform}; install a compatible Bloom`,
|
|
206
|
-
{ cause: error },
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
if (originalTarget !== adapterTarget || bloomRoot(originalTarget) !== expectedBloom) {
|
|
210
|
-
throw new Error(`${PREFIX} ${subpath} selects a different Bloom copy for ${platform}`);
|
|
211
|
-
}
|
|
212
|
-
if (originalTarget !== publicTarget) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`${PREFIX} ${subpath} did not resolve to its declared public export for ${platform}`,
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const resolvedAdapter = sourceFile(delegate(context, adapter, platform), 'SDK chart adapter');
|
|
219
|
-
if (resolvedAdapter !== adapter) throw new Error(`${PREFIX} SDK chart adapter was redirected`);
|
|
220
|
-
return { type: 'sourceFile', filePath: adapter };
|
|
221
|
-
};
|
|
222
|
-
Object.defineProperty(wrapped, WRAPPED, { value: true });
|
|
223
|
-
Object.defineProperty(config, WRAPPED, { value: true, enumerable: true });
|
|
224
|
-
config.resolver.resolveRequest = wrapped;
|
|
225
|
-
return config;
|
|
226
|
-
}
|
|
227
|
-
module.exports = { withGemieGranularCharts };
|