@applica-software-guru/persona-chat-sdk 0.1.108 → 0.1.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +13 -13
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +2029 -1998
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +13 -13
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +14 -14
- package/dist/bundle.umd.js.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/protocol/base.d.ts +1 -1
- package/dist/protocol/base.d.ts.map +1 -1
- package/dist/protocol/rest.d.ts +1 -1
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/protocol/transaction.d.ts +4 -4
- package/dist/protocol/transaction.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +5 -0
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/file-attachment-adapter.d.ts +1 -1
- package/dist/runtime/file-attachment-adapter.d.ts.map +1 -1
- package/dist/runtime/threads.d.ts +2 -1
- package/dist/runtime/threads.d.ts.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/storage/base.d.ts +1 -0
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/persona.d.ts +1 -0
- package/dist/storage/persona.d.ts.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/messages.ts +22 -3
- package/src/protocol/base.ts +2 -1
- package/src/protocol/rest.ts +1 -1
- package/src/protocol/transaction.ts +7 -5
- package/src/runtime/context.ts +12 -0
- package/src/runtime/file-attachment-adapter.ts +2 -1
- package/src/runtime/protocols.ts +1 -1
- package/src/runtime/threads.ts +9 -0
- package/src/runtime.tsx +13 -1
- package/src/storage/base.ts +2 -0
- package/src/storage/persona.ts +20 -12
- package/src/tools.ts +9 -1
- package/src/types.ts +4 -2
package/src/tools.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface ToolDefinition {
|
|
|
35
35
|
timeout?: number;
|
|
36
36
|
parameters: Record<string, ToolParameter>;
|
|
37
37
|
output: Record<string, ToolParameter>;
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
39
|
implementation: (...args: any[]) => any;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -62,7 +63,8 @@ export function createParameter(
|
|
|
62
63
|
*/
|
|
63
64
|
export function generateToolSchema(definition: ToolDefinition): ToolSchema {
|
|
64
65
|
const requiredParams = Object.entries(definition.parameters)
|
|
65
|
-
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
.filter(([_name, param]) => param.required)
|
|
66
68
|
.map(([name]) => name);
|
|
67
69
|
|
|
68
70
|
return {
|
|
@@ -86,6 +88,7 @@ export function generateToolSchema(definition: ToolDefinition): ToolSchema {
|
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
92
|
export type ToolInstance = { schema: ToolSchema; implementation: (...args: any[]) => any };
|
|
90
93
|
|
|
91
94
|
/**
|
|
@@ -102,9 +105,11 @@ export function createTool(definition: ToolDefinition): ToolInstance {
|
|
|
102
105
|
* Extract function signature and generate schema from a JavaScript function
|
|
103
106
|
* This is a utility to help convert existing functions to tool schemas
|
|
104
107
|
*/
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
109
|
export function createToolFromFunction(
|
|
106
110
|
name: string,
|
|
107
111
|
description: string,
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
113
|
fn: (...args: any[]) => any,
|
|
109
114
|
parameterTypes: Record<string, ToolParameter>,
|
|
110
115
|
outputTypes: Record<string, ToolParameter>,
|
|
@@ -166,9 +171,11 @@ export const navigateToToolExample = createTool({
|
|
|
166
171
|
// Helper function to create multiple tools at once
|
|
167
172
|
export function createToolRegistry(tools: ToolDefinition[]): {
|
|
168
173
|
schemas: ToolSchema[];
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
169
175
|
implementations: Record<string, (...args: any[]) => any>;
|
|
170
176
|
} {
|
|
171
177
|
const schemas: ToolSchema[] = [];
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
179
|
const implementations: Record<string, (...args: any[]) => any> = {};
|
|
173
180
|
|
|
174
181
|
tools.forEach((tool) => {
|
|
@@ -181,6 +188,7 @@ export function createToolRegistry(tools: ToolDefinition[]): {
|
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
// Utility to validate tool parameters at runtime
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
184
192
|
export function validateToolParameters(parameters: Record<string, any>, schema: ToolSchema): boolean {
|
|
185
193
|
const { required, properties } = schema.config.parameters;
|
|
186
194
|
|
package/src/types.ts
CHANGED
|
@@ -18,8 +18,8 @@ export type FunctionCall = {
|
|
|
18
18
|
|
|
19
19
|
export type FunctionResponse = {
|
|
20
20
|
name: string;
|
|
21
|
-
result
|
|
22
|
-
|
|
21
|
+
result?: ToolResultItem | ToolResultItem[] | null;
|
|
22
|
+
functionCallId?: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type PersonaFile = {
|
|
@@ -85,6 +85,8 @@ export type PersonaImage = {
|
|
|
85
85
|
contentType: string;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export type ToolResultItem = string | PersonaFile | PersonaImage | ReadonlyJSONObject;
|
|
89
|
+
|
|
88
90
|
export type PersonaSourceChunk = {
|
|
89
91
|
start: number;
|
|
90
92
|
end: number;
|