@hachej/boring-ask-user 0.1.53 → 0.1.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/README.md +6 -1
- package/dist/front/index.js +401 -74
- package/dist/server/index.d.ts +42 -16
- package/dist/server/index.js +443 -97
- package/dist/shared/index.d.ts +304 -252
- package/dist/shared/index.js +18 -0
- package/dist/{types-CF72YmK-.d.ts → types-4g8PL2Y_.d.ts} +3 -1
- package/package.json +4 -4
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UiBridge, WorkspaceServerPlugin } from '@hachej/boring-workspace/server';
|
|
2
|
-
import { A as AskUserQuestion, a as AskUserAnswer, b as AskUserTranscriptEvent, c as AskUserToolResult, d as AskUserCancelReason, e as AskUserRequest, Q as QuestionsCommand, f as AskUserField, g as AskUserAnswerValue } from '../types-
|
|
3
|
-
export { h as ASK_USER_PLUGIN_ID } from '../types-
|
|
1
|
+
import { UiBridge, WorkspaceServerPlugin, WorkspaceBridgeHandlerContribution } from '@hachej/boring-workspace/server';
|
|
2
|
+
import { A as AskUserQuestion, a as AskUserAnswer, b as AskUserTranscriptEvent, c as AskUserToolResult, d as AskUserCancelReason, e as AskUserRequest, Q as QuestionsCommand, f as AskUserField, g as AskUserAnswerValue } from '../types-4g8PL2Y_.js';
|
|
3
|
+
export { h as ASK_USER_PLUGIN_ID } from '../types-4g8PL2Y_.js';
|
|
4
4
|
import { FastifyRequest, FastifyInstance } from 'fastify';
|
|
5
5
|
|
|
6
6
|
declare class AskUserStoreError extends Error {
|
|
@@ -15,6 +15,7 @@ type AskUserStoreChange = {
|
|
|
15
15
|
type AskUserStoreListener = (change: AskUserStoreChange) => void;
|
|
16
16
|
interface AskUserStore {
|
|
17
17
|
getPending(sessionId: string): Promise<AskUserQuestion | null>;
|
|
18
|
+
listPending(): Promise<AskUserQuestion[]>;
|
|
18
19
|
getByQuestionId(questionId: string): Promise<AskUserQuestion | null>;
|
|
19
20
|
createPending(question: AskUserQuestion): Promise<void>;
|
|
20
21
|
answer(questionId: string, answer: AskUserAnswer): Promise<void>;
|
|
@@ -29,10 +30,12 @@ interface AskUserStore {
|
|
|
29
30
|
declare class FileAskUserStore implements AskUserStore {
|
|
30
31
|
private readonly filePath;
|
|
31
32
|
private state;
|
|
33
|
+
private loadInFlight;
|
|
32
34
|
private writeChain;
|
|
33
35
|
private readonly listeners;
|
|
34
36
|
constructor(filePath: string);
|
|
35
37
|
getPending(sessionId: string): Promise<AskUserQuestion | null>;
|
|
38
|
+
listPending(): Promise<AskUserQuestion[]>;
|
|
36
39
|
getByQuestionId(questionId: string): Promise<AskUserQuestion | null>;
|
|
37
40
|
createPending(question: AskUserQuestion): Promise<void>;
|
|
38
41
|
answer(questionId: string, answer: AskUserAnswer): Promise<void>;
|
|
@@ -93,9 +96,9 @@ declare class AskUserRuntime {
|
|
|
93
96
|
ask(request: AskUserRequest, signal?: AbortSignal): Promise<AskUserToolResult>;
|
|
94
97
|
submitAnswer(questionId: string, sessionId: string, values: AskUserAnswer["values"]): Promise<"answered" | "abandoned">;
|
|
95
98
|
cancelQuestion(questionId: string, sessionId: string, reason?: AskUserCancelReason): Promise<void>;
|
|
96
|
-
private waitForAnswerWithOpen;
|
|
97
99
|
private openQuestionSurface;
|
|
98
100
|
private waitForAnswer;
|
|
101
|
+
private resolveCancelledUnlessAnswered;
|
|
99
102
|
private abandon;
|
|
100
103
|
private createQuestion;
|
|
101
104
|
private assertAllowed;
|
|
@@ -104,6 +107,16 @@ declare class AskUserRuntime {
|
|
|
104
107
|
}
|
|
105
108
|
declare function requireAskUserRuntime(runtime: AskUserRuntime | null | undefined): AskUserRuntime;
|
|
106
109
|
|
|
110
|
+
type AskUserServerPluginOptions = {
|
|
111
|
+
workspaceRoot?: string;
|
|
112
|
+
bridge?: UiBridge;
|
|
113
|
+
runtime?: AskUserRuntime;
|
|
114
|
+
store?: AskUserStore;
|
|
115
|
+
sessionId?: string | (() => string);
|
|
116
|
+
onClose?: () => void;
|
|
117
|
+
};
|
|
118
|
+
declare function createAskUserServerPlugin(options: AskUserServerPluginOptions): WorkspaceServerPlugin;
|
|
119
|
+
|
|
107
120
|
declare class QuestionsBridgeError extends Error {
|
|
108
121
|
readonly code: string;
|
|
109
122
|
readonly statusCode: number;
|
|
@@ -143,16 +156,11 @@ type QuestionsRoutesOptions = {
|
|
|
143
156
|
};
|
|
144
157
|
declare function questionsRoutes(app: FastifyInstance, opts: QuestionsRoutesOptions, done: (err?: Error) => void): void;
|
|
145
158
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
sessionId?: string | (() => string);
|
|
152
|
-
routes?: Omit<QuestionsRoutesOptions, "runtime" | "store">;
|
|
153
|
-
onClose?: () => void;
|
|
154
|
-
};
|
|
155
|
-
declare function createAskUserServerPlugin(options: AskUserServerPluginOptions): WorkspaceServerPlugin;
|
|
159
|
+
interface AskUserBridgeHandlersOptions {
|
|
160
|
+
runtime: AskUserRuntime;
|
|
161
|
+
store: AskUserStore;
|
|
162
|
+
}
|
|
163
|
+
declare function createAskUserBridgeHandlers(options: AskUserBridgeHandlersOptions): WorkspaceBridgeHandlerContribution[];
|
|
156
164
|
|
|
157
165
|
type AskUserToolResultPayload = {
|
|
158
166
|
content: Array<{
|
|
@@ -176,17 +184,35 @@ type AskUserToolOptions = {
|
|
|
176
184
|
};
|
|
177
185
|
declare function createAskUserTool(options: AskUserToolOptions): AskUserToolDefinition;
|
|
178
186
|
|
|
187
|
+
type AskUserPendingHint = {
|
|
188
|
+
questionId: string;
|
|
189
|
+
sessionId: string;
|
|
190
|
+
status: AskUserQuestion["status"];
|
|
191
|
+
};
|
|
179
192
|
type AskUserPendingState = {
|
|
180
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Compatibility/current hint for older frontends.
|
|
195
|
+
* Non-authoritative in multi-session state; new readers must use hintsBySession.
|
|
196
|
+
*/
|
|
197
|
+
hint: AskUserPendingHint | null;
|
|
198
|
+
/** Session-indexed hints so background sessions can show a badge without exposing answer tokens. */
|
|
199
|
+
hintsBySession: Record<string, AskUserPendingHint>;
|
|
181
200
|
};
|
|
182
201
|
declare class AskUserStatePublisher {
|
|
183
202
|
private readonly store;
|
|
184
203
|
private readonly bridge;
|
|
185
204
|
private unsubscribe?;
|
|
205
|
+
private publishChain;
|
|
206
|
+
private readonly hintsBySession;
|
|
186
207
|
constructor(store: AskUserStore, bridge: UiBridge);
|
|
187
208
|
start(): () => void;
|
|
188
209
|
stop(): void;
|
|
189
210
|
publishSession(sessionId: string): Promise<void>;
|
|
211
|
+
private currentPendingState;
|
|
212
|
+
private enqueuePublishSession;
|
|
213
|
+
private enqueueInitializeFromStore;
|
|
214
|
+
private enqueuePublish;
|
|
215
|
+
private initializeFromStore;
|
|
190
216
|
}
|
|
191
217
|
|
|
192
218
|
/**
|
|
@@ -202,4 +228,4 @@ declare function defaultAskUserServerPlugin(options: Partial<AskUserServerPlugin
|
|
|
202
228
|
bridge: AskUserServerPluginOptions["bridge"];
|
|
203
229
|
}): WorkspaceServerPlugin;
|
|
204
230
|
|
|
205
|
-
export { type AskUserCoordinator, type AskUserPendingState, AskUserRuntime, AskUserRuntimeError, type AskUserRuntimeOptions, type AskUserServerPluginOptions, AskUserStatePublisher, type AskUserStore, type AskUserStoreChange, AskUserStoreError, type AskUserStoreListener, type AskUserToolDefinition, type AskUserToolOptions, type AskUserToolResultPayload, FileAskUserStore, InProcessAskUserCoordinator, type QuestionsAuthContext, QuestionsBridge, QuestionsBridgeError, type QuestionsBridgeOptions, type QuestionsRoutesOptions, constantTimeEqual, createAskUserServerPlugin, createAskUserTool, defaultAskUserServerPlugin as default, questionsRoutes, requireAskUserRuntime, validateAnswerValues };
|
|
231
|
+
export { type AskUserBridgeHandlersOptions, type AskUserCoordinator, type AskUserPendingHint, type AskUserPendingState, AskUserRuntime, AskUserRuntimeError, type AskUserRuntimeOptions, type AskUserServerPluginOptions, AskUserStatePublisher, type AskUserStore, type AskUserStoreChange, AskUserStoreError, type AskUserStoreListener, type AskUserToolDefinition, type AskUserToolOptions, type AskUserToolResultPayload, FileAskUserStore, InProcessAskUserCoordinator, type QuestionsAuthContext, QuestionsBridge, QuestionsBridgeError, type QuestionsBridgeOptions, type QuestionsRoutesOptions, constantTimeEqual, createAskUserBridgeHandlers, createAskUserServerPlugin, createAskUserTool, defaultAskUserServerPlugin as default, questionsRoutes, requireAskUserRuntime, validateAnswerValues };
|