@agent-native/core 0.159.0 → 0.159.2

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,9 +77,9 @@ 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
  }>>;
@@ -137,13 +137,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
137
137
  inputSchema: {
138
138
  type: string;
139
139
  properties: {
140
+ count?: undefined;
140
141
  query?: undefined;
141
142
  minutes?: undefined;
142
143
  limit?: undefined;
143
144
  clientHint?: undefined;
144
145
  timestamp?: undefined;
145
146
  chapterId?: undefined;
146
- count?: undefined;
147
147
  startAt?: undefined;
148
148
  endAt?: undefined;
149
149
  reason?: undefined;
@@ -159,6 +159,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
159
159
  inputSchema: {
160
160
  type: string;
161
161
  properties: {
162
+ count?: undefined;
162
163
  query: {
163
164
  type: string;
164
165
  description: string;
@@ -174,7 +175,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
174
175
  clientHint?: undefined;
175
176
  timestamp?: undefined;
176
177
  chapterId?: undefined;
177
- count?: undefined;
178
178
  startAt?: undefined;
179
179
  endAt?: undefined;
180
180
  reason?: undefined;
@@ -190,6 +190,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
190
190
  inputSchema: {
191
191
  type: string;
192
192
  properties: {
193
+ count?: undefined;
193
194
  minutes: {
194
195
  type: string;
195
196
  description: string;
@@ -199,7 +200,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
199
200
  clientHint?: undefined;
200
201
  timestamp?: undefined;
201
202
  chapterId?: undefined;
202
- count?: undefined;
203
203
  startAt?: undefined;
204
204
  endAt?: undefined;
205
205
  reason?: undefined;
@@ -216,6 +216,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
216
216
  type: string;
217
217
  required: string[];
218
218
  properties: {
219
+ count?: undefined;
219
220
  query: {
220
221
  type: string;
221
222
  description: string;
@@ -234,7 +235,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
234
235
  };
235
236
  timestamp?: undefined;
236
237
  chapterId?: undefined;
237
- count?: undefined;
238
238
  startAt?: undefined;
239
239
  endAt?: undefined;
240
240
  reason?: undefined;
@@ -250,6 +250,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
250
250
  type: string;
251
251
  required: string[];
252
252
  properties: {
253
+ count?: undefined;
253
254
  query?: undefined;
254
255
  minutes?: undefined;
255
256
  limit?: undefined;
@@ -263,7 +264,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
263
264
  description: string;
264
265
  };
265
266
  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;
317
318
  query?: undefined;
318
319
  minutes?: undefined;
319
320
  limit?: undefined;
320
321
  clientHint?: undefined;
321
322
  timestamp?: undefined;
322
323
  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;
352
353
  query?: undefined;
353
354
  minutes?: undefined;
354
355
  limit?: undefined;
355
356
  clientHint?: undefined;
356
357
  timestamp?: undefined;
357
358
  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;
19
20
  updated: number;
20
21
  error?: undefined;
21
22
  ok?: undefined;
22
- count?: undefined;
23
23
  } | {
24
+ count?: undefined;
24
25
  updated?: undefined;
25
26
  error: string;
26
27
  ok?: undefined;
27
- count?: undefined;
28
28
  } | {
29
+ count?: undefined;
29
30
  updated?: undefined;
30
31
  error?: undefined;
31
32
  ok: boolean;
32
- count?: undefined;
33
33
  }>>;
@@ -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.0",
3
+ "version": "0.159.2",
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": {