@agent-native/core 0.79.5 → 0.79.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/docs/content/locales/zh-TW/durable-background-runs.md +74 -0
- package/corpus/core/package.json +2 -2
- package/corpus/core/scripts/check-dist-imports.mjs +35 -0
- package/corpus/core/src/agent/production-agent.ts +0 -93
- package/corpus/core/src/client/i18n.tsx +1 -1
- package/corpus/core/src/localization/default-messages.ts +492 -0
- package/corpus/templates/slides/actions/_app-url.ts +1 -1
- package/corpus/templates/slides/changelog/2026-06-26-deck-links-now-use-the-workspace-gateway-when-available-so-g.md +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +0 -79
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/client/i18n.d.ts.map +1 -1
- package/dist/client/i18n.js +1 -1
- package/dist/client/i18n.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/localization/default-messages.d.ts +443 -0
- package/dist/localization/default-messages.d.ts.map +1 -0
- package/dist/localization/default-messages.js +448 -0
- package/dist/localization/default-messages.js.map +1 -0
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +6 -6
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/server/agent-engine-api-key-route.d.ts +2 -2
- package/docs/content/locales/zh-TW/durable-background-runs.md +74 -0
- package/package.json +2 -2
|
@@ -2985,23 +2985,6 @@ export function createProductionAgentHandler(options) {
|
|
|
2985
2985
|
if (bgRunId)
|
|
2986
2986
|
void recordRunDiagnostic(bgRunId, RUN_DIAG_STAGE.workerSetupStep, `${s}=${Date.now() - setupT0}ms`).catch(() => { });
|
|
2987
2987
|
};
|
|
2988
|
-
// DIAGNOSTIC-ONLY: AWAITED worker mark. Fire-and-forget workerStep marks
|
|
2989
|
-
// after `post_model_ok` stopped landing even though writes still work
|
|
2990
|
-
// there — so the worker's MAIN FLOW stalls between post_model and pre_claim
|
|
2991
|
-
// (not a write hang). Awaited marks block until they land (or withDbTimeout-
|
|
2992
|
-
// reject), so `worker_stage` reliably advances to the last phase the main
|
|
2993
|
-
// flow actually reached — pinpointing the stall. Bg worker only.
|
|
2994
|
-
const awaitedWorkerMark = async (s) => {
|
|
2995
|
-
if (!isBackgroundWorker || !bgRunId)
|
|
2996
|
-
return;
|
|
2997
|
-
try {
|
|
2998
|
-
await recordRunDiagnostic(bgRunId, RUN_DIAG_STAGE.workerSetupStep, `${s}=${Date.now() - setupT0}ms`);
|
|
2999
|
-
}
|
|
3000
|
-
catch {
|
|
3001
|
-
// bounded by withDbTimeout; ignore — the absence of the next mark is
|
|
3002
|
-
// itself the signal.
|
|
3003
|
-
}
|
|
3004
|
-
};
|
|
3005
2988
|
// Whether this worker is REALLY executing inside a 15-min Netlify
|
|
3006
2989
|
// `-background` function (proven by the runtime function name), not merely a
|
|
3007
2990
|
// `_process-run` re-entry that may have landed on the ~60s synchronous
|
|
@@ -3197,42 +3180,12 @@ export function createProductionAgentHandler(options) {
|
|
|
3197
3180
|
? requestEffort
|
|
3198
3181
|
: options.reasoningEffort);
|
|
3199
3182
|
options.onEngineResolved?.(engine, model);
|
|
3200
|
-
// DIAGNOSTIC-ONLY: localize where the worker stalls AFTER model_done. These
|
|
3201
|
-
// land in `worker_stage` (foreground-independent), so even though the
|
|
3202
|
-
// foreground overwrites `diag_stage` on inline recovery, the worker's last
|
|
3203
|
-
// reached point survives. If the last worker_stage is `model_done`, writes
|
|
3204
|
-
// hang right after model resolution (DB connection); if it's
|
|
3205
|
-
// `engine_resolved`/`systemprompt_enter`, the stall is in the named step.
|
|
3206
|
-
workerStep("engine_resolved");
|
|
3207
|
-
// DIAGNOSTIC-ONLY: AWAITED probe (bg worker only). worker_stage stalls at
|
|
3208
|
-
// `model_done` even though the code right after is trivial sync — this
|
|
3209
|
-
// distinguishes the two causes: if `post_model_awaited` lands, DB writes
|
|
3210
|
-
// still work after model_done and the stall is later in the main flow; if it
|
|
3211
|
-
// never lands (stays `model_done`), the bg-fn DB connection itself is hung
|
|
3212
|
-
// right after model resolution. `recordRunDiagnostic` is `withDbTimeout`-
|
|
3213
|
-
// bounded, so a hung write rejects (caught) rather than blocking forever.
|
|
3214
|
-
if (isBackgroundWorker && bgRunId) {
|
|
3215
|
-
const probeStart = Date.now();
|
|
3216
|
-
try {
|
|
3217
|
-
await recordRunDiagnostic(bgRunId, RUN_DIAG_STAGE.workerSetupStep, "post_model_awaited");
|
|
3218
|
-
workerStep(`post_model_ok=${Date.now() - probeStart}ms`);
|
|
3219
|
-
}
|
|
3220
|
-
catch (e) {
|
|
3221
|
-
workerStep(`post_model_threw=${Date.now() - probeStart}ms:${String(e?.message ?? e).slice(0, 80)}`);
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
3183
|
// One-line per-turn resolution log so it's obvious in dev which engine
|
|
3225
3184
|
// is actually handling the request. `requestEngine` is what the client
|
|
3226
3185
|
// sent from the model picker; `engine.name` is what resolveEngine picked.
|
|
3227
3186
|
// Divergence between them is the usual cause of "status says builder but
|
|
3228
3187
|
// no [builder-engine] log lines appear" confusion.
|
|
3229
3188
|
console.log(`[agent-chat] resolved engine=${engine.name} model=${model} requestEngine=${requestEngine ?? "(none)"}`);
|
|
3230
|
-
// DIAGNOSTIC-ONLY: the worker reaches post_model_ok but never aw_env — the
|
|
3231
|
-
// only exit between them is this anthropic key check. Capture the exact
|
|
3232
|
-
// resolution state so we know WHY effectiveApiKey is falsy in the worker
|
|
3233
|
-
// (owner not resolved from the HMAC/thread? owner has no stored key? deploy
|
|
3234
|
-
// fallback blocked?) vs the foreground which resolves it fine.
|
|
3235
|
-
await awaitedWorkerMark(`apikey_state:engine=${engine.name},owner=${ownerEmail ? "Y" : "N"},userKey=${userApiKey ? "Y" : "N"},effKey=${effectiveApiKey ? "Y" : "N"},block=${shouldBlockDeployCredentialFallback()}`);
|
|
3236
3189
|
// Check for API key before starting a run (only for anthropic engine)
|
|
3237
3190
|
if (engine.name === "anthropic" && !effectiveApiKey) {
|
|
3238
3191
|
setResponseHeader(event, "Content-Type", "text/event-stream");
|
|
@@ -3255,7 +3208,6 @@ export function createProductionAgentHandler(options) {
|
|
|
3255
3208
|
// reached db_request_ctx but not env_config hung in attachment upload or
|
|
3256
3209
|
// engine/model resolution.
|
|
3257
3210
|
workerStep("env_config");
|
|
3258
|
-
await awaitedWorkerMark("aw_env");
|
|
3259
3211
|
// Run all independent pre-send steps in parallel. Each of these hits
|
|
3260
3212
|
// the DB or invokes an action; running them sequentially was the
|
|
3261
3213
|
// single biggest contributor to pre-LLM latency.
|
|
@@ -3267,16 +3219,10 @@ export function createProductionAgentHandler(options) {
|
|
|
3267
3219
|
let systemPromptError = null;
|
|
3268
3220
|
const systemPromptThunk = () => (async () => {
|
|
3269
3221
|
const sysPromptStart = Date.now();
|
|
3270
|
-
// Brackets the system-prompt build (which runs the template's
|
|
3271
|
-
// extraContext / data-dictionary). If worker_stage stalls at
|
|
3272
|
-
// `systemprompt_enter` with no `systemprompt_done`, the build itself is
|
|
3273
|
-
// the stall point.
|
|
3274
|
-
workerStep("systemprompt_enter");
|
|
3275
3222
|
try {
|
|
3276
3223
|
const built = typeof options.systemPrompt === "function"
|
|
3277
3224
|
? await options.systemPrompt(event)
|
|
3278
3225
|
: options.systemPrompt;
|
|
3279
|
-
workerStep("systemprompt_done");
|
|
3280
3226
|
return built;
|
|
3281
3227
|
}
|
|
3282
3228
|
catch (error) {
|
|
@@ -3512,7 +3458,6 @@ export function createProductionAgentHandler(options) {
|
|
|
3512
3458
|
// DIAGNOSTIC-ONLY: all parallel context gathering (system prompt, screen,
|
|
3513
3459
|
// files, loop settings, enriched message) resolved.
|
|
3514
3460
|
workerStep("context_all");
|
|
3515
|
-
await awaitedWorkerMark("aw_presend");
|
|
3516
3461
|
if (systemPromptError) {
|
|
3517
3462
|
setResponseHeader(event, "Content-Type", "text/event-stream");
|
|
3518
3463
|
setResponseHeader(event, "Cache-Control", "no-cache");
|
|
@@ -3534,7 +3479,6 @@ export function createProductionAgentHandler(options) {
|
|
|
3534
3479
|
setupMark("actions");
|
|
3535
3480
|
// DIAGNOSTIC-ONLY: action/tool resolution + engine-tool filtering finished.
|
|
3536
3481
|
workerStep("action_tool_setup");
|
|
3537
|
-
await awaitedWorkerMark("aw_actions");
|
|
3538
3482
|
const requestSystemPrompt = requestMode === "plan"
|
|
3539
3483
|
? `${systemPrompt}\n\n${PLAN_MODE_SYSTEM_PROMPT}`
|
|
3540
3484
|
: systemPrompt;
|
|
@@ -3634,7 +3578,6 @@ export function createProductionAgentHandler(options) {
|
|
|
3634
3578
|
// DIAGNOSTIC-ONLY: owner/thread resolution + runId/effectiveThreadId +
|
|
3635
3579
|
// chained-continuation thread fetch finished.
|
|
3636
3580
|
workerStep("owner_thread");
|
|
3637
|
-
await awaitedWorkerMark("aw_owner");
|
|
3638
3581
|
// Persist the user's turn exactly once. The foreground POST does this
|
|
3639
3582
|
// before dispatching; the background worker must NOT repeat it (it re-enters
|
|
3640
3583
|
// with the same body, which would double-persist the user message).
|
|
@@ -3991,28 +3934,6 @@ export function createProductionAgentHandler(options) {
|
|
|
3991
3934
|
// DIAGNOSTIC-ONLY: last stage before startRun fires. A worker that reaches
|
|
3992
3935
|
// prestart but never workerStarted is hanging inside startRun itself.
|
|
3993
3936
|
workerStep("prestart");
|
|
3994
|
-
// DIAGNOSTIC-ONLY: AWAITED probe right before startRun (bg worker only). If
|
|
3995
|
-
// worker_stage reaches `pre_claim_ok` but the run never flips to
|
|
3996
|
-
// `worker_started`, the stall is inside startRun's claim itself; if it never
|
|
3997
|
-
// reaches `pre_claim_*`, the stall is somewhere in the setup between
|
|
3998
|
-
// post_model and here.
|
|
3999
|
-
if (isBackgroundWorker && bgRunId) {
|
|
4000
|
-
const claimProbeStart = Date.now();
|
|
4001
|
-
try {
|
|
4002
|
-
await recordRunDiagnostic(bgRunId, RUN_DIAG_STAGE.workerSetupStep, "pre_claim");
|
|
4003
|
-
workerStep(`pre_claim_ok=${Date.now() - claimProbeStart}ms`);
|
|
4004
|
-
}
|
|
4005
|
-
catch (e) {
|
|
4006
|
-
workerStep(`pre_claim_threw=${Date.now() - claimProbeStart}ms:${String(e?.message ?? e).slice(0, 80)}`);
|
|
4007
|
-
}
|
|
4008
|
-
}
|
|
4009
|
-
// DIAGNOSTIC-ONLY: peak-ish RSS (MB) + assembled system-prompt size (KB) at
|
|
4010
|
-
// prestart. The analytics bg worker dies right after model_done; if the
|
|
4011
|
-
// FOREGROUND (identical build, writes land) is already near the ~1024MB
|
|
4012
|
-
// Netlify function limit, an OOM kill in the heavier worker explains the
|
|
4013
|
-
// freeze. Both numbers ride along in the existing setup-timings detail.
|
|
4014
|
-
setupMarks.rssMB = Math.round(process.memoryUsage().rss / 1048576);
|
|
4015
|
-
setupMarks.promptKB = Math.round((systemPrompt?.length ?? 0) / 1024);
|
|
4016
3937
|
const setupDetail = Object.entries(setupMarks)
|
|
4017
3938
|
.map(([k, v]) => `${k}=${v}`)
|
|
4018
3939
|
.join(" ") + ` total=${Date.now() - setupT0}`;
|