@fork-api/chat-sdk 0.1.151 → 0.1.154

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.d.cts CHANGED
@@ -19,6 +19,32 @@ interface Fork {
19
19
  completedAt?: string;
20
20
  error?: string;
21
21
  }
22
+ type ForkActivityTargetKind = "slot" | "module";
23
+ interface ForkActivity {
24
+ id: string;
25
+ status: Fork["status"];
26
+ targetKind: ForkActivityTargetKind;
27
+ targetId: string;
28
+ summary?: string | null;
29
+ latestMessage?: string | null;
30
+ estimateMinutes?: number | null;
31
+ promptCount?: number;
32
+ messageCount?: number;
33
+ isActive?: boolean;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ completedAt?: string | null;
37
+ unread?: boolean;
38
+ }
39
+ interface ForkActivitySummary {
40
+ state: "idle" | "running" | "complete" | "error";
41
+ label: string;
42
+ detail?: string;
43
+ count: number;
44
+ runningCount: number;
45
+ unreadCompletedCount: number;
46
+ latest: ForkActivity | null;
47
+ }
22
48
  interface ForkEvent {
23
49
  type: "status" | "agent_message" | "tool_use" | "build_start" | "build_complete" | "build_error" | "complete" | "error";
24
50
  data: unknown;
@@ -39,11 +65,10 @@ interface ForkProviderBase {
39
65
  * The SDK calls this on mount (same-origin, cookies sent automatically).
40
66
  * Your backend computes: userHash = HMAC-SHA256(sk_fork_key, userId).
41
67
  * This provides verified per-user fork isolation.
42
- * To auto-enter admin mode for tenant operators, authUrl may also return
43
- * `{ forkUserId, forkOperatorExpiresAt, forkOperatorHash }`, where
44
- * forkOperatorExpiresAt is a unix-seconds timestamp no more than 10 minutes
45
- * in the future and forkOperatorHash is HMAC-SHA256(sk_fork_key,
46
- * `fork-operator:v1:${appId}:${userId}:${forkUserId}:${forkOperatorExpiresAt}`).
68
+ * If the verified user is also a Fork tenant operator (their email matches
69
+ * a fork_users row with a user_roles entry on this tenant), the SDK
70
+ * transparently enters admin mode and acts as their mapped end-user — set
71
+ * the mapping in Fork's Team Settings End user.
47
72
  */
48
73
  type ForkProviderProps = ForkProviderBase & ({
49
74
  userId: string;
@@ -100,6 +125,12 @@ type ForkChatInterfaceProps = ForkChatTargetInput & {
100
125
  * shell (e.g. Chrome's native side panel).
101
126
  */
102
127
  embedded?: boolean;
128
+ /**
129
+ * How the completed-fork summary renders. "bubble" (default) is the chat
130
+ * bubble layout; "item" is the shadcn-Item layout (icon tile + title +
131
+ * description + Undo action).
132
+ */
133
+ completeVariant?: "bubble" | "item";
103
134
  };
104
135
  interface ForkSlotProps {
105
136
  slotId: string;
@@ -205,8 +236,10 @@ interface ForkUIProps {
205
236
  }
206
237
  declare function ForkUI({ slotId, title, slotLabel }: ForkUIProps): react_jsx_runtime.JSX.Element;
207
238
 
208
- declare function ForkButton({ onClick }: {
239
+ declare function ForkButton({ onClick, hasNotification, activity, }: {
209
240
  onClick?: () => void;
241
+ hasNotification?: boolean;
242
+ activity?: ForkActivitySummary;
210
243
  }): react_jsx_runtime.JSX.Element;
211
244
 
212
245
  interface ForkPanelProps {
@@ -236,8 +269,13 @@ interface ForkPanelProps {
236
269
  * panel.
237
270
  */
238
271
  embedded?: boolean;
272
+ /**
273
+ * Rendering style for the "applied" summary in the complete state.
274
+ * "bubble" (default) is the chat bubble. "item" is a shadcn-Item layout.
275
+ */
276
+ completeVariant?: "bubble" | "item";
239
277
  }
240
- declare function ForkPanel({ state, fork, events, error, slotId, targetId, targetLabel, historyMode, onSubmit, onUndo, onClose, baseUrl, apiKey, userId, userHash, appId, embedded, }: ForkPanelProps): react_jsx_runtime.JSX.Element;
278
+ declare function ForkPanel({ state, fork, events, error, slotId, targetId, targetLabel, historyMode, onSubmit, onUndo, onClose, baseUrl, apiKey, userId, userHash, appId, embedded, completeVariant, }: ForkPanelProps): react_jsx_runtime.JSX.Element;
241
279
 
242
280
  declare function useFork(): {
243
281
  state: ForkState;
@@ -251,6 +289,7 @@ declare function useFork(): {
251
289
  forceNew?: boolean;
252
290
  }) => Promise<void>;
253
291
  undoFork: (slotId: string) => Promise<any>;
292
+ adoptRunningFork: (forkId: string) => Promise<void>;
254
293
  };
255
294
 
256
295
  declare function useBoundaryFork(boundaryId: string): {
@@ -265,9 +304,11 @@ declare function useBoundaryFork(boundaryId: string): {
265
304
  forceNew?: boolean;
266
305
  }) => Promise<void>;
267
306
  undoFork: () => Promise<any>;
307
+ adoptRunningFork: (forkId: string) => Promise<void>;
268
308
  };
269
309
 
270
310
  declare function useForkChatPanel(options: ForkChatPanelOptions): {
311
+ open: () => void;
271
312
  target: ForkChatTarget;
272
313
  targetId: string;
273
314
  targetLabel: string | undefined;
@@ -278,7 +319,9 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
278
319
  }) => Promise<void>;
279
320
  undo: (submittedTargetId?: string) => Promise<any>;
280
321
  buttonProps: {
281
- onClick: (() => void) | (() => void);
322
+ onClick: () => void;
323
+ hasNotification: boolean;
324
+ activity: ForkActivitySummary;
282
325
  };
283
326
  panelProps: {
284
327
  onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: {
@@ -324,9 +367,10 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
324
367
  events: ForkEvent[];
325
368
  error: string | null;
326
369
  isOpen: boolean;
327
- open: () => void;
328
370
  close: () => void;
371
+ adoptRunningFork: (forkId: string) => Promise<void>;
329
372
  } | {
373
+ open: () => void;
330
374
  target: ForkChatTarget;
331
375
  targetId: string;
332
376
  targetLabel: string | undefined;
@@ -337,7 +381,9 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
337
381
  }) => Promise<void>;
338
382
  undo: (submittedTargetId?: string) => Promise<any>;
339
383
  buttonProps: {
340
- onClick: (() => void) | (() => void);
384
+ onClick: () => void;
385
+ hasNotification: boolean;
386
+ activity: ForkActivitySummary;
341
387
  };
342
388
  panelProps: {
343
389
  onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: {
@@ -383,8 +429,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
383
429
  events: ForkEvent[];
384
430
  error: string | null;
385
431
  isOpen: boolean;
386
- open: () => void;
387
432
  close: () => void;
433
+ adoptRunningFork: (forkId: string) => Promise<void>;
388
434
  };
389
435
 
390
436
  /**
@@ -482,4 +528,4 @@ declare function clearCachedManifest(tenantId: string, appId: string, userId: st
482
528
  */
483
529
  declare function manifestDiffers(a: Manifest | null, b: Manifest | null): boolean;
484
530
 
485
- export { type Fork, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkEvent, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type PreviewSessionPayload, clearCachedManifest, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, usePreviewSession, writeCachedManifest };
531
+ export { type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkEvent, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type PreviewSessionPayload, clearCachedManifest, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, usePreviewSession, writeCachedManifest };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,32 @@ interface Fork {
19
19
  completedAt?: string;
20
20
  error?: string;
21
21
  }
22
+ type ForkActivityTargetKind = "slot" | "module";
23
+ interface ForkActivity {
24
+ id: string;
25
+ status: Fork["status"];
26
+ targetKind: ForkActivityTargetKind;
27
+ targetId: string;
28
+ summary?: string | null;
29
+ latestMessage?: string | null;
30
+ estimateMinutes?: number | null;
31
+ promptCount?: number;
32
+ messageCount?: number;
33
+ isActive?: boolean;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ completedAt?: string | null;
37
+ unread?: boolean;
38
+ }
39
+ interface ForkActivitySummary {
40
+ state: "idle" | "running" | "complete" | "error";
41
+ label: string;
42
+ detail?: string;
43
+ count: number;
44
+ runningCount: number;
45
+ unreadCompletedCount: number;
46
+ latest: ForkActivity | null;
47
+ }
22
48
  interface ForkEvent {
23
49
  type: "status" | "agent_message" | "tool_use" | "build_start" | "build_complete" | "build_error" | "complete" | "error";
24
50
  data: unknown;
@@ -39,11 +65,10 @@ interface ForkProviderBase {
39
65
  * The SDK calls this on mount (same-origin, cookies sent automatically).
40
66
  * Your backend computes: userHash = HMAC-SHA256(sk_fork_key, userId).
41
67
  * This provides verified per-user fork isolation.
42
- * To auto-enter admin mode for tenant operators, authUrl may also return
43
- * `{ forkUserId, forkOperatorExpiresAt, forkOperatorHash }`, where
44
- * forkOperatorExpiresAt is a unix-seconds timestamp no more than 10 minutes
45
- * in the future and forkOperatorHash is HMAC-SHA256(sk_fork_key,
46
- * `fork-operator:v1:${appId}:${userId}:${forkUserId}:${forkOperatorExpiresAt}`).
68
+ * If the verified user is also a Fork tenant operator (their email matches
69
+ * a fork_users row with a user_roles entry on this tenant), the SDK
70
+ * transparently enters admin mode and acts as their mapped end-user — set
71
+ * the mapping in Fork's Team Settings End user.
47
72
  */
48
73
  type ForkProviderProps = ForkProviderBase & ({
49
74
  userId: string;
@@ -100,6 +125,12 @@ type ForkChatInterfaceProps = ForkChatTargetInput & {
100
125
  * shell (e.g. Chrome's native side panel).
101
126
  */
102
127
  embedded?: boolean;
128
+ /**
129
+ * How the completed-fork summary renders. "bubble" (default) is the chat
130
+ * bubble layout; "item" is the shadcn-Item layout (icon tile + title +
131
+ * description + Undo action).
132
+ */
133
+ completeVariant?: "bubble" | "item";
103
134
  };
104
135
  interface ForkSlotProps {
105
136
  slotId: string;
@@ -205,8 +236,10 @@ interface ForkUIProps {
205
236
  }
206
237
  declare function ForkUI({ slotId, title, slotLabel }: ForkUIProps): react_jsx_runtime.JSX.Element;
207
238
 
208
- declare function ForkButton({ onClick }: {
239
+ declare function ForkButton({ onClick, hasNotification, activity, }: {
209
240
  onClick?: () => void;
241
+ hasNotification?: boolean;
242
+ activity?: ForkActivitySummary;
210
243
  }): react_jsx_runtime.JSX.Element;
211
244
 
212
245
  interface ForkPanelProps {
@@ -236,8 +269,13 @@ interface ForkPanelProps {
236
269
  * panel.
237
270
  */
238
271
  embedded?: boolean;
272
+ /**
273
+ * Rendering style for the "applied" summary in the complete state.
274
+ * "bubble" (default) is the chat bubble. "item" is a shadcn-Item layout.
275
+ */
276
+ completeVariant?: "bubble" | "item";
239
277
  }
240
- declare function ForkPanel({ state, fork, events, error, slotId, targetId, targetLabel, historyMode, onSubmit, onUndo, onClose, baseUrl, apiKey, userId, userHash, appId, embedded, }: ForkPanelProps): react_jsx_runtime.JSX.Element;
278
+ declare function ForkPanel({ state, fork, events, error, slotId, targetId, targetLabel, historyMode, onSubmit, onUndo, onClose, baseUrl, apiKey, userId, userHash, appId, embedded, completeVariant, }: ForkPanelProps): react_jsx_runtime.JSX.Element;
241
279
 
242
280
  declare function useFork(): {
243
281
  state: ForkState;
@@ -251,6 +289,7 @@ declare function useFork(): {
251
289
  forceNew?: boolean;
252
290
  }) => Promise<void>;
253
291
  undoFork: (slotId: string) => Promise<any>;
292
+ adoptRunningFork: (forkId: string) => Promise<void>;
254
293
  };
255
294
 
256
295
  declare function useBoundaryFork(boundaryId: string): {
@@ -265,9 +304,11 @@ declare function useBoundaryFork(boundaryId: string): {
265
304
  forceNew?: boolean;
266
305
  }) => Promise<void>;
267
306
  undoFork: () => Promise<any>;
307
+ adoptRunningFork: (forkId: string) => Promise<void>;
268
308
  };
269
309
 
270
310
  declare function useForkChatPanel(options: ForkChatPanelOptions): {
311
+ open: () => void;
271
312
  target: ForkChatTarget;
272
313
  targetId: string;
273
314
  targetLabel: string | undefined;
@@ -278,7 +319,9 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
278
319
  }) => Promise<void>;
279
320
  undo: (submittedTargetId?: string) => Promise<any>;
280
321
  buttonProps: {
281
- onClick: (() => void) | (() => void);
322
+ onClick: () => void;
323
+ hasNotification: boolean;
324
+ activity: ForkActivitySummary;
282
325
  };
283
326
  panelProps: {
284
327
  onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: {
@@ -324,9 +367,10 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
324
367
  events: ForkEvent[];
325
368
  error: string | null;
326
369
  isOpen: boolean;
327
- open: () => void;
328
370
  close: () => void;
371
+ adoptRunningFork: (forkId: string) => Promise<void>;
329
372
  } | {
373
+ open: () => void;
330
374
  target: ForkChatTarget;
331
375
  targetId: string;
332
376
  targetLabel: string | undefined;
@@ -337,7 +381,9 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
337
381
  }) => Promise<void>;
338
382
  undo: (submittedTargetId?: string) => Promise<any>;
339
383
  buttonProps: {
340
- onClick: (() => void) | (() => void);
384
+ onClick: () => void;
385
+ hasNotification: boolean;
386
+ activity: ForkActivitySummary;
341
387
  };
342
388
  panelProps: {
343
389
  onSubmit: (prompt: string, submittedTargetId?: string, containerId?: string | null, opts?: {
@@ -383,8 +429,8 @@ declare function useForkChatPanel(options: ForkChatPanelOptions): {
383
429
  events: ForkEvent[];
384
430
  error: string | null;
385
431
  isOpen: boolean;
386
- open: () => void;
387
432
  close: () => void;
433
+ adoptRunningFork: (forkId: string) => Promise<void>;
388
434
  };
389
435
 
390
436
  /**
@@ -482,4 +528,4 @@ declare function clearCachedManifest(tenantId: string, appId: string, userId: st
482
528
  */
483
529
  declare function manifestDiffers(a: Manifest | null, b: Manifest | null): boolean;
484
530
 
485
- export { type Fork, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkEvent, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type PreviewSessionPayload, clearCachedManifest, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, usePreviewSession, writeCachedManifest };
531
+ export { type Fork, type ForkActivity, type ForkActivitySummary, type ForkActivityTargetKind, type ForkBoundaryDefinition, ForkBoundaryUI, ForkButton, ForkChatInterface, type ForkChatInterfaceProps, type ForkChatPanelOptions, type ForkChatTarget, type ForkEvent, ForkPanel, ForkProvider, type ForkProviderProps, type ForkSharedRegistry, ForkSlot, type ForkSlotProps, type ForkState, ForkUI, type LoadManifestInput, type Manifest, type ManifestEntry, type ManifestModuleEntry, type PreviewSessionPayload, clearCachedManifest, forkable, loadManifest, manifestDiffers, readCachedManifest, registerForkShared, useBoundaryFork, useFork, useForkChatPanel, usePreviewSession, writeCachedManifest };