@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.
- package/dist/src/index.d.ts +72 -80
- package/dist/src/index.js +629 -645
- package/dist/src/index.js.map +1 -1
- package/package.json +4 -4
package/dist/src/index.d.ts
CHANGED
|
@@ -1,87 +1,85 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
36
|
+
latestActivity: ActivityOrGroup | null;
|
|
37
|
+
isConnected: boolean;
|
|
40
38
|
};
|
|
41
39
|
declare function useJobStreams(options: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
53
|
+
id: string;
|
|
54
|
+
expertKey: string;
|
|
55
|
+
runId: string;
|
|
56
|
+
previousActivityId?: string;
|
|
57
|
+
delegatedBy?: {
|
|
55
58
|
expertKey: string;
|
|
56
59
|
runId: string;
|
|
57
|
-
|
|
58
|
-
delegatedBy?: {
|
|
59
|
-
expertKey: string;
|
|
60
|
-
runId: string;
|
|
61
|
-
};
|
|
60
|
+
};
|
|
62
61
|
}): Activity;
|
|
63
62
|
type ToolState = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
99
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
137
|
+
runId: string;
|
|
138
|
+
expertKey: string;
|
|
139
|
+
activities: ActivityOrGroup[];
|
|
140
|
+
delegatedBy?: {
|
|
147
141
|
expertKey: string;
|
|
148
|
-
|
|
149
|
-
|
|
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,
|
|
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
|