@alquimia-ai/tools 2.5.0 → 2.8.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/README.md +603 -23
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.d.ts +1 -1
- package/dist/adapters/fetch.d.mts +1 -0
- package/dist/adapters/fetch.d.ts +1 -0
- package/dist/adapters/fetch.js +4 -0
- package/dist/adapters/fetch.js.map +1 -1
- package/dist/adapters/fetch.mjs +4 -0
- package/dist/adapters/fetch.mjs.map +1 -1
- package/dist/adapters/index.d.mts +1 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/next.d.mts +1 -0
- package/dist/adapters/next.d.ts +1 -0
- package/dist/adapters/next.js +4 -0
- package/dist/adapters/next.js.map +1 -1
- package/dist/adapters/next.mjs +4 -0
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/approvals-CcnmqUkQ.d.ts +59 -0
- package/dist/approvals-dn4sd_Ot.d.mts +59 -0
- package/dist/hooks/index.d.mts +36 -5
- package/dist/hooks/index.d.ts +36 -5
- package/dist/hooks/index.js +269 -17
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +269 -17
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/next/index.d.mts +7 -0
- package/dist/next/index.d.ts +7 -0
- package/dist/next/index.js +56 -37
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +56 -37
- package/dist/next/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/{providers-b5_yMyMo.d.ts → providers-J_Z9rQ3Q.d.ts} +1 -1
- package/dist/{providers-DiR9cgyo.d.mts → providers-YKiEag2L.d.mts} +1 -1
- package/dist/proxy.d.mts +2 -0
- package/dist/proxy.d.ts +2 -0
- package/dist/proxy.js +47 -37
- package/dist/proxy.js.map +1 -1
- package/dist/proxy.mjs +47 -37
- package/dist/proxy.mjs.map +1 -1
- package/dist/sdk/index.d.mts +60 -5
- package/dist/sdk/index.d.ts +60 -5
- package/dist/sdk/index.js +115 -15
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +115 -15
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/{type-xksRnBUW.d.ts → type-BFtGEEb4.d.ts} +45 -1
- package/dist/{type-DqX3-9QS.d.mts → type-C_sKpIM1.d.mts} +45 -1
- package/dist/types/index.d.mts +28 -5
- package/dist/types/index.d.ts +28 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/{types-C-6fgK1_.d.mts → types-lOliroPw.d.mts} +1 -1
- package/dist/{types-C-6fgK1_.d.ts → types-lOliroPw.d.ts} +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/worklog/index.d.mts +3 -2
- package/dist/worklog/index.d.ts +3 -2
- package/dist/worklog/index.js +94 -2
- package/dist/worklog/index.js.map +1 -1
- package/dist/worklog/index.mjs +94 -2
- package/dist/worklog/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/fetch.js
CHANGED
|
@@ -28,6 +28,7 @@ function createFetchAdapter(options) {
|
|
|
28
28
|
const streamPath = options.streamPath ?? "/stream";
|
|
29
29
|
const blobUploadPath = options.blobUploadPath ?? "/blob/upload";
|
|
30
30
|
const toolCompletionPath = options.toolCompletionPath ?? "/tool-completion";
|
|
31
|
+
const toolApprovalPath = options.toolApprovalPath ?? "/tool-approval";
|
|
31
32
|
const busMode = options.busMode ?? false;
|
|
32
33
|
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
33
34
|
return {
|
|
@@ -44,6 +45,9 @@ function createFetchAdapter(options) {
|
|
|
44
45
|
resolveToolCompletionUrl() {
|
|
45
46
|
return `${baseUrl}${toolCompletionPath}`;
|
|
46
47
|
},
|
|
48
|
+
resolveToolApprovalUrl() {
|
|
49
|
+
return `${baseUrl}${toolApprovalPath}`;
|
|
50
|
+
},
|
|
47
51
|
getHeaders: options.getHeaders
|
|
48
52
|
};
|
|
49
53
|
}
|
|
@@ -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 toolCompletionPath?: string; // default: '/tool-completion'\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 toolCompletionPath = options.toolCompletionPath ?? '/tool-completion';\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 resolveToolCompletionUrl(): string {\n return `${baseUrl}${toolCompletionPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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 toolCompletionPath?: string; // default: '/tool-completion'\n toolApprovalPath?: string; // default: '/tool-approval'\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 toolCompletionPath = options.toolCompletionPath ?? '/tool-completion';\n const toolApprovalPath = options.toolApprovalPath ?? '/tool-approval';\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 resolveToolCompletionUrl(): string {\n return `${baseUrl}${toolCompletionPath}`;\n },\n resolveToolApprovalUrl(): string {\n return `${baseUrl}${toolApprovalPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,mBAAmB,SAA+C;AAChF,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,iBAAiB,QAAQ,kBAAkB;AACjD,QAAM,qBAAqB,QAAQ,sBAAsB;AACzD,QAAM,mBAAmB,QAAQ,oBAAoB;AACrD,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,2BAAmC;AACjC,aAAO,GAAG,OAAO,GAAG,kBAAkB;AAAA,IACxC;AAAA,IACA,yBAAiC;AAC/B,aAAO,GAAG,OAAO,GAAG,gBAAgB;AAAA,IACtC;AAAA,IACA,YAAY,QAAQ;AAAA,EACtB;AACF;","names":[]}
|
package/dist/adapters/fetch.mjs
CHANGED
|
@@ -4,6 +4,7 @@ function createFetchAdapter(options) {
|
|
|
4
4
|
const streamPath = options.streamPath ?? "/stream";
|
|
5
5
|
const blobUploadPath = options.blobUploadPath ?? "/blob/upload";
|
|
6
6
|
const toolCompletionPath = options.toolCompletionPath ?? "/tool-completion";
|
|
7
|
+
const toolApprovalPath = options.toolApprovalPath ?? "/tool-approval";
|
|
7
8
|
const busMode = options.busMode ?? false;
|
|
8
9
|
const baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
9
10
|
return {
|
|
@@ -20,6 +21,9 @@ function createFetchAdapter(options) {
|
|
|
20
21
|
resolveToolCompletionUrl() {
|
|
21
22
|
return `${baseUrl}${toolCompletionPath}`;
|
|
22
23
|
},
|
|
24
|
+
resolveToolApprovalUrl() {
|
|
25
|
+
return `${baseUrl}${toolApprovalPath}`;
|
|
26
|
+
},
|
|
23
27
|
getHeaders: options.getHeaders
|
|
24
28
|
};
|
|
25
29
|
}
|
|
@@ -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 toolCompletionPath?: string; // default: '/tool-completion'\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 toolCompletionPath = options.toolCompletionPath ?? '/tool-completion';\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 resolveToolCompletionUrl(): string {\n return `${baseUrl}${toolCompletionPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";
|
|
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 toolCompletionPath?: string; // default: '/tool-completion'\n toolApprovalPath?: string; // default: '/tool-approval'\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 toolCompletionPath = options.toolCompletionPath ?? '/tool-completion';\n const toolApprovalPath = options.toolApprovalPath ?? '/tool-approval';\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 resolveToolCompletionUrl(): string {\n return `${baseUrl}${toolCompletionPath}`;\n },\n resolveToolApprovalUrl(): string {\n return `${baseUrl}${toolApprovalPath}`;\n },\n getHeaders: options.getHeaders,\n };\n}\n"],"mappings":";AAaO,SAAS,mBAAmB,SAA+C;AAChF,QAAM,YAAY,QAAQ,aAAa;AACvC,QAAM,aAAa,QAAQ,cAAc;AACzC,QAAM,iBAAiB,QAAQ,kBAAkB;AACjD,QAAM,qBAAqB,QAAQ,sBAAsB;AACzD,QAAM,mBAAmB,QAAQ,oBAAoB;AACrD,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,2BAAmC;AACjC,aAAO,GAAG,OAAO,GAAG,kBAAkB;AAAA,IACxC;AAAA,IACA,yBAAiC;AAC/B,aAAO,GAAG,OAAO,GAAG,gBAAgB;AAAA,IACtC;AAAA,IACA,YAAY,QAAQ;AAAA,EACtB;AACF;","names":[]}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export interface AlquimiaAdapter {\n resolveInferUrl(_assistantId: string): string;\n resolveStreamUrl(_streamId: string): string;\n resolveBlobUploadUrl(): string;\n resolveToolCompletionUrl?(): string;\n getHeaders?(): Record<string, string>;\n}\n\nexport interface AlquimiaSDKOptions {\n enforceCharacterization?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/index.ts"],"sourcesContent":["export interface AlquimiaAdapter {\n resolveInferUrl(_assistantId: string): string;\n resolveStreamUrl(_streamId: string): string;\n resolveBlobUploadUrl(): string;\n resolveToolCompletionUrl?(): string;\n resolveToolApprovalUrl?(): string;\n getHeaders?(): Record<string, string>;\n}\n\nexport interface AlquimiaSDKOptions {\n enforceCharacterization?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/adapters/next.d.mts
CHANGED
package/dist/adapters/next.d.ts
CHANGED
package/dist/adapters/next.js
CHANGED
|
@@ -28,6 +28,7 @@ function createNextJsAdapter(options) {
|
|
|
28
28
|
const streamRoute = options?.streamRoute ?? "/api/stream";
|
|
29
29
|
const blobUploadRoute = options?.blobUploadRoute ?? "/api/blob/upload";
|
|
30
30
|
const toolCompletionRoute = options?.toolCompletionRoute ?? "/api/tool-completion";
|
|
31
|
+
const toolApprovalRoute = options?.toolApprovalRoute ?? "/api/tool-approval";
|
|
31
32
|
const busMode = options?.busMode ?? false;
|
|
32
33
|
return {
|
|
33
34
|
resolveInferUrl(assistantId) {
|
|
@@ -42,6 +43,9 @@ function createNextJsAdapter(options) {
|
|
|
42
43
|
},
|
|
43
44
|
resolveToolCompletionUrl() {
|
|
44
45
|
return toolCompletionRoute;
|
|
46
|
+
},
|
|
47
|
+
resolveToolApprovalUrl() {
|
|
48
|
+
return toolApprovalRoute;
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
51
|
}
|
|
@@ -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 toolCompletionRoute?: string; // default: '/api/tool-completion'\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 toolCompletionRoute = options?.toolCompletionRoute ?? '/api/tool-completion';\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 resolveToolCompletionUrl(): string {\n return toolCompletionRoute;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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 toolCompletionRoute?: string; // default: '/api/tool-completion'\n toolApprovalRoute?: string; // default: '/api/tool-approval'\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 toolCompletionRoute = options?.toolCompletionRoute ?? '/api/tool-completion';\n const toolApprovalRoute = options?.toolApprovalRoute ?? '/api/tool-approval';\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 resolveToolCompletionUrl(): string {\n return toolCompletionRoute;\n },\n resolveToolApprovalUrl(): string {\n return toolApprovalRoute;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,oBAAoB,SAAiD;AACnF,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,cAAc,SAAS,eAAe;AAC5C,QAAM,kBAAkB,SAAS,mBAAmB;AACpD,QAAM,sBAAsB,SAAS,uBAAuB;AAC5D,QAAM,oBAAoB,SAAS,qBAAqB;AACxD,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,IACA,2BAAmC;AACjC,aAAO;AAAA,IACT;AAAA,IACA,yBAAiC;AAC/B,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -4,6 +4,7 @@ function createNextJsAdapter(options) {
|
|
|
4
4
|
const streamRoute = options?.streamRoute ?? "/api/stream";
|
|
5
5
|
const blobUploadRoute = options?.blobUploadRoute ?? "/api/blob/upload";
|
|
6
6
|
const toolCompletionRoute = options?.toolCompletionRoute ?? "/api/tool-completion";
|
|
7
|
+
const toolApprovalRoute = options?.toolApprovalRoute ?? "/api/tool-approval";
|
|
7
8
|
const busMode = options?.busMode ?? false;
|
|
8
9
|
return {
|
|
9
10
|
resolveInferUrl(assistantId) {
|
|
@@ -18,6 +19,9 @@ function createNextJsAdapter(options) {
|
|
|
18
19
|
},
|
|
19
20
|
resolveToolCompletionUrl() {
|
|
20
21
|
return toolCompletionRoute;
|
|
22
|
+
},
|
|
23
|
+
resolveToolApprovalUrl() {
|
|
24
|
+
return toolApprovalRoute;
|
|
21
25
|
}
|
|
22
26
|
};
|
|
23
27
|
}
|
|
@@ -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 toolCompletionRoute?: string; // default: '/api/tool-completion'\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 toolCompletionRoute = options?.toolCompletionRoute ?? '/api/tool-completion';\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 resolveToolCompletionUrl(): string {\n return toolCompletionRoute;\n },\n };\n}\n"],"mappings":";
|
|
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 toolCompletionRoute?: string; // default: '/api/tool-completion'\n toolApprovalRoute?: string; // default: '/api/tool-approval'\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 toolCompletionRoute = options?.toolCompletionRoute ?? '/api/tool-completion';\n const toolApprovalRoute = options?.toolApprovalRoute ?? '/api/tool-approval';\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 resolveToolCompletionUrl(): string {\n return toolCompletionRoute;\n },\n resolveToolApprovalUrl(): string {\n return toolApprovalRoute;\n },\n };\n}\n"],"mappings":";AAWO,SAAS,oBAAoB,SAAiD;AACnF,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,cAAc,SAAS,eAAe;AAC5C,QAAM,kBAAkB,SAAS,mBAAmB;AACpD,QAAM,sBAAsB,SAAS,uBAAuB;AAC5D,QAAM,oBAAoB,SAAS,qBAAqB;AACxD,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,IACA,2BAAmC;AACjC,aAAO;AAAA,IACT;AAAA,IACA,yBAAiC;AAC/B,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { W as WorklogRecord } from './types-lOliroPw.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Human-approval gates, derived from the worklog.
|
|
5
|
+
*
|
|
6
|
+
* When the runtime's authz policy resolves a tool call to `REQUIRE_APPROVAL`,
|
|
7
|
+
* core parks the call and records a `HumanApprovalRequired` whose `data` is the
|
|
8
|
+
* command minus its conversation: `{ parameters: <the tool execution> }`. The
|
|
9
|
+
* gate closes with a `HumanApprovalRequiredResponse` under the same
|
|
10
|
+
* `control_id`, whichever channel the decision came through — so the stream,
|
|
11
|
+
* not the local submit, is the source of truth for "settled".
|
|
12
|
+
*/
|
|
13
|
+
/** A decision as the worklog records it. */
|
|
14
|
+
interface ApprovalDecision {
|
|
15
|
+
approved: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Rejection reason. Core records `result or message` as the response data,
|
|
18
|
+
* so an approval never carries one and a rejection carries the reason when
|
|
19
|
+
* the approver gave it.
|
|
20
|
+
*/
|
|
21
|
+
reason: string | null;
|
|
22
|
+
decidedAt: string;
|
|
23
|
+
}
|
|
24
|
+
/** One approval gate, pending or settled. */
|
|
25
|
+
interface ApprovalRequest {
|
|
26
|
+
/** The `HumanApprovalRequired` control id — the one `/event/tool-approval` expects. */
|
|
27
|
+
controlId: string;
|
|
28
|
+
/** Name of the parked tool call; `null` until the request record is seen. */
|
|
29
|
+
toolName: string | null;
|
|
30
|
+
/** Control id of the parked tool execution itself (distinct from `controlId`). */
|
|
31
|
+
toolCallId: string | null;
|
|
32
|
+
/** Arguments the tool would be called with. What is actually being approved. */
|
|
33
|
+
arguments: unknown;
|
|
34
|
+
/**
|
|
35
|
+
* The gate belongs to an MCP server that runs its own approval over the
|
|
36
|
+
* task's originating channel (the `mcp_approval` runtime extension). The
|
|
37
|
+
* runtime refuses an HTTP decision for it with a 409, so offering buttons
|
|
38
|
+
* would be a lie.
|
|
39
|
+
*/
|
|
40
|
+
channelOwned: boolean;
|
|
41
|
+
requestedAt: string | null;
|
|
42
|
+
/** `null` while pending. */
|
|
43
|
+
decision: ApprovalDecision | null;
|
|
44
|
+
}
|
|
45
|
+
interface ApprovalsState {
|
|
46
|
+
/** Gates in the order they were first seen. */
|
|
47
|
+
order: string[];
|
|
48
|
+
byId: Record<string, ApprovalRequest>;
|
|
49
|
+
}
|
|
50
|
+
declare function initialApprovalsState(): ApprovalsState;
|
|
51
|
+
/** Fold one worklog record into the approvals state. Records of other classes are a no-op. */
|
|
52
|
+
declare function reduceApprovals(state: ApprovalsState, record: WorklogRecord): ApprovalsState;
|
|
53
|
+
declare function foldApprovals(records: WorklogRecord[]): ApprovalsState;
|
|
54
|
+
/** All gates, in first-seen order. */
|
|
55
|
+
declare function listApprovals(state: ApprovalsState): ApprovalRequest[];
|
|
56
|
+
/** Gates with no recorded decision yet. */
|
|
57
|
+
declare function pendingApprovals(state: ApprovalsState): ApprovalRequest[];
|
|
58
|
+
|
|
59
|
+
export { type ApprovalRequest as A, type ApprovalDecision as a, type ApprovalsState as b, foldApprovals as f, initialApprovalsState as i, listApprovals as l, pendingApprovals as p, reduceApprovals as r };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { W as WorklogRecord } from './types-lOliroPw.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Human-approval gates, derived from the worklog.
|
|
5
|
+
*
|
|
6
|
+
* When the runtime's authz policy resolves a tool call to `REQUIRE_APPROVAL`,
|
|
7
|
+
* core parks the call and records a `HumanApprovalRequired` whose `data` is the
|
|
8
|
+
* command minus its conversation: `{ parameters: <the tool execution> }`. The
|
|
9
|
+
* gate closes with a `HumanApprovalRequiredResponse` under the same
|
|
10
|
+
* `control_id`, whichever channel the decision came through — so the stream,
|
|
11
|
+
* not the local submit, is the source of truth for "settled".
|
|
12
|
+
*/
|
|
13
|
+
/** A decision as the worklog records it. */
|
|
14
|
+
interface ApprovalDecision {
|
|
15
|
+
approved: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Rejection reason. Core records `result or message` as the response data,
|
|
18
|
+
* so an approval never carries one and a rejection carries the reason when
|
|
19
|
+
* the approver gave it.
|
|
20
|
+
*/
|
|
21
|
+
reason: string | null;
|
|
22
|
+
decidedAt: string;
|
|
23
|
+
}
|
|
24
|
+
/** One approval gate, pending or settled. */
|
|
25
|
+
interface ApprovalRequest {
|
|
26
|
+
/** The `HumanApprovalRequired` control id — the one `/event/tool-approval` expects. */
|
|
27
|
+
controlId: string;
|
|
28
|
+
/** Name of the parked tool call; `null` until the request record is seen. */
|
|
29
|
+
toolName: string | null;
|
|
30
|
+
/** Control id of the parked tool execution itself (distinct from `controlId`). */
|
|
31
|
+
toolCallId: string | null;
|
|
32
|
+
/** Arguments the tool would be called with. What is actually being approved. */
|
|
33
|
+
arguments: unknown;
|
|
34
|
+
/**
|
|
35
|
+
* The gate belongs to an MCP server that runs its own approval over the
|
|
36
|
+
* task's originating channel (the `mcp_approval` runtime extension). The
|
|
37
|
+
* runtime refuses an HTTP decision for it with a 409, so offering buttons
|
|
38
|
+
* would be a lie.
|
|
39
|
+
*/
|
|
40
|
+
channelOwned: boolean;
|
|
41
|
+
requestedAt: string | null;
|
|
42
|
+
/** `null` while pending. */
|
|
43
|
+
decision: ApprovalDecision | null;
|
|
44
|
+
}
|
|
45
|
+
interface ApprovalsState {
|
|
46
|
+
/** Gates in the order they were first seen. */
|
|
47
|
+
order: string[];
|
|
48
|
+
byId: Record<string, ApprovalRequest>;
|
|
49
|
+
}
|
|
50
|
+
declare function initialApprovalsState(): ApprovalsState;
|
|
51
|
+
/** Fold one worklog record into the approvals state. Records of other classes are a no-op. */
|
|
52
|
+
declare function reduceApprovals(state: ApprovalsState, record: WorklogRecord): ApprovalsState;
|
|
53
|
+
declare function foldApprovals(records: WorklogRecord[]): ApprovalsState;
|
|
54
|
+
/** All gates, in first-seen order. */
|
|
55
|
+
declare function listApprovals(state: ApprovalsState): ApprovalRequest[];
|
|
56
|
+
/** Gates with no recorded decision yet. */
|
|
57
|
+
declare function pendingApprovals(state: ApprovalsState): ApprovalRequest[];
|
|
58
|
+
|
|
59
|
+
export { type ApprovalRequest as A, type ApprovalDecision as a, type ApprovalsState as b, foldApprovals as f, initialApprovalsState as i, listApprovals as l, pendingApprovals as p, reduceApprovals as r };
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { AlquimiaSDK } from '../sdk/index.mjs';
|
|
3
3
|
import { AlquimiaAdapter } from '../adapters/index.mjs';
|
|
4
|
-
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-
|
|
5
|
-
import { G as GenuiSurfaceItem,
|
|
6
|
-
import {
|
|
7
|
-
import { a as WorklogState } from '../types-C-6fgK1_.mjs';
|
|
4
|
+
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-YKiEag2L.mjs';
|
|
5
|
+
import { G as GenuiSurfaceItem, a as AlquimiaMessage, b as ToolEvent, c as AIMessageChunk, R as RatingData } from '../type-C_sKpIM1.mjs';
|
|
6
|
+
import { ToolApprovalResult } from '../types/index.mjs';
|
|
8
7
|
import { createMessageId } from '../utils/index.mjs';
|
|
8
|
+
import { a as WorklogState } from '../types-lOliroPw.mjs';
|
|
9
|
+
import { A as ApprovalRequest } from '../approvals-dn4sd_Ot.mjs';
|
|
10
|
+
import { T as ToolExecutionResponse } from '../types-CMVbyEv8.mjs';
|
|
9
11
|
import { C as CatalogManifest } from '../registry-Bcu_ZYL1.mjs';
|
|
10
12
|
import { U as UIAction } from '../actions-BjDPJdyA.mjs';
|
|
11
13
|
import '@elastic/apm-rum';
|
|
@@ -40,11 +42,40 @@ interface UseAlquimiaConfig {
|
|
|
40
42
|
source?: 'client' | 'agent';
|
|
41
43
|
};
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A human-approval gate as the hook exposes it: what the worklog says, overlaid
|
|
47
|
+
* with this client's own submission.
|
|
48
|
+
*/
|
|
49
|
+
interface ToolApproval extends ApprovalRequest {
|
|
50
|
+
/**
|
|
51
|
+
* `pending` until someone decides; `submitting` while this client's call is
|
|
52
|
+
* in flight; `approved`/`rejected` once the runtime accepted a decision —
|
|
53
|
+
* this client's (optimistically, before the stream confirms) or anyone's.
|
|
54
|
+
*/
|
|
55
|
+
status: 'pending' | 'submitting' | 'approved' | 'rejected';
|
|
56
|
+
/** Rejection reason, from the worklog or from this client's submission. */
|
|
57
|
+
reason: string | null;
|
|
58
|
+
/** `true` when the accepted decision was made from this client. */
|
|
59
|
+
decidedHere: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether offering Approve / Reject here can still work. `false` for a
|
|
62
|
+
* channel-owned gate, and after the runtime refused this client with a 409,
|
|
63
|
+
* 403 or 404 — retrying those can only fail the same way.
|
|
64
|
+
*/
|
|
65
|
+
canAnswer: boolean;
|
|
66
|
+
/** The runtime's answer to this client's last submission, if any. */
|
|
67
|
+
lastResult: ToolApprovalResult | null;
|
|
68
|
+
/** Message count the gate was raised after, for anchoring it in the chat. */
|
|
69
|
+
afterCount: number;
|
|
70
|
+
}
|
|
43
71
|
declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
44
72
|
sdk: AlquimiaSDK;
|
|
45
73
|
activeTool: any;
|
|
46
74
|
pendingClientTool: PendingClientTool | null;
|
|
47
75
|
completeToolExecution: (controlId: string, result: ToolExecutionResponse) => Promise<void>;
|
|
76
|
+
toolApprovals: ToolApproval[];
|
|
77
|
+
pendingApprovals: ToolApproval[];
|
|
78
|
+
approveTool: (controlId: string, approved: boolean, message?: string) => Promise<ToolApprovalResult>;
|
|
48
79
|
genui: {
|
|
49
80
|
surfaces: GenuiSurfaceItem[];
|
|
50
81
|
onAgentAction: (controlId: string) => (action: UIAction) => void;
|
|
@@ -105,4 +136,4 @@ declare function useRatings({ assistantId, sendRating, topicId, onError }: UseRa
|
|
|
105
136
|
hasReviewed: boolean;
|
|
106
137
|
};
|
|
107
138
|
|
|
108
|
-
export { useAlquimia, useRatings };
|
|
139
|
+
export { type ToolApproval, type UseAlquimiaConfig, useAlquimia, useRatings };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { AlquimiaSDK } from '../sdk/index.js';
|
|
3
3
|
import { AlquimiaAdapter } from '../adapters/index.js';
|
|
4
|
-
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-
|
|
5
|
-
import { G as GenuiSurfaceItem,
|
|
6
|
-
import {
|
|
7
|
-
import { a as WorklogState } from '../types-C-6fgK1_.js';
|
|
4
|
+
import { W as WhisperProvider, S as StableDiffusionProvider, C as CharacterizationProvider, R as RatingsProvider, L as LoggerProvider } from '../providers-J_Z9rQ3Q.js';
|
|
5
|
+
import { G as GenuiSurfaceItem, a as AlquimiaMessage, b as ToolEvent, c as AIMessageChunk, R as RatingData } from '../type-BFtGEEb4.js';
|
|
6
|
+
import { ToolApprovalResult } from '../types/index.js';
|
|
8
7
|
import { createMessageId } from '../utils/index.js';
|
|
8
|
+
import { a as WorklogState } from '../types-lOliroPw.js';
|
|
9
|
+
import { A as ApprovalRequest } from '../approvals-CcnmqUkQ.js';
|
|
10
|
+
import { T as ToolExecutionResponse } from '../types-CMVbyEv8.js';
|
|
9
11
|
import { C as CatalogManifest } from '../registry-Bcu_ZYL1.js';
|
|
10
12
|
import { U as UIAction } from '../actions-CP1d4Ye1.js';
|
|
11
13
|
import '@elastic/apm-rum';
|
|
@@ -40,11 +42,40 @@ interface UseAlquimiaConfig {
|
|
|
40
42
|
source?: 'client' | 'agent';
|
|
41
43
|
};
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A human-approval gate as the hook exposes it: what the worklog says, overlaid
|
|
47
|
+
* with this client's own submission.
|
|
48
|
+
*/
|
|
49
|
+
interface ToolApproval extends ApprovalRequest {
|
|
50
|
+
/**
|
|
51
|
+
* `pending` until someone decides; `submitting` while this client's call is
|
|
52
|
+
* in flight; `approved`/`rejected` once the runtime accepted a decision —
|
|
53
|
+
* this client's (optimistically, before the stream confirms) or anyone's.
|
|
54
|
+
*/
|
|
55
|
+
status: 'pending' | 'submitting' | 'approved' | 'rejected';
|
|
56
|
+
/** Rejection reason, from the worklog or from this client's submission. */
|
|
57
|
+
reason: string | null;
|
|
58
|
+
/** `true` when the accepted decision was made from this client. */
|
|
59
|
+
decidedHere: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether offering Approve / Reject here can still work. `false` for a
|
|
62
|
+
* channel-owned gate, and after the runtime refused this client with a 409,
|
|
63
|
+
* 403 or 404 — retrying those can only fail the same way.
|
|
64
|
+
*/
|
|
65
|
+
canAnswer: boolean;
|
|
66
|
+
/** The runtime's answer to this client's last submission, if any. */
|
|
67
|
+
lastResult: ToolApprovalResult | null;
|
|
68
|
+
/** Message count the gate was raised after, for anchoring it in the chat. */
|
|
69
|
+
afterCount: number;
|
|
70
|
+
}
|
|
43
71
|
declare function useAlquimia(config: UseAlquimiaConfig): {
|
|
44
72
|
sdk: AlquimiaSDK;
|
|
45
73
|
activeTool: any;
|
|
46
74
|
pendingClientTool: PendingClientTool | null;
|
|
47
75
|
completeToolExecution: (controlId: string, result: ToolExecutionResponse) => Promise<void>;
|
|
76
|
+
toolApprovals: ToolApproval[];
|
|
77
|
+
pendingApprovals: ToolApproval[];
|
|
78
|
+
approveTool: (controlId: string, approved: boolean, message?: string) => Promise<ToolApprovalResult>;
|
|
48
79
|
genui: {
|
|
49
80
|
surfaces: GenuiSurfaceItem[];
|
|
50
81
|
onAgentAction: (controlId: string) => (action: UIAction) => void;
|
|
@@ -105,4 +136,4 @@ declare function useRatings({ assistantId, sendRating, topicId, onError }: UseRa
|
|
|
105
136
|
hasReviewed: boolean;
|
|
106
137
|
};
|
|
107
138
|
|
|
108
|
-
export { useAlquimia, useRatings };
|
|
139
|
+
export { type ToolApproval, type UseAlquimiaConfig, useAlquimia, useRatings };
|