@cortask/core 0.2.22 → 0.2.24
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/index.d.ts +3 -1
- package/dist/index.js +41 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -388,6 +388,8 @@ declare function createArtifactTool(artifactStore: ArtifactStore): ToolHandler;
|
|
|
388
388
|
|
|
389
389
|
declare function createBrowserTool(artifactStore: ArtifactStore): ToolHandler;
|
|
390
390
|
|
|
391
|
+
declare function ensureInstalled(): Promise<void>;
|
|
392
|
+
|
|
391
393
|
/**
|
|
392
394
|
* Set the AgentRunner reference for subagent spawning.
|
|
393
395
|
* Must be called after AgentRunner instantiation.
|
|
@@ -1215,4 +1217,4 @@ declare class Logger {
|
|
|
1215
1217
|
}
|
|
1216
1218
|
declare const logger: Logger;
|
|
1217
1219
|
|
|
1218
|
-
export { AVAILABLE_PROVIDERS, type AgentRunParams, type AgentRunResult, AgentRunner, type AgentRunnerConfig, type AgentRunnerDeps, type AgentStreamEvent, AnthropicProvider, type Artifact, ArtifactStore, type Attachment, type ChannelType, type ContentPart, type CortaskConfig, type CredentialDefinition, type CredentialSchema, type CredentialStore, type CronDelivery, type CronEvent, type CronJob, type CronJobCreate, type CronJobState, type CronSchedule, CronService, type EmbedParams, type EmbedResult, type EnabledModel, EncryptedCredentialStore, type GenerateTextParams, type GenerateTextResult, GoogleProvider, GrokProvider, type LLMProvider, type LogLevel, MODEL_DEFINITIONS, type Message, MiniMaxProvider, type ModelInfo, ModelStore, MoonshotProvider, OllamaProvider, type OnboardingData, type OnboardingStatus, OpenAICompatibleProvider, OpenAIProvider, OpenRouterProvider, type PermissionRequest, type PromptTemplate, type ProviderId, type ProviderInfo, type ProviderValidationResult, type QuestionnaireQuestion, type QuestionnaireRequest, type QuestionnaireResponse, SUBAGENT_DEFAULTS, type Session, SessionStore, type SessionWithMessages, type SkillCodeTool, type SkillEntry, type SkillManifest, type SkillSource, type SkillToolTemplate, type StreamChunk, type SubagentRunRecord, TemplateStore, type ToolCall, type ToolDefinition, type ToolExecutionContext, type ToolHandler, type ToolResult, type UsageRecord, UsageStore, type UsageSummary, type Workspace, WorkspaceManager, buildSkillOAuth2AuthUrl, buildSkillTools, buildSystemPrompt, builtinTools, cancelChildrenOfSession, cancelSubagentRun, cleanupSubagentRecords, clearSkillCache, completeSubagentRun, computeNextRunAtMs, cortaskConfigSchema, countActiveChildren, createArtifactTool, createBrowserTool, createCronTool, createProvider, createSkill, createSkillTool, createSubagentTool, createSwitchWorkspaceTool, credentialKey, estimateCost, exchangeSkillOAuth2Code, getCredentialStorageKey, getDataDir, getDepthForSession, getEligibleSkills, getModelDefinitions, getOAuth2StorageKeys, getOrCreateSecret, getProviderInfo, getSubagentRun, installSkillFromGit, loadConfig, loadSkills, logger, migrateAllWorkspaces, migrateSessionDatabase, readSkillFile, registerSubagentRun, removeSkill, revokeSkillOAuth2, saveConfig, setSubagentRunner, updateSkill, validateCronExpr, validateProvider, validateSkillName };
|
|
1220
|
+
export { AVAILABLE_PROVIDERS, type AgentRunParams, type AgentRunResult, AgentRunner, type AgentRunnerConfig, type AgentRunnerDeps, type AgentStreamEvent, AnthropicProvider, type Artifact, ArtifactStore, type Attachment, type ChannelType, type ContentPart, type CortaskConfig, type CredentialDefinition, type CredentialSchema, type CredentialStore, type CronDelivery, type CronEvent, type CronJob, type CronJobCreate, type CronJobState, type CronSchedule, CronService, type EmbedParams, type EmbedResult, type EnabledModel, EncryptedCredentialStore, type GenerateTextParams, type GenerateTextResult, GoogleProvider, GrokProvider, type LLMProvider, type LogLevel, MODEL_DEFINITIONS, type Message, MiniMaxProvider, type ModelInfo, ModelStore, MoonshotProvider, OllamaProvider, type OnboardingData, type OnboardingStatus, OpenAICompatibleProvider, OpenAIProvider, OpenRouterProvider, type PermissionRequest, type PromptTemplate, type ProviderId, type ProviderInfo, type ProviderValidationResult, type QuestionnaireQuestion, type QuestionnaireRequest, type QuestionnaireResponse, SUBAGENT_DEFAULTS, type Session, SessionStore, type SessionWithMessages, type SkillCodeTool, type SkillEntry, type SkillManifest, type SkillSource, type SkillToolTemplate, type StreamChunk, type SubagentRunRecord, TemplateStore, type ToolCall, type ToolDefinition, type ToolExecutionContext, type ToolHandler, type ToolResult, type UsageRecord, UsageStore, type UsageSummary, type Workspace, WorkspaceManager, buildSkillOAuth2AuthUrl, buildSkillTools, buildSystemPrompt, builtinTools, cancelChildrenOfSession, cancelSubagentRun, cleanupSubagentRecords, clearSkillCache, completeSubagentRun, computeNextRunAtMs, cortaskConfigSchema, countActiveChildren, createArtifactTool, createBrowserTool, createCronTool, createProvider, createSkill, createSkillTool, createSubagentTool, createSwitchWorkspaceTool, credentialKey, ensureInstalled as ensureBrowserInstalled, estimateCost, exchangeSkillOAuth2Code, getCredentialStorageKey, getDataDir, getDepthForSession, getEligibleSkills, getModelDefinitions, getOAuth2StorageKeys, getOrCreateSecret, getProviderInfo, getSubagentRun, installSkillFromGit, loadConfig, loadSkills, logger, migrateAllWorkspaces, migrateSessionDatabase, readSkillFile, registerSubagentRun, removeSkill, revokeSkillOAuth2, saveConfig, setSubagentRunner, updateSkill, validateCronExpr, validateProvider, validateSkillName };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/providers/openai-compatible.ts
|
|
9
2
|
import OpenAI from "openai";
|
|
10
3
|
|
|
@@ -2979,6 +2972,8 @@ function createArtifactTool(artifactStore) {
|
|
|
2979
2972
|
|
|
2980
2973
|
// src/agent/tools/browser-manager.ts
|
|
2981
2974
|
import { execFile } from "child_process";
|
|
2975
|
+
import { existsSync } from "fs";
|
|
2976
|
+
import { join } from "path";
|
|
2982
2977
|
import { createRequire } from "module";
|
|
2983
2978
|
var DEFAULT_TIMEOUT = 3e4;
|
|
2984
2979
|
function getNativeBinName() {
|
|
@@ -2995,10 +2990,8 @@ function resolveCmd() {
|
|
|
2995
2990
|
const nativeBin = getNativeBinName();
|
|
2996
2991
|
const resourcesPath = process.resourcesPath;
|
|
2997
2992
|
if (resourcesPath && nativeBin) {
|
|
2998
|
-
const
|
|
2999
|
-
|
|
3000
|
-
const candidate = path18.join(resourcesPath, "agent-browser", nativeBin);
|
|
3001
|
-
if (fs20.existsSync(candidate)) return candidate;
|
|
2993
|
+
const candidate = join(resourcesPath, "agent-browser", nativeBin);
|
|
2994
|
+
if (existsSync(candidate)) return candidate;
|
|
3002
2995
|
}
|
|
3003
2996
|
try {
|
|
3004
2997
|
const require2 = createRequire(import.meta.url);
|
|
@@ -3015,7 +3008,9 @@ function resolveCmd() {
|
|
|
3015
3008
|
}
|
|
3016
3009
|
var CMD = resolveCmd();
|
|
3017
3010
|
var instance = null;
|
|
3018
|
-
|
|
3011
|
+
function resetBrowserInstance() {
|
|
3012
|
+
instance = null;
|
|
3013
|
+
}
|
|
3019
3014
|
function exec2(args, timeout = DEFAULT_TIMEOUT) {
|
|
3020
3015
|
return new Promise((resolve, reject) => {
|
|
3021
3016
|
const isScript = CMD.endsWith(".js");
|
|
@@ -3031,18 +3026,25 @@ function exec2(args, timeout = DEFAULT_TIMEOUT) {
|
|
|
3031
3026
|
});
|
|
3032
3027
|
});
|
|
3033
3028
|
}
|
|
3034
|
-
|
|
3035
|
-
|
|
3029
|
+
var _installed = false;
|
|
3030
|
+
async function ensureInstalled() {
|
|
3031
|
+
if (_installed) return;
|
|
3036
3032
|
try {
|
|
3037
3033
|
await exec2(["--version"], 5e3);
|
|
3038
|
-
_available = true;
|
|
3039
3034
|
} catch {
|
|
3040
|
-
|
|
3035
|
+
throw new Error("agent-browser is not installed. Run: npm install -g agent-browser");
|
|
3036
|
+
}
|
|
3037
|
+
try {
|
|
3038
|
+
await exec2(["install"], 12e4);
|
|
3039
|
+
} catch {
|
|
3041
3040
|
}
|
|
3042
|
-
|
|
3041
|
+
_installed = true;
|
|
3043
3042
|
}
|
|
3044
3043
|
async function ensureBrowser() {
|
|
3045
3044
|
if (instance) return instance;
|
|
3045
|
+
await ensureInstalled();
|
|
3046
|
+
await exec2(["close"], 5e3).catch(() => {
|
|
3047
|
+
});
|
|
3046
3048
|
const inst = {
|
|
3047
3049
|
async run(args) {
|
|
3048
3050
|
return exec2(args);
|
|
@@ -3103,9 +3105,7 @@ async function ensureBrowser() {
|
|
|
3103
3105
|
await exec2(["press", key]);
|
|
3104
3106
|
},
|
|
3105
3107
|
async wait(target) {
|
|
3106
|
-
if (
|
|
3107
|
-
await exec2(["wait", target]);
|
|
3108
|
-
} else if (target.startsWith("http")) {
|
|
3108
|
+
if (target.startsWith("http")) {
|
|
3109
3109
|
await exec2(["wait", "--url", target]);
|
|
3110
3110
|
} else {
|
|
3111
3111
|
await exec2(["wait", target]);
|
|
@@ -3194,20 +3194,12 @@ function createBrowserTool(artifactStore) {
|
|
|
3194
3194
|
}
|
|
3195
3195
|
},
|
|
3196
3196
|
async execute(args, _context) {
|
|
3197
|
-
const available = await isAgentBrowserAvailable();
|
|
3198
|
-
if (!available) {
|
|
3199
|
-
return {
|
|
3200
|
-
toolCallId: "",
|
|
3201
|
-
content: "agent-browser is not installed. Run: npm install -g agent-browser && agent-browser install",
|
|
3202
|
-
isError: true
|
|
3203
|
-
};
|
|
3204
|
-
}
|
|
3205
3197
|
const action = args.action;
|
|
3206
3198
|
if (action === "close") {
|
|
3207
3199
|
await closeBrowser();
|
|
3208
3200
|
return { toolCallId: "", content: "Browser closed." };
|
|
3209
3201
|
}
|
|
3210
|
-
|
|
3202
|
+
const executeAction = async () => {
|
|
3211
3203
|
const browser = await ensureBrowser();
|
|
3212
3204
|
switch (action) {
|
|
3213
3205
|
case "navigate": {
|
|
@@ -3397,10 +3389,28 @@ ${result.content}`,
|
|
|
3397
3389
|
isError: true
|
|
3398
3390
|
};
|
|
3399
3391
|
}
|
|
3392
|
+
};
|
|
3393
|
+
try {
|
|
3394
|
+
return await executeAction();
|
|
3400
3395
|
} catch (err) {
|
|
3396
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
3397
|
+
if (msg.includes("has been closed") || msg.includes("Target page")) {
|
|
3398
|
+
await closeBrowser().catch(() => {
|
|
3399
|
+
});
|
|
3400
|
+
resetBrowserInstance();
|
|
3401
|
+
try {
|
|
3402
|
+
return await executeAction();
|
|
3403
|
+
} catch (retryErr) {
|
|
3404
|
+
return {
|
|
3405
|
+
toolCallId: "",
|
|
3406
|
+
content: `Browser error (after retry): ${retryErr instanceof Error ? retryErr.message : String(retryErr)}`,
|
|
3407
|
+
isError: true
|
|
3408
|
+
};
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3401
3411
|
return {
|
|
3402
3412
|
toolCallId: "",
|
|
3403
|
-
content: `Browser error: ${
|
|
3413
|
+
content: `Browser error: ${msg}`,
|
|
3404
3414
|
isError: true
|
|
3405
3415
|
};
|
|
3406
3416
|
}
|
|
@@ -5809,6 +5819,7 @@ export {
|
|
|
5809
5819
|
createSubagentTool,
|
|
5810
5820
|
createSwitchWorkspaceTool,
|
|
5811
5821
|
credentialKey,
|
|
5822
|
+
ensureInstalled as ensureBrowserInstalled,
|
|
5812
5823
|
estimateCost,
|
|
5813
5824
|
exchangeSkillOAuth2Code,
|
|
5814
5825
|
getCredentialStorageKey,
|