@fork-api/chat-sdk 0.1.178 → 0.1.181
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.
- package/dist/index.cjs +8 -7
- package/dist/index.d.cts +102 -51
- package/dist/index.d.ts +102 -51
- package/dist/index.js +8 -7
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, ReactElement, ComponentType } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* DOM element picker — the Chrome-DevTools-inspect experience for the chat
|
|
6
|
+
* panel. While active it paints a highlight overlay + label over whatever
|
|
7
|
+
* host-page element the cursor is on; clicking captures a structured context
|
|
8
|
+
* blob for the agent, Esc cancels.
|
|
9
|
+
*
|
|
10
|
+
* The overlay mounts directly on document.body (NOT inside the panel's
|
|
11
|
+
* shadow root) so it can sit over host elements, and it is pointer-events:
|
|
12
|
+
* none so document.elementFromPoint() resolves the real host target.
|
|
13
|
+
* Everything inside the Fork panel/launcher hosts is ignored — hovering the
|
|
14
|
+
* panel clears the highlight, clicking it neither selects nor cancels.
|
|
15
|
+
*/
|
|
16
|
+
interface SelectedElementContext {
|
|
17
|
+
tag: string;
|
|
18
|
+
id?: string;
|
|
19
|
+
classes?: string[];
|
|
20
|
+
selector?: string;
|
|
21
|
+
componentName?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
html?: string;
|
|
24
|
+
rect?: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Image attachment riding on a fork prompt (raw base64 + media type). */
|
|
33
|
+
interface ForkPromptAttachment {
|
|
34
|
+
mediaType: string;
|
|
35
|
+
data: string;
|
|
36
|
+
}
|
|
37
|
+
/** Options for submitting a prompt from the chat panel. */
|
|
38
|
+
interface ForkSubmitOptions {
|
|
39
|
+
/** Follow-up on this fork (otherwise a new fork is composed). */
|
|
40
|
+
forkId?: string | null;
|
|
41
|
+
/** Force a new fork even when one exists for the target. */
|
|
42
|
+
forceNew?: boolean;
|
|
43
|
+
/** Screenshots pasted/uploaded into the composer. */
|
|
44
|
+
attachments?: ForkPromptAttachment[];
|
|
45
|
+
/** DOM element the user picked on the page for context. */
|
|
46
|
+
selectedElement?: SelectedElementContext | null;
|
|
47
|
+
}
|
|
4
48
|
interface Fork {
|
|
5
49
|
id: string;
|
|
6
50
|
userId: string;
|
|
@@ -63,7 +107,8 @@ interface ForkProviderBase {
|
|
|
63
107
|
shared?: ForkSharedRegistry;
|
|
64
108
|
}
|
|
65
109
|
/**
|
|
66
|
-
* User identity — provide EITHER userId (optionally with userHash
|
|
110
|
+
* User identity — provide EITHER userId (optionally with userHash or userJwt)
|
|
111
|
+
* OR authUrl:
|
|
67
112
|
*
|
|
68
113
|
* - `userId` alone: Client-asserted, no server verification (dev/testing only).
|
|
69
114
|
* - `userId` + `userHash`: Host-brokered verified identity. Your backend
|
|
@@ -71,12 +116,37 @@ interface ForkProviderBase {
|
|
|
71
116
|
* both as props. Fork never touches cookies or Web Storage for identity, so
|
|
72
117
|
* this is the required mode for embedded/iframe contexts where third-party
|
|
73
118
|
* cookies are blocked (e.g. app-store review environments).
|
|
74
|
-
* - `
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
119
|
+
* - `userJwt`: OPTIONAL and ADDITIVE — it carries custom user attributes, it
|
|
120
|
+
* does not replace the identity you already send. Your backend signs HS256
|
|
121
|
+
* with a key DERIVED from your sk_ — `HMAC-SHA256(sk_, "fork-user-jwt-v1")`,
|
|
122
|
+
* never sk_ itself, which would let your own auth endpoint be used as a
|
|
123
|
+
* signing oracle. Payload: `{ sub: userId, attrs: { role, vertical, ... } }`
|
|
124
|
+
* with `audience: "fork"` and an `expiresIn` (both required, max 7 days).
|
|
125
|
+
* Everything in `attrs` becomes a custom user attribute visible in Fork
|
|
126
|
+
* admin. Because the claim sits inside the signature, an end user cannot
|
|
127
|
+
* forge it from devtools — which is why attributes ride here and not in a
|
|
128
|
+
* plain prop. Keep sending `userId` + `userHash` alongside it.
|
|
129
|
+
* - `authUrl`: URL on your backend that returns `{ userId, userHash }`, plus
|
|
130
|
+
* `userJwt` if you want attributes. The SDK calls it on mount (same-origin,
|
|
131
|
+
* cookies sent automatically). Relies on the host's cookie session, so it
|
|
132
|
+
* does not work where the host page's cookies are third-party — prefer the
|
|
133
|
+
* prop modes there.
|
|
134
|
+
*
|
|
135
|
+
* `userHash` remains the universal credential and is NOT deprecated: it is what
|
|
136
|
+
* authenticates every request the SDK makes. `userJwt` is stamped on the
|
|
137
|
+
* provider's own calls, which is where attributes get recorded — one such call
|
|
138
|
+
* per mount is all it takes, since the server leaves stored attributes untouched
|
|
139
|
+
* on requests that carry no token.
|
|
140
|
+
*
|
|
141
|
+
* Adding attributes to an existing integration is therefore purely additive:
|
|
142
|
+
* return one more field from the endpoint you already have. Nothing you send
|
|
143
|
+
* today changes meaning, and rolling it back is deleting that field.
|
|
78
144
|
*
|
|
79
|
-
*
|
|
145
|
+
* Expiry is required and capped at 7 days; 24h is a reasonable choice. An
|
|
146
|
+
* expired token costs you attribute freshness, never access, because `userHash`
|
|
147
|
+
* is still carrying the identity.
|
|
148
|
+
*
|
|
149
|
+
* In any verified mode, if the user is also a Fork tenant operator (their
|
|
80
150
|
* email matches a fork_users row with a user_roles entry on this tenant), the
|
|
81
151
|
* SDK transparently enters admin mode and acts as their mapped end-user — set
|
|
82
152
|
* the mapping in Fork's Team Settings → End user.
|
|
@@ -84,11 +154,13 @@ interface ForkProviderBase {
|
|
|
84
154
|
type ForkProviderProps = ForkProviderBase & ({
|
|
85
155
|
userId: string;
|
|
86
156
|
userHash?: string;
|
|
157
|
+
userJwt?: string;
|
|
87
158
|
authUrl?: never;
|
|
88
159
|
} | {
|
|
89
160
|
authUrl: string;
|
|
90
161
|
userId?: never;
|
|
91
162
|
userHash?: never;
|
|
163
|
+
userJwt?: never;
|
|
92
164
|
});
|
|
93
165
|
interface ForkBoundaryRegistration {
|
|
94
166
|
id: string;
|
|
@@ -268,11 +340,8 @@ interface ForkPanelProps {
|
|
|
268
340
|
targetId?: string;
|
|
269
341
|
targetLabel?: string;
|
|
270
342
|
historyMode?: "slot" | "boundary" | "none";
|
|
271
|
-
onSubmit: (prompt: string, targetId: string, containerId?: string | null, opts?:
|
|
272
|
-
|
|
273
|
-
forceNew?: boolean;
|
|
274
|
-
}) => void;
|
|
275
|
-
onUndo?: (targetId: string) => Promise<any>;
|
|
343
|
+
onSubmit: (prompt: string, targetId: string, containerId?: string | null, opts?: ForkSubmitOptions) => void;
|
|
344
|
+
onUndo?: (targetId: string, forkId?: string | null) => Promise<any>;
|
|
276
345
|
onClose: () => void;
|
|
277
346
|
baseUrl?: string;
|
|
278
347
|
apiKey?: string;
|
|
@@ -302,10 +371,7 @@ declare function useFork(): {
|
|
|
302
371
|
runs: Record<string, ForkRun>;
|
|
303
372
|
open: () => void;
|
|
304
373
|
close: () => void;
|
|
305
|
-
startFork: (prompt: string, slotId?: string, containerId?: string | null, opts?:
|
|
306
|
-
forkId?: string | null;
|
|
307
|
-
forceNew?: boolean;
|
|
308
|
-
}) => Promise<void>;
|
|
374
|
+
startFork: (prompt: string, slotId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
309
375
|
undoFork: (slotId: string) => Promise<any>;
|
|
310
376
|
adoptRunningFork: (forkId: string) => Promise<void>;
|
|
311
377
|
};
|
|
@@ -318,11 +384,8 @@ declare function useBoundaryFork(boundaryId: string): {
|
|
|
318
384
|
runs: Record<string, ForkRun>;
|
|
319
385
|
open: () => void;
|
|
320
386
|
close: () => void;
|
|
321
|
-
startFork: (prompt: string, containerId?: string | null, opts?:
|
|
322
|
-
|
|
323
|
-
forceNew?: boolean;
|
|
324
|
-
}) => Promise<void>;
|
|
325
|
-
undoFork: () => Promise<any>;
|
|
387
|
+
startFork: (prompt: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
388
|
+
undoFork: (forkId?: string | null) => Promise<any>;
|
|
326
389
|
adoptRunningFork: (forkId: string) => Promise<void>;
|
|
327
390
|
};
|
|
328
391
|
|
|
@@ -332,22 +395,16 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
332
395
|
targetId: string;
|
|
333
396
|
targetLabel: string | undefined;
|
|
334
397
|
historyMode: "slot" | "boundary";
|
|
335
|
-
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
336
|
-
|
|
337
|
-
forceNew?: boolean;
|
|
338
|
-
}) => Promise<void>;
|
|
339
|
-
undo: (submittedTargetId?: string) => Promise<any>;
|
|
398
|
+
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
399
|
+
undo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
340
400
|
buttonProps: {
|
|
341
401
|
onClick: () => void;
|
|
342
402
|
hasNotification: boolean;
|
|
343
403
|
activity: ForkActivitySummary;
|
|
344
404
|
};
|
|
345
405
|
panelProps: {
|
|
346
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
347
|
-
|
|
348
|
-
forceNew?: boolean;
|
|
349
|
-
}) => Promise<void>;
|
|
350
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
406
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
407
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
351
408
|
onClose: (() => void) | (() => void);
|
|
352
409
|
baseUrl: string;
|
|
353
410
|
apiKey: string;
|
|
@@ -363,11 +420,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
363
420
|
error: string | null;
|
|
364
421
|
runs: Record<string, ForkRun>;
|
|
365
422
|
} | {
|
|
366
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
367
|
-
|
|
368
|
-
forceNew?: boolean;
|
|
369
|
-
}) => Promise<void>;
|
|
370
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
423
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
424
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
371
425
|
onClose: (() => void) | (() => void);
|
|
372
426
|
baseUrl: string;
|
|
373
427
|
apiKey: string;
|
|
@@ -397,22 +451,16 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
397
451
|
targetId: string;
|
|
398
452
|
targetLabel: string | undefined;
|
|
399
453
|
historyMode: "slot" | "boundary";
|
|
400
|
-
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
401
|
-
|
|
402
|
-
forceNew?: boolean;
|
|
403
|
-
}) => Promise<void>;
|
|
404
|
-
undo: (submittedTargetId?: string) => Promise<any>;
|
|
454
|
+
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
455
|
+
undo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
405
456
|
buttonProps: {
|
|
406
457
|
onClick: () => void;
|
|
407
458
|
hasNotification: boolean;
|
|
408
459
|
activity: ForkActivitySummary;
|
|
409
460
|
};
|
|
410
461
|
panelProps: {
|
|
411
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
412
|
-
|
|
413
|
-
forceNew?: boolean;
|
|
414
|
-
}) => Promise<void>;
|
|
415
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
462
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
463
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
416
464
|
onClose: (() => void) | (() => void);
|
|
417
465
|
baseUrl: string;
|
|
418
466
|
apiKey: string;
|
|
@@ -428,11 +476,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
428
476
|
error: string | null;
|
|
429
477
|
runs: Record<string, ForkRun>;
|
|
430
478
|
} | {
|
|
431
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
432
|
-
|
|
433
|
-
forceNew?: boolean;
|
|
434
|
-
}) => Promise<void>;
|
|
435
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
479
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
480
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
436
481
|
onClose: (() => void) | (() => void);
|
|
437
482
|
baseUrl: string;
|
|
438
483
|
apiKey: string;
|
|
@@ -791,6 +836,12 @@ interface LoadManifestInput {
|
|
|
791
836
|
userId: string;
|
|
792
837
|
/** Optional userHash for HMAC verification. */
|
|
793
838
|
userHash?: string;
|
|
839
|
+
/**
|
|
840
|
+
* Optional attribute-bearing token (see ForkProviderProps). Sent so the
|
|
841
|
+
* manifest fetch — which runs on every mount, for every user, not just
|
|
842
|
+
* operators — is what records the tenant's custom user attributes.
|
|
843
|
+
*/
|
|
844
|
+
userJwt?: string;
|
|
794
845
|
/** Authorized explicit container lookup, used for container-bound previews. */
|
|
795
846
|
containerId?: string;
|
|
796
847
|
/** Additional trusted headers, e.g. preview session headers. */
|
|
@@ -817,4 +868,4 @@ declare function clearCachedManifest(tenantId: string, appId: string, userId: st
|
|
|
817
868
|
*/
|
|
818
869
|
declare function manifestDiffers(a: Manifest | null, b: Manifest | null): boolean;
|
|
819
870
|
|
|
820
|
-
export { type AdminContainer, type AdminContext, type EnsureFeatureInput, type EnsureLlmJobsInput, type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkDataClient, type ForkDataClientConfig, type ForkDataSource, type ForkDataStatus, type ForkEntityRef, type ForkEvent, type ForkFeature, type ForkFeatureKind, type ForkFeatureOption, type ForkFeatureValue, type ForkLlmJob, type ForkLlmJobStatus, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type QueryLlmJobsInput, type QueryValuesInput, type SetOptionsInput, type SetValuesInput, type UseForkFeatureValuesInput, type UseForkLlmJobsInput, clearCachedManifest, createForkDataClient, forkEntityValueKey, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, useForkDataClient, useForkDataMutation, useForkFeatureValues, useForkLlmJobs, writeCachedManifest };
|
|
871
|
+
export { type AdminContainer, type AdminContext, type EnsureFeatureInput, type EnsureLlmJobsInput, type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkDataClient, type ForkDataClientConfig, type ForkDataSource, type ForkDataStatus, type ForkEntityRef, type ForkEvent, type ForkFeature, type ForkFeatureKind, type ForkFeatureOption, type ForkFeatureValue, type ForkLlmJob, type ForkLlmJobStatus, ForkPanel, type ForkPromptAttachment, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, type ForkSubmitOptions, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type QueryLlmJobsInput, type QueryValuesInput, type SelectedElementContext, type SetOptionsInput, type SetValuesInput, type UseForkFeatureValuesInput, type UseForkLlmJobsInput, clearCachedManifest, createForkDataClient, forkEntityValueKey, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, useForkDataClient, useForkDataMutation, useForkFeatureValues, useForkLlmJobs, writeCachedManifest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, ReactElement, ComponentType } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* DOM element picker — the Chrome-DevTools-inspect experience for the chat
|
|
6
|
+
* panel. While active it paints a highlight overlay + label over whatever
|
|
7
|
+
* host-page element the cursor is on; clicking captures a structured context
|
|
8
|
+
* blob for the agent, Esc cancels.
|
|
9
|
+
*
|
|
10
|
+
* The overlay mounts directly on document.body (NOT inside the panel's
|
|
11
|
+
* shadow root) so it can sit over host elements, and it is pointer-events:
|
|
12
|
+
* none so document.elementFromPoint() resolves the real host target.
|
|
13
|
+
* Everything inside the Fork panel/launcher hosts is ignored — hovering the
|
|
14
|
+
* panel clears the highlight, clicking it neither selects nor cancels.
|
|
15
|
+
*/
|
|
16
|
+
interface SelectedElementContext {
|
|
17
|
+
tag: string;
|
|
18
|
+
id?: string;
|
|
19
|
+
classes?: string[];
|
|
20
|
+
selector?: string;
|
|
21
|
+
componentName?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
html?: string;
|
|
24
|
+
rect?: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Image attachment riding on a fork prompt (raw base64 + media type). */
|
|
33
|
+
interface ForkPromptAttachment {
|
|
34
|
+
mediaType: string;
|
|
35
|
+
data: string;
|
|
36
|
+
}
|
|
37
|
+
/** Options for submitting a prompt from the chat panel. */
|
|
38
|
+
interface ForkSubmitOptions {
|
|
39
|
+
/** Follow-up on this fork (otherwise a new fork is composed). */
|
|
40
|
+
forkId?: string | null;
|
|
41
|
+
/** Force a new fork even when one exists for the target. */
|
|
42
|
+
forceNew?: boolean;
|
|
43
|
+
/** Screenshots pasted/uploaded into the composer. */
|
|
44
|
+
attachments?: ForkPromptAttachment[];
|
|
45
|
+
/** DOM element the user picked on the page for context. */
|
|
46
|
+
selectedElement?: SelectedElementContext | null;
|
|
47
|
+
}
|
|
4
48
|
interface Fork {
|
|
5
49
|
id: string;
|
|
6
50
|
userId: string;
|
|
@@ -63,7 +107,8 @@ interface ForkProviderBase {
|
|
|
63
107
|
shared?: ForkSharedRegistry;
|
|
64
108
|
}
|
|
65
109
|
/**
|
|
66
|
-
* User identity — provide EITHER userId (optionally with userHash
|
|
110
|
+
* User identity — provide EITHER userId (optionally with userHash or userJwt)
|
|
111
|
+
* OR authUrl:
|
|
67
112
|
*
|
|
68
113
|
* - `userId` alone: Client-asserted, no server verification (dev/testing only).
|
|
69
114
|
* - `userId` + `userHash`: Host-brokered verified identity. Your backend
|
|
@@ -71,12 +116,37 @@ interface ForkProviderBase {
|
|
|
71
116
|
* both as props. Fork never touches cookies or Web Storage for identity, so
|
|
72
117
|
* this is the required mode for embedded/iframe contexts where third-party
|
|
73
118
|
* cookies are blocked (e.g. app-store review environments).
|
|
74
|
-
* - `
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
119
|
+
* - `userJwt`: OPTIONAL and ADDITIVE — it carries custom user attributes, it
|
|
120
|
+
* does not replace the identity you already send. Your backend signs HS256
|
|
121
|
+
* with a key DERIVED from your sk_ — `HMAC-SHA256(sk_, "fork-user-jwt-v1")`,
|
|
122
|
+
* never sk_ itself, which would let your own auth endpoint be used as a
|
|
123
|
+
* signing oracle. Payload: `{ sub: userId, attrs: { role, vertical, ... } }`
|
|
124
|
+
* with `audience: "fork"` and an `expiresIn` (both required, max 7 days).
|
|
125
|
+
* Everything in `attrs` becomes a custom user attribute visible in Fork
|
|
126
|
+
* admin. Because the claim sits inside the signature, an end user cannot
|
|
127
|
+
* forge it from devtools — which is why attributes ride here and not in a
|
|
128
|
+
* plain prop. Keep sending `userId` + `userHash` alongside it.
|
|
129
|
+
* - `authUrl`: URL on your backend that returns `{ userId, userHash }`, plus
|
|
130
|
+
* `userJwt` if you want attributes. The SDK calls it on mount (same-origin,
|
|
131
|
+
* cookies sent automatically). Relies on the host's cookie session, so it
|
|
132
|
+
* does not work where the host page's cookies are third-party — prefer the
|
|
133
|
+
* prop modes there.
|
|
134
|
+
*
|
|
135
|
+
* `userHash` remains the universal credential and is NOT deprecated: it is what
|
|
136
|
+
* authenticates every request the SDK makes. `userJwt` is stamped on the
|
|
137
|
+
* provider's own calls, which is where attributes get recorded — one such call
|
|
138
|
+
* per mount is all it takes, since the server leaves stored attributes untouched
|
|
139
|
+
* on requests that carry no token.
|
|
140
|
+
*
|
|
141
|
+
* Adding attributes to an existing integration is therefore purely additive:
|
|
142
|
+
* return one more field from the endpoint you already have. Nothing you send
|
|
143
|
+
* today changes meaning, and rolling it back is deleting that field.
|
|
78
144
|
*
|
|
79
|
-
*
|
|
145
|
+
* Expiry is required and capped at 7 days; 24h is a reasonable choice. An
|
|
146
|
+
* expired token costs you attribute freshness, never access, because `userHash`
|
|
147
|
+
* is still carrying the identity.
|
|
148
|
+
*
|
|
149
|
+
* In any verified mode, if the user is also a Fork tenant operator (their
|
|
80
150
|
* email matches a fork_users row with a user_roles entry on this tenant), the
|
|
81
151
|
* SDK transparently enters admin mode and acts as their mapped end-user — set
|
|
82
152
|
* the mapping in Fork's Team Settings → End user.
|
|
@@ -84,11 +154,13 @@ interface ForkProviderBase {
|
|
|
84
154
|
type ForkProviderProps = ForkProviderBase & ({
|
|
85
155
|
userId: string;
|
|
86
156
|
userHash?: string;
|
|
157
|
+
userJwt?: string;
|
|
87
158
|
authUrl?: never;
|
|
88
159
|
} | {
|
|
89
160
|
authUrl: string;
|
|
90
161
|
userId?: never;
|
|
91
162
|
userHash?: never;
|
|
163
|
+
userJwt?: never;
|
|
92
164
|
});
|
|
93
165
|
interface ForkBoundaryRegistration {
|
|
94
166
|
id: string;
|
|
@@ -268,11 +340,8 @@ interface ForkPanelProps {
|
|
|
268
340
|
targetId?: string;
|
|
269
341
|
targetLabel?: string;
|
|
270
342
|
historyMode?: "slot" | "boundary" | "none";
|
|
271
|
-
onSubmit: (prompt: string, targetId: string, containerId?: string | null, opts?:
|
|
272
|
-
|
|
273
|
-
forceNew?: boolean;
|
|
274
|
-
}) => void;
|
|
275
|
-
onUndo?: (targetId: string) => Promise<any>;
|
|
343
|
+
onSubmit: (prompt: string, targetId: string, containerId?: string | null, opts?: ForkSubmitOptions) => void;
|
|
344
|
+
onUndo?: (targetId: string, forkId?: string | null) => Promise<any>;
|
|
276
345
|
onClose: () => void;
|
|
277
346
|
baseUrl?: string;
|
|
278
347
|
apiKey?: string;
|
|
@@ -302,10 +371,7 @@ declare function useFork(): {
|
|
|
302
371
|
runs: Record<string, ForkRun>;
|
|
303
372
|
open: () => void;
|
|
304
373
|
close: () => void;
|
|
305
|
-
startFork: (prompt: string, slotId?: string, containerId?: string | null, opts?:
|
|
306
|
-
forkId?: string | null;
|
|
307
|
-
forceNew?: boolean;
|
|
308
|
-
}) => Promise<void>;
|
|
374
|
+
startFork: (prompt: string, slotId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
309
375
|
undoFork: (slotId: string) => Promise<any>;
|
|
310
376
|
adoptRunningFork: (forkId: string) => Promise<void>;
|
|
311
377
|
};
|
|
@@ -318,11 +384,8 @@ declare function useBoundaryFork(boundaryId: string): {
|
|
|
318
384
|
runs: Record<string, ForkRun>;
|
|
319
385
|
open: () => void;
|
|
320
386
|
close: () => void;
|
|
321
|
-
startFork: (prompt: string, containerId?: string | null, opts?:
|
|
322
|
-
|
|
323
|
-
forceNew?: boolean;
|
|
324
|
-
}) => Promise<void>;
|
|
325
|
-
undoFork: () => Promise<any>;
|
|
387
|
+
startFork: (prompt: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
388
|
+
undoFork: (forkId?: string | null) => Promise<any>;
|
|
326
389
|
adoptRunningFork: (forkId: string) => Promise<void>;
|
|
327
390
|
};
|
|
328
391
|
|
|
@@ -332,22 +395,16 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
332
395
|
targetId: string;
|
|
333
396
|
targetLabel: string | undefined;
|
|
334
397
|
historyMode: "slot" | "boundary";
|
|
335
|
-
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
336
|
-
|
|
337
|
-
forceNew?: boolean;
|
|
338
|
-
}) => Promise<void>;
|
|
339
|
-
undo: (submittedTargetId?: string) => Promise<any>;
|
|
398
|
+
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
399
|
+
undo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
340
400
|
buttonProps: {
|
|
341
401
|
onClick: () => void;
|
|
342
402
|
hasNotification: boolean;
|
|
343
403
|
activity: ForkActivitySummary;
|
|
344
404
|
};
|
|
345
405
|
panelProps: {
|
|
346
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
347
|
-
|
|
348
|
-
forceNew?: boolean;
|
|
349
|
-
}) => Promise<void>;
|
|
350
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
406
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
407
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
351
408
|
onClose: (() => void) | (() => void);
|
|
352
409
|
baseUrl: string;
|
|
353
410
|
apiKey: string;
|
|
@@ -363,11 +420,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
363
420
|
error: string | null;
|
|
364
421
|
runs: Record<string, ForkRun>;
|
|
365
422
|
} | {
|
|
366
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
367
|
-
|
|
368
|
-
forceNew?: boolean;
|
|
369
|
-
}) => Promise<void>;
|
|
370
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
423
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
424
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
371
425
|
onClose: (() => void) | (() => void);
|
|
372
426
|
baseUrl: string;
|
|
373
427
|
apiKey: string;
|
|
@@ -397,22 +451,16 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
397
451
|
targetId: string;
|
|
398
452
|
targetLabel: string | undefined;
|
|
399
453
|
historyMode: "slot" | "boundary";
|
|
400
|
-
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
401
|
-
|
|
402
|
-
forceNew?: boolean;
|
|
403
|
-
}) => Promise<void>;
|
|
404
|
-
undo: (submittedTargetId?: string) => Promise<any>;
|
|
454
|
+
submit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
455
|
+
undo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
405
456
|
buttonProps: {
|
|
406
457
|
onClick: () => void;
|
|
407
458
|
hasNotification: boolean;
|
|
408
459
|
activity: ForkActivitySummary;
|
|
409
460
|
};
|
|
410
461
|
panelProps: {
|
|
411
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
412
|
-
|
|
413
|
-
forceNew?: boolean;
|
|
414
|
-
}) => Promise<void>;
|
|
415
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
462
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
463
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
416
464
|
onClose: (() => void) | (() => void);
|
|
417
465
|
baseUrl: string;
|
|
418
466
|
apiKey: string;
|
|
@@ -428,11 +476,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
|
|
|
428
476
|
error: string | null;
|
|
429
477
|
runs: Record<string, ForkRun>;
|
|
430
478
|
} | {
|
|
431
|
-
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?:
|
|
432
|
-
|
|
433
|
-
forceNew?: boolean;
|
|
434
|
-
}) => Promise<void>;
|
|
435
|
-
onUndo: (submittedTargetId?: string) => Promise<any>;
|
|
479
|
+
onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: ForkSubmitOptions) => Promise<void>;
|
|
480
|
+
onUndo: (submittedTargetId?: string, forkId?: string | null) => Promise<any>;
|
|
436
481
|
onClose: (() => void) | (() => void);
|
|
437
482
|
baseUrl: string;
|
|
438
483
|
apiKey: string;
|
|
@@ -791,6 +836,12 @@ interface LoadManifestInput {
|
|
|
791
836
|
userId: string;
|
|
792
837
|
/** Optional userHash for HMAC verification. */
|
|
793
838
|
userHash?: string;
|
|
839
|
+
/**
|
|
840
|
+
* Optional attribute-bearing token (see ForkProviderProps). Sent so the
|
|
841
|
+
* manifest fetch — which runs on every mount, for every user, not just
|
|
842
|
+
* operators — is what records the tenant's custom user attributes.
|
|
843
|
+
*/
|
|
844
|
+
userJwt?: string;
|
|
794
845
|
/** Authorized explicit container lookup, used for container-bound previews. */
|
|
795
846
|
containerId?: string;
|
|
796
847
|
/** Additional trusted headers, e.g. preview session headers. */
|
|
@@ -817,4 +868,4 @@ declare function clearCachedManifest(tenantId: string, appId: string, userId: st
|
|
|
817
868
|
*/
|
|
818
869
|
declare function manifestDiffers(a: Manifest | null, b: Manifest | null): boolean;
|
|
819
870
|
|
|
820
|
-
export { type AdminContainer, type AdminContext, type EnsureFeatureInput, type EnsureLlmJobsInput, type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkDataClient, type ForkDataClientConfig, type ForkDataSource, type ForkDataStatus, type ForkEntityRef, type ForkEvent, type ForkFeature, type ForkFeatureKind, type ForkFeatureOption, type ForkFeatureValue, type ForkLlmJob, type ForkLlmJobStatus, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type QueryLlmJobsInput, type QueryValuesInput, type SetOptionsInput, type SetValuesInput, type UseForkFeatureValuesInput, type UseForkLlmJobsInput, clearCachedManifest, createForkDataClient, forkEntityValueKey, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, useForkDataClient, useForkDataMutation, useForkFeatureValues, useForkLlmJobs, writeCachedManifest };
|
|
871
|
+
export { type AdminContainer, type AdminContext, type EnsureFeatureInput, type EnsureLlmJobsInput, type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkDataClient, type ForkDataClientConfig, type ForkDataSource, type ForkDataStatus, type ForkEntityRef, type ForkEvent, type ForkFeature, type ForkFeatureKind, type ForkFeatureOption, type ForkFeatureValue, type ForkLlmJob, type ForkLlmJobStatus, ForkPanel, type ForkPromptAttachment, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, type ForkSubmitOptions, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type QueryLlmJobsInput, type QueryValuesInput, type SelectedElementContext, type SetOptionsInput, type SetValuesInput, type UseForkFeatureValuesInput, type UseForkLlmJobsInput, clearCachedManifest, createForkDataClient, forkEntityValueKey, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, useForkDataClient, useForkDataMutation, useForkFeatureValues, useForkLlmJobs, writeCachedManifest };
|