@agent-native/core 0.223.0-nightly-20261102152511 → 0.223.0

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.
Files changed (40) hide show
  1. package/dist/agent/actions/get-agentkit-capabilities.js +2 -2
  2. package/dist/agent/engine/error-detail.d.ts +13 -0
  3. package/dist/agent/engine/error-detail.js +92 -0
  4. package/dist/agent/production-agent.js +3 -5
  5. package/dist/agent/run-failure-retry.d.ts +7 -0
  6. package/dist/agent/run-failure-retry.js +21 -0
  7. package/dist/agent/thread-data-builder.js +2 -3
  8. package/dist/agentkit/capabilities.d.ts +1 -1
  9. package/dist/cli/templates-meta.js +0 -14
  10. package/dist/client/agent-run-status.d.ts +2 -0
  11. package/dist/client/agent-run-status.js +3 -0
  12. package/dist/client/error-format.js +2 -6
  13. package/dist/client/sse-event-processor.js +2 -75
  14. package/dist/collab/routes.d.ts +1 -1
  15. package/dist/collab/struct-routes.d.ts +1 -1
  16. package/dist/connections/catalog.d.ts +5 -5
  17. package/dist/connections/catalog.js +3 -22
  18. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  19. package/dist/file-upload/builder.js +4 -5
  20. package/dist/mcp/analytics.js +7 -0
  21. package/dist/mcp/build-server.js +7 -2
  22. package/dist/mcp/direct-action-call.js +3 -1
  23. package/dist/mcp/embed-redaction.d.ts +3 -0
  24. package/dist/mcp/embed-redaction.js +5 -0
  25. package/dist/mcp/execute-action-call.js +6 -2
  26. package/dist/org/index.d.ts +1 -1
  27. package/dist/progress/routes.d.ts +1 -1
  28. package/dist/provider-api/actions/custom-provider-registration.d.ts +6 -6
  29. package/dist/provider-api/actions/provider-api.d.ts +2 -2
  30. package/dist/provider-api/index.js +2 -9
  31. package/dist/server/agent-chat-plugin.js +7 -0
  32. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  33. package/dist/server/first-touch-route.d.ts +1 -1
  34. package/dist/server/transcribe-voice.d.ts +1 -1
  35. package/dist/vite/bounded-task-plugin.d.ts +12 -2
  36. package/dist/vite/bounded-task-plugin.js +34 -26
  37. package/dist/vite/client.js +162 -106
  38. package/dist/vite/plugin-hook.test-helpers.d.ts +10 -0
  39. package/dist/vite/plugin-hook.test-helpers.js +19 -0
  40. package/package.json +4 -4
@@ -6,7 +6,7 @@ import { MCP_ACTION_RESULT_MARKER, isMcpActionResult, mcpActionResultText, } fro
6
6
  import { assertServicePrincipalMayCall, assertServicePrincipalMayRun, recordServicePrincipalDenial, ServicePrincipalRefusedError, } from "../org/service-principal-guard.js";
7
7
  import { getRequestOrgId, getRequestUserEmail, } from "../server/request-context.js";
8
8
  import { answerMcpApprovalPrompt, consumeMcpApprovalGrant, consumeReviewedMcpApprovalGrant, createMcpApprovalGrant, findRecentMcpApprovalRun, storedApprovalArguments, recordMcpApprovalRun, } from "./approval-store.js";
9
- import { CIRCULAR_RESULT, EMBED_RESULT_SENSITIVE_KEYS, HIDDEN_EMBED_URL, IMAGE_BYTES, isEmbedCredentialKey, readString, redactEmbedText, } from "./embed-redaction.js";
9
+ import { CIRCULAR_RESULT, EMBED_RESULT_SENSITIVE_KEYS, DATABASE_FAILURE_MESSAGE, HIDDEN_EMBED_URL, IMAGE_BYTES, isDatabaseQueryFailure, isEmbedCredentialKey, readString, redactEmbedText, } from "./embed-redaction.js";
10
10
  import { hasMcpOAuthScope } from "./oauth-token.js";
11
11
  /**
12
12
  * The authorization, approval, execution and result-sanitizing steps of an
@@ -503,7 +503,11 @@ function failedOutcome(stage, error) {
503
503
  let message;
504
504
  let errorCode;
505
505
  try {
506
- const raw = error instanceof Error ? error.message : error;
506
+ const raw = isDatabaseQueryFailure(error)
507
+ ? DATABASE_FAILURE_MESSAGE
508
+ : error instanceof Error
509
+ ? error.message
510
+ : error;
507
511
  message =
508
512
  typeof raw === "string"
509
513
  ? redactEmbedText(raw)
@@ -180,9 +180,9 @@ export declare const getMyOrgHandler: import("h3").EventHandlerWithFetch<import(
180
180
  soloDeploymentAdmin: boolean | undefined;
181
181
  }>>;
182
182
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
183
+ name?: undefined;
183
184
  success: boolean;
184
185
  id?: undefined;
185
- name?: undefined;
186
186
  role?: undefined;
187
187
  } | {
188
188
  success?: undefined;
@@ -1,6 +1,6 @@
1
1
  export declare function createProgressHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").AgentRun | import("./types.js").AgentRun[] | {
2
- error: string;
3
2
  ok?: undefined;
3
+ error: string;
4
4
  } | {
5
5
  error?: undefined;
6
6
  ok: boolean;
@@ -75,9 +75,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- id?: undefined;
79
- provider?: undefined;
80
78
  deleted?: undefined;
79
+ id?: undefined;
81
80
  message?: undefined;
82
81
  providers: {
83
82
  id: string;
@@ -89,12 +88,13 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
89
88
  updatedAt: number;
90
89
  }[];
91
90
  count: number;
91
+ provider?: undefined;
92
92
  found?: undefined;
93
93
  registered?: undefined;
94
94
  label?: undefined;
95
95
  } | {
96
- id?: undefined;
97
96
  deleted?: undefined;
97
+ id?: undefined;
98
98
  message?: undefined;
99
99
  providers?: undefined;
100
100
  count?: undefined;
@@ -103,30 +103,30 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
103
103
  registered?: undefined;
104
104
  label?: undefined;
105
105
  } | {
106
- provider?: undefined;
107
106
  deleted?: undefined;
108
107
  message?: undefined;
109
108
  providers?: undefined;
110
109
  count?: undefined;
110
+ provider?: undefined;
111
111
  found: boolean;
112
112
  id: string;
113
113
  registered?: undefined;
114
114
  label?: undefined;
115
115
  } | {
116
- provider?: undefined;
117
116
  message?: undefined;
118
117
  providers?: undefined;
119
118
  count?: undefined;
119
+ provider?: undefined;
120
120
  found?: undefined;
121
121
  deleted: boolean;
122
122
  id: string;
123
123
  registered?: undefined;
124
124
  label?: undefined;
125
125
  } | {
126
- provider?: undefined;
127
126
  deleted?: undefined;
128
127
  providers?: undefined;
129
128
  count?: undefined;
129
+ provider?: undefined;
130
130
  found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
@@ -316,8 +316,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
316
316
  notes?: string | undefined;
317
317
  scope?: "org" | "user" | undefined;
318
318
  }, {
319
- id?: undefined;
320
319
  deleted?: undefined;
320
+ id?: undefined;
321
321
  provider?: undefined;
322
322
  message?: undefined;
323
323
  providers: {
@@ -334,8 +334,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
334
334
  registered?: undefined;
335
335
  label?: undefined;
336
336
  } | {
337
- id?: undefined;
338
337
  deleted?: undefined;
338
+ id?: undefined;
339
339
  count?: undefined;
340
340
  message?: undefined;
341
341
  providers?: undefined;
@@ -790,14 +790,7 @@ const PROVIDER_CONFIGS = {
790
790
  docsUrls: ["https://developers.google.com/drive/api/reference/rest/v3"],
791
791
  specUrls: ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],
792
792
  allowedHostSuffixes: ["googleapis.com"],
793
- templateUses: [
794
- "brain",
795
- "content",
796
- "slides",
797
- "slides-2",
798
- "dispatch",
799
- "analytics",
800
- ],
793
+ templateUses: ["brain", "content", "slides", "dispatch", "analytics"],
801
794
  examples: [
802
795
  { label: "List files", method: "GET", path: "/files" },
803
796
  { label: "Get file metadata", method: "GET", path: "/files/{fileId}" },
@@ -853,7 +846,7 @@ const PROVIDER_CONFIGS = {
853
846
  ],
854
847
  specUrls: ["https://slides.googleapis.com/$discovery/rest?version=v1"],
855
848
  allowedHostSuffixes: ["googleapis.com"],
856
- templateUses: ["brain", "content", "slides", "slides-2", "dispatch"],
849
+ templateUses: ["brain", "content", "slides", "dispatch"],
857
850
  examples: [
858
851
  {
859
852
  label: "Get presentation with slides and speaker notes",
@@ -24,6 +24,7 @@ import { currentExecutionFence, withExecutionFence, } from "../agent/execution-f
24
24
  import { hostedHarnessSystemPrompt } from "../agent/harness/hosted.js";
25
25
  import { createProductionAgentHandler, endsAtContinuationBoundary, actionsToEngineTools, executeAgentToolCall, filterActionsByAllowedNames, normalizeAgentActionSurfaceResolution, getActiveRunForThreadAsync, getJevContextCredentials, abortRunDurably, abortRunAndTurnDurably, abortRunAtSafeBoundaryDurably, abortTurnByRefDurably, abortTurnDurably, buildUserContentWithAttachments, describeAttachmentPreUploadWarning, isAgentModelVisionCapable, subscribeToRun, mergeAgentLoopUsage, } from "../agent/production-agent.js";
26
26
  import { applyProviderModelSelection, providerForEngineName, resolveProviderModelSelectionAtScope, } from "../agent/provider-model-selection.js";
27
+ import { isRunFailureRetryable } from "../agent/run-failure-retry.js";
27
28
  import { startRun } from "../agent/run-manager.js";
28
29
  import { callerHasRunAccess, callerHasThreadAccess, } from "../agent/run-ownership.js";
29
30
  import { AgentRunJournalUnreadableError, getRunById, readBackgroundRunClaim, retryRunThreadProjection, } from "../agent/run-store.js";
@@ -5837,6 +5838,12 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
5837
5838
  // to `getActiveRunForThreadAsync`'s return type does NOT reach
5838
5839
  // the wire on its own; it must be listed here too.
5839
5840
  hasInFlightWork: run.hasInFlightWork === true,
5841
+ // Whether sending the same prompt again can succeed. Null when
5842
+ // the run has not errored or recorded no reason, so a client
5843
+ // keeps its own default.
5844
+ retryable: run.status === "errored" && run.terminalReason
5845
+ ? isRunFailureRetryable(run.terminalReason)
5846
+ : null,
5840
5847
  };
5841
5848
  }
5842
5849
  setResponseStatus(event, 405);
@@ -1,6 +1,6 @@
1
1
  export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
2
- ok?: undefined;
3
2
  error: string;
3
+ ok?: undefined;
4
4
  models?: undefined;
5
5
  } | {
6
6
  error?: undefined;
@@ -17,9 +17,9 @@ export type FirstTouchSyncResult = {
17
17
  * browser's `an_ft` and `an_lt` again, so Safari keeps them their 30 days.
18
18
  */
19
19
  export declare function createFirstTouchHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
20
- stored?: undefined;
21
20
  error: string;
22
21
  reason?: undefined;
22
+ stored?: undefined;
23
23
  firstTouch?: undefined;
24
24
  } | {
25
25
  error?: undefined;
@@ -17,8 +17,8 @@
17
17
  * typed JSON-in / JSON-out).
18
18
  */
19
19
  export declare function createTranscribeVoiceHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
20
- text?: undefined;
21
20
  error: string;
21
+ text?: undefined;
22
22
  } | {
23
23
  error?: undefined;
24
24
  text: string;
@@ -16,7 +16,17 @@ interface PluginContext {
16
16
  export declare function boundedTaskSourcePlugin(): {
17
17
  name: string;
18
18
  enforce: "pre";
19
- resolveId(this: PluginContext, source: string, importer?: string): Promise<string | null>;
20
- load(this: PluginContext, id: string): Promise<string | null>;
19
+ resolveId: {
20
+ filter: {
21
+ id: RegExp;
22
+ };
23
+ handler(this: PluginContext, source: string, importer?: string): Promise<string | null>;
24
+ };
25
+ load: {
26
+ filter: {
27
+ id: RegExp;
28
+ };
29
+ handler(this: PluginContext, id: string): Promise<string | null>;
30
+ };
21
31
  };
22
32
  export {};
@@ -12,33 +12,41 @@ export function boundedTaskSourcePlugin() {
12
12
  return {
13
13
  name: "agent-native-bounded-task-source",
14
14
  enforce: "pre",
15
- async resolveId(source, importer) {
16
- if (!source.endsWith(QUERY))
17
- return null;
18
- const request = source.slice(0, -QUERY.length);
19
- const resolved = await this.resolve(request, importer, {
20
- skipSelf: true,
21
- });
22
- if (!resolved || resolved.external) {
23
- throw new Error(`Cannot resolve bounded task module ${request}${importer ? ` from ${importer}` : ""}`);
24
- }
25
- return RESOLVED_PREFIX + resolved.id.split("?")[0];
15
+ // The filters let the bundler skip this plugin natively for every other
16
+ // import, instead of calling into JS for each one.
17
+ resolveId: {
18
+ filter: { id: /\?bounded-task$/ },
19
+ async handler(source, importer) {
20
+ if (!source.endsWith(QUERY))
21
+ return null;
22
+ const request = source.slice(0, -QUERY.length);
23
+ const resolved = await this.resolve(request, importer, {
24
+ skipSelf: true,
25
+ });
26
+ if (!resolved || resolved.external) {
27
+ throw new Error(`Cannot resolve bounded task module ${request}${importer ? ` from ${importer}` : ""}`);
28
+ }
29
+ return RESOLVED_PREFIX + resolved.id.split("?")[0];
30
+ },
26
31
  },
27
- async load(id) {
28
- if (!id.startsWith(RESOLVED_PREFIX))
29
- return null;
30
- const entry = id.slice(RESOLVED_PREFIX.length);
31
- const bundled = await bundleBoundedTaskSource(entry, {
32
- name: path.basename(entry).replace(/\.[^.]+$/, ""),
33
- });
34
- for (const input of bundled.inputs)
35
- this.addWatchFile(input);
36
- const source = {
37
- kind: bundled.kind,
38
- name: bundled.name,
39
- code: bundled.code,
40
- };
41
- return `export default Object.freeze(${JSON.stringify(source)});\n`;
32
+ load: {
33
+ filter: { id: new RegExp(`^${RESOLVED_PREFIX}`) },
34
+ async handler(id) {
35
+ if (!id.startsWith(RESOLVED_PREFIX))
36
+ return null;
37
+ const entry = id.slice(RESOLVED_PREFIX.length);
38
+ const bundled = await bundleBoundedTaskSource(entry, {
39
+ name: path.basename(entry).replace(/\.[^.]+$/, ""),
40
+ });
41
+ for (const input of bundled.inputs)
42
+ this.addWatchFile(input);
43
+ const source = {
44
+ kind: bundled.kind,
45
+ name: bundled.name,
46
+ code: bundled.code,
47
+ };
48
+ return `export default Object.freeze(${JSON.stringify(source)});\n`;
49
+ },
42
50
  },
43
51
  };
44
52
  }
@@ -563,6 +563,18 @@ function findPnpmWorkspaceRoot(startDir) {
563
563
  function escapeRegex(s) {
564
564
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
565
565
  }
566
+ // Rolldown tests a hook filter natively. A resolveId or load hook without one
567
+ // is called from Rust for every import of every module, about 47,000 times in
568
+ // one app's client build, even when it only returns null.
569
+ function exactIdFilter(id) {
570
+ return new RegExp(`^${escapeRegex(id)}$`);
571
+ }
572
+ function prefixIdFilter(prefix) {
573
+ return new RegExp(`^${escapeRegex(prefix)}`);
574
+ }
575
+ function packageIdFilter(packages) {
576
+ return new RegExp(`^(?:${[...packages].map(escapeRegex).join("|")})(?:/|$)`);
577
+ }
566
578
  function hasDep(pkg, cwd) {
567
579
  try {
568
580
  const pkgJson = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf-8"));
@@ -2074,29 +2086,37 @@ function clientOptionalPeerStubPlugin(cwd) {
2074
2086
  return {
2075
2087
  name: "agent-native-client-optional-peer-stub",
2076
2088
  enforce: "pre",
2077
- resolveId(id) {
2078
- const packageName = id
2079
- .split("/")
2080
- .slice(0, id.startsWith("@") ? 2 : 1)
2081
- .join("/");
2082
- return missing.has(packageName) ? `${stubIdPrefix}${packageName}` : null;
2089
+ resolveId: {
2090
+ filter: { id: packageIdFilter(missing) },
2091
+ handler(id) {
2092
+ const packageName = id
2093
+ .split("/")
2094
+ .slice(0, id.startsWith("@") ? 2 : 1)
2095
+ .join("/");
2096
+ return missing.has(packageName)
2097
+ ? `${stubIdPrefix}${packageName}`
2098
+ : null;
2099
+ },
2083
2100
  },
2084
- load(id) {
2085
- if (!id.startsWith(stubIdPrefix))
2086
- return null;
2087
- const packageName = id.slice(stubIdPrefix.length);
2088
- const exports = CLIENT_OPTIONAL_PEER_EXPORTS[packageName] ?? [];
2089
- return [
2090
- `import { OptionalPeerDependencyError } from ${JSON.stringify(errorModule)};`,
2091
- `function missingOptionalPeer() { throw new OptionalPeerDependencyError(${JSON.stringify(packageName)}); }`,
2092
- ...exports.map((name) => `export const ${name} = missingOptionalPeer;`),
2093
- ...(packageName === "mermaid"
2094
- ? [
2095
- "const mermaid = new Proxy({}, { get: () => missingOptionalPeer });",
2096
- "export default mermaid;",
2097
- ]
2098
- : []),
2099
- ].join("\n");
2101
+ load: {
2102
+ filter: { id: prefixIdFilter(stubIdPrefix) },
2103
+ handler(id) {
2104
+ if (!id.startsWith(stubIdPrefix))
2105
+ return null;
2106
+ const packageName = id.slice(stubIdPrefix.length);
2107
+ const exports = CLIENT_OPTIONAL_PEER_EXPORTS[packageName] ?? [];
2108
+ return [
2109
+ `import { OptionalPeerDependencyError } from ${JSON.stringify(errorModule)};`,
2110
+ `function missingOptionalPeer() { throw new OptionalPeerDependencyError(${JSON.stringify(packageName)}); }`,
2111
+ ...exports.map((name) => `export const ${name} = missingOptionalPeer;`),
2112
+ ...(packageName === "mermaid"
2113
+ ? [
2114
+ "const mermaid = new Proxy({}, { get: () => missingOptionalPeer });",
2115
+ "export default mermaid;",
2116
+ ]
2117
+ : []),
2118
+ ].join("\n");
2119
+ },
2100
2120
  },
2101
2121
  };
2102
2122
  }
@@ -2208,36 +2228,42 @@ function ssrStubPlugin(packages) {
2208
2228
  return {
2209
2229
  name: "agent-native-ssr-stub-heavy-libs",
2210
2230
  enforce: "pre",
2211
- resolveId(id, _importer, opts) {
2212
- if (!opts?.ssr)
2231
+ resolveId: {
2232
+ filter: { id: packageIdFilter(stubbed) },
2233
+ handler(id, _importer, opts) {
2234
+ if (!opts.ssr)
2235
+ return null;
2236
+ const pkg = id
2237
+ .split("/")
2238
+ .slice(0, id.startsWith("@") ? 2 : 1)
2239
+ .join("/");
2240
+ if (stubbed.has(pkg))
2241
+ return STUB_ID;
2213
2242
  return null;
2214
- const pkg = id
2215
- .split("/")
2216
- .slice(0, id.startsWith("@") ? 2 : 1)
2217
- .join("/");
2218
- if (stubbed.has(pkg))
2219
- return STUB_ID;
2220
- return null;
2243
+ },
2221
2244
  },
2222
- load(id) {
2223
- if (id !== STUB_ID)
2224
- return null;
2225
- return ("function makeStub() { return new Proxy(makeStub, resultHandler); } " +
2226
- "const handler = { get(_, p) { " +
2227
- "if (p === Symbol.toPrimitive) return () => ''; " +
2228
- "if (p === 'then') return undefined; " +
2229
- "return new Proxy(makeStub, handler); " +
2230
- "} };" +
2231
- "const resultHandler = { get(_, p) { " +
2232
- "if (p === Symbol.toPrimitive) return () => ''; " +
2233
- "if (p === 'then') return (resolve) => { " +
2234
- "if (typeof resolve === 'function') resolve(''); " +
2235
- "return new Proxy(makeStub, resultHandler); }; " +
2236
- "return new Proxy(makeStub, resultHandler); " +
2237
- "} };" +
2238
- "const stub = new Proxy(makeStub, handler);" +
2239
- "export default stub;" +
2240
- namedExports.map((name) => `export const ${name} = stub;`).join(""));
2245
+ load: {
2246
+ filter: { id: exactIdFilter(STUB_ID) },
2247
+ handler(id) {
2248
+ if (id !== STUB_ID)
2249
+ return null;
2250
+ return ("function makeStub() { return new Proxy(makeStub, resultHandler); } " +
2251
+ "const handler = { get(_, p) { " +
2252
+ "if (p === Symbol.toPrimitive) return () => ''; " +
2253
+ "if (p === 'then') return undefined; " +
2254
+ "return new Proxy(makeStub, handler); " +
2255
+ "} };" +
2256
+ "const resultHandler = { get(_, p) { " +
2257
+ "if (p === Symbol.toPrimitive) return () => ''; " +
2258
+ "if (p === 'then') return (resolve) => { " +
2259
+ "if (typeof resolve === 'function') resolve(''); " +
2260
+ "return new Proxy(makeStub, resultHandler); }; " +
2261
+ "return new Proxy(makeStub, resultHandler); " +
2262
+ "} };" +
2263
+ "const stub = new Proxy(makeStub, handler);" +
2264
+ "export default stub;" +
2265
+ namedExports.map((name) => `export const ${name} = stub;`).join(""));
2266
+ },
2241
2267
  },
2242
2268
  };
2243
2269
  }
@@ -2255,24 +2281,30 @@ function toolkitTablerIconSsrStubPlugin(cwd) {
2255
2281
  return {
2256
2282
  name: "agent-native-toolkit-tabler-chunk-loaders-ssr",
2257
2283
  enforce: "pre",
2258
- resolveId(id, importer, options) {
2259
- if (!options?.ssr || id !== "./tabler-chunk-loaders.js" || !importer) {
2260
- return null;
2261
- }
2262
- const importerPath = path.resolve(importer.split("?")[0]);
2263
- if (!fs.existsSync(importerPath) ||
2264
- !catalogPaths.has(fs.realpathSync(importerPath))) {
2265
- return null;
2266
- }
2267
- return stubId;
2284
+ resolveId: {
2285
+ filter: { id: exactIdFilter("./tabler-chunk-loaders.js") },
2286
+ handler(id, importer, options) {
2287
+ if (!options.ssr || id !== "./tabler-chunk-loaders.js" || !importer) {
2288
+ return null;
2289
+ }
2290
+ const importerPath = path.resolve(importer.replace(/\?.*/s, ""));
2291
+ if (!fs.existsSync(importerPath) ||
2292
+ !catalogPaths.has(fs.realpathSync(importerPath))) {
2293
+ return null;
2294
+ }
2295
+ return stubId;
2296
+ },
2268
2297
  },
2269
- load(id) {
2270
- if (id !== stubId)
2271
- return null;
2272
- return [
2273
- 'const unavailable = () => { throw new Error("Tabler icons are available only in the browser"); };',
2274
- "export default unavailable;",
2275
- ].join("\n");
2298
+ load: {
2299
+ filter: { id: exactIdFilter(stubId) },
2300
+ handler(id) {
2301
+ if (id !== stubId)
2302
+ return null;
2303
+ return [
2304
+ 'const unavailable = () => { throw new Error("Tabler icons are available only in the browser"); };',
2305
+ "export default unavailable;",
2306
+ ].join("\n");
2307
+ },
2276
2308
  },
2277
2309
  };
2278
2310
  }
@@ -2284,17 +2316,25 @@ function enterpriseAuthAdapterStubPlugin(enabled) {
2284
2316
  return {
2285
2317
  name: "agent-native-enterprise-auth-adapter-stub",
2286
2318
  enforce: "pre",
2287
- resolveId(id) {
2288
- const packageName = id
2289
- .split("/")
2290
- .slice(0, id.startsWith("@") ? 2 : 1)
2291
- .join("/");
2292
- return stubbed.has(packageName) ? `${stubIdPrefix}${packageName}` : null;
2319
+ resolveId: {
2320
+ filter: { id: packageIdFilter(stubbed) },
2321
+ handler(id) {
2322
+ const packageName = id
2323
+ .split("/")
2324
+ .slice(0, id.startsWith("@") ? 2 : 1)
2325
+ .join("/");
2326
+ return stubbed.has(packageName)
2327
+ ? `${stubIdPrefix}${packageName}`
2328
+ : null;
2329
+ },
2293
2330
  },
2294
- load(id) {
2295
- if (!id.startsWith(stubIdPrefix))
2296
- return null;
2297
- return "export const sso = undefined; export const scim = undefined;";
2331
+ load: {
2332
+ filter: { id: prefixIdFilter(stubIdPrefix) },
2333
+ handler(id) {
2334
+ if (!id.startsWith(stubIdPrefix))
2335
+ return null;
2336
+ return "export const sso = undefined; export const scim = undefined;";
2337
+ },
2298
2338
  },
2299
2339
  };
2300
2340
  }
@@ -2390,15 +2430,22 @@ function appChangelogRawPlugin() {
2390
2430
  return {
2391
2431
  name: "agent-native-app-changelog-raw",
2392
2432
  enforce: "pre",
2393
- resolveId(source, importer) {
2394
- return resolveChangelogRawImport(source, importer);
2433
+ // Only a request with a query can carry ?raw; the handlers decide the rest.
2434
+ resolveId: {
2435
+ filter: { id: /\?/ },
2436
+ handler(source, importer) {
2437
+ return resolveChangelogRawImport(source, importer);
2438
+ },
2395
2439
  },
2396
- load(id) {
2397
- const changelogPath = changelogRawPathFromId(id);
2398
- if (!changelogPath)
2399
- return null;
2400
- const markdown = readAppChangelogMarkdown(changelogPath, (file) => this.addWatchFile(file));
2401
- return `export default ${JSON.stringify(markdown)};`;
2440
+ load: {
2441
+ filter: { id: /\?/ },
2442
+ handler(id) {
2443
+ const changelogPath = changelogRawPathFromId(id);
2444
+ if (!changelogPath)
2445
+ return null;
2446
+ const markdown = readAppChangelogMarkdown(changelogPath, (file) => this.addWatchFile(file));
2447
+ return `export default ${JSON.stringify(markdown)};`;
2448
+ },
2402
2449
  },
2403
2450
  handleHotUpdate(ctx) {
2404
2451
  if (!isChangelogSourceFile(ctx.file))
@@ -2903,14 +2950,20 @@ function createDesignSystemThemePlugin(theme, cwd) {
2903
2950
  throw new Error("The designSystemTheme Vite option requires @agent-native/toolkit. Install it in the app to render the configured theme.", { cause: error });
2904
2951
  }
2905
2952
  },
2906
- resolveId(id) {
2907
- if (id === DESIGN_SYSTEM_THEME_MODULE_ID) {
2908
- return RESOLVED_DESIGN_SYSTEM_THEME_MODULE_ID;
2909
- }
2953
+ resolveId: {
2954
+ filter: { id: exactIdFilter(DESIGN_SYSTEM_THEME_MODULE_ID) },
2955
+ handler(id) {
2956
+ if (id === DESIGN_SYSTEM_THEME_MODULE_ID) {
2957
+ return RESOLVED_DESIGN_SYSTEM_THEME_MODULE_ID;
2958
+ }
2959
+ },
2910
2960
  },
2911
- load(id) {
2912
- if (id === RESOLVED_DESIGN_SYSTEM_THEME_MODULE_ID)
2913
- return css;
2961
+ load: {
2962
+ filter: { id: exactIdFilter(RESOLVED_DESIGN_SYSTEM_THEME_MODULE_ID) },
2963
+ handler(id) {
2964
+ if (id === RESOLVED_DESIGN_SYSTEM_THEME_MODULE_ID)
2965
+ return css;
2966
+ },
2914
2967
  },
2915
2968
  transformIndexHtml() {
2916
2969
  return [
@@ -3623,21 +3676,24 @@ function externalStoreShimPlugin() {
3623
3676
  return {
3624
3677
  name: "agent-native-external-store-esm-shim",
3625
3678
  enforce: "pre",
3626
- resolveId(source, _importer, options) {
3627
- if (options?.ssr)
3679
+ resolveId: {
3680
+ filter: { id: packageIdFilter(["use-sync-external-store"]) },
3681
+ handler(source, _importer, options) {
3682
+ if (options.ssr)
3683
+ return null;
3684
+ if (source === "use-sync-external-store" ||
3685
+ source === "use-sync-external-store/shim" ||
3686
+ source === "use-sync-external-store/shim/index.js") {
3687
+ return entry;
3688
+ }
3689
+ if (source === "use-sync-external-store/with-selector" ||
3690
+ source === "use-sync-external-store/with-selector.js" ||
3691
+ source === "use-sync-external-store/shim/with-selector" ||
3692
+ source === "use-sync-external-store/shim/with-selector.js") {
3693
+ return entry;
3694
+ }
3628
3695
  return null;
3629
- if (source === "use-sync-external-store" ||
3630
- source === "use-sync-external-store/shim" ||
3631
- source === "use-sync-external-store/shim/index.js") {
3632
- return entry;
3633
- }
3634
- if (source === "use-sync-external-store/with-selector" ||
3635
- source === "use-sync-external-store/with-selector.js" ||
3636
- source === "use-sync-external-store/shim/with-selector" ||
3637
- source === "use-sync-external-store/shim/with-selector.js") {
3638
- return entry;
3639
- }
3640
- return null;
3696
+ },
3641
3697
  },
3642
3698
  };
3643
3699
  }
@@ -0,0 +1,10 @@
1
+ /** The id filter Vite and Rolldown test before they call the hook's handler. */
2
+ export declare function hookIdFilter(hook: unknown): RegExp;
3
+ /**
4
+ * Calls the hook the way Vite and Rolldown do: an id the hook's filter rejects
5
+ * never reaches the handler, so a filter that is narrower than its handler
6
+ * fails the spec.
7
+ */
8
+ export declare function callPluginHook(hook: unknown, thisArg: unknown, id: string, ...rest: unknown[]): unknown;
9
+ /** Calls the handler alone, as a bundler without hook filters would. */
10
+ export declare function callHookHandler(hook: unknown, thisArg: unknown, id: string, ...rest: unknown[]): unknown;