@agent-native/core 0.159.1 → 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.
|
@@ -41,27 +41,27 @@ 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
|
}>>;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -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 — validate an optional candidate value
|
|
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
|
+
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,11 +95,11 @@ 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
|
}>>;
|
|
@@ -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
|
-
|
|
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.
|
|
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": {
|