@agent-native/core 0.76.0 → 0.76.1
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/core/CHANGELOG.md +41 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/durable-background.ts +38 -2
- package/corpus/core/src/agent/production-agent.ts +54 -0
- package/corpus/core/src/agent/run-manager.ts +27 -0
- package/corpus/core/src/agent/run-store.ts +185 -4
- package/corpus/core/src/server/agent-chat-plugin.ts +71 -0
- package/corpus/core/src/server/auth.ts +13 -0
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +12 -12
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +23 -23
- package/corpus/templates/analytics/app/pages/analyses/AnalysesList.tsx +2 -2
- package/corpus/templates/brain/app/routes/knowledge.tsx +6 -6
- package/corpus/templates/brain/app/routes/ops.tsx +4 -4
- package/corpus/templates/brain/app/routes/search.tsx +4 -4
- package/corpus/templates/brain/app/routes/settings.tsx +3 -3
- package/corpus/templates/brain/app/routes/sources.tsx +3 -3
- package/dist/agent/durable-background.d.ts +15 -0
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +28 -2
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +34 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts +8 -0
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +18 -1
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +99 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +155 -4
- package/dist/agent/run-store.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +58 -1
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +12 -0
- package/dist/server/auth.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ import { AGENT_TEAM_PROCESS_RUN_PATH, getCurrentDelegationDepth, processAgentTea
|
|
|
27
27
|
import { setProgressPreListHook } from "../progress/store.js";
|
|
28
28
|
import { verifyInternalToken, extractBearerToken, } from "../integrations/internal-token.js";
|
|
29
29
|
import { hasConfiguredA2ASecret, isA2AProductionRuntime, } from "../a2a/auth-policy.js";
|
|
30
|
-
import { AGENT_CHAT_PROCESS_RUN_PATH, prepareProcessRunRequest, } from "../agent/durable-background.js";
|
|
30
|
+
import { AGENT_CHAT_PROCESS_RUN_PATH, extractProcessRunId, prepareProcessRunRequest, } from "../agent/durable-background.js";
|
|
31
31
|
import { getBuilderBrowserConnectUrlForOwner, resolveBuilderBranchProjectId, } from "./builder-browser.js";
|
|
32
32
|
import { captureCliOutput } from "./cli-capture.js";
|
|
33
33
|
import { withConfiguredAppBasePath } from "./app-base-path.js";
|
|
@@ -5566,6 +5566,14 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
5566
5566
|
status: run.status,
|
|
5567
5567
|
heartbeatAt: run.heartbeatAt,
|
|
5568
5568
|
lastProgressAt: run.lastProgressAt,
|
|
5569
|
+
// Durable-background diagnostics: how the run was dispatched and
|
|
5570
|
+
// the last reached `_process-run` worker stage (JSON
|
|
5571
|
+
// `{stage,detail?,at}`). Surfaced here so a silent background
|
|
5572
|
+
// worker death is diagnosable from the client WITHOUT the
|
|
5573
|
+
// unreadable Netlify background-function logs — read
|
|
5574
|
+
// `/runs/active?threadId=...` and inspect `diagStage`.
|
|
5575
|
+
dispatchMode: run.dispatchMode ?? null,
|
|
5576
|
+
diagStage: run.diagStage ?? null,
|
|
5569
5577
|
// Server clock so the client computes "stuck" elapsed time
|
|
5570
5578
|
// server-relative, immune to client clock skew.
|
|
5571
5579
|
serverNow: Date.now(),
|
|
@@ -6119,6 +6127,18 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
6119
6127
|
setResponseStatus(event, 405);
|
|
6120
6128
|
return { error: "Method not allowed" };
|
|
6121
6129
|
}
|
|
6130
|
+
// DIAGNOSTIC: load the run-store diagnostic recorder. Each stage we
|
|
6131
|
+
// reach is written onto the run row (diag_stage) so a silent failure
|
|
6132
|
+
// INSIDE the Netlify background function — whose logs we cannot read —
|
|
6133
|
+
// is still diagnosable from the client via /runs/active. Best-effort:
|
|
6134
|
+
// the import + every record call is wrapped so diagnostics can never
|
|
6135
|
+
// break the worker path.
|
|
6136
|
+
const diag = await import("../agent/run-store.js")
|
|
6137
|
+
.then((m) => ({
|
|
6138
|
+
record: m.recordRunDiagnostic,
|
|
6139
|
+
stages: m.RUN_DIAG_STAGE,
|
|
6140
|
+
}))
|
|
6141
|
+
.catch(() => null);
|
|
6122
6142
|
// Consume the body ONCE (h3 v2's web Request stream is single-use).
|
|
6123
6143
|
let processBody;
|
|
6124
6144
|
try {
|
|
@@ -6128,14 +6148,44 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
6128
6148
|
setResponseStatus(event, 400);
|
|
6129
6149
|
return { error: "Invalid request body" };
|
|
6130
6150
|
}
|
|
6151
|
+
// Record "the route handler was entered" against the run BEFORE auth
|
|
6152
|
+
// runs. This is the proof the bg-fn invocation actually reached Nitro
|
|
6153
|
+
// (vs. dying at the function entry / never being invoked). The runId
|
|
6154
|
+
// is parsed without authenticating so we can attach it even on a
|
|
6155
|
+
// subsequent auth failure.
|
|
6156
|
+
const diagRunId = extractProcessRunId(processBody);
|
|
6157
|
+
if (diag && diagRunId) {
|
|
6158
|
+
await diag
|
|
6159
|
+
.record(diagRunId, diag.stages.routeEntered)
|
|
6160
|
+
.catch(() => { });
|
|
6161
|
+
}
|
|
6131
6162
|
// Validate + HMAC-authenticate the self-dispatch and prepare the
|
|
6132
6163
|
// background-worker body. Pure decision (unit-tested in
|
|
6133
6164
|
// durable-background.spec.ts); the route only wires it to h3.
|
|
6134
6165
|
const prepared = prepareProcessRunRequest(processBody, getHeader(event, "authorization"));
|
|
6135
6166
|
if (!prepared.ok) {
|
|
6167
|
+
// DIAGNOSTIC: record the auth/validation failure ONTO the run
|
|
6168
|
+
// before returning the error status. Without this, a 401 (e.g.
|
|
6169
|
+
// A2A_SECRET missing/mismatched in the bg-fn env, or the path not
|
|
6170
|
+
// bypassing session auth) inside the unreadable bg function would
|
|
6171
|
+
// leave the run to time out with NO clue. The detail carries the
|
|
6172
|
+
// status + whether A2A_SECRET is even present in this isolate.
|
|
6173
|
+
if (diag && prepared.runId) {
|
|
6174
|
+
const a2aPresent = Boolean(process.env.A2A_SECRET && process.env.A2A_SECRET.length > 0);
|
|
6175
|
+
await diag
|
|
6176
|
+
.record(prepared.runId, diag.stages.authFailed, `status=${prepared.status} error=${prepared.error} a2aSecretPresent=${a2aPresent}`)
|
|
6177
|
+
.catch(() => { });
|
|
6178
|
+
}
|
|
6136
6179
|
setResponseStatus(event, prepared.status);
|
|
6137
6180
|
return { error: prepared.error };
|
|
6138
6181
|
}
|
|
6182
|
+
// DIAGNOSTIC: auth + body validation passed. Reaching here proves the
|
|
6183
|
+
// request was authenticated and we are about to invoke the worker.
|
|
6184
|
+
if (diag) {
|
|
6185
|
+
await diag
|
|
6186
|
+
.record(prepared.runId, diag.stages.authPassed)
|
|
6187
|
+
.catch(() => { });
|
|
6188
|
+
}
|
|
6139
6189
|
// Stash the verified+augmented body for the handler — the body stream
|
|
6140
6190
|
// is already consumed, so the handler reads this instead.
|
|
6141
6191
|
event.context = event.context ?? {};
|
|
@@ -6145,6 +6195,13 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
6145
6195
|
}
|
|
6146
6196
|
catch (err) {
|
|
6147
6197
|
console.error("[agent-chat] _process-run failed:", err);
|
|
6198
|
+
// DIAGNOSTIC: the worker invocation threw at the route boundary —
|
|
6199
|
+
// record the message so the failure cause is readable client-side.
|
|
6200
|
+
if (diag) {
|
|
6201
|
+
await diag
|
|
6202
|
+
.record(prepared.runId, diag.stages.routeThrew, err instanceof Error ? err.message : String(err))
|
|
6203
|
+
.catch(() => { });
|
|
6204
|
+
}
|
|
6148
6205
|
setResponseStatus(event, 500);
|
|
6149
6206
|
return { error: "process-run failed" };
|
|
6150
6207
|
}
|