@perstack/react 0.0.53 → 0.0.55

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.
@@ -1,87 +1,85 @@
1
- import { PerstackEvent, ActivityOrGroup, ToolCall, ToolResult, Activity } from '@perstack/core';
1
+ import { Activity, ActivityOrGroup, PerstackEvent, ToolCall, ToolResult } from "@perstack/core";
2
2
 
3
+ //#region src/types/runtime-state.d.ts
3
4
  /** Per-run streaming state for real-time display */
4
5
  type PerRunStreamingState = {
5
- /** Expert key for this run */
6
- expertKey: string;
7
- /** Accumulated reasoning text during extended thinking */
8
- reasoning?: string;
9
- /** Accumulated run result text during generation */
10
- runResult?: string;
11
- /** Whether reasoning is currently streaming */
12
- isReasoningActive?: boolean;
13
- /** Whether run result is currently streaming */
14
- isRunResultActive?: boolean;
6
+ /** Expert key for this run */expertKey: string; /** Accumulated reasoning text during extended thinking */
7
+ reasoning?: string; /** Accumulated run result text during generation */
8
+ runResult?: string; /** Whether reasoning is currently streaming */
9
+ isReasoningActive?: boolean; /** Whether run result is currently streaming */
10
+ isRunResultActive?: boolean;
15
11
  };
16
12
  /** Streaming state organized by run ID to support parallel execution */
17
13
  type StreamingState = {
18
- /** Per-run streaming state, keyed by runId */
19
- runs: Record<string, PerRunStreamingState>;
14
+ /** Per-run streaming state, keyed by runId */runs: Record<string, PerRunStreamingState>;
20
15
  };
21
-
16
+ //#endregion
17
+ //#region src/utils/stream.d.ts
22
18
  type StreamConnector = (jobId: string, signal: AbortSignal) => Promise<AsyncIterable<PerstackEvent>>;
23
-
19
+ //#endregion
20
+ //#region src/hooks/use-job-stream.d.ts
24
21
  type JobStreamState = {
25
- activities: ActivityOrGroup[];
26
- streaming: StreamingState;
27
- latestActivity: ActivityOrGroup | null;
28
- isConnected: boolean;
29
- error: Error | null;
22
+ activities: ActivityOrGroup[];
23
+ streaming: StreamingState;
24
+ latestActivity: ActivityOrGroup | null;
25
+ isConnected: boolean;
26
+ error: Error | null;
30
27
  };
31
28
  declare function useJobStream(options: {
32
- jobId: string | null;
33
- connect: StreamConnector;
34
- enabled?: boolean;
29
+ jobId: string | null;
30
+ connect: StreamConnector;
31
+ enabled?: boolean;
35
32
  }): JobStreamState;
36
-
33
+ //#endregion
34
+ //#region src/hooks/use-job-streams.d.ts
37
35
  type JobStreamSummary = {
38
- latestActivity: ActivityOrGroup | null;
39
- isConnected: boolean;
36
+ latestActivity: ActivityOrGroup | null;
37
+ isConnected: boolean;
40
38
  };
41
39
  declare function useJobStreams(options: {
42
- jobs: Array<{
43
- id: string;
44
- enabled: boolean;
45
- }>;
46
- connect: StreamConnector;
40
+ jobs: Array<{
41
+ id: string;
42
+ enabled: boolean;
43
+ }>;
44
+ connect: StreamConnector;
47
45
  }): Map<string, JobStreamSummary>;
48
-
46
+ //#endregion
47
+ //#region src/utils/event-to-activity.d.ts
49
48
  /**
50
49
  * Converts a tool call and result to an Activity.
51
50
  * Delegates to core's createBaseToolActivity/createGeneralToolActivity to avoid duplication.
52
51
  */
53
52
  declare function toolToActivity(toolCall: ToolCall, toolResult: ToolResult, reasoning: string | undefined, meta: {
54
- id: string;
53
+ id: string;
54
+ expertKey: string;
55
+ runId: string;
56
+ previousActivityId?: string;
57
+ delegatedBy?: {
55
58
  expertKey: string;
56
59
  runId: string;
57
- previousActivityId?: string;
58
- delegatedBy?: {
59
- expertKey: string;
60
- runId: string;
61
- };
60
+ };
62
61
  }): Activity;
63
62
  type ToolState = {
64
- id: string;
65
- toolCall: ToolCall;
66
- logged: boolean;
63
+ id: string;
64
+ toolCall: ToolCall;
65
+ logged: boolean;
67
66
  };
68
67
  /**
69
68
  * Per-run state to support parallel execution.
70
69
  * Each run maintains its own independent state.
71
70
  */
72
71
  type RunState = {
72
+ expertKey: string;
73
+ queryLogged: boolean;
74
+ completionLogged: boolean;
75
+ isComplete: boolean;
76
+ completedReasoning?: string;
77
+ lastActivityId?: string;
78
+ delegatedBy?: {
73
79
  expertKey: string;
74
- queryLogged: boolean;
75
- completionLogged: boolean;
76
- isComplete: boolean;
77
- completedReasoning?: string;
78
- lastActivityId?: string;
79
- delegatedBy?: {
80
- expertKey: string;
81
- runId: string;
82
- };
83
- /** Track if this run has pending delegate tool calls (for delegation complete detection) */
84
- pendingDelegateCount: number;
80
+ runId: string;
81
+ }; /** Track if this run has pending delegate tool calls (for delegation complete detection) */
82
+ pendingDelegateCount: number;
85
83
  };
86
84
  /**
87
85
  * State for processing RunEvent stream into Activity[].
@@ -95,10 +93,8 @@ type RunState = {
95
93
  * that arrive after parent expert resumes with a new runId.
96
94
  */
97
95
  type ActivityProcessState = {
98
- /** Tool calls indexed by toolCallId - persisted across runs for delegation handling */
99
- tools: Map<string, ToolState>;
100
- /** Per-run state to support parallel execution */
101
- runStates: Map<string, RunState>;
96
+ /** Tool calls indexed by toolCallId - persisted across runs for delegation handling */tools: Map<string, ToolState>; /** Per-run state to support parallel execution */
97
+ runStates: Map<string, RunState>;
102
98
  };
103
99
  declare function createInitialActivityProcessState(): ActivityProcessState;
104
100
  /**
@@ -110,22 +106,16 @@ declare function createInitialActivityProcessState(): ActivityProcessState;
110
106
  * @param addActivity - Callback to add a new Activity or ParallelActivitiesGroup
111
107
  */
112
108
  declare function processRunEventToActivity(state: ActivityProcessState, event: PerstackEvent, addActivity: (activity: ActivityOrGroup) => void): void;
113
-
109
+ //#endregion
110
+ //#region src/hooks/use-run.d.ts
114
111
  type RunResult = {
115
- /** Accumulated activities from RunEvent (may include ParallelActivitiesGroup) */
116
- activities: ActivityOrGroup[];
117
- /** Current streaming state */
118
- streaming: StreamingState;
119
- /** Whether the run is complete */
120
- isComplete: boolean;
121
- /** Number of events processed */
122
- eventCount: number;
123
- /** Add a new event to be processed */
124
- addEvent: (event: PerstackEvent) => void;
125
- /** Append historical events (processes and appends to activities) */
126
- appendHistoricalEvents: (events: PerstackEvent[]) => void;
127
- /** Clear streaming state */
128
- clearStreaming: () => void;
112
+ /** Accumulated activities from RunEvent (may include ParallelActivitiesGroup) */activities: ActivityOrGroup[]; /** Current streaming state */
113
+ streaming: StreamingState; /** Whether the run is complete */
114
+ isComplete: boolean; /** Number of events processed */
115
+ eventCount: number; /** Add a new event to be processed */
116
+ addEvent: (event: PerstackEvent) => void; /** Append historical events (processes and appends to activities) */
117
+ appendHistoricalEvents: (events: PerstackEvent[]) => void; /** Clear streaming state */
118
+ clearStreaming: () => void;
129
119
  };
130
120
  /**
131
121
  * Hook for managing Run state from RunEvent stream.
@@ -138,18 +128,19 @@ type RunResult = {
138
128
  * This is required for compatibility with Ink's <Static> component.
139
129
  */
140
130
  declare function useRun(): RunResult;
141
-
131
+ //#endregion
132
+ //#region src/utils/group-by-run.d.ts
142
133
  /**
143
134
  * Represents a group of activities belonging to the same run
144
135
  */
145
136
  type RunGroup = {
146
- runId: string;
137
+ runId: string;
138
+ expertKey: string;
139
+ activities: ActivityOrGroup[];
140
+ delegatedBy?: {
147
141
  expertKey: string;
148
- activities: ActivityOrGroup[];
149
- delegatedBy?: {
150
- expertKey: string;
151
- runId: string;
152
- };
142
+ runId: string;
143
+ };
153
144
  };
154
145
  /**
155
146
  * Groups activities by their runId while preserving order.
@@ -161,5 +152,6 @@ type RunGroup = {
161
152
  * @returns Array of RunGroup objects, ordered by first appearance
162
153
  */
163
154
  declare function groupActivitiesByRun(activities: ActivityOrGroup[]): RunGroup[];
164
-
165
- export { type ActivityProcessState, type JobStreamState, type JobStreamSummary, type PerRunStreamingState, type RunGroup, type RunResult, type StreamConnector, type StreamingState, type ActivityProcessState as UtilActivityProcessState, createInitialActivityProcessState, groupActivitiesByRun, processRunEventToActivity, toolToActivity, useJobStream, useJobStreams, useRun };
155
+ //#endregion
156
+ export { type ActivityProcessState, type ActivityProcessState as UtilActivityProcessState, type JobStreamState, type JobStreamSummary, type PerRunStreamingState, type RunGroup, type RunResult, type StreamConnector, type StreamingState, createInitialActivityProcessState, groupActivitiesByRun, processRunEventToActivity, toolToActivity, useJobStream, useJobStreams, useRun };
157
+ //# sourceMappingURL=index.d.ts.map