@alquimia-ai/tools 2.1.0 → 2.2.0
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/adapters/fetch.d.mts +1 -0
- package/dist/adapters/fetch.d.ts +1 -0
- package/dist/adapters/fetch.js +3 -1
- package/dist/adapters/fetch.js.map +1 -1
- package/dist/adapters/fetch.mjs +3 -1
- package/dist/adapters/fetch.mjs.map +1 -1
- package/dist/adapters/next.d.mts +1 -0
- package/dist/adapters/next.d.ts +1 -0
- package/dist/adapters/next.js +3 -1
- package/dist/adapters/next.js.map +1 -1
- package/dist/adapters/next.mjs +3 -1
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/hooks/index.d.mts +3 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +190 -21
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +171 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/types-CIqszY3g.d.mts +53 -0
- package/dist/types-CIqszY3g.d.ts +53 -0
- package/dist/worklog/index.d.mts +29 -0
- package/dist/worklog/index.d.ts +29 -0
- package/dist/worklog/index.js +218 -0
- package/dist/worklog/index.js.map +1 -0
- package/dist/worklog/index.mjs +195 -0
- package/dist/worklog/index.mjs.map +1 -0
- package/package.json +6 -1
package/dist/adapters/fetch.d.ts
CHANGED
package/dist/adapters/fetch.js
CHANGED
|
@@ -27,13 +27,15 @@ function createFetchAdapter(options) {
|
|
|
27
27
|
const inferPath = options.inferPath ?? "/chat";
|
|
28
28
|
const streamPath = options.streamPath ?? "/stream";
|
|
29
29
|
const blobUploadPath = options.blobUploadPath ?? "/blob/upload";
|
|
30
|
+
const busMode = options.busMode ?? false;
|
|
30
31
|
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
31
32
|
return {
|
|
32
33
|
resolveInferUrl(assistantId) {
|
|
33
34
|
return `${baseUrl}${inferPath}/${assistantId}`;
|
|
34
35
|
},
|
|
35
36
|
resolveStreamUrl(streamId) {
|
|
36
|
-
|
|
37
|
+
const url = `${baseUrl}${streamPath}/${streamId}`;
|
|
38
|
+
return busMode ? `${url}${url.includes("?") ? "&" : "?"}bus_mode=true` : url;
|
|
37
39
|
},
|
|
38
40
|
resolveBlobUploadUrl() {
|
|
39
41
|
return `${baseUrl}${blobUploadPath}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/fetch.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface FetchAdapterOptions {\n baseUrl: string;\n getHeaders?: () => Record<string, string>;\n inferPath?: string; // default: '/chat'\n streamPath?: string; // default: '/stream'\n blobUploadPath?: string; // default: '/blob/upload'\n}\n\nexport function createFetchAdapter(options: FetchAdapterOptions): AlquimiaAdapter {\n const inferPath = options.inferPath ?? '/chat';\n const streamPath = options.streamPath ?? '/stream';\n const blobUploadPath = options.blobUploadPath ?? '/blob/upload';\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${baseUrl}${inferPath}/${assistantId}`;\n },\n resolveStreamUrl(streamId: string): string {\n
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/fetch.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface FetchAdapterOptions {\n baseUrl: string;\n getHeaders?: () => Record<string, string>;\n inferPath?: string; // default: '/chat'\n streamPath?: string; // default: '/stream'\n blobUploadPath?: string; // default: '/blob/upload'\n busMode?: boolean; // default: false\n}\n\nexport function createFetchAdapter(options: FetchAdapterOptions): AlquimiaAdapter {\n const inferPath = options.inferPath ?? '/chat';\n const streamPath = options.streamPath ?? '/stream';\n const blobUploadPath = options.blobUploadPath ?? '/blob/upload';\n const busMode = options.busMode ?? false;\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${baseUrl}${inferPath}/${assistantId}`;\n },\n resolveStreamUrl(streamId: string): string {\n const url = `${baseUrl}${streamPath}/${streamId}`;\n return busMode ? `${url}${url.includes('?') ? '&' : '?'}bus_mode=true` : url;\n },\n resolveBlobUploadUrl(): string {\n return `${baseUrl}${blobUploadPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,mBAAmB,SAA+C;AAChF,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,iBAAiB,QAAQ,kBAAkB;AACjD,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAEjD,SAAO;AAAA,IACL,gBAAgB,aAA6B;AAC3C,aAAO,GAAG,OAAO,GAAG,SAAS,IAAI,WAAW;AAAA,IAC9C;AAAA,IACA,iBAAiB,UAA0B;AACzC,YAAM,MAAM,GAAG,OAAO,GAAG,UAAU,IAAI,QAAQ;AAC/C,aAAO,UAAU,GAAG,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,MAAM,GAAG,kBAAkB;AAAA,IAC3E;AAAA,IACA,uBAA+B;AAC7B,aAAO,GAAG,OAAO,GAAG,cAAc;AAAA,IACpC;AAAA,IACA,YAAY,QAAQ;AAAA,EACtB;AACF;","names":[]}
|
package/dist/adapters/fetch.mjs
CHANGED
|
@@ -3,13 +3,15 @@ function createFetchAdapter(options) {
|
|
|
3
3
|
const inferPath = options.inferPath ?? "/chat";
|
|
4
4
|
const streamPath = options.streamPath ?? "/stream";
|
|
5
5
|
const blobUploadPath = options.blobUploadPath ?? "/blob/upload";
|
|
6
|
+
const busMode = options.busMode ?? false;
|
|
6
7
|
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
7
8
|
return {
|
|
8
9
|
resolveInferUrl(assistantId) {
|
|
9
10
|
return `${baseUrl}${inferPath}/${assistantId}`;
|
|
10
11
|
},
|
|
11
12
|
resolveStreamUrl(streamId) {
|
|
12
|
-
|
|
13
|
+
const url = `${baseUrl}${streamPath}/${streamId}`;
|
|
14
|
+
return busMode ? `${url}${url.includes("?") ? "&" : "?"}bus_mode=true` : url;
|
|
13
15
|
},
|
|
14
16
|
resolveBlobUploadUrl() {
|
|
15
17
|
return `${baseUrl}${blobUploadPath}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/fetch.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface FetchAdapterOptions {\n baseUrl: string;\n getHeaders?: () => Record<string, string>;\n inferPath?: string; // default: '/chat'\n streamPath?: string; // default: '/stream'\n blobUploadPath?: string; // default: '/blob/upload'\n}\n\nexport function createFetchAdapter(options: FetchAdapterOptions): AlquimiaAdapter {\n const inferPath = options.inferPath ?? '/chat';\n const streamPath = options.streamPath ?? '/stream';\n const blobUploadPath = options.blobUploadPath ?? '/blob/upload';\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${baseUrl}${inferPath}/${assistantId}`;\n },\n resolveStreamUrl(streamId: string): string {\n
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/fetch.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface FetchAdapterOptions {\n baseUrl: string;\n getHeaders?: () => Record<string, string>;\n inferPath?: string; // default: '/chat'\n streamPath?: string; // default: '/stream'\n blobUploadPath?: string; // default: '/blob/upload'\n busMode?: boolean; // default: false\n}\n\nexport function createFetchAdapter(options: FetchAdapterOptions): AlquimiaAdapter {\n const inferPath = options.inferPath ?? '/chat';\n const streamPath = options.streamPath ?? '/stream';\n const blobUploadPath = options.blobUploadPath ?? '/blob/upload';\n const busMode = options.busMode ?? false;\n const baseUrl = options.baseUrl.replace(/\\/$/, '');\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${baseUrl}${inferPath}/${assistantId}`;\n },\n resolveStreamUrl(streamId: string): string {\n const url = `${baseUrl}${streamPath}/${streamId}`;\n return busMode ? `${url}${url.includes('?') ? '&' : '?'}bus_mode=true` : url;\n },\n resolveBlobUploadUrl(): string {\n return `${baseUrl}${blobUploadPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";AAWO,SAAS,mBAAmB,SAA+C;AAChF,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,iBAAiB,QAAQ,kBAAkB;AACjD,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAEjD,SAAO;AAAA,IACL,gBAAgB,aAA6B;AAC3C,aAAO,GAAG,OAAO,GAAG,SAAS,IAAI,WAAW;AAAA,IAC9C;AAAA,IACA,iBAAiB,UAA0B;AACzC,YAAM,MAAM,GAAG,OAAO,GAAG,UAAU,IAAI,QAAQ;AAC/C,aAAO,UAAU,GAAG,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,MAAM,GAAG,kBAAkB;AAAA,IAC3E;AAAA,IACA,uBAA+B;AAC7B,aAAO,GAAG,OAAO,GAAG,cAAc;AAAA,IACpC;AAAA,IACA,YAAY,QAAQ;AAAA,EACtB;AACF;","names":[]}
|
package/dist/adapters/next.d.mts
CHANGED
package/dist/adapters/next.d.ts
CHANGED
package/dist/adapters/next.js
CHANGED
|
@@ -27,12 +27,14 @@ function createNextJsAdapter(options) {
|
|
|
27
27
|
const inferRoute = options?.inferRoute ?? "/api/chat";
|
|
28
28
|
const streamRoute = options?.streamRoute ?? "/api/stream";
|
|
29
29
|
const blobUploadRoute = options?.blobUploadRoute ?? "/api/blob/upload";
|
|
30
|
+
const busMode = options?.busMode ?? false;
|
|
30
31
|
return {
|
|
31
32
|
resolveInferUrl(assistantId) {
|
|
32
33
|
return `${inferRoute.replace(/\/$/, "")}/${encodeURIComponent(assistantId)}`;
|
|
33
34
|
},
|
|
34
35
|
resolveStreamUrl(streamId) {
|
|
35
|
-
|
|
36
|
+
const url = `${streamRoute}/${streamId}`;
|
|
37
|
+
return busMode ? `${url}${url.includes("?") ? "&" : "?"}bus_mode=true` : url;
|
|
36
38
|
},
|
|
37
39
|
resolveBlobUploadUrl() {
|
|
38
40
|
return blobUploadRoute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/next.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface NextJsAdapterOptions {\n inferRoute?: string; // default: '/api/chat'\n streamRoute?: string; // default: '/api/stream'\n blobUploadRoute?: string; // default: '/api/blob/upload'\n}\n\nexport function createNextJsAdapter(options?: NextJsAdapterOptions): AlquimiaAdapter {\n const inferRoute = options?.inferRoute ?? '/api/chat';\n const streamRoute = options?.streamRoute ?? '/api/stream';\n const blobUploadRoute = options?.blobUploadRoute ?? '/api/blob/upload';\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${inferRoute.replace(/\\/$/, '')}/${encodeURIComponent(assistantId)}`;\n },\n resolveStreamUrl(streamId: string): string {\n
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/next.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface NextJsAdapterOptions {\n inferRoute?: string; // default: '/api/chat'\n streamRoute?: string; // default: '/api/stream'\n blobUploadRoute?: string; // default: '/api/blob/upload'\n busMode?: boolean; // default: false\n}\n\nexport function createNextJsAdapter(options?: NextJsAdapterOptions): AlquimiaAdapter {\n const inferRoute = options?.inferRoute ?? '/api/chat';\n const streamRoute = options?.streamRoute ?? '/api/stream';\n const blobUploadRoute = options?.blobUploadRoute ?? '/api/blob/upload';\n const busMode = options?.busMode ?? false;\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${inferRoute.replace(/\\/$/, '')}/${encodeURIComponent(assistantId)}`;\n },\n resolveStreamUrl(streamId: string): string {\n const url = `${streamRoute}/${streamId}`;\n return busMode ? `${url}${url.includes('?') ? '&' : '?'}bus_mode=true` : url;\n },\n resolveBlobUploadUrl(): string {\n return blobUploadRoute;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,oBAAoB,SAAiD;AACnF,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,cAAc,SAAS,eAAe;AAC5C,QAAM,kBAAkB,SAAS,mBAAmB;AACpD,QAAM,UAAU,SAAS,WAAW;AAEpC,SAAO;AAAA,IACL,gBAAgB,aAA6B;AAC3C,aAAO,GAAG,WAAW,QAAQ,OAAO,EAAE,CAAC,IAAI,mBAAmB,WAAW,CAAC;AAAA,IAC5E;AAAA,IACA,iBAAiB,UAA0B;AACzC,YAAM,MAAM,GAAG,WAAW,IAAI,QAAQ;AACtC,aAAO,UAAU,GAAG,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,MAAM,GAAG,kBAAkB;AAAA,IAC3E;AAAA,IACA,uBAA+B;AAC7B,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -3,12 +3,14 @@ function createNextJsAdapter(options) {
|
|
|
3
3
|
const inferRoute = options?.inferRoute ?? "/api/chat";
|
|
4
4
|
const streamRoute = options?.streamRoute ?? "/api/stream";
|
|
5
5
|
const blobUploadRoute = options?.blobUploadRoute ?? "/api/blob/upload";
|
|
6
|
+
const busMode = options?.busMode ?? false;
|
|
6
7
|
return {
|
|
7
8
|
resolveInferUrl(assistantId) {
|
|
8
9
|
return `${inferRoute.replace(/\/$/, "")}/${encodeURIComponent(assistantId)}`;
|
|
9
10
|
},
|
|
10
11
|
resolveStreamUrl(streamId) {
|
|
11
|
-
|
|
12
|
+
const url = `${streamRoute}/${streamId}`;
|
|
13
|
+
return busMode ? `${url}${url.includes("?") ? "&" : "?"}bus_mode=true` : url;
|
|
12
14
|
},
|
|
13
15
|
resolveBlobUploadUrl() {
|
|
14
16
|
return blobUploadRoute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/next.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface NextJsAdapterOptions {\n inferRoute?: string; // default: '/api/chat'\n streamRoute?: string; // default: '/api/stream'\n blobUploadRoute?: string; // default: '/api/blob/upload'\n}\n\nexport function createNextJsAdapter(options?: NextJsAdapterOptions): AlquimiaAdapter {\n const inferRoute = options?.inferRoute ?? '/api/chat';\n const streamRoute = options?.streamRoute ?? '/api/stream';\n const blobUploadRoute = options?.blobUploadRoute ?? '/api/blob/upload';\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${inferRoute.replace(/\\/$/, '')}/${encodeURIComponent(assistantId)}`;\n },\n resolveStreamUrl(streamId: string): string {\n
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/next.ts"],"sourcesContent":["import type { AlquimiaAdapter } from './index';\n\nexport interface NextJsAdapterOptions {\n inferRoute?: string; // default: '/api/chat'\n streamRoute?: string; // default: '/api/stream'\n blobUploadRoute?: string; // default: '/api/blob/upload'\n busMode?: boolean; // default: false\n}\n\nexport function createNextJsAdapter(options?: NextJsAdapterOptions): AlquimiaAdapter {\n const inferRoute = options?.inferRoute ?? '/api/chat';\n const streamRoute = options?.streamRoute ?? '/api/stream';\n const blobUploadRoute = options?.blobUploadRoute ?? '/api/blob/upload';\n const busMode = options?.busMode ?? false;\n\n return {\n resolveInferUrl(assistantId: string): string {\n return `${inferRoute.replace(/\\/$/, '')}/${encodeURIComponent(assistantId)}`;\n },\n resolveStreamUrl(streamId: string): string {\n const url = `${streamRoute}/${streamId}`;\n return busMode ? `${url}${url.includes('?') ? '&' : '?'}bus_mode=true` : url;\n },\n resolveBlobUploadUrl(): string {\n return blobUploadRoute;\n },\n };\n}\n"],"mappings":";AASO,SAAS,oBAAoB,SAAiD;AACnF,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,cAAc,SAAS,eAAe;AAC5C,QAAM,kBAAkB,SAAS,mBAAmB;AACpD,QAAM,UAAU,SAAS,WAAW;AAEpC,SAAO;AAAA,IACL,gBAAgB,aAA6B;AAC3C,aAAO,GAAG,WAAW,QAAQ,OAAO,EAAE,CAAC,IAAI,mBAAmB,WAAW,CAAC;AAAA,IAC5E;AAAA,IACA,iBAAiB,UAA0B;AACzC,YAAM,MAAM,GAAG,WAAW,IAAI,QAAQ;AACtC,aAAO,UAAU,GAAG,GAAG,GAAG,IAAI,SAAS,GAAG,IAAI,MAAM,GAAG,kBAAkB;AAAA,IAC3E;AAAA,IACA,uBAA+B;AAC7B,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ import { AlquimiaAdapter } from '../adapters/index.mjs';
|
|
|
4
4
|
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-0Gi78uNQ.mjs';
|
|
5
5
|
import { AlquimiaMessage, ToolEvent, AIMessageChunk, RatingData } from '../types/index.mjs';
|
|
6
6
|
import { createMessageId } from '../utils/index.mjs';
|
|
7
|
+
import { W as WorklogState } from '../types-CIqszY3g.mjs';
|
|
7
8
|
import '@elastic/apm-rum';
|
|
8
9
|
import 'ai';
|
|
9
10
|
|
|
@@ -21,6 +22,7 @@ interface UseAlquimiaConfig {
|
|
|
21
22
|
enforceCharacterization?: boolean;
|
|
22
23
|
userId?: string;
|
|
23
24
|
extraInstructions?: Record<string, string>;
|
|
25
|
+
worklog?: boolean;
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
@@ -56,6 +58,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
|
56
58
|
setLastRequest: react.Dispatch<react.SetStateAction<string | null>>;
|
|
57
59
|
setIsAudioRecording: react.Dispatch<react.SetStateAction<boolean>>;
|
|
58
60
|
hasThinkings: boolean;
|
|
61
|
+
worklog: WorklogState | undefined;
|
|
59
62
|
attachments: File[];
|
|
60
63
|
addAttachment: (file: File) => void;
|
|
61
64
|
addAttachments: (files: File[]) => void;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AlquimiaAdapter } from '../adapters/index.js';
|
|
|
4
4
|
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-BJTXCtI3.js';
|
|
5
5
|
import { AlquimiaMessage, ToolEvent, AIMessageChunk, RatingData } from '../types/index.js';
|
|
6
6
|
import { createMessageId } from '../utils/index.js';
|
|
7
|
+
import { W as WorklogState } from '../types-CIqszY3g.js';
|
|
7
8
|
import '@elastic/apm-rum';
|
|
8
9
|
import 'ai';
|
|
9
10
|
|
|
@@ -21,6 +22,7 @@ interface UseAlquimiaConfig {
|
|
|
21
22
|
enforceCharacterization?: boolean;
|
|
22
23
|
userId?: string;
|
|
23
24
|
extraInstructions?: Record<string, string>;
|
|
25
|
+
worklog?: boolean;
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
@@ -56,6 +58,7 @@ declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
|
56
58
|
setLastRequest: react.Dispatch<react.SetStateAction<string | null>>;
|
|
57
59
|
setIsAudioRecording: react.Dispatch<react.SetStateAction<boolean>>;
|
|
58
60
|
hasThinkings: boolean;
|
|
61
|
+
worklog: WorklogState | undefined;
|
|
59
62
|
attachments: File[];
|
|
60
63
|
addAttachment: (file: File) => void;
|
|
61
64
|
addAttachments: (files: File[]) => void;
|
package/dist/hooks/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(hooks_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(hooks_exports);
|
|
37
37
|
|
|
38
38
|
// src/hooks/alquimia.hook.tsx
|
|
39
|
-
var
|
|
39
|
+
var import_react2 = require("react");
|
|
40
40
|
|
|
41
41
|
// src/sdk/alquimia-sdk.ts
|
|
42
42
|
var import_axios = __toESM(require("axios"));
|
|
@@ -338,9 +338,169 @@ function mergeToolEvents(initial, toolEvents) {
|
|
|
338
338
|
);
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
// src/worklog/types.ts
|
|
342
|
+
function initialWorklogState(taskId = null) {
|
|
343
|
+
return { taskId, status: "idle", answer: null, nodes: [], index: {}, raw: [] };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/worklog/registry.ts
|
|
347
|
+
var asRecord = (data) => data && typeof data === "object" ? data : {};
|
|
348
|
+
var toolTitle = (r) => {
|
|
349
|
+
const name = asRecord(r.data).name;
|
|
350
|
+
return typeof name === "string" && name.length > 0 ? `Tool: ${name}` : "Tool";
|
|
351
|
+
};
|
|
352
|
+
var agentTitle = (r) => {
|
|
353
|
+
const name = asRecord(r.data).name;
|
|
354
|
+
return typeof name === "string" && name.length > 0 ? `Agent: ${name}` : "Agent-to-agent";
|
|
355
|
+
};
|
|
356
|
+
var constTitle = (label) => () => label;
|
|
357
|
+
var EVENT_REGISTRY = {
|
|
358
|
+
// Run envelope
|
|
359
|
+
AssistantInference: { kind: "answer", role: "run-open", title: constTitle("Inference started") },
|
|
360
|
+
AssistantInferenceResponse: { kind: "answer", role: "run-close", title: constTitle("Answer") },
|
|
361
|
+
// Safeguard
|
|
362
|
+
ShieldInference: { kind: "safeguard", role: "open", title: constTitle("Safeguard") },
|
|
363
|
+
ShieldInferenceResponse: { kind: "safeguard", role: "close", title: constTitle("Safeguard") },
|
|
364
|
+
// Reasoning
|
|
365
|
+
ResponseInference: { kind: "reasoning", role: "open", title: constTitle("Reasoning") },
|
|
366
|
+
ResponseInferenceResponse: { kind: "reasoning", role: "close", title: constTitle("Reasoning") },
|
|
367
|
+
// Tools (server + subclasses) and their responses
|
|
368
|
+
ServerToolExecution: { kind: "tool", role: "open", title: toolTitle },
|
|
369
|
+
BuiltinToolExecution: { kind: "tool", role: "open", title: toolTitle },
|
|
370
|
+
UnknownToolExecution: { kind: "tool", role: "open", title: toolTitle },
|
|
371
|
+
ClientToolExecution: { kind: "tool", role: "open", title: toolTitle, pending: true },
|
|
372
|
+
ToolExecutionResponse: { kind: "tool", role: "close", title: toolTitle },
|
|
373
|
+
BuiltinToolExecutionResponse: { kind: "tool", role: "close", title: toolTitle },
|
|
374
|
+
// Tool schema discovery
|
|
375
|
+
ToolSchema: { kind: "tool", role: "open", title: constTitle("Tool schema") },
|
|
376
|
+
ToolSchemaResponse: { kind: "tool", role: "close", title: constTitle("Tool schema") },
|
|
377
|
+
// Agent-to-agent
|
|
378
|
+
A2AInference: { kind: "a2a", role: "open", title: agentTitle },
|
|
379
|
+
AgentDiscovery: { kind: "a2a", role: "open", title: constTitle("Agent discovery") },
|
|
380
|
+
AgentDiscoveryResponse: { kind: "a2a", role: "close", title: constTitle("Agent discovery") },
|
|
381
|
+
// Memory / persistence
|
|
382
|
+
ContextPersistence: { kind: "memory", role: "open", title: constTitle("Memory persistence") },
|
|
383
|
+
ContextFlush: { kind: "memory", role: "open", title: constTitle("Memory flush") },
|
|
384
|
+
ContextFlushResponse: { kind: "memory", role: "close", title: constTitle("Memory flush") },
|
|
385
|
+
// Human approval
|
|
386
|
+
HumanApprovalRequired: {
|
|
387
|
+
kind: "tool",
|
|
388
|
+
role: "open",
|
|
389
|
+
title: constTitle("Human approval required"),
|
|
390
|
+
pending: true
|
|
391
|
+
},
|
|
392
|
+
HumanApprovalRequiredResponse: { kind: "tool", role: "close", title: constTitle("Human approval") }
|
|
393
|
+
};
|
|
394
|
+
function resolveInterpreter(eventClass) {
|
|
395
|
+
if (Object.prototype.hasOwnProperty.call(EVENT_REGISTRY, eventClass)) {
|
|
396
|
+
return EVENT_REGISTRY[eventClass];
|
|
397
|
+
}
|
|
398
|
+
return {
|
|
399
|
+
kind: "unknown",
|
|
400
|
+
role: "open",
|
|
401
|
+
title: (r) => r.event_class
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/worklog/reducer.ts
|
|
406
|
+
var asString = (v) => typeof v === "string" ? v : v == null ? "" : JSON.stringify(v);
|
|
407
|
+
var nodeDepth = (record) => {
|
|
408
|
+
const d = record.data && typeof record.data === "object" ? record.data.depth : void 0;
|
|
409
|
+
return typeof d === "number" ? d : 0;
|
|
410
|
+
};
|
|
411
|
+
var makeOpenNode = (record, interp, id) => ({
|
|
412
|
+
id,
|
|
413
|
+
kind: interp.kind,
|
|
414
|
+
eventClass: record.event_class,
|
|
415
|
+
status: interp.pending ? "pending" : "running",
|
|
416
|
+
title: interp.title(record),
|
|
417
|
+
startedAt: record.date_submitted,
|
|
418
|
+
depth: nodeDepth(record),
|
|
419
|
+
children: [],
|
|
420
|
+
command: record.data,
|
|
421
|
+
raw: [record]
|
|
422
|
+
});
|
|
423
|
+
var makeClosedNode = (record, interp, id) => ({
|
|
424
|
+
id,
|
|
425
|
+
kind: interp.kind,
|
|
426
|
+
eventClass: record.event_class,
|
|
427
|
+
status: record.status === "error" ? "failed" : "completed",
|
|
428
|
+
title: interp.title(record),
|
|
429
|
+
startedAt: record.date_submitted,
|
|
430
|
+
endedAt: record.date_submitted,
|
|
431
|
+
depth: nodeDepth(record),
|
|
432
|
+
children: [],
|
|
433
|
+
response: record.data,
|
|
434
|
+
error: record.status === "error" ? asString(record.data) : void 0,
|
|
435
|
+
raw: [record]
|
|
436
|
+
});
|
|
437
|
+
function reduceWorklog(state, record) {
|
|
438
|
+
const interp = resolveInterpreter(record.event_class);
|
|
439
|
+
const next = {
|
|
440
|
+
...state,
|
|
441
|
+
nodes: state.nodes.slice(),
|
|
442
|
+
index: { ...state.index },
|
|
443
|
+
raw: [...state.raw, record]
|
|
444
|
+
};
|
|
445
|
+
if (interp.role === "ignore") return next;
|
|
446
|
+
if (interp.role === "run-open") {
|
|
447
|
+
next.status = "running";
|
|
448
|
+
return next;
|
|
449
|
+
}
|
|
450
|
+
if (interp.role === "run-close") {
|
|
451
|
+
next.answer = asString(record.data) || null;
|
|
452
|
+
next.status = record.status === "error" ? "error" : "success";
|
|
453
|
+
return next;
|
|
454
|
+
}
|
|
455
|
+
const key = record.control_id ?? `${record.event_class}-${next.raw.length}`;
|
|
456
|
+
if (interp.role === "close") {
|
|
457
|
+
const pos2 = Object.prototype.hasOwnProperty.call(next.index, key) ? next.index[key] : void 0;
|
|
458
|
+
if (pos2 != null) {
|
|
459
|
+
const existing = next.nodes[pos2];
|
|
460
|
+
next.nodes[pos2] = {
|
|
461
|
+
...existing,
|
|
462
|
+
status: record.status === "error" ? "failed" : "completed",
|
|
463
|
+
endedAt: record.date_submitted,
|
|
464
|
+
response: record.data,
|
|
465
|
+
error: record.status === "error" ? asString(record.data) : existing.error,
|
|
466
|
+
raw: [...existing.raw, record]
|
|
467
|
+
};
|
|
468
|
+
} else {
|
|
469
|
+
next.index[key] = next.nodes.length;
|
|
470
|
+
next.nodes.push(makeClosedNode(record, interp, key));
|
|
471
|
+
}
|
|
472
|
+
if (record.status === "error") next.status = "error";
|
|
473
|
+
return next;
|
|
474
|
+
}
|
|
475
|
+
const pos = Object.prototype.hasOwnProperty.call(next.index, key) ? next.index[key] : void 0;
|
|
476
|
+
if (pos != null) {
|
|
477
|
+
const existing = next.nodes[pos];
|
|
478
|
+
next.nodes[pos] = { ...existing, raw: [...existing.raw, record] };
|
|
479
|
+
} else {
|
|
480
|
+
next.index[key] = next.nodes.length;
|
|
481
|
+
next.nodes.push(makeOpenNode(record, interp, key));
|
|
482
|
+
}
|
|
483
|
+
return next;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/worklog/use-worklog.ts
|
|
487
|
+
var import_react = require("react");
|
|
488
|
+
|
|
489
|
+
// src/worklog/from-frame.ts
|
|
490
|
+
function frameToRecord(frame) {
|
|
491
|
+
const status = frame.status === "success" || frame.status === "error" ? frame.status : null;
|
|
492
|
+
return {
|
|
493
|
+
event_class: typeof frame.event_class === "string" && frame.event_class.length > 0 ? frame.event_class : "Unknown",
|
|
494
|
+
control_id: frame.control_id ?? null,
|
|
495
|
+
data: frame.data,
|
|
496
|
+
status,
|
|
497
|
+
date_submitted: typeof frame.date_submitted === "string" ? frame.date_submitted : ""
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
341
501
|
// src/hooks/alquimia.hook.tsx
|
|
342
502
|
function useAlquimia(config) {
|
|
343
|
-
const sdk = (0,
|
|
503
|
+
const sdk = (0, import_react2.useMemo)(() => {
|
|
344
504
|
const instance = new alquimia_sdk_default(config.assistantId, config.adapter, {
|
|
345
505
|
enforceCharacterization: config.options?.enforceCharacterization
|
|
346
506
|
});
|
|
@@ -353,21 +513,25 @@ function useAlquimia(config) {
|
|
|
353
513
|
if (config.options?.extraInstructions) instance.withExtraInstructions(config.options.extraInstructions);
|
|
354
514
|
return instance;
|
|
355
515
|
}, [config.assistantId, config.adapter]);
|
|
356
|
-
const [input, setInput] = (0,
|
|
357
|
-
const [isMessageLoading, setIsMessageLoading] = (0,
|
|
358
|
-
const [isStreamingLoading, setIsStreamingLoading] = (0,
|
|
359
|
-
const [isMessageStreaming, setIsMessageStreaming] = (0,
|
|
360
|
-
const [streamingMessageId, setStreamingMessageId] = (0,
|
|
361
|
-
const [isAudioRecording, setIsAudioRecording] = (0,
|
|
362
|
-
const [messages, setMessages] = (0,
|
|
363
|
-
const eventSourceRef = (0,
|
|
364
|
-
const streamUserCancelledRef = (0,
|
|
365
|
-
const [sessionId, setSessionId] = (0,
|
|
366
|
-
const [activeTool, setActiveTool] = (0,
|
|
367
|
-
const [lastRequest, setLastRequest] = (0,
|
|
368
|
-
const [hasThinkings, setHasThinkings] = (0,
|
|
369
|
-
const
|
|
370
|
-
const [
|
|
516
|
+
const [input, setInput] = (0, import_react2.useState)("");
|
|
517
|
+
const [isMessageLoading, setIsMessageLoading] = (0, import_react2.useState)(false);
|
|
518
|
+
const [isStreamingLoading, setIsStreamingLoading] = (0, import_react2.useState)(false);
|
|
519
|
+
const [isMessageStreaming, setIsMessageStreaming] = (0, import_react2.useState)(false);
|
|
520
|
+
const [streamingMessageId, setStreamingMessageId] = (0, import_react2.useState)(null);
|
|
521
|
+
const [isAudioRecording, setIsAudioRecording] = (0, import_react2.useState)(false);
|
|
522
|
+
const [messages, setMessages] = (0, import_react2.useState)([]);
|
|
523
|
+
const eventSourceRef = (0, import_react2.useRef)(null);
|
|
524
|
+
const streamUserCancelledRef = (0, import_react2.useRef)(false);
|
|
525
|
+
const [sessionId, setSessionId] = (0, import_react2.useState)(null);
|
|
526
|
+
const [activeTool, setActiveTool] = (0, import_react2.useState)(null);
|
|
527
|
+
const [lastRequest, setLastRequest] = (0, import_react2.useState)(null);
|
|
528
|
+
const [hasThinkings, setHasThinkings] = (0, import_react2.useState)(false);
|
|
529
|
+
const worklogEnabled = config.options?.worklog ?? false;
|
|
530
|
+
const [worklog, setWorklog] = (0, import_react2.useState)(
|
|
531
|
+
worklogEnabled ? initialWorklogState() : void 0
|
|
532
|
+
);
|
|
533
|
+
const [attachments, setAttachments] = (0, import_react2.useState)([]);
|
|
534
|
+
const [isUploadingAttachments, setIsUploadingAttachments] = (0, import_react2.useState)(false);
|
|
371
535
|
const isLoading = isMessageLoading || isStreamingLoading || isUploadingAttachments;
|
|
372
536
|
function cleanMessages() {
|
|
373
537
|
setMessages([]);
|
|
@@ -571,6 +735,7 @@ function useAlquimia(config) {
|
|
|
571
735
|
lastMessageAt: null,
|
|
572
736
|
closedByClient: false
|
|
573
737
|
};
|
|
738
|
+
if (worklogEnabled) setWorklog(initialWorklogState());
|
|
574
739
|
const eventSource = new EventSource(streamUrl);
|
|
575
740
|
eventSourceRef.current = eventSource;
|
|
576
741
|
eventSource.onopen = () => {
|
|
@@ -631,6 +796,9 @@ function useAlquimia(config) {
|
|
|
631
796
|
}
|
|
632
797
|
function handleMessageEvent(event, callBack, eventSource, streamState) {
|
|
633
798
|
const data = JSON.parse(event.data);
|
|
799
|
+
if (worklogEnabled) {
|
|
800
|
+
setWorklog((prev) => reduceWorklog(prev ?? initialWorklogState(), frameToRecord(data)));
|
|
801
|
+
}
|
|
634
802
|
const eventTaskId = data.taskid || "";
|
|
635
803
|
if (data.errors?.length) {
|
|
636
804
|
for (const error of data.errors) {
|
|
@@ -688,6 +856,7 @@ function useAlquimia(config) {
|
|
|
688
856
|
setLastRequest,
|
|
689
857
|
setIsAudioRecording,
|
|
690
858
|
hasThinkings,
|
|
859
|
+
worklog,
|
|
691
860
|
attachments,
|
|
692
861
|
addAttachment,
|
|
693
862
|
addAttachments,
|
|
@@ -698,7 +867,7 @@ function useAlquimia(config) {
|
|
|
698
867
|
}
|
|
699
868
|
|
|
700
869
|
// src/hooks/useRatings.ts
|
|
701
|
-
var
|
|
870
|
+
var import_react3 = require("react");
|
|
702
871
|
var initialState = {
|
|
703
872
|
ratingStars: 0,
|
|
704
873
|
ratingThumbs: "",
|
|
@@ -717,9 +886,9 @@ function ratingReducer(state, action) {
|
|
|
717
886
|
}
|
|
718
887
|
}
|
|
719
888
|
function useRatings({ assistantId, sendRating, topicId }) {
|
|
720
|
-
const [isLoading, setIsLoading] = (0,
|
|
721
|
-
const [hasReviewed, setHasReviewed] = (0,
|
|
722
|
-
const [state, dispatch] = (0,
|
|
889
|
+
const [isLoading, setIsLoading] = (0, import_react3.useState)(false);
|
|
890
|
+
const [hasReviewed, setHasReviewed] = (0, import_react3.useState)(false);
|
|
891
|
+
const [state, dispatch] = (0, import_react3.useReducer)(ratingReducer, initialState);
|
|
723
892
|
const setRatingStars = (rating) => {
|
|
724
893
|
dispatch({ type: "SET_RATING_STARS", payload: rating });
|
|
725
894
|
};
|