@agent-native/core 0.98.15 → 0.98.17

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.
@@ -1,5 +1,17 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.98.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bc381d: Preserve the authenticated owner context when delegated A2A agent runs are reconstructed by the processor.
8
+
9
+ ## 0.98.16
10
+
11
+ ### Patch Changes
12
+
13
+ - cc35446: Resolve the authenticated owner's active provider key for A2A and MCP ask-agent runs, matching the interactive chat engine path.
14
+
3
15
  ## 0.98.15
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.98.15",
3
+ "version": "0.98.17",
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": {
@@ -1252,9 +1252,25 @@ export function createAgentChatPlugin(
1252
1252
 
1253
1253
  // Use the SAME agent setup as the interactive chat — identical tools,
1254
1254
  // prompt, and capabilities. The A2A agent IS the app's agent.
1255
+ const { getOwnerActiveApiKey } =
1256
+ await import("../agent/production-agent.js");
1257
+ const ownerApiKey = await getOwnerActiveApiKey(userEmail);
1258
+ // A2A runs are reconstructed in a fresh processor request, so they
1259
+ // do not pass through the interactive handler's prepareRun hook.
1260
+ // Seed the same mutable run context before resolving the engine and
1261
+ // building tools. Provider credentials, team/fetch helpers, and
1262
+ // other action closures read this context rather than the engine
1263
+ // argument alone; without it delegated runs can silently fall back
1264
+ // to an unscoped/unconfigured provider path even though interactive
1265
+ // chat works for the same owner.
1266
+ const a2aRunContext = ensureRequestRunContext();
1267
+ if (a2aRunContext) {
1268
+ a2aRunContext.owner = userEmail;
1269
+ a2aRunContext.userApiKey = ownerApiKey;
1270
+ }
1255
1271
  const a2aEngine = await resolveEngine({
1256
1272
  engineOption: options?.engine,
1257
- apiKey: options?.apiKey,
1273
+ apiKey: ownerApiKey ?? options?.apiKey,
1258
1274
  appId: options?.appId,
1259
1275
  });
1260
1276
 
@@ -1279,6 +1295,7 @@ export function createAgentChatPlugin(
1279
1295
  const systemPrompt = devActive
1280
1296
  ? devPrompt + resources + schemaBlock + extra + runtimeContext
1281
1297
  : basePrompt + resources + schemaBlock + extra + runtimeContext;
1298
+ if (a2aRunContext) a2aRunContext.systemPrompt = systemPrompt;
1282
1299
 
1283
1300
  const a2aModelCandidate =
1284
1301
  options?.model ??
@@ -1287,6 +1304,10 @@ export function createAgentChatPlugin(
1287
1304
  })) ??
1288
1305
  a2aEngine.defaultModel;
1289
1306
  const model = normalizeModelForEngine(a2aEngine, a2aModelCandidate);
1307
+ if (a2aRunContext) {
1308
+ a2aRunContext.engine = a2aEngine;
1309
+ a2aRunContext.model = model;
1310
+ }
1290
1311
 
1291
1312
  // Build tools — same as interactive handler but WITHOUT call-agent
1292
1313
  // to prevent infinite recursive A2A loops (agent calling itself).
@@ -1524,9 +1545,15 @@ export function createAgentChatPlugin(
1524
1545
  ? { externalAgents: options.externalAgents }
1525
1546
  : {}),
1526
1547
  askAgent: async (message: string) => {
1548
+ const ownerEmail = getRequestUserEmail();
1549
+ const { getOwnerActiveApiKey } =
1550
+ await import("../agent/production-agent.js");
1551
+ const ownerApiKey = ownerEmail
1552
+ ? await getOwnerActiveApiKey(ownerEmail)
1553
+ : undefined;
1527
1554
  const mcpEngine = await resolveEngine({
1528
1555
  engineOption: options?.engine,
1529
- apiKey: options?.apiKey,
1556
+ apiKey: ownerApiKey ?? options?.apiKey,
1530
1557
  appId: options?.appId,
1531
1558
  });
1532
1559
  const mcpModelCandidate =
@@ -13,13 +13,13 @@
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
14
  count: number;
15
15
  updated?: undefined;
16
- ok?: undefined;
17
16
  error?: undefined;
17
+ ok?: undefined;
18
18
  } | {
19
19
  count?: undefined;
20
20
  updated: number;
21
- ok?: undefined;
22
21
  error?: undefined;
22
+ ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
25
25
  updated?: undefined;
@@ -28,7 +28,7 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
28
28
  } | {
29
29
  count?: undefined;
30
30
  updated?: undefined;
31
- ok: boolean;
32
31
  error?: undefined;
32
+ ok: boolean;
33
33
  }>>;
34
34
  //# sourceMappingURL=routes.d.ts.map
@@ -41,28 +41,28 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
+ error?: undefined;
45
+ ok?: undefined;
44
46
  summary: import("./types.js").TraceSummary;
45
47
  spans: import("./types.js").TraceSpan[];
46
48
  id?: undefined;
49
+ } | {
47
50
  error?: undefined;
48
51
  ok?: undefined;
49
- } | {
50
52
  summary?: undefined;
51
53
  spans?: undefined;
52
54
  id: string;
53
- error?: undefined;
54
- ok?: undefined;
55
55
  } | {
56
+ ok?: undefined;
56
57
  summary?: undefined;
57
58
  spans?: undefined;
58
59
  id?: undefined;
59
60
  error: any;
60
- ok?: undefined;
61
61
  } | {
62
+ error?: undefined;
62
63
  summary?: undefined;
63
64
  spans?: undefined;
64
65
  id?: undefined;
65
- error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
68
68
  //# sourceMappingURL=routes.d.ts.map
@@ -15,7 +15,7 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- error?: undefined;
19
18
  ok: boolean;
19
+ error?: undefined;
20
20
  }>>;
21
21
  //# sourceMappingURL=routes.d.ts.map
@@ -49,8 +49,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
49
49
  }>;
50
50
  /** DELETE /_agent-native/resources/:id — delete a resource */
51
51
  export declare function handleDeleteResource(event: any): Promise<{
52
- ok?: undefined;
53
52
  error: string;
53
+ ok?: undefined;
54
54
  } | {
55
55
  error?: undefined;
56
56
  ok: boolean;
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- status?: undefined;
38
37
  ok?: undefined;
38
+ status?: undefined;
39
39
  } | {
40
+ error?: undefined;
40
41
  ok: boolean;
41
42
  status: string;
42
- error?: undefined;
43
43
  } | {
44
+ ok?: undefined;
44
45
  error: string;
45
46
  removed?: undefined;
46
- ok?: undefined;
47
47
  } | {
48
+ error?: undefined;
48
49
  ok: boolean;
49
50
  removed: boolean;
50
- error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — re-run the validator against the
54
54
  * current stored value without changing anything. Useful for the "Test" button.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
+ ok?: undefined;
57
58
  error: string;
58
59
  note?: undefined;
59
- ok?: undefined;
60
60
  } | {
61
+ error?: undefined;
61
62
  ok: boolean;
62
63
  note?: undefined;
63
- error?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  ok: boolean;
66
67
  note: string;
67
- error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
+ error?: undefined;
98
99
  ok: boolean;
99
100
  key: string;
100
- error?: undefined;
101
101
  } | {
102
+ error?: undefined;
102
103
  ok: boolean;
103
104
  removed: boolean;
104
- error?: undefined;
105
105
  }>>;
106
106
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent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AACrC,OAAO,EAAE,wBAAwB,EAAE,CAAC;AACpC,YAAY,EAAE,sBAAsB,EAAE,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,OAAO,EAAE,sCAAsC,EAAE,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAC7C,OAAO,EAAE,yCAAyC,EAAE,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,uCAAuC,CAC3D,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC,CAUlB;AAaD,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,cAAc,CA47JhB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAwC,CAAC;AAE9E,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -947,9 +947,24 @@ export function createAgentChatPlugin(options) {
947
947
  }
948
948
  // Use the SAME agent setup as the interactive chat — identical tools,
949
949
  // prompt, and capabilities. The A2A agent IS the app's agent.
950
+ const { getOwnerActiveApiKey } = await import("../agent/production-agent.js");
951
+ const ownerApiKey = await getOwnerActiveApiKey(userEmail);
952
+ // A2A runs are reconstructed in a fresh processor request, so they
953
+ // do not pass through the interactive handler's prepareRun hook.
954
+ // Seed the same mutable run context before resolving the engine and
955
+ // building tools. Provider credentials, team/fetch helpers, and
956
+ // other action closures read this context rather than the engine
957
+ // argument alone; without it delegated runs can silently fall back
958
+ // to an unscoped/unconfigured provider path even though interactive
959
+ // chat works for the same owner.
960
+ const a2aRunContext = ensureRequestRunContext();
961
+ if (a2aRunContext) {
962
+ a2aRunContext.owner = userEmail;
963
+ a2aRunContext.userApiKey = ownerApiKey;
964
+ }
950
965
  const a2aEngine = await resolveEngine({
951
966
  engineOption: options?.engine,
952
- apiKey: options?.apiKey,
967
+ apiKey: ownerApiKey ?? options?.apiKey,
953
968
  appId: options?.appId,
954
969
  });
955
970
  const devActive = isDevMode();
@@ -968,12 +983,18 @@ export function createAgentChatPlugin(options) {
968
983
  const systemPrompt = devActive
969
984
  ? devPrompt + resources + schemaBlock + extra + runtimeContext
970
985
  : basePrompt + resources + schemaBlock + extra + runtimeContext;
986
+ if (a2aRunContext)
987
+ a2aRunContext.systemPrompt = systemPrompt;
971
988
  const a2aModelCandidate = options?.model ??
972
989
  (await getStoredModelForEngine(a2aEngine, {
973
990
  appId: options?.appId,
974
991
  })) ??
975
992
  a2aEngine.defaultModel;
976
993
  const model = normalizeModelForEngine(a2aEngine, a2aModelCandidate);
994
+ if (a2aRunContext) {
995
+ a2aRunContext.engine = a2aEngine;
996
+ a2aRunContext.model = model;
997
+ }
977
998
  // Build tools — same as interactive handler but WITHOUT call-agent
978
999
  // to prevent infinite recursive A2A loops (agent calling itself).
979
1000
  // In dev mode, template actions are invoked via bash (not native tools),
@@ -1167,9 +1188,14 @@ export function createAgentChatPlugin(options) {
1167
1188
  ? { externalAgents: options.externalAgents }
1168
1189
  : {}),
1169
1190
  askAgent: async (message) => {
1191
+ const ownerEmail = getRequestUserEmail();
1192
+ const { getOwnerActiveApiKey } = await import("../agent/production-agent.js");
1193
+ const ownerApiKey = ownerEmail
1194
+ ? await getOwnerActiveApiKey(ownerEmail)
1195
+ : undefined;
1170
1196
  const mcpEngine = await resolveEngine({
1171
1197
  engineOption: options?.engine,
1172
- apiKey: options?.apiKey,
1198
+ apiKey: ownerApiKey ?? options?.apiKey,
1173
1199
  appId: options?.appId,
1174
1200
  });
1175
1201
  const mcpModelCandidate = options?.model ??