@cortask/core 0.2.23 → 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 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
@@ -2972,6 +2972,8 @@ function createArtifactTool(artifactStore) {
2972
2972
 
2973
2973
  // src/agent/tools/browser-manager.ts
2974
2974
  import { execFile } from "child_process";
2975
+ import { existsSync } from "fs";
2976
+ import { join } from "path";
2975
2977
  import { createRequire } from "module";
2976
2978
  var DEFAULT_TIMEOUT = 3e4;
2977
2979
  function getNativeBinName() {
@@ -2985,9 +2987,14 @@ function getNativeBinName() {
2985
2987
  return null;
2986
2988
  }
2987
2989
  function resolveCmd() {
2990
+ const nativeBin = getNativeBinName();
2991
+ const resourcesPath = process.resourcesPath;
2992
+ if (resourcesPath && nativeBin) {
2993
+ const candidate = join(resourcesPath, "agent-browser", nativeBin);
2994
+ if (existsSync(candidate)) return candidate;
2995
+ }
2988
2996
  try {
2989
2997
  const require2 = createRequire(import.meta.url);
2990
- const nativeBin = getNativeBinName();
2991
2998
  if (nativeBin) {
2992
2999
  try {
2993
3000
  return require2.resolve(`agent-browser/bin/${nativeBin}`);
@@ -3001,6 +3008,9 @@ function resolveCmd() {
3001
3008
  }
3002
3009
  var CMD = resolveCmd();
3003
3010
  var instance = null;
3011
+ function resetBrowserInstance() {
3012
+ instance = null;
3013
+ }
3004
3014
  function exec2(args, timeout = DEFAULT_TIMEOUT) {
3005
3015
  return new Promise((resolve, reject) => {
3006
3016
  const isScript = CMD.endsWith(".js");
@@ -3033,6 +3043,8 @@ async function ensureInstalled() {
3033
3043
  async function ensureBrowser() {
3034
3044
  if (instance) return instance;
3035
3045
  await ensureInstalled();
3046
+ await exec2(["close"], 5e3).catch(() => {
3047
+ });
3036
3048
  const inst = {
3037
3049
  async run(args) {
3038
3050
  return exec2(args);
@@ -3187,7 +3199,7 @@ function createBrowserTool(artifactStore) {
3187
3199
  await closeBrowser();
3188
3200
  return { toolCallId: "", content: "Browser closed." };
3189
3201
  }
3190
- try {
3202
+ const executeAction = async () => {
3191
3203
  const browser = await ensureBrowser();
3192
3204
  switch (action) {
3193
3205
  case "navigate": {
@@ -3377,10 +3389,28 @@ ${result.content}`,
3377
3389
  isError: true
3378
3390
  };
3379
3391
  }
3392
+ };
3393
+ try {
3394
+ return await executeAction();
3380
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
+ }
3381
3411
  return {
3382
3412
  toolCallId: "",
3383
- content: `Browser error: ${err instanceof Error ? err.message : String(err)}`,
3413
+ content: `Browser error: ${msg}`,
3384
3414
  isError: true
3385
3415
  };
3386
3416
  }
@@ -5789,6 +5819,7 @@ export {
5789
5819
  createSubagentTool,
5790
5820
  createSwitchWorkspaceTool,
5791
5821
  credentialKey,
5822
+ ensureInstalled as ensureBrowserInstalled,
5792
5823
  estimateCost,
5793
5824
  exchangeSkillOAuth2Code,
5794
5825
  getCredentialStorageKey,