@agent-native/core 0.159.1 → 0.159.3

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 (38) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/clips/.agents/skills/meetings/SKILL.md +11 -6
  3. package/corpus/templates/clips/AGENTS.md +1 -0
  4. package/corpus/templates/clips/actions/lib/meeting-content.ts +15 -4
  5. package/corpus/templates/clips/actions/list-meetings.ts +179 -42
  6. package/corpus/templates/clips/actions/search-meetings.ts +277 -0
  7. package/corpus/templates/clips/app/components/meetings/agenda-card.tsx +273 -0
  8. package/corpus/templates/clips/app/components/meetings/day-grouped-card.tsx +113 -0
  9. package/corpus/templates/clips/app/components/meetings/meeting-history-row.tsx +117 -0
  10. package/corpus/templates/clips/app/hooks/use-navigation-state.ts +12 -2
  11. package/corpus/templates/clips/app/i18n/en-US.ts +7 -2
  12. package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +263 -357
  13. package/corpus/templates/clips/changelog/2026-08-14-meetings-history-is-searchable-again.md +6 -0
  14. package/corpus/templates/clips/desktop/design-refs/granola-ux.md +17 -0
  15. package/corpus/templates/content/actions/_database-source-utils.ts +29 -2
  16. package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +11 -11
  17. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +11 -50
  18. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +57 -20
  19. package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +30 -0
  20. package/corpus/templates/content/app/components/editor/extensions/NotionExtensions.tsx +204 -51
  21. package/corpus/templates/content/app/global.css +4 -1
  22. package/corpus/templates/content/app/i18n-data.ts +30 -0
  23. package/corpus/templates/content/changelog/2026-08-12-toggle-blocks-now-follow-notion-style-enter-and-shift-tab-be.md +6 -0
  24. package/corpus/templates/content/docs/solutions/2026-08-12-toggle-summary-focus-persistence-shape.md +733 -0
  25. package/corpus/templates/content/shared/builder-mdx.ts +44 -4
  26. package/corpus/templates/slides/actions/get-layout-overflows.ts +65 -2
  27. package/dist/deploy/build.d.ts +6 -4
  28. package/dist/deploy/build.js +27 -11
  29. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  30. package/dist/notifications/routes.d.ts +3 -3
  31. package/dist/observability/routes.d.ts +6 -6
  32. package/dist/secrets/routes.d.ts +3 -3
  33. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  34. package/dist/server/embed-route.js +6 -1
  35. package/dist/server/embed-session.d.ts +4 -1
  36. package/dist/server/embed-session.js +40 -1
  37. package/package.json +2 -2
  38. package/corpus/templates/clips/app/components/meetings/meeting-card.tsx +0 -333
@@ -315,12 +315,50 @@ function isBuilderTrackingPixelBlock(value: unknown) {
315
315
  }
316
316
  }
317
317
 
318
- export function builderBlocksHash(blocks: unknown[]) {
319
- return stableHash(
320
- blocks.filter((block) => !isBuilderTrackingPixelBlock(block)),
318
+ function stripBuilderTrackingPixels(value: unknown): unknown {
319
+ if (isBuilderTrackingPixelBlock(value)) return undefined;
320
+ if (Array.isArray(value)) {
321
+ return value
322
+ .map((item) => stripBuilderTrackingPixels(item))
323
+ .filter((item) => item !== undefined);
324
+ }
325
+ if (!isRecord(value)) return value;
326
+ return Object.fromEntries(
327
+ Object.entries(value).flatMap(([key, child]) => {
328
+ const stripped = stripBuilderTrackingPixels(child);
329
+ return stripped === undefined ? [] : [[key, stripped]];
330
+ }),
321
331
  );
322
332
  }
323
333
 
334
+ function canonicalBuilderBodyHashValue(value: unknown): unknown {
335
+ if (isBuilderTrackingPixelBlock(value)) return undefined;
336
+ if (Array.isArray(value)) {
337
+ return value
338
+ .map((item) => canonicalBuilderBodyHashValue(item))
339
+ .filter((item) => item !== undefined);
340
+ }
341
+ if (!isRecord(value)) return value;
342
+
343
+ const canonical: Record<string, unknown> = {};
344
+ const isReference = value["@type"] === "@builder.io/core:Reference";
345
+ const isBuilderElement = value["@type"] === "@builder.io/sdk:Element";
346
+ const isSymbolContent =
347
+ isRecord(value.data) && Array.isArray(value.data.blocks);
348
+ for (const [key, child] of Object.entries(value)) {
349
+ if (isReference && key === "value") continue;
350
+ if (isBuilderElement && key === "id") continue;
351
+ if (isSymbolContent && key === "rev") continue;
352
+ const next = canonicalBuilderBodyHashValue(child);
353
+ if (next !== undefined) canonical[key] = next;
354
+ }
355
+ return canonical;
356
+ }
357
+
358
+ export function builderBlocksHash(blocks: unknown[]) {
359
+ return stableHash(canonicalBuilderBodyHashValue(blocks));
360
+ }
361
+
324
362
  export function builderSourceHash(entry: BuilderContentEntry) {
325
363
  const data = entry.data ?? {};
326
364
  return stableHash({
@@ -1686,7 +1724,9 @@ async function emitBuilderEntryToMdxFile({
1686
1724
  }
1687
1725
  emitted.add(key);
1688
1726
 
1689
- const blocks = builderEntryBlocks(entry);
1727
+ const blocks = stripBuilderTrackingPixels(
1728
+ builderEntryBlocks(entry),
1729
+ ) as unknown[];
1690
1730
  const rawRoot = builderRawRootForEntry(entry.model, entry.id);
1691
1731
  const ctx: BlocksToMdxContext = {
1692
1732
  rawRoot,
@@ -3,7 +3,58 @@ import { resolveAccess } from "@agent-native/core/sharing";
3
3
  import { z } from "zod";
4
4
 
5
5
  import { hashSlideContent, type DeckFitState } from "../shared/slide-fit.js";
6
- import { readAppStateForCurrentTab } from "./_tab-state.js";
6
+ import {
7
+ readAppStateForCurrentTab,
8
+ writeAppStateForCurrentTab,
9
+ } from "./_tab-state.js";
10
+
11
+ // The layout-fit skill tells the agent to make one bounded repair pass and
12
+ // verify, never to loop. Nothing stopped it from ignoring that and thrashing
13
+ // between get-layout-overflows and update-slide on the same deck until the
14
+ // framework's generic identical-tool-call guard killed the whole turn many
15
+ // calls later. Surface a directive after a few unresolved checks so the
16
+ // agent stops and reports instead of grinding toward that guard.
17
+ const REPEATED_CHECK_WARNING_THRESHOLD = 3;
18
+ const REPEATED_CHECK_WINDOW_MS = 30 * 60_000;
19
+
20
+ interface LayoutOverflowCheckHistory {
21
+ deckId: string;
22
+ count: number;
23
+ lastCheckAt: number;
24
+ }
25
+
26
+ // Keyed per deck (not one shared record) so checking deck A, then B, then A
27
+ // again does not reset A's count on every deck switch within the same tab.
28
+ function historyKeyForDeck(deckId: string): string {
29
+ return `layout-overflow-check-history:${deckId}`;
30
+ }
31
+
32
+ async function noteLayoutOverflowCheck(
33
+ deckId: string,
34
+ resolved: boolean,
35
+ ): Promise<number> {
36
+ const key = historyKeyForDeck(deckId);
37
+ const now = Date.now();
38
+ if (resolved) {
39
+ await writeAppStateForCurrentTab(key, {
40
+ deckId,
41
+ count: 0,
42
+ lastCheckAt: now,
43
+ });
44
+ return 0;
45
+ }
46
+ const prior = (await readAppStateForCurrentTab(key, {
47
+ fallbackToGlobal: false,
48
+ })) as LayoutOverflowCheckHistory | null;
49
+ const carriesOver =
50
+ prior?.deckId === deckId &&
51
+ typeof prior.count === "number" &&
52
+ typeof prior.lastCheckAt === "number" &&
53
+ now - prior.lastCheckAt <= REPEATED_CHECK_WINDOW_MS;
54
+ const count = (carriesOver ? prior!.count : 0) + 1;
55
+ await writeAppStateForCurrentTab(key, { deckId, count, lastCheckAt: now });
56
+ return count;
57
+ }
7
58
 
8
59
  type CurrentSlideFitMeasurement = DeckFitState["slides"][string] & {
9
60
  slideId: string;
@@ -140,6 +191,10 @@ export default defineAction({
140
191
  }
141
192
  });
142
193
 
194
+ const canClaimDeckFits =
195
+ unknownSlideIds.length === 0 && overflows.length === 0;
196
+ const checkCount = await noteLayoutOverflowCheck(deckId, canClaimDeckFits);
197
+
143
198
  return {
144
199
  deckId,
145
200
  status: unknownSlideIds.length > 0 ? "unknown" : "measured",
@@ -147,7 +202,15 @@ export default defineAction({
147
202
  slideCount: slides.length,
148
203
  unknownSlideIds,
149
204
  overflows,
150
- canClaimDeckFits: unknownSlideIds.length === 0 && overflows.length === 0,
205
+ canClaimDeckFits,
206
+ ...(checkCount >= REPEATED_CHECK_WARNING_THRESHOLD
207
+ ? {
208
+ guidance:
209
+ overflows.length > 0
210
+ ? `This deck has been checked ${checkCount} times with overflow still present. Stop re-measuring and patching one slide at a time. Report the exact remaining overflow (slide, pixels, dimension) to the user instead of calling get-layout-overflows again this turn.`
211
+ : `This deck has been checked ${checkCount} times and slide measurements are still unavailable (unknownSlideIds). Stop re-checking and tell the user which slides could not be measured instead of calling get-layout-overflows again this turn.`,
212
+ }
213
+ : {}),
151
214
  };
152
215
  },
153
216
  });
@@ -232,6 +232,8 @@ export declare function emitSingleTemplateNetlifyIntegrationRecoveryFunction(pro
232
232
  * then point every emitted server chunk at that one portable runtime module.
233
233
  */
234
234
  export declare function bundleYjsRuntimeForServerlessOutput(serverDir: string, projectCwd: string): string[];
235
+ /** Presets whose Node-style output needs the emitted Yjs runtime bundle. */
236
+ export declare function shouldBundleYjsRuntimeForPreset(targetPreset: string): boolean;
235
237
  export declare function assertSingleTemplateNetlifyBuildOutput(projectCwd: string): void;
236
238
  /**
237
239
  * Strip the harmful single-template catch-all rewrite that points at
@@ -319,8 +321,8 @@ export declare function createCloudflareModuleStubPlugin(): {
319
321
  load(id: string): string;
320
322
  };
321
323
  /**
322
- * Dependencies Nitro itself must bundle outside the controlled serverless
323
- * output pass. Netlify, Vercel, and Lambda keep Yjs external through Nitro;
324
+ * Dependencies Nitro itself must bundle outside the controlled Yjs output pass.
325
+ * Node and controlled serverless presets keep Yjs external through Nitro;
324
326
  * `bundleYjsRuntimeForServerlessOutput` then creates their one portable copy.
325
327
  */
326
328
  export declare const NITRO_SERVER_RUNTIME_BUNDLED_DEPS: readonly ["yjs"];
@@ -331,8 +333,8 @@ export declare const NITRO_SERVER_RUNTIME_BUNDLED_DEPS: readonly ["yjs"];
331
333
  */
332
334
  export declare function resolveNitroBundledYjsEntry(): string;
333
335
  /**
334
- * Edge runtimes have no node_modules, while Node/serverless outputs only need
335
- * the small set above bundled to keep their package manifests traceable.
336
+ * Edge runtimes have no node_modules, while Node/serverless outputs receive the
337
+ * small set above through the controlled post-build pass.
336
338
  */
337
339
  export declare function nitroNoExternalsForPreset(targetPreset: string): true | readonly string[];
338
340
  export declare function resolveNitroBuildReplacements(env?: NodeJS.ProcessEnv): Record<string, string>;
@@ -2913,7 +2913,7 @@ export function bundleYjsRuntimeForServerlessOutput(serverDir, projectCwd) {
2913
2913
  bareImports.push(filePath);
2914
2914
  });
2915
2915
  if (unsupportedSubpathImports.length > 0) {
2916
- throw new Error(`[deploy] Serverless output left unsupported yjs subpath imports in ${unsupportedSubpathImports.join(", ")}`);
2916
+ throw new Error(`[deploy] Node/server output left unsupported yjs subpath imports in ${unsupportedSubpathImports.join(", ")}`);
2917
2917
  }
2918
2918
  if (bareImports.length === 0)
2919
2919
  return [];
@@ -2954,6 +2954,14 @@ export function bundleYjsRuntimeForServerlessOutput(serverDir, projectCwd) {
2954
2954
  });
2955
2955
  return bareImports;
2956
2956
  }
2957
+ /** Presets whose Node-style output needs the emitted Yjs runtime bundle. */
2958
+ export function shouldBundleYjsRuntimeForPreset(targetPreset) {
2959
+ return (targetPreset === "netlify" ||
2960
+ targetPreset === "vercel" ||
2961
+ targetPreset === "aws-lambda" ||
2962
+ targetPreset === "node" ||
2963
+ targetPreset === "node-server");
2964
+ }
2957
2965
  // Netlify's hard limit is 250MB unzipped per function; keep 10MB of headroom
2958
2966
  // for packaging variance so a passing guard does not sit on the platform edge.
2959
2967
  const NETLIFY_FUNCTION_SIZE_BUDGET_BYTES = 120 * 1024 * 1024;
@@ -3623,8 +3631,8 @@ export function createCloudflareModuleStubPlugin() {
3623
3631
  };
3624
3632
  }
3625
3633
  /**
3626
- * Dependencies Nitro itself must bundle outside the controlled serverless
3627
- * output pass. Netlify, Vercel, and Lambda keep Yjs external through Nitro;
3634
+ * Dependencies Nitro itself must bundle outside the controlled Yjs output pass.
3635
+ * Node and controlled serverless presets keep Yjs external through Nitro;
3628
3636
  * `bundleYjsRuntimeForServerlessOutput` then creates their one portable copy.
3629
3637
  */
3630
3638
  export const NITRO_SERVER_RUNTIME_BUNDLED_DEPS = ["yjs"];
@@ -3643,8 +3651,8 @@ export function resolveNitroBundledYjsEntry() {
3643
3651
  return entry;
3644
3652
  }
3645
3653
  /**
3646
- * Edge runtimes have no node_modules, while Node/serverless outputs only need
3647
- * the small set above bundled to keep their package manifests traceable.
3654
+ * Edge runtimes have no node_modules, while Node/serverless outputs receive the
3655
+ * small set above through the controlled post-build pass.
3648
3656
  */
3649
3657
  export function nitroNoExternalsForPreset(targetPreset) {
3650
3658
  return targetPreset.startsWith("cloudflare") ||
@@ -3652,7 +3660,9 @@ export function nitroNoExternalsForPreset(targetPreset) {
3652
3660
  ? true
3653
3661
  : targetPreset === "netlify" ||
3654
3662
  targetPreset === "vercel" ||
3655
- targetPreset === "aws-lambda"
3663
+ targetPreset === "aws-lambda" ||
3664
+ targetPreset === "node" ||
3665
+ targetPreset === "node-server"
3656
3666
  ? []
3657
3667
  : NITRO_SERVER_RUNTIME_BUNDLED_DEPS;
3658
3668
  }
@@ -3809,10 +3819,14 @@ export default bundle;
3809
3819
  rollupConfig: {
3810
3820
  // Nitro treats the intermediate React Router SSR files as prebuilt
3811
3821
  // chunks, while core's server collaboration files participate in the
3812
- // final Rolldown graph. Externalize Yjs consistently on serverless so
3822
+ // final Rolldown graph. Externalize Yjs consistently on Node/serverless so
3813
3823
  // both graphs retain their public import shapes; the controlled
3814
3824
  // post-build pass below bundles and rewrites them to one module.
3815
- ...(preset === "netlify" || preset === "vercel" || preset === "aws-lambda"
3825
+ ...(preset === "netlify" ||
3826
+ preset === "vercel" ||
3827
+ preset === "aws-lambda" ||
3828
+ preset === "node" ||
3829
+ preset === "node-server"
3816
3830
  ? { external: ["yjs"] }
3817
3831
  : {}),
3818
3832
  plugins: [
@@ -3827,9 +3841,9 @@ export default bundle;
3827
3841
  : {}),
3828
3842
  routeRules: mcpEmbedStaticAssetRouteRules(appBasePath),
3829
3843
  // Edge presets (cloudflare, deno) bundle all deps because node_modules are
3830
- // unavailable at runtime. Ordinary Node presets bundle Yjs through Nitro.
3831
- // Controlled serverless presets externalize it above, then emit one full
3832
- // runtime module after Nitro has preserved every consumer's public imports.
3844
+ // unavailable at runtime. Node and controlled serverless presets
3845
+ // externalize Yjs above, then emit one full runtime module after Nitro has
3846
+ // preserved every consumer's public imports.
3833
3847
  noExternals: nitroNoExternalsForPreset(preset),
3834
3848
  });
3835
3849
  await runNitroBuildPipeline({
@@ -3852,6 +3866,8 @@ export default bundle;
3852
3866
  // Before the Netlify block below clones this dir into the extra functions,
3853
3867
  // so they inherit the pruned bundle instead of a second full copy.
3854
3868
  pruneServerlessFunctionDeadWeight(nitro.options.output.serverDir);
3869
+ }
3870
+ if (shouldBundleYjsRuntimeForPreset(preset)) {
3855
3871
  bundleYjsRuntimeForServerlessOutput(nitro.options.output.serverDir, cwd);
3856
3872
  }
3857
3873
  if (isCloudflareModulePreset(preset)) {
@@ -137,13 +137,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
137
137
  inputSchema: {
138
138
  type: string;
139
139
  properties: {
140
- count?: undefined;
141
140
  query?: undefined;
142
141
  minutes?: undefined;
143
142
  limit?: undefined;
144
143
  clientHint?: undefined;
145
144
  timestamp?: undefined;
146
145
  chapterId?: undefined;
146
+ count?: undefined;
147
147
  startAt?: undefined;
148
148
  endAt?: undefined;
149
149
  reason?: undefined;
@@ -159,7 +159,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
159
159
  inputSchema: {
160
160
  type: string;
161
161
  properties: {
162
- count?: undefined;
163
162
  query: {
164
163
  type: string;
165
164
  description: string;
@@ -175,6 +174,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
175
174
  clientHint?: undefined;
176
175
  timestamp?: undefined;
177
176
  chapterId?: undefined;
177
+ count?: undefined;
178
178
  startAt?: undefined;
179
179
  endAt?: undefined;
180
180
  reason?: undefined;
@@ -190,7 +190,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
190
190
  inputSchema: {
191
191
  type: string;
192
192
  properties: {
193
- count?: undefined;
194
193
  minutes: {
195
194
  type: string;
196
195
  description: string;
@@ -200,6 +199,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
200
199
  clientHint?: undefined;
201
200
  timestamp?: undefined;
202
201
  chapterId?: undefined;
202
+ count?: undefined;
203
203
  startAt?: undefined;
204
204
  endAt?: undefined;
205
205
  reason?: undefined;
@@ -216,7 +216,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
216
216
  type: string;
217
217
  required: string[];
218
218
  properties: {
219
- count?: undefined;
220
219
  query: {
221
220
  type: string;
222
221
  description: string;
@@ -235,6 +234,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
235
234
  };
236
235
  timestamp?: undefined;
237
236
  chapterId?: undefined;
237
+ count?: undefined;
238
238
  startAt?: undefined;
239
239
  endAt?: undefined;
240
240
  reason?: undefined;
@@ -250,7 +250,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
250
250
  type: string;
251
251
  required: string[];
252
252
  properties: {
253
- count?: undefined;
254
253
  query?: undefined;
255
254
  minutes?: undefined;
256
255
  limit?: undefined;
@@ -264,6 +263,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
264
263
  description: string;
265
264
  };
266
265
  chapterId?: undefined;
266
+ count?: undefined;
267
267
  startAt?: undefined;
268
268
  endAt?: undefined;
269
269
  includeMicrophone?: undefined;
@@ -314,13 +314,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
314
314
  type: string;
315
315
  required: string[];
316
316
  properties: {
317
- count?: undefined;
318
317
  query?: undefined;
319
318
  minutes?: undefined;
320
319
  limit?: undefined;
321
320
  clientHint?: undefined;
322
321
  timestamp?: undefined;
323
322
  chapterId?: undefined;
323
+ count?: undefined;
324
324
  startAt: {
325
325
  type: string;
326
326
  description: string;
@@ -349,13 +349,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
349
349
  type: string;
350
350
  required: string[];
351
351
  properties: {
352
- count?: undefined;
353
352
  query?: undefined;
354
353
  minutes?: undefined;
355
354
  limit?: undefined;
356
355
  clientHint?: undefined;
357
356
  timestamp?: undefined;
358
357
  chapterId?: undefined;
358
+ count?: undefined;
359
359
  startAt?: undefined;
360
360
  endAt?: undefined;
361
361
  reason?: undefined;
@@ -16,18 +16,18 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
16
16
  error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- count?: undefined;
20
19
  updated: number;
21
20
  error?: undefined;
22
21
  ok?: undefined;
23
- } | {
24
22
  count?: undefined;
23
+ } | {
25
24
  updated?: undefined;
26
25
  error: string;
27
26
  ok?: undefined;
28
- } | {
29
27
  count?: undefined;
28
+ } | {
30
29
  updated?: undefined;
31
30
  error?: undefined;
32
31
  ok: boolean;
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;
44
46
  summary: import("./types.js").TraceSummary;
45
47
  spans: import("./types.js").TraceSpan[];
46
48
  id?: undefined;
47
- error?: undefined;
48
- ok?: undefined;
49
49
  } | {
50
+ ok?: undefined;
51
+ error?: undefined;
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
  }>>;
@@ -34,16 +34,16 @@ 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
40
  ok: boolean;
41
41
  status: string;
42
42
  error?: undefined;
43
43
  } | {
44
+ ok?: undefined;
44
45
  error: string;
45
46
  removed?: undefined;
46
- ok?: undefined;
47
47
  } | {
48
48
  ok: boolean;
49
49
  removed: boolean;
@@ -54,9 +54,9 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
54
54
  * or the current stored value without changing anything.
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
61
  ok: boolean;
62
62
  note?: undefined;
@@ -27,10 +27,10 @@ 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;
30
31
  ok: boolean;
31
32
  key: string;
32
33
  baseUrlKey?: string;
33
34
  scope: AgentEngineApiKeyScope;
34
- error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -125,6 +125,8 @@ function logEmbedConsumeResult(event, diagnostic, responseStatus) {
125
125
  ticketRowFound: diagnostic.ticketRowFound,
126
126
  consumed: diagnostic.consumed,
127
127
  expired: diagnostic.expired,
128
+ expectedOwnerKey: diagnostic.expectedOwnerKey,
129
+ ticketOwnerKey: diagnostic.ticketOwnerKey,
128
130
  expectedOrgKey: diagnostic.expectedOrgKey,
129
131
  ticketOrgKey: diagnostic.ticketOrgKey,
130
132
  responseStatus,
@@ -253,7 +255,10 @@ export function createEmbedStartRouteHandler(options = {}) {
253
255
  .catch(() => null);
254
256
  let consumeDiagnostic = null;
255
257
  const consumed = await consumeEmbedSessionTicket(ticket, {
256
- expectedOrgId: existingSession?.orgId ?? null,
258
+ // Org ids are app-local in the workspace: the Dispatch parent and a
259
+ // target app can represent the same signed-in person with different
260
+ // ids. Bind an existing target session to the ticket owner instead.
261
+ expectedOwnerEmail: existingSession?.email ?? null,
257
262
  onResult: (diagnostic) => {
258
263
  consumeDiagnostic = diagnostic;
259
264
  },
@@ -12,17 +12,20 @@ export interface EmbedSessionTicket {
12
12
  ticketHash: string;
13
13
  expiresAt: number;
14
14
  }
15
- export type EmbedSessionTicketConsumeOutcome = "missing-ticket" | "not-found" | "already-consumed" | "expired" | "org-mismatch" | "consumption-race" | "invalid-row" | "consumed";
15
+ export type EmbedSessionTicketConsumeOutcome = "missing-ticket" | "not-found" | "already-consumed" | "expired" | "identity-mismatch" | "org-mismatch" | "consumption-race" | "invalid-row" | "consumed";
16
16
  export interface EmbedSessionTicketConsumeDiagnostic {
17
17
  outcome: EmbedSessionTicketConsumeOutcome;
18
18
  ticketKey: string | null;
19
19
  ticketRowFound: boolean;
20
20
  consumed: boolean;
21
21
  expired: boolean;
22
+ expectedOwnerKey: string | null;
23
+ ticketOwnerKey: string | null;
22
24
  expectedOrgKey: string | null;
23
25
  ticketOrgKey: string | null;
24
26
  }
25
27
  export interface ConsumeEmbedSessionTicketOptions {
28
+ expectedOwnerEmail?: string | null;
26
29
  expectedOrgId?: string | null;
27
30
  onResult?: (result: EmbedSessionTicketConsumeDiagnostic) => void;
28
31
  }
@@ -139,6 +139,10 @@ function redactedIdentifier(value) {
139
139
  return null;
140
140
  return crypto.createHash("sha256").update(value).digest("hex").slice(0, 12);
141
141
  }
142
+ function normalizedEmail(value) {
143
+ const normalized = value?.trim().toLowerCase();
144
+ return normalized || null;
145
+ }
142
146
  function numberOrNull(value) {
143
147
  if (value == null)
144
148
  return null;
@@ -464,6 +468,8 @@ export async function createEmbedSessionTicket(input) {
464
468
  return { ticket, ticketHash, expiresAt };
465
469
  }
466
470
  export async function consumeEmbedSessionTicket(ticket, options = {}) {
471
+ const expectedOwnerEmail = normalizedEmail(options.expectedOwnerEmail);
472
+ const expectedOwnerKey = redactedIdentifier(expectedOwnerEmail);
467
473
  const expectedOrgKey = redactedIdentifier(options.expectedOrgId);
468
474
  if (!ticket) {
469
475
  options.onResult?.({
@@ -472,6 +478,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
472
478
  ticketRowFound: false,
473
479
  consumed: false,
474
480
  expired: false,
481
+ expectedOwnerKey,
482
+ ticketOwnerKey: null,
475
483
  expectedOrgKey,
476
484
  ticketOrgKey: null,
477
485
  });
@@ -493,6 +501,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
493
501
  ticketRowFound: false,
494
502
  consumed: false,
495
503
  expired: false,
504
+ expectedOwnerKey,
505
+ ticketOwnerKey: null,
496
506
  expectedOrgKey,
497
507
  ticketOrgKey: null,
498
508
  });
@@ -501,6 +511,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
501
511
  const row = rows[0];
502
512
  const expiresAt = numberOrNull(row.expires_at ?? row.expiresAt);
503
513
  const consumedAt = numberOrNull(row.consumed_at ?? row.consumedAt);
514
+ const ownerEmail = stringOrUndefined(row.owner_email ?? row.ownerEmail);
515
+ const ticketOwnerKey = redactedIdentifier(normalizedEmail(ownerEmail));
504
516
  const orgId = stringOrUndefined(row.org_id ?? row.orgId);
505
517
  const ticketOrgKey = redactedIdentifier(orgId);
506
518
  if (consumedAt != null) {
@@ -510,6 +522,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
510
522
  ticketRowFound: true,
511
523
  consumed: true,
512
524
  expired: false,
525
+ expectedOwnerKey,
526
+ ticketOwnerKey,
513
527
  expectedOrgKey,
514
528
  ticketOrgKey,
515
529
  });
@@ -522,6 +536,24 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
522
536
  ticketRowFound: true,
523
537
  consumed: false,
524
538
  expired: true,
539
+ expectedOwnerKey,
540
+ ticketOwnerKey,
541
+ expectedOrgKey,
542
+ ticketOrgKey,
543
+ });
544
+ return null;
545
+ }
546
+ if (expectedOwnerEmail &&
547
+ ownerEmail &&
548
+ normalizedEmail(ownerEmail) !== expectedOwnerEmail) {
549
+ options.onResult?.({
550
+ outcome: "identity-mismatch",
551
+ ticketKey,
552
+ ticketRowFound: true,
553
+ consumed: false,
554
+ expired: false,
555
+ expectedOwnerKey,
556
+ ticketOwnerKey,
525
557
  expectedOrgKey,
526
558
  ticketOrgKey,
527
559
  });
@@ -534,6 +566,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
534
566
  ticketRowFound: true,
535
567
  consumed: false,
536
568
  expired: false,
569
+ expectedOwnerKey,
570
+ ticketOwnerKey,
537
571
  expectedOrgKey,
538
572
  ticketOrgKey,
539
573
  });
@@ -551,13 +585,14 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
551
585
  ticketRowFound: true,
552
586
  consumed: false,
553
587
  expired: false,
588
+ expectedOwnerKey,
589
+ ticketOwnerKey,
554
590
  expectedOrgKey,
555
591
  ticketOrgKey,
556
592
  });
557
593
  return null;
558
594
  }
559
595
  const targetPath = normalizeEmbedTargetPath(stringOrUndefined(row.target_path ?? row.targetPath));
560
- const ownerEmail = stringOrUndefined(row.owner_email ?? row.ownerEmail);
561
596
  if (!targetPath || !ownerEmail || expiresAt == null) {
562
597
  options.onResult?.({
563
598
  outcome: "invalid-row",
@@ -565,6 +600,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
565
600
  ticketRowFound: true,
566
601
  consumed: true,
567
602
  expired: false,
603
+ expectedOwnerKey,
604
+ ticketOwnerKey,
568
605
  expectedOrgKey,
569
606
  ticketOrgKey,
570
607
  });
@@ -576,6 +613,8 @@ export async function consumeEmbedSessionTicket(ticket, options = {}) {
576
613
  ticketRowFound: true,
577
614
  consumed: true,
578
615
  expired: false,
616
+ expectedOwnerKey,
617
+ ticketOwnerKey,
579
618
  expectedOrgKey,
580
619
  ticketOrgKey,
581
620
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.159.1",
3
+ "version": "0.159.3",
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": {
@@ -426,7 +426,7 @@
426
426
  "yjs": "^13.6.31",
427
427
  "zod": "^4.3.6",
428
428
  "@agent-native/recap-cli": "0.5.4",
429
- "@agent-native/toolkit": "^0.16.3"
429
+ "@agent-native/toolkit": "^0.16.4"
430
430
  },
431
431
  "devDependencies": {
432
432
  "@ai-sdk/anthropic": "^3.0.71",