@agent-native/core 0.114.2 → 0.114.3
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +24 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/db/request-telemetry.ts +32 -8
- package/corpus/core/src/settings/store.ts +15 -6
- package/corpus/core/src/shared/optional-node-builtins.ts +66 -0
- package/corpus/core/src/templates/default/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/core/src/templates/headless/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/core/src/vite/client.ts +5 -0
- package/corpus/templates/analytics/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/assets/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +2 -2
- package/corpus/templates/brain/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/calendar/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/chat/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/clips/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/clips/shared/feature-flags.ts +1 -1
- package/corpus/templates/content/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/design/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/design/actions/update-file.ts +10 -1
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +30 -1
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +14 -1
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +547 -50
- package/corpus/templates/design/app/components/design/dnd-debug.ts +27 -0
- package/corpus/templates/design/app/components/design/multi-screen/draft-primitives.ts +19 -2
- package/corpus/templates/design/app/i18n-data.ts +19 -0
- package/corpus/templates/design/app/lib/design-save-outbox.ts +46 -2
- package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +4 -9
- package/corpus/templates/design/app/pages/design-editor/history.ts +14 -1
- package/corpus/templates/design/changelog/2026-07-17-drawn-shapes-stay-free-positioned-when-dragged.md +6 -0
- package/corpus/templates/design/changelog/2026-07-17-shapes-show-a-live-outline-while-you-draw.md +6 -0
- package/corpus/templates/design/shared/drag-reflow.ts +375 -0
- package/corpus/templates/design/shared/full-app.ts +1 -1
- package/corpus/templates/dispatch/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/forms/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/macros/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/mail/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/plan/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/slides/.agents/skills/feature-flags/SKILL.md +1 -1
- package/corpus/templates/tasks/.agents/skills/feature-flags/SKILL.md +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/request-telemetry.d.ts.map +1 -1
- package/dist/db/request-telemetry.js +24 -6
- package/dist/db/request-telemetry.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/settings/store.d.ts +1 -1
- package/dist/settings/store.d.ts.map +1 -1
- package/dist/settings/store.js +14 -6
- package/dist/settings/store.js.map +1 -1
- package/dist/shared/optional-node-builtins.d.ts +23 -0
- package/dist/shared/optional-node-builtins.d.ts.map +1 -0
- package/dist/shared/optional-node-builtins.js +35 -0
- package/dist/shared/optional-node-builtins.js.map +1 -0
- package/dist/templates/chat/.agents/skills/feature-flags/SKILL.md +1 -1
- package/dist/templates/default/.agents/skills/feature-flags/SKILL.md +1 -1
- package/dist/templates/headless/.agents/skills/feature-flags/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +2 -0
- package/dist/vite/client.js.map +1 -1
- package/package.json +2 -1
- package/src/db/request-telemetry.ts +32 -8
- package/src/settings/store.ts +15 -6
- package/src/shared/optional-node-builtins.ts +66 -0
- package/src/templates/chat/.agents/skills/feature-flags/SKILL.md +1 -1
- package/src/templates/default/.agents/skills/feature-flags/SKILL.md +1 -1
- package/src/templates/headless/.agents/skills/feature-flags/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/feature-flags/SKILL.md +1 -1
- package/src/vite/client.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.3",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
"./application-state": "./dist/application-state/index.js",
|
|
160
160
|
"./settings": "./dist/settings/index.js",
|
|
161
161
|
"./feature-flags": "./dist/feature-flags/index.js",
|
|
162
|
+
"./feature-flags/registry": "./dist/feature-flags/registry.js",
|
|
162
163
|
"./feature-flags/actions/get-feature-flags": "./dist/feature-flags/actions/get-feature-flags.js",
|
|
163
164
|
"./feature-flags/actions/list-feature-flags": "./dist/feature-flags/actions/list-feature-flags.js",
|
|
164
165
|
"./feature-flags/actions/set-feature-flag": "./dist/feature-flags/actions/set-feature-flag.js",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAsyncLocalStorageCtor } from "../shared/optional-node-builtins.js";
|
|
2
2
|
|
|
3
3
|
export type DatabaseOperationKind = "connect" | "query";
|
|
4
4
|
|
|
@@ -30,15 +30,39 @@ interface StartupDatabaseTelemetryState {
|
|
|
30
30
|
claimed: boolean;
|
|
31
31
|
telemetry: DatabaseRequestTelemetry;
|
|
32
32
|
}
|
|
33
|
+
interface TelemetryStorage {
|
|
34
|
+
getStore(): DatabaseRequestTelemetry | undefined;
|
|
35
|
+
run<T>(store: DatabaseRequestTelemetry, fn: () => T): T;
|
|
36
|
+
enterWith(store: DatabaseRequestTelemetry): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
type GlobalWithDatabaseTelemetry = typeof globalThis & {
|
|
34
|
-
[STORAGE_KEY]?:
|
|
40
|
+
[STORAGE_KEY]?: TelemetryStorage;
|
|
35
41
|
[STARTUP_STATE_KEY]?: StartupDatabaseTelemetryState;
|
|
36
42
|
};
|
|
37
43
|
|
|
38
44
|
const globalRef = globalThis as GlobalWithDatabaseTelemetry;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
|
|
46
|
+
// AsyncLocalStorage is resolved lazily, never at module load: this module can
|
|
47
|
+
// land in the browser dev graph, where a top-level `new AsyncLocalStorage()`
|
|
48
|
+
// would throw against Vite's externalized `node:async_hooks` stub. On non-Node
|
|
49
|
+
// runtimes telemetry no-ops.
|
|
50
|
+
const NOOP_STORAGE: TelemetryStorage = {
|
|
51
|
+
getStore: () => undefined,
|
|
52
|
+
run: (_store, fn) => fn(),
|
|
53
|
+
enterWith: () => {},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function getStorage(): TelemetryStorage {
|
|
57
|
+
const existing = globalRef[STORAGE_KEY];
|
|
58
|
+
if (existing) return existing;
|
|
59
|
+
const Ctor = getAsyncLocalStorageCtor();
|
|
60
|
+
const created: TelemetryStorage = Ctor
|
|
61
|
+
? new Ctor<DatabaseRequestTelemetry>()
|
|
62
|
+
: NOOP_STORAGE;
|
|
63
|
+
globalRef[STORAGE_KEY] = created;
|
|
64
|
+
return created;
|
|
65
|
+
}
|
|
42
66
|
|
|
43
67
|
export function createDatabaseRequestTelemetry(): DatabaseRequestTelemetry {
|
|
44
68
|
return {
|
|
@@ -66,7 +90,7 @@ const startupState =
|
|
|
66
90
|
});
|
|
67
91
|
|
|
68
92
|
function currentDatabaseTelemetry(): DatabaseRequestTelemetry | undefined {
|
|
69
|
-
const requestTelemetry =
|
|
93
|
+
const requestTelemetry = getStorage().getStore();
|
|
70
94
|
if (requestTelemetry) return requestTelemetry;
|
|
71
95
|
if (!startupState.claimed && Date.now() <= startupState.captureUntil) {
|
|
72
96
|
return startupState.telemetry;
|
|
@@ -86,13 +110,13 @@ export function runWithDatabaseRequestTelemetry<T>(
|
|
|
86
110
|
telemetry: DatabaseRequestTelemetry,
|
|
87
111
|
fn: () => T,
|
|
88
112
|
): T {
|
|
89
|
-
return
|
|
113
|
+
return getStorage().run(telemetry, fn);
|
|
90
114
|
}
|
|
91
115
|
|
|
92
116
|
export function enterDatabaseRequestTelemetry(
|
|
93
117
|
telemetry: DatabaseRequestTelemetry,
|
|
94
118
|
): void {
|
|
95
|
-
|
|
119
|
+
getStorage().enterWith(telemetry);
|
|
96
120
|
}
|
|
97
121
|
|
|
98
122
|
export function beginDatabaseOperation(
|
package/src/settings/store.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
1
|
+
import type { EventEmitter } from "node:events";
|
|
2
2
|
|
|
3
3
|
import { getDbExec, isPostgres, intType } from "../db/client.js";
|
|
4
4
|
import { ensureIndexExists, ensureTableExists } from "../db/ddl-guard.js";
|
|
5
5
|
import { widenIntColumnsToBigInt } from "../db/widen-columns.js";
|
|
6
6
|
import { getRequestContext } from "../server/request-context.js";
|
|
7
|
+
import { createEventEmitter } from "../shared/optional-node-builtins.js";
|
|
7
8
|
|
|
8
9
|
let _initPromise: Promise<void> | undefined;
|
|
9
10
|
|
|
@@ -29,12 +30,20 @@ function requestSettingsCache(): Map<string, string | null> | null {
|
|
|
29
30
|
return cache;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
// Created lazily so this module can be evaluated in the browser dev graph
|
|
34
|
+
// without a top-level `new EventEmitter()` tripping Vite's externalized
|
|
35
|
+
// `node:events` stub. The emitter drives server-side SSE fan-out only.
|
|
36
|
+
let _emitter: EventEmitter | undefined;
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
function settingsEmitter(): EventEmitter {
|
|
39
|
+
if (!_emitter) _emitter = createEventEmitter();
|
|
35
40
|
return _emitter;
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
export function getSettingsEmitter(): EventEmitter {
|
|
44
|
+
return settingsEmitter();
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
function settingsTable(): string {
|
|
39
48
|
return isPostgres() ? "public.settings" : "settings";
|
|
40
49
|
}
|
|
@@ -174,7 +183,7 @@ export async function mutateSetting(
|
|
|
174
183
|
});
|
|
175
184
|
if (result.rowsAffected === 0) continue;
|
|
176
185
|
requestSettingsCache()?.set(key, nextRaw);
|
|
177
|
-
|
|
186
|
+
settingsEmitter().emit("settings", {
|
|
178
187
|
source: "settings",
|
|
179
188
|
type: "change",
|
|
180
189
|
key,
|
|
@@ -200,7 +209,7 @@ export async function putSetting(
|
|
|
200
209
|
args: [key, JSON.stringify(value), Date.now()],
|
|
201
210
|
});
|
|
202
211
|
requestSettingsCache()?.set(key, JSON.stringify(value));
|
|
203
|
-
|
|
212
|
+
settingsEmitter().emit("settings", {
|
|
204
213
|
source: "settings",
|
|
205
214
|
type: "change",
|
|
206
215
|
key,
|
|
@@ -221,7 +230,7 @@ export async function deleteSetting(
|
|
|
221
230
|
});
|
|
222
231
|
requestSettingsCache()?.set(key, null);
|
|
223
232
|
if (result.rowsAffected > 0) {
|
|
224
|
-
|
|
233
|
+
settingsEmitter().emit("settings", {
|
|
225
234
|
source: "settings",
|
|
226
235
|
type: "delete",
|
|
227
236
|
key,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe accessors for optional Node builtins.
|
|
3
|
+
*
|
|
4
|
+
* `node:async_hooks` and `node:events` are server-only, but the modules that
|
|
5
|
+
* use them (db telemetry, settings/resource emitters) can land in the browser
|
|
6
|
+
* dev graph before tree-shaking runs. A static `import { X } from "node:..."`
|
|
7
|
+
* resolves to Vite's externalized stub and throws the instant the value is
|
|
8
|
+
* touched at module load. We read the builtin through `process.getBuiltinModule`
|
|
9
|
+
* instead — the same guard `server/request-context.ts` uses — so there is no
|
|
10
|
+
* static `node:` import to evaluate in the browser, and callers fall back to a
|
|
11
|
+
* no-op on non-Node runtimes (browser, or Node without getBuiltinModule).
|
|
12
|
+
*/
|
|
13
|
+
import type { AsyncLocalStorage } from "node:async_hooks";
|
|
14
|
+
import type { EventEmitter } from "node:events";
|
|
15
|
+
|
|
16
|
+
type BuiltinProcess = {
|
|
17
|
+
versions?: { node?: string };
|
|
18
|
+
getBuiltinModule?: (name: string) => unknown;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function nodeBuiltin<T>(name: string): T | undefined {
|
|
22
|
+
const proc =
|
|
23
|
+
typeof process === "undefined" ? undefined : (process as BuiltinProcess);
|
|
24
|
+
if (
|
|
25
|
+
typeof window !== "undefined" ||
|
|
26
|
+
!proc ||
|
|
27
|
+
!proc.versions?.node ||
|
|
28
|
+
typeof proc.getBuiltinModule !== "function"
|
|
29
|
+
) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return proc.getBuiltinModule(name) as T | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type AsyncLocalStorageCtor = new <T>() => AsyncLocalStorage<T>;
|
|
36
|
+
|
|
37
|
+
export function getAsyncLocalStorageCtor(): AsyncLocalStorageCtor | undefined {
|
|
38
|
+
return nodeBuiltin<{ AsyncLocalStorage: AsyncLocalStorageCtor }>(
|
|
39
|
+
"node:async_hooks",
|
|
40
|
+
)?.AsyncLocalStorage;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type EventEmitterCtor = new () => EventEmitter;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a real Node EventEmitter on Node, or a no-op emitter elsewhere. The
|
|
47
|
+
* emitters that use this drive server-side SSE fan-out; nothing subscribes in
|
|
48
|
+
* the browser, so the no-op fallback is inert rather than wrong.
|
|
49
|
+
*/
|
|
50
|
+
export function createEventEmitter(): EventEmitter {
|
|
51
|
+
const Ctor = nodeBuiltin<{ EventEmitter: EventEmitterCtor }>(
|
|
52
|
+
"node:events",
|
|
53
|
+
)?.EventEmitter;
|
|
54
|
+
if (Ctor) return new Ctor();
|
|
55
|
+
const noop = {
|
|
56
|
+
on: () => noop,
|
|
57
|
+
off: () => noop,
|
|
58
|
+
once: () => noop,
|
|
59
|
+
addListener: () => noop,
|
|
60
|
+
removeListener: () => noop,
|
|
61
|
+
removeAllListeners: () => noop,
|
|
62
|
+
setMaxListeners: () => noop,
|
|
63
|
+
emit: () => false,
|
|
64
|
+
};
|
|
65
|
+
return noop as unknown as EventEmitter;
|
|
66
|
+
}
|
|
@@ -37,7 +37,7 @@ Keep definitions in a shared TypeScript module so server and client code use the
|
|
|
37
37
|
same stable key. Flags are boolean and default-off.
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
|
-
import { defineFeatureFlag } from "@agent-native/core/feature-flags";
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags/registry";
|
|
41
41
|
|
|
42
42
|
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
43
|
key: "full-app-building",
|
|
@@ -37,7 +37,7 @@ Keep definitions in a shared TypeScript module so server and client code use the
|
|
|
37
37
|
same stable key. Flags are boolean and default-off.
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
|
-
import { defineFeatureFlag } from "@agent-native/core/feature-flags";
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags/registry";
|
|
41
41
|
|
|
42
42
|
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
43
|
key: "full-app-building",
|
|
@@ -37,7 +37,7 @@ Keep definitions in a shared TypeScript module so server and client code use the
|
|
|
37
37
|
same stable key. Flags are boolean and default-off.
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
|
-
import { defineFeatureFlag } from "@agent-native/core/feature-flags";
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags/registry";
|
|
41
41
|
|
|
42
42
|
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
43
|
key: "full-app-building",
|
|
@@ -37,7 +37,7 @@ Keep definitions in a shared TypeScript module so server and client code use the
|
|
|
37
37
|
same stable key. Flags are boolean and default-off.
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
|
-
import { defineFeatureFlag } from "@agent-native/core/feature-flags";
|
|
40
|
+
import { defineFeatureFlag } from "@agent-native/core/feature-flags/registry";
|
|
41
41
|
|
|
42
42
|
export const FULL_APP_BUILDING = defineFeatureFlag({
|
|
43
43
|
key: "full-app-building",
|
package/src/vite/client.ts
CHANGED
|
@@ -805,6 +805,7 @@ const CORE_CLIENT_SUBPATHS = [
|
|
|
805
805
|
"@agent-native/core/client/components/RemoteSelectionRings",
|
|
806
806
|
"@agent-native/core/client/visual-style-controls",
|
|
807
807
|
"@agent-native/core/client/feature-flags",
|
|
808
|
+
"@agent-native/core/feature-flags/registry",
|
|
808
809
|
"@agent-native/core/client/hooks",
|
|
809
810
|
"@agent-native/core/client/host",
|
|
810
811
|
"@agent-native/core/client/i18n",
|
|
@@ -1158,6 +1159,10 @@ function getCoreSourceAliases(
|
|
|
1158
1159
|
coreSrc,
|
|
1159
1160
|
"client/feature-flags/index.ts",
|
|
1160
1161
|
),
|
|
1162
|
+
"@agent-native/core/feature-flags/registry": path.join(
|
|
1163
|
+
coreSrc,
|
|
1164
|
+
"feature-flags/registry.ts",
|
|
1165
|
+
),
|
|
1161
1166
|
"@agent-native/core/client/hooks": path.join(
|
|
1162
1167
|
coreSrc,
|
|
1163
1168
|
"client/hooks/index.ts",
|