rystem.playframework.client 0.1.1 → 0.1.2
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 +1155 -32
- package/lib/engine/ClientInteractionRegistry.d.ts +48 -1
- package/lib/engine/ClientInteractionRegistry.d.ts.map +1 -1
- package/lib/engine/ClientInteractionRegistry.js +84 -13
- package/lib/engine/PlayFrameworkClient.d.ts +39 -0
- package/lib/engine/PlayFrameworkClient.d.ts.map +1 -1
- package/lib/engine/PlayFrameworkClient.js +183 -24
- package/lib/index.d.ts +8 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/models/AiSceneResponse.d.ts +2 -2
- package/lib/models/AiSceneResponse.d.ts.map +1 -1
- package/lib/models/ClientInteractionRequest.d.ts +15 -0
- package/lib/models/ClientInteractionRequest.d.ts.map +1 -1
- package/lib/models/CommandResult.d.ts +31 -0
- package/lib/models/CommandResult.d.ts.map +1 -0
- package/lib/models/CommandResult.js +18 -0
- package/lib/models/ExecutionState.d.ts +35 -0
- package/lib/models/ExecutionState.d.ts.map +1 -0
- package/lib/models/ExecutionState.js +2 -0
- package/lib/models/StoredConversation.d.ts +88 -0
- package/lib/models/StoredConversation.d.ts.map +1 -0
- package/lib/models/StoredConversation.js +17 -0
- package/lib/models/StoredMessage.d.ts +30 -0
- package/lib/models/StoredMessage.d.ts.map +1 -0
- package/lib/models/StoredMessage.js +2 -0
- package/lib/utils/ContentUrlConverter.d.ts +62 -0
- package/lib/utils/ContentUrlConverter.d.ts.map +1 -0
- package/lib/utils/ContentUrlConverter.js +151 -0
- package/package.json +1 -1
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
import { ClientInteractionRequest } from "../models/ClientInteractionRequest";
|
|
2
2
|
import { ClientInteractionResult, AIContent } from "../models/ClientInteractionResult";
|
|
3
|
+
import { CommandResult } from "../models/CommandResult";
|
|
3
4
|
/**
|
|
4
5
|
* Type for client-side tool implementation.
|
|
5
6
|
* Takes optional arguments and returns AIContent array.
|
|
6
7
|
*/
|
|
7
8
|
export type ClientTool<TArgs = any> = (args?: TArgs) => Promise<AIContent[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Type for client-side command implementation.
|
|
11
|
+
* Takes optional arguments and returns CommandResult (success + optional message).
|
|
12
|
+
*/
|
|
13
|
+
export type ClientCommand<TArgs = any> = (args?: TArgs) => Promise<CommandResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Command feedback modes:
|
|
16
|
+
* - 'never': Never send feedback (silent command)
|
|
17
|
+
* - 'onError': Send feedback only on failure (default)
|
|
18
|
+
* - 'always': Always send feedback (even on success)
|
|
19
|
+
*/
|
|
20
|
+
export type CommandFeedbackMode = 'never' | 'onError' | 'always';
|
|
21
|
+
/**
|
|
22
|
+
* Options for command registration.
|
|
23
|
+
*/
|
|
24
|
+
export interface CommandOptions {
|
|
25
|
+
/**
|
|
26
|
+
* When to send feedback to the server.
|
|
27
|
+
* @default 'onError'
|
|
28
|
+
*/
|
|
29
|
+
feedbackMode?: CommandFeedbackMode;
|
|
30
|
+
}
|
|
8
31
|
/**
|
|
9
32
|
* Registry for client-side tools (camera, geolocation, file picker, etc.).
|
|
10
33
|
* Tools are registered once and executed when server requests them.
|
|
11
34
|
*/
|
|
12
35
|
export declare class ClientInteractionRegistry {
|
|
13
36
|
private tools;
|
|
37
|
+
private commands;
|
|
14
38
|
/**
|
|
15
39
|
* Registers a client-side tool.
|
|
16
40
|
* @param toolName - Unique tool name matching server OnClient() registration.
|
|
@@ -25,7 +49,30 @@ export declare class ClientInteractionRegistry {
|
|
|
25
49
|
*/
|
|
26
50
|
register<TArgs = any>(toolName: string, implementation: ClientTool<TArgs>): void;
|
|
27
51
|
/**
|
|
28
|
-
*
|
|
52
|
+
* Registers a command (fire-and-forget tool).
|
|
53
|
+
* Commands return CommandResult and can optionally send feedback based on feedbackMode.
|
|
54
|
+
* @param toolName - Unique command name matching server AddCommand() registration.
|
|
55
|
+
* @param implementation - Async function that returns CommandResult.
|
|
56
|
+
* @param options - Feedback configuration.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* registry.registerCommand("logAction", async (args) => {
|
|
60
|
+
* console.log(args.action);
|
|
61
|
+
* return CommandResult.ok();
|
|
62
|
+
* }, { feedbackMode: 'never' });
|
|
63
|
+
*/
|
|
64
|
+
registerCommand<TArgs = any>(toolName: string, implementation: ClientCommand<TArgs>, options?: CommandOptions): void;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a tool is registered as a command.
|
|
67
|
+
*/
|
|
68
|
+
isCommand(toolName: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Gets command options.
|
|
71
|
+
*/
|
|
72
|
+
getCommandOptions(toolName: string): CommandOptions | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Executes a registered tool/command and returns the result.
|
|
75
|
+
* For commands, converts CommandResult to AIContent[] if needed.
|
|
29
76
|
* @param request - Client interaction request from server.
|
|
30
77
|
* @returns ClientInteractionResult with contents or error.
|
|
31
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientInteractionRegistry.d.ts","sourceRoot":"","sources":["../../src/engine/ClientInteractionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientInteractionRegistry.d.ts","sourceRoot":"","sources":["../../src/engine/ClientInteractionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAElF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED;;;GAGG;AACH,qBAAa,yBAAyB;IAClC,OAAO,CAAC,KAAK,CAAsD;IACnE,OAAO,CAAC,QAAQ,CAA0C;IAE1D;;;;;;;;;;;OAWG;IACI,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI;IAQvF;;;;;;;;;;;;OAYG;IACI,eAAe,CAAC,KAAK,GAAG,GAAG,EAC9B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC,EACpC,OAAO,CAAC,EAAE,cAAc,GACzB,IAAI;IAUP;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI3C;;OAEG;IACI,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAItE;;;;;;;;;OASG;IACU,OAAO,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmFzF;;OAEG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACI,YAAY,IAAI,MAAM,EAAE;IAI/B;;OAEG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI5C;;OAEG;IACI,KAAK,IAAI,IAAI;CAGvB"}
|
|
@@ -7,6 +7,7 @@ exports.ClientInteractionRegistry = void 0;
|
|
|
7
7
|
*/
|
|
8
8
|
class ClientInteractionRegistry {
|
|
9
9
|
tools = new Map();
|
|
10
|
+
commands = new Map();
|
|
10
11
|
/**
|
|
11
12
|
* Registers a client-side tool.
|
|
12
13
|
* @param toolName - Unique tool name matching server OnClient() registration.
|
|
@@ -24,9 +25,45 @@ class ClientInteractionRegistry {
|
|
|
24
25
|
console.warn(`ClientInteractionRegistry: Tool "${toolName}" is already registered. Overwriting.`);
|
|
25
26
|
}
|
|
26
27
|
this.tools.set(toolName, implementation);
|
|
28
|
+
this.commands.delete(toolName); // Remove from commands if re-registered as tool
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* Registers a command (fire-and-forget tool).
|
|
32
|
+
* Commands return CommandResult and can optionally send feedback based on feedbackMode.
|
|
33
|
+
* @param toolName - Unique command name matching server AddCommand() registration.
|
|
34
|
+
* @param implementation - Async function that returns CommandResult.
|
|
35
|
+
* @param options - Feedback configuration.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* registry.registerCommand("logAction", async (args) => {
|
|
39
|
+
* console.log(args.action);
|
|
40
|
+
* return CommandResult.ok();
|
|
41
|
+
* }, { feedbackMode: 'never' });
|
|
42
|
+
*/
|
|
43
|
+
registerCommand(toolName, implementation, options) {
|
|
44
|
+
if (this.tools.has(toolName)) {
|
|
45
|
+
console.warn(`ClientInteractionRegistry: Command "${toolName}" is already registered. Overwriting.`);
|
|
46
|
+
}
|
|
47
|
+
this.tools.set(toolName, implementation);
|
|
48
|
+
this.commands.set(toolName, {
|
|
49
|
+
feedbackMode: options?.feedbackMode ?? 'onError'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a tool is registered as a command.
|
|
54
|
+
*/
|
|
55
|
+
isCommand(toolName) {
|
|
56
|
+
return this.commands.has(toolName);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets command options.
|
|
60
|
+
*/
|
|
61
|
+
getCommandOptions(toolName) {
|
|
62
|
+
return this.commands.get(toolName);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Executes a registered tool/command and returns the result.
|
|
66
|
+
* For commands, converts CommandResult to AIContent[] if needed.
|
|
30
67
|
* @param request - Client interaction request from server.
|
|
31
68
|
* @returns ClientInteractionResult with contents or error.
|
|
32
69
|
*
|
|
@@ -46,21 +83,55 @@ class ClientInteractionRegistry {
|
|
|
46
83
|
executedAt: new Date().toISOString()
|
|
47
84
|
};
|
|
48
85
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
timer = setTimeout(() => {
|
|
53
|
-
reject(new Error(`Tool execution timeout after ${request.timeoutSeconds}s`));
|
|
54
|
-
}, request.timeoutSeconds * 1000);
|
|
55
|
-
});
|
|
86
|
+
const isCommand = this.isCommand(request.toolName);
|
|
87
|
+
// Execute tool with timeout (protects against client-side hangs/crashes)
|
|
88
|
+
const timeoutMs = request.timeoutSeconds > 0 ? request.timeoutSeconds * 1000 : 0;
|
|
56
89
|
const executionPromise = tool(request.arguments);
|
|
90
|
+
let result;
|
|
91
|
+
if (timeoutMs > 0) {
|
|
92
|
+
let timer;
|
|
93
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
94
|
+
timer = setTimeout(() => {
|
|
95
|
+
reject(new Error(`Tool execution timeout after ${request.timeoutSeconds}s`));
|
|
96
|
+
}, timeoutMs);
|
|
97
|
+
});
|
|
98
|
+
try {
|
|
99
|
+
result = await Promise.race([executionPromise, timeoutPromise]);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
if (timer !== undefined)
|
|
103
|
+
clearTimeout(timer);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// No timeout — wait indefinitely for the tool to complete
|
|
108
|
+
result = await executionPromise;
|
|
109
|
+
}
|
|
110
|
+
// If it's a command, convert CommandResult to AIContent[]
|
|
57
111
|
let contents;
|
|
58
|
-
|
|
59
|
-
|
|
112
|
+
if (isCommand && 'success' in result) {
|
|
113
|
+
const cmdResult = result;
|
|
114
|
+
const commandOptions = this.getCommandOptions(request.toolName);
|
|
115
|
+
const feedbackMode = commandOptions?.feedbackMode ?? 'onError';
|
|
116
|
+
// Determine if feedback should be sent
|
|
117
|
+
const shouldSendFeedback = feedbackMode === 'always' ||
|
|
118
|
+
(feedbackMode === 'onError' && !cmdResult.success);
|
|
119
|
+
if (shouldSendFeedback) {
|
|
120
|
+
// Send feedback (success + message)
|
|
121
|
+
contents = [
|
|
122
|
+
{ type: 'text', text: cmdResult.success ? 'true' : 'false' }
|
|
123
|
+
];
|
|
124
|
+
if (cmdResult.message) {
|
|
125
|
+
contents.push({ type: 'text', text: cmdResult.message });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// No feedback mode - send minimal success indicator
|
|
130
|
+
contents = [{ type: 'text', text: 'true' }];
|
|
131
|
+
}
|
|
60
132
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
clearTimeout(timer);
|
|
133
|
+
else {
|
|
134
|
+
contents = result;
|
|
64
135
|
}
|
|
65
136
|
return {
|
|
66
137
|
interactionId: request.interactionId,
|
|
@@ -2,6 +2,7 @@ import { PlayFrameworkRequest } from "../models/PlayFrameworkRequest";
|
|
|
2
2
|
import { AiSceneResponse } from "../models/AiSceneResponse";
|
|
3
3
|
import { PlayFrameworkSettings } from "../servicecollection/PlayFrameworkSettings";
|
|
4
4
|
import { ClientInteractionRegistry } from "./ClientInteractionRegistry";
|
|
5
|
+
import type { StoredConversation, ConversationQueryParameters } from "../models/StoredConversation";
|
|
5
6
|
/**
|
|
6
7
|
* PlayFramework HTTP client with step-by-step and token-level streaming support.
|
|
7
8
|
* Supports client-side tool execution with continuation tokens.
|
|
@@ -42,5 +43,43 @@ export declare class PlayFrameworkClient {
|
|
|
42
43
|
* and automatic reconnection on network failures.
|
|
43
44
|
*/
|
|
44
45
|
private streamSSE;
|
|
46
|
+
/**
|
|
47
|
+
* Lists conversations with filtering, sorting, and pagination.
|
|
48
|
+
*
|
|
49
|
+
* @param params - Query parameters for filtering and pagination.
|
|
50
|
+
* @param signal - AbortSignal for cancellation.
|
|
51
|
+
* @returns Promise<StoredConversation[]>
|
|
52
|
+
*/
|
|
53
|
+
listConversations(params?: ConversationQueryParameters, signal?: AbortSignal): Promise<StoredConversation[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Gets a single conversation by key.
|
|
56
|
+
*
|
|
57
|
+
* @param conversationKey - The conversation key to retrieve.
|
|
58
|
+
* @param includeContents - Whether to include message contents (images, audio, PDFs). Default: false.
|
|
59
|
+
* @param signal - AbortSignal for cancellation.
|
|
60
|
+
* @returns Promise<StoredConversation | null>
|
|
61
|
+
*/
|
|
62
|
+
getConversation(conversationKey: string, includeContents?: boolean, signal?: AbortSignal): Promise<StoredConversation | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes a conversation (owner only).
|
|
65
|
+
*
|
|
66
|
+
* @param conversationKey - The conversation key to delete.
|
|
67
|
+
* @param signal - AbortSignal for cancellation.
|
|
68
|
+
* @returns Promise<void>
|
|
69
|
+
*/
|
|
70
|
+
deleteConversation(conversationKey: string, signal?: AbortSignal): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Updates conversation visibility (public/private).
|
|
73
|
+
*
|
|
74
|
+
* @param conversationKey - The conversation key to update.
|
|
75
|
+
* @param isPublic - Whether the conversation should be public.
|
|
76
|
+
* @param signal - AbortSignal for cancellation.
|
|
77
|
+
* @returns Promise<StoredConversation>
|
|
78
|
+
*/
|
|
79
|
+
updateConversationVisibility(conversationKey: string, isPublic: boolean, signal?: AbortSignal): Promise<StoredConversation>;
|
|
80
|
+
/**
|
|
81
|
+
* Helper to build query string from parameters.
|
|
82
|
+
*/
|
|
83
|
+
private buildQueryString;
|
|
45
84
|
}
|
|
46
85
|
//# sourceMappingURL=PlayFrameworkClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayFrameworkClient.d.ts","sourceRoot":"","sources":["../../src/engine/PlayFrameworkClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"PlayFrameworkClient.d.ts","sourceRoot":"","sources":["../../src/engine/PlayFrameworkClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAuC,MAAM,8BAA8B,CAAC;AAEzI;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,cAAc,CAA4B;gBAEtC,QAAQ,EAAE,qBAAqB,EAAE,cAAc,CAAC,EAAE,yBAAyB;IAKvF;;OAEG;IACI,iBAAiB,IAAI,yBAAyB;IAIrD;;;;;;;OAOG;IACW,iBAAiB,CAC3B,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACrB,qBAAqB,CAAC,eAAe,CAAC;IAKzC;;;;;;;OAOG;IACW,qBAAqB,CAC/B,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACrB,qBAAqB,CAAC,eAAe,CAAC;IAKzC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;;OAGG;YACY,SAAS;IAwMxB;;;;;;OAMG;IACU,iBAAiB,CAC1B,MAAM,CAAC,EAAE,2BAA2B,EACpC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAmBhC;;;;;;;OAOG;IACU,eAAe,CACxB,eAAe,EAAE,MAAM,EACvB,eAAe,GAAE,OAAe,EAChC,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAuBrC;;;;;;OAMG;IACU,kBAAkB,CAC3B,eAAe,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;;OAOG;IACU,4BAA4B,CACrC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,OAAO,EACjB,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,kBAAkB,CAAC;IAoB9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAiC3B"}
|
|
@@ -78,7 +78,9 @@ class PlayFrameworkClient {
|
|
|
78
78
|
while (shouldContinue) {
|
|
79
79
|
const headers = await this.settings.enrichHeaders(url, "POST", undefined, currentRequest);
|
|
80
80
|
let reconnectAttempts = 0;
|
|
81
|
-
|
|
81
|
+
// Collect ALL client interaction responses (server may send multiple in a single batch)
|
|
82
|
+
const pendingInteractions = [];
|
|
83
|
+
let capturedConversationKey;
|
|
82
84
|
let shouldRetry = true;
|
|
83
85
|
while (shouldRetry) {
|
|
84
86
|
try {
|
|
@@ -124,20 +126,27 @@ class PlayFrameworkClient {
|
|
|
124
126
|
}
|
|
125
127
|
// Check for completion/error markers
|
|
126
128
|
if (event.status === "completed") {
|
|
127
|
-
// Don't set shouldContinue = false yet - check if client
|
|
129
|
+
// Don't set shouldContinue = false yet - check if client interactions needed first
|
|
128
130
|
shouldRetry = false; // Don't retry, stream closed successfully
|
|
129
|
-
break; // Exit read loop to handle client
|
|
131
|
+
break; // Exit read loop to handle client interactions if needed
|
|
130
132
|
}
|
|
131
133
|
if (event.status === "error") {
|
|
132
134
|
shouldContinue = false;
|
|
133
135
|
shouldRetry = false; // Don't retry on error
|
|
134
136
|
throw new Error(event.errorMessage || "Unknown error");
|
|
135
137
|
}
|
|
136
|
-
// Check for AwaitingClient status (camelCase from
|
|
137
|
-
if (event.status === "awaitingClient") {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
// Check for AwaitingClient or CommandClient status (camelCase from JsonStringEnumConverter)
|
|
139
|
+
if (event.status === "awaitingClient" || event.status === "commandClient") {
|
|
140
|
+
const interactionResponse = event;
|
|
141
|
+
const isCommand = event.status === "commandClient";
|
|
142
|
+
console.log(isCommand ? '🔥 [PlayFrameworkClient] Received CommandClient (fire-and-forget)' : '⏸️ [PlayFrameworkClient] Received AwaitingClient', ', tool:', interactionResponse.clientInteractionRequest?.toolName);
|
|
143
|
+
// Capture conversationKey from the response (server sets it for resume)
|
|
144
|
+
if (interactionResponse.conversationKey) {
|
|
145
|
+
capturedConversationKey = interactionResponse.conversationKey;
|
|
146
|
+
}
|
|
147
|
+
// Collect ALL interactions (don't overwrite — the server may send multiple)
|
|
148
|
+
pendingInteractions.push(interactionResponse);
|
|
149
|
+
yield interactionResponse; // Yield to user
|
|
141
150
|
// Don't break - continue reading until stream closes
|
|
142
151
|
continue; // Skip the second yield below to avoid duplication
|
|
143
152
|
}
|
|
@@ -153,22 +162,51 @@ class PlayFrameworkClient {
|
|
|
153
162
|
reader.releaseLock();
|
|
154
163
|
}
|
|
155
164
|
shouldRetry = false; // Success, no retry
|
|
156
|
-
// Handle client
|
|
157
|
-
if (shouldContinue &&
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
// Handle client interactions if any were received during this stream
|
|
166
|
+
if (shouldContinue && pendingInteractions.length > 0) {
|
|
167
|
+
console.log(`🔧 [PlayFrameworkClient] Executing ${pendingInteractions.length} client interaction(s)`);
|
|
168
|
+
// Execute ALL pending interactions in parallel
|
|
169
|
+
const allResults = [];
|
|
170
|
+
let hasNonCommandInteraction = false;
|
|
171
|
+
for (const interaction of pendingInteractions) {
|
|
172
|
+
const clientRequest = interaction.clientInteractionRequest;
|
|
173
|
+
if (!clientRequest)
|
|
174
|
+
continue;
|
|
175
|
+
console.log(`🔧 [PlayFrameworkClient] Executing: ${clientRequest.toolName} (${clientRequest.isCommand ? 'command' : 'tool'})`);
|
|
176
|
+
const result = await this.clientRegistry.execute(clientRequest);
|
|
177
|
+
if (clientRequest.isCommand === true) {
|
|
178
|
+
// Command: check feedbackMode to decide whether to send result
|
|
179
|
+
const feedbackMode = clientRequest.feedbackMode ?? 'onError';
|
|
180
|
+
if (feedbackMode === 'always') {
|
|
181
|
+
allResults.push(result);
|
|
182
|
+
}
|
|
183
|
+
else if (feedbackMode === 'onError' && result.error) {
|
|
184
|
+
allResults.push(result);
|
|
185
|
+
}
|
|
186
|
+
// feedbackMode === 'never': don't send result
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// Tool (AwaitingClient): always send result
|
|
190
|
+
hasNonCommandInteraction = true;
|
|
191
|
+
allResults.push(result);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (hasNonCommandInteraction || allResults.length > 0) {
|
|
195
|
+
console.log(`✅ [PlayFrameworkClient] ${allResults.length} result(s) to send back, resuming`);
|
|
196
|
+
// Prepare resume request with ALL applicable results
|
|
197
|
+
// Use captured conversationKey so the server finds the batch in cache
|
|
198
|
+
currentRequest = {
|
|
199
|
+
...currentRequest,
|
|
200
|
+
clientInteractionResults: allResults,
|
|
201
|
+
conversationKey: capturedConversationKey ?? currentRequest.conversationKey
|
|
202
|
+
};
|
|
203
|
+
console.log('📤 [PlayFrameworkClient] Sending resume request with clientInteractionResults');
|
|
204
|
+
shouldContinue = true;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
console.log('✅ [PlayFrameworkClient] All interactions were fire-and-forget commands. No resume needed.');
|
|
208
|
+
shouldContinue = false;
|
|
209
|
+
}
|
|
172
210
|
}
|
|
173
211
|
else {
|
|
174
212
|
console.log('✅ [PlayFrameworkClient] Stream completed normally (no client interaction)');
|
|
@@ -196,5 +234,126 @@ class PlayFrameworkClient {
|
|
|
196
234
|
}
|
|
197
235
|
}
|
|
198
236
|
}
|
|
237
|
+
// ─── Conversation Management Methods ────────────────────────────────────────
|
|
238
|
+
/**
|
|
239
|
+
* Lists conversations with filtering, sorting, and pagination.
|
|
240
|
+
*
|
|
241
|
+
* @param params - Query parameters for filtering and pagination.
|
|
242
|
+
* @param signal - AbortSignal for cancellation.
|
|
243
|
+
* @returns Promise<StoredConversation[]>
|
|
244
|
+
*/
|
|
245
|
+
async listConversations(params, signal) {
|
|
246
|
+
const queryString = this.buildQueryString(params || {});
|
|
247
|
+
const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations${queryString}`;
|
|
248
|
+
const headers = await this.settings.enrichHeaders(url, "GET", undefined, undefined);
|
|
249
|
+
const effectiveSignal = this.createTimeoutSignal(signal);
|
|
250
|
+
const response = await fetch(url, {
|
|
251
|
+
method: "GET",
|
|
252
|
+
headers,
|
|
253
|
+
signal: effectiveSignal
|
|
254
|
+
});
|
|
255
|
+
if (!response.ok) {
|
|
256
|
+
throw new Error(`Failed to list conversations: ${response.statusText}`);
|
|
257
|
+
}
|
|
258
|
+
return await response.json();
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Gets a single conversation by key.
|
|
262
|
+
*
|
|
263
|
+
* @param conversationKey - The conversation key to retrieve.
|
|
264
|
+
* @param includeContents - Whether to include message contents (images, audio, PDFs). Default: false.
|
|
265
|
+
* @param signal - AbortSignal for cancellation.
|
|
266
|
+
* @returns Promise<StoredConversation | null>
|
|
267
|
+
*/
|
|
268
|
+
async getConversation(conversationKey, includeContents = false, signal) {
|
|
269
|
+
const queryString = includeContents ? '?includeContents=true' : '';
|
|
270
|
+
const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations/${conversationKey}${queryString}`;
|
|
271
|
+
const headers = await this.settings.enrichHeaders(url, "GET", undefined, undefined);
|
|
272
|
+
const effectiveSignal = this.createTimeoutSignal(signal);
|
|
273
|
+
const response = await fetch(url, {
|
|
274
|
+
method: "GET",
|
|
275
|
+
headers,
|
|
276
|
+
signal: effectiveSignal
|
|
277
|
+
});
|
|
278
|
+
if (response.status === 404) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
if (!response.ok) {
|
|
282
|
+
throw new Error(`Failed to get conversation: ${response.statusText}`);
|
|
283
|
+
}
|
|
284
|
+
return await response.json();
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Deletes a conversation (owner only).
|
|
288
|
+
*
|
|
289
|
+
* @param conversationKey - The conversation key to delete.
|
|
290
|
+
* @param signal - AbortSignal for cancellation.
|
|
291
|
+
* @returns Promise<void>
|
|
292
|
+
*/
|
|
293
|
+
async deleteConversation(conversationKey, signal) {
|
|
294
|
+
const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations/${conversationKey}`;
|
|
295
|
+
const headers = await this.settings.enrichHeaders(url, "DELETE", undefined, undefined);
|
|
296
|
+
const effectiveSignal = this.createTimeoutSignal(signal);
|
|
297
|
+
const response = await fetch(url, {
|
|
298
|
+
method: "DELETE",
|
|
299
|
+
headers,
|
|
300
|
+
signal: effectiveSignal
|
|
301
|
+
});
|
|
302
|
+
if (!response.ok) {
|
|
303
|
+
throw new Error(`Failed to delete conversation: ${response.statusText}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Updates conversation visibility (public/private).
|
|
308
|
+
*
|
|
309
|
+
* @param conversationKey - The conversation key to update.
|
|
310
|
+
* @param isPublic - Whether the conversation should be public.
|
|
311
|
+
* @param signal - AbortSignal for cancellation.
|
|
312
|
+
* @returns Promise<StoredConversation>
|
|
313
|
+
*/
|
|
314
|
+
async updateConversationVisibility(conversationKey, isPublic, signal) {
|
|
315
|
+
const url = `${this.settings.baseUrl}/${this.settings.factoryName}/conversations/${conversationKey}/visibility`;
|
|
316
|
+
const body = { isPublic };
|
|
317
|
+
const headers = await this.settings.enrichHeaders(url, "PATCH", undefined, body);
|
|
318
|
+
const effectiveSignal = this.createTimeoutSignal(signal);
|
|
319
|
+
const response = await fetch(url, {
|
|
320
|
+
method: "PATCH",
|
|
321
|
+
headers,
|
|
322
|
+
body: JSON.stringify(body),
|
|
323
|
+
signal: effectiveSignal
|
|
324
|
+
});
|
|
325
|
+
if (!response.ok) {
|
|
326
|
+
throw new Error(`Failed to update conversation visibility: ${response.statusText}`);
|
|
327
|
+
}
|
|
328
|
+
return await response.json();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Helper to build query string from parameters.
|
|
332
|
+
*/
|
|
333
|
+
buildQueryString(params) {
|
|
334
|
+
const queryParams = [];
|
|
335
|
+
if (params.searchText) {
|
|
336
|
+
queryParams.push(`searchText=${encodeURIComponent(params.searchText)}`);
|
|
337
|
+
}
|
|
338
|
+
// OrderBy - default to TimestampDescending (0) if not provided
|
|
339
|
+
const orderBy = params.orderBy !== undefined ? params.orderBy : 0;
|
|
340
|
+
queryParams.push(`orderBy=${orderBy}`);
|
|
341
|
+
// IncludePublic - default to true if not provided
|
|
342
|
+
const includePublic = params.includePublic !== undefined ? params.includePublic : true;
|
|
343
|
+
queryParams.push(`includePublic=${includePublic}`);
|
|
344
|
+
// IncludePrivate - default to true if not provided
|
|
345
|
+
const includePrivate = params.includePrivate !== undefined ? params.includePrivate : true;
|
|
346
|
+
queryParams.push(`includePrivate=${includePrivate}`);
|
|
347
|
+
// Skip - default to 0 if not provided (REQUIRED by backend)
|
|
348
|
+
const skip = params.skip !== undefined ? params.skip : 0;
|
|
349
|
+
queryParams.push(`skip=${skip}`);
|
|
350
|
+
// Take - default to 50 if not provided
|
|
351
|
+
const take = params.take !== undefined ? params.take : 50;
|
|
352
|
+
queryParams.push(`take=${take}`);
|
|
353
|
+
// IncludeContents - default to false if not provided
|
|
354
|
+
const includeContents = params.includeContents !== undefined ? params.includeContents : false;
|
|
355
|
+
queryParams.push(`includeContents=${includeContents}`);
|
|
356
|
+
return queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
|
|
357
|
+
}
|
|
199
358
|
}
|
|
200
359
|
exports.PlayFrameworkClient = PlayFrameworkClient;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,10 +3,17 @@ export type { PlayFrameworkRequest, SceneRequestSettings, SceneExecutionMode, Ca
|
|
|
3
3
|
export type { AiSceneResponse, AiResponseStatus, SSEEvent, CompletionMarker, ErrorMarker } from "./models/AiSceneResponse";
|
|
4
4
|
export type { ClientInteractionRequest } from "./models/ClientInteractionRequest";
|
|
5
5
|
export type { ClientInteractionResult, AIContent } from "./models/ClientInteractionResult";
|
|
6
|
+
export type { StoredConversation, ConversationQueryParameters, UpdateConversationVisibilityRequest } from "./models/StoredConversation";
|
|
7
|
+
export { ConversationSortOrder } from "./models/StoredConversation";
|
|
8
|
+
export type { StoredMessage } from "./models/StoredMessage";
|
|
9
|
+
export type { ExecutionState } from "./models/ExecutionState";
|
|
10
|
+
export type { CommandResult } from "./models/CommandResult";
|
|
11
|
+
export { CommandResult as CommandResultHelper } from "./models/CommandResult";
|
|
6
12
|
export { PlayFrameworkClient } from "./engine/PlayFrameworkClient";
|
|
7
13
|
export { ClientInteractionRegistry } from "./engine/ClientInteractionRegistry";
|
|
8
|
-
export type { ClientTool } from "./engine/ClientInteractionRegistry";
|
|
14
|
+
export type { ClientTool, ClientCommand, CommandFeedbackMode, CommandOptions } from "./engine/ClientInteractionRegistry";
|
|
9
15
|
export { AIContentConverter } from "./utils/AIContentConverter";
|
|
16
|
+
export { ContentUrlConverter } from "./utils/ContentUrlConverter";
|
|
10
17
|
export { PlayFrameworkSettings } from "./servicecollection/PlayFrameworkSettings";
|
|
11
18
|
export { PlayFrameworkServices } from "./servicecollection/PlayFrameworkServices";
|
|
12
19
|
export { usePlayFramework } from "./hooks/hooks";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnI,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC3H,YAAY,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,YAAY,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnI,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC3H,YAAY,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,YAAY,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC3F,YAAY,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AACxI,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAGlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePlayFramework = exports.PlayFrameworkServices = exports.PlayFrameworkSettings = exports.AIContentConverter = exports.ClientInteractionRegistry = exports.PlayFrameworkClient = void 0;
|
|
3
|
+
exports.usePlayFramework = exports.PlayFrameworkServices = exports.PlayFrameworkSettings = exports.ContentUrlConverter = exports.AIContentConverter = exports.ClientInteractionRegistry = exports.PlayFrameworkClient = exports.CommandResultHelper = exports.ConversationSortOrder = void 0;
|
|
4
|
+
var StoredConversation_1 = require("./models/StoredConversation");
|
|
5
|
+
Object.defineProperty(exports, "ConversationSortOrder", { enumerable: true, get: function () { return StoredConversation_1.ConversationSortOrder; } });
|
|
6
|
+
var CommandResult_1 = require("./models/CommandResult");
|
|
7
|
+
Object.defineProperty(exports, "CommandResultHelper", { enumerable: true, get: function () { return CommandResult_1.CommandResult; } });
|
|
4
8
|
// Engine
|
|
5
9
|
var PlayFrameworkClient_1 = require("./engine/PlayFrameworkClient");
|
|
6
10
|
Object.defineProperty(exports, "PlayFrameworkClient", { enumerable: true, get: function () { return PlayFrameworkClient_1.PlayFrameworkClient; } });
|
|
@@ -9,6 +13,8 @@ Object.defineProperty(exports, "ClientInteractionRegistry", { enumerable: true,
|
|
|
9
13
|
// Utilities
|
|
10
14
|
var AIContentConverter_1 = require("./utils/AIContentConverter");
|
|
11
15
|
Object.defineProperty(exports, "AIContentConverter", { enumerable: true, get: function () { return AIContentConverter_1.AIContentConverter; } });
|
|
16
|
+
var ContentUrlConverter_1 = require("./utils/ContentUrlConverter");
|
|
17
|
+
Object.defineProperty(exports, "ContentUrlConverter", { enumerable: true, get: function () { return ContentUrlConverter_1.ContentUrlConverter; } });
|
|
12
18
|
// Service Collection
|
|
13
19
|
var PlayFrameworkSettings_1 = require("./servicecollection/PlayFrameworkSettings");
|
|
14
20
|
Object.defineProperty(exports, "PlayFrameworkSettings", { enumerable: true, get: function () { return PlayFrameworkSettings_1.PlayFrameworkSettings; } });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ClientInteractionRequest } from "./ClientInteractionRequest";
|
|
2
2
|
/**
|
|
3
3
|
* Response status from PlayFramework execution.
|
|
4
|
-
*
|
|
4
|
+
* Serialized as camelCase from C# JsonStringEnumConverter.
|
|
5
5
|
*/
|
|
6
|
-
export type AiResponseStatus = "initializing" | "loadingCache" | "executingMainActors" | "planning" | "executingScene" | "functionRequest" | "functionCompleted" | "toolSkipped" | "streaming" | "running" | "summarizing" | "directorDecision" | "generatingFinalResponse" | "savingCache" | "savingMemory" | "awaitingClient" | "completed" | "budgetExceeded" | "error";
|
|
6
|
+
export type AiResponseStatus = "initializing" | "loadingCache" | "executingMainActors" | "planning" | "executingScene" | "functionRequest" | "functionCompleted" | "toolSkipped" | "streaming" | "running" | "summarizing" | "directorDecision" | "generatingFinalResponse" | "savingCache" | "savingMemory" | "awaitingClient" | "commandClient" | "completed" | "budgetExceeded" | "error" | "unauthorized";
|
|
7
7
|
/**
|
|
8
8
|
* Single step response from PlayFramework (used in step-by-step streaming).
|
|
9
9
|
* Matches C# AiSceneResponse contract.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSceneResponse.d.ts","sourceRoot":"","sources":["../../src/models/AiSceneResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACtB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,UAAU,GACV,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,GACb,WAAW,GACX,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,yBAAyB,GACzB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,gBAAgB,GAChB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AiSceneResponse.d.ts","sourceRoot":"","sources":["../../src/models/AiSceneResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACtB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,UAAU,GACV,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,GACb,WAAW,GACX,SAAS,GACT,aAAa,GACb,kBAAkB,GAClB,yBAAyB,GACzB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,gBAAgB,GAChB,OAAO,GACP,cAAc,CAAC;AAErB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAEpD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;CACN;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,WAAW,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,gBAAgB,GAAG,WAAW,CAAC"}
|
|
@@ -27,7 +27,22 @@ export interface ClientInteractionRequest {
|
|
|
27
27
|
argumentsSchema?: string;
|
|
28
28
|
/**
|
|
29
29
|
* Maximum execution time in seconds.
|
|
30
|
+
* For standard tools: timeout for client response.
|
|
31
|
+
* For commands: timeout for client-side execution (protects against crashes/hangs).
|
|
30
32
|
*/
|
|
31
33
|
timeoutSeconds: number;
|
|
34
|
+
/**
|
|
35
|
+
* Indicates if this is a command (fire-and-forget tool).
|
|
36
|
+
* Commands don't require immediate response - auto-completed with 'true' on next user message.
|
|
37
|
+
* Client can optionally send CommandResult (success + message) based on feedbackMode.
|
|
38
|
+
*/
|
|
39
|
+
isCommand?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Feedback mode for Commands (only used when isCommand=true).
|
|
42
|
+
* - 'never': No feedback sent, auto-complete immediately with 'true'
|
|
43
|
+
* - 'onError': Send feedback only if command fails
|
|
44
|
+
* - 'always': Always send feedback (success + message)
|
|
45
|
+
*/
|
|
46
|
+
feedbackMode?: 'never' | 'onError' | 'always';
|
|
32
47
|
}
|
|
33
48
|
//# sourceMappingURL=ClientInteractionRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientInteractionRequest.d.ts","sourceRoot":"","sources":["../../src/models/ClientInteractionRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB
|
|
1
|
+
{"version":3,"file":"ClientInteractionRequest.d.ts","sourceRoot":"","sources":["../../src/models/ClientInteractionRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;CACjD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of a client command execution.
|
|
3
|
+
* Commands are fire-and-forget client tools that don't require immediate response.
|
|
4
|
+
*/
|
|
5
|
+
export interface CommandResult {
|
|
6
|
+
/**
|
|
7
|
+
* Indicates if the command executed successfully.
|
|
8
|
+
*/
|
|
9
|
+
success: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Optional message to send to the LLM (e.g., error details, confirmation message).
|
|
12
|
+
* If undefined, only the success status is sent.
|
|
13
|
+
*/
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper methods for creating CommandResult instances.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CommandResult: {
|
|
20
|
+
/**
|
|
21
|
+
* Creates a successful result.
|
|
22
|
+
* @param message - Optional success message
|
|
23
|
+
*/
|
|
24
|
+
ok: (message?: string) => CommandResult;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a failed result.
|
|
27
|
+
* @param message - Error message describing what went wrong
|
|
28
|
+
*/
|
|
29
|
+
fail: (message: string) => CommandResult;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=CommandResult.d.ts.map
|