@listdoing/core 0.2.0 → 0.2.1

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.mts CHANGED
@@ -165,6 +165,8 @@ interface SkillDefinition {
165
165
  type SkillHandler = (params: Record<string, any>, context: SkillContext) => Promise<SkillResult>;
166
166
  interface SkillContext {
167
167
  sessionId: string;
168
+ /** Stable business deduplication key for a Server tool call, when provided. */
169
+ idempotencyKey?: string;
168
170
  agent?: any;
169
171
  signal: AbortSignal;
170
172
  /** Current SubAgent instance (if executing inside a graph node) */
@@ -349,6 +351,8 @@ interface Session {
349
351
  interface ChatRunContext {
350
352
  systemPromptSuffix?: string;
351
353
  skills?: readonly SkillDefinition[];
354
+ /** @internal A run-local interaction skill that must execute alone in its tool batch. */
355
+ exclusiveSkill?: string;
352
356
  }
353
357
  interface ChatOptions {
354
358
  /** Optional, transient context. It is not written to the session. */
@@ -710,12 +714,37 @@ interface CodeExecutionConfig {
710
714
  sandboxDir?: string;
711
715
  }
712
716
  interface UploadConfig {
713
- /** Temporary directory for uploaded files (default: os.tmpdir()) */
717
+ /** Temporary directory for uploaded files (default: listdoing-uploads inside os.tmpdir()) */
714
718
  tempDir?: string;
715
719
  /** Max file size in bytes (default: 10 * 1024 * 1024 = 10MB) */
716
720
  maxFileSize?: number;
717
721
  /** Allowed MIME types (default: all) */
718
722
  allowedMimeTypes?: string[];
723
+ /** Maximum file count per batch. */
724
+ maxFiles?: number;
725
+ /** Maximum combined bytes per request. */
726
+ maxTotalSize?: number;
727
+ /** Combined disk quota for temporary files. */
728
+ maxStoredSize?: number;
729
+ /** Lifetime of temporary files in milliseconds. */
730
+ ttlMs?: number;
731
+ }
732
+ type ServerPermission = 'model' | 'agent' | 'tools' | 'admin';
733
+ interface ServerScopePolicy {
734
+ allowedTools?: readonly string[];
735
+ maxActiveRuns?: number;
736
+ maxProxyRequests?: number;
737
+ requestsPerMinute?: number;
738
+ }
739
+ interface ServerCoordinator {
740
+ /** Acquire sorted, scoped keys exclusively for the lifetime of work. */
741
+ withLock<T>(scope: string, keys: readonly string[], signal: AbortSignal, work: () => Promise<T>): Promise<T>;
742
+ /** Optional shared admission for a principal on multiple replicas. */
743
+ admit?(scope: string, requestsPerMinute: number): Promise<boolean>;
744
+ }
745
+ interface ServerPersistenceFactory {
746
+ (scope: string): IPersistence | Promise<IPersistence>;
747
+ ready?(): boolean | Promise<boolean>;
719
748
  }
720
749
  interface ServerConfig {
721
750
  port?: number;
@@ -723,14 +752,48 @@ interface ServerConfig {
723
752
  skillsDir?: string;
724
753
  auth?: {
725
754
  apiKey?: string;
755
+ keys?: {
756
+ key: string;
757
+ scope: string;
758
+ permissions: ServerPermission[];
759
+ }[];
726
760
  jwtSecret?: string;
761
+ jwtIssuer?: string;
762
+ jwtAudience?: string;
763
+ jwtPermissions?: ServerPermission[];
727
764
  };
728
- llm?: {
729
- adapter: 'openai' | 'anthropic' | 'ollama';
730
- model: string;
731
- baseUrl?: string;
732
- apiKey?: string;
733
- headers?: Record<string, string>;
765
+ llm?: LLMAdapterConfig;
766
+ /** Routes available to remote clients. Unspecified permits all configured route families. */
767
+ routes?: ServerPermission[];
768
+ /** Browser origins allowed by CORS. Disabled by default. */
769
+ corsOrigins?: string[];
770
+ /** Skill defaults are opt-in. The allowlist also applies to programmatic skills and MCP tools. */
771
+ tools?: {
772
+ builtins?: string[];
773
+ allow?: string[];
774
+ requireApproval?: string[];
775
+ };
776
+ /** Separate durable storage for each authenticated scope. */
777
+ persistence?: ServerPersistenceFactory;
778
+ coordinator?: ServerCoordinator;
779
+ scopePolicy?: (scope: string) => ServerScopePolicy | undefined;
780
+ readiness?: () => boolean | Promise<boolean>;
781
+ shutdownGraceMs?: number;
782
+ context?: ContextConfig;
783
+ /** Server-side boundaries for API calls and model proxy requests. */
784
+ limits?: {
785
+ maxTurnsPerChat?: number;
786
+ maxActiveRuns?: number;
787
+ maxActiveProxyRequests?: number;
788
+ maxSessionsPerScope?: number;
789
+ maxScopes?: number;
790
+ maxRuntimeScopesIdleMs?: number;
791
+ maxJournalEntriesPerScope?: number;
792
+ maxNonStreamingResponseBytes?: number;
793
+ approvalTimeoutMs?: number;
794
+ requestTimeoutMs?: number;
795
+ proxyIdleTimeoutMs?: number;
796
+ allowedModels?: string[];
734
797
  };
735
798
  /** Code execution skill configuration */
736
799
  codeExecution?: CodeExecutionConfig;
@@ -1550,6 +1613,7 @@ declare class GraphExecutor {
1550
1613
  private toolFailureCount;
1551
1614
  private emit;
1552
1615
  private unlinkParent;
1616
+ private onNodeSettled?;
1553
1617
  constructor(options: {
1554
1618
  graph: TaskGraph;
1555
1619
  parentAgent: Ldoing;
@@ -1559,6 +1623,7 @@ declare class GraphExecutor {
1559
1623
  maxDepth?: number;
1560
1624
  baseDepth?: number;
1561
1625
  emit: Emitter;
1626
+ onNodeSettled?: (nodeId: string) => Promise<void>;
1562
1627
  });
1563
1628
  /** Execute the entire graph, level by level */
1564
1629
  execute(): Promise<GraphPlan>;
@@ -1638,4 +1703,4 @@ declare class OpenAIContentAdapter implements IContentAdapter {
1638
1703
  formatMessageContent(content: string | ContentBlock[]): string | any[];
1639
1704
  }
1640
1705
 
1641
- export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type ChatRunContext, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, type LLMProxyMode, type LLMRouteStatus, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, type McpConnectionStatus, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type PromptCacheUsage, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
1706
+ export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type ChatRunContext, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, type LLMProxyMode, type LLMRouteStatus, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, type McpConnectionStatus, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type PromptCacheUsage, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type ServerCoordinator, type ServerPermission, type ServerPersistenceFactory, type ServerScopePolicy, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
package/dist/index.d.ts CHANGED
@@ -165,6 +165,8 @@ interface SkillDefinition {
165
165
  type SkillHandler = (params: Record<string, any>, context: SkillContext) => Promise<SkillResult>;
166
166
  interface SkillContext {
167
167
  sessionId: string;
168
+ /** Stable business deduplication key for a Server tool call, when provided. */
169
+ idempotencyKey?: string;
168
170
  agent?: any;
169
171
  signal: AbortSignal;
170
172
  /** Current SubAgent instance (if executing inside a graph node) */
@@ -349,6 +351,8 @@ interface Session {
349
351
  interface ChatRunContext {
350
352
  systemPromptSuffix?: string;
351
353
  skills?: readonly SkillDefinition[];
354
+ /** @internal A run-local interaction skill that must execute alone in its tool batch. */
355
+ exclusiveSkill?: string;
352
356
  }
353
357
  interface ChatOptions {
354
358
  /** Optional, transient context. It is not written to the session. */
@@ -710,12 +714,37 @@ interface CodeExecutionConfig {
710
714
  sandboxDir?: string;
711
715
  }
712
716
  interface UploadConfig {
713
- /** Temporary directory for uploaded files (default: os.tmpdir()) */
717
+ /** Temporary directory for uploaded files (default: listdoing-uploads inside os.tmpdir()) */
714
718
  tempDir?: string;
715
719
  /** Max file size in bytes (default: 10 * 1024 * 1024 = 10MB) */
716
720
  maxFileSize?: number;
717
721
  /** Allowed MIME types (default: all) */
718
722
  allowedMimeTypes?: string[];
723
+ /** Maximum file count per batch. */
724
+ maxFiles?: number;
725
+ /** Maximum combined bytes per request. */
726
+ maxTotalSize?: number;
727
+ /** Combined disk quota for temporary files. */
728
+ maxStoredSize?: number;
729
+ /** Lifetime of temporary files in milliseconds. */
730
+ ttlMs?: number;
731
+ }
732
+ type ServerPermission = 'model' | 'agent' | 'tools' | 'admin';
733
+ interface ServerScopePolicy {
734
+ allowedTools?: readonly string[];
735
+ maxActiveRuns?: number;
736
+ maxProxyRequests?: number;
737
+ requestsPerMinute?: number;
738
+ }
739
+ interface ServerCoordinator {
740
+ /** Acquire sorted, scoped keys exclusively for the lifetime of work. */
741
+ withLock<T>(scope: string, keys: readonly string[], signal: AbortSignal, work: () => Promise<T>): Promise<T>;
742
+ /** Optional shared admission for a principal on multiple replicas. */
743
+ admit?(scope: string, requestsPerMinute: number): Promise<boolean>;
744
+ }
745
+ interface ServerPersistenceFactory {
746
+ (scope: string): IPersistence | Promise<IPersistence>;
747
+ ready?(): boolean | Promise<boolean>;
719
748
  }
720
749
  interface ServerConfig {
721
750
  port?: number;
@@ -723,14 +752,48 @@ interface ServerConfig {
723
752
  skillsDir?: string;
724
753
  auth?: {
725
754
  apiKey?: string;
755
+ keys?: {
756
+ key: string;
757
+ scope: string;
758
+ permissions: ServerPermission[];
759
+ }[];
726
760
  jwtSecret?: string;
761
+ jwtIssuer?: string;
762
+ jwtAudience?: string;
763
+ jwtPermissions?: ServerPermission[];
727
764
  };
728
- llm?: {
729
- adapter: 'openai' | 'anthropic' | 'ollama';
730
- model: string;
731
- baseUrl?: string;
732
- apiKey?: string;
733
- headers?: Record<string, string>;
765
+ llm?: LLMAdapterConfig;
766
+ /** Routes available to remote clients. Unspecified permits all configured route families. */
767
+ routes?: ServerPermission[];
768
+ /** Browser origins allowed by CORS. Disabled by default. */
769
+ corsOrigins?: string[];
770
+ /** Skill defaults are opt-in. The allowlist also applies to programmatic skills and MCP tools. */
771
+ tools?: {
772
+ builtins?: string[];
773
+ allow?: string[];
774
+ requireApproval?: string[];
775
+ };
776
+ /** Separate durable storage for each authenticated scope. */
777
+ persistence?: ServerPersistenceFactory;
778
+ coordinator?: ServerCoordinator;
779
+ scopePolicy?: (scope: string) => ServerScopePolicy | undefined;
780
+ readiness?: () => boolean | Promise<boolean>;
781
+ shutdownGraceMs?: number;
782
+ context?: ContextConfig;
783
+ /** Server-side boundaries for API calls and model proxy requests. */
784
+ limits?: {
785
+ maxTurnsPerChat?: number;
786
+ maxActiveRuns?: number;
787
+ maxActiveProxyRequests?: number;
788
+ maxSessionsPerScope?: number;
789
+ maxScopes?: number;
790
+ maxRuntimeScopesIdleMs?: number;
791
+ maxJournalEntriesPerScope?: number;
792
+ maxNonStreamingResponseBytes?: number;
793
+ approvalTimeoutMs?: number;
794
+ requestTimeoutMs?: number;
795
+ proxyIdleTimeoutMs?: number;
796
+ allowedModels?: string[];
734
797
  };
735
798
  /** Code execution skill configuration */
736
799
  codeExecution?: CodeExecutionConfig;
@@ -1550,6 +1613,7 @@ declare class GraphExecutor {
1550
1613
  private toolFailureCount;
1551
1614
  private emit;
1552
1615
  private unlinkParent;
1616
+ private onNodeSettled?;
1553
1617
  constructor(options: {
1554
1618
  graph: TaskGraph;
1555
1619
  parentAgent: Ldoing;
@@ -1559,6 +1623,7 @@ declare class GraphExecutor {
1559
1623
  maxDepth?: number;
1560
1624
  baseDepth?: number;
1561
1625
  emit: Emitter;
1626
+ onNodeSettled?: (nodeId: string) => Promise<void>;
1562
1627
  });
1563
1628
  /** Execute the entire graph, level by level */
1564
1629
  execute(): Promise<GraphPlan>;
@@ -1638,4 +1703,4 @@ declare class OpenAIContentAdapter implements IContentAdapter {
1638
1703
  formatMessageContent(content: string | ContentBlock[]): string | any[];
1639
1704
  }
1640
1705
 
1641
- export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type ChatRunContext, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, type LLMProxyMode, type LLMRouteStatus, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, type McpConnectionStatus, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type PromptCacheUsage, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
1706
+ export { ACPError, ACPErrorCodes, type BuildWindowResult, type ChatOptions, type ChatResult, type ChatRunContext, type CodeExecutionConfig, type ContentBlock, type ContextConfig, ContextManager, type ExecutionTrace, type FallbackStrategy, type FileInput, type GraphCheckpoint, type GraphDefinition, GraphExecutor, type GraphNode, type GraphPlan, GraphPlanner, type GraphProgress, HttpTransport, type IContentAdapter, type ILLMAdapter, type IPersistence, type ISkillProvider, type ITransport, type InitResult, type InstallOptions, type JsonRpcRequest, type JsonRpcResponse, type LLMAdapterConfig, type LLMProxyMode, type LLMRouteStatus, Ldoing, type LdoingConfig, type LimitsConfig, type LoadedSkill, LocalTransport, type McpConnectionStatus, McpRouter, type McpServerConnection, MemoryPersistence, type Message, type ModelCapabilities, type NodeResult, type NodeStatus, OpenAIAdapter, OpenAIContentAdapter, PERMISSION_MODE_DEFAULTS, type PermissionMode, type PermissionPolicy, PlanTracker, type PromptCacheUsage, type RetryPolicy, SENSITIVE_PERMISSIONS, type ServerConfig, type ServerCoordinator, type ServerPermission, type ServerPersistenceFactory, type ServerScopePolicy, type Session, SessionManager, type SkillContext, type SkillDefinition, SkillExecutor, type SkillHandler, type SkillInstallRequest, type SkillInstallResult, type SkillPack, type SkillPackEnv, type SkillPackRegistration, type SkillPackResult, SkillRegistry, type SkillResult, type SkillSource, type SkillTier, type SkillWorker, type SkillsConfig, type StandardLLMResponse, type StepPlan, type StepResult, type StepStatus, type StreamEvent, SubAgent, type SubAgentConfig, type TaskCheckpoint, TaskGraph, type TaskPlan, type TaskPlanStatus, TaskPlanner, type TaskProgress, type ToolCall, type ToolDef, type TriggerRule, type UploadConfig, type WorkflowDefinition, type WorkflowProgress, type WorkflowStep, contentToPreview, contentToString, detectRuntime, estimateContentTokens, estimateMessageTokens, estimateRequestTokens, estimateTextTokens, estimateToolDefTokens, fileInputsToContentBlocks, interpolateInstruction, interpolateTemplate, resolveModelCapabilities, resolveModelContextLength, resolvePermissionPolicy };
package/dist/index.js CHANGED
@@ -2410,6 +2410,7 @@ var GraphExecutor = class {
2410
2410
  this.abortController = new AbortController();
2411
2411
  this.unlinkParent = linkAbort(options.parentSignal, this.abortController);
2412
2412
  this.emit = options.emit;
2413
+ this.onNodeSettled = options.onNodeSettled;
2413
2414
  }
2414
2415
  /** Execute the entire graph, level by level */
2415
2416
  async execute() {
@@ -2465,12 +2466,20 @@ var GraphExecutor = class {
2465
2466
  (node) => semaphore.acquire().then(async (release) => {
2466
2467
  try {
2467
2468
  await this.executeNode(node);
2469
+ await this.onNodeSettled?.(node.id);
2470
+ } catch (error) {
2471
+ if (this.onNodeSettled) this.abort();
2472
+ throw error;
2468
2473
  } finally {
2469
2474
  release();
2470
2475
  }
2471
2476
  })
2472
2477
  );
2473
- await Promise.allSettled(promises);
2478
+ const outcomes = await Promise.allSettled(promises);
2479
+ if (this.onNodeSettled) {
2480
+ const failure = outcomes.find((result) => result.status === "rejected");
2481
+ if (failure) throw failure.reason;
2482
+ }
2474
2483
  }
2475
2484
  /** Execute a single node with retry + fallback */
2476
2485
  async executeNode(node) {
@@ -3166,7 +3175,7 @@ var Ldoing = class {
3166
3175
  turn++;
3167
3176
  const session2 = this.sessionManager.getOrThrow(sessionId);
3168
3177
  const systemPrompt = this.buildRunSystemPrompt(session2, runContext);
3169
- const allTools = this.listRunTools(runContext);
3178
+ const allTools = this.listRunTools(runContext, options?._skipLock);
3170
3179
  const tools = this.resolveTools(allTools, { allowedTools: options?.tools, toolsByPermission: options?.toolsByPermission });
3171
3180
  for (const name of this.computeAutoApproval(tools)) {
3172
3181
  requireApproval.add(name);
@@ -3316,7 +3325,7 @@ var Ldoing = class {
3316
3325
  turn++;
3317
3326
  const session2 = this.sessionManager.getOrThrow(sessionId);
3318
3327
  const systemPrompt = this.buildRunSystemPrompt(session2, runContext);
3319
- const allTools = this.listRunTools(runContext);
3328
+ const allTools = this.listRunTools(runContext, options?._skipLock);
3320
3329
  const tools = this.resolveTools(allTools, { allowedTools: options?.tools, toolsByPermission: options?.toolsByPermission });
3321
3330
  for (const name of this.computeAutoApproval(tools)) {
3322
3331
  requireApproval.add(name);
@@ -4525,6 +4534,17 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4525
4534
  const parallelSafe = skillDef?.parallelSafe ?? true;
4526
4535
  return { toolCall: tc, skillDef, location, permPolicy, parallelSafe };
4527
4536
  });
4537
+ const exclusiveSkill = runContext?.exclusiveSkill;
4538
+ if (exclusiveSkill) {
4539
+ const exclusiveCall = items.find((item) => item.toolCall.name === exclusiveSkill && item.permPolicy !== "disabled");
4540
+ if (exclusiveCall) {
4541
+ for (const item of items) {
4542
+ if (item !== exclusiveCall) {
4543
+ item.skippedReason = `Skipped because ${exclusiveSkill} must run alone. Reconsider this call after receiving the interaction result.`;
4544
+ }
4545
+ }
4546
+ }
4547
+ }
4528
4548
  const canParallelize = items.every((item) => item.parallelSafe);
4529
4549
  return { canParallelize, items };
4530
4550
  }
@@ -4537,6 +4557,7 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4537
4557
  let reason;
4538
4558
  if (tc.parseError) reason = `Invalid tool arguments: ${tc.parseError}`;
4539
4559
  else if (item.permPolicy === "disabled") reason = `Tool "${tc.name}" is disabled in current permission mode.`;
4560
+ else if (item.skippedReason) reason = item.skippedReason;
4540
4561
  else if (item.permPolicy === "approval" || item.permPolicy === "force-approval") {
4541
4562
  const decision = this.waitForApproval(tc.id, signal);
4542
4563
  decision.catch(() => {
@@ -4729,13 +4750,18 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4729
4750
  return await this.executeServerSkill(toolCall, controller.signal);
4730
4751
  } else {
4731
4752
  const executorFor = (name) => scope?.registry.has(name) ? scope.executor : this.skillExecutor;
4732
- const invokeFn = (skillName, params) => executorFor(skillName).invokeDirect(skillName, params, {
4733
- sessionId,
4734
- agent: this,
4735
- signal: controller.signal,
4736
- depth: 0,
4737
- invoke: invokeFn
4738
- });
4753
+ const invokeFn = async (skillName, params) => {
4754
+ if (skillName === scope?.exclusiveSkill) {
4755
+ return { isError: true, content: [{ type: "text", text: "This interaction requires a top-level tool call." }] };
4756
+ }
4757
+ return executorFor(skillName).invokeDirect(skillName, params, {
4758
+ sessionId,
4759
+ agent: this,
4760
+ signal: controller.signal,
4761
+ depth: 0,
4762
+ invoke: invokeFn
4763
+ });
4764
+ };
4739
4765
  return await executorFor(toolCall.name).execute(toolCall.name, toolCall.arguments, {
4740
4766
  sessionId,
4741
4767
  agent: this,
@@ -4760,6 +4786,7 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4760
4786
  }
4761
4787
  const scope = {
4762
4788
  systemPromptSuffix: context.systemPromptSuffix,
4789
+ exclusiveSkill: context.exclusiveSkill && registry.has(context.exclusiveSkill) ? context.exclusiveSkill : void 0,
4763
4790
  registry,
4764
4791
  executor: new SkillExecutor(registry, void 0, { validateInputs: this.config.skills?.validateInputs })
4765
4792
  };
@@ -4770,10 +4797,12 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4770
4797
  const base = this.resolveSystemPrompt(session.id, session.systemPrompt ?? this.config.systemPrompt ?? "");
4771
4798
  return runContext?.systemPromptSuffix ? [base, runContext.systemPromptSuffix].filter(Boolean).join("\n\n") : base;
4772
4799
  }
4773
- listRunTools(runContext) {
4800
+ listRunTools(runContext, nested) {
4774
4801
  const tools = this.skillRegistry.listToolDefs();
4775
4802
  if (!runContext) return tools;
4776
- return [...tools.filter((tool) => !runContext.registry.has(tool.name)), ...runContext.registry.listToolDefs()];
4803
+ const localTools = runContext.registry.listToolDefs();
4804
+ const visibleTools = nested && runContext.exclusiveSkill ? localTools.filter((tool) => tool.name !== runContext.exclusiveSkill) : localTools;
4805
+ return [...tools.filter((tool) => !runContext.registry.has(tool.name)), ...visibleTools];
4777
4806
  }
4778
4807
  beginExecution(sessionId, options) {
4779
4808
  const previous = this.abortControllers.get(sessionId);
package/dist/index.mjs CHANGED
@@ -2340,6 +2340,7 @@ var GraphExecutor = class {
2340
2340
  this.abortController = new AbortController();
2341
2341
  this.unlinkParent = linkAbort(options.parentSignal, this.abortController);
2342
2342
  this.emit = options.emit;
2343
+ this.onNodeSettled = options.onNodeSettled;
2343
2344
  }
2344
2345
  /** Execute the entire graph, level by level */
2345
2346
  async execute() {
@@ -2395,12 +2396,20 @@ var GraphExecutor = class {
2395
2396
  (node) => semaphore.acquire().then(async (release) => {
2396
2397
  try {
2397
2398
  await this.executeNode(node);
2399
+ await this.onNodeSettled?.(node.id);
2400
+ } catch (error) {
2401
+ if (this.onNodeSettled) this.abort();
2402
+ throw error;
2398
2403
  } finally {
2399
2404
  release();
2400
2405
  }
2401
2406
  })
2402
2407
  );
2403
- await Promise.allSettled(promises);
2408
+ const outcomes = await Promise.allSettled(promises);
2409
+ if (this.onNodeSettled) {
2410
+ const failure = outcomes.find((result) => result.status === "rejected");
2411
+ if (failure) throw failure.reason;
2412
+ }
2404
2413
  }
2405
2414
  /** Execute a single node with retry + fallback */
2406
2415
  async executeNode(node) {
@@ -3096,7 +3105,7 @@ var Ldoing = class {
3096
3105
  turn++;
3097
3106
  const session2 = this.sessionManager.getOrThrow(sessionId);
3098
3107
  const systemPrompt = this.buildRunSystemPrompt(session2, runContext);
3099
- const allTools = this.listRunTools(runContext);
3108
+ const allTools = this.listRunTools(runContext, options?._skipLock);
3100
3109
  const tools = this.resolveTools(allTools, { allowedTools: options?.tools, toolsByPermission: options?.toolsByPermission });
3101
3110
  for (const name of this.computeAutoApproval(tools)) {
3102
3111
  requireApproval.add(name);
@@ -3246,7 +3255,7 @@ var Ldoing = class {
3246
3255
  turn++;
3247
3256
  const session2 = this.sessionManager.getOrThrow(sessionId);
3248
3257
  const systemPrompt = this.buildRunSystemPrompt(session2, runContext);
3249
- const allTools = this.listRunTools(runContext);
3258
+ const allTools = this.listRunTools(runContext, options?._skipLock);
3250
3259
  const tools = this.resolveTools(allTools, { allowedTools: options?.tools, toolsByPermission: options?.toolsByPermission });
3251
3260
  for (const name of this.computeAutoApproval(tools)) {
3252
3261
  requireApproval.add(name);
@@ -4455,6 +4464,17 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4455
4464
  const parallelSafe = skillDef?.parallelSafe ?? true;
4456
4465
  return { toolCall: tc, skillDef, location, permPolicy, parallelSafe };
4457
4466
  });
4467
+ const exclusiveSkill = runContext?.exclusiveSkill;
4468
+ if (exclusiveSkill) {
4469
+ const exclusiveCall = items.find((item) => item.toolCall.name === exclusiveSkill && item.permPolicy !== "disabled");
4470
+ if (exclusiveCall) {
4471
+ for (const item of items) {
4472
+ if (item !== exclusiveCall) {
4473
+ item.skippedReason = `Skipped because ${exclusiveSkill} must run alone. Reconsider this call after receiving the interaction result.`;
4474
+ }
4475
+ }
4476
+ }
4477
+ }
4458
4478
  const canParallelize = items.every((item) => item.parallelSafe);
4459
4479
  return { canParallelize, items };
4460
4480
  }
@@ -4467,6 +4487,7 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4467
4487
  let reason;
4468
4488
  if (tc.parseError) reason = `Invalid tool arguments: ${tc.parseError}`;
4469
4489
  else if (item.permPolicy === "disabled") reason = `Tool "${tc.name}" is disabled in current permission mode.`;
4490
+ else if (item.skippedReason) reason = item.skippedReason;
4470
4491
  else if (item.permPolicy === "approval" || item.permPolicy === "force-approval") {
4471
4492
  const decision = this.waitForApproval(tc.id, signal);
4472
4493
  decision.catch(() => {
@@ -4659,13 +4680,18 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4659
4680
  return await this.executeServerSkill(toolCall, controller.signal);
4660
4681
  } else {
4661
4682
  const executorFor = (name) => scope?.registry.has(name) ? scope.executor : this.skillExecutor;
4662
- const invokeFn = (skillName, params) => executorFor(skillName).invokeDirect(skillName, params, {
4663
- sessionId,
4664
- agent: this,
4665
- signal: controller.signal,
4666
- depth: 0,
4667
- invoke: invokeFn
4668
- });
4683
+ const invokeFn = async (skillName, params) => {
4684
+ if (skillName === scope?.exclusiveSkill) {
4685
+ return { isError: true, content: [{ type: "text", text: "This interaction requires a top-level tool call." }] };
4686
+ }
4687
+ return executorFor(skillName).invokeDirect(skillName, params, {
4688
+ sessionId,
4689
+ agent: this,
4690
+ signal: controller.signal,
4691
+ depth: 0,
4692
+ invoke: invokeFn
4693
+ });
4694
+ };
4669
4695
  return await executorFor(toolCall.name).execute(toolCall.name, toolCall.arguments, {
4670
4696
  sessionId,
4671
4697
  agent: this,
@@ -4690,6 +4716,7 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4690
4716
  }
4691
4717
  const scope = {
4692
4718
  systemPromptSuffix: context.systemPromptSuffix,
4719
+ exclusiveSkill: context.exclusiveSkill && registry.has(context.exclusiveSkill) ? context.exclusiveSkill : void 0,
4693
4720
  registry,
4694
4721
  executor: new SkillExecutor(registry, void 0, { validateInputs: this.config.skills?.validateInputs })
4695
4722
  };
@@ -4700,10 +4727,12 @@ ${resultLines.join("\n")}` : "Graph resumed but no nodes completed successfully.
4700
4727
  const base = this.resolveSystemPrompt(session.id, session.systemPrompt ?? this.config.systemPrompt ?? "");
4701
4728
  return runContext?.systemPromptSuffix ? [base, runContext.systemPromptSuffix].filter(Boolean).join("\n\n") : base;
4702
4729
  }
4703
- listRunTools(runContext) {
4730
+ listRunTools(runContext, nested) {
4704
4731
  const tools = this.skillRegistry.listToolDefs();
4705
4732
  if (!runContext) return tools;
4706
- return [...tools.filter((tool) => !runContext.registry.has(tool.name)), ...runContext.registry.listToolDefs()];
4733
+ const localTools = runContext.registry.listToolDefs();
4734
+ const visibleTools = nested && runContext.exclusiveSkill ? localTools.filter((tool) => tool.name !== runContext.exclusiveSkill) : localTools;
4735
+ return [...tools.filter((tool) => !runContext.registry.has(tool.name)), ...visibleTools];
4707
4736
  }
4708
4737
  beginExecution(sessionId, options) {
4709
4738
  const previous = this.abortControllers.get(sessionId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@listdoing/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "ListDoing Core — cross-platform shared logic",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",