rystem.playframework.client 0.1.0 → 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 +1701 -102
- package/lib/engine/ClientInteractionRegistry.d.ts +49 -1
- package/lib/engine/ClientInteractionRegistry.d.ts.map +1 -0
- package/lib/engine/ClientInteractionRegistry.js +84 -13
- package/lib/engine/PlayFrameworkClient.d.ts +40 -0
- package/lib/engine/PlayFrameworkClient.d.ts.map +1 -0
- package/lib/engine/PlayFrameworkClient.js +190 -30
- package/lib/hooks/hooks.d.ts +1 -0
- package/lib/hooks/hooks.d.ts.map +1 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -1
- package/lib/models/AiSceneResponse.d.ts +3 -2
- package/lib/models/AiSceneResponse.d.ts.map +1 -0
- package/lib/models/ClientInteractionRequest.d.ts +16 -0
- package/lib/models/ClientInteractionRequest.d.ts.map +1 -0
- package/lib/models/ClientInteractionResult.d.ts +1 -0
- package/lib/models/ClientInteractionResult.d.ts.map +1 -0
- 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/ContentItem.d.ts +1 -0
- package/lib/models/ContentItem.d.ts.map +1 -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/PlayFrameworkRequest.d.ts +5 -6
- package/lib/models/PlayFrameworkRequest.d.ts.map +1 -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/servicecollection/PlayFrameworkServices.d.ts +1 -0
- package/lib/servicecollection/PlayFrameworkServices.d.ts.map +1 -0
- package/lib/servicecollection/PlayFrameworkSettings.d.ts +1 -0
- package/lib/servicecollection/PlayFrameworkSettings.d.ts.map +1 -0
- package/lib/utils/AIContentConverter.d.ts +1 -0
- package/lib/utils/AIContentConverter.d.ts.map +1 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientInteractionResult.d.ts","sourceRoot":"","sources":["../../src/models/ClientInteractionResult.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACpC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,EAAE,SAAS,EAAE,CAAC;IAEtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandResult.d.ts","sourceRoot":"","sources":["../../src/models/CommandResult.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;IACtB;;;OAGG;mBACY,MAAM,KAAG,aAAa;IAErC;;;OAGG;oBACa,MAAM,KAAG,aAAa;CACzC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandResult = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helper methods for creating CommandResult instances.
|
|
6
|
+
*/
|
|
7
|
+
exports.CommandResult = {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a successful result.
|
|
10
|
+
* @param message - Optional success message
|
|
11
|
+
*/
|
|
12
|
+
ok: (message) => ({ success: true, message }),
|
|
13
|
+
/**
|
|
14
|
+
* Creates a failed result.
|
|
15
|
+
* @param message - Error message describing what went wrong
|
|
16
|
+
*/
|
|
17
|
+
fail: (message) => ({ success: false, message }),
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentItem.d.ts","sourceRoot":"","sources":["../../src/models/ContentItem.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IAE5D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution phase enum (matches C# ExecutionPhase).
|
|
3
|
+
* Serialized as camelCase from JsonStringEnumConverter.
|
|
4
|
+
*/
|
|
5
|
+
export type ExecutionPhase = "notStarted" | "initialized" | "sceneSelected" | "executingScene" | "awaitingClient" | "sceneCompleted" | "chaining" | "generatingFinalResponse" | "completed" | "completedNoResponse" | "budgetExceeded" | "sceneNotFound" | "tooManyToolRequests" | "break" | "unauthorized";
|
|
6
|
+
/**
|
|
7
|
+
* Execution state for resuming conversations.
|
|
8
|
+
*/
|
|
9
|
+
export interface ExecutionState {
|
|
10
|
+
/**
|
|
11
|
+
* Current execution phase.
|
|
12
|
+
*/
|
|
13
|
+
phase: ExecutionPhase;
|
|
14
|
+
/**
|
|
15
|
+
* Executed scenes in order.
|
|
16
|
+
*/
|
|
17
|
+
executedSceneOrder: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Tools executed per scene.
|
|
20
|
+
*/
|
|
21
|
+
executedScenes: Record<string, any[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Executed tools.
|
|
24
|
+
*/
|
|
25
|
+
executedTools: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Accumulated cost.
|
|
28
|
+
*/
|
|
29
|
+
accumulatedCost: number;
|
|
30
|
+
/**
|
|
31
|
+
* Current scene name (if resuming mid-execution).
|
|
32
|
+
*/
|
|
33
|
+
currentSceneName?: string | null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ExecutionState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionState.d.ts","sourceRoot":"","sources":["../../src/models/ExecutionState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,cAAc,GACpB,YAAY,GACZ,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,UAAU,GACV,yBAAyB,GACzB,WAAW,GACX,qBAAqB,GACrB,gBAAgB,GAChB,eAAe,GACf,qBAAqB,GACrB,OAAO,GACP,cAAc,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IAEtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAEtC;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC"}
|
|
@@ -36,8 +36,6 @@ export interface SceneRequestSettings {
|
|
|
36
36
|
maxDynamicScenes?: number;
|
|
37
37
|
/** Unique key for this conversation (used by cache and memory). */
|
|
38
38
|
conversationKey?: string;
|
|
39
|
-
/** Continuation token for resuming execution after client interaction. */
|
|
40
|
-
continuationToken?: string;
|
|
41
39
|
/** Name of the scene to execute directly (used with SceneExecutionMode "Scene"). */
|
|
42
40
|
sceneName?: string;
|
|
43
41
|
/** Results from client-side tool executions. */
|
|
@@ -65,13 +63,14 @@ export interface PlayFrameworkRequest {
|
|
|
65
63
|
*/
|
|
66
64
|
settings?: SceneRequestSettings;
|
|
67
65
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
* Conversation key for resuming execution after client interaction.
|
|
67
|
+
* When present, server loads conversation state from cache.
|
|
70
68
|
*/
|
|
71
|
-
|
|
69
|
+
conversationKey?: string;
|
|
72
70
|
/**
|
|
73
71
|
* Results from client-side tool executions.
|
|
74
|
-
*
|
|
72
|
+
* Used to resume execution after AwaitingClient status.
|
|
75
73
|
*/
|
|
76
74
|
clientInteractionResults?: ClientInteractionResult[];
|
|
77
75
|
}
|
|
76
|
+
//# sourceMappingURL=PlayFrameworkRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayFrameworkRequest.d.ts","sourceRoot":"","sources":["../../src/models/PlayFrameworkRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,iBAAiB,GAAG,OAAO,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,uCAAuC;IACvC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gEAAgE;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,wBAAwB,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACxD;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAEhC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACxD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { StoredMessage } from './StoredMessage';
|
|
2
|
+
import type { ExecutionState } from './ExecutionState';
|
|
3
|
+
/**
|
|
4
|
+
* Stored conversation with messages and metadata.
|
|
5
|
+
*/
|
|
6
|
+
export interface StoredConversation {
|
|
7
|
+
/**
|
|
8
|
+
* Unique conversation identifier.
|
|
9
|
+
*/
|
|
10
|
+
conversationKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* User who owns this conversation (null = public).
|
|
13
|
+
*/
|
|
14
|
+
userId?: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether this conversation is public (accessible to everyone).
|
|
17
|
+
*/
|
|
18
|
+
isPublic: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Last update timestamp.
|
|
21
|
+
*/
|
|
22
|
+
timestamp: string;
|
|
23
|
+
/**
|
|
24
|
+
* Serializable messages.
|
|
25
|
+
*/
|
|
26
|
+
messages: StoredMessage[];
|
|
27
|
+
/**
|
|
28
|
+
* Execution state (scenes executed, tools used, etc.).
|
|
29
|
+
*/
|
|
30
|
+
executionState?: ExecutionState | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Query parameters for listing conversations.
|
|
34
|
+
*/
|
|
35
|
+
export interface ConversationQueryParameters {
|
|
36
|
+
/**
|
|
37
|
+
* Search text in conversation messages (optional).
|
|
38
|
+
*/
|
|
39
|
+
searchText?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Sort order by timestamp.
|
|
42
|
+
*/
|
|
43
|
+
orderBy?: ConversationSortOrder;
|
|
44
|
+
/**
|
|
45
|
+
* Include public conversations (default: true).
|
|
46
|
+
*/
|
|
47
|
+
includePublic?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Include private conversations owned by current user (default: true).
|
|
50
|
+
*/
|
|
51
|
+
includePrivate?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Number of items to skip for pagination (default: 0).
|
|
54
|
+
*/
|
|
55
|
+
skip?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Number of items to take for pagination (default: 50).
|
|
58
|
+
*/
|
|
59
|
+
take?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Include message contents (images, audio, PDFs, etc.) in responses (default: false).
|
|
62
|
+
* When false, contents are excluded to reduce payload size in list operations.
|
|
63
|
+
*/
|
|
64
|
+
includeContents?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sort order for conversation list.
|
|
68
|
+
*/
|
|
69
|
+
export declare enum ConversationSortOrder {
|
|
70
|
+
/**
|
|
71
|
+
* Newest first (default).
|
|
72
|
+
*/
|
|
73
|
+
TimestampDescending = 0,
|
|
74
|
+
/**
|
|
75
|
+
* Oldest first.
|
|
76
|
+
*/
|
|
77
|
+
TimestampAscending = 1
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Request body for updating conversation visibility.
|
|
81
|
+
*/
|
|
82
|
+
export interface UpdateConversationVisibilityRequest {
|
|
83
|
+
/**
|
|
84
|
+
* Whether the conversation should be public.
|
|
85
|
+
*/
|
|
86
|
+
isPublic: boolean;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=StoredConversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StoredConversation.d.ts","sourceRoot":"","sources":["../../src/models/StoredConversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,aAAa,EAAE,CAAC;IAE1B;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAEhC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,oBAAY,qBAAqB;IAC7B;;OAEG;IACH,mBAAmB,IAAI;IAEvB;;OAEG;IACH,kBAAkB,IAAI;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAChD;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationSortOrder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sort order for conversation list.
|
|
6
|
+
*/
|
|
7
|
+
var ConversationSortOrder;
|
|
8
|
+
(function (ConversationSortOrder) {
|
|
9
|
+
/**
|
|
10
|
+
* Newest first (default).
|
|
11
|
+
*/
|
|
12
|
+
ConversationSortOrder[ConversationSortOrder["TimestampDescending"] = 0] = "TimestampDescending";
|
|
13
|
+
/**
|
|
14
|
+
* Oldest first.
|
|
15
|
+
*/
|
|
16
|
+
ConversationSortOrder[ConversationSortOrder["TimestampAscending"] = 1] = "TimestampAscending";
|
|
17
|
+
})(ConversationSortOrder || (exports.ConversationSortOrder = ConversationSortOrder = {}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializable representation of a message.
|
|
3
|
+
*/
|
|
4
|
+
export interface StoredMessage {
|
|
5
|
+
/**
|
|
6
|
+
* Business type flags.
|
|
7
|
+
*/
|
|
8
|
+
businessType: number;
|
|
9
|
+
/**
|
|
10
|
+
* Label for debugging.
|
|
11
|
+
*/
|
|
12
|
+
label?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* The role of the message (User, Assistant, System, Tool).
|
|
15
|
+
*/
|
|
16
|
+
role: string;
|
|
17
|
+
/**
|
|
18
|
+
* Text content of the message (if any).
|
|
19
|
+
*/
|
|
20
|
+
text?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Serialized contents for complex messages.
|
|
23
|
+
*/
|
|
24
|
+
contents?: any[] | null;
|
|
25
|
+
/**
|
|
26
|
+
* Additional properties from the original message.
|
|
27
|
+
*/
|
|
28
|
+
additionalProperties?: Record<string, any> | null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=StoredMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StoredMessage.d.ts","sourceRoot":"","sources":["../../src/models/StoredMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayFrameworkServices.d.ts","sourceRoot":"","sources":["../../src/servicecollection/PlayFrameworkServices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,MAAM,CAAC,OAAO,CAA+C;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiD;IAExE;;;;;;;;OAQG;WACiB,SAAS,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACtE,OAAO,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AO,CAAC,SAAS,EAAE,CAAC;IAKvB;;;;;;;;OAQG;WACiB,cAAc,CAC9B,UAAU,GAAE,MAAa,EACzB,QAAQ,GAAE,MAAqB,GAChC,OAAO,CAAC,SAAS,CAAC;CA8BxB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AIContent } from '../models/ClientInteractionResult';
|
|
2
|
+
/**
|
|
3
|
+
* Utility class for converting AIContent (base64 data) to Blob URLs for browser display.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const content: AIContent = { type: "data", data: "...", mediaType: "image/jpeg" };
|
|
8
|
+
*
|
|
9
|
+
* // Convert to Blob URL
|
|
10
|
+
* const url = ContentUrlConverter.toBlobUrl(content);
|
|
11
|
+
*
|
|
12
|
+
* // Use in <img> tag
|
|
13
|
+
* <img src={url} alt="Image" />
|
|
14
|
+
*
|
|
15
|
+
* // Cleanup when done
|
|
16
|
+
* ContentUrlConverter.revokeUrl(url);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class ContentUrlConverter {
|
|
20
|
+
private static urlCache;
|
|
21
|
+
/**
|
|
22
|
+
* Converts AIContent with data (Base64) to a Blob object.
|
|
23
|
+
*
|
|
24
|
+
* @param content - AIContent with data field
|
|
25
|
+
* @returns Blob or null if no data present
|
|
26
|
+
*/
|
|
27
|
+
static toBlob(content: AIContent): Blob | null;
|
|
28
|
+
/**
|
|
29
|
+
* Converts AIContent to a blob: URL that can be used in <img>, <audio>, <video>, etc.
|
|
30
|
+
*
|
|
31
|
+
* @param content - AIContent with data field
|
|
32
|
+
* @param cacheKey - Optional cache key for reusing URLs
|
|
33
|
+
* @returns Blob URL string or null if conversion fails
|
|
34
|
+
*/
|
|
35
|
+
static toBlobUrl(content: AIContent, cacheKey?: string): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Revokes a blob URL to free memory. Always call this when done using the URL.
|
|
38
|
+
*
|
|
39
|
+
* @param url - Blob URL to revoke
|
|
40
|
+
* @param cacheKey - Optional cache key to remove from cache
|
|
41
|
+
*/
|
|
42
|
+
static revokeUrl(url: string, cacheKey?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Clears all cached blob URLs and revokes them.
|
|
45
|
+
*/
|
|
46
|
+
static clearCache(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Downloads AIContent as a file.
|
|
49
|
+
*
|
|
50
|
+
* @param content - AIContent to download
|
|
51
|
+
* @param filename - Filename to use (defaults to "download" + extension)
|
|
52
|
+
*/
|
|
53
|
+
static downloadAsFile(content: AIContent, filename?: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the file extension from mediaType.
|
|
56
|
+
*
|
|
57
|
+
* @param mediaType - MIME type (e.g., "image/jpeg")
|
|
58
|
+
* @returns File extension (e.g., ".jpg") or empty string
|
|
59
|
+
*/
|
|
60
|
+
static getFileExtension(mediaType?: string): string;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ContentUrlConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentUrlConverter.d.ts","sourceRoot":"","sources":["../../src/utils/ContentUrlConverter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA6B;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAmB9C;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAwBtE;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAUtD;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;IASzB;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAqBlE;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;CAyBtD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentUrlConverter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for converting AIContent (base64 data) to Blob URLs for browser display.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const content: AIContent = { type: "data", data: "...", mediaType: "image/jpeg" };
|
|
10
|
+
*
|
|
11
|
+
* // Convert to Blob URL
|
|
12
|
+
* const url = ContentUrlConverter.toBlobUrl(content);
|
|
13
|
+
*
|
|
14
|
+
* // Use in <img> tag
|
|
15
|
+
* <img src={url} alt="Image" />
|
|
16
|
+
*
|
|
17
|
+
* // Cleanup when done
|
|
18
|
+
* ContentUrlConverter.revokeUrl(url);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
class ContentUrlConverter {
|
|
22
|
+
static urlCache = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Converts AIContent with data (Base64) to a Blob object.
|
|
25
|
+
*
|
|
26
|
+
* @param content - AIContent with data field
|
|
27
|
+
* @returns Blob or null if no data present
|
|
28
|
+
*/
|
|
29
|
+
static toBlob(content) {
|
|
30
|
+
if (!content.data)
|
|
31
|
+
return null;
|
|
32
|
+
try {
|
|
33
|
+
// Decode base64 to binary string
|
|
34
|
+
const byteString = atob(content.data);
|
|
35
|
+
const bytes = new Uint8Array(byteString.length);
|
|
36
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
37
|
+
bytes[i] = byteString.charCodeAt(i);
|
|
38
|
+
}
|
|
39
|
+
return new Blob([bytes], { type: content.mediaType || 'application/octet-stream' });
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to decode base64 data:', error);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts AIContent to a blob: URL that can be used in <img>, <audio>, <video>, etc.
|
|
48
|
+
*
|
|
49
|
+
* @param content - AIContent with data field
|
|
50
|
+
* @param cacheKey - Optional cache key for reusing URLs
|
|
51
|
+
* @returns Blob URL string or null if conversion fails
|
|
52
|
+
*/
|
|
53
|
+
static toBlobUrl(content, cacheKey) {
|
|
54
|
+
// For text content, return null (not displayable as media)
|
|
55
|
+
if (content.type === 'text') {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
// Check cache first
|
|
59
|
+
if (cacheKey && this.urlCache.has(cacheKey)) {
|
|
60
|
+
return this.urlCache.get(cacheKey);
|
|
61
|
+
}
|
|
62
|
+
const blob = this.toBlob(content);
|
|
63
|
+
if (!blob)
|
|
64
|
+
return null;
|
|
65
|
+
const url = URL.createObjectURL(blob);
|
|
66
|
+
// Store in cache if key provided
|
|
67
|
+
if (cacheKey) {
|
|
68
|
+
this.urlCache.set(cacheKey, url);
|
|
69
|
+
}
|
|
70
|
+
return url;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Revokes a blob URL to free memory. Always call this when done using the URL.
|
|
74
|
+
*
|
|
75
|
+
* @param url - Blob URL to revoke
|
|
76
|
+
* @param cacheKey - Optional cache key to remove from cache
|
|
77
|
+
*/
|
|
78
|
+
static revokeUrl(url, cacheKey) {
|
|
79
|
+
if (url.startsWith('blob:')) {
|
|
80
|
+
URL.revokeObjectURL(url);
|
|
81
|
+
}
|
|
82
|
+
if (cacheKey) {
|
|
83
|
+
this.urlCache.delete(cacheKey);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clears all cached blob URLs and revokes them.
|
|
88
|
+
*/
|
|
89
|
+
static clearCache() {
|
|
90
|
+
this.urlCache.forEach(url => {
|
|
91
|
+
if (url.startsWith('blob:')) {
|
|
92
|
+
URL.revokeObjectURL(url);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.urlCache.clear();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Downloads AIContent as a file.
|
|
99
|
+
*
|
|
100
|
+
* @param content - AIContent to download
|
|
101
|
+
* @param filename - Filename to use (defaults to "download" + extension)
|
|
102
|
+
*/
|
|
103
|
+
static downloadAsFile(content, filename) {
|
|
104
|
+
const blob = this.toBlob(content);
|
|
105
|
+
if (!blob) {
|
|
106
|
+
console.error('Cannot download: no blob data');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const url = URL.createObjectURL(blob);
|
|
110
|
+
const a = document.createElement('a');
|
|
111
|
+
a.href = url;
|
|
112
|
+
// Generate filename with proper extension
|
|
113
|
+
const extension = this.getFileExtension(content.mediaType);
|
|
114
|
+
a.download = filename || `download${extension}`;
|
|
115
|
+
document.body.appendChild(a);
|
|
116
|
+
a.click();
|
|
117
|
+
document.body.removeChild(a);
|
|
118
|
+
URL.revokeObjectURL(url);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Gets the file extension from mediaType.
|
|
122
|
+
*
|
|
123
|
+
* @param mediaType - MIME type (e.g., "image/jpeg")
|
|
124
|
+
* @returns File extension (e.g., ".jpg") or empty string
|
|
125
|
+
*/
|
|
126
|
+
static getFileExtension(mediaType) {
|
|
127
|
+
if (!mediaType)
|
|
128
|
+
return '';
|
|
129
|
+
const extensionMap = {
|
|
130
|
+
'image/jpeg': '.jpg',
|
|
131
|
+
'image/png': '.png',
|
|
132
|
+
'image/gif': '.gif',
|
|
133
|
+
'image/webp': '.webp',
|
|
134
|
+
'image/svg+xml': '.svg',
|
|
135
|
+
'audio/mpeg': '.mp3',
|
|
136
|
+
'audio/wav': '.wav',
|
|
137
|
+
'audio/ogg': '.ogg',
|
|
138
|
+
'video/mp4': '.mp4',
|
|
139
|
+
'video/webm': '.webm',
|
|
140
|
+
'video/ogg': '.ogv',
|
|
141
|
+
'application/pdf': '.pdf',
|
|
142
|
+
'application/json': '.json',
|
|
143
|
+
'text/plain': '.txt',
|
|
144
|
+
'text/html': '.html',
|
|
145
|
+
'text/css': '.css',
|
|
146
|
+
'application/javascript': '.js',
|
|
147
|
+
};
|
|
148
|
+
return extensionMap[mediaType] || '';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.ContentUrlConverter = ContentUrlConverter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rystem.playframework.client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"author": "Alessandro Rapiti <alessandro.rapiti44@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "TypeScript client for Rystem PlayFramework HTTP API with step-by-step and token-level streaming support.",
|