@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
|
@@ -13,6 +13,7 @@ import { mountDbAdminRoutes } from "../db-admin/routes.js";
|
|
|
13
13
|
import { getDbExec, isProductionServerlessFunctionRuntime, } from "../db/client.js";
|
|
14
14
|
import { getDatabaseRuntimeFingerprint, getEffectiveDatabaseEnvStatus, getRuntimeDebugFingerprint, runDatabaseSchemaHealthCheck, } from "../db/runtime-diagnostics.js";
|
|
15
15
|
import { ssrfSafeFetch } from "../extensions/url-safety.js";
|
|
16
|
+
import { BUILDER_CREDIT_USAGE_REPORTING_FLAG, registerFeatureFlags, } from "../feature-flags/registry.js";
|
|
16
17
|
import { uploadFile, getActiveFileUploadProviderForRequest, listFileUploadProviders, } from "../file-upload/index.js";
|
|
17
18
|
import { ensureS3FileUploadProvider } from "../file-upload/s3.js";
|
|
18
19
|
import { CHATGPT_SUBSCRIPTION_LAB } from "../labs/core-labs.js";
|
|
@@ -1298,6 +1299,7 @@ export function createCoreRoutesPlugin(options = {}) {
|
|
|
1298
1299
|
const googleOAuthManagedConnection = options.googleOAuthManagedConnection ?? "unknown";
|
|
1299
1300
|
return async (nitroApp) => {
|
|
1300
1301
|
markDefaultPluginProvided(nitroApp, "core-routes");
|
|
1302
|
+
registerFeatureFlags([BUILDER_CREDIT_USAGE_REPORTING_FLAG]);
|
|
1301
1303
|
registerLabs([CHATGPT_SUBSCRIPTION_LAB]);
|
|
1302
1304
|
// No-op when called from inside the bootstrap (auto-mount path).
|
|
1303
1305
|
// Otherwise wait so other default plugins finish mounting first.
|
package/dist/server/embedded.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markEmbeddedRuntimeAuthorized } from "../db/embedded-runtime.js";
|
|
1
2
|
import { createIntegrationsPlugin, } from "../integrations/index.js";
|
|
2
3
|
import { createOnboardingPlugin } from "../onboarding/plugin.js";
|
|
3
4
|
import { createOrgPlugin } from "../org/plugin.js";
|
|
@@ -49,6 +50,11 @@ export function configureAgentNativeEmbeddedEnvironment(options) {
|
|
|
49
50
|
}
|
|
50
51
|
if (options.databaseUrl) {
|
|
51
52
|
process.env.DATABASE_URL = options.databaseUrl; // guard:allow-env-mutation — embedded plugin boot-time configuration, not request-scoped state
|
|
53
|
+
// A packaged/desktop host can legitimately run this with NODE_ENV=production
|
|
54
|
+
// and a pglite: URL — exempt it from assertHostedRuntimeDatabase()'s guard,
|
|
55
|
+
// which otherwise can't tell that apart from a deploy silently falling back
|
|
56
|
+
// to PGlite because nobody configured DATABASE_URL.
|
|
57
|
+
markEmbeddedRuntimeAuthorized();
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
export function createAgentNativeEmbeddedAuthOptions(auth) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getHeader, setResponseHeader, setResponseStatus } from "h3";
|
|
2
2
|
import { AppConfigurationError } from "../app-config/index.js";
|
|
3
|
+
import { markServerRuntimeStarted } from "../db/server-runtime.js";
|
|
3
4
|
import { getMissingDefaultPlugins } from "../deploy/route-discovery.js";
|
|
4
5
|
import { MCP_PUBLIC_ROUTE_PREFIX } from "../mcp/route-paths.js";
|
|
5
6
|
import { SIGN_IN_ENTRY_PATH, SIGN_IN_LEGACY_ENTRY_PATH, } from "../shared/sign-in-journey.js";
|
|
@@ -185,6 +186,11 @@ export function getH3App(nitroApp) {
|
|
|
185
186
|
nitroApp[APP_SHIM_KEY] = shim;
|
|
186
187
|
if (!BOOTSTRAPPED.has(nitroApp)) {
|
|
187
188
|
BOOTSTRAPPED.add(nitroApp);
|
|
189
|
+
// A real nitroApp instance exists, wiring its H3 app for real requests —
|
|
190
|
+
// the one cross-platform signal bare Node/Docker has for "this process is
|
|
191
|
+
// actually serving" (see db/server-runtime.js). A build never reaches
|
|
192
|
+
// this: it never constructs a real nitroApp.
|
|
193
|
+
markServerRuntimeStarted();
|
|
188
194
|
// Parse now, decide later. An unknown slot name in `plugins.disabled` is
|
|
189
195
|
// an invalid deployment, not a plugin that failed to start, and the catch
|
|
190
196
|
// below would turn it into an app with every default route missing — so
|
|
@@ -59,8 +59,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
|
|
|
59
59
|
expiresAt?: undefined;
|
|
60
60
|
ttlSeconds?: undefined;
|
|
61
61
|
} | {
|
|
62
|
-
error?: undefined;
|
|
63
62
|
token: string;
|
|
64
63
|
expiresAt: string;
|
|
65
64
|
ttlSeconds: number;
|
|
65
|
+
error?: undefined;
|
|
66
66
|
}>>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineAction } from "../../action.js";
|
|
3
|
+
import { BUILDER_CREDIT_USAGE_REPORTING_FLAG } from "../../feature-flags/registry.js";
|
|
4
|
+
import { isFeatureFlagEnabled } from "../../feature-flags/store.js";
|
|
3
5
|
import { listAppUsageMetrics } from "../metrics-store.js";
|
|
4
6
|
import { resolveUsageAppKey } from "../store.js";
|
|
5
7
|
export default defineAction({
|
|
@@ -14,7 +16,8 @@ export default defineAction({
|
|
|
14
16
|
run: async ({ sinceDays, scope, userEmail, appId }, ctx) => {
|
|
15
17
|
if (!ctx?.userEmail)
|
|
16
18
|
throw new Error("Not authenticated.");
|
|
17
|
-
|
|
19
|
+
const builderCreditsEnabled = await isFeatureFlagEnabled(BUILDER_CREDIT_USAGE_REPORTING_FLAG, { userEmail: ctx.userEmail, orgId: ctx.orgId });
|
|
20
|
+
return listAppUsageMetrics({ sinceDays, scope, userEmail, builderCreditsEnabled }, {
|
|
18
21
|
ownerEmail: ctx.userEmail,
|
|
19
22
|
orgId: ctx.orgId,
|
|
20
23
|
app: resolveUsageAppKey(appId),
|
|
@@ -9,6 +9,9 @@ export interface UsageMetricBucket {
|
|
|
9
9
|
outputTokens: number;
|
|
10
10
|
cacheReadTokens: number;
|
|
11
11
|
cacheWriteTokens: number;
|
|
12
|
+
builderCredits?: number;
|
|
13
|
+
estimatedBuilderCredits?: number;
|
|
14
|
+
otherCostCents?: number;
|
|
12
15
|
activeUsers: number;
|
|
13
16
|
lastActiveAt: number | null;
|
|
14
17
|
}
|
|
@@ -17,6 +20,10 @@ export interface UsageDailyMetric {
|
|
|
17
20
|
costCents: number;
|
|
18
21
|
calls: number;
|
|
19
22
|
tokens: number;
|
|
23
|
+
builderCredits?: number;
|
|
24
|
+
estimatedBuilderCredits?: number;
|
|
25
|
+
otherCostCents?: number;
|
|
26
|
+
otherCalls?: number;
|
|
20
27
|
}
|
|
21
28
|
export interface UsageRecentMetric {
|
|
22
29
|
id: number;
|
|
@@ -30,6 +37,10 @@ export interface UsageRecentMetric {
|
|
|
30
37
|
cacheReadTokens: number;
|
|
31
38
|
cacheWriteTokens: number;
|
|
32
39
|
costCents: number;
|
|
40
|
+
builderCredits?: number;
|
|
41
|
+
estimatedBuilderCredits?: number;
|
|
42
|
+
otherCostCents?: number;
|
|
43
|
+
engineName?: string | null;
|
|
33
44
|
prompt: string | null;
|
|
34
45
|
promptSource: "thread" | "thread-preview" | "not-captured" | "unavailable";
|
|
35
46
|
threadId: string | null;
|
|
@@ -64,10 +75,17 @@ export interface AppUsageMetrics {
|
|
|
64
75
|
cacheReadTokens: number;
|
|
65
76
|
cacheWriteTokens: number;
|
|
66
77
|
activeUsers: number;
|
|
78
|
+
builderCredits?: number;
|
|
79
|
+
estimatedBuilderCredits?: number;
|
|
80
|
+
otherCostCents?: number;
|
|
81
|
+
otherCalls?: number;
|
|
67
82
|
};
|
|
68
83
|
currentDay: {
|
|
69
84
|
costCents: number;
|
|
70
85
|
credits: number;
|
|
86
|
+
estimatedBuilderCredits?: number;
|
|
87
|
+
otherCostCents?: number;
|
|
88
|
+
otherCalls?: number;
|
|
71
89
|
calls: number;
|
|
72
90
|
tokens: number;
|
|
73
91
|
};
|
|
@@ -91,5 +109,6 @@ export declare function listAppUsageMetrics(input: {
|
|
|
91
109
|
sinceDays?: number;
|
|
92
110
|
scope?: UsageMetricsScope;
|
|
93
111
|
userEmail?: string | null;
|
|
112
|
+
builderCreditsEnabled?: boolean;
|
|
94
113
|
}, accessInput: UsageMetricsAccessInput): Promise<AppUsageMetrics>;
|
|
95
114
|
export {};
|
|
@@ -2,7 +2,7 @@ import { getAppConfig } from "../app-config/index.js";
|
|
|
2
2
|
import { getDbExec } from "../db/client.js";
|
|
3
3
|
import { ForbiddenError } from "../sharing/access.js";
|
|
4
4
|
import { isSelfScopedUsageRead, usageOrgScope } from "./org-scope.js";
|
|
5
|
-
import { builderCreditsFromCostCents, usageBillingForEngine, } from "./store.js";
|
|
5
|
+
import { builderCreditsFromCostCents, ensureUsageTable, usageBillingForEngine, MIXED_USAGE_BILLING, } from "./store.js";
|
|
6
6
|
const DAY_MS = 86_400_000;
|
|
7
7
|
function numberField(row, key) {
|
|
8
8
|
return Number(row[key] ?? 0) || 0;
|
|
@@ -133,7 +133,7 @@ async function resolveScope(input, scope, requestedUserEmail) {
|
|
|
133
133
|
function buildUsageCost(row) {
|
|
134
134
|
return numberField(row, "cost_x100") / 100;
|
|
135
135
|
}
|
|
136
|
-
function bucketFromRow(row) {
|
|
136
|
+
function bucketFromRow(row, builderCreditsEnabled) {
|
|
137
137
|
const key = stringField(row, "k");
|
|
138
138
|
return {
|
|
139
139
|
key,
|
|
@@ -144,14 +144,24 @@ function bucketFromRow(row) {
|
|
|
144
144
|
outputTokens: numberField(row, "output_tokens"),
|
|
145
145
|
cacheReadTokens: numberField(row, "cache_read_tokens"),
|
|
146
146
|
cacheWriteTokens: numberField(row, "cache_write_tokens"),
|
|
147
|
+
...(builderCreditsEnabled
|
|
148
|
+
? {
|
|
149
|
+
builderCredits: numberField(row, "builder_credits"),
|
|
150
|
+
estimatedBuilderCredits: builderCreditsFromCostCents(numberField(row, "estimated_builder_cost_x100") / 100),
|
|
151
|
+
otherCostCents: numberField(row, "other_cost_x100") / 100,
|
|
152
|
+
}
|
|
153
|
+
: {}),
|
|
147
154
|
activeUsers: numberField(row, "active_users"),
|
|
148
155
|
lastActiveAt: row.last_active_at == null ? null : numberField(row, "last_active_at"),
|
|
149
156
|
};
|
|
150
157
|
}
|
|
151
|
-
async function usageBuckets(columnExpression, scope, appScope, sinceMs, limit) {
|
|
158
|
+
async function usageBuckets(columnExpression, scope, appScope, sinceMs, limit, builderCreditsEnabled) {
|
|
152
159
|
const result = await getDbExec().execute({
|
|
153
160
|
sql: `SELECT ${columnExpression} AS k,
|
|
154
161
|
COALESCE(SUM(cost_cents_x100), 0) AS cost_x100,
|
|
162
|
+
COALESCE(SUM(builder_credits_used), 0) AS builder_credits,
|
|
163
|
+
COALESCE(SUM(CASE WHEN engine_name = 'builder' AND builder_credits_used IS NULL THEN cost_cents_x100 ELSE 0 END), 0) AS estimated_builder_cost_x100,
|
|
164
|
+
COALESCE(SUM(CASE WHEN engine_name IS DISTINCT FROM 'builder' AND builder_credits_used IS NULL THEN cost_cents_x100 ELSE 0 END), 0) AS other_cost_x100,
|
|
155
165
|
COUNT(*) AS calls,
|
|
156
166
|
COALESCE(SUM(input_tokens), 0) AS input_tokens,
|
|
157
167
|
COALESCE(SUM(output_tokens), 0) AS output_tokens,
|
|
@@ -162,11 +172,11 @@ async function usageBuckets(columnExpression, scope, appScope, sinceMs, limit) {
|
|
|
162
172
|
FROM token_usage
|
|
163
173
|
WHERE ${appScope.where} AND ${scope.where} AND created_at >= ?
|
|
164
174
|
GROUP BY ${columnExpression}
|
|
165
|
-
ORDER BY cost_x100 DESC
|
|
175
|
+
ORDER BY ${builderCreditsEnabled ? "builder_credits DESC, estimated_builder_cost_x100 DESC, other_cost_x100 DESC" : "cost_x100 DESC"}
|
|
166
176
|
LIMIT ?`,
|
|
167
177
|
args: [...appScope.args, ...scope.args, sinceMs, limit],
|
|
168
178
|
});
|
|
169
|
-
return result.rows.map(bucketFromRow);
|
|
179
|
+
return result.rows.map((row) => bucketFromRow(row, builderCreditsEnabled));
|
|
170
180
|
}
|
|
171
181
|
function parseJson(value) {
|
|
172
182
|
if (typeof value !== "string" || !value.trim())
|
|
@@ -221,7 +231,7 @@ function firstUserPrompt(threadData) {
|
|
|
221
231
|
}
|
|
222
232
|
return null;
|
|
223
233
|
}
|
|
224
|
-
async function hydrateRecentPrompts(rows) {
|
|
234
|
+
async function hydrateRecentPrompts(rows, builderCreditsEnabled) {
|
|
225
235
|
const threadIds = [
|
|
226
236
|
...new Set(rows
|
|
227
237
|
.map((row) => nullableStringField(row, "thread_id"))
|
|
@@ -262,6 +272,21 @@ async function hydrateRecentPrompts(rows) {
|
|
|
262
272
|
cacheReadTokens: numberField(row, "cache_read_tokens"),
|
|
263
273
|
cacheWriteTokens: numberField(row, "cache_write_tokens"),
|
|
264
274
|
costCents: numberField(row, "cost_cents_x100") / 100,
|
|
275
|
+
...(builderCreditsEnabled
|
|
276
|
+
? {
|
|
277
|
+
...(row.builder_credits_used != null
|
|
278
|
+
? { builderCredits: numberField(row, "builder_credits_used") }
|
|
279
|
+
: row.engine_name === "builder"
|
|
280
|
+
? {
|
|
281
|
+
estimatedBuilderCredits: builderCreditsFromCostCents(numberField(row, "cost_cents_x100") / 100),
|
|
282
|
+
}
|
|
283
|
+
: {}),
|
|
284
|
+
otherCostCents: row.engine_name === "builder" || row.builder_credits_used != null
|
|
285
|
+
? 0
|
|
286
|
+
: numberField(row, "cost_cents_x100") / 100,
|
|
287
|
+
engineName: nullableStringField(row, "engine_name"),
|
|
288
|
+
}
|
|
289
|
+
: {}),
|
|
265
290
|
prompt: prompt ?? (preview ? preview.slice(0, 359).trimEnd() : null),
|
|
266
291
|
promptSource: prompt
|
|
267
292
|
? "thread"
|
|
@@ -290,7 +315,9 @@ async function detectUsageEngineName() {
|
|
|
290
315
|
return getAppConfig().agent.engine ?? null;
|
|
291
316
|
}
|
|
292
317
|
export async function listAppUsageMetrics(input, accessInput) {
|
|
318
|
+
await ensureUsageTable();
|
|
293
319
|
const scope = input.scope === "workspace" ? "workspace" : "me";
|
|
320
|
+
const builderCreditsEnabled = input.builderCreditsEnabled === true;
|
|
294
321
|
const sinceDays = Math.max(1, Math.min(365, input.sinceDays ?? 30));
|
|
295
322
|
const now = Date.now();
|
|
296
323
|
const sinceMs = now - sinceDays * DAY_MS;
|
|
@@ -304,6 +331,11 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
304
331
|
getDbExec().execute({
|
|
305
332
|
sql: `SELECT
|
|
306
333
|
COALESCE(SUM(cost_cents_x100), 0) AS cost_x100,
|
|
334
|
+
COALESCE(SUM(builder_credits_used), 0) AS builder_credits,
|
|
335
|
+
COALESCE(SUM(CASE WHEN engine_name = 'builder' AND builder_credits_used IS NULL THEN cost_cents_x100 ELSE 0 END), 0) AS estimated_builder_cost_x100,
|
|
336
|
+
COALESCE(SUM(CASE WHEN engine_name IS DISTINCT FROM 'builder' AND builder_credits_used IS NULL THEN cost_cents_x100 ELSE 0 END), 0) AS other_cost_x100,
|
|
337
|
+
COUNT(*) FILTER (WHERE engine_name = 'builder' OR builder_credits_used IS NOT NULL) AS builder_calls,
|
|
338
|
+
COUNT(*) FILTER (WHERE engine_name IS DISTINCT FROM 'builder' AND builder_credits_used IS NULL) AS other_calls,
|
|
307
339
|
COUNT(*) AS calls,
|
|
308
340
|
COALESCE(SUM(input_tokens), 0) AS input_tokens,
|
|
309
341
|
COALESCE(SUM(output_tokens), 0) AS output_tokens,
|
|
@@ -314,11 +346,11 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
314
346
|
WHERE ${appScope.where} AND ${resolved.ownerScope.where} AND created_at >= ?`,
|
|
315
347
|
args: baseArgs,
|
|
316
348
|
}),
|
|
317
|
-
usageBuckets("COALESCE(NULLIF(label, ''), 'chat')", resolved.ownerScope, appScope, sinceMs, 6),
|
|
318
|
-
usageBuckets("COALESCE(NULLIF(model, ''), 'unknown')", resolved.ownerScope, appScope, sinceMs, 4),
|
|
349
|
+
usageBuckets("COALESCE(NULLIF(label, ''), 'chat')", resolved.ownerScope, appScope, sinceMs, 6, builderCreditsEnabled),
|
|
350
|
+
usageBuckets("COALESCE(NULLIF(model, ''), 'unknown')", resolved.ownerScope, appScope, sinceMs, 4, builderCreditsEnabled),
|
|
319
351
|
getDbExec().execute({
|
|
320
352
|
sql: `SELECT created_at, cost_cents_x100, input_tokens, output_tokens,
|
|
321
|
-
cache_read_tokens, cache_write_tokens FROM token_usage
|
|
353
|
+
cache_read_tokens, cache_write_tokens, builder_credits_used, engine_name FROM token_usage
|
|
322
354
|
WHERE ${appScope.where} AND ${resolved.ownerScope.where} AND created_at >= ?
|
|
323
355
|
ORDER BY created_at ASC`,
|
|
324
356
|
args: baseArgs,
|
|
@@ -326,7 +358,7 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
326
358
|
getDbExec().execute({
|
|
327
359
|
sql: `SELECT id, created_at, owner_email, app, label, model,
|
|
328
360
|
input_tokens, output_tokens, cache_read_tokens, cache_write_tokens,
|
|
329
|
-
cost_cents_x100, thread_id
|
|
361
|
+
cost_cents_x100, builder_credits_used, engine_name, thread_id
|
|
330
362
|
FROM token_usage
|
|
331
363
|
WHERE ${appScope.where} AND ${resolved.ownerScope.where} AND created_at >= ?
|
|
332
364
|
ORDER BY created_at DESC
|
|
@@ -340,8 +372,26 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
340
372
|
const date = new Date(numberField(row, "created_at"))
|
|
341
373
|
.toISOString()
|
|
342
374
|
.slice(0, 10);
|
|
343
|
-
const current = dayMap.get(date) ?? {
|
|
375
|
+
const current = dayMap.get(date) ?? {
|
|
376
|
+
costX100: 0,
|
|
377
|
+
calls: 0,
|
|
378
|
+
tokens: 0,
|
|
379
|
+
builderCredits: 0,
|
|
380
|
+
estimatedBuilderCostX100: 0,
|
|
381
|
+
otherCostX100: 0,
|
|
382
|
+
otherCalls: 0,
|
|
383
|
+
};
|
|
344
384
|
current.costX100 += numberField(row, "cost_cents_x100");
|
|
385
|
+
if (row.builder_credits_used != null) {
|
|
386
|
+
current.builderCredits += numberField(row, "builder_credits_used");
|
|
387
|
+
}
|
|
388
|
+
else if (row.engine_name === "builder") {
|
|
389
|
+
current.estimatedBuilderCostX100 += numberField(row, "cost_cents_x100");
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
current.otherCostX100 += numberField(row, "cost_cents_x100");
|
|
393
|
+
current.otherCalls += 1;
|
|
394
|
+
}
|
|
345
395
|
current.calls += 1;
|
|
346
396
|
current.tokens +=
|
|
347
397
|
numberField(row, "input_tokens") +
|
|
@@ -356,6 +406,14 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
356
406
|
costCents: value.costX100 / 100,
|
|
357
407
|
calls: value.calls,
|
|
358
408
|
tokens: value.tokens,
|
|
409
|
+
...(builderCreditsEnabled
|
|
410
|
+
? {
|
|
411
|
+
builderCredits: value.builderCredits,
|
|
412
|
+
estimatedBuilderCredits: builderCreditsFromCostCents(value.estimatedBuilderCostX100 / 100),
|
|
413
|
+
otherCostCents: value.otherCostX100 / 100,
|
|
414
|
+
otherCalls: value.otherCalls,
|
|
415
|
+
}
|
|
416
|
+
: {}),
|
|
359
417
|
}))
|
|
360
418
|
.sort((a, b) => a.date.localeCompare(b.date));
|
|
361
419
|
const today = new Date(now).toISOString().slice(0, 10);
|
|
@@ -364,9 +422,27 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
364
422
|
costCents: 0,
|
|
365
423
|
calls: 0,
|
|
366
424
|
tokens: 0,
|
|
425
|
+
...(builderCreditsEnabled
|
|
426
|
+
? {
|
|
427
|
+
builderCredits: 0,
|
|
428
|
+
estimatedBuilderCredits: 0,
|
|
429
|
+
otherCostCents: 0,
|
|
430
|
+
otherCalls: 0,
|
|
431
|
+
}
|
|
432
|
+
: {}),
|
|
367
433
|
};
|
|
368
|
-
const
|
|
369
|
-
const
|
|
434
|
+
const builderCalls = numberField(totals, "builder_calls");
|
|
435
|
+
const otherCalls = numberField(totals, "other_calls");
|
|
436
|
+
const billing = builderCreditsEnabled
|
|
437
|
+
? builderCalls && otherCalls
|
|
438
|
+
? MIXED_USAGE_BILLING
|
|
439
|
+
: builderCalls
|
|
440
|
+
? usageBillingForEngine("builder")
|
|
441
|
+
: otherCalls
|
|
442
|
+
? usageBillingForEngine(null)
|
|
443
|
+
: usageBillingForEngine(await detectUsageEngineName())
|
|
444
|
+
: usageBillingForEngine(await detectUsageEngineName());
|
|
445
|
+
const recent = await hydrateRecentPrompts(recentResult.rows, builderCreditsEnabled);
|
|
370
446
|
return {
|
|
371
447
|
billing,
|
|
372
448
|
app,
|
|
@@ -388,10 +464,26 @@ export async function listAppUsageMetrics(input, accessInput) {
|
|
|
388
464
|
cacheReadTokens: numberField(totals, "cache_read_tokens"),
|
|
389
465
|
cacheWriteTokens: numberField(totals, "cache_write_tokens"),
|
|
390
466
|
activeUsers: numberField(totals, "active_users"),
|
|
467
|
+
...(builderCreditsEnabled
|
|
468
|
+
? {
|
|
469
|
+
builderCredits: numberField(totals, "builder_credits"),
|
|
470
|
+
estimatedBuilderCredits: builderCreditsFromCostCents(numberField(totals, "estimated_builder_cost_x100") / 100),
|
|
471
|
+
otherCostCents: numberField(totals, "other_cost_x100") / 100,
|
|
472
|
+
otherCalls,
|
|
473
|
+
}
|
|
474
|
+
: {}),
|
|
391
475
|
},
|
|
392
476
|
currentDay: {
|
|
393
477
|
costCents: currentDay.costCents,
|
|
394
|
-
credits:
|
|
478
|
+
credits: currentDay.builderCredits ??
|
|
479
|
+
builderCreditsFromCostCents(currentDay.costCents),
|
|
480
|
+
...(builderCreditsEnabled
|
|
481
|
+
? {
|
|
482
|
+
estimatedBuilderCredits: currentDay.estimatedBuilderCredits ?? 0,
|
|
483
|
+
otherCostCents: currentDay.otherCostCents ?? 0,
|
|
484
|
+
otherCalls: currentDay.otherCalls ?? 0,
|
|
485
|
+
}
|
|
486
|
+
: {}),
|
|
395
487
|
calls: currentDay.calls,
|
|
396
488
|
tokens: currentDay.tokens,
|
|
397
489
|
},
|
package/dist/usage/store.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export { isSelfScopedUsageRead, usageOrgScope, type UsageOrgScope, type UsageOrgScopeOptions, } from "./org-scope.js";
|
|
2
2
|
export declare const BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER = 1.25;
|
|
3
3
|
export declare const BUILDER_AGENT_CREDITS_PER_USD = 20;
|
|
4
|
-
export type UsageBillingUnit = "usd" | "builder-credits";
|
|
4
|
+
export type UsageBillingUnit = "usd" | "builder-credits" | "mixed";
|
|
5
5
|
export interface UsageBillingMode {
|
|
6
6
|
unit: UsageBillingUnit;
|
|
7
7
|
label: string;
|
|
8
8
|
shortLabel: string;
|
|
9
|
-
source: "estimated-provider-cost" | "builder-agent-credits";
|
|
9
|
+
source: "estimated-provider-cost" | "builder-agent-credits" | "mixed-provider-usage";
|
|
10
10
|
hardCostMarginMultiplier?: number;
|
|
11
11
|
creditsPerUsd?: number;
|
|
12
12
|
}
|
|
13
13
|
export declare const USD_USAGE_BILLING: UsageBillingMode;
|
|
14
14
|
export declare const BUILDER_CREDIT_USAGE_BILLING: UsageBillingMode;
|
|
15
|
+
export declare const MIXED_USAGE_BILLING: UsageBillingMode;
|
|
15
16
|
export declare function usageBillingForEngine(engineName: string | null | undefined): UsageBillingMode;
|
|
16
17
|
export declare function builderCreditsFromCostCents(cents: number): number;
|
|
17
18
|
export interface UsageRecord {
|
|
@@ -37,6 +38,10 @@ export interface UsageRecord {
|
|
|
37
38
|
* provider-reported dollar cost so two surfaces agree exactly.
|
|
38
39
|
*/
|
|
39
40
|
costCentsX100?: number;
|
|
41
|
+
/** Exact credits reported by the Builder gateway for this run, when available. */
|
|
42
|
+
builderCreditsUsed?: number;
|
|
43
|
+
/** Engine selected for this call; nullable on historical and external usage rows. */
|
|
44
|
+
engineName?: string;
|
|
40
45
|
/** Whether cost is provider-reported, estimated, or unavailable. */
|
|
41
46
|
costSource?: UsageCostSource;
|
|
42
47
|
/** Defaults to the active request organization when omitted. */
|
package/dist/usage/store.js
CHANGED
|
@@ -29,6 +29,12 @@ export const BUILDER_CREDIT_USAGE_BILLING = {
|
|
|
29
29
|
hardCostMarginMultiplier: BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,
|
|
30
30
|
creditsPerUsd: BUILDER_AGENT_CREDITS_PER_USD,
|
|
31
31
|
};
|
|
32
|
+
export const MIXED_USAGE_BILLING = {
|
|
33
|
+
unit: "mixed",
|
|
34
|
+
label: "Builder credits and provider cost",
|
|
35
|
+
shortLabel: "Mixed",
|
|
36
|
+
source: "mixed-provider-usage",
|
|
37
|
+
};
|
|
32
38
|
export function usageBillingForEngine(engineName) {
|
|
33
39
|
return engineName === "builder"
|
|
34
40
|
? BUILDER_CREDIT_USAGE_BILLING
|
|
@@ -172,6 +178,8 @@ export async function ensureUsageTable() {
|
|
|
172
178
|
cache_read_tokens BIGINT NOT NULL DEFAULT 0,
|
|
173
179
|
cache_write_tokens BIGINT NOT NULL DEFAULT 0,
|
|
174
180
|
cost_cents_x100 BIGINT NOT NULL DEFAULT 0,
|
|
181
|
+
builder_credits_used NUMERIC,
|
|
182
|
+
engine_name TEXT,
|
|
175
183
|
cost_source TEXT NOT NULL DEFAULT 'estimated',
|
|
176
184
|
model TEXT NOT NULL DEFAULT '',
|
|
177
185
|
label TEXT NOT NULL DEFAULT 'chat',
|
|
@@ -192,6 +200,8 @@ export async function ensureUsageTable() {
|
|
|
192
200
|
const additions = [
|
|
193
201
|
["cache_read_tokens", `BIGINT NOT NULL DEFAULT 0`],
|
|
194
202
|
["cache_write_tokens", `BIGINT NOT NULL DEFAULT 0`],
|
|
203
|
+
["builder_credits_used", "NUMERIC"],
|
|
204
|
+
["engine_name", "TEXT"],
|
|
195
205
|
["cost_source", `TEXT NOT NULL DEFAULT 'estimated'`],
|
|
196
206
|
["label", `TEXT NOT NULL DEFAULT 'chat'`],
|
|
197
207
|
["app", `TEXT NOT NULL DEFAULT ''`],
|
|
@@ -288,10 +298,19 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
288
298
|
model: model ?? "",
|
|
289
299
|
}
|
|
290
300
|
: recordOrOwner;
|
|
291
|
-
const { ownerEmail, inputTokens: inTok, outputTokens: outTok, cacheReadTokens = 0, cacheWriteTokens = 0, model: modelName, label, app, refId, costCentsX100, costSource, orgId, runId, threadId, taskId, integrationScopeId, sourcePlatform, sourceId, } = record;
|
|
301
|
+
const { ownerEmail, inputTokens: inTok, outputTokens: outTok, cacheReadTokens = 0, cacheWriteTokens = 0, model: modelName, label, app, refId, costCentsX100, builderCreditsUsed, engineName, costSource, orgId, runId, threadId, taskId, integrationScopeId, sourcePlatform, sourceId, } = record;
|
|
292
302
|
// Skip no-op writes (e.g. a stream aborted before any tokens flowed)
|
|
293
|
-
if (!inTok &&
|
|
303
|
+
if (!inTok &&
|
|
304
|
+
!outTok &&
|
|
305
|
+
!cacheReadTokens &&
|
|
306
|
+
!cacheWriteTokens &&
|
|
307
|
+
builderCreditsUsed == null) {
|
|
294
308
|
return;
|
|
309
|
+
}
|
|
310
|
+
if (builderCreditsUsed != null &&
|
|
311
|
+
(!Number.isFinite(builderCreditsUsed) || builderCreditsUsed < 0)) {
|
|
312
|
+
throw new Error("Builder gateway credits must be a non-negative number.");
|
|
313
|
+
}
|
|
295
314
|
await ensureUsageTable();
|
|
296
315
|
const client = getDbExec();
|
|
297
316
|
const resolvedApp = resolveUsageAppKey(app);
|
|
@@ -319,8 +338,8 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
319
338
|
const id = Date.now() * 1000 + Math.floor(Math.random() * 1000);
|
|
320
339
|
await client.execute({
|
|
321
340
|
sql: `INSERT INTO token_usage
|
|
322
|
-
(id, owner_email, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost_cents_x100, cost_source, model, label, app, ref_id, org_id, run_id, thread_id, task_id, integration_scope_id, source_platform, source_id, created_at)
|
|
323
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
341
|
+
(id, owner_email, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost_cents_x100, builder_credits_used, engine_name, cost_source, model, label, app, ref_id, org_id, run_id, thread_id, task_id, integration_scope_id, source_platform, source_id, created_at)
|
|
342
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
324
343
|
args: [
|
|
325
344
|
id,
|
|
326
345
|
ownerEmail,
|
|
@@ -329,6 +348,8 @@ export async function recordUsage(recordOrOwner, inputTokens, outputTokens, mode
|
|
|
329
348
|
cacheReadTokens,
|
|
330
349
|
cacheWriteTokens,
|
|
331
350
|
costX100,
|
|
351
|
+
builderCreditsUsed ?? null,
|
|
352
|
+
engineName ?? null,
|
|
332
353
|
resolvedCostSource,
|
|
333
354
|
modelName,
|
|
334
355
|
resolvedLabel,
|
|
@@ -185,6 +185,10 @@ const CORE_SHARING_ACTIONS = [
|
|
|
185
185
|
name: "get-observability-review-app",
|
|
186
186
|
specifier: "@agent-native/core/observability/actions/get-observability-review-app",
|
|
187
187
|
},
|
|
188
|
+
{
|
|
189
|
+
name: "get-observability-review-detail",
|
|
190
|
+
specifier: "@agent-native/core/observability/actions/get-observability-review-detail",
|
|
191
|
+
},
|
|
188
192
|
{
|
|
189
193
|
name: "save-observability-instruction-update",
|
|
190
194
|
specifier: "@agent-native/core/observability/actions/save-observability-instruction-update",
|
package/dist/vite/client.d.ts
CHANGED
|
@@ -230,6 +230,11 @@ declare function nitroStartupGate(options?: {
|
|
|
230
230
|
timeoutMs?: number;
|
|
231
231
|
}): Plugin;
|
|
232
232
|
declare function nitroStartupRecovery(): Plugin;
|
|
233
|
+
declare function persistent5xxRecovery(options?: {
|
|
234
|
+
enabled?: boolean;
|
|
235
|
+
now?: () => number;
|
|
236
|
+
exit?: (code: number) => void;
|
|
237
|
+
}): Plugin;
|
|
233
238
|
declare function resolveNitroSsrServiceEntry(rootDir: string): string | undefined;
|
|
234
239
|
/**
|
|
235
240
|
* Ignores files inside these directories, judged from the app root only. A
|
|
@@ -261,4 +266,4 @@ export declare function agentNative(options?: AgentNativeVitePluginOptions): Plu
|
|
|
261
266
|
* preset. This compatibility wrapper remains for existing templates.
|
|
262
267
|
*/
|
|
263
268
|
export declare function defineConfig(options?: ClientConfigOptions): UserConfig;
|
|
264
|
-
export { devActionBridgePlugin as _devActionBridgePlugin, devActionBridgeOrigin as _devActionBridgeOrigin, getClientDedupe as _getClientDedupe, getDefaultOptimizeDeps as _getDefaultOptimizeDeps, findCorePackageRoot as _findCorePackageRoot, getReactRouterAliases as _getReactRouterAliases, nitroStartupGate as _nitroStartupGate, nitroStartupRecovery as _nitroStartupRecovery, nitroModuleGraphSignature as _nitroModuleGraphSignature, resolveNitroSsrServiceEntry as _resolveNitroSsrServiceEntry, debounceNitroFullReloadHotUpdate as _debounceNitroFullReloadHotUpdate, installReactRouterVirtualInvalidationMirror as _installReactRouterVirtualInvalidationMirror, mirrorReactRouterVirtualInvalidation as _mirrorReactRouterVirtualInvalidation, };
|
|
269
|
+
export { devActionBridgePlugin as _devActionBridgePlugin, devActionBridgeOrigin as _devActionBridgeOrigin, getClientDedupe as _getClientDedupe, getDefaultOptimizeDeps as _getDefaultOptimizeDeps, findCorePackageRoot as _findCorePackageRoot, getReactRouterAliases as _getReactRouterAliases, nitroStartupGate as _nitroStartupGate, nitroStartupRecovery as _nitroStartupRecovery, persistent5xxRecovery as _persistent5xxRecovery, nitroModuleGraphSignature as _nitroModuleGraphSignature, resolveNitroSsrServiceEntry as _resolveNitroSsrServiceEntry, debounceNitroFullReloadHotUpdate as _debounceNitroFullReloadHotUpdate, installReactRouterVirtualInvalidationMirror as _installReactRouterVirtualInvalidationMirror, mirrorReactRouterVirtualInvalidation as _mirrorReactRouterVirtualInvalidation, };
|
package/dist/vite/client.js
CHANGED
|
@@ -7,6 +7,7 @@ import { renderDesignSystemThemeCss, } from "@agent-native/toolkit/design-system
|
|
|
7
7
|
import { loadEnv, } from "vite";
|
|
8
8
|
import { getAppConfig } from "../app-config/index.js";
|
|
9
9
|
import { mergePendingChangelog, parsePendingEntry, } from "../changelog/parse.js";
|
|
10
|
+
import { DEV_SERVER_RECOVERY_EXIT_CODE, DEV_SERVER_SUPERVISOR_ENV, } from "../cli/process.js";
|
|
10
11
|
import { getViteDevRecoveryScript } from "../client/vite-dev-recovery-script.js";
|
|
11
12
|
import { inferAgentNativeDeploymentEnvironment, mergeAgentNativeConfigs, readAgentNativeConfigEnv, resolveAgentNativeConfig, } from "../config.js";
|
|
12
13
|
import { getRuntimeDatabaseUrl } from "../db/client.js";
|
|
@@ -2810,6 +2811,43 @@ function nitroStartupRecovery() {
|
|
|
2810
2811
|
},
|
|
2811
2812
|
};
|
|
2812
2813
|
}
|
|
2814
|
+
function persistent5xxRecovery(options = {}) {
|
|
2815
|
+
return {
|
|
2816
|
+
name: "agent-native-persistent-5xx-recovery",
|
|
2817
|
+
apply: "serve",
|
|
2818
|
+
enforce: "pre",
|
|
2819
|
+
configureServer(server) {
|
|
2820
|
+
if (!(options.enabled ?? process.env[DEV_SERVER_SUPERVISOR_ENV] === "1")) {
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
const now = options.now ?? Date.now;
|
|
2824
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
2825
|
+
let hasServedHealthyResponse = false;
|
|
2826
|
+
let first5xxAt;
|
|
2827
|
+
server.middlewares.use((req, res, next) => {
|
|
2828
|
+
if (!isHtmlDocumentRequest(req)) {
|
|
2829
|
+
next();
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
res.once("finish", () => {
|
|
2833
|
+
if ((res.statusCode ?? 500) < 500) {
|
|
2834
|
+
hasServedHealthyResponse = true;
|
|
2835
|
+
first5xxAt = undefined;
|
|
2836
|
+
return;
|
|
2837
|
+
}
|
|
2838
|
+
const failedAt = now();
|
|
2839
|
+
first5xxAt ??= failedAt;
|
|
2840
|
+
if (!hasServedHealthyResponse || failedAt - first5xxAt <= 75_000) {
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2843
|
+
console.error(`[agent-native] Dev server kept returning HTTP ${res.statusCode} after recovery; restarting.`);
|
|
2844
|
+
exit(DEV_SERVER_RECOVERY_EXIT_CODE);
|
|
2845
|
+
});
|
|
2846
|
+
next();
|
|
2847
|
+
});
|
|
2848
|
+
},
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2813
2851
|
/**
|
|
2814
2852
|
* Silence benign connection-reset noise from Vite's dev middleware.
|
|
2815
2853
|
* Fires when a browser closes/reloads/navigates mid-request — the peer has
|
|
@@ -3297,6 +3335,7 @@ function createAgentNativePlugins(options, { command, includeReactTransform, use
|
|
|
3297
3335
|
? ["@better-auth/sso", "@better-auth/scim"]
|
|
3298
3336
|
: [];
|
|
3299
3337
|
return [
|
|
3338
|
+
persistent5xxRecovery(),
|
|
3300
3339
|
presetMarkerPlugin,
|
|
3301
3340
|
// Stub packages from `options.ssrStubs` in the SSR bundle so they
|
|
3302
3341
|
// don't bloat the edge worker. Opt-in per template — the framework
|
|
@@ -3836,4 +3875,4 @@ export function defineConfig(options = {}) {
|
|
|
3836
3875
|
],
|
|
3837
3876
|
};
|
|
3838
3877
|
}
|
|
3839
|
-
export { devActionBridgePlugin as _devActionBridgePlugin, devActionBridgeOrigin as _devActionBridgeOrigin, getClientDedupe as _getClientDedupe, getDefaultOptimizeDeps as _getDefaultOptimizeDeps, findCorePackageRoot as _findCorePackageRoot, getReactRouterAliases as _getReactRouterAliases, nitroStartupGate as _nitroStartupGate, nitroStartupRecovery as _nitroStartupRecovery, nitroModuleGraphSignature as _nitroModuleGraphSignature, resolveNitroSsrServiceEntry as _resolveNitroSsrServiceEntry, debounceNitroFullReloadHotUpdate as _debounceNitroFullReloadHotUpdate, installReactRouterVirtualInvalidationMirror as _installReactRouterVirtualInvalidationMirror, mirrorReactRouterVirtualInvalidation as _mirrorReactRouterVirtualInvalidation, };
|
|
3878
|
+
export { devActionBridgePlugin as _devActionBridgePlugin, devActionBridgeOrigin as _devActionBridgeOrigin, getClientDedupe as _getClientDedupe, getDefaultOptimizeDeps as _getDefaultOptimizeDeps, findCorePackageRoot as _findCorePackageRoot, getReactRouterAliases as _getReactRouterAliases, nitroStartupGate as _nitroStartupGate, nitroStartupRecovery as _nitroStartupRecovery, persistent5xxRecovery as _persistent5xxRecovery, nitroModuleGraphSignature as _nitroModuleGraphSignature, resolveNitroSsrServiceEntry as _resolveNitroSsrServiceEntry, debounceNitroFullReloadHotUpdate as _debounceNitroFullReloadHotUpdate, installReactRouterVirtualInvalidationMirror as _installReactRouterVirtualInvalidationMirror, mirrorReactRouterVirtualInvalidation as _mirrorReactRouterVirtualInvalidation, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.187.
|
|
3
|
+
"version": "0.187.1-nightly-20260925003003",
|
|
4
4
|
"description": "The agentic application framework for building autonomous agents with intuitive UIs",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -187,6 +187,7 @@
|
|
|
187
187
|
"./client/observability": "./dist/client/observability/index.js",
|
|
188
188
|
"./observability/actions/list-observability-reviews": "./dist/observability/actions/list-observability-reviews.js",
|
|
189
189
|
"./observability/actions/get-observability-review-app": "./dist/observability/actions/get-observability-review-app.js",
|
|
190
|
+
"./observability/actions/get-observability-review-detail": "./dist/observability/actions/get-observability-review-detail.js",
|
|
190
191
|
"./observability/actions/save-observability-instruction-update": "./dist/observability/actions/save-observability-instruction-update.js",
|
|
191
192
|
"./client/onboarding": "./dist/client/onboarding/index.js",
|
|
192
193
|
"./client/setup-connections": "./dist/client/setup-connections/index.js",
|
|
@@ -498,9 +499,9 @@
|
|
|
498
499
|
"yaml": "^2.9.0",
|
|
499
500
|
"yjs": "^13.6.32",
|
|
500
501
|
"zod": "^4.3.6",
|
|
501
|
-
"@agent-native/
|
|
502
|
+
"@agent-native/agentkit": "^0.2.9",
|
|
502
503
|
"@agent-native/toolkit": "^0.20.9",
|
|
503
|
-
"@agent-native/
|
|
504
|
+
"@agent-native/recap-cli": "0.5.39"
|
|
504
505
|
},
|
|
505
506
|
"devDependencies": {
|
|
506
507
|
"@ai-sdk/anthropic": "^3.0.71",
|