@dudko.dev/agent 0.0.36 → 0.0.37

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.cts CHANGED
@@ -3,6 +3,57 @@ import { FetchLike } from '@modelcontextprotocol/sdk/shared/transport.js';
3
3
  import { ToolSet, LanguageModel, Tool, SystemModelMessage, ModelMessage } from 'ai';
4
4
  import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
 
6
+ /**
7
+ * Steering a run that is already going.
8
+ *
9
+ * `run()` takes one goal and returns when the run is over, so a host that wants to
10
+ * say something mid-run — "actually use the staging database" — or stop one
11
+ * subagent out of several has nothing to call. A `RunControl` is the handle: create
12
+ * one, pass it as `run(goal, { control })`, and use it from anywhere while the run
13
+ * is in flight.
14
+ *
15
+ * A message is not interrupt. The run never cuts a tool call short (it may be a
16
+ * write): the message is held until the next boundary — the next tool-calling round
17
+ * inside a step, or the end of the step — and is then shown to the model. At a step
18
+ * boundary it also forces the replanner to look at the plan again, because a plan
19
+ * made before the user spoke may no longer be the right one.
20
+ */
21
+ /** One running subagent, as the host sees it. */
22
+ interface SubagentInfo {
23
+ id: string;
24
+ /** The subagent tool's `name`. */
25
+ name: string;
26
+ task: string;
27
+ /** The profile the parent chose for this call, when it chose one. */
28
+ profile?: string;
29
+ startedAt: number;
30
+ }
31
+ interface RunControl {
32
+ /**
33
+ * Queue a message for the run. `false` when there is nothing to deliver it to — the text
34
+ * is empty, or the run has already finished (send it as a new run instead).
35
+ *
36
+ * Accepted does not mean delivered: a message that arrives after the last boundary
37
+ * (while the answer is being written) comes back in `RunResult.undelivered`, so the
38
+ * host can send it next.
39
+ */
40
+ send(text: string): boolean;
41
+ /**
42
+ * Messages sent and not yet delivered. Once the run is over: the ones it never got to show
43
+ * the model (the same list as `RunResult.undelivered`, which a run that threw cannot return).
44
+ */
45
+ pending(): string[];
46
+ /** The subagents running under this run right now (a snapshot; `subagent.*` events are the stream). */
47
+ subagents(): SubagentInfo[];
48
+ /**
49
+ * Stop ONE running subagent. Its delegation fails with a message the parent model can
50
+ * route around, and the run carries on — unlike aborting the run, which stops everything.
51
+ * `false` when no subagent with that id is running.
52
+ */
53
+ stopSubagent(id: string): boolean;
54
+ }
55
+ declare const createRunControl: () => RunControl;
56
+
6
57
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
7
58
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
8
59
  type ToolSelectionStrategy = 'all' | 'plan-narrowed' | 'search' | 'auto';
@@ -191,7 +242,7 @@ interface IStepResult {
191
242
  blocked: boolean;
192
243
  }
193
244
  type ReplanTrigger = 'failure' | 'always' | ((result: IStepResult) => boolean | Promise<boolean>);
194
- type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision';
245
+ type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision' | 'user-message';
195
246
  type UsagePhase = 'plan' | 'execute' | 'replan' | 'synthesize' | 'compact' | 'subagent';
196
247
  type AgentEventBody = {
197
248
  type: 'plan.thought-delta';
@@ -299,6 +350,7 @@ type AgentEventBody = {
299
350
  id: string;
300
351
  name: string;
301
352
  task: string;
353
+ profile?: string;
302
354
  } | {
303
355
  type: 'subagent.event';
304
356
  id: string;
@@ -315,6 +367,16 @@ type AgentEventBody = {
315
367
  id: string;
316
368
  name: string;
317
369
  error: string;
370
+ stopped?: boolean;
371
+ } | {
372
+ type: 'message.queued';
373
+ id: string;
374
+ text: string;
375
+ } | {
376
+ type: 'message.delivered';
377
+ id: string;
378
+ text: string;
379
+ at: 'round' | 'step' | 'final';
318
380
  } | {
319
381
  type: 'revisions.exceeded';
320
382
  cap: number;
@@ -339,6 +401,7 @@ interface IAgentRunOptions {
339
401
  onEvent?: EventHandler;
340
402
  onStepStart?: (info: IStepStartInfo) => void;
341
403
  resumeFromRunId?: string;
404
+ control?: RunControl;
342
405
  }
343
406
  interface IAgentRunResult {
344
407
  text: string;
@@ -347,6 +410,7 @@ interface IAgentRunResult {
347
410
  iterations: number;
348
411
  usage: IUsage;
349
412
  compactedHistory?: IConversationTurn[];
413
+ undelivered?: string[];
350
414
  }
351
415
  interface IRunSnapshot {
352
416
  runId: string;
@@ -367,6 +431,10 @@ interface IRunSnapshot {
367
431
  traceSummaryUpTo?: number;
368
432
  activeSkills?: string[];
369
433
  toolCallCount?: number;
434
+ userUpdates?: {
435
+ text: string;
436
+ reconciled: boolean;
437
+ }[];
370
438
  }
371
439
  interface IPersistence {
372
440
  onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
@@ -765,6 +833,10 @@ interface IClearedInfo {
765
833
  declare const createToolResultClearer: (opts: IToolResultClearing, onCleared?: (info: IClearedInfo) => void) => ((messages: ModelMessage[]) => ModelMessage[]);
766
834
 
767
835
  type SubagentIsolation = 'worker' | 'in-process';
836
+ interface ISubagentProfile {
837
+ description: string;
838
+ config?: Partial<IAgentConfig>;
839
+ }
768
840
  interface ISubagentToolOptions {
769
841
  name: string;
770
842
  description: string;
@@ -775,6 +847,7 @@ interface ISubagentToolOptions {
775
847
  timeoutMs?: number;
776
848
  outputMaxChars?: number;
777
849
  readOnly?: boolean;
850
+ profiles?: Record<string, ISubagentProfile>;
778
851
  }
779
852
  /**
780
853
  * Expose a whole agent as ONE tool of a parent agent: input `{ task }`,
@@ -785,5 +858,5 @@ interface ISubagentToolOptions {
785
858
  */
786
859
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
787
860
 
788
- export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
789
- export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
861
+ export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createRunControl, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
862
+ export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,57 @@ import { FetchLike } from '@modelcontextprotocol/sdk/shared/transport.js';
3
3
  import { ToolSet, LanguageModel, Tool, SystemModelMessage, ModelMessage } from 'ai';
4
4
  import { OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
5
5
 
6
+ /**
7
+ * Steering a run that is already going.
8
+ *
9
+ * `run()` takes one goal and returns when the run is over, so a host that wants to
10
+ * say something mid-run — "actually use the staging database" — or stop one
11
+ * subagent out of several has nothing to call. A `RunControl` is the handle: create
12
+ * one, pass it as `run(goal, { control })`, and use it from anywhere while the run
13
+ * is in flight.
14
+ *
15
+ * A message is not interrupt. The run never cuts a tool call short (it may be a
16
+ * write): the message is held until the next boundary — the next tool-calling round
17
+ * inside a step, or the end of the step — and is then shown to the model. At a step
18
+ * boundary it also forces the replanner to look at the plan again, because a plan
19
+ * made before the user spoke may no longer be the right one.
20
+ */
21
+ /** One running subagent, as the host sees it. */
22
+ interface SubagentInfo {
23
+ id: string;
24
+ /** The subagent tool's `name`. */
25
+ name: string;
26
+ task: string;
27
+ /** The profile the parent chose for this call, when it chose one. */
28
+ profile?: string;
29
+ startedAt: number;
30
+ }
31
+ interface RunControl {
32
+ /**
33
+ * Queue a message for the run. `false` when there is nothing to deliver it to — the text
34
+ * is empty, or the run has already finished (send it as a new run instead).
35
+ *
36
+ * Accepted does not mean delivered: a message that arrives after the last boundary
37
+ * (while the answer is being written) comes back in `RunResult.undelivered`, so the
38
+ * host can send it next.
39
+ */
40
+ send(text: string): boolean;
41
+ /**
42
+ * Messages sent and not yet delivered. Once the run is over: the ones it never got to show
43
+ * the model (the same list as `RunResult.undelivered`, which a run that threw cannot return).
44
+ */
45
+ pending(): string[];
46
+ /** The subagents running under this run right now (a snapshot; `subagent.*` events are the stream). */
47
+ subagents(): SubagentInfo[];
48
+ /**
49
+ * Stop ONE running subagent. Its delegation fails with a message the parent model can
50
+ * route around, and the run carries on — unlike aborting the run, which stops everything.
51
+ * `false` when no subagent with that id is running.
52
+ */
53
+ stopSubagent(id: string): boolean;
54
+ }
55
+ declare const createRunControl: () => RunControl;
56
+
6
57
  type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
7
58
  type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
8
59
  type ToolSelectionStrategy = 'all' | 'plan-narrowed' | 'search' | 'auto';
@@ -191,7 +242,7 @@ interface IStepResult {
191
242
  blocked: boolean;
192
243
  }
193
244
  type ReplanTrigger = 'failure' | 'always' | ((result: IStepResult) => boolean | Promise<boolean>);
194
- type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision';
245
+ type ReplanCause = 'last-step' | 'clean-step' | 'llm-decision' | 'user-message';
195
246
  type UsagePhase = 'plan' | 'execute' | 'replan' | 'synthesize' | 'compact' | 'subagent';
196
247
  type AgentEventBody = {
197
248
  type: 'plan.thought-delta';
@@ -299,6 +350,7 @@ type AgentEventBody = {
299
350
  id: string;
300
351
  name: string;
301
352
  task: string;
353
+ profile?: string;
302
354
  } | {
303
355
  type: 'subagent.event';
304
356
  id: string;
@@ -315,6 +367,16 @@ type AgentEventBody = {
315
367
  id: string;
316
368
  name: string;
317
369
  error: string;
370
+ stopped?: boolean;
371
+ } | {
372
+ type: 'message.queued';
373
+ id: string;
374
+ text: string;
375
+ } | {
376
+ type: 'message.delivered';
377
+ id: string;
378
+ text: string;
379
+ at: 'round' | 'step' | 'final';
318
380
  } | {
319
381
  type: 'revisions.exceeded';
320
382
  cap: number;
@@ -339,6 +401,7 @@ interface IAgentRunOptions {
339
401
  onEvent?: EventHandler;
340
402
  onStepStart?: (info: IStepStartInfo) => void;
341
403
  resumeFromRunId?: string;
404
+ control?: RunControl;
342
405
  }
343
406
  interface IAgentRunResult {
344
407
  text: string;
@@ -347,6 +410,7 @@ interface IAgentRunResult {
347
410
  iterations: number;
348
411
  usage: IUsage;
349
412
  compactedHistory?: IConversationTurn[];
413
+ undelivered?: string[];
350
414
  }
351
415
  interface IRunSnapshot {
352
416
  runId: string;
@@ -367,6 +431,10 @@ interface IRunSnapshot {
367
431
  traceSummaryUpTo?: number;
368
432
  activeSkills?: string[];
369
433
  toolCallCount?: number;
434
+ userUpdates?: {
435
+ text: string;
436
+ reconciled: boolean;
437
+ }[];
370
438
  }
371
439
  interface IPersistence {
372
440
  onRunStart?: (snapshot: IRunSnapshot) => void | Promise<void>;
@@ -765,6 +833,10 @@ interface IClearedInfo {
765
833
  declare const createToolResultClearer: (opts: IToolResultClearing, onCleared?: (info: IClearedInfo) => void) => ((messages: ModelMessage[]) => ModelMessage[]);
766
834
 
767
835
  type SubagentIsolation = 'worker' | 'in-process';
836
+ interface ISubagentProfile {
837
+ description: string;
838
+ config?: Partial<IAgentConfig>;
839
+ }
768
840
  interface ISubagentToolOptions {
769
841
  name: string;
770
842
  description: string;
@@ -775,6 +847,7 @@ interface ISubagentToolOptions {
775
847
  timeoutMs?: number;
776
848
  outputMaxChars?: number;
777
849
  readOnly?: boolean;
850
+ profiles?: Record<string, ISubagentProfile>;
778
851
  }
779
852
  /**
780
853
  * Expose a whole agent as ONE tool of a parent agent: input `{ task }`,
@@ -785,5 +858,5 @@ interface ISubagentToolOptions {
785
858
  */
786
859
  declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
787
860
 
788
- export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
789
- export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };
861
+ export { FileOAuthStore, MemoryOAuthStore, NodeOAuthProvider, SUMMARY_PREFIX, ToolBudgetError, ToolDeniedError, addUsage, beginMcpOAuth, buildInstructions, checkLimits, compactHistory, createAgent, createNodeOAuthProvider, createRunControl, createSubagentTool, createToolResultClearer, decideToolPermission, defineSkill, estimateTokens, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, isReadOnlyTool, loadSkillsFromDir, markReadOnly, matchToolRule, mergeProviderOptions, normalizeUsage, parseSkillMarkdown, redactHeaders, resolveLimits, resolvePromptCaching, resolveThinking, searchTools, truncateToolModelOutput, withRollingBreakpoint, withToolOutputLimit };
862
+ export type { AgentEvent, AgentStage, BudgetKind, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, ILimitBreach, IMcpHttpServerConfig, IMcpServerConfig, IMcpStdioServerConfig, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IPersistence, IPlan, IPlanStep, IResolvedThinking, IRunSnapshot, ISearchToolsOptions, ISkill, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, IUsage, LogLevel, PromptCachingSetting, ProviderType, ReplanCause, ReplanTrigger, RunControl, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TokenLimitKind, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolSelectionStrategy, UsagePhase };