@agent-native/core 0.133.0 → 0.133.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.
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
- error?: undefined;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
69
+ error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,10 +77,10 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
- error?: undefined;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
86
86
  //# sourceMappingURL=awareness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"awareness.d.ts","sourceRoot":"","sources":["../../src/collab/awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAOD,eAAO,MAAM,sBAAsB,EAAG,kBAA2B,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,MAAM,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2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wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAmB,GAC7B,IAAI,CAON;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE1E;AAiBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAO1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAOnE;AAkCD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;kBAwDa,MAAM;eAAS,MAAM;;;GAoB1D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;kBAYM,MAAM;kBAAY,MAAM;;;GAMvD,CAAC"}
@@ -13,8 +13,8 @@
13
13
  * Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
14
14
  */
15
15
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
16
- ok?: undefined;
17
16
  error: string;
17
+ ok?: undefined;
18
18
  } | {
19
19
  error?: undefined;
20
20
  ok: boolean;
@@ -17,12 +17,12 @@ declare const _default: import("../../action.js").ActionDefinition<{
17
17
  id?: undefined;
18
18
  provider?: undefined;
19
19
  } | {
20
+ error?: undefined;
20
21
  configured?: undefined;
21
22
  connectPath?: undefined;
22
23
  url: string;
23
24
  id: string;
24
25
  provider: string;
25
- error?: undefined;
26
26
  }>;
27
27
  export default _default;
28
28
  //# sourceMappingURL=upload-image.d.ts.map
@@ -11,14 +11,14 @@
11
11
  * DELETE /_agent-native/notifications/:id — delete
12
12
  */
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
- error?: undefined;
15
14
  count: number;
16
15
  updated?: undefined;
16
+ error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- error?: undefined;
20
19
  count?: undefined;
21
20
  updated: number;
21
+ error?: undefined;
22
22
  ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
@@ -26,9 +26,9 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
26
26
  error: string;
27
27
  ok?: undefined;
28
28
  } | {
29
- error?: undefined;
30
29
  count?: undefined;
31
30
  updated?: undefined;
32
31
  ok: boolean;
32
+ error?: undefined;
33
33
  }>>;
34
34
  //# sourceMappingURL=routes.d.ts.map
@@ -41,16 +41,16 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
44
  summary: import("./types.js").TraceSummary;
46
45
  spans: import("./types.js").TraceSpan[];
47
46
  id?: undefined;
47
+ error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
50
- error?: undefined;
51
50
  summary?: undefined;
52
51
  spans?: undefined;
53
52
  id: string;
53
+ error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
56
  summary?: undefined;
@@ -59,10 +59,10 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
59
59
  error: any;
60
60
  ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
66
65
  ok: boolean;
66
+ error?: undefined;
67
67
  }>>;
68
68
  //# sourceMappingURL=routes.d.ts.map
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- ok?: undefined;
52
51
  error: string;
52
+ ok?: undefined;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -27,11 +27,11 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
- error?: undefined;
31
30
  ok: boolean;
32
31
  key: string;
33
32
  baseUrlKey?: string;
34
33
  scope: AgentEngineApiKeyScope;
34
+ error?: undefined;
35
35
  }>>;
36
36
  export {};
37
37
  //# sourceMappingURL=agent-engine-api-key-route.d.ts.map
@@ -20,7 +20,7 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- error?: undefined;
24
23
  text: string;
24
+ error?: undefined;
25
25
  }>>;
26
26
  //# sourceMappingURL=transcribe-voice.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.133.0",
3
+ "version": "0.133.1",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -23,6 +23,10 @@ import {
23
23
  supportsClaudeAdaptiveThinking,
24
24
  } from "../../shared/reasoning-effort.js";
25
25
  import { AI_SDK_MODEL_CONFIG, type AISDKProvider } from "../model-config.js";
26
+ import {
27
+ LLM_MISSING_CREDENTIALS_ERROR_CODE,
28
+ LLM_MISSING_CREDENTIALS_MESSAGE,
29
+ } from "./credential-errors.js";
26
30
  import {
27
31
  classifyProviderError,
28
32
  describeErrorWithCauses,
@@ -228,6 +232,8 @@ class AISDKEngine implements AgentEngine {
228
232
  private readonly provider: AISDKProvider;
229
233
  private readonly apiKey?: string;
230
234
  private readonly baseUrl?: string;
235
+ /** Empty for providers that need no key (ollama). */
236
+ private readonly requiredEnvVars: readonly string[];
231
237
  private readonly appName?: string;
232
238
  private readonly appUrl?: string;
233
239
 
@@ -243,12 +249,34 @@ class AISDKEngine implements AgentEngine {
243
249
  this.apiKey =
244
250
  config.apiKey ??
245
251
  (config.allowEnvFallback === false ? "" : getProviderApiKey(provider));
252
+ this.requiredEnvVars = PROVIDER_ENV_VARS[provider];
246
253
  this.baseUrl = config.baseUrl;
247
254
  this.appName = config.appName;
248
255
  this.appUrl = config.appUrl;
249
256
  }
250
257
 
251
258
  async *stream(opts: EngineStreamOptions): AsyncIterable<EngineEvent> {
259
+ // An absent key is not an anonymous request. Without this the provider
260
+ // factory is constructed with no `apiKey`, the SDK omits the Authorization
261
+ // header entirely, and the gateway's 401 comes back as
262
+ // "Missing Authentication header" — which `classifyProviderError` codes
263
+ // `http_401`, a transport failure naming the wrong cause. A scheduled job
264
+ // then repeats that doomed unauthenticated request on every tick forever.
265
+ // `builder-engine` and `anthropic-engine` already fail closed here; this
266
+ // engine was the only one that did not.
267
+ //
268
+ // A configured `baseUrl` is exempt: a self-hosted or local gateway may
269
+ // legitimately accept unauthenticated requests.
270
+ if (!this.apiKey && !this.baseUrl && this.requiredEnvVars.length > 0) {
271
+ yield {
272
+ type: "stop",
273
+ reason: "error",
274
+ error: `${LLM_MISSING_CREDENTIALS_MESSAGE} (engine "${this.name}" has no ${this.requiredEnvVars.join(" or ")})`,
275
+ errorCode: LLM_MISSING_CREDENTIALS_ERROR_CODE,
276
+ };
277
+ return;
278
+ }
279
+
252
280
  let aiModule: any;
253
281
  try {
254
282
  aiModule = await import("ai");
@@ -736,7 +736,13 @@ function backgroundAwareStaleCutoffSql(): string {
736
736
  // `CAST(? AS BIGINT)` is required: without it Postgres infers the param as
737
737
  // int4 from the int4 window literals, so the bound `Date.now()` ms epoch
738
738
  // overflows int4. The cast keeps the subtraction 64-bit; a no-op on SQLite.
739
- return `(CAST(? AS BIGINT) - CASE WHEN dispatch_mode = 'background-processing' THEN ${BACKGROUND_PROCESSING_RUN_STALE_MS} WHEN dispatch_mode LIKE 'background%' THEN ${BACKGROUND_RUN_STALE_MS} ELSE ${RUN_STALE_MS} END)`;
739
+ // The tight post-claim window buys ONE thing: reaching the durable successor
740
+ // sooner (see BACKGROUND_PROCESSING_RUN_STALE_MS). A row with no
741
+ // `dispatch_payload` has no successor to reach — `attemptStaleRunRecovery`
742
+ // declines it as `not_redispatchable` — so reaping it early is pure loss: it
743
+ // kills an in-process background automation (scheduler/trigger) that is still
744
+ // working, and nothing recovers it. Those get the wider background window.
745
+ return `(CAST(? AS BIGINT) - CASE WHEN dispatch_mode = 'background-processing' AND dispatch_payload IS NOT NULL THEN ${BACKGROUND_PROCESSING_RUN_STALE_MS} WHEN dispatch_mode LIKE 'background%' THEN ${BACKGROUND_RUN_STALE_MS} ELSE ${RUN_STALE_MS} END)`;
740
746
  }
741
747
 
742
748
  function terminalRunEventExclusionSql(runIdColumn = "id"): string {
@@ -1546,7 +1552,7 @@ interface StaleRunRecoverySuccessor {
1546
1552
  type StaleRunRecoveryOutcome =
1547
1553
  | ({ outcome: "recovered" } & StaleRunRecoverySuccessor)
1548
1554
  | { outcome: "not_background" }
1549
- | { outcome: "payload_missing" }
1555
+ | { outcome: "not_redispatchable" }
1550
1556
  | { outcome: "newer_run_exists" }
1551
1557
  | { outcome: "budget_exhausted" }
1552
1558
  | { outcome: "repeated_no_progress" };
@@ -1596,7 +1602,9 @@ function staleRecoveryDispatchPayload(payload: string): string {
1596
1602
  * - the row is a background chat-turn dispatch (`dispatch_mode` starting
1597
1603
  * with "background") — a foreground/foreground-self-chain run has a
1598
1604
  * connected client to recover it via its own `auto_continue` re-POST.
1599
- * - its `dispatch_payload` is still present without it there is nothing
1605
+ * - its `dispatch_payload` is still present (an in-process automation run
1606
+ * never had one and is declined as `not_redispatchable`, not as a loss)
1607
+ * — without it there is nothing
1600
1608
  * to rehydrate the successor's request body from. Read HERE, before the
1601
1609
  * caller's terminal write (which NULLs `dispatch_payload` on every other
1602
1610
  * path), so it survives long enough to carry over.
@@ -1633,7 +1641,14 @@ async function attemptStaleRunRecovery(
1633
1641
  }
1634
1642
  const payload = row.dispatch_payload;
1635
1643
  if (typeof payload !== "string" || payload.length === 0) {
1636
- return { outcome: "payload_missing" };
1644
+ // Not an anomaly, and specifically NOT a lost payload: every HTTP-dispatched
1645
+ // background run writes `dispatch_payload` in the same INSERT that creates
1646
+ // the row, so a payload-less row is one that was never HTTP-dispatched at
1647
+ // all — an in-process automation from `runBackgroundAutomation`. It has no
1648
+ // request body to rehydrate because there was never a request. Naming this
1649
+ // `payload_missing` read as "we are losing payloads" in production
1650
+ // forensics and sent a reader hunting a bug that does not exist.
1651
+ return { outcome: "not_redispatchable" };
1637
1652
  }
1638
1653
  const threadId = row.thread_id;
1639
1654
  const turnId = row.turn_id ?? runId;