@agent-native/core 0.187.0 → 0.187.1-nightly-20260925003003
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 +1 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +4 -3
- package/corpus/templates/analytics/changelog/2026-09-24-analytics-sidebar-footer-aligns-consistently.md +6 -0
- package/corpus/templates/analytics/changelog/2026-09-24-dashboard-emails-match-stacked-area-totals.md +6 -0
- package/corpus/templates/analytics/server/lib/report-chart-svg.ts +47 -20
- package/corpus/templates/calendar/app/components/calendar/AttendeeAutocomplete.tsx +1 -1
- package/corpus/templates/calendar/changelog/2026-09-24-guest-inputs-wrap-beneath-existing-guests-so-the-active-inpu.md +6 -0
- package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +8 -3
- package/corpus/templates/clips/app/lib/recording-link.ts +21 -0
- package/corpus/templates/clips/app/routes/record.tsx +27 -8
- package/corpus/templates/clips/changelog/2026-09-24-the-camera-bubble-stays-visible-while-you-reposition-it-befo.md +6 -0
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +7 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +63 -55
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +251 -74
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +66 -56
- package/corpus/templates/design/app/components/design/EditPanel.tsx +19 -0
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +59 -9
- package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +4 -0
- package/corpus/templates/design/app/components/design/edit-panel/layout-properties.tsx +119 -0
- package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +48 -51
- package/corpus/templates/design/app/components/design/edit-panel/style-change-types.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +298 -187
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +2 -2
- package/corpus/templates/design/app/components/design/inspector/index.ts +4 -0
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +4 -2
- package/corpus/templates/design/app/i18n/en-US.ts +6 -0
- package/corpus/templates/design/app/pages/Present.tsx +101 -87
- package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +75 -14
- package/corpus/templates/design/app/pages/design-editor/commands/README.md +1 -0
- package/corpus/templates/design/app/pages/design-editor/commands/commit-relative-style-delta-to-selected-layers.ts +69 -56
- package/corpus/templates/design/app/pages/design-editor/commands/mode-change.ts +16 -0
- package/corpus/templates/design/app/pages/design-editor/commands/scale-selection.ts +17 -2
- package/corpus/templates/design/app/pages/design-editor/commands/styles-change.ts +23 -30
- package/corpus/templates/design/app/pages/design-editor/commands/swap-fill-stroke.ts +105 -0
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +21 -0
- package/corpus/templates/design/app/pages/present-review-state.ts +7 -1
- package/corpus/templates/design/changelog/2026-09-24-a-vector-s-stroke-row-shows-position-beside-weight-instead-o.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-css-margins-can-be-adjusted-on-the-canvas-and-in-the-layout-.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-design-reviews-show-the-real-canvas-beside-its-conversation.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-double-clicking-text-or-a-vector-on-the-board-starts-editing.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-interact-opens-a-focused-responsive-preview-without-reloadin.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-keep-gradient-values-visible-and-limit-canvas-paints-to-supp.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-open-pen-paths-no-longer-paint-a-filled-triangle-after-shift.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-re-clicking-the-active-responsive-preview-returns-to-the-can.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-resized-vectors-can-be-point-edited-and-the-k-scale-tool-sho.md +6 -0
- package/corpus/templates/design/changelog/2026-09-24-while-editing-text-click-to-place-the-caret-and-double-click.md +6 -0
- package/corpus/templates/design/e2e/helpers.ts +19 -2
- package/corpus/templates/mail/app/components/email/ComposeModal.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-09-24-gmail-push-ack.md +6 -0
- package/corpus/templates/mail/changelog/2026-09-24-the-composer-keeps-its-taller-layout-in-a-narrower-window.md +6 -0
- package/corpus/templates/mail/server/db/schema.ts +26 -1
- package/corpus/templates/mail/server/lib/inbox-store.ts +68 -23
- package/corpus/templates/mail/server/lib/inbox-sync.ts +43 -17
- package/corpus/templates/mail/server/plugins/db.ts +19 -0
- package/corpus/templates/mail/server/routes/api/gmail/push.post.ts +4 -15
- package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +45 -30
- package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +18 -2
- package/corpus/templates/slides/actions/export-html.ts +28 -17
- package/corpus/templates/slides/app/hooks/use-deck-design-system.ts +27 -15
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +1 -1
- package/corpus/templates/slides/changelog/2026-09-23-decks-with-no-design-system-now-follow-a-theme-chosen-for-th.md +6 -0
- package/corpus/templates/slides/shared/slide-background.ts +3 -1
- package/dist/agent/engine/builder-engine.js +11 -0
- package/dist/agent/engine/types.d.ts +1 -0
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.js +32 -4
- package/dist/agent/run-loop-with-resume.js +6 -0
- package/dist/cli/index.js +4 -4
- package/dist/cli/process.d.ts +10 -1
- package/dist/cli/process.js +66 -0
- package/dist/cli/workspace-dev.js +2 -0
- package/dist/client/agent-chat.js +13 -14
- package/dist/client/error-format.js +4 -4
- package/dist/client/observability/ObservabilityDashboard.js +95 -65
- package/dist/client/observability/OutputPreview.d.ts +2 -1
- package/dist/client/observability/OutputPreview.js +64 -7
- package/dist/client/observability/useObservability.d.ts +2 -1
- package/dist/client/observability/useObservability.js +5 -1
- package/dist/client/settings/UsageSection.js +105 -17
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts +44 -0
- package/dist/db/client.js +62 -3
- package/dist/db/create-get-db.js +23 -1
- package/dist/db/embedded-runtime.d.ts +21 -0
- package/dist/db/embedded-runtime.js +27 -0
- package/dist/db/migrations.js +2 -0
- package/dist/db/server-runtime.d.ts +22 -0
- package/dist/db/server-runtime.js +26 -0
- package/dist/deploy/build.d.ts +29 -0
- package/dist/deploy/build.js +204 -121
- package/dist/feature-flags/index.d.ts +1 -1
- package/dist/feature-flags/index.js +1 -1
- package/dist/feature-flags/registry.d.ts +1 -0
- package/dist/feature-flags/registry.js +5 -0
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/webhook-handler.js +4 -1
- package/dist/jobs/background-automation-runner.js +6 -1
- package/dist/localization/core-messages/ar-SA.js +9 -1
- package/dist/localization/core-messages/de-DE.js +9 -1
- package/dist/localization/core-messages/en-US.d.ts +9 -1
- package/dist/localization/core-messages/en-US.js +9 -1
- package/dist/localization/core-messages/es-ES.js +9 -1
- package/dist/localization/core-messages/fr-FR.js +9 -1
- package/dist/localization/core-messages/hi-IN.js +9 -1
- package/dist/localization/core-messages/ja-JP.js +9 -1
- package/dist/localization/core-messages/ko-KR.js +9 -1
- package/dist/localization/core-messages/pt-BR.js +9 -1
- package/dist/localization/core-messages/supplemental/ar-SA.js +1 -0
- package/dist/localization/core-messages/supplemental/de-DE.js +1 -0
- package/dist/localization/core-messages/supplemental/en-US.js +1 -0
- package/dist/localization/core-messages/supplemental/es-ES.js +1 -0
- package/dist/localization/core-messages/supplemental/fr-FR.js +1 -0
- package/dist/localization/core-messages/supplemental/hi-IN.js +1 -0
- package/dist/localization/core-messages/supplemental/ja-JP.js +1 -0
- package/dist/localization/core-messages/supplemental/ko-KR.js +1 -0
- package/dist/localization/core-messages/supplemental/pt-BR.js +1 -0
- package/dist/localization/core-messages/supplemental/zh-CN.js +1 -0
- package/dist/localization/core-messages/supplemental/zh-TW.js +1 -0
- package/dist/localization/core-messages/zh-CN.js +9 -1
- package/dist/localization/core-messages/zh-TW.js +9 -1
- package/dist/localization/core-messages.d.ts +9 -1
- package/dist/localization/mcp-settings-messages.d.ts +1 -0
- package/dist/mcp/connect-route.js +45 -8
- package/dist/mcp/connect-store.d.ts +7 -5
- package/dist/mcp/connect-store.js +30 -39
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/actions/get-observability-review-detail.d.ts +7 -0
- package/dist/observability/actions/get-observability-review-detail.js +25 -0
- package/dist/observability/reviews.d.ts +9 -1
- package/dist/observability/reviews.js +20 -0
- package/dist/observability/routes.d.ts +3 -3
- package/dist/observability/types.d.ts +8 -0
- package/dist/org/handlers.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
- package/dist/provider-api/actions/provider-api.d.ts +9 -9
- package/dist/scripts/db/query.js +6 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
- package/dist/server/agent-teams.js +4 -1
- package/dist/server/auth.js +60 -20
- package/dist/server/better-auth-instance.js +7 -1
- package/dist/server/core-routes-plugin.d.ts +1 -1
- package/dist/server/core-routes-plugin.js +2 -0
- package/dist/server/embedded.js +6 -0
- package/dist/server/framework-request-handler.js +6 -0
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/usage/actions/get-usage-metrics.js +4 -1
- package/dist/usage/metrics-store.d.ts +19 -0
- package/dist/usage/metrics-store.js +106 -14
- package/dist/usage/store.d.ts +7 -2
- package/dist/usage/store.js +25 -4
- package/dist/vite/action-types-plugin.js +4 -0
- package/dist/vite/client.d.ts +6 -1
- package/dist/vite/client.js +40 -1
- package/package.json +4 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded host duty: the process-local claim that a real host product
|
|
3
|
+
* (`createAgentNativeEmbeddedPlugin()`) explicitly configured this process's
|
|
4
|
+
* database, including a legitimate `pglite:` URL for a packaged/desktop
|
|
5
|
+
* install.
|
|
6
|
+
*
|
|
7
|
+
* That install can set `NODE_ENV=production` and boots a real H3 app the
|
|
8
|
+
* same way a deployed Node/Docker server does (see `db/server-runtime.js`),
|
|
9
|
+
* so `assertHostedRuntimeDatabase()` cannot otherwise tell "the embedding
|
|
10
|
+
* host chose this database on purpose" apart from "a deploy silently fell
|
|
11
|
+
* back to it because nobody configured `DATABASE_URL`." Claimed with
|
|
12
|
+
* {@link markEmbeddedRuntimeAuthorized}.
|
|
13
|
+
*
|
|
14
|
+
* Its own module, mirroring `./migration-runtime.js`: `client.js` reads it,
|
|
15
|
+
* and keeping it dependency-free avoids adding one more stub to every
|
|
16
|
+
* `vi.mock("../db/client.js")` in the codebase.
|
|
17
|
+
*/
|
|
18
|
+
/** True once an embedding host has explicitly configured this process's database. */
|
|
19
|
+
export declare function isEmbeddedRuntimeAuthorized(): boolean;
|
|
20
|
+
/** Claim embedded-host duty. Idempotent; never unset for the life of the process. */
|
|
21
|
+
export declare function markEmbeddedRuntimeAuthorized(): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedded host duty: the process-local claim that a real host product
|
|
3
|
+
* (`createAgentNativeEmbeddedPlugin()`) explicitly configured this process's
|
|
4
|
+
* database, including a legitimate `pglite:` URL for a packaged/desktop
|
|
5
|
+
* install.
|
|
6
|
+
*
|
|
7
|
+
* That install can set `NODE_ENV=production` and boots a real H3 app the
|
|
8
|
+
* same way a deployed Node/Docker server does (see `db/server-runtime.js`),
|
|
9
|
+
* so `assertHostedRuntimeDatabase()` cannot otherwise tell "the embedding
|
|
10
|
+
* host chose this database on purpose" apart from "a deploy silently fell
|
|
11
|
+
* back to it because nobody configured `DATABASE_URL`." Claimed with
|
|
12
|
+
* {@link markEmbeddedRuntimeAuthorized}.
|
|
13
|
+
*
|
|
14
|
+
* Its own module, mirroring `./migration-runtime.js`: `client.js` reads it,
|
|
15
|
+
* and keeping it dependency-free avoids adding one more stub to every
|
|
16
|
+
* `vi.mock("../db/client.js")` in the codebase.
|
|
17
|
+
*/
|
|
18
|
+
/** True once an embedding host has explicitly configured this process's database. */
|
|
19
|
+
export function isEmbeddedRuntimeAuthorized() {
|
|
20
|
+
return (globalThis.__AGENT_NATIVE_EMBEDDED_RUNTIME__ ===
|
|
21
|
+
true);
|
|
22
|
+
}
|
|
23
|
+
/** Claim embedded-host duty. Idempotent; never unset for the life of the process. */
|
|
24
|
+
export function markEmbeddedRuntimeAuthorized() {
|
|
25
|
+
globalThis.__AGENT_NATIVE_EMBEDDED_RUNTIME__ =
|
|
26
|
+
true;
|
|
27
|
+
}
|
package/dist/db/migrations.js
CHANGED
|
@@ -301,6 +301,8 @@ export function runMigrations(migrationSource, options) {
|
|
|
301
301
|
}
|
|
302
302
|
catch (err) {
|
|
303
303
|
if (isPermissionError(err)) {
|
|
304
|
+
if (isMigrationAuthorizedRuntime())
|
|
305
|
+
throw err;
|
|
304
306
|
console.warn(`[db] Migration ${label} skipped - insufficient privilege: ${err.message}. ` +
|
|
305
307
|
"Apply it with a database role that owns the table. Halting further migrations.", "\nStatement:", currentStatement);
|
|
306
308
|
break;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-serving duty: the process-local claim that a real Nitro server
|
|
3
|
+
* instance has booted and is wiring its H3 app for real requests.
|
|
4
|
+
*
|
|
5
|
+
* Netlify/Lambda/Vercel each hand the process a platform env var that is only
|
|
6
|
+
* ever set during a real function invocation, never during a build. Bare
|
|
7
|
+
* Node/Docker has no such var — `NODE_ENV=production` alone is set by build
|
|
8
|
+
* and prerender steps too (see the Cloudflare Pages static-shell script in
|
|
9
|
+
* deploy/build.ts), so it cannot stand in for one. This flag is set from
|
|
10
|
+
* {@link import("../server/framework-request-handler.js").getH3App}, the one
|
|
11
|
+
* choke point every plugin — default or app-authored, on every preset —
|
|
12
|
+
* calls to register routes, the first time any nitroApp instance actually
|
|
13
|
+
* boots. A build never constructs a real nitroApp, so this never fires there.
|
|
14
|
+
*
|
|
15
|
+
* Its own module, mirroring `./migration-runtime.js`: `client.js` reads it,
|
|
16
|
+
* and keeping it dependency-free avoids adding one more stub to every
|
|
17
|
+
* `vi.mock("../db/client.js")` in the codebase.
|
|
18
|
+
*/
|
|
19
|
+
/** True once a real Nitro server instance has started wiring its H3 app. */
|
|
20
|
+
export declare function isServerRuntimeStarted(): boolean;
|
|
21
|
+
/** Claim server-serving duty. Idempotent; never unset for the life of the process. */
|
|
22
|
+
export declare function markServerRuntimeStarted(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-serving duty: the process-local claim that a real Nitro server
|
|
3
|
+
* instance has booted and is wiring its H3 app for real requests.
|
|
4
|
+
*
|
|
5
|
+
* Netlify/Lambda/Vercel each hand the process a platform env var that is only
|
|
6
|
+
* ever set during a real function invocation, never during a build. Bare
|
|
7
|
+
* Node/Docker has no such var — `NODE_ENV=production` alone is set by build
|
|
8
|
+
* and prerender steps too (see the Cloudflare Pages static-shell script in
|
|
9
|
+
* deploy/build.ts), so it cannot stand in for one. This flag is set from
|
|
10
|
+
* {@link import("../server/framework-request-handler.js").getH3App}, the one
|
|
11
|
+
* choke point every plugin — default or app-authored, on every preset —
|
|
12
|
+
* calls to register routes, the first time any nitroApp instance actually
|
|
13
|
+
* boots. A build never constructs a real nitroApp, so this never fires there.
|
|
14
|
+
*
|
|
15
|
+
* Its own module, mirroring `./migration-runtime.js`: `client.js` reads it,
|
|
16
|
+
* and keeping it dependency-free avoids adding one more stub to every
|
|
17
|
+
* `vi.mock("../db/client.js")` in the codebase.
|
|
18
|
+
*/
|
|
19
|
+
/** True once a real Nitro server instance has started wiring its H3 app. */
|
|
20
|
+
export function isServerRuntimeStarted() {
|
|
21
|
+
return (globalThis.__AGENT_NATIVE_SERVER_RUNTIME__ === true);
|
|
22
|
+
}
|
|
23
|
+
/** Claim server-serving duty. Idempotent; never unset for the life of the process. */
|
|
24
|
+
export function markServerRuntimeStarted() {
|
|
25
|
+
globalThis.__AGENT_NATIVE_SERVER_RUNTIME__ = true;
|
|
26
|
+
}
|
package/dist/deploy/build.d.ts
CHANGED
|
@@ -33,6 +33,27 @@ export declare const CLOUDFLARE_MODULE_WORKER_ENTRY = "worker.mjs";
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function configureAwsAmplifyRuntimeOutput(serverDir: string, appDir: string, env?: NodeJS.ProcessEnv): void;
|
|
35
35
|
export declare function configureAwsLambdaRuntimeOutput(serverDir: string, appDir: string, env?: NodeJS.ProcessEnv): void;
|
|
36
|
+
/**
|
|
37
|
+
* Shims one already-read Cloudflare Pages output file's module-scope
|
|
38
|
+
* `setInterval` calls, sharing the Module preset's globalThis-keyed capture
|
|
39
|
+
* (`cloudflareModuleTimerShimPrefix` / `CF_MODULE_ORIG_SET_INTERVAL_KEY`)
|
|
40
|
+
* instead of a disconnected per-file mechanism.
|
|
41
|
+
*
|
|
42
|
+
* Pages used to prepend its own shim keyed on a per-file `var
|
|
43
|
+
* __origSetInterval`, captured independently by every chunk. Since the
|
|
44
|
+
* generated entry statically imports routes, actions, and plugins (they
|
|
45
|
+
* evaluate before the entry's own top-level code runs, same as any ES
|
|
46
|
+
* module's imports), a dependency chunk's shim neutered
|
|
47
|
+
* `globalThis.setInterval` before the entry's own `var` ever captured
|
|
48
|
+
* it — so the entry's "original" was already the neutered stub, and its
|
|
49
|
+
* restore call restored nothing. Sharing this capture with the Module
|
|
50
|
+
* preset's `__cfRestoreModuleTimers()` (already emitted into the generated
|
|
51
|
+
* entry by `cloudflareModuleTimerRestoreScript` — see `generateWorkerEntry`)
|
|
52
|
+
* fixes both: whichever chunk evaluates first captures the one true
|
|
53
|
+
* original, and every later chunk (including the entry) sees it's already
|
|
54
|
+
* captured and skips straight to neutering.
|
|
55
|
+
*/
|
|
56
|
+
export declare function shimCloudflarePagesModuleTimers(code: string): string;
|
|
36
57
|
export declare function generateCloudflareModuleWorkerEntry(): string;
|
|
37
58
|
export declare function patchCloudflareModuleNitroEntry(code: string): string;
|
|
38
59
|
export declare function configureCloudflareModuleWorkerOutput(serverDir: string): void;
|
|
@@ -255,6 +276,14 @@ export declare function emitSingleTemplateNetlifyBackgroundFunction(projectCwd:
|
|
|
255
276
|
*/
|
|
256
277
|
export declare function assertEmittedBackgroundFunctionOnDisk(destDir: string, functionName: string): void;
|
|
257
278
|
export declare function emitSingleTemplateNetlifyIntegrationRecoveryFunction(projectCwd: string): void;
|
|
279
|
+
/**
|
|
280
|
+
* Post-build patches for `cloudflare_module` server output. Recurses (via
|
|
281
|
+
* `walkServerJavaScriptFiles`) because esbuild/Nitro can emit a dependency at
|
|
282
|
+
* a nested path (e.g. `_libs/@agent-native/core.mjs`) — a flat `readdirSync`
|
|
283
|
+
* silently skips it, leaving its module-scope `setInterval` call unpatched,
|
|
284
|
+
* which Cloudflare rejects with error 10021.
|
|
285
|
+
*/
|
|
286
|
+
export declare function patchCloudflareModuleServerOutput(serverDir: string): void;
|
|
258
287
|
/**
|
|
259
288
|
* Nitro receives the React Router SSR build as prebuilt chunks, so its normal
|
|
260
289
|
* dependency resolver cannot reliably fold the preserved bare `yjs` imports
|
package/dist/deploy/build.js
CHANGED
|
@@ -275,17 +275,21 @@ export function configureAwsAmplifyRuntimeOutput(serverDir, appDir, env = proces
|
|
|
275
275
|
export function configureAwsLambdaRuntimeOutput(serverDir, appDir, env = process.env) {
|
|
276
276
|
configureAwsRuntimeOutput(serverDir, appDir, "aws_lambda", env);
|
|
277
277
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
278
|
+
/**
|
|
279
|
+
* JS source for a generated Cloudflare Worker entry's `initializeBindings(env)`
|
|
280
|
+
* helper, shared between the Module (`generateCloudflareModuleWorkerEntry`) and
|
|
281
|
+
* Pages (`generateWorkerEntry`) entries so they cannot drift apart.
|
|
282
|
+
*
|
|
283
|
+
* Setting `globalThis.__env__` is not optional decoration: it is the
|
|
284
|
+
* framework's canonical "this is a real Cloudflare invocation" signal
|
|
285
|
+
* (`hasCloudflareRuntime()` in db/client.ts, also read by `isNodeRuntime()` /
|
|
286
|
+
* `isCloudflareRuntime()` in shared/runtime.ts). The Pages entry used to copy
|
|
287
|
+
* bindings into `process.env` without ever setting `__env__`, which silently
|
|
288
|
+
* defeated every one of those checks on every Pages deploy — including the
|
|
289
|
+
* hosted-database guard, which never refused to open PGlite there.
|
|
290
|
+
*/
|
|
291
|
+
function cloudflareBindingsInitScript() {
|
|
292
|
+
return `function initializeBindings(env) {
|
|
289
293
|
if (!env) return;
|
|
290
294
|
globalThis.__env__ = env;
|
|
291
295
|
globalThis.process = globalThis.process || { env: {} };
|
|
@@ -293,35 +297,127 @@ function initializeBindings(env) {
|
|
|
293
297
|
for (const [key, value] of Object.entries(env)) {
|
|
294
298
|
if (typeof value === "string") globalThis.process.env[key] = value;
|
|
295
299
|
}
|
|
300
|
+
}`;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Global-scope key Module's timer shim (see `cloudflareModuleTimerShimPrefix`
|
|
304
|
+
* in `buildWithNitro`'s post-build patch) uses to stash the real
|
|
305
|
+
* `setInterval` before neutering it. Cloudflare Workers loads each server
|
|
306
|
+
* chunk as its own ES module, so a chunk's own top-level `var` can't be read
|
|
307
|
+
* back from `worker.mjs` — the original has to be captured on `globalThis`
|
|
308
|
+
* instead, and only once, since `worker.mjs` always loads (and shims) first.
|
|
309
|
+
*/
|
|
310
|
+
const CF_MODULE_ORIG_SET_INTERVAL_KEY = "__cfModuleOrigSetInterval";
|
|
311
|
+
const CF_MODULE_TIMER_SHIM_MARKER = "__cf_module_timer_shim__";
|
|
312
|
+
/**
|
|
313
|
+
* Restores the real `setInterval`, captured by
|
|
314
|
+
* `cloudflareModuleTimerShimPrefix`. Callers must invoke this only after the
|
|
315
|
+
* shimmed dependency graph has actually been evaluated (e.g. after `await
|
|
316
|
+
* loadHandler()` in the Module entry, or unconditionally in the Pages entry,
|
|
317
|
+
* whose dependencies are all statically imported and so are already
|
|
318
|
+
* evaluated by the time any handler body runs) — calling it any earlier is a
|
|
319
|
+
* no-op on a cold isolate, since nothing has captured the original yet, and
|
|
320
|
+
* the shim then immediately re-neuters it during that later evaluation with
|
|
321
|
+
* nothing left to restore it again.
|
|
322
|
+
*/
|
|
323
|
+
function cloudflareModuleTimerRestoreScript() {
|
|
324
|
+
return `function __cfRestoreModuleTimers() {
|
|
325
|
+
if (typeof globalThis.${CF_MODULE_ORIG_SET_INTERVAL_KEY} !== "undefined") {
|
|
326
|
+
globalThis.setInterval = globalThis.${CF_MODULE_ORIG_SET_INTERVAL_KEY};
|
|
327
|
+
}
|
|
328
|
+
}`;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Prepended (in `buildWithNitro`'s post-build patch) to every server chunk
|
|
332
|
+
* that calls `setInterval` at module scope — Cloudflare Workers disallows
|
|
333
|
+
* timer creation outside a request/handler context. Neuters the call and,
|
|
334
|
+
* the first time any chunk runs this, stashes the real `setInterval` on
|
|
335
|
+
* `globalThis` for `__cfRestoreModuleTimers` (see
|
|
336
|
+
* `cloudflareModuleTimerRestoreScript`) to hand back once a handler runs.
|
|
337
|
+
*/
|
|
338
|
+
function cloudflareModuleTimerShimPrefix() {
|
|
339
|
+
return (`/* ${CF_MODULE_TIMER_SHIM_MARKER} */` +
|
|
340
|
+
`if(typeof globalThis.${CF_MODULE_ORIG_SET_INTERVAL_KEY}==="undefined"){globalThis.${CF_MODULE_ORIG_SET_INTERVAL_KEY}=globalThis.setInterval;}` +
|
|
341
|
+
`globalThis.setInterval=function(){return{unref(){},ref(){},close(){}}};`);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Shims one already-read Cloudflare Pages output file's module-scope
|
|
345
|
+
* `setInterval` calls, sharing the Module preset's globalThis-keyed capture
|
|
346
|
+
* (`cloudflareModuleTimerShimPrefix` / `CF_MODULE_ORIG_SET_INTERVAL_KEY`)
|
|
347
|
+
* instead of a disconnected per-file mechanism.
|
|
348
|
+
*
|
|
349
|
+
* Pages used to prepend its own shim keyed on a per-file `var
|
|
350
|
+
* __origSetInterval`, captured independently by every chunk. Since the
|
|
351
|
+
* generated entry statically imports routes, actions, and plugins (they
|
|
352
|
+
* evaluate before the entry's own top-level code runs, same as any ES
|
|
353
|
+
* module's imports), a dependency chunk's shim neutered
|
|
354
|
+
* `globalThis.setInterval` before the entry's own `var` ever captured
|
|
355
|
+
* it — so the entry's "original" was already the neutered stub, and its
|
|
356
|
+
* restore call restored nothing. Sharing this capture with the Module
|
|
357
|
+
* preset's `__cfRestoreModuleTimers()` (already emitted into the generated
|
|
358
|
+
* entry by `cloudflareModuleTimerRestoreScript` — see `generateWorkerEntry`)
|
|
359
|
+
* fixes both: whichever chunk evaluates first captures the one true
|
|
360
|
+
* original, and every later chunk (including the entry) sees it's already
|
|
361
|
+
* captured and skips straight to neutering.
|
|
362
|
+
*/
|
|
363
|
+
export function shimCloudflarePagesModuleTimers(code) {
|
|
364
|
+
if (code.includes("setInterval") &&
|
|
365
|
+
!code.includes(CF_MODULE_TIMER_SHIM_MARKER)) {
|
|
366
|
+
return cloudflareModuleTimerShimPrefix() + code;
|
|
367
|
+
}
|
|
368
|
+
return code;
|
|
369
|
+
}
|
|
370
|
+
export function generateCloudflareModuleWorkerEntry() {
|
|
371
|
+
return `let handler;
|
|
372
|
+
|
|
373
|
+
async function loadHandler() {
|
|
374
|
+
handler ??= (await import("./index.mjs")).default;
|
|
375
|
+
return handler;
|
|
296
376
|
}
|
|
297
377
|
|
|
378
|
+
${cloudflareBindingsInitScript()}
|
|
379
|
+
|
|
380
|
+
${cloudflareModuleTimerRestoreScript()}
|
|
381
|
+
|
|
298
382
|
export default {
|
|
299
383
|
async fetch(request, env, ctx) {
|
|
300
384
|
if (typeof ctx?.waitUntil === "function") {
|
|
301
385
|
request.waitUntil = ctx.waitUntil.bind(ctx);
|
|
302
386
|
}
|
|
303
387
|
initializeBindings(env);
|
|
304
|
-
|
|
388
|
+
const h = await loadHandler();
|
|
389
|
+
__cfRestoreModuleTimers();
|
|
390
|
+
return h.fetch(request, env, ctx);
|
|
305
391
|
},
|
|
306
392
|
async scheduled(controller, env, ctx) {
|
|
307
393
|
initializeBindings(env);
|
|
308
|
-
|
|
394
|
+
const h = await loadHandler();
|
|
395
|
+
__cfRestoreModuleTimers();
|
|
396
|
+
return h.scheduled?.(controller, env, ctx);
|
|
309
397
|
},
|
|
310
398
|
async email(message, env, ctx) {
|
|
311
399
|
initializeBindings(env);
|
|
312
|
-
|
|
400
|
+
const h = await loadHandler();
|
|
401
|
+
__cfRestoreModuleTimers();
|
|
402
|
+
return h.email?.(message, env, ctx);
|
|
313
403
|
},
|
|
314
404
|
async queue(batch, env, ctx) {
|
|
315
405
|
initializeBindings(env);
|
|
316
|
-
|
|
406
|
+
const h = await loadHandler();
|
|
407
|
+
__cfRestoreModuleTimers();
|
|
408
|
+
return h.queue?.(batch, env, ctx);
|
|
317
409
|
},
|
|
318
410
|
async tail(traces, env, ctx) {
|
|
319
411
|
initializeBindings(env);
|
|
320
|
-
|
|
412
|
+
const h = await loadHandler();
|
|
413
|
+
__cfRestoreModuleTimers();
|
|
414
|
+
return h.tail?.(traces, env, ctx);
|
|
321
415
|
},
|
|
322
416
|
async trace(traces, env, ctx) {
|
|
323
417
|
initializeBindings(env);
|
|
324
|
-
|
|
418
|
+
const h = await loadHandler();
|
|
419
|
+
__cfRestoreModuleTimers();
|
|
420
|
+
return h.trace?.(traces, env, ctx);
|
|
325
421
|
},
|
|
326
422
|
};
|
|
327
423
|
`;
|
|
@@ -1899,21 +1995,23 @@ ${includeReactRouterSsr
|
|
|
1899
1995
|
return _handler;
|
|
1900
1996
|
}
|
|
1901
1997
|
|
|
1998
|
+
${cloudflareBindingsInitScript()}
|
|
1999
|
+
|
|
2000
|
+
${cloudflareModuleTimerRestoreScript()}
|
|
2001
|
+
|
|
1902
2002
|
export default {
|
|
1903
2003
|
async fetch(request, env, ctx) {
|
|
1904
2004
|
// Attach the request-scoped continuation hook before any URL rewrite.
|
|
1905
2005
|
if (typeof ctx?.waitUntil === "function") {
|
|
1906
2006
|
request.waitUntil = ctx.waitUntil.bind(ctx);
|
|
1907
2007
|
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
2008
|
+
initializeBindings(env);
|
|
2009
|
+
// Unlike the Module entry, every dependency here is statically imported
|
|
2010
|
+
// (see routeImports/actionImports above), so patchCloudflareModuleServerOutput's
|
|
2011
|
+
// shim has already run — and already re-neutered setInterval — by the
|
|
2012
|
+
// time this handler body executes. No loadHandler()-style deferred
|
|
2013
|
+
// import to wait on: restoring here is always safe and always needed.
|
|
2014
|
+
__cfRestoreModuleTimers();
|
|
1917
2015
|
|
|
1918
2016
|
// Try serving static assets first (CF Pages advanced mode).
|
|
1919
2017
|
// Only attempt this for GET/HEAD — the ASSETS binding is a static file
|
|
@@ -2492,7 +2590,6 @@ async function buildCloudflarePages() {
|
|
|
2492
2590
|
const allJsFiles = getAllJsFiles(workerOutDir);
|
|
2493
2591
|
for (const jsFile of allJsFiles) {
|
|
2494
2592
|
let code = fs.readFileSync(jsFile, "utf-8");
|
|
2495
|
-
const isEntry = path.basename(jsFile) === "index.js";
|
|
2496
2593
|
// Strip "node:" prefix from all imports/requires. Cloudflare Pages
|
|
2497
2594
|
// Functions runs under nodejs_compat v1, which exposes builtins as
|
|
2498
2595
|
// bare names ("fs") and rejects "node:fs" at worker init:
|
|
@@ -2527,20 +2624,7 @@ async function buildCloudflarePages() {
|
|
|
2527
2624
|
// prefix preserved (for nodejs_compat_v2), the latter is what esbuild now emits.
|
|
2528
2625
|
code = code.replace(/\bimport\s*\{\s*createRequire\s+as\s+([\w$]+)\s*\}\s*from\s*["'](?:node:)?module["']\s*;/g, "var $1 = function() { return typeof require !== 'undefined' ? require : function(m) { throw new Error('require not supported: ' + m); }; };");
|
|
2529
2626
|
// Patch setInterval/setTimeout at module scope — CF Workers disallows timers in global scope.
|
|
2530
|
-
|
|
2531
|
-
// With code splitting, chunks evaluate before the entry, so the shim must be in every file.
|
|
2532
|
-
// The restore only happens in the entry's fetch() handler.
|
|
2533
|
-
if (!code.includes("__origSetInterval")) {
|
|
2534
|
-
const timerShim = [
|
|
2535
|
-
"var __origSetInterval=globalThis.setInterval;",
|
|
2536
|
-
"globalThis.setInterval=function(){return{unref(){},ref(){},close(){}}};",
|
|
2537
|
-
].join("");
|
|
2538
|
-
code = timerShim + code;
|
|
2539
|
-
}
|
|
2540
|
-
if (isEntry) {
|
|
2541
|
-
const timerRestore = "if(__origSetInterval)globalThis.setInterval=__origSetInterval;";
|
|
2542
|
-
code = code.replace(/async fetch\(request,\s*env,\s*ctx\)\s*\{/, (match) => match + timerRestore);
|
|
2543
|
-
}
|
|
2627
|
+
code = shimCloudflarePagesModuleTimers(code);
|
|
2544
2628
|
assertNoCloudflareWorkerStubDynamicImports(code, jsFile);
|
|
2545
2629
|
fs.writeFileSync(jsFile, code);
|
|
2546
2630
|
}
|
|
@@ -3827,6 +3911,82 @@ function walkServerJavaScriptFiles(dir, onFile) {
|
|
|
3827
3911
|
onFile(entryPath);
|
|
3828
3912
|
}
|
|
3829
3913
|
}
|
|
3914
|
+
const CF_MODULE_NODE_BUILTINS = [
|
|
3915
|
+
"fs",
|
|
3916
|
+
"path",
|
|
3917
|
+
"os",
|
|
3918
|
+
"crypto",
|
|
3919
|
+
"http",
|
|
3920
|
+
"https",
|
|
3921
|
+
"stream",
|
|
3922
|
+
"url",
|
|
3923
|
+
"util",
|
|
3924
|
+
"events",
|
|
3925
|
+
"buffer",
|
|
3926
|
+
"console",
|
|
3927
|
+
"querystring",
|
|
3928
|
+
"zlib",
|
|
3929
|
+
"net",
|
|
3930
|
+
"tls",
|
|
3931
|
+
"assert",
|
|
3932
|
+
"timers",
|
|
3933
|
+
"child_process",
|
|
3934
|
+
"module",
|
|
3935
|
+
"process",
|
|
3936
|
+
"worker_threads",
|
|
3937
|
+
"string_decoder",
|
|
3938
|
+
"diagnostics_channel",
|
|
3939
|
+
"async_hooks",
|
|
3940
|
+
"perf_hooks",
|
|
3941
|
+
"inspector",
|
|
3942
|
+
"vm",
|
|
3943
|
+
];
|
|
3944
|
+
/**
|
|
3945
|
+
* Post-build patches for `cloudflare_module` server output. Recurses (via
|
|
3946
|
+
* `walkServerJavaScriptFiles`) because esbuild/Nitro can emit a dependency at
|
|
3947
|
+
* a nested path (e.g. `_libs/@agent-native/core.mjs`) — a flat `readdirSync`
|
|
3948
|
+
* silently skips it, leaving its module-scope `setInterval` call unpatched,
|
|
3949
|
+
* which Cloudflare rejects with error 10021.
|
|
3950
|
+
*/
|
|
3951
|
+
export function patchCloudflareModuleServerOutput(serverDir) {
|
|
3952
|
+
if (!fs.existsSync(serverDir))
|
|
3953
|
+
return;
|
|
3954
|
+
walkServerJavaScriptFiles(serverDir, (filePath) => {
|
|
3955
|
+
let code = fs.readFileSync(filePath, "utf-8");
|
|
3956
|
+
let changed = false;
|
|
3957
|
+
// 1. Rewrite bare Node.js imports to node: prefixed.
|
|
3958
|
+
// CF Workers requires the node: prefix for built-in modules.
|
|
3959
|
+
for (const mod of CF_MODULE_NODE_BUILTINS) {
|
|
3960
|
+
// Match: from"fs" or from "fs" (but not from"node:fs")
|
|
3961
|
+
const re = new RegExp(`from\\s*["']${mod}["']`, "g");
|
|
3962
|
+
if (re.test(code)) {
|
|
3963
|
+
code = code.replace(re, `from"node:${mod}"`);
|
|
3964
|
+
changed = true;
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
// 2. Patch import.meta.url for createRequire().
|
|
3968
|
+
// React Router's server build uses createRequire(import.meta.url)
|
|
3969
|
+
// but import.meta.url is undefined on CF Workers.
|
|
3970
|
+
if (code.includes("import.meta.url")) {
|
|
3971
|
+
code = code.replace(/import\.meta\.url/g, '"file:///worker.mjs"');
|
|
3972
|
+
changed = true;
|
|
3973
|
+
}
|
|
3974
|
+
// 3. Patch setInterval/setTimeout at global scope.
|
|
3975
|
+
// CF Workers disallows timers in global scope. Shim every matching
|
|
3976
|
+
// chunk; only worker.mjs restores the real function, from inside its
|
|
3977
|
+
// own handlers (baked into generateCloudflareModuleWorkerEntry), never
|
|
3978
|
+
// via an immediate per-chunk restore — a chunk loaded ahead of
|
|
3979
|
+
// worker.mjs's handlers running would otherwise leave setInterval
|
|
3980
|
+
// neutered for the rest of the request.
|
|
3981
|
+
if (code.includes("setInterval") &&
|
|
3982
|
+
!code.includes(CF_MODULE_TIMER_SHIM_MARKER)) {
|
|
3983
|
+
code = cloudflareModuleTimerShimPrefix() + code;
|
|
3984
|
+
changed = true;
|
|
3985
|
+
}
|
|
3986
|
+
if (changed)
|
|
3987
|
+
fs.writeFileSync(filePath, code);
|
|
3988
|
+
});
|
|
3989
|
+
}
|
|
3830
3990
|
/**
|
|
3831
3991
|
* Nitro receives the React Router SSR build as prebuilt chunks, so its normal
|
|
3832
3992
|
* dependency resolver cannot reliably fold the preserved bare `yjs` imports
|
|
@@ -5212,86 +5372,9 @@ export default bundle;
|
|
|
5212
5372
|
// Cloudflare-specific post-build patches
|
|
5213
5373
|
if (preset.startsWith("cloudflare")) {
|
|
5214
5374
|
const serverDir2 = nitro.options.output.serverDir;
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
const libsDir = path.join(serverDir2, "_libs");
|
|
5219
|
-
if (fs.existsSync(chunksDir))
|
|
5220
|
-
scanDirs.push(chunksDir);
|
|
5221
|
-
if (fs.existsSync(libsDir))
|
|
5222
|
-
scanDirs.push(libsDir);
|
|
5223
|
-
}
|
|
5224
|
-
for (const scanDir of scanDirs) {
|
|
5225
|
-
if (!scanDir || !fs.existsSync(scanDir))
|
|
5226
|
-
continue;
|
|
5227
|
-
for (const file of fs.readdirSync(scanDir)) {
|
|
5228
|
-
if (!file.endsWith(".mjs") && !file.endsWith(".js"))
|
|
5229
|
-
continue;
|
|
5230
|
-
const filePath = path.join(scanDir, file);
|
|
5231
|
-
let code = fs.readFileSync(filePath, "utf-8");
|
|
5232
|
-
let changed = false;
|
|
5233
|
-
// 1. Rewrite bare Node.js imports to node: prefixed.
|
|
5234
|
-
// CF Workers requires the node: prefix for built-in modules.
|
|
5235
|
-
const NODE_BUILTINS = [
|
|
5236
|
-
"fs",
|
|
5237
|
-
"path",
|
|
5238
|
-
"os",
|
|
5239
|
-
"crypto",
|
|
5240
|
-
"http",
|
|
5241
|
-
"https",
|
|
5242
|
-
"stream",
|
|
5243
|
-
"url",
|
|
5244
|
-
"util",
|
|
5245
|
-
"events",
|
|
5246
|
-
"buffer",
|
|
5247
|
-
"console",
|
|
5248
|
-
"querystring",
|
|
5249
|
-
"zlib",
|
|
5250
|
-
"net",
|
|
5251
|
-
"tls",
|
|
5252
|
-
"assert",
|
|
5253
|
-
"timers",
|
|
5254
|
-
"child_process",
|
|
5255
|
-
"module",
|
|
5256
|
-
"process",
|
|
5257
|
-
"worker_threads",
|
|
5258
|
-
"string_decoder",
|
|
5259
|
-
"diagnostics_channel",
|
|
5260
|
-
"async_hooks",
|
|
5261
|
-
"perf_hooks",
|
|
5262
|
-
"inspector",
|
|
5263
|
-
"vm",
|
|
5264
|
-
];
|
|
5265
|
-
for (const mod of NODE_BUILTINS) {
|
|
5266
|
-
// Match: from"fs" or from "fs" (but not from"node:fs")
|
|
5267
|
-
const re = new RegExp(`from\\s*["']${mod}["']`, "g");
|
|
5268
|
-
if (re.test(code)) {
|
|
5269
|
-
code = code.replace(re, `from"node:${mod}"`);
|
|
5270
|
-
changed = true;
|
|
5271
|
-
}
|
|
5272
|
-
}
|
|
5273
|
-
// 2. Patch import.meta.url for createRequire().
|
|
5274
|
-
// React Router's server build uses createRequire(import.meta.url)
|
|
5275
|
-
// but import.meta.url is undefined on CF Workers.
|
|
5276
|
-
if (code.includes("import.meta.url")) {
|
|
5277
|
-
code = code.replace(/import\.meta\.url/g, '"file:///worker.mjs"');
|
|
5278
|
-
changed = true;
|
|
5279
|
-
}
|
|
5280
|
-
// 3. Patch setInterval/setTimeout at global scope.
|
|
5281
|
-
// CF Workers disallows timers in global scope.
|
|
5282
|
-
if (code.includes("setInterval") && !code.includes("__timer_shim__")) {
|
|
5283
|
-
const shim = "/* __timer_shim__ */" +
|
|
5284
|
-
"var __origSetInterval=globalThis.setInterval;" +
|
|
5285
|
-
"globalThis.setInterval=function(){return{unref(){},ref(){},close(){}}};";
|
|
5286
|
-
const restore = ";(function(){if(typeof __origSetInterval!=='undefined')globalThis.setInterval=__origSetInterval})();";
|
|
5287
|
-
code = shim + code + "\n" + restore;
|
|
5288
|
-
changed = true;
|
|
5289
|
-
}
|
|
5290
|
-
if (changed)
|
|
5291
|
-
fs.writeFileSync(filePath, code);
|
|
5292
|
-
}
|
|
5293
|
-
}
|
|
5294
|
-
// 3. Create stub modules in _libs/ for native deps that Nitro's rolldown
|
|
5375
|
+
if (serverDir2)
|
|
5376
|
+
patchCloudflareModuleServerOutput(serverDir2);
|
|
5377
|
+
// Create stub modules in _libs/ for native deps that Nitro's rolldown
|
|
5295
5378
|
// bundler references but can't resolve on CF Workers, and rewrite
|
|
5296
5379
|
// bare imports to point to the stub files.
|
|
5297
5380
|
const libsDir2 = path.join(serverDir2 || path.join(cwd, "dist", "_worker.js"), "_libs");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, getFeatureFlagDefinition, listFeatureFlags, registerFeatureFlags, type FeatureFlagDefinition, } from "./registry.js";
|
|
1
|
+
export { BUILDER_CREDIT_USAGE_REPORTING_FLAG, CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, getFeatureFlagDefinition, listFeatureFlags, registerFeatureFlags, type FeatureFlagDefinition, } from "./registry.js";
|
|
2
2
|
export { defaultFeatureFlagRules, evaluateFeatureFlag, evaluateFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, getFeatureFlagRules, normalizeFeatureFlagRules, type FeatureFlagMode, type FeatureFlagRules, type FeatureFlagScope, } from "./store.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, getFeatureFlagDefinition, listFeatureFlags, registerFeatureFlags, } from "./registry.js";
|
|
1
|
+
export { BUILDER_CREDIT_USAGE_REPORTING_FLAG, CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, getFeatureFlagDefinition, listFeatureFlags, registerFeatureFlags, } from "./registry.js";
|
|
2
2
|
export { defaultFeatureFlagRules, evaluateFeatureFlag, evaluateFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, getFeatureFlagRules, normalizeFeatureFlagRules, } from "./store.js";
|
|
3
3
|
// Plugin and A2A auth stay on `./server` and `@agent-native/core/server`.
|
|
4
4
|
// Re-exporting them here pulls HMAC Node builtins into any Vite client that
|
|
@@ -10,6 +10,7 @@ export interface FeatureFlagDefinition {
|
|
|
10
10
|
export declare function defineFeatureFlag(definition: FeatureFlagDefinition): FeatureFlagDefinition;
|
|
11
11
|
/** Framework-owned labs flag available to every app's feature-flag plugin. */
|
|
12
12
|
export declare const CONNECT_APPS_FLAG: FeatureFlagDefinition;
|
|
13
|
+
export declare const BUILDER_CREDIT_USAGE_REPORTING_FLAG: FeatureFlagDefinition;
|
|
13
14
|
/** Define a small app-owned feature-flag registry. */
|
|
14
15
|
export declare function defineFeatureFlags(definitions: readonly FeatureFlagDefinition[]): readonly FeatureFlagDefinition[];
|
|
15
16
|
/** Register definitions once at Nitro startup. Re-registering identical data is safe for HMR. */
|
|
@@ -25,6 +25,11 @@ export const CONNECT_APPS_FLAG = defineFeatureFlag({
|
|
|
25
25
|
displayName: "Connect apps",
|
|
26
26
|
description: "Show the experimental app connection surface.",
|
|
27
27
|
});
|
|
28
|
+
export const BUILDER_CREDIT_USAGE_REPORTING_FLAG = defineFeatureFlag({
|
|
29
|
+
key: "billing.builder-credit-usage-reporting",
|
|
30
|
+
displayName: "Builder credit usage reporting",
|
|
31
|
+
description: "Use the Builder gateway's reported credit charges in usage reports.",
|
|
32
|
+
});
|
|
28
33
|
/** Define a small app-owned feature-flag registry. */
|
|
29
34
|
export function defineFeatureFlags(definitions) {
|
|
30
35
|
const seen = new Set();
|
|
@@ -44,9 +44,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
44
44
|
url: string;
|
|
45
45
|
id: string;
|
|
46
46
|
provider: string;
|
|
47
|
-
error?: undefined;
|
|
48
47
|
configured?: undefined;
|
|
49
48
|
connectPath?: undefined;
|
|
49
|
+
error?: undefined;
|
|
50
50
|
} | {
|
|
51
51
|
url?: undefined;
|
|
52
52
|
id?: undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { createDevScriptRegistry } from "./scripts/dev/index.js";
|
|
|
11
11
|
export { createAgentChatPlugin, defaultAgentChatPlugin, createAgentNativeEmbeddedPlugin, mountAgentNativeEmbedded, createServer, createSSEHandler, defineNitroPlugin, autoMountAuth, getSession, type AgentChatPluginOptions, type AgentNativeEmbeddedPluginOptions, type AuthSession, type AuthOptions, type CreateServerOptions, type SSEHandlerOptions, } from "./root-server-compat.js";
|
|
12
12
|
export { BUILT_IN_INTEGRATION_CATALOG, INTEGRATION_CATEGORIES, getIntegrationCatalogEntry, listBuiltInChannelIntegrations, listIntegrationCatalog, type AutomationCapabilities, type BuiltInChannelId, type ChannelCapabilities, type IntegrationAvailability, type IntegrationCatalogEntry, type IntegrationCategory, type IntegrationCredentialRequirement, type IntegrationIconKey, type IntegrationSupportMaturity, } from "./integrations/catalog.js";
|
|
13
13
|
export { AutomationConnectorError, createAutomationCallbackHandler, createAutomationRuntime, createInvokeAutomationWorkflowAction, type AutomationCallbackAuthentication, type AutomationCallbackInput, type AutomationCallbackResult, type AutomationInboundDefinition, type AutomationInvocation, type AutomationInvocationResult, type AutomationInvocationStatus, type AutomationOutboundDefinition, type AutomationResponseMode, type AutomationRetryPolicy, type AutomationRuntime, type AutomationRuntimeOptions, type AutomationWorkflowCapabilities, type AutomationWorkflowDefinition, type JsonSchema, } from "./automation/index.js";
|
|
14
|
-
export { CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, evaluateFeatureFlag, getFeatureFlagDefinition, getFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, listFeatureFlags, registerFeatureFlags, type FeatureFlagDefinition, type FeatureFlagMode, type FeatureFlagRules, type FeatureFlagScope, } from "./feature-flags/index.js";
|
|
14
|
+
export { BUILDER_CREDIT_USAGE_REPORTING_FLAG, CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, evaluateFeatureFlag, getFeatureFlagDefinition, getFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, listFeatureFlags, registerFeatureFlags, type FeatureFlagDefinition, type FeatureFlagMode, type FeatureFlagRules, type FeatureFlagScope, } from "./feature-flags/index.js";
|
|
15
15
|
export { createFeatureFlagA2AActionRouteAuth, createFeatureFlagsPlugin, } from "./feature-flags/server.js";
|
|
16
16
|
export { defineLab, defineLabs, getLabDefinition, listLabs, registerLabs, type LabDefinition, } from "./labs/index.js";
|
|
17
17
|
export { createLabsPlugin } from "./labs/server.js";
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { createDevScriptRegistry } from "./scripts/dev/index.js";
|
|
|
16
16
|
export { createAgentChatPlugin, defaultAgentChatPlugin, createAgentNativeEmbeddedPlugin, mountAgentNativeEmbedded, createServer, createSSEHandler, defineNitroPlugin, autoMountAuth, getSession, } from "./root-server-compat.js";
|
|
17
17
|
export { BUILT_IN_INTEGRATION_CATALOG, INTEGRATION_CATEGORIES, getIntegrationCatalogEntry, listBuiltInChannelIntegrations, listIntegrationCatalog, } from "./integrations/catalog.js";
|
|
18
18
|
export { AutomationConnectorError, createAutomationCallbackHandler, createAutomationRuntime, createInvokeAutomationWorkflowAction, } from "./automation/index.js";
|
|
19
|
-
export { CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, evaluateFeatureFlag, getFeatureFlagDefinition, getFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, listFeatureFlags, registerFeatureFlags, } from "./feature-flags/index.js";
|
|
19
|
+
export { BUILDER_CREDIT_USAGE_REPORTING_FLAG, CONNECT_APPS_FLAG, defineFeatureFlag, defineFeatureFlags, evaluateFeatureFlag, getFeatureFlagDefinition, getFeatureFlagRules, hasActiveFeatureFlagRollout, isFeatureFlagEnabled, listFeatureFlags, registerFeatureFlags, } from "./feature-flags/index.js";
|
|
20
20
|
export { createFeatureFlagA2AActionRouteAuth, createFeatureFlagsPlugin, } from "./feature-flags/server.js";
|
|
21
21
|
export { defineLab, defineLabs, getLabDefinition, listLabs, registerLabs, } from "./labs/index.js";
|
|
22
22
|
export { createLabsPlugin } from "./labs/server.js";
|
|
@@ -1448,7 +1448,8 @@ async function recordIntegrationUsage(options) {
|
|
|
1448
1448
|
(usage.inputTokens <= 0 &&
|
|
1449
1449
|
usage.outputTokens <= 0 &&
|
|
1450
1450
|
usage.cacheReadTokens <= 0 &&
|
|
1451
|
-
usage.cacheWriteTokens <= 0
|
|
1451
|
+
usage.cacheWriteTokens <= 0 &&
|
|
1452
|
+
usage.builderCreditsUsed == null)) {
|
|
1452
1453
|
return;
|
|
1453
1454
|
}
|
|
1454
1455
|
try {
|
|
@@ -1459,6 +1460,8 @@ async function recordIntegrationUsage(options) {
|
|
|
1459
1460
|
outputTokens: usage.outputTokens,
|
|
1460
1461
|
cacheReadTokens: usage.cacheReadTokens,
|
|
1461
1462
|
cacheWriteTokens: usage.cacheWriteTokens,
|
|
1463
|
+
builderCreditsUsed: usage.builderCreditsUsed,
|
|
1464
|
+
engineName: usage.engineName,
|
|
1462
1465
|
model: usage.model,
|
|
1463
1466
|
label: `integration:${options.incoming.platform}`,
|
|
1464
1467
|
app: options.appId,
|