@agent-native/core 0.0.0-beta-20260820194548 → 0.0.0-beta-20260820200358

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,4 +1,4 @@
1
- export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type AgentActionSurfaceDetails, type AgentLoopFinalResponseGuard, type AgentLoopFinalResponseGuardContext, type AgentLoopFinalResponseGuardResult, type AgentLoopToolCallSummary, type AgentLoopToolResultSummary, } from "./production-agent.js";
1
+ export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type DefaultAgentActionSurface, type AgentActionSurfaceResolution, type AgentActionSurfaceDetails, type AgentLoopFinalResponseGuard, type AgentLoopFinalResponseGuardContext, type AgentLoopFinalResponseGuardResult, type AgentLoopToolCallSummary, type AgentLoopToolResultSummary, } from "./production-agent.js";
2
2
  export { type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, type AgentChatReference, type MentionProvider, type MentionProviderItem, } from "./types.js";
3
3
  export { TripWire, type Processor, type ProcessorState, type ProcessorAbort, type ProcessOutputStreamArgs, type ProcessOutputStepArgs, type ProcessOutputResultArgs, } from "./processors.js";
4
4
  export { DEFAULT_MODEL } from "./default-model.js";
@@ -259,6 +259,14 @@ export type AgentExecutionMode = "act" | "plan";
259
259
  export interface AgentActionSurface {
260
260
  allowedActionNames: readonly string[];
261
261
  }
262
+ export interface DefaultAgentActionSurface {
263
+ mode: "default";
264
+ }
265
+ export type AgentActionSurfaceResolution = AgentActionSurface | DefaultAgentActionSurface;
266
+ type NormalizedAgentActionSurface = DefaultAgentActionSurface | {
267
+ mode: "allowlist";
268
+ allowedActionNames: string[];
269
+ };
262
270
  export interface AgentActionSurfaceDetails {
263
271
  event: any;
264
272
  ownerEmail: string | null;
@@ -271,10 +279,14 @@ export interface AgentActionSurfaceDetails {
271
279
  /** Read a persisted allowlist while preserving legacy absence and failing
272
280
  * closed when the field is present but malformed. */
273
281
  export declare function readPersistedAllowedActionNames(value: unknown): string[] | undefined;
274
- export interface PersistedActionSurface {
282
+ export declare function normalizeAgentActionSurfaceResolution(value: unknown): NormalizedAgentActionSurface;
283
+ export type PersistedActionSurface = {
275
284
  orgId: string | null;
276
285
  allowedActionNames: string[];
277
- }
286
+ } | {
287
+ orgId: string | null;
288
+ mode: "default";
289
+ };
278
290
  /** Read a nested persisted action surface. An absent envelope is legacy;
279
291
  * a present but invalid envelope is an explicit org-less, empty surface. */
280
292
  export declare function readPersistedActionSurface(value: unknown, propertyName: string): PersistedActionSurface | undefined;
@@ -342,11 +354,12 @@ export interface ProductionAgentOptions {
342
354
  }>;
343
355
  /**
344
356
  * Resolve the exact action registry exposed to one interactive agent-chat
345
- * request. Returned names are a hard allowlist: omitted actions are absent
346
- * from both the provider schemas and the searchable registry. When set, all
347
- * allowed actions are loaded directly on the first model request.
357
+ * request. Return an allowlist to remove omitted actions from both provider
358
+ * schemas and the searchable registry, or `{ mode: "default" }` to preserve
359
+ * the normal initial-tool and discovery behavior for that request. Every
360
+ * allowlisted action is loaded directly on the first model request.
348
361
  */
349
- resolveActionSurface?: (details: AgentActionSurfaceDetails) => AgentActionSurface | Promise<AgentActionSurface>;
362
+ resolveActionSurface?: (details: AgentActionSurfaceDetails) => AgentActionSurfaceResolution | Promise<AgentActionSurfaceResolution>;
350
363
  /** Optional per-app agent run chunk budget in milliseconds. Defaults to
351
364
  * AGENT_RUN_SOFT_TIMEOUT_MS when set, otherwise no framework-imposed
352
365
  * timeout. When reached, the client receives an internal auto-continuation
@@ -411,13 +411,32 @@ export function readPersistedAllowedActionNames(value) {
411
411
  }
412
412
  return [...new Set(names)];
413
413
  }
414
+ export function normalizeAgentActionSurfaceResolution(value) {
415
+ if (hasOwn(value, "mode")) {
416
+ if (value.mode === "default" && !hasOwn(value, "allowedActionNames")) {
417
+ return { mode: "default" };
418
+ }
419
+ throw new Error("resolveActionSurface returned an invalid default surface");
420
+ }
421
+ if (!hasOwn(value, "allowedActionNames")) {
422
+ throw new Error("resolveActionSurface returned an invalid action surface");
423
+ }
424
+ const allowedActionNames = value.allowedActionNames;
425
+ if (!Array.isArray(allowedActionNames) ||
426
+ !allowedActionNames.every((name) => typeof name === "string")) {
427
+ throw new Error("resolveActionSurface returned an invalid action surface");
428
+ }
429
+ return {
430
+ mode: "allowlist",
431
+ allowedActionNames: [...new Set(allowedActionNames)],
432
+ };
433
+ }
414
434
  /** Read a nested persisted action surface. An absent envelope is legacy;
415
435
  * a present but invalid envelope is an explicit org-less, empty surface. */
416
436
  export function readPersistedActionSurface(value, propertyName) {
417
437
  if (!hasOwn(value, propertyName))
418
438
  return undefined;
419
439
  const surface = value[propertyName];
420
- const allowedActionNames = readPersistedAllowedActionNames(surface) ?? [];
421
440
  if (!hasOwn(surface, "orgId")) {
422
441
  return { orgId: null, allowedActionNames: [] };
423
442
  }
@@ -426,6 +445,13 @@ export function readPersistedActionSurface(value, propertyName) {
426
445
  (typeof orgId !== "string" || orgId.trim().length === 0)) {
427
446
  return { orgId: null, allowedActionNames: [] };
428
447
  }
448
+ if (hasOwn(surface, "mode")) {
449
+ if (surface.mode === "default" && !hasOwn(surface, "allowedActionNames")) {
450
+ return { orgId, mode: "default" };
451
+ }
452
+ return { orgId: null, allowedActionNames: [] };
453
+ }
454
+ const allowedActionNames = readPersistedAllowedActionNames(surface) ?? [];
429
455
  return { orgId, allowedActionNames };
430
456
  }
431
457
  export function filterActionsByAllowedNames(actions, allowedActionNames) {
@@ -6560,6 +6586,7 @@ export function createProductionAgentHandler(options) {
6560
6586
  availableRequestActions = filterActionsByAllowedNames(availableRequestActions, filterHostedHarnessToolNames(Object.keys(availableRequestActions)));
6561
6587
  }
6562
6588
  let surfacedRequestActions = availableRequestActions;
6589
+ let useDefaultRequestActionSurface = !options.resolveActionSurface;
6563
6590
  if (options.resolveActionSurface) {
6564
6591
  const persistedSurface = isBackgroundWorker
6565
6592
  ? readPersistedActionSurface(body, "__resolvedActionSurface")
@@ -6575,19 +6602,33 @@ export function createProductionAgentHandler(options) {
6575
6602
  internalContinuation: Boolean(internalContinuation),
6576
6603
  availableActionNames: Object.keys(availableRequestActions),
6577
6604
  });
6578
- surfacedRequestActions = filterActionsByAllowedNames(availableRequestActions, surface.allowedActionNames);
6579
- if (requestedHostedHarness) {
6580
- surfacedRequestActions = filterActionsByAllowedNames(surfacedRequestActions, filterHostedHarnessToolNames(Object.keys(surfacedRequestActions)));
6581
- }
6582
- const allowedNames = Object.keys(surfacedRequestActions);
6605
+ const normalizedSurface = normalizeAgentActionSurfaceResolution(surface);
6583
6606
  const runCtx = ensureRequestRunContext();
6584
- if (runCtx)
6585
- runCtx.allowedActionNames = allowedNames;
6586
- if (!isBackgroundWorker) {
6587
- body.__resolvedActionSurface = {
6588
- orgId: getRequestOrgId() ?? null,
6589
- allowedActionNames: allowedNames,
6590
- };
6607
+ if (normalizedSurface.mode === "default") {
6608
+ useDefaultRequestActionSurface = true;
6609
+ if (runCtx)
6610
+ delete runCtx.allowedActionNames;
6611
+ if (!isBackgroundWorker) {
6612
+ body.__resolvedActionSurface = {
6613
+ orgId: getRequestOrgId() ?? null,
6614
+ mode: "default",
6615
+ };
6616
+ }
6617
+ }
6618
+ else {
6619
+ surfacedRequestActions = filterActionsByAllowedNames(availableRequestActions, normalizedSurface.allowedActionNames);
6620
+ if (requestedHostedHarness) {
6621
+ surfacedRequestActions = filterActionsByAllowedNames(surfacedRequestActions, filterHostedHarnessToolNames(Object.keys(surfacedRequestActions)));
6622
+ }
6623
+ const allowedNames = Object.keys(surfacedRequestActions);
6624
+ if (runCtx)
6625
+ runCtx.allowedActionNames = allowedNames;
6626
+ if (!isBackgroundWorker) {
6627
+ body.__resolvedActionSurface = {
6628
+ orgId: getRequestOrgId() ?? null,
6629
+ allowedActionNames: allowedNames,
6630
+ };
6631
+ }
6591
6632
  }
6592
6633
  }
6593
6634
  // DIAGNOSTIC-ONLY: owner/request context prep (resolveAgentOwnerEmail +
@@ -7075,9 +7116,9 @@ export function createProductionAgentHandler(options) {
7075
7116
  ? createPlanModeActionRegistry(surfacedRequestActions)
7076
7117
  : surfacedRequestActions;
7077
7118
  const availableRequestTools = getEngineTools(requestActions);
7078
- const initialRequestTools = options.resolveActionSurface
7079
- ? availableRequestTools
7080
- : filterInitialEngineTools(availableRequestTools, options.initialToolNames);
7119
+ const initialRequestTools = useDefaultRequestActionSurface
7120
+ ? filterInitialEngineTools(availableRequestTools, options.initialToolNames)
7121
+ : availableRequestTools;
7081
7122
  const requestTools = requestMode === "plan"
7082
7123
  ? preloadPlanModeEngineTools({
7083
7124
  request: requestMessage,
@@ -208,6 +208,9 @@ export interface AgentChatRequest {
208
208
  __resolvedActionSurface?: {
209
209
  orgId: string | null;
210
210
  allowedActionNames: string[];
211
+ } | {
212
+ orgId: string | null;
213
+ mode: "default";
211
214
  };
212
215
  /**
213
216
  * Stable identity for the logical assistant turn this request belongs to.
@@ -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;
65
66
  states: {
66
67
  clientId: number;
67
68
  state: string;
68
69
  }[];
69
- error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
+ error?: undefined;
80
81
  users: {
81
82
  clientId: number;
82
83
  lastSeen: number;
83
84
  }[];
84
- error?: undefined;
85
85
  }>>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./config.js";
2
- export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type AgentActionSurfaceDetails, type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, DEFAULT_MODEL, TripWire, type Processor, type ProcessorState, type ProcessorAbort, } from "./agent/index.js";
2
+ export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type DefaultAgentActionSurface, type AgentActionSurfaceResolution, type AgentActionSurfaceDetails, type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, DEFAULT_MODEL, TripWire, type Processor, type ProcessorState, type ProcessorAbort, } from "./agent/index.js";
3
3
  export { defineAction, ActionContractError, isActionContractError, type ActionContractErrorOptions, AgentActionStopError, isAgentActionStopError, type ActionDefinition, type ActionHttpConfig, type AgentActionStopOptions, type PublicAgentActionConfig, type ActionDeepLink, type ActionLinkBuilder, MCP_APP_EXTENSION_ID, MCP_APP_MIME_TYPE, MCP_APP_RESOURCE_URI_META_KEY, type ActionMcpAppConfig, type ActionMcpAppCsp, type ActionMcpAppCspBuilder, type ActionMcpAppHtmlBuilder, type ActionMcpAppPermissions, type ActionMcpAppResourceConfig, type ActionMcpAppResourceMeta, } from "./action.js";
4
4
  export * from "./user-profile/index.js";
5
5
  export { embedApp, MCP_APP_REQUEST_ORIGIN_CSP_SOURCE, type EmbedAppOptions, } from "./mcp/embed-app.js";
@@ -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;
14
15
  count: number;
15
16
  updated?: undefined;
16
17
  ok?: undefined;
17
- error?: undefined;
18
18
  } | {
19
+ error?: undefined;
19
20
  updated: number;
20
21
  ok?: undefined;
21
- error?: undefined;
22
22
  count?: undefined;
23
23
  } | {
24
24
  updated?: undefined;
@@ -26,8 +26,8 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
26
26
  ok?: undefined;
27
27
  count?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  updated?: undefined;
30
31
  ok: boolean;
31
- error?: undefined;
32
32
  count?: undefined;
33
33
  }>>;
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- ok?: undefined;
45
- error?: undefined;
46
44
  summary: import("./types.js").TraceSummary;
47
45
  spans: import("./types.js").TraceSpan[];
48
46
  id?: undefined;
49
- } | {
50
- ok?: undefined;
51
47
  error?: undefined;
48
+ ok?: undefined;
49
+ } | {
52
50
  summary?: undefined;
53
51
  spans?: undefined;
54
52
  id: string;
55
- } | {
53
+ error?: undefined;
56
54
  ok?: undefined;
55
+ } | {
57
56
  summary?: undefined;
58
57
  spans?: undefined;
59
58
  id?: undefined;
60
59
  error: any;
60
+ ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
65
+ error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
@@ -171,8 +171,9 @@ export interface AgentChatPluginOptions {
171
171
  }>;
172
172
  /**
173
173
  * Resolve the exact native action surface for each interactive chat request.
174
- * Omitted names are not sent to the model and are not discoverable through
175
- * tool-search. When configured, every allowed action is loaded directly.
174
+ * Omitted allowlist names are not sent to the model or discoverable through
175
+ * tool-search. Return `{ mode: "default" }` to keep the normal initial-tool
176
+ * and discovery behavior for a request instead.
176
177
  */
177
178
  resolveActionSurface?: ProductionAgentOptions["resolveActionSurface"];
178
179
  /**
@@ -13,7 +13,7 @@ import { resolveEngine, createAnthropicEngine, getStoredModelForEngine, normaliz
13
13
  import { SYSTEM_PROMPT_CACHE_SPLIT } from "../agent/engine/prompt-cache.js";
14
14
  import { PROVIDER_TO_ENV } from "../agent/engine/provider-env-vars.js";
15
15
  import { hostedHarnessSystemPrompt } from "../agent/harness/hosted.js";
16
- import { createProductionAgentHandler, actionsToEngineTools, executeAgentToolCall, filterActionsByAllowedNames, readPersistedActionSurface, toolCallCacheKey, getActiveRunForThreadAsync, abortRunDurably, abortTurnDurably, subscribeToRun, } from "../agent/production-agent.js";
16
+ import { createProductionAgentHandler, actionsToEngineTools, executeAgentToolCall, filterActionsByAllowedNames, normalizeAgentActionSurfaceResolution, readPersistedActionSurface, toolCallCacheKey, getActiveRunForThreadAsync, abortRunDurably, abortTurnDurably, subscribeToRun, } from "../agent/production-agent.js";
17
17
  import { callerHasRunAccess, callerHasThreadAccess, } from "../agent/run-ownership.js";
18
18
  import { markTurnAborted, readBackgroundRunClaim } from "../agent/run-store.js";
19
19
  import { buildCurrentTimeUserContext, buildRuntimeContextPrompt, } from "../agent/runtime-context.js";
@@ -2974,11 +2974,14 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
2974
2974
  ...details,
2975
2975
  availableActionNames: appActionNames,
2976
2976
  });
2977
+ const normalizedSurface = normalizeAgentActionSurfaceResolution(surface);
2978
+ if (normalizedSurface.mode === "default")
2979
+ return surface;
2977
2980
  const localActionNames = details.availableActionNames.filter((name) => localDevActionNames.has(name));
2978
2981
  return {
2979
2982
  allowedActionNames: [
2980
2983
  ...new Set([
2981
- ...surface.allowedActionNames,
2984
+ ...normalizedSurface.allowedActionNames,
2982
2985
  ...localActionNames,
2983
2986
  ]),
2984
2987
  ],
@@ -15,7 +15,7 @@ export { requireEnvKey, type MissingKeyResponse } from "./missing-key.js";
15
15
  export { assertCurrentRequestUserIsOrgAdmin, currentRequestUserIsOrgAdmin, } from "./org-admin.js";
16
16
  export { verifyCaptcha, type CaptchaVerifyResult } from "./captcha.js";
17
17
  export { getLocaleInitScript, parseAcceptLanguage, resolveLocaleFromRequest, type LocaleInitScriptOptions, type ResolveLocaleFromRequestOptions, type ResolvedRequestLocale, } from "../localization/server.js";
18
- export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type AgentActionSurfaceDetails, type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, type AgentChatReference, type MentionProvider, type MentionProviderItem, type AgentLoopFinalResponseGuard, type AgentLoopFinalResponseGuardContext, type AgentLoopFinalResponseGuardResult, type AgentLoopToolCallSummary, type AgentLoopToolResultSummary, } from "../agent/index.js";
18
+ export { createProductionAgentHandler, type ActionEntry, type ScriptEntry, type ProductionAgentOptions, type AgentActionSurface, type DefaultAgentActionSurface, type AgentActionSurfaceResolution, type AgentActionSurfaceDetails, type ActionTool, type ScriptTool, type AgentMessage, type AgentChatRequest, type AgentChatEvent, type AgentChatAttachment, type AgentChatReference, type MentionProvider, type MentionProviderItem, type AgentLoopFinalResponseGuard, type AgentLoopFinalResponseGuardContext, type AgentLoopFinalResponseGuardResult, type AgentLoopToolCallSummary, type AgentLoopToolResultSummary, } from "../agent/index.js";
19
19
  export { actionsToEngineTools, executeAgentToolCall, getOwnerActiveApiKey, getOwnerApiKeyForEngine, resolveOwnerEngineApiKey, runAgentLoop, type AgentToolCallExecutionResult, type ExecuteAgentToolCallOptions, type ResolvedOwnerApiKey, } from "../agent/production-agent.js";
20
20
  export { mountRealtimeVoiceRoutes, realtimeVoiceSafetyIdentifier, REALTIME_VOICE_MAX_SDP_BYTES, REALTIME_VOICE_MAX_TOOL_BODY_BYTES, REALTIME_VOICE_MAX_TOOL_OUTPUT_CHARS, REALTIME_VOICE_SESSION_PATH, REALTIME_VOICE_TOOL_PATH, type MountRealtimeVoiceRoutesOptions, type RealtimeVoiceRequestContext, type RealtimeVoiceToolExecutionRequest, type RealtimeVoiceToolExecutionResult, } from "./realtime-voice.js";
21
21
  export { getStoredModelForEngine, resolveEngine, } from "../agent/engine/index.js";
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
26
26
  expiresAt?: undefined;
27
27
  ttlSeconds?: undefined;
28
28
  } | {
29
- error?: undefined;
30
29
  token: string;
31
30
  expiresAt: string;
32
31
  ttlSeconds: number;
32
+ error?: undefined;
33
33
  }>>;
@@ -20,6 +20,6 @@ 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
  }>>;
@@ -188,6 +188,12 @@ createAgentChatPlugin({
188
188
  });
189
189
  ```
190
190
 
191
+ When the same resolver also handles unrestricted chat, return
192
+ `{ mode: "default" }`. This preserves the normal `initialToolNames` filtering
193
+ and `tool-search` discovery instead of loading every available schema on the
194
+ first model request. The explicit mode is preserved across durable
195
+ continuations.
196
+
191
197
  An empty list exposes no native actions. Unknown names fail the request instead
192
198
  of widening access. Every allowed action is loaded directly on the first model
193
199
  request; include `tool-search` explicitly only when discovery inside the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.0.0-beta-20260820194548",
3
+ "version": "0.0.0-beta-20260820200358",
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": {