@paddockai/react 0.0.3 → 0.0.5
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/LICENSE +202 -0
- package/dist/index.cjs +499 -10
- package/dist/index.d.cts +186 -5
- package/dist/index.d.ts +186 -5
- package/dist/index.js +490 -7
- package/dist/ui.cjs +586 -0
- package/dist/ui.d.cts +187 -0
- package/dist/ui.d.ts +187 -0
- package/dist/ui.js +572 -0
- package/package.json +15 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { SessionState, Event } from '@paddockai/client';
|
|
3
|
-
export { ClientMessage, ConnectionState, SessionState } from '@paddockai/client';
|
|
2
|
+
import { SessionState, Event, TurnOrigin, TurnError, Usage, ToolCall, ToolResult, Harness, Author, Metadata, SessionStatus, ToolName, TokenMode, EventType } from '@paddockai/client';
|
|
3
|
+
export { Author, ClientMessage, ConnectionState, Event, EventType, SessionState, SessionStatus, TokenMode, ToolCall, ToolName, ToolResult } from '@paddockai/client';
|
|
4
4
|
|
|
5
5
|
type PaddockProviderProps = {
|
|
6
6
|
/** The base URL every useSession below uses unless its options name one. */
|
|
@@ -18,8 +18,189 @@ type UseSessionResult = SessionState & {
|
|
|
18
18
|
send(text: string): Promise<Event>;
|
|
19
19
|
stop(): Promise<Event>;
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* A session's live state, with send and stop. During server rendering, and while the
|
|
23
|
+
* token is empty, it is the empty state and makes no request. When the token changes,
|
|
24
|
+
* it keeps the previous token's state until the new connection has loaded.
|
|
25
|
+
*/
|
|
22
26
|
declare function useSession(sessionId: string, options: UseSessionOptions): UseSessionResult;
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
type Delivery = "waiting" | "processing" | "held" | "processed";
|
|
29
|
+
type UserMessage = {
|
|
30
|
+
kind: "user";
|
|
31
|
+
id: string;
|
|
32
|
+
seq: number;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
text: string;
|
|
35
|
+
author: Author | null;
|
|
36
|
+
metadata: Metadata;
|
|
37
|
+
delivery: Delivery;
|
|
38
|
+
};
|
|
39
|
+
type TurnStatus = "running" | "completed" | "stopped" | "failed" | "discarded" | (string & {});
|
|
40
|
+
type ToolStatus = "running" | "done" | "error" | "interrupted";
|
|
41
|
+
type TextPart = {
|
|
42
|
+
kind: "text";
|
|
43
|
+
id: string;
|
|
44
|
+
text: string;
|
|
45
|
+
streaming: boolean;
|
|
46
|
+
};
|
|
47
|
+
type ReasoningPart = {
|
|
48
|
+
kind: "reasoning";
|
|
49
|
+
id: string;
|
|
50
|
+
text: string;
|
|
51
|
+
};
|
|
52
|
+
type ToolPart = {
|
|
53
|
+
kind: "tool";
|
|
54
|
+
id: string;
|
|
55
|
+
callId: string;
|
|
56
|
+
call: ToolCall | null;
|
|
57
|
+
result: ToolResult | null;
|
|
58
|
+
status: ToolStatus;
|
|
59
|
+
children: Part[];
|
|
60
|
+
};
|
|
61
|
+
type UnknownPart = {
|
|
62
|
+
kind: "unknown";
|
|
63
|
+
id: string;
|
|
64
|
+
harness: Harness | null;
|
|
65
|
+
type: string;
|
|
66
|
+
raw: unknown;
|
|
67
|
+
};
|
|
68
|
+
type Part = TextPart | ReasoningPart | ToolPart | UnknownPart;
|
|
69
|
+
type AgentTurn = {
|
|
70
|
+
kind: "turn";
|
|
71
|
+
id: string;
|
|
72
|
+
origin: TurnOrigin;
|
|
73
|
+
attempt: number;
|
|
74
|
+
status: TurnStatus;
|
|
75
|
+
error: TurnError | null;
|
|
76
|
+
retryAt: string | null;
|
|
77
|
+
gaveUp: boolean;
|
|
78
|
+
startedAt: string;
|
|
79
|
+
endedAt: string | null;
|
|
80
|
+
usage: Usage | null;
|
|
81
|
+
parts: Part[];
|
|
82
|
+
};
|
|
83
|
+
type Notice = {
|
|
84
|
+
kind: "notice";
|
|
85
|
+
id: string;
|
|
86
|
+
event: Event;
|
|
87
|
+
};
|
|
88
|
+
type ConversationItem = UserMessage | AgentTurn | Notice;
|
|
89
|
+
|
|
90
|
+
type SessionStatusInfo = {
|
|
91
|
+
status: SessionStatus;
|
|
92
|
+
connected: boolean;
|
|
93
|
+
canSend: boolean;
|
|
94
|
+
canStop: boolean;
|
|
95
|
+
readOnly: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type DiffChange = {
|
|
99
|
+
path: string;
|
|
100
|
+
change: "add" | "delete" | "update";
|
|
101
|
+
unified: string | null;
|
|
102
|
+
before: string | null;
|
|
103
|
+
after: string | null;
|
|
104
|
+
};
|
|
105
|
+
type ToolSummary = {
|
|
106
|
+
kind: ToolName;
|
|
107
|
+
title: string;
|
|
108
|
+
status: ToolStatus;
|
|
109
|
+
shell?: {
|
|
110
|
+
command: string;
|
|
111
|
+
output: string | null;
|
|
112
|
+
exitCode: number | null;
|
|
113
|
+
};
|
|
114
|
+
diff?: DiffChange[];
|
|
115
|
+
mcp?: {
|
|
116
|
+
server: string;
|
|
117
|
+
tool: string;
|
|
118
|
+
arguments: unknown;
|
|
119
|
+
content: unknown[] | null;
|
|
120
|
+
};
|
|
121
|
+
text?: string | null;
|
|
122
|
+
call: ToolCall | null;
|
|
123
|
+
result: ToolResult | null;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
type UseConversationOptions = {
|
|
127
|
+
/** Event types to show as notice items, such as "stop.requested"; none by default. */
|
|
128
|
+
notices?: readonly EventType[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The session as a person reads it: user messages and agent turns in seq order, with
|
|
132
|
+
* tool calls paired with their results and subagent work nested under its call. An
|
|
133
|
+
* item that did not change keeps its object.
|
|
134
|
+
*/
|
|
135
|
+
declare function useConversation(session: UseSessionResult, options?: UseConversationOptions): ConversationItem[];
|
|
136
|
+
type UseSessionStatusOptions = {
|
|
137
|
+
/** The token's mode, as useSessionToken returns it; read_only makes the session read-only. */
|
|
138
|
+
mode?: TokenMode | null;
|
|
139
|
+
};
|
|
140
|
+
/** The session's status and connection, and whether a send or a stop is possible now. */
|
|
141
|
+
declare function useSessionStatus(session: UseSessionResult, options?: UseSessionStatusOptions): SessionStatusInfo;
|
|
142
|
+
/** A summary of one tool part: its title, and its command, diff, MCP call, or text. */
|
|
143
|
+
declare function useToolCall(part: ToolPart): ToolSummary;
|
|
144
|
+
type UseComposerOptions = {
|
|
145
|
+
mode?: TokenMode | null;
|
|
146
|
+
/** Called with the error of a failed send or stop. */
|
|
147
|
+
onError?: (error: Error) => void;
|
|
148
|
+
};
|
|
149
|
+
/** Props for a text area: Enter submits, Shift+Enter adds a line, and nothing submits while composing. */
|
|
150
|
+
type ComposerInputProps = {
|
|
151
|
+
value: string;
|
|
152
|
+
onChange(event: {
|
|
153
|
+
target: {
|
|
154
|
+
value: string;
|
|
155
|
+
};
|
|
156
|
+
}): void;
|
|
157
|
+
onKeyDown(event: {
|
|
158
|
+
key: string;
|
|
159
|
+
shiftKey: boolean;
|
|
160
|
+
keyCode?: number;
|
|
161
|
+
nativeEvent?: {
|
|
162
|
+
isComposing?: boolean;
|
|
163
|
+
};
|
|
164
|
+
preventDefault(): void;
|
|
165
|
+
}): void;
|
|
166
|
+
};
|
|
167
|
+
type UseComposerResult = {
|
|
168
|
+
value: string;
|
|
169
|
+
setValue(value: string): void;
|
|
170
|
+
/** Sends the trimmed value; it is cleared once stored and kept with error set when the send fails. */
|
|
171
|
+
submit(): Promise<void>;
|
|
172
|
+
stop(): Promise<void>;
|
|
173
|
+
pending: boolean;
|
|
174
|
+
error: Error | null;
|
|
175
|
+
canSend: boolean;
|
|
176
|
+
canStop: boolean;
|
|
177
|
+
inputProps: ComposerInputProps;
|
|
178
|
+
};
|
|
179
|
+
/** The state and actions of a message box over one session. */
|
|
180
|
+
declare function useComposer(session: UseSessionResult, options?: UseComposerOptions): UseComposerResult;
|
|
181
|
+
|
|
182
|
+
/** What session.createToken answers, as the application's backend passes it on. */
|
|
183
|
+
type FetchedToken = {
|
|
184
|
+
token: string;
|
|
185
|
+
expiresAt: string;
|
|
186
|
+
mode: TokenMode;
|
|
187
|
+
};
|
|
188
|
+
type UseSessionTokenResult = {
|
|
189
|
+
/** The current token; null until the first arrives and after it expires. */
|
|
190
|
+
token: string | null;
|
|
191
|
+
expiresAt: string | null;
|
|
192
|
+
mode: TokenMode | null;
|
|
193
|
+
/** The last fetch's error; cleared by the next success. */
|
|
194
|
+
error: Error | null;
|
|
195
|
+
/** Fetches a new token at once. */
|
|
196
|
+
refresh(): void;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Keeps a session token fresh through the application's backend: fetchToken is called
|
|
200
|
+
* on mount, again when a fifth of the token's lifetime is left (at most five minutes
|
|
201
|
+
* before it expires), every 15 seconds after a failure, and on refresh().
|
|
202
|
+
*/
|
|
203
|
+
declare function useSessionToken(fetchToken: () => Promise<FetchedToken>): UseSessionTokenResult;
|
|
204
|
+
|
|
205
|
+
export { PaddockProvider, useComposer, useConversation, useSession, useSessionStatus, useSessionToken, useToolCall };
|
|
206
|
+
export type { AgentTurn, ComposerInputProps, ConversationItem, Delivery, DiffChange, FetchedToken, Notice, PaddockProviderProps, Part, ReasoningPart, SessionStatusInfo, TextPart, ToolPart, ToolStatus, ToolSummary, TurnStatus, UnknownPart, UseComposerOptions, UseComposerResult, UseConversationOptions, UseSessionOptions, UseSessionResult, UseSessionStatusOptions, UseSessionTokenResult, UserMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { SessionState, Event } from '@paddockai/client';
|
|
3
|
-
export { ClientMessage, ConnectionState, SessionState } from '@paddockai/client';
|
|
2
|
+
import { SessionState, Event, TurnOrigin, TurnError, Usage, ToolCall, ToolResult, Harness, Author, Metadata, SessionStatus, ToolName, TokenMode, EventType } from '@paddockai/client';
|
|
3
|
+
export { Author, ClientMessage, ConnectionState, Event, EventType, SessionState, SessionStatus, TokenMode, ToolCall, ToolName, ToolResult } from '@paddockai/client';
|
|
4
4
|
|
|
5
5
|
type PaddockProviderProps = {
|
|
6
6
|
/** The base URL every useSession below uses unless its options name one. */
|
|
@@ -18,8 +18,189 @@ type UseSessionResult = SessionState & {
|
|
|
18
18
|
send(text: string): Promise<Event>;
|
|
19
19
|
stop(): Promise<Event>;
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* A session's live state, with send and stop. During server rendering, and while the
|
|
23
|
+
* token is empty, it is the empty state and makes no request. When the token changes,
|
|
24
|
+
* it keeps the previous token's state until the new connection has loaded.
|
|
25
|
+
*/
|
|
22
26
|
declare function useSession(sessionId: string, options: UseSessionOptions): UseSessionResult;
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
type Delivery = "waiting" | "processing" | "held" | "processed";
|
|
29
|
+
type UserMessage = {
|
|
30
|
+
kind: "user";
|
|
31
|
+
id: string;
|
|
32
|
+
seq: number;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
text: string;
|
|
35
|
+
author: Author | null;
|
|
36
|
+
metadata: Metadata;
|
|
37
|
+
delivery: Delivery;
|
|
38
|
+
};
|
|
39
|
+
type TurnStatus = "running" | "completed" | "stopped" | "failed" | "discarded" | (string & {});
|
|
40
|
+
type ToolStatus = "running" | "done" | "error" | "interrupted";
|
|
41
|
+
type TextPart = {
|
|
42
|
+
kind: "text";
|
|
43
|
+
id: string;
|
|
44
|
+
text: string;
|
|
45
|
+
streaming: boolean;
|
|
46
|
+
};
|
|
47
|
+
type ReasoningPart = {
|
|
48
|
+
kind: "reasoning";
|
|
49
|
+
id: string;
|
|
50
|
+
text: string;
|
|
51
|
+
};
|
|
52
|
+
type ToolPart = {
|
|
53
|
+
kind: "tool";
|
|
54
|
+
id: string;
|
|
55
|
+
callId: string;
|
|
56
|
+
call: ToolCall | null;
|
|
57
|
+
result: ToolResult | null;
|
|
58
|
+
status: ToolStatus;
|
|
59
|
+
children: Part[];
|
|
60
|
+
};
|
|
61
|
+
type UnknownPart = {
|
|
62
|
+
kind: "unknown";
|
|
63
|
+
id: string;
|
|
64
|
+
harness: Harness | null;
|
|
65
|
+
type: string;
|
|
66
|
+
raw: unknown;
|
|
67
|
+
};
|
|
68
|
+
type Part = TextPart | ReasoningPart | ToolPart | UnknownPart;
|
|
69
|
+
type AgentTurn = {
|
|
70
|
+
kind: "turn";
|
|
71
|
+
id: string;
|
|
72
|
+
origin: TurnOrigin;
|
|
73
|
+
attempt: number;
|
|
74
|
+
status: TurnStatus;
|
|
75
|
+
error: TurnError | null;
|
|
76
|
+
retryAt: string | null;
|
|
77
|
+
gaveUp: boolean;
|
|
78
|
+
startedAt: string;
|
|
79
|
+
endedAt: string | null;
|
|
80
|
+
usage: Usage | null;
|
|
81
|
+
parts: Part[];
|
|
82
|
+
};
|
|
83
|
+
type Notice = {
|
|
84
|
+
kind: "notice";
|
|
85
|
+
id: string;
|
|
86
|
+
event: Event;
|
|
87
|
+
};
|
|
88
|
+
type ConversationItem = UserMessage | AgentTurn | Notice;
|
|
89
|
+
|
|
90
|
+
type SessionStatusInfo = {
|
|
91
|
+
status: SessionStatus;
|
|
92
|
+
connected: boolean;
|
|
93
|
+
canSend: boolean;
|
|
94
|
+
canStop: boolean;
|
|
95
|
+
readOnly: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type DiffChange = {
|
|
99
|
+
path: string;
|
|
100
|
+
change: "add" | "delete" | "update";
|
|
101
|
+
unified: string | null;
|
|
102
|
+
before: string | null;
|
|
103
|
+
after: string | null;
|
|
104
|
+
};
|
|
105
|
+
type ToolSummary = {
|
|
106
|
+
kind: ToolName;
|
|
107
|
+
title: string;
|
|
108
|
+
status: ToolStatus;
|
|
109
|
+
shell?: {
|
|
110
|
+
command: string;
|
|
111
|
+
output: string | null;
|
|
112
|
+
exitCode: number | null;
|
|
113
|
+
};
|
|
114
|
+
diff?: DiffChange[];
|
|
115
|
+
mcp?: {
|
|
116
|
+
server: string;
|
|
117
|
+
tool: string;
|
|
118
|
+
arguments: unknown;
|
|
119
|
+
content: unknown[] | null;
|
|
120
|
+
};
|
|
121
|
+
text?: string | null;
|
|
122
|
+
call: ToolCall | null;
|
|
123
|
+
result: ToolResult | null;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
type UseConversationOptions = {
|
|
127
|
+
/** Event types to show as notice items, such as "stop.requested"; none by default. */
|
|
128
|
+
notices?: readonly EventType[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The session as a person reads it: user messages and agent turns in seq order, with
|
|
132
|
+
* tool calls paired with their results and subagent work nested under its call. An
|
|
133
|
+
* item that did not change keeps its object.
|
|
134
|
+
*/
|
|
135
|
+
declare function useConversation(session: UseSessionResult, options?: UseConversationOptions): ConversationItem[];
|
|
136
|
+
type UseSessionStatusOptions = {
|
|
137
|
+
/** The token's mode, as useSessionToken returns it; read_only makes the session read-only. */
|
|
138
|
+
mode?: TokenMode | null;
|
|
139
|
+
};
|
|
140
|
+
/** The session's status and connection, and whether a send or a stop is possible now. */
|
|
141
|
+
declare function useSessionStatus(session: UseSessionResult, options?: UseSessionStatusOptions): SessionStatusInfo;
|
|
142
|
+
/** A summary of one tool part: its title, and its command, diff, MCP call, or text. */
|
|
143
|
+
declare function useToolCall(part: ToolPart): ToolSummary;
|
|
144
|
+
type UseComposerOptions = {
|
|
145
|
+
mode?: TokenMode | null;
|
|
146
|
+
/** Called with the error of a failed send or stop. */
|
|
147
|
+
onError?: (error: Error) => void;
|
|
148
|
+
};
|
|
149
|
+
/** Props for a text area: Enter submits, Shift+Enter adds a line, and nothing submits while composing. */
|
|
150
|
+
type ComposerInputProps = {
|
|
151
|
+
value: string;
|
|
152
|
+
onChange(event: {
|
|
153
|
+
target: {
|
|
154
|
+
value: string;
|
|
155
|
+
};
|
|
156
|
+
}): void;
|
|
157
|
+
onKeyDown(event: {
|
|
158
|
+
key: string;
|
|
159
|
+
shiftKey: boolean;
|
|
160
|
+
keyCode?: number;
|
|
161
|
+
nativeEvent?: {
|
|
162
|
+
isComposing?: boolean;
|
|
163
|
+
};
|
|
164
|
+
preventDefault(): void;
|
|
165
|
+
}): void;
|
|
166
|
+
};
|
|
167
|
+
type UseComposerResult = {
|
|
168
|
+
value: string;
|
|
169
|
+
setValue(value: string): void;
|
|
170
|
+
/** Sends the trimmed value; it is cleared once stored and kept with error set when the send fails. */
|
|
171
|
+
submit(): Promise<void>;
|
|
172
|
+
stop(): Promise<void>;
|
|
173
|
+
pending: boolean;
|
|
174
|
+
error: Error | null;
|
|
175
|
+
canSend: boolean;
|
|
176
|
+
canStop: boolean;
|
|
177
|
+
inputProps: ComposerInputProps;
|
|
178
|
+
};
|
|
179
|
+
/** The state and actions of a message box over one session. */
|
|
180
|
+
declare function useComposer(session: UseSessionResult, options?: UseComposerOptions): UseComposerResult;
|
|
181
|
+
|
|
182
|
+
/** What session.createToken answers, as the application's backend passes it on. */
|
|
183
|
+
type FetchedToken = {
|
|
184
|
+
token: string;
|
|
185
|
+
expiresAt: string;
|
|
186
|
+
mode: TokenMode;
|
|
187
|
+
};
|
|
188
|
+
type UseSessionTokenResult = {
|
|
189
|
+
/** The current token; null until the first arrives and after it expires. */
|
|
190
|
+
token: string | null;
|
|
191
|
+
expiresAt: string | null;
|
|
192
|
+
mode: TokenMode | null;
|
|
193
|
+
/** The last fetch's error; cleared by the next success. */
|
|
194
|
+
error: Error | null;
|
|
195
|
+
/** Fetches a new token at once. */
|
|
196
|
+
refresh(): void;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Keeps a session token fresh through the application's backend: fetchToken is called
|
|
200
|
+
* on mount, again when a fifth of the token's lifetime is left (at most five minutes
|
|
201
|
+
* before it expires), every 15 seconds after a failure, and on refresh().
|
|
202
|
+
*/
|
|
203
|
+
declare function useSessionToken(fetchToken: () => Promise<FetchedToken>): UseSessionTokenResult;
|
|
204
|
+
|
|
205
|
+
export { PaddockProvider, useComposer, useConversation, useSession, useSessionStatus, useSessionToken, useToolCall };
|
|
206
|
+
export type { AgentTurn, ComposerInputProps, ConversationItem, Delivery, DiffChange, FetchedToken, Notice, PaddockProviderProps, Part, ReasoningPart, SessionStatusInfo, TextPart, ToolPart, ToolStatus, ToolSummary, TurnStatus, UnknownPart, UseComposerOptions, UseComposerResult, UseConversationOptions, UseSessionOptions, UseSessionResult, UseSessionStatusOptions, UseSessionTokenResult, UserMessage };
|