@eko-ai/eko 1.0.12 → 1.0.14
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/common/chrome/proxy.d.ts +38 -0
- package/dist/common/tools/cancel_workflow.d.ts +9 -0
- package/dist/common/tools/human.d.ts +30 -0
- package/dist/common/tools/index.d.ts +4 -0
- package/dist/common/tools/summary_workflow.d.ts +9 -0
- package/dist/core/chrome-proxy.d.ts +10 -0
- package/dist/extension/script/build_dom_tree.js +1 -0
- package/dist/extension.cjs.js +69 -33
- package/dist/extension.esm.js +69 -33
- package/dist/extension_content_script.js +1 -1
- package/dist/index.cjs.js +1 -14
- package/dist/index.esm.js +1 -14
- package/dist/nodejs.cjs.js +62 -29
- package/dist/nodejs.esm.js +62 -29
- package/dist/services/chrome/chrome-proxy.d.ts +10 -0
- package/dist/services/llm/deepseek-provider.d.ts +2 -0
- package/dist/types/workflow.types.d.ts +2 -0
- package/dist/web/tools/index.d.ts +1 -0
- package/dist/web.cjs.js +241 -1
- package/dist/web.esm.js +241 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets a proxy for the Chrome API.
|
|
3
|
+
* This function creates a proxy for the Chrome API, allowing for interception and modification of certain methods.
|
|
4
|
+
* The main logic involves creating a proxy for the `chrome` namespaces.
|
|
5
|
+
* If a method exists in the mock implementation (e.g., `a` or `a_b` or `a_b_c` and so on), it will be used; otherwise, the original Chrome API method will be called.
|
|
6
|
+
* @param chromeProxy - An object that provides mock implementations of Chrome API methods.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* class MyChromeProxy {
|
|
10
|
+
* chrome.events.Event<(tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void>.removeListener(callback: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void): void
|
|
11
|
+
* public static tabs_onUpdated_removeListener(callback: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void): void {
|
|
12
|
+
* console.log(callback);
|
|
13
|
+
* return chrome.tabs.onUpdated.removeListener(callback);
|
|
14
|
+
* }
|
|
15
|
+
* public static tabs_get(tabId: number): Promise<chrome.tabs.Tab> {
|
|
16
|
+
* console.log(tabId);
|
|
17
|
+
* return chrome.tabs.get(tabId);
|
|
18
|
+
* }
|
|
19
|
+
* public static windows_create(createData: chrome.windows.CreateData): Promise<chrome.windows.Window> {
|
|
20
|
+
* console.log(createData);
|
|
21
|
+
* return chrome.windows.create(createData);
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* setChromeProxy(MyChromeProxy);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function setChromeProxy(chromeProxy: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the current Chrome API proxy.
|
|
30
|
+
* This function returns the proxy object created by `setChromeProxy`, which can be used to access the proxied Chrome API methods.
|
|
31
|
+
* @returns The proxied Chrome API object.
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* getChromeProxy().tabs.get(1).then(tab => console.log(tab));
|
|
35
|
+
* ```
|
|
36
|
+
* In this example, `getChromeProxy` is used to retrieve the proxied Chrome API object, and then `tabs.get` is called on it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getChromeProxy(): any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CancelWorkflowInput } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
export declare class CancelWorkflow implements Tool<CancelWorkflowInput, void> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: CancelWorkflowInput): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HumanInputTextInput, HumanInputTextResult, HumanInputSingleChoiceInput, HumanInputSingleChoiceResult, HumanInputMultipleChoiceInput, HumanInputMultipleChoiceResult, HumanOperateInput, HumanOperateResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
export declare class HumanInputText implements Tool<HumanInputTextInput, HumanInputTextResult> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: HumanInputTextInput): Promise<HumanInputTextResult>;
|
|
9
|
+
}
|
|
10
|
+
export declare class HumanInputSingleChoice implements Tool<HumanInputSingleChoiceInput, HumanInputSingleChoiceResult> {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
input_schema: InputSchema;
|
|
14
|
+
constructor();
|
|
15
|
+
execute(context: ExecutionContext, params: HumanInputSingleChoiceInput): Promise<HumanInputSingleChoiceResult>;
|
|
16
|
+
}
|
|
17
|
+
export declare class HumanInputMultipleChoice implements Tool<HumanInputMultipleChoiceInput, HumanInputMultipleChoiceResult> {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
input_schema: InputSchema;
|
|
21
|
+
constructor();
|
|
22
|
+
execute(context: ExecutionContext, params: HumanInputMultipleChoiceInput): Promise<HumanInputMultipleChoiceResult>;
|
|
23
|
+
}
|
|
24
|
+
export declare class HumanOperate implements Tool<HumanOperateInput, HumanOperateResult> {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
input_schema: InputSchema;
|
|
28
|
+
constructor();
|
|
29
|
+
execute(context: ExecutionContext, params: HumanOperateInput): Promise<HumanOperateResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CancelWorkflow } from "./cancel_workflow";
|
|
2
|
+
import { HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate } from "./human";
|
|
3
|
+
import { SummaryWorkflow } from "./summary_workflow";
|
|
4
|
+
export { CancelWorkflow, HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate, SummaryWorkflow, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SummaryWorkflowInput } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
export declare class SummaryWorkflow implements Tool<SummaryWorkflowInput, any> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: SummaryWorkflowInput): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class ChromeMock {
|
|
2
|
+
static tabs_create(createProperties: chrome.tabs.CreateProperties): Promise<chrome.tabs.Tab>;
|
|
3
|
+
static tabs_get(tabId: number): Promise<chrome.tabs.Tab>;
|
|
4
|
+
static tabs_remove(tabId: number): Promise<void>;
|
|
5
|
+
static windows_create(createData: chrome.windows.CreateData): Promise<chrome.windows.Window>;
|
|
6
|
+
static windows_get(windowId: number): Promise<chrome.windows.Window>;
|
|
7
|
+
static windows_getCurrent(): Promise<chrome.windows.Window>;
|
|
8
|
+
static windows_remove(windowId: number): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const ChromeProxy: any;
|
package/dist/extension.cjs.js
CHANGED
|
@@ -1120,10 +1120,11 @@ class ExportFile {
|
|
|
1120
1120
|
* @returns > { success: true }
|
|
1121
1121
|
*/
|
|
1122
1122
|
async execute(context, params) {
|
|
1123
|
-
var _a, _b, _c;
|
|
1123
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1124
1124
|
if (typeof params !== 'object' || params === null || !('content' in params)) {
|
|
1125
1125
|
throw new Error('Invalid parameters. Expected an object with a "content" property.');
|
|
1126
1126
|
}
|
|
1127
|
+
await ((_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onExportFile) === null || _c === undefined ? undefined : _c.call(_b, params));
|
|
1127
1128
|
let type = 'text/plain';
|
|
1128
1129
|
switch (params.fileType) {
|
|
1129
1130
|
case 'csv':
|
|
@@ -1172,7 +1173,7 @@ class ExportFile {
|
|
|
1172
1173
|
else {
|
|
1173
1174
|
tab = await open_new_tab(url, true);
|
|
1174
1175
|
}
|
|
1175
|
-
(
|
|
1176
|
+
(_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
|
|
1176
1177
|
let tabId = tab.id;
|
|
1177
1178
|
await chrome.scripting.executeScript({
|
|
1178
1179
|
target: { tabId: tabId },
|
|
@@ -1422,7 +1423,10 @@ class OpenUrl {
|
|
|
1422
1423
|
}
|
|
1423
1424
|
let url = params.url;
|
|
1424
1425
|
let newWindow = params.newWindow;
|
|
1425
|
-
if (
|
|
1426
|
+
if (context.ekoConfig.workingWindowId) {
|
|
1427
|
+
newWindow = false;
|
|
1428
|
+
}
|
|
1429
|
+
else if (!newWindow && !context.variables.get('windowId') && !context.variables.get('tabId')) {
|
|
1426
1430
|
// First mandatory opening of a new window
|
|
1427
1431
|
newWindow = true;
|
|
1428
1432
|
}
|
|
@@ -1432,7 +1436,7 @@ class OpenUrl {
|
|
|
1432
1436
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1433
1437
|
}
|
|
1434
1438
|
else {
|
|
1435
|
-
let windowId = await getWindowId(context);
|
|
1439
|
+
let windowId = context.ekoConfig.workingWindowId ? context.ekoConfig.workingWindowId : await getWindowId(context);
|
|
1436
1440
|
tab = await open_new_tab(url, false, windowId);
|
|
1437
1441
|
(_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
|
|
1438
1442
|
}
|
|
@@ -2073,21 +2077,29 @@ class HumanInputText {
|
|
|
2073
2077
|
};
|
|
2074
2078
|
}
|
|
2075
2079
|
async execute(context, params) {
|
|
2076
|
-
var _a
|
|
2080
|
+
var _a;
|
|
2077
2081
|
if (typeof params !== 'object' || params === null || !params.question) {
|
|
2078
2082
|
throw new Error('Invalid parameters. Expected an object with a "question" property.');
|
|
2079
2083
|
}
|
|
2080
2084
|
const question = params.question;
|
|
2081
2085
|
console.log("question: " + question);
|
|
2082
|
-
let
|
|
2083
|
-
if (
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2086
|
+
let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
|
|
2087
|
+
if (onHumanInputText) {
|
|
2088
|
+
let answer;
|
|
2089
|
+
try {
|
|
2090
|
+
answer = await onHumanInputText(question);
|
|
2091
|
+
}
|
|
2092
|
+
catch (e) {
|
|
2093
|
+
console.error(e);
|
|
2094
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2095
|
+
}
|
|
2088
2096
|
console.log("answer: " + answer);
|
|
2089
2097
|
return { status: "OK", answer: answer };
|
|
2090
2098
|
}
|
|
2099
|
+
else {
|
|
2100
|
+
console.error("`onHumanInputText` not implemented");
|
|
2101
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2102
|
+
}
|
|
2091
2103
|
}
|
|
2092
2104
|
}
|
|
2093
2105
|
class HumanInputSingleChoice {
|
|
@@ -2110,7 +2122,7 @@ class HumanInputSingleChoice {
|
|
|
2110
2122
|
};
|
|
2111
2123
|
}
|
|
2112
2124
|
async execute(context, params) {
|
|
2113
|
-
var _a
|
|
2125
|
+
var _a;
|
|
2114
2126
|
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
2115
2127
|
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
2116
2128
|
}
|
|
@@ -2118,15 +2130,23 @@ class HumanInputSingleChoice {
|
|
|
2118
2130
|
const choices = params.choices;
|
|
2119
2131
|
console.log("question: " + question);
|
|
2120
2132
|
console.log("choices: " + choices);
|
|
2121
|
-
let
|
|
2122
|
-
if (
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2133
|
+
let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
|
|
2134
|
+
if (onHumanInputSingleChoice) {
|
|
2135
|
+
let answer;
|
|
2136
|
+
try {
|
|
2137
|
+
answer = await onHumanInputSingleChoice(question, choices);
|
|
2138
|
+
}
|
|
2139
|
+
catch (e) {
|
|
2140
|
+
console.error(e);
|
|
2141
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2142
|
+
}
|
|
2127
2143
|
console.log("answer: " + answer);
|
|
2128
2144
|
return { status: "OK", answer: answer };
|
|
2129
2145
|
}
|
|
2146
|
+
else {
|
|
2147
|
+
console.error("`onHumanInputSingleChoice` not implemented");
|
|
2148
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2149
|
+
}
|
|
2130
2150
|
}
|
|
2131
2151
|
}
|
|
2132
2152
|
class HumanInputMultipleChoice {
|
|
@@ -2149,7 +2169,7 @@ class HumanInputMultipleChoice {
|
|
|
2149
2169
|
};
|
|
2150
2170
|
}
|
|
2151
2171
|
async execute(context, params) {
|
|
2152
|
-
var _a
|
|
2172
|
+
var _a;
|
|
2153
2173
|
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
2154
2174
|
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
2155
2175
|
}
|
|
@@ -2157,15 +2177,23 @@ class HumanInputMultipleChoice {
|
|
|
2157
2177
|
const choices = params.choices;
|
|
2158
2178
|
console.log("question: " + question);
|
|
2159
2179
|
console.log("choices: " + choices);
|
|
2160
|
-
let
|
|
2161
|
-
if (
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2180
|
+
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
|
|
2181
|
+
if (onHumanInputMultipleChoice) {
|
|
2182
|
+
let answer;
|
|
2183
|
+
try {
|
|
2184
|
+
answer = await onHumanInputMultipleChoice(question, choices);
|
|
2185
|
+
}
|
|
2186
|
+
catch (e) {
|
|
2187
|
+
console.error(e);
|
|
2188
|
+
return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
|
|
2189
|
+
}
|
|
2166
2190
|
console.log("answer: " + answer);
|
|
2167
2191
|
return { status: "OK", answer: answer };
|
|
2168
2192
|
}
|
|
2193
|
+
else {
|
|
2194
|
+
console.error("Cannot get user's answer.");
|
|
2195
|
+
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
2196
|
+
}
|
|
2169
2197
|
}
|
|
2170
2198
|
}
|
|
2171
2199
|
class HumanOperate {
|
|
@@ -2184,28 +2212,36 @@ class HumanOperate {
|
|
|
2184
2212
|
};
|
|
2185
2213
|
}
|
|
2186
2214
|
async execute(context, params) {
|
|
2187
|
-
var _a
|
|
2215
|
+
var _a;
|
|
2188
2216
|
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
2189
2217
|
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
2190
2218
|
}
|
|
2191
2219
|
const reason = params.reason;
|
|
2192
2220
|
console.log("reason: " + reason);
|
|
2193
|
-
let
|
|
2194
|
-
if (
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2221
|
+
let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
|
|
2222
|
+
if (onHumanOperate) {
|
|
2223
|
+
let userOperation;
|
|
2224
|
+
try {
|
|
2225
|
+
userOperation = await onHumanOperate(reason);
|
|
2226
|
+
}
|
|
2227
|
+
catch (e) {
|
|
2228
|
+
console.error(e);
|
|
2229
|
+
return { status: "`onHumanOperate` not implemented", userOperation: "" };
|
|
2230
|
+
}
|
|
2199
2231
|
console.log("userOperation: " + userOperation);
|
|
2200
2232
|
return { status: "OK", userOperation: userOperation };
|
|
2201
2233
|
}
|
|
2234
|
+
else {
|
|
2235
|
+
console.error("Cannot get user's operation.");
|
|
2236
|
+
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
2237
|
+
}
|
|
2202
2238
|
}
|
|
2203
2239
|
}
|
|
2204
2240
|
|
|
2205
2241
|
class SummaryWorkflow {
|
|
2206
2242
|
constructor() {
|
|
2207
2243
|
this.name = 'summary_workflow';
|
|
2208
|
-
this.description = 'Summarize what this workflow has
|
|
2244
|
+
this.description = 'Summarize briefly what this workflow has accomplished.';
|
|
2209
2245
|
this.input_schema = {
|
|
2210
2246
|
type: 'object',
|
|
2211
2247
|
properties: {
|
package/dist/extension.esm.js
CHANGED
|
@@ -1118,10 +1118,11 @@ class ExportFile {
|
|
|
1118
1118
|
* @returns > { success: true }
|
|
1119
1119
|
*/
|
|
1120
1120
|
async execute(context, params) {
|
|
1121
|
-
var _a, _b, _c;
|
|
1121
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1122
1122
|
if (typeof params !== 'object' || params === null || !('content' in params)) {
|
|
1123
1123
|
throw new Error('Invalid parameters. Expected an object with a "content" property.');
|
|
1124
1124
|
}
|
|
1125
|
+
await ((_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onExportFile) === null || _c === undefined ? undefined : _c.call(_b, params));
|
|
1125
1126
|
let type = 'text/plain';
|
|
1126
1127
|
switch (params.fileType) {
|
|
1127
1128
|
case 'csv':
|
|
@@ -1170,7 +1171,7 @@ class ExportFile {
|
|
|
1170
1171
|
else {
|
|
1171
1172
|
tab = await open_new_tab(url, true);
|
|
1172
1173
|
}
|
|
1173
|
-
(
|
|
1174
|
+
(_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
|
|
1174
1175
|
let tabId = tab.id;
|
|
1175
1176
|
await chrome.scripting.executeScript({
|
|
1176
1177
|
target: { tabId: tabId },
|
|
@@ -1420,7 +1421,10 @@ class OpenUrl {
|
|
|
1420
1421
|
}
|
|
1421
1422
|
let url = params.url;
|
|
1422
1423
|
let newWindow = params.newWindow;
|
|
1423
|
-
if (
|
|
1424
|
+
if (context.ekoConfig.workingWindowId) {
|
|
1425
|
+
newWindow = false;
|
|
1426
|
+
}
|
|
1427
|
+
else if (!newWindow && !context.variables.get('windowId') && !context.variables.get('tabId')) {
|
|
1424
1428
|
// First mandatory opening of a new window
|
|
1425
1429
|
newWindow = true;
|
|
1426
1430
|
}
|
|
@@ -1430,7 +1434,7 @@ class OpenUrl {
|
|
|
1430
1434
|
(_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onTabCreated) === null || _c === undefined ? undefined : _c.call(_b, tab.id);
|
|
1431
1435
|
}
|
|
1432
1436
|
else {
|
|
1433
|
-
let windowId = await getWindowId(context);
|
|
1437
|
+
let windowId = context.ekoConfig.workingWindowId ? context.ekoConfig.workingWindowId : await getWindowId(context);
|
|
1434
1438
|
tab = await open_new_tab(url, false, windowId);
|
|
1435
1439
|
(_f = (_e = (_d = context.callback) === null || _d === undefined ? undefined : _d.hooks) === null || _e === undefined ? undefined : _e.onTabCreated) === null || _f === undefined ? undefined : _f.call(_e, tab.id);
|
|
1436
1440
|
}
|
|
@@ -2071,21 +2075,29 @@ class HumanInputText {
|
|
|
2071
2075
|
};
|
|
2072
2076
|
}
|
|
2073
2077
|
async execute(context, params) {
|
|
2074
|
-
var _a
|
|
2078
|
+
var _a;
|
|
2075
2079
|
if (typeof params !== 'object' || params === null || !params.question) {
|
|
2076
2080
|
throw new Error('Invalid parameters. Expected an object with a "question" property.');
|
|
2077
2081
|
}
|
|
2078
2082
|
const question = params.question;
|
|
2079
2083
|
console.log("question: " + question);
|
|
2080
|
-
let
|
|
2081
|
-
if (
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2084
|
+
let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
|
|
2085
|
+
if (onHumanInputText) {
|
|
2086
|
+
let answer;
|
|
2087
|
+
try {
|
|
2088
|
+
answer = await onHumanInputText(question);
|
|
2089
|
+
}
|
|
2090
|
+
catch (e) {
|
|
2091
|
+
console.error(e);
|
|
2092
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2093
|
+
}
|
|
2086
2094
|
console.log("answer: " + answer);
|
|
2087
2095
|
return { status: "OK", answer: answer };
|
|
2088
2096
|
}
|
|
2097
|
+
else {
|
|
2098
|
+
console.error("`onHumanInputText` not implemented");
|
|
2099
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2100
|
+
}
|
|
2089
2101
|
}
|
|
2090
2102
|
}
|
|
2091
2103
|
class HumanInputSingleChoice {
|
|
@@ -2108,7 +2120,7 @@ class HumanInputSingleChoice {
|
|
|
2108
2120
|
};
|
|
2109
2121
|
}
|
|
2110
2122
|
async execute(context, params) {
|
|
2111
|
-
var _a
|
|
2123
|
+
var _a;
|
|
2112
2124
|
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
2113
2125
|
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
2114
2126
|
}
|
|
@@ -2116,15 +2128,23 @@ class HumanInputSingleChoice {
|
|
|
2116
2128
|
const choices = params.choices;
|
|
2117
2129
|
console.log("question: " + question);
|
|
2118
2130
|
console.log("choices: " + choices);
|
|
2119
|
-
let
|
|
2120
|
-
if (
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2131
|
+
let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
|
|
2132
|
+
if (onHumanInputSingleChoice) {
|
|
2133
|
+
let answer;
|
|
2134
|
+
try {
|
|
2135
|
+
answer = await onHumanInputSingleChoice(question, choices);
|
|
2136
|
+
}
|
|
2137
|
+
catch (e) {
|
|
2138
|
+
console.error(e);
|
|
2139
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2140
|
+
}
|
|
2125
2141
|
console.log("answer: " + answer);
|
|
2126
2142
|
return { status: "OK", answer: answer };
|
|
2127
2143
|
}
|
|
2144
|
+
else {
|
|
2145
|
+
console.error("`onHumanInputSingleChoice` not implemented");
|
|
2146
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
2147
|
+
}
|
|
2128
2148
|
}
|
|
2129
2149
|
}
|
|
2130
2150
|
class HumanInputMultipleChoice {
|
|
@@ -2147,7 +2167,7 @@ class HumanInputMultipleChoice {
|
|
|
2147
2167
|
};
|
|
2148
2168
|
}
|
|
2149
2169
|
async execute(context, params) {
|
|
2150
|
-
var _a
|
|
2170
|
+
var _a;
|
|
2151
2171
|
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
2152
2172
|
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
2153
2173
|
}
|
|
@@ -2155,15 +2175,23 @@ class HumanInputMultipleChoice {
|
|
|
2155
2175
|
const choices = params.choices;
|
|
2156
2176
|
console.log("question: " + question);
|
|
2157
2177
|
console.log("choices: " + choices);
|
|
2158
|
-
let
|
|
2159
|
-
if (
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2178
|
+
let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
|
|
2179
|
+
if (onHumanInputMultipleChoice) {
|
|
2180
|
+
let answer;
|
|
2181
|
+
try {
|
|
2182
|
+
answer = await onHumanInputMultipleChoice(question, choices);
|
|
2183
|
+
}
|
|
2184
|
+
catch (e) {
|
|
2185
|
+
console.error(e);
|
|
2186
|
+
return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
|
|
2187
|
+
}
|
|
2164
2188
|
console.log("answer: " + answer);
|
|
2165
2189
|
return { status: "OK", answer: answer };
|
|
2166
2190
|
}
|
|
2191
|
+
else {
|
|
2192
|
+
console.error("Cannot get user's answer.");
|
|
2193
|
+
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
2194
|
+
}
|
|
2167
2195
|
}
|
|
2168
2196
|
}
|
|
2169
2197
|
class HumanOperate {
|
|
@@ -2182,28 +2210,36 @@ class HumanOperate {
|
|
|
2182
2210
|
};
|
|
2183
2211
|
}
|
|
2184
2212
|
async execute(context, params) {
|
|
2185
|
-
var _a
|
|
2213
|
+
var _a;
|
|
2186
2214
|
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
2187
2215
|
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
2188
2216
|
}
|
|
2189
2217
|
const reason = params.reason;
|
|
2190
2218
|
console.log("reason: " + reason);
|
|
2191
|
-
let
|
|
2192
|
-
if (
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2219
|
+
let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
|
|
2220
|
+
if (onHumanOperate) {
|
|
2221
|
+
let userOperation;
|
|
2222
|
+
try {
|
|
2223
|
+
userOperation = await onHumanOperate(reason);
|
|
2224
|
+
}
|
|
2225
|
+
catch (e) {
|
|
2226
|
+
console.error(e);
|
|
2227
|
+
return { status: "`onHumanOperate` not implemented", userOperation: "" };
|
|
2228
|
+
}
|
|
2197
2229
|
console.log("userOperation: " + userOperation);
|
|
2198
2230
|
return { status: "OK", userOperation: userOperation };
|
|
2199
2231
|
}
|
|
2232
|
+
else {
|
|
2233
|
+
console.error("Cannot get user's operation.");
|
|
2234
|
+
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
2235
|
+
}
|
|
2200
2236
|
}
|
|
2201
2237
|
}
|
|
2202
2238
|
|
|
2203
2239
|
class SummaryWorkflow {
|
|
2204
2240
|
constructor() {
|
|
2205
2241
|
this.name = 'summary_workflow';
|
|
2206
|
-
this.description = 'Summarize what this workflow has
|
|
2242
|
+
this.description = 'Summarize briefly what this workflow has accomplished.';
|
|
2207
2243
|
this.input_schema = {
|
|
2208
2244
|
type: 'object',
|
|
2209
2245
|
properties: {
|
package/dist/index.cjs.js
CHANGED
|
@@ -502,7 +502,7 @@ class ActionImpl {
|
|
|
502
502
|
result = modified_result;
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
const result_has_image = result &&
|
|
505
|
+
const result_has_image = result && result.image;
|
|
506
506
|
const resultContent = result_has_image
|
|
507
507
|
? {
|
|
508
508
|
type: 'tool_result',
|
|
@@ -942,19 +942,6 @@ class WorkflowGenerator {
|
|
|
942
942
|
],
|
|
943
943
|
});
|
|
944
944
|
const workflowData = response.toolCalls[0].input.workflow;
|
|
945
|
-
// Forcibly add special tools
|
|
946
|
-
const specialTools = [
|
|
947
|
-
"cancel_workflow",
|
|
948
|
-
"human_input_text",
|
|
949
|
-
"human_operate",
|
|
950
|
-
];
|
|
951
|
-
for (const node of workflowData.nodes) {
|
|
952
|
-
for (const tool of specialTools) {
|
|
953
|
-
if (!node.action.tools.includes(tool)) {
|
|
954
|
-
node.action.tools.push(tool);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
945
|
// Validate all tools exist
|
|
959
946
|
for (const node of workflowData.nodes) {
|
|
960
947
|
if (!this.toolRegistry.hasTools(node.action.tools)) {
|
package/dist/index.esm.js
CHANGED
|
@@ -498,7 +498,7 @@ class ActionImpl {
|
|
|
498
498
|
result = modified_result;
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
const result_has_image = result &&
|
|
501
|
+
const result_has_image = result && result.image;
|
|
502
502
|
const resultContent = result_has_image
|
|
503
503
|
? {
|
|
504
504
|
type: 'tool_result',
|
|
@@ -938,19 +938,6 @@ class WorkflowGenerator {
|
|
|
938
938
|
],
|
|
939
939
|
});
|
|
940
940
|
const workflowData = response.toolCalls[0].input.workflow;
|
|
941
|
-
// Forcibly add special tools
|
|
942
|
-
const specialTools = [
|
|
943
|
-
"cancel_workflow",
|
|
944
|
-
"human_input_text",
|
|
945
|
-
"human_operate",
|
|
946
|
-
];
|
|
947
|
-
for (const node of workflowData.nodes) {
|
|
948
|
-
for (const tool of specialTools) {
|
|
949
|
-
if (!node.action.tools.includes(tool)) {
|
|
950
|
-
node.action.tools.push(tool);
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
941
|
// Validate all tools exist
|
|
955
942
|
for (const node of workflowData.nodes) {
|
|
956
943
|
if (!this.toolRegistry.hasTools(node.action.tools)) {
|